-
Makes explicit WidgetManager interface (#670)
Drops
@jupyter-widgets/base
as a dependency and instead makes an explicit interface forAnyModel.widget_manager
. Right now we only supportwidget_manager.get_model
, so having the other methods on the interface was misleading (leading to issues around.create_view
not being supported).
-
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}`; }); }, };
- Export
Experimental
type (#524)
-
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
- Add
AnyWidget
definition (9aa8dcc8558e00e33fbe4506b68ae30113df3728
)
- Add
Initialize
method types (#395)
- feat: expose the
IWidgetManager
from@jupyter-widgets/base
to render function. (f2dbdbf
)
- feat: Infer event payloads from model (
272782b
)
-
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 }
- fix: re-expose model.send for custom messages (#146)
-
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 themodel
andel
fields to the user-providedrender
function. This change aims to simplify the API and reduce potential misuse. Please ensure your render function only depends on these fields.