@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.
Files changed (34) hide show
  1. package/dist/{chat-ui-DinOvbWu.js → chat-ui-FiwuOgQU.js} +3094 -3094
  2. package/dist/{code-visibility-PV_v9dwf.js → code-visibility-HO1U02IJ.js} +171 -171
  3. package/dist/{html-to-image-_wGfk8V-.js → html-to-image-JXL8cvmt.js} +2218 -2205
  4. package/dist/main.js +327 -339
  5. package/dist/{process-output-Mh4UrjwM.js → process-output-CnDIXtM-.js} +1 -1
  6. package/dist/{reveal-component-DVEmgnsr.js → reveal-component-BuQ2GKAM.js} +2 -2
  7. package/dist/style.css +1 -1
  8. package/package.json +1 -1
  9. package/src/components/chat/__tests__/chat-utils.test.ts +244 -1
  10. package/src/components/chat/__tests__/message-queue.test.tsx +121 -0
  11. package/src/components/chat/chat-panel.tsx +196 -67
  12. package/src/components/chat/chat-utils.ts +111 -2
  13. package/src/components/editor/SortableCell.tsx +6 -2
  14. package/src/components/editor/__tests__/output-persistence.test.tsx +241 -0
  15. package/src/components/editor/cell/cell-context-menu.tsx +7 -0
  16. package/src/components/editor/columns/__tests__/cell-column.test.tsx +105 -0
  17. package/src/components/editor/columns/cell-column.tsx +34 -4
  18. package/src/components/editor/columns/sortable-column.tsx +24 -4
  19. package/src/components/editor/notebook-cell.tsx +203 -106
  20. package/src/components/editor/renderers/__tests__/cells-renderer.test.tsx +66 -0
  21. package/src/components/editor/renderers/cell-array.tsx +26 -13
  22. package/src/components/editor/renderers/cells-renderer.tsx +8 -2
  23. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +19 -19
  24. package/src/core/cells/__tests__/utils.test.ts +59 -0
  25. package/src/core/cells/utils.ts +51 -0
  26. package/src/css/app/Cell.css +10 -0
  27. package/src/hooks/__tests__/useHotkey.test.tsx +88 -0
  28. package/src/hooks/useHotkey.ts +29 -4
  29. package/src/plugins/impl/anywidget/__tests__/host.test.ts +6 -9
  30. package/src/plugins/impl/anywidget/__tests__/widget-binding.test.ts +22 -61
  31. package/src/plugins/impl/anywidget/model-proxy.ts +0 -13
  32. package/src/plugins/impl/anywidget/widget-binding.ts +4 -34
  33. package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +71 -3
  34. 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 type { Data } from "../matplotlib-renderer";
4
- import { visibleForTesting } from "../matplotlib-renderer";
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
+ });
@@ -377,6 +377,7 @@ export class MatplotlibRenderer {
377
377
 
378
378
  if (state.chartBase64 !== this.#currentChartBase64) {
379
379
  this.#loadImage(state.chartBase64);
380
+ this.#restoreSelection(state.value);
380
381
  return;
381
382
  }
382
383