@marimo-team/islands 0.19.8-dev41 → 0.19.8-dev49
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/assets/__vite-browser-external-WSlCcXn_.js +1 -0
- package/dist/assets/worker-DUYMdbtA.js +73 -0
- package/dist/main.js +1740 -1691
- package/dist/style.css +1 -1
- package/dist/{useDeepCompareMemoize-CMGprt3H.js → useDeepCompareMemoize-BhZZsis0.js} +7 -3
- package/dist/{vega-component-DU3aSp4m.js → vega-component-DCxUyPnb.js} +1 -1
- package/package.json +1 -1
- package/src/components/app-config/optional-features.tsx +1 -1
- package/src/components/chat/__tests__/useFileState.test.tsx +93 -0
- package/src/components/chat/acp/agent-panel.tsx +26 -77
- package/src/components/chat/chat-components.tsx +114 -1
- package/src/components/chat/chat-panel.tsx +32 -104
- package/src/components/chat/chat-utils.ts +42 -0
- package/src/components/editor/ai/add-cell-with-ai.tsx +85 -53
- package/src/components/editor/ai/ai-completion-editor.tsx +15 -38
- package/src/components/editor/chrome/panels/packages-panel.tsx +12 -9
- package/src/core/islands/__tests__/bridge.test.ts +7 -2
- package/src/core/islands/bridge.ts +1 -1
- package/src/core/islands/main.ts +7 -0
- package/src/core/network/types.ts +2 -2
- package/src/core/wasm/bridge.ts +1 -1
- package/src/core/websocket/useMarimoKernelConnection.tsx +5 -15
- package/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx +86 -167
- package/src/plugins/impl/anywidget/__tests__/AnyWidgetPlugin.test.tsx +37 -123
- package/src/plugins/impl/anywidget/__tests__/model.test.ts +128 -122
- package/src/{utils/__tests__/data-views.test.ts → plugins/impl/anywidget/__tests__/serialization.test.ts} +42 -96
- package/src/plugins/impl/anywidget/model.ts +348 -223
- package/src/plugins/impl/anywidget/schemas.ts +32 -0
- package/src/{utils/data-views.ts → plugins/impl/anywidget/serialization.ts} +13 -36
- package/src/plugins/impl/anywidget/types.ts +27 -0
- package/src/plugins/impl/chat/chat-ui.tsx +22 -20
- package/src/utils/Deferred.ts +21 -0
- package/src/utils/json/base64.ts +38 -8
- package/dist/assets/__vite-browser-external-6-UwTyQC.js +0 -1
- package/dist/assets/worker-D3e5wDxM.js +0 -73
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
serializeBuffersToBase64,
|
|
7
|
-
type WireFormat,
|
|
8
|
-
} from "../data-views";
|
|
9
|
-
import type { Base64String } from "../json/base64";
|
|
3
|
+
import type { WireFormat } from "@/plugins/impl/anywidget/types";
|
|
4
|
+
import type { Base64String } from "../../../../utils/json/base64";
|
|
5
|
+
import { decodeFromWire, serializeBuffersToBase64 } from "../serialization";
|
|
10
6
|
|
|
11
7
|
describe("decodeFromWire with DataViews", () => {
|
|
12
8
|
it("should return the original state if bufferPaths.length === 0", () => {
|
|
@@ -108,7 +104,7 @@ describe("Immutability Tests", () => {
|
|
|
108
104
|
expect(input.array).toBe(input.array); // Array reference unchanged
|
|
109
105
|
});
|
|
110
106
|
|
|
111
|
-
it("decodeFromWire (wire format) should
|
|
107
|
+
it("decodeFromWire (wire format) should decode base64 to DataView", () => {
|
|
112
108
|
const encoder = new TextEncoder();
|
|
113
109
|
const data = encoder.encode("Hello");
|
|
114
110
|
const base64 = btoa(String.fromCharCode(...data)) as Base64String;
|
|
@@ -119,19 +115,16 @@ describe("Immutability Tests", () => {
|
|
|
119
115
|
buffers: [base64],
|
|
120
116
|
};
|
|
121
117
|
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
decodeFromWire(input);
|
|
125
|
-
|
|
126
|
-
// Check deep equality
|
|
127
|
-
expect(input).toEqual(clone);
|
|
118
|
+
const result = decodeFromWire(input);
|
|
128
119
|
|
|
129
|
-
//
|
|
130
|
-
expect(
|
|
131
|
-
|
|
120
|
+
// Result should have DataView instead of base64 string
|
|
121
|
+
expect(result.text).toBeInstanceOf(DataView);
|
|
122
|
+
// Other properties should be preserved
|
|
123
|
+
expect(result.number).toBe(42);
|
|
124
|
+
expect(result.nested).toEqual({ value: "test" });
|
|
132
125
|
});
|
|
133
126
|
|
|
134
|
-
it("decodeFromWire (with DataViews) should
|
|
127
|
+
it("decodeFromWire (with DataViews) should insert buffers at paths", () => {
|
|
135
128
|
const encoder = new TextEncoder();
|
|
136
129
|
const dataView = new DataView(encoder.encode("data").buffer);
|
|
137
130
|
|
|
@@ -143,21 +136,21 @@ describe("Immutability Tests", () => {
|
|
|
143
136
|
const bufferPaths = [["data"]];
|
|
144
137
|
const buffers = [dataView];
|
|
145
138
|
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
//
|
|
155
|
-
expect(
|
|
156
|
-
expect(
|
|
157
|
-
expect(
|
|
139
|
+
const result = decodeFromWire({
|
|
140
|
+
state,
|
|
141
|
+
bufferPaths,
|
|
142
|
+
buffers,
|
|
143
|
+
}) as typeof state & { data: DataView };
|
|
144
|
+
|
|
145
|
+
// Result should have the DataView at the path
|
|
146
|
+
expect(result.data).toBe(dataView);
|
|
147
|
+
// Other properties should be preserved
|
|
148
|
+
expect(result.placeholder).toBe("value");
|
|
149
|
+
expect(result.nested).toEqual({ key: "test" });
|
|
150
|
+
expect(result.array).toEqual([1, 2, 3]);
|
|
158
151
|
});
|
|
159
152
|
|
|
160
|
-
it("decodeFromWire should
|
|
153
|
+
it("decodeFromWire should insert buffers and return state", () => {
|
|
161
154
|
const encoder = new TextEncoder();
|
|
162
155
|
const dataView = new DataView(encoder.encode("data").buffer);
|
|
163
156
|
|
|
@@ -165,16 +158,15 @@ describe("Immutability Tests", () => {
|
|
|
165
158
|
const bufferPaths = [["c"]];
|
|
166
159
|
const buffers = [dataView];
|
|
167
160
|
|
|
168
|
-
const result = decodeFromWire({
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// Input should not have new property
|
|
174
|
-
expect("c" in state).toBe(false);
|
|
161
|
+
const result = decodeFromWire({
|
|
162
|
+
state,
|
|
163
|
+
bufferPaths,
|
|
164
|
+
buffers,
|
|
165
|
+
}) as typeof state & { c: DataView };
|
|
175
166
|
|
|
176
167
|
// Result should have new property
|
|
177
168
|
expect("c" in result).toBe(true);
|
|
169
|
+
expect(result.c).toBe(dataView);
|
|
178
170
|
});
|
|
179
171
|
|
|
180
172
|
it("serializeBuffersToBase64 should return new state object", () => {
|
|
@@ -198,7 +190,7 @@ describe("Immutability Tests", () => {
|
|
|
198
190
|
expect(typeof result.state.buffer).toBe("string");
|
|
199
191
|
});
|
|
200
192
|
|
|
201
|
-
it("decodeFromWire with object input should
|
|
193
|
+
it("decodeFromWire with object input should insert buffers", () => {
|
|
202
194
|
const encoder = new TextEncoder();
|
|
203
195
|
const dataView = new DataView(encoder.encode("data").buffer);
|
|
204
196
|
|
|
@@ -206,16 +198,17 @@ describe("Immutability Tests", () => {
|
|
|
206
198
|
const bufferPaths = [["d"]];
|
|
207
199
|
const buffers = [dataView];
|
|
208
200
|
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
//
|
|
218
|
-
expect(
|
|
201
|
+
const result = decodeFromWire({
|
|
202
|
+
state,
|
|
203
|
+
bufferPaths,
|
|
204
|
+
buffers,
|
|
205
|
+
}) as typeof state & { d: DataView };
|
|
206
|
+
|
|
207
|
+
// Result should have the buffer inserted
|
|
208
|
+
expect(result.d).toBe(dataView);
|
|
209
|
+
// Original properties should be preserved
|
|
210
|
+
expect(result.a).toBe(1);
|
|
211
|
+
expect(result.b).toEqual({ c: 2 });
|
|
219
212
|
});
|
|
220
213
|
|
|
221
214
|
it("nested objects should maintain independence after serialization", () => {
|
|
@@ -342,53 +335,6 @@ describe("serializeBuffersToBase64", () => {
|
|
|
342
335
|
});
|
|
343
336
|
});
|
|
344
337
|
|
|
345
|
-
describe("isWireFormat", () => {
|
|
346
|
-
it("should return true for valid wire format", () => {
|
|
347
|
-
const wireFormat: WireFormat = {
|
|
348
|
-
state: { a: 1 },
|
|
349
|
-
bufferPaths: [],
|
|
350
|
-
buffers: [],
|
|
351
|
-
};
|
|
352
|
-
expect(isWireFormat(wireFormat)).toBe(true);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it("should return true for wire format with data", () => {
|
|
356
|
-
const wireFormat: WireFormat = {
|
|
357
|
-
state: { value: "SGVsbG8=" },
|
|
358
|
-
bufferPaths: [["value"]],
|
|
359
|
-
buffers: ["SGVsbG8=" as Base64String],
|
|
360
|
-
};
|
|
361
|
-
expect(isWireFormat(wireFormat)).toBe(true);
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
it("should return false for null", () => {
|
|
365
|
-
expect(isWireFormat(null)).toBe(false);
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
it("should return false for non-objects", () => {
|
|
369
|
-
expect(isWireFormat("string")).toBe(false);
|
|
370
|
-
expect(isWireFormat(123)).toBe(false);
|
|
371
|
-
expect(isWireFormat(true)).toBe(false);
|
|
372
|
-
expect(isWireFormat(undefined)).toBe(false);
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
it("should return false when missing state", () => {
|
|
376
|
-
expect(isWireFormat({ bufferPaths: [], buffers: [] })).toBe(false);
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
it("should return false when missing bufferPaths", () => {
|
|
380
|
-
expect(isWireFormat({ state: {}, buffers: [] })).toBe(false);
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
it("should return false when missing buffers", () => {
|
|
384
|
-
expect(isWireFormat({ state: {}, bufferPaths: [] })).toBe(false);
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
it("should return false for plain objects", () => {
|
|
388
|
-
expect(isWireFormat({ a: 1, b: 2 })).toBe(false);
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
|
|
392
338
|
describe("decodeFromWire from WireFormat", () => {
|
|
393
339
|
it("should return state unchanged when no buffer paths", () => {
|
|
394
340
|
const wire: WireFormat = {
|