@pixerate/editor 0.24.0 → 0.25.0

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.
Files changed (133) hide show
  1. package/README.md +71 -1
  2. package/THIRD_PARTY_NOTICES.md +29 -0
  3. package/dist/agent/index.cjs +10 -9
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +1 -1
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +4 -3
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/canvas/index.cjs +3173 -340
  10. package/dist/canvas/index.cjs.map +1 -1
  11. package/dist/canvas/index.d.cts +617 -4
  12. package/dist/canvas/index.d.ts +617 -4
  13. package/dist/canvas/index.js +3105 -272
  14. package/dist/canvas/index.js.map +1 -1
  15. package/dist/chunk-4BVP64JJ.cjs +1406 -0
  16. package/dist/chunk-4BVP64JJ.cjs.map +1 -0
  17. package/dist/{chunk-XNORY7M6.cjs → chunk-7WISYZFO.cjs} +105 -50
  18. package/dist/chunk-7WISYZFO.cjs.map +1 -0
  19. package/dist/{chunk-OLZJXL4R.cjs → chunk-AL6JMGWW.cjs} +59 -25
  20. package/dist/chunk-AL6JMGWW.cjs.map +1 -0
  21. package/dist/chunk-BVP3TSLH.cjs +69 -0
  22. package/dist/chunk-BVP3TSLH.cjs.map +1 -0
  23. package/dist/{chunk-MCSJFWAO.cjs → chunk-C7P22VIP.cjs} +670 -96
  24. package/dist/chunk-C7P22VIP.cjs.map +1 -0
  25. package/dist/{chunk-PGNZKFQS.js → chunk-ECCCYKGL.js} +76 -21
  26. package/dist/chunk-ECCCYKGL.js.map +1 -0
  27. package/dist/{chunk-3CN2WD3X.js → chunk-FH6F67DN.js} +646 -72
  28. package/dist/chunk-FH6F67DN.js.map +1 -0
  29. package/dist/chunk-HRMEDT2L.js +1406 -0
  30. package/dist/chunk-HRMEDT2L.js.map +1 -0
  31. package/dist/{chunk-ITBSKI26.js → chunk-IXHSYOVY.js} +941 -9
  32. package/dist/chunk-IXHSYOVY.js.map +1 -0
  33. package/dist/{chunk-FODNLX5N.js → chunk-NAXVVS5I.js} +38 -4
  34. package/dist/chunk-NAXVVS5I.js.map +1 -0
  35. package/dist/chunk-O5RYH2PG.js +69 -0
  36. package/dist/chunk-O5RYH2PG.js.map +1 -0
  37. package/dist/{chunk-SBCZ6RN5.cjs → chunk-PO6A6QQH.cjs} +1039 -107
  38. package/dist/chunk-PO6A6QQH.cjs.map +1 -0
  39. package/dist/{chunk-3LV6RRPH.js → chunk-QGYDWPRM.js} +2 -2
  40. package/dist/{chunk-U5KWZU4X.js → chunk-RR7F5GUM.js} +2632 -129
  41. package/dist/chunk-RR7F5GUM.js.map +1 -0
  42. package/dist/{chunk-5S3Z4PPF.js → chunk-UAKDG62Z.js} +232 -25
  43. package/dist/chunk-UAKDG62Z.js.map +1 -0
  44. package/dist/{chunk-SML64VJG.cjs → chunk-V3CHHWOE.cjs} +4 -4
  45. package/dist/{chunk-SML64VJG.cjs.map → chunk-V3CHHWOE.cjs.map} +1 -1
  46. package/dist/chunk-WSQKHXW7.cjs +5726 -0
  47. package/dist/chunk-WSQKHXW7.cjs.map +1 -0
  48. package/dist/{chunk-D27YFC46.cjs → chunk-X4N4WUKB.cjs} +267 -60
  49. package/dist/chunk-X4N4WUKB.cjs.map +1 -0
  50. package/dist/commands/index.cjs +74 -1
  51. package/dist/commands/index.cjs.map +1 -1
  52. package/dist/commands/index.d.cts +34 -1
  53. package/dist/commands/index.d.ts +34 -1
  54. package/dist/commands/index.js +73 -0
  55. package/dist/commands/index.js.map +1 -1
  56. package/dist/compare/index.cjs +3 -3
  57. package/dist/compare/index.d.cts +1 -1
  58. package/dist/compare/index.d.ts +1 -1
  59. package/dist/compare/index.js +2 -2
  60. package/dist/controller-BIJiNoVs.d.cts +1842 -0
  61. package/dist/controller-BIJiNoVs.d.ts +1842 -0
  62. package/dist/{documents-BQjzJNe2.d.ts → documents-CHT1U5Vs.d.ts} +10 -0
  63. package/dist/{documents-KRTPhvst.d.cts → documents-Gp7wb0Me.d.cts} +10 -0
  64. package/dist/extensions/index.cjs +53 -6
  65. package/dist/extensions/index.cjs.map +1 -1
  66. package/dist/extensions/index.d.cts +12 -4
  67. package/dist/extensions/index.d.ts +12 -4
  68. package/dist/extensions/index.js +53 -6
  69. package/dist/generation/index.cjs +1013 -69
  70. package/dist/generation/index.cjs.map +1 -1
  71. package/dist/generation/index.d.cts +474 -13
  72. package/dist/generation/index.d.ts +474 -13
  73. package/dist/generation/index.js +976 -32
  74. package/dist/generation/index.js.map +1 -1
  75. package/dist/image-editor/index.cjs +3385 -1275
  76. package/dist/image-editor/index.cjs.map +1 -1
  77. package/dist/image-editor/index.d.cts +693 -128
  78. package/dist/image-editor/index.d.ts +693 -128
  79. package/dist/image-editor/index.js +3325 -1215
  80. package/dist/image-editor/index.js.map +1 -1
  81. package/dist/{index-fJrlkJCd.d.ts → index-7a6bHTLy.d.ts} +494 -5
  82. package/dist/{index-BhJBSm2d.d.cts → index-Csd5qI8u.d.cts} +494 -5
  83. package/dist/index.cjs +1491 -45
  84. package/dist/index.cjs.map +1 -1
  85. package/dist/index.d.cts +110 -19
  86. package/dist/index.d.ts +110 -19
  87. package/dist/index.js +1464 -18
  88. package/dist/index.js.map +1 -1
  89. package/dist/mention-text-CDnCFd3c.d.cts +53 -0
  90. package/dist/mention-text-CDnCFd3c.d.ts +53 -0
  91. package/dist/model-C1zApQM8.d.cts +219 -0
  92. package/dist/model-C1zApQM8.d.ts +219 -0
  93. package/dist/persistence/index.d.cts +3 -120
  94. package/dist/persistence/index.d.ts +3 -120
  95. package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.cts} +12 -1
  96. package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.ts} +12 -1
  97. package/dist/serializers/index.cjs +12 -4
  98. package/dist/serializers/index.cjs.map +1 -1
  99. package/dist/serializers/index.d.cts +39 -12
  100. package/dist/serializers/index.d.ts +39 -12
  101. package/dist/serializers/index.js +12 -4
  102. package/dist/spreadsheet/index.cjs +127 -3
  103. package/dist/spreadsheet/index.cjs.map +1 -1
  104. package/dist/spreadsheet/index.d.cts +431 -11
  105. package/dist/spreadsheet/index.d.ts +431 -11
  106. package/dist/spreadsheet/index.js +127 -3
  107. package/dist/storage-BpFfspHm.d.cts +120 -0
  108. package/dist/storage-BpFfspHm.d.ts +120 -0
  109. package/dist/tokens/index.cjs +115 -0
  110. package/dist/tokens/index.cjs.map +1 -0
  111. package/dist/tokens/index.d.cts +212 -0
  112. package/dist/tokens/index.d.ts +212 -0
  113. package/dist/tokens/index.js +115 -0
  114. package/dist/tokens/index.js.map +1 -0
  115. package/dist/{track-changes-BK5sVf4_.d.cts → track-changes-D_VAPELi.d.cts} +95 -11
  116. package/dist/{track-changes-CDjCrwKe.d.ts → track-changes-Db_fGEvx.d.ts} +95 -11
  117. package/package.json +6 -1
  118. package/dist/chunk-3CN2WD3X.js.map +0 -1
  119. package/dist/chunk-5S3Z4PPF.js.map +0 -1
  120. package/dist/chunk-D27YFC46.cjs.map +0 -1
  121. package/dist/chunk-FODNLX5N.js.map +0 -1
  122. package/dist/chunk-ITBSKI26.js.map +0 -1
  123. package/dist/chunk-MA2F5KHF.cjs +0 -3223
  124. package/dist/chunk-MA2F5KHF.cjs.map +0 -1
  125. package/dist/chunk-MCSJFWAO.cjs.map +0 -1
  126. package/dist/chunk-OLZJXL4R.cjs.map +0 -1
  127. package/dist/chunk-PGNZKFQS.js.map +0 -1
  128. package/dist/chunk-SBCZ6RN5.cjs.map +0 -1
  129. package/dist/chunk-U5KWZU4X.js.map +0 -1
  130. package/dist/chunk-XNORY7M6.cjs.map +0 -1
  131. package/dist/controller-BhLLAoi8.d.cts +0 -1000
  132. package/dist/controller-BhLLAoi8.d.ts +0 -1000
  133. /package/dist/{chunk-3LV6RRPH.js.map → chunk-QGYDWPRM.js.map} +0 -0
