@marimo-team/islands 0.26.1-dev25 → 0.26.1-dev29
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-Bs2ehxEI.js → ErrorBoundary-CPcZlpvU.js} +1 -1
- package/dist/{chat-ui-DOvIzlMA.js → chat-ui-CWmSnBs8.js} +899 -899
- package/dist/{code-visibility-BnMkbydx.js → code-visibility-CHvnQsso.js} +2 -2
- package/dist/{common-CQur5dRA.js → common-9OlCmjdr.js} +6565 -6565
- package/dist/{config-DL9e-OWE.js → config-1ku0tAiU.js} +27 -28
- package/dist/{data-grid-overlay-editor-BXEY35Xl.js → data-grid-overlay-editor-D6x_MBSD.js} +1 -1
- package/dist/{dropdown-menu-DYN2RV5d.js → dropdown-menu-D65ZUqka.js} +1983 -1983
- package/dist/{error-entries-CncQR572.js → error-entries-DFHEq_SO.js} +515 -519
- package/dist/{feedback-button-BAOp7zqu.js → feedback-button-CodkZ3hF.js} +19 -19
- package/dist/{glide-data-editor-Ce94qTW7.js → glide-data-editor-BZxvtSp-.js} +35 -35
- package/dist/{globals-Uqg4j5z5.js → globals-DFf-tSyE.js} +1 -1
- package/dist/{html-to-image-BU7H-AM1.js → html-to-image-D6Gtk5ik.js} +24005 -23992
- package/dist/main.js +864 -864
- package/dist/{number-overlay-editor-Br_Vp3Ws.js → number-overlay-editor-CfwFMv_U.js} +1 -1
- package/dist/{process-output-xJm8T5-E.js → process-output-ZBdibqlG.js} +2 -2
- package/dist/{reveal-component-B7TgfbYJ.js → reveal-component-CDfNuSFv.js} +3 -3
- package/dist/style.css +1 -1
- package/dist/{vega-component-DpTyTrz3.js → vega-component-D61CTW1X.js} +1 -1
- package/package.json +1 -1
- package/src/__mocks__/intersection-observer.ts +45 -0
- package/src/components/databases/engine-variable.tsx +2 -2
- package/src/components/dependency-graph/panels.tsx +2 -2
- package/src/components/editor/actions/useCellActionButton.tsx +2 -8
- package/src/components/editor/cell/code/__tests__/code-placeholder.test.tsx +40 -0
- package/src/components/editor/cell/code/cell-editor.tsx +41 -104
- package/src/components/editor/cell/code/code-placeholder.css +61 -11
- package/src/components/editor/cell/code/code-placeholder.tsx +52 -29
- package/src/components/editor/cell/useSplitCell.tsx +2 -2
- package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +6 -10
- package/src/components/editor/errors/auto-fix.tsx +8 -7
- package/src/components/editor/navigation/__tests__/navigation.test.ts +3 -12
- package/src/components/editor/navigation/focus-utils.ts +20 -8
- package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +3 -11
- package/src/components/editor/navigation/navigation.ts +2 -2
- package/src/components/editor/notebook-cell.tsx +15 -24
- package/src/components/editor/output/MarimoTracebackOutput.tsx +2 -2
- package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts +6 -9
- package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +2 -5
- package/src/components/find-replace/find-replace.tsx +3 -7
- package/src/components/variables/__tests__/variables-table.test.tsx +1 -2
- package/src/core/ai/__tests__/staged-cells.test.ts +6 -39
- package/src/core/ai/staged-cells.ts +2 -20
- package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +15 -13
- package/src/core/ai/tools/edit-notebook-tool.ts +13 -8
- package/src/core/cells/__tests__/cell-editor-view.test.ts +44 -0
- package/src/core/cells/__tests__/cells.test.ts +0 -1
- package/src/core/cells/__tests__/focus.test.ts +1 -7
- package/src/core/cells/__tests__/harness.ts +0 -1
- package/src/core/cells/cells.ts +15 -10
- package/src/core/cells/focus.ts +1 -1
- package/src/core/cells/scrollCellIntoView.ts +4 -14
- package/src/core/cells/utils.ts +0 -13
- package/src/core/codemirror/__tests__/cell-documents.test.ts +79 -0
- package/src/core/codemirror/__tests__/editor-mount-scheduler.test.ts +75 -105
- package/src/core/codemirror/__tests__/format.test.ts +85 -63
- package/src/core/codemirror/__tests__/use-lazy-editor-mount.test.tsx +193 -0
- package/src/core/codemirror/cell-documents.ts +132 -0
- package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +0 -1
- package/src/core/codemirror/copilot/getCodes.ts +3 -14
- package/src/core/codemirror/editor-mount-scheduler.ts +41 -48
- package/src/core/codemirror/extensions.ts +2 -2
- package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +42 -16
- package/src/core/codemirror/find-replace/__tests__/search-highlight.test.ts +30 -0
- package/src/core/codemirror/find-replace/__tests__/unmounted-cells.test.ts +145 -0
- package/src/core/codemirror/find-replace/navigate.ts +88 -129
- package/src/core/codemirror/find-replace/search-highlight.ts +3 -1
- package/src/core/codemirror/find-replace/state.ts +7 -2
- package/src/core/codemirror/format.ts +25 -31
- package/src/core/codemirror/go-to-definition/__tests__/utils.test.ts +8 -9
- package/src/core/codemirror/language/cell-code.ts +7 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +25 -0
- package/src/core/codemirror/lsp/notebook-lsp.ts +6 -16
- package/src/core/codemirror/use-lazy-editor-mount.ts +67 -0
- package/src/core/codemirror/utils.ts +2 -6
- package/src/utils/__tests__/shared-intersection-observer.test.ts +49 -0
- package/src/utils/shared-intersection-observer.ts +53 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
3
|
+
import { mockIntersectionObservers } from "@/__mocks__/intersection-observer";
|
|
4
|
+
import { createSharedIntersectionObserver } from "../shared-intersection-observer";
|
|
5
|
+
|
|
6
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
7
|
+
|
|
8
|
+
it("shares one observer across 500 nodes and releases each node exactly once", () => {
|
|
9
|
+
const observers = mockIntersectionObservers();
|
|
10
|
+
const subscribe = createSharedIntersectionObserver({});
|
|
11
|
+
const callbacks = Array.from({ length: 500 }, () => vi.fn());
|
|
12
|
+
const nodes = callbacks.map(() => document.createElement("div"));
|
|
13
|
+
const releases = nodes.map((node, i) => subscribe(node, callbacks[i]));
|
|
14
|
+
expect(observers).toHaveLength(1);
|
|
15
|
+
expect(observers[0].observe).toHaveBeenCalledTimes(500);
|
|
16
|
+
observers[0].emit(nodes[300], true);
|
|
17
|
+
expect(callbacks.filter((callback) => callback.mock.calls.length)).toEqual([
|
|
18
|
+
callbacks[300],
|
|
19
|
+
]);
|
|
20
|
+
for (const release of releases) {
|
|
21
|
+
release();
|
|
22
|
+
release();
|
|
23
|
+
}
|
|
24
|
+
expect(observers[0].unobserve).toHaveBeenCalledTimes(500);
|
|
25
|
+
expect(observers[0].disconnect).toHaveBeenCalledTimes(1);
|
|
26
|
+
observers[0].emit(nodes[300], false);
|
|
27
|
+
expect(callbacks[300]).toHaveBeenCalledExactlyOnceWith(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("keeps duplicate subscriptions independent and ignores callbacks from a disposed observer", () => {
|
|
31
|
+
const observers = mockIntersectionObservers();
|
|
32
|
+
const subscribe = createSharedIntersectionObserver({});
|
|
33
|
+
const node = document.createElement("div");
|
|
34
|
+
const callback = vi.fn();
|
|
35
|
+
const first = subscribe(node, callback);
|
|
36
|
+
const second = subscribe(node, callback);
|
|
37
|
+
first();
|
|
38
|
+
expect(observers[0].unobserve).not.toHaveBeenCalled();
|
|
39
|
+
observers[0].emit(node, true);
|
|
40
|
+
expect(callback).toHaveBeenCalledExactlyOnceWith(true);
|
|
41
|
+
second();
|
|
42
|
+
const third = subscribe(node, callback);
|
|
43
|
+
observers[0].emit(node, false);
|
|
44
|
+
expect(callback).toHaveBeenCalledTimes(1);
|
|
45
|
+
observers[1].emit(node, false);
|
|
46
|
+
expect(callback).toHaveBeenLastCalledWith(false);
|
|
47
|
+
third();
|
|
48
|
+
expect(observers[1].disconnect).toHaveBeenCalledTimes(1);
|
|
49
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { createSharedResource } from "./shared-resource";
|
|
3
|
+
|
|
4
|
+
/** One observer per options set, with independently disposable subscriptions. */
|
|
5
|
+
export function createSharedIntersectionObserver(
|
|
6
|
+
options: IntersectionObserverInit,
|
|
7
|
+
) {
|
|
8
|
+
const subscribers = new Map<Element, Set<(visible: boolean) => void>>();
|
|
9
|
+
let observer: IntersectionObserver | undefined;
|
|
10
|
+
const acquire = createSharedResource(() => {
|
|
11
|
+
const current = new IntersectionObserver((entries) => {
|
|
12
|
+
if (observer !== current) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
const callbacks = subscribers.get(entry.target);
|
|
17
|
+
const snapshot = [...(callbacks ?? [])];
|
|
18
|
+
for (const callback of snapshot) {
|
|
19
|
+
if (callbacks?.has(callback)) {
|
|
20
|
+
callback(entry.isIntersecting);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}, options);
|
|
25
|
+
observer = current;
|
|
26
|
+
return () => {
|
|
27
|
+
observer = undefined;
|
|
28
|
+
current.disconnect();
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return (target: Element, onChange: (visible: boolean) => void) => {
|
|
33
|
+
const release = acquire();
|
|
34
|
+
const callback = (visible: boolean) => onChange(visible);
|
|
35
|
+
let callbacks = subscribers.get(target);
|
|
36
|
+
if (!callbacks) {
|
|
37
|
+
callbacks = new Set();
|
|
38
|
+
subscribers.set(target, callbacks);
|
|
39
|
+
observer?.observe(target);
|
|
40
|
+
}
|
|
41
|
+
callbacks.add(callback);
|
|
42
|
+
return () => {
|
|
43
|
+
if (!callbacks.delete(callback)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (callbacks.size === 0) {
|
|
47
|
+
subscribers.delete(target);
|
|
48
|
+
observer?.unobserve(target);
|
|
49
|
+
}
|
|
50
|
+
release();
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|