@marimo-team/islands 0.23.1 → 0.23.2-dev10
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-CNHw9Osh.js → chat-ui-Bi0ioKDx.js} +1 -1
- package/dist/main.js +41 -7
- package/dist/{process-output-Bekznt_B.js → process-output-H_7QTreh.js} +2133 -2119
- package/package.json +1 -1
- package/src/components/editor/Output.tsx +1 -1
- package/src/core/codemirror/language/languages/python.ts +9 -9
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +8 -1
- package/src/core/codemirror/lsp/federated-lsp.ts +2 -2
- package/src/core/codemirror/lsp/notebook-lsp.ts +2 -2
- package/src/core/codemirror/lsp/utils.ts +21 -6
- package/src/plugins/impl/plotly/__tests__/PlotlyPlugin.test.tsx +50 -0
- package/src/plugins/impl/plotly/__tests__/selection.test.ts +82 -0
- package/src/plugins/impl/plotly/selection.ts +62 -3
package/package.json
CHANGED
|
@@ -263,7 +263,7 @@ const MimeBundleOutputRenderer: React.FC<{
|
|
|
263
263
|
const { mode } = useAtomValue(viewStateAtom);
|
|
264
264
|
const appView = mode === "present" || mode === "read";
|
|
265
265
|
|
|
266
|
-
// Extract metadata if present (e.g.,
|
|
266
|
+
// Extract metadata if present (e.g., to maintain a constant display size regardless of DPI/PPI)
|
|
267
267
|
const metadata = mimebundle[METADATA_KEY];
|
|
268
268
|
|
|
269
269
|
// Filter out metadata from the mime entries and type narrow
|
|
@@ -36,7 +36,7 @@ import { FederatedLanguageServerClient } from "../../lsp/federated-lsp";
|
|
|
36
36
|
import { NotebookLanguageServerClient } from "../../lsp/notebook-lsp";
|
|
37
37
|
import { createTransport } from "../../lsp/transports";
|
|
38
38
|
import { CellDocumentUri, type ILanguageServerClient } from "../../lsp/types";
|
|
39
|
-
import {
|
|
39
|
+
import { getLspRootUri, getLspWorkspaceFolders } from "../../lsp/utils";
|
|
40
40
|
import {
|
|
41
41
|
clickablePlaceholderExtension,
|
|
42
42
|
smartPlaceholderExtension,
|
|
@@ -54,8 +54,8 @@ const pylspClient = once((lspConfig: LSPConfig) => {
|
|
|
54
54
|
|
|
55
55
|
const lspClientOpts = {
|
|
56
56
|
transport,
|
|
57
|
-
rootUri:
|
|
58
|
-
workspaceFolders:
|
|
57
|
+
rootUri: getLspRootUri(),
|
|
58
|
+
workspaceFolders: getLspWorkspaceFolders(),
|
|
59
59
|
};
|
|
60
60
|
const config = lspConfig?.pylsp;
|
|
61
61
|
|
|
@@ -161,8 +161,8 @@ const tyLspClient = once((_: LSPConfig) => {
|
|
|
161
161
|
|
|
162
162
|
const lspClientOpts = {
|
|
163
163
|
transport,
|
|
164
|
-
rootUri:
|
|
165
|
-
workspaceFolders:
|
|
164
|
+
rootUri: getLspRootUri(),
|
|
165
|
+
workspaceFolders: getLspWorkspaceFolders(),
|
|
166
166
|
};
|
|
167
167
|
|
|
168
168
|
// We wrap the client in a NotebookLanguageServerClient to add some
|
|
@@ -192,8 +192,8 @@ const pyreflyClient = once(
|
|
|
192
192
|
|
|
193
193
|
const lspClientOpts = {
|
|
194
194
|
transport,
|
|
195
|
-
rootUri:
|
|
196
|
-
workspaceFolders:
|
|
195
|
+
rootUri: getLspRootUri(),
|
|
196
|
+
workspaceFolders: getLspWorkspaceFolders(),
|
|
197
197
|
};
|
|
198
198
|
|
|
199
199
|
// We wrap the client in a NotebookLanguageServerClient to add some
|
|
@@ -230,8 +230,8 @@ const pyrightClient = once((_: LSPConfig) => {
|
|
|
230
230
|
|
|
231
231
|
const lspClientOpts = {
|
|
232
232
|
transport,
|
|
233
|
-
rootUri:
|
|
234
|
-
workspaceFolders:
|
|
233
|
+
rootUri: getLspRootUri(),
|
|
234
|
+
workspaceFolders: getLspWorkspaceFolders(),
|
|
235
235
|
};
|
|
236
236
|
|
|
237
237
|
// We wrap the client in a NotebookLanguageServerClient to add some
|
|
@@ -12,6 +12,7 @@ import { cellId } from "@/__tests__/branded";
|
|
|
12
12
|
import type { CellId } from "@/core/cells/ids";
|
|
13
13
|
import { store } from "@/core/state/jotai";
|
|
14
14
|
import { topologicalCodesAtom } from "../../copilot/getCodes";
|
|
15
|
+
import { lspWorkspaceAtom } from "@/core/saving/file-state";
|
|
15
16
|
import { languageAdapterState } from "../../language/extension";
|
|
16
17
|
import { PythonLanguageAdapter } from "../../language/languages/python";
|
|
17
18
|
import { languageMetadataField } from "../../language/metadata";
|
|
@@ -285,6 +286,12 @@ describe("NotebookLanguageServerClient", () => {
|
|
|
285
286
|
},
|
|
286
287
|
};
|
|
287
288
|
}
|
|
289
|
+
if (atom === lspWorkspaceAtom) {
|
|
290
|
+
return {
|
|
291
|
+
rootUri: "file:///project",
|
|
292
|
+
documentUri: "file:///project/__marimo_notebook__.py",
|
|
293
|
+
};
|
|
294
|
+
}
|
|
288
295
|
return undefined;
|
|
289
296
|
});
|
|
290
297
|
|
|
@@ -421,7 +428,7 @@ describe("NotebookLanguageServerClient", () => {
|
|
|
421
428
|
expect(result).toEqual(mockCompletionResponse);
|
|
422
429
|
expect(mockClient.textDocumentCompletion).toHaveBeenCalledWith(
|
|
423
430
|
expect.objectContaining({
|
|
424
|
-
textDocument: { uri: "file:///__marimo_notebook__.py" },
|
|
431
|
+
textDocument: { uri: "file:///project/__marimo_notebook__.py" },
|
|
425
432
|
}),
|
|
426
433
|
);
|
|
427
434
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type * as LSP from "vscode-languageserver-protocol";
|
|
4
4
|
import { Objects } from "@/utils/objects";
|
|
5
5
|
import type { ILanguageServerClient } from "./types";
|
|
6
|
-
import {
|
|
6
|
+
import { getLspDocumentUri } from "./utils";
|
|
7
7
|
|
|
8
8
|
function removeFalseyValues<T extends object>(obj: T): T {
|
|
9
9
|
return Objects.filter(obj, (value) => value !== false && value !== null) as T;
|
|
@@ -20,7 +20,7 @@ export class FederatedLanguageServerClient implements ILanguageServerClient {
|
|
|
20
20
|
|
|
21
21
|
constructor(clients: ILanguageServerClient[]) {
|
|
22
22
|
this.clients = clients;
|
|
23
|
-
this.documentUri =
|
|
23
|
+
this.documentUri = getLspDocumentUri();
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
onNotification(
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
type ILanguageServerClient,
|
|
23
23
|
isClientWithNotify,
|
|
24
24
|
} from "./types";
|
|
25
|
-
import {
|
|
25
|
+
import { getLspDocumentUri } from "./utils";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Check if a variable name is private (starts with underscore but not dunder).
|
|
@@ -189,7 +189,7 @@ export class NotebookLanguageServerClient implements ILanguageServerClient {
|
|
|
189
189
|
EditorView | null | undefined
|
|
190
190
|
> = defaultGetNotebookEditors,
|
|
191
191
|
) {
|
|
192
|
-
this.documentUri =
|
|
192
|
+
this.documentUri = getLspDocumentUri();
|
|
193
193
|
this.getNotebookEditors = getNotebookEditors;
|
|
194
194
|
this.initialSettings = initialSettings;
|
|
195
195
|
this.client = client;
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { lspWorkspaceAtom } from "@/core/saving/file-state";
|
|
3
|
+
import { store } from "@/core/state/jotai";
|
|
4
4
|
|
|
5
|
-
export function
|
|
6
|
-
|
|
5
|
+
export function getLspRootUri() {
|
|
6
|
+
const lspWorkspace = store.get(lspWorkspaceAtom);
|
|
7
|
+
// The backend provides rootUri for active notebook sessions.
|
|
8
|
+
// For non-notebook pages (home, gallery), lspWorkspace is null,
|
|
9
|
+
// so return a valid file URI fallback.
|
|
10
|
+
return lspWorkspace?.rootUri ?? "file:///";
|
|
7
11
|
}
|
|
8
12
|
|
|
9
|
-
export function
|
|
10
|
-
|
|
13
|
+
export function getLspWorkspaceFolders() {
|
|
14
|
+
const lspWorkspace = store.get(lspWorkspaceAtom);
|
|
15
|
+
const rootUri = lspWorkspace?.rootUri;
|
|
16
|
+
// Return workspace folders only if rootUri is set; empty array otherwise.
|
|
17
|
+
return rootUri ? [{ uri: rootUri, name: "marimo" }] : [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getLspDocumentUri() {
|
|
21
|
+
const lspWorkspace = store.get(lspWorkspaceAtom);
|
|
22
|
+
// The backend provides documentUri for active notebook sessions.
|
|
23
|
+
// For non-notebook pages (home, gallery), lspWorkspace is null,
|
|
24
|
+
// so return a valid file URI fallback.
|
|
25
|
+
return lspWorkspace?.documentUri ?? "file:///__marimo_notebook__.py";
|
|
11
26
|
}
|
|
@@ -112,6 +112,56 @@ describe("PlotlyPlugin", () => {
|
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
+
it("clicking a box element triggers onClick", async () => {
|
|
116
|
+
const setValue = vi.fn<Setter<unknown>>();
|
|
117
|
+
|
|
118
|
+
render(
|
|
119
|
+
<Suspense fallback={null}>
|
|
120
|
+
<PlotlyComponent
|
|
121
|
+
figure={{
|
|
122
|
+
data: [{ type: "box" }],
|
|
123
|
+
layout: {},
|
|
124
|
+
frames: null,
|
|
125
|
+
}}
|
|
126
|
+
value={undefined}
|
|
127
|
+
setValue={setValue}
|
|
128
|
+
host={document.createElement("div")}
|
|
129
|
+
config={{}}
|
|
130
|
+
/>
|
|
131
|
+
</Suspense>,
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
await waitFor(() => {
|
|
135
|
+
expect(capturedPlotProps).not.toBeNull();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
act(() => {
|
|
139
|
+
capturedPlotProps?.onClick?.({
|
|
140
|
+
points: [
|
|
141
|
+
{
|
|
142
|
+
data: { type: "box" },
|
|
143
|
+
x: "Group A",
|
|
144
|
+
y: 3,
|
|
145
|
+
pointIndex: 0,
|
|
146
|
+
pointNumber: 0,
|
|
147
|
+
curveNumber: 0,
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
expect(setValue).toHaveBeenCalledTimes(1);
|
|
154
|
+
const updater = setValue.mock.calls[0][0] as (value: unknown) => unknown;
|
|
155
|
+
expect(updater({})).toEqual({
|
|
156
|
+
selections: [],
|
|
157
|
+
points: [
|
|
158
|
+
{ x: "Group A", y: 3, curveNumber: 0, pointNumber: 0, pointIndex: 0 },
|
|
159
|
+
],
|
|
160
|
+
indices: [0],
|
|
161
|
+
range: undefined,
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
115
165
|
it("clicking a violin element triggers onClick", async () => {
|
|
116
166
|
const setValue = vi.fn<Setter<unknown>>();
|
|
117
167
|
|
|
@@ -102,6 +102,14 @@ describe("shouldHandleClickSelection", () => {
|
|
|
102
102
|
expect(shouldHandleClickSelection([heatmapPoint])).toBe(true);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
+
it("accepts box clicks", () => {
|
|
106
|
+
const boxPoint = createPlotDatum({
|
|
107
|
+
data: { type: "box" },
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
expect(shouldHandleClickSelection([boxPoint])).toBe(true);
|
|
111
|
+
});
|
|
112
|
+
|
|
105
113
|
it("accepts violin clicks", () => {
|
|
106
114
|
const violinPoint = createPlotDatum({
|
|
107
115
|
data: { type: "violin" },
|
|
@@ -126,6 +134,22 @@ describe("shouldHandleClickSelection", () => {
|
|
|
126
134
|
expect(shouldHandleClickSelection([linePoint])).toBe(true);
|
|
127
135
|
});
|
|
128
136
|
|
|
137
|
+
it("accepts funnel clicks", () => {
|
|
138
|
+
const funnelPoint = createPlotDatum({
|
|
139
|
+
data: { type: "funnel" },
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
expect(shouldHandleClickSelection([funnelPoint])).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("accepts funnelarea clicks", () => {
|
|
146
|
+
const funnelAreaPoint = createPlotDatum({
|
|
147
|
+
data: { type: "funnelarea" },
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
expect(shouldHandleClickSelection([funnelAreaPoint])).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
|
|
129
153
|
it("accepts waterfall clicks", () => {
|
|
130
154
|
const waterfallPoint = createPlotDatum({
|
|
131
155
|
data: { type: "waterfall" },
|
|
@@ -214,6 +238,64 @@ describe("extractPoints", () => {
|
|
|
214
238
|
expect(extractPoints([point])).toEqual([{ x: 1, y: 2, z: 3 }]);
|
|
215
239
|
});
|
|
216
240
|
|
|
241
|
+
it("returns funnel-specific fields for funnel traces", () => {
|
|
242
|
+
const point = createPlotDatum({
|
|
243
|
+
x: 1000,
|
|
244
|
+
y: "Visit",
|
|
245
|
+
label: "Visit",
|
|
246
|
+
value: 1000,
|
|
247
|
+
percentInitial: 1.0,
|
|
248
|
+
percentPrevious: 1.0,
|
|
249
|
+
percentTotal: 1.0,
|
|
250
|
+
curveNumber: 0,
|
|
251
|
+
pointIndex: 0,
|
|
252
|
+
pointNumber: 0,
|
|
253
|
+
data: { type: "funnel" },
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
expect(extractPoints([point])).toEqual([
|
|
257
|
+
{
|
|
258
|
+
x: 1000,
|
|
259
|
+
y: "Visit",
|
|
260
|
+
label: "Visit",
|
|
261
|
+
value: 1000,
|
|
262
|
+
percentInitial: 1.0,
|
|
263
|
+
percentPrevious: 1.0,
|
|
264
|
+
percentTotal: 1.0,
|
|
265
|
+
curveNumber: 0,
|
|
266
|
+
pointIndex: 0,
|
|
267
|
+
pointNumber: 0,
|
|
268
|
+
},
|
|
269
|
+
]);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it("returns funnelarea-specific fields without x/y for funnelarea traces", () => {
|
|
273
|
+
const point = createPlotDatum({
|
|
274
|
+
label: "Stage A",
|
|
275
|
+
value: 500,
|
|
276
|
+
percentInitial: 0.5,
|
|
277
|
+
percentPrevious: 0.8,
|
|
278
|
+
percentTotal: 0.5,
|
|
279
|
+
curveNumber: 0,
|
|
280
|
+
pointNumber: 1,
|
|
281
|
+
x: 99,
|
|
282
|
+
y: 99,
|
|
283
|
+
data: { type: "funnelarea" },
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
expect(extractPoints([point])).toEqual([
|
|
287
|
+
{
|
|
288
|
+
label: "Stage A",
|
|
289
|
+
value: 500,
|
|
290
|
+
percentInitial: 0.5,
|
|
291
|
+
percentPrevious: 0.8,
|
|
292
|
+
percentTotal: 0.5,
|
|
293
|
+
curveNumber: 0,
|
|
294
|
+
pointNumber: 1,
|
|
295
|
+
},
|
|
296
|
+
]);
|
|
297
|
+
});
|
|
298
|
+
|
|
217
299
|
it("returns x/y/pointIndex for waterfall clicks", () => {
|
|
218
300
|
const point = createPlotDatum({
|
|
219
301
|
x: "Revenue",
|
|
@@ -24,6 +24,32 @@ const SUNBURST_DATA_KEYS: (keyof Plotly.SunburstPlotDatum)[] = [
|
|
|
24
24
|
"value",
|
|
25
25
|
] as const;
|
|
26
26
|
|
|
27
|
+
// Fields emitted by go.Funnel click events: includes x/y coordinates plus
|
|
28
|
+
// funnel-specific percent metrics.
|
|
29
|
+
const FUNNEL_DATA_KEYS: string[] = [
|
|
30
|
+
"curveNumber",
|
|
31
|
+
"pointIndex",
|
|
32
|
+
"pointNumber",
|
|
33
|
+
"x",
|
|
34
|
+
"y",
|
|
35
|
+
"label",
|
|
36
|
+
"value",
|
|
37
|
+
"percentInitial",
|
|
38
|
+
"percentPrevious",
|
|
39
|
+
"percentTotal",
|
|
40
|
+
] as const;
|
|
41
|
+
|
|
42
|
+
// Fields emitted by go.FunnelArea click events: sector-based, no x/y.
|
|
43
|
+
const FUNNEL_AREA_DATA_KEYS: string[] = [
|
|
44
|
+
"curveNumber",
|
|
45
|
+
"pointNumber",
|
|
46
|
+
"label",
|
|
47
|
+
"value",
|
|
48
|
+
"percentInitial",
|
|
49
|
+
"percentPrevious",
|
|
50
|
+
"percentTotal",
|
|
51
|
+
] as const;
|
|
52
|
+
|
|
27
53
|
const LINE_CLICK_TRACE_TYPES = new Set(["scatter", "scattergl"]);
|
|
28
54
|
|
|
29
55
|
const STANDARD_POINT_KEYS: string[] = [
|
|
@@ -256,10 +282,13 @@ export function shouldHandleClickSelection(
|
|
|
256
282
|
const type = getTraceSource(point).type;
|
|
257
283
|
return (
|
|
258
284
|
type === "bar" ||
|
|
285
|
+
type === "box" ||
|
|
286
|
+
type === "funnel" ||
|
|
287
|
+
type === "funnelarea" ||
|
|
259
288
|
type === "heatmap" ||
|
|
260
289
|
type === "histogram" ||
|
|
261
|
-
type === "waterfall" ||
|
|
262
290
|
type === "violin" ||
|
|
291
|
+
type === "waterfall" ||
|
|
263
292
|
isLinePoint(point)
|
|
264
293
|
);
|
|
265
294
|
});
|
|
@@ -329,13 +358,43 @@ export function extractPoints(
|
|
|
329
358
|
let parser: PlotlyTemplateParser | undefined;
|
|
330
359
|
|
|
331
360
|
return points.map((point) => {
|
|
361
|
+
const trace = getTraceSource(point);
|
|
362
|
+
|
|
363
|
+
// FunnelArea: sector-based chart with no x/y coordinates.
|
|
364
|
+
// Pick funnel-area-specific keys, then merge any hovertemplate-parsed
|
|
365
|
+
// fields (e.g. customdata columns) so user-defined fields are preserved.
|
|
366
|
+
if (trace.type === "funnelarea") {
|
|
367
|
+
const base = pick(point, FUNNEL_AREA_DATA_KEYS);
|
|
368
|
+
const ht = Array.isArray(trace.hovertemplate)
|
|
369
|
+
? trace.hovertemplate[0]
|
|
370
|
+
: trace.hovertemplate;
|
|
371
|
+
if (!ht) {
|
|
372
|
+
return base;
|
|
373
|
+
}
|
|
374
|
+
parser = parser ? parser.update(ht) : createParser(ht);
|
|
375
|
+
return { ...base, ...parser.parse(point) };
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Funnel: bar-like chart with x/y plus per-stage percent metrics.
|
|
379
|
+
// Pick funnel-specific keys, then merge hovertemplate-parsed fields so
|
|
380
|
+
// callers get both percentInitial et al. and any user-defined columns.
|
|
381
|
+
if (trace.type === "funnel") {
|
|
382
|
+
const base = pick(point, FUNNEL_DATA_KEYS);
|
|
383
|
+
const ht = Array.isArray(trace.hovertemplate)
|
|
384
|
+
? trace.hovertemplate[0]
|
|
385
|
+
: trace.hovertemplate;
|
|
386
|
+
if (!ht) {
|
|
387
|
+
return base;
|
|
388
|
+
}
|
|
389
|
+
parser = parser ? parser.update(ht) : createParser(ht);
|
|
390
|
+
return { ...base, ...parser.parse(point) };
|
|
391
|
+
}
|
|
392
|
+
|
|
332
393
|
const standardPointFields = withInferredXY(
|
|
333
394
|
point,
|
|
334
395
|
pick(point, STANDARD_POINT_KEYS),
|
|
335
396
|
);
|
|
336
397
|
|
|
337
|
-
const trace = getTraceSource(point);
|
|
338
|
-
|
|
339
398
|
// Get the first hovertemplate
|
|
340
399
|
const hovertemplate = Array.isArray(trace.hovertemplate)
|
|
341
400
|
? trace.hovertemplate[0]
|