@open-pencil/scene-graph 0.15.0 → 0.15.1

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.
@@ -832,7 +832,7 @@ var SceneGraph = class SceneGraph {
832
832
  figKiwiVersion = null;
833
833
  /** Deflated kiwi schema bytes from the original .fig file, preserved for roundtrip fidelity. */
834
834
  figSchemaDeflated = null;
835
- documentColorSpace = "display-p3";
835
+ documentColorSpace = "srgb";
836
836
  enabledLibraries = /* @__PURE__ */ new Map();
837
837
  emitter = createNanoEvents();
838
838
  absPosCache = /* @__PURE__ */ new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Variables.createVariable","Variables.createCollection","Variables.getActiveModeId","Variables.getNodeVariableModeId","Variables.resolveVariable","Variables.resolveColorVariable","Variables.resolveNumberVariable","Variables.resolveColorVariableForNode","Variables.resolveNumberVariableForNode","Variables.getVariablesForCollection","Variables.getVariablesByType","HitTest.hitTest","HitTest.hitTestDeep","HitTest.hitTestFrame","Instances.createInstance","Instances.getMainComponent","Instances.getInstances"],"sources":["../../src/mutation-impact.ts","../../src/snap.ts","../../src/layout-guides.ts","../../src/shared-styles.ts","../../src/undo.ts","../../src/text-picture.ts","../../src/preview.ts","../../src/source-metadata.ts","../../src/variables.ts","../../src/index.ts"],"sourcesContent":["import type { SceneGraph } from './index'\n\nexport interface SceneMutationImpact {\n changedNodeIds: Set<string>\n previousParentIds: Set<string>\n currentParentIds: Set<string>\n createdNodeIds: Set<string>\n deletedNodeIds: Set<string>\n}\n\nexport function createSceneMutationImpact(): SceneMutationImpact {\n return {\n changedNodeIds: new Set(),\n previousParentIds: new Set(),\n currentParentIds: new Set(),\n createdNodeIds: new Set(),\n deletedNodeIds: new Set()\n }\n}\n\nexport type MutationImpactListener = (impact: SceneMutationImpact) => void\n\nexport interface CollectedSceneMutation<T> {\n result: T\n impact: SceneMutationImpact\n}\n\n/** Collects the actual graph nodes and parent containers touched by an operation. */\nexport async function collectSceneMutation<T>(\n graph: SceneGraph,\n operation: () => T | Promise<T>\n): Promise<CollectedSceneMutation<T>> {\n const impact = createSceneMutationImpact()\n const unbind = graph.onNodeEvents({\n created: (node) => {\n impact.createdNodeIds.add(node.id)\n impact.changedNodeIds.add(node.id)\n if (node.parentId) impact.currentParentIds.add(node.parentId)\n },\n updated: (id) => impact.changedNodeIds.add(id),\n deleted: (id, parentId) => {\n if (parentId) impact.previousParentIds.add(parentId)\n impact.deletedNodeIds.add(id)\n impact.changedNodeIds.add(id)\n },\n reparented: (nodeId, oldParentId, newParentId) => {\n impact.changedNodeIds.add(nodeId)\n if (oldParentId) impact.previousParentIds.add(oldParentId)\n impact.currentParentIds.add(newParentId)\n },\n reordered: (nodeId, parentId, _index, previousParentId) => {\n impact.changedNodeIds.add(nodeId)\n if (previousParentId && previousParentId !== parentId) {\n impact.previousParentIds.add(previousParentId)\n }\n impact.currentParentIds.add(parentId)\n }\n })\n try {\n return { result: await operation(), impact }\n } finally {\n unbind()\n }\n}\n\nexport function mutationLayoutScopeIds(impact: SceneMutationImpact): string[] {\n return [\n ...new Set([...impact.changedNodeIds, ...impact.previousParentIds, ...impact.currentParentIds])\n ]\n}\n","import type { SceneNode } from './'\nimport { rotatedBBox } from './geometry'\nimport type { Rect } from './primitives'\n\nconst DEFAULT_SNAP_THRESHOLD = 5\n\nexport interface SnapGuide {\n axis: 'x' | 'y'\n position: number\n from: number\n to: number\n}\n\nexport interface SnapResult {\n dx: number\n dy: number\n guides: SnapGuide[]\n}\n\nfunction getEdges(node: SceneNode) {\n return rotatedBBox(node.x, node.y, node.width, node.height, node.rotation)\n}\n\n// Pairwise edge/center matching intentionally keeps both axes in one pass.\n// eslint-disable-next-line complexity\nexport function computeSnap(\n movingIds: Set<string>,\n movingBounds: Rect,\n allNodes: SceneNode[],\n threshold = DEFAULT_SNAP_THRESHOLD\n): SnapResult {\n const targets = allNodes.filter((n) => !movingIds.has(n.id))\n if (targets.length === 0) return { dx: 0, dy: 0, guides: [] }\n\n const m = {\n left: movingBounds.x,\n right: movingBounds.x + movingBounds.width,\n centerX: movingBounds.x + movingBounds.width / 2,\n top: movingBounds.y,\n bottom: movingBounds.y + movingBounds.height,\n centerY: movingBounds.y + movingBounds.height / 2\n }\n\n let bestDx = Infinity\n let bestDy = Infinity\n const guides: SnapGuide[] = []\n\n for (const target of targets) {\n const t = getEdges(target)\n\n // X-axis snapping: left-to-left, left-to-right, right-to-left, right-to-right, center-to-center\n const xPairs: [number, number][] = [\n [m.left, t.left],\n [m.left, t.right],\n [m.right, t.left],\n [m.right, t.right],\n [m.centerX, t.centerX]\n ]\n\n for (const [mVal, tVal] of xPairs) {\n const d = tVal - mVal\n if (Math.abs(d) < threshold && Math.abs(d) <= Math.abs(bestDx)) {\n if (Math.abs(d) < Math.abs(bestDx)) {\n bestDx = d\n guides.length = guides.filter((g) => g.axis === 'y').length\n ? guides.length\n : guides.length\n // Remove old x guides if we found a closer snap\n for (let i = guides.length - 1; i >= 0; i--) {\n if (guides[i].axis === 'x') guides.splice(i, 1)\n }\n }\n if (Math.abs(d) === Math.abs(bestDx)) {\n const minY = Math.min(m.top, t.top)\n const maxY = Math.max(m.bottom, t.bottom)\n guides.push({ axis: 'x', position: tVal, from: minY, to: maxY })\n }\n }\n }\n\n // Y-axis snapping\n const yPairs: [number, number][] = [\n [m.top, t.top],\n [m.top, t.bottom],\n [m.bottom, t.top],\n [m.bottom, t.bottom],\n [m.centerY, t.centerY]\n ]\n\n for (const [mVal, tVal] of yPairs) {\n const d = tVal - mVal\n if (Math.abs(d) < threshold && Math.abs(d) <= Math.abs(bestDy)) {\n if (Math.abs(d) < Math.abs(bestDy)) {\n for (let i = guides.length - 1; i >= 0; i--) {\n if (guides[i].axis === 'y') guides.splice(i, 1)\n }\n bestDy = d\n }\n if (Math.abs(d) === Math.abs(bestDy)) {\n const minX = Math.min(m.left, t.left)\n const maxX = Math.max(m.right, t.right)\n guides.push({ axis: 'y', position: tVal, from: minX, to: maxX })\n }\n }\n }\n }\n\n return {\n dx: Math.abs(bestDx) <= threshold ? bestDx : 0,\n dy: Math.abs(bestDy) <= threshold ? bestDy : 0,\n guides\n }\n}\n\nexport function computeSelectionBounds(nodes: SceneNode[]): Rect | null {\n if (nodes.length === 0) return null\n let minX = Infinity\n let minY = Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n for (const n of nodes) {\n const edges = getEdges(n)\n minX = Math.min(minX, edges.left)\n minY = Math.min(minY, edges.top)\n maxX = Math.max(maxX, edges.right)\n maxY = Math.max(maxY, edges.bottom)\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }\n}\n","import type { LayoutGrid, SceneNode } from './types'\n\nexport interface LayoutGuideLine {\n axis: 'x' | 'y'\n position: number\n}\n\nconst MAX_LAYOUT_GUIDE_LINES = 10_000\n\nfunction normalizedCount(grid: LayoutGrid): number {\n const value = grid.count ?? grid.numSections ?? 1\n if (!Number.isFinite(value)) return 0\n return Math.min(MAX_LAYOUT_GUIDE_LINES, Math.max(0, Math.floor(value)))\n}\n\nfunction pattern(grid: LayoutGrid): 'COLUMNS' | 'ROWS' | 'GRID' {\n if (grid.pattern === 'GRID' || grid.pattern === 'ROWS') return grid.pattern\n if (grid.axis === 'Y') return 'ROWS'\n return 'COLUMNS'\n}\n\nfunction alignment(grid: LayoutGrid): 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' {\n const value = grid.alignment ?? grid.type\n if (value === 'CENTER' || value === 'MAX' || value === 'STRETCH') return value\n return 'MIN'\n}\n\nfunction sectionSize(nodeSize: number, grid: LayoutGrid): number {\n const fixed = grid.sectionSize ?? 0\n if (alignment(grid) !== 'STRETCH') return fixed\n const count = normalizedCount(grid)\n const gutter = grid.gutterSize ?? 0\n const offset = grid.offset ?? 0\n return (nodeSize - offset * 2 - Math.max(0, count - 1) * gutter) / count\n}\n\nfunction start(nodeSize: number, grid: LayoutGrid, size: number): number {\n const count = normalizedCount(grid)\n const gutter = grid.gutterSize ?? 0\n const offset = grid.offset ?? 0\n const span = count * size + Math.max(0, count - 1) * gutter\n if (alignment(grid) === 'CENTER') return (nodeSize - span) / 2 + offset\n if (alignment(grid) === 'MAX') return nodeSize - span - offset\n return offset\n}\n\nexport interface LayoutGuideSection {\n axis: 'x' | 'y'\n start: number\n end: number\n}\n\nexport function layoutGuideSections(\n node: Pick<SceneNode, 'width' | 'height'>,\n grid: LayoutGrid\n): LayoutGuideSection[] {\n if (grid.visible === false || pattern(grid) === 'GRID') return []\n const axis = pattern(grid) === 'ROWS' ? 'y' : 'x'\n const nodeSize = axis === 'x' ? node.width : node.height\n const size = sectionSize(nodeSize, grid)\n const count = normalizedCount(grid)\n if (count <= 0 || size <= 0) return []\n const first = start(nodeSize, grid, size)\n const step = size + (grid.gutterSize ?? 0)\n return Array.from({ length: count }, (_, index) => {\n const sectionStart = first + index * step\n return { axis, start: sectionStart, end: sectionStart + size }\n })\n}\n\nexport function layoutGuideLines(node: Pick<SceneNode, 'width' | 'height'>, grid: LayoutGrid) {\n if (grid.visible === false) return []\n const gridPattern = pattern(grid)\n const lines: LayoutGuideLine[] = []\n if (gridPattern === 'GRID') {\n const size = grid.sectionSize ?? 0\n if (size <= 0) return lines\n for (\n let index = 0, x = grid.offset ?? 0;\n x <= node.width && index < MAX_LAYOUT_GUIDE_LINES;\n index++, x += size\n ) {\n lines.push({ axis: 'x', position: x })\n }\n for (\n let index = 0, y = grid.offset ?? 0;\n y <= node.height && index < MAX_LAYOUT_GUIDE_LINES;\n index++, y += size\n ) {\n lines.push({ axis: 'y', position: y })\n }\n return lines\n }\n\n const sections = layoutGuideSections(node, grid)\n for (const section of sections) {\n lines.push(\n { axis: section.axis, position: section.start },\n { axis: section.axis, position: section.end }\n )\n }\n return lines\n}\n","import type { SceneGraph, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType } from './index'\n\nconst STYLE_REF_KEYS = {\n fill: 'fillStyleId',\n stroke: 'strokeStyleId',\n text: 'textStyleId',\n effect: 'effectStyleId',\n grid: 'gridStyleId'\n} as const satisfies Record<SharedStyleKind, keyof SceneNode>\n\nconst STYLE_TYPES = {\n fill: 'FILL',\n stroke: 'FILL',\n text: 'TEXT',\n effect: 'EFFECT',\n grid: 'GRID'\n} as const satisfies Record<SharedStyleKind, SharedStyleType>\n\nconst TEXT_STYLE_KEYS = new Set<keyof SceneNode>([\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textDecoration',\n 'textCase',\n 'fontFeatures'\n])\n\nexport function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind] {\n return STYLE_REF_KEYS[kind]\n}\n\nexport function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType {\n return STYLE_TYPES[kind]\n}\n\nexport function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[] {\n const type = sharedStyleTypeForKind(kind)\n const styles: SharedStyle[] = []\n for (const node of graph.getAllNodes()) {\n if (node.sharedStyleType !== type || !node.source.id) continue\n styles.push({ id: node.source.id, nodeId: node.id, name: node.name, type })\n }\n return styles.sort((left, right) => left.name.localeCompare(right.name))\n}\n\nexport function styleDetachmentChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const next = { ...changes }\n if ('fills' in changes && !('fillStyleId' in changes) && node.fillStyleId) {\n next.fillStyleId = null\n }\n if ('strokes' in changes && !('strokeStyleId' in changes) && node.strokeStyleId) {\n next.strokeStyleId = null\n }\n if ('effects' in changes && !('effectStyleId' in changes) && node.effectStyleId) {\n next.effectStyleId = null\n }\n if ('layoutGrids' in changes && !('gridStyleId' in changes) && node.gridStyleId) {\n next.gridStyleId = null\n }\n const changesTextStyle = (Object.keys(changes) as (keyof SceneNode)[]).some((key) =>\n TEXT_STYLE_KEYS.has(key)\n )\n if (changesTextStyle && !('textStyleId' in changes) && node.textStyleId) {\n next.textStyleId = null\n }\n return next\n}\n","export interface UndoEntry {\n label: string\n forward: () => void\n inverse: () => void\n coalesceKey?: string\n}\n\nexport interface UndoManagerOptions {\n limit?: number\n /** Called after recording, undoing, redoing, or clearing committed history. */\n onChange?: () => void\n}\n\ninterface UndoBatch {\n label: string\n entries: UndoEntry[]\n coalesceKey?: string\n}\n\nconst DEFAULT_HISTORY_LIMIT = 200\n\nexport class UndoManager {\n private undoStack: UndoEntry[] = []\n private redoStack: UndoEntry[] = []\n private batches: UndoBatch[] = []\n private readonly limit: number\n private readonly onChange: (() => void) | undefined\n\n constructor(options: UndoManagerOptions = {}) {\n this.limit = options.limit ?? DEFAULT_HISTORY_LIMIT\n this.onChange = options.onChange\n }\n\n apply(entry: UndoEntry): void {\n this.execute(entry)\n }\n\n execute(entry: UndoEntry): void {\n entry.forward()\n this.record(entry)\n }\n\n push(entry: UndoEntry): void {\n this.record(entry)\n }\n\n record(entry: UndoEntry): void {\n const batch = this.currentBatch\n if (batch) {\n batch.entries.push(entry)\n return\n }\n this.pushUndoEntry(entry)\n }\n\n undo(): string | null {\n const entry = this.undoStack.pop()\n if (!entry) return null\n entry.inverse()\n this.redoStack.push(entry)\n this.onChange?.()\n return entry.label\n }\n\n redo(): string | null {\n const entry = this.redoStack.pop()\n if (!entry) return null\n entry.forward()\n this.undoStack.push(entry)\n this.onChange?.()\n return entry.label\n }\n\n beginBatch(label: string, coalesceKey?: string): void {\n this.batches.push({ label, entries: [], coalesceKey })\n }\n\n commitBatch(): void {\n const batch = this.batches.pop()\n if (!batch || batch.entries.length === 0) return\n\n const entry = this.createBatchEntry(batch)\n const parentBatch = this.currentBatch\n if (parentBatch) parentBatch.entries.push(entry)\n else this.pushUndoEntry(entry)\n }\n\n runBatch<T>(label: string, fn: () => T, coalesceKey?: string): T {\n this.beginBatch(label, coalesceKey)\n try {\n const result = fn()\n this.commitBatch()\n return result\n } catch (error) {\n this.rollbackBatch()\n throw error\n }\n }\n\n rollbackBatch(): void {\n const batch = this.batches.pop()\n if (!batch) return\n for (const entry of batch.entries.toReversed()) entry.inverse()\n }\n\n /** Abandon provisional history without replaying it or changing committed undo/redo entries. */\n discardBatches(): void {\n this.batches = []\n }\n\n clear(): void {\n this.undoStack = []\n this.redoStack = []\n this.discardBatches()\n this.onChange?.()\n }\n\n get isBatching(): boolean {\n return this.batches.length > 0\n }\n\n get canUndo(): boolean {\n return this.undoStack.length > 0\n }\n\n get canRedo(): boolean {\n return this.redoStack.length > 0\n }\n\n get undoLabel(): string | null {\n return this.undoStack.at(-1)?.label ?? null\n }\n\n get redoLabel(): string | null {\n return this.redoStack.at(-1)?.label ?? null\n }\n\n private get currentBatch(): UndoBatch | null {\n return this.batches.at(-1) ?? null\n }\n\n private createBatchEntry(batch: UndoBatch): UndoEntry {\n return {\n label: batch.label,\n forward: () => batch.entries.forEach((entry) => entry.forward()),\n inverse: () => batch.entries.toReversed().forEach((entry) => entry.inverse()),\n coalesceKey: batch.coalesceKey\n }\n }\n\n private pushUndoEntry(entry: UndoEntry): void {\n const previous = this.undoStack.at(-1)\n if (entry.coalesceKey && previous?.coalesceKey === entry.coalesceKey) {\n this.undoStack[this.undoStack.length - 1] = {\n ...entry,\n inverse: previous.inverse\n }\n } else {\n this.undoStack.push(entry)\n }\n this.redoStack = []\n this.trimUndoStack()\n this.onChange?.()\n }\n\n private trimUndoStack(): void {\n if (!Number.isFinite(this.limit) || this.limit <= 0) return\n const overflow = this.undoStack.length - this.limit\n if (overflow > 0) this.undoStack.splice(0, overflow)\n }\n}\n","import type { SceneNode } from './types'\n\n/**\n * Invalidate cached Skia textPicture (Paragraph snapshot). Includes width/height\n * because wrapping/layout depends on the box.\n */\nexport const TEXT_PICTURE_KEYS: ReadonlySet<string> = new Set([\n 'text',\n 'fontSize',\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'textAlignHorizontal',\n 'textDirection',\n 'textAlignVertical',\n 'lineHeight',\n 'letterSpacing',\n 'textDecoration',\n 'textCase',\n 'styleRuns',\n 'fills',\n 'width',\n 'height'\n])\n\nexport const GLYPH_AFFECTING_KEYS: ReadonlySet<string> = new Set([\n 'text',\n 'fontSize',\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'textDirection',\n 'lineHeight',\n 'letterSpacing',\n 'textCase',\n 'styleRuns'\n])\n\n/**\n * Shared by SceneGraph.updateNode and updateNodePreview (drag hot path) so the\n * two invalidation rules cannot drift. Glyphs are kept when the caller\n * replaces them in the same update (resize supplies scaled copies).\n */\nexport function textCacheInvalidationChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const invalidated: Partial<SceneNode> = {}\n const keys = Object.keys(changes)\n if (node.textPicture && keys.some((key) => TEXT_PICTURE_KEYS.has(key)))\n invalidated.textPicture = null\n const glyphsInvalidated = keys.some((key) => GLYPH_AFFECTING_KEYS.has(key))\n // A successful path-text edit supplies reflowed glyphs in `changes`. Every\n // other mutation path must drop stale baked glyphs and path identity rather\n // than pair new text/style with old visible outlines.\n if (node.derivedTextGlyphs && glyphsInvalidated && !changes.derivedTextGlyphs) {\n invalidated.derivedTextGlyphs = null\n invalidated.textPathData = null\n }\n return invalidated\n}\n\nexport function invalidateTextCaches(node: SceneNode, changes: Partial<SceneNode>): void {\n Object.assign(node, textCacheInvalidationChanges(node, changes))\n}\n","import { textCacheInvalidationChanges } from './text-picture'\nimport type { SceneNode } from './types'\nimport { normalizeVectorNetwork } from './vector-network'\n\nexport type NodePreviewObserver = (node: SceneNode, changes: Partial<SceneNode>) => void\n\ntype PreviewGraph = {\n nodes: Map<string, SceneNode>\n positionPreviewVersion: number\n clearAbsPosCache: () => void\n}\n\nconst LAYOUT_AFFECTING_KEYS = new Set<string>([\n 'x',\n 'y',\n 'width',\n 'height',\n 'rotation',\n 'flipX',\n 'flipY',\n 'parentId',\n 'childIds',\n 'layoutMode',\n 'layoutDirection',\n 'layoutWrap',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'layoutPositioning',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'visible',\n 'text',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'styleRuns',\n 'textAutoResize'\n])\n\nexport function updateNodePreview(\n graph: PreviewGraph,\n id: string,\n changes: Partial<SceneNode>,\n beforeUpdate?: NodePreviewObserver\n): Partial<SceneNode> | null {\n const node = graph.nodes.get(id)\n if (!node) return null\n changes = Object.fromEntries(\n (Object.entries(changes) as Array<[string, unknown]>).filter(([, value]) => value !== undefined)\n ) as Partial<SceneNode>\n if ((Object.keys(changes) as (keyof SceneNode)[]).every((key) => node[key] === changes[key])) {\n return null\n }\n const affectsLayout = Object.keys(changes).some((key) => LAYOUT_AFFECTING_KEYS.has(key))\n if (affectsLayout) graph.clearAbsPosCache()\n let normalizedChanges = changes\n if (node.type === 'TEXT') {\n normalizedChanges = { ...textCacheInvalidationChanges(node, changes), ...changes }\n }\n if (changes.vectorNetwork) {\n normalizedChanges = {\n ...normalizedChanges,\n vectorNetwork: normalizeVectorNetwork(changes.vectorNetwork)\n }\n }\n beforeUpdate?.(node, normalizedChanges)\n graph.positionPreviewVersion++\n Object.assign(node, normalizedChanges)\n return normalizedChanges\n}\n","import type { SceneNode } from './types'\n\nexport function markSourceFieldsEdited(node: SceneNode, changeKeys: string[]): void {\n if (changeKeys.length === 0) return\n const editedFields = new Set(node.source.editedFields)\n for (const key of changeKeys) editedFields.add(key)\n node.source.editedFields = [...editedFields]\n}\n","import { omit, omitBy } from 'es-toolkit/object'\n\nimport { BLACK } from './constants'\nimport type { SceneGraph } from './index'\nimport { setInstanceOverride } from './instance-overrides'\nimport type { Color } from './primitives'\nimport type { Variable, VariableCollection, VariableType, VariableValue } from './types'\n\nexport function addVariable(graph: SceneGraph, variable: Variable): void {\n graph.variables.set(variable.id, variable)\n const collection = graph.variableCollections.get(variable.collectionId)\n if (collection && !collection.variableIds.includes(variable.id)) {\n collection.variableIds.push(variable.id)\n }\n}\n\nexport function removeVariable(graph: SceneGraph, id: string): void {\n const variable = graph.variables.get(id)\n if (!variable) return\n graph.variables.delete(id)\n const collection = graph.variableCollections.get(variable.collectionId)\n if (collection) {\n collection.variableIds = collection.variableIds.filter((vid) => vid !== id)\n }\n for (const node of graph.nodes.values()) {\n const hadBinding = Object.values(node.boundVariables).includes(id)\n if (!hadBinding) continue\n node.boundVariables = omitBy(node.boundVariables, (varId) => varId === id) as Record<\n string,\n string\n >\n graph.emitter.emit('node:updated', node.id, { boundVariables: { ...node.boundVariables } })\n markBoundVariablesOverrideOnInstance(graph, node.id)\n }\n}\n\nexport function addCollection(graph: SceneGraph, collection: VariableCollection): void {\n graph.variableCollections.set(collection.id, collection)\n if (!graph.activeMode.has(collection.id)) {\n graph.activeMode.set(collection.id, collection.defaultModeId)\n }\n}\n\nfunction defaultVariableValue(type: VariableType, value?: VariableValue): VariableValue {\n if (value !== undefined) return value\n if (type === 'COLOR') return { ...BLACK }\n if (type === 'FLOAT') return 0\n if (type === 'BOOLEAN') return false\n return ''\n}\n\nexport function createVariable(\n graph: SceneGraph,\n generateId: () => string,\n name: string,\n type: VariableType,\n collectionId: string,\n value?: VariableValue\n): Variable {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) throw new Error(`Collection \"${collectionId}\" not found`)\n const id = generateId()\n const defaultValue = defaultVariableValue(type, value)\n const valuesByMode: Record<string, VariableValue> = {}\n for (const mode of collection.modes) {\n valuesByMode[mode.modeId] = structuredClone(defaultValue)\n }\n const variable: Variable = {\n id,\n name,\n type,\n collectionId,\n valuesByMode,\n description: '',\n hiddenFromPublishing: false\n }\n addVariable(graph, variable)\n return variable\n}\n\nexport function createCollection(\n graph: SceneGraph,\n generateId: () => string,\n name: string\n): VariableCollection {\n const id = generateId()\n const modeId = generateId()\n const collection: VariableCollection = {\n id,\n name,\n modes: [{ modeId, name: 'Mode 1' }],\n defaultModeId: modeId,\n variableIds: []\n }\n addCollection(graph, collection)\n return collection\n}\n\nexport function removeCollection(graph: SceneGraph, id: string): void {\n const collection = graph.variableCollections.get(id)\n if (collection) {\n for (const varId of Array.from(collection.variableIds)) {\n removeVariable(graph, varId)\n }\n }\n graph.variableCollections.delete(id)\n graph.activeMode.delete(id)\n}\n\nexport function getActiveModeId(graph: SceneGraph, collectionId: string): string {\n const mode = graph.activeMode.get(collectionId)\n if (mode) return mode\n const collection = graph.variableCollections.get(collectionId)\n return collection?.defaultModeId ?? ''\n}\n\nexport function getNodeVariableModeId(\n graph: SceneGraph,\n nodeId: string,\n collectionId: string\n): string {\n let node = graph.nodes.get(nodeId)\n while (node) {\n const modeId = node.variableModes[collectionId]\n if (modeId) return modeId\n node = node.parentId ? graph.nodes.get(node.parentId) : undefined\n }\n return getActiveModeId(graph, collectionId)\n}\n\nexport function setActiveMode(graph: SceneGraph, collectionId: string, modeId: string): void {\n graph.activeMode.set(collectionId, modeId)\n}\n\nexport function addMode(\n graph: SceneGraph,\n collectionId: string,\n modeId: string,\n name: string,\n sourceMode?: string\n): void {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) return\n collection.modes.push({ modeId, name })\n const sourceModeId = sourceMode ?? collection.defaultModeId\n for (const varId of collection.variableIds) {\n const variable = graph.variables.get(varId)\n if (!variable) continue\n variable.valuesByMode[modeId] = structuredClone(\n variable.valuesByMode[sourceModeId] ?? Object.values(variable.valuesByMode)[0]\n )\n }\n}\n\nexport function removeMode(graph: SceneGraph, collectionId: string, modeId: string): void {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection || collection.modes.length <= 1) return\n collection.modes = collection.modes.filter((m) => m.modeId !== modeId)\n if (collection.defaultModeId === modeId) {\n collection.defaultModeId = collection.modes[0].modeId\n }\n for (const varId of collection.variableIds) {\n const variable = graph.variables.get(varId)\n if (variable) variable.valuesByMode = omit(variable.valuesByMode, [modeId])\n }\n if (graph.activeMode.get(collectionId) === modeId) {\n graph.activeMode.set(collectionId, collection.defaultModeId)\n }\n}\n\nexport function renameMode(\n graph: SceneGraph,\n collectionId: string,\n modeId: string,\n name: string\n): void {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) return\n const mode = collection.modes.find((m) => m.modeId === modeId)\n if (mode) mode.name = name\n}\n\nexport function setDefaultMode(graph: SceneGraph, collectionId: string, modeId: string): void {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) return\n if (!collection.modes.some((m) => m.modeId === modeId)) return\n collection.defaultModeId = modeId\n}\n\nexport function resolveVariable(\n graph: SceneGraph,\n variableId: string,\n modeId?: string,\n visited?: Set<string>\n): VariableValue | undefined {\n if (visited?.has(variableId)) return undefined\n const variable = graph.variables.get(variableId)\n if (!variable) return undefined\n const collection = graph.variableCollections.get(variable.collectionId)\n const preferredModeId = modeId ?? getActiveModeId(graph, variable.collectionId)\n const fallbackModeId = collection?.defaultModeId\n let value = Object.hasOwn(variable.valuesByMode, preferredModeId)\n ? variable.valuesByMode[preferredModeId]\n : undefined\n if (\n value === undefined &&\n fallbackModeId &&\n Object.hasOwn(variable.valuesByMode, fallbackModeId)\n ) {\n value = variable.valuesByMode[fallbackModeId]\n }\n value ??= Object.values(variable.valuesByMode)[0]\n if (value && typeof value === 'object' && 'aliasId' in value) {\n const seen = visited ?? new Set<string>()\n seen.add(variableId)\n return resolveVariable(graph, value.aliasId, preferredModeId, seen)\n }\n return value\n}\n\nexport function resolveColorVariable(graph: SceneGraph, variableId: string): Color | undefined {\n const value = resolveVariable(graph, variableId)\n if (value && typeof value === 'object' && 'r' in value) return value\n return undefined\n}\n\nexport function resolveNumberVariable(graph: SceneGraph, variableId: string): number | undefined {\n const value = resolveVariable(graph, variableId)\n return typeof value === 'number' ? value : undefined\n}\n\nexport function resolveColorVariableForNode(\n graph: SceneGraph,\n nodeId: string,\n variableId: string\n): Color | undefined {\n const variable = graph.variables.get(variableId)\n if (!variable) return undefined\n const modeId = getNodeVariableModeId(graph, nodeId, variable.collectionId)\n const value = resolveVariable(graph, variableId, modeId)\n if (value && typeof value === 'object' && 'r' in value) return value\n return undefined\n}\n\nexport function resolveNumberVariableForNode(\n graph: SceneGraph,\n nodeId: string,\n variableId: string\n): number | undefined {\n const variable = graph.variables.get(variableId)\n if (!variable) return undefined\n const modeId = getNodeVariableModeId(graph, nodeId, variable.collectionId)\n const value = resolveVariable(graph, variableId, modeId)\n return typeof value === 'number' ? value : undefined\n}\n\nexport function getVariablesForCollection(graph: SceneGraph, collectionId: string): Variable[] {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) return []\n return collection.variableIds\n .map((id) => graph.variables.get(id))\n .filter((v): v is Variable => v !== undefined)\n}\n\nexport function getVariablesByType(graph: SceneGraph, type: VariableType): Variable[] {\n return [...graph.variables.values()].filter((v) => v.type === type)\n}\n\nconst SCALAR_BINDING_FIELDS: ReadonlySet<string> = new Set([\n 'opacity',\n 'width',\n 'height',\n 'cornerRadius',\n 'fontSize',\n 'letterSpacing',\n 'lineHeight',\n 'itemSpacing',\n 'strokeWeight',\n 'paddingLeft',\n 'paddingRight',\n 'paddingTop',\n 'paddingBottom',\n 'counterAxisSpacing',\n 'topLeftRadius',\n 'topRightRadius',\n 'bottomLeftRadius',\n 'bottomRightRadius',\n 'rotation',\n 'x',\n 'y',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'borderTopWeight',\n 'borderBottomWeight',\n 'borderLeftWeight',\n 'borderRightWeight',\n 'gridRowGap',\n 'gridColumnGap'\n])\n\nconst STRING_BINDING_FIELDS: ReadonlySet<string> = new Set(['fontFamily'])\n\nconst BOOLEAN_BINDING_FIELDS: ReadonlySet<string> = new Set(['visible'])\n\nexport function bindVariable(\n graph: SceneGraph,\n nodeId: string,\n field: string,\n variableId: string\n): void {\n const node = graph.nodes.get(nodeId)\n if (!node) return\n\n // Validate variable exists\n const variable = graph.variables.get(variableId)\n if (!variable) {\n throw new Error(`Variable \"${variableId}\" not found`)\n }\n\n // Color fields require COLOR variable type\n const colorFieldMatch = field.match(/^(fills|strokes)\\/(\\d+)\\/color$/)\n if (colorFieldMatch) {\n if (variable.type !== 'COLOR') {\n throw new Error(`Cannot bind ${variable.type} variable to color field \"${field}\"`)\n }\n // Validate index is within current array bounds\n const arrayKey = colorFieldMatch[1] as 'fills' | 'strokes'\n const index = Number.parseInt(colorFieldMatch[2], 10)\n const currentLength = (node[arrayKey] as unknown[] | undefined)?.length ?? 0\n if (index >= currentLength) {\n throw new Error(`Index ${index} out of range for ${arrayKey} (length ${currentLength})`)\n }\n // Auto-remove top-level dead binding (e.g. 'fills') when setting indexed binding\n const topLevelKey = colorFieldMatch[1]\n if (topLevelKey in node.boundVariables) {\n node.boundVariables = omit(node.boundVariables, [topLevelKey])\n }\n }\n\n if (SCALAR_BINDING_FIELDS.has(field) && variable.type !== 'FLOAT') {\n throw new Error(`Cannot bind ${variable.type} variable to scalar field \"${field}\"`)\n }\n\n if (STRING_BINDING_FIELDS.has(field) && variable.type !== 'STRING') {\n throw new Error(`Cannot bind ${variable.type} variable to string field \"${field}\"`)\n }\n\n if (BOOLEAN_BINDING_FIELDS.has(field) && variable.type !== 'BOOLEAN') {\n throw new Error(`Cannot bind ${variable.type} variable to boolean field \"${field}\"`)\n }\n\n const isKnownField =\n SCALAR_BINDING_FIELDS.has(field) ||\n STRING_BINDING_FIELDS.has(field) ||\n BOOLEAN_BINDING_FIELDS.has(field) ||\n colorFieldMatch\n\n if (!isKnownField) {\n throw new Error(`Unknown binding field \"${field}\"`)\n }\n\n node.boundVariables = { ...node.boundVariables, [field]: variableId }\n graph.emitter.emit('node:updated', nodeId, { boundVariables: { ...node.boundVariables } })\n markBoundVariablesOverrideOnInstance(graph, nodeId)\n}\n\nexport function unbindVariable(graph: SceneGraph, nodeId: string, field: string): void {\n const node = graph.nodes.get(nodeId)\n if (!node) return\n if (!(field in node.boundVariables)) return\n node.boundVariables = omit(node.boundVariables, [field])\n graph.emitter.emit('node:updated', nodeId, { boundVariables: { ...node.boundVariables } })\n markBoundVariablesOverrideOnInstance(graph, nodeId)\n}\n\nfunction markBoundVariablesOverrideOnInstance(graph: SceneGraph, nodeId: string): void {\n const node = graph.nodes.get(nodeId)\n if (!node) return\n\n // Mark the field on the canonical structured state.\n if (node.type === 'INSTANCE') {\n setInstanceOverride(node.instanceOverrides, node.id, node.id, 'boundVariables')\n return\n }\n\n // Walk up to the owning instance for descendant fields.\n let current = node\n while (current.parentId) {\n const parent = graph.nodes.get(current.parentId)\n if (!parent) break\n if (parent.type === 'INSTANCE') {\n setInstanceOverride(parent.instanceOverrides, parent.id, nodeId, 'boundVariables')\n break\n }\n current = parent\n }\n}\n","/* eslint-disable max-lines -- SceneGraph exposes a stable facade over domain modules */\nexport * from './mutation-impact'\nexport * from './instance-overrides'\nexport * from './images'\nexport * from './components/properties'\nexport * from './copy'\nexport {\n copyInstanceComponentProps,\n hasInstanceOverride,\n INSTANCE_SYNC_FIELDS,\n INSTANCE_SYNC_PROPS,\n INSTANCE_SYNC_TEXT_PROPS,\n recordInstanceOverride\n} from './instances'\nexport {\n clearInstanceOverrides,\n cloneInstanceOverrideState,\n forEachInstanceOverride,\n getInstanceOverride,\n setInstanceOverride,\n type InstanceOverrideState\n} from './instance-overrides'\nexport * from './snap'\nexport * from './export-scale'\nexport * from './coordinate'\nexport * from './constants'\nexport * from './geometry'\nexport * from './guides'\nexport * from './layout-guides'\nexport * from './font-style'\nexport * from './shared-styles'\nexport { default as TransformMatrix } from './matrix'\nexport type { Mat3 } from './matrix'\nexport { UndoManager, type UndoEntry, type UndoManagerOptions } from './undo'\n\nimport { createNanoEvents } from 'nanoevents'\n\nimport { removeStaleBindings } from './bindings'\nimport { cloneNodeProps } from './copy'\nimport { bindNodeEvents } from './events'\nimport * as HitTest from './hit-test'\nimport * as Instances from './instances'\nimport { CONTAINER_TYPES, createDefaultNode } from './node-defaults'\nimport { updateNodePreview, type NodePreviewObserver } from './preview'\nimport { styleDetachmentChanges } from './shared-styles'\nimport { markSourceFieldsEdited } from './source-metadata'\nimport { GLYPH_AFFECTING_KEYS, invalidateTextCaches, TEXT_PICTURE_KEYS } from './text-picture'\nimport * as Variables from './variables'\nimport { normalizeVectorNetwork } from './vector-network'\n\nexport type { GUID, Color, Size, Vector } from './primitives'\nexport * from './types'\n\nimport type { Emitter } from 'nanoevents'\n\nimport { getAbsolutePosition } from './coordinate'\nimport type { Color, Rect, Vector } from './primitives'\nimport type {\n DocumentColorSpace,\n EnabledLibraryBinding,\n NodeType,\n SceneGraphEventHandlers,\n SceneGraphEvents,\n SceneNode,\n SourceMetadata,\n Variable,\n VariableCollection,\n VariableType,\n VariableValue\n} from './types'\n\nexport {\n cloneVectorNetwork,\n mergeVectorNetworks,\n normalizeVectorNetwork,\n transformVectorNetwork,\n validateVectorNetwork,\n vectorNetworksEqual\n} from './vector-network'\n\nlet nextLocalID = 1\n\nexport function generateId(): string {\n return `0:${nextLocalID++}`\n}\n\nfunction stripUndefinedProps<T extends object>(obj: T): T {\n const result = {} as T\n for (const key of Object.keys(obj) as (keyof T)[]) {\n const val = obj[key]\n if (val !== undefined) {\n result[key] = val\n }\n }\n return result\n}\n\nexport { captureGraphCheckpoint } from './checkpoint'\n\nexport class SceneGraph {\n nodes = new Map<string, SceneNode>()\n images = new Map<string, Uint8Array>()\n variables = new Map<string, Variable>()\n variableCollections = new Map<string, VariableCollection>()\n activeMode = new Map<string, string>()\n rootId: string\n figKiwiVersion: number | null = null\n /** Deflated kiwi schema bytes from the original .fig file, preserved for roundtrip fidelity. */\n figSchemaDeflated: Uint8Array | null = null\n documentColorSpace: DocumentColorSpace = 'display-p3'\n enabledLibraries = new Map<string, EnabledLibraryBinding>()\n readonly emitter: Emitter<SceneGraphEvents> = createNanoEvents()\n private absPosCache = new Map<string, Vector>()\n private previewMutationDepth = 0\n private previewObservers: NodePreviewObserver[] = []\n private sourceMetadataPreservationDepth = 0\n private layoutMutationDepth = 0\n positionPreviewVersion = 0\n instanceIndex = new Map<string, Set<string>>()\n\n constructor() {\n const root = createDefaultNode(generateId, 'FRAME', {\n name: 'Document',\n width: 0,\n height: 0\n })\n this.rootId = root.id\n this.nodes.set(root.id, root)\n\n this.addPage('Page 1')\n }\n addPage(name: string): SceneNode {\n return this.createNode('CANVAS', this.rootId, { name, width: 0, height: 0 })\n }\n\n getPages(includeInternal = false): SceneNode[] {\n return this.getChildren(this.rootId).filter(\n (n) => n.type === 'CANVAS' && (includeInternal || !n.internalOnly)\n )\n }\n getAllNodes(): Iterable<SceneNode> {\n return this.nodes.values()\n }\n getNode(id: string): SceneNode | undefined {\n return this.nodes.get(id)\n }\n onNodeEvents(handlers: SceneGraphEventHandlers): () => void {\n return bindNodeEvents(this.emitter, handlers)\n }\n\n countDescendants(nodeId: string): number {\n const node = this.nodes.get(nodeId)\n if (!node) return 0\n let count = 0\n const stack = [...node.childIds]\n while (stack.length > 0) {\n const id = stack.pop()\n if (id === undefined) break\n count++\n const child = this.nodes.get(id)\n if (child) {\n for (const childId of child.childIds) {\n stack.push(childId)\n }\n }\n }\n return count\n }\n addVariable(variable: Variable): void {\n Variables.addVariable(this, variable)\n }\n removeVariable(id: string): void {\n Variables.removeVariable(this, id)\n }\n addCollection(collection: VariableCollection): void {\n Variables.addCollection(this, collection)\n }\n createVariable(\n name: string,\n type: VariableType,\n collectionId: string,\n value?: VariableValue\n ): Variable {\n return Variables.createVariable(this, generateId, name, type, collectionId, value)\n }\n\n createCollection(name: string): VariableCollection {\n return Variables.createCollection(this, generateId, name)\n }\n\n removeCollection(id: string): void {\n Variables.removeCollection(this, id)\n }\n\n getActiveModeId(collectionId: string): string {\n return Variables.getActiveModeId(this, collectionId)\n }\n\n getNodeVariableModeId(nodeId: string, collectionId: string): string {\n return Variables.getNodeVariableModeId(this, nodeId, collectionId)\n }\n\n setActiveMode(collectionId: string, modeId: string): void {\n Variables.setActiveMode(this, collectionId, modeId)\n }\n\n addMode(collectionId: string, modeId: string, name: string, sourceMode?: string): void {\n Variables.addMode(this, collectionId, modeId, name, sourceMode)\n }\n\n removeMode(collectionId: string, modeId: string): void {\n Variables.removeMode(this, collectionId, modeId)\n }\n\n renameMode(collectionId: string, modeId: string, name: string): void {\n Variables.renameMode(this, collectionId, modeId, name)\n }\n\n setDefaultMode(collectionId: string, modeId: string): void {\n Variables.setDefaultMode(this, collectionId, modeId)\n }\n\n resolveVariable(\n variableId: string,\n modeId?: string,\n visited?: Set<string>\n ): VariableValue | undefined {\n return Variables.resolveVariable(this, variableId, modeId, visited)\n }\n\n resolveColorVariable(variableId: string): Color | undefined {\n return Variables.resolveColorVariable(this, variableId)\n }\n\n resolveNumberVariable(variableId: string): number | undefined {\n return Variables.resolveNumberVariable(this, variableId)\n }\n\n resolveColorVariableForNode(nodeId: string, variableId: string): Color | undefined {\n return Variables.resolveColorVariableForNode(this, nodeId, variableId)\n }\n\n resolveNumberVariableForNode(nodeId: string, variableId: string): number | undefined {\n return Variables.resolveNumberVariableForNode(this, nodeId, variableId)\n }\n\n getVariablesForCollection(collectionId: string): Variable[] {\n return Variables.getVariablesForCollection(this, collectionId)\n }\n\n getVariablesByType(type: VariableType): Variable[] {\n return Variables.getVariablesByType(this, type)\n }\n\n bindVariable(nodeId: string, field: string, variableId: string): void {\n Variables.bindVariable(this, nodeId, field, variableId)\n }\n\n unbindVariable(nodeId: string, field: string): void {\n Variables.unbindVariable(this, nodeId, field)\n }\n\n getChildren(id: string): SceneNode[] {\n const node = this.nodes.get(id)\n if (!node) return []\n return node.childIds\n .map((cid) => this.nodes.get(cid))\n .filter((n): n is SceneNode => n !== undefined)\n }\n\n isContainer(id: string): boolean {\n const node = this.nodes.get(id)\n return node ? CONTAINER_TYPES.has(node.type) : false\n }\n\n isDescendant(childId: string, ancestorId: string): boolean {\n let current = this.nodes.get(childId)\n while (current) {\n if (current.id === ancestorId) return true\n current = current.parentId ? this.nodes.get(current.parentId) : undefined\n }\n return false\n }\n\n clearAbsPosCache(): void {\n this.absPosCache.clear()\n }\n\n getAbsolutePosition(id: string): Vector {\n const cached = this.absPosCache.get(id)\n if (cached) return cached\n\n const node = this.getNode(id)\n if (!node) return { x: 0, y: 0 }\n\n const result = getAbsolutePosition(node, this)\n this.absPosCache.set(id, result)\n return result\n }\n\n getAbsoluteBounds(id: string): Rect {\n const pos = this.getAbsolutePosition(id)\n const node = this.nodes.get(id)\n return {\n x: pos.x,\n y: pos.y,\n width: node?.width ?? 0,\n height: node?.height ?? 0\n }\n }\n private generateNodeId(): string {\n let id = generateId()\n while (this.nodes.has(id)) id = generateId()\n return id\n }\n private registerNode(node: SceneNode, parentId: string | null): SceneNode {\n node.parentId = parentId\n this.nodes.set(node.id, node)\n if (node.type === 'INSTANCE' && node.componentId) {\n let set = this.instanceIndex.get(node.componentId)\n if (!set) {\n set = new Set()\n this.instanceIndex.set(node.componentId, set)\n }\n set.add(node.id)\n }\n this.emitter.emit('node:created', node)\n return node\n }\n createNode(type: NodeType, parentId: string, overrides: Partial<SceneNode> = {}): SceneNode {\n const node = createDefaultNode(() => this.generateNodeId(), type, overrides)\n this.nodes.get(parentId)?.childIds.push(node.id)\n return this.registerNode(node, parentId)\n }\n createNodeWithId(\n id: string,\n type: NodeType,\n parentId: string | null,\n overrides: Partial<SceneNode> = {}\n ): SceneNode {\n const node = createDefaultNode(() => id, type, overrides)\n node.id = id\n const parent = parentId ? this.nodes.get(parentId) : undefined\n if (parent && !parent.childIds.includes(id)) parent.childIds.push(id)\n return this.registerNode(node, parentId)\n }\n\n static TEXT_PICTURE_KEYS: ReadonlySet<string> = TEXT_PICTURE_KEYS\n static GLYPH_AFFECTING_KEYS: ReadonlySet<string> = GLYPH_AFFECTING_KEYS\n\n static LAYOUT_AFFECTING_KEYS: ReadonlySet<string> = new Set([\n 'x',\n 'y',\n 'width',\n 'height',\n 'rotation',\n 'flipX',\n 'flipY',\n 'layoutMode',\n 'layoutDirection',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingLeft',\n 'paddingRight',\n 'paddingTop',\n 'paddingBottom',\n 'primaryAxisAlign',\n 'counterAxisAlign',\n 'counterAxisAlignContent',\n 'layoutWrap',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'layoutPositioning',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'strokesIncludedInLayout',\n 'horizontalConstraint',\n 'verticalConstraint',\n 'gridTemplateColumns',\n 'gridTemplateRows',\n 'gridColumnGap',\n 'gridRowGap',\n 'gridPosition',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight'\n ])\n\n runPreviewUpdates(fn: () => void, beforeUpdate?: NodePreviewObserver): void {\n this.previewMutationDepth++\n if (beforeUpdate) this.previewObservers.push(beforeUpdate)\n try {\n fn()\n } finally {\n if (beforeUpdate) this.previewObservers.pop()\n this.previewMutationDepth--\n }\n }\n preserveSourceMetadataDuring(fn: () => void): void {\n this.sourceMetadataPreservationDepth++\n try {\n fn()\n } finally {\n this.sourceMetadataPreservationDepth--\n }\n }\n withLayoutMutations(fn: () => void): void {\n this.layoutMutationDepth++\n try {\n fn()\n } finally {\n this.layoutMutationDepth--\n }\n }\n get isApplyingLayout(): boolean {\n return this.layoutMutationDepth > 0\n }\n updateNodePositionPreview(id: string, x: number, y: number): void {\n this.updateNodePreview(id, { x, y })\n }\n updateNodePreview(id: string, changes: Partial<SceneNode>): void {\n const appliedChanges = updateNodePreview(this, id, changes, (node, applied) => {\n for (const observe of this.previewObservers) observe(node, applied)\n })\n if (appliedChanges) this.emitter.emit('node:previewUpdated', id, appliedChanges)\n }\n\n updateNode(id: string, changes: Partial<SceneNode>): void {\n if (this.previewMutationDepth > 0) {\n this.updateNodePreview(id, changes)\n return\n }\n\n const node = this.nodes.get(id)\n if (!node) return\n changes = stripUndefinedProps(styleDetachmentChanges(node, stripUndefinedProps(changes)))\n this.applyNodeChanges(node, changes)\n }\n\n /** Replay captured properties without dropping explicit undefined values or absent keys. */\n restoreNodeProperties(\n id: string,\n changes: Partial<SceneNode>,\n absent: readonly (keyof SceneNode)[]\n ): void {\n const node = this.nodes.get(id)\n if (node) this.applyNodeChanges(node, changes, absent)\n }\n\n private applyNodeChanges(\n node: SceneNode,\n changes: Partial<SceneNode>,\n absent: readonly (keyof SceneNode)[] = []\n ): void {\n const { id } = node\n // Include removed keys in cache invalidation and update notifications.\n if (absent.length) {\n changes = { ...changes }\n for (const key of absent) Reflect.set(changes, key, undefined)\n }\n\n // Only clear absPosCache when layout-affecting properties change.\n // Fills, strokes, effects, plugin data changes do NOT affect absolute position.\n const affectsLayout = Object.keys(changes).some((k) => SceneGraph.LAYOUT_AFFECTING_KEYS.has(k))\n if (affectsLayout) this.absPosCache.clear()\n if (\n node.type === 'INSTANCE' &&\n 'componentId' in changes &&\n changes.componentId !== node.componentId\n ) {\n if (node.componentId) this.instanceIndex.get(node.componentId)?.delete(id)\n if (changes.componentId) {\n let set = this.instanceIndex.get(changes.componentId)\n if (!set) {\n set = new Set()\n this.instanceIndex.set(changes.componentId, set)\n }\n set.add(id)\n }\n }\n if (node.type === 'TEXT') invalidateTextCaches(node, changes)\n if (this.sourceMetadataPreservationDepth === 0) {\n markSourceFieldsEdited(node, Object.keys(changes))\n }\n if (changes.vectorNetwork) {\n changes = { ...changes, vectorNetwork: normalizeVectorNetwork(changes.vectorNetwork) }\n }\n Object.assign(node, changes)\n if (changes.fills) removeStaleBindings(node, 'fills', changes)\n if (changes.strokes) removeStaleBindings(node, 'strokes', changes)\n for (const key of absent) Reflect.deleteProperty(node, key)\n this.emitter.emit('node:updated', id, changes)\n }\n\n reparentNode(nodeId: string, newParentId: string): void {\n const node = this.nodes.get(nodeId)\n if (!node || nodeId === this.rootId) return\n if (this.isDescendant(newParentId, nodeId)) return\n\n const oldParent = node.parentId ? this.nodes.get(node.parentId) : undefined\n const newParent = this.nodes.get(newParentId)\n if (!newParent) return\n if (node.parentId === newParentId) return\n\n const oldParentId = node.parentId\n this.absPosCache.clear()\n\n const absPos = this.getAbsolutePosition(nodeId)\n const newParentNode = this.nodes.get(newParentId)\n const newParentAbs =\n newParentId === this.rootId || newParentNode?.type === 'CANVAS'\n ? { x: 0, y: 0 }\n : this.getAbsolutePosition(newParentId)\n\n if (oldParent) {\n oldParent.childIds = oldParent.childIds.filter((cid) => cid !== nodeId)\n }\n\n node.parentId = newParentId\n newParent.childIds.push(nodeId)\n\n node.x = absPos.x - newParentAbs.x\n node.y = absPos.y - newParentAbs.y\n\n this.emitter.emit('node:reparented', nodeId, oldParentId, newParentId)\n }\n\n reorderChild(nodeId: string, parentId: string, insertIndex: number): void {\n const node = this.nodes.get(nodeId)\n if (!node) return\n\n const previousParentId = node.parentId\n const oldParent = previousParentId ? this.nodes.get(previousParentId) : undefined\n const newParent = this.nodes.get(parentId)\n if (!newParent || this.isDescendant(parentId, nodeId)) return\n\n // Remove from old parent\n if (oldParent) {\n oldParent.childIds = oldParent.childIds.filter((cid) => cid !== nodeId)\n }\n\n // If same parent, adjust index since we removed the item\n let idx = insertIndex\n if (\n oldParent === newParent &&\n idx > (!oldParent.childIds.includes(nodeId) ? idx : oldParent.childIds.length)\n ) {\n // Already removed above, no adjustment needed\n }\n\n node.parentId = parentId\n this.absPosCache.clear()\n idx = Math.min(idx, newParent.childIds.length)\n newParent.childIds.splice(idx, 0, nodeId)\n\n this.emitter.emit('node:reordered', nodeId, parentId, idx, previousParentId)\n }\n\n insertChildAt(childId: string, parentId: string, index: number): void {\n const node = this.getNode(childId)\n const newParent = this.getNode(parentId)\n if (!node || !newParent || childId === parentId || this.isDescendant(parentId, childId)) return\n const previousParentId = node.parentId\n const oldParent = previousParentId ? this.getNode(previousParentId) : undefined\n if (oldParent) {\n oldParent.childIds = oldParent.childIds.filter((id) => id !== childId)\n }\n newParent.childIds = newParent.childIds.filter((id) => id !== childId)\n newParent.childIds.splice(index, 0, childId)\n node.parentId = parentId\n this.clearAbsPosCache()\n this.emitter.emit('node:reordered', childId, parentId, index, previousParentId)\n }\n\n deleteNode(id: string): void {\n const node = this.nodes.get(id)\n if (!node || id === this.rootId) return\n\n if (node.parentId) {\n const parent = this.nodes.get(node.parentId)\n if (parent) {\n parent.childIds = parent.childIds.filter((cid) => cid !== id)\n }\n }\n\n for (const childId of Array.from(node.childIds)) {\n this.deleteNode(childId)\n }\n\n if (node.type === 'INSTANCE' && node.componentId) {\n this.instanceIndex.get(node.componentId)?.delete(id)\n }\n this.nodes.delete(id)\n this.emitter.emit('node:deleted', id, node.parentId)\n }\n\n hitTest(px: number, py: number, scopeId?: string): SceneNode | null {\n return HitTest.hitTest(this, px, py, scopeId)\n }\n\n hitTestDeep(px: number, py: number, scopeId?: string): SceneNode | null {\n return HitTest.hitTestDeep(this, px, py, scopeId)\n }\n\n hitTestFrame(\n px: number,\n py: number,\n excludeIds: Set<string>,\n scopeId?: string\n ): SceneNode | null {\n return HitTest.hitTestFrame(this, px, py, excludeIds, scopeId)\n }\n\n cloneTree(\n sourceId: string,\n parentId: string,\n overrides: Partial<SceneNode> = {}\n ): SceneNode | null {\n const src = this.nodes.get(sourceId)\n if (!src) return null\n\n const props = cloneNodeProps(src, null)\n // Null out Figma source identifiers so the clone is treated as local.\n // `as SourceMetadata` required: cloneNodeProps returns Partial<SceneNode>,\n // so props.source is SourceMetadata | undefined, but we know it's always set.\n props.source = { ...(props.source as SourceMetadata), id: null, orderKey: null }\n const clone = this.createNode(src.type, parentId, { ...props, ...overrides })\n\n for (const childId of src.childIds) {\n this.cloneTree(childId, clone.id)\n }\n\n return clone\n }\n\n createInstance(\n componentId: string,\n parentId: string,\n overrides: Partial<SceneNode> = {}\n ): SceneNode | null {\n return Instances.createInstance(this, componentId, parentId, overrides)\n }\n\n populateInstanceChildren(\n instanceId: string,\n componentId: string,\n mode: Instances.NodeCloneMode = 'deep'\n ): void {\n Instances.populateInstanceChildren(this, instanceId, componentId, mode)\n }\n\n swapInstanceComponent(instanceId: string, componentId: string): void {\n Instances.swapInstanceComponent(this, instanceId, componentId)\n }\n\n syncInstances(componentId: string): void {\n Instances.syncInstances(this, componentId)\n }\n\n detachInstance(instanceId: string): void {\n Instances.detachInstance(this, instanceId)\n }\n\n getMainComponent(instanceId: string): SceneNode | undefined {\n return Instances.getMainComponent(this, instanceId)\n }\n\n getInstances(componentId: string): SceneNode[] {\n return Instances.getInstances(this, componentId)\n }\n\n flattenTree(parentId?: string, depth = 0): Array<{ node: SceneNode; depth: number }> {\n const id = parentId ?? this.rootId\n const parent = this.nodes.get(id)\n if (!parent) return []\n const result: Array<{ node: SceneNode; depth: number }> = []\n for (const childId of parent.childIds) {\n const child = this.nodes.get(childId)\n if (!child) continue\n result.push({ node: child, depth })\n if (child.childIds.length > 0) result.push(...this.flattenTree(childId, depth + 1))\n }\n return result\n }\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,4BAAiD;CAC/D,OAAO;EACL,gCAAgB,IAAI,IAAI;EACxB,mCAAmB,IAAI,IAAI;EAC3B,kCAAkB,IAAI,IAAI;EAC1B,gCAAgB,IAAI,IAAI;EACxB,gCAAgB,IAAI,IAAI;CAC1B;AACF;;AAUA,eAAsB,qBACpB,OACA,WACoC;CACpC,MAAM,SAAS,0BAA0B;CACzC,MAAM,SAAS,MAAM,aAAa;EAChC,UAAU,SAAS;GACjB,OAAO,eAAe,IAAI,KAAK,EAAE;GACjC,OAAO,eAAe,IAAI,KAAK,EAAE;GACjC,IAAI,KAAK,UAAU,OAAO,iBAAiB,IAAI,KAAK,QAAQ;EAC9D;EACA,UAAU,OAAO,OAAO,eAAe,IAAI,EAAE;EAC7C,UAAU,IAAI,aAAa;GACzB,IAAI,UAAU,OAAO,kBAAkB,IAAI,QAAQ;GACnD,OAAO,eAAe,IAAI,EAAE;GAC5B,OAAO,eAAe,IAAI,EAAE;EAC9B;EACA,aAAa,QAAQ,aAAa,gBAAgB;GAChD,OAAO,eAAe,IAAI,MAAM;GAChC,IAAI,aAAa,OAAO,kBAAkB,IAAI,WAAW;GACzD,OAAO,iBAAiB,IAAI,WAAW;EACzC;EACA,YAAY,QAAQ,UAAU,QAAQ,qBAAqB;GACzD,OAAO,eAAe,IAAI,MAAM;GAChC,IAAI,oBAAoB,qBAAqB,UAC3C,OAAO,kBAAkB,IAAI,gBAAgB;GAE/C,OAAO,iBAAiB,I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sBAAsB,YAAoB,aAA2B;EACnE,sBAAgC,MAAM,YAAY,WAAW;CAC/D;CAEA,cAAc,aAA2B;EACvC,cAAwB,MAAM,WAAW;CAC3C;CAEA,eAAe,YAA0B;EACvC,eAAyB,MAAM,UAAU;CAC3C;CAEA,iBAAiB,YAA2C;EAC1D,OAAOC,iBAA2B,MAAM,UAAU;CACpD;CAEA,aAAa,aAAkC;EAC7C,OAAOC,aAAuB,MAAM,WAAW;CACjD;CAEA,YAAY,UAAmB,QAAQ,GAA8C;EACnF,MAAM,KAAK,YAAY,KAAK;EAC5B,MAAM,SAAS,KAAK,MAAM,IAAI,EAAE;EAChC,IAAI,CAAC,QAAQ,OAAO,CAAC;EACrB,MAAM,SAAoD,CAAC;EAC3D,KAAK,MAAM,WAAW,OAAO,UAAU;GACrC,MAAM,QAAQ,KAAK,MAAM,IAAI,OAAO;GACpC,IAAI,CAAC,OAAO;GACZ,OAAO,KAAK;IAAE,MAAM;IAAO;GAAM,CAAC;GAClC,IAAI,MAAM,SAAS,SAAS,GAAG,OAAO,KAAK,GAAG,KAAK,YAAY,SAAS,QAAQ,CAAC,CAAC;EACpF;EACA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"index.js","names":["Variables.createVariable","Variables.createCollection","Variables.getActiveModeId","Variables.getNodeVariableModeId","Variables.resolveVariable","Variables.resolveColorVariable","Variables.resolveNumberVariable","Variables.resolveColorVariableForNode","Variables.resolveNumberVariableForNode","Variables.getVariablesForCollection","Variables.getVariablesByType","HitTest.hitTest","HitTest.hitTestDeep","HitTest.hitTestFrame","Instances.createInstance","Instances.getMainComponent","Instances.getInstances"],"sources":["../../src/mutation-impact.ts","../../src/snap.ts","../../src/layout-guides.ts","../../src/shared-styles.ts","../../src/undo.ts","../../src/text-picture.ts","../../src/preview.ts","../../src/source-metadata.ts","../../src/variables.ts","../../src/index.ts"],"sourcesContent":["import type { SceneGraph } from './index'\n\nexport interface SceneMutationImpact {\n changedNodeIds: Set<string>\n previousParentIds: Set<string>\n currentParentIds: Set<string>\n createdNodeIds: Set<string>\n deletedNodeIds: Set<string>\n}\n\nexport function createSceneMutationImpact(): SceneMutationImpact {\n return {\n changedNodeIds: new Set(),\n previousParentIds: new Set(),\n currentParentIds: new Set(),\n createdNodeIds: new Set(),\n deletedNodeIds: new Set()\n }\n}\n\nexport type MutationImpactListener = (impact: SceneMutationImpact) => void\n\nexport interface CollectedSceneMutation<T> {\n result: T\n impact: SceneMutationImpact\n}\n\n/** Collects the actual graph nodes and parent containers touched by an operation. */\nexport async function collectSceneMutation<T>(\n graph: SceneGraph,\n operation: () => T | Promise<T>\n): Promise<CollectedSceneMutation<T>> {\n const impact = createSceneMutationImpact()\n const unbind = graph.onNodeEvents({\n created: (node) => {\n impact.createdNodeIds.add(node.id)\n impact.changedNodeIds.add(node.id)\n if (node.parentId) impact.currentParentIds.add(node.parentId)\n },\n updated: (id) => impact.changedNodeIds.add(id),\n deleted: (id, parentId) => {\n if (parentId) impact.previousParentIds.add(parentId)\n impact.deletedNodeIds.add(id)\n impact.changedNodeIds.add(id)\n },\n reparented: (nodeId, oldParentId, newParentId) => {\n impact.changedNodeIds.add(nodeId)\n if (oldParentId) impact.previousParentIds.add(oldParentId)\n impact.currentParentIds.add(newParentId)\n },\n reordered: (nodeId, parentId, _index, previousParentId) => {\n impact.changedNodeIds.add(nodeId)\n if (previousParentId && previousParentId !== parentId) {\n impact.previousParentIds.add(previousParentId)\n }\n impact.currentParentIds.add(parentId)\n }\n })\n try {\n return { result: await operation(), impact }\n } finally {\n unbind()\n }\n}\n\nexport function mutationLayoutScopeIds(impact: SceneMutationImpact): string[] {\n return [\n ...new Set([...impact.changedNodeIds, ...impact.previousParentIds, ...impact.currentParentIds])\n ]\n}\n","import type { SceneNode } from './'\nimport { rotatedBBox } from './geometry'\nimport type { Rect } from './primitives'\n\nconst DEFAULT_SNAP_THRESHOLD = 5\n\nexport interface SnapGuide {\n axis: 'x' | 'y'\n position: number\n from: number\n to: number\n}\n\nexport interface SnapResult {\n dx: number\n dy: number\n guides: SnapGuide[]\n}\n\nfunction getEdges(node: SceneNode) {\n return rotatedBBox(node.x, node.y, node.width, node.height, node.rotation)\n}\n\n// Pairwise edge/center matching intentionally keeps both axes in one pass.\n// eslint-disable-next-line complexity\nexport function computeSnap(\n movingIds: Set<string>,\n movingBounds: Rect,\n allNodes: SceneNode[],\n threshold = DEFAULT_SNAP_THRESHOLD\n): SnapResult {\n const targets = allNodes.filter((n) => !movingIds.has(n.id))\n if (targets.length === 0) return { dx: 0, dy: 0, guides: [] }\n\n const m = {\n left: movingBounds.x,\n right: movingBounds.x + movingBounds.width,\n centerX: movingBounds.x + movingBounds.width / 2,\n top: movingBounds.y,\n bottom: movingBounds.y + movingBounds.height,\n centerY: movingBounds.y + movingBounds.height / 2\n }\n\n let bestDx = Infinity\n let bestDy = Infinity\n const guides: SnapGuide[] = []\n\n for (const target of targets) {\n const t = getEdges(target)\n\n // X-axis snapping: left-to-left, left-to-right, right-to-left, right-to-right, center-to-center\n const xPairs: [number, number][] = [\n [m.left, t.left],\n [m.left, t.right],\n [m.right, t.left],\n [m.right, t.right],\n [m.centerX, t.centerX]\n ]\n\n for (const [mVal, tVal] of xPairs) {\n const d = tVal - mVal\n if (Math.abs(d) < threshold && Math.abs(d) <= Math.abs(bestDx)) {\n if (Math.abs(d) < Math.abs(bestDx)) {\n bestDx = d\n guides.length = guides.filter((g) => g.axis === 'y').length\n ? guides.length\n : guides.length\n // Remove old x guides if we found a closer snap\n for (let i = guides.length - 1; i >= 0; i--) {\n if (guides[i].axis === 'x') guides.splice(i, 1)\n }\n }\n if (Math.abs(d) === Math.abs(bestDx)) {\n const minY = Math.min(m.top, t.top)\n const maxY = Math.max(m.bottom, t.bottom)\n guides.push({ axis: 'x', position: tVal, from: minY, to: maxY })\n }\n }\n }\n\n // Y-axis snapping\n const yPairs: [number, number][] = [\n [m.top, t.top],\n [m.top, t.bottom],\n [m.bottom, t.top],\n [m.bottom, t.bottom],\n [m.centerY, t.centerY]\n ]\n\n for (const [mVal, tVal] of yPairs) {\n const d = tVal - mVal\n if (Math.abs(d) < threshold && Math.abs(d) <= Math.abs(bestDy)) {\n if (Math.abs(d) < Math.abs(bestDy)) {\n for (let i = guides.length - 1; i >= 0; i--) {\n if (guides[i].axis === 'y') guides.splice(i, 1)\n }\n bestDy = d\n }\n if (Math.abs(d) === Math.abs(bestDy)) {\n const minX = Math.min(m.left, t.left)\n const maxX = Math.max(m.right, t.right)\n guides.push({ axis: 'y', position: tVal, from: minX, to: maxX })\n }\n }\n }\n }\n\n return {\n dx: Math.abs(bestDx) <= threshold ? bestDx : 0,\n dy: Math.abs(bestDy) <= threshold ? bestDy : 0,\n guides\n }\n}\n\nexport function computeSelectionBounds(nodes: SceneNode[]): Rect | null {\n if (nodes.length === 0) return null\n let minX = Infinity\n let minY = Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n for (const n of nodes) {\n const edges = getEdges(n)\n minX = Math.min(minX, edges.left)\n minY = Math.min(minY, edges.top)\n maxX = Math.max(maxX, edges.right)\n maxY = Math.max(maxY, edges.bottom)\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }\n}\n","import type { LayoutGrid, SceneNode } from './types'\n\nexport interface LayoutGuideLine {\n axis: 'x' | 'y'\n position: number\n}\n\nconst MAX_LAYOUT_GUIDE_LINES = 10_000\n\nfunction normalizedCount(grid: LayoutGrid): number {\n const value = grid.count ?? grid.numSections ?? 1\n if (!Number.isFinite(value)) return 0\n return Math.min(MAX_LAYOUT_GUIDE_LINES, Math.max(0, Math.floor(value)))\n}\n\nfunction pattern(grid: LayoutGrid): 'COLUMNS' | 'ROWS' | 'GRID' {\n if (grid.pattern === 'GRID' || grid.pattern === 'ROWS') return grid.pattern\n if (grid.axis === 'Y') return 'ROWS'\n return 'COLUMNS'\n}\n\nfunction alignment(grid: LayoutGrid): 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' {\n const value = grid.alignment ?? grid.type\n if (value === 'CENTER' || value === 'MAX' || value === 'STRETCH') return value\n return 'MIN'\n}\n\nfunction sectionSize(nodeSize: number, grid: LayoutGrid): number {\n const fixed = grid.sectionSize ?? 0\n if (alignment(grid) !== 'STRETCH') return fixed\n const count = normalizedCount(grid)\n const gutter = grid.gutterSize ?? 0\n const offset = grid.offset ?? 0\n return (nodeSize - offset * 2 - Math.max(0, count - 1) * gutter) / count\n}\n\nfunction start(nodeSize: number, grid: LayoutGrid, size: number): number {\n const count = normalizedCount(grid)\n const gutter = grid.gutterSize ?? 0\n const offset = grid.offset ?? 0\n const span = count * size + Math.max(0, count - 1) * gutter\n if (alignment(grid) === 'CENTER') return (nodeSize - span) / 2 + offset\n if (alignment(grid) === 'MAX') return nodeSize - span - offset\n return offset\n}\n\nexport interface LayoutGuideSection {\n axis: 'x' | 'y'\n start: number\n end: number\n}\n\nexport function layoutGuideSections(\n node: Pick<SceneNode, 'width' | 'height'>,\n grid: LayoutGrid\n): LayoutGuideSection[] {\n if (grid.visible === false || pattern(grid) === 'GRID') return []\n const axis = pattern(grid) === 'ROWS' ? 'y' : 'x'\n const nodeSize = axis === 'x' ? node.width : node.height\n const size = sectionSize(nodeSize, grid)\n const count = normalizedCount(grid)\n if (count <= 0 || size <= 0) return []\n const first = start(nodeSize, grid, size)\n const step = size + (grid.gutterSize ?? 0)\n return Array.from({ length: count }, (_, index) => {\n const sectionStart = first + index * step\n return { axis, start: sectionStart, end: sectionStart + size }\n })\n}\n\nexport function layoutGuideLines(node: Pick<SceneNode, 'width' | 'height'>, grid: LayoutGrid) {\n if (grid.visible === false) return []\n const gridPattern = pattern(grid)\n const lines: LayoutGuideLine[] = []\n if (gridPattern === 'GRID') {\n const size = grid.sectionSize ?? 0\n if (size <= 0) return lines\n for (\n let index = 0, x = grid.offset ?? 0;\n x <= node.width && index < MAX_LAYOUT_GUIDE_LINES;\n index++, x += size\n ) {\n lines.push({ axis: 'x', position: x })\n }\n for (\n let index = 0, y = grid.offset ?? 0;\n y <= node.height && index < MAX_LAYOUT_GUIDE_LINES;\n index++, y += size\n ) {\n lines.push({ axis: 'y', position: y })\n }\n return lines\n }\n\n const sections = layoutGuideSections(node, grid)\n for (const section of sections) {\n lines.push(\n { axis: section.axis, position: section.start },\n { axis: section.axis, position: section.end }\n )\n }\n return lines\n}\n","import type { SceneGraph, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType } from './index'\n\nconst STYLE_REF_KEYS = {\n fill: 'fillStyleId',\n stroke: 'strokeStyleId',\n text: 'textStyleId',\n effect: 'effectStyleId',\n grid: 'gridStyleId'\n} as const satisfies Record<SharedStyleKind, keyof SceneNode>\n\nconst STYLE_TYPES = {\n fill: 'FILL',\n stroke: 'FILL',\n text: 'TEXT',\n effect: 'EFFECT',\n grid: 'GRID'\n} as const satisfies Record<SharedStyleKind, SharedStyleType>\n\nconst TEXT_STYLE_KEYS = new Set<keyof SceneNode>([\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textDecoration',\n 'textCase',\n 'fontFeatures'\n])\n\nexport function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind] {\n return STYLE_REF_KEYS[kind]\n}\n\nexport function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType {\n return STYLE_TYPES[kind]\n}\n\nexport function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[] {\n const type = sharedStyleTypeForKind(kind)\n const styles: SharedStyle[] = []\n for (const node of graph.getAllNodes()) {\n if (node.sharedStyleType !== type || !node.source.id) continue\n styles.push({ id: node.source.id, nodeId: node.id, name: node.name, type })\n }\n return styles.sort((left, right) => left.name.localeCompare(right.name))\n}\n\nexport function styleDetachmentChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const next = { ...changes }\n if ('fills' in changes && !('fillStyleId' in changes) && node.fillStyleId) {\n next.fillStyleId = null\n }\n if ('strokes' in changes && !('strokeStyleId' in changes) && node.strokeStyleId) {\n next.strokeStyleId = null\n }\n if ('effects' in changes && !('effectStyleId' in changes) && node.effectStyleId) {\n next.effectStyleId = null\n }\n if ('layoutGrids' in changes && !('gridStyleId' in changes) && node.gridStyleId) {\n next.gridStyleId = null\n }\n const changesTextStyle = (Object.keys(changes) as (keyof SceneNode)[]).some((key) =>\n TEXT_STYLE_KEYS.has(key)\n )\n if (changesTextStyle && !('textStyleId' in changes) && node.textStyleId) {\n next.textStyleId = null\n }\n return next\n}\n","export interface UndoEntry {\n label: string\n forward: () => void\n inverse: () => void\n coalesceKey?: string\n}\n\nexport interface UndoManagerOptions {\n limit?: number\n /** Called after recording, undoing, redoing, or clearing committed history. */\n onChange?: () => void\n}\n\ninterface UndoBatch {\n label: string\n entries: UndoEntry[]\n coalesceKey?: string\n}\n\nconst DEFAULT_HISTORY_LIMIT = 200\n\nexport class UndoManager {\n private undoStack: UndoEntry[] = []\n private redoStack: UndoEntry[] = []\n private batches: UndoBatch[] = []\n private readonly limit: number\n private readonly onChange: (() => void) | undefined\n\n constructor(options: UndoManagerOptions = {}) {\n this.limit = options.limit ?? DEFAULT_HISTORY_LIMIT\n this.onChange = options.onChange\n }\n\n apply(entry: UndoEntry): void {\n this.execute(entry)\n }\n\n execute(entry: UndoEntry): void {\n entry.forward()\n this.record(entry)\n }\n\n push(entry: UndoEntry): void {\n this.record(entry)\n }\n\n record(entry: UndoEntry): void {\n const batch = this.currentBatch\n if (batch) {\n batch.entries.push(entry)\n return\n }\n this.pushUndoEntry(entry)\n }\n\n undo(): string | null {\n const entry = this.undoStack.pop()\n if (!entry) return null\n entry.inverse()\n this.redoStack.push(entry)\n this.onChange?.()\n return entry.label\n }\n\n redo(): string | null {\n const entry = this.redoStack.pop()\n if (!entry) return null\n entry.forward()\n this.undoStack.push(entry)\n this.onChange?.()\n return entry.label\n }\n\n beginBatch(label: string, coalesceKey?: string): void {\n this.batches.push({ label, entries: [], coalesceKey })\n }\n\n commitBatch(): void {\n const batch = this.batches.pop()\n if (!batch || batch.entries.length === 0) return\n\n const entry = this.createBatchEntry(batch)\n const parentBatch = this.currentBatch\n if (parentBatch) parentBatch.entries.push(entry)\n else this.pushUndoEntry(entry)\n }\n\n runBatch<T>(label: string, fn: () => T, coalesceKey?: string): T {\n this.beginBatch(label, coalesceKey)\n try {\n const result = fn()\n this.commitBatch()\n return result\n } catch (error) {\n this.rollbackBatch()\n throw error\n }\n }\n\n rollbackBatch(): void {\n const batch = this.batches.pop()\n if (!batch) return\n for (const entry of batch.entries.toReversed()) entry.inverse()\n }\n\n /** Abandon provisional history without replaying it or changing committed undo/redo entries. */\n discardBatches(): void {\n this.batches = []\n }\n\n clear(): void {\n this.undoStack = []\n this.redoStack = []\n this.discardBatches()\n this.onChange?.()\n }\n\n get isBatching(): boolean {\n return this.batches.length > 0\n }\n\n get canUndo(): boolean {\n return this.undoStack.length > 0\n }\n\n get canRedo(): boolean {\n return this.redoStack.length > 0\n }\n\n get undoLabel(): string | null {\n return this.undoStack.at(-1)?.label ?? null\n }\n\n get redoLabel(): string | null {\n return this.redoStack.at(-1)?.label ?? null\n }\n\n private get currentBatch(): UndoBatch | null {\n return this.batches.at(-1) ?? null\n }\n\n private createBatchEntry(batch: UndoBatch): UndoEntry {\n return {\n label: batch.label,\n forward: () => batch.entries.forEach((entry) => entry.forward()),\n inverse: () => batch.entries.toReversed().forEach((entry) => entry.inverse()),\n coalesceKey: batch.coalesceKey\n }\n }\n\n private pushUndoEntry(entry: UndoEntry): void {\n const previous = this.undoStack.at(-1)\n if (entry.coalesceKey && previous?.coalesceKey === entry.coalesceKey) {\n this.undoStack[this.undoStack.length - 1] = {\n ...entry,\n inverse: previous.inverse\n }\n } else {\n this.undoStack.push(entry)\n }\n this.redoStack = []\n this.trimUndoStack()\n this.onChange?.()\n }\n\n private trimUndoStack(): void {\n if (!Number.isFinite(this.limit) || this.limit <= 0) return\n const overflow = this.undoStack.length - this.limit\n if (overflow > 0) this.undoStack.splice(0, overflow)\n }\n}\n","import type { SceneNode } from './types'\n\n/**\n * Invalidate cached Skia textPicture (Paragraph snapshot). Includes width/height\n * because wrapping/layout depends on the box.\n */\nexport const TEXT_PICTURE_KEYS: ReadonlySet<string> = new Set([\n 'text',\n 'fontSize',\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'textAlignHorizontal',\n 'textDirection',\n 'textAlignVertical',\n 'lineHeight',\n 'letterSpacing',\n 'textDecoration',\n 'textCase',\n 'styleRuns',\n 'fills',\n 'width',\n 'height'\n])\n\nexport const GLYPH_AFFECTING_KEYS: ReadonlySet<string> = new Set([\n 'text',\n 'fontSize',\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'textDirection',\n 'lineHeight',\n 'letterSpacing',\n 'textCase',\n 'styleRuns'\n])\n\n/**\n * Shared by SceneGraph.updateNode and updateNodePreview (drag hot path) so the\n * two invalidation rules cannot drift. Glyphs are kept when the caller\n * replaces them in the same update (resize supplies scaled copies).\n */\nexport function textCacheInvalidationChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const invalidated: Partial<SceneNode> = {}\n const keys = Object.keys(changes)\n if (node.textPicture && keys.some((key) => TEXT_PICTURE_KEYS.has(key)))\n invalidated.textPicture = null\n const glyphsInvalidated = keys.some((key) => GLYPH_AFFECTING_KEYS.has(key))\n // A successful path-text edit supplies reflowed glyphs in `changes`. Every\n // other mutation path must drop stale baked glyphs and path identity rather\n // than pair new text/style with old visible outlines.\n if (node.derivedTextGlyphs && glyphsInvalidated && !changes.derivedTextGlyphs) {\n invalidated.derivedTextGlyphs = null\n invalidated.textPathData = null\n }\n return invalidated\n}\n\nexport function invalidateTextCaches(node: SceneNode, changes: Partial<SceneNode>): void {\n Object.assign(node, textCacheInvalidationChanges(node, changes))\n}\n","import { textCacheInvalidationChanges } from './text-picture'\nimport type { SceneNode } from './types'\nimport { normalizeVectorNetwork } from './vector-network'\n\nexport type NodePreviewObserver = (node: SceneNode, changes: Partial<SceneNode>) => void\n\ntype PreviewGraph = {\n nodes: Map<string, SceneNode>\n positionPreviewVersion: number\n clearAbsPosCache: () => void\n}\n\nconst LAYOUT_AFFECTING_KEYS = new Set<string>([\n 'x',\n 'y',\n 'width',\n 'height',\n 'rotation',\n 'flipX',\n 'flipY',\n 'parentId',\n 'childIds',\n 'layoutMode',\n 'layoutDirection',\n 'layoutWrap',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'layoutPositioning',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'visible',\n 'text',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'styleRuns',\n 'textAutoResize'\n])\n\nexport function updateNodePreview(\n graph: PreviewGraph,\n id: string,\n changes: Partial<SceneNode>,\n beforeUpdate?: NodePreviewObserver\n): Partial<SceneNode> | null {\n const node = graph.nodes.get(id)\n if (!node) return null\n changes = Object.fromEntries(\n (Object.entries(changes) as Array<[string, unknown]>).filter(([, value]) => value !== undefined)\n ) as Partial<SceneNode>\n if ((Object.keys(changes) as (keyof SceneNode)[]).every((key) => node[key] === changes[key])) {\n return null\n }\n const affectsLayout = Object.keys(changes).some((key) => LAYOUT_AFFECTING_KEYS.has(key))\n if (affectsLayout) graph.clearAbsPosCache()\n let normalizedChanges = changes\n if (node.type === 'TEXT') {\n normalizedChanges = { ...textCacheInvalidationChanges(node, changes), ...changes }\n }\n if (changes.vectorNetwork) {\n normalizedChanges = {\n ...normalizedChanges,\n vectorNetwork: normalizeVectorNetwork(changes.vectorNetwork)\n }\n }\n beforeUpdate?.(node, normalizedChanges)\n graph.positionPreviewVersion++\n Object.assign(node, normalizedChanges)\n return normalizedChanges\n}\n","import type { SceneNode } from './types'\n\nexport function markSourceFieldsEdited(node: SceneNode, changeKeys: string[]): void {\n if (changeKeys.length === 0) return\n const editedFields = new Set(node.source.editedFields)\n for (const key of changeKeys) editedFields.add(key)\n node.source.editedFields = [...editedFields]\n}\n","import { omit, omitBy } from 'es-toolkit/object'\n\nimport { BLACK } from './constants'\nimport type { SceneGraph } from './index'\nimport { setInstanceOverride } from './instance-overrides'\nimport type { Color } from './primitives'\nimport type { Variable, VariableCollection, VariableType, VariableValue } from './types'\n\nexport function addVariable(graph: SceneGraph, variable: Variable): void {\n graph.variables.set(variable.id, variable)\n const collection = graph.variableCollections.get(variable.collectionId)\n if (collection && !collection.variableIds.includes(variable.id)) {\n collection.variableIds.push(variable.id)\n }\n}\n\nexport function removeVariable(graph: SceneGraph, id: string): void {\n const variable = graph.variables.get(id)\n if (!variable) return\n graph.variables.delete(id)\n const collection = graph.variableCollections.get(variable.collectionId)\n if (collection) {\n collection.variableIds = collection.variableIds.filter((vid) => vid !== id)\n }\n for (const node of graph.nodes.values()) {\n const hadBinding = Object.values(node.boundVariables).includes(id)\n if (!hadBinding) continue\n node.boundVariables = omitBy(node.boundVariables, (varId) => varId === id) as Record<\n string,\n string\n >\n graph.emitter.emit('node:updated', node.id, { boundVariables: { ...node.boundVariables } })\n markBoundVariablesOverrideOnInstance(graph, node.id)\n }\n}\n\nexport function addCollection(graph: SceneGraph, collection: VariableCollection): void {\n graph.variableCollections.set(collection.id, collection)\n if (!graph.activeMode.has(collection.id)) {\n graph.activeMode.set(collection.id, collection.defaultModeId)\n }\n}\n\nfunction defaultVariableValue(type: VariableType, value?: VariableValue): VariableValue {\n if (value !== undefined) return value\n if (type === 'COLOR') return { ...BLACK }\n if (type === 'FLOAT') return 0\n if (type === 'BOOLEAN') return false\n return ''\n}\n\nexport function createVariable(\n graph: SceneGraph,\n generateId: () => string,\n name: string,\n type: VariableType,\n collectionId: string,\n value?: VariableValue\n): Variable {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) throw new Error(`Collection \"${collectionId}\" not found`)\n const id = generateId()\n const defaultValue = defaultVariableValue(type, value)\n const valuesByMode: Record<string, VariableValue> = {}\n for (const mode of collection.modes) {\n valuesByMode[mode.modeId] = structuredClone(defaultValue)\n }\n const variable: Variable = {\n id,\n name,\n type,\n collectionId,\n valuesByMode,\n description: '',\n hiddenFromPublishing: false\n }\n addVariable(graph, variable)\n return variable\n}\n\nexport function createCollection(\n graph: SceneGraph,\n generateId: () => string,\n name: string\n): VariableCollection {\n const id = generateId()\n const modeId = generateId()\n const collection: VariableCollection = {\n id,\n name,\n modes: [{ modeId, name: 'Mode 1' }],\n defaultModeId: modeId,\n variableIds: []\n }\n addCollection(graph, collection)\n return collection\n}\n\nexport function removeCollection(graph: SceneGraph, id: string): void {\n const collection = graph.variableCollections.get(id)\n if (collection) {\n for (const varId of Array.from(collection.variableIds)) {\n removeVariable(graph, varId)\n }\n }\n graph.variableCollections.delete(id)\n graph.activeMode.delete(id)\n}\n\nexport function getActiveModeId(graph: SceneGraph, collectionId: string): string {\n const mode = graph.activeMode.get(collectionId)\n if (mode) return mode\n const collection = graph.variableCollections.get(collectionId)\n return collection?.defaultModeId ?? ''\n}\n\nexport function getNodeVariableModeId(\n graph: SceneGraph,\n nodeId: string,\n collectionId: string\n): string {\n let node = graph.nodes.get(nodeId)\n while (node) {\n const modeId = node.variableModes[collectionId]\n if (modeId) return modeId\n node = node.parentId ? graph.nodes.get(node.parentId) : undefined\n }\n return getActiveModeId(graph, collectionId)\n}\n\nexport function setActiveMode(graph: SceneGraph, collectionId: string, modeId: string): void {\n graph.activeMode.set(collectionId, modeId)\n}\n\nexport function addMode(\n graph: SceneGraph,\n collectionId: string,\n modeId: string,\n name: string,\n sourceMode?: string\n): void {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) return\n collection.modes.push({ modeId, name })\n const sourceModeId = sourceMode ?? collection.defaultModeId\n for (const varId of collection.variableIds) {\n const variable = graph.variables.get(varId)\n if (!variable) continue\n variable.valuesByMode[modeId] = structuredClone(\n variable.valuesByMode[sourceModeId] ?? Object.values(variable.valuesByMode)[0]\n )\n }\n}\n\nexport function removeMode(graph: SceneGraph, collectionId: string, modeId: string): void {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection || collection.modes.length <= 1) return\n collection.modes = collection.modes.filter((m) => m.modeId !== modeId)\n if (collection.defaultModeId === modeId) {\n collection.defaultModeId = collection.modes[0].modeId\n }\n for (const varId of collection.variableIds) {\n const variable = graph.variables.get(varId)\n if (variable) variable.valuesByMode = omit(variable.valuesByMode, [modeId])\n }\n if (graph.activeMode.get(collectionId) === modeId) {\n graph.activeMode.set(collectionId, collection.defaultModeId)\n }\n}\n\nexport function renameMode(\n graph: SceneGraph,\n collectionId: string,\n modeId: string,\n name: string\n): void {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) return\n const mode = collection.modes.find((m) => m.modeId === modeId)\n if (mode) mode.name = name\n}\n\nexport function setDefaultMode(graph: SceneGraph, collectionId: string, modeId: string): void {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) return\n if (!collection.modes.some((m) => m.modeId === modeId)) return\n collection.defaultModeId = modeId\n}\n\nexport function resolveVariable(\n graph: SceneGraph,\n variableId: string,\n modeId?: string,\n visited?: Set<string>\n): VariableValue | undefined {\n if (visited?.has(variableId)) return undefined\n const variable = graph.variables.get(variableId)\n if (!variable) return undefined\n const collection = graph.variableCollections.get(variable.collectionId)\n const preferredModeId = modeId ?? getActiveModeId(graph, variable.collectionId)\n const fallbackModeId = collection?.defaultModeId\n let value = Object.hasOwn(variable.valuesByMode, preferredModeId)\n ? variable.valuesByMode[preferredModeId]\n : undefined\n if (\n value === undefined &&\n fallbackModeId &&\n Object.hasOwn(variable.valuesByMode, fallbackModeId)\n ) {\n value = variable.valuesByMode[fallbackModeId]\n }\n value ??= Object.values(variable.valuesByMode)[0]\n if (value && typeof value === 'object' && 'aliasId' in value) {\n const seen = visited ?? new Set<string>()\n seen.add(variableId)\n return resolveVariable(graph, value.aliasId, preferredModeId, seen)\n }\n return value\n}\n\nexport function resolveColorVariable(graph: SceneGraph, variableId: string): Color | undefined {\n const value = resolveVariable(graph, variableId)\n if (value && typeof value === 'object' && 'r' in value) return value\n return undefined\n}\n\nexport function resolveNumberVariable(graph: SceneGraph, variableId: string): number | undefined {\n const value = resolveVariable(graph, variableId)\n return typeof value === 'number' ? value : undefined\n}\n\nexport function resolveColorVariableForNode(\n graph: SceneGraph,\n nodeId: string,\n variableId: string\n): Color | undefined {\n const variable = graph.variables.get(variableId)\n if (!variable) return undefined\n const modeId = getNodeVariableModeId(graph, nodeId, variable.collectionId)\n const value = resolveVariable(graph, variableId, modeId)\n if (value && typeof value === 'object' && 'r' in value) return value\n return undefined\n}\n\nexport function resolveNumberVariableForNode(\n graph: SceneGraph,\n nodeId: string,\n variableId: string\n): number | undefined {\n const variable = graph.variables.get(variableId)\n if (!variable) return undefined\n const modeId = getNodeVariableModeId(graph, nodeId, variable.collectionId)\n const value = resolveVariable(graph, variableId, modeId)\n return typeof value === 'number' ? value : undefined\n}\n\nexport function getVariablesForCollection(graph: SceneGraph, collectionId: string): Variable[] {\n const collection = graph.variableCollections.get(collectionId)\n if (!collection) return []\n return collection.variableIds\n .map((id) => graph.variables.get(id))\n .filter((v): v is Variable => v !== undefined)\n}\n\nexport function getVariablesByType(graph: SceneGraph, type: VariableType): Variable[] {\n return [...graph.variables.values()].filter((v) => v.type === type)\n}\n\nconst SCALAR_BINDING_FIELDS: ReadonlySet<string> = new Set([\n 'opacity',\n 'width',\n 'height',\n 'cornerRadius',\n 'fontSize',\n 'letterSpacing',\n 'lineHeight',\n 'itemSpacing',\n 'strokeWeight',\n 'paddingLeft',\n 'paddingRight',\n 'paddingTop',\n 'paddingBottom',\n 'counterAxisSpacing',\n 'topLeftRadius',\n 'topRightRadius',\n 'bottomLeftRadius',\n 'bottomRightRadius',\n 'rotation',\n 'x',\n 'y',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'borderTopWeight',\n 'borderBottomWeight',\n 'borderLeftWeight',\n 'borderRightWeight',\n 'gridRowGap',\n 'gridColumnGap'\n])\n\nconst STRING_BINDING_FIELDS: ReadonlySet<string> = new Set(['fontFamily'])\n\nconst BOOLEAN_BINDING_FIELDS: ReadonlySet<string> = new Set(['visible'])\n\nexport function bindVariable(\n graph: SceneGraph,\n nodeId: string,\n field: string,\n variableId: string\n): void {\n const node = graph.nodes.get(nodeId)\n if (!node) return\n\n // Validate variable exists\n const variable = graph.variables.get(variableId)\n if (!variable) {\n throw new Error(`Variable \"${variableId}\" not found`)\n }\n\n // Color fields require COLOR variable type\n const colorFieldMatch = field.match(/^(fills|strokes)\\/(\\d+)\\/color$/)\n if (colorFieldMatch) {\n if (variable.type !== 'COLOR') {\n throw new Error(`Cannot bind ${variable.type} variable to color field \"${field}\"`)\n }\n // Validate index is within current array bounds\n const arrayKey = colorFieldMatch[1] as 'fills' | 'strokes'\n const index = Number.parseInt(colorFieldMatch[2], 10)\n const currentLength = (node[arrayKey] as unknown[] | undefined)?.length ?? 0\n if (index >= currentLength) {\n throw new Error(`Index ${index} out of range for ${arrayKey} (length ${currentLength})`)\n }\n // Auto-remove top-level dead binding (e.g. 'fills') when setting indexed binding\n const topLevelKey = colorFieldMatch[1]\n if (topLevelKey in node.boundVariables) {\n node.boundVariables = omit(node.boundVariables, [topLevelKey])\n }\n }\n\n if (SCALAR_BINDING_FIELDS.has(field) && variable.type !== 'FLOAT') {\n throw new Error(`Cannot bind ${variable.type} variable to scalar field \"${field}\"`)\n }\n\n if (STRING_BINDING_FIELDS.has(field) && variable.type !== 'STRING') {\n throw new Error(`Cannot bind ${variable.type} variable to string field \"${field}\"`)\n }\n\n if (BOOLEAN_BINDING_FIELDS.has(field) && variable.type !== 'BOOLEAN') {\n throw new Error(`Cannot bind ${variable.type} variable to boolean field \"${field}\"`)\n }\n\n const isKnownField =\n SCALAR_BINDING_FIELDS.has(field) ||\n STRING_BINDING_FIELDS.has(field) ||\n BOOLEAN_BINDING_FIELDS.has(field) ||\n colorFieldMatch\n\n if (!isKnownField) {\n throw new Error(`Unknown binding field \"${field}\"`)\n }\n\n node.boundVariables = { ...node.boundVariables, [field]: variableId }\n graph.emitter.emit('node:updated', nodeId, { boundVariables: { ...node.boundVariables } })\n markBoundVariablesOverrideOnInstance(graph, nodeId)\n}\n\nexport function unbindVariable(graph: SceneGraph, nodeId: string, field: string): void {\n const node = graph.nodes.get(nodeId)\n if (!node) return\n if (!(field in node.boundVariables)) return\n node.boundVariables = omit(node.boundVariables, [field])\n graph.emitter.emit('node:updated', nodeId, { boundVariables: { ...node.boundVariables } })\n markBoundVariablesOverrideOnInstance(graph, nodeId)\n}\n\nfunction markBoundVariablesOverrideOnInstance(graph: SceneGraph, nodeId: string): void {\n const node = graph.nodes.get(nodeId)\n if (!node) return\n\n // Mark the field on the canonical structured state.\n if (node.type === 'INSTANCE') {\n setInstanceOverride(node.instanceOverrides, node.id, node.id, 'boundVariables')\n return\n }\n\n // Walk up to the owning instance for descendant fields.\n let current = node\n while (current.parentId) {\n const parent = graph.nodes.get(current.parentId)\n if (!parent) break\n if (parent.type === 'INSTANCE') {\n setInstanceOverride(parent.instanceOverrides, parent.id, nodeId, 'boundVariables')\n break\n }\n current = parent\n }\n}\n","/* eslint-disable max-lines -- SceneGraph exposes a stable facade over domain modules */\nexport * from './mutation-impact'\nexport * from './instance-overrides'\nexport * from './images'\nexport * from './components/properties'\nexport * from './copy'\nexport {\n copyInstanceComponentProps,\n hasInstanceOverride,\n INSTANCE_SYNC_FIELDS,\n INSTANCE_SYNC_PROPS,\n INSTANCE_SYNC_TEXT_PROPS,\n recordInstanceOverride\n} from './instances'\nexport {\n clearInstanceOverrides,\n cloneInstanceOverrideState,\n forEachInstanceOverride,\n getInstanceOverride,\n setInstanceOverride,\n type InstanceOverrideState\n} from './instance-overrides'\nexport * from './snap'\nexport * from './export-scale'\nexport * from './coordinate'\nexport * from './constants'\nexport * from './geometry'\nexport * from './guides'\nexport * from './layout-guides'\nexport * from './font-style'\nexport * from './shared-styles'\nexport { default as TransformMatrix } from './matrix'\nexport type { Mat3 } from './matrix'\nexport { UndoManager, type UndoEntry, type UndoManagerOptions } from './undo'\n\nimport { createNanoEvents } from 'nanoevents'\n\nimport { removeStaleBindings } from './bindings'\nimport { cloneNodeProps } from './copy'\nimport { bindNodeEvents } from './events'\nimport * as HitTest from './hit-test'\nimport * as Instances from './instances'\nimport { CONTAINER_TYPES, createDefaultNode } from './node-defaults'\nimport { updateNodePreview, type NodePreviewObserver } from './preview'\nimport { styleDetachmentChanges } from './shared-styles'\nimport { markSourceFieldsEdited } from './source-metadata'\nimport { GLYPH_AFFECTING_KEYS, invalidateTextCaches, TEXT_PICTURE_KEYS } from './text-picture'\nimport * as Variables from './variables'\nimport { normalizeVectorNetwork } from './vector-network'\n\nexport type { GUID, Color, Size, Vector } from './primitives'\nexport * from './types'\n\nimport type { Emitter } from 'nanoevents'\n\nimport { getAbsolutePosition } from './coordinate'\nimport type { Color, Rect, Vector } from './primitives'\nimport type {\n DocumentColorSpace,\n EnabledLibraryBinding,\n NodeType,\n SceneGraphEventHandlers,\n SceneGraphEvents,\n SceneNode,\n SourceMetadata,\n Variable,\n VariableCollection,\n VariableType,\n VariableValue\n} from './types'\n\nexport {\n cloneVectorNetwork,\n mergeVectorNetworks,\n normalizeVectorNetwork,\n transformVectorNetwork,\n validateVectorNetwork,\n vectorNetworksEqual\n} from './vector-network'\n\nlet nextLocalID = 1\n\nexport function generateId(): string {\n return `0:${nextLocalID++}`\n}\n\nfunction stripUndefinedProps<T extends object>(obj: T): T {\n const result = {} as T\n for (const key of Object.keys(obj) as (keyof T)[]) {\n const val = obj[key]\n if (val !== undefined) {\n result[key] = val\n }\n }\n return result\n}\n\nexport { captureGraphCheckpoint } from './checkpoint'\n\nexport class SceneGraph {\n nodes = new Map<string, SceneNode>()\n images = new Map<string, Uint8Array>()\n variables = new Map<string, Variable>()\n variableCollections = new Map<string, VariableCollection>()\n activeMode = new Map<string, string>()\n rootId: string\n figKiwiVersion: number | null = null\n /** Deflated kiwi schema bytes from the original .fig file, preserved for roundtrip fidelity. */\n figSchemaDeflated: Uint8Array | null = null\n documentColorSpace: DocumentColorSpace = 'srgb'\n enabledLibraries = new Map<string, EnabledLibraryBinding>()\n readonly emitter: Emitter<SceneGraphEvents> = createNanoEvents()\n private absPosCache = new Map<string, Vector>()\n private previewMutationDepth = 0\n private previewObservers: NodePreviewObserver[] = []\n private sourceMetadataPreservationDepth = 0\n private layoutMutationDepth = 0\n positionPreviewVersion = 0\n instanceIndex = new Map<string, Set<string>>()\n\n constructor() {\n const root = createDefaultNode(generateId, 'FRAME', {\n name: 'Document',\n width: 0,\n height: 0\n })\n this.rootId = root.id\n this.nodes.set(root.id, root)\n\n this.addPage('Page 1')\n }\n addPage(name: string): SceneNode {\n return this.createNode('CANVAS', this.rootId, { name, width: 0, height: 0 })\n }\n\n getPages(includeInternal = false): SceneNode[] {\n return this.getChildren(this.rootId).filter(\n (n) => n.type === 'CANVAS' && (includeInternal || !n.internalOnly)\n )\n }\n getAllNodes(): Iterable<SceneNode> {\n return this.nodes.values()\n }\n getNode(id: string): SceneNode | undefined {\n return this.nodes.get(id)\n }\n onNodeEvents(handlers: SceneGraphEventHandlers): () => void {\n return bindNodeEvents(this.emitter, handlers)\n }\n\n countDescendants(nodeId: string): number {\n const node = this.nodes.get(nodeId)\n if (!node) return 0\n let count = 0\n const stack = [...node.childIds]\n while (stack.length > 0) {\n const id = stack.pop()\n if (id === undefined) break\n count++\n const child = this.nodes.get(id)\n if (child) {\n for (const childId of child.childIds) {\n stack.push(childId)\n }\n }\n }\n return count\n }\n addVariable(variable: Variable): void {\n Variables.addVariable(this, variable)\n }\n removeVariable(id: string): void {\n Variables.removeVariable(this, id)\n }\n addCollection(collection: VariableCollection): void {\n Variables.addCollection(this, collection)\n }\n createVariable(\n name: string,\n type: VariableType,\n collectionId: string,\n value?: VariableValue\n ): Variable {\n return Variables.createVariable(this, generateId, name, type, collectionId, value)\n }\n\n createCollection(name: string): VariableCollection {\n return Variables.createCollection(this, generateId, name)\n }\n\n removeCollection(id: string): void {\n Variables.removeCollection(this, id)\n }\n\n getActiveModeId(collectionId: string): string {\n return Variables.getActiveModeId(this, collectionId)\n }\n\n getNodeVariableModeId(nodeId: string, collectionId: string): string {\n return Variables.getNodeVariableModeId(this, nodeId, collectionId)\n }\n\n setActiveMode(collectionId: string, modeId: string): void {\n Variables.setActiveMode(this, collectionId, modeId)\n }\n\n addMode(collectionId: string, modeId: string, name: string, sourceMode?: string): void {\n Variables.addMode(this, collectionId, modeId, name, sourceMode)\n }\n\n removeMode(collectionId: string, modeId: string): void {\n Variables.removeMode(this, collectionId, modeId)\n }\n\n renameMode(collectionId: string, modeId: string, name: string): void {\n Variables.renameMode(this, collectionId, modeId, name)\n }\n\n setDefaultMode(collectionId: string, modeId: string): void {\n Variables.setDefaultMode(this, collectionId, modeId)\n }\n\n resolveVariable(\n variableId: string,\n modeId?: string,\n visited?: Set<string>\n ): VariableValue | undefined {\n return Variables.resolveVariable(this, variableId, modeId, visited)\n }\n\n resolveColorVariable(variableId: string): Color | undefined {\n return Variables.resolveColorVariable(this, variableId)\n }\n\n resolveNumberVariable(variableId: string): number | undefined {\n return Variables.resolveNumberVariable(this, variableId)\n }\n\n resolveColorVariableForNode(nodeId: string, variableId: string): Color | undefined {\n return Variables.resolveColorVariableForNode(this, nodeId, variableId)\n }\n\n resolveNumberVariableForNode(nodeId: string, variableId: string): number | undefined {\n return Variables.resolveNumberVariableForNode(this, nodeId, variableId)\n }\n\n getVariablesForCollection(collectionId: string): Variable[] {\n return Variables.getVariablesForCollection(this, collectionId)\n }\n\n getVariablesByType(type: VariableType): Variable[] {\n return Variables.getVariablesByType(this, type)\n }\n\n bindVariable(nodeId: string, field: string, variableId: string): void {\n Variables.bindVariable(this, nodeId, field, variableId)\n }\n\n unbindVariable(nodeId: string, field: string): void {\n Variables.unbindVariable(this, nodeId, field)\n }\n\n getChildren(id: string): SceneNode[] {\n const node = this.nodes.get(id)\n if (!node) return []\n return node.childIds\n .map((cid) => this.nodes.get(cid))\n .filter((n): n is SceneNode => n !== undefined)\n }\n\n isContainer(id: string): boolean {\n const node = this.nodes.get(id)\n return node ? CONTAINER_TYPES.has(node.type) : false\n }\n\n isDescendant(childId: string, ancestorId: string): boolean {\n let current = this.nodes.get(childId)\n while (current) {\n if (current.id === ancestorId) return true\n current = current.parentId ? this.nodes.get(current.parentId) : undefined\n }\n return false\n }\n\n clearAbsPosCache(): void {\n this.absPosCache.clear()\n }\n\n getAbsolutePosition(id: string): Vector {\n const cached = this.absPosCache.get(id)\n if (cached) return cached\n\n const node = this.getNode(id)\n if (!node) return { x: 0, y: 0 }\n\n const result = getAbsolutePosition(node, this)\n this.absPosCache.set(id, result)\n return result\n }\n\n getAbsoluteBounds(id: string): Rect {\n const pos = this.getAbsolutePosition(id)\n const node = this.nodes.get(id)\n return {\n x: pos.x,\n y: pos.y,\n width: node?.width ?? 0,\n height: node?.height ?? 0\n }\n }\n private generateNodeId(): string {\n let id = generateId()\n while (this.nodes.has(id)) id = generateId()\n return id\n }\n private registerNode(node: SceneNode, parentId: string | null): SceneNode {\n node.parentId = parentId\n this.nodes.set(node.id, node)\n if (node.type === 'INSTANCE' && node.componentId) {\n let set = this.instanceIndex.get(node.componentId)\n if (!set) {\n set = new Set()\n this.instanceIndex.set(node.componentId, set)\n }\n set.add(node.id)\n }\n this.emitter.emit('node:created', node)\n return node\n }\n createNode(type: NodeType, parentId: string, overrides: Partial<SceneNode> = {}): SceneNode {\n const node = createDefaultNode(() => this.generateNodeId(), type, overrides)\n this.nodes.get(parentId)?.childIds.push(node.id)\n return this.registerNode(node, parentId)\n }\n createNodeWithId(\n id: string,\n type: NodeType,\n parentId: string | null,\n overrides: Partial<SceneNode> = {}\n ): SceneNode {\n const node = createDefaultNode(() => id, type, overrides)\n node.id = id\n const parent = parentId ? this.nodes.get(parentId) : undefined\n if (parent && !parent.childIds.includes(id)) parent.childIds.push(id)\n return this.registerNode(node, parentId)\n }\n\n static TEXT_PICTURE_KEYS: ReadonlySet<string> = TEXT_PICTURE_KEYS\n static GLYPH_AFFECTING_KEYS: ReadonlySet<string> = GLYPH_AFFECTING_KEYS\n\n static LAYOUT_AFFECTING_KEYS: ReadonlySet<string> = new Set([\n 'x',\n 'y',\n 'width',\n 'height',\n 'rotation',\n 'flipX',\n 'flipY',\n 'layoutMode',\n 'layoutDirection',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingLeft',\n 'paddingRight',\n 'paddingTop',\n 'paddingBottom',\n 'primaryAxisAlign',\n 'counterAxisAlign',\n 'counterAxisAlignContent',\n 'layoutWrap',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'layoutPositioning',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'strokesIncludedInLayout',\n 'horizontalConstraint',\n 'verticalConstraint',\n 'gridTemplateColumns',\n 'gridTemplateRows',\n 'gridColumnGap',\n 'gridRowGap',\n 'gridPosition',\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight'\n ])\n\n runPreviewUpdates(fn: () => void, beforeUpdate?: NodePreviewObserver): void {\n this.previewMutationDepth++\n if (beforeUpdate) this.previewObservers.push(beforeUpdate)\n try {\n fn()\n } finally {\n if (beforeUpdate) this.previewObservers.pop()\n this.previewMutationDepth--\n }\n }\n preserveSourceMetadataDuring(fn: () => void): void {\n this.sourceMetadataPreservationDepth++\n try {\n fn()\n } finally {\n this.sourceMetadataPreservationDepth--\n }\n }\n withLayoutMutations(fn: () => void): void {\n this.layoutMutationDepth++\n try {\n fn()\n } finally {\n this.layoutMutationDepth--\n }\n }\n get isApplyingLayout(): boolean {\n return this.layoutMutationDepth > 0\n }\n updateNodePositionPreview(id: string, x: number, y: number): void {\n this.updateNodePreview(id, { x, y })\n }\n updateNodePreview(id: string, changes: Partial<SceneNode>): void {\n const appliedChanges = updateNodePreview(this, id, changes, (node, applied) => {\n for (const observe of this.previewObservers) observe(node, applied)\n })\n if (appliedChanges) this.emitter.emit('node:previewUpdated', id, appliedChanges)\n }\n\n updateNode(id: string, changes: Partial<SceneNode>): void {\n if (this.previewMutationDepth > 0) {\n this.updateNodePreview(id, changes)\n return\n }\n\n const node = this.nodes.get(id)\n if (!node) return\n changes = stripUndefinedProps(styleDetachmentChanges(node, stripUndefinedProps(changes)))\n this.applyNodeChanges(node, changes)\n }\n\n /** Replay captured properties without dropping explicit undefined values or absent keys. */\n restoreNodeProperties(\n id: string,\n changes: Partial<SceneNode>,\n absent: readonly (keyof SceneNode)[]\n ): void {\n const node = this.nodes.get(id)\n if (node) this.applyNodeChanges(node, changes, absent)\n }\n\n private applyNodeChanges(\n node: SceneNode,\n changes: Partial<SceneNode>,\n absent: readonly (keyof SceneNode)[] = []\n ): void {\n const { id } = node\n // Include removed keys in cache invalidation and update notifications.\n if (absent.length) {\n changes = { ...changes }\n for (const key of absent) Reflect.set(changes, key, undefined)\n }\n\n // Only clear absPosCache when layout-affecting properties change.\n // Fills, strokes, effects, plugin data changes do NOT affect absolute position.\n const affectsLayout = Object.keys(changes).some((k) => SceneGraph.LAYOUT_AFFECTING_KEYS.has(k))\n if (affectsLayout) this.absPosCache.clear()\n if (\n node.type === 'INSTANCE' &&\n 'componentId' in changes &&\n changes.componentId !== node.componentId\n ) {\n if (node.componentId) this.instanceIndex.get(node.componentId)?.delete(id)\n if (changes.componentId) {\n let set = this.instanceIndex.get(changes.componentId)\n if (!set) {\n set = new Set()\n this.instanceIndex.set(changes.componentId, set)\n }\n set.add(id)\n }\n }\n if (node.type === 'TEXT') invalidateTextCaches(node, changes)\n if (this.sourceMetadataPreservationDepth === 0) {\n markSourceFieldsEdited(node, Object.keys(changes))\n }\n if (changes.vectorNetwork) {\n changes = { ...changes, vectorNetwork: normalizeVectorNetwork(changes.vectorNetwork) }\n }\n Object.assign(node, changes)\n if (changes.fills) removeStaleBindings(node, 'fills', changes)\n if (changes.strokes) removeStaleBindings(node, 'strokes', changes)\n for (const key of absent) Reflect.deleteProperty(node, key)\n this.emitter.emit('node:updated', id, changes)\n }\n\n reparentNode(nodeId: string, newParentId: string): void {\n const node = this.nodes.get(nodeId)\n if (!node || nodeId === this.rootId) return\n if (this.isDescendant(newParentId, nodeId)) return\n\n const oldParent = node.parentId ? this.nodes.get(node.parentId) : undefined\n const newParent = this.nodes.get(newParentId)\n if (!newParent) return\n if (node.parentId === newParentId) return\n\n const oldParentId = node.parentId\n this.absPosCache.clear()\n\n const absPos = this.getAbsolutePosition(nodeId)\n const newParentNode = this.nodes.get(newParentId)\n const newParentAbs =\n newParentId === this.rootId || newParentNode?.type === 'CANVAS'\n ? { x: 0, y: 0 }\n : this.getAbsolutePosition(newParentId)\n\n if (oldParent) {\n oldParent.childIds = oldParent.childIds.filter((cid) => cid !== nodeId)\n }\n\n node.parentId = newParentId\n newParent.childIds.push(nodeId)\n\n node.x = absPos.x - newParentAbs.x\n node.y = absPos.y - newParentAbs.y\n\n this.emitter.emit('node:reparented', nodeId, oldParentId, newParentId)\n }\n\n reorderChild(nodeId: string, parentId: string, insertIndex: number): void {\n const node = this.nodes.get(nodeId)\n if (!node) return\n\n const previousParentId = node.parentId\n const oldParent = previousParentId ? this.nodes.get(previousParentId) : undefined\n const newParent = this.nodes.get(parentId)\n if (!newParent || this.isDescendant(parentId, nodeId)) return\n\n // Remove from old parent\n if (oldParent) {\n oldParent.childIds = oldParent.childIds.filter((cid) => cid !== nodeId)\n }\n\n // If same parent, adjust index since we removed the item\n let idx = insertIndex\n if (\n oldParent === newParent &&\n idx > (!oldParent.childIds.includes(nodeId) ? idx : oldParent.childIds.length)\n ) {\n // Already removed above, no adjustment needed\n }\n\n node.parentId = parentId\n this.absPosCache.clear()\n idx = Math.min(idx, newParent.childIds.length)\n newParent.childIds.splice(idx, 0, nodeId)\n\n this.emitter.emit('node:reordered', nodeId, parentId, idx, previousParentId)\n }\n\n insertChildAt(childId: string, parentId: string, index: number): void {\n const node = this.getNode(childId)\n const newParent = this.getNode(parentId)\n if (!node || !newParent || childId === parentId || this.isDescendant(parentId, childId)) return\n const previousParentId = node.parentId\n const oldParent = previousParentId ? this.getNode(previousParentId) : undefined\n if (oldParent) {\n oldParent.childIds = oldParent.childIds.filter((id) => id !== childId)\n }\n newParent.childIds = newParent.childIds.filter((id) => id !== childId)\n newParent.childIds.splice(index, 0, childId)\n node.parentId = parentId\n this.clearAbsPosCache()\n this.emitter.emit('node:reordered', childId, parentId, index, previousParentId)\n }\n\n deleteNode(id: string): void {\n const node = this.nodes.get(id)\n if (!node || id === this.rootId) return\n\n if (node.parentId) {\n const parent = this.nodes.get(node.parentId)\n if (parent) {\n parent.childIds = parent.childIds.filter((cid) => cid !== id)\n }\n }\n\n for (const childId of Array.from(node.childIds)) {\n this.deleteNode(childId)\n }\n\n if (node.type === 'INSTANCE' && node.componentId) {\n this.instanceIndex.get(node.componentId)?.delete(id)\n }\n this.nodes.delete(id)\n this.emitter.emit('node:deleted', id, node.parentId)\n }\n\n hitTest(px: number, py: number, scopeId?: string): SceneNode | null {\n return HitTest.hitTest(this, px, py, scopeId)\n }\n\n hitTestDeep(px: number, py: number, scopeId?: string): SceneNode | null {\n return HitTest.hitTestDeep(this, px, py, scopeId)\n }\n\n hitTestFrame(\n px: number,\n py: number,\n excludeIds: Set<string>,\n scopeId?: string\n ): SceneNode | null {\n return HitTest.hitTestFrame(this, px, py, excludeIds, scopeId)\n }\n\n cloneTree(\n sourceId: string,\n parentId: string,\n overrides: Partial<SceneNode> = {}\n ): SceneNode | null {\n const src = this.nodes.get(sourceId)\n if (!src) return null\n\n const props = cloneNodeProps(src, null)\n // Null out Figma source identifiers so the clone is treated as local.\n // `as SourceMetadata` required: cloneNodeProps returns Partial<SceneNode>,\n // so props.source is SourceMetadata | undefined, but we know it's always set.\n props.source = { ...(props.source as SourceMetadata), id: null, orderKey: null }\n const clone = this.createNode(src.type, parentId, { ...props, ...overrides })\n\n for (const childId of src.childIds) {\n this.cloneTree(childId, clone.id)\n }\n\n return clone\n }\n\n createInstance(\n componentId: string,\n parentId: string,\n overrides: Partial<SceneNode> = {}\n ): SceneNode | null {\n return Instances.createInstance(this, componentId, parentId, overrides)\n }\n\n populateInstanceChildren(\n instanceId: string,\n componentId: string,\n mode: Instances.NodeCloneMode = 'deep'\n ): void {\n Instances.populateInstanceChildren(this, instanceId, componentId, mode)\n }\n\n swapInstanceComponent(instanceId: string, componentId: string): void {\n Instances.swapInstanceComponent(this, instanceId, componentId)\n }\n\n syncInstances(componentId: string): void {\n Instances.syncInstances(this, componentId)\n }\n\n detachInstance(instanceId: string): void {\n Instances.detachInstance(this, instanceId)\n }\n\n getMainComponent(instanceId: string): SceneNode | undefined {\n return Instances.getMainComponent(this, instanceId)\n }\n\n getInstances(componentId: string): SceneNode[] {\n return Instances.getInstances(this, componentId)\n }\n\n flattenTree(parentId?: string, depth = 0): Array<{ node: SceneNode; depth: number }> {\n const id = parentId ?? this.rootId\n const parent = this.nodes.get(id)\n if (!parent) return []\n const result: Array<{ node: SceneNode; depth: number }> = []\n for (const childId of parent.childIds) {\n const child = this.nodes.get(childId)\n if (!child) continue\n result.push({ node: child, depth })\n if (child.childIds.length > 0) result.push(...this.flattenTree(childId, depth + 1))\n }\n return result\n }\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,4BAAiD;CAC/D,OAAO;EACL,gCAAgB,IAAI,IAAI;EACxB,mCAAmB,IAAI,IAAI;EAC3B,kCAAkB,IAAI,IAAI;EAC1B,gCAAgB,IAAI,IAAI;EACxB,gCAAgB,IAAI,IAAI;CAC1B;AACF;;AAUA,eAAsB,qBACpB,OACA,WACoC;CACpC,MAAM,SAAS,0BAA0B;CACzC,MAAM,SAAS,MAAM,aAAa;EAChC,UAAU,SAAS;GACjB,OAAO,eAAe,IAAI,KAAK,EAAE;GACjC,OAAO,eAAe,IAAI,KAAK,EAAE;GACjC,IAAI,KAAK,UAAU,OAAO,iBAAiB,IAAI,KAAK,QAAQ;EAC9D;EACA,UAAU,OAAO,OAAO,eAAe,IAAI,EAAE;EAC7C,UAAU,IAAI,aAAa;GACzB,IAAI,UAAU,OAAO,kBAAkB,IAAI,QAAQ;GACnD,OAAO,eAAe,IAAI,EAAE;GAC5B,O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QAAQ,KAAK,WAAW,IAAI,MAAM,UAAU;GAAE,GAAG;GAAO,GAAG;EAAU,CAAC;EAE5E,KAAK,MAAM,WAAW,IAAI,UACxB,KAAK,UAAU,SAAS,MAAM,EAAE;EAGlC,OAAO;CACT;CAEA,eACE,aACA,UACA,YAAgC,CAAC,GACf;EAClB,OAAOC,eAAyB,MAAM,aAAa,UAAU,SAAS;CACxE;CAEA,yBACE,YACA,aACA,OAAgC,QAC1B;EACN,yBAAmC,MAAM,YAAY,aAAa,IAAI;CACxE;CAEA,sBAAsB,YAAoB,aAA2B;EACnE,sBAAgC,MAAM,YAAY,WAAW;CAC/D;CAEA,cAAc,aAA2B;EACvC,cAAwB,MAAM,WAAW;CAC3C;CAEA,eAAe,YAA0B;EACvC,eAAyB,MAAM,UAAU;CAC3C;CAEA,iBAAiB,YAA2C;EAC1D,OAAOC,iBAA2B,MAAM,UAAU;CACpD;CAEA,aAAa,aAAkC;EAC7C,OAAOC,aAAuB,MAAM,WAAW;CACjD;CAEA,YAAY,UAAmB,QAAQ,GAA8C;EACnF,MAAM,KAAK,YAAY,KAAK;EAC5B,MAAM,SAAS,KAAK,MAAM,IAAI,EAAE;EAChC,IAAI,CAAC,QAAQ,OAAO,CAAC;EACrB,MAAM,SAAoD,CAAC;EAC3D,KAAK,MAAM,WAAW,OAAO,UAAU;GACrC,MAAM,QAAQ,KAAK,MAAM,IAAI,OAAO;GACpC,IAAI,CAAC,OAAO;GACZ,OAAO,KAAK;IAAE,MAAM;IAAO;GAAM,CAAC;GAClC,IAAI,MAAM,SAAS,SAAS,GAAG,OAAO,KAAK,GAAG,KAAK,YAAY,SAAS,QAAQ,CAAC,CAAC;EACpF;EACA,OAAO;CACT;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-pencil/scene-graph",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
package/src/index.ts CHANGED
@@ -107,7 +107,7 @@ export class SceneGraph {
107
107
  figKiwiVersion: number | null = null
108
108
  /** Deflated kiwi schema bytes from the original .fig file, preserved for roundtrip fidelity. */
109
109
  figSchemaDeflated: Uint8Array | null = null
110
- documentColorSpace: DocumentColorSpace = 'display-p3'
110
+ documentColorSpace: DocumentColorSpace = 'srgb'
111
111
  enabledLibraries = new Map<string, EnabledLibraryBinding>()
112
112
  readonly emitter: Emitter<SceneGraphEvents> = createNanoEvents()
113
113
  private absPosCache = new Map<string, Vector>()