@pixodesk/svg-animator-web 1.0.34 → 1.0.35
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/README.md +25 -7
- package/dist/index.cjs +724 -462
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -4
- package/dist/index.d.ts +29 -4
- package/dist/index.js +714 -460
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.prerendered-waapi.umd.js +981 -85
- package/dist/index.prerendered-waapi.umd.js.map +1 -1
- package/dist/index.prerendered-waapi.umd.min.js +1 -1
- package/dist/index.prerendered.umd.js +1006 -105
- package/dist/index.prerendered.umd.js.map +1 -1
- package/dist/index.prerendered.umd.min.js +1 -1
- package/dist/pixodesk-svg-animator.umd.js +512 -270
- package/dist/pixodesk-svg-animator.umd.js.map +1 -1
- package/dist/pixodesk-svg-animator.umd.min.js +1 -1
- package/mangle-reserved.json +232 -0
- package/package.json +7 -4
package/dist/index.cjs
CHANGED
|
@@ -58,12 +58,11 @@ __export(index_exports, {
|
|
|
58
58
|
PxAnimatedSvgDocumentSchema: () => PxAnimatedSvgDocumentSchema,
|
|
59
59
|
PxAnimationDefinitionSchema: () => PxAnimationDefinitionSchema,
|
|
60
60
|
PxAnimatorConfigSchema: () => PxAnimatorConfigSchema,
|
|
61
|
-
PxAnimatorEngine: () => PxAnimatorEngine,
|
|
62
|
-
PxAnimatorMode: () => PxAnimatorMode,
|
|
63
61
|
PxAttrValueSchema: () => PxAttrValueSchema,
|
|
64
62
|
PxBezierPathSchema: () => PxBezierPathSchema,
|
|
65
63
|
PxBindingSchema: () => PxBindingSchema,
|
|
66
64
|
PxCloneEffectSchema: () => PxCloneEffectSchema,
|
|
65
|
+
PxCloneWithout: () => PxCloneWithout,
|
|
67
66
|
PxDefsSchema: () => PxDefsSchema,
|
|
68
67
|
PxEasingOrRefSchema: () => PxEasingOrRefSchema,
|
|
69
68
|
PxEffectsSchema: () => PxEffectsSchema,
|
|
@@ -75,6 +74,8 @@ __export(index_exports, {
|
|
|
75
74
|
PxGradientUnits: () => PxGradientUnits,
|
|
76
75
|
PxKeyframeSchema: () => PxKeyframeSchema,
|
|
77
76
|
PxKeyframeValueSchema: () => PxKeyframeValueSchema,
|
|
77
|
+
PxLoopDirection: () => PxLoopDirection,
|
|
78
|
+
PxLoopRepeatAt: () => PxLoopRepeatAt,
|
|
78
79
|
PxLoopSchema: () => PxLoopSchema,
|
|
79
80
|
PxMaskedByEffectSchema: () => PxMaskedByEffectSchema,
|
|
80
81
|
PxNodeBase: () => PxNodeBase,
|
|
@@ -84,15 +85,19 @@ __export(index_exports, {
|
|
|
84
85
|
PxRetimeEffectSchema: () => PxRetimeEffectSchema,
|
|
85
86
|
PxStrokeGradientEffectSchema: () => PxStrokeGradientEffectSchema,
|
|
86
87
|
PxStrokeTrimEffectSchema: () => PxStrokeTrimEffectSchema,
|
|
88
|
+
PxStrokeTrimSubPaths: () => PxStrokeTrimSubPaths,
|
|
87
89
|
PxSvgNodeExtra: () => PxSvgNodeExtra,
|
|
88
90
|
PxTextEffectSchema: () => PxTextEffectSchema,
|
|
89
91
|
PxTextPathEffectSchema: () => PxTextPathEffectSchema,
|
|
92
|
+
PxTimelineEngine: () => PxTimelineEngine,
|
|
93
|
+
PxTimelineEngineExtra: () => PxTimelineEngineExtra,
|
|
90
94
|
PxTransformByEffectSchema: () => PxTransformByEffectSchema,
|
|
91
95
|
PxTransformPartsSchema: () => PxTransformPartsSchema,
|
|
92
96
|
PxTransformValueSchema: () => PxTransformValueSchema,
|
|
93
97
|
PxTriggerSchema: () => PxTriggerSchema,
|
|
94
98
|
STYLE_ATTR_NAMES: () => STYLE_ATTR_NAMES,
|
|
95
99
|
TRANSFORM_FN_NAMES: () => TRANSFORM_FN_NAMES,
|
|
100
|
+
applyAnimatorConfig: () => applyAnimatorConfig,
|
|
96
101
|
applyPlayerEffects: () => applyPlayerEffects,
|
|
97
102
|
calcAnimationValues: () => calcAnimationValues,
|
|
98
103
|
camelCaseToKebabWordIfNeeded: () => camelCaseToKebabWordIfNeeded,
|
|
@@ -107,6 +112,7 @@ __export(index_exports, {
|
|
|
107
112
|
diffInEffect: () => diffInEffect,
|
|
108
113
|
evaluateMotionPathSegment: () => evaluateMotionPathSegment,
|
|
109
114
|
extendedPathForBrowser: () => extendedPathForBrowser,
|
|
115
|
+
foldAnimatorConfigShortcuts: () => foldAnimatorConfigShortcuts,
|
|
110
116
|
generateNewIds: () => generateNewIds,
|
|
111
117
|
getAnimatorConfig: () => getAnimatorConfig,
|
|
112
118
|
getBindings: () => getBindings,
|
|
@@ -127,6 +133,7 @@ __export(index_exports, {
|
|
|
127
133
|
materialiseInternalLoopsInTree: () => materialiseInternalLoopsInTree,
|
|
128
134
|
materialiseMotionPathInPropAnim: () => materialiseMotionPathInPropAnim,
|
|
129
135
|
materialiseMotionPathsInTree: () => materialiseMotionPathsInTree,
|
|
136
|
+
mergeAnimatorConfig: () => mergeAnimatorConfig,
|
|
130
137
|
normalizeDocument: () => getNormalisedBindings,
|
|
131
138
|
propAnimIsMotionPath: () => propAnimIsMotionPath,
|
|
132
139
|
px: () => px,
|
|
@@ -135,6 +142,7 @@ __export(index_exports, {
|
|
|
135
142
|
setupAnimationTriggers: () => setupAnimationTriggers,
|
|
136
143
|
shiftAnimatable: () => shiftAnimatable,
|
|
137
144
|
toRGBA: () => toRGBA,
|
|
145
|
+
validateDocument: () => validateDocument,
|
|
138
146
|
validateNodeEffects: () => validateNodeEffects,
|
|
139
147
|
visualModelAt: () => visualModelAt
|
|
140
148
|
});
|
|
@@ -174,7 +182,7 @@ var __objRest2 = (source, exclude) => {
|
|
|
174
182
|
return target;
|
|
175
183
|
};
|
|
176
184
|
function bezierToSvgPath(path, forceCurves = false) {
|
|
177
|
-
var
|
|
185
|
+
var _a2, _b, _c, _d;
|
|
178
186
|
const v = path.v;
|
|
179
187
|
const i = path.i;
|
|
180
188
|
const o = path.o;
|
|
@@ -185,7 +193,7 @@ function bezierToSvgPath(path, forceCurves = false) {
|
|
|
185
193
|
d.push("M" + v[0][0] + "," + v[0][1]);
|
|
186
194
|
for (let idx = 1; idx < len; idx++) {
|
|
187
195
|
const prevV = v[idx - 1];
|
|
188
|
-
const prevO = (
|
|
196
|
+
const prevO = (_a2 = o == null ? void 0 : o[idx - 1]) != null ? _a2 : prevV;
|
|
189
197
|
const currI = (_b = i == null ? void 0 : i[idx]) != null ? _b : v[idx];
|
|
190
198
|
const currV = v[idx];
|
|
191
199
|
const isLine = !forceCurves && (prevO[0] === prevV[0] && prevO[1] === prevV[1]) && (currI[0] === currV[0] && currI[1] === currV[1]);
|
|
@@ -236,7 +244,7 @@ function interpolateBeziers(paths1, paths2, progress) {
|
|
|
236
244
|
return res;
|
|
237
245
|
}
|
|
238
246
|
function interpolateBezier(path1, path2, progress) {
|
|
239
|
-
var
|
|
247
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
240
248
|
if (!path1 || !path2) return path1 || path2 || { v: [] };
|
|
241
249
|
const t = Math.min(Math.max(progress, 0), 1);
|
|
242
250
|
const len = Math.min(path1.v.length, path2.v.length);
|
|
@@ -247,7 +255,7 @@ function interpolateBezier(path1, path2, progress) {
|
|
|
247
255
|
const v1 = path1.v[idx];
|
|
248
256
|
const v2 = path2.v[idx];
|
|
249
257
|
v.push(interpolateVec(v1, v2, t));
|
|
250
|
-
const i1 = (_b = (
|
|
258
|
+
const i1 = (_b = (_a2 = path1.i) == null ? void 0 : _a2[idx]) != null ? _b : v1;
|
|
251
259
|
const i2 = (_d = (_c = path2.i) == null ? void 0 : _c[idx]) != null ? _d : v2;
|
|
252
260
|
i.push(interpolateVec(i1, i2, t));
|
|
253
261
|
const o1 = (_f = (_e = path1.o) == null ? void 0 : _e[idx]) != null ? _f : v1;
|
|
@@ -366,8 +374,8 @@ function toRGBA(color) {
|
|
|
366
374
|
return color.length === 4 ? "rgba(" + r + "," + g + "," + b + "," + color[3] + ")" : "rgb(" + r + "," + g + "," + b + ")";
|
|
367
375
|
}
|
|
368
376
|
function parseRgba(s) {
|
|
369
|
-
var
|
|
370
|
-
const inner = (
|
|
377
|
+
var _a2;
|
|
378
|
+
const inner = (_a2 = s.match(/rgba?\((.*)\)/)) == null ? void 0 : _a2[1];
|
|
371
379
|
if (!inner) throw new Error("Invalid rgb/rgba format");
|
|
372
380
|
const parts = inner.split(",").map((v) => +v.trim());
|
|
373
381
|
return [parts[0] / 255, parts[1] / 255, parts[2] / 255, ...parts[3] !== void 0 ? [parts[3]] : []];
|
|
@@ -406,9 +414,9 @@ var COLOUR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color",
|
|
|
406
414
|
var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
|
|
407
415
|
var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
408
416
|
function composeTransformParts(parts, opts) {
|
|
409
|
-
var
|
|
417
|
+
var _a2;
|
|
410
418
|
if (!parts) return "";
|
|
411
|
-
const withUnits = (
|
|
419
|
+
const withUnits = (_a2 = opts == null ? void 0 : opts.withUnits) != null ? _a2 : true;
|
|
412
420
|
const segs = [];
|
|
413
421
|
const t = parts.translate;
|
|
414
422
|
const o = parts.origin;
|
|
@@ -426,7 +434,7 @@ function composeTransformParts(parts, opts) {
|
|
|
426
434
|
return segs.join("");
|
|
427
435
|
}
|
|
428
436
|
function parseTransformParts(str2) {
|
|
429
|
-
var
|
|
437
|
+
var _a2, _b;
|
|
430
438
|
if (!str2 || typeof str2 !== "string") return void 0;
|
|
431
439
|
const out = {};
|
|
432
440
|
const re = /([a-zA-Z]+)\s*\(([^)]*)\)/g;
|
|
@@ -442,7 +450,7 @@ function parseTransformParts(str2) {
|
|
|
442
450
|
if (nums.some((n) => Number.isNaN(n))) return void 0;
|
|
443
451
|
if (fn === "translate") {
|
|
444
452
|
if (nums.length < 1 || nums.length > 2) return void 0;
|
|
445
|
-
out.translate = [nums[0], (
|
|
453
|
+
out.translate = [nums[0], (_a2 = nums[1]) != null ? _a2 : 0];
|
|
446
454
|
} else if (fn === "rotate") {
|
|
447
455
|
if (nums.length !== 1) return void 0;
|
|
448
456
|
out.rotate = nums[0];
|
|
@@ -646,8 +654,8 @@ function scrollPhaseInterval(phase, subjectSize, scrollportSize) {
|
|
|
646
654
|
}
|
|
647
655
|
var DEFAULT_PHASE = "cover";
|
|
648
656
|
function resolveRangePointU(point, defaultFraction, subjectSize, scrollportSize) {
|
|
649
|
-
var
|
|
650
|
-
const [u0, u1] = scrollPhaseInterval((
|
|
657
|
+
var _a2;
|
|
658
|
+
const [u0, u1] = scrollPhaseInterval((_a2 = point == null ? void 0 : point.phase) != null ? _a2 : DEFAULT_PHASE, subjectSize, scrollportSize);
|
|
651
659
|
const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
|
|
652
660
|
return u0 + fraction * (u1 - u0);
|
|
653
661
|
}
|
|
@@ -659,9 +667,9 @@ function scrollViewProgress(subjectStart, subjectSize, scrollportSize, range) {
|
|
|
659
667
|
return clamp((u - uStart) / (uEnd - uStart), 0, 1);
|
|
660
668
|
}
|
|
661
669
|
function scrollOffsetProgress(offset, maxOffset, range) {
|
|
662
|
-
var
|
|
670
|
+
var _a2, _b;
|
|
663
671
|
const raw = maxOffset > 0 ? clamp(offset / maxOffset, 0, 1) : 1;
|
|
664
|
-
const start = typeof ((
|
|
672
|
+
const start = typeof ((_a2 = range == null ? void 0 : range.start) == null ? void 0 : _a2.fraction) === "number" ? range.start.fraction : 0;
|
|
665
673
|
const end = typeof ((_b = range == null ? void 0 : range.end) == null ? void 0 : _b.fraction) === "number" ? range.end.fraction : 1;
|
|
666
674
|
if (end <= start) return raw >= end ? 1 : 0;
|
|
667
675
|
return clamp((raw - start) / (end - start), 0, 1);
|
|
@@ -673,6 +681,7 @@ function scrollResolveAxis(axis, writingMode) {
|
|
|
673
681
|
if (a === "inline") return vertical ? "y" : "x";
|
|
674
682
|
return vertical ? "x" : "y";
|
|
675
683
|
}
|
|
684
|
+
var PX_UNKNOWN_KEY_ERROR = "unexpected extra key";
|
|
676
685
|
function pathStr(path) {
|
|
677
686
|
if (!path.length) return ".";
|
|
678
687
|
let result = "";
|
|
@@ -794,10 +803,10 @@ var Union = class extends Base {
|
|
|
794
803
|
return this._default;
|
|
795
804
|
}
|
|
796
805
|
isValid(raw, ctx, path) {
|
|
797
|
-
var
|
|
806
|
+
var _a2;
|
|
798
807
|
const probe = ctx && { errors: [], warnings: [], strict: ctx.strict };
|
|
799
808
|
if (this.schemas.some((s) => s.isValid(raw, probe, path ? [...path] : void 0))) return true;
|
|
800
|
-
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": no union member matched for value " + ((
|
|
809
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": no union member matched for value " + ((_a2 = JSON.stringify(raw)) != null ? _a2 : "").slice(0, 240));
|
|
801
810
|
return false;
|
|
802
811
|
}
|
|
803
812
|
_canSanitize(raw) {
|
|
@@ -806,6 +815,7 @@ var Union = class extends Base {
|
|
|
806
815
|
};
|
|
807
816
|
var DiscriminatedUnion = class extends Base {
|
|
808
817
|
constructor(_key, _schemas, defaultVal) {
|
|
818
|
+
var _a2;
|
|
809
819
|
super();
|
|
810
820
|
this._key = _key;
|
|
811
821
|
this._schemas = _schemas;
|
|
@@ -814,18 +824,21 @@ var DiscriminatedUnion = class extends Base {
|
|
|
814
824
|
this._map = /* @__PURE__ */ new Map();
|
|
815
825
|
for (const s of _schemas) {
|
|
816
826
|
const keySchema = s._shape[_key];
|
|
817
|
-
if (keySchema)
|
|
827
|
+
if (!keySchema) continue;
|
|
828
|
+
const literal = (_a2 = keySchema.inner) != null ? _a2 : keySchema;
|
|
829
|
+
this._map.set(literal._default, s);
|
|
830
|
+
if (keySchema.inner) this._absentMember = s;
|
|
818
831
|
}
|
|
819
832
|
}
|
|
820
833
|
_findSchema(raw) {
|
|
821
834
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
822
835
|
const val = raw[this._key];
|
|
823
|
-
if (val === void 0 || val === null) return
|
|
836
|
+
if (val === void 0 || val === null) return this._absentMember;
|
|
824
837
|
return this._map.get(val);
|
|
825
838
|
}
|
|
826
839
|
sanitize(raw) {
|
|
827
|
-
var
|
|
828
|
-
return ((
|
|
840
|
+
var _a2;
|
|
841
|
+
return ((_a2 = this._findSchema(raw)) != null ? _a2 : this._schemas[0]).sanitize(raw);
|
|
829
842
|
}
|
|
830
843
|
isValid(raw, ctx, path) {
|
|
831
844
|
const schema = this._findSchema(raw);
|
|
@@ -854,7 +867,8 @@ var Obj = class extends Base {
|
|
|
854
867
|
const src = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
855
868
|
const out = {};
|
|
856
869
|
for (const key of Object.keys(this._shape)) {
|
|
857
|
-
|
|
870
|
+
const v = this._shape[key].sanitize(src[key]);
|
|
871
|
+
if (v !== void 0) out[key] = v;
|
|
858
872
|
}
|
|
859
873
|
return out;
|
|
860
874
|
}
|
|
@@ -876,7 +890,7 @@ var Obj = class extends Base {
|
|
|
876
890
|
if (key in this._shape) continue;
|
|
877
891
|
if (obj[key] === void 0) continue;
|
|
878
892
|
p.push(key);
|
|
879
|
-
ctx.errors.push(pathStr(p) + ":
|
|
893
|
+
ctx.errors.push(pathStr(p) + ": " + PX_UNKNOWN_KEY_ERROR);
|
|
880
894
|
p.pop();
|
|
881
895
|
ok = false;
|
|
882
896
|
}
|
|
@@ -900,7 +914,8 @@ var OpenObj = class extends Base {
|
|
|
900
914
|
const src = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
901
915
|
const out = __spreadValues2({}, src);
|
|
902
916
|
for (const key of Object.keys(this._shape)) {
|
|
903
|
-
|
|
917
|
+
const v = this._shape[key].sanitize(src[key]);
|
|
918
|
+
if (v !== void 0) out[key] = v;
|
|
904
919
|
}
|
|
905
920
|
if (this._openSchema) {
|
|
906
921
|
for (const key of Object.keys(src)) {
|
|
@@ -1041,8 +1056,8 @@ var Lazy = class extends Base {
|
|
|
1041
1056
|
this.resolved = null;
|
|
1042
1057
|
}
|
|
1043
1058
|
get schema() {
|
|
1044
|
-
var
|
|
1045
|
-
return (
|
|
1059
|
+
var _a2;
|
|
1060
|
+
return (_a2 = this.resolved) != null ? _a2 : this.resolved = this.fn();
|
|
1046
1061
|
}
|
|
1047
1062
|
sanitize(raw) {
|
|
1048
1063
|
return this.schema.sanitize(raw);
|
|
@@ -1093,7 +1108,7 @@ function schemaKeys(schema) {
|
|
|
1093
1108
|
);
|
|
1094
1109
|
}
|
|
1095
1110
|
function describeSchema(schema) {
|
|
1096
|
-
var
|
|
1111
|
+
var _a2;
|
|
1097
1112
|
const s = schema;
|
|
1098
1113
|
switch (s._kind) {
|
|
1099
1114
|
case "union":
|
|
@@ -1108,7 +1123,7 @@ function describeSchema(schema) {
|
|
|
1108
1123
|
if ("_shape" in s) return { kind: "shape", shape: s._shape, openValue: s._openSchema };
|
|
1109
1124
|
if ("item" in s) return { kind: "array", item: s.item };
|
|
1110
1125
|
if ("inner" in s) return { kind: "optional", inner: s.inner };
|
|
1111
|
-
if ("fn" in s) return { kind: "lazy", resolved: (
|
|
1126
|
+
if ("fn" in s) return { kind: "lazy", resolved: (_a2 = s.resolved) != null ? _a2 : s.resolved = s.fn() };
|
|
1112
1127
|
return { kind: "leaf" };
|
|
1113
1128
|
}
|
|
1114
1129
|
var px = {
|
|
@@ -1162,24 +1177,49 @@ var px = {
|
|
|
1162
1177
|
/** Defers schema creation — required for recursive types. Must supply a default value. */
|
|
1163
1178
|
lazy: (fn, defaultVal) => new Lazy(fn, defaultVal)
|
|
1164
1179
|
};
|
|
1180
|
+
var PX_PLAYER_SCHEMA_VERSION = "1.1";
|
|
1181
|
+
var VERSION_RE = /^(\d+)\.(\d+)(?:\.(\d+))?$/;
|
|
1182
|
+
function parseWireVersion(raw) {
|
|
1183
|
+
if (typeof raw !== "string") return void 0;
|
|
1184
|
+
const m = VERSION_RE.exec(raw.trim());
|
|
1185
|
+
if (!m) return void 0;
|
|
1186
|
+
return { a: Number(m[1]), b: Number(m[2]), c: m[3] === void 0 ? 0 : Number(m[3]) };
|
|
1187
|
+
}
|
|
1188
|
+
var _a;
|
|
1189
|
+
var PLAYER_WIRE_VERSION = (_a = parseWireVersion(PX_PLAYER_SCHEMA_VERSION)) != null ? _a : { a: 1, b: 1, c: 0 };
|
|
1165
1190
|
var PX_ANIM_SRC_ATTR_NAME = "data-px-animation-src";
|
|
1166
1191
|
var PX_ANIM_ATTR_NAME = "_px_animator";
|
|
1167
|
-
var
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1192
|
+
var PX_TIMELINE_SHARED_KEYS = ["duration", "iterations", "engine", "frameRate"];
|
|
1193
|
+
var PX_TIME_ONLY_TIMELINE_KEYS = ["trigger", "delay", "fillMode", "direction"];
|
|
1194
|
+
var PxTimelineEngine = {
|
|
1195
|
+
native: "native",
|
|
1196
|
+
js: "js"
|
|
1171
1197
|
};
|
|
1172
|
-
var
|
|
1173
|
-
|
|
1174
|
-
|
|
1198
|
+
var PxTimelineEngineExtra = __spreadProps2(__spreadValues2({}, PxTimelineEngine), {
|
|
1199
|
+
auto: "auto"
|
|
1200
|
+
});
|
|
1201
|
+
function resolveTimelineEngine(engine) {
|
|
1202
|
+
return engine === PxTimelineEngineExtra.js ? PxTimelineEngine.js : PxTimelineEngine.native;
|
|
1203
|
+
}
|
|
1204
|
+
function isNativeForced(engine) {
|
|
1205
|
+
return engine === PxTimelineEngineExtra.native;
|
|
1206
|
+
}
|
|
1207
|
+
function mayUseNativeScrollTimeline(engine) {
|
|
1208
|
+
return engine !== PxTimelineEngineExtra.js;
|
|
1209
|
+
}
|
|
1210
|
+
var PxLoopRepeatAt = {
|
|
1211
|
+
/** Segment from the START; the repetition runs BEFORE the first keyframe
|
|
1212
|
+
* (intro loops that play until the main timeline begins). */
|
|
1213
|
+
start: "start",
|
|
1214
|
+
/** DEFAULT — segment from the END; the repetition runs AFTER the last keyframe
|
|
1215
|
+
* (idle/outro loops that continue once the main timeline has finished). */
|
|
1216
|
+
end: "end"
|
|
1175
1217
|
};
|
|
1176
|
-
var
|
|
1177
|
-
/**
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
* loops that continue once the main timeline has finished). */
|
|
1182
|
-
after: "after"
|
|
1218
|
+
var PxLoopDirection = {
|
|
1219
|
+
/** DEFAULT — cycle: every repetition replays the segment the same way round. */
|
|
1220
|
+
normal: "normal",
|
|
1221
|
+
/** Ping-pong: repetitions alternate forward / backward. */
|
|
1222
|
+
alternate: "alternate"
|
|
1183
1223
|
};
|
|
1184
1224
|
var PxMaskType = {
|
|
1185
1225
|
luminance: "luminance",
|
|
@@ -1189,8 +1229,9 @@ var PxUnits = {
|
|
|
1189
1229
|
userSpaceOnUse: "userSpaceOnUse",
|
|
1190
1230
|
objectBoundingBox: "objectBoundingBox"
|
|
1191
1231
|
};
|
|
1192
|
-
var
|
|
1193
|
-
|
|
1232
|
+
var PxCloneWithout = {
|
|
1233
|
+
translate: "translate"
|
|
1234
|
+
// transform: 'transform', // future: drop rotate/scale too (content only)
|
|
1194
1235
|
};
|
|
1195
1236
|
var PxPathOverflow = {
|
|
1196
1237
|
clip: "clip",
|
|
@@ -1214,6 +1255,9 @@ var PxStrokeTrimSubPaths = {
|
|
|
1214
1255
|
};
|
|
1215
1256
|
var TEXT_ATTR = "text";
|
|
1216
1257
|
var TEXT_CONTENT_ATTR = "textContent";
|
|
1258
|
+
var CLASS_ATTR = "class";
|
|
1259
|
+
var TRANSFORM_ATTR = "transform";
|
|
1260
|
+
var OFFSET_DISTANCE_ATTR = "offsetDistance";
|
|
1217
1261
|
var INTERNAL_ATTRS = /* @__PURE__ */ new Set([
|
|
1218
1262
|
"type",
|
|
1219
1263
|
"children",
|
|
@@ -1224,7 +1268,18 @@ var INTERNAL_ATTRS = /* @__PURE__ */ new Set([
|
|
|
1224
1268
|
TEXT_ATTR,
|
|
1225
1269
|
TEXT_CONTENT_ATTR
|
|
1226
1270
|
]);
|
|
1227
|
-
var
|
|
1271
|
+
var TRANSFORM_PART = {
|
|
1272
|
+
translate: "translate",
|
|
1273
|
+
rotate: "rotate",
|
|
1274
|
+
scale: "scale",
|
|
1275
|
+
origin: "origin"
|
|
1276
|
+
};
|
|
1277
|
+
var PX_TRANSFORM_PART_KEYS = [
|
|
1278
|
+
TRANSFORM_PART.translate,
|
|
1279
|
+
TRANSFORM_PART.rotate,
|
|
1280
|
+
TRANSFORM_PART.scale,
|
|
1281
|
+
TRANSFORM_PART.origin
|
|
1282
|
+
];
|
|
1228
1283
|
var PxGradientUnits = {
|
|
1229
1284
|
userSpaceOnUse: "userSpaceOnUse",
|
|
1230
1285
|
objectBoundingBox: "objectBoundingBox"
|
|
@@ -1242,11 +1297,11 @@ function isPxElementFileFormat(fileJson) {
|
|
|
1242
1297
|
if (!(fileJson && typeof fileJson === "object" && !Array.isArray(fileJson))) {
|
|
1243
1298
|
return false;
|
|
1244
1299
|
}
|
|
1245
|
-
return fileJson
|
|
1300
|
+
return fileJson.type === "svg";
|
|
1246
1301
|
}
|
|
1247
1302
|
function getAnimatorConfig(doc) {
|
|
1248
|
-
var
|
|
1249
|
-
const cfg = (doc == null ? void 0 : doc.animator) || ((
|
|
1303
|
+
var _a2;
|
|
1304
|
+
const cfg = (doc == null ? void 0 : doc.animator) || ((_a2 = doc == null ? void 0 : doc.meta) == null ? void 0 : _a2.animator);
|
|
1250
1305
|
return cfg ? flattenAnimatorTimeline(cfg) : void 0;
|
|
1251
1306
|
}
|
|
1252
1307
|
var flattenMemo = /* @__PURE__ */ new WeakMap();
|
|
@@ -1255,14 +1310,15 @@ function flattenAnimatorTimeline(cfg) {
|
|
|
1255
1310
|
if (timeline === void 0 || timeline === null || typeof timeline !== "object") return cfg;
|
|
1256
1311
|
const memoised = flattenMemo.get(cfg);
|
|
1257
1312
|
if (memoised) return memoised;
|
|
1258
|
-
const
|
|
1313
|
+
const _a2 = cfg, { timeline: _dropped } = _a2, flat = __objRest2(_a2, ["timeline"]);
|
|
1314
|
+
if (timeline.engine !== void 0) flat.engine = timeline.engine;
|
|
1315
|
+
if (timeline.frameRate !== void 0) flat.frameRate = timeline.frameRate;
|
|
1259
1316
|
if (timeline.type === "scroll" || timeline.type === "view") {
|
|
1260
1317
|
flat.timelineSource = "scroll";
|
|
1261
1318
|
if (timeline.duration !== void 0) flat.duration = timeline.duration;
|
|
1262
1319
|
if (timeline.iterations !== void 0) flat.iterations = timeline.iterations;
|
|
1263
1320
|
const scroll = __spreadValues2({}, flat.scroll || {});
|
|
1264
1321
|
scroll.kind = timeline.type;
|
|
1265
|
-
if (timeline.engine !== void 0) scroll.driver = timeline.engine;
|
|
1266
1322
|
if (timeline.axis !== void 0) scroll.axis = timeline.axis;
|
|
1267
1323
|
if (timeline.source !== void 0) scroll.source = timeline.source;
|
|
1268
1324
|
if (timeline.subject !== void 0) scroll.subject = timeline.subject;
|
|
@@ -1280,27 +1336,27 @@ function flattenAnimatorTimeline(cfg) {
|
|
|
1280
1336
|
} else {
|
|
1281
1337
|
if (timeline.duration !== void 0) flat.duration = timeline.duration;
|
|
1282
1338
|
if (timeline.trigger !== void 0) {
|
|
1283
|
-
const _b = timeline.trigger, {
|
|
1339
|
+
const _b = timeline.trigger, { finishAction } = _b, restTrigger = __objRest2(_b, ["finishAction"]);
|
|
1284
1340
|
if (Object.keys(restTrigger).length) flat.trigger = restTrigger;
|
|
1285
|
-
if (
|
|
1341
|
+
if (finishAction !== void 0) flat.resetOnFinish = finishAction === "reset";
|
|
1286
1342
|
}
|
|
1287
1343
|
if (timeline.delay !== void 0) flat.delay = timeline.delay;
|
|
1288
1344
|
if (timeline.iterations !== void 0) flat.iterations = timeline.iterations;
|
|
1289
1345
|
if (timeline.direction !== void 0) flat.direction = timeline.direction;
|
|
1290
|
-
if (timeline.
|
|
1346
|
+
if (timeline.fillMode !== void 0) flat.fill = timeline.fillMode;
|
|
1291
1347
|
}
|
|
1292
1348
|
flattenMemo.set(cfg, flat);
|
|
1293
1349
|
return flat;
|
|
1294
1350
|
}
|
|
1295
1351
|
function getDefs(doc) {
|
|
1296
|
-
var
|
|
1352
|
+
var _a2;
|
|
1297
1353
|
if (!doc) return void 0;
|
|
1298
|
-
return (
|
|
1354
|
+
return (_a2 = getAnimatorConfig(doc)) == null ? void 0 : _a2.definitions;
|
|
1299
1355
|
}
|
|
1300
1356
|
function getBindings(doc) {
|
|
1301
|
-
var
|
|
1357
|
+
var _a2;
|
|
1302
1358
|
if (!doc) return void 0;
|
|
1303
|
-
const animateById = (
|
|
1359
|
+
const animateById = (_a2 = getAnimatorConfig(doc)) == null ? void 0 : _a2.animateById;
|
|
1304
1360
|
if (!animateById) return void 0;
|
|
1305
1361
|
return Object.entries(animateById).map(([id, anim]) => ({ id: id.startsWith("#") ? id.slice(1) : id, animate: anim }));
|
|
1306
1362
|
}
|
|
@@ -1338,16 +1394,32 @@ var PxKeyframeSchema = implementsInterface()(px.object({
|
|
|
1338
1394
|
// (review §1.3): editor data lives under `meta`. The editor still carries it on
|
|
1339
1395
|
// its internal COPY-PASTE payload, which never validates against this schema.)
|
|
1340
1396
|
}));
|
|
1397
|
+
var anyKf = (kf) => kf;
|
|
1398
|
+
var kfTime = (kf) => {
|
|
1399
|
+
var _a2, _b;
|
|
1400
|
+
return (_b = (_a2 = anyKf(kf).time) != null ? _a2 : anyKf(kf).t) != null ? _b : 0;
|
|
1401
|
+
};
|
|
1402
|
+
var kfValue = (kf) => {
|
|
1403
|
+
var _a2;
|
|
1404
|
+
return (_a2 = anyKf(kf).value) != null ? _a2 : anyKf(kf).v;
|
|
1405
|
+
};
|
|
1406
|
+
var kfEasing = (kf) => {
|
|
1407
|
+
var _a2;
|
|
1408
|
+
return (_a2 = anyKf(kf).easing) != null ? _a2 : anyKf(kf).e;
|
|
1409
|
+
};
|
|
1410
|
+
var kfTangentIn = (kf) => anyKf(kf).tangentIn;
|
|
1411
|
+
var kfTangentOut = (kf) => anyKf(kf).tangentOut;
|
|
1341
1412
|
var PxLoopSchema = implementsInterface()(px.object({
|
|
1342
1413
|
segmentCount: px.number().optional(),
|
|
1343
|
-
|
|
1344
|
-
|
|
1414
|
+
repeatAt: px.enum([PxLoopRepeatAt.start, PxLoopRepeatAt.end]).optional(),
|
|
1415
|
+
direction: px.enum([PxLoopDirection.normal, PxLoopDirection.alternate]).optional()
|
|
1345
1416
|
}));
|
|
1346
1417
|
var PxPropertyAnimationSchema = implementsInterface()(px.object({
|
|
1347
1418
|
value: PxKeyframeValueSchema.optional(),
|
|
1348
1419
|
keyframes: px.array(PxKeyframeSchema).optional(),
|
|
1349
1420
|
loop: px.union([PxLoopSchema, px.boolean()]).optional(),
|
|
1350
|
-
autoOrient: px.boolean().optional()
|
|
1421
|
+
autoOrient: px.boolean().optional(),
|
|
1422
|
+
alongPathMode: px.enum(["sampled", "offsetPath"]).optional()
|
|
1351
1423
|
}));
|
|
1352
1424
|
var PxTransformPartsSchema = implementsInterface()(px.object({
|
|
1353
1425
|
translate: px.tuple([px.number(), px.number()]).optional(),
|
|
@@ -1374,10 +1446,9 @@ var PxTriggerSchema = implementsInterface()(px.object({
|
|
|
1374
1446
|
startOn: px.enum(["load", "mouseOver", "click", "scrollIntoView", "programmatic"]).optional(),
|
|
1375
1447
|
outAction: px.enum(["continue", "pause", "reset", "reverse"]).optional(),
|
|
1376
1448
|
// What happens after a NATURAL finish — `'hold'` (default: keep the end state per
|
|
1377
|
-
// `fill`) or `'reset'` (snap back to the start state).
|
|
1378
|
-
// the
|
|
1379
|
-
|
|
1380
|
-
onFinish: px.enum(["hold", "reset"]).optional(),
|
|
1449
|
+
// `fill`) or `'reset'` (snap back to the start state). Pairs with `outAction` ("what
|
|
1450
|
+
// happens when the trigger condition ends"); both end-of-life knobs now read alike.
|
|
1451
|
+
finishAction: px.enum(["hold", "reset"]).optional(),
|
|
1381
1452
|
scrollIntoViewThreshold: px.number().optional()
|
|
1382
1453
|
}));
|
|
1383
1454
|
var PxGlyphSchema = implementsInterface()(px.object({
|
|
@@ -1397,7 +1468,7 @@ var PxDefsSchema = implementsInterface()(px.object({
|
|
|
1397
1468
|
// Review §2.6: the schema now matches the declared type — a style preset is a flat
|
|
1398
1469
|
// record of string|number attribute values, nothing nested.
|
|
1399
1470
|
styles: px.record(px.record(px.union([px.string(), px.number()]))).optional(),
|
|
1400
|
-
|
|
1471
|
+
fonts: px.record(PxGlyphFontSchema).optional()
|
|
1401
1472
|
}));
|
|
1402
1473
|
var PX_SCROLL_PHASES = ["cover", "contain", "entry", "exit", "entry-crossing", "exit-crossing"];
|
|
1403
1474
|
var PxScrollRangePointSchema = implementsInterface()(px.object({
|
|
@@ -1409,7 +1480,6 @@ var PxScrollRangeSchema = px.object({
|
|
|
1409
1480
|
end: PxScrollRangePointSchema.optional()
|
|
1410
1481
|
});
|
|
1411
1482
|
var PxScrollSchema = implementsInterface()(px.object({
|
|
1412
|
-
driver: px.enum(["custom", "native"]).optional(),
|
|
1413
1483
|
kind: px.enum(["view", "scroll"]).optional(),
|
|
1414
1484
|
axis: px.enum(["block", "inline", "x", "y"]).optional(),
|
|
1415
1485
|
source: px.enum(["nearest", "root"]).optional(),
|
|
@@ -1422,21 +1492,26 @@ var PxScrollSchema = implementsInterface()(px.object({
|
|
|
1422
1492
|
pinDistance: px.number().optional(),
|
|
1423
1493
|
range: PxScrollRangeSchema.optional()
|
|
1424
1494
|
}));
|
|
1425
|
-
var PxTimelinePinSchema = px.object({
|
|
1495
|
+
var PxTimelinePinSchema = implementsInterface()(px.object({
|
|
1426
1496
|
align: px.enum(["top", "center", "bottom"]).optional(),
|
|
1427
1497
|
top: px.number().optional(),
|
|
1428
1498
|
distance: px.number().optional()
|
|
1429
|
-
});
|
|
1430
|
-
var
|
|
1431
|
-
|
|
1499
|
+
}));
|
|
1500
|
+
var PxTimelineEngineSchema = px.enum([PxTimelineEngineExtra.auto, PxTimelineEngineExtra.native, PxTimelineEngineExtra.js]).optional();
|
|
1501
|
+
var PxTimeTimelineSchema = implementsInterface()(px.object({
|
|
1502
|
+
type: px.literal("time").optional(),
|
|
1503
|
+
engine: PxTimelineEngineSchema,
|
|
1504
|
+
frameRate: px.number().optional(),
|
|
1432
1505
|
// §2.8: duration is a property of the TIMELINE — how long one pass takes.
|
|
1433
1506
|
duration: px.number().optional(),
|
|
1434
1507
|
trigger: PxTriggerSchema.optional(),
|
|
1435
1508
|
delay: px.number().optional(),
|
|
1436
1509
|
iterations: px.union([px.number(), px.literal("infinite")]).optional(),
|
|
1437
|
-
|
|
1510
|
+
// `fillMode` on the wire (CSS `animation-fill-mode`; the runtime view calls it `fill`)
|
|
1511
|
+
// — never `fill`, which is paint everywhere else in the format.
|
|
1512
|
+
fillMode: px.enum(["forwards", "backwards", "both", "none"]).optional(),
|
|
1438
1513
|
direction: px.enum(["normal", "reverse", "alternate", "alternate-reverse"]).optional()
|
|
1439
|
-
});
|
|
1514
|
+
}));
|
|
1440
1515
|
var scrollishTimelineShape = {
|
|
1441
1516
|
// §2.8: duration is a property of the TIMELINE — under scrubbing it is the keyframe
|
|
1442
1517
|
// span the scroll range maps onto.
|
|
@@ -1444,7 +1519,8 @@ var scrollishTimelineShape = {
|
|
|
1444
1519
|
// Finite repeat count IS meaningful when scrubbing — the scroll range maps onto
|
|
1445
1520
|
// duration × iterations (rule D4; `'infinite'` cannot map to a range, so no literal here).
|
|
1446
1521
|
iterations: px.number().optional(),
|
|
1447
|
-
engine:
|
|
1522
|
+
engine: PxTimelineEngineSchema,
|
|
1523
|
+
frameRate: px.number().optional(),
|
|
1448
1524
|
axis: px.enum(["block", "inline", "x", "y"]).optional(),
|
|
1449
1525
|
source: px.enum(["nearest", "root"]).optional(),
|
|
1450
1526
|
subject: px.string().optional(),
|
|
@@ -1454,23 +1530,29 @@ var scrollishTimelineShape = {
|
|
|
1454
1530
|
pin: px.union([px.boolean(), PxTimelinePinSchema]).optional(),
|
|
1455
1531
|
range: PxScrollRangeSchema.optional()
|
|
1456
1532
|
};
|
|
1457
|
-
var PxScrollTimelineSchema =
|
|
1458
|
-
|
|
1533
|
+
var PxScrollTimelineSchema = implementsInterface()(
|
|
1534
|
+
px.object(__spreadValues2({ type: px.literal("scroll") }, scrollishTimelineShape))
|
|
1535
|
+
);
|
|
1536
|
+
var PxViewTimelineSchema = implementsInterface()(
|
|
1537
|
+
px.object(__spreadValues2({ type: px.literal("view") }, scrollishTimelineShape))
|
|
1538
|
+
);
|
|
1459
1539
|
var PxTimelineSchema = px.discriminatedUnion("type", [
|
|
1460
|
-
|
|
1540
|
+
PxTimeTimelineSchema,
|
|
1541
|
+
// first = the member an absent `type` selects
|
|
1461
1542
|
PxScrollTimelineSchema,
|
|
1462
1543
|
PxViewTimelineSchema
|
|
1463
1544
|
]);
|
|
1464
1545
|
var PxAnimatorConfigSchema = implementsInterface()(px.object({
|
|
1465
|
-
|
|
1466
|
-
//
|
|
1467
|
-
// exists only on the runtime view, like the rest of the playback dynamics.)
|
|
1468
|
-
frameRate: px.number().optional(),
|
|
1546
|
+
// (`mode`, `duration` and `frameRate` live INSIDE `timeline` on the wire — §2.8; they exist
|
|
1547
|
+
// at this level only on the runtime view, like the rest of the playback dynamics.)
|
|
1469
1548
|
// THE spelling of "what advances progress" — clock / scroll / view (review §2.1).
|
|
1470
1549
|
timeline: PxTimelineSchema.optional(),
|
|
1471
1550
|
definitions: PxDefsSchema.optional(),
|
|
1472
1551
|
animateById: px.record(PxElementAnimationSchema).optional(),
|
|
1473
|
-
|
|
1552
|
+
debugGlobalName: px.string().optional(),
|
|
1553
|
+
// Declared HERE because this is a closed object: an undeclared key would be stripped by
|
|
1554
|
+
// `sanitize` and flagged by strict validation on our own files.
|
|
1555
|
+
version: px.string().optional()
|
|
1474
1556
|
}));
|
|
1475
1557
|
var PxBindingSchema = implementsInterface()(px.object({
|
|
1476
1558
|
id: px.string(),
|
|
@@ -1519,7 +1601,7 @@ var PxRepeaterEffectSchema = implementsInterface()(px.object({
|
|
|
1519
1601
|
origin: PxAnimatableVec2Schema.optional()
|
|
1520
1602
|
}));
|
|
1521
1603
|
var PxMaskedByEffectSchema = implementsInterface()(px.object({
|
|
1522
|
-
|
|
1604
|
+
source: px.string().optional(),
|
|
1523
1605
|
maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha]).optional(),
|
|
1524
1606
|
maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
1525
1607
|
maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
@@ -1542,9 +1624,10 @@ var PxRetimeEffectSchema = implementsInterface()(px.object({
|
|
|
1542
1624
|
timeCrop: px.tuple([px.number(), px.number()]).optional()
|
|
1543
1625
|
}));
|
|
1544
1626
|
var PxCloneEffectSchema = implementsInterface()(px.object({
|
|
1545
|
-
//
|
|
1546
|
-
|
|
1547
|
-
|
|
1627
|
+
// Subtractive on purpose: the `<use>` can only point at one wrapper layer of the
|
|
1628
|
+
// source, so the choices form a ladder — 'translate' now, maybe 'transform' later.
|
|
1629
|
+
without: px.enum([PxCloneWithout.translate]).optional(),
|
|
1630
|
+
source: px.string().optional(),
|
|
1548
1631
|
retime: PxRetimeEffectSchema.optional()
|
|
1549
1632
|
}));
|
|
1550
1633
|
var PxGradientStopSchema = implementsInterface()(px.object({
|
|
@@ -1571,7 +1654,7 @@ var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
|
1571
1654
|
}));
|
|
1572
1655
|
var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
|
|
1573
1656
|
var PxTextPathEffectSchema = implementsInterface()(px.object({
|
|
1574
|
-
|
|
1657
|
+
pathData: px.string(),
|
|
1575
1658
|
pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
|
|
1576
1659
|
lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
|
|
1577
1660
|
method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
|
|
@@ -1611,16 +1694,33 @@ function validateNodeEffects(root, opts) {
|
|
|
1611
1694
|
walk(root, "root");
|
|
1612
1695
|
return warnings;
|
|
1613
1696
|
}
|
|
1697
|
+
function validateDocument(doc) {
|
|
1698
|
+
const ctx = { errors: [], warnings: [], strict: true };
|
|
1699
|
+
const problems = PxAnimatedSvgDocumentSchema.isValid(doc, ctx, ["root"]) ? [] : [...ctx.errors];
|
|
1700
|
+
if (doc && typeof doc === "object") {
|
|
1701
|
+
for (const w of validateNodeEffects(doc, { strict: true })) {
|
|
1702
|
+
if (!problems.includes(w)) problems.push(w);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
return problems;
|
|
1706
|
+
}
|
|
1614
1707
|
var PxNodeBase = px.openObject({
|
|
1615
1708
|
// CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
|
|
1616
1709
|
// kind of thing is this", discriminated by its CARRIER — here the node TAG
|
|
1617
|
-
// (`rect`, `text`), and inside a sub-object that object's kind (`
|
|
1710
|
+
// (`rect`, `text`), and inside a sub-object that object's kind (`fillGradient.type`,
|
|
1618
1711
|
// `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
|
|
1619
1712
|
// the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
|
|
1620
1713
|
// would add words that all mean "type" and still need the carrier to read.
|
|
1621
1714
|
// Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
|
|
1622
1715
|
// (issues V3), never of distinct key names.
|
|
1623
1716
|
type: px.string(),
|
|
1717
|
+
// The escape hatch for elements that carry a REAL `type` attribute — `<feTurbulence
|
|
1718
|
+
// type="fractalNoise">`, `<feFuncR type="table">`, `<feColorMatrix type="saturate">`.
|
|
1719
|
+
// `type` is taken by the tag name, so the attribute travels here and the renderer puts
|
|
1720
|
+
// it back (`PxAnimatorDOM.renderNode`, `PxRnRender`). Declared here — not merely
|
|
1721
|
+
// documented — because a wire key that is not in a schema is invisible to the
|
|
1722
|
+
// minifier's reserve list and gets renamed (MINIFICATION-BOUNDARY-PLAN.md §1.1).
|
|
1723
|
+
domType: px.string().optional(),
|
|
1624
1724
|
id: px.string().optional(),
|
|
1625
1725
|
meta: px.any().optional(),
|
|
1626
1726
|
// Player-effects bucket emitted by the Editor's lightweight design format.
|
|
@@ -1677,7 +1777,7 @@ function deepClone(value) {
|
|
|
1677
1777
|
return cloned;
|
|
1678
1778
|
}
|
|
1679
1779
|
function generateNewIds(doc) {
|
|
1680
|
-
var
|
|
1780
|
+
var _a2, _b;
|
|
1681
1781
|
const cloned = deepClone(doc);
|
|
1682
1782
|
const idMap = /* @__PURE__ */ new Map();
|
|
1683
1783
|
const hashRefAttrs = /* @__PURE__ */ new Set(["href", "xlink:href"]);
|
|
@@ -1695,7 +1795,8 @@ function generateNewIds(doc) {
|
|
|
1695
1795
|
"flood-color",
|
|
1696
1796
|
"lighting-color"
|
|
1697
1797
|
]);
|
|
1698
|
-
const directIdRefAttrs = /* @__PURE__ */ new Set(["
|
|
1798
|
+
const directIdRefAttrs = /* @__PURE__ */ new Set(["targetId", "boundElementId"]);
|
|
1799
|
+
const isEffectSourceRef = (key, parentKey) => key === "source" && (parentKey === "maskedBy" || parentKey === "clone");
|
|
1699
1800
|
function collectIds(node) {
|
|
1700
1801
|
if (!node || typeof node !== "object") return;
|
|
1701
1802
|
if (node.id && typeof node.id === "string") {
|
|
@@ -1712,7 +1813,7 @@ function generateNewIds(doc) {
|
|
|
1712
1813
|
}
|
|
1713
1814
|
}
|
|
1714
1815
|
}
|
|
1715
|
-
function updateRefs(node) {
|
|
1816
|
+
function updateRefs(node, parentKey) {
|
|
1716
1817
|
if (!node || typeof node !== "object") return;
|
|
1717
1818
|
for (const [key, value] of Object.entries(node)) {
|
|
1718
1819
|
if (key === "children") {
|
|
@@ -1732,7 +1833,7 @@ function generateNewIds(doc) {
|
|
|
1732
1833
|
}
|
|
1733
1834
|
} else if (urlRefAttrs.has(key)) {
|
|
1734
1835
|
node[key] = replaceUrlRefs(value, idMap);
|
|
1735
|
-
} else if (directIdRefAttrs.has(key)) {
|
|
1836
|
+
} else if (directIdRefAttrs.has(key) || isEffectSourceRef(key, parentKey)) {
|
|
1736
1837
|
const hasHash = value.startsWith("#");
|
|
1737
1838
|
const newId = idMap.get(hasHash ? value.slice(1) : value);
|
|
1738
1839
|
if (newId) {
|
|
@@ -1748,13 +1849,13 @@ function generateNewIds(doc) {
|
|
|
1748
1849
|
}
|
|
1749
1850
|
}
|
|
1750
1851
|
} else if (typeof value === "object" && value !== null) {
|
|
1751
|
-
updateRefs(value);
|
|
1852
|
+
updateRefs(value, key);
|
|
1752
1853
|
}
|
|
1753
1854
|
}
|
|
1754
1855
|
}
|
|
1755
1856
|
collectIds(cloned);
|
|
1756
1857
|
updateRefs(cloned);
|
|
1757
|
-
const docAnimate = (
|
|
1858
|
+
const docAnimate = (_a2 = cloned.animator) == null ? void 0 : _a2.animateById;
|
|
1758
1859
|
if (docAnimate && typeof docAnimate === "object") {
|
|
1759
1860
|
const updatedAnimate = {};
|
|
1760
1861
|
for (const [key, anim] of Object.entries(docAnimate)) {
|
|
@@ -1836,10 +1937,10 @@ function sanitiseAttributeValue(name, value) {
|
|
|
1836
1937
|
return value;
|
|
1837
1938
|
}
|
|
1838
1939
|
function resolveStyle(style, defs) {
|
|
1839
|
-
var
|
|
1940
|
+
var _a2;
|
|
1840
1941
|
if (!style) return void 0;
|
|
1841
1942
|
if (typeof style === "string") {
|
|
1842
|
-
return (
|
|
1943
|
+
return (_a2 = defs == null ? void 0 : defs.styles) == null ? void 0 : _a2[style];
|
|
1843
1944
|
}
|
|
1844
1945
|
return style;
|
|
1845
1946
|
}
|
|
@@ -1854,14 +1955,14 @@ function getNormalizedProps(props) {
|
|
|
1854
1955
|
propsCopy[key] = toRGBA(value);
|
|
1855
1956
|
} else if (key === "transform" && value !== null && typeof value === "object" && !Array.isArray(value) && !value.keyframes) {
|
|
1856
1957
|
const parts = value.value && typeof value.value === "object" ? value.value : value;
|
|
1857
|
-
propsCopy[
|
|
1958
|
+
propsCopy[TRANSFORM_ATTR] = composeTransformParts(parts, { withUnits: false });
|
|
1858
1959
|
} else if (TRANSFORM_FN_NAMES.has(key)) {
|
|
1859
1960
|
if (Array.isArray(value)) {
|
|
1860
1961
|
if (key === "translate") value = value.map((v) => v + "px");
|
|
1861
1962
|
value = value.join(",");
|
|
1862
1963
|
}
|
|
1863
1964
|
if (key === "rotate") value = value + "deg";
|
|
1864
|
-
propsCopy[
|
|
1965
|
+
propsCopy[TRANSFORM_ATTR] = key + "(" + value + ")";
|
|
1865
1966
|
} else if (Array.isArray(value)) {
|
|
1866
1967
|
propsCopy[key] = value.join(",");
|
|
1867
1968
|
} else if (value !== void 0 && value !== null) {
|
|
@@ -1871,8 +1972,7 @@ function getNormalizedProps(props) {
|
|
|
1871
1972
|
return propsCopy;
|
|
1872
1973
|
}
|
|
1873
1974
|
function getKfTranslate(kf) {
|
|
1874
|
-
|
|
1875
|
-
const v = (_a = kf.value) != null ? _a : kf.v;
|
|
1975
|
+
const v = kfValue(kf);
|
|
1876
1976
|
if (!v) return void 0;
|
|
1877
1977
|
if (Array.isArray(v) && v.length >= 2 && typeof v[0] === "number" && typeof v[1] === "number") {
|
|
1878
1978
|
return [v[0], v[1]];
|
|
@@ -1882,31 +1982,27 @@ function getKfTranslate(kf) {
|
|
|
1882
1982
|
return void 0;
|
|
1883
1983
|
}
|
|
1884
1984
|
function getKfTime(kf) {
|
|
1885
|
-
|
|
1886
|
-
return (_b = (_a = kf.time) != null ? _a : kf.t) != null ? _b : 0;
|
|
1985
|
+
return kfTime(kf);
|
|
1887
1986
|
}
|
|
1888
1987
|
function getKfEasing(kf) {
|
|
1889
|
-
|
|
1890
|
-
return (_a = kf.easing) != null ? _a : kf.e;
|
|
1988
|
+
return kfEasing(kf);
|
|
1891
1989
|
}
|
|
1892
1990
|
function propAnimIsMotionPath(anim) {
|
|
1893
|
-
var _a, _b;
|
|
1894
1991
|
const kfs = anim.keyframes;
|
|
1895
1992
|
if (!Array.isArray(kfs)) return false;
|
|
1896
1993
|
if (anim.autoOrient) return true;
|
|
1897
1994
|
for (const kf of kfs) {
|
|
1898
|
-
if ((
|
|
1995
|
+
if (kfTangentIn(kf) || kfTangentOut(kf)) return true;
|
|
1899
1996
|
}
|
|
1900
1997
|
return false;
|
|
1901
1998
|
}
|
|
1902
1999
|
var _segmentCache = /* @__PURE__ */ new WeakMap();
|
|
1903
2000
|
function getSegmentCache(prevKf, nextKf, prevPos, nextPos) {
|
|
1904
|
-
var _a, _b;
|
|
1905
2001
|
let byNext = _segmentCache.get(prevKf);
|
|
1906
2002
|
const existing = byNext == null ? void 0 : byNext.get(nextKf);
|
|
1907
2003
|
if (existing) return existing;
|
|
1908
|
-
const to = (
|
|
1909
|
-
const ti = (
|
|
2004
|
+
const to = kfTangentOut(prevKf);
|
|
2005
|
+
const ti = kfTangentIn(nextKf);
|
|
1910
2006
|
const P1 = [prevPos[0] + (to ? to[0] : 0), prevPos[1] + (to ? to[1] : 0)];
|
|
1911
2007
|
const P2 = [nextPos[0] + (ti ? ti[0] : 0), nextPos[1] + (ti ? ti[1] : 0)];
|
|
1912
2008
|
const lut = bezier2D_arcLengthLUT(prevPos, P1, P2, nextPos);
|
|
@@ -1956,12 +2052,12 @@ var DEFAULT_FLATNESS_TOL = 0.5;
|
|
|
1956
2052
|
var DEFAULT_ROTATION_TOL = 5;
|
|
1957
2053
|
var DEFAULT_MAX_SAMPLES = 32;
|
|
1958
2054
|
function materialiseMotionPathInPropAnim(anim, opts) {
|
|
1959
|
-
var
|
|
2055
|
+
var _a2, _b, _c;
|
|
1960
2056
|
if (!propAnimIsMotionPath(anim)) return anim;
|
|
1961
2057
|
const kfs = anim.keyframes;
|
|
1962
2058
|
if (!Array.isArray(kfs) || kfs.length < 2) return anim;
|
|
1963
2059
|
const autoOrient = !!anim.autoOrient;
|
|
1964
|
-
const flatnessTol = (
|
|
2060
|
+
const flatnessTol = (_a2 = opts == null ? void 0 : opts.flatnessTolerance) != null ? _a2 : DEFAULT_FLATNESS_TOL;
|
|
1965
2061
|
const rotationTol = (_b = opts == null ? void 0 : opts.rotationTolerance) != null ? _b : DEFAULT_ROTATION_TOL;
|
|
1966
2062
|
const maxSamples = (_c = opts == null ? void 0 : opts.maxSamplesPerSegment) != null ? _c : DEFAULT_MAX_SAMPLES;
|
|
1967
2063
|
const out = [];
|
|
@@ -1997,10 +2093,9 @@ function materialiseMotionPathInPropAnim(anim, opts) {
|
|
|
1997
2093
|
return result;
|
|
1998
2094
|
}
|
|
1999
2095
|
function unwrapAutoOrientRotations(kfs) {
|
|
2000
|
-
var _a;
|
|
2001
2096
|
let prev;
|
|
2002
2097
|
for (const kf of kfs) {
|
|
2003
|
-
const v = (
|
|
2098
|
+
const v = kfValue(kf);
|
|
2004
2099
|
if (!v || typeof v.rotate !== "number") continue;
|
|
2005
2100
|
if (prev === void 0) {
|
|
2006
2101
|
prev = v.rotate;
|
|
@@ -2017,8 +2112,7 @@ function makeOutKf(time, value) {
|
|
|
2017
2112
|
return { t: time, v: value };
|
|
2018
2113
|
}
|
|
2019
2114
|
function getKfValueParts(kf) {
|
|
2020
|
-
|
|
2021
|
-
const v = (_a = kf.value) != null ? _a : kf.v;
|
|
2115
|
+
const v = kfValue(kf);
|
|
2022
2116
|
if (!v || typeof v !== "object" || Array.isArray(v)) return void 0;
|
|
2023
2117
|
return v;
|
|
2024
2118
|
}
|
|
@@ -2079,9 +2173,8 @@ function wrappedAngleDelta(a, b) {
|
|
|
2079
2173
|
return d;
|
|
2080
2174
|
}
|
|
2081
2175
|
function insertSharpCornerStepKfIfNeeded(out, prevKf, nextKf, prevPos, nextPos, rotationTol) {
|
|
2082
|
-
var _a;
|
|
2083
2176
|
const lastKf = out[out.length - 1];
|
|
2084
|
-
const lastV = (
|
|
2177
|
+
const lastV = kfValue(lastKf);
|
|
2085
2178
|
const prevExit = lastV == null ? void 0 : lastV.rotate;
|
|
2086
2179
|
if (typeof prevExit !== "number") return;
|
|
2087
2180
|
const boundaryV = getKfValueParts(prevKf);
|
|
@@ -2392,21 +2485,21 @@ function normalizePathValue(value) {
|
|
|
2392
2485
|
return value;
|
|
2393
2486
|
}
|
|
2394
2487
|
function resolveEasing(easing, defs) {
|
|
2395
|
-
var
|
|
2488
|
+
var _a2;
|
|
2396
2489
|
if (!easing) return void 0;
|
|
2397
2490
|
if (Array.isArray(easing)) {
|
|
2398
2491
|
return easing;
|
|
2399
2492
|
}
|
|
2400
|
-
if ((
|
|
2493
|
+
if ((_a2 = defs == null ? void 0 : defs.easings) == null ? void 0 : _a2[easing]) {
|
|
2401
2494
|
return defs.easings[easing];
|
|
2402
2495
|
}
|
|
2403
2496
|
console.warn("Unknown easing name: " + easing);
|
|
2404
2497
|
return void 0;
|
|
2405
2498
|
}
|
|
2406
2499
|
function resolveAnimation(animRef, defs) {
|
|
2407
|
-
var
|
|
2500
|
+
var _a2;
|
|
2408
2501
|
if (typeof animRef === "string") {
|
|
2409
|
-
const resolved = (
|
|
2502
|
+
const resolved = (_a2 = defs == null ? void 0 : defs.animations) == null ? void 0 : _a2[animRef];
|
|
2410
2503
|
if (!resolved) {
|
|
2411
2504
|
console.warn("Unknown animation name: " + animRef);
|
|
2412
2505
|
}
|
|
@@ -2431,9 +2524,9 @@ function resolveElementAnimation(animate, defs) {
|
|
|
2431
2524
|
return results;
|
|
2432
2525
|
}
|
|
2433
2526
|
function interpolateValue(propName, a, b, t) {
|
|
2434
|
-
var
|
|
2527
|
+
var _a2, _b;
|
|
2435
2528
|
if (propName === "d") {
|
|
2436
|
-
const aPaths = (
|
|
2529
|
+
const aPaths = (_a2 = a == null ? void 0 : a.paths) != null ? _a2 : Array.isArray(a) ? a : [];
|
|
2437
2530
|
const bPaths = (_b = b == null ? void 0 : b.paths) != null ? _b : Array.isArray(b) ? b : [];
|
|
2438
2531
|
return { paths: interpolateBeziers(aPaths, bPaths, t) };
|
|
2439
2532
|
}
|
|
@@ -2469,11 +2562,11 @@ function interpolateTransformParts(a, b, t) {
|
|
|
2469
2562
|
return out;
|
|
2470
2563
|
}
|
|
2471
2564
|
function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
2472
|
-
var
|
|
2565
|
+
var _a2, _b, _c, _d, _e;
|
|
2473
2566
|
const totalIntervals = keyframes.length - 1;
|
|
2474
|
-
const segCount = clamp((
|
|
2567
|
+
const segCount = clamp((_a2 = loop.segmentCount) != null ? _a2 : totalIntervals, 1, totalIntervals);
|
|
2475
2568
|
let segKfs;
|
|
2476
|
-
if (loop.
|
|
2569
|
+
if (loop.repeatAt === PxLoopRepeatAt.start) {
|
|
2477
2570
|
segKfs = keyframes.slice(0, segCount + 1);
|
|
2478
2571
|
} else {
|
|
2479
2572
|
segKfs = keyframes.slice(totalIntervals - segCount);
|
|
@@ -2481,7 +2574,7 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2481
2574
|
const firstT = (_b = keyframes[0].t) != null ? _b : 0;
|
|
2482
2575
|
const lastT = (_c = keyframes[keyframes.length - 1].t) != null ? _c : 0;
|
|
2483
2576
|
let fillStart, fillEnd;
|
|
2484
|
-
if (loop.
|
|
2577
|
+
if (loop.repeatAt === PxLoopRepeatAt.start) {
|
|
2485
2578
|
fillStart = 0;
|
|
2486
2579
|
fillEnd = firstT;
|
|
2487
2580
|
} else {
|
|
@@ -2494,26 +2587,23 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2494
2587
|
const segEndT = (_e = segKfs[segKfs.length - 1].t) != null ? _e : 0;
|
|
2495
2588
|
const segDuration = segEndT - segStartT;
|
|
2496
2589
|
if (segDuration <= 0) return keyframes;
|
|
2497
|
-
const template = segKfs.map((kf) => {
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
tangentOut: (_b2 = kf.tangentOut) != null ? _b2 : kf.to
|
|
2505
|
-
};
|
|
2506
|
-
});
|
|
2590
|
+
const template = segKfs.map((kf) => ({
|
|
2591
|
+
relT: (kf.t - segStartT) / segDuration,
|
|
2592
|
+
v: kf.v,
|
|
2593
|
+
e: kf.e,
|
|
2594
|
+
tangentIn: kfTangentIn(kf),
|
|
2595
|
+
tangentOut: kfTangentOut(kf)
|
|
2596
|
+
}));
|
|
2507
2597
|
const fullReps = Math.floor(fillDuration / segDuration);
|
|
2508
2598
|
const remainder = fillDuration - fullReps * segDuration;
|
|
2509
2599
|
const partialFraction = remainder / segDuration;
|
|
2510
2600
|
const looped = [];
|
|
2511
|
-
const separateBoundary = loop.
|
|
2601
|
+
const separateBoundary = loop.repeatAt !== PxLoopRepeatAt.start;
|
|
2512
2602
|
const originalTerminalKf = keyframes[keyframes.length - 1];
|
|
2513
2603
|
let terminalEasingOverride;
|
|
2514
2604
|
let hasTerminalEasingOverride = false;
|
|
2515
2605
|
function appendRep(repStart, isReversed, partial) {
|
|
2516
|
-
var
|
|
2606
|
+
var _a3;
|
|
2517
2607
|
let entries;
|
|
2518
2608
|
if (isReversed) {
|
|
2519
2609
|
entries = [];
|
|
@@ -2550,7 +2640,7 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2550
2640
|
return;
|
|
2551
2641
|
}
|
|
2552
2642
|
const prevKf = looped.length > 0 ? looped[looped.length - 1] : originalTerminalKf;
|
|
2553
|
-
const isBoundary = separateBoundary && i === 0 && prevKf !== void 0 && Math.abs(((
|
|
2643
|
+
const isBoundary = separateBoundary && i === 0 && prevKf !== void 0 && Math.abs(((_a3 = prevKf.t) != null ? _a3 : 0) - (repStart + entry.relT * segDuration)) < 1e-9;
|
|
2554
2644
|
if (isBoundary) {
|
|
2555
2645
|
if (deepEqualValue(prevKf.v, entry.v)) {
|
|
2556
2646
|
if (looped.length > 0) {
|
|
@@ -2616,30 +2706,30 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2616
2706
|
looped.push(pushed);
|
|
2617
2707
|
}
|
|
2618
2708
|
}
|
|
2619
|
-
if (loop.
|
|
2709
|
+
if (loop.repeatAt === PxLoopRepeatAt.start) {
|
|
2620
2710
|
if (partialFraction > 1e-9) {
|
|
2621
|
-
const isReversed =
|
|
2711
|
+
const isReversed = loop.direction === PxLoopDirection.alternate && fullReps % 2 === 0;
|
|
2622
2712
|
appendRepTail(fillStart, isReversed, partialFraction);
|
|
2623
2713
|
}
|
|
2624
2714
|
for (let rep = 0; rep < fullReps; rep++) {
|
|
2625
2715
|
const distFromBoundary = fullReps - 1 - rep;
|
|
2626
|
-
const isReversed =
|
|
2716
|
+
const isReversed = loop.direction === PxLoopDirection.alternate && distFromBoundary % 2 === 0;
|
|
2627
2717
|
const repStart = fillStart + remainder + rep * segDuration;
|
|
2628
2718
|
appendRep(repStart, isReversed);
|
|
2629
2719
|
}
|
|
2630
2720
|
} else {
|
|
2631
2721
|
for (let rep = 0; rep < fullReps; rep++) {
|
|
2632
|
-
const isReversed =
|
|
2722
|
+
const isReversed = loop.direction === PxLoopDirection.alternate && rep % 2 === 0;
|
|
2633
2723
|
const repStart = fillStart + rep * segDuration;
|
|
2634
2724
|
appendRep(repStart, isReversed);
|
|
2635
2725
|
}
|
|
2636
2726
|
if (partialFraction > 1e-9) {
|
|
2637
|
-
const isReversed =
|
|
2727
|
+
const isReversed = loop.direction === PxLoopDirection.alternate && fullReps % 2 === 0;
|
|
2638
2728
|
const repStart = fillStart + fullReps * segDuration;
|
|
2639
2729
|
appendRep(repStart, isReversed, partialFraction);
|
|
2640
2730
|
}
|
|
2641
2731
|
}
|
|
2642
|
-
if (loop.
|
|
2732
|
+
if (loop.repeatAt === PxLoopRepeatAt.start) {
|
|
2643
2733
|
return [...looped, ...keyframes];
|
|
2644
2734
|
} else {
|
|
2645
2735
|
if (hasTerminalEasingOverride && keyframes.length > 0) {
|
|
@@ -2651,34 +2741,34 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2651
2741
|
}
|
|
2652
2742
|
}
|
|
2653
2743
|
function normalizeKeyframes(propName, propAnim, duration, defs) {
|
|
2654
|
-
var
|
|
2744
|
+
var _a2;
|
|
2655
2745
|
const keyframes = propAnim.keyframes || [];
|
|
2656
2746
|
const normalized = [];
|
|
2657
2747
|
for (const kf of keyframes) {
|
|
2658
|
-
const timePct = (
|
|
2659
|
-
let value = (
|
|
2660
|
-
const easing = (
|
|
2748
|
+
const timePct = kfTime(kf);
|
|
2749
|
+
let value = kfValue(kf);
|
|
2750
|
+
const easing = kfEasing(kf);
|
|
2661
2751
|
if (propName === "d") {
|
|
2662
2752
|
value = normalizePathValue(value);
|
|
2663
2753
|
}
|
|
2664
2754
|
const propNameKebab = isCamelCaseWord(propName) ? camelCaseToKebabWordIfNeeded(propName) : propName;
|
|
2665
2755
|
if (COLOUR_ATTR_NAMES.has(propNameKebab)) {
|
|
2666
|
-
value = (
|
|
2756
|
+
value = (_a2 = parseColor(value)) != null ? _a2 : value;
|
|
2667
2757
|
}
|
|
2668
2758
|
const normKf = {
|
|
2669
2759
|
t: timePct,
|
|
2670
2760
|
v: value,
|
|
2671
2761
|
e: resolveEasing(easing, defs)
|
|
2672
2762
|
};
|
|
2673
|
-
const tIn = (
|
|
2674
|
-
const tOut = (
|
|
2763
|
+
const tIn = kfTangentIn(kf);
|
|
2764
|
+
const tOut = kfTangentOut(kf);
|
|
2675
2765
|
if (tIn) normKf.tangentIn = tIn;
|
|
2676
2766
|
if (tOut) normKf.tangentOut = tOut;
|
|
2677
2767
|
normalized.push(normKf);
|
|
2678
2768
|
}
|
|
2679
2769
|
normalized.sort((a, b) => {
|
|
2680
|
-
var
|
|
2681
|
-
return ((
|
|
2770
|
+
var _a3, _b;
|
|
2771
|
+
return ((_a3 = a.t) != null ? _a3 : 0) - ((_b = b.t) != null ? _b : 0);
|
|
2682
2772
|
});
|
|
2683
2773
|
const loopRaw = propAnim.loop;
|
|
2684
2774
|
const loop = loopRaw === true ? {} : loopRaw || void 0;
|
|
@@ -2705,15 +2795,17 @@ function materialiseInternalLoopsInPropAnim(propName, propAnim, duration) {
|
|
|
2705
2795
|
const propNameKebab = isCamelCaseWord(propName) ? camelCaseToKebabWordIfNeeded(propName) : propName;
|
|
2706
2796
|
const isColour = COLOUR_ATTR_NAMES.has(propNameKebab);
|
|
2707
2797
|
const kfs = rawKfs.map((kf) => {
|
|
2708
|
-
var
|
|
2709
|
-
const t = (
|
|
2710
|
-
let v = (
|
|
2798
|
+
var _a2;
|
|
2799
|
+
const t = kfTime(kf);
|
|
2800
|
+
let v = kfValue(kf);
|
|
2711
2801
|
if (propName === "d") v = normalizePathValue(v);
|
|
2712
|
-
if (isColour) v = (
|
|
2713
|
-
const e = (
|
|
2802
|
+
if (isColour) v = (_a2 = parseColor(v)) != null ? _a2 : v;
|
|
2803
|
+
const e = kfEasing(kf);
|
|
2714
2804
|
const out2 = { t, v, e };
|
|
2715
|
-
|
|
2716
|
-
|
|
2805
|
+
const tIn = kfTangentIn(kf);
|
|
2806
|
+
const tOut = kfTangentOut(kf);
|
|
2807
|
+
if (tIn) out2.tangentIn = tIn;
|
|
2808
|
+
if (tOut) out2.tangentOut = tOut;
|
|
2717
2809
|
return out2;
|
|
2718
2810
|
});
|
|
2719
2811
|
const expanded = expandLoopKeyframes(propName, kfs, loop, duration);
|
|
@@ -2764,7 +2856,7 @@ function mergeStaticTransformIntoAnimDef(animDef, staticTransform) {
|
|
|
2764
2856
|
const staticParts = staticTransform && typeof staticTransform === "object" && !Array.isArray(staticTransform) ? staticTransform : parseTransformParts(staticTransform);
|
|
2765
2857
|
if (!staticParts || !Object.keys(staticParts).length) return animDef;
|
|
2766
2858
|
const mergeKfValue = (v) => v && typeof v === "object" && !Array.isArray(v) ? __spreadValues2(__spreadValues2({}, staticParts), v) : v;
|
|
2767
|
-
const transformAnim = animDef[
|
|
2859
|
+
const transformAnim = animDef[TRANSFORM_ATTR];
|
|
2768
2860
|
if (transformAnim && typeof transformAnim === "object") {
|
|
2769
2861
|
const anim = transformAnim;
|
|
2770
2862
|
if (Array.isArray(anim.keyframes)) {
|
|
@@ -2789,7 +2881,7 @@ function mergeStaticTransformIntoAnimDef(animDef, staticTransform) {
|
|
|
2789
2881
|
delete rest[ch];
|
|
2790
2882
|
return __spreadProps2(__spreadValues2({}, rest), { transform: lifted });
|
|
2791
2883
|
}
|
|
2792
|
-
function normalizeAnimationDefinition(animDef, duration, defs, engine =
|
|
2884
|
+
function normalizeAnimationDefinition(animDef, duration, defs, engine = PxTimelineEngine.native) {
|
|
2793
2885
|
const normalized = {};
|
|
2794
2886
|
for (const [propName, propAnim] of Object.entries(animDef)) {
|
|
2795
2887
|
if (propName === "transform" && propAnim.alongPathMode === "offsetPath" && animDef["offsetDistance"] !== void 0) {
|
|
@@ -2800,12 +2892,12 @@ function normalizeAnimationDefinition(animDef, duration, defs, engine = PxAnimat
|
|
|
2800
2892
|
const out = { keyframes: normalizedKfs };
|
|
2801
2893
|
if (propAnim.autoOrient !== void 0) out.autoOrient = propAnim.autoOrient;
|
|
2802
2894
|
if (propAnim.loop !== void 0) out.loop = propAnim.loop;
|
|
2803
|
-
normalized[propName] = engine ===
|
|
2895
|
+
normalized[propName] = engine === PxTimelineEngine.native && propName === "transform" ? materialiseMotionPathInPropAnim(out) : out;
|
|
2804
2896
|
}
|
|
2805
2897
|
}
|
|
2806
2898
|
return normalized;
|
|
2807
2899
|
}
|
|
2808
|
-
function getNormalisedBindings(doc, engine =
|
|
2900
|
+
function getNormalisedBindings(doc, engine = PxTimelineEngine.native) {
|
|
2809
2901
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
2810
2902
|
const defs = getDefs(doc);
|
|
2811
2903
|
const duration = animatorConfig.duration || 1e3;
|
|
@@ -2851,12 +2943,12 @@ function getNormalisedBindings(doc, engine = PxAnimatorEngine.waapi) {
|
|
|
2851
2943
|
return bindings;
|
|
2852
2944
|
}
|
|
2853
2945
|
function getKeyframesPair(keyframes, progress) {
|
|
2854
|
-
var
|
|
2946
|
+
var _a2, _b;
|
|
2855
2947
|
const last = keyframes.length - 1;
|
|
2856
2948
|
let prevKf = keyframes[0];
|
|
2857
2949
|
let nextKf = keyframes[last > 0 ? 1 : 0];
|
|
2858
2950
|
for (let j = 0; j < last; j++) {
|
|
2859
|
-
const aOff = (
|
|
2951
|
+
const aOff = (_a2 = keyframes[j].t) != null ? _a2 : 0;
|
|
2860
2952
|
const bOff = (_b = keyframes[j + 1].t) != null ? _b : 0;
|
|
2861
2953
|
if (aOff <= progress && progress <= bOff) {
|
|
2862
2954
|
prevKf = keyframes[j];
|
|
@@ -2871,13 +2963,13 @@ function getKeyframesPair(keyframes, progress) {
|
|
|
2871
2963
|
return { prevKf, nextKf };
|
|
2872
2964
|
}
|
|
2873
2965
|
function calcPropertyValue(propName, propAnim, progress) {
|
|
2874
|
-
var
|
|
2966
|
+
var _a2, _b, _c, _d;
|
|
2875
2967
|
const keyframes = propAnim.keyframes || [];
|
|
2876
2968
|
if (keyframes.length === 0) return null;
|
|
2877
2969
|
const { prevKf, nextKf } = getKeyframesPair(keyframes, progress);
|
|
2878
|
-
let localProgress = prevKf === nextKf ? 0 : remap(progress, (
|
|
2970
|
+
let localProgress = prevKf === nextKf ? 0 : remap(progress, (_a2 = prevKf.t) != null ? _a2 : 0, (_b = nextKf.t) != null ? _b : 0, 0, 1);
|
|
2879
2971
|
localProgress = clamp(localProgress, 0, 1);
|
|
2880
|
-
const easing = (
|
|
2972
|
+
const easing = kfEasing(prevKf);
|
|
2881
2973
|
if (easing && Array.isArray(easing)) {
|
|
2882
2974
|
try {
|
|
2883
2975
|
localProgress = cubicBezier(easing)(localProgress);
|
|
@@ -2886,11 +2978,11 @@ function calcPropertyValue(propName, propAnim, progress) {
|
|
|
2886
2978
|
}
|
|
2887
2979
|
let cssAttrName = isCamelCaseWord(propName) ? camelCaseToKebabWordIfNeeded(propName) : propName;
|
|
2888
2980
|
let cssValue = null;
|
|
2889
|
-
const prevV =
|
|
2890
|
-
const nextV =
|
|
2981
|
+
const prevV = prevKf == null ? void 0 : prevKf.v;
|
|
2982
|
+
const nextV = nextKf == null ? void 0 : nextKf.v;
|
|
2891
2983
|
if (cssAttrName === "d") {
|
|
2892
|
-
const prevPaths = (
|
|
2893
|
-
const nextPaths = (
|
|
2984
|
+
const prevPaths = (_c = prevV == null ? void 0 : prevV.paths) != null ? _c : Array.isArray(prevV) ? prevV : [];
|
|
2985
|
+
const nextPaths = (_d = nextV == null ? void 0 : nextV.paths) != null ? _d : Array.isArray(nextV) ? nextV : [];
|
|
2894
2986
|
cssValue = interpolateBeziers(
|
|
2895
2987
|
prevPaths,
|
|
2896
2988
|
nextPaths,
|
|
@@ -3002,13 +3094,13 @@ function deepClonePxNode(value) {
|
|
|
3002
3094
|
function regenerateIdsAndRewriteRefs(root, genId3) {
|
|
3003
3095
|
const oldToNew = /* @__PURE__ */ new Map();
|
|
3004
3096
|
const walkAssign = (n) => {
|
|
3005
|
-
var
|
|
3097
|
+
var _a2;
|
|
3006
3098
|
if (typeof n.id === "string") {
|
|
3007
3099
|
const newId = genId3();
|
|
3008
3100
|
oldToNew.set(n.id, newId);
|
|
3009
3101
|
n.id = newId;
|
|
3010
3102
|
}
|
|
3011
|
-
(
|
|
3103
|
+
(_a2 = n.children) == null ? void 0 : _a2.forEach(walkAssign);
|
|
3012
3104
|
};
|
|
3013
3105
|
walkAssign(root);
|
|
3014
3106
|
const rewriteUrl = (s) => s.replace(/url\(#([^)]+)\)/g, (m, oldId) => {
|
|
@@ -3016,7 +3108,7 @@ function regenerateIdsAndRewriteRefs(root, genId3) {
|
|
|
3016
3108
|
return newId ? "url(#" + newId + ")" : m;
|
|
3017
3109
|
});
|
|
3018
3110
|
const walkRewrite = (n) => {
|
|
3019
|
-
var
|
|
3111
|
+
var _a2;
|
|
3020
3112
|
if (typeof n.href === "string" && n.href.startsWith("#")) {
|
|
3021
3113
|
const newId = oldToNew.get(n.href.slice(1));
|
|
3022
3114
|
if (newId) n.href = "#" + newId;
|
|
@@ -3028,7 +3120,7 @@ function regenerateIdsAndRewriteRefs(root, genId3) {
|
|
|
3028
3120
|
n[k] = rewriteUrl(v);
|
|
3029
3121
|
}
|
|
3030
3122
|
}
|
|
3031
|
-
(
|
|
3123
|
+
(_a2 = n.children) == null ? void 0 : _a2.forEach(walkRewrite);
|
|
3032
3124
|
};
|
|
3033
3125
|
walkRewrite(root);
|
|
3034
3126
|
return oldToNew;
|
|
@@ -3038,7 +3130,7 @@ function toFiniteNum(v) {
|
|
|
3038
3130
|
return Number.isFinite(n) ? n : 0;
|
|
3039
3131
|
}
|
|
3040
3132
|
function applyUseOffsetToG(gNode) {
|
|
3041
|
-
var
|
|
3133
|
+
var _a2;
|
|
3042
3134
|
const x = toFiniteNum(gNode.x);
|
|
3043
3135
|
const y = toFiniteNum(gNode.y);
|
|
3044
3136
|
delete gNode.x;
|
|
@@ -3047,7 +3139,7 @@ function applyUseOffsetToG(gNode) {
|
|
|
3047
3139
|
const offset = "translate(" + x + "," + y + ")";
|
|
3048
3140
|
const carriesTransform = gNode.transform !== void 0 || gNode.animate !== void 0;
|
|
3049
3141
|
if (carriesTransform) {
|
|
3050
|
-
const inner = { type: "g", transform: offset, children: (
|
|
3142
|
+
const inner = { type: "g", transform: offset, children: (_a2 = gNode.children) != null ? _a2 : [] };
|
|
3051
3143
|
gNode.children = [inner];
|
|
3052
3144
|
} else {
|
|
3053
3145
|
gNode.transform = offset;
|
|
@@ -3055,7 +3147,7 @@ function applyUseOffsetToG(gNode) {
|
|
|
3055
3147
|
return gNode;
|
|
3056
3148
|
}
|
|
3057
3149
|
function materialiseAnimatedUseInstances(root) {
|
|
3058
|
-
var
|
|
3150
|
+
var _a2;
|
|
3059
3151
|
const idMap = buildIdMap(root);
|
|
3060
3152
|
const animatedIds = computeAnimatedSubtreeIds(root, idMap);
|
|
3061
3153
|
if (animatedIds.size === 0) return root;
|
|
@@ -3066,7 +3158,7 @@ function materialiseAnimatedUseInstances(root) {
|
|
|
3066
3158
|
const walked = walkAndMaterialise2(root, idMap, animatedIds, genId3, defsCollector, rootViewport);
|
|
3067
3159
|
if (defsCollector.length === 0) return walked;
|
|
3068
3160
|
const defsNode = { type: "defs", children: defsCollector };
|
|
3069
|
-
const newChildren = [...(
|
|
3161
|
+
const newChildren = [...(_a2 = walked.children) != null ? _a2 : [], defsNode];
|
|
3070
3162
|
return __spreadProps2(__spreadValues2({}, walked), { children: newChildren });
|
|
3071
3163
|
}
|
|
3072
3164
|
function readRootViewport(root) {
|
|
@@ -3088,9 +3180,9 @@ function numericAttr(v) {
|
|
|
3088
3180
|
function buildIdMap(root) {
|
|
3089
3181
|
const map = /* @__PURE__ */ new Map();
|
|
3090
3182
|
const visit = (n) => {
|
|
3091
|
-
var
|
|
3183
|
+
var _a2;
|
|
3092
3184
|
if (typeof n.id === "string") map.set(n.id, n);
|
|
3093
|
-
(
|
|
3185
|
+
(_a2 = n.children) == null ? void 0 : _a2.forEach(visit);
|
|
3094
3186
|
};
|
|
3095
3187
|
visit(root);
|
|
3096
3188
|
return map;
|
|
@@ -3137,11 +3229,11 @@ function stripHash(href) {
|
|
|
3137
3229
|
return href.startsWith("#") ? href.slice(1) : href;
|
|
3138
3230
|
}
|
|
3139
3231
|
function materialiseOneUse(useNode, target, idMap, animatedIds, genId3, defsCollector, rootViewport) {
|
|
3140
|
-
var
|
|
3232
|
+
var _a2, _b, _c, _d;
|
|
3141
3233
|
const clone2 = deepClonePxNode(target);
|
|
3142
3234
|
regenerateIdsAndRewriteRefs(clone2, genId3);
|
|
3143
3235
|
const symbolViewBox = clone2.type === "symbol" ? parseViewBox(clone2.viewBox) : void 0;
|
|
3144
|
-
const useW = (_b = (
|
|
3236
|
+
const useW = (_b = (_a2 = numericAttr(useNode.width)) != null ? _a2 : symbolViewBox == null ? void 0 : symbolViewBox[2]) != null ? _b : rootViewport[0];
|
|
3145
3237
|
const useH = (_d = (_c = numericAttr(useNode.height)) != null ? _c : symbolViewBox == null ? void 0 : symbolViewBox[3]) != null ? _d : rootViewport[1];
|
|
3146
3238
|
const rewrittenClone = clone2.type === "symbol" ? rewriteSymbolRootToGroup(clone2, genId3, defsCollector, useW, useH) : clone2;
|
|
3147
3239
|
const materialisedClone = walkAndMaterialise2(rewrittenClone, idMap, animatedIds, genId3, defsCollector, rootViewport);
|
|
@@ -3210,7 +3302,7 @@ function partsRecord(part, value, origin) {
|
|
|
3210
3302
|
return rec;
|
|
3211
3303
|
}
|
|
3212
3304
|
function readAnimatable(raw) {
|
|
3213
|
-
var
|
|
3305
|
+
var _a2, _b;
|
|
3214
3306
|
if (raw === void 0) return {
|
|
3215
3307
|
kind: "absent"
|
|
3216
3308
|
/* Absent */
|
|
@@ -3218,20 +3310,20 @@ function readAnimatable(raw) {
|
|
|
3218
3310
|
if (Array.isArray(raw)) return { kind: "static", value: raw };
|
|
3219
3311
|
if (typeof raw === "object") {
|
|
3220
3312
|
const obj = raw;
|
|
3221
|
-
const kfs =
|
|
3313
|
+
const kfs = obj.keyframes;
|
|
3222
3314
|
if (kfs) {
|
|
3223
3315
|
const out = { kind: "animated", keyframes: kfs.map(normaliseKeyframe), autoOrient: obj.autoOrient, loop: obj.loop };
|
|
3224
|
-
const base = (
|
|
3316
|
+
const base = (_a2 = obj.value) != null ? _a2 : obj.v;
|
|
3225
3317
|
if (base !== void 0 && out.kind === "animated") out.base = base;
|
|
3226
3318
|
return out;
|
|
3227
3319
|
}
|
|
3228
|
-
const staticValue = (
|
|
3320
|
+
const staticValue = (_b = obj.value) != null ? _b : obj.v;
|
|
3229
3321
|
if (staticValue !== void 0) return { kind: "static", value: staticValue };
|
|
3230
3322
|
}
|
|
3231
3323
|
return { kind: "static", value: raw };
|
|
3232
3324
|
}
|
|
3233
3325
|
function writeAnimatableChannel(node, attrName, read, opts) {
|
|
3234
|
-
var
|
|
3326
|
+
var _a2, _b, _c, _d;
|
|
3235
3327
|
const toOut = (v) => (opts == null ? void 0 : opts.asString) && v !== void 0 && v !== null ? String(v) : v;
|
|
3236
3328
|
if (read.kind === "absent") return;
|
|
3237
3329
|
if (read.kind === "static") {
|
|
@@ -3245,7 +3337,7 @@ function writeAnimatableChannel(node, attrName, read, opts) {
|
|
|
3245
3337
|
if (read.autoOrient !== void 0) block.autoOrient = read.autoOrient;
|
|
3246
3338
|
animate[attrName] = block;
|
|
3247
3339
|
node.animate = animate;
|
|
3248
|
-
const baseline = (_d = (_b = read.base) != null ? _b : (
|
|
3340
|
+
const baseline = (_d = (_b = read.base) != null ? _b : (_a2 = read.keyframes[0]) == null ? void 0 : _a2.value) != null ? _d : (_c = read.keyframes[0]) == null ? void 0 : _c.v;
|
|
3249
3341
|
if (baseline !== void 0) node[attrName] = toOut(baseline);
|
|
3250
3342
|
}
|
|
3251
3343
|
function normaliseKeyframe(kf) {
|
|
@@ -3263,12 +3355,12 @@ function normaliseKeyframe(kf) {
|
|
|
3263
3355
|
return out;
|
|
3264
3356
|
}
|
|
3265
3357
|
function readStaticOrigin(raw, ctx) {
|
|
3266
|
-
var
|
|
3358
|
+
var _a2;
|
|
3267
3359
|
const o = readAnimatable(raw);
|
|
3268
3360
|
if (o.kind === "absent") return void 0;
|
|
3269
3361
|
if (o.kind === "static") return o.value;
|
|
3270
3362
|
ctx.warnings.push("transformBy.origin: animated origin approximated by its first keyframe");
|
|
3271
|
-
return (
|
|
3363
|
+
return (_a2 = o.keyframes[0]) == null ? void 0 : _a2.value;
|
|
3272
3364
|
}
|
|
3273
3365
|
function keyframeWith(kf, value) {
|
|
3274
3366
|
const out = { value };
|
|
@@ -3374,9 +3466,9 @@ function stripHash2(href) {
|
|
|
3374
3466
|
return typeof href === "string" ? href.replace(/^#/, "") : void 0;
|
|
3375
3467
|
}
|
|
3376
3468
|
function indexById(node, map) {
|
|
3377
|
-
var
|
|
3469
|
+
var _a2;
|
|
3378
3470
|
if (typeof node.id === "string") map.set(node.id, node);
|
|
3379
|
-
(
|
|
3471
|
+
(_a2 = node.children) == null ? void 0 : _a2.forEach((child) => indexById(child, map));
|
|
3380
3472
|
}
|
|
3381
3473
|
function spliceDefs(root, defs) {
|
|
3382
3474
|
if (!defs.length) return;
|
|
@@ -3388,9 +3480,9 @@ function regenerateIdsInClone(root, ctx) {
|
|
|
3388
3480
|
return regenerateIdsAndRewriteRefs(root, () => genId(ctx, "retimed"));
|
|
3389
3481
|
}
|
|
3390
3482
|
function identifyContentRefTargets(node, ctx, allocator) {
|
|
3391
|
-
var
|
|
3392
|
-
if (node.type === "use" && ((_b = (
|
|
3393
|
-
const sourceId = stripHash2(node.effects.clone.
|
|
3483
|
+
var _a2, _b, _c;
|
|
3484
|
+
if (node.type === "use" && ((_b = (_a2 = node.effects) == null ? void 0 : _a2.clone) == null ? void 0 : _b.without) === "translate") {
|
|
3485
|
+
const sourceId = stripHash2(node.effects.clone.source);
|
|
3394
3486
|
if (typeof sourceId === "string" && sourceId && !ctx.contentRefInnerIds.has(sourceId)) {
|
|
3395
3487
|
ctx.contentRefInnerIds.set(sourceId, allocator(sourceId));
|
|
3396
3488
|
}
|
|
@@ -3415,10 +3507,10 @@ function splitForContentRef(node, transformBy, originalId, innerId, ctx) {
|
|
|
3415
3507
|
return outerWrapper;
|
|
3416
3508
|
}
|
|
3417
3509
|
function liftBodyTranslate(node, transformBy) {
|
|
3418
|
-
var
|
|
3510
|
+
var _a2, _b, _c;
|
|
3419
3511
|
const out = {};
|
|
3420
3512
|
let didLiftAnimate = false;
|
|
3421
|
-
const animTr = (
|
|
3513
|
+
const animTr = (_a2 = node.animate) == null ? void 0 : _a2.transform;
|
|
3422
3514
|
if (animTr && typeof animTr === "object" && Array.isArray(animTr.keyframes)) {
|
|
3423
3515
|
const kfs = animTr.keyframes;
|
|
3424
3516
|
const hasTranslate = kfs.some((kf) => kf.value && kf.value.translate);
|
|
@@ -3634,7 +3726,7 @@ function synthesiseGradientDef(fx, id, ctx) {
|
|
|
3634
3726
|
return out;
|
|
3635
3727
|
}
|
|
3636
3728
|
function applyGeomVec(out, xAttr, yAttr, raw) {
|
|
3637
|
-
var
|
|
3729
|
+
var _a2, _b, _c;
|
|
3638
3730
|
const read = readAnimatable(raw);
|
|
3639
3731
|
if (read.kind === "absent") return;
|
|
3640
3732
|
if (read.kind === "static") {
|
|
@@ -3653,7 +3745,7 @@ function applyGeomVec(out, xAttr, yAttr, raw) {
|
|
|
3653
3745
|
if (read.loop !== void 0) block.loop = read.loop;
|
|
3654
3746
|
return block;
|
|
3655
3747
|
};
|
|
3656
|
-
const animate = (
|
|
3748
|
+
const animate = (_a2 = out.animate) != null ? _a2 : {};
|
|
3657
3749
|
animate[xAttr] = axisChannel(0);
|
|
3658
3750
|
animate[yAttr] = axisChannel(1);
|
|
3659
3751
|
out.animate = animate;
|
|
@@ -3669,7 +3761,7 @@ function applyGeomNumber(out, attrName, raw) {
|
|
|
3669
3761
|
writeAnimatableChannel(out, attrName, read, { asString: true });
|
|
3670
3762
|
}
|
|
3671
3763
|
function buildStopChildren(stops, ctx) {
|
|
3672
|
-
var
|
|
3764
|
+
var _a2, _b;
|
|
3673
3765
|
if (!stops) return [];
|
|
3674
3766
|
const read = readAnimatable(stops);
|
|
3675
3767
|
if (read.kind === "absent") return [];
|
|
@@ -3679,14 +3771,14 @@ function buildStopChildren(stops, ctx) {
|
|
|
3679
3771
|
const loopFromSource = read.loop;
|
|
3680
3772
|
let stopCount = 0;
|
|
3681
3773
|
for (const kf of kfs) {
|
|
3682
|
-
const v = (
|
|
3774
|
+
const v = kfValue(kf);
|
|
3683
3775
|
if (Array.isArray(v) && v.length > stopCount) stopCount = v.length;
|
|
3684
3776
|
}
|
|
3685
3777
|
if (!stopCount) return [];
|
|
3686
|
-
const firstKfValue = (
|
|
3778
|
+
const firstKfValue = kfValue(kfs[0]);
|
|
3687
3779
|
const baselineStops = [];
|
|
3688
3780
|
for (let i = 0; i < stopCount; i++) {
|
|
3689
|
-
const s = (
|
|
3781
|
+
const s = (_b = (_a2 = firstKfValue == null ? void 0 : firstKfValue[i]) != null ? _a2 : prevDefinedStop(kfs, 0, i)) != null ? _b : { offset: i / Math.max(1, stopCount - 1), color: "#000000" };
|
|
3690
3782
|
baselineStops.push({ offset: s.offset, color: s.color });
|
|
3691
3783
|
}
|
|
3692
3784
|
return baselineStops.map((bs, i) => animatedStopNode(bs, kfs, i, ctx, loopFromSource));
|
|
@@ -3699,16 +3791,16 @@ function staticStopNode(s) {
|
|
|
3699
3791
|
};
|
|
3700
3792
|
}
|
|
3701
3793
|
function animatedStopNode(baseline, kfs, stopIdx, _ctx, loop) {
|
|
3702
|
-
var
|
|
3794
|
+
var _a2;
|
|
3703
3795
|
const colorKfs = [];
|
|
3704
3796
|
const offsetKfs = [];
|
|
3705
3797
|
let offsetVaries = false;
|
|
3706
3798
|
for (const kf of kfs) {
|
|
3707
|
-
const t = (
|
|
3708
|
-
const arr = (
|
|
3709
|
-
const sliced = (
|
|
3799
|
+
const t = kfTime(kf);
|
|
3800
|
+
const arr = kfValue(kf);
|
|
3801
|
+
const sliced = (_a2 = arr == null ? void 0 : arr[stopIdx]) != null ? _a2 : prevDefinedStop(kfs, kfs.indexOf(kf), stopIdx);
|
|
3710
3802
|
if (!sliced) continue;
|
|
3711
|
-
const easing = (
|
|
3803
|
+
const easing = kfEasing(kf);
|
|
3712
3804
|
const colorOut = { time: t, value: sliced.color };
|
|
3713
3805
|
if (easing !== void 0) colorOut.easing = easing;
|
|
3714
3806
|
colorKfs.push(colorOut);
|
|
@@ -3735,13 +3827,12 @@ function animatedStopNode(baseline, kfs, stopIdx, _ctx, loop) {
|
|
|
3735
3827
|
return stop;
|
|
3736
3828
|
}
|
|
3737
3829
|
function prevDefinedStop(kfs, fromIdx, stopIdx) {
|
|
3738
|
-
var _a, _b;
|
|
3739
3830
|
for (let i = fromIdx; i >= 0; i--) {
|
|
3740
|
-
const arr = (
|
|
3831
|
+
const arr = kfValue(kfs[i]);
|
|
3741
3832
|
if (arr == null ? void 0 : arr[stopIdx]) return arr[stopIdx];
|
|
3742
3833
|
}
|
|
3743
3834
|
for (let i = fromIdx + 1; i < kfs.length; i++) {
|
|
3744
|
-
const arr = (
|
|
3835
|
+
const arr = kfValue(kfs[i]);
|
|
3745
3836
|
if (arr == null ? void 0 : arr[stopIdx]) return arr[stopIdx];
|
|
3746
3837
|
}
|
|
3747
3838
|
return void 0;
|
|
@@ -3774,9 +3865,9 @@ function pathString(v) {
|
|
|
3774
3865
|
}
|
|
3775
3866
|
function applyMaskedByEffect(node, fx, transformBy, ctx) {
|
|
3776
3867
|
if (!fx) return node;
|
|
3777
|
-
const sourceId = stripHash2(fx.
|
|
3868
|
+
const sourceId = stripHash2(fx.source);
|
|
3778
3869
|
if (!sourceId) {
|
|
3779
|
-
ctx.errors.push("maskedBy.
|
|
3870
|
+
ctx.errors.push("maskedBy.source missing \u2014 cannot build mask");
|
|
3780
3871
|
return node;
|
|
3781
3872
|
}
|
|
3782
3873
|
const maskId = genId(ctx, "mask");
|
|
@@ -3839,16 +3930,16 @@ function invertPartValue(part, value) {
|
|
|
3839
3930
|
return [1 / value[0], 1 / value[1]];
|
|
3840
3931
|
}
|
|
3841
3932
|
function negatedSpatialTangents(kf) {
|
|
3842
|
-
var
|
|
3933
|
+
var _a2, _b;
|
|
3843
3934
|
const out = {};
|
|
3844
|
-
const to = (
|
|
3935
|
+
const to = (_a2 = kf.tangentOut) != null ? _a2 : kf.to;
|
|
3845
3936
|
const ti = (_b = kf.tangentIn) != null ? _b : kf.ti;
|
|
3846
3937
|
if (Array.isArray(to)) out.tangentOut = [-to[0], -to[1]];
|
|
3847
3938
|
if (Array.isArray(ti)) out.tangentIn = [-ti[0], -ti[1]];
|
|
3848
3939
|
return out;
|
|
3849
3940
|
}
|
|
3850
3941
|
function wrapInverseAnimatedBodyTransform(inner, node, _ctx) {
|
|
3851
|
-
var
|
|
3942
|
+
var _a2;
|
|
3852
3943
|
const animate = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate : void 0;
|
|
3853
3944
|
const animTr = animate == null ? void 0 : animate.transform;
|
|
3854
3945
|
const kfs = animTr && typeof animTr === "object" && Array.isArray(animTr.keyframes) ? animTr.keyframes : void 0;
|
|
@@ -3857,7 +3948,7 @@ function wrapInverseAnimatedBodyTransform(inner, node, _ctx) {
|
|
|
3857
3948
|
const rotateKfs = [];
|
|
3858
3949
|
const scaleKfs = [];
|
|
3859
3950
|
for (const kf of kfs) {
|
|
3860
|
-
const v = ((
|
|
3951
|
+
const v = ((_a2 = kf.value) != null ? _a2 : kf.v) || {};
|
|
3861
3952
|
const baseKf = keyframeWith(kf, void 0);
|
|
3862
3953
|
if (Array.isArray(v.translate)) {
|
|
3863
3954
|
translateKfs.push(__spreadProps2(__spreadValues2(__spreadValues2({}, baseKf), negatedSpatialTangents(kf)), { value: { translate: [-v.translate[0], -v.translate[1]] } }));
|
|
@@ -3921,7 +4012,7 @@ function readTransformationFromBody(node) {
|
|
|
3921
4012
|
return void 0;
|
|
3922
4013
|
}
|
|
3923
4014
|
function parseTransformStringToParts(s) {
|
|
3924
|
-
var
|
|
4015
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
3925
4016
|
const re = /([a-zA-Z]+)\s*\(([^)]*)\)/g;
|
|
3926
4017
|
let m;
|
|
3927
4018
|
const ops = [];
|
|
@@ -3935,7 +4026,7 @@ function parseTransformStringToParts(s) {
|
|
|
3935
4026
|
for (let j = ops.length - 2; j >= 0; j--) {
|
|
3936
4027
|
const cand = ops[j];
|
|
3937
4028
|
if (cand.name !== "translate") continue;
|
|
3938
|
-
const ox = (
|
|
4029
|
+
const ox = (_a2 = cand.args[0]) != null ? _a2 : 0;
|
|
3939
4030
|
const oy = (_b = cand.args[1]) != null ? _b : 0;
|
|
3940
4031
|
const lx = (_c = last.args[0]) != null ? _c : 0;
|
|
3941
4032
|
const ly = (_d = last.args[1]) != null ? _d : 0;
|
|
@@ -4050,8 +4141,8 @@ function interpKfs(kfs, t) {
|
|
|
4050
4141
|
function collectMaskAncestorChains(root, ctx) {
|
|
4051
4142
|
const interestingNodes = /* @__PURE__ */ new Set();
|
|
4052
4143
|
const collectInterestingNodes = (n) => {
|
|
4053
|
-
var
|
|
4054
|
-
const maskSourceId = stripHash2((_b = (
|
|
4144
|
+
var _a2, _b;
|
|
4145
|
+
const maskSourceId = stripHash2((_b = (_a2 = n.effects) == null ? void 0 : _a2.maskedBy) == null ? void 0 : _b.source);
|
|
4055
4146
|
if (typeof maskSourceId === "string") {
|
|
4056
4147
|
interestingNodes.add(n);
|
|
4057
4148
|
const sourceNode = ctx.idMap.get(maskSourceId);
|
|
@@ -4072,7 +4163,7 @@ function collectMaskAncestorChains(root, ctx) {
|
|
|
4072
4163
|
walk(root, []);
|
|
4073
4164
|
}
|
|
4074
4165
|
function extractTranslateOnly(node, ctx) {
|
|
4075
|
-
var
|
|
4166
|
+
var _a2, _b, _c;
|
|
4076
4167
|
const tr = node.transform;
|
|
4077
4168
|
const animateBlock = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate.transform : void 0;
|
|
4078
4169
|
if (tr === void 0 && !animateBlock) return void 0;
|
|
@@ -4080,7 +4171,7 @@ function extractTranslateOnly(node, ctx) {
|
|
|
4080
4171
|
if (typeof tr === "string") {
|
|
4081
4172
|
const parts = parseTranslateOnlyFromString(tr, ctx);
|
|
4082
4173
|
if (parts) out.translate = parts;
|
|
4083
|
-
} else if (tr && typeof tr === "object" && !tr.keyframes
|
|
4174
|
+
} else if (tr && typeof tr === "object" && !tr.keyframes) {
|
|
4084
4175
|
const wrapped = tr.value;
|
|
4085
4176
|
const value = wrapped && typeof wrapped === "object" ? wrapped : tr;
|
|
4086
4177
|
if (value && typeof value === "object" && Array.isArray(value.translate)) {
|
|
@@ -4094,7 +4185,7 @@ function extractTranslateOnly(node, ctx) {
|
|
|
4094
4185
|
const kfs = animateBlock.keyframes;
|
|
4095
4186
|
const translateKfs = [];
|
|
4096
4187
|
for (const kf of kfs) {
|
|
4097
|
-
const v = (
|
|
4188
|
+
const v = (_a2 = kf.value) != null ? _a2 : kf.v;
|
|
4098
4189
|
const t = (_c = (_b = kf.time) != null ? _b : kf.t) != null ? _c : 0;
|
|
4099
4190
|
if (v && typeof v === "object" && Array.isArray(v.translate)) {
|
|
4100
4191
|
translateKfs.push({ time: t, value: [v.translate[0] || 0, v.translate[1] || 0] });
|
|
@@ -4127,15 +4218,14 @@ function parseTranslateOnlyFromString(s, ctx) {
|
|
|
4127
4218
|
if (droppedNonTranslate) ctx.warnings.push("maskedBy ancestor: non-translate transform in string ignored: " + s);
|
|
4128
4219
|
return seen ? [x, y] : void 0;
|
|
4129
4220
|
}
|
|
4130
|
-
var CONTENT_SUBREF = "content";
|
|
4131
4221
|
function applyRefHref(node, clone2, ctx) {
|
|
4132
4222
|
if (!clone2) return;
|
|
4133
|
-
const sourceId = stripHash2(clone2.
|
|
4223
|
+
const sourceId = stripHash2(clone2.source);
|
|
4134
4224
|
if (!sourceId) {
|
|
4135
|
-
if (clone2.
|
|
4225
|
+
if (clone2.without === PxCloneWithout.translate) ctx.errors.push("clone: content ref missing `source`");
|
|
4136
4226
|
return;
|
|
4137
4227
|
}
|
|
4138
|
-
const targetId = clone2.
|
|
4228
|
+
const targetId = clone2.without === PxCloneWithout.translate ? ctx.contentRefInnerIds.get(sourceId) || sourceId : sourceId;
|
|
4139
4229
|
node.href = "#" + targetId;
|
|
4140
4230
|
}
|
|
4141
4231
|
function applyRefAndTransformationEffect(node, clone2, transformBy, ctx) {
|
|
@@ -4143,9 +4233,9 @@ function applyRefAndTransformationEffect(node, clone2, transformBy, ctx) {
|
|
|
4143
4233
|
return applyTransformByEffect(node, transformBy, ctx);
|
|
4144
4234
|
}
|
|
4145
4235
|
function applyRepeaterEffect(node, fx, ctx) {
|
|
4146
|
-
var
|
|
4236
|
+
var _a2, _b;
|
|
4147
4237
|
if (!fx) return node;
|
|
4148
|
-
const copies = (
|
|
4238
|
+
const copies = (_a2 = fx.copies) != null ? _a2 : 1;
|
|
4149
4239
|
if (copies < 1) {
|
|
4150
4240
|
ctx.errors.push("repeater.copies invalid: " + fx.copies);
|
|
4151
4241
|
return node;
|
|
@@ -4213,8 +4303,8 @@ function synthesiseScale(raw, i) {
|
|
|
4213
4303
|
}
|
|
4214
4304
|
var RETIME_MATERIALISATION_MODE_INLINE_G = false;
|
|
4215
4305
|
function asRetime(r) {
|
|
4216
|
-
var
|
|
4217
|
-
return { start: (
|
|
4306
|
+
var _a2, _b;
|
|
4307
|
+
return { start: (_a2 = r.start) != null ? _a2 : 0, stretch: (_b = r.stretch) != null ? _b : 1 };
|
|
4218
4308
|
}
|
|
4219
4309
|
var CROP_EDGE_MS = 1;
|
|
4220
4310
|
function applyTimeCrop(useNode, crop, ctx) {
|
|
@@ -4242,12 +4332,12 @@ function concatRetime(child, parent) {
|
|
|
4242
4332
|
};
|
|
4243
4333
|
}
|
|
4244
4334
|
function readCloneRetime(n) {
|
|
4245
|
-
var
|
|
4246
|
-
return (_b = (
|
|
4335
|
+
var _a2, _b;
|
|
4336
|
+
return (_b = (_a2 = n.effects) == null ? void 0 : _a2.clone) == null ? void 0 : _b.retime;
|
|
4247
4337
|
}
|
|
4248
4338
|
function clearCloneRetime(n) {
|
|
4249
|
-
var
|
|
4250
|
-
const clone2 = (
|
|
4339
|
+
var _a2;
|
|
4340
|
+
const clone2 = (_a2 = n.effects) == null ? void 0 : _a2.clone;
|
|
4251
4341
|
if (!clone2) return;
|
|
4252
4342
|
delete clone2.retime;
|
|
4253
4343
|
if (Object.keys(clone2).length === 0) delete n.effects.clone;
|
|
@@ -4258,9 +4348,9 @@ function applyAllRetimeEffects(root, ctx) {
|
|
|
4258
4348
|
indexById(root, ctx.idMap);
|
|
4259
4349
|
const sites = [];
|
|
4260
4350
|
const collect = (n) => {
|
|
4261
|
-
var
|
|
4351
|
+
var _a2;
|
|
4262
4352
|
if (readCloneRetime(n)) sites.push(n);
|
|
4263
|
-
(
|
|
4353
|
+
(_a2 = n.children) == null ? void 0 : _a2.forEach(collect);
|
|
4264
4354
|
};
|
|
4265
4355
|
collect(root);
|
|
4266
4356
|
const reachCount = /* @__PURE__ */ new Map();
|
|
@@ -4268,7 +4358,7 @@ function applyAllRetimeEffects(root, ctx) {
|
|
|
4268
4358
|
let count = 0;
|
|
4269
4359
|
const visited = /* @__PURE__ */ new Set();
|
|
4270
4360
|
const walk = (n) => {
|
|
4271
|
-
var
|
|
4361
|
+
var _a2;
|
|
4272
4362
|
if (!n) return;
|
|
4273
4363
|
if (n !== site && readCloneRetime(n)) count++;
|
|
4274
4364
|
if (n.type === "use" && n.href) {
|
|
@@ -4278,7 +4368,7 @@ function applyAllRetimeEffects(root, ctx) {
|
|
|
4278
4368
|
walk(ctx.idMap.get(id));
|
|
4279
4369
|
}
|
|
4280
4370
|
}
|
|
4281
|
-
(
|
|
4371
|
+
(_a2 = n.children) == null ? void 0 : _a2.forEach(walk);
|
|
4282
4372
|
};
|
|
4283
4373
|
const rootId = stripHash2(site.href);
|
|
4284
4374
|
if (rootId) {
|
|
@@ -4288,8 +4378,8 @@ function applyAllRetimeEffects(root, ctx) {
|
|
|
4288
4378
|
reachCount.set(site, count);
|
|
4289
4379
|
}
|
|
4290
4380
|
sites.sort((a, b) => {
|
|
4291
|
-
var
|
|
4292
|
-
return ((
|
|
4381
|
+
var _a2, _b;
|
|
4382
|
+
return ((_a2 = reachCount.get(b)) != null ? _a2 : 0) - ((_b = reachCount.get(a)) != null ? _b : 0);
|
|
4293
4383
|
});
|
|
4294
4384
|
for (const useNode of sites) {
|
|
4295
4385
|
const retime = readCloneRetime(useNode);
|
|
@@ -4356,7 +4446,7 @@ function buildChainClone(targetId, accum, ctx, chain) {
|
|
|
4356
4446
|
}
|
|
4357
4447
|
function materialiseNestedRetimeUses(node, accum, ctx, chain, parentTargetId) {
|
|
4358
4448
|
const visit = (n) => {
|
|
4359
|
-
var
|
|
4449
|
+
var _a2;
|
|
4360
4450
|
const retime = readCloneRetime(n);
|
|
4361
4451
|
if (n.type === "use" && retime && n.href) {
|
|
4362
4452
|
const subId = stripHash2(n.href);
|
|
@@ -4369,14 +4459,14 @@ function materialiseNestedRetimeUses(node, accum, ctx, chain, parentTargetId) {
|
|
|
4369
4459
|
}
|
|
4370
4460
|
clearCloneRetime(n);
|
|
4371
4461
|
}
|
|
4372
|
-
(
|
|
4462
|
+
(_a2 = n.children) == null ? void 0 : _a2.forEach(visit);
|
|
4373
4463
|
};
|
|
4374
4464
|
visit(node);
|
|
4375
4465
|
}
|
|
4376
4466
|
function remapKeyframeTimes(node, start, stretch) {
|
|
4377
|
-
var
|
|
4467
|
+
var _a2;
|
|
4378
4468
|
remapKeyframeTimesOnly(node, start, stretch);
|
|
4379
|
-
(
|
|
4469
|
+
(_a2 = node.children) == null ? void 0 : _a2.forEach((c) => remapKeyframeTimes(c, start, stretch));
|
|
4380
4470
|
}
|
|
4381
4471
|
function remapKeyframeTimesOnly(node, start, stretch) {
|
|
4382
4472
|
const remap2 = (kfs) => {
|
|
@@ -4551,8 +4641,8 @@ function numRange(v) {
|
|
|
4551
4641
|
function estimateTextAdvance(node) {
|
|
4552
4642
|
let chars = 0, maxFont = 16;
|
|
4553
4643
|
const walk = (el) => {
|
|
4554
|
-
var
|
|
4555
|
-
const fs = parseFloat(String((
|
|
4644
|
+
var _a2, _b;
|
|
4645
|
+
const fs = parseFloat(String((_a2 = el.fontSize) != null ? _a2 : "")) || 0;
|
|
4556
4646
|
if (fs) maxFont = Math.max(maxFont, fs);
|
|
4557
4647
|
const t = (_b = el.text) != null ? _b : el.textContent;
|
|
4558
4648
|
if (typeof t === "string") chars += t.length;
|
|
@@ -4576,14 +4666,14 @@ function shiftAnimatable(v, by) {
|
|
|
4576
4666
|
return out;
|
|
4577
4667
|
}
|
|
4578
4668
|
function extendedPathForBrowser(pathD, opts) {
|
|
4579
|
-
var
|
|
4669
|
+
var _a2;
|
|
4580
4670
|
if (opts.pathOverflow === "clip") return { d: pathD, startShift: 0 };
|
|
4581
4671
|
const sampler = createPathSampler(pathD);
|
|
4582
4672
|
if (!sampler || sampler.closed || sampler.totalLength <= 0) return { d: pathD, startShift: 0 };
|
|
4583
4673
|
const L = sampler.totalLength;
|
|
4584
4674
|
const margin = EXTEND_MARGIN_FRAC * L;
|
|
4585
4675
|
const so = numRange(opts.startOffset);
|
|
4586
|
-
const runWidth = numRange(opts.textLength).max || ((
|
|
4676
|
+
const runWidth = numRange(opts.textLength).max || ((_a2 = opts.advance) != null ? _a2 : 0);
|
|
4587
4677
|
const startOverflow = Math.max(0, -so.min);
|
|
4588
4678
|
const endOverflow = Math.max(0, so.max + runWidth - L);
|
|
4589
4679
|
const startExt = startOverflow > 0 ? startOverflow + margin : 0;
|
|
@@ -4604,10 +4694,10 @@ function extendedPathForBrowser(pathD, opts) {
|
|
|
4604
4694
|
return { d, startShift: startExt };
|
|
4605
4695
|
}
|
|
4606
4696
|
function applyTextPathEffect(node, fx, ctx) {
|
|
4607
|
-
var
|
|
4608
|
-
if (!fx || typeof fx.
|
|
4697
|
+
var _a2;
|
|
4698
|
+
if (!fx || typeof fx.pathData !== "string" || !fx.pathData) return node;
|
|
4609
4699
|
const pathId = genId(ctx, "tpath");
|
|
4610
|
-
const { d, startShift } = extendedPathForBrowser(fx.
|
|
4700
|
+
const { d, startShift } = extendedPathForBrowser(fx.pathData, {
|
|
4611
4701
|
pathOverflow: fx.pathOverflow,
|
|
4612
4702
|
startOffset: fx.startOffset,
|
|
4613
4703
|
textLength: fx.textLength,
|
|
@@ -4617,7 +4707,7 @@ function applyTextPathEffect(node, fx, ctx) {
|
|
|
4617
4707
|
const textPath = {
|
|
4618
4708
|
type: "textPath",
|
|
4619
4709
|
href: "#" + pathId,
|
|
4620
|
-
children: (
|
|
4710
|
+
children: (_a2 = node.children) != null ? _a2 : []
|
|
4621
4711
|
};
|
|
4622
4712
|
if (fx.lengthAdjust !== void 0) textPath.lengthAdjust = fx.lengthAdjust;
|
|
4623
4713
|
if (fx.method !== void 0) textPath.method = fx.method;
|
|
@@ -4741,15 +4831,15 @@ function paintAnimateOf(node) {
|
|
|
4741
4831
|
return out;
|
|
4742
4832
|
}
|
|
4743
4833
|
function resolveStyle2(node, parent) {
|
|
4744
|
-
var
|
|
4834
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4745
4835
|
const isTextRoot = node.type === "text";
|
|
4746
4836
|
const nodeStyle = node.style;
|
|
4747
4837
|
const own = (key) => {
|
|
4748
|
-
var
|
|
4749
|
-
return isTextRoot ? void 0 : (
|
|
4838
|
+
var _a3;
|
|
4839
|
+
return isTextRoot ? void 0 : (_a3 = node[key]) != null ? _a3 : nodeStyle == null ? void 0 : nodeStyle[key];
|
|
4750
4840
|
};
|
|
4751
4841
|
const res = {
|
|
4752
|
-
fontFamily: (
|
|
4842
|
+
fontFamily: (_a2 = str(node.fontFamily)) != null ? _a2 : parent.fontFamily,
|
|
4753
4843
|
fontSize: (_b = parseLen(node.fontSize)) != null ? _b : parent.fontSize,
|
|
4754
4844
|
fill: (_c = node.fill) != null ? _c : parent.fill,
|
|
4755
4845
|
stroke: (_d = node.stroke) != null ? _d : parent.stroke,
|
|
@@ -4766,10 +4856,10 @@ function resolveStyle2(node, parent) {
|
|
|
4766
4856
|
return res;
|
|
4767
4857
|
}
|
|
4768
4858
|
function rootStyleOf(node) {
|
|
4769
|
-
var
|
|
4859
|
+
var _a2, _b, _c;
|
|
4770
4860
|
return {
|
|
4771
4861
|
fontFamily: str(node.fontFamily),
|
|
4772
|
-
fontSize: (
|
|
4862
|
+
fontSize: (_a2 = parseLen(node.fontSize)) != null ? _a2 : DEFAULT_FONT_SIZE,
|
|
4773
4863
|
fill: node.fill,
|
|
4774
4864
|
stroke: node.stroke,
|
|
4775
4865
|
strokeWidth: node.strokeWidth,
|
|
@@ -4790,9 +4880,9 @@ function paintOf(s) {
|
|
|
4790
4880
|
return p;
|
|
4791
4881
|
}
|
|
4792
4882
|
function glyphFontFor(s, glyphs, soleFont, warnings) {
|
|
4793
|
-
var
|
|
4883
|
+
var _a2;
|
|
4794
4884
|
const gf = s.fontFamily ? glyphs[s.fontFamily] : soleFont;
|
|
4795
|
-
if (!gf) warnings == null ? void 0 : warnings.push('textGlyphs: no glyphs for font "' + ((
|
|
4885
|
+
if (!gf) warnings == null ? void 0 : warnings.push('textGlyphs: no glyphs for font "' + ((_a2 = s.fontFamily) != null ? _a2 : "") + '"');
|
|
4796
4886
|
return gf;
|
|
4797
4887
|
}
|
|
4798
4888
|
function soleFontOf(glyphs) {
|
|
@@ -4814,19 +4904,19 @@ function missingGlyphBoxEm(advanceEm, ascentEm) {
|
|
|
4814
4904
|
return outer + "M" + ix0 + " " + iyb + "L" + ix0 + " " + iyt + "L" + ix1 + " " + iyt + "L" + ix1 + " " + iyb + "Z";
|
|
4815
4905
|
}
|
|
4816
4906
|
function materialiseGlyphTextHorizontal(node, opts) {
|
|
4817
|
-
var
|
|
4907
|
+
var _a2, _b, _c, _d;
|
|
4818
4908
|
const { glyphs, create = jsonElementFactory, warnings } = opts;
|
|
4819
4909
|
const soleFont = soleFontOf(glyphs);
|
|
4820
|
-
const pen = { x: (
|
|
4910
|
+
const pen = { x: (_a2 = parseLen(node.x)) != null ? _a2 : 0, y: (_b = parseLen(node.y)) != null ? _b : 0 };
|
|
4821
4911
|
const placements = [];
|
|
4822
4912
|
const lines = [{ start: pen.x, end: pen.x }];
|
|
4823
4913
|
let line = 0;
|
|
4824
4914
|
const renderChars = (content, s) => {
|
|
4825
|
-
var
|
|
4915
|
+
var _a3;
|
|
4826
4916
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
4827
4917
|
const upm = (gf == null ? void 0 : gf.unitsPerEm) || 1e3;
|
|
4828
4918
|
const scale = s.fontSize / upm;
|
|
4829
|
-
const ascentEm = (
|
|
4919
|
+
const ascentEm = (_a3 = gf == null ? void 0 : gf.ascent) != null ? _a3 : 0.9 * upm;
|
|
4830
4920
|
const paint = paintOf(s);
|
|
4831
4921
|
for (let i = 0; i < content.length; i++) {
|
|
4832
4922
|
const ch = content.charAt(i);
|
|
@@ -4846,7 +4936,7 @@ function materialiseGlyphTextHorizontal(node, opts) {
|
|
|
4846
4936
|
}
|
|
4847
4937
|
};
|
|
4848
4938
|
const walk = (el, parentStyle) => {
|
|
4849
|
-
var
|
|
4939
|
+
var _a3, _b2, _c2, _d2;
|
|
4850
4940
|
const s = resolveStyle2(el, parentStyle);
|
|
4851
4941
|
const x = parseLen(el.x);
|
|
4852
4942
|
const y = parseLen(el.y);
|
|
@@ -4856,7 +4946,7 @@ function materialiseGlyphTextHorizontal(node, opts) {
|
|
|
4856
4946
|
lines.push({ start: pen.x, end: pen.x });
|
|
4857
4947
|
}
|
|
4858
4948
|
if (y !== void 0) pen.y = y;
|
|
4859
|
-
pen.x += (
|
|
4949
|
+
pen.x += (_a3 = parseLen(el.dx)) != null ? _a3 : 0;
|
|
4860
4950
|
pen.y += (_b2 = parseLen(el.dy)) != null ? _b2 : 0;
|
|
4861
4951
|
const content = (_c2 = str(el[TEXT_CONTENT_ATTR])) != null ? _c2 : str(el[TEXT_ATTR]);
|
|
4862
4952
|
if (content && !((_d2 = el.children) == null ? void 0 : _d2.length)) renderChars(content, s);
|
|
@@ -4877,8 +4967,8 @@ function materialiseGlyphTextHorizontal(node, opts) {
|
|
|
4877
4967
|
return toGroup(node, buildPaths(placements, create, warnings), create);
|
|
4878
4968
|
}
|
|
4879
4969
|
function layoutGlyphTextChars(node, opts) {
|
|
4880
|
-
var
|
|
4881
|
-
if ((
|
|
4970
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
4971
|
+
if ((_a2 = opts.alongPath) == null ? void 0 : _a2.pathD) return layoutGlyphTextCharsAlongPath(node, opts.alongPath.pathD, opts);
|
|
4882
4972
|
const { glyphs, warnings } = opts;
|
|
4883
4973
|
const soleFont = soleFontOf(glyphs);
|
|
4884
4974
|
const pen = { x: (_b = parseLen(node.x)) != null ? _b : 0, y: (_c = parseLen(node.y)) != null ? _c : 0 };
|
|
@@ -4886,11 +4976,11 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
4886
4976
|
const lines = [{ start: pen.x, end: pen.x }];
|
|
4887
4977
|
let line = 0;
|
|
4888
4978
|
const renderChars = (content, s) => {
|
|
4889
|
-
var
|
|
4979
|
+
var _a3;
|
|
4890
4980
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
4891
4981
|
const upm = (gf == null ? void 0 : gf.unitsPerEm) || 1e3;
|
|
4892
4982
|
const scale = s.fontSize / upm;
|
|
4893
|
-
const ascent = ((
|
|
4983
|
+
const ascent = ((_a3 = gf == null ? void 0 : gf.ascent) != null ? _a3 : 0.9 * upm) * scale;
|
|
4894
4984
|
for (let i = 0; i < content.length; i++) {
|
|
4895
4985
|
const ch = content.charAt(i);
|
|
4896
4986
|
const g = gf == null ? void 0 : gf.glyphs[ch];
|
|
@@ -4901,7 +4991,7 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
4901
4991
|
}
|
|
4902
4992
|
};
|
|
4903
4993
|
const walk = (el, parentStyle) => {
|
|
4904
|
-
var
|
|
4994
|
+
var _a3, _b2, _c2, _d2;
|
|
4905
4995
|
const s = resolveStyle2(el, parentStyle);
|
|
4906
4996
|
const x = parseLen(el.x);
|
|
4907
4997
|
const y = parseLen(el.y);
|
|
@@ -4911,7 +5001,7 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
4911
5001
|
lines.push({ start: pen.x, end: pen.x });
|
|
4912
5002
|
}
|
|
4913
5003
|
if (y !== void 0) pen.y = y;
|
|
4914
|
-
pen.x += (
|
|
5004
|
+
pen.x += (_a3 = parseLen(el.dx)) != null ? _a3 : 0;
|
|
4915
5005
|
pen.y += (_b2 = parseLen(el.dy)) != null ? _b2 : 0;
|
|
4916
5006
|
const content = (_c2 = str(el[TEXT_CONTENT_ATTR])) != null ? _c2 : str(el[TEXT_ATTR]);
|
|
4917
5007
|
if (content && !((_d2 = el.children) == null ? void 0 : _d2.length)) renderChars(content, s);
|
|
@@ -4943,7 +5033,7 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
4943
5033
|
});
|
|
4944
5034
|
}
|
|
4945
5035
|
function layoutGlyphTextCharsAlongPath(node, pathD, opts) {
|
|
4946
|
-
var
|
|
5036
|
+
var _a2, _b;
|
|
4947
5037
|
const { glyphs, warnings, alongPath } = opts;
|
|
4948
5038
|
const sampler = createPathSampler(pathD);
|
|
4949
5039
|
if (!sampler) {
|
|
@@ -4954,9 +5044,9 @@ function layoutGlyphTextCharsAlongPath(node, pathD, opts) {
|
|
|
4954
5044
|
const chars = [];
|
|
4955
5045
|
let adv = 0;
|
|
4956
5046
|
const walk = (el, parentStyle) => {
|
|
4957
|
-
var
|
|
5047
|
+
var _a3, _b2, _c;
|
|
4958
5048
|
const s = resolveStyle2(el, parentStyle);
|
|
4959
|
-
const content = (
|
|
5049
|
+
const content = (_a3 = str(el[TEXT_CONTENT_ATTR])) != null ? _a3 : str(el[TEXT_ATTR]);
|
|
4960
5050
|
if (content && !((_b2 = el.children) == null ? void 0 : _b2.length)) {
|
|
4961
5051
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
4962
5052
|
const upm = (gf == null ? void 0 : gf.unitsPerEm) || 1e3;
|
|
@@ -4976,7 +5066,7 @@ function layoutGlyphTextCharsAlongPath(node, pathD, opts) {
|
|
|
4976
5066
|
walk(node, rootStyleOf(node));
|
|
4977
5067
|
const width = adv;
|
|
4978
5068
|
const tlr = readAnimatable(alongPath == null ? void 0 : alongPath.textLength);
|
|
4979
|
-
const tlv = tlr.kind === "animated" ? Number((
|
|
5069
|
+
const tlv = tlr.kind === "animated" ? Number((_a2 = tlr.keyframes[0]) == null ? void 0 : _a2.value) || 0 : tlr.kind === "static" ? Number(tlr.value) || 0 : 0;
|
|
4980
5070
|
const k = tlv > 0 && width > 0 ? tlv / width : 1;
|
|
4981
5071
|
const so = readAnimatable(alongPath == null ? void 0 : alongPath.startOffset);
|
|
4982
5072
|
const { along: alongOffset, perp } = alongPathNodeOffsets(node);
|
|
@@ -5008,9 +5098,9 @@ function collectAlongPathCells(node, glyphs, soleFont, warnings) {
|
|
|
5008
5098
|
const cells = [];
|
|
5009
5099
|
let adv = 0;
|
|
5010
5100
|
const walk = (el, parentStyle) => {
|
|
5011
|
-
var
|
|
5101
|
+
var _a2, _b, _c;
|
|
5012
5102
|
const s = resolveStyle2(el, parentStyle);
|
|
5013
|
-
const content = (
|
|
5103
|
+
const content = (_a2 = str(el[TEXT_CONTENT_ATTR])) != null ? _a2 : str(el[TEXT_ATTR]);
|
|
5014
5104
|
if (content && !((_b = el.children) == null ? void 0 : _b.length)) {
|
|
5015
5105
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
5016
5106
|
if (gf) {
|
|
@@ -5047,9 +5137,9 @@ function alongAffine(sampler, dist, scale, widthEm, perp = 0) {
|
|
|
5047
5137
|
return [scale * cos, scale * sin, -scale * sin, scale * cos, x - scale * cos * hw - perp * sin, y - scale * sin * hw + perp * cos];
|
|
5048
5138
|
}
|
|
5049
5139
|
function alongPathNodeOffsets(node) {
|
|
5050
|
-
var
|
|
5140
|
+
var _a2, _b, _c;
|
|
5051
5141
|
return {
|
|
5052
|
-
along: ((
|
|
5142
|
+
along: ((_a2 = parseLen(node.x)) != null ? _a2 : 0) + ((_b = parseLen(node.dx)) != null ? _b : 0),
|
|
5053
5143
|
perp: (_c = parseLen(node.dy)) != null ? _c : 0
|
|
5054
5144
|
};
|
|
5055
5145
|
}
|
|
@@ -5089,7 +5179,7 @@ function materialiseGlyphTextAlongPath(node, pathD, startOffset, opts, textLengt
|
|
|
5089
5179
|
return toGroup(node, buildPaths(placements, create, warnings), create);
|
|
5090
5180
|
}
|
|
5091
5181
|
function numTrackOf(raw) {
|
|
5092
|
-
var
|
|
5182
|
+
var _a2;
|
|
5093
5183
|
const r = readAnimatable(raw);
|
|
5094
5184
|
if (r.kind === "animated" && r.keyframes.length >= 2) {
|
|
5095
5185
|
const kfs = [...r.keyframes].sort((k1, k2) => (Number(k1.time) || 0) - (Number(k2.time) || 0));
|
|
@@ -5112,7 +5202,7 @@ function numTrackOf(raw) {
|
|
|
5112
5202
|
}
|
|
5113
5203
|
};
|
|
5114
5204
|
}
|
|
5115
|
-
const v = r.kind === "animated" ? Number((
|
|
5205
|
+
const v = r.kind === "animated" ? Number((_a2 = r.keyframes[0]) == null ? void 0 : _a2.value) || 0 : r.kind === "static" ? Number(r.value) || 0 : 0;
|
|
5116
5206
|
return { animated: false, times: [], at: () => v };
|
|
5117
5207
|
}
|
|
5118
5208
|
function mergeTrackTimes(a, b) {
|
|
@@ -5194,7 +5284,7 @@ function paintProps(paint) {
|
|
|
5194
5284
|
return p;
|
|
5195
5285
|
}
|
|
5196
5286
|
function missingGlyphProps(isMissing) {
|
|
5197
|
-
return isMissing ? {
|
|
5287
|
+
return isMissing ? { [CLASS_ATTR]: MISSING_GLYPH_CLASS_NAME } : {};
|
|
5198
5288
|
}
|
|
5199
5289
|
function buildPaths(placements, create, warnings) {
|
|
5200
5290
|
if (!placements.length) {
|
|
@@ -5238,14 +5328,14 @@ function materialiseGlyphText(node, opts) {
|
|
|
5238
5328
|
function applyTextGlyphsEffect(node, fx, ctx) {
|
|
5239
5329
|
if (!(fx == null ? void 0 : fx.useGlyphs)) return node;
|
|
5240
5330
|
if (!ctx.glyphs) {
|
|
5241
|
-
ctx.warnings.push("textGlyphs: no definitions.
|
|
5331
|
+
ctx.warnings.push("textGlyphs: no definitions.fonts \u2014 left as native <text>");
|
|
5242
5332
|
return node;
|
|
5243
5333
|
}
|
|
5244
5334
|
return materialiseGlyphTextHorizontal(node, { glyphs: ctx.glyphs, warnings: ctx.warnings });
|
|
5245
5335
|
}
|
|
5246
5336
|
function applyTextGlyphsAlongPath(node, ctx, pathD, startOffset, textLength, pathOverflow) {
|
|
5247
5337
|
if (!ctx.glyphs) {
|
|
5248
|
-
ctx.warnings.push("textGlyphs: no definitions.
|
|
5338
|
+
ctx.warnings.push("textGlyphs: no definitions.fonts");
|
|
5249
5339
|
return null;
|
|
5250
5340
|
}
|
|
5251
5341
|
return materialiseGlyphTextAlongPath(node, pathD, startOffset, { glyphs: ctx.glyphs, warnings: ctx.warnings }, textLength, pathOverflow);
|
|
@@ -5385,12 +5475,11 @@ function getOffsetIndexRange(minMaxOffset) {
|
|
|
5385
5475
|
];
|
|
5386
5476
|
}
|
|
5387
5477
|
function readScalarValues(r) {
|
|
5388
|
-
var _a;
|
|
5389
5478
|
if (r.kind === "absent") return [];
|
|
5390
5479
|
if (r.kind === "static") return [r.value];
|
|
5391
5480
|
const out = [];
|
|
5392
5481
|
for (const kf of r.keyframes) {
|
|
5393
|
-
const v = (
|
|
5482
|
+
const v = kfValue(kf);
|
|
5394
5483
|
if (typeof v === "number") out.push(v);
|
|
5395
5484
|
}
|
|
5396
5485
|
return out;
|
|
@@ -5400,14 +5489,11 @@ function computeAnimAttr(read, map) {
|
|
|
5400
5489
|
if (read.kind === "static") return { kind: "static", value: map(read.value) };
|
|
5401
5490
|
return {
|
|
5402
5491
|
kind: "animated",
|
|
5403
|
-
keyframes: read.keyframes.map((kf) => {
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
easing: (_d = kf.easing) != null ? _d : kf.e
|
|
5409
|
-
};
|
|
5410
|
-
}),
|
|
5492
|
+
keyframes: read.keyframes.map((kf) => ({
|
|
5493
|
+
time: kfTime(kf),
|
|
5494
|
+
value: map(kfValue(kf)),
|
|
5495
|
+
easing: kfEasing(kf)
|
|
5496
|
+
})),
|
|
5411
5497
|
loop: read.loop
|
|
5412
5498
|
};
|
|
5413
5499
|
}
|
|
@@ -5417,7 +5503,6 @@ function applyAttr(node, attrName, attr) {
|
|
|
5417
5503
|
}
|
|
5418
5504
|
var OPACITY_STEP_MS = 10;
|
|
5419
5505
|
function computeOpacityFromRange(rangeRead) {
|
|
5420
|
-
var _a, _b, _c, _d, _e, _f;
|
|
5421
5506
|
const hide = (v) => v[0] === v[1];
|
|
5422
5507
|
if (rangeRead.kind === "absent") return void 0;
|
|
5423
5508
|
if (rangeRead.kind === "static") return hide(rangeRead.value) ? { kind: "static", value: 0 } : void 0;
|
|
@@ -5425,7 +5510,7 @@ function computeOpacityFromRange(rangeRead) {
|
|
|
5425
5510
|
let anyHide = false;
|
|
5426
5511
|
let allHide = true;
|
|
5427
5512
|
for (const kf of kfs) {
|
|
5428
|
-
if (hide((
|
|
5513
|
+
if (hide(kfValue(kf))) anyHide = true;
|
|
5429
5514
|
else allHide = false;
|
|
5430
5515
|
}
|
|
5431
5516
|
if (!anyHide) return void 0;
|
|
@@ -5435,10 +5520,10 @@ function computeOpacityFromRange(rangeRead) {
|
|
|
5435
5520
|
const kf = kfs[i];
|
|
5436
5521
|
const prevKf = i > 0 ? kfs[i - 1] : void 0;
|
|
5437
5522
|
const nextKf = i < kfs.length - 1 ? kfs[i + 1] : void 0;
|
|
5438
|
-
const t = (
|
|
5439
|
-
const thisHide = hide((
|
|
5440
|
-
const prevHide = prevKf ? thisHide && hide((
|
|
5441
|
-
const nextHide = nextKf ? thisHide && hide((
|
|
5523
|
+
const t = kfTime(kf);
|
|
5524
|
+
const thisHide = hide(kfValue(kf));
|
|
5525
|
+
const prevHide = prevKf ? thisHide && hide(kfValue(prevKf)) : thisHide;
|
|
5526
|
+
const nextHide = nextKf ? thisHide && hide(kfValue(nextKf)) : thisHide;
|
|
5442
5527
|
if (prevHide && !nextHide) {
|
|
5443
5528
|
out.push({ time: t, value: 0 });
|
|
5444
5529
|
out.push({ time: t + OPACITY_STEP_MS, value: 1 });
|
|
@@ -5453,14 +5538,11 @@ function computeOpacityFromRange(rangeRead) {
|
|
|
5453
5538
|
function readRangeWithCrossings(raw) {
|
|
5454
5539
|
const r = readAnimatable(raw);
|
|
5455
5540
|
if (r.kind !== "animated") return r;
|
|
5456
|
-
const kfs = r.keyframes.map((kf) => {
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
easing: (_d = kf.easing) != null ? _d : kf.e
|
|
5462
|
-
};
|
|
5463
|
-
});
|
|
5541
|
+
const kfs = r.keyframes.map((kf) => ({
|
|
5542
|
+
time: kfTime(kf),
|
|
5543
|
+
value: kfValue(kf),
|
|
5544
|
+
easing: kfEasing(kf)
|
|
5545
|
+
}));
|
|
5464
5546
|
const hasReverse = kfs.some((kf) => kf.value[0] > kf.value[1]);
|
|
5465
5547
|
if (!hasReverse) {
|
|
5466
5548
|
return {
|
|
@@ -5557,20 +5639,20 @@ function pxBezierPathLength(path) {
|
|
|
5557
5639
|
return total;
|
|
5558
5640
|
}
|
|
5559
5641
|
function segmentLength(path, from, to) {
|
|
5560
|
-
var
|
|
5642
|
+
var _a2, _b, _c, _d;
|
|
5561
5643
|
const v = path.v;
|
|
5562
5644
|
const p0 = v[from];
|
|
5563
5645
|
const p3 = v[to];
|
|
5564
|
-
const p1 = (_b = (
|
|
5646
|
+
const p1 = (_b = (_a2 = path.o) == null ? void 0 : _a2[from]) != null ? _b : p0;
|
|
5565
5647
|
const p2 = (_d = (_c = path.i) == null ? void 0 : _c[to]) != null ? _d : p3;
|
|
5566
5648
|
const lut = bezier2D_arcLengthLUT(p0, p1, p2, p3);
|
|
5567
5649
|
return lut.ds[lut.ds.length - 1];
|
|
5568
5650
|
}
|
|
5569
5651
|
var ARC_KAPPA = 0.5522847498307936;
|
|
5570
5652
|
function shapeToPathD(node) {
|
|
5571
|
-
var
|
|
5653
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
5572
5654
|
if (node.type === "rect") {
|
|
5573
|
-
const x = Number((
|
|
5655
|
+
const x = Number((_a2 = node.x) != null ? _a2 : 0), y = Number((_b = node.y) != null ? _b : 0);
|
|
5574
5656
|
const w = Number((_c = node.width) != null ? _c : 0), h = Number((_d = node.height) != null ? _d : 0);
|
|
5575
5657
|
return "M" + (x + w) + "," + y + "L" + (x + w) + "," + (y + h) + "L" + x + "," + (y + h) + "L" + x + "," + y + "L" + (x + w) + "," + y + "z";
|
|
5576
5658
|
}
|
|
@@ -5586,7 +5668,7 @@ function shapeToPathD(node) {
|
|
|
5586
5668
|
return void 0;
|
|
5587
5669
|
}
|
|
5588
5670
|
function applyPlayerEffects(root) {
|
|
5589
|
-
var
|
|
5671
|
+
var _a2, _b;
|
|
5590
5672
|
const ctx = {
|
|
5591
5673
|
defs: [],
|
|
5592
5674
|
warnings: [],
|
|
@@ -5597,8 +5679,8 @@ function applyPlayerEffects(root) {
|
|
|
5597
5679
|
maskAncestorChains: /* @__PURE__ */ new Map(),
|
|
5598
5680
|
// Resolved engine: `frames` ONLY when explicitly set; auto/waapi/unset →
|
|
5599
5681
|
// waapi (we're not 100% sure it's frames, and CSS/WAAPI need the inline form).
|
|
5600
|
-
engine: ((
|
|
5601
|
-
glyphs: (_b = getDefs(root)) == null ? void 0 : _b.
|
|
5682
|
+
engine: resolveTimelineEngine((_a2 = getAnimatorConfig(root)) == null ? void 0 : _a2.engine),
|
|
5683
|
+
glyphs: (_b = getDefs(root)) == null ? void 0 : _b.fonts
|
|
5602
5684
|
};
|
|
5603
5685
|
const working = clone(root);
|
|
5604
5686
|
indexById(working, ctx.idMap);
|
|
@@ -5621,7 +5703,7 @@ function applyPlayerEffects_exceptRetime(node, ctx) {
|
|
|
5621
5703
|
let consumedByGlyphs = false;
|
|
5622
5704
|
if (text == null ? void 0 : text.useGlyphs) {
|
|
5623
5705
|
if (textPath) {
|
|
5624
|
-
const pathD = typeof textPath.
|
|
5706
|
+
const pathD = typeof textPath.pathData === "string" ? textPath.pathData : void 0;
|
|
5625
5707
|
const glyphed = applyTextGlyphsAlongPath(n, ctx, pathD, textPath.startOffset, textPath.textLength, textPath.pathOverflow);
|
|
5626
5708
|
if (glyphed) {
|
|
5627
5709
|
n = glyphed;
|
|
@@ -5653,26 +5735,6 @@ function applyPlayerEffects_retime(node, ctx) {
|
|
|
5653
5735
|
applyAllRetimeEffects(node, ctx);
|
|
5654
5736
|
return node;
|
|
5655
5737
|
}
|
|
5656
|
-
var kfTime = (kf) => {
|
|
5657
|
-
var _a, _b;
|
|
5658
|
-
return (_b = (_a = kf.t) != null ? _a : kf.time) != null ? _b : 0;
|
|
5659
|
-
};
|
|
5660
|
-
var kfValue = (kf) => {
|
|
5661
|
-
var _a;
|
|
5662
|
-
return (_a = kf.v) != null ? _a : kf.value;
|
|
5663
|
-
};
|
|
5664
|
-
var kfEasing = (kf) => {
|
|
5665
|
-
var _a;
|
|
5666
|
-
return (_a = kf.e) != null ? _a : kf.easing;
|
|
5667
|
-
};
|
|
5668
|
-
var kfTangentIn = (kf) => {
|
|
5669
|
-
var _a;
|
|
5670
|
-
return (_a = kf.tangentIn) != null ? _a : kf.ti;
|
|
5671
|
-
};
|
|
5672
|
-
var kfTangentOut = (kf) => {
|
|
5673
|
-
var _a;
|
|
5674
|
-
return (_a = kf.tangentOut) != null ? _a : kf.to;
|
|
5675
|
-
};
|
|
5676
5738
|
function cubicAt(p0, c1, c2, p1, t) {
|
|
5677
5739
|
const u = 1 - t;
|
|
5678
5740
|
const a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;
|
|
@@ -5696,7 +5758,7 @@ var fmt2 = (n) => {
|
|
|
5696
5758
|
return Object.is(r, -0) ? "0" : String(r);
|
|
5697
5759
|
};
|
|
5698
5760
|
function buildOffsetPath(propAnim) {
|
|
5699
|
-
var
|
|
5761
|
+
var _a2, _b, _c;
|
|
5700
5762
|
if (propAnim.alongPathMode !== "offsetPath") return void 0;
|
|
5701
5763
|
const kfs = propAnim.keyframes;
|
|
5702
5764
|
if (!kfs || kfs.length < 2) return void 0;
|
|
@@ -5709,7 +5771,7 @@ function buildOffsetPath(propAnim) {
|
|
|
5709
5771
|
if (!tr || tr.length < 2) return void 0;
|
|
5710
5772
|
const parts = Object.keys(v);
|
|
5711
5773
|
if (parts.some((p) => p !== "translate" && p !== "origin")) return void 0;
|
|
5712
|
-
const o = (
|
|
5774
|
+
const o = (_a2 = v == null ? void 0 : v.origin) != null ? _a2 : [0, 0];
|
|
5713
5775
|
if (o[0] !== anchor[0] || o[1] !== anchor[1]) return void 0;
|
|
5714
5776
|
points.push([tr[0] + anchor[0], tr[1] + anchor[1]]);
|
|
5715
5777
|
}
|
|
@@ -5740,7 +5802,7 @@ function buildOffsetPath(propAnim) {
|
|
|
5740
5802
|
}
|
|
5741
5803
|
function materialiseOffsetPathsInTree(root) {
|
|
5742
5804
|
const walk = (node) => {
|
|
5743
|
-
var
|
|
5805
|
+
var _a2;
|
|
5744
5806
|
let out = node;
|
|
5745
5807
|
const anim = node.animate;
|
|
5746
5808
|
const transform = anim == null ? void 0 : anim["transform"];
|
|
@@ -5748,16 +5810,16 @@ function materialiseOffsetPathsInTree(root) {
|
|
|
5748
5810
|
const built = buildOffsetPath(transform);
|
|
5749
5811
|
if (built) {
|
|
5750
5812
|
const newAnimate = __spreadValues2({}, anim);
|
|
5751
|
-
delete newAnimate[
|
|
5813
|
+
delete newAnimate[TRANSFORM_ATTR];
|
|
5752
5814
|
const distance = { keyframes: built.distanceKfs };
|
|
5753
5815
|
if (transform.loop !== void 0) distance.loop = transform.loop;
|
|
5754
|
-
newAnimate[
|
|
5816
|
+
newAnimate[OFFSET_DISTANCE_ATTR] = distance;
|
|
5755
5817
|
const staticTr = node.transform;
|
|
5756
5818
|
let newTransform = staticTr;
|
|
5757
5819
|
if (staticTr && typeof staticTr === "object") {
|
|
5758
5820
|
const t = __spreadValues2({}, staticTr);
|
|
5759
|
-
delete t[
|
|
5760
|
-
delete t[
|
|
5821
|
+
delete t[TRANSFORM_PART.translate];
|
|
5822
|
+
delete t[TRANSFORM_PART.origin];
|
|
5761
5823
|
newTransform = Object.keys(t).length ? t : void 0;
|
|
5762
5824
|
}
|
|
5763
5825
|
out = __spreadProps2(__spreadValues2({}, node), {
|
|
@@ -5773,7 +5835,7 @@ function materialiseOffsetPathsInTree(root) {
|
|
|
5773
5835
|
else delete out.transform;
|
|
5774
5836
|
}
|
|
5775
5837
|
}
|
|
5776
|
-
if ((
|
|
5838
|
+
if ((_a2 = out.children) == null ? void 0 : _a2.length) {
|
|
5777
5839
|
const children = out.children.map(walk);
|
|
5778
5840
|
if (children.some((c, i) => c !== out.children[i])) out = __spreadProps2(__spreadValues2({}, out), { children });
|
|
5779
5841
|
}
|
|
@@ -5782,12 +5844,12 @@ function materialiseOffsetPathsInTree(root) {
|
|
|
5782
5844
|
return walk(root);
|
|
5783
5845
|
}
|
|
5784
5846
|
function materialiseAllInTree(doc, engine, opts) {
|
|
5785
|
-
var
|
|
5847
|
+
var _a2, _b;
|
|
5786
5848
|
let root = applyPlayerEffects(doc).root;
|
|
5787
5849
|
root = materialiseOffsetPathsInTree(root);
|
|
5788
|
-
const duration = (_b = (
|
|
5850
|
+
const duration = (_b = (_a2 = getAnimatorConfig(root)) == null ? void 0 : _a2.duration) != null ? _b : DEFAULT_DURATION_MS;
|
|
5789
5851
|
root = materialiseInternalLoopsInTree(root, duration);
|
|
5790
|
-
if (engine ===
|
|
5852
|
+
if (engine === PxTimelineEngine.native) {
|
|
5791
5853
|
root = materialiseMotionPathsInTree(root, opts == null ? void 0 : opts.motionPath);
|
|
5792
5854
|
root = materialiseAnimatedUseInstances(root);
|
|
5793
5855
|
root = pruneUnreferencedDefs(root);
|
|
@@ -5797,9 +5859,9 @@ function materialiseAllInTree(doc, engine, opts) {
|
|
|
5797
5859
|
function pruneUnreferencedDefs(root) {
|
|
5798
5860
|
const stripHash3 = (h) => h.startsWith("#") ? h.slice(1) : h;
|
|
5799
5861
|
const walk = (n, fn) => {
|
|
5800
|
-
var
|
|
5862
|
+
var _a2;
|
|
5801
5863
|
fn(n);
|
|
5802
|
-
(
|
|
5864
|
+
(_a2 = n.children) == null ? void 0 : _a2.forEach((c) => walk(c, fn));
|
|
5803
5865
|
};
|
|
5804
5866
|
let changed = true;
|
|
5805
5867
|
while (changed) {
|
|
@@ -5837,9 +5899,9 @@ function cancelFrame(handle) {
|
|
|
5837
5899
|
g.clearTimeout(handle);
|
|
5838
5900
|
}
|
|
5839
5901
|
function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
5840
|
-
var
|
|
5902
|
+
var _a2;
|
|
5841
5903
|
const config = getAnimatorConfig(doc) || {};
|
|
5842
|
-
const bindings = getNormalisedBindings(doc,
|
|
5904
|
+
const bindings = getNormalisedBindings(doc, PxTimelineEngine.js);
|
|
5843
5905
|
const _iterations = config.iterations;
|
|
5844
5906
|
let iterations = 1;
|
|
5845
5907
|
if (typeof _iterations === "number") iterations = _iterations || 1;
|
|
@@ -5848,7 +5910,7 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
5848
5910
|
const duration = +(config.duration || DEFAULT_DURATION_MS);
|
|
5849
5911
|
const totalDuration = duration && iterations ? duration * (iterations === Infinity ? Infinity : iterations) : duration ? (iterations != null ? iterations : 1) * duration : 0;
|
|
5850
5912
|
const direction = config.direction || "normal";
|
|
5851
|
-
const fill = (
|
|
5913
|
+
const fill = (_a2 = config.fill) != null ? _a2 : "forwards";
|
|
5852
5914
|
const fillsForwards = fill === "forwards" || fill === "both";
|
|
5853
5915
|
const fillsBackwards = fill === "backwards" || fill === "both";
|
|
5854
5916
|
let timerId = null;
|
|
@@ -5910,7 +5972,7 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
5910
5972
|
}
|
|
5911
5973
|
}
|
|
5912
5974
|
const tick = () => {
|
|
5913
|
-
var
|
|
5975
|
+
var _a3, _b;
|
|
5914
5976
|
if (!adapter.isConnected()) {
|
|
5915
5977
|
pauseAnim();
|
|
5916
5978
|
return;
|
|
@@ -5926,7 +5988,7 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
5926
5988
|
renderFrame(0);
|
|
5927
5989
|
if (!finishCalled) {
|
|
5928
5990
|
finishCalled = true;
|
|
5929
|
-
(
|
|
5991
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onFinish) == null ? void 0 : _a3.call(callbacks);
|
|
5930
5992
|
}
|
|
5931
5993
|
return;
|
|
5932
5994
|
}
|
|
@@ -6018,17 +6080,17 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
6018
6080
|
}
|
|
6019
6081
|
};
|
|
6020
6082
|
const cancelAnim = () => {
|
|
6021
|
-
var
|
|
6083
|
+
var _a3;
|
|
6022
6084
|
pauseAnim();
|
|
6023
6085
|
timeBeforeLastStartMs = 0;
|
|
6024
6086
|
lastStartedTs = 0;
|
|
6025
6087
|
playing = false;
|
|
6026
6088
|
finishCalled = false;
|
|
6027
6089
|
renderFrame(timeBeforeLastStartMs);
|
|
6028
|
-
(
|
|
6090
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onCancel) == null ? void 0 : _a3.call(callbacks);
|
|
6029
6091
|
};
|
|
6030
6092
|
const finishAnim = (callOnFinish = true) => {
|
|
6031
|
-
var
|
|
6093
|
+
var _a3;
|
|
6032
6094
|
if (Number.isFinite(totalDuration)) {
|
|
6033
6095
|
timeBeforeLastStartMs = totalDuration;
|
|
6034
6096
|
} else {
|
|
@@ -6043,7 +6105,7 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
6043
6105
|
renderFrame(fillsForwards ? timeBeforeLastStartMs : 0);
|
|
6044
6106
|
if (callOnFinish && !finishCalled) {
|
|
6045
6107
|
finishCalled = true;
|
|
6046
|
-
(
|
|
6108
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onFinish) == null ? void 0 : _a3.call(callbacks);
|
|
6047
6109
|
}
|
|
6048
6110
|
};
|
|
6049
6111
|
const api = {
|
|
@@ -6053,14 +6115,14 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
6053
6115
|
return _isPlaying();
|
|
6054
6116
|
},
|
|
6055
6117
|
"play": () => {
|
|
6056
|
-
var
|
|
6118
|
+
var _a3;
|
|
6057
6119
|
startAnim();
|
|
6058
|
-
(
|
|
6120
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onPlay) == null ? void 0 : _a3.call(callbacks);
|
|
6059
6121
|
},
|
|
6060
6122
|
"pause": () => {
|
|
6061
|
-
var
|
|
6123
|
+
var _a3;
|
|
6062
6124
|
pauseAnim();
|
|
6063
|
-
(
|
|
6125
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onPause) == null ? void 0 : _a3.call(callbacks);
|
|
6064
6126
|
},
|
|
6065
6127
|
"cancel": () => {
|
|
6066
6128
|
cancelAnim();
|
|
@@ -6092,9 +6154,9 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
6092
6154
|
renderFrame(getAnimCurrentTime());
|
|
6093
6155
|
},
|
|
6094
6156
|
"destroy": () => {
|
|
6095
|
-
var
|
|
6157
|
+
var _a3;
|
|
6096
6158
|
api.cancel();
|
|
6097
|
-
(
|
|
6159
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onRemove) == null ? void 0 : _a3.call(callbacks);
|
|
6098
6160
|
}
|
|
6099
6161
|
};
|
|
6100
6162
|
return api;
|
|
@@ -6148,9 +6210,9 @@ function lerp(a, b, f) {
|
|
|
6148
6210
|
return a + (b - a) * f;
|
|
6149
6211
|
}
|
|
6150
6212
|
function interpParts(kfs, t) {
|
|
6151
|
-
var
|
|
6213
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
6152
6214
|
if (!kfs.length) return {};
|
|
6153
|
-
if (t <= ((
|
|
6215
|
+
if (t <= ((_a2 = kfs[0].time) != null ? _a2 : 0)) return kfs[0].value || {};
|
|
6154
6216
|
if (t >= ((_b = kfs[kfs.length - 1].time) != null ? _b : 0)) return kfs[kfs.length - 1].value || {};
|
|
6155
6217
|
let i = 0;
|
|
6156
6218
|
while (i < kfs.length - 1 && ((_c = kfs[i + 1].time) != null ? _c : 0) < t) i++;
|
|
@@ -6181,10 +6243,10 @@ function nodeMatrix(node, t) {
|
|
|
6181
6243
|
return IDENTITY;
|
|
6182
6244
|
}
|
|
6183
6245
|
function evalScalar(animated, staticVal, fallback, t) {
|
|
6184
|
-
var
|
|
6246
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
6185
6247
|
if (animated && animated.keyframes && animated.keyframes.length) {
|
|
6186
6248
|
const kfs = animated.keyframes;
|
|
6187
|
-
if (t <= ((
|
|
6249
|
+
if (t <= ((_a2 = kfs[0].time) != null ? _a2 : 0)) return kfs[0].value;
|
|
6188
6250
|
if (t >= ((_b = kfs[kfs.length - 1].time) != null ? _b : 0)) return kfs[kfs.length - 1].value;
|
|
6189
6251
|
let i = 0;
|
|
6190
6252
|
while (i < kfs.length - 1 && ((_c = kfs[i + 1].time) != null ? _c : 0) < t) i++;
|
|
@@ -6197,9 +6259,9 @@ function evalScalar(animated, staticVal, fallback, t) {
|
|
|
6197
6259
|
var CONTAINER_TYPES = /* @__PURE__ */ new Set(["svg", "g", "symbol"]);
|
|
6198
6260
|
var SKIP_TYPES = /* @__PURE__ */ new Set(["defs", "mask", "clipPath", "title"]);
|
|
6199
6261
|
function buildIdMap2(node, map) {
|
|
6200
|
-
var
|
|
6262
|
+
var _a2;
|
|
6201
6263
|
if (typeof node.id === "string") map.set(node.id, node);
|
|
6202
|
-
(
|
|
6264
|
+
(_a2 = node.children) == null ? void 0 : _a2.forEach((c) => buildIdMap2(c, map));
|
|
6203
6265
|
}
|
|
6204
6266
|
function num(v) {
|
|
6205
6267
|
return v === void 0 || v === null ? 0 : Number(v);
|
|
@@ -6208,7 +6270,7 @@ function round(n) {
|
|
|
6208
6270
|
return Math.round(n * 100) / 100 + 0;
|
|
6209
6271
|
}
|
|
6210
6272
|
function geomKey(node) {
|
|
6211
|
-
var
|
|
6273
|
+
var _a2;
|
|
6212
6274
|
switch (node.type) {
|
|
6213
6275
|
case "rect":
|
|
6214
6276
|
return num(node.width) + "," + num(node.height) + "," + num(node.x) + "," + num(node.y);
|
|
@@ -6217,14 +6279,14 @@ function geomKey(node) {
|
|
|
6217
6279
|
case "circle":
|
|
6218
6280
|
return num(node.r) + "," + num(node.cx) + "," + num(node.cy);
|
|
6219
6281
|
case "path":
|
|
6220
|
-
return String((
|
|
6282
|
+
return String((_a2 = node.d) != null ? _a2 : "");
|
|
6221
6283
|
default:
|
|
6222
6284
|
return "";
|
|
6223
6285
|
}
|
|
6224
6286
|
}
|
|
6225
6287
|
function describePrimitive(node, m, t) {
|
|
6226
|
-
var
|
|
6227
|
-
const fill = (
|
|
6288
|
+
var _a2, _b, _c, _d, _e;
|
|
6289
|
+
const fill = (_a2 = node.fill) != null ? _a2 : "";
|
|
6228
6290
|
const stroke = (_b = node.stroke) != null ? _b : "";
|
|
6229
6291
|
const sw = (_d = (_c = node["stroke-width"]) != null ? _c : node.strokeWidth) != null ? _d : "";
|
|
6230
6292
|
const opacity = round(evalScalar((_e = node.animate) == null ? void 0 : _e.opacity, node.opacity, 1, t));
|
|
@@ -6233,7 +6295,7 @@ function describePrimitive(node, m, t) {
|
|
|
6233
6295
|
return node.type + "|" + geomKey(node) + "|[" + mat + "]|f:" + fill + "|s:" + stroke + "|sw:" + (num(sw) || "") + "|o:" + opacity + "|m:" + masked;
|
|
6234
6296
|
}
|
|
6235
6297
|
function flatten(node, parent, t, idMap, out) {
|
|
6236
|
-
var
|
|
6298
|
+
var _a2;
|
|
6237
6299
|
const type = node.type || "";
|
|
6238
6300
|
if (SKIP_TYPES.has(type)) return;
|
|
6239
6301
|
const m = mul(parent, nodeMatrix(node, t));
|
|
@@ -6246,33 +6308,33 @@ function flatten(node, parent, t, idMap, out) {
|
|
|
6246
6308
|
return;
|
|
6247
6309
|
}
|
|
6248
6310
|
if (CONTAINER_TYPES.has(type)) {
|
|
6249
|
-
(
|
|
6311
|
+
(_a2 = node.children) == null ? void 0 : _a2.forEach((c) => flatten(c, m, t, idMap, out));
|
|
6250
6312
|
return;
|
|
6251
6313
|
}
|
|
6252
6314
|
out.push(describePrimitive(node, m, t));
|
|
6253
6315
|
}
|
|
6254
6316
|
function collectSampleTimes(node, into) {
|
|
6255
|
-
var
|
|
6317
|
+
var _a2;
|
|
6256
6318
|
into.add(0);
|
|
6257
6319
|
const scanAnim = (anim) => {
|
|
6258
|
-
var
|
|
6320
|
+
var _a3;
|
|
6259
6321
|
if (!anim || typeof anim !== "object") return;
|
|
6260
6322
|
for (const key of Object.keys(anim)) {
|
|
6261
|
-
const kfs = (
|
|
6323
|
+
const kfs = (_a3 = anim[key]) == null ? void 0 : _a3.keyframes;
|
|
6262
6324
|
if (Array.isArray(kfs)) kfs.forEach((kf) => {
|
|
6263
|
-
var
|
|
6264
|
-
return into.add((
|
|
6325
|
+
var _a4;
|
|
6326
|
+
return into.add((_a4 = kf.time) != null ? _a4 : 0);
|
|
6265
6327
|
});
|
|
6266
6328
|
}
|
|
6267
6329
|
};
|
|
6268
6330
|
scanAnim(node.animate);
|
|
6269
6331
|
if (node.transform && typeof node.transform === "object" && node.transform.keyframes) {
|
|
6270
6332
|
node.transform.keyframes.forEach((kf) => {
|
|
6271
|
-
var
|
|
6272
|
-
return into.add((
|
|
6333
|
+
var _a3;
|
|
6334
|
+
return into.add((_a3 = kf.time) != null ? _a3 : 0);
|
|
6273
6335
|
});
|
|
6274
6336
|
}
|
|
6275
|
-
(
|
|
6337
|
+
(_a2 = node.children) == null ? void 0 : _a2.forEach((c) => collectSampleTimes(c, into));
|
|
6276
6338
|
}
|
|
6277
6339
|
function visualModelAt(root, t) {
|
|
6278
6340
|
const idMap = /* @__PURE__ */ new Map();
|
|
@@ -6306,8 +6368,191 @@ function subtractMultiset(a, b) {
|
|
|
6306
6368
|
}
|
|
6307
6369
|
return extra;
|
|
6308
6370
|
}
|
|
6371
|
+
var FLAT_ONLY_KEYS = [
|
|
6372
|
+
"timelineSource",
|
|
6373
|
+
"scroll",
|
|
6374
|
+
"trigger",
|
|
6375
|
+
"delay",
|
|
6376
|
+
"iterations",
|
|
6377
|
+
"direction",
|
|
6378
|
+
"fill",
|
|
6379
|
+
"resetOnFinish",
|
|
6380
|
+
"duration",
|
|
6381
|
+
"mode",
|
|
6382
|
+
"frameRate"
|
|
6383
|
+
];
|
|
6384
|
+
var CONTENT_KEYS = ["definitions", "animateById"];
|
|
6385
|
+
var isPlainObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
6386
|
+
var timelineTypeOf = (t) => isPlainObject(t) && typeof t.type === "string" ? t.type : "time";
|
|
6387
|
+
var isScrollish = (type) => type === "scroll" || type === "view";
|
|
6388
|
+
function mergePlain(base, patch) {
|
|
6389
|
+
const out = isPlainObject(base) ? __spreadValues2({}, base) : {};
|
|
6390
|
+
for (const key of Object.keys(patch)) {
|
|
6391
|
+
const value = patch[key];
|
|
6392
|
+
if (value === null) {
|
|
6393
|
+
delete out[key];
|
|
6394
|
+
continue;
|
|
6395
|
+
}
|
|
6396
|
+
if (isPlainObject(value)) {
|
|
6397
|
+
out[key] = mergePlain(out[key], value);
|
|
6398
|
+
continue;
|
|
6399
|
+
}
|
|
6400
|
+
out[key] = value;
|
|
6401
|
+
}
|
|
6402
|
+
return out;
|
|
6403
|
+
}
|
|
6404
|
+
function mergeTimeline(base, patch, warn) {
|
|
6405
|
+
const baseType = timelineTypeOf(base);
|
|
6406
|
+
const patchNamesType = isPlainObject(patch) && typeof patch.type === "string";
|
|
6407
|
+
const patchType = patchNamesType ? String(patch.type) : baseType;
|
|
6408
|
+
let merged;
|
|
6409
|
+
if (patchType !== baseType) {
|
|
6410
|
+
const carried = {};
|
|
6411
|
+
if (isPlainObject(base)) {
|
|
6412
|
+
for (const k of PX_TIMELINE_SHARED_KEYS) {
|
|
6413
|
+
if (base[k] !== void 0) carried[k] = base[k];
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6416
|
+
merged = mergePlain(carried, patch);
|
|
6417
|
+
} else {
|
|
6418
|
+
merged = mergePlain(base, patch);
|
|
6419
|
+
}
|
|
6420
|
+
if (isScrollish(patchType)) {
|
|
6421
|
+
for (const k of PX_TIME_ONLY_TIMELINE_KEYS) {
|
|
6422
|
+
if (merged[k] === void 0) continue;
|
|
6423
|
+
warn("animator.timeline." + k + ": no slot on a '" + patchType + "' timeline \u2014 dropped");
|
|
6424
|
+
delete merged[k];
|
|
6425
|
+
}
|
|
6426
|
+
if (merged.iterations === "infinite") {
|
|
6427
|
+
warn("animator.timeline.iterations: 'infinite' cannot map onto a scroll range \u2014 dropped");
|
|
6428
|
+
delete merged.iterations;
|
|
6429
|
+
}
|
|
6430
|
+
}
|
|
6431
|
+
return merged;
|
|
6432
|
+
}
|
|
6433
|
+
function foldAnimatorConfigShortcuts(config, shortcuts) {
|
|
6434
|
+
let base;
|
|
6435
|
+
if (typeof config === "string") {
|
|
6436
|
+
try {
|
|
6437
|
+
base = JSON.parse(config);
|
|
6438
|
+
} catch (e) {
|
|
6439
|
+
console.warn("animator config: not valid JSON \u2014 ignored", e);
|
|
6440
|
+
base = void 0;
|
|
6441
|
+
}
|
|
6442
|
+
} else {
|
|
6443
|
+
base = config != null ? config : void 0;
|
|
6444
|
+
}
|
|
6445
|
+
const { duration, delay, iterations, startOn } = shortcuts;
|
|
6446
|
+
if (duration === void 0 && delay === void 0 && iterations === void 0 && startOn === void 0) {
|
|
6447
|
+
return base;
|
|
6448
|
+
}
|
|
6449
|
+
const out = isPlainObject(base) ? __spreadValues2({}, base) : {};
|
|
6450
|
+
const timeline = __spreadValues2({}, out.timeline);
|
|
6451
|
+
if (duration !== void 0) timeline.duration = duration;
|
|
6452
|
+
if (delay !== void 0) timeline.delay = delay;
|
|
6453
|
+
if (iterations !== void 0) timeline.iterations = iterations;
|
|
6454
|
+
if (startOn !== void 0) {
|
|
6455
|
+
timeline.trigger = __spreadProps2(__spreadValues2({}, timeline.trigger), { startOn });
|
|
6456
|
+
}
|
|
6457
|
+
out.timeline = timeline;
|
|
6458
|
+
return out;
|
|
6459
|
+
}
|
|
6460
|
+
function mergeAnimatorConfig(base, patch) {
|
|
6461
|
+
const warnings = [];
|
|
6462
|
+
const warn = (m) => warnings.push(m);
|
|
6463
|
+
if (patch === null) return { config: void 0, warnings };
|
|
6464
|
+
if (!isPlainObject(patch) || Object.keys(patch).length === 0) {
|
|
6465
|
+
return { config: base, warnings };
|
|
6466
|
+
}
|
|
6467
|
+
const flatInBase = isPlainObject(base) ? FLAT_ONLY_KEYS.filter((k) => base[k] !== void 0) : [];
|
|
6468
|
+
if (flatInBase.length) {
|
|
6469
|
+
warn("animator: the base carries the flat runtime spelling (" + flatInBase.join(", ") + "); the patch merges the wire spelling only");
|
|
6470
|
+
}
|
|
6471
|
+
const out = isPlainObject(base) ? __spreadValues2({}, base) : {};
|
|
6472
|
+
for (const key of Object.keys(patch)) {
|
|
6473
|
+
const value = patch[key];
|
|
6474
|
+
if (value === null) {
|
|
6475
|
+
delete out[key];
|
|
6476
|
+
continue;
|
|
6477
|
+
}
|
|
6478
|
+
if (key === "timeline") {
|
|
6479
|
+
out.timeline = isPlainObject(value) ? mergeTimeline(out.timeline, value, warn) : value;
|
|
6480
|
+
continue;
|
|
6481
|
+
}
|
|
6482
|
+
if (isPlainObject(value)) {
|
|
6483
|
+
out[key] = mergePlain(out[key], value);
|
|
6484
|
+
continue;
|
|
6485
|
+
}
|
|
6486
|
+
out[key] = value;
|
|
6487
|
+
}
|
|
6488
|
+
return { config: out, warnings };
|
|
6489
|
+
}
|
|
6490
|
+
function applyAnimatorConfig(doc, patch, opts) {
|
|
6491
|
+
var _a2, _b;
|
|
6492
|
+
const reset = !!(opts == null ? void 0 : opts.resetDefaults);
|
|
6493
|
+
if (!doc || (patch === void 0 || !reset && (patch === null || !isPlainObject(patch) || !Object.keys(patch).length))) {
|
|
6494
|
+
return { doc, warnings: [] };
|
|
6495
|
+
}
|
|
6496
|
+
const anyDoc = doc;
|
|
6497
|
+
const atRoot = isPlainObject(anyDoc.animator);
|
|
6498
|
+
const atMeta = !atRoot && isPlainObject((_a2 = anyDoc.meta) == null ? void 0 : _a2.animator);
|
|
6499
|
+
const current = atRoot ? anyDoc.animator : atMeta ? anyDoc.meta.animator : void 0;
|
|
6500
|
+
const warnings = [];
|
|
6501
|
+
if (atRoot && isPlainObject((_b = anyDoc.meta) == null ? void 0 : _b.animator)) {
|
|
6502
|
+
warnings.push("animator: doc.meta.animator is shadowed by doc.animator and was not patched");
|
|
6503
|
+
}
|
|
6504
|
+
let base = current;
|
|
6505
|
+
if (reset) {
|
|
6506
|
+
const kept = {};
|
|
6507
|
+
for (const k of CONTENT_KEYS) {
|
|
6508
|
+
if (isPlainObject(current) && current[k] !== void 0) kept[k] = current[k];
|
|
6509
|
+
}
|
|
6510
|
+
base = kept;
|
|
6511
|
+
}
|
|
6512
|
+
const merged = mergeAnimatorConfig(base, patch != null ? patch : {});
|
|
6513
|
+
warnings.push(...merged.warnings);
|
|
6514
|
+
if (merged.config === current) return { doc, warnings };
|
|
6515
|
+
if (atMeta) {
|
|
6516
|
+
return {
|
|
6517
|
+
doc: __spreadProps2(__spreadValues2({}, anyDoc), { meta: __spreadProps2(__spreadValues2({}, anyDoc.meta), { animator: merged.config }) }),
|
|
6518
|
+
warnings
|
|
6519
|
+
};
|
|
6520
|
+
}
|
|
6521
|
+
return { doc: __spreadProps2(__spreadValues2({}, anyDoc), { animator: merged.config }), warnings };
|
|
6522
|
+
}
|
|
6523
|
+
var MAX_REPORTED = 6;
|
|
6524
|
+
var LEGACY_FLAT_KEYS = [
|
|
6525
|
+
...PX_TIMELINE_SHARED_KEYS,
|
|
6526
|
+
...PX_TIME_ONLY_TIMELINE_KEYS,
|
|
6527
|
+
"fill",
|
|
6528
|
+
"resetOnFinish",
|
|
6529
|
+
"timelineSource",
|
|
6530
|
+
"scroll"
|
|
6531
|
+
];
|
|
6532
|
+
var isLegacyFlatAnimatorKey = (w) => LEGACY_FLAT_KEYS.some((k) => w.indexOf("animator." + k + ":") >= 0);
|
|
6533
|
+
function diagnoseDocument(doc) {
|
|
6534
|
+
let all;
|
|
6535
|
+
try {
|
|
6536
|
+
all = validateDocument(doc);
|
|
6537
|
+
} catch (e) {
|
|
6538
|
+
return { problems: [], legacy: [] };
|
|
6539
|
+
}
|
|
6540
|
+
const problems = [];
|
|
6541
|
+
const legacy = [];
|
|
6542
|
+
for (const w of all) (isLegacyFlatAnimatorKey(w) ? legacy : problems).push(w);
|
|
6543
|
+
return { problems, legacy };
|
|
6544
|
+
}
|
|
6545
|
+
function reportDocumentDiagnostics(doc, where) {
|
|
6546
|
+
const { problems } = diagnoseDocument(doc);
|
|
6547
|
+
if (!problems.length) return;
|
|
6548
|
+
const shown = problems.slice(0, MAX_REPORTED);
|
|
6549
|
+
const more = problems.length - shown.length;
|
|
6550
|
+
console.warn(
|
|
6551
|
+
where + ": this document does not match the animation schema in " + problems.length + " place" + (problems.length === 1 ? "" : "s") + ".\n" + shown.map((p) => " - " + p).join("\n") + (more > 0 ? "\n \u2026 and " + more + " more" : "") + "\n\nIf you did not author these keys, the usual cause is a build that MANGLES PROPERTY NAMES. An animation document is data loaded at runtime, so renaming the property reads inside the player stops them matching the keys in the JSON, and the animation silently does nothing. Feed the published reserved-name list to your minifier \u2014 @pixodesk/svg-animator-web/mangle-reserved.json \u2014 see docs/library/minification.md."
|
|
6552
|
+
);
|
|
6553
|
+
}
|
|
6309
6554
|
|
|
6310
|
-
// src/PxAnimatorTriggers.ts
|
|
6555
|
+
// src/triggers/PxAnimatorTriggers.ts
|
|
6311
6556
|
function setupAnimationTriggers(api, config) {
|
|
6312
6557
|
const { startOn, outAction = "continue", scrollIntoViewThreshold = 0 } = config;
|
|
6313
6558
|
const root = api.getRootElement();
|
|
@@ -6377,12 +6622,12 @@ function setupAnimationTriggers(api, config) {
|
|
|
6377
6622
|
}
|
|
6378
6623
|
case "scrollIntoView": {
|
|
6379
6624
|
const effectiveRatio = (entry) => {
|
|
6380
|
-
var
|
|
6625
|
+
var _a2, _b;
|
|
6381
6626
|
const target = entry.boundingClientRect;
|
|
6382
6627
|
const visible = entry.intersectionRect;
|
|
6383
6628
|
if (!(target == null ? void 0 : target.height) || !visible) return entry.intersectionRatio;
|
|
6384
6629
|
const live = typeof window !== "undefined" && window.innerHeight ? window.innerHeight : Infinity;
|
|
6385
|
-
const declared = (_b = (
|
|
6630
|
+
const declared = (_b = (_a2 = entry.rootBounds) == null ? void 0 : _a2.height) != null ? _b : Infinity;
|
|
6386
6631
|
const viewport = Math.min(live, declared);
|
|
6387
6632
|
const denom = Math.min(target.height, Number.isFinite(viewport) ? viewport : target.height);
|
|
6388
6633
|
return denom > 0 ? visible.height / denom : entry.intersectionRatio;
|
|
@@ -6412,7 +6657,7 @@ function setupAnimationTriggers(api, config) {
|
|
|
6412
6657
|
return api;
|
|
6413
6658
|
}
|
|
6414
6659
|
|
|
6415
|
-
// src/PxAnimatorFrameLoop.ts
|
|
6660
|
+
// src/engines/PxAnimatorFrameLoop.ts
|
|
6416
6661
|
function getSelector(id) {
|
|
6417
6662
|
return "#" + id;
|
|
6418
6663
|
}
|
|
@@ -6472,11 +6717,10 @@ function createDomAdapter(rootElement) {
|
|
|
6472
6717
|
return adapter;
|
|
6473
6718
|
}
|
|
6474
6719
|
|
|
6475
|
-
// src/PxAnimatorWebApi.ts
|
|
6720
|
+
// src/engines/PxAnimatorWebApi.ts
|
|
6476
6721
|
function createCssKf(kf, t, propName, unsupportedSet) {
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
const e = (_b = kf.e) != null ? _b : kf.easing;
|
|
6722
|
+
let value = kfValue(kf);
|
|
6723
|
+
const e = kfEasing(kf);
|
|
6480
6724
|
const cssKf = {
|
|
6481
6725
|
offset: t,
|
|
6482
6726
|
easing: e && Array.isArray(e) ? "cubic-bezier(" + e.join(",") + ")" : void 0
|
|
@@ -6510,11 +6754,11 @@ function createCssKf(kf, t, propName, unsupportedSet) {
|
|
|
6510
6754
|
return cssKf;
|
|
6511
6755
|
}
|
|
6512
6756
|
function clipKeyframesToDuration(propName, keyframes, duration) {
|
|
6513
|
-
var
|
|
6757
|
+
var _a2, _b, _c, _d, _e;
|
|
6514
6758
|
const result = [];
|
|
6515
6759
|
for (let i = 0; i < keyframes.length; i++) {
|
|
6516
6760
|
const kf = keyframes[i];
|
|
6517
|
-
const t = (
|
|
6761
|
+
const t = (_a2 = kf.t) != null ? _a2 : 0;
|
|
6518
6762
|
if (t < 0) {
|
|
6519
6763
|
const next = keyframes[i + 1];
|
|
6520
6764
|
if (next && ((_b = next.t) != null ? _b : 0) >= 0) {
|
|
@@ -6543,7 +6787,7 @@ function clipKeyframesToDuration(propName, keyframes, duration) {
|
|
|
6543
6787
|
return result;
|
|
6544
6788
|
}
|
|
6545
6789
|
function convertToWebApiKeyframes(animDef, unsupportedSet, config) {
|
|
6546
|
-
var
|
|
6790
|
+
var _a2;
|
|
6547
6791
|
const result = /* @__PURE__ */ new Map();
|
|
6548
6792
|
for (const [propName, propAnim] of Object.entries(animDef)) {
|
|
6549
6793
|
const duration = config.duration || 1;
|
|
@@ -6551,7 +6795,7 @@ function convertToWebApiKeyframes(animDef, unsupportedSet, config) {
|
|
|
6551
6795
|
const cssKeyframes = [];
|
|
6552
6796
|
for (let i = 0; i < clippedKeyframes.length; i++) {
|
|
6553
6797
|
const kf = clippedKeyframes[i];
|
|
6554
|
-
const t = clamp(((
|
|
6798
|
+
const t = clamp(((_a2 = kf.t) != null ? _a2 : 0) / duration, 0, 1);
|
|
6555
6799
|
const cssKf = createCssKf(kf, t, propName, unsupportedSet);
|
|
6556
6800
|
if (i === 0 && (cssKf.offset || 0) > 0) {
|
|
6557
6801
|
cssKeyframes.push(__spreadProps(__spreadValues({}, cssKf), { offset: 0 }));
|
|
@@ -6570,7 +6814,7 @@ function convertToWebApiKeyframes(animDef, unsupportedSet, config) {
|
|
|
6570
6814
|
return result;
|
|
6571
6815
|
}
|
|
6572
6816
|
function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs, scrollTimeline) {
|
|
6573
|
-
var
|
|
6817
|
+
var _a2;
|
|
6574
6818
|
const config = getAnimatorConfig(doc) || {};
|
|
6575
6819
|
if (!rootElement) {
|
|
6576
6820
|
if (doc.id) {
|
|
@@ -6581,7 +6825,7 @@ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsuppo
|
|
|
6581
6825
|
console.warn("createFrameLoopAnimator: No root element provided");
|
|
6582
6826
|
}
|
|
6583
6827
|
}
|
|
6584
|
-
const bindings = getNormalisedBindings(doc,
|
|
6828
|
+
const bindings = getNormalisedBindings(doc, PxTimelineEngine.native);
|
|
6585
6829
|
const animations = [];
|
|
6586
6830
|
const _iterations = config.iterations;
|
|
6587
6831
|
let iterations;
|
|
@@ -6618,7 +6862,7 @@ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsuppo
|
|
|
6618
6862
|
// animation ends — consistent with Lottie and other animation runtimes.
|
|
6619
6863
|
// Without this, seeking to the last frame reverts elements to their
|
|
6620
6864
|
// pre-animation state (the Web Animations API "after" phase with fill:'none').
|
|
6621
|
-
fill: (
|
|
6865
|
+
fill: (_a2 = config.fill) != null ? _a2 : "forwards",
|
|
6622
6866
|
direction: config.direction,
|
|
6623
6867
|
iterations
|
|
6624
6868
|
};
|
|
@@ -6635,16 +6879,16 @@ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsuppo
|
|
|
6635
6879
|
if (scrollTimeline.rangeEnd) a.rangeEnd = scrollTimeline.rangeEnd;
|
|
6636
6880
|
}
|
|
6637
6881
|
if (callbacks == null ? void 0 : callbacks.onFinish) anim.onfinish = () => {
|
|
6638
|
-
var
|
|
6882
|
+
var _a3;
|
|
6639
6883
|
if (finishNotified) return;
|
|
6640
6884
|
finishNotified = true;
|
|
6641
|
-
(
|
|
6885
|
+
(_a3 = callbacks.onFinish) == null ? void 0 : _a3.call(callbacks);
|
|
6642
6886
|
};
|
|
6643
6887
|
if (callbacks == null ? void 0 : callbacks.onRemove) anim.onremove = () => {
|
|
6644
|
-
var
|
|
6888
|
+
var _a3;
|
|
6645
6889
|
if (removeCalled) return;
|
|
6646
6890
|
removeCalled = true;
|
|
6647
|
-
(
|
|
6891
|
+
(_a3 = callbacks.onRemove) == null ? void 0 : _a3.call(callbacks);
|
|
6648
6892
|
};
|
|
6649
6893
|
if (seekPosition !== void 0) {
|
|
6650
6894
|
anim.currentTime = seekPosition;
|
|
@@ -6665,31 +6909,31 @@ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsuppo
|
|
|
6665
6909
|
"isReady": () => true,
|
|
6666
6910
|
"getRootElement": () => rootElement || null,
|
|
6667
6911
|
"isPlaying": () => {
|
|
6668
|
-
var
|
|
6669
|
-
return ((
|
|
6912
|
+
var _a3;
|
|
6913
|
+
return ((_a3 = animations[0]) == null ? void 0 : _a3.playState) === "running";
|
|
6670
6914
|
},
|
|
6671
6915
|
"play": () => {
|
|
6672
|
-
var
|
|
6916
|
+
var _a3;
|
|
6673
6917
|
finishNotified = false;
|
|
6674
6918
|
animations.forEach((a) => a.play());
|
|
6675
|
-
(
|
|
6919
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onPlay) == null ? void 0 : _a3.call(callbacks);
|
|
6676
6920
|
},
|
|
6677
6921
|
"pause": () => {
|
|
6678
|
-
var
|
|
6922
|
+
var _a3;
|
|
6679
6923
|
animations.forEach((a) => a.pause());
|
|
6680
|
-
(
|
|
6924
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onPause) == null ? void 0 : _a3.call(callbacks);
|
|
6681
6925
|
},
|
|
6682
6926
|
"cancel": () => {
|
|
6683
|
-
var
|
|
6927
|
+
var _a3;
|
|
6684
6928
|
finishNotified = false;
|
|
6685
6929
|
animations.forEach((a) => a.cancel());
|
|
6686
|
-
(
|
|
6930
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onCancel) == null ? void 0 : _a3.call(callbacks);
|
|
6687
6931
|
},
|
|
6688
6932
|
"finish": () => {
|
|
6689
|
-
var
|
|
6933
|
+
var _a3;
|
|
6690
6934
|
for (const a of animations) {
|
|
6691
6935
|
try {
|
|
6692
|
-
if (((
|
|
6936
|
+
if (((_a3 = a.effect) == null ? void 0 : _a3.getTiming().iterations) === Infinity) {
|
|
6693
6937
|
a.effect.updateTiming({ iterations: 1 });
|
|
6694
6938
|
a.finish();
|
|
6695
6939
|
a.effect.updateTiming({ iterations: Infinity });
|
|
@@ -6706,8 +6950,8 @@ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsuppo
|
|
|
6706
6950
|
return api;
|
|
6707
6951
|
},
|
|
6708
6952
|
"getCurrentTime": () => {
|
|
6709
|
-
var
|
|
6710
|
-
const res = (_b = (
|
|
6953
|
+
var _a3, _b;
|
|
6954
|
+
const res = (_b = (_a3 = animations[0]) == null ? void 0 : _a3.currentTime) != null ? _b : null;
|
|
6711
6955
|
return res !== null ? +res : null;
|
|
6712
6956
|
},
|
|
6713
6957
|
"setCurrentTime": (time) => {
|
|
@@ -6717,12 +6961,12 @@ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsuppo
|
|
|
6717
6961
|
});
|
|
6718
6962
|
},
|
|
6719
6963
|
"destroy": () => {
|
|
6720
|
-
var
|
|
6964
|
+
var _a3;
|
|
6721
6965
|
api.cancel();
|
|
6722
6966
|
animations.splice(0, animations.length);
|
|
6723
6967
|
if (!removeCalled) {
|
|
6724
6968
|
removeCalled = true;
|
|
6725
|
-
(
|
|
6969
|
+
(_a3 = callbacks == null ? void 0 : callbacks.onRemove) == null ? void 0 : _a3.call(callbacks);
|
|
6726
6970
|
}
|
|
6727
6971
|
}
|
|
6728
6972
|
};
|
|
@@ -6739,21 +6983,21 @@ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsuppo
|
|
|
6739
6983
|
return api;
|
|
6740
6984
|
}
|
|
6741
6985
|
|
|
6742
|
-
// src/PxScrollDriver.ts
|
|
6986
|
+
// src/scroll/PxScrollDriver.ts
|
|
6743
6987
|
function nativeRangeOffset(point, defaultFraction, view) {
|
|
6744
|
-
var
|
|
6988
|
+
var _a2, _b, _c;
|
|
6745
6989
|
const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
|
|
6746
|
-
const pct = (_b = (
|
|
6990
|
+
const pct = (_b = (_a2 = globalThis.CSS) == null ? void 0 : _a2.percent) == null ? void 0 : _b.call(_a2, fraction * 100);
|
|
6747
6991
|
if (pct === void 0) return void 0;
|
|
6748
6992
|
return view ? { rangeName: (_c = point == null ? void 0 : point.phase) != null ? _c : "cover", offset: pct } : { offset: pct };
|
|
6749
6993
|
}
|
|
6750
6994
|
function createNativeScrollTimeline(subject, config) {
|
|
6751
|
-
var
|
|
6995
|
+
var _a2, _b, _c, _d;
|
|
6752
6996
|
if (!config || !isScrollTimeline(config)) return null;
|
|
6753
6997
|
const scroll = config.scroll || {};
|
|
6754
|
-
const kind = (
|
|
6998
|
+
const kind = (_a2 = scroll.kind) != null ? _a2 : "view";
|
|
6755
6999
|
if (scroll.smoothing) {
|
|
6756
|
-
console.warn(
|
|
7000
|
+
console.warn("scroll timeline: `smoothing` needs the built-in driver \u2014 using the built-in driver instead of the browser timeline");
|
|
6757
7001
|
return null;
|
|
6758
7002
|
}
|
|
6759
7003
|
const g = globalThis;
|
|
@@ -6770,7 +7014,7 @@ function createNativeScrollTimeline(subject, config) {
|
|
|
6770
7014
|
timeline = new Ctor({ source, axis });
|
|
6771
7015
|
}
|
|
6772
7016
|
} catch (e) {
|
|
6773
|
-
console.warn("scroll timeline: native timeline construction failed \u2014 falling back to the
|
|
7017
|
+
console.warn("scroll timeline: native timeline construction failed \u2014 falling back to the player measuring progress itself", e);
|
|
6774
7018
|
return null;
|
|
6775
7019
|
}
|
|
6776
7020
|
return {
|
|
@@ -6798,7 +7042,7 @@ function documentScroller() {
|
|
|
6798
7042
|
var SUBJECT_PARENT = "parent";
|
|
6799
7043
|
var SUBJECT_SCROLLER = "scroller";
|
|
6800
7044
|
function resolveScrollSubject(svgRoot, subject) {
|
|
6801
|
-
var
|
|
7045
|
+
var _a2, _b;
|
|
6802
7046
|
const spec = subject == null ? void 0 : subject.trim();
|
|
6803
7047
|
if (!spec) return svgRoot;
|
|
6804
7048
|
if (spec === SUBJECT_PARENT) {
|
|
@@ -6807,7 +7051,7 @@ function resolveScrollSubject(svgRoot, subject) {
|
|
|
6807
7051
|
const position = getComputedStyle(p).position;
|
|
6808
7052
|
if (position === "sticky" || position === "fixed") outermostPinned = p;
|
|
6809
7053
|
}
|
|
6810
|
-
return (_b = (
|
|
7054
|
+
return (_b = (_a2 = outermostPinned == null ? void 0 : outermostPinned.parentElement) != null ? _a2 : svgRoot.parentElement) != null ? _b : svgRoot;
|
|
6811
7055
|
}
|
|
6812
7056
|
if (spec === SUBJECT_SCROLLER) {
|
|
6813
7057
|
return findNearestScroller(svgRoot, "y") || findNearestScroller(svgRoot, "x") || documentScroller();
|
|
@@ -6826,10 +7070,10 @@ function resolveScrollSubject(svgRoot, subject) {
|
|
|
6826
7070
|
return found;
|
|
6827
7071
|
}
|
|
6828
7072
|
function createScrollDriver(subject, config, onProgress) {
|
|
6829
|
-
var
|
|
7073
|
+
var _a2, _b;
|
|
6830
7074
|
if (!config || !isScrollTimeline(config)) return null;
|
|
6831
7075
|
const scroll = config.scroll || {};
|
|
6832
|
-
const kind = (
|
|
7076
|
+
const kind = (_a2 = scroll.kind) != null ? _a2 : "view";
|
|
6833
7077
|
const measured = resolveScrollSubject(subject, scroll.subject);
|
|
6834
7078
|
const nearest = findNearestScroller(subject, "y") || findNearestScroller(subject, "x");
|
|
6835
7079
|
const scroller = kind === "scroll" && scroll.source === "root" ? documentScroller() : nearest || documentScroller();
|
|
@@ -6948,8 +7192,8 @@ function applyScrollPin(svgRoot, scroll) {
|
|
|
6948
7192
|
style.position = "sticky";
|
|
6949
7193
|
const alignFactor = scroll.pinAlign === "center" ? 0.5 : scroll.pinAlign === "bottom" ? 1 : 0;
|
|
6950
7194
|
const applyTop = () => {
|
|
6951
|
-
var
|
|
6952
|
-
const extra = (
|
|
7195
|
+
var _a2;
|
|
7196
|
+
const extra = (_a2 = scroll.pinTop) != null ? _a2 : 0;
|
|
6953
7197
|
if (!alignFactor) {
|
|
6954
7198
|
style.top = extra + "px";
|
|
6955
7199
|
return;
|
|
@@ -6989,23 +7233,23 @@ function applyScrollPin(svgRoot, scroll) {
|
|
|
6989
7233
|
};
|
|
6990
7234
|
}
|
|
6991
7235
|
|
|
6992
|
-
// src/PxAnimatorBind.ts
|
|
7236
|
+
// src/engines/PxAnimatorBind.ts
|
|
6993
7237
|
function finaliseAnimator(animatorConfig, callbacks, make) {
|
|
6994
7238
|
let apiRef;
|
|
6995
7239
|
let effectiveCallbacks = callbacks;
|
|
6996
7240
|
if (animatorConfig.resetOnFinish) {
|
|
6997
7241
|
effectiveCallbacks = __spreadProps(__spreadValues({}, callbacks), {
|
|
6998
7242
|
onFinish: () => {
|
|
6999
|
-
var
|
|
7000
|
-
(
|
|
7243
|
+
var _a2;
|
|
7244
|
+
(_a2 = callbacks == null ? void 0 : callbacks.onFinish) == null ? void 0 : _a2.call(callbacks);
|
|
7001
7245
|
apiRef == null ? void 0 : apiRef.cancel();
|
|
7002
7246
|
}
|
|
7003
7247
|
});
|
|
7004
7248
|
}
|
|
7005
7249
|
const res = make(effectiveCallbacks);
|
|
7006
7250
|
apiRef = res;
|
|
7007
|
-
if (animatorConfig.
|
|
7008
|
-
window[animatorConfig.
|
|
7251
|
+
if (animatorConfig.debugGlobalName) {
|
|
7252
|
+
window[animatorConfig.debugGlobalName] = res;
|
|
7009
7253
|
}
|
|
7010
7254
|
return res;
|
|
7011
7255
|
}
|
|
@@ -7013,10 +7257,10 @@ function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
|
|
|
7013
7257
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
7014
7258
|
if (isScrollTimeline(animatorConfig)) {
|
|
7015
7259
|
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
7016
|
-
var
|
|
7260
|
+
var _a2;
|
|
7017
7261
|
let unpin = () => {
|
|
7018
7262
|
};
|
|
7019
|
-
if (
|
|
7263
|
+
if (mayUseNativeScrollTimeline(animatorConfig.engine) && rootElement) {
|
|
7020
7264
|
unpin = applyScrollPin(rootElement, animatorConfig.scroll);
|
|
7021
7265
|
const native = createNativeScrollTimeline(rootElement, animatorConfig);
|
|
7022
7266
|
if (native) {
|
|
@@ -7024,7 +7268,7 @@ function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
|
|
|
7024
7268
|
doc,
|
|
7025
7269
|
cb,
|
|
7026
7270
|
rootElement,
|
|
7027
|
-
animatorConfig.
|
|
7271
|
+
isNativeForced(animatorConfig.engine),
|
|
7028
7272
|
native
|
|
7029
7273
|
);
|
|
7030
7274
|
if (api2) {
|
|
@@ -7040,8 +7284,8 @@ function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
|
|
|
7040
7284
|
unpin = () => {
|
|
7041
7285
|
};
|
|
7042
7286
|
}
|
|
7043
|
-
const api = (animatorConfig.
|
|
7044
|
-
const subject = ((
|
|
7287
|
+
const api = (animatorConfig.engine !== PxTimelineEngineExtra.js ? createWebApiAnimator(doc, cb, rootElement, isNativeForced(animatorConfig.engine)) : null) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
7288
|
+
const subject = ((_a2 = api.getRootElement) == null ? void 0 : _a2.call(api)) || rootElement;
|
|
7045
7289
|
if (subject) {
|
|
7046
7290
|
unpin = applyScrollPin(subject, animatorConfig.scroll);
|
|
7047
7291
|
const totalMs = scrollTotalDurationMs(animatorConfig);
|
|
@@ -7065,20 +7309,19 @@ function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
|
|
|
7065
7309
|
});
|
|
7066
7310
|
}
|
|
7067
7311
|
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
7068
|
-
if (animatorConfig.
|
|
7312
|
+
if (animatorConfig.engine === PxTimelineEngineExtra.js) {
|
|
7069
7313
|
return createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
7070
7314
|
}
|
|
7071
7315
|
return createWebApiAnimator(
|
|
7072
7316
|
doc,
|
|
7073
7317
|
cb,
|
|
7074
7318
|
rootElement,
|
|
7075
|
-
animatorConfig.
|
|
7076
|
-
// forcing waapi
|
|
7319
|
+
isNativeForced(animatorConfig.engine)
|
|
7077
7320
|
) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
7078
7321
|
});
|
|
7079
7322
|
}
|
|
7080
7323
|
|
|
7081
|
-
// src/PxAnimatorDOM.ts
|
|
7324
|
+
// src/dom/PxAnimatorDOM.ts
|
|
7082
7325
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
7083
7326
|
function createElement(tagName, normalisedProps, style, children, textContent) {
|
|
7084
7327
|
if (DISALLOWED_SVG_TAGS_LOWER.has(tagName.toLowerCase())) {
|
|
@@ -7110,7 +7353,7 @@ function createElement(tagName, normalisedProps, style, children, textContent) {
|
|
|
7110
7353
|
}
|
|
7111
7354
|
function renderNode(node, defs) {
|
|
7112
7355
|
if (!node) return null;
|
|
7113
|
-
const
|
|
7356
|
+
const _a2 = node, { type, children, style } = _a2, props = __objRest(_a2, ["type", "children", "style"]);
|
|
7114
7357
|
const domType = props.domType;
|
|
7115
7358
|
if (domType !== void 0) delete props.domType;
|
|
7116
7359
|
const nodeDefs = getDefs(node) || defs;
|
|
@@ -7136,18 +7379,24 @@ function renderNode(node, defs) {
|
|
|
7136
7379
|
return element;
|
|
7137
7380
|
}
|
|
7138
7381
|
|
|
7139
|
-
// src/PxAnimatorKeys.ts
|
|
7382
|
+
// src/shared/PxAnimatorKeys.ts
|
|
7140
7383
|
var PX_ANIMATOR_DATA_KEY = "data";
|
|
7141
7384
|
|
|
7142
|
-
// src/PxAnimator.ts
|
|
7385
|
+
// src/animator/PxAnimator.ts
|
|
7143
7386
|
function createAnimatorFromConfig(doc, adapter, callbacks, rootElement) {
|
|
7144
7387
|
return bindWithEngineChoice(doc, adapter, callbacks, rootElement);
|
|
7145
7388
|
}
|
|
7146
|
-
function createAnimatorImpl(doc, adapter, callbacks, containerElement) {
|
|
7389
|
+
function createAnimatorImpl(doc, adapter, callbacks, containerElement, config, resetDocDefaults) {
|
|
7147
7390
|
const effectsWarnings = validateNodeEffects(doc);
|
|
7148
7391
|
for (const w of effectsWarnings) console.warn("[PxAnimator] effects shape warning:", w);
|
|
7392
|
+
reportDocumentDiagnostics(doc, "[PxAnimator] createAnimator");
|
|
7393
|
+
if (config !== void 0 || resetDocDefaults) {
|
|
7394
|
+
const patched = applyAnimatorConfig(doc, config != null ? config : {}, { resetDefaults: !!resetDocDefaults });
|
|
7395
|
+
for (const w of patched.warnings) console.warn("[PxAnimator] config override:", w);
|
|
7396
|
+
doc = patched.doc;
|
|
7397
|
+
}
|
|
7149
7398
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
7150
|
-
const engine = animatorConfig.
|
|
7399
|
+
const engine = resolveTimelineEngine(animatorConfig.engine);
|
|
7151
7400
|
doc = materialiseAllInTree(doc, engine);
|
|
7152
7401
|
let rootElement = null;
|
|
7153
7402
|
if (containerElement) {
|
|
@@ -7171,8 +7420,13 @@ function createAnimatorImpl(doc, adapter, callbacks, containerElement) {
|
|
|
7171
7420
|
}
|
|
7172
7421
|
return api;
|
|
7173
7422
|
}
|
|
7423
|
+
function resolveAnimatorConfigOption(options) {
|
|
7424
|
+
const { config, duration, delay, iterations, startOn } = options;
|
|
7425
|
+
return foldAnimatorConfigShortcuts(config, { duration, delay, iterations, startOn });
|
|
7426
|
+
}
|
|
7174
7427
|
function createAnimator(options) {
|
|
7175
|
-
const { src, data, adapter, callbacks, container } = options;
|
|
7428
|
+
const { src, data, adapter, callbacks, container, resetDocDefaults } = options;
|
|
7429
|
+
const config = resolveAnimatorConfigOption(options);
|
|
7176
7430
|
if (data !== void 0 && src !== void 0) {
|
|
7177
7431
|
throw new Error("createAnimator: provide either `src` or `data`, not both");
|
|
7178
7432
|
}
|
|
@@ -7180,7 +7434,7 @@ function createAnimator(options) {
|
|
|
7180
7434
|
throw new Error("createAnimator: either `src` or `data` is required");
|
|
7181
7435
|
}
|
|
7182
7436
|
if (data !== void 0) {
|
|
7183
|
-
return createAnimatorImpl(data, adapter, callbacks, container);
|
|
7437
|
+
return createAnimatorImpl(data, adapter, callbacks, container, config, resetDocDefaults);
|
|
7184
7438
|
}
|
|
7185
7439
|
let animator = null;
|
|
7186
7440
|
let pending = [];
|
|
@@ -7195,7 +7449,7 @@ function createAnimator(options) {
|
|
|
7195
7449
|
fetch(src).then((res) => res.json()).then((json) => {
|
|
7196
7450
|
if (destroyed) return;
|
|
7197
7451
|
if (isPxElementFileFormat(json)) {
|
|
7198
|
-
animator = createAnimatorImpl(json, adapter, callbacks, container);
|
|
7452
|
+
animator = createAnimatorImpl(json, adapter, callbacks, container, config, resetDocDefaults);
|
|
7199
7453
|
const queued = pending;
|
|
7200
7454
|
pending = null;
|
|
7201
7455
|
queued == null ? void 0 : queued.forEach((call) => call(animator));
|
|
@@ -7264,12 +7518,11 @@ if (typeof window !== "undefined") {
|
|
|
7264
7518
|
PxAnimatedSvgDocumentSchema,
|
|
7265
7519
|
PxAnimationDefinitionSchema,
|
|
7266
7520
|
PxAnimatorConfigSchema,
|
|
7267
|
-
PxAnimatorEngine,
|
|
7268
|
-
PxAnimatorMode,
|
|
7269
7521
|
PxAttrValueSchema,
|
|
7270
7522
|
PxBezierPathSchema,
|
|
7271
7523
|
PxBindingSchema,
|
|
7272
7524
|
PxCloneEffectSchema,
|
|
7525
|
+
PxCloneWithout,
|
|
7273
7526
|
PxDefsSchema,
|
|
7274
7527
|
PxEasingOrRefSchema,
|
|
7275
7528
|
PxEffectsSchema,
|
|
@@ -7281,6 +7534,8 @@ if (typeof window !== "undefined") {
|
|
|
7281
7534
|
PxGradientUnits,
|
|
7282
7535
|
PxKeyframeSchema,
|
|
7283
7536
|
PxKeyframeValueSchema,
|
|
7537
|
+
PxLoopDirection,
|
|
7538
|
+
PxLoopRepeatAt,
|
|
7284
7539
|
PxLoopSchema,
|
|
7285
7540
|
PxMaskedByEffectSchema,
|
|
7286
7541
|
PxNodeBase,
|
|
@@ -7290,15 +7545,19 @@ if (typeof window !== "undefined") {
|
|
|
7290
7545
|
PxRetimeEffectSchema,
|
|
7291
7546
|
PxStrokeGradientEffectSchema,
|
|
7292
7547
|
PxStrokeTrimEffectSchema,
|
|
7548
|
+
PxStrokeTrimSubPaths,
|
|
7293
7549
|
PxSvgNodeExtra,
|
|
7294
7550
|
PxTextEffectSchema,
|
|
7295
7551
|
PxTextPathEffectSchema,
|
|
7552
|
+
PxTimelineEngine,
|
|
7553
|
+
PxTimelineEngineExtra,
|
|
7296
7554
|
PxTransformByEffectSchema,
|
|
7297
7555
|
PxTransformPartsSchema,
|
|
7298
7556
|
PxTransformValueSchema,
|
|
7299
7557
|
PxTriggerSchema,
|
|
7300
7558
|
STYLE_ATTR_NAMES,
|
|
7301
7559
|
TRANSFORM_FN_NAMES,
|
|
7560
|
+
applyAnimatorConfig,
|
|
7302
7561
|
applyPlayerEffects,
|
|
7303
7562
|
calcAnimationValues,
|
|
7304
7563
|
camelCaseToKebabWordIfNeeded,
|
|
@@ -7313,6 +7572,7 @@ if (typeof window !== "undefined") {
|
|
|
7313
7572
|
diffInEffect,
|
|
7314
7573
|
evaluateMotionPathSegment,
|
|
7315
7574
|
extendedPathForBrowser,
|
|
7575
|
+
foldAnimatorConfigShortcuts,
|
|
7316
7576
|
generateNewIds,
|
|
7317
7577
|
getAnimatorConfig,
|
|
7318
7578
|
getBindings,
|
|
@@ -7333,6 +7593,7 @@ if (typeof window !== "undefined") {
|
|
|
7333
7593
|
materialiseInternalLoopsInTree,
|
|
7334
7594
|
materialiseMotionPathInPropAnim,
|
|
7335
7595
|
materialiseMotionPathsInTree,
|
|
7596
|
+
mergeAnimatorConfig,
|
|
7336
7597
|
normalizeDocument,
|
|
7337
7598
|
propAnimIsMotionPath,
|
|
7338
7599
|
px,
|
|
@@ -7341,6 +7602,7 @@ if (typeof window !== "undefined") {
|
|
|
7341
7602
|
setupAnimationTriggers,
|
|
7342
7603
|
shiftAnimatable,
|
|
7343
7604
|
toRGBA,
|
|
7605
|
+
validateDocument,
|
|
7344
7606
|
validateNodeEffects,
|
|
7345
7607
|
visualModelAt
|
|
7346
7608
|
});
|