@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.
@@ -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 (for now) because we don't have a panel to show
1099
+ // Hidden in VSCode and islands because there's no panel to show
1098
1100
  // the table explorer.
1099
1101
  showTableExplorer={
1100
- (showRowExplorer || canShowColumnExplorer) && !isInVscode
1102
+ (showRowExplorer || canShowColumnExplorer) &&
1103
+ !isInVscode &&
1104
+ !isIslandsMode
1101
1105
  }
1102
1106
  togglePanel={togglePanel}
1103
1107
  isPanelOpen={isPanelOpen}