@@ -3,6 +3,7 @@ export { h as CanvasDockingCallbacks, i as CollapseNodeOptions, j as Displacemen
3
3
  import { b as CanvasNodeUpdate, N as NodeRectOptions, A as AlignEdge, c as AlignNodesOptions, D as DistributeAxis, a as DistributeMode, d as DistributeNodesOptions, S as SizeDimension, M as MatchSizeOptions, Z as ZOrderOperation, C as CanvasArrangeAction } from '../arrangeShortcuts-sLlD2rSX.js';
4
4
  export { e as ArrangeShortcutBinding, f as DEFAULT_ARRANGE_SHORTCUTS, L as LOCKED_DATA_KEY, g as LOCKED_PREVIOUS_FLAGS_KEY, h as alignNodes, i as applyNodeUpdates, j as createNodeLookup, k as distributeNodes, l as getAbsolutePosition, m as getNodeRect, n as getNodeSize, o as invertNodeUpdates, p as isLocked, q as lockNodes, r as matchArrangeShortcut, s as matchSize, t as readStyleSize, u as reorderNodes, v as toggleLockNodes, w as unlockNodes, x as withStyleSize } from '../arrangeShortcuts-sLlD2rSX.js';
5
5
  import { C as Command } from '../types-GT5a5YAX.js';
6
+ import { r as TokenType, o as TokenScope, f as TokenLiteral, c as TokenVariable, e as TokenResolution, d as TokenModeContext, T as TokenState } from '../model-C1zApQM8.js';
6
7
 
7
8
  declare const DEFAULT_NODE_WIDTH = 200;
8
9
  declare const DEFAULT_NODE_HEIGHT = 60;
@@ -898,6 +899,346 @@ interface PolygonToPathOptions {
898
899
  */
899
900
  declare function polygonToSvgPath(input: MultiPolygon | PolygonRing[], options?: PolygonToPathOptions): string;
900
901
 
902
+ /**
903
+ * Bézier path model shared by the curve-preserving path operations: absolute `M` / `L` /
904
+ * `Q` / `C` / `Z` commands, conversion from SVG path data (arcs become cubics), segment
905
+ * math (evaluation, splitting, extrema, nearest point), exact areas, winding numbers and
906
+ * arc-length utilities.
907
+ */
908
+
909
+ /** One absolute path command. Every subpath starts with `M`; `Z` closes it. */
910
+ type BezierCommand = {
911
+ type: 'M';
912
+ x: number;
913
+ y: number;
914
+ } | {
915
+ type: 'L';
916
+ x: number;
917
+ y: number;
918
+ } | {
919
+ type: 'Q';
920
+ x1: number;
921
+ y1: number;
922
+ x: number;
923
+ y: number;
924
+ } | {
925
+ type: 'C';
926
+ x1: number;
927
+ y1: number;
928
+ x2: number;
929
+ y2: number;
930
+ x: number;
931
+ y: number;
932
+ } | {
933
+ type: 'Z';
934
+ };
935
+ /** A path as a list of absolute move / line / quadratic / cubic / close commands. */
936
+ type BezierPath = BezierCommand[];
937
+ /** Anything the path operations accept as a path: SVG path data, parsed commands or a `BezierPath`. */
938
+ type BezierPathInput = string | readonly BezierCommand[] | readonly PathCommand[];
939
+ /**
940
+ * One segment as its control points: 2 points for a line, 3 for a quadratic and 4 for a
941
+ * cubic Bézier.
942
+ */
943
+ type BezierSegment = readonly Point[];
944
+ /** A subpath as a chain of segments (each starts where the previous one ends). */
945
+ interface BezierContour {
946
+ segments: BezierSegment[];
947
+ closed: boolean;
948
+ }
949
+ /** Point at parameter `t` (de Casteljau, works for any degree). */
950
+ declare function segmentPoint(seg: BezierSegment, t: number): Point;
951
+ /** First derivative at `t`. */
952
+ declare function segmentDerivative(seg: BezierSegment, t: number): Point;
953
+ /**
954
+ * Unit tangent at `t`. Where the derivative vanishes (a handle on its anchor) the direction
955
+ * a hair further along is used, and the chord as the last resort.
956
+ */
957
+ declare function segmentTangent(seg: BezierSegment, t: number): Point;
958
+ /** Signed curvature at `t` (positive when turning counter-clockwise in a y-up frame). */
959
+ declare function segmentCurvature(seg: BezierSegment, t: number): number;
960
+ /** Splits a segment at `t` (de Casteljau). */
961
+ declare function splitSegment(seg: BezierSegment, t: number): [Point[], Point[]];
962
+ /** The part of a segment between parameters `t0` and `t1` (reversed when `t1 < t0`). */
963
+ declare function subSegment(seg: BezierSegment, t0: number, t1: number): Point[];
964
+ /** Parameters in (0, 1) where the segment's `axis` coordinate has a local extremum. */
965
+ declare function segmentExtrema(seg: BezierSegment, axis: 0 | 1): number[];
966
+ /** Exact axis-aligned bounds of a segment. */
967
+ declare function segmentBounds(seg: BezierSegment): {
968
+ minX: number;
969
+ minY: number;
970
+ maxX: number;
971
+ maxY: number;
972
+ };
973
+ /** Arc length of the segment between `t0` and `t1` (default the whole segment). */
974
+ declare function segmentLength(seg: BezierSegment, t0?: number, t1?: number, tolerance?: number): number;
975
+ /** Parameter at arc length `length` from the segment start (clamped to [0, 1]). */
976
+ declare function segmentParamAtLength(seg: BezierSegment, length: number, total?: number): number;
977
+ /**
978
+ * Nearest point of the segment to `p`: the parameter and the distance. Coarse sampling
979
+ * followed by Newton refinement around the best samples.
980
+ */
981
+ declare function segmentNearest(seg: BezierSegment, p: Point): {
982
+ t: number;
983
+ distance: number;
984
+ };
985
+ /** Converts an SVG elliptical arc (SVG 1.1 F.6.5) to cubic segments, at most 90° each. */
986
+ declare function arcToCubics(from: Point, cmd: {
987
+ rx: number;
988
+ ry: number;
989
+ rotation: number;
990
+ largeArc: boolean;
991
+ sweep: boolean;
992
+ x: number;
993
+ y: number;
994
+ }): Point[][];
995
+ /**
996
+ * Converts SVG path data or parsed commands to a `BezierPath` (absolute `M` / `L` / `Q` /
997
+ * `C` / `Z`); elliptical arcs become cubic Béziers (at most 90° each).
998
+ */
999
+ declare function toBezierPath(input: BezierPathInput): BezierPath;
1000
+ /** Splits a path into contours of segments. Zero-length segments are dropped. */
1001
+ declare function pathToContours(input: BezierPathInput): BezierContour[];
1002
+ /** Builds a path from contours (a closed contour's closing line is left to `Z`). */
1003
+ declare function contoursToPath(contours: readonly BezierContour[]): BezierPath;
1004
+ interface BezierPathToSvgOptions {
1005
+ /** Decimal places (default 3). */
1006
+ precision?: number;
1007
+ /** Added to every point before formatting. */
1008
+ offset?: {
1009
+ x: number;
1010
+ y: number;
1011
+ };
1012
+ }
1013
+ /** Writes a path as compact SVG path data. */
1014
+ declare function bezierPathToSvg(input: BezierPathInput, options?: BezierPathToSvgOptions): string;
1015
+ /** 2D affine matrix `[a, b, c, d, e, f]` mapping `(x, y)` to `(a x + c y + e, b x + d y + f)`. */
1016
+ type AffineMatrix = readonly [number, number, number, number, number, number];
1017
+ /** Applies an affine transform to every point (exact for Bézier curves). */
1018
+ declare function transformBezierPath(input: BezierPathInput, m: AffineMatrix): BezierPath;
1019
+ /** Number of drawing segments (`L` / `Q` / `C`, plus the closing line of `Z` when it has length). */
1020
+ declare function countPathSegments(input: BezierPathInput): {
1021
+ lines: number;
1022
+ quads: number;
1023
+ cubics: number;
1024
+ };
1025
+ /** The contour's segments, with the closing line added when the contour is closed (or filled). */
1026
+ declare function closeContour(contour: BezierContour, force?: boolean): BezierSegment[];
1027
+ /** Exact bounds of a path, or `null` when it has no points. */
1028
+ declare function bezierPathBounds(input: BezierPathInput): {
1029
+ minX: number;
1030
+ minY: number;
1031
+ maxX: number;
1032
+ maxY: number;
1033
+ } | null;
1034
+ /**
1035
+ * Signed area of the path as drawn: every subpath closed, contributions summed (positive
1036
+ * for counter-clockwise subpaths in a y-up frame). Exact for curves. Overlapping subpaths
1037
+ * count with their multiplicity; use `bezierPathArea` for the filled area.
1038
+ */
1039
+ declare function bezierPathSignedArea(input: BezierPathInput): number;
1040
+ /** Signed area of a closed chain of segments. */
1041
+ declare function contourSignedArea(segs: readonly BezierSegment[]): number;
1042
+ /** Arc length of a path (closing lines of closed subpaths included). */
1043
+ declare function bezierPathLength(input: BezierPathInput): number;
1044
+ /** Point, unit tangent and angle (radians) at an arc length along the path. */
1045
+ interface PathPointAtLength {
1046
+ point: Point;
1047
+ tangent: Point;
1048
+ angle: number;
1049
+ /** Subpath index. */
1050
+ contour: number;
1051
+ /** Segment index within the subpath (closing line last). */
1052
+ segment: number;
1053
+ /** Parameter within the segment. */
1054
+ t: number;
1055
+ }
1056
+ /**
1057
+ * The point at arc length `length` from the start of the path (clamped to the path). Arc
1058
+ * lengths run through the subpaths in order, as `bezierPathLength` counts them.
1059
+ */
1060
+ declare function bezierPathPointAtLength(input: BezierPathInput, length: number): PathPointAtLength | null;
1061
+ /**
1062
+ * Splits a segment chain by arc length: the part between `from` and `to` (measured from the
1063
+ * chain's start) as new segments.
1064
+ */
1065
+ declare function trimSegments(segs: readonly BezierSegment[], from: number, to: number, lengths?: number[]): Point[][];
1066
+ /**
1067
+ * Winding number of a set of closed segment chains around `point` (ray to +x, half-open
1068
+ * crossing rule). Points exactly on the outline may report either side.
1069
+ */
1070
+ declare function windingNumber(chains: readonly (readonly BezierSegment[])[], point: Point): number;
1071
+ /** Whether `point` is inside the filled path (every subpath closed for filling). */
1072
+ declare function pointInBezierPath(input: BezierPathInput, point: Point, fillRule?: PolygonFillRule): boolean;
1073
+ /** Distance from `point` to the path outline (closing lines of closed subpaths included). */
1074
+ declare function distanceToBezierPath(input: BezierPathInput | readonly BezierContour[], point: Point): number;
1075
+
1076
+ /** Boolean operations (same names as `polygonBoolean`). `xor` is Exclude. */
1077
+ type PathBooleanOperation = PolygonBooleanOperation;
1078
+ /** A path with the fill rule it is read with (default `nonzero`). */
1079
+ interface PathOperand {
1080
+ path: BezierPathInput;
1081
+ fillRule?: PolygonFillRule;
1082
+ }
1083
+ type PathOperandInput = BezierPathInput | PathOperand;
1084
+ interface PathOpsOptions {
1085
+ /**
1086
+ * Distance below which points are treated as equal. Defaults to `1e-9` times the
1087
+ * largest coordinate magnitude (at least `1e-9`).
1088
+ */
1089
+ epsilon?: number;
1090
+ /** Fall back to the polygon engine when the curve engine fails (default `true`). */
1091
+ fallback?: boolean;
1092
+ /** Flattening tolerance used by the polygon fallback (default 0.05). */
1093
+ fallbackTolerance?: number;
1094
+ /** Called with the reason whenever the polygon fallback is used. */
1095
+ onFallback?: (reason: string) => void;
1096
+ /**
1097
+ * Work budget of the curve–curve intersection search (flat sub-curve pairs per pair of
1098
+ * pieces, default 20,000). Exceeding it (nearly coincident curves) falls back.
1099
+ */
1100
+ subdivisionBudget?: number;
1101
+ }
1102
+ /** Which engine produced a result, and why the curve engine was not used. */
1103
+ interface PathOpsReport {
1104
+ engine: 'curve' | 'polygon';
1105
+ fallbackReason?: string;
1106
+ /** Set when the input cannot be processed at all (non-finite coordinates); the result is empty. */
1107
+ error?: string;
1108
+ }
1109
+ interface PathBooleanResult extends PathOpsReport {
1110
+ path: BezierPath;
1111
+ }
1112
+ /** One region of `dividePaths`, with the indices of the operands that cover it. */
1113
+ interface PathPiece {
1114
+ path: BezierPath;
1115
+ operands: number[];
1116
+ }
1117
+ interface DividePathsResult extends PathOpsReport {
1118
+ pieces: PathPiece[];
1119
+ }
1120
+ /** Raised by the curve engine when it cannot produce a reliable arrangement. */
1121
+ declare class PathOpsError extends Error {
1122
+ constructor(message: string);
1123
+ }
1124
+ /**
1125
+ * Applies a boolean operation to any number of path operands, keeping curves:
1126
+ * - `union`: covered by any operand.
1127
+ * - `intersection`: covered by every operand.
1128
+ * - `difference`: the first operand minus all others.
1129
+ * - `xor`: covered by an odd number of operands (Exclude).
1130
+ *
1131
+ * Open subpaths are closed for filling. Non-finite input gives an empty path (`error`); with
1132
+ * `fallback: false` a failure of the curve engine throws a `PathOpsError`. The result is a set of simple closed subpaths that
1133
+ * never cross (they may touch at points): outer subpaths run counter-clockwise in a y-up
1134
+ * frame (clockwise on screen), holes the other way, so it fills the same with `nonzero`
1135
+ * and `evenodd`. Segments of the inputs are kept as exact sub-curves.
1136
+ */
1137
+ declare function pathBoolean(operation: PathBooleanOperation, operands: PathOperandInput[], options?: PathOpsOptions): PathBooleanResult;
1138
+ declare const unitePaths: (a: PathOperandInput, b: PathOperandInput, options?: PathOpsOptions) => BezierPath;
1139
+ declare const intersectPaths: (a: PathOperandInput, b: PathOperandInput, options?: PathOpsOptions) => BezierPath;
1140
+ declare const subtractPaths: (a: PathOperandInput, b: PathOperandInput, options?: PathOpsOptions) => BezierPath;
1141
+ declare const excludePaths: (a: PathOperandInput, b: PathOperandInput, options?: PathOpsOptions) => BezierPath;
1142
+ /**
1143
+ * Splits the arrangement of the operands into its regions (Divide): every connected area
1144
+ * covered by the same set of operands becomes one piece (an outer subpath with its holes).
1145
+ * Pieces are ordered by operand set, then by area (largest first).
1146
+ */
1147
+ declare function dividePaths(operands: PathOperandInput[], options?: PathOpsOptions): DividePathsResult;
1148
+ /**
1149
+ * Resolves self-intersections and overlaps of one filled path into simple, consistently
1150
+ * oriented subpaths (outer subpaths and holes) under its fill rule.
1151
+ */
1152
+ declare function normalizeBezierPath(path: BezierPathInput, fillRule?: PolygonFillRule, options?: PathOpsOptions): BezierPath;
1153
+ /** Filled area of a path under its fill rule (overlaps counted once; exact for curves). */
1154
+ declare function bezierPathArea(path: BezierPathInput, fillRule?: PolygonFillRule, options?: PathOpsOptions): number;
1155
+
1156
+ /**
1157
+ * Offset Path and Outline Stroke on Bézier paths.
1158
+ *
1159
+ * The stroker offsets every segment by ± half the width (lines exactly, curves by cubic
1160
+ * approximations refined until they stay within `tolerance` of the true offset), joins the
1161
+ * pieces (miter with a miter limit, round or bevel on the outer side of a turn; through the
1162
+ * vertex on the inner side) and adds caps (butt, round, square) to open subpaths. Dashes
1163
+ * follow arc length, restart on every subpath and join across the start of a closed
1164
+ * subpath. The raw outline overlaps itself, so it is filled with the non-zero rule and
1165
+ * normalised with the curve boolean engine.
1166
+ *
1167
+ * When the stroke is wider than a curve's radius of curvature the inner offset turns inside
1168
+ * out and its loops cancel winding, leaving holes that are really covered. Every face of
1169
+ * the true result is bounded by the arrangement, so a face is spurious exactly when a point
1170
+ * deep inside it is closer to the path than the offset distance (holes when growing,
1171
+ * islands when insetting); such faces are dropped.
1172
+ *
1173
+ * Portions ported from vectorcraft-main/crates/pathops/src/offset.rs,
1174
+ * vectorcraft-main/crates/pathops/src/boolean.rs (`try_merge`) and
1175
+ * vectorcraft-main/crates/effects/src/stroke/dash.rs (MIT OR Apache-2.0, © ArtCraft Team
1176
+ * and contributors). See THIRD_PARTY_NOTICES.md.
1177
+ */
1178
+
1179
+ /** Line join (as SVG `stroke-linejoin`). */
1180
+ type StrokeJoin = 'miter' | 'round' | 'bevel';
1181
+ /** Line cap (as SVG `stroke-linecap`). */
1182
+ type StrokeCap = 'butt' | 'round' | 'square';
1183
+ interface OutlineStrokeOptions extends PathOpsOptions {
1184
+ /** Stroke width. Non-positive or non-finite widths give an empty result. */
1185
+ width: number;
1186
+ /** Default `miter` (as SVG). */
1187
+ join?: StrokeJoin;
1188
+ /** Default `butt` (as SVG). */
1189
+ cap?: StrokeCap;
1190
+ /** Miter length / stroke width above which a miter join is bevelled (default 4, as SVG). */
1191
+ miterLimit?: number;
1192
+ /** Dash pattern (as SVG `stroke-dasharray`); odd patterns repeat twice. */
1193
+ dash?: readonly number[];
1194
+ /** Distance into the dash pattern at the start of each subpath (as `stroke-dashoffset`). */
1195
+ dashOffset?: number;
1196
+ /** Maximum distance between the approximated and the true offset curve (default 0.01). */
1197
+ tolerance?: number;
1198
+ }
1199
+ interface OffsetPathOptions extends PathOpsOptions {
1200
+ /** Corner style of the grown / shrunk outline (default `miter`). */
1201
+ join?: StrokeJoin;
1202
+ /** Miter limit (default 4). */
1203
+ miterLimit?: number;
1204
+ /** Fill rule of the input (default `nonzero`). */
1205
+ fillRule?: PolygonFillRule;
1206
+ /** Maximum distance between the approximated and the true offset curve (default 0.01). */
1207
+ tolerance?: number;
1208
+ }
1209
+ interface DashedPath {
1210
+ /** The dashes, as open subpaths. */
1211
+ contours: BezierContour[];
1212
+ /** Zero-length dashes: where they sit and the path direction there. */
1213
+ dots: {
1214
+ point: Point;
1215
+ tangent: Point;
1216
+ }[];
1217
+ }
1218
+ /**
1219
+ * Applies a dash pattern (SVG `stroke-dasharray` / `stroke-dashoffset` semantics) to the
1220
+ * subpaths. Returns `null` when the pattern is invalid (negative or non-finite entries),
1221
+ * has no positive entry, or would make more than 200,000 dashes: the line is solid.
1222
+ */
1223
+ declare function dashContours(contours: readonly BezierContour[], pattern: readonly number[], offset?: number): DashedPath | null;
1224
+ /**
1225
+ * The raw (overlapping) outline of a stroke as closed subpaths to fill with `nonzero`.
1226
+ * `outlineStroke` normalises it; this is useful for previews.
1227
+ */
1228
+ declare function strokeOutlineRings(input: BezierPathInput, options: OutlineStrokeOptions): BezierPath;
1229
+ /**
1230
+ * Outline Stroke: the filled area painted by stroking `path`, as one clean path (overlaps
1231
+ * removed, consistently oriented). Joins, caps, miter limit and dashes follow SVG.
1232
+ */
1233
+ declare function outlineStroke(input: BezierPathInput, options: OutlineStrokeOptions): BezierPath;
1234
+ /**
1235
+ * Offset Path: grows (`distance > 0`) or shrinks (`distance < 0`) the filled area by
1236
+ * `distance`. Closed subpaths are a filled region (read with `fillRule`); open subpaths are
1237
+ * outlined with a stroke of width `2·|distance|` and butt caps (when growing). Loops of the
1238
+ * offset curves are removed.
1239
+ */
1240
+ declare function offsetPath(input: BezierPathInput, distance: number, options?: OffsetPathOptions): BezierPath;
1241
+
901
1242
  /**
902
1243
  * Shape nodes and Freeform-style shape boolean operations (Unite / Intersect / Subtract /
903
1244
  * Exclude / Divide) on canvas nodes.
@@ -929,6 +1270,22 @@ declare function shapeNodeToPolygon(node: CanvasNode, lookup?: ReadonlyMap<strin
929
1270
  rings: PolygonRing[];
930
1271
  fillRule: PolygonFillRule;
931
1272
  } | null;
1273
+ /**
1274
+ * A shape as an exact Bézier path in node-local pixels (rotation and path view boxes
1275
+ * applied; arcs become cubics), with the fill rule it is read with.
1276
+ */
1277
+ declare function shapeToBezierPath(shape: ShapeDescription, size: ShapeSize): {
1278
+ path: BezierPath;
1279
+ fillRule: PolygonFillRule;
1280
+ };
1281
+ /**
1282
+ * A shape node's outline as an exact Bézier path in absolute flow coordinates (parent
1283
+ * offsets, size and rotation applied), or `null` for non-shape nodes.
1284
+ */
1285
+ declare function shapeNodeToBezierPath(node: CanvasNode, lookup?: ReadonlyMap<string, CanvasNode>, options?: NodeRectOptions): {
1286
+ path: BezierPath;
1287
+ fillRule: PolygonFillRule;
1288
+ } | null;
932
1289
  /** Why `combineShapeNodes` refused. */
933
1290
  type CombineShapeNodesRefusal =
934
1291
  /** A selected shape is locked; locked shapes are never consumed. */
@@ -955,9 +1312,20 @@ interface CombineShapeNodesOptions extends ShapeNodePolygonOptions {
955
1312
  /** Ramer–Douglas–Peucker simplification tolerance for the result (default 0, off). */
956
1313
  simplify?: number;
957
1314
  /**
958
- * How the result's outline is written: `'fit'` (default) fits smooth cubic curves to the
959
- * flattened result, so booleans of curved shapes stay curved (sharp corners and straight
960
- * edges are kept); `'lines'` writes the polygon as straight segments.
1315
+ * Geometry engine. `'curve'` (default) computes the operation on the exact Bézier
1316
+ * outlines and keeps the inputs' curves (circles stay cubic arcs, rectangles stay four
1317
+ * lines); it falls back to `'polygon'` when it cannot resolve the input (reported as
1318
+ * `engine` / `fallbackReason` on the result). `'polygon'` flattens the shapes and uses
1319
+ * `polygonBoolean` (the behaviour before curve booleans). `curves: 'lines'` implies
1320
+ * `'polygon'` unless an engine is named.
1321
+ */
1322
+ engine?: 'curve' | 'polygon';
1323
+ /** Called with the reason when the curve engine falls back to polygons. */
1324
+ onFallback?: (reason: string) => void;
1325
+ /**
1326
+ * Polygon engine only: how the result's outline is written: `'fit'` (default) fits
1327
+ * smooth cubic curves to the flattened result (sharp corners and straight edges are
1328
+ * kept); `'lines'` writes the polygon as straight segments.
961
1329
  */
962
1330
  curves?: 'lines' | 'fit';
963
1331
  /** Curve-fitting tolerance in flow units for `curves: 'fit'` (default: `tolerance`, 0.25). */
@@ -976,6 +1344,10 @@ type CombineShapeNodesResult<TNode extends CanvasNode = CanvasNode> = {
976
1344
  removeIds: string[];
977
1345
  /** New path shape node(s): one, or one per region for `divide`. */
978
1346
  nodes: TNode[];
1347
+ /** Engine that produced the geometry (`polygon` after a fallback). */
1348
+ engine: 'curve' | 'polygon';
1349
+ /** Why the curve engine fell back to polygons. */
1350
+ fallbackReason?: string;
979
1351
  } | {
980
1352
  ok: false;
981
1353
  operation: ShapeOperation;
@@ -1029,6 +1401,129 @@ declare function revertShapeCombination<TNode extends CanvasNode>(nodes: TNode[]
1029
1401
  removeIds: Iterable<string>;
1030
1402
  nodes: TNode[];
1031
1403
  }, previous: TNode[]): TNode[];
1404
+ /** Per-node path edits: `offset` (Offset Path) and `outlineStroke` (Outline Stroke). */
1405
+ type ShapePathEditOperation = 'offset' | 'outlineStroke';
1406
+ /** Why `offsetShapeNodes` / `outlineShapeNodeStrokes` refused. */
1407
+ type ShapePathEditRefusal =
1408
+ /** A selected shape is locked. */
1409
+ 'locked'
1410
+ /** No shape node was selected. */
1411
+ | 'no-shapes'
1412
+ /** Outline Stroke: no selected shape has a visible stroke. */
1413
+ | 'no-stroke'
1414
+ /** Every result is empty (e.g. an inset larger than the shapes). */
1415
+ | 'empty'
1416
+ /** The offset distance or stroke width is not a finite number. */
1417
+ | 'invalid';
1418
+ type ShapePathEditResult<TNode extends CanvasNode = CanvasNode> = {
1419
+ ok: true;
1420
+ operation: ShapePathEditOperation;
1421
+ /** Ids of the replaced nodes. */
1422
+ removeIds: string[];
1423
+ /** All new nodes (a replaced node may come back with the same id). */
1424
+ nodes: TNode[];
1425
+ /** Each replaced node with the nodes that take its place, in stacking order. */
1426
+ replacements: {
1427
+ id: string;
1428
+ nodes: TNode[];
1429
+ }[];
1430
+ } | {
1431
+ ok: false;
1432
+ operation: ShapePathEditOperation;
1433
+ reason: ShapePathEditRefusal;
1434
+ };
1435
+ interface ShapePathEditBaseOptions extends NodeRectOptions {
1436
+ /** Id factory for new nodes (default `crypto.randomUUID`, with a counter fallback). */
1437
+ createId?: (index: number) => string;
1438
+ /** Node `type` for the new nodes (default: the source node's type). */
1439
+ nodeType?: string;
1440
+ /** Decimal places in the path data (default 3). */
1441
+ precision?: number;
1442
+ /** Select the new nodes (default `true`). */
1443
+ select?: boolean;
1444
+ /** Maximum error of the approximated offset curves in flow units (default 0.01). */
1445
+ tolerance?: number;
1446
+ /** Point-merge tolerance passed to the boolean engine. */
1447
+ epsilon?: number;
1448
+ /** Called with the reason when the curve engine falls back to polygons. */
1449
+ onFallback?: (reason: string) => void;
1450
+ }
1451
+ interface OffsetShapeNodesOptions extends ShapePathEditBaseOptions {
1452
+ /** Corner style of the offset outline (default `miter`). */
1453
+ join?: StrokeJoin;
1454
+ /** Miter limit (default 4). */
1455
+ miterLimit?: number;
1456
+ /** Keep the original shape above the offset one (Illustrator style; default `false`: replace it). */
1457
+ keepOriginal?: boolean;
1458
+ }
1459
+ interface OutlineShapeStrokesOptions extends ShapePathEditBaseOptions {
1460
+ /** Stroke width in flow units (default: the shape's `strokeWidth`, 1 when unset). */
1461
+ width?: number;
1462
+ /** Default `miter`, as SVG. */
1463
+ join?: StrokeJoin;
1464
+ /** Default `butt`, as SVG. */
1465
+ cap?: StrokeCap;
1466
+ /** Default 4, as SVG. */
1467
+ miterLimit?: number;
1468
+ /** Dash pattern (as `stroke-dasharray`). */
1469
+ dash?: readonly number[];
1470
+ dashOffset?: number;
1471
+ /**
1472
+ * Keep the shape's fill as the original node with its stroke removed, below the outlined
1473
+ * stroke (default `true`). With `false`, or when the shape has no visible fill, the node is
1474
+ * replaced by the outlined stroke alone.
1475
+ */
1476
+ keepFill?: boolean;
1477
+ }
1478
+ /** Whether a shape draws a stroke (a stroke colour other than `none` and a positive width). */
1479
+ declare function hasVisibleStroke(shape: ShapeDescription | null): boolean;
1480
+ /** Checks whether `offsetShapeNodes` can run (it cannot predict an `empty` result). */
1481
+ declare function canOffsetShapeNodes(nodes: CanvasNode[], ids: Iterable<string>): {
1482
+ ok: true;
1483
+ shapeIds: string[];
1484
+ } | {
1485
+ ok: false;
1486
+ reason: 'locked' | 'no-shapes';
1487
+ };
1488
+ /** Checks whether `outlineShapeNodeStrokes` can run. */
1489
+ declare function canOutlineShapeNodeStrokes(nodes: CanvasNode[], ids: Iterable<string>): {
1490
+ ok: true;
1491
+ shapeIds: string[];
1492
+ } | {
1493
+ ok: false;
1494
+ reason: 'locked' | 'no-shapes' | 'no-stroke';
1495
+ };
1496
+ /**
1497
+ * Offset Path on shape nodes: each selected shape grows (`distance > 0`) or shrinks
1498
+ * (`distance < 0`) by `distance` flow units, keeping curves. The result replaces the shape
1499
+ * (or sits below it with `keepOriginal`) as a `path` shape node with the same paint. Shapes
1500
+ * whose offset is empty are left unchanged; refuses when every result is empty, a selected
1501
+ * shape is locked or no shape is selected. Pure: apply with `applyShapeReplacement`.
1502
+ */
1503
+ declare function offsetShapeNodes<TNode extends CanvasNode>(nodes: TNode[], ids: Iterable<string>, distance: number, options?: OffsetShapeNodesOptions): ShapePathEditResult<TNode>;
1504
+ /**
1505
+ * Outline Stroke on shape nodes: each selected shape with a visible stroke gets its stroke
1506
+ * converted to a filled `path` shape node (filled with the stroke colour, no stroke), using
1507
+ * the stroke width in flow units (strokes do not scale with the node) and SVG's default
1508
+ * miter join, miter limit 4 and butt caps unless overridden. The shape's fill stays as the
1509
+ * original node without its stroke, below the outline (`keepFill`). Pure: apply with
1510
+ * `applyShapeReplacement`.
1511
+ */
1512
+ declare function outlineShapeNodeStrokes<TNode extends CanvasNode>(nodes: TNode[], ids: Iterable<string>, options?: OutlineShapeStrokesOptions): ShapePathEditResult<TNode>;
1513
+ /**
1514
+ * Applies a successful `offsetShapeNodes` / `outlineShapeNodeStrokes` result: each replaced
1515
+ * node is swapped in place for its replacement nodes, so the stacking order of everything
1516
+ * else is kept. With `deselect` (default `true`) other nodes are deselected when the
1517
+ * result is selected. Undo with `revertShapeCombination(nodes, result, previous)`.
1518
+ */
1519
+ declare function applyShapeReplacement<TNode extends CanvasNode>(nodes: TNode[], change: {
1520
+ replacements: {
1521
+ id: string;
1522
+ nodes: TNode[];
1523
+ }[];
1524
+ }, options?: {
1525
+ deselect?: boolean;
1526
+ }): TNode[];
1032
1527
 
1033
1528
  /** A resize handle, named like xyflow's `ControlPosition`. */
1034
1529
  type ResizeHandle = 'top-left' | 'top' | 'top-right' | 'right' | 'bottom-right' | 'bottom' | 'bottom-left' | 'left';
@@ -1389,6 +1884,23 @@ declare function createCanvasArrangeController<TNode extends CanvasNode = Canvas
1389
1884
  divide: (ids?: Iterable<string>, o?: CombineShapeNodesOptions) => CombineShapeNodesResult<TNode>;
1390
1885
  /** Whether the shape operations can run on `ids` (default: the selection). */
1391
1886
  canCombineShapes: (ids?: Iterable<string>) => boolean;
1887
+ /**
1888
+ * Offset Path: grows (`distance > 0`) or shrinks (`distance < 0`) every shape among
1889
+ * `ids` (default: the selection) by `distance` flow units, keeping curves, as one
1890
+ * undoable step. Refuses without changing anything when a shape is locked, no shape is
1891
+ * selected or every result is empty.
1892
+ */
1893
+ offsetShapes(distance: number, ids?: Iterable<string>, offsetOptions?: OffsetShapeNodesOptions): ShapePathEditResult<TNode>;
1894
+ /** Whether `offsetShapes` can run on `ids` (default: the selection). */
1895
+ canOffsetShapes: (ids?: Iterable<string>) => boolean;
1896
+ /**
1897
+ * Outline Stroke: converts the strokes of the shapes among `ids` (default: the
1898
+ * selection) to filled path shapes, as one undoable step. Refuses when a shape is
1899
+ * locked or no selected shape has a visible stroke.
1900
+ */
1901
+ outlineStroke(ids?: Iterable<string>, outlineOptions?: OutlineShapeStrokesOptions): ShapePathEditResult<TNode>;
1902
+ /** Whether `outlineStroke` can run on `ids` (default: the selection). */
1903
+ canOutlineStroke: (ids?: Iterable<string>) => boolean;
1392
1904
  /**
1393
1905
  * Runs a shortcut action. Scene actions are not handled here (see the scenes store);
1394
1906
  * returns `false` for them and for unknown actions.
@@ -1687,4 +2199,105 @@ declare function createCanvasAutoLayoutController<TNode extends CanvasNode = Can
1687
2199
  };
1688
2200
  type CanvasAutoLayoutController<TNode extends CanvasNode = CanvasNode> = ReturnType<typeof createCanvasAutoLayoutController<TNode>>;
1689
2201
 
1690
- export { AUTO_LAYOUT_DATA_KEY, AlignEdge, AlignNodesOptions, type ArrangeHistoryTarget, type AutoLayout, type AutoLayoutAlignContent, type AutoLayoutAlignCross, type AutoLayoutAlignMain, type AutoLayoutCellAlign, type AutoLayoutChild, type AutoLayoutConstraints, type AutoLayoutGrid, type AutoLayoutGridArea, type AutoLayoutGridCell, type AutoLayoutGridGeometry, type AutoLayoutGridTrack, type AutoLayoutHorizontalConstraint, type AutoLayoutInsertTarget, type AutoLayoutMeasure, type AutoLayoutMode, type AutoLayoutOptions, type AutoLayoutPadding, type AutoLayoutSize, type AutoLayoutSizing, type AutoLayoutSizingPair, type AutoLayoutVerticalConstraint, CHILD_LAYOUT_DATA_KEY, CONNECTION_LINE_TYPES, CanvasArrangeAction, type CanvasArrangeController, type CanvasArrangeControllerOptions, type CanvasAutoLayoutController, type CanvasAutoLayoutControllerOptions, CanvasClipboardPayload, type CanvasConnectionLineType, CanvasEdge, type CanvasHeightOptions, CanvasLayoutOptions, CanvasNode, CanvasNodeStyle, CanvasNodeUpdate, type CanvasScene, type CanvasScenesOptions, type CanvasScenesState, CanvasScenesStore, type CanvasViewport, type Clock, type CombineShapeNodesOptions, type CombineShapeNodesRefusal, type CombineShapeNodesResult, type ConnectorSnap, type ConnectorSnapOptions, type ConnectorSnapTarget, type CubicSegment, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, DirectionalDisplacementOptions, DistributeAxis, DistributeMode, DistributeNodesOptions, type EllipseShape, FanOutTrajectoryOptions, type FitCubicsOptions, type FitPathDataOptions, type FitViewportOptions, type FlattenOptions, type GuideIndex, type GuideLine, IncrementalLayoutOptions, ManualClock, MatchSizeOptions, type MeasureGuide, type MeasureSelectionOptions, type MeasureSelectionResult, type MultiNodeTransitionOptions, type MultiPolygon, NodeRectOptions, NodeTransition, type PathCommand, type PathShape, PlaceBesideOptions, Point, type PolygonBooleanOperation, type PolygonBooleanOptions, type PolygonFillRule, type PolygonInput, type PolygonOperand, type PolygonPiece, type PolygonRing, type PolygonToPathOptions, type PolygonWithHoles, Position, type PositionChangeLike, RESIZE_HANDLES, Rect, type RectShape, ReflowDisplacementOptions, type RegularPolygonShape, type ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, type SerializedCanvasScenes, type ShapeDescription, type ShapeKind, type ShapeNodePolygonOptions, type ShapeOperation, type ShapePaint, type ShapeRenderData, type ShapeSize, Side, SizeDimension, type SnapGuidesOptions, type SnapNodeDragOptions, type SnapNodeDragResult, type SnapNodeResizeOptions, type SnapNodeResizeResult, type SnapResizeOptions, type SnapResizeResult, type SnapResult, type StarShape, StreamingLayoutManager, type StreamingLayoutManagerOptions, TrajectoryFunction, XYPosition, ZOrderOperation, applyConstraints, applyShapeCombination, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canvasHeight, centerNodes, centre, clampLayoutSize, collectDescendantIds, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, createBezierTrajectory, createCanvasArrangeController, createCanvasAutoLayoutController, createCanvasScenesStore, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicPointAt, cubicsToPathData, defaultEasing, dividePolygons, ensureLayout, estimateCanvasHeight, estimateNodeSize, findConnectorSnap, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatNumber, getAutoLayout, getAutoLayoutGrid, getAutoLayoutInsertTarget, getCenteredNodePosition, getChildLayout, getFlowChildren, getLayoutParent, getLayoutSizing, getLayoutedNodes, getNodeShape, getResizingNodeRect, getShapeRenderData, getShapeSvg, handlePoint, inferResizeHandle, intersectPolygons, isAutoLayoutFrame, isEventFromTextInput, isMeasureModifierHeld, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasEdge, isValidCanvasNode, isValidCanvasScene, isValidUrl, layoutAll, layoutBounds, layoutFrame, layoutUp, layoutUpMany, linearPositionTrajectory, linearTrajectory, makeSizingCoherent, measureBetween, measureLabel, measureSelection, measureToLine, mergeNodeUpdates, moveLayoutChild, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, oppositePosition, overlaps, pageHidden, parseCanvasClipboardData, parseCanvasScenes, parseSvgPath, placeBeside, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, realClock, relayoutUpdates, remapPastedNodes, repositionNodesTo, resizeHandleAxes, resolvePadding, revertShapeCombination, ringSignedArea, runMultiNodeTransition, serializeCanvasNodes, shapeNodeToPolygon, shapeToPolygon, sideToPosition, simplifyRing, snapNodeDrag, snapNodeResize, snapResize, snapToGrid, subtractPolygons, unionPolygons, withStyleOpacity, xorPolygons };
2202
+ /**
2203
+ * Design-token bindings on canvas nodes.
2204
+ *
2205
+ * - `node.data.tokenBindings` maps a property key (`fill`, `opacity`, `gap`, …) to a variable id.
2206
+ * - `node.data.tokenModes` maps a collection id to a mode id: an explicit mode for the node and
2207
+ * its descendants (via `parentId`); the nearest ancestor wins, then the root `modes` option,
2208
+ * then the collection's default mode.
2209
+ *
2210
+ * Bound properties are *materialised*: `resolveCanvasTokens` writes the resolved values into
2211
+ * the ordinary node fields (`data.shape.fill`, `style.backgroundColor`, `data.layout.gap`, …), so
2212
+ * renderers, auto layout and exports need no token awareness, and a node whose variable is
2213
+ * gone keeps its last value. Both keys live in `data`, so they survive copy / paste,
2214
+ * duplication and serialisation unchanged.
2215
+ */
2216
+ /** Data key holding a node's property → variable id bindings. */
2217
+ declare const TOKEN_BINDINGS_DATA_KEY = "tokenBindings";
2218
+ /** Data key holding a node's explicit collection → mode choices. */
2219
+ declare const TOKEN_MODES_DATA_KEY = "tokenModes";
2220
+ /** A node property a variable can drive. */
2221
+ interface CanvasTokenProperty {
2222
+ key: string;
2223
+ label: string;
2224
+ /** The variable type it takes. */
2225
+ type: TokenType;
2226
+ /** The scope pickers filter by (variables scoped elsewhere are not offered). */
2227
+ scope?: TokenScope | ((node: CanvasNode) => TokenScope | undefined);
2228
+ appliesTo(node: CanvasNode): boolean;
2229
+ read(node: CanvasNode): TokenLiteral | undefined;
2230
+ /** Returns the node with the value written, or the same node when nothing changes. */
2231
+ write(node: CanvasNode, value: TokenLiteral): CanvasNode;
2232
+ }
2233
+ /** A style property (camelCase name) from a style string or object. */
2234
+ declare function readNodeStyleProperty(style: CanvasNodeStyle | undefined | null, prop: string): string | number | undefined;
2235
+ /**
2236
+ * Returns `style` with one property set (or removed with `undefined`), keeping its
2237
+ * representation. Numbers become `px` in style strings unless `unitless`.
2238
+ */
2239
+ declare function writeNodeStyleProperty(style: CanvasNodeStyle | undefined | null, prop: string, value: string | number | undefined, unitless?: boolean): CanvasNodeStyle | undefined;
2240
+ /** The built-in bindable properties. */
2241
+ declare const CANVAS_TOKEN_PROPERTIES: readonly CanvasTokenProperty[];
2242
+ interface CanvasTokenOptions {
2243
+ /** Modes for nodes without an explicit mode up their tree (e.g. the page's). */
2244
+ modes?: TokenModeContext;
2245
+ /** Bindable properties (default {@link CANVAS_TOKEN_PROPERTIES}); add your own to extend. */
2246
+ properties?: readonly CanvasTokenProperty[];
2247
+ }
2248
+ /** The node's property → variable id bindings. */
2249
+ declare function getNodeTokenBindings(node: CanvasNode | undefined | null): Readonly<Record<string, string>>;
2250
+ /** The node's own explicit modes (collection id → mode id). */
2251
+ declare function getNodeTokenModes(node: CanvasNode | undefined | null): Readonly<Record<string, string>>;
2252
+ declare function getCanvasTokenProperty(key: string, options?: CanvasTokenOptions): CanvasTokenProperty | undefined;
2253
+ /** Properties a variable can be bound to on this node. */
2254
+ declare function getBindableTokenProperties(node: CanvasNode, options?: CanvasTokenOptions): CanvasTokenProperty[];
2255
+ /** The scope of a property on a node. */
2256
+ declare function getTokenPropertyScope(property: CanvasTokenProperty, node: CanvasNode): TokenScope | undefined;
2257
+ /** Variables a picker offers for `property` on `node`: the property's type, in scope. */
2258
+ declare function getTokensForProperty(state: TokenState, property: CanvasTokenProperty, node: CanvasNode): TokenVariable[];
2259
+ /**
2260
+ * The modes `node` is in: the root `modes`, overridden by each ancestor's explicit modes from
2261
+ * the top down, then the node's own. Modes `state` doesn't know are ignored.
2262
+ */
2263
+ declare function getEffectiveTokenModes(node: CanvasNode, nodes: readonly CanvasNode[] | ReadonlyMap<string, CanvasNode>, state?: TokenState, options?: Pick<CanvasTokenOptions, 'modes'>): Record<string, string>;
2264
+ /**
2265
+ * Writes every bound property's resolved value into its node. Returns the same array when
2266
+ * nothing changed (unchanged nodes keep their identity), so it is safe to run on every change.
2267
+ * Bindings that don't resolve (deleted variable, cycle) keep the node's current value.
2268
+ */
2269
+ declare function resolveCanvasTokens<TNode extends CanvasNode>(nodes: readonly TNode[], state: TokenState, options?: CanvasTokenOptions): TNode[];
2270
+ interface CanvasTokenBindingInfo {
2271
+ property: CanvasTokenProperty;
2272
+ variableId: string;
2273
+ variable: TokenVariable | undefined;
2274
+ resolution: TokenResolution;
2275
+ }
2276
+ /** Each binding of a node with its variable and resolution (for inspectors and diagnostics). */
2277
+ declare function inspectNodeTokens(node: CanvasNode, nodes: readonly CanvasNode[], state: TokenState, options?: CanvasTokenOptions): CanvasTokenBindingInfo[];
2278
+ /**
2279
+ * Binds `property` of each node in `ids` to `variableId` (or unbinds with `null`, keeping the
2280
+ * current value) and resolves. Throws `type-mismatch` when the variable's type doesn't fit the
2281
+ * property, `not-found` for unknown variables or properties. Nodes the property doesn't apply
2282
+ * to are left alone.
2283
+ */
2284
+ declare function bindCanvasToken<TNode extends CanvasNode>(nodes: readonly TNode[], ids: Iterable<string>, propertyKey: string, variableId: string | null, state: TokenState, options?: CanvasTokenOptions): TNode[];
2285
+ /**
2286
+ * Sets (or with `null` clears, back to "Auto") the explicit mode of `collectionId` on each node
2287
+ * in `ids`, then resolves, so descendants follow.
2288
+ */
2289
+ declare function setCanvasTokenMode<TNode extends CanvasNode>(nodes: readonly TNode[], ids: Iterable<string>, collectionId: string, modeId: string | null, state: TokenState, options?: CanvasTokenOptions): TNode[];
2290
+ /**
2291
+ * Detaches bindings to `variableIds` (default: every binding whose variable is missing from
2292
+ * `state`): each property keeps its value resolved in `state` and the binding is removed. Pass
2293
+ * the state from *before* a delete (`TokenChangeEvent.previous`) so deleted variables still
2294
+ * resolve.
2295
+ */
2296
+ declare function detachTokenBindings<TNode extends CanvasNode>(nodes: readonly TNode[], state: TokenState, variableIds?: Iterable<string>, options?: CanvasTokenOptions): TNode[];
2297
+ /**
2298
+ * Removes explicit modes `state` no longer knows (deleted collections or modes), like figcraft
2299
+ * resetting such layers to "Auto". Resolution already ignores them; this tidies the data.
2300
+ */
2301
+ declare function pruneCanvasTokenModes<TNode extends CanvasNode>(nodes: readonly TNode[], state: TokenState): TNode[];
2302
+
2303
+ export { AUTO_LAYOUT_DATA_KEY, type AffineMatrix, AlignEdge, AlignNodesOptions, type ArrangeHistoryTarget, type AutoLayout, type AutoLayoutAlignContent, type AutoLayoutAlignCross, type AutoLayoutAlignMain, type AutoLayoutCellAlign, type AutoLayoutChild, type AutoLayoutConstraints, type AutoLayoutGrid, type AutoLayoutGridArea, type AutoLayoutGridCell, type AutoLayoutGridGeometry, type AutoLayoutGridTrack, type AutoLayoutHorizontalConstraint, type AutoLayoutInsertTarget, type AutoLayoutMeasure, type AutoLayoutMode, type AutoLayoutOptions, type AutoLayoutPadding, type AutoLayoutSize, type AutoLayoutSizing, type AutoLayoutSizingPair, type AutoLayoutVerticalConstraint, type BezierCommand, type BezierContour, type BezierPath, type BezierPathInput, type BezierPathToSvgOptions, type BezierSegment, CANVAS_TOKEN_PROPERTIES, CHILD_LAYOUT_DATA_KEY, CONNECTION_LINE_TYPES, CanvasArrangeAction, type CanvasArrangeController, type CanvasArrangeControllerOptions, type CanvasAutoLayoutController, type CanvasAutoLayoutControllerOptions, CanvasClipboardPayload, type CanvasConnectionLineType, CanvasEdge, type CanvasHeightOptions, CanvasLayoutOptions, CanvasNode, CanvasNodeStyle, CanvasNodeUpdate, type CanvasScene, type CanvasScenesOptions, type CanvasScenesState, CanvasScenesStore, type CanvasTokenBindingInfo, type CanvasTokenOptions, type CanvasTokenProperty, type CanvasViewport, type Clock, type CombineShapeNodesOptions, type CombineShapeNodesRefusal, type CombineShapeNodesResult, type ConnectorSnap, type ConnectorSnapOptions, type ConnectorSnapTarget, type CubicSegment, DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DEFAULT_PLACEMENT_GAP, type DashedPath, DirectionalDisplacementOptions, DistributeAxis, DistributeMode, DistributeNodesOptions, type DividePathsResult, type EllipseShape, FanOutTrajectoryOptions, type FitCubicsOptions, type FitPathDataOptions, type FitViewportOptions, type FlattenOptions, type GuideIndex, type GuideLine, IncrementalLayoutOptions, ManualClock, MatchSizeOptions, type MeasureGuide, type MeasureSelectionOptions, type MeasureSelectionResult, type MultiNodeTransitionOptions, type MultiPolygon, NodeRectOptions, NodeTransition, type OffsetPathOptions, type OffsetShapeNodesOptions, type OutlineShapeStrokesOptions, type OutlineStrokeOptions, type PathBooleanOperation, type PathBooleanResult, type PathCommand, type PathOperand, type PathOperandInput, PathOpsError, type PathOpsOptions, type PathOpsReport, type PathPiece, type PathPointAtLength, type PathShape, PlaceBesideOptions, Point, type PolygonBooleanOperation, type PolygonBooleanOptions, type PolygonFillRule, type PolygonInput, type PolygonOperand, type PolygonPiece, type PolygonRing, type PolygonToPathOptions, type PolygonWithHoles, Position, type PositionChangeLike, RESIZE_HANDLES, Rect, type RectShape, ReflowDisplacementOptions, type RegularPolygonShape, type ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, type SerializedCanvasScenes, type ShapeDescription, type ShapeKind, type ShapeNodePolygonOptions, type ShapeOperation, type ShapePaint, type ShapePathEditOperation, type ShapePathEditRefusal, type ShapePathEditResult, type ShapeRenderData, type ShapeSize, Side, SizeDimension, type SnapGuidesOptions, type SnapNodeDragOptions, type SnapNodeDragResult, type SnapNodeResizeOptions, type SnapNodeResizeResult, type SnapResizeOptions, type SnapResizeResult, type SnapResult, type StarShape, StreamingLayoutManager, type StreamingLayoutManagerOptions, type StrokeCap, type StrokeJoin, TOKEN_BINDINGS_DATA_KEY, TOKEN_MODES_DATA_KEY, TrajectoryFunction, XYPosition, ZOrderOperation, applyConstraints, applyShapeCombination, applyShapeReplacement, arcToCubics, bezierPathArea, bezierPathBounds, bezierPathLength, bezierPathPointAtLength, bezierPathSignedArea, bezierPathToSvg, bindCanvasToken, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canOffsetShapeNodes, canOutlineShapeNodeStrokes, canvasHeight, centerNodes, centre, clampLayoutSize, closeContour, collectDescendantIds, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, contourSignedArea, contoursToPath, countPathSegments, createBezierTrajectory, createCanvasArrangeController, createCanvasAutoLayoutController, createCanvasScenesStore, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicPointAt, cubicsToPathData, dashContours, defaultEasing, detachTokenBindings, distanceToBezierPath, dividePaths, dividePolygons, ensureLayout, estimateCanvasHeight, estimateNodeSize, excludePaths, findConnectorSnap, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatNumber, getAutoLayout, getAutoLayoutGrid, getAutoLayoutInsertTarget, getBindableTokenProperties, getCanvasTokenProperty, getCenteredNodePosition, getChildLayout, getEffectiveTokenModes, getFlowChildren, getLayoutParent, getLayoutSizing, getLayoutedNodes, getNodeShape, getNodeTokenBindings, getNodeTokenModes, getResizingNodeRect, getShapeRenderData, getShapeSvg, getTokenPropertyScope, getTokensForProperty, handlePoint, hasVisibleStroke, inferResizeHandle, inspectNodeTokens, intersectPaths, intersectPolygons, isAutoLayoutFrame, isEventFromTextInput, isMeasureModifierHeld, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasEdge, isValidCanvasNode, isValidCanvasScene, isValidUrl, layoutAll, layoutBounds, layoutFrame, layoutUp, layoutUpMany, linearPositionTrajectory, linearTrajectory, makeSizingCoherent, measureBetween, measureLabel, measureSelection, measureToLine, mergeNodeUpdates, moveLayoutChild, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, normalizeBezierPath, offsetPath, offsetShapeNodes, oppositePosition, outlineShapeNodeStrokes, outlineStroke, overlaps, pageHidden, parseCanvasClipboardData, parseCanvasScenes, parseSvgPath, pathBoolean, pathToContours, placeBeside, pointInBezierPath, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, pruneCanvasTokenModes, readNodeStyleProperty, realClock, relayoutUpdates, remapPastedNodes, repositionNodesTo, resizeHandleAxes, resolveCanvasTokens, resolvePadding, revertShapeCombination, ringSignedArea, runMultiNodeTransition, segmentBounds, segmentCurvature, segmentDerivative, segmentExtrema, segmentLength, segmentNearest, segmentParamAtLength, segmentPoint, segmentTangent, serializeCanvasNodes, setCanvasTokenMode, shapeNodeToBezierPath, shapeNodeToPolygon, shapeToBezierPath, shapeToPolygon, sideToPosition, simplifyRing, snapNodeDrag, snapNodeResize, snapResize, snapToGrid, splitSegment, strokeOutlineRings, subSegment, subtractPaths, subtractPolygons, toBezierPath, transformBezierPath, trimSegments, unionPolygons, unitePaths, windingNumber, withStyleOpacity, writeNodeStyleProperty, xorPolygons };