@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.
@@ -38,6 +38,16 @@ interface PxAnimatorOptions extends PxPlaybackOverride, PxAnimatorCallbacks {
38
38
  interface PxInternalAnimatorOptions extends PxAnimatorOptions {
39
39
  /** A custom render target for the frame-loop engine (`PxPlatformAdapter`). */
40
40
  adapter?: PxPlatformAdapter;
41
+ /**
42
+ * The root `<svg>` the CALLER rendered, when it renders the document itself (the React and
43
+ * Vue components). Triggers attach to it — pointer listeners, the visibility gate — and
44
+ * without one they are not wired at all, so even a `load` trigger never fires.
45
+ *
46
+ * Otherwise the engines look the root up as `#` + the document's root id, which finds
47
+ * nothing for the common document whose root `<svg>` has no id. The component already holds
48
+ * the element, so it hands it over rather than have it guessed.
49
+ */
50
+ rootElement?: Element;
41
51
  }
42
52
  /**
43
53
  * Creates an animator instance to control SVG animations.
@@ -38,6 +38,16 @@ interface PxAnimatorOptions extends PxPlaybackOverride, PxAnimatorCallbacks {
38
38
  interface PxInternalAnimatorOptions extends PxAnimatorOptions {
39
39
  /** A custom render target for the frame-loop engine (`PxPlatformAdapter`). */
40
40
  adapter?: PxPlatformAdapter;
41
+ /**
42
+ * The root `<svg>` the CALLER rendered, when it renders the document itself (the React and
43
+ * Vue components). Triggers attach to it — pointer listeners, the visibility gate — and
44
+ * without one they are not wired at all, so even a `load` trigger never fires.
45
+ *
46
+ * Otherwise the engines look the root up as `#` + the document's root id, which finds
47
+ * nothing for the common document whose root `<svg>` has no id. The component already holds
48
+ * the element, so it hands it over rather than have it guessed.
49
+ */
50
+ rootElement?: Element;
41
51
  }
