@pixodesk/svg-animator-web 1.0.45 → 1.0.47

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.
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
 
21
- // ../svg-animator-core/dist/chunk-YVKMPBHE.js
21
+ // ../svg-animator-core/dist/chunk-37OFJ3RX.js
22
22
  var __defProp2 = Object.defineProperty;
23
23
  var __defProps2 = Object.defineProperties;
24
24
  var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
@@ -62,19 +62,31 @@ function pathStr(path) {
62
62
  return result;
63
63
  }
64
64
  var Base = class {
65
+ /** Structural schemas (objects, arrays, unions of objects…) pass `false`: they state no scalar default. */
66
+ constructor(_statesDefault) {
67
+ this._statesDefault = _statesDefault;
68
+ }
65
69
  _canSanitize(raw) {
66
70
  return this.isValid(raw);
67
71
  }
72
+ /** A REQUIRED field is never absent; its default is the repair value. */
73
+ absentDefault() {
74
+ return this._default;
75
+ }
68
76
  optional() {
69
77
  return new Optional(this);
70
78
  }
71
79
  };
72
80
  var Optional = class extends Base {
73
81
  constructor(inner) {
74
- super();
82
+ super(inner._statesDefault);
75
83
  this.inner = inner;
76
84
  this._default = void 0;
77
85
  }
86
+ /** Absent means the inner schema's STATED default — or nothing at all when it states none. */
87
+ absentDefault() {
88
+ return this.inner._statesDefault ? this.inner._default : void 0;
89
+ }
78
90
  sanitize(raw) {
79
91
  if (raw === void 0 || raw === null) return void 0;
80
92
  return this.inner._canSanitize(raw) ? this.inner.sanitize(raw) : void 0;
@@ -88,8 +100,8 @@ var Optional = class extends Base {
88
100
  }
89
101
  };
90
102
  var Str = class extends Base {
91
- constructor(_default = "") {
92
- super();
103
+ constructor(_default, statesDefault) {
104
+ super(statesDefault);
93
105
  this._default = _default;
94
106
  }
95
107
  sanitize(raw) {
@@ -102,8 +114,8 @@ var Str = class extends Base {
102
114
  }
103
115
  };
104
116
  var Num = class extends Base {
105
- constructor(_default = 0) {
106
- super();
117
+ constructor(_default, statesDefault) {
118
+ super(statesDefault);
107
119
  this._default = _default;
108
120
  }
109
121
  sanitize(raw) {
@@ -116,8 +128,8 @@ var Num = class extends Base {
116
128
  }
117
129
  };
118
130
  var Bool = class extends Base {
119
- constructor(_default = false) {
120
- super();
131
+ constructor(_default, statesDefault) {
132
+ super(statesDefault);
121
133
  this._default = _default;
122
134
  }
123
135
  sanitize(raw) {
@@ -130,8 +142,9 @@ var Bool = class extends Base {
130
142
  }
131
143
  };
132
144
  var Literal = class extends Base {
145
+ /** A literal IS its own value: absent means it. */
133
146
  constructor(value) {
134
- super();
147
+ super(true);
135
148
  this.value = value;
136
149
  this._default = value;
137
150
  }
@@ -145,8 +158,8 @@ var Literal = class extends Base {
145
158
  }
146
159
  };
147
160
  var Enum = class extends Base {
148
- constructor(values, defaultVal) {
149
- super();
161
+ constructor(values, defaultVal, statesDefault) {
162
+ super(statesDefault);
150
163
  this.values = values;
151
164
  this._default = defaultVal != null ? defaultVal : values[0];
152
165
  }
@@ -161,8 +174,8 @@ var Enum = class extends Base {
161
174
  };
162
175
  var UNION_MEMBER_ERROR_LIMIT = 4;
163
176
  var Union = class extends Base {
164
- constructor(schemas, defaultVal) {
165
- super();
177
+ constructor(schemas, defaultVal, statesDefault) {
178
+ super(statesDefault);
166
179
  this.schemas = schemas;
167
180
  this._kind = "union";
168
181
  this._default = defaultVal != null ? defaultVal : schemas[0]._default;
@@ -215,7 +228,7 @@ var Union = class extends Base {
215
228
  var DiscriminatedUnion = class extends Base {
216
229
  constructor(_key, _schemas, defaultVal) {
217
230
  var _a2;
218
- super();
231
+ super(false);
219
232
  this._key = _key;
220
233
  this._schemas = _schemas;
221
234
  this._kind = "discriminatedUnion";
@@ -254,13 +267,19 @@ var DiscriminatedUnion = class extends Base {
254
267
  return schema ? schema._canSanitize(raw) : this._schemas[0]._canSanitize(raw);
255
268
  }
256
269
  };
270
+ function statedDefaults(shape) {
271
+ const out = {};
272
+ for (const key of Object.keys(shape)) if (shape[key]._statesDefault) out[key] = shape[key].absentDefault();
273
+ return Object.freeze(out);
274
+ }
257
275
  var Obj = class extends Base {
258
276
  constructor(_shape) {
259
- super();
277
+ super(false);
260
278
  this._shape = _shape;
261
279
  const d = {};
262
280
  for (const key of Object.keys(_shape)) d[key] = _shape[key]._default;
263
281
  this._default = d;
282
+ this.defaults = statedDefaults(_shape);
264
283
  }
265
284
  sanitize(raw) {
266
285
  const src = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
@@ -302,12 +321,13 @@ var Obj = class extends Base {
302
321
  };
303
322
  var OpenObj = class extends Base {
304
323
  constructor(_shape, _openSchema) {
305
- super();
324
+ super(false);
306
325
  this._shape = _shape;
307
326
  this._openSchema = _openSchema;
308
327
  const d = {};
309
328
  for (const key of Object.keys(_shape)) d[key] = _shape[key]._default;
310
329
  this._default = d;
330
+ this.defaults = statedDefaults(_shape);
311
331
  }
312
332
  sanitize(raw) {
313
333
  const src = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
@@ -352,7 +372,7 @@ var OpenObj = class extends Base {
352
372
  };
353
373
  var Arr = class extends Base {
354
374
  constructor(item) {
355
- super();
375
+ super(false);
356
376
  this.item = item;
357
377
  this._default = [];
358
378
  }
@@ -384,7 +404,7 @@ var Arr = class extends Base {
384
404
  };
385
405
  var Rec = class extends Base {
386
406
  constructor(value) {
387
- super();
407
+ super(false);
388
408
  this.value = value;
389
409
  this._kind = "record";
390
410
  this._default = {};
@@ -417,7 +437,7 @@ var Rec = class extends Base {
417
437
  };
418
438
  var Any = class extends Base {
419
439
  constructor() {
420
- super(...arguments);
440
+ super(false);
421
441
  this._default = void 0;
422
442
  }
423
443
  sanitize(raw) {
@@ -432,7 +452,7 @@ var Any = class extends Base {
432
452
  };
433
453
  var Defined = class extends Base {
434
454
  constructor() {
435
- super(...arguments);
455
+ super(false);
436
456
  this._default = void 0;
437
457
  }
438
458
  sanitize(raw) {
@@ -449,7 +469,7 @@ var Defined = class extends Base {
449
469
  };
450
470
  var Lazy = class extends Base {
451
471
  constructor(fn, _default) {
452
- super();
472
+ super(false);
453
473
  this.fn = fn;
454
474
  this._default = _default;
455
475
  this.resolved = null;
@@ -470,7 +490,7 @@ var Lazy = class extends Base {
470
490
  };
471
491
  var Tuple = class extends Base {
472
492
  constructor(schemas) {
473
- super();
493
+ super(false);
474
494
  this.schemas = schemas;
475
495
  this._kind = "tuple";
476
496
  this._default = schemas.map((s) => s._default);
@@ -501,22 +521,29 @@ var Tuple = class extends Base {
501
521
  function implementsInterface() {
502
522
  return (schema) => schema;
503
523
  }
524
+ function string(defaultVal) {
525
+ return defaultVal === void 0 ? new Str("", false) : new Str(defaultVal, true);
526
+ }
527
+ function number(defaultVal) {
528
+ return defaultVal === void 0 ? new Num(0, false) : new Num(defaultVal, true);
529
+ }
530
+ function boolean(defaultVal) {
531
+ return defaultVal === void 0 ? new Bool(false, false) : new Bool(defaultVal, true);
532
+ }
533
+ function oneOf(values, defaultVal) {
534
+ return defaultVal === void 0 ? new Enum(values, void 0, false) : new Enum(values, defaultVal, true);
535
+ }
536
+ function unionOf(schemas, defaultVal) {
537
+ return defaultVal === void 0 ? new Union(schemas, void 0, false) : new Union(schemas, defaultVal, true);
538
+ }
504
539
  var px = {
505
- /** Matches a string. Default: '' or provided value. */
506
- string: (defaultVal = "") => new Str(defaultVal),
507
- /** Matches a finite number. Default: 0 or provided value. */
508
- number: (defaultVal = 0) => new Num(defaultVal),
509
- /** Matches a boolean. Default: false or provided value. */
510
- boolean: (defaultVal = false) => new Bool(defaultVal),
511
- /** Matches one exact primitive value; its default is the value itself. */
540
+ string,
541
+ number,
542
+ boolean,
543
+ /** Matches one exact primitive value; absent means the value itself. */
512
544
  literal: (value) => new Literal(value),
513
- /** Matches one of a fixed set of string/number values. Default: first value. */
514
- enum: (values, defaultVal) => new Enum(values, defaultVal),
515
- /**
516
- * Returns the first schema whose isValid passes.
517
- * TypeScript infers the union of all member types automatically.
518
- */
519
- union: (schemas, defaultVal) => new Union(schemas, defaultVal),
545
+ enum: oneOf,
546
+ union: unionOf,
520
547
  /**
521
548
  * Discriminated union — reads `raw[key]`, finds the member schema whose
522
549
  * literal at `key` matches, then delegates sanitize/isValid to that member.
@@ -524,7 +551,8 @@ var px = {
524
551
  * TypeScript infers the union of all member types automatically.
525
552
  */
526
553
  discriminatedUnion: (key, schemas) => new DiscriminatedUnion(key, schemas),
527
- /** Typed object — unknown keys are stripped. Required fields fall back to their default. */
554
+ /** Typed object — unknown keys are stripped. Required fields fall back to their default.
555
+ * Its `defaults` say what each stated field means when a document leaves it out. */
528
556
  object: (shape) => new Obj(shape),
529
557
  /**
530
558
  * Open object — validates known keys; passes unknown keys through as-is,
@@ -659,8 +687,11 @@ var PX_TRIGGER_DEFAULTS = {
659
687
  offScreen: "pause",
660
688
  mouseOut: "continue",
661
689
  visibilityThreshold: 0.5,
662
- visibilityDebounce: 150
690
+ visibilityDebounce: 150,
691
+ finish: "hold"
663
692
  };
693
+ var PX_DEFAULT_DURATION_MS = 1e3;
694
+ var PX_DEFAULT_ITERATIONS = 1;
664
695
  function resolveTrigger(trigger) {
665
696
  var _a2, _b, _c, _d, _e;
666
697
  return {
@@ -873,15 +904,15 @@ var keyframeTangentIn = (kf) => anyKf(kf).tangentIn;
873
904
  var keyframeTangentOut = (kf) => anyKf(kf).tangentOut;
874
905
  var PxLoopSchema = implementsInterface()(px.object({
875
906
  segmentCount: px.number().optional(),
876
- repeatAt: px.enum([PxLoopRepeatAt.start, PxLoopRepeatAt.end]).optional(),
877
- direction: px.enum([PxLoopDirection.normal, PxLoopDirection.alternate]).optional()
907
+ repeatAt: px.enum([PxLoopRepeatAt.start, PxLoopRepeatAt.end], PxLoopRepeatAt.end).optional(),
908
+ direction: px.enum([PxLoopDirection.normal, PxLoopDirection.alternate], PxLoopDirection.normal).optional()
878
909
  }));
879
910
  var PxPropertyAnimationSchema = implementsInterface()(px.object({
880
911
  value: PxKeyframeValueSchema.optional(),
881
912
  keyframes: px.array(PxKeyframeSchema).optional(),
882
913
  loop: px.union([PxLoopSchema, px.boolean()]).optional(),
883
914
  autoOrient: px.boolean().optional(),
884
- alongPathMode: px.enum([PxAlongPathMode.sampled, PxAlongPathMode.offsetPath]).optional()
915
+ alongPathMode: px.enum([PxAlongPathMode.sampled, PxAlongPathMode.offsetPath], PxAlongPathMode.sampled).optional()
885
916
  }));
886
917
  var PxTransformPartsSchema = implementsInterface()(px.object({
887
918
  translate: px.tuple([px.number(), px.number()]).optional(),
@@ -911,9 +942,9 @@ var PxTriggerSchema = implementsInterface()(px.object({
911
942
  // What happens after a NATURAL finish — `'hold'` (default: keep the end state per
912
943
  // `fill`) or `'reset'` (snap back to the start state). One of four occasion keys
913
944
  // (`start`, `offScreen`, `mouseOut`, `finish`), all named the same way.
914
- finish: px.enum([PxFinishAction.hold, PxFinishAction.reset]).optional(),
915
- visibilityThreshold: px.number().optional(),
916
- visibilityDebounce: px.number().optional()
945
+ finish: px.enum([PxFinishAction.hold, PxFinishAction.reset], PX_TRIGGER_DEFAULTS.finish).optional(),
946
+ visibilityThreshold: px.number(PX_TRIGGER_DEFAULTS.visibilityThreshold).optional(),
947
+ visibilityDebounce: px.number(PX_TRIGGER_DEFAULTS.visibilityDebounce).optional()
917
948
  }));
918
949
  var PxGlyphSchema = implementsInterface()(px.object({
919
950
  width: px.number(),
@@ -939,7 +970,7 @@ var PxScrollRangePointSchema = implementsInterface()(px.object({
939
970
  PxScrollPhase.exit,
940
971
  PxScrollPhase.entryCrossing,
941
972
  PxScrollPhase.exitCrossing
942
- ]).optional(),
973
+ ], PxScrollPhase.cover).optional(),
943
974
  fraction: px.number().optional()
944
975
  }));
945
976
  var PxScrollRangeSchema = px.object({
@@ -947,37 +978,37 @@ var PxScrollRangeSchema = px.object({
947
978
  end: PxScrollRangePointSchema.optional()
948
979
  });
949
980
  var PxScrollSchema = implementsInterface()(px.object({
950
- kind: px.enum([PxScrollKind.view, PxScrollKind.scroll]).optional(),
951
- axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y]).optional(),
952
- source: px.enum([PxScrollSource.nearest, PxScrollSource.root]).optional(),
981
+ kind: px.enum([PxScrollKind.view, PxScrollKind.scroll], PxScrollKind.view).optional(),
982
+ axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y], PxScrollAxis.block).optional(),
983
+ source: px.enum([PxScrollSource.nearest, PxScrollSource.root], PxScrollSource.nearest).optional(),
953
984
  // Free-form: the two keywords `parent`/`scroller` plus any CSS selector.
954
985
  subject: px.string().optional(),
955
986
  smoothing: px.number().optional(),
956
- pin: px.boolean().optional(),
957
- pinAlign: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom]).optional(),
987
+ pin: px.boolean(false).optional(),
988
+ pinAlign: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom], PxPinAlign.top).optional(),
958
989
  pinOffset: px.number().optional(),
959
990
  pinDistance: px.number().optional(),
960
991
  range: PxScrollRangeSchema.optional()
961
992
  }));
962
993
  var PxTimelinePinSchema = implementsInterface()(px.object({
963
- align: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom]).optional(),
994
+ align: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom], PxPinAlign.top).optional(),
964
995
  offset: px.number().optional(),
965
996
  distance: px.number().optional()
966
997
  }));
967
- var PxTimelineEngineSchema = px.enum([PxTimelineEngineSetting.auto, PxTimelineEngineSetting.native, PxTimelineEngineSetting.js]).optional();
998
+ var PxTimelineEngineSchema = px.enum([PxTimelineEngineSetting.auto, PxTimelineEngineSetting.native, PxTimelineEngineSetting.js], PxTimelineEngineSetting.auto).optional();
968
999
  var PxTimeTimelineSchema = implementsInterface()(px.object({
969
1000
  type: px.literal("time").optional(),
970
1001
  engine: PxTimelineEngineSchema,
971
1002
  frameRate: px.number().optional(),
972
1003
  // §2.8: duration is a property of the TIMELINE — how long one pass takes.
973
- duration: px.number().optional(),
1004
+ duration: px.number(PX_DEFAULT_DURATION_MS).optional(),
974
1005
  trigger: PxTriggerSchema.optional(),
975
- delay: px.number().optional(),
976
- iterations: px.union([px.number(), px.literal("infinite")]).optional(),
1006
+ delay: px.number(0).optional(),
1007
+ iterations: px.union([px.number(PX_DEFAULT_ITERATIONS), px.literal("infinite")], PX_DEFAULT_ITERATIONS).optional(),
977
1008
  // `fillMode` on the wire (CSS `animation-fill-mode`; the runtime view calls it `fill`)
978
1009
  // — never `fill`, which is paint everywhere else in the format.
979
- fillMode: px.enum([PxFillMode.forwards, PxFillMode.backwards, PxFillMode.both, PxFillMode.none]).optional(),
980
- direction: px.enum([PxPlaybackDirection.normal, PxPlaybackDirection.reverse, PxPlaybackDirection.alternate, PxPlaybackDirection.alternateReverse]).optional()
1010
+ fillMode: px.enum([PxFillMode.forwards, PxFillMode.backwards, PxFillMode.both, PxFillMode.none], PxFillMode.forwards).optional(),
1011
+ direction: px.enum([PxPlaybackDirection.normal, PxPlaybackDirection.reverse, PxPlaybackDirection.alternate, PxPlaybackDirection.alternateReverse], PxPlaybackDirection.normal).optional()
981
1012
  }));
982
1013
  var scrollishTimelineShape = {
983
1014
  // §2.8: duration is a property of the TIMELINE — under scrubbing it is the keyframe
@@ -988,8 +1019,8 @@ var scrollishTimelineShape = {
988
1019
  iterations: px.number().optional(),
989
1020
  engine: PxTimelineEngineSchema,
990
1021
  frameRate: px.number().optional(),
991
- axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y]).optional(),
992
- source: px.enum([PxScrollSource.nearest, PxScrollSource.root]).optional(),
1022
+ axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y], PxScrollAxis.block).optional(),
1023
+ source: px.enum([PxScrollSource.nearest, PxScrollSource.root], PxScrollSource.nearest).optional(),
993
1024
  subject: px.string().optional(),
994
1025
  // 'parent' | 'scroller' | any CSS selector
995
1026
  smoothing: px.number().optional(),
@@ -1069,9 +1100,10 @@ var PxRepeaterEffectSchema = implementsInterface()(px.object({
1069
1100
  }));
1070
1101
  var PxMaskedByEffectSchema = implementsInterface()(px.object({
1071
1102
  source: px.string().optional(),
1072
- maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha]).optional(),
1073
- maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
1074
- maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
1103
+ // SVG's own initial values — what a <mask> does when the attribute is not there.
1104
+ maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha], PxMaskType.luminance).optional(),
1105
+ maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox], PxUnits.objectBoundingBox).optional(),
1106
+ maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox], PxUnits.userSpaceOnUse).optional(),
1075
1107
  x: px.number().optional(),
1076
1108
  y: px.number().optional(),
1077
1109
  width: px.number().optional(),
@@ -1083,7 +1115,7 @@ var PxClipPathEffectSchema = implementsInterface()(px.object({
1083
1115
  var PxStrokeTrimEffectSchema = implementsInterface()(px.object({
1084
1116
  offset: PxAnimatableNumberSchema.optional(),
1085
1117
  range: PxAnimatableVec2Schema.optional(),
1086
- subPaths: px.enum([PxStrokeTrimSubPaths.separate, PxStrokeTrimSubPaths.combined]).optional()
1118
+ subPaths: px.enum([PxStrokeTrimSubPaths.separate, PxStrokeTrimSubPaths.combined], PxStrokeTrimSubPaths.separate).optional()
1087
1119
  }));
1088
1120
  var PxRetimeEffectSchema = implementsInterface()(px.object({
1089
1121
  start: px.number().optional(),
@@ -1115,17 +1147,20 @@ var PxFillGradientEffectSchema = implementsInterface()(px.object({
1115
1147
  radius: PxAnimatableNumberSchema.optional(),
1116
1148
  focal: PxAnimatableVec2Schema.optional(),
1117
1149
  stops: PxAnimatableGradientStopsSchema.optional(),
1118
- gradientUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
1119
- spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
1150
+ // SVG's own initial values — what a gradient does when the attribute is not there.
1151
+ gradientUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox], PxUnits.objectBoundingBox).optional(),
1152
+ spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat], PxGradientSpreadMethod.pad).optional(),
1120
1153
  gradientTransform: px.string().optional()
1121
1154
  }));
1122
1155
  var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
1123
1156
  var PxTextPathEffectSchema = implementsInterface()(px.object({
1124
1157
  pathData: px.string(),
1125
- pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
1126
- lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
1127
- method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
1128
- spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
1158
+ // `extend` is what an omitted pathOverflow means (glyphs continue along the tangent); the
1159
+ // other three are SVG's own initial values for the native <textPath> attributes.
1160
+ pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend], PxPathOverflow.extend).optional(),
1161
+ lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs], PxLengthAdjust.spacing).optional(),
1162
+ method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch], PxTextPathMethod.align).optional(),
1163
+ spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact], PxTextPathSpacing.exact).optional(),
1129
1164
  startOffset: PxAnimatableNumberSchema.optional(),
1130
1165
  textLength: PxAnimatableNumberSchema.optional()
1131
1166
  }));
@@ -1685,7 +1720,6 @@ function parseTransformParts(str2) {
1685
1720
  return Object.keys(out).length ? out : void 0;
1686
1721
  }
1687
1722
  var PX_STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
1688
- var PX_DEFAULT_DURATION_MS = 1e3;
1689
1723
  function kebabToCamelCaseWord(kebab) {
1690
1724
  return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
1691
1725
  }
@@ -5682,9 +5716,10 @@ function walkAndMaterialize2(node, idMap, animatedIds, genId3, defsCollector, ro
5682
5716
  }
5683
5717
  var TRANSFORM_CHANNEL = "transform";
5684
5718
  var REVERSED_DIRECTIONS = /* @__PURE__ */ new Set(["reverse", "alternate-reverse"]);
5719
+ var VERIFY_SAMPLE_FRACTIONS = [0, 0.25, 0.5, 0.75, 1];
5685
5720
  var SCRATCH_ID_PREFIX = "__px_rest_";
5686
5721
  function materializeRestPosesInTree(root, engine) {
5687
- var _a2;
5722
+ var _a2, _b;
5688
5723
  const out = deepClone(root);
5689
5724
  const config = getAnimatorConfig(out) || {};
5690
5725
  const duration = +(config.duration || PX_DEFAULT_DURATION_MS);
@@ -5696,18 +5731,27 @@ function materializeRestPosesInTree(root, engine) {
5696
5731
  for (const [key, animate] of before) {
5697
5732
  const node = nodes.get(key);
5698
5733
  if (!node) continue;
5699
- for (const channel of Object.keys(animate)) {
5734
+ const channels = Object.keys(animate);
5735
+ for (const channel of channels) {
5736
+ if (PX_TRANSFORM_FN_NAMES.has(channel)) continue;
5700
5737
  if (!mayCarryRestPose(node, channel)) continue;
5701
5738
  const value = firstFrameValue(animate, channel, firstFrameTime);
5702
5739
  if (value === void 0) continue;
5703
5740
  node[channel] = value;
5704
5741
  added.set(key, [...(_a2 = added.get(key)) != null ? _a2 : [], channel]);
5705
5742
  }
5743
+ if (channels.some((channel) => PX_TRANSFORM_FN_NAMES.has(channel)) && mayCarryTransformRestPose(node)) {
5744
+ const parts = firstFrameTransformParts(animate, firstFrameTime);
5745
+ if (parts) {
5746
+ node[TRANSFORM_CHANNEL] = parts;
5747
+ added.set(key, [...(_b = added.get(key)) != null ? _b : [], TRANSFORM_CHANNEL]);
5748
+ }
5749
+ }
5706
5750
  }
5707
5751
  if (added.size) {
5708
5752
  const after = bindingsOf(out, engine);
5709
5753
  for (const [key, channels] of added) {
5710
- if (JSON.stringify(after.get(key)) === JSON.stringify(before.get(key))) continue;
5754
+ if (writesTheSameFrames(before.get(key), after.get(key), duration)) continue;
5711
5755
  const node = nodes.get(key);
5712
5756
  if (node) for (const channel of channels) delete node[channel];
5713
5757
  }
@@ -5716,16 +5760,31 @@ function materializeRestPosesInTree(root, engine) {
5716
5760
  }
5717
5761
  function mayCarryRestPose(node, channel) {
5718
5762
  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
- }
5763
+ if (channel === TRANSFORM_CHANNEL) return mayCarryTransformRestPose(node);
5764
+ return true;
5765
+ }
5766
+ function mayCarryTransformRestPose(node) {
5767
+ if (node[TRANSFORM_CHANNEL] !== void 0) return false;
5768
+ for (const part of PX_TRANSFORM_FN_NAMES) if (node[part] !== void 0) return false;
5723
5769
  return true;
5724
5770
  }
5725
5771
  function firstFrameValue(animate, channel, timeMs) {
5726
5772
  const values = Object.values(calcAnimationValues({ [channel]: animate[channel] }, timeMs));
5727
5773
  return values.length === 1 && values[0] !== "" ? values[0] : void 0;
5728
5774
  }
5775
+ function firstFrameTransformParts(animate, timeMs) {
5776
+ const family = {};
5777
+ for (const channel of Object.keys(animate)) if (PX_TRANSFORM_FN_NAMES.has(channel)) family[channel] = animate[channel];
5778
+ const written = calcAnimationValues(family, timeMs)[TRANSFORM_CHANNEL];
5779
+ if (!written) return void 0;
5780
+ const parts = parseTransformParts(written.replace(/(px|deg)\b/g, ""));
5781
+ return parts && Object.keys(parts).length ? parts : void 0;
5782
+ }
5783
+ function writesTheSameFrames(a, b, durationMs) {
5784
+ if (!a || !b) return a === b;
5785
+ const frame = (animate, t) => JSON.stringify(calcAnimationValues(animate, t)).replace(/\s+/g, "");
5786
+ return VERIFY_SAMPLE_FRACTIONS.every((fraction) => frame(a, fraction * durationMs) === frame(b, fraction * durationMs));
5787
+ }
5729
5788
  function bindingsOf(tree, engine) {
5730
5789
  const scratch = deepClone(tree);
5731
5790
  const keyById = /* @__PURE__ */ new Map();
@@ -5936,13 +5995,13 @@ function createAdapterAnimator(doc, adapter, callbacks) {
5936
5995
  const bindings = normalizeBindings(doc, PxTimelineEngine.js);
5937
5996
  const _iterations = config.iterations;
5938
5997
  let iterations = 1;
5939
- if (typeof _iterations === "number") iterations = _iterations || 1;
5998
+ if (typeof _iterations === "number") iterations = _iterations || PX_DEFAULT_ITERATIONS;
5940
5999
  if (_iterations === "infinite") iterations = Infinity;
5941
6000
  if (iterations < 1) iterations = 1;
5942
6001
  const duration = +(config.duration || PX_DEFAULT_DURATION_MS);
5943
- const totalDuration = duration && iterations ? duration * (iterations === Infinity ? Infinity : iterations) : duration ? (iterations != null ? iterations : 1) * duration : 0;
5944
- const direction = config.direction || "normal";
5945
- const fill = (_a2 = config.fill) != null ? _a2 : "forwards";
6002
+ const totalDuration = duration && iterations ? duration * (iterations === Infinity ? Infinity : iterations) : duration ? (iterations != null ? iterations : PX_DEFAULT_ITERATIONS) * duration : 0;
6003
+ const direction = config.direction || PxTimeTimelineSchema.defaults.direction;
6004
+ const fill = (_a2 = config.fill) != null ? _a2 : PxTimeTimelineSchema.defaults.fillMode;
5946
6005
  const fillsForwards = fill === "forwards" || fill === "both";
5947
6006
  const fillsBackwards = fill === "backwards" || fill === "both";
5948
6007
  let timerId = null;
@@ -6478,6 +6537,8 @@ export {
6478
6537
  resolveTimelineEngine,
6479
6538
  isNativeForced,
6480
6539
  mayUseNativeScrollTimeline,
6540
+ PX_DEFAULT_DURATION_MS,
6541
+ PX_DEFAULT_ITERATIONS,
6481
6542
  resolveTrigger,
6482
6543
  PX_TEXT_CONTENT_ATTR,
6483
6544
  isPxDocument,
@@ -6502,7 +6563,6 @@ export {
6502
6563
  PX_PCT_BASED_ATTR_NAMES,
6503
6564
  composeTransformParts,
6504
6565
  PX_STYLE_ATTR_NAMES,
6505
- PX_DEFAULT_DURATION_MS,
6506
6566
  kebabToCamelCaseWord,
6507
6567
  camelCaseToKebabWordIfNeeded,
6508
6568
  clamp,
@@ -6529,4 +6589,4 @@ export {
6529
6589
  createVisibilityGate,
6530
6590
  PX_ANIMATOR_DOC_KEY
6531
6591
  };
6532
- //# sourceMappingURL=chunk-QE7KJWAN.js.map
6592
+ //# sourceMappingURL=chunk-ZBGGXE5W.js.map