@pixodesk/svg-animator-web 1.0.44 → 1.0.45
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/{PxAnimator-yjuSFhQw.d.cts → PxAnimator-BS-SZULN.d.cts} +10 -0
- package/dist/{PxAnimator-yjuSFhQw.d.ts → PxAnimator-BS-SZULN.d.ts} +10 -0
- package/dist/{chunk-ZEMEZT7X.js → chunk-QE7KJWAN.js} +213 -149
- package/dist/chunk-QE7KJWAN.js.map +1 -0
- package/dist/chunk-RQ5KZXDT.min.js +1 -0
- package/dist/index.cjs +269 -201
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +60 -58
- 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 +32 -30
- package/dist/index.prerendered-waapi.umd.js.map +1 -1
- package/dist/index.prerendered.umd.js +34 -32
- package/dist/index.prerendered.umd.js.map +1 -1
- package/dist/index.prerendered.umd.min.js +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.min.cjs +1 -1
- package/dist/internal.min.js +1 -1
- package/dist/pixodesk-svg-animator.umd.js +177 -91
- package/dist/pixodesk-svg-animator.umd.js.map +1 -1
- package/dist/pixodesk-svg-animator.umd.min.js +1 -1
- package/mangle-reserved.json +6 -0
- package/package.json +2 -2
- package/dist/chunk-AROHP6GD.min.js +0 -1
- package/dist/chunk-ZEMEZT7X.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -20,18 +20,6 @@ var __spreadValues = (a, b) => {
|
|
|
20
20
|
return a;
|
|
21
21
|
};
|
|
22
22
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
-
var __objRest = (source, exclude) => {
|
|
24
|
-
var target = {};
|
|
25
|
-
for (var prop in source)
|
|
26
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
-
target[prop] = source[prop];
|
|
28
|
-
if (source != null && __getOwnPropSymbols)
|
|
29
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
-
target[prop] = source[prop];
|
|
32
|
-
}
|
|
33
|
-
return target;
|
|
34
|
-
};
|
|
35
23
|
var __export = (target, all) => {
|
|
36
24
|
for (var name in all)
|
|
37
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -71,7 +59,7 @@ __export(index_exports, {
|
|
|
71
59
|
});
|
|
72
60
|
module.exports = __toCommonJS(index_exports);
|
|
73
61
|
|
|
74
|
-
// ../svg-animator-core/dist/chunk-
|
|
62
|
+
// ../svg-animator-core/dist/chunk-YVKMPBHE.js
|
|
75
63
|
var __defProp2 = Object.defineProperty;
|
|
76
64
|
var __defProps2 = Object.defineProperties;
|
|
77
65
|
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
@@ -92,7 +80,7 @@ var __spreadValues2 = (a, b) => {
|
|
|
92
80
|
return a;
|
|
93
81
|
};
|
|
94
82
|
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
95
|
-
var
|
|
83
|
+
var __objRest = (source, exclude) => {
|
|
96
84
|
var target = {};
|
|
97
85
|
for (var prop in source)
|
|
98
86
|
if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
@@ -831,7 +819,7 @@ function flattenAnimatorTimeline(cfg) {
|
|
|
831
819
|
if (timeline === void 0 || timeline === null || typeof timeline !== "object") return cfg;
|
|
832
820
|
const memoised = flattenMemo.get(cfg);
|
|
833
821
|
if (memoised) return memoised;
|
|
834
|
-
const _a2 = cfg, { timeline: _dropped } = _a2, flat =
|
|
822
|
+
const _a2 = cfg, { timeline: _dropped } = _a2, flat = __objRest(_a2, ["timeline"]);
|
|
835
823
|
if (timeline.engine !== void 0) flat.engine = timeline.engine;
|
|
836
824
|
if (timeline.frameRate !== void 0) flat.frameRate = timeline.frameRate;
|
|
837
825
|
if (timeline.type === "scroll" || timeline.type === "view") {
|
|
@@ -857,7 +845,7 @@ function flattenAnimatorTimeline(cfg) {
|
|
|
857
845
|
} else {
|
|
858
846
|
if (timeline.duration !== void 0) flat.duration = timeline.duration;
|
|
859
847
|
if (timeline.trigger !== void 0) {
|
|
860
|
-
const _b = timeline.trigger, { finish } = _b, restTrigger =
|
|
848
|
+
const _b = timeline.trigger, { finish } = _b, restTrigger = __objRest(_b, ["finish"]);
|
|
861
849
|
if (Object.keys(restTrigger).length) flat.trigger = restTrigger;
|
|
862
850
|
if (finish !== void 0) flat.resetOnFinish = finish === "reset";
|
|
863
851
|
}
|
|
@@ -1988,6 +1976,36 @@ function toDomProps(props) {
|
|
|
1988
1976
|
}
|
|
1989
1977
|
return propsCopy;
|
|
1990
1978
|
}
|
|
1979
|
+
function mergeStaticTransformIntoAnimDef(animDef, staticTransform) {
|
|
1980
|
+
if (!animDef) return animDef;
|
|
1981
|
+
const staticParts = staticTransform && typeof staticTransform === "object" && !Array.isArray(staticTransform) ? staticTransform : parseTransformParts(staticTransform);
|
|
1982
|
+
if (!staticParts || !Object.keys(staticParts).length) return animDef;
|
|
1983
|
+
const mergeKfValue = (v) => v && typeof v === "object" && !Array.isArray(v) ? __spreadValues2(__spreadValues2({}, staticParts), v) : v;
|
|
1984
|
+
const transformAnim = animDef[TRANSFORM_ATTR];
|
|
1985
|
+
if (transformAnim && typeof transformAnim === "object") {
|
|
1986
|
+
const anim = transformAnim;
|
|
1987
|
+
if (Array.isArray(anim.keyframes)) {
|
|
1988
|
+
const out = __spreadProps2(__spreadValues2({}, anim), {
|
|
1989
|
+
keyframes: anim.keyframes.map((kf) => __spreadProps2(__spreadValues2({}, kf), { value: mergeKfValue(kf.value) }))
|
|
1990
|
+
});
|
|
1991
|
+
if (out.value !== void 0) out.value = mergeKfValue(out.value);
|
|
1992
|
+
return __spreadProps2(__spreadValues2({}, animDef), { transform: out });
|
|
1993
|
+
}
|
|
1994
|
+
return animDef;
|
|
1995
|
+
}
|
|
1996
|
+
const channels = Object.keys(animDef).filter((k) => PX_TRANSFORM_FN_NAMES.has(k));
|
|
1997
|
+
if (channels.length !== 1) return animDef;
|
|
1998
|
+
const ch = channels[0];
|
|
1999
|
+
const chAnim = animDef[ch];
|
|
2000
|
+
if (!chAnim || typeof chAnim !== "object" || !Array.isArray(chAnim.keyframes)) return animDef;
|
|
2001
|
+
const lifted = __spreadProps2(__spreadValues2({}, chAnim), {
|
|
2002
|
+
keyframes: chAnim.keyframes.map((kf) => __spreadProps2(__spreadValues2({}, kf), { value: __spreadProps2(__spreadValues2({}, staticParts), { [ch]: kf.value }) }))
|
|
2003
|
+
});
|
|
2004
|
+
if (lifted.value !== void 0) lifted.value = __spreadProps2(__spreadValues2({}, staticParts), { [ch]: lifted.value });
|
|
2005
|
+
const rest = __spreadValues2({}, animDef);
|
|
2006
|
+
delete rest[ch];
|
|
2007
|
+
return __spreadProps2(__spreadValues2({}, rest), { transform: lifted });
|
|
2008
|
+
}
|
|
1991
2009
|
function getKfTranslate(kf) {
|
|
1992
2010
|
const v = keyframeValue(kf);
|
|
1993
2011
|
if (!v) return void 0;
|
|
@@ -2356,7 +2374,7 @@ function walkAndMaterialize(node, opts) {
|
|
|
2356
2374
|
let newAnimate;
|
|
2357
2375
|
const animBucket = node.animate;
|
|
2358
2376
|
if (animBucket && typeof animBucket === "object" && !Array.isArray(animBucket)) {
|
|
2359
|
-
const animDef = animBucket;
|
|
2377
|
+
const animDef = mergeStaticTransformIntoAnimDef(animBucket, node.transform);
|
|
2360
2378
|
const transformAnim = animDef.transform;
|
|
2361
2379
|
if (transformAnim && typeof transformAnim === "object" && propAnimIsMotionPath(transformAnim)) {
|
|
2362
2380
|
const materialized = materializeMotionPathInPropAnim(transformAnim, opts);
|
|
@@ -2868,36 +2886,6 @@ var _elementIdCounter = 0;
|
|
|
2868
2886
|
function generateElementId() {
|
|
2869
2887
|
return "_px_el_" + ++_elementIdCounter;
|
|
2870
2888
|
}
|
|
2871
|
-
function mergeStaticTransformIntoAnimDef(animDef, staticTransform) {
|
|
2872
|
-
if (!animDef) return animDef;
|
|
2873
|
-
const staticParts = staticTransform && typeof staticTransform === "object" && !Array.isArray(staticTransform) ? staticTransform : parseTransformParts(staticTransform);
|
|
2874
|
-
if (!staticParts || !Object.keys(staticParts).length) return animDef;
|
|
2875
|
-
const mergeKfValue = (v) => v && typeof v === "object" && !Array.isArray(v) ? __spreadValues2(__spreadValues2({}, staticParts), v) : v;
|
|
2876
|
-
const transformAnim = animDef[TRANSFORM_ATTR];
|
|
2877
|
-
if (transformAnim && typeof transformAnim === "object") {
|
|
2878
|
-
const anim = transformAnim;
|
|
2879
|
-
if (Array.isArray(anim.keyframes)) {
|
|
2880
|
-
const out = __spreadProps2(__spreadValues2({}, anim), {
|
|
2881
|
-
keyframes: anim.keyframes.map((kf) => __spreadProps2(__spreadValues2({}, kf), { value: mergeKfValue(kf.value) }))
|
|
2882
|
-
});
|
|
2883
|
-
if (out.value !== void 0) out.value = mergeKfValue(out.value);
|
|
2884
|
-
return __spreadProps2(__spreadValues2({}, animDef), { transform: out });
|
|
2885
|
-
}
|
|
2886
|
-
return animDef;
|
|
2887
|
-
}
|
|
2888
|
-
const channels = Object.keys(animDef).filter((k) => PX_TRANSFORM_FN_NAMES.has(k));
|
|
2889
|
-
if (channels.length !== 1) return animDef;
|
|
2890
|
-
const ch = channels[0];
|
|
2891
|
-
const chAnim = animDef[ch];
|
|
2892
|
-
if (!chAnim || typeof chAnim !== "object" || !Array.isArray(chAnim.keyframes)) return animDef;
|
|
2893
|
-
const lifted = __spreadProps2(__spreadValues2({}, chAnim), {
|
|
2894
|
-
keyframes: chAnim.keyframes.map((kf) => __spreadProps2(__spreadValues2({}, kf), { value: __spreadProps2(__spreadValues2({}, staticParts), { [ch]: kf.value }) }))
|
|
2895
|
-
});
|
|
2896
|
-
if (lifted.value !== void 0) lifted.value = __spreadProps2(__spreadValues2({}, staticParts), { [ch]: lifted.value });
|
|
2897
|
-
const rest = __spreadValues2({}, animDef);
|
|
2898
|
-
delete rest[ch];
|
|
2899
|
-
return __spreadProps2(__spreadValues2({}, rest), { transform: lifted });
|
|
2900
|
-
}
|
|
2901
2889
|
function normalizeAnimationDefinition(animDef, duration, defs, engine = PxTimelineEngine.native) {
|
|
2902
2890
|
const normalized = {};
|
|
2903
2891
|
for (const [propName, propAnim] of Object.entries(animDef)) {
|
|
@@ -2980,7 +2968,7 @@ function getKeyframesPair(keyframes, progress) {
|
|
|
2980
2968
|
return { prevKf, nextKf };
|
|
2981
2969
|
}
|
|
2982
2970
|
function calcPropertyValue(propName, propAnim, progress) {
|
|
2983
|
-
var _a2, _b, _c, _d;
|
|
2971
|
+
var _a2, _b, _c, _d, _e;
|
|
2984
2972
|
const keyframes = propAnim.keyframes || [];
|
|
2985
2973
|
if (keyframes.length === 0) return null;
|
|
2986
2974
|
const { prevKf, nextKf } = getKeyframesPair(keyframes, progress);
|
|
@@ -3049,7 +3037,7 @@ function calcPropertyValue(propName, propAnim, progress) {
|
|
|
3049
3037
|
!!propAnim.autoOrient
|
|
3050
3038
|
);
|
|
3051
3039
|
partsResult.translate = [sample.translate[0], sample.translate[1]];
|
|
3052
|
-
if (sample.rotateDeg !== void 0) partsResult.rotate = sample.rotateDeg;
|
|
3040
|
+
if (sample.rotateDeg !== void 0) partsResult.rotate = sample.rotateDeg + ((_e = partsResult.rotate) != null ? _e : 0);
|
|
3053
3041
|
}
|
|
3054
3042
|
}
|
|
3055
3043
|
cssValue = composeTransformParts(partsResult, { withUnits: false });
|
|
@@ -3332,12 +3320,12 @@ function deepClonePxNode(value) {
|
|
|
3332
3320
|
for (const k of Object.keys(value)) out[k] = deepClonePxNode(value[k]);
|
|
3333
3321
|
return out;
|
|
3334
3322
|
}
|
|
3335
|
-
function regenerateIdsAndRewriteRefs(root,
|
|
3323
|
+
function regenerateIdsAndRewriteRefs(root, genId3) {
|
|
3336
3324
|
const oldToNew = /* @__PURE__ */ new Map();
|
|
3337
3325
|
const walkAssign = (n) => {
|
|
3338
3326
|
var _a2;
|
|
3339
3327
|
if (typeof n.id === "string") {
|
|
3340
|
-
const newId =
|
|
3328
|
+
const newId = genId3();
|
|
3341
3329
|
oldToNew.set(n.id, newId);
|
|
3342
3330
|
n.id = newId;
|
|
3343
3331
|
}
|
|
@@ -3986,68 +3974,6 @@ function applyTextGlyphsAlongPath(node, ctx, pathD, startOffset, textLength, pat
|
|
|
3986
3974
|
}
|
|
3987
3975
|
return materializeGlyphTextAlongPath(node, pathD, startOffset, { glyphs: ctx.glyphs, warnings: ctx.warnings }, textLength, pathOverflow);
|
|
3988
3976
|
}
|
|
3989
|
-
var PxDiagnosticKind = {
|
|
3990
|
-
/** The document is wrong — regenerate or repair the file. */
|
|
3991
|
-
document: "document",
|
|
3992
|
-
/** The page or app cannot provide what the document asks for — fix the mount. */
|
|
3993
|
-
host: "host",
|
|
3994
|
-
/** The platform cannot do it and the player degraded — usually nothing to fix. */
|
|
3995
|
-
platform: "platform",
|
|
3996
|
-
/** The call is wrong or self-contradictory — fix the options or props you passed. */
|
|
3997
|
-
usage: "usage",
|
|
3998
|
-
/** The player failed where it did not expect to — report it to us. */
|
|
3999
|
-
internal: "internal"
|
|
4000
|
-
};
|
|
4001
|
-
var DOCS_URL = "https://github.com/pixodesk/pixodesk-svg-animator/blob/main/docs/diagnostics.md";
|
|
4002
|
-
function codeLine(code) {
|
|
4003
|
-
return "PX" + code + " " + DOCS_URL + "#px" + code;
|
|
4004
|
-
}
|
|
4005
|
-
function errorIn(data) {
|
|
4006
|
-
return data.find((d) => d instanceof Error);
|
|
4007
|
-
}
|
|
4008
|
-
function createDiagnostics(config, prefix) {
|
|
4009
|
-
const tag = prefix ? prefix + " " : "";
|
|
4010
|
-
return {
|
|
4011
|
-
warn: (kind, code, ...data) => {
|
|
4012
|
-
const message = codeLine(code);
|
|
4013
|
-
if (config == null ? void 0 : config.onWarn) {
|
|
4014
|
-
config.onWarn({ code, kind, data, message });
|
|
4015
|
-
return;
|
|
4016
|
-
}
|
|
4017
|
-
if (config == null ? void 0 : config.muteWarn) return;
|
|
4018
|
-
console.warn(tag + kind + " " + message, ...data);
|
|
4019
|
-
},
|
|
4020
|
-
error: (kind, code, ...data) => {
|
|
4021
|
-
const message = codeLine(code);
|
|
4022
|
-
const error = errorIn(data);
|
|
4023
|
-
if (config == null ? void 0 : config.onError) {
|
|
4024
|
-
config.onError({ code, kind, data, message, error });
|
|
4025
|
-
return;
|
|
4026
|
-
}
|
|
4027
|
-
if (config == null ? void 0 : config.muteError) return;
|
|
4028
|
-
console.error(tag + kind + " " + message, ...data);
|
|
4029
|
-
}
|
|
4030
|
-
};
|
|
4031
|
-
}
|
|
4032
|
-
var MAX_REPORTED = 6;
|
|
4033
|
-
function diagnoseDocument(doc) {
|
|
4034
|
-
try {
|
|
4035
|
-
return { problems: validateDocument(doc) };
|
|
4036
|
-
} catch (e) {
|
|
4037
|
-
return { problems: [] };
|
|
4038
|
-
}
|
|
4039
|
-
}
|
|
4040
|
-
function reportDocumentDiagnostics(doc, where) {
|
|
4041
|
-
const { problems } = diagnoseDocument(doc);
|
|
4042
|
-
if (!problems.length) return;
|
|
4043
|
-
const shown = problems.slice(0, MAX_REPORTED);
|
|
4044
|
-
const more = problems.length - shown.length;
|
|
4045
|
-
console.warn(
|
|
4046
|
-
where + ": this document does not match the animation schema in " + problems.length + " place" + (problems.length === 1 ? "" : "s") + ".\n" + shown.map((p) => " - " + p).join("\n") + (more > 0 ? "\n \u2026 and " + more + " more" : "") + "\n\nIf you did not author these keys, the usual cause is a build that MANGLES PROPERTY NAMES. An animation document is data loaded at runtime, so renaming the property reads inside the player stops them matching the keys in the JSON, and the animation silently does nothing. Feed the published reserved-name list to your minifier \u2014 @pixodesk/svg-animator-web/mangle-reserved.json \u2014 see docs/library/minification.md."
|
|
4047
|
-
);
|
|
4048
|
-
}
|
|
4049
|
-
|
|
4050
|
-
// ../svg-animator-core/dist/index.js
|
|
4051
3977
|
function applyTransformByEffect(node, fx, ctx) {
|
|
4052
3978
|
if (!fx) return node;
|
|
4053
3979
|
delete node.transform;
|
|
@@ -5565,12 +5491,17 @@ function buildOffsetPath(propAnim) {
|
|
|
5565
5491
|
const first = keyframeValue(kfs[0]);
|
|
5566
5492
|
const anchor = (first == null ? void 0 : first.origin) && first.origin.length >= 2 ? [first.origin[0], first.origin[1]] : [0, 0];
|
|
5567
5493
|
const points = [];
|
|
5494
|
+
let keyframesCarryRotate = false;
|
|
5568
5495
|
for (const kf of kfs) {
|
|
5569
5496
|
const v = keyframeValue(kf);
|
|
5570
5497
|
const tr = v == null ? void 0 : v.translate;
|
|
5571
5498
|
if (!tr || tr.length < 2) return void 0;
|
|
5572
5499
|
const parts = Object.keys(v);
|
|
5573
|
-
if (parts.some((p) => p !==
|
|
5500
|
+
if (parts.some((p) => p !== TRANSFORM_PART.translate && p !== TRANSFORM_PART.origin && p !== TRANSFORM_PART.rotate)) return void 0;
|
|
5501
|
+
if ((v == null ? void 0 : v.rotate) !== void 0) {
|
|
5502
|
+
if (v.rotate !== 0) return void 0;
|
|
5503
|
+
keyframesCarryRotate = true;
|
|
5504
|
+
}
|
|
5574
5505
|
const o = (_a2 = v == null ? void 0 : v.origin) != null ? _a2 : [0, 0];
|
|
5575
5506
|
if (o[0] !== anchor[0] || o[1] !== anchor[1]) return void 0;
|
|
5576
5507
|
points.push([tr[0] + anchor[0], tr[1] + anchor[1]]);
|
|
@@ -5598,7 +5529,7 @@ function buildOffsetPath(propAnim) {
|
|
|
5598
5529
|
if (e !== void 0) out.e = e;
|
|
5599
5530
|
distanceKfs.push(out);
|
|
5600
5531
|
}
|
|
5601
|
-
return { pathStr: d, distanceKfs, autoOrient: !!propAnim.autoOrient, anchor };
|
|
5532
|
+
return { pathStr: d, distanceKfs, autoOrient: !!propAnim.autoOrient, anchor, keyframesCarryRotate };
|
|
5602
5533
|
}
|
|
5603
5534
|
function materializeOffsetPathsInTree(root) {
|
|
5604
5535
|
const walk = (node) => {
|
|
@@ -5620,6 +5551,7 @@ function materializeOffsetPathsInTree(root) {
|
|
|
5620
5551
|
const t = __spreadValues2({}, staticTr);
|
|
5621
5552
|
delete t[TRANSFORM_PART.translate];
|
|
5622
5553
|
delete t[TRANSFORM_PART.origin];
|
|
5554
|
+
if (built.keyframesCarryRotate) delete t[TRANSFORM_PART.rotate];
|
|
5623
5555
|
newTransform = Object.keys(t).length ? t : void 0;
|
|
5624
5556
|
}
|
|
5625
5557
|
out = __spreadProps2(__spreadValues2({}, node), {
|
|
@@ -5789,6 +5721,76 @@ function walkAndMaterialize2(node, idMap, animatedIds, genId3, defsCollector, ro
|
|
|
5789
5721
|
});
|
|
5790
5722
|
return changed ? __spreadProps2(__spreadValues2({}, node), { children: newChildren }) : node;
|
|
5791
5723
|
}
|
|
5724
|
+
var TRANSFORM_CHANNEL = "transform";
|
|
5725
|
+
var REVERSED_DIRECTIONS = /* @__PURE__ */ new Set(["reverse", "alternate-reverse"]);
|
|
5726
|
+
var SCRATCH_ID_PREFIX = "__px_rest_";
|
|
5727
|
+
function materializeRestPosesInTree(root, engine) {
|
|
5728
|
+
var _a2;
|
|
5729
|
+
const out = deepClone(root);
|
|
5730
|
+
const config = getAnimatorConfig(out) || {};
|
|
5731
|
+
const duration = +(config.duration || PX_DEFAULT_DURATION_MS);
|
|
5732
|
+
const firstFrameTime = REVERSED_DIRECTIONS.has(String(config.direction)) ? duration : 0;
|
|
5733
|
+
const nodes = animatedNodes(out);
|
|
5734
|
+
if (!nodes.size) return out;
|
|
5735
|
+
const before = bindingsOf(out, engine);
|
|
5736
|
+
const added = /* @__PURE__ */ new Map();
|
|
5737
|
+
for (const [key, animate] of before) {
|
|
5738
|
+
const node = nodes.get(key);
|
|
5739
|
+
if (!node) continue;
|
|
5740
|
+
for (const channel of Object.keys(animate)) {
|
|
5741
|
+
if (!mayCarryRestPose(node, channel)) continue;
|
|
5742
|
+
const value = firstFrameValue(animate, channel, firstFrameTime);
|
|
5743
|
+
if (value === void 0) continue;
|
|
5744
|
+
node[channel] = value;
|
|
5745
|
+
added.set(key, [...(_a2 = added.get(key)) != null ? _a2 : [], channel]);
|
|
5746
|
+
}
|
|
5747
|
+
}
|
|
5748
|
+
if (added.size) {
|
|
5749
|
+
const after = bindingsOf(out, engine);
|
|
5750
|
+
for (const [key, channels] of added) {
|
|
5751
|
+
if (JSON.stringify(after.get(key)) === JSON.stringify(before.get(key))) continue;
|
|
5752
|
+
const node = nodes.get(key);
|
|
5753
|
+
if (node) for (const channel of channels) delete node[channel];
|
|
5754
|
+
}
|
|
5755
|
+
}
|
|
5756
|
+
return out;
|
|
5757
|
+
}
|
|
5758
|
+
function mayCarryRestPose(node, channel) {
|
|
5759
|
+
if (node[channel] !== void 0) return false;
|
|
5760
|
+
if (PX_TRANSFORM_FN_NAMES.has(channel)) return false;
|
|
5761
|
+
if (channel === TRANSFORM_CHANNEL) {
|
|
5762
|
+
for (const part of PX_TRANSFORM_FN_NAMES) if (node[part] !== void 0) return false;
|
|
5763
|
+
}
|
|
5764
|
+
return true;
|
|
5765
|
+
}
|
|
5766
|
+
function firstFrameValue(animate, channel, timeMs) {
|
|
5767
|
+
const values = Object.values(calcAnimationValues({ [channel]: animate[channel] }, timeMs));
|
|
5768
|
+
return values.length === 1 && values[0] !== "" ? values[0] : void 0;
|
|
5769
|
+
}
|
|
5770
|
+
function bindingsOf(tree, engine) {
|
|
5771
|
+
const scratch = deepClone(tree);
|
|
5772
|
+
const keyById = /* @__PURE__ */ new Map();
|
|
5773
|
+
for (const [key, node] of animatedNodes(scratch)) {
|
|
5774
|
+
if (node.id === void 0) node.id = SCRATCH_ID_PREFIX + key;
|
|
5775
|
+
keyById.set(String(node.id), key);
|
|
5776
|
+
}
|
|
5777
|
+
const out = /* @__PURE__ */ new Map();
|
|
5778
|
+
for (const binding of normalizeBindings(scratch, engine)) {
|
|
5779
|
+
const key = keyById.get(binding.id);
|
|
5780
|
+
if (key !== void 0) out.set(key, binding.animate);
|
|
5781
|
+
}
|
|
5782
|
+
return out;
|
|
5783
|
+
}
|
|
5784
|
+
function animatedNodes(tree) {
|
|
5785
|
+
const out = /* @__PURE__ */ new Map();
|
|
5786
|
+
let counter = 0;
|
|
5787
|
+
const visit = (node) => {
|
|
5788
|
+
if (node.animate) out.set(String(counter++), node);
|
|
5789
|
+
if (node.children) for (const child of node.children) visit(child);
|
|
5790
|
+
};
|
|
5791
|
+
if (tree.children) for (const child of tree.children) visit(child);
|
|
5792
|
+
return out;
|
|
5793
|
+
}
|
|
5792
5794
|
function materializeAllInTree(doc, engine, options) {
|
|
5793
5795
|
var _a2, _b;
|
|
5794
5796
|
let root = materializeNodeEffects(doc).root;
|
|
@@ -5800,6 +5802,7 @@ function materializeAllInTree(doc, engine, options) {
|
|
|
5800
5802
|
root = materializeAnimatedUseInstances(root);
|
|
5801
5803
|
root = pruneUnreferencedDefs(root);
|
|
5802
5804
|
}
|
|
5805
|
+
root = materializeRestPosesInTree(root, engine);
|
|
5803
5806
|
return root;
|
|
5804
5807
|
}
|
|
5805
5808
|
function pruneUnreferencedDefs(root) {
|
|
@@ -5831,6 +5834,98 @@ function pruneUnreferencedDefs(root) {
|
|
|
5831
5834
|
}
|
|
5832
5835
|
return root;
|
|
5833
5836
|
}
|
|
5837
|
+
var PxDiagnosticCode = /* @__PURE__ */ ((PxDiagnosticCode2) => {
|
|
5838
|
+
PxDiagnosticCode2[PxDiagnosticCode2["buildFailed"] = 1001] = "buildFailed";
|
|
5839
|
+
PxDiagnosticCode2[PxDiagnosticCode2["invalidDocumentAtSrc"] = 1002] = "invalidDocumentAtSrc";
|
|
5840
|
+
PxDiagnosticCode2[PxDiagnosticCode2["loadFailed"] = 1003] = "loadFailed";
|
|
5841
|
+
PxDiagnosticCode2[PxDiagnosticCode2["animationBuildFailed"] = 1004] = "animationBuildFailed";
|
|
5842
|
+
PxDiagnosticCode2[PxDiagnosticCode2["effectsShape"] = 1101] = "effectsShape";
|
|
5843
|
+
PxDiagnosticCode2[PxDiagnosticCode2["timelineOverrideIgnored"] = 1102] = "timelineOverrideIgnored";
|
|
5844
|
+
PxDiagnosticCode2[PxDiagnosticCode2["blockedTag"] = 1103] = "blockedTag";
|
|
5845
|
+
PxDiagnosticCode2[PxDiagnosticCode2["unsupportedAnimatedAttrs"] = 1104] = "unsupportedAnimatedAttrs";
|
|
5846
|
+
PxDiagnosticCode2[PxDiagnosticCode2["noBindings"] = 1105] = "noBindings";
|
|
5847
|
+
PxDiagnosticCode2[PxDiagnosticCode2["unresolvedBinding"] = 1106] = "unresolvedBinding";
|
|
5848
|
+
PxDiagnosticCode2[PxDiagnosticCode2["triggersNoRoot"] = 1201] = "triggersNoRoot";
|
|
5849
|
+
PxDiagnosticCode2[PxDiagnosticCode2["noRootForSelector"] = 1202] = "noRootForSelector";
|
|
5850
|
+
PxDiagnosticCode2[PxDiagnosticCode2["noRootElement"] = 1203] = "noRootElement";
|
|
5851
|
+
PxDiagnosticCode2[PxDiagnosticCode2["noElementsForSelector"] = 1206] = "noElementsForSelector";
|
|
5852
|
+
PxDiagnosticCode2[PxDiagnosticCode2["setAttributeNoElement"] = 1207] = "setAttributeNoElement";
|
|
5853
|
+
PxDiagnosticCode2[PxDiagnosticCode2["scrollSmoothingNeedsOwnDriver"] = 1301] = "scrollSmoothingNeedsOwnDriver";
|
|
5854
|
+
PxDiagnosticCode2[PxDiagnosticCode2["scrollNativeUnavailable"] = 1302] = "scrollNativeUnavailable";
|
|
5855
|
+
PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectInvalid"] = 1303] = "scrollSubjectInvalid";
|
|
5856
|
+
PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectNoMatch"] = 1304] = "scrollSubjectNoMatch";
|
|
5857
|
+
PxDiagnosticCode2[PxDiagnosticCode2["scrollNoRootToObserve"] = 1305] = "scrollNoRootToObserve";
|
|
5858
|
+
PxDiagnosticCode2[PxDiagnosticCode2["scrollTriggerIgnored"] = 1306] = "scrollTriggerIgnored";
|
|
5859
|
+
PxDiagnosticCode2[PxDiagnosticCode2["rateRejected"] = 1401] = "rateRejected";
|
|
5860
|
+
PxDiagnosticCode2[PxDiagnosticCode2["controlPropsConflict"] = 1501] = "controlPropsConflict";
|
|
5861
|
+
PxDiagnosticCode2[PxDiagnosticCode2["rnCompileFailed"] = 1601] = "rnCompileFailed";
|
|
5862
|
+
PxDiagnosticCode2[PxDiagnosticCode2["rnRenderFailed"] = 1602] = "rnRenderFailed";
|
|
5863
|
+
PxDiagnosticCode2[PxDiagnosticCode2["rnBoundaryCaught"] = 1603] = "rnBoundaryCaught";
|
|
5864
|
+
PxDiagnosticCode2[PxDiagnosticCode2["rnUnsupported"] = 1604] = "rnUnsupported";
|
|
5865
|
+
return PxDiagnosticCode2;
|
|
5866
|
+
})(PxDiagnosticCode || {});
|
|
5867
|
+
var PxDiagnosticKind = {
|
|
5868
|
+
/** The document is wrong — regenerate or repair the file. */
|
|
5869
|
+
document: "document",
|
|
5870
|
+
/** The page or app cannot provide what the document asks for — fix the mount. */
|
|
5871
|
+
host: "host",
|
|
5872
|
+
/** The platform cannot do it and the player degraded — usually nothing to fix. */
|
|
5873
|
+
platform: "platform",
|
|
5874
|
+
/** The call is wrong or self-contradictory — fix the options or props you passed. */
|
|
5875
|
+
usage: "usage",
|
|
5876
|
+
/** The player failed where it did not expect to — report it to us. */
|
|
5877
|
+
internal: "internal"
|
|
5878
|
+
};
|
|
5879
|
+
var DOCS_URL = "https://github.com/pixodesk/pixodesk-svg-animator/blob/main/docs/diagnostics.md";
|
|
5880
|
+
function codeLine(code) {
|
|
5881
|
+
return "PX" + code + " " + DOCS_URL + "#px" + code;
|
|
5882
|
+
}
|
|
5883
|
+
function errorIn(data) {
|
|
5884
|
+
return data.find((d) => d instanceof Error);
|
|
5885
|
+
}
|
|
5886
|
+
function createDiagnostics(config, prefix) {
|
|
5887
|
+
const tag = prefix ? prefix + " " : "";
|
|
5888
|
+
return {
|
|
5889
|
+
warn: (kind, code, ...data) => {
|
|
5890
|
+
const message = codeLine(code);
|
|
5891
|
+
if (config == null ? void 0 : config.onWarn) {
|
|
5892
|
+
config.onWarn({ code, kind, data, message });
|
|
5893
|
+
return;
|
|
5894
|
+
}
|
|
5895
|
+
if (config == null ? void 0 : config.muteWarn) return;
|
|
5896
|
+
console.warn(tag + kind + " " + message, ...data);
|
|
5897
|
+
},
|
|
5898
|
+
error: (kind, code, ...data) => {
|
|
5899
|
+
const message = codeLine(code);
|
|
5900
|
+
const error = errorIn(data);
|
|
5901
|
+
if (config == null ? void 0 : config.onError) {
|
|
5902
|
+
config.onError({ code, kind, data, message, error });
|
|
5903
|
+
return;
|
|
5904
|
+
}
|
|
5905
|
+
if (config == null ? void 0 : config.muteError) return;
|
|
5906
|
+
console.error(tag + kind + " " + message, ...data);
|
|
5907
|
+
}
|
|
5908
|
+
};
|
|
5909
|
+
}
|
|
5910
|
+
var MAX_REPORTED = 6;
|
|
5911
|
+
function diagnoseDocument(doc) {
|
|
5912
|
+
try {
|
|
5913
|
+
return { problems: validateDocument(doc) };
|
|
5914
|
+
} catch (e) {
|
|
5915
|
+
return { problems: [] };
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5918
|
+
function reportDocumentDiagnostics(doc, where) {
|
|
5919
|
+
const { problems } = diagnoseDocument(doc);
|
|
5920
|
+
if (!problems.length) return;
|
|
5921
|
+
const shown = problems.slice(0, MAX_REPORTED);
|
|
5922
|
+
const more = problems.length - shown.length;
|
|
5923
|
+
console.warn(
|
|
5924
|
+
where + ": this document does not match the animation schema in " + problems.length + " place" + (problems.length === 1 ? "" : "s") + ".\n" + shown.map((p) => " - " + p).join("\n") + (more > 0 ? "\n \u2026 and " + more + " more" : "") + "\n\nIf you did not author these keys, the usual cause is a build that MANGLES PROPERTY NAMES. An animation document is data loaded at runtime, so renaming the property reads inside the player stops them matching the keys in the JSON, and the animation silently does nothing. Feed the published reserved-name list to your minifier \u2014 @pixodesk/svg-animator-web/mangle-reserved.json \u2014 see docs/library/minification.md."
|
|
5925
|
+
);
|
|
5926
|
+
}
|
|
5927
|
+
|
|
5928
|
+
// ../svg-animator-core/dist/index.js
|
|
5834
5929
|
var PX_RATE_REJECTED = "setPlaybackRate: rate must be finite and non-zero";
|
|
5835
5930
|
function isValidPlaybackRate(rate) {
|
|
5836
5931
|
return Number.isFinite(rate) && rate !== 0;
|
|
@@ -6142,36 +6237,6 @@ function createAdapterAnimator(doc, adapter, callbacks) {
|
|
|
6142
6237
|
};
|
|
6143
6238
|
return api;
|
|
6144
6239
|
}
|
|
6145
|
-
var PxDiagnosticCode = /* @__PURE__ */ ((PxDiagnosticCode2) => {
|
|
6146
|
-
PxDiagnosticCode2[PxDiagnosticCode2["buildFailed"] = 1001] = "buildFailed";
|
|
6147
|
-
PxDiagnosticCode2[PxDiagnosticCode2["invalidDocumentAtSrc"] = 1002] = "invalidDocumentAtSrc";
|
|
6148
|
-
PxDiagnosticCode2[PxDiagnosticCode2["loadFailed"] = 1003] = "loadFailed";
|
|
6149
|
-
PxDiagnosticCode2[PxDiagnosticCode2["animationBuildFailed"] = 1004] = "animationBuildFailed";
|
|
6150
|
-
PxDiagnosticCode2[PxDiagnosticCode2["effectsShape"] = 1101] = "effectsShape";
|
|
6151
|
-
PxDiagnosticCode2[PxDiagnosticCode2["timelineOverrideIgnored"] = 1102] = "timelineOverrideIgnored";
|
|
6152
|
-
PxDiagnosticCode2[PxDiagnosticCode2["blockedTag"] = 1103] = "blockedTag";
|
|
6153
|
-
PxDiagnosticCode2[PxDiagnosticCode2["unsupportedAnimatedAttrs"] = 1104] = "unsupportedAnimatedAttrs";
|
|
6154
|
-
PxDiagnosticCode2[PxDiagnosticCode2["noBindings"] = 1105] = "noBindings";
|
|
6155
|
-
PxDiagnosticCode2[PxDiagnosticCode2["unresolvedBinding"] = 1106] = "unresolvedBinding";
|
|
6156
|
-
PxDiagnosticCode2[PxDiagnosticCode2["triggersNoRoot"] = 1201] = "triggersNoRoot";
|
|
6157
|
-
PxDiagnosticCode2[PxDiagnosticCode2["noRootForSelector"] = 1202] = "noRootForSelector";
|
|
6158
|
-
PxDiagnosticCode2[PxDiagnosticCode2["noRootElement"] = 1203] = "noRootElement";
|
|
6159
|
-
PxDiagnosticCode2[PxDiagnosticCode2["noElementsForSelector"] = 1206] = "noElementsForSelector";
|
|
6160
|
-
PxDiagnosticCode2[PxDiagnosticCode2["setAttributeNoElement"] = 1207] = "setAttributeNoElement";
|
|
6161
|
-
PxDiagnosticCode2[PxDiagnosticCode2["scrollSmoothingNeedsOwnDriver"] = 1301] = "scrollSmoothingNeedsOwnDriver";
|
|
6162
|
-
PxDiagnosticCode2[PxDiagnosticCode2["scrollNativeUnavailable"] = 1302] = "scrollNativeUnavailable";
|
|
6163
|
-
PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectInvalid"] = 1303] = "scrollSubjectInvalid";
|
|
6164
|
-
PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectNoMatch"] = 1304] = "scrollSubjectNoMatch";
|
|
6165
|
-
PxDiagnosticCode2[PxDiagnosticCode2["scrollNoRootToObserve"] = 1305] = "scrollNoRootToObserve";
|
|
6166
|
-
PxDiagnosticCode2[PxDiagnosticCode2["scrollTriggerIgnored"] = 1306] = "scrollTriggerIgnored";
|
|
6167
|
-
PxDiagnosticCode2[PxDiagnosticCode2["rateRejected"] = 1401] = "rateRejected";
|
|
6168
|
-
PxDiagnosticCode2[PxDiagnosticCode2["controlPropsConflict"] = 1501] = "controlPropsConflict";
|
|
6169
|
-
PxDiagnosticCode2[PxDiagnosticCode2["rnCompileFailed"] = 1601] = "rnCompileFailed";
|
|
6170
|
-
PxDiagnosticCode2[PxDiagnosticCode2["rnRenderFailed"] = 1602] = "rnRenderFailed";
|
|
6171
|
-
PxDiagnosticCode2[PxDiagnosticCode2["rnBoundaryCaught"] = 1603] = "rnBoundaryCaught";
|
|
6172
|
-
PxDiagnosticCode2[PxDiagnosticCode2["rnUnsupported"] = 1604] = "rnUnsupported";
|
|
6173
|
-
return PxDiagnosticCode2;
|
|
6174
|
-
})(PxDiagnosticCode || {});
|
|
6175
6240
|
var FLAT_ONLY_KEYS = [
|
|
6176
6241
|
"timelineSource",
|
|
6177
6242
|
"scroll",
|
|
@@ -6324,6 +6389,50 @@ function applyAnimatorConfig(doc, patch, options) {
|
|
|
6324
6389
|
}
|
|
6325
6390
|
|
|
6326
6391
|
// ../svg-animator-core/dist/internal.js
|
|
6392
|
+
var CLASS_NAME_KEY = "className";
|
|
6393
|
+
var CLASS_ATTR2 = "class";
|
|
6394
|
+
var DOM_TYPE_KEY = "domType";
|
|
6395
|
+
var TYPE_ATTR = "type";
|
|
6396
|
+
var DEFAULT_TAG = "g";
|
|
6397
|
+
function renderPxTree(node, factory, diag) {
|
|
6398
|
+
return node ? renderOne(node, factory, diag, true, 0) : null;
|
|
6399
|
+
}
|
|
6400
|
+
function renderOne(node, factory, diag, isRoot, index) {
|
|
6401
|
+
const _a2 = node, { type, children, style } = _a2, props = __objRest(_a2, ["type", "children", "style"]);
|
|
6402
|
+
const tag = type || DEFAULT_TAG;
|
|
6403
|
+
if (PX_DISALLOWED_SVG_TAGS_LOWER.has(tag.toLowerCase())) {
|
|
6404
|
+
(diag != null ? diag : createDiagnostics(void 0, "[PxAnimator]")).warn(PxDiagnosticKind.document, 1103, tag);
|
|
6405
|
+
return null;
|
|
6406
|
+
}
|
|
6407
|
+
const domType = props[DOM_TYPE_KEY];
|
|
6408
|
+
if (domType !== void 0) delete props[DOM_TYPE_KEY];
|
|
6409
|
+
const attrs = {};
|
|
6410
|
+
let inlineStyle;
|
|
6411
|
+
const domProps = toDomProps(props);
|
|
6412
|
+
for (const propName of Object.keys(domProps)) {
|
|
6413
|
+
const sanitized = sanitizeAttributeValue(propName, domProps[propName]);
|
|
6414
|
+
if (sanitized === void 0) continue;
|
|
6415
|
+
if (PX_CSS_ONLY_STYLE_PROPS.has(propName)) {
|
|
6416
|
+
(inlineStyle != null ? inlineStyle : inlineStyle = {})[propName] = String(sanitized);
|
|
6417
|
+
continue;
|
|
6418
|
+
}
|
|
6419
|
+
attrs[propName === CLASS_NAME_KEY ? CLASS_ATTR2 : camelCaseToKebabWordIfNeeded(propName)] = sanitized;
|
|
6420
|
+
}
|
|
6421
|
+
if (domType !== void 0) attrs[TYPE_ATTR] = String(domType);
|
|
6422
|
+
if (style) {
|
|
6423
|
+
for (const styleProp of Object.keys(style)) (inlineStyle != null ? inlineStyle : inlineStyle = {})[styleProp] = String(style[styleProp]);
|
|
6424
|
+
}
|
|
6425
|
+
const rendered = [];
|
|
6426
|
+
if (children) {
|
|
6427
|
+
children.forEach((child, i) => {
|
|
6428
|
+
const el = renderOne(child, factory, diag, false, i);
|
|
6429
|
+
if (el !== null) rendered.push(el);
|
|
6430
|
+
});
|
|
6431
|
+
}
|
|
6432
|
+
const ownText = props[PX_TEXT_CONTENT_ATTR];
|
|
6433
|
+
const text = !rendered.length && typeof ownText === "string" && ownText ? ownText : void 0;
|
|
6434
|
+
return factory({ tag, attrs, style: inlineStyle, children: rendered, text, node, isRoot, index });
|
|
6435
|
+
}
|
|
6327
6436
|
function isScrollTimeline(config) {
|
|
6328
6437
|
return (config == null ? void 0 : config.timelineSource) === "scroll";
|
|
6329
6438
|
}
|
|
@@ -7389,69 +7498,26 @@ function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
|
|
|
7389
7498
|
|
|
7390
7499
|
// src/dom/PxAnimatorDOM.ts
|
|
7391
7500
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
return null;
|
|
7396
|
-
}
|
|
7397
|
-
const element = document.createElementNS(SVG_NS, tagName);
|
|
7398
|
-
for (const propName in normalizedProps) {
|
|
7399
|
-
const sanitized = sanitizeAttributeValue(propName, normalizedProps[propName]);
|
|
7400
|
-
if (sanitized === void 0) continue;
|
|
7401
|
-
if (PX_CSS_ONLY_STYLE_PROPS.has(propName)) {
|
|
7402
|
-
element.style[propName] = String(sanitized);
|
|
7403
|
-
continue;
|
|
7404
|
-
}
|
|
7405
|
-
element.setAttribute(camelCaseToKebabWordIfNeeded(propName), sanitized);
|
|
7406
|
-
}
|
|
7501
|
+
var createDomElement = ({ tag, attrs, style, children, text }) => {
|
|
7502
|
+
const element = document.createElementNS(SVG_NS, tag);
|
|
7503
|
+
for (const name of Object.keys(attrs)) element.setAttribute(name, attrs[name]);
|
|
7407
7504
|
if (style) {
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
}
|
|
7411
|
-
}
|
|
7412
|
-
if (children == null ? void 0 : children.length) {
|
|
7413
|
-
for (const child of children) {
|
|
7414
|
-
element.appendChild(child);
|
|
7415
|
-
}
|
|
7416
|
-
} else if (textContent) {
|
|
7417
|
-
element.textContent = textContent;
|
|
7505
|
+
const target = element.style;
|
|
7506
|
+
for (const prop of Object.keys(style)) target[prop] = style[prop];
|
|
7418
7507
|
}
|
|
7508
|
+
for (const child of children) element.appendChild(child);
|
|
7509
|
+
if (text !== void 0) element.textContent = text;
|
|
7419
7510
|
return element;
|
|
7420
|
-
}
|
|
7421
|
-
function renderNode(node,
|
|
7422
|
-
|
|
7423
|
-
const _a2 = node, { type, children, style } = _a2, props = __objRest(_a2, ["type", "children", "style"]);
|
|
7424
|
-
const domType = props.domType;
|
|
7425
|
-
if (domType !== void 0) delete props.domType;
|
|
7426
|
-
const nodeDefs = getDefinitions(node) || defs;
|
|
7427
|
-
const resolvedStyle = style;
|
|
7428
|
-
let childElements;
|
|
7429
|
-
if (children) {
|
|
7430
|
-
for (const ch of children) {
|
|
7431
|
-
const child = renderNode(ch, nodeDefs, diag);
|
|
7432
|
-
if (child) {
|
|
7433
|
-
if (!childElements) childElements = [];
|
|
7434
|
-
childElements.push(child);
|
|
7435
|
-
}
|
|
7436
|
-
}
|
|
7437
|
-
}
|
|
7438
|
-
const element = createElement(
|
|
7439
|
-
type || "g",
|
|
7440
|
-
toDomProps(props),
|
|
7441
|
-
resolvedStyle,
|
|
7442
|
-
childElements,
|
|
7443
|
-
props[PX_TEXT_CONTENT_ATTR],
|
|
7444
|
-
diag
|
|
7445
|
-
);
|
|
7446
|
-
if (element && domType !== void 0) element.setAttribute("type", domType);
|
|
7447
|
-
return element;
|
|
7511
|
+
};
|
|
7512
|
+
function renderNode(node, _defs, diag) {
|
|
7513
|
+
return renderPxTree(node, createDomElement, diag);
|
|
7448
7514
|
}
|
|
7449
7515
|
|
|
7450
7516
|
// src/animator/PxAnimator.ts
|
|
7451
7517
|
function createAnimatorFromConfig(doc, adapter, callbacks, rootElement) {
|
|
7452
7518
|
return bindWithEngineChoice(doc, adapter, callbacks, rootElement);
|
|
7453
7519
|
}
|
|
7454
|
-
function createAnimatorImpl(doc, adapter, callbacks, containerElement, patch, resetTimeline) {
|
|
7520
|
+
function createAnimatorImpl(doc, adapter, callbacks, containerElement, patch, resetTimeline, providedRoot) {
|
|
7455
7521
|
const diag = createDiagnostics(callbacks, "[PxAnimator]");
|
|
7456
7522
|
const effectsWarnings = validateNodeEffects(doc);
|
|
7457
7523
|
for (const w of effectsWarnings) diag.warn(PxDiagnosticKind.document, PxDiagnosticCode.effectsShape, w);
|
|
@@ -7475,6 +7541,7 @@ function createAnimatorImpl(doc, adapter, callbacks, containerElement, patch, re
|
|
|
7475
7541
|
}
|
|
7476
7542
|
}
|
|
7477
7543
|
}
|
|
7544
|
+
if (!rootElement && providedRoot) rootElement = providedRoot;
|
|
7478
7545
|
const api = createAnimatorFromConfig(doc, adapter, callbacks, rootElement);
|
|
7479
7546
|
if (containerElement && rootElement) {
|
|
7480
7547
|
const rendered = rootElement;
|
|
@@ -7487,7 +7554,7 @@ function createAnimatorImpl(doc, adapter, callbacks, containerElement, patch, re
|
|
|
7487
7554
|
return api;
|
|
7488
7555
|
}
|
|
7489
7556
|
function isInternalOptions(options) {
|
|
7490
|
-
return "adapter" in options;
|
|
7557
|
+
return "adapter" in options || "rootElement" in options;
|
|
7491
7558
|
}
|
|
7492
7559
|
function resolveTimelineOption(options) {
|
|
7493
7560
|
const { timeline, duration, delay, iterations, start } = options;
|
|
@@ -7496,6 +7563,7 @@ function resolveTimelineOption(options) {
|
|
|
7496
7563
|
function createAnimator(options) {
|
|
7497
7564
|
const { src, doc, container, resetTimeline } = options;
|
|
7498
7565
|
const adapter = isInternalOptions(options) ? options.adapter : void 0;
|
|
7566
|
+
const providedRoot = isInternalOptions(options) ? options.rootElement : void 0;
|
|
7499
7567
|
const patch = resolveTimelineOption(options);
|
|
7500
7568
|
let proxy;
|
|
7501
7569
|
const callbacks = withRegistryEvents(toEngineCallbacks(options), () => proxy);
|
|
@@ -7528,7 +7596,7 @@ function createAnimator(options) {
|
|
|
7528
7596
|
};
|
|
7529
7597
|
const build = (document2) => {
|
|
7530
7598
|
try {
|
|
7531
|
-
ready(createAnimatorImpl(document2, adapter, callbacks, container, patch, resetTimeline));
|
|
7599
|
+
ready(createAnimatorImpl(document2, adapter, callbacks, container, patch, resetTimeline, providedRoot));
|
|
7532
7600
|
} catch (e) {
|
|
7533
7601
|
const err = asThrownError(e);
|
|
7534
7602
|
failed(PxDiagnosticKind.internal, PxDiagnosticCode.buildFailed, err);
|