@pixodesk/svg-animator-web 1.0.41 → 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.
@@ -2440,7 +2440,6 @@ var PixodeskAnimator = (() => {
2440
2440
  }
2441
2441
 
2442
2442
  // ../svg-animator-core/src/playback/PxPlaybackTime.ts
2443
- var PX_RATE_REJECTED = "setPlaybackRate: rate must be finite and non-zero";
2444
2443
  function isValidPlaybackRate(rate) {
2445
2444
  return Number.isFinite(rate) && rate !== 0;
2446
2445
  }
@@ -2486,32 +2485,34 @@ var PixodeskAnimator = (() => {
2486
2485
  /** The player failed where it did not expect to — report it to us. */
2487
2486
  internal: "internal"
2488
2487
  };
2489
- function asError(error) {
2490
- return typeof error === "string" ? new Error(error) : error;
2488
+ var DOCS_URL = "https://github.com/pixodesk/pixodesk-svg-animator/blob/main/docs/diagnostics.md";
2489
+ function codeLine(code) {
2490
+ return "PX" + code + " " + DOCS_URL + "#px" + code;
2491
+ }
2492
+ function errorIn(data) {
2493
+ return data.find((d) => d instanceof Error);
2491
2494
  }
2492
2495
  function createDiagnostics(config, prefix) {
2493
2496
  const tag = prefix ? prefix + " " : "";
2494
2497
  return {
2495
- warn: (kind, message, detail) => {
2498
+ warn: (kind, code, ...data) => {
2499
+ const message = codeLine(code);
2496
2500
  if (config == null ? void 0 : config.onWarn) {
2497
- config.onWarn({ kind, message, detail });
2501
+ config.onWarn({ code, kind, data, message });
2498
2502
  return;
2499
2503
  }
2500
2504
  if (config == null ? void 0 : config.muteWarn) return;
2501
- const line = tag + kind + ": " + message;
2502
- if (detail === void 0) console.warn(line);
2503
- else console.warn(line, detail);
2505
+ console.warn(tag + kind + " " + message, ...data);
2504
2506
  },
2505
- error: (kind, error, detail) => {
2506
- const err = asError(error);
2507
+ error: (kind, code, ...data) => {
2508
+ const message = codeLine(code);
2509
+ const error = errorIn(data);
2507
2510
  if (config == null ? void 0 : config.onError) {
2508
- config.onError({ kind, message: err.message, error: err, detail });
2511
+ config.onError({ code, kind, data, message, error });
2509
2512
  return;
2510
2513
  }
2511
2514
  if (config == null ? void 0 : config.muteError) return;
2512
- const line = tag + kind + ": " + err.message;
2513
- if (detail === void 0) console.error(line);
2514
- else console.error(line, detail);
2515
+ console.error(tag + kind + " " + message, ...data);
2515
2516
  }
2516
2517
  };
2517
2518
  }
@@ -2574,7 +2575,7 @@ var PixodeskAnimator = (() => {
2574
2575
  const { startOn, outAction, scrollIntoViewThreshold } = resolveTrigger(trigger);
2575
2576
  const root = api.getRootElement();
2576
2577
  if (!root) {
2577
- report.warn(PxDiagnosticKind.host, "setupAnimationTriggers: No root element found for animation.");
2578
+ report.warn(PxDiagnosticKind.host, 1201 /* triggersNoRoot */);
2578
2579
  return dispose;
2579
2580
  }
2580
2581
  let reversed = false;
@@ -2790,9 +2791,9 @@ var PixodeskAnimator = (() => {
2790
2791
  if (doc.id) {
2791
2792
  const rootSelector = getSelector(doc.id);
2792
2793
  rootElement = document.querySelector(rootSelector);
2793
- if (!rootElement) diag.warn(PxDiagnosticKind.host, "createWebApiAnimator: No root element found for selector: " + rootSelector);
2794
+ if (!rootElement) diag.warn(PxDiagnosticKind.host, 1202 /* noRootForSelector */, rootSelector);
2794
2795
  } else {
2795
- diag.warn(PxDiagnosticKind.host, "createWebApiAnimator: No root element provided");
2796
+ diag.warn(PxDiagnosticKind.host, 1203 /* noRootElement */);
2796
2797
  }
2797
2798
  }
2798
2799
  const bindings = normalizeBindings(doc, PxTimelineEngine.native);
@@ -2805,18 +2806,18 @@ var PixodeskAnimator = (() => {
2805
2806
  let finishNotified = false;
2806
2807
  let removeCalled = false;
2807
2808
  if (!(bindings == null ? void 0 : bindings.length)) {
2808
- diag.warn(PxDiagnosticKind.document, "createWebApiAnimator: No animation bindings defined");
2809
+ diag.warn(PxDiagnosticKind.document, 1105 /* noBindings */);
2809
2810
  }
2810
2811
  for (const binding of bindings || []) {
2811
2812
  const animDef = binding.animate;
2812
2813
  if (!animDef || typeof animDef !== "object" || Array.isArray(animDef)) {
2813
- diag.warn(PxDiagnosticKind.document, "createWebApiAnimator: Empty or unresolved binding", binding);
2814
+ diag.warn(PxDiagnosticKind.document, 1106 /* unresolvedBinding */, binding);
2814
2815
  continue;
2815
2816
  }
2816
2817
  const selector = getSelector(binding.id);
2817
2818
  const elements = (rootElement == null ? void 0 : rootElement.querySelectorAll(selector)) || document.querySelectorAll(selector);
2818
2819
  if (elements.length === 0) {
2819
- diag.warn(PxDiagnosticKind.host, 'createWebApiAnimator: No elements found for selector "' + selector + '"');
2820
+ diag.warn(PxDiagnosticKind.host, 1206 /* noElementsForSelector */, selector);
2820
2821
  }
2821
2822
  const keyframesMap = convertToWebApiKeyframes(animDef, unsupportedSet, config);
2822
2823
  const positiveDelay = config.delay && config.delay > 0 ? config.delay : void 0;
@@ -2865,14 +2866,14 @@ var PixodeskAnimator = (() => {
2865
2866
  }
2866
2867
  animations.push(anim);
2867
2868
  } catch (e) {
2868
- diag.warn(PxDiagnosticKind.internal, "createWebApiAnimator: could not build the animation", e);
2869
+ diag.warn(PxDiagnosticKind.internal, 1004 /* animationBuildFailed */, e);
2869
2870
  }
2870
2871
  }
2871
2872
  }
2872
2873
  }
2873
2874
  }
2874
2875
  if (!forceEvenIfHasUnsupportedAttrs && unsupportedSet.size) {
2875
- diag.warn(PxDiagnosticKind.platform, "Unsupported CSS attrs: " + [...unsupportedSet].join(", "));
2876
+ diag.warn(PxDiagnosticKind.platform, 1104 /* unsupportedAnimatedAttrs */, [...unsupportedSet].join(", "));
2876
2877
  return null;
2877
2878
  }
2878
2879
  const api = {
@@ -2917,7 +2918,7 @@ var PixodeskAnimator = (() => {
2917
2918
  },
2918
2919
  "setPlaybackRate": (rate) => {
2919
2920
  if (!isValidPlaybackRate(rate)) {
2920
- diag.warn(PxDiagnosticKind.usage, PX_RATE_REJECTED);
2921
+ diag.warn(PxDiagnosticKind.usage, 1401 /* rateRejected */);
2921
2922
  return api;
2922
2923
  }
2923
2924
  animations.forEach((a) => a.playbackRate = rate);
@@ -2957,7 +2958,7 @@ var PixodeskAnimator = (() => {
2957
2958
  }
2958
2959
  };
2959
2960
  if (config.timelineSource === "scroll") {
2960
- if (config.trigger) diag.warn(PxDiagnosticKind.usage, "scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
2961
+ if (config.trigger) diag.warn(PxDiagnosticKind.usage, 1306 /* scrollTriggerIgnored */);
2961
2962
  } else {
2962
2963
  const detachTriggers = setupAnimationTriggers(api, (_b = config.trigger) != null ? _b : {}, diag);
2963
2964
  const destroyEngine = api.destroy.bind(api);
@@ -3001,7 +3002,7 @@ var PixodeskAnimator = (() => {
3001
3002
  return build();
3002
3003
  } catch (e) {
3003
3004
  const err = asThrownError(e);
3004
- createDiagnostics(options, "[PxAnimator]").error(PxDiagnosticKind.internal, "createAnimator: could not build the player \u2014 " + err.message, err);
3005
+ createDiagnostics(options, "[PxAnimator]").error(PxDiagnosticKind.internal, 1001 /* buildFailed */, err);
3005
3006
  return createInertAnimator();
3006
3007
  }
3007
3008
  }