@jupyter-widgets/base

  • Version 4.1.0
  • Published
  • 165 kB
  • 10 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

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

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

variable CONTROL_COMM_PROTOCOL_VERSION

const CONTROL_COMM_PROTOCOL_VERSION: string;
  • The supported version for the control comm channel.

variable CONTROL_COMM_TARGET

const CONTROL_COMM_TARGET: string;
  • The control comm target name.

variable CONTROL_COMM_TIMEOUT

const CONTROL_COMM_TIMEOUT: number;
  • Time (in ms) after which we consider the control comm target not responding.

variable IJupyterWidgetRegistry

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

variable JUPYTER_WIDGETS_VERSION

const JUPYTER_WIDGETS_VERSION: string;

    variable PROTOCOL_VERSION

    const PROTOCOL_VERSION: string;

      Functions

      function base64ToBuffer

      base64ToBuffer: (base64: string) => ArrayBuffer;
      • Convert a base64 string to an ArrayBuffer.

      function bufferToBase64

      bufferToBase64: (buffer: ArrayBuffer) => string;
      • Convert an ArrayBuffer to a base64 string.

      function bufferToHex

      bufferToHex: (buffer: ArrayBuffer) => string;
      • Convert an ArrayBuffer to a hex string.

      function difference

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

      function hexToBuffer

      hexToBuffer: (hex: string) => ArrayBuffer;
      • Convert a hex string to an ArrayBuffer.

      function isEqual

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

      function put_buffers

      put_buffers: (
      state: any,
      buffer_paths: (string | number)[][],
      buffers: DataView[]
      ) => 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: any) => 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: any) => {
      state: any;
      buffers: ArrayBuffer[];
      buffer_paths: (string | number)[][];
      };
      • 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>>) => Promise<Dict<V>>;
      • Resolve a promiseful dictionary. Returns a single Promise.

      function serialize_state

      serialize_state: (
      models: WidgetModel[],
      options?: IStateOptions
      ) => { version_major: number; version_minor: number; state: { [key: string]: any } };
      • Serialize an array of widget models

        #### Notes The return value follows the format given in the @jupyter-widgets/schema package.

      function unpack_models

      unpack_models: (
      value: any,
      manager: managerBase.ManagerBase<any>
      ) => Promise<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: () => any;

            class DOMWidgetView

            class DOMWidgetView extends WidgetView {}

              property '$el'

              '$el': any;

                property layoutPromise

                layoutPromise: Promise<any>;

                  property pWidget

                  pWidget: Widget;

                    property stylePromise

                    stylePromise: Promise<any>;

                      method initialize

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

                      method processPhosphorMessage

                      processPhosphorMessage: (msg: Message) => void;

                        method remove

                        remove: () => any;

                          method set_mapped_classes

                          set_mapped_classes: (
                          class_map: { [key: string]: string[] },
                          trait_name: string,
                          el?: HTMLElement
                          ) => void;

                            method setLayout

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

                              method setStyle

                              setStyle: (style: WidgetModel, oldStyle?: WidgetModel) => 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: { [key: string]: 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.

                                class JupyterPhosphorPanelWidget

                                class JupyterPhosphorPanelWidget 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 phosphor message.

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

                                    class JupyterPhosphorWidget

                                    class JupyterPhosphorWidget 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 phosphor message.

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

                                        class LayoutModel

                                        class LayoutModel extends WidgetModel {}

                                          method defaults

                                          defaults: () => any;

                                            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 handleOverflowChange

                                              handleOverflowChange: (trait: string, value: any) => void;
                                              • Handles when the value of overflow_x or overflow_y changes

                                              method initialize

                                              initialize: (parameters: WidgetView.InitializeParameters) => 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 ManagerBase

                                              abstract class ManagerBase<T> {}
                                              • Manager abstract base class

                                              property comm_target_name

                                              readonly comm_target_name: string;
                                              • The comm target name to register

                                              method callbacks

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

                                              method clear_state

                                              clear_state: () => Promise<void>;
                                              • Close all widgets and empty the widget state. Promise that resolves when the widget state is cleared.

                                              method create_view

                                              create_view: (model: DOMWidgetModel, options: any) => Promise<DOMWidgetView>;
                                              • 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 disconnect

                                              disconnect: () => void;
                                              • Disconnect the widget manager from the kernel, setting each model's comm as dead.

                                              method display_model

                                              display_model: (
                                              msg: services.KernelMessage.IMessage,
                                              model: DOMWidgetModel,
                                              options?: any
                                              ) => Promise<T>;
                                              • Display a DOMWidgetView for a particular model.

                                              method display_view

                                              abstract display_view: (
                                              msg: services.KernelMessage.IMessage,
                                              view: DOMWidgetView,
                                              options: any
                                              ) => Promise<T>;
                                              • Display a DOMWidget view.

                                                #### Notes This must be implemented by a subclass. The implementation must trigger the view's displayed event after the view is on the page: view.trigger('displayed')

                                              method filterExistingModelState

                                              protected filterExistingModelState: (serialized_state: any) => any;
                                              • Filter serialized widget state to remove any ID's already present in manager.

                                                Parameter state

                                                Serialized state to filter

                                                Returns

                                                {*} A copy of the state, with its 'state' attribute filtered

                                              method get_model

                                              get_model: (model_id: string) => Promise<WidgetModel> | undefined;
                                              • 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 get_state

                                              get_state: (options?: IStateOptions) => Promise<any>;
                                              • Asynchronously get the state of the widget manager.

                                                This includes all of the widget models, and follows the format given in the @jupyter-widgets/schema package.

                                                Parameter options

                                                The options for what state to return.

                                                Returns

                                                Promise for a state dictionary

                                              method handle_comm_open

                                              handle_comm_open: (
                                              comm: IClassicComm,
                                              msg: services.KernelMessage.ICommOpenMsg
                                              ) => Promise<WidgetModel>;
                                              • Handle when a comm is opened.

                                              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 loadClass

                                              protected abstract loadClass: (
                                              className: string,
                                              moduleName: string,
                                              moduleVersion: string
                                              ) => Promise<typeof WidgetModel | typeof WidgetView>;
                                              • Load a class and return a promise to the loaded object.

                                              method new_model

                                              new_model: (
                                              options: ModelOptions,
                                              serialized_state?: any
                                              ) => 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: WidgetOptions,
                                              serialized_state?: any
                                              ) => 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;

                                                method resolveUrl

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

                                                  The default implementation just returns the original url.

                                                method set_state

                                                set_state: (state: any) => Promise<WidgetModel[]>;
                                                • Set the widget manager state.

                                                  Parameter state

                                                  a Javascript object conforming to the application/vnd.jupyter.widget-state+json spec.

                                                  Reconstructs all of the widget models in the state, merges that with the current manager state, and then attempts to redisplay the widgets in the state.

                                                method setViewOptions

                                                setViewOptions: (options?: any) => any;
                                                • Modifies view options. Generally overloaded in custom widget manager implementations.

                                                class StyleModel

                                                class StyleModel extends WidgetModel {}

                                                  property styleProperties

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

                                                    method defaults

                                                    defaults: () => any;

                                                      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.InitializeParameters) => 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: managerBase.ManagerBase<any>;

                                                                                  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: () => {
                                                                                  _model_module: string;
                                                                                  _model_name: string;
                                                                                  _model_module_version: string;
                                                                                  _view_module: string;
                                                                                  _view_name: string;
                                                                                  _view_module_version: string;
                                                                                  _view_count: number;
                                                                                  };
                                                                                  • The default attributes.

                                                                                  method get_state

                                                                                  get_state: (drop_defaults: boolean) => any;
                                                                                  • 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: any,
                                                                                  options: { model_id: string; comm?: any; widget_manager: any }
                                                                                  ) => 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: {},
                                                                                    callbacks: {},
                                                                                    buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                    ) => void;
                                                                                    • Send a custom msg over the comm.

                                                                                    method send_sync_message

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

                                                                                    method serialize

                                                                                    serialize: (state: { [key: string]: any }) => { [key: string]: any };
                                                                                    • 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: any) => 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: any) => 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: (
                                                                                        child_model: WidgetModel,
                                                                                        options?: {}
                                                                                        ) => Promise<DOMWidgetView>;
                                                                                        • Create and promise that resolves to a child view of a given model

                                                                                        method initialize

                                                                                        initialize: (parameters: WidgetView.InitializeParameters) => 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

                                                                                            class WrappedError

                                                                                            class WrappedError extends Error {}
                                                                                            • Wrappable Error class

                                                                                              The Error class doesn't actually act on this. Instead it always returns a new instance of Error. Here we capture that instance so we can apply it's properties to this.

                                                                                            constructor

                                                                                            constructor(message: string, error: any);

                                                                                              property error_stack

                                                                                              error_stack: any[];

                                                                                                Interfaces

                                                                                                interface ICallbacks

                                                                                                interface ICallbacks {}
                                                                                                • Callbacks for services shim comms.

                                                                                                property input

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

                                                                                                  property iopub

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

                                                                                                    property shell

                                                                                                    shell?: {
                                                                                                    [key: string]: (msg: KernelMessage.IMessage) => 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?: any,
                                                                                                        callbacks?: any,
                                                                                                        metadata?: any,
                                                                                                        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: any,
                                                                                                        callbacks: any,
                                                                                                        metadata?: any,
                                                                                                        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: any,
                                                                                                        callbacks: any,
                                                                                                        metadata?: any,
                                                                                                        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 ISerializers

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

                                                                                                        index signature

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

                                                                                                          interface IStateOptions

                                                                                                          interface IStateOptions {}

                                                                                                            property drop_defaults

                                                                                                            drop_defaults?: boolean;
                                                                                                            • Drop model attributes that are equal to their default value.

                                                                                                              false

                                                                                                            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.

                                                                                                              interface ModelOptions

                                                                                                              interface ModelOptions {}
                                                                                                              • 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;
                                                                                                              • 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;
                                                                                                              • Target name of the widget view to create.

                                                                                                              interface WidgetOptions

                                                                                                              interface WidgetOptions {}
                                                                                                              • 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;
                                                                                                              • 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;
                                                                                                              • Target name of the widget view to create.

                                                                                                              Type Aliases

                                                                                                              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 JupyterPhosphorWidget

                                                                                                                  namespace JupyterPhosphorWidget {}

                                                                                                                    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?: any,
                                                                                                                                  callbacks?: any,
                                                                                                                                  metadata?: any,
                                                                                                                                  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: any,
                                                                                                                                  callbacks: any,
                                                                                                                                  metadata?: any,
                                                                                                                                  buffers?: ArrayBuffer[] | ArrayBufferView[]
                                                                                                                                  ) => string;
                                                                                                                                  • Opens a sibling comm in the backend

                                                                                                                                    Parameter data

                                                                                                                                    Parameter callbacks

                                                                                                                                    Parameter metadata

                                                                                                                                    msg id

                                                                                                                                  method send

                                                                                                                                  send: (
                                                                                                                                  data: any,
                                                                                                                                  callbacks: any,
                                                                                                                                  metadata?: any,
                                                                                                                                  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, data: {}) => 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, data: {}) => void
                                                                                                                                            ) => void;
                                                                                                                                            • Unregisters a comm target

                                                                                                                                              Parameter target_name

                                                                                                                                            namespace WidgetView

                                                                                                                                            namespace WidgetView {}

                                                                                                                                              interface InitializeParameters

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

                                                                                                                                                property options

                                                                                                                                                options: any;

                                                                                                                                                  Package Files (10)

                                                                                                                                                  Dependencies (10)

                                                                                                                                                  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>