@marimo-team/islands 0.19.3-dev30 → 0.19.3-dev32

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/main.js CHANGED
@@ -101155,7 +101155,7 @@ Defaulting to \`null\`.`;
101155
101155
  return Logger.warn("Failed to get version from mount config"), null;
101156
101156
  }
101157
101157
  }
101158
- const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.3-dev30"), showCodeInRunModeAtom = atom(true);
101158
+ const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.3-dev32"), showCodeInRunModeAtom = atom(true);
101159
101159
  atom(null);
101160
101160
  var VIRTUAL_FILE_REGEX = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g, VirtualFileTracker = class e {
101161
101161
  constructor() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.19.3-dev30",
3
+ "version": "0.19.3-dev32",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -0,0 +1,128 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
+ import { connectionAtom } from "@/core/network/connection";
5
+ import { store } from "@/core/state/jotai";
6
+ import { WebSocketState } from "@/core/websocket/types";
7
+ import { mount, visibleForTesting } from "../mount";
8
+
9
+ // Mock React DOM
10
+ vi.mock("react-dom/client", () => ({
11
+ createRoot: vi.fn(() => ({
12
+ render: vi.fn(),
13
+ })),
14
+ }));
15
+
16
+ // Mock static state
17
+ vi.mock("@/core/static/static-state", () => ({
18
+ isStaticNotebook: vi.fn(() => false),
19
+ }));
20
+
21
+ // Mock other side-effect modules
22
+ vi.mock("@/core/vscode/vscode-bindings", () => ({
23
+ maybeRegisterVSCodeBindings: vi.fn(),
24
+ }));
25
+
26
+ vi.mock("@/plugins/plugins", () => ({
27
+ initializePlugins: vi.fn(),
28
+ }));
29
+
30
+ vi.mock("@/core/network/auth", () => ({
31
+ cleanupAuthQueryParams: vi.fn(),
32
+ }));
33
+
34
+ vi.mock("@/utils/vitals", () => ({
35
+ reportVitals: vi.fn(),
36
+ }));
37
+
38
+ // Mock preloadPage
39
+ vi.mock("@/core/MarimoApp", () => ({
40
+ MarimoApp: () => null,
41
+ preloadPage: vi.fn(),
42
+ }));
43
+
44
+ describe("mount", () => {
45
+ const mockElement = document.createElement("div");
46
+
47
+ beforeEach(() => {
48
+ visibleForTesting.reset();
49
+ // Reset connection atom to initial state
50
+ store.set(connectionAtom, { state: WebSocketState.NOT_STARTED });
51
+ });
52
+
53
+ afterEach(() => {
54
+ vi.clearAllMocks();
55
+ });
56
+
57
+ const baseOptions = {
58
+ filename: "test.py",
59
+ code: "",
60
+ version: "0.0.1",
61
+ mode: "edit" as const,
62
+ config: {},
63
+ configOverrides: {},
64
+ appConfig: {},
65
+ view: { showAppCode: true },
66
+ serverToken: "",
67
+ };
68
+
69
+ describe("connection state initialization", () => {
70
+ it("should set connection to CONNECTING when runtimeConfig has lazy=false", () => {
71
+ mount(
72
+ {
73
+ ...baseOptions,
74
+ runtimeConfig: [{ url: "http://localhost:8080", lazy: false }],
75
+ },
76
+ mockElement,
77
+ );
78
+
79
+ const connection = store.get(connectionAtom);
80
+ expect(connection.state).toBe(WebSocketState.CONNECTING);
81
+ });
82
+
83
+ it("should keep connection as NOT_STARTED when runtimeConfig has lazy=true", () => {
84
+ mount(
85
+ {
86
+ ...baseOptions,
87
+ runtimeConfig: [{ url: "http://localhost:8080", lazy: true }],
88
+ },
89
+ mockElement,
90
+ );
91
+
92
+ const connection = store.get(connectionAtom);
93
+ expect(connection.state).toBe(WebSocketState.NOT_STARTED);
94
+ });
95
+
96
+ it("should keep connection as NOT_STARTED when no runtimeConfig is provided", () => {
97
+ mount(
98
+ {
99
+ ...baseOptions,
100
+ runtimeConfig: [],
101
+ },
102
+ mockElement,
103
+ );
104
+
105
+ const connection = store.get(connectionAtom);
106
+ expect(connection.state).toBe(WebSocketState.NOT_STARTED);
107
+ });
108
+
109
+ it("should keep connection as NOT_STARTED for static notebooks even with lazy=false", async () => {
110
+ const { isStaticNotebook } = await import("@/core/static/static-state");
111
+ vi.mocked(isStaticNotebook).mockReturnValue(true);
112
+
113
+ // Reset mount state to allow another mount
114
+ visibleForTesting.reset();
115
+
116
+ mount(
117
+ {
118
+ ...baseOptions,
119
+ runtimeConfig: [{ url: "http://localhost:8080", lazy: false }],
120
+ },
121
+ mockElement,
122
+ );
123
+
124
+ const connection = store.get(connectionAtom);
125
+ expect(connection.state).toBe(WebSocketState.NOT_STARTED);
126
+ });
127
+ });
128
+ });
package/src/mount.tsx CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  import { MarimoApp, preloadPage } from "./core/MarimoApp";
30
30
  import { type AppMode, initialModeAtom, viewStateAtom } from "./core/mode";
31
31
  import { cleanupAuthQueryParams } from "./core/network/auth";
32
+ import { connectionAtom } from "./core/network/connection";
32
33
  import { requestClientAtom } from "./core/network/requests";
33
34
  import { resolveRequestClient } from "./core/network/resolve";
34
35
  import {
@@ -42,6 +43,7 @@ import { isStaticNotebook } from "./core/static/static-state";
42
43
  import { maybeRegisterVSCodeBindings } from "./core/vscode/vscode-bindings";
43
44
  import type { FileStore } from "./core/wasm/store";
44
45
  import { notebookFileStore } from "./core/wasm/store";
46
+ import { WebSocketState } from "./core/websocket/types";
45
47
  import { vegaLoader } from "./plugins/impl/vega/loader";
46
48
  import { initializePlugins } from "./plugins/plugins";
47
49
  import { ThemeProvider } from "./theme/ThemeProvider";
@@ -304,6 +306,10 @@ function initStore(options: unknown) {
304
306
  ...firstRuntimeConfig,
305
307
  serverToken: parsedOptions.data.serverToken,
306
308
  });
309
+ // If the remote runtime is not lazy, start it in CONNECTING
310
+ if (!firstRuntimeConfig.lazy && !isStaticNotebook()) {
311
+ store.set(connectionAtom, { state: WebSocketState.CONNECTING });
312
+ }
307
313
  } else {
308
314
  store.set(runtimeConfigAtom, {
309
315
  ...DEFAULT_RUNTIME_CONFIG,