@pixodesk/svg-animator-web 1.0.41 → 1.0.44

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.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { P as PxAnimatorApi } from './PxAnimator-yjuSFhQw.cjs';
2
2
  export { a as PxAnimatorOptions, b as PxPlaybackApi, c as PxTagAnimatorOptions, d as createAnimator, l as loadTagAnimators } from './PxAnimator-yjuSFhQw.cjs';
3
3
  import { PxAnimatorCallbacks, PxAnimatedSvgDocument, PxTrigger, PxDiagnostics, PxNode, PxDefinitions } from '@pixodesk/svg-animator-core';
4
- export { PxAnimatedSvgDocument, PxAnimatorCallbacks, PxAnimatorConfig, PxAnimatorConfigSchema, PxBinding, PxDefinitions, PxDefinitionsSchema, PxDiagnostic, PxDiagnosticKind, PxDiagnostics, PxDiagnosticsConfig, PxEngineCallbacks, PxFillMode, PxInfer, PxNode, PxNodeBaseSchema, PxPlatformAdapter, PxPlaybackDirection, PxPlaybackOverride, PxSchema, PxScrollSchema, PxStartOn, PxSvgNode, PxSvgNodeRootSchema, PxTimelineEngineSetting, PxTimelinePatch, PxTrigger, PxTriggerSchema, PxValidationContext, createAdapterAnimator, generateNewIds, px, toDomProps, validateDocument } from '@pixodesk/svg-animator-core';
4
+ export { PxAnimatedSvgDocument, PxAnimatorCallbacks, PxAnimatorConfig, PxAnimatorConfigSchema, PxBinding, PxDefinitions, PxDefinitionsSchema, PxDiagnostic, PxDiagnosticKind, PxDiagnostics, PxDiagnosticsConfig, PxEngineCallbacks, PxFillMode, PxInfer, PxNode, PxNodeBaseSchema, PxPlatformAdapter, PxPlaybackDirection, PxPlaybackOverride, PxSchema, PxScrollSchema, PxSvgNode, PxSvgNodeRootSchema, PxTimelineEngineSetting, PxTimelinePatch, PxTrigger, PxTriggerSchema, PxTriggerStart, PxValidationContext, createAdapterAnimator, generateNewIds, px, toDomProps, validateDocument } from '@pixodesk/svg-animator-core';
5
5
 
6
6
  /**
7
7
  * Options accepted by the pre-rendered entry points — a subset of `PxAnimatorOptions`: the
@@ -19,41 +19,71 @@ interface PxPrerenderedAnimatorOptions extends PxAnimatorCallbacks {
19
19
  }
20
20
 
21
21
  /**
22
- * Sets up event-based triggers for an animation.
22
+ * Wires a document's trigger block to its root element.
23
23
  *
24
- * This function attaches event listeners to the animation's root element based on the
25
- * provided configuration, allowing animations to be started by user interactions
26
- * or visibility changes.
24
+ * TWO INDEPENDENT AXES, which is why there is no `scrollIntoView` here:
25
+ * - `start` — what STARTS the animation: 'load' (default), 'mouseOver', 'click', or 'none'
26
+ * (nothing but the API does).
27
+ * - `offScreen` + `visibilityThreshold` + `visibilityDebounce` — whether it may RUN, whatever
28
+ * started it. Owned by {@link createVisibilityGate}, wired for every document.
27
29
  *
28
- * ### Trigger Options (startOn):
29
- * - 'load' (default): Starts after the page loads.
30
- * - 'mouseOver': Starts on mouse enter.
31
- * - 'click': Toggles play/end action on click.
32
- * - 'scrollIntoView': Starts when the element scrolls into the viewport.
33
- * - 'programmatic': No automatic start. Must be controlled via the API.
30
+ * `start: 'load'` behind the default gate is what `startOn: 'scrollIntoView'` used to mean: hold
31
+ * at frame 0 until enough is on screen, play, pause when it leaves, resume when it returns. The
32
+ * difference is that the same gate now also applies to a document started by a click or a hover.
34
33
  *
35
- * ### End Action Options (outAction):
36
- * Defines behavior when the trigger condition ends (e.g., mouse leave).
37
- * - 'continue' (default): Animation continues playing.
38
- * - 'pause': Pauses the animation.
39
- * - 'reset': Cancels the animation, resetting it to the start.
40
- * - 'reverse': Reverses the animation playback.
34
+ * `mouseOut` is what happens when the pointer LEAVES ('continue' by default, or pause / reset /
35
+ * reverse); it is read only for `start: 'mouseOver'`. A `click` document is a plain play/pause
36
+ * toggle with nothing to configure.
41
37
  *
42
- * @param {!PxAnimatorApi} api The animator API instance to control.
43
- * @param {!PxTrigger} trigger The trigger configuration object. Only `startOn`, `outAction` and
44
- * `scrollIntoViewThreshold` are read here; `finishAction` belongs to the PLAYER (what happens
45
- * after a natural end), not to the trigger wiring.
46
- * @returns A disposer that detaches every listener and observer this call attached (review §14).
47
- * `createAnimator` ties it to `destroy()`. Call it yourself before re-arming an element you
48
- * wired by hand — otherwise the old listeners stay live next to the new ones.
38
+ * @param api The animator API instance to control.
39
+ * @param trigger The trigger configuration. `finish` belongs to the PLAYER (what happens after a
40
+ * natural end), not to the trigger wiring, and is not read here.
41
+ * @returns A disposer that detaches every listener, observer and timer this call attached
42
+ * (review §14). `createAnimator` ties it to `destroy()`. Call it yourself before re-arming an
43
+ * element you wired by hand — otherwise the old listeners stay live next to the new ones.
49
44
  * @public
50
45
  */
