@pixodesk/svg-animator-web 1.0.34 → 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 +41 -21
- package/dist/index.cjs +1538 -679
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -37
- package/dist/index.d.ts +67 -37
- package/dist/index.js +1473 -664
- 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 +1278 -126
- 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 +1343 -172
- 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 +1212 -637
- package/dist/pixodesk-svg-animator.umd.js.map +1 -1
- package/dist/pixodesk-svg-animator.umd.min.js +1 -1
- package/mangle-reserved.json +244 -0
- package/package.json +8 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PxAnimatorAPI as PxAnimatorAPI$1, PxBasicAnimatorAPI as PxBasicAnimatorAPI$1, PxAnimatedSvgDocument, PxPlatformAdapter,
|
|
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,39 +12,36 @@ 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
47
|
}
|
|
@@ -52,7 +49,7 @@ interface PxAnimatorOptions {
|
|
|
52
49
|
* Creates an animator instance to control SVG animations.
|
|
53
50
|
*
|
|
54
51
|
* @param options.src URL to fetch the animation document from.
|
|
55
|
-
* @param options.
|
|
52
|
+
* @param options.doc The animation document, inline.
|
|
56
53
|
* @param options.container CSS selector or element to render the SVG into.
|
|
57
54
|
* @returns A PxAnimatorAPI instance to programmatically control the animation.
|
|
58
55
|
*/
|
|
@@ -61,7 +58,36 @@ declare function createAnimator(options: PxAnimatorOptions): PxAnimatorAPI;
|
|
|
61
58
|
* Scan and load for tags, e.g.
|
|
62
59
|
* <div data-px-animation-src="animation.json"></div>
|
|
63
60
|
*/
|
|
64
|
-
|
|
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
|
+
}
|
|
65
91
|
|
|
66
92
|
/**
|
|
67
93
|
* Sets up event-based triggers for an animation.
|
|
@@ -71,7 +97,7 @@ declare function loadTagAnimators(): void;
|
|
|
71
97
|
* or visibility changes.
|
|
72
98
|
*
|
|
73
99
|
* ### Trigger Options (startOn):
|
|
74
|
-
* - 'load': Starts after the page loads.
|
|
100
|
+
* - 'load' (default): Starts after the page loads.
|
|
75
101
|
* - 'mouseOver': Starts on mouse enter.
|
|
76
102
|
* - 'click': Toggles play/end action on click.
|
|
77
103
|
* - 'scrollIntoView': Starts when the element scrolls into the viewport.
|
|
@@ -79,21 +105,25 @@ declare function loadTagAnimators(): void;
|
|
|
79
105
|
*
|
|
80
106
|
* ### End Action Options (outAction):
|
|
81
107
|
* Defines behavior when the trigger condition ends (e.g., mouse leave).
|
|
82
|
-
* - 'continue': Animation continues playing.
|
|
108
|
+
* - 'continue' (default): Animation continues playing.
|
|
83
109
|
* - 'pause': Pauses the animation.
|
|
84
110
|
* - 'reset': Cancels the animation, resetting it to the start.
|
|
85
111
|
* - 'reverse': Reverses the animation playback.
|
|
86
112
|
*
|
|
87
113
|
* @param {!PxAnimatorAPI} api The animator API instance to control.
|
|
88
|
-
* @param {!PxTrigger} config The trigger configuration object.
|
|
89
|
-
*
|
|
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.
|
|
90
120
|
*/
|
|
91
|
-
declare function setupAnimationTriggers(api: PxAnimatorAPI, config: PxTrigger):
|
|
121
|
+
declare function setupAnimationTriggers(api: PxAnimatorAPI, config: PxTrigger, diag?: PxDiagnostics): () => void;
|
|
92
122
|
|
|
93
123
|
/**
|
|
94
124
|
* Renders a PxNode tree to DOM elements.
|
|
95
125
|
*/
|
|
96
|
-
declare function renderNode(node: PxNode, defs?: PxDefs): Element | null;
|
|
126
|
+
declare function renderNode(node: PxNode, defs?: PxDefs, diag?: PxDiagnostics): Element | null;
|
|
97
127
|
|
|
98
128
|
/**
|
|
99
129
|
* Creates an animator instance that uses a requestAnimationFrame loop for animations.
|
|
@@ -117,7 +147,7 @@ declare function createFrameLoopAnimator(doc: PxAnimatedSvgDocument, adapter?: P
|
|
|
117
147
|
* @param forceEvenIfHasUnsupportedAttrs If true, an animator will be created even if some CSS properties are not supported.
|
|
118
148
|
* @returns An PxAnimatorAPI instance, or null if unsupported features are used and not forced.
|
|
119
149
|
*/
|
|
120
|
-
/** `
|
|
150
|
+
/** Native scroll-timeline payload (`timeline.engine: 'native'` / `auto`; see PxScrollDriver.createNativeScrollTimeline): the
|
|
121
151
|
* browser-native timeline every Animation attaches to, plus optional range offsets. */
|
|
122
152
|
interface PxWebApiScrollTimeline {
|
|
123
153
|
timeline: AnimationTimeline;
|
|
@@ -126,4 +156,4 @@ interface PxWebApiScrollTimeline {
|
|
|
126
156
|
}
|
|
127
157
|
declare function createWebApiAnimator(doc: PxAnimatedSvgDocument, callbacks?: PxAnimatorCallbacksConfig, rootElement?: Element | null, forceEvenIfHasUnsupportedAttrs?: boolean, scrollTimeline?: PxWebApiScrollTimeline): PxAnimatorAPI | null;
|
|
128
158
|
|
|
129
|
-
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, PxAnimatedSvgDocument, PxPlatformAdapter,
|
|
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,39 +12,36 @@ 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
47
|
}
|
|
@@ -52,7 +49,7 @@ interface PxAnimatorOptions {
|
|
|
52
49
|
* Creates an animator instance to control SVG animations.
|
|
53
50
|
*
|
|
54
51
|
* @param options.src URL to fetch the animation document from.
|
|
55
|
-
* @param options.
|
|
52
|
+
* @param options.doc The animation document, inline.
|
|
56
53
|
* @param options.container CSS selector or element to render the SVG into.
|
|
57
54
|
* @returns A PxAnimatorAPI instance to programmatically control the animation.
|
|
58
55
|
*/
|
|
@@ -61,7 +58,36 @@ declare function createAnimator(options: PxAnimatorOptions): PxAnimatorAPI;
|
|
|
61
58
|
* Scan and load for tags, e.g.
|
|
62
59
|
* <div data-px-animation-src="animation.json"></div>
|
|
63
60
|
*/
|
|
64
|
-
|
|
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
|
+
}
|
|
65
91
|
|
|
66
92
|
/**
|
|
67
93
|
* Sets up event-based triggers for an animation.
|
|
@@ -71,7 +97,7 @@ declare function loadTagAnimators(): void;
|
|
|
71
97
|
* or visibility changes.
|
|
72
98
|
*
|
|
73
99
|
* ### Trigger Options (startOn):
|
|
74
|
-
* - 'load': Starts after the page loads.
|
|
100
|
+
* - 'load' (default): Starts after the page loads.
|
|
75
101
|
* - 'mouseOver': Starts on mouse enter.
|
|
76
102
|
* - 'click': Toggles play/end action on click.
|
|
77
103
|
* - 'scrollIntoView': Starts when the element scrolls into the viewport.
|
|
@@ -79,21 +105,25 @@ declare function loadTagAnimators(): void;
|
|
|
79
105
|
*
|
|
80
106
|
* ### End Action Options (outAction):
|
|
81
107
|
* Defines behavior when the trigger condition ends (e.g., mouse leave).
|
|
82
|
-
* - 'continue': Animation continues playing.
|
|
108
|
+
* - 'continue' (default): Animation continues playing.
|
|
83
109
|
* - 'pause': Pauses the animation.
|
|
84
110
|
* - 'reset': Cancels the animation, resetting it to the start.
|
|
85
111
|
* - 'reverse': Reverses the animation playback.
|
|
86
112
|
*
|
|
87
113
|
* @param {!PxAnimatorAPI} api The animator API instance to control.
|
|
88
|
-
* @param {!PxTrigger} config The trigger configuration object.
|
|
89
|
-
*
|
|
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.
|
|
90
120
|
*/
|
|
91
|
-
declare function setupAnimationTriggers(api: PxAnimatorAPI, config: PxTrigger):
|
|
121
|
+
declare function setupAnimationTriggers(api: PxAnimatorAPI, config: PxTrigger, diag?: PxDiagnostics): () => void;
|
|
92
122
|
|
|
93
123
|
/**
|
|
94
124
|
* Renders a PxNode tree to DOM elements.
|
|
95
125
|
*/
|
|
96
|
-
declare function renderNode(node: PxNode, defs?: PxDefs): Element | null;
|
|
126
|
+
declare function renderNode(node: PxNode, defs?: PxDefs, diag?: PxDiagnostics): Element | null;
|
|
97
127
|
|
|
98
128
|
/**
|
|
99
129
|
* Creates an animator instance that uses a requestAnimationFrame loop for animations.
|
|
@@ -117,7 +147,7 @@ declare function createFrameLoopAnimator(doc: PxAnimatedSvgDocument, adapter?: P
|
|
|
117
147
|
* @param forceEvenIfHasUnsupportedAttrs If true, an animator will be created even if some CSS properties are not supported.
|
|
118
148
|
* @returns An PxAnimatorAPI instance, or null if unsupported features are used and not forced.
|
|
119
149
|
*/
|
|
120
|
-
/** `
|
|
150
|
+
/** Native scroll-timeline payload (`timeline.engine: 'native'` / `auto`; see PxScrollDriver.createNativeScrollTimeline): the
|
|
121
151
|
* browser-native timeline every Animation attaches to, plus optional range offsets. */
|
|
122
152
|
interface PxWebApiScrollTimeline {
|
|
123
153
|
timeline: AnimationTimeline;
|
|
@@ -126,4 +156,4 @@ interface PxWebApiScrollTimeline {
|
|
|
126
156
|
}
|
|
127
157
|
declare function createWebApiAnimator(doc: PxAnimatedSvgDocument, callbacks?: PxAnimatorCallbacksConfig, rootElement?: Element | null, forceEvenIfHasUnsupportedAttrs?: boolean, scrollTimeline?: PxWebApiScrollTimeline): PxAnimatorAPI | null;
|
|
128
158
|
|
|
129
|
-
export {
|
|
159
|
+
export { PX_ANIMATOR_DOC_KEY, type PxAnimatorAPI, type PxAnimatorOptions, type PxBasicAnimatorAPI, type PxPrerenderedOptions, type PxTagAnimatorOptions, createAnimator, createFrameLoopAnimator, createWebApiAnimator, loadTagAnimators, renderNode, setupAnimationTriggers };
|