@svgsketch/core 1.7.0 → 1.9.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/README.md CHANGED
@@ -21,19 +21,19 @@ const doc = new Document({ width: 400, height: 300 })
21
21
  .add(new Circle(200, 150, 80).fill('#2563eb'))
22
22
  .add(new Rectangle(10, 10, 100, 60).fill('#ef4444').cornerRadius(8));
23
23
 
24
- const svg = doc.toSVG(); // rendered SVG string
25
- const svgs = doc.toJSON(); // canonical `.svgs` document
24
+ const svg = doc.toSVG(); // rendered SVG string
25
+ const svgs = doc.toJSON(); // canonical `.svgs` document
26
26
  ```
27
27
 
28
28
  ## What it includes
29
29
 
30
- | Module | Exports |
31
- | ----------- | --------------------------------------------------------------- |
32
- | `types` | `HistorySnapshot`, `SerializedShape`, `SerializedSymbolDef`, … |
33
- | `format` | `parseDocument`, `stringifyDocument`, `migrateSnapshot`, `validateSnapshot`, `substituteVariables` |
34
- | `renderer` | `renderToSvg` |
35
- | `sdk` | `Document`, `Circle`, `Rectangle`, …, `Timeline`, `Track` |
36
- | `codegen` | `generateCode` — SVG / React / Vue / D3 / CSS output |
30
+ | Module | Exports |
31
+ | ---------- | -------------------------------------------------------------------------------------------------- |
32
+ | `types` | `HistorySnapshot`, `SerializedShape`, `SerializedSymbolDef`, … |
33
+ | `format` | `parseDocument`, `stringifyDocument`, `migrateSnapshot`, `validateSnapshot`, `substituteVariables` |
34
+ | `renderer` | `renderToSvg` |
35
+ | `sdk` | `Document`, `Circle`, `Rectangle`, …, `Timeline`, `Track` |
36
+ | `codegen` | `generateCode` — SVG / React / Vue / D3 / CSS output |
37
37
 
38
38
  ## The `.svgs` format
39
39
 
@@ -52,17 +52,39 @@ designed for:
52
52
  ```jsonc
53
53
  {
54
54
  "schemaVersion": 1,
55
- "documentMetadata": { /* title, author, license, … */ },
56
- "templateVariables": [ /* { name, type, defaultValue, … } */ ],
57
- "viewboxes": [ /* { id, x, y, width, height } */ ],
58
- "guides": [ /* { id, orientation, position, … } */ ],
59
- "measurements": [ /* dimensioning annotations */ ],
60
- "groups": [ /* { id, parentId, siblingIndex, … } */ ],
61
- "clipMaskGroups": [ /* <clipPath> / <mask> definitions */ ],
62
- "customPatterns": [ /* user-defined fill patterns */ ],
63
- "symbols": [ /* reusable component definitions */ ],
64
- "animationTimeline": { /* tracks + keyframes */ },
65
- "shapes": [ /* array order IS z-order */ ]
55
+ "documentMetadata": {
56
+ /* title, author, license, … */
57
+ },
58
+ "templateVariables": [
59
+ /* { name, type, defaultValue, … } */
60
+ ],
61
+ "viewboxes": [
62
+ /* { id, x, y, width, height } */
63
+ ],
64
+ "guides": [
65
+ /* { id, orientation, position, } */
66
+ ],
67
+ "measurements": [
68
+ /* dimensioning annotations */
69
+ ],
70
+ "groups": [
71
+ /* { id, parentId, siblingIndex, … } */
72
+ ],
73
+ "clipMaskGroups": [
74
+ /* <clipPath> / <mask> definitions */
75
+ ],
76
+ "customPatterns": [
77
+ /* user-defined fill patterns */
78
+ ],
79
+ "symbols": [
80
+ /* reusable component definitions */
81
+ ],
82
+ "animationTimeline": {
83
+ /* tracks + keyframes */
84
+ },
85
+ "shapes": [
86
+ /* array — order IS z-order */
87
+ ],
66
88
  }
67
89
  ```
68
90
 
@@ -72,7 +94,7 @@ exhaustive schema.
72
94
  ### Ordering rules
73
95
 
74
96
  - **`shapes` preserves array order** — the position of a shape in the
75
- array *is* its painter's-model z-order. Sorting would silently reorder
97
+ array _is_ its painter's-model z-order. Sorting would silently reorder
76
98
  rendering and destroy user intent.
77
99
  - **Id-keyed collections** (`groups`, `viewboxes`, `guides`,
78
100
  `clipMaskGroups`, `customPatterns`, `symbols`) are sorted by `id`.
@@ -122,7 +144,7 @@ Two complementary mechanisms for parameterizing documents:
122
144
 
123
145
  - **`state.bindings`** — a map from a geometry property name to a CSS
124
146
  custom-property name (without the leading `--`). When a property is
125
- bound, `state[property]` holds the *resolved* value (what the renderer
147
+ bound, `state[property]` holds the _resolved_ value (what the renderer
126
148
  uses if no substitution runs), and `bindings` records the variable the
127
149
  editor should re-bind to on the next edit. Example:
128
150
 
@@ -132,8 +154,8 @@ Two complementary mechanisms for parameterizing documents:
132
154
  "type": "circle",
133
155
  "state": {
134
156
  "radius": 50,
135
- "bindings": { "radius": "card-radius" }
136
- }
157
+ "bindings": { "radius": "card-radius" },
158
+ },
137
159
  }
138
160
  ```