51
46
  declare function setupAnimationTriggers(api: PxAnimatorApi, trigger: PxTrigger, diag?: PxDiagnostics): () => void;
52
47
 
48
+ /**
49
+ * THE PAGE-WIDE REGISTRY — every live animator in the window, whoever created it.
50
+ *
51
+ * Like lottie-web's `getRegisteredAnimations()`: a dev tool, a test, or a "pause everything
52
+ * while the tab is hidden" can reach every player without holding on to each `createAnimator`
53
+ * result. An animator joins when it is built and leaves on `destroy()`; play / pause / cancel /
54
+ * finish are announced to subscribers.
55
+ *
56
+ * ONE registry per window, whatever the bundling: the store hangs off `globalThis` under a
57
+ * `Symbol.for` key, so the ESM build in one script and the UMD build in another share it. It
58
+ * is also reachable by NAME — `globalThis.__pixodeskAnimators` — for tooling that does not
59
+ * import the library (a devtools panel reading a page it did not build). Web only: React
60
+ * Native players never touch it.
61
+ *
62
+ * EXPERIMENTAL (2026-09): not settled — the event names, what `getAll()` includes and the
63
+ * global's name may change without a major version. Documented as such in
64
+ * docs/library/web-player.md ("Every animator on the page").
65
+ */
66
+ /** What changed for an animator in the page-wide registry. Experimental — may change. @public */
67
+ type PxAnimatorsEvent = 'add' | 'remove' | 'play' | 'pause' | 'cancel' | 'finish';
68
+ /** Called for every {@link PxAnimatorsEvent} of every animator in the window. Experimental — may change. @public */
69
+ type PxAnimatorsListener = (event: PxAnimatorsEvent, animator: PxAnimatorApi) => void;
70
+ /** The store itself — what `globalThis.__pixodeskAnimators` holds. Experimental — may change. @public */
71
+ interface PxAnimatorRegistry {
72
+ /** Every live animator, in creation order. */
73
+ getAll(): ReadonlyArray<PxAnimatorApi>;
74
+ /** Announcements of add / remove / play / pause / cancel / finish; returns the unsubscribe. */
75
+ subscribe(listener: PxAnimatorsListener): () => void;
76
+ }
77
+ /** Every live animator in this window, in creation order. Experimental — may change. @public */
78
+ declare function getAllAnimators(): ReadonlyArray<PxAnimatorApi>;
79
+ /** Hear every animator in this window start, pause, cancel, finish, appear or go — returns
80
+ * the unsubscribe. Experimental — may change. @public */
81
+ declare function onAnimatorsChange(listener: PxAnimatorsListener): () => void;
82
+
53
83
  /**
54
84
  * Renders a PxNode tree to DOM elements.
55
85
  * @public @advanced
56
86
  */
57
87
  declare function renderNode(node: PxNode, defs?: PxDefinitions, diag?: PxDiagnostics): Element | null;
58
88
 
