@marimo-team/islands 0.21.2-dev6 → 0.21.2-dev61
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/{ConnectedDataExplorerComponent-D0GoOd_c.js → ConnectedDataExplorerComponent-DrWDbHRV.js} +1 -1
- package/dist/{any-language-editor-DlsjUw_l.js → any-language-editor-BRpxklRq.js} +1 -1
- package/dist/{copy-DIK6DiIA.js → copy-BjkXCUxP.js} +12 -2
- package/dist/{esm-BLobyqMs.js → esm-No_6eSQS.js} +1 -1
- package/dist/{glide-data-editor-pZyd9UJ_.js → glide-data-editor-858wsVkd.js} +1 -1
- package/dist/main.js +821 -417
- package/dist/{spec-Bfvf9Hre.js → spec-oVDndBz4.js} +25 -16
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/__mocks__/notebook.ts +9 -9
- package/src/__mocks__/requests.ts +1 -0
- package/src/__tests__/branded.ts +20 -0
- package/src/components/app-config/user-config-form.tsx +5 -4
- package/src/components/data-table/__tests__/utils.test.ts +138 -1
- package/src/components/data-table/charts/__tests__/storage.test.ts +7 -7
- package/src/components/data-table/context-menu.tsx +9 -5
- package/src/components/data-table/data-table.tsx +3 -0
- package/src/components/data-table/range-focus/__tests__/atoms.test.ts +8 -2
- package/src/components/data-table/range-focus/__tests__/test-utils.ts +2 -0
- package/src/components/data-table/range-focus/__tests__/utils.test.ts +82 -8
- package/src/components/data-table/range-focus/atoms.ts +2 -2
- package/src/components/data-table/range-focus/utils.ts +50 -12
- package/src/components/data-table/types.ts +7 -0
- package/src/components/data-table/utils.ts +87 -0
- package/src/components/editor/__tests__/data-attributes.test.tsx +8 -8
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +15 -15
- package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap +2 -2
- package/src/components/editor/connections/storage/as-code.ts +2 -2
- package/src/components/editor/file-tree/file-explorer.tsx +16 -2
- package/src/components/editor/file-tree/file-viewer.tsx +17 -3
- package/src/components/editor/navigation/__tests__/clipboard.test.ts +2 -2
- package/src/components/editor/navigation/__tests__/selection.test.ts +7 -6
- package/src/components/editor/navigation/__tests__/state.test.ts +8 -7
- package/src/components/editor/output/MarimoErrorOutput.tsx +7 -7
- package/src/components/editor/output/__tests__/traceback.test.tsx +4 -4
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +4 -4
- package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +8 -1
- package/src/components/storage/storage-file-viewer.tsx +35 -1
- package/src/components/storage/storage-inspector.tsx +9 -4
- package/src/components/storage/storage-snippets.ts +3 -3
- package/src/components/tracing/tracing.tsx +3 -1
- package/src/components/ui/range-slider.tsx +108 -1
- package/src/core/ai/__tests__/staged-cells.test.ts +9 -8
- package/src/core/ai/context/providers/__tests__/cell-output.test.ts +31 -31
- package/src/core/ai/context/providers/__tests__/datasource.test.ts +3 -3
- package/src/core/ai/context/providers/__tests__/tables.test.ts +3 -2
- package/src/core/ai/context/providers/__tests__/variable.test.ts +84 -63
- package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +10 -9
- package/src/core/ai/tools/__tests__/run-cells-tool.test.ts +6 -6
- package/src/core/ai/tools/edit-notebook-tool.ts +3 -3
- package/src/core/cells/__tests__/add-missing-import.test.ts +3 -3
- package/src/core/cells/__tests__/apply-transaction.test.ts +279 -0
- package/src/core/cells/__tests__/cells.test.ts +198 -135
- package/src/core/cells/__tests__/document-changes.test.ts +575 -0
- package/src/core/cells/__tests__/document-roundtrip.test.ts +376 -0
- package/src/core/cells/__tests__/focus.test.ts +5 -4
- package/src/core/cells/__tests__/logs.test.ts +13 -12
- package/src/core/cells/__tests__/pending-delete-service.test.tsx +3 -3
- package/src/core/cells/__tests__/runs.test.ts +22 -21
- package/src/core/cells/__tests__/scrollCellIntoView.test.ts +8 -7
- package/src/core/cells/__tests__/session.test.ts +23 -22
- package/src/core/cells/cells.ts +29 -4
- package/src/core/cells/document-changes.ts +644 -0
- package/src/core/cells/ids.ts +5 -5
- package/src/core/cells/logs.ts +2 -2
- package/src/core/cells/runs.ts +6 -8
- package/src/core/codemirror/__tests__/format.test.ts +34 -36
- package/src/core/codemirror/__tests__/setup.test.ts +2 -2
- package/src/core/codemirror/cells/__tests__/extensions.test.ts +114 -0
- package/src/core/codemirror/cells/__tests__/traceback-decorations.test.ts +33 -32
- package/src/core/codemirror/cells/extensions.ts +66 -23
- package/src/core/codemirror/completion/__tests__/keymap.test.ts +15 -35
- package/src/core/codemirror/completion/keymap.ts +14 -4
- package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +12 -13
- package/src/core/codemirror/language/__tests__/utils.test.ts +3 -3
- package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +7 -8
- package/src/core/codemirror/language/languages/python.ts +4 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +4 -3
- package/src/core/codemirror/lsp/notebook-lsp.ts +28 -2
- package/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts +7 -6
- package/src/core/codemirror/reactive-references/analyzer.ts +2 -2
- package/src/core/codemirror/rtc/loro/__tests__/sync.test.ts +52 -0
- package/src/core/codemirror/rtc/loro/sync.ts +1 -0
- package/src/core/datasets/__tests__/data-source.test.ts +5 -6
- package/src/core/datasets/state.ts +1 -1
- package/src/core/errors/__tests__/errors.test.ts +2 -1
- package/src/core/export/__tests__/hooks.test.ts +37 -36
- package/src/core/islands/bridge.ts +1 -0
- package/src/core/islands/main.ts +4 -7
- package/src/core/kernel/__tests__/handlers.test.ts +5 -4
- package/src/core/kernel/handlers.ts +7 -4
- package/src/core/network/DeferredRequestRegistry.ts +2 -2
- package/src/core/network/__tests__/CachingRequestRegistry.test.ts +9 -10
- package/src/core/network/__tests__/DeferredRequestRegistry.test.ts +4 -6
- package/src/core/network/requests-lazy.ts +1 -0
- package/src/core/network/requests-network.ts +9 -0
- package/src/core/network/requests-static.ts +1 -0
- package/src/core/network/requests-toasting.tsx +1 -0
- package/src/core/network/types.ts +5 -0
- package/src/core/static/__tests__/virtual-file-tracker.test.ts +8 -8
- package/src/core/static/virtual-file-tracker.ts +1 -1
- package/src/core/storage/__tests__/state.test.ts +31 -21
- package/src/core/storage/state.ts +1 -1
- package/src/core/variables/__tests__/state.test.ts +6 -6
- package/src/core/variables/types.ts +2 -2
- package/src/core/wasm/__tests__/state.test.ts +8 -8
- package/src/core/wasm/bridge.ts +1 -0
- package/src/core/websocket/useMarimoKernelConnection.tsx +31 -16
- package/src/css/app/fonts.css +6 -6
- package/src/css/md-tooltip.css +4 -39
- package/src/css/md.css +7 -0
- package/src/fonts/Fira_Mono/FiraMono-Bold.woff2 +0 -0
- package/src/fonts/Fira_Mono/FiraMono-Medium.woff2 +0 -0
- package/src/fonts/Fira_Mono/FiraMono-Regular.woff2 +0 -0
- package/src/fonts/Lora/Lora-VariableFont_wght.woff2 +0 -0
- package/src/fonts/PT_Sans/PTSans-Bold.woff2 +0 -0
- package/src/fonts/PT_Sans/PTSans-Regular.woff2 +0 -0
- package/src/plugins/core/RenderHTML.tsx +17 -0
- package/src/plugins/core/__test__/RenderHTML.test.ts +45 -0
- package/src/plugins/core/sanitize-html.ts +25 -18
- package/src/plugins/impl/DataTablePlugin.tsx +23 -2
- package/src/plugins/impl/SliderPlugin.tsx +1 -3
- package/src/plugins/impl/__tests__/SliderPlugin.test.tsx +120 -0
- package/src/plugins/impl/anywidget/model.ts +1 -2
- package/src/stories/cell.stories.tsx +8 -8
- package/src/stories/layout/vertical/one-column.stories.tsx +9 -8
- package/src/stories/log-viewer.stories.tsx +8 -8
- package/src/stories/variables.stories.tsx +2 -2
- package/src/utils/__tests__/download.test.tsx +21 -20
- package/src/utils/copy.ts +18 -5
- package/src/utils/createReducer.ts +26 -11
- package/src/utils/download.ts +4 -3
- package/src/utils/html-to-image.ts +6 -0
- package/src/utils/json/base64.ts +3 -3
- package/src/utils/traceback.ts +5 -3
- package/src/fonts/Fira_Mono/FiraMono-Bold.ttf +0 -0
- package/src/fonts/Fira_Mono/FiraMono-Medium.ttf +0 -0
- package/src/fonts/Fira_Mono/FiraMono-Regular.ttf +0 -0
- package/src/fonts/Lora/Lora-Italic-VariableFont_wght.ttf +0 -0
- package/src/fonts/Lora/Lora-VariableFont_wght.ttf +0 -0
- package/src/fonts/Lora/static/Lora-Bold.ttf +0 -0
- package/src/fonts/Lora/static/Lora-BoldItalic.ttf +0 -0
- package/src/fonts/Lora/static/Lora-Italic.ttf +0 -0
- package/src/fonts/Lora/static/Lora-Medium.ttf +0 -0
- package/src/fonts/Lora/static/Lora-MediumItalic.ttf +0 -0
- package/src/fonts/Lora/static/Lora-Regular.ttf +0 -0
- package/src/fonts/Lora/static/Lora-SemiBold.ttf +0 -0
- package/src/fonts/Lora/static/Lora-SemiBoldItalic.ttf +0 -0
- package/src/fonts/PT_Sans/PTSans-Bold.ttf +0 -0
- package/src/fonts/PT_Sans/PTSans-BoldItalic.ttf +0 -0
- package/src/fonts/PT_Sans/PTSans-Italic.ttf +0 -0
- package/src/fonts/PT_Sans/PTSans-Regular.ttf +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import type { Table } from "@tanstack/react-table";
|
|
3
4
|
import type { TableData } from "@/plugins/impl/DataTablePlugin";
|
|
4
5
|
import { vegaLoadData } from "@/plugins/impl/vega/loader";
|
|
5
6
|
import { jsonParseWithSpecialChar } from "@/utils/json/json-parser";
|
|
7
|
+
import { getMimeValues } from "./mime-cell";
|
|
6
8
|
import { INDEX_COLUMN_NAME } from "./types";
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -32,6 +34,21 @@ export async function loadTableData<T = object>(
|
|
|
32
34
|
return tableData;
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Load both table and raw table data. Raw table data is typically when
|
|
39
|
+
* there is formatting applied to the table data.
|
|
40
|
+
*/
|
|
41
|
+
export async function loadTableAndRawData<T>(
|
|
42
|
+
tableData: TableData<T>,
|
|
43
|
+
rawTableData?: TableData<T> | null,
|
|
44
|
+
): Promise<[T[], T[] | undefined]> {
|
|
45
|
+
if (rawTableData) {
|
|
46
|
+
return Promise.all([loadTableData(tableData), loadTableData(rawTableData)]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return [await loadTableData(tableData), undefined];
|
|
50
|
+
}
|
|
51
|
+
|
|
35
52
|
/**
|
|
36
53
|
* Get the stable row ID for a row.
|
|
37
54
|
*
|
|
@@ -87,3 +104,73 @@ export function stringifyUnknownValue(opts: {
|
|
|
87
104
|
}
|
|
88
105
|
return String(value);
|
|
89
106
|
}
|
|
107
|
+
|
|
108
|
+
function stripHtml(html: string): string {
|
|
109
|
+
const div = document.createElement("div");
|
|
110
|
+
div.innerHTML = html;
|
|
111
|
+
const text = (div.textContent || div.innerText || "").trim();
|
|
112
|
+
return text || html;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const HTML_MIMETYPES = new Set(["text/html", "text/markdown"]);
|
|
116
|
+
|
|
117
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
118
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Get clipboard-ready text and optional HTML for a cell.
|
|
123
|
+
*
|
|
124
|
+
* @param rawValue - The raw (unformatted) value, or undefined if not available.
|
|
125
|
+
* @param displayedValue - The displayed value (may be a mime bundle).
|
|
126
|
+
*/
|
|
127
|
+
export function getClipboardContent(
|
|
128
|
+
rawValue: unknown,
|
|
129
|
+
displayedValue: unknown,
|
|
130
|
+
): { text: string; html?: string } {
|
|
131
|
+
const mimeValues =
|
|
132
|
+
typeof displayedValue === "object" && displayedValue !== null
|
|
133
|
+
? getMimeValues(displayedValue)
|
|
134
|
+
: undefined;
|
|
135
|
+
|
|
136
|
+
let html: string | undefined;
|
|
137
|
+
if (mimeValues) {
|
|
138
|
+
// text/markdown from mo.md() contains rendered HTML
|
|
139
|
+
const htmlParts = mimeValues
|
|
140
|
+
.filter((v) => HTML_MIMETYPES.has(v.mimetype))
|
|
141
|
+
.map((v) => v.data);
|
|
142
|
+
html = htmlParts.length > 0 ? htmlParts.join("") : undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let text: string;
|
|
146
|
+
if (rawValue !== undefined && rawValue !== displayedValue) {
|
|
147
|
+
text = stringifyUnknownValue({ value: rawValue });
|
|
148
|
+
} else if (mimeValues) {
|
|
149
|
+
text = mimeValues
|
|
150
|
+
.map((v) => (HTML_MIMETYPES.has(v.mimetype) ? stripHtml(v.data) : v.data))
|
|
151
|
+
.join(", ");
|
|
152
|
+
} else {
|
|
153
|
+
text = stringifyUnknownValue({ value: displayedValue });
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return { text, html };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Get the raw (unformatted) value for a row/column from the table,
|
|
161
|
+
* or undefined if raw data is not available.
|
|
162
|
+
*/
|
|
163
|
+
export function getRawValue<TData>(
|
|
164
|
+
table: Table<TData>,
|
|
165
|
+
rowIndex: number,
|
|
166
|
+
columnId: string,
|
|
167
|
+
): unknown {
|
|
168
|
+
const rawData = table.options.meta?.rawData;
|
|
169
|
+
if (rawData) {
|
|
170
|
+
const rawRow = rawData[rowIndex];
|
|
171
|
+
if (isRecord(rawRow)) {
|
|
172
|
+
return rawRow[columnId];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
@@ -5,9 +5,9 @@ import { beforeAll, describe, expect, it } from "vitest";
|
|
|
5
5
|
import { SetupMocks } from "@/__mocks__/common";
|
|
6
6
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
7
7
|
import { MockRequestClient } from "@/__mocks__/requests";
|
|
8
|
+
import { cellId } from "@/__tests__/branded";
|
|
8
9
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
9
10
|
import { notebookAtom } from "@/core/cells/cells";
|
|
10
|
-
import type { CellId } from "@/core/cells/ids";
|
|
11
11
|
import { createCellRuntimeState } from "@/core/cells/types";
|
|
12
12
|
import type { UserConfig } from "@/core/config/config-schema";
|
|
13
13
|
import type { OutputMessage } from "@/core/kernel/messages";
|
|
@@ -39,7 +39,7 @@ describe("Cell data attributes", () => {
|
|
|
39
39
|
"present",
|
|
40
40
|
])("should render cell with data-cell-id and data-cell-name in %s mode", (mode) => {
|
|
41
41
|
const { store, wrapper } = createTestWrapper();
|
|
42
|
-
const
|
|
42
|
+
const cid = cellId("test");
|
|
43
43
|
const cellName = "test_cell";
|
|
44
44
|
|
|
45
45
|
const userConfig: UserConfig = {
|
|
@@ -83,7 +83,7 @@ describe("Cell data attributes", () => {
|
|
|
83
83
|
|
|
84
84
|
const notebook = MockNotebook.notebookState({
|
|
85
85
|
cellData: {
|
|
86
|
-
[
|
|
86
|
+
[cid]: {
|
|
87
87
|
code: "",
|
|
88
88
|
name: cellName,
|
|
89
89
|
edited: false,
|
|
@@ -97,7 +97,7 @@ describe("Cell data attributes", () => {
|
|
|
97
97
|
},
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
notebook.cellRuntime[
|
|
100
|
+
notebook.cellRuntime[cid] = createCellRuntimeState({
|
|
101
101
|
status: "idle",
|
|
102
102
|
output: null,
|
|
103
103
|
consoleOutputs: [],
|
|
@@ -117,7 +117,7 @@ describe("Cell data attributes", () => {
|
|
|
117
117
|
const { container } = render(
|
|
118
118
|
<TooltipProvider>
|
|
119
119
|
<Cell
|
|
120
|
-
cellId={
|
|
120
|
+
cellId={cid}
|
|
121
121
|
mode={mode as AppMode}
|
|
122
122
|
canDelete={true}
|
|
123
123
|
userConfig={userConfig}
|
|
@@ -131,7 +131,7 @@ describe("Cell data attributes", () => {
|
|
|
131
131
|
{ wrapper },
|
|
132
132
|
);
|
|
133
133
|
|
|
134
|
-
const cellElement = container.querySelector(`[data-cell-id="${
|
|
134
|
+
const cellElement = container.querySelector(`[data-cell-id="${cid}"]`);
|
|
135
135
|
expect(cellElement).toBeTruthy();
|
|
136
136
|
expect(cellElement?.getAttribute("data-cell-name")).toBe(cellName);
|
|
137
137
|
});
|
|
@@ -139,7 +139,7 @@ describe("Cell data attributes", () => {
|
|
|
139
139
|
|
|
140
140
|
describe("Output data attributes", () => {
|
|
141
141
|
it("should render output with data-cell-role", () => {
|
|
142
|
-
const
|
|
142
|
+
const cid = cellId("test");
|
|
143
143
|
const output: OutputMessage = {
|
|
144
144
|
channel: "output",
|
|
145
145
|
mimetype: "text/plain",
|
|
@@ -151,7 +151,7 @@ describe("Output data attributes", () => {
|
|
|
151
151
|
<TooltipProvider>
|
|
152
152
|
<OutputArea
|
|
153
153
|
output={output}
|
|
154
|
-
cellId={
|
|
154
|
+
cellId={cid}
|
|
155
155
|
stale={false}
|
|
156
156
|
loading={false}
|
|
157
157
|
allowExpand={true}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import { beforeEach, describe, expect, it, type Mock, vi } from "vitest";
|
|
3
|
+
import { variableName } from "@/__tests__/branded";
|
|
3
4
|
import { getCodes } from "@/core/codemirror/copilot/getCodes";
|
|
4
5
|
import { dataSourceConnectionsAtom } from "@/core/datasets/data-source-connections";
|
|
5
6
|
import { DUCKDB_ENGINE } from "@/core/datasets/engines";
|
|
@@ -7,7 +8,6 @@ import { datasetsAtom } from "@/core/datasets/state";
|
|
|
7
8
|
import type { DatasetsState } from "@/core/datasets/types";
|
|
8
9
|
import { store } from "@/core/state/jotai";
|
|
9
10
|
import { variablesAtom } from "@/core/variables/state";
|
|
10
|
-
import type { Variable, VariableName } from "@/core/variables/types";
|
|
11
11
|
import { codeToCells, getAICompletionBody } from "../completion-utils";
|
|
12
12
|
|
|
13
13
|
// Mock getCodes function
|
|
@@ -205,16 +205,16 @@ describe("getAICompletionBody", () => {
|
|
|
205
205
|
|
|
206
206
|
it("should return the correct completion body with mentioned variables", () => {
|
|
207
207
|
// Set up test data in the Jotai store
|
|
208
|
-
const testVariables
|
|
209
|
-
["var1"
|
|
210
|
-
name: "var1"
|
|
208
|
+
const testVariables = {
|
|
209
|
+
[variableName("var1")]: {
|
|
210
|
+
name: variableName("var1"),
|
|
211
211
|
value: "string value",
|
|
212
212
|
dataType: "string",
|
|
213
213
|
declaredBy: [],
|
|
214
214
|
usedBy: [],
|
|
215
215
|
},
|
|
216
|
-
["var2"
|
|
217
|
-
name: "var2"
|
|
216
|
+
[variableName("var2")]: {
|
|
217
|
+
name: variableName("var2"),
|
|
218
218
|
value: "42",
|
|
219
219
|
dataType: "number",
|
|
220
220
|
declaredBy: [],
|
|
@@ -253,9 +253,9 @@ describe("getAICompletionBody", () => {
|
|
|
253
253
|
];
|
|
254
254
|
store.set(datasetsAtom, { tables: testDatasets } as DatasetsState);
|
|
255
255
|
|
|
256
|
-
const testVariables
|
|
257
|
-
["var1"
|
|
258
|
-
name: "var1"
|
|
256
|
+
const testVariables = {
|
|
257
|
+
[variableName("var1")]: {
|
|
258
|
+
name: variableName("var1"),
|
|
259
259
|
value: "string value",
|
|
260
260
|
dataType: "string",
|
|
261
261
|
declaredBy: [],
|
|
@@ -285,9 +285,9 @@ describe("getAICompletionBody", () => {
|
|
|
285
285
|
|
|
286
286
|
it("should handle non-existent variables", () => {
|
|
287
287
|
// Set up test data in the Jotai store
|
|
288
|
-
const testVariables
|
|
289
|
-
["existingVar"
|
|
290
|
-
name: "existingVar"
|
|
288
|
+
const testVariables = {
|
|
289
|
+
[variableName("existingVar")]: {
|
|
290
|
+
name: variableName("existingVar"),
|
|
291
291
|
value: "string value",
|
|
292
292
|
dataType: "string",
|
|
293
293
|
declaredBy: [],
|
|
@@ -322,9 +322,9 @@ describe("getAICompletionBody", () => {
|
|
|
322
322
|
];
|
|
323
323
|
store.set(datasetsAtom, { tables: testDatasets } as DatasetsState);
|
|
324
324
|
|
|
325
|
-
const testVariables
|
|
326
|
-
["conflict"
|
|
327
|
-
name: "conflict"
|
|
325
|
+
const testVariables = {
|
|
326
|
+
[variableName("conflict")]: {
|
|
327
|
+
name: variableName("conflict"),
|
|
328
328
|
value: "string value",
|
|
329
329
|
dataType: "string",
|
|
330
330
|
declaredBy: [],
|
package/src/components/editor/connections/storage/__tests__/__snapshots__/as-code.test.ts.snap
CHANGED
|
@@ -85,7 +85,7 @@ store = GCSStore("my-bucket")"
|
|
|
85
85
|
exports[`generateStorageCode > Google Drive > with browser auth (no credentials) 1`] = `
|
|
86
86
|
"from gdrive_fsspec import GoogleDriveFileSystem
|
|
87
87
|
|
|
88
|
-
fs = GoogleDriveFileSystem(token="browser")"
|
|
88
|
+
fs = GoogleDriveFileSystem(token="browser", use_listings_cache=False)"
|
|
89
89
|
`;
|
|
90
90
|
|
|
91
91
|
exports[`generateStorageCode > Google Drive > with service account credentials 1`] = `
|
|
@@ -93,7 +93,7 @@ exports[`generateStorageCode > Google Drive > with service account credentials 1
|
|
|
93
93
|
import json
|
|
94
94
|
|
|
95
95
|
_creds = json.loads("""{"type": "service_account", "client_email": "test@test.iam.gserviceaccount.com"}""")
|
|
96
|
-
fs = GoogleDriveFileSystem(creds=_creds, token="service_account")"
|
|
96
|
+
fs = GoogleDriveFileSystem(creds=_creds, token="service_account", use_listings_cache=False)"
|
|
97
97
|
`;
|
|
98
98
|
|
|
99
99
|
exports[`generateStorageCode > S3 > basic connection with all fields 1`] = `
|
|
@@ -173,13 +173,13 @@ function generateGDriveCode(
|
|
|
173
173
|
);
|
|
174
174
|
const code = dedent(`
|
|
175
175
|
_creds = json.loads("""${connection.credentials_json?.startsWith("ENV:") ? `{${creds}}` : connection.credentials_json}""")
|
|
176
|
-
fs = GoogleDriveFileSystem(creds=_creds, token="service_account")
|
|
176
|
+
fs = GoogleDriveFileSystem(creds=_creds, token="service_account", use_listings_cache=False)
|
|
177
177
|
`);
|
|
178
178
|
return { imports, code };
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
const code = dedent(`
|
|
182
|
-
fs = GoogleDriveFileSystem(token="browser")
|
|
182
|
+
fs = GoogleDriveFileSystem(token="browser", use_listings_cache=False)
|
|
183
183
|
`);
|
|
184
184
|
return { imports, code };
|
|
185
185
|
}
|
|
@@ -62,9 +62,11 @@ import type { FileInfo } from "@/core/network/types";
|
|
|
62
62
|
import { isWasm } from "@/core/wasm/utils";
|
|
63
63
|
import { useAsyncData } from "@/hooks/useAsyncData";
|
|
64
64
|
import { ErrorBanner } from "@/plugins/impl/common/error-banner";
|
|
65
|
+
import { deserializeBlob } from "@/utils/blob";
|
|
65
66
|
import { cn } from "@/utils/cn";
|
|
66
67
|
import { copyToClipboard } from "@/utils/copy";
|
|
67
68
|
import { downloadBlob } from "@/utils/download";
|
|
69
|
+
import { type Base64String, base64ToDataURL } from "@/utils/json/base64";
|
|
68
70
|
import { openNotebook } from "@/utils/links";
|
|
69
71
|
import type { FilePath } from "@/utils/paths";
|
|
70
72
|
import { fileSplit } from "@/utils/pathUtils";
|
|
@@ -650,8 +652,20 @@ const Node = ({ node, style, dragHandle }: NodeRendererProps<FileInfo>) => {
|
|
|
650
652
|
<DropdownMenuItem
|
|
651
653
|
onSelect={async () => {
|
|
652
654
|
const details = await sendFileDetails({ path: node.data.path });
|
|
653
|
-
|
|
654
|
-
|
|
655
|
+
if (details.isBase64 && details.contents) {
|
|
656
|
+
const blob = deserializeBlob(
|
|
657
|
+
base64ToDataURL(
|
|
658
|
+
details.contents as Base64String,
|
|
659
|
+
details.mimeType || "application/octet-stream",
|
|
660
|
+
),
|
|
661
|
+
);
|
|
662
|
+
downloadBlob(blob, node.data.name);
|
|
663
|
+
} else {
|
|
664
|
+
downloadBlob(
|
|
665
|
+
new Blob([details.contents || ""]),
|
|
666
|
+
node.data.name,
|
|
667
|
+
);
|
|
668
|
+
}
|
|
655
669
|
}}
|
|
656
670
|
>
|
|
657
671
|
<DownloadIcon className={ic} />
|
|
@@ -21,6 +21,7 @@ import { filenameAtom } from "@/core/saving/file-state";
|
|
|
21
21
|
import { isWasm } from "@/core/wasm/utils";
|
|
22
22
|
import { useAsyncData } from "@/hooks/useAsyncData";
|
|
23
23
|
import { ErrorBanner } from "@/plugins/impl/common/error-banner";
|
|
24
|
+
import { deserializeBlob } from "@/utils/blob";
|
|
24
25
|
import { copyToClipboard } from "@/utils/copy";
|
|
25
26
|
import { downloadBlob, downloadByURL } from "@/utils/download";
|
|
26
27
|
import { type Base64String, base64ToDataURL } from "@/utils/json/base64";
|
|
@@ -121,9 +122,22 @@ export const FileViewer: React.FC<Props> = ({ file, onOpenNotebook }) => {
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
const handleDownload = () => {
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
if (data.isBase64 && data.contents) {
|
|
126
|
+
if (isMediaMime(mimeType)) {
|
|
127
|
+
const dataURL = base64ToDataURL(
|
|
128
|
+
data.contents as Base64String,
|
|
129
|
+
mimeType,
|
|
130
|
+
);
|
|
131
|
+
downloadByURL(dataURL, data.file.name);
|
|
132
|
+
} else {
|
|
133
|
+
const blob = deserializeBlob(
|
|
134
|
+
base64ToDataURL(
|
|
135
|
+
data.contents as Base64String,
|
|
136
|
+
data.mimeType || "application/octet-stream",
|
|
137
|
+
),
|
|
138
|
+
);
|
|
139
|
+
downloadBlob(blob, data.file.name);
|
|
140
|
+
}
|
|
127
141
|
return;
|
|
128
142
|
}
|
|
129
143
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { act, renderHook } from "@testing-library/react";
|
|
5
5
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
6
|
import { asMock, MockModules, Mocks, SetupMocks } from "@/__mocks__/common";
|
|
7
|
+
import { cellId } from "@/__tests__/branded";
|
|
7
8
|
import type { CellActions, NotebookState } from "@/core/cells/cells";
|
|
8
|
-
import type { CellId } from "@/core/cells/ids";
|
|
9
9
|
import { useCellClipboard } from "../clipboard";
|
|
10
10
|
|
|
11
11
|
// Mock dependencies
|
|
@@ -179,7 +179,7 @@ describe("useCellClipboard", () => {
|
|
|
179
179
|
});
|
|
180
180
|
|
|
181
181
|
it("should filter out non-existent cells", async () => {
|
|
182
|
-
const nonExistentCellId = "non-existent"
|
|
182
|
+
const nonExistentCellId = cellId("non-existent");
|
|
183
183
|
|
|
184
184
|
const { result } = renderHook(() => useCellClipboard());
|
|
185
185
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
2
3
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
3
|
-
import
|
|
4
|
+
import { cellId } from "@/__tests__/branded";
|
|
4
5
|
import { MultiColumn } from "@/utils/id-tree";
|
|
5
6
|
import type { CellSelectionState } from "../selection";
|
|
6
7
|
import { exportedForTesting } from "../selection";
|
|
@@ -8,11 +9,11 @@ import { exportedForTesting } from "../selection";
|
|
|
8
9
|
const { initialState, reducer, createActions } = exportedForTesting;
|
|
9
10
|
|
|
10
11
|
const CellIds = {
|
|
11
|
-
a: "a"
|
|
12
|
-
b: "b"
|
|
13
|
-
c: "c"
|
|
14
|
-
d: "d"
|
|
15
|
-
e: "e"
|
|
12
|
+
a: cellId("a"),
|
|
13
|
+
b: cellId("b"),
|
|
14
|
+
c: cellId("c"),
|
|
15
|
+
d: cellId("d"),
|
|
16
|
+
e: cellId("e"),
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
describe("cell selection reducer", () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { cellId } from "@/__tests__/branded";
|
|
4
5
|
import { type CellId, HTMLCellId } from "@/core/cells/ids";
|
|
5
6
|
|
|
6
7
|
const mockScrollCellIntoView = vi.fn();
|
|
@@ -14,12 +15,12 @@ vi.mock("../focus-utils", () => ({
|
|
|
14
15
|
type TemporarilyShownCodeState = Set<CellId>;
|
|
15
16
|
|
|
16
17
|
describe("temporarilyShownCodeActions", () => {
|
|
17
|
-
const
|
|
18
|
+
const cid = cellId("cell-1");
|
|
18
19
|
let cellElement: HTMLElement;
|
|
19
20
|
|
|
20
21
|
beforeEach(() => {
|
|
21
22
|
cellElement = document.createElement("div");
|
|
22
|
-
cellElement.id = HTMLCellId.create(
|
|
23
|
+
cellElement.id = HTMLCellId.create(cid);
|
|
23
24
|
document.body.append(cellElement);
|
|
24
25
|
cellElement.focus();
|
|
25
26
|
|
|
@@ -37,17 +38,17 @@ describe("temporarilyShownCodeActions", () => {
|
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
it("should scroll cell into view when removing cell causes layout shift", () => {
|
|
40
|
-
const state = new Set<CellId>([
|
|
41
|
-
removeCell(state,
|
|
41
|
+
const state = new Set<CellId>([cid]);
|
|
42
|
+
removeCell(state, cid);
|
|
42
43
|
|
|
43
|
-
expect(mockScrollCellIntoView).toHaveBeenCalledWith(
|
|
44
|
+
expect(mockScrollCellIntoView).toHaveBeenCalledWith(cid);
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
it("should not scroll when focused cell is not found", () => {
|
|
47
48
|
vi.spyOn(HTMLCellId, "findElementThroughShadowDOMs").mockReturnValue(null);
|
|
48
49
|
|
|
49
|
-
const state = new Set<CellId>([
|
|
50
|
-
removeCell(state,
|
|
50
|
+
const state = new Set<CellId>([cid]);
|
|
51
|
+
removeCell(state, cid);
|
|
51
52
|
|
|
52
53
|
expect(mockScrollCellIntoView).not.toHaveBeenCalled();
|
|
53
54
|
});
|
|
@@ -316,7 +316,7 @@ export const MarimoErrorOutput = ({
|
|
|
316
316
|
<ul className="list-disc">
|
|
317
317
|
{error.cells.map((cid, cidIdx) => (
|
|
318
318
|
<li className={liStyle} key={`cell-${cidIdx}`}>
|
|
319
|
-
<CellLinkError cellId={cid
|
|
319
|
+
<CellLinkError cellId={cid} />
|
|
320
320
|
</li>
|
|
321
321
|
))}
|
|
322
322
|
</ul>
|
|
@@ -491,7 +491,7 @@ export const MarimoErrorOutput = ({
|
|
|
491
491
|
) : (
|
|
492
492
|
<div>
|
|
493
493
|
{processTextForUrls(error.msg, `exception-${idx}`)}
|
|
494
|
-
<CellLinkError cellId={error.raising_cell
|
|
494
|
+
<CellLinkError cellId={error.raising_cell} />
|
|
495
495
|
</div>
|
|
496
496
|
)}
|
|
497
497
|
</li>
|
|
@@ -518,7 +518,7 @@ export const MarimoErrorOutput = ({
|
|
|
518
518
|
) : (
|
|
519
519
|
<div>
|
|
520
520
|
{error.msg}
|
|
521
|
-
<CellLinkError cellId={error.blamed_cell
|
|
521
|
+
<CellLinkError cellId={error.blamed_cell} />
|
|
522
522
|
</div>
|
|
523
523
|
)}
|
|
524
524
|
</li>
|
|
@@ -554,13 +554,13 @@ export const MarimoErrorOutput = ({
|
|
|
554
554
|
{error.msg}
|
|
555
555
|
{error.blamed_cell == null ? (
|
|
556
556
|
<span>
|
|
557
|
-
(<CellLinkError cellId={error.raising_cell
|
|
557
|
+
(<CellLinkError cellId={error.raising_cell} />)
|
|
558
558
|
</span>
|
|
559
559
|
) : (
|
|
560
560
|
<span>
|
|
561
|
-
(<CellLinkError cellId={error.raising_cell
|
|
561
|
+
(<CellLinkError cellId={error.raising_cell} />
|
|
562
562
|
blames
|
|
563
|
-
<CellLinkError cellId={error.blamed_cell
|
|
563
|
+
<CellLinkError cellId={error.blamed_cell} />)
|
|
564
564
|
</span>
|
|
565
565
|
)}
|
|
566
566
|
</div>
|
|
@@ -578,7 +578,7 @@ export const MarimoErrorOutput = ({
|
|
|
578
578
|
{ancestorStoppedErrors.map((error, idx) => (
|
|
579
579
|
<div key={`ancestor-stopped-${idx}`}>
|
|
580
580
|
{error.msg}
|
|
581
|
-
<CellLinkError cellId={error.raising_cell
|
|
581
|
+
<CellLinkError cellId={error.raising_cell} />
|
|
582
582
|
</div>
|
|
583
583
|
))}
|
|
584
584
|
{cellId && (
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { render } from "@testing-library/react";
|
|
4
4
|
import { beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
|
5
5
|
import { Tracebacks } from "@/__mocks__/tracebacks";
|
|
6
|
+
import { cellId } from "@/__tests__/branded";
|
|
6
7
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
7
|
-
import type { CellId } from "@/core/cells/ids";
|
|
8
8
|
import { initialModeAtom } from "@/core/mode";
|
|
9
9
|
import { store } from "@/core/state/jotai";
|
|
10
10
|
import { renderHTML } from "@/plugins/core/RenderHTML";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
replaceTracebackPrefix,
|
|
15
15
|
} from "../MarimoTracebackOutput";
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const cid = cellId("1");
|
|
18
18
|
|
|
19
19
|
describe("traceback component", () => {
|
|
20
20
|
beforeEach(() => {
|
|
@@ -25,7 +25,7 @@ describe("traceback component", () => {
|
|
|
25
25
|
test("extracts cell-link", () => {
|
|
26
26
|
const traceback = (
|
|
27
27
|
<TooltipProvider>
|
|
28
|
-
<MarimoTracebackOutput traceback={Tracebacks.raw} cellId={
|
|
28
|
+
<MarimoTracebackOutput traceback={Tracebacks.raw} cellId={cid} />
|
|
29
29
|
</TooltipProvider>
|
|
30
30
|
);
|
|
31
31
|
const { unmount, getAllByRole } = render(traceback);
|
|
@@ -45,7 +45,7 @@ describe("traceback component", () => {
|
|
|
45
45
|
test("renames File to Cell for relevant lines", () => {
|
|
46
46
|
const traceback = (
|
|
47
47
|
<TooltipProvider>
|
|
48
|
-
<MarimoTracebackOutput traceback={Tracebacks.raw} cellId={
|
|
48
|
+
<MarimoTracebackOutput traceback={Tracebacks.raw} cellId={cid} />
|
|
49
49
|
</TooltipProvider>
|
|
50
50
|
);
|
|
51
51
|
const { unmount, container } = render(traceback);
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
5
|
import { SetupMocks } from "@/__mocks__/common";
|
|
6
|
+
import { cellId } from "@/__tests__/branded";
|
|
6
7
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
7
|
-
import type { CellId } from "@/core/cells/ids";
|
|
8
8
|
import type { WithResponse } from "@/core/cells/types";
|
|
9
9
|
import type { OutputMessage } from "@/core/kernel/messages";
|
|
10
10
|
import { CONSOLE_CLEAR_DEBOUNCE_MS, ConsoleOutput } from "../ConsoleOutput";
|
|
@@ -24,7 +24,7 @@ describe("ConsoleOutput integration", () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
const defaultProps = {
|
|
27
|
-
cellId: "cell-1"
|
|
27
|
+
cellId: cellId("cell-1"),
|
|
28
28
|
cellName: "test_cell",
|
|
29
29
|
consoleOutputs: [] as WithResponse<OutputMessage>[],
|
|
30
30
|
stale: false,
|
|
@@ -55,7 +55,7 @@ describe("ConsoleOutput integration", () => {
|
|
|
55
55
|
|
|
56
56
|
describe("ConsoleOutput pdb history", () => {
|
|
57
57
|
const defaultProps = {
|
|
58
|
-
cellId: "cell-1"
|
|
58
|
+
cellId: cellId("cell-1"),
|
|
59
59
|
cellName: "test_cell",
|
|
60
60
|
consoleOutputs: [] as WithResponse<OutputMessage>[],
|
|
61
61
|
stale: false,
|
|
@@ -215,7 +215,7 @@ describe("ConsoleOutput debounced clearing", () => {
|
|
|
215
215
|
});
|
|
216
216
|
|
|
217
217
|
const defaultProps = {
|
|
218
|
-
cellId: "cell-1"
|
|
218
|
+
cellId: cellId("cell-1"),
|
|
219
219
|
cellName: "test_cell",
|
|
220
220
|
consoleOutputs: [] as WithResponse<OutputMessage>[],
|
|
221
221
|
stale: false,
|
|
@@ -91,7 +91,7 @@ function focusCellByName(cellName: string) {
|
|
|
91
91
|
|
|
92
92
|
// Look for an editor to focus
|
|
93
93
|
const { cellHandles } = getNotebook();
|
|
94
|
-
const cellId = cellElement
|
|
94
|
+
const cellId = extractCellIdFromDomElement(cellElement);
|
|
95
95
|
|
|
96
96
|
if (!cellId) {
|
|
97
97
|
Logger.error(`Missing cellId for cell with name ${cellName}`);
|
|
@@ -111,3 +111,10 @@ function focusCellByName(cellName: string) {
|
|
|
111
111
|
focusFirstEditor();
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
|
|
115
|
+
function extractCellIdFromDomElement(
|
|
116
|
+
cellElement: HTMLElement,
|
|
117
|
+
): CellId | undefined {
|
|
118
|
+
const cellIdStr = cellElement.dataset.cellId ?? undefined;
|
|
119
|
+
return cellIdStr as CellId | undefined;
|
|
120
|
+
}
|