@open-pencil/scene-graph 0.17.0-beta.4 → 0.17.0-beta.5
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/arrays.d.ts +17 -0
- package/dist/arrays.d.ts.map +1 -0
- package/dist/arrays.js +38 -0
- package/dist/arrays.js.map +1 -0
- package/dist/buffered-events.js +1 -1
- package/dist/buffered-events.js.map +1 -1
- package/dist/clipping.d.ts +7 -1
- package/dist/clipping.d.ts.map +1 -1
- package/dist/clipping.js +23 -19
- package/dist/clipping.js.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -2
- package/dist/components/properties.d.ts +1 -3
- package/dist/components/properties.d.ts.map +1 -1
- package/dist/components/properties.js +2 -9
- package/dist/components/properties.js.map +1 -1
- package/dist/corners.d.ts +22 -0
- package/dist/corners.d.ts.map +1 -0
- package/dist/corners.js +52 -0
- package/dist/corners.js.map +1 -0
- package/dist/css/grid.d.ts +4 -1
- package/dist/css/grid.d.ts.map +1 -1
- package/dist/css/grid.js +16 -7
- package/dist/css/grid.js.map +1 -1
- package/dist/css/index.d.ts +2 -2
- package/dist/css/index.js +2 -2
- package/dist/css/values.d.ts +6 -1
- package/dist/css/values.d.ts.map +1 -1
- package/dist/font-style.d.ts +2 -1
- package/dist/font-style.d.ts.map +1 -1
- package/dist/font-style.js +31 -6
- package/dist/font-style.js.map +1 -1
- package/dist/geometry.d.ts +68 -3
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +155 -5
- package/dist/geometry.js.map +1 -1
- package/dist/gradient.d.ts +9 -2
- package/dist/gradient.d.ts.map +1 -1
- package/dist/gradient.js +29 -1
- package/dist/gradient.js.map +1 -1
- package/dist/graph.d.ts +4 -0
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +30 -4
- package/dist/graph.js.map +1 -1
- package/dist/group-bounds.d.ts.map +1 -1
- package/dist/group-bounds.js +4 -3
- package/dist/group-bounds.js.map +1 -1
- package/dist/guides.d.ts +11 -2
- package/dist/guides.d.ts.map +1 -1
- package/dist/guides.js +30 -1
- package/dist/guides.js.map +1 -1
- package/dist/hit-test.d.ts.map +1 -1
- package/dist/hit-test.js +57 -5
- package/dist/hit-test.js.map +1 -1
- package/dist/icons/fit.d.ts +17 -0
- package/dist/icons/fit.d.ts.map +1 -0
- package/dist/icons/fit.js +21 -0
- package/dist/icons/fit.js.map +1 -0
- package/dist/icons/glyph.d.ts.map +1 -1
- package/dist/icons/glyph.js +5 -4
- package/dist/icons/glyph.js.map +1 -1
- package/dist/icons/index.d.ts +2 -1
- package/dist/icons/index.js +2 -1
- package/dist/images.d.ts +14 -4
- package/dist/images.d.ts.map +1 -1
- package/dist/images.js +45 -5
- package/dist/images.js.map +1 -1
- package/dist/instances/assignments.js +39 -6
- package/dist/instances/assignments.js.map +1 -1
- package/dist/instances/index.d.ts.map +1 -1
- package/dist/instances/index.js +39 -2
- package/dist/instances/index.js.map +1 -1
- package/dist/instances/kept-overrides.js +2 -2
- package/dist/instances/kept-overrides.js.map +1 -1
- package/dist/instances/matching.js +68 -0
- package/dist/instances/matching.js.map +1 -0
- package/dist/instances/overrides.d.ts +4 -1
- package/dist/instances/overrides.d.ts.map +1 -1
- package/dist/instances/overrides.js +13 -1
- package/dist/instances/overrides.js.map +1 -1
- package/dist/instances/protection.js +67 -0
- package/dist/instances/protection.js.map +1 -0
- package/dist/instances/swap.js +7 -5
- package/dist/instances/swap.js.map +1 -1
- package/dist/instances/sync.js +10 -116
- package/dist/instances/sync.js.map +1 -1
- package/dist/layout/guides.d.ts +17 -1
- package/dist/layout/guides.d.ts.map +1 -1
- package/dist/layout/guides.js +31 -11
- package/dist/layout/guides.js.map +1 -1
- package/dist/layout/index.d.ts +4 -2
- package/dist/layout/index.js +4 -2
- package/dist/layout/limits.d.ts +40 -0
- package/dist/layout/limits.d.ts.map +1 -0
- package/dist/layout/limits.js +54 -0
- package/dist/layout/limits.js.map +1 -0
- package/dist/layout/sizing.d.ts.map +1 -1
- package/dist/layout/sizing.js +0 -1
- package/dist/layout/sizing.js.map +1 -1
- package/dist/layout/spacing.d.ts +10 -0
- package/dist/layout/spacing.d.ts.map +1 -0
- package/dist/layout/spacing.js +12 -0
- package/dist/layout/spacing.js.map +1 -0
- package/dist/masks.d.ts +28 -0
- package/dist/masks.d.ts.map +1 -0
- package/dist/masks.js +53 -0
- package/dist/masks.js.map +1 -0
- package/dist/matrix.d.ts +2 -1
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +14 -1
- package/dist/matrix.js.map +1 -1
- package/dist/node-defaults.d.ts +9 -1
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +16 -1
- package/dist/node-defaults.js.map +1 -1
- package/dist/outline/flatten.d.ts.map +1 -1
- package/dist/outline/flatten.js +24 -17
- package/dist/outline/flatten.js.map +1 -1
- package/dist/outline/hit.d.ts +2 -8
- package/dist/outline/hit.d.ts.map +1 -1
- package/dist/outline/hit.js +16 -25
- package/dist/outline/hit.js.map +1 -1
- package/dist/outline/index.d.ts +3 -3
- package/dist/outline/index.js +3 -3
- package/dist/outline/shapes.d.ts +3 -1
- package/dist/outline/shapes.d.ts.map +1 -1
- package/dist/outline/shapes.js +18 -39
- package/dist/outline/shapes.js.map +1 -1
- package/dist/paints/index.d.ts +3 -1
- package/dist/paints/index.js +3 -1
- package/dist/paints/pattern.d.ts +13 -0
- package/dist/paints/pattern.d.ts.map +1 -0
- package/dist/paints/pattern.js +47 -0
- package/dist/paints/pattern.js.map +1 -0
- package/dist/paints/shows.d.ts +11 -0
- package/dist/paints/shows.d.ts.map +1 -0
- package/dist/paints/shows.js +16 -0
- package/dist/paints/shows.js.map +1 -0
- package/dist/paths/arc.d.ts +32 -0
- package/dist/paths/arc.d.ts.map +1 -0
- package/dist/paths/arc.js +49 -0
- package/dist/paths/arc.js.map +1 -0
- package/dist/paths/index.d.ts +5 -0
- package/dist/paths/index.js +5 -0
- package/dist/paths/network.d.ts +43 -0
- package/dist/paths/network.d.ts.map +1 -0
- package/dist/paths/network.js +249 -0
- package/dist/paths/network.js.map +1 -0
- package/dist/paths/sink.d.ts +20 -0
- package/dist/paths/sink.d.ts.map +1 -0
- package/dist/paths/sink.js +32 -0
- package/dist/paths/sink.js.map +1 -0
- package/dist/paths/smooth-corners.d.ts +25 -0
- package/dist/paths/smooth-corners.d.ts.map +1 -0
- package/dist/paths/smooth-corners.js +196 -0
- package/dist/paths/smooth-corners.js.map +1 -0
- package/dist/plugin-data/fields.d.ts +4 -0
- package/dist/plugin-data/fields.d.ts.map +1 -1
- package/dist/plugin-data/fields.js +2 -0
- package/dist/plugin-data/fields.js.map +1 -1
- package/dist/polygon.d.ts +1 -3
- package/dist/polygon.d.ts.map +1 -1
- package/dist/polygon.js +1 -16
- package/dist/polygon.js.map +1 -1
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +5 -5
- package/dist/resize.js.map +1 -1
- package/dist/scaling/node.d.ts.map +1 -1
- package/dist/scaling/node.js +25 -3
- package/dist/scaling/node.js.map +1 -1
- package/dist/text/auto-resize.d.ts +15 -0
- package/dist/text/auto-resize.d.ts.map +1 -0
- package/dist/text/auto-resize.js +23 -0
- package/dist/text/auto-resize.js.map +1 -0
- package/dist/text/index.d.ts +4 -3
- package/dist/text/index.js +4 -3
- package/dist/text/lengths.d.ts +6 -1
- package/dist/text/lengths.d.ts.map +1 -1
- package/dist/text/lengths.js +10 -1
- package/dist/text/lengths.js.map +1 -1
- package/dist/text/overflow.d.ts +14 -5
- package/dist/text/overflow.d.ts.map +1 -1
- package/dist/text/overflow.js +24 -6
- package/dist/text/overflow.js.map +1 -1
- package/dist/text/path.js +10 -0
- package/dist/text/path.js.map +1 -0
- package/dist/text/picture.js +5 -5
- package/dist/text/picture.js.map +1 -1
- package/dist/transfer/dependencies.d.ts.map +1 -1
- package/dist/transfer/dependencies.js +3 -2
- package/dist/transfer/dependencies.js.map +1 -1
- package/dist/transfer/nodes.js +2 -1
- package/dist/transfer/nodes.js.map +1 -1
- package/dist/types.d.ts +21 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/variables/index.d.ts +4 -3
- package/dist/variables/index.d.ts.map +1 -1
- package/dist/variables/index.js +4 -3
- package/dist/variables/index.js.map +1 -1
- package/dist/variables/lookup.d.ts +20 -0
- package/dist/variables/lookup.d.ts.map +1 -0
- package/dist/variables/lookup.js +34 -0
- package/dist/variables/lookup.js.map +1 -0
- package/dist/variables/paints.d.ts +35 -4
- package/dist/variables/paints.d.ts.map +1 -1
- package/dist/variables/paints.js +67 -16
- package/dist/variables/paints.js.map +1 -1
- package/dist/variables/resolution.d.ts +3 -1
- package/dist/variables/resolution.d.ts.map +1 -1
- package/dist/variables/resolution.js +8 -3
- package/dist/variables/resolution.js.map +1 -1
- package/dist/variables/subtree.js +1 -1
- package/dist/variables/subtree.js.map +1 -1
- package/dist/vector-network.d.ts.map +1 -1
- package/dist/vector-network.js +12 -76
- package/dist/vector-network.js.map +1 -1
- package/package.json +25 -1
- package/src/arrays.ts +37 -0
- package/src/buffered-events.ts +2 -1
- package/src/clipping.ts +11 -8
- package/src/components/properties.ts +1 -13
- package/src/corners.ts +93 -0
- package/src/css/grid.ts +21 -7
- package/src/css/index.ts +1 -1
- package/src/font-style.ts +38 -4
- package/src/geometry.ts +219 -6
- package/src/gradient.ts +23 -1
- package/src/graph.ts +22 -4
- package/src/group-bounds.ts +7 -3
- package/src/guides.ts +26 -1
- package/src/hit-test.ts +68 -10
- package/src/icons/fit.ts +24 -0
- package/src/icons/glyph.ts +5 -4
- package/src/icons/index.ts +1 -0
- package/src/images.ts +67 -7
- package/src/instances/assignments.ts +65 -7
- package/src/instances/index.ts +53 -4
- package/src/instances/kept-overrides.ts +2 -5
- package/src/instances/matching.ts +101 -0
- package/src/instances/overrides.ts +18 -0
- package/src/instances/protection.ts +103 -0
- package/src/instances/swap.ts +11 -9
- package/src/instances/sync.ts +11 -184
- package/src/layout/guides.ts +42 -9
- package/src/layout/index.ts +2 -0
- package/src/layout/limits.ts +64 -0
- package/src/layout/sizing.ts +0 -2
- package/src/layout/spacing.ts +11 -0
- package/src/masks.ts +51 -0
- package/src/matrix.ts +15 -2
- package/src/node-defaults.ts +23 -3
- package/src/outline/flatten.ts +30 -18
- package/src/outline/hit.ts +16 -33
- package/src/outline/index.ts +2 -2
- package/src/outline/shapes.ts +19 -36
- package/src/paints/index.ts +2 -0
- package/src/paints/pattern.ts +45 -0
- package/src/paints/shows.ts +13 -0
- package/src/paths/arc.ts +59 -0
- package/src/paths/index.ts +4 -0
- package/src/paths/network.ts +334 -0
- package/src/paths/sink.ts +50 -0
- package/src/paths/smooth-corners.ts +356 -0
- package/src/plugin-data/fields.ts +2 -0
- package/src/polygon.ts +0 -17
- package/src/resize.ts +6 -7
- package/src/scaling/node.ts +29 -3
- package/src/text/auto-resize.ts +25 -0
- package/src/text/index.ts +1 -0
- package/src/text/lengths.ts +11 -0
- package/src/text/overflow.ts +32 -6
- package/src/text/path.ts +13 -0
- package/src/text/picture.ts +5 -5
- package/src/transfer/dependencies.ts +3 -2
- package/src/transfer/nodes.ts +2 -1
- package/src/types.ts +25 -8
- package/src/variables/index.ts +1 -0
- package/src/variables/lookup.ts +31 -0
- package/src/variables/paints.ts +101 -20
- package/src/variables/resolution.ts +14 -2
- package/src/variables/subtree.ts +1 -1
- package/src/vector-network.ts +17 -138
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guides.js","names":[],"sources":["../../src/layout/guides.ts"],"sourcesContent":["import type { LayoutGrid, SceneNode } from '../types'\n\nexport interface LayoutGuideLine {\n axis: 'x' | 'y'\n position: number\n}\n\
|
|
1
|
+
{"version":3,"file":"guides.js","names":[],"sources":["../../src/layout/guides.ts"],"sourcesContent":["import type { Color } from '../primitives'\nimport type { LayoutGrid, SceneNode } from '../types'\n\nexport interface LayoutGuideLine {\n axis: 'x' | 'y'\n position: number\n}\n\n/** The most lines one guide draws or snaps to on an axis. */\nexport const MAX_LAYOUT_GUIDE_LINES = 10_000\n\n/** Figma's Auto count, as its archive stores it: as many sections as fit. */\nexport const AUTO_LAYOUT_GRID_COUNT = 2_147_483_647\n\n/** Whether a guide's count is Auto: the archive's value, or the plugin API's `Infinity` or `null`. */\nexport function isAutoGridCount(count: number | null | undefined): boolean {\n return count === null || count === Infinity || (count ?? 0) >= AUTO_LAYOUT_GRID_COUNT\n}\n\n/**\n * A guide's count, set in Figma's plugin shape (`count`) or read from a file (`numSections`); an\n * edit's `count` wins over the count the file had. Auto is {@link AUTO_LAYOUT_GRID_COUNT}.\n */\nexport function layoutGridCount(grid: LayoutGrid): number {\n const count = grid.count === undefined ? grid.numSections : grid.count\n return isAutoGridCount(count) ? AUTO_LAYOUT_GRID_COUNT : (count ?? 1)\n}\n\n/** Figma's color for a new guide: red at 10%. */\nexport const DEFAULT_LAYOUT_GRID_COLOR: Readonly<Color> = Object.freeze({\n r: 1,\n g: 0,\n b: 0,\n a: 0.1\n})\n\n/** A guide's pattern in Figma's plugin names, from either shape: the archive's `STRIPES` along an `axis`. */\nexport function layoutGridPattern(\n grid: Pick<LayoutGrid, 'pattern' | 'axis'>\n): 'COLUMNS' | 'ROWS' | 'GRID' {\n if (grid.pattern === 'GRID' || grid.pattern === 'ROWS' || grid.pattern === 'COLUMNS') {\n return grid.pattern\n }\n return grid.axis === 'Y' ? 'ROWS' : 'COLUMNS'\n}\n\n/**\n * A guide's alignment, from either shape. One set without any stretches, as the plugin API and\n * export have read it; a file's guide always has one, as Figma drops a guide without it.\n */\nexport function layoutGridAlignment(\n grid: Pick<LayoutGrid, 'alignment' | 'type'>\n): 'MIN' | 'CENTER' | 'MAX' | 'STRETCH' {\n return grid.alignment ?? grid.type ?? 'STRETCH'\n}\n\n/** Whether a file's guide record names an alignment; Figma drops one that does not (live). */\nexport function hasLayoutGridAlignment(\n grid: Partial<Pick<LayoutGrid, 'alignment' | 'type'>>\n): boolean {\n return grid.type !== undefined || grid.alignment !== undefined\n}\n\n/** A guide's color, Figma's new-guide red for one set without any. */\nexport function layoutGridColor(grid: Pick<LayoutGrid, 'color'>): Color {\n return { ...(grid.color ?? DEFAULT_LAYOUT_GRID_COLOR) }\n}\n\nconst pattern = layoutGridPattern\nconst alignment = layoutGridAlignment\n\n/**\n * How many sections a guide draws. Auto fits as many fixed sections as the frame holds, counting\n * the offset once from the aligned edge, as Figma desktop 126 draws them.\n */\nfunction sectionCount(nodeSize: number, grid: LayoutGrid): number {\n const value = layoutGridCount(grid)\n if (value === AUTO_LAYOUT_GRID_COUNT) {\n const size = grid.sectionSize ?? 0\n if (alignment(grid) === 'STRETCH' || size <= 0) return 0\n const gutter = grid.gutterSize ?? 0\n const offset = alignment(grid) === 'CENTER' ? 0 : (grid.offset ?? 0)\n return Math.min(\n MAX_LAYOUT_GUIDE_LINES,\n Math.max(0, Math.floor((nodeSize - offset + gutter) / (size + gutter)))\n )\n }\n if (!Number.isFinite(value)) return 0\n return Math.min(MAX_LAYOUT_GUIDE_LINES, Math.max(0, Math.floor(value)))\n}\n\nfunction sectionSize(nodeSize: number, grid: LayoutGrid, count: number): number {\n const fixed = grid.sectionSize ?? 0\n if (alignment(grid) !== 'STRETCH') return fixed\n const gutter = grid.gutterSize ?? 0\n const offset = grid.offset ?? 0\n return (nodeSize - offset * 2 - Math.max(0, count - 1) * gutter) / count\n}\n\nfunction start(nodeSize: number, grid: LayoutGrid, size: number, count: number): number {\n const gutter = grid.gutterSize ?? 0\n const offset = grid.offset ?? 0\n const span = count * size + Math.max(0, count - 1) * gutter\n if (alignment(grid) === 'CENTER') return (nodeSize - span) / 2 + offset\n if (alignment(grid) === 'MAX') return nodeSize - span - offset\n return offset\n}\n\nexport interface LayoutGuideSection {\n axis: 'x' | 'y'\n start: number\n end: number\n}\n\nexport function layoutGuideSections(\n node: Pick<SceneNode, 'width' | 'height'>,\n grid: LayoutGrid\n): LayoutGuideSection[] {\n if (grid.visible === false || pattern(grid) === 'GRID') return []\n const axis = pattern(grid) === 'ROWS' ? 'y' : 'x'\n const nodeSize = axis === 'x' ? node.width : node.height\n const count = sectionCount(nodeSize, grid)\n const size = sectionSize(nodeSize, grid, count)\n if (count <= 0 || size <= 0) return []\n const first = start(nodeSize, grid, size, count)\n const step = size + (grid.gutterSize ?? 0)\n return Array.from({ length: count }, (_, index) => {\n const sectionStart = first + index * step\n return { axis, start: sectionStart, end: sectionStart + size }\n })\n}\n\nexport function layoutGuideLines(node: Pick<SceneNode, 'width' | 'height'>, grid: LayoutGrid) {\n if (grid.visible === false) return []\n const gridPattern = pattern(grid)\n const lines: LayoutGuideLine[] = []\n if (gridPattern === 'GRID') {\n const size = grid.sectionSize ?? 0\n if (size <= 0) return lines\n for (\n let index = 0, x = grid.offset ?? 0;\n x <= node.width && index < MAX_LAYOUT_GUIDE_LINES;\n index++, x += size\n ) {\n lines.push({ axis: 'x', position: x })\n }\n for (\n let index = 0, y = grid.offset ?? 0;\n y <= node.height && index < MAX_LAYOUT_GUIDE_LINES;\n index++, y += size\n ) {\n lines.push({ axis: 'y', position: y })\n }\n return lines\n }\n\n const sections = layoutGuideSections(node, grid)\n for (const section of sections) {\n lines.push(\n { axis: section.axis, position: section.start },\n { axis: section.axis, position: section.end }\n )\n }\n return lines\n}\n"],"mappings":";;AASA,MAAa,yBAAyB;;AAGtC,MAAa,yBAAyB;;AAGtC,SAAgB,gBAAgB,OAA2C;CACzE,OAAO,UAAU,QAAQ,UAAU,aAAa,SAAS,MAAA;AAC3D;;;;;AAMA,SAAgB,gBAAgB,MAA0B;CACxD,MAAM,QAAQ,KAAK,UAAU,KAAA,IAAY,KAAK,cAAc,KAAK;CACjE,OAAO,gBAAgB,KAAK,IAAI,yBAA0B,SAAS;AACrE;;AAGA,MAAa,4BAA6C,OAAO,OAAO;CACtE,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL,CAAC;;AAGD,SAAgB,kBACd,MAC6B;CAC7B,IAAI,KAAK,YAAY,UAAU,KAAK,YAAY,UAAU,KAAK,YAAY,WAC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GAAE,MAAM;GAAK,UAAU;EAAE,CAAC;EAEvC,OAAO;CACT;CAEA,MAAM,WAAW,oBAAoB,MAAM,IAAI;CAC/C,KAAK,MAAM,WAAW,UACpB,MAAM,KACJ;EAAE,MAAM,QAAQ;EAAM,UAAU,QAAQ;CAAM,GAC9C;EAAE,MAAM,QAAQ;EAAM,UAAU,QAAQ;CAAI,CAC9C;CAEF,OAAO;AACT"}
|
package/dist/layout/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AutoLayoutDirection, paddingFromShorthand, parseAutoLayoutDirection, parseCounterAxisAlign, parseLayoutAlignSelf, parsePrimaryAxisAlign } from "./keywords.js";
|
|
2
2
|
import { aspectRatioLockEditable, enforcedAspectRatio, lockedAspectRatioTarget, recapturedAspectRatio, sizeKeepingAspectRatio } from "./aspect-ratio.js";
|
|
3
|
-
import { AUTO_LAYOUT_GRID_COUNT, LayoutGuideLine, LayoutGuideSection, isAutoGridCount, layoutGridCount, layoutGuideLines, layoutGuideSections } from "./guides.js";
|
|
3
|
+
import { AUTO_LAYOUT_GRID_COUNT, DEFAULT_LAYOUT_GRID_COLOR, LayoutGuideLine, LayoutGuideSection, MAX_LAYOUT_GUIDE_LINES, hasLayoutGridAlignment, isAutoGridCount, layoutGridAlignment, layoutGridColor, layoutGridCount, layoutGridPattern, layoutGuideLines, layoutGuideSections } from "./guides.js";
|
|
4
|
+
import { MAX_FONT_SIZE, MAX_GRID_LINE, MAX_GRID_SPAN, MAX_GRID_TRACKS, MAX_LAYOUT_ANGLE, MAX_LAYOUT_FACTOR, MAX_LAYOUT_LENGTH, MAX_LAYOUT_SPACING, MAX_TEXT_LENGTH, clampFontSize, clampGridTracks, clampLayoutLength, clampLayoutPosition } from "./limits.js";
|
|
4
5
|
import { LayoutSizingAxis, autoLayoutSizingFields, fillSizingFields, layoutSizing, layoutSizingError, layoutSizingInParent, layoutSizingOptions, layoutSizingUpdates, textAutoResizeFor } from "./sizing.js";
|
|
5
|
-
|
|
6
|
+
import { counterAxisSpacingOf } from "./spacing.js";
|
|
7
|
+
export { AUTO_LAYOUT_GRID_COUNT, AutoLayoutDirection, DEFAULT_LAYOUT_GRID_COLOR, LayoutGuideLine, LayoutGuideSection, LayoutSizingAxis, MAX_FONT_SIZE, MAX_GRID_LINE, MAX_GRID_SPAN, MAX_GRID_TRACKS, MAX_LAYOUT_ANGLE, MAX_LAYOUT_FACTOR, MAX_LAYOUT_GUIDE_LINES, MAX_LAYOUT_LENGTH, MAX_LAYOUT_SPACING, MAX_TEXT_LENGTH, aspectRatioLockEditable, autoLayoutSizingFields, clampFontSize, clampGridTracks, clampLayoutLength, clampLayoutPosition, counterAxisSpacingOf, enforcedAspectRatio, fillSizingFields, hasLayoutGridAlignment, isAutoGridCount, layoutGridAlignment, layoutGridColor, layoutGridCount, layoutGridPattern, layoutGuideLines, layoutGuideSections, layoutSizing, layoutSizingError, layoutSizingInParent, layoutSizingOptions, layoutSizingUpdates, lockedAspectRatioTarget, paddingFromShorthand, parseAutoLayoutDirection, parseCounterAxisAlign, parseLayoutAlignSelf, parsePrimaryAxisAlign, recapturedAspectRatio, sizeKeepingAspectRatio, textAutoResizeFor };
|
package/dist/layout/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { autoLayoutSizingFields, fillSizingFields, layoutSizing, layoutSizingError, layoutSizingInParent, layoutSizingOptions, layoutSizingUpdates, textAutoResizeFor } from "./sizing.js";
|
|
2
2
|
import { aspectRatioLockEditable, enforcedAspectRatio, lockedAspectRatioTarget, recapturedAspectRatio, sizeKeepingAspectRatio } from "./aspect-ratio.js";
|
|
3
|
+
import { MAX_FONT_SIZE, MAX_GRID_LINE, MAX_GRID_SPAN, MAX_GRID_TRACKS, MAX_LAYOUT_ANGLE, MAX_LAYOUT_FACTOR, MAX_LAYOUT_LENGTH, MAX_LAYOUT_SPACING, MAX_TEXT_LENGTH, clampFontSize, clampGridTracks, clampLayoutLength, clampLayoutPosition } from "./limits.js";
|
|
3
4
|
import { paddingFromShorthand, parseAutoLayoutDirection, parseCounterAxisAlign, parseLayoutAlignSelf, parsePrimaryAxisAlign } from "./keywords.js";
|
|
4
|
-
import { AUTO_LAYOUT_GRID_COUNT, isAutoGridCount, layoutGridCount, layoutGuideLines, layoutGuideSections } from "./guides.js";
|
|
5
|
-
|
|
5
|
+
import { AUTO_LAYOUT_GRID_COUNT, DEFAULT_LAYOUT_GRID_COLOR, MAX_LAYOUT_GUIDE_LINES, hasLayoutGridAlignment, isAutoGridCount, layoutGridAlignment, layoutGridColor, layoutGridCount, layoutGridPattern, layoutGuideLines, layoutGuideSections } from "./guides.js";
|
|
6
|
+
import { counterAxisSpacingOf } from "./spacing.js";
|
|
7
|
+
export { AUTO_LAYOUT_GRID_COUNT, DEFAULT_LAYOUT_GRID_COLOR, MAX_FONT_SIZE, MAX_GRID_LINE, MAX_GRID_SPAN, MAX_GRID_TRACKS, MAX_LAYOUT_ANGLE, MAX_LAYOUT_FACTOR, MAX_LAYOUT_GUIDE_LINES, MAX_LAYOUT_LENGTH, MAX_LAYOUT_SPACING, MAX_TEXT_LENGTH, aspectRatioLockEditable, autoLayoutSizingFields, clampFontSize, clampGridTracks, clampLayoutLength, clampLayoutPosition, counterAxisSpacingOf, enforcedAspectRatio, fillSizingFields, hasLayoutGridAlignment, isAutoGridCount, layoutGridAlignment, layoutGridColor, layoutGridCount, layoutGridPattern, layoutGuideLines, layoutGuideSections, layoutSizing, layoutSizingError, layoutSizingInParent, layoutSizingOptions, layoutSizingUpdates, lockedAspectRatioTarget, paddingFromShorthand, parseAutoLayoutDirection, parseCounterAxisAlign, parseLayoutAlignSelf, parsePrimaryAxisAlign, recapturedAspectRatio, sizeKeepingAspectRatio, textAutoResizeFor };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GridTrack } from "../types.js";
|
|
2
|
+
//#region src/layout/limits.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Bounds for the numbers layout computes with and for the values it writes back.
|
|
5
|
+
*
|
|
6
|
+
* Layout tolerates a span of zero or a track list a tool wrote by mistake, but not every
|
|
7
|
+
* consumer does: a document carrying absurd geometry cannot be rasterized, a grid template
|
|
8
|
+
* naming a billion tracks allocates one entry per track, and a text layer set at 1e9 px makes
|
|
9
|
+
* font shaping build a run of glyphs no memory holds. Every path that writes a layout value
|
|
10
|
+
* clamps to these bounds, and tool schemas reject values outside them.
|
|
11
|
+
*/
|
|
12
|
+
/** The largest size or position, in pixels, that a layout value may carry. */
|
|
13
|
+
declare const MAX_LAYOUT_LENGTH = 1000000;
|
|
14
|
+
/** The largest gap, padding, or stroke a layout value may carry, in pixels. */
|
|
15
|
+
declare const MAX_LAYOUT_SPACING = 100000;
|
|
16
|
+
/** The largest number of tracks one grid template may name. */
|
|
17
|
+
declare const MAX_GRID_TRACKS = 1000;
|
|
18
|
+
/** The last grid line a placement may name; line 0 leaves placement to auto-flow. */
|
|
19
|
+
declare const MAX_GRID_LINE = 1000;
|
|
20
|
+
/** The most tracks one grid item may span. */
|
|
21
|
+
declare const MAX_GRID_SPAN = 1000;
|
|
22
|
+
/** The largest rotation, in degrees, a layout or transform may carry. */
|
|
23
|
+
declare const MAX_LAYOUT_ANGLE = 360000;
|
|
24
|
+
/** The largest font size, in pixels, text may be set in. */
|
|
25
|
+
declare const MAX_FONT_SIZE = 10000;
|
|
26
|
+
/** The largest ratio a layout factor, such as a flex grow share, may carry. */
|
|
27
|
+
declare const MAX_LAYOUT_FACTOR = 1000;
|
|
28
|
+
/** The largest line height or letter spacing, in pixels or percent, a text may carry. */
|
|
29
|
+
declare const MAX_TEXT_LENGTH = 10000;
|
|
30
|
+
/** A length that cannot be negative, such as a size, padding, gap, or radius. */
|
|
31
|
+
declare function clampLayoutLength(value: number, max?: number): number;
|
|
32
|
+
/** A coordinate that may be negative, such as a position. */
|
|
33
|
+
declare function clampLayoutPosition(value: number, max?: number): number;
|
|
34
|
+
/** A font size in pixels, at least one and at most `MAX_FONT_SIZE`; fractions are kept. */
|
|
35
|
+
declare function clampFontSize(value: number): number;
|
|
36
|
+
/** A grid template's tracks, with at most `MAX_GRID_TRACKS` of them and no negative sizes. */
|
|
37
|
+
declare function clampGridTracks(tracks: readonly GridTrack[]): GridTrack[];
|
|
38
|
+
//#endregion
|
|
39
|
+
export { MAX_FONT_SIZE, MAX_GRID_LINE, MAX_GRID_SPAN, MAX_GRID_TRACKS, MAX_LAYOUT_ANGLE, MAX_LAYOUT_FACTOR, MAX_LAYOUT_LENGTH, MAX_LAYOUT_SPACING, MAX_TEXT_LENGTH, clampFontSize, clampGridTracks, clampLayoutLength, clampLayoutPosition };
|
|
40
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","names":[],"sources":["../../src/layout/limits.ts"],"mappings":";;;;;;;;;;;;cAaa;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;iBAGG,kBAAkB,eAAe;;iBAMjC,oBAAoB,eAAe;;iBAMnC,cAAc;;iBAMd,gBAAgB,iBAAiB,cAAc"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//#region src/layout/limits.ts
|
|
2
|
+
/**
|
|
3
|
+
* Bounds for the numbers layout computes with and for the values it writes back.
|
|
4
|
+
*
|
|
5
|
+
* Layout tolerates a span of zero or a track list a tool wrote by mistake, but not every
|
|
6
|
+
* consumer does: a document carrying absurd geometry cannot be rasterized, a grid template
|
|
7
|
+
* naming a billion tracks allocates one entry per track, and a text layer set at 1e9 px makes
|
|
8
|
+
* font shaping build a run of glyphs no memory holds. Every path that writes a layout value
|
|
9
|
+
* clamps to these bounds, and tool schemas reject values outside them.
|
|
10
|
+
*/
|
|
11
|
+
/** The largest size or position, in pixels, that a layout value may carry. */
|
|
12
|
+
const MAX_LAYOUT_LENGTH = 1e6;
|
|
13
|
+
/** The largest gap, padding, or stroke a layout value may carry, in pixels. */
|
|
14
|
+
const MAX_LAYOUT_SPACING = 1e5;
|
|
15
|
+
/** The largest number of tracks one grid template may name. */
|
|
16
|
+
const MAX_GRID_TRACKS = 1e3;
|
|
17
|
+
/** The last grid line a placement may name; line 0 leaves placement to auto-flow. */
|
|
18
|
+
const MAX_GRID_LINE = 1e3;
|
|
19
|
+
/** The most tracks one grid item may span. */
|
|
20
|
+
const MAX_GRID_SPAN = 1e3;
|
|
21
|
+
/** The largest rotation, in degrees, a layout or transform may carry. */
|
|
22
|
+
const MAX_LAYOUT_ANGLE = 36e4;
|
|
23
|
+
/** The largest font size, in pixels, text may be set in. */
|
|
24
|
+
const MAX_FONT_SIZE = 1e4;
|
|
25
|
+
/** The largest ratio a layout factor, such as a flex grow share, may carry. */
|
|
26
|
+
const MAX_LAYOUT_FACTOR = 1e3;
|
|
27
|
+
/** The largest line height or letter spacing, in pixels or percent, a text may carry. */
|
|
28
|
+
const MAX_TEXT_LENGTH = 1e4;
|
|
29
|
+
/** A length that cannot be negative, such as a size, padding, gap, or radius. */
|
|
30
|
+
function clampLayoutLength(value, max = MAX_LAYOUT_LENGTH) {
|
|
31
|
+
if (!Number.isFinite(value)) return 0;
|
|
32
|
+
return Math.min(max, Math.max(0, value));
|
|
33
|
+
}
|
|
34
|
+
/** A coordinate that may be negative, such as a position. */
|
|
35
|
+
function clampLayoutPosition(value, max = MAX_LAYOUT_LENGTH) {
|
|
36
|
+
if (!Number.isFinite(value)) return 0;
|
|
37
|
+
return Math.min(max, Math.max(-max, value));
|
|
38
|
+
}
|
|
39
|
+
/** A font size in pixels, at least one and at most `MAX_FONT_SIZE`; fractions are kept. */
|
|
40
|
+
function clampFontSize(value) {
|
|
41
|
+
if (!Number.isFinite(value)) return 1;
|
|
42
|
+
return Math.min(MAX_FONT_SIZE, Math.max(1, value));
|
|
43
|
+
}
|
|
44
|
+
/** A grid template's tracks, with at most `MAX_GRID_TRACKS` of them and no negative sizes. */
|
|
45
|
+
function clampGridTracks(tracks) {
|
|
46
|
+
return tracks.slice(0, MAX_GRID_TRACKS).map((track) => ({
|
|
47
|
+
...track,
|
|
48
|
+
value: clampLayoutLength(track.value)
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { MAX_FONT_SIZE, MAX_GRID_LINE, MAX_GRID_SPAN, MAX_GRID_TRACKS, MAX_LAYOUT_ANGLE, MAX_LAYOUT_FACTOR, MAX_LAYOUT_LENGTH, MAX_LAYOUT_SPACING, MAX_TEXT_LENGTH, clampFontSize, clampGridTracks, clampLayoutLength, clampLayoutPosition };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","names":[],"sources":["../../src/layout/limits.ts"],"sourcesContent":["import type { GridTrack } from '../types'\n\n/**\n * Bounds for the numbers layout computes with and for the values it writes back.\n *\n * Layout tolerates a span of zero or a track list a tool wrote by mistake, but not every\n * consumer does: a document carrying absurd geometry cannot be rasterized, a grid template\n * naming a billion tracks allocates one entry per track, and a text layer set at 1e9 px makes\n * font shaping build a run of glyphs no memory holds. Every path that writes a layout value\n * clamps to these bounds, and tool schemas reject values outside them.\n */\n\n/** The largest size or position, in pixels, that a layout value may carry. */\nexport const MAX_LAYOUT_LENGTH = 1_000_000\n\n/** The largest gap, padding, or stroke a layout value may carry, in pixels. */\nexport const MAX_LAYOUT_SPACING = 100_000\n\n/** The largest number of tracks one grid template may name. */\nexport const MAX_GRID_TRACKS = 1_000\n\n/** The last grid line a placement may name; line 0 leaves placement to auto-flow. */\nexport const MAX_GRID_LINE = 1_000\n\n/** The most tracks one grid item may span. */\nexport const MAX_GRID_SPAN = 1_000\n\n/** The largest rotation, in degrees, a layout or transform may carry. */\nexport const MAX_LAYOUT_ANGLE = 360_000\n\n/** The largest font size, in pixels, text may be set in. */\nexport const MAX_FONT_SIZE = 10_000\n\n/** The largest ratio a layout factor, such as a flex grow share, may carry. */\nexport const MAX_LAYOUT_FACTOR = 1_000\n\n/** The largest line height or letter spacing, in pixels or percent, a text may carry. */\nexport const MAX_TEXT_LENGTH = 10_000\n\n/** A length that cannot be negative, such as a size, padding, gap, or radius. */\nexport function clampLayoutLength(value: number, max = MAX_LAYOUT_LENGTH): number {\n if (!Number.isFinite(value)) return 0\n return Math.min(max, Math.max(0, value))\n}\n\n/** A coordinate that may be negative, such as a position. */\nexport function clampLayoutPosition(value: number, max = MAX_LAYOUT_LENGTH): number {\n if (!Number.isFinite(value)) return 0\n return Math.min(max, Math.max(-max, value))\n}\n\n/** A font size in pixels, at least one and at most `MAX_FONT_SIZE`; fractions are kept. */\nexport function clampFontSize(value: number): number {\n if (!Number.isFinite(value)) return 1\n return Math.min(MAX_FONT_SIZE, Math.max(1, value))\n}\n\n/** A grid template's tracks, with at most `MAX_GRID_TRACKS` of them and no negative sizes. */\nexport function clampGridTracks(tracks: readonly GridTrack[]): GridTrack[] {\n return tracks.slice(0, MAX_GRID_TRACKS).map((track) => ({\n ...track,\n value: clampLayoutLength(track.value)\n }))\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,oBAAoB;;AAGjC,MAAa,qBAAqB;;AAGlC,MAAa,kBAAkB;;AAG/B,MAAa,gBAAgB;;AAG7B,MAAa,gBAAgB;;AAG7B,MAAa,mBAAmB;;AAGhC,MAAa,gBAAgB;;AAG7B,MAAa,oBAAoB;;AAGjC,MAAa,kBAAkB;;AAG/B,SAAgB,kBAAkB,OAAe,MAAM,mBAA2B;CAChF,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO;CACpC,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC;AACzC;;AAGA,SAAgB,oBAAoB,OAAe,MAAM,mBAA2B;CAClF,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO;CACpC,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,KAAK,CAAC;AAC5C;;AAGA,SAAgB,cAAc,OAAuB;CACnD,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO;CACpC,OAAO,KAAK,IAAI,eAAe,KAAK,IAAI,GAAG,KAAK,CAAC;AACnD;;AAGA,SAAgB,gBAAgB,QAA2C;CACzE,OAAO,OAAO,MAAM,GAAG,eAAe,CAAC,CAAC,KAAK,WAAW;EACtD,GAAG;EACH,OAAO,kBAAkB,MAAM,KAAK;CACtC,EAAE;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sizing.d.ts","names":[],"sources":["../../src/layout/sizing.ts"],"mappings":";;;;;;;;;;;KAWY;KAEP,iBAAiB,QAAQ;;iBAgDd,aACd,OAAO,YACP,MAAM,WACN,MAAM,mBACL;;iBAKa,qBACd,YAAY,uBACZ,MAAM,WACN,MAAM,mBACL;;iBASa,oBAAoB,OAAO,YAAY,MAAM,YAAY;;iBAOzD,kBACd,OAAO,YACP,MAAM,WACN,OAAO;;iBAoBO,kBAAkB,oBAAoB,sBAAsB;;;;;
|
|
1
|
+
{"version":3,"file":"sizing.d.ts","names":[],"sources":["../../src/layout/sizing.ts"],"mappings":";;;;;;;;;;;KAWY;KAEP,iBAAiB,QAAQ;;iBAgDd,aACd,OAAO,YACP,MAAM,WACN,MAAM,mBACL;;iBAKa,qBACd,YAAY,uBACZ,MAAM,WACN,MAAM,mBACL;;iBASa,oBAAoB,OAAO,YAAY,MAAM,YAAY;;iBAOzD,kBACd,OAAO,YACP,MAAM,WACN,OAAO;;iBAoBO,kBAAkB,oBAAoB,sBAAsB;;;;;iBAyB5D,oBACd,OAAO,YACP,MAAM,WACN,MAAM,kBACN,OAAO,eACN,QAAQ;;;;;;;iBA+BK,iBACd,cAAc,yBACd,MAAM,mBACL,QAAQ,KAAK;;iBAMA,uBACd,WAAW,gBACX,wBACA,0BACC,KAAK"}
|
package/dist/layout/sizing.js
CHANGED
|
@@ -69,7 +69,6 @@ function textSizingUpdates(graph, node, axis, value) {
|
|
|
69
69
|
const hugsAxis = value === "HUG";
|
|
70
70
|
const hugsOther = layoutSizing(graph, node, other) === "HUG";
|
|
71
71
|
const autoResize = axis === "HORIZONTAL" ? textAutoResizeFor(hugsAxis, hugsOther) : textAutoResizeFor(hugsOther, hugsAxis);
|
|
72
|
-
if (autoResize === "NONE" && node.textAutoResize === "TRUNCATE") return {};
|
|
73
72
|
return autoResize === node.textAutoResize ? {} : { textAutoResize: autoResize };
|
|
74
73
|
}
|
|
75
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sizing.js","names":[],"sources":["../../src/layout/sizing.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { LayoutSizing, SceneNode, TextAutoResize } from '../types'\n\n/**\n * How a node sizes along one screen axis, as Figma's `layoutSizingHorizontal` and\n * `layoutSizingVertical` report it. Fill is stored on the child, the way Figma stores it:\n * along the parent's primary axis as `layoutGrow`, across it as `layoutAlignSelf: 'STRETCH'`.\n * A grid lays its children out like a horizontal stack. Hug is stored on the node itself:\n * `primaryAxisSizing` and `counterAxisSizing` for an auto-layout frame, `textAutoResize`\n * for text.\n */\nexport type LayoutSizingAxis = 'HORIZONTAL' | 'VERTICAL'\n\ntype AutoLayoutMode = Exclude<SceneNode['layoutMode'], 'NONE'>\n\nfunction primaryAxis(mode: AutoLayoutMode): LayoutSizingAxis {\n return mode === 'VERTICAL' ? 'VERTICAL' : 'HORIZONTAL'\n}\n\n/** The auto-layout parent that sizes a node's fill, or `undefined` when nothing does. */\nfunction fillingParent(parent: SceneNode | undefined, node: SceneNode): SceneNode | undefined {\n if (!parent || parent.layoutMode === 'NONE' || node.layoutPositioning === 'ABSOLUTE')\n return undefined\n return parent\n}\n\nfunction graphParent(graph: SceneGraph, node: SceneNode): SceneNode | undefined {\n return node.parentId ? graph.getNode(node.parentId) : undefined\n}\n\nfunction fills(parent: SceneNode, node: SceneNode, axis: LayoutSizingAxis): boolean {\n if (parent.layoutMode === 'NONE') return false\n if (axis === primaryAxis(parent.layoutMode)) return node.layoutGrow > 0\n if (node.layoutAlignSelf === 'STRETCH') return true\n return (\n node.layoutAlignSelf === 'AUTO' &&\n parent.layoutMode !== 'GRID' &&\n parent.counterAxisAlign === 'STRETCH'\n )\n}\n\nfunction ownSizingField(\n node: SceneNode,\n axis: LayoutSizingAxis\n): 'primaryAxisSizing' | 'counterAxisSizing' | undefined {\n if (node.layoutMode === 'NONE') return undefined\n return axis === primaryAxis(node.layoutMode) ? 'primaryAxisSizing' : 'counterAxisSizing'\n}\n\nfunction textHugs(autoResize: TextAutoResize, axis: LayoutSizingAxis): boolean {\n if (autoResize === 'WIDTH_AND_HEIGHT') return true\n return axis === 'VERTICAL' && autoResize === 'HEIGHT'\n}\n\nfunction hugs(node: SceneNode, axis: LayoutSizingAxis): boolean {\n if (node.type === 'TEXT') return textHugs(node.textAutoResize, axis)\n const field = ownSizingField(node, axis)\n return field !== undefined && node[field] === 'HUG'\n}\n\n/** The node's sizing along `axis`: fill from its parent, else its own hug, else fixed. */\nexport function layoutSizing(\n graph: SceneGraph,\n node: SceneNode,\n axis: LayoutSizingAxis\n): LayoutSizing {\n return layoutSizingInParent(graphParent(graph, node), node, axis)\n}\n\n/** `layoutSizing` for code that holds the parent rather than the graph. */\nexport function layoutSizingInParent(\n parentNode: SceneNode | undefined,\n node: SceneNode,\n axis: LayoutSizingAxis\n): LayoutSizing {\n const parent = fillingParent(parentNode, node)\n if (parent && fills(parent, node, axis)) return 'FILL'\n // Figma reports text outside auto-layout as fixed, though it still resizes to its content.\n if (hugs(node, axis) && (parent || node.layoutMode !== 'NONE')) return 'HUG'\n return 'FIXED'\n}\n\n/** The sizings this node accepts on either axis, in Figma's order. */\nexport function layoutSizingOptions(graph: SceneGraph, node: SceneNode): LayoutSizing[] {\n return (['FIXED', 'HUG', 'FILL'] as const).filter(\n (value) => layoutSizingError(graph, node, value) === undefined\n )\n}\n\n/** Figma's reason for refusing `value` on this node, or `undefined` when it applies. */\nexport function layoutSizingError(\n graph: SceneGraph,\n node: SceneNode,\n value: LayoutSizing\n): string | undefined {\n const parent = graphParent(graph, node)\n const inAutoLayout = parent !== undefined && parent.layoutMode !== 'NONE'\n if (!inAutoLayout && node.layoutMode === 'NONE') {\n return 'node must be an auto-layout frame or a child of an auto-layout frame'\n }\n if (value === 'FILL') {\n if (!inAutoLayout) return 'FILL can only be set on children of auto-layout frames'\n if (node.layoutPositioning === 'ABSOLUTE') {\n return 'FILL cannot be set on absolute positioned auto-layout children'\n }\n }\n if (value === 'HUG' && node.layoutMode === 'NONE' && node.type !== 'TEXT') {\n return 'HUG can only be set on auto-layout frames or text children of auto-layout frames'\n }\n return undefined\n}\n\n/** The text auto-resize that hugs the content along the axes given. */\nexport function textAutoResizeFor(hugsWidth: boolean, hugsHeight: boolean): TextAutoResize {\n if (hugsWidth && hugsHeight) return 'WIDTH_AND_HEIGHT'\n return hugsHeight ? 'HEIGHT' : 'NONE'\n}\n\nfunction textSizingUpdates(\n graph: SceneGraph,\n node: SceneNode,\n axis: LayoutSizingAxis,\n value: LayoutSizing\n): Partial<SceneNode> {\n const other: LayoutSizingAxis = axis === 'HORIZONTAL' ? 'VERTICAL' : 'HORIZONTAL'\n const hugsAxis = value === 'HUG'\n const hugsOther = layoutSizing(graph, node, other) === 'HUG'\n const autoResize =\n axis === 'HORIZONTAL'\n ? textAutoResizeFor(hugsAxis, hugsOther)\n : textAutoResizeFor(hugsOther, hugsAxis)\n // Truncated text keeps truncating when it stops hugging.\n if (autoResize === 'NONE' && node.textAutoResize === 'TRUNCATE') return {}\n return autoResize === node.textAutoResize ? {} : { textAutoResize: autoResize }\n}\n\n/**\n * The fields that set the node's sizing along `axis` to `value`, as Figma's setter writes\n * them. A value Figma refuses yields no updates; `layoutSizingError` says why.\n */\nexport function layoutSizingUpdates(\n graph: SceneGraph,\n node: SceneNode,\n axis: LayoutSizingAxis,\n value: LayoutSizing\n): Partial<SceneNode> {\n if (layoutSizingError(graph, node, value) !== undefined) return {}\n const updates: Partial<SceneNode> = {}\n const parent = fillingParent(graphParent(graph, node), node)\n if (parent && parent.layoutMode !== 'NONE') {\n const fill = value === 'FILL'\n if (axis === primaryAxis(parent.layoutMode)) {\n if (fill !== node.layoutGrow > 0) updates.layoutGrow = fill ? 1 : 0\n } else if (fill && node.layoutAlignSelf !== 'STRETCH') {\n updates.layoutAlignSelf = 'STRETCH'\n } else if (!fill && fills(parent, node, axis)) {\n // A flex parent set to stretch its children stretches this one too unless it opts out.\n const inheritsStretch = parent.layoutMode !== 'GRID' && parent.counterAxisAlign === 'STRETCH'\n updates.layoutAlignSelf = inheritsStretch ? 'MIN' : 'AUTO'\n }\n }\n const field = ownSizingField(node, axis)\n if (field) {\n const own = value === 'HUG' ? 'HUG' : 'FIXED'\n if (node[field] !== own) updates[field] = own\n }\n if (node.type === 'TEXT') Object.assign(updates, textSizingUpdates(graph, node, axis, value))\n return updates\n}\n\n/**\n * The fields that make a child fill `axis` of a parent laid out as `parentLayout`, for a node\n * an importer builds before it joins the graph. Under a parent without auto layout, such as a\n * staging parent the node leaves when placed, both are set, so it fills whichever axis its\n * eventual parent stacks along.\n */\nexport function fillSizingFields(\n parentLayout: SceneNode['layoutMode'],\n axis: LayoutSizingAxis\n): Partial<Pick<SceneNode, 'layoutGrow' | 'layoutAlignSelf'>> {\n if (parentLayout === 'NONE') return { layoutGrow: 1, layoutAlignSelf: 'STRETCH' }\n return axis === primaryAxis(parentLayout) ? { layoutGrow: 1 } : { layoutAlignSelf: 'STRETCH' }\n}\n\n/** An auto-layout frame's own sizing when it hugs or fixes its width and height. */\nexport function autoLayoutSizingFields(\n direction: AutoLayoutMode,\n width: 'FIXED' | 'HUG',\n height: 'FIXED' | 'HUG'\n): Pick<SceneNode, 'primaryAxisSizing' | 'counterAxisSizing'> {\n const horizontal = primaryAxis(direction) === 'HORIZONTAL'\n return {\n primaryAxisSizing: horizontal ? width : height,\n counterAxisSizing: horizontal ? height : width\n }\n}\n"],"mappings":";AAeA,SAAS,YAAY,MAAwC;CAC3D,OAAO,SAAS,aAAa,aAAa;AAC5C;;AAGA,SAAS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AAa,OAAO,IAAI;EAAA,OAC7D,IAAI,QAAQ,KAAK,oBAAoB,WAC1C,QAAQ,kBAAkB;OACrB,IAAI,CAAC,QAAQ,MAAM,QAAQ,MAAM,IAAI,GAG1C,QAAQ,kBADgB,OAAO,eAAe,UAAU,OAAO,qBAAqB,YACxC,QAAQ;CAExD;CACA,MAAM,QAAQ,eAAe,MAAM,IAAI;CACvC,IAAI,OAAO;EACT,MAAM,MAAM,UAAU,QAAQ,QAAQ;EACtC,IAAI,KAAK,WAAW,KAAK,QAAQ,SAAS;CAC5C;CACA,IAAI,KAAK,SAAS,QAAQ,OAAO,OAAO,SAAS,kBAAkB,OAAO,MAAM,MAAM,KAAK,CAAC;CAC5F,OAAO;AACT;;;;;;;AAQA,SAAgB,iBACd,cACA,MAC4D;CAC5D,IAAI,iBAAiB,QAAQ,OAAO;EAAE,YAAY;EAAG,iBAAiB;CAAU;CAChF,OAAO,SAAS,YAAY,YAAY,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,UAAU;AAC/F;;AAGA,SAAgB,uBACd,WACA,OACA,QAC4D;CAC5D,MAAM,aAAa,YAAY,SAAS,MAAM;CAC9C,OAAO;EACL,mBAAmB,aAAa,QAAQ;EACxC,mBAAmB,aAAa,SAAS;CAC3C;AACF"}
|
|
1
|
+
{"version":3,"file":"sizing.js","names":[],"sources":["../../src/layout/sizing.ts"],"sourcesContent":["import type { SceneGraph } from '../graph'\nimport type { LayoutSizing, SceneNode, TextAutoResize } from '../types'\n\n/**\n * How a node sizes along one screen axis, as Figma's `layoutSizingHorizontal` and\n * `layoutSizingVertical` report it. Fill is stored on the child, the way Figma stores it:\n * along the parent's primary axis as `layoutGrow`, across it as `layoutAlignSelf: 'STRETCH'`.\n * A grid lays its children out like a horizontal stack. Hug is stored on the node itself:\n * `primaryAxisSizing` and `counterAxisSizing` for an auto-layout frame, `textAutoResize`\n * for text.\n */\nexport type LayoutSizingAxis = 'HORIZONTAL' | 'VERTICAL'\n\ntype AutoLayoutMode = Exclude<SceneNode['layoutMode'], 'NONE'>\n\nfunction primaryAxis(mode: AutoLayoutMode): LayoutSizingAxis {\n return mode === 'VERTICAL' ? 'VERTICAL' : 'HORIZONTAL'\n}\n\n/** The auto-layout parent that sizes a node's fill, or `undefined` when nothing does. */\nfunction fillingParent(parent: SceneNode | undefined, node: SceneNode): SceneNode | undefined {\n if (!parent || parent.layoutMode === 'NONE' || node.layoutPositioning === 'ABSOLUTE')\n return undefined\n return parent\n}\n\nfunction graphParent(graph: SceneGraph, node: SceneNode): SceneNode | undefined {\n return node.parentId ? graph.getNode(node.parentId) : undefined\n}\n\nfunction fills(parent: SceneNode, node: SceneNode, axis: LayoutSizingAxis): boolean {\n if (parent.layoutMode === 'NONE') return false\n if (axis === primaryAxis(parent.layoutMode)) return node.layoutGrow > 0\n if (node.layoutAlignSelf === 'STRETCH') return true\n return (\n node.layoutAlignSelf === 'AUTO' &&\n parent.layoutMode !== 'GRID' &&\n parent.counterAxisAlign === 'STRETCH'\n )\n}\n\nfunction ownSizingField(\n node: SceneNode,\n axis: LayoutSizingAxis\n): 'primaryAxisSizing' | 'counterAxisSizing' | undefined {\n if (node.layoutMode === 'NONE') return undefined\n return axis === primaryAxis(node.layoutMode) ? 'primaryAxisSizing' : 'counterAxisSizing'\n}\n\nfunction textHugs(autoResize: TextAutoResize, axis: LayoutSizingAxis): boolean {\n if (autoResize === 'WIDTH_AND_HEIGHT') return true\n return axis === 'VERTICAL' && autoResize === 'HEIGHT'\n}\n\nfunction hugs(node: SceneNode, axis: LayoutSizingAxis): boolean {\n if (node.type === 'TEXT') return textHugs(node.textAutoResize, axis)\n const field = ownSizingField(node, axis)\n return field !== undefined && node[field] === 'HUG'\n}\n\n/** The node's sizing along `axis`: fill from its parent, else its own hug, else fixed. */\nexport function layoutSizing(\n graph: SceneGraph,\n node: SceneNode,\n axis: LayoutSizingAxis\n): LayoutSizing {\n return layoutSizingInParent(graphParent(graph, node), node, axis)\n}\n\n/** `layoutSizing` for code that holds the parent rather than the graph. */\nexport function layoutSizingInParent(\n parentNode: SceneNode | undefined,\n node: SceneNode,\n axis: LayoutSizingAxis\n): LayoutSizing {\n const parent = fillingParent(parentNode, node)\n if (parent && fills(parent, node, axis)) return 'FILL'\n // Figma reports text outside auto-layout as fixed, though it still resizes to its content.\n if (hugs(node, axis) && (parent || node.layoutMode !== 'NONE')) return 'HUG'\n return 'FIXED'\n}\n\n/** The sizings this node accepts on either axis, in Figma's order. */\nexport function layoutSizingOptions(graph: SceneGraph, node: SceneNode): LayoutSizing[] {\n return (['FIXED', 'HUG', 'FILL'] as const).filter(\n (value) => layoutSizingError(graph, node, value) === undefined\n )\n}\n\n/** Figma's reason for refusing `value` on this node, or `undefined` when it applies. */\nexport function layoutSizingError(\n graph: SceneGraph,\n node: SceneNode,\n value: LayoutSizing\n): string | undefined {\n const parent = graphParent(graph, node)\n const inAutoLayout = parent !== undefined && parent.layoutMode !== 'NONE'\n if (!inAutoLayout && node.layoutMode === 'NONE') {\n return 'node must be an auto-layout frame or a child of an auto-layout frame'\n }\n if (value === 'FILL') {\n if (!inAutoLayout) return 'FILL can only be set on children of auto-layout frames'\n if (node.layoutPositioning === 'ABSOLUTE') {\n return 'FILL cannot be set on absolute positioned auto-layout children'\n }\n }\n if (value === 'HUG' && node.layoutMode === 'NONE' && node.type !== 'TEXT') {\n return 'HUG can only be set on auto-layout frames or text children of auto-layout frames'\n }\n return undefined\n}\n\n/** The text auto-resize that hugs the content along the axes given. */\nexport function textAutoResizeFor(hugsWidth: boolean, hugsHeight: boolean): TextAutoResize {\n if (hugsWidth && hugsHeight) return 'WIDTH_AND_HEIGHT'\n return hugsHeight ? 'HEIGHT' : 'NONE'\n}\n\nfunction textSizingUpdates(\n graph: SceneGraph,\n node: SceneNode,\n axis: LayoutSizingAxis,\n value: LayoutSizing\n): Partial<SceneNode> {\n const other: LayoutSizingAxis = axis === 'HORIZONTAL' ? 'VERTICAL' : 'HORIZONTAL'\n const hugsAxis = value === 'HUG'\n const hugsOther = layoutSizing(graph, node, other) === 'HUG'\n const autoResize =\n axis === 'HORIZONTAL'\n ? textAutoResizeFor(hugsAxis, hugsOther)\n : textAutoResizeFor(hugsOther, hugsAxis)\n return autoResize === node.textAutoResize ? {} : { textAutoResize: autoResize }\n}\n\n/**\n * The fields that set the node's sizing along `axis` to `value`, as Figma's setter writes\n * them. A value Figma refuses yields no updates; `layoutSizingError` says why.\n */\nexport function layoutSizingUpdates(\n graph: SceneGraph,\n node: SceneNode,\n axis: LayoutSizingAxis,\n value: LayoutSizing\n): Partial<SceneNode> {\n if (layoutSizingError(graph, node, value) !== undefined) return {}\n const updates: Partial<SceneNode> = {}\n const parent = fillingParent(graphParent(graph, node), node)\n if (parent && parent.layoutMode !== 'NONE') {\n const fill = value === 'FILL'\n if (axis === primaryAxis(parent.layoutMode)) {\n if (fill !== node.layoutGrow > 0) updates.layoutGrow = fill ? 1 : 0\n } else if (fill && node.layoutAlignSelf !== 'STRETCH') {\n updates.layoutAlignSelf = 'STRETCH'\n } else if (!fill && fills(parent, node, axis)) {\n // A flex parent set to stretch its children stretches this one too unless it opts out.\n const inheritsStretch = parent.layoutMode !== 'GRID' && parent.counterAxisAlign === 'STRETCH'\n updates.layoutAlignSelf = inheritsStretch ? 'MIN' : 'AUTO'\n }\n }\n const field = ownSizingField(node, axis)\n if (field) {\n const own = value === 'HUG' ? 'HUG' : 'FIXED'\n if (node[field] !== own) updates[field] = own\n }\n if (node.type === 'TEXT') Object.assign(updates, textSizingUpdates(graph, node, axis, value))\n return updates\n}\n\n/**\n * The fields that make a child fill `axis` of a parent laid out as `parentLayout`, for a node\n * an importer builds before it joins the graph. Under a parent without auto layout, such as a\n * staging parent the node leaves when placed, both are set, so it fills whichever axis its\n * eventual parent stacks along.\n */\nexport function fillSizingFields(\n parentLayout: SceneNode['layoutMode'],\n axis: LayoutSizingAxis\n): Partial<Pick<SceneNode, 'layoutGrow' | 'layoutAlignSelf'>> {\n if (parentLayout === 'NONE') return { layoutGrow: 1, layoutAlignSelf: 'STRETCH' }\n return axis === primaryAxis(parentLayout) ? { layoutGrow: 1 } : { layoutAlignSelf: 'STRETCH' }\n}\n\n/** An auto-layout frame's own sizing when it hugs or fixes its width and height. */\nexport function autoLayoutSizingFields(\n direction: AutoLayoutMode,\n width: 'FIXED' | 'HUG',\n height: 'FIXED' | 'HUG'\n): Pick<SceneNode, 'primaryAxisSizing' | 'counterAxisSizing'> {\n const horizontal = primaryAxis(direction) === 'HORIZONTAL'\n return {\n primaryAxisSizing: horizontal ? width : height,\n counterAxisSizing: horizontal ? height : width\n }\n}\n"],"mappings":";AAeA,SAAS,YAAY,MAAwC;CAC3D,OAAO,SAAS,aAAa,aAAa;AAC5C;;AAGA,SAAS,cAAc,QAA+B,MAAwC;CAC5F,IAAI,CAAC,UAAU,OAAO,eAAe,UAAU,KAAK,sBAAsB,YACxE,OAAO,KAAA;CACT,OAAO;AACT;AAEA,SAAS,YAAY,OAAmB,MAAwC;CAC9E,OAAO,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI,KAAA;AACxD;AAEA,SAAS,MAAM,QAAmB,MAAiB,MAAiC;CAClF,IAAI,OAAO,eAAe,QAAQ,OAAO;CACzC,IAAI,SAAS,YAAY,OAAO,UAAU,GAAG,OAAO,KAAK,aAAa;CACtE,IAAI,KAAK,oBAAoB,WAAW,OAAO;CAC/C,OACE,KAAK,oBAAoB,UACzB,OAAO,eAAe,UACtB,OAAO,qBAAqB;AAEhC;AAEA,SAAS,eACP,MACA,MACuD;CACvD,IAAI,KAAK,eAAe,QAAQ,OAAO,KAAA;CACvC,OAAO,SAAS,YAAY,KAAK,UAAU,IAAI,sBAAsB;AACvE;AAEA,SAAS,SAAS,YAA4B,MAAiC;CAC7E,IAAI,eAAe,oBAAoB,OAAO;CAC9C,OAAO,SAAS,cAAc,eAAe;AAC/C;AAEA,SAAS,KAAK,MAAiB,MAAiC;CAC9D,IAAI,KAAK,SAAS,QAAQ,OAAO,SAAS,KAA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
|
+
import { SceneNode } from "../types.js";
|
|
2
|
+
//#region src/layout/spacing.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The space between wrapped lines of an auto layout. A frame without its own follows the item
|
|
5
|
+
* spacing, as Figma's `counterAxisSpacing: null` does.
|
|
6
|
+
*/
|
|
7
|
+
declare function counterAxisSpacingOf(node: Pick<SceneNode, 'counterAxisSpacing' | 'itemSpacing'>): number;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { counterAxisSpacingOf };
|
|
10
|
+
//# sourceMappingURL=spacing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spacing.d.ts","names":[],"sources":["../../src/layout/spacing.ts"],"mappings":";;;;;;iBAMgB,qBACd,MAAM,KAAK"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/layout/spacing.ts
|
|
2
|
+
/**
|
|
3
|
+
* The space between wrapped lines of an auto layout. A frame without its own follows the item
|
|
4
|
+
* spacing, as Figma's `counterAxisSpacing: null` does.
|
|
5
|
+
*/
|
|
6
|
+
function counterAxisSpacingOf(node) {
|
|
7
|
+
return node.counterAxisSpacing ?? node.itemSpacing;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { counterAxisSpacingOf };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=spacing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spacing.js","names":[],"sources":["../../src/layout/spacing.ts"],"sourcesContent":["import type { SceneNode } from '../types'\n\n/**\n * The space between wrapped lines of an auto layout. A frame without its own follows the item\n * spacing, as Figma's `counterAxisSpacing: null` does.\n */\nexport function counterAxisSpacingOf(\n node: Pick<SceneNode, 'counterAxisSpacing' | 'itemSpacing'>\n): number {\n return node.counterAxisSpacing ?? node.itemSpacing\n}\n"],"mappings":";;;;;AAMA,SAAgB,qBACd,MACQ;CACR,OAAO,KAAK,sBAAsB,KAAK;AACzC"}
|
package/dist/masks.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SceneNode } from "./types.js";
|
|
2
|
+
//#region src/masks.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The layer as it masks: an outline mask masks with its shape alone, so Figma ignores how opaque
|
|
5
|
+
* its fills are, and the canvas and hit testing take them as opaque.
|
|
6
|
+
*/
|
|
7
|
+
declare function asMaskShape(node: SceneNode): SceneNode;
|
|
8
|
+
/** Whether a layer masks its siblings: a mask that is shown, since a hidden mask masks nothing. */
|
|
9
|
+
declare function isVisibleMask(node: Pick<SceneNode, 'visible' | 'isMask'>): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* A run of masks and the siblings they mask, as indices into the children: the masks are
|
|
12
|
+
* `[start, maskedStart)` and what they mask `[maskedStart, end)`, which may be empty.
|
|
13
|
+
*/
|
|
14
|
+
interface MaskRun {
|
|
15
|
+
readonly start: number;
|
|
16
|
+
readonly maskedStart: number;
|
|
17
|
+
readonly end: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Where masks act among a container's children, bottom to top. A visible mask, with the visible
|
|
21
|
+
* masks right after it, masks every sibling after them up to the next visible mask, which starts
|
|
22
|
+
* a run of its own; a sibling that is hidden or a hidden mask is masked like any other (Figma
|
|
23
|
+
* desktop, live). Children before the first mask are not in any run.
|
|
24
|
+
*/
|
|
25
|
+
declare function maskRuns<T>(children: readonly T[], isMask: (child: T) => boolean): MaskRun[];
|
|
26
|
+
//#endregion
|
|
27
|
+
export { MaskRun, asMaskShape, isVisibleMask, maskRuns };
|
|
28
|
+
//# sourceMappingURL=masks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"masks.d.ts","names":[],"sources":["../src/masks.ts"],"mappings":";;;;;;iBAMgB,YAAY,MAAM,YAAY;;iBAS9B,cAAc,MAAM,KAAK;;;;;UAQxB;WACN;WACA;WACA;;;;;;;;iBASK,SAAS,GAAG,mBAAmB,KAAK,SAAS,OAAO,gBAAgB"}
|
package/dist/masks.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/masks.ts
|
|
2
|
+
/**
|
|
3
|
+
* The layer as it masks: an outline mask masks with its shape alone, so Figma ignores how opaque
|
|
4
|
+
* its fills are, and the canvas and hit testing take them as opaque.
|
|
5
|
+
*/
|
|
6
|
+
function asMaskShape(node) {
|
|
7
|
+
if (node.maskType !== "VECTOR") return node;
|
|
8
|
+
return {
|
|
9
|
+
...node,
|
|
10
|
+
fills: node.fills.map((fill) => ({
|
|
11
|
+
...fill,
|
|
12
|
+
opacity: 1,
|
|
13
|
+
color: {
|
|
14
|
+
...fill.color,
|
|
15
|
+
a: 1
|
|
16
|
+
}
|
|
17
|
+
}))
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Whether a layer masks its siblings: a mask that is shown, since a hidden mask masks nothing. */
|
|
21
|
+
function isVisibleMask(node) {
|
|
22
|
+
return node.visible && node.isMask;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Where masks act among a container's children, bottom to top. A visible mask, with the visible
|
|
26
|
+
* masks right after it, masks every sibling after them up to the next visible mask, which starts
|
|
27
|
+
* a run of its own; a sibling that is hidden or a hidden mask is masked like any other (Figma
|
|
28
|
+
* desktop, live). Children before the first mask are not in any run.
|
|
29
|
+
*/
|
|
30
|
+
function maskRuns(children, isMask) {
|
|
31
|
+
const runs = [];
|
|
32
|
+
let index = 0;
|
|
33
|
+
while (index < children.length) {
|
|
34
|
+
if (!isMask(children[index])) {
|
|
35
|
+
index++;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const start = index;
|
|
39
|
+
while (index < children.length && isMask(children[index])) index++;
|
|
40
|
+
const maskedStart = index;
|
|
41
|
+
while (index < children.length && !isMask(children[index])) index++;
|
|
42
|
+
runs.push({
|
|
43
|
+
start,
|
|
44
|
+
maskedStart,
|
|
45
|
+
end: index
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return runs;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { asMaskShape, isVisibleMask, maskRuns };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=masks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"masks.js","names":[],"sources":["../src/masks.ts"],"sourcesContent":["import type { SceneNode } from './types'\n\n/**\n * The layer as it masks: an outline mask masks with its shape alone, so Figma ignores how opaque\n * its fills are, and the canvas and hit testing take them as opaque.\n */\nexport function asMaskShape(node: SceneNode): SceneNode {\n if (node.maskType !== 'VECTOR') return node\n return {\n ...node,\n fills: node.fills.map((fill) => ({ ...fill, opacity: 1, color: { ...fill.color, a: 1 } }))\n }\n}\n\n/** Whether a layer masks its siblings: a mask that is shown, since a hidden mask masks nothing. */\nexport function isVisibleMask(node: Pick<SceneNode, 'visible' | 'isMask'>): boolean {\n return node.visible && node.isMask\n}\n\n/**\n * A run of masks and the siblings they mask, as indices into the children: the masks are\n * `[start, maskedStart)` and what they mask `[maskedStart, end)`, which may be empty.\n */\nexport interface MaskRun {\n readonly start: number\n readonly maskedStart: number\n readonly end: number\n}\n\n/**\n * Where masks act among a container's children, bottom to top. A visible mask, with the visible\n * masks right after it, masks every sibling after them up to the next visible mask, which starts\n * a run of its own; a sibling that is hidden or a hidden mask is masked like any other (Figma\n * desktop, live). Children before the first mask are not in any run.\n */\nexport function maskRuns<T>(children: readonly T[], isMask: (child: T) => boolean): MaskRun[] {\n const runs: MaskRun[] = []\n let index = 0\n while (index < children.length) {\n if (!isMask(children[index])) {\n index++\n continue\n }\n const start = index\n while (index < children.length && isMask(children[index])) index++\n const maskedStart = index\n while (index < children.length && !isMask(children[index])) index++\n runs.push({ start, maskedStart, end: index })\n }\n return runs\n}\n"],"mappings":";;;;;AAMA,SAAgB,YAAY,MAA4B;CACtD,IAAI,KAAK,aAAa,UAAU,OAAO;CACvC,OAAO;EACL,GAAG;EACH,OAAO,KAAK,MAAM,KAAK,UAAU;GAAE,GAAG;GAAM,SAAS;GAAG,OAAO;IAAE,GAAG,KAAK;IAAO,GAAG;GAAE;EAAE,EAAE;CAC3F;AACF;;AAGA,SAAgB,cAAc,MAAsD;CAClF,OAAO,KAAK,WAAW,KAAK;AAC9B;;;;;;;AAkBA,SAAgB,SAAY,UAAwB,QAA0C;CAC5F,MAAM,OAAkB,CAAC;CACzB,IAAI,QAAQ;CACZ,OAAO,QAAQ,SAAS,QAAQ;EAC9B,IAAI,CAAC,OAAO,SAAS,MAAM,GAAG;GAC5B;GACA;EACF;EACA,MAAM,QAAQ;EACd,OAAO,QAAQ,SAAS,UAAU,OAAO,SAAS,MAAM,GAAG;EAC3D,MAAM,cAAc;EACpB,OAAO,QAAQ,SAAS,UAAU,CAAC,OAAO,SAAS,MAAM,GAAG;EAC5D,KAAK,KAAK;GAAE;GAAO;GAAa,KAAK;EAAM,CAAC;CAC9C;CACA,OAAO;AACT"}
|
package/dist/matrix.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector } from "./primitives/index.js";
|
|
1
|
+
import { Matrix as Matrix$1, Vector } from "./primitives/index.js";
|
|
2
2
|
//#region src/matrix.d.ts
|
|
3
3
|
type Mat3 = number[];
|
|
4
4
|
declare const Matrix: {
|
|
@@ -10,6 +10,7 @@ declare const Matrix: {
|
|
|
10
10
|
invert: (m: Mat3) => Mat3 | null;
|
|
11
11
|
mapPoints: (matrix: Mat3, ptArr: number[]) => number[];
|
|
12
12
|
mapPoint: (m: Mat3, p: Vector) => Vector;
|
|
13
|
+
fromAffine: (t: Matrix$1) => Mat3;
|
|
13
14
|
};
|
|
14
15
|
//#endregion
|
|
15
16
|
export { Mat3, Matrix as default };
|
package/dist/matrix.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.d.ts","names":[],"sources":["../src/matrix.ts"],"mappings":";;KAEY;
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","names":[],"sources":["../src/matrix.ts"],"mappings":";;KAEY;cAmHN;EAjHe,gBAAA;EAmBI,cAAA,IAAA,WAAS;EAOV,aAAA,YAAM,eAAe;EAEnB,UAAA,iBAAM,aAAA,gBAAmB;EAmB/B,SAAA,YAAM,YAAY,aAAA,gBAAmB;EAiBtC,SAAA,GAAA,SAAO;EA0BC,YAAA,QAAA,MAAI;EAeV,WAAA,GAAA,MAAI,GAAK,WAAS;EAMhB,aAAA,GAAA,aAAkB"}
|
package/dist/matrix.js
CHANGED
|
@@ -104,6 +104,18 @@ const mapPoint = (m, p) => {
|
|
|
104
104
|
y: arr[1]
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
|
+
/** A 2 × 3 affine transform, as Figma stores gradient and image transforms, as a 3 × 3 matrix. */
|
|
108
|
+
const fromAffine = (t) => [
|
|
109
|
+
t.m00,
|
|
110
|
+
t.m01,
|
|
111
|
+
t.m02,
|
|
112
|
+
t.m10,
|
|
113
|
+
t.m11,
|
|
114
|
+
t.m12,
|
|
115
|
+
0,
|
|
116
|
+
0,
|
|
117
|
+
1
|
|
118
|
+
];
|
|
107
119
|
const Matrix = {
|
|
108
120
|
identity,
|
|
109
121
|
multiply,
|
|
@@ -112,7 +124,8 @@ const Matrix = {
|
|
|
112
124
|
scaled,
|
|
113
125
|
invert,
|
|
114
126
|
mapPoints,
|
|
115
|
-
mapPoint
|
|
127
|
+
mapPoint,
|
|
128
|
+
fromAffine
|
|
116
129
|
};
|
|
117
130
|
//#endregion
|
|
118
131
|
export { Matrix as default };
|
package/dist/matrix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.js","names":[],"sources":["../src/matrix.ts"],"sourcesContent":["import type { Vector } from './primitives'\n\nexport type Mat3 = number[]\n\nconst identity = (): Mat3 => [1, 0, 0, 0, 1, 0, 0, 0, 1]\n\nconst multiply2 = (m1: Mat3, m2: Mat3): Mat3 => {\n // row-major general 3x3 multiply: out = m1 * m2\n return [\n m1[0] * m2[0] + m1[1] * m2[3] + m1[2] * m2[6],\n m1[0] * m2[1] + m1[1] * m2[4] + m1[2] * m2[7],\n m1[0] * m2[2] + m1[1] * m2[5] + m1[2] * m2[8],\n\n m1[3] * m2[0] + m1[4] * m2[3] + m1[5] * m2[6],\n m1[3] * m2[1] + m1[4] * m2[4] + m1[5] * m2[7],\n m1[3] * m2[2] + m1[4] * m2[5] + m1[5] * m2[8],\n\n m1[6] * m2[0] + m1[7] * m2[3] + m1[8] * m2[6],\n m1[6] * m2[1] + m1[7] * m2[4] + m1[8] * m2[7],\n m1[6] * m2[2] + m1[7] * m2[5] + m1[8] * m2[8]\n ]\n}\n\nconst multiply = (...ms: Mat3[]): Mat3 => {\n if (ms.length === 0) return identity()\n let out = ms[0].slice()\n for (let i = 1; i < ms.length; i++) out = multiply2(out, ms[i])\n return out\n}\n\nconst translated = (dx: number, dy: number): Mat3 => [1, 0, dx, 0, 1, dy, 0, 0, 1]\n\nconst rotated = (radians: number, px = 0, py = 0): Mat3 => {\n const s = Math.sin(radians)\n const c = Math.cos(radians)\n // exactly like ck.Matrix.rotated\n return [\n c,\n -s,\n s * py + (1 - c) * px,\n\n s,\n c,\n -s * px + (1 - c) * py,\n\n 0,\n 0,\n 1\n ]\n}\n\nconst scaled = (sx: number, sy: number, px = 0, py = 0): Mat3 => {\n // match ck.Matrix.scaled\n return [\n sx,\n 0,\n px - sx * px,\n\n 0,\n sy,\n py - sy * py,\n\n 0,\n 0,\n 1\n ]\n}\n\nconst invert = (m: Mat3): Mat3 | null => {\n // match ck.Matrix.invert (Sarrus)\n const det =\n m[0] * m[4] * m[8] +\n m[1] * m[5] * m[6] +\n m[2] * m[3] * m[7] -\n m[2] * m[4] * m[6] -\n m[1] * m[3] * m[8] -\n m[0] * m[5] * m[7]\n if (!det) return null\n\n return [\n (m[4] * m[8] - m[5] * m[7]) / det,\n (m[2] * m[7] - m[1] * m[8]) / det,\n (m[1] * m[5] - m[2] * m[4]) / det,\n\n (m[5] * m[6] - m[3] * m[8]) / det,\n (m[0] * m[8] - m[2] * m[6]) / det,\n (m[2] * m[3] - m[0] * m[5]) / det,\n\n (m[3] * m[7] - m[4] * m[6]) / det,\n (m[1] * m[6] - m[0] * m[7]) / det,\n (m[0] * m[4] - m[1] * m[3]) / det\n ]\n}\n\nconst mapPoints = (matrix: Mat3, ptArr: number[]): number[] => {\n if (ptArr.length % 2) throw new Error('mapPoints requires even length [x,y,...].')\n const out = ptArr.slice()\n for (let i = 0; i < out.length; i += 2) {\n const x = out[i]\n const y = out[i + 1]\n const denom = matrix[6] * x + matrix[7] * y + matrix[8]\n const xTrans = matrix[0] * x + matrix[1] * y + matrix[2]\n const yTrans = matrix[3] * x + matrix[4] * y + matrix[5]\n out[i] = xTrans / denom\n out[i + 1] = yTrans / denom\n }\n return out\n}\n\nconst mapPoint = (m: Mat3, p: Vector): Vector => {\n const arr = mapPoints(m, [p.x, p.y])\n return { x: arr[0], y: arr[1] }\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"matrix.js","names":[],"sources":["../src/matrix.ts"],"sourcesContent":["import type { Matrix as AffineTransform, Vector } from './primitives'\n\nexport type Mat3 = number[]\n\nconst identity = (): Mat3 => [1, 0, 0, 0, 1, 0, 0, 0, 1]\n\nconst multiply2 = (m1: Mat3, m2: Mat3): Mat3 => {\n // row-major general 3x3 multiply: out = m1 * m2\n return [\n m1[0] * m2[0] + m1[1] * m2[3] + m1[2] * m2[6],\n m1[0] * m2[1] + m1[1] * m2[4] + m1[2] * m2[7],\n m1[0] * m2[2] + m1[1] * m2[5] + m1[2] * m2[8],\n\n m1[3] * m2[0] + m1[4] * m2[3] + m1[5] * m2[6],\n m1[3] * m2[1] + m1[4] * m2[4] + m1[5] * m2[7],\n m1[3] * m2[2] + m1[4] * m2[5] + m1[5] * m2[8],\n\n m1[6] * m2[0] + m1[7] * m2[3] + m1[8] * m2[6],\n m1[6] * m2[1] + m1[7] * m2[4] + m1[8] * m2[7],\n m1[6] * m2[2] + m1[7] * m2[5] + m1[8] * m2[8]\n ]\n}\n\nconst multiply = (...ms: Mat3[]): Mat3 => {\n if (ms.length === 0) return identity()\n let out = ms[0].slice()\n for (let i = 1; i < ms.length; i++) out = multiply2(out, ms[i])\n return out\n}\n\nconst translated = (dx: number, dy: number): Mat3 => [1, 0, dx, 0, 1, dy, 0, 0, 1]\n\nconst rotated = (radians: number, px = 0, py = 0): Mat3 => {\n const s = Math.sin(radians)\n const c = Math.cos(radians)\n // exactly like ck.Matrix.rotated\n return [\n c,\n -s,\n s * py + (1 - c) * px,\n\n s,\n c,\n -s * px + (1 - c) * py,\n\n 0,\n 0,\n 1\n ]\n}\n\nconst scaled = (sx: number, sy: number, px = 0, py = 0): Mat3 => {\n // match ck.Matrix.scaled\n return [\n sx,\n 0,\n px - sx * px,\n\n 0,\n sy,\n py - sy * py,\n\n 0,\n 0,\n 1\n ]\n}\n\nconst invert = (m: Mat3): Mat3 | null => {\n // match ck.Matrix.invert (Sarrus)\n const det =\n m[0] * m[4] * m[8] +\n m[1] * m[5] * m[6] +\n m[2] * m[3] * m[7] -\n m[2] * m[4] * m[6] -\n m[1] * m[3] * m[8] -\n m[0] * m[5] * m[7]\n if (!det) return null\n\n return [\n (m[4] * m[8] - m[5] * m[7]) / det,\n (m[2] * m[7] - m[1] * m[8]) / det,\n (m[1] * m[5] - m[2] * m[4]) / det,\n\n (m[5] * m[6] - m[3] * m[8]) / det,\n (m[0] * m[8] - m[2] * m[6]) / det,\n (m[2] * m[3] - m[0] * m[5]) / det,\n\n (m[3] * m[7] - m[4] * m[6]) / det,\n (m[1] * m[6] - m[0] * m[7]) / det,\n (m[0] * m[4] - m[1] * m[3]) / det\n ]\n}\n\nconst mapPoints = (matrix: Mat3, ptArr: number[]): number[] => {\n if (ptArr.length % 2) throw new Error('mapPoints requires even length [x,y,...].')\n const out = ptArr.slice()\n for (let i = 0; i < out.length; i += 2) {\n const x = out[i]\n const y = out[i + 1]\n const denom = matrix[6] * x + matrix[7] * y + matrix[8]\n const xTrans = matrix[0] * x + matrix[1] * y + matrix[2]\n const yTrans = matrix[3] * x + matrix[4] * y + matrix[5]\n out[i] = xTrans / denom\n out[i + 1] = yTrans / denom\n }\n return out\n}\n\nconst mapPoint = (m: Mat3, p: Vector): Vector => {\n const arr = mapPoints(m, [p.x, p.y])\n return { x: arr[0], y: arr[1] }\n}\n\n/** A 2 × 3 affine transform, as Figma stores gradient and image transforms, as a 3 × 3 matrix. */\nconst fromAffine = (t: AffineTransform): Mat3 => [t.m00, t.m01, t.m02, t.m10, t.m11, t.m12, 0, 0, 1]\n\nconst Matrix = {\n identity,\n multiply,\n translated,\n rotated,\n scaled,\n invert,\n mapPoints,\n mapPoint,\n fromAffine\n}\nexport default Matrix\n"],"mappings":";AAIA,MAAM,iBAAuB;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;AAAC;AAEvD,MAAM,aAAa,IAAU,OAAmB;CAE9C,OAAO;EACL,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAC3C,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAC3C,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAE3C,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAC3C,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAC3C,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAE3C,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAC3C,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAC3C,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;CAC7C;AAC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
|
/** The kinds that hold layers of their own on the canvas: what a shadow or a clip encloses. */
|
|
17
17
|
declare const LAYER_CONTAINER_TYPES: ReadonlySet<NodeType>;
|
|
18
18
|
declare function isLayerContainer(node: Pick<SceneNode, 'type'>): boolean;
|
|
19
|
+
/** The kinds that clip their children when their clip content is on. */
|
|
20
|
+
declare const CLIPPING_TYPES: ReadonlySet<NodeType>;
|
|
21
|
+
/**
|
|
22
|
+
* Whether a layer clips its children: a frame, component, component set or instance with clip
|
|
23
|
+
* content on. A section or group has no such setting in Figma and never clips, whatever an import
|
|
24
|
+
* left in `clipsContent` (Figma desktop, live).
|
|
25
|
+
*/
|
|
26
|
+
declare function clipsChildren(node: Pick<SceneNode, 'type' | 'clipsContent'>): boolean;
|
|
19
27
|
declare const CONTAINER_TYPES: Set<NodeType>;
|
|
20
28
|
//#endregion
|
|
21
|
-
export { CONTAINER_TYPES, FITTED_CONTAINER_TYPES, LAYER_CONTAINER_TYPES, SIDE_STROKE_TYPES, createDefaultNode, createDefaultSourceMetadata, defaultStrokeAlign, isLayerContainer, newStrokeGeometry };
|
|
29
|
+
export { CLIPPING_TYPES, CONTAINER_TYPES, FITTED_CONTAINER_TYPES, LAYER_CONTAINER_TYPES, SIDE_STROKE_TYPES, clipsChildren, createDefaultNode, createDefaultSourceMetadata, defaultStrokeAlign, isLayerContainer, newStrokeGeometry };
|
|
22
30
|
//# sourceMappingURL=node-defaults.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-defaults.d.ts","names":[],"sources":["../src/node-defaults.ts"],"mappings":";;iBAUgB,+BAA+B;;iBA4B/B,mBAAmB,MAAM,WAAW;;;;;iBASpC,kBACd,MAAM,KAAK,yDACV,KAAK;iBAKQ,kBACd,0BACA,MAAM,UACN,YAAW,QAAQ,aAClB;;
|
|
1
|
+
{"version":3,"file":"node-defaults.d.ts","names":[],"sources":["../src/node-defaults.ts"],"mappings":";;iBAUgB,+BAA+B;;iBA4B/B,mBAAmB,MAAM,WAAW;;;;;iBASpC,kBACd,MAAM,KAAK,yDACV,KAAK;iBAKQ,kBACd,0BACA,MAAM,UACN,YAAW,QAAQ,aAClB;;cAsLU,wBAAwB,YAAY;;cAMpC,mBAAmB,YAAY;;cAS/B,uBAAuB,YAAY;iBAShC,iBAAiB,MAAM,KAAK;;cAK/B,gBAAgB,YAAY;;;;;;iBAYzB,cAAc,MAAM,KAAK;cAI5B,iBAAe,IAAA"}
|
package/dist/node-defaults.js
CHANGED
|
@@ -239,6 +239,21 @@ const LAYER_CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
|
239
239
|
function isLayerContainer(node) {
|
|
240
240
|
return LAYER_CONTAINER_TYPES.has(node.type);
|
|
241
241
|
}
|
|
242
|
+
/** The kinds that clip their children when their clip content is on. */
|
|
243
|
+
const CLIPPING_TYPES = /* @__PURE__ */ new Set([
|
|
244
|
+
"FRAME",
|
|
245
|
+
"COMPONENT",
|
|
246
|
+
"COMPONENT_SET",
|
|
247
|
+
"INSTANCE"
|
|
248
|
+
]);
|
|
249
|
+
/**
|
|
250
|
+
* Whether a layer clips its children: a frame, component, component set or instance with clip
|
|
251
|
+
* content on. A section or group has no such setting in Figma and never clips, whatever an import
|
|
252
|
+
* left in `clipsContent` (Figma desktop, live).
|
|
253
|
+
*/
|
|
254
|
+
function clipsChildren(node) {
|
|
255
|
+
return node.clipsContent && CLIPPING_TYPES.has(node.type);
|
|
256
|
+
}
|
|
242
257
|
const CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
243
258
|
"CANVAS",
|
|
244
259
|
"FRAME",
|
|
@@ -250,6 +265,6 @@ const CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
|
250
265
|
"INSTANCE"
|
|
251
266
|
]);
|
|
252
267
|
//#endregion
|
|
253
|
-
export { CONTAINER_TYPES, FITTED_CONTAINER_TYPES, LAYER_CONTAINER_TYPES, SIDE_STROKE_TYPES, createDefaultNode, createDefaultSourceMetadata, defaultStrokeAlign, isLayerContainer, newStrokeGeometry };
|
|
268
|
+
export { CLIPPING_TYPES, CONTAINER_TYPES, FITTED_CONTAINER_TYPES, LAYER_CONTAINER_TYPES, SIDE_STROKE_TYPES, clipsChildren, createDefaultNode, createDefaultSourceMetadata, defaultStrokeAlign, isLayerContainer, newStrokeGeometry };
|
|
254
269
|
|
|
255
270
|
//# sourceMappingURL=node-defaults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-defaults.js","names":[],"sources":["../src/node-defaults.ts"],"sourcesContent":["import {\n BLACK,\n DEFAULT_FONT_FAMILY,\n DEFAULT_STROKE_MITER_LIMIT,\n DEFAULT_STROKE_WEIGHT\n} from './constants'\nimport { createInstanceOverrideState } from './instances/overrides'\nimport { NO_LETTER_SPACING } from './text/lengths'\nimport type { NodeType, SceneNode, SourceMetadata } from './types'\n\nexport function createDefaultSourceMetadata(): SourceMetadata {\n return {\n format: null,\n id: null,\n orderKey: null,\n editedFields: [],\n fig: {\n rawSize: null,\n rawTransform: null,\n rawNodeFields: {},\n layout: null,\n symbolOverrides: [],\n componentPropAssignments: [],\n derivedSymbolData: [],\n derivedSymbolDataLayoutVersion: null,\n uniformScaleFactor: null\n }\n }\n}\n\n/**\n * Every SceneNode field. Nodes start with all of them, so setting any field later keeps the\n * shape every node shares; a key added after creation turns a JavaScriptCore object into a\n * slower, larger dictionary.\n */\ntype CompleteNodeFields = SceneNode & Record<keyof SceneNode, unknown>\n\n/** Where Figma aligns a new node's strokes: centered on lines and vectors, outside text, else inside. */\nexport function defaultStrokeAlign(type: NodeType): SceneNode['strokeAlign'] {\n if (type === 'LINE' || type === 'VECTOR') return 'CENTER'\n return type === 'TEXT' ? 'OUTSIDE' : 'INSIDE'\n}\n\n/**\n * Weight and alignment a stroke added to `node` takes: its first stroke's, or what the node keeps\n * with none. Adding a stroke from the panel and from the plugin API both go through here.\n */\nexport function newStrokeGeometry(\n node: Pick<SceneNode, 'strokes' | 'strokeWeight' | 'strokeAlign'>\n): Pick<SceneNode['strokes'][number], 'weight' | 'align'> {\n const first = node.strokes.at(0)\n return { weight: first?.weight ?? node.strokeWeight, align: first?.align ?? node.strokeAlign }\n}\n\nexport function createDefaultNode(\n generateId: () => string,\n type: NodeType,\n overrides: Partial<SceneNode> = {}\n): SceneNode {\n return {\n id: generateId(),\n type,\n name: type.charAt(0) + type.slice(1).toLowerCase(),\n parentId: null,\n childIds: [],\n x: 0,\n y: 0,\n width: 100,\n height: 100,\n rotation: 0,\n source: createDefaultSourceMetadata(),\n derivedLayout: null,\n fills:\n type === 'TEXT' ? [{ type: 'SOLID' as const, color: BLACK, opacity: 1, visible: true }] : [],\n strokes: [],\n effects: [],\n layoutGrids: [],\n guides: [],\n fillStyleId: null,\n strokeStyleId: null,\n textStyleId: null,\n effectStyleId: null,\n gridStyleId: null,\n sharedStyleType: null,\n opacity: 1,\n cornerRadius: 0,\n topLeftRadius: 0,\n topRightRadius: 0,\n bottomRightRadius: 0,\n bottomLeftRadius: 0,\n independentCorners: false,\n cornerSmoothing: 0,\n visible: true,\n locked: false,\n clipsContent: false,\n text: '',\n fontSize: 14,\n fontFamily: DEFAULT_FONT_FAMILY,\n fontWeight: 400,\n italic: false,\n fontStyle: null,\n textAlignHorizontal: 'LEFT',\n textDirection: 'AUTO',\n textLanguage: null,\n leadingTrim: 'NONE',\n lineHeight: null,\n letterSpacing: NO_LETTER_SPACING,\n layoutMode: 'NONE',\n layoutDirection: 'AUTO',\n layoutWrap: 'NO_WRAP',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n counterAxisSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n blendMode: 'PASS_THROUGH',\n layoutPositioning: 'AUTO',\n layoutGrow: 0,\n layoutAlignSelf: 'AUTO',\n vectorNetwork: null,\n handleMirroring: 'NONE',\n fillGeometry: [],\n strokeGeometry: [],\n arcData: null,\n textAlignVertical: 'TOP',\n textAutoResize: 'NONE',\n textCase: 'ORIGINAL',\n textDecoration: 'NONE',\n textDecorationStyle: 'SOLID',\n textDecorationThickness: null,\n textDecorationFills: [],\n textDecorationSkipInk: true,\n textUnderlineOffset: null,\n maxLines: null,\n textParagraphs: [],\n listSpacing: 0,\n paragraphSpacing: 0,\n paragraphIndent: 0,\n hangingList: false,\n styleRuns: [],\n fontVariations: [],\n opticalSizeFromFontSize: true,\n fontFeatures: [],\n horizontalConstraint: 'MIN',\n verticalConstraint: 'MIN',\n strokeCap: 'NONE',\n strokeJoin: 'MITER',\n dashPattern: [],\n borderTopWeight: 0,\n borderRightWeight: 0,\n borderBottomWeight: 0,\n borderLeftWeight: 0,\n independentStrokeWeights: false,\n strokeWeight: DEFAULT_STROKE_WEIGHT,\n strokeAlign: defaultStrokeAlign(type),\n strokeMiterLimit: DEFAULT_STROKE_MITER_LIMIT,\n minWidth: null,\n maxWidth: null,\n minHeight: null,\n maxHeight: null,\n targetAspectRatio: null,\n connectorStart: null,\n connectorEnd: null,\n connectorLineType: 'ELBOWED',\n connectorStartCap: 'ROUND',\n connectorEndCap: 'ARROW_LINES',\n connectorControlPoints: [],\n connectorCurveHandles: null,\n connectorLabelPosition: null,\n isMask: false,\n maskType: 'ALPHA',\n maskIsOutline: false,\n gridTemplateColumns: [],\n gridTemplateRows: [],\n gridColumnGap: 0,\n gridRowGap: 0,\n gridPosition: null,\n counterAxisAlignContent: 'AUTO',\n itemReverseZIndex: false,\n strokesIncludedInLayout: false,\n expanded: true,\n textTruncation: 'DISABLED',\n autoRename: true,\n pointCount: 5,\n // Figma's: the golden-ratio star, whose inner points line up with its outer ones.\n starInnerRadius: (3 - Math.sqrt(5)) / 2,\n shapeWithTextType: 'SQUARE',\n shapeUserHeight: 0,\n shapeTruncates: false,\n componentId: null,\n instanceOverrides: createInstanceOverrideState(),\n componentPropertyDefinitions: [],\n componentPropertyReferences: [],\n componentPropertyAssignments: {},\n componentPropertyValues: {},\n componentKey: null,\n sourceLibraryKey: null,\n publishId: null,\n overrideKey: null,\n sharedSymbolVersion: null,\n publishedVersion: null,\n librarySource: null,\n libraryLayerId: null,\n isPublishable: false,\n isSymbolPublishable: false,\n isExposedInstance: false,\n symbolDescription: '',\n symbolLinks: [],\n variantPropSpecs: [],\n boundVariables: {},\n variableBindingScales: {},\n variableAssignmentScales: {},\n componentScale: 1,\n variableModes: {},\n exportSettings: [],\n status: null,\n pluginData: [],\n pluginRelaunchData: [],\n internalOnly: false,\n flipX: false,\n flipY: false,\n textPicture: null,\n derivedTextGlyphs: null,\n derivedTextHeight: null,\n textPathData: null,\n textPathBox: null,\n booleanOperation: undefined,\n ...overrides\n } satisfies CompleteNodeFields\n}\n\n/** Containers whose bounds follow their children and that set no coordinate space, as in Figma. */\nexport const FITTED_CONTAINER_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'GROUP',\n 'BOOLEAN_OPERATION'\n])\n\n/** Layers whose stroke can take a weight per side, as Figma's `strokeTopWeight` and its siblings. */\nexport const SIDE_STROKE_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'RECTANGLE',\n 'FRAME',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\n/** The kinds that hold layers of their own on the canvas: what a shadow or a clip encloses. */\nexport const LAYER_CONTAINER_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'FRAME',\n 'GROUP',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\nexport function isLayerContainer(node: Pick<SceneNode, 'type'>): boolean {\n return LAYER_CONTAINER_TYPES.has(node.type)\n}\n\nexport const CONTAINER_TYPES = new Set<NodeType>([\n 'CANVAS',\n 'FRAME',\n 'GROUP',\n 'BOOLEAN_OPERATION',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n"],"mappings":";;;;AAUA,SAAgB,8BAA8C;CAC5D,OAAO;EACL,Q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,mBAAmB;EACnB,iBAAiB;EACjB,gBAAgB;EAChB,aAAa;EACb,mBAAmB,4BAA4B;EAC/C,8BAA8B,CAAC;EAC/B,6BAA6B,CAAC;EAC9B,8BAA8B,CAAC;EAC/B,yBAAyB,CAAC;EAC1B,cAAc;EACd,kBAAkB;EAClB,WAAW;EACX,aAAa;EACb,qBAAqB;EACrB,kBAAkB;EAClB,eAAe;EACf,gBAAgB;EAChB,eAAe;EACf,qBAAqB;EACrB,mBAAmB;EACnB,mBAAmB;EACnB,aAAa,CAAC;EACd,kBAAkB,CAAC;EACnB,gBAAgB,CAAC;EACjB,uBAAuB,CAAC;EACxB,0BAA0B,CAAC;EAC3B,gBAAgB;EAChB,eAAe,CAAC;EAChB,gBAAgB,CAAC;EACjB,QAAQ;EACR,YAAY,CAAC;EACb,oBAAoB,CAAC;EACrB,cAAc;EACd,OAAO;EACP,OAAO;EACP,aAAa;EACb,mBAAmB;EACnB,mBAAmB;EACnB,cAAc;EACd,aAAa;EACb,kBAAkB,KAAA;EAClB,GAAG;CACL;AACF;;AAGA,MAAa,yCAAgD,IAAI,IAAc,CAC7E,SACA,mBACF,CAAC;;AAGD,MAAa,oCAA2C,IAAI,IAAc;CACxE;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,wCAA+C,IAAI,IAAc;CAC5E;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,iBAAiB,MAAwC;CACvE,OAAO,sBAAsB,IAAI,KAAK,IAAI;AAC5C;AAEA,MAAa,kCAAkB,IAAI,IAAc;CAC/C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"node-defaults.js","names":[],"sources":["../src/node-defaults.ts"],"sourcesContent":["import {\n BLACK,\n DEFAULT_FONT_FAMILY,\n DEFAULT_STROKE_MITER_LIMIT,\n DEFAULT_STROKE_WEIGHT\n} from './constants'\nimport { createInstanceOverrideState } from './instances/overrides'\nimport { NO_LETTER_SPACING } from './text/lengths'\nimport type { NodeType, SceneNode, SourceMetadata } from './types'\n\nexport function createDefaultSourceMetadata(): SourceMetadata {\n return {\n format: null,\n id: null,\n orderKey: null,\n editedFields: [],\n fig: {\n rawSize: null,\n rawTransform: null,\n rawNodeFields: {},\n layout: null,\n symbolOverrides: [],\n componentPropAssignments: [],\n derivedSymbolData: [],\n derivedSymbolDataLayoutVersion: null,\n uniformScaleFactor: null\n }\n }\n}\n\n/**\n * Every SceneNode field. Nodes start with all of them, so setting any field later keeps the\n * shape every node shares; a key added after creation turns a JavaScriptCore object into a\n * slower, larger dictionary.\n */\ntype CompleteNodeFields = SceneNode & Record<keyof SceneNode, unknown>\n\n/** Where Figma aligns a new node's strokes: centered on lines and vectors, outside text, else inside. */\nexport function defaultStrokeAlign(type: NodeType): SceneNode['strokeAlign'] {\n if (type === 'LINE' || type === 'VECTOR') return 'CENTER'\n return type === 'TEXT' ? 'OUTSIDE' : 'INSIDE'\n}\n\n/**\n * Weight and alignment a stroke added to `node` takes: its first stroke's, or what the node keeps\n * with none. Adding a stroke from the panel and from the plugin API both go through here.\n */\nexport function newStrokeGeometry(\n node: Pick<SceneNode, 'strokes' | 'strokeWeight' | 'strokeAlign'>\n): Pick<SceneNode['strokes'][number], 'weight' | 'align'> {\n const first = node.strokes.at(0)\n return { weight: first?.weight ?? node.strokeWeight, align: first?.align ?? node.strokeAlign }\n}\n\nexport function createDefaultNode(\n generateId: () => string,\n type: NodeType,\n overrides: Partial<SceneNode> = {}\n): SceneNode {\n // A literal ending in a spread is built one field at a time, and V8 keeps an object given this\n // many fields that way in dictionary mode, about 3 KB more per layer; a spread copy of a\n // finished literal keeps fast fields, in JavaScriptCore as well.\n const defaults = {\n id: generateId(),\n type,\n name: type.charAt(0) + type.slice(1).toLowerCase(),\n parentId: null,\n childIds: [],\n x: 0,\n y: 0,\n width: 100,\n height: 100,\n rotation: 0,\n source: createDefaultSourceMetadata(),\n derivedLayout: null,\n fills:\n type === 'TEXT' ? [{ type: 'SOLID' as const, color: BLACK, opacity: 1, visible: true }] : [],\n strokes: [],\n effects: [],\n layoutGrids: [],\n guides: [],\n fillStyleId: null,\n strokeStyleId: null,\n textStyleId: null,\n effectStyleId: null,\n gridStyleId: null,\n sharedStyleType: null,\n opacity: 1,\n cornerRadius: 0,\n topLeftRadius: 0,\n topRightRadius: 0,\n bottomRightRadius: 0,\n bottomLeftRadius: 0,\n independentCorners: false,\n cornerSmoothing: 0,\n visible: true,\n locked: false,\n clipsContent: false,\n text: '',\n fontSize: 14,\n fontFamily: DEFAULT_FONT_FAMILY,\n fontWeight: 400,\n italic: false,\n fontStyle: null,\n textAlignHorizontal: 'LEFT',\n textDirection: 'AUTO',\n textLanguage: null,\n leadingTrim: 'NONE',\n lineHeight: null,\n letterSpacing: NO_LETTER_SPACING,\n layoutMode: 'NONE',\n layoutDirection: 'AUTO',\n layoutWrap: 'NO_WRAP',\n primaryAxisAlign: 'MIN',\n counterAxisAlign: 'MIN',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n counterAxisSpacing: 0,\n paddingTop: 0,\n paddingRight: 0,\n paddingBottom: 0,\n paddingLeft: 0,\n blendMode: 'PASS_THROUGH',\n layoutPositioning: 'AUTO',\n layoutGrow: 0,\n layoutAlignSelf: 'AUTO',\n vectorNetwork: null,\n handleMirroring: 'NONE',\n fillGeometry: [],\n strokeGeometry: [],\n arcData: null,\n textAlignVertical: 'TOP',\n textAutoResize: 'NONE',\n textCase: 'ORIGINAL',\n textDecoration: 'NONE',\n textDecorationStyle: 'SOLID',\n textDecorationThickness: null,\n textDecorationFills: [],\n textDecorationSkipInk: true,\n textUnderlineOffset: null,\n maxLines: null,\n textParagraphs: [],\n listSpacing: 0,\n paragraphSpacing: 0,\n paragraphIndent: 0,\n hangingList: false,\n styleRuns: [],\n fontVariations: [],\n opticalSizeFromFontSize: true,\n fontFeatures: [],\n horizontalConstraint: 'MIN',\n verticalConstraint: 'MIN',\n strokeCap: 'NONE',\n strokeJoin: 'MITER',\n dashPattern: [],\n borderTopWeight: 0,\n borderRightWeight: 0,\n borderBottomWeight: 0,\n borderLeftWeight: 0,\n independentStrokeWeights: false,\n strokeWeight: DEFAULT_STROKE_WEIGHT,\n strokeAlign: defaultStrokeAlign(type),\n strokeMiterLimit: DEFAULT_STROKE_MITER_LIMIT,\n minWidth: null,\n maxWidth: null,\n minHeight: null,\n maxHeight: null,\n targetAspectRatio: null,\n connectorStart: null,\n connectorEnd: null,\n connectorLineType: 'ELBOWED',\n connectorStartCap: 'ROUND',\n connectorEndCap: 'ARROW_LINES',\n connectorControlPoints: [],\n connectorCurveHandles: null,\n connectorLabelPosition: null,\n isMask: false,\n maskType: 'ALPHA',\n maskIsOutline: false,\n gridTemplateColumns: [],\n gridTemplateRows: [],\n gridColumnGap: 0,\n gridRowGap: 0,\n gridPosition: null,\n counterAxisAlignContent: 'AUTO',\n itemReverseZIndex: false,\n strokesIncludedInLayout: false,\n expanded: true,\n textTruncation: 'DISABLED',\n autoRename: true,\n pointCount: 5,\n // Figma's: the golden-ratio star, whose inner points line up with its outer ones.\n starInnerRadius: (3 - Math.sqrt(5)) / 2,\n shapeWithTextType: 'SQUARE',\n shapeUserHeight: 0,\n shapeTruncates: false,\n componentId: null,\n instanceOverrides: createInstanceOverrideState(),\n componentPropertyDefinitions: [],\n componentPropertyReferences: [],\n componentPropertyAssignments: {},\n componentPropertyValues: {},\n componentKey: null,\n sourceLibraryKey: null,\n publishId: null,\n overrideKey: null,\n sharedSymbolVersion: null,\n publishedVersion: null,\n librarySource: null,\n libraryLayerId: null,\n isPublishable: false,\n isSymbolPublishable: false,\n isExposedInstance: false,\n symbolDescription: '',\n symbolLinks: [],\n variantPropSpecs: [],\n boundVariables: {},\n variableBindingScales: {},\n variableAssignmentScales: {},\n componentScale: 1,\n variableModes: {},\n exportSettings: [],\n status: null,\n pluginData: [],\n pluginRelaunchData: [],\n internalOnly: false,\n flipX: false,\n flipY: false,\n textPicture: null,\n derivedTextGlyphs: null,\n derivedTextHeight: null,\n textPathData: null,\n textPathBox: null,\n booleanOperation: undefined\n } satisfies CompleteNodeFields\n return { ...defaults, ...overrides }\n}\n\n/** Containers whose bounds follow their children and that set no coordinate space, as in Figma. */\nexport const FITTED_CONTAINER_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'GROUP',\n 'BOOLEAN_OPERATION'\n])\n\n/** Layers whose stroke can take a weight per side, as Figma's `strokeTopWeight` and its siblings. */\nexport const SIDE_STROKE_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'RECTANGLE',\n 'FRAME',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\n/** The kinds that hold layers of their own on the canvas: what a shadow or a clip encloses. */\nexport const LAYER_CONTAINER_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'FRAME',\n 'GROUP',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\nexport function isLayerContainer(node: Pick<SceneNode, 'type'>): boolean {\n return LAYER_CONTAINER_TYPES.has(node.type)\n}\n\n/** The kinds that clip their children when their clip content is on. */\nexport const CLIPPING_TYPES: ReadonlySet<NodeType> = new Set<NodeType>([\n 'FRAME',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n\n/**\n * Whether a layer clips its children: a frame, component, component set or instance with clip\n * content on. A section or group has no such setting in Figma and never clips, whatever an import\n * left in `clipsContent` (Figma desktop, live).\n */\nexport function clipsChildren(node: Pick<SceneNode, 'type' | 'clipsContent'>): boolean {\n return node.clipsContent && CLIPPING_TYPES.has(node.type)\n}\n\nexport const CONTAINER_TYPES = new Set<NodeType>([\n 'CANVAS',\n 'FRAME',\n 'GROUP',\n 'BOOLEAN_OPERATION',\n 'SECTION',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE'\n])\n"],"mappings":";;;;AAUA,SAAgB,8BAA8C;CAC5D,OAAO;EACL,QAAQ;EACR,IAA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../../src/outline/flatten.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"flatten.d.ts","names":[],"sources":["../../src/outline/flatten.ts"],"mappings":";;;;iBAsCgB,cACd,SAAS,eACT,eACA,oBACC;;;;;iBAoBa,WAAW,SAAS,eAAe,gBAAgB,oBAAoB;;iBAiDvE,aAAa,MAAM,YAAY,oBAAoB"}
|