@svgsketch/core 1.4.0 → 1.6.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.
package/dist/index.d.mts CHANGED
@@ -97,12 +97,13 @@ type CycleBehavior = 'restart' | 'alternate';
97
97
  * A single keyframe in an animation track.
98
98
  *
99
99
  * - `time` — Absolute time in seconds within the track.
100
- * - `value` — The property value at this point (number for numeric, string for colors/paths).
100
+ * - `value` — The property value at this point (number for numeric, string
101
+ * for colors/paths, or a 6-number matrix for `transformMatrix`).
101
102
  * - `easing` — The easing curve *leading into* this keyframe (from the previous keyframe).
102
103
  */
103
104
  interface AnimationKeyframe {
104
105
  time: number;
105
- value: number | string;
106
+ value: number | string | number[];
106
107
  easing: EasingType;
107
108
  /** Custom cubic-bezier control points [x1, y1, x2, y2] when easing is CUSTOM_BEZIER. */
108
109
  customBezier?: [number, number, number, number];
@@ -340,7 +341,7 @@ interface SerializedAnimationTimeline {
340
341
  calcMode?: 'linear' | 'discrete' | 'paced' | 'spline';
341
342
  keyframes: {
342
343
  time: number;
343
- value: number | string;
344
+ value: number | string | number[];
344
345
  easing: string;
345
346
  customBezier?: [number, number, number, number];
346
347
  linearPoints?: {
@@ -1532,6 +1533,68 @@ interface Measurement {
1532
1533
  opacity?: number;
1533
1534
  }
1534
1535
 
1536
+ /** SVG affine matrix in `[a,b,c,d,e,f]` order. */
1537
+ type AffineTransformMatrix = number[];
1538
+ /**
1539
+ * Persisted/editor-facing transform state shared by document serialization,
1540
+ * editor shape state, and public plugin geometry types.
1541
+ */
1542
+ interface ShapeTransformState {
1543
+ /**
1544
+ * Canonical local affine transform mapping shape-local geometry into the
1545
+ * parent frame. This matrix is the definitive transform state when present.
1546
+ */
1547
+ transformMatrix?: AffineTransformMatrix | null;
1548
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1549
+ scaleX?: number;
1550
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1551
+ scaleY?: number;
1552
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1553
+ translateX?: number;
1554
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1555
+ translateY?: number;
1556
+ /** @deprecated Legacy text resize anchor; fold into `transformMatrix` on read. */
1557
+ scaleAnchor?: Point | null;
1558
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1559
+ rotation?: number;
1560
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1561
+ skewX?: number;
1562
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1563
+ skewY?: number;
1564
+ customPivot?: Point | null;
1565
+ /** @deprecated Use `transformMatrix`; retained only for legacy/source-fidelity imports. */
1566
+ rawTransform?: string;
1567
+ /** @deprecated Legacy v2 import field. Fold into `transformMatrix` on read; never use at runtime. */
1568
+ ancestorTransform?: AffineTransformMatrix;
1569
+ }
1570
+ declare const SHAPE_TRANSFORM_STATE_KEYS: readonly ["transformMatrix", "scaleX", "scaleY", "translateX", "translateY", "rotation", "skewX", "skewY", "customPivot", "rawTransform"];
1571
+ declare const NUMERIC_SHAPE_TRANSFORM_STATE_KEYS: readonly ["transformMatrix", "scaleX", "scaleY", "translateX", "translateY", "rotation", "skewX", "skewY"];
1572
+ /**
1573
+ * Runtime scene-node transform state after schema defaults are applied.
1574
+ * Unlike serialized shape state, these properties are always present.
1575
+ */
1576
+ interface CommonTransformNodeProps {
1577
+ /**
1578
+ * Canonical local transform matrix in SVG affine order `[a,b,c,d,e,f]`.
1579
+ * This maps shape-local geometry into the parent scene-node frame.
1580
+ */
1581
+ transformMatrix: AffineTransformMatrix | null;
1582
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1583
+ translateX: number;
1584
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1585
+ translateY: number;
1586
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1587
+ rotation: number;
1588
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1589
+ skewX: number;
1590
+ /** @deprecated Use `transformMatrix`; retained as a decomposed compatibility projection. */
1591
+ skewY: number;
1592
+ customPivot: Point | null;
1593
+ /** @deprecated Use `transformMatrix`; retained only for legacy/source-fidelity imports. */
1594
+ rawTransform: string | null;
1595
+ }
1596
+ declare const COMMON_TRANSFORM_NODE_DEFAULTS: CommonTransformNodeProps;
1597
+
1535
1598
  /**
1536
1599
  * @svgsketch/core — Serialized document types.
1537
1600
  *
@@ -1540,114 +1603,108 @@ interface Measurement {
1540
1603
  * SVGSketch documents.
1541
1604
  */
1542
1605
 
1606
+ type SerializedShapeState = ShapeTransformState & {
1607
+ [key: string]: unknown;
1608
+ x?: number;
1609
+ y?: number;
1610
+ width?: number;
1611
+ height?: number;
1612
+ radius?: number;
1613
+ rx?: number;
1614
+ ry?: number;
1615
+ cornerRadius?: number;
1616
+ cornerShape?: 'round' | 'notch' | 'bevel' | 'scoop';
1617
+ cornerMode?: 'uniform' | 'non-uniform';
1618
+ cornerRadiusTL?: number;
1619
+ cornerRadiusTR?: number;
1620
+ cornerRadiusBL?: number;
1621
+ cornerRadiusBR?: number;
1622
+ cornerShapeTL?: 'round' | 'notch' | 'bevel' | 'scoop';
1623
+ cornerShapeTR?: 'round' | 'notch' | 'bevel' | 'scoop';
1624
+ cornerShapeBL?: 'round' | 'notch' | 'bevel' | 'scoop';
1625
+ cornerShapeBR?: 'round' | 'notch' | 'bevel' | 'scoop';
1626
+ fontSize?: number;
1627
+ text?: string;
1628
+ fontFamily?: string;
1629
+ fontWeight?: string;
1630
+ fontStyle?: string;
1631
+ fontVariant?: string;
1632
+ fontVariantLigatures?: string;
1633
+ fontVariantPosition?: string;
1634
+ fontVariantCaps?: string;
1635
+ fontVariantNumeric?: string;
1636
+ fontVariantEastAsian?: string;
1637
+ textDecoration?: {
1638
+ underline?: boolean;
1639
+ strikethrough?: boolean;
1640
+ overline?: boolean;
1641
+ };
1642
+ textTransform?: string;
1643
+ baselineShift?: string;
1644
+ dominantBaseline?: string;
1645
+ writingMode?: 'horizontal-tb' | 'vertical-rl' | 'vertical-lr';
1646
+ textAnchor?: string;
1647
+ letterSpacing?: number;
1648
+ wordSpacing?: number;
1649
+ lineHeight?: number;
1650
+ inlineSize?: number;
1651
+ overflowWrap?: 'normal' | 'break-word' | 'anywhere';
1652
+ whiteSpace?: 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | 'pre-line' | 'break-spaces';
1653
+ textDirection?: 'ltr' | 'rtl';
1654
+ unicodeBidi?: 'normal' | 'embed' | 'bidi-override' | 'isolate' | 'isolate-override' | 'plaintext';
1655
+ fontVariationSettings?: Record<string, number>;
1656
+ /**
1657
+ * Per-glyph positioning data, mirroring SVG 2 §11.2's five attribute
1658
+ * lists (`x`, `y`, `dx`, `dy`, `rotate`).
1659
+ *
1660
+ * - `x`/`y` are absolute user coordinates; `null` means "no
1661
+ * override at this glyph — the cursor advances naturally".
1662
+ * - `dx`/`dy` are additive shifts on top of natural advance.
1663
+ * - `rotate` is per-glyph rotation in degrees.
1664
+ *
1665
+ * For backward compatibility, the legacy three-field shape
1666
+ * `{x, y, rotate}` (produced before the spec-aligned model shipped)
1667
+ * is still accepted on read; its `x`/`y` are interpreted as the
1668
+ * additive shifts (`dx`/`dy`).
1669
+ */
1670
+ charOffsets?: ({
1671
+ x: number | null;
1672
+ y: number | null;
1673
+ dx: number;
1674
+ dy: number;
1675
+ rotate: number;
1676
+ } | {
1677
+ x: number;
1678
+ y: number;
1679
+ rotate: number;
1680
+ })[];
1681
+ linePositions?: {
1682
+ x: number;
1683
+ dy: number;
1684
+ }[];
1685
+ textLength?: number;
1686
+ lengthAdjust?: 'spacing' | 'spacingAndGlyphs';
1687
+ /**
1688
+ * Whether this text element uses the rich-text model (styled runs with
1689
+ * per-character formatting) versus the plain-text model. When true,
1690
+ * `richTextData` is the authoritative source for text content and
1691
+ * formatting; when false/absent, `text` is authoritative.
1692
+ */
1693
+ useRichText?: boolean;
1694
+ richTextData?: RichTextData;
1695
+ textX?: number;
1696
+ textY?: number;
1697
+ fillColor?: string;
1698
+ fillOpacity?: number;
1699
+ borderColor?: string;
1700
+ borderWidth?: number | string;
1701
+ strokeOpacity?: number;
1702
+ };
1543
1703
  interface SerializedShape {
1544
1704
  id: string;
1545
1705
  /** Shape type identifier. Built-in types: 'circle', 'rectangle', etc. Plugin shapes use custom ids. */
1546
1706
  type: string;
1547
- state: {
1548
- x?: number;
1549
- y?: number;
1550
- width?: number;
1551
- height?: number;
1552
- radius?: number;
1553
- rx?: number;
1554
- ry?: number;
1555
- cornerRadius?: number;
1556
- cornerShape?: 'round' | 'notch' | 'bevel' | 'scoop';
1557
- cornerMode?: 'uniform' | 'non-uniform';
1558
- cornerRadiusTL?: number;
1559
- cornerRadiusTR?: number;
1560
- cornerRadiusBL?: number;
1561
- cornerRadiusBR?: number;
1562
- cornerShapeTL?: 'round' | 'notch' | 'bevel' | 'scoop';
1563
- cornerShapeTR?: 'round' | 'notch' | 'bevel' | 'scoop';
1564
- cornerShapeBL?: 'round' | 'notch' | 'bevel' | 'scoop';
1565
- cornerShapeBR?: 'round' | 'notch' | 'bevel' | 'scoop';
1566
- fontSize?: number;
1567
- text?: string;
1568
- fontFamily?: string;
1569
- fontWeight?: string;
1570
- fontStyle?: string;
1571
- fontVariant?: string;
1572
- fontVariantLigatures?: string;
1573
- fontVariantPosition?: string;
1574
- fontVariantCaps?: string;
1575
- fontVariantNumeric?: string;
1576
- fontVariantEastAsian?: string;
1577
- textDecoration?: {
1578
- underline?: boolean;
1579
- strikethrough?: boolean;
1580
- overline?: boolean;
1581
- };
1582
- textTransform?: string;
1583
- baselineShift?: string;
1584
- dominantBaseline?: string;
1585
- writingMode?: 'horizontal-tb' | 'vertical-rl' | 'vertical-lr';
1586
- textAnchor?: string;
1587
- letterSpacing?: number;
1588
- wordSpacing?: number;
1589
- lineHeight?: number;
1590
- inlineSize?: number;
1591
- overflowWrap?: 'normal' | 'break-word' | 'anywhere';
1592
- whiteSpace?: 'normal' | 'nowrap' | 'pre' | 'pre-wrap' | 'pre-line' | 'break-spaces';
1593
- textDirection?: 'ltr' | 'rtl';
1594
- unicodeBidi?: 'normal' | 'embed' | 'bidi-override' | 'isolate' | 'isolate-override' | 'plaintext';
1595
- fontVariationSettings?: Record<string, number>;
1596
- /**
1597
- * Per-glyph positioning data, mirroring SVG 2 §11.2's five attribute
1598
- * lists (`x`, `y`, `dx`, `dy`, `rotate`).
1599
- *
1600
- * - `x`/`y` are absolute user coordinates; `null` means "no
1601
- * override at this glyph — the cursor advances naturally".
1602
- * - `dx`/`dy` are additive shifts on top of natural advance.
1603
- * - `rotate` is per-glyph rotation in degrees.
1604
- *
1605
- * For backward compatibility, the legacy three-field shape
1606
- * `{x, y, rotate}` (produced before the spec-aligned model shipped)
1607
- * is still accepted on read; its `x`/`y` are interpreted as the
1608
- * additive shifts (`dx`/`dy`).
1609
- */
1610
- charOffsets?: ({
1611
- x: number | null;
1612
- y: number | null;
1613
- dx: number;
1614
- dy: number;
1615
- rotate: number;
1616
- } | {
1617
- x: number;
1618
- y: number;
1619
- rotate: number;
1620
- })[];
1621
- linePositions?: {
1622
- x: number;
1623
- dy: number;
1624
- }[];
1625
- textLength?: number;
1626
- lengthAdjust?: 'spacing' | 'spacingAndGlyphs';
1627
- /**
1628
- * Whether this text element uses the rich-text model (styled runs with
1629
- * per-character formatting) versus the plain-text model. When true,
1630
- * `richTextData` is the authoritative source for text content and
1631
- * formatting; when false/absent, `text` is authoritative.
1632
- */
1633
- useRichText?: boolean;
1634
- richTextData?: RichTextData;
1635
- scaleX?: number;
1636
- scaleY?: number;
1637
- translateX?: number;
1638
- translateY?: number;
1639
- textX?: number;
1640
- textY?: number;
1641
- scaleAnchor?: Point | null;
1642
- rotation?: number;
1643
- skewX?: number;
1644
- skewY?: number;
1645
- customPivot?: Point | null;
1646
- fillColor?: string;
1647
- fillOpacity?: number;
1648
- borderColor?: string;
1649
- borderWidth?: number | string;
1650
- strokeOpacity?: number;
1707
+ state: SerializedShapeState & {
1651
1708
  /**
1652
1709
  * Inherit `fill` from the ancestor cascade rather than emit an explicit
1653
1710
  * attribute. Set at import for shapes inside `<defs>`/`<symbol>` that
@@ -1790,8 +1847,6 @@ interface SerializedShape {
1790
1847
  filterWidth?: string;
1791
1848
  /** @deprecated v2 — see `filterX`. */
1792
1849
  filterHeight?: string;
1793
- rawTransform?: string;
1794
- ancestorTransform?: number[];
1795
1850
  pathPoints?: PathPoint[];
1796
1851
  pathCurveType?: PathCurveType;
1797
1852
  pathClosed?: boolean;
@@ -1932,6 +1987,28 @@ interface SerializedShape {
1932
1987
  * rendering tree.
1933
1988
  */
1934
1989
  display?: 'none';
1990
+ /**
1991
+ * Passthrough inline CSS declarations the editor doesn't model as
1992
+ * typed state. Holds CSS Custom Properties (`--foo`, CSS Variables 1
1993
+ * §2 — scoped vars cascading to descendants via `var()` references)
1994
+ * and vendor-prefixed CSS (`-inkscape-*`, `-webkit-*`, …) authored
1995
+ * directly on the source element's `style="…"` attribute.
1996
+ *
1997
+ * Round-trip mechanism (`applyPresentationEntry` / `clearPresentationEntry`
1998
+ * in `apps/editor/src/canvas/import-export/ie-shared.ts`):
1999
+ * - Custom properties live on `el.style` via `setProperty`; browsers
2000
+ * cascade them natively.
2001
+ * - Vendor prefixes live in an editor-internal
2002
+ * `data-svgsketch-vendor-css` attribute (CSSOM `setProperty` drops
2003
+ * unknown vendor names per CSSOM §6.3.6 step 1); export merges
2004
+ * them into the visible `style="…"` attribute on serialize.
2005
+ *
2006
+ * Editor-modeled CSS (`fill`, `stroke`, `font-*`, `mix-blend-mode`,
2007
+ * `mask`, etc.) is captured into the dedicated typed slots above and
2008
+ * does NOT appear in this map — keeps a single source of truth per
2009
+ * declaration and avoids round-trip drift.
2010
+ */
2011
+ inlineStyle?: Record<string, string>;
1935
2012
  metadata?: Partial<ShapeMetadata>;
1936
2013
  /**
1937
2014
  * Shape-scoped `<script>` elements (SVG 2 §15.9 allows scripts as
@@ -2111,6 +2188,26 @@ interface SerializedShape {
2111
2188
  };
2112
2189
  }
2113
2190
  type SerializedViewbox = Viewbox;
2191
+ /**
2192
+ * Scene-graph placement for a node in the document tree.
2193
+ *
2194
+ * This is intentionally independent of SVG DOM serialization: `parentId`
2195
+ * identifies the scene parent (`null` means the document root) and `index`
2196
+ * is the sibling slot inside that parent.
2197
+ */
2198
+ interface SerializedSceneNodePlacement {
2199
+ id: string;
2200
+ parentId: string | null;
2201
+ index: number;
2202
+ updatedAt?: number;
2203
+ clientId?: string;
2204
+ }
2205
+ interface SerializedPaintServerDef {
2206
+ id: string;
2207
+ type: 'mask' | 'clipPath' | 'filter' | 'linearGradient' | 'radialGradient' | 'pattern' | 'symbol';
2208
+ /** Serialized SVG element markup for this def. */
2209
+ markup: string;
2210
+ }
2114
2211
  /**
2115
2212
  * Schema version for the HistorySnapshot format.
2116
2213
  *
@@ -2132,7 +2229,7 @@ type SerializedViewbox = Viewbox;
2132
2229
  * (version - 1) snapshots into the new format.
2133
2230
  * c. Register it in the migrateSnapshot() chain.
2134
2231
  */
2135
- declare const CURRENT_SCHEMA_VERSION = 2;
2232
+ declare const CURRENT_SCHEMA_VERSION = 4;
2136
2233
  interface HistorySnapshot {
2137
2234
  /**
2138
2235
  * Schema version — written on save, read on load to trigger migrations.
@@ -2143,6 +2240,12 @@ interface HistorySnapshot {
2143
2240
  viewboxes: SerializedViewbox[];
2144
2241
  guides?: Guide[];
2145
2242
  measurements?: Measurement[];
2243
+ /**
2244
+ * Canonical scene-graph hierarchy/order. Optional for backward
2245
+ * compatibility with older snapshots that encoded structure only through
2246
+ * container-owned `state.children` and legacy group side channels.
2247
+ */
2248
+ sceneTree?: SerializedSceneNodePlacement[];
2146
2249
  /** Group structure: array of group IDs with their parent group ID (null for top-level) */
2147
2250
  groups?: SerializedGroup[];
2148
2251
  /** Clip/mask group structure for undo/redo support */
@@ -2181,6 +2284,12 @@ interface HistorySnapshot {
2181
2284
  * `innerHTML`-append into editor defs on restore.
2182
2285
  */
2183
2286
  rawPaintServerDefs?: string[];
2287
+ /**
2288
+ * Typed paint-server/defs fragments that are not yet represented by the
2289
+ * structured `library` records. This supersedes `rawPaintServerDefs` for
2290
+ * new writers while the legacy string array remains for older clients.
2291
+ */
2292
+ paintServerDefs?: SerializedPaintServerDef[];
2184
2293
  /** @deprecated v2 — use `library`. Read-only: v1 docs migrate into `library`. */
2185
2294
  customPatterns?: CustomPatternDef[];
2186
2295
  /** @deprecated v2 — use `library`. Read-only: v1 docs migrate into `library`. */
@@ -2483,7 +2592,14 @@ interface SymbolLibraryDef extends LibraryDefBase {
2483
2592
  */
2484
2593
  interface MarkerLibraryDef extends LibraryDefBase {
2485
2594
  kind: 'marker';
2486
- viewBox: string;
2595
+ /**
2596
+ * SVG 2 §11.6: when omitted, marker contents render directly in the
2597
+ * viewport coordinate system (scaled by markerUnits) rather than being
2598
+ * mapped from viewBox space to the markerWidth × markerHeight viewport.
2599
+ * Editor-authored markers always set this; imported markers preserve
2600
+ * "no viewBox" when the source `<marker>` had none.
2601
+ */
2602
+ viewBox?: string;
2487
2603
  /** X reference point — where the marker's tip aligns with the host vertex. */
2488
2604
  refX: number;
2489
2605
  refY: number;
@@ -2499,6 +2615,12 @@ interface MarkerLibraryDef extends LibraryDefBase {
2499
2615
  * start marker; a number is a fixed rotation in degrees.
2500
2616
  */
2501
2617
  orient: 'auto' | 'auto-start-reverse' | number;
2618
+ /**
2619
+ * SVG 2 §11.6: `'visible'` allows content to render past the
2620
+ * markerWidth × markerHeight viewport (default is `'hidden'`). Captured
2621
+ * from the source `overflow` attr; emitted only when explicitly set.
2622
+ */
2623
+ overflow?: 'visible' | 'hidden';
2502
2624
  /**
2503
2625
  * Inner geometry (authoritative for user markers). Built-ins render from
2504
2626
  * the descriptor registry and carry `shapes: []`.
@@ -2582,19 +2704,13 @@ type LibraryDefOfKind<K extends LibraryKind> = Extract<LibraryDef, {
2582
2704
  * - Serialization format for the `.svgs` document format
2583
2705
  */
2584
2706
 
2585
- interface CommonNodeProps {
2707
+ interface CommonNodeProps extends CommonTransformNodeProps {
2586
2708
  fillColor: string;
2587
2709
  borderColor: string;
2588
2710
  borderWidth: number;
2589
2711
  opacity: number;
2590
2712
  fillOpacity: number;
2591
2713
  strokeOpacity: number;
2592
- translateX: number;
2593
- translateY: number;
2594
- rotation: number;
2595
- skewX: number;
2596
- skewY: number;
2597
- customPivot: Point | null;
2598
2714
  locked: boolean;
2599
2715
  visible: boolean;
2600
2716
  fillType: string;
@@ -2619,8 +2735,6 @@ interface CommonNodeProps {
2619
2735
  filterY: string | null;
2620
2736
  filterWidth: string | null;
2621
2737
  filterHeight: string | null;
2622
- rawTransform: string | null;
2623
- ancestorTransform: number[] | null;
2624
2738
  metadata: unknown | null;
2625
2739
  cssClipPath: string | null;
2626
2740
  cssMaskProperties: Record<string, string> | null;
@@ -2701,6 +2815,7 @@ interface TextNodeProps extends CommonNodeProps {
2701
2815
  unicodeBidi: string;
2702
2816
  scaleX: number;
2703
2817
  scaleY: number;
2818
+ /** @deprecated Runtime-only legacy text anchor; persisted transforms use transformMatrix. */
2704
2819
  scaleAnchor: Point | null;
2705
2820
  useRichText: boolean;
2706
2821
  richTextData: unknown | null;
@@ -3190,6 +3305,33 @@ declare function roundSerializedShape(shape: SerializedShape, precision: number)
3190
3305
  */
3191
3306
  declare function roundSnapshot(snapshot: HistorySnapshot, precision: number): HistorySnapshot;
3192
3307
 
3308
+ type Affine2D = readonly [number, number, number, number, number, number];
3309
+ declare const IDENTITY_AFFINE: Affine2D;
3310
+ declare function affine(a: number, b: number, c: number, d: number, e: number, f: number): Affine2D;
3311
+ declare function affineFromArray(m: readonly number[]): Affine2D;
3312
+ declare function affineToArray(m: Affine2D): number[];
3313
+ declare function isFiniteAffineArray(m: unknown): m is readonly number[];
3314
+ declare function isIdentityAffine(m: readonly number[], epsilon?: number): boolean;
3315
+ declare function multiplyAffine(parent: Affine2D, child: Affine2D): Affine2D;
3316
+ declare function translateAffine(tx: number, ty?: number): Affine2D;
3317
+ declare function scaleAffine(sx: number, sy?: number): Affine2D;
3318
+ declare function rotateAffine(angleDeg: number): Affine2D;
3319
+ declare function skewXAffine(angleDeg: number): Affine2D;
3320
+ declare function skewYAffine(angleDeg: number): Affine2D;
3321
+ declare function around(origin: Point, operation: Affine2D): Affine2D;
3322
+ declare function parseSvgTransformList(transform: string): Affine2D;
3323
+ declare function matrixTransformPart(matrix: readonly number[] | null | undefined): string | null;
3324
+ declare function composeLegacyTransformMatrix(state: Record<string, unknown>, defaultPivot?: Point): Affine2D;
3325
+ declare function canonicalTransformString(state: Record<string, unknown>, defaultPivot?: Point): string | null;
3326
+ /**
3327
+ * Compatibility normalizer for documents that still carry the pre-v3
3328
+ * `ancestorTransform` field. The legacy ancestor matrix is composed as the
3329
+ * outer transform and then removed so runtime/editor code only sees the
3330
+ * canonical local `transformMatrix`.
3331
+ */
3332
+ declare function foldLegacyAncestorTransformIntoMatrix(state: Record<string, unknown>, defaultPivot?: Point): void;
3333
+ declare function canonicalPolygonTransformString(state: Record<string, unknown>, cx: number, cy: number): string;
3334
+
3193
3335
  /**
3194
3336
  * Document-level SVG renderer.
3195
3337
  *
@@ -3570,7 +3712,7 @@ declare function getBuiltInMarkerDefs(): SerializedMarkerDef[];
3570
3712
  *
3571
3713
  * Produces:
3572
3714
  * - `<animate>` for numeric and color properties
3573
- * - `<animateTransform>` for rotation, skewX, skewY
3715
+ * - `<animateTransform>` for transformMatrix, rotation, skewX, skewY
3574
3716
  * - `<animateMotion>` for path-based motion
3575
3717
  * - `<discard>` for remove-at-time tracks
3576
3718
  *
@@ -4045,6 +4187,10 @@ declare abstract class ShapeBuilder<T extends ShapeBuilder<T>> {
4045
4187
  scale(x: number, y?: number): T;
4046
4188
  /** Set a custom pivot point for transforms. */
4047
4189
  pivot(x: number, y: number): T;
4190
+ /** Set the canonical local affine transform matrix directly. */
4191
+ transformMatrix(matrix: readonly [number, number, number, number, number, number] | number[]): T;
4192
+ private refreshTransformMatrix;
4193
+ private defaultTransformPivot;
4048
4194
  /** Add one or more filters to the shape. */
4049
4195
  filter(...filters: ShapeFilter[]): T;
4050
4196
  /** Add a drop shadow filter. */
@@ -4599,8 +4745,18 @@ declare class View extends ShapeBuilder<View> {
4599
4745
  zoomAndPan(value: 'disable' | 'magnify'): View;
4600
4746
  /** SVG `viewTarget` attribute. */
4601
4747
  viewTarget(value: string): View;
4602
- /** Mark this view as the canonical "home" view of the document. */
4603
- asHome(value?: boolean): View;
4748
+ /**
4749
+ * No-op kept for backwards compatibility with existing call sites.
4750
+ * The "home view" abstraction was retired — the document's framing
4751
+ * is owned by the root `<svg>` element (via the SDK's `Document`
4752
+ * width/height/viewBox), not by a `<view>` element flagged as
4753
+ * "home." `<view>` is reserved for author-authored named viewports
4754
+ * (SVG 2 §16.3.3).
4755
+ *
4756
+ * @deprecated v3 — pass `width`/`height`/`viewBox` to `Document`
4757
+ * instead. This shim will be removed in a future major.
4758
+ */
4759
+ asHome(_value?: boolean): View;
4604
4760
  }
4605
4761
  declare class NestedSvg extends ContainerShapeBuilder<NestedSvg> {
4606
4762
  constructor(x?: number, y?: number, width?: number, height?: number);
@@ -4766,11 +4922,11 @@ declare class Track {
4766
4922
  * Add a keyframe at the given time.
4767
4923
  *
4768
4924
  * @param time - Time in seconds from the start of the track.
4769
- * @param value - The property value at this time (number or color string).
4925
+ * @param value - The property value at this time.
4770
4926
  * @param easing - Easing curve leading *into* this keyframe.
4771
4927
  * Defaults to LINEAR.
4772
4928
  */
4773
- keyframe(time: number, value: number | string, easing?: EasingType): Track;
4929
+ keyframe(time: number, value: number | string | number[], easing?: EasingType): Track;
4774
4930
  /**
4775
4931
  * Add a keyframe with a custom cubic-bezier easing.
4776
4932
  *
@@ -4778,7 +4934,7 @@ declare class Track {
4778
4934
  * @param value - The property value.
4779
4935
  * @param points - Cubic-bezier control points [x1, y1, x2, y2].
4780
4936
  */
4781
- keyframeBezier(time: number, value: number | string, points: [number, number, number, number]): Track;
4937
+ keyframeBezier(time: number, value: number | string | number[], points: [number, number, number, number]): Track;
4782
4938
  /**
4783
4939
  * Add a keyframe with a CSS linear() easing function.
4784
4940
  *
@@ -4786,7 +4942,7 @@ declare class Track {
4786
4942
  * @param value - The property value.
4787
4943
  * @param linearPoints - Control points for the piecewise linear function.
4788
4944
  */
4789
- keyframeLinear(time: number, value: number | string, linearPoints: LinearEasingPoint[]): Track;
4945
+ keyframeLinear(time: number, value: number | string | number[], linearPoints: LinearEasingPoint[]): Track;
4790
4946
  /** Add multiple keyframes at once. */
4791
4947
  keyframes(...kfs: AnimationKeyframe[]): Track;
4792
4948
  /** Disable this track (excluded from playback/export). */
@@ -5438,4 +5594,4 @@ declare function solveSudoku(grid: SudokuGrid, options?: SolveSudokuOptions): Su
5438
5594
  declare function validateSudokuPuzzle(grid: SudokuGrid): SudokuValidationResult;
5439
5595
  declare function generateSudokuPuzzle(options: GenerateSudokuOptions): GeneratedSudokuPuzzle;
5440
5596
 
5441
- export { type AnimatablePropertyDescriptor, type AnimationKeyframe, type AnimationTimeline, type AnimationTrack, type AnimationTrigger, type AnimationTriggerType, type AnyNodeProps, type ArcParams$1 as ArcParams, type AriaRole, Arrow, type ArrowNodeProps, Audio, BUILTIN_MARKER_ID_MAP, type BaseFilter, type BaseFilterPrimitive, type BlackAndWhiteFilter, type BlurQuality, type BrightnessFilter, CURRENT_SCHEMA_VERSION, type ChannelPainterFilter, Circle, type CircleNodeProps, Cloud, type CodeFormat, type CodegenOptions, type CommonNodeProps, type ConnectionDirection, type ConnectionPoint, Container, ContainerShapeBuilder, type ContouringDiscreteFilter, type ContouringTableFilter, type ContrastFilter, type CornerShapeValue, type CreateDocumentOptions, type CreateShapeOptions, Cross, type CrossNodeProps, type CrumpledPlasticFilter, type CustomPatternDef, type CycleBehavior, DEFAULT_COORDINATE_PRECISION, type DiffuseLightingFilter, Document, type DocumentMetadata, type DocumentNodeProps, type DocumentOptions, type DocumentScript, type DocumentStyle, type DropShadowFilter, type DuotoneFilter, EASING_CURVES, EVENT_TRIGGER_OPTIONS, EasingType, Ellipse, type EllipseNodeProps, type EmbossFilter, type ExtractedVariables, type FeBlendPrimitive, type FeColorMatrixPrimitive, type FeComponentTransferPrimitive, type FeCompositePrimitive, type FeConvolveMatrixPrimitive, type FeDiffuseLightingPrimitive, type FeDisplacementMapPrimitive, type FeDropShadowPrimitive, type FeFloodPrimitive, type FeGaussianBlurPrimitive, type FeImagePrimitive, type FeMergePrimitive, type FeMorphologyPrimitive, type FeOffsetPrimitive, type FeSpecularLightingPrimitive, type FeTilePrimitive, type FeTurbulencePrimitive, type FillType, type FilmGrainFilter, type FilterBlendMode, type FilterLibraryDef, type FilterLightSource, type FilterPrimitive, type FilterPrimitiveType, type FilterType, type GaussianBlurFilter, Gear, type GearNodeProps, type GenerateSudokuOptions, type GeneratedSudokuPuzzle, type GlowFilter, type GouacheFilter, type GradientDefinition, type GradientSpreadMethod, type GradientStop, type GradientUnits, type GrayscaleFilter, type GroupNodeProps, type Guide, Heart, type HistorySnapshot, type HueRotateFilter, Hyperlink, type ImageAttribution, type ImageNodeProps, ImageShape, type InkBlotFilter, type InnerGlowFilter, type InnerShadowFilter, type InvertFilter, LIBRARY_EMIT_ORDER, type LibraryDef, type LibraryDefBase, type LibraryDefOfKind, type LibraryKind, type LicenseType, type LightSource, Lightning, Line, type LineEndpointValue, type LineNodeProps, type LinearEasingPoint, type LinearGradient, LinearGradientBuilder, type LinearGradientLibraryDef, type LinkTarget, MARKER_HEIGHT, MARKER_VIEWBOX, MARKER_WIDTH, MAX_COORDINATE_PRECISION, MIGRATIONS, type MarkerDescriptor, type MarkerLibraryDef, type Measurement, type Migration, type MorphologyFilter, type MorphologyOperator, type MotionBlurFilter, NGon, type NGonNodeProps, NestedSvg, type NodeTypePropsMap, type NoiseFilter, type OpacityFilter, type OutlineFilter, type OutlinePosition, PUZZLE_DEFAULTS, type ParseOptions, Path, PathCurveType, type PathNodeProps, type PathPoint, PathPointType, PatternBuilder, type PatternElement, type PatternFill, type PatternLibraryDef, type PatternParams, type PatternSvgContentResult, type PatternType, type PixelateFilter, type Point, type PointLightFilter, type PolygonBaseNodeProps, Polyline, type PolylineNodeProps, type PuzzleBounds, type PuzzleOptions, type PuzzlePiece, type PuzzleStyle, type PuzzleTabPattern, type RadialGradient, RadialGradientBuilder, type RadialGradientLibraryDef, type RawSvgFilter, Rectangle, type RectangleNodeProps, type RenderOptions, type RichTextData, type RichTextLine, type RichTextSegment, type RichTextSegmentStyle, type RiddledFilter, Ring, type RingNodeProps, type RoundEdgesFilter, type SaturateFilter, type SegmentCurveType, type SepiaFilter, type SerializedAnimationTimeline, type SerializedClipMaskGroup, type SerializedColorGlyph, type SerializedColorGlyphLibrary, type SerializedGroup, type SerializedMarkerDef, type SerializedShape, type SerializedSymbolDef, type SerializedVariantAxis, type SerializedViewbox, ShapeBuilder, type ShapeFilter, type ShapeMetadata, ShapeReference, type SharpenFilter, type SolveSudokuOptions, type SpecularLightingFilter, SpeechBubble, Spiral, type SpiralNodeProps, type SpotLightFilter, Square, type SquareNodeProps, Star, type StarNodeProps, type StepPosition, type StepsParams, type StringifyOptions, type StrokeType, type SudokuDifficulty, type SudokuGrid, type SudokuRating, type SudokuValidationResult, type SvgPrimitiveChainFilter, Switch, type SymbolInstanceNodeProps, type SymbolLibraryDef, type TemplateVariable, type TemplateVariableMode, type TemplateVariableSource, type TemplateVariableType, Text, type TextNodeProps, Timeline, Track, type TransferFunc, Triangle, type TriangleNodeProps, type ValidationError, type ValidationResult, type VariableMap, Video, View, type Viewbox, type WarpFilter, type WarpType, type WatercolorFilter, type XrayFilter, collectReferencedLibraryIds, computeArrowVertices, computeCloudPath, computeCrossVertices, computeDashArray, computeGearPath, computeGearVertices, computeHeartPath, computeLightningVertices, computePolygonVertices, computeRectanglePath, computeRingPath, computeSpeechBubbleVertices, computeSpiralPath, computeSplinePath, computeStarVertices, createDocument, createShape, createViewbox, defaultVariableMode, escXml, extractVariables, filterAttr, generateCode, generateCssCode, generateD3Code, generateId, generatePatternSvgContent, generatePuzzlePieces, generateReactCode, generateSudokuPuzzle, generateSvgCode, generateVueCode, getBuiltInMarkerDefs, getEasingCubicBezier, getEffectivePrecision, getMarkerDescriptors, getPatternElements, linearGradient, migrateSnapshot, parseDocument, parseVariableArgs, pattern, radialGradient, renderAnimationElements, renderBuiltinMarkerDefs, renderCircle, renderEllipse, renderFilterDefs, renderFilterLibraryDef, renderFilterPrimitive, renderFilterPrimitivesForType, renderImage, renderLibraryDef, renderLibraryDefs, renderLine, renderLinearGradientLibraryDef, renderMarkerLibraryDef, renderPatternLibraryDef, renderPolygonShape, renderPolyline, renderRadialGradientLibraryDef, renderRectangle, renderReferencedLibraryDefs, renderShape, renderSpline, renderSvgPrimitiveChainFilter, renderSymbolLibraryDef, renderText, renderToSvg, roundCoord, roundNumberString, roundSerializedShape, roundSnapshot, solveSudoku, stringifyDocument, substituteString, substituteVariables, validateSnapshot, validateSudokuPuzzle, verticesToPath };
5597
+ export { type Affine2D, type AffineTransformMatrix, type AnimatablePropertyDescriptor, type AnimationKeyframe, type AnimationTimeline, type AnimationTrack, type AnimationTrigger, type AnimationTriggerType, type AnyNodeProps, type ArcParams$1 as ArcParams, type AriaRole, Arrow, type ArrowNodeProps, Audio, BUILTIN_MARKER_ID_MAP, type BaseFilter, type BaseFilterPrimitive, type BlackAndWhiteFilter, type BlurQuality, type BrightnessFilter, COMMON_TRANSFORM_NODE_DEFAULTS, CURRENT_SCHEMA_VERSION, type ChannelPainterFilter, Circle, type CircleNodeProps, Cloud, type CodeFormat, type CodegenOptions, type CommonNodeProps, type CommonTransformNodeProps, type ConnectionDirection, type ConnectionPoint, Container, ContainerShapeBuilder, type ContouringDiscreteFilter, type ContouringTableFilter, type ContrastFilter, type CornerShapeValue, type CreateDocumentOptions, type CreateShapeOptions, Cross, type CrossNodeProps, type CrumpledPlasticFilter, type CustomPatternDef, type CycleBehavior, DEFAULT_COORDINATE_PRECISION, type DiffuseLightingFilter, Document, type DocumentMetadata, type DocumentNodeProps, type DocumentOptions, type DocumentScript, type DocumentStyle, type DropShadowFilter, type DuotoneFilter, EASING_CURVES, EVENT_TRIGGER_OPTIONS, EasingType, Ellipse, type EllipseNodeProps, type EmbossFilter, type ExtractedVariables, type FeBlendPrimitive, type FeColorMatrixPrimitive, type FeComponentTransferPrimitive, type FeCompositePrimitive, type FeConvolveMatrixPrimitive, type FeDiffuseLightingPrimitive, type FeDisplacementMapPrimitive, type FeDropShadowPrimitive, type FeFloodPrimitive, type FeGaussianBlurPrimitive, type FeImagePrimitive, type FeMergePrimitive, type FeMorphologyPrimitive, type FeOffsetPrimitive, type FeSpecularLightingPrimitive, type FeTilePrimitive, type FeTurbulencePrimitive, type FillType, type FilmGrainFilter, type FilterBlendMode, type FilterLibraryDef, type FilterLightSource, type FilterPrimitive, type FilterPrimitiveType, type FilterType, type GaussianBlurFilter, Gear, type GearNodeProps, type GenerateSudokuOptions, type GeneratedSudokuPuzzle, type GlowFilter, type GouacheFilter, type GradientDefinition, type GradientSpreadMethod, type GradientStop, type GradientUnits, type GrayscaleFilter, type GroupNodeProps, type Guide, Heart, type HistorySnapshot, type HueRotateFilter, Hyperlink, IDENTITY_AFFINE, type ImageAttribution, type ImageNodeProps, ImageShape, type InkBlotFilter, type InnerGlowFilter, type InnerShadowFilter, type InvertFilter, LIBRARY_EMIT_ORDER, type LibraryDef, type LibraryDefBase, type LibraryDefOfKind, type LibraryKind, type LicenseType, type LightSource, Lightning, Line, type LineEndpointValue, type LineNodeProps, type LinearEasingPoint, type LinearGradient, LinearGradientBuilder, type LinearGradientLibraryDef, type LinkTarget, MARKER_HEIGHT, MARKER_VIEWBOX, MARKER_WIDTH, MAX_COORDINATE_PRECISION, MIGRATIONS, type MarkerDescriptor, type MarkerLibraryDef, type Measurement, type Migration, type MorphologyFilter, type MorphologyOperator, type MotionBlurFilter, NGon, type NGonNodeProps, NUMERIC_SHAPE_TRANSFORM_STATE_KEYS, NestedSvg, type NodeTypePropsMap, type NoiseFilter, type OpacityFilter, type OutlineFilter, type OutlinePosition, PUZZLE_DEFAULTS, type ParseOptions, Path, PathCurveType, type PathNodeProps, type PathPoint, PathPointType, PatternBuilder, type PatternElement, type PatternFill, type PatternLibraryDef, type PatternParams, type PatternSvgContentResult, type PatternType, type PixelateFilter, type Point, type PointLightFilter, type PolygonBaseNodeProps, Polyline, type PolylineNodeProps, type PuzzleBounds, type PuzzleOptions, type PuzzlePiece, type PuzzleStyle, type PuzzleTabPattern, type RadialGradient, RadialGradientBuilder, type RadialGradientLibraryDef, type RawSvgFilter, Rectangle, type RectangleNodeProps, type RenderOptions, type RichTextData, type RichTextLine, type RichTextSegment, type RichTextSegmentStyle, type RiddledFilter, Ring, type RingNodeProps, type RoundEdgesFilter, SHAPE_TRANSFORM_STATE_KEYS, type SaturateFilter, type SegmentCurveType, type SepiaFilter, type SerializedAnimationTimeline, type SerializedClipMaskGroup, type SerializedColorGlyph, type SerializedColorGlyphLibrary, type SerializedGroup, type SerializedMarkerDef, type SerializedPaintServerDef, type SerializedSceneNodePlacement, type SerializedShape, type SerializedShapeState, type SerializedSymbolDef, type SerializedVariantAxis, type SerializedViewbox, ShapeBuilder, type ShapeFilter, type ShapeMetadata, ShapeReference, type ShapeTransformState, type SharpenFilter, type SolveSudokuOptions, type SpecularLightingFilter, SpeechBubble, Spiral, type SpiralNodeProps, type SpotLightFilter, Square, type SquareNodeProps, Star, type StarNodeProps, type StepPosition, type StepsParams, type StringifyOptions, type StrokeType, type SudokuDifficulty, type SudokuGrid, type SudokuRating, type SudokuValidationResult, type SvgPrimitiveChainFilter, Switch, type SymbolInstanceNodeProps, type SymbolLibraryDef, type TemplateVariable, type TemplateVariableMode, type TemplateVariableSource, type TemplateVariableType, Text, type TextNodeProps, Timeline, Track, type TransferFunc, Triangle, type TriangleNodeProps, type ValidationError, type ValidationResult, type VariableMap, Video, View, type Viewbox, type WarpFilter, type WarpType, type WatercolorFilter, type XrayFilter, affine, affineFromArray, affineToArray, around, canonicalPolygonTransformString, canonicalTransformString, collectReferencedLibraryIds, composeLegacyTransformMatrix, computeArrowVertices, computeCloudPath, computeCrossVertices, computeDashArray, computeGearPath, computeGearVertices, computeHeartPath, computeLightningVertices, computePolygonVertices, computeRectanglePath, computeRingPath, computeSpeechBubbleVertices, computeSpiralPath, computeSplinePath, computeStarVertices, createDocument, createShape, createViewbox, defaultVariableMode, escXml, extractVariables, filterAttr, foldLegacyAncestorTransformIntoMatrix, generateCode, generateCssCode, generateD3Code, generateId, generatePatternSvgContent, generatePuzzlePieces, generateReactCode, generateSudokuPuzzle, generateSvgCode, generateVueCode, getBuiltInMarkerDefs, getEasingCubicBezier, getEffectivePrecision, getMarkerDescriptors, getPatternElements, isFiniteAffineArray, isIdentityAffine, linearGradient, matrixTransformPart, migrateSnapshot, multiplyAffine, parseDocument, parseSvgTransformList, parseVariableArgs, pattern, radialGradient, renderAnimationElements, renderBuiltinMarkerDefs, renderCircle, renderEllipse, renderFilterDefs, renderFilterLibraryDef, renderFilterPrimitive, renderFilterPrimitivesForType, renderImage, renderLibraryDef, renderLibraryDefs, renderLine, renderLinearGradientLibraryDef, renderMarkerLibraryDef, renderPatternLibraryDef, renderPolygonShape, renderPolyline, renderRadialGradientLibraryDef, renderRectangle, renderReferencedLibraryDefs, renderShape, renderSpline, renderSvgPrimitiveChainFilter, renderSymbolLibraryDef, renderText, renderToSvg, rotateAffine, roundCoord, roundNumberString, roundSerializedShape, roundSnapshot, scaleAffine, skewXAffine, skewYAffine, solveSudoku, stringifyDocument, substituteString, substituteVariables, translateAffine, validateSnapshot, validateSudokuPuzzle, verticesToPath };