@pixodesk/svg-animator-core 1.0.41 → 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.
@@ -563,7 +563,7 @@ var px = {
563
563
  };
564
564
 
565
565
  // src/version/PxSchemaVersion.ts
566
- var PX_WIRE_SCHEMA_VERSION = "1.1";
566
+ var PX_WIRE_SCHEMA_VERSION = "1.2";
567
567
 
568
568
  // src/version/PxWireVersion.ts
569
569
  var PX_WIRE_VERSION_KEY = "version";
@@ -632,7 +632,46 @@ var PxWireStepKind = /* @__PURE__ */ ((PxWireStepKind2) => {
632
632
  return PxWireStepKind2;
633
633
  })(PxWireStepKind || {});
634
634
  var PX_WIRE_BASELINE_VERSION = "1.1";
635
- var PX_WIRE_STEPS = [];
635
+ var PX_WIRE_STEPS = [
636
+ {
637
+ from: "1.1",
638
+ to: "1.2",
639
+ reason: "The trigger block became two axes: `start` says what STARTS an animation, `offScreen` + `visibilityThreshold` + `visibilityDebounce` say whether it may RUN. `scrollIntoView` is no longer a start value \u2014 it is what `start: 'load'` behind the default gate already means \u2014 and `outAction` split into `offScreen` (scroll) and `mouseOut` (hover), because one field meant three things.",
640
+ kind: "converted" /* converted */,
641
+ up: upTriggerTwoAxes
642
+ // No `down`: 1.2 can express combinations 1.1 could not ("start on click AND pause when
643
+ // scrolled away"), so the mapping is not invertible.
644
+ }
645
+ ];
646
+ function upTriggerTwoAxes(doc) {
647
+ const animator = doc["animator"];
648
+ if (!animator || typeof animator !== "object") return;
649
+ const timeline = animator["timeline"];
650
+ const holder = timeline && typeof timeline === "object" ? timeline : animator;
651
+ const trigger = holder["trigger"];
652
+ if (!trigger || typeof trigger !== "object") return;
653
+ const t = trigger;
654
+ const startOn = t["startOn"];
655
+ const outAction = t["outAction"];
656
+ delete t["startOn"];
657
+ delete t["outAction"];
658
+ if (startOn === "scrollIntoView") {
659
+ if (outAction !== void 0) t["offScreen"] = outAction;
660
+ } else {
661
+ if (startOn === "programmatic") t["start"] = "none";
662
+ else if (startOn !== void 0) t["start"] = startOn;
663
+ if (startOn === "mouseOver" && outAction !== void 0) t["mouseOut"] = outAction;
664
+ if (t["offScreen"] === void 0) t["offScreen"] = "continue";
665
+ }
666
+ if (t["scrollIntoViewThreshold"] !== void 0) {
667
+ t["visibilityThreshold"] = t["scrollIntoViewThreshold"];
668
+ delete t["scrollIntoViewThreshold"];
669
+ }
670
+ if (t["finishAction"] !== void 0) {
671
+ t["finish"] = t["finishAction"];
672
+ delete t["finishAction"];
673
+ }
674
+ }
636
675
  function applyWireSteps(doc, cfg) {
637
676
  const from = readWireVersion(doc);
638
677
  const relation = compareWireVersion(from, cfg.target, cfg.readerReadsEditorPart);
@@ -757,14 +796,18 @@ var PxPlaybackDirection = {
757
796
  };
758
797
  var PX_ANIM_SRC_ATTR_NAME = "data-px-animation-src";
759
798
  var PX_ANIM_ATTR_NAME = "_px_animator";
760
- var PxStartOn = {
799
+ var PxTriggerStart = {
761
800
  load: "load",
762
801
  mouseOver: "mouseOver",
763
802
  click: "click",
764
- scrollIntoView: "scrollIntoView",
765
- programmatic: "programmatic"
803
+ none: "none"
766
804
  };
767
- var PxOutAction = {
805
+ var PxOffScreenAction = {
806
+ pause: "pause",
807
+ continue: "continue",
808
+ reset: "reset"
809
+ };
810
+ var PxMouseOutAction = {
768
811
  continue: "continue",
769
812
  pause: "pause",
770
813
  reset: "reset",
@@ -832,9 +875,11 @@ function mayUseNativeScrollTimeline(engine) {
832
875
  return engine !== PxTimelineEngineSetting.js;
833
876
  }
834
877
  var PX_TRIGGER_DEFAULTS = {
835
- startOn: "load",
836
- outAction: "continue",
837
- scrollIntoViewThreshold: 0
878
+ start: "load",
879
+ offScreen: "pause",
880
+ mouseOut: "continue",
881
+ visibilityThreshold: 0.5,
882
+ visibilityDebounce: 150
838
883
  };
839
884
  var PxControlMode = {
840
885
  /** No control props — the document's trigger decides, and nothing is taken over. */
@@ -868,11 +913,13 @@ function controlModeTakesOverTrigger(mode) {
868
913
  return mode !== PxControlMode.autoplay;
869
914
  }
870
915
  function resolveTrigger(trigger) {
871
- var _a2, _b, _c;
916
+ var _a2, _b, _c, _d, _e;
872
917
  return {
873
- startOn: (_a2 = trigger == null ? void 0 : trigger.startOn) != null ? _a2 : PX_TRIGGER_DEFAULTS.startOn,
874
- outAction: (_b = trigger == null ? void 0 : trigger.outAction) != null ? _b : PX_TRIGGER_DEFAULTS.outAction,
875
- scrollIntoViewThreshold: (_c = trigger == null ? void 0 : trigger.scrollIntoViewThreshold) != null ? _c : PX_TRIGGER_DEFAULTS.scrollIntoViewThreshold
918
+ start: (_a2 = trigger == null ? void 0 : trigger.start) != null ? _a2 : PX_TRIGGER_DEFAULTS.start,
919
+ offScreen: (_b = trigger == null ? void 0 : trigger.offScreen) != null ? _b : PX_TRIGGER_DEFAULTS.offScreen,
920
+ mouseOut: (_c = trigger == null ? void 0 : trigger.mouseOut) != null ? _c : PX_TRIGGER_DEFAULTS.mouseOut,
921
+ visibilityThreshold: (_d = trigger == null ? void 0 : trigger.visibilityThreshold) != null ? _d : PX_TRIGGER_DEFAULTS.visibilityThreshold,
922
+ visibilityDebounce: (_e = trigger == null ? void 0 : trigger.visibilityDebounce) != null ? _e : PX_TRIGGER_DEFAULTS.visibilityDebounce
876
923
  };
877
924
  }
878
925
  var PxLoopRepeatAt = {
@@ -1008,9 +1055,9 @@ function flattenAnimatorTimeline(cfg) {
1008
1055
  } else {
1009
1056
  if (timeline.duration !== void 0) flat.duration = timeline.duration;
1010
1057
  if (timeline.trigger !== void 0) {
1011
- const _b = timeline.trigger, { finishAction } = _b, restTrigger = __objRest(_b, ["finishAction"]);
1058
+ const _b = timeline.trigger, { finish } = _b, restTrigger = __objRest(_b, ["finish"]);
1012
1059
  if (Object.keys(restTrigger).length) flat.trigger = restTrigger;
1013
- if (finishAction !== void 0) flat.resetOnFinish = finishAction === "reset";
1060
+ if (finish !== void 0) flat.resetOnFinish = finish === "reset";
1014
1061
  }
1015
1062
  if (timeline.delay !== void 0) flat.delay = timeline.delay;
1016
1063
  if (timeline.iterations !== void 0) flat.iterations = timeline.iterations;
@@ -1077,7 +1124,7 @@ function nestAnimatorTimeline(cfg) {
1077
1124
  if (duration !== void 0) timeline.duration = duration;
1078
1125
  if (trigger !== void 0 || resetOnFinish) {
1079
1126
  const t = __spreadValues({}, trigger || {});
1080
- if (resetOnFinish) t.finishAction = "reset";
1127
+ if (resetOnFinish) t.finish = "reset";
1081
1128
  timeline.trigger = t;
1082
1129
  }
1083
1130
  if (delay !== void 0) timeline.delay = delay;
@@ -1180,13 +1227,15 @@ var PxElementAnimationSchema = implementsInterface()(px.union([
1180
1227
  PxAnimationDefinitionSchema
1181
1228
  ]));
1182
1229
  var PxTriggerSchema = implementsInterface()(px.object({
1183
- startOn: px.enum([PxStartOn.load, PxStartOn.mouseOver, PxStartOn.click, PxStartOn.scrollIntoView, PxStartOn.programmatic], PX_TRIGGER_DEFAULTS.startOn).optional(),
1184
- outAction: px.enum([PxOutAction.continue, PxOutAction.pause, PxOutAction.reset, PxOutAction.reverse], PX_TRIGGER_DEFAULTS.outAction).optional(),
1230
+ start: px.enum([PxTriggerStart.load, PxTriggerStart.mouseOver, PxTriggerStart.click, PxTriggerStart.none], PX_TRIGGER_DEFAULTS.start).optional(),
1231
+ offScreen: px.enum([PxOffScreenAction.pause, PxOffScreenAction.continue, PxOffScreenAction.reset], PX_TRIGGER_DEFAULTS.offScreen).optional(),
1232
+ mouseOut: px.enum([PxMouseOutAction.continue, PxMouseOutAction.pause, PxMouseOutAction.reset, PxMouseOutAction.reverse], PX_TRIGGER_DEFAULTS.mouseOut).optional(),
1185
1233
  // What happens after a NATURAL finish — `'hold'` (default: keep the end state per
1186
- // `fill`) or `'reset'` (snap back to the start state). Pairs with `outAction` ("what
1187
- // happens when the trigger condition ends"); both end-of-life knobs now read alike.
1188
- finishAction: px.enum([PxFinishAction.hold, PxFinishAction.reset]).optional(),
1189
- scrollIntoViewThreshold: px.number().optional()
1234
+ // `fill`) or `'reset'` (snap back to the start state). One of four occasion keys
1235
+ // (`start`, `offScreen`, `mouseOut`, `finish`), all named the same way.
1236
+ finish: px.enum([PxFinishAction.hold, PxFinishAction.reset]).optional(),
1237
+ visibilityThreshold: px.number().optional(),
1238
+ visibilityDebounce: px.number().optional()
1190
1239
  }));
1191
1240
  var PxGlyphSchema = implementsInterface()(px.object({
1192
1241
  width: px.number(),
@@ -4373,32 +4422,34 @@ var PxDiagnosticKind = {
4373
4422
  /** The player failed where it did not expect to — report it to us. */
4374
4423
  internal: "internal"
4375
4424
  };
4376
- function asError(error) {
4377
- return typeof error === "string" ? new Error(error) : error;
4425
+ var DOCS_URL = "https://github.com/pixodesk/pixodesk-svg-animator/blob/main/docs/diagnostics.md";
4426
+ function codeLine(code) {
4427
+ return "PX" + code + " " + DOCS_URL + "#px" + code;
4428
+ }
4429
+ function errorIn(data) {
4430
+ return data.find((d) => d instanceof Error);
4378
4431
  }
4379
4432
  function createDiagnostics(config, prefix) {
4380
4433
  const tag = prefix ? prefix + " " : "";
4381
4434
  return {
4382
- warn: (kind, message, detail) => {
4435
+ warn: (kind, code, ...data) => {
4436
+ const message = codeLine(code);
4383
4437
  if (config == null ? void 0 : config.onWarn) {
4384
- config.onWarn({ kind, message, detail });
4438
+ config.onWarn({ code, kind, data, message });
4385
4439
  return;
4386
4440
  }
4387
4441
  if (config == null ? void 0 : config.muteWarn) return;
4388
- const line = tag + kind + ": " + message;
4389
- if (detail === void 0) console.warn(line);
4390
- else console.warn(line, detail);
4442
+ console.warn(tag + kind + " " + message, ...data);
4391
4443
  },
4392
- error: (kind, error, detail) => {
4393
- const err = asError(error);
4444
+ error: (kind, code, ...data) => {
4445
+ const message = codeLine(code);
4446
+ const error = errorIn(data);
4394
4447
  if (config == null ? void 0 : config.onError) {
4395
- config.onError({ kind, message: err.message, error: err, detail });
4448
+ config.onError({ code, kind, data, message, error });
4396
4449
  return;
4397
4450
  }
4398
4451
  if (config == null ? void 0 : config.muteError) return;
4399
- const line = tag + kind + ": " + err.message;
4400
- if (detail === void 0) console.error(line);
4401
- else console.error(line, detail);
4452
+ console.error(tag + kind + " " + message, ...data);
4402
4453
  }
4403
4454
  };
4404
4455
  }
@@ -4448,8 +4499,9 @@ export {
4448
4499
  PxPlaybackDirection,
4449
4500
  PX_ANIM_SRC_ATTR_NAME,
4450
4501
  PX_ANIM_ATTR_NAME,
4451
- PxStartOn,
4452
- PxOutAction,
4502
+ PxTriggerStart,
4503
+ PxOffScreenAction,
4504
+ PxMouseOutAction,
4453
4505
  PxFinishAction,
4454
4506
  PxScrollKind,
4455
4507
  PxScrollAxis,
@@ -4592,4 +4644,4 @@ export {
4592
4644
  diagnoseDocument,
4593
4645
  reportDocumentDiagnostics
4594
4646
  };
4595
- //# sourceMappingURL=chunk-L6GJ6Y2M.js.map
4647
+ //# sourceMappingURL=chunk-EFQLDGFY.js.map