59
- export { PxAnimatorApi, type PxPrerenderedAnimatorOptions, renderNode, setupAnimationTriggers };
89
+ export { PxAnimatorApi, type PxAnimatorRegistry, type PxAnimatorsEvent, type PxAnimatorsListener, type PxPrerenderedAnimatorOptions, getAllAnimators, onAnimatorsChange, renderNode, setupAnimationTriggers };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { P as PxAnimatorApi } from './PxAnimator-yjuSFhQw.js';
2
2
  export { a as PxAnimatorOptions, b as PxPlaybackApi, c as PxTagAnimatorOptions, d as createAnimator, l as loadTagAnimators } from './PxAnimator-yjuSFhQw.js';
3
3
  import { PxAnimatorCallbacks, PxAnimatedSvgDocument, PxTrigger, PxDiagnostics, PxNode, PxDefinitions } from '@pixodesk/svg-animator-core';
4
- export { PxAnimatedSvgDocument, PxAnimatorCallbacks, PxAnimatorConfig, PxAnimatorConfigSchema, PxBinding, PxDefinitions, PxDefinitionsSchema, PxDiagnostic, PxDiagnosticKind, PxDiagnostics, PxDiagnosticsConfig, PxEngineCallbacks, PxFillMode, PxInfer, PxNode, PxNodeBaseSchema, PxPlatformAdapter, PxPlaybackDirection, PxPlaybackOverride, PxSchema, PxScrollSchema, PxStartOn, PxSvgNode, PxSvgNodeRootSchema, PxTimelineEngineSetting, PxTimelinePatch, PxTrigger, PxTriggerSchema, PxValidationContext, createAdapterAnimator, generateNewIds, px, toDomProps, validateDocument } from '@pixodesk/svg-animator-core';
4
+ export { PxAnimatedSvgDocument, PxAnimatorCallbacks, PxAnimatorConfig, PxAnimatorConfigSchema, PxBinding, PxDefinitions, PxDefinitionsSchema, PxDiagnostic, PxDiagnosticKind, PxDiagnostics, PxDiagnosticsConfig, PxEngineCallbacks, PxFillMode, PxInfer, PxNode, PxNodeBaseSchema, PxPlatformAdapter, PxPlaybackDirection, PxPlaybackOverride, PxSchema, PxScrollSchema, PxSvgNode, PxSvgNodeRootSchema, PxTimelineEngineSetting, PxTimelinePatch, PxTrigger, PxTriggerSchema, PxTriggerStart, PxValidationContext, createAdapterAnimator, generateNewIds, px, toDomProps, validateDocument } from '@pixodesk/svg-animator-core';
5
5
 
6
6
  /**
7
7
  * Options accepted by the pre-rendered entry points — a subset of `PxAnimatorOptions`: the
@@ -19,41 +19,71 @@ interface PxPrerenderedAnimatorOptions extends PxAnimatorCallbacks {
19
19
  }
20
20
 
21
21
  /**
22
- * Sets up event-based triggers for an animation.
22
+ * Wires a document's trigger block to its root element.
23
23
  *
24
- * This function attaches event listeners to the animation's root element based on the
25
- * provided configuration, allowing animations to be started by user interactions
26
- * or visibility changes.
24
+ * TWO INDEPENDENT AXES, which is why there is no `scrollIntoView` here:
25
+ * - `start` — what STARTS the animation: 'load' (default), 'mouseOver', 'click', or 'none'
26
+ * (nothing but the API does).
27
+ * - `offScreen` + `visibilityThreshold` + `visibilityDebounce` — whether it may RUN, whatever
28
+ * started it. Owned by {@link createVisibilityGate}, wired for every document.
27
29
  *
28
- * ### Trigger Options (startOn):
29
- * - 'load' (default): Starts after the page loads.
30
- * - 'mouseOver': Starts on mouse enter.
31
- * - 'click': Toggles play/end action on click.
32
- * - 'scrollIntoView': Starts when the element scrolls into the viewport.
33
- * - 'programmatic': No automatic start. Must be controlled via the API.
30
+ * `start: 'load'` behind the default gate is what `startOn: 'scrollIntoView'` used to mean: hold
31
+ * at frame 0 until enough is on screen, play, pause when it leaves, resume when it returns. The
32
+ * difference is that the same gate now also applies to a document started by a click or a hover.
34
33
  *
35
- * ### End Action Options (outAction):
36
- * Defines behavior when the trigger condition ends (e.g., mouse leave).
37
- * - 'continue' (default): Animation continues playing.
38
- * - 'pause': Pauses the animation.
39
- * - 'reset': Cancels the animation, resetting it to the start.
40
- * - 'reverse': Reverses the animation playback.
34
+ * `mouseOut` is what happens when the pointer LEAVES ('continue' by default, or pause / reset /
35
+ * reverse); it is read only for `start: 'mouseOver'`. A `click` document is a plain play/pause
36
+ * toggle with nothing to configure.
41
37
  *
42
- * @param {!PxAnimatorApi} api The animator API instance to control.
43
- * @param {!PxTrigger} trigger The trigger configuration object. Only `startOn`, `outAction` and
44
- * `scrollIntoViewThreshold` are read here; `finishAction` belongs to the PLAYER (what happens
45
- * after a natural end), not to the trigger wiring.
46
- * @returns A disposer that detaches every listener and observer this call attached (review §14).
47
- * `createAnimator` ties it to `destroy()`. Call it yourself before re-arming an element you
48
- * wired by hand — otherwise the old listeners stay live next to the new ones.
38
+ * @param api The animator API instance to control.
39
+ * @param trigger The trigger configuration. `finish` belongs to the PLAYER (what happens after a
40
+ * natural end), not to the trigger wiring, and is not read here.
41
+ * @returns A disposer that detaches every listener, observer and timer this call attached
42
+ * (review §14). `createAnimator` ties it to `destroy()`. Call it yourself before re-arming an
43
+ * element you wired by hand — otherwise the old listeners stay live next to the new ones.
49
44
  * @public
50
45
  */
