@pixodesk/svg-animator-core 1.0.29 → 1.0.30

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
@@ -56,7 +56,7 @@ runtime crash on a non-browser platform.
56
56
  | **Text** | `materialiseGlyphText`, `layoutGlyphTextChars`, `extendedPathForBrowser` |
57
57
  | **Node helpers** | `getNormalizedProps`, `sanitiseAttributeValue`, `resolveStyle`, `generateNewIds` |
58
58
  | **Playback engine** | `createBasicFrameLoopAnimator` + the `PxPlatformAdapter` interface |
59
- | **Wire enums** | `PxAnimatorMode`, `PxAnimatorEngine`, `PxLoopExtend`, `PxTrimSubPaths`, `PxMaskType`, `PxCloneType`, `PxUnits`, `PxGradientType`, `PxGradientUnits`, `PxGradientSpreadMethod`, `PxPathOverflow`, `PxLengthAdjust`, `PxTextPathMethod`, `PxTextPathSpacing` — every two-or-more-way wire selector is a named enum, not a bare string |
59
+ | **Wire enums** | `PxAnimatorMode`, `PxAnimatorEngine`, `PxLoopExtend`, `PxStrokeTrimSubPaths`, `PxMaskType`, `PxCloneType`, `PxUnits`, `PxGradientType`, `PxGradientUnits`, `PxGradientSpreadMethod`, `PxPathOverflow`, `PxLengthAdjust`, `PxTextPathMethod`, `PxTextPathSpacing` — every two-or-more-way wire selector is a named enum, not a bare string |
60
60
 
61
61
  ### Validating a document
62
62
 
@@ -69,7 +69,7 @@ import { PxAnimatedSvgDocumentSchema, type PxValidationContext } from '@pixodesk
69
69
 
70
70
  const ctx: PxValidationContext = { errors: [], warnings: [], strict: true };
71
71
  const ok = PxAnimatedSvgDocumentSchema.isValid(doc, ctx, []);
