@visualli/core 0.2.15 → 0.2.17
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-4R5LZUVK.js → chunk-2JCBDPOL.js} +2 -2
- package/dist/{chunk-COKCN5NW.js → chunk-3RLUS5K7.js} +15 -5
- package/dist/chunk-3RLUS5K7.js.map +1 -0
- package/dist/{chunk-EASI6BW7.js → chunk-3UZU4SK5.js} +17 -3
- package/dist/chunk-3UZU4SK5.js.map +1 -0
- package/dist/{chunk-URWZU4I5.js → chunk-6GAKZATW.js} +2 -2
- package/dist/{chunk-RDHSLWMU.js → chunk-6LHBNFP4.js} +2 -1
- package/dist/{chunk-RDHSLWMU.js.map → chunk-6LHBNFP4.js.map} +1 -1
- package/dist/{chunk-C5IC52GJ.js → chunk-EGXQEULM.js} +4 -4
- package/dist/{chunk-OOTXA4BA.js → chunk-T3SFVKHY.js} +2 -2
- package/dist/{chunk-KP57ODE7.js → chunk-YU3KV4UY.js} +2 -2
- package/dist/config/index.cjs +15 -1
- 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 +2 -2
- package/dist/{designSystem-D-iI9c23.d.cts → designSystem-D1TEwtFB.d.cts} +1 -0
- package/dist/{designSystem-D-iI9c23.d.ts → designSystem-D1TEwtFB.d.ts} +1 -0
- package/dist/{ideaSize-Dj7qGmuk.d.cts → ideaSize-BNzONHMD.d.cts} +1 -1
- package/dist/{ideaSize-BD-vUcOU.d.ts → ideaSize-D3bwx7nU.d.ts} +1 -1
- package/dist/{index-uqNXf5yF.d.cts → index-CpNpxxTi.d.cts} +1 -1
- package/dist/{index-Bi8djF7z.d.ts → index-b1eML2o2.d.ts} +1 -1
- package/dist/index.cjs +85 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -23
- package/dist/index.d.ts +80 -23
- package/dist/index.js +60 -11
- 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-BbQrM6Pm.d.cts → mindmap-BkGXWW3M.d.cts} +1 -1
- package/dist/{mindmap-BU-aLrAR.d.ts → mindmap-GAjdtx5S.d.ts} +1 -1
- package/dist/parser/index.cjs +15 -1
- 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 +1 -0
- 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 +1 -0
- package/src/generated/geometry/container.ts +51 -2
- package/src/generated/geometry/idea.ts +12 -1
- package/src/generated/geometry/interaction.ts +29 -4
- package/src/index.ts +3 -3
- package/src/utils/navigation.ts +13 -8
- package/dist/chunk-COKCN5NW.js.map +0 -1
- package/dist/chunk-EASI6BW7.js.map +0 -1
- /package/dist/{chunk-4R5LZUVK.js.map → chunk-2JCBDPOL.js.map} +0 -0
- /package/dist/{chunk-URWZU4I5.js.map → chunk-6GAKZATW.js.map} +0 -0
- /package/dist/{chunk-C5IC52GJ.js.map → chunk-EGXQEULM.js.map} +0 -0
- /package/dist/{chunk-OOTXA4BA.js.map → chunk-T3SFVKHY.js.map} +0 -0
- /package/dist/{chunk-KP57ODE7.js.map → chunk-YU3KV4UY.js.map} +0 -0
|
@@ -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 /** 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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Y;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/** The zoom buttons (− % +) are for screens with a mouse or trackpad. On a touch-only screen (a phone, a tablet\n * without a trackpad) people pinch to zoom, so the buttons stay out of the way: the spec CSS hides `.vi-map__ctrls`\n * under `@media not all and (hover: hover) and (pointer: fine)`, and the design system's VisualMap reads the same query.\n * A screen with any fine pointer (a touchscreen laptop, a tablet with a trackpad) keeps them. Pinch, wheel and keys\n * zoom everywhere. */\nexport const CONTROLS = {\n /** Where the zoom buttons show: a screen whose main pointer is a mouse or trackpad (it hovers and is fine). Not a\n * tablet with a stylus, which also has a fine pointer but is used by touch: there people pinch. */ zoomButtonsMedia: '(hover: hover) and (pointer: fine)',\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: at least `hullX` / `hullY`\n * (a one-line pill), more when the pill reaches further (a 2 - 3 line name): half its largest drawn height plus\n * `pillAir`. A pill on a side edge may reach further sideways; the framing doesn't reserve that. */ hullX: 24, hullY: 40, pillAir: 12,\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. A hull's `pillH` is\n * its name pill's height at the largest drawn size (container.ts pillScaled at PILL.maxGrow). */\nexport function layerBounds(ideas: ReadonlyArray<{ x: number; y: number; rx: number; ry: number }>, hulls: ReadonlyArray<FrameBox & { pillH?: number }> = []): 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) {\n const hy = Math.max(FRAME.hullY, (h.pillH ?? 0) / 2 + FRAME.pillAir);\n x0 = Math.min(x0, h.x0 - FRAME.hullX); x1 = Math.max(x1, h.x1 + FRAME.hullX); y0 = Math.min(y0, h.y0 - hy); y1 = Math.max(y1, h.y1 + hy);\n }\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 idea draws while a highlight is on (VisualMap `highlight`, or picking ideas for a group or a connector):\n * `ids` are the highlighted ideas. A non-empty list: those are 'selected' and every other idea 'dimmed'. An empty list:\n * every idea 'dimmed' while `picking` (nothing chosen yet), else no highlight (null). No list: null. */\nexport function ideaHighlight(ids: readonly string[] | null | undefined, picking: boolean, id: string): 'selected' | 'dimmed' | null {\n if (!ids) return null;\n if (ids.length) return ids.includes(id) ? 'selected' : 'dimmed';\n return picking ? 'dimmed' : null;\n}\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;AAA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,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.17",
|
|
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.17",
|
|
78
78
|
"rbush": "^3.0.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
@@ -745,6 +745,7 @@ export const CANVAS_STYLE = {
|
|
|
745
745
|
"dimmedOpacityFocus": 0.4,
|
|
746
746
|
"dimmedOpacityTouch": 0.6,
|
|
747
747
|
"dimmedOpacityFocusTouch": 0.4,
|
|
748
|
+
"highlightDimmedOpacity": 0.35,
|
|
748
749
|
"shadowLight": "0 6px 14px rgba(24, 33, 64, .10)",
|
|
749
750
|
"shadowDark": "0 0 22px rgba(255, 255, 255, .10)"
|
|
750
751
|
},
|
|
@@ -19,15 +19,64 @@ const WEIGHT = { idea: 1000, label: 1000, connector: 60, preference: 1 };
|
|
|
19
19
|
/** Room kept between a member's outline and the hull, for ideas larger than the base size. */
|
|
20
20
|
export const HULL_CLEAR = { x: 50, y: 51 } as const;
|
|
21
21
|
|
|
22
|
+
/** The name pill (1x, world units = CSS px): the `note` face 26px bold (× the label scale), line-height 1.1, padding
|
|
23
|
+
* and border as the CSS draws them. It grows with the name up to `maxWidth` (padding and border included), then wraps
|
|
24
|
+
* to at most `maxLines` lines; an ellipsis only past that. Zooming grows the text with the label growth (up to
|
|
25
|
+
* `maxGrow`) but never the padding or border, and never re-wraps. `.vi-map__group-label`'s max-width equals
|
|
26
|
+
* `maxWidth` (the build checks it). */
|
|
27
|
+
export const PILL = {
|
|
28
|
+
fontPx: 26, lineHeight: 1.1, padX: 22, padTop: 6, padBottom: 8, border: 1.5, maxWidth: 420, maxLines: 3, maxGrow: 1.3,
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
/** The pill's fixed chrome (padding + border): width and height that don't scale with the text. */
|
|
32
|
+
export const PILL_CHROME = { w: 2 * PILL.padX + 2 * PILL.border, h: PILL.padTop + PILL.padBottom + 2 * PILL.border } as const;
|
|
33
|
+
export type PillSize = { lines: string[]; w: number; h: number };
|
|
34
|
+
|
|
35
|
+
/** Wraps a container's name into its pill at 1x. `measure(text, px)` is the width of `text` in the note face at `px`
|
|
36
|
+
* (an injected canvas measure, like wrapLines in idea.ts); `scale` is the label scale (1.15 in large type). Words wrap
|
|
37
|
+
* greedily inside `maxWidth`; a word wider than that gets its own line (and is clipped). Past `maxLines` the last
|
|
38
|
+
* line ends in an ellipsis. `w` is the widest line plus the chrome (at most `maxWidth`), `h` the lines plus the chrome. */
|
|
39
|
+
export function pillLayout(name: string, measure: (text: string, px: number) => number, scale = 1): PillSize {
|
|
40
|
+
const px = PILL.fontPx * scale, room = PILL.maxWidth - PILL_CHROME.w, m = (s: string) => measure(s, px);
|
|
41
|
+
const words = name.split(/\s+/).filter(Boolean);
|
|
42
|
+
let lines: string[] = [], cur = '';
|
|
43
|
+
for (const w of words) {
|
|
44
|
+
const next = cur ? `${cur} ${w}` : w;
|
|
45
|
+
if (cur && m(next) > room) { lines.push(cur); cur = w; } else cur = next;
|
|
46
|
+
}
|
|
47
|
+
if (cur) lines.push(cur);
|
|
48
|
+
if (!lines.length) lines = [''];
|
|
49
|
+
if (lines.length > PILL.maxLines) {
|
|
50
|
+
// Past the limit: keep the first lines, and end the last one in an ellipsis that fits.
|
|
51
|
+
let last = lines.slice(PILL.maxLines - 1).join(' ');
|
|
52
|
+
while (last.length > 1 && m(last + '\u2026') > room) last = last.slice(0, -1);
|
|
53
|
+
lines = [...lines.slice(0, PILL.maxLines - 1), last.replace(/\s+$/, '') + '\u2026'];
|
|
54
|
+
}
|
|
55
|
+
const widest = Math.max(...lines.map(m));
|
|
56
|
+
return { lines, w: Math.min(PILL.maxWidth, widest + PILL_CHROME.w), h: lines.length * px * PILL.lineHeight + PILL_CHROME.h };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The pill as drawn at label growth `k` (1 to PILL.maxGrow): the text grows, the padding and border don't. */
|
|
60
|
+
export function pillScaled(p: { w: number; h: number }, k: number): { w: number; h: number } {
|
|
61
|
+
return { w: (p.w - PILL_CHROME.w) * k + PILL_CHROME.w, h: (p.h - PILL_CHROME.h) * k + PILL_CHROME.h };
|
|
62
|
+
}
|
|
63
|
+
|
|
22
64
|
/** The hull around a group's ideas: `padX` / `padY` beyond their centres, or more for an idea that has grown to show
|
|
23
|
-
* its label (`rx` / `ry`, its half size: then its outline plus HULL_CLEAR).
|
|
24
|
-
|
|
65
|
+
* its label (`rx` / `ry`, its half size: then its outline plus HULL_CLEAR). With the name's `pill` (its 1x size,
|
|
66
|
+
* from pillLayout) the hull is also widened, symmetrically about its centre, so that the pill at its largest drawn
|
|
67
|
+
* size (PILL.maxGrow) fits on the straight part of an edge: pill width + 2 × the corner radius. Hull and pill then
|
|
68
|
+
* never change while zooming. Without a pill the hull is as before. */
|
|
69
|
+
export function containerHull(members: ReadonlyArray<Pt & { rx?: number; ry?: number }>, pill?: { w: number; h: number } | null): Hull | null {
|
|
25
70
|
if (!members.length) return null;
|
|
26
71
|
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
27
72
|
for (const m of members) {
|
|
28
73
|
const px = Math.max(HULL.padX, (m.rx ?? 0) + HULL_CLEAR.x), py = Math.max(HULL.padY, (m.ry ?? 0) + HULL_CLEAR.y);
|
|
29
74
|
x0 = Math.min(x0, m.x - px); x1 = Math.max(x1, m.x + px); y0 = Math.min(y0, m.y - py); y1 = Math.max(y1, m.y + py);
|
|
30
75
|
}
|
|
76
|
+
if (pill) {
|
|
77
|
+
const need = pillScaled(pill, PILL.maxGrow).w + 2 * HULL.radius, cx = (x0 + x1) / 2;
|
|
78
|
+
if (x1 - x0 < need) { x0 = cx - need / 2; x1 = cx + need / 2; }
|
|
79
|
+
}
|
|
31
80
|
return { x0, x1, y0, y1, radius: HULL.radius };
|
|
32
81
|
}
|
|
33
82
|
|
|
@@ -114,9 +114,20 @@ export function ideaSize(kind: IdeaKind, label: string, measure: (text: string,
|
|
|
114
114
|
while (!r.fits && width < max) { width = Math.min(max, width + IDEA.step); r = at(width); }
|
|
115
115
|
// A single word too wide for the widest idea (a word is never broken): only then, wider than max, up to twice it.
|
|
116
116
|
const wordTooWide = () => label.split(/\s+/).some((w) => m(w) > (lineWidthsInShape(1, lh, profile(r.rx, r.ry))[0] ?? 0));
|
|
117
|
+
const longWord = !r.fits && wordTooWide();
|
|
117
118
|
while (!r.fits && width < max * 2 && wordTooWide()) { width += IDEA.step; r = at(width); }
|
|
118
119
|
// At its widest: taller, until every line fits the shape (bounded, so a pathological label still ends).
|
|
119
|
-
|
|
120
|
+
let tall = r;
|
|
121
|
+
for (let k = 0; k < 40 && !fitsShape(tall.lines, lh, profile(tall.rx, tall.ry), m); k++) tall = at(width, tall.ry + IDEA.step / 2);
|
|
122
|
+
// A word too long for the widest idea sits on a line near the top or bottom, narrower than the middle one, so
|
|
123
|
+
// widening only until it fits the middle line leaves the idea growing tall and lopsided: for such a word, widen
|
|
124
|
+
// further (up to twice the widest) when that fits the label and is not taller.
|
|
125
|
+
if (longWord && tall.ry * 2 > width) {
|
|
126
|
+
let w = width, q = r;
|
|
127
|
+
while (!q.fits && w < max * 2) { w += IDEA.step; q = at(w); }
|
|
128
|
+
if (q.fits && q.ry < tall.ry) { width = w; tall = q; }
|
|
129
|
+
}
|
|
130
|
+
r = tall;
|
|
120
131
|
return { width, height: r.ry * 2, rx: r.rx, ry: r.ry, lines: r.lines };
|
|
121
132
|
}
|
|
122
133
|
|
|
@@ -62,6 +62,16 @@ export const BACK = {
|
|
|
62
62
|
/** The bump at the top layer (ms). */ bumpMs: 320,
|
|
63
63
|
} as const;
|
|
64
64
|
|
|
65
|
+
/** The zoom buttons (− % +) are for screens with a mouse or trackpad. On a touch-only screen (a phone, a tablet
|
|
66
|
+
* without a trackpad) people pinch to zoom, so the buttons stay out of the way: the spec CSS hides `.vi-map__ctrls`
|
|
67
|
+
* under `@media not all and (hover: hover) and (pointer: fine)`, and the design system's VisualMap reads the same query.
|
|
68
|
+
* A screen with any fine pointer (a touchscreen laptop, a tablet with a trackpad) keeps them. Pinch, wheel and keys
|
|
69
|
+
* zoom everywhere. */
|
|
70
|
+
export const CONTROLS = {
|
|
71
|
+
/** Where the zoom buttons show: a screen whose main pointer is a mouse or trackpad (it hovers and is fine). Not a
|
|
72
|
+
* tablet with a stylus, which also has a fine pointer but is used by touch: there people pinch. */ zoomButtonsMedia: '(hover: hover) and (pointer: fine)',
|
|
73
|
+
} as const;
|
|
74
|
+
|
|
65
75
|
/** How the map changed layer, reported with onLayerPathChange so a host can keep browser history in step:
|
|
66
76
|
* 'step-in' (an idea's rings or Step inside), 'trail', 'gesture' (double-click, double-tap), 'key' (Escape, Backspace), 'host' (the host set layerPath). */
|
|
67
77
|
export type LayerVia = 'step-in' | 'trail' | 'gesture' | 'key' | 'host';
|
|
@@ -82,18 +92,24 @@ export function zoomAround(t0: { x: number; y: number }, s0: number, s1: number,
|
|
|
82
92
|
/** Framing a layer (fit to view): its ideas with room around them, and its container hulls with room for the name pill. */
|
|
83
93
|
export const FRAME = {
|
|
84
94
|
/** 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,
|
|
85
|
-
/** Room beyond each container hull for its dashed line and the name pill straddling it
|
|
95
|
+
/** Room beyond each container hull for its dashed line and the name pill straddling it: at least `hullX` / `hullY`
|
|
96
|
+
* (a one-line pill), more when the pill reaches further (a 2 - 3 line name): half its largest drawn height plus
|
|
97
|
+
* `pillAir`. A pill on a side edge may reach further sideways; the framing doesn't reserve that. */ hullX: 24, hullY: 40, pillAir: 12,
|
|
86
98
|
} as const;
|
|
87
99
|
export type FrameBox = { x0: number; y0: number; x1: number; y1: number };
|
|
88
100
|
|
|
89
|
-
/** The box a layer is framed by: every idea (`rx` / `ry` its half size) and every container hull.
|
|
90
|
-
|
|
101
|
+
/** The box a layer is framed by: every idea (`rx` / `ry` its half size) and every container hull. A hull's `pillH` is
|
|
102
|
+
* its name pill's height at the largest drawn size (container.ts pillScaled at PILL.maxGrow). */
|
|
103
|
+
export function layerBounds(ideas: ReadonlyArray<{ x: number; y: number; rx: number; ry: number }>, hulls: ReadonlyArray<FrameBox & { pillH?: number }> = []): FrameBox {
|
|
91
104
|
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
92
105
|
for (const n of ideas) {
|
|
93
106
|
const px = n.rx * (1 + FRAME.ring) + FRAME.clearX, py = n.ry * (1 + FRAME.ring) + FRAME.clearY;
|
|
94
107
|
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);
|
|
95
108
|
}
|
|
96
|
-
for (const h of hulls) {
|
|
109
|
+
for (const h of hulls) {
|
|
110
|
+
const hy = Math.max(FRAME.hullY, (h.pillH ?? 0) / 2 + FRAME.pillAir);
|
|
111
|
+
x0 = Math.min(x0, h.x0 - FRAME.hullX); x1 = Math.max(x1, h.x1 + FRAME.hullX); y0 = Math.min(y0, h.y0 - hy); y1 = Math.max(y1, h.y1 + hy);
|
|
112
|
+
}
|
|
97
113
|
if (!Number.isFinite(x0)) return { x0: -150, y0: -120, x1: 150, y1: 120 };
|
|
98
114
|
return { x0, y0, x1, y1 };
|
|
99
115
|
}
|
|
@@ -145,6 +161,15 @@ export function peekPosition(idea: { x: number; y: number; half: number }, box:
|
|
|
145
161
|
* The dot is the idea shape (shapeForLevel). */
|
|
146
162
|
export const TRAIL = { rootTopic: 'stone', rootLabel: 'icon', homeIconSize: 12, dotBox: 16, dotRadius: 6.4, stroke: 1.25, currentStroke: 1.75 } as const;
|
|
147
163
|
|
|
164
|
+
/** How an idea draws while a highlight is on (VisualMap `highlight`, or picking ideas for a group or a connector):
|
|
165
|
+
* `ids` are the highlighted ideas. A non-empty list: those are 'selected' and every other idea 'dimmed'. An empty list:
|
|
166
|
+
* every idea 'dimmed' while `picking` (nothing chosen yet), else no highlight (null). No list: null. */
|
|
167
|
+
export function ideaHighlight(ids: readonly string[] | null | undefined, picking: boolean, id: string): 'selected' | 'dimmed' | null {
|
|
168
|
+
if (!ids) return null;
|
|
169
|
+
if (ids.length) return ids.includes(id) ? 'selected' : 'dimmed';
|
|
170
|
+
return picking ? 'dimmed' : null;
|
|
171
|
+
}
|
|
172
|
+
|
|
148
173
|
/** How an input answers: a mouse hovers (peeks and terms open on hover); touch and pen tap. Null for unknown pointers. */
|
|
149
174
|
export function pointerModeFor(pointerType: string): 'hover' | 'touch' | null {
|
|
150
175
|
return pointerType === 'mouse' ? 'hover' : pointerType === 'touch' || pointerType === 'pen' ? 'touch' : null;
|
package/src/index.ts
CHANGED
|
@@ -21,12 +21,12 @@ export { MOTION, EASE, revealDelay, connectorDelay, revealTotal, bloomOffset, sw
|
|
|
21
21
|
export type { Bezier } from './generated/geometry/motion.js';
|
|
22
22
|
// Containers: the dashed hull around a group's ideas and where its name goes (a pill on the hull, placed clear of
|
|
23
23
|
// ideas, connectors and other names), verbatim from the design system's geometry/container.ts.
|
|
24
|
-
export { HULL, HULL_CLEAR, containerHull, labelCandidates, placeContainerLabel, connectorSamples } from './generated/geometry/container.js';
|
|
25
|
-
export type { Hull, Box as LabelBox, LabelPlacement, LabelSide, Pt } from './generated/geometry/container.js';
|
|
24
|
+
export { HULL, HULL_CLEAR, PILL, PILL_CHROME, pillLayout, pillScaled, containerHull, labelCandidates, placeContainerLabel, connectorSamples } from './generated/geometry/container.js';
|
|
25
|
+
export type { Hull, Box as LabelBox, LabelPlacement, LabelSide, Pt, PillSize } from './generated/geometry/container.js';
|
|
26
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, BACK, FRAME, PEEK_PLACEMENT, TRAIL, pointerModeFor, hoverOpensTerm, pinchZoom, zoomAround, layerBounds, fitView, fitViewInset, FIT_ROOM, peekPosition } from './generated/geometry/interaction.js';
|
|
29
|
+
export { TERM, PEEK, SHEET, VIEW, GESTURE, BACK, FRAME, PEEK_PLACEMENT, TRAIL, pointerModeFor, hoverOpensTerm, pinchZoom, zoomAround, layerBounds, ideaHighlight, fitView, fitViewInset, FIT_ROOM, peekPosition } from './generated/geometry/interaction.js';
|
|
30
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';
|
package/src/utils/navigation.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { VisualliDocument, VisualliLayer, FlatNode, MindMapConnection } from '../types/index.js';
|
|
2
2
|
import { fitView, fitViewInset, layerBounds, type FrameBox, type FrameInsets } from '../generated/geometry/interaction.js';
|
|
3
|
-
import { containerHull } from '../generated/geometry/container.js';
|
|
3
|
+
import { PILL, containerHull, pillScaled } from '../generated/geometry/container.js';
|
|
4
4
|
|
|
5
5
|
// ── Connection helpers ────────────────────────────────────────────────────────
|
|
6
6
|
|
|
@@ -65,25 +65,30 @@ export interface FitResult {
|
|
|
65
65
|
zoomLevel: number;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
/** A container as the fit sees it: its members and, when it has a name, the name's pill at 1x (`w` × `h`, the design
|
|
69
|
+
* system's pillLayout: the host measures it with the real face). The hull widens for the pill and the framing leaves
|
|
70
|
+
* room for it (containerHull, layerBounds). Without it the container is framed by its hull alone. */
|
|
71
|
+
export interface FitContainer { nodeIds: string[]; pill?: { w: number; h: number } | null }
|
|
72
|
+
|
|
68
73
|
/** The box a layer is framed by: its ideas (their real sizes) and the hulls of its `containers`. */
|
|
69
|
-
export function layerFrame(nodes: ReadonlyArray<FlatNode>, containers: ReadonlyArray<
|
|
74
|
+
export function layerFrame(nodes: ReadonlyArray<FlatNode>, containers: ReadonlyArray<FitContainer> = []): FrameBox {
|
|
70
75
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
71
|
-
const hulls: FrameBox
|
|
76
|
+
const hulls: Array<FrameBox & { pillH?: number }> = [];
|
|
72
77
|
for (const c of containers) {
|
|
73
|
-
const hull = containerHull(c.nodeIds.flatMap((id) => { const n = byId.get(id); return n ? [{ x: n.x, y: n.y, rx: n.width / 2, ry: n.height / 2 }] : []; }));
|
|
74
|
-
if (hull) hulls.push(hull);
|
|
78
|
+
const hull = containerHull(c.nodeIds.flatMap((id) => { const n = byId.get(id); return n ? [{ x: n.x, y: n.y, rx: n.width / 2, ry: n.height / 2 }] : []; }), c.pill);
|
|
79
|
+
if (hull) hulls.push(c.pill ? { ...hull, pillH: pillScaled(c.pill, PILL.maxGrow).h } : hull);
|
|
75
80
|
}
|
|
76
81
|
return layerBounds(nodes.map((n) => ({ x: n.x, y: n.y, rx: n.width / 2, ry: n.height / 2 })), hulls);
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
/** The zoom that fits a layer's ideas (and container hulls) into a canvas of `canvasWidth` × `canvasHeight`. */
|
|
80
|
-
export function calculateFitZoom(nodes: FlatNode[], canvasWidth: number, canvasHeight: number, containers: ReadonlyArray<
|
|
85
|
+
export function calculateFitZoom(nodes: FlatNode[], canvasWidth: number, canvasHeight: number, containers: ReadonlyArray<FitContainer> = []): number {
|
|
81
86
|
if (nodes.length === 0) return 1;
|
|
82
87
|
return fitView(layerFrame(nodes, containers), canvasWidth, canvasHeight).scale;
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
/** The world point a fitted layer is centred on: the middle of its frame. */
|
|
86
|
-
export function calculateFitCenter(nodes: FlatNode[], containers: ReadonlyArray<
|
|
91
|
+
export function calculateFitCenter(nodes: FlatNode[], containers: ReadonlyArray<FitContainer> = []): { x: number; y: number } {
|
|
87
92
|
if (nodes.length === 0) return { x: 0, y: 0 };
|
|
88
93
|
const f = layerFrame(nodes, containers);
|
|
89
94
|
return { x: (f.x0 + f.x1) / 2, y: (f.y0 + f.y1) / 2 };
|
|
@@ -132,7 +137,7 @@ export function calculateFitView(
|
|
|
132
137
|
nodes: FlatNode[],
|
|
133
138
|
canvasWidth: number,
|
|
134
139
|
canvasHeight: number,
|
|
135
|
-
containers: ReadonlyArray<
|
|
140
|
+
containers: ReadonlyArray<FitContainer> = [],
|
|
136
141
|
insets?: FrameInsets,
|
|
137
142
|
): FitResult {
|
|
138
143
|
if (nodes.length === 0) return { centerX: 0, centerY: 0, zoomLevel: 1 };
|
|
@@ -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 /** 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"],"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;A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,0BAA6B;AACnC,IAAM,wBAA6B;AACnC,IAAM,2BAA6B;AAInC,IAAM,uBAAwB;AAC9B,IAAM,wBAAwB;AAI9B,IAAM,kBAAuB;AAC7B,IAAM,qBAAuB;AAC7B,IAAM,sBAAuB;AAI7B,IAAM,YAA+B;AACrC,IAAM,+BAA+B;AAIrC,IAAM,kBAAmB;AACzB,IAAM,kBAAmB;AACzB,IAAM,kBAAmB;AAGzB,IAAM,wBAAwB;AAAA,EACnC,mBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,mBAAsB;AACxB;AAGO,IAAM,kBAAkB;AAAA,EAC7B,gBAAkB;AAAA,EAClB,mBAAmB;AACrB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generated/geometry/idea.ts","../src/rendering/ideaSize.ts","../src/generated/geometry/blobShapes.ts","../src/generated/geometry/blob.ts","../src/rendering/nodeGeometry.ts"],"sourcesContent":["// Generated from visualli.ai design-system/components/src/idea.ts — do not edit here.\n/* An idea's size and its label. An idea grows to show its whole label: it starts at its base width and widens in\n steps until the label fits in `labelLines` lines and every line fits the shape; at its widest it grows taller\n instead, so a label is never cut (a single word too long for the widest idea widens it further, up to twice). Labels wrap inside the idea's real outline (a ShapeProfile — blob.ts blobProfile\n for the drawn blob, an ellipse by default): each line may be as wide as the shape is at that line's height.\n Labels (and connector labels) grow a little when the map is zoomed out, so they stay readable. Every renderer sizes\n ideas with these rules, measuring text with its own font engine (`measure`). No dependencies, so it can travel alone. */\n\nexport type IdeaKind = 'root' | 'node' | 'mini';\n\n/** How much labels grow when zoomed out (`scale` = the map's zoom): never smaller than their size, up to these caps.\n * Idea labels and container names use `idea`; connector labels `connector`. Below 100% they grow; above, they don't. */\nexport const LABEL_GROWTH = { idea: 1.3, connector: 1.6, /** Label lines are wrapped at growth steps this size (layoutGrowth). */ layoutStep: 0.02 } as const;\n\nexport const IDEA = {\n /** Width an idea starts at… */ baseWidth: { root: 240, node: 200, mini: 120 },\n /** …and the widest it gets before it grows taller instead. */ maxWidth: { root: 400, node: 360, mini: 200 },\n /** Width grows in steps of this. */ step: 20,\n /** Height = width × aspect (at least `minRy` × 2), more if the label needs it. */ aspect: 0.74, minRy: 64,\n /** The label's box is the idea's width less this (22 each side). */ labelInset: 44,\n /** The idea widens until its label fits in this many lines. */ labelLines: 3,\n /** Label size (before the label scale and zoom growth), weight from the canvas type styles. */ labelSize: { root: 30, node: 22, mini: 15 },\n labelLineHeight: 1.15,\n /** The label may fill at most this share of the idea's height. */ labelFillHeight: 0.7,\n} as const;\n\n/** Greedy word wrap of `text` into lines no wider than `maxWidth` (a single word longer than that gets its own line). */\nexport function wrapLines(text: string, maxWidth: number, measure: (s: string) => number): string[] {\n const words = text.split(/\\s+/).filter(Boolean);\n const lines: string[] = [];\n let cur = '';\n for (const w of words) {\n const next = cur ? `${cur} ${w}` : w;\n if (cur && measure(next) > maxWidth) { lines.push(cur); cur = w; } else cur = next;\n }\n if (cur) lines.push(cur);\n return lines.length ? lines : [''];\n}\n\n/** A line's width as the shape-aware wrap measures it: its words' widths plus the spaces between them, each word\n * measured once. Words repeat across a map, so a renderer measures far fewer strings; kerning across a space (a\n * fraction of a pixel) is ignored, well inside labelInset. */\nfunction wordsMeasure(measure: (s: string) => number): (s: string) => number {\n const seen = new Map<string, number>(), space = measure(' ');\n const word = (w: string) => { let x = seen.get(w); if (x === undefined) { x = measure(w); seen.set(w, x); } return x; };\n return (line) => { const ws = line.split(' '); let x = (ws.length - 1) * space; for (const w of ws) x += word(w); return x; };\n}\n\n/** How wide a shape is at a height: for an idea of half-size rx × ry, `(y) => ` the distance a centered line at height\n * y (from the center) can reach before it meets the outline. blob.ts `blobProfile(shape)` gives the drawn blob's. */\nexport type ShapeProfile = (rx: number, ry: number) => (y: number) => number;\n/** The default profile, an ellipse — for renderers without blob geometry. */\nexport const ELLIPSE: ShapeProfile = (rx, ry) => (y) => rx * Math.sqrt(Math.max(0, 1 - (y / ry) * (y / ry)));\n\n/** Greedy word wrap of `text` where line i may be at most `widthOf(i)` wide (a word wider than its line gets its own). */\nfunction wrapVarying(text: string, widthOf: (i: number) => number, measure: (s: string) => number): string[] {\n const words = text.split(/\\s+/).filter(Boolean);\n const lines: string[] = [];\n let cur = '';\n for (const w of words) {\n const next = cur ? `${cur} ${w}` : w;\n if (cur && measure(next) > widthOf(lines.length)) { lines.push(cur); cur = w; } else cur = next;\n }\n if (cur) lines.push(cur);\n return lines.length ? lines : [''];\n}\n\n/** The widest each line of an n-line label may be, inside the shape: the label is centered vertically, lines are\n * `lineHeight` tall, and line i may reach as far as the shape does at both its top and bottom edge, less labelInset. */\nexport function lineWidthsInShape(n: number, lineHeight: number, halfWidthAt: (y: number) => number): number[] {\n return Array.from({ length: n }, (_, i) => {\n const top = (i - n / 2) * lineHeight, bottom = top + lineHeight;\n return Math.max(0, 2 * Math.min(halfWidthAt(top), halfWidthAt(bottom)) - IDEA.labelInset);\n });\n}\n\n/** Word wrap inside a shape: lines take the width the shape has at their height (lineWidthsInShape). The line count\n * and the lines' heights depend on each other, so it settles in a few passes. */\nexport function wrapInShape(text: string, lineHeight: number, halfWidthAt: (y: number) => number, measure: (s: string) => number): string[] {\n let n = 1, lines = [text];\n for (let pass = 0; pass < 6; pass++) {\n const widths = lineWidthsInShape(n, lineHeight, halfWidthAt);\n lines = wrapVarying(text, (i) => widths[Math.min(i, n - 1)] ?? 0, measure);\n if (lines.length === n) break;\n n = lines.length;\n }\n return lines;\n}\n\n/** Whether `lines` fit the shape: each line no wider than lineWidthsInShape allows (a single word that can't fit counts). */\nfunction fitsShape(lines: string[], lineHeight: number, halfWidthAt: (y: number) => number, measure: (s: string) => number): boolean {\n const widths = lineWidthsInShape(lines.length, lineHeight, halfWidthAt);\n return lines.every((l, i) => measure(l) <= (widths[i] ?? 0) + 0.5);\n}\n\n/** An idea's size for its label: width, half-width / half-height for the blob, and the label's lines. The label is\n * measured at its largest drawn size — its type size × `labelScale` (Comfort: larger text) × LABEL_GROWTH.idea (zoomed\n * out) — so it fits at every zoom and the idea never changes size while zooming. `measure(text, px)` returns the\n * text's width in px in the label's face at `px`. */\nexport function ideaSize(kind: IdeaKind, label: string, measure: (text: string, px: number) => number, labelScale = 1, profile: ShapeProfile = ELLIPSE) {\n const px = IDEA.labelSize[kind] * labelScale * LABEL_GROWTH.idea, lh = px * IDEA.labelLineHeight;\n const m = wordsMeasure((t: string) => measure(t, px));\n // For a width: the base height, the label wrapped in the shape, then taller if the label needs the height.\n const at = (width: number, minRy = 0) => {\n const rx = width / 2;\n let ry = Math.max(IDEA.minRy, rx * IDEA.aspect, minRy);\n let lines = wrapInShape(label, lh, profile(rx, ry), m);\n const needRy = (lines.length * lh) / 2 / IDEA.labelFillHeight;\n if (needRy > ry) { ry = needRy; lines = wrapInShape(label, lh, profile(rx, ry), m); }\n return { rx, ry, lines, fits: lines.length <= IDEA.labelLines && fitsShape(lines, lh, profile(rx, ry), m) };\n };\n const base: number = IDEA.baseWidth[kind], max: number = IDEA.maxWidth[kind];\n let width = base, r = at(width);\n while (!r.fits && width < max) { width = Math.min(max, width + IDEA.step); r = at(width); }\n // A single word too wide for the widest idea (a word is never broken): only then, wider than max, up to twice it.\n const wordTooWide = () => label.split(/\\s+/).some((w) => m(w) > (lineWidthsInShape(1, lh, profile(r.rx, r.ry))[0] ?? 0));\n while (!r.fits && width < max * 2 && wordTooWide()) { width += IDEA.step; r = at(width); }\n // At its widest: taller, until every line fits the shape (bounded, so a pathological label still ends).\n for (let k = 0; k < 40 && !fitsShape(r.lines, lh, profile(r.rx, r.ry), m); k++) r = at(width, r.ry + IDEA.step / 2);\n return { width, height: r.ry * 2, rx: r.rx, ry: r.ry, lines: r.lines };\n}\n\n/** How an idea's label is drawn at a zoom: its type size × `labelScale` × labelGrowth(zoom).idea, wrapped inside the\n * idea's shape (wrapInShape with the same profile ideaSize used). Grow first, then wrap: a grown label takes more,\n * shorter lines and never crosses the outline (the idea itself never resizes with zoom; ideaSize made it big enough\n * for the largest growth). `px` and `lineHeight` are in map units — draw them inside the map's transform, centered,\n * one line after another. */\nexport function labelLayout(kind: IdeaKind, label: string, size: { rx: number; ry: number }, zoom: number, measure: (text: string, px: number) => number, labelScale = 1, profile: ShapeProfile = ELLIPSE) {\n const base = IDEA.labelSize[kind] * labelScale;\n const px = base * labelGrowth(zoom).idea, lineHeight = px * IDEA.labelLineHeight;\n // Lines are wrapped at layoutGrowth (the growth rounded up to a step), so they hold across a zoom range and can be\n // cached; the label is drawn at `px`, never larger than they were wrapped for, so every line still fits.\n const lpx = base * layoutGrowth(zoom), lh = lpx * IDEA.labelLineHeight;\n return { px, lineHeight, lines: wrapInShape(label, lh, profile(size.rx, size.ry), wordsMeasure((t) => measure(t, lpx))) };\n}\n\n/** The growth a label's lines are wrapped at: labelGrowth(zoom).idea rounded up to the next LABEL_GROWTH.layoutStep\n * (never above LABEL_GROWTH.idea). Renderers key cached layouts by it. */\nexport function layoutGrowth(zoom: number): number {\n const g = labelGrowth(zoom).idea, step = LABEL_GROWTH.layoutStep;\n return Math.min(LABEL_GROWTH.idea, Math.ceil(g / step - 1e-9) * step);\n}\n\nexport function labelGrowth(scale: number): { idea: number; connector: number } {\n const inv = 1 / Math.max(scale, 0.0001);\n return { idea: Math.max(1, Math.min(inv, LABEL_GROWTH.idea)), connector: Math.max(1, Math.min(inv, LABEL_GROWTH.connector)) };\n}\n","// ─── Idea size and label growth ──────────────────────────────────────────────\n//\n// The design system's idea.ts (copied verbatim into generated/geometry): an idea\n// grows to show its whole label, and labels grow a little when zoomed out. The\n// SDK only supplies the text measurement (its font engine) and picks the kind.\n\nimport { ELLIPSE, IDEA, LABEL_GROWTH, ideaSize, labelGrowth, labelLayout, layoutGrowth, lineWidthsInShape, wrapInShape, wrapLines, type IdeaKind, type ShapeProfile } from '../generated/geometry/idea.js';\nimport type { VisualliLayer } from '../types/layer.js';\n\nexport { ELLIPSE, IDEA, LABEL_GROWTH, ideaSize, labelGrowth, labelLayout, layoutGrowth, lineWidthsInShape, wrapInShape, wrapLines };\nexport type { IdeaKind, ShapeProfile };\n\n/** Width in px of `text` in the idea label's face at `px` (the label's weight; readable type adds its tracking). */\nexport type IdeaMeasure = (text: string, px: number) => number;\n\n/** Measurement without a font engine (server, tests): half an em per character. Renderers pass the real face. */\nexport const approximateMeasure: IdeaMeasure = (text, px) => text.length * px * 0.5;\n\n/** The size kind of the `index`-th idea of a layer: the centre of the root radial layer is the root, the rest ideas. */\nexport const ideaKindOf = (layer: Pick<VisualliLayer, 'level' | 'layout'>, index: number): IdeaKind =>\n layer.level === 0 && (layer.layout ?? 'radial') === 'radial' && index === 0 ? 'root' : 'node';\n","// Generated from visualli.ai design-system/components/src/blobShapes.ts — do not edit here.\n// The six hand-authored Visualli node outlines, in normalized units (rx = ry = 1).\n// Copied verbatim from the web app (features/canvas/config/blobShapes.ts). Shape 0 is the root shape.\nexport const BLOB_SHAPES: number[][][] = [[[1.12,0.0],[0.86,0.56],[0.46,0.94],[-0.08,1.06],[-0.68,0.82],[-0.96,0.08],[-0.55,-0.82],[0.04,-1.02],[0.72,-0.8],[1.08,-0.38]],[[-0.489,-0.625],[-0.384,-0.716],[-0.285,-0.792],[-0.189,-0.855],[-0.09,-0.903],[0.014,-0.932],[0.129,-0.94],[0.255,-0.924],[0.412,-0.876],[0.516,-0.832],[0.612,-0.78],[0.695,-0.725],[0.767,-0.666],[0.83,-0.606],[0.885,-0.546],[0.933,-0.486],[0.979,-0.425],[1.006,-0.385],[1.034,-0.334],[1.058,-0.276],[1.078,-0.209],[1.092,-0.133],[1.101,-0.046],[1.102,0.052],[1.094,0.173],[1.083,0.244],[1.063,0.324],[1.034,0.401],[0.996,0.477],[0.948,0.549],[0.889,0.617],[0.82,0.681],[0.735,0.741],[0.658,0.783],[0.569,0.822],[0.474,0.855],[0.372,0.882],[0.265,0.904],[0.156,0.92],[0.046,0.931],[-0.069,0.938],[-0.155,0.935],[-0.25,0.919],[-0.346,0.89],[-0.443,0.851],[-0.539,0.8],[-0.633,0.738],[-0.723,0.667],[-0.808,0.585],[-0.882,0.501],[-0.944,0.421],[-0.994,0.343],[-1.034,0.267],[-1.064,0.192],[-1.085,0.12],[-1.097,0.042],[-1.102,0.001],[-1.09,-0.243],[-1.05,-0.365],[-0.99,-0.441],[-0.911,-0.479],[-0.819,-0.499],[-0.715,-0.517],[-0.605,-0.551]],[[0.003,-0.97],[0.163,-0.984],[0.286,-1.028],[0.389,-1.096],[0.488,-1.174],[0.597,-1.21],[0.728,-1.165],[0.867,-1.036],[0.996,-0.839],[1.098,-0.59],[1.158,-0.304],[1.153,0.012],[1.08,0.336],[0.944,0.639],[0.756,0.889],[0.484,1.072],[0.339,1.079],[0.219,1.051],[0.131,0.994],[0.059,0.939],[0.008,0.915],[-0.105,0.931],[-0.176,0.965],[-0.249,1.005],[-0.345,1.039],[-0.497,1.055],[-0.672,1.032],[-0.817,0.952],[-0.945,0.81],[-1.054,0.6],[-1.16,0.302],[-1.187,-0.011],[-1.165,-0.326],[-1.097,-0.599],[-0.991,-0.838],[-0.852,-0.912],[-0.695,-0.958],[-0.53,-0.988],[-0.357,-0.992],[-0.18,-0.983]],[[-0.734,-1.127],[-0.656,-1.146],[-0.567,-1.142],[-0.468,-1.115],[-0.358,-1.079],[-0.238,-1.034],[-0.107,-0.989],[0.035,-0.953],[0.188,-0.929],[0.325,-0.916],[0.484,-0.896],[0.65,-0.854],[0.811,-0.77],[0.955,-0.631],[1.068,-0.422],[1.138,-0.126],[1.152,0.272],[1.121,0.451],[1.046,0.602],[0.928,0.727],[0.767,0.833],[0.565,0.925],[0.323,1.001],[0.042,1.075],[-0.277,1.142],[-0.368,1.147],[-0.475,1.136],[-0.589,1.104],[-0.704,1.05],[-0.815,0.973],[-0.913,0.871],[-0.993,0.746],[-1.048,0.593],[-1.109,0.298],[-1.145,0.018],[-1.154,-0.243],[-1.135,-0.482],[-1.085,-0.695],[-1.003,-0.874],[-0.886,-1.02]],[[-0.734,1.127],[-0.656,1.146],[-0.567,1.142],[-0.468,1.115],[-0.358,1.079],[-0.238,1.034],[-0.107,0.989],[0.035,0.953],[0.188,0.929],[0.325,0.916],[0.484,0.896],[0.65,0.854],[0.811,0.77],[0.955,0.631],[1.068,0.422],[1.138,0.126],[1.152,-0.272],[1.121,-0.451],[1.046,-0.602],[0.928,-0.727],[0.767,-0.833],[0.565,-0.925],[0.323,-1.001],[0.042,-1.075],[-0.277,-1.142],[-0.368,-1.147],[-0.475,-1.136],[-0.589,-1.104],[-0.704,-1.05],[-0.815,-0.973],[-0.913,-0.871],[-0.993,-0.746],[-1.048,-0.593],[-1.109,-0.298],[-1.145,-0.018],[-1.154,0.243],[-1.135,0.482],[-1.085,0.695],[-1.003,0.874],[-0.886,1.02]],[[0.001,-1.006],[0.134,-1.001],[0.262,-1.024],[0.382,-1.073],[0.498,-1.107],[0.614,-1.105],[0.733,-1.049],[0.85,-0.932],[0.953,-0.755],[1.03,-0.529],[1.067,-0.265],[1.054,0.018],[0.986,0.3],[0.868,0.557],[0.715,0.766],[0.55,0.909],[0.396,0.984],[0.262,1.005],[0.148,1.003],[0.037,1.008],[-0.083,1.04],[-0.22,1.118],[-0.36,1.192],[-0.5,1.234],[-0.65,1.175],[-0.81,1.045],[-0.99,0.855],[-1.14,0.61],[-1.24,0.33],[-1.27,0.04],[-1.275,-0.25],[-1.225,-0.5],[-1.08,-0.72],[-0.89,-0.92],[-0.734,-1.053],[-0.614,-1.112],[-0.498,-1.127],[-0.381,-1.11],[-0.261,-1.095],[-0.133,-1.058],[0.001,-1.01],[0.134,-1.001]]];\n","// Generated from visualli.ai design-system/components/src/blob.ts — do not edit here.\nimport { BLOB_SHAPES } from './blobShapes';\nexport { BLOB_SHAPES };\n\n/** Which outline ideas take. Every idea, at every depth, has the same shape (`idea`, the shape of the map's centre);\n * depth shows through the depth trail, rings, the layer tint and the step-inside motion. The other authored shapes\n * stay in BLOB_SHAPES for explicit use (`Node shape`); `varyByLevel: true` brings back one shape per level. */\nexport const SHAPE: { idea: number; varyByLevel: boolean } = { idea: 0, varyByLevel: false };\n\n/** Shape for a layer level: SHAPE.idea for every level. With SHAPE.varyByLevel, level 0 is SHAPE.idea and consecutive\n * levels never repeat. */\nexport function shapeForLevel(level: number): number {\n if (!SHAPE.varyByLevel) return SHAPE.idea;\n const n = BLOB_SHAPES.length;\n let cur = SHAPE.idea;\n for (let i = 1; i <= level; i++) {\n const r = Math.floor(Math.abs(Math.sin((i + 1) * 12.9898) * 43758.5453));\n cur = (cur + (r % (n - 1)) + 1) % n;\n }\n return cur;\n}\n\n/** SVG path of a node outline centered on (cx, cy): midpoint-quadratic smoothing through the authored points. */\nexport function blobPath(shape: number, rx: number, ry: number, cx = 0, cy = 0): string {\n const pts = BLOB_SHAPES[((shape % BLOB_SHAPES.length) + BLOB_SHAPES.length) % BLOB_SHAPES.length].map(([x, y]) => [cx + x * rx, cy + y * ry]);\n const mid = (a: number[], b: number[]) => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];\n const f = (n: number) => n.toFixed(2);\n const start = mid(pts[pts.length - 1], pts[0]);\n let d = `M${f(start[0])} ${f(start[1])}`;\n for (let i = 0; i < pts.length; i++) {\n const p = pts[i], m = mid(p, pts[(i + 1) % pts.length]);\n d += `Q${f(p[0])} ${f(p[1])} ${f(m[0])} ${f(m[1])}`;\n }\n return d + 'Z';\n}\n\n/** The path calls drawBlob makes: satisfied by a CanvasRenderingContext2D and by Konva's Context (sceneFunc / hitFunc). */\nexport type PathContext = { beginPath(): void; moveTo(x: number, y: number): void; quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; closePath(): void };\n\n/** Canvas twin of blobPath — call fill()/stroke() after (in Konva: ctx.fillStrokeShape(shape)). */\nexport function drawBlob(ctx: PathContext, shape: number, rx: number, ry: number, cx = 0, cy = 0) {\n const pts = BLOB_SHAPES[((shape % BLOB_SHAPES.length) + BLOB_SHAPES.length) % BLOB_SHAPES.length].map(([x, y]) => [cx + x * rx, cy + y * ry]);\n const mid = (a: number[], b: number[]) => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];\n const s = mid(pts[pts.length - 1], pts[0]);\n ctx.beginPath();\n ctx.moveTo(s[0], s[1]);\n pts.forEach((p, i) => { const m = mid(p, pts[(i + 1) % pts.length]); ctx.quadraticCurveTo(p[0], p[1], m[0], m[1]); });\n ctx.closePath();\n}\n\n/** Distance from the center to the smoothed outline (blobPath) in direction `angle` (radians, SVG y-down).\n * Connectors use it to start and end just outside the outline an idea actually has, not a stand-in ellipse. */\n/** The outline as a polygon: the midpoint-quadratic curve sampled 8 times per segment. */\nfunction blobPolygon(shape: number, rx: number, ry: number): number[][] {\n const pts = BLOB_SHAPES[((shape % BLOB_SHAPES.length) + BLOB_SHAPES.length) % BLOB_SHAPES.length].map(([x, y]) => [x * rx, y * ry]);\n const mid = (a: number[], b: number[]) => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];\n const poly: number[][] = [];\n for (let i = 0; i < pts.length; i++) {\n const p0 = mid(pts[(i - 1 + pts.length) % pts.length], pts[i]), c = pts[i], p1 = mid(pts[i], pts[(i + 1) % pts.length]);\n for (let k = 0; k < 8; k++) { const t = k / 8, u = 1 - t; poly.push([u * u * p0[0] + 2 * u * t * c[0] + t * t * p1[0], u * u * p0[1] + 2 * u * t * c[1] + t * t * p1[1]]); }\n }\n return poly;\n}\n\n/** The shape's profile for label wrapping (idea.ts ShapeProfile): for an idea of half-size rx × ry, how far a centered\n * line at height y (from the center) can reach before it meets the outline — the nearer of the outline's left and\n * right edges at that height, 0 outside it. Labels wrap inside the real shape, so a new shape needs no new label rule. */\nconst profiles = new Map<string, (y: number) => number>();\nexport function blobProfile(shape: number): (rx: number, ry: number) => (y: number) => number {\n return (rx, ry) => {\n const key = `${shape}|${rx}|${ry}`, hit = profiles.get(key);\n if (hit) return hit;\n const poly = blobPolygon(shape, rx, ry);\n const at = new Map<number, number>(); // the same heights come up again and again while wrapping\n const fn = (y: number) => {\n const seen = at.get(y);\n if (seen !== undefined) return seen;\n let left = 0, right = 0;\n for (let i = 0; i < poly.length; i++) {\n const [ax, ay] = poly[i], [bx, by] = poly[(i + 1) % poly.length];\n if ((ay <= y && by > y) || (by <= y && ay > y)) { const x = ax + ((y - ay) / (by - ay)) * (bx - ax); if (x < left) left = x; if (x > right) right = x; }\n }\n const half = Math.max(0, Math.min(-left, right));\n if (at.size < 256) at.set(y, half);\n return half;\n };\n if (profiles.size > 2048) profiles.clear();\n profiles.set(key, fn);\n return fn;\n };\n}\n\nexport function blobRadius(shape: number, rx: number, ry: number, angle: number): number {\n // Cast a ray from the center to the sampled outline.\n const poly = blobPolygon(shape, rx, ry);\n const dx = Math.cos(angle), dy = Math.sin(angle);\n let best = 0;\n for (let i = 0; i < poly.length; i++) {\n const [ax, ay] = poly[i], [bx, by] = poly[(i + 1) % poly.length], ex = bx - ax, ey = by - ay;\n const den = dx * ey - dy * ex;\n if (Math.abs(den) < 1e-9) continue;\n const r = (ax * ey - ay * ex) / den, q = (ax * dy - ay * dx) / den;\n if (r > 0 && q >= 0 && q <= 1) best = Math.max(best, r);\n }\n return best || Math.max(rx, ry);\n}\n\n/** Ring recipe: index 0 is the innermost ring. A node shows min(childLayers, 3) rings. `opacity` is the halo (the ring's\n * fill); `strokeOpacity` is its outline, drawn at full strength so the ring — the \"there is more inside\" cue — reads at\n * 3:1 against the canvas and the halos (the `topic-*-ring` tokens are chosen for that in every theme). */\nexport const RINGS = [\n { scale: 1.1, opacity: 0.5, strokeOpacity: 1, rotate: -5, width: 2, dash: '' },\n { scale: 1.2, opacity: 0.4, strokeOpacity: 1, rotate: -10, width: 1, dash: '' },\n { scale: 1.3, opacity: 0.3, strokeOpacity: 1, rotate: -15, width: 3, dash: '6 4' },\n];\n\n/** Connector geometry: a cubic that bows perpendicular to the chord, flatter as distance grows. */\nexport function edgePath(a: { x: number; y: number }, b: { x: number; y: number }, bow = 1) {\n const dx = b.x - a.x, dy = b.y - a.y, d = Math.hypot(dx, dy) || 1;\n const arc = Math.min(45, 45 / (1 + Math.max(0, (d - 200) / 400))) * bow;\n const nx = -dy / d, ny = dx / d;\n const mx = (a.x + b.x) / 2 + nx * arc, my = (a.y + b.y) / 2 + ny * arc;\n const c1 = { x: a.x + (mx - a.x) * 0.66 + 0, y: a.y + (my - a.y) * 0.66 };\n const c2 = { x: b.x + (mx - b.x) * 0.66, y: b.y + (my - b.y) * 0.66 };\n const ang = Math.atan2(b.y - c2.y, b.x - c2.x);\n return { d: `M${a.x.toFixed(1)} ${a.y.toFixed(1)}C${c1.x.toFixed(1)} ${c1.y.toFixed(1)} ${c2.x.toFixed(1)} ${c2.y.toFixed(1)} ${b.x.toFixed(1)} ${b.y.toFixed(1)}`, angle: ang, mid: { x: mx, y: my } };\n}\n\n/** Open V arrowhead at point p, pointing along angle. */\nexport function arrowPath(p: { x: number; y: number }, angle: number, len = 11) {\n const s = Math.PI / 5.5;\n const a1 = { x: p.x - len * Math.cos(angle - s), y: p.y - len * Math.sin(angle - s) };\n const a2 = { x: p.x - len * Math.cos(angle + s), y: p.y - len * Math.sin(angle + s) };\n return `M${a1.x.toFixed(1)} ${a1.y.toFixed(1)}L${p.x.toFixed(1)} ${p.y.toFixed(1)}L${a2.x.toFixed(1)} ${a2.y.toFixed(1)}`;\n}\n","// ─── Node & connector geometry ───────────────────────────────────────────────\n//\n// Thin layer over the design system's geometry (generated/geometry/blob.ts):\n// it chooses the radii, shapes, rings and endpoints for a FlatNode and never\n// re-implements outline or curve math. Pure functions, no DOM.\n\nimport { BLOB_SHAPES, RINGS, SHAPE, arrowPath, blobPath, blobProfile, blobRadius, edgePath, shapeForLevel } from '../generated/geometry/blob.js';\nimport { METRICS } from '../generated/designSystem.js';\nimport type { FlatNode } from '../types/mindmap.js';\n\n// The design system's geometry is part of the public API (single source of truth).\nexport { BLOB_SHAPES, RINGS, SHAPE, arrowPath, blobPath, blobProfile, blobRadius, edgePath, shapeForLevel };\nexport { drawBlob } from '../generated/geometry/blob.js';\n\n/** Minimum a node needs to be drawn / connected. */\nexport type NodeLike = Pick<FlatNode, 'x' | 'y' | 'width' | 'height' | 'level' | 'branchCount'>;\n\nexport const MAX_RINGS = RINGS.length;\nconst DEG = Math.PI / 180;\n\n/** Outline radii of an idea: half its size (sized for its label by the design system's idea.ts). */\nexport function nodeRadii(n: Pick<FlatNode, 'width' | 'height'>): { rx: number; ry: number } {\n return { rx: n.width / 2, ry: n.height / 2 };\n}\n\n/** Rings an idea shows: one per layer beneath it, at most 3. */\nexport const ringCount = (branchCount: number | undefined): number => Math.max(0, Math.min(branchCount ?? 0, MAX_RINGS));\n\n/** The design system's ring recipes an idea shows, innermost first (index 0 = scale 1.1). */\nexport const ringsFor = (branchCount: number | undefined): typeof RINGS => RINGS.slice(0, ringCount(branchCount));\n\nconst shapeCache = new Map<number, number>();\n/** Outline shape for a layer level (memoised: shapeForLevel is O(level)). */\nexport function shapeOfLevel(level: number): number {\n let s = shapeCache.get(level);\n if (s === undefined) { s = shapeForLevel(level); shapeCache.set(level, s); }\n return s;\n}\n\n/** Largest distance from a blob's centre to any control point, in units of max(rx, ry). */\nconst BLOB_MAX_NORM = Math.max(...BLOB_SHAPES.flatMap((s) => s.map(([x, y]) => Math.hypot(x!, y!))));\n\n/** Visual margin around an idea beyond its outline: stroke, hover lift and the node shadow. */\nconst VISUAL_MARGIN = METRICS.nodeStroke * 2 + 24;\n\n/**\n * Conservative world-space bounds of everything drawn for an idea (rings and\n * stroke included). Ideas are drawn CENTRED on (x, y), so bounds are centred\n * too. A circle bound is used so ring rotation can never push ink outside it.\n */\nexport function nodeBounds(n: NodeLike): { minX: number; minY: number; maxX: number; maxY: number } {\n const { rx, ry } = nodeRadii(n);\n const rings = ringCount(n.branchCount);\n const scale = rings > 0 ? RINGS[rings - 1]!.scale : 1;\n const r = BLOB_MAX_NORM * Math.max(rx, ry) * scale + VISUAL_MARGIN;\n return { minX: n.x - r, minY: n.y - r, maxX: n.x + r, maxY: n.y + r };\n}\n\n/**\n * Distance from an idea's centre to the outline connectors must clear, in the\n * world direction `angle` (radians, y down). That is the outermost visible\n * ring (rotated like the ring is drawn), or the body when there are no rings.\n */\nexport function outlineRadius(n: NodeLike, angle: number): number {\n const { rx, ry } = nodeRadii(n);\n const shape = shapeOfLevel(n.level);\n const rings = ringCount(n.branchCount);\n if (rings === 0) return blobRadius(shape, rx, ry, angle);\n const ring = RINGS[rings - 1]!;\n // The ring is the same blob scaled and rotated about the centre, so look up\n // the radius in the ring's own frame.\n return blobRadius(shape, rx * ring.scale, ry * ring.scale, angle - ring.rotate * DEG);\n}\n\nexport interface ConnectorGeometry {\n /** Start / end points: `edge-gap` outside the source / target outline. */\n a: { x: number; y: number };\n b: { x: number; y: number };\n /** Cubic path data (SVG syntax) and the arrowhead direction, from the design system's edgePath. */\n d: string;\n angle: number;\n /** Bow apex returned by edgePath, where the connector label sits. */\n mid: { x: number; y: number };\n /** Open arrowhead path data at b, from the design system's arrowPath. */\n arrow: string;\n}\n\n/** Endpoints and curve of a connector between two ideas. */\nexport function connectorGeometry(from: NodeLike, to: NodeLike, gap: number = METRICS.edgeGap): ConnectorGeometry {\n const theta = Math.atan2(to.y - from.y, to.x - from.x);\n const ra = outlineRadius(from, theta) + gap;\n const rb = outlineRadius(to, theta + Math.PI) + gap;\n const a = { x: from.x + Math.cos(theta) * ra, y: from.y + Math.sin(theta) * ra };\n const b = { x: to.x - Math.cos(theta) * rb, y: to.y - Math.sin(theta) * rb };\n const e = edgePath(a, b);\n return { a, b, d: e.d, angle: e.angle, mid: e.mid, arrow: arrowPath(b, e.angle) };\n}\n"],"mappings":";;;;;AAYO,IAAM,eAAe;AAAA,EAAE,MAAM;AAAA,EAAK,WAAW;AAAA;AAAA,EAA8E,YAAY;AAAK;AAE5I,IAAM,OAAO;AAAA;AAAA,EACc,WAAW,EAAE,MAAM,KAAK,MAAM,KAAK,MAAM,IAAI;AAAA;AAAA,EACd,UAAU,EAAE,MAAM,KAAK,MAAM,KAAK,MAAM,IAAI;AAAA;AAAA,EACtE,MAAM;AAAA;AA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