@pixodesk/svg-animator-core 1.0.35 → 1.0.39

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
@@ -6,7 +6,7 @@
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
8
  Platform-neutral core of the Pixodesk SVG animator: the document schema, the
9
- effect materialisers, the interpolation engine and the path sampler — with **no
9
+ effect materializers, the interpolation engine and the path sampler — with **no
10
10
  DOM dependency at all**. It is what every player shares, so the web player and
11
11
  the React Native player produce identical values from the same document.
12
12
 
@@ -16,6 +16,7 @@ the React Native player produce identical values from the same document.
16
16
 
17
17
  Usually **no**. If you just want to play an animation, install a player:
18
18
 
19
+ <!-- px-check off the package list, prose -->
19
20
  | You are building for | Install |
20
21
  |---|---|
21
22
  | Browser (vanilla JS) | [`@pixodesk/svg-animator-web`](../svg-animator-web/README.md) |
@@ -48,17 +49,18 @@ runtime crash on a non-browser platform.
48
49
 
49
50
  ## What's inside
50
51
 
52
+ <!-- px-check exports @pixodesk/svg-animator-core partial -->
51
53
  | Area | Exports |
52
54
  |---|---|
53
55
  | **Schema & types** | `PxAnimatedSvgDocumentSchema`, `PxNodeSchema`, `PxEffectsSchema`, … plus every `Px*` TypeScript type and the `px` schema builder |
54
56
  | **Validation** | `validateDocument` (the whole document, strict), `isPxElementFileFormat`, `isPxElementFileFormatDeep`, `validateNodeEffects` |
55
- | **Materialisers** | `materialiseAllInTree`, `applyPlayerEffects`, `materialiseInternalLoopsInTree`, `materialiseMotionPathsInTree`, `materialiseAnimatedUseInstances` |
56
- | **Interpolation** | `calcAnimationValues`, `interpolateValue`, `getNormalisedBindings` |
57
+ | **Materializers** | `materializeAllInTree`, `applyPlayerEffects`, `materializeInternalLoopsInTree`, `materializeMotionPathsInTree`, `materializeAnimatedUseInstances` |
58
+ | **Interpolation** | `calcAnimationValues`, `interpolateValue`, `getNormalizedBindings` |
57
59
  | **Sampling / geometry** | `createPathSampler`, `evaluateMotionPathSegment`, bezier helpers, `cubicBezier`, `splitEasing` |
58
- | **Text** | `materialiseGlyphText`, `layoutGlyphTextChars`, `extendedPathForBrowser` |
59
- | **Node helpers** | `getNormalizedProps`, `sanitiseAttributeValue`, `resolveStyle`, `generateNewIds` |
60
+ | **Text** | `materializeGlyphText`, `layoutGlyphTextChars`, `extendedPathForBrowser` |
61
+ | **Node helpers** | `getNormalizedProps`, `sanitizeAttributeValue`, `resolveStyle`, `generateNewIds` |
60
62
  | **Playback engine** | `createBasicFrameLoopAnimator` + the `PxPlatformAdapter` interface |
61
- | **Wire enums** | `PxAnimatorMode`, `PxTimelineEngine`, `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 |
63
+ | **Wire enums** | `PxTimelineEngine` / `PxTimelineEngineExtra`, `PxStartOn`, `PxOutAction`, `PxFinishAction`, `PxFillMode`, `PxPlaybackDirection`, `PxScrollKind`, `PxScrollAxis`, `PxScrollSource`, `PxScrollPhase`, `PxPinAlign`, `PxAlongPathMode`, `PxLoopRepeatAt`, `PxLoopDirection`, `PxStrokeTrimSubPaths`, `PxMaskType`, `PxCloneWithout`, `PxUnits`, `PxGradientType`, `PxGradientSpreadMethod`, `PxPathOverflow`, `PxLengthAdjust`, `PxTextPathMethod`, `PxTextPathSpacing` — every two-or-more-way wire selector is a named enum, not a bare string. Each is a const namespace AND the string type derived from it under the same name, so `PxStartOn.click` and `startOn?: PxStartOn` come from one import |
62
64
 
63
65
  ### Validating a document
64
66
 
@@ -76,6 +78,7 @@ if (!ok) console.error(ctx.errors); // ["children[0].effects.strokeTrim.range:
76
78
 
77
79
  **Two modes, two different questions:**
78
80
 
81
+ <!-- px-check off validation modes, prose -->
79
82
  | mode | question it answers | undeclared keys |
80
83
  |---|---|---|
81
84
  | default (`strict` absent/false) | *is this document repairable?* — what `sanitize` would accept | ignored, so unknown future fields stay forward-compatible |
@@ -87,9 +90,9 @@ per-branch errors are not reported unless every branch fails), and it **ignores
87
90
  `undefined`** — those cannot survive `JSON.stringify`, so strict judges the document rather than the
88
91
  in-memory object that produced it.
89
92
 
90
- ## The materialisation pipeline
93
+ ## The materialization pipeline
91
94
 
92
- `materialiseAllInTree(doc, engine)` is the single entry point that turns a
95
+ `materializeAllInTree(doc, engine)` is the single entry point that turns a
93
96
  lightweight editor document into a flat tree any renderer can walk:
94
97
 
95
98
  1. **Effects** — `node.effects` (transformBy, repeater, maskedBy, strokeTrim,
@@ -105,22 +108,22 @@ without live `<use>` propagation** — that includes `react-native-svg` — and
105
108
 
106
109
  ```ts
107
110
  import {
108
- materialiseAllInTree, generateNewIds, calcAnimationValues,
109
- getNormalisedBindings, PxTimelineEngine,
111
+ materializeAllInTree, generateNewIds, calcAnimationValues,
112
+ getNormalizedBindings, PxTimelineEngine,
110
113
  } from '@pixodesk/svg-animator-core';
111
114
 
112
115
  // Flatten once …
113
- const flat = generateNewIds(materialiseAllInTree(doc, PxTimelineEngine.native));
116
+ const flat = generateNewIds(materializeAllInTree(doc, PxTimelineEngine.native));
114
117
 
115
118
  // … then ask for values at any time, with no renderer involved.
116
- for (const binding of getNormalisedBindings(flat, PxTimelineEngine.js) ?? []) {
119
+ for (const binding of getNormalizedBindings(flat, PxTimelineEngine.js) ?? []) {
117
120
  const values = calcAnimationValues(binding.animate, 500); // t = 500 ms
118
121
  console.log(binding.id, values); // → { opacity: '0.5', transform: 'translate(…)' }
119
122
  }
120
123
  ```
121
124
 
122
125
  This is exactly how the React Native player precomputes its animation tracks, and
123
- how the frames engine renders each tick in the browser — same function, same
126
+ how the frame-loop engine renders each tick in the browser — same function, same
124
127
  numbers.
125
128
 
126
129
  ## Writing your own player