@marimo-team/islands 0.23.1-dev8 → 0.23.1-dev9
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.
package/dist/main.js
CHANGED
|
@@ -89,7 +89,7 @@ let __tla = Promise.all([
|
|
|
89
89
|
}
|
|
90
90
|
})()
|
|
91
91
|
]).then(async () => {
|
|
92
|
-
var _e2, _WidgetDefRegistry_instances, t_fn, _a, _e3, _t2, _n2, _b, _e4, _c, _e5, _t3, _ModelManager_instances, n_fn, _d, _e6, _e7, _t4, _n3, _r, _i, _f, _e_instances, a_fn, o_fn, s_fn, _c2, _g, _e8, _t5, _n4, _r2, _i2, _a2, _o2, _s, _MatplotlibRenderer_instances, c_fn,
|
|
92
|
+
var _e2, _WidgetDefRegistry_instances, t_fn, _a, _e3, _t2, _n2, _b, _e4, _c, _e5, _t3, _ModelManager_instances, n_fn, _d, _e6, _e7, _t4, _n3, _r, _i, _f, _e_instances, a_fn, o_fn, s_fn, _c2, _g, _e8, _t5, _n4, _r2, _i2, _a2, _o2, _s, _MatplotlibRenderer_instances, c_fn, l_fn, u_fn, _d2, _f2, _p, _m, _h, _g2, __, _v, _y, _b2, _x, _S, _C, _w, _h2, _i3;
|
|
93
93
|
var defaultIconDimensions = Object.freeze({
|
|
94
94
|
left: 0,
|
|
95
95
|
top: 0,
|
|
@@ -20872,7 +20872,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
|
|
|
20872
20872
|
];
|
|
20873
20873
|
}
|
|
20874
20874
|
})(memoTheme_default(({ theme: e }) => {
|
|
20875
|
-
var _a3, _b3, _c3, _d3, _e9, _f3, _g3, _h3, _i4, _j, _k,
|
|
20875
|
+
var _a3, _b3, _c3, _d3, _e9, _f3, _g3, _h3, _i4, _j, _k, _l, _m2, _n5;
|
|
20876
20876
|
return {
|
|
20877
20877
|
userSelect: "none",
|
|
20878
20878
|
width: "1em",
|
|
@@ -20937,7 +20937,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
|
|
|
20937
20937
|
color: "action"
|
|
20938
20938
|
},
|
|
20939
20939
|
style: {
|
|
20940
|
-
color: (
|
|
20940
|
+
color: (_l = (_k = (e.vars ?? e).palette) == null ? void 0 : _k.action) == null ? void 0 : _l.active
|
|
20941
20941
|
}
|
|
20942
20942
|
},
|
|
20943
20943
|
{
|
|
@@ -56429,7 +56429,7 @@ ${c}
|
|
|
56429
56429
|
__privateAdd(this, _a2, null);
|
|
56430
56430
|
__privateAdd(this, _o2, 0);
|
|
56431
56431
|
__privateAdd(this, _s, "");
|
|
56432
|
-
__privateAdd(this,
|
|
56432
|
+
__privateAdd(this, _d2, () => {
|
|
56433
56433
|
let e = __privateGet(this, _a2);
|
|
56434
56434
|
if (!e) return;
|
|
56435
56435
|
let r = __privateGet(this, _e8).getContext("2d");
|
|
@@ -56445,17 +56445,17 @@ ${c}
|
|
|
56445
56445
|
r.closePath(), r.save(), r.fillStyle = c.selectionColor, r.globalAlpha = c.selectionOpacity, r.fill("evenodd"), r.restore(), r.strokeStyle = c.selectionColor, r.lineWidth = c.strokeWidth, r.stroke();
|
|
56446
56446
|
}
|
|
56447
56447
|
});
|
|
56448
|
-
__privateAdd(this,
|
|
56449
|
-
cancelAnimationFrame(__privateGet(this, _i2)), __privateSet(this, _i2, requestAnimationFrame(__privateGet(this,
|
|
56448
|
+
__privateAdd(this, _f2, () => {
|
|
56449
|
+
cancelAnimationFrame(__privateGet(this, _i2)), __privateSet(this, _i2, requestAnimationFrame(__privateGet(this, _d2)));
|
|
56450
56450
|
});
|
|
56451
|
-
__privateAdd(this,
|
|
56451
|
+
__privateAdd(this, _p, (e) => {
|
|
56452
56452
|
let r = __privateGet(this, _e8).getBoundingClientRect(), c = __privateGet(this, _n4).width / r.width, d = __privateGet(this, _n4).height / r.height;
|
|
56453
56453
|
return {
|
|
56454
56454
|
x: (e.clientX - r.left) * c,
|
|
56455
56455
|
y: (e.clientY - r.top) * d
|
|
56456
56456
|
};
|
|
56457
56457
|
});
|
|
56458
|
-
__privateAdd(this,
|
|
56458
|
+
__privateAdd(this, _m, (e, r) => {
|
|
56459
56459
|
let c = pixelToData(e, __privateGet(this, _n4)), d = pixelToData(r, __privateGet(this, _n4));
|
|
56460
56460
|
__privateGet(this, _n4).setValue({
|
|
56461
56461
|
type: "box",
|
|
@@ -56468,7 +56468,7 @@ ${c}
|
|
|
56468
56468
|
}
|
|
56469
56469
|
});
|
|
56470
56470
|
});
|
|
56471
|
-
__privateAdd(this,
|
|
56471
|
+
__privateAdd(this, _h, (e) => {
|
|
56472
56472
|
if (e.length >= 3) {
|
|
56473
56473
|
let r = e.map((e2) => {
|
|
56474
56474
|
let r2 = pixelToData(e2, __privateGet(this, _n4));
|
|
@@ -56484,19 +56484,19 @@ ${c}
|
|
|
56484
56484
|
});
|
|
56485
56485
|
}
|
|
56486
56486
|
});
|
|
56487
|
-
__privateAdd(this,
|
|
56487
|
+
__privateAdd(this, _g2, () => {
|
|
56488
56488
|
__privateSet(this, _r2, {
|
|
56489
56489
|
type: "idle"
|
|
56490
56490
|
}), __privateGet(this, _n4).setValue({
|
|
56491
56491
|
has_selection: false
|
|
56492
|
-
}), __privateGet(this,
|
|
56492
|
+
}), __privateGet(this, _f2).call(this);
|
|
56493
56493
|
});
|
|
56494
|
-
__privateAdd(this,
|
|
56495
|
-
__privateAdd(this,
|
|
56494
|
+
__privateAdd(this, __, () => __privateGet(this, _r2).type !== "idle");
|
|
56495
|
+
__privateAdd(this, _v, (e) => {
|
|
56496
56496
|
let r = __privateGet(this, _r2);
|
|
56497
56497
|
return r.type === "box" ? isPointInBox(e, r.start, r.end) : r.type === "lasso" ? pointInPolygon(e, r.points) : false;
|
|
56498
56498
|
});
|
|
56499
|
-
__privateAdd(this,
|
|
56499
|
+
__privateAdd(this, _y, (e) => {
|
|
56500
56500
|
let [r, c, d, f] = __privateGet(this, _n4).axesPixelBounds;
|
|
56501
56501
|
if (!(e.x >= r && e.x <= d && e.y >= c && e.y <= f)) {
|
|
56502
56502
|
__privateGet(this, _e8).style.cursor = "default";
|
|
@@ -56510,13 +56510,13 @@ ${c}
|
|
|
56510
56510
|
return;
|
|
56511
56511
|
}
|
|
56512
56512
|
}
|
|
56513
|
-
if (__privateGet(this,
|
|
56513
|
+
if (__privateGet(this, __).call(this) && __privateGet(this, _v).call(this, e)) {
|
|
56514
56514
|
__privateGet(this, _e8).style.cursor = "move";
|
|
56515
56515
|
return;
|
|
56516
56516
|
}
|
|
56517
56517
|
__privateGet(this, _e8).style.cursor = "crosshair";
|
|
56518
56518
|
});
|
|
56519
|
-
__privateAdd(this,
|
|
56519
|
+
__privateAdd(this, _b2, (e) => {
|
|
56520
56520
|
if (!(!e || !("has_selection" in e) || !e.has_selection)) {
|
|
56521
56521
|
if (e.type === "box") {
|
|
56522
56522
|
let r = e.data;
|
|
@@ -56540,12 +56540,12 @@ ${c}
|
|
|
56540
56540
|
}, __privateGet(this, _n4))),
|
|
56541
56541
|
action: null
|
|
56542
56542
|
});
|
|
56543
|
-
__privateGet(this,
|
|
56543
|
+
__privateGet(this, _f2).call(this);
|
|
56544
56544
|
}
|
|
56545
56545
|
});
|
|
56546
|
-
__privateAdd(this,
|
|
56546
|
+
__privateAdd(this, _x, (e) => {
|
|
56547
56547
|
__privateGet(this, _e8).setPointerCapture(e.pointerId), __privateGet(this, _t5).focus();
|
|
56548
|
-
let r = __privateGet(this,
|
|
56548
|
+
let r = __privateGet(this, _p).call(this, e), c = __privateGet(this, _r2);
|
|
56549
56549
|
if (e.shiftKey) {
|
|
56550
56550
|
if (!isInAxes(r, __privateGet(this, _n4))) return;
|
|
56551
56551
|
__privateSet(this, _r2, {
|
|
@@ -56556,7 +56556,7 @@ ${c}
|
|
|
56556
56556
|
action: {
|
|
56557
56557
|
type: "drawing"
|
|
56558
56558
|
}
|
|
56559
|
-
}), __privateGet(this,
|
|
56559
|
+
}), __privateGet(this, _f2).call(this);
|
|
56560
56560
|
return;
|
|
56561
56561
|
}
|
|
56562
56562
|
if (c.type === "box" && c.action === null) {
|
|
@@ -56577,7 +56577,7 @@ ${c}
|
|
|
56577
56577
|
return;
|
|
56578
56578
|
}
|
|
56579
56579
|
}
|
|
56580
|
-
if (__privateGet(this,
|
|
56580
|
+
if (__privateGet(this, __).call(this) && __privateGet(this, _v).call(this, r)) {
|
|
56581
56581
|
c.type === "box" ? __privateSet(this, _r2, {
|
|
56582
56582
|
type: "box",
|
|
56583
56583
|
start: c.start,
|
|
@@ -56596,7 +56596,7 @@ ${c}
|
|
|
56596
56596
|
});
|
|
56597
56597
|
return;
|
|
56598
56598
|
}
|
|
56599
|
-
if (__privateGet(this,
|
|
56599
|
+
if (__privateGet(this, __).call(this) && __privateGet(this, _g2).call(this), !isInAxes(r, __privateGet(this, _n4))) return;
|
|
56600
56600
|
let d = clampToAxes(r, __privateGet(this, _n4));
|
|
56601
56601
|
__privateSet(this, _r2, {
|
|
56602
56602
|
type: "box",
|
|
@@ -56605,21 +56605,21 @@ ${c}
|
|
|
56605
56605
|
action: {
|
|
56606
56606
|
type: "drawing"
|
|
56607
56607
|
}
|
|
56608
|
-
}), __privateGet(this,
|
|
56608
|
+
}), __privateGet(this, _f2).call(this);
|
|
56609
56609
|
});
|
|
56610
|
-
__privateAdd(this,
|
|
56611
|
-
let r = __privateGet(this,
|
|
56610
|
+
__privateAdd(this, _S, (e) => {
|
|
56611
|
+
let r = __privateGet(this, _p).call(this, e), c = __privateGet(this, _r2), d = __privateGet(this, _n4);
|
|
56612
56612
|
if (c.type === "idle" || c.action === null) {
|
|
56613
|
-
__privateGet(this,
|
|
56613
|
+
__privateGet(this, _y).call(this, r);
|
|
56614
56614
|
return;
|
|
56615
56615
|
}
|
|
56616
56616
|
if (c.type === "lasso" && c.action.type === "drawing") {
|
|
56617
|
-
c.points.push(clampToAxes(r, d)), __privateGet(this,
|
|
56617
|
+
c.points.push(clampToAxes(r, d)), __privateGet(this, _f2).call(this);
|
|
56618
56618
|
return;
|
|
56619
56619
|
}
|
|
56620
56620
|
if (c.type === "box" && c.action.type === "drawing") {
|
|
56621
56621
|
let e2 = clampToAxes(r, d);
|
|
56622
|
-
c.end = e2, __privateGet(this,
|
|
56622
|
+
c.end = e2, __privateGet(this, _f2).call(this), d.debounce || __privateGet(this, _m).call(this, c.start, e2);
|
|
56623
56623
|
return;
|
|
56624
56624
|
}
|
|
56625
56625
|
if (c.type === "box" && c.action.type === "resizing") {
|
|
@@ -56627,7 +56627,7 @@ ${c}
|
|
|
56627
56627
|
c.start = f, c.end = {
|
|
56628
56628
|
x: h ?? e2.x,
|
|
56629
56629
|
y: _ ?? e2.y
|
|
56630
|
-
}, __privateGet(this,
|
|
56630
|
+
}, __privateGet(this, _f2).call(this), d.debounce || __privateGet(this, _m).call(this, c.start, c.end);
|
|
56631
56631
|
return;
|
|
56632
56632
|
}
|
|
56633
56633
|
if (c.type === "box" && c.action.type === "dragging") {
|
|
@@ -56640,7 +56640,7 @@ ${c}
|
|
|
56640
56640
|
}, c.end = {
|
|
56641
56641
|
x: c.end.x + v,
|
|
56642
56642
|
y: c.end.y + y
|
|
56643
|
-
}, __privateGet(this,
|
|
56643
|
+
}, __privateGet(this, _f2).call(this), d.debounce || __privateGet(this, _m).call(this, c.start, c.end);
|
|
56644
56644
|
return;
|
|
56645
56645
|
}
|
|
56646
56646
|
if (c.type === "lasso" && c.action.type === "dragging") {
|
|
@@ -56653,68 +56653,72 @@ ${c}
|
|
|
56653
56653
|
x: c.points[e3].x + v,
|
|
56654
56654
|
y: c.points[e3].y + y
|
|
56655
56655
|
};
|
|
56656
|
-
__privateGet(this,
|
|
56656
|
+
__privateGet(this, _f2).call(this), d.debounce || __privateGet(this, _h).call(this, c.points);
|
|
56657
56657
|
}
|
|
56658
56658
|
});
|
|
56659
|
-
__privateAdd(this,
|
|
56659
|
+
__privateAdd(this, _C, (e) => {
|
|
56660
56660
|
var _a3, _b3;
|
|
56661
56661
|
__privateGet(this, _e8).releasePointerCapture(e.pointerId);
|
|
56662
56662
|
let r = __privateGet(this, _r2), c = __privateGet(this, _n4);
|
|
56663
56663
|
if (r.type === "lasso" && ((_a3 = r.action) == null ? void 0 : _a3.type) === "drawing") {
|
|
56664
|
-
r.points.length >= 3 ? (r.action = null, __privateGet(this,
|
|
56664
|
+
r.points.length >= 3 ? (r.action = null, __privateGet(this, _h).call(this, r.points)) : (__privateSet(this, _r2, {
|
|
56665
56665
|
type: "idle"
|
|
56666
56666
|
}), __privateGet(this, _n4).setValue({
|
|
56667
56667
|
has_selection: false
|
|
56668
|
-
})), __privateGet(this,
|
|
56668
|
+
})), __privateGet(this, _f2).call(this);
|
|
56669
56669
|
return;
|
|
56670
56670
|
}
|
|
56671
56671
|
if (r.type === "lasso" && ((_b3 = r.action) == null ? void 0 : _b3.type) === "dragging") {
|
|
56672
|
-
r.action = null, c.debounce && __privateGet(this,
|
|
56672
|
+
r.action = null, c.debounce && __privateGet(this, _h).call(this, r.points);
|
|
56673
56673
|
return;
|
|
56674
56674
|
}
|
|
56675
|
-
r.type === "box" && r.action !== null && (r.action = null, c.debounce && __privateGet(this,
|
|
56675
|
+
r.type === "box" && r.action !== null && (r.action = null, c.debounce && __privateGet(this, _m).call(this, r.start, r.end));
|
|
56676
56676
|
});
|
|
56677
|
-
__privateAdd(this,
|
|
56677
|
+
__privateAdd(this, _w, (e) => {
|
|
56678
56678
|
var _a3;
|
|
56679
56679
|
if (e.key === "Escape") {
|
|
56680
56680
|
let e2 = __privateGet(this, _r2);
|
|
56681
56681
|
if (e2.type === "idle") return;
|
|
56682
56682
|
((_a3 = e2.action) == null ? void 0 : _a3.type) === "drawing" ? (__privateSet(this, _r2, {
|
|
56683
56683
|
type: "idle"
|
|
56684
|
-
}), __privateGet(this,
|
|
56684
|
+
}), __privateGet(this, _f2).call(this)) : __privateGet(this, _g2).call(this);
|
|
56685
56685
|
}
|
|
56686
56686
|
});
|
|
56687
56687
|
__privateSet(this, _t5, e), __privateSet(this, _n4, r.state), e.tabIndex = -1, e.role = "application", e.className = "relative inline-block select-none outline-none";
|
|
56688
56688
|
let c = document.createElement("canvas");
|
|
56689
|
-
c.className = "block cursor-crosshair"
|
|
56690
|
-
let d = globalThis.devicePixelRatio ?? 1;
|
|
56691
|
-
c.width = __privateGet(this, _n4).width * d, c.height = __privateGet(this, _n4).height * d, c.style.width = `${__privateGet(this, _n4).width}px`, c.style.maxWidth = "100%", c.style.height = "auto", c.style.aspectRatio = `${__privateGet(this, _n4).width} / ${__privateGet(this, _n4).height}`, c.style.touchAction = "none", e.append(c), __privateSet(this, _e8, c), c.addEventListener("pointerdown", __privateGet(this, _y), {
|
|
56689
|
+
c.className = "block cursor-crosshair", __privateMethod(this, _MatplotlibRenderer_instances, c_fn).call(this, c), c.style.touchAction = "none", e.append(c), __privateSet(this, _e8, c), c.addEventListener("pointerdown", __privateGet(this, _x), {
|
|
56692
56690
|
signal: r.signal
|
|
56693
|
-
}), c.addEventListener("pointermove", __privateGet(this,
|
|
56691
|
+
}), c.addEventListener("pointermove", __privateGet(this, _S), {
|
|
56694
56692
|
signal: r.signal
|
|
56695
|
-
}), c.addEventListener("pointerup", __privateGet(this,
|
|
56693
|
+
}), c.addEventListener("pointerup", __privateGet(this, _C), {
|
|
56696
56694
|
signal: r.signal
|
|
56697
|
-
}), e.addEventListener("keydown", __privateGet(this,
|
|
56695
|
+
}), e.addEventListener("keydown", __privateGet(this, _w), {
|
|
56698
56696
|
signal: r.signal
|
|
56699
|
-
}), r.signal.addEventListener("abort", () => {
|
|
56697
|
+
}), __privateMethod(this, _MatplotlibRenderer_instances, l_fn).call(this, r.signal), r.signal.addEventListener("abort", () => {
|
|
56700
56698
|
cancelAnimationFrame(__privateGet(this, _i2)), __privateGet(this, _e8).remove();
|
|
56701
|
-
}), __privateMethod(this, _MatplotlibRenderer_instances,
|
|
56699
|
+
}), __privateMethod(this, _MatplotlibRenderer_instances, u_fn).call(this, __privateGet(this, _n4).chartBase64), __privateGet(this, _b2).call(this, __privateGet(this, _n4).value);
|
|
56702
56700
|
}
|
|
56703
56701
|
update(e) {
|
|
56704
56702
|
let r = __privateGet(this, _n4);
|
|
56705
56703
|
__privateSet(this, _n4, e);
|
|
56706
56704
|
let c = false;
|
|
56707
|
-
if (e.width !== r.width || e.height !== r.height) {
|
|
56708
|
-
|
|
56709
|
-
__privateGet(this, _e8).width = e.width * r2, __privateGet(this, _e8).height = e.height * r2, __privateGet(this, _e8).style.width = `${e.width}px`, __privateGet(this, _e8).style.maxWidth = "100%", __privateGet(this, _e8).style.height = "auto", __privateGet(this, _e8).style.aspectRatio = `${e.width} / ${e.height}`, c = true;
|
|
56710
|
-
}
|
|
56711
|
-
if (e.chartBase64 !== __privateGet(this, _s)) {
|
|
56712
|
-
__privateMethod(this, _MatplotlibRenderer_instances, c_fn).call(this, e.chartBase64);
|
|
56705
|
+
if ((e.width !== r.width || e.height !== r.height) && (__privateMethod(this, _MatplotlibRenderer_instances, c_fn).call(this), c = true), e.chartBase64 !== __privateGet(this, _s)) {
|
|
56706
|
+
__privateMethod(this, _MatplotlibRenderer_instances, u_fn).call(this, e.chartBase64);
|
|
56713
56707
|
return;
|
|
56714
56708
|
}
|
|
56715
|
-
(c || e.selectionColor !== r.selectionColor || e.selectionOpacity !== r.selectionOpacity || e.strokeWidth !== r.strokeWidth) && __privateGet(this,
|
|
56709
|
+
(c || e.selectionColor !== r.selectionColor || e.selectionOpacity !== r.selectionOpacity || e.strokeWidth !== r.strokeWidth) && __privateGet(this, _d2).call(this);
|
|
56716
56710
|
}
|
|
56717
|
-
}, _e8 = new WeakMap(), _t5 = new WeakMap(), _n4 = new WeakMap(), _r2 = new WeakMap(), _i2 = new WeakMap(), _a2 = new WeakMap(), _o2 = new WeakMap(), _s = new WeakMap(), _MatplotlibRenderer_instances = new WeakSet(), c_fn = function(e) {
|
|
56711
|
+
}, _e8 = new WeakMap(), _t5 = new WeakMap(), _n4 = new WeakMap(), _r2 = new WeakMap(), _i2 = new WeakMap(), _a2 = new WeakMap(), _o2 = new WeakMap(), _s = new WeakMap(), _MatplotlibRenderer_instances = new WeakSet(), c_fn = function(e = __privateGet(this, _e8)) {
|
|
56712
|
+
let r = globalThis.devicePixelRatio ?? 1, { width: c, height: d } = __privateGet(this, _n4);
|
|
56713
|
+
e.width = c * r, e.height = d * r, e.style.width = `${c}px`, e.style.maxWidth = "100%", e.style.height = "auto", e.style.aspectRatio = `${c} / ${d}`;
|
|
56714
|
+
}, l_fn = function(e) {
|
|
56715
|
+
e.aborted || matchMedia(`(resolution: ${globalThis.devicePixelRatio ?? 1}dppx)`).addEventListener("change", () => {
|
|
56716
|
+
__privateMethod(this, _MatplotlibRenderer_instances, c_fn).call(this), __privateGet(this, _d2).call(this), __privateMethod(this, _MatplotlibRenderer_instances, l_fn).call(this, e);
|
|
56717
|
+
}, {
|
|
56718
|
+
once: true,
|
|
56719
|
+
signal: e
|
|
56720
|
+
});
|
|
56721
|
+
}, u_fn = function(e) {
|
|
56718
56722
|
__privateSet(this, _s, e), __privateWrapper(this, _o2)._++;
|
|
56719
56723
|
let r = __privateGet(this, _o2);
|
|
56720
56724
|
__privateSet(this, _r2, {
|
|
@@ -56727,9 +56731,9 @@ ${c}
|
|
|
56727
56731
|
}
|
|
56728
56732
|
let d = new Image();
|
|
56729
56733
|
d.onload = () => {
|
|
56730
|
-
r === __privateGet(this, _o2) && (__privateSet(this, _a2, d), __privateGet(this,
|
|
56734
|
+
r === __privateGet(this, _o2) && (__privateSet(this, _a2, d), __privateGet(this, _d2).call(this));
|
|
56731
56735
|
}, d.src = e;
|
|
56732
|
-
},
|
|
56736
|
+
}, _d2 = new WeakMap(), _f2 = new WeakMap(), _p = new WeakMap(), _m = new WeakMap(), _h = new WeakMap(), _g2 = new WeakMap(), __ = new WeakMap(), _v = new WeakMap(), _y = new WeakMap(), _b2 = new WeakMap(), _x = new WeakMap(), _S = new WeakMap(), _C = new WeakMap(), _w = new WeakMap(), _h2), import_compiler_runtime$37 = require_compiler_runtime(), MatplotlibPlugin = class {
|
|
56733
56737
|
constructor() {
|
|
56734
56738
|
__publicField(this, "tagName", "marimo-matplotlib");
|
|
56735
56739
|
__publicField(this, "validator", object({
|
|
@@ -68727,7 +68731,7 @@ ${c}
|
|
|
68727
68731
|
return Logger.warn("Failed to get version from mount config"), null;
|
|
68728
68732
|
}
|
|
68729
68733
|
}
|
|
68730
|
-
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.1-
|
|
68734
|
+
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.1-dev9"), showCodeInRunModeAtom = atom(true);
|
|
68731
68735
|
atom(null);
|
|
68732
68736
|
var VIRTUAL_FILE_REGEX = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g, VirtualFileTracker = class e {
|
|
68733
68737
|
constructor() {
|
package/package.json
CHANGED
|
@@ -297,13 +297,7 @@ export class MatplotlibRenderer {
|
|
|
297
297
|
// Create canvas
|
|
298
298
|
const canvas = document.createElement("canvas");
|
|
299
299
|
canvas.className = "block cursor-crosshair";
|
|
300
|
-
|
|
301
|
-
canvas.width = this.#state.width * dpr;
|
|
302
|
-
canvas.height = this.#state.height * dpr;
|
|
303
|
-
canvas.style.width = `${this.#state.width}px`;
|
|
304
|
-
canvas.style.maxWidth = "100%";
|
|
305
|
-
canvas.style.height = "auto";
|
|
306
|
-
canvas.style.aspectRatio = `${this.#state.width} / ${this.#state.height}`;
|
|
300
|
+
this.#syncCanvasSize(canvas);
|
|
307
301
|
canvas.style.touchAction = "none";
|
|
308
302
|
container.append(canvas);
|
|
309
303
|
this.#canvas = canvas;
|
|
@@ -322,6 +316,10 @@ export class MatplotlibRenderer {
|
|
|
322
316
|
signal: options.signal,
|
|
323
317
|
});
|
|
324
318
|
|
|
319
|
+
// Watch for devicePixelRatio changes (e.g. browser zoom, moving between
|
|
320
|
+
// displays). matchMedia fires exactly once per DPR transition.
|
|
321
|
+
this.#watchDevicePixelRatio(options.signal);
|
|
322
|
+
|
|
325
323
|
// Clean up on abort
|
|
326
324
|
options.signal.addEventListener("abort", () => {
|
|
327
325
|
cancelAnimationFrame(this.#rafId);
|
|
@@ -333,6 +331,38 @@ export class MatplotlibRenderer {
|
|
|
333
331
|
this.#restoreSelection(this.#state.value);
|
|
334
332
|
}
|
|
335
333
|
|
|
334
|
+
/** Set the canvas buffer + CSS size to match current logical size and DPR. */
|
|
335
|
+
#syncCanvasSize(canvas: HTMLCanvasElement = this.#canvas): void {
|
|
336
|
+
const dpr = globalThis.devicePixelRatio ?? 1;
|
|
337
|
+
const { width, height } = this.#state;
|
|
338
|
+
canvas.width = width * dpr;
|
|
339
|
+
canvas.height = height * dpr;
|
|
340
|
+
canvas.style.width = `${width}px`;
|
|
341
|
+
canvas.style.maxWidth = "100%";
|
|
342
|
+
canvas.style.height = "auto";
|
|
343
|
+
canvas.style.aspectRatio = `${width} / ${height}`;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Observe devicePixelRatio changes via matchMedia. Each listener fires once
|
|
348
|
+
* per transition, so we re-register after every change.
|
|
349
|
+
*/
|
|
350
|
+
#watchDevicePixelRatio(signal: AbortSignal): void {
|
|
351
|
+
if (signal.aborted) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const mq = matchMedia(
|
|
355
|
+
`(resolution: ${globalThis.devicePixelRatio ?? 1}dppx)`,
|
|
356
|
+
);
|
|
357
|
+
const onChange = () => {
|
|
358
|
+
this.#syncCanvasSize();
|
|
359
|
+
this.#drawCanvas();
|
|
360
|
+
// Re-register for the next DPR transition
|
|
361
|
+
this.#watchDevicePixelRatio(signal);
|
|
362
|
+
};
|
|
363
|
+
mq.addEventListener("change", onChange, { once: true, signal });
|
|
364
|
+
}
|
|
365
|
+
|
|
336
366
|
update(state: MatplotlibState): void {
|
|
337
367
|
const prev = this.#state;
|
|
338
368
|
this.#state = state;
|
|
@@ -341,13 +371,7 @@ export class MatplotlibRenderer {
|
|
|
341
371
|
|
|
342
372
|
// Update canvas dimensions if changed
|
|
343
373
|
if (state.width !== prev.width || state.height !== prev.height) {
|
|
344
|
-
|
|
345
|
-
this.#canvas.width = state.width * dpr;
|
|
346
|
-
this.#canvas.height = state.height * dpr;
|
|
347
|
-
this.#canvas.style.width = `${state.width}px`;
|
|
348
|
-
this.#canvas.style.maxWidth = "100%";
|
|
349
|
-
this.#canvas.style.height = "auto";
|
|
350
|
-
this.#canvas.style.aspectRatio = `${state.width} / ${state.height}`;
|
|
374
|
+
this.#syncCanvasSize();
|
|
351
375
|
needsRedraw = true;
|
|
352
376
|
}
|
|
353
377
|
|