plot-saver 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2
4
+
5
+ - Dropped wrapper-level anywidget UIElement caching so marimo rebuilds the plot saver widget with a fresh virtual-file JavaScript module on each rerun.
6
+ - Kept the widget comm initialization path so the underlying anywidget model id remains stable across marimo renders.
7
+
3
8
  ## 0.1.1
4
9
 
5
10
  - Fixed the marimo anywidget compatibility layer to serve widget JavaScript through marimo-managed virtual files instead of embedding untrusted `data:` URLs.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plot-saver
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Reusable anywidget plot saver configurable with a config.toml.
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: anywidget>=0.10.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "plot-saver"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "Reusable anywidget plot saver configurable with a config.toml."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,7 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- from weakref import WeakKeyDictionary
4
-
5
3
  import marimo._output.data.data as mo_data
6
4
  from marimo._plugins.ui._core.ui_element import UIElement
7
5
  from marimo._plugins.ui._impl.from_anywidget import (
@@ -12,6 +10,8 @@ from marimo._utils.code import hash_code
12
10
 
13
11
 
14
12
  class _StableAnyWidget(MarimoAnyWidget):
13
+ """Marimo anywidget wrapper that keeps the widget model-id stable."""
14
+
15
15
  def __init__(self, widget):
16
16
  self.widget = widget
17
17
  self._initialized = False
@@ -35,15 +35,8 @@ class _StableAnyWidget(MarimoAnyWidget):
35
35
  on_change=None,
36
36
  )
37
37
 
38
-
39
- _WIDGET_CACHE: WeakKeyDictionary[object, _StableAnyWidget] = WeakKeyDictionary()
40
-
41
-
42
38
  def wrap_anywidget(widget):
43
- cached = _WIDGET_CACHE.get(widget)
44
- if cached is not None:
45
- return cached
46
-
47
- wrapped = _StableAnyWidget(widget)
48
- _WIDGET_CACHE[widget] = wrapped
49
- return wrapped
39
+ # Rebuild the marimo UIElement on each call so its virtual-file-backed
40
+ # JS module belongs to the current cell lifecycle. Caching the wrapper can
41
+ # leave a stale `@file/...js` URL behind after notebook reruns.
42
+ return _StableAnyWidget(widget)
File without changes