@visualli/core 0.2.12 → 0.2.14
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/{chunk-EB5RHCQP.js → chunk-4R5LZUVK.js} +2 -2
- package/dist/{chunk-4O42KVJ5.js → chunk-C5IC52GJ.js} +11 -6
- package/dist/chunk-C5IC52GJ.js.map +1 -0
- package/dist/{chunk-KUW3GHKQ.js → chunk-COKCN5NW.js} +18 -11
- package/dist/chunk-COKCN5NW.js.map +1 -0
- package/dist/{chunk-DRTDHK4R.js → chunk-EASI6BW7.js} +2 -2
- package/dist/{chunk-XMD5FYME.js → chunk-KP57ODE7.js} +2 -2
- package/dist/{chunk-C2DF7LGT.js → chunk-OOTXA4BA.js} +2 -2
- package/dist/{chunk-TJF6R4WH.js → chunk-RDHSLWMU.js} +18 -2
- package/dist/chunk-RDHSLWMU.js.map +1 -0
- package/dist/{chunk-WGLWQQKC.js → chunk-URWZU4I5.js} +2 -2
- package/dist/config/index.cjs.map +1 -1
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +2 -2
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +2 -2
- package/dist/constants/index.d.ts +2 -2
- package/dist/constants/index.js +5 -5
- package/dist/{designSystem-C6DKkmV8.d.ts → designSystem-D-iI9c23.d.cts} +1 -1
- package/dist/{designSystem-C6DKkmV8.d.cts → designSystem-D-iI9c23.d.ts} +1 -1
- package/dist/{ideaSize-B4lvLW5S.d.ts → ideaSize-BD-vUcOU.d.ts} +1 -1
- package/dist/{ideaSize-CTA03TLY.d.cts → ideaSize-Dj7qGmuk.d.cts} +1 -1
- package/dist/{index-BSG3ACvL.d.ts → index-Bi8djF7z.d.ts} +1 -1
- package/dist/{index-CzKgW53y.d.cts → index-uqNXf5yF.d.cts} +1 -1
- package/dist/index.cjs +42 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -13
- package/dist/index.d.ts +23 -13
- package/dist/index.js +71 -69
- package/dist/index.js.map +1 -1
- package/dist/layout/index.d.cts +2 -2
- package/dist/layout/index.d.ts +2 -2
- package/dist/{mindmap-B59ENw1g.d.ts → mindmap-BU-aLrAR.d.ts} +1 -1
- package/dist/{mindmap-D2M47Mxn.d.cts → mindmap-BbQrM6Pm.d.cts} +1 -1
- package/dist/parser/index.cjs +23 -2
- package/dist/parser/index.cjs.map +1 -1
- package/dist/parser/index.d.cts +3 -3
- package/dist/parser/index.d.ts +3 -3
- package/dist/parser/index.js +4 -4
- package/dist/performance/index.cjs.map +1 -1
- package/dist/performance/index.js +2 -2
- package/dist/theme/index.cjs +17 -1
- package/dist/theme/index.cjs.map +1 -1
- package/dist/theme/index.d.cts +2 -2
- package/dist/theme/index.d.ts +2 -2
- package/dist/theme/index.js +2 -2
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/viewport/index.cjs.map +1 -1
- package/dist/viewport/index.d.cts +2 -2
- package/dist/viewport/index.d.ts +2 -2
- package/dist/viewport/index.js +2 -2
- package/package.json +2 -2
- package/src/generated/designSystem.ts +17 -1
- package/src/generated/geometry/interaction.ts +19 -8
- package/src/index.ts +3 -3
- package/src/parser/visualliConverter.ts +8 -3
- package/dist/chunk-4O42KVJ5.js.map +0 -1
- package/dist/chunk-KUW3GHKQ.js.map +0 -1
- package/dist/chunk-TJF6R4WH.js.map +0 -1
- /package/dist/{chunk-EB5RHCQP.js.map → chunk-4R5LZUVK.js.map} +0 -0
- /package/dist/{chunk-DRTDHK4R.js.map → chunk-EASI6BW7.js.map} +0 -0
- /package/dist/{chunk-XMD5FYME.js.map → chunk-KP57ODE7.js.map} +0 -0
- /package/dist/{chunk-C2DF7LGT.js.map → chunk-OOTXA4BA.js.map} +0 -0
- /package/dist/{chunk-WGLWQQKC.js.map → chunk-URWZU4I5.js.map} +0 -0
package/dist/theme/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
token,
|
|
15
15
|
topicFromName,
|
|
16
16
|
topicStyle
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-URWZU4I5.js";
|
|
18
18
|
import {
|
|
19
19
|
CANVAS_STYLE,
|
|
20
20
|
DESIGN_SYSTEM_VERSION,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
TOKENS,
|
|
25
25
|
TOPICS,
|
|
26
26
|
TYPE_STYLES
|
|
27
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-RDHSLWMU.js";
|
|
28
28
|
export {
|
|
29
29
|
CANVAS_STYLE,
|
|
30
30
|
DESIGN_SYSTEM_VERSION,
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { F as FlatNode, b as MindMapConfig, M as MindMapConnection, c as MindMapData, d as MindMapNode, e as NodeMap, N as NodeSelection, R as RenderConfig, f as SpatialBounds, T as TopLevelConnection, V as ViewportState } from '../mindmap-
|
|
1
|
+
export { F as FlatNode, b as MindMapConfig, M as MindMapConnection, c as MindMapData, d as MindMapNode, e as NodeMap, N as NodeSelection, R as RenderConfig, f as SpatialBounds, T as TopLevelConnection, V as ViewportState } from '../mindmap-BbQrM6Pm.cjs';
|
|
2
2
|
export { S as SemanticAnchor, V as VisualliDocument, a as VisualliMeta } from '../document-MEJEfxl3.cjs';
|
|
3
3
|
export { L as LayerConnection, a as LayerContainer, b as LayerNode, V as VisualliLayer, c as VisualliRenderConnection, d as VisualliRenderNode } from '../layer-B2A3Ki48.cjs';
|
|
4
4
|
import { Meta, Layer } from '@visualli/bindings';
|
|
5
5
|
export { Connection, Container, Extension, Layer, Meta, Node } from '@visualli/bindings';
|
|
6
|
-
import '../designSystem-
|
|
6
|
+
import '../designSystem-D-iI9c23.cjs';
|
|
7
7
|
|
|
8
8
|
type VisualliFragment = Meta | Layer;
|
|
9
9
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { F as FlatNode, b as MindMapConfig, M as MindMapConnection, c as MindMapData, d as MindMapNode, e as NodeMap, N as NodeSelection, R as RenderConfig, f as SpatialBounds, T as TopLevelConnection, V as ViewportState } from '../mindmap-
|
|
1
|
+
export { F as FlatNode, b as MindMapConfig, M as MindMapConnection, c as MindMapData, d as MindMapNode, e as NodeMap, N as NodeSelection, R as RenderConfig, f as SpatialBounds, T as TopLevelConnection, V as ViewportState } from '../mindmap-BU-aLrAR.js';
|
|
2
2
|
export { S as SemanticAnchor, V as VisualliDocument, a as VisualliMeta } from '../document-BFBwn93X.js';
|
|
3
3
|
export { L as LayerConnection, a as LayerContainer, b as LayerNode, V as VisualliLayer, c as VisualliRenderConnection, d as VisualliRenderNode } from '../layer-B2A3Ki48.js';
|
|
4
4
|
import { Meta, Layer } from '@visualli/bindings';
|
|
5
5
|
export { Connection, Container, Extension, Layer, Meta, Node } from '@visualli/bindings';
|
|
6
|
-
import '../designSystem-
|
|
6
|
+
import '../designSystem-D-iI9c23.js';
|
|
7
7
|
|
|
8
8
|
type VisualliFragment = Meta | Layer;
|
|
9
9
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/viewport/index.ts","../../src/generated/geometry/interaction.ts","../../src/constants/performanceConstants.ts","../../src/viewport/viewportUtils.ts"],"sourcesContent":["export * from './viewportUtils.js';\n","// Generated from visualli.ai design-system/components/src/interaction.ts — do not edit here.\n/* How the canvas answers the pointer and the keyboard — the timing and rules behind the peek (an idea's summary)\n and terms (semantic anchors: an underlined word and its definition card). The look and the pop-in animation live\n in the CSS (.vi-fact, .vi-anchor, .vi-anchor-card); these are the behaviours, as data, so every renderer (VisualMap,\n the spec SDK on a canvas) opens and closes them alike. Times in ms. No dependencies, so it can travel alone. */\n\n/** Terms (semantic anchors) in a peek's text. */\nexport const TERM = {\n /** Hovering the term this long opens its definition card… */ hoverOpen: 250,\n /** …which closes this long after the pointer leaves both the term and the card (moving between them keeps it open). */ hoverClose: 300,\n /** Only a mouse opens on hover; touch and pen open on tap. */ hoverPointers: ['mouse'] as readonly string[],\n /** A click, tap, Enter or Space pins the card open (hovering away doesn't close it); pressing again unpins and closes. */ clickPins: true,\n /** Escape closes the card and returns focus to the term; a press anywhere outside the term and its card closes it. */ escapeCloses: true, pressOutsideCloses: true,\n /** Opening by click or keyboard moves focus to the card's first link or button. */ focusCardOnOpen: true,\n /** The card is kept this far inside the viewport's left and right edges. */ viewportMargin: 8,\n /** The card's link to a source about the term. */ learnMoreLabel: 'Learn more',\n} as const;\n\n/** The peek: an idea's summary card on hover (pointer) or tap (touch). */\nexport const PEEK = {\n /** Hovering an idea opens its peek at once; it stays this long after the pointer leaves the idea (and while the\n * pointer is over the peek itself), so the pointer can travel from the idea onto the card. */ hoverClose: 180,\n} as const;\n\n/** The touch peek: a bottom sheet with a grip. */\nexport const SHEET = {\n /** Dragging the grip down this far closes the sheet (or collapses it when expanded); up this far expands it. */ dismissDrag: 80, expandDrag: 40,\n /** Its height: this share of the map, at most `maxHeight` px; the map pans the chosen idea into the space above it. */ heightRatio: 0.42, maxHeight: 300,\n} as const;\n\n/** Zoom, pan and fit. */\nexport const VIEW = {\n /** Each zoom step multiplies or divides the zoom by this. */ zoomStep: 1.2,\n /** Zoom limits (the zoom-min / zoom-max tokens; the build checks they agree). */ zoomMin: 0.3, zoomMax: 5,\n /** Fit to view never enlarges a layer beyond this. */ fitMax: 1.1,\n} as const;\n\n/** Touch gestures on the map (any touch input — phones, tablets and touchscreen laptops alike; it follows the pointer\n * in use, not the device, so a mouse or trackpad on the same laptop isn't affected). */\nexport const GESTURE = {\n /** Two fingers pinch to zoom the map's contents — ideas, connectors, containers and their labels — around the\n * point between the fingers, within VIEW's limits. Controls, the depth trail, the peek, chat and the page never scale. */ pinchZoom: true,\n /** Moving both fingers pans the contents. */ twoFingerPan: true,\n /** The pointers that pinch (PointerEvent.pointerType). */ pointers: ['touch'] as readonly string[],\n /** Where the map is the page (an app: AppShell, the mobile app), it takes every touch gesture (touch-action: none),\n * so the browser never zooms the page. Embedded on a scrolling page (website, docs), one finger still scrolls the\n * page (touch-action: pan-x pan-y); two fingers that land together pinch the map. */ appTouchAction: 'none', embeddedTouchAction: 'pan-x pan-y',\n /** Press and move on the empty canvas to pan the contents (mouse and pen; touch pans with two fingers, so one finger\n * still scrolls an embedded page). A press that moves less than `panSlop` px is a click. */ dragPan: true,\n panPointers: ['mouse', 'pen'] as readonly string[], panSlop: 6,\n /** Moving an idea starts once the press has moved this far (px), by pointerModeFor: a mouse ('hover') sooner, a finger\n * or pen ('touch') later, so taps still work. */\n ideaDragSlop: { hover: 4, touch: 10 },\n /** Zoom never navigates: stepping inside and backing out stay explicit (tap an idea / Step inside, the depth trail,\n * Escape or Backspace). */ zoomNavigates: false,\n} as const;\n\n/** The zoom after a pinch: the zoom at the start, scaled by how far the fingers spread, within VIEW's limits. */\nexport function pinchZoom(startZoom: number, startDistance: number, distance: number): number {\n const z = startZoom * (distance / Math.max(startDistance, 1));\n return Math.min(VIEW.zoomMax, Math.max(VIEW.zoomMin, z));\n}\n\n/** Keeps the map point that was under `from` under `to` when the scale changes from `s0` to `s1`: the new\n * translation, given the old one (screen = world × s + t). Used to zoom around the fingers. */\nexport function zoomAround(t0: { x: number; y: number }, s0: number, s1: number, from: { x: number; y: number }, to: { x: number; y: number }): { x: number; y: number } {\n const wx = (from.x - t0.x) / s0, wy = (from.y - t0.y) / s0;\n return { x: to.x - wx * s1, y: to.y - wy * s1 };\n}\n\n/** Framing a layer (fit to view): its ideas with room around them, and its container hulls with room for the name pill. */\nexport const FRAME = {\n /** Room beyond each idea's outermost ring (RINGS[2].scale, 1.3 × its half size): its stroke, hover lift and a little air. */ ring: 0.3, clearX: 16, clearY: 16,\n /** Room beyond each container hull for its dashed line and the name pill straddling it. */ hullX: 24, hullY: 40,\n} as const;\nexport type FrameBox = { x0: number; y0: number; x1: number; y1: number };\n\n/** The box a layer is framed by: every idea (`rx` / `ry` its half size) and every container hull. */\nexport function layerBounds(ideas: ReadonlyArray<{ x: number; y: number; rx: number; ry: number }>, hulls: ReadonlyArray<FrameBox> = []): FrameBox {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const n of ideas) {\n const px = n.rx * (1 + FRAME.ring) + FRAME.clearX, py = n.ry * (1 + FRAME.ring) + FRAME.clearY;\n x0 = Math.min(x0, n.x - px); x1 = Math.max(x1, n.x + px); y0 = Math.min(y0, n.y - py); y1 = Math.max(y1, n.y + py);\n }\n for (const h of hulls) { x0 = Math.min(x0, h.x0 - FRAME.hullX); x1 = Math.max(x1, h.x1 + FRAME.hullX); y0 = Math.min(y0, h.y0 - FRAME.hullY); y1 = Math.max(y1, h.y1 + FRAME.hullY); }\n if (!Number.isFinite(x0)) return { x0: -150, y0: -120, x1: 150, y1: 120 };\n return { x0, y0, x1, y1 };\n}\n\n/** Fit to view: the scale that shows `bounds` in an area of `width` × `height` (never beyond VIEW.fitMax), and the\n * world point to centre. */\nexport function fitView(bounds: FrameBox, width: number, height: number): { scale: number; center: { x: number; y: number } } {\n const scale = Math.min(width / Math.max(1, bounds.x1 - bounds.x0), height / Math.max(1, bounds.y1 - bounds.y0), VIEW.fitMax);\n return { scale, center: { x: (bounds.x0 + bounds.x1) / 2, y: (bounds.y0 + bounds.y1) / 2 } };\n}\n\n/** Insets: room the host's chrome takes at each edge of the map (a docked Vault, a top bar, the Composer). */\nexport type FrameInsets = { top?: number; right?: number; bottom?: number; left?: number };\n/** The smallest free area a map is ever fitted into, however much the insets take. */\nexport const FIT_ROOM = { minWidth: 200, minHeight: 160 } as const;\n\n/** Fit to view inside insets. The map's canvas fills its whole frame - so the canvas itself and its chromatic immersion\n * run behind the host's chrome (a docked Vault floats over the tinted canvas) - while the layer is fitted into the\n * free area (the frame less the insets, never below FIT_ROOM) and centred in it. `screen`: where on the canvas the\n * world `center` goes (screen = world × scale + translation); `room`: the free area's size. With no insets this is\n * fitView, centred on the canvas. */\nexport function fitViewInset(bounds: FrameBox, width: number, height: number, insets: FrameInsets = {}): { scale: number; center: { x: number; y: number }; screen: { x: number; y: number }; room: { width: number; height: number } } {\n const top = insets.top ?? 0, right = insets.right ?? 0, bottom = insets.bottom ?? 0, left = insets.left ?? 0;\n const w = Math.max(FIT_ROOM.minWidth, width - left - right), h = Math.max(FIT_ROOM.minHeight, height - top - bottom);\n const { scale, center } = fitView(bounds, w, h);\n return { scale, center, screen: { x: left + w / 2, y: top + h / 2 }, room: { width: w, height: h } };\n}\n\n/** Where the peek card sits (pointer): beside the idea — right of it if it fits, else left — and level with it. */\nexport const PEEK_PLACEMENT = {\n /** Gap between the idea's outermost ring and the card. */ gap: 16,\n /** The card's width and the height kept clear below it. */ cardWidth: 300, cardHeight: 220,\n /** The card is raised this much above the idea's centre. */ raise: 70,\n /** Kept this far inside the map's edges. */ margin: 12,\n} as const;\n\n/** The peek card's top-left, in map (screen) pixels. `idea`: the idea's centre on screen and its on-screen half\n * width with its outermost ring (`half`); `box`: the map's size. */\nexport function peekPosition(idea: { x: number; y: number; half: number }, box: { w: number; h: number }, card: { w: number; h: number } = { w: PEEK_PLACEMENT.cardWidth, h: PEEK_PLACEMENT.cardHeight }) {\n const P = PEEK_PLACEMENT, half = idea.half + P.gap;\n const right = idea.x + half + card.w < box.w - P.margin;\n return { left: right ? idea.x + half : Math.max(P.margin, idea.x - half - card.w), top: Math.min(Math.max(P.margin, idea.y - P.raise), box.h - card.h), side: right ? 'right' as const : 'left' as const };\n}\n\n/** The depth trail: each entry shows the idea that was stepped into — its title and a dot in its color (the same\n * topic or custom color the idea is drawn in, including the sibling-order topic of an uncolored idea). The first\n * entry is the map itself: a `stone` dot and the home glyph only (`rootLabel: 'icon'`) — no text, since a map's title\n * usually repeats its centre idea's, which the next entry shows; its accessible name and tooltip are the map's title.\n * The dot is the idea shape (shapeForLevel). */\nexport const TRAIL = { rootTopic: 'stone', rootLabel: 'icon', homeIconSize: 12, dotBox: 16, dotRadius: 6.4, stroke: 1.25, currentStroke: 1.75 } as const;\n\n/** How an input answers: a mouse hovers (peeks and terms open on hover); touch and pen tap. Null for unknown pointers. */\nexport function pointerModeFor(pointerType: string): 'hover' | 'touch' | null {\n return pointerType === 'mouse' ? 'hover' : pointerType === 'touch' || pointerType === 'pen' ? 'touch' : null;\n}\n\n/** Whether a pointer of this type opens a term on hover (PointerEvent.pointerType). */\nexport function hoverOpensTerm(pointerType: string): boolean {\n return TERM.hoverPointers.includes(pointerType);\n}\n","// ─── Performance & Rendering Constants ───────────────────────────────────────\n//\n// Performance budgets and interaction thresholds. Visual values (colours,\n// stroke widths, node size, zoom range) come from the design system tokens.\n\nimport { VIEW } from '../generated/geometry/interaction.js';\n\n// ── FPS ───────────────────────────────────────────────────────────────────────\n\nexport const FPS_TARGET = 60;\nexport const FPS_WARNING_THRESHOLD = 45;\nexport const FPS_CRITICAL_THRESHOLD = 30;\nexport const TARGET_FRAME_TIME = 1000 / FPS_TARGET; // ~16.67 ms\nexport const MAX_FRAME_TIME = 18; // p95 threshold\n\n/** Legacy frame-rate targets kept for backward compatibility. */\nexport const FPS_TARGETS = {\n PAN_MIN: 30,\n ZOOM_TARGET: 60,\n WARNING_THRESHOLD: 20,\n} as const;\n\n// ── Timing Thresholds (ms) ────────────────────────────────────────────────────\n\nexport const TIMING_THRESHOLDS = {\n VIEWPORT_QUERY_MAX: 5,\n SPATIAL_UPDATE_MAX: 10,\n DRAG_RESPONSE_MAX: 16,\n LOAD_5K_TARGET: 2000,\n LOAD_10K_TARGET: 3000,\n VIEWPORT_DEBOUNCE: 100,\n SPATIAL_INDEX_BUILD: 50,\n} as const;\n\n// ── Memory Limits (MB) ────────────────────────────────────────────────────────\n\nexport const MEMORY_TARGET_MB = 500;\nexport const MEMORY_WARNING_MB = 600;\nexport const MEMORY_CRITICAL_MB = 800;\n\nexport const MEMORY_LIMITS = {\n MAX_10K_NODES: 500,\n MAX_GROWTH_PERCENT: 20,\n WARNING_THRESHOLD: 400,\n} as const;\n\n// ── Viewport Culling ──────────────────────────────────────────────────────────\n\nexport const VIEWPORT_MARGIN = 0.1;\nexport const MAX_VISIBLE_NODES = 800;\nexport const CULLING_QUERY_TIME_BUDGET = 5;\n\n// ── Spatial Index ─────────────────────────────────────────────────────────────\n\nexport const RBUSH_MAX_ENTRIES = 16;\nexport const SPATIAL_INDEX_BUILD_BUDGET = 50;\n\n// ── Zoom Constraints ──────────────────────────────────────────────────────────\n\n// Zoom limits: the design system's VIEW (geometry/interaction.ts; equal to the zoom-min / zoom-max tokens).\nexport const ZOOM_MIN = VIEW.zoomMin;\nexport const ZOOM_MAX = VIEW.zoomMax;\nexport const ZOOM_DEFAULT = 1.0;\n\n// ── Quality Level Presets ─────────────────────────────────────────────────────\n\nexport const QUALITY_HIGH = {\n shadows: true,\n bezierCurves: true,\n animations: true,\n textQuality: 'high' as const,\n antialiasing: true,\n};\n\nexport const QUALITY_MEDIUM = {\n shadows: false,\n bezierCurves: true,\n animations: true,\n textQuality: 'medium' as const,\n antialiasing: true,\n};\n\nexport const QUALITY_LOW = {\n shadows: false,\n bezierCurves: false,\n animations: false,\n textQuality: 'low' as const,\n antialiasing: false,\n};\n\n// ── Performance Monitoring ────────────────────────────────────────────────────\n\nexport const FPS_SAMPLE_WINDOW = 60;\nexport const FPS_UPDATE_INTERVAL = 1000;\nexport const MEMORY_CHECK_INTERVAL = 5000;\nexport const PERFORMANCE_TOAST_COOLDOWN = 10000;\n\n// ── Auto-Adjustment ───────────────────────────────────────────────────────────\n\nexport const FPS_DOWNGRADE_THRESHOLD = 45;\nexport const FPS_UPGRADE_THRESHOLD = 58;\nexport const FPS_STABILIZATION_FRAMES = 180;\n\n// ── Canvas Dimensions ─────────────────────────────────────────────────────────\n\nexport const DEFAULT_CANVAS_WIDTH = 1920;\nexport const DEFAULT_CANVAS_HEIGHT = 1080;\n\n// ── Interaction ───────────────────────────────────────────────────────────────\n\nexport const CLICK_THRESHOLD = 5;\nexport const DOUBLE_CLICK_DELAY = 300;\nexport const DRAG_START_DISTANCE = 10;\n\n// ── Data Validation ───────────────────────────────────────────────────────────\n\nexport const MAX_NODES = 20000;\nexport const CIRCULAR_REFERENCE_MAX_DEPTH = 1000;\n\n// ── Debounce / Throttle ───────────────────────────────────────────────────────\n\nexport const RESIZE_DEBOUNCE = 300;\nexport const SCROLL_THROTTLE = 16;\nexport const SEARCH_DEBOUNCE = 500;\n\n/** Node count thresholds that gate optimisation strategies. */\nexport const NODE_COUNT_THRESHOLDS = {\n SPATIAL_INDEX_MIN: 100,\n VIEWPORT_CULLING_MIN: 500,\n CANVAS_RENDERING_MIN: 2000,\n DOM_RENDERING_MAX: 5000,\n} as const;\n\n/** Viewport buffer configuration. */\nexport const VIEWPORT_CONFIG = {\n BUFFER_PERCENT: 0.2,\n MIN_VISIBLE_NODES: 10,\n} as const;\n","// ─── Viewport Utilities ───────────────────────────────────────────────────────\n//\n// Pure functions for viewport bounds calculation, coordinate transforms,\n// pan/zoom operations, and node visibility queries.\n\nimport type { ViewportState } from '../types/mindmap.js';\nimport {\n VIEWPORT_MARGIN,\n DEFAULT_CANVAS_WIDTH,\n DEFAULT_CANVAS_HEIGHT,\n ZOOM_MIN,\n ZOOM_MAX,\n} from '../constants/performanceConstants.js';\n\n// ── Viewport Bounds ───────────────────────────────────────────────────────────\n\nexport interface WorldBounds {\n minX: number;\n minY: number;\n maxX: number;\n maxY: number;\n}\n\n/**\n * Calculate the visible world-space bounding box including a margin buffer.\n */\nexport function calculateViewportBounds(\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): WorldBounds {\n const worldW = canvasWidth / viewport.zoomLevel;\n const worldH = canvasHeight / viewport.zoomLevel;\n const mx = worldW * VIEWPORT_MARGIN;\n const my = worldH * VIEWPORT_MARGIN;\n return {\n minX: viewport.centerX - worldW / 2 - mx,\n minY: viewport.centerY - worldH / 2 - my,\n maxX: viewport.centerX + worldW / 2 + mx,\n maxY: viewport.centerY + worldH / 2 + my,\n };\n}\n\n/**\n * Return a new ViewportState with `visibleBounds` recalculated.\n */\nexport function recalculateViewportBounds(\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): ViewportState {\n return {\n ...viewport,\n visibleBounds: calculateViewportBounds(viewport, canvasWidth, canvasHeight),\n };\n}\n\n// ── Coordinate Transforms ─────────────────────────────────────────────────────\n\n/**\n * Convert world-space coordinates to screen-space pixel coordinates.\n */\nexport function worldToScreen(\n worldX: number,\n worldY: number,\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): { x: number; y: number } {\n return {\n x: (worldX - viewport.centerX) * viewport.zoomLevel + canvasWidth / 2,\n y: (worldY - viewport.centerY) * viewport.zoomLevel + canvasHeight / 2,\n };\n}\n\n/**\n * Convert screen-space pixel coordinates to world-space coordinates.\n */\nexport function screenToWorld(\n screenX: number,\n screenY: number,\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): { x: number; y: number } {\n return {\n x: (screenX - canvasWidth / 2) / viewport.zoomLevel + viewport.centerX,\n y: (screenY - canvasHeight / 2) / viewport.zoomLevel + viewport.centerY,\n };\n}\n\n// ── Pan / Zoom ────────────────────────────────────────────────────────────────\n\n/** Clamp zoom to the design system's limits (VIEW: ZOOM_MIN–ZOOM_MAX), which apply to the zoom relative to the\n * layer's fit (`fit`: the fit-to-view scale), as in the design system's map (scale = fit × zoom). */\nexport function clampZoom(zoom: number, fit = 1): number {\n return Math.min(ZOOM_MAX * fit, Math.max(ZOOM_MIN * fit, zoom));\n}\n\n/**\n * Pan the viewport by a screen-space delta (positive = right/down).\n */\nexport function panViewport(\n deltaX: number,\n deltaY: number,\n viewport: ViewportState,\n): ViewportState {\n return {\n ...viewport,\n centerX: viewport.centerX - deltaX / viewport.zoomLevel,\n centerY: viewport.centerY - deltaY / viewport.zoomLevel,\n };\n}\n\n/** Teleport the viewport centre to the given world coordinates. */\nexport function setViewportCenter(\n x: number,\n y: number,\n viewport: ViewportState,\n): ViewportState {\n return { ...viewport, centerX: x, centerY: y };\n}\n\n/**\n * Zoom the viewport by a multiplicative delta, optionally around a pivot point.\n *\n * @param delta - Multiplier delta, e.g. 0.1 for +10% zoom\n * @param pivotX - Optional screen-space X pivot\n * @param pivotY - Optional screen-space Y pivot\n */\nexport function zoomViewport(\n delta: number,\n viewport: ViewportState,\n pivotX?: number,\n pivotY?: number,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n fit = 1,\n): ViewportState {\n const newZoom = clampZoom(viewport.zoomLevel * (1 + delta), fit);\n\n let cx = viewport.centerX;\n let cy = viewport.centerY;\n\n if (pivotX !== undefined && pivotY !== undefined) {\n const worldPivot = screenToWorld(pivotX, pivotY, viewport, canvasWidth, canvasHeight);\n cx = worldPivot.x - (pivotX - canvasWidth / 2) / newZoom;\n cy = worldPivot.y - (pivotY - canvasHeight / 2) / newZoom;\n }\n\n return { ...viewport, centerX: cx, centerY: cy, zoomLevel: newZoom };\n}\n\n/**\n * Create a viewport centred on a node (world coordinates) at the given zoom level.\n */\nexport function focusOnNode(\n nodeX: number,\n nodeY: number,\n zoom: number,\n): ViewportState {\n const clamped = clampZoom(zoom);\n return {\n centerX: nodeX,\n centerY: nodeY,\n zoomLevel: clamped,\n rotation: 0,\n visibleBounds: calculateViewportBounds(\n { centerX: nodeX, centerY: nodeY, zoomLevel: clamped, rotation: 0, visibleBounds: { minX: 0, minY: 0, maxX: 0, maxY: 0 } },\n ),\n };\n}\n\n// ── Visibility ────────────────────────────────────────────────────────────────\n\n/**\n * Test whether a world-space AABB intersects the viewport's visible bounds.\n */\nexport function isNodeInViewport(\n nodeX: number,\n nodeY: number,\n nodeWidth: number,\n nodeHeight: number,\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): boolean {\n const bounds = calculateViewportBounds(viewport, canvasWidth, canvasHeight);\n const hw = nodeWidth / 2;\n const hh = nodeHeight / 2;\n return !(\n nodeX + hw < bounds.minX ||\n nodeX - hw > bounds.maxX ||\n nodeY + hh < bounds.minY ||\n nodeY - hh > bounds.maxY\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC+BO,IAAM,OAAO;AAAA;AAAA,EAC4C,UAAU;AAAA;AAAA,EACU,SAAS;AAAA,EAAK,SAAS;AAAA;AAAA,EAClD,QAAQ;AACjE;;;AC1BO,IAAM,aAA6B;AAGnC,IAAM,oBAA6B,MAAO;AAoC1C,IAAM,kBAA2B;AAYjC,IAAM,WAAwB,KAAK;AACnC,IAAM,WAAwB,KAAK;AA4CnC,IAAM,uBAAwB;AAC9B,IAAM,wBAAwB;;;AChF9B,SAAS,wBACd,UACA,cAAe,sBACf,eAAe,uBACF;AACb,QAAM,SAAS,cAAe,SAAS;AACvC,QAAM,SAAS,eAAe,SAAS;AACvC,QAAM,KAAK,SAAS;AACpB,QAAM,KAAK,SAAS;AACpB,SAAO;AAAA,IACL,MAAM,SAAS,UAAU,SAAS,IAAI;AAAA,IACtC,MAAM,SAAS,UAAU,SAAS,IAAI;AAAA,IACtC,MAAM,SAAS,UAAU,SAAS,IAAI;AAAA,IACtC,MAAM,SAAS,UAAU,SAAS,IAAI;AAAA,EACxC;AACF;AAKO,SAAS,0BACd,UACA,cAAe,sBACf,eAAe,uBACA;AACf,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe,wBAAwB,UAAU,aAAa,YAAY;AAAA,EAC5E;AACF;AAOO,SAAS,cACd,QACA,QACA,UACA,cAAe,sBACf,eAAe,uBACW;AAC1B,SAAO;AAAA,IACL,IAAI,SAAS,SAAS,WAAW,SAAS,YAA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AAAA,MACb,EAAE,SAAS,OAAO,SAAS,OAAO,WAAW,SAAS,UAAU,GAAG,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,EAAE;AAAA,IAC3H;AAAA,EACF;AACF;AAOO,SAAS,iBACd,OACA,OACA,WACA,YACA,UACA,cAAe,sBACf,eAAe,uBACN;AACT,QAAM,SAAS,wBAAwB,UAAU,aAAa,YAAY;AAC1E,QAAM,KAAK,YAAa;AACxB,QAAM,KAAK,aAAa;AACxB,SAAO,EACL,QAAQ,KAAK,OAAO,QACpB,QAAQ,KAAK,OAAO,QACpB,QAAQ,KAAK,OAAO,QACpB,QAAQ,KAAK,OAAO;AAExB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/viewport/index.ts","../../src/generated/geometry/interaction.ts","../../src/constants/performanceConstants.ts","../../src/viewport/viewportUtils.ts"],"sourcesContent":["export * from './viewportUtils.js';\n","// Generated from visualli.ai design-system/components/src/interaction.ts — do not edit here.\n/* How the canvas answers the pointer and the keyboard — the timing and rules behind the peek (an idea's summary)\n and terms (semantic anchors: an underlined word and its definition card). The look and the pop-in animation live\n in the CSS (.vi-fact, .vi-anchor, .vi-anchor-card); these are the behaviours, as data, so every renderer (VisualMap,\n the spec SDK on a canvas) opens and closes them alike. Times in ms. No dependencies, so it can travel alone. */\n\n/** Terms (semantic anchors) in a peek's text. */\nexport const TERM = {\n /** Hovering the term this long opens its definition card… */ hoverOpen: 250,\n /** …which closes this long after the pointer leaves both the term and the card (moving between them keeps it open). */ hoverClose: 300,\n /** Only a mouse opens on hover; touch and pen open on tap. */ hoverPointers: ['mouse'] as readonly string[],\n /** A click, tap, Enter or Space pins the card open (hovering away doesn't close it); pressing again unpins and closes. */ clickPins: true,\n /** Escape closes the card and returns focus to the term; a press anywhere outside the term and its card closes it. */ escapeCloses: true, pressOutsideCloses: true,\n /** Opening by click or keyboard moves focus to the card's first link or button. */ focusCardOnOpen: true,\n /** The card is kept this far inside the viewport's left and right edges. */ viewportMargin: 8,\n /** The card's link to a source about the term. */ learnMoreLabel: 'Learn more',\n} as const;\n\n/** The peek: an idea's summary card on hover (pointer) or tap (touch). */\nexport const PEEK = {\n /** Hovering an idea opens its peek at once; it stays this long after the pointer leaves the idea (and while the\n * pointer is over the peek itself), so the pointer can travel from the idea onto the card. */ hoverClose: 180,\n} as const;\n\n/** The touch peek: a bottom sheet with a grip. */\nexport const SHEET = {\n /** Dragging the grip down this far closes the sheet (or collapses it when expanded); up this far expands it. */ dismissDrag: 80, expandDrag: 40,\n /** Its height: this share of the map, at most `maxHeight` px; the map pans the chosen idea into the space above it. */ heightRatio: 0.42, maxHeight: 300,\n} as const;\n\n/** Zoom, pan and fit. */\nexport const VIEW = {\n /** Each zoom step multiplies or divides the zoom by this. */ zoomStep: 1.2,\n /** Zoom limits (the zoom-min / zoom-max tokens; the build checks they agree). */ zoomMin: 0.3, zoomMax: 5,\n /** Fit to view never enlarges a layer beyond this. */ fitMax: 1.1,\n} as const;\n\n/** Touch gestures on the map (any touch input — phones, tablets and touchscreen laptops alike; it follows the pointer\n * in use, not the device, so a mouse or trackpad on the same laptop isn't affected). */\nexport const GESTURE = {\n /** Two fingers pinch to zoom the map's contents — ideas, connectors, containers and their labels — around the\n * point between the fingers, within VIEW's limits. Controls, the depth trail, the peek, chat and the page never scale. */ pinchZoom: true,\n /** Moving both fingers pans the contents. */ twoFingerPan: true,\n /** One finger on the empty canvas pans the contents too, on every surface (VI-040). A host whose map sits inside a\n * scrolling page can pass `gestures=\"cooperative\"` to give one finger back to the page (two fingers then move the map). */ oneFingerPan: true,\n /** The pointers that pinch (PointerEvent.pointerType). */ pointers: ['touch'] as readonly string[],\n /** The map takes every touch gesture (touch-action: none), so the browser never zooms or scrolls under it. With\n * `gestures=\"cooperative\"` one finger scrolls the page (touch-action: pan-x pan-y); two fingers move the map. */ appTouchAction: 'none', embeddedTouchAction: 'pan-x pan-y',\n /** Press and move on the empty canvas to pan the contents - mouse, pen and one finger. A press that moves less than\n * `panSlop` px is a click or a tap. */ dragPan: true,\n panPointers: ['mouse', 'pen', 'touch'] as readonly string[], panSlop: 6,\n /** Moving an idea starts once the press has moved this far (px), by pointerModeFor: a mouse ('hover') sooner, a finger\n * or pen ('touch') later, so taps still work. */\n ideaDragSlop: { hover: 4, touch: 10 },\n} as const;\n\n/** Going back a layer without the trail (VI-040): double-click empty canvas (not while editing - there it adds an idea)\n * or double-tap it. Never on an idea, a card, the trail or a control. At the top layer the\n * map gives a small bump instead. A double-tap whose first tap closed a peek doesn't also go back. */\nexport const BACK = {\n /** Two taps this close in time (ms) and place (px) are a double-tap. */ doubleTapMs: 300, doubleTapPx: 32,\n /** The bump at the top layer (ms). */ bumpMs: 320,\n} as const;\n\n/** How the map changed layer, reported with onLayerPathChange so a host can keep browser history in step:\n * 'step-in' (an idea's rings or Step inside), 'trail', 'gesture' (double-click, double-tap), 'key' (Escape, Backspace), 'host' (the host set layerPath). */\nexport type LayerVia = 'step-in' | 'trail' | 'gesture' | 'key' | 'host';\n\n/** The zoom after a pinch: the zoom at the start, scaled by how far the fingers spread, within VIEW's limits. */\nexport function pinchZoom(startZoom: number, startDistance: number, distance: number): number {\n const z = startZoom * (distance / Math.max(startDistance, 1));\n return Math.min(VIEW.zoomMax, Math.max(VIEW.zoomMin, z));\n}\n\n/** Keeps the map point that was under `from` under `to` when the scale changes from `s0` to `s1`: the new\n * translation, given the old one (screen = world × s + t). Used to zoom around the fingers. */\nexport function zoomAround(t0: { x: number; y: number }, s0: number, s1: number, from: { x: number; y: number }, to: { x: number; y: number }): { x: number; y: number } {\n const wx = (from.x - t0.x) / s0, wy = (from.y - t0.y) / s0;\n return { x: to.x - wx * s1, y: to.y - wy * s1 };\n}\n\n/** Framing a layer (fit to view): its ideas with room around them, and its container hulls with room for the name pill. */\nexport const FRAME = {\n /** Room beyond each idea's outermost ring (RINGS[2].scale, 1.3 × its half size): its stroke, hover lift and a little air. */ ring: 0.3, clearX: 16, clearY: 16,\n /** Room beyond each container hull for its dashed line and the name pill straddling it. */ hullX: 24, hullY: 40,\n} as const;\nexport type FrameBox = { x0: number; y0: number; x1: number; y1: number };\n\n/** The box a layer is framed by: every idea (`rx` / `ry` its half size) and every container hull. */\nexport function layerBounds(ideas: ReadonlyArray<{ x: number; y: number; rx: number; ry: number }>, hulls: ReadonlyArray<FrameBox> = []): FrameBox {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const n of ideas) {\n const px = n.rx * (1 + FRAME.ring) + FRAME.clearX, py = n.ry * (1 + FRAME.ring) + FRAME.clearY;\n x0 = Math.min(x0, n.x - px); x1 = Math.max(x1, n.x + px); y0 = Math.min(y0, n.y - py); y1 = Math.max(y1, n.y + py);\n }\n for (const h of hulls) { x0 = Math.min(x0, h.x0 - FRAME.hullX); x1 = Math.max(x1, h.x1 + FRAME.hullX); y0 = Math.min(y0, h.y0 - FRAME.hullY); y1 = Math.max(y1, h.y1 + FRAME.hullY); }\n if (!Number.isFinite(x0)) return { x0: -150, y0: -120, x1: 150, y1: 120 };\n return { x0, y0, x1, y1 };\n}\n\n/** Fit to view: the scale that shows `bounds` in an area of `width` × `height` (never beyond VIEW.fitMax), and the\n * world point to centre. */\nexport function fitView(bounds: FrameBox, width: number, height: number): { scale: number; center: { x: number; y: number } } {\n const scale = Math.min(width / Math.max(1, bounds.x1 - bounds.x0), height / Math.max(1, bounds.y1 - bounds.y0), VIEW.fitMax);\n return { scale, center: { x: (bounds.x0 + bounds.x1) / 2, y: (bounds.y0 + bounds.y1) / 2 } };\n}\n\n/** Insets: room the host's chrome takes at each edge of the map (a docked Vault, a top bar, the Composer). */\nexport type FrameInsets = { top?: number; right?: number; bottom?: number; left?: number };\n/** The smallest free area a map is ever fitted into, however much the insets take. */\nexport const FIT_ROOM = { minWidth: 200, minHeight: 160 } as const;\n\n/** Fit to view inside insets. The map's canvas fills its whole frame - so the canvas itself and its chromatic immersion\n * run behind the host's chrome (a docked Vault floats over the tinted canvas) - while the layer is fitted into the\n * free area (the frame less the insets, never below FIT_ROOM) and centred in it. `screen`: where on the canvas the\n * world `center` goes (screen = world × scale + translation); `room`: the free area's size. With no insets this is\n * fitView, centred on the canvas. */\nexport function fitViewInset(bounds: FrameBox, width: number, height: number, insets: FrameInsets = {}): { scale: number; center: { x: number; y: number }; screen: { x: number; y: number }; room: { width: number; height: number } } {\n const top = insets.top ?? 0, right = insets.right ?? 0, bottom = insets.bottom ?? 0, left = insets.left ?? 0;\n const w = Math.max(FIT_ROOM.minWidth, width - left - right), h = Math.max(FIT_ROOM.minHeight, height - top - bottom);\n const { scale, center } = fitView(bounds, w, h);\n return { scale, center, screen: { x: left + w / 2, y: top + h / 2 }, room: { width: w, height: h } };\n}\n\n/** Where the peek card sits (pointer): beside the idea — right of it if it fits, else left — and level with it. */\nexport const PEEK_PLACEMENT = {\n /** Gap between the idea's outermost ring and the card. */ gap: 16,\n /** The card's width and the height kept clear below it. */ cardWidth: 300, cardHeight: 220,\n /** The card is raised this much above the idea's centre. */ raise: 70,\n /** Kept this far inside the map's edges. */ margin: 12,\n} as const;\n\n/** The peek card's top-left, in map (screen) pixels. `idea`: the idea's centre on screen and its on-screen half\n * width with its outermost ring (`half`); `box`: the map's size. */\nexport function peekPosition(idea: { x: number; y: number; half: number }, box: { w: number; h: number }, card: { w: number; h: number } = { w: PEEK_PLACEMENT.cardWidth, h: PEEK_PLACEMENT.cardHeight }) {\n const P = PEEK_PLACEMENT, half = idea.half + P.gap;\n const right = idea.x + half + card.w < box.w - P.margin;\n return { left: right ? idea.x + half : Math.max(P.margin, idea.x - half - card.w), top: Math.min(Math.max(P.margin, idea.y - P.raise), box.h - card.h), side: right ? 'right' as const : 'left' as const };\n}\n\n/** The depth trail: each entry shows the idea that was stepped into — its title and a dot in its color (the same\n * topic or custom color the idea is drawn in, including the sibling-order topic of an uncolored idea). The first\n * entry is the map itself: a `stone` dot and the home glyph only (`rootLabel: 'icon'`) — no text, since a map's title\n * usually repeats its centre idea's, which the next entry shows; its accessible name and tooltip are the map's title.\n * The dot is the idea shape (shapeForLevel). */\nexport const TRAIL = { rootTopic: 'stone', rootLabel: 'icon', homeIconSize: 12, dotBox: 16, dotRadius: 6.4, stroke: 1.25, currentStroke: 1.75 } as const;\n\n/** How an input answers: a mouse hovers (peeks and terms open on hover); touch and pen tap. Null for unknown pointers. */\nexport function pointerModeFor(pointerType: string): 'hover' | 'touch' | null {\n return pointerType === 'mouse' ? 'hover' : pointerType === 'touch' || pointerType === 'pen' ? 'touch' : null;\n}\n\n/** Whether a pointer of this type opens a term on hover (PointerEvent.pointerType). */\nexport function hoverOpensTerm(pointerType: string): boolean {\n return TERM.hoverPointers.includes(pointerType);\n}\n","// ─── Performance & Rendering Constants ───────────────────────────────────────\n//\n// Performance budgets and interaction thresholds. Visual values (colours,\n// stroke widths, node size, zoom range) come from the design system tokens.\n\nimport { VIEW } from '../generated/geometry/interaction.js';\n\n// ── FPS ───────────────────────────────────────────────────────────────────────\n\nexport const FPS_TARGET = 60;\nexport const FPS_WARNING_THRESHOLD = 45;\nexport const FPS_CRITICAL_THRESHOLD = 30;\nexport const TARGET_FRAME_TIME = 1000 / FPS_TARGET; // ~16.67 ms\nexport const MAX_FRAME_TIME = 18; // p95 threshold\n\n/** Legacy frame-rate targets kept for backward compatibility. */\nexport const FPS_TARGETS = {\n PAN_MIN: 30,\n ZOOM_TARGET: 60,\n WARNING_THRESHOLD: 20,\n} as const;\n\n// ── Timing Thresholds (ms) ────────────────────────────────────────────────────\n\nexport const TIMING_THRESHOLDS = {\n VIEWPORT_QUERY_MAX: 5,\n SPATIAL_UPDATE_MAX: 10,\n DRAG_RESPONSE_MAX: 16,\n LOAD_5K_TARGET: 2000,\n LOAD_10K_TARGET: 3000,\n VIEWPORT_DEBOUNCE: 100,\n SPATIAL_INDEX_BUILD: 50,\n} as const;\n\n// ── Memory Limits (MB) ────────────────────────────────────────────────────────\n\nexport const MEMORY_TARGET_MB = 500;\nexport const MEMORY_WARNING_MB = 600;\nexport const MEMORY_CRITICAL_MB = 800;\n\nexport const MEMORY_LIMITS = {\n MAX_10K_NODES: 500,\n MAX_GROWTH_PERCENT: 20,\n WARNING_THRESHOLD: 400,\n} as const;\n\n// ── Viewport Culling ──────────────────────────────────────────────────────────\n\nexport const VIEWPORT_MARGIN = 0.1;\nexport const MAX_VISIBLE_NODES = 800;\nexport const CULLING_QUERY_TIME_BUDGET = 5;\n\n// ── Spatial Index ─────────────────────────────────────────────────────────────\n\nexport const RBUSH_MAX_ENTRIES = 16;\nexport const SPATIAL_INDEX_BUILD_BUDGET = 50;\n\n// ── Zoom Constraints ──────────────────────────────────────────────────────────\n\n// Zoom limits: the design system's VIEW (geometry/interaction.ts; equal to the zoom-min / zoom-max tokens).\nexport const ZOOM_MIN = VIEW.zoomMin;\nexport const ZOOM_MAX = VIEW.zoomMax;\nexport const ZOOM_DEFAULT = 1.0;\n\n// ── Quality Level Presets ─────────────────────────────────────────────────────\n\nexport const QUALITY_HIGH = {\n shadows: true,\n bezierCurves: true,\n animations: true,\n textQuality: 'high' as const,\n antialiasing: true,\n};\n\nexport const QUALITY_MEDIUM = {\n shadows: false,\n bezierCurves: true,\n animations: true,\n textQuality: 'medium' as const,\n antialiasing: true,\n};\n\nexport const QUALITY_LOW = {\n shadows: false,\n bezierCurves: false,\n animations: false,\n textQuality: 'low' as const,\n antialiasing: false,\n};\n\n// ── Performance Monitoring ────────────────────────────────────────────────────\n\nexport const FPS_SAMPLE_WINDOW = 60;\nexport const FPS_UPDATE_INTERVAL = 1000;\nexport const MEMORY_CHECK_INTERVAL = 5000;\nexport const PERFORMANCE_TOAST_COOLDOWN = 10000;\n\n// ── Auto-Adjustment ───────────────────────────────────────────────────────────\n\nexport const FPS_DOWNGRADE_THRESHOLD = 45;\nexport const FPS_UPGRADE_THRESHOLD = 58;\nexport const FPS_STABILIZATION_FRAMES = 180;\n\n// ── Canvas Dimensions ─────────────────────────────────────────────────────────\n\nexport const DEFAULT_CANVAS_WIDTH = 1920;\nexport const DEFAULT_CANVAS_HEIGHT = 1080;\n\n// ── Interaction ───────────────────────────────────────────────────────────────\n\nexport const CLICK_THRESHOLD = 5;\nexport const DOUBLE_CLICK_DELAY = 300;\nexport const DRAG_START_DISTANCE = 10;\n\n// ── Data Validation ───────────────────────────────────────────────────────────\n\nexport const MAX_NODES = 20000;\nexport const CIRCULAR_REFERENCE_MAX_DEPTH = 1000;\n\n// ── Debounce / Throttle ───────────────────────────────────────────────────────\n\nexport const RESIZE_DEBOUNCE = 300;\nexport const SCROLL_THROTTLE = 16;\nexport const SEARCH_DEBOUNCE = 500;\n\n/** Node count thresholds that gate optimisation strategies. */\nexport const NODE_COUNT_THRESHOLDS = {\n SPATIAL_INDEX_MIN: 100,\n VIEWPORT_CULLING_MIN: 500,\n CANVAS_RENDERING_MIN: 2000,\n DOM_RENDERING_MAX: 5000,\n} as const;\n\n/** Viewport buffer configuration. */\nexport const VIEWPORT_CONFIG = {\n BUFFER_PERCENT: 0.2,\n MIN_VISIBLE_NODES: 10,\n} as const;\n","// ─── Viewport Utilities ───────────────────────────────────────────────────────\n//\n// Pure functions for viewport bounds calculation, coordinate transforms,\n// pan/zoom operations, and node visibility queries.\n\nimport type { ViewportState } from '../types/mindmap.js';\nimport {\n VIEWPORT_MARGIN,\n DEFAULT_CANVAS_WIDTH,\n DEFAULT_CANVAS_HEIGHT,\n ZOOM_MIN,\n ZOOM_MAX,\n} from '../constants/performanceConstants.js';\n\n// ── Viewport Bounds ───────────────────────────────────────────────────────────\n\nexport interface WorldBounds {\n minX: number;\n minY: number;\n maxX: number;\n maxY: number;\n}\n\n/**\n * Calculate the visible world-space bounding box including a margin buffer.\n */\nexport function calculateViewportBounds(\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): WorldBounds {\n const worldW = canvasWidth / viewport.zoomLevel;\n const worldH = canvasHeight / viewport.zoomLevel;\n const mx = worldW * VIEWPORT_MARGIN;\n const my = worldH * VIEWPORT_MARGIN;\n return {\n minX: viewport.centerX - worldW / 2 - mx,\n minY: viewport.centerY - worldH / 2 - my,\n maxX: viewport.centerX + worldW / 2 + mx,\n maxY: viewport.centerY + worldH / 2 + my,\n };\n}\n\n/**\n * Return a new ViewportState with `visibleBounds` recalculated.\n */\nexport function recalculateViewportBounds(\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): ViewportState {\n return {\n ...viewport,\n visibleBounds: calculateViewportBounds(viewport, canvasWidth, canvasHeight),\n };\n}\n\n// ── Coordinate Transforms ─────────────────────────────────────────────────────\n\n/**\n * Convert world-space coordinates to screen-space pixel coordinates.\n */\nexport function worldToScreen(\n worldX: number,\n worldY: number,\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): { x: number; y: number } {\n return {\n x: (worldX - viewport.centerX) * viewport.zoomLevel + canvasWidth / 2,\n y: (worldY - viewport.centerY) * viewport.zoomLevel + canvasHeight / 2,\n };\n}\n\n/**\n * Convert screen-space pixel coordinates to world-space coordinates.\n */\nexport function screenToWorld(\n screenX: number,\n screenY: number,\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): { x: number; y: number } {\n return {\n x: (screenX - canvasWidth / 2) / viewport.zoomLevel + viewport.centerX,\n y: (screenY - canvasHeight / 2) / viewport.zoomLevel + viewport.centerY,\n };\n}\n\n// ── Pan / Zoom ────────────────────────────────────────────────────────────────\n\n/** Clamp zoom to the design system's limits (VIEW: ZOOM_MIN–ZOOM_MAX), which apply to the zoom relative to the\n * layer's fit (`fit`: the fit-to-view scale), as in the design system's map (scale = fit × zoom). */\nexport function clampZoom(zoom: number, fit = 1): number {\n return Math.min(ZOOM_MAX * fit, Math.max(ZOOM_MIN * fit, zoom));\n}\n\n/**\n * Pan the viewport by a screen-space delta (positive = right/down).\n */\nexport function panViewport(\n deltaX: number,\n deltaY: number,\n viewport: ViewportState,\n): ViewportState {\n return {\n ...viewport,\n centerX: viewport.centerX - deltaX / viewport.zoomLevel,\n centerY: viewport.centerY - deltaY / viewport.zoomLevel,\n };\n}\n\n/** Teleport the viewport centre to the given world coordinates. */\nexport function setViewportCenter(\n x: number,\n y: number,\n viewport: ViewportState,\n): ViewportState {\n return { ...viewport, centerX: x, centerY: y };\n}\n\n/**\n * Zoom the viewport by a multiplicative delta, optionally around a pivot point.\n *\n * @param delta - Multiplier delta, e.g. 0.1 for +10% zoom\n * @param pivotX - Optional screen-space X pivot\n * @param pivotY - Optional screen-space Y pivot\n */\nexport function zoomViewport(\n delta: number,\n viewport: ViewportState,\n pivotX?: number,\n pivotY?: number,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n fit = 1,\n): ViewportState {\n const newZoom = clampZoom(viewport.zoomLevel * (1 + delta), fit);\n\n let cx = viewport.centerX;\n let cy = viewport.centerY;\n\n if (pivotX !== undefined && pivotY !== undefined) {\n const worldPivot = screenToWorld(pivotX, pivotY, viewport, canvasWidth, canvasHeight);\n cx = worldPivot.x - (pivotX - canvasWidth / 2) / newZoom;\n cy = worldPivot.y - (pivotY - canvasHeight / 2) / newZoom;\n }\n\n return { ...viewport, centerX: cx, centerY: cy, zoomLevel: newZoom };\n}\n\n/**\n * Create a viewport centred on a node (world coordinates) at the given zoom level.\n */\nexport function focusOnNode(\n nodeX: number,\n nodeY: number,\n zoom: number,\n): ViewportState {\n const clamped = clampZoom(zoom);\n return {\n centerX: nodeX,\n centerY: nodeY,\n zoomLevel: clamped,\n rotation: 0,\n visibleBounds: calculateViewportBounds(\n { centerX: nodeX, centerY: nodeY, zoomLevel: clamped, rotation: 0, visibleBounds: { minX: 0, minY: 0, maxX: 0, maxY: 0 } },\n ),\n };\n}\n\n// ── Visibility ────────────────────────────────────────────────────────────────\n\n/**\n * Test whether a world-space AABB intersects the viewport's visible bounds.\n */\nexport function isNodeInViewport(\n nodeX: number,\n nodeY: number,\n nodeWidth: number,\n nodeHeight: number,\n viewport: ViewportState,\n canvasWidth = DEFAULT_CANVAS_WIDTH,\n canvasHeight = DEFAULT_CANVAS_HEIGHT,\n): boolean {\n const bounds = calculateViewportBounds(viewport, canvasWidth, canvasHeight);\n const hw = nodeWidth / 2;\n const hh = nodeHeight / 2;\n return !(\n nodeX + hw < bounds.minX ||\n nodeX - hw > bounds.maxX ||\n nodeY + hh < bounds.minY ||\n nodeY - hh > bounds.maxY\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC+BO,IAAM,OAAO;AAAA;AAAA,EAC4C,UAAU;AAAA;AAAA,EACU,SAAS;AAAA,EAAK,SAAS;AAAA;AAAA,EAClD,QAAQ;AACjE;;;AC1BO,IAAM,aAA6B;AAGnC,IAAM,oBAA6B,MAAO;AAoC1C,IAAM,kBAA2B;AAYjC,IAAM,WAAwB,KAAK;AACnC,IAAM,WAAwB,KAAK;AA4CnC,IAAM,uBAAwB;AAC9B,IAAM,wBAAwB;;;AChF9B,SAAS,wBACd,UACA,cAAe,sBACf,eAAe,uBACF;AACb,QAAM,SAAS,cAAe,SAAS;AACvC,QAAM,SAAS,eAAe,SAAS;AACvC,QAAM,KAAK,SAAS;AACpB,QAAM,KAAK,SAAS;AACpB,SAAO;AAAA,IACL,MAAM,SAAS,UAAU,SAAS,IAAI;AAAA,IACtC,MAAM,SAAS,UAAU,SAAS,IAAI;AAAA,IACtC,MAAM,SAAS,UAAU,SAAS,IAAI;AAAA,IACtC,MAAM,SAAS,UAAU,SAAS,IAAI;AAAA,EACxC;AACF;AAKO,SAAS,0BACd,UACA,cAAe,sBACf,eAAe,uBACA;AACf,SAAO;AAAA,IACL,GAAG;AAAA,IACH,eAAe,wB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KO,SAAS,YACd,OACA,OACA,MACe;AACf,QAAM,UAAU,UAAU,IAAI;AAC9B,SAAO;AAAA,IACL,SAAU;AAAA,IACV,SAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,eAAe;AAAA,MACb,EAAE,SAAS,OAAO,SAAS,OAAO,WAAW,SAAS,UAAU,GAAG,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,EAAE;AAAA,IAC3H;AAAA,EACF;AACF;AAOO,SAAS,iBACd,OACA,OACA,WACA,YACA,UACA,cAAe,sBACf,eAAe,uBACN;AACT,QAAM,SAAS,wBAAwB,UAAU,aAAa,YAAY;AAC1E,QAAM,KAAK,YAAa;AACxB,QAAM,KAAK,aAAa;AACxB,SAAO,EACL,QAAQ,KAAK,OAAO,QACpB,QAAQ,KAAK,OAAO,QACpB,QAAQ,KAAK,OAAO,QACpB,QAAQ,KAAK,OAAO;AAExB;","names":[]}
|
package/dist/viewport/index.d.ts
CHANGED
package/dist/viewport/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visualli/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "Framework-agnostic core logic, types, and engines for Visualli",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"test": "vitest run"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@visualli/bindings": "0.2.
|
|
77
|
+
"@visualli/bindings": "0.2.14",
|
|
78
78
|
"rbush": "^3.0.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Change the design system instead; the next `npm run build` regenerates this file.
|
|
3
3
|
|
|
4
4
|
/** Version of the design system these modules were generated from. */
|
|
5
|
-
export const DESIGN_SYSTEM_VERSION = "0.3.
|
|
5
|
+
export const DESIGN_SYSTEM_VERSION = "0.3.7" as const;
|
|
6
6
|
|
|
7
7
|
export const THEME_NAMES = [
|
|
8
8
|
"light",
|
|
@@ -41,6 +41,8 @@ export const TOKENS: Readonly<Record<ThemeName, Readonly<Record<string, string>>
|
|
|
41
41
|
"node-ink": "#182140",
|
|
42
42
|
"edge": "#2a3048",
|
|
43
43
|
"edge-label": "#4f5671",
|
|
44
|
+
"info": "#2f5a87",
|
|
45
|
+
"info-soft": "#e2edf8",
|
|
44
46
|
"topic-teal": "#87f2f8",
|
|
45
47
|
"topic-teal-ring": "#00949c",
|
|
46
48
|
"topic-harbor": "#bcdbff",
|
|
@@ -114,6 +116,8 @@ export const TOKENS: Readonly<Record<ThemeName, Readonly<Record<string, string>>
|
|
|
114
116
|
"node-ink": "#182140",
|
|
115
117
|
"edge": "#c9cddc",
|
|
116
118
|
"edge-label": "#b3b8cc",
|
|
119
|
+
"info": "#7cc8f2",
|
|
120
|
+
"info-soft": "#13283a",
|
|
117
121
|
"topic-teal": "#87f2f8",
|
|
118
122
|
"topic-teal-ring": "#0fc5cd",
|
|
119
123
|
"topic-harbor": "#bcdbff",
|
|
@@ -187,6 +191,8 @@ export const TOKENS: Readonly<Record<ThemeName, Readonly<Record<string, string>>
|
|
|
187
191
|
"node-ink": "#182140",
|
|
188
192
|
"edge": "#5a6079",
|
|
189
193
|
"edge-label": "#5a6079",
|
|
194
|
+
"info": "#2f5a87",
|
|
195
|
+
"info-soft": "#e2edf8",
|
|
190
196
|
"topic-teal": "#bce8ea",
|
|
191
197
|
"topic-teal-ring": "#2c9298",
|
|
192
198
|
"topic-harbor": "#c9d9ec",
|
|
@@ -260,6 +266,8 @@ export const TOKENS: Readonly<Record<ThemeName, Readonly<Record<string, string>>
|
|
|
260
266
|
"node-ink": "#182140",
|
|
261
267
|
"edge": "#a9aec0",
|
|
262
268
|
"edge-label": "#b3b8cc",
|
|
269
|
+
"info": "#7cc8f2",
|
|
270
|
+
"info-soft": "#13283a",
|
|
263
271
|
"topic-teal": "#bce8ea",
|
|
264
272
|
"topic-teal-ring": "#71bdc1",
|
|
265
273
|
"topic-harbor": "#c9d9ec",
|
|
@@ -333,6 +341,8 @@ export const TOKENS: Readonly<Record<ThemeName, Readonly<Record<string, string>>
|
|
|
333
341
|
"node-ink": "#182140",
|
|
334
342
|
"edge": "#2a3048",
|
|
335
343
|
"edge-label": "#4f5671",
|
|
344
|
+
"info": "#603376",
|
|
345
|
+
"info-soft": "#efe6f6",
|
|
336
346
|
"topic-teal": "#bbeec1",
|
|
337
347
|
"topic-teal-ring": "#389754",
|
|
338
348
|
"topic-harbor": "#9bc9ef",
|
|
@@ -406,6 +416,8 @@ export const TOKENS: Readonly<Record<ThemeName, Readonly<Record<string, string>>
|
|
|
406
416
|
"node-ink": "#182140",
|
|
407
417
|
"edge": "#c9cddc",
|
|
408
418
|
"edge-label": "#b3b8cc",
|
|
419
|
+
"info": "#daa4f6",
|
|
420
|
+
"info-soft": "#2a1c33",
|
|
409
421
|
"topic-teal": "#bbeec1",
|
|
410
422
|
"topic-teal-ring": "#69c27e",
|
|
411
423
|
"topic-harbor": "#9bc9ef",
|
|
@@ -479,6 +491,8 @@ export const TOKENS: Readonly<Record<ThemeName, Readonly<Record<string, string>>
|
|
|
479
491
|
"node-ink": "#000000",
|
|
480
492
|
"edge": "#000000",
|
|
481
493
|
"edge-label": "#1f2433",
|
|
494
|
+
"info": "#471f61",
|
|
495
|
+
"info-soft": "#ffffff",
|
|
482
496
|
"topic-teal": "#87f2f8",
|
|
483
497
|
"topic-teal-ring": "#006b70",
|
|
484
498
|
"topic-harbor": "#bcdbff",
|
|
@@ -552,6 +566,8 @@ export const TOKENS: Readonly<Record<ThemeName, Readonly<Record<string, string>>
|
|
|
552
566
|
"node-ink": "#000000",
|
|
553
567
|
"edge": "#ffffff",
|
|
554
568
|
"edge-label": "#e6e8f0",
|
|
569
|
+
"info": "#d5a5d6",
|
|
570
|
+
"info-soft": "#000000",
|
|
555
571
|
"topic-teal": "#87f2f8",
|
|
556
572
|
"topic-teal-ring": "#64eff7",
|
|
557
573
|
"topic-harbor": "#bcdbff",
|
|
@@ -41,20 +41,31 @@ export const GESTURE = {
|
|
|
41
41
|
/** Two fingers pinch to zoom the map's contents — ideas, connectors, containers and their labels — around the
|
|
42
42
|
* point between the fingers, within VIEW's limits. Controls, the depth trail, the peek, chat and the page never scale. */ pinchZoom: true,
|
|
43
43
|
/** Moving both fingers pans the contents. */ twoFingerPan: true,
|
|
44
|
+
/** One finger on the empty canvas pans the contents too, on every surface (VI-040). A host whose map sits inside a
|
|
45
|
+
* scrolling page can pass `gestures="cooperative"` to give one finger back to the page (two fingers then move the map). */ oneFingerPan: true,
|
|
44
46
|
/** The pointers that pinch (PointerEvent.pointerType). */ pointers: ['touch'] as readonly string[],
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
panPointers: ['mouse', 'pen'] as readonly string[], panSlop: 6,
|
|
47
|
+
/** The map takes every touch gesture (touch-action: none), so the browser never zooms or scrolls under it. With
|
|
48
|
+
* `gestures="cooperative"` one finger scrolls the page (touch-action: pan-x pan-y); two fingers move the map. */ appTouchAction: 'none', embeddedTouchAction: 'pan-x pan-y',
|
|
49
|
+
/** Press and move on the empty canvas to pan the contents - mouse, pen and one finger. A press that moves less than
|
|
50
|
+
* `panSlop` px is a click or a tap. */ dragPan: true,
|
|
51
|
+
panPointers: ['mouse', 'pen', 'touch'] as readonly string[], panSlop: 6,
|
|
51
52
|
/** Moving an idea starts once the press has moved this far (px), by pointerModeFor: a mouse ('hover') sooner, a finger
|
|
52
53
|
* or pen ('touch') later, so taps still work. */
|
|
53
54
|
ideaDragSlop: { hover: 4, touch: 10 },
|
|
54
|
-
/** Zoom never navigates: stepping inside and backing out stay explicit (tap an idea / Step inside, the depth trail,
|
|
55
|
-
* Escape or Backspace). */ zoomNavigates: false,
|
|
56
55
|
} as const;
|
|
57
56
|
|
|
57
|
+
/** Going back a layer without the trail (VI-040): double-click empty canvas (not while editing - there it adds an idea)
|
|
58
|
+
* or double-tap it. Never on an idea, a card, the trail or a control. At the top layer the
|
|
59
|
+
* map gives a small bump instead. A double-tap whose first tap closed a peek doesn't also go back. */
|
|
60
|
+
export const BACK = {
|
|
61
|
+
/** Two taps this close in time (ms) and place (px) are a double-tap. */ doubleTapMs: 300, doubleTapPx: 32,
|
|
62
|
+
/** The bump at the top layer (ms). */ bumpMs: 320,
|
|
63
|
+
} as const;
|
|
64
|
+
|
|
65
|
+
/** How the map changed layer, reported with onLayerPathChange so a host can keep browser history in step:
|
|
66
|
+
* 'step-in' (an idea's rings or Step inside), 'trail', 'gesture' (double-click, double-tap), 'key' (Escape, Backspace), 'host' (the host set layerPath). */
|
|
67
|
+
export type LayerVia = 'step-in' | 'trail' | 'gesture' | 'key' | 'host';
|
|
68
|
+
|
|
58
69
|
/** The zoom after a pinch: the zoom at the start, scaled by how far the fingers spread, within VIEW's limits. */
|
|
59
70
|
export function pinchZoom(startZoom: number, startDistance: number, distance: number): number {
|
|
60
71
|
const z = startZoom * (distance / Math.max(startDistance, 1));
|
package/src/index.ts
CHANGED
|
@@ -23,11 +23,11 @@ export type { Bezier } from './generated/geometry/motion.js';
|
|
|
23
23
|
// ideas, connectors and other names), verbatim from the design system's geometry/container.ts.
|
|
24
24
|
export { HULL, HULL_CLEAR, containerHull, labelCandidates, placeContainerLabel, connectorSamples } from './generated/geometry/container.js';
|
|
25
25
|
export type { Hull, Box as LabelBox, LabelPlacement, LabelSide, Pt } from './generated/geometry/container.js';
|
|
26
|
-
// How terms, the peek, the touch sheet, zoom, fit
|
|
26
|
+
// How terms, the peek, the touch sheet, zoom, fit, the depth trail and going back a layer by gesture behave, and which colour an idea gets: the design
|
|
27
27
|
// system's geometry/interaction.ts and geometry/color.ts, verbatim. (Idea size and label growth, geometry/idea.ts, come
|
|
28
28
|
// through rendering/ideaSize.)
|
|
29
|
-
export { TERM, PEEK, SHEET, VIEW, GESTURE, FRAME, PEEK_PLACEMENT, TRAIL, pointerModeFor, hoverOpensTerm, pinchZoom, zoomAround, layerBounds, fitView, fitViewInset, FIT_ROOM, peekPosition } from './generated/geometry/interaction.js';
|
|
30
|
-
export type { FrameBox, FrameInsets } from './generated/geometry/interaction.js';
|
|
29
|
+
export { TERM, PEEK, SHEET, VIEW, GESTURE, BACK, FRAME, PEEK_PLACEMENT, TRAIL, pointerModeFor, hoverOpensTerm, pinchZoom, zoomAround, layerBounds, fitView, fitViewInset, FIT_ROOM, peekPosition } from './generated/geometry/interaction.js';
|
|
30
|
+
export type { FrameBox, FrameInsets, LayerVia } from './generated/geometry/interaction.js';
|
|
31
31
|
// Level of detail: what an idea draws at the size it's seen, and when shadows are skipped (geometry/detail.ts, verbatim).
|
|
32
32
|
export { DETAIL, ideaDetail, shadowsShown } from './generated/geometry/detail.js';
|
|
33
33
|
export type { IdeaDetail } from './generated/geometry/detail.js';
|
|
@@ -264,11 +264,16 @@ export function convertVisualliToFlatNodes(doc: VisualliDocument, opts: ConvertO
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
// Build children index
|
|
267
|
+
// Build children index in linear time O(N)
|
|
268
268
|
for (const node of map.values()) {
|
|
269
269
|
node.childrenIds = [];
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
}
|
|
271
|
+
for (const node of map.values()) {
|
|
272
|
+
if (node.parentId) {
|
|
273
|
+
const parent = map.get(node.parentId);
|
|
274
|
+
if (parent) {
|
|
275
|
+
(parent.childrenIds ??= []).push(node.id);
|
|
276
|
+
}
|
|
272
277
|
}
|
|
273
278
|
}
|
|
274
279
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parser/visualliParser.ts","../src/parser/visualliConverter.ts","../src/parser/mindmapUtils.ts","../src/parser/configUtils.ts"],"sourcesContent":["// ─── .visualli File Parser ────────────────────────────────────────────────────\n//\n// Reads JSONL (JSON Lines) format and parses into a structured VisualliDocument.\n\nimport type { VisualliDocument, SemanticAnchor } from '../types/document.js';\nimport type { VisualliMeta } from '../types/meta.js';\nimport type { VisualliLayer } from '../types/layer.js';\nimport type { Layer } from '../types/schema.js';\n\n/**\n * Convert schema Layer to VisualliLayer by ensuring required arrays exist.\n */\nfunction toVisualliLayer(schemaLayer: Layer): VisualliLayer {\n return {\n type: 'layer',\n id: schemaLayer.id,\n level: schemaLayer.level,\n parentLayerId: schemaLayer.parentLayerId,\n parentNodeId: schemaLayer.parentNodeId,\n layout: schemaLayer.layout,\n nodes: schemaLayer.nodes ?? [],\n connections: schemaLayer.connections ?? [],\n containers: schemaLayer.containers ?? [],\n };\n}\n\nexport class VisualliParseError extends Error {\n constructor(message: string, public readonly lineNumber?: number) {\n super(message);\n this.name = 'VisualliParseError';\n }\n}\n\n/**\n * Parse a .visualli file content (JSONL format) into a VisualliDocument.\n *\n * @throws VisualliParseError on malformed input\n */\nexport function parseVisualliFile(content: string): VisualliDocument {\n const lines = content.trim().split('\\n');\n\n const doc: VisualliDocument = {\n meta: null as unknown as VisualliMeta,\n layers: new Map(),\n layersByLevel: new Map(),\n rootLayer: null,\n };\n\n let lineNumber = 0;\n\n for (const line of lines) {\n lineNumber++;\n if (!line.trim()) continue;\n\n let obj: Record<string, unknown>;\n try {\n obj = JSON.parse(line) as Record<string, unknown>;\n } catch (err) {\n throw new VisualliParseError(\n `Failed to parse JSON at line ${lineNumber}: ${err}`,\n lineNumber,\n );\n }\n\n if (!obj['type']) {\n throw new VisualliParseError(\n `Missing 'type' field at line ${lineNumber}`,\n lineNumber,\n );\n }\n\n switch (obj['type']) {\n case 'meta':\n doc.meta = obj as unknown as VisualliMeta;\n break;\n\n case 'layer': {\n // Convert schema Layer to VisualliLayer\n const schemaLayer = obj as unknown as Layer;\n const layer = toVisualliLayer(schemaLayer);\n \n doc.layers.set(layer.id, layer);\n\n if (!doc.layersByLevel.has(layer.level)) {\n doc.layersByLevel.set(layer.level, []);\n }\n doc.layersByLevel.get(layer.level)!.push(layer);\n\n if (layer.level === 0) {\n doc.rootLayer = layer;\n }\n break;\n }\n\n case 'extension': {\n const id = obj['id'];\n if (typeof id === 'string') {\n (doc.extensions ??= {})[id] = Array.isArray(obj['data']) ? (obj['data'] as unknown[]) : [];\n }\n break;\n }\n\n default:\n // Unknown type — silently skip\n break;\n }\n }\n\n if (!doc.meta) throw new VisualliParseError('Missing required meta section');\n if (!doc.rootLayer) throw new VisualliParseError('Missing root layer (level 0)');\n\n return doc;\n}\n\nexport async function fetchAndParseVisualli(url: string): Promise<VisualliDocument> {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n }\n return parseVisualliFile(await response.text());\n}\n\n/**\n * Parse .visualli JSONL data as returned from the MongoDB `visualli` field.\n *\n * @throws VisualliParseError\n */\nexport function parseVisualliFromMongoDB(visualliJsonl: string): VisualliDocument {\n if (!visualliJsonl || typeof visualliJsonl !== 'string') {\n throw new VisualliParseError('Invalid visualli data: expected a JSONL string');\n }\n const trimmed = visualliJsonl.trim();\n if (!trimmed) throw new VisualliParseError('Empty visualli data from MongoDB');\n return parseVisualliFile(trimmed);\n}\n\n/**\n * Parse a .visualli file from a browser `File` object.\n * (Browser-only – requires `FileReader`.)\n */\nexport function loadVisualliFileFromFile(file: File): Promise<VisualliDocument> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = e => {\n try {\n resolve(parseVisualliFile(e.target?.result as string));\n } catch (err) {\n reject(err);\n }\n };\n reader.onerror = () => reject(new Error('Failed to read file'));\n reader.readAsText(file);\n });\n}\n\n// ── Tree Helpers ──────────────────────────────────────────────────────────────\n\n/** Return all layers whose `parentNodeId` matches the given node ID. */\n/** Terms defined by the document's `semantic-anchors` extension (empty when absent). */\nexport function getSemanticAnchors(doc: VisualliDocument): SemanticAnchor[] {\n const raw = doc.extensions?.['semantic-anchors'];\n if (!Array.isArray(raw)) return [];\n return raw.filter((a): a is SemanticAnchor => !!a && typeof (a as SemanticAnchor).word === 'string' && typeof (a as SemanticAnchor).description === 'string');\n}\n\nexport function getChildLayers(\n doc: VisualliDocument,\n nodeId: string,\n): VisualliLayer[] {\n const result: VisualliLayer[] = [];\n for (const layer of doc.layers.values()) {\n if (layer.parentNodeId === nodeId) result.push(layer);\n }\n return result;\n}\n\n/**\n * Count the maximum depth of layers beneath a node (its \"magnitude\").\n * Returns 0 when the node has no child layers.\n */\nexport function countLayersBeneath(\n doc: VisualliDocument,\n nodeId: string,\n visited = new Set<string>(),\n): number {\n if (visited.has(nodeId)) return 0;\n visited.add(nodeId);\n\n const children = getChildLayers(doc, nodeId);\n if (children.length === 0) return 0;\n\n let maxDepth = 0;\n for (const layer of children) {\n let depth = 1;\n for (const node of layer.nodes) {\n depth = Math.max(depth, 1 + countLayersBeneath(doc, node.id, visited));\n }\n maxDepth = Math.max(maxDepth, depth);\n }\n return maxDepth;\n}\n","// ─── .visualli → FlatNode Converter ──────────────────────────────────────────\n//\n// Transforms the layer-based .visualli format into the flat Map<id, FlatNode>\n// structure consumed by the canvas renderer.\n\nimport type { VisualliDocument } from '../types/document.js';\nimport type { VisualliLayer } from '../types/layer.js';\nimport type { FlatNode, NodeMap } from '../types/mindmap.js';\nimport { countLayersBeneath } from './visualliParser.js';\nimport { ideaColor } from '../theme/index.js';\nimport { approximateMeasure, ideaKindOf, ideaSize, type IdeaMeasure } from '../rendering/ideaSize.js';\nimport { blobProfile, shapeOfLevel } from '../rendering/nodeGeometry.js';\nimport { applyCircularLayout, calculateOptimalRadiusPercentage } from '../layout/circularLayout.js';\nimport { applyLinearHorizontalLayout, applyLinearVerticalLayout } from '../layout/linearLayout.js';\n\n// ── Overlap Resolution ────────────────────────────────────────────────────────\n\nfunction doNodesOverlap(n1: FlatNode, n2: FlatNode, padding = 20): boolean {\n return !(\n n1.x + n1.width / 2 + padding < n2.x - n2.width / 2 - padding ||\n n1.x - n1.width / 2 - padding > n2.x + n2.width / 2 + padding ||\n n1.y + n1.height / 2 + padding < n2.y - n2.height / 2 - padding ||\n n1.y - n1.height / 2 - padding > n2.y + n2.height / 2 + padding\n );\n}\n\n/** Iteratively push overlapping nodes apart using symmetric force separation. */\nexport function resolveNodeOverlaps(nodes: FlatNode[], maxIterations = 10): void {\n const padding = 150;\n\n for (let iter = 0; iter < maxIterations; iter++) {\n let any = false;\n for (let i = 0; i < nodes.length; i++) {\n for (let j = i + 1; j < nodes.length; j++) {\n const n1 = nodes[i];\n const n2 = nodes[j];\n if (!doNodesOverlap(n1, n2, padding)) continue;\n\n any = true;\n const dx = n2.x - n1.x;\n const dy = n2.y - n1.y;\n const dist = Math.sqrt(dx * dx + dy * dy);\n\n if (dist < 1) {\n n2.x += n2.width / 2 + padding;\n continue;\n }\n\n const minDist = (n1.width + n2.width) / 2 + padding;\n if (dist < minDist) {\n const push = (minDist - dist) / 2;\n n1.x -= (dx / dist) * push;\n n1.y -= (dy / dist) * push;\n n2.x += (dx / dist) * push;\n n2.y += (dy / dist) * push;\n }\n }\n }\n if (!any) break;\n }\n}\n\n// ── Options ───────────────────────────────────────────────────────────────────\n\nexport interface ConvertOptions {\n /** Measures label text in the idea face (the renderer's font engine); ideas are sized with the design system's\n * ideaSize. Defaults to an approximation (half an em per character) where no font engine exists. */\n measure?: IdeaMeasure;\n /** Label scale (comfort: larger text is 1.15); ideas grow to fit the larger label. */\n labelScale?: number;\n}\n\n/** Whether a layer's ideas carry their own positions: every idea has one, and (with more than one idea) they aren't\n * all on the same spot (a placeholder). Then the file's positions are used as they are. */\nfunction hasFilePositions(layer: VisualliLayer): boolean {\n const ps = layer.nodes.map((n) => n.position);\n if (!ps.length || !ps.every((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y))) return false;\n return ps.length === 1 || ps.some((p) => p!.x !== ps[0]!.x || p!.y !== ps[0]!.y);\n}\n\n// ── Container-formation Layout ────────────────────────────────────────────────\n\ninterface Proxy { id: string; x: number; y: number; width: number; height: number }\n\nfunction applyFormation(nodes: FlatNode[], formation: string): void {\n if (nodes.length === 0) return;\n if (nodes.length === 1) { nodes[0].x = 0; nodes[0].y = 0; return; }\n if (formation === 'linear-horizontal' || formation === 'linear') {\n applyLinearHorizontalLayout(nodes, { centerX: 0, centerY: 0 });\n } else if (formation === 'linear-vertical') {\n applyLinearVerticalLayout(nodes, { centerX: 0, centerY: 0 });\n } else {\n const r = Math.max(250, nodes.length * 70);\n const step = (2 * Math.PI) / nodes.length;\n for (let i = 0; i < nodes.length; i++) {\n nodes[i].x = r * Math.cos(i * step);\n nodes[i].y = r * Math.sin(i * step);\n }\n }\n}\n\nfunction containerBBox(nodes: FlatNode[], padding: number): { width: number; height: number } {\n let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;\n for (const n of nodes) {\n minX = Math.min(minX, n.x - n.width / 2);\n maxX = Math.max(maxX, n.x + n.width / 2);\n minY = Math.min(minY, n.y - n.height / 2);\n maxY = Math.max(maxY, n.y + n.height / 2);\n }\n return { width: maxX - minX + padding * 2, height: maxY - minY + padding * 2 };\n}\n\nfunction proxyLinearH(proxies: Proxy[], gap = 180): void {\n const total = proxies.reduce((s, p) => s + p.width, 0) + gap * (proxies.length - 1);\n let x = -total / 2;\n for (const p of proxies) { p.x = x + p.width / 2; p.y = 0; x += p.width + gap; }\n}\n\nfunction proxyLinearV(proxies: Proxy[], gap = 180): void {\n const total = proxies.reduce((s, p) => s + p.height, 0) + gap * (proxies.length - 1);\n let y = -total / 2;\n for (const p of proxies) { p.x = 0; p.y = y + p.height / 2; y += p.height + gap; }\n}\n\nfunction proxyRadial(proxies: Proxy[], radius = 500): void {\n if (proxies.length === 1) { proxies[0].x = 0; proxies[0].y = 0; return; }\n // Start at top (12 o'clock) for n>=3, horizontal for n=2 (matches circular layout)\n const startAngle = proxies.length === 2 ? 0 : -Math.PI / 2;\n const step = (2 * Math.PI) / proxies.length;\n for (let i = 0; i < proxies.length; i++) {\n const angle = startAngle + i * step;\n proxies[i].x = radius * Math.cos(angle);\n proxies[i].y = radius * Math.sin(angle);\n }\n}\n\n// ── Layer Conversion ──────────────────────────────────────────────────────────\n\nfunction makeFlatNode(\n node: VisualliLayer['nodes'][number],\n layer: VisualliLayer,\n doc: VisualliDocument,\n /** Position among the layer's ideas (file order): missing colours cycle the topics by it, and the first idea of the root radial layer is the root. */\n siblingIndex: number,\n opts: ConvertOptions,\n): FlatNode {\n const label = Array.isArray(node.data.label) ? (node.data.label as string[]).join(' ') : (node.data.label || 'Untitled');\n const branchCount = countLayersBeneath(doc, node.id);\n const kind = ideaKindOf(layer, siblingIndex);\n // Sized so the label wraps inside the idea's own blob (the design system's blobProfile).\n const size = ideaSize(kind, label, opts.measure ?? approximateMeasure, opts.labelScale ?? 1, blobProfile(shapeOfLevel(layer.level)));\n const { topic, custom } = ideaColor(node.data.color, siblingIndex);\n return {\n id: node.id,\n parentId: layer.parentNodeId ?? null,\n x: node.position?.x ?? 0,\n y: node.position?.y ?? 0,\n level: layer.level,\n title: label,\n description: node.data.summary || '',\n color: node.data.color ?? '',\n ...(topic ? { topic } : {}),\n ...(custom ? { custom } : {}),\n kind,\n width: size.width,\n height: size.height,\n isExpanded: branchCount > 0,\n branchCount,\n createdAt: new Date(),\n updatedAt: new Date(),\n };\n}\n\nfunction layoutLayerWithContainers(layer: VisualliLayer, flatNodes: FlatNode[]): void {\n const PADDING = 80;\n const byId = new Map(flatNodes.map((n: FlatNode) => [n.id, n]));\n const containerNodeIds = new Set<string>();\n const containerGroups = new Map<string, FlatNode[]>();\n\n for (const container of layer.containers) {\n const group = container.nodes.map((id: string) => byId.get(id)).filter((n: FlatNode | undefined): n is FlatNode => !!n);\n if (!group.length) continue;\n container.nodes.forEach((id: string) => containerNodeIds.add(id));\n const formation = ((container.data as unknown as Record<string, unknown> | undefined)?.['formation'] as string | undefined) ?? 'radial';\n applyFormation(group, formation);\n containerGroups.set(container.id, group);\n }\n\n const proxies: Proxy[] = [];\n for (const n of flatNodes) {\n if (!containerNodeIds.has(n.id)) proxies.push({ id: n.id, x: 0, y: 0, width: n.width, height: n.height });\n }\n for (const container of layer.containers) {\n const group = containerGroups.get(container.id);\n if (!group?.length) continue;\n const bbox = containerBBox(group, PADDING);\n proxies.push({ id: `__c__${container.id}`, x: 0, y: 0, width: bbox.width, height: bbox.height });\n }\n\n const layout = layer.layout || 'radial';\n if (layout === 'linear-horizontal') proxyLinearH(proxies, 180);\n else if (layout === 'linear-vertical') proxyLinearV(proxies, 180);\n else proxyRadial(proxies, 500);\n\n for (const proxy of proxies) {\n if (proxy.id.startsWith('__c__')) {\n const group = containerGroups.get(proxy.id.slice(5));\n group?.forEach(n => { n.x += proxy.x; n.y += proxy.y; });\n } else {\n const fn = byId.get(proxy.id);\n if (fn) { fn.x = proxy.x; fn.y = proxy.y; }\n }\n }\n}\n\nfunction layoutLayer(layer: VisualliLayer, flatNodes: FlatNode[]): void {\n const layout = layer.layout || 'radial';\n if (layout === 'linear-horizontal') {\n applyLinearHorizontalLayout(flatNodes, { centerX: 0, centerY: 0 });\n } else if (layout === 'linear-vertical') {\n applyLinearVerticalLayout(flatNodes, { centerX: 0, centerY: 0 });\n } else {\n const pct = calculateOptimalRadiusPercentage(flatNodes.length, 2000, 2000, 200, 30);\n applyCircularLayout(flatNodes, {\n radiusPercentage: pct,\n containerWidth: 2000,\n containerHeight: 2000,\n centerX: 0,\n centerY: 0,\n });\n }\n}\n\n/**\n * Convert a single layer to an array of FlatNode objects, each sized for its label\n * (the design system's idea.ts) and coloured by its colour rule (color.ts).\n * Positions: the file's own when its ideas carry them; otherwise the SDK lays the\n * layer out by `layer.layout` (default radial) and container formations.\n */\nexport function convertLayerToFlatNodes(\n layer: VisualliLayer,\n doc: VisualliDocument,\n opts: ConvertOptions = {},\n): FlatNode[] {\n const flatNodes = layer.nodes.map((node, i) => makeFlatNode(node, layer, doc, i, opts));\n if (flatNodes.length === 0 || hasFilePositions(layer)) return flatNodes;\n for (const n of flatNodes) { n.x = 0; n.y = 0; }\n if ((layer.containers ?? []).length > 0) layoutLayerWithContainers(layer, flatNodes);\n else layoutLayer(layer, flatNodes);\n resolveNodeOverlaps(flatNodes);\n return flatNodes;\n}\n\n/**\n * Convert an entire .visualli document to a flat NodeMap.\n * All layers are converted and a children-index is built for O(1) tree traversal.\n */\nexport function convertVisualliToFlatNodes(doc: VisualliDocument, opts: ConvertOptions = {}): NodeMap {\n const map: NodeMap = new Map();\n\n for (const layer of doc.layers.values()) {\n for (const node of convertLayerToFlatNodes(layer, doc, opts)) {\n map.set(node.id, node);\n }\n }\n\n // Build children index\n for (const node of map.values()) {\n node.childrenIds = [];\n for (const candidate of map.values()) {\n if (candidate.parentId === node.id) node.childrenIds.push(candidate.id);\n }\n }\n\n return map;\n}\n\n/**\n * Get flat nodes for a specific layer only.\n *\n * @param doc - Parsed .visualli document\n * @param layerId - Layer ID to extract\n * @param opts - Text measurement and label scale for sizing ideas\n * @returns FlatNode array, or empty array if layer not found\n */\nexport function getNodesForLayer(doc: VisualliDocument, layerId: string, opts: ConvertOptions = {}): FlatNode[] {\n const layer = doc.layers.get(layerId);\n return layer ? convertLayerToFlatNodes(layer, doc, opts) : [];\n}\n","// ─── Mindmap Tree Utilities ───────────────────────────────────────────────────\n\nimport type { MindMapNode, TopLevelConnection } from '../types/mindmap.js';\n\n/** Flatten a nested MindMapNode tree into a depth-first array. */\nexport function flattenNodes(nodes: MindMapNode[]): MindMapNode[] {\n const result: MindMapNode[] = [];\n const traverse = (list: MindMapNode[]) => {\n for (const n of list) {\n result.push(n);\n if (n.children) traverse(n.children);\n }\n };\n traverse(nodes);\n return result;\n}\n\n/**\n * Return nodes visible at the given zoom level.\n *\n * At lower zoom values only top-level nodes are shown; each 5% zoom increment\n * reveals one additional hierarchy level.\n */\nexport function getVisibleNodes(\n nodes: MindMapNode[],\n zoom: number,\n focusedNode?: string,\n): MindMapNode[] {\n const flat = flattenNodes(nodes);\n\n if (focusedNode) {\n const focused = flat.find(n => n.id === focusedNode);\n if (focused) {\n return focused.children ? [focused, ...focused.children] : [focused];\n }\n }\n\n // Map zoom to max visible level (level 0 at ≤70%, +1 level per 5% increment)\n if (zoom <= 0.70) return flat.filter(n => n.level === 0);\n const maxLevel = Math.floor((zoom - 0.70) / 0.05);\n return flat.filter(n => n.level <= maxLevel);\n}\n\n/** Build parent→child connection pairs from the node tree. */\nexport function getNodeConnections(\n nodes: MindMapNode[],\n): Array<{ from: MindMapNode; to: MindMapNode; label?: string }> {\n const flat = flattenNodes(nodes);\n const result: Array<{ from: MindMapNode; to: MindMapNode; label?: string }> = [];\n for (const n of flat) {\n if (!n.parent) continue;\n const parent = flat.find(p => p.id === n.parent);\n if (parent) result.push({ from: parent, to: n, label: n.relationshipLabel });\n }\n return result;\n}\n\n/** Resolve top-level cross-connections to node pairs. */\nexport function getTopLevelConnections(\n nodes: MindMapNode[],\n topLevelConnections: TopLevelConnection[],\n): Array<{ from: MindMapNode; to: MindMapNode; label: string }> {\n const flat = flattenNodes(nodes);\n const result: Array<{ from: MindMapNode; to: MindMapNode; label: string }> = [];\n for (const conn of topLevelConnections) {\n const from = flat.find(n => n.id === conn.from);\n const to = flat.find(n => n.id === conn.to);\n if (from && to) result.push({ from, to, label: conn.label ?? '' });\n }\n return result;\n}\n\n/** Euclidean distance between two world-space points. */\nexport function calculateDistance(x1: number, y1: number, x2: number, y2: number): number {\n return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);\n}\n","// ─── MindMapConfig Utilities ──────────────────────────────────────────────────\n//\n// Helpers for creating and generating MindMapConfig objects (pure data, no UI).\n\nimport type { MindMapNode, MindMapConfig, TopLevelConnection } from '../types/mindmap.js';\nimport { LAYOUT_SPACING } from '../constants/layout.js';\nimport { TOKENS, TOPICS } from '../theme/index.js';\n\n/** Light-theme fill of the topic used for a level (cycles through the design-system topics). */\nconst levelColor = (level: number): string => TOKENS.light[`topic-${TOPICS[level % TOPICS.length]}`]!;\n\ntype LevelColors = { level0: string; level1: string; level2: string; level3: string; [key: `level${number}`]: string };\nconst levelColors = (count: number): LevelColors =>\n Object.fromEntries(Array.from({ length: count }, (_, i) => [`level${i}`, levelColor(i)])) as LevelColors;\n\nexport function createMindMapConfig(\n nodes: MindMapNode[],\n topLevelConnections: TopLevelConnection[],\n title = 'Untitled Mindmap',\n): MindMapConfig {\n const now = new Date().toISOString();\n return {\n metadata: {\n title,\n description: `Interactive mindmap with ${nodes.length} nodes`,\n version: '1.0.0',\n created: now,\n lastModified: now,\n },\n nodes,\n topLevelConnections,\n settings: {\n defaultColors: levelColors(4),\n layout: {\n nodeSpacing: LAYOUT_SPACING.nodeSpacing,\n levelSpacing: LAYOUT_SPACING.levelSpacing,\n },\n },\n };\n}\n\n// ── Sample Data Generator ─────────────────────────────────────────────────────\n\nfunction generateId(prefix: string, level: number, index: number): string {\n return `${prefix}-l${level}-${index}`;\n}\n\nfunction generateLevelNodes(\n parentId: string | null,\n level: number,\n maxLevels: number,\n xOffset = 0,\n yOffset = 0,\n): MindMapNode[] {\n if (level >= maxLevels) return [];\n\n const count = 5;\n const levelSpacing = 200;\n const nodeSpacing = 300;\n const nodes: MindMapNode[] = [];\n\n for (let i = 0; i < count; i++) {\n const nodeId = parentId\n ? generateId(`${parentId}-${i}`, level, i)\n : generateId('root', level, i);\n\n const x = xOffset + (i - (count - 1) / 2) * nodeSpacing;\n const y = yOffset + level * levelSpacing;\n\n const node: MindMapNode = {\n id: nodeId,\n title: `Level ${level} Node ${i + 1}`,\n level,\n x,\n y,\n color: levelColor(level),\n relationshipLabel: level > 0 ? 'child' : undefined,\n parent: parentId ?? undefined,\n };\n\n const children = generateLevelNodes(nodeId, level + 1, maxLevels, x, y + levelSpacing);\n if (children.length > 0) node.children = children;\n\n nodes.push(node);\n }\n\n return nodes;\n}\n\n/**\n * Generate a sample MindMapConfig with `maxLevels` of hierarchy.\n * Useful for testing and demos.\n */\nexport function generateSampleConfig(maxLevels = 9): MindMapConfig {\n const nodes = generateLevelNodes(null, 0, maxLevels, 0, 0);\n\n const topLevelConnections: TopLevelConnection[] = nodes.slice(0, -1).map((n, i) => ({\n from: n.id,\n to: nodes[i + 1].id,\n label: 'related to',\n }));\n\n return {\n metadata: {\n id: `mindmap-${Date.now()}`,\n title: 'Sample Mind Map',\n description: 'A sample mind map',\n version: '1.0.0',\n created: new Date().toISOString(),\n lastModified: new Date().toISOString(),\n },\n nodes,\n topLevelConnections,\n settings: {\n defaultColors: levelColors(9),\n layout: {\n nodeSpacing: LAYOUT_SPACING.nodeSpacing,\n levelSpacing: LAYOUT_SPACING.levelSpacing,\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAYA,SAAS,gBAAgB,aAAmC;AAC1D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI,YAAY;AAAA,IAChB,OAAO,YAAY;AAAA,IACnB,eAAe,YAAY;AAAA,IAC3B,cAAc,YAAY;AAAA,IAC1B,QAAQ,YAAY;AAAA,IACpB,OAAO,YAAY,SAAS,CAAC;AAAA,IAC7B,aAAa,YAAY,eAAe,CAAC;AAAA,IACzC,YAAY,YAAY,cAAc,CAAC;AAAA,EACzC;AACF;AAEO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EAC5C,YAAY,SAAiC,YAAqB;AAChE,UAAM,OAAO;AAD8B;AAE3C,SAAK,OAAO;AAAA,EACd;AACF;AAOO,SAAS,kBAAkB,SAAmC;AACnE,QAAM,QAAQ,QAAQ,KAAK,EAAE,MAAM,IAAI;AAEvC,QAAM,MAAwB;AAAA,IAC5B,MAAM;AAAA,IACN,QAAQ,oBAAI,IAAI;AAAA,IAChB,eAAe,oBAAI,IAAI;AAAA,IACvB,WAAW;AAAA,EACb;AAEA,MAAI,aAAa;AAEjB,aAAW,QAAQ,OAAO;AACxB;AACA,QAAI,CAAC,KAAK,KAAK,EAAG;AAElB,QAAI;AACJ,QAAI;AACF,YAAM,KAAK,MAAM,IAAI;AAAA,IACvB,SAAS,KAAK;AACZ,YAAM,IAAI;AAAA,QACR,gCAAgC,UAAU,KAAK,GAAG;AAAA,QAClD;AAAA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EAAE,EAAE,IAAI,CAAC,GAAG,OAAO;AAAA,IAClF,MAAM,EAAE;AAAA,IACR,IAAI,MAAM,IAAI,CAAC,EAAE;AAAA,IACjB,OAAO;AAAA,EACT,EAAE;AAEF,SAAO;AAAA,IACL,UAAU;AAAA,MACR,IAAI,WAAW,KAAK,IAAI,CAAC;AAAA,MACzB,OAAO;AAAA,MACP,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAS,oBAAI,KAAK,GAAE,YAAY;AAAA,MAChC,eAAc,oBAAI,KAAK,GAAE,YAAY;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,MACR,eAAe,YAAY,CAAC;AAAA,MAC5B,QAAQ;AAAA,QACN,aAAa,eAAe;AAAA,QAC5B,cAAc,eAAe;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generated/geometry/interaction.ts","../src/constants/performanceConstants.ts"],"sourcesContent":["// Generated from visualli.ai design-system/components/src/interaction.ts — do not edit here.\n/* How the canvas answers the pointer and the keyboard — the timing and rules behind the peek (an idea's summary)\n and terms (semantic anchors: an underlined word and its definition card). The look and the pop-in animation live\n in the CSS (.vi-fact, .vi-anchor, .vi-anchor-card); these are the behaviours, as data, so every renderer (VisualMap,\n the spec SDK on a canvas) opens and closes them alike. Times in ms. No dependencies, so it can travel alone. */\n\n/** Terms (semantic anchors) in a peek's text. */\nexport const TERM = {\n /** Hovering the term this long opens its definition card… */ hoverOpen: 250,\n /** …which closes this long after the pointer leaves both the term and the card (moving between them keeps it open). */ hoverClose: 300,\n /** Only a mouse opens on hover; touch and pen open on tap. */ hoverPointers: ['mouse'] as readonly string[],\n /** A click, tap, Enter or Space pins the card open (hovering away doesn't close it); pressing again unpins and closes. */ clickPins: true,\n /** Escape closes the card and returns focus to the term; a press anywhere outside the term and its card closes it. */ escapeCloses: true, pressOutsideCloses: true,\n /** Opening by click or keyboard moves focus to the card's first link or button. */ focusCardOnOpen: true,\n /** The card is kept this far inside the viewport's left and right edges. */ viewportMargin: 8,\n /** The card's link to a source about the term. */ learnMoreLabel: 'Learn more',\n} as const;\n\n/** The peek: an idea's summary card on hover (pointer) or tap (touch). */\nexport const PEEK = {\n /** Hovering an idea opens its peek at once; it stays this long after the pointer leaves the idea (and while the\n * pointer is over the peek itself), so the pointer can travel from the idea onto the card. */ hoverClose: 180,\n} as const;\n\n/** The touch peek: a bottom sheet with a grip. */\nexport const SHEET = {\n /** Dragging the grip down this far closes the sheet (or collapses it when expanded); up this far expands it. */ dismissDrag: 80, expandDrag: 40,\n /** Its height: this share of the map, at most `maxHeight` px; the map pans the chosen idea into the space above it. */ heightRatio: 0.42, maxHeight: 300,\n} as const;\n\n/** Zoom, pan and fit. */\nexport const VIEW = {\n /** Each zoom step multiplies or divides the zoom by this. */ zoomStep: 1.2,\n /** Zoom limits (the zoom-min / zoom-max tokens; the build checks they agree). */ zoomMin: 0.3, zoomMax: 5,\n /** Fit to view never enlarges a layer beyond this. */ fitMax: 1.1,\n} as const;\n\n/** Touch gestures on the map (any touch input — phones, tablets and touchscreen laptops alike; it follows the pointer\n * in use, not the device, so a mouse or trackpad on the same laptop isn't affected). */\nexport const GESTURE = {\n /** Two fingers pinch to zoom the map's contents — ideas, connectors, containers and their labels — around the\n * point between the fingers, within VIEW's limits. Controls, the depth trail, the peek, chat and the page never scale. */ pinchZoom: true,\n /** Moving both fingers pans the contents. */ twoFingerPan: true,\n /** The pointers that pinch (PointerEvent.pointerType). */ pointers: ['touch'] as readonly string[],\n /** Where the map is the page (an app: AppShell, the mobile app), it takes every touch gesture (touch-action: none),\n * so the browser never zooms the page. Embedded on a scrolling page (website, docs), one finger still scrolls the\n * page (touch-action: pan-x pan-y); two fingers that land together pinch the map. */ appTouchAction: 'none', embeddedTouchAction: 'pan-x pan-y',\n /** Press and move on the empty canvas to pan the contents (mouse and pen; touch pans with two fingers, so one finger\n * still scrolls an embedded page). A press that moves less than `panSlop` px is a click. */ dragPan: true,\n panPointers: ['mouse', 'pen'] as readonly string[], panSlop: 6,\n /** Moving an idea starts once the press has moved this far (px), by pointerModeFor: a mouse ('hover') sooner, a finger\n * or pen ('touch') later, so taps still work. */\n ideaDragSlop: { hover: 4, touch: 10 },\n /** Zoom never navigates: stepping inside and backing out stay explicit (tap an idea / Step inside, the depth trail,\n * Escape or Backspace). */ zoomNavigates: false,\n} as const;\n\n/** The zoom after a pinch: the zoom at the start, scaled by how far the fingers spread, within VIEW's limits. */\nexport function pinchZoom(startZoom: number, startDistance: number, distance: number): number {\n const z = startZoom * (distance / Math.max(startDistance, 1));\n return Math.min(VIEW.zoomMax, Math.max(VIEW.zoomMin, z));\n}\n\n/** Keeps the map point that was under `from` under `to` when the scale changes from `s0` to `s1`: the new\n * translation, given the old one (screen = world × s + t). Used to zoom around the fingers. */\nexport function zoomAround(t0: { x: number; y: number }, s0: number, s1: number, from: { x: number; y: number }, to: { x: number; y: number }): { x: number; y: number } {\n const wx = (from.x - t0.x) / s0, wy = (from.y - t0.y) / s0;\n return { x: to.x - wx * s1, y: to.y - wy * s1 };\n}\n\n/** Framing a layer (fit to view): its ideas with room around them, and its container hulls with room for the name pill. */\nexport const FRAME = {\n /** Room beyond each idea's outermost ring (RINGS[2].scale, 1.3 × its half size): its stroke, hover lift and a little air. */ ring: 0.3, clearX: 16, clearY: 16,\n /** Room beyond each container hull for its dashed line and the name pill straddling it. */ hullX: 24, hullY: 40,\n} as const;\nexport type FrameBox = { x0: number; y0: number; x1: number; y1: number };\n\n/** The box a layer is framed by: every idea (`rx` / `ry` its half size) and every container hull. */\nexport function layerBounds(ideas: ReadonlyArray<{ x: number; y: number; rx: number; ry: number }>, hulls: ReadonlyArray<FrameBox> = []): FrameBox {\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const n of ideas) {\n const px = n.rx * (1 + FRAME.ring) + FRAME.clearX, py = n.ry * (1 + FRAME.ring) + FRAME.clearY;\n x0 = Math.min(x0, n.x - px); x1 = Math.max(x1, n.x + px); y0 = Math.min(y0, n.y - py); y1 = Math.max(y1, n.y + py);\n }\n for (const h of hulls) { x0 = Math.min(x0, h.x0 - FRAME.hullX); x1 = Math.max(x1, h.x1 + FRAME.hullX); y0 = Math.min(y0, h.y0 - FRAME.hullY); y1 = Math.max(y1, h.y1 + FRAME.hullY); }\n if (!Number.isFinite(x0)) return { x0: -150, y0: -120, x1: 150, y1: 120 };\n return { x0, y0, x1, y1 };\n}\n\n/** Fit to view: the scale that shows `bounds` in an area of `width` × `height` (never beyond VIEW.fitMax), and the\n * world point to centre. */\nexport function fitView(bounds: FrameBox, width: number, height: number): { scale: number; center: { x: number; y: number } } {\n const scale = Math.min(width / Math.max(1, bounds.x1 - bounds.x0), height / Math.max(1, bounds.y1 - bounds.y0), VIEW.fitMax);\n return { scale, center: { x: (bounds.x0 + bounds.x1) / 2, y: (bounds.y0 + bounds.y1) / 2 } };\n}\n\n/** Insets: room the host's chrome takes at each edge of the map (a docked Vault, a top bar, the Composer). */\nexport type FrameInsets = { top?: number; right?: number; bottom?: number; left?: number };\n/** The smallest free area a map is ever fitted into, however much the insets take. */\nexport const FIT_ROOM = { minWidth: 200, minHeight: 160 } as const;\n\n/** Fit to view inside insets. The map's canvas fills its whole frame - so the canvas itself and its chromatic immersion\n * run behind the host's chrome (a docked Vault floats over the tinted canvas) - while the layer is fitted into the\n * free area (the frame less the insets, never below FIT_ROOM) and centred in it. `screen`: where on the canvas the\n * world `center` goes (screen = world × scale + translation); `room`: the free area's size. With no insets this is\n * fitView, centred on the canvas. */\nexport function fitViewInset(bounds: FrameBox, width: number, height: number, insets: FrameInsets = {}): { scale: number; center: { x: number; y: number }; screen: { x: number; y: number }; room: { width: number; height: number } } {\n const top = insets.top ?? 0, right = insets.right ?? 0, bottom = insets.bottom ?? 0, left = insets.left ?? 0;\n const w = Math.max(FIT_ROOM.minWidth, width - left - right), h = Math.max(FIT_ROOM.minHeight, height - top - bottom);\n const { scale, center } = fitView(bounds, w, h);\n return { scale, center, screen: { x: left + w / 2, y: top + h / 2 }, room: { width: w, height: h } };\n}\n\n/** Where the peek card sits (pointer): beside the idea — right of it if it fits, else left — and level with it. */\nexport const PEEK_PLACEMENT = {\n /** Gap between the idea's outermost ring and the card. */ gap: 16,\n /** The card's width and the height kept clear below it. */ cardWidth: 300, cardHeight: 220,\n /** The card is raised this much above the idea's centre. */ raise: 70,\n /** Kept this far inside the map's edges. */ margin: 12,\n} as const;\n\n/** The peek card's top-left, in map (screen) pixels. `idea`: the idea's centre on screen and its on-screen half\n * width with its outermost ring (`half`); `box`: the map's size. */\nexport function peekPosition(idea: { x: number; y: number; half: number }, box: { w: number; h: number }, card: { w: number; h: number } = { w: PEEK_PLACEMENT.cardWidth, h: PEEK_PLACEMENT.cardHeight }) {\n const P = PEEK_PLACEMENT, half = idea.half + P.gap;\n const right = idea.x + half + card.w < box.w - P.margin;\n return { left: right ? idea.x + half : Math.max(P.margin, idea.x - half - card.w), top: Math.min(Math.max(P.margin, idea.y - P.raise), box.h - card.h), side: right ? 'right' as const : 'left' as const };\n}\n\n/** The depth trail: each entry shows the idea that was stepped into — its title and a dot in its color (the same\n * topic or custom color the idea is drawn in, including the sibling-order topic of an uncolored idea). The first\n * entry is the map itself: a `stone` dot and the home glyph only (`rootLabel: 'icon'`) — no text, since a map's title\n * usually repeats its centre idea's, which the next entry shows; its accessible name and tooltip are the map's title.\n * The dot is the idea shape (shapeForLevel). */\nexport const TRAIL = { rootTopic: 'stone', rootLabel: 'icon', homeIconSize: 12, dotBox: 16, dotRadius: 6.4, stroke: 1.25, currentStroke: 1.75 } as const;\n\n/** How an input answers: a mouse hovers (peeks and terms open on hover); touch and pen tap. Null for unknown pointers. */\nexport function pointerModeFor(pointerType: string): 'hover' | 'touch' | null {\n return pointerType === 'mouse' ? 'hover' : pointerType === 'touch' || pointerType === 'pen' ? 'touch' : null;\n}\n\n/** Whether a pointer of this type opens a term on hover (PointerEvent.pointerType). */\nexport function hoverOpensTerm(pointerType: string): boolean {\n return TERM.hoverPointers.includes(pointerType);\n}\n","// ─── Performance & Rendering Constants ───────────────────────────────────────\n//\n// Performance budgets and interaction thresholds. Visual values (colours,\n// stroke widths, node size, zoom range) come from the design system tokens.\n\nimport { VIEW } from '../generated/geometry/interaction.js';\n\n// ── FPS ───────────────────────────────────────────────────────────────────────\n\nexport const FPS_TARGET = 60;\nexport const FPS_WARNING_THRESHOLD = 45;\nexport const FPS_CRITICAL_THRESHOLD = 30;\nexport const TARGET_FRAME_TIME = 1000 / FPS_TARGET; // ~16.67 ms\nexport const MAX_FRAME_TIME = 18; // p95 threshold\n\n/** Legacy frame-rate targets kept for backward compatibility. */\nexport const FPS_TARGETS = {\n PAN_MIN: 30,\n ZOOM_TARGET: 60,\n WARNING_THRESHOLD: 20,\n} as const;\n\n// ── Timing Thresholds (ms) ────────────────────────────────────────────────────\n\nexport const TIMING_THRESHOLDS = {\n VIEWPORT_QUERY_MAX: 5,\n SPATIAL_UPDATE_MAX: 10,\n DRAG_RESPONSE_MAX: 16,\n LOAD_5K_TARGET: 2000,\n LOAD_10K_TARGET: 3000,\n VIEWPORT_DEBOUNCE: 100,\n SPATIAL_INDEX_BUILD: 50,\n} as const;\n\n// ── Memory Limits (MB) ────────────────────────────────────────────────────────\n\nexport const MEMORY_TARGET_MB = 500;\nexport const MEMORY_WARNING_MB = 600;\nexport const MEMORY_CRITICAL_MB = 800;\n\nexport const MEMORY_LIMITS = {\n MAX_10K_NODES: 500,\n MAX_GROWTH_PERCENT: 20,\n WARNING_THRESHOLD: 400,\n} as const;\n\n// ── Viewport Culling ──────────────────────────────────────────────────────────\n\nexport const VIEWPORT_MARGIN = 0.1;\nexport const MAX_VISIBLE_NODES = 800;\nexport const CULLING_QUERY_TIME_BUDGET = 5;\n\n// ── Spatial Index ─────────────────────────────────────────────────────────────\n\nexport const RBUSH_MAX_ENTRIES = 16;\nexport const SPATIAL_INDEX_BUILD_BUDGET = 50;\n\n// ── Zoom Constraints ──────────────────────────────────────────────────────────\n\n// Zoom limits: the design system's VIEW (geometry/interaction.ts; equal to the zoom-min / zoom-max tokens).\nexport const ZOOM_MIN = VIEW.zoomMin;\nexport const ZOOM_MAX = VIEW.zoomMax;\nexport const ZOOM_DEFAULT = 1.0;\n\n// ── Quality Level Presets ─────────────────────────────────────────────────────\n\nexport const QUALITY_HIGH = {\n shadows: true,\n bezierCurves: true,\n animations: true,\n textQuality: 'high' as const,\n antialiasing: true,\n};\n\nexport const QUALITY_MEDIUM = {\n shadows: false,\n bezierCurves: true,\n animations: true,\n textQuality: 'medium' as const,\n antialiasing: true,\n};\n\nexport const QUALITY_LOW = {\n shadows: false,\n bezierCurves: false,\n animations: false,\n textQuality: 'low' as const,\n antialiasing: false,\n};\n\n// ── Performance Monitoring ────────────────────────────────────────────────────\n\nexport const FPS_SAMPLE_WINDOW = 60;\nexport const FPS_UPDATE_INTERVAL = 1000;\nexport const MEMORY_CHECK_INTERVAL = 5000;\nexport const PERFORMANCE_TOAST_COOLDOWN = 10000;\n\n// ── Auto-Adjustment ───────────────────────────────────────────────────────────\n\nexport const FPS_DOWNGRADE_THRESHOLD = 45;\nexport const FPS_UPGRADE_THRESHOLD = 58;\nexport const FPS_STABILIZATION_FRAMES = 180;\n\n// ── Canvas Dimensions ─────────────────────────────────────────────────────────\n\nexport const DEFAULT_CANVAS_WIDTH = 1920;\nexport const DEFAULT_CANVAS_HEIGHT = 1080;\n\n// ── Interaction ───────────────────────────────────────────────────────────────\n\nexport const CLICK_THRESHOLD = 5;\nexport const DOUBLE_CLICK_DELAY = 300;\nexport const DRAG_START_DISTANCE = 10;\n\n// ── Data Validation ───────────────────────────────────────────────────────────\n\nexport const MAX_NODES = 20000;\nexport const CIRCULAR_REFERENCE_MAX_DEPTH = 1000;\n\n// ── Debounce / Throttle ───────────────────────────────────────────────────────\n\nexport const RESIZE_DEBOUNCE = 300;\nexport const SCROLL_THROTTLE = 16;\nexport const SEARCH_DEBOUNCE = 500;\n\n/** Node count thresholds that gate optimisation strategies. */\nexport const NODE_COUNT_THRESHOLDS = {\n SPATIAL_INDEX_MIN: 100,\n VIEWPORT_CULLING_MIN: 500,\n CANVAS_RENDERING_MIN: 2000,\n DOM_RENDERING_MAX: 5000,\n} as const;\n\n/** Viewport buffer configuration. */\nexport const VIEWPORT_CONFIG = {\n BUFFER_PERCENT: 0.2,\n MIN_VISIBLE_NODES: 10,\n} as const;\n"],"mappings":";AAOO,IAAM,OAAO;AAAA;AAAA,EAC4C,WAAW;AAAA;AAAA,EAC+C,YAAY;AAAA;AAAA,EACrE,eAAe,CAAC,OAAO;AAAA;AAAA,EACqC,WAAW;AAAA;AAAA,EACf,cAAc;AAAA,EAAM,oBAAoB;AAAA;AAAA,EAC3E,iBAAiB;AAAA;AAAA,EACxB,gBAAgB;AAAA;AAAA,EAC1C,gBAAgB;AACrE;AAGO,IAAM,OAAO;AAAA;AAAA;AAAA,EAE8E,YAAY;AAC9G;AAGO,IAAM,QAAQ;AAAA;AAAA,EAC8F,aAAa;AAAA,EAAI,YAAY;AAAA;AAAA,EACtB,aAAa;AAAA,EAAM,WAAW;AACxJ;AAGO,IAAM,OAAO;AAAA;AAAA,EAC4C,UAAU;AAAA;AAAA,EACU,SAAS;AAAA,EAAK,SAAS;AAAA;AAAA,EAClD,QAAQ;AACjE;AAIO,IAAM,UAAU;AAAA;AAAA;AAAA,EAEuG,WAAW;AAAA;AAAA,EACzF,cAAc;AAAA;AAAA,EACD,UAAU,CAAC,OAAO;AAAA;AAAA;AAAA;AAAA,EAGU,gBAAgB;AAAA,EAAQ,qBAAqB;AAAA;AAAA;AAAA,EAEtC,SAAS;AAAA,EACvG,aAAa,CAAC,SAAS,KAAK;AAAA,EAAwB,SAAS;AAAA;AAAA;AAAA,EAG7D,cAAc,EAAE,OAAO,GAAG,OAAO,GAAG;AAAA;AAAA;AAAA,EAEP,eAAe;AAC9C;AAGO,SAAS,UAAU,WAAmB,eAAuB,UAA0B;AAC5F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