139
161
 
@@ -173,13 +195,7 @@ Errors block loading; warnings are surfaced but do not.
173
195
  ## Minimal example
174
196
 
175
197
  ```ts
176
- import {
177
- Document,
178
- Circle,
179
- parseDocument,
180
- substituteVariables,
181
- renderToSvg,
182
- } from '@svgsketch/core';
198
+ import { Document, Circle, parseDocument, substituteVariables, renderToSvg } from '@svgsketch/core';
183
199
 
184
200
  // Build
185
201
  const doc = new Document({ width: 200, height: 200 })
package/dist/index.d.mts CHANGED
@@ -339,6 +339,12 @@ interface SerializedAnimationTimeline {
339
339
  * tracks degrade to interpolated `<animate>` after save/reload.
340
340
  */
341
341
  calcMode?: 'linear' | 'discrete' | 'paced' | 'spline';
342
+ /**
343
+ * Source SMIL element kind when the track came from an imported SVG.
344
+ * Persisted so export can distinguish true `<set>` sequences from
345
+ * repeating `<animate calcMode="discrete">` tracks after save/reload.
346
+ */
347
+ sourceSmilElement?: 'animate' | 'set' | 'animateTransform' | 'animateMotion' | 'discard';
342
348
  keyframes: {
343
349
  time: number;
344
350
  value: number | string | number[];
@@ -1605,6 +1611,12 @@ declare const COMMON_TRANSFORM_NODE_DEFAULTS: CommonTransformNodeProps;
1605
1611
 
1606
1612
  type SerializedShapeState = ShapeTransformState & {
1607
1613
  [key: string]: unknown;
1614
+ /**
1615
+ * Editor layer label shown in the Elements panel. This is intentionally
1616
+ * separate from ShapeMetadata.name / SVG id so it may contain arbitrary
1617
+ * user-facing text without changing exported element identifiers.
1618
+ */
1619
+ layerName?: string;
1608
1620
  x?: number;
1609
1621
  y?: number;
1610
1622
  width?: number;
@@ -2308,6 +2320,32 @@ interface HistorySnapshot {
2308
2320
  * and the field is omitted on serialisation when the library is empty.
2309
2321
  */
2310
2322
  colorGlyphLibrary?: SerializedColorGlyphLibrary;
2323
+ /**
2324
+ * User-configured export profile for this document. Each entry encodes
2325
+ * a filename, source (root SVG / embedded SVG / view / selection),
2326
+ * format (SVG / PNG / PDF / animated / video / etc.), and any
2327
+ * format-specific settings. Rides with the document so the user's
2328
+ * export setup survives refresh, local save/load, cloud reload, and
2329
+ * collab handoff between clients.
2330
+ *
2331
+ * The full record shape is owned by the editor — see `ExportItem` in
2332
+ * `apps/editor/src/interfaces/interfaces.ts`. Core only types the
2333
+ * identity fields (`id`, `filename`, `format`) and treats the rest as
2334
+ * opaque pass-through, so the editor can grow new settings without
2335
+ * bumping the core schema version. Absent on snapshots from older
2336
+ * editors; restoration uses `?? []` and falls back to the default item.
2337
+ */
2338
+ exportItems?: SerializedExportItem[];
2339
+ }
2340
+ /**
2341
+ * Pass-through wire format for editor-owned export profile entries.
2342
+ * See `HistorySnapshot.exportItems` for the contract.
2343
+ */
2344
+ interface SerializedExportItem {
2345
+ id: string;
2346
+ filename: string;
2347
+ format: string;
2348
+ [key: string]: unknown;
2311
2349
  }
2312
2350
  /**
2313
2351
  * Wire format for the color glyph library. Mirrors the in-editor
@@ -2437,6 +2475,8 @@ interface SerializedGroup {
2437
2475
  interface SerializedClipMaskGroup {
2438
2476
  id: string;
2439
2477
  type: 'clip' | 'mask';
2478
+ /** Actual `<clipPath>` / `<mask>` id used by this group. Older snapshots infer `${type}-${id}`. */
2479
+ definitionId?: string;
2440
2480
  /**
2441
2481
  * @deprecated Use `clipShapeIds` instead. Kept for backward compatibility
2442
2482
  * when reading older documents that used a single clip/mask shape.
@@ -2719,6 +2759,7 @@ type LibraryDefOfKind<K extends LibraryKind> = Extract<LibraryDef, {
2719
2759
  */
2720
2760
 
2721
2761
  interface CommonNodeProps extends CommonTransformNodeProps {
2762
+ layerName: string | null;
2722
2763
  fillColor: string;
2723
2764
  borderColor: string;
2724
2765
  borderWidth: number;
@@ -5608,4 +5649,4 @@ declare function solveSudoku(grid: SudokuGrid, options?: SolveSudokuOptions): Su
5608
5649
  declare function validateSudokuPuzzle(grid: SudokuGrid): SudokuValidationResult;
5609
5650
  declare function generateSudokuPuzzle(options: GenerateSudokuOptions): GeneratedSudokuPuzzle;
5610
5651
 
5611
- 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 };
5652
+ 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 SerializedExportItem, 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 };
package/dist/index.d.ts CHANGED
@@ -339,6 +339,12 @@ interface SerializedAnimationTimeline {
339
339
  * tracks degrade to interpolated `<animate>` after save/reload.
340
340
  */
341
341
  calcMode?: 'linear' | 'discrete' | 'paced' | 'spline';
342
+ /**
343
+ * Source SMIL element kind when the track came from an imported SVG.
344
+ * Persisted so export can distinguish true `<set>` sequences from
345
+ * repeating `<animate calcMode="discrete">` tracks after save/reload.
346
+ */
347
+ sourceSmilElement?: 'animate' | 'set' | 'animateTransform' | 'animateMotion' | 'discard';
342
348
  keyframes: {
343
349
  time: number;
344
350
  value: number | string | number[];
@@ -1605,6 +1611,12 @@ declare const COMMON_TRANSFORM_NODE_DEFAULTS: CommonTransformNodeProps;
1605
1611
 
1606
1612
  type SerializedShapeState = ShapeTransformState & {
1607
1613
  [key: string]: unknown;
1614
+ /**
1615
+ * Editor layer label shown in the Elements panel. This is intentionally
1616
+ * separate from ShapeMetadata.name / SVG id so it may contain arbitrary
1617
+ * user-facing text without changing exported element identifiers.
1618
+ */
1619
+ layerName?: string;
1608
1620
  x?: number;
1609
1621
  y?: number;
1610
1622
  width?: number;
@@ -2308,6 +2320,32 @@ interface HistorySnapshot {
2308
2320
  * and the field is omitted on serialisation when the library is empty.
2309
2321
  */
2310
2322
  colorGlyphLibrary?: SerializedColorGlyphLibrary;
2323
+ /**
2324
+ * User-configured export profile for this document. Each entry encodes
2325
+ * a filename, source (root SVG / embedded SVG / view / selection),
2326
+ * format (SVG / PNG / PDF / animated / video / etc.), and any
2327
+ * format-specific settings. Rides with the document so the user's
2328
+ * export setup survives refresh, local save/load, cloud reload, and
2329
+ * collab handoff between clients.
2330
+ *
2331
+ * The full record shape is owned by the editor — see `ExportItem` in
2332
+ * `apps/editor/src/interfaces/interfaces.ts`. Core only types the
2333
+ * identity fields (`id`, `filename`, `format`) and treats the rest as
2334
+ * opaque pass-through, so the editor can grow new settings without
2335
+ * bumping the core schema version. Absent on snapshots from older
2336
+ * editors; restoration uses `?? []` and falls back to the default item.
2337
+ */
2338
+ exportItems?: SerializedExportItem[];
2339
+ }
2340
+ /**
2341
+ * Pass-through wire format for editor-owned export profile entries.
2342
+ * See `HistorySnapshot.exportItems` for the contract.
2343
+ */
2344
+ interface SerializedExportItem {
2345
+ id: string;
2346
+ filename: string;
2347
+ format: string;
2348
+ [key: string]: unknown;
2311
2349
  }
2312
2350
  /**
2313
2351
  * Wire format for the color glyph library. Mirrors the in-editor
@@ -2437,6 +2475,8 @@ interface SerializedGroup {
2437
2475
  interface SerializedClipMaskGroup {
2438
2476
  id: string;
2439
2477
  type: 'clip' | 'mask';
2478
+ /** Actual `<clipPath>` / `<mask>` id used by this group. Older snapshots infer `${type}-${id}`. */
2479
+ definitionId?: string;
2440
2480
  /**
2441
2481
  * @deprecated Use `clipShapeIds` instead. Kept for backward compatibility
2442
2482
  * when reading older documents that used a single clip/mask shape.
@@ -2719,6 +2759,7 @@ type LibraryDefOfKind<K extends LibraryKind> = Extract<LibraryDef, {
2719
2759
  */
2720
2760
 
2721
2761
  interface CommonNodeProps extends CommonTransformNodeProps {
2762
+ layerName: string | null;
2722
2763
  fillColor: string;
2723
2764
  borderColor: string;
2724
2765
  borderWidth: number;
@@ -5608,4 +5649,4 @@ declare function solveSudoku(grid: SudokuGrid, options?: SolveSudokuOptions): Su
5608
5649
  declare function validateSudokuPuzzle(grid: SudokuGrid): SudokuValidationResult;
5609
5650
  declare function generateSudokuPuzzle(options: GenerateSudokuOptions): GeneratedSudokuPuzzle;
5610
5651
 
5611
- 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 };
5652
+ 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 SerializedExportItem, 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 };