Releases: manzt/anywidget
[email protected]
Patch Changes
-
Use rsbuild inline sourcemaps for JupyterLab extension (#909)
JupyterLab was refusing to load external source map files because they were
being served with the wrong MIME type ('application/octet-stream' instead of
the expected source map MIME type). This caused the extension to fail loading
in version 0.9.20.Switching to inline source maps embeds the source map directly in the
JavaScript bundle, avoiding the MIME type issue while still providing source
map support for debugging.
[email protected]
Patch Changes
-
Override repr to avoid expensive trait serialization #906 (#906)
Previously,
AnyWidgetinheritedipywidgets.Widget.__repr__which serialized all trait values. This is costly because the repr might not even be shown to users, yet it forces a full serialization of potentially large data.AnyWidgetnow overrides__repr__to useobject.__repr__(self), which produces a simple<module.ClassName object at 0x...>format.To restore the previous behavior showing all trait values, users can define:
class MyWidget(anywidget.AnyWidget): def __repr__(self): return traitlets.HasTraits.__repr__(self)
[email protected]
Patch Changes
- Exclude
docs/andpaper/from sdist/wheel (#902)
@anywidget/[email protected]
Patch Changes
- Normalize possible AFM inputs to an AFM object when using Vite HMR. (#881)
[email protected]
Patch Changes
- Upgrade
@clack/promptsto avoid using placeholder values (#868)
@anywidget/[email protected]
This release deliberately contains backwards-incompatible changes. To avoid automatically picking up releases like this, you should either be pinning the exact version of @anywidget/svelte in your package.json file or be using a version range syntax that only accepts patch upgrades such as ~0.0.1.
-
Migrate to Svelte 5 signals API (#869)
The
@anywidget/sveltenow uses Svelte 5's new runes reactivity system (aka signals). The context-based implementation has been replaced with reactive model bindings usingcreateSubscriber.Update your Svelte dependency to version 5:
npm install svelte@^5.0.0
Ensure Svelte 5 runes are enabled in your bundler configuration:
// rolldown.config.js or rollup.config.js svelte({ compilerOptions: { runes: true, }, });
The previous API used Svelte 4 and exposed model values via the
storesproxy:<script> import { stores } from "@anywidget/svelte"; let { count } = stores; </script> <button on:click={() => $count += 1}>Count is {$count}</button>
With Svelte 5,
@anywidget/sveltenow uses direct reactive bindings and the$props()rune:<script> /** @type {{ bindings: { count: number } }} */ let { bindings } = $props(); </script> <button on:click={() => bindings.count++}>Count is {bindings.count}</button>
This is a breaking change. The old stores API and getContext-based access are no longer supported. You must update your components to use the new bindings prop via
$props().See manzt/ipyfoo-svelte for a complete example.
@anywidget/[email protected]
Minor Changes
-
Initial release (
1c5f07a)Thanks to @aryan02420, we now support Vue with an official framework bridge—similar to our React and Svelte bindings.
Unlike
@anywidget/react, theuseModelStatehook returns a VueShallowRefthat you can update directly (e.g.value++), aligning with Vue’s reactivity model.// src/index.js import { createRender } from "@anywidget/vue"; import CounterWidget from "./CounterWidget.vue"; const render = createRender(CounterWidget); export default { render };
<!-- src/CounterWidget.vue --> <script setup> import { useModelState } from "@anywidget/vue"; const value = useModelState("value"); </script> <template> <button :onClick="() => value++">count is {{ value }}</button> </template>
See the README for build tool configuration.
[email protected]
Patch Changes
- Pin
@anywidget/react~v0.2 (#837)
@anywidget/[email protected]
Minor Changes
-
Use
React.useSyncExternalStoreforuseModelStatehook implementation (34f01a3)The
React.useSyncExternalStorehook was introduced in React 18 and is designed for external sources of truth, like the anywidgetmodel. It ensures a shared source within the component tree, and consistent behavior during concurrent rendering, avoiding subtle bugs present inuseEffect-based patterns.This is marked as a breaking change to signal the internal shift in behavior, though in practice it should be considered an improvement. Most users should not notice any difference, aside from more consistent updates.
-
Mirror
React.useStateAPI inuseModelStatehook (34f01a3)Aligns the
useModelStatehook more closely with theReact.useStateAPI by allowing a callback function in the state setter.
Patch Changes
- Add generic type parameter to
useModelhook (34f01a3)
[email protected]
Patch Changes
- experimental Fix descriptor API to send initial state on comm creation (#832)