@jupyter-widgets/base

  • Version 6.0.7
  • Published
  • 119 kB
  • 9 dependencies
  • BSD-3-Clause license

Install

npm i @jupyter-widgets/base
yarn add @jupyter-widgets/base
pnpm add @jupyter-widgets/base

Overview

Jupyter interactive widgets

Index

Variables

Functions

Classes

Interfaces

Type Aliases

Namespaces

Variables

variable assign

const assign: any;
  • A polyfill for Object.assign

    This is from code that Typescript 2.4 generates for a polyfill.

variable BROKEN_FILE_SVG_ICON

const BROKEN_FILE_SVG_ICON: string;

    variable IJupyterWidgetRegistry

    const IJupyterWidgetRegistry: Token<IJupyterWidgetRegistry>;
    • A runtime interface token for a widget registry.

    variable JUPYTER_WIDGETS_VERSION

    const JUPYTER_WIDGETS_VERSION: string;

      variable JupyterPhosphorWidget

      const JupyterPhosphorWidget: typeof JupyterLuminoWidget;

      variable PROTOCOL_VERSION

      const PROTOCOL_VERSION: string;

        Functions

        function createErrorWidgetModel

        createErrorWidgetModel: (error: unknown, msg?: string) => typeof WidgetModel;

          function createErrorWidgetView

          createErrorWidgetView: (error?: unknown, msg?: string) => typeof WidgetView;

            function difference

            difference: (a: string[], b: string[]) => string[];
            • Find all strings in the first argument that are not in the second.

            function isEqual

            isEqual: (a: unknown, b: unknown) => boolean;
            • Compare two objects deeply to see if they are equal.

            function isObject

            isObject: (data: BufferJSON) => data is Dict<BufferJSON>;

              function isSerializable

              isSerializable: (object: unknown) => object is ISerializeable;

                function pack_models

                pack_models: (
                value: WidgetModel | Dict<WidgetModel> | WidgetModel[] | any,
                widget?: WidgetModel
                ) => any | Dict<unknown> | string | (Dict<unknown> | string)[];
                • Replace models with ids recursively.

                  If the commonly-used unpack_models is given as the deseralize method, pack_models would be the appropriate serialize. However, the default serialize method will have the same effect, when unpack_models is used as the deserialize method. This is to ensure backwards compatibility, see: https://github.com/jupyter-widgets/ipywidgets/pull/3738/commits/f9e27328bb631eb5247a7a6563595d3e655492c7#diff-efb19099381ae8911dd7f69b015a0138d08da7164512c1ee112aa75100bc9be2

                function put_buffers

                put_buffers: (
                state: Dict<BufferJSON>,
                buffer_paths: (string | number)[][],
                buffers: (DataView | ArrayBuffer | ArrayBufferView | { buffer: ArrayBuffer })[]
                ) => void;
                • Takes an object 'state' and fills in buffer[i] at 'path' buffer_paths[i] where buffer_paths[i] is a list indicating where in the object buffer[i] should be placed Example: state = {a: 1, b: {}, c: [0, null]} buffers = [array1, array2] buffer_paths = [['b', 'data'], ['c', 1]] Will lead to {a: 1, b: {data: array1}, c: [0, array2]}

                function reject

                reject: (message: string, log: boolean) => (error: Error) => never;
                • Creates a wrappable Promise rejection function.

                  Creates a function that logs an error message before rethrowing the original error that caused the promise to reject.

                function remove_buffers

                remove_buffers: (state: BufferJSON | ISerializeable) => ISerializedState;
                • The inverse of put_buffers, return an objects with the new state where all buffers(ArrayBuffer) are removed. If a buffer is a member of an object, that object is cloned, and the key removed. If a buffer is an element of an array, that array is cloned, and the element is set to null. See put_buffers for the meaning of buffer_paths Returns an object with the new state (.state) an array with paths to the buffers (.buffer_paths), and the buffers associated to those paths (.buffers).

                function resolvePromisesDict

                resolvePromisesDict: <V>(d: Dict<PromiseLike<V> | V>) => Promise<Dict<V>>;
                • Resolve a promiseful dictionary. Returns a single Promise.

                function unpack_models

                unpack_models: (
                value: any | Dict<unknown> | string | (Dict<unknown> | string)[],
                manager?: IWidgetManager
                ) => Promise<WidgetModel | Dict<WidgetModel> | WidgetModel[] | any>;
                • Replace model ids with models recursively.

                function uuid

                uuid: () => string;
                • Generate a UUID

                  http://www.ietf.org/rfc/rfc4122.txt

                Classes

                class DOMWidgetModel

                class DOMWidgetModel extends WidgetModel {}

                  property serializers

                  static serializers: ISerializers;

                    method defaults

                    defaults: () => Backbone.ObjectHash;

                      class DOMWidgetView

                      class DOMWidgetView extends WidgetView {}

                        property '$el'

                        '$el': any;

                          property el

                          el: HTMLElement;

                            property layoutPromise

                            layoutPromise: Promise<any>;

                              property luminoWidget

                              luminoWidget: Widget;

                                property pWidget

                                readonly pWidget: Widget;

                                property stylePromise

                                stylePromise: Promise<any>;

                                  method initialize

                                  initialize: (parameters: WidgetView.IInitializeParameters) => void;
                                  • Public constructor

                                  method processLuminoMessage

                                  processLuminoMessage: (msg: Message) => void;

                                    method remove

                                    remove: () => any;

                                      method set_mapped_classes

                                      set_mapped_classes: (
                                      class_map: Dict<string[]>,
                                      trait_name: string,
                                      el?: HTMLElement
                                      ) => void;

                                        method setLayout

                                        setLayout: (layout: LayoutModel, oldLayout?: LayoutModel) => void;

                                          method setStyle

                                          setStyle: (style: StyleModel, oldStyle?: StyleModel) => void;

                                            method update_classes

                                            update_classes: (
                                            old_classes: string[],
                                            new_classes: string[],
                                            el?: HTMLElement
                                            ) => void;
                                            • Update the DOM classes applied to an element, default to this.el.

                                            method update_mapped_classes

                                            update_mapped_classes: (
                                            class_map: Dict<string[]>,
                                            trait_name: string,
                                            el?: HTMLElement
                                            ) => void;
                                            • Update the DOM classes applied to the widget based on a single trait's value.

                                              Given a trait value classes map, this function automatically handles applying the appropriate classes to the widget element and removing classes that are no longer valid.

                                              Parameters ---------- class_map: dictionary Dictionary of trait values to class lists. Example: { success: ['alert', 'alert-success'], info: ['alert', 'alert-info'], warning: ['alert', 'alert-warning'], danger: ['alert', 'alert-danger'] }; trait_name: string Name of the trait to check the value of. el: optional DOM element handle, defaults to this.el Element that the classes are applied to.

                                            method updateTabindex

                                            updateTabindex: () => void;

                                              method updateTooltip

                                              updateTooltip: () => void;

                                                class ErrorWidgetView

                                                class ErrorWidgetView extends DOMWidgetView {}

                                                  method generateErrorMessage

                                                  generateErrorMessage: () => { msg?: string; stack: string };

                                                    method render

                                                    render: () => void;

                                                      class JupyterLuminoPanelWidget

                                                      class JupyterLuminoPanelWidget extends Panel {}

                                                        constructor

                                                        constructor(options: any);

                                                          method dispose

                                                          dispose: () => void;
                                                          • Dispose the widget.

                                                            This causes the view to be destroyed as well with 'remove'

                                                          method processMessage

                                                          processMessage: (msg: Message) => void;
                                                          • Process the Lumino message.

                                                            Any custom Lumino widget used inside a Jupyter widget should override the processMessage function like this.

                                                          class JupyterLuminoWidget

                                                          class JupyterLuminoWidget extends Widget {}

                                                            constructor

                                                            constructor(options: any);

                                                              method dispose

                                                              dispose: () => void;
                                                              • Dispose the widget.

                                                                This causes the view to be destroyed as well with 'remove'

                                                              method processMessage

                                                              processMessage: (msg: Message) => void;
                                                              • Process the Lumino message.

                                                                Any custom Lumino widget used inside a Jupyter widget should override the processMessage function like this.

                                                              class LayoutModel

                                                              class LayoutModel extends WidgetModel {}

                                                                method defaults

                                                                defaults: () => Backbone.ObjectHash;

                                                                  class LayoutView

                                                                  class LayoutView extends WidgetView {}

                                                                    method css_name

                                                                    css_name: (trait: string) => string;
                                                                    • Get the the name of the css property from the trait name

                                                                      Parameter model

                                                                      attribute name css property name

                                                                    method handleChange

                                                                    handleChange: (trait: string, value: any) => void;
                                                                    • Handles when a trait value changes

                                                                    method initialize

                                                                    initialize: (parameters: WidgetView.IInitializeParameters) => void;
                                                                    • Public constructor

                                                                    method registerTrait

                                                                    registerTrait: (trait: string) => void;
                                                                    • Register a CSS trait that is known by the model

                                                                      Parameter trait

                                                                    method unlayout

                                                                    unlayout: () => void;
                                                                    • Remove the styling from the parent view.

                                                                    class StyleModel

                                                                    class StyleModel extends WidgetModel {}
                                                                    • Three functions to deal with some CSS attributes to make them easier to use.

                                                                    property styleProperties

                                                                    static styleProperties: { [s: string]: IStyleProperty };

                                                                      method defaults

                                                                      defaults: () => Backbone.ObjectHash;

                                                                        class StyleView

                                                                        class StyleView extends WidgetView {}

                                                                          method handleChange

                                                                          handleChange: (trait: string, value: any) => void;
                                                                          • Handles when a trait value changes

                                                                          method initialize

                                                                          initialize: (parameters: WidgetView.IInitializeParameters) => void;
                                                                          • Public constructor

                                                                          method registerTrait

                                                                          registerTrait: (trait: string) => void;
                                                                          • Register a CSS trait that is known by the model

                                                                            Parameter trait

                                                                          method style

                                                                          style: () => void;
                                                                          • Apply styles for all registered traits

                                                                          method unstyle

                                                                          unstyle: () => void;
                                                                          • Remove the styling from the parent view.

                                                                          class ViewList

                                                                          class ViewList<T> {}
                                                                          • - create_view and remove_view are default functions called when adding or removing views - create_view takes a model and an index and returns a view or a promise for a view for that model - remove_view takes a view and destroys it (including calling view.remove()) - each time the update() function is called with a new list, the create and remove callbacks will be called in an order so that if you append the views created in the create callback and remove the views in the remove callback, you will duplicate the order of the list. - the remove callback defaults to just removing the view (e.g., pass in null for the second parameter) - the context defaults to the created ViewList. If you pass another context, the create and remove will be called in that context.

                                                                          constructor

                                                                          constructor(
                                                                          create_view: (model: any, index: any) => T | Promise<T>,
                                                                          remove_view: (view: T) => void,
                                                                          context: any
                                                                          );

                                                                            property views

                                                                            views: Promise<T>[];

                                                                              method dispose

                                                                              dispose: () => void;
                                                                              • Dispose this viewlist.

                                                                                A synchronous function which just deletes references to child views. This function does not call .remove() on child views because that is asynchronous. Use this in cases where child views will be removed in another way.

                                                                              method initialize

                                                                              initialize: (
                                                                              create_view: (model: any, index: any) => T | Promise<T>,
                                                                              remove_view: (view: T) => void,
                                                                              context: any
                                                                              ) => void;

                                                                                method remove

                                                                                remove: () => Promise<void>;
                                                                                • removes every view in the list; convenience function for .update([]) that should be faster returns a promise that resolves after this removal is done

                                                                                method update

                                                                                update: (
                                                                                new_models: any[],
                                                                                create_view?: (model: any, index: any) => T | Promise<T>,
                                                                                remove_view?: (view: T) => void,
                                                                                context?: any
                                                                                ) => Promise<T[]>;
                                                                                • the create_view, remove_view, and context arguments override the defaults specified when the list is created. after this function, the .views attribute is a list of promises for views if you want to perform some action on the list of views, do something like Promise.all(myviewlist.views).then(function(views) {...});

                                                                                class WidgetModel

                                                                                class WidgetModel extends Backbone.Model {}

                                                                                  property comm

                                                                                  comm?: IClassicComm;

                                                                                    property comm_live

                                                                                    comm_live: boolean;

                                                                                      property model_id

                                                                                      model_id: string;

                                                                                        property module

                                                                                        module: string;

                                                                                          property name

                                                                                          name: string;

                                                                                            property serializers

                                                                                            static serializers: ISerializers;

                                                                                              property state_change

                                                                                              state_change: Promise<any>;

                                                                                                property views

                                                                                                views?: { [key: string]: Promise<WidgetView> };

                                                                                                  property widget_manager

                                                                                                  widget_manager: IWidgetManager;

                                                                                                    method callbacks

                                                                                                    callbacks: (view?: WidgetView) => ICallbacks;
                                                                                                    • Create msg callbacks for a comm msg.

                                                                                                    method close

                                                                                                    close: (comm_closed?: boolean) => Promise<void>;
                                                                                                    • Close model

                                                                                                      Parameter comm_closed

                                                                                                      true if the comm is already being closed. If false, the comm will be closed.

                                                                                                      Returns

                                                                                                      - a promise that is fulfilled when all the associated views have been removed.

                                                                                                    method defaults

                                                                                                    defaults: () => Backbone.ObjectHash;
                                                                                                    • The default attributes.

                                                                                                    method get_state

                                                                                                    get_state: (drop_defaults?: boolean) => JSONObject;
                                                                                                    • Get the serializable state of the model.

                                                                                                      If drop_default is truthy, attributes that are equal to their default values are dropped.

                                                                                                    method initialize

                                                                                                    initialize: (
                                                                                                    attributes: Backbone.ObjectHash,
                                                                                                    options: IBackboneModelOptions
                                                                                                    ) => void;
                                                                                                    • Constructor

                                                                                                      Initializes a WidgetModel instance. Called by the Backbone constructor.

                                                                                                      Parameters ---------- widget_manager : WidgetManager instance model_id : string An ID unique to this model. comm : Comm instance (optional)

                                                                                                    method isNew

                                                                                                    isNew: () => boolean;
                                                                                                    • Test to see if the model has been synced with the server.

                                                                                                      #### Notes As of backbone 1.1, backbone ignores patch if it thinks the model has never been pushed.

                                                                                                    method on_some_change

                                                                                                    on_some_change: (
                                                                                                    keys: string[],
                                                                                                    callback: (...args: any[]) => void,
                                                                                                    context: any
                                                                                                    ) => void;
                                                                                                    • on_some_change(['key1', 'key2'], foo, context) differs from on('change:key1 change:key2', foo, context). If the widget attributes key1 and key2 are both modified, the second form will result in foo being called twice while the first will call foo only once.

                                                                                                    method rememberLastUpdateFor

                                                                                                    rememberLastUpdateFor: (msgId: string) => void;

                                                                                                      method save_changes

                                                                                                      save_changes: (callbacks?: {}) => void;
                                                                                                      • Push this model's state to the back-end

                                                                                                        This invokes a Backbone.Sync.

                                                                                                      method send

                                                                                                      send: (
                                                                                                      content: JSONValue,
                                                                                                      callbacks?: ICallbacks,
                                                                                                      buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                                      ) => void;
                                                                                                      • Send a custom msg over the comm.

                                                                                                      method send_sync_message

                                                                                                      send_sync_message: (state: JSONObject, callbacks?: any) => string;
                                                                                                      • Send a sync message to the kernel.

                                                                                                        If a message is sent successfully, this returns the message ID of that message. Otherwise it returns an empty string

                                                                                                      method serialize

                                                                                                      serialize: (state: Dict<any>) => JSONObject;
                                                                                                      • Serialize widget state.

                                                                                                        A serializer is a function which takes in a state attribute and a widget, and synchronously returns a JSONable object. The returned object will have toJSON called if possible, and the final result should be a primitive object that is a snapshot of the widget state that may have binary array buffers.

                                                                                                      method set

                                                                                                      set: (key: any, val?: any, options?: any) => any;
                                                                                                      • Set one or more values.

                                                                                                        We just call the super method, in which val and options are optional. Handles both "key", value and {key: value} -style arguments.

                                                                                                      method set_state

                                                                                                      set_state: (state: Dict<unknown>) => void;
                                                                                                      • Handle when a widget is updated from the backend.

                                                                                                        This function is meant for internal use only. Values set here will not be propagated on a sync.

                                                                                                      method sync

                                                                                                      sync: (method: string, model: WidgetModel, options?: any) => any;
                                                                                                      • Handle sync to the back-end. Called when a model.save() is called.

                                                                                                        Make sure a comm exists.

                                                                                                        Parameters ---------- method : create, update, patch, delete, read create/update always send the full attribute set patch - only send attributes listed in options.attrs, and if we are queuing up messages, combine with previous messages that have not been sent yet model : the model we are syncing will normally be the same as this options : dict the attrs key, if it exists, gives an {attr: value} dict that should be synced, otherwise, sync all attributes.

                                                                                                      method toJSON

                                                                                                      toJSON: (options?: {}) => string;
                                                                                                      • Serialize the model. See the deserialization function at the top of this file and the kernel-side serializer/deserializer.

                                                                                                      class WidgetView

                                                                                                      class WidgetView extends NativeView<WidgetModel> {}

                                                                                                        constructor

                                                                                                        constructor(options?: any);
                                                                                                        • Public constructor.

                                                                                                        property displayed

                                                                                                        displayed: Promise<WidgetView>;
                                                                                                        • A promise that resolves to the parent view when a child view is displayed.

                                                                                                        property options

                                                                                                        options: any;

                                                                                                          method callbacks

                                                                                                          callbacks: () => ICallbacks;
                                                                                                          • Create msg callbacks for a comm msg.

                                                                                                          method create_child_view

                                                                                                          create_child_view: {
                                                                                                          <VT extends DOMWidgetView = DOMWidgetView>(
                                                                                                          child_model: DOMWidgetModel,
                                                                                                          options?: any
                                                                                                          ): Promise<VT>;
                                                                                                          <VT extends WidgetView = WidgetView>(
                                                                                                          child_model: WidgetModel,
                                                                                                          options?: any
                                                                                                          ): Promise<VT>;
                                                                                                          };
                                                                                                          • Create and promise that resolves to a child view of a given model

                                                                                                          method handle_message

                                                                                                          handle_message: (content: any) => void;
                                                                                                          • Handle message sent to the front end.

                                                                                                            Used to focus or blur the widget.

                                                                                                          method initialize

                                                                                                          initialize: (parameters: WidgetView.IInitializeParameters) => void;
                                                                                                          • Initializer, called at the end of the constructor.

                                                                                                          method remove

                                                                                                          remove: () => any;

                                                                                                            method render

                                                                                                            render: () => any;
                                                                                                            • Render a view

                                                                                                              Returns

                                                                                                              the view or a promise to the view.

                                                                                                            method send

                                                                                                            send: (content: {}, buffers?: ArrayBuffer[] | ArrayBufferView[]) => void;
                                                                                                            • Send a custom msg associated with this view.

                                                                                                            method touch

                                                                                                            touch: () => void;

                                                                                                              method update

                                                                                                              update: (options?: any) => void;
                                                                                                              • Triggered on model change.

                                                                                                                Update view to be consistent with this.model

                                                                                                              Interfaces

                                                                                                              interface IBackboneModelOptions

                                                                                                              interface IBackboneModelOptions extends Backbone.ModelSetOptions {}

                                                                                                                property comm

                                                                                                                comm?: any;

                                                                                                                  property model_id

                                                                                                                  model_id: string;

                                                                                                                    property widget_manager

                                                                                                                    widget_manager: any;

                                                                                                                      interface ICallbacks

                                                                                                                      interface ICallbacks {}
                                                                                                                      • Callbacks for services shim comms.

                                                                                                                      property input

                                                                                                                      input?: (msg: KernelMessage.IStdinMessage) => void;

                                                                                                                        property iopub

                                                                                                                        iopub?: {
                                                                                                                        [key: string]: (msg: KernelMessage.IIOPubMessage) => void;
                                                                                                                        };

                                                                                                                          property shell

                                                                                                                          shell?: {
                                                                                                                          [key: string]: (msg: KernelMessage.IShellMessage) => void;
                                                                                                                          };

                                                                                                                            interface IClassicComm

                                                                                                                            interface IClassicComm {}

                                                                                                                              property comm_id

                                                                                                                              comm_id: string;
                                                                                                                              • Comm id {string}

                                                                                                                              property target_name

                                                                                                                              target_name: string;
                                                                                                                              • Target name {string}

                                                                                                                              method close

                                                                                                                              close: (
                                                                                                                              data?: JSONValue,
                                                                                                                              callbacks?: ICallbacks,
                                                                                                                              metadata?: JSONObject,
                                                                                                                              buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                                                              ) => string;
                                                                                                                              • Closes the sibling comm in the backend

                                                                                                                                Parameter data

                                                                                                                                Parameter callbacks

                                                                                                                                Parameter metadata

                                                                                                                                Parameter buffers

                                                                                                                                msg id

                                                                                                                              method on_close

                                                                                                                              on_close: (callback: (x: any) => void) => void;
                                                                                                                              • Register a handler for when the comm is closed by the backend

                                                                                                                                Parameter callback

                                                                                                                                , which is given a message

                                                                                                                              method on_msg

                                                                                                                              on_msg: (callback: (x: any) => void) => void;
                                                                                                                              • Register a message handler

                                                                                                                                Parameter callback

                                                                                                                                , which is given a message

                                                                                                                              method open

                                                                                                                              open: (
                                                                                                                              data: JSONValue,
                                                                                                                              callbacks?: ICallbacks,
                                                                                                                              metadata?: JSONObject,
                                                                                                                              buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                                                              ) => string;
                                                                                                                              • Opens a sibling comm in the backend

                                                                                                                                Parameter data

                                                                                                                                Parameter callbacks

                                                                                                                                Parameter metadata

                                                                                                                                Parameter buffers

                                                                                                                                msg id

                                                                                                                              method send

                                                                                                                              send: (
                                                                                                                              data: JSONValue,
                                                                                                                              callbacks?: ICallbacks,
                                                                                                                              metadata?: JSONObject,
                                                                                                                              buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                                                              ) => string;
                                                                                                                              • Sends a message to the sibling comm in the backend

                                                                                                                                Parameter data

                                                                                                                                Parameter callbacks

                                                                                                                                Parameter metadata

                                                                                                                                Parameter buffers

                                                                                                                                message id

                                                                                                                              interface IJupyterWidgetRegistry

                                                                                                                              interface IJupyterWidgetRegistry {}
                                                                                                                              • A registry of Jupyter Widgets.

                                                                                                                                This is used by widget managers that support an external registry.

                                                                                                                              method registerWidget

                                                                                                                              registerWidget: (data: IWidgetRegistryData) => void;
                                                                                                                              • Register a widget module.

                                                                                                                              interface IModelOptions

                                                                                                                              interface IModelOptions {}
                                                                                                                              • The options for a model.

                                                                                                                                #### Notes Either a comm or a model_id must be provided.

                                                                                                                              property comm

                                                                                                                              comm?: any;
                                                                                                                              • Comm object associated with the widget.

                                                                                                                              property model_id

                                                                                                                              model_id?: string;
                                                                                                                              • The model id to use. If not provided, the comm id of the comm is used.

                                                                                                                              property model_module

                                                                                                                              model_module: string;
                                                                                                                              • Module name of the widget model to create.

                                                                                                                              property model_module_version

                                                                                                                              model_module_version: string;
                                                                                                                              • Semver version requirement for the model module.

                                                                                                                              property model_name

                                                                                                                              model_name: string;
                                                                                                                              • Target name of the widget model to create.

                                                                                                                              property view_module

                                                                                                                              view_module?: string | null;
                                                                                                                              • Module name of the widget view to create.

                                                                                                                              property view_module_version

                                                                                                                              view_module_version?: string;
                                                                                                                              • Semver version requirement for the view module.

                                                                                                                              property view_name

                                                                                                                              view_name?: string | null;
                                                                                                                              • Target name of the widget view to create.

                                                                                                                              interface ISerializeable

                                                                                                                              interface ISerializeable {}

                                                                                                                                method toJSON

                                                                                                                                toJSON: (options?: {}) => JSONObject;

                                                                                                                                  interface ISerializedState

                                                                                                                                  interface ISerializedState {}

                                                                                                                                    property buffer_paths

                                                                                                                                    buffer_paths: (string | number)[][];

                                                                                                                                      property buffers

                                                                                                                                      buffers: ArrayBuffer[];

                                                                                                                                        property state

                                                                                                                                        state: JSONObject;

                                                                                                                                          interface ISerializers

                                                                                                                                          interface ISerializers {}
                                                                                                                                          • Type declaration for general widget serializers.

                                                                                                                                          index signature

                                                                                                                                          [key: string]: {
                                                                                                                                          deserialize?: (value?: any, manager?: IWidgetManager) => any;
                                                                                                                                          serialize?: (value?: any, widget?: WidgetModel) => any;
                                                                                                                                          };

                                                                                                                                            interface IWidgetManager

                                                                                                                                            interface IWidgetManager {}
                                                                                                                                            • The widget manager interface exposed on the Widget instances

                                                                                                                                            method callbacks

                                                                                                                                            callbacks: (view?: WidgetView) => ICallbacks;
                                                                                                                                            • callback handlers specific to a view

                                                                                                                                            method create_view

                                                                                                                                            create_view: {
                                                                                                                                            <VT extends DOMWidgetView = DOMWidgetView>(
                                                                                                                                            model: DOMWidgetModel,
                                                                                                                                            options?: unknown
                                                                                                                                            ): Promise<VT>;
                                                                                                                                            <VT extends WidgetView = WidgetView>(
                                                                                                                                            model: WidgetModel,
                                                                                                                                            options?: unknown
                                                                                                                                            ): Promise<VT>;
                                                                                                                                            };
                                                                                                                                            • Creates a promise for a view of a given model

                                                                                                                                              Make sure the view creation is not out of order with any state updates.

                                                                                                                                            method get_model

                                                                                                                                            get_model: (model_id: string) => Promise<WidgetModel>;
                                                                                                                                            • Get a promise for a model by model id.

                                                                                                                                              #### Notes If a model is not found, undefined is returned (NOT a promise). However, the calling code should also deal with the case where a rejected promise is returned, and should treat that also as a model not found.

                                                                                                                                            method has_model

                                                                                                                                            has_model: (model_id: string) => boolean;
                                                                                                                                            • Returns true if the given model is registered, otherwise false.

                                                                                                                                              #### Notes This is a synchronous way to check if a model is registered.

                                                                                                                                            method inline_sanitize

                                                                                                                                            inline_sanitize: (s: string) => string;

                                                                                                                                              method new_model

                                                                                                                                              new_model: (
                                                                                                                                              options: IModelOptions,
                                                                                                                                              serialized_state?: JSONObject
                                                                                                                                              ) => Promise<WidgetModel>;
                                                                                                                                              • Create and return a promise for a new widget model

                                                                                                                                                Parameter options

                                                                                                                                                the options for creating the model.

                                                                                                                                                Parameter serialized_state

                                                                                                                                                attribute values for the model.

                                                                                                                                                Example 1

                                                                                                                                                widget_manager.new_model({ model_name: 'IntSlider', model_module: '@jupyter-widgets/controls', model_module_version: '1.0.0', model_id: 'u-u-i-d' }).then((model) => { console.log('Create success!', model); }, (err) => {console.error(err)});

                                                                                                                                              method new_widget

                                                                                                                                              new_widget: (
                                                                                                                                              options: IWidgetOptions,
                                                                                                                                              serialized_state?: JSONObject
                                                                                                                                              ) => Promise<WidgetModel>;
                                                                                                                                              • Create a comm and new widget model.

                                                                                                                                                Parameter options

                                                                                                                                                same options as new_model but comm is not required and additional options are available.

                                                                                                                                                Parameter serialized_state

                                                                                                                                                serialized model attributes.

                                                                                                                                              method register_model

                                                                                                                                              register_model: (model_id: string, modelPromise: Promise<WidgetModel>) => void;
                                                                                                                                              • Register a model instance promise with the manager.

                                                                                                                                                By registering the model, it can later be retrieved with get_model.

                                                                                                                                              method resolveUrl

                                                                                                                                              resolveUrl: (url: string) => Promise<string>;
                                                                                                                                              • Resolve a URL relative to the current notebook location.

                                                                                                                                                The default implementation just returns the original url.

                                                                                                                                              interface IWidgetOptions

                                                                                                                                              interface IWidgetOptions extends IModelOptions {}
                                                                                                                                              • The options for a connected model.

                                                                                                                                                This gives all of the information needed to instantiate a comm to a new widget on the kernel side (so view information is mandatory).

                                                                                                                                                #### Notes Either a comm or a model_id must be provided.

                                                                                                                                              property comm

                                                                                                                                              comm?: IClassicComm;
                                                                                                                                              • Comm object associated with the widget.

                                                                                                                                              property model_id

                                                                                                                                              model_id?: string;
                                                                                                                                              • The model id to use. If not provided, the comm id of the comm is used.

                                                                                                                                              property model_module

                                                                                                                                              model_module: string;
                                                                                                                                              • Module name of the widget model to create.

                                                                                                                                              property model_module_version

                                                                                                                                              model_module_version: string;
                                                                                                                                              • Semver version requirement for the model module.

                                                                                                                                              property model_name

                                                                                                                                              model_name: string;
                                                                                                                                              • Target name of the widget model to create.

                                                                                                                                              property view_module

                                                                                                                                              view_module: string | null;
                                                                                                                                              • Module name of the widget view to create.

                                                                                                                                              property view_module_version

                                                                                                                                              view_module_version: string;
                                                                                                                                              • Semver version requirement for the view module.

                                                                                                                                              property view_name

                                                                                                                                              view_name: string | null;
                                                                                                                                              • Target name of the widget view to create.

                                                                                                                                              interface IWidgetRegistryData

                                                                                                                                              interface IWidgetRegistryData {}

                                                                                                                                                property exports

                                                                                                                                                exports: ExportData;
                                                                                                                                                • A map of object names to widget classes provided by the module, or a promise to such a map, or a function returning the same.

                                                                                                                                                property name

                                                                                                                                                name: string;
                                                                                                                                                • The widget module name.

                                                                                                                                                property version

                                                                                                                                                version: string;
                                                                                                                                                • The widget module version.

                                                                                                                                                Type Aliases

                                                                                                                                                type BufferJSON

                                                                                                                                                type BufferJSON =
                                                                                                                                                | {
                                                                                                                                                [property: string]: BufferJSON;
                                                                                                                                                }
                                                                                                                                                | BufferJSON[]
                                                                                                                                                | string
                                                                                                                                                | number
                                                                                                                                                | boolean
                                                                                                                                                | null
                                                                                                                                                | ArrayBuffer
                                                                                                                                                | DataView;

                                                                                                                                                  type Dict

                                                                                                                                                  type Dict<T> = {
                                                                                                                                                  [keys: string]: T;
                                                                                                                                                  };
                                                                                                                                                  • A simple dictionary type.

                                                                                                                                                  type ExportData

                                                                                                                                                  type ExportData =
                                                                                                                                                  | ExportMap
                                                                                                                                                  | Promise<ExportMap>
                                                                                                                                                  | (() => ExportMap)
                                                                                                                                                  | (() => Promise<ExportMap>);

                                                                                                                                                    type ExportMap

                                                                                                                                                    type ExportMap = {
                                                                                                                                                    [key: string]: typeof WidgetModel | typeof WidgetView;
                                                                                                                                                    };

                                                                                                                                                      Namespaces

                                                                                                                                                      namespace JupyterLuminoWidget

                                                                                                                                                      namespace JupyterLuminoWidget {}

                                                                                                                                                        interface IOptions

                                                                                                                                                        interface IOptions {}

                                                                                                                                                          property view

                                                                                                                                                          view: DOMWidgetView;

                                                                                                                                                            namespace shims

                                                                                                                                                            namespace shims {}

                                                                                                                                                              namespace shims.services

                                                                                                                                                              namespace shims.services {}

                                                                                                                                                                class Comm

                                                                                                                                                                class Comm implements IClassicComm {}
                                                                                                                                                                • Public constructor

                                                                                                                                                                  Parameter jsServicesComm

                                                                                                                                                                  @jupyterlab/services IComm instance

                                                                                                                                                                constructor

                                                                                                                                                                constructor(jsServicesComm: Kernel.IComm);

                                                                                                                                                                  property comm_id

                                                                                                                                                                  readonly comm_id: string;
                                                                                                                                                                  • Comm id {string}

                                                                                                                                                                  property jsServicesComm

                                                                                                                                                                  jsServicesComm: Kernel.IComm;

                                                                                                                                                                    property kernel

                                                                                                                                                                    kernel: Kernel.IKernelConnection;

                                                                                                                                                                      property target_name

                                                                                                                                                                      readonly target_name: string;
                                                                                                                                                                      • Target name {string}

                                                                                                                                                                      method close

                                                                                                                                                                      close: (
                                                                                                                                                                      data?: JSONValue,
                                                                                                                                                                      callbacks?: ICallbacks,
                                                                                                                                                                      metadata?: JSONObject,
                                                                                                                                                                      buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                                                                                                      ) => string;
                                                                                                                                                                      • Closes the sibling comm in the backend

                                                                                                                                                                        Parameter data

                                                                                                                                                                        Parameter callbacks

                                                                                                                                                                        Parameter metadata

                                                                                                                                                                        msg id

                                                                                                                                                                      method on_close

                                                                                                                                                                      on_close: (callback: (x: any) => void) => void;
                                                                                                                                                                      • Register a handler for when the comm is closed by the backend

                                                                                                                                                                        Parameter callback

                                                                                                                                                                        , which is given a message

                                                                                                                                                                      method on_msg

                                                                                                                                                                      on_msg: (callback: (x: any) => void) => void;
                                                                                                                                                                      • Register a message handler

                                                                                                                                                                        Parameter callback

                                                                                                                                                                        , which is given a message

                                                                                                                                                                      method open

                                                                                                                                                                      open: (
                                                                                                                                                                      data: JSONValue,
                                                                                                                                                                      callbacks?: ICallbacks,
                                                                                                                                                                      metadata?: JSONObject,
                                                                                                                                                                      buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                                                                                                      ) => string;
                                                                                                                                                                      • Opens a sibling comm in the backend

                                                                                                                                                                        Parameter data

                                                                                                                                                                        Parameter callbacks

                                                                                                                                                                        Parameter metadata

                                                                                                                                                                        msg id

                                                                                                                                                                      method send

                                                                                                                                                                      send: (
                                                                                                                                                                      data: JSONValue,
                                                                                                                                                                      callbacks?: ICallbacks,
                                                                                                                                                                      metadata?: JSONObject,
                                                                                                                                                                      buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                                                                                                      ) => string;
                                                                                                                                                                      • Sends a message to the sibling comm in the backend

                                                                                                                                                                        Parameter data

                                                                                                                                                                        Parameter callbacks

                                                                                                                                                                        Parameter metadata

                                                                                                                                                                        Parameter buffers

                                                                                                                                                                        message id

                                                                                                                                                                      class CommManager

                                                                                                                                                                      class CommManager {}
                                                                                                                                                                      • Public constructor

                                                                                                                                                                        Parameter jsServicesKernel

                                                                                                                                                                        @jupyterlab/services Kernel.IKernel instance

                                                                                                                                                                      constructor

                                                                                                                                                                      constructor(jsServicesKernel: Kernel.IKernelConnection);

                                                                                                                                                                        property comms

                                                                                                                                                                        comms: any;

                                                                                                                                                                          property jsServicesKernel

                                                                                                                                                                          jsServicesKernel: Kernel.IKernelConnection;

                                                                                                                                                                            property kernel

                                                                                                                                                                            kernel: Kernel.IKernelConnection;

                                                                                                                                                                              property targets

                                                                                                                                                                              targets: any;

                                                                                                                                                                                method init_kernel

                                                                                                                                                                                init_kernel: (jsServicesKernel: Kernel.IKernelConnection) => void;
                                                                                                                                                                                • Hookup kernel events.

                                                                                                                                                                                  Parameter jsServicesKernel

                                                                                                                                                                                  @jupyterlab/services Kernel.IKernel instance

                                                                                                                                                                                method new_comm

                                                                                                                                                                                new_comm: (
                                                                                                                                                                                target_name: string,
                                                                                                                                                                                data: any,
                                                                                                                                                                                callbacks: any,
                                                                                                                                                                                metadata: any,
                                                                                                                                                                                comm_id: string,
                                                                                                                                                                                buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                                                                                                                ) => Promise<Comm>;
                                                                                                                                                                                • Creates a new connected comm

                                                                                                                                                                                method register_comm

                                                                                                                                                                                register_comm: (comm: Comm) => string;
                                                                                                                                                                                • Register a comm in the mapping

                                                                                                                                                                                method register_target

                                                                                                                                                                                register_target: (
                                                                                                                                                                                target_name: string,
                                                                                                                                                                                f: (comm: Comm, object: KernelMessage.IMessage) => void
                                                                                                                                                                                ) => void;
                                                                                                                                                                                • Register a comm target

                                                                                                                                                                                  Parameter target_name

                                                                                                                                                                                  Parameter f

                                                                                                                                                                                  callback that is called when the comm is made. Signature of f(comm, msg).

                                                                                                                                                                                method unregister_target

                                                                                                                                                                                unregister_target: (
                                                                                                                                                                                target_name: string,
                                                                                                                                                                                f: (comm: Comm, object: KernelMessage.IMessage) => void
                                                                                                                                                                                ) => void;
                                                                                                                                                                                • Unregisters a comm target

                                                                                                                                                                                  Parameter target_name

                                                                                                                                                                                namespace WidgetView

                                                                                                                                                                                namespace WidgetView {}

                                                                                                                                                                                  interface IInitializeParameters

                                                                                                                                                                                  interface IInitializeParameters<T extends WidgetModel = WidgetModel>
                                                                                                                                                                                  extends Backbone.ViewOptions<T> {}

                                                                                                                                                                                    property options

                                                                                                                                                                                    options: any;

                                                                                                                                                                                      Package Files (11)

                                                                                                                                                                                      Dependencies (9)

                                                                                                                                                                                      Dev Dependencies (27)

                                                                                                                                                                                      Peer Dependencies (0)

                                                                                                                                                                                      No peer dependencies.

                                                                                                                                                                                      Badge

                                                                                                                                                                                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@jupyter-widgets/base.

                                                                                                                                                                                      • Markdown
                                                                                                                                                                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@jupyter-widgets/base)
                                                                                                                                                                                      • HTML
                                                                                                                                                                                        <a href="https://www.jsdocs.io/package/@jupyter-widgets/base"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>