@pixodesk/svg-animator-core 1.0.35 → 1.0.39
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 +16 -13
- package/dist/index.cjs +571 -205
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1762 -2251
- package/dist/index.d.ts +1762 -2251
- package/dist/index.js +525 -190
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -51,7 +51,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
51
51
|
var index_exports = {};
|
|
52
52
|
__export(index_exports, {
|
|
53
53
|
BASELINE_PLAYER_VERSION: () => BASELINE_PLAYER_VERSION,
|
|
54
|
-
|
|
54
|
+
COLOR_ATTR_NAMES: () => COLOR_ATTR_NAMES,
|
|
55
55
|
CSS_ONLY_STYLE_PROPS: () => CSS_ONLY_STYLE_PROPS,
|
|
56
56
|
DEFAULT_DURATION_MS: () => DEFAULT_DURATION_MS,
|
|
57
57
|
DISALLOWED_SVG_TAGS_LOWER: () => DISALLOWED_SVG_TAGS_LOWER,
|
|
@@ -64,45 +64,65 @@ __export(index_exports, {
|
|
|
64
64
|
PX_ANIM_ATTR_NAME: () => PX_ANIM_ATTR_NAME,
|
|
65
65
|
PX_ANIM_SRC_ATTR_NAME: () => PX_ANIM_SRC_ATTR_NAME,
|
|
66
66
|
PX_PLAYER_SCHEMA_VERSION: () => PX_PLAYER_SCHEMA_VERSION,
|
|
67
|
+
PX_RATE_REJECTED: () => PX_RATE_REJECTED,
|
|
67
68
|
PX_TRANSFORM_PART_KEYS: () => PX_TRANSFORM_PART_KEYS,
|
|
69
|
+
PX_TRIGGER_DEFAULTS: () => PX_TRIGGER_DEFAULTS,
|
|
68
70
|
PX_UNKNOWN_KEY_ERROR: () => PX_UNKNOWN_KEY_ERROR,
|
|
71
|
+
PxAlongPathMode: () => PxAlongPathMode,
|
|
69
72
|
PxAnimatedSvgDocumentSchema: () => PxAnimatedSvgDocumentSchema,
|
|
70
73
|
PxAnimationDefinitionSchema: () => PxAnimationDefinitionSchema,
|
|
71
74
|
PxAnimatorConfigSchema: () => PxAnimatorConfigSchema,
|
|
72
75
|
PxAttrValueSchema: () => PxAttrValueSchema,
|
|
73
76
|
PxBezierPathSchema: () => PxBezierPathSchema,
|
|
74
77
|
PxBindingSchema: () => PxBindingSchema,
|
|
78
|
+
PxClipPathEffectSchema: () => PxClipPathEffectSchema,
|
|
75
79
|
PxCloneEffectSchema: () => PxCloneEffectSchema,
|
|
76
80
|
PxCloneWithout: () => PxCloneWithout,
|
|
81
|
+
PxControlMode: () => PxControlMode,
|
|
77
82
|
PxDefsSchema: () => PxDefsSchema,
|
|
83
|
+
PxDiagnosticKind: () => PxDiagnosticKind,
|
|
78
84
|
PxEasingOrRefSchema: () => PxEasingOrRefSchema,
|
|
79
85
|
PxEffectsSchema: () => PxEffectsSchema,
|
|
80
86
|
PxElementAnimationSchema: () => PxElementAnimationSchema,
|
|
81
87
|
PxFillGradientEffectSchema: () => PxFillGradientEffectSchema,
|
|
88
|
+
PxFillMode: () => PxFillMode,
|
|
89
|
+
PxFinishAction: () => PxFinishAction,
|
|
82
90
|
PxGradientSpreadMethod: () => PxGradientSpreadMethod,
|
|
83
91
|
PxGradientStopSchema: () => PxGradientStopSchema,
|
|
84
92
|
PxGradientType: () => PxGradientType,
|
|
85
|
-
PxGradientUnits: () => PxGradientUnits,
|
|
86
93
|
PxKeyframeSchema: () => PxKeyframeSchema,
|
|
87
94
|
PxKeyframeValueSchema: () => PxKeyframeValueSchema,
|
|
95
|
+
PxLengthAdjust: () => PxLengthAdjust,
|
|
88
96
|
PxLoopDirection: () => PxLoopDirection,
|
|
89
97
|
PxLoopRepeatAt: () => PxLoopRepeatAt,
|
|
90
98
|
PxLoopSchema: () => PxLoopSchema,
|
|
99
|
+
PxMaskType: () => PxMaskType,
|
|
91
100
|
PxMaskedByEffectSchema: () => PxMaskedByEffectSchema,
|
|
92
101
|
PxNodeBase: () => PxNodeBase,
|
|
93
102
|
PxNodeSchema: () => PxNodeSchema,
|
|
103
|
+
PxOutAction: () => PxOutAction,
|
|
104
|
+
PxPathOverflow: () => PxPathOverflow,
|
|
105
|
+
PxPinAlign: () => PxPinAlign,
|
|
106
|
+
PxPlaybackDirection: () => PxPlaybackDirection,
|
|
94
107
|
PxPropertyAnimationSchema: () => PxPropertyAnimationSchema,
|
|
95
108
|
PxRepeaterEffectSchema: () => PxRepeaterEffectSchema,
|
|
96
109
|
PxRetimeEffectSchema: () => PxRetimeEffectSchema,
|
|
110
|
+
PxScrollAxis: () => PxScrollAxis,
|
|
111
|
+
PxScrollKind: () => PxScrollKind,
|
|
112
|
+
PxScrollPhase: () => PxScrollPhase,
|
|
97
113
|
PxScrollRangePointSchema: () => PxScrollRangePointSchema,
|
|
98
114
|
PxScrollRangeSchema: () => PxScrollRangeSchema,
|
|
99
115
|
PxScrollSchema: () => PxScrollSchema,
|
|
116
|
+
PxScrollSource: () => PxScrollSource,
|
|
117
|
+
PxStartOn: () => PxStartOn,
|
|
100
118
|
PxStrokeGradientEffectSchema: () => PxStrokeGradientEffectSchema,
|
|
101
119
|
PxStrokeTrimEffectSchema: () => PxStrokeTrimEffectSchema,
|
|
102
120
|
PxStrokeTrimSubPaths: () => PxStrokeTrimSubPaths,
|
|
103
121
|
PxSvgNodeExtra: () => PxSvgNodeExtra,
|
|
104
122
|
PxTextEffectSchema: () => PxTextEffectSchema,
|
|
105
123
|
PxTextPathEffectSchema: () => PxTextPathEffectSchema,
|
|
124
|
+
PxTextPathMethod: () => PxTextPathMethod,
|
|
125
|
+
PxTextPathSpacing: () => PxTextPathSpacing,
|
|
106
126
|
PxTimelineEngine: () => PxTimelineEngine,
|
|
107
127
|
PxTimelineEngineExtra: () => PxTimelineEngineExtra,
|
|
108
128
|
PxTimelinePinSchema: () => PxTimelinePinSchema,
|
|
@@ -111,8 +131,8 @@ __export(index_exports, {
|
|
|
111
131
|
PxTransformPartsSchema: () => PxTransformPartsSchema,
|
|
112
132
|
PxTransformValueSchema: () => PxTransformValueSchema,
|
|
113
133
|
PxTriggerSchema: () => PxTriggerSchema,
|
|
134
|
+
PxUnits: () => PxUnits,
|
|
114
135
|
STYLE_ATTR_NAMES: () => STYLE_ATTR_NAMES,
|
|
115
|
-
TEXT_ATTR: () => TEXT_ATTR,
|
|
116
136
|
TEXT_CONTENT_ATTR: () => TEXT_CONTENT_ATTR,
|
|
117
137
|
TRANSFORM_FN_NAMES: () => TRANSFORM_FN_NAMES,
|
|
118
138
|
WIRE_VERSION_KEY: () => WIRE_VERSION_KEY,
|
|
@@ -126,12 +146,16 @@ __export(index_exports, {
|
|
|
126
146
|
calcAnimationValues: () => calcAnimationValues,
|
|
127
147
|
camelCaseToKebabWordIfNeeded: () => camelCaseToKebabWordIfNeeded,
|
|
128
148
|
clamp: () => clamp,
|
|
149
|
+
clampSeekMs: () => clampSeekMs,
|
|
129
150
|
collectSampleTimes: () => collectSampleTimes,
|
|
130
151
|
compareWireVersion: () => compareWireVersion,
|
|
131
152
|
composeTransformParts: () => composeTransformParts,
|
|
153
|
+
controlModeTakesOverTrigger: () => controlModeTakesOverTrigger,
|
|
132
154
|
convertPlayerDocument: () => convertPlayerDocument,
|
|
133
155
|
createBasicFrameLoopAnimator: () => createBasicFrameLoopAnimator,
|
|
156
|
+
createDiagnostics: () => createDiagnostics,
|
|
134
157
|
createPathSampler: () => createPathSampler,
|
|
158
|
+
createRunClock: () => createRunClock,
|
|
135
159
|
cubicBezier: () => cubicBezier,
|
|
136
160
|
deepClone: () => deepClone,
|
|
137
161
|
describeSchema: () => describeSchema,
|
|
@@ -142,7 +166,7 @@ __export(index_exports, {
|
|
|
142
166
|
evaluateMotionPathSegment: () => evaluateMotionPathSegment,
|
|
143
167
|
extendedPathForBrowser: () => extendedPathForBrowser,
|
|
144
168
|
flattenAnimatorTimeline: () => flattenAnimatorTimeline,
|
|
145
|
-
|
|
169
|
+
foldTimelineOverride: () => foldTimelineOverride,
|
|
146
170
|
formatWireVersion: () => formatWireVersion,
|
|
147
171
|
generateNewIds: () => generateNewIds,
|
|
148
172
|
generateUniqueId: () => generateUniqueId,
|
|
@@ -150,7 +174,7 @@ __export(index_exports, {
|
|
|
150
174
|
getBindings: () => getBindings,
|
|
151
175
|
getChildren: () => getChildren,
|
|
152
176
|
getDefs: () => getDefs,
|
|
153
|
-
|
|
177
|
+
getNormalizedBindings: () => getNormalizedBindings,
|
|
154
178
|
getNormalizedProps: () => getNormalizedProps,
|
|
155
179
|
interpolateBeziers: () => interpolateBeziers,
|
|
156
180
|
interpolateValue: () => interpolateValue,
|
|
@@ -158,6 +182,7 @@ __export(index_exports, {
|
|
|
158
182
|
isPxElementFileFormat: () => isPxElementFileFormat,
|
|
159
183
|
isPxElementFileFormatDeep: () => isPxElementFileFormatDeep,
|
|
160
184
|
isScrollTimeline: () => isScrollTimeline,
|
|
185
|
+
isValidPlaybackRate: () => isValidPlaybackRate,
|
|
161
186
|
jsonElementFactory: () => jsonElementFactory,
|
|
162
187
|
kebabToCamelCaseWord: () => kebabToCamelCaseWord,
|
|
163
188
|
kfEasing: () => kfEasing,
|
|
@@ -166,15 +191,15 @@ __export(index_exports, {
|
|
|
166
191
|
kfTime: () => kfTime,
|
|
167
192
|
kfValue: () => kfValue,
|
|
168
193
|
layoutGlyphTextChars: () => layoutGlyphTextChars,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
194
|
+
materializeAllInTree: () => materializeAllInTree,
|
|
195
|
+
materializeAnimatedUseInstances: () => materializeAnimatedUseInstances,
|
|
196
|
+
materializeGlyphText: () => materializeGlyphText,
|
|
197
|
+
materializeGlyphTextAlongPath: () => materializeGlyphTextAlongPath,
|
|
198
|
+
materializeGlyphTextHorizontal: () => materializeGlyphTextHorizontal,
|
|
199
|
+
materializeInternalLoopsInPropAnim: () => materializeInternalLoopsInPropAnim,
|
|
200
|
+
materializeInternalLoopsInTree: () => materializeInternalLoopsInTree,
|
|
201
|
+
materializeMotionPathInPropAnim: () => materializeMotionPathInPropAnim,
|
|
202
|
+
materializeMotionPathsInTree: () => materializeMotionPathsInTree,
|
|
178
203
|
mayUseNativeScrollTimeline: () => mayUseNativeScrollTimeline,
|
|
179
204
|
mergeAnimatorConfig: () => mergeAnimatorConfig,
|
|
180
205
|
mergeStaticTransformIntoAnimDef: () => mergeStaticTransformIntoAnimDef,
|
|
@@ -182,15 +207,19 @@ __export(index_exports, {
|
|
|
182
207
|
parseTransformParts: () => parseTransformParts,
|
|
183
208
|
parseWireVersion: () => parseWireVersion,
|
|
184
209
|
planSchemaRelease: () => planSchemaRelease,
|
|
210
|
+
progressSpanMs: () => progressSpanMs,
|
|
211
|
+
progressToTimeMs: () => progressToTimeMs,
|
|
185
212
|
propAnimIsMotionPath: () => propAnimIsMotionPath,
|
|
186
213
|
px: () => px,
|
|
187
214
|
readWireVersion: () => readWireVersion,
|
|
188
215
|
releaseLogProblems: () => releaseLogProblems,
|
|
189
216
|
reportDocumentDiagnostics: () => reportDocumentDiagnostics,
|
|
217
|
+
resolveControlMode: () => resolveControlMode,
|
|
190
218
|
resolveStyle: () => resolveStyle,
|
|
191
219
|
resolveTimelineEngine: () => resolveTimelineEngine,
|
|
220
|
+
resolveTrigger: () => resolveTrigger,
|
|
192
221
|
reverseEasing: () => reverseEasing,
|
|
193
|
-
|
|
222
|
+
sanitizeAttributeValue: () => sanitizeAttributeValue,
|
|
194
223
|
schemaFieldUniverse: () => schemaFieldUniverse,
|
|
195
224
|
schemaKeys: () => schemaKeys,
|
|
196
225
|
scrollOffsetProgress: () => scrollOffsetProgress,
|
|
@@ -198,9 +227,11 @@ __export(index_exports, {
|
|
|
198
227
|
scrollResolveAxis: () => scrollResolveAxis,
|
|
199
228
|
scrollTotalDurationMs: () => scrollTotalDurationMs,
|
|
200
229
|
scrollViewProgress: () => scrollViewProgress,
|
|
230
|
+
seekCeilingMs: () => seekCeilingMs,
|
|
201
231
|
shiftAnimatable: () => shiftAnimatable,
|
|
202
232
|
splitEasing: () => splitEasing,
|
|
203
233
|
subdivideCubicBezier: () => subdivideCubicBezier,
|
|
234
|
+
timeToProgress: () => timeToProgress,
|
|
204
235
|
toRGBA: () => toRGBA,
|
|
205
236
|
validateDocument: () => validateDocument,
|
|
206
237
|
validateNodeEffects: () => validateNodeEffects,
|
|
@@ -439,7 +470,7 @@ function parseColor(s) {
|
|
|
439
470
|
}
|
|
440
471
|
return void 0;
|
|
441
472
|
}
|
|
442
|
-
var
|
|
473
|
+
var COLOR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
|
|
443
474
|
var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
|
|
444
475
|
var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
445
476
|
function composeTransformParts(parts, opts) {
|
|
@@ -822,6 +853,7 @@ var Enum = class extends Base {
|
|
|
822
853
|
return false;
|
|
823
854
|
}
|
|
824
855
|
};
|
|
856
|
+
var UNION_MEMBER_ERROR_LIMIT = 4;
|
|
825
857
|
var Union = class extends Base {
|
|
826
858
|
constructor(schemas, defaultVal) {
|
|
827
859
|
super();
|
|
@@ -840,7 +872,35 @@ var Union = class extends Base {
|
|
|
840
872
|
var _a2;
|
|
841
873
|
const probe = ctx && { errors: [], warnings: [], strict: ctx.strict };
|
|
842
874
|
if (this.schemas.some((s) => s.isValid(raw, probe, path ? [...path] : void 0))) return true;
|
|
843
|
-
|
|
875
|
+
if (!ctx) return false;
|
|
876
|
+
const base = pathStr(path != null ? path : []);
|
|
877
|
+
ctx.errors.push(base + ": no union member matched for value " + ((_a2 = JSON.stringify(raw)) != null ? _a2 : "").slice(0, 240));
|
|
878
|
+
let best;
|
|
879
|
+
let bestDepth = -1;
|
|
880
|
+
const leafExpectations = [];
|
|
881
|
+
for (const member of this.schemas) {
|
|
882
|
+
const sink = { errors: [], warnings: [], strict: ctx.strict };
|
|
883
|
+
member.isValid(raw, sink, path ? [...path] : void 0);
|
|
884
|
+
if (!sink.errors.length) continue;
|
|
885
|
+
const depth = Math.max(...sink.errors.map((e) => e.slice(0, e.indexOf(":")).length));
|
|
886
|
+
if (depth > bestDepth || depth === bestDepth && best && sink.errors.length < best.length) {
|
|
887
|
+
bestDepth = depth;
|
|
888
|
+
best = sink.errors;
|
|
889
|
+
}
|
|
890
|
+
if (depth <= base.length) {
|
|
891
|
+
for (const e of sink.errors) {
|
|
892
|
+
const m = /: expected (.+?), got /.exec(e);
|
|
893
|
+
if (m && !leafExpectations.includes(m[1])) leafExpectations.push(m[1]);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
if (best && bestDepth > base.length) {
|
|
898
|
+
for (const e of best.slice(0, UNION_MEMBER_ERROR_LIMIT)) {
|
|
899
|
+
if (!ctx.errors.includes(e)) ctx.errors.push(e);
|
|
900
|
+
}
|
|
901
|
+
} else if (leafExpectations.length) {
|
|
902
|
+
ctx.errors.push(base + ": expected " + leafExpectations.join(" | "));
|
|
903
|
+
}
|
|
844
904
|
return false;
|
|
845
905
|
}
|
|
846
906
|
_canSanitize(raw) {
|
|
@@ -1519,10 +1579,78 @@ function releaseLogProblems(releases, steps, declared, baseline) {
|
|
|
1519
1579
|
}
|
|
1520
1580
|
|
|
1521
1581
|
// src/format/PxAnimatorConstants.ts
|
|
1582
|
+
var PxFillMode = {
|
|
1583
|
+
forwards: "forwards",
|
|
1584
|
+
backwards: "backwards",
|
|
1585
|
+
both: "both",
|
|
1586
|
+
none: "none"
|
|
1587
|
+
};
|
|
1588
|
+
var PxPlaybackDirection = {
|
|
1589
|
+
normal: "normal",
|
|
1590
|
+
reverse: "reverse",
|
|
1591
|
+
alternate: "alternate",
|
|
1592
|
+
alternateReverse: "alternate-reverse"
|
|
1593
|
+
};
|
|
1522
1594
|
var PX_ANIM_SRC_ATTR_NAME = "data-px-animation-src";
|
|
1523
1595
|
var PX_ANIM_ATTR_NAME = "_px_animator";
|
|
1596
|
+
var PxStartOn = {
|
|
1597
|
+
load: "load",
|
|
1598
|
+
mouseOver: "mouseOver",
|
|
1599
|
+
click: "click",
|
|
1600
|
+
scrollIntoView: "scrollIntoView",
|
|
1601
|
+
programmatic: "programmatic"
|
|
1602
|
+
};
|
|
1603
|
+
var PxOutAction = {
|
|
1604
|
+
continue: "continue",
|
|
1605
|
+
pause: "pause",
|
|
1606
|
+
reset: "reset",
|
|
1607
|
+
reverse: "reverse"
|
|
1608
|
+
};
|
|
1609
|
+
var PxFinishAction = {
|
|
1610
|
+
hold: "hold",
|
|
1611
|
+
reset: "reset"
|
|
1612
|
+
};
|
|
1613
|
+
var PxScrollKind = {
|
|
1614
|
+
view: "view",
|
|
1615
|
+
scroll: "scroll"
|
|
1616
|
+
};
|
|
1617
|
+
var PxScrollAxis = {
|
|
1618
|
+
block: "block",
|
|
1619
|
+
inline: "inline",
|
|
1620
|
+
x: "x",
|
|
1621
|
+
y: "y"
|
|
1622
|
+
};
|
|
1623
|
+
var PxScrollSource = {
|
|
1624
|
+
nearest: "nearest",
|
|
1625
|
+
root: "root"
|
|
1626
|
+
};
|
|
1627
|
+
var PxPinAlign = {
|
|
1628
|
+
top: "top",
|
|
1629
|
+
center: "center",
|
|
1630
|
+
bottom: "bottom"
|
|
1631
|
+
};
|
|
1632
|
+
var PxScrollPhase = {
|
|
1633
|
+
cover: "cover",
|
|
1634
|
+
contain: "contain",
|
|
1635
|
+
entry: "entry",
|
|
1636
|
+
exit: "exit",
|
|
1637
|
+
entryCrossing: "entry-crossing",
|
|
1638
|
+
exitCrossing: "exit-crossing"
|
|
1639
|
+
};
|
|
1640
|
+
var PxAlongPathMode = {
|
|
1641
|
+
sampled: "sampled",
|
|
1642
|
+
offsetPath: "offsetPath"
|
|
1643
|
+
};
|
|
1524
1644
|
var PX_TIMELINE_SHARED_KEYS = ["duration", "iterations", "engine", "frameRate"];
|
|
1525
1645
|
var PX_TIME_ONLY_TIMELINE_KEYS = ["trigger", "delay", "fillMode", "direction"];
|
|
1646
|
+
var PX_FLAT_RUNTIME_VIEW_KEYS = [
|
|
1647
|
+
...PX_TIMELINE_SHARED_KEYS,
|
|
1648
|
+
...PX_TIME_ONLY_TIMELINE_KEYS,
|
|
1649
|
+
"fill",
|
|
1650
|
+
"resetOnFinish",
|
|
1651
|
+
"timelineSource",
|
|
1652
|
+
"scroll"
|
|
1653
|
+
];
|
|
1526
1654
|
var PxTimelineEngine = {
|
|
1527
1655
|
native: "native",
|
|
1528
1656
|
js: "js"
|
|
@@ -1539,6 +1667,50 @@ function isNativeForced(engine) {
|
|
|
1539
1667
|
function mayUseNativeScrollTimeline(engine) {
|
|
1540
1668
|
return engine !== PxTimelineEngineExtra.js;
|
|
1541
1669
|
}
|
|
1670
|
+
var PX_TRIGGER_DEFAULTS = {
|
|
1671
|
+
startOn: "load",
|
|
1672
|
+
outAction: "continue",
|
|
1673
|
+
scrollIntoViewThreshold: 0
|
|
1674
|
+
};
|
|
1675
|
+
var PxControlMode = {
|
|
1676
|
+
/** No control props — the document's trigger decides, and nothing is taken over. */
|
|
1677
|
+
static: "static",
|
|
1678
|
+
/** `progress` / `time` — the host scrubs; the component seeks and stays paused. */
|
|
1679
|
+
fixedTime: "fixedTime",
|
|
1680
|
+
/** `play` / `pause` — the host drives playback with booleans. */
|
|
1681
|
+
play: "play",
|
|
1682
|
+
/** `autoplay` — the document's own trigger starts it. */
|
|
1683
|
+
autoplay: "autoplay"
|
|
1684
|
+
};
|
|
1685
|
+
function resolveControlMode(props) {
|
|
1686
|
+
const hasFixedTime = props.progress !== void 0 || props.time !== void 0;
|
|
1687
|
+
const hasPlayPause = props.play !== void 0 || props.pause !== void 0;
|
|
1688
|
+
const hasAutoplay = !!props.autoplay;
|
|
1689
|
+
const warnings = [];
|
|
1690
|
+
const named = (a, b, winner) => a + " and " + b + " were both set \u2014 " + winner + " wins, " + (winner === a ? b : a) + " is ignored.";
|
|
1691
|
+
if (hasFixedTime) {
|
|
1692
|
+
if (hasPlayPause) warnings.push(named("progress/time", "play/pause", "progress/time"));
|
|
1693
|
+
if (hasAutoplay) warnings.push(named("progress/time", "autoplay", "progress/time"));
|
|
1694
|
+
return { mode: PxControlMode.fixedTime, warnings };
|
|
1695
|
+
}
|
|
1696
|
+
if (hasPlayPause) {
|
|
1697
|
+
if (hasAutoplay) warnings.push(named("play/pause", "autoplay", "play/pause"));
|
|
1698
|
+
return { mode: PxControlMode.play, warnings };
|
|
1699
|
+
}
|
|
1700
|
+
if (hasAutoplay) return { mode: PxControlMode.autoplay, warnings };
|
|
1701
|
+
return { mode: PxControlMode.static, warnings };
|
|
1702
|
+
}
|
|
1703
|
+
function controlModeTakesOverTrigger(mode) {
|
|
1704
|
+
return mode !== PxControlMode.autoplay;
|
|
1705
|
+
}
|
|
1706
|
+
function resolveTrigger(trigger) {
|
|
1707
|
+
var _a2, _b, _c;
|
|
1708
|
+
return {
|
|
1709
|
+
startOn: (_a2 = trigger == null ? void 0 : trigger.startOn) != null ? _a2 : PX_TRIGGER_DEFAULTS.startOn,
|
|
1710
|
+
outAction: (_b = trigger == null ? void 0 : trigger.outAction) != null ? _b : PX_TRIGGER_DEFAULTS.outAction,
|
|
1711
|
+
scrollIntoViewThreshold: (_c = trigger == null ? void 0 : trigger.scrollIntoViewThreshold) != null ? _c : PX_TRIGGER_DEFAULTS.scrollIntoViewThreshold
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1542
1714
|
var PxLoopRepeatAt = {
|
|
1543
1715
|
/** Segment from the START; the repetition runs BEFORE the first keyframe
|
|
1544
1716
|
* (intro loops that play until the main timeline begins). */
|
|
@@ -1585,7 +1757,6 @@ var PxStrokeTrimSubPaths = {
|
|
|
1585
1757
|
separate: "separate",
|
|
1586
1758
|
combined: "combined"
|
|
1587
1759
|
};
|
|
1588
|
-
var TEXT_ATTR = "text";
|
|
1589
1760
|
var TEXT_CONTENT_ATTR = "textContent";
|
|
1590
1761
|
var CLASS_ATTR = "class";
|
|
1591
1762
|
var TRANSFORM_ATTR = "transform";
|
|
@@ -1597,7 +1768,6 @@ var INTERNAL_ATTRS = /* @__PURE__ */ new Set([
|
|
|
1597
1768
|
"meta",
|
|
1598
1769
|
"animate",
|
|
1599
1770
|
"effects",
|
|
1600
|
-
TEXT_ATTR,
|
|
1601
1771
|
TEXT_CONTENT_ATTR
|
|
1602
1772
|
]);
|
|
1603
1773
|
var TRANSFORM_PART = {
|
|
@@ -1612,10 +1782,6 @@ var PX_TRANSFORM_PART_KEYS = [
|
|
|
1612
1782
|
TRANSFORM_PART.scale,
|
|
1613
1783
|
TRANSFORM_PART.origin
|
|
1614
1784
|
];
|
|
1615
|
-
var PxGradientUnits = {
|
|
1616
|
-
userSpaceOnUse: "userSpaceOnUse",
|
|
1617
|
-
objectBoundingBox: "objectBoundingBox"
|
|
1618
|
-
};
|
|
1619
1785
|
var PxGradientSpreadMethod = {
|
|
1620
1786
|
pad: "pad",
|
|
1621
1787
|
reflect: "reflect",
|
|
@@ -1634,8 +1800,18 @@ function isPxElementFileFormat(fileJson) {
|
|
|
1634
1800
|
function getAnimatorConfig(doc) {
|
|
1635
1801
|
var _a2;
|
|
1636
1802
|
const cfg = (doc == null ? void 0 : doc.animator) || ((_a2 = doc == null ? void 0 : doc.meta) == null ? void 0 : _a2.animator);
|
|
1637
|
-
|
|
1638
|
-
|
|
1803
|
+
if (!cfg) return void 0;
|
|
1804
|
+
const memoised = wireViewMemo.get(cfg);
|
|
1805
|
+
if (memoised) return memoised;
|
|
1806
|
+
const wire = cfg;
|
|
1807
|
+
const stray = PX_FLAT_RUNTIME_VIEW_KEYS.filter((k) => wire[k] !== void 0);
|
|
1808
|
+
const source = stray.length ? __spreadValues({}, wire) : cfg;
|
|
1809
|
+
for (const k of stray) delete source[k];
|
|
1810
|
+
const view = flattenAnimatorTimeline(source);
|
|
1811
|
+
wireViewMemo.set(cfg, view);
|
|
1812
|
+
return view;
|
|
1813
|
+
}
|
|
1814
|
+
var wireViewMemo = /* @__PURE__ */ new WeakMap();
|
|
1639
1815
|
var flattenMemo = /* @__PURE__ */ new WeakMap();
|
|
1640
1816
|
function flattenAnimatorTimeline(cfg) {
|
|
1641
1817
|
const timeline = cfg.timeline;
|
|
@@ -1661,7 +1837,7 @@ function flattenAnimatorTimeline(cfg) {
|
|
|
1661
1837
|
else if (pin && typeof pin === "object") {
|
|
1662
1838
|
scroll.pin = true;
|
|
1663
1839
|
if (pin.align !== void 0) scroll.pinAlign = pin.align;
|
|
1664
|
-
if (pin.
|
|
1840
|
+
if (pin.offset !== void 0) scroll.pinOffset = pin.offset;
|
|
1665
1841
|
if (pin.distance !== void 0) scroll.pinDistance = pin.distance;
|
|
1666
1842
|
}
|
|
1667
1843
|
flat.scroll = scroll;
|
|
@@ -1722,9 +1898,9 @@ function nestAnimatorTimeline(cfg) {
|
|
|
1722
1898
|
if (scroll.subject !== void 0) timeline2.subject = scroll.subject;
|
|
1723
1899
|
if (scroll.smoothing !== void 0) timeline2.smoothing = scroll.smoothing;
|
|
1724
1900
|
if (scroll.range !== void 0) timeline2.range = scroll.range;
|
|
1725
|
-
const hasPinParams = scroll.pinAlign !== void 0 || scroll.
|
|
1901
|
+
const hasPinParams = scroll.pinAlign !== void 0 || scroll.pinOffset !== void 0 || scroll.pinDistance !== void 0;
|
|
1726
1902
|
if (hasPinParams) {
|
|
1727
|
-
timeline2.pin = __spreadValues(__spreadValues(__spreadValues({}, scroll.pinAlign !== void 0 ? { align: scroll.pinAlign } : {}), scroll.
|
|
1903
|
+
timeline2.pin = __spreadValues(__spreadValues(__spreadValues({}, scroll.pinAlign !== void 0 ? { align: scroll.pinAlign } : {}), scroll.pinOffset !== void 0 ? { offset: scroll.pinOffset } : {}), scroll.pinDistance !== void 0 ? { distance: scroll.pinDistance } : {});
|
|
1728
1904
|
} else if (scroll.pin !== void 0) {
|
|
1729
1905
|
timeline2.pin = scroll.pin;
|
|
1730
1906
|
}
|
|
@@ -1772,14 +1948,13 @@ var PxKeyframeValueSchema = implementsInterface()(px.union([
|
|
|
1772
1948
|
// e.g. for colors
|
|
1773
1949
|
px.number(),
|
|
1774
1950
|
px.array(px.number()),
|
|
1775
|
-
// ORDER LAW: the key-discriminated object
|
|
1951
|
+
// ORDER LAW: the key-discriminated object shape (`{pathData}`) comes BEFORE the
|
|
1776
1952
|
// all-optional transform-parts record. In default (non-strict) mode that record accepts
|
|
1777
1953
|
// ANY object (every key optional, unknown keys ignored), so listing it earlier made
|
|
1778
|
-
// Union.sanitize route `{
|
|
1954
|
+
// Union.sanitize route `{pathData}` values into it and strip them to `{}` —
|
|
1779
1955
|
// silent morph-data loss (repro: the editor's keyframeValueSanitize spec). Validity is
|
|
1780
1956
|
// order-independent (`some()`); only sanitize routing depends on this order.
|
|
1781
|
-
px.object({
|
|
1782
|
-
px.lazy(() => px.object({ paths: px.array(PxBezierPathSchema) }), { paths: [] }),
|
|
1957
|
+
px.object({ pathData: px.string() }),
|
|
1783
1958
|
// Gradient `stops` timeline — each kf value is the full stops-array snapshot.
|
|
1784
1959
|
px.lazy(() => px.array(PxGradientStopSchema), []),
|
|
1785
1960
|
px.lazy(() => PxTransformPartsSchema, {})
|
|
@@ -1819,7 +1994,7 @@ var PxPropertyAnimationSchema = implementsInterface()(px.object({
|
|
|
1819
1994
|
keyframes: px.array(PxKeyframeSchema).optional(),
|
|
1820
1995
|
loop: px.union([PxLoopSchema, px.boolean()]).optional(),
|
|
1821
1996
|
autoOrient: px.boolean().optional(),
|
|
1822
|
-
alongPathMode: px.enum([
|
|
1997
|
+
alongPathMode: px.enum([PxAlongPathMode.sampled, PxAlongPathMode.offsetPath]).optional()
|
|
1823
1998
|
}));
|
|
1824
1999
|
var PxTransformPartsSchema = implementsInterface()(px.object({
|
|
1825
2000
|
translate: px.tuple([px.number(), px.number()]).optional(),
|
|
@@ -1843,17 +2018,17 @@ var PxElementAnimationSchema = implementsInterface()(px.union([
|
|
|
1843
2018
|
PxAnimationDefinitionSchema
|
|
1844
2019
|
]));
|
|
1845
2020
|
var PxTriggerSchema = implementsInterface()(px.object({
|
|
1846
|
-
startOn: px.enum([
|
|
1847
|
-
outAction: px.enum([
|
|
2021
|
+
startOn: px.enum([PxStartOn.load, PxStartOn.mouseOver, PxStartOn.click, PxStartOn.scrollIntoView, PxStartOn.programmatic], PX_TRIGGER_DEFAULTS.startOn).optional(),
|
|
2022
|
+
outAction: px.enum([PxOutAction.continue, PxOutAction.pause, PxOutAction.reset, PxOutAction.reverse], PX_TRIGGER_DEFAULTS.outAction).optional(),
|
|
1848
2023
|
// What happens after a NATURAL finish — `'hold'` (default: keep the end state per
|
|
1849
2024
|
// `fill`) or `'reset'` (snap back to the start state). Pairs with `outAction` ("what
|
|
1850
2025
|
// happens when the trigger condition ends"); both end-of-life knobs now read alike.
|
|
1851
|
-
finishAction: px.enum([
|
|
2026
|
+
finishAction: px.enum([PxFinishAction.hold, PxFinishAction.reset]).optional(),
|
|
1852
2027
|
scrollIntoViewThreshold: px.number().optional()
|
|
1853
2028
|
}));
|
|
1854
2029
|
var PxGlyphSchema = implementsInterface()(px.object({
|
|
1855
2030
|
width: px.number(),
|
|
1856
|
-
|
|
2031
|
+
pathData: px.string()
|
|
1857
2032
|
}));
|
|
1858
2033
|
var PxGlyphFontSchema = implementsInterface()(px.object({
|
|
1859
2034
|
fontFamily: px.string(),
|
|
@@ -1870,9 +2045,15 @@ var PxDefsSchema = implementsInterface()(px.object({
|
|
|
1870
2045
|
styles: px.record(px.record(px.union([px.string(), px.number()]))).optional(),
|
|
1871
2046
|
fonts: px.record(PxGlyphFontSchema).optional()
|
|
1872
2047
|
}));
|
|
1873
|
-
var PX_SCROLL_PHASES = ["cover", "contain", "entry", "exit", "entry-crossing", "exit-crossing"];
|
|
1874
2048
|
var PxScrollRangePointSchema = implementsInterface()(px.object({
|
|
1875
|
-
phase: px.enum(
|
|
2049
|
+
phase: px.enum([
|
|
2050
|
+
PxScrollPhase.cover,
|
|
2051
|
+
PxScrollPhase.contain,
|
|
2052
|
+
PxScrollPhase.entry,
|
|
2053
|
+
PxScrollPhase.exit,
|
|
2054
|
+
PxScrollPhase.entryCrossing,
|
|
2055
|
+
PxScrollPhase.exitCrossing
|
|
2056
|
+
]).optional(),
|
|
1876
2057
|
fraction: px.number().optional()
|
|
1877
2058
|
}));
|
|
1878
2059
|
var PxScrollRangeSchema = px.object({
|
|
@@ -1880,21 +2061,21 @@ var PxScrollRangeSchema = px.object({
|
|
|
1880
2061
|
end: PxScrollRangePointSchema.optional()
|
|
1881
2062
|
});
|
|
1882
2063
|
var PxScrollSchema = implementsInterface()(px.object({
|
|
1883
|
-
kind: px.enum([
|
|
1884
|
-
axis: px.enum([
|
|
1885
|
-
source: px.enum([
|
|
2064
|
+
kind: px.enum([PxScrollKind.view, PxScrollKind.scroll]).optional(),
|
|
2065
|
+
axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y]).optional(),
|
|
2066
|
+
source: px.enum([PxScrollSource.nearest, PxScrollSource.root]).optional(),
|
|
1886
2067
|
// Free-form: the two keywords `parent`/`scroller` plus any CSS selector.
|
|
1887
2068
|
subject: px.string().optional(),
|
|
1888
2069
|
smoothing: px.number().optional(),
|
|
1889
2070
|
pin: px.boolean().optional(),
|
|
1890
|
-
pinAlign: px.enum([
|
|
1891
|
-
|
|
2071
|
+
pinAlign: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom]).optional(),
|
|
2072
|
+
pinOffset: px.number().optional(),
|
|
1892
2073
|
pinDistance: px.number().optional(),
|
|
1893
2074
|
range: PxScrollRangeSchema.optional()
|
|
1894
2075
|
}));
|
|
1895
2076
|
var PxTimelinePinSchema = implementsInterface()(px.object({
|
|
1896
|
-
align: px.enum([
|
|
1897
|
-
|
|
2077
|
+
align: px.enum([PxPinAlign.top, PxPinAlign.center, PxPinAlign.bottom]).optional(),
|
|
2078
|
+
offset: px.number().optional(),
|
|
1898
2079
|
distance: px.number().optional()
|
|
1899
2080
|
}));
|
|
1900
2081
|
var PxTimelineEngineSchema = px.enum([PxTimelineEngineExtra.auto, PxTimelineEngineExtra.native, PxTimelineEngineExtra.js]).optional();
|
|
@@ -1909,8 +2090,8 @@ var PxTimeTimelineSchema = implementsInterface()(px.object({
|
|
|
1909
2090
|
iterations: px.union([px.number(), px.literal("infinite")]).optional(),
|
|
1910
2091
|
// `fillMode` on the wire (CSS `animation-fill-mode`; the runtime view calls it `fill`)
|
|
1911
2092
|
// — never `fill`, which is paint everywhere else in the format.
|
|
1912
|
-
fillMode: px.enum([
|
|
1913
|
-
direction: px.enum([
|
|
2093
|
+
fillMode: px.enum([PxFillMode.forwards, PxFillMode.backwards, PxFillMode.both, PxFillMode.none]).optional(),
|
|
2094
|
+
direction: px.enum([PxPlaybackDirection.normal, PxPlaybackDirection.reverse, PxPlaybackDirection.alternate, PxPlaybackDirection.alternateReverse]).optional()
|
|
1914
2095
|
}));
|
|
1915
2096
|
var scrollishTimelineShape = {
|
|
1916
2097
|
// §2.8: duration is a property of the TIMELINE — under scrubbing it is the keyframe
|
|
@@ -1921,8 +2102,8 @@ var scrollishTimelineShape = {
|
|
|
1921
2102
|
iterations: px.number().optional(),
|
|
1922
2103
|
engine: PxTimelineEngineSchema,
|
|
1923
2104
|
frameRate: px.number().optional(),
|
|
1924
|
-
axis: px.enum([
|
|
1925
|
-
source: px.enum([
|
|
2105
|
+
axis: px.enum([PxScrollAxis.block, PxScrollAxis.inline, PxScrollAxis.x, PxScrollAxis.y]).optional(),
|
|
2106
|
+
source: px.enum([PxScrollSource.nearest, PxScrollSource.root]).optional(),
|
|
1926
2107
|
subject: px.string().optional(),
|
|
1927
2108
|
// 'parent' | 'scroller' | any CSS selector
|
|
1928
2109
|
smoothing: px.number().optional(),
|
|
@@ -2011,7 +2192,7 @@ var PxMaskedByEffectSchema = implementsInterface()(px.object({
|
|
|
2011
2192
|
height: px.number().optional()
|
|
2012
2193
|
}));
|
|
2013
2194
|
var PxClipPathEffectSchema = implementsInterface()(px.object({
|
|
2014
|
-
|
|
2195
|
+
pathData: PxAnimatableStringSchema.optional()
|
|
2015
2196
|
}));
|
|
2016
2197
|
var PxStrokeTrimEffectSchema = implementsInterface()(px.object({
|
|
2017
2198
|
offset: PxAnimatableNumberSchema.optional(),
|
|
@@ -2048,7 +2229,7 @@ var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
|
2048
2229
|
radius: PxAnimatableNumberSchema.optional(),
|
|
2049
2230
|
focal: PxAnimatableVec2Schema.optional(),
|
|
2050
2231
|
stops: PxAnimatableGradientStopsSchema.optional(),
|
|
2051
|
-
gradientUnits: px.enum([
|
|
2232
|
+
gradientUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
2052
2233
|
spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
|
|
2053
2234
|
gradientTransform: px.string().optional()
|
|
2054
2235
|
}));
|
|
@@ -2094,11 +2275,71 @@ function validateNodeEffects(root, opts) {
|
|
|
2094
2275
|
walk(root, "root");
|
|
2095
2276
|
return warnings;
|
|
2096
2277
|
}
|
|
2097
|
-
function
|
|
2098
|
-
|
|
2278
|
+
function validateGlyphFontRefs(root, fonts) {
|
|
2279
|
+
if (!fonts || !Object.keys(fonts).length) return [];
|
|
2280
|
+
const problems = [];
|
|
2281
|
+
const walk = (node, path, inherited, inGlyphText) => {
|
|
2282
|
+
var _a2, _b;
|
|
2283
|
+
if (!node) return;
|
|
2284
|
+
const own = typeof node.fontFamily === "string" ? node.fontFamily : void 0;
|
|
2285
|
+
const family = own != null ? own : inherited;
|
|
2286
|
+
const isGlyphText = inGlyphText || node.type === "text" && !!((_b = (_a2 = node.effects) == null ? void 0 : _a2.text) == null ? void 0 : _b.useGlyphs);
|
|
2287
|
+
if (isGlyphText && own && !Object.prototype.hasOwnProperty.call(fonts, own)) {
|
|
2288
|
+
const problem = path + ': glyph-mode text uses font-family "' + own + '", which has no entry in animator.definitions.fonts';
|
|
2289
|
+
if (!problems.includes(problem)) problems.push(problem);
|
|
2290
|
+
}
|
|
2291
|
+
if (Array.isArray(node.children)) {
|
|
2292
|
+
node.children.forEach((c, i) => walk(c, path + ".children[" + i + "]", family, isGlyphText));
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
walk(root, "root", void 0, false);
|
|
2296
|
+
return problems;
|
|
2297
|
+
}
|
|
2298
|
+
function validateEasingRefs(root, easings) {
|
|
2299
|
+
const problems = [];
|
|
2300
|
+
const walk = (node, path) => {
|
|
2301
|
+
if (Array.isArray(node)) {
|
|
2302
|
+
node.forEach((item, i) => walk(item, path + "[" + i + "]"));
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
if (!node || typeof node !== "object") return;
|
|
2306
|
+
const easing = node.easing;
|
|
2307
|
+
if (typeof easing === "string" && !(easings && Object.prototype.hasOwnProperty.call(easings, easing))) {
|
|
2308
|
+
const problem = path + '.easing: "' + easing + '" names no entry in animator.definitions.easings \u2014 it will play linear';
|
|
2309
|
+
if (!problems.includes(problem)) problems.push(problem);
|
|
2310
|
+
}
|
|
2311
|
+
for (const [key, value] of Object.entries(node)) {
|
|
2312
|
+
if (key === "easing") continue;
|
|
2313
|
+
if (value && typeof value === "object") walk(value, path + "." + key);
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2316
|
+
walk(root, "root");
|
|
2317
|
+
return problems;
|
|
2318
|
+
}
|
|
2319
|
+
function validateVersionStamp(doc) {
|
|
2320
|
+
var _a2;
|
|
2321
|
+
const version = (_a2 = getAnimatorConfig(doc)) == null ? void 0 : _a2.version;
|
|
2322
|
+
if (version === void 0) return [];
|
|
2323
|
+
if (parseWireVersion(version) !== void 0) return [];
|
|
2324
|
+
return ["root.animator.version: " + JSON.stringify(version) + ' is not a version stamp ("a.b" or "a.b.c") \u2014 it reads as unstamped'];
|
|
2325
|
+
}
|
|
2326
|
+
function validateDocument(doc, opts) {
|
|
2327
|
+
var _a2;
|
|
2328
|
+
const strict = (opts == null ? void 0 : opts.strict) !== false;
|
|
2329
|
+
const ctx = { errors: [], warnings: [], strict };
|
|
2099
2330
|
const problems = PxAnimatedSvgDocumentSchema.isValid(doc, ctx, ["root"]) ? [] : [...ctx.errors];
|
|
2100
2331
|
if (doc && typeof doc === "object") {
|
|
2101
|
-
for (const w of validateNodeEffects(doc, { strict
|
|
2332
|
+
for (const w of validateNodeEffects(doc, { strict })) {
|
|
2333
|
+
if (!problems.includes(w)) problems.push(w);
|
|
2334
|
+
}
|
|
2335
|
+
const defs = (_a2 = getAnimatorConfig(doc)) == null ? void 0 : _a2.definitions;
|
|
2336
|
+
for (const w of validateGlyphFontRefs(doc, defs == null ? void 0 : defs.fonts)) {
|
|
2337
|
+
if (!problems.includes(w)) problems.push(w);
|
|
2338
|
+
}
|
|
2339
|
+
for (const w of validateEasingRefs(doc, defs == null ? void 0 : defs.easings)) {
|
|
2340
|
+
if (!problems.includes(w)) problems.push(w);
|
|
2341
|
+
}
|
|
2342
|
+
for (const w of validateVersionStamp(doc)) {
|
|
2102
2343
|
if (!problems.includes(w)) problems.push(w);
|
|
2103
2344
|
}
|
|
2104
2345
|
}
|
|
@@ -2121,10 +2362,13 @@ var PxNodeBase = px.openObject({
|
|
|
2121
2362
|
// documented — because a wire key that is not in a schema is invisible to the
|
|
2122
2363
|
// minifier's reserve list and gets renamed (MINIFICATION-BOUNDARY-PLAN.md §1.1).
|
|
2123
2364
|
domType: px.string().optional(),
|
|
2365
|
+
// Text content of a `<text>` / `<tspan>`. Declared, so a non-string value is a schema error
|
|
2366
|
+
// and the minifier reserves the key; `text` is NOT an alias for it and is not read anywhere.
|
|
2367
|
+
textContent: px.string().optional(),
|
|
2124
2368
|
id: px.string().optional(),
|
|
2125
2369
|
meta: px.any().optional(),
|
|
2126
2370
|
// Player-effects bucket emitted by the Editor's lightweight design format.
|
|
2127
|
-
// Consumed and removed by `applyPlayerEffects` before any other
|
|
2371
|
+
// Consumed and removed by `applyPlayerEffects` before any other normalization
|
|
2128
2372
|
// (see `createAnimatorImpl`), so downstream code never sees it.
|
|
2129
2373
|
effects: PxEffectsSchema.optional(),
|
|
2130
2374
|
// `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
|
|
@@ -2156,8 +2400,8 @@ var PxBezierPathSchema = implementsInterface()(px.object({
|
|
|
2156
2400
|
c: px.boolean().optional()
|
|
2157
2401
|
}));
|
|
2158
2402
|
function isPxElementFileFormatDeep(fileJson) {
|
|
2159
|
-
const
|
|
2160
|
-
return { valid
|
|
2403
|
+
const errors = validateDocument(fileJson, { strict: false });
|
|
2404
|
+
return { valid: errors.length === 0, errors };
|
|
2161
2405
|
}
|
|
2162
2406
|
|
|
2163
2407
|
// src/util/PxIdUtil.ts
|
|
@@ -2316,7 +2560,7 @@ function isDangerousAttrName(nameLower) {
|
|
|
2316
2560
|
if (nameLower.startsWith("on")) return true;
|
|
2317
2561
|
return false;
|
|
2318
2562
|
}
|
|
2319
|
-
function
|
|
2563
|
+
function sanitizeAttributeValue(name, value) {
|
|
2320
2564
|
const nameLower = name.toLowerCase();
|
|
2321
2565
|
if (isDangerousAttrName(nameLower)) {
|
|
2322
2566
|
console.warn("Attribute blocked (event handler / dangerous): ", nameLower);
|
|
@@ -2355,7 +2599,7 @@ function getNormalizedProps(props) {
|
|
|
2355
2599
|
if (INTERNAL_ATTRS.has(key)) continue;
|
|
2356
2600
|
if (key === "style") continue;
|
|
2357
2601
|
let value = props[rawKey];
|
|
2358
|
-
if (
|
|
2602
|
+
if (COLOR_ATTR_NAMES.has(key) && Array.isArray(value)) {
|
|
2359
2603
|
propsCopy[key] = toRGBA(value);
|
|
2360
2604
|
} else if (key === "transform" && value !== null && typeof value === "object" && !Array.isArray(value) && !value.keyframes) {
|
|
2361
2605
|
const parts = value.value && typeof value.value === "object" ? value.value : value;
|
|
@@ -2376,7 +2620,7 @@ function getNormalizedProps(props) {
|
|
|
2376
2620
|
return propsCopy;
|
|
2377
2621
|
}
|
|
2378
2622
|
|
|
2379
|
-
// src/
|
|
2623
|
+
// src/materialize/PxMotionPath.ts
|
|
2380
2624
|
function getKfTranslate(kf) {
|
|
2381
2625
|
const v = kfValue(kf);
|
|
2382
2626
|
if (!v) return void 0;
|
|
@@ -2457,7 +2701,7 @@ function tFromArcFraction(lut, arcFrac) {
|
|
|
2457
2701
|
var DEFAULT_FLATNESS_TOL = 0.5;
|
|
2458
2702
|
var DEFAULT_ROTATION_TOL = 5;
|
|
2459
2703
|
var DEFAULT_MAX_SAMPLES = 32;
|
|
2460
|
-
function
|
|
2704
|
+
function materializeMotionPathInPropAnim(anim, opts) {
|
|
2461
2705
|
var _a2, _b, _c;
|
|
2462
2706
|
if (!propAnimIsMotionPath(anim)) return anim;
|
|
2463
2707
|
const kfs = anim.keyframes;
|
|
@@ -2489,7 +2733,7 @@ function materialiseMotionPathInPropAnim(anim, opts) {
|
|
|
2489
2733
|
if (autoOrient && i > 0) {
|
|
2490
2734
|
insertSharpCornerStepKfIfNeeded(out, prevKf, nextKf, prevPos, nextPos, rotationTol);
|
|
2491
2735
|
}
|
|
2492
|
-
|
|
2736
|
+
materializeSegment(out, prevKf, nextKf, prevPos, nextPos, autoOrient, flatnessTol, rotationTol, maxSamples);
|
|
2493
2737
|
}
|
|
2494
2738
|
const lastInE = getKfEasing(kfs[kfs.length - 1]);
|
|
2495
2739
|
if (lastInE) out[out.length - 1].e = lastInE;
|
|
@@ -2603,7 +2847,7 @@ function insertSharpCornerStepKfIfNeeded(out, prevKf, nextKf, prevPos, nextPos,
|
|
|
2603
2847
|
out.push(makeOutKf(stepTime, dupValue));
|
|
2604
2848
|
}
|
|
2605
2849
|
var CORNER_STEP_AFTER_BOUNDARY_MS = 0.05;
|
|
2606
|
-
function
|
|
2850
|
+
function materializeSegment(out, prevKf, nextKf, prevPos, nextPos, autoOrient, flatnessTol, rotationTol, maxSamples) {
|
|
2607
2851
|
const seg = getSegmentCache(prevKf, nextKf, prevPos, nextPos);
|
|
2608
2852
|
const prevTime = getKfTime(prevKf);
|
|
2609
2853
|
const nextTime = getKfTime(nextKf);
|
|
@@ -2726,16 +2970,16 @@ function perpDist(q, pA, pB) {
|
|
|
2726
2970
|
const cross = (q[0] - pA[0]) * dy - (q[1] - pA[1]) * dx;
|
|
2727
2971
|
return Math.abs(cross) / Math.sqrt(len2);
|
|
2728
2972
|
}
|
|
2729
|
-
function
|
|
2730
|
-
const out =
|
|
2973
|
+
function materializeMotionPathsInTree(root, opts) {
|
|
2974
|
+
const out = walkAndMaterialize(root, opts);
|
|
2731
2975
|
return out != null ? out : root;
|
|
2732
2976
|
}
|
|
2733
|
-
function
|
|
2977
|
+
function walkAndMaterialize(node, opts) {
|
|
2734
2978
|
let newChildren;
|
|
2735
2979
|
if (node.children) {
|
|
2736
2980
|
for (let i = 0; i < node.children.length; i++) {
|
|
2737
2981
|
const ch = node.children[i];
|
|
2738
|
-
const ret =
|
|
2982
|
+
const ret = walkAndMaterialize(ch, opts);
|
|
2739
2983
|
if (ret !== null) {
|
|
2740
2984
|
if (!newChildren) newChildren = node.children.slice();
|
|
2741
2985
|
newChildren[i] = ret;
|
|
@@ -2748,9 +2992,9 @@ function walkAndMaterialise(node, opts) {
|
|
|
2748
2992
|
const animDef = animBucket;
|
|
2749
2993
|
const transformAnim = animDef.transform;
|
|
2750
2994
|
if (transformAnim && typeof transformAnim === "object" && propAnimIsMotionPath(transformAnim)) {
|
|
2751
|
-
const
|
|
2752
|
-
if (
|
|
2753
|
-
newAnimate = __spreadProps(__spreadValues({}, animDef), { transform:
|
|
2995
|
+
const materialized = materializeMotionPathInPropAnim(transformAnim, opts);
|
|
2996
|
+
if (materialized !== transformAnim) {
|
|
2997
|
+
newAnimate = __spreadProps(__spreadValues({}, animDef), { transform: materialized });
|
|
2754
2998
|
}
|
|
2755
2999
|
}
|
|
2756
3000
|
}
|
|
@@ -2853,8 +3097,8 @@ function isPathString(value) {
|
|
|
2853
3097
|
return typeof value === "string" && extractPathData(value) !== void 0;
|
|
2854
3098
|
}
|
|
2855
3099
|
function normalizePathValue(value) {
|
|
2856
|
-
if (value && typeof value === "object" && typeof value.
|
|
2857
|
-
const d = extractPathData(value.
|
|
3100
|
+
if (value && typeof value === "object" && typeof value.pathData === "string") {
|
|
3101
|
+
const d = extractPathData(value.pathData);
|
|
2858
3102
|
return d ? { paths: parseSvgPathToBezier(d) } : value;
|
|
2859
3103
|
}
|
|
2860
3104
|
if (value && typeof value === "object" && "paths" in value) {
|
|
@@ -2938,7 +3182,7 @@ function interpolateValue(propName, a, b, t) {
|
|
|
2938
3182
|
const bPaths = (_b = b == null ? void 0 : b.paths) != null ? _b : Array.isArray(b) ? b : [];
|
|
2939
3183
|
return { paths: interpolateBeziers(aPaths, bPaths, t) };
|
|
2940
3184
|
}
|
|
2941
|
-
if (
|
|
3185
|
+
if (COLOR_ATTR_NAMES.has(propName)) {
|
|
2942
3186
|
return interpolateColor(a || [0, 0, 0, 1], b || [0, 0, 0, 1], t);
|
|
2943
3187
|
}
|
|
2944
3188
|
if (propName === "transform" && typeof a === "object" && a !== null && !Array.isArray(a) && typeof b === "object" && b !== null && !Array.isArray(b)) {
|
|
@@ -3160,7 +3404,7 @@ function normalizeKeyframes(propName, propAnim, duration, defs) {
|
|
|
3160
3404
|
value = normalizePathValue(value);
|
|
3161
3405
|
}
|
|
3162
3406
|
const propNameKebab = isCamelCaseWord(propName) ? camelCaseToKebabWordIfNeeded(propName) : propName;
|
|
3163
|
-
if (
|
|
3407
|
+
if (COLOR_ATTR_NAMES.has(propNameKebab)) {
|
|
3164
3408
|
value = (_a2 = parseColor(value)) != null ? _a2 : value;
|
|
3165
3409
|
}
|
|
3166
3410
|
const normKf = {
|
|
@@ -3194,20 +3438,20 @@ function mergeAnimationDefinitions(animations) {
|
|
|
3194
3438
|
}
|
|
3195
3439
|
return merged;
|
|
3196
3440
|
}
|
|
3197
|
-
function
|
|
3441
|
+
function materializeInternalLoopsInPropAnim(propName, propAnim, duration) {
|
|
3198
3442
|
const loopRaw = propAnim.loop;
|
|
3199
3443
|
if (loopRaw === void 0 || loopRaw === null || loopRaw === false) return propAnim;
|
|
3200
3444
|
const loop = loopRaw === true ? {} : loopRaw;
|
|
3201
3445
|
const rawKfs = propAnim.keyframes;
|
|
3202
3446
|
if (!Array.isArray(rawKfs) || rawKfs.length < 2) return propAnim;
|
|
3203
3447
|
const propNameKebab = isCamelCaseWord(propName) ? camelCaseToKebabWordIfNeeded(propName) : propName;
|
|
3204
|
-
const
|
|
3448
|
+
const isColor = COLOR_ATTR_NAMES.has(propNameKebab);
|
|
3205
3449
|
const kfs = rawKfs.map((kf) => {
|
|
3206
3450
|
var _a2;
|
|
3207
3451
|
const t = kfTime(kf);
|
|
3208
3452
|
let v = kfValue(kf);
|
|
3209
3453
|
if (propName === "d") v = normalizePathValue(v);
|
|
3210
|
-
if (
|
|
3454
|
+
if (isColor) v = (_a2 = parseColor(v)) != null ? _a2 : v;
|
|
3211
3455
|
const e = kfEasing(kf);
|
|
3212
3456
|
const out2 = { t, v, e };
|
|
3213
3457
|
const tIn = kfTangentIn(kf);
|
|
@@ -3221,15 +3465,15 @@ function materialiseInternalLoopsInPropAnim(propName, propAnim, duration) {
|
|
|
3221
3465
|
if (propAnim.autoOrient !== void 0) out.autoOrient = propAnim.autoOrient;
|
|
3222
3466
|
return out;
|
|
3223
3467
|
}
|
|
3224
|
-
function
|
|
3225
|
-
const ret =
|
|
3468
|
+
function materializeInternalLoopsInTree(root, duration) {
|
|
3469
|
+
const ret = walkAndMaterializeLoops(root, duration);
|
|
3226
3470
|
return ret != null ? ret : root;
|
|
3227
3471
|
}
|
|
3228
|
-
function
|
|
3472
|
+
function walkAndMaterializeLoops(node, duration) {
|
|
3229
3473
|
let newChildren;
|
|
3230
3474
|
if (node.children) {
|
|
3231
3475
|
for (let i = 0; i < node.children.length; i++) {
|
|
3232
|
-
const ret =
|
|
3476
|
+
const ret = walkAndMaterializeLoops(node.children[i], duration);
|
|
3233
3477
|
if (ret !== null) {
|
|
3234
3478
|
if (!newChildren) newChildren = node.children.slice();
|
|
3235
3479
|
newChildren[i] = ret;
|
|
@@ -3242,10 +3486,10 @@ function walkAndMaterialiseLoops(node, duration) {
|
|
|
3242
3486
|
const animDef = animBucket;
|
|
3243
3487
|
for (const propName of Object.keys(animDef)) {
|
|
3244
3488
|
const propAnim = animDef[propName];
|
|
3245
|
-
const
|
|
3246
|
-
if (
|
|
3489
|
+
const materialized = materializeInternalLoopsInPropAnim(propName, propAnim, duration);
|
|
3490
|
+
if (materialized !== propAnim) {
|
|
3247
3491
|
if (!newAnimate) newAnimate = __spreadValues({}, animDef);
|
|
3248
|
-
newAnimate[propName] =
|
|
3492
|
+
newAnimate[propName] = materialized;
|
|
3249
3493
|
}
|
|
3250
3494
|
}
|
|
3251
3495
|
}
|
|
@@ -3300,12 +3544,12 @@ function normalizeAnimationDefinition(animDef, duration, defs, engine = PxTimeli
|
|
|
3300
3544
|
const out = { keyframes: normalizedKfs };
|
|
3301
3545
|
if (propAnim.autoOrient !== void 0) out.autoOrient = propAnim.autoOrient;
|
|
3302
3546
|
if (propAnim.loop !== void 0) out.loop = propAnim.loop;
|
|
3303
|
-
normalized[propName] = engine === PxTimelineEngine.native && propName === "transform" ?
|
|
3547
|
+
normalized[propName] = engine === PxTimelineEngine.native && propName === "transform" ? materializeMotionPathInPropAnim(out) : out;
|
|
3304
3548
|
}
|
|
3305
3549
|
}
|
|
3306
3550
|
return normalized;
|
|
3307
3551
|
}
|
|
3308
|
-
function
|
|
3552
|
+
function getNormalizedBindings(doc, engine = PxTimelineEngine.native) {
|
|
3309
3553
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
3310
3554
|
const defs = getDefs(doc);
|
|
3311
3555
|
const duration = animatorConfig.duration || 1e3;
|
|
@@ -3396,7 +3640,7 @@ function calcPropertyValue(propName, propAnim, progress) {
|
|
|
3396
3640
|
nextPaths,
|
|
3397
3641
|
localProgress
|
|
3398
3642
|
).map((bz) => bezierToSvgPath(bz)).join("");
|
|
3399
|
-
} else if (
|
|
3643
|
+
} else if (COLOR_ATTR_NAMES.has(cssAttrName)) {
|
|
3400
3644
|
cssValue = toRGBA(interpolateColor(
|
|
3401
3645
|
prevV || [0, 0, 0, 1],
|
|
3402
3646
|
nextV || [0, 0, 0, 1],
|
|
@@ -3557,8 +3801,8 @@ function applyUseOffsetToG(gNode) {
|
|
|
3557
3801
|
return gNode;
|
|
3558
3802
|
}
|
|
3559
3803
|
|
|
3560
|
-
// src/
|
|
3561
|
-
function
|
|
3804
|
+
// src/materialize/PxAnimatorUseMaterializer.ts
|
|
3805
|
+
function materializeAnimatedUseInstances(root) {
|
|
3562
3806
|
var _a2;
|
|
3563
3807
|
const idMap = buildIdMap(root);
|
|
3564
3808
|
const animatedIds = computeAnimatedSubtreeIds(root, idMap);
|
|
@@ -3567,7 +3811,7 @@ function materialiseAnimatedUseInstances(root) {
|
|
|
3567
3811
|
const genId3 = () => "_lw_use_mat_" + ++idCounter;
|
|
3568
3812
|
const rootViewport = readRootViewport(root);
|
|
3569
3813
|
const defsCollector = [];
|
|
3570
|
-
const walked =
|
|
3814
|
+
const walked = walkAndMaterialize2(root, idMap, animatedIds, genId3, defsCollector, rootViewport);
|
|
3571
3815
|
if (defsCollector.length === 0) return walked;
|
|
3572
3816
|
const defsNode = { type: "defs", children: defsCollector };
|
|
3573
3817
|
const newChildren = [...(_a2 = walked.children) != null ? _a2 : [], defsNode];
|
|
@@ -3640,7 +3884,7 @@ function stripHash(href) {
|
|
|
3640
3884
|
if (typeof href !== "string") return void 0;
|
|
3641
3885
|
return href.startsWith("#") ? href.slice(1) : href;
|
|
3642
3886
|
}
|
|
3643
|
-
function
|
|
3887
|
+
function materializeOneUse(useNode, target, idMap, animatedIds, genId3, defsCollector, rootViewport) {
|
|
3644
3888
|
var _a2, _b, _c, _d;
|
|
3645
3889
|
const clone2 = deepClonePxNode(target);
|
|
3646
3890
|
regenerateIdsAndRewriteRefs(clone2, genId3);
|
|
@@ -3648,8 +3892,8 @@ function materialiseOneUse(useNode, target, idMap, animatedIds, genId3, defsColl
|
|
|
3648
3892
|
const useW = (_b = (_a2 = numericAttr(useNode.width)) != null ? _a2 : symbolViewBox == null ? void 0 : symbolViewBox[2]) != null ? _b : rootViewport[0];
|
|
3649
3893
|
const useH = (_d = (_c = numericAttr(useNode.height)) != null ? _c : symbolViewBox == null ? void 0 : symbolViewBox[3]) != null ? _d : rootViewport[1];
|
|
3650
3894
|
const rewrittenClone = clone2.type === "symbol" ? rewriteSymbolRootToGroup(clone2, genId3, defsCollector, useW, useH) : clone2;
|
|
3651
|
-
const
|
|
3652
|
-
const newNode = __spreadProps(__spreadValues({}, useNode), { type: "g", children: [
|
|
3895
|
+
const materializedClone = walkAndMaterialize2(rewrittenClone, idMap, animatedIds, genId3, defsCollector, rootViewport);
|
|
3896
|
+
const newNode = __spreadProps(__spreadValues({}, useNode), { type: "g", children: [materializedClone] });
|
|
3653
3897
|
delete newNode.href;
|
|
3654
3898
|
delete newNode.width;
|
|
3655
3899
|
delete newNode.height;
|
|
@@ -3687,18 +3931,18 @@ function parseViewBox(v) {
|
|
|
3687
3931
|
if (parts.length < 4 || parts.some((n) => !Number.isFinite(n))) return void 0;
|
|
3688
3932
|
return [parts[0], parts[1], parts[2], parts[3]];
|
|
3689
3933
|
}
|
|
3690
|
-
function
|
|
3934
|
+
function walkAndMaterialize2(node, idMap, animatedIds, genId3, defsCollector, rootViewport) {
|
|
3691
3935
|
if (node.type === "use" && typeof node.href === "string") {
|
|
3692
3936
|
const targetId = stripHash(node.href);
|
|
3693
3937
|
if (targetId && animatedIds.has(targetId)) {
|
|
3694
3938
|
const target = idMap.get(targetId);
|
|
3695
|
-
if (target) return
|
|
3939
|
+
if (target) return materializeOneUse(node, target, idMap, animatedIds, genId3, defsCollector, rootViewport);
|
|
3696
3940
|
}
|
|
3697
3941
|
}
|
|
3698
3942
|
if (!node.children) return node;
|
|
3699
3943
|
let changed = false;
|
|
3700
3944
|
const newChildren = node.children.map((ch) => {
|
|
3701
|
-
const m =
|
|
3945
|
+
const m = walkAndMaterialize2(ch, idMap, animatedIds, genId3, defsCollector, rootViewport);
|
|
3702
3946
|
if (m !== ch) changed = true;
|
|
3703
3947
|
return m;
|
|
3704
3948
|
});
|
|
@@ -3723,7 +3967,7 @@ function readAnimatable(raw) {
|
|
|
3723
3967
|
const obj = raw;
|
|
3724
3968
|
const kfs = obj.keyframes;
|
|
3725
3969
|
if (kfs) {
|
|
3726
|
-
const out = { kind: "animated" /* Animated */, keyframes: kfs.map(
|
|
3970
|
+
const out = { kind: "animated" /* Animated */, keyframes: kfs.map(normalizeKeyframe), autoOrient: obj.autoOrient, loop: obj.loop };
|
|
3727
3971
|
const base = (_a2 = obj.value) != null ? _a2 : obj.v;
|
|
3728
3972
|
if (base !== void 0 && out.kind === "animated" /* Animated */) out.base = base;
|
|
3729
3973
|
return out;
|
|
@@ -3751,7 +3995,7 @@ function writeAnimatableChannel(node, attrName, read, opts) {
|
|
|
3751
3995
|
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;
|
|
3752
3996
|
if (baseline !== void 0) node[attrName] = toOut(baseline);
|
|
3753
3997
|
}
|
|
3754
|
-
function
|
|
3998
|
+
function normalizeKeyframe(kf) {
|
|
3755
3999
|
if (!kf || typeof kf !== "object") return kf;
|
|
3756
4000
|
const k = kf;
|
|
3757
4001
|
if (k.t === void 0 && k.v === void 0 && k.e === void 0 && k.to === void 0 && k.ti === void 0) {
|
|
@@ -4263,10 +4507,10 @@ function formatOffset(o) {
|
|
|
4263
4507
|
|
|
4264
4508
|
// src/effects/clipping/clipPathEffect.ts
|
|
4265
4509
|
function applyClipPathEffect(node, fx, ctx) {
|
|
4266
|
-
if (!(fx == null ? void 0 : fx.
|
|
4510
|
+
if (!(fx == null ? void 0 : fx.pathData)) return node;
|
|
4267
4511
|
const clipId = genId(ctx, "clip");
|
|
4268
4512
|
const pathChild = { type: "path" };
|
|
4269
|
-
const read = readAnimatable(fx.
|
|
4513
|
+
const read = readAnimatable(fx.pathData);
|
|
4270
4514
|
if (read.kind !== "absent" /* Absent */) {
|
|
4271
4515
|
if (read.kind === "static" /* Static */) {
|
|
4272
4516
|
pathChild.d = pathString(read.value);
|
|
@@ -4281,7 +4525,7 @@ function applyClipPathEffect(node, fx, ctx) {
|
|
|
4281
4525
|
}
|
|
4282
4526
|
function pathString(v) {
|
|
4283
4527
|
if (typeof v === "string") return v;
|
|
4284
|
-
if (v && typeof v === "object" && typeof v.
|
|
4528
|
+
if (v && typeof v === "object" && typeof v.pathData === "string") return v.pathData;
|
|
4285
4529
|
return void 0;
|
|
4286
4530
|
}
|
|
4287
4531
|
|
|
@@ -4328,8 +4572,8 @@ function wrapInverseTransform(inner, fx, ctx) {
|
|
|
4328
4572
|
}
|
|
4329
4573
|
function wrapInversePart(inner, part, raw, origin, ctx) {
|
|
4330
4574
|
if (raw === void 0) return inner;
|
|
4331
|
-
const
|
|
4332
|
-
const v = readAnimatable(
|
|
4575
|
+
const normalizedRaw = part === "scale" /* Scale */ && Array.isArray(raw) ? [raw[0] / 100, raw[1] / 100] : raw;
|
|
4576
|
+
const v = readAnimatable(normalizedRaw);
|
|
4333
4577
|
if (v.kind === "static" /* Static */) {
|
|
4334
4578
|
return { type: "g", transform: { value: partsRecord(part, invertPartValue(part, v.value), origin) }, children: [inner] };
|
|
4335
4579
|
}
|
|
@@ -4730,7 +4974,7 @@ function synthesiseScale(raw, i) {
|
|
|
4730
4974
|
}
|
|
4731
4975
|
|
|
4732
4976
|
// src/effects/reference/retimeEffect.ts
|
|
4733
|
-
var
|
|
4977
|
+
var RETIME_MATERIALIZATION_MODE_INLINE_G = false;
|
|
4734
4978
|
function asRetime(r) {
|
|
4735
4979
|
var _a2, _b;
|
|
4736
4980
|
return { start: (_a2 = r.start) != null ? _a2 : 0, stretch: (_b = r.stretch) != null ? _b : 1 };
|
|
@@ -4815,11 +5059,11 @@ function applyAllRetimeEffects(root, ctx) {
|
|
|
4815
5059
|
if (!retime) continue;
|
|
4816
5060
|
const crop = retime.timeCrop;
|
|
4817
5061
|
clearCloneRetime(useNode);
|
|
4818
|
-
|
|
5062
|
+
materializeRetime(useNode, asRetime(retime), ctx);
|
|
4819
5063
|
if (crop) applyTimeCrop(useNode, crop, ctx);
|
|
4820
5064
|
}
|
|
4821
5065
|
}
|
|
4822
|
-
function
|
|
5066
|
+
function materializeRetime(useNode, retime, ctx) {
|
|
4823
5067
|
const targetId = stripHash2(useNode.href);
|
|
4824
5068
|
if (!targetId) {
|
|
4825
5069
|
ctx.errors.push("retime: <use> has no href to follow");
|
|
@@ -4827,7 +5071,7 @@ function materialiseRetime(useNode, retime, ctx) {
|
|
|
4827
5071
|
}
|
|
4828
5072
|
const chainRootId = buildChainClone(targetId, retime, ctx, /* @__PURE__ */ new Set());
|
|
4829
5073
|
if (!chainRootId) return;
|
|
4830
|
-
if (
|
|
5074
|
+
if (RETIME_MATERIALIZATION_MODE_INLINE_G) {
|
|
4831
5075
|
const cloneNode = ctx.idMap.get(chainRootId);
|
|
4832
5076
|
useNode.type = "g";
|
|
4833
5077
|
delete useNode.href;
|
|
@@ -4867,13 +5111,13 @@ function buildChainClone(targetId, accum, ctx, chain) {
|
|
|
4867
5111
|
if (subId2) cloneNode.href = "#" + subId2;
|
|
4868
5112
|
}
|
|
4869
5113
|
} else {
|
|
4870
|
-
|
|
5114
|
+
materializeNestedRetimeUses(cloneNode, accum, ctx, chain, targetId);
|
|
4871
5115
|
}
|
|
4872
5116
|
ctx.defs.push(cloneNode);
|
|
4873
5117
|
if (typeof cloneNode.id === "string") ctx.idMap.set(cloneNode.id, cloneNode);
|
|
4874
5118
|
return typeof cloneNode.id === "string" ? cloneNode.id : void 0;
|
|
4875
5119
|
}
|
|
4876
|
-
function
|
|
5120
|
+
function materializeNestedRetimeUses(node, accum, ctx, chain, parentTargetId) {
|
|
4877
5121
|
const visit = (n) => {
|
|
4878
5122
|
var _a2;
|
|
4879
5123
|
const retime = readCloneRetime(n);
|
|
@@ -5074,10 +5318,10 @@ function numRange(v) {
|
|
|
5074
5318
|
function estimateTextAdvance(node) {
|
|
5075
5319
|
let chars = 0, maxFont = 16;
|
|
5076
5320
|
const walk = (el) => {
|
|
5077
|
-
var _a2
|
|
5321
|
+
var _a2;
|
|
5078
5322
|
const fs = parseFloat(String((_a2 = el.fontSize) != null ? _a2 : "")) || 0;
|
|
5079
5323
|
if (fs) maxFont = Math.max(maxFont, fs);
|
|
5080
|
-
const t =
|
|
5324
|
+
const t = el.textContent;
|
|
5081
5325
|
if (typeof t === "string") chars += t.length;
|
|
5082
5326
|
if (el.children) for (const c of el.children) walk(c);
|
|
5083
5327
|
};
|
|
@@ -5232,7 +5476,6 @@ var TEXT_ATTR_KEYS = [
|
|
|
5232
5476
|
"stroke",
|
|
5233
5477
|
"strokeWidth",
|
|
5234
5478
|
"effects",
|
|
5235
|
-
TEXT_ATTR,
|
|
5236
5479
|
TEXT_CONTENT_ATTR,
|
|
5237
5480
|
"xml:space"
|
|
5238
5481
|
];
|
|
@@ -5342,8 +5585,8 @@ function missingGlyphBoxEm(advanceEm, ascentEm) {
|
|
|
5342
5585
|
const ix0 = x0 + t, ix1 = x1 - t, iyb = -t, iyt = y1 + t;
|
|
5343
5586
|
return outer + "M" + ix0 + " " + iyb + "L" + ix0 + " " + iyt + "L" + ix1 + " " + iyt + "L" + ix1 + " " + iyb + "Z";
|
|
5344
5587
|
}
|
|
5345
|
-
function
|
|
5346
|
-
var _a2, _b, _c
|
|
5588
|
+
function materializeGlyphTextHorizontal(node, opts) {
|
|
5589
|
+
var _a2, _b, _c;
|
|
5347
5590
|
const { glyphs, create = jsonElementFactory, warnings } = opts;
|
|
5348
5591
|
const soleFont = soleFontOf(glyphs);
|
|
5349
5592
|
const pen = { x: (_a2 = parseLen(node.x)) != null ? _a2 : 0, y: (_b = parseLen(node.y)) != null ? _b : 0 };
|
|
@@ -5360,8 +5603,8 @@ function materialiseGlyphTextHorizontal(node, opts) {
|
|
|
5360
5603
|
for (let i = 0; i < content.length; i++) {
|
|
5361
5604
|
const ch = content.charAt(i);
|
|
5362
5605
|
const g = gf == null ? void 0 : gf.glyphs[ch];
|
|
5363
|
-
if (g && g.
|
|
5364
|
-
placements.push({ glyphD: g.
|
|
5606
|
+
if (g && g.pathData) {
|
|
5607
|
+
placements.push({ glyphD: g.pathData, m: [scale, 0, 0, scale, pen.x, pen.y], paint, line, x: pen.x, y: pen.y, scale });
|
|
5365
5608
|
pen.x += g.width * scale;
|
|
5366
5609
|
} else if (/\S/.test(ch)) {
|
|
5367
5610
|
const advEm = g && g.width > 0 ? g.width : MISSING_GLYPH_ADVANCE_EM * upm;
|
|
@@ -5375,7 +5618,7 @@ function materialiseGlyphTextHorizontal(node, opts) {
|
|
|
5375
5618
|
}
|
|
5376
5619
|
};
|
|
5377
5620
|
const walk = (el, parentStyle) => {
|
|
5378
|
-
var _a3, _b2, _c2
|
|
5621
|
+
var _a3, _b2, _c2;
|
|
5379
5622
|
const s = resolveStyle2(el, parentStyle);
|
|
5380
5623
|
const x = parseLen(el.x);
|
|
5381
5624
|
const y = parseLen(el.y);
|
|
@@ -5387,14 +5630,14 @@ function materialiseGlyphTextHorizontal(node, opts) {
|
|
|
5387
5630
|
if (y !== void 0) pen.y = y;
|
|
5388
5631
|
pen.x += (_a3 = parseLen(el.dx)) != null ? _a3 : 0;
|
|
5389
5632
|
pen.y += (_b2 = parseLen(el.dy)) != null ? _b2 : 0;
|
|
5390
|
-
const content =
|
|
5391
|
-
if (content && !((
|
|
5633
|
+
const content = str(el[TEXT_CONTENT_ATTR]);
|
|
5634
|
+
if (content && !((_c2 = el.children) == null ? void 0 : _c2.length)) renderChars(content, s);
|
|
5392
5635
|
if (el.children) for (const ch of el.children) walk(ch, s);
|
|
5393
5636
|
};
|
|
5394
5637
|
const rootStyle = rootStyleOf(node);
|
|
5395
5638
|
if (node.children) for (const ch of node.children) walk(ch, rootStyle);
|
|
5396
|
-
const rootContent =
|
|
5397
|
-
if (rootContent && !((
|
|
5639
|
+
const rootContent = str(node[TEXT_CONTENT_ATTR]);
|
|
5640
|
+
if (rootContent && !((_c = node.children) == null ? void 0 : _c.length)) renderChars(rootContent, rootStyle);
|
|
5398
5641
|
const anchor = str(node.textAnchor);
|
|
5399
5642
|
if (anchor === "middle" || anchor === "end") {
|
|
5400
5643
|
for (const p of placements) {
|
|
@@ -5406,7 +5649,7 @@ function materialiseGlyphTextHorizontal(node, opts) {
|
|
|
5406
5649
|
return toGroup(node, buildPaths(placements, create, warnings), create);
|
|
5407
5650
|
}
|
|
5408
5651
|
function layoutGlyphTextChars(node, opts) {
|
|
5409
|
-
var _a2, _b, _c, _d, _e
|
|
5652
|
+
var _a2, _b, _c, _d, _e;
|
|
5410
5653
|
if ((_a2 = opts.alongPath) == null ? void 0 : _a2.pathD) return layoutGlyphTextCharsAlongPath(node, opts.alongPath.pathD, opts);
|
|
5411
5654
|
const { glyphs, warnings } = opts;
|
|
5412
5655
|
const soleFont = soleFontOf(glyphs);
|
|
@@ -5430,7 +5673,7 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
5430
5673
|
}
|
|
5431
5674
|
};
|
|
5432
5675
|
const walk = (el, parentStyle) => {
|
|
5433
|
-
var _a3, _b2, _c2
|
|
5676
|
+
var _a3, _b2, _c2;
|
|
5434
5677
|
const s = resolveStyle2(el, parentStyle);
|
|
5435
5678
|
const x = parseLen(el.x);
|
|
5436
5679
|
const y = parseLen(el.y);
|
|
@@ -5442,8 +5685,8 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
5442
5685
|
if (y !== void 0) pen.y = y;
|
|
5443
5686
|
pen.x += (_a3 = parseLen(el.dx)) != null ? _a3 : 0;
|
|
5444
5687
|
pen.y += (_b2 = parseLen(el.dy)) != null ? _b2 : 0;
|
|
5445
|
-
const content =
|
|
5446
|
-
if (content && !((
|
|
5688
|
+
const content = str(el[TEXT_CONTENT_ATTR]);
|
|
5689
|
+
if (content && !((_c2 = el.children) == null ? void 0 : _c2.length)) renderChars(content, s);
|
|
5447
5690
|
if (el.children) for (const ch of el.children) walk(ch, s);
|
|
5448
5691
|
};
|
|
5449
5692
|
const rootStyle = rootStyleOf(node);
|
|
@@ -5457,8 +5700,8 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
5457
5700
|
boxes.push({ x: pen.x, y: pen.y, width: 0, ascent: ((_d = gf == null ? void 0 : gf.ascent) != null ? _d : 0.9 * upm) * (s.fontSize / upm), fontSize: s.fontSize, line });
|
|
5458
5701
|
}
|
|
5459
5702
|
}
|
|
5460
|
-
const rootContent =
|
|
5461
|
-
if (rootContent && !((
|
|
5703
|
+
const rootContent = str(node[TEXT_CONTENT_ATTR]);
|
|
5704
|
+
if (rootContent && !((_e = node.children) == null ? void 0 : _e.length)) renderChars(rootContent, rootStyle);
|
|
5462
5705
|
const anchor = str(node.textAnchor);
|
|
5463
5706
|
if (anchor === "middle" || anchor === "end") {
|
|
5464
5707
|
for (const b of boxes) {
|
|
@@ -5466,8 +5709,8 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
5466
5709
|
b.x += anchor === "middle" ? -w / 2 : -w;
|
|
5467
5710
|
}
|
|
5468
5711
|
}
|
|
5469
|
-
return boxes.map((
|
|
5470
|
-
var
|
|
5712
|
+
return boxes.map((_f) => {
|
|
5713
|
+
var _g = _f, { line: _l } = _g, b = __objRest(_g, ["line"]);
|
|
5471
5714
|
return b;
|
|
5472
5715
|
});
|
|
5473
5716
|
}
|
|
@@ -5483,14 +5726,14 @@ function layoutGlyphTextCharsAlongPath(node, pathD, opts) {
|
|
|
5483
5726
|
const chars = [];
|
|
5484
5727
|
let adv = 0;
|
|
5485
5728
|
const walk = (el, parentStyle) => {
|
|
5486
|
-
var _a3, _b2
|
|
5729
|
+
var _a3, _b2;
|
|
5487
5730
|
const s = resolveStyle2(el, parentStyle);
|
|
5488
|
-
const content =
|
|
5489
|
-
if (content && !((
|
|
5731
|
+
const content = str(el[TEXT_CONTENT_ATTR]);
|
|
5732
|
+
if (content && !((_a3 = el.children) == null ? void 0 : _a3.length)) {
|
|
5490
5733
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
5491
5734
|
const upm = (gf == null ? void 0 : gf.unitsPerEm) || 1e3;
|
|
5492
5735
|
const scale = s.fontSize / upm;
|
|
5493
|
-
const ascent = ((
|
|
5736
|
+
const ascent = ((_b2 = gf == null ? void 0 : gf.ascent) != null ? _b2 : 0.9 * upm) * scale;
|
|
5494
5737
|
for (let i = 0; i < content.length; i++) {
|
|
5495
5738
|
const ch = content.charAt(i);
|
|
5496
5739
|
const g = gf == null ? void 0 : gf.glyphs[ch];
|
|
@@ -5537,21 +5780,21 @@ function collectAlongPathCells(node, glyphs, soleFont, warnings) {
|
|
|
5537
5780
|
const cells = [];
|
|
5538
5781
|
let adv = 0;
|
|
5539
5782
|
const walk = (el, parentStyle) => {
|
|
5540
|
-
var _a2, _b
|
|
5783
|
+
var _a2, _b;
|
|
5541
5784
|
const s = resolveStyle2(el, parentStyle);
|
|
5542
|
-
const content =
|
|
5543
|
-
if (content && !((
|
|
5785
|
+
const content = str(el[TEXT_CONTENT_ATTR]);
|
|
5786
|
+
if (content && !((_a2 = el.children) == null ? void 0 : _a2.length)) {
|
|
5544
5787
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
5545
5788
|
if (gf) {
|
|
5546
5789
|
const scale = s.fontSize / gf.unitsPerEm;
|
|
5547
|
-
const ascentEm = (
|
|
5790
|
+
const ascentEm = (_b = gf.ascent) != null ? _b : 0.9 * gf.unitsPerEm;
|
|
5548
5791
|
const paint = paintOf(s);
|
|
5549
5792
|
for (let i = 0; i < content.length; i++) {
|
|
5550
5793
|
const ch = content.charAt(i);
|
|
5551
5794
|
const g = gf.glyphs[ch];
|
|
5552
|
-
if (g && g.
|
|
5795
|
+
if (g && g.pathData) {
|
|
5553
5796
|
const glyphAdv = g.width * scale;
|
|
5554
|
-
cells.push({ glyphD: g.
|
|
5797
|
+
cells.push({ glyphD: g.pathData, widthEm: g.width, scale, paint, midBase: adv + glyphAdv / 2 });
|
|
5555
5798
|
adv += glyphAdv;
|
|
5556
5799
|
} else if (/\S/.test(ch)) {
|
|
5557
5800
|
const wEm = g && g.width > 0 ? g.width : MISSING_GLYPH_ADVANCE_EM * gf.unitsPerEm;
|
|
@@ -5582,7 +5825,7 @@ function alongPathNodeOffsets(node) {
|
|
|
5582
5825
|
perp: (_c = parseLen(node.dy)) != null ? _c : 0
|
|
5583
5826
|
};
|
|
5584
5827
|
}
|
|
5585
|
-
function
|
|
5828
|
+
function materializeGlyphTextAlongPath(node, pathD, startOffset, opts, textLength, pathOverflow) {
|
|
5586
5829
|
const { glyphs, create = jsonElementFactory, warnings } = opts;
|
|
5587
5830
|
const sampler = pathD ? createPathSampler(pathD) : null;
|
|
5588
5831
|
if (!sampler) {
|
|
@@ -5661,8 +5904,8 @@ function buildAnimatedAlongPath(cells, sampler, distOf, times, loop, create, isC
|
|
|
5661
5904
|
const onPath = (dist) => dist >= 0 && dist <= sampler.totalLength;
|
|
5662
5905
|
const out = [];
|
|
5663
5906
|
for (const c of cells) {
|
|
5664
|
-
const
|
|
5665
|
-
const d = transformPathData(c.glyphD,
|
|
5907
|
+
const centered = [c.scale, 0, 0, c.scale, -c.scale * (c.widthEm / 2), 0];
|
|
5908
|
+
const d = transformPathData(c.glyphD, centered);
|
|
5666
5909
|
const sampleKf = (dist, time) => {
|
|
5667
5910
|
const { x, y, angle } = sampler.sampleAtDistance(dist);
|
|
5668
5911
|
const cos = Math.cos(angle), sin = Math.sin(angle);
|
|
@@ -5754,9 +5997,9 @@ function toGroup(node, children, create) {
|
|
|
5754
5997
|
}
|
|
5755
5998
|
return create("g", gProps, children);
|
|
5756
5999
|
}
|
|
5757
|
-
function
|
|
5758
|
-
if (opts.alongPath) return
|
|
5759
|
-
return
|
|
6000
|
+
function materializeGlyphText(node, opts) {
|
|
6001
|
+
if (opts.alongPath) return materializeGlyphTextAlongPath(node, opts.alongPath.pathD, opts.alongPath.startOffset, opts, opts.alongPath.textLength, opts.alongPath.pathOverflow);
|
|
6002
|
+
return materializeGlyphTextHorizontal(node, opts);
|
|
5760
6003
|
}
|
|
5761
6004
|
function applyTextGlyphsEffect(node, fx, ctx) {
|
|
5762
6005
|
if (!(fx == null ? void 0 : fx.useGlyphs)) return node;
|
|
@@ -5764,14 +6007,14 @@ function applyTextGlyphsEffect(node, fx, ctx) {
|
|
|
5764
6007
|
ctx.warnings.push("textGlyphs: no definitions.fonts \u2014 left as native <text>");
|
|
5765
6008
|
return node;
|
|
5766
6009
|
}
|
|
5767
|
-
return
|
|
6010
|
+
return materializeGlyphTextHorizontal(node, { glyphs: ctx.glyphs, warnings: ctx.warnings });
|
|
5768
6011
|
}
|
|
5769
6012
|
function applyTextGlyphsAlongPath(node, ctx, pathD, startOffset, textLength, pathOverflow) {
|
|
5770
6013
|
if (!ctx.glyphs) {
|
|
5771
6014
|
ctx.warnings.push("textGlyphs: no definitions.fonts");
|
|
5772
6015
|
return null;
|
|
5773
6016
|
}
|
|
5774
|
-
return
|
|
6017
|
+
return materializeGlyphTextAlongPath(node, pathD, startOffset, { glyphs: ctx.glyphs, warnings: ctx.warnings }, textLength, pathOverflow);
|
|
5775
6018
|
}
|
|
5776
6019
|
|
|
5777
6020
|
// src/effects/stroke/strokeTrimEffect.ts
|
|
@@ -6173,7 +6416,7 @@ function applyPlayerEffects_retime(node, ctx) {
|
|
|
6173
6416
|
return node;
|
|
6174
6417
|
}
|
|
6175
6418
|
|
|
6176
|
-
// src/
|
|
6419
|
+
// src/materialize/PxOffsetPathMaterializer.ts
|
|
6177
6420
|
function cubicAt(p0, c1, c2, p1, t) {
|
|
6178
6421
|
const u = 1 - t;
|
|
6179
6422
|
const a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;
|
|
@@ -6239,7 +6482,7 @@ function buildOffsetPath(propAnim) {
|
|
|
6239
6482
|
}
|
|
6240
6483
|
return { pathStr: d, distanceKfs, autoOrient: !!propAnim.autoOrient, anchor };
|
|
6241
6484
|
}
|
|
6242
|
-
function
|
|
6485
|
+
function materializeOffsetPathsInTree(root) {
|
|
6243
6486
|
const walk = (node) => {
|
|
6244
6487
|
var _a2;
|
|
6245
6488
|
let out = node;
|
|
@@ -6283,16 +6526,16 @@ function materialiseOffsetPathsInTree(root) {
|
|
|
6283
6526
|
return walk(root);
|
|
6284
6527
|
}
|
|
6285
6528
|
|
|
6286
|
-
// src/
|
|
6287
|
-
function
|
|
6529
|
+
// src/materialize/PxAnimatorMaterializeAll.ts
|
|
6530
|
+
function materializeAllInTree(doc, engine, opts) {
|
|
6288
6531
|
var _a2, _b;
|
|
6289
6532
|
let root = applyPlayerEffects(doc).root;
|
|
6290
|
-
root =
|
|
6533
|
+
root = materializeOffsetPathsInTree(root);
|
|
6291
6534
|
const duration = (_b = (_a2 = getAnimatorConfig(root)) == null ? void 0 : _a2.duration) != null ? _b : DEFAULT_DURATION_MS;
|
|
6292
|
-
root =
|
|
6535
|
+
root = materializeInternalLoopsInTree(root, duration);
|
|
6293
6536
|
if (engine === PxTimelineEngine.native) {
|
|
6294
|
-
root =
|
|
6295
|
-
root =
|
|
6537
|
+
root = materializeMotionPathsInTree(root, opts == null ? void 0 : opts.motionPath);
|
|
6538
|
+
root = materializeAnimatedUseInstances(root);
|
|
6296
6539
|
root = pruneUnreferencedDefs(root);
|
|
6297
6540
|
}
|
|
6298
6541
|
return root;
|
|
@@ -6327,6 +6570,66 @@ function pruneUnreferencedDefs(root) {
|
|
|
6327
6570
|
return root;
|
|
6328
6571
|
}
|
|
6329
6572
|
|
|
6573
|
+
// src/playback/PxPlaybackTime.ts
|
|
6574
|
+
var PX_RATE_REJECTED = "setPlaybackRate: rate must be finite and non-zero";
|
|
6575
|
+
function isValidPlaybackRate(rate) {
|
|
6576
|
+
return Number.isFinite(rate) && rate !== 0;
|
|
6577
|
+
}
|
|
6578
|
+
function seekCeilingMs(durationMs, iterations) {
|
|
6579
|
+
if (!(durationMs > 0)) return 0;
|
|
6580
|
+
if (iterations === Infinity) return Infinity;
|
|
6581
|
+
return durationMs * (iterations > 0 ? iterations : 1);
|
|
6582
|
+
}
|
|
6583
|
+
function progressSpanMs(durationMs, iterations) {
|
|
6584
|
+
if (!(durationMs > 0)) return 0;
|
|
6585
|
+
if (iterations === Infinity) return durationMs;
|
|
6586
|
+
return durationMs * (iterations > 0 ? iterations : 1);
|
|
6587
|
+
}
|
|
6588
|
+
function clampSeekMs(timeMs, ceilingMs) {
|
|
6589
|
+
if (Number.isNaN(timeMs) || timeMs < 0) return 0;
|
|
6590
|
+
if (Number.isFinite(ceilingMs)) return timeMs > ceilingMs ? ceilingMs : timeMs;
|
|
6591
|
+
return Number.isFinite(timeMs) ? timeMs : 0;
|
|
6592
|
+
}
|
|
6593
|
+
function timeToProgress(timeMs, durationMs, iterations) {
|
|
6594
|
+
const span = progressSpanMs(durationMs, iterations);
|
|
6595
|
+
if (!(span > 0) || !Number.isFinite(timeMs)) return 0;
|
|
6596
|
+
if (timeMs <= 0) return 0;
|
|
6597
|
+
if (iterations === Infinity) return timeMs % span / span;
|
|
6598
|
+
return timeMs >= span ? 1 : timeMs / span;
|
|
6599
|
+
}
|
|
6600
|
+
function progressToTimeMs(progress, durationMs, iterations) {
|
|
6601
|
+
const span = progressSpanMs(durationMs, iterations);
|
|
6602
|
+
if (!(span > 0) || !Number.isFinite(progress)) return 0;
|
|
6603
|
+
if (progress <= 0) return 0;
|
|
6604
|
+
return progress >= 1 ? span : progress * span;
|
|
6605
|
+
}
|
|
6606
|
+
function createRunClock(ceilingMs, nowFn = Date.now) {
|
|
6607
|
+
let baseMs = 0;
|
|
6608
|
+
let startedAt = 0;
|
|
6609
|
+
let running = false;
|
|
6610
|
+
let rate = 1;
|
|
6611
|
+
const value = () => running ? clampSeekMs(baseMs + (nowFn() - startedAt) * rate, ceilingMs) : clampSeekMs(baseMs, ceilingMs);
|
|
6612
|
+
return {
|
|
6613
|
+
now: value,
|
|
6614
|
+
isRunning: () => running,
|
|
6615
|
+
start: (r, atMs) => {
|
|
6616
|
+
baseMs = clampSeekMs(atMs != null ? atMs : value(), ceilingMs);
|
|
6617
|
+
rate = isValidPlaybackRate(r) ? r : 1;
|
|
6618
|
+
startedAt = nowFn();
|
|
6619
|
+
running = true;
|
|
6620
|
+
},
|
|
6621
|
+
stop: () => {
|
|
6622
|
+
baseMs = value();
|
|
6623
|
+
startedAt = 0;
|
|
6624
|
+
running = false;
|
|
6625
|
+
},
|
|
6626
|
+
seek: (ms) => {
|
|
6627
|
+
baseMs = clampSeekMs(ms, ceilingMs);
|
|
6628
|
+
if (running) startedAt = nowFn();
|
|
6629
|
+
}
|
|
6630
|
+
};
|
|
6631
|
+
}
|
|
6632
|
+
|
|
6330
6633
|
// src/playback/PxFrameLoop.ts
|
|
6331
6634
|
function requestFrame(cb) {
|
|
6332
6635
|
const g = globalThis;
|
|
@@ -6344,7 +6647,7 @@ function cancelFrame(handle) {
|
|
|
6344
6647
|
function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
6345
6648
|
var _a2;
|
|
6346
6649
|
const config = getAnimatorConfig(doc) || {};
|
|
6347
|
-
const bindings =
|
|
6650
|
+
const bindings = getNormalizedBindings(doc, PxTimelineEngine.js);
|
|
6348
6651
|
const _iterations = config.iterations;
|
|
6349
6652
|
let iterations = 1;
|
|
6350
6653
|
if (typeof _iterations === "number") iterations = _iterations || 1;
|
|
@@ -6574,8 +6877,8 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
6574
6877
|
finishAnim(true);
|
|
6575
6878
|
},
|
|
6576
6879
|
"setPlaybackRate": (rate) => {
|
|
6577
|
-
if (!
|
|
6578
|
-
console.warn(
|
|
6880
|
+
if (!isValidPlaybackRate(rate)) {
|
|
6881
|
+
console.warn(PX_RATE_REJECTED);
|
|
6579
6882
|
return;
|
|
6580
6883
|
}
|
|
6581
6884
|
let current = getRawAnimTime();
|
|
@@ -6589,13 +6892,16 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
6589
6892
|
return getAnimCurrentTime();
|
|
6590
6893
|
},
|
|
6591
6894
|
"setCurrentTime": (newTime) => {
|
|
6592
|
-
|
|
6593
|
-
if (Number.isFinite(totalDuration) && newTime > totalDuration) newTime = totalDuration;
|
|
6895
|
+
newTime = clampSeekMs(newTime, totalDuration);
|
|
6594
6896
|
timeBeforeLastStartMs = newTime;
|
|
6595
6897
|
if (playing) lastStartedTs = Date.now();
|
|
6596
6898
|
if (!Number.isFinite(totalDuration) || newTime < totalDuration) finishCalled = false;
|
|
6597
6899
|
renderFrame(getAnimCurrentTime());
|
|
6598
6900
|
},
|
|
6901
|
+
"getCurrentProgress": () => timeToProgress(getAnimCurrentTime(), duration, iterations),
|
|
6902
|
+
"setCurrentProgress": (progress) => {
|
|
6903
|
+
api.setCurrentTime(progressToTimeMs(progress, duration, iterations));
|
|
6904
|
+
},
|
|
6599
6905
|
"destroy": () => {
|
|
6600
6906
|
var _a3;
|
|
6601
6907
|
api.cancel();
|
|
@@ -6605,6 +6911,51 @@ function createBasicFrameLoopAnimator(doc, adapter, callbacks) {
|
|
|
6605
6911
|
return api;
|
|
6606
6912
|
}
|
|
6607
6913
|
|
|
6914
|
+
// src/playback/PxDiagnostics.ts
|
|
6915
|
+
var PxDiagnosticKind = {
|
|
6916
|
+
/** The document is wrong — regenerate or repair the file. */
|
|
6917
|
+
document: "document",
|
|
6918
|
+
/** The page or app cannot provide what the document asks for — fix the mount. */
|
|
6919
|
+
host: "host",
|
|
6920
|
+
/** The platform cannot do it and the player degraded — usually nothing to fix. */
|
|
6921
|
+
platform: "platform",
|
|
6922
|
+
/** The call is wrong or self-contradictory — fix the options or props you passed. */
|
|
6923
|
+
usage: "usage",
|
|
6924
|
+
/** The player failed where it did not expect to — report it to us. */
|
|
6925
|
+
internal: "internal"
|
|
6926
|
+
};
|
|
6927
|
+
function asError(error) {
|
|
6928
|
+
return typeof error === "string" ? new Error(error) : error;
|
|
6929
|
+
}
|
|
6930
|
+
function isSilenced(silent, kind) {
|
|
6931
|
+
if (!silent) return false;
|
|
6932
|
+
return silent === true || silent.includes(kind);
|
|
6933
|
+
}
|
|
6934
|
+
function createDiagnostics(config, prefix) {
|
|
6935
|
+
const tag = prefix ? prefix + " " : "";
|
|
6936
|
+
return {
|
|
6937
|
+
warn: (kind, message, detail) => {
|
|
6938
|
+
if (config == null ? void 0 : config.onWarn) {
|
|
6939
|
+
config.onWarn({ kind, message, detail });
|
|
6940
|
+
return;
|
|
6941
|
+
}
|
|
6942
|
+
if (isSilenced(config == null ? void 0 : config.silent, kind)) return;
|
|
6943
|
+
const line = tag + kind + ": " + message;
|
|
6944
|
+
if (detail === void 0) console.warn(line);
|
|
6945
|
+
else console.warn(line, detail);
|
|
6946
|
+
},
|
|
6947
|
+
error: (kind, error) => {
|
|
6948
|
+
const err = asError(error);
|
|
6949
|
+
if (config == null ? void 0 : config.onError) {
|
|
6950
|
+
config.onError({ kind, message: err.message, error: err });
|
|
6951
|
+
return;
|
|
6952
|
+
}
|
|
6953
|
+
if (isSilenced(config == null ? void 0 : config.silent, kind)) return;
|
|
6954
|
+
console.error(tag + kind + ": " + err.message);
|
|
6955
|
+
}
|
|
6956
|
+
};
|
|
6957
|
+
}
|
|
6958
|
+
|
|
6608
6959
|
// src/effects/PlayerEffectsUtil.visualModel.ts
|
|
6609
6960
|
var IDENTITY = [1, 0, 0, 1, 0, 0];
|
|
6610
6961
|
function mul(m, n) {
|
|
@@ -6877,32 +7228,30 @@ function mergeTimeline(base, patch, warn) {
|
|
|
6877
7228
|
}
|
|
6878
7229
|
return merged;
|
|
6879
7230
|
}
|
|
6880
|
-
function
|
|
7231
|
+
function foldTimelineOverride(timeline, shortcuts) {
|
|
6881
7232
|
let base;
|
|
6882
|
-
if (typeof
|
|
7233
|
+
if (typeof timeline === "string") {
|
|
6883
7234
|
try {
|
|
6884
|
-
base = JSON.parse(
|
|
7235
|
+
base = JSON.parse(timeline);
|
|
6885
7236
|
} catch (e) {
|
|
6886
|
-
console.warn("
|
|
7237
|
+
console.warn("timeline override: not valid JSON \u2014 ignored", e);
|
|
6887
7238
|
base = void 0;
|
|
6888
7239
|
}
|
|
6889
7240
|
} else {
|
|
6890
|
-
base =
|
|
7241
|
+
base = timeline != null ? timeline : void 0;
|
|
6891
7242
|
}
|
|
6892
7243
|
const { duration, delay, iterations, startOn } = shortcuts;
|
|
6893
7244
|
if (duration === void 0 && delay === void 0 && iterations === void 0 && startOn === void 0) {
|
|
6894
|
-
return base;
|
|
7245
|
+
return base === void 0 ? void 0 : { timeline: base };
|
|
6895
7246
|
}
|
|
6896
7247
|
const out = isPlainObject(base) ? __spreadValues({}, base) : {};
|
|
6897
|
-
|
|
6898
|
-
if (
|
|
6899
|
-
if (
|
|
6900
|
-
if (iterations !== void 0) timeline.iterations = iterations;
|
|
7248
|
+
if (duration !== void 0) out.duration = duration;
|
|
7249
|
+
if (delay !== void 0) out.delay = delay;
|
|
7250
|
+
if (iterations !== void 0) out.iterations = iterations;
|
|
6901
7251
|
if (startOn !== void 0) {
|
|
6902
|
-
|
|
7252
|
+
out.trigger = __spreadProps(__spreadValues({}, out.trigger), { startOn });
|
|
6903
7253
|
}
|
|
6904
|
-
|
|
6905
|
-
return out;
|
|
7254
|
+
return { timeline: out };
|
|
6906
7255
|
}
|
|
6907
7256
|
function mergeAnimatorConfig(base, patch) {
|
|
6908
7257
|
const warnings = [];
|
|
@@ -6970,26 +7319,12 @@ function applyAnimatorConfig(doc, patch, opts) {
|
|
|
6970
7319
|
|
|
6971
7320
|
// src/format/PxDocumentDiagnostic.ts
|
|
6972
7321
|
var MAX_REPORTED = 6;
|
|
6973
|
-
var LEGACY_FLAT_KEYS = [
|
|
6974
|
-
...PX_TIMELINE_SHARED_KEYS,
|
|
6975
|
-
...PX_TIME_ONLY_TIMELINE_KEYS,
|
|
6976
|
-
"fill",
|
|
6977
|
-
"resetOnFinish",
|
|
6978
|
-
"timelineSource",
|
|
6979
|
-
"scroll"
|
|
6980
|
-
];
|
|
6981
|
-
var isLegacyFlatAnimatorKey = (w) => LEGACY_FLAT_KEYS.some((k) => w.indexOf("animator." + k + ":") >= 0);
|
|
6982
7322
|
function diagnoseDocument(doc) {
|
|
6983
|
-
let all;
|
|
6984
7323
|
try {
|
|
6985
|
-
|
|
7324
|
+
return { problems: validateDocument(doc) };
|
|
6986
7325
|
} catch (e) {
|
|
6987
|
-
return { problems: []
|
|
7326
|
+
return { problems: [] };
|
|
6988
7327
|
}
|
|
6989
|
-
const problems = [];
|
|
6990
|
-
const legacy = [];
|
|
6991
|
-
for (const w of all) (isLegacyFlatAnimatorKey(w) ? legacy : problems).push(w);
|
|
6992
|
-
return { problems, legacy };
|
|
6993
7328
|
}
|
|
6994
7329
|
function reportDocumentDiagnostics(doc, where) {
|
|
6995
7330
|
const { problems } = diagnoseDocument(doc);
|
|
@@ -7003,7 +7338,7 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7003
7338
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7004
7339
|
0 && (module.exports = {
|
|
7005
7340
|
BASELINE_PLAYER_VERSION,
|
|
7006
|
-
|
|
7341
|
+
COLOR_ATTR_NAMES,
|
|
7007
7342
|
CSS_ONLY_STYLE_PROPS,
|
|
7008
7343
|
DEFAULT_DURATION_MS,
|
|
7009
7344
|
DISALLOWED_SVG_TAGS_LOWER,
|
|
@@ -7016,45 +7351,65 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7016
7351
|
PX_ANIM_ATTR_NAME,
|
|
7017
7352
|
PX_ANIM_SRC_ATTR_NAME,
|
|
7018
7353
|
PX_PLAYER_SCHEMA_VERSION,
|
|
7354
|
+
PX_RATE_REJECTED,
|
|
7019
7355
|
PX_TRANSFORM_PART_KEYS,
|
|
7356
|
+
PX_TRIGGER_DEFAULTS,
|
|
7020
7357
|
PX_UNKNOWN_KEY_ERROR,
|
|
7358
|
+
PxAlongPathMode,
|
|
7021
7359
|
PxAnimatedSvgDocumentSchema,
|
|
7022
7360
|
PxAnimationDefinitionSchema,
|
|
7023
7361
|
PxAnimatorConfigSchema,
|
|
7024
7362
|
PxAttrValueSchema,
|
|
7025
7363
|
PxBezierPathSchema,
|
|
7026
7364
|
PxBindingSchema,
|
|
7365
|
+
PxClipPathEffectSchema,
|
|
7027
7366
|
PxCloneEffectSchema,
|
|
7028
7367
|
PxCloneWithout,
|
|
7368
|
+
PxControlMode,
|
|
7029
7369
|
PxDefsSchema,
|
|
7370
|
+
PxDiagnosticKind,
|
|
7030
7371
|
PxEasingOrRefSchema,
|
|
7031
7372
|
PxEffectsSchema,
|
|
7032
7373
|
PxElementAnimationSchema,
|
|
7033
7374
|
PxFillGradientEffectSchema,
|
|
7375
|
+
PxFillMode,
|
|
7376
|
+
PxFinishAction,
|
|
7034
7377
|
PxGradientSpreadMethod,
|
|
7035
7378
|
PxGradientStopSchema,
|
|
7036
7379
|
PxGradientType,
|
|
7037
|
-
PxGradientUnits,
|
|
7038
7380
|
PxKeyframeSchema,
|
|
7039
7381
|
PxKeyframeValueSchema,
|
|
7382
|
+
PxLengthAdjust,
|
|
7040
7383
|
PxLoopDirection,
|
|
7041
7384
|
PxLoopRepeatAt,
|
|
7042
7385
|
PxLoopSchema,
|
|
7386
|
+
PxMaskType,
|
|
7043
7387
|
PxMaskedByEffectSchema,
|
|
7044
7388
|
PxNodeBase,
|
|
7045
7389
|
PxNodeSchema,
|
|
7390
|
+
PxOutAction,
|
|
7391
|
+
PxPathOverflow,
|
|
7392
|
+
PxPinAlign,
|
|
7393
|
+
PxPlaybackDirection,
|
|
7046
7394
|
PxPropertyAnimationSchema,
|
|
7047
7395
|
PxRepeaterEffectSchema,
|
|
7048
7396
|
PxRetimeEffectSchema,
|
|
7397
|
+
PxScrollAxis,
|
|
7398
|
+
PxScrollKind,
|
|
7399
|
+
PxScrollPhase,
|
|
7049
7400
|
PxScrollRangePointSchema,
|
|
7050
7401
|
PxScrollRangeSchema,
|
|
7051
7402
|
PxScrollSchema,
|
|
7403
|
+
PxScrollSource,
|
|
7404
|
+
PxStartOn,
|
|
7052
7405
|
PxStrokeGradientEffectSchema,
|
|
7053
7406
|
PxStrokeTrimEffectSchema,
|
|
7054
7407
|
PxStrokeTrimSubPaths,
|
|
7055
7408
|
PxSvgNodeExtra,
|
|
7056
7409
|
PxTextEffectSchema,
|
|
7057
7410
|
PxTextPathEffectSchema,
|
|
7411
|
+
PxTextPathMethod,
|
|
7412
|
+
PxTextPathSpacing,
|
|
7058
7413
|
PxTimelineEngine,
|
|
7059
7414
|
PxTimelineEngineExtra,
|
|
7060
7415
|
PxTimelinePinSchema,
|
|
@@ -7063,8 +7418,8 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7063
7418
|
PxTransformPartsSchema,
|
|
7064
7419
|
PxTransformValueSchema,
|
|
7065
7420
|
PxTriggerSchema,
|
|
7421
|
+
PxUnits,
|
|
7066
7422
|
STYLE_ATTR_NAMES,
|
|
7067
|
-
TEXT_ATTR,
|
|
7068
7423
|
TEXT_CONTENT_ATTR,
|
|
7069
7424
|
TRANSFORM_FN_NAMES,
|
|
7070
7425
|
WIRE_VERSION_KEY,
|
|
@@ -7078,12 +7433,16 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7078
7433
|
calcAnimationValues,
|
|
7079
7434
|
camelCaseToKebabWordIfNeeded,
|
|
7080
7435
|
clamp,
|
|
7436
|
+
clampSeekMs,
|
|
7081
7437
|
collectSampleTimes,
|
|
7082
7438
|
compareWireVersion,
|
|
7083
7439
|
composeTransformParts,
|
|
7440
|
+
controlModeTakesOverTrigger,
|
|
7084
7441
|
convertPlayerDocument,
|
|
7085
7442
|
createBasicFrameLoopAnimator,
|
|
7443
|
+
createDiagnostics,
|
|
7086
7444
|
createPathSampler,
|
|
7445
|
+
createRunClock,
|
|
7087
7446
|
cubicBezier,
|
|
7088
7447
|
deepClone,
|
|
7089
7448
|
describeSchema,
|
|
@@ -7094,7 +7453,7 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7094
7453
|
evaluateMotionPathSegment,
|
|
7095
7454
|
extendedPathForBrowser,
|
|
7096
7455
|
flattenAnimatorTimeline,
|
|
7097
|
-
|
|
7456
|
+
foldTimelineOverride,
|
|
7098
7457
|
formatWireVersion,
|
|
7099
7458
|
generateNewIds,
|
|
7100
7459
|
generateUniqueId,
|
|
@@ -7102,7 +7461,7 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7102
7461
|
getBindings,
|
|
7103
7462
|
getChildren,
|
|
7104
7463
|
getDefs,
|
|
7105
|
-
|
|
7464
|
+
getNormalizedBindings,
|
|
7106
7465
|
getNormalizedProps,
|
|
7107
7466
|
interpolateBeziers,
|
|
7108
7467
|
interpolateValue,
|
|
@@ -7110,6 +7469,7 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7110
7469
|
isPxElementFileFormat,
|
|
7111
7470
|
isPxElementFileFormatDeep,
|
|
7112
7471
|
isScrollTimeline,
|
|
7472
|
+
isValidPlaybackRate,
|
|
7113
7473
|
jsonElementFactory,
|
|
7114
7474
|
kebabToCamelCaseWord,
|
|
7115
7475
|
kfEasing,
|
|
@@ -7118,15 +7478,15 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7118
7478
|
kfTime,
|
|
7119
7479
|
kfValue,
|
|
7120
7480
|
layoutGlyphTextChars,
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7481
|
+
materializeAllInTree,
|
|
7482
|
+
materializeAnimatedUseInstances,
|
|
7483
|
+
materializeGlyphText,
|
|
7484
|
+
materializeGlyphTextAlongPath,
|
|
7485
|
+
materializeGlyphTextHorizontal,
|
|
7486
|
+
materializeInternalLoopsInPropAnim,
|
|
7487
|
+
materializeInternalLoopsInTree,
|
|
7488
|
+
materializeMotionPathInPropAnim,
|
|
7489
|
+
materializeMotionPathsInTree,
|
|
7130
7490
|
mayUseNativeScrollTimeline,
|
|
7131
7491
|
mergeAnimatorConfig,
|
|
7132
7492
|
mergeStaticTransformIntoAnimDef,
|
|
@@ -7134,15 +7494,19 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7134
7494
|
parseTransformParts,
|
|
7135
7495
|
parseWireVersion,
|
|
7136
7496
|
planSchemaRelease,
|
|
7497
|
+
progressSpanMs,
|
|
7498
|
+
progressToTimeMs,
|
|
7137
7499
|
propAnimIsMotionPath,
|
|
7138
7500
|
px,
|
|
7139
7501
|
readWireVersion,
|
|
7140
7502
|
releaseLogProblems,
|
|
7141
7503
|
reportDocumentDiagnostics,
|
|
7504
|
+
resolveControlMode,
|
|
7142
7505
|
resolveStyle,
|
|
7143
7506
|
resolveTimelineEngine,
|
|
7507
|
+
resolveTrigger,
|
|
7144
7508
|
reverseEasing,
|
|
7145
|
-
|
|
7509
|
+
sanitizeAttributeValue,
|
|
7146
7510
|
schemaFieldUniverse,
|
|
7147
7511
|
schemaKeys,
|
|
7148
7512
|
scrollOffsetProgress,
|
|
@@ -7150,9 +7514,11 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
7150
7514
|
scrollResolveAxis,
|
|
7151
7515
|
scrollTotalDurationMs,
|
|
7152
7516
|
scrollViewProgress,
|
|
7517
|
+
seekCeilingMs,
|
|
7153
7518
|
shiftAnimatable,
|
|
7154
7519
|
splitEasing,
|
|
7155
7520
|
subdivideCubicBezier,
|
|
7521
|
+
timeToProgress,
|
|
7156
7522
|
toRGBA,
|
|
7157
7523
|
validateDocument,
|
|
7158
7524
|
validateNodeEffects,
|