@marimo-team/islands 0.23.10-dev4 → 0.23.10-dev42
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-CyV83R2m.js → ConnectedDataExplorerComponent-Z3RP7Vmm.js} +31 -31
- package/dist/{ErrorBoundary-rULOrC_p.js → ErrorBoundary-DpbaKVv7.js} +1 -1
- package/dist/{any-language-editor-DfdpyDv_.js → any-language-editor-CAgFD4Kd.js} +20 -20
- package/dist/assets/__vite-browser-external-eshhtsgZ.js +1 -0
- package/dist/assets/worker-CC0Oul9k.js +73 -0
- package/dist/{chat-ui-TL2w0gQI.js → chat-ui-CqtCMdc-.js} +76 -76
- package/dist/{check-DTbrK0zt.js → check-BCaJeT-J.js} +1 -1
- package/dist/{code-visibility-Dly0oW20.js → code-visibility-BIrMe3pI.js} +2166 -1292
- package/dist/{copy-BuQpJEzp.js → copy-UqRYxiOg.js} +33 -33
- package/dist/dist-7QfXoMdB.js +5 -0
- package/dist/{dist-DgnE8F-r.js → dist-A2846XWO.js} +1 -1
- package/dist/dist-BEXXyZig.js +5 -0
- package/dist/{dist-B3pZ0Ab6.js → dist-BR_gyG9L.js} +3 -3
- package/dist/{dist-CcXxepx6.js → dist-BSAt6RhH.js} +27 -27
- package/dist/{dist-Bde4a2kU.js → dist-BY018Paw.js} +8 -8
- package/dist/dist-BYj57OV4.js +5 -0
- package/dist/{dist-CUCNs1ja.js → dist-BaoDKvdy.js} +2 -2
- package/dist/{dist-Cy1WxgBD.js → dist-Bf7SHuNp.js} +5 -5
- package/dist/{dist-Bz_sYWbr.js → dist-Bk75fBZA.js} +2 -2
- package/dist/dist-BlSvQzNr.js +5 -0
- package/dist/{dist-C5VC_yzu.js → dist-BzEzfugY.js} +1 -1
- package/dist/dist-CCBlxAgS.js +8 -0
- package/dist/dist-CIDTVIUf.js +5 -0
- package/dist/{dist-CLUtPrdy.js → dist-CIYBwstr.js} +1 -1
- package/dist/{dist-BotSqB48.js → dist-C_Y3oV3C.js} +12 -12
- package/dist/{dist-BTfv03uy.js → dist-CcWX6tmx.js} +2 -2
- package/dist/{dist-BhM8gdSO.js → dist-CoXAujgg.js} +4 -4
- package/dist/{dist-4j4c7bjm.js → dist-CpxNdDkw.js} +3 -3
- package/dist/dist-CqQyhAM8.js +8 -0
- package/dist/dist-CwRu2Xzh.js +5 -0
- package/dist/{dist-BcuoonNH.js → dist-CxJDU6Bh.js} +9 -9
- package/dist/{dist-DxvORzUR.js → dist-D-W5ny5a.js} +8 -8
- package/dist/dist-D8CDTVgf.js +6 -0
- package/dist/dist-D8DNB0nO.js +8 -0
- package/dist/dist-DL6N_q-A.js +5 -0
- package/dist/{dist-BbbIBDiQ.js → dist-DMjWuVs8.js} +1 -1
- package/dist/dist-DOFbNV_b.js +8 -0
- package/dist/dist-DPrYzMY0.js +6 -0
- package/dist/{dist-h2c8sZvT.js → dist-DZORgqKY.js} +1 -1
- package/dist/{dist-B3P2fFpz.js → dist-DZo4nSS0.js} +14 -14
- package/dist/{dist-D4CewLk6.js → dist-Dax--nl9.js} +1 -1
- package/dist/{dist-DRfcqpxJ.js → dist-DgGbNavJ.js} +2 -2
- package/dist/{dist-C1BYNeCR.js → dist-Dk6PV_d3.js} +10 -10
- package/dist/{dist-fQ0ViXGs.js → dist-Dv_Y15yk.js} +107 -107
- package/dist/{dist-Bfwsv11D.js → dist-DyyjKEYf.js} +2 -2
- package/dist/{dist-p2qyWijU.js → dist-GZXUmt0b.js} +2 -2
- package/dist/{dist-CLJWPTX2.js → dist-LTU8Hdvn.js} +3 -3
- package/dist/{dist-DqAWR3CS.js → dist-M9Vag9Y0.js} +20 -20
- package/dist/{dist-DNdhYsgW.js → dist-U4F-tbMs.js} +79 -62
- package/dist/{dist-RqXTaiir.js → dist-abid3KgM.js} +11 -11
- package/dist/dist-cdmMjgsn.js +5 -0
- package/dist/dist-hT4QzYX-.js +1247 -0
- package/dist/{dist-luvabDEB.js → dist-t9Kf7xqC.js} +2 -2
- package/dist/{error-banner-5bz0L9hS.js → error-banner-CJXYJ6Sb.js} +11 -6
- package/dist/esm-BaH2eg5-.js +1171 -0
- package/dist/{esm-Duie8iU-.js → esm-ga2Bf3O2.js} +43 -43
- package/dist/{extends-BgdxCfYu.js → extends-D_hDsj6R.js} +4 -4
- package/dist/files/wasm-intro.py +11 -8
- package/dist/{formats-DHxc-FdY.js → formats-C4wO47tk.js} +1 -1
- package/dist/{glide-data-editor-BOmK9ETQ.js → glide-data-editor-BPkCPs7L.js} +255 -255
- package/dist/{html-to-image-DS-GYb0Y.js → html-to-image-BviMxrkm.js} +2316 -2273
- package/dist/{input-_2sjvfne.js → input-OdWHkobi.js} +263 -245
- package/dist/{label-LWtdw5i8.js → label-CC4ytI1X.js} +1 -1
- package/dist/main.js +7630 -7558
- package/dist/{mermaid-lXOw5Py9.js → mermaid-BotvIKg9.js} +4 -4
- package/dist/{process-output-BdlB3Vhy.js → process-output-Bq3VMBsg.js} +3 -3
- package/dist/{reveal-component-Dj7ybE5_.js → reveal-component-cGpBwp6O.js} +697 -619
- package/dist/{spec-B96zNUEA.js → spec-X7FwLJni.js} +4 -4
- package/dist/{strings-Bu3vlb6W.js → strings-J57tzLr3.js} +47 -46
- package/dist/style.css +1 -1
- package/dist/{toDate-x-WRDCH7.js → toDate-d8RCRrRd.js} +2 -2
- package/dist/{tooltip-C5FYOpQc.js → tooltip-DpcyNkQ2.js} +2 -2
- package/dist/{types-CVvp1fKr.js → types-ChtMFmZ2.js} +1 -1
- package/dist/{useAsyncData-iRgKDT5s.js → useAsyncData-PonK__yh.js} +1 -1
- package/dist/{useDateFormatter-BA4FCquG.js → useDateFormatter-QB-3MpYr.js} +2 -2
- package/dist/{useDeepCompareMemoize-CkQ57VS2.js → useDeepCompareMemoize-D3NGWke6.js} +1 -1
- package/dist/{useLifecycle-BBO9PIph.js → useLifecycle-00mO3OSS.js} +2 -2
- package/dist/{useTheme-DHIrRQOe.js → useTheme-DEhDzATN.js} +1 -1
- package/dist/{vega-component-Dq-SH463.js → vega-component-DGPUhbDs.js} +8 -8
- package/dist/{zod-CoBiJ5v4.js → zod-aLSua2NL.js} +24 -23
- package/package.json +3 -3
- package/src/components/data-table/TableBottomBar.tsx +1 -15
- package/src/components/data-table/TableTopBar.tsx +8 -13
- package/src/components/data-table/__tests__/TableBottomBar.test.tsx +6 -12
- package/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx +227 -0
- package/src/components/data-table/__tests__/data-table.test.tsx +154 -12
- package/src/components/data-table/column-visibility-dropdown.tsx +204 -0
- package/src/components/data-table/data-table.tsx +1 -1
- package/src/components/data-table/filter-by-values-picker.tsx +39 -17
- package/src/components/data-table/filter-pills.tsx +1 -1
- package/src/components/data-table/hover-tooltip/__tests__/content.test.ts +60 -0
- package/src/components/data-table/hover-tooltip/content.ts +44 -0
- package/src/components/data-table/hover-tooltip/hover-tooltip.tsx +55 -0
- package/src/components/data-table/hover-tooltip/use-table-hover-tooltip.ts +159 -0
- package/src/components/data-table/renderers.tsx +27 -43
- package/src/components/datasources/__tests__/filter-empty.test.ts +183 -0
- package/src/components/datasources/datasources.tsx +92 -3
- package/src/components/editor/cell/code/language-toggle.tsx +7 -1
- package/src/components/editor/chrome/wrapper/app-chrome.tsx +97 -52
- package/src/components/editor/chrome/wrapper/lazy-panels.ts +91 -0
- package/src/components/editor/chrome/wrapper/sidebar.tsx +2 -0
- package/src/components/editor/documentation.css +35 -0
- package/src/components/editor/file-tree/file-explorer.tsx +8 -18
- package/src/components/editor/file-tree/tree-actions.tsx +46 -1
- package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +20 -0
- package/src/components/editor/renderers/slides-layout/types.ts +1 -0
- package/src/components/slides/__tests__/minimap-actions.test.tsx +166 -0
- package/src/components/slides/__tests__/reveal-component.test.ts +425 -0
- package/src/components/slides/minimap.tsx +127 -10
- package/src/components/slides/reveal-component.tsx +287 -61
- package/src/components/slides/slide-cell-view.tsx +26 -2
- package/src/components/slides/slide-form.tsx +26 -4
- package/src/components/storage/__tests__/storage-inspector.test.ts +53 -0
- package/src/components/storage/storage-inspector.tsx +68 -48
- package/src/components/ui/__tests__/use-toast.test.ts +75 -0
- package/src/components/ui/combobox.tsx +51 -32
- package/src/components/ui/number-field.tsx +5 -1
- package/src/components/ui/reorderable-list.tsx +13 -0
- package/src/components/ui/select-core/__tests__/use-select-list.test.ts +294 -0
- package/src/components/ui/select-core/__tests__/utils.test.ts +222 -0
- package/src/components/ui/select-core/index.ts +16 -0
- package/src/components/ui/select-core/option-row.tsx +33 -0
- package/src/components/ui/select-core/render-slot.ts +20 -0
- package/src/components/ui/select-core/select-list.tsx +248 -0
- package/src/components/ui/select-core/types.ts +44 -0
- package/src/components/ui/select-core/use-select-list.ts +347 -0
- package/src/components/ui/select-core/utils.ts +121 -0
- package/src/components/ui/use-toast.ts +33 -13
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -28
- package/src/core/cells/__tests__/cell.test.ts +29 -2
- package/src/core/cells/cell.ts +5 -1
- package/src/core/codemirror/language/languages/python.ts +2 -0
- package/src/core/codemirror/language/languages/sql/utils.ts +3 -1
- package/src/core/codemirror/lsp/__tests__/markdown-renderer.test.ts +41 -0
- package/src/core/codemirror/lsp/markdown-renderer.ts +59 -0
- package/src/core/datasets/data-source-connections.ts +2 -0
- package/src/core/network/__tests__/requests-static.test.ts +30 -0
- package/src/core/network/requests-static.ts +14 -10
- package/src/core/wasm/worker/bootstrap.ts +12 -4
- package/src/plugins/core/__test__/registerReactComponent.test.ts +96 -0
- package/src/plugins/core/registerReactComponent.tsx +42 -10
- package/src/plugins/impl/MultiselectPlugin.tsx +19 -142
- package/src/plugins/impl/SearchableSelect.tsx +16 -97
- package/src/plugins/impl/SliderPlugin.tsx +132 -18
- package/src/plugins/impl/__tests__/DropdownPlugin.test.tsx +5 -2
- package/src/plugins/impl/__tests__/MultiSelectPlugin.test.ts +1 -1
- package/src/plugins/impl/__tests__/SliderPlugin.test.tsx +278 -8
- package/src/plugins/layout/DownloadPlugin.tsx +1 -1
- package/src/utils/__tests__/numbers.test.ts +20 -0
- package/src/utils/errors.ts +9 -0
- package/src/utils/lazy.ts +6 -1
- package/src/utils/numbers.ts +27 -0
- package/dist/assets/__vite-browser-external-Ci2ZQfXU.js +0 -1
- package/dist/assets/worker-ip3AI_sN.js +0 -73
- package/dist/dist-0Fif7jnk.js +0 -5
- package/dist/dist-B5h_9sHB.js +0 -6
- package/dist/dist-B9M6R5ye.js +0 -5
- package/dist/dist-BCt3tnck.js +0 -8
- package/dist/dist-BUIJwMwn.js +0 -8
- package/dist/dist-BpquMd3k.js +0 -5
- package/dist/dist-BzJsqYfz.js +0 -5
- package/dist/dist-CA5ELXAf.js +0 -6
- package/dist/dist-CLBRs6Uv.js +0 -5
- package/dist/dist-CStVCMbq.js +0 -5
- package/dist/dist-CZRIEY3Y.js +0 -8
- package/dist/dist-CuUHbFD0.js +0 -5
- package/dist/dist-DV7Iabxb.js +0 -8
- package/dist/dist-DhHh0jLg.js +0 -1247
- package/dist/dist-DuEeHMvL.js +0 -5
- package/dist/esm-BfhQmZjp.js +0 -1171
- package/src/plugins/impl/multiselectFilterFn.tsx +0 -22
- /package/src/components/{data-table → ui}/value-chips.tsx +0 -0
|
@@ -3,6 +3,18 @@ import { toast } from "@/components/ui/use-toast";
|
|
|
3
3
|
import { Logger } from "@/utils/Logger";
|
|
4
4
|
import type { EditRequests, RunRequests } from "./types";
|
|
5
5
|
|
|
6
|
+
const STATIC_NOTEBOOK_TOAST_ID = "static-notebook";
|
|
7
|
+
|
|
8
|
+
function showStaticNotebookToast() {
|
|
9
|
+
toast({
|
|
10
|
+
id: STATIC_NOTEBOOK_TOAST_ID,
|
|
11
|
+
once: true,
|
|
12
|
+
title: "Static notebook",
|
|
13
|
+
description:
|
|
14
|
+
"This notebook is not connected to a kernel. Any interactive elements will not work.",
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
export function createStaticRequests(): EditRequests & RunRequests {
|
|
7
19
|
const throwNotInEditMode = () => {
|
|
8
20
|
throw new Error("Unreachable. Expected to be in run mode");
|
|
@@ -10,11 +22,7 @@ export function createStaticRequests(): EditRequests & RunRequests {
|
|
|
10
22
|
|
|
11
23
|
return {
|
|
12
24
|
sendComponentValues: async () => {
|
|
13
|
-
|
|
14
|
-
title: "Static notebook",
|
|
15
|
-
description:
|
|
16
|
-
"This notebook is not connected to a kernel. Any interactive elements will not work.",
|
|
17
|
-
});
|
|
25
|
+
showStaticNotebookToast();
|
|
18
26
|
Logger.log("Updating UI elements is not supported in static mode");
|
|
19
27
|
return null;
|
|
20
28
|
},
|
|
@@ -27,11 +35,7 @@ export function createStaticRequests(): EditRequests & RunRequests {
|
|
|
27
35
|
return null;
|
|
28
36
|
},
|
|
29
37
|
sendFunctionRequest: async () => {
|
|
30
|
-
|
|
31
|
-
title: "Static notebook",
|
|
32
|
-
description:
|
|
33
|
-
"This notebook is not connected to a kernel. Any interactive elements will not work.",
|
|
34
|
-
});
|
|
38
|
+
showStaticNotebookToast();
|
|
35
39
|
Logger.log("Function requests are not supported in static mode");
|
|
36
40
|
return null;
|
|
37
41
|
},
|
|
@@ -55,6 +55,10 @@ export class DefaultWasmController implements WasmController {
|
|
|
55
55
|
// Load pyodide and packages
|
|
56
56
|
const span = t.startSpan("loadPyodide");
|
|
57
57
|
try {
|
|
58
|
+
// Without this, this fails in Firefox with
|
|
59
|
+
// `Could not extract indexURL path from pyodide module`
|
|
60
|
+
// This fixes for Firefox and does not break Chrome/others
|
|
61
|
+
const indexURL = `https://cdn.jsdelivr.net/pyodide/${opts.pyodideVersion}/full/`;
|
|
58
62
|
const pyodide = await loadPyodide({
|
|
59
63
|
// Perf: These get loaded while pyodide is being bootstrapped
|
|
60
64
|
packages: [
|
|
@@ -68,10 +72,14 @@ export class DefaultWasmController implements WasmController {
|
|
|
68
72
|
],
|
|
69
73
|
_makeSnapshot: MAKE_SNAPSHOT,
|
|
70
74
|
lockFileURL: `https://wasm.marimo.app/pyodide-lock.json?v=${opts.version}&pyodide=${opts.pyodideVersion}`,
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
+
indexURL,
|
|
76
|
+
// Since Pyodide 0.28.0, when lockFileURL is set, the package base URL
|
|
77
|
+
// defaults to the lockfile's URL (wasm.marimo.app) instead of indexURL.
|
|
78
|
+
// Unlike Node, browsers get no CDN fallback on a failed fetch, so we
|
|
79
|
+
// should pin packageBaseUrl back to the jsDelivr CDN to restore
|
|
80
|
+
// the resolution akin to pre-0.28.
|
|
81
|
+
packageBaseUrl: indexURL,
|
|
82
|
+
convertNullToNone: true,
|
|
75
83
|
});
|
|
76
84
|
this.pyodide = pyodide;
|
|
77
85
|
span.end("ok");
|
|
@@ -3,11 +3,20 @@
|
|
|
3
3
|
import ReactDOM from "react-dom/client";
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
+
import { FUNCTIONS_REGISTRY } from "@/core/functions/FunctionRegistry";
|
|
7
|
+
import type { FunctionCallResultMessage } from "@/core/kernel/messages";
|
|
8
|
+
import { FunctionNotFoundError } from "@/utils/errors";
|
|
6
9
|
import {
|
|
7
10
|
isCustomMarimoElement,
|
|
8
11
|
registerReactComponent,
|
|
9
12
|
} from "../registerReactComponent";
|
|
10
13
|
|
|
14
|
+
vi.mock("@/core/functions/FunctionRegistry", () => ({
|
|
15
|
+
FUNCTIONS_REGISTRY: { request: vi.fn() },
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
const requestMock = vi.mocked(FUNCTIONS_REGISTRY.request);
|
|
19
|
+
|
|
11
20
|
// Each custom element name can only be registered once per jsdom window,
|
|
12
21
|
// so we use a counter to generate unique tag names across tests.
|
|
13
22
|
let tagCounter = 0;
|
|
@@ -202,3 +211,90 @@ describe("connectedCallback - light DOM nesting detection", () => {
|
|
|
202
211
|
outer.remove();
|
|
203
212
|
});
|
|
204
213
|
});
|
|
214
|
+
|
|
215
|
+
describe("plugin function: not-found recovery", () => {
|
|
216
|
+
const NOT_FOUND: FunctionCallResultMessage = {
|
|
217
|
+
function_call_id:
|
|
218
|
+
"call-id" as FunctionCallResultMessage["function_call_id"],
|
|
219
|
+
status: { code: "error", message: "Function not found" },
|
|
220
|
+
found: false,
|
|
221
|
+
return_value: null,
|
|
222
|
+
};
|
|
223
|
+
const OK: FunctionCallResultMessage = {
|
|
224
|
+
function_call_id:
|
|
225
|
+
"call-id" as FunctionCallResultMessage["function_call_id"],
|
|
226
|
+
status: { code: "ok" },
|
|
227
|
+
found: true,
|
|
228
|
+
return_value: { ok: true },
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Mount a plugin exposing a single callable function and resolve the
|
|
232
|
+
// function map that PluginSlot hands to render(), so tests can invoke the
|
|
233
|
+
// request path directly.
|
|
234
|
+
async function mountWithFunction(): Promise<
|
|
235
|
+
(args: Record<string, unknown>) => Promise<unknown>
|
|
236
|
+
> {
|
|
237
|
+
const tag = uniqueTag("fn");
|
|
238
|
+
let captured:
|
|
239
|
+
| ((args: Record<string, unknown>) => Promise<unknown>)
|
|
240
|
+
| undefined;
|
|
241
|
+
registerReactComponent({
|
|
242
|
+
tagName: tag,
|
|
243
|
+
validator: z.any(),
|
|
244
|
+
functions: { run: { input: z.any(), output: z.any() } },
|
|
245
|
+
render: ({ functions }) => {
|
|
246
|
+
captured = (functions as Record<string, typeof captured>).run;
|
|
247
|
+
return null as never;
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const wrapper = document.createElement("marimo-ui-element");
|
|
252
|
+
wrapper.setAttribute("object-id", "test-object-id");
|
|
253
|
+
const el = document.createElement(tag);
|
|
254
|
+
wrapper.append(el);
|
|
255
|
+
document.body.append(wrapper);
|
|
256
|
+
|
|
257
|
+
await vi.waitFor(() => expect(captured).toBeDefined());
|
|
258
|
+
return captured as (args: Record<string, unknown>) => Promise<unknown>;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
beforeEach(() => {
|
|
262
|
+
requestMock.mockReset();
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
afterEach(() => {
|
|
266
|
+
document.body.innerHTML = "";
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test("retries on found:false and resolves once the function appears", async () => {
|
|
270
|
+
const run = await mountWithFunction();
|
|
271
|
+
requestMock.mockResolvedValueOnce(NOT_FOUND).mockResolvedValueOnce(OK);
|
|
272
|
+
|
|
273
|
+
await expect(run({})).resolves.toEqual({ ok: true });
|
|
274
|
+
expect(requestMock).toHaveBeenCalledTimes(2);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test("throws FunctionNotFoundError after retries are exhausted", async () => {
|
|
278
|
+
const run = await mountWithFunction();
|
|
279
|
+
requestMock.mockResolvedValue(NOT_FOUND);
|
|
280
|
+
|
|
281
|
+
await expect(run({})).rejects.toBeInstanceOf(FunctionNotFoundError);
|
|
282
|
+
// Initial attempt plus three retries.
|
|
283
|
+
expect(requestMock).toHaveBeenCalledTimes(4);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("does not retry once the function is found (found:true)", async () => {
|
|
287
|
+
const run = await mountWithFunction();
|
|
288
|
+
requestMock.mockResolvedValue({
|
|
289
|
+
function_call_id:
|
|
290
|
+
"call-id" as FunctionCallResultMessage["function_call_id"],
|
|
291
|
+
status: { code: "error", message: "boom" },
|
|
292
|
+
found: true,
|
|
293
|
+
return_value: null,
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
const promise = run({});
|
|
297
|
+
await expect(promise).rejects.toThrow("boom");
|
|
298
|
+
expect(requestMock).toHaveBeenCalledTimes(1);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
@@ -40,7 +40,10 @@ import {
|
|
|
40
40
|
} from "@/hooks/useEventListener";
|
|
41
41
|
import { StyleNamespace } from "@/theme/namespace";
|
|
42
42
|
import { useTheme } from "@/theme/useTheme";
|
|
43
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
CellNotInitializedError,
|
|
45
|
+
FunctionNotFoundError,
|
|
46
|
+
} from "@/utils/errors.ts";
|
|
44
47
|
import { Functions } from "@/utils/functions";
|
|
45
48
|
import { shallowCompare } from "@/utils/shallow-compare";
|
|
46
49
|
import { defineCustomElement } from "../../core/dom/defineCustomElement";
|
|
@@ -80,6 +83,12 @@ export interface IMarimoHTMLElement extends HTMLElement {
|
|
|
80
83
|
rerender: () => void;
|
|
81
84
|
}
|
|
82
85
|
|
|
86
|
+
// Bounded exponential backoff for re-issuing a request whose function the
|
|
87
|
+
// kernel reported as not found. Short enough to fail fast on a genuinely
|
|
88
|
+
// missing function, long enough to outlast a transient object-id desync.
|
|
89
|
+
const FUNCTION_NOT_FOUND_MAX_RETRIES = 3;
|
|
90
|
+
const FUNCTION_NOT_FOUND_BASE_DELAY_MS = 150;
|
|
91
|
+
|
|
83
92
|
interface PluginSlotProps<T> {
|
|
84
93
|
hostElement: HTMLElement;
|
|
85
94
|
plugin: IPlugin<T, unknown>;
|
|
@@ -188,8 +197,6 @@ function PluginSlotInternal<T>(
|
|
|
188
197
|
args.length <= 1,
|
|
189
198
|
`Plugin functions only supports a single argument. Called ${key}`,
|
|
190
199
|
);
|
|
191
|
-
const objectId = getUIElementObjectId(hostElement);
|
|
192
|
-
invariant(objectId, "Object ID should exist");
|
|
193
200
|
|
|
194
201
|
const isStatic = isStaticNotebook();
|
|
195
202
|
|
|
@@ -218,16 +225,41 @@ function PluginSlotInternal<T>(
|
|
|
218
225
|
Logger.warn(`Cell ID ${cellId} cannot be found`);
|
|
219
226
|
}
|
|
220
227
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
228
|
+
// A "function not found" response means the kernel never ran the
|
|
229
|
+
// function, so re-issuing the request is side-effect-safe regardless
|
|
230
|
+
// of whether the function is idempotent. This recovers from a
|
|
231
|
+
// transient window where the frontend's object-id leads the kernel's
|
|
232
|
+
// registry. The object-id is re-read each attempt so a corrected id
|
|
233
|
+
// from a re-render is picked up. Once the function is found
|
|
234
|
+
// (found === true) the request is never retried, since the failure
|
|
235
|
+
// is unrelated to lookup and retrying would not help.
|
|
236
|
+
const parsedArgs = prettyParse(input, args[0]);
|
|
237
|
+
for (let attempt = 0; ; attempt++) {
|
|
238
|
+
const namespace = getUIElementObjectId(hostElement);
|
|
239
|
+
invariant(namespace, "Object ID should exist");
|
|
240
|
+
|
|
241
|
+
const response = await FUNCTIONS_REGISTRY.request({
|
|
242
|
+
args: parsedArgs,
|
|
243
|
+
functionName: key,
|
|
244
|
+
namespace,
|
|
245
|
+
});
|
|
246
|
+
if (response.status.code === "ok") {
|
|
247
|
+
return prettyParse(output, response.return_value);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const recoverable = response.found === false;
|
|
251
|
+
if (recoverable && attempt < FUNCTION_NOT_FOUND_MAX_RETRIES) {
|
|
252
|
+
const delay = FUNCTION_NOT_FOUND_BASE_DELAY_MS * 2 ** attempt;
|
|
253
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
|
|
227
257
|
Logger.error(response.status);
|
|
258
|
+
if (recoverable) {
|
|
259
|
+
throw new FunctionNotFoundError();
|
|
260
|
+
}
|
|
228
261
|
throw new Error(response.status.message || "Unknown error");
|
|
229
262
|
}
|
|
230
|
-
return prettyParse(output, response.return_value);
|
|
231
263
|
};
|
|
232
264
|
}
|
|
233
265
|
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
import { type JSX, useId, useMemo
|
|
3
|
-
import { Virtuoso } from "react-virtuoso";
|
|
2
|
+
import { type JSX, useId, useMemo } from "react";
|
|
4
3
|
import { z } from "zod";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { CommandSeparator } from "../../components/ui/command";
|
|
4
|
+
import type { Option } from "@/components/ui/select-core";
|
|
5
|
+
import { SelectList } from "@/components/ui/select-core";
|
|
8
6
|
import type { IPlugin, IPluginProps, Setter } from "../types";
|
|
9
7
|
import { Labeled } from "./common/labeled";
|
|
10
|
-
import { multiselectFilterFn } from "./multiselectFilterFn";
|
|
11
8
|
|
|
12
9
|
interface Data {
|
|
13
10
|
label: string | null;
|
|
@@ -55,9 +52,6 @@ interface MultiselectProps extends Data {
|
|
|
55
52
|
setValue: Setter<T>;
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
const SELECT_ALL_KEY = "__select_all__";
|
|
59
|
-
const DESELECT_ALL_KEY = "__deselect_all__";
|
|
60
|
-
|
|
61
55
|
export const Multiselect = ({
|
|
62
56
|
options,
|
|
63
57
|
label,
|
|
@@ -68,144 +62,27 @@ export const Multiselect = ({
|
|
|
68
62
|
disabled,
|
|
69
63
|
}: MultiselectProps): JSX.Element => {
|
|
70
64
|
const id = useId();
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return options;
|
|
76
|
-
}
|
|
77
|
-
return options.filter(
|
|
78
|
-
(option) => multiselectFilterFn(option, searchQuery) === 1,
|
|
79
|
-
);
|
|
80
|
-
}, [options, searchQuery]);
|
|
81
|
-
|
|
82
|
-
const handleValueChange = (newValues: string[] | null) => {
|
|
83
|
-
if (!newValues || newValues.length === 0) {
|
|
84
|
-
setValue([]);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Remove select all and deselect all from the new values
|
|
89
|
-
newValues = newValues.filter(
|
|
90
|
-
(value) => value !== SELECT_ALL_KEY && value !== DESELECT_ALL_KEY,
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
if (maxSelections === 1) {
|
|
94
|
-
// For single selection, just take the last selected value
|
|
95
|
-
setValue([newValues[newValues.length - 1]]);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (maxSelections != null && newValues.length > maxSelections) {
|
|
100
|
-
// When over max selections, remove oldest selections
|
|
101
|
-
newValues = newValues.slice(-maxSelections);
|
|
102
|
-
}
|
|
103
|
-
setValue(newValues);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const handleSelectAll = () => {
|
|
107
|
-
setValue(options);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const handleDeselectAll = () => {
|
|
111
|
-
setValue([]);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const extraOptions: React.ReactNode[] = [];
|
|
115
|
-
const selectAllEnabled = options.length > 0 && value.length < options.length;
|
|
116
|
-
const deselectAllEnabled = options.length > 0 && value.length > 0;
|
|
117
|
-
|
|
118
|
-
// Only show when more than 2 options
|
|
119
|
-
// Only show select all when maxSelections is not set
|
|
120
|
-
if (options.length > 2 && maxSelections == null) {
|
|
121
|
-
extraOptions.push(
|
|
122
|
-
<ComboboxItem
|
|
123
|
-
key={SELECT_ALL_KEY}
|
|
124
|
-
value={SELECT_ALL_KEY}
|
|
125
|
-
onSelect={handleSelectAll}
|
|
126
|
-
disabled={!selectAllEnabled}
|
|
127
|
-
>
|
|
128
|
-
Select all
|
|
129
|
-
</ComboboxItem>,
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (options.length > 2) {
|
|
134
|
-
extraOptions.push(
|
|
135
|
-
<ComboboxItem
|
|
136
|
-
key={DESELECT_ALL_KEY}
|
|
137
|
-
value={DESELECT_ALL_KEY}
|
|
138
|
-
onSelect={handleDeselectAll}
|
|
139
|
-
disabled={!deselectAllEnabled}
|
|
140
|
-
>
|
|
141
|
-
{maxSelections === 1 ? "Deselect" : "Deselect all"}
|
|
142
|
-
</ComboboxItem>,
|
|
143
|
-
<CommandSeparator key="_separator" />,
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const renderList = () => {
|
|
148
|
-
// List virtualization
|
|
149
|
-
if (filteredOptions.length > 200) {
|
|
150
|
-
return (
|
|
151
|
-
<Virtuoso
|
|
152
|
-
style={{ height: "200px" }}
|
|
153
|
-
totalCount={filteredOptions.length}
|
|
154
|
-
overscan={50}
|
|
155
|
-
itemContent={(i: number) => {
|
|
156
|
-
const comboboxItem = (
|
|
157
|
-
<ComboboxItem key={filteredOptions[i]} value={filteredOptions[i]}>
|
|
158
|
-
{filteredOptions[i]}
|
|
159
|
-
</ComboboxItem>
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
if (i === 0) {
|
|
163
|
-
return (
|
|
164
|
-
<>
|
|
165
|
-
{extraOptions}
|
|
166
|
-
{comboboxItem}
|
|
167
|
-
</>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return comboboxItem;
|
|
172
|
-
}}
|
|
173
|
-
/>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const list = filteredOptions.map((option) => (
|
|
178
|
-
<ComboboxItem key={option} value={option}>
|
|
179
|
-
{option}
|
|
180
|
-
</ComboboxItem>
|
|
181
|
-
));
|
|
182
|
-
|
|
183
|
-
return (
|
|
184
|
-
<>
|
|
185
|
-
{extraOptions}
|
|
186
|
-
{list}
|
|
187
|
-
</>
|
|
188
|
-
);
|
|
189
|
-
};
|
|
65
|
+
const items = useMemo<Array<Option<string>>>(
|
|
66
|
+
() => options.map((option) => ({ value: option, label: option })),
|
|
67
|
+
[options],
|
|
68
|
+
);
|
|
190
69
|
|
|
191
70
|
return (
|
|
192
71
|
<Labeled label={label} id={id} fullWidth={fullWidth}>
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
multiple={true}
|
|
197
|
-
className={cn({
|
|
198
|
-
"w-full": fullWidth,
|
|
199
|
-
})}
|
|
72
|
+
<SelectList<string>
|
|
73
|
+
id={id}
|
|
74
|
+
options={items}
|
|
200
75
|
value={value}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
76
|
+
onChange={(next: string[] | string | null) =>
|
|
77
|
+
setValue((next as string[] | null) ?? [])
|
|
78
|
+
}
|
|
79
|
+
multiple={true}
|
|
80
|
+
maxSelections={maxSelections}
|
|
81
|
+
pinSelected={true}
|
|
82
|
+
compactChipTrigger={true}
|
|
83
|
+
fullWidth={fullWidth}
|
|
205
84
|
disabled={disabled}
|
|
206
|
-
|
|
207
|
-
{renderList()}
|
|
208
|
-
</Combobox>
|
|
85
|
+
/>
|
|
209
86
|
</Labeled>
|
|
210
87
|
);
|
|
211
88
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
import { type JSX, useId, useMemo
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { type JSX, useId, useMemo } from "react";
|
|
3
|
+
import type { Option } from "@/components/ui/select-core";
|
|
4
|
+
import { SelectList } from "@/components/ui/select-core";
|
|
5
5
|
import { cn } from "../../utils/cn";
|
|
6
6
|
import { Labeled } from "./common/labeled";
|
|
7
|
-
import { multiselectFilterFn } from "./multiselectFilterFn";
|
|
8
7
|
|
|
9
8
|
interface SearchableSelectProps {
|
|
10
9
|
options: string[];
|
|
@@ -16,8 +15,6 @@ interface SearchableSelectProps {
|
|
|
16
15
|
disabled: boolean;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
const NONE_KEY = "__none__";
|
|
20
|
-
|
|
21
18
|
export const SearchableSelect = (props: SearchableSelectProps): JSX.Element => {
|
|
22
19
|
const {
|
|
23
20
|
options,
|
|
@@ -29,104 +26,26 @@ export const SearchableSelect = (props: SearchableSelectProps): JSX.Element => {
|
|
|
29
26
|
disabled,
|
|
30
27
|
} = props;
|
|
31
28
|
const id = useId();
|
|
32
|
-
const [searchQuery, setSearchQuery] = useState<string>("");
|
|
33
|
-
|
|
34
|
-
const filteredOptions = useMemo(() => {
|
|
35
|
-
if (!searchQuery) {
|
|
36
|
-
return options;
|
|
37
|
-
}
|
|
38
|
-
return options.filter(
|
|
39
|
-
(option) => multiselectFilterFn(option, searchQuery) === 1,
|
|
40
|
-
);
|
|
41
|
-
}, [options, searchQuery]);
|
|
42
|
-
|
|
43
|
-
const handleValueChange = (newValue: string | null) => {
|
|
44
|
-
if (newValue == null) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (newValue === NONE_KEY) {
|
|
49
|
-
setValue(null);
|
|
50
|
-
} else {
|
|
51
|
-
setValue(newValue);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const renderList = () => {
|
|
56
|
-
const extraOptions = allowSelectNone ? (
|
|
57
|
-
<ComboboxItem key={NONE_KEY} value={NONE_KEY}>
|
|
58
|
-
--
|
|
59
|
-
</ComboboxItem>
|
|
60
|
-
) : null;
|
|
61
|
-
|
|
62
|
-
if (filteredOptions.length > 200) {
|
|
63
|
-
return (
|
|
64
|
-
<Virtuoso
|
|
65
|
-
style={{ height: "200px" }}
|
|
66
|
-
totalCount={filteredOptions.length}
|
|
67
|
-
overscan={50}
|
|
68
|
-
itemContent={(i: number) => {
|
|
69
|
-
const option = filteredOptions[i];
|
|
70
29
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
if (i === 0) {
|
|
78
|
-
return (
|
|
79
|
-
<>
|
|
80
|
-
{extraOptions}
|
|
81
|
-
{comboboxItem}
|
|
82
|
-
</>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return comboboxItem;
|
|
87
|
-
}}
|
|
88
|
-
/>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const list = filteredOptions.map((option) => (
|
|
93
|
-
<ComboboxItem key={option} value={option}>
|
|
94
|
-
{option}
|
|
95
|
-
</ComboboxItem>
|
|
96
|
-
));
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<>
|
|
100
|
-
{extraOptions}
|
|
101
|
-
{list}
|
|
102
|
-
</>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
30
|
+
const items = useMemo<Array<Option<string>>>(
|
|
31
|
+
() => options.map((option) => ({ value: option, label: option })),
|
|
32
|
+
[options],
|
|
33
|
+
);
|
|
105
34
|
|
|
106
35
|
return (
|
|
107
36
|
<Labeled label={label} id={id} fullWidth={fullWidth}>
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return option;
|
|
114
|
-
}}
|
|
115
|
-
placeholder="Select..."
|
|
37
|
+
<SelectList<string>
|
|
38
|
+
id={id}
|
|
39
|
+
options={items}
|
|
40
|
+
value={value}
|
|
41
|
+
onChange={(next) => setValue((next as string | null) ?? null)}
|
|
116
42
|
multiple={false}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
})}
|
|
120
|
-
value={value ?? NONE_KEY}
|
|
121
|
-
onValueChange={handleValueChange}
|
|
122
|
-
shouldFilter={false}
|
|
123
|
-
search={searchQuery}
|
|
124
|
-
onSearchChange={setSearchQuery}
|
|
43
|
+
allowSelectNone={allowSelectNone}
|
|
44
|
+
fullWidth={fullWidth}
|
|
125
45
|
disabled={disabled}
|
|
46
|
+
className={cn({ "w-full": fullWidth })}
|
|
126
47
|
data-testid="marimo-plugin-searchable-dropdown"
|
|
127
|
-
|
|
128
|
-
{renderList()}
|
|
129
|
-
</Combobox>
|
|
48
|
+
/>
|
|
130
49
|
</Labeled>
|
|
131
50
|
);
|
|
132
51
|
};
|