@pixodesk/svg-animator-web 1.0.39 → 1.0.41

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
@@ -87,8 +87,7 @@ animator.destroy(); // cleanup
87
87
  | `src` | `string` | URL to fetch the animation document from (provide either `src` or `doc`) |
88
88
  | `doc` | `PxAnimatedSvgDocument` | Inline animation document object |
89
89
  | `container` | `string \| Element` | CSS selector or element to render the SVG into |
90
- | `onPlay` · `onPause` · `onCancel` · `onFinish` · `onRemove` · `onStop` | `() => void` | the lifecycle callbacks, inline — the same names the components take; plus `onWarn`, `onError`, `silent` for diagnostics. See [Callbacks](#callbacks) | <!-- px names=onPlay,onPause,onCancel,onFinish,onRemove,onStop,onWarn,onError,silent -->
91
- | `adapter` | `PxPlatformAdapter` | Custom attribute-writer for frame-loop rendering (advanced) |
90
+ | `onPlay` · `onPause` · `onCancel` · `onFinish` · `onRemove` · `onStop` | `() => void` | the lifecycle callbacks, inline — the same names the components take; plus `onWarn`, `onError`, `muteWarn`, `muteError` for diagnostics. See [Callbacks](#callbacks) | <!-- px names=onPlay,onPause,onCancel,onFinish,onRemove,onStop,onWarn,onError,muteWarn,muteError -->
92
91
  | `timeline` | `object \| string` | per-instance override of the document's `timeline` block, deep-merged over it — same shape as the file; `null` at any slot deletes that key. A JSON string is accepted too. See [Playback overrides](#playback-overrides) |
93
92
  | `resetTimeline` | `boolean` | ignore the document's own timeline and start from the player's default timeline, with `timeline` on top |
94
93
  | `duration` · `delay` | `number` | Shortcuts for `timeline.duration` / `.delay` (ms) | <!-- px names=duration,delay -->
@@ -108,9 +107,9 @@ const animator = createAnimator({
108
107
  animator.play();
109
108
  ```
110
109
 
111
- It returns a `PxAnimatorAPI`:
110
+ It returns a `PxAnimatorApi`:
112
111
 
113
- <!-- px-check props PxAnimatorAPI pkg=web -->
112
+ <!-- px-check props PxAnimatorApi pkg=web -->
114
113
  | Method | Description |
115
114
  | ----------------------- | ----------------------------------------------------------------- |
116
115
  | `play()` | Start or resume playback |
@@ -156,15 +155,23 @@ same shape as the JSON export. It comes in two modes:
156
155
 
157
156
  - **Self-contained document** — has `children`: the player renders the SVG tree and animates it.
158
157
  - **Bind-by-id document** — no `children`: the player animates a pre-existing SVG DOM, mapping
159
- element ids to animation specs via `animator.animateById`.
158
+ each `bindings` entry names an element (`target`, `#id`) and the named animations it plays (`animateWith`).
160
159
 
161
160
  Elements may also carry a `node.effects` bucket (structural effects such as
162
161
  `transformBy`, `repeater`, `maskedBy`, `strokeTrim`, `clone`, `fillGradient` /
163
162
  `strokeGradient`, `textPath`). This player materializes and removes them at
164
163
  runtime before any other normalization.
165
164
 
165
+ When you want the markup without a player — a static first frame, a thumbnail, a snapshot —
166
+ `renderNode` is that one step on its own: hand it a node and it returns the DOM element for it, or
167
+ `null` when the node renders to nothing. Give it the document's `animator.definitions` as the
168
+ second argument so named fonts resolve, and a diagnostics channel as the third to hear about
169
+ anything it skips. It renders; it does not animate. `toDomProps(props)` is the attribute half of
170
+ that step on its own: a node's attributes, resolved to what the DOM receives.
171
+
166
172
  See the [JSON format reference](../../docs/format/README.md#json-format-reference) and
167
173
  [Player effects](../../docs/format/README.md#player-effects) for the full schema and
168
- examples (compact printable schema: [SCHEMA.md](../../SCHEMA.md)). The wire
169
- types live in [`PxAnimatorTypes.ts`](../svg-animator-core/src/format/PxAnimatorTypes.ts).
174
+ examples, and [Schema at a glance](../../docs/format/README.md#schema-at-a-glance) for the whole
175
+ format as typings. The wire types live in
176
+ [`PxAnimatorTypes.ts`](../svg-animator-core/src/format/PxAnimatorTypes.ts).
170
177
 
@@ -0,0 +1,73 @@
1
+ import { PxAnimatorApi as PxAnimatorApi$1, PxPlaybackApi as PxPlaybackApi$1, PxPlaybackOverride, PxAnimatorCallbacks, PxAnimatedSvgDocument, PxPlatformAdapter } from '@pixodesk/svg-animator-core';
2
+
3
+ /**
4
+ * DOM specializations of the platform-neutral animator API types.
5
+ * `getRootElement()` returns a DOM `Element` on the web — these aliases keep
6
+ * the historical (pre-core-extraction) signatures for web consumers.
7
+ * @public
8
+ */
9
+ type PxPlaybackApi = PxPlaybackApi$1<Element>;
10
+ /** @public */
11
+ type PxAnimatorApi = PxAnimatorApi$1<Element>;
12
+
13
+ /**
14
+ * Everything `createAnimator` takes. The playback override (`timeline`, `resetTimeline` and the
15
+ * four shortcuts) and the callbacks are core's shared shapes — the SAME names, inline, as the
16
+ * React, Vue and React Native components take (review §9) — so only what is web-specific is
17
+ * declared here.
18
+ * @public
19
+ */
20
+ interface PxAnimatorOptions extends PxPlaybackOverride, PxAnimatorCallbacks {
21
+ /** URL to fetch the animation document from. Provide either this or `doc`, not both. */
22
+ src?: string;
23
+ /** The animation document, inline (see docs/format/README.md). Provide either this or `src`, not both. */
24
+ doc?: PxAnimatedSvgDocument;
25
+ /** CSS selector or element to render the SVG into. */
26
+ container?: string | Element;
27
+ }
28
+ /**
29
+ * What the framework COMPONENTS build the player with: the public options plus the `adapter`
30
+ * that routes the frame loop's attribute writes to the elements they rendered themselves.
31
+ *
32
+ * NOT part of the public API (review §25.14). The React and Vue packages are its only callers;
33
+ * `createAnimator`'s signature says `PxAnimatorOptions` on purpose — a page has a DOM to write
34
+ * to, so for anyone else the option would only be a way to hold the player wrong. Exported as a
35
+ * type so those packages can name it; never documented as an option.
36
+ * @internal
37
+ */
38
+ interface PxInternalAnimatorOptions extends PxAnimatorOptions {
39
+ /** A custom render target for the frame-loop engine (`PxPlatformAdapter`). */
40
+ adapter?: PxPlatformAdapter;
41
+ }
42
+ /**
43
+ * Creates an animator instance to control SVG animations.
44
+ *
45
+ * @param options.src URL to fetch the animation document from.
46
+ * @param options.doc The animation document, inline.
47
+ * @param options.container CSS selector or element to render the SVG into.
48
+ * @returns A PxAnimatorApi instance to programmatically control the animation.
49
+ * @public
50
+ */
51
+ declare function createAnimator(options: PxAnimatorOptions): PxAnimatorApi;
52
+ /**
53
+ * Scan and load for tags, e.g.
54
+ * <div data-px-animation-src="animation.json"></div>
55
+ */
56
+ /**
57
+ * Everything `createAnimator` takes except the three the tag supplies (`src`, `container`) or
58
+ * forbids (`data`): callbacks, the diagnostics channel, a playback override and its shortcuts.
59
+ * @public
60
+ */
61
+ type PxTagAnimatorOptions = Omit<PxAnimatorOptions, 'src' | 'doc' | 'container'>;
62
+ /**
63
+ * Scan the page for `<div data-px-animation-src="animation.json">` and create one player per
64
+ * match, rendered into that element and stored on it. Safe to call repeatedly: elements that
65
+ * already carry a player are skipped.
66
+ *
67
+ * `options` applies to EVERY player this call creates (review §15) — the same callbacks, the
68
+ * same override. Omit it for the zero-config path.
69
+ * @public
70
+ */
71
+ declare function loadTagAnimators(options?: PxTagAnimatorOptions): void;
72
+
73
+ export { type PxAnimatorApi as P, type PxAnimatorOptions as a, type PxPlaybackApi as b, type PxTagAnimatorOptions as c, createAnimator as d, type PxInternalAnimatorOptions as e, loadTagAnimators as l };
@@ -0,0 +1,73 @@
1
+ import { PxAnimatorApi as PxAnimatorApi$1, PxPlaybackApi as PxPlaybackApi$1, PxPlaybackOverride, PxAnimatorCallbacks, PxAnimatedSvgDocument, PxPlatformAdapter } from '@pixodesk/svg-animator-core';
2
+
3
+ /**
4
+ * DOM specializations of the platform-neutral animator API types.
5
+ * `getRootElement()` returns a DOM `Element` on the web — these aliases keep
6
+ * the historical (pre-core-extraction) signatures for web consumers.
7
+ * @public
8
+ */
9
+ type PxPlaybackApi = PxPlaybackApi$1<Element>;
10
+ /** @public */
11
+ type PxAnimatorApi = PxAnimatorApi$1<Element>;
12
+
13
+ /**
14
+ * Everything `createAnimator` takes. The playback override (`timeline`, `resetTimeline` and the
15
+ * four shortcuts) and the callbacks are core's shared shapes — the SAME names, inline, as the
16
+ * React, Vue and React Native components take (review §9) — so only what is web-specific is
17
+ * declared here.
18
+ * @public
19
+ */
20
+ interface PxAnimatorOptions extends PxPlaybackOverride, PxAnimatorCallbacks {
21
+ /** URL to fetch the animation document from. Provide either this or `doc`, not both. */
22
+ src?: string;
23
+ /** The animation document, inline (see docs/format/README.md). Provide either this or `src`, not both. */
24
+ doc?: PxAnimatedSvgDocument;
25
+ /** CSS selector or element to render the SVG into. */
26
+ container?: string | Element;
27
+ }
28
+ /**
29
+ * What the framework COMPONENTS build the player with: the public options plus the `adapter`
30
+ * that routes the frame loop's attribute writes to the elements they rendered themselves.
31
+ *
32
+ * NOT part of the public API (review §25.14). The React and Vue packages are its only callers;
33
+ * `createAnimator`'s signature says `PxAnimatorOptions` on purpose — a page has a DOM to write
34
+ * to, so for anyone else the option would only be a way to hold the player wrong. Exported as a
35
+ * type so those packages can name it; never documented as an option.
36
+ * @internal
37
+ */
38
+ interface PxInternalAnimatorOptions extends PxAnimatorOptions {
39
+ /** A custom render target for the frame-loop engine (`PxPlatformAdapter`). */
40
+ adapter?: PxPlatformAdapter;
41
+ }
42
+ /**
43
+ * Creates an animator instance to control SVG animations.
44
+ *
45
+ * @param options.src URL to fetch the animation document from.
46
+ * @param options.doc The animation document, inline.
47
+ * @param options.container CSS selector or element to render the SVG into.
48
+ * @returns A PxAnimatorApi instance to programmatically control the animation.
49
+ * @public
50
+ */
51
+ declare function createAnimator(options: PxAnimatorOptions): PxAnimatorApi;
52
+ /**
53
+ * Scan and load for tags, e.g.
54
+ * <div data-px-animation-src="animation.json"></div>
55
+ */
56
+ /**
57
+ * Everything `createAnimator` takes except the three the tag supplies (`src`, `container`) or
58
+ * forbids (`data`): callbacks, the diagnostics channel, a playback override and its shortcuts.
59
+ * @public
60
+ */
61
+ type PxTagAnimatorOptions = Omit<PxAnimatorOptions, 'src' | 'doc' | 'container'>;
62
+ /**
63
+ * Scan the page for `<div data-px-animation-src="animation.json">` and create one player per
64
+ * match, rendered into that element and stored on it. Safe to call repeatedly: elements that
65
+ * already carry a player are skipped.
66
+ *
67
+ * `options` applies to EVERY player this call creates (review §15) — the same callbacks, the
68
+ * same override. Omit it for the zero-config path.
69
+ * @public
70
+ */
71
+ declare function loadTagAnimators(options?: PxTagAnimatorOptions): void;
72
+
73
+ export { type PxAnimatorApi as P, type PxAnimatorOptions as a, type PxPlaybackApi as b, type PxTagAnimatorOptions as c, createAnimator as d, type PxInternalAnimatorOptions as e, loadTagAnimators as l };
@@ -0,0 +1,42 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // src/shared/PxAnimatorKeys.ts
34
+ var PX_ANIMATOR_DOC_KEY = "doc";
35
+
36
+ export {
37
+ __spreadValues,
38
+ __spreadProps,
39
+ __objRest,
40
+ PX_ANIMATOR_DOC_KEY
41
+ };
42
+ //# sourceMappingURL=chunk-BYDBNKO7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shared/PxAnimatorKeys.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------\n * Copyright (c) Pixodesk LTD.\n * Licensed under the MIT License. See the LICENSE file in the project root for details.\n *---------------------------------------------------------------------------------------*/\n\n/**\n * Wire keys shared by every entry point.\n *\n * These live here rather than in `PxAnimator.ts` on purpose: that module used to end with a\n * top-level `if (typeof window !== 'undefined')` block publishing `createAnimator` /\n * `loadTagAnimators` as globals. A module-level side effect cannot be tree-shaken, so\n * importing ANY symbol from `PxAnimator.ts` pulled the entire full player in with it —\n * which silently made the pre-rendered builds the same size as the full one until this\n * constant was moved out. See dev-docs/plans/prerendered-player-builds.md.\n *\n * That block is gone (API review §4) and the package now declares `\"sideEffects\": false`, but\n * keeping these here costs nothing and removes the trap for good.\n */\n\n/**\n * Key under which `createAnimator` options carry the inline animation document. The editor\n * writes it into every exported SVG+JS — `createAnimator({\"doc\": …})` — so it is part of the\n * export format, which is why it is a named constant and not a literal.\n * @internal\n */\nexport const PX_ANIMATOR_DOC_KEY = 'doc';\n\n/** Key under which `createAnimator` options carry the per-instance `timeline` override. */\nexport const PX_ANIMATOR_TIMELINE_KEY = 'timeline';\n\n/** Key that makes the override start from the player's default timeline instead of the document's. */\nexport const PX_ANIMATOR_RESET_KEY = 'resetTimeline';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,IAAM,sBAAsB;","names":[]}
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,r=Object.defineProperties,t=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,n=(r,t,o)=>t in r?e(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,c=(e,r)=>{for(var t in r||(r={}))a.call(r,t)&&n(e,t,r[t]);if(o)for(var t of o(r))l.call(r,t)&&n(e,t,r[t]);return e},f=(e,o)=>r(e,t(o)),i=(e,r)=>{var t={};for(var n in e)a.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&o)for(var n of o(e))r.indexOf(n)<0&&l.call(e,n)&&(t[n]=e[n]);return t},p="doc";export{c as __spreadValues,f as __spreadProps,i as __objRest,p as PX_ANIMATOR_DOC_KEY};