@open-pencil/scene-graph 0.17.0-beta.6 → 0.17.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/copy.d.ts.map +1 -1
- package/dist/copy.js +1 -0
- package/dist/copy.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +13 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/copy.ts +1 -0
- package/src/types.ts +13 -0
package/dist/copy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy.d.ts","names":[],"sources":["../src/copy.ts"],"mappings":";;;iBAiCgB,SAAS,UAAU,MAAM,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"copy.d.ts","names":[],"sources":["../src/copy.ts"],"mappings":";;;iBAiCgB,SAAS,UAAU,MAAM,GAAG,IAAI;iBAWhC,WAAW,GAAG,SAAS;iBAQvB,WAAW,GAAG,SAAS;iBAevB,aAAa,GAAG,WAAW;;iBA2B3B,eAAe,kBAAkB,QAAQ,GAAG,MAAM,IAAI;;iBAMtD,kBAAkB,cAAc;iBAKhC,UAAU,OAAO,SAAS;iBAI1B,YAAY,SAAS,WAAW;iBAIhC,YAAY,SAAS,WAAW;iBAIhC,gBAAgB,OAAO,eAAe;iBAItC,cAAc,MAAM,aAAa;;iBAKjC,iBACd,QAAQ,cACR,qBACC;;iBAQa,mBAAmB,IAAI,gBAAgB;iBAYvC,kBAAkB,OAAO,iBAAiB;;;;;;;iBAU1C,sBACd,MAAM,YACN,aACA,aACA,aACA,aACA,aACA,cACC;iBAca,uBACd,OAAO,gBACP,aACA,aACA,aACA,aACA,aACA,cACC;;;;;iBAWa,mBAAmB,OAAO,gBAAgB,YAAY,aAAa;;iBAmCnE,kBAAkB,QAAQ,4BAA4B;iBAatD,sBAAsB,UAAU,oBAAoB;;;;;;;;KAiBxD;iBAUI,eACd,KAAK,WACL,4BACA,OAAM,gBACL,QAAQ"}
|
package/dist/copy.js
CHANGED
|
@@ -20,6 +20,7 @@ function copyFill(f) {
|
|
|
20
20
|
if (f.gradientStops) copy.gradientStops = f.gradientStops.map(copyGradientStop);
|
|
21
21
|
if (f.gradientTransform) copy.gradientTransform = { ...f.gradientTransform };
|
|
22
22
|
if (f.imageTransform) copy.imageTransform = { ...f.imageTransform };
|
|
23
|
+
if (f.filters) copy.filters = { ...f.filters };
|
|
23
24
|
if (f.patternSpacing) copy.patternSpacing = { ...f.patternSpacing };
|
|
24
25
|
if (f.noiseSize) copy.noiseSize = { ...f.noiseSize };
|
|
25
26
|
return copy;
|
package/dist/copy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy.js","names":[],"sources":["../src/copy.ts"],"sourcesContent":["/**\n * Typed shallow-copy helpers for Fill, Stroke, Effect, and StyleRun.\n *\n * These replace `structuredClone` for known scene-graph array types,\n * avoiding the ~24× overhead of the generic deep-clone algorithm.\n * Each helper spreads the top-level object and any nested objects\n * (color, offset, gradientStops, dashPattern, style) to ensure\n * no shared references between source and copy.\n */\n\nimport { readGeometryBlob } from './geometry'\nimport { cloneInstanceOverrideState } from './instances/overrides'\nimport { createDefaultSourceMetadata } from './node-defaults'\nimport type {\n ArcData,\n ComponentPropertyDefinition,\n ConnectorEndpoint,\n Effect,\n DerivedTextGlyph,\n Fill,\n GeometryPath,\n GradientStop,\n LayoutGrid,\n SceneNode,\n Stroke,\n StyleRun,\n VectorNetwork,\n VectorRegion\n} from './types'\n\n// --- Individual copy functions ---\n\n/** Generic over the paint shape so a stroke keeps its own fields while the paint deep-copies. */\nexport function copyFill<T extends Fill>(f: T): T {\n const copy: T = { ...f, color: { ...f.color } }\n if (f.gradientStops) copy.gradientStops = f.gradientStops.map(copyGradientStop)\n if (f.gradientTransform) copy.gradientTransform = { ...f.gradientTransform }\n if (f.imageTransform) copy.imageTransform = { ...f.imageTransform }\n if (f.patternSpacing) copy.patternSpacing = { ...f.patternSpacing }\n if (f.noiseSize) copy.noiseSize = { ...f.noiseSize }\n return copy\n}\n\nexport function copyStroke(s: Stroke): Stroke {\n const copy = copyFill(s)\n if (s.dashPattern) {\n copy.dashPattern = [...s.dashPattern]\n }\n return copy\n}\n\nexport function copyEffect(e: Effect): Effect {\n const copy: Effect = { ...e, color: { ...e.color }, offset: { ...e.offset } }\n if (e.glass) copy.glass = { ...e.glass }\n if (e.noise) copy.noise = structuredClone(e.noise)\n if (e.texture) copy.texture = structuredClone(e.texture)\n if (e.progressive) {\n copy.progressive = {\n startRadius: e.progressive.startRadius,\n startOffset: { ...e.progressive.startOffset },\n endOffset: { ...e.progressive.endOffset }\n }\n }\n return copy\n}\n\nexport function copyStyleRun(r: StyleRun): StyleRun {\n const copy: StyleRun = {\n ...r,\n style: {\n ...r.style,\n fills: r.style.fills ? r.style.fills.map(copyFill) : undefined,\n textDecorationFills: r.style.textDecorationFills\n ? r.style.textDecorationFills.map(copyFill)\n : undefined,\n fontVariations: r.style.fontVariations\n ? r.style.fontVariations.map((v) => ({ ...v }))\n : undefined,\n fontFeatures: r.style.fontFeatures ? r.style.fontFeatures.map((v) => ({ ...v })) : undefined\n }\n }\n if (r.style.hyperlink) copy.style.hyperlink = { ...r.style.hyperlink }\n if (r.style.lineHeight) copy.style.lineHeight = { ...r.style.lineHeight }\n if (r.style.letterSpacing) copy.style.letterSpacing = { ...r.style.letterSpacing }\n if (r.style.boundVariables) copy.style.boundVariables = { ...r.style.boundVariables }\n return copy\n}\n\n// --- Array copy functions ---\n\nconst internalCopySources = new WeakMap<object, object>()\n\n/** Record immutable lineage for an internal deep copy without sharing mutable values. */\nexport function markCopySource<T extends object>(source: T, copy: T): T {\n internalCopySources.set(copy, internalCopySources.get(source) ?? source)\n return copy\n}\n\n/** Compare internal deep copies in O(1) without traversing large paint or text payloads. */\nexport function hasSameCopySource(left: object, right: object): boolean {\n if (left === right) return true\n return (internalCopySources.get(left) ?? left) === (internalCopySources.get(right) ?? right)\n}\n\nexport function copyFills(fills: Fill[]): Fill[] {\n return fills.map(copyFill)\n}\n\nexport function copyStrokes(strokes: Stroke[]): Stroke[] {\n return strokes.map(copyStroke)\n}\n\nexport function copyEffects(effects: Effect[]): Effect[] {\n return effects.map(copyEffect)\n}\n\nexport function copyLayoutGrids(grids: LayoutGrid[]): LayoutGrid[] {\n return grids.map((grid) => ({ ...grid, color: grid.color ? { ...grid.color } : undefined }))\n}\n\nexport function copyStyleRuns(runs: StyleRun[]): StyleRun[] {\n return runs.map(copyStyleRun)\n}\n\n/** A region, with new loops when given, keeping its own paints and fill style. */\nexport function copyVectorRegion(\n region: VectorRegion,\n loops = region.loops.map((loop) => [...loop])\n): VectorRegion {\n const copy: VectorRegion = { windingRule: region.windingRule, loops }\n if (region.fills) copy.fills = copyFills(region.fills)\n if (region.fillStyleId) copy.fillStyleId = region.fillStyleId\n return copy\n}\n\n/** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */\nexport function cloneVectorNetwork(vn: VectorNetwork): VectorNetwork {\n return {\n vertices: vn.vertices.map((v) => ({ ...v })),\n segments: vn.segments.map((s) => ({\n ...s,\n tangentStart: { ...s.tangentStart },\n tangentEnd: { ...s.tangentEnd }\n })),\n regions: vn.regions.map((r) => copyVectorRegion(r))\n }\n}\n\nexport function copyGeometryPaths(paths: GeometryPath[]): GeometryPath[] {\n return paths.map((p) => ({ windingRule: p.windingRule, commandsBlob: p.commandsBlob.slice() }))\n}\n\n/**\n * Affine-transform every coordinate pair in a path command blob (returns a\n * copy): (x, y) → (m00·x + m01·y + tx, m10·x + m11·y + ty).\n * Command layout: 1=move/2=line (1 pair), 3=quad (2 pairs), 4=cubic (3 pairs)\n * — font-glyph blobs are quad-heavy, so skipping command 3 desyncs the walk.\n */\nexport function transformGeometryBlob(\n blob: Uint8Array,\n m00: number,\n m01: number,\n m10: number,\n m11: number,\n tx = 0,\n ty = 0\n): Uint8Array {\n const out = blob.slice()\n const view = new DataView(out.buffer, out.byteOffset, out.byteLength)\n readGeometryBlob(out, (_, coords, offset) => {\n for (let i = 0; i < coords.length; i += 2) {\n const x = coords[i]\n const y = coords[i + 1]\n view.setFloat32(offset + i * 4, m00 * x + m01 * y + tx, true)\n view.setFloat32(offset + i * 4 + 4, m10 * x + m11 * y + ty, true)\n }\n })\n return out\n}\n\nexport function transformGeometryPaths(\n paths: GeometryPath[],\n m00: number,\n m01: number,\n m10: number,\n m11: number,\n tx = 0,\n ty = 0\n): GeometryPath[] {\n return paths.map((g) => ({\n windingRule: g.windingRule,\n commandsBlob: transformGeometryBlob(g.commandsBlob, m00, m01, m10, m11, tx, ty)\n }))\n}\n\n/**\n * Scale path command blob coordinates by (sx, sy).\n * Identity scale returns a deep copy (same as copyGeometryPaths).\n */\nexport function scaleGeometryPaths(paths: GeometryPath[], sx: number, sy: number): GeometryPath[] {\n if (sx === 1 && sy === 1) return copyGeometryPaths(paths)\n return transformGeometryPaths(paths, sx, 0, 0, sy)\n}\n\n// --- Internal helpers ---\n\n/** Copy an optional array: non-empty → mapped, empty → [], undefined → undefined. */\nfunction copyOpt<T, U>(arr: T[] | undefined, fn: (arr: T[]) => U[]): U[] | undefined {\n if (arr === undefined) return undefined\n return arr.length > 0 ? fn(arr) : []\n}\n\nfunction copyGradientStop(gs: GradientStop): GradientStop {\n return { color: { ...gs.color }, position: gs.position }\n}\n\nfunction copySpread<T extends object>(arr: T[] | undefined): T[] {\n return arr?.map((item) => ({ ...item })) ?? []\n}\n\nfunction copyPropertyDefs(\n defs: ComponentPropertyDefinition[] | undefined\n): ComponentPropertyDefinition[] {\n return (\n defs?.map((d) => ({\n ...d,\n variantOptions: d.variantOptions ? [...d.variantOptions] : undefined,\n preferredValues: d.preferredValues ? [...d.preferredValues] : undefined,\n slotSettings: d.slotSettings ? { ...d.slotSettings } : undefined\n })) ?? []\n )\n}\n\n/** Deep-copy path-text glyphs (fresh commandsBlob buffers). */\nexport function copyDerivedGlyphs(glyphs: DerivedTextGlyph[] | null): DerivedTextGlyph[] | null {\n return glyphs\n ? glyphs.map((g) => ({\n ...g,\n commandsBlob: new Uint8Array(g.commandsBlob),\n ...(g.emojiCodePoints ? { emojiCodePoints: [...g.emojiCodePoints] } : {})\n }))\n : null\n}\n\n// --- Complex structure copy functions ---\n// These replace structuredClone for known types, avoiding its ~24× overhead.\n\nexport function copyConnectorEndpoint(endpoint: ConnectorEndpoint): ConnectorEndpoint {\n return { ...endpoint, position: { ...endpoint.position } }\n}\n\nfunction copyArcData(a: ArcData): ArcData {\n return { startingAngle: a.startingAngle, endingAngle: a.endingAngle, innerRadius: a.innerRadius }\n}\n\n// --- Deep-copy clone props ---\n\n/**\n * Build the init props for a deep-copy clone of `src`.\n * Shares logic between SceneGraph.cloneTree and instance child cloning.\n * Explicitly deep-copies all mutable object/array fields that `...rest`\n * would otherwise share by reference. When adding a mutable SceneNode field,\n * add its copy behavior here or document why sharing is intentional.\n */\nexport type NodeCloneMode = 'deep' | 'fig-import'\n\n/** A text's line height and letter spacing, copied so a clone never shares them. */\nfunction copyTextLengths(src: SceneNode): Pick<SceneNode, 'lineHeight' | 'letterSpacing'> {\n return {\n lineHeight: src.lineHeight && { ...src.lineHeight },\n letterSpacing: { ...src.letterSpacing }\n }\n}\n\nexport function cloneNodeProps(\n src: SceneNode,\n componentId: string | null,\n mode: NodeCloneMode = 'deep'\n): Partial<SceneNode> {\n const { id: _, parentId: _p, childIds: _c, ...rest } = src\n if (mode === 'fig-import') {\n return {\n ...rest,\n ...(componentId !== null ? { componentId } : {}),\n source: createDefaultSourceMetadata(),\n boundVariables: { ...src.boundVariables },\n variableBindingScales: { ...src.variableBindingScales },\n variableAssignmentScales: { ...src.variableAssignmentScales },\n variableModes: { ...src.variableModes },\n instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),\n componentPropertyAssignments: { ...src.componentPropertyAssignments },\n\n componentPropertyValues: { ...src.componentPropertyValues }\n }\n }\n return {\n ...rest,\n ...(componentId !== null ? { componentId } : {}),\n boundVariables: { ...src.boundVariables },\n variableBindingScales: { ...src.variableBindingScales },\n variableAssignmentScales: { ...src.variableAssignmentScales },\n variableModes: { ...src.variableModes },\n instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),\n fills: copyOpt(src.fills, (value) => markCopySource(value, copyFills(value))),\n\n strokes: copyOpt(src.strokes, (value) => markCopySource(value, copyStrokes(value))),\n effects: copyOpt(src.effects, (value) => markCopySource(value, copyEffects(value))),\n layoutGrids: copyOpt(src.layoutGrids, copyLayoutGrids),\n guides: copyOpt(src.guides, (guides) => guides.map((guide) => ({ ...guide }))),\n styleRuns: copyOpt(src.styleRuns, (value) => markCopySource(value, copyStyleRuns(value))),\n // Generated instance descendants have no independent Figma provenance. Retaining the source\n // component's opaque raw payload here duplicates megabytes of metadata per instance.\n source: componentId === null ? structuredClone(src.source) : createDefaultSourceMetadata(),\n dashPattern: copyOpt(src.dashPattern, (a) => [...a]),\n fontVariations: copyOpt(src.fontVariations, (a) => a.map((v) => ({ ...v }))),\n ...copyTextLengths(src),\n fontFeatures: copyOpt(src.fontFeatures, (a) => a.map((v) => ({ ...v }))),\n textParagraphs: copyOpt(src.textParagraphs, (a) => a.map((v) => ({ ...v }))),\n textDecorationFills: copyOpt(src.textDecorationFills, copyFills),\n fillGeometry: copyOpt(src.fillGeometry, copyGeometryPaths),\n strokeGeometry: copyOpt(src.strokeGeometry, copyGeometryPaths),\n gridTemplateColumns: copySpread(src.gridTemplateColumns),\n gridTemplateRows: copySpread(src.gridTemplateRows),\n componentPropertyDefinitions: copyPropertyDefs(src.componentPropertyDefinitions),\n componentPropertyReferences: copySpread(src.componentPropertyReferences),\n componentPropertyAssignments: { ...src.componentPropertyAssignments },\n symbolLinks: copySpread(src.symbolLinks),\n variantPropSpecs: copySpread(src.variantPropSpecs),\n pluginData: copySpread(src.pluginData),\n pluginRelaunchData: copySpread(src.pluginRelaunchData),\n exportSettings: copySpread(src.exportSettings),\n // Generated instance descendants have no status of their own.\n status: componentId === null ? src.status : null,\n componentPropertyValues: { ...src.componentPropertyValues },\n derivedLayout: src.derivedLayout ? { ...src.derivedLayout } : null,\n arcData: src.arcData ? copyArcData(src.arcData) : null,\n vectorNetwork: src.vectorNetwork ? cloneVectorNetwork(src.vectorNetwork) : null,\n textPicture: src.textPicture ? new Uint8Array(src.textPicture) : null,\n derivedTextGlyphs: src.derivedTextGlyphs\n ? markCopySource(src.derivedTextGlyphs, copyDerivedGlyphs(src.derivedTextGlyphs) ?? [])\n : null,\n textPathData: src.textPathData ? structuredClone(src.textPathData) : null,\n textPathBox: src.textPathBox ? { ...src.textPathBox } : null,\n gridPosition: src.gridPosition ? { ...src.gridPosition } : null,\n targetAspectRatio: src.targetAspectRatio ? { ...src.targetAspectRatio } : null,\n connectorStart: src.connectorStart ? copyConnectorEndpoint(src.connectorStart) : null,\n connectorEnd: src.connectorEnd ? copyConnectorEndpoint(src.connectorEnd) : null,\n connectorControlPoints: structuredClone(src.connectorControlPoints),\n connectorCurveHandles: structuredClone(src.connectorCurveHandles),\n connectorLabelPosition: src.connectorLabelPosition ? { ...src.connectorLabelPosition } : null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,SAAgB,SAAyB,GAAS;CAChD,MAAM,OAAU;EAAE,GAAG;EAAG,OAAO,EAAE,GAAG,EAAE,MAAM;CAAE;CAC9C,IAAI,EAAE,eAAe,KAAK,gBAAgB,EAAE,cAAc,IAAI,gBAAgB;CAC9E,IAAI,EAAE,mBAAmB,KAAK,oBAAoB,EAAE,GAAG,EAAE,kBAAkB;CAC3E,IAAI,EAAE,gBAAgB,KAAK,iBAAiB,EAAE,GAAG,EAAE,eAAe;CAClE,IAAI,EAAE,gBAAgB,KAAK,iBAAiB,EAAE,GAAG,EAAE,eAAe;CAClE,IAAI,EAAE,WAAW,KAAK,YAAY,EAAE,GAAG,EAAE,UAAU;CACnD,OAAO;AACT;AAEA,SAAgB,WAAW,GAAmB;CAC5C,MAAM,OAAO,SAAS,CAAC;CACvB,IAAI,EAAE,aACJ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,aAAa,IAAI;EAC3D,mBAAmB,IAAI,oBAAoB,EAAE,GAAG,IAAI,kBAAkB,IAAI;EAC1E,gBAAgB,IAAI,iBAAiB,sBAAsB,IAAI,cAAc,IAAI;EACjF,cAAc,IAAI,eAAe,sBAAsB,IAAI,YAAY,IAAI;EAC3E,wBAAwB,gBAAgB,IAAI,sBAAsB;EAClE,uBAAuB,gBAAgB,IAAI,qBAAqB;EAChE,wBAAwB,IAAI,yBAAyB,EAAE,GAAG,IAAI,uBAAuB,IAAI;CAC3F;AACF"}
|
|
1
|
+
{"version":3,"file":"copy.js","names":[],"sources":["../src/copy.ts"],"sourcesContent":["/**\n * Typed shallow-copy helpers for Fill, Stroke, Effect, and StyleRun.\n *\n * These replace `structuredClone` for known scene-graph array types,\n * avoiding the ~24× overhead of the generic deep-clone algorithm.\n * Each helper spreads the top-level object and any nested objects\n * (color, offset, gradientStops, dashPattern, style) to ensure\n * no shared references between source and copy.\n */\n\nimport { readGeometryBlob } from './geometry'\nimport { cloneInstanceOverrideState } from './instances/overrides'\nimport { createDefaultSourceMetadata } from './node-defaults'\nimport type {\n ArcData,\n ComponentPropertyDefinition,\n ConnectorEndpoint,\n Effect,\n DerivedTextGlyph,\n Fill,\n GeometryPath,\n GradientStop,\n LayoutGrid,\n SceneNode,\n Stroke,\n StyleRun,\n VectorNetwork,\n VectorRegion\n} from './types'\n\n// --- Individual copy functions ---\n\n/** Generic over the paint shape so a stroke keeps its own fields while the paint deep-copies. */\nexport function copyFill<T extends Fill>(f: T): T {\n const copy: T = { ...f, color: { ...f.color } }\n if (f.gradientStops) copy.gradientStops = f.gradientStops.map(copyGradientStop)\n if (f.gradientTransform) copy.gradientTransform = { ...f.gradientTransform }\n if (f.imageTransform) copy.imageTransform = { ...f.imageTransform }\n if (f.filters) copy.filters = { ...f.filters }\n if (f.patternSpacing) copy.patternSpacing = { ...f.patternSpacing }\n if (f.noiseSize) copy.noiseSize = { ...f.noiseSize }\n return copy\n}\n\nexport function copyStroke(s: Stroke): Stroke {\n const copy = copyFill(s)\n if (s.dashPattern) {\n copy.dashPattern = [...s.dashPattern]\n }\n return copy\n}\n\nexport function copyEffect(e: Effect): Effect {\n const copy: Effect = { ...e, color: { ...e.color }, offset: { ...e.offset } }\n if (e.glass) copy.glass = { ...e.glass }\n if (e.noise) copy.noise = structuredClone(e.noise)\n if (e.texture) copy.texture = structuredClone(e.texture)\n if (e.progressive) {\n copy.progressive = {\n startRadius: e.progressive.startRadius,\n startOffset: { ...e.progressive.startOffset },\n endOffset: { ...e.progressive.endOffset }\n }\n }\n return copy\n}\n\nexport function copyStyleRun(r: StyleRun): StyleRun {\n const copy: StyleRun = {\n ...r,\n style: {\n ...r.style,\n fills: r.style.fills ? r.style.fills.map(copyFill) : undefined,\n textDecorationFills: r.style.textDecorationFills\n ? r.style.textDecorationFills.map(copyFill)\n : undefined,\n fontVariations: r.style.fontVariations\n ? r.style.fontVariations.map((v) => ({ ...v }))\n : undefined,\n fontFeatures: r.style.fontFeatures ? r.style.fontFeatures.map((v) => ({ ...v })) : undefined\n }\n }\n if (r.style.hyperlink) copy.style.hyperlink = { ...r.style.hyperlink }\n if (r.style.lineHeight) copy.style.lineHeight = { ...r.style.lineHeight }\n if (r.style.letterSpacing) copy.style.letterSpacing = { ...r.style.letterSpacing }\n if (r.style.boundVariables) copy.style.boundVariables = { ...r.style.boundVariables }\n return copy\n}\n\n// --- Array copy functions ---\n\nconst internalCopySources = new WeakMap<object, object>()\n\n/** Record immutable lineage for an internal deep copy without sharing mutable values. */\nexport function markCopySource<T extends object>(source: T, copy: T): T {\n internalCopySources.set(copy, internalCopySources.get(source) ?? source)\n return copy\n}\n\n/** Compare internal deep copies in O(1) without traversing large paint or text payloads. */\nexport function hasSameCopySource(left: object, right: object): boolean {\n if (left === right) return true\n return (internalCopySources.get(left) ?? left) === (internalCopySources.get(right) ?? right)\n}\n\nexport function copyFills(fills: Fill[]): Fill[] {\n return fills.map(copyFill)\n}\n\nexport function copyStrokes(strokes: Stroke[]): Stroke[] {\n return strokes.map(copyStroke)\n}\n\nexport function copyEffects(effects: Effect[]): Effect[] {\n return effects.map(copyEffect)\n}\n\nexport function copyLayoutGrids(grids: LayoutGrid[]): LayoutGrid[] {\n return grids.map((grid) => ({ ...grid, color: grid.color ? { ...grid.color } : undefined }))\n}\n\nexport function copyStyleRuns(runs: StyleRun[]): StyleRun[] {\n return runs.map(copyStyleRun)\n}\n\n/** A region, with new loops when given, keeping its own paints and fill style. */\nexport function copyVectorRegion(\n region: VectorRegion,\n loops = region.loops.map((loop) => [...loop])\n): VectorRegion {\n const copy: VectorRegion = { windingRule: region.windingRule, loops }\n if (region.fills) copy.fills = copyFills(region.fills)\n if (region.fillStyleId) copy.fillStyleId = region.fillStyleId\n return copy\n}\n\n/** Deep-copy a VectorNetwork, stripping any Vue Proxy wrappers. */\nexport function cloneVectorNetwork(vn: VectorNetwork): VectorNetwork {\n return {\n vertices: vn.vertices.map((v) => ({ ...v })),\n segments: vn.segments.map((s) => ({\n ...s,\n tangentStart: { ...s.tangentStart },\n tangentEnd: { ...s.tangentEnd }\n })),\n regions: vn.regions.map((r) => copyVectorRegion(r))\n }\n}\n\nexport function copyGeometryPaths(paths: GeometryPath[]): GeometryPath[] {\n return paths.map((p) => ({ windingRule: p.windingRule, commandsBlob: p.commandsBlob.slice() }))\n}\n\n/**\n * Affine-transform every coordinate pair in a path command blob (returns a\n * copy): (x, y) → (m00·x + m01·y + tx, m10·x + m11·y + ty).\n * Command layout: 1=move/2=line (1 pair), 3=quad (2 pairs), 4=cubic (3 pairs)\n * — font-glyph blobs are quad-heavy, so skipping command 3 desyncs the walk.\n */\nexport function transformGeometryBlob(\n blob: Uint8Array,\n m00: number,\n m01: number,\n m10: number,\n m11: number,\n tx = 0,\n ty = 0\n): Uint8Array {\n const out = blob.slice()\n const view = new DataView(out.buffer, out.byteOffset, out.byteLength)\n readGeometryBlob(out, (_, coords, offset) => {\n for (let i = 0; i < coords.length; i += 2) {\n const x = coords[i]\n const y = coords[i + 1]\n view.setFloat32(offset + i * 4, m00 * x + m01 * y + tx, true)\n view.setFloat32(offset + i * 4 + 4, m10 * x + m11 * y + ty, true)\n }\n })\n return out\n}\n\nexport function transformGeometryPaths(\n paths: GeometryPath[],\n m00: number,\n m01: number,\n m10: number,\n m11: number,\n tx = 0,\n ty = 0\n): GeometryPath[] {\n return paths.map((g) => ({\n windingRule: g.windingRule,\n commandsBlob: transformGeometryBlob(g.commandsBlob, m00, m01, m10, m11, tx, ty)\n }))\n}\n\n/**\n * Scale path command blob coordinates by (sx, sy).\n * Identity scale returns a deep copy (same as copyGeometryPaths).\n */\nexport function scaleGeometryPaths(paths: GeometryPath[], sx: number, sy: number): GeometryPath[] {\n if (sx === 1 && sy === 1) return copyGeometryPaths(paths)\n return transformGeometryPaths(paths, sx, 0, 0, sy)\n}\n\n// --- Internal helpers ---\n\n/** Copy an optional array: non-empty → mapped, empty → [], undefined → undefined. */\nfunction copyOpt<T, U>(arr: T[] | undefined, fn: (arr: T[]) => U[]): U[] | undefined {\n if (arr === undefined) return undefined\n return arr.length > 0 ? fn(arr) : []\n}\n\nfunction copyGradientStop(gs: GradientStop): GradientStop {\n return { color: { ...gs.color }, position: gs.position }\n}\n\nfunction copySpread<T extends object>(arr: T[] | undefined): T[] {\n return arr?.map((item) => ({ ...item })) ?? []\n}\n\nfunction copyPropertyDefs(\n defs: ComponentPropertyDefinition[] | undefined\n): ComponentPropertyDefinition[] {\n return (\n defs?.map((d) => ({\n ...d,\n variantOptions: d.variantOptions ? [...d.variantOptions] : undefined,\n preferredValues: d.preferredValues ? [...d.preferredValues] : undefined,\n slotSettings: d.slotSettings ? { ...d.slotSettings } : undefined\n })) ?? []\n )\n}\n\n/** Deep-copy path-text glyphs (fresh commandsBlob buffers). */\nexport function copyDerivedGlyphs(glyphs: DerivedTextGlyph[] | null): DerivedTextGlyph[] | null {\n return glyphs\n ? glyphs.map((g) => ({\n ...g,\n commandsBlob: new Uint8Array(g.commandsBlob),\n ...(g.emojiCodePoints ? { emojiCodePoints: [...g.emojiCodePoints] } : {})\n }))\n : null\n}\n\n// --- Complex structure copy functions ---\n// These replace structuredClone for known types, avoiding its ~24× overhead.\n\nexport function copyConnectorEndpoint(endpoint: ConnectorEndpoint): ConnectorEndpoint {\n return { ...endpoint, position: { ...endpoint.position } }\n}\n\nfunction copyArcData(a: ArcData): ArcData {\n return { startingAngle: a.startingAngle, endingAngle: a.endingAngle, innerRadius: a.innerRadius }\n}\n\n// --- Deep-copy clone props ---\n\n/**\n * Build the init props for a deep-copy clone of `src`.\n * Shares logic between SceneGraph.cloneTree and instance child cloning.\n * Explicitly deep-copies all mutable object/array fields that `...rest`\n * would otherwise share by reference. When adding a mutable SceneNode field,\n * add its copy behavior here or document why sharing is intentional.\n */\nexport type NodeCloneMode = 'deep' | 'fig-import'\n\n/** A text's line height and letter spacing, copied so a clone never shares them. */\nfunction copyTextLengths(src: SceneNode): Pick<SceneNode, 'lineHeight' | 'letterSpacing'> {\n return {\n lineHeight: src.lineHeight && { ...src.lineHeight },\n letterSpacing: { ...src.letterSpacing }\n }\n}\n\nexport function cloneNodeProps(\n src: SceneNode,\n componentId: string | null,\n mode: NodeCloneMode = 'deep'\n): Partial<SceneNode> {\n const { id: _, parentId: _p, childIds: _c, ...rest } = src\n if (mode === 'fig-import') {\n return {\n ...rest,\n ...(componentId !== null ? { componentId } : {}),\n source: createDefaultSourceMetadata(),\n boundVariables: { ...src.boundVariables },\n variableBindingScales: { ...src.variableBindingScales },\n variableAssignmentScales: { ...src.variableAssignmentScales },\n variableModes: { ...src.variableModes },\n instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),\n componentPropertyAssignments: { ...src.componentPropertyAssignments },\n\n componentPropertyValues: { ...src.componentPropertyValues }\n }\n }\n return {\n ...rest,\n ...(componentId !== null ? { componentId } : {}),\n boundVariables: { ...src.boundVariables },\n variableBindingScales: { ...src.variableBindingScales },\n variableAssignmentScales: { ...src.variableAssignmentScales },\n variableModes: { ...src.variableModes },\n instanceOverrides: cloneInstanceOverrideState(src.instanceOverrides),\n fills: copyOpt(src.fills, (value) => markCopySource(value, copyFills(value))),\n\n strokes: copyOpt(src.strokes, (value) => markCopySource(value, copyStrokes(value))),\n effects: copyOpt(src.effects, (value) => markCopySource(value, copyEffects(value))),\n layoutGrids: copyOpt(src.layoutGrids, copyLayoutGrids),\n guides: copyOpt(src.guides, (guides) => guides.map((guide) => ({ ...guide }))),\n styleRuns: copyOpt(src.styleRuns, (value) => markCopySource(value, copyStyleRuns(value))),\n // Generated instance descendants have no independent Figma provenance. Retaining the source\n // component's opaque raw payload here duplicates megabytes of metadata per instance.\n source: componentId === null ? structuredClone(src.source) : createDefaultSourceMetadata(),\n dashPattern: copyOpt(src.dashPattern, (a) => [...a]),\n fontVariations: copyOpt(src.fontVariations, (a) => a.map((v) => ({ ...v }))),\n ...copyTextLengths(src),\n fontFeatures: copyOpt(src.fontFeatures, (a) => a.map((v) => ({ ...v }))),\n textParagraphs: copyOpt(src.textParagraphs, (a) => a.map((v) => ({ ...v }))),\n textDecorationFills: copyOpt(src.textDecorationFills, copyFills),\n fillGeometry: copyOpt(src.fillGeometry, copyGeometryPaths),\n strokeGeometry: copyOpt(src.strokeGeometry, copyGeometryPaths),\n gridTemplateColumns: copySpread(src.gridTemplateColumns),\n gridTemplateRows: copySpread(src.gridTemplateRows),\n componentPropertyDefinitions: copyPropertyDefs(src.componentPropertyDefinitions),\n componentPropertyReferences: copySpread(src.componentPropertyReferences),\n componentPropertyAssignments: { ...src.componentPropertyAssignments },\n symbolLinks: copySpread(src.symbolLinks),\n variantPropSpecs: copySpread(src.variantPropSpecs),\n pluginData: copySpread(src.pluginData),\n pluginRelaunchData: copySpread(src.pluginRelaunchData),\n exportSettings: copySpread(src.exportSettings),\n // Generated instance descendants have no status of their own.\n status: componentId === null ? src.status : null,\n componentPropertyValues: { ...src.componentPropertyValues },\n derivedLayout: src.derivedLayout ? { ...src.derivedLayout } : null,\n arcData: src.arcData ? copyArcData(src.arcData) : null,\n vectorNetwork: src.vectorNetwork ? cloneVectorNetwork(src.vectorNetwork) : null,\n textPicture: src.textPicture ? new Uint8Array(src.textPicture) : null,\n derivedTextGlyphs: src.derivedTextGlyphs\n ? markCopySource(src.derivedTextGlyphs, copyDerivedGlyphs(src.derivedTextGlyphs) ?? [])\n : null,\n textPathData: src.textPathData ? structuredClone(src.textPathData) : null,\n textPathBox: src.textPathBox ? { ...src.textPathBox } : null,\n gridPosition: src.gridPosition ? { ...src.gridPosition } : null,\n targetAspectRatio: src.targetAspectRatio ? { ...src.targetAspectRatio } : null,\n connectorStart: src.connectorStart ? copyConnectorEndpoint(src.connectorStart) : null,\n connectorEnd: src.connectorEnd ? copyConnectorEndpoint(src.connectorEnd) : null,\n connectorControlPoints: structuredClone(src.connectorControlPoints),\n connectorCurveHandles: structuredClone(src.connectorCurveHandles),\n connectorLabelPosition: src.connectorLabelPosition ? { ...src.connectorLabelPosition } : null\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,SAAgB,SAAyB,GAAS;CAChD,MAAM,OAAU;EAAE,GAAG;EAAG,OAAO,EAAE,GAAG,EAAE,MAAM;CAAE;CAC9C,IAAI,EAAE,eAAe,KAAK,gBAAgB,EAAE,cAAc,IAAI,gBAAgB;CAC9E,IAAI,EAAE,mBAAmB,KAAK,oBAAoB,EAAE,GAAG,EAAE,kBAAkB;CAC3E,IAAI,EAAE,gBAAgB,KAAK,iBAAiB,EAAE,GAAG,EAAE,eAAe;CAClE,IAAI,EAAE,SAAS,KAAK,UAAU,EAAE,GAAG,EAAE,QAAQ;CAC7C,IAAI,EAAE,gBAAgB,KAAK,iBAAiB,EAAE,GAAG,EAAE,eAAe;CAClE,IAAI,EAAE,WAAW,KAAK,YAAY,EAAE,GAAG,EAAE,UAAU;CACnD,OAAO;AACT;AAEA,SAAgB,WAAW,GAAmB;CAC5C,MAAM,OAAO,SAAS,CAAC;CACvB,IAAI,EAAE,aACJ,KAAK,cAAc,CAAC,GAAG,EAA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AAI,oBAAoB,EAAE,GAAG,IAAI,kBAAkB,IAAI;EAC1E,gBAAgB,IAAI,iBAAiB,sBAAsB,IAAI,cAAc,IAAI;EACjF,cAAc,IAAI,eAAe,sBAAsB,IAAI,YAAY,IAAI;EAC3E,wBAAwB,gBAAgB,IAAI,sBAAsB;EAClE,uBAAuB,gBAAgB,IAAI,qBAAqB;EAChE,wBAAwB,IAAI,yBAAyB,EAAE,GAAG,IAAI,uBAAuB,IAAI;CAC3F;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CommittedGraphEventError } from "./buffered-events.js";
|
|
2
2
|
import { SceneGraph } from "./graph.js";
|
|
3
|
-
import { ArcData, AxisSizingMode, BlendMode, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, DocumentRecordKind, Effect, EnabledLibraryBinding, ExportColorProfile, ExportSetting, ExportSize, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GlassEffectParams, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, NodeChangeObserver, NodeType, NoiseEffectParams, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, ProgressiveBlur, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType, SlotSettings, SourceLibraryPublication, SourceMetadata, Stroke, StrokeCap, StrokeJoin, StyleRun, SymbolLink, TEXT_BINDABLE_FIELDS, TOKEN_UNITS, TextAlignVertical, TextAutoResize, TextBindableField, TextBoundVariables, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextLength, TextListType, TextParagraphSpacingField, TextParagraphStyle, TextPathData, TextureEffectParams, TokenExpression, TokenUnit, VARIABLE_FORMULA_OPERATORS, VARIABLE_SCOPES, Variable, VariableAlias, VariableCollection, VariableCollectionMode, VariableColorExpression, VariableFormula, VariableFormulaNode, VariableFormulaOperation, VariableFormulaOperator, VariableLiteral, VariableModeMap, VariableScope, VariableType, VariableUnsupportedExpression, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule, isLibraryCollection, isModeAttributeName } from "./types.js";
|
|
3
|
+
import { ArcData, AxisSizingMode, BlendMode, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, DocumentRecordKind, Effect, EnabledLibraryBinding, ExportColorProfile, ExportSetting, ExportSize, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GlassEffectParams, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageFilters, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, NodeChangeObserver, NodeType, NoiseEffectParams, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, ProgressiveBlur, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType, SlotSettings, SourceLibraryPublication, SourceMetadata, Stroke, StrokeCap, StrokeJoin, StyleRun, SymbolLink, TEXT_BINDABLE_FIELDS, TOKEN_UNITS, TextAlignVertical, TextAutoResize, TextBindableField, TextBoundVariables, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextLength, TextListType, TextParagraphSpacingField, TextParagraphStyle, TextPathData, TextureEffectParams, TokenExpression, TokenUnit, VARIABLE_FORMULA_OPERATORS, VARIABLE_SCOPES, Variable, VariableAlias, VariableCollection, VariableCollectionMode, VariableColorExpression, VariableFormula, VariableFormulaNode, VariableFormulaOperation, VariableFormulaOperator, VariableLiteral, VariableModeMap, VariableScope, VariableType, VariableUnsupportedExpression, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule, isLibraryCollection, isModeAttributeName } from "./types.js";
|
|
4
4
|
import { generateId, setIdSession } from "./ids.js";
|
|
5
|
-
export { ArcData, AxisSizingMode, BlendMode, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, CommittedGraphEventError, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, DocumentRecordKind, Effect, EnabledLibraryBinding, ExportColorProfile, ExportSetting, ExportSize, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GlassEffectParams, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, NodeChangeObserver, NodeType, NoiseEffectParams, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, ProgressiveBlur, SceneGraph, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType, SlotSettings, SourceLibraryPublication, SourceMetadata, Stroke, StrokeCap, StrokeJoin, StyleRun, SymbolLink, TEXT_BINDABLE_FIELDS, TOKEN_UNITS, TextAlignVertical, TextAutoResize, TextBindableField, TextBoundVariables, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextLength, TextListType, TextParagraphSpacingField, TextParagraphStyle, TextPathData, TextureEffectParams, TokenExpression, TokenUnit, VARIABLE_FORMULA_OPERATORS, VARIABLE_SCOPES, Variable, VariableAlias, VariableCollection, VariableCollectionMode, VariableColorExpression, VariableFormula, VariableFormulaNode, VariableFormulaOperation, VariableFormulaOperator, VariableLiteral, VariableModeMap, VariableScope, VariableType, VariableUnsupportedExpression, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule, generateId, isLibraryCollection, isModeAttributeName, setIdSession };
|
|
5
|
+
export { ArcData, AxisSizingMode, BlendMode, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, CommittedGraphEventError, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, DocumentRecordKind, Effect, EnabledLibraryBinding, ExportColorProfile, ExportSetting, ExportSize, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GlassEffectParams, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageFilters, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, NodeChangeObserver, NodeType, NoiseEffectParams, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, ProgressiveBlur, SceneGraph, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType, SlotSettings, SourceLibraryPublication, SourceMetadata, Stroke, StrokeCap, StrokeJoin, StyleRun, SymbolLink, TEXT_BINDABLE_FIELDS, TOKEN_UNITS, TextAlignVertical, TextAutoResize, TextBindableField, TextBoundVariables, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextLength, TextListType, TextParagraphSpacingField, TextParagraphStyle, TextPathData, TextureEffectParams, TokenExpression, TokenUnit, VARIABLE_FORMULA_OPERATORS, VARIABLE_SCOPES, Variable, VariableAlias, VariableCollection, VariableCollectionMode, VariableColorExpression, VariableFormula, VariableFormulaNode, VariableFormulaOperation, VariableFormulaOperator, VariableLiteral, VariableModeMap, VariableScope, VariableType, VariableUnsupportedExpression, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule, generateId, isLibraryCollection, isModeAttributeName, setIdSession };
|
package/dist/types.d.ts
CHANGED
|
@@ -108,6 +108,16 @@ interface GradientStop {
|
|
|
108
108
|
position: number;
|
|
109
109
|
}
|
|
110
110
|
type GradientTransform = Matrix;
|
|
111
|
+
/** Figma's adjustments of an image paint, each from -1 to 1; 0 leaves the image as it is. */
|
|
112
|
+
interface ImageFilters {
|
|
113
|
+
exposure?: number;
|
|
114
|
+
contrast?: number;
|
|
115
|
+
saturation?: number;
|
|
116
|
+
temperature?: number;
|
|
117
|
+
tint?: number;
|
|
118
|
+
highlights?: number;
|
|
119
|
+
shadows?: number;
|
|
120
|
+
}
|
|
111
121
|
interface Fill {
|
|
112
122
|
type: FillType;
|
|
113
123
|
color: Color;
|
|
@@ -125,6 +135,8 @@ interface Fill {
|
|
|
125
135
|
imageTransform?: GradientTransform;
|
|
126
136
|
/** Clockwise turn of a Fill, Fit or Tile image, in multiples of 90°; a crop holds its own. */
|
|
127
137
|
imageRotation?: number;
|
|
138
|
+
/** An image's adjustments, kept and saved; the canvas does not draw them. */
|
|
139
|
+
filters?: ImageFilters;
|
|
128
140
|
sourceNodeId?: string;
|
|
129
141
|
scale?: number;
|
|
130
142
|
spacing?: number;
|
|
@@ -941,5 +953,5 @@ declare function isLibraryCollection(collection: Pick<VariableCollection, 'key'>
|
|
|
941
953
|
declare const MODE_ATTRIBUTE_PATTERN: RegExp;
|
|
942
954
|
declare function isModeAttributeName(name: string): boolean;
|
|
943
955
|
//#endregion
|
|
944
|
-
export { ArcData, AxisSizingMode, BlendMode, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, DocumentRecordKind, Effect, EnabledLibraryBinding, ExportColorProfile, ExportSetting, ExportSize, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GlassEffectParams, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, NodeChangeObserver, NodeType, NoiseEffectParams, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, ProgressiveBlur, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType, SlotSettings, SourceLibraryPublication, SourceMetadata, Stroke, StrokeCap, StrokeJoin, StyleRun, SymbolLink, TEXT_BINDABLE_FIELDS, TOKEN_UNITS, TextAlignVertical, TextAutoResize, TextBindableField, TextBoundVariables, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextLength, TextListType, TextParagraphSpacingField, TextParagraphStyle, TextPathData, TextureEffectParams, TokenExpression, TokenUnit, VARIABLE_FORMULA_OPERATORS, VARIABLE_SCOPES, Variable, VariableAlias, VariableCollection, VariableCollectionMode, VariableColorExpression, VariableFormula, VariableFormulaNode, VariableFormulaOperation, VariableFormulaOperator, VariableLiteral, VariableModeMap, VariableScope, VariableType, VariableUnsupportedExpression, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule, isLibraryCollection, isModeAttributeName };
|
|
956
|
+
export { ArcData, AxisSizingMode, BlendMode, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, DocumentRecordKind, Effect, EnabledLibraryBinding, ExportColorProfile, ExportSetting, ExportSize, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GlassEffectParams, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageFilters, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, NodeChangeObserver, NodeType, NoiseEffectParams, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, ProgressiveBlur, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, SharedStyle, SharedStyleKind, SharedStyleType, SlotSettings, SourceLibraryPublication, SourceMetadata, Stroke, StrokeCap, StrokeJoin, StyleRun, SymbolLink, TEXT_BINDABLE_FIELDS, TOKEN_UNITS, TextAlignVertical, TextAutoResize, TextBindableField, TextBoundVariables, TextCase, TextDecoration, TextDecorationStyle, TextDirection, TextLength, TextListType, TextParagraphSpacingField, TextParagraphStyle, TextPathData, TextureEffectParams, TokenExpression, TokenUnit, VARIABLE_FORMULA_OPERATORS, VARIABLE_SCOPES, Variable, VariableAlias, VariableCollection, VariableCollectionMode, VariableColorExpression, VariableFormula, VariableFormulaNode, VariableFormulaOperation, VariableFormulaOperator, VariableLiteral, VariableModeMap, VariableScope, VariableType, VariableUnsupportedExpression, VariableValue, VariantPropSpec, VectorNetwork, VectorRegion, VectorSegment, VectorVertex, WindingRule, isLibraryCollection, isModeAttributeName };
|
|
945
957
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;UAQiB;EACf,iBAAiB,MAAM;EACvB,iBAAiB,YAAY,SAAS,QAAQ;EAC9C,wBAAwB,YAAY,SAAS,QAAQ;EACrD,iBAAiB,YAAY;EAC7B,oBAAoB,gBAAgB,4BAA4B;EAChE,mBACE,gBACA,kBACA,eACA;;KAIQ,0BAA0B;EACpC,UAAU,MAAM;EAChB,UAAU,YAAY,SAAS,QAAQ;EACvC,iBAAiB,YAAY,SAAS,QAAQ;EAC9C,UAAU,YAAY;EACtB,aAAa,gBAAgB,4BAA4B;EACzD,YACE,gBACA,kBACA,eACA;;;KAKQ;;UAGK;;EAEf,SAAS,MAAM;;EAEf,UAAU,MAAM;;EAEhB,aAAa,MAAM;;;;;EAKnB,gBAAgB,MAAM,oBAAoB;;;;;EAK1C;EACA;;KAGU;;KAGA;UAEK;EACf,SAAS;EACT,cAAc;EACd,eAAe;EACf,QAAQ;EACR;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA,KAAK;;KAGK;KACA;UAEK;EACf;EACA;EACA;EACA;EACA;EACA,kBAAkB;;UAGH;EACf;EACA;EACA,cAAc;EACd,YAAY;;UAGG;EACf,aAAa;EACb;;EAEA,QAAQ;;EAER;;UAGe;EACf,UAAU;EACV,UAAU;EACV,SAAS;;UAGM;EACf,aAAa;EACb,cAAc;;KAGJ;KAqBA;KAWA;KAoBA;KACA;KACA;KACA;UAEK;EACf,OAAO;EACP;;KAGU,oBAAoB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;UAQiB;EACf,iBAAiB,MAAM;EACvB,iBAAiB,YAAY,SAAS,QAAQ;EAC9C,wBAAwB,YAAY,SAAS,QAAQ;EACrD,iBAAiB,YAAY;EAC7B,oBAAoB,gBAAgB,4BAA4B;EAChE,mBACE,gBACA,kBACA,eACA;;KAIQ,0BAA0B;EACpC,UAAU,MAAM;EAChB,UAAU,YAAY,SAAS,QAAQ;EACvC,iBAAiB,YAAY,SAAS,QAAQ;EAC9C,UAAU,YAAY;EACtB,aAAa,gBAAgB,4BAA4B;EACzD,YACE,gBACA,kBACA,eACA;;;KAKQ;;UAGK;;EAEf,SAAS,MAAM;;EAEf,UAAU,MAAM;;EAEhB,aAAa,MAAM;;;;;EAKnB,gBAAgB,MAAM,oBAAoB;;;;;EAK1C;EACA;;KAGU;;KAGA;UAEK;EACf,SAAS;EACT,cAAc;EACd,eAAe;EACf,QAAQ;EACR;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA,KAAK;;KAGK;KACA;UAEK;EACf;EACA;EACA;EACA;EACA;EACA,kBAAkB;;UAGH;EACf;EACA;EACA,cAAc;EACd,YAAY;;UAGG;EACf,aAAa;EACb;;EAEA,QAAQ;;EAER;;UAGe;EACf,UAAU;EACV,UAAU;EACV,SAAS;;UAGM;EACf,aAAa;EACb,cAAc;;KAGJ;KAqBA;KAWA;KAoBA;KACA;KACA;KACA;UAEK;EACf,OAAO;EACP;;KAGU,oBAAoB;;UAGf;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,MAAM;EACN,OAAO;EACP;EACA;EACA,YAAY;EACZ,gBAAgB;EAChB,oBAAoB;;EAEpB;;EAEA;EACA,iBAAiB;;EAEjB,iBAAiB;;EAEjB;;EAEA,UAAU;EACV;EACA;EACA;EACA,iBAAiB;EACjB,kBAAkB;EAClB,oBAAoB;EACpB,sBAAsB;EACtB,YAAY;EACZ;EACA,YAAY;EACZ;;KAGU;KASA;KACA;KACA;KACA;UAEK;EACf;EACA,QAAQ;;EAER;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA,MAAM;;;UAIS,eAAe;EAC9B;EACA;EACA,MAAM;EACN,OAAO;EACP;;;;;;;;UASe;EACf;EACA;EACA;EACA;EACA;;;;;;;UAQe;EACf;EACA,aAAa;EACb,WAAW;;;;;;;;UASI;EACf,WAAW;EACX,WAAW;EACX;EACA,iBAAiB;EACjB;EACA;;;;;;;;UASe;EACf,WAAW;EACX;EACA;;UAGe;EACf;EASA,OAAO;EACP,QAAQ;EACR;EACA;EACA;EACA,YAAY;EACZ;;EAEA,QAAQ;;EAER,cAAc;;EAEd,QAAQ;;EAER,UAAU;;KAGA;KACA;;KAGA;;;;;;UAiBK;EACf;EACA,QAAQ;EACR,UAAU;;KAGA;;;;;UAMK;EACf,UAAU;EACV;;;;;;;UAQe;EACf;EACA;EACA;;KAEU;KACA;KACA;KACA;KACA;KACA;KACA;;KAEA;;;KAIA;UAEK;EACf,UAAU;;EAEV;;EAEA;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;E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package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-lines -- scene node contracts are kept together as the public graph type surface */\n\nimport type { ExportFormatId } from './export-format'\nimport type { CanvasGuide } from './guides'\nimport type { InstanceOverrideState } from './instances/overrides'\nimport type { Color, Matrix, Rect, Vector } from './primitives'\nimport type { ShapeWithTextType } from './shape-with-text/kinds'\n\nexport interface SceneGraphEvents {\n 'node:created': (node: SceneNode) => void\n 'node:updated': (id: string, changes: Partial<SceneNode>) => void\n 'node:previewUpdated': (id: string, changes: Partial<SceneNode>) => void\n 'node:deleted': (id: string, parentId: string | null) => void\n 'node:reparented': (nodeId: string, oldParentId: string | null, newParentId: string) => void\n 'node:reordered': (\n nodeId: string,\n parentId: string,\n index: number,\n previousParentId: string | null\n ) => void\n}\n\nexport type SceneGraphEventHandlers = Partial<{\n created: (node: SceneNode) => void\n updated: (id: string, changes: Partial<SceneNode>) => void\n previewUpdated: (id: string, changes: Partial<SceneNode>) => void\n deleted: (id: string, parentId: string | null) => void\n reparented: (nodeId: string, oldParentId: string | null, newParentId: string) => void\n reordered: (\n nodeId: string,\n parentId: string,\n index: number,\n previousParentId: string | null\n ) => void\n}>\n\n/** The document's records besides its nodes, which edits report changing as they do nodes. */\nexport type DocumentRecordKind = 'variable' | 'collection'\n\n/** Hears about nodes as an edit adds and changes them, synchronously and before each change. */\nexport interface NodeChangeObserver {\n /** A node is about to change and is still as it was. */\n before: (node: SceneNode) => void\n /** A node was just added. */\n created: (node: SceneNode) => void\n /** A node is about to take a preview's changes, which no history keeps. */\n previewed?: (node: SceneNode) => void\n /**\n * A variable or collection is about to change, be added, or be removed, and is still as it\n * was: absent, for one about to be added.\n */\n beforeRecord?: (kind: DocumentRecordKind, id: string) => void\n /**\n * The edit being observed waits on something outside it (`SceneGraph.waitOutsideEdit`): until\n * `resume`, nodes change for someone else's edit, not this one.\n */\n pause?: () => void\n resume?: () => void\n}\n\nexport type DocumentColorSpace = 'srgb' | 'display-p3'\n\n/** What a document is for, as Figma keeps design files and FigJam boards apart. */\nexport type DocumentKind = 'design' | 'board'\n\nexport interface FigmaSourcePayload {\n rawSize: Vector | null\n rawTransform: Matrix | null\n rawNodeFields: Record<string, unknown>\n layout: FigmaLayoutMetadata | null\n symbolOverrides: unknown[]\n componentPropAssignments: unknown[]\n derivedSymbolData: unknown[]\n derivedSymbolDataLayoutVersion: number | null\n uniformScaleFactor: number | null\n}\n\nexport interface SourceMetadata {\n format: 'fig' | null\n id: string | null\n orderKey: string | null\n editedFields: string[]\n fig: FigmaSourcePayload\n}\n\nexport type HandleMirroring = 'NONE' | 'ANGLE' | 'ANGLE_AND_LENGTH'\nexport type WindingRule = 'NONZERO' | 'EVENODD'\n\nexport interface VectorVertex {\n x: number\n y: number\n strokeCap?: string\n strokeJoin?: string\n cornerRadius?: number\n handleMirroring?: HandleMirroring\n}\n\nexport interface VectorSegment {\n start: number\n end: number\n tangentStart: Vector\n tangentEnd: Vector\n}\n\nexport interface VectorRegion {\n windingRule: WindingRule\n loops: number[][]\n /** The region's own paints. Without them it draws the layer's fills, as in Figma. */\n fills?: Fill[]\n /** The shared fill style the region's paints come from. */\n fillStyleId?: string\n}\n\nexport interface VectorNetwork {\n vertices: VectorVertex[]\n segments: VectorSegment[]\n regions: VectorRegion[]\n}\n\nexport interface GeometryPath {\n windingRule: WindingRule\n commandsBlob: Uint8Array\n}\n\nexport type NodeType =\n | 'CANVAS'\n | 'FRAME'\n | 'RECTANGLE'\n | 'ROUNDED_RECTANGLE'\n | 'ELLIPSE'\n | 'TEXT'\n | 'LINE'\n | 'STAR'\n | 'POLYGON'\n | 'VECTOR'\n | 'BOOLEAN_OPERATION'\n | 'GROUP'\n | 'SECTION'\n | 'COMPONENT'\n | 'COMPONENT_SET'\n | 'INSTANCE'\n | 'CONNECTOR'\n | 'SHAPE_WITH_TEXT'\n | 'STICKY'\n\nexport type FillType =\n | 'SOLID'\n | 'GRADIENT_LINEAR'\n | 'GRADIENT_RADIAL'\n | 'GRADIENT_ANGULAR'\n | 'GRADIENT_DIAMOND'\n | 'IMAGE'\n | 'VIDEO'\n | 'PATTERN'\n | 'NOISE'\n | 'CUSTOM'\nexport type BlendMode =\n | 'NORMAL'\n | 'DARKEN'\n | 'MULTIPLY'\n | 'LINEAR_BURN'\n | 'COLOR_BURN'\n | 'LIGHTEN'\n | 'SCREEN'\n | 'LINEAR_DODGE'\n | 'COLOR_DODGE'\n | 'OVERLAY'\n | 'SOFT_LIGHT'\n | 'HARD_LIGHT'\n | 'DIFFERENCE'\n | 'EXCLUSION'\n | 'HUE'\n | 'SATURATION'\n | 'COLOR'\n | 'LUMINOSITY'\n | 'PASS_THROUGH'\nexport type ImageScaleMode = 'FILL' | 'FIT' | 'CROP' | 'TILE'\nexport type NoiseType = 'MULTITONE' | 'MONOTONE' | 'DUOTONE'\nexport type PatternTileType = 'RECTANGULAR' | 'HORIZONTAL_HEXAGONAL' | 'VERTICAL_HEXAGONAL'\nexport type PatternAlignment = 'START' | 'CENTER' | 'END'\n\nexport interface GradientStop {\n color: Color\n position: number\n}\n\nexport type GradientTransform = Matrix\n\nexport interface Fill {\n type: FillType\n color: Color\n opacity: number\n visible: boolean\n blendMode?: BlendMode\n gradientStops?: GradientStop[]\n gradientTransform?: GradientTransform\n /** The image an IMAGE paint draws, or the poster frame a VIDEO paint draws in its clip's place. */\n imageHash?: string\n /** A VIDEO paint's clip, which `imageHash`'s poster frame stands in for when drawn. */\n videoHash?: string\n imageScaleMode?: ImageScaleMode\n /** A crop's image-space window; Fill, Fit and Tile ignore it. */\n imageTransform?: GradientTransform\n /** Clockwise turn of a Fill, Fit or Tile image, in multiples of 90°; a crop holds its own. */\n imageRotation?: number\n sourceNodeId?: string\n scale?: number\n spacing?: number\n patternSpacing?: Vector\n patternTileType?: PatternTileType\n verticalAlignment?: PatternAlignment\n horizontalAlignment?: PatternAlignment\n noiseType?: NoiseType\n density?: number\n noiseSize?: Vector\n customEffectId?: string\n}\n\nexport type StrokeCap =\n | 'NONE'\n | 'ROUND'\n | 'SQUARE'\n | 'ARROW_LINES'\n | 'ARROW_EQUILATERAL'\n | 'TRIANGLE_FILLED'\n | 'DIAMOND_FILLED'\n | 'CIRCLE_FILLED'\nexport type StrokeJoin = 'MITER' | 'BEVEL' | 'ROUND'\nexport type SharedStyleType = 'FILL' | 'TEXT' | 'EFFECT' | 'GRID'\nexport type SharedStyleKind = 'fill' | 'stroke' | 'text' | 'effect' | 'grid'\nexport type MaskType = 'ALPHA' | 'VECTOR' | 'LUMINANCE'\n\nexport interface LayoutGrid {\n visible?: boolean\n color?: Color\n /** `STRIPES` is the archive's name for columns or rows, along `axis`. */\n pattern?: 'COLUMNS' | 'ROWS' | 'GRID' | 'STRIPES'\n axis?: 'X' | 'Y'\n type?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH'\n alignment?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH'\n numSections?: number\n /** Figma's plugin API reports an Auto count as `null` and accepts `Infinity` for it. */\n count?: number | null\n offset?: number\n sectionSize?: number\n gutterSize?: number\n}\n\nexport interface SharedStyle {\n id: string\n nodeId: string\n name: string\n type: SharedStyleType\n}\n\n/** A stroke is a paint with the geometry that decides where it is drawn. */\nexport interface Stroke extends Fill {\n weight: number\n align: 'INSIDE' | 'CENTER' | 'OUTSIDE'\n cap?: StrokeCap\n join?: StrokeJoin\n dashPattern?: number[]\n}\n\n/**\n * A Glass effect's lens, in Figma's plugin terms: how far in from the edge it bends what is\n * behind the layer (`depth`, 1 to 100 px) and how strongly (`refraction`, 0 to 1), the light it\n * catches (`lightAngle` in degrees, 0 lighting the top edge, and `lightIntensity`, 0 to 1), and how\n * far the colours split (`dispersion`, 0 to 1). The effect's `radius` frosts the glass.\n */\nexport interface GlassEffectParams {\n refraction: number\n depth: number\n lightAngle: number\n lightIntensity: number\n dispersion: number\n}\n\n/**\n * A progressive blur's ramp, in Figma's plugin terms: the blur grows from `startRadius` at\n * `startOffset` to the effect's `radius` at `endOffset`, both points fractions of the layer's\n * size, and holds each end's radius beyond it.\n */\nexport interface ProgressiveBlur {\n startRadius: number\n startOffset: Vector\n endOffset: Vector\n}\n\n/**\n * A Noise effect's grain, in Figma's plugin terms: `MONOTONE` grains in the effect's colour,\n * `DUOTONE` in it and `secondaryColor`, `MULTITONE` in many colours at `opacity`. `noiseSize` is a\n * grain's size in px, which Figma keeps within 0 to 100, and `density` how much of the layer the\n * grains cover, 0 to 1. `seed` picks the pattern; Figma's plugin API neither shows nor sets it.\n */\nexport interface NoiseEffectParams {\n noiseType: NoiseType\n noiseSize: Vector\n density: number\n secondaryColor?: Color\n opacity?: number\n seed?: number\n}\n\n/**\n * A Texture effect's grain, which roughens the layer's edges: `noiseSize` is the grain's size in\n * px, within 0 to 100 as Figma keeps it, and `clipToShape` keeps the roughened layer inside its\n * own outline. The effect's `radius` is how far the grain moves the edges. `.fig` files name the\n * effect `GRAIN`.\n */\nexport interface TextureEffectParams {\n noiseSize: Vector\n clipToShape: boolean\n seed?: number\n}\n\nexport interface Effect {\n type:\n | 'DROP_SHADOW'\n | 'INNER_SHADOW'\n | 'LAYER_BLUR'\n | 'BACKGROUND_BLUR'\n | 'FOREGROUND_BLUR'\n | 'GLASS'\n | 'NOISE'\n | 'TEXTURE'\n color: Color\n offset: Vector\n radius: number\n spread: number\n visible: boolean\n blendMode?: BlendMode\n showShadowBehindNode?: boolean\n /** Set on a `GLASS` effect, and only there. */\n glass?: GlassEffectParams\n /** Set on a layer or background blur that is progressive, and only there. */\n progressive?: ProgressiveBlur\n /** Set on a `NOISE` effect, and only there. */\n noise?: NoiseEffectParams\n /** Set on a `TEXTURE` effect, and only there. */\n texture?: TextureEffectParams\n}\n\nexport type ConstraintType = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'SCALE'\nexport type TextAutoResize = 'NONE' | 'HEIGHT' | 'WIDTH_AND_HEIGHT'\n\n/** Where a connector end attaches to a layer: a side, the side Figma picks, or a fixed point. */\nexport type ConnectorMagnet =\n | 'NONE'\n | 'AUTO'\n | 'AUTO_HORIZONTAL'\n | 'TOP'\n | 'RIGHT'\n | 'BOTTOM'\n | 'LEFT'\n | 'CENTER'\n | 'EDGE'\n | 'ABSOLUTE'\n\n/**\n * One end of a connector. Bound to a layer, it follows the layer by `magnet`, or by `position`\n * in the layer's own axes when the magnet is `NONE`. Free, `nodeId` is null and `position` is in\n * the connector's parent's axes.\n */\nexport interface ConnectorEndpoint {\n nodeId: string | null\n magnet: ConnectorMagnet\n position: Vector\n}\n\nexport type ConnectorLineType = 'ELBOWED' | 'STRAIGHT' | 'CURVED'\n\n/**\n * A segment of an elbow connector that was dragged into place: the line it runs along, through\n * `position`, in the connector's own axes. `position` lies midway along the segment as last drawn.\n */\nexport interface ConnectorControlPoint {\n position: Vector\n direction: 'HORIZONTAL' | 'VERTICAL'\n}\n\n/**\n * Where a connector's label was dragged along its line: `offset` of the way from the middle of\n * the line towards one end, by length, on the line or to one side of it. `ABOVE` is the side to\n * the left of the line's direction.\n */\nexport interface ConnectorLabelPosition {\n section: 'MIDDLE_TO_START' | 'MIDDLE_TO_END'\n offset: number\n offAxis: 'NONE' | 'ABOVE' | 'BELOW'\n}\nexport type TextAlignVertical = 'TOP' | 'CENTER' | 'BOTTOM'\nexport type TextCase = 'ORIGINAL' | 'UPPER' | 'LOWER' | 'TITLE'\nexport type TextDecoration = 'NONE' | 'UNDERLINE' | 'STRIKETHROUGH'\nexport type TextDecorationStyle = 'SOLID' | 'DOTTED' | 'WAVY'\nexport type LeadingTrim = 'NONE' | 'CAP_HEIGHT'\nexport type TextDirection = 'AUTO' | 'LTR' | 'RTL'\nexport type LayoutDirection = 'AUTO' | 'LTR' | 'RTL'\n/** Whether a paragraph is an item of a numbered list, a bulleted list, or no list. */\nexport type TextListType = 'NONE' | 'ORDERED' | 'UNORDERED'\n\n/** How one paragraph of a text node (a line ending at a newline) sits in a list. */\n/** Spacing a text sets for all its paragraphs and a paragraph can set for itself. */\nexport type TextParagraphSpacingField = 'listSpacing' | 'paragraphSpacing' | 'paragraphIndent'\n\nexport interface TextParagraphStyle {\n listType: TextListType\n /** Nesting level: 1–5 for list items; kept but not drawn for plain paragraphs. */\n indentation: number\n /** This paragraph's own spacing, in place of the text's; absent ones follow the text. */\n listSpacing?: number\n paragraphSpacing?: number\n paragraphIndent?: number\n}\n\nexport interface FontVariation {\n axis: string\n value: number\n}\n\nexport interface FontFeature {\n tag: string\n enabled: boolean\n}\n\n/** Where a stretch of text links to, as Figma's `HyperlinkTarget`: a URL, or a node by its ID. */\nexport interface HyperlinkTarget {\n type: 'URL' | 'NODE'\n value: string\n}\n\n/** The text fields a range of characters can bind to a variable, as Figma lists them. */\nexport const TEXT_BINDABLE_FIELDS = [\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontWeight',\n 'letterSpacing',\n 'lineHeight',\n 'paragraphSpacing',\n 'paragraphIndent'\n] as const\n\nexport type TextBindableField = (typeof TEXT_BINDABLE_FIELDS)[number]\n\n/** Variable IDs bound to text fields, by field. */\nexport type TextBoundVariables = Partial<Record<TextBindableField, string>>\n\n/**\n * A line height or letter spacing as Figma keeps it: pixels, or a percent of the font size that\n * follows the size when it changes.\n */\nexport interface TextLength {\n value: number\n unit: 'PIXELS' | 'PERCENT'\n}\n\nexport interface CharacterStyleOverride {\n fontWeight?: number\n italic?: boolean\n /** The characters' face by its font's own name for it; `null` is the face their weight picks. */\n fontStyle?: string | null\n textDecoration?: TextDecoration\n textDecorationStyle?: TextDecorationStyle\n textDecorationThickness?: number | null\n textDecorationFills?: Fill[]\n textDecorationSkipInk?: boolean\n textUnderlineOffset?: number | null\n fontSize?: number\n fontFamily?: string\n letterSpacing?: TextLength\n /** `null` is automatic, from the font. */\n lineHeight?: TextLength | null\n fills?: Fill[]\n fontVariations?: FontVariation[]\n /** Whether the characters' optical size follows their font size, in place of the text's own. */\n opticalSizeFromFontSize?: boolean\n fontFeatures?: FontFeature[]\n textLanguage?: string | null\n textCase?: TextCase\n /** A link over the characters; `null`, like leaving it out, links nowhere. */\n hyperlink?: HyperlinkTarget | null\n /** The text style the characters use in place of the text's own; `null` uses none. */\n textStyleId?: string | null\n /** The fill style the characters use in place of the text's own; `null` uses none. */\n fillStyleId?: string | null\n /** The characters' text field bindings, in place of the text's own. */\n boundVariables?: TextBoundVariables\n}\n\nexport interface StyleRun {\n start: number\n length: number\n style: CharacterStyleOverride\n}\n\nexport interface ArcData {\n startingAngle: number\n endingAngle: number\n innerRadius: number\n}\n\nexport type LayoutMode = 'NONE' | 'HORIZONTAL' | 'VERTICAL' | 'GRID'\n/** A node's sizing along one axis; fill is stored on the child, see `layoutSizing`. */\nexport type LayoutSizing = 'FIXED' | 'HUG' | 'FILL'\n/** Whether an auto-layout frame keeps its size or hugs its children along one of its axes. */\nexport type AxisSizingMode = 'FIXED' | 'HUG'\n\nexport type GridTrackSizing = 'FIXED' | 'FR' | 'AUTO'\n\nexport interface GridTrack {\n sizing: GridTrackSizing\n value: number\n}\n\nexport interface GridPosition {\n column: number\n row: number\n columnSpan: number\n rowSpan: number\n}\nexport type LayoutAlign = 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN'\nexport type LayoutCounterAlign = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'BASELINE'\nexport type LayoutAlignSelf = 'AUTO' | 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'BASELINE'\nexport type LayoutWrap = 'NO_WRAP' | 'WRAP'\n\nexport interface PluginDataEntry {\n pluginId: string\n key: string\n value: string\n}\n\n/** A fixed width or height in pixels an export is scaled to, instead of a multiplier. */\nexport interface ExportSize {\n type: 'WIDTH' | 'HEIGHT'\n value: number\n}\n\n/** The colour profile an export is written in; the document's own unless set. */\nexport type ExportColorProfile = 'DOCUMENT' | 'SRGB' | 'DISPLAY_P3_V4'\n\n/**\n * One export a layer keeps. The options past `scale` and `format` are Figma's and read as Figma's\n * defaults when left out.\n */\nexport interface ExportSetting {\n scale: number\n format: ExportFormatId\n /** Appended to the file name. */\n suffix?: string\n /** A size that replaces `scale`. */\n size?: ExportSize\n /** Only the layer, without what overlaps it (default true). */\n contentsOnly?: boolean\n /** The layer's box rather than everything it draws, for text (default false). */\n useAbsoluteBounds?: boolean\n colorProfile?: ExportColorProfile\n /** SVG: text as outlines rather than `<text>` (default true). */\n svgOutlineText?: boolean\n /** SVG: every layer's name as its element's `id` (default false). */\n svgIdAttribute?: boolean\n /** SVG: strokes as strokes where possible rather than masked outlines (default true). */\n svgSimplifyStroke?: boolean\n}\n\nexport interface PluginRelaunchDataEntry {\n pluginId: string\n command: string\n message: string\n isDeleted: boolean\n}\n\n/**\n * One derived glyph outline for display (path text / missing-font fidelity).\n * Figma import is one producer; OpenPencil editing and reflow can regenerate it.\n * commandsBlob is in font units; paint multiplies by fontSize (and scaleX/Y).\n */\nexport interface TextPathData {\n network: VectorNetwork\n normalizedSize: Vector\n /** Where on the start segment the text starts, from 0 at its start to 1 at its end. */\n tValue: number\n forward: boolean\n /** The segment the text starts on, which Figma marks in the network blob; 0 when unmarked. */\n startSegment?: number\n}\n\nexport interface DerivedTextGlyph {\n /** UTF-16 source-text cluster start, when supplied by the shaping source. */\n firstCharacter?: number\n commandsBlob: Uint8Array\n x: number\n y: number\n fontSize: number\n /** Figma Glyph.rotation — radians, not degrees. Zero for axis-aligned text. */\n rotation?: number\n /**\n * Horizontal advance in pixels at `fontSize`, before `scaleX`, when the shaping source gave\n * one; where the glyph ends, so decorations stop at the text rather than the layer's edge.\n */\n advance?: number\n /**\n * Accumulated non-uniform resize scale (default 1). Paint order is\n * translate → scale(scaleX,Y) → rotate → scale(fontSize,-fontSize) so\n * anisotropic stretch matches scaleGeometryPaths(strokeGeometry).\n * Do not fold this into fontSize or rotated letters desync from outlines.\n */\n scaleX?: number\n scaleY?: number\n /**\n * The code points of the emoji this glyph stands for, sequence and all. Its outline is only a\n * placeholder square a 1 em wide; the emoji's image is drawn there instead, as Figma does.\n */\n emojiCodePoints?: number[]\n /** The image set Figma draws the emoji from, when the file names one other than Apple's. */\n emojiImageSet?: 'NOTO'\n}\n\nexport interface SymbolLink {\n uri: string\n displayName?: string\n displayText?: string\n}\n\nexport interface VariantPropSpec {\n propDefId: string\n value: string\n}\n\nexport type FigmaLayoutMetadata = Partial<\n Record<\n | 'stackMode'\n | 'stackCounterAlign'\n | 'stackJustify'\n | 'stackCounterAlignItems'\n | 'stackPrimaryAlignItems'\n | 'stackPrimarySizing'\n | 'stackCounterSizing'\n | 'stackWrap'\n | 'stackPositioning'\n | 'stackChildAlignSelf',\n string\n > &\n Record<\n | 'stackSpacing'\n | 'stackPadding'\n | 'stackPaddingRight'\n | 'stackPaddingBottom'\n | 'stackVerticalPadding'\n | 'stackHorizontalPadding'\n | 'stackChildPrimaryGrow'\n | 'stackCounterSpacing',\n number\n > &\n Record<'bordersTakeSpace' | 'stackReverseZIndex', boolean>\n>\n\nexport interface LibraryAssetIdentity {\n libraryId: string\n assetKey: string\n revisionId: string\n}\n\nexport interface LibraryAssetSource {\n identity: LibraryAssetIdentity\n sourceNodeId: string | null\n readOnly: boolean\n}\n\nexport interface EnabledLibraryBinding {\n libraryId: string\n revisionId: string\n enabled: boolean\n}\n\n/** The library a document publishes as. */\nexport interface SourceLibraryPublication {\n libraryId: string\n revisionId: string\n name: string\n catalogSource?: string\n}\n\n/** A reply in a canvas comment thread. */\nexport interface CommentReply {\n id: string\n author: string\n /** The author's collaboration color when they wrote it, for their avatar. */\n authorColor?: Color\n /** The agent that wrote it, for `author` or as itself. */\n agent?: string\n /** Markdown: bold, italic, strikethrough, links and lists. */\n text: string\n createdAt: string\n deleted?: boolean\n}\n\n/** A canvas comment thread, kept in the document's root plugin data. */\nexport interface CommentThread {\n id: string\n pageId: string\n /** Page name when the pin was placed, for readers of the raw data. */\n pageName?: string\n /** Top-level layer under the pin; the pin follows it when it moves. */\n nodeId?: string | null\n nodeName?: string | null\n /** Offset from the layer's top-left corner, in canvas units. */\n offsetX?: number\n offsetY?: number\n /** Canvas position when the pin was last saved; used when the layer is gone. */\n x: number\n y: number\n author: string\n /** The author's collaboration color when they wrote it, for their avatar. */\n authorColor?: Color\n /** The agent that wrote it, for `author` or as itself. */\n agent?: string\n /** Markdown: bold, italic, strikethrough, links and lists. */\n text: string\n createdAt: string\n /** Bumped on every change. */\n updatedAt: string\n resolved: boolean\n resolvedAt?: string | null\n /** Deleted threads stay as tombstones so a stale copy cannot bring them back. */\n deleted?: boolean\n replies: CommentReply[]\n}\n\nexport interface SceneNode {\n id: string\n type: NodeType\n name: string\n parentId: string | null\n childIds: string[]\n\n x: number\n y: number\n width: number\n height: number\n rotation: number\n source: SourceMetadata\n /** Materialized layout hint imported or generated outside the live layout pass. */\n derivedLayout: Partial<Rect> | null\n\n fills: Fill[]\n strokes: Stroke[]\n effects: Effect[]\n layoutGrids: LayoutGrid[]\n guides: CanvasGuide[]\n fillStyleId: string | null\n strokeStyleId: string | null\n textStyleId: string | null\n effectStyleId: string | null\n gridStyleId: string | null\n sharedStyleType: SharedStyleType | null\n opacity: number\n\n cornerRadius: number\n topLeftRadius: number\n topRightRadius: number\n bottomRightRadius: number\n bottomLeftRadius: number\n independentCorners: boolean\n cornerSmoothing: number\n\n visible: boolean\n locked: boolean\n clipsContent: boolean\n\n blendMode: BlendMode\n\n text: string\n fontSize: number\n fontFamily: string\n fontWeight: number\n italic: boolean\n /**\n * The face by the name its font gives it (\"Semi Bold\", \"Book\", \"Condensed Bold\"), which Figma\n * finds a font's face by; `null` is the face the weight and slant pick in the family.\n */\n fontStyle: string | null\n textAlignHorizontal: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'\n textDirection: TextDirection\n textLanguage: string | null\n textAlignVertical: TextAlignVertical\n textAutoResize: TextAutoResize\n textCase: TextCase\n textDecoration: TextDecoration\n textDecorationStyle: TextDecorationStyle\n textDecorationThickness: number | null\n textDecorationFills: Fill[]\n textDecorationSkipInk: boolean\n textUnderlineOffset: number | null\n leadingTrim: LeadingTrim\n /** `null` is automatic, from the font. */\n lineHeight: TextLength | null\n letterSpacing: TextLength\n maxLines: number | null\n /**\n * One entry per paragraph of `text`, in order. Missing entries are plain paragraphs, so text\n * without lists keeps this empty.\n */\n textParagraphs: TextParagraphStyle[]\n /** Space after a list item followed by another; a paragraph's own value comes first. */\n listSpacing: number\n /** Space after a paragraph other than between two list items. */\n paragraphSpacing: number\n /** Indent of the first line of each plain paragraph. */\n paragraphIndent: number\n /** Whether list markers hang outside the text box instead of indenting the items. */\n hangingList: boolean\n\n styleRuns: StyleRun[]\n fontVariations: FontVariation[]\n /**\n * Whether a variable font's optical size follows the font size, as Figma's \"Set optical size\n * automatically\" does by default; when it does not, the `opsz` in `fontVariations` applies.\n */\n opticalSizeFromFontSize: boolean\n fontFeatures: FontFeature[]\n\n horizontalConstraint: ConstraintType\n verticalConstraint: ConstraintType\n\n layoutMode: LayoutMode\n layoutDirection: LayoutDirection\n layoutWrap: LayoutWrap\n primaryAxisAlign: LayoutAlign\n counterAxisAlign: LayoutCounterAlign\n primaryAxisSizing: AxisSizingMode\n counterAxisSizing: AxisSizingMode\n itemSpacing: number\n /** Space between wrapped lines; null follows `itemSpacing`. Read it with `counterAxisSpacingOf`. */\n counterAxisSpacing: number | null\n paddingTop: number\n paddingRight: number\n paddingBottom: number\n paddingLeft: number\n\n layoutPositioning: 'AUTO' | 'ABSOLUTE'\n layoutGrow: number\n layoutAlignSelf: LayoutAlignSelf\n\n vectorNetwork: VectorNetwork | null\n handleMirroring: HandleMirroring\n booleanOperation: 'UNION' | 'SUBTRACT' | 'INTERSECT' | 'EXCLUDE' | undefined\n fillGeometry: GeometryPath[]\n strokeGeometry: GeometryPath[]\n\n arcData: ArcData | null\n\n strokeCap: StrokeCap\n strokeJoin: StrokeJoin\n dashPattern: number[]\n\n borderTopWeight: number\n borderRightWeight: number\n borderBottomWeight: number\n borderLeftWeight: number\n independentStrokeWeights: boolean\n\n /**\n * The weight and alignment a node keeps for its strokes, as Figma keeps them on the node: they\n * last while it has no strokes, and a stroke added to it takes them. Each stroke still carries\n * its own `weight` and `align`, which win while the node has strokes.\n */\n strokeWeight: number\n strokeAlign: Stroke['align']\n\n strokeMiterLimit: number\n\n minWidth: number | null\n maxWidth: number | null\n minHeight: number | null\n maxHeight: number | null\n /**\n * The size whose proportions the layer keeps, as Figma stores it: the width and height it had\n * when the ratio was locked, not a reduced ratio. Null leaves the proportions free.\n */\n targetAspectRatio: Vector | null\n\n /** A connector's ends and the line between them; null on other layers. */\n connectorStart: ConnectorEndpoint | null\n connectorEnd: ConnectorEndpoint | null\n connectorLineType: ConnectorLineType\n connectorStartCap: StrokeCap\n connectorEndCap: StrokeCap\n /**\n * An elbow connector's segments between its first and last, in order, once one was dragged;\n * empty while it routes itself. Kept, unused, while the line is straight or curved.\n */\n connectorControlPoints: ConnectorControlPoint[]\n /**\n * A curved connector's two cubic control points, in the connector's own axes, once its curve\n * was dragged; null while it curves by itself. Kept, unused, while the line is not curved.\n */\n connectorCurveHandles: [Vector, Vector] | null\n /** Where a connector's label was dragged to; null while it sits midway along the line. */\n connectorLabelPosition: ConnectorLabelPosition | null\n\n isMask: boolean\n maskType: MaskType\n maskIsOutline: boolean\n\n gridTemplateColumns: GridTrack[]\n gridTemplateRows: GridTrack[]\n gridColumnGap: number\n gridRowGap: number\n gridPosition: GridPosition | null\n\n counterAxisAlignContent: 'AUTO' | 'SPACE_BETWEEN'\n itemReverseZIndex: boolean\n strokesIncludedInLayout: boolean\n\n expanded: boolean\n textTruncation: 'DISABLED' | 'ENDING'\n autoRename: boolean\n\n pointCount: number\n starInnerRadius: number\n /** The FigJam kind a SHAPE_WITH_TEXT draws; its label is the node's own text. */\n shapeWithTextType: ShapeWithTextType\n /** The height a shape with text was given; it grows past it to fit its label. 0 is unset. */\n shapeUserHeight: number\n /**\n * Whether a shape with text keeps its height and cuts its label off with \"…\" instead of growing,\n * as FigJam does once the shape's height was set.\n */\n shapeTruncates: boolean\n\n componentId: string | null\n instanceOverrides: InstanceOverrideState\n componentPropertyDefinitions: ComponentPropertyDefinition[]\n componentPropertyReferences: ComponentPropertyReference[]\n componentPropertyAssignments: Record<string, string>\n componentPropertyValues: Record<string, string>\n componentKey: string | null\n sourceLibraryKey: string | null\n publishId: string | null\n overrideKey: string | null\n sharedSymbolVersion: string | null\n publishedVersion: string | null\n librarySource: LibraryAssetSource | null\n /**\n * The layer of a library's source document that a library definition's layer copies, which pairs\n * it with the same layer in the library's next revision whatever that layer is called by then.\n */\n libraryLayerId: string | null\n isPublishable: boolean\n isSymbolPublishable: boolean\n /**\n * On an instance inside a component: its properties show on instances of that component,\n * as Figma's `isExposedInstance`.\n */\n isExposedInstance: boolean\n symbolDescription: string\n symbolLinks: SymbolLink[]\n variantPropSpecs: VariantPropSpec[]\n\n boundVariables: Record<string, string>\n /** Multipliers from bound numeric values to this occurrence's scene units. */\n variableBindingScales: Partial<Record<string, number>>\n /** Numeric units for new declarations owned by this node's occurrence scope. */\n variableAssignmentScales: Partial<Record<string, number>>\n /** Explicit coordinate scale relative to the containing component definition. */\n componentScale: number\n variableModes: VariableModeMap\n exportSettings: ExportSetting[]\n /**\n * The id of the status a team gave the layer, a state of the document's workflow such as Ready\n * for dev. It stays while the layer sits where it cannot show one; `effectiveStatus` tells\n * whether it shows.\n */\n status: string | null\n\n pluginData: PluginDataEntry[]\n pluginRelaunchData: PluginRelaunchDataEntry[]\n\n internalOnly: boolean\n\n flipX: boolean\n flipY: boolean\n\n textPicture: Uint8Array | null\n derivedTextGlyphs: DerivedTextGlyph[] | null\n /**\n * How tall a text's lines are, from the top of the first to the bottom of the last: measured at\n * its width when its text or width changes, or read from the lines a file saved, and never saved\n * itself. A fixed-size box does not clip them, as in Figma, so its visual bounds reach past the\n * box on the side away from its vertical alignment (`textLinesReach`). Null when not known.\n */\n derivedTextHeight: number | null\n /** Format-neutral layout path for text-on-path nodes. */\n textPathData: TextPathData | null\n /** Node-local box that maps textPathData into the node coordinate space. */\n textPathBox: Rect | null\n}\n\nexport type ComponentPropertyType = 'VARIANT' | 'TEXT' | 'BOOLEAN' | 'INSTANCE_SWAP' | 'SLOT'\n\n/** `SLOT_CONTENT` marks a frame whose children are the slot's content. */\nexport type ComponentPropertyReferenceField = 'VISIBLE' | 'TEXT' | 'INSTANCE_SWAP' | 'SLOT_CONTENT'\n\nexport interface ComponentPropertyReference {\n propertyId: string\n field: ComponentPropertyReferenceField\n}\n\n/** Guidance for a slot property; Figma reports a breach but still accepts the content. */\nexport interface SlotSettings {\n minChildren?: number\n maxChildren?: number\n allowPreferredValuesOnly: boolean\n displayEmptyByDefault: boolean\n /** Content added to the slot fills its counter axis. */\n stretchChildOnInsert: boolean\n}\n\n/**\n * For a `SLOT` property, an instance assignment (whatever its value) means the instance owns\n * that slot's content: the slot frame's children in the instance, which component sync keeps.\n */\nexport interface ComponentPropertyDefinition {\n id: string\n name: string\n type: ComponentPropertyType\n defaultValue: string\n variantOptions?: string[]\n preferredValues?: string[]\n description?: string\n slotSettings?: SlotSettings\n}\n\nexport type VariableType = 'COLOR' | 'FLOAT' | 'STRING' | 'BOOLEAN'\nexport interface VariableAlias {\n aliasId: string\n}\n\n/** Figma's two-argument color expression; opacity is a percentage, not an alpha multiplier. */\nexport interface VariableColorExpression {\n expression: 'COMPOSE_COLOR'\n color: Color | VariableAlias\n opacity: number | VariableAlias\n}\n\nexport type VariableLiteral = Color | number | string | boolean\n/** The arithmetic, comparison, logic and conversions a formula combines values with. */\nexport const VARIABLE_FORMULA_OPERATORS = [\n 'add',\n 'subtract',\n 'multiply',\n 'divide',\n 'negate',\n 'equal',\n 'notEqual',\n 'less',\n 'lessOrEqual',\n 'greater',\n 'greaterOrEqual',\n 'and',\n 'or',\n 'not',\n 'text',\n 'truthy',\n 'if'\n] as const\nexport type VariableFormulaOperator = (typeof VARIABLE_FORMULA_OPERATORS)[number]\nexport interface VariableFormulaOperation {\n operator: VariableFormulaOperator\n operands: VariableFormulaNode[]\n}\nexport type VariableFormulaNode = VariableLiteral | VariableAlias | VariableFormulaOperation\nexport interface VariableFormula {\n expression: 'FORMULA'\n type: VariableType\n value: VariableFormulaNode\n}\n/**\n * An imported expression OpenPencil cannot evaluate, kept as the file wrote it so saving writes it\n * back. `references` holds one entry per alias in `value`, in the order the format walks them, and\n * `null` where the alias names a variable this document does not have. `modes` holds the mode id of\n * each mode key in `value`, in the same walk order.\n */\nexport interface VariableUnsupportedExpression {\n expression: 'UNSUPPORTED'\n /** The function name the file gives, such as `VAR_MODE_LOOKUP`. */\n function: string\n value: Record<string, unknown>\n references: (string | null)[]\n modes: string[]\n}\nexport type VariableValue =\n | VariableLiteral\n | VariableAlias\n | VariableColorExpression\n | VariableFormula\n | VariableUnsupportedExpression\nexport type VariableModeMap = Record<string, string>\n\n/** Property pickers a variable is offered in, as Figma names them. */\nexport const VARIABLE_SCOPES = [\n 'ALL_SCOPES',\n 'TEXT_CONTENT',\n 'CORNER_RADIUS',\n 'WIDTH_HEIGHT',\n 'GAP',\n 'ALL_FILLS',\n 'FRAME_FILL',\n 'SHAPE_FILL',\n 'TEXT_FILL',\n 'STROKE',\n 'STROKE_FLOAT',\n 'EFFECT_FLOAT',\n 'EFFECT_COLOR',\n 'OPACITY',\n 'FONT_STYLE',\n 'FONT_FAMILY',\n 'FONT_SIZE',\n 'LINE_HEIGHT',\n 'LETTER_SPACING',\n 'PARAGRAPH_SPACING',\n 'PARAGRAPH_INDENT',\n 'FONT_VARIATIONS',\n 'TRANSFORM'\n] as const\nexport type VariableScope = (typeof VARIABLE_SCOPES)[number]\n\nexport const CODE_SYNTAX_PLATFORMS = ['WEB', 'ANDROID', 'iOS'] as const\nexport type CodeSyntaxPlatform = (typeof CODE_SYNTAX_PLATFORMS)[number]\n\n/**\n * The CSS unit a numeric token is written in. Lengths (`px`, `rem`) stay in canvas pixels in\n * the document and convert only when written as CSS; the other units store the number as written.\n */\nexport const TOKEN_UNITS = ['none', 'px', 'rem', '%', 'ms', 's', 'deg'] as const\nexport type TokenUnit = (typeof TOKEN_UNITS)[number]\n\n/**\n * CSS written in place of a number mode's value, such as `clamp(1rem, 4vw, 1.5rem)`. While the\n * mode holds a plain number, `resolved` records it, so a number later edited elsewhere, Figma\n * included, shows the CSS no longer describes it.\n */\nexport interface TokenExpression {\n css: string\n resolved?: number\n}\n\nexport interface Variable {\n id: string\n name: string\n type: VariableType\n collectionId: string\n valuesByMode: Record<string, VariableValue>\n description: string\n hiddenFromPublishing: boolean\n /** Absent means every scope. */\n scopes?: VariableScope[]\n /**\n * Per-platform code snippets, as Figma's Dev Mode shows them. A `WEB` snippet of `--x` or\n * `var(--x)` names the token's CSS custom property; otherwise the name is derived.\n */\n codeSyntax?: Partial<Record<CodeSyntaxPlatform, string>>\n /** FLOAT only. Absent means inferred when written as CSS. */\n unit?: TokenUnit\n /** Raw CSS by mode id, for values a number cannot express (`clamp()`, `calc()`). */\n expressions?: Record<string, TokenExpression>\n pluginData?: PluginDataEntry[]\n /** Published library key (from NodeChange.key). Used for assetRef resolution in colorVar. */\n key?: string\n /** Published library version (from NodeChange.version). Used for assetRef resolution in colorVar. */\n version?: string\n}\n\n/** Scalar numeric node fields accepted by numeric property controls; some may also be null. */\nexport type NumericNodeProperty = {\n [K in keyof SceneNode]-?: SceneNode[K] extends number | null\n ? number extends SceneNode[K]\n ? K\n : never\n : never\n}[keyof SceneNode]\n\nexport interface VariableCollectionMode {\n modeId: string\n name: string\n /**\n * The library mode this one came from, for a mode of a collection copied from a library. A\n * library that renames its mode renames this one with it, so the layers and the document set\n * to it keep following the library.\n */\n libraryModeId?: string\n /**\n * Where the mode applies in CSS: a selector (`[data-theme=\"dark\"]`, `.compact`) or an\n * at-rule prelude (`@media (max-width: 640px)`). Absent means the default for its axis.\n */\n condition?: string\n /** Where Figma lists the mode, as the file saved it; Figma orders a collection's modes by it. */\n sortPosition?: string\n}\n\nexport interface VariableCollection {\n id: string\n name: string\n /** The default mode comes first, as in Figma. */\n modes: VariableCollectionMode[]\n defaultModeId: string\n variableIds: string[]\n /**\n * The attribute that switches a mode with no condition of its own, `data-theme` for\n * `[data-theme=\"dark\"]`. Absent means one named after the collection.\n */\n modeAttribute?: string\n pluginData?: PluginDataEntry[]\n /**\n * Published library key, for a collection the file copies from a library. Such a collection\n * belongs to the library: Figma lists it with the library's, not the file's own.\n */\n key?: string\n /** Published library version, which references by key carry with it. */\n version?: string\n}\n\n/** Whether a collection is a library's copy, which takes no variables or modes of the file's. */\nexport function isLibraryCollection(collection: Pick<VariableCollection, 'key'>): boolean {\n return !!collection.key\n}\n\n/** An HTML attribute name a stylesheet can select on unescaped: `data-theme`, `theme`. */\nexport const MODE_ATTRIBUTE_PATTERN = /^[A-Za-z_][\\w-]*$/\n\nexport function isModeAttributeName(name: string): boolean {\n return name.length <= 100 && MODE_ATTRIBUTE_PATTERN.test(name)\n}\n"],"mappings":";;AAgbA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AA+lBA,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAmCA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,wBAAwB;CAAC;CAAO;CAAW;AAAK;;;;;AAO7D,MAAa,cAAc;CAAC;CAAQ;CAAM;CAAO;CAAK;CAAM;CAAK;AAAK;;AAyFtE,SAAgB,oBAAoB,YAAsD;CACxF,OAAO,CAAC,CAAC,WAAW;AACtB;;AAGA,MAAa,yBAAyB;AAEtC,SAAgB,oBAAoB,MAAuB;CACzD,OAAO,KAAK,UAAU,OAAO,uBAAuB,KAAK,IAAI;AAC/D"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-lines -- scene node contracts are kept together as the public graph type surface */\n\nimport type { ExportFormatId } from './export-format'\nimport type { CanvasGuide } from './guides'\nimport type { InstanceOverrideState } from './instances/overrides'\nimport type { Color, Matrix, Rect, Vector } from './primitives'\nimport type { ShapeWithTextType } from './shape-with-text/kinds'\n\nexport interface SceneGraphEvents {\n 'node:created': (node: SceneNode) => void\n 'node:updated': (id: string, changes: Partial<SceneNode>) => void\n 'node:previewUpdated': (id: string, changes: Partial<SceneNode>) => void\n 'node:deleted': (id: string, parentId: string | null) => void\n 'node:reparented': (nodeId: string, oldParentId: string | null, newParentId: string) => void\n 'node:reordered': (\n nodeId: string,\n parentId: string,\n index: number,\n previousParentId: string | null\n ) => void\n}\n\nexport type SceneGraphEventHandlers = Partial<{\n created: (node: SceneNode) => void\n updated: (id: string, changes: Partial<SceneNode>) => void\n previewUpdated: (id: string, changes: Partial<SceneNode>) => void\n deleted: (id: string, parentId: string | null) => void\n reparented: (nodeId: string, oldParentId: string | null, newParentId: string) => void\n reordered: (\n nodeId: string,\n parentId: string,\n index: number,\n previousParentId: string | null\n ) => void\n}>\n\n/** The document's records besides its nodes, which edits report changing as they do nodes. */\nexport type DocumentRecordKind = 'variable' | 'collection'\n\n/** Hears about nodes as an edit adds and changes them, synchronously and before each change. */\nexport interface NodeChangeObserver {\n /** A node is about to change and is still as it was. */\n before: (node: SceneNode) => void\n /** A node was just added. */\n created: (node: SceneNode) => void\n /** A node is about to take a preview's changes, which no history keeps. */\n previewed?: (node: SceneNode) => void\n /**\n * A variable or collection is about to change, be added, or be removed, and is still as it\n * was: absent, for one about to be added.\n */\n beforeRecord?: (kind: DocumentRecordKind, id: string) => void\n /**\n * The edit being observed waits on something outside it (`SceneGraph.waitOutsideEdit`): until\n * `resume`, nodes change for someone else's edit, not this one.\n */\n pause?: () => void\n resume?: () => void\n}\n\nexport type DocumentColorSpace = 'srgb' | 'display-p3'\n\n/** What a document is for, as Figma keeps design files and FigJam boards apart. */\nexport type DocumentKind = 'design' | 'board'\n\nexport interface FigmaSourcePayload {\n rawSize: Vector | null\n rawTransform: Matrix | null\n rawNodeFields: Record<string, unknown>\n layout: FigmaLayoutMetadata | null\n symbolOverrides: unknown[]\n componentPropAssignments: unknown[]\n derivedSymbolData: unknown[]\n derivedSymbolDataLayoutVersion: number | null\n uniformScaleFactor: number | null\n}\n\nexport interface SourceMetadata {\n format: 'fig' | null\n id: string | null\n orderKey: string | null\n editedFields: string[]\n fig: FigmaSourcePayload\n}\n\nexport type HandleMirroring = 'NONE' | 'ANGLE' | 'ANGLE_AND_LENGTH'\nexport type WindingRule = 'NONZERO' | 'EVENODD'\n\nexport interface VectorVertex {\n x: number\n y: number\n strokeCap?: string\n strokeJoin?: string\n cornerRadius?: number\n handleMirroring?: HandleMirroring\n}\n\nexport interface VectorSegment {\n start: number\n end: number\n tangentStart: Vector\n tangentEnd: Vector\n}\n\nexport interface VectorRegion {\n windingRule: WindingRule\n loops: number[][]\n /** The region's own paints. Without them it draws the layer's fills, as in Figma. */\n fills?: Fill[]\n /** The shared fill style the region's paints come from. */\n fillStyleId?: string\n}\n\nexport interface VectorNetwork {\n vertices: VectorVertex[]\n segments: VectorSegment[]\n regions: VectorRegion[]\n}\n\nexport interface GeometryPath {\n windingRule: WindingRule\n commandsBlob: Uint8Array\n}\n\nexport type NodeType =\n | 'CANVAS'\n | 'FRAME'\n | 'RECTANGLE'\n | 'ROUNDED_RECTANGLE'\n | 'ELLIPSE'\n | 'TEXT'\n | 'LINE'\n | 'STAR'\n | 'POLYGON'\n | 'VECTOR'\n | 'BOOLEAN_OPERATION'\n | 'GROUP'\n | 'SECTION'\n | 'COMPONENT'\n | 'COMPONENT_SET'\n | 'INSTANCE'\n | 'CONNECTOR'\n | 'SHAPE_WITH_TEXT'\n | 'STICKY'\n\nexport type FillType =\n | 'SOLID'\n | 'GRADIENT_LINEAR'\n | 'GRADIENT_RADIAL'\n | 'GRADIENT_ANGULAR'\n | 'GRADIENT_DIAMOND'\n | 'IMAGE'\n | 'VIDEO'\n | 'PATTERN'\n | 'NOISE'\n | 'CUSTOM'\nexport type BlendMode =\n | 'NORMAL'\n | 'DARKEN'\n | 'MULTIPLY'\n | 'LINEAR_BURN'\n | 'COLOR_BURN'\n | 'LIGHTEN'\n | 'SCREEN'\n | 'LINEAR_DODGE'\n | 'COLOR_DODGE'\n | 'OVERLAY'\n | 'SOFT_LIGHT'\n | 'HARD_LIGHT'\n | 'DIFFERENCE'\n | 'EXCLUSION'\n | 'HUE'\n | 'SATURATION'\n | 'COLOR'\n | 'LUMINOSITY'\n | 'PASS_THROUGH'\nexport type ImageScaleMode = 'FILL' | 'FIT' | 'CROP' | 'TILE'\nexport type NoiseType = 'MULTITONE' | 'MONOTONE' | 'DUOTONE'\nexport type PatternTileType = 'RECTANGULAR' | 'HORIZONTAL_HEXAGONAL' | 'VERTICAL_HEXAGONAL'\nexport type PatternAlignment = 'START' | 'CENTER' | 'END'\n\nexport interface GradientStop {\n color: Color\n position: number\n}\n\nexport type GradientTransform = Matrix\n\n/** Figma's adjustments of an image paint, each from -1 to 1; 0 leaves the image as it is. */\nexport interface ImageFilters {\n exposure?: number\n contrast?: number\n saturation?: number\n temperature?: number\n tint?: number\n highlights?: number\n shadows?: number\n}\n\nexport interface Fill {\n type: FillType\n color: Color\n opacity: number\n visible: boolean\n blendMode?: BlendMode\n gradientStops?: GradientStop[]\n gradientTransform?: GradientTransform\n /** The image an IMAGE paint draws, or the poster frame a VIDEO paint draws in its clip's place. */\n imageHash?: string\n /** A VIDEO paint's clip, which `imageHash`'s poster frame stands in for when drawn. */\n videoHash?: string\n imageScaleMode?: ImageScaleMode\n /** A crop's image-space window; Fill, Fit and Tile ignore it. */\n imageTransform?: GradientTransform\n /** Clockwise turn of a Fill, Fit or Tile image, in multiples of 90°; a crop holds its own. */\n imageRotation?: number\n /** An image's adjustments, kept and saved; the canvas does not draw them. */\n filters?: ImageFilters\n sourceNodeId?: string\n scale?: number\n spacing?: number\n patternSpacing?: Vector\n patternTileType?: PatternTileType\n verticalAlignment?: PatternAlignment\n horizontalAlignment?: PatternAlignment\n noiseType?: NoiseType\n density?: number\n noiseSize?: Vector\n customEffectId?: string\n}\n\nexport type StrokeCap =\n | 'NONE'\n | 'ROUND'\n | 'SQUARE'\n | 'ARROW_LINES'\n | 'ARROW_EQUILATERAL'\n | 'TRIANGLE_FILLED'\n | 'DIAMOND_FILLED'\n | 'CIRCLE_FILLED'\nexport type StrokeJoin = 'MITER' | 'BEVEL' | 'ROUND'\nexport type SharedStyleType = 'FILL' | 'TEXT' | 'EFFECT' | 'GRID'\nexport type SharedStyleKind = 'fill' | 'stroke' | 'text' | 'effect' | 'grid'\nexport type MaskType = 'ALPHA' | 'VECTOR' | 'LUMINANCE'\n\nexport interface LayoutGrid {\n visible?: boolean\n color?: Color\n /** `STRIPES` is the archive's name for columns or rows, along `axis`. */\n pattern?: 'COLUMNS' | 'ROWS' | 'GRID' | 'STRIPES'\n axis?: 'X' | 'Y'\n type?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH'\n alignment?: 'MIN' | 'CENTER' | 'MAX' | 'STRETCH'\n numSections?: number\n /** Figma's plugin API reports an Auto count as `null` and accepts `Infinity` for it. */\n count?: number | null\n offset?: number\n sectionSize?: number\n gutterSize?: number\n}\n\nexport interface SharedStyle {\n id: string\n nodeId: string\n name: string\n type: SharedStyleType\n}\n\n/** A stroke is a paint with the geometry that decides where it is drawn. */\nexport interface Stroke extends Fill {\n weight: number\n align: 'INSIDE' | 'CENTER' | 'OUTSIDE'\n cap?: StrokeCap\n join?: StrokeJoin\n dashPattern?: number[]\n}\n\n/**\n * A Glass effect's lens, in Figma's plugin terms: how far in from the edge it bends what is\n * behind the layer (`depth`, 1 to 100 px) and how strongly (`refraction`, 0 to 1), the light it\n * catches (`lightAngle` in degrees, 0 lighting the top edge, and `lightIntensity`, 0 to 1), and how\n * far the colours split (`dispersion`, 0 to 1). The effect's `radius` frosts the glass.\n */\nexport interface GlassEffectParams {\n refraction: number\n depth: number\n lightAngle: number\n lightIntensity: number\n dispersion: number\n}\n\n/**\n * A progressive blur's ramp, in Figma's plugin terms: the blur grows from `startRadius` at\n * `startOffset` to the effect's `radius` at `endOffset`, both points fractions of the layer's\n * size, and holds each end's radius beyond it.\n */\nexport interface ProgressiveBlur {\n startRadius: number\n startOffset: Vector\n endOffset: Vector\n}\n\n/**\n * A Noise effect's grain, in Figma's plugin terms: `MONOTONE` grains in the effect's colour,\n * `DUOTONE` in it and `secondaryColor`, `MULTITONE` in many colours at `opacity`. `noiseSize` is a\n * grain's size in px, which Figma keeps within 0 to 100, and `density` how much of the layer the\n * grains cover, 0 to 1. `seed` picks the pattern; Figma's plugin API neither shows nor sets it.\n */\nexport interface NoiseEffectParams {\n noiseType: NoiseType\n noiseSize: Vector\n density: number\n secondaryColor?: Color\n opacity?: number\n seed?: number\n}\n\n/**\n * A Texture effect's grain, which roughens the layer's edges: `noiseSize` is the grain's size in\n * px, within 0 to 100 as Figma keeps it, and `clipToShape` keeps the roughened layer inside its\n * own outline. The effect's `radius` is how far the grain moves the edges. `.fig` files name the\n * effect `GRAIN`.\n */\nexport interface TextureEffectParams {\n noiseSize: Vector\n clipToShape: boolean\n seed?: number\n}\n\nexport interface Effect {\n type:\n | 'DROP_SHADOW'\n | 'INNER_SHADOW'\n | 'LAYER_BLUR'\n | 'BACKGROUND_BLUR'\n | 'FOREGROUND_BLUR'\n | 'GLASS'\n | 'NOISE'\n | 'TEXTURE'\n color: Color\n offset: Vector\n radius: number\n spread: number\n visible: boolean\n blendMode?: BlendMode\n showShadowBehindNode?: boolean\n /** Set on a `GLASS` effect, and only there. */\n glass?: GlassEffectParams\n /** Set on a layer or background blur that is progressive, and only there. */\n progressive?: ProgressiveBlur\n /** Set on a `NOISE` effect, and only there. */\n noise?: NoiseEffectParams\n /** Set on a `TEXTURE` effect, and only there. */\n texture?: TextureEffectParams\n}\n\nexport type ConstraintType = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'SCALE'\nexport type TextAutoResize = 'NONE' | 'HEIGHT' | 'WIDTH_AND_HEIGHT'\n\n/** Where a connector end attaches to a layer: a side, the side Figma picks, or a fixed point. */\nexport type ConnectorMagnet =\n | 'NONE'\n | 'AUTO'\n | 'AUTO_HORIZONTAL'\n | 'TOP'\n | 'RIGHT'\n | 'BOTTOM'\n | 'LEFT'\n | 'CENTER'\n | 'EDGE'\n | 'ABSOLUTE'\n\n/**\n * One end of a connector. Bound to a layer, it follows the layer by `magnet`, or by `position`\n * in the layer's own axes when the magnet is `NONE`. Free, `nodeId` is null and `position` is in\n * the connector's parent's axes.\n */\nexport interface ConnectorEndpoint {\n nodeId: string | null\n magnet: ConnectorMagnet\n position: Vector\n}\n\nexport type ConnectorLineType = 'ELBOWED' | 'STRAIGHT' | 'CURVED'\n\n/**\n * A segment of an elbow connector that was dragged into place: the line it runs along, through\n * `position`, in the connector's own axes. `position` lies midway along the segment as last drawn.\n */\nexport interface ConnectorControlPoint {\n position: Vector\n direction: 'HORIZONTAL' | 'VERTICAL'\n}\n\n/**\n * Where a connector's label was dragged along its line: `offset` of the way from the middle of\n * the line towards one end, by length, on the line or to one side of it. `ABOVE` is the side to\n * the left of the line's direction.\n */\nexport interface ConnectorLabelPosition {\n section: 'MIDDLE_TO_START' | 'MIDDLE_TO_END'\n offset: number\n offAxis: 'NONE' | 'ABOVE' | 'BELOW'\n}\nexport type TextAlignVertical = 'TOP' | 'CENTER' | 'BOTTOM'\nexport type TextCase = 'ORIGINAL' | 'UPPER' | 'LOWER' | 'TITLE'\nexport type TextDecoration = 'NONE' | 'UNDERLINE' | 'STRIKETHROUGH'\nexport type TextDecorationStyle = 'SOLID' | 'DOTTED' | 'WAVY'\nexport type LeadingTrim = 'NONE' | 'CAP_HEIGHT'\nexport type TextDirection = 'AUTO' | 'LTR' | 'RTL'\nexport type LayoutDirection = 'AUTO' | 'LTR' | 'RTL'\n/** Whether a paragraph is an item of a numbered list, a bulleted list, or no list. */\nexport type TextListType = 'NONE' | 'ORDERED' | 'UNORDERED'\n\n/** How one paragraph of a text node (a line ending at a newline) sits in a list. */\n/** Spacing a text sets for all its paragraphs and a paragraph can set for itself. */\nexport type TextParagraphSpacingField = 'listSpacing' | 'paragraphSpacing' | 'paragraphIndent'\n\nexport interface TextParagraphStyle {\n listType: TextListType\n /** Nesting level: 1–5 for list items; kept but not drawn for plain paragraphs. */\n indentation: number\n /** This paragraph's own spacing, in place of the text's; absent ones follow the text. */\n listSpacing?: number\n paragraphSpacing?: number\n paragraphIndent?: number\n}\n\nexport interface FontVariation {\n axis: string\n value: number\n}\n\nexport interface FontFeature {\n tag: string\n enabled: boolean\n}\n\n/** Where a stretch of text links to, as Figma's `HyperlinkTarget`: a URL, or a node by its ID. */\nexport interface HyperlinkTarget {\n type: 'URL' | 'NODE'\n value: string\n}\n\n/** The text fields a range of characters can bind to a variable, as Figma lists them. */\nexport const TEXT_BINDABLE_FIELDS = [\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontWeight',\n 'letterSpacing',\n 'lineHeight',\n 'paragraphSpacing',\n 'paragraphIndent'\n] as const\n\nexport type TextBindableField = (typeof TEXT_BINDABLE_FIELDS)[number]\n\n/** Variable IDs bound to text fields, by field. */\nexport type TextBoundVariables = Partial<Record<TextBindableField, string>>\n\n/**\n * A line height or letter spacing as Figma keeps it: pixels, or a percent of the font size that\n * follows the size when it changes.\n */\nexport interface TextLength {\n value: number\n unit: 'PIXELS' | 'PERCENT'\n}\n\nexport interface CharacterStyleOverride {\n fontWeight?: number\n italic?: boolean\n /** The characters' face by its font's own name for it; `null` is the face their weight picks. */\n fontStyle?: string | null\n textDecoration?: TextDecoration\n textDecorationStyle?: TextDecorationStyle\n textDecorationThickness?: number | null\n textDecorationFills?: Fill[]\n textDecorationSkipInk?: boolean\n textUnderlineOffset?: number | null\n fontSize?: number\n fontFamily?: string\n letterSpacing?: TextLength\n /** `null` is automatic, from the font. */\n lineHeight?: TextLength | null\n fills?: Fill[]\n fontVariations?: FontVariation[]\n /** Whether the characters' optical size follows their font size, in place of the text's own. */\n opticalSizeFromFontSize?: boolean\n fontFeatures?: FontFeature[]\n textLanguage?: string | null\n textCase?: TextCase\n /** A link over the characters; `null`, like leaving it out, links nowhere. */\n hyperlink?: HyperlinkTarget | null\n /** The text style the characters use in place of the text's own; `null` uses none. */\n textStyleId?: string | null\n /** The fill style the characters use in place of the text's own; `null` uses none. */\n fillStyleId?: string | null\n /** The characters' text field bindings, in place of the text's own. */\n boundVariables?: TextBoundVariables\n}\n\nexport interface StyleRun {\n start: number\n length: number\n style: CharacterStyleOverride\n}\n\nexport interface ArcData {\n startingAngle: number\n endingAngle: number\n innerRadius: number\n}\n\nexport type LayoutMode = 'NONE' | 'HORIZONTAL' | 'VERTICAL' | 'GRID'\n/** A node's sizing along one axis; fill is stored on the child, see `layoutSizing`. */\nexport type LayoutSizing = 'FIXED' | 'HUG' | 'FILL'\n/** Whether an auto-layout frame keeps its size or hugs its children along one of its axes. */\nexport type AxisSizingMode = 'FIXED' | 'HUG'\n\nexport type GridTrackSizing = 'FIXED' | 'FR' | 'AUTO'\n\nexport interface GridTrack {\n sizing: GridTrackSizing\n value: number\n}\n\nexport interface GridPosition {\n column: number\n row: number\n columnSpan: number\n rowSpan: number\n}\nexport type LayoutAlign = 'MIN' | 'CENTER' | 'MAX' | 'SPACE_BETWEEN'\nexport type LayoutCounterAlign = 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'BASELINE'\nexport type LayoutAlignSelf = 'AUTO' | 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' | 'BASELINE'\nexport type LayoutWrap = 'NO_WRAP' | 'WRAP'\n\nexport interface PluginDataEntry {\n pluginId: string\n key: string\n value: string\n}\n\n/** A fixed width or height in pixels an export is scaled to, instead of a multiplier. */\nexport interface ExportSize {\n type: 'WIDTH' | 'HEIGHT'\n value: number\n}\n\n/** The colour profile an export is written in; the document's own unless set. */\nexport type ExportColorProfile = 'DOCUMENT' | 'SRGB' | 'DISPLAY_P3_V4'\n\n/**\n * One export a layer keeps. The options past `scale` and `format` are Figma's and read as Figma's\n * defaults when left out.\n */\nexport interface ExportSetting {\n scale: number\n format: ExportFormatId\n /** Appended to the file name. */\n suffix?: string\n /** A size that replaces `scale`. */\n size?: ExportSize\n /** Only the layer, without what overlaps it (default true). */\n contentsOnly?: boolean\n /** The layer's box rather than everything it draws, for text (default false). */\n useAbsoluteBounds?: boolean\n colorProfile?: ExportColorProfile\n /** SVG: text as outlines rather than `<text>` (default true). */\n svgOutlineText?: boolean\n /** SVG: every layer's name as its element's `id` (default false). */\n svgIdAttribute?: boolean\n /** SVG: strokes as strokes where possible rather than masked outlines (default true). */\n svgSimplifyStroke?: boolean\n}\n\nexport interface PluginRelaunchDataEntry {\n pluginId: string\n command: string\n message: string\n isDeleted: boolean\n}\n\n/**\n * One derived glyph outline for display (path text / missing-font fidelity).\n * Figma import is one producer; OpenPencil editing and reflow can regenerate it.\n * commandsBlob is in font units; paint multiplies by fontSize (and scaleX/Y).\n */\nexport interface TextPathData {\n network: VectorNetwork\n normalizedSize: Vector\n /** Where on the start segment the text starts, from 0 at its start to 1 at its end. */\n tValue: number\n forward: boolean\n /** The segment the text starts on, which Figma marks in the network blob; 0 when unmarked. */\n startSegment?: number\n}\n\nexport interface DerivedTextGlyph {\n /** UTF-16 source-text cluster start, when supplied by the shaping source. */\n firstCharacter?: number\n commandsBlob: Uint8Array\n x: number\n y: number\n fontSize: number\n /** Figma Glyph.rotation — radians, not degrees. Zero for axis-aligned text. */\n rotation?: number\n /**\n * Horizontal advance in pixels at `fontSize`, before `scaleX`, when the shaping source gave\n * one; where the glyph ends, so decorations stop at the text rather than the layer's edge.\n */\n advance?: number\n /**\n * Accumulated non-uniform resize scale (default 1). Paint order is\n * translate → scale(scaleX,Y) → rotate → scale(fontSize,-fontSize) so\n * anisotropic stretch matches scaleGeometryPaths(strokeGeometry).\n * Do not fold this into fontSize or rotated letters desync from outlines.\n */\n scaleX?: number\n scaleY?: number\n /**\n * The code points of the emoji this glyph stands for, sequence and all. Its outline is only a\n * placeholder square a 1 em wide; the emoji's image is drawn there instead, as Figma does.\n */\n emojiCodePoints?: number[]\n /** The image set Figma draws the emoji from, when the file names one other than Apple's. */\n emojiImageSet?: 'NOTO'\n}\n\nexport interface SymbolLink {\n uri: string\n displayName?: string\n displayText?: string\n}\n\nexport interface VariantPropSpec {\n propDefId: string\n value: string\n}\n\nexport type FigmaLayoutMetadata = Partial<\n Record<\n | 'stackMode'\n | 'stackCounterAlign'\n | 'stackJustify'\n | 'stackCounterAlignItems'\n | 'stackPrimaryAlignItems'\n | 'stackPrimarySizing'\n | 'stackCounterSizing'\n | 'stackWrap'\n | 'stackPositioning'\n | 'stackChildAlignSelf',\n string\n > &\n Record<\n | 'stackSpacing'\n | 'stackPadding'\n | 'stackPaddingRight'\n | 'stackPaddingBottom'\n | 'stackVerticalPadding'\n | 'stackHorizontalPadding'\n | 'stackChildPrimaryGrow'\n | 'stackCounterSpacing',\n number\n > &\n Record<'bordersTakeSpace' | 'stackReverseZIndex', boolean>\n>\n\nexport interface LibraryAssetIdentity {\n libraryId: string\n assetKey: string\n revisionId: string\n}\n\nexport interface LibraryAssetSource {\n identity: LibraryAssetIdentity\n sourceNodeId: string | null\n readOnly: boolean\n}\n\nexport interface EnabledLibraryBinding {\n libraryId: string\n revisionId: string\n enabled: boolean\n}\n\n/** The library a document publishes as. */\nexport interface SourceLibraryPublication {\n libraryId: string\n revisionId: string\n name: string\n catalogSource?: string\n}\n\n/** A reply in a canvas comment thread. */\nexport interface CommentReply {\n id: string\n author: string\n /** The author's collaboration color when they wrote it, for their avatar. */\n authorColor?: Color\n /** The agent that wrote it, for `author` or as itself. */\n agent?: string\n /** Markdown: bold, italic, strikethrough, links and lists. */\n text: string\n createdAt: string\n deleted?: boolean\n}\n\n/** A canvas comment thread, kept in the document's root plugin data. */\nexport interface CommentThread {\n id: string\n pageId: string\n /** Page name when the pin was placed, for readers of the raw data. */\n pageName?: string\n /** Top-level layer under the pin; the pin follows it when it moves. */\n nodeId?: string | null\n nodeName?: string | null\n /** Offset from the layer's top-left corner, in canvas units. */\n offsetX?: number\n offsetY?: number\n /** Canvas position when the pin was last saved; used when the layer is gone. */\n x: number\n y: number\n author: string\n /** The author's collaboration color when they wrote it, for their avatar. */\n authorColor?: Color\n /** The agent that wrote it, for `author` or as itself. */\n agent?: string\n /** Markdown: bold, italic, strikethrough, links and lists. */\n text: string\n createdAt: string\n /** Bumped on every change. */\n updatedAt: string\n resolved: boolean\n resolvedAt?: string | null\n /** Deleted threads stay as tombstones so a stale copy cannot bring them back. */\n deleted?: boolean\n replies: CommentReply[]\n}\n\nexport interface SceneNode {\n id: string\n type: NodeType\n name: string\n parentId: string | null\n childIds: string[]\n\n x: number\n y: number\n width: number\n height: number\n rotation: number\n source: SourceMetadata\n /** Materialized layout hint imported or generated outside the live layout pass. */\n derivedLayout: Partial<Rect> | null\n\n fills: Fill[]\n strokes: Stroke[]\n effects: Effect[]\n layoutGrids: LayoutGrid[]\n guides: CanvasGuide[]\n fillStyleId: string | null\n strokeStyleId: string | null\n textStyleId: string | null\n effectStyleId: string | null\n gridStyleId: string | null\n sharedStyleType: SharedStyleType | null\n opacity: number\n\n cornerRadius: number\n topLeftRadius: number\n topRightRadius: number\n bottomRightRadius: number\n bottomLeftRadius: number\n independentCorners: boolean\n cornerSmoothing: number\n\n visible: boolean\n locked: boolean\n clipsContent: boolean\n\n blendMode: BlendMode\n\n text: string\n fontSize: number\n fontFamily: string\n fontWeight: number\n italic: boolean\n /**\n * The face by the name its font gives it (\"Semi Bold\", \"Book\", \"Condensed Bold\"), which Figma\n * finds a font's face by; `null` is the face the weight and slant pick in the family.\n */\n fontStyle: string | null\n textAlignHorizontal: 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED'\n textDirection: TextDirection\n textLanguage: string | null\n textAlignVertical: TextAlignVertical\n textAutoResize: TextAutoResize\n textCase: TextCase\n textDecoration: TextDecoration\n textDecorationStyle: TextDecorationStyle\n textDecorationThickness: number | null\n textDecorationFills: Fill[]\n textDecorationSkipInk: boolean\n textUnderlineOffset: number | null\n leadingTrim: LeadingTrim\n /** `null` is automatic, from the font. */\n lineHeight: TextLength | null\n letterSpacing: TextLength\n maxLines: number | null\n /**\n * One entry per paragraph of `text`, in order. Missing entries are plain paragraphs, so text\n * without lists keeps this empty.\n */\n textParagraphs: TextParagraphStyle[]\n /** Space after a list item followed by another; a paragraph's own value comes first. */\n listSpacing: number\n /** Space after a paragraph other than between two list items. */\n paragraphSpacing: number\n /** Indent of the first line of each plain paragraph. */\n paragraphIndent: number\n /** Whether list markers hang outside the text box instead of indenting the items. */\n hangingList: boolean\n\n styleRuns: StyleRun[]\n fontVariations: FontVariation[]\n /**\n * Whether a variable font's optical size follows the font size, as Figma's \"Set optical size\n * automatically\" does by default; when it does not, the `opsz` in `fontVariations` applies.\n */\n opticalSizeFromFontSize: boolean\n fontFeatures: FontFeature[]\n\n horizontalConstraint: ConstraintType\n verticalConstraint: ConstraintType\n\n layoutMode: LayoutMode\n layoutDirection: LayoutDirection\n layoutWrap: LayoutWrap\n primaryAxisAlign: LayoutAlign\n counterAxisAlign: LayoutCounterAlign\n primaryAxisSizing: AxisSizingMode\n counterAxisSizing: AxisSizingMode\n itemSpacing: number\n /** Space between wrapped lines; null follows `itemSpacing`. Read it with `counterAxisSpacingOf`. */\n counterAxisSpacing: number | null\n paddingTop: number\n paddingRight: number\n paddingBottom: number\n paddingLeft: number\n\n layoutPositioning: 'AUTO' | 'ABSOLUTE'\n layoutGrow: number\n layoutAlignSelf: LayoutAlignSelf\n\n vectorNetwork: VectorNetwork | null\n handleMirroring: HandleMirroring\n booleanOperation: 'UNION' | 'SUBTRACT' | 'INTERSECT' | 'EXCLUDE' | undefined\n fillGeometry: GeometryPath[]\n strokeGeometry: GeometryPath[]\n\n arcData: ArcData | null\n\n strokeCap: StrokeCap\n strokeJoin: StrokeJoin\n dashPattern: number[]\n\n borderTopWeight: number\n borderRightWeight: number\n borderBottomWeight: number\n borderLeftWeight: number\n independentStrokeWeights: boolean\n\n /**\n * The weight and alignment a node keeps for its strokes, as Figma keeps them on the node: they\n * last while it has no strokes, and a stroke added to it takes them. Each stroke still carries\n * its own `weight` and `align`, which win while the node has strokes.\n */\n strokeWeight: number\n strokeAlign: Stroke['align']\n\n strokeMiterLimit: number\n\n minWidth: number | null\n maxWidth: number | null\n minHeight: number | null\n maxHeight: number | null\n /**\n * The size whose proportions the layer keeps, as Figma stores it: the width and height it had\n * when the ratio was locked, not a reduced ratio. Null leaves the proportions free.\n */\n targetAspectRatio: Vector | null\n\n /** A connector's ends and the line between them; null on other layers. */\n connectorStart: ConnectorEndpoint | null\n connectorEnd: ConnectorEndpoint | null\n connectorLineType: ConnectorLineType\n connectorStartCap: StrokeCap\n connectorEndCap: StrokeCap\n /**\n * An elbow connector's segments between its first and last, in order, once one was dragged;\n * empty while it routes itself. Kept, unused, while the line is straight or curved.\n */\n connectorControlPoints: ConnectorControlPoint[]\n /**\n * A curved connector's two cubic control points, in the connector's own axes, once its curve\n * was dragged; null while it curves by itself. Kept, unused, while the line is not curved.\n */\n connectorCurveHandles: [Vector, Vector] | null\n /** Where a connector's label was dragged to; null while it sits midway along the line. */\n connectorLabelPosition: ConnectorLabelPosition | null\n\n isMask: boolean\n maskType: MaskType\n maskIsOutline: boolean\n\n gridTemplateColumns: GridTrack[]\n gridTemplateRows: GridTrack[]\n gridColumnGap: number\n gridRowGap: number\n gridPosition: GridPosition | null\n\n counterAxisAlignContent: 'AUTO' | 'SPACE_BETWEEN'\n itemReverseZIndex: boolean\n strokesIncludedInLayout: boolean\n\n expanded: boolean\n textTruncation: 'DISABLED' | 'ENDING'\n autoRename: boolean\n\n pointCount: number\n starInnerRadius: number\n /** The FigJam kind a SHAPE_WITH_TEXT draws; its label is the node's own text. */\n shapeWithTextType: ShapeWithTextType\n /** The height a shape with text was given; it grows past it to fit its label. 0 is unset. */\n shapeUserHeight: number\n /**\n * Whether a shape with text keeps its height and cuts its label off with \"…\" instead of growing,\n * as FigJam does once the shape's height was set.\n */\n shapeTruncates: boolean\n\n componentId: string | null\n instanceOverrides: InstanceOverrideState\n componentPropertyDefinitions: ComponentPropertyDefinition[]\n componentPropertyReferences: ComponentPropertyReference[]\n componentPropertyAssignments: Record<string, string>\n componentPropertyValues: Record<string, string>\n componentKey: string | null\n sourceLibraryKey: string | null\n publishId: string | null\n overrideKey: string | null\n sharedSymbolVersion: string | null\n publishedVersion: string | null\n librarySource: LibraryAssetSource | null\n /**\n * The layer of a library's source document that a library definition's layer copies, which pairs\n * it with the same layer in the library's next revision whatever that layer is called by then.\n */\n libraryLayerId: string | null\n isPublishable: boolean\n isSymbolPublishable: boolean\n /**\n * On an instance inside a component: its properties show on instances of that component,\n * as Figma's `isExposedInstance`.\n */\n isExposedInstance: boolean\n symbolDescription: string\n symbolLinks: SymbolLink[]\n variantPropSpecs: VariantPropSpec[]\n\n boundVariables: Record<string, string>\n /** Multipliers from bound numeric values to this occurrence's scene units. */\n variableBindingScales: Partial<Record<string, number>>\n /** Numeric units for new declarations owned by this node's occurrence scope. */\n variableAssignmentScales: Partial<Record<string, number>>\n /** Explicit coordinate scale relative to the containing component definition. */\n componentScale: number\n variableModes: VariableModeMap\n exportSettings: ExportSetting[]\n /**\n * The id of the status a team gave the layer, a state of the document's workflow such as Ready\n * for dev. It stays while the layer sits where it cannot show one; `effectiveStatus` tells\n * whether it shows.\n */\n status: string | null\n\n pluginData: PluginDataEntry[]\n pluginRelaunchData: PluginRelaunchDataEntry[]\n\n internalOnly: boolean\n\n flipX: boolean\n flipY: boolean\n\n textPicture: Uint8Array | null\n derivedTextGlyphs: DerivedTextGlyph[] | null\n /**\n * How tall a text's lines are, from the top of the first to the bottom of the last: measured at\n * its width when its text or width changes, or read from the lines a file saved, and never saved\n * itself. A fixed-size box does not clip them, as in Figma, so its visual bounds reach past the\n * box on the side away from its vertical alignment (`textLinesReach`). Null when not known.\n */\n derivedTextHeight: number | null\n /** Format-neutral layout path for text-on-path nodes. */\n textPathData: TextPathData | null\n /** Node-local box that maps textPathData into the node coordinate space. */\n textPathBox: Rect | null\n}\n\nexport type ComponentPropertyType = 'VARIANT' | 'TEXT' | 'BOOLEAN' | 'INSTANCE_SWAP' | 'SLOT'\n\n/** `SLOT_CONTENT` marks a frame whose children are the slot's content. */\nexport type ComponentPropertyReferenceField = 'VISIBLE' | 'TEXT' | 'INSTANCE_SWAP' | 'SLOT_CONTENT'\n\nexport interface ComponentPropertyReference {\n propertyId: string\n field: ComponentPropertyReferenceField\n}\n\n/** Guidance for a slot property; Figma reports a breach but still accepts the content. */\nexport interface SlotSettings {\n minChildren?: number\n maxChildren?: number\n allowPreferredValuesOnly: boolean\n displayEmptyByDefault: boolean\n /** Content added to the slot fills its counter axis. */\n stretchChildOnInsert: boolean\n}\n\n/**\n * For a `SLOT` property, an instance assignment (whatever its value) means the instance owns\n * that slot's content: the slot frame's children in the instance, which component sync keeps.\n */\nexport interface ComponentPropertyDefinition {\n id: string\n name: string\n type: ComponentPropertyType\n defaultValue: string\n variantOptions?: string[]\n preferredValues?: string[]\n description?: string\n slotSettings?: SlotSettings\n}\n\nexport type VariableType = 'COLOR' | 'FLOAT' | 'STRING' | 'BOOLEAN'\nexport interface VariableAlias {\n aliasId: string\n}\n\n/** Figma's two-argument color expression; opacity is a percentage, not an alpha multiplier. */\nexport interface VariableColorExpression {\n expression: 'COMPOSE_COLOR'\n color: Color | VariableAlias\n opacity: number | VariableAlias\n}\n\nexport type VariableLiteral = Color | number | string | boolean\n/** The arithmetic, comparison, logic and conversions a formula combines values with. */\nexport const VARIABLE_FORMULA_OPERATORS = [\n 'add',\n 'subtract',\n 'multiply',\n 'divide',\n 'negate',\n 'equal',\n 'notEqual',\n 'less',\n 'lessOrEqual',\n 'greater',\n 'greaterOrEqual',\n 'and',\n 'or',\n 'not',\n 'text',\n 'truthy',\n 'if'\n] as const\nexport type VariableFormulaOperator = (typeof VARIABLE_FORMULA_OPERATORS)[number]\nexport interface VariableFormulaOperation {\n operator: VariableFormulaOperator\n operands: VariableFormulaNode[]\n}\nexport type VariableFormulaNode = VariableLiteral | VariableAlias | VariableFormulaOperation\nexport interface VariableFormula {\n expression: 'FORMULA'\n type: VariableType\n value: VariableFormulaNode\n}\n/**\n * An imported expression OpenPencil cannot evaluate, kept as the file wrote it so saving writes it\n * back. `references` holds one entry per alias in `value`, in the order the format walks them, and\n * `null` where the alias names a variable this document does not have. `modes` holds the mode id of\n * each mode key in `value`, in the same walk order.\n */\nexport interface VariableUnsupportedExpression {\n expression: 'UNSUPPORTED'\n /** The function name the file gives, such as `VAR_MODE_LOOKUP`. */\n function: string\n value: Record<string, unknown>\n references: (string | null)[]\n modes: string[]\n}\nexport type VariableValue =\n | VariableLiteral\n | VariableAlias\n | VariableColorExpression\n | VariableFormula\n | VariableUnsupportedExpression\nexport type VariableModeMap = Record<string, string>\n\n/** Property pickers a variable is offered in, as Figma names them. */\nexport const VARIABLE_SCOPES = [\n 'ALL_SCOPES',\n 'TEXT_CONTENT',\n 'CORNER_RADIUS',\n 'WIDTH_HEIGHT',\n 'GAP',\n 'ALL_FILLS',\n 'FRAME_FILL',\n 'SHAPE_FILL',\n 'TEXT_FILL',\n 'STROKE',\n 'STROKE_FLOAT',\n 'EFFECT_FLOAT',\n 'EFFECT_COLOR',\n 'OPACITY',\n 'FONT_STYLE',\n 'FONT_FAMILY',\n 'FONT_SIZE',\n 'LINE_HEIGHT',\n 'LETTER_SPACING',\n 'PARAGRAPH_SPACING',\n 'PARAGRAPH_INDENT',\n 'FONT_VARIATIONS',\n 'TRANSFORM'\n] as const\nexport type VariableScope = (typeof VARIABLE_SCOPES)[number]\n\nexport const CODE_SYNTAX_PLATFORMS = ['WEB', 'ANDROID', 'iOS'] as const\nexport type CodeSyntaxPlatform = (typeof CODE_SYNTAX_PLATFORMS)[number]\n\n/**\n * The CSS unit a numeric token is written in. Lengths (`px`, `rem`) stay in canvas pixels in\n * the document and convert only when written as CSS; the other units store the number as written.\n */\nexport const TOKEN_UNITS = ['none', 'px', 'rem', '%', 'ms', 's', 'deg'] as const\nexport type TokenUnit = (typeof TOKEN_UNITS)[number]\n\n/**\n * CSS written in place of a number mode's value, such as `clamp(1rem, 4vw, 1.5rem)`. While the\n * mode holds a plain number, `resolved` records it, so a number later edited elsewhere, Figma\n * included, shows the CSS no longer describes it.\n */\nexport interface TokenExpression {\n css: string\n resolved?: number\n}\n\nexport interface Variable {\n id: string\n name: string\n type: VariableType\n collectionId: string\n valuesByMode: Record<string, VariableValue>\n description: string\n hiddenFromPublishing: boolean\n /** Absent means every scope. */\n scopes?: VariableScope[]\n /**\n * Per-platform code snippets, as Figma's Dev Mode shows them. A `WEB` snippet of `--x` or\n * `var(--x)` names the token's CSS custom property; otherwise the name is derived.\n */\n codeSyntax?: Partial<Record<CodeSyntaxPlatform, string>>\n /** FLOAT only. Absent means inferred when written as CSS. */\n unit?: TokenUnit\n /** Raw CSS by mode id, for values a number cannot express (`clamp()`, `calc()`). */\n expressions?: Record<string, TokenExpression>\n pluginData?: PluginDataEntry[]\n /** Published library key (from NodeChange.key). Used for assetRef resolution in colorVar. */\n key?: string\n /** Published library version (from NodeChange.version). Used for assetRef resolution in colorVar. */\n version?: string\n}\n\n/** Scalar numeric node fields accepted by numeric property controls; some may also be null. */\nexport type NumericNodeProperty = {\n [K in keyof SceneNode]-?: SceneNode[K] extends number | null\n ? number extends SceneNode[K]\n ? K\n : never\n : never\n}[keyof SceneNode]\n\nexport interface VariableCollectionMode {\n modeId: string\n name: string\n /**\n * The library mode this one came from, for a mode of a collection copied from a library. A\n * library that renames its mode renames this one with it, so the layers and the document set\n * to it keep following the library.\n */\n libraryModeId?: string\n /**\n * Where the mode applies in CSS: a selector (`[data-theme=\"dark\"]`, `.compact`) or an\n * at-rule prelude (`@media (max-width: 640px)`). Absent means the default for its axis.\n */\n condition?: string\n /** Where Figma lists the mode, as the file saved it; Figma orders a collection's modes by it. */\n sortPosition?: string\n}\n\nexport interface VariableCollection {\n id: string\n name: string\n /** The default mode comes first, as in Figma. */\n modes: VariableCollectionMode[]\n defaultModeId: string\n variableIds: string[]\n /**\n * The attribute that switches a mode with no condition of its own, `data-theme` for\n * `[data-theme=\"dark\"]`. Absent means one named after the collection.\n */\n modeAttribute?: string\n pluginData?: PluginDataEntry[]\n /**\n * Published library key, for a collection the file copies from a library. Such a collection\n * belongs to the library: Figma lists it with the library's, not the file's own.\n */\n key?: string\n /** Published library version, which references by key carry with it. */\n version?: string\n}\n\n/** Whether a collection is a library's copy, which takes no variables or modes of the file's. */\nexport function isLibraryCollection(collection: Pick<VariableCollection, 'key'>): boolean {\n return !!collection.key\n}\n\n/** An HTML attribute name a stylesheet can select on unescaped: `data-theme`, `theme`. */\nexport const MODE_ATTRIBUTE_PATTERN = /^[A-Za-z_][\\w-]*$/\n\nexport function isModeAttributeName(name: string): boolean {\n return name.length <= 100 && MODE_ATTRIBUTE_PATTERN.test(name)\n}\n"],"mappings":";;AA6bA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AA+lBA,MAAa,6BAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAmCA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,MAAa,wBAAwB;CAAC;CAAO;CAAW;AAAK;;;;;AAO7D,MAAa,cAAc;CAAC;CAAQ;CAAM;CAAO;CAAK;CAAM;CAAK;AAAK;;AAyFtE,SAAgB,oBAAoB,YAAsD;CACxF,OAAO,CAAC,CAAC,WAAW;AACtB;;AAGA,MAAa,yBAAyB;AAEtC,SAAgB,oBAAoB,MAAuB;CACzD,OAAO,KAAK,UAAU,OAAO,uBAAuB,KAAK,IAAI;AAC/D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-pencil/scene-graph",
|
|
3
|
-
"version": "0.17.0-beta.
|
|
3
|
+
"version": "0.17.0-beta.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"funding": "https://ko-fi.com/dannote",
|
|
6
6
|
"files": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@noble/hashes": "^2.4.0",
|
|
15
|
-
"@open-pencil/std": "^0.17.0-beta.
|
|
15
|
+
"@open-pencil/std": "^0.17.0-beta.7",
|
|
16
16
|
"culori": "^4.0.2",
|
|
17
17
|
"es-toolkit": "^1.52.0",
|
|
18
18
|
"image-size": "^2.0.4",
|
package/src/copy.ts
CHANGED
|
@@ -36,6 +36,7 @@ export function copyFill<T extends Fill>(f: T): T {
|
|
|
36
36
|
if (f.gradientStops) copy.gradientStops = f.gradientStops.map(copyGradientStop)
|
|
37
37
|
if (f.gradientTransform) copy.gradientTransform = { ...f.gradientTransform }
|
|
38
38
|
if (f.imageTransform) copy.imageTransform = { ...f.imageTransform }
|
|
39
|
+
if (f.filters) copy.filters = { ...f.filters }
|
|
39
40
|
if (f.patternSpacing) copy.patternSpacing = { ...f.patternSpacing }
|
|
40
41
|
if (f.noiseSize) copy.noiseSize = { ...f.noiseSize }
|
|
41
42
|
return copy
|
package/src/types.ts
CHANGED
|
@@ -186,6 +186,17 @@ export interface GradientStop {
|
|
|
186
186
|
|
|
187
187
|
export type GradientTransform = Matrix
|
|
188
188
|
|
|
189
|
+
/** Figma's adjustments of an image paint, each from -1 to 1; 0 leaves the image as it is. */
|
|
190
|
+
export interface ImageFilters {
|
|
191
|
+
exposure?: number
|
|
192
|
+
contrast?: number
|
|
193
|
+
saturation?: number
|
|
194
|
+
temperature?: number
|
|
195
|
+
tint?: number
|
|
196
|
+
highlights?: number
|
|
197
|
+
shadows?: number
|
|
198
|
+
}
|
|
199
|
+
|
|
189
200
|
export interface Fill {
|
|
190
201
|
type: FillType
|
|
191
202
|
color: Color
|
|
@@ -203,6 +214,8 @@ export interface Fill {
|
|
|
203
214
|
imageTransform?: GradientTransform
|
|
204
215
|
/** Clockwise turn of a Fill, Fit or Tile image, in multiples of 90°; a crop holds its own. */
|
|
205
216
|
imageRotation?: number
|
|
217
|
+
/** An image's adjustments, kept and saved; the canvas does not draw them. */
|
|
218
|
+
filters?: ImageFilters
|
|
206
219
|
sourceNodeId?: string
|
|
207
220
|
scale?: number
|
|
208
221
|
spacing?: number
|