@marimo-team/frontend 0.23.1-dev20 → 0.23.1-dev22
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/assets/{index-C9DyCFTe.js → index-C7hH7rgL.js} +14 -14
- package/dist/index.html +1 -1
- package/package.json +4 -4
- package/src/core/islands/__tests__/bridge.test.ts +2 -12
- package/src/core/islands/__tests__/islands-harness.test.ts +348 -0
- package/src/core/islands/__tests__/parse.test.ts +466 -24
- package/src/core/islands/__tests__/test-utils.tsx +263 -0
- package/src/core/islands/bootstrap.ts +265 -0
- package/src/core/islands/bridge.ts +154 -75
- package/src/core/islands/components/IslandControls.tsx +103 -0
- package/src/core/islands/components/__tests__/IslandControls.test.tsx +185 -0
- package/src/core/islands/components/__tests__/useIslandControls.test.ts +208 -0
- package/src/core/islands/components/output-wrapper.tsx +76 -93
- package/src/core/islands/components/useIslandControls.ts +60 -0
- package/src/core/islands/components/web-components.tsx +168 -40
- package/src/core/islands/constants.ts +28 -0
- package/src/core/islands/main.ts +7 -205
- package/src/core/islands/parse.ts +73 -26
- package/src/core/islands/worker-factory.ts +86 -0
- package/src/plugins/impl/DataTablePlugin.tsx +7 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { getMarimoVersion } from "../meta/globals";
|
|
4
|
+
import workerUrl from "./worker/worker.tsx?worker&url";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Interface for creating Web Workers for islands
|
|
8
|
+
*/
|
|
9
|
+
export interface WorkerFactory {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new worker instance
|
|
12
|
+
*/
|
|
13
|
+
create(): Worker;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for the default worker factory
|
|
18
|
+
*/
|
|
19
|
+
export interface DefaultWorkerFactoryConfig {
|
|
20
|
+
/**
|
|
21
|
+
* The URL to the worker script
|
|
22
|
+
* Defaults to the bundled worker
|
|
23
|
+
*/
|
|
24
|
+
workerUrl?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The name to give the worker (shows in DevTools)
|
|
28
|
+
* Defaults to the marimo version
|
|
29
|
+
*/
|
|
30
|
+
workerName?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Default implementation of WorkerFactory that creates Pyodide workers
|
|
35
|
+
* for islands mode.
|
|
36
|
+
*/
|
|
37
|
+
export class DefaultWorkerFactory implements WorkerFactory {
|
|
38
|
+
private readonly url: string;
|
|
39
|
+
private readonly name: string;
|
|
40
|
+
|
|
41
|
+
constructor(config: DefaultWorkerFactoryConfig = {}) {
|
|
42
|
+
this.url = config.workerUrl || this.getDefaultWorkerUrl();
|
|
43
|
+
this.name = config.workerName || getMarimoVersion();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new Pyodide worker
|
|
48
|
+
*/
|
|
49
|
+
create(): Worker {
|
|
50
|
+
const js = `import ${JSON.stringify(new URL(this.url, import.meta.url))}`;
|
|
51
|
+
const blob = new Blob([js], { type: "application/javascript" });
|
|
52
|
+
const objURL = URL.createObjectURL(blob);
|
|
53
|
+
|
|
54
|
+
const worker = new Worker(objURL, {
|
|
55
|
+
type: "module",
|
|
56
|
+
/* @vite-ignore */
|
|
57
|
+
name: this.name,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Blob URL can be revoked once the worker has loaded the script
|
|
61
|
+
URL.revokeObjectURL(objURL);
|
|
62
|
+
|
|
63
|
+
return worker;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Gets the default worker URL based on environment
|
|
68
|
+
*/
|
|
69
|
+
private getDefaultWorkerUrl(): string {
|
|
70
|
+
const url = import.meta.env.DEV
|
|
71
|
+
? workerUrl
|
|
72
|
+
: makeRelativeWorkerUrl(workerUrl);
|
|
73
|
+
return url;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Makes worker URLs relative for production builds
|
|
79
|
+
*/
|
|
80
|
+
function makeRelativeWorkerUrl(url: string): string {
|
|
81
|
+
return url.startsWith("./")
|
|
82
|
+
? url
|
|
83
|
+
: url.startsWith("/")
|
|
84
|
+
? `.${url}`
|
|
85
|
+
: `./${url}`;
|
|
86
|
+
}
|
|
@@ -68,6 +68,7 @@ import {
|
|
|
68
68
|
import { slotsController } from "@/core/slots/slots";
|
|
69
69
|
import { store } from "@/core/state/jotai";
|
|
70
70
|
import { isStaticNotebook } from "@/core/static/static-state";
|
|
71
|
+
import { isIslands } from "@/core/islands/utils";
|
|
71
72
|
import { isInVscodeExtension } from "@/core/vscode/is-in-vscode";
|
|
72
73
|
import { useAsyncData } from "@/hooks/useAsyncData";
|
|
73
74
|
import { useDeepCompareMemoize } from "@/hooks/useDeepCompareMemoize";
|
|
@@ -1006,6 +1007,7 @@ const DataTableComponent = ({
|
|
|
1006
1007
|
const canShowColumnExplorer = showColumnExplorer && !!preview_column;
|
|
1007
1008
|
|
|
1008
1009
|
const isInVscode = isInVscodeExtension();
|
|
1010
|
+
const isIslandsMode = isIslands();
|
|
1009
1011
|
|
|
1010
1012
|
return (
|
|
1011
1013
|
<>
|
|
@@ -1091,13 +1093,15 @@ const DataTableComponent = ({
|
|
|
1091
1093
|
onCellSelectionChange={handleCellSelectionChange}
|
|
1092
1094
|
getRowIds={get_row_ids}
|
|
1093
1095
|
toggleDisplayHeader={toggleDisplayHeader}
|
|
1094
|
-
showChartBuilder={showChartBuilder}
|
|
1096
|
+
showChartBuilder={showChartBuilder && !isIslandsMode}
|
|
1095
1097
|
isChartBuilderOpen={isChartBuilderOpen}
|
|
1096
1098
|
showPageSizeSelector={showPageSizeSelector}
|
|
1097
|
-
// Hidden in VSCode
|
|
1099
|
+
// Hidden in VSCode and islands because there's no panel to show
|
|
1098
1100
|
// the table explorer.
|
|
1099
1101
|
showTableExplorer={
|
|
1100
|
-
(showRowExplorer || canShowColumnExplorer) &&
|
|
1102
|
+
(showRowExplorer || canShowColumnExplorer) &&
|
|
1103
|
+
!isInVscode &&
|
|
1104
|
+
!isIslandsMode
|
|
1101
1105
|
}
|
|
1102
1106
|
togglePanel={togglePanel}
|
|
1103
1107
|
isPanelOpen={isPanelOpen}
|