@marimo-team/islands 0.23.6-dev23 → 0.23.6-dev28

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.
@@ -5,6 +5,7 @@ import { Logger } from "@/utils/Logger";
5
5
  import { KnownQueryParams } from "../constants";
6
6
  import { isIslands } from "../islands/utils";
7
7
  import { getSessionId, type SessionId } from "../kernel/session";
8
+ import { isStaticNotebook } from "../static/static-state";
8
9
  import { isWasm } from "../wasm/utils";
9
10
  import type { RuntimeConfig } from "./types";
10
11
 
@@ -178,8 +179,8 @@ export class RuntimeManager {
178
179
  }
179
180
 
180
181
  async isHealthy(): Promise<boolean> {
181
- // Always healthy if WASM
182
- if (isWasm() || isIslands()) {
182
+ // Always healthy if WASM, Islands, or a static notebook (no server)
183
+ if (isWasm() || isIslands() || isStaticNotebook()) {
183
184
  return true;
184
185
  }
185
186
 
@@ -58,7 +58,7 @@ vi.mock("@/core/wasm/store", () => ({
58
58
  // Import after all mocks are set up
59
59
  import { store } from "@/core/state/jotai";
60
60
  import { initialModeAtom } from "@/core/mode";
61
- import { PyodideBridge } from "../bridge";
61
+ import { getWasmWorkerName, PyodideBridge } from "../bridge";
62
62
 
63
63
  // Access INSTANCE once at module level so the constructor runs (and
64
64
  // addMessageListener populates rpcListeners) before any test executes.
@@ -111,3 +111,28 @@ describe("PyodideBridge.readCode", () => {
111
111
  expect(mockNotebookReadFile).not.toHaveBeenCalled();
112
112
  });
113
113
  });
114
+
115
+ describe("getWasmWorkerName", () => {
116
+ afterEach(() => {
117
+ delete (window as unknown as { __MARIMO_HAS_WASM_CONTROLLER__?: boolean })
118
+ .__MARIMO_HAS_WASM_CONTROLLER__;
119
+ });
120
+
121
+ it("returns the version without suffix by default", () => {
122
+ expect(getWasmWorkerName()).toBe("0.0.0-test");
123
+ });
124
+
125
+ it("appends ::controller when the host opts in", () => {
126
+ (
127
+ window as unknown as { __MARIMO_HAS_WASM_CONTROLLER__?: boolean }
128
+ ).__MARIMO_HAS_WASM_CONTROLLER__ = true;
129
+ expect(getWasmWorkerName()).toBe("0.0.0-test::controller");
130
+ });
131
+
132
+ it("does not append the suffix for non-true values", () => {
133
+ (
134
+ window as unknown as { __MARIMO_HAS_WASM_CONTROLLER__?: unknown }
135
+ ).__MARIMO_HAS_WASM_CONTROLLER__ = "true";
136
+ expect(getWasmWorkerName()).toBe("0.0.0-test");
137
+ });
138
+ });
@@ -81,9 +81,9 @@ export class PyodideBridge implements RunRequests, EditRequests {
81
81
  new URL("./worker/save-worker.ts", import.meta.url),
82
82
  {
83
83
  type: "module",
84
- // Pass the version to the worker
84
+ // Pass the version (and optional capability suffix) to the worker
85
85
  /* @vite-ignore */
86
- name: getMarimoVersion(),
86
+ name: getWasmWorkerName(),
87
87
  },
88
88
  );
89
89
 
@@ -101,9 +101,9 @@ export class PyodideBridge implements RunRequests, EditRequests {
101
101
  new URL("./worker/worker.ts", import.meta.url),
102
102
  {
103
103
  type: "module",
104
- // Pass the version to the worker
104
+ // Pass the version (and optional capability suffix) to the worker
105
105
  /* @vite-ignore */
106
- name: getMarimoVersion(),
106
+ name: getWasmWorkerName(),
107
107
  },
108
108
  );
109
109
 
@@ -634,3 +634,17 @@ export function createPyodideConnection(): IConnectionTransport {
634
634
  PyodideBridge.INSTANCE.attachMessageConsumer(callback);
635
635
  });
636
636
  }
637
+
638
+ // Compose the worker name. The version prefix is read by getMarimoVersion()
639
+ // in the worker; the optional "::controller" suffix tells getController.ts
640
+ // that the host page provides a custom /wasm/controller.js and that the
641
+ // dynamic import should be attempted. Hosts opt in by setting
642
+ // `window.__MARIMO_HAS_WASM_CONTROLLER__ = true` before
643
+ // PyodideBridge/worker initialization.
644
+ export function getWasmWorkerName(): string {
645
+ const hasCustomController =
646
+ typeof window !== "undefined" &&
647
+ (window as unknown as { __MARIMO_HAS_WASM_CONTROLLER__?: boolean })
648
+ .__MARIMO_HAS_WASM_CONTROLLER__ === true;
649
+ return getMarimoVersion() + (hasCustomController ? "::controller" : "");
650
+ }
@@ -5,6 +5,13 @@ import type { WasmController } from "./types";
5
5
  // Load the controller
6
6
  // Falls back to the default controller
7
7
  export async function getController(version: string): Promise<WasmController> {
8
+ // Hosts that provide a custom /wasm/controller.js opt in via the worker
9
+ // name (see bridge.ts). Default: skip the dynamic import to avoid a
10
+ // guaranteed-404 round trip on the standard build.
11
+ const hasCustomController = self.name?.includes("::controller") ?? false;
12
+ if (!hasCustomController) {
13
+ return new DefaultWasmController();
14
+ }
8
15
  try {
9
16
  const controller = await import(
10
17
  /* @vite-ignore */ `/wasm/controller.js?version=${version}`
@@ -103,5 +103,6 @@ const rpc = createRPC<SaveWorkerSchema, ParentSchema>({
103
103
  rpc.send("ready", {});
104
104
 
105
105
  function getMarimoVersion() {
106
- return self.name; // We store the version in the worker name
106
+ // Worker name is "<version>" or "<version>::<capability>" see bridge.ts.
107
+ return self.name.split("::")[0];
107
108
  }
@@ -375,7 +375,8 @@ const namesThatRequireSync = new Set<keyof RawBridge>([
375
375
  ]);
376
376
 
377
377
  function getMarimoVersion() {
378
- return self.name; // We store the version in the worker name
378
+ // Worker name is "<version>" or "<version>::<capability>" see bridge.ts.
379
+ return self.name.split("::")[0];
379
380
  }
380
381
 
381
382
  const pyodideReadyPromise = t.wrapAsync(loadPyodideAndPackages)();
@@ -44,7 +44,7 @@ export const Labeled: React.FC<PropsWithChildren<Props>> = ({
44
44
  }
45
45
 
46
46
  const labelElement = (
47
- <div part="label" className="m-0 p-0">
47
+ <div part="label" className="inline-flex items-center m-0 p-0">
48
48
  <Label htmlFor={id} className={cn("font-prose", labelClassName)}>
49
49
  {renderHTML({ html: label })}
50
50
  </Label>