42
52
  /**
43
53
  * Creates an animator instance to control SVG animations.
@@ -17,20 +17,8 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
20
 
33
- // ../svg-animator-core/dist/chunk-EFQLDGFY.js
21
+ // ../svg-animator-core/dist/chunk-YVKMPBHE.js
34
22
  var __defProp2 = Object.defineProperty;
35
23
  var __defProps2 = Object.defineProperties;
36
24
  var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
@@ -51,7 +39,7 @@ var __spreadValues2 = (a, b) => {
51
39
  return a;
52
40
  };
53
41
  var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
54
- var __objRest2 = (source, exclude) => {
42
+ var __objRest = (source, exclude) => {
55
43
  var target = {};
56
44
  for (var prop in source)
57
45
  if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
@@ -790,7 +778,7 @@ function flattenAnimatorTimeline(cfg) {
790
778
  if (timeline === void 0 || timeline === null || typeof timeline !== "object") return cfg;
791
779
  const memoised = flattenMemo.get(cfg);
792
780
  if (memoised) return memoised;
793
- const _a2 = cfg, { timeline: _dropped } = _a2, flat = __objRest2(_a2, ["timeline"]);
781
+ const _a2 = cfg, { timeline: _dropped } = _a2, flat = __objRest(_a2, ["timeline"]);
794
782
  if (timeline.engine !== void 0) flat.engine = timeline.engine;
795
783
  if (timeline.frameRate !== void 0) flat.frameRate = timeline.frameRate;
796
784
  if (timeline.type === "scroll" || timeline.type === "view") {
@@ -816,7 +804,7 @@ function flattenAnimatorTimeline(cfg) {
816
804
  } else {
817
805
  if (timeline.duration !== void 0) flat.duration = timeline.duration;
818
806
  if (timeline.trigger !== void 0) {
819
- const _b = timeline.trigger, { finish } = _b, restTrigger = __objRest2(_b, ["finish"]);
807
+ const _b = timeline.trigger, { finish } = _b, restTrigger = __objRest(_b, ["finish"]);
820
808
  if (Object.keys(restTrigger).length) flat.trigger = restTrigger;
821
809
  if (finish !== void 0) flat.resetOnFinish = finish === "reset";
822
810
  }
@@ -1947,6 +1935,36 @@ function toDomProps(props) {
1947
1935
  }
1948
1936
  return propsCopy;
1949
1937
  }
1938
+ function mergeStaticTransformIntoAnimDef(animDef, staticTransform) {
1939
+ if (!animDef) return animDef;
1940
+ const staticParts = staticTransform && typeof staticTransform === "object" && !Array.isArray(staticTransform) ? staticTransform : parseTransformParts(staticTransform);
1941
+ if (!staticParts || !Object.keys(staticParts).length) return animDef;
1942
+ const mergeKfValue = (v) => v && typeof v === "object" && !Array.isArray(v) ? __spreadValues2(__spreadValues2({}, staticParts), v) : v;
1943
+ const transformAnim = animDef[TRANSFORM_ATTR];
1944
+ if (transformAnim && typeof transformAnim === "object") {
1945
+ const anim = transformAnim;
1946
+ if (Array.isArray(anim.keyframes)) {
1947
+ const out = __spreadProps2(__spreadValues2({}, anim), {
1948
+ keyframes: anim.keyframes.map((kf) => __spreadProps2(__spreadValues2({}, kf), { value: mergeKfValue(kf.value) }))
1949
+ });
1950
+ if (out.value !== void 0) out.value = mergeKfValue(out.value);
1951
+ return __spreadProps2(__spreadValues2({}, animDef), { transform: out });
1952
+ }
1953
+ return animDef;
1954
+ }
1955
+ const channels = Object.keys(animDef).filter((k) => PX_TRANSFORM_FN_NAMES.has(k));
1956
+ if (channels.length !== 1) return animDef;
1957
+ const ch = channels[0];
1958
+ const chAnim = animDef[ch];
1959
+ if (!chAnim || typeof chAnim !== "object" || !Array.isArray(chAnim.keyframes)) return animDef;
1960
+ const lifted = __spreadProps2(__spreadValues2({}, chAnim), {
1961
+ keyframes: chAnim.keyframes.map((kf) => __spreadProps2(__spreadValues2({}, kf), { value: __spreadProps2(__spreadValues2({}, staticParts), { [ch]: kf.value }) }))
1962
+ });
1963
+ if (lifted.value !== void 0) lifted.value = __spreadProps2(__spreadValues2({}, staticParts), { [ch]: lifted.value });
1964
+ const rest = __spreadValues2({}, animDef);
1965
+ delete rest[ch];
1966
+ return __spreadProps2(__spreadValues2({}, rest), { transform: lifted });
1967
+ }
1950
1968
  function getKfTranslate(kf) {
1951
1969
  const v = keyframeValue(kf);
1952
1970
  if (!v) return void 0;
@@ -2315,7 +2333,7 @@ function walkAndMaterialize(node, opts) {
2315
2333
  let newAnimate;
2316
2334
  const animBucket = node.animate;
2317
2335
  if (animBucket && typeof animBucket === "object" && !Array.isArray(animBucket)) {
2318
- const animDef = animBucket;
2336
+ const animDef = mergeStaticTransformIntoAnimDef(animBucket, node.transform);
2319
2337
  const transformAnim = animDef.transform;
2320
2338
  if (transformAnim && typeof transformAnim === "object" && propAnimIsMotionPath(transformAnim)) {
2321
2339
  const materialized = materializeMotionPathInPropAnim(transformAnim, opts);
@@ -2827,36 +2845,6 @@ var _elementIdCounter = 0;
2827
2845
  function generateElementId() {
2828
2846
  return "_px_el_" + ++_elementIdCounter;
2829
2847
  }
2830
- function mergeStaticTransformIntoAnimDef(animDef, staticTransform) {
2831
- if (!animDef) return animDef;
2832
- const staticParts = staticTransform && typeof staticTransform === "object" && !Array.isArray(staticTransform) ? staticTransform : parseTransformParts(staticTransform);
2833
- if (!staticParts || !Object.keys(staticParts).length) return animDef;
2834
- const mergeKfValue = (v) => v && typeof v === "object" && !Array.isArray(v) ? __spreadValues2(__spreadValues2({}, staticParts), v) : v;
2835
- const transformAnim = animDef[TRANSFORM_ATTR];
2836
- if (transformAnim && typeof transformAnim === "object") {
2837
- const anim = transformAnim;
2838
- if (Array.isArray(anim.keyframes)) {
2839
- const out = __spreadProps2(__spreadValues2({}, anim), {
2840
- keyframes: anim.keyframes.map((kf) => __spreadProps2(__spreadValues2({}, kf), { value: mergeKfValue(kf.value) }))
2841
- });
2842
- if (out.value !== void 0) out.value = mergeKfValue(out.value);
2843
- return __spreadProps2(__spreadValues2({}, animDef), { transform: out });
2844
- }
2845
- return animDef;
2846
- }
2847
- const channels = Object.keys(animDef).filter((k) => PX_TRANSFORM_FN_NAMES.has(k));
2848
- if (channels.length !== 1) return animDef;
2849
- const ch = channels[0];
2850
- const chAnim = animDef[ch];
2851
- if (!chAnim || typeof chAnim !== "object" || !Array.isArray(chAnim.keyframes)) return animDef;
2852
- const lifted = __spreadProps2(__spreadValues2({}, chAnim), {
2853
- keyframes: chAnim.keyframes.map((kf) => __spreadProps2(__spreadValues2({}, kf), { value: __spreadProps2(__spreadValues2({}, staticParts), { [ch]: kf.value }) }))
2854
- });
2855
- if (lifted.value !== void 0) lifted.value = __spreadProps2(__spreadValues2({}, staticParts), { [ch]: lifted.value });
2856
- const rest = __spreadValues2({}, animDef);
2857
- delete rest[ch];
2858
- return __spreadProps2(__spreadValues2({}, rest), { transform: lifted });
2859
- }
2860
2848
  function normalizeAnimationDefinition(animDef, duration, defs, engine = PxTimelineEngine.native) {
2861
2849
  const normalized = {};
2862
2850
  for (const [propName, propAnim] of Object.entries(animDef)) {
@@ -2939,7 +2927,7 @@ function getKeyframesPair(keyframes, progress) {
2939
2927
  return { prevKf, nextKf };
2940
2928
  }
2941
2929
  function calcPropertyValue(propName, propAnim, progress) {
2942
- var _a2, _b, _c, _d;
2930
+ var _a2, _b, _c, _d, _e;
2943
2931
  const keyframes = propAnim.keyframes || [];
2944
2932
  if (keyframes.length === 0) return null;
2945
2933
  const { prevKf, nextKf } = getKeyframesPair(keyframes, progress);
@@ -3008,7 +2996,7 @@ function calcPropertyValue(propName, propAnim, progress) {
3008
2996
  !!propAnim.autoOrient
3009
2997
  );
3010
2998
  partsResult.translate = [sample.translate[0], sample.translate[1]];
3011
- if (sample.rotateDeg !== void 0) partsResult.rotate = sample.rotateDeg;
2999
+ if (sample.rotateDeg !== void 0) partsResult.rotate = sample.rotateDeg + ((_e = partsResult.rotate) != null ? _e : 0);
3012
3000
  }
3013
3001
  }
3014
3002
  cssValue = composeTransformParts(partsResult, { withUnits: false });
@@ -3291,12 +3279,12 @@ function deepClonePxNode(value) {
3291
3279
  for (const k of Object.keys(value)) out[k] = deepClonePxNode(value[k]);
3292
3280
  return out;
3293
3281
  }
3294
- function regenerateIdsAndRewriteRefs(root, genId2) {
3282
+ function regenerateIdsAndRewriteRefs(root, genId3) {
3295
3283
  const oldToNew = /* @__PURE__ */ new Map();
