@marimo-team/islands 0.23.14-dev55 → 0.23.14-dev58
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/{ConnectedDataExplorerComponent-DXBx_nQg.js → ConnectedDataExplorerComponent-CU4fZJzG.js} +4 -4
- package/dist/assets/__vite-browser-external-BQCLNwri.js +1 -0
- package/dist/assets/{worker-DEDLIQQV.js → worker-DAWRHcPq.js} +2 -2
- package/dist/{chat-ui-DXPRhRO2.js → chat-ui-D7EyLr6c.js} +6 -6
- package/dist/{code-visibility-DQX0uy8x.js → code-visibility-Con-26vn.js} +8 -8
- package/dist/{formats-WsOgyW_K.js → formats-Dzx4J_z1.js} +1 -1
- package/dist/{glide-data-editor-7wxMGXjG.js → glide-data-editor-CjTu7ukN.js} +2 -2
- package/dist/{html-to-image-DOqQBSQc.js → html-to-image-hevd6UWC.js} +5 -5
- package/dist/{input-BSdZp5Ng.js → input-DtsN7xm-.js} +1 -1
- package/dist/main.js +18 -18
- package/dist/{mermaid-D-HYBMEV.js → mermaid-BYqXy_NE.js} +2 -2
- package/dist/{process-output-kGk2Jc2x.js → process-output-DOO3J9E6.js} +1 -1
- package/dist/{reveal-component-wJKTADmW.js → reveal-component-CfKy-mTN.js} +5 -5
- package/dist/{spec-CnTgI25l.js → spec-Cz-Bj1JI.js} +1 -1
- package/dist/{toDate-D1Z7ZXWh.js → toDate-CWNNlFEX.js} +15 -7
- package/dist/{useAsyncData-BMc8itk2.js → useAsyncData-KfHB8wQR.js} +1 -1
- package/dist/{useDeepCompareMemoize-ZwmDBRDY.js → useDeepCompareMemoize-nJMtxhm4.js} +1 -1
- package/dist/{useLifecycle-CxffarYV.js → useLifecycle-DegSo0lV.js} +1 -1
- package/dist/{useTheme-yGsGEk82.js → useTheme-6eZ3GOTS.js} +5 -2
- package/dist/{vega-component-BFJTyykA.js → vega-component-DzyyM9fc.js} +5 -5
- package/package.json +1 -1
- package/src/core/config/__tests__/config-schema.test.ts +17 -0
- package/src/core/config/config-schema.ts +1 -0
- package/src/core/config/config.ts +10 -0
- package/src/core/runtime/__tests__/runtime.test.ts +45 -0
- package/src/core/runtime/runtime.ts +30 -16
- package/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts +4 -0
- package/src/core/websocket/__tests__/useWebSocket.test.ts +49 -0
- package/src/core/websocket/transports/__tests__/sse.test.ts +338 -0
- package/src/core/websocket/transports/sse.ts +308 -0
- package/src/core/websocket/useMarimoKernelConnection.tsx +39 -4
- package/src/core/websocket/useWebSocket.tsx +12 -2
- package/dist/assets/__vite-browser-external-DAm_YW43.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import { useAtom, useSetAtom } from "jotai";
|
|
3
|
+
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
4
4
|
import { useRef } from "react";
|
|
5
5
|
import { useErrorBoundary } from "react-error-boundary";
|
|
6
6
|
import { toast } from "@/components/ui/use-toast";
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
} from "../codemirror/cells/debugger-state";
|
|
39
39
|
import type { CellData } from "../cells/types";
|
|
40
40
|
import { capabilitiesAtom } from "../config/capabilities";
|
|
41
|
-
import { useSetAppConfig } from "../config/config";
|
|
41
|
+
import { connectionTransportTypeAtom, useSetAppConfig } from "../config/config";
|
|
42
42
|
import { useDataSourceActions } from "../datasets/data-source-connections";
|
|
43
43
|
import type { ConnectionName } from "../datasets/engines";
|
|
44
44
|
import {
|
|
@@ -84,13 +84,18 @@ const SUPPORTS_LAZY_KERNELS = true;
|
|
|
84
84
|
|
|
85
85
|
// All MARIMO_* reasons except TRANSPORT_EXHAUSTED are emitted by the backend
|
|
86
86
|
// (marimo/_server/api/endpoints/ws_endpoint.py and ws/*.py). Keep in sync with
|
|
87
|
-
// the backend literals.
|
|
87
|
+
// the backend literals. Over the SSE transport these arrive as in-band
|
|
88
|
+
// `close` events rather than WebSocket close frames, so every terminal
|
|
89
|
+
// reason must be classified here — an unclassified reason falls into the
|
|
90
|
+
// retry path.
|
|
88
91
|
export type CloseReason =
|
|
89
92
|
| "MARIMO_NO_FILE_KEY"
|
|
90
93
|
| "MARIMO_NO_SESSION_ID"
|
|
91
94
|
| "MARIMO_NO_SESSION"
|
|
92
95
|
| "MARIMO_SHUTDOWN"
|
|
93
96
|
| "MARIMO_KERNEL_STARTUP_ERROR"
|
|
97
|
+
| "MARIMO_UNAUTHORIZED"
|
|
98
|
+
| "MARIMO_KIOSK_NOT_ALLOWED"
|
|
94
99
|
| typeof TRANSPORT_EXHAUSTED_REASON;
|
|
95
100
|
|
|
96
101
|
export type CloseDecision =
|
|
@@ -122,6 +127,26 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {
|
|
|
122
127
|
},
|
|
123
128
|
closeTransport: true,
|
|
124
129
|
};
|
|
130
|
+
case "MARIMO_UNAUTHORIZED":
|
|
131
|
+
return {
|
|
132
|
+
kind: "terminal",
|
|
133
|
+
status: {
|
|
134
|
+
state: WebSocketState.CLOSED,
|
|
135
|
+
code: WebSocketClosedReason.KERNEL_DISCONNECTED,
|
|
136
|
+
reason: "not authorized",
|
|
137
|
+
},
|
|
138
|
+
closeTransport: true,
|
|
139
|
+
};
|
|
140
|
+
case "MARIMO_KIOSK_NOT_ALLOWED":
|
|
141
|
+
return {
|
|
142
|
+
kind: "terminal",
|
|
143
|
+
status: {
|
|
144
|
+
state: WebSocketState.CLOSED,
|
|
145
|
+
code: WebSocketClosedReason.KERNEL_DISCONNECTED,
|
|
146
|
+
reason: "kiosk mode is not available for this session",
|
|
147
|
+
},
|
|
148
|
+
closeTransport: true,
|
|
149
|
+
};
|
|
125
150
|
case "MARIMO_KERNEL_STARTUP_ERROR":
|
|
126
151
|
return {
|
|
127
152
|
kind: "terminal",
|
|
@@ -198,6 +223,7 @@ export function useMarimoKernelConnection(opts: {
|
|
|
198
223
|
const setKioskMode = useSetAtom(kioskModeAtom);
|
|
199
224
|
const setCapabilities = useSetAtom(capabilitiesAtom);
|
|
200
225
|
const runtimeManager = useRuntimeManager();
|
|
226
|
+
const transportType = useAtomValue(connectionTransportTypeAtom);
|
|
201
227
|
const setCacheInfo = useSetAtom(cacheInfoAtom);
|
|
202
228
|
const setKernelStartupError = useSetAtom(kernelStartupErrorAtom);
|
|
203
229
|
const setDebuggerCurrentLine = useSetAtom(debuggerCurrentLineAtom);
|
|
@@ -456,10 +482,19 @@ export function useMarimoKernelConnection(opts: {
|
|
|
456
482
|
|
|
457
483
|
const ws = useConnectionTransport({
|
|
458
484
|
static: isStaticNotebook(),
|
|
485
|
+
transportType,
|
|
459
486
|
/**
|
|
460
487
|
* Unique URL for this session.
|
|
461
488
|
*/
|
|
462
|
-
url: () =>
|
|
489
|
+
url: () =>
|
|
490
|
+
transportType === "sse"
|
|
491
|
+
? runtimeManager.getSseURL(sessionId).toString()
|
|
492
|
+
: runtimeManager.getWsURL(sessionId).toString(),
|
|
493
|
+
/**
|
|
494
|
+
* Auth headers for the SSE transport. WebSockets cannot send headers
|
|
495
|
+
* and instead put the access token in the URL.
|
|
496
|
+
*/
|
|
497
|
+
headers: () => runtimeManager.headers(),
|
|
463
498
|
|
|
464
499
|
/**
|
|
465
500
|
* Open callback. Set the connection status to open.
|
|
@@ -5,12 +5,16 @@ import { Logger } from "@/utils/Logger";
|
|
|
5
5
|
import { createPyodideConnection } from "../wasm/bridge";
|
|
6
6
|
import { isWasm } from "../wasm/utils";
|
|
7
7
|
import { BasicTransport } from "./transports/basic";
|
|
8
|
+
import { SseTransport } from "./transports/sse";
|
|
8
9
|
import { WsTransport } from "./transports/ws";
|
|
9
10
|
import type { IConnectionTransport } from "./transports/transport";
|
|
10
11
|
|
|
11
12
|
interface UseConnectionTransportOptions {
|
|
12
13
|
url: () => string;
|
|
13
14
|
static: boolean;
|
|
15
|
+
transportType: "websocket" | "sse";
|
|
16
|
+
/** Request headers for the SSE transport (auth); unused by WebSockets. */
|
|
17
|
+
headers: () => Record<string, string>;
|
|
14
18
|
waitToConnect: () => Promise<void>;
|
|
15
19
|
onOpen: (event: WebSocketEventMap["open"]) => void;
|
|
16
20
|
onMessage: (event: WebSocketEventMap["message"]) => void;
|
|
@@ -18,8 +22,11 @@ interface UseConnectionTransportOptions {
|
|
|
18
22
|
onError: (event: WebSocketEventMap["error"]) => void;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
function createConnectionTransport(
|
|
22
|
-
options: Pick<
|
|
25
|
+
export function createConnectionTransport(
|
|
26
|
+
options: Pick<
|
|
27
|
+
UseConnectionTransportOptions,
|
|
28
|
+
"url" | "static" | "transportType" | "headers"
|
|
29
|
+
>,
|
|
23
30
|
): IConnectionTransport {
|
|
24
31
|
if (options.static) {
|
|
25
32
|
return BasicTransport.empty();
|
|
@@ -28,6 +35,9 @@ function createConnectionTransport(
|
|
|
28
35
|
return createPyodideConnection();
|
|
29
36
|
}
|
|
30
37
|
// urlProvider is passed lazily; it may change after a runtime redirect.
|
|
38
|
+
if (options.transportType === "sse") {
|
|
39
|
+
return new SseTransport(options.url, options.headers);
|
|
40
|
+
}
|
|
31
41
|
return new WsTransport(options.url);
|
|
32
42
|
}
|
|
33
43
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./worker-DEDLIQQV.js";var t=e(((e,t)=>{t.exports={}}));export default t();
|