Releases: manzt/anywidget
[email protected]
Minor Changes
-
feat: Add support for evented msgspec.Struct objects (#64)
Our experimental descriptor API can now work with
msgspec
, a fast and efficient serialization library, similar topydantic
but with a stronger emphasis on ser/de, and less on runtime casting of Python types.from anywidget._descriptor import MimeBundleDescriptor import psygnal import msgspec @psygnal.evented class Counter(msgspec.Struct, weakref=True): value: int = 0 _repr_mimebundle_: ClassVar = MimeBundleDescriptor(_esm="index.js", autodetect_observer=False)
[email protected]
Patch Changes
- fix: properly cache cleanup function for HMR (#122)
[email protected]
[email protected]
Patch Changes
- fix: add
watchfiles
as a direct dependency (#116)
[email protected]
Patch Changes
- fix: JS variable scope issue (
eacc99c
)
[email protected]
Patch Changes
- feat: log an re-raise error on ESM import failure (#105)
v0.2.1
v0.2.0
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 insite-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
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
Patch Changes
-
fix: support ipywidgets v7 and v8 in Google Colab (#52) (
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
)