51
46
  declare function setupAnimationTriggers(api: PxAnimatorApi, trigger: PxTrigger, diag?: PxDiagnostics): () => void;
52
47
 
48
+ /**
49
+ * THE PAGE-WIDE REGISTRY — every live animator in the window, whoever created it.
50
+ *
51
+ * Like lottie-web's `getRegisteredAnimations()`: a dev tool, a test, or a "pause everything
52
+ * while the tab is hidden" can reach every player without holding on to each `createAnimator`
53
+ * result. An animator joins when it is built and leaves on `destroy()`; play / pause / cancel /
54
+ * finish are announced to subscribers.
55
+ *
56
+ * ONE registry per window, whatever the bundling: the store hangs off `globalThis` under a
57
+ * `Symbol.for` key, so the ESM build in one script and the UMD build in another share it. It
58
+ * is also reachable by NAME — `globalThis.__pixodeskAnimators` — for tooling that does not
59
+ * import the library (a devtools panel reading a page it did not build). Web only: React
60
+ * Native players never touch it.
61
+ *
62
+ * EXPERIMENTAL (2026-09): not settled — the event names, what `getAll()` includes and the
63
+ * global's name may change without a major version. Documented as such in
64
+ * docs/library/web-player.md ("Every animator on the page").
65
+ */
66
+ /** What changed for an animator in the page-wide registry. Experimental — may change. @public */
67
+ type PxAnimatorsEvent = 'add' | 'remove' | 'play' | 'pause' | 'cancel' | 'finish';
68
+ /** Called for every {@link PxAnimatorsEvent} of every animator in the window. Experimental — may change. @public */
69
+ type PxAnimatorsListener = (event: PxAnimatorsEvent, animator: PxAnimatorApi) => void;
70
+ /** The store itself — what `globalThis.__pixodeskAnimators` holds. Experimental — may change. @public */
71
+ interface PxAnimatorRegistry {
72
+ /** Every live animator, in creation order. */
73
+ getAll(): ReadonlyArray<PxAnimatorApi>;
74
+ /** Announcements of add / remove / play / pause / cancel / finish; returns the unsubscribe. */
75
+ subscribe(listener: PxAnimatorsListener): () => void;
76
+ }
77
+ /** Every live animator in this window, in creation order. Experimental — may change. @public */
78
+ declare function getAllAnimators(): ReadonlyArray<PxAnimatorApi>;
79
+ /** Hear every animator in this window start, pause, cancel, finish, appear or go — returns
80
+ * the unsubscribe. Experimental — may change. @public */
81
+ declare function onAnimatorsChange(listener: PxAnimatorsListener): () => void;
82
+
53
83
  /**
54
84
  * Renders a PxNode tree to DOM elements.
55
85
  * @public @advanced
56
86
  */
57
87
  declare function renderNode(node: PxNode, defs?: PxDefinitions, diag?: PxDiagnostics): Element | null;
58
88
 
59
- export { PxAnimatorApi, type PxPrerenderedAnimatorOptions, renderNode, setupAnimationTriggers };
89
+ export { PxAnimatorApi, type PxAnimatorRegistry, type PxAnimatorsEvent, type PxAnimatorsListener, type PxPrerenderedAnimatorOptions, getAllAnimators, onAnimatorsChange, renderNode, setupAnimationTriggers };