@pairdraw/pen 0.0.0-stage → 0.16.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.
- package/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/chunks/annotations.js +510 -0
- package/dist/chunks/annotations.js.map +1 -0
- package/dist/chunks/assets.js +158 -0
- package/dist/chunks/assets.js.map +1 -0
- package/dist/chunks/effects.js +775 -0
- package/dist/chunks/effects.js.map +1 -0
- package/dist/chunks/geometry.js +95 -0
- package/dist/chunks/geometry.js.map +1 -0
- package/dist/chunks/icons.js +156 -0
- package/dist/chunks/icons.js.map +1 -0
- package/dist/chunks/imports.js +120 -0
- package/dist/chunks/imports.js.map +1 -0
- package/dist/chunks/index.js +1478 -0
- package/dist/chunks/index.js.map +1 -0
- package/dist/index.d.ts +492 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/package.json +43 -4
- package/src/annotations.ts +128 -0
- package/src/assets.ts +224 -0
- package/src/effects.ts +62 -0
- package/src/geometry.ts +71 -0
- package/src/icons.ts +173 -0
- package/src/images.ts +109 -0
- package/src/imports.ts +169 -0
- package/src/index.ts +23 -0
- package/src/instances.ts +272 -0
- package/src/jsonc.ts +77 -0
- package/src/layout.ts +135 -0
- package/src/library.ts +153 -0
- package/src/nodes.ts +410 -0
- package/src/paints.ts +417 -0
- package/src/placeholders.ts +86 -0
- package/src/placement.ts +84 -0
- package/src/plugin-data.ts +86 -0
- package/src/read.ts +150 -0
- package/src/schema.ts +299 -0
- package/src/slots.ts +41 -0
- package/src/text.ts +92 -0
- package/src/variables.ts +284 -0
- package/src/write.ts +594 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["SceneGraphValue"],"sources":["../../src/library.ts","../../src/placeholders.ts","../../src/placement.ts","../../src/slots.ts","../../src/text.ts","../../src/nodes.ts","../../src/instances.ts","../../src/read.ts","../../src/write.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport { libraryDefinitionsPage } from '@pairdraw/scene-graph/components'\n\nimport { withImports, type PenImports } from './imports'\nimport type { Build } from './nodes'\nimport type { PenDocument, PenNode, PenOverride } from './schema'\n\n/** A component an imported document defines, with the outermost component holding it. */\ninterface Owner {\n alias: string\n path: string\n root: PenNode\n /** The themes of the layers around the root in its document, which it was drawn in. */\n theme: Record<string, string> | undefined\n}\n\n/** An imported component the document draws, as it went on the library page. */\nexport interface LibraryRoot {\n id: string\n alias: string\n path: string\n}\n\n/** The component IDs a layer and its overrides name: its `ref`s and the slots' suggestions. */\nfunction namedComponents(node: PenOverride, found: string[]): void {\n if (typeof node.ref === 'string') found.push(node.ref)\n if (Array.isArray(node.slot)) found.push(...node.slot)\n for (const child of node.children ?? []) namedComponents(child, found)\n for (const override of Object.values(node.descendants ?? {})) namedComponents(override, found)\n}\n\nfunction mergeTheme(\n outer: Record<string, string> | undefined,\n inner: Record<string, string> | undefined\n): Record<string, string> | undefined {\n return outer || inner ? { ...outer, ...inner } : undefined\n}\n\n/** Each reusable layer of the imported documents by ID, with the outermost component holding it. */\nfunction componentOwners(imports: PenImports): Map<string, Owner> {\n const owners = new Map<string, Owner>()\n for (const [alias, { path, doc }] of imports) {\n const visit = (nodes: readonly PenNode[], root: PenNode | undefined, theme: Owner['theme']) => {\n for (const node of nodes) {\n const own = root ?? (node.reusable ? node : undefined)\n if (node.reusable && own) owners.set(node.id, { alias, path, root: own, theme })\n visit(node.children ?? [], own, own ? theme : mergeTheme(theme, node.theme))\n }\n }\n visit(doc.children, undefined, undefined)\n }\n return owners\n}\n\n/**\n * The imported components a document draws, through the components they draw in turn, each as the\n * outermost component holding it, in the order the document first names them. A library's other\n * components stay out of the document, which only ever shows instances of the ones it uses.\n */\nfunction usedRoots(doc: PenDocument, imports: PenImports): Owner[] {\n const owners = componentOwners(imports)\n const pending: string[] = []\n for (const node of doc.children) namedComponents(node, pending)\n const roots = new Map<string, Owner>()\n // Each root's own names join the list as it is read.\n for (const id of pending) {\n const owner = owners.get(id)\n if (!owner || roots.has(owner.root.id)) continue\n roots.set(owner.root.id, owner)\n namedComponents(owner.root, pending)\n }\n return [...roots.values()]\n}\n\n/**\n * The document with the imported components it uses after its own layers, and the imported\n * variables and themes, so `penAssets` lists every icon and image it draws and no other of a\n * library's.\n */\nexport function withUsedImports(doc: PenDocument, imports: PenImports): PenDocument {\n if (imports.size === 0) return doc\n return {\n ...withImports(doc, imports),\n children: [...doc.children, ...usedRoots(doc, imports).map((owner) => owner.root)]\n }\n}\n\n/**\n * Draws the imported components the document uses on the hidden library page, in the themes they\n * sit in in their own documents, so its instances of them resolve. Nothing is drawn when the\n * document uses none.\n */\nexport function createLibraryRoots(\n doc: PenDocument,\n imports: PenImports,\n build: Build,\n create: (pen: PenNode, parentId: string, build: Build) => string\n): LibraryRoot[] {\n const roots = usedRoots(doc, imports)\n if (roots.length === 0) return []\n const page = libraryDefinitionsPage(build.graph)\n return roots.map(({ alias, path, root, theme }) => {\n const leave = theme ? build.ctx.enterTheme(theme) : undefined\n try {\n return { id: create(root, page.id, build), alias, path }\n } finally {\n leave?.()\n }\n })\n}\n\n/** `value` with what `allowed` rejects replaced, starting with a letter or digit, at most `max` long. */\nfunction libraryName(value: string, allowed: RegExp, max: number): string {\n const name = value.replace(allowed, '_')\n return (/^[a-zA-Z0-9]/.test(name) ? name : `x${name}`).slice(0, max)\n}\n\n/** The ID a library's assets name it by: `pen:<alias>`, in the characters library IDs take. */\nfunction penLibraryId(alias: string): string {\n return libraryName(`pen:${alias}`, /[^a-zA-Z0-9._:-]/g, 128)\n}\n\n/** A component's key in its library: its ID in the imported document, without the alias. */\nfunction penLibraryAssetKey(alias: string, id: string): string {\n const prefix = `${alias}:`\n const own = id.startsWith(prefix) ? id.slice(prefix.length) : id\n return libraryName(own, /[^a-zA-Z0-9._:/-]/g, 256)\n}\n\n/**\n * Marks the imported components as a library's definitions: read-only, locked, and each with its\n * library and key, so the editor treats them as it treats a component library's, and their\n * instances as library instances. The file they came from is their revision.\n */\nexport function markLibraryRoots(graph: SceneGraph, roots: readonly LibraryRoot[]): void {\n for (const { id, alias, path } of roots) {\n const root = graph.getNode(id)\n if (!root) continue\n const libraryId = penLibraryId(alias)\n const queue = [root]\n for (const node of queue) {\n if (node === root || node.type === 'COMPONENT' || node.type === 'COMPONENT_SET') {\n node.librarySource = {\n identity: { libraryId, assetKey: penLibraryAssetKey(alias, node.id), revisionId: path },\n sourceNodeId: null,\n readOnly: true\n }\n }\n queue.push(...graph.getChildren(node.id))\n }\n root.locked = true\n }\n}\n","import type { SceneNode } from '@pairdraw/scene-graph'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { unresolvedRef } from './plugin-data'\nimport type { PenNode } from './schema'\n\n/**\n * Layers pen.dev draws that this reader cannot: a `script` node's generated layers, a `browser`\n * node's live page, and a `ref` to a component that could not be found, such as one from a library\n * the host could not read. Each reads as a frame in its box, filled and outlined with a dashed line\n * where pen.dev gives it neither, and labelled with what it stands for when it has no layers.\n */\nconst EMBED_TYPES: ReadonlySet<string> = new Set(['script', 'browser'])\n\nconst PLACEHOLDER_FILL: Color = { r: 0.96, g: 0.96, b: 0.96, a: 1 }\nconst PLACEHOLDER_OUTLINE: Color = { r: 0.62, g: 0.62, b: 0.62, a: 1 }\nconst PLACEHOLDER_DASH = [4, 4]\n/** Room around the label, inside the outline. */\nconst PLACEHOLDER_INSET = 8\nconst LABEL_SIZE = 12\nconst LABEL_COLOR = '#737373'\n\n/** Whether a layer reads as a placeholder. */\nexport function isPlaceholder(pen: PenNode): boolean {\n return EMBED_TYPES.has(pen.type) || unresolvedRef(pen) !== undefined\n}\n\n/**\n * Fills and outlines a placeholder where pen.dev gives it no paint of its own, insets an auto\n * layout's content, and clips a script or browser frame to its box, as pen.dev shows them.\n */\nexport function applyPlaceholderLook(node: SceneNode, pen: PenNode): void {\n if (pen.fill === undefined) {\n node.fills = [{ type: 'SOLID', color: { ...PLACEHOLDER_FILL }, opacity: 1, visible: true }]\n }\n if (node.strokes.length === 0) {\n node.strokes = [\n {\n type: 'SOLID',\n color: { ...PLACEHOLDER_OUTLINE },\n opacity: 1,\n visible: true,\n weight: 1,\n align: 'INSIDE',\n dashPattern: [...PLACEHOLDER_DASH]\n }\n ]\n }\n if (pen.padding === undefined && node.layoutMode !== 'NONE') {\n node.paddingTop = PLACEHOLDER_INSET\n node.paddingRight = PLACEHOLDER_INSET\n node.paddingBottom = PLACEHOLDER_INSET\n node.paddingLeft = PLACEHOLDER_INSET\n }\n if (EMBED_TYPES.has(pen.type) && pen.clip === undefined) node.clipsContent = true\n}\n\n/** What a placeholder stands for: its file, its page, or the component it names. */\nfunction labelText(pen: PenNode): string {\n const missing = unresolvedRef(pen)\n if (missing !== undefined) return missing || (pen.name ?? 'ref')\n if (pen.type === 'script' && pen.scriptUri) return pen.scriptUri\n if (pen.type === 'browser' && pen.url) return pen.url\n return pen.name ?? pen.type\n}\n\n/**\n * The label a placeholder without layers of its own shows, as a text layer; none for one with\n * layers, such as a script node pen.dev saved with what it generated. The label says it was\n * generated, so a writer can leave it out.\n */\nexport function placeholderLabel(pen: PenNode, nodeId: string): PenNode | undefined {\n if (!isPlaceholder(pen) || (pen.children?.length ?? 0) > 0) return undefined\n const text = labelText(pen)\n return {\n id: `${nodeId}#label`,\n type: 'text',\n name: text,\n content: text,\n fontSize: LABEL_SIZE,\n fill: LABEL_COLOR,\n x: PLACEHOLDER_INSET,\n y: PLACEHOLDER_INSET,\n generated: 'placeholder'\n }\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { localTransformFromWorld } from '@pairdraw/scene-graph/coordinate'\nimport { fitEnclosingGroups } from '@pairdraw/scene-graph/group-bounds'\nimport Matrix from '@pairdraw/scene-graph/matrix'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\n/**\n * Where pen.dev puts a layer: at `x`, `y` in its parent, turned `rotation` degrees\n * counter-clockwise and then mirrored, both about that corner. The scene graph turns clockwise and\n * mirrors about a layer's centre, so a layer's position depends on its final size and is set after\n * layout. Measured against pen.dev 2.21 renders of turned, mirrored, and grouped layers.\n */\nexport interface PenPlacement {\n x: number\n y: number\n rotation: number\n flipX: boolean\n flipY: boolean\n}\n\nexport function isPlain(placement: PenPlacement): boolean {\n return placement.rotation === 0 && !placement.flipX && !placement.flipY\n}\n\nfunction inFlow(graph: SceneGraph, node: SceneNode): boolean {\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n return !!parent && parent.layoutMode !== 'NONE' && node.layoutPositioning !== 'ABSOLUTE'\n}\n\n/** Sets a layer's position and turn so it lands where pen.dev draws it; `offset` is where its box starts in pen.dev's. */\nfunction place(\n graph: SceneGraph,\n node: SceneNode,\n placement: PenPlacement,\n offset: Vector = { x: 0, y: 0 }\n) {\n const world = Matrix.multiply(\n Matrix.translated(placement.x, placement.y),\n Matrix.rotated((-placement.rotation * Math.PI) / 180),\n Matrix.scaled(placement.flipX ? -1 : 1, placement.flipY ? -1 : 1),\n Matrix.translated(offset.x, offset.y)\n )\n const local = localTransformFromWorld(\n { ...node, flipX: placement.flipX },\n world,\n Matrix.identity()\n )\n if (!local) return\n // Auto layout places the layers in its flow; only their turn and mirroring carry over.\n if (inFlow(graph, node)) graph.updateNode(node.id, { ...local, x: node.x, y: node.y })\n else graph.updateNode(node.id, local)\n}\n\n/**\n * Places every turned or mirrored layer, which the reader builds upright. Then each group, inner\n * ones first, is fitted to its placed layers and placed itself; its box starts at its layers'\n * bounds, wherever pen.dev's starts. `groupIds` is in reading order.\n */\nexport function placeLayers(\n graph: SceneGraph,\n placements: ReadonlyMap<string, PenPlacement>,\n groupIds: readonly string[]\n): void {\n const groups = new Set(groupIds)\n for (const [id, placement] of placements) {\n const node = graph.getNode(id)\n if (node && !groups.has(id) && !isPlain(placement)) place(graph, node, placement)\n }\n\n const origins = new Map<string, Vector>()\n for (const id of groupIds) {\n const group = graph.getNode(id)\n if (group) origins.set(id, { x: group.x, y: group.y })\n }\n // Reading order lists a group before the groups inside it, so reversed it is innermost first.\n for (const id of groupIds.toReversed()) {\n fitEnclosingGroups(graph, [id])\n const node = graph.getNode(id)\n const origin = origins.get(id)\n const placement = placements.get(id)\n if (!node || !origin || !placement || isPlain(placement)) continue\n place(graph, node, placement, { x: node.x - origin.x, y: node.y - origin.y })\n }\n}\n","import type { SceneNode } from '@pairdraw/scene-graph'\nimport { createComponentPropertyId } from '@pairdraw/scene-graph/components'\nimport {\n canCreateSlot,\n claimSlotContent,\n createSlotProperty,\n slotOwner,\n slotScope,\n updateSlotProperty\n} from '@pairdraw/scene-graph/slots'\n\nimport type { Build } from './nodes'\nimport type { PenNode } from './schema'\n\n/**\n * Makes a frame pen.dev marks with `slot` a slot of the component it is in, suggesting the\n * components it lists that the document defines. A frame outside a component has no slot to be.\n */\nexport function createPenSlot(node: SceneNode, pen: PenNode, build: Build): void {\n const { graph, components } = build\n if (!Array.isArray(pen.slot) || !canCreateSlot(graph, node)) return\n const definition = createSlotProperty(graph, node.id, createComponentPropertyId())\n const owner = slotOwner(graph, node)\n if (!definition || !owner) return\n const preferredValues = pen.slot.filter((id) => components.get(id)?.type === 'frame')\n if (preferredValues.length > 0)\n updateSlotProperty(graph, owner.id, definition.id, { preferredValues })\n}\n\n/**\n * Lets `instance` own the content of the slot frame `target`, which an override of its is about\n * to fill, as filling a slot in pen.dev keeps the instance. Returns false when `target` is not a\n * slot of that very instance, whose layers the override must then replace.\n */\nexport function claimSlot(build: Build, instance: SceneNode, target: SceneNode): boolean {\n const scope = slotScope(build.graph, target.id)\n if (scope.kind !== 'slot' || scope.frame.id !== target.id || scope.instance.id !== instance.id)\n return false\n claimSlotContent(build.graph, scope)\n return true\n}\n","import type { SceneNode, StyleRun, TextAlignVertical, TextAutoResize } from '@pairdraw/scene-graph'\nimport { percentLength, pixelLength } from '@pairdraw/scene-graph/text'\n\nimport type { PenNode } from './schema'\nimport { bindIfVar, isVarRef, resolveNumber, resolveString, type VarContext } from './variables'\n\nconst FONT_WEIGHTS: Partial<Record<string, number>> = {\n thin: 100,\n extralight: 200,\n light: 300,\n normal: 400,\n regular: 400,\n medium: 500,\n semibold: 600,\n bold: 700,\n extrabold: 800,\n black: 900\n}\n\n/** pen.dev writes weights as numbers in strings, such as \"700\"; older files use names. */\nfunction fontWeight(value: PenNode['fontWeight'], ctx: VarContext): number {\n if (value === undefined) return 400\n if (typeof value === 'number') return value\n const named = isVarRef(value) ? ctx.resolveString(value) || ctx.resolveNumber(value) : value\n const numeric = Number(named)\n if (Number.isFinite(numeric) && numeric > 0) return numeric\n return FONT_WEIGHTS[String(named).toLowerCase()] ?? 400\n}\n\nconst TEXT_ALIGN: Partial<Record<string, SceneNode['textAlignHorizontal']>> = {\n left: 'LEFT',\n center: 'CENTER',\n right: 'RIGHT',\n justify: 'JUSTIFIED'\n}\n\nconst TEXT_ALIGN_VERTICAL: Partial<Record<string, TextAlignVertical>> = {\n top: 'TOP',\n middle: 'CENTER',\n bottom: 'BOTTOM'\n}\n\n/**\n * `auto` grows on one line, `fixed-width` wraps and grows down, and `fixed-width-height` wraps in\n * a fixed box its text may overflow.\n */\nconst TEXT_GROWTH: Partial<Record<string, TextAutoResize>> = {\n auto: 'WIDTH_AND_HEIGHT',\n 'fixed-width': 'HEIGHT',\n 'fixed-width-height': 'NONE'\n}\n\n/**\n * A text layer's content and style. Content that reads like a variable reference stays as written,\n * as pen.dev shows it. pen.dev 2.21 draws no underline, strikethrough, or text stroke, so those\n * are left out to match it. An `href` is kept as a link, drawn without an underline.\n */\nexport function applyTextProps(node: SceneNode, pen: PenNode, ctx: VarContext): void {\n const isIconFont = pen.type === 'icon_font'\n node.text = isIconFont ? (pen.iconFontName ?? '') : (pen.content ?? '')\n node.fontFamily = isIconFont\n ? (pen.iconFontFamily ?? 'Material Symbols Sharp')\n : (resolveString(pen.fontFamily, ctx) ?? 'Inter')\n bindIfVar(node, 'fontFamily', pen.fontFamily, ctx)\n node.fontSize = resolveNumber(pen.fontSize, ctx, 14)\n bindIfVar(node, 'fontSize', pen.fontSize, ctx)\n const weight = pen.fontWeight ?? (isIconFont ? pen.weight : undefined)\n node.fontWeight = fontWeight(weight, ctx)\n bindIfVar(node, 'fontWeight', weight, ctx)\n node.italic = resolveString(pen.fontStyle, ctx)?.toLowerCase() === 'italic'\n node.textAlignHorizontal = TEXT_ALIGN[pen.textAlign ?? 'left'] ?? 'LEFT'\n node.textAlignVertical = TEXT_ALIGN_VERTICAL[pen.textAlignVertical ?? 'top'] ?? 'TOP'\n // pen.dev's line height multiplies the font size, so it follows the size as a percent.\n if (pen.lineHeight !== undefined) {\n node.lineHeight = percentLength(resolveNumber(pen.lineHeight, ctx) * 100)\n }\n if (pen.letterSpacing !== undefined) {\n node.letterSpacing = pixelLength(resolveNumber(pen.letterSpacing, ctx))\n }\n node.textAutoResize = TEXT_GROWTH[pen.textGrowth ?? 'auto'] ?? 'WIDTH_AND_HEIGHT'\n // pen.dev draws every font at its default optical size, whatever the text's size.\n node.opticalSizeFromFontSize = false\n node.strokes = []\n node.styleRuns = textLink(pen, node.text, ctx)\n}\n\n/** A text's `href` links all of its characters, as one run. */\nfunction textLink(pen: PenNode, text: string, ctx: VarContext): StyleRun[] {\n const href = pen.type === 'text' ? resolveString(pen.href ?? undefined, ctx)?.trim() : undefined\n if (!href || text.length === 0) return []\n return [{ start: 0, length: text.length, style: { hyperlink: { type: 'URL', value: href } } }]\n}\n","import type {\n AxisSizingMode,\n LayoutMode,\n LayoutSizing,\n NodeType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { CORNER_FIELDS } from '@pairdraw/scene-graph/fields'\nimport { fillSizingFields } from '@pairdraw/scene-graph/layout'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { applyAnnotation, createAnnotation, isAnnotation } from './annotations'\nimport { convertEffects } from './effects'\nimport { ellipseArc } from './geometry'\nimport { drawIcon, insideComponent, useIconComponent } from './icons'\nimport type { PenImages } from './images'\nimport {\n applyCornerRadius,\n applyPadding,\n mapAlignItems,\n mapJustifyContent,\n mapLayoutMode,\n parseSize\n} from './layout'\nimport { applyStroke, convertPaints, strokeFields, type PenShaderSources } from './paints'\nimport { applyPlaceholderLook, isPlaceholder, placeholderLabel } from './placeholders'\nimport { isPlain, type PenPlacement } from './placement'\nimport { applyPenPluginData, UNRESOLVED_REF } from './plugin-data'\nimport type { NodeFields, PenNode, PenOverride } from './schema'\nimport { createPenSlot } from './slots'\nimport { applyTextProps } from './text'\nimport { bindIfVar, resolveBoolean, resolveNumber, type VarContext } from './variables'\n\n/** Where icon glyphs come from, as the host loaded them. */\nexport interface PenIconSource {\n /**\n * Draws the icon `name` into the frame, `size` square at its origin, painted `color` where the\n * icon takes its colour and drawn with `options` where its set has them. False when the source\n * does not have it.\n */\n draw(\n graph: SceneGraph,\n frameId: string,\n name: string,\n size: number,\n color: Color,\n options?: Record<string, number>\n ): boolean\n}\n\n/** What reading one document builds up. */\nexport interface Build {\n graph: SceneGraph\n ctx: VarContext\n images: PenImages\n /** Shader files the document's paints and effects name, by URL, as their source. */\n shaders: PenShaderSources | undefined\n icons: PenIconSource | undefined\n /** Reusable nodes by their pen.dev ID. */\n components: Map<string, PenNode>\n /** The pen.dev fields each layer was built from, its instance's and overrides' merged in. */\n effective: Map<string, PenNode>\n /** Instances in reading order, with the `ref` node that made each. */\n instances: Map<string, PenNode>\n /** pen.dev's placement of each turned or mirrored layer, and of every group. */\n placements: Map<string, PenPlacement>\n /** Groups in reading order. */\n groupIds: Set<string>\n /** The components icons in components are instances of, by glyph and size. */\n iconComponents: Map<string, string>\n /** The page those components are on, added with the first one. */\n iconPageId: string | null\n /** Layers whose children an override replaced, whose instances are detached. */\n replaced: Set<string>\n}\n\nfunction penPlacement(pen: PenOverride, ctx: VarContext): PenPlacement {\n return {\n x: pen.x ?? 0,\n y: pen.y ?? 0,\n rotation: resolveNumber(pen.rotation, ctx),\n flipX: resolveBoolean(pen.flipX, ctx, false),\n flipY: resolveBoolean(pen.flipY, ctx, false)\n }\n}\n\n/**\n * A `line` runs from its box's top-left corner to its bottom-right, so a line with no height is\n * a line layer and any other one a vector drawn across its box.\n */\nfunction isFlatLine(pen: PenNode, ctx: VarContext): boolean {\n const height = parseSize(pen.height, 100, ctx)\n return height.sizing === 'FIXED' && height.value === 0\n}\n\nfunction sceneType(pen: PenNode, ctx: VarContext): NodeType {\n if (pen.type === 'frame') return pen.reusable ? 'COMPONENT' : 'FRAME'\n if (pen.type === 'line') return isFlatLine(pen, ctx) ? 'LINE' : 'VECTOR'\n if (isAnnotation(pen)) return 'STICKY'\n if (pen.type === 'rectangle') return 'RECTANGLE'\n if (pen.type === 'ellipse') return 'ELLIPSE'\n if (pen.type === 'polygon') return 'POLYGON'\n if (pen.type === 'group') return 'GROUP'\n if (pen.type === 'text' || pen.type === 'icon_font') return 'TEXT'\n if (pen.type === 'path') return 'VECTOR'\n return 'FRAME'\n}\n\nfunction resolveSizing(pen: PenNode, ctx: VarContext) {\n const isTextLike = pen.type === 'text' || pen.type === 'icon_font'\n const defaultSize = isTextLike ? 20 : 100\n const defaultW = isTextLike && pen.width === undefined ? 0 : defaultSize\n const w = parseSize(pen.width, defaultW, ctx)\n const h = parseSize(pen.height, defaultSize, ctx)\n const layout = mapLayoutMode(pen)\n\n if (pen.width === undefined && layout !== 'NONE') w.sizing = 'HUG'\n if (pen.height === undefined && layout !== 'NONE') h.sizing = 'HUG'\n\n return { w, h, layout, isTextLike }\n}\n\nfunction applyAutoLayout(\n node: SceneNode,\n layoutMode: LayoutMode,\n pen: PenNode,\n widthSizing: LayoutSizing,\n heightSizing: LayoutSizing,\n ctx: VarContext\n): void {\n node.layoutMode = layoutMode\n node.primaryAxisAlign = mapJustifyContent(pen.justifyContent)\n node.counterAxisAlign = mapAlignItems(pen.alignItems)\n node.itemSpacing = resolveNumber(pen.gap, ctx)\n bindIfVar(node, 'itemSpacing', pen.gap, ctx)\n node.strokesIncludedInLayout = pen.layoutIncludeStroke ?? false\n\n // Fill is the child's grow or stretch, set with its parent; the frame itself stays fixed.\n const own = (sizing: LayoutSizing): AxisSizingMode => (sizing === 'HUG' ? 'HUG' : 'FIXED')\n if (layoutMode === 'VERTICAL') {\n node.primaryAxisSizing = own(heightSizing)\n node.counterAxisSizing = own(widthSizing)\n } else {\n node.primaryAxisSizing = own(widthSizing)\n node.counterAxisSizing = own(heightSizing)\n }\n}\n\nconst PLACEMENT_FIELDS = ['x', 'y', 'rotation', 'flipX', 'flipY'] as const\n\n/** What `applyStroke` writes: a stroke's weight and alignment are its paints'. */\nconst STROKE_WRITES = [\n 'strokes',\n 'independentStrokeWeights',\n 'borderTopWeight',\n 'borderRightWeight',\n 'borderBottomWeight',\n 'borderLeftWeight',\n 'strokeCap',\n 'strokeJoin'\n] as const\n\n/**\n * The layer fields each property `applyPenProperties` reads writes. A property that writes none of\n * the layer's own fields maps to none: bookkeeping, the decorations pen.dev does not draw, and an\n * icon's glyph, which is the layer's children or the component it shows.\n */\nconst PROPERTY_FIELDS = {\n name: ['name'],\n context: ['pluginData'],\n metadata: ['pluginData'],\n x: PLACEMENT_FIELDS,\n y: PLACEMENT_FIELDS,\n width: ['width'],\n height: ['height'],\n reusable: [],\n theme: ['variableModes'],\n enabled: ['visible'],\n opacity: ['opacity'],\n flipX: PLACEMENT_FIELDS,\n flipY: PLACEMENT_FIELDS,\n layoutPosition: ['layoutPositioning'],\n rotation: PLACEMENT_FIELDS,\n fill: ['fills'],\n stroke: STROKE_WRITES,\n strokeWidth: STROKE_WRITES,\n strokeLinecap: ['strokes', 'strokeCap'],\n strokeLinejoin: ['strokes', 'strokeJoin'],\n strokeAlignment: ['strokes'],\n effect: ['effects'],\n cornerRadius: CORNER_FIELDS,\n layout: ['layoutMode'],\n gap: ['itemSpacing'],\n layoutIncludeStroke: ['strokesIncludedInLayout'],\n padding: ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'],\n justifyContent: ['primaryAxisAlign'],\n alignItems: ['counterAxisAlign'],\n clip: ['clipsContent'],\n placeholder: ['pluginData'],\n slot: ['pluginData'],\n innerRadius: ['arcData'],\n startAngle: ['arcData'],\n sweepAngle: ['arcData'],\n polygonCount: ['pointCount'],\n geometry: ['vectorNetwork'],\n fillRule: ['vectorNetwork'],\n viewBox: ['vectorNetwork'],\n content: ['text'],\n textGrowth: ['textAutoResize'],\n fontFamily: ['fontFamily'],\n fontSize: ['fontSize'],\n fontWeight: ['fontWeight'],\n fontStyle: ['italic'],\n letterSpacing: ['letterSpacing'],\n lineHeight: ['lineHeight'],\n textAlign: ['textAlignHorizontal'],\n textAlignVertical: ['textAlignVertical'],\n underline: [],\n strikethrough: [],\n href: ['styleRuns'],\n library: [],\n icon: [],\n weight: [],\n iconFontName: [],\n iconFontFamily: [],\n ref: [],\n model: ['pluginData'],\n scriptUri: ['pluginData'],\n inputs: ['pluginData'],\n url: ['pluginData'],\n deviceId: ['pluginData'],\n zoom: ['pluginData'],\n scrollX: ['pluginData'],\n scrollY: ['pluginData']\n} satisfies Record<keyof NodeFields, readonly (keyof SceneNode)[]>\n\nconst isProperty = (key: string): key is keyof typeof PROPERTY_FIELDS => key in PROPERTY_FIELDS\n\n/**\n * The fields the properties `pen` carries write, whatever their values: pen.dev keeps a property\n * an instance sets even when it equals its component's, so a later change to the component does\n * not reach it.\n */\nexport function fieldsSetBy(pen: PenOverride): (keyof SceneNode)[] {\n return Object.keys(pen).flatMap((key) => (isProperty(key) ? PROPERTY_FIELDS[key] : []))\n}\n\nfunction drawIconLayer(node: SceneNode, pen: PenNode, build: Build): void {\n if (node.type === 'INSTANCE') useIconComponent(node, pen, build)\n else drawIcon(node, pen, build)\n}\n\n/**\n * Draws a filling or fitting icon again at its laid-out size, which reading it could only guess.\n * Drawing takes the icon's colour from its fill and moves it to the glyph, so the fill is read again.\n */\nexport function redrawIconAtLaidOutSize(node: SceneNode, pen: PenNode, build: Build): void {\n const { w, h } = resolveSizing(pen, build.ctx)\n if (w.sizing === 'FIXED' && h.sizing === 'FIXED') return\n node.fills = convertPaints(pen.fill, 'fills', build.ctx, node, build.images, build.shaders)\n drawIconLayer(node, pen, build)\n}\n\n/**\n * Sets every field a layer takes from its pen.dev fields, so a layer copied from a component can be\n * given its overrides by applying its merged fields again. Turned and mirrored layers are built\n * upright and placed once laid out.\n */\n// eslint-disable-next-line complexity -- .pen node mapping touches many format-specific fields\nexport function applyPenProperties(node: SceneNode, pen: PenNode, build: Build): void {\n if (node.type === 'STICKY') {\n applyAnnotation(node, pen, build)\n return\n }\n const { graph, ctx } = build\n const { w, h, layout, isTextLike } = resolveSizing(pen, ctx)\n const hasChildren = (pen.children?.length ?? 0) > 0 || node.childIds.length > 0\n const parentLayout = (node.parentId && graph.getNode(node.parentId)?.layoutMode) || 'NONE'\n // An absolute layer leaves its parent's flow; fill sizing then falls back to its value.\n const absolute = pen.layoutPosition === 'absolute' && parentLayout !== 'NONE'\n const flowLayout = absolute ? 'NONE' : parentLayout\n\n Object.assign(node, {\n name: pen.name ?? (pen.type === 'icon_font' ? (pen.iconFontName ?? 'Icon') : pen.type),\n x: pen.x ?? 0,\n y: pen.y ?? 0,\n rotation: 0,\n flipX: false,\n flipY: false,\n width: w.value,\n height: h.value,\n minWidth: !hasChildren && w.fitContentFallback !== undefined ? w.fitContentFallback : null,\n minHeight: !hasChildren && h.fitContentFallback !== undefined ? h.fitContentFallback : null,\n visible: resolveBoolean(pen.enabled, ctx),\n opacity: resolveNumber(pen.opacity, ctx, 1),\n clipsContent: resolveBoolean(pen.clip, ctx, false),\n layoutPositioning: absolute ? 'ABSOLUTE' : 'AUTO',\n layoutGrow: 0,\n layoutAlignSelf: 'AUTO',\n boundVariables: {},\n variableModes: pen.theme && ctx.collectionId ? { [ctx.collectionId]: ctx.modeId() } : {}\n } satisfies Partial<SceneNode>)\n bindIfVar(node, 'visible', pen.enabled, ctx)\n bindIfVar(node, 'opacity', pen.opacity, ctx)\n bindIfVar(node, 'width', pen.width, ctx)\n bindIfVar(node, 'height', pen.height, ctx)\n\n node.layoutMode = 'NONE'\n if (layout !== 'NONE') {\n const widthSizing = flowLayout === 'NONE' && w.sizing === 'FILL' ? 'FIXED' : w.sizing\n const heightSizing = flowLayout === 'NONE' && h.sizing === 'FILL' ? 'FIXED' : h.sizing\n applyAutoLayout(node, layout, pen, widthSizing, heightSizing, ctx)\n }\n\n const placement = penPlacement(pen, ctx)\n if (pen.type === 'group') build.groupIds.add(node.id)\n if (pen.type === 'group' || !isPlain(placement)) build.placements.set(node.id, placement)\n else build.placements.delete(node.id)\n\n node.fills = convertPaints(pen.fill, 'fills', ctx, node, build.images, build.shaders)\n applyStroke(node, strokeFields(pen), ctx, build.images, build.shaders)\n // A line layer has no inside or outside; its stroke is centred on it.\n if (node.type === 'LINE')\n node.strokes = node.strokes.map((paint) => ({ ...paint, align: 'CENTER' }))\n node.effects = convertEffects(pen.effect, ctx, build.shaders)\n applyCornerRadius(node, pen.cornerRadius, ctx)\n applyPadding(node, pen.padding, ctx)\n\n // Text without a width resizes to its content, which laying out the document measures.\n if (isTextLike) applyTextProps(node, pen, ctx)\n\n if (pen.type === 'icon') drawIconLayer(node, pen, build)\n if (pen.type === 'ellipse') node.arcData = ellipseArc(pen, ctx)\n if (pen.type === 'polygon') node.pointCount = Math.max(3, resolveNumber(pen.polygonCount, ctx, 3))\n\n if (flowLayout !== 'NONE') {\n if (w.sizing === 'FILL') Object.assign(node, fillSizingFields(flowLayout, 'HORIZONTAL'))\n if (h.sizing === 'FILL') Object.assign(node, fillSizingFields(flowLayout, 'VERTICAL'))\n }\n if (isPlaceholder(pen)) applyPlaceholderLook(node, pen)\n applyPenPluginData(node, pen)\n build.effective.set(node.id, pen)\n}\n\n/**\n * The fields an instance draws with: its component's, with the `ref` node's own replacing them one\n * by one, as pen.dev reads them. A theme on both merges axis by axis. A `ref` whose component is\n * missing, such as one from a library the host could not read, is a placeholder naming it.\n */\nfunction instanceFields(ref: PenNode, component: PenNode | undefined): PenNode {\n const { ref: _ref, type: _type, descendants: _descendants, children: _children, ...own } = ref\n if (!component) return { ...own, type: 'frame', [UNRESOLVED_REF]: ref.ref ?? '' }\n const {\n id: _id,\n reusable: _reusable,\n ref: _componentRef,\n children: _componentChildren,\n descendants: _componentDescendants,\n ...inherited\n } = component\n const theme = component.theme || ref.theme ? { ...component.theme, ...ref.theme } : undefined\n return { ...inherited, ...own, theme, name: ref.name ?? component.name }\n}\n\n/**\n * Builds the layers inside a layer that is no instance: a `ref`'s copies of its component's, named\n * by the path to them, or the layer's own, then a placeholder's label and a slot.\n */\nfunction createChildren(node: SceneNode, pen: PenNode, fields: PenNode, build: Build): void {\n const component = pen.type === 'ref' && pen.ref ? build.components.get(pen.ref) : undefined\n const children = pen.type === 'ref' ? (component?.children ?? []) : (pen.children ?? [])\n for (const child of children) {\n createSceneNode(\n pen.type === 'ref' ? { ...child, id: `${pen.id}/${child.id}` } : child,\n node.id,\n build\n )\n }\n const label = placeholderLabel(fields, node.id)\n if (label) createSceneNode(label, node.id, build)\n createPenSlot(node, fields, build)\n}\n\n/** Builds a layer and its children in the layer's theme, merged over its parent's. */\nexport function createSceneNode(pen: PenNode, parentId: string, build: Build): string {\n const component = pen.type === 'ref' && pen.ref ? build.components.get(pen.ref) : undefined\n // A component that is not a frame has no instances; its uses are plain copies.\n const instanceOf = pen.type === 'ref' && component?.type === 'frame' ? component : undefined\n const fields = pen.type === 'ref' ? instanceFields(pen, component) : pen\n const iconInstance = fields.type === 'icon' && insideComponent(build.graph, parentId)\n const leaveTheme = fields.theme ? build.ctx.enterTheme(fields.theme) : undefined\n try {\n const type = instanceOf || iconInstance ? 'INSTANCE' : sceneType(fields, build.ctx)\n const node =\n type === 'STICKY'\n ? createAnnotation({ ...fields, id: pen.id }, parentId, build)\n : build.graph.createNode(type, parentId, { id: pen.id })\n applyPenProperties(node, fields, build)\n if (instanceOf) {\n node.componentId = instanceOf.id\n build.instances.set(node.id, pen)\n } else {\n createChildren(node, pen, fields, build)\n }\n return node.id\n } finally {\n leaveTheme?.()\n }\n}\n","import { pick } from 'es-toolkit/object'\nimport { isEqual } from 'es-toolkit/predicate'\n\nimport { generateId, type SceneGraph, type SceneNode } from '@pairdraw/scene-graph'\nimport {\n detachInstance,\n INSTANCE_OVERRIDE_FIELDS,\n populateInstanceChildren,\n recordInstanceOverride,\n swapInstanceComponent\n} from '@pairdraw/scene-graph/instances'\n\nimport { applyPenProperties, createSceneNode, fieldsSetBy, type Build } from './nodes'\nimport type { PenNode, PenOverride } from './schema'\nimport { claimSlot } from './slots'\n\n/** Fills an instance read from `.pen`, after the instances inside its component. */\ntype Populate = (id: string) => void\n\n/** The layers a copy was made from, nearest first, through copies of copies. */\nfunction sources(graph: SceneGraph, node: SceneNode): Set<string> {\n const found = new Set<string>()\n for (\n let id = node.componentId;\n id && !found.has(id);\n id = graph.getNode(id)?.componentId ?? null\n ) {\n found.add(id)\n }\n return found\n}\n\n/** The copy in `root`'s layers made from the pen.dev layer `sourceId`, at any depth. */\nfunction findCopy(graph: SceneGraph, root: SceneNode, sourceId: string): SceneNode | undefined {\n const queue = graph.getChildren(root.id)\n for (const node of queue) {\n if (sources(graph, node).has(sourceId)) return node\n queue.push(...graph.getChildren(node.id))\n }\n return undefined\n}\n\n/**\n * The layer an override's key names: pen.dev IDs separated by `/`, each one inside the copy of the\n * instance the one before it names.\n */\nfunction resolvePath(graph: SceneGraph, instance: SceneNode, path: string): SceneNode | undefined {\n let current: SceneNode | undefined = instance\n for (const id of path.split('/')) {\n current = current ? findCopy(graph, current, id) : undefined\n }\n return current\n}\n\n/** Runs `apply` in the merged theme of a layer's ancestors, as the layer was read in. */\nexport function inAncestorThemes<T>(build: Build, node: SceneNode, apply: () => T): T {\n const chain: Record<string, string>[] = []\n for (let id = node.parentId; id; id = build.graph.getNode(id)?.parentId ?? null) {\n const theme = build.effective.get(id)?.theme\n if (theme) chain.unshift(theme)\n }\n const leave = chain.map((theme) => build.ctx.enterTheme(theme))\n try {\n return apply()\n } finally {\n for (const exit of leave.toReversed()) exit()\n }\n}\n\nfunction replaceLayer(\n build: Build,\n target: SceneNode,\n replacement: PenOverride,\n populate: Populate\n): void {\n const { graph } = build\n const parentId = target.parentId\n if (!parentId) return\n if (swapLayer(build, target, replacement, populate)) return\n const index = graph.getNode(parentId)?.childIds.indexOf(target.id) ?? -1\n const pen: PenNode = {\n ...replacement,\n type: replacement.type ?? 'frame',\n id: replacement.id ?? generateId()\n }\n inAncestorThemes(build, target, () => {\n graph.deleteNode(target.id)\n const id = createSceneNode(pen, parentId, build)\n if (id && index >= 0) graph.insertChildAt(id, parentId, index)\n // The parent's layers changed; a replacement that is itself an instance stays one.\n if (id) build.replaced.add(parentId)\n })\n}\n\n/**\n * Swaps a nested instance an override replaces with an instance of another component for that\n * component, as Figma's instance swap does, so the instances holding it stay instances. The\n * replacement's own fields and overrides then apply to the swapped layer. Returns whether it\n * swapped; any other replacement changes the layers of the instance holding it.\n */\nfunction swapLayer(\n build: Build,\n target: SceneNode,\n replacement: PenOverride,\n populate: Populate\n): boolean {\n const { graph, effective, instances } = build\n const component =\n typeof replacement.ref === 'string' ? build.components.get(replacement.ref) : undefined\n if (target.type !== 'INSTANCE' || replacement.type !== 'ref' || component?.type !== 'frame')\n return false\n for (const nested of instances.keys()) {\n if (graph.isDescendant(nested, component.id)) populate(nested)\n }\n swapInstanceComponent(graph, target.id, component.id)\n if (graph.getNode(target.id)?.componentId !== component.id) return false\n const {\n children: _children,\n reusable: _reusable,\n descendants: _descendants,\n ...fields\n } = component\n effective.set(target.id, { ...fields, id: target.id })\n inheritCopyFields(build, target)\n const { ref: _ref, type: _type, id: _id, descendants, ...own } = replacement\n overrideLayer(build, target, own)\n applyDescendants(build, target, descendants, populate)\n return true\n}\n\n/**\n * Records as the instance's overrides the fields an override set or changed on a copy, so they\n * survive the instance's next sync and a save, as an edit made in the editor would.\n */\nfunction recordChangedFields(\n graph: SceneGraph,\n target: SceneNode,\n before: Partial<SceneNode>,\n override: PenOverride\n): void {\n const changed = INSTANCE_OVERRIDE_FIELDS.filter((field) => !isEqual(before[field], target[field]))\n recordInstanceOverride(graph, target.id, [...changed, ...fieldsSetBy(override)])\n}\n\n/**\n * Records as the instance's own overrides the fields its `ref` sets or makes differ from its\n * component's. A size counts only when the `ref` sets it: otherwise it is the layout's, which\n * follows the component's.\n */\nfunction recordOwnFields(graph: SceneGraph, instance: SceneNode, ref: PenNode): void {\n const component = instance.componentId ? graph.getNode(instance.componentId) : undefined\n if (!component) return\n const changed = INSTANCE_OVERRIDE_FIELDS.filter(\n (field) =>\n (field !== 'width' || 'width' in ref) &&\n (field !== 'height' || 'height' in ref) &&\n !isEqual(instance[field], component[field])\n )\n recordInstanceOverride(graph, instance.id, [...changed, ...fieldsSetBy(ref)])\n}\n\n/**\n * Gives a copy an override's fields. Children the override gives a slot of `instance` become the\n * instance's content for that slot; any other layer's children are replaced, which detaches the\n * instances holding it.\n */\nfunction overrideLayer(\n build: Build,\n target: SceneNode,\n override: PenOverride,\n instance?: SceneNode\n): void {\n const { graph, ctx, effective } = build\n const base = effective.get(target.id) ?? { type: 'frame', id: target.id }\n const { descendants: _descendants, children, ...fields } = override\n const merged: PenNode = { ...base, ...fields, type: base.type, id: base.id }\n const before = structuredClone(pick(target, INSTANCE_OVERRIDE_FIELDS))\n inAncestorThemes(build, target, () => {\n const leave = merged.theme ? ctx.enterTheme(merged.theme) : undefined\n try {\n applyPenProperties(target, merged, build)\n recordChangedFields(graph, target, before, fields)\n if (children) {\n const fillsSlot = instance !== undefined && claimSlot(build, instance, target)\n const replaced = target.childIds\n for (const childId of replaced) graph.deleteNode(childId)\n for (const child of children) createSceneNode(child, target.id, build)\n if (!fillsSlot) build.replaced.add(target.id)\n }\n } finally {\n leave?.()\n }\n })\n}\n\n/**\n * Detaches the instances holding a layer whose children an override replaced. An instance keeps\n * its component's layers, overriding their fields but never replacing them, so such an instance\n * becomes a frame that keeps what it shows, as detaching it in Figma does.\n */\nfunction detachReplacingInstances(build: Build): void {\n const { graph } = build\n for (const id of build.replaced) {\n for (let node = graph.getNode(id); node;) {\n if (node.type === 'INSTANCE') detachInstance(graph, node.id)\n node = node.parentId ? graph.getNode(node.parentId) : undefined\n }\n }\n build.replaced.clear()\n}\n\n/** Gives an instance's copies their overrides; a key with a `type` replaces the layer. */\nfunction applyDescendants(\n build: Build,\n instance: SceneNode,\n descendants: PenNode['descendants'],\n populate: Populate\n): void {\n for (const [path, override] of Object.entries(descendants ?? {})) {\n const target = resolvePath(build.graph, instance, path)\n if (!target) continue\n if (override.type) replaceLayer(build, target, override, populate)\n else overrideLayer(build, target, override, instance)\n }\n}\n\n/** Gives each copy inside `root` the pen.dev fields and placement of the layer it copies. */\nfunction inheritCopyFields(build: Build, root: SceneNode): void {\n const { graph, effective, placements } = build\n const copies = graph.getChildren(root.id)\n for (const copy of copies) {\n const source = copy.componentId\n const fields = source ? effective.get(source) : undefined\n if (fields) effective.set(copy.id, fields)\n const placement = source ? placements.get(source) : undefined\n if (placement) placements.set(copy.id, placement)\n if (source && build.groupIds.has(source)) build.groupIds.add(copy.id)\n copies.push(...graph.getChildren(copy.id))\n }\n}\n\n/**\n * Fills each instance with copies of its component's layers, then applies its overrides. An\n * instance inside a component is filled first, so the copies made of it carry its layers and\n * overrides; a copy keeps its source's pen.dev fields and placement.\n */\nexport function populateInstances(build: Build): void {\n const { graph, instances } = build\n const done = new Set<string>()\n\n function populate(id: string): void {\n if (done.has(id)) return\n done.add(id)\n const instance = graph.getNode(id)\n const ref = instances.get(id)\n if (!instance?.componentId || !ref) return\n const component = graph.getNode(instance.componentId)\n if (!component) return\n for (const nested of instances.keys()) {\n if (graph.isDescendant(nested, component.id)) populate(nested)\n }\n populateInstanceChildren(graph, instance.id, component.id)\n recordOwnFields(graph, instance, ref)\n inheritCopyFields(build, instance)\n applyDescendants(build, instance, ref.descendants, populate)\n // Before anything copies this instance, so the copies are of what it became.\n detachReplacingInstances(build)\n }\n\n // A replacement may hold instances of its own, which join the map as they are read.\n for (const id of instances.keys()) populate(id)\n}\n","import * as v from 'valibot'\n\nimport { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { lineNetwork, pathNetwork } from './geometry'\nimport { removeUnusedIconComponents } from './icons'\nimport { createImageStore } from './images'\nimport { withImports, type PenImports } from './imports'\nimport { inAncestorThemes, populateInstances } from './instances'\nimport { createLibraryRoots, markLibraryRoots } from './library'\nimport { createSceneNode, redrawIconAtLaidOutSize, type Build, type PenIconSource } from './nodes'\nimport { placeLayers } from './placement'\nimport { penFileSchema, type PenDocument, type PenNode } from './schema'\nimport { buildVarContext } from './variables'\n\n/** Options for reading a document. */\nexport interface PenReadOptions {\n /**\n * Lays out the graph's auto layout and text, as `layoutAuthoredNodes` in Core does. Turned and\n * mirrored layers are placed after it, since where they land depends on their final size.\n */\n layout?(graph: SceneGraph): void\n /** The image files the document's paints name, by their URL in it; see `penAssets`. */\n images?: ReadonlyMap<string, Uint8Array>\n /**\n * The shader files the document's paints and effects name, by their URL in it, as their source\n * text; see `penAssets`. A shader whose file is missing draws nothing.\n */\n shaders?: ReadonlyMap<string, string>\n /** Where icon glyphs come from; icons are empty frames without it. */\n icons?: PenIconSource\n /**\n * The documents the document imports, by alias, as `importedDocument` gives them. Their\n * variables join the document's as `<alias>:<name>`, and the components it uses, as\n * `<alias>:<id>`, go on the hidden library page as read-only library definitions. A `ref` to a\n * component no import has reads as a placeholder.\n */\n imports?: PenImports\n}\n\nfunction collectComponents(nodes: PenNode[], components: Map<string, PenNode>): void {\n for (const node of nodes) {\n if (node.reusable) components.set(node.id, node)\n if (node.children) collectComponents(node.children, components)\n }\n}\n\n/** Whether a group sits in an auto layout's flow, where fitting it changes the layout. */\nfunction groupsInFlow(graph: SceneGraph, groupIds: Iterable<string>): boolean {\n for (const id of groupIds) {\n const group = graph.getNode(id)\n const parent = group?.parentId ? graph.getNode(group.parentId) : undefined\n if (parent && parent.layoutMode !== 'NONE') return true\n }\n return false\n}\n\n/**\n * Draws each path and slanted line in its box once boxes have their final size, which fill and\n * fit sizing only give once laid out, and redraws each icon laying out sized.\n */\nfunction drawAtFinalSize(build: Build, laidOut: boolean): void {\n for (const [id, pen] of build.effective) {\n const node = build.graph.getNode(id)\n if (!node) continue\n if (pen.type === 'path') {\n const network = pathNetwork(pen, node.width, node.height)\n if (network) node.vectorNetwork = network\n } else if (pen.type === 'line' && node.type === 'VECTOR') {\n node.vectorNetwork = lineNetwork(node.width, node.height)\n } else if (pen.type === 'icon' && laidOut) {\n // In the themes the icon was read in, which its colour and glyph may take variables from.\n inAncestorThemes(build, node, () => {\n const leave = pen.theme ? build.ctx.enterTheme(pen.theme) : undefined\n try {\n redrawIconAtLaidOutSize(node, pen, build)\n } finally {\n leave?.()\n }\n })\n }\n }\n}\n\n/** A `.pen` document's JSON, validated; throws for text that is not one. */\nexport function parsePenDocument(json: string): PenDocument {\n const parsed = v.safeParse(penFileSchema, json)\n if (!parsed.success) {\n throw new Error(`Not a .pen document: ${v.summarize(parsed.issues)}`)\n }\n return parsed.output\n}\n\n/** Builds the scene graph of a document `parsePenDocument` read. */\nexport function buildPenGraph(doc: PenDocument, options: PenReadOptions = {}): SceneGraph {\n const graph = new SceneGraph()\n\n for (const page of graph.getPages(true)) {\n graph.deleteNode(page.id)\n }\n\n const imports: PenImports = options.imports ?? new Map()\n const build: Build = {\n graph,\n ctx: buildVarContext(graph, withImports(doc, imports)),\n images: createImageStore(graph, options.images),\n shaders: options.shaders,\n icons: options.icons,\n components: new Map(),\n effective: new Map(),\n instances: new Map(),\n placements: new Map(),\n groupIds: new Set(),\n iconComponents: new Map(),\n iconPageId: null,\n replaced: new Set()\n }\n collectComponents(doc.children, build.components)\n for (const imported of imports.values())\n collectComponents(imported.doc.children, build.components)\n\n const page = graph.addPage(doc.children[0]?.name ?? 'Page 1')\n for (const child of doc.children) createSceneNode(child, page.id, build)\n const libraryRoots = createLibraryRoots(doc, imports, build, createSceneNode)\n populateInstances(build)\n\n options.layout?.(graph)\n drawAtFinalSize(build, options.layout !== undefined)\n placeLayers(graph, build.placements, [...build.groupIds])\n if (options.layout && groupsInFlow(graph, build.groupIds)) {\n options.layout(graph)\n drawAtFinalSize(build, true)\n }\n removeUnusedIconComponents(build)\n markLibraryRoots(graph, libraryRoots)\n\n if (graph.getPages(true).length === 0) {\n graph.addPage('Page 1')\n }\n\n return graph\n}\n\nexport function parsePenFile(json: string, options: PenReadOptions = {}): SceneGraph {\n return buildPenGraph(parsePenDocument(json), options)\n}\n\nexport async function readPenFile(file: File, options?: PenReadOptions): Promise<SceneGraph> {\n return parsePenFile(await file.text(), options)\n}\n","import type {\n BlendMode,\n Fill,\n GradientTransform,\n LayoutAlign,\n LayoutCounterAlign,\n SceneGraph,\n SceneNode,\n ShadowEffect,\n Stroke,\n Variable,\n VariableCollection,\n VariableValue\n} from '@pairdraw/scene-graph'\nimport { SceneGraph as SceneGraphValue } from '@pairdraw/scene-graph'\nimport { colorToHex, colorToHex8 } from '@pairdraw/scene-graph/color'\nimport { getNodeLocalMatrix } from '@pairdraw/scene-graph/coordinate'\nimport { stickySublayers } from '@pairdraw/scene-graph/generated'\nimport { applyGradientTransform, invertGradientTransform } from '@pairdraw/scene-graph/gradient'\nimport { layoutSizing } from '@pairdraw/scene-graph/layout'\nimport type { Color, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { PEN_PLUGIN_DATA_NAMESPACE } from './plugin-data'\nimport type {\n PenDocument,\n PenEffect,\n PenNode,\n PenNumber,\n PenPaint,\n PenPaints,\n PenSides,\n PenVariable,\n PenVariableScalar\n} from './schema'\nconst PEN_VERSION = '2.21'\nconst PEN_PLUGIN_FIELDS: Readonly<Partial<Record<string, string>>> = {\n 'pen/type': 'type',\n 'pen/ref': 'ref',\n 'pen/generated': 'generated',\n 'pen/context': 'context',\n 'pen/placeholder': 'placeholder',\n 'pen/slot': 'slot',\n 'pen/model': 'model',\n 'pen/scriptUri': 'scriptUri',\n 'pen/inputs': 'inputs',\n 'pen/url': 'url',\n 'pen/deviceId': 'deviceId',\n 'pen/zoom': 'zoom',\n 'pen/scrollX': 'scrollX',\n 'pen/scrollY': 'scrollY'\n}\n\ntype PenWriteState = {\n graph: SceneGraph\n variables: ReadonlyMap<string, Variable>\n collections: ReadonlyMap<string, VariableCollection>\n}\n/** Snaps matrix values that are within floating-point noise of an integer. */\nfunction snapCoordinate(value: number): number {\n return Math.abs(value - Math.round(value)) < 1e-9 ? Math.round(value) : value\n}\nfunction rounded(value: number): number {\n return Number(value.toFixed(3))\n}\nfunction colorValue(value: Color): string {\n return value.a === 1 ? colorToHex(value) : colorToHex8(value)\n}\nfunction variableReference(state: PenWriteState, id: string | undefined): string | undefined {\n const variable = id === undefined ? undefined : state.variables.get(id)\n return variable === undefined ? undefined : `$${variable.name}`\n}\nfunction variableOr<T>(state: PenWriteState, node: SceneNode, field: string, value: T): T | string {\n return variableReference(state, node.boundVariables[field]) ?? value\n}\n\n/** Matches the pen corner convention of placing x/y after undoing the node's rotation or flip. */\nfunction penCoordinates(node: SceneNode): Vector {\n if (node.rotation === 0 && !node.flipX && !node.flipY) return { x: node.x, y: node.y }\n const matrix = getNodeLocalMatrix({ ...node, x: 0, y: 0 })\n return { x: snapCoordinate(node.x + matrix[2]), y: snapCoordinate(node.y + matrix[5]) }\n}\n\n/** pen.dev's names for the scene graph's blend modes, inverse of the reader's `BLEND_MODES`. */\nconst BLEND_MODE_NAMES: Partial<Record<BlendMode, string>> = {\n NORMAL: 'normal',\n DARKEN: 'darken',\n MULTIPLY: 'multiply',\n COLOR_BURN: 'colorBurn',\n LIGHTEN: 'light',\n SCREEN: 'screen',\n COLOR_DODGE: 'colorDodge',\n OVERLAY: 'overlay',\n SOFT_LIGHT: 'softLight',\n HARD_LIGHT: 'hardLight',\n DIFFERENCE: 'difference',\n EXCLUSION: 'exclusion',\n HUE: 'hue',\n SATURATION: 'saturation',\n COLOR: 'color',\n LUMINOSITY: 'luminosity'\n}\nfunction paintBase(fill: Fill): Record<string, unknown> {\n const result: Record<string, unknown> = {}\n if (!fill.visible) result.enabled = false\n if (fill.opacity !== 1) result.opacity = rounded(fill.opacity)\n const blendMode = (fill.blendMode && BLEND_MODE_NAMES[fill.blendMode]) ?? undefined\n if (blendMode && blendMode !== 'normal') result.blendMode = blendMode\n return result\n}\n\nfunction gradientName(type: Fill['type']): 'linear' | 'radial' | 'angular' | 'diamond' {\n if (type === 'GRADIENT_RADIAL') return 'radial'\n if (type === 'GRADIENT_ANGULAR') return 'angular'\n if (type === 'GRADIENT_DIAMOND') return 'diamond'\n return 'linear'\n}\n\nfunction gradientPoint(inverse: GradientTransform | undefined, point: Vector): Vector {\n return inverse === undefined ? point : applyGradientTransform(inverse, point)\n}\nfunction gradientAxis(\n fill: Fill,\n inverse: GradientTransform | undefined,\n center: Vector,\n first: Vector,\n second: Vector\n): { rotation: number; width: number; height: number } {\n const firstLength = 2 * Math.hypot(first.x - center.x, first.y - center.y)\n const secondLength = 2 * Math.hypot(second.x - center.x, second.y - center.y)\n const rotationOf = (axis: Vector, offset: number): number =>\n offset - (Math.atan2(axis.x, -axis.y) * 180) / Math.PI\n if (fill.type === 'GRADIENT_LINEAR') {\n const axis =\n inverse === undefined\n ? { x: 0, y: -1 }\n : {\n x: applyGradientTransform(inverse, { x: 1, y: 0.5 }).x - center.x,\n y: applyGradientTransform(inverse, { x: 1, y: 0.5 }).y - center.y\n }\n return { rotation: rotationOf(axis, 0), width: secondLength, height: firstLength }\n }\n if (fill.type === 'GRADIENT_RADIAL' || fill.type === 'GRADIENT_DIAMOND') {\n const axis = { x: second.x - center.x, y: second.y - center.y }\n return { rotation: rotationOf(axis, 180), width: firstLength, height: secondLength }\n }\n const axis = { x: first.x - center.x, y: first.y - center.y }\n return { rotation: rotationOf(axis, 0), width: secondLength, height: firstLength }\n}\nfunction gradientPaint(fill: Fill): PenPaint {\n const transform = fill.gradientTransform\n const inverse = transform === undefined ? undefined : invertGradientTransform(transform)\n const center = gradientPoint(inverse, { x: 0.5, y: 0.5 })\n const first = gradientPoint(inverse, { x: 1, y: 0.5 })\n const second = gradientPoint(inverse, { x: 0.5, y: 1 })\n const axis = gradientAxis(fill, inverse, center, first, second)\n return {\n type: 'gradient',\n gradientType: gradientName(fill.type),\n ...paintBase(fill),\n center: { x: rounded(center.x), y: rounded(center.y) },\n size: { width: rounded(axis.width), height: rounded(axis.height) },\n rotation: rounded(axis.rotation),\n colors: (fill.gradientStops ?? []).map((stop) => ({\n color: colorValue(stop.color),\n position: rounded(stop.position)\n }))\n }\n}\n\nfunction imagePaint(fill: Fill): PenPaint {\n return { type: 'image', ...paintBase(fill), url: fill.imageHash }\n}\n\nfunction penPaint(\n state: PenWriteState,\n node: SceneNode,\n field: 'fills' | 'strokes',\n fill: Fill,\n index: number\n): PenPaint {\n if (fill.type === 'SOLID') {\n const binding = variableReference(state, node.boundVariables[`${field}/${index}/color`])\n return { type: 'color', color: binding ?? colorValue(fill.color), ...paintBase(fill) }\n }\n if (fill.type.startsWith('GRADIENT_')) return gradientPaint(fill)\n if (fill.type === 'IMAGE') return imagePaint(fill)\n return { type: fill.type.toLowerCase(), ...paintBase(fill) }\n}\n\nfunction paintsOf(\n state: PenWriteState,\n node: SceneNode,\n field: 'fills' | 'strokes',\n paints: readonly Fill[]\n): PenPaints | undefined {\n if (paints.length === 0) return undefined\n const result = paints.map((paint, index) => penPaint(state, node, field, paint, index))\n return result.length === 1 ? result[0] : result\n}\n\nfunction strokesOf(\n state: PenWriteState,\n node: SceneNode\n): Pick<\n PenNode,\n 'stroke' | 'strokeWidth' | 'strokeAlignment' | 'strokeLinecap' | 'strokeLinejoin'\n> {\n if (node.strokes.length === 0) return {}\n const paints = paintsOf(state, node, 'strokes', node.strokes)\n if (paints === undefined) return {}\n const first = node.strokes[0]\n const strokeWidth: PenNumber | PenSides = node.independentStrokeWeights\n ? {\n top: variableOr(state, node, 'borderTopWeight', rounded(node.borderTopWeight)),\n right: variableOr(state, node, 'borderRightWeight', rounded(node.borderRightWeight)),\n bottom: variableOr(state, node, 'borderBottomWeight', rounded(node.borderBottomWeight)),\n left: variableOr(state, node, 'borderLeftWeight', rounded(node.borderLeftWeight))\n }\n : variableOr(state, node, 'strokeWeight', rounded(first.weight))\n const caps: Record<NonNullable<Stroke['cap']>, string> = {\n NONE: 'butt',\n ROUND: 'round',\n SQUARE: 'square',\n ARROW_LINES: 'butt',\n ARROW_EQUILATERAL: 'butt',\n TRIANGLE_FILLED: 'butt',\n DIAMOND_FILLED: 'butt',\n CIRCLE_FILLED: 'butt'\n }\n const joins: Record<NonNullable<Stroke['join']>, string> = {\n MITER: 'miter',\n BEVEL: 'bevel',\n ROUND: 'round'\n }\n const linecap = first.cap === undefined ? undefined : caps[first.cap]\n const linejoin = first.join === undefined ? undefined : joins[first.join]\n return {\n stroke: paints,\n strokeWidth,\n strokeAlignment: first.align.toLowerCase(),\n strokeLinecap: linecap === 'butt' ? undefined : linecap,\n strokeLinejoin: linejoin === 'miter' ? undefined : linejoin\n }\n}\n\nfunction effectOf(effect: ShadowEffect): PenEffect {\n if (effect.type === 'LAYER_BLUR' || effect.type === 'BACKGROUND_BLUR') {\n return {\n type: effect.type === 'LAYER_BLUR' ? 'blur' : 'background_blur',\n radius: rounded(effect.radius),\n enabled: effect.visible\n }\n }\n return {\n type: 'shadow',\n shadowType: effect.type === 'INNER_SHADOW' ? 'inner' : undefined,\n color: colorValue(effect.color),\n offset: { x: rounded(effect.offset.x), y: rounded(effect.offset.y) },\n blur: rounded(effect.radius),\n spread: rounded(effect.spread),\n enabled: effect.visible\n }\n}\n\nfunction variableType(type: Variable['type']): PenVariable['type'] {\n if (type === 'COLOR') return 'color'\n if (type === 'FLOAT') return 'number'\n if (type === 'BOOLEAN') return 'boolean'\n return 'string'\n}\n\nfunction layoutFields(state: PenWriteState, node: SceneNode): Partial<PenNode> {\n if (node.layoutMode === 'NONE')\n return node.type === 'FRAME' || node.type === 'COMPONENT' ? { layout: 'none' } : {}\n const justify: Partial<Record<LayoutAlign, string>> = {\n CENTER: 'center',\n MAX: 'end',\n SPACE_BETWEEN: 'space_between',\n SPACE_AROUND: 'space_around'\n }\n const align: Partial<Record<LayoutCounterAlign, string>> = {\n CENTER: 'center',\n MAX: 'end',\n STRETCH: 'stretch',\n BASELINE: 'baseline'\n }\n const fields: Partial<PenNode> = {\n layout: node.layoutMode === 'HORIZONTAL' ? 'horizontal' : 'vertical'\n }\n const gapBinding = variableReference(state, node.boundVariables['itemSpacing'])\n if (gapBinding !== undefined) fields.gap = gapBinding\n else if (node.itemSpacing !== 0) fields.gap = rounded(node.itemSpacing)\n if (node.primaryAxisAlign !== 'MIN') fields.justifyContent = justify[node.primaryAxisAlign]\n if (node.counterAxisAlign !== 'MIN') fields.alignItems = align[node.counterAxisAlign]\n const padding: [number, number, number, number] = [\n node.paddingTop,\n node.paddingRight,\n node.paddingBottom,\n node.paddingLeft\n ]\n if (padding.some((value) => value !== 0)) fields.padding = padding\n if (node.clipsContent) fields.clip = true\n if (node.strokesIncludedInLayout) fields.layoutIncludeStroke = true\n return fields\n}\n\nfunction sizing(\n state: PenWriteState,\n node: SceneNode,\n axis: 'HORIZONTAL' | 'VERTICAL'\n): PenNumber | undefined {\n const mode = layoutSizing(state.graph, node, axis)\n if (mode === 'FILL') return 'fill_container'\n if (mode === 'HUG') return 'fit_content'\n return undefined\n}\n\nfunction penPluginFields(node: SceneNode, result: PenNode): void {\n for (const entry of node.pluginData) {\n if (entry.pluginId !== PEN_PLUGIN_DATA_NAMESPACE) continue\n const field = PEN_PLUGIN_FIELDS[entry.key]\n if (field === undefined) continue\n let value: unknown\n try {\n value = JSON.parse(entry.value)\n } catch {\n console.warn(`Skipping corrupt pen plugin field ${field}`)\n continue\n }\n result[field] = value\n }\n}\n\nfunction nodeType(node: SceneNode): string {\n switch (node.type) {\n case 'COMPONENT':\n case 'COMPONENT_SET':\n case 'FRAME':\n case 'SECTION':\n return 'frame'\n case 'RECTANGLE':\n case 'ROUNDED_RECTANGLE':\n return 'rectangle'\n case 'ELLIPSE':\n return 'ellipse'\n case 'POLYGON':\n case 'STAR':\n return 'polygon'\n case 'GROUP':\n case 'BOOLEAN_OPERATION':\n return 'group'\n case 'TEXT':\n return 'text'\n case 'VECTOR':\n return 'path'\n case 'LINE':\n return 'line'\n case 'STICKY':\n return 'note'\n default:\n return 'frame'\n }\n}\n\n/** A line height as the multiple of the font size pen.dev stores; undefined when it has none. */\nfunction lineHeightMultiple(node: SceneNode): number | undefined {\n const lineHeight = node.lineHeight\n if (!lineHeight) return undefined\n if (lineHeight.unit !== 'PIXELS') return rounded(lineHeight.value / 100)\n return node.fontSize > 0 ? rounded(lineHeight.value / node.fontSize) : undefined\n}\n\n/** Letter spacing in the pixels pen.dev stores, a percent following the font size. */\nfunction letterSpacingPixels(node: SceneNode): number {\n const spacing = node.letterSpacing\n return spacing.unit === 'PIXELS' ? spacing.value : (spacing.value / 100) * node.fontSize\n}\n\nfunction textFields(state: PenWriteState, node: SceneNode): Partial<PenNode> {\n if (node.type !== 'TEXT') return {}\n const fields: Partial<PenNode> = { content: node.text }\n if (node.fontFamily !== 'Inter')\n fields.fontFamily = variableOr(state, node, 'fontFamily', node.fontFamily)\n if (node.fontSize !== 14)\n fields.fontSize = variableOr(state, node, 'fontSize', rounded(node.fontSize))\n const fontWeight = variableOr(state, node, 'fontWeight', node.fontWeight)\n if (typeof fontWeight === 'string' || node.fontWeight !== 400) fields.fontWeight = fontWeight\n if (node.italic) fields.fontStyle = 'italic'\n const textAlign: Partial<Record<SceneNode['textAlignHorizontal'], string>> = {\n CENTER: 'center',\n RIGHT: 'right',\n JUSTIFIED: 'justify'\n }\n const textAlignVertical: Partial<Record<SceneNode['textAlignVertical'], string>> = {\n CENTER: 'middle',\n BOTTOM: 'bottom'\n }\n if (node.textAlignHorizontal !== 'LEFT') fields.textAlign = textAlign[node.textAlignHorizontal]\n if (node.textAlignVertical !== 'TOP')\n fields.textAlignVertical = textAlignVertical[node.textAlignVertical]\n const lineHeight = lineHeightMultiple(node)\n if (lineHeight !== undefined) fields.lineHeight = lineHeight\n if (node.letterSpacing.value !== 0) fields.letterSpacing = rounded(letterSpacingPixels(node))\n if (node.textAutoResize === 'HEIGHT') fields.textGrowth = 'fixed-width'\n if (node.textAutoResize === 'NONE' || node.textAutoResize === 'TRUNCATE')\n fields.textGrowth = 'fixed-width-height'\n const link = node.styleRuns.find((run) => run.style.hyperlink?.type === 'URL')\n if (link?.style.hyperlink?.type === 'URL') fields.href = link.style.hyperlink.value\n return fields\n}\n\nfunction cornerFields(node: SceneNode): Partial<PenNode> {\n if (node.independentCorners) {\n return {\n cornerRadius: [\n node.topLeftRadius,\n node.topRightRadius,\n node.bottomRightRadius,\n node.bottomLeftRadius\n ]\n }\n }\n if (node.cornerRadius !== 0) return { cornerRadius: rounded(node.cornerRadius) }\n return {}\n}\n\nfunction variableScalar(value: VariableValue | undefined, state: PenWriteState): PenVariableScalar {\n if (value === undefined) return ''\n if (typeof value === 'object' && 'aliasId' in value) {\n const variable = state.variables.get(value.aliasId)\n return variable === undefined ? '' : `$${variable.name}`\n }\n if (typeof value === 'object') return 'r' in value ? colorValue(value) : ''\n return value\n}\nfunction penVariable(\n variable: Variable,\n collection: VariableCollection | undefined,\n state: PenWriteState\n): PenVariable {\n const modes = collection?.modes ?? []\n if (modes.length <= 1)\n return {\n type: variableType(variable.type),\n value: variableScalar(variable.valuesByMode[modes[0]?.modeId ?? ''], state)\n }\n return {\n type: variableType(variable.type),\n value: modes.map((mode, index) => ({\n value: variableScalar(variable.valuesByMode[mode.modeId], state),\n ...(index === 0 ? {} : { theme: { [collection?.name ?? 'Mode']: mode.name } })\n }))\n }\n}\n\nfunction variablesOf(state: PenWriteState): Record<string, PenVariable> | undefined {\n if (state.graph.variables.size === 0) return undefined\n return Object.fromEntries(\n [...state.graph.variables.values()]\n .sort((left, right) => left.name.localeCompare(right.name))\n .map((variable) => [\n variable.name,\n penVariable(variable, state.collections.get(variable.collectionId), state)\n ])\n )\n}\n\nfunction themesOf(state: PenWriteState): PenDocument['themes'] {\n if (state.graph.variableCollections.size === 0) return undefined\n return Object.fromEntries(\n [...state.graph.variableCollections.values()]\n .sort((left, right) => left.name.localeCompare(right.name))\n .map((collection) => [collection.name, collection.modes.map((mode) => mode.name)])\n )\n}\n\nfunction basicNodeFields(state: PenWriteState, node: SceneNode, result: PenNode): void {\n if (node.name) result.name = node.name\n const placement = penCoordinates(node)\n if (placement.x !== 0) result.x = rounded(placement.x)\n if (placement.y !== 0) result.y = rounded(placement.y)\n result.width = variableOr(\n state,\n node,\n 'width',\n sizing(state, node, 'HORIZONTAL') ?? rounded(node.width)\n )\n result.height = variableOr(\n state,\n node,\n 'height',\n sizing(state, node, 'VERTICAL') ?? rounded(node.height)\n )\n if (!node.visible) result.enabled = false\n if (node.opacity !== 1) result.opacity = rounded(node.opacity)\n if (node.rotation !== 0)\n result.rotation = rounded(node.flipX !== node.flipY ? node.rotation : -node.rotation)\n if (node.flipX) result.flipX = true\n if (node.flipY) result.flipY = true\n const fill = paintsOf(state, node, 'fills', node.fills)\n if (fill !== undefined) result.fill = fill\n Object.assign(\n result,\n strokesOf(state, node),\n layoutFields(state, node),\n cornerFields(node),\n textFields(state, node)\n )\n}\nfunction semanticNodeFields(state: PenWriteState, node: SceneNode, result: PenNode): boolean {\n if (\n node.type === 'TEXT' &&\n node.textAutoResize === 'WIDTH_AND_HEIGHT' &&\n layoutSizing(state.graph, node, 'HORIZONTAL') === 'HUG'\n )\n result.width = 'fit_content'\n if (node.type === 'STICKY') result.content = stickySublayers(state.graph, node)?.body.text ?? ''\n penPluginFields(node, result)\n // Shader effects have no pen.dev form yet; dropping them keeps the file loadable.\n const effects = node.effects.filter((effect): effect is ShadowEffect => effect.type !== 'SHADER')\n if (effects.length > 0)\n result.effect = effects.length === 1 ? effectOf(effects[0]) : effects.map(effectOf)\n if (node.type === 'COMPONENT' || node.type === 'COMPONENT_SET') result.reusable = true\n if (node.type === 'INSTANCE' && node.componentId) {\n result.type = 'ref'\n result.ref = node.componentId\n return true\n }\n return false\n}\nfunction writeNode(state: PenWriteState, node: SceneNode): PenNode {\n const result: PenNode = { id: node.id, type: nodeType(node) }\n basicNodeFields(state, node, result)\n if (semanticNodeFields(state, node, result)) return result\n const children =\n node.type === 'STICKY'\n ? []\n : state.graph\n .getChildren(node.id)\n .filter((child) => !child.internalOnly)\n .map((child) => writeNode(state, child))\n if (children.length > 0) result.children = children\n return result\n}\n\n/** Code-point order, so the canonical text does not depend on the runtime locale. */\nfunction compareCodePoints(left: string, right: string): number {\n if (left < right) return -1\n if (left > right) return 1\n return 0\n}\n\nfunction sortKeys(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(sortKeys)\n if (value !== null && typeof value === 'object') {\n const entries = Object.entries(value as { [key: string]: unknown })\n return Object.fromEntries(\n entries\n .sort(([left], [right]) => compareCodePoints(left, right))\n .map(([key, entry]) => [key, sortKeys(entry)])\n )\n }\n return value\n}\n\nexport function penDocumentFromGraph(graph: SceneGraph): PenDocument {\n const variables = new Map<string, Variable>()\n for (const variable of graph.variables.values()) variables.set(variable.id, variable)\n const collections = new Map<string, VariableCollection>()\n for (const collection of graph.variableCollections.values())\n collections.set(collection.id, collection)\n const state: PenWriteState = { graph, variables, collections }\n const children = graph.getPages().flatMap((page) =>\n graph\n .getChildren(page.id)\n .filter((node) => !node.internalOnly)\n .map((node) => writeNode(state, node))\n )\n const document: PenDocument = { version: PEN_VERSION, children }\n const variablesValue = variablesOf(state)\n if (variablesValue) document.variables = variablesValue\n const themes = themesOf(state)\n if (themes) document.themes = themes\n return document\n}\n\nexport function stringifyPenDocument(document: PenDocument): string {\n return `${JSON.stringify(sortKeys(document), null, 2)}\\n`\n}\n\nexport function writePenDocument(source: PenDocument | SceneGraph): string {\n const document = source instanceof SceneGraphValue ? penDocumentFromGraph(source) : source\n return stringifyPenDocument(document)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAS,gBAAgB,MAAmB,OAAuB;CACjE,IAAI,OAAO,KAAK,QAAQ,UAAU,MAAM,KAAK,KAAK,GAAG;CACrD,IAAI,MAAM,QAAQ,KAAK,IAAI,GAAG,MAAM,KAAK,GAAG,KAAK,IAAI;CACrD,KAAK,MAAM,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