@marimo-team/islands 0.23.10-dev3 → 0.23.10-dev31
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-DmBropAy.js} +31 -31
- package/dist/{ErrorBoundary-rULOrC_p.js → ErrorBoundary-DpbaKVv7.js} +1 -1
- package/dist/{any-language-editor-DfdpyDv_.js → any-language-editor-DNmoSiWL.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-C1tL1pML.js → chat-ui-D6oraHT2.js} +76 -76
- package/dist/{check-DTbrK0zt.js → check-BCaJeT-J.js} +1 -1
- package/dist/{code-visibility-DfnO0DcH.js → code-visibility-B9qGgair.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-Cc0I3C9e.js} +1 -1
- 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/{formats-DHxc-FdY.js → formats-C4wO47tk.js} +1 -1
- package/dist/{glide-data-editor-BOmK9ETQ.js → glide-data-editor-Qhu8oCX-.js} +12 -12
- package/dist/{html-to-image-CNa5ok96.js → html-to-image-UEH5lFDZ.js} +2318 -2275
- package/dist/{input-_2sjvfne.js → input-CMYy4hzj.js} +187 -185
- package/dist/{label-LWtdw5i8.js → label-CC4ytI1X.js} +1 -1
- package/dist/main.js +6941 -6913
- package/dist/{mermaid-lXOw5Py9.js → mermaid-zuLgJ8J8.js} +4 -4
- package/dist/{process-output-DKr4f1di.js → process-output-CyMLTogj.js} +3 -3
- package/dist/{reveal-component-UdMnCK5U.js → reveal-component-Co2AuBAx.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-9h1ACS78.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/cell-context-menu.tsx +15 -2
- 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/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/go-to-definition/commands.ts +4 -3
- 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/impl/MultiselectPlugin.tsx +19 -142
- package/src/plugins/impl/SearchableSelect.tsx +16 -97
- package/src/plugins/impl/__tests__/DropdownPlugin.test.tsx +5 -2
- package/src/plugins/impl/__tests__/MultiSelectPlugin.test.ts +1 -1
- package/src/plugins/layout/DownloadPlugin.tsx +1 -1
- package/src/utils/lazy.ts +6 -1
- 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
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import type { BulkActionSpec, Option } from "./types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Override cmdk's relevance-sorting filter with a stricter membership test: an
|
|
6
|
+
* option matches only when every whitespace-separated query word appears in it
|
|
7
|
+
* (case-insensitive), in any order. More lenient than exact match, stricter than
|
|
8
|
+
* fuzzy.
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* - "foo bar" matches "foo bar"
|
|
12
|
+
* - "bar foo" matches "foo bar"
|
|
13
|
+
* - "foob" does not match "foo bar"
|
|
14
|
+
*/
|
|
15
|
+
export function multiselectFilterFn(option: string, value: string): number {
|
|
16
|
+
const words = value.split(/\s+/);
|
|
17
|
+
const match = words.every((word) =>
|
|
18
|
+
option.toLowerCase().includes(word.toLowerCase()),
|
|
19
|
+
);
|
|
20
|
+
return match ? 1 : 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Union: append the not-yet-selected members of `toAdd`, preserving order. */
|
|
24
|
+
export function selectMatching<V>(selected: V[], toAdd: V[]): V[] {
|
|
25
|
+
const set = new Set(selected);
|
|
26
|
+
return [...set, ...toAdd.filter((v) => !set.has(v))];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Difference: drop every member of `toRemove` from `selected`. */
|
|
30
|
+
export function deselectMatching<V>(selected: V[], toRemove: V[]): V[] {
|
|
31
|
+
const set = new Set(toRemove);
|
|
32
|
+
return selected.filter((v) => !set.has(v));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Order options for the idle (no active search) menu: pinned selections first in
|
|
37
|
+
* pin insertion order (so a freshly added selection appears after earlier ones),
|
|
38
|
+
* then everything else in option order. `pinnedSelection` is a frozen snapshot
|
|
39
|
+
* taken when the menu opens, so toggling an item does not reorder the list under
|
|
40
|
+
* the cursor. Returns the count of pinned options alongside the list so callers
|
|
41
|
+
* don't have to re-scan to find where the pinned block ends.
|
|
42
|
+
*/
|
|
43
|
+
export function getVisibleOptions<V>(
|
|
44
|
+
options: Array<Option<V>>,
|
|
45
|
+
pinnedSelection: ReadonlySet<V>,
|
|
46
|
+
): { visibleOptions: Array<Option<V>>; pinnedCount: number } {
|
|
47
|
+
const byValue = new Map(options.map((o) => [o.value, o] as const));
|
|
48
|
+
const pinned: Array<Option<V>> = [];
|
|
49
|
+
for (const value of pinnedSelection) {
|
|
50
|
+
const option = byValue.get(value);
|
|
51
|
+
if (option) {
|
|
52
|
+
pinned.push(option);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const rest = options.filter((o) => !pinnedSelection.has(o.value));
|
|
56
|
+
return { visibleOptions: [...pinned, ...rest], pinnedCount: pinned.length };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Decide which bulk rows the menu shows for the current search/cap state.
|
|
61
|
+
*
|
|
62
|
+
* When searching, the select-side spec carries the unselected matches and the
|
|
63
|
+
* deselect-side spec carries the selected matches (each omitted when empty).
|
|
64
|
+
* When idle, the spec is just `select-all` / `deselect-all` with an `enabled`
|
|
65
|
+
* flag for the disabled-but-visible state. `maxSelections` hides the select-
|
|
66
|
+
* side everywhere (a bulk select could exceed the cap); `maxSelections === 1`
|
|
67
|
+
* suppresses bulk rows entirely. Returns `[]` when bulk rows shouldn't show.
|
|
68
|
+
*
|
|
69
|
+
* Specs come in select-then-deselect order so the facade can render them as-is.
|
|
70
|
+
*/
|
|
71
|
+
export function getBulkActions<V>(params: {
|
|
72
|
+
options: Array<Option<V>>;
|
|
73
|
+
filteredOptions: Array<Option<V>>;
|
|
74
|
+
value: V[];
|
|
75
|
+
searchQuery: string;
|
|
76
|
+
maxSelections: number | undefined;
|
|
77
|
+
}): Array<BulkActionSpec<V>> {
|
|
78
|
+
const { options, filteredOptions, value, searchQuery, maxSelections } =
|
|
79
|
+
params;
|
|
80
|
+
|
|
81
|
+
if (options.length <= 2 || maxSelections === 1) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const capped = maxSelections != null;
|
|
86
|
+
const specs: Array<BulkActionSpec<V>> = [];
|
|
87
|
+
|
|
88
|
+
if (searchQuery !== "") {
|
|
89
|
+
if (filteredOptions.length === 0) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
const selected = new Set(value);
|
|
93
|
+
const selectedMatches: Array<Option<V>> = [];
|
|
94
|
+
const unselectedMatches: Array<Option<V>> = [];
|
|
95
|
+
for (const option of filteredOptions) {
|
|
96
|
+
if (selected.has(option.value)) {
|
|
97
|
+
selectedMatches.push(option);
|
|
98
|
+
} else if (!option.disabled) {
|
|
99
|
+
// Disabled rows can't be picked individually, so bulk select skips them too.
|
|
100
|
+
unselectedMatches.push(option);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!capped && unselectedMatches.length > 0) {
|
|
104
|
+
specs.push({ kind: "select-matching", items: unselectedMatches });
|
|
105
|
+
}
|
|
106
|
+
if (selectedMatches.length > 0) {
|
|
107
|
+
specs.push({ kind: "deselect-matching", items: selectedMatches });
|
|
108
|
+
}
|
|
109
|
+
return specs;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!capped) {
|
|
113
|
+
const selected = new Set(value);
|
|
114
|
+
specs.push({
|
|
115
|
+
kind: "select-all",
|
|
116
|
+
enabled: options.some((o) => !o.disabled && !selected.has(o.value)),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
specs.push({ kind: "deselect-all", enabled: value.length > 0 });
|
|
120
|
+
return specs;
|
|
121
|
+
}
|
|
@@ -58,6 +58,10 @@ interface State {
|
|
|
58
58
|
|
|
59
59
|
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
|
60
60
|
|
|
61
|
+
// Keys of toasts requested with `once: true`, suppressed after first show
|
|
62
|
+
// for the lifetime of the page (i.e. one static-preview session).
|
|
63
|
+
const shownOnceKeys = new Set<string>();
|
|
64
|
+
|
|
61
65
|
const addToRemoveQueue = (toastId: string) => {
|
|
62
66
|
if (toastTimeouts.has(toastId)) {
|
|
63
67
|
return;
|
|
@@ -159,9 +163,18 @@ function dispatch(action: Action) {
|
|
|
159
163
|
|
|
160
164
|
type Toast = Omit<ToasterToast, "id">;
|
|
161
165
|
|
|
162
|
-
function toast({
|
|
166
|
+
function toast({
|
|
167
|
+
id,
|
|
168
|
+
once,
|
|
169
|
+
...props
|
|
170
|
+
}: Toast & { id?: string; once?: boolean }) {
|
|
163
171
|
const toastId = id || genId();
|
|
164
172
|
|
|
173
|
+
// `once` dedupe requires a caller-provided stable `id`. A generated id is
|
|
174
|
+
// unique per call, so it could never match (and would grow the set without
|
|
175
|
+
// bound); gate on `id` so `once` without one is simply a no-op.
|
|
176
|
+
const dedupeOnce = once === true && id !== undefined;
|
|
177
|
+
|
|
165
178
|
const update = (props: Toast) =>
|
|
166
179
|
dispatch({
|
|
167
180
|
type: "UPDATE_TOAST",
|
|
@@ -183,19 +196,26 @@ function toast({ id, ...props }: Toast & { id?: string }) {
|
|
|
183
196
|
},
|
|
184
197
|
});
|
|
185
198
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
199
|
+
const suppressed = dedupeOnce && shownOnceKeys.has(toastId);
|
|
200
|
+
if (dedupeOnce) {
|
|
201
|
+
shownOnceKeys.add(toastId);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (!suppressed) {
|
|
205
|
+
dispatch({
|
|
206
|
+
type: "ADD_TOAST",
|
|
207
|
+
toast: {
|
|
208
|
+
...props,
|
|
209
|
+
id: toastId,
|
|
210
|
+
open: true,
|
|
211
|
+
onOpenChange: (open) => {
|
|
212
|
+
if (!open) {
|
|
213
|
+
dismiss();
|
|
214
|
+
}
|
|
215
|
+
},
|
|
196
216
|
},
|
|
197
|
-
}
|
|
198
|
-
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
199
219
|
|
|
200
220
|
return {
|
|
201
221
|
id: toastId,
|
|
@@ -80,7 +80,6 @@ exports[`cell reducer > can initialize stdin 3`] = `
|
|
|
80
80
|
"output": null,
|
|
81
81
|
"runElapsedTimeMs": null,
|
|
82
82
|
"runStartTimestamp": null,
|
|
83
|
-
"serialization": undefined,
|
|
84
83
|
"serializedEditorState": null,
|
|
85
84
|
"staleInputs": false,
|
|
86
85
|
"status": "queued",
|
|
@@ -110,7 +109,6 @@ exports[`cell reducer > can initialize stdin 4`] = `
|
|
|
110
109
|
"output": null,
|
|
111
110
|
"runElapsedTimeMs": null,
|
|
112
111
|
"runStartTimestamp": 20,
|
|
113
|
-
"serialization": undefined,
|
|
114
112
|
"serializedEditorState": null,
|
|
115
113
|
"staleInputs": false,
|
|
116
114
|
"status": "running",
|
|
@@ -147,7 +145,6 @@ exports[`cell reducer > can initialize stdin 5`] = `
|
|
|
147
145
|
"output": null,
|
|
148
146
|
"runElapsedTimeMs": null,
|
|
149
147
|
"runStartTimestamp": 20,
|
|
150
|
-
"serialization": undefined,
|
|
151
148
|
"serializedEditorState": null,
|
|
152
149
|
"staleInputs": false,
|
|
153
150
|
"status": "running",
|
|
@@ -184,7 +181,6 @@ exports[`cell reducer > can initialize stdin 6`] = `
|
|
|
184
181
|
"output": null,
|
|
185
182
|
"runElapsedTimeMs": null,
|
|
186
183
|
"runStartTimestamp": 20,
|
|
187
|
-
"serialization": undefined,
|
|
188
184
|
"serializedEditorState": null,
|
|
189
185
|
"staleInputs": false,
|
|
190
186
|
"status": "running",
|
|
@@ -227,7 +223,6 @@ exports[`cell reducer > can initialize stdin 7`] = `
|
|
|
227
223
|
"output": null,
|
|
228
224
|
"runElapsedTimeMs": null,
|
|
229
225
|
"runStartTimestamp": 20,
|
|
230
|
-
"serialization": undefined,
|
|
231
226
|
"serializedEditorState": null,
|
|
232
227
|
"staleInputs": false,
|
|
233
228
|
"status": "running",
|
|
@@ -271,7 +266,6 @@ exports[`cell reducer > can initialize stdin 8`] = `
|
|
|
271
266
|
"output": null,
|
|
272
267
|
"runElapsedTimeMs": null,
|
|
273
268
|
"runStartTimestamp": 20,
|
|
274
|
-
"serialization": undefined,
|
|
275
269
|
"serializedEditorState": null,
|
|
276
270
|
"staleInputs": false,
|
|
277
271
|
"status": "running",
|
|
@@ -321,7 +315,6 @@ exports[`cell reducer > can initialize stdin 9`] = `
|
|
|
321
315
|
"output": null,
|
|
322
316
|
"runElapsedTimeMs": null,
|
|
323
317
|
"runStartTimestamp": 20,
|
|
324
|
-
"serialization": undefined,
|
|
325
318
|
"serializedEditorState": null,
|
|
326
319
|
"staleInputs": false,
|
|
327
320
|
"status": "running",
|
|
@@ -387,7 +380,6 @@ exports[`cell reducer > can receive console when the cell is idle and will clear
|
|
|
387
380
|
"output": null,
|
|
388
381
|
"runElapsedTimeMs": null,
|
|
389
382
|
"runStartTimestamp": null,
|
|
390
|
-
"serialization": undefined,
|
|
391
383
|
"serializedEditorState": null,
|
|
392
384
|
"staleInputs": false,
|
|
393
385
|
"status": "queued",
|
|
@@ -424,7 +416,6 @@ exports[`cell reducer > can receive console when the cell is idle and will clear
|
|
|
424
416
|
"output": null,
|
|
425
417
|
"runElapsedTimeMs": null,
|
|
426
418
|
"runStartTimestamp": null,
|
|
427
|
-
"serialization": undefined,
|
|
428
419
|
"serializedEditorState": null,
|
|
429
420
|
"staleInputs": false,
|
|
430
421
|
"status": "queued",
|
|
@@ -454,7 +445,6 @@ exports[`cell reducer > can receive console when the cell is idle and will clear
|
|
|
454
445
|
"output": null,
|
|
455
446
|
"runElapsedTimeMs": null,
|
|
456
447
|
"runStartTimestamp": 20,
|
|
457
|
-
"serialization": undefined,
|
|
458
448
|
"serializedEditorState": null,
|
|
459
449
|
"staleInputs": false,
|
|
460
450
|
"status": "running",
|
|
@@ -491,7 +481,6 @@ exports[`cell reducer > can receive console when the cell is idle and will clear
|
|
|
491
481
|
"output": null,
|
|
492
482
|
"runElapsedTimeMs": 2000,
|
|
493
483
|
"runStartTimestamp": null,
|
|
494
|
-
"serialization": undefined,
|
|
495
484
|
"serializedEditorState": null,
|
|
496
485
|
"staleInputs": false,
|
|
497
486
|
"status": "idle",
|
|
@@ -521,7 +510,6 @@ exports[`cell reducer > can run a stale cell 1`] = `
|
|
|
521
510
|
"output": null,
|
|
522
511
|
"runElapsedTimeMs": null,
|
|
523
512
|
"runStartTimestamp": null,
|
|
524
|
-
"serialization": undefined,
|
|
525
513
|
"serializedEditorState": null,
|
|
526
514
|
"staleInputs": false,
|
|
527
515
|
"status": "queued",
|
|
@@ -551,7 +539,6 @@ exports[`cell reducer > can run a stale cell 2`] = `
|
|
|
551
539
|
"output": null,
|
|
552
540
|
"runElapsedTimeMs": null,
|
|
553
541
|
"runStartTimestamp": null,
|
|
554
|
-
"serialization": undefined,
|
|
555
542
|
"serializedEditorState": null,
|
|
556
543
|
"staleInputs": true,
|
|
557
544
|
"status": "queued",
|
|
@@ -581,7 +568,6 @@ exports[`cell reducer > can run a stopped cell 1`] = `
|
|
|
581
568
|
"output": null,
|
|
582
569
|
"runElapsedTimeMs": null,
|
|
583
570
|
"runStartTimestamp": null,
|
|
584
|
-
"serialization": undefined,
|
|
585
571
|
"serializedEditorState": null,
|
|
586
572
|
"staleInputs": false,
|
|
587
573
|
"status": "queued",
|
|
@@ -611,7 +597,6 @@ exports[`cell reducer > can run a stopped cell 2`] = `
|
|
|
611
597
|
"output": null,
|
|
612
598
|
"runElapsedTimeMs": null,
|
|
613
599
|
"runStartTimestamp": null,
|
|
614
|
-
"serialization": undefined,
|
|
615
600
|
"serializedEditorState": null,
|
|
616
601
|
"staleInputs": false,
|
|
617
602
|
"status": "idle",
|
|
@@ -652,7 +637,6 @@ exports[`cell reducer > can run a stopped cell 3`] = `
|
|
|
652
637
|
},
|
|
653
638
|
"runElapsedTimeMs": null,
|
|
654
639
|
"runStartTimestamp": null,
|
|
655
|
-
"serialization": undefined,
|
|
656
640
|
"serializedEditorState": null,
|
|
657
641
|
"staleInputs": false,
|
|
658
642
|
"status": "idle",
|
|
@@ -693,7 +677,6 @@ exports[`cell reducer > can run a stopped cell 4`] = `
|
|
|
693
677
|
},
|
|
694
678
|
"runElapsedTimeMs": null,
|
|
695
679
|
"runStartTimestamp": null,
|
|
696
|
-
"serialization": undefined,
|
|
697
680
|
"serializedEditorState": null,
|
|
698
681
|
"staleInputs": false,
|
|
699
682
|
"status": "queued",
|
|
@@ -723,7 +706,6 @@ exports[`cell reducer > can run a stopped cell 5`] = `
|
|
|
723
706
|
"output": null,
|
|
724
707
|
"runElapsedTimeMs": null,
|
|
725
708
|
"runStartTimestamp": 40,
|
|
726
|
-
"serialization": undefined,
|
|
727
709
|
"serializedEditorState": null,
|
|
728
710
|
"staleInputs": false,
|
|
729
711
|
"status": "running",
|
|
@@ -840,7 +822,6 @@ exports[`cell reducer > can run cell and receive cell messages 4`] = `
|
|
|
840
822
|
"output": null,
|
|
841
823
|
"runElapsedTimeMs": null,
|
|
842
824
|
"runStartTimestamp": null,
|
|
843
|
-
"serialization": undefined,
|
|
844
825
|
"serializedEditorState": null,
|
|
845
826
|
"staleInputs": false,
|
|
846
827
|
"status": "queued",
|
|
@@ -870,7 +851,6 @@ exports[`cell reducer > can run cell and receive cell messages 5`] = `
|
|
|
870
851
|
"output": null,
|
|
871
852
|
"runElapsedTimeMs": null,
|
|
872
853
|
"runStartTimestamp": 20,
|
|
873
|
-
"serialization": undefined,
|
|
874
854
|
"serializedEditorState": null,
|
|
875
855
|
"staleInputs": false,
|
|
876
856
|
"status": "running",
|
|
@@ -907,7 +887,6 @@ exports[`cell reducer > can run cell and receive cell messages 6`] = `
|
|
|
907
887
|
"output": null,
|
|
908
888
|
"runElapsedTimeMs": null,
|
|
909
889
|
"runStartTimestamp": 20,
|
|
910
|
-
"serialization": undefined,
|
|
911
890
|
"serializedEditorState": null,
|
|
912
891
|
"staleInputs": false,
|
|
913
892
|
"status": "running",
|
|
@@ -949,7 +928,6 @@ exports[`cell reducer > can run cell and receive cell messages 7`] = `
|
|
|
949
928
|
},
|
|
950
929
|
"runElapsedTimeMs": 13000,
|
|
951
930
|
"runStartTimestamp": null,
|
|
952
|
-
"serialization": undefined,
|
|
953
931
|
"serializedEditorState": null,
|
|
954
932
|
"staleInputs": false,
|
|
955
933
|
"status": "idle",
|
|
@@ -992,7 +970,6 @@ import numpy",
|
|
|
992
970
|
},
|
|
993
971
|
"runElapsedTimeMs": 13000,
|
|
994
972
|
"runStartTimestamp": null,
|
|
995
|
-
"serialization": undefined,
|
|
996
973
|
"serializedEditorState": null,
|
|
997
974
|
"staleInputs": false,
|
|
998
975
|
"status": "idle",
|
|
@@ -1034,7 +1011,6 @@ exports[`cell reducer > can run cell and receive cell messages 9`] = `
|
|
|
1034
1011
|
},
|
|
1035
1012
|
"runElapsedTimeMs": 13000,
|
|
1036
1013
|
"runStartTimestamp": null,
|
|
1037
|
-
"serialization": undefined,
|
|
1038
1014
|
"serializedEditorState": null,
|
|
1039
1015
|
"staleInputs": false,
|
|
1040
1016
|
"status": "idle",
|
|
@@ -1077,7 +1053,6 @@ import numpy",
|
|
|
1077
1053
|
},
|
|
1078
1054
|
"runElapsedTimeMs": 13000,
|
|
1079
1055
|
"runStartTimestamp": null,
|
|
1080
|
-
"serialization": undefined,
|
|
1081
1056
|
"serializedEditorState": null,
|
|
1082
1057
|
"staleInputs": false,
|
|
1083
1058
|
"status": "idle",
|
|
@@ -1127,7 +1102,6 @@ import numpy",
|
|
|
1127
1102
|
},
|
|
1128
1103
|
"runElapsedTimeMs": 11000,
|
|
1129
1104
|
"runStartTimestamp": null,
|
|
1130
|
-
"serialization": undefined,
|
|
1131
1105
|
"serializedEditorState": null,
|
|
1132
1106
|
"staleInputs": false,
|
|
1133
1107
|
"status": "idle",
|
|
@@ -1175,7 +1149,6 @@ import numpy",
|
|
|
1175
1149
|
},
|
|
1176
1150
|
"runElapsedTimeMs": 11000,
|
|
1177
1151
|
"runStartTimestamp": null,
|
|
1178
|
-
"serialization": undefined,
|
|
1179
1152
|
"serializedEditorState": null,
|
|
1180
1153
|
"staleInputs": false,
|
|
1181
1154
|
"status": "idle",
|
|
@@ -1303,7 +1276,6 @@ exports[`cell reducer > errors reset status to idle 4`] = `
|
|
|
1303
1276
|
},
|
|
1304
1277
|
"runElapsedTimeMs": null,
|
|
1305
1278
|
"runStartTimestamp": null,
|
|
1306
|
-
"serialization": undefined,
|
|
1307
1279
|
"serializedEditorState": null,
|
|
1308
1280
|
"staleInputs": false,
|
|
1309
1281
|
"status": "idle",
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
|
-
import type { OutputMessage } from "@/core/kernel/messages";
|
|
3
|
+
import type { CellMessage, OutputMessage } from "@/core/kernel/messages";
|
|
4
4
|
import type { RuntimeState } from "@/core/network/types";
|
|
5
5
|
import type { Seconds } from "@/utils/time";
|
|
6
|
-
import { outputIsLoading, outputIsStale } from "../cell";
|
|
6
|
+
import { outputIsLoading, outputIsStale, transitionCell } from "../cell";
|
|
7
|
+
import { createCellRuntimeState } from "../types";
|
|
7
8
|
|
|
8
9
|
const STATUSES: RuntimeState[] = [
|
|
9
10
|
"queued",
|
|
@@ -191,3 +192,29 @@ describe("outputIsStale", () => {
|
|
|
191
192
|
expect(outputIsStale(cell, edited)).toBe(false);
|
|
192
193
|
});
|
|
193
194
|
});
|
|
195
|
+
|
|
196
|
+
describe("transitionCell serialization", () => {
|
|
197
|
+
function cellMessage(serialization?: string | null): CellMessage {
|
|
198
|
+
return {
|
|
199
|
+
cell_id: "cell-1",
|
|
200
|
+
...(serialization === undefined ? {} : { serialization }),
|
|
201
|
+
} as CellMessage;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
it("leaves the hint unchanged when serialization is omitted", () => {
|
|
205
|
+
const cell = createCellRuntimeState({ serialization: "Valid" });
|
|
206
|
+
expect(transitionCell(cell, cellMessage()).serialization).toBe("Valid");
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("clears the hint when serialization is null", () => {
|
|
210
|
+
const cell = createCellRuntimeState({ serialization: "Valid" });
|
|
211
|
+
expect(transitionCell(cell, cellMessage(null)).serialization).toBeNull();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("sets the hint when serialization is a string", () => {
|
|
215
|
+
const cell = createCellRuntimeState();
|
|
216
|
+
expect(transitionCell(cell, cellMessage("Valid")).serialization).toBe(
|
|
217
|
+
"Valid",
|
|
218
|
+
);
|
|
219
|
+
});
|
|
220
|
+
});
|
package/src/core/cells/cell.ts
CHANGED
|
@@ -73,7 +73,11 @@ export function transitionCell(
|
|
|
73
73
|
nextCell.output = message.output ?? nextCell.output;
|
|
74
74
|
nextCell.staleInputs = message.stale_inputs ?? nextCell.staleInputs;
|
|
75
75
|
nextCell.status = message.status ?? nextCell.status;
|
|
76
|
-
|
|
76
|
+
// Tri-state partial update: an omitted field (undefined) leaves the hint
|
|
77
|
+
// unchanged; null explicitly clears it; a string sets it.
|
|
78
|
+
if (message.serialization !== undefined) {
|
|
79
|
+
nextCell.serialization = message.serialization;
|
|
80
|
+
}
|
|
77
81
|
|
|
78
82
|
let didInterruptFromThisMessage = false;
|
|
79
83
|
|
|
@@ -28,10 +28,11 @@ interface VariableDeclaration {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function goToPosition(view: EditorView, from: number): void {
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
//
|
|
31
|
+
// Focus on the next frame: a synchronous focus is a no-op while a Radix
|
|
32
|
+
// context menu still owns focus, and codemirror would otherwise add a
|
|
33
|
+
// cursor from the pointer click.
|
|
34
34
|
requestAnimationFrame(() => {
|
|
35
|
+
view.focus();
|
|
35
36
|
view.dispatch({
|
|
36
37
|
selection: {
|
|
37
38
|
anchor: from,
|
|
@@ -33,6 +33,7 @@ import { cellActionsState } from "../../cells/state";
|
|
|
33
33
|
import { pythonCompletionSource } from "../../completion/completer";
|
|
34
34
|
import type { PlaceholderType } from "../../config/types";
|
|
35
35
|
import { FederatedLanguageServerClient } from "../../lsp/federated-lsp";
|
|
36
|
+
import { createLspMarkdownRenderer } from "../../lsp/markdown-renderer";
|
|
36
37
|
import { NotebookLanguageServerClient } from "../../lsp/notebook-lsp";
|
|
37
38
|
import { createTransport } from "../../lsp/transports";
|
|
38
39
|
import { CellDocumentUri, type ILanguageServerClient } from "../../lsp/types";
|
|
@@ -342,6 +343,7 @@ export class PythonLanguageAdapter implements LanguageAdapter<{}> {
|
|
|
342
343
|
client: client as unknown as LanguageServerClient,
|
|
343
344
|
languageId: "python",
|
|
344
345
|
allowHTMLContent: true,
|
|
346
|
+
markdownRenderer: createLspMarkdownRenderer(),
|
|
345
347
|
useSnippetOnCompletion: true,
|
|
346
348
|
hoverConfig: hoverOptions,
|
|
347
349
|
completionConfig: autocompleteOptions,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "@codemirror/lang-sql";
|
|
15
15
|
import {
|
|
16
16
|
BigQueryDialect,
|
|
17
|
+
DremioDialect,
|
|
17
18
|
DuckDBDialect,
|
|
18
19
|
} from "@marimo-team/codemirror-sql/dialects";
|
|
19
20
|
import type { DataSourceConnection } from "@/core/kernel/messages";
|
|
@@ -97,6 +98,8 @@ export function guessDialect(
|
|
|
97
98
|
return PLSQL;
|
|
98
99
|
case "bigquery":
|
|
99
100
|
return BigQueryDialect;
|
|
101
|
+
case "dremio":
|
|
102
|
+
return DremioDialect;
|
|
100
103
|
case "timescaledb":
|
|
101
104
|
return PostgreSQL; // TimescaleDB is a PostgreSQL dialect
|
|
102
105
|
case "awsathena":
|
|
@@ -116,7 +119,6 @@ export function guessDialect(
|
|
|
116
119
|
case "spark":
|
|
117
120
|
case "databricks":
|
|
118
121
|
case "datafusion":
|
|
119
|
-
case "dremio":
|
|
120
122
|
Logger.debug("Unsupported dialect", { dialect });
|
|
121
123
|
return ModifiedStandardSQL;
|
|
122
124
|
default:
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { createLspMarkdownRenderer } from "../markdown-renderer";
|
|
4
|
+
|
|
5
|
+
describe("createLspMarkdownRenderer", () => {
|
|
6
|
+
it("syntax-highlights python code blocks with tok-* span classes", () => {
|
|
7
|
+
const render = createLspMarkdownRenderer();
|
|
8
|
+
const result = render("```python\ndef foo():\n pass\n```");
|
|
9
|
+
expect(result).toContain('class="language-python"');
|
|
10
|
+
expect(result).toContain("tok-keyword");
|
|
11
|
+
expect(result).toContain("<pre><code");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("does not highlight non-python code blocks", () => {
|
|
15
|
+
const render = createLspMarkdownRenderer();
|
|
16
|
+
const result = render("```bash\necho hello\n```");
|
|
17
|
+
expect(result).not.toContain("tok-keyword");
|
|
18
|
+
expect(result).toContain("<code");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("renders empty python code blocks as empty string", () => {
|
|
22
|
+
const render = createLspMarkdownRenderer();
|
|
23
|
+
const result = render("```python\n \n```");
|
|
24
|
+
expect(result).toBe("");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("renders markdown prose unchanged", () => {
|
|
28
|
+
const render = createLspMarkdownRenderer();
|
|
29
|
+
const result = render("## Examples\n\nSome text.");
|
|
30
|
+
expect(result).toContain("<h2");
|
|
31
|
+
expect(result).toContain("Examples");
|
|
32
|
+
expect(result).toContain("Some text.");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("escapes HTML in highlighted code", () => {
|
|
36
|
+
const render = createLspMarkdownRenderer();
|
|
37
|
+
const result = render('```python\nx = "<div>"\n```');
|
|
38
|
+
expect(result).not.toContain("<div>");
|
|
39
|
+
expect(result).toContain("<div>");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { classHighlighter, highlightCode } from "@lezer/highlight";
|
|
3
|
+
import { parser as pythonParser } from "@lezer/python";
|
|
4
|
+
import { marked } from "marked";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Syntax-highlight a Python code string using the lezer Python parser.
|
|
8
|
+
* Returns an HTML string with tok-* span classes for styling.
|
|
9
|
+
*/
|
|
10
|
+
function highlightPython(code: string): string {
|
|
11
|
+
const tree = pythonParser.parse(code);
|
|
12
|
+
let html = "";
|
|
13
|
+
highlightCode(
|
|
14
|
+
code,
|
|
15
|
+
tree,
|
|
16
|
+
classHighlighter,
|
|
17
|
+
(text, classes) => {
|
|
18
|
+
const escaped = text
|
|
19
|
+
.replace(/&/g, "&")
|
|
20
|
+
.replace(/</g, "<")
|
|
21
|
+
.replace(/>/g, ">");
|
|
22
|
+
html += classes ? `<span class="${classes}">${escaped}</span>` : escaped;
|
|
23
|
+
},
|
|
24
|
+
() => {
|
|
25
|
+
html += "\n";
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
return html;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A markdown renderer for LSP hover tooltips that adds syntax highlighting
|
|
33
|
+
* to Python code blocks using the lezer Python parser and classHighlighter.
|
|
34
|
+
* The tok-* CSS classes are defined in documentation.css.
|
|
35
|
+
*/
|
|
36
|
+
export function createLspMarkdownRenderer(): (markdown: string) => string {
|
|
37
|
+
const renderer = new marked.Renderer();
|
|
38
|
+
const prevCode = renderer.code.bind(renderer);
|
|
39
|
+
|
|
40
|
+
renderer.code = (token) => {
|
|
41
|
+
const { text, lang } = token;
|
|
42
|
+
if (!text.trim()) {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
if (lang === "python" || lang === "py") {
|
|
46
|
+
const highlighted = highlightPython(text);
|
|
47
|
+
return `<pre><code class="language-python">${highlighted}</code></pre>\n`;
|
|
48
|
+
}
|
|
49
|
+
return prevCode(token);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (markdown: string): string =>
|
|
53
|
+
marked(markdown, {
|
|
54
|
+
async: false,
|
|
55
|
+
gfm: true,
|
|
56
|
+
breaks: true,
|
|
57
|
+
renderer,
|
|
58
|
+
}) as string;
|
|
59
|
+
}
|
|
@@ -169,6 +169,7 @@ const {
|
|
|
169
169
|
return {
|
|
170
170
|
...db,
|
|
171
171
|
schemas: schemas,
|
|
172
|
+
schemas_resolved: true,
|
|
172
173
|
};
|
|
173
174
|
}),
|
|
174
175
|
};
|
|
@@ -213,6 +214,7 @@ const {
|
|
|
213
214
|
return {
|
|
214
215
|
...schema,
|
|
215
216
|
tables: tables,
|
|
217
|
+
tables_resolved: true,
|
|
216
218
|
};
|
|
217
219
|
}),
|
|
218
220
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { toast } from "@/components/ui/use-toast";
|
|
4
|
+
import { createStaticRequests } from "../requests-static";
|
|
5
|
+
|
|
6
|
+
vi.mock("@/components/ui/use-toast", () => ({ toast: vi.fn() }));
|
|
7
|
+
|
|
8
|
+
describe("createStaticRequests static-notebook toast", () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
vi.mocked(toast).mockClear();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("requests a once-toast with a stable id on component value updates", async () => {
|
|
14
|
+
const requests = createStaticRequests();
|
|
15
|
+
await requests.sendComponentValues({} as never);
|
|
16
|
+
|
|
17
|
+
expect(toast).toHaveBeenCalledWith(
|
|
18
|
+
expect.objectContaining({ id: "static-notebook", once: true }),
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("uses the same once-toast for function requests", async () => {
|
|
23
|
+
const requests = createStaticRequests();
|
|
24
|
+
await requests.sendFunctionRequest({} as never);
|
|
25
|
+
|
|
26
|
+
expect(toast).toHaveBeenCalledWith(
|
|
27
|
+
expect.objectContaining({ id: "static-notebook", once: true }),
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
});
|