@marimo-team/islands 0.25.3-dev446 → 0.25.3-dev453
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/{ErrorBoundary-CBvdOZsh.js → ErrorBoundary-CIYMOu2p.js} +1 -1
- package/dist/assets/__vite-browser-external-D2z_TiUO.js +1 -0
- package/dist/assets/{worker-BUqfWMtI.js → worker-DLJ9P24O.js} +2 -2
- package/dist/{chat-ui-9oyUBL6M.js → chat-ui-DEHpKH2l.js} +17 -19
- package/dist/{code-visibility-BVsBD2bm.js → code-visibility-BQE60zOk.js} +7 -7
- package/dist/{common-Cz5kXzjw.js → common-DfUux6zJ.js} +4902 -4893
- package/dist/{data-grid-overlay-editor-B-PHwg_F.js → data-grid-overlay-editor-B9zW4oN1.js} +1 -1
- package/dist/{error-entries-CWdDf7iZ.js → error-entries-BG7ifiDg.js} +1368 -996
- package/dist/{feedback-button-DKfgWMh1.js → feedback-button-BEUh4iQQ.js} +129 -129
- package/dist/{glide-data-editor-BMrcgCud.js → glide-data-editor-CbdIXPTZ.js} +3 -3
- package/dist/{globals-vjja83iL.js → globals-BkxG-Y8L.js} +1 -1
- package/dist/{html-to-image-CexRSGAZ.js → html-to-image-9HLBGrIx.js} +4115 -4103
- package/dist/main.js +6562 -6671
- package/dist/{number-overlay-editor-CQvIdVeX.js → number-overlay-editor-BFzdth50.js} +1 -1
- package/dist/{process-output-hcyVRJCC.js → process-output-B8HPq5iZ.js} +2 -2
- package/dist/{reveal-component-DF7VRfN2.js → reveal-component-DK_-9fAX.js} +166 -167
- package/package.json +1 -1
- package/src/__mocks__/executions.ts +7 -4
- package/src/__mocks__/notebook.ts +20 -4
- package/src/components/editor/cell/DeleteButton.tsx +2 -2
- package/src/components/editor/cell/StopButton.tsx +2 -2
- package/src/components/editor/cell/useRunCells.ts +0 -3
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +1 -1
- package/src/components/editor/notebook-cell.tsx +4 -35
- package/src/components/editor/output/ansi-reduce.ts +124 -61
- package/src/components/editor/output/console/ConsoleOutput.tsx +7 -25
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +15 -44
- package/src/components/editor/renderers/cells-renderer.tsx +2 -5
- package/src/components/editor/renderers/grid-layout/__tests__/grid-layout.test.tsx +1 -1
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +3 -6
- package/src/components/editor/stdin-blocking-alert.tsx +14 -18
- package/src/components/scratchpad/scratchpad.test.tsx +1 -1
- package/src/components/scratchpad/scratchpad.tsx +5 -6
- package/src/components/slides/__tests__/cell-output-block.test.tsx +2 -2
- package/src/components/slides/__tests__/slide-cell-view.test.tsx +2 -2
- package/src/components/tracing/tracing-spec.ts +11 -1
- package/src/components/tracing/tracing.tsx +4 -0
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +10 -20
- package/src/core/ai/context/providers/__tests__/error.test.ts +5 -27
- package/src/core/ai/context/providers/cell-output.ts +4 -12
- package/src/core/cells/__tests__/cell.test.ts +1 -169
- package/src/core/cells/__tests__/cells.test.ts +32 -709
- package/src/core/cells/__tests__/clear-outputs.test.ts +21 -14
- package/src/core/cells/__tests__/collapseConsoleOutputs.test.ts +71 -2
- package/src/core/cells/__tests__/logs.test.ts +18 -29
- package/src/core/cells/__tests__/runs.test.ts +128 -431
- package/src/core/cells/__tests__/session.test.ts +9 -9
- package/src/core/cells/actions.ts +29 -7
- package/src/core/cells/cell.ts +1 -96
- package/src/core/cells/cells.ts +147 -117
- package/src/core/cells/collapseConsoleOutputs.tsx +71 -40
- package/src/core/cells/command-console.ts +46 -0
- package/src/core/cells/execution-console.ts +230 -0
- package/src/core/cells/focus.ts +9 -29
- package/src/core/cells/logs.ts +10 -2
- package/src/core/cells/runs.ts +62 -118
- package/src/core/cells/session.ts +2 -2
- package/src/core/cells/types.ts +30 -23
- package/src/core/cells/useAnswerPrompt.ts +29 -0
- package/src/core/errors/error-entries.ts +3 -4
- package/src/core/executions/__tests__/atoms.test.ts +6 -20
- package/src/core/executions/__tests__/input.test.ts +3 -3
- package/src/core/executions/__tests__/output-lifecycle.test.ts +2 -8
- package/src/core/executions/atoms.ts +2 -21
- package/src/core/executions/index.ts +2 -1
- package/src/core/executions/input.ts +4 -3
- package/src/core/executions/output.ts +3 -3
- package/src/core/islands/__tests__/bridge.test.ts +59 -0
- package/src/core/islands/bootstrap.ts +29 -12
- package/src/core/islands/bridge.ts +67 -13
- package/src/core/kernel/handlers.ts +2 -21
- package/src/core/kernel/messages.ts +0 -1
- package/src/core/network/types.ts +0 -1
- package/src/core/notebook/document/__tests__/codemirror.test.ts +1 -0
- package/src/core/notebook/replica/__tests__/executions.test.ts +1 -0
- package/src/core/notebook/replica/__tests__/replica.test.ts +113 -0
- package/src/core/notebook/replica/replica.ts +106 -12
- package/src/core/notebook/replica/resources/executions.ts +57 -4
- package/src/core/session/__tests__/backend.test.ts +2 -4
- package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +1 -0
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +601 -35
- package/src/core/session/useNotebookReplica.ts +20 -6
- package/src/core/session/useNotebookSession.tsx +63 -33
- package/src/core/static/virtual-file-tracker.ts +26 -8
- package/src/stories/layout/vertical/one-column.stories.tsx +18 -12
- package/dist/assets/__vite-browser-external-CpRgw4M_.js +0 -1
- package/src/components/editor/alerts/stdin-blocking-alert.tsx +0 -68
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -703
|
@@ -7,16 +7,16 @@ import { f as s, h as c } from "./tooltip-CiJ919pg.js";
|
|
|
7
7
|
import { t as l } from "./check-CApwK1fD.js";
|
|
8
8
|
import { n as u, r as d } from "./assertNever-DOTNJ2Y4.js";
|
|
9
9
|
import { t as f } from "./jsx-runtime-D8btoEHk.js";
|
|
10
|
-
import { At as
|
|
11
|
-
import { n as
|
|
12
|
-
import { t as
|
|
10
|
+
import { At as p, Dt as m, Et as h, Ft as g, Nt as _, Pt as ee, Rt as v, St as y, Tt as b, Vt as x, _n as te, f as ne, fn as re, gn as ie, kt as S, mn as ae, pn as oe, wt as se, xt as ce } from "./use-restore-focus-BLj45Ibw.js";
|
|
11
|
+
import { n as le } from "./toast-BGvv7tKS.js";
|
|
12
|
+
import { t as ue } from "./objects-DCmMvZtn.js";
|
|
13
13
|
import { t as C } from "./invariant-DLmrl-hA.js";
|
|
14
|
-
import { t as
|
|
15
|
-
import { t as
|
|
16
|
-
import { H as
|
|
17
|
-
import { a as
|
|
18
|
-
import { t as
|
|
19
|
-
var
|
|
14
|
+
import { t as de } from "./purify.es-DmnrIjg4.js";
|
|
15
|
+
import { t as fe } from "./createReducer-CXqSak4H.js";
|
|
16
|
+
import { H as pe, N as me, P as he, _ as ge } from "./dist-D92tYjLc.js";
|
|
17
|
+
import { a as _e, i as ve, l as ye, m as be, u as xe } from "./static-state-CWXd6dYX.js";
|
|
18
|
+
import { t as Se } from "./capabilities-DKqMqBzm.js";
|
|
19
|
+
var Ce = c("external-link", [
|
|
20
20
|
["path", {
|
|
21
21
|
d: "M15 3h6v6",
|
|
22
22
|
key: "1q9fwt"
|
|
@@ -29,49 +29,49 @@ var Se = c("external-link", [
|
|
|
29
29
|
d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",
|
|
30
30
|
key: "a6xqqp"
|
|
31
31
|
}]
|
|
32
|
-
]),
|
|
32
|
+
]), we = c("minus", [["path", {
|
|
33
33
|
d: "M5 12h14",
|
|
34
34
|
key: "1ays0h"
|
|
35
|
-
}]]), w = /* @__PURE__ */ e(i(), 1), T = f(),
|
|
35
|
+
}]]), w = /* @__PURE__ */ e(i(), 1), T = f(), Te = Object.defineProperty, E = (e, t) => Te(e, "name", {
|
|
36
36
|
value: t,
|
|
37
37
|
configurable: !0
|
|
38
|
-
}),
|
|
39
|
-
function
|
|
40
|
-
let { __scopeCheckbox: t, checked: n, children: r, defaultChecked: i, disabled: a, form: o, name: s, onCheckedChange: c, required: l, value: u = "on", internal_do_not_use_render: d } = e, [f,
|
|
38
|
+
}), Ee = "Checkbox", [De, Oe] = ie(Ee), [ke, Ae] = De(Ee);
|
|
39
|
+
function je(e) {
|
|
40
|
+
let { __scopeCheckbox: t, checked: n, children: r, defaultChecked: i, disabled: a, form: o, name: s, onCheckedChange: c, required: l, value: u = "on", internal_do_not_use_render: d } = e, [f, p] = oe({
|
|
41
41
|
prop: n,
|
|
42
42
|
defaultProp: i ?? !1,
|
|
43
43
|
onChange: c,
|
|
44
|
-
caller:
|
|
45
|
-
}), [
|
|
44
|
+
caller: Ee
|
|
45
|
+
}), [m, h] = w.useState(null), [g, _] = w.useState(null), [ee, v] = w.useState(null), y = !m || !!o || !!m.closest("form"), b = {
|
|
46
46
|
checked: f,
|
|
47
47
|
disabled: a,
|
|
48
|
-
setChecked:
|
|
49
|
-
control:
|
|
50
|
-
setControl:
|
|
48
|
+
setChecked: p,
|
|
49
|
+
control: m,
|
|
50
|
+
setControl: h,
|
|
51
51
|
name: s,
|
|
52
52
|
form: o,
|
|
53
53
|
value: u,
|
|
54
|
-
userClick:
|
|
54
|
+
userClick: ee,
|
|
55
55
|
onUserClick: v,
|
|
56
56
|
required: l,
|
|
57
57
|
defaultChecked: !D(i) && i,
|
|
58
58
|
isFormControl: y,
|
|
59
|
-
bubbleInput:
|
|
60
|
-
setBubbleInput:
|
|
59
|
+
bubbleInput: g,
|
|
60
|
+
setBubbleInput: _
|
|
61
61
|
};
|
|
62
|
-
return /* @__PURE__ */ (0, T.jsx)(
|
|
62
|
+
return /* @__PURE__ */ (0, T.jsx)(ke, {
|
|
63
63
|
scope: t,
|
|
64
64
|
...b,
|
|
65
|
-
children:
|
|
65
|
+
children: ze(d) ? d(b) : r
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
E(
|
|
69
|
-
var
|
|
70
|
-
let { control: o, value: s, disabled: c, checked: l, required: u, setControl: d, setChecked: f, onUserClick:
|
|
68
|
+
E(je, "CheckboxProvider");
|
|
69
|
+
var Me = "CheckboxTrigger", Ne = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(function({ __scopeCheckbox: e, onKeyDown: t, onClick: n, ...i }, a) {
|
|
70
|
+
let { control: o, value: s, disabled: c, checked: l, required: u, setControl: d, setChecked: f, onUserClick: p, isFormControl: m, bubbleInput: h } = Ae(Me, e), g = r(a, d), _ = w.useRef(l);
|
|
71
71
|
return w.useEffect(() => {
|
|
72
72
|
let e = o?.form;
|
|
73
73
|
if (e) {
|
|
74
|
-
let t = /* @__PURE__ */ E(() => f(
|
|
74
|
+
let t = /* @__PURE__ */ E(() => f(_.current), "reset");
|
|
75
75
|
return e.addEventListener("reset", t), () => e.removeEventListener("reset", t);
|
|
76
76
|
}
|
|
77
77
|
}, [o, f]), /* @__PURE__ */ (0, T.jsx)(te.button, {
|
|
@@ -79,26 +79,26 @@ var je = "CheckboxTrigger", Me = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(
|
|
|
79
79
|
role: "checkbox",
|
|
80
80
|
"aria-checked": D(l) ? "mixed" : l,
|
|
81
81
|
"aria-required": u,
|
|
82
|
-
"data-state":
|
|
82
|
+
"data-state": Be(l),
|
|
83
83
|
"data-disabled": c ? "" : void 0,
|
|
84
84
|
disabled: c,
|
|
85
85
|
value: s,
|
|
86
86
|
...i,
|
|
87
|
-
ref:
|
|
88
|
-
onKeyDown:
|
|
87
|
+
ref: g,
|
|
88
|
+
onKeyDown: ae(t, (e) => {
|
|
89
89
|
e.key === "Enter" && e.preventDefault();
|
|
90
90
|
}),
|
|
91
|
-
onClick:
|
|
91
|
+
onClick: ae(n, (e) => {
|
|
92
92
|
let t = e.isPropagationStopped();
|
|
93
|
-
|
|
93
|
+
p({
|
|
94
94
|
requestedChecked: D(l) ? !0 : !l,
|
|
95
95
|
hasConsumerStoppedPropagation: t
|
|
96
|
-
}), f((e) => D(e) ? !0 : !e),
|
|
96
|
+
}), f((e) => D(e) ? !0 : !e), h && m && (t || e.stopPropagation());
|
|
97
97
|
})
|
|
98
98
|
});
|
|
99
|
-
}, "CheckboxTrigger")),
|
|
99
|
+
}, "CheckboxTrigger")), Pe = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(function(e, t) {
|
|
100
100
|
let { __scopeCheckbox: n, name: r, checked: i, defaultChecked: a, required: o, disabled: s, value: c, onCheckedChange: l, form: u, ...d } = e;
|
|
101
|
-
return /* @__PURE__ */ (0, T.jsx)(
|
|
101
|
+
return /* @__PURE__ */ (0, T.jsx)(je, {
|
|
102
102
|
__scopeCheckbox: n,
|
|
103
103
|
checked: i,
|
|
104
104
|
defaultChecked: a,
|
|
@@ -108,18 +108,18 @@ var je = "CheckboxTrigger", Me = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(
|
|
|
108
108
|
name: r,
|
|
109
109
|
form: u,
|
|
110
110
|
value: c,
|
|
111
|
-
internal_do_not_use_render: ({ isFormControl: e }) => /* @__PURE__ */ (0, T.jsxs)(T.Fragment, { children: [/* @__PURE__ */ (0, T.jsx)(
|
|
111
|
+
internal_do_not_use_render: ({ isFormControl: e }) => /* @__PURE__ */ (0, T.jsxs)(T.Fragment, { children: [/* @__PURE__ */ (0, T.jsx)(Ne, {
|
|
112
112
|
...d,
|
|
113
113
|
ref: t,
|
|
114
114
|
__scopeCheckbox: n
|
|
115
|
-
}), e && /* @__PURE__ */ (0, T.jsx)(
|
|
115
|
+
}), e && /* @__PURE__ */ (0, T.jsx)(Re, { __scopeCheckbox: n })] })
|
|
116
116
|
});
|
|
117
|
-
}, "Checkbox")),
|
|
118
|
-
let { __scopeCheckbox: n, forceMount: r, ...i } = e, a =
|
|
119
|
-
return /* @__PURE__ */ (0, T.jsx)(
|
|
117
|
+
}, "Checkbox")), Fe = "CheckboxIndicator", Ie = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(function(e, t) {
|
|
118
|
+
let { __scopeCheckbox: n, forceMount: r, ...i } = e, a = Ae(Fe, n);
|
|
119
|
+
return /* @__PURE__ */ (0, T.jsx)(re, {
|
|
120
120
|
present: r || D(a.checked) || a.checked === !0,
|
|
121
121
|
children: /* @__PURE__ */ (0, T.jsx)(te.span, {
|
|
122
|
-
"data-state":
|
|
122
|
+
"data-state": Be(a.checked),
|
|
123
123
|
"data-disabled": a.disabled ? "" : void 0,
|
|
124
124
|
...i,
|
|
125
125
|
ref: t,
|
|
@@ -129,10 +129,10 @@ var je = "CheckboxTrigger", Me = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(
|
|
|
129
129
|
}
|
|
130
130
|
})
|
|
131
131
|
});
|
|
132
|
-
}, "CheckboxIndicator")),
|
|
133
|
-
let { control: a, userClick: o, checked: c, defaultChecked: l, required: u, disabled: d, name: f, value:
|
|
132
|
+
}, "CheckboxIndicator")), Le = "CheckboxBubbleInput", Re = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(function({ __scopeCheckbox: e, onClick: t, ...n }, i) {
|
|
133
|
+
let { control: a, userClick: o, checked: c, defaultChecked: l, required: u, disabled: d, name: f, value: p, form: m, bubbleInput: h, setBubbleInput: g } = Ae(Le, e), _ = r(i, g), ee = s(a), v = w.useRef(!1), y = w.useRef(c), b = w.useRef(o), x = w.useRef(null);
|
|
134
134
|
w.useEffect(() => {
|
|
135
|
-
let e =
|
|
135
|
+
let e = h;
|
|
136
136
|
if (!e) return;
|
|
137
137
|
let t = window.HTMLInputElement.prototype, n = Object.getOwnPropertyDescriptor(t, "checked").set;
|
|
138
138
|
if (!n) return;
|
|
@@ -147,7 +147,7 @@ var je = "CheckboxTrigger", Me = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(
|
|
|
147
147
|
v.current = !0, e.indeterminate = D(c), n.call(e, !D(c) && c), e.dispatchEvent(new Event("click", { bubbles: !(r && t.hasConsumerStoppedPropagation) })), v.current = !1;
|
|
148
148
|
}
|
|
149
149
|
}, [
|
|
150
|
-
|
|
150
|
+
h,
|
|
151
151
|
c,
|
|
152
152
|
o
|
|
153
153
|
]);
|
|
@@ -159,17 +159,17 @@ var je = "CheckboxTrigger", Me = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(
|
|
|
159
159
|
required: u,
|
|
160
160
|
disabled: d,
|
|
161
161
|
name: f,
|
|
162
|
-
value:
|
|
163
|
-
form:
|
|
162
|
+
value: p,
|
|
163
|
+
form: m,
|
|
164
164
|
...n,
|
|
165
165
|
tabIndex: -1,
|
|
166
|
-
ref:
|
|
167
|
-
onClick:
|
|
166
|
+
ref: _,
|
|
167
|
+
onClick: ae(t, (e) => {
|
|
168
168
|
v.current && e.stopPropagation();
|
|
169
169
|
}),
|
|
170
170
|
style: {
|
|
171
171
|
...n.style,
|
|
172
|
-
...
|
|
172
|
+
...ee,
|
|
173
173
|
position: "absolute",
|
|
174
174
|
pointerEvents: "none",
|
|
175
175
|
opacity: 0,
|
|
@@ -178,30 +178,30 @@ var je = "CheckboxTrigger", Me = /* @__PURE__ */ w.forwardRef(/* @__PURE__ */ E(
|
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
}, "CheckboxBubbleInput"));
|
|
181
|
-
function
|
|
181
|
+
function ze(e) {
|
|
182
182
|
return typeof e == "function";
|
|
183
183
|
}
|
|
184
|
-
E(
|
|
184
|
+
E(ze, "isFunction");
|
|
185
185
|
function D(e) {
|
|
186
186
|
return e === "indeterminate";
|
|
187
187
|
}
|
|
188
188
|
E(D, "isIndeterminate");
|
|
189
|
-
function
|
|
189
|
+
function Be(e) {
|
|
190
190
|
return D(e) ? "indeterminate" : e ? "checked" : "unchecked";
|
|
191
191
|
}
|
|
192
|
-
E(
|
|
192
|
+
E(Be, "getState");
|
|
193
193
|
//#endregion
|
|
194
194
|
//#region src/plugins/core/sanitize-html.ts
|
|
195
|
-
var
|
|
195
|
+
var Ve = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix|zotero):|[^a-z]|[-a-z+.]+(?:[^-a-z+.:]|$))/i;
|
|
196
196
|
if (typeof document < "u") {
|
|
197
197
|
let e = "data-temp-href-target";
|
|
198
|
-
|
|
198
|
+
de.addHook("beforeSanitizeAttributes", (t) => {
|
|
199
199
|
t.tagName === "A" && (t.hasAttribute("target") || t.setAttribute("target", "_self"), t.hasAttribute("target") && t.setAttribute(e, t.getAttribute("target") || ""));
|
|
200
|
-
}),
|
|
200
|
+
}), de.addHook("afterSanitizeAttributes", (t) => {
|
|
201
201
|
t.tagName === "A" && t.hasAttribute(e) && (t.setAttribute("target", t.getAttribute(e) || ""), t.removeAttribute(e), t.getAttribute("target") === "_blank" && t.setAttribute("rel", "noopener noreferrer"));
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function He(e) {
|
|
205
205
|
let t = {
|
|
206
206
|
USE_PROFILES: {
|
|
207
207
|
html: !0,
|
|
@@ -210,7 +210,7 @@ function Ve(e) {
|
|
|
210
210
|
},
|
|
211
211
|
ADD_TAGS: ["use"],
|
|
212
212
|
ADD_ATTR: ["href", "xlink:href"],
|
|
213
|
-
ALLOWED_URI_REGEXP:
|
|
213
|
+
ALLOWED_URI_REGEXP: Ve,
|
|
214
214
|
FORCE_BODY: !0,
|
|
215
215
|
CUSTOM_ELEMENT_HANDLING: {
|
|
216
216
|
tagNameCheck: /^(marimo-[A-Za-z][\w-]*|iconify-icon)$/,
|
|
@@ -218,59 +218,59 @@ function Ve(e) {
|
|
|
218
218
|
},
|
|
219
219
|
SAFE_FOR_XML: !e.includes("marimo-mermaid")
|
|
220
220
|
};
|
|
221
|
-
return
|
|
221
|
+
return de.sanitize(e, t);
|
|
222
222
|
}
|
|
223
223
|
//#endregion
|
|
224
224
|
//#region src/core/dom/outline.ts
|
|
225
|
-
var
|
|
225
|
+
var Ue = [
|
|
226
226
|
"marimo-carousel",
|
|
227
227
|
"marimo-tabs",
|
|
228
228
|
"marimo-accordion",
|
|
229
229
|
"marimo-sidebar"
|
|
230
|
-
],
|
|
231
|
-
function
|
|
230
|
+
], We = "h1, h2, h3, h4, h5, h6";
|
|
231
|
+
function Ge(e) {
|
|
232
232
|
if (typeof DOMParser > "u") return null;
|
|
233
|
-
let t = [], n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(
|
|
233
|
+
let t = [], n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(We);
|
|
234
234
|
for (let e of Array.from(n)) {
|
|
235
235
|
let n = e.textContent;
|
|
236
|
-
if (
|
|
236
|
+
if (Ue.some((t) => e.closest(t)) || !n) continue;
|
|
237
237
|
let r = Number.parseInt(e.tagName[1], 10), i = e.innerHTML, a = {
|
|
238
238
|
name: n,
|
|
239
239
|
level: r,
|
|
240
|
-
by:
|
|
240
|
+
by: qe(e)
|
|
241
241
|
};
|
|
242
|
-
i !== n && (a.html =
|
|
242
|
+
i !== n && (a.html = He(i)), t.push(a);
|
|
243
243
|
}
|
|
244
244
|
return { items: t };
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function Ke(e) {
|
|
247
247
|
if (!e.includes("\"")) return `"${e}"`;
|
|
248
248
|
if (!e.includes("'")) return `'${e}'`;
|
|
249
249
|
let t = e.split("\""), n = [];
|
|
250
250
|
for (let [e, r] of t.entries()) r && n.push(`"${r}"`), e < t.length - 1 && n.push("'\"'");
|
|
251
251
|
return `concat(${n.join(", ")})`;
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function qe(e) {
|
|
254
254
|
let t = e.id;
|
|
255
255
|
if (t) return { id: t };
|
|
256
256
|
let n = e.textContent ?? "";
|
|
257
|
-
return { path: `//${e.tagName}[contains(., ${
|
|
257
|
+
return { path: `//${e.tagName}[contains(., ${Ke(n)})]` };
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function Je(e) {
|
|
260
260
|
return { items: e.filter(Boolean).flatMap((e) => e.items) };
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function Ye(e) {
|
|
263
263
|
if (e == null || e.mimetype !== "text/html" && e.mimetype !== "text/markdown" || e.data == null) return null;
|
|
264
264
|
try {
|
|
265
|
-
return C(typeof e.data == "string", "expected string"),
|
|
265
|
+
return C(typeof e.data == "string", "expected string"), Ge(e.data);
|
|
266
266
|
} catch {
|
|
267
267
|
return t.error("Failed to parse outline"), null;
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function Xe(e) {
|
|
271
271
|
return e != null && e.items.some((e) => e.level <= 3);
|
|
272
272
|
}
|
|
273
|
-
function
|
|
273
|
+
function Ze(e, n) {
|
|
274
274
|
let r = (e) => e.items.length === 0 ? 7 : Math.min(...e.items.map((e) => e.level)), i = n[e];
|
|
275
275
|
if (i == null || i.items.length === 0) return t.warn("Failed to find a starting outline"), null;
|
|
276
276
|
let a = r(i), o = e + 1;
|
|
@@ -288,14 +288,196 @@ var O = {
|
|
|
288
288
|
CONNECTING: "CONNECTING",
|
|
289
289
|
OPEN: "OPEN",
|
|
290
290
|
CLOSED: "CLOSED"
|
|
291
|
-
},
|
|
291
|
+
}, Qe = {
|
|
292
292
|
KERNEL_DISCONNECTED: "KERNEL_DISCONNECTED",
|
|
293
293
|
KERNEL_STARTUP_ERROR: "KERNEL_STARTUP_ERROR"
|
|
294
|
-
}
|
|
294
|
+
};
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/core/notebook/replica/resources/results.ts
|
|
297
|
+
function $e(e, t) {
|
|
298
|
+
let { record: n, outputVersion: r } = t, i = n.cell_id;
|
|
299
|
+
return i === null || n.status !== "completed" || !e.has(i) || n.outcome?.kind === "skipped" && n.outcome.reason === "superseded" ? e : new Map(e).set(i, {
|
|
300
|
+
record: n,
|
|
301
|
+
outputVersion: r
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
function et(e, t) {
|
|
305
|
+
let { record: n, outputVersion: r } = t;
|
|
306
|
+
if (n.cell_id !== null || n.outcome === null) return e;
|
|
307
|
+
let i = (e) => Date.parse(e.completed_at ?? e.started_at ?? "1970-01-01T00:00:00Z");
|
|
308
|
+
return e !== null && i(e.record) > i(n) ? e : {
|
|
309
|
+
record: n,
|
|
310
|
+
outputVersion: r
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/core/notebook/replica/resources/executions.ts
|
|
315
|
+
function tt(e) {
|
|
316
|
+
return [...e.items.values()].toSorted((e, t) => e.seq - t.seq);
|
|
317
|
+
}
|
|
318
|
+
function k(e, t) {
|
|
319
|
+
if (!e.has(t)) return e;
|
|
320
|
+
let n = new Map(e);
|
|
321
|
+
return n.delete(t), n;
|
|
322
|
+
}
|
|
323
|
+
function nt(e, t) {
|
|
324
|
+
let n = e.scratchConsole, { id: r, cell_id: i, started_at: a } = t.record;
|
|
325
|
+
return i !== null || a === null ? n : !n || n.record.id === r || e.executions.get(r)?.record.started_at == null && Date.parse(a) >= Date.parse(n.record.started_at ?? "") ? t : n;
|
|
326
|
+
}
|
|
327
|
+
function A(e, t) {
|
|
328
|
+
let { id: n, cell_id: r } = t.record;
|
|
329
|
+
return {
|
|
330
|
+
...e,
|
|
331
|
+
executions: new Map(e.executions).set(n, t),
|
|
332
|
+
scratchConsole: nt(e, t),
|
|
333
|
+
latest: r === null || e.latest.get(r) === n ? e.latest : new Map(e.latest).set(r, n)
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function rt(e, t) {
|
|
337
|
+
let n = e.executions.get(t);
|
|
338
|
+
if (n === void 0) return e;
|
|
339
|
+
let r = n.record.cell_id;
|
|
340
|
+
return {
|
|
341
|
+
...e,
|
|
342
|
+
executions: k(e.executions, t),
|
|
343
|
+
scratchConsole: e.scratchConsole?.record.id === t ? void 0 : e.scratchConsole,
|
|
344
|
+
latest: r !== null && e.latest.get(r) === t ? k(e.latest, r) : e.latest
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function it(e, t) {
|
|
348
|
+
let n = e.executions.get(t.execution_id);
|
|
349
|
+
if (n === void 0) return e;
|
|
350
|
+
let r = n.items.get(t.id);
|
|
351
|
+
return r && (t = {
|
|
352
|
+
...t,
|
|
353
|
+
time: r.time
|
|
354
|
+
}), A(e, {
|
|
355
|
+
...n,
|
|
356
|
+
append: !r && t.seq > (n.lastSeq ?? -1) ? {
|
|
357
|
+
before: new WeakRef(n.items),
|
|
358
|
+
item: t
|
|
359
|
+
} : void 0,
|
|
360
|
+
lastSeq: Math.max(n.lastSeq ?? -1, t.seq),
|
|
361
|
+
items: new Map(n.items).set(t.id, t)
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function at(e, t) {
|
|
365
|
+
for (let n of e.executions.values()) if (n.items.has(t)) return A(e, {
|
|
366
|
+
...n,
|
|
367
|
+
append: void 0,
|
|
368
|
+
items: k(n.items, t)
|
|
369
|
+
});
|
|
370
|
+
return e;
|
|
371
|
+
}
|
|
372
|
+
function ot(e, t) {
|
|
373
|
+
let n = e.executions.get(t.execution_id);
|
|
374
|
+
return n === void 0 ? e : A(e, {
|
|
375
|
+
...n,
|
|
376
|
+
variables: new Map(n.variables).set(t.id, t)
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
function st(e, t) {
|
|
380
|
+
for (let n of e.executions.values()) if (n.variables.has(t)) return A(e, {
|
|
381
|
+
...n,
|
|
382
|
+
variables: k(n.variables, t)
|
|
383
|
+
});
|
|
384
|
+
return e;
|
|
385
|
+
}
|
|
386
|
+
function ct(e, t) {
|
|
387
|
+
return e.outcome === t.outcome || JSON.stringify(e.outcome) === JSON.stringify(t.outcome);
|
|
388
|
+
}
|
|
389
|
+
function lt(e, t, n) {
|
|
390
|
+
let r = new Map(e.executions);
|
|
391
|
+
for (let [e, n] of r) {
|
|
392
|
+
let i = n.record.cell_id === null ? t.scratch : t.results.get(n.record.cell_id), a = t.executions.get(e) ?? (i?.record.id === e ? i : void 0);
|
|
393
|
+
a !== void 0 && r.set(e, {
|
|
394
|
+
...n,
|
|
395
|
+
outputVersion: a.outputVersion + +!ct(a.record, n.record)
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
let i = new Map(e.results);
|
|
399
|
+
for (let [e, n] of i) {
|
|
400
|
+
let a = n === null ? void 0 : r.get(n.record.id);
|
|
401
|
+
i.set(e, a === void 0 ? t.results.get(e) ?? null : {
|
|
402
|
+
record: a.record,
|
|
403
|
+
outputVersion: a.outputVersion
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
let a = e.scratch === null ? null : r.get(e.scratch.record.id);
|
|
407
|
+
return {
|
|
408
|
+
...e,
|
|
409
|
+
executions: r,
|
|
410
|
+
results: i,
|
|
411
|
+
scratchConsole: e.scratchConsole ?? (t.scratchConsole?.record.status === "completed" && t.scratchConsole.record.runtime_id === n ? t.scratchConsole : void 0),
|
|
412
|
+
scratch: a == null ? t.scratch : et(t.scratch, a)
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
var ut = {
|
|
416
|
+
initial: {
|
|
417
|
+
runs: /* @__PURE__ */ new Map(),
|
|
418
|
+
executions: /* @__PURE__ */ new Map(),
|
|
419
|
+
latest: /* @__PURE__ */ new Map(),
|
|
420
|
+
results: /* @__PURE__ */ new Map(),
|
|
421
|
+
scratch: null
|
|
422
|
+
},
|
|
423
|
+
on: {
|
|
424
|
+
cell: (e, { data: t }) => e.results.has(t.cell.id) ? e : {
|
|
425
|
+
...e,
|
|
426
|
+
results: new Map(e.results).set(t.cell.id, null)
|
|
427
|
+
},
|
|
428
|
+
"cell.removed": (e, { data: t }) => ({
|
|
429
|
+
...e,
|
|
430
|
+
results: k(e.results, t.id)
|
|
431
|
+
}),
|
|
432
|
+
run: (e, { data: t }) => ({
|
|
433
|
+
...e,
|
|
434
|
+
runs: new Map(e.runs).set(t.run.id, t.run)
|
|
435
|
+
}),
|
|
436
|
+
"run.removed": (e, { data: t }) => e.runs.has(t.id) ? {
|
|
437
|
+
...e,
|
|
438
|
+
runs: k(e.runs, t.id)
|
|
439
|
+
} : e,
|
|
440
|
+
execution: (e, { data: { execution: t } }) => {
|
|
441
|
+
let n = e.executions.get(t.id), r = {
|
|
442
|
+
record: t,
|
|
443
|
+
outputVersion: n === void 0 ? 0 : n.outputVersion + +!ct(n.record, t),
|
|
444
|
+
append: n?.append,
|
|
445
|
+
lastSeq: n?.lastSeq,
|
|
446
|
+
items: n?.items ?? /* @__PURE__ */ new Map(),
|
|
447
|
+
variables: n?.variables ?? /* @__PURE__ */ new Map()
|
|
448
|
+
};
|
|
449
|
+
return {
|
|
450
|
+
...A(e, r),
|
|
451
|
+
results: $e(e.results, r),
|
|
452
|
+
scratch: et(e.scratch, r)
|
|
453
|
+
};
|
|
454
|
+
},
|
|
455
|
+
"execution.removed": (e, { data: t }) => rt(e, t.id),
|
|
456
|
+
console: (e, { data: t }) => it(e, {
|
|
457
|
+
...t.console,
|
|
458
|
+
kind: "console",
|
|
459
|
+
time: t.time
|
|
460
|
+
}),
|
|
461
|
+
"console.removed": (e, { data: t }) => at(e, t.id),
|
|
462
|
+
display: (e, { data: t }) => it(e, {
|
|
463
|
+
...t.display,
|
|
464
|
+
kind: "display",
|
|
465
|
+
time: t.time
|
|
466
|
+
}),
|
|
467
|
+
"display.removed": (e, { data: t }) => at(e, t.id),
|
|
468
|
+
input: (e, { data: t }) => it(e, {
|
|
469
|
+
...t.input,
|
|
470
|
+
kind: "input",
|
|
471
|
+
time: t.time
|
|
472
|
+
}),
|
|
473
|
+
variable: (e, { data: t }) => ot(e, t.variable),
|
|
474
|
+
"variable.removed": (e, { data: t }) => st(e, t.id)
|
|
475
|
+
}
|
|
476
|
+
}, dt = {
|
|
295
477
|
sourceChanged: !1,
|
|
296
478
|
inputsChanged: !1
|
|
297
479
|
};
|
|
298
|
-
function
|
|
480
|
+
function ft(e) {
|
|
299
481
|
let t = /* @__PURE__ */ new Map();
|
|
300
482
|
for (let n of e.executions.values()) for (let e of n.variables.values()) {
|
|
301
483
|
let n = t.get(e.name);
|
|
@@ -303,8 +485,8 @@ function $e(e) {
|
|
|
303
485
|
}
|
|
304
486
|
return t;
|
|
305
487
|
}
|
|
306
|
-
function
|
|
307
|
-
let t =
|
|
488
|
+
function pt(e) {
|
|
489
|
+
let t = ft(e.executions), n = /* @__PURE__ */ new Map(), r = (t) => e.executions.executions.get(t)?.record;
|
|
308
490
|
function i(e, n) {
|
|
309
491
|
let i = new Set(n).add(e.id);
|
|
310
492
|
for (let [n, a] of Object.entries(e.depends_on)) {
|
|
@@ -341,54 +523,54 @@ function et(e) {
|
|
|
341
523
|
}
|
|
342
524
|
return (t) => {
|
|
343
525
|
let n = e.results.get(t)?.record;
|
|
344
|
-
return n == null ?
|
|
526
|
+
return n == null ? dt : o(n, /* @__PURE__ */ new Set());
|
|
345
527
|
};
|
|
346
528
|
}
|
|
347
529
|
//#endregion
|
|
348
530
|
//#region src/core/executions/output.ts
|
|
349
|
-
var
|
|
350
|
-
function
|
|
531
|
+
var mt = /* @__PURE__ */ new Map(), ht = "application/vnd.marimo+error";
|
|
532
|
+
function j(e) {
|
|
351
533
|
return e;
|
|
352
534
|
}
|
|
353
|
-
function
|
|
535
|
+
function gt(e) {
|
|
354
536
|
return e.map(({ cell_id: e, message: t }) => ({
|
|
355
|
-
cell_id:
|
|
537
|
+
cell_id: j(e),
|
|
356
538
|
message: t
|
|
357
539
|
}));
|
|
358
540
|
}
|
|
359
|
-
function
|
|
541
|
+
function _t(e) {
|
|
360
542
|
return e === null ? 0 : Date.parse(e) / 1e3;
|
|
361
543
|
}
|
|
362
|
-
function
|
|
363
|
-
return
|
|
544
|
+
function vt(e) {
|
|
545
|
+
return _t(e.completed_at ?? e.started_at);
|
|
364
546
|
}
|
|
365
|
-
function
|
|
547
|
+
function yt(e, t) {
|
|
366
548
|
return {
|
|
367
549
|
channel: "output",
|
|
368
550
|
mimetype: t.mimetype,
|
|
369
551
|
data: t.data,
|
|
370
|
-
timestamp:
|
|
552
|
+
timestamp: vt(e)
|
|
371
553
|
};
|
|
372
554
|
}
|
|
373
|
-
function
|
|
555
|
+
function M(e, t) {
|
|
374
556
|
return {
|
|
375
557
|
channel: "marimo-error",
|
|
376
|
-
mimetype:
|
|
558
|
+
mimetype: ht,
|
|
377
559
|
data: t,
|
|
378
|
-
timestamp:
|
|
560
|
+
timestamp: vt(e)
|
|
379
561
|
};
|
|
380
562
|
}
|
|
381
|
-
function
|
|
563
|
+
function bt(e) {
|
|
382
564
|
let t = e.related.at(0);
|
|
383
|
-
return t === void 0 ? null :
|
|
565
|
+
return t === void 0 ? null : j(t.cell_id);
|
|
384
566
|
}
|
|
385
|
-
function
|
|
567
|
+
function xt(e) {
|
|
386
568
|
switch (e.kind) {
|
|
387
569
|
case "exception": return {
|
|
388
570
|
type: "exception",
|
|
389
571
|
exception_type: e.name ?? "Exception",
|
|
390
572
|
msg: e.message,
|
|
391
|
-
raising_cell:
|
|
573
|
+
raising_cell: bt(e),
|
|
392
574
|
traceback: e.traceback?.data ?? null
|
|
393
575
|
};
|
|
394
576
|
case "invalid-syntax": return {
|
|
@@ -406,78 +588,78 @@ function ct(e) {
|
|
|
406
588
|
type: "diagnostic",
|
|
407
589
|
kind: e.kind,
|
|
408
590
|
msg: e.message,
|
|
409
|
-
related:
|
|
591
|
+
related: gt(e.related)
|
|
410
592
|
};
|
|
411
593
|
}
|
|
412
594
|
}
|
|
413
|
-
function
|
|
595
|
+
function St(e, t) {
|
|
414
596
|
let n = t.related[0];
|
|
415
|
-
if (n !== void 0 && t.reason === "upstream-stopped") return
|
|
597
|
+
if (n !== void 0 && t.reason === "upstream-stopped") return M(e, [{
|
|
416
598
|
type: "ancestor-stopped",
|
|
417
599
|
msg: t.message,
|
|
418
|
-
raising_cell:
|
|
600
|
+
raising_cell: j(n.cell_id)
|
|
419
601
|
}]);
|
|
420
602
|
if (n !== void 0 && t.reason === "upstream-failed") {
|
|
421
603
|
let r = t.related.slice(1).find((t) => t.cell_id !== e.cell_id);
|
|
422
|
-
return
|
|
604
|
+
return M(e, [{
|
|
423
605
|
type: "ancestor-prevented",
|
|
424
606
|
msg: t.message,
|
|
425
|
-
raising_cell:
|
|
426
|
-
blamed_cell: r === void 0 ? null :
|
|
607
|
+
raising_cell: j(n.cell_id),
|
|
608
|
+
blamed_cell: r === void 0 ? null : j(r.cell_id)
|
|
427
609
|
}]);
|
|
428
610
|
}
|
|
429
|
-
return
|
|
611
|
+
return M(e, [{
|
|
430
612
|
type: "diagnostic",
|
|
431
613
|
kind: t.reason,
|
|
432
614
|
msg: t.message,
|
|
433
|
-
related:
|
|
615
|
+
related: gt(t.related)
|
|
434
616
|
}]);
|
|
435
617
|
}
|
|
436
|
-
function
|
|
618
|
+
function Ct(e, t = mt) {
|
|
437
619
|
let n = e.cell_id === null ? void 0 : t.get(e.cell_id);
|
|
438
620
|
return n !== void 0 && n.code !== null && n.code_fingerprint === e.code_fingerprint ? n.code : void 0;
|
|
439
621
|
}
|
|
440
|
-
function
|
|
441
|
-
let n =
|
|
622
|
+
function wt(e, t = mt) {
|
|
623
|
+
let n = Tt(e), r = Ct(e, t);
|
|
442
624
|
return n === null || r === void 0 ? n : {
|
|
443
625
|
...n,
|
|
444
626
|
code: r
|
|
445
627
|
};
|
|
446
628
|
}
|
|
447
|
-
function
|
|
629
|
+
function Tt(e) {
|
|
448
630
|
let t = e.outcome;
|
|
449
631
|
if (t === null) return null;
|
|
450
632
|
switch (t.kind) {
|
|
451
|
-
case "value": return t.display === null ? null :
|
|
452
|
-
case "error": return
|
|
453
|
-
case "interrupted": return
|
|
454
|
-
case "skipped": return
|
|
633
|
+
case "value": return t.display === null ? null : yt(e, t.display);
|
|
634
|
+
case "error": return M(e, [xt(t.error)]);
|
|
635
|
+
case "interrupted": return M(e, [{ type: "interruption" }]);
|
|
636
|
+
case "skipped": return St(e, t);
|
|
455
637
|
}
|
|
456
638
|
}
|
|
457
|
-
function
|
|
639
|
+
function Et(e, t) {
|
|
458
640
|
let n = e.executions.latest.get(t), r = n === void 0 ? void 0 : e.executions.executions.get(n);
|
|
459
641
|
if (r !== void 0 && r.record.outcome !== null && r.record.status !== "completed") return r;
|
|
460
642
|
let i = e.results.get(t) ?? null;
|
|
461
643
|
return r?.record.status === "running" && i?.record.outcome?.kind === "skipped" ? null : i;
|
|
462
644
|
}
|
|
463
|
-
function
|
|
645
|
+
function Dt(e, t) {
|
|
464
646
|
return e?.execution === t.record.id && e.version === t.outputVersion;
|
|
465
647
|
}
|
|
466
|
-
function
|
|
467
|
-
let n =
|
|
468
|
-
return n === null ||
|
|
648
|
+
function Ot(e, t) {
|
|
649
|
+
let n = Et(e, t);
|
|
650
|
+
return n === null || Dt(e.cleared.get(t), n) ? null : wt(n.record, e.cells);
|
|
469
651
|
}
|
|
470
|
-
function
|
|
652
|
+
function kt(e) {
|
|
471
653
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set([...e.results.keys(), ...e.executions.latest.keys()]);
|
|
472
654
|
for (let r of n) {
|
|
473
|
-
let n =
|
|
474
|
-
n !== null && t.set(
|
|
655
|
+
let n = Ot(e, r);
|
|
656
|
+
n !== null && t.set(j(r), n);
|
|
475
657
|
}
|
|
476
658
|
return t;
|
|
477
659
|
}
|
|
478
660
|
//#endregion
|
|
479
661
|
//#region src/utils/time.ts
|
|
480
|
-
var
|
|
662
|
+
var At = class e {
|
|
481
663
|
ms;
|
|
482
664
|
static fromMilliseconds(t) {
|
|
483
665
|
return t == null ? null : new e(t);
|
|
@@ -506,145 +688,145 @@ var _t = class e {
|
|
|
506
688
|
};
|
|
507
689
|
//#endregion
|
|
508
690
|
//#region src/core/executions/select.ts
|
|
509
|
-
function
|
|
691
|
+
function jt(e) {
|
|
510
692
|
let t = e.outcome;
|
|
511
693
|
return t === null ? null : t.kind;
|
|
512
694
|
}
|
|
513
|
-
function
|
|
514
|
-
return e === null ? null :
|
|
695
|
+
function Mt(e) {
|
|
696
|
+
return e === null ? null : At.parse(e).toMilliseconds();
|
|
515
697
|
}
|
|
516
|
-
function
|
|
698
|
+
function Nt(e, t) {
|
|
517
699
|
let n = e.latest.get(t);
|
|
518
700
|
return n === void 0 ? null : e.executions.get(n) ?? null;
|
|
519
701
|
}
|
|
520
|
-
function
|
|
702
|
+
function Pt(e, t) {
|
|
521
703
|
let n = e.cells.get(t);
|
|
522
704
|
return n !== void 0 && !n.config.disabled && !e.blocked.has(t);
|
|
523
705
|
}
|
|
524
|
-
function
|
|
525
|
-
if (!
|
|
706
|
+
function Ft(e, t) {
|
|
707
|
+
if (!Pt(e, t)) return !1;
|
|
526
708
|
if (e.requested.has(t)) return !0;
|
|
527
|
-
let n =
|
|
709
|
+
let n = Nt(e.executions, t)?.record.run_id ?? e.results.get(t)?.record.run_id;
|
|
528
710
|
for (let r of e.executions.runs.values()) if (r.status !== "completed" && r.id !== n && r.cells.includes(t)) return !0;
|
|
529
711
|
return !1;
|
|
530
712
|
}
|
|
531
|
-
function
|
|
532
|
-
let n =
|
|
533
|
-
n !== null && n.record.status !== "completed" ? (i = n.record.status, a =
|
|
534
|
-
let o = i === "idle", s = o && r !== null && r.started_at !== null && r.completed_at !== null ?
|
|
713
|
+
function It(e, t) {
|
|
714
|
+
let n = Nt(e.executions, t), r = e.results.get(t)?.record ?? null, i = "idle", a = r === null ? null : Mt(r.started_at);
|
|
715
|
+
n !== null && n.record.status !== "completed" ? (i = n.record.status, a = Mt(n.record.started_at) ?? a) : Ft(e, t) && (i = "queued");
|
|
716
|
+
let o = i === "idle", s = o && r !== null && r.started_at !== null && r.completed_at !== null ? At.parse(r.completed_at).since(At.parse(r.started_at)) : null;
|
|
535
717
|
return {
|
|
536
718
|
status: i,
|
|
537
719
|
blocked: e.blocked.has(t),
|
|
538
|
-
outcome: o && r !== null ?
|
|
720
|
+
outcome: o && r !== null ? jt(r) : null,
|
|
539
721
|
live: r === null || e.runtimeId === null || r.runtime_id === e.runtimeId,
|
|
540
722
|
startedAt: a,
|
|
541
723
|
duration: s
|
|
542
724
|
};
|
|
543
725
|
}
|
|
544
|
-
function
|
|
726
|
+
function Lt(e) {
|
|
545
727
|
return [...e.executions.values()].filter((e) => e.record.status !== "completed");
|
|
546
728
|
}
|
|
547
|
-
function
|
|
548
|
-
return
|
|
729
|
+
function Rt(e) {
|
|
730
|
+
return Lt(e).some((e) => e.record.status === "running");
|
|
549
731
|
}
|
|
550
|
-
function
|
|
551
|
-
let t =
|
|
732
|
+
function zt(e) {
|
|
733
|
+
let t = Lt(e.executions), n = new Set(t.flatMap((e) => e.record.cell_id === null ? [] : [e.record.cell_id])), r = new Set(e.requested);
|
|
552
734
|
for (let t of e.executions.runs.values()) if (t.status !== "completed") for (let e of t.cells) r.add(e);
|
|
553
735
|
let i = 0;
|
|
554
|
-
for (let t of r) !n.has(t) &&
|
|
736
|
+
for (let t of r) !n.has(t) && Ft(e, t) && (i += 1);
|
|
555
737
|
return t.length + i;
|
|
556
738
|
}
|
|
557
739
|
//#endregion
|
|
558
740
|
//#region src/core/executions/atoms.ts
|
|
559
|
-
var
|
|
741
|
+
var Bt = {
|
|
560
742
|
runs: /* @__PURE__ */ new Map(),
|
|
561
743
|
executions: /* @__PURE__ */ new Map(),
|
|
562
744
|
latest: /* @__PURE__ */ new Map(),
|
|
563
745
|
results: /* @__PURE__ */ new Map(),
|
|
564
746
|
scratch: null
|
|
565
|
-
},
|
|
566
|
-
function
|
|
747
|
+
}, Vt = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map(), Ht = /* @__PURE__ */ new Set(), Ut = /* @__PURE__ */ new Set(), Wt = /* @__PURE__ */ new Set(), Gt = /* @__PURE__ */ new Map(), P = x(null), Kt = x(null);
|
|
748
|
+
function qt(e, t) {
|
|
567
749
|
return t !== null && e.replica === t.replica && e.id === t.id && e.generation === t.generation;
|
|
568
750
|
}
|
|
569
|
-
function
|
|
570
|
-
return e !== null &&
|
|
751
|
+
function F(e, t, n) {
|
|
752
|
+
return e !== null && qt(e.notebook, t) ? e.value : n;
|
|
571
753
|
}
|
|
572
|
-
var
|
|
573
|
-
let t = e(
|
|
754
|
+
var I = x((e) => {
|
|
755
|
+
let t = e(h), n = t === null ? null : e(t.notebookAtom);
|
|
574
756
|
return t === null || n === null ? null : {
|
|
575
757
|
replica: t,
|
|
576
758
|
id: n.id,
|
|
577
759
|
generation: e(t.generationAtom)
|
|
578
760
|
};
|
|
579
761
|
});
|
|
580
|
-
function
|
|
581
|
-
return
|
|
582
|
-
}
|
|
583
|
-
var
|
|
584
|
-
let t =
|
|
585
|
-
return t.size === 0 ?
|
|
586
|
-
}),
|
|
587
|
-
let t = e(
|
|
762
|
+
function Jt(e, t) {
|
|
763
|
+
return qt(t.notebook, e.get(I));
|
|
764
|
+
}
|
|
765
|
+
var Yt = x((e) => {
|
|
766
|
+
let t = F(e(P), e(I), Ht);
|
|
767
|
+
return t.size === 0 ? Ut : new Set([...t].flatMap((e) => e.cells));
|
|
768
|
+
}), L = x((e) => {
|
|
769
|
+
let t = e(h), n = t === null ? null : e(t.shownDocumentAtom);
|
|
588
770
|
return {
|
|
589
|
-
executions: t === null ?
|
|
590
|
-
results: t === null ?
|
|
591
|
-
cells: n?.cells ??
|
|
592
|
-
requested: e(
|
|
593
|
-
blocked:
|
|
771
|
+
executions: t === null ? Bt : e(t.executionsAtom),
|
|
772
|
+
results: t === null ? Vt : e(t.resultsAtom),
|
|
773
|
+
cells: n?.cells ?? N,
|
|
774
|
+
requested: e(Yt),
|
|
775
|
+
blocked: F(e(Kt), e(I), Wt),
|
|
594
776
|
runtimeId: t === null ? null : e(t.runtimeAtom)?.id ?? null
|
|
595
777
|
};
|
|
596
|
-
}),
|
|
597
|
-
let t = e(
|
|
778
|
+
}), Xt = x((e) => {
|
|
779
|
+
let t = e(h), n = t === null ? null : e(t.shownDocumentAtom);
|
|
598
780
|
return t === null || n === null ? {
|
|
599
|
-
cells:
|
|
600
|
-
executions:
|
|
601
|
-
results:
|
|
781
|
+
cells: N,
|
|
782
|
+
executions: Bt,
|
|
783
|
+
results: Vt
|
|
602
784
|
} : {
|
|
603
785
|
cells: n.cells,
|
|
604
786
|
executions: e(t.executionsAtom),
|
|
605
787
|
results: e(t.resultsAtom)
|
|
606
788
|
};
|
|
607
|
-
}),
|
|
608
|
-
let t = e(
|
|
789
|
+
}), Zt = x((e) => pt(e(Xt))), Qt = x(null), $t = x((e) => {
|
|
790
|
+
let t = e(h), n = t === null ? null : e(t.shownDocumentAtom);
|
|
609
791
|
return t === null || n === null ? null : {
|
|
610
792
|
replica: t,
|
|
611
793
|
id: n.revision.notebook_id,
|
|
612
794
|
generation: e(t.generationAtom)
|
|
613
795
|
};
|
|
614
|
-
}),
|
|
615
|
-
let t = e(
|
|
796
|
+
}), en = x((e) => {
|
|
797
|
+
let t = e(h);
|
|
616
798
|
return {
|
|
617
|
-
executions: t === null ?
|
|
618
|
-
results: t === null ?
|
|
619
|
-
cleared:
|
|
620
|
-
cells: t === null ?
|
|
799
|
+
executions: t === null ? Bt : e(t.executionsAtom),
|
|
800
|
+
results: t === null ? Vt : e(t.resultsAtom),
|
|
801
|
+
cleared: F(e(Qt), e($t), Gt),
|
|
802
|
+
cells: t === null ? N : e(t.documentAtom)?.cells ?? N
|
|
621
803
|
};
|
|
622
|
-
}),
|
|
623
|
-
function
|
|
624
|
-
|
|
804
|
+
}), tn = x((e) => kt(e(en))), R = S((e) => _(tn, (t) => t.get(e) ?? null, g)), z = S((e) => x((t) => Ye(t(R(e)))));
|
|
805
|
+
function nn(e) {
|
|
806
|
+
R.remove(e), z.remove(e);
|
|
625
807
|
}
|
|
626
|
-
function
|
|
627
|
-
let n = e.get(
|
|
808
|
+
function rn(e, t) {
|
|
809
|
+
let n = e.get(en), r = new Map(n.cleared);
|
|
628
810
|
for (let e of t) {
|
|
629
|
-
let t =
|
|
811
|
+
let t = Et(n, e);
|
|
630
812
|
t?.record.outcome != null && r.set(e, {
|
|
631
813
|
execution: t.record.id,
|
|
632
814
|
version: t.outputVersion
|
|
633
815
|
});
|
|
634
816
|
}
|
|
635
|
-
let i = e.get(
|
|
636
|
-
e.set(
|
|
817
|
+
let i = e.get($t);
|
|
818
|
+
e.set(Qt, i === null ? null : {
|
|
637
819
|
notebook: i,
|
|
638
820
|
value: r
|
|
639
821
|
});
|
|
640
822
|
}
|
|
641
|
-
var
|
|
642
|
-
let t = e(
|
|
823
|
+
var an = x((e) => {
|
|
824
|
+
let t = e(h);
|
|
643
825
|
return t === null ? null : e(t.runtimeAtom)?.status ?? null;
|
|
644
826
|
});
|
|
645
|
-
|
|
646
|
-
var
|
|
647
|
-
let t = e(
|
|
827
|
+
x((e) => Rt(e(L).executions)), x((e) => zt(e(L)));
|
|
828
|
+
var on = x((e) => {
|
|
829
|
+
let t = e(h);
|
|
648
830
|
if (t === null) return { refused: "No notebook is connected" };
|
|
649
831
|
if (e(t.connectionAtom).state === O.CLOSED) return { refused: "The notebook is disconnected" };
|
|
650
832
|
if (e(t.notebookAtom) === null) return "waiting";
|
|
@@ -656,72 +838,69 @@ var qt = b((e) => {
|
|
|
656
838
|
default: return "waiting";
|
|
657
839
|
}
|
|
658
840
|
});
|
|
659
|
-
function
|
|
841
|
+
function sn(e) {
|
|
660
842
|
return new Promise((t, n) => {
|
|
661
|
-
let r = e.sub(
|
|
843
|
+
let r = e.sub(on, i);
|
|
662
844
|
function i() {
|
|
663
|
-
let i = e.get(
|
|
845
|
+
let i = e.get(on);
|
|
664
846
|
i !== "waiting" && (r(), i === "running" ? t() : n(Error(i.refused)));
|
|
665
847
|
}
|
|
666
848
|
i();
|
|
667
849
|
});
|
|
668
850
|
}
|
|
669
|
-
function
|
|
670
|
-
let n = e.get(
|
|
851
|
+
function cn(e, t) {
|
|
852
|
+
let n = e.get(I);
|
|
671
853
|
if (n === null) return null;
|
|
672
854
|
let r = {
|
|
673
855
|
notebook: n,
|
|
674
856
|
cells: [...t]
|
|
675
|
-
}, i =
|
|
676
|
-
return e.set(
|
|
857
|
+
}, i = F(e.get(P), n, Ht);
|
|
858
|
+
return e.set(P, {
|
|
677
859
|
notebook: n,
|
|
678
860
|
value: new Set(i).add(r)
|
|
679
861
|
}), r;
|
|
680
862
|
}
|
|
681
|
-
function
|
|
682
|
-
let n = e.get(
|
|
863
|
+
function ln(e, t) {
|
|
864
|
+
let n = e.get(P);
|
|
683
865
|
if (n === null || !n.value.has(t)) return;
|
|
684
866
|
let r = new Set(n.value);
|
|
685
|
-
r.delete(t), e.set(
|
|
867
|
+
r.delete(t), e.set(P, {
|
|
686
868
|
notebook: n.notebook,
|
|
687
869
|
value: r
|
|
688
870
|
});
|
|
689
871
|
}
|
|
690
|
-
function
|
|
691
|
-
let r =
|
|
872
|
+
function un(e, t, n) {
|
|
873
|
+
let r = x((e) => qt(t.notebook, e(I)) && !e(t.notebook.replica.executionsAtom).runs.has(n.id)), i = e.sub(r, a);
|
|
692
874
|
function a() {
|
|
693
|
-
e.get(r) || (i(),
|
|
875
|
+
e.get(r) || (i(), ln(e, t));
|
|
694
876
|
}
|
|
695
877
|
a();
|
|
696
878
|
}
|
|
697
|
-
function
|
|
698
|
-
let r = e.get(
|
|
879
|
+
function dn(e, t, n) {
|
|
880
|
+
let r = e.get(L).blocked;
|
|
699
881
|
if (r.has(t) === n) return;
|
|
700
882
|
let i = new Set(r);
|
|
701
883
|
n ? i.add(t) : i.delete(t);
|
|
702
|
-
let a = e.get(
|
|
703
|
-
a !== null && e.set(
|
|
884
|
+
let a = e.get(I);
|
|
885
|
+
a !== null && e.set(Kt, {
|
|
704
886
|
notebook: a,
|
|
705
887
|
value: i
|
|
706
888
|
});
|
|
707
889
|
}
|
|
708
|
-
function $t(e, t) {
|
|
709
|
-
t.status != null && Qt(e, t.cell_id, t.status === "disabled-transitively");
|
|
710
|
-
}
|
|
711
890
|
//#endregion
|
|
712
891
|
//#region src/core/codemirror/editing/commands.ts
|
|
713
|
-
var
|
|
714
|
-
function
|
|
892
|
+
var fn = a();
|
|
893
|
+
function pn(e) {
|
|
715
894
|
return (t) => {
|
|
716
895
|
let n = !1;
|
|
717
896
|
for (let r of t) r && (n = e(r) || n);
|
|
718
897
|
return n;
|
|
719
898
|
};
|
|
720
899
|
}
|
|
721
|
-
var
|
|
900
|
+
var mn = pn(ge), hn = pn(he);
|
|
722
901
|
//#endregion
|
|
723
902
|
//#region src/utils/schedule-task.ts
|
|
724
|
-
function
|
|
903
|
+
function gn() {
|
|
725
904
|
let e = globalThis.scheduler;
|
|
726
905
|
if (typeof e?.postTask == "function") return (t) => {
|
|
727
906
|
e.postTask(t, { priority: "user-visible" }).catch((e) => {
|
|
@@ -742,10 +921,10 @@ function an() {
|
|
|
742
921
|
setTimeout(e, 0);
|
|
743
922
|
};
|
|
744
923
|
}
|
|
745
|
-
var
|
|
924
|
+
var _n = gn();
|
|
746
925
|
//#endregion
|
|
747
926
|
//#region src/core/codemirror/editor-mount-scheduler.ts
|
|
748
|
-
function
|
|
927
|
+
function vn(e = _n) {
|
|
749
928
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = !1;
|
|
750
929
|
function i() {
|
|
751
930
|
r || t.size === 0 || (r = !0, e(o));
|
|
@@ -788,29 +967,157 @@ function sn(e = on) {
|
|
|
788
967
|
}
|
|
789
968
|
};
|
|
790
969
|
}
|
|
791
|
-
var
|
|
970
|
+
var yn = vn();
|
|
971
|
+
//#endregion
|
|
972
|
+
//#region src/core/mime.ts
|
|
973
|
+
function bn(e) {
|
|
974
|
+
return e === "application/vnd.marimo+error";
|
|
975
|
+
}
|
|
976
|
+
function xn(e) {
|
|
977
|
+
return e === "application/vnd.marimo+traceback";
|
|
978
|
+
}
|
|
979
|
+
function Sn(e) {
|
|
980
|
+
return bn(e) || xn(e);
|
|
981
|
+
}
|
|
982
|
+
//#endregion
|
|
983
|
+
//#region src/core/cells/command-console.ts
|
|
984
|
+
function Cn(e, { op: t, entries: n, replace: r, after_seq: i }, a) {
|
|
985
|
+
if (t === "callback-output" && !r && n.length === 0) return { entries: [] };
|
|
986
|
+
let o = r || n.length === 0, s = e?.entries ?? [], c = r && a !== void 0 ? n.findIndex((e) => e.command_id === a) : -1, l = n.slice(c + 1).map((e, n) => ({
|
|
987
|
+
...e,
|
|
988
|
+
source: t,
|
|
989
|
+
afterSeq: i?.[c + 1 + n]
|
|
990
|
+
}));
|
|
991
|
+
return { entries: [...o ? s.filter((e) => e.source !== t) : s, ...l] };
|
|
992
|
+
}
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/core/dom/ui-element-constants.ts
|
|
995
|
+
var wn = "object-id", Tn = "random-id", En = "abcdefghijklmnopqrstuvwxyz", Dn = En + En.toUpperCase(), On = /* @__PURE__ */ new Set(), B = "__scratch__", kn = "setup", An = { create() {
|
|
996
|
+
let e = 0, t;
|
|
997
|
+
do {
|
|
998
|
+
let n = "";
|
|
999
|
+
for (let e = 0; e < 4; e++) n += Dn[Math.floor(Math.random() * 52)];
|
|
1000
|
+
t = n, e++;
|
|
1001
|
+
} while (On.has(t) && e < 100);
|
|
1002
|
+
if (e >= 100) throw Error("Failed to generate unique CellId after 100 attempts");
|
|
1003
|
+
return On.add(t), t;
|
|
1004
|
+
} }, V = {
|
|
1005
|
+
create(e) {
|
|
1006
|
+
return C(e != null, "cellId is required"), `cell-${e}`;
|
|
1007
|
+
},
|
|
1008
|
+
parse(e) {
|
|
1009
|
+
return e.slice(5);
|
|
1010
|
+
},
|
|
1011
|
+
findElement(e) {
|
|
1012
|
+
return e.closest("div[id^=\"cell-\"]");
|
|
1013
|
+
},
|
|
1014
|
+
findElementThroughShadowDOMs(e) {
|
|
1015
|
+
let t = e;
|
|
1016
|
+
for (; t;) {
|
|
1017
|
+
let e = V.findElement(t);
|
|
1018
|
+
if (e) return e;
|
|
1019
|
+
let n = t.getRootNode();
|
|
1020
|
+
if (t = n instanceof ShadowRoot ? n.host : t.parentElement, t === n) break;
|
|
1021
|
+
}
|
|
1022
|
+
return null;
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
function jn(e) {
|
|
1026
|
+
let t = null, n = V.findElementThroughShadowDOMs(e);
|
|
1027
|
+
return n && (t = V.parse(n.id)), t;
|
|
1028
|
+
}
|
|
1029
|
+
var Mn = {
|
|
1030
|
+
parse(e) {
|
|
1031
|
+
return e.getAttribute(wn);
|
|
1032
|
+
},
|
|
1033
|
+
parseOrThrow(e) {
|
|
1034
|
+
let t = Mn.parse(e);
|
|
1035
|
+
return C(t, "<marimo-ui-element/> missing object-id attribute"), t;
|
|
1036
|
+
}
|
|
1037
|
+
}, Nn = { create(e) {
|
|
1038
|
+
return `output-${e}`;
|
|
1039
|
+
} }, Pn = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g, Fn = class e {
|
|
1040
|
+
static get INSTANCE() {
|
|
1041
|
+
let t = "_marimo_private_VirtualFileTracker";
|
|
1042
|
+
return window[t] || (window[t] = new e()), window[t];
|
|
1043
|
+
}
|
|
1044
|
+
virtualFiles = /* @__PURE__ */ new Map();
|
|
1045
|
+
callbackFiles = /* @__PURE__ */ new Map();
|
|
1046
|
+
constructor() {}
|
|
1047
|
+
track(e) {
|
|
1048
|
+
this.trackValue(e.cell_id, e.output);
|
|
1049
|
+
}
|
|
1050
|
+
trackExecution(e) {
|
|
1051
|
+
let t = e.outcome?.kind === "value" ? e.outcome.display : null;
|
|
1052
|
+
t && this.trackValue(e.cell_id ?? "__scratch__", t);
|
|
1053
|
+
}
|
|
1054
|
+
trackCallbackOutput(e) {
|
|
1055
|
+
(e.replace || e.entries.length === 0) && this.callbackFiles.delete(e.cell_id);
|
|
1056
|
+
for (let t of e.entries) this.trackValue(e.cell_id, t, this.callbackFiles);
|
|
1057
|
+
}
|
|
1058
|
+
trackValue(e, t, n = this.virtualFiles) {
|
|
1059
|
+
switch (t.mimetype) {
|
|
1060
|
+
case "application/json":
|
|
1061
|
+
case "text/html": {
|
|
1062
|
+
let r = n.get(e), i = In(t.data);
|
|
1063
|
+
r?.forEach((e) => i.add(e)), n.set(e, i);
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
default: return;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
filenames() {
|
|
1070
|
+
let e = /* @__PURE__ */ new Set();
|
|
1071
|
+
for (let t of [...this.virtualFiles.values(), ...this.callbackFiles.values()]) t.forEach((t) => e.add(t));
|
|
1072
|
+
return [...e];
|
|
1073
|
+
}
|
|
1074
|
+
removeForCellId(e) {
|
|
1075
|
+
this.virtualFiles.delete(e), this.callbackFiles.delete(e);
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
function In(e) {
|
|
1079
|
+
if (!e) return /* @__PURE__ */ new Set();
|
|
1080
|
+
let t = /* @__PURE__ */ new Set(), n = (typeof e == "string" ? e : JSON.stringify(e)).match(Pn);
|
|
1081
|
+
if (n) for (let e of n) t.add(e);
|
|
1082
|
+
return t;
|
|
1083
|
+
}
|
|
1084
|
+
//#endregion
|
|
1085
|
+
//#region src/components/editor/output/ansi-reduce.ts
|
|
1086
|
+
var Ln = class e {
|
|
792
1087
|
lines = [""];
|
|
793
1088
|
cursor = {
|
|
794
1089
|
row: 0,
|
|
795
1090
|
col: 0
|
|
796
1091
|
};
|
|
1092
|
+
firstRow;
|
|
1093
|
+
constructor(e = 0) {
|
|
1094
|
+
this.firstRow = e;
|
|
1095
|
+
}
|
|
1096
|
+
copy(t = 0) {
|
|
1097
|
+
let n = new e(this.firstRow + t);
|
|
1098
|
+
return n.lines = this.lines.slice(t), n.cursor = {
|
|
1099
|
+
row: this.cursor.row - t,
|
|
1100
|
+
col: this.cursor.col
|
|
1101
|
+
}, n;
|
|
1102
|
+
}
|
|
797
1103
|
static ESCAPE_REGEX = new RegExp(String.raw`\u001B\[([0-9;]*)([A-DJKH])`, "u");
|
|
798
1104
|
ensureLine(e) {
|
|
799
1105
|
for (; this.lines.length <= e;) this.lines.push("");
|
|
800
1106
|
}
|
|
801
1107
|
moveCursor(e, t) {
|
|
802
|
-
this.cursor.row = Math.max(
|
|
1108
|
+
this.cursor.row = Math.max(-this.firstRow, this.cursor.row + e), this.cursor.col = Math.max(0, this.cursor.col + t), this.ensureLine(this.cursor.row);
|
|
803
1109
|
}
|
|
804
1110
|
setCursor(e, t) {
|
|
805
|
-
this.cursor.row = Math.max(0, e), this.cursor.col = Math.max(0, t), this.ensureLine(this.cursor.row);
|
|
1111
|
+
this.cursor.row = Math.max(0, e) - this.firstRow, this.cursor.col = Math.max(0, t), this.ensureLine(this.cursor.row);
|
|
806
1112
|
}
|
|
807
1113
|
writeChar(e) {
|
|
808
|
-
this.
|
|
809
|
-
let t = this.lines[this.cursor.row].padEnd(this.cursor.col, " ");
|
|
810
|
-
this.lines[this.cursor.row] = t.slice(0, this.cursor.col) + e + t.slice(this.cursor.col + 1), this.cursor.col++;
|
|
1114
|
+
this.writeString(e);
|
|
811
1115
|
}
|
|
812
1116
|
writeString(e) {
|
|
813
|
-
if (e.length === 0)
|
|
1117
|
+
if (this.cursor.row < 0 || e.length === 0) {
|
|
1118
|
+
this.cursor.col += e.length;
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
814
1121
|
this.ensureLine(this.cursor.row);
|
|
815
1122
|
let t = this.lines[this.cursor.row].padEnd(this.cursor.col, " ");
|
|
816
1123
|
this.lines[this.cursor.row] = t.slice(0, this.cursor.col) + e + t.slice(this.cursor.col + e.length), this.cursor.col += e.length;
|
|
@@ -856,9 +1163,10 @@ var cn = sn(), ln = class e {
|
|
|
856
1163
|
this.setCursor(r[0] - 1 || 0, r[1] - 1 || 0);
|
|
857
1164
|
break;
|
|
858
1165
|
case "J":
|
|
859
|
-
r[0] === 2 && (this.lines = [""], this.setCursor(0, 0));
|
|
1166
|
+
r[0] === 2 && (this.lines = [""], this.firstRow = 0, this.setCursor(0, 0));
|
|
860
1167
|
break;
|
|
861
1168
|
case "K":
|
|
1169
|
+
if (this.cursor.row < 0) break;
|
|
862
1170
|
switch (this.ensureLine(this.cursor.row), r[0]) {
|
|
863
1171
|
case 0:
|
|
864
1172
|
this.lines[this.cursor.row] = this.lines[this.cursor.row].slice(0, this.cursor.col);
|
|
@@ -877,7 +1185,7 @@ var cn = sn(), ln = class e {
|
|
|
877
1185
|
render() {
|
|
878
1186
|
return this.lines.join("\n");
|
|
879
1187
|
}
|
|
880
|
-
},
|
|
1188
|
+
}, Rn = class {
|
|
881
1189
|
ESC_REGEX = new RegExp(String.raw`\u001B(?:\[[0-9;]*[A-Za-z]|\([0-9A-Za-z])`, "gu");
|
|
882
1190
|
parse(e) {
|
|
883
1191
|
let t = [], n = 0;
|
|
@@ -896,25 +1204,37 @@ var cn = sn(), ln = class e {
|
|
|
896
1204
|
value: e.slice(n)
|
|
897
1205
|
}), t;
|
|
898
1206
|
}
|
|
899
|
-
},
|
|
900
|
-
parser = new
|
|
901
|
-
buffer
|
|
1207
|
+
}, zn = class e {
|
|
1208
|
+
parser = new Rn();
|
|
1209
|
+
buffer;
|
|
1210
|
+
incompleteEscape = "";
|
|
1211
|
+
static INCOMPLETE_ESCAPE = new RegExp(String.raw`\u001B(?:\[[0-9;]*|\()?$`, "u");
|
|
1212
|
+
constructor(e = 0) {
|
|
1213
|
+
this.buffer = new Ln(e);
|
|
1214
|
+
}
|
|
1215
|
+
copy(t = 0) {
|
|
1216
|
+
let n = new e();
|
|
1217
|
+
return n.buffer = this.buffer.copy(t), n.incompleteEscape = this.incompleteEscape, n;
|
|
1218
|
+
}
|
|
902
1219
|
reduce(e) {
|
|
903
1220
|
return this.reset(), this.append(e), this.render();
|
|
904
1221
|
}
|
|
905
|
-
append(
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
1222
|
+
append(t) {
|
|
1223
|
+
t = this.incompleteEscape + t;
|
|
1224
|
+
let n = e.INCOMPLETE_ESCAPE.exec(t);
|
|
1225
|
+
this.incompleteEscape = n?.[0] ?? "", n && (t = t.slice(0, n.index));
|
|
1226
|
+
let r = this.parser.parse(t);
|
|
1227
|
+
if (r.length === 1 && r[0].type === "text") {
|
|
1228
|
+
let e = r[0].value;
|
|
909
1229
|
if (!this.hasControlChars(e)) {
|
|
910
1230
|
this.buffer.writeString(e);
|
|
911
1231
|
return;
|
|
912
1232
|
}
|
|
913
1233
|
}
|
|
914
|
-
for (let e of
|
|
1234
|
+
for (let e of r) e.type === "text" ? this.processText(e.value) : this.buffer.handleEscape(e.value);
|
|
915
1235
|
}
|
|
916
1236
|
reset() {
|
|
917
|
-
this.buffer = new
|
|
1237
|
+
this.buffer = new Ln(), this.incompleteEscape = "";
|
|
918
1238
|
}
|
|
919
1239
|
render() {
|
|
920
1240
|
return this.buffer.render();
|
|
@@ -957,42 +1277,62 @@ var cn = sn(), ln = class e {
|
|
|
957
1277
|
for (let t of e) t >= " " && (n += t);
|
|
958
1278
|
return n;
|
|
959
1279
|
}
|
|
960
|
-
}
|
|
1280
|
+
};
|
|
1281
|
+
function Bn(e) {
|
|
1282
|
+
let t = 1;
|
|
1283
|
+
for (let n = 0; n < e.length; n++) {
|
|
1284
|
+
let r = e.charCodeAt(n);
|
|
1285
|
+
if (r === 10) t++;
|
|
1286
|
+
else if (r < 32) return;
|
|
1287
|
+
}
|
|
1288
|
+
return t;
|
|
1289
|
+
}
|
|
1290
|
+
var H = class e {
|
|
961
1291
|
mimetype;
|
|
962
1292
|
channel;
|
|
963
1293
|
timestamp;
|
|
964
1294
|
code;
|
|
965
1295
|
id;
|
|
966
1296
|
input_id;
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1297
|
+
data;
|
|
1298
|
+
lineCount;
|
|
1299
|
+
terminal;
|
|
1300
|
+
firstPlainRow;
|
|
1301
|
+
constructor(e, t) {
|
|
1302
|
+
this.data = t.data, this.lineCount = t.lineCount, this.terminal = t.terminal, this.firstPlainRow = t.firstPlainRow ?? 0, this.mimetype = e.mimetype, this.channel = e.channel, this.timestamp = e.timestamp, this.code = e.code, this.id = e.id, this.input_id = e.input_id;
|
|
971
1303
|
}
|
|
972
1304
|
static create(t) {
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
timestamp: t.timestamp,
|
|
978
|
-
ansiReducer: n,
|
|
979
|
-
code: t.code,
|
|
980
|
-
id: t.id,
|
|
981
|
-
input_id: t.input_id
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
constructor({ mimetype: e, channel: t, timestamp: n, ansiReducer: r, code: i, id: a, input_id: o }) {
|
|
985
|
-
this.mimetype = e, this.channel = t, this.timestamp = n, this.code = i, this.id = a, this.input_id = o, this.ansiReducer = r, this._data = this.ansiReducer.render();
|
|
1305
|
+
return new e(t, {
|
|
1306
|
+
data: "",
|
|
1307
|
+
lineCount: 1
|
|
1308
|
+
}).appendData(t.data);
|
|
986
1309
|
}
|
|
987
1310
|
appendData(t) {
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1311
|
+
if (!this.terminal) {
|
|
1312
|
+
let n = Bn(t);
|
|
1313
|
+
if (n !== void 0) return new e(this, {
|
|
1314
|
+
data: this.data + t,
|
|
1315
|
+
lineCount: this.lineCount + n - 1,
|
|
1316
|
+
firstPlainRow: this.firstPlainRow
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
let n = this.terminal?.copy() ?? new zn(this.firstPlainRow);
|
|
1320
|
+
this.terminal || n.append(this.data), n.append(t);
|
|
1321
|
+
let r = n.render();
|
|
1322
|
+
return new e(this, {
|
|
1323
|
+
data: r,
|
|
1324
|
+
lineCount: r.split("\n").length,
|
|
1325
|
+
terminal: n
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
dropFirstLines(t) {
|
|
1329
|
+
if (t === 0) return this;
|
|
1330
|
+
let n = this.terminal?.copy(t);
|
|
1331
|
+
return new e(this, {
|
|
1332
|
+
data: n?.render() ?? this.data.split("\n").slice(t).join("\n"),
|
|
1333
|
+
lineCount: this.lineCount - t,
|
|
1334
|
+
terminal: n,
|
|
1335
|
+
firstPlainRow: this.firstPlainRow + t
|
|
996
1336
|
});
|
|
997
1337
|
}
|
|
998
1338
|
toJSON() {
|
|
@@ -1004,404 +1344,100 @@ var cn = sn(), ln = class e {
|
|
|
1004
1344
|
...this.code === void 0 ? {} : { code: this.code }
|
|
1005
1345
|
};
|
|
1006
1346
|
}
|
|
1007
|
-
};
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
let
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1347
|
+
}, Vn = 5e3;
|
|
1348
|
+
function Hn(e, t = Vn) {
|
|
1349
|
+
let n = e.slice(0, -1), r = e.at(-1);
|
|
1350
|
+
return r && Wn(n, r), Yn(n, t);
|
|
1351
|
+
}
|
|
1352
|
+
function Un(e) {
|
|
1353
|
+
let t = [];
|
|
1354
|
+
for (let n = 0; n < e.length;) {
|
|
1355
|
+
let r = e[n], i = n + 1;
|
|
1356
|
+
for (; i < e.length && Gn(r, e[i]);) i++;
|
|
1357
|
+
if (i === n + 1) Wn(t, r);
|
|
1358
|
+
else {
|
|
1359
|
+
let a = e.slice(n, i).map((e) => (Jn(e), e.data));
|
|
1360
|
+
t.push(H.create({
|
|
1361
|
+
...r,
|
|
1362
|
+
data: a.join("")
|
|
1363
|
+
}));
|
|
1364
|
+
}
|
|
1365
|
+
n = i;
|
|
1366
|
+
}
|
|
1367
|
+
return Yn(t, Vn);
|
|
1368
|
+
}
|
|
1369
|
+
function Wn(e, t) {
|
|
1370
|
+
let n = e.at(-1);
|
|
1371
|
+
n && Gn(n, t) ? (Jn(n), Jn(t), e[e.length - 1] = qn(n, t)) : e.push(Kn(t));
|
|
1372
|
+
}
|
|
1373
|
+
function Gn(e, t) {
|
|
1017
1374
|
let n = e.mimetype === "text/plain" && t.mimetype === "text/plain";
|
|
1018
1375
|
if (!n) return !1;
|
|
1019
1376
|
let r = e.channel === t.channel, i = e.channel !== "stdin";
|
|
1020
1377
|
return n && r && i;
|
|
1021
1378
|
}
|
|
1022
|
-
function
|
|
1023
|
-
return e instanceof
|
|
1379
|
+
function Kn(e) {
|
|
1380
|
+
return e instanceof H ? e : e.mimetype === "text/plain" && e.channel !== "stdin" && typeof e.data == "string" ? H.create(e) : e;
|
|
1024
1381
|
}
|
|
1025
|
-
function
|
|
1026
|
-
return e instanceof
|
|
1382
|
+
function qn(e, t) {
|
|
1383
|
+
return e instanceof H ? e.appendData(t.data) : H.create(e).appendData(t.data);
|
|
1027
1384
|
}
|
|
1028
|
-
function
|
|
1385
|
+
function Jn(e) {
|
|
1029
1386
|
C(typeof e.data == "string", "expected string output");
|
|
1030
1387
|
}
|
|
1031
|
-
function
|
|
1388
|
+
function Yn(e, t) {
|
|
1032
1389
|
let n = 0, r;
|
|
1033
1390
|
for (r = e.length - 1; r >= 0 && n < t; r--) {
|
|
1034
1391
|
let t = e[r];
|
|
1035
|
-
t.mimetype === "text/plain" ? (C(typeof t.data == "string", "expected string"), n += t.data.split("\n").length) : n++;
|
|
1392
|
+
t.mimetype === "text/plain" ? (C(typeof t.data == "string", "expected string"), n += t instanceof H ? t.lineCount : t.data.split("\n").length) : n++;
|
|
1036
1393
|
}
|
|
1037
1394
|
if (n < t) return e;
|
|
1038
|
-
let i = r + 1, a = {
|
|
1395
|
+
let i = r + 1, a = [{
|
|
1039
1396
|
channel: "stderr",
|
|
1040
1397
|
mimetype: "text/html",
|
|
1041
1398
|
data: `<pre>Streaming output truncated to last ${t} lines.\n</pre>`,
|
|
1042
1399
|
timestamp: -1
|
|
1043
|
-
}, o = e[i];
|
|
1044
|
-
if (o
|
|
1045
|
-
if (o
|
|
1400
|
+
}, ...e.slice(0, i).filter((e) => e.channel === "stdin" && e.response === void 0)], o = e[i];
|
|
1401
|
+
if (o?.channel === "stdin" && o.response === void 0) return [...a, ...e.slice(i)];
|
|
1402
|
+
if (o?.mimetype === "text/plain") {
|
|
1046
1403
|
C(typeof o.data == "string", "expected string");
|
|
1047
|
-
let r =
|
|
1404
|
+
let r = n - t, s = o instanceof H ? o.dropFirstLines(r) : {
|
|
1405
|
+
...o,
|
|
1406
|
+
data: o.data.split("\n").slice(r).join("\n")
|
|
1407
|
+
};
|
|
1048
1408
|
return [
|
|
1049
|
-
a,
|
|
1050
|
-
|
|
1051
|
-
...o,
|
|
1052
|
-
data: r.slice(-s).join("\n")
|
|
1053
|
-
},
|
|
1409
|
+
...a,
|
|
1410
|
+
s,
|
|
1054
1411
|
...e.slice(i + 1)
|
|
1055
1412
|
];
|
|
1056
1413
|
}
|
|
1057
|
-
return [a, ...e.slice(i + 1)];
|
|
1414
|
+
return [...a, ...e.slice(i + 1)];
|
|
1058
1415
|
}
|
|
1059
1416
|
//#endregion
|
|
1060
|
-
//#region
|
|
1061
|
-
function
|
|
1062
|
-
return e
|
|
1063
|
-
}
|
|
1064
|
-
function yn(e) {
|
|
1065
|
-
return e === "application/vnd.marimo+traceback";
|
|
1066
|
-
}
|
|
1067
|
-
function R(e) {
|
|
1068
|
-
return vn(e) || yn(e);
|
|
1069
|
-
}
|
|
1070
|
-
//#endregion
|
|
1071
|
-
//#region src/core/cells/cell.ts
|
|
1072
|
-
function bn(e) {
|
|
1073
|
-
return (e.at(-1)?.id ?? 0) + 1;
|
|
1074
|
-
}
|
|
1075
|
-
function xn(e) {
|
|
1076
|
-
return e == null || e.mimetype !== "application/vnd.marimo+error" || !Array.isArray(e.data) ? [] : e.data.map((e) => e.type);
|
|
1077
|
-
}
|
|
1078
|
-
function Sn(e, t) {
|
|
1079
|
-
let n = { ...e };
|
|
1080
|
-
t.status === "running" && n.pdbOutput && delete n.pdbOutput, t.status === "queued" && (n.debuggerActive = !1), t.serialization !== void 0 && (n.serialization = t.serialization);
|
|
1081
|
-
let r = xn(t.output).includes("interruption"), i = e.consoleOutputs;
|
|
1082
|
-
(r || t.status === "idle") && (n.debuggerActive = !1, i = i.map((e) => e.channel === "stdin" ? {
|
|
1083
|
-
channel: e.channel,
|
|
1084
|
-
mimetype: e.mimetype,
|
|
1085
|
-
data: e.data,
|
|
1086
|
-
timestamp: e.timestamp,
|
|
1087
|
-
id: e.id,
|
|
1088
|
-
input_id: e.input_id,
|
|
1089
|
-
response: e.response ?? ""
|
|
1090
|
-
} : e));
|
|
1091
|
-
let a = t.console;
|
|
1092
|
-
a != null && (i = fn(Array.isArray(a) ? a.map((e, t) => ({
|
|
1093
|
-
...e,
|
|
1094
|
-
id: t + 1
|
|
1095
|
-
})) : [...i, {
|
|
1096
|
-
...a,
|
|
1097
|
-
id: bn(i)
|
|
1098
|
-
}])), n.consoleOutputs = i;
|
|
1099
|
-
let o = [t.console].flat().filter(Boolean).filter((e) => e.channel === "pdb");
|
|
1100
|
-
return o.length > 0 && o.some((e) => e.data === "start") && (n.debuggerActive = !0), n;
|
|
1101
|
-
}
|
|
1102
|
-
function Cn(e) {
|
|
1103
|
-
return e === "running" || e === "queued";
|
|
1104
|
-
}
|
|
1105
|
-
function wn(e, t, n) {
|
|
1106
|
-
let { status: r, outcome: i } = e;
|
|
1107
|
-
return Cn(r) ? !1 : n && t.sourceChanged ? !0 : i !== "interrupted" && t.inputsChanged;
|
|
1417
|
+
//#region ../node_modules/.pnpm/date-fns@4.4.0/node_modules/date-fns/fromUnixTime.js
|
|
1418
|
+
function Xn(e, t) {
|
|
1419
|
+
return xe(e * 1e3, t?.in);
|
|
1108
1420
|
}
|
|
1109
1421
|
//#endregion
|
|
1110
|
-
//#region
|
|
1111
|
-
function
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
t[r].push(n);
|
|
1422
|
+
//#region ../node_modules/.pnpm/ansi_up@6.0.6/node_modules/ansi_up/ansi_up.js
|
|
1423
|
+
var Zn = function(e, t) {
|
|
1424
|
+
return Object.defineProperty ? Object.defineProperty(e, "raw", { value: t }) : e.raw = t, e;
|
|
1425
|
+
}, U;
|
|
1426
|
+
(function(e) {
|
|
1427
|
+
e[e.EOS = 0] = "EOS", e[e.Text = 1] = "Text", e[e.Incomplete = 2] = "Incomplete", e[e.ESC = 3] = "ESC", e[e.Unknown = 4] = "Unknown", e[e.SGR = 5] = "SGR", e[e.OSCURL = 6] = "OSCURL";
|
|
1428
|
+
})(U ||= {});
|
|
1429
|
+
var Qn = class {
|
|
1430
|
+
constructor() {
|
|
1431
|
+
this.VERSION = "6.0.6", this.setup_palettes(), this._use_classes = !1, this.bold = !1, this.faint = !1, this.italic = !1, this.underline = !1, this.fg = this.bg = null, this._buffer = "", this._url_allowlist = {
|
|
1432
|
+
http: 1,
|
|
1433
|
+
https: 1
|
|
1434
|
+
}, this._escape_html = !0, this.boldStyle = "font-weight:bold", this.faintStyle = "opacity:0.7", this.italicStyle = "font-style:italic", this.underlineStyle = "text-decoration:underline";
|
|
1124
1435
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
//#endregion
|
|
1128
|
-
//#region src/core/dom/ui-element-constants.ts
|
|
1129
|
-
var Dn = "object-id", On = "random-id", kn = "abcdefghijklmnopqrstuvwxyz", An = kn + kn.toUpperCase(), jn = /* @__PURE__ */ new Set(), z = "__scratch__", Mn = "setup", Nn = { create() {
|
|
1130
|
-
let e = 0, t;
|
|
1131
|
-
do {
|
|
1132
|
-
let n = "";
|
|
1133
|
-
for (let e = 0; e < 4; e++) n += An[Math.floor(Math.random() * 52)];
|
|
1134
|
-
t = n, e++;
|
|
1135
|
-
} while (jn.has(t) && e < 100);
|
|
1136
|
-
if (e >= 100) throw Error("Failed to generate unique CellId after 100 attempts");
|
|
1137
|
-
return jn.add(t), t;
|
|
1138
|
-
} }, B = {
|
|
1139
|
-
create(e) {
|
|
1140
|
-
return C(e != null, "cellId is required"), `cell-${e}`;
|
|
1141
|
-
},
|
|
1142
|
-
parse(e) {
|
|
1143
|
-
return e.slice(5);
|
|
1144
|
-
},
|
|
1145
|
-
findElement(e) {
|
|
1146
|
-
return e.closest("div[id^=\"cell-\"]");
|
|
1147
|
-
},
|
|
1148
|
-
findElementThroughShadowDOMs(e) {
|
|
1149
|
-
let t = e;
|
|
1150
|
-
for (; t;) {
|
|
1151
|
-
let e = B.findElement(t);
|
|
1152
|
-
if (e) return e;
|
|
1153
|
-
let n = t.getRootNode();
|
|
1154
|
-
if (t = n instanceof ShadowRoot ? n.host : t.parentElement, t === n) break;
|
|
1155
|
-
}
|
|
1156
|
-
return null;
|
|
1436
|
+
set use_classes(e) {
|
|
1437
|
+
this._use_classes = e;
|
|
1157
1438
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
let t = null, n = B.findElementThroughShadowDOMs(e);
|
|
1161
|
-
return n && (t = B.parse(n.id)), t;
|
|
1162
|
-
}
|
|
1163
|
-
var Fn = {
|
|
1164
|
-
parse(e) {
|
|
1165
|
-
return e.getAttribute(Dn);
|
|
1166
|
-
},
|
|
1167
|
-
parseOrThrow(e) {
|
|
1168
|
-
let t = Fn.parse(e);
|
|
1169
|
-
return C(t, "<marimo-ui-element/> missing object-id attribute"), t;
|
|
1170
|
-
}
|
|
1171
|
-
}, In = { create(e) {
|
|
1172
|
-
return `output-${e}`;
|
|
1173
|
-
} }, Ln = b(/* @__PURE__ */ new Set()), V = b([]), H = b([]);
|
|
1174
|
-
function Rn() {
|
|
1175
|
-
return `column-${Nn.create()}`;
|
|
1176
|
-
}
|
|
1177
|
-
var zn = b(null, (e, t, n) => {
|
|
1178
|
-
let r = En(n).length, i = e(V);
|
|
1179
|
-
if (i.length === r) return;
|
|
1180
|
-
let a = e(H), o = [...i, ...a].slice(0, r);
|
|
1181
|
-
for (; o.length < r;) o.push(Rn());
|
|
1182
|
-
t(V, o), t(H, a.slice(Math.max(0, r - i.length)));
|
|
1183
|
-
});
|
|
1184
|
-
function Bn(e, t, n) {
|
|
1185
|
-
return [...(e === null ? [[]] : En(e)).map((e, n) => ({
|
|
1186
|
-
id: t[n] ?? `column-${n}`,
|
|
1187
|
-
ids: e
|
|
1188
|
-
})), ...n.map((e) => ({
|
|
1189
|
-
id: e,
|
|
1190
|
-
ids: []
|
|
1191
|
-
}))];
|
|
1192
|
-
}
|
|
1193
|
-
function Vn(e, t, n) {
|
|
1194
|
-
let r = /* @__PURE__ */ new Map();
|
|
1195
|
-
return e.forEach((i, a) => {
|
|
1196
|
-
let o = t[a];
|
|
1197
|
-
if (!n.has(i) || !o || o.items.length === 0) return;
|
|
1198
|
-
let s = Xe(a, t);
|
|
1199
|
-
s !== null && r.set(i, e.slice(a + 1, s[1] + 1));
|
|
1200
|
-
}), r;
|
|
1201
|
-
}
|
|
1202
|
-
function Hn(e, t, n) {
|
|
1203
|
-
return { columns: e.map(({ id: e, ids: r }) => {
|
|
1204
|
-
let i = Vn(r, r.map(t), n), a = new Set([...i.values()].flat());
|
|
1205
|
-
return {
|
|
1206
|
-
id: e,
|
|
1207
|
-
ids: r,
|
|
1208
|
-
visible: r.filter((e) => !a.has(e)),
|
|
1209
|
-
folds: i
|
|
1210
|
-
};
|
|
1211
|
-
}) };
|
|
1212
|
-
}
|
|
1213
|
-
var Un = b((e) => {
|
|
1214
|
-
let t = e(y), n = t === null ? null : e(t.documentAtom), r = e(qi);
|
|
1215
|
-
return Hn(Bn(n, e(V), e(H)), (e) => r[e] ?? null, e(Ln));
|
|
1216
|
-
}), Wn = () => _(Un), Gn = b((e) => e(Un).columns.length);
|
|
1217
|
-
function Kn(e, t) {
|
|
1218
|
-
return e.columns.find((e) => e.id === t);
|
|
1219
|
-
}
|
|
1220
|
-
function qn(e, t) {
|
|
1221
|
-
let n = e.columns.find((e) => e.ids.includes(t));
|
|
1222
|
-
if (n === void 0) throw Error(`Cell ${t} is not in the layout`);
|
|
1223
|
-
return n;
|
|
1224
|
-
}
|
|
1225
|
-
function Jn(e, t) {
|
|
1226
|
-
for (let n of e.columns) {
|
|
1227
|
-
let e = n.folds.get(t);
|
|
1228
|
-
if (e !== void 0) return e;
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
function Yn(e, t) {
|
|
1232
|
-
let n = e.columns.find((e) => e.ids.includes(t));
|
|
1233
|
-
return n === void 0 ? [] : [...n.folds].filter(([, e]) => e.includes(t)).map(([e]) => e);
|
|
1234
|
-
}
|
|
1235
|
-
function Xn(e, t) {
|
|
1236
|
-
let n = Yn(e, t);
|
|
1237
|
-
return Jn(e, t) === void 0 ? n : [...n, t];
|
|
1238
|
-
}
|
|
1239
|
-
var Zn = /* @__PURE__ */ new Set(/* @__PURE__ */ "__*.marimo.app.False.None.True.__peg_parser__.and.as.assert.async.await.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.nonlocal.not.or.pass.raise.return.try.while.with.yield.None.setup".split("."));
|
|
1240
|
-
function Qn(e, t = !0) {
|
|
1241
|
-
return e = e.trim(), e ? (/^\d/.test(e) && (e = `_${e}`), e = e.replaceAll(/\W/g, "_"), t ? e.toLowerCase() : e) : "_";
|
|
1242
|
-
}
|
|
1243
|
-
function $n(e, t) {
|
|
1244
|
-
let n = new Set(t), r = e, i = (e) => !n.has(e) && !Zn.has(e);
|
|
1245
|
-
if (i(e)) return e;
|
|
1246
|
-
let a = 1;
|
|
1247
|
-
for (; !i(r);) r = `${e}_${a}`, a++;
|
|
1248
|
-
return r;
|
|
1249
|
-
}
|
|
1250
|
-
function er(e, t) {
|
|
1251
|
-
return tr(e) ? `cell-${t}` : e;
|
|
1252
|
-
}
|
|
1253
|
-
function tr(e) {
|
|
1254
|
-
return !e || e === "_" || e === "__";
|
|
1255
|
-
}
|
|
1256
|
-
//#endregion
|
|
1257
|
-
//#region src/core/cells/types.ts
|
|
1258
|
-
function nr({ id: e, name: t = "_", code: n = "", config: r }) {
|
|
1259
|
-
return {
|
|
1260
|
-
id: e,
|
|
1261
|
-
config: r || {
|
|
1262
|
-
hide_code: !1,
|
|
1263
|
-
disabled: !1,
|
|
1264
|
-
column: null,
|
|
1265
|
-
expand_output: !1
|
|
1266
|
-
},
|
|
1267
|
-
name: t,
|
|
1268
|
-
code: n
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
function rr(e) {
|
|
1272
|
-
return {
|
|
1273
|
-
hide_code: !1,
|
|
1274
|
-
disabled: !1,
|
|
1275
|
-
column: null,
|
|
1276
|
-
expand_output: !1,
|
|
1277
|
-
...e
|
|
1278
|
-
};
|
|
1279
|
-
}
|
|
1280
|
-
function ir(e) {
|
|
1281
|
-
return {
|
|
1282
|
-
consoleOutputs: [],
|
|
1283
|
-
debuggerActive: !1,
|
|
1284
|
-
...e
|
|
1285
|
-
};
|
|
1286
|
-
}
|
|
1287
|
-
function ar(e) {
|
|
1288
|
-
return e?.pdbOutput?.length ? {
|
|
1289
|
-
...e,
|
|
1290
|
-
consoleOutputs: [...e.consoleOutputs, ...e.pdbOutput]
|
|
1291
|
-
} : e;
|
|
1292
|
-
}
|
|
1293
|
-
//#endregion
|
|
1294
|
-
//#region src/core/cells/document.ts
|
|
1295
|
-
function or(e, t) {
|
|
1296
|
-
let n = t.code ?? e.code, r = m(e.config, t.config) ? e.config : rr(t.config);
|
|
1297
|
-
return n === e.code && t.name === e.name && r === e.config ? e : n === e.code ? {
|
|
1298
|
-
...e,
|
|
1299
|
-
name: t.name,
|
|
1300
|
-
config: r
|
|
1301
|
-
} : {
|
|
1302
|
-
...e,
|
|
1303
|
-
code: n,
|
|
1304
|
-
name: t.name,
|
|
1305
|
-
config: r
|
|
1306
|
-
};
|
|
1307
|
-
}
|
|
1308
|
-
function sr(e, t) {
|
|
1309
|
-
let n = m(t.order, e.cellIds) ? e.cellIds : [...t.order], { cellData: r, cellRuntime: i, cellHandles: a } = e;
|
|
1310
|
-
for (let o of n) {
|
|
1311
|
-
let n = t.cells.get(o), s = e.cellData[o];
|
|
1312
|
-
if (n === void 0) continue;
|
|
1313
|
-
if (s === void 0) {
|
|
1314
|
-
r = {
|
|
1315
|
-
...r,
|
|
1316
|
-
[o]: nr({
|
|
1317
|
-
id: o,
|
|
1318
|
-
code: n.code ?? "",
|
|
1319
|
-
name: n.name,
|
|
1320
|
-
config: rr(n.config)
|
|
1321
|
-
})
|
|
1322
|
-
}, i = {
|
|
1323
|
-
...i,
|
|
1324
|
-
[o]: i[o] ?? ir()
|
|
1325
|
-
}, a = {
|
|
1326
|
-
...a,
|
|
1327
|
-
[o]: (0, w.createRef)()
|
|
1328
|
-
};
|
|
1329
|
-
continue;
|
|
1330
|
-
}
|
|
1331
|
-
let c = or(s, n);
|
|
1332
|
-
c !== s && (r = {
|
|
1333
|
-
...r,
|
|
1334
|
-
[o]: c
|
|
1335
|
-
});
|
|
1336
|
-
}
|
|
1337
|
-
let o = new Set(n), s = e.cellIds.filter((e) => !o.has(e));
|
|
1338
|
-
if (s.length > 0) {
|
|
1339
|
-
let e = new Set(s), t = (t) => Object.fromEntries(Object.entries(t).filter(([t]) => !e.has(t)));
|
|
1340
|
-
r = t(r), i = t(i), a = t(a);
|
|
1341
|
-
}
|
|
1342
|
-
return n === e.cellIds && r === e.cellData && s.length === 0 ? e : {
|
|
1343
|
-
...e,
|
|
1344
|
-
cellIds: n,
|
|
1345
|
-
cellData: r,
|
|
1346
|
-
cellRuntime: i,
|
|
1347
|
-
cellHandles: a
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
|
-
function cr({ store: e, model: t, reconcile: n, signal: r }) {
|
|
1351
|
-
let i = () => {
|
|
1352
|
-
let r = e.get(t.documentAtom);
|
|
1353
|
-
r !== null && (n(r), e.set(zn, r));
|
|
1354
|
-
}, a = e.sub(t.documentAtom, i);
|
|
1355
|
-
r.addEventListener("abort", a, { once: !0 }), i();
|
|
1356
|
-
}
|
|
1357
|
-
async function lr() {
|
|
1358
|
-
let e = v.get(y);
|
|
1359
|
-
e !== null && v.get(e.syncStatusAtom).status !== "unavailable" && await e.flush();
|
|
1360
|
-
}
|
|
1361
|
-
//#endregion
|
|
1362
|
-
//#region src/core/cells/editor.ts
|
|
1363
|
-
var U = b(/* @__PURE__ */ new Set());
|
|
1364
|
-
function ur(e, t, n) {
|
|
1365
|
-
return !!e && !t.has(n);
|
|
1366
|
-
}
|
|
1367
|
-
b(null, (e, t, { cellId: n }) => {
|
|
1368
|
-
t(U, (e) => /* @__PURE__ */ new Set([...e, n]));
|
|
1369
|
-
}), b(null, (e, t, { cellId: n }) => e(U).has(n) ? (t(U, (e) => {
|
|
1370
|
-
let t = new Set(e);
|
|
1371
|
-
return t.delete(n), t;
|
|
1372
|
-
}), !0) : !1);
|
|
1373
|
-
var dr = b(/* @__PURE__ */ new Map());
|
|
1374
|
-
b(null, (e, t, { cellId: n }) => {
|
|
1375
|
-
t(dr, (e) => {
|
|
1376
|
-
let t = new Map(e);
|
|
1377
|
-
return t.delete(n), t;
|
|
1378
|
-
});
|
|
1379
|
-
});
|
|
1380
|
-
//#endregion
|
|
1381
|
-
//#region ../node_modules/.pnpm/date-fns@4.4.0/node_modules/date-fns/fromUnixTime.js
|
|
1382
|
-
function fr(e, t) {
|
|
1383
|
-
return be(e * 1e3, t?.in);
|
|
1384
|
-
}
|
|
1385
|
-
//#endregion
|
|
1386
|
-
//#region ../node_modules/.pnpm/ansi_up@6.0.6/node_modules/ansi_up/ansi_up.js
|
|
1387
|
-
var pr = function(e, t) {
|
|
1388
|
-
return Object.defineProperty ? Object.defineProperty(e, "raw", { value: t }) : e.raw = t, e;
|
|
1389
|
-
}, W;
|
|
1390
|
-
(function(e) {
|
|
1391
|
-
e[e.EOS = 0] = "EOS", e[e.Text = 1] = "Text", e[e.Incomplete = 2] = "Incomplete", e[e.ESC = 3] = "ESC", e[e.Unknown = 4] = "Unknown", e[e.SGR = 5] = "SGR", e[e.OSCURL = 6] = "OSCURL";
|
|
1392
|
-
})(W ||= {});
|
|
1393
|
-
var mr = class {
|
|
1394
|
-
constructor() {
|
|
1395
|
-
this.VERSION = "6.0.6", this.setup_palettes(), this._use_classes = !1, this.bold = !1, this.faint = !1, this.italic = !1, this.underline = !1, this.fg = this.bg = null, this._buffer = "", this._url_allowlist = {
|
|
1396
|
-
http: 1,
|
|
1397
|
-
https: 1
|
|
1398
|
-
}, this._escape_html = !0, this.boldStyle = "font-weight:bold", this.faintStyle = "opacity:0.7", this.italicStyle = "font-style:italic", this.underlineStyle = "text-decoration:underline";
|
|
1399
|
-
}
|
|
1400
|
-
set use_classes(e) {
|
|
1401
|
-
this._use_classes = e;
|
|
1402
|
-
}
|
|
1403
|
-
get use_classes() {
|
|
1404
|
-
return this._use_classes;
|
|
1439
|
+
get use_classes() {
|
|
1440
|
+
return this._use_classes;
|
|
1405
1441
|
}
|
|
1406
1442
|
set url_allowlist(e) {
|
|
1407
1443
|
this._url_allowlist = e;
|
|
@@ -1622,57 +1658,57 @@ var mr = class {
|
|
|
1622
1658
|
}
|
|
1623
1659
|
get_next_packet() {
|
|
1624
1660
|
var e = {
|
|
1625
|
-
kind:
|
|
1661
|
+
kind: U.EOS,
|
|
1626
1662
|
text: "",
|
|
1627
1663
|
url: ""
|
|
1628
1664
|
}, t = this._buffer.length;
|
|
1629
1665
|
if (t == 0) return e;
|
|
1630
1666
|
var n = this._buffer.indexOf("\x1B");
|
|
1631
|
-
if (n == -1) return e.kind =
|
|
1632
|
-
if (n > 0) return e.kind =
|
|
1667
|
+
if (n == -1) return e.kind = U.Text, e.text = this._buffer, this._buffer = "", e;
|
|
1668
|
+
if (n > 0) return e.kind = U.Text, e.text = this._buffer.slice(0, n), this._buffer = this._buffer.slice(n), e;
|
|
1633
1669
|
if (n == 0) {
|
|
1634
|
-
if (t < 3) return e.kind =
|
|
1670
|
+
if (t < 3) return e.kind = U.Incomplete, e;
|
|
1635
1671
|
var r = this._buffer.charAt(1);
|
|
1636
|
-
if (r != "[" && r != "]" && r != "(") return e.kind =
|
|
1672
|
+
if (r != "[" && r != "]" && r != "(") return e.kind = U.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
|
|
1637
1673
|
if (r == "[") {
|
|
1638
|
-
this._csi_regex ||=
|
|
1674
|
+
this._csi_regex ||= $n(tr ||= Zn(["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \x1B[ # CSI\n ([<-?]?) # private-mode char\n ([d;]*) # any digits or semicolons\n ([ -/]? # an intermediate modifier\n [@-~]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \x1B[ # CSI\n [ -~]* # anything legal\n ([\0-:]) # anything illegal\n )\n "], ["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \\x1b\\[ # CSI\n ([\\x3c-\\x3f]?) # private-mode char\n ([\\d;]*) # any digits or semicolons\n ([\\x20-\\x2f]? # an intermediate modifier\n [\\x40-\\x7e]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \\x1b\\[ # CSI\n [\\x20-\\x7e]* # anything legal\n ([\\x00-\\x1f:]) # anything illegal\n )\n "]));
|
|
1639
1675
|
let t = this._buffer.match(this._csi_regex);
|
|
1640
|
-
if (t === null) return e.kind =
|
|
1641
|
-
if (t[4]) return e.kind =
|
|
1642
|
-
e.kind = t[1] != "" || t[3] != "m" ?
|
|
1676
|
+
if (t === null) return e.kind = U.Incomplete, e;
|
|
1677
|
+
if (t[4]) return e.kind = U.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
|
|
1678
|
+
e.kind = t[1] != "" || t[3] != "m" ? U.Unknown : U.SGR, e.text = t[2];
|
|
1643
1679
|
var i = t[0].length;
|
|
1644
1680
|
return this._buffer = this._buffer.slice(i), e;
|
|
1645
1681
|
}
|
|
1646
1682
|
if (r == "]") {
|
|
1647
|
-
if (t < 4) return e.kind =
|
|
1648
|
-
if (this._buffer.charAt(2) != "8" || this._buffer.charAt(3) != ";") return e.kind =
|
|
1649
|
-
this._osc_st ||=
|
|
1683
|
+
if (t < 4) return e.kind = U.Incomplete, e;
|
|
1684
|
+
if (this._buffer.charAt(2) != "8" || this._buffer.charAt(3) != ";") return e.kind = U.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
|
|
1685
|
+
this._osc_st ||= er(nr ||= Zn(["\n (?: # legal sequence\n (\x1B\\) # ESC | # alternate\n (\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\0-] # anything illegal\n | # alternate\n [\b-] # anything illegal\n | # alternate\n [-] # anything illegal\n )\n "], ["\n (?: # legal sequence\n (\\x1b\\\\) # ESC \\\n | # alternate\n (\\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\\x00-\\x06] # anything illegal\n | # alternate\n [\\x08-\\x1a] # anything illegal\n | # alternate\n [\\x1c-\\x1f] # anything illegal\n )\n "])), this._osc_st.lastIndex = 0;
|
|
1650
1686
|
{
|
|
1651
1687
|
let t = this._osc_st.exec(this._buffer);
|
|
1652
|
-
if (t === null) return e.kind =
|
|
1653
|
-
if (t[3]) return e.kind =
|
|
1688
|
+
if (t === null) return e.kind = U.Incomplete, e;
|
|
1689
|
+
if (t[3]) return e.kind = U.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
|
|
1654
1690
|
}
|
|
1655
1691
|
{
|
|
1656
1692
|
let t = this._osc_st.exec(this._buffer);
|
|
1657
|
-
if (t === null) return e.kind =
|
|
1658
|
-
if (t[3]) return e.kind =
|
|
1693
|
+
if (t === null) return e.kind = U.Incomplete, e;
|
|
1694
|
+
if (t[3]) return e.kind = U.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
|
|
1659
1695
|
}
|
|
1660
|
-
this._osc_regex ||=
|
|
1696
|
+
this._osc_regex ||= $n(rr ||= Zn(["\n ^ # beginning of line\n #\n \x1B]8; # OSC Hyperlink\n [ -:<-~]* # params (excluding ;)\n ; # end of params\n ([!-~]{0,512}) # URL capture\n (?: # ST\n (?:\x1B\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n ([ -~]+) # TEXT capture\n \x1B]8;; # OSC Hyperlink End\n (?: # ST\n (?:\x1B\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n "], ["\n ^ # beginning of line\n #\n \\x1b\\]8; # OSC Hyperlink\n [\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)\n ; # end of params\n ([\\x21-\\x7e]{0,512}) # URL capture\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n ([\\x20-\\x7e]+) # TEXT capture\n \\x1b\\]8;; # OSC Hyperlink End\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n "]));
|
|
1661
1697
|
let n = this._buffer.match(this._osc_regex);
|
|
1662
|
-
if (n === null) return e.kind =
|
|
1663
|
-
e.kind =
|
|
1698
|
+
if (n === null) return e.kind = U.ESC, e.text = this._buffer.slice(0, 1), this._buffer = this._buffer.slice(1), e;
|
|
1699
|
+
e.kind = U.OSCURL, e.url = n[1], e.text = n[2];
|
|
1664
1700
|
var i = n[0].length;
|
|
1665
1701
|
return this._buffer = this._buffer.slice(i), e;
|
|
1666
1702
|
}
|
|
1667
|
-
if (r == "(") return e.kind =
|
|
1703
|
+
if (r == "(") return e.kind = U.Unknown, this._buffer = this._buffer.slice(3), e;
|
|
1668
1704
|
}
|
|
1669
1705
|
}
|
|
1670
1706
|
ansi_to_html(e) {
|
|
1671
1707
|
this.append_buffer(e);
|
|
1672
1708
|
for (var t = [];;) {
|
|
1673
1709
|
var n = this.get_next_packet();
|
|
1674
|
-
if (n.kind ==
|
|
1675
|
-
n.kind !=
|
|
1710
|
+
if (n.kind == U.EOS || n.kind == U.Incomplete) break;
|
|
1711
|
+
n.kind != U.ESC && n.kind != U.Unknown && (n.kind == U.Text ? t.push(this.transform_to_html(this.with_state(n))) : n.kind == U.SGR ? this.process_ansi(n) : n.kind == U.OSCURL && t.push(this.process_hyperlink(n)));
|
|
1676
1712
|
}
|
|
1677
1713
|
return t.join("");
|
|
1678
1714
|
}
|
|
@@ -1742,16 +1778,16 @@ var mr = class {
|
|
|
1742
1778
|
return t.length < 1 || !this._url_allowlist[t[0]] ? "" : `<a href="${this.escape_txt_for_html(e.url)}">${this.escape_txt_for_html(e.text)}</a>`;
|
|
1743
1779
|
}
|
|
1744
1780
|
};
|
|
1745
|
-
function
|
|
1781
|
+
function $n(e, ...t) {
|
|
1746
1782
|
let n = e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm, "");
|
|
1747
1783
|
return new RegExp(n);
|
|
1748
1784
|
}
|
|
1749
|
-
function
|
|
1785
|
+
function er(e, ...t) {
|
|
1750
1786
|
let n = e.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm, "");
|
|
1751
1787
|
return new RegExp(n, "g");
|
|
1752
1788
|
}
|
|
1753
|
-
var
|
|
1754
|
-
function
|
|
1789
|
+
var tr, nr, rr, ir = new Qn();
|
|
1790
|
+
function W(e) {
|
|
1755
1791
|
try {
|
|
1756
1792
|
let t = document.createElement("div");
|
|
1757
1793
|
return t.innerHTML = e, (t.textContent || t.innerText || "").split("\n").map((e) => e.trimEnd()).join("\n");
|
|
@@ -1759,24 +1795,24 @@ function G(e) {
|
|
|
1759
1795
|
return t.error("Error parsing HTML content:", n), e;
|
|
1760
1796
|
}
|
|
1761
1797
|
}
|
|
1762
|
-
function
|
|
1798
|
+
function ar(e) {
|
|
1763
1799
|
if (!e) return "";
|
|
1764
1800
|
try {
|
|
1765
|
-
return
|
|
1801
|
+
return W(ir.ansi_to_html(e));
|
|
1766
1802
|
} catch (n) {
|
|
1767
1803
|
return t.error("Error converting ANSI to plain text:", n), e;
|
|
1768
1804
|
}
|
|
1769
1805
|
}
|
|
1770
1806
|
//#endregion
|
|
1771
1807
|
//#region src/core/errors/traceback-atom.ts
|
|
1772
|
-
var
|
|
1808
|
+
var or = x(null);
|
|
1773
1809
|
//#endregion
|
|
1774
1810
|
//#region src/core/cells/logs.ts
|
|
1775
|
-
function
|
|
1811
|
+
function sr(e) {
|
|
1776
1812
|
return e.type === "cell" ? e.cellId : `lsp:${e.name}`;
|
|
1777
1813
|
}
|
|
1778
|
-
var
|
|
1779
|
-
function
|
|
1814
|
+
var cr = !1;
|
|
1815
|
+
function lr(e) {
|
|
1780
1816
|
let t = [], n = [e.console].filter(Boolean).flat();
|
|
1781
1817
|
for (let r of n) {
|
|
1782
1818
|
let n = r.mimetype === "text/plain", i = r.mimetype === "text/html" || r.mimetype === "application/vnd.marimo+traceback";
|
|
@@ -1786,7 +1822,7 @@ function Tr(e) {
|
|
|
1786
1822
|
case "stdout":
|
|
1787
1823
|
case "stderr":
|
|
1788
1824
|
case "marimo-error": {
|
|
1789
|
-
let a = d.asString(r.data), o = i ?
|
|
1825
|
+
let a = d.asString(r.data), o = i ? W(a) : a;
|
|
1790
1826
|
t.push({
|
|
1791
1827
|
timestamp: r.timestamp || Date.now(),
|
|
1792
1828
|
level: n ? "stderr" : "stdout",
|
|
@@ -1801,9 +1837,9 @@ function Tr(e) {
|
|
|
1801
1837
|
}
|
|
1802
1838
|
}
|
|
1803
1839
|
}
|
|
1804
|
-
if (t.forEach(
|
|
1840
|
+
if (t.forEach(ur.log), n.length === 0 && Sn(e.output?.mimetype) && Array.isArray(e.output.data)) {
|
|
1805
1841
|
e.output.data.forEach((t) => {
|
|
1806
|
-
|
|
1842
|
+
ur.log({
|
|
1807
1843
|
level: "stderr",
|
|
1808
1844
|
source: {
|
|
1809
1845
|
type: "cell",
|
|
@@ -1813,18 +1849,18 @@ function Tr(e) {
|
|
|
1813
1849
|
message: JSON.stringify(t)
|
|
1814
1850
|
});
|
|
1815
1851
|
});
|
|
1816
|
-
let t = e.output.data.filter((e) => "type" in e && e.type === "exception" || e.type === "internal"), n =
|
|
1817
|
-
if (t.length > 0 && !
|
|
1818
|
-
|
|
1852
|
+
let t = e.output.data.filter((e) => "type" in e && e.type === "exception" || e.type === "internal"), n = y.get(ve) === "read";
|
|
1853
|
+
if (t.length > 0 && !cr && n) {
|
|
1854
|
+
cr = !0;
|
|
1819
1855
|
let e = t.find((e) => e.traceback);
|
|
1820
1856
|
o(e ? {
|
|
1821
1857
|
title: "An internal error occurred",
|
|
1822
1858
|
description: e.msg || "Click 'View' to see traceback",
|
|
1823
1859
|
variant: "danger",
|
|
1824
|
-
action: w.createElement(
|
|
1860
|
+
action: w.createElement(le, {
|
|
1825
1861
|
altText: "View traceback",
|
|
1826
1862
|
onClick: () => {
|
|
1827
|
-
|
|
1863
|
+
y.set(or, {
|
|
1828
1864
|
traceback: e.traceback,
|
|
1829
1865
|
errorMessage: e.msg || "An internal error occurred"
|
|
1830
1866
|
});
|
|
@@ -1839,13 +1875,13 @@ function Tr(e) {
|
|
|
1839
1875
|
}
|
|
1840
1876
|
return t;
|
|
1841
1877
|
}
|
|
1842
|
-
var
|
|
1878
|
+
var ur = { log: (e) => {
|
|
1843
1879
|
let t = e.level === "stdout" ? "gray" : e.level === "stderr" ? "red" : "orange", n = e.level.toUpperCase();
|
|
1844
|
-
console.log(`%c[${n}]`, `color:${t}; padding:2px 0; border-radius:2px; font-weight:bold`, `[${
|
|
1880
|
+
console.log(`%c[${n}]`, `color:${t}; padding:2px 0; border-radius:2px; font-weight:bold`, `[${dr(e.timestamp)}]`, `(${sr(e.source)}) ${e.message}`);
|
|
1845
1881
|
} };
|
|
1846
|
-
function
|
|
1882
|
+
function dr(e) {
|
|
1847
1883
|
try {
|
|
1848
|
-
return
|
|
1884
|
+
return Xn(e).toLocaleTimeString(void 0, {
|
|
1849
1885
|
hour12: !0,
|
|
1850
1886
|
hour: "numeric",
|
|
1851
1887
|
minute: "numeric",
|
|
@@ -1855,16 +1891,326 @@ function Dr(e) {
|
|
|
1855
1891
|
return "";
|
|
1856
1892
|
}
|
|
1857
1893
|
}
|
|
1894
|
+
var fr = /* @__PURE__ */ new Set(/* @__PURE__ */ "__*.marimo.app.False.None.True.__peg_parser__.and.as.assert.async.await.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.in.is.lambda.nonlocal.not.or.pass.raise.return.try.while.with.yield.None.setup".split("."));
|
|
1895
|
+
function pr(e, t = !0) {
|
|
1896
|
+
return e = e.trim(), e ? (/^\d/.test(e) && (e = `_${e}`), e = e.replaceAll(/\W/g, "_"), t ? e.toLowerCase() : e) : "_";
|
|
1897
|
+
}
|
|
1898
|
+
function mr(e, t) {
|
|
1899
|
+
let n = new Set(t), r = e, i = (e) => !n.has(e) && !fr.has(e);
|
|
1900
|
+
if (i(e)) return e;
|
|
1901
|
+
let a = 1;
|
|
1902
|
+
for (; !i(r);) r = `${e}_${a}`, a++;
|
|
1903
|
+
return r;
|
|
1904
|
+
}
|
|
1905
|
+
function hr(e, t) {
|
|
1906
|
+
return gr(e) ? `cell-${t}` : e;
|
|
1907
|
+
}
|
|
1908
|
+
function gr(e) {
|
|
1909
|
+
return !e || e === "_" || e === "__";
|
|
1910
|
+
}
|
|
1858
1911
|
//#endregion
|
|
1859
|
-
//#region src/
|
|
1860
|
-
function
|
|
1861
|
-
|
|
1862
|
-
|
|
1912
|
+
//#region src/core/cells/types.ts
|
|
1913
|
+
function _r({ id: e, name: t = "_", code: n = "", config: r }) {
|
|
1914
|
+
return {
|
|
1915
|
+
id: e,
|
|
1916
|
+
config: r || {
|
|
1917
|
+
hide_code: !1,
|
|
1918
|
+
disabled: !1,
|
|
1919
|
+
column: null,
|
|
1920
|
+
expand_output: !1
|
|
1921
|
+
},
|
|
1922
|
+
name: t,
|
|
1923
|
+
code: n
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
function vr(e) {
|
|
1927
|
+
return {
|
|
1928
|
+
hide_code: !1,
|
|
1929
|
+
disabled: !1,
|
|
1930
|
+
column: null,
|
|
1931
|
+
expand_output: !1,
|
|
1932
|
+
...e
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
function yr(e) {
|
|
1936
|
+
return {
|
|
1937
|
+
embeddedConsole: [],
|
|
1938
|
+
...e
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
//#endregion
|
|
1942
|
+
//#region src/core/cells/execution-console.ts
|
|
1943
|
+
function br(e, t, n) {
|
|
1944
|
+
let r = e.time === void 0 ? t : Date.parse(e.time) / 1e3, i = e.seq + 1;
|
|
1945
|
+
switch (e.kind) {
|
|
1946
|
+
case "console": return {
|
|
1947
|
+
id: i,
|
|
1948
|
+
channel: e.name,
|
|
1949
|
+
data: e.text,
|
|
1950
|
+
mimetype: "text/plain",
|
|
1951
|
+
timestamp: r
|
|
1952
|
+
};
|
|
1953
|
+
case "display": return {
|
|
1954
|
+
id: i,
|
|
1955
|
+
channel: e.content.mimetype === "application/vnd.marimo+traceback" ? "stderr" : "media",
|
|
1956
|
+
mimetype: e.content.mimetype,
|
|
1957
|
+
data: e.content.data,
|
|
1958
|
+
code: e.content.mimetype === "application/vnd.marimo+traceback" ? n : void 0,
|
|
1959
|
+
timestamp: r
|
|
1960
|
+
};
|
|
1961
|
+
case "input": return {
|
|
1962
|
+
id: i,
|
|
1963
|
+
channel: "stdin",
|
|
1964
|
+
mimetype: e.password ? "text/password" : "text/plain",
|
|
1965
|
+
input_id: e.id,
|
|
1966
|
+
data: e.prompt,
|
|
1967
|
+
timestamp: r,
|
|
1968
|
+
response: e.status === "pending" ? void 0 : null
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
function xr(e, t) {
|
|
1973
|
+
return {
|
|
1974
|
+
onExecution(n, r) {
|
|
1975
|
+
Fn.INSTANCE.trackExecution(n), r && (n.status === "running" && e.startCellConsole({ cellId: n.cell_id ?? "__scratch__" }), t?.(n));
|
|
1976
|
+
},
|
|
1977
|
+
onItem(t, n, r) {
|
|
1978
|
+
let i = t.cell_id ?? "__scratch__", a = br(n, t.started_at ? Date.parse(t.started_at) / 1e3 : 0);
|
|
1979
|
+
a.channel === "media" && Fn.INSTANCE.track({
|
|
1980
|
+
cell_id: i,
|
|
1981
|
+
output: a
|
|
1982
|
+
}), r && (n.kind === "console" || a.channel === "stderr") && e.addLogs({ logs: lr({
|
|
1983
|
+
cell_id: i,
|
|
1984
|
+
console: a
|
|
1985
|
+
}) });
|
|
1986
|
+
}
|
|
1987
|
+
};
|
|
1988
|
+
}
|
|
1989
|
+
function Sr(e, t) {
|
|
1990
|
+
let n = e(h);
|
|
1991
|
+
if (!n) return;
|
|
1992
|
+
let r = e(n.executionsAtom);
|
|
1993
|
+
if (t === "__scratch__") return r.scratchConsole;
|
|
1994
|
+
let i = r.latest.get(t);
|
|
1995
|
+
return i === void 0 ? void 0 : r.executions.get(i);
|
|
1996
|
+
}
|
|
1997
|
+
function Cr(e, t) {
|
|
1998
|
+
let { local: n, execution: r, code: i } = e;
|
|
1999
|
+
if (t && t.local === n && t.code === i && t.execution?.items === r?.items) return t;
|
|
2000
|
+
let a = r?.record, o = n.clearedConsole, s = n.clearedConsoleInputs, c = a?.started_at ? Date.parse(a.started_at) / 1e3 : 0, l = (e) => {
|
|
2001
|
+
if (o && o.executionId === a?.id && e.seq <= o.seq && !(e.kind === "input" && o.prompts.has(e.id)) || e.kind === "input" && s?.executionId === e.execution_id && s.ids.has(e.id)) return;
|
|
2002
|
+
let t = br(e, c, i);
|
|
2003
|
+
return e.kind === "input" && !e.password && n.answers?.has(e.id) && (t.response = n.answers.get(e.id)), t;
|
|
2004
|
+
}, u = n.commandConsole?.entries, d = r?.append;
|
|
2005
|
+
if (t && t.local === n && t.code === i && t.execution && d && d.before.deref() === t.execution.items && (!u?.length || u.every((e) => e.afterSeq !== void 0 && e.afterSeq < d.item.seq))) {
|
|
2006
|
+
let r = l(d.item), i = t.rendered.consoleOutputs;
|
|
2007
|
+
return {
|
|
2008
|
+
...e,
|
|
2009
|
+
rendered: {
|
|
2010
|
+
serialization: n.serialization,
|
|
2011
|
+
consoleOutputs: r ? Hn([...i, r]) : i
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2015
|
+
let f = !r || a?.runtime_id === "embedded" && !r.items.size ? n.embeddedConsole : tt(r).flatMap((e) => l(e) ?? []);
|
|
2016
|
+
if (u?.length) {
|
|
2017
|
+
let e = u.every((e) => e.afterSeq !== void 0) && f.every((e) => e.id !== void 0), t = (e) => e.afterSeq === void 0 ? e.id ?? 0 : e.afterSeq + 1.5;
|
|
2018
|
+
f = [...f, ...u.map((e, t) => ({
|
|
2019
|
+
...e,
|
|
2020
|
+
id: -1 - t
|
|
2021
|
+
}))].toSorted((n, r) => (e ? t(n) - t(r) : 0) || (n.timestamp ?? 0) - (r.timestamp ?? 0));
|
|
2022
|
+
}
|
|
2023
|
+
return {
|
|
2024
|
+
...e,
|
|
2025
|
+
rendered: {
|
|
2026
|
+
serialization: n.serialization,
|
|
2027
|
+
consoleOutputs: Un(f)
|
|
2028
|
+
}
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
2031
|
+
//#endregion
|
|
2032
|
+
//#region src/core/cells/columns.ts
|
|
2033
|
+
function wr(e) {
|
|
2034
|
+
let t = /* @__PURE__ */ new Map(), n = 0;
|
|
2035
|
+
for (let r of e.order) {
|
|
2036
|
+
let i = e.cells.get(r)?.config.column;
|
|
2037
|
+
i != null && i >= 0 && (n = i), t.set(r, n);
|
|
2038
|
+
}
|
|
2039
|
+
return t;
|
|
2040
|
+
}
|
|
2041
|
+
function Tr(e) {
|
|
2042
|
+
let t = [[]];
|
|
2043
|
+
for (let [n, r] of wr(e)) {
|
|
2044
|
+
for (; t.length <= r;) t.push([]);
|
|
2045
|
+
t[r].push(n);
|
|
2046
|
+
}
|
|
2047
|
+
return t;
|
|
1863
2048
|
}
|
|
2049
|
+
//#endregion
|
|
2050
|
+
//#region src/core/cells/layout.ts
|
|
2051
|
+
var Er = x(/* @__PURE__ */ new Set()), Dr = x([]), Or = x([]);
|
|
1864
2052
|
function kr() {
|
|
2053
|
+
return `column-${An.create()}`;
|
|
2054
|
+
}
|
|
2055
|
+
var Ar = x(null, (e, t, n) => {
|
|
2056
|
+
let r = Tr(n).length, i = e(Dr);
|
|
2057
|
+
if (i.length === r) return;
|
|
2058
|
+
let a = e(Or), o = [...i, ...a].slice(0, r);
|
|
2059
|
+
for (; o.length < r;) o.push(kr());
|
|
2060
|
+
t(Dr, o), t(Or, a.slice(Math.max(0, r - i.length)));
|
|
2061
|
+
});
|
|
2062
|
+
function jr(e, t, n) {
|
|
2063
|
+
return [...(e === null ? [[]] : Tr(e)).map((e, n) => ({
|
|
2064
|
+
id: t[n] ?? `column-${n}`,
|
|
2065
|
+
ids: e
|
|
2066
|
+
})), ...n.map((e) => ({
|
|
2067
|
+
id: e,
|
|
2068
|
+
ids: []
|
|
2069
|
+
}))];
|
|
2070
|
+
}
|
|
2071
|
+
function Mr(e, t, n) {
|
|
2072
|
+
let r = /* @__PURE__ */ new Map();
|
|
2073
|
+
return e.forEach((i, a) => {
|
|
2074
|
+
let o = t[a];
|
|
2075
|
+
if (!n.has(i) || !o || o.items.length === 0) return;
|
|
2076
|
+
let s = Ze(a, t);
|
|
2077
|
+
s !== null && r.set(i, e.slice(a + 1, s[1] + 1));
|
|
2078
|
+
}), r;
|
|
2079
|
+
}
|
|
2080
|
+
function Nr(e, t, n) {
|
|
2081
|
+
return { columns: e.map(({ id: e, ids: r }) => {
|
|
2082
|
+
let i = Mr(r, r.map(t), n), a = new Set([...i.values()].flat());
|
|
2083
|
+
return {
|
|
2084
|
+
id: e,
|
|
2085
|
+
ids: r,
|
|
2086
|
+
visible: r.filter((e) => !a.has(e)),
|
|
2087
|
+
folds: i
|
|
2088
|
+
};
|
|
2089
|
+
}) };
|
|
2090
|
+
}
|
|
2091
|
+
var Pr = x((e) => {
|
|
2092
|
+
let t = e(b), n = t === null ? null : e(t.documentAtom), r = e(pa);
|
|
2093
|
+
return Nr(jr(n, e(Dr), e(Or)), (e) => r[e] ?? null, e(Er));
|
|
2094
|
+
}), Fr = () => v(Pr), Ir = x((e) => e(Pr).columns.length);
|
|
2095
|
+
function Lr(e, t) {
|
|
2096
|
+
return e.columns.find((e) => e.id === t);
|
|
2097
|
+
}
|
|
2098
|
+
function Rr(e, t) {
|
|
2099
|
+
let n = e.columns.find((e) => e.ids.includes(t));
|
|
2100
|
+
if (n === void 0) throw Error(`Cell ${t} is not in the layout`);
|
|
2101
|
+
return n;
|
|
2102
|
+
}
|
|
2103
|
+
function zr(e, t) {
|
|
2104
|
+
for (let n of e.columns) {
|
|
2105
|
+
let e = n.folds.get(t);
|
|
2106
|
+
if (e !== void 0) return e;
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
function Br(e, t) {
|
|
2110
|
+
let n = e.columns.find((e) => e.ids.includes(t));
|
|
2111
|
+
return n === void 0 ? [] : [...n.folds].filter(([, e]) => e.includes(t)).map(([e]) => e);
|
|
2112
|
+
}
|
|
2113
|
+
function Vr(e, t) {
|
|
2114
|
+
let n = Br(e, t);
|
|
2115
|
+
return zr(e, t) === void 0 ? n : [...n, t];
|
|
2116
|
+
}
|
|
2117
|
+
//#endregion
|
|
2118
|
+
//#region src/core/cells/document.ts
|
|
2119
|
+
function Hr(e, t) {
|
|
2120
|
+
let n = t.code ?? e.code, r = g(e.config, t.config) ? e.config : vr(t.config);
|
|
2121
|
+
return n === e.code && t.name === e.name && r === e.config ? e : n === e.code ? {
|
|
2122
|
+
...e,
|
|
2123
|
+
name: t.name,
|
|
2124
|
+
config: r
|
|
2125
|
+
} : {
|
|
2126
|
+
...e,
|
|
2127
|
+
code: n,
|
|
2128
|
+
name: t.name,
|
|
2129
|
+
config: r
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2132
|
+
function Ur(e, t) {
|
|
2133
|
+
let n = g(t.order, e.cellIds) ? e.cellIds : [...t.order], { cellData: r, cellRuntime: i, cellHandles: a } = e;
|
|
2134
|
+
for (let o of n) {
|
|
2135
|
+
let n = t.cells.get(o), s = e.cellData[o];
|
|
2136
|
+
if (n === void 0) continue;
|
|
2137
|
+
if (s === void 0) {
|
|
2138
|
+
r = {
|
|
2139
|
+
...r,
|
|
2140
|
+
[o]: _r({
|
|
2141
|
+
id: o,
|
|
2142
|
+
code: n.code ?? "",
|
|
2143
|
+
name: n.name,
|
|
2144
|
+
config: vr(n.config)
|
|
2145
|
+
})
|
|
2146
|
+
}, i = {
|
|
2147
|
+
...i,
|
|
2148
|
+
[o]: i[o] ?? yr()
|
|
2149
|
+
}, a = {
|
|
2150
|
+
...a,
|
|
2151
|
+
[o]: (0, w.createRef)()
|
|
2152
|
+
};
|
|
2153
|
+
continue;
|
|
2154
|
+
}
|
|
2155
|
+
let c = Hr(s, n);
|
|
2156
|
+
c !== s && (r = {
|
|
2157
|
+
...r,
|
|
2158
|
+
[o]: c
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
let o = new Set(n), s = e.cellIds.filter((e) => !o.has(e));
|
|
2162
|
+
if (s.length > 0) {
|
|
2163
|
+
let e = new Set(s), t = (t) => Object.fromEntries(Object.entries(t).filter(([t]) => !e.has(t)));
|
|
2164
|
+
r = t(r), i = t(i), a = t(a);
|
|
2165
|
+
}
|
|
2166
|
+
return n === e.cellIds && r === e.cellData && s.length === 0 ? e : {
|
|
2167
|
+
...e,
|
|
2168
|
+
cellIds: n,
|
|
2169
|
+
cellData: r,
|
|
2170
|
+
cellRuntime: i,
|
|
2171
|
+
cellHandles: a
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
function Wr({ store: e, model: t, reconcile: n, signal: r }) {
|
|
2175
|
+
let i = () => {
|
|
2176
|
+
let r = e.get(t.documentAtom);
|
|
2177
|
+
r !== null && (n(r), e.set(Ar, r));
|
|
2178
|
+
}, a = e.sub(t.documentAtom, i);
|
|
2179
|
+
r.addEventListener("abort", a, { once: !0 }), i();
|
|
2180
|
+
}
|
|
2181
|
+
async function Gr() {
|
|
2182
|
+
let e = y.get(b);
|
|
2183
|
+
e !== null && y.get(e.syncStatusAtom).status !== "unavailable" && await e.flush();
|
|
2184
|
+
}
|
|
2185
|
+
//#endregion
|
|
2186
|
+
//#region src/core/cells/editor.ts
|
|
2187
|
+
var G = x(/* @__PURE__ */ new Set());
|
|
2188
|
+
function Kr(e, t, n) {
|
|
2189
|
+
return !!e && !t.has(n);
|
|
2190
|
+
}
|
|
2191
|
+
x(null, (e, t, { cellId: n }) => {
|
|
2192
|
+
t(G, (e) => /* @__PURE__ */ new Set([...e, n]));
|
|
2193
|
+
}), x(null, (e, t, { cellId: n }) => e(G).has(n) ? (t(G, (e) => {
|
|
2194
|
+
let t = new Set(e);
|
|
2195
|
+
return t.delete(n), t;
|
|
2196
|
+
}), !0) : !1);
|
|
2197
|
+
var qr = x(/* @__PURE__ */ new Map());
|
|
2198
|
+
x(null, (e, t, { cellId: n }) => {
|
|
2199
|
+
t(qr, (e) => {
|
|
2200
|
+
let t = new Map(e);
|
|
2201
|
+
return t.delete(n), t;
|
|
2202
|
+
});
|
|
2203
|
+
});
|
|
2204
|
+
//#endregion
|
|
2205
|
+
//#region src/components/editor/navigation/focus-utils.ts
|
|
2206
|
+
function Jr(e, n) {
|
|
2207
|
+
let r = document.getElementById(V.create(e));
|
|
2208
|
+
r ? Xr(r, n) : t.warn(`[CellFocusManager] focusCell: element not found: ${e}`);
|
|
2209
|
+
}
|
|
2210
|
+
function Yr() {
|
|
1865
2211
|
return document.activeElement instanceof HTMLElement && document.activeElement.classList.contains("marimo-cell");
|
|
1866
2212
|
}
|
|
1867
|
-
function
|
|
2213
|
+
function Xr(e, n) {
|
|
1868
2214
|
try {
|
|
1869
2215
|
e.focus(n);
|
|
1870
2216
|
} catch {
|
|
@@ -1873,7 +2219,7 @@ function Ar(e, n) {
|
|
|
1873
2219
|
}
|
|
1874
2220
|
//#endregion
|
|
1875
2221
|
//#region src/utils/timeout.ts
|
|
1876
|
-
function
|
|
2222
|
+
function Zr(e, n) {
|
|
1877
2223
|
let { retries: r, delay: i, initialDelay: a = 0 } = n, o = 0, s = () => {
|
|
1878
2224
|
if (o < r) {
|
|
1879
2225
|
try {
|
|
@@ -1888,75 +2234,75 @@ function jr(e, n) {
|
|
|
1888
2234
|
}
|
|
1889
2235
|
//#endregion
|
|
1890
2236
|
//#region src/core/cells/utils.ts
|
|
1891
|
-
function
|
|
2237
|
+
function Qr(e) {
|
|
1892
2238
|
return e.cellIds.map((t) => e.cellData[t]);
|
|
1893
2239
|
}
|
|
1894
|
-
function
|
|
2240
|
+
function $r(e) {
|
|
1895
2241
|
let { cellIds: t, cellData: n } = e, r = [];
|
|
1896
2242
|
for (let e of t) n[e].config.disabled && r.push(e);
|
|
1897
2243
|
return r;
|
|
1898
2244
|
}
|
|
1899
|
-
function
|
|
2245
|
+
function ei(e) {
|
|
1900
2246
|
let { cellIds: t, cellData: n } = e, r = [];
|
|
1901
2247
|
for (let e of t) n[e].config.disabled || r.push(e);
|
|
1902
2248
|
return r;
|
|
1903
2249
|
}
|
|
1904
|
-
function
|
|
2250
|
+
function ti(e) {
|
|
1905
2251
|
return e.history.length > 0;
|
|
1906
2252
|
}
|
|
1907
|
-
function
|
|
2253
|
+
function ni(e) {
|
|
1908
2254
|
let t = e.history[e.history.length - 1];
|
|
1909
2255
|
return t && t.type === "move" ? "Undo move" : "Undo cell deletion";
|
|
1910
2256
|
}
|
|
1911
|
-
function
|
|
1912
|
-
return e.status === "idle" ?
|
|
2257
|
+
function ri(e, t, n) {
|
|
2258
|
+
return e.status === "idle" ? si(e) && n.code.trim() ? "not-run" : t.sourceChanged ? "source" : e.outcome === "interrupted" ? "interrupted" : t.inputsChanged && !n.config.disabled && !e.blocked ? "inputs" : null : null;
|
|
1913
2259
|
}
|
|
1914
|
-
function*
|
|
2260
|
+
function* ii(e, t, n) {
|
|
1915
2261
|
for (let r of e.cellIds) {
|
|
1916
|
-
let i =
|
|
1917
|
-
o === null ? a.sourceChanged &&
|
|
2262
|
+
let i = It(t, r), a = n(r), o = ri(i, a, e.cellData[r]);
|
|
2263
|
+
o === null ? a.sourceChanged && oi(t.executions, r) && (yield [r, "source"]) : yield [r, o];
|
|
1918
2264
|
}
|
|
1919
2265
|
}
|
|
1920
|
-
function
|
|
2266
|
+
function ai(e, t, n) {
|
|
1921
2267
|
let r = null;
|
|
1922
|
-
for (let [, i] of
|
|
2268
|
+
for (let [, i] of ii(e, t, n)) {
|
|
1923
2269
|
if (i !== "inputs") return i;
|
|
1924
2270
|
r = i;
|
|
1925
2271
|
}
|
|
1926
2272
|
return r;
|
|
1927
2273
|
}
|
|
1928
|
-
function
|
|
2274
|
+
function oi(e, t) {
|
|
1929
2275
|
let n = e.latest.get(t), r = n === void 0 ? void 0 : e.executions.get(n)?.record;
|
|
1930
2276
|
return r !== void 0 && r.status !== "completed";
|
|
1931
2277
|
}
|
|
1932
|
-
function
|
|
2278
|
+
function si({ status: e, outcome: t, live: n }) {
|
|
1933
2279
|
return (t === null || !n) && e !== "queued" && e !== "running";
|
|
1934
2280
|
}
|
|
1935
|
-
function
|
|
2281
|
+
function ci({ errored: e, stopped: t }) {
|
|
1936
2282
|
return {
|
|
1937
2283
|
published: !0,
|
|
1938
2284
|
"has-error": e,
|
|
1939
2285
|
stopped: t
|
|
1940
2286
|
};
|
|
1941
2287
|
}
|
|
1942
|
-
function
|
|
1943
|
-
let a =
|
|
2288
|
+
function li({ errored: e, interrupted: t, stopped: n, output: r, showErrorTracebacks: i }) {
|
|
2289
|
+
let a = Sn(r?.mimetype), o = i && a && Array.isArray(r?.data) && r.data.some((e) => e.type === "exception" && "traceback" in e && e.traceback);
|
|
1944
2290
|
return (e || t || n || a) && !o;
|
|
1945
2291
|
}
|
|
1946
2292
|
//#endregion
|
|
1947
2293
|
//#region src/core/network/requests.ts
|
|
1948
|
-
var
|
|
1949
|
-
function
|
|
1950
|
-
let e =
|
|
2294
|
+
var ui = x(null);
|
|
2295
|
+
function di() {
|
|
2296
|
+
let e = v(ui);
|
|
1951
2297
|
return C(e, "useRequestClient() requires setting requestClientAtom."), e;
|
|
1952
2298
|
}
|
|
1953
|
-
function
|
|
1954
|
-
let e =
|
|
2299
|
+
function fi() {
|
|
2300
|
+
let e = y.get(ui);
|
|
1955
2301
|
return C(e, "getRequestClient() requires requestClientAtom to be set."), e;
|
|
1956
2302
|
}
|
|
1957
2303
|
//#endregion
|
|
1958
2304
|
//#region src/utils/storage/storage.ts
|
|
1959
|
-
var
|
|
2305
|
+
var pi = class {
|
|
1960
2306
|
store = /* @__PURE__ */ new Map();
|
|
1961
2307
|
get length() {
|
|
1962
2308
|
return this.store.size;
|
|
@@ -1977,16 +2323,16 @@ var qr = class {
|
|
|
1977
2323
|
this.store.set(e, t);
|
|
1978
2324
|
}
|
|
1979
2325
|
};
|
|
1980
|
-
function
|
|
1981
|
-
let { hasLocalStorage: e, hasSessionStorage: t } =
|
|
1982
|
-
return e ? window.localStorage : t ? window.sessionStorage : new
|
|
2326
|
+
function mi() {
|
|
2327
|
+
let { hasLocalStorage: e, hasSessionStorage: t } = Se();
|
|
2328
|
+
return e ? window.localStorage : t ? window.sessionStorage : new pi();
|
|
1983
2329
|
}
|
|
1984
|
-
var
|
|
1985
|
-
function
|
|
1986
|
-
return
|
|
2330
|
+
var hi = mi(), gi = /(https?:\/\/[^\s"<>`{}|\\^]+)/, _i = /\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i, vi = /^data:image\//i, yi = ["avatars.githubusercontent.com"];
|
|
2331
|
+
function bi(e) {
|
|
2332
|
+
return vi.test(e) ? [{
|
|
1987
2333
|
type: "image",
|
|
1988
2334
|
url: e
|
|
1989
|
-
}] : e.split(
|
|
2335
|
+
}] : e.split(gi).filter((e) => e !== "").map((e) => gi.test(e) ? _i.test(e) || vi.test(e) || yi.some((t) => e.includes(t)) ? {
|
|
1990
2336
|
type: "image",
|
|
1991
2337
|
url: e
|
|
1992
2338
|
} : {
|
|
@@ -1999,48 +2345,48 @@ function ei(e) {
|
|
|
1999
2345
|
}
|
|
2000
2346
|
//#endregion
|
|
2001
2347
|
//#region src/utils/json/json-parser.ts
|
|
2002
|
-
var
|
|
2348
|
+
var xi = new RegExp(gi.source, "g");
|
|
2003
2349
|
BigInt.prototype.toJSON = function() {
|
|
2004
2350
|
return JSON.rawJSON(this.toString());
|
|
2005
2351
|
};
|
|
2006
|
-
function
|
|
2352
|
+
function Si(e) {
|
|
2007
2353
|
try {
|
|
2008
|
-
return JSON.parse(e, (e, t) =>
|
|
2354
|
+
return JSON.parse(e, (e, t) => Ei(t));
|
|
2009
2355
|
} catch {}
|
|
2010
2356
|
if (e == null || e === "") return {};
|
|
2011
2357
|
try {
|
|
2012
|
-
return e ??= "", e = e.replaceAll(/(?<=\s|^|\[|,|:)(NaN|-Infinity|Infinity)(?=(?:[^"'\\]*(\\.|'([^'\\]*\\.)*[^'\\]*'|"([^"\\]*\\.)*[^"\\]*"))*[^"']*$)/g, "\"◐$1◐\""), JSON.parse(e, (e, t) => typeof t == "string" ? t === "◐NaN◐" ? NaN : t === "◐Infinity◐" ? Infinity : t === "◐-Infinity◐" ? -Infinity :
|
|
2358
|
+
return e ??= "", e = e.replaceAll(/(?<=\s|^|\[|,|:)(NaN|-Infinity|Infinity)(?=(?:[^"'\\]*(\\.|'([^'\\]*\\.)*[^'\\]*'|"([^"\\]*\\.)*[^"\\]*"))*[^"']*$)/g, "\"◐$1◐\""), JSON.parse(e, (e, t) => typeof t == "string" ? t === "◐NaN◐" ? NaN : t === "◐Infinity◐" ? Infinity : t === "◐-Infinity◐" ? -Infinity : Ei(t) : Ei(t));
|
|
2013
2359
|
} catch {
|
|
2014
2360
|
return {};
|
|
2015
2361
|
}
|
|
2016
2362
|
}
|
|
2017
|
-
function
|
|
2363
|
+
function Ci(e) {
|
|
2018
2364
|
if (e.length === 0) return "";
|
|
2019
2365
|
let t = Object.keys(e[0]);
|
|
2020
2366
|
return [
|
|
2021
2367
|
`| ${t.join(" | ")} |`,
|
|
2022
2368
|
`|${t.map(() => "---").join("|")}|`,
|
|
2023
|
-
...e.map((e) => `| ${t.map((t) =>
|
|
2369
|
+
...e.map((e) => `| ${t.map((t) => wi(e[t])).join(" | ")} |`)
|
|
2024
2370
|
].join("\n");
|
|
2025
2371
|
}
|
|
2026
|
-
function
|
|
2372
|
+
function wi(e) {
|
|
2027
2373
|
if (e == null) return "";
|
|
2028
|
-
if (Array.isArray(e) || typeof e == "object") return
|
|
2374
|
+
if (Array.isArray(e) || typeof e == "object") return Ti(JSON.stringify(e));
|
|
2029
2375
|
let t = String(e), n = /\[([^\]]+)]\((https?:\/\/[^)]+)\)/g, r = /* @__PURE__ */ new Map(), i = 0;
|
|
2030
2376
|
t = t.replaceAll(n, (e) => {
|
|
2031
2377
|
let t = `__MDLINK_${i++}__`;
|
|
2032
2378
|
return r.set(t, e), t;
|
|
2033
|
-
}), t = t.replaceAll(
|
|
2379
|
+
}), t = t.replaceAll(xi, "[$1]($1)");
|
|
2034
2380
|
for (let [e, n] of r) t = t.replace(e, n);
|
|
2035
|
-
return
|
|
2381
|
+
return Ti(t);
|
|
2036
2382
|
}
|
|
2037
|
-
function
|
|
2383
|
+
function Ti(e) {
|
|
2038
2384
|
return e.replaceAll("\\", "\\\\").replaceAll("|", "\\|").replaceAll("\n", " ").replaceAll("\r", "");
|
|
2039
2385
|
}
|
|
2040
|
-
function
|
|
2386
|
+
function Ei(e) {
|
|
2041
2387
|
return typeof e == "object" && e && "$bigint" in e && typeof e.$bigint == "string" ? BigInt(e.$bigint) : e;
|
|
2042
2388
|
}
|
|
2043
|
-
var
|
|
2389
|
+
var Di = new class {
|
|
2044
2390
|
getFilename() {
|
|
2045
2391
|
return this.getSearchParam("filename");
|
|
2046
2392
|
}
|
|
@@ -2067,39 +2413,39 @@ var si = new class {
|
|
|
2067
2413
|
}();
|
|
2068
2414
|
//#endregion
|
|
2069
2415
|
//#region src/core/dom/htmlUtils.ts
|
|
2070
|
-
function
|
|
2071
|
-
return
|
|
2416
|
+
function Oi(e) {
|
|
2417
|
+
return Si(e ?? "");
|
|
2072
2418
|
}
|
|
2073
|
-
function
|
|
2074
|
-
return
|
|
2419
|
+
function ki(e) {
|
|
2420
|
+
return ue.mapValues(e.dataset, (e) => typeof e == "string" ? Oi(e) : e);
|
|
2075
2421
|
}
|
|
2076
|
-
function
|
|
2077
|
-
let n = e.parentElement ?
|
|
2078
|
-
return n && t.has(n) ? t.lookupValue(n) :
|
|
2422
|
+
function Ai(e, t) {
|
|
2423
|
+
let n = e.parentElement ? Mn.parse(e.parentElement) : void 0;
|
|
2424
|
+
return n && t.has(n) ? t.lookupValue(n) : Oi(e.dataset.initialValue);
|
|
2079
2425
|
}
|
|
2080
|
-
function
|
|
2081
|
-
if (
|
|
2082
|
-
if (
|
|
2083
|
-
let e =
|
|
2426
|
+
function ji() {
|
|
2427
|
+
if (ne()) return document.title || null;
|
|
2428
|
+
if (be()) {
|
|
2429
|
+
let e = Di.getFilename();
|
|
2084
2430
|
if (e) return e;
|
|
2085
2431
|
}
|
|
2086
2432
|
let e = document.querySelector("marimo-filename");
|
|
2087
|
-
|
|
2433
|
+
ye(e, "marimo-filename tag not found");
|
|
2088
2434
|
let t = e.innerHTML;
|
|
2089
2435
|
return t.length === 0 ? null : t;
|
|
2090
2436
|
}
|
|
2091
2437
|
//#endregion
|
|
2092
2438
|
//#region src/core/saving/file-state.ts
|
|
2093
|
-
var
|
|
2094
|
-
|
|
2095
|
-
var
|
|
2096
|
-
|
|
2439
|
+
var Mi = x(ji());
|
|
2440
|
+
x(null);
|
|
2441
|
+
var Ni = x(null);
|
|
2442
|
+
x(void 0);
|
|
2097
2443
|
//#endregion
|
|
2098
2444
|
//#region src/utils/storage/typed.ts
|
|
2099
|
-
var
|
|
2445
|
+
var Pi = class {
|
|
2100
2446
|
defaultValue;
|
|
2101
2447
|
storage;
|
|
2102
|
-
constructor(e, t =
|
|
2448
|
+
constructor(e, t = hi) {
|
|
2103
2449
|
this.defaultValue = e, this.storage = t;
|
|
2104
2450
|
}
|
|
2105
2451
|
get(e) {
|
|
@@ -2116,11 +2462,11 @@ var pi = class {
|
|
|
2116
2462
|
remove(e) {
|
|
2117
2463
|
this.storage.removeItem(e);
|
|
2118
2464
|
}
|
|
2119
|
-
},
|
|
2465
|
+
}, Fi = class {
|
|
2120
2466
|
schema;
|
|
2121
2467
|
getDefaultValue;
|
|
2122
2468
|
storage;
|
|
2123
|
-
constructor(e, t, n =
|
|
2469
|
+
constructor(e, t, n = hi) {
|
|
2124
2470
|
this.schema = e, this.getDefaultValue = t, this.storage = n;
|
|
2125
2471
|
}
|
|
2126
2472
|
get(e) {
|
|
@@ -2139,15 +2485,15 @@ var pi = class {
|
|
|
2139
2485
|
remove(e) {
|
|
2140
2486
|
this.storage.removeItem(e);
|
|
2141
2487
|
}
|
|
2142
|
-
},
|
|
2488
|
+
}, Ii = class extends Fi {
|
|
2143
2489
|
filename;
|
|
2144
2490
|
unsubscribeFromFilename;
|
|
2145
2491
|
constructor(e, t, n) {
|
|
2146
|
-
let r =
|
|
2492
|
+
let r = y.get(Mi);
|
|
2147
2493
|
super(t, n), this.filename = r;
|
|
2148
2494
|
try {
|
|
2149
|
-
this.unsubscribeFromFilename =
|
|
2150
|
-
let t =
|
|
2495
|
+
this.unsubscribeFromFilename = y.sub(Mi, () => {
|
|
2496
|
+
let t = y.get(Mi);
|
|
2151
2497
|
this.handleFilenameChange(e, t);
|
|
2152
2498
|
});
|
|
2153
2499
|
} catch {
|
|
@@ -2175,7 +2521,7 @@ var pi = class {
|
|
|
2175
2521
|
dispose() {
|
|
2176
2522
|
this.unsubscribeFromFilename &&= (this.unsubscribeFromFilename(), null);
|
|
2177
2523
|
}
|
|
2178
|
-
},
|
|
2524
|
+
}, K = {
|
|
2179
2525
|
VariableName: "VariableName",
|
|
2180
2526
|
FunctionDefinition: "FunctionDefinition",
|
|
2181
2527
|
ClassDefinition: "ClassDefinition",
|
|
@@ -2200,30 +2546,30 @@ var pi = class {
|
|
|
2200
2546
|
Comment: "Comment",
|
|
2201
2547
|
String: "String",
|
|
2202
2548
|
FormatString: "FormatString"
|
|
2203
|
-
},
|
|
2549
|
+
}, q = {
|
|
2204
2550
|
For: "for",
|
|
2205
2551
|
In: "in",
|
|
2206
2552
|
As: "as",
|
|
2207
2553
|
Import: "import"
|
|
2208
|
-
},
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2554
|
+
}, Li = /* @__PURE__ */ new Set([
|
|
2555
|
+
K.FunctionDefinition,
|
|
2556
|
+
K.LambdaExpression,
|
|
2557
|
+
K.ArrayComprehensionExpression,
|
|
2558
|
+
K.SetComprehensionExpression,
|
|
2559
|
+
K.DictionaryComprehensionExpression,
|
|
2560
|
+
K.ComprehensionExpression,
|
|
2561
|
+
K.ClassDefinition
|
|
2216
2562
|
]);
|
|
2217
|
-
|
|
2563
|
+
K.Comment, K.String, K.FormatString;
|
|
2218
2564
|
//#endregion
|
|
2219
2565
|
//#region src/core/codemirror/utils.ts
|
|
2220
|
-
function
|
|
2566
|
+
function Ri(e) {
|
|
2221
2567
|
e && e.dispatch({ selection: {
|
|
2222
2568
|
anchor: e.state.doc.length,
|
|
2223
2569
|
head: e.state.doc.length
|
|
2224
2570
|
} });
|
|
2225
2571
|
}
|
|
2226
|
-
function
|
|
2572
|
+
function zi(e) {
|
|
2227
2573
|
let t = e.dom.closest(".marimo-cell");
|
|
2228
2574
|
t && requestAnimationFrame(() => {
|
|
2229
2575
|
t.scrollIntoView({
|
|
@@ -2235,29 +2581,29 @@ function vi(e) {
|
|
|
2235
2581
|
}
|
|
2236
2582
|
//#endregion
|
|
2237
2583
|
//#region src/core/codemirror/go-to-definition/commands.ts
|
|
2238
|
-
var
|
|
2239
|
-
function
|
|
2584
|
+
var Bi = /* @__PURE__ */ new Set([K.ClassDefinition]);
|
|
2585
|
+
function Vi(e, t) {
|
|
2240
2586
|
requestAnimationFrame(() => {
|
|
2241
2587
|
e.focus(), e.dispatch({
|
|
2242
2588
|
selection: {
|
|
2243
2589
|
anchor: t,
|
|
2244
2590
|
head: t
|
|
2245
2591
|
},
|
|
2246
|
-
effects:
|
|
2592
|
+
effects: pe.scrollIntoView(t, { y: "center" })
|
|
2247
2593
|
});
|
|
2248
|
-
}),
|
|
2594
|
+
}), zi(e);
|
|
2249
2595
|
}
|
|
2250
|
-
function
|
|
2251
|
-
let n =
|
|
2596
|
+
function Hi(e, t) {
|
|
2597
|
+
let n = me(e), r = null;
|
|
2252
2598
|
return n.iterate({ enter: (n) => {
|
|
2253
2599
|
if (r !== null) return !1;
|
|
2254
|
-
if (n.name ===
|
|
2255
|
-
if (n.name ===
|
|
2600
|
+
if (n.name === K.VariableName && e.doc.sliceString(n.from, n.to) === t) return r = n.from, !1;
|
|
2601
|
+
if (n.name === K.Comment || n.name === K.String) return !1;
|
|
2256
2602
|
} }), r;
|
|
2257
2603
|
}
|
|
2258
|
-
function
|
|
2604
|
+
function Ui(e, t) {
|
|
2259
2605
|
let n = [], r = e.resolveInner(t, 0);
|
|
2260
|
-
for (; r;)
|
|
2606
|
+
for (; r;) Li.has(r.name) && (n.some((e) => e.type === K.FunctionDefinition || e.type === K.LambdaExpression) && r.name === K.ClassDefinition || n.push({
|
|
2261
2607
|
id: r.from,
|
|
2262
2608
|
type: r.name
|
|
2263
2609
|
})), r = r.parent;
|
|
@@ -2266,70 +2612,70 @@ function Si(e, t) {
|
|
|
2266
2612
|
type: "global"
|
|
2267
2613
|
}), n;
|
|
2268
2614
|
}
|
|
2269
|
-
function
|
|
2615
|
+
function J(e, t, n) {
|
|
2270
2616
|
e.push({
|
|
2271
2617
|
scopeId: t,
|
|
2272
2618
|
from: n
|
|
2273
2619
|
});
|
|
2274
2620
|
}
|
|
2275
|
-
function
|
|
2621
|
+
function Wi(e, t) {
|
|
2276
2622
|
if (e.firstChild()) do
|
|
2277
2623
|
t(e.node);
|
|
2278
2624
|
while (e.nextSibling());
|
|
2279
2625
|
}
|
|
2280
|
-
function
|
|
2626
|
+
function Gi(e, t) {
|
|
2281
2627
|
let { state: n, variableName: r, scopeId: i, declarations: a } = t;
|
|
2282
2628
|
switch (e.name) {
|
|
2283
|
-
case
|
|
2284
|
-
n.doc.sliceString(e.from, e.to) === r &&
|
|
2629
|
+
case K.VariableName:
|
|
2630
|
+
n.doc.sliceString(e.from, e.to) === r && J(a, i, e.from);
|
|
2285
2631
|
break;
|
|
2286
|
-
case
|
|
2287
|
-
case
|
|
2632
|
+
case K.TupleExpression:
|
|
2633
|
+
case K.ArrayExpression: {
|
|
2288
2634
|
let n = e.node.cursor();
|
|
2289
2635
|
n.firstChild();
|
|
2290
2636
|
do
|
|
2291
|
-
|
|
2637
|
+
Gi(n, t);
|
|
2292
2638
|
while (n.nextSibling());
|
|
2293
2639
|
break;
|
|
2294
2640
|
}
|
|
2295
2641
|
}
|
|
2296
2642
|
}
|
|
2297
|
-
function
|
|
2643
|
+
function Ki(e, t) {
|
|
2298
2644
|
let { state: n, variableName: r, scopeId: i, declarations: a } = t, o = e.cursor();
|
|
2299
2645
|
o.firstChild();
|
|
2300
2646
|
do {
|
|
2301
|
-
if (o.name !==
|
|
2647
|
+
if (o.name !== K.ParamList) continue;
|
|
2302
2648
|
let e = o.node.cursor();
|
|
2303
2649
|
e.firstChild();
|
|
2304
2650
|
do
|
|
2305
|
-
e.name ===
|
|
2651
|
+
e.name === K.VariableName && n.doc.sliceString(e.from, e.to) === r && J(a, i, e.from);
|
|
2306
2652
|
while (e.nextSibling());
|
|
2307
2653
|
} while (o.nextSibling());
|
|
2308
2654
|
}
|
|
2309
|
-
function
|
|
2655
|
+
function qi(e, t) {
|
|
2310
2656
|
let n = e.cursor();
|
|
2311
2657
|
n.firstChild();
|
|
2312
2658
|
let r = !1;
|
|
2313
2659
|
do
|
|
2314
|
-
if (n.name ===
|
|
2315
|
-
else if (r && n.name ===
|
|
2316
|
-
else r &&
|
|
2660
|
+
if (n.name === q.For) r = !0;
|
|
2661
|
+
else if (r && n.name === q.In) break;
|
|
2662
|
+
else r && Gi(n, t);
|
|
2317
2663
|
while (n.nextSibling());
|
|
2318
2664
|
}
|
|
2319
|
-
function
|
|
2320
|
-
let { state: n, variableName: r, scopeStack: i, declarations: a } = t, o = e.cursor(), s = o.name, c = o.from, l =
|
|
2665
|
+
function Ji(e, t) {
|
|
2666
|
+
let { state: n, variableName: r, scopeStack: i, declarations: a } = t, o = e.cursor(), s = o.name, c = o.from, l = Li.has(s) ? [...i, c] : i, u = l[l.length - 1] ?? -1;
|
|
2321
2667
|
switch (s) {
|
|
2322
|
-
case
|
|
2323
|
-
case
|
|
2668
|
+
case K.FunctionDefinition:
|
|
2669
|
+
case K.ClassDefinition: {
|
|
2324
2670
|
let t = e.cursor();
|
|
2325
2671
|
t.firstChild();
|
|
2326
2672
|
do
|
|
2327
|
-
if (t.name ===
|
|
2328
|
-
|
|
2673
|
+
if (t.name === K.VariableName && n.doc.sliceString(t.from, t.to) === r) {
|
|
2674
|
+
J(a, i[i.length - 1] ?? -1, t.from);
|
|
2329
2675
|
break;
|
|
2330
2676
|
}
|
|
2331
2677
|
while (t.nextSibling());
|
|
2332
|
-
s ===
|
|
2678
|
+
s === K.FunctionDefinition && Ki(e, {
|
|
2333
2679
|
state: n,
|
|
2334
2680
|
variableName: r,
|
|
2335
2681
|
scopeId: c,
|
|
@@ -2337,38 +2683,38 @@ function Di(e, t) {
|
|
|
2337
2683
|
});
|
|
2338
2684
|
break;
|
|
2339
2685
|
}
|
|
2340
|
-
case
|
|
2341
|
-
|
|
2686
|
+
case K.LambdaExpression:
|
|
2687
|
+
Ki(e, {
|
|
2342
2688
|
state: n,
|
|
2343
2689
|
variableName: r,
|
|
2344
2690
|
scopeId: c,
|
|
2345
2691
|
declarations: a
|
|
2346
2692
|
});
|
|
2347
2693
|
break;
|
|
2348
|
-
case
|
|
2349
|
-
case
|
|
2350
|
-
case
|
|
2351
|
-
case
|
|
2352
|
-
case
|
|
2353
|
-
|
|
2694
|
+
case K.ArrayComprehensionExpression:
|
|
2695
|
+
case K.DictionaryComprehensionExpression:
|
|
2696
|
+
case K.SetComprehensionExpression:
|
|
2697
|
+
case K.ComprehensionExpression:
|
|
2698
|
+
case K.ForStatement:
|
|
2699
|
+
qi(e, {
|
|
2354
2700
|
state: n,
|
|
2355
2701
|
variableName: r,
|
|
2356
2702
|
scopeId: u,
|
|
2357
2703
|
declarations: a
|
|
2358
2704
|
});
|
|
2359
2705
|
break;
|
|
2360
|
-
case
|
|
2706
|
+
case K.AssignStatement: {
|
|
2361
2707
|
let t = [], i = e.cursor();
|
|
2362
2708
|
i.firstChild();
|
|
2363
2709
|
do
|
|
2364
|
-
i.name ===
|
|
2710
|
+
i.name === K.AssignOp && t.push(i.from);
|
|
2365
2711
|
while (i.nextSibling());
|
|
2366
2712
|
let o = t[t.length - 1];
|
|
2367
2713
|
if (o === void 0) break;
|
|
2368
2714
|
let s = e.cursor();
|
|
2369
2715
|
s.firstChild();
|
|
2370
2716
|
do
|
|
2371
|
-
s.from < o &&
|
|
2717
|
+
s.from < o && Gi(s, {
|
|
2372
2718
|
state: n,
|
|
2373
2719
|
variableName: r,
|
|
2374
2720
|
scopeId: u,
|
|
@@ -2377,14 +2723,14 @@ function Di(e, t) {
|
|
|
2377
2723
|
while (s.nextSibling());
|
|
2378
2724
|
break;
|
|
2379
2725
|
}
|
|
2380
|
-
case
|
|
2726
|
+
case K.ImportStatement: {
|
|
2381
2727
|
let t = e.cursor();
|
|
2382
2728
|
t.firstChild();
|
|
2383
2729
|
let i = !1, o = null, s = () => {
|
|
2384
|
-
o?.matches &&
|
|
2730
|
+
o?.matches && J(a, u, o.from), o = null;
|
|
2385
2731
|
};
|
|
2386
2732
|
do
|
|
2387
|
-
t.name ===
|
|
2733
|
+
t.name === q.Import ? i = !0 : i && (t.name === q.As ? o = null : t.name === K.VariableName ? (s(), o = {
|
|
2388
2734
|
from: t.from,
|
|
2389
2735
|
matches: n.doc.sliceString(t.from, t.to) === r
|
|
2390
2736
|
}) : t.name === "," && s());
|
|
@@ -2392,19 +2738,19 @@ function Di(e, t) {
|
|
|
2392
2738
|
s();
|
|
2393
2739
|
break;
|
|
2394
2740
|
}
|
|
2395
|
-
case
|
|
2396
|
-
case
|
|
2741
|
+
case K.TryStatement:
|
|
2742
|
+
case K.WithStatement: {
|
|
2397
2743
|
let t = e.cursor();
|
|
2398
2744
|
t.firstChild();
|
|
2399
2745
|
let i = !1;
|
|
2400
2746
|
do
|
|
2401
|
-
t.name ===
|
|
2747
|
+
t.name === q.As ? i = !0 : i && t.name === K.VariableName && n.doc.sliceString(t.from, t.to) === r && (J(a, u, t.from), i = !1);
|
|
2402
2748
|
while (t.nextSibling());
|
|
2403
2749
|
break;
|
|
2404
2750
|
}
|
|
2405
2751
|
}
|
|
2406
|
-
|
|
2407
|
-
|
|
2752
|
+
Wi(o, (e) => {
|
|
2753
|
+
Ji(e, {
|
|
2408
2754
|
state: n,
|
|
2409
2755
|
variableName: r,
|
|
2410
2756
|
scopeStack: l,
|
|
@@ -2412,86 +2758,86 @@ function Di(e, t) {
|
|
|
2412
2758
|
});
|
|
2413
2759
|
});
|
|
2414
2760
|
}
|
|
2415
|
-
function
|
|
2416
|
-
let r =
|
|
2417
|
-
|
|
2761
|
+
function Yi(e, t, n) {
|
|
2762
|
+
let r = me(e), i = [];
|
|
2763
|
+
Ji(r, {
|
|
2418
2764
|
state: e,
|
|
2419
2765
|
variableName: t,
|
|
2420
2766
|
scopeStack: [],
|
|
2421
2767
|
declarations: i
|
|
2422
2768
|
});
|
|
2423
2769
|
let a = Math.max(0, Math.min(n, e.doc.length));
|
|
2424
|
-
for (let e of
|
|
2425
|
-
let t = i.filter((t) => t.scopeId === e.id).filter((t) => !
|
|
2770
|
+
for (let e of Ui(r, a)) {
|
|
2771
|
+
let t = i.filter((t) => t.scopeId === e.id).filter((t) => !Bi.has(e.type) || t.from <= a).toSorted((e, t) => e.from - t.from)[0];
|
|
2426
2772
|
if (t) return t.from;
|
|
2427
2773
|
}
|
|
2428
2774
|
return null;
|
|
2429
2775
|
}
|
|
2430
|
-
function
|
|
2431
|
-
let { state: r } = e, i = n === void 0 ?
|
|
2432
|
-
return i !== null && (
|
|
2776
|
+
function Xi(e, t, n) {
|
|
2777
|
+
let { state: r } = e, i = n === void 0 ? Hi(r, t) : Yi(r, t, n);
|
|
2778
|
+
return i !== null && (Vi(e, i), !0);
|
|
2433
2779
|
}
|
|
2434
|
-
function
|
|
2435
|
-
return
|
|
2780
|
+
function Zi(e, t) {
|
|
2781
|
+
return Vi(e, e.state.doc.line(t).from), !0;
|
|
2436
2782
|
}
|
|
2437
2783
|
//#endregion
|
|
2438
2784
|
//#region src/core/network/connection.ts
|
|
2439
|
-
var
|
|
2440
|
-
|
|
2785
|
+
var Y = x({ state: O.NOT_STARTED });
|
|
2786
|
+
p(null, (e, t) => t === null ? null : {
|
|
2441
2787
|
phase: t.phase,
|
|
2442
2788
|
logs: t.log_mode === "append" && e?.phase === t.phase ? e.logs + t.logs : t.logs
|
|
2443
2789
|
});
|
|
2444
|
-
function
|
|
2445
|
-
return
|
|
2790
|
+
function Qi() {
|
|
2791
|
+
return se(Y, (e) => e.state === O.OPEN);
|
|
2446
2792
|
}
|
|
2447
|
-
function
|
|
2448
|
-
return
|
|
2793
|
+
function $i() {
|
|
2794
|
+
return _e() ? Qi() : Promise.resolve();
|
|
2449
2795
|
}
|
|
2450
|
-
|
|
2451
|
-
let t = e(
|
|
2796
|
+
x((e) => e(Y).state === O.CONNECTING), x((e) => e(Y).state === O.OPEN), x((e) => {
|
|
2797
|
+
let t = e(Y);
|
|
2452
2798
|
return t.state === O.OPEN || t.state === O.NOT_STARTED;
|
|
2453
|
-
}),
|
|
2799
|
+
}), x((e) => e(Y).state === O.CLOSED);
|
|
2454
2800
|
//#endregion
|
|
2455
2801
|
//#region src/components/ui/checkbox.tsx
|
|
2456
|
-
var
|
|
2457
|
-
let r = (0,
|
|
2802
|
+
var ea = w.forwardRef((e, t) => {
|
|
2803
|
+
let r = (0, fn.c)(13), i, a;
|
|
2458
2804
|
r[0] === e ? (i = r[1], a = r[2]) : ({className: i, ...a} = e, r[0] = e, r[1] = i, r[2] = a);
|
|
2459
2805
|
let o;
|
|
2460
2806
|
r[3] === i ? o = r[4] : (o = n("flex items-center justify-center peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground", i), r[3] = i, r[4] = o);
|
|
2461
2807
|
let s;
|
|
2462
2808
|
r[5] === Symbol.for("react.memo_cache_sentinel") ? (s = n("flex items-center justify-center text-current max-h-[14px] overflow-hidden"), r[5] = s) : s = r[5];
|
|
2463
2809
|
let c;
|
|
2464
|
-
r[6] === a.checked ? c = r[7] : (c = /* @__PURE__ */ (0, T.jsx)(
|
|
2810
|
+
r[6] === a.checked ? c = r[7] : (c = /* @__PURE__ */ (0, T.jsx)(Ie, {
|
|
2465
2811
|
className: s,
|
|
2466
|
-
children: a.checked === "indeterminate" ? /* @__PURE__ */ (0, T.jsx)(
|
|
2812
|
+
children: a.checked === "indeterminate" ? /* @__PURE__ */ (0, T.jsx)(we, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, T.jsx)(l, { className: "h-4 w-4" })
|
|
2467
2813
|
}), r[6] = a.checked, r[7] = c);
|
|
2468
2814
|
let u;
|
|
2469
|
-
return r[8] !== a || r[9] !== t || r[10] !== o || r[11] !== c ? (u = /* @__PURE__ */ (0, T.jsx)(
|
|
2815
|
+
return r[8] !== a || r[9] !== t || r[10] !== o || r[11] !== c ? (u = /* @__PURE__ */ (0, T.jsx)(Pe, {
|
|
2470
2816
|
ref: t,
|
|
2471
2817
|
className: o,
|
|
2472
2818
|
...a,
|
|
2473
2819
|
children: c
|
|
2474
2820
|
}), r[8] = a, r[9] = t, r[10] = o, r[11] = c, r[12] = u) : u = r[12], u;
|
|
2475
2821
|
});
|
|
2476
|
-
|
|
2822
|
+
ea.displayName = Pe.displayName;
|
|
2477
2823
|
//#endregion
|
|
2478
2824
|
//#region src/core/cells/scrollCellIntoView.ts
|
|
2479
|
-
function
|
|
2825
|
+
function ta({ cellId: e, cell: n, isCodeHidden: r, codeFocus: i, variableName: a }) {
|
|
2480
2826
|
if (!n) return;
|
|
2481
|
-
let o = document.getElementById(
|
|
2827
|
+
let o = document.getElementById(V.create(e));
|
|
2482
2828
|
if (!o) t.warn("scrollCellIntoView: element not found");
|
|
2483
|
-
else if (
|
|
2829
|
+
else if (Yr()) Xr(o);
|
|
2484
2830
|
else {
|
|
2485
|
-
if (r)
|
|
2831
|
+
if (r) Xr(o);
|
|
2486
2832
|
else {
|
|
2487
|
-
|
|
2833
|
+
yn.promote(e);
|
|
2488
2834
|
let r = n.current?.editorView;
|
|
2489
2835
|
if (!r) {
|
|
2490
2836
|
t.warn("scrollCellIntoView: editor not found", e);
|
|
2491
2837
|
return;
|
|
2492
2838
|
}
|
|
2493
2839
|
if (r.hasFocus || !document.hasFocus()) return;
|
|
2494
|
-
if (
|
|
2840
|
+
if (Zr(() => (r.focus(), r.hasFocus), {
|
|
2495
2841
|
retries: 5,
|
|
2496
2842
|
delay: 20
|
|
2497
2843
|
}), i === "top") r.dispatch({ selection: {
|
|
@@ -2504,7 +2850,7 @@ function Pi({ cellId: e, cell: n, isCodeHidden: r, codeFocus: i, variableName: a
|
|
|
2504
2850
|
anchor: e.from,
|
|
2505
2851
|
head: e.from
|
|
2506
2852
|
} });
|
|
2507
|
-
} else a &&
|
|
2853
|
+
} else a && Xi(r, a);
|
|
2508
2854
|
}
|
|
2509
2855
|
o.scrollIntoView({
|
|
2510
2856
|
behavior: "smooth",
|
|
@@ -2512,21 +2858,21 @@ function Pi({ cellId: e, cell: n, isCodeHidden: r, codeFocus: i, variableName: a
|
|
|
2512
2858
|
});
|
|
2513
2859
|
}
|
|
2514
2860
|
}
|
|
2515
|
-
function
|
|
2861
|
+
function na() {
|
|
2516
2862
|
let e = document.getElementById("App");
|
|
2517
2863
|
e?.scrollTo({
|
|
2518
2864
|
top: e.scrollHeight,
|
|
2519
2865
|
behavior: "smooth"
|
|
2520
2866
|
});
|
|
2521
2867
|
}
|
|
2522
|
-
function
|
|
2868
|
+
function ra() {
|
|
2523
2869
|
document.getElementById("App")?.scrollTo({
|
|
2524
2870
|
top: 0,
|
|
2525
2871
|
behavior: "smooth"
|
|
2526
2872
|
});
|
|
2527
2873
|
}
|
|
2528
|
-
function
|
|
2529
|
-
let t = document.getElementById(
|
|
2874
|
+
function ia(e) {
|
|
2875
|
+
let t = document.getElementById(V.create(e));
|
|
2530
2876
|
return t?.scrollIntoView({
|
|
2531
2877
|
behavior: "smooth",
|
|
2532
2878
|
block: "center"
|
|
@@ -2534,7 +2880,7 @@ function Li(e) {
|
|
|
2534
2880
|
}
|
|
2535
2881
|
//#endregion
|
|
2536
2882
|
//#region src/core/cells/cells.ts
|
|
2537
|
-
function
|
|
2883
|
+
function aa(e) {
|
|
2538
2884
|
let t = {
|
|
2539
2885
|
column: 0,
|
|
2540
2886
|
hide_code: !1,
|
|
@@ -2544,24 +2890,24 @@ function Ri(e) {
|
|
|
2544
2890
|
return {
|
|
2545
2891
|
...e,
|
|
2546
2892
|
cellData: {
|
|
2547
|
-
[
|
|
2548
|
-
id:
|
|
2893
|
+
[B]: _r({
|
|
2894
|
+
id: B,
|
|
2549
2895
|
config: t
|
|
2550
2896
|
}),
|
|
2551
2897
|
...e.cellData
|
|
2552
2898
|
},
|
|
2553
2899
|
cellRuntime: {
|
|
2554
|
-
[
|
|
2900
|
+
[B]: yr(),
|
|
2555
2901
|
...e.cellRuntime
|
|
2556
2902
|
},
|
|
2557
2903
|
cellHandles: {
|
|
2558
|
-
[
|
|
2904
|
+
[B]: (0, w.createRef)(),
|
|
2559
2905
|
...e.cellHandles
|
|
2560
2906
|
}
|
|
2561
2907
|
};
|
|
2562
2908
|
}
|
|
2563
|
-
function
|
|
2564
|
-
return
|
|
2909
|
+
function oa() {
|
|
2910
|
+
return aa({
|
|
2565
2911
|
cellIds: [],
|
|
2566
2912
|
cellData: {},
|
|
2567
2913
|
cellRuntime: {},
|
|
@@ -2571,53 +2917,74 @@ function zi() {
|
|
|
2571
2917
|
cellLogs: []
|
|
2572
2918
|
});
|
|
2573
2919
|
}
|
|
2574
|
-
var { reducer:
|
|
2575
|
-
|
|
2920
|
+
var { reducer: sa, createActions: ca, useActions: la, valueAtom: X } = fe(oa, {
|
|
2921
|
+
setCellReusability: (e, t) => Z({
|
|
2576
2922
|
state: e,
|
|
2577
|
-
cellId: t.
|
|
2923
|
+
cellId: t.cell_id,
|
|
2578
2924
|
cellReducer: (e) => ({
|
|
2579
2925
|
...e,
|
|
2580
|
-
|
|
2926
|
+
serialization: t.serialization
|
|
2581
2927
|
})
|
|
2582
2928
|
}),
|
|
2583
|
-
|
|
2929
|
+
startCellConsole: (e, { cellId: t }) => Z({
|
|
2584
2930
|
state: e,
|
|
2585
2931
|
cellId: t,
|
|
2586
|
-
cellReducer: (e) => {
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
t = fn([...t, n]);
|
|
2594
|
-
}
|
|
2595
|
-
return {
|
|
2596
|
-
...e,
|
|
2597
|
-
pdbOutput: t
|
|
2598
|
-
};
|
|
2599
|
-
}
|
|
2932
|
+
cellReducer: (e) => ({
|
|
2933
|
+
...e,
|
|
2934
|
+
embeddedConsole: [],
|
|
2935
|
+
commandConsole: void 0,
|
|
2936
|
+
answers: void 0,
|
|
2937
|
+
clearedConsoleInputs: void 0
|
|
2938
|
+
})
|
|
2600
2939
|
}),
|
|
2601
|
-
|
|
2602
|
-
let t = {
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2940
|
+
showCommandOutput: (e, t) => {
|
|
2941
|
+
let { cell_id: n, entries: r, replace: i } = t, a = Z({
|
|
2942
|
+
state: e,
|
|
2943
|
+
cellId: n,
|
|
2944
|
+
cellReducer: (e) => ({
|
|
2945
|
+
...e,
|
|
2946
|
+
commandConsole: Cn(e.commandConsole, t, e.clearedCommandIds?.[t.op])
|
|
2947
|
+
})
|
|
2606
2948
|
});
|
|
2607
|
-
return {
|
|
2608
|
-
...
|
|
2609
|
-
|
|
2949
|
+
return i || t.op === "pdb-output" ? a : {
|
|
2950
|
+
...a,
|
|
2951
|
+
cellLogs: [...a.cellLogs, ...lr({
|
|
2952
|
+
cell_id: n,
|
|
2953
|
+
console: r
|
|
2954
|
+
})]
|
|
2610
2955
|
};
|
|
2611
2956
|
},
|
|
2612
|
-
|
|
2613
|
-
let
|
|
2957
|
+
hideConsoleInputs: (e, { cellId: t, executionId: n, inputIds: r }) => {
|
|
2958
|
+
let i = new Set(r);
|
|
2959
|
+
return Z({
|
|
2614
2960
|
state: e,
|
|
2615
|
-
cellId:
|
|
2616
|
-
cellReducer: (e) =>
|
|
2961
|
+
cellId: t,
|
|
2962
|
+
cellReducer: (e) => ({
|
|
2963
|
+
...e,
|
|
2964
|
+
clearedConsoleInputs: {
|
|
2965
|
+
executionId: n,
|
|
2966
|
+
ids: i
|
|
2967
|
+
}
|
|
2968
|
+
})
|
|
2617
2969
|
});
|
|
2970
|
+
},
|
|
2971
|
+
clearDebuggerOutput: (e) => {
|
|
2972
|
+
let t = { ...e.cellRuntime };
|
|
2973
|
+
for (let e of Object.keys(t)) {
|
|
2974
|
+
let n = t[e];
|
|
2975
|
+
n.commandConsole?.entries.some((e) => e.source === "pdb-output") && (t[e] = {
|
|
2976
|
+
...n,
|
|
2977
|
+
commandConsole: Cn(n.commandConsole, {
|
|
2978
|
+
op: "pdb-output",
|
|
2979
|
+
cell_id: e,
|
|
2980
|
+
entries: [],
|
|
2981
|
+
replace: !0
|
|
2982
|
+
})
|
|
2983
|
+
});
|
|
2984
|
+
}
|
|
2618
2985
|
return {
|
|
2619
|
-
...
|
|
2620
|
-
|
|
2986
|
+
...e,
|
|
2987
|
+
cellRuntime: t
|
|
2621
2988
|
};
|
|
2622
2989
|
},
|
|
2623
2990
|
addLogs: (e, t) => ({
|
|
@@ -2625,51 +2992,43 @@ var { reducer: Bi, createActions: Vi, useActions: Hi, valueAtom: Z } = de(zi, {
|
|
|
2625
2992
|
cellLogs: [...e.cellLogs, ...t.logs]
|
|
2626
2993
|
}),
|
|
2627
2994
|
reconcileDocument: (e, t) => {
|
|
2628
|
-
let n =
|
|
2629
|
-
for (let t of e.cellIds) t in n.cellData ||
|
|
2995
|
+
let n = Ur(e, t);
|
|
2996
|
+
for (let t of e.cellIds) t in n.cellData || wa(t);
|
|
2630
2997
|
return n;
|
|
2631
2998
|
},
|
|
2632
|
-
setStdinResponse: (e,
|
|
2633
|
-
let { cellId:
|
|
2634
|
-
return
|
|
2999
|
+
setStdinResponse: (e, t) => {
|
|
3000
|
+
let { cellId: n, response: r, inputId: i } = t;
|
|
3001
|
+
return Z({
|
|
2635
3002
|
state: e,
|
|
2636
|
-
cellId:
|
|
2637
|
-
cellReducer: (e) => {
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
mimetype: r.mimetype,
|
|
2642
|
-
data: r.data,
|
|
2643
|
-
timestamp: r.timestamp,
|
|
2644
|
-
id: r.id,
|
|
2645
|
-
input_id: r.input_id,
|
|
2646
|
-
response: r.mimetype === "text/password" ? "" : i
|
|
2647
|
-
}, {
|
|
2648
|
-
...e,
|
|
2649
|
-
consoleOutputs: n
|
|
2650
|
-
});
|
|
2651
|
-
}
|
|
3003
|
+
cellId: n,
|
|
3004
|
+
cellReducer: (e) => ({
|
|
3005
|
+
...e,
|
|
3006
|
+
answers: new Map(e.answers).set(i, r)
|
|
3007
|
+
})
|
|
2652
3008
|
});
|
|
2653
3009
|
},
|
|
2654
|
-
resetCellRuntimes: (e) => {
|
|
2655
|
-
let
|
|
2656
|
-
for (let
|
|
2657
|
-
let
|
|
2658
|
-
|
|
3010
|
+
resetCellRuntimes: (e, t) => {
|
|
3011
|
+
let n = be(), r = { ...e.cellRuntime };
|
|
3012
|
+
for (let i of [...e.cellIds, B]) {
|
|
3013
|
+
let a = e.cellRuntime[i];
|
|
3014
|
+
r[i] = n && a !== void 0 && a.embeddedConsole.length > 0 ? a : yr({
|
|
3015
|
+
clearedConsole: t ? a?.clearedConsole : void 0,
|
|
3016
|
+
clearedCommandIds: t ? a?.clearedCommandIds : void 0
|
|
3017
|
+
});
|
|
2659
3018
|
}
|
|
2660
3019
|
return {
|
|
2661
3020
|
...e,
|
|
2662
|
-
cellRuntime:
|
|
3021
|
+
cellRuntime: r
|
|
2663
3022
|
};
|
|
2664
3023
|
},
|
|
2665
3024
|
scrollToTarget: (e) => {
|
|
2666
3025
|
let t = e.scrollKey;
|
|
2667
3026
|
if (t === null) return e;
|
|
2668
3027
|
let n = t;
|
|
2669
|
-
return
|
|
3028
|
+
return ta({
|
|
2670
3029
|
cellId: n,
|
|
2671
3030
|
cell: e.cellHandles[n],
|
|
2672
|
-
isCodeHidden:
|
|
3031
|
+
isCodeHidden: Kr(e.cellData[n]?.config.hide_code, y.get(G), n),
|
|
2673
3032
|
codeFocus: void 0,
|
|
2674
3033
|
variableName: void 0
|
|
2675
3034
|
}), {
|
|
@@ -2677,31 +3036,29 @@ var { reducer: Bi, createActions: Vi, useActions: Hi, valueAtom: Z } = de(zi, {
|
|
|
2677
3036
|
scrollKey: null
|
|
2678
3037
|
};
|
|
2679
3038
|
},
|
|
2680
|
-
foldAll: (e) => (
|
|
2681
|
-
unfoldAll: (e) => (
|
|
3039
|
+
foldAll: (e) => (mn(Object.values(e.cellHandles).map((e) => e.current?.editorView)), e),
|
|
3040
|
+
unfoldAll: (e) => (hn(Object.values(e.cellHandles).map((e) => e.current?.editorView)), e),
|
|
2682
3041
|
clearLogs: (e) => ({
|
|
2683
3042
|
...e,
|
|
2684
3043
|
cellLogs: []
|
|
2685
3044
|
}),
|
|
2686
|
-
|
|
2687
|
-
|
|
3045
|
+
clearCellConsole: (e, t) => Z({
|
|
3046
|
+
state: e,
|
|
3047
|
+
cellId: t.cellId,
|
|
3048
|
+
cellReducer: (e) => {
|
|
3049
|
+
let n = { ...e.clearedCommandIds };
|
|
3050
|
+
for (let t of e.commandConsole?.entries ?? []) t.command_id !== void 0 && (n[t.source] = t.command_id);
|
|
3051
|
+
return {
|
|
3052
|
+
...e,
|
|
3053
|
+
commandConsole: void 0,
|
|
3054
|
+
clearedCommandIds: n,
|
|
3055
|
+
clearedConsole: t.clearedConsole,
|
|
3056
|
+
embeddedConsole: e.embeddedConsole.filter((e) => e.channel === "stdin" && e.response === void 0)
|
|
3057
|
+
};
|
|
3058
|
+
}
|
|
3059
|
+
})
|
|
2688
3060
|
});
|
|
2689
|
-
function
|
|
2690
|
-
let r = { ...e.cellRuntime };
|
|
2691
|
-
for (let e of n) {
|
|
2692
|
-
let n = r[e];
|
|
2693
|
-
n === void 0 ? t.warn(`Cell ${e} not found in state`) : r[e] = {
|
|
2694
|
-
...n,
|
|
2695
|
-
pdbOutput: void 0,
|
|
2696
|
-
consoleOutputs: n.consoleOutputs.filter((e) => e.channel === "stdin" && e.response == null)
|
|
2697
|
-
};
|
|
2698
|
-
}
|
|
2699
|
-
return {
|
|
2700
|
-
...e,
|
|
2701
|
-
cellRuntime: r
|
|
2702
|
-
};
|
|
2703
|
-
}
|
|
2704
|
-
function Q({ state: e, cellId: n, cellReducer: r }) {
|
|
3061
|
+
function Z({ state: e, cellId: n, cellReducer: r }) {
|
|
2705
3062
|
return n in e.cellRuntime ? {
|
|
2706
3063
|
...e,
|
|
2707
3064
|
cellRuntime: {
|
|
@@ -2710,17 +3067,17 @@ function Q({ state: e, cellId: n, cellReducer: r }) {
|
|
|
2710
3067
|
}
|
|
2711
3068
|
} : (t.warn(`Cell ${n} not found in state`), e);
|
|
2712
3069
|
}
|
|
2713
|
-
var
|
|
2714
|
-
|
|
2715
|
-
}).addLogs,
|
|
2716
|
-
|
|
2717
|
-
var
|
|
2718
|
-
|
|
2719
|
-
var
|
|
2720
|
-
let { cellIds: t, cellData: n } = e(
|
|
3070
|
+
var ua = ca((e) => {
|
|
3071
|
+
y.set(X, (t) => sa(t, e));
|
|
3072
|
+
}).addLogs, Q = x((e) => e(X).cellIds);
|
|
3073
|
+
x((e) => e(Q).length === 1), x((e) => $r(e(X)).length > 0), x((e) => ei(e(X)).length > 0), x((e) => ti(e(X))), x((e) => ni(e(X)));
|
|
3074
|
+
var da = x((e) => ai(e(X), e(L), e(Zt)));
|
|
3075
|
+
x((e) => e(da) !== null);
|
|
3076
|
+
var fa = x((e) => {
|
|
3077
|
+
let { cellIds: t, cellData: n } = e(X);
|
|
2721
3078
|
return t.map((t) => {
|
|
2722
|
-
let r = e(
|
|
2723
|
-
if (r !== null &&
|
|
3079
|
+
let r = e(R(t)), { name: i } = n[t];
|
|
3080
|
+
if (r !== null && Sn(r.mimetype)) {
|
|
2724
3081
|
C(Array.isArray(r.data), "Expected array data");
|
|
2725
3082
|
let e = r.data.filter((e) => !e.type.includes("ancestor"));
|
|
2726
3083
|
if (e.length > 0) return {
|
|
@@ -2734,88 +3091,103 @@ var Ki = b((e) => {
|
|
|
2734
3091
|
}
|
|
2735
3092
|
return null;
|
|
2736
3093
|
}).filter(Boolean);
|
|
2737
|
-
}),
|
|
3094
|
+
}), pa = ce(x((e) => {
|
|
2738
3095
|
let t = {};
|
|
2739
|
-
for (let n of e(
|
|
2740
|
-
let r = e(
|
|
3096
|
+
for (let n of e(Q)) {
|
|
3097
|
+
let r = e(z(n));
|
|
2741
3098
|
r !== null && r.items.length > 0 && (t[n] = r);
|
|
2742
3099
|
}
|
|
2743
3100
|
return t;
|
|
2744
|
-
})),
|
|
2745
|
-
|
|
2746
|
-
var
|
|
2747
|
-
let { cellIds: t, cellData: n } = e(
|
|
2748
|
-
return
|
|
3101
|
+
})), ma = x((e) => Je(e(Q).map((t) => e(z(t)))));
|
|
3102
|
+
x((e) => e(fa).length);
|
|
3103
|
+
var ha = ce(x((e) => {
|
|
3104
|
+
let { cellIds: t, cellData: n } = e(X);
|
|
3105
|
+
return ue.fromEntries(t.map((e) => [e, n[e]?.name]));
|
|
2749
3106
|
}));
|
|
2750
|
-
|
|
2751
|
-
var
|
|
2752
|
-
let { cellIds: e, cellData: t } =
|
|
3107
|
+
x((e) => e(X).scrollKey);
|
|
3108
|
+
var ga = () => v(Q), _a = () => v(ha), va = () => y.get(X), ya = () => y.get(X).cellIds, ba = () => {
|
|
3109
|
+
let { cellIds: e, cellData: t } = y.get(X);
|
|
2753
3110
|
return e.map((e) => t[e]?.name).filter(Boolean);
|
|
2754
3111
|
};
|
|
2755
|
-
|
|
2756
|
-
var
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
3112
|
+
ee(_(X, (e) => e.cellIds.map((t) => e.cellData[t]))), x((e) => e(X).cellIds.length > 0);
|
|
3113
|
+
var xa = S((e) => x((t) => t(X).cellData[e])), Sa = yr(), $ = S((e) => {
|
|
3114
|
+
let t = x((t) => {
|
|
3115
|
+
let n = Sr(t, e), r = t(m)?.cells;
|
|
3116
|
+
return {
|
|
3117
|
+
local: t(X).cellRuntime[e] ?? Sa,
|
|
3118
|
+
execution: n,
|
|
3119
|
+
code: n && Ct(n.record, r)
|
|
3120
|
+
};
|
|
3121
|
+
}), n = _(t, Cr);
|
|
3122
|
+
return x((e) => e(n).rendered);
|
|
3123
|
+
}), Ca = S((e) => x((t) => t(X).cellHandles[e]));
|
|
3124
|
+
function wa(e) {
|
|
3125
|
+
xa.remove(e), $.remove(e), Ca.remove(e), nn(e);
|
|
3126
|
+
}
|
|
3127
|
+
var Ta = (e) => {
|
|
3128
|
+
let { cellHandles: t } = y.get(X);
|
|
2762
3129
|
return t[e].current?.editorView;
|
|
2763
|
-
},
|
|
2764
|
-
|
|
2765
|
-
|
|
3130
|
+
}, Ea = (e) => (yn.promote(e), Ta(e));
|
|
3131
|
+
x((e) => e(Q).map((t) => ({
|
|
3132
|
+
...e(xa(t)),
|
|
3133
|
+
...e($(t)),
|
|
3134
|
+
output: e(R(t))
|
|
3135
|
+
})));
|
|
3136
|
+
function Da() {
|
|
3137
|
+
return la();
|
|
2766
3138
|
}
|
|
2767
3139
|
//#endregion
|
|
2768
3140
|
//#region src/core/errors/error-entries.ts
|
|
2769
|
-
function
|
|
2770
|
-
if (
|
|
3141
|
+
function Oa(e) {
|
|
3142
|
+
if (bn(e.mimetype)) {
|
|
2771
3143
|
if (!Array.isArray(e.data)) return null;
|
|
2772
3144
|
let t = e.data.filter((e) => !e.type.includes("ancestor"));
|
|
2773
3145
|
return t.length === 0 ? null : { errorData: t };
|
|
2774
3146
|
}
|
|
2775
|
-
return
|
|
3147
|
+
return xn(e.mimetype) ? typeof e.data != "string" || e.data.length === 0 ? null : {
|
|
2776
3148
|
errorData: [],
|
|
2777
3149
|
tracebackHtml: e.data
|
|
2778
3150
|
} : null;
|
|
2779
3151
|
}
|
|
2780
|
-
function
|
|
3152
|
+
function ka(e) {
|
|
2781
3153
|
return e.some((e) => "traceback" in e && e.traceback);
|
|
2782
3154
|
}
|
|
2783
|
-
function
|
|
2784
|
-
let t = e?.find((e) =>
|
|
3155
|
+
function Aa(e) {
|
|
3156
|
+
let t = e?.find((e) => xn(e.mimetype));
|
|
2785
3157
|
if (t && typeof t.data == "string" && t.data.length !== 0) return t.data;
|
|
2786
3158
|
}
|
|
2787
|
-
function
|
|
3159
|
+
function ja(e, t) {
|
|
2788
3160
|
if (e.tracebackHtml) return e.tracebackHtml;
|
|
2789
|
-
if (!
|
|
2790
|
-
}
|
|
2791
|
-
function
|
|
2792
|
-
let { cellIds: t,
|
|
2793
|
-
for (let [
|
|
2794
|
-
let t = e.get(
|
|
2795
|
-
if (t === null || !
|
|
2796
|
-
let
|
|
2797
|
-
if (!
|
|
2798
|
-
let
|
|
2799
|
-
|
|
2800
|
-
cellId:
|
|
2801
|
-
cellName:
|
|
2802
|
-
cellCode:
|
|
2803
|
-
errorData:
|
|
2804
|
-
tracebackHtml:
|
|
3161
|
+
if (!ka(e.errorData)) return Aa(t);
|
|
3162
|
+
}
|
|
3163
|
+
function Ma(e) {
|
|
3164
|
+
let { cellIds: t, cellData: n } = e.get(X), r = [];
|
|
3165
|
+
for (let [i, a] of t.entries()) {
|
|
3166
|
+
let t = e.get(R(a));
|
|
3167
|
+
if (t === null || !Sn(t.mimetype)) continue;
|
|
3168
|
+
let o = Oa(t);
|
|
3169
|
+
if (!o) continue;
|
|
3170
|
+
let s = hr(n[a].name, i), c = t.code ?? n[a].code;
|
|
3171
|
+
r.push({
|
|
3172
|
+
cellId: a,
|
|
3173
|
+
cellName: s,
|
|
3174
|
+
cellCode: c,
|
|
3175
|
+
errorData: o.errorData,
|
|
3176
|
+
tracebackHtml: ja(o, e.get($(a)).consoleOutputs)
|
|
2805
3177
|
});
|
|
2806
3178
|
}
|
|
2807
|
-
return
|
|
3179
|
+
return r;
|
|
2808
3180
|
}
|
|
2809
|
-
function
|
|
3181
|
+
function Na(e) {
|
|
2810
3182
|
return e.type === "diagnostic" ? e.msg : e.type === "setup-refs" ? "The setup cell cannot have references" : e.type === "cycle" ? "This cell is in a cycle" : e.type === "multiple-defs" ? `The variable '${e.name}' was defined by another cell` : e.type === "import-star" || e.type === "lazy-import" || e.type === "ancestor-stopped" || e.type === "ancestor-prevented" || e.type === "exception" || e.type === "strict-exception" ? e.msg : e.type === "interruption" ? "This cell was interrupted and needs to be re-run" : e.type === "syntax" || e.type === "unknown" || e.type === "sql-error" ? e.msg : e.type === "internal" ? e.msg || "An internal error occurred" : (u(e), "Unknown error");
|
|
2811
3183
|
}
|
|
2812
|
-
function
|
|
2813
|
-
let t =
|
|
2814
|
-
return "traceback" in e && e.traceback && (t += `\n\nTraceback:\n${
|
|
3184
|
+
function Pa(e) {
|
|
3185
|
+
let t = Na(e);
|
|
3186
|
+
return "traceback" in e && e.traceback && (t += `\n\nTraceback:\n${W(e.traceback)}`), t;
|
|
2815
3187
|
}
|
|
2816
|
-
function
|
|
3188
|
+
function Fa(e) {
|
|
2817
3189
|
let t = [e.cellName];
|
|
2818
|
-
return e.tracebackHtml && t.push(
|
|
3190
|
+
return e.tracebackHtml && t.push(W(e.tracebackHtml)), e.errorData.length > 0 && t.push(e.errorData.map(Pa).join("\n\n")), t.join("\n\n");
|
|
2819
3191
|
}
|
|
2820
3192
|
//#endregion
|
|
2821
|
-
export {
|
|
3193
|
+
export { Kr as $, Qe as $t, $i as A, V as At, Ai as B, z as Bt, ta as C, lr as Ct, ea as D, Fn as Dt, ra as E, Qn as Et, Fi as F, wn as Ft, fi as G, cn as Gt, Ci as H, en as Ht, Mi as I, Tn as It, si as J, sn as Jt, ui as K, an as Kt, Ni as L, un as Lt, Ri as M, kn as Mt, Ii as N, Mn as Nt, Y as O, An as Ot, Pi as P, jn as Pt, Jr as Q, lt as Qt, Oi as R, L as Rt, Da as S, pr as St, ia as T, W as Tt, bi as U, rn as Ut, Si as V, R as Vt, hi as W, Jt as Wt, ci as X, It as Xt, Qr as Y, ln as Yt, li as Z, ut as Zt, ma as _, Sr as _t, ua as a, Ce as an, Dr as at, ga as b, mr as bt, $ as c, Lr as ct, Ta as d, Br as dt, O as en, qr as et, ba as f, Pr as ft, X as g, wr as gt, oa as h, Fr as ht, Ma as i, we as in, Er as it, Zi as j, B as jt, Qi as k, Nn as kt, ca as l, zr as lt, va as m, Ir as mt, Fa as n, qe as nn, Gr as nt, xa as o, Rr as ot, ya as p, kr as pt, di as q, dn as qt, Pa as r, He as rn, Wr as rt, Q as s, Or as st, Na as t, Xe as tn, G as tt, Ea as u, Vr as ut, sa as v, xr as vt, na as w, ar as wt, _a as x, gr as xt, wa as y, hr as yt, ki as z, Zt as zt };
|