@pixodesk/svg-animator-core 1.0.40 → 1.0.43
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 +58 -13
- package/dist/{internal-BZSJtt_h.d.ts → PxDocumentDiagnostic-DkBZYJ7X.d.cts} +227 -462
- package/dist/{internal-BZSJtt_h.d.cts → PxDocumentDiagnostic-DkBZYJ7X.d.ts} +227 -462
- package/dist/{chunk-PAE3NF2U.js → chunk-BOTZI36B.js} +183 -580
- package/dist/chunk-BOTZI36B.js.map +1 -0
- package/dist/chunk-CAZFG2HW.min.js +1 -0
- package/dist/index.cjs +240 -926
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.js +117 -175
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/dist/internal.cjs +93 -91
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +378 -1
- package/dist/internal.d.ts +378 -1
- package/dist/internal.js +413 -34
- package/dist/internal.js.map +1 -1
- package/dist/internal.min.cjs +1 -1
- package/dist/internal.min.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-PAE3NF2U.js.map +0 -1
- package/dist/chunk-WIVGJ5YO.min.js +0 -1
|
@@ -545,7 +545,7 @@ var px = {
|
|
|
545
545
|
* The base can be the result of px.object() or px.openObject() — anything with a _shape property.
|
|
546
546
|
*
|
|
547
547
|
* @example
|
|
548
|
-
* const PxSvgNodeSchema = px.extendedObject(
|
|
548
|
+
* const PxSvgNodeSchema = px.extendedObject(PxNodeBaseSchema, { width: px.number().optional() });
|
|
549
549
|
*/
|
|
550
550
|
extendedObject: (base, extra) => new Obj(__spreadValues(__spreadValues({}, base._shape), extra)),
|
|
551
551
|
/** Array whose unrecoverable items are filtered out. Default: []. */
|
|
@@ -563,20 +563,20 @@ var px = {
|
|
|
563
563
|
};
|
|
564
564
|
|
|
565
565
|
// src/version/PxSchemaVersion.ts
|
|
566
|
-
var
|
|
566
|
+
var PX_WIRE_SCHEMA_VERSION = "1.1";
|
|
567
567
|
|
|
568
568
|
// src/version/PxWireVersion.ts
|
|
569
|
-
var
|
|
569
|
+
var PX_WIRE_VERSION_KEY = "version";
|
|
570
570
|
var ANIMATOR_KEY = "animator";
|
|
571
571
|
var META_KEY = "meta";
|
|
572
|
-
var
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
return
|
|
579
|
-
})(
|
|
572
|
+
var PxWireVersionRelation = /* @__PURE__ */ ((PxWireVersionRelation2) => {
|
|
573
|
+
PxWireVersionRelation2["unstamped"] = "unstamped";
|
|
574
|
+
PxWireVersionRelation2["same"] = "same";
|
|
575
|
+
PxWireVersionRelation2["older"] = "older";
|
|
576
|
+
PxWireVersionRelation2["newer"] = "newer";
|
|
577
|
+
PxWireVersionRelation2["otherGeneration"] = "otherGeneration";
|
|
578
|
+
return PxWireVersionRelation2;
|
|
579
|
+
})(PxWireVersionRelation || {});
|
|
580
580
|
var VERSION_RE = /^(\d+)\.(\d+)(?:\.(\d+))?$/;
|
|
581
581
|
function parseWireVersion(raw) {
|
|
582
582
|
if (typeof raw !== "string") return void 0;
|
|
@@ -588,7 +588,7 @@ function formatWireVersion(v) {
|
|
|
588
588
|
return v.a + "." + v.b + "." + v.c;
|
|
589
589
|
}
|
|
590
590
|
var _a;
|
|
591
|
-
var
|
|
591
|
+
var PX_WIRE_VERSION = (_a = parseWireVersion(PX_WIRE_SCHEMA_VERSION)) != null ? _a : { a: 1, b: 1, c: 0 };
|
|
592
592
|
function getAnimatorBlock(doc) {
|
|
593
593
|
if (!doc || typeof doc !== "object") return void 0;
|
|
594
594
|
const atRoot = readObjectProp(doc, ANIMATOR_KEY);
|
|
@@ -602,7 +602,7 @@ function readObjectProp(obj, key) {
|
|
|
602
602
|
}
|
|
603
603
|
function readWireVersion(doc) {
|
|
604
604
|
const animator = getAnimatorBlock(doc);
|
|
605
|
-
return animator ? parseWireVersion(animator[
|
|
605
|
+
return animator ? parseWireVersion(animator[PX_WIRE_VERSION_KEY]) : void 0;
|
|
606
606
|
}
|
|
607
607
|
function compareWireVersion(file, mine, readerReadsEditorPart) {
|
|
608
608
|
if (!file) return "unstamped" /* unstamped */;
|
|
@@ -611,7 +611,7 @@ function compareWireVersion(file, mine, readerReadsEditorPart) {
|
|
|
611
611
|
if (!readerReadsEditorPart || file.c === mine.c) return "same" /* same */;
|
|
612
612
|
return file.c > mine.c ? "newer" /* newer */ : "older" /* older */;
|
|
613
613
|
}
|
|
614
|
-
function
|
|
614
|
+
function wireVersionAdvice(relation, file, mine, isPlayer) {
|
|
615
615
|
if (!file) return void 0;
|
|
616
616
|
const target = isPlayer ? "player" : "editor";
|
|
617
617
|
const gap = "written for schema " + formatWireVersion(file) + ", this " + target + " reads " + formatWireVersion(mine);
|
|
@@ -626,13 +626,13 @@ function versionAdvice(relation, file, mine, isPlayer) {
|
|
|
626
626
|
return void 0;
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
|
-
var
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
return
|
|
633
|
-
})(
|
|
634
|
-
var
|
|
635
|
-
var
|
|
629
|
+
var PxWireStepKind = /* @__PURE__ */ ((PxWireStepKind2) => {
|
|
630
|
+
PxWireStepKind2["additive"] = "additive";
|
|
631
|
+
PxWireStepKind2["converted"] = "converted";
|
|
632
|
+
return PxWireStepKind2;
|
|
633
|
+
})(PxWireStepKind || {});
|
|
634
|
+
var PX_WIRE_BASELINE_VERSION = "1.1";
|
|
635
|
+
var PX_WIRE_STEPS = [];
|
|
636
636
|
function applyWireSteps(doc, cfg) {
|
|
637
637
|
const from = readWireVersion(doc);
|
|
638
638
|
const relation = compareWireVersion(from, cfg.target, cfg.readerReadsEditorPart);
|
|
@@ -642,7 +642,7 @@ function applyWireSteps(doc, cfg) {
|
|
|
642
642
|
from,
|
|
643
643
|
relation,
|
|
644
644
|
applied: [],
|
|
645
|
-
advice:
|
|
645
|
+
advice: wireVersionAdvice(relation, from, cfg.target, !cfg.readerReadsEditorPart)
|
|
646
646
|
};
|
|
647
647
|
}
|
|
648
648
|
const due = [];
|
|
@@ -668,10 +668,10 @@ function applyWireSteps(doc, cfg) {
|
|
|
668
668
|
stampVersion(target, cfg.target, cfg.readerReadsEditorPart);
|
|
669
669
|
return { doc: target, from, relation, applied };
|
|
670
670
|
}
|
|
671
|
-
function
|
|
671
|
+
function convertWireDocument(doc) {
|
|
672
672
|
return applyWireSteps(doc, {
|
|
673
|
-
steps:
|
|
674
|
-
target:
|
|
673
|
+
steps: PX_WIRE_STEPS,
|
|
674
|
+
target: PX_WIRE_VERSION,
|
|
675
675
|
readerReadsEditorPart: false
|
|
676
676
|
});
|
|
677
677
|
}
|
|
@@ -682,8 +682,8 @@ function clonePlain(value) {
|
|
|
682
682
|
function stampVersion(doc, target, readerReadsEditorPart) {
|
|
683
683
|
const animator = getAnimatorBlock(doc);
|
|
684
684
|
if (!animator) return;
|
|
685
|
-
const previous = parseWireVersion(animator[
|
|
686
|
-
animator[
|
|
685
|
+
const previous = parseWireVersion(animator[PX_WIRE_VERSION_KEY]);
|
|
686
|
+
animator[PX_WIRE_VERSION_KEY] = formatWireVersion({
|
|
687
687
|
a: target.a,
|
|
688
688
|
b: target.b,
|
|
689
689
|
c: readerReadsEditorPart ? target.c : previous ? previous.c : 0
|
|
@@ -738,8 +738,8 @@ function applyWireStepsDown(doc, cfg) {
|
|
|
738
738
|
stampVersion(target, cfg.target, cfg.readerReadsEditorPart);
|
|
739
739
|
return { ok: true, doc: target, applied };
|
|
740
740
|
}
|
|
741
|
-
function
|
|
742
|
-
return applyWireStepsDown(doc, { steps:
|
|
741
|
+
function downgradeWireDocument(doc, target) {
|
|
742
|
+
return applyWireStepsDown(doc, { steps: PX_WIRE_STEPS, target, readerReadsEditorPart: false });
|
|
743
743
|
}
|
|
744
744
|
|
|
745
745
|
// src/format/PxAnimatorConstants.ts
|
|
@@ -819,17 +819,17 @@ var PxTimelineEngine = {
|
|
|
819
819
|
native: "native",
|
|
820
820
|
js: "js"
|
|
821
821
|
};
|
|
822
|
-
var
|
|
822
|
+
var PxTimelineEngineSetting = __spreadProps(__spreadValues({}, PxTimelineEngine), {
|
|
823
823
|
auto: "auto"
|
|
824
824
|
});
|
|
825
825
|
function resolveTimelineEngine(engine) {
|
|
826
|
-
return engine ===
|
|
826
|
+
return engine === PxTimelineEngineSetting.js ? PxTimelineEngine.js : PxTimelineEngine.native;
|
|
827
827
|
}
|
|
828
828
|
function isNativeForced(engine) {
|
|
829
|
-
return engine ===
|
|
829
|
+
return engine === PxTimelineEngineSetting.native;
|
|
830
830
|
}
|
|
831
831
|
function mayUseNativeScrollTimeline(engine) {
|
|
832
|
-
return engine !==
|
|
832
|
+
return engine !== PxTimelineEngineSetting.js;
|
|
833
833
|
}
|
|
834
834
|
var PX_TRIGGER_DEFAULTS = {
|
|
835
835
|
startOn: "load",
|
|
@@ -921,7 +921,7 @@ var PxStrokeTrimSubPaths = {
|
|
|
921
921
|
separate: "separate",
|
|
922
922
|
combined: "combined"
|
|
923
923
|
};
|
|
924
|
-
var
|
|
924
|
+
var PX_TEXT_CONTENT_ATTR = "textContent";
|
|
925
925
|
var CLASS_ATTR = "class";
|
|
926
926
|
var TRANSFORM_ATTR = "transform";
|
|
927
927
|
var OFFSET_DISTANCE_ATTR = "offsetDistance";
|
|
@@ -932,7 +932,7 @@ var INTERNAL_ATTRS = /* @__PURE__ */ new Set([
|
|
|
932
932
|
"meta",
|
|
933
933
|
"animate",
|
|
934
934
|
"effects",
|
|
935
|
-
|
|
935
|
+
PX_TEXT_CONTENT_ATTR
|
|
936
936
|
]);
|
|
937
937
|
var TRANSFORM_PART = {
|
|
938
938
|
translate: "translate",
|
|
@@ -955,11 +955,11 @@ var PxGradientType = {
|
|
|
955
955
|
linear: "linear",
|
|
956
956
|
radial: "radial"
|
|
957
957
|
};
|
|
958
|
-
function
|
|
959
|
-
if (!(
|
|
958
|
+
function isPxDocument(doc) {
|
|
959
|
+
if (!(doc && typeof doc === "object" && !Array.isArray(doc))) {
|
|
960
960
|
return false;
|
|
961
961
|
}
|
|
962
|
-
return
|
|
962
|
+
return doc.type === "svg";
|
|
963
963
|
}
|
|
964
964
|
function getAnimatorConfig(doc) {
|
|
965
965
|
var _a2;
|
|
@@ -1086,7 +1086,7 @@ function nestAnimatorTimeline(cfg) {
|
|
|
1086
1086
|
if (fill !== void 0) timeline.fillMode = fill;
|
|
1087
1087
|
return Object.keys(timeline).length > 0 ? __spreadProps(__spreadValues({}, shared), { timeline }) : shared;
|
|
1088
1088
|
}
|
|
1089
|
-
function
|
|
1089
|
+
function getDefinitions(doc) {
|
|
1090
1090
|
var _a2;
|
|
1091
1091
|
if (!doc) return void 0;
|
|
1092
1092
|
return (_a2 = getAnimatorConfig(doc)) == null ? void 0 : _a2.definitions;
|
|
@@ -1132,20 +1132,20 @@ var PxKeyframeSchema = implementsInterface()(px.object({
|
|
|
1132
1132
|
// its internal COPY-PASTE payload, which never validates against this schema.)
|
|
1133
1133
|
}));
|
|
1134
1134
|
var anyKf = (kf) => kf;
|
|
1135
|
-
var
|
|
1135
|
+
var keyframeTime = (kf) => {
|
|
1136
1136
|
var _a2, _b;
|
|
1137
1137
|
return (_b = (_a2 = anyKf(kf).time) != null ? _a2 : anyKf(kf).t) != null ? _b : 0;
|
|
1138
1138
|
};
|
|
1139
|
-
var
|
|
1139
|
+
var keyframeValue = (kf) => {
|
|
1140
1140
|
var _a2;
|
|
1141
1141
|
return (_a2 = anyKf(kf).value) != null ? _a2 : anyKf(kf).v;
|
|
1142
1142
|
};
|
|
1143
|
-
var
|
|
1143
|
+
var keyframeEasing = (kf) => {
|
|
1144
1144
|
var _a2;
|
|
1145
1145
|
return (_a2 = anyKf(kf).easing) != null ? _a2 : anyKf(kf).e;
|
|
1146
1146
|
};
|
|
1147
|
-
var
|
|
1148
|
-
var
|
|
1147
|
+
var keyframeTangentIn = (kf) => anyKf(kf).tangentIn;
|
|
1148
|
+
var keyframeTangentOut = (kf) => anyKf(kf).tangentOut;
|
|
1149
1149
|
var PxLoopSchema = implementsInterface()(px.object({
|
|
1150
1150
|
segmentCount: px.number().optional(),
|
|
1151
1151
|
repeatAt: px.enum([PxLoopRepeatAt.start, PxLoopRepeatAt.end]).optional(),
|
|
@@ -1199,7 +1199,7 @@ var PxGlyphFontSchema = implementsInterface()(px.object({
|
|
|
1199
1199
|
unitsPerEm: px.number(),
|
|
1200
1200
|
glyphs: px.record(PxGlyphSchema)
|
|
1201
1201
|
}));
|
|
1202
|
-
var
|
|
1202
|
+
var PxDefinitionsSchema = implementsInterface()(px.object({
|
|
1203
1203
|
easings: px.record(px.tuple([px.number(), px.number(), px.number(), px.number()])).optional(),
|
|
1204
1204
|
animations: px.record(PxAnimationDefinitionSchema).optional(),
|
|
1205
1205
|
fonts: px.record(PxGlyphFontSchema).optional()
|
|
@@ -1237,7 +1237,7 @@ var PxTimelinePinSchema = implementsInterface()(px.object({
|
|
|
1237
1237
|
offset: px.number().optional(),
|
|
1238
1238
|
distance: px.number().optional()
|
|
1239
1239
|
}));
|
|
1240
|
-
var PxTimelineEngineSchema = px.enum([
|
|
1240
|
+
var PxTimelineEngineSchema = px.enum([PxTimelineEngineSetting.auto, PxTimelineEngineSetting.native, PxTimelineEngineSetting.js]).optional();
|
|
1241
1241
|
var PxTimeTimelineSchema = implementsInterface()(px.object({
|
|
1242
1242
|
type: px.literal("time").optional(),
|
|
1243
1243
|
engine: PxTimelineEngineSchema,
|
|
@@ -1291,7 +1291,7 @@ var PxAnimatorConfigSchema = implementsInterface()(px.object({
|
|
|
1291
1291
|
// at this level only on the runtime view, like the rest of the playback dynamics.)
|
|
1292
1292
|
// THE spelling of "what advances progress" — clock / scroll / view (review §2.1).
|
|
1293
1293
|
timeline: PxTimelineSchema.optional(),
|
|
1294
|
-
definitions:
|
|
1294
|
+
definitions: PxDefinitionsSchema.optional(),
|
|
1295
1295
|
bindings: px.array(PxBindingSchema).optional(),
|
|
1296
1296
|
debugGlobalName: px.string().optional(),
|
|
1297
1297
|
// Declared HERE because this is a closed object: an undeclared key would be stripped by
|
|
@@ -1380,7 +1380,7 @@ var PxAnimatableGradientStopsSchema = px.union([
|
|
|
1380
1380
|
PxPropertyAnimationSchema
|
|
1381
1381
|
]);
|
|
1382
1382
|
var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
1383
|
-
// Contextual kind — the `type` convention, see `
|
|
1383
|
+
// Contextual kind — the `type` convention, see `PxNodeBaseSchema.type`.
|
|
1384
1384
|
type: px.enum([PxGradientType.linear, PxGradientType.radial]),
|
|
1385
1385
|
start: PxAnimatableVec2Schema.optional(),
|
|
1386
1386
|
end: PxAnimatableVec2Schema.optional(),
|
|
@@ -1417,11 +1417,11 @@ var PxEffectsSchema = implementsInterface()(px.object({
|
|
|
1417
1417
|
textPath: PxTextPathEffectSchema.optional(),
|
|
1418
1418
|
text: PxTextEffectSchema.optional()
|
|
1419
1419
|
}));
|
|
1420
|
-
function validateNodeEffects(root,
|
|
1420
|
+
function validateNodeEffects(root, options) {
|
|
1421
1421
|
const warnings = [];
|
|
1422
1422
|
const walk = (node, path) => {
|
|
1423
1423
|
if (node && node.effects) {
|
|
1424
|
-
const ctx = { errors: [], warnings: [], strict: !!(
|
|
1424
|
+
const ctx = { errors: [], warnings: [], strict: !!(options == null ? void 0 : options.strict) };
|
|
1425
1425
|
const ok = PxEffectsSchema.isValid(node.effects, ctx, [path + ".effects"]);
|
|
1426
1426
|
if (!ok) {
|
|
1427
1427
|
for (const err of ctx.errors) warnings.push(err);
|
|
@@ -1482,9 +1482,9 @@ function validateVersionStamp(doc) {
|
|
|
1482
1482
|
if (parseWireVersion(version) !== void 0) return [];
|
|
1483
1483
|
return ["root.animator.version: " + JSON.stringify(version) + ' is not a version stamp ("a.b" or "a.b.c") \u2014 it reads as unstamped'];
|
|
1484
1484
|
}
|
|
1485
|
-
function validateDocument(doc,
|
|
1485
|
+
function validateDocument(doc, options) {
|
|
1486
1486
|
var _a2;
|
|
1487
|
-
const strict = (
|
|
1487
|
+
const strict = (options == null ? void 0 : options.strict) !== false;
|
|
1488
1488
|
const ctx = { errors: [], warnings: [], strict };
|
|
1489
1489
|
const problems = PxAnimatedSvgDocumentSchema.isValid(doc, ctx, ["root"]) ? [] : [...ctx.errors];
|
|
1490
1490
|
if (doc && typeof doc === "object") {
|
|
@@ -1504,7 +1504,7 @@ function validateDocument(doc, opts) {
|
|
|
1504
1504
|
}
|
|
1505
1505
|
return problems;
|
|
1506
1506
|
}
|
|
1507
|
-
var
|
|
1507
|
+
var PxNodeBaseSchema = px.openObject({
|
|
1508
1508
|
// CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
|
|
1509
1509
|
// kind of thing is this", discriminated by its CARRIER — here the node TAG
|
|
1510
1510
|
// (`rect`, `text`), and inside a sub-object that object's kind (`fillGradient.type`,
|
|
@@ -1519,7 +1519,7 @@ var PxNodeBase = px.openObject({
|
|
|
1519
1519
|
// `type` is taken by the tag name, so the attribute travels here and the renderer puts
|
|
1520
1520
|
// it back (`PxAnimatorDOM.renderNode`, `PxRnRender`). Declared here — not merely
|
|
1521
1521
|
// documented — because a wire key that is not in a schema is invisible to the
|
|
1522
|
-
// minifier's reserve list and gets renamed (
|
|
1522
|
+
// minifier's reserve list and gets renamed (dev-docs/plans/minification-boundary.md §1.1).
|
|
1523
1523
|
domType: px.string().optional(),
|
|
1524
1524
|
// Text content of a `<text>` / `<tspan>`. Declared, so a non-string value is a schema error
|
|
1525
1525
|
// and the minifier reserves the key; `text` is NOT an alias for it and is not read anywhere.
|
|
@@ -1527,7 +1527,7 @@ var PxNodeBase = px.openObject({
|
|
|
1527
1527
|
id: px.string().optional(),
|
|
1528
1528
|
meta: px.any().optional(),
|
|
1529
1529
|
// Player-effects bucket emitted by the Editor's lightweight design format.
|
|
1530
|
-
// Consumed and removed by `
|
|
1530
|
+
// Consumed and removed by `materializeNodeEffects` before any other normalization
|
|
1531
1531
|
// (see `createAnimatorImpl`), so downstream code never sees it.
|
|
1532
1532
|
effects: PxEffectsSchema.optional(),
|
|
1533
1533
|
// `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
|
|
@@ -1536,10 +1536,10 @@ var PxNodeBase = px.openObject({
|
|
|
1536
1536
|
animate: PxElementAnimationSchema.optional(),
|
|
1537
1537
|
style: px.record(px.union([px.string(), px.number()])).optional()
|
|
1538
1538
|
}, PxAttrValueSchema);
|
|
1539
|
-
var PxNodeSchema = px.openObject(__spreadProps(__spreadValues({},
|
|
1539
|
+
var PxNodeSchema = px.openObject(__spreadProps(__spreadValues({}, PxNodeBaseSchema._shape), {
|
|
1540
1540
|
children: px.lazy(() => px.array(PxNodeSchema), []).optional()
|
|
1541
1541
|
}), PxAttrValueSchema);
|
|
1542
|
-
var
|
|
1542
|
+
var PxSvgNodeRootSchema = px.object({
|
|
1543
1543
|
// `"100%"` and other SVG length strings are legal here — a number-only slot rejected
|
|
1544
1544
|
// real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
|
|
1545
1545
|
width: px.union([px.number(), px.string()]).optional(),
|
|
@@ -1547,7 +1547,7 @@ var PxSvgNodeExtra = px.object({
|
|
|
1547
1547
|
viewBox: px.string().optional(),
|
|
1548
1548
|
animator: PxAnimatorConfigSchema.optional()
|
|
1549
1549
|
});
|
|
1550
|
-
var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps(__spreadValues(__spreadValues({},
|
|
1550
|
+
var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps(__spreadValues(__spreadValues({}, PxNodeBaseSchema._shape), PxSvgNodeRootSchema._shape), {
|
|
1551
1551
|
type: px.literal("svg"),
|
|
1552
1552
|
// override string → literal to require 'svg'
|
|
1553
1553
|
children: px.array(PxNodeSchema).optional()
|
|
@@ -1558,8 +1558,8 @@ var PxBezierPathSchema = implementsInterface()(px.object({
|
|
|
1558
1558
|
o: px.array(px.array(px.number())).optional(),
|
|
1559
1559
|
c: px.boolean().optional()
|
|
1560
1560
|
}));
|
|
1561
|
-
function
|
|
1562
|
-
const errors = validateDocument(
|
|
1561
|
+
function isValidPxDocument(doc) {
|
|
1562
|
+
const errors = validateDocument(doc, { strict: false });
|
|
1563
1563
|
return { valid: errors.length === 0, errors };
|
|
1564
1564
|
}
|
|
1565
1565
|
|
|
@@ -1910,9 +1910,9 @@ function parseColor(s) {
|
|
|
1910
1910
|
}
|
|
1911
1911
|
return void 0;
|
|
1912
1912
|
}
|
|
1913
|
-
var
|
|
1914
|
-
var
|
|
1915
|
-
var
|
|
1913
|
+
var PX_COLOR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
|
|
1914
|
+
var PX_TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
|
|
1915
|
+
var PX_PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
1916
1916
|
function composeTransformParts(parts, opts) {
|
|
1917
1917
|
var _a2;
|
|
1918
1918
|
if (!parts) return "";
|
|
@@ -1965,8 +1965,8 @@ function parseTransformParts(str2) {
|
|
|
1965
1965
|
if (str2.replace(/([a-zA-Z]+)\s*\(([^)]*)\)/g, "").replace(/[\s,]/g, "").length) return void 0;
|
|
1966
1966
|
return Object.keys(out).length ? out : void 0;
|
|
1967
1967
|
}
|
|
1968
|
-
var
|
|
1969
|
-
var
|
|
1968
|
+
var PX_STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
1969
|
+
var PX_DEFAULT_DURATION_MS = 1e3;
|
|
1970
1970
|
function kebabToCamelCaseWord(kebab) {
|
|
1971
1971
|
return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
|
|
1972
1972
|
}
|
|
@@ -2129,7 +2129,7 @@ function invertEasing(easing) {
|
|
|
2129
2129
|
}
|
|
2130
2130
|
|
|
2131
2131
|
// src/util/PxNodeProps.ts
|
|
2132
|
-
var
|
|
2132
|
+
var PX_DISALLOWED_SVG_TAGS_LOWER = /* @__PURE__ */ new Set([
|
|
2133
2133
|
"script",
|
|
2134
2134
|
"foreignobject"
|
|
2135
2135
|
]);
|
|
@@ -2154,7 +2154,7 @@ var URL_VALUE_ATTRS_LOWER = /* @__PURE__ */ new Set([
|
|
|
2154
2154
|
// marker-end="url(#…)"
|
|
2155
2155
|
]);
|
|
2156
2156
|
var IMAGE_REF_ATTRS_LOWER = /* @__PURE__ */ new Set(["href", "xlink:href", "src"]);
|
|
2157
|
-
var
|
|
2157
|
+
var PX_CSS_ONLY_STYLE_PROPS = /* @__PURE__ */ new Set(["mixBlendMode", "isolation"]);
|
|
2158
2158
|
var DATA_RASTER_IMAGE_RE = /^data:image\/(?:png|jpe?g|gif|webp|bmp);base64,/i;
|
|
2159
2159
|
var DATA_SVG_IMAGE_RE = /^data:image\/svg\+xml(?:;[^,]*)?,/i;
|
|
2160
2160
|
var DATA_IMAGE_BASE64_PAYLOAD_RE = /^data:image\/[^;,]*;base64,([A-Za-z0-9+/]{8})/i;
|
|
@@ -2191,19 +2191,19 @@ function sanitizeAttributeValue(name, value) {
|
|
|
2191
2191
|
}
|
|
2192
2192
|
return value;
|
|
2193
2193
|
}
|
|
2194
|
-
function
|
|
2194
|
+
function toDomProps(props) {
|
|
2195
2195
|
const propsCopy = {};
|
|
2196
2196
|
for (const rawKey of Object.keys(props)) {
|
|
2197
2197
|
const key = kebabToCamelCaseWord(rawKey);
|
|
2198
2198
|
if (INTERNAL_ATTRS.has(key)) continue;
|
|
2199
2199
|
if (key === "style") continue;
|
|
2200
2200
|
let value = props[rawKey];
|
|
2201
|
-
if (
|
|
2201
|
+
if (PX_COLOR_ATTR_NAMES.has(key) && Array.isArray(value)) {
|
|
2202
2202
|
propsCopy[key] = toRGBA(value);
|
|
2203
2203
|
} else if (key === "transform" && value !== null && typeof value === "object" && !Array.isArray(value) && !value.keyframes) {
|
|
2204
2204
|
const parts = value.value && typeof value.value === "object" ? value.value : value;
|
|
2205
2205
|
propsCopy[TRANSFORM_ATTR] = composeTransformParts(parts, { withUnits: false });
|
|
2206
|
-
} else if (
|
|
2206
|
+
} else if (PX_TRANSFORM_FN_NAMES.has(key)) {
|
|
2207
2207
|
if (Array.isArray(value)) {
|
|
2208
2208
|
if (key === "translate") value = value.map((v) => v + "px");
|
|
2209
2209
|
value = value.join(",");
|
|
@@ -2221,7 +2221,7 @@ function getNormalizedProps(props) {
|
|
|
2221
2221
|
|
|
2222
2222
|
// src/materialize/PxMotionPath.ts
|
|
2223
2223
|
function getKfTranslate(kf) {
|
|
2224
|
-
const v =
|
|
2224
|
+
const v = keyframeValue(kf);
|
|
2225
2225
|
if (!v) return void 0;
|
|
2226
2226
|
if (Array.isArray(v) && v.length >= 2 && typeof v[0] === "number" && typeof v[1] === "number") {
|
|
2227
2227
|
return [v[0], v[1]];
|
|
@@ -2231,17 +2231,17 @@ function getKfTranslate(kf) {
|
|
|
2231
2231
|
return void 0;
|
|
2232
2232
|
}
|
|
2233
2233
|
function getKfTime(kf) {
|
|
2234
|
-
return
|
|
2234
|
+
return keyframeTime(kf);
|
|
2235
2235
|
}
|
|
2236
2236
|
function getKfEasing(kf) {
|
|
2237
|
-
return
|
|
2237
|
+
return keyframeEasing(kf);
|
|
2238
2238
|
}
|
|
2239
2239
|
function propAnimIsMotionPath(anim) {
|
|
2240
2240
|
const kfs = anim.keyframes;
|
|
2241
2241
|
if (!Array.isArray(kfs)) return false;
|
|
2242
2242
|
if (anim.autoOrient) return true;
|
|
2243
2243
|
for (const kf of kfs) {
|
|
2244
|
-
if (
|
|
2244
|
+
if (keyframeTangentIn(kf) || keyframeTangentOut(kf)) return true;
|
|
2245
2245
|
}
|
|
2246
2246
|
return false;
|
|
2247
2247
|
}
|
|
@@ -2250,8 +2250,8 @@ function getSegmentCache(prevKf, nextKf, prevPos, nextPos) {
|
|
|
2250
2250
|
let byNext = _segmentCache.get(prevKf);
|
|
2251
2251
|
const existing = byNext == null ? void 0 : byNext.get(nextKf);
|
|
2252
2252
|
if (existing) return existing;
|
|
2253
|
-
const to =
|
|
2254
|
-
const ti =
|
|
2253
|
+
const to = keyframeTangentOut(prevKf);
|
|
2254
|
+
const ti = keyframeTangentIn(nextKf);
|
|
2255
2255
|
const P1 = [prevPos[0] + (to ? to[0] : 0), prevPos[1] + (to ? to[1] : 0)];
|
|
2256
2256
|
const P2 = [nextPos[0] + (ti ? ti[0] : 0), nextPos[1] + (ti ? ti[1] : 0)];
|
|
2257
2257
|
const lut = bezier2D_arcLengthLUT(prevPos, P1, P2, nextPos);
|
|
@@ -2344,7 +2344,7 @@ function materializeMotionPathInPropAnim(anim, opts) {
|
|
|
2344
2344
|
function unwrapAutoOrientRotations(kfs) {
|
|
2345
2345
|
let prev;
|
|
2346
2346
|
for (const kf of kfs) {
|
|
2347
|
-
const v =
|
|
2347
|
+
const v = keyframeValue(kf);
|
|
2348
2348
|
if (!v || typeof v.rotate !== "number") continue;
|
|
2349
2349
|
if (prev === void 0) {
|
|
2350
2350
|
prev = v.rotate;
|
|
@@ -2361,7 +2361,7 @@ function makeOutKf(time, value) {
|
|
|
2361
2361
|
return { t: time, v: value };
|
|
2362
2362
|
}
|
|
2363
2363
|
function getKfValueParts(kf) {
|
|
2364
|
-
const v =
|
|
2364
|
+
const v = keyframeValue(kf);
|
|
2365
2365
|
if (!v || typeof v !== "object" || Array.isArray(v)) return void 0;
|
|
2366
2366
|
return v;
|
|
2367
2367
|
}
|
|
@@ -2423,7 +2423,7 @@ function wrappedAngleDelta(a, b) {
|
|
|
2423
2423
|
}
|
|
2424
2424
|
function insertSharpCornerStepKfIfNeeded(out, prevKf, nextKf, prevPos, nextPos, rotationTol) {
|
|
2425
2425
|
const lastKf = out[out.length - 1];
|
|
2426
|
-
const lastV =
|
|
2426
|
+
const lastV = keyframeValue(lastKf);
|
|
2427
2427
|
const prevExit = lastV == null ? void 0 : lastV.rotate;
|
|
2428
2428
|
if (typeof prevExit !== "number") return;
|
|
2429
2429
|
const boundaryV = getKfValueParts(prevKf);
|
|
@@ -2605,7 +2605,7 @@ function walkAndMaterialize(node, opts) {
|
|
|
2605
2605
|
}
|
|
2606
2606
|
|
|
2607
2607
|
// src/animation/PxDefinitions.ts
|
|
2608
|
-
var
|
|
2608
|
+
var PX_LOOP_JUMP_SHIFT_MS = 1;
|
|
2609
2609
|
function deepEqualValue(a, b) {
|
|
2610
2610
|
if (a === b) return true;
|
|
2611
2611
|
if (typeof a !== typeof b || a === null || b === null || typeof a !== "object") return false;
|
|
@@ -2781,7 +2781,7 @@ function interpolateValue(propName, a, b, t) {
|
|
|
2781
2781
|
const bPaths = (_b = b == null ? void 0 : b.paths) != null ? _b : Array.isArray(b) ? b : [];
|
|
2782
2782
|
return { paths: interpolateBeziers(aPaths, bPaths, t) };
|
|
2783
2783
|
}
|
|
2784
|
-
if (
|
|
2784
|
+
if (PX_COLOR_ATTR_NAMES.has(propName)) {
|
|
2785
2785
|
return interpolateColor(a || [0, 0, 0, 1], b || [0, 0, 0, 1], t);
|
|
2786
2786
|
}
|
|
2787
2787
|
if (propName === "transform" && typeof a === "object" && a !== null && !Array.isArray(a) && typeof b === "object" && b !== null && !Array.isArray(b)) {
|
|
@@ -2790,7 +2790,7 @@ function interpolateValue(propName, a, b, t) {
|
|
|
2790
2790
|
if (propName === "rotate" && typeof a === "number" && typeof b === "number") {
|
|
2791
2791
|
return interpolateNum(a, b, t);
|
|
2792
2792
|
}
|
|
2793
|
-
if (
|
|
2793
|
+
if (PX_TRANSFORM_FN_NAMES.has(propName) || propName === "stroke-dasharray" || propName === "strokeDasharray") {
|
|
2794
2794
|
return interpolateVec(a || [], b || [], t);
|
|
2795
2795
|
}
|
|
2796
2796
|
return interpolateNum(+(a || 0), +(b || 0), t);
|
|
@@ -2842,8 +2842,8 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2842
2842
|
relT: (kf.t - segStartT) / segDuration,
|
|
2843
2843
|
v: kf.v,
|
|
2844
2844
|
e: kf.e,
|
|
2845
|
-
tangentIn:
|
|
2846
|
-
tangentOut:
|
|
2845
|
+
tangentIn: keyframeTangentIn(kf),
|
|
2846
|
+
tangentOut: keyframeTangentOut(kf)
|
|
2847
2847
|
}));
|
|
2848
2848
|
const fullReps = Math.floor(fillDuration / segDuration);
|
|
2849
2849
|
const remainder = fillDuration - fullReps * segDuration;
|
|
@@ -2909,7 +2909,7 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2909
2909
|
}
|
|
2910
2910
|
}
|
|
2911
2911
|
const pushed = {
|
|
2912
|
-
t: repStart + entry.relT * segDuration + (isBoundary ?
|
|
2912
|
+
t: repStart + entry.relT * segDuration + (isBoundary ? PX_LOOP_JUMP_SHIFT_MS : 0),
|
|
2913
2913
|
v: entry.v,
|
|
2914
2914
|
e: i < entries.length - 1 ? entry.e : void 0
|
|
2915
2915
|
};
|
|
@@ -2996,14 +2996,14 @@ function normalizeKeyframes(propName, propAnim, duration, defs) {
|
|
|
2996
2996
|
const keyframes = propAnim.keyframes || [];
|
|
2997
2997
|
const normalized = [];
|
|
2998
2998
|
for (const kf of keyframes) {
|
|
2999
|
-
const timePct =
|
|
3000
|
-
let value =
|
|
3001
|
-
const easing =
|
|
2999
|
+
const timePct = keyframeTime(kf);
|
|
3000
|
+
let value = keyframeValue(kf);
|
|
3001
|
+
const easing = keyframeEasing(kf);
|
|
3002
3002
|
if (propName === "d") {
|
|
3003
3003
|
value = normalizePathValue(value);
|
|
3004
3004
|
}
|
|
3005
3005
|
const propNameKebab = isCamelCaseWord(propName) ? camelCaseToKebabWordIfNeeded(propName) : propName;
|
|
3006
|
-
if (
|
|
3006
|
+
if (PX_COLOR_ATTR_NAMES.has(propNameKebab)) {
|
|
3007
3007
|
value = (_a2 = parseColor(value)) != null ? _a2 : value;
|
|
3008
3008
|
}
|
|
3009
3009
|
const normKf = {
|
|
@@ -3011,8 +3011,8 @@ function normalizeKeyframes(propName, propAnim, duration, defs) {
|
|
|
3011
3011
|
v: value,
|
|
3012
3012
|
e: resolveEasing(easing, defs)
|
|
3013
3013
|
};
|
|
3014
|
-
const tIn =
|
|
3015
|
-
const tOut =
|
|
3014
|
+
const tIn = keyframeTangentIn(kf);
|
|
3015
|
+
const tOut = keyframeTangentOut(kf);
|
|
3016
3016
|
if (tIn) normKf.tangentIn = tIn;
|
|
3017
3017
|
if (tOut) normKf.tangentOut = tOut;
|
|
3018
3018
|
normalized.push(normKf);
|
|
@@ -3044,17 +3044,17 @@ function materializeInternalLoopsInPropAnim(propName, propAnim, duration) {
|
|
|
3044
3044
|
const rawKfs = propAnim.keyframes;
|
|
3045
3045
|
if (!Array.isArray(rawKfs) || rawKfs.length < 2) return propAnim;
|
|
3046
3046
|
const propNameKebab = isCamelCaseWord(propName) ? camelCaseToKebabWordIfNeeded(propName) : propName;
|
|
3047
|
-
const isColor =
|
|
3047
|
+
const isColor = PX_COLOR_ATTR_NAMES.has(propNameKebab);
|
|
3048
3048
|
const kfs = rawKfs.map((kf) => {
|
|
3049
3049
|
var _a2;
|
|
3050
|
-
const t =
|
|
3051
|
-
let v =
|
|
3050
|
+
const t = keyframeTime(kf);
|
|
3051
|
+
let v = keyframeValue(kf);
|
|
3052
3052
|
if (propName === "d") v = normalizePathValue(v);
|
|
3053
3053
|
if (isColor) v = (_a2 = parseColor(v)) != null ? _a2 : v;
|
|
3054
|
-
const e =
|
|
3054
|
+
const e = keyframeEasing(kf);
|
|
3055
3055
|
const out2 = { t, v, e };
|
|
3056
|
-
const tIn =
|
|
3057
|
-
const tOut =
|
|
3056
|
+
const tIn = keyframeTangentIn(kf);
|
|
3057
|
+
const tOut = keyframeTangentOut(kf);
|
|
3058
3058
|
if (tIn) out2.tangentIn = tIn;
|
|
3059
3059
|
if (tOut) out2.tangentOut = tOut;
|
|
3060
3060
|
return out2;
|
|
@@ -3119,7 +3119,7 @@ function mergeStaticTransformIntoAnimDef(animDef, staticTransform) {
|
|
|
3119
3119
|
}
|
|
3120
3120
|
return animDef;
|
|
3121
3121
|
}
|
|
3122
|
-
const channels = Object.keys(animDef).filter((k) =>
|
|
3122
|
+
const channels = Object.keys(animDef).filter((k) => PX_TRANSFORM_FN_NAMES.has(k));
|
|
3123
3123
|
if (channels.length !== 1) return animDef;
|
|
3124
3124
|
const ch = channels[0];
|
|
3125
3125
|
const chAnim = animDef[ch];
|
|
@@ -3148,9 +3148,9 @@ function normalizeAnimationDefinition(animDef, duration, defs, engine = PxTimeli
|
|
|
3148
3148
|
}
|
|
3149
3149
|
return normalized;
|
|
3150
3150
|
}
|
|
3151
|
-
function
|
|
3151
|
+
function normalizeBindings(doc, engine = PxTimelineEngine.native) {
|
|
3152
3152
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
3153
|
-
const defs =
|
|
3153
|
+
const defs = getDefinitions(doc);
|
|
3154
3154
|
const duration = animatorConfig.duration || 1e3;
|
|
3155
3155
|
const bindings = [];
|
|
3156
3156
|
const processAnimation = (id, animDefs, staticTransform) => {
|
|
@@ -3220,7 +3220,7 @@ function calcPropertyValue(propName, propAnim, progress) {
|
|
|
3220
3220
|
const { prevKf, nextKf } = getKeyframesPair(keyframes, progress);
|
|
3221
3221
|
let localProgress = prevKf === nextKf ? 0 : remap(progress, (_a2 = prevKf.t) != null ? _a2 : 0, (_b = nextKf.t) != null ? _b : 0, 0, 1);
|
|
3222
3222
|
localProgress = clamp(localProgress, 0, 1);
|
|
3223
|
-
const easing =
|
|
3223
|
+
const easing = keyframeEasing(prevKf);
|
|
3224
3224
|
if (easing && Array.isArray(easing)) {
|
|
3225
3225
|
try {
|
|
3226
3226
|
localProgress = cubicBezier(easing)(localProgress);
|
|
@@ -3239,7 +3239,7 @@ function calcPropertyValue(propName, propAnim, progress) {
|
|
|
3239
3239
|
nextPaths,
|
|
3240
3240
|
localProgress
|
|
3241
3241
|
).map((bz) => bezierToSvgPath(bz)).join("");
|
|
3242
|
-
} else if (
|
|
3242
|
+
} else if (PX_COLOR_ATTR_NAMES.has(cssAttrName)) {
|
|
3243
3243
|
cssValue = toRGBA(interpolateColor(
|
|
3244
3244
|
prevV || [0, 0, 0, 1],
|
|
3245
3245
|
nextV || [0, 0, 0, 1],
|
|
@@ -3313,14 +3313,14 @@ function calcPropertyValue(propName, propAnim, progress) {
|
|
|
3313
3313
|
cssValue = "scale(" + v.join(",") + ")";
|
|
3314
3314
|
cssAttrName = "transform";
|
|
3315
3315
|
} else {
|
|
3316
|
-
const
|
|
3316
|
+
const num = interpolateNum(
|
|
3317
3317
|
+(prevV || 0),
|
|
3318
3318
|
+(nextV || 0),
|
|
3319
3319
|
localProgress
|
|
3320
3320
|
);
|
|
3321
|
-
cssValue =
|
|
3321
|
+
cssValue = num;
|
|
3322
3322
|
}
|
|
3323
|
-
if (
|
|
3323
|
+
if (PX_PCT_BASED_ATTR_NAMES.has(cssAttrName) && typeof cssValue === "number") {
|
|
3324
3324
|
cssValue = cssValue * 100 + "%";
|
|
3325
3325
|
}
|
|
3326
3326
|
return { k: cssAttrName, v: cssValue === null ? "" : "" + cssValue };
|
|
@@ -3361,7 +3361,7 @@ function parseCubics(d) {
|
|
|
3361
3361
|
let pcx = 0, pcy = 0;
|
|
3362
3362
|
let pqx = 0, pqy = 0;
|
|
3363
3363
|
let prevCmd = "";
|
|
3364
|
-
const
|
|
3364
|
+
const num = () => parseFloat(tokens[i++]);
|
|
3365
3365
|
const push = (P1, P2, P3) => {
|
|
3366
3366
|
const P0 = [cx, cy];
|
|
3367
3367
|
const lut = bezier2D_arcLengthLUT(P0, P1, P2, P3, LUT_STEPS);
|
|
@@ -3390,7 +3390,7 @@ function parseCubics(d) {
|
|
|
3390
3390
|
continue;
|
|
3391
3391
|
}
|
|
3392
3392
|
if (U === "M") {
|
|
3393
|
-
const x =
|
|
3393
|
+
const x = num() + (rel ? cx : 0), y = num() + (rel ? cy : 0);
|
|
3394
3394
|
cx = x;
|
|
3395
3395
|
cy = y;
|
|
3396
3396
|
sx = x;
|
|
@@ -3399,29 +3399,29 @@ function parseCubics(d) {
|
|
|
3399
3399
|
continue;
|
|
3400
3400
|
}
|
|
3401
3401
|
if (U === "L") {
|
|
3402
|
-
pushLine(
|
|
3402
|
+
pushLine(num() + (rel ? cx : 0), num() + (rel ? cy : 0));
|
|
3403
3403
|
} else if (U === "H") {
|
|
3404
|
-
pushLine(
|
|
3404
|
+
pushLine(num() + (rel ? cx : 0), cy);
|
|
3405
3405
|
} else if (U === "V") {
|
|
3406
|
-
pushLine(cx,
|
|
3406
|
+
pushLine(cx, num() + (rel ? cy : 0));
|
|
3407
3407
|
} else if (U === "C") {
|
|
3408
|
-
const p1 = [
|
|
3409
|
-
const p2 = [
|
|
3410
|
-
const p3 = [
|
|
3408
|
+
const p1 = [num() + (rel ? cx : 0), num() + (rel ? cy : 0)];
|
|
3409
|
+
const p2 = [num() + (rel ? cx : 0), num() + (rel ? cy : 0)];
|
|
3410
|
+
const p3 = [num() + (rel ? cx : 0), num() + (rel ? cy : 0)];
|
|
3411
3411
|
pcx = p2[0];
|
|
3412
3412
|
pcy = p2[1];
|
|
3413
3413
|
push(p1, p2, p3);
|
|
3414
3414
|
} else if (U === "S") {
|
|
3415
3415
|
const smooth = prevCmd.toUpperCase() === "C" || prevCmd.toUpperCase() === "S";
|
|
3416
3416
|
const p1 = smooth ? [2 * cx - pcx, 2 * cy - pcy] : [cx, cy];
|
|
3417
|
-
const p2 = [
|
|
3418
|
-
const p3 = [
|
|
3417
|
+
const p2 = [num() + (rel ? cx : 0), num() + (rel ? cy : 0)];
|
|
3418
|
+
const p3 = [num() + (rel ? cx : 0), num() + (rel ? cy : 0)];
|
|
3419
3419
|
pcx = p2[0];
|
|
3420
3420
|
pcy = p2[1];
|
|
3421
3421
|
push(p1, p2, p3);
|
|
3422
3422
|
} else if (U === "Q") {
|
|
3423
|
-
const qc = [
|
|
3424
|
-
const p3 = [
|
|
3423
|
+
const qc = [num() + (rel ? cx : 0), num() + (rel ? cy : 0)];
|
|
3424
|
+
const p3 = [num() + (rel ? cx : 0), num() + (rel ? cy : 0)];
|
|
3425
3425
|
pqx = qc[0];
|
|
3426
3426
|
pqy = qc[1];
|
|
3427
3427
|
const { P1, P2 } = quadToCubic([cx, cy], qc, p3);
|
|
@@ -3429,14 +3429,14 @@ function parseCubics(d) {
|
|
|
3429
3429
|
} else if (U === "T") {
|
|
3430
3430
|
const smooth = prevCmd.toUpperCase() === "Q" || prevCmd.toUpperCase() === "T";
|
|
3431
3431
|
const qc = smooth ? [2 * cx - pqx, 2 * cy - pqy] : [cx, cy];
|
|
3432
|
-
const p3 = [
|
|
3432
|
+
const p3 = [num() + (rel ? cx : 0), num() + (rel ? cy : 0)];
|
|
3433
3433
|
pqx = qc[0];
|
|
3434
3434
|
pqy = qc[1];
|
|
3435
3435
|
const { P1, P2 } = quadToCubic([cx, cy], qc, p3);
|
|
3436
3436
|
push(P1, P2, p3);
|
|
3437
3437
|
} else if (U === "A") {
|
|
3438
3438
|
i += 5;
|
|
3439
|
-
pushLine(
|
|
3439
|
+
pushLine(num() + (rel ? cx : 0), num() + (rel ? cy : 0));
|
|
3440
3440
|
} else {
|
|
3441
3441
|
i++;
|
|
3442
3442
|
continue;
|
|
@@ -3775,20 +3775,20 @@ function transformPathData(d, m, decimals = 2) {
|
|
|
3775
3775
|
while ((match = TOKEN_RE.exec(d)) !== null) tokens.push(match[0]);
|
|
3776
3776
|
let out = "";
|
|
3777
3777
|
let i = 0;
|
|
3778
|
-
const
|
|
3778
|
+
const num = () => parseFloat(tokens[i++]);
|
|
3779
3779
|
while (i < tokens.length) {
|
|
3780
3780
|
const cmd = tokens[i++];
|
|
3781
3781
|
if (cmd === "M" || cmd === "L") {
|
|
3782
|
-
const [x, y] = apply(m,
|
|
3782
|
+
const [x, y] = apply(m, num(), num());
|
|
3783
3783
|
out += cmd + pack([x, y], decimals);
|
|
3784
3784
|
} else if (cmd === "C") {
|
|
3785
|
-
const [x1, y1] = apply(m,
|
|
3786
|
-
const [x2, y2] = apply(m,
|
|
3787
|
-
const [x, y] = apply(m,
|
|
3785
|
+
const [x1, y1] = apply(m, num(), num());
|
|
3786
|
+
const [x2, y2] = apply(m, num(), num());
|
|
3787
|
+
const [x, y] = apply(m, num(), num());
|
|
3788
3788
|
out += "C" + pack([x1, y1, x2, y2, x, y], decimals);
|
|
3789
3789
|
} else if (cmd === "Q") {
|
|
3790
|
-
const [x1, y1] = apply(m,
|
|
3791
|
-
const [x, y] = apply(m,
|
|
3790
|
+
const [x1, y1] = apply(m, num(), num());
|
|
3791
|
+
const [x, y] = apply(m, num(), num());
|
|
3792
3792
|
out += "Q" + pack([x1, y1, x, y], decimals);
|
|
3793
3793
|
} else if (cmd === "Z" || cmd === "z") {
|
|
3794
3794
|
out += "Z";
|
|
@@ -3819,7 +3819,7 @@ var TEXT_ATTR_KEYS = [
|
|
|
3819
3819
|
"stroke",
|
|
3820
3820
|
"strokeWidth",
|
|
3821
3821
|
"effects",
|
|
3822
|
-
|
|
3822
|
+
PX_TEXT_CONTENT_ATTR,
|
|
3823
3823
|
"xml:space"
|
|
3824
3824
|
];
|
|
3825
3825
|
var PAINT_STATIC_KEYS = [
|
|
@@ -3973,13 +3973,13 @@ function materializeGlyphTextHorizontal(node, opts) {
|
|
|
3973
3973
|
if (y !== void 0) pen.y = y;
|
|
3974
3974
|
pen.x += (_a3 = parseLen(el.dx)) != null ? _a3 : 0;
|
|
3975
3975
|
pen.y += (_b2 = parseLen(el.dy)) != null ? _b2 : 0;
|
|
3976
|
-
const content = str(el[
|
|
3976
|
+
const content = str(el[PX_TEXT_CONTENT_ATTR]);
|
|
3977
3977
|
if (content && !((_c2 = el.children) == null ? void 0 : _c2.length)) renderChars(content, s);
|
|
3978
3978
|
if (el.children) for (const ch of el.children) walk(ch, s);
|
|
3979
3979
|
};
|
|
3980
3980
|
const rootStyle = rootStyleOf(node);
|
|
3981
3981
|
if (node.children) for (const ch of node.children) walk(ch, rootStyle);
|
|
3982
|
-
const rootContent = str(node[
|
|
3982
|
+
const rootContent = str(node[PX_TEXT_CONTENT_ATTR]);
|
|
3983
3983
|
if (rootContent && !((_c = node.children) == null ? void 0 : _c.length)) renderChars(rootContent, rootStyle);
|
|
3984
3984
|
const anchor = str(node.textAnchor);
|
|
3985
3985
|
if (anchor === "middle" || anchor === "end") {
|
|
@@ -4028,7 +4028,7 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
4028
4028
|
if (y !== void 0) pen.y = y;
|
|
4029
4029
|
pen.x += (_a3 = parseLen(el.dx)) != null ? _a3 : 0;
|
|
4030
4030
|
pen.y += (_b2 = parseLen(el.dy)) != null ? _b2 : 0;
|
|
4031
|
-
const content = str(el[
|
|
4031
|
+
const content = str(el[PX_TEXT_CONTENT_ATTR]);
|
|
4032
4032
|
if (content && !((_c2 = el.children) == null ? void 0 : _c2.length)) renderChars(content, s);
|
|
4033
4033
|
if (el.children) for (const ch of el.children) walk(ch, s);
|
|
4034
4034
|
};
|
|
@@ -4043,7 +4043,7 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
4043
4043
|
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 });
|
|
4044
4044
|
}
|
|
4045
4045
|
}
|
|
4046
|
-
const rootContent = str(node[
|
|
4046
|
+
const rootContent = str(node[PX_TEXT_CONTENT_ATTR]);
|
|
4047
4047
|
if (rootContent && !((_e = node.children) == null ? void 0 : _e.length)) renderChars(rootContent, rootStyle);
|
|
4048
4048
|
const anchor = str(node.textAnchor);
|
|
4049
4049
|
if (anchor === "middle" || anchor === "end") {
|
|
@@ -4071,7 +4071,7 @@ function layoutGlyphTextCharsAlongPath(node, pathD, opts) {
|
|
|
4071
4071
|
const walk = (el, parentStyle) => {
|
|
4072
4072
|
var _a3, _b2;
|
|
4073
4073
|
const s = resolveStyle(el, parentStyle);
|
|
4074
|
-
const content = str(el[
|
|
4074
|
+
const content = str(el[PX_TEXT_CONTENT_ATTR]);
|
|
4075
4075
|
if (content && !((_a3 = el.children) == null ? void 0 : _a3.length)) {
|
|
4076
4076
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
4077
4077
|
const upm = (gf == null ? void 0 : gf.unitsPerEm) || 1e3;
|
|
@@ -4125,7 +4125,7 @@ function collectAlongPathCells(node, glyphs, soleFont, warnings) {
|
|
|
4125
4125
|
const walk = (el, parentStyle) => {
|
|
4126
4126
|
var _a2, _b;
|
|
4127
4127
|
const s = resolveStyle(el, parentStyle);
|
|
4128
|
-
const content = str(el[
|
|
4128
|
+
const content = str(el[PX_TEXT_CONTENT_ATTR]);
|
|
4129
4129
|
if (content && !((_a2 = el.children) == null ? void 0 : _a2.length)) {
|
|
4130
4130
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
4131
4131
|
if (gf) {
|
|
@@ -4373,32 +4373,34 @@ var PxDiagnosticKind = {
|
|
|
4373
4373
|
/** The player failed where it did not expect to — report it to us. */
|
|
4374
4374
|
internal: "internal"
|
|
4375
4375
|
};
|
|
4376
|
-
|
|
4377
|
-
|
|
4376
|
+
var DOCS_URL = "https://github.com/pixodesk/pixodesk-svg-animator/blob/main/docs/diagnostics.md";
|
|
4377
|
+
function codeLine(code) {
|
|
4378
|
+
return "PX" + code + " " + DOCS_URL + "#px" + code;
|
|
4379
|
+
}
|
|
4380
|
+
function errorIn(data) {
|
|
4381
|
+
return data.find((d) => d instanceof Error);
|
|
4378
4382
|
}
|
|
4379
4383
|
function createDiagnostics(config, prefix) {
|
|
4380
4384
|
const tag = prefix ? prefix + " " : "";
|
|
4381
4385
|
return {
|
|
4382
|
-
warn: (kind,
|
|
4386
|
+
warn: (kind, code, ...data) => {
|
|
4387
|
+
const message = codeLine(code);
|
|
4383
4388
|
if (config == null ? void 0 : config.onWarn) {
|
|
4384
|
-
config.onWarn({ kind,
|
|
4389
|
+
config.onWarn({ code, kind, data, message });
|
|
4385
4390
|
return;
|
|
4386
4391
|
}
|
|
4387
4392
|
if (config == null ? void 0 : config.muteWarn) return;
|
|
4388
|
-
|
|
4389
|
-
if (detail === void 0) console.warn(line);
|
|
4390
|
-
else console.warn(line, detail);
|
|
4393
|
+
console.warn(tag + kind + " " + message, ...data);
|
|
4391
4394
|
},
|
|
4392
|
-
error: (kind,
|
|
4393
|
-
const
|
|
4395
|
+
error: (kind, code, ...data) => {
|
|
4396
|
+
const message = codeLine(code);
|
|
4397
|
+
const error = errorIn(data);
|
|
4394
4398
|
if (config == null ? void 0 : config.onError) {
|
|
4395
|
-
config.onError({ kind,
|
|
4399
|
+
config.onError({ code, kind, data, message, error });
|
|
4396
4400
|
return;
|
|
4397
4401
|
}
|
|
4398
4402
|
if (config == null ? void 0 : config.muteError) return;
|
|
4399
|
-
|
|
4400
|
-
if (detail === void 0) console.error(line);
|
|
4401
|
-
else console.error(line, detail);
|
|
4403
|
+
console.error(tag + kind + " " + message, ...data);
|
|
4402
4404
|
}
|
|
4403
4405
|
};
|
|
4404
4406
|
}
|
|
@@ -4422,394 +4424,6 @@ function reportDocumentDiagnostics(doc, where) {
|
|
|
4422
4424
|
);
|
|
4423
4425
|
}
|
|
4424
4426
|
|
|
4425
|
-
// src/effects/PlayerEffectsUtil.visualModel.ts
|
|
4426
|
-
var IDENTITY = [1, 0, 0, 1, 0, 0];
|
|
4427
|
-
function mul(m, n) {
|
|
4428
|
-
return [
|
|
4429
|
-
m[0] * n[0] + m[2] * n[1],
|
|
4430
|
-
m[1] * n[0] + m[3] * n[1],
|
|
4431
|
-
m[0] * n[2] + m[2] * n[3],
|
|
4432
|
-
m[1] * n[2] + m[3] * n[3],
|
|
4433
|
-
m[0] * n[4] + m[2] * n[5] + m[4],
|
|
4434
|
-
m[1] * n[4] + m[3] * n[5] + m[5]
|
|
4435
|
-
];
|
|
4436
|
-
}
|
|
4437
|
-
var translateM = (x, y) => [1, 0, 0, 1, x, y];
|
|
4438
|
-
var scaleM = (sx, sy) => [sx, 0, 0, sy, 0, 0];
|
|
4439
|
-
function rotateM(deg) {
|
|
4440
|
-
const r = deg * Math.PI / 180;
|
|
4441
|
-
return [Math.cos(r), Math.sin(r), -Math.sin(r), Math.cos(r), 0, 0];
|
|
4442
|
-
}
|
|
4443
|
-
var skewXM = (deg) => [1, 0, Math.tan(deg * Math.PI / 180), 1, 0, 0];
|
|
4444
|
-
var skewYM = (deg) => [1, Math.tan(deg * Math.PI / 180), 0, 1, 0, 0];
|
|
4445
|
-
function parseTransformString(s) {
|
|
4446
|
-
let m = IDENTITY;
|
|
4447
|
-
const re = /(translate|rotate|scale|matrix|skewX|skewY)\(([^)]*)\)/g;
|
|
4448
|
-
let hit;
|
|
4449
|
-
while (hit = re.exec(s)) {
|
|
4450
|
-
const fn = hit[1];
|
|
4451
|
-
const a = hit[2].split(/[\s,]+/).filter(Boolean).map(Number);
|
|
4452
|
-
if (fn === "translate") m = mul(m, translateM(a[0] || 0, a[1] || 0));
|
|
4453
|
-
else if (fn === "scale") m = mul(m, scaleM(a[0], a.length > 1 ? a[1] : a[0]));
|
|
4454
|
-
else if (fn === "rotate") m = mul(m, rotateM(a[0]));
|
|
4455
|
-
else if (fn === "skewX") m = mul(m, skewXM(a[0]));
|
|
4456
|
-
else if (fn === "skewY") m = mul(m, skewYM(a[0]));
|
|
4457
|
-
else if (fn === "matrix") m = mul(m, [a[0], a[1], a[2], a[3], a[4], a[5]]);
|
|
4458
|
-
}
|
|
4459
|
-
return m;
|
|
4460
|
-
}
|
|
4461
|
-
function partsToMatrix(p) {
|
|
4462
|
-
let m = IDENTITY;
|
|
4463
|
-
if (p.translate) m = mul(m, translateM(p.translate[0], p.translate[1]));
|
|
4464
|
-
const pivot = p.origin && (p.rotate !== void 0 || p.scale);
|
|
4465
|
-
if (pivot) m = mul(m, translateM(p.origin[0], p.origin[1]));
|
|
4466
|
-
if (p.rotate !== void 0) m = mul(m, rotateM(p.rotate));
|
|
4467
|
-
if (p.scale) m = mul(m, scaleM(p.scale[0], p.scale[1]));
|
|
4468
|
-
if (pivot) m = mul(m, translateM(-p.origin[0], -p.origin[1]));
|
|
4469
|
-
return m;
|
|
4470
|
-
}
|
|
4471
|
-
function lerp(a, b, f) {
|
|
4472
|
-
return a + (b - a) * f;
|
|
4473
|
-
}
|
|
4474
|
-
function interpParts(kfs, t) {
|
|
4475
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
4476
|
-
if (!kfs.length) return {};
|
|
4477
|
-
if (t <= ((_a2 = kfs[0].time) != null ? _a2 : 0)) return kfs[0].value || {};
|
|
4478
|
-
if (t >= ((_b = kfs[kfs.length - 1].time) != null ? _b : 0)) return kfs[kfs.length - 1].value || {};
|
|
4479
|
-
let i = 0;
|
|
4480
|
-
while (i < kfs.length - 1 && ((_c = kfs[i + 1].time) != null ? _c : 0) < t) i++;
|
|
4481
|
-
const a = kfs[i], b = kfs[i + 1];
|
|
4482
|
-
const f = (t - ((_d = a.time) != null ? _d : 0)) / (((_e = b.time) != null ? _e : 0) - ((_f = a.time) != null ? _f : 0) || 1);
|
|
4483
|
-
const va = a.value || {}, vb = b.value || {};
|
|
4484
|
-
const out = {};
|
|
4485
|
-
if (va.translate && vb.translate) out.translate = [lerp(va.translate[0], vb.translate[0], f), lerp(va.translate[1], vb.translate[1], f)];
|
|
4486
|
-
else out.translate = va.translate || vb.translate;
|
|
4487
|
-
if (va.rotate !== void 0 && vb.rotate !== void 0) out.rotate = lerp(va.rotate, vb.rotate, f);
|
|
4488
|
-
else out.rotate = (_g = va.rotate) != null ? _g : vb.rotate;
|
|
4489
|
-
if (va.scale && vb.scale) out.scale = [lerp(va.scale[0], vb.scale[0], f), lerp(va.scale[1], vb.scale[1], f)];
|
|
4490
|
-
else out.scale = va.scale || vb.scale;
|
|
4491
|
-
out.origin = va.origin || vb.origin;
|
|
4492
|
-
return out;
|
|
4493
|
-
}
|
|
4494
|
-
function evalTransformValue(v, t) {
|
|
4495
|
-
if (v === void 0 || v === null) return IDENTITY;
|
|
4496
|
-
if (typeof v === "string") return parseTransformString(v);
|
|
4497
|
-
if (v.keyframes) return partsToMatrix(interpParts(v.keyframes, t));
|
|
4498
|
-
if (v.value) return partsToMatrix(v.value);
|
|
4499
|
-
if (typeof v === "object" && !Array.isArray(v)) return partsToMatrix(v);
|
|
4500
|
-
return IDENTITY;
|
|
4501
|
-
}
|
|
4502
|
-
function nodeMatrix(node, t) {
|
|
4503
|
-
if (node.animate && node.animate.transform) return evalTransformValue(node.animate.transform, t);
|
|
4504
|
-
if (node.transform !== void 0) return evalTransformValue(node.transform, t);
|
|
4505
|
-
return IDENTITY;
|
|
4506
|
-
}
|
|
4507
|
-
function evalScalar(animated, staticVal, fallback, t) {
|
|
4508
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
4509
|
-
if (animated && animated.keyframes && animated.keyframes.length) {
|
|
4510
|
-
const kfs = animated.keyframes;
|
|
4511
|
-
if (t <= ((_a2 = kfs[0].time) != null ? _a2 : 0)) return kfs[0].value;
|
|
4512
|
-
if (t >= ((_b = kfs[kfs.length - 1].time) != null ? _b : 0)) return kfs[kfs.length - 1].value;
|
|
4513
|
-
let i = 0;
|
|
4514
|
-
while (i < kfs.length - 1 && ((_c = kfs[i + 1].time) != null ? _c : 0) < t) i++;
|
|
4515
|
-
const a = kfs[i], b = kfs[i + 1];
|
|
4516
|
-
const f = (t - ((_d = a.time) != null ? _d : 0)) / (((_e = b.time) != null ? _e : 0) - ((_f = a.time) != null ? _f : 0) || 1);
|
|
4517
|
-
return lerp(a.value, b.value, f);
|
|
4518
|
-
}
|
|
4519
|
-
return staticVal !== void 0 ? Number(staticVal) : fallback;
|
|
4520
|
-
}
|
|
4521
|
-
var CONTAINER_TYPES = /* @__PURE__ */ new Set(["svg", "g", "symbol"]);
|
|
4522
|
-
var SKIP_TYPES = /* @__PURE__ */ new Set(["defs", "mask", "clipPath", "title"]);
|
|
4523
|
-
function buildIdMap(node, map) {
|
|
4524
|
-
var _a2;
|
|
4525
|
-
if (typeof node.id === "string") map.set(node.id, node);
|
|
4526
|
-
(_a2 = node.children) == null ? void 0 : _a2.forEach((c) => buildIdMap(c, map));
|
|
4527
|
-
}
|
|
4528
|
-
function num(v) {
|
|
4529
|
-
return v === void 0 || v === null ? 0 : Number(v);
|
|
4530
|
-
}
|
|
4531
|
-
function round(n) {
|
|
4532
|
-
return Math.round(n * 100) / 100 + 0;
|
|
4533
|
-
}
|
|
4534
|
-
function geomKey(node) {
|
|
4535
|
-
var _a2;
|
|
4536
|
-
switch (node.type) {
|
|
4537
|
-
case "rect":
|
|
4538
|
-
return num(node.width) + "," + num(node.height) + "," + num(node.x) + "," + num(node.y);
|
|
4539
|
-
case "ellipse":
|
|
4540
|
-
return num(node.rx) + "," + num(node.ry) + "," + num(node.cx) + "," + num(node.cy);
|
|
4541
|
-
case "circle":
|
|
4542
|
-
return num(node.r) + "," + num(node.cx) + "," + num(node.cy);
|
|
4543
|
-
case "path":
|
|
4544
|
-
return String((_a2 = node.d) != null ? _a2 : "");
|
|
4545
|
-
default:
|
|
4546
|
-
return "";
|
|
4547
|
-
}
|
|
4548
|
-
}
|
|
4549
|
-
function describePrimitive(node, m, t) {
|
|
4550
|
-
var _a2, _b, _c, _d, _e;
|
|
4551
|
-
const fill = (_a2 = node.fill) != null ? _a2 : "";
|
|
4552
|
-
const stroke = (_b = node.stroke) != null ? _b : "";
|
|
4553
|
-
const sw = (_d = (_c = node["stroke-width"]) != null ? _c : node.strokeWidth) != null ? _d : "";
|
|
4554
|
-
const opacity = round(evalScalar((_e = node.animate) == null ? void 0 : _e.opacity, node.opacity, 1, t));
|
|
4555
|
-
const masked = node.mask ? 1 : 0;
|
|
4556
|
-
const mat = m.map(round).join(",");
|
|
4557
|
-
return node.type + "|" + geomKey(node) + "|[" + mat + "]|f:" + fill + "|s:" + stroke + "|sw:" + (num(sw) || "") + "|o:" + opacity + "|m:" + masked;
|
|
4558
|
-
}
|
|
4559
|
-
function flatten(node, parent, t, idMap, out) {
|
|
4560
|
-
var _a2;
|
|
4561
|
-
const type = node.type || "";
|
|
4562
|
-
if (SKIP_TYPES.has(type)) return;
|
|
4563
|
-
const m = mul(parent, nodeMatrix(node, t));
|
|
4564
|
-
if (type === "use") {
|
|
4565
|
-
const targetId = typeof node.href === "string" ? node.href.replace(/^#/, "") : "";
|
|
4566
|
-
const target = idMap.get(targetId);
|
|
4567
|
-
const useM = mul(m, translateM(num(node.x), num(node.y)));
|
|
4568
|
-
if (target) flatten(target, useM, t, idMap, out);
|
|
4569
|
-
else out.push("UNRESOLVED_USE:#" + targetId);
|
|
4570
|
-
return;
|
|
4571
|
-
}
|
|
4572
|
-
if (CONTAINER_TYPES.has(type)) {
|
|
4573
|
-
(_a2 = node.children) == null ? void 0 : _a2.forEach((c) => flatten(c, m, t, idMap, out));
|
|
4574
|
-
return;
|
|
4575
|
-
}
|
|
4576
|
-
out.push(describePrimitive(node, m, t));
|
|
4577
|
-
}
|
|
4578
|
-
function collectSampleTimes(node, into) {
|
|
4579
|
-
var _a2;
|
|
4580
|
-
into.add(0);
|
|
4581
|
-
const scanAnim = (anim) => {
|
|
4582
|
-
var _a3;
|
|
4583
|
-
if (!anim || typeof anim !== "object") return;
|
|
4584
|
-
for (const key of Object.keys(anim)) {
|
|
4585
|
-
const kfs = (_a3 = anim[key]) == null ? void 0 : _a3.keyframes;
|
|
4586
|
-
if (Array.isArray(kfs)) kfs.forEach((kf) => {
|
|
4587
|
-
var _a4;
|
|
4588
|
-
return into.add((_a4 = kf.time) != null ? _a4 : 0);
|
|
4589
|
-
});
|
|
4590
|
-
}
|
|
4591
|
-
};
|
|
4592
|
-
scanAnim(node.animate);
|
|
4593
|
-
if (node.transform && typeof node.transform === "object" && node.transform.keyframes) {
|
|
4594
|
-
node.transform.keyframes.forEach((kf) => {
|
|
4595
|
-
var _a3;
|
|
4596
|
-
return into.add((_a3 = kf.time) != null ? _a3 : 0);
|
|
4597
|
-
});
|
|
4598
|
-
}
|
|
4599
|
-
(_a2 = node.children) == null ? void 0 : _a2.forEach((c) => collectSampleTimes(c, into));
|
|
4600
|
-
}
|
|
4601
|
-
function visualModelAt(root, t) {
|
|
4602
|
-
const idMap = /* @__PURE__ */ new Map();
|
|
4603
|
-
buildIdMap(root, idMap);
|
|
4604
|
-
const out = [];
|
|
4605
|
-
flatten(root, IDENTITY, t, idMap, out);
|
|
4606
|
-
return out.sort();
|
|
4607
|
-
}
|
|
4608
|
-
function diffInEffect(a, b) {
|
|
4609
|
-
const times = /* @__PURE__ */ new Set();
|
|
4610
|
-
collectSampleTimes(a, times);
|
|
4611
|
-
collectSampleTimes(b, times);
|
|
4612
|
-
const diffs = [];
|
|
4613
|
-
for (const t of Array.from(times).sort((x, y) => x - y)) {
|
|
4614
|
-
const ma = visualModelAt(a, t);
|
|
4615
|
-
const mb = visualModelAt(b, t);
|
|
4616
|
-
const onlyInA = subtractMultiset(ma, mb);
|
|
4617
|
-
const onlyInB = subtractMultiset(mb, ma);
|
|
4618
|
-
if (onlyInA.length || onlyInB.length) diffs.push({ time: t, onlyInA, onlyInB });
|
|
4619
|
-
}
|
|
4620
|
-
return diffs;
|
|
4621
|
-
}
|
|
4622
|
-
function subtractMultiset(a, b) {
|
|
4623
|
-
const counts = /* @__PURE__ */ new Map();
|
|
4624
|
-
for (const x of b) counts.set(x, (counts.get(x) || 0) + 1);
|
|
4625
|
-
const extra = [];
|
|
4626
|
-
for (const x of a) {
|
|
4627
|
-
const c = counts.get(x) || 0;
|
|
4628
|
-
if (c > 0) counts.set(x, c - 1);
|
|
4629
|
-
else extra.push(x);
|
|
4630
|
-
}
|
|
4631
|
-
return extra;
|
|
4632
|
-
}
|
|
4633
|
-
|
|
4634
|
-
// src/playback/PxScrollMath.ts
|
|
4635
|
-
function isScrollTimeline(config) {
|
|
4636
|
-
return (config == null ? void 0 : config.timelineSource) === "scroll";
|
|
4637
|
-
}
|
|
4638
|
-
function scrollTotalDurationMs(config) {
|
|
4639
|
-
const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration : DEFAULT_DURATION_MS;
|
|
4640
|
-
const iterations = typeof (config == null ? void 0 : config.iterations) === "number" && config.iterations > 0 ? config.iterations : 1;
|
|
4641
|
-
return duration * iterations;
|
|
4642
|
-
}
|
|
4643
|
-
function scrollPhaseInterval(phase, subjectSize, scrollportSize) {
|
|
4644
|
-
const s = subjectSize, vp = scrollportSize;
|
|
4645
|
-
switch (phase) {
|
|
4646
|
-
case "cover":
|
|
4647
|
-
return [0, s + vp];
|
|
4648
|
-
case "entry":
|
|
4649
|
-
return [0, Math.min(s, vp)];
|
|
4650
|
-
case "contain":
|
|
4651
|
-
return [Math.min(s, vp), Math.max(s, vp)];
|
|
4652
|
-
case "exit":
|
|
4653
|
-
return [Math.max(s, vp), s + vp];
|
|
4654
|
-
case "entry-crossing":
|
|
4655
|
-
return [0, s];
|
|
4656
|
-
case "exit-crossing":
|
|
4657
|
-
return [vp, s + vp];
|
|
4658
|
-
}
|
|
4659
|
-
}
|
|
4660
|
-
var DEFAULT_PHASE = "cover";
|
|
4661
|
-
function resolveRangePointU(point, defaultFraction, subjectSize, scrollportSize) {
|
|
4662
|
-
var _a2;
|
|
4663
|
-
const [u0, u1] = scrollPhaseInterval((_a2 = point == null ? void 0 : point.phase) != null ? _a2 : DEFAULT_PHASE, subjectSize, scrollportSize);
|
|
4664
|
-
const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
|
|
4665
|
-
return u0 + fraction * (u1 - u0);
|
|
4666
|
-
}
|
|
4667
|
-
function scrollViewProgress(subjectStart, subjectSize, scrollportSize, range) {
|
|
4668
|
-
const u = scrollportSize - subjectStart;
|
|
4669
|
-
const uStart = resolveRangePointU(range == null ? void 0 : range.start, 0, subjectSize, scrollportSize);
|
|
4670
|
-
const uEnd = resolveRangePointU(range == null ? void 0 : range.end, 1, subjectSize, scrollportSize);
|
|
4671
|
-
if (uEnd <= uStart) return u >= uEnd ? 1 : 0;
|
|
4672
|
-
return clamp((u - uStart) / (uEnd - uStart), 0, 1);
|
|
4673
|
-
}
|
|
4674
|
-
function scrollOffsetProgress(offset, maxOffset, range) {
|
|
4675
|
-
var _a2, _b;
|
|
4676
|
-
const raw = maxOffset > 0 ? clamp(offset / maxOffset, 0, 1) : 1;
|
|
4677
|
-
const start = typeof ((_a2 = range == null ? void 0 : range.start) == null ? void 0 : _a2.fraction) === "number" ? range.start.fraction : 0;
|
|
4678
|
-
const end = typeof ((_b = range == null ? void 0 : range.end) == null ? void 0 : _b.fraction) === "number" ? range.end.fraction : 1;
|
|
4679
|
-
if (end <= start) return raw >= end ? 1 : 0;
|
|
4680
|
-
return clamp((raw - start) / (end - start), 0, 1);
|
|
4681
|
-
}
|
|
4682
|
-
function scrollResolveAxis(axis, writingMode) {
|
|
4683
|
-
const a = axis != null ? axis : "block";
|
|
4684
|
-
if (a === "x" || a === "y") return a;
|
|
4685
|
-
const vertical = !!writingMode && writingMode.startsWith("vertical");
|
|
4686
|
-
if (a === "inline") return vertical ? "y" : "x";
|
|
4687
|
-
return vertical ? "x" : "y";
|
|
4688
|
-
}
|
|
4689
|
-
|
|
4690
|
-
// src/version/PxSchemaFieldUniverse.ts
|
|
4691
|
-
function schemaFieldUniverse(root) {
|
|
4692
|
-
const fields = /* @__PURE__ */ new Set();
|
|
4693
|
-
const enumerated = /* @__PURE__ */ new Set();
|
|
4694
|
-
const queue = [{ schema: root, path: "" }];
|
|
4695
|
-
while (queue.length) {
|
|
4696
|
-
const { schema, path } = queue.shift();
|
|
4697
|
-
const d = describeSchema(schema);
|
|
4698
|
-
switch (d.kind) {
|
|
4699
|
-
case "shape": {
|
|
4700
|
-
if (enumerated.has(schema)) break;
|
|
4701
|
-
enumerated.add(schema);
|
|
4702
|
-
for (const key of Object.keys(d.shape)) {
|
|
4703
|
-
const id = path ? path + "." + key : key;
|
|
4704
|
-
fields.add(id);
|
|
4705
|
-
queue.push({ schema: d.shape[key], path: id });
|
|
4706
|
-
}
|
|
4707
|
-
if (d.openValue) queue.push({ schema: d.openValue, path: path + "{*}" });
|
|
4708
|
-
break;
|
|
4709
|
-
}
|
|
4710
|
-
case "optional":
|
|
4711
|
-
queue.push({ schema: d.inner, path });
|
|
4712
|
-
break;
|
|
4713
|
-
case "array":
|
|
4714
|
-
queue.push({ schema: d.item, path: path + "[]" });
|
|
4715
|
-
break;
|
|
4716
|
-
case "lazy":
|
|
4717
|
-
queue.push({ schema: d.resolved, path });
|
|
4718
|
-
break;
|
|
4719
|
-
case "record":
|
|
4720
|
-
queue.push({ schema: d.value, path: path + "{*}" });
|
|
4721
|
-
break;
|
|
4722
|
-
case "union":
|
|
4723
|
-
d.members.forEach((member, i) => queue.push({ schema: member, path: path + "|" + i }));
|
|
4724
|
-
break;
|
|
4725
|
-
case "discriminatedUnion":
|
|
4726
|
-
for (const member of d.members) queue.push({ schema: member, path: path + "|" + discriminantOf(member, d.key) });
|
|
4727
|
-
break;
|
|
4728
|
-
default:
|
|
4729
|
-
break;
|
|
4730
|
-
}
|
|
4731
|
-
}
|
|
4732
|
-
return [...fields].sort();
|
|
4733
|
-
}
|
|
4734
|
-
function discriminantOf(member, key) {
|
|
4735
|
-
const d = describeSchema(member);
|
|
4736
|
-
if (d.kind !== "shape") return "?";
|
|
4737
|
-
const keySchema = d.shape[key];
|
|
4738
|
-
if (keySchema === void 0) return "?";
|
|
4739
|
-
const kd = describeSchema(keySchema);
|
|
4740
|
-
return String((kd.kind === "optional" ? kd.inner : keySchema)._default);
|
|
4741
|
-
}
|
|
4742
|
-
|
|
4743
|
-
// src/version/PxSchemaRelease.ts
|
|
4744
|
-
function diffFieldUniverse(previous, current) {
|
|
4745
|
-
const prev = new Set(previous);
|
|
4746
|
-
const cur = new Set(current);
|
|
4747
|
-
return {
|
|
4748
|
-
added: current.filter((k) => !prev.has(k)).sort(),
|
|
4749
|
-
removed: previous.filter((k) => !cur.has(k)).sort()
|
|
4750
|
-
};
|
|
4751
|
-
}
|
|
4752
|
-
function planSchemaRelease(p) {
|
|
4753
|
-
const changed = p.added.length > 0 || p.removed.length > 0;
|
|
4754
|
-
const last = parseWireVersion(p.lastReleased);
|
|
4755
|
-
const declared = parseWireVersion(p.declared);
|
|
4756
|
-
if (!last || !declared) return { changed, refuse: "Unparseable version: " + p.lastReleased + " / " + p.declared + "." };
|
|
4757
|
-
const requiredVersion = last.a + "." + (last.b + 1);
|
|
4758
|
-
if (!changed) {
|
|
4759
|
-
if (declared.b === last.b && declared.a === last.a) return { changed };
|
|
4760
|
-
const step2 = p.steps.find((s) => s.to === p.declared);
|
|
4761
|
-
return step2 ? { changed, requiredVersion: p.declared } : { changed, refuse: "The version moved to " + p.declared + " with no key change and no step explaining it." };
|
|
4762
|
-
}
|
|
4763
|
-
const requiredKind = p.removed.length ? "converted" /* converted */ : "additive" /* additive */;
|
|
4764
|
-
const summary = p.added.length + " key(s) added, " + p.removed.length + " removed";
|
|
4765
|
-
if (declared.a !== last.a || declared.b !== last.b + 1) {
|
|
4766
|
-
return {
|
|
4767
|
-
changed,
|
|
4768
|
-
requiredKind,
|
|
4769
|
-
requiredVersion,
|
|
4770
|
-
refuse: "The player schema changed (" + summary + ") but PX_PLAYER_SCHEMA_VERSION is " + p.declared + ". Set it to " + requiredVersion + " and add the PLAYER_WIRE_STEPS entry."
|
|
4771
|
-
};
|
|
4772
|
-
}
|
|
4773
|
-
const step = p.steps.find((s) => s.to === p.declared);
|
|
4774
|
-
if (!step) {
|
|
4775
|
-
return { changed, requiredKind, requiredVersion, refuse: "No PLAYER_WIRE_STEPS entry reaches " + p.declared + "." };
|
|
4776
|
-
}
|
|
4777
|
-
if (requiredKind === "converted" /* converted */ && step.kind !== "converted" /* converted */) {
|
|
4778
|
-
return {
|
|
4779
|
-
changed,
|
|
4780
|
-
requiredKind,
|
|
4781
|
-
requiredVersion,
|
|
4782
|
-
refuse: "Keys were REMOVED (" + p.removed.join(", ") + "), which is never additive \u2014 the " + p.declared + " step must be `converted`, with an up()."
|
|
4783
|
-
};
|
|
4784
|
-
}
|
|
4785
|
-
return { changed, requiredKind, requiredVersion };
|
|
4786
|
-
}
|
|
4787
|
-
function releaseLogProblems(releases, steps, declared, baseline) {
|
|
4788
|
-
const problems = [];
|
|
4789
|
-
if (!releases.length) return ["The release log is empty."];
|
|
4790
|
-
if (!releases[0].baseline || releases[0].version !== baseline) {
|
|
4791
|
-
problems.push("The first release must be the baseline " + baseline + ".");
|
|
4792
|
-
}
|
|
4793
|
-
for (let i = 1; i < releases.length; i++) {
|
|
4794
|
-
const prev = parseWireVersion(releases[i - 1].version);
|
|
4795
|
-
const cur = parseWireVersion(releases[i].version);
|
|
4796
|
-
if (!prev || !cur || cur.a !== prev.a || cur.b !== prev.b + 1) {
|
|
4797
|
-
problems.push("Release " + releases[i].version + " does not follow " + releases[i - 1].version + " by one `b` step.");
|
|
4798
|
-
}
|
|
4799
|
-
if (releases[i].date < releases[i - 1].date) problems.push("Release " + releases[i].version + " is dated before its predecessor.");
|
|
4800
|
-
const step = steps.find((s) => s.to === releases[i].version);
|
|
4801
|
-
if (!step) problems.push("Release " + releases[i].version + " has no PLAYER_WIRE_STEPS entry.");
|
|
4802
|
-
else if (releases[i].removed.length && step.kind !== "converted" /* converted */) {
|
|
4803
|
-
problems.push("Release " + releases[i].version + " removed keys, but its step is not `converted`.");
|
|
4804
|
-
}
|
|
4805
|
-
}
|
|
4806
|
-
const latest = releases[releases.length - 1].version;
|
|
4807
|
-
if (latest !== declared) {
|
|
4808
|
-
problems.push("PX_PLAYER_SCHEMA_VERSION is " + declared + " but the last release record is " + latest + " \u2014 a bump needs its changelog entry (run scripts/schema-release.mjs --apply).");
|
|
4809
|
-
}
|
|
4810
|
-
return problems;
|
|
4811
|
-
}
|
|
4812
|
-
|
|
4813
4427
|
export {
|
|
4814
4428
|
__spreadValues,
|
|
4815
4429
|
__spreadProps,
|
|
@@ -4817,21 +4431,21 @@ export {
|
|
|
4817
4431
|
schemaKeys,
|
|
4818
4432
|
describeSchema,
|
|
4819
4433
|
px,
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4434
|
+
PX_WIRE_SCHEMA_VERSION,
|
|
4435
|
+
PX_WIRE_VERSION_KEY,
|
|
4436
|
+
PxWireVersionRelation,
|
|
4823
4437
|
parseWireVersion,
|
|
4824
4438
|
formatWireVersion,
|
|
4825
|
-
|
|
4439
|
+
PX_WIRE_VERSION,
|
|
4826
4440
|
readWireVersion,
|
|
4827
4441
|
compareWireVersion,
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4442
|
+
wireVersionAdvice,
|
|
4443
|
+
PxWireStepKind,
|
|
4444
|
+
PX_WIRE_BASELINE_VERSION,
|
|
4445
|
+
PX_WIRE_STEPS,
|
|
4832
4446
|
applyWireSteps,
|
|
4833
|
-
|
|
4834
|
-
|
|
4447
|
+
convertWireDocument,
|
|
4448
|
+
downgradeWireDocument,
|
|
4835
4449
|
PxFillMode,
|
|
4836
4450
|
PxPlaybackDirection,
|
|
4837
4451
|
PX_ANIM_SRC_ATTR_NAME,
|
|
@@ -4848,7 +4462,7 @@ export {
|
|
|
4848
4462
|
PX_TIMELINE_SHARED_KEYS,
|
|
4849
4463
|
PX_TIME_ONLY_TIMELINE_KEYS,
|
|
4850
4464
|
PxTimelineEngine,
|
|
4851
|
-
|
|
4465
|
+
PxTimelineEngineSetting,
|
|
4852
4466
|
resolveTimelineEngine,
|
|
4853
4467
|
isNativeForced,
|
|
4854
4468
|
mayUseNativeScrollTimeline,
|
|
@@ -4867,34 +4481,34 @@ export {
|
|
|
4867
4481
|
PxTextPathMethod,
|
|
4868
4482
|
PxTextPathSpacing,
|
|
4869
4483
|
PxStrokeTrimSubPaths,
|
|
4870
|
-
|
|
4484
|
+
PX_TEXT_CONTENT_ATTR,
|
|
4871
4485
|
TRANSFORM_ATTR,
|
|
4872
4486
|
OFFSET_DISTANCE_ATTR,
|
|
4873
4487
|
TRANSFORM_PART,
|
|
4874
4488
|
PX_TRANSFORM_PART_KEYS,
|
|
4875
4489
|
PxGradientSpreadMethod,
|
|
4876
4490
|
PxGradientType,
|
|
4877
|
-
|
|
4491
|
+
isPxDocument,
|
|
4878
4492
|
getAnimatorConfig,
|
|
4879
4493
|
flattenAnimatorTimeline,
|
|
4880
4494
|
nestAnimatorTimeline,
|
|
4881
|
-
|
|
4495
|
+
getDefinitions,
|
|
4882
4496
|
getBindings,
|
|
4883
4497
|
getChildren,
|
|
4884
4498
|
PxKeyframeValueSchema,
|
|
4885
4499
|
PxKeyframeSchema,
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4500
|
+
keyframeTime,
|
|
4501
|
+
keyframeValue,
|
|
4502
|
+
keyframeEasing,
|
|
4503
|
+
keyframeTangentIn,
|
|
4504
|
+
keyframeTangentOut,
|
|
4891
4505
|
PxLoopSchema,
|
|
4892
4506
|
PxPropertyAnimationSchema,
|
|
4893
4507
|
PxTransformPartsSchema,
|
|
4894
4508
|
PxTransformValueSchema,
|
|
4895
4509
|
PxElementAnimationSchema,
|
|
4896
4510
|
PxTriggerSchema,
|
|
4897
|
-
|
|
4511
|
+
PxDefinitionsSchema,
|
|
4898
4512
|
PxScrollRangePointSchema,
|
|
4899
4513
|
PxScrollRangeSchema,
|
|
4900
4514
|
PxScrollSchema,
|
|
@@ -4915,12 +4529,12 @@ export {
|
|
|
4915
4529
|
PxEffectsSchema,
|
|
4916
4530
|
validateNodeEffects,
|
|
4917
4531
|
validateDocument,
|
|
4918
|
-
|
|
4532
|
+
PxNodeBaseSchema,
|
|
4919
4533
|
PxNodeSchema,
|
|
4920
|
-
|
|
4534
|
+
PxSvgNodeRootSchema,
|
|
4921
4535
|
PxAnimatedSvgDocumentSchema,
|
|
4922
4536
|
PxBezierPathSchema,
|
|
4923
|
-
|
|
4537
|
+
isValidPxDocument,
|
|
4924
4538
|
generateUniqueId,
|
|
4925
4539
|
deepClone,
|
|
4926
4540
|
generateNewIds,
|
|
@@ -4930,28 +4544,28 @@ export {
|
|
|
4930
4544
|
splitEasing,
|
|
4931
4545
|
reverseEasing,
|
|
4932
4546
|
toRGBA,
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4547
|
+
PX_COLOR_ATTR_NAMES,
|
|
4548
|
+
PX_TRANSFORM_FN_NAMES,
|
|
4549
|
+
PX_PCT_BASED_ATTR_NAMES,
|
|
4936
4550
|
composeTransformParts,
|
|
4937
|
-
|
|
4938
|
-
|
|
4551
|
+
PX_STYLE_ATTR_NAMES,
|
|
4552
|
+
PX_DEFAULT_DURATION_MS,
|
|
4939
4553
|
kebabToCamelCaseWord,
|
|
4940
4554
|
camelCaseToKebabWordIfNeeded,
|
|
4941
4555
|
clamp,
|
|
4942
4556
|
bezier2D_arcLengthLUT,
|
|
4943
|
-
|
|
4944
|
-
|
|
4557
|
+
PX_DISALLOWED_SVG_TAGS_LOWER,
|
|
4558
|
+
PX_CSS_ONLY_STYLE_PROPS,
|
|
4945
4559
|
sanitizeAttributeValue,
|
|
4946
|
-
|
|
4560
|
+
toDomProps,
|
|
4947
4561
|
materializeMotionPathInPropAnim,
|
|
4948
4562
|
materializeMotionPathsInTree,
|
|
4949
|
-
|
|
4563
|
+
PX_LOOP_JUMP_SHIFT_MS,
|
|
4950
4564
|
parseSvgPathToBezier,
|
|
4951
4565
|
interpolateValue,
|
|
4952
4566
|
materializeInternalLoopsInTree,
|
|
4953
4567
|
mergeStaticTransformIntoAnimDef,
|
|
4954
|
-
|
|
4568
|
+
normalizeBindings,
|
|
4955
4569
|
calcAnimationValues,
|
|
4956
4570
|
partsRecord,
|
|
4957
4571
|
readAnimatable,
|
|
@@ -4978,17 +4592,6 @@ export {
|
|
|
4978
4592
|
PxDiagnosticKind,
|
|
4979
4593
|
createDiagnostics,
|
|
4980
4594
|
diagnoseDocument,
|
|
4981
|
-
reportDocumentDiagnostics
|
|
4982
|
-
diffInEffect,
|
|
4983
|
-
isScrollTimeline,
|
|
4984
|
-
scrollTotalDurationMs,
|
|
4985
|
-
scrollPhaseInterval,
|
|
4986
|
-
scrollViewProgress,
|
|
4987
|
-
scrollOffsetProgress,
|
|
4988
|
-
scrollResolveAxis,
|
|
4989
|
-
schemaFieldUniverse,
|
|
4990
|
-
diffFieldUniverse,
|
|
4991
|
-
planSchemaRelease,
|
|
4992
|
-
releaseLogProblems
|
|
4595
|
+
reportDocumentDiagnostics
|
|
4993
4596
|
};
|
|
4994
|
-
//# sourceMappingURL=chunk-
|
|
4597
|
+
//# sourceMappingURL=chunk-BOTZI36B.js.map
|