@marimo-team/islands 0.25.1-dev27 → 0.25.1-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.
- package/dist/{ErrorBoundary-D4ttmcVM.js → ErrorBoundary-CE6-1WC1.js} +1 -1
- package/dist/{code-visibility-BPU-HPcn.js → code-visibility--u2Q2Zfx.js} +1 -1
- package/dist/{common-BqBhuV4I.js → common-hHL7iKzA.js} +1 -1
- package/dist/{data-grid-overlay-editor-J_6pQ0_d.js → data-grid-overlay-editor-v7VZO5up.js} +1 -1
- package/dist/{feedback-button-BaxvkeuW.js → feedback-button-C3Ya1IXo.js} +2 -2
- package/dist/{glide-data-editor-CQLOtNIR.js → glide-data-editor-BKOLh2Tv.js} +3 -3
- package/dist/{globals-CNGEBL2Q.js → globals-DOJr_y24.js} +1 -1
- package/dist/main.js +6 -6
- package/dist/{number-overlay-editor-BdiJ3rzS.js → number-overlay-editor-DkEFJYK7.js} +1 -1
- package/dist/{reveal-component-Bphz8syB.js → reveal-component-rbEv9ppg.js} +2 -2
- package/package.json +1 -1
- package/src/__mocks__/common.ts +3 -3
- package/src/__tests__/CellStatus.test.tsx +1 -1
- package/src/__tests__/setup.ts +7 -7
- package/src/components/data-table/column-summary/chart-spec-model.tsx +4 -4
- package/src/components/dependency-graph/elements.ts +2 -2
- package/src/components/editor/ai/staged-cell-submission.ts +2 -2
- package/src/components/editor/ai/transport/chat-transport.tsx +1 -1
- package/src/components/editor/connections/database/as-code.ts +44 -44
- package/src/components/editor/connections/storage/as-code.ts +3 -3
- package/src/components/editor/file-tree/requesting-tree.tsx +16 -13
- package/src/components/editor/navigation/clipboard.ts +2 -2
- package/src/components/editor/output/ansi-reduce.ts +13 -13
- package/src/components/slides/__tests__/minimap-actions.test.tsx +7 -7
- package/src/components/slides/__tests__/minimap.test.ts +12 -12
- package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +8 -8
- package/src/core/ai/context/__tests__/registry.test.ts +31 -28
- package/src/core/ai/context/providers/cell-output.ts +8 -8
- package/src/core/ai/context/providers/datasource.ts +10 -7
- package/src/core/ai/context/providers/error.ts +7 -7
- package/src/core/ai/context/providers/file.ts +8 -8
- package/src/core/ai/context/providers/tables.ts +7 -7
- package/src/core/ai/context/providers/variable.ts +7 -7
- package/src/core/ai/context/registry.ts +18 -18
- package/src/core/ai/ids/ids.ts +5 -5
- package/src/core/ai/model-registry.ts +12 -9
- package/src/core/ai/staged-cells.ts +6 -6
- package/src/core/ai/tools/base.ts +6 -6
- package/src/core/ai/tools/edit-notebook-tool.ts +6 -6
- package/src/core/ai/tools/registry.ts +4 -4
- package/src/core/ai/tools/run-cells-tool.ts +7 -7
- package/src/core/ai/tools/sample-tool.ts +6 -6
- package/src/core/codemirror/cells/debugger-decorations.ts +13 -7
- package/src/core/codemirror/cells/line-timing-decorations.ts +9 -9
- package/src/core/codemirror/cells/traceback-decorations.ts +7 -4
- package/src/core/codemirror/code-lens/extension.ts +13 -13
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +6 -6
- package/src/core/codemirror/copilot/__tests__/transport.test.ts +12 -12
- package/src/core/codemirror/copilot/language-server.ts +13 -13
- package/src/core/codemirror/copilot/transport.ts +1 -1
- package/src/core/codemirror/find-replace/search-highlight.ts +5 -5
- package/src/core/codemirror/go-to-definition/underline.ts +3 -3
- package/src/core/codemirror/keymaps/vim.ts +3 -3
- package/src/core/codemirror/language/languages/markdown.ts +8 -8
- package/src/core/codemirror/language/languages/python.ts +7 -7
- package/src/core/codemirror/language/languages/sql/completion-builder.ts +5 -5
- package/src/core/codemirror/language/languages/sql/completion-store.ts +4 -4
- package/src/core/codemirror/language/languages/sql/sql.ts +21 -21
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +10 -10
- package/src/core/codemirror/lsp/federated-lsp.ts +29 -27
- package/src/core/codemirror/lsp/notebook-lsp.ts +21 -21
- package/src/core/codemirror/misc/__tests__/dnd.test.ts +10 -10
- package/src/core/codemirror/misc/__tests__/paste.test.ts +7 -4
- package/src/core/codemirror/reactive-references/extension.ts +3 -3
- package/src/core/codemirror/rtc/loro/awareness.ts +12 -12
- package/src/core/codemirror/rtc/loro/sync.ts +5 -5
- package/src/core/codemirror/vim/cursor-visibility.ts +3 -3
- package/src/core/dom/ui-element.ts +5 -5
- package/src/core/dom/uiregistry.ts +10 -10
- package/src/core/hotkeys/hotkeys.ts +9 -9
- package/src/core/islands/__tests__/bridge.test.ts +4 -4
- package/src/core/islands/__tests__/test-utils.tsx +4 -4
- package/src/core/islands/bridge.ts +85 -82
- package/src/core/islands/components/web-components.tsx +7 -7
- package/src/core/islands/worker/__tests__/controller.test.ts +1 -1
- package/src/core/islands/worker/controller.ts +6 -3
- package/src/core/islands/worker-factory.ts +2 -2
- package/src/core/kernel/RuntimeState.ts +4 -4
- package/src/core/lsp/__tests__/transport.test.ts +19 -19
- package/src/core/lsp/transport.ts +5 -5
- package/src/core/network/CachingRequestRegistry.ts +2 -2
- package/src/core/network/DeferredRequestRegistry.ts +4 -4
- package/src/core/runtime/runtime.ts +25 -20
- package/src/core/static/virtual-file-tracker.ts +5 -5
- package/src/core/wasm/__tests__/bridge.test.ts +2 -2
- package/src/core/wasm/bridge.ts +130 -126
- package/src/core/wasm/router.ts +5 -5
- package/src/core/wasm/store.ts +4 -4
- package/src/core/wasm/worker/bootstrap.ts +8 -5
- package/src/core/wasm/worker/message-buffer.ts +3 -3
- package/src/core/websocket/transports/__tests__/ws.test.ts +8 -8
- package/src/core/websocket/transports/basic.ts +15 -8
- package/src/core/websocket/transports/sse.ts +7 -7
- package/src/core/websocket/transports/transport.ts +3 -3
- package/src/core/websocket/transports/ws.ts +9 -7
- package/src/hooks/__tests__/useOverflowDetection.test.tsx +5 -5
- package/src/hooks/__tests__/useResizeObserver.test.tsx +12 -12
- package/src/plugins/core/registerReactComponent.tsx +5 -5
- package/src/plugins/core/sidebar-element.tsx +2 -2
- package/src/plugins/impl/ButtonPlugin.tsx +3 -3
- package/src/plugins/impl/CheckboxPlugin.tsx +3 -3
- package/src/plugins/impl/CodeEditorPlugin.tsx +3 -3
- package/src/plugins/impl/DatePickerPlugin.tsx +3 -3
- package/src/plugins/impl/DateRangePlugin.tsx +3 -3
- package/src/plugins/impl/DateTimePickerPlugin.tsx +3 -3
- package/src/plugins/impl/DictPlugin.tsx +3 -3
- package/src/plugins/impl/DropdownPlugin.tsx +3 -3
- package/src/plugins/impl/FileUploadPlugin.tsx +3 -3
- package/src/plugins/impl/MatrixPlugin.tsx +4 -4
- package/src/plugins/impl/MicrophonePlugin.tsx +3 -3
- package/src/plugins/impl/MultiselectPlugin.tsx +3 -3
- package/src/plugins/impl/NumberPlugin.tsx +3 -3
- package/src/plugins/impl/RadioPlugin.tsx +3 -3
- package/src/plugins/impl/RangeSliderPlugin.tsx +3 -3
- package/src/plugins/impl/RefreshPlugin.tsx +3 -3
- package/src/plugins/impl/SliderPlugin.tsx +3 -3
- package/src/plugins/impl/SwitchPlugin.tsx +3 -3
- package/src/plugins/impl/TabsPlugin.tsx +3 -3
- package/src/plugins/impl/TextAreaPlugin.tsx +3 -3
- package/src/plugins/impl/TextInputPlugin.tsx +3 -3
- package/src/plugins/impl/__tests__/MatrixPlugin.test.tsx +2 -2
- package/src/plugins/impl/anywidget/model.ts +10 -10
- package/src/plugins/impl/anywidget/registry.ts +12 -9
- package/src/plugins/impl/anywidget/runtime.ts +11 -9
- package/src/plugins/impl/anywidget/widget-binding.ts +6 -6
- package/src/plugins/impl/matplotlib/MatplotlibPlugin.tsx +3 -3
- package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +2 -2
- package/src/plugins/impl/matplotlib/matplotlib-renderer.ts +2 -2
- package/src/plugins/impl/mpl-interactive/mpl-websocket-shim.ts +10 -10
- package/src/plugins/impl/panel/utils.ts +5 -5
- package/src/plugins/impl/plotly/PlotlyPlugin.tsx +3 -3
- package/src/plugins/impl/vega/VegaPlugin.tsx +3 -3
- package/src/plugins/impl/vega/__tests__/use-vega-container-remeasure.test.ts +7 -7
- package/src/plugins/layout/AccordionPlugin.tsx +3 -3
- package/src/plugins/layout/CalloutPlugin.tsx +3 -3
- package/src/plugins/layout/ImageComparisonPlugin.tsx +5 -3
- package/src/plugins/layout/JsonOutputPlugin.tsx +3 -3
- package/src/plugins/layout/MimeRenderPlugin.tsx +3 -3
- package/src/plugins/layout/NavigationMenuPlugin.tsx +3 -3
- package/src/plugins/layout/OutlinePlugin.tsx +3 -3
- package/src/plugins/layout/ProgressPlugin.tsx +3 -3
- package/src/plugins/layout/RoutesPlugin.tsx +3 -3
- package/src/plugins/layout/StatPlugin.tsx +3 -3
- package/src/plugins/layout/TexPlugin.tsx +3 -3
- package/src/plugins/layout/carousel/CarouselPlugin.tsx +4 -4
- package/src/plugins/layout/mermaid/MermaidPlugin.tsx +3 -3
- package/src/utils/Deferred.ts +6 -6
- package/src/utils/async-capture-tracker.ts +10 -7
- package/src/utils/errors.ts +5 -5
- package/src/utils/id-tree.tsx +83 -80
- package/src/utils/lru.ts +1 -1
- package/src/utils/multi-map.ts +14 -12
- package/src/utils/paths.ts +6 -6
- package/src/utils/pluralize.ts +3 -3
- package/src/utils/progress.ts +6 -6
- package/src/utils/python-poet/poet.ts +14 -14
- package/src/utils/routes.ts +4 -2
- package/src/utils/semaphore.ts +6 -6
- package/src/utils/storage/storage.ts +6 -6
- package/src/utils/storage/typed.ts +16 -12
- package/src/utils/time.ts +9 -9
- package/src/utils/timed-cache.ts +4 -4
- package/src/utils/tracer.ts +9 -6
|
@@ -8,12 +8,12 @@ export class MessageBuffer<T> {
|
|
|
8
8
|
private buffer: T[];
|
|
9
9
|
private started = false;
|
|
10
10
|
private onMessage: (data: T) => void;
|
|
11
|
-
constructor(onMessage: (data: T) => void) {
|
|
11
|
+
public constructor(onMessage: (data: T) => void) {
|
|
12
12
|
this.onMessage = onMessage;
|
|
13
13
|
this.buffer = [];
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
push = (data: T) => {
|
|
16
|
+
public push = (data: T) => {
|
|
17
17
|
if (this.started) {
|
|
18
18
|
this.onMessage(data);
|
|
19
19
|
} else {
|
|
@@ -24,7 +24,7 @@ export class MessageBuffer<T> {
|
|
|
24
24
|
/**
|
|
25
25
|
* Start processing messages
|
|
26
26
|
*/
|
|
27
|
-
start = () => {
|
|
27
|
+
public start = () => {
|
|
28
28
|
this.started = true;
|
|
29
29
|
// Flush the buffer
|
|
30
30
|
this.buffer.forEach((data) => this.onMessage(data));
|
|
@@ -7,20 +7,20 @@ let innerListeners: Record<string, ((e: unknown) => void)[]>;
|
|
|
7
7
|
|
|
8
8
|
vi.mock("partysocket/ws", () => {
|
|
9
9
|
class FakeReconnectingWebSocket {
|
|
10
|
-
retryCount = 0;
|
|
11
|
-
readyState = WebSocket.CONNECTING;
|
|
12
|
-
constructor() {
|
|
10
|
+
public retryCount = 0;
|
|
11
|
+
public readyState = WebSocket.CONNECTING;
|
|
12
|
+
public constructor() {
|
|
13
13
|
innerListeners = { open: [], close: [], message: [], error: [] };
|
|
14
14
|
}
|
|
15
|
-
addEventListener(event: string, cb: (e: unknown) => void) {
|
|
15
|
+
public addEventListener(event: string, cb: (e: unknown) => void) {
|
|
16
16
|
innerListeners[event].push(cb);
|
|
17
17
|
}
|
|
18
|
-
removeEventListener(event: string, cb: (e: unknown) => void) {
|
|
18
|
+
public removeEventListener(event: string, cb: (e: unknown) => void) {
|
|
19
19
|
innerListeners[event] = innerListeners[event].filter((c) => c !== cb);
|
|
20
20
|
}
|
|
21
|
-
reconnect() {}
|
|
22
|
-
close() {}
|
|
23
|
-
send() {}
|
|
21
|
+
public reconnect() {}
|
|
22
|
+
public close() {}
|
|
23
|
+
public send() {}
|
|
24
24
|
}
|
|
25
25
|
return { default: FakeReconnectingWebSocket };
|
|
26
26
|
});
|
|
@@ -13,11 +13,13 @@ export class BasicTransport implements IConnectionTransport {
|
|
|
13
13
|
private subscriptions = new ConnectionSubscriptions();
|
|
14
14
|
private producer?: MessageProducer;
|
|
15
15
|
|
|
16
|
-
static withProducerCallback(
|
|
16
|
+
public static withProducerCallback(
|
|
17
|
+
producer: MessageProducer,
|
|
18
|
+
): IConnectionTransport {
|
|
17
19
|
return new BasicTransport(producer);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
static empty(): IConnectionTransport {
|
|
22
|
+
public static empty(): IConnectionTransport {
|
|
21
23
|
return new BasicTransport();
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -39,21 +41,26 @@ export class BasicTransport implements IConnectionTransport {
|
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
get readyState(): WebSocket["readyState"] {
|
|
44
|
+
public get readyState(): WebSocket["readyState"] {
|
|
43
45
|
return WebSocket.OPEN;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
reconnect(
|
|
48
|
+
public reconnect(
|
|
49
|
+
_code?: number | undefined,
|
|
50
|
+
_reason?: string | undefined,
|
|
51
|
+
): void {
|
|
47
52
|
this.close();
|
|
48
53
|
this.connect();
|
|
49
54
|
return;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
close(): void {
|
|
57
|
+
public close(): void {
|
|
53
58
|
this.subscriptions.notify("close", new Event("close"));
|
|
54
59
|
}
|
|
55
60
|
|
|
56
|
-
send(
|
|
61
|
+
public send(
|
|
62
|
+
data: string | ArrayBuffer | Blob | ArrayBufferView,
|
|
63
|
+
): Promise<void> {
|
|
57
64
|
this.subscriptions.notify(
|
|
58
65
|
"message",
|
|
59
66
|
new MessageEvent("message", {
|
|
@@ -63,7 +70,7 @@ export class BasicTransport implements IConnectionTransport {
|
|
|
63
70
|
return Promise.resolve();
|
|
64
71
|
}
|
|
65
72
|
|
|
66
|
-
addEventListener<T extends ConnectionEvent>(
|
|
73
|
+
public addEventListener<T extends ConnectionEvent>(
|
|
67
74
|
event: T,
|
|
68
75
|
callback: ConnectionTransportCallback<T>,
|
|
69
76
|
): void {
|
|
@@ -83,7 +90,7 @@ export class BasicTransport implements IConnectionTransport {
|
|
|
83
90
|
}
|
|
84
91
|
}
|
|
85
92
|
|
|
86
|
-
removeEventListener<T extends ConnectionEvent>(
|
|
93
|
+
public removeEventListener<T extends ConnectionEvent>(
|
|
87
94
|
event: T,
|
|
88
95
|
callback: ConnectionTransportCallback<T>,
|
|
89
96
|
): void {
|
|
@@ -52,7 +52,7 @@ export class SseTransport implements IConnectionTransport {
|
|
|
52
52
|
private userClosed = false;
|
|
53
53
|
private state: WebSocket["readyState"] = WebSocket.CLOSED;
|
|
54
54
|
|
|
55
|
-
constructor(
|
|
55
|
+
public constructor(
|
|
56
56
|
urlProvider: () => string,
|
|
57
57
|
headersProvider: () => Record<string, string> = () => ({}),
|
|
58
58
|
) {
|
|
@@ -60,11 +60,11 @@ export class SseTransport implements IConnectionTransport {
|
|
|
60
60
|
this.headersProvider = headersProvider;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
get readyState(): WebSocket["readyState"] {
|
|
63
|
+
public get readyState(): WebSocket["readyState"] {
|
|
64
64
|
return this.state;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
reconnect(_code?: number, _reason?: string): void {
|
|
67
|
+
public reconnect(_code?: number, _reason?: string): void {
|
|
68
68
|
this.userClosed = false;
|
|
69
69
|
this.retryCount = 0;
|
|
70
70
|
this.clearRetryTimer();
|
|
@@ -72,7 +72,7 @@ export class SseTransport implements IConnectionTransport {
|
|
|
72
72
|
this.connect();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
close(): void {
|
|
75
|
+
public close(): void {
|
|
76
76
|
this.userClosed = true;
|
|
77
77
|
this.clearRetryTimer();
|
|
78
78
|
this.state = WebSocket.CLOSED;
|
|
@@ -80,13 +80,13 @@ export class SseTransport implements IConnectionTransport {
|
|
|
80
80
|
this.abortController = null;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
send(_data: string | ArrayBuffer | Blob | ArrayBufferView): void {
|
|
83
|
+
public send(_data: string | ArrayBuffer | Blob | ArrayBufferView): void {
|
|
84
84
|
// The kernel connection is receive-only; all client requests go over
|
|
85
85
|
// HTTP POST endpoints.
|
|
86
86
|
Logger.warn("SseTransport does not support send(); dropping message");
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
addEventListener<T extends ConnectionEvent>(
|
|
89
|
+
public addEventListener<T extends ConnectionEvent>(
|
|
90
90
|
event: T,
|
|
91
91
|
callback: ConnectionTransportCallback<T>,
|
|
92
92
|
): void {
|
|
@@ -96,7 +96,7 @@ export class SseTransport implements IConnectionTransport {
|
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
removeEventListener<T extends ConnectionEvent>(
|
|
99
|
+
public removeEventListener<T extends ConnectionEvent>(
|
|
100
100
|
event: T,
|
|
101
101
|
callback: ConnectionTransportCallback<T>,
|
|
102
102
|
): void {
|
|
@@ -33,7 +33,7 @@ export class ConnectionSubscriptions {
|
|
|
33
33
|
Set<ConnectionTransportCallback<ConnectionEvent>>
|
|
34
34
|
>();
|
|
35
35
|
|
|
36
|
-
addSubscription(
|
|
36
|
+
public addSubscription(
|
|
37
37
|
event: ConnectionEvent,
|
|
38
38
|
callback: ConnectionTransportCallback<ConnectionEvent>,
|
|
39
39
|
): void {
|
|
@@ -43,14 +43,14 @@ export class ConnectionSubscriptions {
|
|
|
43
43
|
this.subscriptions.get(event)?.add(callback);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
removeSubscription(
|
|
46
|
+
public removeSubscription(
|
|
47
47
|
event: ConnectionEvent,
|
|
48
48
|
callback: ConnectionTransportCallback<ConnectionEvent>,
|
|
49
49
|
): void {
|
|
50
50
|
this.subscriptions.get(event)?.delete(callback);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
notify(
|
|
53
|
+
public notify(
|
|
54
54
|
event: ConnectionEvent,
|
|
55
55
|
data: IConnectionTransportMap[ConnectionEvent],
|
|
56
56
|
): void {
|
|
@@ -20,7 +20,7 @@ export class WsTransport implements IConnectionTransport {
|
|
|
20
20
|
ConnectionTransportCallback<"close">
|
|
21
21
|
>();
|
|
22
22
|
|
|
23
|
-
constructor(urlProvider: () => string) {
|
|
23
|
+
public constructor(urlProvider: () => string) {
|
|
24
24
|
this.inner = new ReconnectingWebSocket(urlProvider, undefined, {
|
|
25
25
|
maxRetries: MAX_RETRIES,
|
|
26
26
|
debug: false,
|
|
@@ -30,23 +30,25 @@ export class WsTransport implements IConnectionTransport {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
get readyState(): WebSocket["readyState"] {
|
|
33
|
+
public get readyState(): WebSocket["readyState"] {
|
|
34
34
|
return this.inner.readyState as WebSocket["readyState"];
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
reconnect(code?: number, reason?: string): void {
|
|
37
|
+
public reconnect(code?: number, reason?: string): void {
|
|
38
38
|
this.inner.reconnect(code, reason);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
close(): void {
|
|
41
|
+
public close(): void {
|
|
42
42
|
this.inner.close();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
send(
|
|
45
|
+
public send(
|
|
46
|
+
data: string | ArrayBuffer | Blob | ArrayBufferView<ArrayBuffer>,
|
|
47
|
+
): void {
|
|
46
48
|
this.inner.send(data);
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
addEventListener<T extends ConnectionEvent>(
|
|
51
|
+
public addEventListener<T extends ConnectionEvent>(
|
|
50
52
|
event: T,
|
|
51
53
|
callback: ConnectionTransportCallback<T>,
|
|
52
54
|
): void {
|
|
@@ -78,7 +80,7 @@ export class WsTransport implements IConnectionTransport {
|
|
|
78
80
|
this.inner.addEventListener(event, callback as never);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
removeEventListener<T extends ConnectionEvent>(
|
|
83
|
+
public removeEventListener<T extends ConnectionEvent>(
|
|
82
84
|
event: T,
|
|
83
85
|
callback: ConnectionTransportCallback<T>,
|
|
84
86
|
): void {
|
|
@@ -10,23 +10,23 @@ const mockObserve = vi.fn();
|
|
|
10
10
|
const mockDisconnect = vi.fn();
|
|
11
11
|
|
|
12
12
|
global.ResizeObserver = class MockResizeObserver {
|
|
13
|
-
callback: ResizeObserverCallback;
|
|
13
|
+
public callback: ResizeObserverCallback;
|
|
14
14
|
|
|
15
|
-
constructor(callback: ResizeObserverCallback) {
|
|
15
|
+
public constructor(callback: ResizeObserverCallback) {
|
|
16
16
|
this.callback = callback;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
observe(target: Element) {
|
|
19
|
+
public observe(target: Element) {
|
|
20
20
|
mockObserve(target);
|
|
21
21
|
// Simulate initial observation callback
|
|
22
22
|
this.callback([], this);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
unobserve() {
|
|
25
|
+
public unobserve() {
|
|
26
26
|
// noop
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
disconnect() {
|
|
29
|
+
public disconnect() {
|
|
30
30
|
mockDisconnect();
|
|
31
31
|
}
|
|
32
32
|
};
|
|
@@ -16,9 +16,9 @@ describe("useResizeObserver", () => {
|
|
|
16
16
|
it("should call observe when ref is provided", () => {
|
|
17
17
|
const observeSpy = vi.fn();
|
|
18
18
|
global.ResizeObserver = class MockedResizeObserver {
|
|
19
|
-
observe = observeSpy;
|
|
20
|
-
unobserve = vi.fn();
|
|
21
|
-
disconnect = vi.fn();
|
|
19
|
+
public observe = observeSpy;
|
|
20
|
+
public unobserve = vi.fn();
|
|
21
|
+
public disconnect = vi.fn();
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
renderHook(() =>
|
|
@@ -33,9 +33,9 @@ describe("useResizeObserver", () => {
|
|
|
33
33
|
it("should not call observe when ref is not provided", () => {
|
|
34
34
|
const observeSpy = vi.fn();
|
|
35
35
|
global.ResizeObserver = class MockedResizeObserver {
|
|
36
|
-
observe = observeSpy;
|
|
37
|
-
unobserve = vi.fn();
|
|
38
|
-
disconnect = vi.fn();
|
|
36
|
+
public observe = observeSpy;
|
|
37
|
+
public unobserve = vi.fn();
|
|
38
|
+
public disconnect = vi.fn();
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
renderHook(() =>
|
|
@@ -50,9 +50,9 @@ describe("useResizeObserver", () => {
|
|
|
50
50
|
it("should not call observe when skipped", () => {
|
|
51
51
|
const observeSpy = vi.fn();
|
|
52
52
|
global.ResizeObserver = class MockedResizeObserver {
|
|
53
|
-
observe = observeSpy;
|
|
54
|
-
unobserve = vi.fn();
|
|
55
|
-
disconnect = vi.fn();
|
|
53
|
+
public observe = observeSpy;
|
|
54
|
+
public unobserve = vi.fn();
|
|
55
|
+
public disconnect = vi.fn();
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
renderHook(() =>
|
|
@@ -68,9 +68,9 @@ describe("useResizeObserver", () => {
|
|
|
68
68
|
it("disconnect should be called once unmounted", () => {
|
|
69
69
|
const disconnectSpy = vi.fn();
|
|
70
70
|
global.ResizeObserver = class MockedResizeObserver {
|
|
71
|
-
observe = vi.fn();
|
|
72
|
-
unobserve = vi.fn();
|
|
73
|
-
disconnect = disconnectSpy;
|
|
71
|
+
public observe = vi.fn();
|
|
72
|
+
public unobserve = vi.fn();
|
|
73
|
+
public disconnect = disconnectSpy;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
const { unmount } = renderHook(() =>
|
|
@@ -336,7 +336,7 @@ export function registerReactComponent<T>(plugin: IPlugin<T, unknown>): void {
|
|
|
336
336
|
private pluginRef = createRef<PluginSlotHandle>();
|
|
337
337
|
protected __type__ = customElementLocator;
|
|
338
338
|
|
|
339
|
-
constructor() {
|
|
339
|
+
public constructor() {
|
|
340
340
|
super();
|
|
341
341
|
// Create a shadow root so we can store the React tree on the shadow root, while the original
|
|
342
342
|
// element's children are still on the DOM
|
|
@@ -349,7 +349,7 @@ export function registerReactComponent<T>(plugin: IPlugin<T, unknown>): void {
|
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
connectedCallback() {
|
|
352
|
+
public connectedCallback() {
|
|
353
353
|
// Skip mounting if this element is in the light DOM of another
|
|
354
354
|
// marimo custom element. The parent element's shadow DOM will
|
|
355
355
|
// re-create this element via getChildren() -> renderHTML(), so
|
|
@@ -383,7 +383,7 @@ export function registerReactComponent<T>(plugin: IPlugin<T, unknown>): void {
|
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
-
disconnectedCallback() {
|
|
386
|
+
public disconnectedCallback() {
|
|
387
387
|
this.observer.disconnect();
|
|
388
388
|
this.root?.unmount();
|
|
389
389
|
if (this.mounted) {
|
|
@@ -419,7 +419,7 @@ export function registerReactComponent<T>(plugin: IPlugin<T, unknown>): void {
|
|
|
419
419
|
* Reset the plugin initial value and data.
|
|
420
420
|
* And then re-render the plugin.
|
|
421
421
|
*/
|
|
422
|
-
reset() {
|
|
422
|
+
public reset() {
|
|
423
423
|
this.dispatchEvent(
|
|
424
424
|
createInputEvent(parseAttrValue(this.dataset.initialValue), this),
|
|
425
425
|
);
|
|
@@ -429,7 +429,7 @@ export function registerReactComponent<T>(plugin: IPlugin<T, unknown>): void {
|
|
|
429
429
|
/**
|
|
430
430
|
* Re-render the plugin.
|
|
431
431
|
*/
|
|
432
|
-
rerender() {
|
|
432
|
+
public rerender() {
|
|
433
433
|
this.pluginRef.current?.reset();
|
|
434
434
|
}
|
|
435
435
|
|
|
@@ -19,7 +19,7 @@ export function initializeSidebarElement(): void {
|
|
|
19
19
|
private observer?: MutationObserver;
|
|
20
20
|
private uniqueId = Symbol(createId());
|
|
21
21
|
|
|
22
|
-
connectedCallback() {
|
|
22
|
+
public connectedCallback() {
|
|
23
23
|
// Render the component for the first time
|
|
24
24
|
this.mountReactComponent();
|
|
25
25
|
|
|
@@ -39,7 +39,7 @@ export function initializeSidebarElement(): void {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
disconnectedCallback() {
|
|
42
|
+
public disconnectedCallback() {
|
|
43
43
|
if (this.observer) {
|
|
44
44
|
this.observer.disconnect();
|
|
45
45
|
this.unmountReactComponent();
|
|
@@ -20,9 +20,9 @@ interface Data {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export class ButtonPlugin implements IPlugin<number, Data> {
|
|
23
|
-
tagName = "marimo-button";
|
|
23
|
+
public tagName = "marimo-button";
|
|
24
24
|
|
|
25
|
-
validator = z.object({
|
|
25
|
+
public validator = z.object({
|
|
26
26
|
label: z.string(),
|
|
27
27
|
kind: zodIntent,
|
|
28
28
|
disabled: z.boolean().default(false),
|
|
@@ -31,7 +31,7 @@ export class ButtonPlugin implements IPlugin<number, Data> {
|
|
|
31
31
|
keyboardShortcut: z.string().optional(),
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
render(props: IPluginProps<number, Data>): JSX.Element {
|
|
34
|
+
public render(props: IPluginProps<number, Data>): JSX.Element {
|
|
35
35
|
const {
|
|
36
36
|
data: { disabled, kind, label, fullWidth, tooltip, keyboardShortcut },
|
|
37
37
|
} = props;
|
|
@@ -18,15 +18,15 @@ interface Data {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export class CheckboxPlugin implements IPlugin<T, Data> {
|
|
21
|
-
tagName = "marimo-checkbox";
|
|
21
|
+
public tagName = "marimo-checkbox";
|
|
22
22
|
|
|
23
|
-
validator = z.object({
|
|
23
|
+
public validator = z.object({
|
|
24
24
|
initialValue: z.boolean(),
|
|
25
25
|
label: z.string().nullable(),
|
|
26
26
|
disabled: z.boolean().optional(),
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
render(props: IPluginProps<T, Data>): JSX.Element {
|
|
29
|
+
public render(props: IPluginProps<T, Data>): JSX.Element {
|
|
30
30
|
return <CheckboxComponent {...props} />;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -25,9 +25,9 @@ interface Data {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export class CodeEditorPlugin implements IPlugin<T, Data> {
|
|
28
|
-
tagName = "marimo-code-editor";
|
|
28
|
+
public tagName = "marimo-code-editor";
|
|
29
29
|
|
|
30
|
-
validator = z.object({
|
|
30
|
+
public validator = z.object({
|
|
31
31
|
initialValue: z.string(),
|
|
32
32
|
language: z.string().default("python"),
|
|
33
33
|
placeholder: z.string(),
|
|
@@ -40,7 +40,7 @@ export class CodeEditorPlugin implements IPlugin<T, Data> {
|
|
|
40
40
|
debounce: z.union([z.boolean(), z.number()]).default(false),
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
render(props: IPluginProps<T, Data>): JSX.Element {
|
|
43
|
+
public render(props: IPluginProps<T, Data>): JSX.Element {
|
|
44
44
|
return (
|
|
45
45
|
<CodeEditorComponent
|
|
46
46
|
{...props.data}
|
|
@@ -19,9 +19,9 @@ interface Data {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export class DatePickerPlugin implements IPlugin<T, Data> {
|
|
22
|
-
tagName = "marimo-date";
|
|
22
|
+
public tagName = "marimo-date";
|
|
23
23
|
|
|
24
|
-
validator = z.object({
|
|
24
|
+
public validator = z.object({
|
|
25
25
|
initialValue: z.string(),
|
|
26
26
|
label: z.string().nullable(),
|
|
27
27
|
start: z.string(),
|
|
@@ -31,7 +31,7 @@ export class DatePickerPlugin implements IPlugin<T, Data> {
|
|
|
31
31
|
disabled: z.boolean().optional(),
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
render(props: IPluginProps<T, Data>): JSX.Element {
|
|
34
|
+
public render(props: IPluginProps<T, Data>): JSX.Element {
|
|
35
35
|
return (
|
|
36
36
|
<DatePickerComponent
|
|
37
37
|
{...props.data}
|
|
@@ -19,9 +19,9 @@ interface Data {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export class DateRangePickerPlugin implements IPlugin<T, Data> {
|
|
22
|
-
tagName = "marimo-date-range";
|
|
22
|
+
public tagName = "marimo-date-range";
|
|
23
23
|
|
|
24
|
-
validator = z.object({
|
|
24
|
+
public validator = z.object({
|
|
25
25
|
initialValue: z.tuple([z.string(), z.string()]),
|
|
26
26
|
label: z.string().nullable(),
|
|
27
27
|
start: z.string(),
|
|
@@ -31,7 +31,7 @@ export class DateRangePickerPlugin implements IPlugin<T, Data> {
|
|
|
31
31
|
disabled: z.boolean().optional(),
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
render(props: IPluginProps<T, Data>): JSX.Element {
|
|
34
|
+
public render(props: IPluginProps<T, Data>): JSX.Element {
|
|
35
35
|
return (
|
|
36
36
|
<DateRangePickerComponent
|
|
37
37
|
{...props.data}
|
|
@@ -20,9 +20,9 @@ interface Data {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export class DateTimePickerPlugin implements IPlugin<T, Data> {
|
|
23
|
-
tagName = "marimo-datetime";
|
|
23
|
+
public tagName = "marimo-datetime";
|
|
24
24
|
|
|
25
|
-
validator = z.object({
|
|
25
|
+
public validator = z.object({
|
|
26
26
|
initialValue: z.string(),
|
|
27
27
|
label: z.string().nullable(),
|
|
28
28
|
start: z.string(),
|
|
@@ -33,7 +33,7 @@ export class DateTimePickerPlugin implements IPlugin<T, Data> {
|
|
|
33
33
|
disabled: z.boolean().optional(),
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
render(props: IPluginProps<T, Data>): JSX.Element {
|
|
36
|
+
public render(props: IPluginProps<T, Data>): JSX.Element {
|
|
37
37
|
return (
|
|
38
38
|
<DateTimePickerComponent
|
|
39
39
|
{...props.data}
|
|
@@ -18,14 +18,14 @@ interface Data {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export class DictPlugin implements IPlugin<T, Data> {
|
|
21
|
-
tagName = "marimo-dict";
|
|
21
|
+
public tagName = "marimo-dict";
|
|
22
22
|
|
|
23
|
-
validator = z.object({
|
|
23
|
+
public validator = z.object({
|
|
24
24
|
label: z.string().nullable(),
|
|
25
25
|
elementIds: z.record(z.string(), z.string()),
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
render(props: IPluginProps<T, Data>): JSX.Element {
|
|
28
|
+
public render(props: IPluginProps<T, Data>): JSX.Element {
|
|
29
29
|
return (
|
|
30
30
|
<Dict {...props.data} value={props.value} setValue={props.setValue}>
|
|
31
31
|
{props.children}
|
|
@@ -17,9 +17,9 @@ interface Data {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export class DropdownPlugin implements IPlugin<string[], Data> {
|
|
20
|
-
tagName = "marimo-dropdown";
|
|
20
|
+
public tagName = "marimo-dropdown";
|
|
21
21
|
|
|
22
|
-
validator = z.object({
|
|
22
|
+
public validator = z.object({
|
|
23
23
|
initialValue: z.array(z.string()),
|
|
24
24
|
label: z.string().nullable(),
|
|
25
25
|
options: z.array(z.string()),
|
|
@@ -29,7 +29,7 @@ export class DropdownPlugin implements IPlugin<string[], Data> {
|
|
|
29
29
|
disabled: z.boolean().default(false),
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
render(props: IPluginProps<string[], Data>): JSX.Element {
|
|
32
|
+
public render(props: IPluginProps<string[], Data>): JSX.Element {
|
|
33
33
|
if (props.data.searchable) {
|
|
34
34
|
const value = props.value.length > 0 ? props.value[0] : null;
|
|
35
35
|
const setValue = (newValue: string | null) =>
|
|
@@ -34,9 +34,9 @@ interface Data {
|
|
|
34
34
|
type T = [string, string][];
|
|
35
35
|
|
|
36
36
|
export class FileUploadPlugin implements IPlugin<T, Data> {
|
|
37
|
-
tagName = "marimo-file";
|
|
37
|
+
public tagName = "marimo-file";
|
|
38
38
|
|
|
39
|
-
validator = z.object({
|
|
39
|
+
public validator = z.object({
|
|
40
40
|
filetypes: z.array(z.string()),
|
|
41
41
|
multiple: z.boolean(),
|
|
42
42
|
kind: z.enum(["button", "area"]),
|
|
@@ -44,7 +44,7 @@ export class FileUploadPlugin implements IPlugin<T, Data> {
|
|
|
44
44
|
max_size: z.number(),
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
render(props: IPluginProps<T, Data>): JSX.Element {
|
|
47
|
+
public render(props: IPluginProps<T, Data>): JSX.Element {
|
|
48
48
|
return (
|
|
49
49
|
<FileUpload
|
|
50
50
|
label={props.data.label}
|
|
@@ -23,11 +23,11 @@ interface Data {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export class MatrixPlugin implements IPlugin<T, Data> {
|
|
26
|
-
tagName = "marimo-matrix";
|
|
26
|
+
public tagName = "marimo-matrix";
|
|
27
27
|
|
|
28
|
-
cssStyles = [matrixCss];
|
|
28
|
+
public cssStyles = [matrixCss];
|
|
29
29
|
|
|
30
|
-
validator = z.object({
|
|
30
|
+
public validator = z.object({
|
|
31
31
|
initialValue: z.array(z.array(z.number())),
|
|
32
32
|
label: z.string().nullable(),
|
|
33
33
|
minValue: z.array(z.array(z.number())).nullish(),
|
|
@@ -42,7 +42,7 @@ export class MatrixPlugin implements IPlugin<T, Data> {
|
|
|
42
42
|
disabled: z.array(z.array(z.boolean())),
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
render(props: IPluginProps<T, Data>): JSX.Element {
|
|
45
|
+
public render(props: IPluginProps<T, Data>): JSX.Element {
|
|
46
46
|
return (
|
|
47
47
|
<MatrixComponent
|
|
48
48
|
{...props.data}
|
|
@@ -18,13 +18,13 @@ interface Data {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export class MicrophonePlugin implements IPlugin<Value, Data> {
|
|
21
|
-
tagName = "marimo-microphone";
|
|
21
|
+
public tagName = "marimo-microphone";
|
|
22
22
|
|
|
23
|
-
validator = z.object({
|
|
23
|
+
public validator = z.object({
|
|
24
24
|
label: z.string().nullish(),
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
render(props: IPluginProps<Value, Data>): JSX.Element {
|
|
27
|
+
public render(props: IPluginProps<Value, Data>): JSX.Element {
|
|
28
28
|
return <Microphone {...props} />;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -17,9 +17,9 @@ interface Data {
|
|
|
17
17
|
type T = string[];
|
|
18
18
|
|
|
19
19
|
export class MultiselectPlugin implements IPlugin<T, Data> {
|
|
20
|
-
tagName = "marimo-multiselect";
|
|
20
|
+
public tagName = "marimo-multiselect";
|
|
21
21
|
|
|
22
|
-
validator = z.object({
|
|
22
|
+
public validator = z.object({
|
|
23
23
|
initialValue: z.array(z.string()),
|
|
24
24
|
label: z.string().nullable(),
|
|
25
25
|
options: z.array(z.string()),
|
|
@@ -28,7 +28,7 @@ export class MultiselectPlugin implements IPlugin<T, Data> {
|
|
|
28
28
|
disabled: z.boolean().default(false),
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
render(props: IPluginProps<string[], Data>): JSX.Element {
|
|
31
|
+
public render(props: IPluginProps<string[], Data>): JSX.Element {
|
|
32
32
|
return (
|
|
33
33
|
<Multiselect
|
|
34
34
|
{...props.data}
|
|
@@ -20,9 +20,9 @@ interface Data {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export class NumberPlugin implements IPlugin<T | null, Data> {
|
|
23
|
-
tagName = "marimo-number";
|
|
23
|
+
public tagName = "marimo-number";
|
|
24
24
|
|
|
25
|
-
validator = z.object({
|
|
25
|
+
public validator = z.object({
|
|
26
26
|
initialValue: z.number().nullish(),
|
|
27
27
|
label: z.string().nullable(),
|
|
28
28
|
start: z.number().nullish(),
|
|
@@ -33,7 +33,7 @@ export class NumberPlugin implements IPlugin<T | null, Data> {
|
|
|
33
33
|
disabled: z.boolean().optional(),
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
render(props: IPluginProps<T | null, Data>): JSX.Element {
|
|
36
|
+
public render(props: IPluginProps<T | null, Data>): JSX.Element {
|
|
37
37
|
return (
|
|
38
38
|
<NumberComponent
|
|
39
39
|
{...props.data}
|