3296
3284
  const walkAssign = (n) => {
3297
3285
  var _a2;
3298
3286
  if (typeof n.id === "string") {
3299
- const newId = genId2();
3287
+ const newId = genId3();
3300
3288
  oldToNew.set(n.id, newId);
3301
3289
  n.id = newId;
3302
3290
  }
@@ -3945,68 +3933,6 @@ function applyTextGlyphsAlongPath(node, ctx, pathD, startOffset, textLength, pat
3945
3933
  }
3946
3934
  return materializeGlyphTextAlongPath(node, pathD, startOffset, { glyphs: ctx.glyphs, warnings: ctx.warnings }, textLength, pathOverflow);
3947
3935
  }
3948
- var PxDiagnosticKind = {
3949
- /** The document is wrong — regenerate or repair the file. */
3950
- document: "document",
3951
- /** The page or app cannot provide what the document asks for — fix the mount. */
3952
- host: "host",
3953
- /** The platform cannot do it and the player degraded — usually nothing to fix. */
3954
- platform: "platform",
3955
- /** The call is wrong or self-contradictory — fix the options or props you passed. */
3956
- usage: "usage",
3957
- /** The player failed where it did not expect to — report it to us. */
3958
- internal: "internal"
3959
- };
3960
- var DOCS_URL = "https://github.com/pixodesk/pixodesk-svg-animator/blob/main/docs/diagnostics.md";
3961
- function codeLine(code) {
3962
- return "PX" + code + " " + DOCS_URL + "#px" + code;
3963
- }
3964
- function errorIn(data) {
3965
- return data.find((d) => d instanceof Error);
3966
- }
3967
- function createDiagnostics(config, prefix) {
3968
- const tag = prefix ? prefix + " " : "";
3969
- return {
3970
- warn: (kind, code, ...data) => {
3971
- const message = codeLine(code);
3972
- if (config == null ? void 0 : config.onWarn) {
3973
- config.onWarn({ code, kind, data, message });
3974
- return;
3975
- }
3976
- if (config == null ? void 0 : config.muteWarn) return;
3977
- console.warn(tag + kind + " " + message, ...data);
3978
- },
3979
- error: (kind, code, ...data) => {
3980
- const message = codeLine(code);
3981
- const error = errorIn(data);
3982
- if (config == null ? void 0 : config.onError) {
3983
- config.onError({ code, kind, data, message, error });
3984
- return;
3985
- }
3986
- if (config == null ? void 0 : config.muteError) return;
3987
- console.error(tag + kind + " " + message, ...data);
3988
- }
3989
- };
3990
- }
3991
- var MAX_REPORTED = 6;
3992
- function diagnoseDocument(doc) {
3993
- try {
3994
- return { problems: validateDocument(doc) };
3995
- } catch (e) {
3996
- return { problems: [] };
3997
- }
3998
- }
3999
- function reportDocumentDiagnostics(doc, where) {
4000
- const { problems } = diagnoseDocument(doc);
4001
- if (!problems.length) return;
4002
- const shown = problems.slice(0, MAX_REPORTED);
4003
- const more = problems.length - shown.length;
4004
- console.warn(
4005
- 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."
4006
- );
4007
- }
4008
-
4009
- // ../svg-animator-core/dist/index.js
4010
3936
  function applyTransformByEffect(node, fx, ctx) {
4011
3937
  if (!fx) return node;
4012
3938
  delete node.transform;
@@ -5524,12 +5450,17 @@ function buildOffsetPath(propAnim) {
5524
5450
  const first = keyframeValue(kfs[0]);
5525
5451
  const anchor = (first == null ? void 0 : first.origin) && first.origin.length >= 2 ? [first.origin[0], first.origin[1]] : [0, 0];
5526
5452
  const points = [];
5453
+ let keyframesCarryRotate = false;
5527
5454
  for (const kf of kfs) {
5528
5455
  const v = keyframeValue(kf);
5529
5456
  const tr = v == null ? void 0 : v.translate;
5530
5457
  if (!tr || tr.length < 2) return void 0;
5531
5458
  const parts = Object.keys(v);
5532
- if (parts.some((p) => p !== "translate" && p !== "origin")) return void 0;
5459
+ if (parts.some((p) => p !== TRANSFORM_PART.translate && p !== TRANSFORM_PART.origin && p !== TRANSFORM_PART.rotate)) return void 0;
5460
+ if ((v == null ? void 0 : v.rotate) !== void 0) {
5461
+ if (v.rotate !== 0) return void 0;
5462
+ keyframesCarryRotate = true;
5463
+ }
5533
5464
  const o = (_a2 = v == null ? void 0 : v.origin) != null ? _a2 : [0, 0];
5534
5465
  if (o[0] !== anchor[0] || o[1] !== anchor[1]) return void 0;
5535
5466
  points.push([tr[0] + anchor[0], tr[1] + anchor[1]]);
@@ -5557,7 +5488,7 @@ function buildOffsetPath(propAnim) {
5557
5488
  if (e !== void 0) out.e = e;
5558
5489
  distanceKfs.push(out);
5559
5490
  }
5560
- return { pathStr: d, distanceKfs, autoOrient: !!propAnim.autoOrient, anchor };
5491
+ return { pathStr: d, distanceKfs, autoOrient: !!propAnim.autoOrient, anchor, keyframesCarryRotate };
5561
5492
  }
5562
5493
  function materializeOffsetPathsInTree(root) {
5563
5494
  const walk = (node) => {
@@ -5579,6 +5510,7 @@ function materializeOffsetPathsInTree(root) {
5579
5510
  const t = __spreadValues2({}, staticTr);
5580
5511
  delete t[TRANSFORM_PART.translate];
5581
5512
  delete t[TRANSFORM_PART.origin];
5513
+ if (built.keyframesCarryRotate) delete t[TRANSFORM_PART.rotate];
5582
5514
  newTransform = Object.keys(t).length ? t : void 0;
5583
5515
  }
5584
5516
  out = __spreadProps2(__spreadValues2({}, node), {
@@ -5748,6 +5680,76 @@ function walkAndMaterialize2(node, idMap, animatedIds, genId3, defsCollector, ro
5748
5680
  });
5749
5681
  return changed ? __spreadProps2(__spreadValues2({}, node), { children: newChildren }) : node;
5750
5682
  }
5683
+ var TRANSFORM_CHANNEL = "transform";
5684
+ var REVERSED_DIRECTIONS = /* @__PURE__ */ new Set(["reverse", "alternate-reverse"]);
5685
+ var SCRATCH_ID_PREFIX = "__px_rest_";
5686
+ function materializeRestPosesInTree(root, engine) {
5687
+ var _a2;
5688
+ const out = deepClone(root);
5689
+ const config = getAnimatorConfig(out) || {};
5690
+ const duration = +(config.duration || PX_DEFAULT_DURATION_MS);
5691
+ const firstFrameTime = REVERSED_DIRECTIONS.has(String(config.direction)) ? duration : 0;
5692
+ const nodes = animatedNodes(out);
5693
+ if (!nodes.size) return out;
5694
+ const before = bindingsOf(out, engine);
5695
+ const added = /* @__PURE__ */ new Map();
5696
+ for (const [key, animate] of before) {
5697
+ const node = nodes.get(key);
5698
+ if (!node) continue;
5699
+ for (const channel of Object.keys(animate)) {
5700
+ if (!mayCarryRestPose(node, channel)) continue;
5701
+ const value = firstFrameValue(animate, channel, firstFrameTime);
5702
+ if (value === void 0) continue;
5703
+ node[channel] = value;
5704
+ added.set(key, [...(_a2 = added.get(key)) != null ? _a2 : [], channel]);
5705
+ }
5706
+ }
5707
+ if (added.size) {
5708
+ const after = bindingsOf(out, engine);
5709
+ for (const [key, channels] of added) {
5710
+ if (JSON.stringify(after.get(key)) === JSON.stringify(before.get(key))) continue;
5711
+ const node = nodes.get(key);
5712
+ if (node) for (const channel of channels) delete node[channel];
5713
+ }
5714
+ }
5715
+ return out;
5716
+ }
5717
+ function mayCarryRestPose(node, channel) {
5718
+ if (node[channel] !== void 0) return false;
5719
+ if (PX_TRANSFORM_FN_NAMES.has(channel)) return false;
5720
+ if (channel === TRANSFORM_CHANNEL) {
5721
+ for (const part of PX_TRANSFORM_FN_NAMES) if (node[part] !== void 0) return false;
5722
+ }
5723
+ return true;
5724
+ }
5725
+ function firstFrameValue(animate, channel, timeMs) {
5726
+ const values = Object.values(calcAnimationValues({ [channel]: animate[channel] }, timeMs));
5727
+ return values.length === 1 && values[0] !== "" ? values[0] : void 0;
5728
+ }
5729
+ function bindingsOf(tree, engine) {
5730
+ const scratch = deepClone(tree);
5731
+ const keyById = /* @__PURE__ */ new Map();
5732
+ for (const [key, node] of animatedNodes(scratch)) {
5733
+ if (node.id === void 0) node.id = SCRATCH_ID_PREFIX + key;
5734
+ keyById.set(String(node.id), key);
5735
+ }
5736
+ const out = /* @__PURE__ */ new Map();
5737
+ for (const binding of normalizeBindings(scratch, engine)) {
5738
+ const key = keyById.get(binding.id);
5739
+ if (key !== void 0) out.set(key, binding.animate);
5740
+ }
5741
+ return out;
5742
+ }
5743
+ function animatedNodes(tree) {
5744
+ const out = /* @__PURE__ */ new Map();
5745
+ let counter = 0;
5746
+ const visit = (node) => {
5747
+ if (node.animate) out.set(String(counter++), node);
5748
+ if (node.children) for (const child of node.children) visit(child);
5749
+ };
5750
+ if (tree.children) for (const child of tree.children) visit(child);
5751
+ return out;
5752
+ }
5751
5753
  function materializeAllInTree(doc, engine, options) {
5752
5754
  var _a2, _b;
5753
5755
  let root = materializeNodeEffects(doc).root;
@@ -5759,6 +5761,7 @@ function materializeAllInTree(doc, engine, options) {
5759
5761
  root = materializeAnimatedUseInstances(root);
5760
5762
  root = pruneUnreferencedDefs(root);
5761
5763
  }
5764
+ root = materializeRestPosesInTree(root, engine);
5762
5765
  return root;
5763
5766
  }
5764
5767
  function pruneUnreferencedDefs(root) {
@@ -5790,6 +5793,98 @@ function pruneUnreferencedDefs(root) {
5790
5793
  }
5791
5794
  return root;
5792
5795
  }
5796
+ var PxDiagnosticCode = /* @__PURE__ */ ((PxDiagnosticCode2) => {
5797
+ PxDiagnosticCode2[PxDiagnosticCode2["buildFailed"] = 1001] = "buildFailed";
5798
+ PxDiagnosticCode2[PxDiagnosticCode2["invalidDocumentAtSrc"] = 1002] = "invalidDocumentAtSrc";
5799
+ PxDiagnosticCode2[PxDiagnosticCode2["loadFailed"] = 1003] = "loadFailed";
5800
+ PxDiagnosticCode2[PxDiagnosticCode2["animationBuildFailed"] = 1004] = "animationBuildFailed";
5801
+ PxDiagnosticCode2[PxDiagnosticCode2["effectsShape"] = 1101] = "effectsShape";
5802
+ PxDiagnosticCode2[PxDiagnosticCode2["timelineOverrideIgnored"] = 1102] = "timelineOverrideIgnored";
5803
+ PxDiagnosticCode2[PxDiagnosticCode2["blockedTag"] = 1103] = "blockedTag";
5804
+ PxDiagnosticCode2[PxDiagnosticCode2["unsupportedAnimatedAttrs"] = 1104] = "unsupportedAnimatedAttrs";
5805
+ PxDiagnosticCode2[PxDiagnosticCode2["noBindings"] = 1105] = "noBindings";
5806
+ PxDiagnosticCode2[PxDiagnosticCode2["unresolvedBinding"] = 1106] = "unresolvedBinding";
5807
+ PxDiagnosticCode2[PxDiagnosticCode2["triggersNoRoot"] = 1201] = "triggersNoRoot";
5808
+ PxDiagnosticCode2[PxDiagnosticCode2["noRootForSelector"] = 1202] = "noRootForSelector";
5809
+ PxDiagnosticCode2[PxDiagnosticCode2["noRootElement"] = 1203] = "noRootElement";
5810
+ PxDiagnosticCode2[PxDiagnosticCode2["noElementsForSelector"] = 1206] = "noElementsForSelector";
5811
+ PxDiagnosticCode2[PxDiagnosticCode2["setAttributeNoElement"] = 1207] = "setAttributeNoElement";
5812
+ PxDiagnosticCode2[PxDiagnosticCode2["scrollSmoothingNeedsOwnDriver"] = 1301] = "scrollSmoothingNeedsOwnDriver";
5813
+ PxDiagnosticCode2[PxDiagnosticCode2["scrollNativeUnavailable"] = 1302] = "scrollNativeUnavailable";
5814
+ PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectInvalid"] = 1303] = "scrollSubjectInvalid";
5815
+ PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectNoMatch"] = 1304] = "scrollSubjectNoMatch";
5816
+ PxDiagnosticCode2[PxDiagnosticCode2["scrollNoRootToObserve"] = 1305] = "scrollNoRootToObserve";
5817
+ PxDiagnosticCode2[PxDiagnosticCode2["scrollTriggerIgnored"] = 1306] = "scrollTriggerIgnored";
5818
+ PxDiagnosticCode2[PxDiagnosticCode2["rateRejected"] = 1401] = "rateRejected";
5819
+ PxDiagnosticCode2[PxDiagnosticCode2["controlPropsConflict"] = 1501] = "controlPropsConflict";
5820
+ PxDiagnosticCode2[PxDiagnosticCode2["rnCompileFailed"] = 1601] = "rnCompileFailed";
5821
+ PxDiagnosticCode2[PxDiagnosticCode2["rnRenderFailed"] = 1602] = "rnRenderFailed";
5822
+ PxDiagnosticCode2[PxDiagnosticCode2["rnBoundaryCaught"] = 1603] = "rnBoundaryCaught";
5823
+ PxDiagnosticCode2[PxDiagnosticCode2["rnUnsupported"] = 1604] = "rnUnsupported";
5824
+ return PxDiagnosticCode2;
5825
+ })(PxDiagnosticCode || {});
5826
+ var PxDiagnosticKind = {
5827
+ /** The document is wrong — regenerate or repair the file. */
5828
+ document: "document",
5829
+ /** The page or app cannot provide what the document asks for — fix the mount. */
5830
+ host: "host",
5831
+ /** The platform cannot do it and the player degraded — usually nothing to fix. */
5832
+ platform: "platform",
5833
+ /** The call is wrong or self-contradictory — fix the options or props you passed. */
5834
+ usage: "usage",
5835
+ /** The player failed where it did not expect to — report it to us. */
5836
+ internal: "internal"
5837
+ };
5838
+ var DOCS_URL = "https://github.com/pixodesk/pixodesk-svg-animator/blob/main/docs/diagnostics.md";
5839
+ function codeLine(code) {
5840
+ return "PX" + code + " " + DOCS_URL + "#px" + code;
5841
+ }
5842
+ function errorIn(data) {
5843
+ return data.find((d) => d instanceof Error);
5844
+ }
5845
+ function createDiagnostics(config, prefix) {
5846
+ const tag = prefix ? prefix + " " : "";
5847
+ return {
5848
+ warn: (kind, code, ...data) => {
5849
+ const message = codeLine(code);
5850
+ if (config == null ? void 0 : config.onWarn) {
5851
+ config.onWarn({ code, kind, data, message });
5852
+ return;
5853
+ }
5854
+ if (config == null ? void 0 : config.muteWarn) return;
5855
+ console.warn(tag + kind + " " + message, ...data);
5856
+ },
5857
+ error: (kind, code, ...data) => {
5858
+ const message = codeLine(code);
5859
+ const error = errorIn(data);
5860
+ if (config == null ? void 0 : config.onError) {
5861
+ config.onError({ code, kind, data, message, error });
5862
+ return;
5863
+ }
5864
+ if (config == null ? void 0 : config.muteError) return;
5865
+ console.error(tag + kind + " " + message, ...data);
5866
+ }
5867
+ };
5868
+ }
5869
+ var MAX_REPORTED = 6;
5870
+ function diagnoseDocument(doc) {
5871
+ try {
5872
+ return { problems: validateDocument(doc) };
5873
+ } catch (e) {
5874
+ return { problems: [] };
5875
+ }
5876
+ }
5877
+ function reportDocumentDiagnostics(doc, where) {
5878
+ const { problems } = diagnoseDocument(doc);
5879
+ if (!problems.length) return;
5880
+ const shown = problems.slice(0, MAX_REPORTED);
5881
+ const more = problems.length - shown.length;
5882
+ console.warn(
5883
+ 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."
5884
+ );
5885
+ }
5886
+
5887
+ // ../svg-animator-core/dist/index.js
5793
5888
  var PX_RATE_REJECTED = "setPlaybackRate: rate must be finite and non-zero";
5794
5889
  function isValidPlaybackRate(rate) {
5795
5890
  return Number.isFinite(rate) && rate !== 0;
@@ -6101,36 +6196,6 @@ function createAdapterAnimator(doc, adapter, callbacks) {
6101
6196
  };
6102
6197
  return api;
6103
6198
  }
6104
- var PxDiagnosticCode = /* @__PURE__ */ ((PxDiagnosticCode2) => {
6105
- PxDiagnosticCode2[PxDiagnosticCode2["buildFailed"] = 1001] = "buildFailed";
6106
- PxDiagnosticCode2[PxDiagnosticCode2["invalidDocumentAtSrc"] = 1002] = "invalidDocumentAtSrc";
6107
- PxDiagnosticCode2[PxDiagnosticCode2["loadFailed"] = 1003] = "loadFailed";
6108
- PxDiagnosticCode2[PxDiagnosticCode2["animationBuildFailed"] = 1004] = "animationBuildFailed";
6109
- PxDiagnosticCode2[PxDiagnosticCode2["effectsShape"] = 1101] = "effectsShape";
6110
- PxDiagnosticCode2[PxDiagnosticCode2["timelineOverrideIgnored"] = 1102] = "timelineOverrideIgnored";
6111
- PxDiagnosticCode2[PxDiagnosticCode2["blockedTag"] = 1103] = "blockedTag";
6112
- PxDiagnosticCode2[PxDiagnosticCode2["unsupportedAnimatedAttrs"] = 1104] = "unsupportedAnimatedAttrs";
6113
- PxDiagnosticCode2[PxDiagnosticCode2["noBindings"] = 1105] = "noBindings";
6114
- PxDiagnosticCode2[PxDiagnosticCode2["unresolvedBinding"] = 1106] = "unresolvedBinding";
6115
- PxDiagnosticCode2[PxDiagnosticCode2["triggersNoRoot"] = 1201] = "triggersNoRoot";
6116
- PxDiagnosticCode2[PxDiagnosticCode2["noRootForSelector"] = 1202] = "noRootForSelector";
6117
- PxDiagnosticCode2[PxDiagnosticCode2["noRootElement"] = 1203] = "noRootElement";
6118
- PxDiagnosticCode2[PxDiagnosticCode2["noElementsForSelector"] = 1206] = "noElementsForSelector";
6119
- PxDiagnosticCode2[PxDiagnosticCode2["setAttributeNoElement"] = 1207] = "setAttributeNoElement";
6120
- PxDiagnosticCode2[PxDiagnosticCode2["scrollSmoothingNeedsOwnDriver"] = 1301] = "scrollSmoothingNeedsOwnDriver";
6121
- PxDiagnosticCode2[PxDiagnosticCode2["scrollNativeUnavailable"] = 1302] = "scrollNativeUnavailable";
6122
- PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectInvalid"] = 1303] = "scrollSubjectInvalid";
6123
- PxDiagnosticCode2[PxDiagnosticCode2["scrollSubjectNoMatch"] = 1304] = "scrollSubjectNoMatch";
6124
- PxDiagnosticCode2[PxDiagnosticCode2["scrollNoRootToObserve"] = 1305] = "scrollNoRootToObserve";
6125
- PxDiagnosticCode2[PxDiagnosticCode2["scrollTriggerIgnored"] = 1306] = "scrollTriggerIgnored";
6126
- PxDiagnosticCode2[PxDiagnosticCode2["rateRejected"] = 1401] = "rateRejected";
6127
- PxDiagnosticCode2[PxDiagnosticCode2["controlPropsConflict"] = 1501] = "controlPropsConflict";
6128
- PxDiagnosticCode2[PxDiagnosticCode2["rnCompileFailed"] = 1601] = "rnCompileFailed";
6129
- PxDiagnosticCode2[PxDiagnosticCode2["rnRenderFailed"] = 1602] = "rnRenderFailed";
6130
- PxDiagnosticCode2[PxDiagnosticCode2["rnBoundaryCaught"] = 1603] = "rnBoundaryCaught";
6131
- PxDiagnosticCode2[PxDiagnosticCode2["rnUnsupported"] = 1604] = "rnUnsupported";
6132
- return PxDiagnosticCode2;
6133
- })(PxDiagnosticCode || {});
6134
6199
  var FLAT_ONLY_KEYS = [
6135
6200
  "timelineSource",
6136
6201
  "scroll",
@@ -6417,7 +6482,6 @@ export {
6417
6482
  PX_TEXT_CONTENT_ATTR,
6418
6483
  isPxDocument,
6419
6484
  getAnimatorConfig,
6420
- getDefinitions,
6421
6485
  keyframeValue,
6422
6486
  keyframeEasing,
6423
6487
  PxTriggerSchema,
@@ -6448,21 +6512,21 @@ export {
6448
6512
  toDomProps,
6449
6513
  interpolateValue,
6450
6514
  normalizeBindings,
6515
+ materializeAllInTree,
6516
+ PxDiagnosticCode,
6451
6517
  PxDiagnosticKind,
6452
6518
  createDiagnostics,
6453
6519
  reportDocumentDiagnostics,
6454
- materializeAllInTree,
6455
6520
  isValidPlaybackRate,
6456
6521
  seekCeilingMs,
6457
6522
  clampSeekMs,
6458
6523
  timeToProgress,
6459
6524
  progressToTimeMs,
6460
6525
  createAdapterAnimator,
6461
- PxDiagnosticCode,
6462
6526
  foldTimelineOverride,
6463
6527
  applyAnimatorConfig,
6464
6528
  PLAY_WHEN_VISIBLE_DEFAULTS,
6465
6529
  createVisibilityGate,
6466
6530
  PX_ANIMATOR_DOC_KEY
6467
6531
  };
6468
- //# sourceMappingURL=chunk-ZEMEZT7X.js.map
6532
+ //# sourceMappingURL=chunk-QE7KJWAN.js.map