@pixodesk/svg-animator-web 1.0.43 → 1.0.44

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/index.cjs CHANGED
@@ -60,7 +60,9 @@ __export(index_exports, {
60
60
  createAdapterAnimator: () => createAdapterAnimator,
61
61
  createAnimator: () => createAnimator,
62
62
  generateNewIds: () => generateNewIds,
63
+ getAllAnimators: () => getAllAnimators,
63
64
  loadTagAnimators: () => loadTagAnimators,
65
+ onAnimatorsChange: () => onAnimatorsChange,
64
66
  px: () => px,
65
67
  renderNode: () => renderNode,
66
68
  setupAnimationTriggers: () => setupAnimationTriggers,
@@ -69,7 +71,7 @@ __export(index_exports, {
69
71
  });
70
72
  module.exports = __toCommonJS(index_exports);
71
73
 
72
- // ../svg-animator-core/dist/chunk-BOTZI36B.js
74
+ // ../svg-animator-core/dist/chunk-EFQLDGFY.js
73
75
  var __defProp2 = Object.defineProperty;
74
76
  var __defProps2 = Object.defineProperties;
75
77
  var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
@@ -603,7 +605,7 @@ var px = {
603
605
  /** Defers schema creation — required for recursive types. Must supply a default value. */
604
606
  lazy: (fn, defaultVal) => new Lazy(fn, defaultVal)
605
607
  };
606
- var PX_WIRE_SCHEMA_VERSION = "1.1";
608
+ var PX_WIRE_SCHEMA_VERSION = "1.2";
607
609
  var VERSION_RE = /^(\d+)\.(\d+)(?:\.(\d+))?$/;
608
610
  function parseWireVersion(raw) {
609
611
  if (typeof raw !== "string") return void 0;
@@ -627,14 +629,18 @@ var PxPlaybackDirection = {
627
629
  };
628
630
  var PX_ANIM_SRC_ATTR_NAME = "data-px-animation-src";
629
631
  var PX_ANIM_ATTR_NAME = "_px_animator";
630
- var PxStartOn = {
632
+ var PxTriggerStart = {
631
633
  load: "load",
632
634
  mouseOver: "mouseOver",
633
635
  click: "click",
634
- scrollIntoView: "scrollIntoView",
635
- programmatic: "programmatic"
636
+ none: "none"
637
+ };
638
+ var PxOffScreenAction = {
639
+ pause: "pause",
640
+ continue: "continue",
641
+ reset: "reset"
636
642
  };
637
- var PxOutAction = {
643
+ var PxMouseOutAction = {
638
644
  continue: "continue",
639
645
  pause: "pause",
640
646
  reset: "reset",
@@ -702,16 +708,20 @@ function mayUseNativeScrollTimeline(engine) {
702
708
  return engine !== PxTimelineEngineSetting.js;
703
709
  }
704
710
  var PX_TRIGGER_DEFAULTS = {
705
- startOn: "load",
706
- outAction: "continue",
707
- scrollIntoViewThreshold: 0
711
+ start: "load",
712
+ offScreen: "pause",
713
+ mouseOut: "continue",
714
+ visibilityThreshold: 0.5,
715
+ visibilityDebounce: 150
708
716
  };
709
717
  function resolveTrigger(trigger) {
710
- var _a2, _b, _c;
718
+ var _a2, _b, _c, _d, _e;
711
719
  return {
712
- startOn: (_a2 = trigger == null ? void 0 : trigger.startOn) != null ? _a2 : PX_TRIGGER_DEFAULTS.startOn,
713
- outAction: (_b = trigger == null ? void 0 : trigger.outAction) != null ? _b : PX_TRIGGER_DEFAULTS.outAction,
714
- scrollIntoViewThreshold: (_c = trigger == null ? void 0 : trigger.scrollIntoViewThreshold) != null ? _c : PX_TRIGGER_DEFAULTS.scrollIntoViewThreshold
720
+ start: (_a2 = trigger == null ? void 0 : trigger.start) != null ? _a2 : PX_TRIGGER_DEFAULTS.start,
721
+ offScreen: (_b = trigger == null ? void 0 : trigger.offScreen) != null ? _b : PX_TRIGGER_DEFAULTS.offScreen,
722
+ mouseOut: (_c = trigger == null ? void 0 : trigger.mouseOut) != null ? _c : PX_TRIGGER_DEFAULTS.mouseOut,
723
+ visibilityThreshold: (_d = trigger == null ? void 0 : trigger.visibilityThreshold) != null ? _d : PX_TRIGGER_DEFAULTS.visibilityThreshold,
724
+ visibilityDebounce: (_e = trigger == null ? void 0 : trigger.visibilityDebounce) != null ? _e : PX_TRIGGER_DEFAULTS.visibilityDebounce
715
725
  };
716
726
  }
717
727
  var PxLoopRepeatAt = {
@@ -847,9 +857,9 @@ function flattenAnimatorTimeline(cfg) {
847
857
  } else {
848
858
  if (timeline.duration !== void 0) flat.duration = timeline.duration;
849
859
  if (timeline.trigger !== void 0) {
850
- const _b = timeline.trigger, { finishAction } = _b, restTrigger = __objRest2(_b, ["finishAction"]);
860
+ const _b = timeline.trigger, { finish } = _b, restTrigger = __objRest2(_b, ["finish"]);
851
861
  if (Object.keys(restTrigger).length) flat.trigger = restTrigger;
852
- if (finishAction !== void 0) flat.resetOnFinish = finishAction === "reset";
862
+ if (finish !== void 0) flat.resetOnFinish = finish === "reset";
853
863
  }
854
864
  if (timeline.delay !== void 0) flat.delay = timeline.delay;
855
865
  if (timeline.iterations !== void 0) flat.iterations = timeline.iterations;
@@ -948,13 +958,15 @@ var PxElementAnimationSchema = implementsInterface()(px.union([
948
958
  PxAnimationDefinitionSchema
949
959
  ]));
950
960
  var PxTriggerSchema = implementsInterface()(px.object({
951
- startOn: px.enum([PxStartOn.load, PxStartOn.mouseOver, PxStartOn.click, PxStartOn.scrollIntoView, PxStartOn.programmatic], PX_TRIGGER_DEFAULTS.startOn).optional(),
952
- outAction: px.enum([PxOutAction.continue, PxOutAction.pause, PxOutAction.reset, PxOutAction.reverse], PX_TRIGGER_DEFAULTS.outAction).optional(),
961
+ start: px.enum([PxTriggerStart.load, PxTriggerStart.mouseOver, PxTriggerStart.click, PxTriggerStart.none], PX_TRIGGER_DEFAULTS.start).optional(),
962
+ offScreen: px.enum([PxOffScreenAction.pause, PxOffScreenAction.continue, PxOffScreenAction.reset], PX_TRIGGER_DEFAULTS.offScreen).optional(),
963
+ mouseOut: px.enum([PxMouseOutAction.continue, PxMouseOutAction.pause, PxMouseOutAction.reset, PxMouseOutAction.reverse], PX_TRIGGER_DEFAULTS.mouseOut).optional(),
953
964
  // What happens after a NATURAL finish — `'hold'` (default: keep the end state per
954
- // `fill`) or `'reset'` (snap back to the start state). Pairs with `outAction` ("what
955
- // happens when the trigger condition ends"); both end-of-life knobs now read alike.
956
- finishAction: px.enum([PxFinishAction.hold, PxFinishAction.reset]).optional(),
957
- scrollIntoViewThreshold: px.number().optional()
965
+ // `fill`) or `'reset'` (snap back to the start state). One of four occasion keys
966
+ // (`start`, `offScreen`, `mouseOut`, `finish`), all named the same way.
967
+ finish: px.enum([PxFinishAction.hold, PxFinishAction.reset]).optional(),
968
+ visibilityThreshold: px.number().optional(),
969
+ visibilityDebounce: px.number().optional()
958
970
  }));
959
971
  var PxGlyphSchema = implementsInterface()(px.object({
960
972
  width: px.number(),
@@ -6234,16 +6246,16 @@ function foldTimelineOverride(timeline, shortcuts) {
6234
6246
  } else {
6235
6247
  base = timeline != null ? timeline : void 0;
6236
6248
  }
6237
- const { duration, delay, iterations, startOn } = shortcuts;
6238
- if (duration === void 0 && delay === void 0 && iterations === void 0 && startOn === void 0) {
6249
+ const { duration, delay, iterations, start } = shortcuts;
6250
+ if (duration === void 0 && delay === void 0 && iterations === void 0 && start === void 0) {
6239
6251
  return base === void 0 ? void 0 : { timeline: base };
6240
6252
  }
6241
6253
  const out = isPlainObject(base) ? __spreadValues2({}, base) : {};
6242
6254
  if (duration !== void 0) out.duration = duration;
6243
6255
  if (delay !== void 0) out.delay = delay;
6244
6256
  if (iterations !== void 0) out.iterations = iterations;
6245
- if (startOn !== void 0) {
6246
- out.trigger = __spreadProps2(__spreadValues2({}, out.trigger), { startOn });
6257
+ if (start !== void 0) {
6258
+ out.trigger = __spreadProps2(__spreadValues2({}, out.trigger), { start });
6247
6259
  }
6248
6260
  return { timeline: out };
6249
6261
  }
@@ -6390,6 +6402,202 @@ function asThrownError(e) {
6390
6402
  return e instanceof Error ? e : new Error(String(e));
6391
6403
  }
6392
6404
 
6405
+ // src/registry/PxAnimatorRegistry.ts
6406
+ var STORE_KEY = /* @__PURE__ */ Symbol.for("@pixodesk/svg-animator-web:animators");
6407
+ var GLOBAL_NAME = "__pixodeskAnimators";
6408
+ function store() {
6409
+ const g = globalThis;
6410
+ let s = g[STORE_KEY];
6411
+ if (!s) {
6412
+ const animators = /* @__PURE__ */ new Set();
6413
+ const listeners = /* @__PURE__ */ new Set();
6414
+ s = {
6415
+ animators,
6416
+ listeners,
6417
+ getAll: () => Array.from(animators),
6418
+ subscribe: (listener) => {
6419
+ listeners.add(listener);
6420
+ return () => {
6421
+ listeners.delete(listener);
6422
+ };
6423
+ }
6424
+ };
6425
+ g[STORE_KEY] = s;
6426
+ if (g[GLOBAL_NAME] === void 0) g[GLOBAL_NAME] = s;
6427
+ }
6428
+ return s;
6429
+ }
6430
+ function getAllAnimators() {
6431
+ return store().getAll();
6432
+ }
6433
+ function onAnimatorsChange(listener) {
6434
+ return store().subscribe(listener);
6435
+ }
6436
+ function notify(event, animator) {
6437
+ for (const listener of store().listeners) {
6438
+ try {
6439
+ listener(event, animator);
6440
+ } catch (e) {
6441
+ setTimeout(() => {
6442
+ throw e;
6443
+ }, 0);
6444
+ }
6445
+ }
6446
+ }
6447
+ function registerAnimator(animator) {
6448
+ const s = store();
6449
+ if (s.animators.has(animator)) return;
6450
+ s.animators.add(animator);
6451
+ notify("add", animator);
6452
+ const destroy = animator.destroy.bind(animator);
6453
+ animator.destroy = () => {
6454
+ destroy();
6455
+ if (s.animators.delete(animator)) notify("remove", animator);
6456
+ };
6457
+ }
6458
+ function withRegistryEvents(callbacks, api) {
6459
+ const fire = (event) => {
6460
+ const a = api();
6461
+ if (a) notify(event, a);
6462
+ };
6463
+ return __spreadProps(__spreadValues({}, callbacks), {
6464
+ onPlay: () => {
6465
+ var _a2;
6466
+ (_a2 = callbacks == null ? void 0 : callbacks.onPlay) == null ? void 0 : _a2.call(callbacks);
6467
+ fire("play");
6468
+ },
6469
+ onPause: () => {
6470
+ var _a2;
6471
+ (_a2 = callbacks == null ? void 0 : callbacks.onPause) == null ? void 0 : _a2.call(callbacks);
6472
+ fire("pause");
6473
+ },
6474
+ onCancel: () => {
6475
+ var _a2;
6476
+ (_a2 = callbacks == null ? void 0 : callbacks.onCancel) == null ? void 0 : _a2.call(callbacks);
6477
+ fire("cancel");
6478
+ },
6479
+ onFinish: () => {
6480
+ var _a2;
6481
+ (_a2 = callbacks == null ? void 0 : callbacks.onFinish) == null ? void 0 : _a2.call(callbacks);
6482
+ fire("finish");
6483
+ }
6484
+ });
6485
+ }
6486
+
6487
+ // src/triggers/PxVisibilityGate.ts
6488
+ var PLAY_WHEN_VISIBLE_DEFAULTS = {
6489
+ offScreen: PX_TRIGGER_DEFAULTS.offScreen,
6490
+ visibilityThreshold: PX_TRIGGER_DEFAULTS.visibilityThreshold,
6491
+ visibilityDebounce: PX_TRIGGER_DEFAULTS.visibilityDebounce
6492
+ };
6493
+ var THRESHOLD_STEPS = Array.from({ length: 21 }, (_, i) => i / 20);
6494
+ function effectiveRatio(entry) {
6495
+ var _a2, _b;
6496
+ const target = entry.boundingClientRect;
6497
+ const visible = entry.intersectionRect;
6498
+ if (!(target == null ? void 0 : target.height) || !visible) return entry.intersectionRatio;
6499
+ const live = typeof window !== "undefined" && window.innerHeight ? window.innerHeight : Infinity;
6500
+ const declared = (_b = (_a2 = entry.rootBounds) == null ? void 0 : _a2.height) != null ? _b : Infinity;
6501
+ const viewport = Math.min(live, declared);
6502
+ const denom = Math.min(target.height, Number.isFinite(viewport) ? viewport : target.height);
6503
+ return denom > 0 ? visible.height / denom : entry.intersectionRatio;
6504
+ }
6505
+ function openGate(host) {
6506
+ return {
6507
+ requestStart: () => host.play(),
6508
+ dispose: () => {
6509
+ }
6510
+ };
6511
+ }
6512
+ function isGated(offScreen) {
6513
+ return offScreen !== PxOffScreenAction.continue;
6514
+ }
6515
+ function createVisibilityGate(root, trigger, host) {
6516
+ if (!isGated(trigger.offScreen)) return openGate(host);
6517
+ if (typeof IntersectionObserver === "undefined") return openGate(host);
6518
+ const threshold = trigger.visibilityThreshold;
6519
+ const debounceMs = trigger.visibilityDebounce;
6520
+ let isOpen = void 0;
6521
+ let startPending = false;
6522
+ let pausedByGate = false;
6523
+ let lastRatio = 0;
6524
+ let openTimer;
6525
+ const cancelPendingOpen = () => {
6526
+ if (openTimer !== void 0) {
6527
+ clearTimeout(openTimer);
6528
+ openTimer = void 0;
6529
+ }
6530
+ };
6531
+ const open = () => {
6532
+ openTimer = void 0;
6533
+ if (isOpen === true) return;
6534
+ isOpen = true;
6535
+ if (startPending || pausedByGate) {
6536
+ startPending = false;
6537
+ pausedByGate = false;
6538
+ host.play();
6539
+ }
6540
+ };
6541
+ const close = () => {
6542
+ cancelPendingOpen();
6543
+ if (isOpen === false) return;
6544
+ isOpen = false;
6545
+ if (!host.isPlaying()) return;
6546
+ if (trigger.offScreen === PxOffScreenAction.reset) {
6547
+ host.cancel();
6548
+ } else {
6549
+ host.pause();
6550
+ }
6551
+ pausedByGate = true;
6552
+ };
6553
+ const apply2 = (ratio) => {
6554
+ lastRatio = ratio;
6555
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
6556
+ close();
6557
+ return;
6558
+ }
6559
+ if (ratio >= threshold) {
6560
+ if (isOpen === true || openTimer !== void 0) return;
6561
+ if (debounceMs > 0) openTimer = setTimeout(open, debounceMs);
6562
+ else open();
6563
+ return;
6564
+ }
6565
+ if (ratio <= 0) {
6566
+ close();
6567
+ return;
6568
+ }
6569
+ if (isOpen !== true) cancelPendingOpen();
6570
+ };
6571
+ const observer = new IntersectionObserver((entries) => {
6572
+ const last = entries[entries.length - 1];
6573
+ if (last) apply2(last.isIntersecting ? effectiveRatio(last) : 0);
6574
+ }, { threshold: THRESHOLD_STEPS });
6575
+ observer.observe(root);
6576
+ const onVisibilityChange = () => {
6577
+ apply2(lastRatio);
6578
+ };
6579
+ const hasDocument = typeof document !== "undefined";
6580
+ if (hasDocument) document.addEventListener("visibilitychange", onVisibilityChange);
6581
+ return {
6582
+ requestStart: (immediate) => {
6583
+ if (immediate || isOpen === true) {
6584
+ cancelPendingOpen();
6585
+ isOpen = true;
6586
+ startPending = false;
6587
+ pausedByGate = false;
6588
+ host.play();
6589
+ return;
6590
+ }
6591
+ startPending = true;
6592
+ },
6593
+ dispose: () => {
6594
+ cancelPendingOpen();
6595
+ observer.disconnect();
6596
+ if (hasDocument) document.removeEventListener("visibilitychange", onVisibilityChange);
6597
+ }
6598
+ };
6599
+ }
6600
+
6393
6601
  // src/triggers/PxAnimatorTriggers.ts
6394
6602
  function setupAnimationTriggers(api, trigger, diag) {
6395
6603
  const report = diag != null ? diag : createDiagnostics(void 0, "[PxAnimator]");
@@ -6397,7 +6605,7 @@ function setupAnimationTriggers(api, trigger, diag) {
6397
6605
  const dispose = () => {
6398
6606
  for (const undo of cleanups.splice(0)) undo();
6399
6607
  };
6400
- const { startOn, outAction, scrollIntoViewThreshold } = resolveTrigger(trigger);
6608
+ const resolved = resolveTrigger(trigger);
6401
6609
  const root = api.getRootElement();
6402
6610
  if (!root) {
6403
6611
  report.warn(PxDiagnosticKind.host, PxDiagnosticCode.triggersNoRoot);
@@ -6411,27 +6619,34 @@ function setupAnimationTriggers(api, trigger, diag) {
6411
6619
  }
6412
6620
  api.play();
6413
6621
  };
6414
- const handleEndAction = () => {
6415
- switch (outAction) {
6416
- case "pause":
6622
+ const gate = createVisibilityGate(root, resolved, {
6623
+ isPlaying: () => api.isPlaying(),
6624
+ play: start,
6625
+ pause: () => api.pause(),
6626
+ cancel: () => api.cancel()
6627
+ });
6628
+ cleanups.push(() => gate.dispose());
6629
+ const handleMouseOut = () => {
6630
+ switch (resolved.mouseOut) {
6631
+ case PxMouseOutAction.pause:
6417
6632
  api.pause();
6418
6633
  break;
6419
- case "reset":
6634
+ case PxMouseOutAction.reset:
6420
6635
  api.cancel();
6421
6636
  break;
6422
- case "reverse":
6637
+ case PxMouseOutAction.reverse:
6423
6638
  reversed = true;
6424
6639
  api.setPlaybackRate(-1);
6425
6640
  api.play();
6426
6641
  break;
6427
- case "continue":
6642
+ case PxMouseOutAction.continue:
6428
6643
  default:
6429
6644
  break;
6430
6645
  }
6431
6646
  };
6432
- switch (startOn) {
6433
- case "load": {
6434
- const startHandler = () => start();
6647
+ switch (resolved.start) {
6648
+ case PxTriggerStart.load: {
6649
+ const startHandler = () => gate.requestStart(false);
6435
6650
  if (document.readyState === "complete") {
6436
6651
  startHandler();
6437
6652
  } else {
@@ -6440,14 +6655,14 @@ function setupAnimationTriggers(api, trigger, diag) {
6440
6655
  }
6441
6656
  break;
6442
6657
  }
6443
- case "mouseOver": {
6658
+ case PxTriggerStart.mouseOver: {
6444
6659
  let enteredOnce = false;
6445
6660
  const mouseOverHandler = () => {
6446
6661
  enteredOnce = true;
6447
- start();
6662
+ gate.requestStart(true);
6448
6663
  };
6449
6664
  const mouseOutHandler = () => {
6450
- if (enteredOnce) handleEndAction();
6665
+ if (enteredOnce) handleMouseOut();
6451
6666
  };
6452
6667
  root.addEventListener("mouseenter", mouseOverHandler);
6453
6668
  root.addEventListener("mouseleave", mouseOutHandler);
@@ -6457,51 +6672,16 @@ function setupAnimationTriggers(api, trigger, diag) {
6457
6672
  });
6458
6673
  break;
6459
6674
  }
6460
- case "click": {
6675
+ case PxTriggerStart.click: {
6461
6676
  const clickHandler = () => {
6462
- if (api.isPlaying()) {
6463
- handleEndAction();
6464
- } else {
6465
- start();
6466
- }
6677
+ if (api.isPlaying()) api.pause();
6678
+ else gate.requestStart(true);
6467
6679
  };
6468
6680
  root.addEventListener("click", clickHandler);
6469
6681
  cleanups.push(() => root.removeEventListener("click", clickHandler));
6470
6682
  break;
6471
6683
  }
6472
- case "scrollIntoView": {
6473
- const effectiveRatio = (entry) => {
6474
- var _a2, _b;
6475
- const target = entry.boundingClientRect;
6476
- const visible = entry.intersectionRect;
6477
- if (!(target == null ? void 0 : target.height) || !visible) return entry.intersectionRatio;
6478
- const live = typeof window !== "undefined" && window.innerHeight ? window.innerHeight : Infinity;
6479
- const declared = (_b = (_a2 = entry.rootBounds) == null ? void 0 : _a2.height) != null ? _b : Infinity;
6480
- const viewport = Math.min(live, declared);
6481
- const denom = Math.min(target.height, Number.isFinite(viewport) ? viewport : target.height);
6482
- return denom > 0 ? visible.height / denom : entry.intersectionRatio;
6483
- };
6484
- const thresholdSteps = Array.from({ length: 21 }, (_, i) => i / 20);
6485
- let wasIntersecting = false;
6486
- const observer = new IntersectionObserver(
6487
- (entries) => {
6488
- entries.forEach((entry) => {
6489
- if (entry.isIntersecting && effectiveRatio(entry) >= scrollIntoViewThreshold) {
6490
- wasIntersecting = true;
6491
- start();
6492
- } else if (wasIntersecting) {
6493
- wasIntersecting = false;
6494
- handleEndAction();
6495
- }
6496
- });
6497
- },
6498
- { threshold: thresholdSteps }
6499
- );
6500
- observer.observe(root);
6501
- cleanups.push(() => observer.disconnect());
6502
- break;
6503
- }
6504
- case "programmatic":
6684
+ case PxTriggerStart.none:
6505
6685
  break;
6506
6686
  }
6507
6687
  return dispose;
@@ -6509,7 +6689,12 @@ function setupAnimationTriggers(api, trigger, diag) {
6509
6689
 
6510
6690
  // src/engines/PxAnimatorFrameLoop.ts
6511
6691
  function getSelector(id) {
6512
- return "#" + id;
6692
+ return "#" + escapeCssId(id);
6693
+ }
6694
+ function escapeCssId(id) {
6695
+ const css = globalThis.CSS;
6696
+ if (typeof (css == null ? void 0 : css.escape) === "function") return css.escape(id);
6697
+ return id.replace(/^([0-9])/, (_all, digit) => "\\3" + digit + " ").replace(/([^\w\-\\ ])/g, "\\$1");
6513
6698
  }
6514
6699
  function createFrameLoopAnimator(doc, adapter, callbacks, rootElement) {
6515
6700
  var _a2;
@@ -7305,14 +7490,15 @@ function isInternalOptions(options) {
7305
7490
  return "adapter" in options;
7306
7491
  }
7307
7492
  function resolveTimelineOption(options) {
7308
- const { timeline, duration, delay, iterations, startOn } = options;
7309
- return foldTimelineOverride(timeline, { duration, delay, iterations, startOn });
7493
+ const { timeline, duration, delay, iterations, start } = options;
7494
+ return foldTimelineOverride(timeline, { duration, delay, iterations, start });
7310
7495
  }
7311
7496
  function createAnimator(options) {
7312
7497
  const { src, doc, container, resetTimeline } = options;
7313
7498
  const adapter = isInternalOptions(options) ? options.adapter : void 0;
7314
7499
  const patch = resolveTimelineOption(options);
7315
- const callbacks = toEngineCallbacks(options);
7500
+ let proxy;
7501
+ const callbacks = withRegistryEvents(toEngineCallbacks(options), () => proxy);
7316
7502
  if (doc !== void 0 && src !== void 0) {
7317
7503
  throw new Error("createAnimator: provide either `src` or `doc`, not both");
7318
7504
  }
@@ -7348,19 +7534,7 @@ function createAnimator(options) {
7348
7534
  failed(PxDiagnosticKind.internal, PxDiagnosticCode.buildFailed, err);
7349
7535
  }
7350
7536
  };
7351
- if (doc !== void 0) {
7352
- build(doc);
7353
- } else {
7354
- fetch(src).then((res) => res.json()).then((json) => {
7355
- if (destroyed) return;
7356
- if (isPxDocument(json)) build(json);
7357
- else failed(PxDiagnosticKind.document, PxDiagnosticCode.invalidDocumentAtSrc, src);
7358
- }).catch((err) => {
7359
- var _a2;
7360
- failed(PxDiagnosticKind.host, PxDiagnosticCode.loadFailed, src, (_a2 = err == null ? void 0 : err.message) != null ? _a2 : String(err));
7361
- });
7362
- }
7363
- return {
7537
+ proxy = {
7364
7538
  "isReady": () => !!animator,
7365
7539
  "getRootElement": () => animator ? animator.getRootElement() : null,
7366
7540
  "isPlaying": () => (animator == null ? void 0 : animator.isPlaying()) || false,
@@ -7393,6 +7567,20 @@ function createAnimator(options) {
7393
7567
  animator == null ? void 0 : animator.destroy();
7394
7568
  }
7395
7569
  };
7570
+ registerAnimator(proxy);
7571
+ if (doc !== void 0) {
7572
+ build(doc);
7573
+ } else {
7574
+ fetch(src).then((res) => res.json()).then((json) => {
7575
+ if (destroyed) return;
7576
+ if (isPxDocument(json)) build(json);
7577
+ else failed(PxDiagnosticKind.document, PxDiagnosticCode.invalidDocumentAtSrc, src);
7578
+ }).catch((err) => {
7579
+ var _a2;
7580
+ failed(PxDiagnosticKind.host, PxDiagnosticCode.loadFailed, src, (_a2 = err == null ? void 0 : err.message) != null ? _a2 : String(err));
7581
+ });
7582
+ }
7583
+ return proxy;
7396
7584
  }
7397
7585
  function loadTagAnimators(options) {
7398
7586
  const elements = document.querySelectorAll("[" + PX_ANIM_SRC_ATTR_NAME + "]");
@@ -7419,7 +7607,9 @@ function loadTagAnimators(options) {
7419
7607
  createAdapterAnimator,
7420
7608
  createAnimator,
7421
7609
  generateNewIds,
7610
+ getAllAnimators,
7422
7611
  loadTagAnimators,
7612
+ onAnimatorsChange,
7423
7613
  px,
7424
7614
  renderNode,
7425
7615
  setupAnimationTriggers,