@pairdraw/scene-graph 0.19.0 → 0.19.2
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/behaviours/index.d.ts +2 -2
- package/dist/behaviours/index.js +2 -2
- package/dist/behaviours/spec.d.ts +6 -1
- package/dist/behaviours/spec.d.ts.map +1 -1
- package/dist/behaviours/spec.js +62 -5
- package/dist/behaviours/spec.js.map +1 -1
- package/dist/canvas-layout.js +66 -0
- package/dist/canvas-layout.js.map +1 -0
- package/dist/coordinate.js +1 -1
- package/dist/css/index.d.ts +2 -2
- package/dist/css/index.js +2 -2
- package/dist/css/text.d.ts +6 -1
- package/dist/css/text.d.ts.map +1 -1
- package/dist/css/text.js +20 -1
- package/dist/css/text.js.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +2 -2
- package/dist/generated/shape-with-text.d.ts +7 -2
- package/dist/generated/shape-with-text.d.ts.map +1 -1
- package/dist/generated/shape-with-text.js +20 -3
- package/dist/generated/shape-with-text.js.map +1 -1
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +11 -5
- package/dist/graph.js.map +1 -1
- package/dist/group-bounds.d.ts +4 -1
- package/dist/group-bounds.d.ts.map +1 -1
- package/dist/group-bounds.js +11 -1
- package/dist/group-bounds.js.map +1 -1
- package/dist/hit-test.d.ts.map +1 -1
- package/dist/hit-test.js +47 -24
- package/dist/hit-test.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/node-defaults.d.ts +21 -1
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +22 -14
- package/dist/node-defaults.js.map +1 -1
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +3 -6
- package/dist/resize.js.map +1 -1
- package/dist/scaling/node.d.ts.map +1 -1
- package/dist/scaling/node.js +23 -3
- package/dist/scaling/node.js.map +1 -1
- package/dist/shared-styles.d.ts +3 -1
- package/dist/shared-styles.d.ts.map +1 -1
- package/dist/shared-styles.js +7 -1
- package/dist/shared-styles.js.map +1 -1
- package/dist/text/path.js +11 -0
- package/dist/text/path.js.map +1 -0
- package/dist/text/picture.d.ts.map +1 -1
- package/dist/text/picture.js +5 -5
- package/dist/text/picture.js.map +1 -1
- package/dist/transfer/copied.d.ts +14 -0
- package/dist/transfer/copied.d.ts.map +1 -0
- package/dist/transfer/copied.js +52 -0
- package/dist/transfer/copied.js.map +1 -0
- package/dist/transfer/index.d.ts +2 -1
- package/dist/transfer/index.js +2 -1
- package/dist/transfer/nodes.js +7 -0
- package/dist/transfer/nodes.js.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/undo.d.ts +6 -0
- package/dist/undo.d.ts.map +1 -1
- package/dist/undo.js +13 -0
- package/dist/undo.js.map +1 -1
- package/dist/variables/index.d.ts.map +1 -1
- package/dist/variables/index.js.map +1 -1
- package/package.json +1 -1
- package/src/behaviours/spec.ts +94 -4
- package/src/canvas-layout.ts +76 -0
- package/src/css/index.ts +6 -1
- package/src/css/text.ts +24 -0
- package/src/generated/shape-with-text.ts +28 -2
- package/src/graph.ts +14 -4
- package/src/group-bounds.ts +13 -0
- package/src/hit-test.ts +95 -39
- package/src/node-defaults.ts +22 -13
- package/src/resize.ts +3 -14
- package/src/scaling/node.ts +27 -3
- package/src/shared-styles.ts +8 -0
- package/src/text/path.ts +14 -0
- package/src/text/picture.ts +5 -2
- package/src/transfer/copied.ts +72 -0
- package/src/transfer/index.ts +1 -0
- package/src/transfer/nodes.ts +10 -0
- package/src/types.ts +2 -1
- package/src/undo.ts +11 -0
- package/src/variables/index.ts +1 -4
package/dist/scaling/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","names":[],"sources":["../../src/scaling/node.ts"],"sourcesContent":["import { scaleGeometryPaths } from '../copy'\nimport { scaledPathTextChanges } from '../resize'\nimport { scaledTextLength } from '../text/lengths'\nimport { TEXT_PARAGRAPH_SPACING_FIELDS } from '../text/paragraphs'\nimport {\n type Effect,\n type Fill,\n type GridTrack,\n type LayoutGrid,\n type SceneNode,\n type Stroke,\n type StyleRun,\n type TextParagraphStyle\n} from '../types'\nimport { cloneVectorNetwork } from '../vector-network'\n\nfunction scaledOptional(value: number | null, scale: number): number | null {\n return value == null ? null : value * scale\n}\n\nfunction scaledStrokes(strokes: readonly Stroke[], scale: number): Stroke[] {\n return strokes.map((stroke) => ({\n ...structuredClone(stroke),\n weight: stroke.weight * scale,\n dashPattern: stroke.dashPattern?.map((value) => value * scale)\n }))\n}\n\nfunction scaledEffects(effects: readonly Effect[], scale: number): Effect[] {\n return effects.map((effect) => {\n const copy = structuredClone(effect)\n // A shader effect has no geometry of its own; only a shadow's measures follow the layer.\n if (copy.type === 'SHADER') return copy\n copy.offset = { x: copy.offset.x * scale, y: copy.offset.y * scale }\n copy.radius *= scale\n copy.spread *= scale\n return copy\n })\n}\n\nfunction scaledFills(fills: readonly Fill[], scale: number): Fill[] {\n return fills.map((fill) => ({\n ...structuredClone(fill),\n scale: fill.scale == null ? undefined : fill.scale * scale,\n spacing: fill.spacing == null ? undefined : fill.spacing * scale,\n patternSpacing: fill.patternSpacing\n ? { x: fill.patternSpacing.x * scale, y: fill.patternSpacing.y * scale }\n : undefined,\n noiseSize: fill.noiseSize\n ? { x: fill.noiseSize.x * scale, y: fill.noiseSize.y * scale }\n : undefined\n }))\n}\n\nfunction scaledStyleRuns(styleRuns: readonly StyleRun[], scale: number): StyleRun[] {\n return styleRuns.map((run) => ({\n ...structuredClone(run),\n style: {\n ...structuredClone(run.style),\n fontSize: run.style.fontSize == null ? undefined : run.style.fontSize * scale,\n letterSpacing: run.style.letterSpacing && scaledTextLength(run.style.letterSpacing, scale),\n lineHeight: run.style.lineHeight && scaledTextLength(run.style.lineHeight, scale),\n textDecorationThickness: scaledOptional(run.style.textDecorationThickness ?? null, scale),\n textUnderlineOffset: scaledOptional(run.style.textUnderlineOffset ?? null, scale)\n }\n }))\n}\n\nfunction scaledParagraphStyles(\n paragraphs: readonly TextParagraphStyle[],\n scale: number\n): TextParagraphStyle[] {\n return paragraphs.map((style) => {\n const scaled = { ...style }\n for (const field of TEXT_PARAGRAPH_SPACING_FIELDS) {\n const value = style[field]\n if (value !== undefined) scaled[field] = value * scale\n }\n return scaled\n })\n}\n\nfunction scaledLayoutGrids(grids: readonly LayoutGrid[], scale: number): LayoutGrid[] {\n return grids.map((grid) => ({\n ...structuredClone(grid),\n offset: grid.offset == null ? undefined : grid.offset * scale,\n sectionSize: grid.sectionSize == null ? undefined : grid.sectionSize * scale,\n gutterSize: grid.gutterSize == null ? undefined : grid.gutterSize * scale\n }))\n}\n\nfunction scaledGridTracks(tracks: readonly GridTrack[], scale: number): GridTrack[] {\n return tracks.map((track) => ({\n ...track,\n value: track.sizing === 'FIXED' ? track.value * scale : track.value\n }))\n}\n\nfunction scaledVectorNetwork(node: SceneNode, scale: number): SceneNode['vectorNetwork'] {\n if (!node.vectorNetwork) return null\n const network = cloneVectorNetwork(node.vectorNetwork)\n for (const vertex of network.vertices) {\n vertex.x *= scale\n vertex.y *= scale\n }\n for (const segment of network.segments) {\n segment.tangentStart.x *= scale\n segment.tangentStart.y *= scale\n segment.tangentEnd.x *= scale\n segment.tangentEnd.y *= scale\n }\n return network\n}\n\nexport function scaleNodeChanges(\n node: SceneNode,\n scale: number,\n scalePosition: boolean\n): Partial<SceneNode> {\n return {\n x: scalePosition ? node.x * scale : node.x,\n y: scalePosition ? node.y * scale : node.y,\n width: node.width * scale,\n height: node.height * scale,\n minWidth: scaledOptional(node.minWidth, scale),\n maxWidth: scaledOptional(node.maxWidth, scale),\n minHeight: scaledOptional(node.minHeight, scale),\n maxHeight: scaledOptional(node.maxHeight, scale),\n cornerRadius: node.cornerRadius * scale,\n topLeftRadius: node.topLeftRadius * scale,\n topRightRadius: node.topRightRadius * scale,\n bottomRightRadius: node.bottomRightRadius * scale,\n bottomLeftRadius: node.bottomLeftRadius * scale,\n fontSize: node.fontSize * scale,\n letterSpacing: scaledTextLength(node.letterSpacing, scale),\n lineHeight: node.lineHeight && scaledTextLength(node.lineHeight, scale),\n textDecorationThickness: scaledOptional(node.textDecorationThickness, scale),\n textUnderlineOffset: scaledOptional(node.textUnderlineOffset, scale),\n styleRuns: scaledStyleRuns(node.styleRuns, scale),\n listSpacing: node.listSpacing * scale,\n paragraphSpacing: node.paragraphSpacing * scale,\n paragraphIndent: node.paragraphIndent * scale,\n textParagraphs: scaledParagraphStyles(node.textParagraphs, scale),\n itemSpacing: node.itemSpacing * scale,\n counterAxisSpacing: node.counterAxisSpacing * scale,\n paddingTop: node.paddingTop * scale,\n paddingRight: node.paddingRight * scale,\n paddingBottom: node.paddingBottom * scale,\n paddingLeft: node.paddingLeft * scale,\n gridColumnGap: node.gridColumnGap * scale,\n gridRowGap: node.gridRowGap * scale,\n gridTemplateColumns: scaledGridTracks(node.gridTemplateColumns, scale),\n gridTemplateRows: scaledGridTracks(node.gridTemplateRows, scale),\n strokes: scaledStrokes(node.strokes, scale),\n strokeWeight: node.strokeWeight * scale,\n dashPattern: node.dashPattern.map((value) => value * scale),\n borderTopWeight: node.borderTopWeight * scale,\n borderRightWeight: node.borderRightWeight * scale,\n borderBottomWeight: node.borderBottomWeight * scale,\n borderLeftWeight: node.borderLeftWeight * scale,\n strokeMiterLimit: node.strokeMiterLimit,\n effects: scaledEffects(node.effects, scale),\n fills: scaledFills(node.fills, scale),\n layoutGrids: scaledLayoutGrids(node.layoutGrids, scale),\n vectorNetwork: scaledVectorNetwork(node, scale),\n fillGeometry: scaleGeometryPaths(node.fillGeometry, scale, scale),\n strokeGeometry: scaleGeometryPaths(node.strokeGeometry, scale, scale),\n ...scaledPathTextChanges(node, scale, scale)\n }\n}\n"],"mappings":";;;;;;AAgBA,SAAS,eAAe,OAAsB,OAA8B;CAC1E,OAAO,SAAS,OAAO,OAAO,QAAQ;AACxC;AAEA,SAAS,cAAc,SAA4B,OAAyB;CAC1E,OAAO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AkB,KAAK;EACvB,SAAS,cAAc,KAAK,SAAS,KAAK;EAC1C,OAAO,YAAY,KAAK,OAAO,KAAK;EACpC,aAAa,kBAAkB,KAAK,aAAa,KAAK;EACtD,eAAe,oBAAoB,MAAM,KAAK;EAC9C,cAAc,mBAAmB,KAAK,cAAc,OAAO,KAAK;EAChE,gBAAgB,mBAAmB,KAAK,gBAAgB,OAAO,KAAK;EACpE,GAAG,sBAAsB,MAAM,OAAO,KAAK;CAC7C;AACF"}
|
|
1
|
+
{"version":3,"file":"node.js","names":[],"sources":["../../src/scaling/node.ts"],"sourcesContent":["import { copyDerivedGlyphs, scaleGeometryPaths } from '../copy'\nimport { scaledTextLength } from '../text/lengths'\nimport { TEXT_PARAGRAPH_SPACING_FIELDS } from '../text/paragraphs'\nimport { followsPath } from '../text/path'\nimport {\n type Effect,\n type Fill,\n type GridTrack,\n type LayoutGrid,\n type SceneNode,\n type Stroke,\n type StyleRun,\n type TextParagraphStyle\n} from '../types'\nimport { cloneVectorNetwork } from '../vector-network'\n\nfunction scaledPathText(node: SceneNode, scale: number): Partial<SceneNode> {\n if (!node.textPathData && !followsPath(node)) {\n return {}\n }\n const box = node.textPathBox\n return {\n derivedTextGlyphs:\n copyDerivedGlyphs(node.derivedTextGlyphs)?.map((glyph) => ({\n ...glyph,\n x: glyph.x * scale,\n y: glyph.y * scale,\n fontSize: glyph.fontSize * scale,\n ...(glyph.advance === undefined ? {} : { advance: glyph.advance * scale })\n })) ?? null,\n textPathBox: box && {\n x: box.x * scale,\n y: box.y * scale,\n width: box.width * scale,\n height: box.height * scale\n }\n }\n}\n\nfunction scaledOptional(value: number | null, scale: number): number | null {\n return value == null ? null : value * scale\n}\n\nfunction scaledStrokes(strokes: readonly Stroke[], scale: number): Stroke[] {\n return strokes.map((stroke) => ({\n ...structuredClone(stroke),\n weight: stroke.weight * scale,\n dashPattern: stroke.dashPattern?.map((value) => value * scale)\n }))\n}\n\nfunction scaledEffects(effects: readonly Effect[], scale: number): Effect[] {\n return effects.map((effect) => {\n const copy = structuredClone(effect)\n // A shader effect has no geometry of its own; only a shadow's measures follow the layer.\n if (copy.type === 'SHADER') return copy\n copy.offset = { x: copy.offset.x * scale, y: copy.offset.y * scale }\n copy.radius *= scale\n copy.spread *= scale\n return copy\n })\n}\n\nfunction scaledFills(fills: readonly Fill[], scale: number): Fill[] {\n return fills.map((fill) => ({\n ...structuredClone(fill),\n scale: fill.scale == null ? undefined : fill.scale * scale,\n spacing: fill.spacing == null ? undefined : fill.spacing * scale,\n patternSpacing: fill.patternSpacing\n ? { x: fill.patternSpacing.x * scale, y: fill.patternSpacing.y * scale }\n : undefined,\n noiseSize: fill.noiseSize\n ? { x: fill.noiseSize.x * scale, y: fill.noiseSize.y * scale }\n : undefined\n }))\n}\n\nfunction scaledStyleRuns(styleRuns: readonly StyleRun[], scale: number): StyleRun[] {\n return styleRuns.map((run) => ({\n ...structuredClone(run),\n style: {\n ...structuredClone(run.style),\n fontSize: run.style.fontSize == null ? undefined : run.style.fontSize * scale,\n letterSpacing: run.style.letterSpacing && scaledTextLength(run.style.letterSpacing, scale),\n lineHeight: run.style.lineHeight && scaledTextLength(run.style.lineHeight, scale),\n textDecorationThickness: scaledOptional(run.style.textDecorationThickness ?? null, scale),\n textUnderlineOffset: scaledOptional(run.style.textUnderlineOffset ?? null, scale)\n }\n }))\n}\n\nfunction scaledParagraphStyles(\n paragraphs: readonly TextParagraphStyle[],\n scale: number\n): TextParagraphStyle[] {\n return paragraphs.map((style) => {\n const scaled = { ...style }\n for (const field of TEXT_PARAGRAPH_SPACING_FIELDS) {\n const value = style[field]\n if (value !== undefined) scaled[field] = value * scale\n }\n return scaled\n })\n}\n\nfunction scaledLayoutGrids(grids: readonly LayoutGrid[], scale: number): LayoutGrid[] {\n return grids.map((grid) => ({\n ...structuredClone(grid),\n offset: grid.offset == null ? undefined : grid.offset * scale,\n sectionSize: grid.sectionSize == null ? undefined : grid.sectionSize * scale,\n gutterSize: grid.gutterSize == null ? undefined : grid.gutterSize * scale\n }))\n}\n\nfunction scaledGridTracks(tracks: readonly GridTrack[], scale: number): GridTrack[] {\n return tracks.map((track) => ({\n ...track,\n value: track.sizing === 'FIXED' ? track.value * scale : track.value\n }))\n}\n\nfunction scaledVectorNetwork(node: SceneNode, scale: number): SceneNode['vectorNetwork'] {\n if (!node.vectorNetwork) return null\n const network = cloneVectorNetwork(node.vectorNetwork)\n for (const vertex of network.vertices) {\n vertex.x *= scale\n vertex.y *= scale\n }\n for (const segment of network.segments) {\n segment.tangentStart.x *= scale\n segment.tangentStart.y *= scale\n segment.tangentEnd.x *= scale\n segment.tangentEnd.y *= scale\n }\n return network\n}\n\nexport function scaleNodeChanges(\n node: SceneNode,\n scale: number,\n scalePosition: boolean\n): Partial<SceneNode> {\n return {\n x: scalePosition ? node.x * scale : node.x,\n y: scalePosition ? node.y * scale : node.y,\n width: node.width * scale,\n height: node.height * scale,\n minWidth: scaledOptional(node.minWidth, scale),\n maxWidth: scaledOptional(node.maxWidth, scale),\n minHeight: scaledOptional(node.minHeight, scale),\n maxHeight: scaledOptional(node.maxHeight, scale),\n cornerRadius: node.cornerRadius * scale,\n topLeftRadius: node.topLeftRadius * scale,\n topRightRadius: node.topRightRadius * scale,\n bottomRightRadius: node.bottomRightRadius * scale,\n bottomLeftRadius: node.bottomLeftRadius * scale,\n fontSize: node.fontSize * scale,\n letterSpacing: scaledTextLength(node.letterSpacing, scale),\n lineHeight: node.lineHeight && scaledTextLength(node.lineHeight, scale),\n textDecorationThickness: scaledOptional(node.textDecorationThickness, scale),\n textUnderlineOffset: scaledOptional(node.textUnderlineOffset, scale),\n styleRuns: scaledStyleRuns(node.styleRuns, scale),\n listSpacing: node.listSpacing * scale,\n paragraphSpacing: node.paragraphSpacing * scale,\n paragraphIndent: node.paragraphIndent * scale,\n textParagraphs: scaledParagraphStyles(node.textParagraphs, scale),\n derivedTextHeight: scaledOptional(node.derivedTextHeight, scale),\n itemSpacing: node.itemSpacing * scale,\n counterAxisSpacing: node.counterAxisSpacing * scale,\n paddingTop: node.paddingTop * scale,\n paddingRight: node.paddingRight * scale,\n paddingBottom: node.paddingBottom * scale,\n paddingLeft: node.paddingLeft * scale,\n gridColumnGap: node.gridColumnGap * scale,\n gridRowGap: node.gridRowGap * scale,\n gridTemplateColumns: scaledGridTracks(node.gridTemplateColumns, scale),\n gridTemplateRows: scaledGridTracks(node.gridTemplateRows, scale),\n strokes: scaledStrokes(node.strokes, scale),\n strokeWeight: node.strokeWeight * scale,\n dashPattern: node.dashPattern.map((value) => value * scale),\n borderTopWeight: node.borderTopWeight * scale,\n borderRightWeight: node.borderRightWeight * scale,\n borderBottomWeight: node.borderBottomWeight * scale,\n borderLeftWeight: node.borderLeftWeight * scale,\n strokeMiterLimit: node.strokeMiterLimit,\n effects: scaledEffects(node.effects, scale),\n fills: scaledFills(node.fills, scale),\n layoutGrids: scaledLayoutGrids(node.layoutGrids, scale),\n vectorNetwork: scaledVectorNetwork(node, scale),\n fillGeometry: scaleGeometryPaths(node.fillGeometry, scale, scale),\n strokeGeometry: scaleGeometryPaths(node.strokeGeometry, scale, scale),\n ...scaledPathText(node, scale)\n }\n}\n"],"mappings":";;;;;;AAgBA,SAAS,eAAe,MAAiB,OAAmC;CAC1E,IAAI,CAAC,KAAK,gBAAgB,CAAC,YAAY,IAAI,GACzC,OAAO,CAAC;CAEV,MAAM,MAAM,KAAK;CACjB,OAAO;EACL,mBACE,kBAAkB,KAAK,iBAAiB,CAAC,EAAE,KAAK,WAAW;GACzD,GAAG;GACH,GAAG,MAAM,IAAI;GACb,GAAG,MAAM,IAAI;GACb,UAAU,MAAM,WAAW;GAC3B,GAAI,MAAM,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,MAAM,UAAU,MAAM;EAC1E,EAAE,KAAK;EACT,aAAa,OAAO;GAClB,GAAG,IAAI,IAAI;GACX,GAAG,IAAI,IAAI;GACX,OAAO,IAAI,QAAQ;GACnB,QAAQ,IAAI,SAAS;EACvB;CACF;AACF;A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,YAAY,KAAK,UAAU,QAAQ,KAAK;EAC1D,iBAAiB,KAAK,kBAAkB;EACxC,mBAAmB,KAAK,oBAAoB;EAC5C,oBAAoB,KAAK,qBAAqB;EAC9C,kBAAkB,KAAK,mBAAmB;EAC1C,kBAAkB,KAAK;EACvB,SAAS,cAAc,KAAK,SAAS,KAAK;EAC1C,OAAO,YAAY,KAAK,OAAO,KAAK;EACpC,aAAa,kBAAkB,KAAK,aAAa,KAAK;EACtD,eAAe,oBAAoB,MAAM,KAAK;EAC9C,cAAc,mBAAmB,KAAK,cAAc,OAAO,KAAK;EAChE,gBAAgB,mBAAmB,KAAK,gBAAgB,OAAO,KAAK;EACpE,GAAG,eAAe,MAAM,KAAK;CAC/B;AACF"}
|
package/dist/shared-styles.d.ts
CHANGED
|
@@ -29,8 +29,10 @@ declare const FACE_KEYS: readonly ["fontFamily", "fontWeight", "italic"];
|
|
|
29
29
|
declare function rangeFontStyle(node: Pick<SceneNode, 'fontStyle'>, style: CharacterStyleOverride): string | null;
|
|
30
30
|
declare function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind];
|
|
31
31
|
declare function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType;
|
|
32
|
+
/** The document's shared style layers, by the source ID layers link them by. */
|
|
33
|
+
declare function sharedStyleLayers(graph: SceneGraph): Map<string, SceneNode>;
|
|
32
34
|
declare function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[];
|
|
33
35
|
declare function styleDetachmentChanges(node: SceneNode, changes: Partial<SceneNode>): Partial<SceneNode>;
|
|
34
36
|
//#endregion
|
|
35
|
-
export { FACE_KEYS, SHARED_STYLE_FIELDS, SHARED_TEXT_STYLE_FIELDS, STYLE_LINK_FIELDS, getSharedStyles, rangeFontStyle, sharedStyleRefKey, sharedStyleTypeForKind, styleDetachmentChanges };
|
|
37
|
+
export { FACE_KEYS, SHARED_STYLE_FIELDS, SHARED_TEXT_STYLE_FIELDS, STYLE_LINK_FIELDS, getSharedStyles, rangeFontStyle, sharedStyleLayers, sharedStyleRefKey, sharedStyleTypeForKind, styleDetachmentChanges };
|
|
36
38
|
//# sourceMappingURL=shared-styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-styles.d.ts","names":[],"sources":["../src/shared-styles.ts"],"mappings":";;;cAaM;;;;;;;;cASO;;cAWA;;cAwBA;;;;;;;;cASA;;;;;iBAUG,eACd,MAAM,KAAK,yBACX,OAAO;iBAMO,kBAAkB,MAAM,0BAA0B,gBAAgB;iBAIlE,uBAAuB,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"shared-styles.d.ts","names":[],"sources":["../src/shared-styles.ts"],"mappings":";;;cAaM;;;;;;;;cASO;;cAWA;;cAwBA;;;;;;;;cASA;;;;;iBAUG,eACd,MAAM,KAAK,yBACX,OAAO;iBAMO,kBAAkB,MAAM,0BAA0B,gBAAgB;iBAIlE,uBAAuB,MAAM,kBAAkB;;iBAK/C,kBAAkB,OAAO,aAAa,YAAY;iBAOlD,gBAAgB,OAAO,YAAY,MAAM,kBAAkB;iBAuB3D,uBACd,MAAM,WACN,SAAS,QAAQ,aAChB,QAAQ"}
|
package/dist/shared-styles.js
CHANGED
|
@@ -67,6 +67,12 @@ function sharedStyleRefKey(kind) {
|
|
|
67
67
|
function sharedStyleTypeForKind(kind) {
|
|
68
68
|
return STYLE_TYPES[kind];
|
|
69
69
|
}
|
|
70
|
+
/** The document's shared style layers, by the source ID layers link them by. */
|
|
71
|
+
function sharedStyleLayers(graph) {
|
|
72
|
+
const styles = /* @__PURE__ */ new Map();
|
|
73
|
+
for (const node of graph.getAllNodes()) if (node.sharedStyleType !== null && node.source.id) styles.set(node.source.id, node);
|
|
74
|
+
return styles;
|
|
75
|
+
}
|
|
70
76
|
function getSharedStyles(graph, kind) {
|
|
71
77
|
const type = sharedStyleTypeForKind(kind);
|
|
72
78
|
const styles = [];
|
|
@@ -104,6 +110,6 @@ function styleDetachmentChanges(node, changes) {
|
|
|
104
110
|
return next;
|
|
105
111
|
}
|
|
106
112
|
//#endregion
|
|
107
|
-
export { FACE_KEYS, SHARED_STYLE_FIELDS, SHARED_TEXT_STYLE_FIELDS, STYLE_LINK_FIELDS, getSharedStyles, rangeFontStyle, sharedStyleRefKey, sharedStyleTypeForKind, styleDetachmentChanges };
|
|
113
|
+
export { FACE_KEYS, SHARED_STYLE_FIELDS, SHARED_TEXT_STYLE_FIELDS, STYLE_LINK_FIELDS, getSharedStyles, rangeFontStyle, sharedStyleLayers, sharedStyleRefKey, sharedStyleTypeForKind, styleDetachmentChanges };
|
|
108
114
|
|
|
109
115
|
//# sourceMappingURL=shared-styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-styles.js","names":[],"sources":["../src/shared-styles.ts"],"sourcesContent":["import { isEqual, omit } from 'es-toolkit'\n\nimport type { SceneGraph } from './graph'\nimport { STROKE_LINE_KEYS } from './strokes'\nimport type {\n CharacterStyleOverride,\n SceneNode,\n SharedStyle,\n SharedStyleKind,\n SharedStyleType,\n Stroke\n} from './types'\n\nconst STYLE_REF_KEYS = {\n fill: 'fillStyleId',\n stroke: 'strokeStyleId',\n text: 'textStyleId',\n effect: 'effectStyleId',\n grid: 'gridStyleId'\n} as const satisfies Record<SharedStyleKind, keyof SceneNode>\n\n/** The fields that link a layer to its shared styles. */\nexport const STYLE_LINK_FIELDS = Object.values(STYLE_REF_KEYS)\n\nconst STYLE_TYPES = {\n fill: 'FILL',\n stroke: 'FILL',\n text: 'TEXT',\n effect: 'EFFECT',\n grid: 'GRID'\n} as const satisfies Record<SharedStyleKind, SharedStyleType>\n\n/** The fields a text style gives what uses it; changing one leaves the style. */\nexport const SHARED_TEXT_STYLE_FIELDS = [\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'fontStyle',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textDecoration',\n 'textCase',\n 'fontFeatures'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/**\n * The paragraph fields a text style also gives the whole text; a range takes only the character\n * ones. Changing one leaves the style, and a cleared style resets them (live-verified).\n */\nconst TEXT_STYLE_PARAGRAPH_FIELDS = [\n 'paragraphSpacing',\n 'paragraphIndent',\n 'listSpacing'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** The fields each kind of shared style gives what uses it; changing one leaves the style. */\nexport const SHARED_STYLE_FIELDS = {\n fill: ['fills'],\n stroke: ['strokes'],\n text: [...SHARED_TEXT_STYLE_FIELDS, ...TEXT_STYLE_PARAGRAPH_FIELDS],\n effect: ['effects'],\n grid: ['layoutGrids']\n} as const satisfies Record<SharedStyleKind, readonly (keyof SceneNode)[]>\n\n/** The fields that pick a text's face, which its style name names. */\nexport const FACE_KEYS = [\n 'fontFamily',\n 'fontWeight',\n 'italic'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/**\n * The face name of characters with `style` over the text: their own, none where they set another\n * face without one (as ranges from HTML or `.pen` do), else the text's.\n */\nexport function rangeFontStyle(\n node: Pick<SceneNode, 'fontStyle'>,\n style: CharacterStyleOverride\n): string | null {\n if (style.fontStyle !== undefined) return style.fontStyle\n return FACE_KEYS.some((key) => style[key] !== undefined) ? null : node.fontStyle\n}\n\nexport function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind] {\n return STYLE_REF_KEYS[kind]\n}\n\nexport function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType {\n return STYLE_TYPES[kind]\n}\n\nexport function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[] {\n const type = sharedStyleTypeForKind(kind)\n const styles: SharedStyle[] = []\n for (const node of graph.getAllNodes()) {\n if (node.sharedStyleType !== type || !node.source.id) continue\n styles.push({ id: node.source.id, nodeId: node.id, name: node.name, type })\n }\n return styles.sort((left, right) => left.name.localeCompare(right.name))\n}\n\n/**\n * Whether new strokes only change how their lines run, keeping every paint. A stroke style gives\n * paints only, so such a write keeps it; any other strokes write leaves it, as setting even the\n * same paints does in Figma (live-verified).\n */\nfunction restylesStrokeLines(current: readonly Stroke[], next: readonly Stroke[]): boolean {\n const paints = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => omit(stroke, STROKE_LINE_KEYS))\n const lines = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => STROKE_LINE_KEYS.map((key) => stroke[key]))\n return isEqual(paints(current), paints(next)) && !isEqual(lines(current), lines(next))\n}\n\nexport function styleDetachmentChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const next = { ...changes }\n for (const [kind, fields] of Object.entries(SHARED_STYLE_FIELDS)) {\n const reference = STYLE_REF_KEYS[kind as SharedStyleKind]\n if (reference in changes || !node[reference]) continue\n if (!fields.some((field) => field in changes)) continue\n if (kind === 'stroke' && changes.strokes && restylesStrokeLines(node.strokes, changes.strokes))\n continue\n next[reference] = null\n }\n // A face named for another family, weight, or slant names none; the new one takes its own name.\n const changesFace = FACE_KEYS.some((key) => key in changes && changes[key] !== node[key])\n if (changesFace && !('fontStyle' in changes) && node.fontStyle) {\n next.fontStyle = null\n }\n return next\n}\n"],"mappings":";;;AAaA,MAAM,iBAAiB;CACrB,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,oBAAoB,OAAO,OAAO,cAAc;AAE7D,MAAM,cAAc;CAClB,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,2BAA2B;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,8BAA8B;CAClC;CACA;CACA;AACF;;AAGA,MAAa,sBAAsB;CACjC,MAAM,CAAC,OAAO;CACd,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,GAAG,0BAA0B,GAAG,2BAA2B;CAClE,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,aAAa;AACtB;;A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OAAO,GAAG;EAC/C,IAAI,SAAS,YAAY,QAAQ,WAAW,oBAAoB,KAAK,SAAS,QAAQ,OAAO,GAC3F;EACF,KAAK,aAAa;CACpB;CAGA,IADoB,UAAU,MAAM,QAAQ,OAAO,WAAW,QAAQ,SAAS,KAAK,IACtE,KAAK,EAAE,eAAe,YAAY,KAAK,WACnD,KAAK,YAAY;CAEnB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"shared-styles.js","names":[],"sources":["../src/shared-styles.ts"],"sourcesContent":["import { isEqual, omit } from 'es-toolkit'\n\nimport type { SceneGraph } from './graph'\nimport { STROKE_LINE_KEYS } from './strokes'\nimport type {\n CharacterStyleOverride,\n SceneNode,\n SharedStyle,\n SharedStyleKind,\n SharedStyleType,\n Stroke\n} from './types'\n\nconst STYLE_REF_KEYS = {\n fill: 'fillStyleId',\n stroke: 'strokeStyleId',\n text: 'textStyleId',\n effect: 'effectStyleId',\n grid: 'gridStyleId'\n} as const satisfies Record<SharedStyleKind, keyof SceneNode>\n\n/** The fields that link a layer to its shared styles. */\nexport const STYLE_LINK_FIELDS = Object.values(STYLE_REF_KEYS)\n\nconst STYLE_TYPES = {\n fill: 'FILL',\n stroke: 'FILL',\n text: 'TEXT',\n effect: 'EFFECT',\n grid: 'GRID'\n} as const satisfies Record<SharedStyleKind, SharedStyleType>\n\n/** The fields a text style gives what uses it; changing one leaves the style. */\nexport const SHARED_TEXT_STYLE_FIELDS = [\n 'fontFamily',\n 'fontWeight',\n 'italic',\n 'fontStyle',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textDecoration',\n 'textCase',\n 'fontFeatures'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/**\n * The paragraph fields a text style also gives the whole text; a range takes only the character\n * ones. Changing one leaves the style, and a cleared style resets them (live-verified).\n */\nconst TEXT_STYLE_PARAGRAPH_FIELDS = [\n 'paragraphSpacing',\n 'paragraphIndent',\n 'listSpacing'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** The fields each kind of shared style gives what uses it; changing one leaves the style. */\nexport const SHARED_STYLE_FIELDS = {\n fill: ['fills'],\n stroke: ['strokes'],\n text: [...SHARED_TEXT_STYLE_FIELDS, ...TEXT_STYLE_PARAGRAPH_FIELDS],\n effect: ['effects'],\n grid: ['layoutGrids']\n} as const satisfies Record<SharedStyleKind, readonly (keyof SceneNode)[]>\n\n/** The fields that pick a text's face, which its style name names. */\nexport const FACE_KEYS = [\n 'fontFamily',\n 'fontWeight',\n 'italic'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/**\n * The face name of characters with `style` over the text: their own, none where they set another\n * face without one (as ranges from HTML or `.pen` do), else the text's.\n */\nexport function rangeFontStyle(\n node: Pick<SceneNode, 'fontStyle'>,\n style: CharacterStyleOverride\n): string | null {\n if (style.fontStyle !== undefined) return style.fontStyle\n return FACE_KEYS.some((key) => style[key] !== undefined) ? null : node.fontStyle\n}\n\nexport function sharedStyleRefKey(kind: SharedStyleKind): (typeof STYLE_REF_KEYS)[SharedStyleKind] {\n return STYLE_REF_KEYS[kind]\n}\n\nexport function sharedStyleTypeForKind(kind: SharedStyleKind): SharedStyleType {\n return STYLE_TYPES[kind]\n}\n\n/** The document's shared style layers, by the source ID layers link them by. */\nexport function sharedStyleLayers(graph: SceneGraph): Map<string, SceneNode> {\n const styles = new Map<string, SceneNode>()\n for (const node of graph.getAllNodes())\n if (node.sharedStyleType !== null && node.source.id) styles.set(node.source.id, node)\n return styles\n}\n\nexport function getSharedStyles(graph: SceneGraph, kind: SharedStyleKind): SharedStyle[] {\n const type = sharedStyleTypeForKind(kind)\n const styles: SharedStyle[] = []\n for (const node of graph.getAllNodes()) {\n if (node.sharedStyleType !== type || !node.source.id) continue\n styles.push({ id: node.source.id, nodeId: node.id, name: node.name, type })\n }\n return styles.sort((left, right) => left.name.localeCompare(right.name))\n}\n\n/**\n * Whether new strokes only change how their lines run, keeping every paint. A stroke style gives\n * paints only, so such a write keeps it; any other strokes write leaves it, as setting even the\n * same paints does in Figma (live-verified).\n */\nfunction restylesStrokeLines(current: readonly Stroke[], next: readonly Stroke[]): boolean {\n const paints = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => omit(stroke, STROKE_LINE_KEYS))\n const lines = (strokes: readonly Stroke[]) =>\n strokes.map((stroke) => STROKE_LINE_KEYS.map((key) => stroke[key]))\n return isEqual(paints(current), paints(next)) && !isEqual(lines(current), lines(next))\n}\n\nexport function styleDetachmentChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const next = { ...changes }\n for (const [kind, fields] of Object.entries(SHARED_STYLE_FIELDS)) {\n const reference = STYLE_REF_KEYS[kind as SharedStyleKind]\n if (reference in changes || !node[reference]) continue\n if (!fields.some((field) => field in changes)) continue\n if (kind === 'stroke' && changes.strokes && restylesStrokeLines(node.strokes, changes.strokes))\n continue\n next[reference] = null\n }\n // A face named for another family, weight, or slant names none; the new one takes its own name.\n const changesFace = FACE_KEYS.some((key) => key in changes && changes[key] !== node[key])\n if (changesFace && !('fontStyle' in changes) && node.fontStyle) {\n next.fontStyle = null\n }\n return next\n}\n"],"mappings":";;;AAaA,MAAM,iBAAiB;CACrB,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,oBAAoB,OAAO,OAAO,cAAc;AAE7D,MAAM,cAAc;CAClB,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,2BAA2B;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,8BAA8B;CAClC;CACA;CACA;AACF;;AAGA,MAAa,sBAAsB;CACjC,MAAM,CAAC,OAAO;CACd,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,GAAG,0BAA0B,GAAG,2BAA2B;CAClE,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,aAAa;AACtB;;AAGA,MAAa,YAAY;CACvB;CACA;CACA;AACF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1B,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,mBAAmB,GAAG;EAChE,MAAM,YAAY,eAAe;EACjC,IAAI,aAAa,WAAW,CAAC,KAAK,YAAY;EAC9C,IAAI,CAAC,OAAO,MAAM,UAAU,SAAS,OAAO,GAAG;EAC/C,IAAI,SAAS,YAAY,QAAQ,WAAW,oBAAoB,KAAK,SAAS,QAAQ,OAAO,GAC3F;EACF,KAAK,aAAa;CACpB;CAGA,IADoB,UAAU,MAAM,QAAQ,OAAO,WAAW,QAAQ,SAAS,KAAK,IACtE,KAAK,EAAE,eAAe,YAAY,KAAK,WACnD,KAAK,YAAY;CAEnB,OAAO;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/text/path.ts
|
|
2
|
+
/** Whether the node's glyphs were baked along a path, including rotated-as-a-picture text. */
|
|
3
|
+
function followsPath(node) {
|
|
4
|
+
const glyphs = node.derivedTextGlyphs ?? [];
|
|
5
|
+
if (glyphs.length === 0) return false;
|
|
6
|
+
return !!node.textPathData || !!node.textPathBox || glyphs.some((glyph) => (glyph.rotation ?? 0) !== 0);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { followsPath };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","names":[],"sources":["../../src/text/path.ts"],"sourcesContent":["import type { SceneNode } from '../types'\n\n/** Whether the node's glyphs were baked along a path, including rotated-as-a-picture text. */\nexport function followsPath(\n node: Pick<SceneNode, 'derivedTextGlyphs' | 'textPathData' | 'textPathBox'>\n): boolean {\n const glyphs = node.derivedTextGlyphs ?? []\n if (glyphs.length === 0) {\n return false\n }\n return (\n !!node.textPathData || !!node.textPathBox || glyphs.some((glyph) => (glyph.rotation ?? 0) !== 0)\n )\n}\n"],"mappings":";;AAGA,SAAgB,YACd,MACS;CACT,MAAM,SAAS,KAAK,qBAAqB,CAAC;CAC1C,IAAI,OAAO,WAAW,GACpB,OAAO;CAET,OACE,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC,KAAK,eAAe,OAAO,MAAM,WAAW,MAAM,YAAY,OAAO,CAAC;AAEnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picture.d.ts","names":[],"sources":["../../src/text/picture.ts"],"mappings":";;;;;;cASa,mBAAmB;cAQnB,sBAAsB;;;;;;iBAOnB,6BACd,MAAM,WACN,SAAS,QAAQ,aAChB,QAAQ;
|
|
1
|
+
{"version":3,"file":"picture.d.ts","names":[],"sources":["../../src/text/picture.ts"],"mappings":";;;;;;cASa,mBAAmB;cAQnB,sBAAsB;;;;;;iBAOnB,6BACd,MAAM,WACN,SAAS,QAAQ,aAChB,QAAQ;iBA8BK,qBAAqB,MAAM,WAAW,SAAS,QAAQ"}
|
package/dist/text/picture.js
CHANGED
|
@@ -24,11 +24,11 @@ function textCacheInvalidationChanges(node, changes) {
|
|
|
24
24
|
if (node.textPicture && keys.some((key) => TEXT_PICTURE_KEYS.has(key))) invalidated.textPicture = null;
|
|
25
25
|
const glyphsInvalidated = keys.some((key) => GLYPH_AFFECTING_KEYS.has(key)) || TEXT_LAYOUT_FIELDS.some((key) => keys.includes(key));
|
|
26
26
|
if (glyphsInvalidated && !("derivedLayout" in changes)) invalidated.derivedLayout = null;
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
if (glyphsInvalidated && !changes.derivedTextGlyphs) {
|
|
28
|
+
const onlyPathBoxResize = !!node.textPathData && keys.every((key) => key === "width" || key === "height");
|
|
29
|
+
const placesPath = keys.includes("textPathBox") && !!changes.textPathBox;
|
|
30
|
+
if (node.derivedTextGlyphs && !onlyPathBoxResize) invalidated.derivedTextGlyphs = null;
|
|
31
|
+
if (node.textPathData && !onlyPathBoxResize && !placesPath) invalidated.textPathData = null;
|
|
32
32
|
}
|
|
33
33
|
return invalidated;
|
|
34
34
|
}
|
package/dist/text/picture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picture.js","names":[],"sources":["../../src/text/picture.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport { TEXT_SHAPING_FIELDS, TEXT_LAYOUT_FIELDS } from '../fields/text'\nimport type { SceneNode } from '../types'\n\n/**\n * Invalidate cached Skia textPicture (Paragraph snapshot). Includes width/height\n * because wrapping/layout depends on the box.\n */\nexport const TEXT_PICTURE_KEYS: ReadonlySet<string> = new Set([\n ...TEXT_SHAPING_FIELDS,\n 'textDecoration',\n 'fills',\n 'width',\n 'height'\n])\n\nexport const GLYPH_AFFECTING_KEYS: ReadonlySet<string> = new Set(TEXT_SHAPING_FIELDS)\n\n/**\n * Shared by SceneGraph.updateNode and updateNodePreview (drag hot path) so the\n * two invalidation rules cannot drift. Glyphs are kept when the caller\n * replaces them in the same update (resize supplies scaled copies).\n */\nexport function textCacheInvalidationChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const invalidated: Partial<SceneNode> = {}\n const keys = Object.keys(changes).filter(\n (key) => !isEqual(node[key as keyof SceneNode], changes[key as keyof SceneNode])\n )\n if (node.textPicture && keys.some((key) => TEXT_PICTURE_KEYS.has(key)))\n invalidated.textPicture = null\n const glyphsInvalidated =\n keys.some((key) => GLYPH_AFFECTING_KEYS.has(key)) ||\n TEXT_LAYOUT_FIELDS.some((key) => keys.includes(key))\n if (glyphsInvalidated && !('derivedLayout' in changes)) invalidated.derivedLayout = null\n // A successful path-text edit supplies reflowed glyphs in `changes`. Every\n // other mutation path must drop stale baked glyphs and path identity rather\n // than pair new text/style with old visible outlines.\n if (
|
|
1
|
+
{"version":3,"file":"picture.js","names":[],"sources":["../../src/text/picture.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport { TEXT_SHAPING_FIELDS, TEXT_LAYOUT_FIELDS } from '../fields/text'\nimport type { SceneNode } from '../types'\n\n/**\n * Invalidate cached Skia textPicture (Paragraph snapshot). Includes width/height\n * because wrapping/layout depends on the box.\n */\nexport const TEXT_PICTURE_KEYS: ReadonlySet<string> = new Set([\n ...TEXT_SHAPING_FIELDS,\n 'textDecoration',\n 'fills',\n 'width',\n 'height'\n])\n\nexport const GLYPH_AFFECTING_KEYS: ReadonlySet<string> = new Set(TEXT_SHAPING_FIELDS)\n\n/**\n * Shared by SceneGraph.updateNode and updateNodePreview (drag hot path) so the\n * two invalidation rules cannot drift. Glyphs are kept when the caller\n * replaces them in the same update (resize supplies scaled copies).\n */\nexport function textCacheInvalidationChanges(\n node: SceneNode,\n changes: Partial<SceneNode>\n): Partial<SceneNode> {\n const invalidated: Partial<SceneNode> = {}\n const keys = Object.keys(changes).filter(\n (key) => !isEqual(node[key as keyof SceneNode], changes[key as keyof SceneNode])\n )\n if (node.textPicture && keys.some((key) => TEXT_PICTURE_KEYS.has(key)))\n invalidated.textPicture = null\n const glyphsInvalidated =\n keys.some((key) => GLYPH_AFFECTING_KEYS.has(key)) ||\n TEXT_LAYOUT_FIELDS.some((key) => keys.includes(key))\n if (glyphsInvalidated && !('derivedLayout' in changes)) invalidated.derivedLayout = null\n // A successful path-text edit supplies reflowed glyphs in `changes`. Every\n // other mutation path must drop stale baked glyphs and path identity rather\n // than pair new text/style with old visible outlines.\n if (glyphsInvalidated && !changes.derivedTextGlyphs) {\n // Path-text resize supplies transformed glyphs through the resize workflow. A raw box\n // preview keeps them until that workflow commits or an actual shaping edit occurs.\n const onlyPathBoxResize =\n !!node.textPathData && keys.every((key) => key === 'width' || key === 'height')\n const placesPath = keys.includes('textPathBox') && !!changes.textPathBox\n if (node.derivedTextGlyphs && !onlyPathBoxResize) {\n invalidated.derivedTextGlyphs = null\n }\n if (node.textPathData && !onlyPathBoxResize && !placesPath) {\n invalidated.textPathData = null\n }\n }\n return invalidated\n}\n\nexport function invalidateTextCaches(node: SceneNode, changes: Partial<SceneNode>): void {\n Object.assign(node, textCacheInvalidationChanges(node, changes))\n}\n"],"mappings":";;;;;;;AASA,MAAa,oCAAyC,IAAI,IAAI;CAC5D,GAAG;CACH;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,uBAA4C,IAAI,IAAI,mBAAmB;;;;;;AAOpF,SAAgB,6BACd,MACA,SACoB;CACpB,MAAM,cAAkC,CAAC;CACzC,MAAM,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,QAC/B,QAAQ,CAAC,QAAQ,KAAK,MAAyB,QAAQ,IAAuB,CACjF;CACA,IAAI,KAAK,eAAe,KAAK,MAAM,QAAQ,kBAAkB,IAAI,GAAG,CAAC,GACnE,YAAY,cAAc;CAC5B,MAAM,oBACJ,KAAK,MAAM,QAAQ,qBAAqB,IAAI,GAAG,CAAC,KAChD,mBAAmB,MAAM,QAAQ,KAAK,SAAS,GAAG,CAAC;CACrD,IAAI,qBAAqB,EAAE,mBAAmB,UAAU,YAAY,gBAAgB;CAIpF,IAAI,qBAAqB,CAAC,QAAQ,mBAAmB;EAGnD,MAAM,oBACJ,CAAC,CAAC,KAAK,gBAAgB,KAAK,OAAO,QAAQ,QAAQ,WAAW,QAAQ,QAAQ;EAChF,MAAM,aAAa,KAAK,SAAS,aAAa,KAAK,CAAC,CAAC,QAAQ;EAC7D,IAAI,KAAK,qBAAqB,CAAC,mBAC7B,YAAY,oBAAoB;EAElC,IAAI,KAAK,gBAAgB,CAAC,qBAAqB,CAAC,YAC9C,YAAY,eAAe;CAE/B;CACA,OAAO;AACT;AAEA,SAAgB,qBAAqB,MAAiB,SAAmC;CACvF,OAAO,OAAO,MAAM,6BAA6B,MAAM,OAAO,CAAC;AACjE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
//#region src/transfer/copied.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Points copied layers at one another, as `prepareNodeTransfer` does for a paste: an instance's
|
|
5
|
+
* main component, the layers its overrides change and the components they swap in, the
|
|
6
|
+
* components an instance-swap property defaults to or is set to, and the layers a connector's
|
|
7
|
+
* ends follow. `mappedIds` maps each copied layer to its copy, such as a library copy or a design
|
|
8
|
+
* JSX render folded into the layers it replaces; a reference outside the copy stays as it is, and
|
|
9
|
+
* so do variable IDs, since the copies keep their source's variables.
|
|
10
|
+
*/
|
|
11
|
+
declare function remapCopiedReferences(graph: SceneGraph, mappedIds: ReadonlyMap<string, string>): void;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { remapCopiedReferences };
|
|
14
|
+
//# sourceMappingURL=copied.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copied.d.ts","names":[],"sources":["../../src/transfer/copied.ts"],"mappings":";;;;;;;;;;iBAuDgB,sBACd,OAAO,YACP,WAAW"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { remapInstanceOverrideState } from "../instances/overrides.js";
|
|
2
|
+
import { componentPropertyDefinitions } from "../components/properties.js";
|
|
3
|
+
import { isEqual, mapValues } from "es-toolkit";
|
|
4
|
+
//#region src/transfer/copied.ts
|
|
5
|
+
function swapPropertyIds(definitions) {
|
|
6
|
+
return definitions.filter((definition) => definition.type === "INSTANCE_SWAP").map((definition) => definition.id);
|
|
7
|
+
}
|
|
8
|
+
function remappedReferences(node, mapped, swapProperties) {
|
|
9
|
+
const changes = {};
|
|
10
|
+
if (node.componentId && mapped(node.componentId) !== node.componentId) changes.componentId = mapped(node.componentId);
|
|
11
|
+
const overrides = remapInstanceOverrideState(node.instanceOverrides, {
|
|
12
|
+
node: mapped,
|
|
13
|
+
variable: (id) => id
|
|
14
|
+
});
|
|
15
|
+
if (!isEqual(overrides, node.instanceOverrides)) changes.instanceOverrides = overrides;
|
|
16
|
+
const definitions = node.componentPropertyDefinitions.map((definition) => definition.type === "INSTANCE_SWAP" && definition.defaultValue ? {
|
|
17
|
+
...definition,
|
|
18
|
+
defaultValue: mapped(definition.defaultValue)
|
|
19
|
+
} : definition);
|
|
20
|
+
if (!isEqual(definitions, node.componentPropertyDefinitions)) changes.componentPropertyDefinitions = definitions;
|
|
21
|
+
const assignments = mapValues(node.componentPropertyAssignments, (value, id) => swapProperties.has(id) ? mapped(value) : value);
|
|
22
|
+
if (!isEqual(assignments, node.componentPropertyAssignments)) changes.componentPropertyAssignments = assignments;
|
|
23
|
+
for (const field of ["connectorStart", "connectorEnd"]) {
|
|
24
|
+
const endpoint = node[field];
|
|
25
|
+
if (endpoint?.nodeId && mapped(endpoint.nodeId) !== endpoint.nodeId) changes[field] = {
|
|
26
|
+
...endpoint,
|
|
27
|
+
nodeId: mapped(endpoint.nodeId)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return changes;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Points copied layers at one another, as `prepareNodeTransfer` does for a paste: an instance's
|
|
34
|
+
* main component, the layers its overrides change and the components they swap in, the
|
|
35
|
+
* components an instance-swap property defaults to or is set to, and the layers a connector's
|
|
36
|
+
* ends follow. `mappedIds` maps each copied layer to its copy, such as a library copy or a design
|
|
37
|
+
* JSX render folded into the layers it replaces; a reference outside the copy stays as it is, and
|
|
38
|
+
* so do variable IDs, since the copies keep their source's variables.
|
|
39
|
+
*/
|
|
40
|
+
function remapCopiedReferences(graph, mappedIds) {
|
|
41
|
+
const mapped = (id) => mappedIds.get(id) ?? id;
|
|
42
|
+
const copies = [...mappedIds.values()].flatMap((id) => graph.getNode(id) ?? []);
|
|
43
|
+
const copiedSwaps = copies.flatMap((node) => swapPropertyIds(node.componentPropertyDefinitions));
|
|
44
|
+
for (const node of copies) {
|
|
45
|
+
const changes = remappedReferences(node, mapped, /* @__PURE__ */ new Set([...copiedSwaps, ...swapPropertyIds(componentPropertyDefinitions(graph, node))]));
|
|
46
|
+
if (Object.keys(changes).length > 0) graph.updateNode(node.id, changes);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { remapCopiedReferences };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=copied.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copied.js","names":[],"sources":["../../src/transfer/copied.ts"],"sourcesContent":["import { isEqual, mapValues } from 'es-toolkit'\n\nimport { componentPropertyDefinitions } from '../components/properties'\nimport type { SceneGraph } from '../graph'\nimport { remapInstanceOverrideState } from '../instances/overrides'\nimport type { ComponentPropertyDefinition, SceneNode } from '../types'\n\nfunction swapPropertyIds(definitions: readonly ComponentPropertyDefinition[]): string[] {\n return definitions\n .filter((definition) => definition.type === 'INSTANCE_SWAP')\n .map((definition) => definition.id)\n}\n\nfunction remappedReferences(\n node: SceneNode,\n mapped: (id: string) => string,\n swapProperties: ReadonlySet<string>\n): Partial<SceneNode> {\n const changes: Partial<SceneNode> = {}\n if (node.componentId && mapped(node.componentId) !== node.componentId)\n changes.componentId = mapped(node.componentId)\n // Only what a mapping changes: every write is an update collaboration sends.\n const overrides = remapInstanceOverrideState(node.instanceOverrides, {\n node: mapped,\n variable: (id) => id\n })\n if (!isEqual(overrides, node.instanceOverrides)) changes.instanceOverrides = overrides\n const definitions = node.componentPropertyDefinitions.map((definition) =>\n definition.type === 'INSTANCE_SWAP' && definition.defaultValue\n ? { ...definition, defaultValue: mapped(definition.defaultValue) }\n : definition\n )\n if (!isEqual(definitions, node.componentPropertyDefinitions))\n changes.componentPropertyDefinitions = definitions\n const assignments = mapValues(node.componentPropertyAssignments, (value, id) =>\n swapProperties.has(id) ? mapped(value) : value\n )\n if (!isEqual(assignments, node.componentPropertyAssignments))\n changes.componentPropertyAssignments = assignments\n for (const field of ['connectorStart', 'connectorEnd'] as const) {\n const endpoint = node[field]\n if (endpoint?.nodeId && mapped(endpoint.nodeId) !== endpoint.nodeId)\n changes[field] = { ...endpoint, nodeId: mapped(endpoint.nodeId) }\n }\n return changes\n}\n\n/**\n * Points copied layers at one another, as `prepareNodeTransfer` does for a paste: an instance's\n * main component, the layers its overrides change and the components they swap in, the\n * components an instance-swap property defaults to or is set to, and the layers a connector's\n * ends follow. `mappedIds` maps each copied layer to its copy, such as a library copy or a design\n * JSX render folded into the layers it replaces; a reference outside the copy stays as it is, and\n * so do variable IDs, since the copies keep their source's variables.\n */\nexport function remapCopiedReferences(\n graph: SceneGraph,\n mappedIds: ReadonlyMap<string, string>\n): void {\n const mapped = (id: string) => mappedIds.get(id) ?? id\n const copies = [...mappedIds.values()].flatMap((id) => graph.getNode(id) ?? [])\n const copiedSwaps = copies.flatMap((node) => swapPropertyIds(node.componentPropertyDefinitions))\n for (const node of copies) {\n // An instance's swap property may be defined on a component the copy leaves behind.\n const swapProperties = new Set([\n ...copiedSwaps,\n ...swapPropertyIds(componentPropertyDefinitions(graph, node))\n ])\n const changes = remappedReferences(node, mapped, swapProperties)\n if (Object.keys(changes).length > 0) graph.updateNode(node.id, changes)\n }\n}\n"],"mappings":";;;;AAOA,SAAS,gBAAgB,aAA+D;CACtF,OAAO,YACJ,QAAQ,eAAe,WAAW,SAAS,eAAe,CAAC,CAC3D,KAAK,eAAe,WAAW,EAAE;AACtC;AAEA,SAAS,mBACP,MACA,QACA,gBACoB;CACpB,MAAM,UAA8B,CAAC;CACrC,IAAI,KAAK,eAAe,OAAO,KAAK,WAAW,MAAM,KAAK,aACxD,QAAQ,cAAc,OAAO,KAAK,WAAW;CAE/C,MAAM,YAAY,2BAA2B,KAAK,mBAAmB;EACnE,MAAM;EACN,WAAW,OAAO;CACpB,CAAC;CACD,IAAI,CAAC,QAAQ,WAAW,KAAK,iBAAiB,GAAG,QAAQ,oBAAoB;CAC7E,MAAM,cAAc,KAAK,6BAA6B,KAAK,eACzD,WAAW,SAAS,mBAAmB,WAAW,eAC9C;EAAE,GAAG;EAAY,cAAc,OAAO,WAAW,YAAY;CAAE,IAC/D,UACN;CACA,IAAI,CAAC,QAAQ,aAAa,KAAK,4BAA4B,GACzD,QAAQ,+BAA+B;CACzC,MAAM,cAAc,UAAU,KAAK,+BAA+B,OAAO,OACvE,eAAe,IAAI,EAAE,IAAI,OAAO,KAAK,IAAI,KAC3C;CACA,IAAI,CAAC,QAAQ,aAAa,KAAK,4BAA4B,GACzD,QAAQ,+BAA+B;CACzC,KAAK,MAAM,SAAS,CAAC,kBAAkB,cAAc,GAAY;EAC/D,MAAM,WAAW,KAAK;EACtB,IAAI,UAAU,UAAU,OAAO,SAAS,MAAM,MAAM,SAAS,QAC3D,QAAQ,SAAS;GAAE,GAAG;GAAU,QAAQ,OAAO,SAAS,MAAM;EAAE;CACpE;CACA,OAAO;AACT;;;;;;;;;AAUA,SAAgB,sBACd,OACA,WACM;CACN,MAAM,UAAU,OAAe,UAAU,IAAI,EAAE,KAAK;CACpD,MAAM,SAAS,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,CAAC;CAC9E,MAAM,cAAc,OAAO,SAAS,SAAS,gBAAgB,KAAK,4BAA4B,CAAC;CAC/F,KAAK,MAAM,QAAQ,QAAQ;EAMzB,MAAM,UAAU,mBAAmB,MAAM,wBAAQ,IAJtB,IAAI,CAC7B,GAAG,aACH,GAAG,gBAAgB,6BAA6B,OAAO,IAAI,CAAC,CAC9D,CAC8D,CAAC;EAC/D,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,GAAG,MAAM,WAAW,KAAK,IAAI,OAAO;CACxE;AACF"}
|
package/dist/transfer/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ import { removeGraphTransfer } from "./remove.js";
|
|
|
4
4
|
import { captureTransferredState } from "./history.js";
|
|
5
5
|
import { VariableTransferReferences, prepareVariableTransfer } from "./variables.js";
|
|
6
6
|
import { NodeTransferReferences, prepareNodeTransfer } from "./nodes.js";
|
|
7
|
-
|
|
7
|
+
import { remapCopiedReferences } from "./copied.js";
|
|
8
|
+
export { type GraphTransferInput, type GraphTransferPlan, type NodeTransferReferences, type VariableTransferReferences, applyGraphTransfer, captureTransferredState, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, remapCopiedReferences, removeGraphTransfer };
|
package/dist/transfer/index.js
CHANGED
|
@@ -4,4 +4,5 @@ import { captureTransferredState } from "./history.js";
|
|
|
4
4
|
import { prepareVariableTransfer } from "./variables.js";
|
|
5
5
|
import { applyGraphTransfer } from "./apply.js";
|
|
6
6
|
import { prepareGraphTransfer } from "./plan.js";
|
|
7
|
-
|
|
7
|
+
import { remapCopiedReferences } from "./copied.js";
|
|
8
|
+
export { applyGraphTransfer, captureTransferredState, prepareGraphTransfer, prepareNodeTransfer, prepareVariableTransfer, remapCopiedReferences, removeGraphTransfer };
|
package/dist/transfer/nodes.js
CHANGED
|
@@ -59,6 +59,13 @@ function prepareNodeTransfer(source, refs) {
|
|
|
59
59
|
style,
|
|
60
60
|
node: (id) => refs.nodes.get(id) ?? id
|
|
61
61
|
});
|
|
62
|
+
result.prototypeReactions = (result.prototypeReactions ?? []).map((reaction) => ({
|
|
63
|
+
...reaction,
|
|
64
|
+
actions: reaction.actions.map((action) => action.type === "NODE" && action.nodeId ? {
|
|
65
|
+
...action,
|
|
66
|
+
nodeId: refs.nodes.get(action.nodeId) ?? action.nodeId
|
|
67
|
+
} : action)
|
|
68
|
+
}));
|
|
62
69
|
for (const field of ["connectorStart", "connectorEnd"]) {
|
|
63
70
|
const endpoint = result[field];
|
|
64
71
|
if (endpoint?.nodeId) endpoint.nodeId = refs.nodes.get(endpoint.nodeId) ?? endpoint.nodeId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","names":["required"],"sources":["../../src/transfer/nodes.ts"],"sourcesContent":["import { cloneNodeProps } from '../copy'\nimport {\n isLayerReferenceOverride,\n overriddenBindingField,\n remapInstanceOverrideState\n} from '../instances/overrides'\nimport { remapStyleRunReferences, styleRunReferences } from '../text/references'\nimport type { ComponentPropertyType, SceneNode } from '../types'\nimport { requireTransferReference as required } from './references'\nimport type { VariableTransferReferences } from './variables'\n\nexport function semanticTransferReferences(node: SceneNode): string[] {\n const runs = styleRunReferences(node.styleRuns)\n return [\n ...(node.componentId ? [node.componentId] : []),\n ...Object.values(node.boundVariables),\n ...runs.variables,\n ...runs.styles,\n ...[\n node.fillStyleId,\n node.strokeStyleId,\n node.textStyleId,\n node.effectStyleId,\n node.gridStyleId\n ].filter((id): id is string => !!id),\n ...node.fillGeometry.flatMap((path) => (path.fillStyleId ? [path.fillStyleId] : [])),\n ...node.strokeGeometry.flatMap((path) => (path.fillStyleId ? [path.fillStyleId] : [])),\n ...Object.entries(node.componentPropertyAssignments).flatMap(([id, value]) => [id, value]),\n ...node.componentPropertyReferences.map((reference) => reference.propertyId),\n ...node.componentPropertyDefinitions.flatMap((definition) => [\n definition.id,\n ...(definition.type === 'INSTANCE_SWAP' && definition.defaultValue\n ? [definition.defaultValue]\n : [])\n ]),\n ...node.instanceOverrides.descendants.keys(),\n ...[\n ...node.instanceOverrides.self,\n ...[...node.instanceOverrides.descendants.values()].flatMap((fields) => [...fields])\n ].flatMap(([field, value]) =>\n typeof value === 'string' &&\n (isLayerReferenceOverride(field) || overriddenBindingField(field) !== null)\n ? [value]\n : []\n )\n ]\n}\n\nexport interface NodeTransferReferences extends VariableTransferReferences {\n nodes: ReadonlyMap<string, string>\n styles: ReadonlyMap<string, string>\n properties: ReadonlyMap<string, string>\n propertyTypes: ReadonlyMap<string, ComponentPropertyType>\n}\n\n/** Prepare runtime references without rewriting original format identities or ordinary text. */\nexport function prepareNodeTransfer(\n source: SceneNode,\n refs: NodeTransferReferences\n): Partial<SceneNode> {\n const node = (id: string) => required(refs.nodes, id, 'node')\n const variable = (id: string) => required(refs.variables, id, 'variable')\n const property = (id: string) => required(refs.properties, id, 'property')\n const style = (id: string) => required(refs.styles, id, 'style')\n const propertyValue = (id: string, value: string): string => {\n const type = refs.propertyTypes.get(id)\n if (!type) throw new Error(`Missing property transfer type: ${id}`)\n return type === 'INSTANCE_SWAP' && value ? node(value) : value\n }\n const values = (entries: Record<string, string>) =>\n Object.fromEntries(\n Object.entries(entries).map(([id, value]) => [property(id), propertyValue(id, value)])\n )\n const result = cloneNodeProps(source, null)\n result.componentId = source.componentId ? node(source.componentId) : null\n result.instanceOverrides = remapInstanceOverrideState(source.instanceOverrides, {\n node,\n variable,\n property: (id) => refs.properties.get(id)\n })\n result.boundVariables = Object.fromEntries(\n Object.entries(source.boundVariables).map(([field, id]) => [field, variable(id)])\n )\n result.variableModes = Object.fromEntries(\n Object.entries(source.variableModes).map(([collection, mode]) => [\n required(refs.collections, collection, 'collection'),\n required(refs.modes, mode, 'mode')\n ])\n )\n for (const field of [\n 'fillStyleId',\n 'strokeStyleId',\n 'textStyleId',\n 'effectStyleId',\n 'gridStyleId'\n ] as const) {\n result[field] = source[field] ? style(source[field]) : null\n }\n if (result.styleRuns) {\n // A link to a layer the transfer leaves behind keeps naming it.\n result.styleRuns = remapStyleRunReferences(result.styleRuns, {\n variable,\n style,\n node: (id) => refs.nodes.get(id) ?? id\n })\n }\n // A connector keeps the layers it was attached to when they are left behind; the end becomes\n // free where nothing by that ID exists, as a pasted Figma connector does.\n for (const field of ['connectorStart', 'connectorEnd'] as const) {\n const endpoint = result[field]\n if (endpoint?.nodeId) endpoint.nodeId = refs.nodes.get(endpoint.nodeId) ?? endpoint.nodeId\n }\n for (const paths of [result.fillGeometry, result.strokeGeometry]) {\n for (const path of paths ?? []) if (path.fillStyleId) path.fillStyleId = style(path.fillStyleId)\n }\n result.componentPropertyDefinitions = source.componentPropertyDefinitions.map((definition) => ({\n ...structuredClone(definition),\n id: property(definition.id),\n defaultValue: propertyValue(definition.id, definition.defaultValue)\n }))\n // A reference to a property that neither the transfer nor its destination defines names nothing.\n result.componentPropertyReferences = source.componentPropertyReferences.flatMap((reference) => {\n const propertyId = refs.properties.get(reference.propertyId)\n return propertyId ? [{ ...reference, propertyId }] : []\n })\n result.componentPropertyAssignments = values(source.componentPropertyAssignments)\n // Variant values are keyed by display names, unlike definition-ID assignments.\n result.componentPropertyValues = { ...source.componentPropertyValues }\n return result\n}\n"],"mappings":";;;;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C;CAIH,KAAK,MAAM,SAAS,CAAC,kBAAkB,cAAc,GAAY;EAC/D,MAAM,WAAW,OAAO;EACxB,IAAI,UAAU,QAAQ,SAAS,SAAS,KAAK,MAAM,IAAI,SAAS,MAAM,KAAK,SAAS;CACtF;CACA,KAAK,MAAM,SAAS,CAAC,OAAO,cAAc,OAAO,cAAc,GAC7D,KAAK,MAAM,QAAQ,SAAS,CAAC,GAAG,IAAI,KAAK,aAAa,KAAK,cAAc,MAAM,KAAK,WAAW;CAEjG,OAAO,+BAA+B,OAAO,6BAA6B,KAAK,gBAAgB;EAC7F,GAAG,gBAAgB,UAAU;EAC7B,IAAI,SAAS,WAAW,EAAE;EAC1B,cAAc,cAAc,WAAW,IAAI,WAAW,YAAY;CACpE,EAAE;CAEF,OAAO,8BAA8B,OAAO,4BAA4B,SAAS,cAAc;EAC7F,MAAM,aAAa,KAAK,WAAW,IAAI,UAAU,UAAU;EAC3D,OAAO,aAAa,CAAC;GAAE,GAAG;GAAW;EAAW,CAAC,IAAI,CAAC;CACxD,CAAC;CACD,OAAO,+BAA+B,OAAO,OAAO,4BAA4B;CAEhF,OAAO,0BAA0B,EAAE,GAAG,OAAO,wBAAwB;CACrE,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"nodes.js","names":["required"],"sources":["../../src/transfer/nodes.ts"],"sourcesContent":["import { cloneNodeProps } from '../copy'\nimport {\n isLayerReferenceOverride,\n overriddenBindingField,\n remapInstanceOverrideState\n} from '../instances/overrides'\nimport { remapStyleRunReferences, styleRunReferences } from '../text/references'\nimport type { ComponentPropertyType, SceneNode } from '../types'\nimport { requireTransferReference as required } from './references'\nimport type { VariableTransferReferences } from './variables'\n\nexport function semanticTransferReferences(node: SceneNode): string[] {\n const runs = styleRunReferences(node.styleRuns)\n return [\n ...(node.componentId ? [node.componentId] : []),\n ...Object.values(node.boundVariables),\n ...runs.variables,\n ...runs.styles,\n ...[\n node.fillStyleId,\n node.strokeStyleId,\n node.textStyleId,\n node.effectStyleId,\n node.gridStyleId\n ].filter((id): id is string => !!id),\n ...node.fillGeometry.flatMap((path) => (path.fillStyleId ? [path.fillStyleId] : [])),\n ...node.strokeGeometry.flatMap((path) => (path.fillStyleId ? [path.fillStyleId] : [])),\n ...Object.entries(node.componentPropertyAssignments).flatMap(([id, value]) => [id, value]),\n ...node.componentPropertyReferences.map((reference) => reference.propertyId),\n ...node.componentPropertyDefinitions.flatMap((definition) => [\n definition.id,\n ...(definition.type === 'INSTANCE_SWAP' && definition.defaultValue\n ? [definition.defaultValue]\n : [])\n ]),\n ...node.instanceOverrides.descendants.keys(),\n ...[\n ...node.instanceOverrides.self,\n ...[...node.instanceOverrides.descendants.values()].flatMap((fields) => [...fields])\n ].flatMap(([field, value]) =>\n typeof value === 'string' &&\n (isLayerReferenceOverride(field) || overriddenBindingField(field) !== null)\n ? [value]\n : []\n )\n ]\n}\n\nexport interface NodeTransferReferences extends VariableTransferReferences {\n nodes: ReadonlyMap<string, string>\n styles: ReadonlyMap<string, string>\n properties: ReadonlyMap<string, string>\n propertyTypes: ReadonlyMap<string, ComponentPropertyType>\n}\n\n/** Prepare runtime references without rewriting original format identities or ordinary text. */\nexport function prepareNodeTransfer(\n source: SceneNode,\n refs: NodeTransferReferences\n): Partial<SceneNode> {\n const node = (id: string) => required(refs.nodes, id, 'node')\n const variable = (id: string) => required(refs.variables, id, 'variable')\n const property = (id: string) => required(refs.properties, id, 'property')\n const style = (id: string) => required(refs.styles, id, 'style')\n const propertyValue = (id: string, value: string): string => {\n const type = refs.propertyTypes.get(id)\n if (!type) throw new Error(`Missing property transfer type: ${id}`)\n return type === 'INSTANCE_SWAP' && value ? node(value) : value\n }\n const values = (entries: Record<string, string>) =>\n Object.fromEntries(\n Object.entries(entries).map(([id, value]) => [property(id), propertyValue(id, value)])\n )\n const result = cloneNodeProps(source, null)\n result.componentId = source.componentId ? node(source.componentId) : null\n result.instanceOverrides = remapInstanceOverrideState(source.instanceOverrides, {\n node,\n variable,\n property: (id) => refs.properties.get(id)\n })\n result.boundVariables = Object.fromEntries(\n Object.entries(source.boundVariables).map(([field, id]) => [field, variable(id)])\n )\n result.variableModes = Object.fromEntries(\n Object.entries(source.variableModes).map(([collection, mode]) => [\n required(refs.collections, collection, 'collection'),\n required(refs.modes, mode, 'mode')\n ])\n )\n for (const field of [\n 'fillStyleId',\n 'strokeStyleId',\n 'textStyleId',\n 'effectStyleId',\n 'gridStyleId'\n ] as const) {\n result[field] = source[field] ? style(source[field]) : null\n }\n if (result.styleRuns) {\n // A link to a layer the transfer leaves behind keeps naming it.\n result.styleRuns = remapStyleRunReferences(result.styleRuns, {\n variable,\n style,\n node: (id) => refs.nodes.get(id) ?? id\n })\n }\n // A reaction's destination keeps its name when the transfer leaves it behind; a copied frame\n // with a copy of its destination points at the copy, as Figma's paste does.\n result.prototypeReactions = (result.prototypeReactions ?? []).map((reaction) => ({\n ...reaction,\n actions: reaction.actions.map((action) =>\n action.type === 'NODE' && action.nodeId\n ? { ...action, nodeId: refs.nodes.get(action.nodeId) ?? action.nodeId }\n : action\n )\n }))\n // A connector keeps the layers it was attached to when they are left behind; the end becomes\n // free where nothing by that ID exists, as a pasted Figma connector does.\n for (const field of ['connectorStart', 'connectorEnd'] as const) {\n const endpoint = result[field]\n if (endpoint?.nodeId) endpoint.nodeId = refs.nodes.get(endpoint.nodeId) ?? endpoint.nodeId\n }\n for (const paths of [result.fillGeometry, result.strokeGeometry]) {\n for (const path of paths ?? []) if (path.fillStyleId) path.fillStyleId = style(path.fillStyleId)\n }\n result.componentPropertyDefinitions = source.componentPropertyDefinitions.map((definition) => ({\n ...structuredClone(definition),\n id: property(definition.id),\n defaultValue: propertyValue(definition.id, definition.defaultValue)\n }))\n // A reference to a property that neither the transfer nor its destination defines names nothing.\n result.componentPropertyReferences = source.componentPropertyReferences.flatMap((reference) => {\n const propertyId = refs.properties.get(reference.propertyId)\n return propertyId ? [{ ...reference, propertyId }] : []\n })\n result.componentPropertyAssignments = values(source.componentPropertyAssignments)\n // Variant values are keyed by display names, unlike definition-ID assignments.\n result.componentPropertyValues = { ...source.componentPropertyValues }\n return result\n}\n"],"mappings":";;;;;AAWA,SAAgB,2BAA2B,MAA2B;CACpE,MAAM,OAAO,mBAAmB,KAAK,SAAS;CAC9C,OAAO;EACL,GAAI,KAAK,cAAc,CAAC,KAAK,WAAW,IAAI,CAAC;EAC7C,GAAG,OAAO,OAAO,KAAK,cAAc;EACpC,GAAG,KAAK;EACR,GAAG,KAAK;EACR,GAAG;GACD,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;EACP,CAAC,CAAC,QAAQ,OAAqB,CAAC,CAAC,EAAE;EACnC,GAAG,KAAK,aAAa,SAAS,SAAU,KAAK,cAAc,CAAC,KAAK,WAAW,IAAI,CAAC,CAAE;EACnF,GAAG,KAAK,eAAe,SAAS,SAAU,KAAK,cAAc,CAAC,KAAK,WAAW,IAAI,CAAC,CAAE;EACrF,GAAG,OAAO,QAAQ,KAAK,4BAA4B,CAAC,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,IAAI,KAAK,CAAC;EACzF,GAAG,KAAK,4BAA4B,KAAK,cAAc,UAAU,UAAU;EAC3E,GAAG,KAAK,6BAA6B,SAAS,eAAe,CAC3D,WAAW,IACX,GAAI,WAAW,SAAS,mBAAmB,WAAW,eAClD,CAAC,WAAW,YAAY,IACxB,CAAC,CACP,CAAC;EACD,GAAG,KAAK,kBAAkB,YAAY,KAAK;EAC3C,GAAG,CACD,GAAG,KAAK,kBAAkB,MAC1B,GAAG,CAAC,GAAG,KAAK,kBAAkB,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,MAAM,CAAC,CACrF,CAAC,CAAC,SAAS,CAAC,OAAO,WACjB,OAAO,UAAU,aAChB,yBAAyB,KAAK,KAAK,uBAAuB,KAAK,MAAM,QAClE,CAAC,KAAK,IACN,CAAC,CACP;CACF;AACF;;AAUA,SAAgB,oBACd,QACA,MACoB;CACpB,MAAM,QAA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|
156
156
|
type SharedStyleKind = 'fill' | 'stroke' | 'text' | 'effect' | 'grid';
|
|
157
157
|
type MaskType = 'ALPHA' | 'VECTOR' | 'LUMINANCE';
|
|
158
|
+
type BooleanOperation = 'UNION' | 'SUBTRACT' | 'INTERSECT' | 'EXCLUDE';
|
|
158
159
|
interface LayoutGrid {
|
|
159
160
|
visible?: boolean;
|
|
160
161
|
color?: Color;
|
|
@@ -642,7 +643,7 @@ interface SceneNode {
|
|
|
642
643
|
layoutAlignSelf: LayoutAlignSelf;
|
|
643
644
|
vectorNetwork: VectorNetwork | null;
|
|
644
645
|
handleMirroring: HandleMirroring;
|
|
645
|
-
booleanOperation:
|
|
646
|
+
booleanOperation: BooleanOperation | undefined;
|
|
646
647
|
fillGeometry: GeometryPath[];
|
|
647
648
|
strokeGeometry: GeometryPath[];
|
|
648
649
|
arcData: ArcData | null;
|
|
@@ -927,5 +928,5 @@ declare function isLibraryCollection(collection: Pick<VariableCollection, 'key'>
|
|
|
927
928
|
declare const MODE_ATTRIBUTE_PATTERN: RegExp;
|
|
928
929
|
declare function isModeAttributeName(name: string): boolean;
|
|
929
930
|
//#endregion
|
|
930
|
-
export { ArcData, AxisSizingMode, BlendMode, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, Effect, EnabledLibraryBinding, ExportSetting, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageFilters, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, MeshGradientPoint, NodeChangeObserver, NodeType, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, PrototypeAction, PrototypeActionType, PrototypeBackAction, PrototypeCloseAction, PrototypeNavigationType, PrototypeNodeAction, PrototypeOverlayPositionType, PrototypeReaction, PrototypeTransition, PrototypeTransitionType, PrototypeTrigger, PrototypeTriggerType, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, ShaderEffect, ShadowEffect, 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, 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 };
|
|
931
|
+
export { ArcData, AxisSizingMode, BlendMode, BooleanOperation, CODE_SYNTAX_PLATFORMS, CharacterStyleOverride, CodeSyntaxPlatform, CommentReply, CommentThread, ComponentPropertyDefinition, ComponentPropertyReference, ComponentPropertyReferenceField, ComponentPropertyType, ConnectorControlPoint, ConnectorEndpoint, ConnectorLabelPosition, ConnectorLineType, ConnectorMagnet, ConstraintType, DerivedTextGlyph, DocumentColorSpace, DocumentKind, Effect, EnabledLibraryBinding, ExportSetting, FigmaLayoutMetadata, FigmaSourcePayload, Fill, FillType, FontFeature, FontVariation, GeometryPath, GradientStop, GradientTransform, GridPosition, GridTrack, GridTrackSizing, HandleMirroring, HyperlinkTarget, ImageFilters, ImageScaleMode, LayoutAlign, LayoutAlignSelf, LayoutCounterAlign, LayoutDirection, LayoutGrid, LayoutMode, LayoutSizing, LayoutWrap, LeadingTrim, LibraryAssetIdentity, LibraryAssetSource, MODE_ATTRIBUTE_PATTERN, MaskType, MeshGradientPoint, NodeChangeObserver, NodeType, NoiseType, NumericNodeProperty, PatternAlignment, PatternTileType, PluginDataEntry, PluginRelaunchDataEntry, PrototypeAction, PrototypeActionType, PrototypeBackAction, PrototypeCloseAction, PrototypeNavigationType, PrototypeNodeAction, PrototypeOverlayPositionType, PrototypeReaction, PrototypeTransition, PrototypeTransitionType, PrototypeTrigger, PrototypeTriggerType, SceneGraphEventHandlers, SceneGraphEvents, SceneNode, ShaderEffect, ShadowEffect, 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, 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 };
|
|
931
932
|
//# 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"],"m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,YAAY;EACZ,kBAAkB;EAClB,kBAAkB;EAClB,mBAAmB;EACnB,mBAAmB;EACnB;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA,iBAAiB;EAEjB,eAAe;EACf,iBAAiB;EACjB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;UASiB;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;;;UAKa;;EAEf,SAAS,MAAM;;EAEf,UAAU,MAAM;;EAEhB;;EAEA;;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;;UAGe;EACf,UAAU;EACV,UAAU;EACV,SAAS;;UAGM;EACf,aAAa;EACb,cAAc;;EAEd,QAAQ;;EAER;;KAGU;KAsBA;KAYA;KAoBA;KACA;KACA;KACA;UAEK;EACf,OAAO;EACP;;;;;;;;UASe;EACf,UAAU;EACV,OAAO;;KAGG,oBAAoB;;UAGf;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,MAAM;EACN,OAAO;EACP;EACA;EACA,YAAY;EACZ,gBAAgB;EAChB,oBAAoB;;EAEpB;EACA;EACA,aAAa;EACb;EAC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;KACA;KACA;KACA;UAEK;EACf;EACA;EACA;;UAGe;EACf;EACA,QAAQ;;EAER;;UAGe;EACf;EACA;EACA;EACA;;;;;;;UAQe;EACf,SAAS;EACT,gBAAgB;;EAEhB;EACA;;EAEA;;UAGe;;EAEf;EACA,cAAc;EACd;EACA;EACA;;EAEA;;;;;EAKA;;;;;;;EAOA;EACA;;;;;EAKA;;EAEA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;;KAGU,sBAAsB,QAChC,oOAaE,qMAWA;UAGa;EACf;EACA;EACA;;UAGe;EACf,UAAU;EACV;EACA;;UAGe;EACf;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;;EAEA,cAAc;;EAEd;EACA;EACA;;;UAIe;EACf;EACA;;EAEA;;EAEA;EACA;;EAEA;EACA;;EAEA;EACA;EACA;;EAEA,cAAc;;EAEd;EACA;;EAEA;EACA;EACA;;EAEA;EACA,SAAS;;;KAIC;;KAGA;;KAGA;;KAGA;;KAGA;;UAUK;EACf,MAAM;EACN;;;UAIe;EACf;;EAEA;EACA,YAAY;EACZ,YAAY;;EAEZ,iBAAiB;;;UAIF;EACf;;;UAIe;EACf;;KAGU,kBAAkB,sBAAsB,sBAAsB;;UAGzD;EACf,MAAM;;EAEN;;;;;;UAOe;EACf;EACA,SAAS;EACT,SAAS;;UAGM;EACf;EACA,MAAM;EACN;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA,QAAQ;;EAER,eAAe,QAAQ;EAEvB,OAAO;EACP,SAAS;EACT,SAAS;EACT,aAAa;EACb,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA,iBAAiB;EACjB;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EAEA,WAAW;EAEX;EACA;EACA;EACA;EACA;;;;;EAKA;EACA;EACA,eAAe;EACf;EACA,mBAAmB;EACnB,gBAAgB;EAChB,UAAU;EACV,gBAAgB;EAChB,qBAAqB;EACrB;EACA,qBAA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