72
- if (!ok) console.error(ctx.errors); // ["children[0].effects.trimPath.range: …", …]
72
+ if (!ok) console.error(ctx.errors); // ["children[0].effects.strokeTrim.range: …", …]
73
73
  ```
74
74
 
75
75
  **Two modes, two different questions:**
@@ -90,7 +90,7 @@ in-memory object that produced it.
90
90
  `materialiseAllInTree(doc, engine)` is the single entry point that turns a
91
91
  lightweight editor document into a flat tree any renderer can walk:
92
92
 
93
- 1. **Effects** — `node.effects` (transformBy, repeater, maskedBy, trimPath,
93
+ 1. **Effects** — `node.effects` (transformBy, repeater, maskedBy, strokeTrim,
94
94
  clone/retime, gradients, textPath) become real nodes, wrappers and defs.
95
95
  2. **Loops** — each property's `loop` is expanded into explicit keyframes.
96
96
  3. **Motion paths** — tangented `transform` keyframes plus `autoOrient` are
package/dist/index.cjs CHANGED
@@ -93,6 +93,8 @@ __export(index_exports, {
93
93
  PxScrollRangeSchema: () => PxScrollRangeSchema,
94
94
  PxScrollSchema: () => PxScrollSchema,
95
95
  PxStrokeGradientEffectSchema: () => PxStrokeGradientEffectSchema,
96
+ PxStrokeTrimEffectSchema: () => PxStrokeTrimEffectSchema,
97
+ PxStrokeTrimSubPaths: () => PxStrokeTrimSubPaths,
96
98
  PxSvgNodeExtra: () => PxSvgNodeExtra,
97
99
  PxTextEffectSchema: () => PxTextEffectSchema,
98
100
  PxTextPathEffectSchema: () => PxTextPathEffectSchema,
@@ -100,8 +102,6 @@ __export(index_exports, {
100
102
  PxTransformPartsSchema: () => PxTransformPartsSchema,
101
103
  PxTransformValueSchema: () => PxTransformValueSchema,
102
104
  PxTriggerSchema: () => PxTriggerSchema,
103
- PxTrimPathEffectSchema: () => PxTrimPathEffectSchema,
104
- PxTrimSubPaths: () => PxTrimSubPaths,
105
105
  STYLE_ATTR_NAMES: () => STYLE_ATTR_NAMES,
106
106
  TEXT_ATTR: () => TEXT_ATTR,
107
107
  TEXT_CONTENT_ATTR: () => TEXT_CONTENT_ATTR,
@@ -1162,7 +1162,7 @@ var PxTextPathSpacing = {
1162
1162
  auto: "auto",
1163
1163
  exact: "exact"
1164
1164
  };
1165
- var PxTrimSubPaths = {
1165
+ var PxStrokeTrimSubPaths = {
1166
1166
  separate: "separate",
1167
1167
  combined: "combined"
1168
1168
  };
@@ -1406,10 +1406,10 @@ var PxClipPathEffectSchema = implementsInterface()(px.object({
1406
1406
  d: PxAnimatableStringSchema.optional(),
1407
1407
  animate: PxPropertyAnimationSchema.optional()
1408
1408
  }));
1409
- var PxTrimPathEffectSchema = implementsInterface()(px.object({
1409
+ var PxStrokeTrimEffectSchema = implementsInterface()(px.object({
1410
1410
  offset: PxAnimatableNumberSchema.optional(),
1411
1411
  range: PxAnimatableVec2Schema.optional(),
1412
- subPaths: px.enum([PxTrimSubPaths.separate, PxTrimSubPaths.combined]).optional()
1412
+ subPaths: px.enum([PxStrokeTrimSubPaths.separate, PxStrokeTrimSubPaths.combined]).optional()
1413
1413
  }));
1414
1414
  var PxRetimeEffectSchema = implementsInterface()(px.object({
1415
1415
  sourceId: px.string().optional(),
@@ -1463,7 +1463,7 @@ var PxEffectsSchema = implementsInterface()(px.object({
1463
1463
  repeater: PxRepeaterEffectSchema.optional(),
1464
1464
  maskedBy: PxMaskedByEffectSchema.optional(),
1465
1465
  clipPath: PxClipPathEffectSchema.optional(),
1466
- trimPath: PxTrimPathEffectSchema.optional(),
1466
+ strokeTrim: PxStrokeTrimEffectSchema.optional(),
1467
1467
  clone: PxCloneEffectSchema.optional(),
1468
1468
  fillGradient: PxFillGradientEffectSchema.optional(),
1469
1469
  strokeGradient: PxStrokeGradientEffectSchema.optional(),
@@ -5135,10 +5135,10 @@ function applyTextGlyphsAlongPath(node, ctx, pathD, startOffset, textLength, pat
5135
5135
  return materialiseGlyphTextAlongPath(node, pathD, startOffset, { glyphs: ctx.glyphs, warnings: ctx.warnings }, textLength, pathOverflow);
5136
5136
  }
5137
5137
 
5138
- // src/effects/trimPathEffect.ts
5139
- function applyTrimPathEffect(node, trimPath, ctx) {
5140
- if (!trimPath) return node;
5141
- const combined = trimPath.subPaths === PxTrimSubPaths.combined;
5138
+ // src/effects/strokeTrimEffect.ts
5139
+ function applyStrokeTrimEffect(node, strokeTrim, ctx) {
5140
+ if (!strokeTrim) return node;
5141
+ const combined = strokeTrim.subPaths === PxStrokeTrimSubPaths.combined;
5142
5142
  const leafEntries = [];
5143
5143
  const measure = (n) => {
5144
5144
  if (Array.isArray(n.children) && n.children.length > 0) {
@@ -5169,9 +5169,9 @@ function applyTrimPathEffect(node, trimPath, ctx) {
5169
5169
  }
5170
5170
  const chainLengthPx = acc;
5171
5171
  if (combined && chainLengthPx < 1e-3) return node;
5172
- const offsetReadRaw = readAnimatable(trimPath.offset);
5172
+ const offsetReadRaw = readAnimatable(strokeTrim.offset);
5173
5173
  const offsetRead = offsetReadRaw.kind === "absent" /* Absent */ ? { kind: "static" /* Static */, value: 0 } : offsetReadRaw;
5174
- const rangeReadRaw = readRangeWithCrossings(trimPath.range);
5174
+ const rangeReadRaw = readRangeWithCrossings(strokeTrim.range);
5175
5175
  const rangeRead = rangeReadRaw.kind === "absent" /* Absent */ ? { kind: "static" /* Static */, value: [0, 1] } : rangeReadRaw;
5176
5176
  const offsetValues = readScalarValues(offsetRead);
5177
5177
  const minOffset = offsetValues.length ? Math.min(...offsetValues) : 0;
@@ -5503,7 +5503,7 @@ function applyPlayerEffects_exceptRetime(node, ctx) {
5503
5503
  const originalId = typeof node.id === "string" ? node.id : void 0;
5504
5504
  const innerIdForContentRef = originalId ? ctx.contentRefInnerIds.get(originalId) : void 0;
5505
5505
  if (!fx && !innerIdForContentRef) return node;
5506
- const { transformBy, repeater, maskedBy, clipPath, trimPath, clone: cloneFx, fillGradient, strokeGradient, textPath, text } = fx != null ? fx : {};
5506
+ const { transformBy, repeater, maskedBy, clipPath, strokeTrim, clone: cloneFx, fillGradient, strokeGradient, textPath, text } = fx != null ? fx : {};
5507
5507
  if (fx) delete node.effects;
5508
5508
  let n = node;
5509
5509
  let consumedByGlyphs = false;
@@ -5523,7 +5523,7 @@ function applyPlayerEffects_exceptRetime(node, ctx) {
5523
5523
  if (!consumedByGlyphs) n = applyTextPathEffect(n, textPath, ctx);
5524
5524
  n = applyFillGradientEffect(n, fillGradient, ctx);
5525
5525
  n = applyStrokeGradientEffect(n, strokeGradient, ctx);
5526
- n = applyTrimPathEffect(n, trimPath, ctx);
5526
+ n = applyStrokeTrimEffect(n, strokeTrim, ctx);
5527
5527
  n = applyRepeaterEffect(n, repeater, ctx);
5528
5528
  n = applyMaskedByEffect(n, maskedBy, transformBy, ctx);
5529
5529
  n = applyClipPathEffect(n, clipPath, ctx);
@@ -6247,6 +6247,8 @@ function subtractMultiset(a, b) {
6247
6247
  PxScrollRangeSchema,
6248
6248
  PxScrollSchema,
6249
6249
  PxStrokeGradientEffectSchema,
6250
+ PxStrokeTrimEffectSchema,
6251
+ PxStrokeTrimSubPaths,
6250
6252
  PxSvgNodeExtra,
6251
6253
  PxTextEffectSchema,
6252
6254
  PxTextPathEffectSchema,
@@ -6254,8 +6256,6 @@ function subtractMultiset(a, b) {
6254
6256
  PxTransformPartsSchema,
6255
6257
  PxTransformValueSchema,
6256
6258
  PxTriggerSchema,
6257
- PxTrimPathEffectSchema,
6258
- PxTrimSubPaths,
6259
6259
  STYLE_ATTR_NAMES,
6260
6260
  TEXT_ATTR,
6261
6261
  TEXT_CONTENT_ATTR,