@marimo-team/islands 0.23.14-dev2 → 0.23.14-dev5
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/{chat-ui-CsPewo4h.js → chat-ui-BZxLHwyD.js} +2 -2
- package/dist/{code-visibility-CRYdBxcA.js → code-visibility-rxZi4Phe.js} +2 -2
- package/dist/{html-to-image-DXwLcQ6l.js → html-to-image-CGp_08St.js} +2145 -2114
- package/dist/main.js +5 -5
- package/dist/{process-output-C6_e1pT_.js → process-output-R6JsYrv3.js} +1 -1
- package/dist/{reveal-component-CbqUMhp8.js → reveal-component-sEb3Wd1x.js} +2 -2
- package/package.json +1 -1
- package/src/components/editor/chrome/panels/__tests__/snippet-display.test.ts +22 -0
- package/src/components/editor/chrome/panels/snippet-display.ts +27 -0
- package/src/components/editor/chrome/panels/snippets-panel.tsx +5 -2
- package/src/core/codemirror/completion/__tests__/signature-hint.test.ts +94 -0
- package/src/core/codemirror/completion/completer.ts +12 -1
- package/src/core/codemirror/completion/signature-hint.ts +68 -0
- package/src/core/codemirror/language/languages/python.ts +10 -4
- package/src/core/wasm/store.ts +1 -1
- /package/dist/{files → export_demos}/wasm-intro.py +0 -0
package/dist/main.js
CHANGED
|
@@ -22,17 +22,17 @@ import { _ as Logger, c as Objects, g as cn, h as Events, i as NOT_SET, l as use
|
|
|
22
22
|
import { t as require_react } from "./react-DA-nE2FX.js";
|
|
23
23
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
24
24
|
import { n as Copy, r as toast, t as copyToClipboard } from "./copy-COam1EG7.js";
|
|
25
|
-
import { $ as reducer, B as safeExtractSetUIElementMessageBuffers, Bn as CircleAlert, Bt as DATA_TYPE_ICON, C as AccordionContent, Cn as Root2$1, Ct as Checkbox, Dn as Table2, Dt as PathBuilder, E as BorderAllIcon, En as Trash2, F as base64ToDataView, Fn as Eye, H as getMarimoExportContext, Ht as require_client, It as jotaiJsonStorage, J as getCellNames, Jt as requestClientAtom, K as createActions, Kt as convertStatsName, L as dataViewToBase64, Ln as Database, Mn as Layers, Mt as generateUUID, Nn as Info, On as PaintRoller, Ot as Paths, Pn as FileText, Pt as repl, Q as numColumnsAtom, Rn as Columns2, S as Accordion, Sn as Item$1, St as normalizeName, T as AccordionTrigger, Tt as MarkdownLanguageAdapter, U as hasTrustedExportContext, V as renderHTML, Vn as Braces, W as hasRunAnyCellAtom, X as notebookAtom, Xt as isUninstantiated, Y as hasOnlyOneCellAtom, Yt as useRequestClient, Z as notebookOutline, _n as atomWithStorage, a as useCellFocusActions, an as parseDataset, bt as getValidName, cn as HTMLCellId, ct as initialModeAtom, dn as findCellId, et as useCellActions, f as isOutputEmpty, fn as OBJECT_ID_ATTR, ft as outputIsLoading, gn as atomWithReducer, ht as headingToIdentifier, i as LazyAnyLanguageCodeMirror, in as parseAttrValue, jn as LoaderCircle, jt as DeferredRequestRegistry, k as ChevronDownIcon, lt as kioskModeAtom, mn as jsonParseWithSpecialChar, mt as isErrorMime, n as Spinner, o as useLastFocusedCellId, on as parseInitialValue, p as useExpandedConsoleOutput, pn as RANDOM_ID_ATTR, pt as outputIsStale, qt as getRequestClient, rt as createCell, s as maybeAddAltairImport, st as getInitialAppMode, tn as NotebookScopedLocalStorage, tt as useCellIds, un as UIElementId, vn as selectAtom, w as AccordionItem, wn as Trigger2, wt as customPythonLanguageSupport, xn as Content2, xt as isInternalCellName, zt as PluralWords, __tla as __tla_0 } from "./html-to-image-
|
|
25
|
+
import { $ as reducer, B as safeExtractSetUIElementMessageBuffers, Bn as CircleAlert, Bt as DATA_TYPE_ICON, C as AccordionContent, Cn as Root2$1, Ct as Checkbox, Dn as Table2, Dt as PathBuilder, E as BorderAllIcon, En as Trash2, F as base64ToDataView, Fn as Eye, H as getMarimoExportContext, Ht as require_client, It as jotaiJsonStorage, J as getCellNames, Jt as requestClientAtom, K as createActions, Kt as convertStatsName, L as dataViewToBase64, Ln as Database, Mn as Layers, Mt as generateUUID, Nn as Info, On as PaintRoller, Ot as Paths, Pn as FileText, Pt as repl, Q as numColumnsAtom, Rn as Columns2, S as Accordion, Sn as Item$1, St as normalizeName, T as AccordionTrigger, Tt as MarkdownLanguageAdapter, U as hasTrustedExportContext, V as renderHTML, Vn as Braces, W as hasRunAnyCellAtom, X as notebookAtom, Xt as isUninstantiated, Y as hasOnlyOneCellAtom, Yt as useRequestClient, Z as notebookOutline, _n as atomWithStorage, a as useCellFocusActions, an as parseDataset, bt as getValidName, cn as HTMLCellId, ct as initialModeAtom, dn as findCellId, et as useCellActions, f as isOutputEmpty, fn as OBJECT_ID_ATTR, ft as outputIsLoading, gn as atomWithReducer, ht as headingToIdentifier, i as LazyAnyLanguageCodeMirror, in as parseAttrValue, jn as LoaderCircle, jt as DeferredRequestRegistry, k as ChevronDownIcon, lt as kioskModeAtom, mn as jsonParseWithSpecialChar, mt as isErrorMime, n as Spinner, o as useLastFocusedCellId, on as parseInitialValue, p as useExpandedConsoleOutput, pn as RANDOM_ID_ATTR, pt as outputIsStale, qt as getRequestClient, rt as createCell, s as maybeAddAltairImport, st as getInitialAppMode, tn as NotebookScopedLocalStorage, tt as useCellIds, un as UIElementId, vn as selectAtom, w as AccordionItem, wn as Trigger2, wt as customPythonLanguageSupport, xn as Content2, xt as isInternalCellName, zt as PluralWords, __tla as __tla_0 } from "./html-to-image-CGp_08St.js";
|
|
26
26
|
import { __tla as __tla_1 } from "./chunk-5FQGJX7Z-BbqSm5gU.js";
|
|
27
27
|
import { o as useSize, s as Root$1, u as createLucideIcon } from "./dist--2Bqjvs0.js";
|
|
28
28
|
import { A as SquareFunction, C as DEFAULT_COLOR_SCHEME, D as SCALE_TYPE_DESCRIPTIONS, E as EMPTY_VALUE$1, O as TIME_UNIT_DESCRIPTIONS, S as DEFAULT_AGGREGATION, T as DEFAULT_TIME_UNIT, _ as AGGREGATION_TYPE_DESCRIPTIONS, a as AGGREGATION_FNS$1, b as COLOR_SCHEMES, c as COLOR_BY_FIELDS, d as NONE_VALUE, f as SELECTABLE_DATA_TYPES, g as TIME_UNITS, h as STRING_AGGREGATION_FNS, i as convertDataTypeToSelectable, j as ChartColumn, k as escapeFieldName, l as COMBINED_TIME_UNITS, m as SORT_TYPES, n as createSpecWithoutData, o as BIN_AGGREGATION, p as SINGLE_TIME_UNITS, r as isFieldSet, s as CHART_TYPES, t as augmentSpecWithData, u as ChartType, v as AGGREGATION_TYPE_ICON, w as DEFAULT_MAX_BINS_FACET, x as COUNT_FIELD, y as CHART_TYPE_ICON } from "./spec-Bv-XlYiv.js";
|
|
29
|
-
import { $ as contextAwarePanelOpen, $t as EmotionCacheProvider, A as prettifyRowCount, At as SELECT_COLUMN_ID, B as DatePicker, Bt as dateToLocalISOTime, C as downloadSizeLimitAtom, Ct as DelayMount, D as ErrorState, Dt as loadTableAndRawData, E as EmptyState, Et as getPageIndexForRow, F as ContextMenuSeparator, Ft as isRecord, G as CommandEmpty, Gt as ChartErrorState, H as Combobox, Ht as TabsContent, I as ContextMenuTrigger, It as isNullishFilter, J as CommandList, Jt as LazyVegaEmbed, K as CommandInput, Kt as ChartInfoState, L as useInternalStateWithSync, Lt as Maps, M as ContextMenu, Mt as toFieldTypes, N as ContextMenuContent, Nt as getMimeValues, O as LoadingState, Ot as loadTableData, P as ContextMenuItem, Pt as hasFunctionProperty, Q as PANEL_TYPES, Qt as HtmlOutput, R as useSelectList, Rt as dateToLocalISODate, S as Filenames, St as ColumnChartSpecModel, T as ColumnPreviewContainer, Tt as usePrevious$1, U as ComboboxItem, Ut as TabsList, V as DateRangePicker, Vt as Tabs, W as Command, Wt as TabsTrigger, X as smartMatch, Xt as RenderTextWithLinks, Y as CommandSeparator, Yt as useOverflowDetection, Z as ContextAwarePanelItem, Zt as Kbd, _ as ADD_PRINTING_CLASS, _t as NAMELESS_COLUMN_PREFIX, an as EyeOff, at as Toggle, b as downloadHTMLAsImage, bt as renderCellValue, c as Slide, cn as Download, d as RadioGroupItem, dn as ChevronsRight, dt as Table, en as $fae977aafc393c5c$export$588937bcd60ade55, et as contextAwarePanelOwner, f as JsonOutput, fn as ChevronsLeft, ft as TableBody, g as InstallPackageButton, gt as TableRow, h as DataTable, hn as ArrowDownWideNarrow, ht as TableHeader, in as Funnel, it as slotsController, j as getColumnCountForDisplay, jt as TOO_MANY_ROWS, k as prettifyRowColumnCount, kt as INDEX_COLUMN_NAME, l as Switch, ln as Code, lt as Fill, m as OutputRenderer, mn as ChevronLeft, mt as TableHead, n as marimoVersionAtom, nn as TextWrap, nt as isCellAwareAtom, o as SLIDE_TYPE_OPTIONS_BY_VALUE, p as OutputArea, pn as ChevronsDownUp, pt as TableCell, q as CommandItem, qt as ChartLoadingState, r as showCodeInRunModeAtom, rn as GripHorizontal, rt as SlotNames, sn as Ellipsis, t as useNotebookCodeAvailable, tn as $fae977aafc393c5c$export$6b862160d295c8e, tt as contextAwarePanelType, u as RadioGroup, un as ChevronsUpDown, ut as Provider$1, v as downloadBlob, vt as generateColumns, w as ColumnName, wt as useIntersectionObserver, x as Progress, xt as ColumnChartContext, y as downloadByURL, yt as inferFieldTypes, z as CompactChipRow, zt as dateToLocalISODateTime, __tla as __tla_2 } from "./code-visibility-
|
|
29
|
+
import { $ as contextAwarePanelOpen, $t as EmotionCacheProvider, A as prettifyRowCount, At as SELECT_COLUMN_ID, B as DatePicker, Bt as dateToLocalISOTime, C as downloadSizeLimitAtom, Ct as DelayMount, D as ErrorState, Dt as loadTableAndRawData, E as EmptyState, Et as getPageIndexForRow, F as ContextMenuSeparator, Ft as isRecord, G as CommandEmpty, Gt as ChartErrorState, H as Combobox, Ht as TabsContent, I as ContextMenuTrigger, It as isNullishFilter, J as CommandList, Jt as LazyVegaEmbed, K as CommandInput, Kt as ChartInfoState, L as useInternalStateWithSync, Lt as Maps, M as ContextMenu, Mt as toFieldTypes, N as ContextMenuContent, Nt as getMimeValues, O as LoadingState, Ot as loadTableData, P as ContextMenuItem, Pt as hasFunctionProperty, Q as PANEL_TYPES, Qt as HtmlOutput, R as useSelectList, Rt as dateToLocalISODate, S as Filenames, St as ColumnChartSpecModel, T as ColumnPreviewContainer, Tt as usePrevious$1, U as ComboboxItem, Ut as TabsList, V as DateRangePicker, Vt as Tabs, W as Command, Wt as TabsTrigger, X as smartMatch, Xt as RenderTextWithLinks, Y as CommandSeparator, Yt as useOverflowDetection, Z as ContextAwarePanelItem, Zt as Kbd, _ as ADD_PRINTING_CLASS, _t as NAMELESS_COLUMN_PREFIX, an as EyeOff, at as Toggle, b as downloadHTMLAsImage, bt as renderCellValue, c as Slide, cn as Download, d as RadioGroupItem, dn as ChevronsRight, dt as Table, en as $fae977aafc393c5c$export$588937bcd60ade55, et as contextAwarePanelOwner, f as JsonOutput, fn as ChevronsLeft, ft as TableBody, g as InstallPackageButton, gt as TableRow, h as DataTable, hn as ArrowDownWideNarrow, ht as TableHeader, in as Funnel, it as slotsController, j as getColumnCountForDisplay, jt as TOO_MANY_ROWS, k as prettifyRowColumnCount, kt as INDEX_COLUMN_NAME, l as Switch, ln as Code, lt as Fill, m as OutputRenderer, mn as ChevronLeft, mt as TableHead, n as marimoVersionAtom, nn as TextWrap, nt as isCellAwareAtom, o as SLIDE_TYPE_OPTIONS_BY_VALUE, p as OutputArea, pn as ChevronsDownUp, pt as TableCell, q as CommandItem, qt as ChartLoadingState, r as showCodeInRunModeAtom, rn as GripHorizontal, rt as SlotNames, sn as Ellipsis, t as useNotebookCodeAvailable, tn as $fae977aafc393c5c$export$6b862160d295c8e, tt as contextAwarePanelType, u as RadioGroup, un as ChevronsUpDown, ut as Provider$1, v as downloadBlob, vt as generateColumns, w as ColumnName, wt as useIntersectionObserver, x as Progress, xt as ColumnChartContext, y as downloadByURL, yt as inferFieldTypes, z as CompactChipRow, zt as dateToLocalISODateTime, __tla as __tla_2 } from "./code-visibility-rxZi4Phe.js";
|
|
30
30
|
import { c as Calendar, i as createReducerAndAtoms, n as useOnUnmount, o as ToggleLeft, t as useOnMount } from "./useLifecycle-AHlswLw-.js";
|
|
31
31
|
import { t as Check } from "./check-C9OoNtR4.js";
|
|
32
32
|
import { A as Icon, C as logNever, D as $18f2051aff69b9bf$export$a54013f0d02a8f82, E as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, F as createCollection, I as X, M as clamp$2, N as usePrevious$2, P as useDirection, R as ChevronDown, S as assertNever, a as SelectGroup, c as SelectSeparator, d as NativeSelect, i as SelectContent, j as Trigger$1, l as SelectTrigger, n as capitalize, o as SelectItem, r as Select, s as SelectLabel, t as Strings, u as SelectValue, w as $a916eb452884faea$export$b7a616150fdb9f44 } from "./strings-Dq_j3Rxw.js";
|
|
33
33
|
import { B as $64fa3d84918910a7$export$4d86445c2cf5e3, C as DropdownMenuTrigger, Ft as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, It as $3ef42575df84b30b$export$9d1611c77c2fe928, W as $64fa3d84918910a7$export$df3a06d6289f983e, Wt as $ff5963eb1fccf552$export$e08e3b67e392101e, X as useDebouncedCallback, Y as useDebounceControlledState, a as NumberField, d as roundToFractionDigits, f as DropdownMenu, g as DropdownMenuLabel, gn as ChevronRight, h as DropdownMenuItem, hn as Circle, i as OnBlurredInput, l as prettyNumber, m as DropdownMenuGroup, n as DebouncedNumberInput, o as maxFractionDigitsForSteps, ot as $f7dceffc5ad7768b$export$4e328f61c538687f, p as DropdownMenuContent, pt as $6179b936705e76d3$export$ae780daf29e6d456, r as Input, st as $701a24aa0da5b062$export$ea18c227d4417cc3, t as DebouncedInput, u as prettyScientificNumber, v as DropdownMenuSeparator, xt as $458b0a5536c1a7cf$export$40bfa8c7b0832715, y as DropdownMenuShortcut, z as $64fa3d84918910a7$export$29f1550f4b0d4415 } from "./input-CbEz_aj_.js";
|
|
34
34
|
import { _ as isWasm, c as asRemoteURL, d as isStaticNotebook, f as appendQueryParams, g as Deferred, m as require_cuid2, u as getStaticVirtualFiles, v as CircleQuestionMark } from "./toDate-D-l5s8nn.js";
|
|
35
|
-
import { a as MarimoIncomingMessageEvent, c as MarimoValueUpdateEvent, d as Square, f as File, i as PythonIcon, l as createInputEvent, n as blobToString, o as MarimoValueInputEvent, r as filesToBase64, s as MarimoValueReadyEvent, t as processOutput, u as deserializeBlob } from "./process-output-
|
|
35
|
+
import { a as MarimoIncomingMessageEvent, c as MarimoValueUpdateEvent, d as Square, f as File, i as PythonIcon, l as createInputEvent, n as blobToString, o as MarimoValueInputEvent, r as filesToBase64, s as MarimoValueReadyEvent, t as processOutput, u as deserializeBlob } from "./process-output-R6JsYrv3.js";
|
|
36
36
|
import { n as Trash, r as Pencil, t as BulkEdit } from "./types-C2Ir191_.js";
|
|
37
37
|
import { n as require_prop_types, r as Plus, t as ErrorBoundary } from "./ErrorBoundary-DE6tzZf-.js";
|
|
38
38
|
import { t as require_react_dom } from "./react-dom-BTJzcVJ9.js";
|
|
@@ -8576,7 +8576,7 @@ let __tla = Promise.all([
|
|
|
8576
8576
|
};
|
|
8577
8577
|
}
|
|
8578
8578
|
};
|
|
8579
|
-
var LazyChatbot = import_react.lazy(() => import("./chat-ui-
|
|
8579
|
+
var LazyChatbot = import_react.lazy(() => import("./chat-ui-BZxLHwyD.js").then((e) => ({
|
|
8580
8580
|
default: e.Chatbot
|
|
8581
8581
|
}))), messageSchema = array(object({
|
|
8582
8582
|
id: string(),
|
|
@@ -36235,7 +36235,7 @@ ${c}
|
|
|
36235
36235
|
function _temp2$2(e) {
|
|
36236
36236
|
e.target === e.currentTarget && e.key === "Enter" && (e.preventDefault(), e.stopPropagation(), e.currentTarget.click());
|
|
36237
36237
|
}
|
|
36238
|
-
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-
|
|
36238
|
+
var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-sEb3Wd1x.js"));
|
|
36239
36239
|
const SlidesLayoutRenderer = ({ layout: e, setLayout: r, cells: c, mode: l }) => {
|
|
36240
36240
|
var _a3;
|
|
36241
36241
|
let u = useAtomValue(kioskModeAtom), d = l === "read" || u, f = useAtomValue(numColumnsAtom) > 1, [p, m] = (0, import_react.useState)(null), { slideCells: h, skippedIds: g, noOutputIds: _, slideTypes: v, startCellIndex: y } = (0, import_react.useMemo)(() => computeSlideCellsInfo(c, e), [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as __toESM } from "./chunk-BNovOVIE.js";
|
|
2
2
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
3
|
-
import { at as parseHtmlContent, it as ansiToPlainText } from "./html-to-image-
|
|
3
|
+
import { at as parseHtmlContent, it as ansiToPlainText } from "./html-to-image-CGp_08St.js";
|
|
4
4
|
import { u as createLucideIcon } from "./dist--2Bqjvs0.js";
|
|
5
5
|
import { t as Strings } from "./strings-Dq_j3Rxw.js";
|
|
6
6
|
import { t as require_jsx_runtime } from "./jsx-runtime-DebpN0FN.js";
|
|
@@ -6,10 +6,10 @@ import { s as __toESM } from "./chunk-BNovOVIE.js";
|
|
|
6
6
|
import { _ as Logger, g as cn, h as Events, l as useEventListener, t as Button } from "./button-BacYv-bE.js";
|
|
7
7
|
import { t as require_react } from "./react-DA-nE2FX.js";
|
|
8
8
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
9
|
-
import { lt as kioskModeAtom } from "./html-to-image-
|
|
9
|
+
import { lt as kioskModeAtom } from "./html-to-image-CGp_08St.js";
|
|
10
10
|
import "./chunk-5FQGJX7Z-BbqSm5gU.js";
|
|
11
11
|
import { u as createLucideIcon } from "./dist--2Bqjvs0.js";
|
|
12
|
-
import { a as DEFAULT_SLIDE_TYPE, an as EyeOff, c as Slide, ct as PanelResizeHandle, i as DEFAULT_DECK_TRANSITION, ln as Code, on as Expand, ot as Panel, s as SlideSidebar, st as PanelGroup, t as useNotebookCodeAvailable } from "./code-visibility-
|
|
12
|
+
import { a as DEFAULT_SLIDE_TYPE, an as EyeOff, c as Slide, ct as PanelResizeHandle, i as DEFAULT_DECK_TRANSITION, ln as Code, on as Expand, ot as Panel, s as SlideSidebar, st as PanelGroup, t as useNotebookCodeAvailable } from "./code-visibility-rxZi4Phe.js";
|
|
13
13
|
import { X as useDebouncedCallback } from "./input-CbEz_aj_.js";
|
|
14
14
|
import "./toDate-D-l5s8nn.js";
|
|
15
15
|
import "./react-dom-BTJzcVJ9.js";
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { getSnippetDisplay } from "../snippet-display";
|
|
5
|
+
|
|
6
|
+
describe("getSnippetDisplay", () => {
|
|
7
|
+
it("shows sql cells as the sql query", () => {
|
|
8
|
+
const { language, value } = getSnippetDisplay(
|
|
9
|
+
'df = mo.sql("""SELECT * FROM users LIMIT 5""")',
|
|
10
|
+
);
|
|
11
|
+
expect(language).toBe("sql");
|
|
12
|
+
expect(value).toBe("SELECT * FROM users LIMIT 5");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("keeps plain python cells as python", () => {
|
|
16
|
+
const code = "x = 1 + 2\nprint(x)";
|
|
17
|
+
expect(getSnippetDisplay(code)).toEqual({
|
|
18
|
+
language: "python",
|
|
19
|
+
value: code,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { SQLParser } from "@marimo-team/smart-cells";
|
|
4
|
+
|
|
5
|
+
export type SnippetLanguage = "python" | "sql";
|
|
6
|
+
|
|
7
|
+
export interface SnippetDisplay {
|
|
8
|
+
language: SnippetLanguage;
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const sqlParser = new SQLParser();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Decide how a snippet's code should be shown in the panel.
|
|
16
|
+
*
|
|
17
|
+
* SQL cells are stored as python `mo.sql(...)`. Unwrap the inner query and
|
|
18
|
+
* highlight it as SQL, matching how the cell renders once the snippet is
|
|
19
|
+
* inserted. Everything else stays python.
|
|
20
|
+
*/
|
|
21
|
+
export function getSnippetDisplay(code: string): SnippetDisplay {
|
|
22
|
+
if (sqlParser.isSupported(code)) {
|
|
23
|
+
const { code: query } = sqlParser.transformIn(code);
|
|
24
|
+
return { language: "sql", value: query };
|
|
25
|
+
}
|
|
26
|
+
return { language: "python", value: code };
|
|
27
|
+
}
|
|
@@ -31,6 +31,7 @@ import { cn } from "@/utils/cn";
|
|
|
31
31
|
import { HideInKioskMode } from "../../kiosk-mode";
|
|
32
32
|
import { ContributeSnippetButton } from "../components/contribute-snippet-button";
|
|
33
33
|
import { usePanelOrientation, usePanelSection } from "./panel-context";
|
|
34
|
+
import { getSnippetDisplay } from "./snippet-display";
|
|
34
35
|
|
|
35
36
|
const extensions = [EditorView.lineWrapping];
|
|
36
37
|
|
|
@@ -187,6 +188,8 @@ const SnippetViewer: React.FC<{ snippet: Snippet; onClose: () => void }> = ({
|
|
|
187
188
|
return null;
|
|
188
189
|
}
|
|
189
190
|
|
|
191
|
+
const { language, value } = getSnippetDisplay(code);
|
|
192
|
+
|
|
190
193
|
return (
|
|
191
194
|
<div
|
|
192
195
|
className="relative hover-actions-parent pr-2"
|
|
@@ -210,10 +213,10 @@ const SnippetViewer: React.FC<{ snippet: Snippet; onClose: () => void }> = ({
|
|
|
210
213
|
<LazyAnyLanguageCodeMirror
|
|
211
214
|
key={`${snippet.title}-${id}`}
|
|
212
215
|
theme={theme === "dark" ? "dark" : "light"}
|
|
213
|
-
language=
|
|
216
|
+
language={language}
|
|
214
217
|
className="cm border rounded overflow-hidden"
|
|
215
218
|
extensions={extensions}
|
|
216
|
-
value={
|
|
219
|
+
value={value}
|
|
217
220
|
readOnly={true}
|
|
218
221
|
/>
|
|
219
222
|
</Suspense>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { EditorState } from "@codemirror/state";
|
|
4
|
+
import { EditorView, type Tooltip } from "@codemirror/view";
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
import {
|
|
7
|
+
asSignatureHint,
|
|
8
|
+
setSignatureHintEffect,
|
|
9
|
+
signatureHintField,
|
|
10
|
+
} from "../signature-hint";
|
|
11
|
+
|
|
12
|
+
function fakeTooltip(pos: number): Tooltip {
|
|
13
|
+
return {
|
|
14
|
+
pos,
|
|
15
|
+
above: true,
|
|
16
|
+
create: () => ({ dom: document.createElement("div") }),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function stateWithHint(doc: string, pos: number): EditorState {
|
|
21
|
+
const state = EditorState.create({
|
|
22
|
+
doc,
|
|
23
|
+
extensions: [signatureHintField],
|
|
24
|
+
});
|
|
25
|
+
return state.update({ effects: setSignatureHintEffect.of(fakeTooltip(pos)) })
|
|
26
|
+
.state;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe("signatureHintField", () => {
|
|
30
|
+
it("starts empty", () => {
|
|
31
|
+
const state = EditorState.create({ extensions: [signatureHintField] });
|
|
32
|
+
expect(state.field(signatureHintField)).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("shows a tooltip when the effect is dispatched", () => {
|
|
36
|
+
const state = stateWithHint("plt.plot(", 9);
|
|
37
|
+
expect(state.field(signatureHintField)?.pos).toBe(9);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("clears the tooltip when the effect dispatches null", () => {
|
|
41
|
+
let state = stateWithHint("plt.plot(", 9);
|
|
42
|
+
state = state.update({
|
|
43
|
+
effects: setSignatureHintEffect.of(null),
|
|
44
|
+
}).state;
|
|
45
|
+
expect(state.field(signatureHintField)).toBeNull();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("dismisses the tooltip on a selection-only change", () => {
|
|
49
|
+
let state = stateWithHint("plt.plot(x)", 9);
|
|
50
|
+
state = state.update({ selection: { anchor: 0 } }).state;
|
|
51
|
+
expect(state.field(signatureHintField)).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("keeps and re-anchors the tooltip across edits", () => {
|
|
55
|
+
let state = stateWithHint("plt.plot(", 9);
|
|
56
|
+
// Insert before the tooltip position; it should shift to stay anchored.
|
|
57
|
+
state = state.update({ changes: { from: 0, insert: "xy" } }).state;
|
|
58
|
+
expect(state.field(signatureHintField)?.pos).toBe(11);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("asSignatureHint", () => {
|
|
63
|
+
it("nests the content so descendant styling applies", () => {
|
|
64
|
+
const content = document.createElement("span");
|
|
65
|
+
content.classList.add("mo-cm-tooltip", "docs-documentation");
|
|
66
|
+
const base: Tooltip = {
|
|
67
|
+
pos: 0,
|
|
68
|
+
create: () => ({ dom: content, resize: false }),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const view = new EditorView({ state: EditorState.create({}) });
|
|
72
|
+
const { dom } = asSignatureHint(base).create(view);
|
|
73
|
+
|
|
74
|
+
// Outer wrapper carries the tooltip sizing class...
|
|
75
|
+
expect(dom.classList.contains("mo-cm-tooltip")).toBe(true);
|
|
76
|
+
// ...and the documentation content is a descendant (not the same node),
|
|
77
|
+
// so `.cm-tooltip .docs-documentation` padding/font rules match.
|
|
78
|
+
expect(dom).not.toBe(content);
|
|
79
|
+
expect(dom.querySelector(".docs-documentation")).toBe(content);
|
|
80
|
+
|
|
81
|
+
view.destroy();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("preserves other tooltip fields", () => {
|
|
85
|
+
const base: Tooltip = {
|
|
86
|
+
pos: 5,
|
|
87
|
+
above: true,
|
|
88
|
+
create: () => ({ dom: document.createElement("span"), resize: false }),
|
|
89
|
+
};
|
|
90
|
+
const wrapped = asSignatureHint(base);
|
|
91
|
+
expect(wrapped.pos).toBe(5);
|
|
92
|
+
expect(wrapped.above).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -9,6 +9,7 @@ import { documentationAtom } from "@/core/documentation/state";
|
|
|
9
9
|
import { store } from "@/core/state/jotai";
|
|
10
10
|
import { Logger } from "../../../utils/Logger";
|
|
11
11
|
import { AUTOCOMPLETER, Autocompleter } from "./Autocompleter";
|
|
12
|
+
import { asSignatureHint, setSignatureHintEffect } from "./signature-hint";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Completion source for Python, using Jedi.
|
|
@@ -36,10 +37,12 @@ export const pythonCompletionSource: CompletionSource = async (
|
|
|
36
37
|
cellId: cellId,
|
|
37
38
|
});
|
|
38
39
|
if (!result) {
|
|
40
|
+
context.view?.dispatch({ effects: setSignatureHintEffect.of(null) });
|
|
39
41
|
return null;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
// If it is a tooltip, show it as a
|
|
44
|
+
// If it is a tooltip (e.g. a signature after `(` or `,`), show it as a
|
|
45
|
+
// Tooltip instead of a completion.
|
|
43
46
|
const tooltip = Autocompleter.asHoverTooltip({
|
|
44
47
|
position: context.pos,
|
|
45
48
|
message: result,
|
|
@@ -50,6 +53,14 @@ export const pythonCompletionSource: CompletionSource = async (
|
|
|
50
53
|
documentation: tooltip.html ?? null,
|
|
51
54
|
});
|
|
52
55
|
}
|
|
56
|
+
// Surface the signature as a floating hint near the cursor (the LSP path has
|
|
57
|
+
// its own signature help), and clear any stale hint when we instead have a
|
|
58
|
+
// real completion list.
|
|
59
|
+
context.view?.dispatch({
|
|
60
|
+
effects: setSignatureHintEffect.of(
|
|
61
|
+
tooltip ? asSignatureHint(tooltip) : null,
|
|
62
|
+
),
|
|
63
|
+
});
|
|
53
64
|
if (tooltip) {
|
|
54
65
|
return null;
|
|
55
66
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { StateEffect, StateField } from "@codemirror/state";
|
|
3
|
+
import { showTooltip, type Tooltip } from "@codemirror/view";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Effect to set (or clear, with `null`) the floating signature hint.
|
|
7
|
+
*/
|
|
8
|
+
export const setSignatureHintEffect = StateEffect.define<Tooltip | null>();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wrap a tooltip so it renders like the completion popup's info box.
|
|
12
|
+
*
|
|
13
|
+
* CodeMirror adds `cm-tooltip` directly to the DOM node returned by `create`,
|
|
14
|
+
* so the documentation content ends up on the same element as `cm-tooltip`.
|
|
15
|
+
* Our styling for padding/font (`.cm-tooltip .docs-documentation`) is a
|
|
16
|
+
* descendant selector, so we nest the content one level deeper to make it
|
|
17
|
+
* apply — mirroring how CodeMirror nests completion info inside its own
|
|
18
|
+
* wrapper. The outer `mo-cm-tooltip` class picks up the shared tooltip sizing.
|
|
19
|
+
*/
|
|
20
|
+
export function asSignatureHint(tooltip: Tooltip): Tooltip {
|
|
21
|
+
return {
|
|
22
|
+
...tooltip,
|
|
23
|
+
create: (view) => {
|
|
24
|
+
const { dom: content, ...rest } = tooltip.create(view);
|
|
25
|
+
const dom = document.createElement("div");
|
|
26
|
+
dom.classList.add("mo-cm-tooltip");
|
|
27
|
+
dom.append(content);
|
|
28
|
+
return { ...rest, dom };
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds the floating "signature hint" shown after typing `(` or `,` inside a
|
|
35
|
+
* call on the non-LSP (Jedi) completion path.
|
|
36
|
+
*
|
|
37
|
+
* The LSP path has its own signature help; this fills the gap for users
|
|
38
|
+
* without a language server. The completion source (`pythonCompletionSource`)
|
|
39
|
+
* drives it: it dispatches `setSignatureHintEffect` with the tooltip when the
|
|
40
|
+
* backend returns a signature and with `null` otherwise. The hint is also
|
|
41
|
+
* cleared when the cursor moves via a selection-only change (e.g. clicking
|
|
42
|
+
* away or arrowing out of the call), and kept anchored across edits so it
|
|
43
|
+
* doesn't flicker while a fresh result is in flight.
|
|
44
|
+
*/
|
|
45
|
+
export const signatureHintField = StateField.define<Tooltip | null>({
|
|
46
|
+
create: () => null,
|
|
47
|
+
update(tooltip, tr) {
|
|
48
|
+
for (const effect of tr.effects) {
|
|
49
|
+
if (effect.is(setSignatureHintEffect)) {
|
|
50
|
+
return effect.value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!tooltip) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
// Cursor moved without editing (click / arrow key): dismiss the hint.
|
|
57
|
+
if (tr.selection && !tr.docChanged) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
// Keep the hint anchored across edits; the completion source refreshes or
|
|
61
|
+
// clears it as new results arrive.
|
|
62
|
+
if (tr.docChanged) {
|
|
63
|
+
return { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) };
|
|
64
|
+
}
|
|
65
|
+
return tooltip;
|
|
66
|
+
},
|
|
67
|
+
provide: (field) => showTooltip.from(field),
|
|
68
|
+
});
|
|
@@ -31,6 +31,7 @@ import { Logger } from "@/utils/Logger";
|
|
|
31
31
|
import { once } from "@/utils/once";
|
|
32
32
|
import { cellActionsState } from "../../cells/state";
|
|
33
33
|
import { pythonCompletionSource } from "../../completion/completer";
|
|
34
|
+
import { signatureHintField } from "../../completion/signature-hint";
|
|
34
35
|
import type { PlaceholderType } from "../../config/types";
|
|
35
36
|
import { FederatedLanguageServerClient } from "../../lsp/federated-lsp";
|
|
36
37
|
import { createLspMarkdownRenderer } from "../../lsp/markdown-renderer";
|
|
@@ -376,10 +377,15 @@ export class PythonLanguageAdapter implements LanguageAdapter<{}> {
|
|
|
376
377
|
];
|
|
377
378
|
}
|
|
378
379
|
|
|
379
|
-
return
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
380
|
+
return [
|
|
381
|
+
autocompletion({
|
|
382
|
+
...autocompleteOptions,
|
|
383
|
+
override: [pythonCompletionSource],
|
|
384
|
+
}),
|
|
385
|
+
// The Jedi path has no built-in signature help; show a floating hint
|
|
386
|
+
// fed by `pythonCompletionSource` (the LSP path handles this itself).
|
|
387
|
+
signatureHintField,
|
|
388
|
+
];
|
|
383
389
|
};
|
|
384
390
|
|
|
385
391
|
return [
|
package/src/core/wasm/store.ts
CHANGED
|
@@ -62,7 +62,7 @@ const remoteDefaultFileStore: FileStore = {
|
|
|
62
62
|
if (window.location.hostname !== "marimo.app") {
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
|
-
const url = new URL("
|
|
65
|
+
const url = new URL("export_demos/wasm-intro.py", document.baseURI);
|
|
66
66
|
return fetch(url.toString())
|
|
67
67
|
.then((res) => (res.ok ? res.text() : null))
|
|
68
68
|
.catch(() => null);
|
|
File without changes
|