@pixodesk/svg-animator-web 1.0.40 → 1.0.43

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.
@@ -545,7 +545,7 @@ var PixodeskAnimator = (() => {
545
545
  * The base can be the result of px.object() or px.openObject() — anything with a _shape property.
546
546
  *
547
547
  * @example
548
- * const PxSvgNodeSchema = px.extendedObject(PxNodeBase, { width: px.number().optional() });
548
+ * const PxSvgNodeSchema = px.extendedObject(PxNodeBaseSchema, { width: px.number().optional() });
549
549
  */
550
550
  extendedObject: (base, extra) => new Obj(__spreadValues(__spreadValues({}, base._shape), extra)),
551
551
  /** Array whose unrecoverable items are filtered out. Default: []. */
@@ -637,14 +637,14 @@ var PixodeskAnimator = (() => {
637
637
  native: "native",
638
638
  js: "js"
639
639
  };
640
- var PxTimelineEngineExtra = __spreadProps(__spreadValues({}, PxTimelineEngine), {
640
+ var PxTimelineEngineSetting = __spreadProps(__spreadValues({}, PxTimelineEngine), {
641
641
  auto: "auto"
642
642
  });
643
643
  function isNativeForced(engine) {
644
- return engine === PxTimelineEngineExtra.native;
644
+ return engine === PxTimelineEngineSetting.native;
645
645
  }
646
646
  function mayUseNativeScrollTimeline(engine) {
647
- return engine !== PxTimelineEngineExtra.js;
647
+ return engine !== PxTimelineEngineSetting.js;
648
648
  }
649
649
  var PX_TRIGGER_DEFAULTS = {
650
650
  startOn: "load",
@@ -786,7 +786,7 @@ var PixodeskAnimator = (() => {
786
786
  flattenMemo.set(cfg, flat);
787
787
  return flat;
788
788
  }
789
- function getDefs(doc) {
789
+ function getDefinitions(doc) {
790
790
  var _a;
791
791
  if (!doc) return void 0;
792
792
  return (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.definitions;
@@ -829,20 +829,20 @@ var PixodeskAnimator = (() => {
829
829
  // its internal COPY-PASTE payload, which never validates against this schema.)
830
830
  }));
831
831
  var anyKf = (kf) => kf;
832
- var kfTime = (kf) => {
832
+ var keyframeTime = (kf) => {
833
833
  var _a, _b;
834
834
  return (_b = (_a = anyKf(kf).time) != null ? _a : anyKf(kf).t) != null ? _b : 0;
835
835
  };
836
- var kfValue = (kf) => {
836
+ var keyframeValue = (kf) => {
837
837
  var _a;
838
838
  return (_a = anyKf(kf).value) != null ? _a : anyKf(kf).v;
839
839
  };
840
- var kfEasing = (kf) => {
840
+ var keyframeEasing = (kf) => {
841
841
  var _a;
842
842
  return (_a = anyKf(kf).easing) != null ? _a : anyKf(kf).e;
843
843
  };
844
- var kfTangentIn = (kf) => anyKf(kf).tangentIn;
845
- var kfTangentOut = (kf) => anyKf(kf).tangentOut;
844
+ var keyframeTangentIn = (kf) => anyKf(kf).tangentIn;
845
+ var keyframeTangentOut = (kf) => anyKf(kf).tangentOut;
846
846
  var PxLoopSchema = implementsInterface()(px.object({
847
847
  segmentCount: px.number().optional(),
848
848
  repeatAt: px.enum([PxLoopRepeatAt.start, PxLoopRepeatAt.end]).optional(),
@@ -896,7 +896,7 @@ var PixodeskAnimator = (() => {
896
896
  unitsPerEm: px.number(),
897
897
  glyphs: px.record(PxGlyphSchema)
898
898
  }));
899
- var PxDefsSchema = implementsInterface()(px.object({
899
+ var PxDefinitionsSchema = implementsInterface()(px.object({
900
900
  easings: px.record(px.tuple([px.number(), px.number(), px.number(), px.number()])).optional(),
901
901
  animations: px.record(PxAnimationDefinitionSchema).optional(),
902
902
  fonts: px.record(PxGlyphFontSchema).optional()
@@ -934,7 +934,7 @@ var PixodeskAnimator = (() => {
934
934
  offset: px.number().optional(),
935
935
  distance: px.number().optional()
936
936
  }));
937
- var PxTimelineEngineSchema = px.enum([PxTimelineEngineExtra.auto, PxTimelineEngineExtra.native, PxTimelineEngineExtra.js]).optional();
937
+ var PxTimelineEngineSchema = px.enum([PxTimelineEngineSetting.auto, PxTimelineEngineSetting.native, PxTimelineEngineSetting.js]).optional();
938
938
  var PxTimeTimelineSchema = implementsInterface()(px.object({
939
939
  type: px.literal("time").optional(),
940
940
  engine: PxTimelineEngineSchema,
@@ -988,7 +988,7 @@ var PixodeskAnimator = (() => {
988
988
  // at this level only on the runtime view, like the rest of the playback dynamics.)
989
989
  // THE spelling of "what advances progress" — clock / scroll / view (review §2.1).
990
990
  timeline: PxTimelineSchema.optional(),
991
- definitions: PxDefsSchema.optional(),
991
+ definitions: PxDefinitionsSchema.optional(),
992
992
  bindings: px.array(PxBindingSchema).optional(),
993
993
  debugGlobalName: px.string().optional(),
994
994
  // Declared HERE because this is a closed object: an undeclared key would be stripped by
@@ -1077,7 +1077,7 @@ var PixodeskAnimator = (() => {
1077
1077
  PxPropertyAnimationSchema
1078
1078
  ]);
1079
1079
  var PxFillGradientEffectSchema = implementsInterface()(px.object({
1080
- // Contextual kind — the `type` convention, see `PxNodeBase.type`.
1080
+ // Contextual kind — the `type` convention, see `PxNodeBaseSchema.type`.
1081
1081
  type: px.enum([PxGradientType.linear, PxGradientType.radial]),
1082
1082
  start: PxAnimatableVec2Schema.optional(),
1083
1083
  end: PxAnimatableVec2Schema.optional(),
@@ -1114,7 +1114,7 @@ var PixodeskAnimator = (() => {
1114
1114
  textPath: PxTextPathEffectSchema.optional(),
1115
1115
  text: PxTextEffectSchema.optional()
1116
1116
  }));
1117
- var PxNodeBase = px.openObject({
1117
+ var PxNodeBaseSchema = px.openObject({
1118
1118
  // CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
1119
1119
  // kind of thing is this", discriminated by its CARRIER — here the node TAG
1120
1120
  // (`rect`, `text`), and inside a sub-object that object's kind (`fillGradient.type`,
@@ -1129,7 +1129,7 @@ var PixodeskAnimator = (() => {
1129
1129
  // `type` is taken by the tag name, so the attribute travels here and the renderer puts
1130
1130
  // it back (`PxAnimatorDOM.renderNode`, `PxRnRender`). Declared here — not merely
1131
1131
  // documented — because a wire key that is not in a schema is invisible to the
1132
- // minifier's reserve list and gets renamed (MINIFICATION-BOUNDARY-PLAN.md §1.1).
1132
+ // minifier's reserve list and gets renamed (dev-docs/plans/minification-boundary.md §1.1).
1133
1133
  domType: px.string().optional(),
1134
1134
  // Text content of a `<text>` / `<tspan>`. Declared, so a non-string value is a schema error
1135
1135
  // and the minifier reserves the key; `text` is NOT an alias for it and is not read anywhere.
@@ -1137,7 +1137,7 @@ var PixodeskAnimator = (() => {
1137
1137
  id: px.string().optional(),
1138
1138
  meta: px.any().optional(),
1139
1139
  // Player-effects bucket emitted by the Editor's lightweight design format.
1140
- // Consumed and removed by `applyPlayerEffects` before any other normalization
1140
+ // Consumed and removed by `materializeNodeEffects` before any other normalization
1141
1141
  // (see `createAnimatorImpl`), so downstream code never sees it.
1142
1142
  effects: PxEffectsSchema.optional(),
1143
1143
  // `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
@@ -1146,10 +1146,10 @@ var PixodeskAnimator = (() => {
1146
1146
  animate: PxElementAnimationSchema.optional(),
1147
1147
  style: px.record(px.union([px.string(), px.number()])).optional()
1148
1148
  }, PxAttrValueSchema);
1149
- var PxNodeSchema = px.openObject(__spreadProps(__spreadValues({}, PxNodeBase._shape), {
1149
+ var PxNodeSchema = px.openObject(__spreadProps(__spreadValues({}, PxNodeBaseSchema._shape), {
1150
1150
  children: px.lazy(() => px.array(PxNodeSchema), []).optional()
1151
1151
  }), PxAttrValueSchema);
1152
- var PxSvgNodeExtra = px.object({
1152
+ var PxSvgNodeRootSchema = px.object({
1153
1153
  // `"100%"` and other SVG length strings are legal here — a number-only slot rejected
1154
1154
  // real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
1155
1155
  width: px.union([px.number(), px.string()]).optional(),
@@ -1157,7 +1157,7 @@ var PixodeskAnimator = (() => {
1157
1157
  viewBox: px.string().optional(),
1158
1158
  animator: PxAnimatorConfigSchema.optional()
1159
1159
  });
1160
- var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps(__spreadValues(__spreadValues({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
1160
+ var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps(__spreadValues(__spreadValues({}, PxNodeBaseSchema._shape), PxSvgNodeRootSchema._shape), {
1161
1161
  type: px.literal("svg"),
1162
1162
  // override string → literal to require 'svg'
1163
1163
  children: px.array(PxNodeSchema).optional()
@@ -1399,9 +1399,9 @@ var PixodeskAnimator = (() => {
1399
1399
  }
1400
1400
  return void 0;
1401
1401
  }
1402
- var COLOR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
1403
- var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
1404
- var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
1402
+ var PX_COLOR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
1403
+ var PX_TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
1404
+ var PX_PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
1405
1405
  function composeTransformParts(parts, opts) {
1406
1406
  var _a;
1407
1407
  if (!parts) return "";
@@ -1454,8 +1454,8 @@ var PixodeskAnimator = (() => {
1454
1454
  if (str.replace(/([a-zA-Z]+)\s*\(([^)]*)\)/g, "").replace(/[\s,]/g, "").length) return void 0;
1455
1455
  return Object.keys(out).length ? out : void 0;
1456
1456
  }
1457
- var STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
1458
- var DEFAULT_DURATION_MS = 1e3;
1457
+ var PX_STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
1458
+ var PX_DEFAULT_DURATION_MS = 1e3;
1459
1459
  function kebabToCamelCaseWord(kebab) {
1460
1460
  return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
1461
1461
  }
@@ -1601,7 +1601,7 @@ var PixodeskAnimator = (() => {
1601
1601
 
1602
1602
  // ../svg-animator-core/src/materialize/PxMotionPath.ts
1603
1603
  function getKfTranslate(kf) {
1604
- const v = kfValue(kf);
1604
+ const v = keyframeValue(kf);
1605
1605
  if (!v) return void 0;
1606
1606
  if (Array.isArray(v) && v.length >= 2 && typeof v[0] === "number" && typeof v[1] === "number") {
1607
1607
  return [v[0], v[1]];
@@ -1611,17 +1611,17 @@ var PixodeskAnimator = (() => {
1611
1611
  return void 0;
1612
1612
  }
1613
1613
  function getKfTime(kf) {
1614
- return kfTime(kf);
1614
+ return keyframeTime(kf);
1615
1615
  }
1616
1616
  function getKfEasing(kf) {
1617
- return kfEasing(kf);
1617
+ return keyframeEasing(kf);
1618
1618
  }
1619
1619
  function propAnimIsMotionPath(anim) {
1620
1620
  const kfs = anim.keyframes;
1621
1621
  if (!Array.isArray(kfs)) return false;
1622
1622
  if (anim.autoOrient) return true;
1623
1623
  for (const kf of kfs) {
1624
- if (kfTangentIn(kf) || kfTangentOut(kf)) return true;
1624
+ if (keyframeTangentIn(kf) || keyframeTangentOut(kf)) return true;
1625
1625
  }
1626
1626
  return false;
1627
1627
  }
@@ -1630,8 +1630,8 @@ var PixodeskAnimator = (() => {
1630
1630
  let byNext = _segmentCache.get(prevKf);
1631
1631
  const existing = byNext == null ? void 0 : byNext.get(nextKf);
1632
1632
  if (existing) return existing;
1633
- const to = kfTangentOut(prevKf);
1634
- const ti = kfTangentIn(nextKf);
1633
+ const to = keyframeTangentOut(prevKf);
1634
+ const ti = keyframeTangentIn(nextKf);
1635
1635
  const P1 = [prevPos[0] + (to ? to[0] : 0), prevPos[1] + (to ? to[1] : 0)];
1636
1636
  const P2 = [nextPos[0] + (ti ? ti[0] : 0), nextPos[1] + (ti ? ti[1] : 0)];
1637
1637
  const lut = bezier2D_arcLengthLUT(prevPos, P1, P2, nextPos);
@@ -1724,7 +1724,7 @@ var PixodeskAnimator = (() => {
1724
1724
  function unwrapAutoOrientRotations(kfs) {
1725
1725
  let prev;
1726
1726
  for (const kf of kfs) {
1727
- const v = kfValue(kf);
1727
+ const v = keyframeValue(kf);
1728
1728
  if (!v || typeof v.rotate !== "number") continue;
1729
1729
  if (prev === void 0) {
1730
1730
  prev = v.rotate;
@@ -1741,7 +1741,7 @@ var PixodeskAnimator = (() => {
1741
1741
  return { t: time, v: value };
1742
1742
  }
1743
1743
  function getKfValueParts(kf) {
1744
- const v = kfValue(kf);
1744
+ const v = keyframeValue(kf);
1745
1745
  if (!v || typeof v !== "object" || Array.isArray(v)) return void 0;
1746
1746
  return v;
1747
1747
  }
@@ -1803,7 +1803,7 @@ var PixodeskAnimator = (() => {
1803
1803
  }
1804
1804
  function insertSharpCornerStepKfIfNeeded(out, prevKf, nextKf, prevPos, nextPos, rotationTol) {
1805
1805
  const lastKf = out[out.length - 1];
1806
- const lastV = kfValue(lastKf);
1806
+ const lastV = keyframeValue(lastKf);
1807
1807
  const prevExit = lastV == null ? void 0 : lastV.rotate;
1808
1808
  if (typeof prevExit !== "number") return;
1809
1809
  const boundaryV = getKfValueParts(prevKf);
@@ -1951,7 +1951,7 @@ var PixodeskAnimator = (() => {
1951
1951
  }
1952
1952
 
1953
1953
  // ../svg-animator-core/src/animation/PxDefinitions.ts
1954
- var LOOP_JUMP_SHIFT_MS = 1;
1954
+ var PX_LOOP_JUMP_SHIFT_MS = 1;
1955
1955
  function deepEqualValue(a, b) {
1956
1956
  if (a === b) return true;
1957
1957
  if (typeof a !== typeof b || a === null || b === null || typeof a !== "object") return false;
@@ -2127,7 +2127,7 @@ var PixodeskAnimator = (() => {
2127
2127
  const bPaths = (_b = b == null ? void 0 : b.paths) != null ? _b : Array.isArray(b) ? b : [];
2128
2128
  return { paths: interpolateBeziers(aPaths, bPaths, t) };
2129
2129
  }
2130
- if (COLOR_ATTR_NAMES.has(propName)) {
2130
+ if (PX_COLOR_ATTR_NAMES.has(propName)) {
2131
2131
  return interpolateColor(a || [0, 0, 0, 1], b || [0, 0, 0, 1], t);
2132
2132
  }
2133
2133
  if (propName === "transform" && typeof a === "object" && a !== null && !Array.isArray(a) && typeof b === "object" && b !== null && !Array.isArray(b)) {
@@ -2136,7 +2136,7 @@ var PixodeskAnimator = (() => {
2136
2136
  if (propName === "rotate" && typeof a === "number" && typeof b === "number") {
2137
2137
  return interpolateNum(a, b, t);
2138
2138
  }
2139
- if (TRANSFORM_FN_NAMES.has(propName) || propName === "stroke-dasharray" || propName === "strokeDasharray") {
2139
+ if (PX_TRANSFORM_FN_NAMES.has(propName) || propName === "stroke-dasharray" || propName === "strokeDasharray") {
2140
2140
  return interpolateVec(a || [], b || [], t);
2141
2141
  }
2142
2142
  return interpolateNum(+(a || 0), +(b || 0), t);
@@ -2188,8 +2188,8 @@ var PixodeskAnimator = (() => {
2188
2188
  relT: (kf.t - segStartT) / segDuration,
2189
2189
  v: kf.v,
2190
2190
  e: kf.e,
2191
- tangentIn: kfTangentIn(kf),
2192
- tangentOut: kfTangentOut(kf)
2191
+ tangentIn: keyframeTangentIn(kf),
2192
+ tangentOut: keyframeTangentOut(kf)
2193
2193
  }));
2194
2194
  const fullReps = Math.floor(fillDuration / segDuration);
2195
2195
  const remainder = fillDuration - fullReps * segDuration;
@@ -2255,7 +2255,7 @@ var PixodeskAnimator = (() => {
2255
2255
  }
2256
2256
  }
2257
2257
  const pushed = {
2258
- t: repStart + entry.relT * segDuration + (isBoundary ? LOOP_JUMP_SHIFT_MS : 0),
2258
+ t: repStart + entry.relT * segDuration + (isBoundary ? PX_LOOP_JUMP_SHIFT_MS : 0),
2259
2259
  v: entry.v,
2260
2260
  e: i < entries.length - 1 ? entry.e : void 0
2261
2261
  };
@@ -2342,14 +2342,14 @@ var PixodeskAnimator = (() => {
2342
2342
  const keyframes = propAnim.keyframes || [];
2343
2343
  const normalized = [];
2344
2344
  for (const kf of keyframes) {
2345
- const timePct = kfTime(kf);
2346
- let value = kfValue(kf);
2347
- const easing = kfEasing(kf);
2345
+ const timePct = keyframeTime(kf);
2346
+ let value = keyframeValue(kf);
2347
+ const easing = keyframeEasing(kf);
2348
2348
  if (propName === "d") {
2349
2349
  value = normalizePathValue(value);
2350
2350
  }
2351
2351
  const propNameKebab = isCamelCaseWord(propName) ? camelCaseToKebabWordIfNeeded(propName) : propName;
2352
- if (COLOR_ATTR_NAMES.has(propNameKebab)) {
2352
+ if (PX_COLOR_ATTR_NAMES.has(propNameKebab)) {
2353
2353
  value = (_a = parseColor(value)) != null ? _a : value;
2354
2354
  }
2355
2355
  const normKf = {
@@ -2357,8 +2357,8 @@ var PixodeskAnimator = (() => {
2357
2357
  v: value,
2358
2358
  e: resolveEasing(easing, defs)
2359
2359
  };
2360
- const tIn = kfTangentIn(kf);
2361
- const tOut = kfTangentOut(kf);
2360
+ const tIn = keyframeTangentIn(kf);
2361
+ const tOut = keyframeTangentOut(kf);
2362
2362
  if (tIn) normKf.tangentIn = tIn;
2363
2363
  if (tOut) normKf.tangentOut = tOut;
2364
2364
  normalized.push(normKf);
@@ -2404,7 +2404,7 @@ var PixodeskAnimator = (() => {
2404
2404
  }
2405
2405
  return animDef;
2406
2406
  }
2407
- const channels = Object.keys(animDef).filter((k) => TRANSFORM_FN_NAMES.has(k));
2407
+ const channels = Object.keys(animDef).filter((k) => PX_TRANSFORM_FN_NAMES.has(k));
2408
2408
  if (channels.length !== 1) return animDef;
2409
2409
  const ch = channels[0];
2410
2410
  const chAnim = animDef[ch];
@@ -2433,9 +2433,9 @@ var PixodeskAnimator = (() => {
2433
2433
  }
2434
2434
  return normalized;
2435
2435
  }
2436
- function getNormalizedBindings(doc, engine = PxTimelineEngine.native) {
2436
+ function normalizeBindings(doc, engine = PxTimelineEngine.native) {
2437
2437
  const animatorConfig = getAnimatorConfig(doc) || {};
2438
- const defs = getDefs(doc);
2438
+ const defs = getDefinitions(doc);
2439
2439
  const duration = animatorConfig.duration || 1e3;
2440
2440
  const bindings = [];
2441
2441
  const processAnimation = (id, animDefs, staticTransform) => {
@@ -2505,7 +2505,7 @@ var PixodeskAnimator = (() => {
2505
2505
  const { prevKf, nextKf } = getKeyframesPair(keyframes, progress);
2506
2506
  let localProgress = prevKf === nextKf ? 0 : remap(progress, (_a = prevKf.t) != null ? _a : 0, (_b = nextKf.t) != null ? _b : 0, 0, 1);
2507
2507
  localProgress = clamp(localProgress, 0, 1);
2508
- const easing = kfEasing(prevKf);
2508
+ const easing = keyframeEasing(prevKf);
2509
2509
  if (easing && Array.isArray(easing)) {
2510
2510
  try {
2511
2511
  localProgress = cubicBezier(easing)(localProgress);
@@ -2524,7 +2524,7 @@ var PixodeskAnimator = (() => {
2524
2524
  nextPaths,
2525
2525
  localProgress
2526
2526
  ).map((bz) => bezierToSvgPath(bz)).join("");
2527
- } else if (COLOR_ATTR_NAMES.has(cssAttrName)) {
2527
+ } else if (PX_COLOR_ATTR_NAMES.has(cssAttrName)) {
2528
2528
  cssValue = toRGBA(interpolateColor(
2529
2529
  prevV || [0, 0, 0, 1],
2530
2530
  nextV || [0, 0, 0, 1],
@@ -2605,7 +2605,7 @@ var PixodeskAnimator = (() => {
2605
2605
  );
2606
2606
  cssValue = num;
2607
2607
  }
2608
- if (PCT_BASED_ATTR_NAMES.has(cssAttrName) && typeof cssValue === "number") {
2608
+ if (PX_PCT_BASED_ATTR_NAMES.has(cssAttrName) && typeof cssValue === "number") {
2609
2609
  cssValue = cssValue * 100 + "%";
2610
2610
  }
2611
2611
  return { k: cssAttrName, v: cssValue === null ? "" : "" + cssValue };
@@ -2669,16 +2669,16 @@ var PixodeskAnimator = (() => {
2669
2669
  }
2670
2670
  g.clearTimeout(handle);
2671
2671
  }
2672
- function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
2672
+ function createAdapterAnimator(doc, adapter, callbacks) {
2673
2673
  var _a;
2674
2674
  const config = getAnimatorConfig(doc) || {};
2675
- const bindings = getNormalizedBindings(doc, PxTimelineEngine.js);
2675
+ const bindings = normalizeBindings(doc, PxTimelineEngine.js);
2676
2676
  const _iterations = config.iterations;
2677
2677
  let iterations = 1;
2678
2678
  if (typeof _iterations === "number") iterations = _iterations || 1;
2679
2679
  if (_iterations === "infinite") iterations = Infinity;
2680
2680
  if (iterations < 1) iterations = 1;
2681
- const duration = +(config.duration || DEFAULT_DURATION_MS);
2681
+ const duration = +(config.duration || PX_DEFAULT_DURATION_MS);
2682
2682
  const totalDuration = duration && iterations ? duration * (iterations === Infinity ? Infinity : iterations) : duration ? (iterations != null ? iterations : 1) * duration : 0;
2683
2683
  const direction = config.direction || "normal";
2684
2684
  const fill = (_a = config.fill) != null ? _a : "forwards";
@@ -2949,32 +2949,34 @@ var PixodeskAnimator = (() => {
2949
2949
  /** The player failed where it did not expect to — report it to us. */
2950
2950
  internal: "internal"
2951
2951
  };
2952
- function asError(error) {
2953
- return typeof error === "string" ? new Error(error) : error;
2952
+ var DOCS_URL = "https://github.com/pixodesk/pixodesk-svg-animator/blob/main/docs/diagnostics.md";
2953
+ function codeLine(code) {
2954
+ return "PX" + code + " " + DOCS_URL + "#px" + code;
2955
+ }
2956
+ function errorIn(data) {
2957
+ return data.find((d) => d instanceof Error);
2954
2958
  }
2955
2959
  function createDiagnostics(config, prefix) {
2956
2960
  const tag = prefix ? prefix + " " : "";
2957
2961
  return {
2958
- warn: (kind, message, detail) => {
2962
+ warn: (kind, code, ...data) => {
2963
+ const message = codeLine(code);
2959
2964
  if (config == null ? void 0 : config.onWarn) {
2960
- config.onWarn({ kind, message, detail });
2965
+ config.onWarn({ code, kind, data, message });
2961
2966
  return;
2962
2967
  }
2963
2968
  if (config == null ? void 0 : config.muteWarn) return;
2964
- const line = tag + kind + ": " + message;
2965
- if (detail === void 0) console.warn(line);
2966
- else console.warn(line, detail);
2969
+ console.warn(tag + kind + " " + message, ...data);
2967
2970
  },
2968
- error: (kind, error, detail) => {
2969
- const err = asError(error);
2971
+ error: (kind, code, ...data) => {
2972
+ const message = codeLine(code);
2973
+ const error = errorIn(data);
2970
2974
  if (config == null ? void 0 : config.onError) {
2971
- config.onError({ kind, message: err.message, error: err, detail });
2975
+ config.onError({ code, kind, data, message, error });
2972
2976
  return;
2973
2977
  }
2974
2978
  if (config == null ? void 0 : config.muteError) return;
2975
- const line = tag + kind + ": " + err.message;
2976
- if (detail === void 0) console.error(line);
2977
- else console.error(line, detail);
2979
+ console.error(tag + kind + " " + message, ...data);
2978
2980
  }
2979
2981
  };
2980
2982
  }
@@ -2984,7 +2986,7 @@ var PixodeskAnimator = (() => {
2984
2986
  return (config == null ? void 0 : config.timelineSource) === "scroll";
2985
2987
  }
2986
2988
  function scrollTotalDurationMs(config) {
2987
- const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration : DEFAULT_DURATION_MS;
2989
+ const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration : PX_DEFAULT_DURATION_MS;
2988
2990
  const iterations = typeof (config == null ? void 0 : config.iterations) === "number" && config.iterations > 0 ? config.iterations : 1;
2989
2991
  return duration * iterations;
2990
2992
  }
@@ -3084,16 +3086,16 @@ var PixodeskAnimator = (() => {
3084
3086
  }
3085
3087
 
3086
3088
  // src/triggers/PxAnimatorTriggers.ts
3087
- function setupAnimationTriggers(api, config, diag) {
3089
+ function setupAnimationTriggers(api, trigger, diag) {
3088
3090
  const report = diag != null ? diag : createDiagnostics(void 0, "[PxAnimator]");
3089
3091
  const cleanups = [];
3090
3092
  const dispose = () => {
3091
3093
  for (const undo of cleanups.splice(0)) undo();
3092
3094
  };
3093
- const { startOn, outAction, scrollIntoViewThreshold } = resolveTrigger(config);
3095
+ const { startOn, outAction, scrollIntoViewThreshold } = resolveTrigger(trigger);
3094
3096
  const root = api.getRootElement();
3095
3097
  if (!root) {
3096
- report.warn(PxDiagnosticKind.host, "setupAnimationTriggers: No root element found for animation.");
3098
+ report.warn(PxDiagnosticKind.host, 1201 /* triggersNoRoot */);
3097
3099
  return dispose;
3098
3100
  }
3099
3101
  let reversed = false;
@@ -3212,12 +3214,12 @@ var PixodeskAnimator = (() => {
3212
3214
  if (doc.id) {
3213
3215
  const rootSelector = getSelector(doc.id);
3214
3216
  rootElement = document.querySelector(rootSelector);
3215
- if (!rootElement) diag.warn(PxDiagnosticKind.host, "createFrameLoopAnimator: No root element found for selector: " + rootSelector);
3217
+ if (!rootElement) diag.warn(PxDiagnosticKind.host, 1202 /* noRootForSelector */, rootSelector);
3216
3218
  } else {
3217
- diag.warn(PxDiagnosticKind.host, "createFrameLoopAnimator: No root element provided");
3219
+ diag.warn(PxDiagnosticKind.host, 1203 /* noRootElement */);
3218
3220
  }
3219
3221
  }
3220
- const basicApi = createBasicFrameLoopAnimator(
3222
+ const basicApi = createAdapterAnimator(
3221
3223
  doc,
3222
3224
  adapter || createDomAdapter(rootElement, diag),
3223
3225
  callbacks
@@ -3226,7 +3228,7 @@ var PixodeskAnimator = (() => {
3226
3228
  "getRootElement": () => rootElement || null
3227
3229
  });
3228
3230
  if (isScrollTimeline(config)) {
3229
- if (config.trigger) diag.warn(PxDiagnosticKind.usage, "scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
3231
+ if (config.trigger) diag.warn(PxDiagnosticKind.usage, 1306 /* scrollTriggerIgnored */);
3230
3232
  } else {
3231
3233
  const detachTriggers = setupAnimationTriggers(api, (_a = config.trigger) != null ? _a : {}, diag);
3232
3234
  const destroyEngine = api.destroy.bind(api);
@@ -3251,13 +3253,13 @@ var PixodeskAnimator = (() => {
3251
3253
  const elements = (rootElement == null ? void 0 : rootElement.querySelectorAll(selector)) || document.querySelectorAll(selector);
3252
3254
  if (elements.length === 0 && !warnedSelectors.has(selector)) {
3253
3255
  warnedSelectors.add(selector);
3254
- report.warn(PxDiagnosticKind.host, 'setAttribute: No elements found for selector "' + selector + '"');
3256
+ report.warn(PxDiagnosticKind.host, 1207 /* setAttributeNoElement */, selector);
3255
3257
  }
3256
3258
  for (let i = 0; i < elements.length; i++) {
3257
3259
  const element = elements[i];
3258
3260
  const effectiveAttrName = attrName === "transform" && element.tagName === "pattern" ? "patternTransform" : attrName;
3259
3261
  element.setAttribute(effectiveAttrName, value);
3260
- if (STYLE_ATTR_NAMES.has(attrName)) {
3262
+ if (PX_STYLE_ATTR_NAMES.has(attrName)) {
3261
3263
  element.style[attrName] = value;
3262
3264
  }
3263
3265
  }
@@ -3268,20 +3270,20 @@ var PixodeskAnimator = (() => {
3268
3270
 
3269
3271
  // src/engines/PxAnimatorWebApi.ts
3270
3272
  function createCssKf(kf, t, propName, unsupportedSet) {
3271
- let value = kfValue(kf);
3272
- const e = kfEasing(kf);
3273
+ let value = keyframeValue(kf);
3274
+ const e = keyframeEasing(kf);
3273
3275
  const cssKf = {
3274
3276
  offset: t,
3275
3277
  easing: e && Array.isArray(e) ? "cubic-bezier(" + e.join(",") + ")" : void 0
3276
3278
  };
3277
3279
  let cssValue;
3278
3280
  let cssKey = propName;
3279
- if (COLOR_ATTR_NAMES.has(propName) && Array.isArray(value)) {
3281
+ if (PX_COLOR_ATTR_NAMES.has(propName) && Array.isArray(value)) {
3280
3282
  cssValue = toRGBA(value);
3281
3283
  } else if (propName === "transform" && value !== null && typeof value === "object" && !Array.isArray(value)) {
3282
3284
  cssValue = composeTransformParts(value, { withUnits: true });
3283
3285
  cssKey = "transform";
3284
- } else if (TRANSFORM_FN_NAMES.has(propName)) {
3286
+ } else if (PX_TRANSFORM_FN_NAMES.has(propName)) {
3285
3287
  if (Array.isArray(value)) {
3286
3288
  if (propName === "translate") value = value.map((v) => v + "px");
3287
3289
  value = value.join(",");
@@ -3292,7 +3294,7 @@ var PixodeskAnimator = (() => {
3292
3294
  } else if (propName === "d") {
3293
3295
  const paths = value && typeof value === "object" && Array.isArray(value.paths) ? value.paths : [];
3294
3296
  cssValue = 'path("' + paths.map((bz) => bezierToSvgPath(bz, true)).join("") + '")';
3295
- } else if (PCT_BASED_ATTR_NAMES.has(propName) && typeof value === "number") {
3297
+ } else if (PX_PCT_BASED_ATTR_NAMES.has(propName) && typeof value === "number") {
3296
3298
  cssValue = value * 100 + "%";
3297
3299
  } else {
3298
3300
  cssValue = "" + value;
@@ -3370,12 +3372,12 @@ var PixodeskAnimator = (() => {
3370
3372
  if (doc.id) {
3371
3373
  const rootSelector = getSelector(doc.id);
3372
3374
  rootElement = document.querySelector(rootSelector);
3373
- if (!rootElement) diag.warn(PxDiagnosticKind.host, "createWebApiAnimator: No root element found for selector: " + rootSelector);
3375
+ if (!rootElement) diag.warn(PxDiagnosticKind.host, 1202 /* noRootForSelector */, rootSelector);
3374
3376
  } else {
3375
- diag.warn(PxDiagnosticKind.host, "createWebApiAnimator: No root element provided");
3377
+ diag.warn(PxDiagnosticKind.host, 1203 /* noRootElement */);
3376
3378
  }
3377
3379
  }
3378
- const bindings = getNormalizedBindings(doc, PxTimelineEngine.native);
3380
+ const bindings = normalizeBindings(doc, PxTimelineEngine.native);
3379
3381
  const animations = [];
3380
3382
  const _iterations = config.iterations;
3381
3383
  let iterations;
@@ -3385,18 +3387,18 @@ var PixodeskAnimator = (() => {
3385
3387
  let finishNotified = false;
3386
3388
  let removeCalled = false;
3387
3389
  if (!(bindings == null ? void 0 : bindings.length)) {
3388
- diag.warn(PxDiagnosticKind.document, "createWebApiAnimator: No animation bindings defined");
3390
+ diag.warn(PxDiagnosticKind.document, 1105 /* noBindings */);
3389
3391
  }
3390
3392
  for (const binding of bindings || []) {
3391
3393
  const animDef = binding.animate;
3392
3394
  if (!animDef || typeof animDef !== "object" || Array.isArray(animDef)) {
3393
- diag.warn(PxDiagnosticKind.document, "createWebApiAnimator: Empty or unresolved binding", binding);
3395
+ diag.warn(PxDiagnosticKind.document, 1106 /* unresolvedBinding */, binding);
3394
3396
  continue;
3395
3397
  }
3396
3398
  const selector = getSelector(binding.id);
3397
3399
  const elements = (rootElement == null ? void 0 : rootElement.querySelectorAll(selector)) || document.querySelectorAll(selector);
3398
3400
  if (elements.length === 0) {
3399
- diag.warn(PxDiagnosticKind.host, 'createWebApiAnimator: No elements found for selector "' + selector + '"');
3401
+ diag.warn(PxDiagnosticKind.host, 1206 /* noElementsForSelector */, selector);
3400
3402
  }
3401
3403
  const keyframesMap = convertToWebApiKeyframes(animDef, unsupportedSet, config);
3402
3404
  const positiveDelay = config.delay && config.delay > 0 ? config.delay : void 0;
@@ -3445,14 +3447,14 @@ var PixodeskAnimator = (() => {
3445
3447
  }
3446
3448
  animations.push(anim);
3447
3449
  } catch (e) {
3448
- diag.warn(PxDiagnosticKind.internal, "createWebApiAnimator: could not build the animation", e);
3450
+ diag.warn(PxDiagnosticKind.internal, 1004 /* animationBuildFailed */, e);
3449
3451
  }
3450
3452
  }
3451
3453
  }
3452
3454
  }
3453
3455
  }
3454
3456
  if (!forceEvenIfHasUnsupportedAttrs && unsupportedSet.size) {
3455
- diag.warn(PxDiagnosticKind.platform, "Unsupported CSS attrs: " + [...unsupportedSet].join(", "));
3457
+ diag.warn(PxDiagnosticKind.platform, 1104 /* unsupportedAnimatedAttrs */, [...unsupportedSet].join(", "));
3456
3458
  return null;
3457
3459
  }
3458
3460
  const api = {
@@ -3497,7 +3499,7 @@ var PixodeskAnimator = (() => {
3497
3499
  },
3498
3500
  "setPlaybackRate": (rate) => {
3499
3501
  if (!isValidPlaybackRate(rate)) {
3500
- diag.warn(PxDiagnosticKind.usage, PX_RATE_REJECTED);
3502
+ diag.warn(PxDiagnosticKind.usage, 1401 /* rateRejected */);
3501
3503
  return api;
3502
3504
  }
3503
3505
  animations.forEach((a) => a.playbackRate = rate);
@@ -3537,7 +3539,7 @@ var PixodeskAnimator = (() => {
3537
3539
  }
3538
3540
  };
3539
3541
  if (config.timelineSource === "scroll") {
3540
- if (config.trigger) diag.warn(PxDiagnosticKind.usage, "scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
3542
+ if (config.trigger) diag.warn(PxDiagnosticKind.usage, 1306 /* scrollTriggerIgnored */);
3541
3543
  } else {
3542
3544
  const detachTriggers = setupAnimationTriggers(api, (_b = config.trigger) != null ? _b : {}, diag);
3543
3545
  const destroyEngine = api.destroy.bind(api);
@@ -3567,7 +3569,7 @@ var PixodeskAnimator = (() => {
3567
3569
  const scroll = config.scroll || {};
3568
3570
  const kind = (_a = scroll.kind) != null ? _a : "view";
3569
3571
  if (scroll.smoothing) {
3570
- report.warn(PxDiagnosticKind.platform, "scroll timeline: `smoothing` needs the built-in driver \u2014 using the built-in driver instead of the browser timeline");
3572
+ report.warn(PxDiagnosticKind.platform, 1301 /* scrollSmoothingNeedsOwnDriver */);
3571
3573
  return null;
3572
3574
  }
3573
3575
  const g = globalThis;
@@ -3584,7 +3586,7 @@ var PixodeskAnimator = (() => {
3584
3586
  timeline = new Ctor({ source, axis });
3585
3587
  }
3586
3588
  } catch (e) {
3587
- report.warn(PxDiagnosticKind.platform, "scroll timeline: native timeline construction failed \u2014 falling back to the player measuring progress itself", e);
3589
+ report.warn(PxDiagnosticKind.platform, 1302 /* scrollNativeUnavailable */, e);
3588
3590
  return null;
3589
3591
  }
3590
3592
  return {
@@ -3631,11 +3633,11 @@ var PixodeskAnimator = (() => {
3631
3633
  try {
3632
3634
  found = document.querySelector(spec);
3633
3635
  } catch (e) {
3634
- report.warn(PxDiagnosticKind.document, 'scroll timeline: subject "' + spec + '" is not a valid selector \u2014 measuring the SVG itself');
3636
+ report.warn(PxDiagnosticKind.document, 1303 /* scrollSubjectInvalid */, spec);
3635
3637
  return svgRoot;
3636
3638
  }
3637
3639
  if (!found) {
3638
- report.warn(PxDiagnosticKind.host, 'scroll timeline: subject "' + spec + '" matched no element \u2014 measuring the SVG itself');
3640
+ report.warn(PxDiagnosticKind.host, 1304 /* scrollSubjectNoMatch */, spec);
3639
3641
  return svgRoot;
3640
3642
  }
3641
3643
  return found;
@@ -3857,7 +3859,7 @@ var PixodeskAnimator = (() => {
3857
3859
  unpin = () => {
3858
3860
  };
3859
3861
  }
3860
- const api = (animatorConfig.engine !== PxTimelineEngineExtra.js ? createWebApiAnimator(doc, cb, rootElement, isNativeForced(animatorConfig.engine)) : null) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
3862
+ const api = (animatorConfig.engine !== PxTimelineEngineSetting.js ? createWebApiAnimator(doc, cb, rootElement, isNativeForced(animatorConfig.engine)) : null) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
3861
3863
  const subject = ((_a = api.getRootElement) == null ? void 0 : _a.call(api)) || rootElement;
3862
3864
  if (subject) {
3863
3865
  unpin = applyScrollPin(subject, animatorConfig.scroll);
@@ -3877,13 +3879,13 @@ var PixodeskAnimator = (() => {
3877
3879
  };
3878
3880
  }
3879
3881
  } else {
3880
- diag.warn(PxDiagnosticKind.host, "scroll timeline: no root element to observe \u2014 animation will stay at frame 0");
3882
+ diag.warn(PxDiagnosticKind.host, 1305 /* scrollNoRootToObserve */);
3881
3883
  }
3882
3884
  return api;
3883
3885
  });
3884
3886
  }
3885
3887
  return finaliseAnimator(animatorConfig, callbacks, (cb) => {
3886
- if (animatorConfig.engine === PxTimelineEngineExtra.js) {
3888
+ if (animatorConfig.engine === PxTimelineEngineSetting.js) {
3887
3889
  return createFrameLoopAnimator(doc, adapter, cb, rootElement);
3888
3890
  }
3889
3891
  return createWebApiAnimator(
@@ -3903,7 +3905,7 @@ var PixodeskAnimator = (() => {
3903
3905
  return build();
3904
3906
  } catch (e) {
3905
3907
  const err = asThrownError(e);
3906
- createDiagnostics(options, "[PxAnimator]").error(PxDiagnosticKind.internal, "createAnimator: could not build the player \u2014 " + err.message, err);
3908
+ createDiagnostics(options, "[PxAnimator]").error(PxDiagnosticKind.internal, 1001 /* buildFailed */, err);
3907
3909
  return createInertAnimator();
3908
3910
  }
3909
3911
  }