@marimo-team/islands 0.19.8-dev32 → 0.19.8-dev34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js
CHANGED
|
@@ -73203,7 +73203,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
73203
73203
|
return Logger.warn("Failed to get version from mount config"), null;
|
|
73204
73204
|
}
|
|
73205
73205
|
}
|
|
73206
|
-
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.8-
|
|
73206
|
+
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.8-dev34"), showCodeInRunModeAtom = atom(true);
|
|
73207
73207
|
atom(null);
|
|
73208
73208
|
var import_compiler_runtime$88 = require_compiler_runtime();
|
|
73209
73209
|
function useKeydownOnElement(e, r) {
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { parseOutline } from "@/core/dom/outline";
|
|
|
7
7
|
import { MultiColumn, visibleForTesting } from "@/utils/id-tree";
|
|
8
8
|
import { invariant } from "@/utils/invariant";
|
|
9
9
|
import { Logger } from "@/utils/Logger";
|
|
10
|
-
import type
|
|
10
|
+
import { type CellId, SETUP_CELL_ID } from "../ids";
|
|
11
11
|
import { notebookStateFromSession } from "../session";
|
|
12
12
|
|
|
13
13
|
// Mock dependencies
|
|
@@ -358,6 +358,42 @@ describe("notebookStateFromSession", () => {
|
|
|
358
358
|
serializedEditorState: null,
|
|
359
359
|
});
|
|
360
360
|
});
|
|
361
|
+
|
|
362
|
+
it("uses SETUP_CELL_ID for setup cell with null id", () => {
|
|
363
|
+
const notebookCell = {
|
|
364
|
+
id: null,
|
|
365
|
+
code: "import marimo as mo",
|
|
366
|
+
name: "setup",
|
|
367
|
+
code_hash: null,
|
|
368
|
+
config: {
|
|
369
|
+
hide_code: null,
|
|
370
|
+
disabled: null,
|
|
371
|
+
column: null,
|
|
372
|
+
},
|
|
373
|
+
};
|
|
374
|
+
const notebook = createNotebook([notebookCell as any]);
|
|
375
|
+
const result = notebookStateFromSession(null, notebook);
|
|
376
|
+
|
|
377
|
+
expect(result).not.toBeNull();
|
|
378
|
+
invariant(result, "result is null");
|
|
379
|
+
expect(result.cellIds.inOrderIds).toEqual(
|
|
380
|
+
MultiColumn.from([[SETUP_CELL_ID]]).inOrderIds,
|
|
381
|
+
);
|
|
382
|
+
expect(result.cellData[SETUP_CELL_ID]).toEqual({
|
|
383
|
+
id: SETUP_CELL_ID,
|
|
384
|
+
name: "setup",
|
|
385
|
+
code: "import marimo as mo",
|
|
386
|
+
edited: false,
|
|
387
|
+
lastCodeRun: null,
|
|
388
|
+
lastExecutionTime: null,
|
|
389
|
+
config: {
|
|
390
|
+
hide_code: false,
|
|
391
|
+
disabled: false,
|
|
392
|
+
column: null,
|
|
393
|
+
},
|
|
394
|
+
serializedEditorState: null,
|
|
395
|
+
});
|
|
396
|
+
});
|
|
361
397
|
});
|
|
362
398
|
|
|
363
399
|
describe("both session and notebook scenarios", () => {
|
|
@@ -6,7 +6,7 @@ import { MultiColumn } from "@/utils/id-tree";
|
|
|
6
6
|
import { Logger } from "@/utils/Logger";
|
|
7
7
|
import { parseOutline } from "../dom/outline";
|
|
8
8
|
import type { NotebookState } from "./cells";
|
|
9
|
-
import { CellId } from "./ids";
|
|
9
|
+
import { CellId, SETUP_CELL_ID } from "./ids";
|
|
10
10
|
import {
|
|
11
11
|
type CellData,
|
|
12
12
|
type CellRuntimeState,
|
|
@@ -20,6 +20,22 @@ const EMPTY_STRING = "";
|
|
|
20
20
|
type SessionCell = api.Session["NotebookSessionV1"]["cells"][0];
|
|
21
21
|
type NotebookCell = api.Notebook["NotebookV1"]["cells"][0];
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Get the cell ID from a cell object.
|
|
25
|
+
* If the cell has an ID, use it.
|
|
26
|
+
* If the cell has a name of "setup", use the special SETUP_CELL_ID.
|
|
27
|
+
* Otherwise, generate a new random ID.
|
|
28
|
+
*/
|
|
29
|
+
function getCellId(cell: { id?: string | null; name?: string | null }): CellId {
|
|
30
|
+
if (cell.id) {
|
|
31
|
+
return cell.id as CellId;
|
|
32
|
+
}
|
|
33
|
+
if (cell.name === SETUP_CELL_ID) {
|
|
34
|
+
return SETUP_CELL_ID;
|
|
35
|
+
}
|
|
36
|
+
return CellId.create();
|
|
37
|
+
}
|
|
38
|
+
|
|
23
39
|
function mergeSessionAndNotebookCells(
|
|
24
40
|
session: api.Session["NotebookSessionV1"] | null | undefined,
|
|
25
41
|
notebook: api.Notebook["NotebookV1"] | null | undefined,
|
|
@@ -36,9 +52,7 @@ function mergeSessionAndNotebookCells(
|
|
|
36
52
|
}
|
|
37
53
|
|
|
38
54
|
if (!session) {
|
|
39
|
-
const cellIds =
|
|
40
|
-
(cell) => cell.id ?? CellId.create(),
|
|
41
|
-
) || []) as CellId[];
|
|
55
|
+
const cellIds = notebook?.cells.map((cell) => getCellId(cell)) || [];
|
|
42
56
|
return {
|
|
43
57
|
cellIds,
|
|
44
58
|
sessionCellData: new Map(
|
|
@@ -57,9 +71,7 @@ function mergeSessionAndNotebookCells(
|
|
|
57
71
|
}
|
|
58
72
|
|
|
59
73
|
if (!notebook) {
|
|
60
|
-
const cellIds = session.cells.map(
|
|
61
|
-
(cell) => cell.id ?? CellId.create(),
|
|
62
|
-
) as CellId[];
|
|
74
|
+
const cellIds = session.cells.map((cell) => getCellId(cell));
|
|
63
75
|
return {
|
|
64
76
|
cellIds,
|
|
65
77
|
sessionCellData: new Map(
|
|
@@ -105,7 +117,7 @@ function mergeSessionAndNotebookCells(
|
|
|
105
117
|
for (let i = 0; i < notebook.cells.length; i++) {
|
|
106
118
|
const notebookCell = notebook.cells[i];
|
|
107
119
|
if (notebookCell) {
|
|
108
|
-
const id = (notebookCell
|
|
120
|
+
const id = getCellId(notebookCell);
|
|
109
121
|
mergedCellIdsTyped.push(id);
|
|
110
122
|
|
|
111
123
|
// Should always be set, but good typing fallback too.
|