@marimo-team/islands 0.23.15-dev1 → 0.23.15-dev11
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/{chat-ui-DinOvbWu.js → chat-ui-FiwuOgQU.js} +3094 -3094
- package/dist/{code-visibility-PV_v9dwf.js → code-visibility-HO1U02IJ.js} +171 -171
- package/dist/{html-to-image-_wGfk8V-.js → html-to-image-JXL8cvmt.js} +2218 -2205
- package/dist/main.js +327 -339
- package/dist/{process-output-Mh4UrjwM.js → process-output-CnDIXtM-.js} +1 -1
- package/dist/{reveal-component-DVEmgnsr.js → reveal-component-BuQ2GKAM.js} +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/chat/__tests__/chat-utils.test.ts +244 -1
- package/src/components/chat/__tests__/message-queue.test.tsx +121 -0
- package/src/components/chat/chat-panel.tsx +196 -67
- package/src/components/chat/chat-utils.ts +111 -2
- package/src/components/editor/SortableCell.tsx +6 -2
- package/src/components/editor/__tests__/output-persistence.test.tsx +241 -0
- package/src/components/editor/cell/cell-context-menu.tsx +7 -0
- package/src/components/editor/columns/__tests__/cell-column.test.tsx +105 -0
- package/src/components/editor/columns/cell-column.tsx +34 -4
- package/src/components/editor/columns/sortable-column.tsx +24 -4
- package/src/components/editor/notebook-cell.tsx +203 -106
- package/src/components/editor/renderers/__tests__/cells-renderer.test.tsx +66 -0
- package/src/components/editor/renderers/cell-array.tsx +26 -13
- package/src/components/editor/renderers/cells-renderer.tsx +8 -2
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +19 -19
- package/src/core/cells/__tests__/utils.test.ts +59 -0
- package/src/core/cells/utils.ts +51 -0
- package/src/css/app/Cell.css +10 -0
- package/src/hooks/__tests__/useHotkey.test.tsx +88 -0
- package/src/hooks/useHotkey.ts +29 -4
- package/src/plugins/impl/anywidget/__tests__/host.test.ts +6 -9
- package/src/plugins/impl/anywidget/__tests__/widget-binding.test.ts +22 -61
- package/src/plugins/impl/anywidget/model-proxy.ts +0 -13
- package/src/plugins/impl/anywidget/widget-binding.ts +4 -34
- package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +71 -3
- package/src/plugins/impl/matplotlib/matplotlib-renderer.ts +1 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import {
|
|
4
|
+
type Data,
|
|
5
|
+
MatplotlibRenderer,
|
|
6
|
+
type MatplotlibState,
|
|
7
|
+
visibleForTesting,
|
|
8
|
+
} from "../matplotlib-renderer";
|
|
5
9
|
|
|
6
10
|
const {
|
|
7
11
|
pixelToData,
|
|
@@ -185,3 +189,67 @@ describe("isInAxes", () => {
|
|
|
185
189
|
expect(isInAxes({ x: 300, y: 351 }, LINEAR_AXES)).toBe(false);
|
|
186
190
|
});
|
|
187
191
|
});
|
|
192
|
+
|
|
193
|
+
describe("MatplotlibRenderer", () => {
|
|
194
|
+
afterEach(() => {
|
|
195
|
+
vi.unstubAllGlobals();
|
|
196
|
+
vi.restoreAllMocks();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("restores a new selection when the chart changes", () => {
|
|
200
|
+
vi.stubGlobal(
|
|
201
|
+
"matchMedia",
|
|
202
|
+
vi.fn(() => ({ addEventListener: vi.fn() })),
|
|
203
|
+
);
|
|
204
|
+
vi.stubGlobal(
|
|
205
|
+
"requestAnimationFrame",
|
|
206
|
+
vi.fn(() => 1),
|
|
207
|
+
);
|
|
208
|
+
vi.stubGlobal("cancelAnimationFrame", vi.fn());
|
|
209
|
+
vi.spyOn(HTMLCanvasElement.prototype, "getContext").mockReturnValue(null);
|
|
210
|
+
|
|
211
|
+
const value = {
|
|
212
|
+
type: "box",
|
|
213
|
+
has_selection: true,
|
|
214
|
+
data: { x_min: 2, x_max: 4, y_min: 2, y_max: 4 },
|
|
215
|
+
} as const;
|
|
216
|
+
const state: MatplotlibState = {
|
|
217
|
+
...LINEAR_AXES,
|
|
218
|
+
axesPixelBounds: [0, 0, 100, 100],
|
|
219
|
+
yBounds: [0, 10],
|
|
220
|
+
chartBase64: "first",
|
|
221
|
+
width: 100,
|
|
222
|
+
height: 100,
|
|
223
|
+
selectionColor: "blue",
|
|
224
|
+
selectionOpacity: 0.15,
|
|
225
|
+
strokeWidth: 2,
|
|
226
|
+
debounce: false,
|
|
227
|
+
value: { has_selection: false },
|
|
228
|
+
setValue: vi.fn(),
|
|
229
|
+
};
|
|
230
|
+
const container = document.createElement("div");
|
|
231
|
+
const controller = new AbortController();
|
|
232
|
+
const renderer = new MatplotlibRenderer(container, {
|
|
233
|
+
state,
|
|
234
|
+
signal: controller.signal,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Cell reruns reuse the renderer, updating the chart and initial value together.
|
|
238
|
+
renderer.update({ ...state, chartBase64: "second", value });
|
|
239
|
+
|
|
240
|
+
const canvas = container.querySelector("canvas");
|
|
241
|
+
expect(canvas).not.toBeNull();
|
|
242
|
+
if (!canvas) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
vi.spyOn(canvas, "getBoundingClientRect").mockReturnValue(
|
|
246
|
+
DOMRect.fromRect({ width: 100, height: 100 }),
|
|
247
|
+
);
|
|
248
|
+
canvas.dispatchEvent(
|
|
249
|
+
new MouseEvent("pointermove", { clientX: 30, clientY: 70 }),
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
expect(canvas.style.cursor).toBe("move");
|
|
253
|
+
controller.abort();
|
|
254
|
+
});
|
|
255
|
+
});
|