@pixodesk/svg-animator-web 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 +25 -23
- package/dist/index.cjs +884 -287
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -61
- package/dist/index.d.ts +66 -61
- package/dist/index.js +828 -273
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.prerendered-waapi.umd.js +331 -75
- package/dist/index.prerendered-waapi.umd.js.map +1 -1
- package/dist/index.prerendered-waapi.umd.min.js +1 -1
- package/dist/index.prerendered.umd.js +374 -104
- package/dist/index.prerendered.umd.js.map +1 -1
- package/dist/index.prerendered.umd.min.js +1 -1
- package/dist/pixodesk-svg-animator.umd.js +785 -452
- package/dist/pixodesk-svg-animator.umd.js.map +1 -1
- package/dist/pixodesk-svg-animator.umd.min.js +1 -1
- package/mangle-reserved.json +20 -8
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PxAnimatorAPI as PxAnimatorAPI$1, PxBasicAnimatorAPI as PxBasicAnimatorAPI$1,
|
|
2
|
-
export { ApplyResult,
|
|
1
|
+
import { PxAnimatorAPI as PxAnimatorAPI$1, PxBasicAnimatorAPI as PxBasicAnimatorAPI$1, PxPlaybackOverrideProps, PxComponentCallbacks, PxAnimatedSvgDocument, PxPlatformAdapter, PxTrigger, PxDiagnostics, PxNode, PxDefs, PxAnimatorCallbacksConfig } from '@pixodesk/svg-animator-core';
|
|
2
|
+
export { ApplyResult, BASELINE_PLAYER_VERSION, COLOR_ATTR_NAMES, DEFAULT_DURATION_MS, ExtendPathOpts, ExtendedPath, GlyphCharBox, GlyphCharBoxAlongPath, GlyphMaterializeOpts, KeysMatch, MISSING_GLYPH_CLASS_NAME, MaterializeAllOptions, MotionPathMaterializationOptions, MotionPathSample, PLAYER_WIRE_STEPS, PLAYER_WIRE_VERSION, PX_ANIM_ATTR_NAME, PX_ANIM_SRC_ATTR_NAME, PX_PLAYER_SCHEMA_VERSION, PX_TRANSFORM_PART_KEYS, PX_TRIGGER_DEFAULTS, PathPoint, PathSampler, PlayerConversionResult, PxAlongPathMode, PxAnimatable, PxAnimatedSvgDocument, PxAnimatedSvgDocumentSchema, PxAnimationDefinition, PxAnimationDefinitionSchema, PxAnimatorCallbacksConfig, PxAnimatorConfig, PxAnimatorConfigMergeResult, PxAnimatorConfigPatch, PxAnimatorConfigSchema, PxAnimatorConfigShortcuts, PxAnimatorHandle, PxAnyKeyframe, PxAttrValue, PxAttrValueSchema, PxBezierPath, PxBezierPathSchema, PxBinding, PxBindingSchema, PxClipPathEffectSchema, PxCloneEffect, PxCloneEffectSchema, PxCloneWithout, PxComponentCallbacks, PxControlMode, PxControlProps, PxCreateElement, PxDefs, PxDefsSchema, PxDiagnostic, PxDiagnosticKind, PxDiagnostics, PxDiagnosticsConfig, PxDocumentDiagnosis, PxEasingOrRefSchema, PxEffects, PxEffectsSchema, PxElementAnimation, PxElementAnimationSchema, PxFillGradientEffect, PxFillGradientEffectSchema, PxFillMode, PxFinishAction, PxGlyph, PxGlyphFont, PxGradientSpreadMethod, PxGradientStop, PxGradientStopSchema, PxGradientType, PxInfer, PxKeyframe, PxKeyframeSchema, PxKeyframeValueSchema, PxLengthAdjust, PxLoop, PxLoopDirection, PxLoopRepeatAt, PxLoopSchema, PxMaskType, PxMaskedByEffect, PxMaskedByEffectSchema, PxNode, PxNodeBase, PxNodeSchema, PxNormalizedKeyframe, PxOutAction, PxPathOverflow, PxPinAlign, PxPlatformAdapter, PxPlaybackDirection, PxPlaybackOverrideProps, PxPropertyAnimation, PxPropertyAnimationSchema, PxRepeaterEffect, PxRepeaterEffectSchema, PxResolvedControlMode, PxRetimeEffect, PxRetimeEffectSchema, PxSchema, PxSchemaDesc, PxScrollAxis, PxScrollKind, PxScrollPhase, PxScrollRangePointSchema, PxScrollRangeSchema, PxScrollSchema, PxScrollSource, PxStartOn, PxStrokeGradientEffect, PxStrokeGradientEffectSchema, PxStrokeTrimEffect, PxStrokeTrimEffectSchema, PxStrokeTrimSubPaths, PxSvgNode, PxSvgNodeExtra, PxTextEffectSchema, PxTextPathEffect, PxTextPathEffectSchema, PxTextPathMethod, PxTextPathSpacing, PxTimelineEngine, PxTimelineEngineExtra, PxTimelinePatch, PxTimelinePinSchema, PxTimelineSchema, PxTransformByEffect, PxTransformByEffectSchema, PxTransformPartKey, PxTransformParts, PxTransformPartsSchema, PxTransformValue, PxTransformValueSchema, PxTrigger, PxTriggerSchema, PxUnits, PxValidationContext, PxValidationResult, RemoveIndex, STYLE_ATTR_NAMES, TRANSFORM_FN_NAMES, Vec2, WIRE_VERSION_KEY, WireConversionConfig, WireDowngradeConfig, WireDowngradeResult, WireStepKind, WireVersion, WireVersionRelation, WireVersionStep, applyAnimatorConfig, applyPlayerEffects, calcAnimationValues, camelCaseToKebabWordIfNeeded, collectSampleTimes, compareWireVersion, controlModeTakesOverTrigger, convertPlayerDocument, createBasicFrameLoopAnimator, createDiagnostics, createPathSampler, describeSchema, diagnoseDocument, diffInEffect, downgradePlayerDocument, evaluateMotionPathSegment, extendedPathForBrowser, foldTimelineOverride, formatWireVersion, generateNewIds, getAnimatorConfig, getBindings, getChildren, getDefs, getNormalizedProps, isPxElementFileFormat, isPxElementFileFormatDeep, jsonElementFactory, layoutGlyphTextChars, materializeAllInTree, materializeAnimatedUseInstances, materializeGlyphText, materializeGlyphTextAlongPath, materializeGlyphTextHorizontal, materializeInternalLoopsInPropAnim, materializeInternalLoopsInTree, materializeMotionPathInPropAnim, materializeMotionPathsInTree, mergeAnimatorConfig, getNormalizedBindings as normalizeDocument, parseWireVersion, progressToTimeMs, propAnimIsMotionPath, px, readWireVersion, resolveControlMode, resolveTrigger, schemaKeys, shiftAnimatable, timeToProgress, toRGBA, validateDocument, validateNodeEffects, versionAdvice, visualModelAt } from '@pixodesk/svg-animator-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* DOM
|
|
5
|
+
* DOM specializations of the platform-neutral animator API types.
|
|
6
6
|
* `getRootElement()` returns a DOM `Element` on the web — these aliases keep
|
|
7
7
|
* the historical (pre-core-extraction) signatures for web consumers.
|
|
8
8
|
*/
|
|
@@ -12,72 +12,44 @@ type PxAnimatorAPI = PxAnimatorAPI$1<Element>;
|
|
|
12
12
|
/**
|
|
13
13
|
* Wire keys shared by every entry point.
|
|
14
14
|
*
|
|
15
|
-
* These live here rather than in `PxAnimator.ts` on purpose: that module
|
|
16
|
-
* top-level `if (typeof window !== 'undefined')` block
|
|
15
|
+
* These live here rather than in `PxAnimator.ts` on purpose: that module used to end with a
|
|
16
|
+
* top-level `if (typeof window !== 'undefined')` block publishing `createAnimator` /
|
|
17
17
|
* `loadTagAnimators` as globals. A module-level side effect cannot be tree-shaken, so
|
|
18
|
-
* importing ANY symbol from `PxAnimator.ts`
|
|
18
|
+
* importing ANY symbol from `PxAnimator.ts` pulled the entire full player in with it —
|
|
19
19
|
* which silently made the pre-rendered builds the same size as the full one until this
|
|
20
20
|
* constant was moved out. See PRERENDERED-PLAYER-BUILDS.md.
|
|
21
|
+
*
|
|
22
|
+
* That block is gone (API review §4) and the package now declares `"sideEffects": false`, but
|
|
23
|
+
* keeping these here costs nothing and removes the trap for good.
|
|
21
24
|
*/
|
|
22
|
-
/** Key under which `createAnimator` options carry an inline animation document. */
|
|
23
|
-
declare const PX_ANIMATOR_DATA_KEY = "data";
|
|
24
|
-
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* chooses the best animation engine available ('waapi' or 'frames') or can be
|
|
30
|
-
* forced to use a specific one.
|
|
31
|
-
*
|
|
32
|
-
* @param doc The animated SVG document.
|
|
33
|
-
* @param callbacks Optional object with callback functions for animation lifecycle events (play, pause, finish, etc.).
|
|
34
|
-
* @param containerElement Optional selector or element to render the SVG into.
|
|
35
|
-
* @returns An PxAnimatorAPI instance to programmatically control the animation.
|
|
26
|
+
* Key under which `createAnimator` options carry the inline animation document. The editor
|
|
27
|
+
* writes it into every exported SVG+JS — `createAnimator({"doc": …})` — so it is part of the
|
|
28
|
+
* export format, which is why it is a named constant and not a literal.
|
|
36
29
|
*/
|
|
37
|
-
declare
|
|
30
|
+
declare const PX_ANIMATOR_DOC_KEY = "doc";
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Everything `createAnimator` takes. The playback override (`timeline`, `resetTimeline` and the
|
|
34
|
+
* four shortcuts) and the callbacks are core's shared shapes — the SAME names, inline, as the
|
|
35
|
+
* React, Vue and React Native components take (review §9) — so only what is web-specific is
|
|
36
|
+
* declared here.
|
|
37
|
+
*/
|
|
38
|
+
interface PxAnimatorOptions extends PxPlaybackOverrideProps, PxComponentCallbacks {
|
|
39
|
+
/** URL to fetch the animation document from. Provide either this or `doc`, not both. */
|
|
41
40
|
src?: string;
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
/**
|
|
41
|
+
/** The animation document, inline (see SCHEMA.md). Provide either this or `src`, not both. */
|
|
42
|
+
doc?: PxAnimatedSvgDocument;
|
|
43
|
+
/** ○ A custom render target for the frame-loop engine (`PxPlatformAdapter`); omit for the DOM. */
|
|
45
44
|
adapter?: PxPlatformAdapter;
|
|
46
|
-
/** Callback functions for animation lifecycle events. */
|
|
47
|
-
callbacks?: PxAnimatorCallbacksConfig;
|
|
48
45
|
/** CSS selector or element to render the SVG into. */
|
|
49
46
|
container?: string | Element;
|
|
50
|
-
/**
|
|
51
|
-
* Per-instance override of the document's `animator` config — the same shape as
|
|
52
|
-
* `animator` in SCHEMA.md, deep-merged over what the document says, so one file can play
|
|
53
|
-
* twice on a page with different timing. `null` at any slot DELETES that key, which is
|
|
54
|
-
* how you restore a default that absence means.
|
|
55
|
-
*
|
|
56
|
-
* Also accepts a JSON STRING of the same object. Strings are immune to property mangling,
|
|
57
|
-
* so that form survives a build that renames object keys (see docs/library/minification.md).
|
|
58
|
-
*/
|
|
59
|
-
config?: PxAnimatorConfigPatch | string;
|
|
60
|
-
/**
|
|
61
|
-
* Ignore the document's own playback settings and start from the player's defaults, with
|
|
62
|
-
* `config` applied on top. The lookup tables (`definitions`, `animateById`) are kept
|
|
63
|
-
* either way — resetting those would leave the animation with nothing to animate.
|
|
64
|
-
*/
|
|
65
|
-
resetDocDefaults?: boolean;
|
|
66
|
-
/** Shortcut for `config.timeline.duration` (ms). Wins over the same key inside `config`. */
|
|
67
|
-
duration?: number;
|
|
68
|
-
/** Shortcut for `config.timeline.delay` (ms). */
|
|
69
|
-
delay?: number;
|
|
70
|
-
/** Shortcut for `config.timeline.iterations`. */
|
|
71
|
-
iterations?: number | 'infinite';
|
|
72
|
-
/** Shortcut for `config.timeline.trigger.startOn`. Typed from the WIRE, so it includes
|
|
73
|
-
* `'programmatic'` — the value that says "nothing starts this but a `play()` call". */
|
|
74
|
-
startOn?: PxTrigger['startOn'];
|
|
75
47
|
}
|
|
76
48
|
/**
|
|
77
49
|
* Creates an animator instance to control SVG animations.
|
|
78
50
|
*
|
|
79
51
|
* @param options.src URL to fetch the animation document from.
|
|
80
|
-
* @param options.
|
|
52
|
+
* @param options.doc The animation document, inline.
|
|
81
53
|
* @param options.container CSS selector or element to render the SVG into.
|
|
82
54
|
* @returns A PxAnimatorAPI instance to programmatically control the animation.
|
|
83
55
|
*/
|
|
@@ -86,7 +58,36 @@ declare function createAnimator(options: PxAnimatorOptions): PxAnimatorAPI;
|
|
|
86
58
|
* Scan and load for tags, e.g.
|
|
87
59
|
* <div data-px-animation-src="animation.json"></div>
|
|
88
60
|
*/
|
|
89
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Everything `createAnimator` takes except the three the tag supplies (`src`, `container`) or
|
|
63
|
+
* forbids (`data`): callbacks, the diagnostics channel, a playback override and its shortcuts.
|
|
64
|
+
*/
|
|
65
|
+
type PxTagAnimatorOptions = Omit<PxAnimatorOptions, 'src' | 'doc' | 'container'>;
|
|
66
|
+
/**
|
|
67
|
+
* Scan the page for `<div data-px-animation-src="animation.json">` and create one player per
|
|
68
|
+
* match, rendered into that element and stored on it. Safe to call repeatedly: elements that
|
|
69
|
+
* already carry a player are skipped.
|
|
70
|
+
*
|
|
71
|
+
* `options` applies to EVERY player this call creates (review §15) — the same callbacks, the
|
|
72
|
+
* same override. Omit it for the zero-config path.
|
|
73
|
+
*/
|
|
74
|
+
declare function loadTagAnimators(options?: PxTagAnimatorOptions): void;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Options accepted by the pre-rendered entry points — a subset of `PxAnimatorOptions`: the
|
|
78
|
+
* document, an optional adapter, and the callbacks INLINE under the same names every surface
|
|
79
|
+
* uses (review §9).
|
|
80
|
+
*/
|
|
81
|
+
interface PxPrerenderedOptions extends PxComponentCallbacks {
|
|
82
|
+
/**
|
|
83
|
+
* The animation document. For a pre-rendered SVG this carries `animator.definitions`
|
|
84
|
+
* and `animator.animateById` only — no `children`, because the elements are already
|
|
85
|
+
* in the DOM.
|
|
86
|
+
*/
|
|
87
|
+
doc: PxAnimatedSvgDocument;
|
|
88
|
+
/** ○ A custom render target for the frame-loop engine; omit for the DOM. */
|
|
89
|
+
adapter?: PxPlatformAdapter;
|
|
90
|
+
}
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
93
|
* Sets up event-based triggers for an animation.
|
|
@@ -96,7 +97,7 @@ declare function loadTagAnimators(): void;
|
|
|
96
97
|
* or visibility changes.
|
|
97
98
|
*
|
|
98
99
|
* ### Trigger Options (startOn):
|
|
99
|
-
* - 'load': Starts after the page loads.
|
|
100
|
+
* - 'load' (default): Starts after the page loads.
|
|
100
101
|
* - 'mouseOver': Starts on mouse enter.
|
|
101
102
|
* - 'click': Toggles play/end action on click.
|
|
102
103
|
* - 'scrollIntoView': Starts when the element scrolls into the viewport.
|
|
@@ -104,21 +105,25 @@ declare function loadTagAnimators(): void;
|
|
|
104
105
|
*
|
|
105
106
|
* ### End Action Options (outAction):
|
|
106
107
|
* Defines behavior when the trigger condition ends (e.g., mouse leave).
|
|
107
|
-
* - 'continue': Animation continues playing.
|
|
108
|
+
* - 'continue' (default): Animation continues playing.
|
|
108
109
|
* - 'pause': Pauses the animation.
|
|
109
110
|
* - 'reset': Cancels the animation, resetting it to the start.
|
|
110
111
|
* - 'reverse': Reverses the animation playback.
|
|
111
112
|
*
|
|
112
113
|
* @param {!PxAnimatorAPI} api The animator API instance to control.
|
|
113
|
-
* @param {!PxTrigger} config The trigger configuration object.
|
|
114
|
-
*
|
|
114
|
+
* @param {!PxTrigger} config The trigger configuration object. Only `startOn`, `outAction` and
|
|
115
|
+
* `scrollIntoViewThreshold` are read here; `finishAction` belongs to the PLAYER (what happens
|
|
116
|
+
* after a natural end), not to the trigger wiring.
|
|
117
|
+
* @returns A disposer that detaches every listener and observer this call attached (review §14).
|
|
118
|
+
* `createAnimator` ties it to `destroy()`. Call it yourself before re-arming an element you
|
|
119
|
+
* wired by hand — otherwise the old listeners stay live next to the new ones.
|
|
115
120
|
*/
|
|
116
|
-
declare function setupAnimationTriggers(api: PxAnimatorAPI, config: PxTrigger):
|
|
121
|
+
declare function setupAnimationTriggers(api: PxAnimatorAPI, config: PxTrigger, diag?: PxDiagnostics): () => void;
|
|
117
122
|
|
|
118
123
|
/**
|
|
119
124
|
* Renders a PxNode tree to DOM elements.
|
|
120
125
|
*/
|
|
121
|
-
declare function renderNode(node: PxNode, defs?: PxDefs): Element | null;
|
|
126
|
+
declare function renderNode(node: PxNode, defs?: PxDefs, diag?: PxDiagnostics): Element | null;
|
|
122
127
|
|
|
123
128
|
/**
|
|
124
129
|
* Creates an animator instance that uses a requestAnimationFrame loop for animations.
|
|
@@ -151,4 +156,4 @@ interface PxWebApiScrollTimeline {
|
|
|
151
156
|
}
|
|
152
157
|
declare function createWebApiAnimator(doc: PxAnimatedSvgDocument, callbacks?: PxAnimatorCallbacksConfig, rootElement?: Element | null, forceEvenIfHasUnsupportedAttrs?: boolean, scrollTimeline?: PxWebApiScrollTimeline): PxAnimatorAPI | null;
|
|
153
158
|
|
|
154
|
-
export {
|
|
159
|
+
export { PX_ANIMATOR_DOC_KEY, type PxAnimatorAPI, type PxAnimatorOptions, type PxBasicAnimatorAPI, type PxPrerenderedOptions, type PxTagAnimatorOptions, createAnimator, createFrameLoopAnimator, createWebApiAnimator, loadTagAnimators, renderNode, setupAnimationTriggers };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PxAnimatorAPI as PxAnimatorAPI$1, PxBasicAnimatorAPI as PxBasicAnimatorAPI$1,
|
|
2
|
-
export { ApplyResult,
|
|
1
|
+
import { PxAnimatorAPI as PxAnimatorAPI$1, PxBasicAnimatorAPI as PxBasicAnimatorAPI$1, PxPlaybackOverrideProps, PxComponentCallbacks, PxAnimatedSvgDocument, PxPlatformAdapter, PxTrigger, PxDiagnostics, PxNode, PxDefs, PxAnimatorCallbacksConfig } from '@pixodesk/svg-animator-core';
|
|
2
|
+
export { ApplyResult, BASELINE_PLAYER_VERSION, COLOR_ATTR_NAMES, DEFAULT_DURATION_MS, ExtendPathOpts, ExtendedPath, GlyphCharBox, GlyphCharBoxAlongPath, GlyphMaterializeOpts, KeysMatch, MISSING_GLYPH_CLASS_NAME, MaterializeAllOptions, MotionPathMaterializationOptions, MotionPathSample, PLAYER_WIRE_STEPS, PLAYER_WIRE_VERSION, PX_ANIM_ATTR_NAME, PX_ANIM_SRC_ATTR_NAME, PX_PLAYER_SCHEMA_VERSION, PX_TRANSFORM_PART_KEYS, PX_TRIGGER_DEFAULTS, PathPoint, PathSampler, PlayerConversionResult, PxAlongPathMode, PxAnimatable, PxAnimatedSvgDocument, PxAnimatedSvgDocumentSchema, PxAnimationDefinition, PxAnimationDefinitionSchema, PxAnimatorCallbacksConfig, PxAnimatorConfig, PxAnimatorConfigMergeResult, PxAnimatorConfigPatch, PxAnimatorConfigSchema, PxAnimatorConfigShortcuts, PxAnimatorHandle, PxAnyKeyframe, PxAttrValue, PxAttrValueSchema, PxBezierPath, PxBezierPathSchema, PxBinding, PxBindingSchema, PxClipPathEffectSchema, PxCloneEffect, PxCloneEffectSchema, PxCloneWithout, PxComponentCallbacks, PxControlMode, PxControlProps, PxCreateElement, PxDefs, PxDefsSchema, PxDiagnostic, PxDiagnosticKind, PxDiagnostics, PxDiagnosticsConfig, PxDocumentDiagnosis, PxEasingOrRefSchema, PxEffects, PxEffectsSchema, PxElementAnimation, PxElementAnimationSchema, PxFillGradientEffect, PxFillGradientEffectSchema, PxFillMode, PxFinishAction, PxGlyph, PxGlyphFont, PxGradientSpreadMethod, PxGradientStop, PxGradientStopSchema, PxGradientType, PxInfer, PxKeyframe, PxKeyframeSchema, PxKeyframeValueSchema, PxLengthAdjust, PxLoop, PxLoopDirection, PxLoopRepeatAt, PxLoopSchema, PxMaskType, PxMaskedByEffect, PxMaskedByEffectSchema, PxNode, PxNodeBase, PxNodeSchema, PxNormalizedKeyframe, PxOutAction, PxPathOverflow, PxPinAlign, PxPlatformAdapter, PxPlaybackDirection, PxPlaybackOverrideProps, PxPropertyAnimation, PxPropertyAnimationSchema, PxRepeaterEffect, PxRepeaterEffectSchema, PxResolvedControlMode, PxRetimeEffect, PxRetimeEffectSchema, PxSchema, PxSchemaDesc, PxScrollAxis, PxScrollKind, PxScrollPhase, PxScrollRangePointSchema, PxScrollRangeSchema, PxScrollSchema, PxScrollSource, PxStartOn, PxStrokeGradientEffect, PxStrokeGradientEffectSchema, PxStrokeTrimEffect, PxStrokeTrimEffectSchema, PxStrokeTrimSubPaths, PxSvgNode, PxSvgNodeExtra, PxTextEffectSchema, PxTextPathEffect, PxTextPathEffectSchema, PxTextPathMethod, PxTextPathSpacing, PxTimelineEngine, PxTimelineEngineExtra, PxTimelinePatch, PxTimelinePinSchema, PxTimelineSchema, PxTransformByEffect, PxTransformByEffectSchema, PxTransformPartKey, PxTransformParts, PxTransformPartsSchema, PxTransformValue, PxTransformValueSchema, PxTrigger, PxTriggerSchema, PxUnits, PxValidationContext, PxValidationResult, RemoveIndex, STYLE_ATTR_NAMES, TRANSFORM_FN_NAMES, Vec2, WIRE_VERSION_KEY, WireConversionConfig, WireDowngradeConfig, WireDowngradeResult, WireStepKind, WireVersion, WireVersionRelation, WireVersionStep, applyAnimatorConfig, applyPlayerEffects, calcAnimationValues, camelCaseToKebabWordIfNeeded, collectSampleTimes, compareWireVersion, controlModeTakesOverTrigger, convertPlayerDocument, createBasicFrameLoopAnimator, createDiagnostics, createPathSampler, describeSchema, diagnoseDocument, diffInEffect, downgradePlayerDocument, evaluateMotionPathSegment, extendedPathForBrowser, foldTimelineOverride, formatWireVersion, generateNewIds, getAnimatorConfig, getBindings, getChildren, getDefs, getNormalizedProps, isPxElementFileFormat, isPxElementFileFormatDeep, jsonElementFactory, layoutGlyphTextChars, materializeAllInTree, materializeAnimatedUseInstances, materializeGlyphText, materializeGlyphTextAlongPath, materializeGlyphTextHorizontal, materializeInternalLoopsInPropAnim, materializeInternalLoopsInTree, materializeMotionPathInPropAnim, materializeMotionPathsInTree, mergeAnimatorConfig, getNormalizedBindings as normalizeDocument, parseWireVersion, progressToTimeMs, propAnimIsMotionPath, px, readWireVersion, resolveControlMode, resolveTrigger, schemaKeys, shiftAnimatable, timeToProgress, toRGBA, validateDocument, validateNodeEffects, versionAdvice, visualModelAt } from '@pixodesk/svg-animator-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* DOM
|
|
5
|
+
* DOM specializations of the platform-neutral animator API types.
|
|
6
6
|
* `getRootElement()` returns a DOM `Element` on the web — these aliases keep
|
|
7
7
|
* the historical (pre-core-extraction) signatures for web consumers.
|
|
8
8
|
*/
|
|
@@ -12,72 +12,44 @@ type PxAnimatorAPI = PxAnimatorAPI$1<Element>;
|
|
|
12
12
|
/**
|
|
13
13
|
* Wire keys shared by every entry point.
|
|
14
14
|
*
|
|
15
|
-
* These live here rather than in `PxAnimator.ts` on purpose: that module
|
|
16
|
-
* top-level `if (typeof window !== 'undefined')` block
|
|
15
|
+
* These live here rather than in `PxAnimator.ts` on purpose: that module used to end with a
|
|
16
|
+
* top-level `if (typeof window !== 'undefined')` block publishing `createAnimator` /
|
|
17
17
|
* `loadTagAnimators` as globals. A module-level side effect cannot be tree-shaken, so
|
|
18
|
-
* importing ANY symbol from `PxAnimator.ts`
|
|
18
|
+
* importing ANY symbol from `PxAnimator.ts` pulled the entire full player in with it —
|
|
19
19
|
* which silently made the pre-rendered builds the same size as the full one until this
|
|
20
20
|
* constant was moved out. See PRERENDERED-PLAYER-BUILDS.md.
|
|
21
|
+
*
|
|
22
|
+
* That block is gone (API review §4) and the package now declares `"sideEffects": false`, but
|
|
23
|
+
* keeping these here costs nothing and removes the trap for good.
|
|
21
24
|
*/
|
|
22
|
-
/** Key under which `createAnimator` options carry an inline animation document. */
|
|
23
|
-
declare const PX_ANIMATOR_DATA_KEY = "data";
|
|
24
|
-
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* chooses the best animation engine available ('waapi' or 'frames') or can be
|
|
30
|
-
* forced to use a specific one.
|
|
31
|
-
*
|
|
32
|
-
* @param doc The animated SVG document.
|
|
33
|
-
* @param callbacks Optional object with callback functions for animation lifecycle events (play, pause, finish, etc.).
|
|
34
|
-
* @param containerElement Optional selector or element to render the SVG into.
|
|
35
|
-
* @returns An PxAnimatorAPI instance to programmatically control the animation.
|
|
26
|
+
* Key under which `createAnimator` options carry the inline animation document. The editor
|
|
27
|
+
* writes it into every exported SVG+JS — `createAnimator({"doc": …})` — so it is part of the
|
|
28
|
+
* export format, which is why it is a named constant and not a literal.
|
|
36
29
|
*/
|
|
37
|
-
declare
|
|
30
|
+
declare const PX_ANIMATOR_DOC_KEY = "doc";
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Everything `createAnimator` takes. The playback override (`timeline`, `resetTimeline` and the
|
|
34
|
+
* four shortcuts) and the callbacks are core's shared shapes — the SAME names, inline, as the
|
|
35
|
+
* React, Vue and React Native components take (review §9) — so only what is web-specific is
|
|
36
|
+
* declared here.
|
|
37
|
+
*/
|
|
38
|
+
interface PxAnimatorOptions extends PxPlaybackOverrideProps, PxComponentCallbacks {
|
|
39
|
+
/** URL to fetch the animation document from. Provide either this or `doc`, not both. */
|
|
41
40
|
src?: string;
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
/**
|
|
41
|
+
/** The animation document, inline (see SCHEMA.md). Provide either this or `src`, not both. */
|
|
42
|
+
doc?: PxAnimatedSvgDocument;
|
|
43
|
+
/** ○ A custom render target for the frame-loop engine (`PxPlatformAdapter`); omit for the DOM. */
|
|
45
44
|
adapter?: PxPlatformAdapter;
|
|
46
|
-
/** Callback functions for animation lifecycle events. */
|
|
47
|
-
callbacks?: PxAnimatorCallbacksConfig;
|
|
48
45
|
/** CSS selector or element to render the SVG into. */
|
|
49
46
|
container?: string | Element;
|
|
50
|
-
/**
|
|
51
|
-
* Per-instance override of the document's `animator` config — the same shape as
|
|
52
|
-
* `animator` in SCHEMA.md, deep-merged over what the document says, so one file can play
|
|
53
|
-
* twice on a page with different timing. `null` at any slot DELETES that key, which is
|
|
54
|
-
* how you restore a default that absence means.
|
|
55
|
-
*
|
|
56
|
-
* Also accepts a JSON STRING of the same object. Strings are immune to property mangling,
|
|
57
|
-
* so that form survives a build that renames object keys (see docs/library/minification.md).
|
|
58
|
-
*/
|
|
59
|
-
config?: PxAnimatorConfigPatch | string;
|
|
60
|
-
/**
|
|
61
|
-
* Ignore the document's own playback settings and start from the player's defaults, with
|
|
62
|
-
* `config` applied on top. The lookup tables (`definitions`, `animateById`) are kept
|
|
63
|
-
* either way — resetting those would leave the animation with nothing to animate.
|
|
64
|
-
*/
|
|
65
|
-
resetDocDefaults?: boolean;
|
|
66
|
-
/** Shortcut for `config.timeline.duration` (ms). Wins over the same key inside `config`. */
|
|
67
|
-
duration?: number;
|
|
68
|
-
/** Shortcut for `config.timeline.delay` (ms). */
|
|
69
|
-
delay?: number;
|
|
70
|
-
/** Shortcut for `config.timeline.iterations`. */
|
|
71
|
-
iterations?: number | 'infinite';
|
|
72
|
-
/** Shortcut for `config.timeline.trigger.startOn`. Typed from the WIRE, so it includes
|
|
73
|
-
* `'programmatic'` — the value that says "nothing starts this but a `play()` call". */
|
|
74
|
-
startOn?: PxTrigger['startOn'];
|
|
75
47
|
}
|
|
76
48
|
/**
|
|
77
49
|
* Creates an animator instance to control SVG animations.
|
|
78
50
|
*
|
|
79
51
|
* @param options.src URL to fetch the animation document from.
|
|
80
|
-
* @param options.
|
|
52
|
+
* @param options.doc The animation document, inline.
|
|
81
53
|
* @param options.container CSS selector or element to render the SVG into.
|
|
82
54
|
* @returns A PxAnimatorAPI instance to programmatically control the animation.
|
|
83
55
|
*/
|
|
@@ -86,7 +58,36 @@ declare function createAnimator(options: PxAnimatorOptions): PxAnimatorAPI;
|
|
|
86
58
|
* Scan and load for tags, e.g.
|
|
87
59
|
* <div data-px-animation-src="animation.json"></div>
|
|
88
60
|
*/
|
|
89
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Everything `createAnimator` takes except the three the tag supplies (`src`, `container`) or
|
|
63
|
+
* forbids (`data`): callbacks, the diagnostics channel, a playback override and its shortcuts.
|
|
64
|
+
*/
|
|
65
|
+
type PxTagAnimatorOptions = Omit<PxAnimatorOptions, 'src' | 'doc' | 'container'>;
|
|
66
|
+
/**
|
|
67
|
+
* Scan the page for `<div data-px-animation-src="animation.json">` and create one player per
|
|
68
|
+
* match, rendered into that element and stored on it. Safe to call repeatedly: elements that
|
|
69
|
+
* already carry a player are skipped.
|
|
70
|
+
*
|
|
71
|
+
* `options` applies to EVERY player this call creates (review §15) — the same callbacks, the
|
|
72
|
+
* same override. Omit it for the zero-config path.
|
|
73
|
+
*/
|
|
74
|
+
declare function loadTagAnimators(options?: PxTagAnimatorOptions): void;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Options accepted by the pre-rendered entry points — a subset of `PxAnimatorOptions`: the
|
|
78
|
+
* document, an optional adapter, and the callbacks INLINE under the same names every surface
|
|
79
|
+
* uses (review §9).
|
|
80
|
+
*/
|
|
81
|
+
interface PxPrerenderedOptions extends PxComponentCallbacks {
|
|
82
|
+
/**
|
|
83
|
+
* The animation document. For a pre-rendered SVG this carries `animator.definitions`
|
|
84
|
+
* and `animator.animateById` only — no `children`, because the elements are already
|
|
85
|
+
* in the DOM.
|
|
86
|
+
*/
|
|
87
|
+
doc: PxAnimatedSvgDocument;
|
|
88
|
+
/** ○ A custom render target for the frame-loop engine; omit for the DOM. */
|
|
89
|
+
adapter?: PxPlatformAdapter;
|
|
90
|
+
}
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
93
|
* Sets up event-based triggers for an animation.
|
|
@@ -96,7 +97,7 @@ declare function loadTagAnimators(): void;
|
|
|
96
97
|
* or visibility changes.
|
|
97
98
|
*
|
|
98
99
|
* ### Trigger Options (startOn):
|
|
99
|
-
* - 'load': Starts after the page loads.
|
|
100
|
+
* - 'load' (default): Starts after the page loads.
|
|
100
101
|
* - 'mouseOver': Starts on mouse enter.
|
|
101
102
|
* - 'click': Toggles play/end action on click.
|
|
102
103
|
* - 'scrollIntoView': Starts when the element scrolls into the viewport.
|
|
@@ -104,21 +105,25 @@ declare function loadTagAnimators(): void;
|
|
|
104
105
|
*
|
|
105
106
|
* ### End Action Options (outAction):
|
|
106
107
|
* Defines behavior when the trigger condition ends (e.g., mouse leave).
|
|
107
|
-
* - 'continue': Animation continues playing.
|
|
108
|
+
* - 'continue' (default): Animation continues playing.
|
|
108
109
|
* - 'pause': Pauses the animation.
|
|
109
110
|
* - 'reset': Cancels the animation, resetting it to the start.
|
|
110
111
|
* - 'reverse': Reverses the animation playback.
|
|
111
112
|
*
|
|
112
113
|
* @param {!PxAnimatorAPI} api The animator API instance to control.
|
|
113
|
-
* @param {!PxTrigger} config The trigger configuration object.
|
|
114
|
-
*
|
|
114
|
+
* @param {!PxTrigger} config The trigger configuration object. Only `startOn`, `outAction` and
|
|
115
|
+
* `scrollIntoViewThreshold` are read here; `finishAction` belongs to the PLAYER (what happens
|
|
116
|
+
* after a natural end), not to the trigger wiring.
|
|
117
|
+
* @returns A disposer that detaches every listener and observer this call attached (review §14).
|
|
118
|
+
* `createAnimator` ties it to `destroy()`. Call it yourself before re-arming an element you
|
|
119
|
+
* wired by hand — otherwise the old listeners stay live next to the new ones.
|
|
115
120
|
*/
|
|
116
|
-
declare function setupAnimationTriggers(api: PxAnimatorAPI, config: PxTrigger):
|
|
121
|
+
declare function setupAnimationTriggers(api: PxAnimatorAPI, config: PxTrigger, diag?: PxDiagnostics): () => void;
|
|
117
122
|
|
|
118
123
|
/**
|
|
119
124
|
* Renders a PxNode tree to DOM elements.
|
|
120
125
|
*/
|
|
121
|
-
declare function renderNode(node: PxNode, defs?: PxDefs): Element | null;
|
|
126
|
+
declare function renderNode(node: PxNode, defs?: PxDefs, diag?: PxDiagnostics): Element | null;
|
|
122
127
|
|
|
123
128
|
/**
|
|
124
129
|
* Creates an animator instance that uses a requestAnimationFrame loop for animations.
|
|
@@ -151,4 +156,4 @@ interface PxWebApiScrollTimeline {
|
|
|
151
156
|
}
|
|
152
157
|
declare function createWebApiAnimator(doc: PxAnimatedSvgDocument, callbacks?: PxAnimatorCallbacksConfig, rootElement?: Element | null, forceEvenIfHasUnsupportedAttrs?: boolean, scrollTimeline?: PxWebApiScrollTimeline): PxAnimatorAPI | null;
|
|
153
158
|
|
|
154
|
-
export {
|
|
159
|
+
export { PX_ANIMATOR_DOC_KEY, type PxAnimatorAPI, type PxAnimatorOptions, type PxBasicAnimatorAPI, type PxPrerenderedOptions, type PxTagAnimatorOptions, createAnimator, createFrameLoopAnimator, createWebApiAnimator, loadTagAnimators, renderNode, setupAnimationTriggers };
|