Skip to content

Releases: manzt/anywidget

v0.2.0

17 Mar 15:35
ecd57b8
Compare
Choose a tag to compare

Minor Changes

  • feat: auto-create (and watch) FileContents for valid file paths (#79)

    import anywidget
    import traitlets
    
    class Counter(anywidget.AnyWidget):
        _esm = "index.js"
        value = traitlets.Int(0).tag(sync=True)

    If a file path for an existing file is detected for _esm or _css,
    the contents will be read from disk automatically. If the resolved
    path is not in site-packages (i.e., likely a development install), a
    background thread will start watching for file changes and push updates
    to the front end.

  • feat: add anywidget/types to npm package to allow opt-in strictness (#80)

    // @ts-check
    
    /** @type {import("anywidget/types").Render<{ value: number }>} */
    export function render(view) {
      let value = view.model.get("value");
      //^ ? `number`
    
      view.model.set("value", "not-a-number");
      // Error: Argument of type 'string' is not assignable to parameter of type 'number'. [2345]
    }

v0.1.2

21 Feb 14:28
9ac02a4
Compare
Choose a tag to compare

Patch Changes

  • feat: add (optional) cleanup/unmount return to render (#67)

    export function render(view) {
      /* create elements and add event listeners */
      return function cleanup() => {
        /* specify how to cleanup any expensive resources created above */
      }
    }
  • feat: add colab metadata to _repr_mimebundle_ to fix displaying ipywidgets v7 & v8 in Colab (#75)

v0.1.1

13 Feb 23:40
b1496fc
Compare
Choose a tag to compare

Patch Changes

  • fix: support ipywidgets v7 and v8 in Google Colab (#52) (7540ec9)

  • fix: hot CSS replacement (#65) (7540ec9)

  • feat: add ESM fallback if none is specified for an anywidget.AnyWidget subclass (#45) (7540ec9)

    class MyWidget(anywidget.AnyWidget):
        ...
    
    MyWidget()
    # Dev note: Implement an `_esm` attribute on AnyWidget subclass
    # `__main__.MyWidget` to customize this widget.
  • feat: add FileContents to read/watch files (#62) (7540ec9)

    contents = FileContents("./index.js", start_thread=True)
    
    contents.changed.connect
    def _on_change(new_contents: str):
        print("index.js changed:")
        print(new_contents)
  • chore: deprecate _module attribute for _esm for defining widget ESM (#66) (7540ec9)

  • fix: support Python 3.7 with from __future__ import annotations (#44) (7540ec9)

  • feat: add MimeBundleDescriptor pattern, for more library agnostic Python <> JS communication (#49) (7540ec9)

    from anywidget._descriptor import MimeBundleDescriptor
    
    import traitlets
    
    class Counter(traitlets.HasTraits):
        _repr_mimebundle_ = MimeBundleDescriptor(_esm=ESM)
        value = traitlets.Int(0).tag(sync=True)
  • feat: add support for HMR during development (#60) (7540ec9)