Skip to content

Latest commit

 

History

History
134 lines (89 loc) · 3.93 KB

CHANGELOG.md

File metadata and controls

134 lines (89 loc) · 3.93 KB

@anywidget/types

0.2.0

Minor Changes

  • Makes explicit WidgetManager interface (#670)

    Drops @jupyter-widgets/base as a dependency and instead makes an explicit interface for AnyModel.widget_manager. Right now we only support widget_manager.get_model, so having the other methods on the interface was misleading (leading to issues around .create_view not being supported).

0.1.9

Patch Changes

  • experimental Replace invoke timeout with more flexible AbortSignal (#540)

    This allows more flexible control over aborting the invoke request, including delegating to third-party libraries that manage cancellation.

    export default {
      async render({ model, el }) {
        const controller = new AbortController();
    
        // Randomly abort the request after 1 second
        setTimeout(() => Math.random() < 0.5 && controller.abort(), 1000);
    
        const signal = controller.signal;
        model
          .invoke("echo", "Hello, world", { signal })
          .then((result) => {
            el.innerHTML = result;
          })
          .catch((err) => {
            el.innerHTML = `Error: ${err.message}`;
          });
      },
    };

0.1.8

Patch Changes

  • Export Experimental type (#524)

0.1.7

Patch Changes

  • Add experimental invoke API to call Python functions from the front end and (#453) await the response.

    This removes a lot of boilerplate required for this pattern. The API is experimental and opt-in only. Subclasses must use the command to register functions.

    class Widget(anywidget.AnyWidget):
        _esm = """
        export default {
          async render({ model, el, experimental }) {
            let [msg, buffers] = await experimental.invoke("_echo", "hello, world");
            console.log(msg); // "HELLO, WORLD"
          },
        };
        """
    
        @anywidget.experimental.command
        def _echo(self, msg, buffers):
            # upper case the message
            return msg.upper(), buffers

0.1.6

Patch Changes

0.1.5

Patch Changes

  • Add Initialize method types (#395)

0.1.4

Patch Changes

  • feat: expose the IWidgetManager from @jupyter-widgets/base to render function. (f2dbdbf)

0.1.3

Patch Changes

  • feat: Infer event payloads from model (272782b)

0.1.2

Patch Changes

  • feat: Autocomplete event names for known model events (#151)

    /**
     * @typedef Model
     * @prop {number} value - the current count
     */
    
    /** @type {import("@anywidget/types").Render<Model>} */
    export function render({ model, el }) {
      model.on("change:value", () => { /* ... */);
               // ^ auto-completed in editor
    }

0.1.1

Patch Changes

  • fix: re-expose model.send for custom messages (#146)

0.1.0

Minor Changes

  • feat: restrict backbone model access in render context (#140)

  • feat!: Limit view fields exposed to render function (#138)

    BREAKING: The render function's argument has been refactored from a full AnyView to a simple object. This object only exposes the model and el fields to the user-provided render function. This change aims to simplify the API and reduce potential misuse. Please ensure your render function only depends on these fields.