@marimo-team/frontend 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/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
|
@@ -45,12 +45,12 @@ interface UIElementEntry {
|
|
|
45
45
|
*/
|
|
46
46
|
export class UIElementRegistry {
|
|
47
47
|
// maps UIElement objectIds to entries.
|
|
48
|
-
entries: Map<UIElementId, UIElementEntry>;
|
|
48
|
+
public entries: Map<UIElementId, UIElementEntry>;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Shared instance of UIElementRegistry since this must be a singleton.
|
|
52
52
|
*/
|
|
53
|
-
static get INSTANCE(): UIElementRegistry {
|
|
53
|
+
public static get INSTANCE(): UIElementRegistry {
|
|
54
54
|
const KEY = "_marimo_private_UIElementRegistry";
|
|
55
55
|
if (!window[KEY]) {
|
|
56
56
|
window[KEY] = new UIElementRegistry();
|
|
@@ -62,11 +62,11 @@ export class UIElementRegistry {
|
|
|
62
62
|
this.entries = new Map();
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
has(objectId: UIElementId): boolean {
|
|
65
|
+
public has(objectId: UIElementId): boolean {
|
|
66
66
|
return this.entries.has(objectId);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
set(objectId: UIElementId, value: ValueType): void {
|
|
69
|
+
public set(objectId: UIElementId, value: ValueType): void {
|
|
70
70
|
if (this.entries.has(objectId)) {
|
|
71
71
|
Logger.debug(
|
|
72
72
|
"UIElementRegistry overwriting entry for objectId.",
|
|
@@ -86,7 +86,7 @@ export class UIElementRegistry {
|
|
|
86
86
|
* @param objectId - id of the UIElement
|
|
87
87
|
* @param instance - the HTMLElement that the UIElement wraps
|
|
88
88
|
*/
|
|
89
|
-
registerInstance(objectId: UIElementId, instance: HTMLElement) {
|
|
89
|
+
public registerInstance(objectId: UIElementId, instance: HTMLElement) {
|
|
90
90
|
const entry = this.entries.get(objectId);
|
|
91
91
|
if (entry === undefined) {
|
|
92
92
|
this.entries.set(objectId, {
|
|
@@ -109,7 +109,7 @@ export class UIElementRegistry {
|
|
|
109
109
|
* @param instance - the HTMLElement to remove
|
|
110
110
|
*
|
|
111
111
|
*/
|
|
112
|
-
removeInstance(objectId: UIElementId, instance: HTMLElement) {
|
|
112
|
+
public removeInstance(objectId: UIElementId, instance: HTMLElement) {
|
|
113
113
|
const entry = this.entries.get(objectId);
|
|
114
114
|
// The UIElement can be removed from the registry before all
|
|
115
115
|
// instances are removed: UIElement removal is triggered
|
|
@@ -129,7 +129,7 @@ export class UIElementRegistry {
|
|
|
129
129
|
*
|
|
130
130
|
* @param cellId - stringified cellId
|
|
131
131
|
*/
|
|
132
|
-
removeElementsByCell(cellId: CellId) {
|
|
132
|
+
public removeElementsByCell(cellId: CellId) {
|
|
133
133
|
const objectIds = [...this.entries.keys()].filter((objectId) =>
|
|
134
134
|
objectId.startsWith(`${cellId}-`),
|
|
135
135
|
);
|
|
@@ -145,12 +145,12 @@ export class UIElementRegistry {
|
|
|
145
145
|
* @param objectId - id of the UIElement
|
|
146
146
|
* @returns the value for `objectId`, or `undefined` if the object was not found.
|
|
147
147
|
*/
|
|
148
|
-
lookupValue(objectId: UIElementId): ValueType {
|
|
148
|
+
public lookupValue(objectId: UIElementId): ValueType {
|
|
149
149
|
const entry = this.entries.get(objectId);
|
|
150
150
|
return entry === undefined ? undefined : entry.value;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
broadcastMessage(
|
|
153
|
+
public broadcastMessage(
|
|
154
154
|
objectId: UIElementId,
|
|
155
155
|
message: unknown,
|
|
156
156
|
buffers: readonly DataView[],
|
|
@@ -202,7 +202,7 @@ export class UIElementRegistry {
|
|
|
202
202
|
* @param objectId - id of the UIElement
|
|
203
203
|
* @param value - value to broadcast
|
|
204
204
|
*/
|
|
205
|
-
broadcastValueUpdate(
|
|
205
|
+
public broadcastValueUpdate(
|
|
206
206
|
initiator: HTMLElement,
|
|
207
207
|
objectId: UIElementId,
|
|
208
208
|
value: ValueType,
|
|
@@ -510,13 +510,13 @@ export class HotkeyProvider implements IHotkeyProvider {
|
|
|
510
510
|
/**
|
|
511
511
|
* @param platform - See {@link HotkeyProviderOptions.platform}.
|
|
512
512
|
*/
|
|
513
|
-
static create(platform?: Platform): HotkeyProvider {
|
|
513
|
+
public static create(platform?: Platform): HotkeyProvider {
|
|
514
514
|
return new HotkeyProvider(DEFAULT_HOT_KEY, { platform });
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
private hotkeys: Record<HotkeyAction, Hotkey>;
|
|
518
518
|
|
|
519
|
-
constructor(
|
|
519
|
+
public constructor(
|
|
520
520
|
hotkeys: Record<HotkeyAction, Hotkey>,
|
|
521
521
|
options: HotkeyProviderOptions = {},
|
|
522
522
|
) {
|
|
@@ -525,11 +525,11 @@ export class HotkeyProvider implements IHotkeyProvider {
|
|
|
525
525
|
this.mod = this.platform === "mac" ? "Cmd" : "Ctrl";
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
-
iterate(): HotkeyAction[] {
|
|
528
|
+
public iterate(): HotkeyAction[] {
|
|
529
529
|
return Objects.keys(this.hotkeys);
|
|
530
530
|
}
|
|
531
531
|
|
|
532
|
-
getHotkey(action: HotkeyAction): ResolvedHotkey {
|
|
532
|
+
public getHotkey(action: HotkeyAction): ResolvedHotkey {
|
|
533
533
|
const { name, key, additionalKeywords } = this.hotkeys[action];
|
|
534
534
|
if (typeof key === "string") {
|
|
535
535
|
return {
|
|
@@ -553,15 +553,15 @@ export class HotkeyProvider implements IHotkeyProvider {
|
|
|
553
553
|
};
|
|
554
554
|
}
|
|
555
555
|
|
|
556
|
-
getHotkeyDisplay(action: HotkeyAction): string {
|
|
556
|
+
public getHotkeyDisplay(action: HotkeyAction): string {
|
|
557
557
|
return this.hotkeys[action].name;
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
-
isEditable(action: HotkeyAction): boolean {
|
|
560
|
+
public isEditable(action: HotkeyAction): boolean {
|
|
561
561
|
return this.hotkeys[action].editable !== false;
|
|
562
562
|
}
|
|
563
563
|
|
|
564
|
-
getHotkeyGroups(): Record<HotkeyGroup, HotkeyAction[]> {
|
|
564
|
+
public getHotkeyGroups(): Record<HotkeyGroup, HotkeyAction[]> {
|
|
565
565
|
return Objects.groupBy(
|
|
566
566
|
Objects.entries(this.hotkeys),
|
|
567
567
|
([, hotkey]) => hotkey.group,
|
|
@@ -573,7 +573,7 @@ export class HotkeyProvider implements IHotkeyProvider {
|
|
|
573
573
|
export class OverridingHotkeyProvider extends HotkeyProvider {
|
|
574
574
|
private readonly overrides: Partial<Record<HotkeyAction, string | undefined>>;
|
|
575
575
|
|
|
576
|
-
constructor(
|
|
576
|
+
public constructor(
|
|
577
577
|
overrides: Partial<Record<HotkeyAction, string | undefined>>,
|
|
578
578
|
options: HotkeyProviderOptions = {},
|
|
579
579
|
) {
|
|
@@ -581,7 +581,7 @@ export class OverridingHotkeyProvider extends HotkeyProvider {
|
|
|
581
581
|
this.overrides = overrides;
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
-
override getHotkey(action: HotkeyAction): ResolvedHotkey {
|
|
584
|
+
public override getHotkey(action: HotkeyAction): ResolvedHotkey {
|
|
585
585
|
const base = super.getHotkey(action);
|
|
586
586
|
const override = this.overrides[action];
|
|
587
587
|
return {
|
|
@@ -38,12 +38,12 @@ vi.stubGlobal(
|
|
|
38
38
|
|
|
39
39
|
// Create a mock URL class that works as a constructor
|
|
40
40
|
class MockURL {
|
|
41
|
-
href: string;
|
|
42
|
-
constructor(url: string, base?: string | URL) {
|
|
41
|
+
public href: string;
|
|
42
|
+
public constructor(url: string, base?: string | URL) {
|
|
43
43
|
this.href = base ? `${base}/${url}` : url;
|
|
44
44
|
}
|
|
45
|
-
static createObjectURL = vi.fn(() => "blob:mock-url");
|
|
46
|
-
static revokeObjectURL = vi.fn();
|
|
45
|
+
public static createObjectURL = vi.fn(() => "blob:mock-url");
|
|
46
|
+
public static revokeObjectURL = vi.fn();
|
|
47
47
|
}
|
|
48
48
|
vi.stubGlobal("URL", MockURL);
|
|
49
49
|
|
|
@@ -236,11 +236,11 @@ export class MockWorkerFactory implements WorkerFactory {
|
|
|
236
236
|
public workers: Worker[] = [];
|
|
237
237
|
private readonly mockWorker?: Worker;
|
|
238
238
|
|
|
239
|
-
constructor(mockWorker?: Worker) {
|
|
239
|
+
public constructor(mockWorker?: Worker) {
|
|
240
240
|
this.mockWorker = mockWorker;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
create(): Worker {
|
|
243
|
+
public create(): Worker {
|
|
244
244
|
const worker = this.mockWorker || this.createMockWorker();
|
|
245
245
|
this.workers.push(worker);
|
|
246
246
|
return worker;
|
|
@@ -259,11 +259,11 @@ export class MockWorkerFactory implements WorkerFactory {
|
|
|
259
259
|
} as unknown as Worker;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
getCreatedWorkers(): Worker[] {
|
|
262
|
+
public getCreatedWorkers(): Worker[] {
|
|
263
263
|
return this.workers;
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
terminateAll(): void {
|
|
266
|
+
public terminateAll(): void {
|
|
267
267
|
for (const worker of this.workers) {
|
|
268
268
|
worker.terminate();
|
|
269
269
|
}
|
|
@@ -72,7 +72,7 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
72
72
|
|
|
73
73
|
public initialized = new Deferred<void>();
|
|
74
74
|
|
|
75
|
-
constructor(config: IslandsBridgeConfig = {}) {
|
|
75
|
+
public constructor(config: IslandsBridgeConfig = {}) {
|
|
76
76
|
this.store = config.store || defaultStore;
|
|
77
77
|
this.root = config.root || document;
|
|
78
78
|
|
|
@@ -120,7 +120,7 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
async initializeApps(): Promise<void> {
|
|
123
|
+
public async initializeApps(): Promise<void> {
|
|
124
124
|
await this.enqueueAppTransition(async () => {
|
|
125
125
|
await this.workerReady.promise;
|
|
126
126
|
await this.startApps();
|
|
@@ -211,7 +211,7 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
async stopSession(appId?: string): Promise<void> {
|
|
214
|
+
public async stopSession(appId?: string): Promise<void> {
|
|
215
215
|
await this.enqueueAppTransition(async () => {
|
|
216
216
|
const session = this.session;
|
|
217
217
|
if (session?.code === undefined || (appId && session.appId !== appId)) {
|
|
@@ -238,7 +238,7 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
238
238
|
/**
|
|
239
239
|
* Starts a new Python session for an app
|
|
240
240
|
*/
|
|
241
|
-
async startSession(opts: {
|
|
241
|
+
public async startSession(opts: {
|
|
242
242
|
code: string;
|
|
243
243
|
appId: string;
|
|
244
244
|
sessionGeneration: number;
|
|
@@ -249,7 +249,9 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
249
249
|
/**
|
|
250
250
|
* Sets up a consumer for kernel messages
|
|
251
251
|
*/
|
|
252
|
-
consumeMessages(
|
|
252
|
+
public consumeMessages(
|
|
253
|
+
consumer: (message: IslandsKernelMessage) => void,
|
|
254
|
+
): void {
|
|
253
255
|
this.messageConsumer = consumer;
|
|
254
256
|
this.rpc.proxy.send.consumerReady({});
|
|
255
257
|
}
|
|
@@ -258,7 +260,7 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
258
260
|
// RunRequests Implementation
|
|
259
261
|
// ============================================================================
|
|
260
262
|
|
|
261
|
-
sendComponentValues: RunRequests["sendComponentValues"] = async (
|
|
263
|
+
public sendComponentValues: RunRequests["sendComponentValues"] = async (
|
|
262
264
|
request,
|
|
263
265
|
): Promise<null> => {
|
|
264
266
|
await this.putControlRequest({
|
|
@@ -269,11 +271,12 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
269
271
|
return null;
|
|
270
272
|
};
|
|
271
273
|
|
|
272
|
-
sendInstantiate: RunRequests["sendInstantiate"] =
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
public sendInstantiate: RunRequests["sendInstantiate"] =
|
|
275
|
+
async (): Promise<null> => {
|
|
276
|
+
return null;
|
|
277
|
+
};
|
|
275
278
|
|
|
276
|
-
sendFunctionRequest: RunRequests["sendFunctionRequest"] = async (
|
|
279
|
+
public sendFunctionRequest: RunRequests["sendFunctionRequest"] = async (
|
|
277
280
|
request,
|
|
278
281
|
): Promise<null> => {
|
|
279
282
|
await this.putControlRequest({
|
|
@@ -283,7 +286,7 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
283
286
|
return null;
|
|
284
287
|
};
|
|
285
288
|
|
|
286
|
-
sendModelValue: RunRequests["sendModelValue"] = async (request) => {
|
|
289
|
+
public sendModelValue: RunRequests["sendModelValue"] = async (request) => {
|
|
287
290
|
await this.putControlRequest({
|
|
288
291
|
type: "model",
|
|
289
292
|
...request,
|
|
@@ -295,7 +298,7 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
295
298
|
// EditRequests Implementation
|
|
296
299
|
// ============================================================================
|
|
297
300
|
|
|
298
|
-
sendRun: EditRequests["sendRun"] = async (request): Promise<null> => {
|
|
301
|
+
public sendRun: EditRequests["sendRun"] = async (request): Promise<null> => {
|
|
299
302
|
const session = await this.getActiveSession();
|
|
300
303
|
await this.rpc.proxy.request.loadPackages({
|
|
301
304
|
appId: session.appId,
|
|
@@ -316,75 +319,75 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
316
319
|
// Not Implemented (Read-Only Mode)
|
|
317
320
|
// ============================================================================
|
|
318
321
|
|
|
319
|
-
getUsageStats = throwNotImplemented;
|
|
320
|
-
getEnvironmentInfo = throwNotImplemented;
|
|
321
|
-
sendRename = throwNotImplemented;
|
|
322
|
-
sendSave = throwNotImplemented;
|
|
323
|
-
sendCopy = throwNotImplemented;
|
|
324
|
-
sendRunScratchpad = throwNotImplemented;
|
|
325
|
-
sendStdin = throwNotImplemented;
|
|
326
|
-
sendInterrupt = throwNotImplemented;
|
|
327
|
-
sendShutdown = throwNotImplemented;
|
|
328
|
-
sendFormat = throwNotImplemented;
|
|
329
|
-
sendDeleteCell = throwNotImplemented;
|
|
330
|
-
sendInstallMissingPackages = throwNotImplemented;
|
|
331
|
-
sendCodeCompletionRequest = throwNotImplemented;
|
|
332
|
-
saveUserConfig = throwNotImplemented;
|
|
333
|
-
saveAppConfig = throwNotImplemented;
|
|
334
|
-
saveCellConfig = throwNotImplemented;
|
|
335
|
-
sendRestart = throwNotImplemented;
|
|
336
|
-
sendDocumentTransaction = throwNotImplemented;
|
|
337
|
-
readCode = throwNotImplemented;
|
|
338
|
-
readSnippets = throwNotImplemented;
|
|
339
|
-
previewDatasetColumn = throwNotImplemented;
|
|
340
|
-
previewSQLTable = throwNotImplemented;
|
|
341
|
-
previewSQLTableList = throwNotImplemented;
|
|
342
|
-
previewSQLSchemaList = throwNotImplemented;
|
|
343
|
-
previewDataSourceConnection = throwNotImplemented;
|
|
344
|
-
discoverDataSources = throwNotImplemented;
|
|
345
|
-
validateSQL = throwNotImplemented;
|
|
346
|
-
openFile = throwNotImplemented;
|
|
347
|
-
getFileRoots = throwNotImplemented;
|
|
348
|
-
sendListFiles = throwNotImplemented;
|
|
349
|
-
sendSearchFiles = throwNotImplemented;
|
|
350
|
-
sendPdb = throwNotImplemented;
|
|
351
|
-
sendSetBreakpoints = throwNotImplemented;
|
|
352
|
-
sendCreateFileOrFolder = throwNotImplemented;
|
|
353
|
-
sendDeleteFileOrFolder = throwNotImplemented;
|
|
354
|
-
sendCopyFileOrFolder = throwNotImplemented;
|
|
355
|
-
sendRenameFileOrFolder = throwNotImplemented;
|
|
356
|
-
sendUpdateFile = throwNotImplemented;
|
|
357
|
-
sendFileDetails = throwNotImplemented;
|
|
358
|
-
openTutorial = throwNotImplemented;
|
|
359
|
-
getExportAvailability = throwNotImplemented;
|
|
360
|
-
installExportRequirements = throwNotImplemented;
|
|
361
|
-
exportAsHTML = throwNotImplemented;
|
|
362
|
-
exportAsIPYNB = throwNotImplemented;
|
|
363
|
-
exportAsMarkdown = throwNotImplemented;
|
|
364
|
-
exportAsScript = throwNotImplemented;
|
|
365
|
-
exportAsPDF = throwNotImplemented;
|
|
366
|
-
autoExportAsHTML = throwNotImplemented;
|
|
367
|
-
autoExportAsMarkdown = throwNotImplemented;
|
|
368
|
-
autoExportAsIPYNB = throwNotImplemented;
|
|
369
|
-
updateCellOutputs = throwNotImplemented;
|
|
370
|
-
addPackage = throwNotImplemented;
|
|
371
|
-
removePackage = throwNotImplemented;
|
|
372
|
-
getPackageList = throwNotImplemented;
|
|
373
|
-
getSandbox = throwNotImplemented;
|
|
374
|
-
updateManifest = throwNotImplemented;
|
|
375
|
-
syncSandbox = throwNotImplemented;
|
|
376
|
-
getDependencyTree = throwNotImplemented;
|
|
377
|
-
getRecentFiles = throwNotImplemented;
|
|
378
|
-
getWorkspaceFiles = throwNotImplemented;
|
|
379
|
-
getRunningNotebooks = throwNotImplemented;
|
|
380
|
-
shutdownSession = throwNotImplemented;
|
|
381
|
-
listSecretKeys = throwNotImplemented;
|
|
382
|
-
writeSecret = throwNotImplemented;
|
|
383
|
-
invokeAiTool = throwNotImplemented;
|
|
384
|
-
clearCache = throwNotImplemented;
|
|
385
|
-
getCacheInfo = throwNotImplemented;
|
|
386
|
-
listStorageEntries = throwNotImplemented;
|
|
387
|
-
downloadStorage = throwNotImplemented;
|
|
322
|
+
public getUsageStats = throwNotImplemented;
|
|
323
|
+
public getEnvironmentInfo = throwNotImplemented;
|
|
324
|
+
public sendRename = throwNotImplemented;
|
|
325
|
+
public sendSave = throwNotImplemented;
|
|
326
|
+
public sendCopy = throwNotImplemented;
|
|
327
|
+
public sendRunScratchpad = throwNotImplemented;
|
|
328
|
+
public sendStdin = throwNotImplemented;
|
|
329
|
+
public sendInterrupt = throwNotImplemented;
|
|
330
|
+
public sendShutdown = throwNotImplemented;
|
|
331
|
+
public sendFormat = throwNotImplemented;
|
|
332
|
+
public sendDeleteCell = throwNotImplemented;
|
|
333
|
+
public sendInstallMissingPackages = throwNotImplemented;
|
|
334
|
+
public sendCodeCompletionRequest = throwNotImplemented;
|
|
335
|
+
public saveUserConfig = throwNotImplemented;
|
|
336
|
+
public saveAppConfig = throwNotImplemented;
|
|
337
|
+
public saveCellConfig = throwNotImplemented;
|
|
338
|
+
public sendRestart = throwNotImplemented;
|
|
339
|
+
public sendDocumentTransaction = throwNotImplemented;
|
|
340
|
+
public readCode = throwNotImplemented;
|
|
341
|
+
public readSnippets = throwNotImplemented;
|
|
342
|
+
public previewDatasetColumn = throwNotImplemented;
|
|
343
|
+
public previewSQLTable = throwNotImplemented;
|
|
344
|
+
public previewSQLTableList = throwNotImplemented;
|
|
345
|
+
public previewSQLSchemaList = throwNotImplemented;
|
|
346
|
+
public previewDataSourceConnection = throwNotImplemented;
|
|
347
|
+
public discoverDataSources = throwNotImplemented;
|
|
348
|
+
public validateSQL = throwNotImplemented;
|
|
349
|
+
public openFile = throwNotImplemented;
|
|
350
|
+
public getFileRoots = throwNotImplemented;
|
|
351
|
+
public sendListFiles = throwNotImplemented;
|
|
352
|
+
public sendSearchFiles = throwNotImplemented;
|
|
353
|
+
public sendPdb = throwNotImplemented;
|
|
354
|
+
public sendSetBreakpoints = throwNotImplemented;
|
|
355
|
+
public sendCreateFileOrFolder = throwNotImplemented;
|
|
356
|
+
public sendDeleteFileOrFolder = throwNotImplemented;
|
|
357
|
+
public sendCopyFileOrFolder = throwNotImplemented;
|
|
358
|
+
public sendRenameFileOrFolder = throwNotImplemented;
|
|
359
|
+
public sendUpdateFile = throwNotImplemented;
|
|
360
|
+
public sendFileDetails = throwNotImplemented;
|
|
361
|
+
public openTutorial = throwNotImplemented;
|
|
362
|
+
public getExportAvailability = throwNotImplemented;
|
|
363
|
+
public installExportRequirements = throwNotImplemented;
|
|
364
|
+
public exportAsHTML = throwNotImplemented;
|
|
365
|
+
public exportAsIPYNB = throwNotImplemented;
|
|
366
|
+
public exportAsMarkdown = throwNotImplemented;
|
|
367
|
+
public exportAsScript = throwNotImplemented;
|
|
368
|
+
public exportAsPDF = throwNotImplemented;
|
|
369
|
+
public autoExportAsHTML = throwNotImplemented;
|
|
370
|
+
public autoExportAsMarkdown = throwNotImplemented;
|
|
371
|
+
public autoExportAsIPYNB = throwNotImplemented;
|
|
372
|
+
public updateCellOutputs = throwNotImplemented;
|
|
373
|
+
public addPackage = throwNotImplemented;
|
|
374
|
+
public removePackage = throwNotImplemented;
|
|
375
|
+
public getPackageList = throwNotImplemented;
|
|
376
|
+
public getSandbox = throwNotImplemented;
|
|
377
|
+
public updateManifest = throwNotImplemented;
|
|
378
|
+
public syncSandbox = throwNotImplemented;
|
|
379
|
+
public getDependencyTree = throwNotImplemented;
|
|
380
|
+
public getRecentFiles = throwNotImplemented;
|
|
381
|
+
public getWorkspaceFiles = throwNotImplemented;
|
|
382
|
+
public getRunningNotebooks = throwNotImplemented;
|
|
383
|
+
public shutdownSession = throwNotImplemented;
|
|
384
|
+
public listSecretKeys = throwNotImplemented;
|
|
385
|
+
public writeSecret = throwNotImplemented;
|
|
386
|
+
public invokeAiTool = throwNotImplemented;
|
|
387
|
+
public clearCache = throwNotImplemented;
|
|
388
|
+
public getCacheInfo = throwNotImplemented;
|
|
389
|
+
public listStorageEntries = throwNotImplemented;
|
|
390
|
+
public downloadStorage = throwNotImplemented;
|
|
388
391
|
|
|
389
392
|
// The kernel uses msgspec to parse control requests, which requires a 'type'
|
|
390
393
|
// field for discriminated union deserialization.
|
|
@@ -412,7 +415,7 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
|
|
|
412
415
|
/**
|
|
413
416
|
* Cleans up resources (for testing)
|
|
414
417
|
*/
|
|
415
|
-
destroy(): void {
|
|
418
|
+
public destroy(): void {
|
|
416
419
|
// Future: terminate worker if we own it
|
|
417
420
|
}
|
|
418
421
|
}
|
|
@@ -51,7 +51,7 @@ export class MarimoIslandElement extends HTMLElement {
|
|
|
51
51
|
public static readonly editorTagName = ISLAND_TAG_NAMES.CODE_EDITOR;
|
|
52
52
|
public static readonly styleNamespace = ISLAND_CSS_CLASSES.NAMESPACE;
|
|
53
53
|
|
|
54
|
-
constructor() {
|
|
54
|
+
public constructor() {
|
|
55
55
|
super();
|
|
56
56
|
this.classList.add(MarimoIslandElement.styleNamespace);
|
|
57
57
|
}
|
|
@@ -59,7 +59,7 @@ export class MarimoIslandElement extends HTMLElement {
|
|
|
59
59
|
/**
|
|
60
60
|
* Gets the app ID from the element's data attribute
|
|
61
61
|
*/
|
|
62
|
-
get appId(): string {
|
|
62
|
+
public get appId(): string {
|
|
63
63
|
const appId = this.getAttribute(ISLAND_DATA_ATTRIBUTES.APP_ID);
|
|
64
64
|
invariant(appId, "Missing data-app-id attribute");
|
|
65
65
|
return appId;
|
|
@@ -68,7 +68,7 @@ export class MarimoIslandElement extends HTMLElement {
|
|
|
68
68
|
/**
|
|
69
69
|
* Whether this island is reactive (has code sent to Python for execution)
|
|
70
70
|
*/
|
|
71
|
-
get isReactive(): boolean {
|
|
71
|
+
public get isReactive(): boolean {
|
|
72
72
|
return this.getAttribute(ISLAND_DATA_ATTRIBUTES.REACTIVE) === "true";
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -76,7 +76,7 @@ export class MarimoIslandElement extends HTMLElement {
|
|
|
76
76
|
* Gets the cell ID by looking up the cell index in the notebook state.
|
|
77
77
|
* Returns undefined for non-reactive islands (they have no corresponding cell).
|
|
78
78
|
*/
|
|
79
|
-
get cellId(): CellId | undefined {
|
|
79
|
+
public get cellId(): CellId | undefined {
|
|
80
80
|
if (!this.isReactive) {
|
|
81
81
|
return undefined;
|
|
82
82
|
}
|
|
@@ -95,7 +95,7 @@ export class MarimoIslandElement extends HTMLElement {
|
|
|
95
95
|
/**
|
|
96
96
|
* Gets the code for this island cell
|
|
97
97
|
*/
|
|
98
|
-
get code(): string {
|
|
98
|
+
public get code(): string {
|
|
99
99
|
return extractIslandCodeFromEmbed(this);
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -115,7 +115,7 @@ export class MarimoIslandElement extends HTMLElement {
|
|
|
115
115
|
* which can happen inside a React render cycle. Rendering
|
|
116
116
|
* synchronously from there causes "unmount during render" warnings.
|
|
117
117
|
*/
|
|
118
|
-
connectedCallback(): void {
|
|
118
|
+
public connectedCallback(): void {
|
|
119
119
|
const connectionGeneration = ++this.connectionGeneration;
|
|
120
120
|
this.addEventListener(
|
|
121
121
|
ISLAND_SOURCE_CHANGED_EVENT,
|
|
@@ -296,7 +296,7 @@ export class MarimoIslandElement extends HTMLElement {
|
|
|
296
296
|
/**
|
|
297
297
|
* Cleanup when element is removed from DOM
|
|
298
298
|
*/
|
|
299
|
-
disconnectedCallback(): void {
|
|
299
|
+
public disconnectedCallback(): void {
|
|
300
300
|
this.removeEventListener(
|
|
301
301
|
ISLAND_SOURCE_CHANGED_EVENT,
|
|
302
302
|
this.handleSourceChanged,
|
|
@@ -5,7 +5,7 @@ import { describe, expect, it, vi } from "vitest";
|
|
|
5
5
|
import { ReadonlyWasmController } from "../controller";
|
|
6
6
|
|
|
7
7
|
class TestController extends ReadonlyWasmController {
|
|
8
|
-
setPyodide(pyodide: PyodideInterface) {
|
|
8
|
+
public setPyodide(pyodide: PyodideInterface) {
|
|
9
9
|
this.pyodide = pyodide;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -9,7 +9,7 @@ import type { JsonString } from "@/utils/json/base64";
|
|
|
9
9
|
import { Logger } from "../../../utils/Logger";
|
|
10
10
|
|
|
11
11
|
export class ReadonlyWasmController extends DefaultWasmController {
|
|
12
|
-
override async bootstrap(opts: {
|
|
12
|
+
public override async bootstrap(opts: {
|
|
13
13
|
version: string;
|
|
14
14
|
pyodideVersion: string;
|
|
15
15
|
}): Promise<PyodideInterface> {
|
|
@@ -17,7 +17,10 @@ export class ReadonlyWasmController extends DefaultWasmController {
|
|
|
17
17
|
return pyodide;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
override async mountFilesystem(opts: {
|
|
20
|
+
public override async mountFilesystem(opts: {
|
|
21
|
+
code: string;
|
|
22
|
+
filename: string;
|
|
23
|
+
}) {
|
|
21
24
|
const { code, filename } = opts;
|
|
22
25
|
// Write file
|
|
23
26
|
try {
|
|
@@ -34,7 +37,7 @@ export class ReadonlyWasmController extends DefaultWasmController {
|
|
|
34
37
|
return { code, filename };
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
override async startSession(opts: {
|
|
40
|
+
public override async startSession(opts: {
|
|
38
41
|
code: string;
|
|
39
42
|
filename: string | null;
|
|
40
43
|
onMessage: (message: JsonString<NotificationPayload>) => void;
|
|
@@ -39,7 +39,7 @@ export class DefaultWorkerFactory implements WorkerFactory {
|
|
|
39
39
|
private readonly url: string;
|
|
40
40
|
private readonly name: string;
|
|
41
41
|
|
|
42
|
-
constructor(config: DefaultWorkerFactoryConfig = {}) {
|
|
42
|
+
public constructor(config: DefaultWorkerFactoryConfig = {}) {
|
|
43
43
|
this.url = config.workerUrl || this.getDefaultWorkerUrl();
|
|
44
44
|
this.name = config.workerName || getMarimoVersion();
|
|
45
45
|
}
|
|
@@ -47,7 +47,7 @@ export class DefaultWorkerFactory implements WorkerFactory {
|
|
|
47
47
|
/**
|
|
48
48
|
* Creates a new Pyodide worker
|
|
49
49
|
*/
|
|
50
|
-
create(): Worker {
|
|
50
|
+
public create(): Worker {
|
|
51
51
|
return createModuleWorker(new URL(this.url, import.meta.url), {
|
|
52
52
|
name: this.name,
|
|
53
53
|
});
|
|
@@ -17,7 +17,7 @@ export class RuntimeState {
|
|
|
17
17
|
/**
|
|
18
18
|
* Shared instance of RuntimeState since this must be a singleton.
|
|
19
19
|
*/
|
|
20
|
-
static get INSTANCE(): RuntimeState {
|
|
20
|
+
public static get INSTANCE(): RuntimeState {
|
|
21
21
|
const KEY = "_marimo_private_RuntimeState";
|
|
22
22
|
if (!window[KEY]) {
|
|
23
23
|
window[KEY] = new RuntimeState(UI_ELEMENT_REGISTRY);
|
|
@@ -31,7 +31,7 @@ export class RuntimeState {
|
|
|
31
31
|
private _sendComponentValues: RunRequests["sendComponentValues"] | undefined;
|
|
32
32
|
private uiElementRegistry: UIElementRegistry;
|
|
33
33
|
|
|
34
|
-
constructor(uiElementRegistry: UIElementRegistry) {
|
|
34
|
+
public constructor(uiElementRegistry: UIElementRegistry) {
|
|
35
35
|
this.uiElementRegistry = uiElementRegistry;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -45,7 +45,7 @@ export class RuntimeState {
|
|
|
45
45
|
/**
|
|
46
46
|
* Start listening for events from UIElements
|
|
47
47
|
*/
|
|
48
|
-
start(sendComponentValues: RunRequests["sendComponentValues"]) {
|
|
48
|
+
public start(sendComponentValues: RunRequests["sendComponentValues"]) {
|
|
49
49
|
if (this.hasStarted) {
|
|
50
50
|
Logger.warn("RuntimeState already started");
|
|
51
51
|
return;
|
|
@@ -61,7 +61,7 @@ export class RuntimeState {
|
|
|
61
61
|
/**
|
|
62
62
|
* Stop listening for events from UIElements
|
|
63
63
|
*/
|
|
64
|
-
stop() {
|
|
64
|
+
public stop() {
|
|
65
65
|
if (!this.hasStarted) {
|
|
66
66
|
Logger.warn("RuntimeState already stopped");
|
|
67
67
|
return;
|
|
@@ -10,28 +10,28 @@ vi.mock("@/utils/Logger", () => ({
|
|
|
10
10
|
}));
|
|
11
11
|
|
|
12
12
|
class FakeWebSocket {
|
|
13
|
-
static readonly CONNECTING = 0;
|
|
14
|
-
static readonly OPEN = 1;
|
|
15
|
-
static readonly CLOSING = 2;
|
|
16
|
-
static readonly CLOSED = 3;
|
|
17
|
-
static readonly instances: FakeWebSocket[] = [];
|
|
18
|
-
|
|
19
|
-
readonly sent: string[] = [];
|
|
20
|
-
readonly url: string;
|
|
21
|
-
readonly protocols: string | string[] | undefined;
|
|
22
|
-
readyState = FakeWebSocket.CONNECTING;
|
|
13
|
+
public static readonly CONNECTING = 0;
|
|
14
|
+
public static readonly OPEN = 1;
|
|
15
|
+
public static readonly CLOSING = 2;
|
|
16
|
+
public static readonly CLOSED = 3;
|
|
17
|
+
public static readonly instances: FakeWebSocket[] = [];
|
|
18
|
+
|
|
19
|
+
public readonly sent: string[] = [];
|
|
20
|
+
public readonly url: string;
|
|
21
|
+
public readonly protocols: string | string[] | undefined;
|
|
22
|
+
public readyState = FakeWebSocket.CONNECTING;
|
|
23
23
|
private readonly listeners = new Map<
|
|
24
24
|
string,
|
|
25
25
|
Set<(event: { data?: unknown }) => void>
|
|
26
26
|
>();
|
|
27
27
|
|
|
28
|
-
constructor(url: string, protocols?: string | string[]) {
|
|
28
|
+
public constructor(url: string, protocols?: string | string[]) {
|
|
29
29
|
this.url = url;
|
|
30
30
|
this.protocols = protocols;
|
|
31
31
|
FakeWebSocket.instances.push(this);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
addEventListener(
|
|
34
|
+
public addEventListener(
|
|
35
35
|
type: string,
|
|
36
36
|
listener: (event: { data?: unknown }) => void,
|
|
37
37
|
) {
|
|
@@ -40,34 +40,34 @@ class FakeWebSocket {
|
|
|
40
40
|
this.listeners.set(type, listeners);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
send(frame: string) {
|
|
43
|
+
public send(frame: string) {
|
|
44
44
|
this.sent.push(frame);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
close() {
|
|
47
|
+
public close() {
|
|
48
48
|
this.readyState = FakeWebSocket.CLOSED;
|
|
49
49
|
this.emit("close", {});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
open() {
|
|
52
|
+
public open() {
|
|
53
53
|
this.readyState = FakeWebSocket.OPEN;
|
|
54
54
|
this.emit("open", {});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
fail() {
|
|
57
|
+
public fail() {
|
|
58
58
|
this.emit("error", {});
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
disconnect() {
|
|
61
|
+
public disconnect() {
|
|
62
62
|
this.readyState = FakeWebSocket.CLOSED;
|
|
63
63
|
this.emit("close", {});
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
receive(message: JSONRPCMessage) {
|
|
66
|
+
public receive(message: JSONRPCMessage) {
|
|
67
67
|
this.emit("message", { data: JSON.stringify(message) });
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
messages(): JSONRPCMessage[] {
|
|
70
|
+
public messages(): JSONRPCMessage[] {
|
|
71
71
|
return this.sent.map((frame) => {
|
|
72
72
|
const message: unknown = JSON.parse(frame);
|
|
73
73
|
if (!isJSONRPCMessage(message)) {
|