@pixodesk/svg-animator-web 1.0.22 → 1.0.24
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 +3 -3
- package/dist/index.cjs +573 -421
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +571 -420
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.prerendered-waapi.umd.js +1687 -0
- package/dist/index.prerendered-waapi.umd.js.map +1 -0
- package/dist/index.prerendered-waapi.umd.min.js +1 -0
- package/dist/index.prerendered.umd.js +2200 -0
- package/dist/index.prerendered.umd.js.map +1 -0
- package/dist/index.prerendered.umd.min.js +1 -0
- package/dist/index.umd.js +716 -987
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +17 -12
package/dist/index.js
CHANGED
|
@@ -184,8 +184,9 @@ var Union = class extends Base {
|
|
|
184
184
|
}
|
|
185
185
|
isValid(raw, ctx, path) {
|
|
186
186
|
var _a;
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
const probe = ctx && { errors: [], warnings: [], strict: ctx.strict };
|
|
188
|
+
if (this.schemas.some((s) => s.isValid(raw, probe, path ? [...path] : void 0))) return true;
|
|
189
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": no union member matched for value " + ((_a = JSON.stringify(raw)) != null ? _a : "").slice(0, 240));
|
|
189
190
|
return false;
|
|
190
191
|
}
|
|
191
192
|
_canSanitize(raw) {
|
|
@@ -261,6 +262,7 @@ var Obj = class extends Base {
|
|
|
261
262
|
if (ctx == null ? void 0 : ctx.strict) {
|
|
262
263
|
for (const key of Object.keys(obj)) {
|
|
263
264
|
if (key in this._shape) continue;
|
|
265
|
+
if (obj[key] === void 0) continue;
|
|
264
266
|
p.push(key);
|
|
265
267
|
ctx.errors.push(pathStr(p) + ": unexpected extra key");
|
|
266
268
|
p.pop();
|
|
@@ -401,6 +403,23 @@ var Any = class extends Base {
|
|
|
401
403
|
return true;
|
|
402
404
|
}
|
|
403
405
|
};
|
|
406
|
+
var Defined = class extends Base {
|
|
407
|
+
constructor() {
|
|
408
|
+
super(...arguments);
|
|
409
|
+
this._default = void 0;
|
|
410
|
+
}
|
|
411
|
+
sanitize(raw) {
|
|
412
|
+
return raw;
|
|
413
|
+
}
|
|
414
|
+
isValid(raw, ctx, path) {
|
|
415
|
+
if (raw !== void 0) return true;
|
|
416
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": required value is missing");
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
_canSanitize(raw) {
|
|
420
|
+
return raw !== void 0;
|
|
421
|
+
}
|
|
422
|
+
};
|
|
404
423
|
var Lazy = class extends Base {
|
|
405
424
|
constructor(fn, _default) {
|
|
406
425
|
super();
|
|
@@ -512,6 +531,8 @@ var px = {
|
|
|
512
531
|
record: (value) => new Rec(value),
|
|
513
532
|
/** Passes anything through unchanged — always valid. */
|
|
514
533
|
any: () => new Any(),
|
|
534
|
+
/** Anything EXCEPT `undefined` — an open type whose presence is required (V6). */
|
|
535
|
+
defined: () => new Defined(),
|
|
515
536
|
/** Fixed-length tuple — validates element count and each position individually. */
|
|
516
537
|
tuple: (schemas) => new Tuple(schemas),
|
|
517
538
|
/** Defers schema creation — required for recursive types. Must supply a default value. */
|
|
@@ -521,13 +542,52 @@ var PX_ANIM_SRC_ATTR_NAME = "data-px-animation-src";
|
|
|
521
542
|
var PX_ANIM_ATTR_NAME = "_px_animator";
|
|
522
543
|
var PxAnimatorMode = {
|
|
523
544
|
auto: "auto",
|
|
524
|
-
|
|
545
|
+
waapi: "waapi",
|
|
525
546
|
frames: "frames"
|
|
526
547
|
};
|
|
527
548
|
var PxAnimatorEngine = {
|
|
528
|
-
|
|
549
|
+
waapi: PxAnimatorMode.waapi,
|
|
529
550
|
frames: PxAnimatorMode.frames
|
|
530
551
|
};
|
|
552
|
+
var PxLoopExtend = {
|
|
553
|
+
/** Segment from the START; the animation is extended BEFORE the first keyframe
|
|
554
|
+
* (intro loops that run before the main timeline begins). */
|
|
555
|
+
before: "before",
|
|
556
|
+
/** DEFAULT — segment from the END; extended AFTER the last keyframe (idle/outro
|
|
557
|
+
* loops that continue once the main timeline has finished). */
|
|
558
|
+
after: "after"
|
|
559
|
+
};
|
|
560
|
+
var PxMaskType = {
|
|
561
|
+
luminance: "luminance",
|
|
562
|
+
alpha: "alpha"
|
|
563
|
+
};
|
|
564
|
+
var PxUnits = {
|
|
565
|
+
userSpaceOnUse: "userSpaceOnUse",
|
|
566
|
+
objectBoundingBox: "objectBoundingBox"
|
|
567
|
+
};
|
|
568
|
+
var PxCloneType = {
|
|
569
|
+
content: "content"
|
|
570
|
+
};
|
|
571
|
+
var PxPathOverflow = {
|
|
572
|
+
clip: "clip",
|
|
573
|
+
extend: "extend"
|
|
574
|
+
};
|
|
575
|
+
var PxLengthAdjust = {
|
|
576
|
+
spacing: "spacing",
|
|
577
|
+
spacingAndGlyphs: "spacingAndGlyphs"
|
|
578
|
+
};
|
|
579
|
+
var PxTextPathMethod = {
|
|
580
|
+
align: "align",
|
|
581
|
+
stretch: "stretch"
|
|
582
|
+
};
|
|
583
|
+
var PxTextPathSpacing = {
|
|
584
|
+
auto: "auto",
|
|
585
|
+
exact: "exact"
|
|
586
|
+
};
|
|
587
|
+
var PxTrimSubPaths = {
|
|
588
|
+
separate: "separate",
|
|
589
|
+
combined: "combined"
|
|
590
|
+
};
|
|
531
591
|
var TEXT_ATTR = "text";
|
|
532
592
|
var TEXT_CONTENT_ATTR = "textContent";
|
|
533
593
|
var INTERNAL_ATTRS = /* @__PURE__ */ new Set([
|
|
@@ -536,9 +596,49 @@ var INTERNAL_ATTRS = /* @__PURE__ */ new Set([
|
|
|
536
596
|
"animator",
|
|
537
597
|
"meta",
|
|
538
598
|
"animate",
|
|
599
|
+
"effects",
|
|
539
600
|
TEXT_ATTR,
|
|
540
601
|
TEXT_CONTENT_ATTR
|
|
541
602
|
]);
|
|
603
|
+
var PX_TRANSFORM_PART_KEYS = ["translate", "rotate", "scale", "origin"];
|
|
604
|
+
var PxGradientUnits = {
|
|
605
|
+
userSpaceOnUse: "userSpaceOnUse",
|
|
606
|
+
objectBoundingBox: "objectBoundingBox"
|
|
607
|
+
};
|
|
608
|
+
var PxGradientSpreadMethod = {
|
|
609
|
+
pad: "pad",
|
|
610
|
+
reflect: "reflect",
|
|
611
|
+
repeat: "repeat"
|
|
612
|
+
};
|
|
613
|
+
var PxGradientType = {
|
|
614
|
+
linear: "linear",
|
|
615
|
+
radial: "radial"
|
|
616
|
+
};
|
|
617
|
+
function isPxElementFileFormat(fileJson) {
|
|
618
|
+
if (!(fileJson && typeof fileJson === "object" && !Array.isArray(fileJson))) {
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
return fileJson["type"] === "svg";
|
|
622
|
+
}
|
|
623
|
+
function getAnimatorConfig(doc) {
|
|
624
|
+
var _a;
|
|
625
|
+
return (doc == null ? void 0 : doc.animator) || ((_a = doc == null ? void 0 : doc.meta) == null ? void 0 : _a.animator);
|
|
626
|
+
}
|
|
627
|
+
function getDefs(doc) {
|
|
628
|
+
var _a;
|
|
629
|
+
if (!doc) return void 0;
|
|
630
|
+
return (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.definitions;
|
|
631
|
+
}
|
|
632
|
+
function getBindings(doc) {
|
|
633
|
+
var _a;
|
|
634
|
+
if (!doc) return void 0;
|
|
635
|
+
const animateById = (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.animateById;
|
|
636
|
+
if (!animateById) return void 0;
|
|
637
|
+
return Object.entries(animateById).map(([id, anim]) => ({ id, animate: anim }));
|
|
638
|
+
}
|
|
639
|
+
function getChildren(doc) {
|
|
640
|
+
return doc == null ? void 0 : doc.children;
|
|
641
|
+
}
|
|
542
642
|
var PxEasingOrRefSchema = px.union([
|
|
543
643
|
px.string(),
|
|
544
644
|
px.tuple([px.number(), px.number(), px.number(), px.number()])
|
|
@@ -550,13 +650,15 @@ var PxKeyframeValueSchema = implementsInterface()(px.union([
|
|
|
550
650
|
px.array(px.number()),
|
|
551
651
|
px.lazy(() => PxTransformPartsSchema, {}),
|
|
552
652
|
px.object({ path: px.string() }),
|
|
553
|
-
px.lazy(() => px.object({ paths: px.array(PxBezierPathSchema) }), { paths: [] })
|
|
653
|
+
px.lazy(() => px.object({ paths: px.array(PxBezierPathSchema) }), { paths: [] }),
|
|
654
|
+
// Gradient `stops` timeline — each kf value is the full stops-array snapshot.
|
|
655
|
+
px.lazy(() => px.array(PxGradientStopSchema), [])
|
|
554
656
|
]));
|
|
555
657
|
var PxKeyframeSchema = implementsInterface()(px.object({
|
|
556
658
|
time: px.number().optional(),
|
|
557
659
|
t: px.number().optional(),
|
|
558
|
-
value:
|
|
559
|
-
v:
|
|
660
|
+
value: PxKeyframeValueSchema.optional(),
|
|
661
|
+
v: PxKeyframeValueSchema.optional(),
|
|
560
662
|
easing: PxEasingOrRefSchema.optional(),
|
|
561
663
|
e: PxEasingOrRefSchema.optional(),
|
|
562
664
|
tangentOut: px.tuple([px.number(), px.number()]).optional(),
|
|
@@ -570,16 +672,16 @@ var PxKeyframeSchema = implementsInterface()(px.object({
|
|
|
570
672
|
}));
|
|
571
673
|
var PxLoopSchema = implementsInterface()(px.object({
|
|
572
674
|
segmentCount: px.number().optional(),
|
|
573
|
-
|
|
675
|
+
extend: px.enum([PxLoopExtend.before, PxLoopExtend.after]).optional(),
|
|
574
676
|
alternate: px.boolean().optional()
|
|
575
677
|
}));
|
|
576
678
|
var PxPropertyAnimationSchema = implementsInterface()(px.object({
|
|
679
|
+
value: PxKeyframeValueSchema.optional(),
|
|
577
680
|
keyframes: px.array(PxKeyframeSchema).optional(),
|
|
578
681
|
kfs: px.array(PxKeyframeSchema).optional(),
|
|
579
682
|
loop: px.union([PxLoopSchema, px.boolean()]).optional(),
|
|
580
683
|
autoOrient: px.boolean().optional()
|
|
581
684
|
}));
|
|
582
|
-
var PX_TRANSFORM_PART_KEYS = ["translate", "rotate", "scale", "origin"];
|
|
583
685
|
var PxTransformPartsSchema = implementsInterface()(px.object({
|
|
584
686
|
translate: px.tuple([px.number(), px.number()]).optional(),
|
|
585
687
|
rotate: px.number().optional(),
|
|
@@ -589,6 +691,7 @@ var PxTransformPartsSchema = implementsInterface()(px.object({
|
|
|
589
691
|
}));
|
|
590
692
|
var PxTransformValueSchema = px.union([
|
|
591
693
|
px.string(),
|
|
694
|
+
PxTransformPartsSchema,
|
|
592
695
|
px.object({ value: PxTransformPartsSchema }),
|
|
593
696
|
PxPropertyAnimationSchema
|
|
594
697
|
]);
|
|
@@ -623,9 +726,11 @@ var PxDefsSchema = implementsInterface()(px.object({
|
|
|
623
726
|
glyphs: px.record(PxGlyphFontSchema).optional()
|
|
624
727
|
}));
|
|
625
728
|
var PxAnimatorConfigSchema = implementsInterface()(px.object({
|
|
626
|
-
mode: px.enum([PxAnimatorMode.auto, PxAnimatorMode.
|
|
729
|
+
mode: px.enum([PxAnimatorMode.auto, PxAnimatorMode.waapi, PxAnimatorMode.frames]).optional(),
|
|
627
730
|
duration: px.number().optional(),
|
|
628
731
|
delay: px.number().optional(),
|
|
732
|
+
// LAW (SCHEMA-DESIGN R3, S10): the ONE sanctioned string-in-number union
|
|
733
|
+
// (CSS animation-iteration-count familiarity) — do not add more mixed unions.
|
|
629
734
|
iterations: px.union([px.number(), px.literal("infinite")]).optional(),
|
|
630
735
|
fill: px.enum(["forwards", "backwards", "both", "none"]).optional(),
|
|
631
736
|
direction: px.enum(["normal", "reverse", "alternate", "alternate-reverse"]).optional(),
|
|
@@ -633,9 +738,8 @@ var PxAnimatorConfigSchema = implementsInterface()(px.object({
|
|
|
633
738
|
trigger: PxTriggerSchema.optional(),
|
|
634
739
|
resetOnFinish: px.boolean().optional(),
|
|
635
740
|
definitions: PxDefsSchema.optional(),
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
debug: px.boolean().optional(),
|
|
741
|
+
animateById: px.record(PxElementAnimationSchema).optional(),
|
|
742
|
+
timelineSource: px.string().optional(),
|
|
639
743
|
debugInstName: px.string().optional()
|
|
640
744
|
}));
|
|
641
745
|
var PxBindingSchema = implementsInterface()(px.object({
|
|
@@ -645,26 +749,29 @@ var PxBindingSchema = implementsInterface()(px.object({
|
|
|
645
749
|
var PxAttrValueSchema = px.union([
|
|
646
750
|
px.string(),
|
|
647
751
|
px.number(),
|
|
648
|
-
px.
|
|
649
|
-
|
|
752
|
+
px.array(px.number()),
|
|
753
|
+
// Structured static — `{value: …}` (read-accepted transitional spelling, S1).
|
|
754
|
+
// `defined`, not `any`: the KEY's presence is what identifies this branch (V6).
|
|
755
|
+
px.object({ value: px.defined() }),
|
|
756
|
+
// Bare transform parts record — the canonical static `transform` on the wire (T2).
|
|
757
|
+
PxTransformPartsSchema
|
|
650
758
|
]);
|
|
651
759
|
var PxAnimatableNumberSchema = px.union([
|
|
652
760
|
px.number(),
|
|
653
761
|
px.object({ value: px.number() }),
|
|
654
|
-
|
|
655
|
-
keyframes: px.array(PxKeyframeSchema),
|
|
656
|
-
autoOrient: px.boolean().optional()
|
|
657
|
-
})
|
|
762
|
+
PxPropertyAnimationSchema
|
|
658
763
|
]);
|
|
659
764
|
var PxAnimatableVec2Schema = px.union([
|
|
660
765
|
px.tuple([px.number(), px.number()]),
|
|
661
766
|
px.object({ value: px.tuple([px.number(), px.number()]) }),
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
767
|
+
PxPropertyAnimationSchema
|
|
768
|
+
]);
|
|
769
|
+
var PxAnimatableStringSchema = px.union([
|
|
770
|
+
px.string(),
|
|
771
|
+
px.object({ value: px.string() }),
|
|
772
|
+
PxPropertyAnimationSchema
|
|
666
773
|
]);
|
|
667
|
-
var
|
|
774
|
+
var PxTransformByEffectSchema = implementsInterface()(px.object({
|
|
668
775
|
translate: PxAnimatableVec2Schema.optional(),
|
|
669
776
|
rotate: PxAnimatableNumberSchema.optional(),
|
|
670
777
|
scale: PxAnimatableVec2Schema.optional(),
|
|
@@ -672,51 +779,46 @@ var PxTransformationEffectSchema = implementsInterface()(px.object({
|
|
|
672
779
|
origin: PxAnimatableVec2Schema.optional()
|
|
673
780
|
}));
|
|
674
781
|
var PxRepeaterEffectSchema = implementsInterface()(px.object({
|
|
782
|
+
// STATIC config, not a channel (V2/SCHEMA-DESIGN R5): the copy COUNT is read
|
|
783
|
+
// once at expansion time and never sampled — plain number, no `keyframes`.
|
|
675
784
|
copies: px.number().optional(),
|
|
676
785
|
translate: PxAnimatableVec2Schema.optional(),
|
|
677
786
|
rotate: PxAnimatableNumberSchema.optional(),
|
|
787
|
+
skew: PxAnimatableNumberSchema.optional(),
|
|
678
788
|
scale: PxAnimatableVec2Schema.optional(),
|
|
679
789
|
origin: PxAnimatableVec2Schema.optional()
|
|
680
790
|
}));
|
|
681
791
|
var PxMaskedByEffectSchema = implementsInterface()(px.object({
|
|
682
|
-
|
|
683
|
-
maskType: px.
|
|
684
|
-
maskUnits: px.
|
|
685
|
-
maskContentUnits: px.
|
|
792
|
+
sourceId: px.string().optional(),
|
|
793
|
+
maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha]).optional(),
|
|
794
|
+
maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
795
|
+
maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
796
|
+
x: px.number().optional(),
|
|
797
|
+
y: px.number().optional(),
|
|
798
|
+
width: px.number().optional(),
|
|
799
|
+
height: px.number().optional()
|
|
686
800
|
}));
|
|
687
801
|
var PxClipPathEffectSchema = implementsInterface()(px.object({
|
|
688
|
-
d:
|
|
802
|
+
d: PxAnimatableStringSchema.optional(),
|
|
689
803
|
animate: PxPropertyAnimationSchema.optional()
|
|
690
804
|
}));
|
|
691
805
|
var PxTrimPathEffectSchema = implementsInterface()(px.object({
|
|
692
806
|
offset: PxAnimatableNumberSchema.optional(),
|
|
693
807
|
range: PxAnimatableVec2Schema.optional(),
|
|
694
|
-
|
|
808
|
+
subPaths: px.enum([PxTrimSubPaths.separate, PxTrimSubPaths.combined]).optional()
|
|
695
809
|
}));
|
|
696
810
|
var PxRetimeEffectSchema = implementsInterface()(px.object({
|
|
697
|
-
|
|
811
|
+
sourceId: px.string().optional(),
|
|
698
812
|
start: px.number().optional(),
|
|
699
813
|
stretch: px.number().optional(),
|
|
700
814
|
timeCrop: px.tuple([px.number(), px.number()]).optional()
|
|
701
815
|
}));
|
|
702
816
|
var PxCloneEffectSchema = implementsInterface()(px.object({
|
|
703
|
-
type
|
|
704
|
-
|
|
817
|
+
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
818
|
+
type: px.enum([PxCloneType.content]).optional(),
|
|
819
|
+
sourceId: px.string().optional(),
|
|
705
820
|
retime: PxRetimeEffectSchema.optional()
|
|
706
821
|
}));
|
|
707
|
-
var PxGradientUnits = {
|
|
708
|
-
userSpaceOnUse: "userSpaceOnUse",
|
|
709
|
-
objectBoundingBox: "objectBoundingBox"
|
|
710
|
-
};
|
|
711
|
-
var PxGradientSpreadMethod = {
|
|
712
|
-
pad: "pad",
|
|
713
|
-
reflect: "reflect",
|
|
714
|
-
repeat: "repeat"
|
|
715
|
-
};
|
|
716
|
-
var PxGradientType = {
|
|
717
|
-
linear: "linear",
|
|
718
|
-
radial: "radial"
|
|
719
|
-
};
|
|
720
822
|
var PxGradientStopSchema = implementsInterface()(px.object({
|
|
721
823
|
offset: px.number(),
|
|
722
824
|
color: px.string()
|
|
@@ -724,39 +826,28 @@ var PxGradientStopSchema = implementsInterface()(px.object({
|
|
|
724
826
|
var PxAnimatableGradientStopsSchema = px.union([
|
|
725
827
|
px.array(PxGradientStopSchema),
|
|
726
828
|
px.object({ value: px.array(PxGradientStopSchema) }),
|
|
727
|
-
|
|
829
|
+
PxPropertyAnimationSchema
|
|
728
830
|
]);
|
|
729
|
-
var PxGradientGeometryAnimationSchema = implementsInterface()(px.object({
|
|
730
|
-
gradientX1: PxPropertyAnimationSchema.optional(),
|
|
731
|
-
gradientY1: PxPropertyAnimationSchema.optional(),
|
|
732
|
-
gradientX2: PxPropertyAnimationSchema.optional(),
|
|
733
|
-
gradientY2: PxPropertyAnimationSchema.optional(),
|
|
734
|
-
gradientCx: PxPropertyAnimationSchema.optional(),
|
|
735
|
-
gradientCy: PxPropertyAnimationSchema.optional(),
|
|
736
|
-
gradientFx: PxPropertyAnimationSchema.optional(),
|
|
737
|
-
gradientFy: PxPropertyAnimationSchema.optional(),
|
|
738
|
-
gradientR: PxPropertyAnimationSchema.optional()
|
|
739
|
-
}));
|
|
740
831
|
var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
832
|
+
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
741
833
|
type: px.enum([PxGradientType.linear, PxGradientType.radial]),
|
|
742
|
-
p1:
|
|
743
|
-
p2:
|
|
744
|
-
c:
|
|
745
|
-
r:
|
|
746
|
-
fp:
|
|
834
|
+
p1: PxAnimatableVec2Schema.optional(),
|
|
835
|
+
p2: PxAnimatableVec2Schema.optional(),
|
|
836
|
+
c: PxAnimatableVec2Schema.optional(),
|
|
837
|
+
r: PxAnimatableNumberSchema.optional(),
|
|
838
|
+
fp: PxAnimatableVec2Schema.optional(),
|
|
747
839
|
stops: PxAnimatableGradientStopsSchema.optional(),
|
|
748
|
-
gradientUnits: px.
|
|
749
|
-
spreadMethod: px.
|
|
750
|
-
gradientTransform: px.string().optional()
|
|
751
|
-
animate: PxGradientGeometryAnimationSchema.optional()
|
|
840
|
+
gradientUnits: px.enum([PxGradientUnits.userSpaceOnUse, PxGradientUnits.objectBoundingBox]).optional(),
|
|
841
|
+
spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
|
|
842
|
+
gradientTransform: px.string().optional()
|
|
752
843
|
}));
|
|
753
844
|
var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
|
|
754
845
|
var PxTextPathEffectSchema = implementsInterface()(px.object({
|
|
755
846
|
path: px.string(),
|
|
756
|
-
pathOverflow: px.
|
|
757
|
-
lengthAdjust: px.
|
|
758
|
-
method: px.
|
|
759
|
-
spacing: px.
|
|
847
|
+
pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
|
|
848
|
+
lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
|
|
849
|
+
method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
|
|
850
|
+
spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
|
|
760
851
|
startOffset: PxAnimatableNumberSchema.optional(),
|
|
761
852
|
textLength: PxAnimatableNumberSchema.optional()
|
|
762
853
|
}));
|
|
@@ -764,13 +855,12 @@ var PxTextEffectSchema = implementsInterface()(px.object({
|
|
|
764
855
|
useGlyphs: px.boolean().optional()
|
|
765
856
|
}));
|
|
766
857
|
var PxEffectsSchema = implementsInterface()(px.object({
|
|
767
|
-
|
|
858
|
+
transformBy: PxTransformByEffectSchema.optional(),
|
|
768
859
|
repeater: PxRepeaterEffectSchema.optional(),
|
|
769
860
|
maskedBy: PxMaskedByEffectSchema.optional(),
|
|
770
861
|
clipPath: PxClipPathEffectSchema.optional(),
|
|
771
862
|
trimPath: PxTrimPathEffectSchema.optional(),
|
|
772
863
|
clone: PxCloneEffectSchema.optional(),
|
|
773
|
-
isCombinedShape: px.boolean().optional(),
|
|
774
864
|
fillGradient: PxFillGradientEffectSchema.optional(),
|
|
775
865
|
strokeGradient: PxStrokeGradientEffectSchema.optional(),
|
|
776
866
|
textPath: PxTextPathEffectSchema.optional(),
|
|
@@ -794,6 +884,14 @@ function validateNodeEffects(root, opts) {
|
|
|
794
884
|
return warnings;
|
|
795
885
|
}
|
|
796
886
|
var PxNodeBase = px.openObject({
|
|
887
|
+
// CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
|
|
888
|
+
// kind of thing is this", discriminated by its CARRIER — here the node TAG
|
|
889
|
+
// (`rect`, `text`), and inside a sub-object that object's kind (`clone.type`,
|
|
890
|
+
// `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
|
|
891
|
+
// the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
|
|
892
|
+
// would add words that all mean "type" and still need the carrier to read.
|
|
893
|
+
// Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
|
|
894
|
+
// (issues V3), never of distinct key names.
|
|
797
895
|
type: px.string(),
|
|
798
896
|
id: px.string().optional(),
|
|
799
897
|
meta: px.any().optional(),
|
|
@@ -803,7 +901,7 @@ var PxNodeBase = px.openObject({
|
|
|
803
901
|
effects: PxEffectsSchema.optional(),
|
|
804
902
|
// `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
|
|
805
903
|
// string ref / array of refs / inline definition / mixed array; mirrors
|
|
806
|
-
// `animator.
|
|
904
|
+
// `animator.animateById` map values and what `processNode` resolves at runtime.
|
|
807
905
|
animate: PxElementAnimationSchema.optional(),
|
|
808
906
|
style: px.union([px.string(), px.record(px.union([px.string(), px.number()]))]).optional()
|
|
809
907
|
}, PxAttrValueSchema);
|
|
@@ -827,35 +925,10 @@ var PxBezierPathSchema = implementsInterface()(px.object({
|
|
|
827
925
|
o: px.array(px.array(px.number())).optional(),
|
|
828
926
|
c: px.boolean().optional()
|
|
829
927
|
}));
|
|
830
|
-
function isPxElementFileFormat(fileJson) {
|
|
831
|
-
if (!(fileJson && typeof fileJson === "object" && !Array.isArray(fileJson))) {
|
|
832
|
-
return false;
|
|
833
|
-
}
|
|
834
|
-
return fileJson["type"] === "svg" || fileJson["tagName"] === "svg";
|
|
835
|
-
}
|
|
836
928
|
function isPxElementFileFormatDeep(fileJson) {
|
|
837
929
|
const valid = PxAnimatedSvgDocumentSchema.isValid(fileJson);
|
|
838
930
|
return { valid, errors: valid ? [] : ["Document failed schema validation"] };
|
|
839
931
|
}
|
|
840
|
-
function getAnimatorConfig(doc) {
|
|
841
|
-
var _a, _b;
|
|
842
|
-
return (doc == null ? void 0 : doc.animator) || ((_a = doc == null ? void 0 : doc.meta) == null ? void 0 : _a.animator) || (doc == null ? void 0 : doc.animation) || ((_b = doc == null ? void 0 : doc.meta) == null ? void 0 : _b.animation);
|
|
843
|
-
}
|
|
844
|
-
function getDefs(doc) {
|
|
845
|
-
var _a;
|
|
846
|
-
if (!doc) return void 0;
|
|
847
|
-
return (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.definitions;
|
|
848
|
-
}
|
|
849
|
-
function getBindings(doc) {
|
|
850
|
-
var _a;
|
|
851
|
-
if (!doc) return void 0;
|
|
852
|
-
const animate = (_a = getAnimatorConfig(doc)) == null ? void 0 : _a.animate;
|
|
853
|
-
if (!animate) return void 0;
|
|
854
|
-
return Object.entries(animate).map(([id, anim]) => ({ id, animate: anim }));
|
|
855
|
-
}
|
|
856
|
-
function getChildren(doc) {
|
|
857
|
-
return doc == null ? void 0 : doc.children;
|
|
858
|
-
}
|
|
859
932
|
function bezierToSvgPath(path, forceCurves = false) {
|
|
860
933
|
var _a, _b, _c, _d;
|
|
861
934
|
const v = path.v;
|
|
@@ -1306,7 +1379,7 @@ function generateNewIds(doc) {
|
|
|
1306
1379
|
"flood-color",
|
|
1307
1380
|
"lighting-color"
|
|
1308
1381
|
]);
|
|
1309
|
-
const directIdRefAttrs = /* @__PURE__ */ new Set(["
|
|
1382
|
+
const directIdRefAttrs = /* @__PURE__ */ new Set(["sourceId", "targetId", "boundElementId"]);
|
|
1310
1383
|
function collectIds(node) {
|
|
1311
1384
|
if (!node || typeof node !== "object") return;
|
|
1312
1385
|
if (node.id && typeof node.id === "string") {
|
|
@@ -1344,9 +1417,10 @@ function generateNewIds(doc) {
|
|
|
1344
1417
|
} else if (urlRefAttrs.has(key)) {
|
|
1345
1418
|
node[key] = replaceUrlRefs(value, idMap);
|
|
1346
1419
|
} else if (directIdRefAttrs.has(key)) {
|
|
1347
|
-
const
|
|
1420
|
+
const hasHash = value.startsWith("#");
|
|
1421
|
+
const newId = idMap.get(hasHash ? value.slice(1) : value);
|
|
1348
1422
|
if (newId) {
|
|
1349
|
-
node[key] = newId;
|
|
1423
|
+
node[key] = hasHash ? "#" + newId : newId;
|
|
1350
1424
|
}
|
|
1351
1425
|
} else if (value.includes("url(#")) {
|
|
1352
1426
|
node[key] = replaceUrlRefs(value, idMap);
|
|
@@ -1364,14 +1438,14 @@ function generateNewIds(doc) {
|
|
|
1364
1438
|
}
|
|
1365
1439
|
collectIds(cloned);
|
|
1366
1440
|
updateRefs(cloned);
|
|
1367
|
-
const docAnimate = (_a = cloned.animator) == null ? void 0 : _a.
|
|
1441
|
+
const docAnimate = (_a = cloned.animator) == null ? void 0 : _a.animateById;
|
|
1368
1442
|
if (docAnimate && typeof docAnimate === "object") {
|
|
1369
1443
|
const updatedAnimate = {};
|
|
1370
1444
|
for (const [id, anim] of Object.entries(docAnimate)) {
|
|
1371
1445
|
const newId = (_b = idMap.get(id)) != null ? _b : id;
|
|
1372
1446
|
updatedAnimate[newId] = anim;
|
|
1373
1447
|
}
|
|
1374
|
-
cloned.animator = __spreadProps2(__spreadValues2({}, cloned.animator), {
|
|
1448
|
+
cloned.animator = __spreadProps2(__spreadValues2({}, cloned.animator), { animateById: updatedAnimate });
|
|
1375
1449
|
}
|
|
1376
1450
|
return cloned;
|
|
1377
1451
|
}
|
|
@@ -1460,8 +1534,9 @@ function getNormalizedProps(props) {
|
|
|
1460
1534
|
let value = props[rawKey];
|
|
1461
1535
|
if (COLOUR_ATTR_NAMES.has(key) && Array.isArray(value)) {
|
|
1462
1536
|
propsCopy[key] = toRGBA(value);
|
|
1463
|
-
} else if (key === "transform" && value !== null && typeof value === "object" && !Array.isArray(value) && value.
|
|
1464
|
-
|
|
1537
|
+
} else if (key === "transform" && value !== null && typeof value === "object" && !Array.isArray(value) && !value.keyframes && !value.kfs) {
|
|
1538
|
+
const parts = value.value && typeof value.value === "object" ? value.value : value;
|
|
1539
|
+
propsCopy["transform"] = composeTransformParts(parts, { withUnits: false });
|
|
1465
1540
|
} else if (TRANSFORM_FN_NAMES.has(key)) {
|
|
1466
1541
|
if (Array.isArray(value)) {
|
|
1467
1542
|
if (key === "translate") value = value.map((v) => v + "px");
|
|
@@ -1469,6 +1544,8 @@ function getNormalizedProps(props) {
|
|
|
1469
1544
|
}
|
|
1470
1545
|
if (key === "rotate") value = value + "deg";
|
|
1471
1546
|
propsCopy["transform"] = key + "(" + value + ")";
|
|
1547
|
+
} else if (Array.isArray(value)) {
|
|
1548
|
+
propsCopy[key] = value.join(",");
|
|
1472
1549
|
} else if (value !== void 0 && value !== null) {
|
|
1473
1550
|
propsCopy[key] = String(value);
|
|
1474
1551
|
}
|
|
@@ -1866,6 +1943,16 @@ function walkAndMaterialise(node, opts) {
|
|
|
1866
1943
|
if (newAnimate) cloned.animate = newAnimate;
|
|
1867
1944
|
return cloned;
|
|
1868
1945
|
}
|
|
1946
|
+
var LOOP_JUMP_SHIFT_MS = 10;
|
|
1947
|
+
function deepEqualValue(a, b) {
|
|
1948
|
+
if (a === b) return true;
|
|
1949
|
+
if (typeof a !== typeof b || a === null || b === null || typeof a !== "object") return false;
|
|
1950
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
1951
|
+
const ka = Object.keys(a);
|
|
1952
|
+
const kb = Object.keys(b);
|
|
1953
|
+
if (ka.length !== kb.length) return false;
|
|
1954
|
+
return ka.every((k) => deepEqualValue(a[k], b[k]));
|
|
1955
|
+
}
|
|
1869
1956
|
function parsePathCommands(d) {
|
|
1870
1957
|
const tokens = d.split(/([MLCZmlcz]|[\s,]+)/).map((t) => t.trim()).filter((t) => t && t !== ",");
|
|
1871
1958
|
const commands = [];
|
|
@@ -2068,7 +2155,7 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2068
2155
|
const totalIntervals = keyframes.length - 1;
|
|
2069
2156
|
const segCount = clamp((_a = loop.segmentCount) != null ? _a : totalIntervals, 1, totalIntervals);
|
|
2070
2157
|
let segKfs;
|
|
2071
|
-
if (loop.before) {
|
|
2158
|
+
if (loop.extend === PxLoopExtend.before) {
|
|
2072
2159
|
segKfs = keyframes.slice(0, segCount + 1);
|
|
2073
2160
|
} else {
|
|
2074
2161
|
segKfs = keyframes.slice(totalIntervals - segCount);
|
|
@@ -2076,7 +2163,7 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2076
2163
|
const firstT = (_b = keyframes[0].t) != null ? _b : 0;
|
|
2077
2164
|
const lastT = (_c = keyframes[keyframes.length - 1].t) != null ? _c : 0;
|
|
2078
2165
|
let fillStart, fillEnd;
|
|
2079
|
-
if (loop.before) {
|
|
2166
|
+
if (loop.extend === PxLoopExtend.before) {
|
|
2080
2167
|
fillStart = 0;
|
|
2081
2168
|
fillEnd = firstT;
|
|
2082
2169
|
} else {
|
|
@@ -2103,7 +2190,10 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2103
2190
|
const remainder = fillDuration - fullReps * segDuration;
|
|
2104
2191
|
const partialFraction = remainder / segDuration;
|
|
2105
2192
|
const looped = [];
|
|
2193
|
+
const separateBoundary = loop.extend !== PxLoopExtend.before;
|
|
2194
|
+
const originalTerminalKf = keyframes[keyframes.length - 1];
|
|
2106
2195
|
function appendRep(repStart, isReversed, partial) {
|
|
2196
|
+
var _a2;
|
|
2107
2197
|
let entries;
|
|
2108
2198
|
if (isReversed) {
|
|
2109
2199
|
entries = [];
|
|
@@ -2139,8 +2229,17 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2139
2229
|
looped.push({ t: repStart + cutRelT * segDuration, v: cutValue, e: void 0 });
|
|
2140
2230
|
return;
|
|
2141
2231
|
}
|
|
2232
|
+
const prevKf = looped.length > 0 ? looped[looped.length - 1] : originalTerminalKf;
|
|
2233
|
+
const isBoundary = separateBoundary && i === 0 && prevKf !== void 0 && Math.abs(((_a2 = prevKf.t) != null ? _a2 : 0) - (repStart + entry.relT * segDuration)) < 1e-9;
|
|
2234
|
+
if (isBoundary) {
|
|
2235
|
+
if (deepEqualValue(prevKf.v, entry.v)) continue;
|
|
2236
|
+
if (looped.length > 0) {
|
|
2237
|
+
delete prevKf.tangentIn;
|
|
2238
|
+
delete prevKf.tangentOut;
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2142
2241
|
const pushed = {
|
|
2143
|
-
t: repStart + entry.relT * segDuration,
|
|
2242
|
+
t: repStart + entry.relT * segDuration + (isBoundary ? LOOP_JUMP_SHIFT_MS : 0),
|
|
2144
2243
|
v: entry.v,
|
|
2145
2244
|
e: i < entries.length - 1 ? entry.e : void 0
|
|
2146
2245
|
};
|
|
@@ -2188,7 +2287,7 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2188
2287
|
looped.push(pushed);
|
|
2189
2288
|
}
|
|
2190
2289
|
}
|
|
2191
|
-
if (loop.before) {
|
|
2290
|
+
if (loop.extend === PxLoopExtend.before) {
|
|
2192
2291
|
if (partialFraction > 1e-9) {
|
|
2193
2292
|
const isReversed = !!loop.alternate && fullReps % 2 === 0;
|
|
2194
2293
|
appendRepTail(fillStart, isReversed, partialFraction);
|
|
@@ -2211,7 +2310,7 @@ function expandLoopKeyframes(propName, keyframes, loop, duration) {
|
|
|
2211
2310
|
appendRep(repStart, isReversed, partialFraction);
|
|
2212
2311
|
}
|
|
2213
2312
|
}
|
|
2214
|
-
if (loop.before) {
|
|
2313
|
+
if (loop.extend === PxLoopExtend.before) {
|
|
2215
2314
|
return [...looped, ...keyframes];
|
|
2216
2315
|
} else {
|
|
2217
2316
|
return [...keyframes, ...looped];
|
|
@@ -2327,7 +2426,7 @@ var _elementIdCounter = 0;
|
|
|
2327
2426
|
function generateElementId() {
|
|
2328
2427
|
return "_px_el_" + ++_elementIdCounter;
|
|
2329
2428
|
}
|
|
2330
|
-
function normalizeAnimationDefinition(animDef, duration, defs, engine = PxAnimatorEngine.
|
|
2429
|
+
function normalizeAnimationDefinition(animDef, duration, defs, engine = PxAnimatorEngine.waapi) {
|
|
2331
2430
|
const normalized = {};
|
|
2332
2431
|
for (const [propName, propAnim] of Object.entries(animDef)) {
|
|
2333
2432
|
const normalizedKfs = normalizeKeyframes(propName, propAnim, duration, defs);
|
|
@@ -2335,12 +2434,12 @@ function normalizeAnimationDefinition(animDef, duration, defs, engine = PxAnimat
|
|
|
2335
2434
|
const out = { kfs: normalizedKfs };
|
|
2336
2435
|
if (propAnim.autoOrient !== void 0) out.autoOrient = propAnim.autoOrient;
|
|
2337
2436
|
if (propAnim.loop !== void 0) out.loop = propAnim.loop;
|
|
2338
|
-
normalized[propName] = engine === PxAnimatorEngine.
|
|
2437
|
+
normalized[propName] = engine === PxAnimatorEngine.waapi && propName === "transform" ? materialiseMotionPathInPropAnim(out) : out;
|
|
2339
2438
|
}
|
|
2340
2439
|
}
|
|
2341
2440
|
return normalized;
|
|
2342
2441
|
}
|
|
2343
|
-
function getNormalisedBindings(doc, engine = PxAnimatorEngine.
|
|
2442
|
+
function getNormalisedBindings(doc, engine = PxAnimatorEngine.waapi) {
|
|
2344
2443
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
2345
2444
|
const defs = getDefs(doc);
|
|
2346
2445
|
const duration = animatorConfig.duration || 1e3;
|
|
@@ -2745,7 +2844,7 @@ function partsRecord(part, value, origin) {
|
|
|
2745
2844
|
return rec;
|
|
2746
2845
|
}
|
|
2747
2846
|
function readAnimatable(raw) {
|
|
2748
|
-
var _a, _b;
|
|
2847
|
+
var _a, _b, _c;
|
|
2749
2848
|
if (raw === void 0) return {
|
|
2750
2849
|
kind: "absent"
|
|
2751
2850
|
/* Absent */
|
|
@@ -2755,13 +2854,34 @@ function readAnimatable(raw) {
|
|
|
2755
2854
|
const obj = raw;
|
|
2756
2855
|
const kfs = (_a = obj.keyframes) != null ? _a : obj.kfs;
|
|
2757
2856
|
if (kfs) {
|
|
2758
|
-
|
|
2857
|
+
const out = { kind: "animated", keyframes: kfs.map(normaliseKeyframe), autoOrient: obj.autoOrient, loop: obj.loop };
|
|
2858
|
+
const base = (_b = obj.value) != null ? _b : obj.v;
|
|
2859
|
+
if (base !== void 0 && out.kind === "animated") out.base = base;
|
|
2860
|
+
return out;
|
|
2759
2861
|
}
|
|
2760
|
-
const staticValue = (
|
|
2862
|
+
const staticValue = (_c = obj.value) != null ? _c : obj.v;
|
|
2761
2863
|
if (staticValue !== void 0) return { kind: "static", value: staticValue };
|
|
2762
2864
|
}
|
|
2763
2865
|
return { kind: "static", value: raw };
|
|
2764
2866
|
}
|
|
2867
|
+
function writeAnimatableChannel(node, attrName, read, opts) {
|
|
2868
|
+
var _a, _b, _c, _d;
|
|
2869
|
+
const toOut = (v) => (opts == null ? void 0 : opts.asString) && v !== void 0 && v !== null ? String(v) : v;
|
|
2870
|
+
if (read.kind === "absent") return;
|
|
2871
|
+
if (read.kind === "static") {
|
|
2872
|
+
node[attrName] = toOut(read.value);
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
const prevAnimate = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate : void 0;
|
|
2876
|
+
const animate = __spreadValues2({}, prevAnimate || {});
|
|
2877
|
+
const block = { keyframes: read.keyframes };
|
|
2878
|
+
if (read.loop !== void 0) block.loop = read.loop;
|
|
2879
|
+
if (read.autoOrient !== void 0) block.autoOrient = read.autoOrient;
|
|
2880
|
+
animate[attrName] = block;
|
|
2881
|
+
node.animate = animate;
|
|
2882
|
+
const baseline = (_d = (_b = read.base) != null ? _b : (_a = read.keyframes[0]) == null ? void 0 : _a.value) != null ? _d : (_c = read.keyframes[0]) == null ? void 0 : _c.v;
|
|
2883
|
+
if (baseline !== void 0) node[attrName] = toOut(baseline);
|
|
2884
|
+
}
|
|
2765
2885
|
function normaliseKeyframe(kf) {
|
|
2766
2886
|
if (!kf || typeof kf !== "object") return kf;
|
|
2767
2887
|
const k = kf;
|
|
@@ -2781,7 +2901,7 @@ function readStaticOrigin(raw, ctx) {
|
|
|
2781
2901
|
const o = readAnimatable(raw);
|
|
2782
2902
|
if (o.kind === "absent") return void 0;
|
|
2783
2903
|
if (o.kind === "static") return o.value;
|
|
2784
|
-
ctx.warnings.push("
|
|
2904
|
+
ctx.warnings.push("transformBy.origin: animated origin approximated by its first keyframe");
|
|
2785
2905
|
return (_a = o.keyframes[0]) == null ? void 0 : _a.value;
|
|
2786
2906
|
}
|
|
2787
2907
|
function keyframeWith(kf, value) {
|
|
@@ -2792,7 +2912,7 @@ function keyframeWith(kf, value) {
|
|
|
2792
2912
|
if (kf.tangentIn !== void 0) out.tangentIn = kf.tangentIn;
|
|
2793
2913
|
return out;
|
|
2794
2914
|
}
|
|
2795
|
-
function
|
|
2915
|
+
function applyTransformByEffect(node, fx, ctx) {
|
|
2796
2916
|
if (!fx) return node;
|
|
2797
2917
|
delete node.transform;
|
|
2798
2918
|
let n = node;
|
|
@@ -2828,6 +2948,10 @@ function applyTransformationEffect(node, fx, ctx) {
|
|
|
2828
2948
|
} else {
|
|
2829
2949
|
n = wrapTransformPart(n, "translate", fx.translate, ctx);
|
|
2830
2950
|
}
|
|
2951
|
+
if (n !== node && node.id) {
|
|
2952
|
+
n.id = node.id;
|
|
2953
|
+
delete node.id;
|
|
2954
|
+
}
|
|
2831
2955
|
return n;
|
|
2832
2956
|
}
|
|
2833
2957
|
function translateHasAutoOrient(translate) {
|
|
@@ -2837,8 +2961,6 @@ function translateHasAutoOrient(translate) {
|
|
|
2837
2961
|
return Array.isArray(obj.keyframes) && obj.keyframes.some((kf) => kf.tangentOut || kf.tangentIn);
|
|
2838
2962
|
}
|
|
2839
2963
|
function normalizeScale(raw) {
|
|
2840
|
-
if (raw === void 0) return void 0;
|
|
2841
|
-
if (Array.isArray(raw)) return [raw[0] / 100, raw[1] / 100];
|
|
2842
2964
|
return raw;
|
|
2843
2965
|
}
|
|
2844
2966
|
function wrapTransformPart(inner, part, raw, ctx) {
|
|
@@ -2879,34 +3001,54 @@ function wrapOrigin(inner, raw, invert) {
|
|
|
2879
3001
|
}
|
|
2880
3002
|
return inner;
|
|
2881
3003
|
}
|
|
3004
|
+
function genId(ctx, prefix) {
|
|
3005
|
+
return "_lw_" + prefix + "_" + ctx.nextId++;
|
|
3006
|
+
}
|
|
3007
|
+
function stripHash2(href) {
|
|
3008
|
+
return typeof href === "string" ? href.replace(/^#/, "") : void 0;
|
|
3009
|
+
}
|
|
3010
|
+
function indexById(node, map) {
|
|
3011
|
+
var _a;
|
|
3012
|
+
if (typeof node.id === "string") map.set(node.id, node);
|
|
3013
|
+
(_a = node.children) == null ? void 0 : _a.forEach((child) => indexById(child, map));
|
|
3014
|
+
}
|
|
3015
|
+
function spliceDefs(root, defs) {
|
|
3016
|
+
if (!defs.length) return;
|
|
3017
|
+
const existing = root.children || (root.children = []);
|
|
3018
|
+
existing.unshift({ type: "defs", children: defs });
|
|
3019
|
+
}
|
|
3020
|
+
var clone = deepClonePxNode;
|
|
3021
|
+
function regenerateIdsInClone(root, ctx) {
|
|
3022
|
+
return regenerateIdsAndRewriteRefs(root, () => genId(ctx, "retimed"));
|
|
3023
|
+
}
|
|
2882
3024
|
function identifyContentRefTargets(node, ctx, allocator) {
|
|
2883
3025
|
var _a, _b, _c;
|
|
2884
3026
|
if (node.type === "use" && ((_b = (_a = node.effects) == null ? void 0 : _a.clone) == null ? void 0 : _b.type) === "content") {
|
|
2885
|
-
const
|
|
2886
|
-
if (typeof
|
|
2887
|
-
ctx.contentRefInnerIds.set(
|
|
3027
|
+
const sourceId = stripHash2(node.effects.clone.sourceId);
|
|
3028
|
+
if (typeof sourceId === "string" && sourceId && !ctx.contentRefInnerIds.has(sourceId)) {
|
|
3029
|
+
ctx.contentRefInnerIds.set(sourceId, allocator(sourceId));
|
|
2888
3030
|
}
|
|
2889
3031
|
}
|
|
2890
3032
|
(_c = node.children) == null ? void 0 : _c.forEach((c) => identifyContentRefTargets(c, ctx, allocator));
|
|
2891
3033
|
}
|
|
2892
|
-
function splitForContentRef(node,
|
|
2893
|
-
const outerBody = liftBodyTranslate(node,
|
|
3034
|
+
function splitForContentRef(node, transformBy, originalId, innerId, ctx) {
|
|
3035
|
+
const outerBody = liftBodyTranslate(node, transformBy);
|
|
2894
3036
|
if (typeof node.id === "string") delete node.id;
|
|
2895
|
-
const { outer: outerTr, inner: innerTr } =
|
|
3037
|
+
const { outer: outerTr, inner: innerTr } = splitTransformByEffect(transformBy);
|
|
2896
3038
|
let innerNode = node;
|
|
2897
|
-
innerNode =
|
|
3039
|
+
innerNode = applyTransformByEffect(innerNode, innerTr, ctx);
|
|
2898
3040
|
const innerWrapper = { type: "g", id: innerId, children: [innerNode] };
|
|
2899
3041
|
let outerWrapper = { type: "g", id: originalId, children: [innerWrapper] };
|
|
2900
3042
|
if (outerBody.transform !== void 0) outerWrapper.transform = outerBody.transform;
|
|
2901
3043
|
if (outerBody.animate !== void 0) outerWrapper.animate = outerBody.animate;
|
|
2902
3044
|
if (outerTr) {
|
|
2903
3045
|
delete outerWrapper.id;
|
|
2904
|
-
outerWrapper =
|
|
3046
|
+
outerWrapper = applyTransformByEffect(outerWrapper, outerTr, ctx);
|
|
2905
3047
|
outerWrapper.id = originalId;
|
|
2906
3048
|
}
|
|
2907
3049
|
return outerWrapper;
|
|
2908
3050
|
}
|
|
2909
|
-
function liftBodyTranslate(node,
|
|
3051
|
+
function liftBodyTranslate(node, transformBy) {
|
|
2910
3052
|
var _a, _b, _c;
|
|
2911
3053
|
const out = {};
|
|
2912
3054
|
let didLiftAnimate = false;
|
|
@@ -2960,7 +3102,7 @@ function liftBodyTranslate(node, transformation) {
|
|
|
2960
3102
|
didLiftAnimate = true;
|
|
2961
3103
|
}
|
|
2962
3104
|
}
|
|
2963
|
-
const transformationHasTranslate = (
|
|
3105
|
+
const transformationHasTranslate = (transformBy == null ? void 0 : transformBy.translate) !== void 0;
|
|
2964
3106
|
const stripBodyTranslateOnly = didLiftAnimate || transformationHasTranslate;
|
|
2965
3107
|
const liftedAnimateIsAutoOriented = didLiftAnimate && needsOriginOnOuter(((_b = node.animate) == null ? void 0 : _b.transform) || void 0) || didLiftAnimate && needsOriginOnOuter(((_c = out.animate) == null ? void 0 : _c.transform) || void 0);
|
|
2966
3108
|
if (typeof node.transform === "string") {
|
|
@@ -2979,6 +3121,24 @@ function liftBodyTranslate(node, transformation) {
|
|
|
2979
3121
|
if (split.rest) node.transform = split.rest;
|
|
2980
3122
|
else delete node.transform;
|
|
2981
3123
|
}
|
|
3124
|
+
} else if (node.transform && typeof node.transform === "object" && !Array.isArray(node.transform) && !node.transform.keyframes && !node.transform.kfs) {
|
|
3125
|
+
const wrapped = node.transform.value;
|
|
3126
|
+
const isWrapped = !!(wrapped && typeof wrapped === "object");
|
|
3127
|
+
const value = isWrapped ? wrapped : node.transform;
|
|
3128
|
+
const rewrap = (rec) => isWrapped ? { value: rec } : rec;
|
|
3129
|
+
if (Array.isArray(value.translate)) {
|
|
3130
|
+
const rest = __spreadValues2({}, value);
|
|
3131
|
+
delete rest.translate;
|
|
3132
|
+
const hasRest = Object.keys(rest).length > 0;
|
|
3133
|
+
if (stripBodyTranslateOnly) {
|
|
3134
|
+
if (hasRest) node.transform = rewrap(rest);
|
|
3135
|
+
else delete node.transform;
|
|
3136
|
+
} else {
|
|
3137
|
+
out.transform = rewrap({ translate: value.translate });
|
|
3138
|
+
if (hasRest) node.transform = rewrap(rest);
|
|
3139
|
+
else delete node.transform;
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
2982
3142
|
}
|
|
2983
3143
|
return out;
|
|
2984
3144
|
}
|
|
@@ -3048,7 +3208,7 @@ function parseTranslateArgs(translateOp) {
|
|
|
3048
3208
|
const nums = m[1].split(/[\s,]+/).filter(Boolean).map(Number);
|
|
3049
3209
|
return [nums[0] || 0, nums[1] || 0];
|
|
3050
3210
|
}
|
|
3051
|
-
function
|
|
3211
|
+
function splitTransformByEffect(fx) {
|
|
3052
3212
|
if (!fx) return {};
|
|
3053
3213
|
const originOnOuter = needsOriginOnOuter(fx.translate);
|
|
3054
3214
|
const innerHasPivotedPart = fx.rotate !== void 0 || fx.scale !== void 0;
|
|
@@ -3074,26 +3234,6 @@ function needsOriginOnOuter(translateAnim) {
|
|
|
3074
3234
|
}
|
|
3075
3235
|
return false;
|
|
3076
3236
|
}
|
|
3077
|
-
function genId(ctx, prefix) {
|
|
3078
|
-
return "_lw_" + prefix + "_" + ctx.nextId++;
|
|
3079
|
-
}
|
|
3080
|
-
function stripHash2(href) {
|
|
3081
|
-
return typeof href === "string" ? href.replace(/^#/, "") : void 0;
|
|
3082
|
-
}
|
|
3083
|
-
function indexById(node, map) {
|
|
3084
|
-
var _a;
|
|
3085
|
-
if (typeof node.id === "string") map.set(node.id, node);
|
|
3086
|
-
(_a = node.children) == null ? void 0 : _a.forEach((child) => indexById(child, map));
|
|
3087
|
-
}
|
|
3088
|
-
function spliceDefs(root, defs) {
|
|
3089
|
-
if (!defs.length) return;
|
|
3090
|
-
const existing = root.children || (root.children = []);
|
|
3091
|
-
existing.unshift({ type: "defs", children: defs });
|
|
3092
|
-
}
|
|
3093
|
-
var clone = deepClonePxNode;
|
|
3094
|
-
function regenerateIdsInClone(root, ctx) {
|
|
3095
|
-
return regenerateIdsAndRewriteRefs(root, () => genId(ctx, "retimed"));
|
|
3096
|
-
}
|
|
3097
3237
|
function applyFillGradientEffect(node, fx, ctx) {
|
|
3098
3238
|
return applyGradient(node, fx, ctx, "fill");
|
|
3099
3239
|
}
|
|
@@ -3114,62 +3254,63 @@ function synthesiseGradientDef(fx, id, ctx) {
|
|
|
3114
3254
|
id
|
|
3115
3255
|
};
|
|
3116
3256
|
if (fx.type === PxGradientType.linear) {
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
out.y1 = String(fx.p1[1]);
|
|
3120
|
-
}
|
|
3121
|
-
if (fx.p2) {
|
|
3122
|
-
out.x2 = String(fx.p2[0]);
|
|
3123
|
-
out.y2 = String(fx.p2[1]);
|
|
3124
|
-
}
|
|
3257
|
+
applyGeomVec(out, "x1", "y1", fx.p1);
|
|
3258
|
+
applyGeomVec(out, "x2", "y2", fx.p2);
|
|
3125
3259
|
} else {
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
}
|
|
3130
|
-
if (fx.r !== void 0) out.r = String(fx.r);
|
|
3131
|
-
if (fx.fp) {
|
|
3132
|
-
out.fx = String(fx.fp[0]);
|
|
3133
|
-
out.fy = String(fx.fp[1]);
|
|
3134
|
-
}
|
|
3260
|
+
applyGeomVec(out, "cx", "cy", fx.c);
|
|
3261
|
+
applyGeomNumber(out, "r", fx.r);
|
|
3262
|
+
applyGeomVec(out, "fx", "fy", fx.fp);
|
|
3135
3263
|
}
|
|
3136
3264
|
if (fx.gradientUnits) out.gradientUnits = fx.gradientUnits;
|
|
3137
3265
|
if (fx.spreadMethod) out.spreadMethod = fx.spreadMethod;
|
|
3138
3266
|
if (fx.gradientTransform) out.gradientTransform = fx.gradientTransform;
|
|
3139
|
-
const animate = fx.animate;
|
|
3140
|
-
if (animate) {
|
|
3141
|
-
const mapped = {};
|
|
3142
|
-
for (const wireKey of Object.keys(animate)) {
|
|
3143
|
-
const attr = GRADIENT_ANIM_CHANNEL_TO_ATTR[wireKey];
|
|
3144
|
-
if (attr) mapped[attr] = animate[wireKey];
|
|
3145
|
-
}
|
|
3146
|
-
if (Object.keys(mapped).length) out.animate = mapped;
|
|
3147
|
-
}
|
|
3148
3267
|
out.children = buildStopChildren(fx.stops, ctx);
|
|
3149
3268
|
return out;
|
|
3150
3269
|
}
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3270
|
+
function applyGeomVec(out, xAttr, yAttr, raw) {
|
|
3271
|
+
var _a, _b, _c;
|
|
3272
|
+
const read = readAnimatable(raw);
|
|
3273
|
+
if (read.kind === "absent") return;
|
|
3274
|
+
if (read.kind === "static") {
|
|
3275
|
+
out[xAttr] = String(read.value[0]);
|
|
3276
|
+
out[yAttr] = String(read.value[1]);
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3279
|
+
const axisChannel = (idx) => {
|
|
3280
|
+
const block = {
|
|
3281
|
+
keyframes: read.keyframes.map((kf) => {
|
|
3282
|
+
const axisKf = { time: kf.time, value: Array.isArray(kf.value) ? kf.value[idx] : void 0 };
|
|
3283
|
+
if (kf.easing !== void 0) axisKf.easing = kf.easing;
|
|
3284
|
+
return axisKf;
|
|
3285
|
+
})
|
|
3286
|
+
};
|
|
3287
|
+
if (read.loop !== void 0) block.loop = read.loop;
|
|
3288
|
+
return block;
|
|
3289
|
+
};
|
|
3290
|
+
const animate = (_a = out.animate) != null ? _a : {};
|
|
3291
|
+
animate[xAttr] = axisChannel(0);
|
|
3292
|
+
animate[yAttr] = axisChannel(1);
|
|
3293
|
+
out.animate = animate;
|
|
3294
|
+
const baseline = (_c = read.base) != null ? _c : (_b = read.keyframes[0]) == null ? void 0 : _b.value;
|
|
3295
|
+
if (Array.isArray(baseline)) {
|
|
3296
|
+
out[xAttr] = String(baseline[0]);
|
|
3297
|
+
out[yAttr] = String(baseline[1]);
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
function applyGeomNumber(out, attrName, raw) {
|
|
3301
|
+
const read = readAnimatable(raw);
|
|
3302
|
+
if (read.kind === "absent") return;
|
|
3303
|
+
writeAnimatableChannel(out, attrName, read, { asString: true });
|
|
3304
|
+
}
|
|
3162
3305
|
function buildStopChildren(stops, ctx) {
|
|
3163
3306
|
var _a, _b, _c, _d;
|
|
3164
3307
|
if (!stops) return [];
|
|
3165
|
-
|
|
3166
|
-
if (
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
const
|
|
3171
|
-
if (!Array.isArray(kfs) || !kfs.length) return [];
|
|
3172
|
-
const loopFromSource = animBlock.loop;
|
|
3308
|
+
const read = readAnimatable(stops);
|
|
3309
|
+
if (read.kind === "absent") return [];
|
|
3310
|
+
if (read.kind === "static") return Array.isArray(read.value) ? read.value.map(staticStopNode) : [];
|
|
3311
|
+
const kfs = read.keyframes;
|
|
3312
|
+
if (!kfs.length) return [];
|
|
3313
|
+
const loopFromSource = read.loop;
|
|
3173
3314
|
let stopCount = 0;
|
|
3174
3315
|
for (const kf of kfs) {
|
|
3175
3316
|
const v = (_a = kf.value) != null ? _a : kf.v;
|
|
@@ -3244,36 +3385,60 @@ function formatOffset(o) {
|
|
|
3244
3385
|
return pct + "%";
|
|
3245
3386
|
}
|
|
3246
3387
|
function applyClipPathEffect(node, fx, ctx) {
|
|
3388
|
+
var _a, _b;
|
|
3247
3389
|
if (!fx || !fx.d && !fx.animate) return node;
|
|
3248
3390
|
const clipId = genId(ctx, "clip");
|
|
3249
|
-
const pathChild = { type: "path"
|
|
3250
|
-
|
|
3391
|
+
const pathChild = { type: "path" };
|
|
3392
|
+
const read = readAnimatable(fx.d);
|
|
3393
|
+
if (read.kind !== "absent") {
|
|
3394
|
+
if (read.kind === "static") {
|
|
3395
|
+
pathChild.d = pathString(read.value);
|
|
3396
|
+
} else {
|
|
3397
|
+
writeAnimatableChannel(pathChild, "d", read);
|
|
3398
|
+
if (pathChild.d !== void 0) pathChild.d = pathString(pathChild.d);
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
if (fx.animate && !((_a = pathChild.animate) == null ? void 0 : _a.d)) {
|
|
3402
|
+
const animate = (_b = pathChild.animate) != null ? _b : {};
|
|
3403
|
+
animate.d = fx.animate;
|
|
3404
|
+
pathChild.animate = animate;
|
|
3405
|
+
}
|
|
3251
3406
|
ctx.defs.push({ type: "clipPath", id: clipId, children: [pathChild] });
|
|
3252
3407
|
node.clipPath = "url(#" + clipId + ")";
|
|
3253
3408
|
return node;
|
|
3254
3409
|
}
|
|
3255
|
-
function
|
|
3410
|
+
function pathString(v) {
|
|
3411
|
+
if (typeof v === "string") return v;
|
|
3412
|
+
if (v && typeof v === "object" && typeof v.path === "string") return v.path;
|
|
3413
|
+
return void 0;
|
|
3414
|
+
}
|
|
3415
|
+
function applyMaskedByEffect(node, fx, transformBy, ctx) {
|
|
3256
3416
|
if (!fx) return node;
|
|
3257
|
-
|
|
3258
|
-
|
|
3417
|
+
const sourceId = stripHash2(fx.sourceId);
|
|
3418
|
+
if (!sourceId) {
|
|
3419
|
+
ctx.errors.push("maskedBy.sourceId missing \u2014 cannot build mask");
|
|
3259
3420
|
return node;
|
|
3260
3421
|
}
|
|
3261
3422
|
const maskId = genId(ctx, "mask");
|
|
3262
|
-
let content = { type: "use", href: "#" +
|
|
3263
|
-
if (
|
|
3264
|
-
content = wrapInverseTransform(content,
|
|
3423
|
+
let content = { type: "use", href: "#" + sourceId };
|
|
3424
|
+
if (transformBy) {
|
|
3425
|
+
content = wrapInverseTransform(content, transformBy, ctx);
|
|
3265
3426
|
} else if (hasAnimateTransform(node)) {
|
|
3266
3427
|
content = wrapInverseAnimatedBodyTransform(content, node, ctx);
|
|
3267
3428
|
} else {
|
|
3268
3429
|
const bodyStatic = readTransformationFromBody(node);
|
|
3269
3430
|
if (bodyStatic) content = wrapInverseTransform(content, bodyStatic, ctx);
|
|
3270
3431
|
}
|
|
3271
|
-
const includeTargetOwn =
|
|
3272
|
-
content = wrapAncestorChainCompensation(content, node,
|
|
3432
|
+
const includeTargetOwn = transformBy === void 0 && !nodeHasBodyTransform(node);
|
|
3433
|
+
content = wrapAncestorChainCompensation(content, node, sourceId, ctx, includeTargetOwn);
|
|
3273
3434
|
const mask = { type: "mask", id: maskId, children: [content] };
|
|
3274
3435
|
if (fx.maskType) mask.maskType = fx.maskType;
|
|
3275
3436
|
if (fx.maskUnits) mask.maskUnits = fx.maskUnits;
|
|
3276
3437
|
if (fx.maskContentUnits) mask.maskContentUnits = fx.maskContentUnits;
|
|
3438
|
+
if (fx.x !== void 0) mask.x = String(fx.x);
|
|
3439
|
+
if (fx.y !== void 0) mask.y = String(fx.y);
|
|
3440
|
+
if (fx.width !== void 0) mask.width = String(fx.width);
|
|
3441
|
+
if (fx.height !== void 0) mask.height = String(fx.height);
|
|
3277
3442
|
ctx.defs.push(mask);
|
|
3278
3443
|
node.mask = "url(#" + maskId + ")";
|
|
3279
3444
|
return node;
|
|
@@ -3380,6 +3545,19 @@ function readTransformationFromBody(node) {
|
|
|
3380
3545
|
if (parts.origin) out.origin = parts.origin;
|
|
3381
3546
|
return Object.keys(out).length ? out : void 0;
|
|
3382
3547
|
}
|
|
3548
|
+
if (node.transform && typeof node.transform === "object" && !node.transform.keyframes && !node.transform.kfs) {
|
|
3549
|
+
const wrapped = node.transform.value;
|
|
3550
|
+
const value = wrapped && typeof wrapped === "object" ? wrapped : node.transform;
|
|
3551
|
+
if (value && typeof value === "object") {
|
|
3552
|
+
const out = {};
|
|
3553
|
+
if (Array.isArray(value.translate)) out.translate = value.translate;
|
|
3554
|
+
if (typeof value.rotate === "number") out.rotate = value.rotate;
|
|
3555
|
+
if (typeof value.skew === "number") out.skew = value.skew;
|
|
3556
|
+
if (Array.isArray(value.scale)) out.scale = { value: value.scale };
|
|
3557
|
+
if (Array.isArray(value.origin)) out.origin = value.origin;
|
|
3558
|
+
return Object.keys(out).length ? out : void 0;
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3383
3561
|
return void 0;
|
|
3384
3562
|
}
|
|
3385
3563
|
function parseTransformStringToParts(s) {
|
|
@@ -3513,10 +3691,10 @@ function collectMaskAncestorChains(root, ctx) {
|
|
|
3513
3691
|
const interestingNodes = /* @__PURE__ */ new Set();
|
|
3514
3692
|
const collectInterestingNodes = (n) => {
|
|
3515
3693
|
var _a, _b;
|
|
3516
|
-
const
|
|
3517
|
-
if (typeof
|
|
3694
|
+
const maskSourceId = stripHash2((_b = (_a = n.effects) == null ? void 0 : _a.maskedBy) == null ? void 0 : _b.sourceId);
|
|
3695
|
+
if (typeof maskSourceId === "string") {
|
|
3518
3696
|
interestingNodes.add(n);
|
|
3519
|
-
const sourceNode = ctx.idMap.get(
|
|
3697
|
+
const sourceNode = ctx.idMap.get(maskSourceId);
|
|
3520
3698
|
if (sourceNode) interestingNodes.add(sourceNode);
|
|
3521
3699
|
}
|
|
3522
3700
|
if (Array.isArray(n.children)) for (const ch of n.children) collectInterestingNodes(ch);
|
|
@@ -3542,8 +3720,9 @@ function extractTranslateOnly(node, ctx) {
|
|
|
3542
3720
|
if (typeof tr === "string") {
|
|
3543
3721
|
const parts = parseTranslateOnlyFromString(tr, ctx);
|
|
3544
3722
|
if (parts) out.translate = parts;
|
|
3545
|
-
} else if (tr && typeof tr === "object") {
|
|
3546
|
-
const
|
|
3723
|
+
} else if (tr && typeof tr === "object" && !tr.keyframes && !tr.kfs) {
|
|
3724
|
+
const wrapped = tr.value;
|
|
3725
|
+
const value = wrapped && typeof wrapped === "object" ? wrapped : tr;
|
|
3547
3726
|
if (value && typeof value === "object" && Array.isArray(value.translate)) {
|
|
3548
3727
|
out.translate = [value.translate[0] || 0, value.translate[1] || 0];
|
|
3549
3728
|
}
|
|
@@ -3591,17 +3770,17 @@ function parseTranslateOnlyFromString(s, ctx) {
|
|
|
3591
3770
|
var CONTENT_SUBREF = "content";
|
|
3592
3771
|
function applyRefHref(node, clone2, ctx) {
|
|
3593
3772
|
if (!clone2) return;
|
|
3594
|
-
const
|
|
3595
|
-
if (!
|
|
3596
|
-
if (clone2.type === CONTENT_SUBREF) ctx.errors.push("clone: content ref missing
|
|
3773
|
+
const sourceId = stripHash2(clone2.sourceId);
|
|
3774
|
+
if (!sourceId) {
|
|
3775
|
+
if (clone2.type === CONTENT_SUBREF) ctx.errors.push("clone: content ref missing sourceId");
|
|
3597
3776
|
return;
|
|
3598
3777
|
}
|
|
3599
|
-
const targetId = clone2.type === CONTENT_SUBREF ? ctx.contentRefInnerIds.get(
|
|
3778
|
+
const targetId = clone2.type === CONTENT_SUBREF ? ctx.contentRefInnerIds.get(sourceId) || sourceId : sourceId;
|
|
3600
3779
|
node.href = "#" + targetId;
|
|
3601
3780
|
}
|
|
3602
|
-
function applyRefAndTransformationEffect(node, clone2,
|
|
3781
|
+
function applyRefAndTransformationEffect(node, clone2, transformBy, ctx) {
|
|
3603
3782
|
applyRefHref(node, clone2, ctx);
|
|
3604
|
-
return
|
|
3783
|
+
return applyTransformByEffect(node, transformBy, ctx);
|
|
3605
3784
|
}
|
|
3606
3785
|
function applyRepeaterEffect(node, fx, ctx) {
|
|
3607
3786
|
var _a, _b;
|
|
@@ -3624,7 +3803,7 @@ function applyRepeaterEffect(node, fx, ctx) {
|
|
|
3624
3803
|
for (let i = 1; i < copies; i++) {
|
|
3625
3804
|
const baseClone = clone(base);
|
|
3626
3805
|
const synthFx = synthesisePerCopyFx(fx, i);
|
|
3627
|
-
const wrapped = synthFx ?
|
|
3806
|
+
const wrapped = synthFx ? applyTransformByEffect(baseClone, synthFx, ctx) : baseClone;
|
|
3628
3807
|
children.push(wrapped);
|
|
3629
3808
|
}
|
|
3630
3809
|
const wrapper = { type: "g", children };
|
|
@@ -3636,10 +3815,13 @@ function applyRepeaterEffect(node, fx, ctx) {
|
|
|
3636
3815
|
function synthesisePerCopyFx(fx, i) {
|
|
3637
3816
|
const out = {};
|
|
3638
3817
|
if (fx.translate !== void 0) {
|
|
3639
|
-
out.translate =
|
|
3818
|
+
out.translate = mapAnimatable(fx.translate, (v) => [v[0] * i, v[1] * i]);
|
|
3640
3819
|
}
|
|
3641
3820
|
if (fx.rotate !== void 0) {
|
|
3642
|
-
out.rotate =
|
|
3821
|
+
out.rotate = mapAnimatable(fx.rotate, (v) => v * i);
|
|
3822
|
+
}
|
|
3823
|
+
if (fx.skew !== void 0) {
|
|
3824
|
+
out.skew = mapAnimatable(fx.skew, (v) => v * i);
|
|
3643
3825
|
}
|
|
3644
3826
|
if (fx.scale !== void 0) {
|
|
3645
3827
|
out.scale = synthesiseScale(fx.scale, i);
|
|
@@ -3649,63 +3831,50 @@ function synthesisePerCopyFx(fx, i) {
|
|
|
3649
3831
|
}
|
|
3650
3832
|
return Object.keys(out).length ? out : void 0;
|
|
3651
3833
|
}
|
|
3652
|
-
function
|
|
3653
|
-
|
|
3654
|
-
if (
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
});
|
|
3660
|
-
}
|
|
3661
|
-
if (obj.value !== void 0) {
|
|
3662
|
-
return __spreadProps2(__spreadValues2({}, obj), { value: fn(obj.value) });
|
|
3663
|
-
}
|
|
3834
|
+
function mapAnimatable(raw, fn, wrapStatic = false) {
|
|
3835
|
+
const read = readAnimatable(raw);
|
|
3836
|
+
if (read.kind === "absent") return raw;
|
|
3837
|
+
if (read.kind === "static") {
|
|
3838
|
+
const mapped = fn(read.value);
|
|
3839
|
+
const wasRawStatic = typeof raw === "number" || Array.isArray(raw);
|
|
3840
|
+
return wasRawStatic && !wrapStatic ? mapped : { value: mapped };
|
|
3664
3841
|
}
|
|
3665
|
-
|
|
3666
|
-
}
|
|
3667
|
-
|
|
3668
|
-
if (
|
|
3669
|
-
if (
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
return __spreadProps2(__spreadValues2({}, obj), {
|
|
3673
|
-
keyframes: obj.keyframes.map((kf) => kf && kf.value !== void 0 ? __spreadProps2(__spreadValues2({}, kf), { value: fn(kf.value) }) : kf)
|
|
3674
|
-
});
|
|
3675
|
-
}
|
|
3676
|
-
if (obj.value !== void 0) {
|
|
3677
|
-
return __spreadProps2(__spreadValues2({}, obj), { value: fn(obj.value) });
|
|
3678
|
-
}
|
|
3679
|
-
}
|
|
3680
|
-
return raw;
|
|
3842
|
+
const out = {
|
|
3843
|
+
keyframes: read.keyframes.map((kf) => kf && kf.value !== void 0 ? __spreadProps2(__spreadValues2({}, kf), { value: fn(kf.value) }) : kf)
|
|
3844
|
+
};
|
|
3845
|
+
if (read.loop !== void 0) out.loop = read.loop;
|
|
3846
|
+
if (read.autoOrient !== void 0) out.autoOrient = read.autoOrient;
|
|
3847
|
+
if (read.base !== void 0) out.value = fn(read.base);
|
|
3848
|
+
return out;
|
|
3681
3849
|
}
|
|
3682
3850
|
function synthesiseScale(raw, i) {
|
|
3683
|
-
const
|
|
3684
|
-
|
|
3685
|
-
if (Array.isArray(raw)) {
|
|
3686
|
-
return { value: scalePowerFromPercent(raw) };
|
|
3687
|
-
}
|
|
3688
|
-
if (raw && typeof raw === "object") {
|
|
3689
|
-
const obj = raw;
|
|
3690
|
-
if (Array.isArray(obj.keyframes)) {
|
|
3691
|
-
return __spreadProps2(__spreadValues2({}, obj), {
|
|
3692
|
-
keyframes: obj.keyframes.map((kf) => kf && kf.value !== void 0 ? __spreadProps2(__spreadValues2({}, kf), { value: scalePowerFromUnits(kf.value) }) : kf)
|
|
3693
|
-
});
|
|
3694
|
-
}
|
|
3695
|
-
if (obj.value !== void 0) {
|
|
3696
|
-
return __spreadProps2(__spreadValues2({}, obj), { value: scalePowerFromPercent(obj.value) });
|
|
3697
|
-
}
|
|
3698
|
-
}
|
|
3699
|
-
return raw;
|
|
3851
|
+
const scalePower = (v) => [Math.pow(v[0], i), Math.pow(v[1], i)];
|
|
3852
|
+
return mapAnimatable(raw, scalePower, true);
|
|
3700
3853
|
}
|
|
3701
3854
|
var RETIME_MATERIALISATION_MODE_INLINE_G = false;
|
|
3702
3855
|
function asRetime(r) {
|
|
3703
3856
|
var _a, _b;
|
|
3704
|
-
if (r.timeCrop) {
|
|
3705
|
-
console.warn("retime: `timeCrop` is not supported yet and will be ignored");
|
|
3706
|
-
}
|
|
3707
3857
|
return { start: (_a = r.start) != null ? _a : 0, stretch: (_b = r.stretch) != null ? _b : 1 };
|
|
3708
3858
|
}
|
|
3859
|
+
var CROP_EDGE_MS = 1;
|
|
3860
|
+
function applyTimeCrop(useNode, crop, ctx) {
|
|
3861
|
+
const [start, end] = crop;
|
|
3862
|
+
if (!Number.isFinite(start) || !Number.isFinite(end)) {
|
|
3863
|
+
ctx.warnings.push("retime: timeCrop is not a pair of finite numbers \u2014 ignored");
|
|
3864
|
+
return;
|
|
3865
|
+
}
|
|
3866
|
+
const keyframes = end <= start ? [{ time: 0, value: 0 }] : [
|
|
3867
|
+
...start > 0 ? [{ time: Math.max(0, start - CROP_EDGE_MS), value: 0 }] : [],
|
|
3868
|
+
{ time: Math.max(0, start), value: 1 },
|
|
3869
|
+
{ time: end, value: 1 },
|
|
3870
|
+
{ time: end + CROP_EDGE_MS, value: 0 }
|
|
3871
|
+
];
|
|
3872
|
+
const inner = __spreadValues2({}, useNode);
|
|
3873
|
+
for (const k of Object.keys(useNode)) delete useNode[k];
|
|
3874
|
+
useNode.type = "g";
|
|
3875
|
+
useNode.children = [inner];
|
|
3876
|
+
useNode.animate = { opacity: { keyframes } };
|
|
3877
|
+
}
|
|
3709
3878
|
function concatRetime(child, parent) {
|
|
3710
3879
|
return {
|
|
3711
3880
|
start: parent.start + parent.stretch * child.start,
|
|
@@ -3765,8 +3934,10 @@ function applyAllRetimeEffects(root, ctx) {
|
|
|
3765
3934
|
for (const useNode of sites) {
|
|
3766
3935
|
const retime = readCloneRetime(useNode);
|
|
3767
3936
|
if (!retime) continue;
|
|
3937
|
+
const crop = retime.timeCrop;
|
|
3768
3938
|
clearCloneRetime(useNode);
|
|
3769
3939
|
materialiseRetime(useNode, asRetime(retime), ctx);
|
|
3940
|
+
if (crop) applyTimeCrop(useNode, crop, ctx);
|
|
3770
3941
|
}
|
|
3771
3942
|
}
|
|
3772
3943
|
function materialiseRetime(useNode, retime, ctx) {
|
|
@@ -4009,14 +4180,11 @@ function createPathSampler(d) {
|
|
|
4009
4180
|
}
|
|
4010
4181
|
var EXTEND_MARGIN_FRAC = 0.15;
|
|
4011
4182
|
function numRange(v) {
|
|
4012
|
-
|
|
4013
|
-
if (
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
const vals = o.keyframes.map((k) => Number(k.value) || 0);
|
|
4018
|
-
return { min: Math.min(...vals), max: Math.max(...vals) };
|
|
4019
|
-
}
|
|
4183
|
+
const read = readAnimatable(v);
|
|
4184
|
+
if (read.kind === "static" && typeof read.value === "number") return { min: read.value, max: read.value };
|
|
4185
|
+
if (read.kind === "animated" && read.keyframes.length) {
|
|
4186
|
+
const vals = read.keyframes.map((k) => Number(k.value) || 0);
|
|
4187
|
+
return { min: Math.min(...vals), max: Math.max(...vals) };
|
|
4020
4188
|
}
|
|
4021
4189
|
return { min: 0, max: 0 };
|
|
4022
4190
|
}
|
|
@@ -4036,11 +4204,16 @@ function estimateTextAdvance(node) {
|
|
|
4036
4204
|
var r3 = (n) => Math.round(n * 1e3) / 1e3;
|
|
4037
4205
|
function shiftAnimatable(v, by) {
|
|
4038
4206
|
if (!by || v === void 0 || v === null) return v;
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
if (
|
|
4042
|
-
|
|
4043
|
-
|
|
4207
|
+
const read = readAnimatable(v);
|
|
4208
|
+
if (read.kind === "absent") return v;
|
|
4209
|
+
if (read.kind === "static") return typeof v === "number" ? read.value + by : { value: read.value + by };
|
|
4210
|
+
const out = {
|
|
4211
|
+
keyframes: read.keyframes.map((k) => __spreadProps2(__spreadValues2({}, k), { value: (Number(k.value) || 0) + by }))
|
|
4212
|
+
};
|
|
4213
|
+
if (read.loop !== void 0) out.loop = read.loop;
|
|
4214
|
+
if (read.autoOrient !== void 0) out.autoOrient = read.autoOrient;
|
|
4215
|
+
if (read.base !== void 0) out.value = read.base + by;
|
|
4216
|
+
return out;
|
|
4044
4217
|
}
|
|
4045
4218
|
function extendedPathForBrowser(pathD, opts) {
|
|
4046
4219
|
var _a;
|
|
@@ -4096,26 +4269,7 @@ function applyTextPathEffect(node, fx, ctx) {
|
|
|
4096
4269
|
}
|
|
4097
4270
|
function applyAnimatableNumber(node, attrName, raw) {
|
|
4098
4271
|
if (raw === void 0 || raw === null) return;
|
|
4099
|
-
|
|
4100
|
-
node[attrName] = String(raw);
|
|
4101
|
-
return;
|
|
4102
|
-
}
|
|
4103
|
-
if (typeof raw === "object" && raw !== null) {
|
|
4104
|
-
const obj = raw;
|
|
4105
|
-
if (Array.isArray(obj.keyframes)) {
|
|
4106
|
-
const prevAnimate = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate : void 0;
|
|
4107
|
-
const animate = __spreadValues2({}, prevAnimate || {});
|
|
4108
|
-
const block = { keyframes: obj.keyframes };
|
|
4109
|
-
if (obj.loop !== void 0) block.loop = obj.loop;
|
|
4110
|
-
animate[attrName] = block;
|
|
4111
|
-
node.animate = animate;
|
|
4112
|
-
return;
|
|
4113
|
-
}
|
|
4114
|
-
if (typeof obj.value === "number") {
|
|
4115
|
-
node[attrName] = String(obj.value);
|
|
4116
|
-
return;
|
|
4117
|
-
}
|
|
4118
|
-
}
|
|
4272
|
+
writeAnimatableChannel(node, attrName, readAnimatable(raw), { asString: true });
|
|
4119
4273
|
}
|
|
4120
4274
|
var jsonElementFactory = (type, props, children) => {
|
|
4121
4275
|
const node = { type };
|
|
@@ -4303,13 +4457,13 @@ function materialiseGlyphTextHorizontal(node, opts) {
|
|
|
4303
4457
|
if (y !== void 0) pen.y = y;
|
|
4304
4458
|
pen.x += (_a2 = parseLen(el.dx)) != null ? _a2 : 0;
|
|
4305
4459
|
pen.y += (_b2 = parseLen(el.dy)) != null ? _b2 : 0;
|
|
4306
|
-
const content = (_c2 = str(el[
|
|
4460
|
+
const content = (_c2 = str(el[TEXT_CONTENT_ATTR])) != null ? _c2 : str(el[TEXT_ATTR]);
|
|
4307
4461
|
if (content && !((_d2 = el.children) == null ? void 0 : _d2.length)) renderChars(content, s);
|
|
4308
4462
|
if (el.children) for (const ch of el.children) walk(ch, s);
|
|
4309
4463
|
};
|
|
4310
4464
|
const rootStyle = rootStyleOf(node);
|
|
4311
4465
|
if (node.children) for (const ch of node.children) walk(ch, rootStyle);
|
|
4312
|
-
const rootContent = (_c = str(node[
|
|
4466
|
+
const rootContent = (_c = str(node[TEXT_CONTENT_ATTR])) != null ? _c : str(node[TEXT_ATTR]);
|
|
4313
4467
|
if (rootContent && !((_d = node.children) == null ? void 0 : _d.length)) renderChars(rootContent, rootStyle);
|
|
4314
4468
|
const anchor = str(node.textAnchor);
|
|
4315
4469
|
if (anchor === "middle" || anchor === "end") {
|
|
@@ -4358,7 +4512,7 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
4358
4512
|
if (y !== void 0) pen.y = y;
|
|
4359
4513
|
pen.x += (_a2 = parseLen(el.dx)) != null ? _a2 : 0;
|
|
4360
4514
|
pen.y += (_b2 = parseLen(el.dy)) != null ? _b2 : 0;
|
|
4361
|
-
const content = (_c2 = str(el[
|
|
4515
|
+
const content = (_c2 = str(el[TEXT_CONTENT_ATTR])) != null ? _c2 : str(el[TEXT_ATTR]);
|
|
4362
4516
|
if (content && !((_d2 = el.children) == null ? void 0 : _d2.length)) renderChars(content, s);
|
|
4363
4517
|
if (el.children) for (const ch of el.children) walk(ch, s);
|
|
4364
4518
|
};
|
|
@@ -4373,7 +4527,7 @@ function layoutGlyphTextChars(node, opts) {
|
|
|
4373
4527
|
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 });
|
|
4374
4528
|
}
|
|
4375
4529
|
}
|
|
4376
|
-
const rootContent = (_e = str(node[
|
|
4530
|
+
const rootContent = (_e = str(node[TEXT_CONTENT_ATTR])) != null ? _e : str(node[TEXT_ATTR]);
|
|
4377
4531
|
if (rootContent && !((_f = node.children) == null ? void 0 : _f.length)) renderChars(rootContent, rootStyle);
|
|
4378
4532
|
const anchor = str(node.textAnchor);
|
|
4379
4533
|
if (anchor === "middle" || anchor === "end") {
|
|
@@ -4401,7 +4555,7 @@ function layoutGlyphTextCharsAlongPath(node, pathD, opts) {
|
|
|
4401
4555
|
const walk = (el, parentStyle) => {
|
|
4402
4556
|
var _a2, _b2, _c;
|
|
4403
4557
|
const s = resolveStyle2(el, parentStyle);
|
|
4404
|
-
const content = (_a2 = str(el[
|
|
4558
|
+
const content = (_a2 = str(el[TEXT_CONTENT_ATTR])) != null ? _a2 : str(el[TEXT_ATTR]);
|
|
4405
4559
|
if (content && !((_b2 = el.children) == null ? void 0 : _b2.length)) {
|
|
4406
4560
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
4407
4561
|
const upm = (gf == null ? void 0 : gf.unitsPerEm) || 1e3;
|
|
@@ -4455,7 +4609,7 @@ function collectAlongPathCells(node, glyphs, soleFont, warnings) {
|
|
|
4455
4609
|
const walk = (el, parentStyle) => {
|
|
4456
4610
|
var _a, _b, _c;
|
|
4457
4611
|
const s = resolveStyle2(el, parentStyle);
|
|
4458
|
-
const content = (_a = str(el[
|
|
4612
|
+
const content = (_a = str(el[TEXT_CONTENT_ATTR])) != null ? _a : str(el[TEXT_ATTR]);
|
|
4459
4613
|
if (content && !((_b = el.children) == null ? void 0 : _b.length)) {
|
|
4460
4614
|
const gf = glyphFontFor(s, glyphs, soleFont, warnings);
|
|
4461
4615
|
if (gf) {
|
|
@@ -4683,9 +4837,9 @@ function applyTextGlyphsAlongPath(node, ctx, pathD, startOffset, textLength, pat
|
|
|
4683
4837
|
}
|
|
4684
4838
|
return materialiseGlyphTextAlongPath(node, pathD, startOffset, { glyphs: ctx.glyphs, warnings: ctx.warnings }, textLength, pathOverflow);
|
|
4685
4839
|
}
|
|
4686
|
-
function applyTrimPathEffect(node, trimPath,
|
|
4840
|
+
function applyTrimPathEffect(node, trimPath, ctx) {
|
|
4687
4841
|
if (!trimPath) return node;
|
|
4688
|
-
const
|
|
4842
|
+
const combined = trimPath.subPaths === PxTrimSubPaths.combined;
|
|
4689
4843
|
const leafEntries = [];
|
|
4690
4844
|
const measure = (n) => {
|
|
4691
4845
|
if (Array.isArray(n.children) && n.children.length > 0) {
|
|
@@ -4706,16 +4860,16 @@ function applyTrimPathEffect(node, trimPath, isCombinedShape, ctx) {
|
|
|
4706
4860
|
measure(node);
|
|
4707
4861
|
if (!leafEntries.length) return node;
|
|
4708
4862
|
let acc = 0;
|
|
4709
|
-
const iterOrder =
|
|
4863
|
+
const iterOrder = combined ? [...leafEntries].reverse() : leafEntries;
|
|
4710
4864
|
for (const entry of iterOrder) {
|
|
4711
4865
|
for (const sp of entry.subpaths) {
|
|
4712
|
-
if (!
|
|
4866
|
+
if (!combined) acc = 0;
|
|
4713
4867
|
sp.startOffsetPx = acc;
|
|
4714
4868
|
acc += sp.lengthPx;
|
|
4715
4869
|
}
|
|
4716
4870
|
}
|
|
4717
4871
|
const chainLengthPx = acc;
|
|
4718
|
-
if (
|
|
4872
|
+
if (combined && chainLengthPx < 1e-3) return node;
|
|
4719
4873
|
const offsetReadRaw = readAnimatable(trimPath.offset);
|
|
4720
4874
|
const offsetRead = offsetReadRaw.kind === "absent" ? { kind: "static", value: 0 } : offsetReadRaw;
|
|
4721
4875
|
const rangeReadRaw = readRangeWithCrossings(trimPath.range);
|
|
@@ -4727,18 +4881,18 @@ function applyTrimPathEffect(node, trimPath, isCombinedShape, ctx) {
|
|
|
4727
4881
|
if (leafEntries.length === 1 && leafEntries[0].leaf === node && leafEntries[0].subpaths.length === 1) {
|
|
4728
4882
|
const entry = leafEntries[0];
|
|
4729
4883
|
const sp = entry.subpaths[0];
|
|
4730
|
-
const pathLengthPx =
|
|
4884
|
+
const pathLengthPx = combined ? chainLengthPx : sp.lengthPx;
|
|
4731
4885
|
if (pathLengthPx < 1e-3) return node;
|
|
4732
|
-
const startOffsetPct =
|
|
4886
|
+
const startOffsetPct = combined ? sp.startOffsetPx / pathLengthPx : 0;
|
|
4733
4887
|
return collapseLeafWithTrim(entry.leaf, pathLengthPx, startOffsetPct, minMaxOffset, offsetRead, rangeRead);
|
|
4734
4888
|
}
|
|
4735
4889
|
const replacements = /* @__PURE__ */ new Map();
|
|
4736
4890
|
for (const entry of leafEntries) {
|
|
4737
4891
|
const newChildren = [];
|
|
4738
4892
|
for (const sp of entry.subpaths) {
|
|
4739
|
-
const pathLengthPx =
|
|
4893
|
+
const pathLengthPx = combined ? chainLengthPx : sp.lengthPx;
|
|
4740
4894
|
if (pathLengthPx < 1e-3) continue;
|
|
4741
|
-
const startOffsetPct =
|
|
4895
|
+
const startOffsetPct = combined ? sp.startOffsetPx / pathLengthPx : 0;
|
|
4742
4896
|
newChildren.push(...buildSubpathNodes(entry.leaf, sp.subpath, pathLengthPx, startOffsetPct, minMaxOffset, offsetRead, rangeRead, ctx));
|
|
4743
4897
|
}
|
|
4744
4898
|
replacements.set(entry.leaf, wrapLeafAsGroup(entry.leaf, newChildren));
|
|
@@ -4845,22 +4999,8 @@ function computeAnimAttr(read, map) {
|
|
|
4845
4999
|
};
|
|
4846
5000
|
}
|
|
4847
5001
|
function applyAttr(node, attrName, attr) {
|
|
4848
|
-
var _a, _b;
|
|
4849
5002
|
if (!attr) return;
|
|
4850
|
-
|
|
4851
|
-
node[attrName] = attr.value;
|
|
4852
|
-
return;
|
|
4853
|
-
}
|
|
4854
|
-
const prevAnimate = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate : void 0;
|
|
4855
|
-
const animate = __spreadValues2({}, prevAnimate || {});
|
|
4856
|
-
const block = { keyframes: attr.keyframes };
|
|
4857
|
-
if (attr.loop !== void 0) block.loop = attr.loop;
|
|
4858
|
-
animate[attrName] = block;
|
|
4859
|
-
node.animate = animate;
|
|
4860
|
-
const firstKf = attr.keyframes[0];
|
|
4861
|
-
if (firstKf && ((_a = firstKf.value) != null ? _a : firstKf.v) !== void 0) {
|
|
4862
|
-
node[attrName] = (_b = firstKf.value) != null ? _b : firstKf.v;
|
|
4863
|
-
}
|
|
5003
|
+
writeAnimatableChannel(node, attrName, attr);
|
|
4864
5004
|
}
|
|
4865
5005
|
var OPACITY_STEP_MS = 10;
|
|
4866
5006
|
function computeOpacityFromRange(rangeRead) {
|
|
@@ -5042,9 +5182,9 @@ function applyPlayerEffects(root) {
|
|
|
5042
5182
|
nextId: 0,
|
|
5043
5183
|
contentRefInnerIds: /* @__PURE__ */ new Map(),
|
|
5044
5184
|
maskAncestorChains: /* @__PURE__ */ new Map(),
|
|
5045
|
-
// Resolved engine: `frames` ONLY when explicitly set; auto/
|
|
5046
|
-
//
|
|
5047
|
-
engine: ((_a = getAnimatorConfig(root)) == null ? void 0 : _a.mode) === PxAnimatorMode.frames ? PxAnimatorEngine.frames : PxAnimatorEngine.
|
|
5185
|
+
// Resolved engine: `frames` ONLY when explicitly set; auto/waapi/unset →
|
|
5186
|
+
// waapi (we're not 100% sure it's frames, and CSS/WAAPI need the inline form).
|
|
5187
|
+
engine: ((_a = getAnimatorConfig(root)) == null ? void 0 : _a.mode) === PxAnimatorMode.frames ? PxAnimatorEngine.frames : PxAnimatorEngine.waapi,
|
|
5048
5188
|
glyphs: (_b = getDefs(root)) == null ? void 0 : _b.glyphs
|
|
5049
5189
|
};
|
|
5050
5190
|
const working = clone(root);
|
|
@@ -5062,8 +5202,7 @@ function applyPlayerEffects_exceptRetime(node, ctx) {
|
|
|
5062
5202
|
const originalId = typeof node.id === "string" ? node.id : void 0;
|
|
5063
5203
|
const innerIdForContentRef = originalId ? ctx.contentRefInnerIds.get(originalId) : void 0;
|
|
5064
5204
|
if (!fx && !innerIdForContentRef) return node;
|
|
5065
|
-
const {
|
|
5066
|
-
const isCombinedShape = fx == null ? void 0 : fx.isCombinedShape;
|
|
5205
|
+
const { transformBy, repeater, maskedBy, clipPath, trimPath, clone: cloneFx, fillGradient, strokeGradient, textPath, text } = fx != null ? fx : {};
|
|
5067
5206
|
if (fx) delete node.effects;
|
|
5068
5207
|
let n = node;
|
|
5069
5208
|
let consumedByGlyphs = false;
|
|
@@ -5083,15 +5222,15 @@ function applyPlayerEffects_exceptRetime(node, ctx) {
|
|
|
5083
5222
|
if (!consumedByGlyphs) n = applyTextPathEffect(n, textPath, ctx);
|
|
5084
5223
|
n = applyFillGradientEffect(n, fillGradient, ctx);
|
|
5085
5224
|
n = applyStrokeGradientEffect(n, strokeGradient, ctx);
|
|
5086
|
-
n = applyTrimPathEffect(n, trimPath,
|
|
5225
|
+
n = applyTrimPathEffect(n, trimPath, ctx);
|
|
5087
5226
|
n = applyRepeaterEffect(n, repeater, ctx);
|
|
5088
|
-
n = applyMaskedByEffect(n, maskedBy,
|
|
5227
|
+
n = applyMaskedByEffect(n, maskedBy, transformBy, ctx);
|
|
5089
5228
|
n = applyClipPathEffect(n, clipPath, ctx);
|
|
5090
5229
|
if (innerIdForContentRef) {
|
|
5091
5230
|
applyRefHref(n, cloneFx, ctx);
|
|
5092
|
-
n = splitForContentRef(n,
|
|
5231
|
+
n = splitForContentRef(n, transformBy, originalId, innerIdForContentRef, ctx);
|
|
5093
5232
|
} else {
|
|
5094
|
-
n = applyRefAndTransformationEffect(n, cloneFx,
|
|
5233
|
+
n = applyRefAndTransformationEffect(n, cloneFx, transformBy, ctx);
|
|
5095
5234
|
}
|
|
5096
5235
|
if (cloneFx == null ? void 0 : cloneFx.retime) node.effects = { clone: { retime: cloneFx.retime } };
|
|
5097
5236
|
if (originalId) ctx.idMap.set(originalId, n);
|
|
@@ -5106,7 +5245,7 @@ function materialiseAllInTree(doc, engine, opts) {
|
|
|
5106
5245
|
let root = applyPlayerEffects(doc).root;
|
|
5107
5246
|
const duration = (_b = (_a = getAnimatorConfig(root)) == null ? void 0 : _a.duration) != null ? _b : DEFAULT_DURATION_MS;
|
|
5108
5247
|
root = materialiseInternalLoopsInTree(root, duration);
|
|
5109
|
-
if (engine === PxAnimatorEngine.
|
|
5248
|
+
if (engine === PxAnimatorEngine.waapi) {
|
|
5110
5249
|
root = materialiseMotionPathsInTree(root, opts == null ? void 0 : opts.motionPath);
|
|
5111
5250
|
root = materialiseAnimatedUseInstances(root);
|
|
5112
5251
|
root = pruneUnreferencedDefs(root);
|
|
@@ -5491,6 +5630,7 @@ function evalTransformValue(v, t) {
|
|
|
5491
5630
|
if (typeof v === "string") return parseTransformString(v);
|
|
5492
5631
|
if (v.keyframes) return partsToMatrix(interpParts(v.keyframes, t));
|
|
5493
5632
|
if (v.value) return partsToMatrix(v.value);
|
|
5633
|
+
if (typeof v === "object" && !Array.isArray(v)) return partsToMatrix(v);
|
|
5494
5634
|
return IDENTITY;
|
|
5495
5635
|
}
|
|
5496
5636
|
function nodeMatrix(node, t) {
|
|
@@ -5625,64 +5765,6 @@ function subtractMultiset(a, b) {
|
|
|
5625
5765
|
return extra;
|
|
5626
5766
|
}
|
|
5627
5767
|
|
|
5628
|
-
// src/PxAnimatorDOM.ts
|
|
5629
|
-
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
5630
|
-
function createElement(tagName, normalisedProps, style, children, textContent) {
|
|
5631
|
-
if (DISALLOWED_SVG_TAGS_LOWER.has(tagName.toLowerCase())) {
|
|
5632
|
-
console.warn("SVG tag blocked (dangerous): ", tagName);
|
|
5633
|
-
return null;
|
|
5634
|
-
}
|
|
5635
|
-
const element = document.createElementNS(SVG_NS, tagName);
|
|
5636
|
-
for (const propName in normalisedProps) {
|
|
5637
|
-
const sanitised = sanitiseAttributeValue(propName, normalisedProps[propName]);
|
|
5638
|
-
if (sanitised === void 0) continue;
|
|
5639
|
-
if (CSS_ONLY_STYLE_PROPS.has(propName)) {
|
|
5640
|
-
element.style[propName] = String(sanitised);
|
|
5641
|
-
continue;
|
|
5642
|
-
}
|
|
5643
|
-
element.setAttribute(camelCaseToKebabWordIfNeeded(propName), sanitised);
|
|
5644
|
-
}
|
|
5645
|
-
if (style) {
|
|
5646
|
-
for (const styleProp in style) {
|
|
5647
|
-
element.style[styleProp] = String(style[styleProp]);
|
|
5648
|
-
}
|
|
5649
|
-
}
|
|
5650
|
-
if (children) {
|
|
5651
|
-
for (const child of children) {
|
|
5652
|
-
element.appendChild(child);
|
|
5653
|
-
}
|
|
5654
|
-
}
|
|
5655
|
-
if (textContent) element.textContent = textContent;
|
|
5656
|
-
return element;
|
|
5657
|
-
}
|
|
5658
|
-
function renderNode(node, defs) {
|
|
5659
|
-
if (!node) return null;
|
|
5660
|
-
const _a = node, { type, children, style } = _a, props = __objRest(_a, ["type", "children", "style"]);
|
|
5661
|
-
const feFuncType = props.funcType;
|
|
5662
|
-
if (feFuncType !== void 0) delete props.funcType;
|
|
5663
|
-
const nodeDefs = getDefs(node) || defs;
|
|
5664
|
-
const resolvedStyle = resolveStyle(style, nodeDefs);
|
|
5665
|
-
let childElements;
|
|
5666
|
-
if (children) {
|
|
5667
|
-
for (const ch of children) {
|
|
5668
|
-
const child = renderNode(ch, nodeDefs);
|
|
5669
|
-
if (child) {
|
|
5670
|
-
if (!childElements) childElements = [];
|
|
5671
|
-
childElements.push(child);
|
|
5672
|
-
}
|
|
5673
|
-
}
|
|
5674
|
-
}
|
|
5675
|
-
const element = createElement(
|
|
5676
|
-
type || "g",
|
|
5677
|
-
getNormalizedProps(props),
|
|
5678
|
-
resolvedStyle,
|
|
5679
|
-
childElements,
|
|
5680
|
-
props[TEXT_ATTR] || props[TEXT_CONTENT_ATTR]
|
|
5681
|
-
);
|
|
5682
|
-
if (element && feFuncType !== void 0) element.setAttribute("type", feFuncType);
|
|
5683
|
-
return element;
|
|
5684
|
-
}
|
|
5685
|
-
|
|
5686
5768
|
// src/PxAnimatorTriggers.ts
|
|
5687
5769
|
function setupAnimationTriggers(api, config) {
|
|
5688
5770
|
const { startOn, outAction = "continue", scrollIntoViewThreshold = 0 } = config;
|
|
@@ -5872,7 +5954,7 @@ function createCssKf(kf, t, propName, unsupportedSet) {
|
|
|
5872
5954
|
} else {
|
|
5873
5955
|
cssValue = "" + value;
|
|
5874
5956
|
}
|
|
5875
|
-
if (!CSS.supports(cssKey, cssValue)) unsupportedSet.add(cssKey);
|
|
5957
|
+
if (!CSS.supports(camelCaseToKebabWordIfNeeded(cssKey), cssValue)) unsupportedSet.add(cssKey);
|
|
5876
5958
|
cssKey = kebabToCamelCaseWord(cssKey);
|
|
5877
5959
|
cssKf[cssKey] = cssValue;
|
|
5878
5960
|
return cssKf;
|
|
@@ -5949,7 +6031,7 @@ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsuppo
|
|
|
5949
6031
|
console.warn("createFrameLoopAnimator: No root element provided");
|
|
5950
6032
|
}
|
|
5951
6033
|
}
|
|
5952
|
-
const bindings = getNormalisedBindings(doc, PxAnimatorEngine.
|
|
6034
|
+
const bindings = getNormalisedBindings(doc, PxAnimatorEngine.waapi);
|
|
5953
6035
|
const animations = [];
|
|
5954
6036
|
const _iterations = config.iterations;
|
|
5955
6037
|
let iterations;
|
|
@@ -6095,9 +6177,8 @@ function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsuppo
|
|
|
6095
6177
|
return api;
|
|
6096
6178
|
}
|
|
6097
6179
|
|
|
6098
|
-
// src/
|
|
6099
|
-
function
|
|
6100
|
-
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
6180
|
+
// src/PxAnimatorBind.ts
|
|
6181
|
+
function finaliseAnimator(animatorConfig, callbacks, make) {
|
|
6101
6182
|
let apiRef;
|
|
6102
6183
|
let effectiveCallbacks = callbacks;
|
|
6103
6184
|
if (animatorConfig.resetOnFinish) {
|
|
@@ -6109,29 +6190,99 @@ function createAnimatorFromConfig(doc, adapter, callbacks, rootElement) {
|
|
|
6109
6190
|
}
|
|
6110
6191
|
});
|
|
6111
6192
|
}
|
|
6112
|
-
|
|
6113
|
-
if (animatorConfig.mode === PxAnimatorMode.frames) {
|
|
6114
|
-
res = createFrameLoopAnimator(doc, adapter, effectiveCallbacks, rootElement);
|
|
6115
|
-
} else {
|
|
6116
|
-
res = createWebApiAnimator(
|
|
6117
|
-
doc,
|
|
6118
|
-
effectiveCallbacks,
|
|
6119
|
-
rootElement,
|
|
6120
|
-
animatorConfig.mode === PxAnimatorMode.webapi
|
|
6121
|
-
// forcing webapi
|
|
6122
|
-
) || createFrameLoopAnimator(doc, adapter, effectiveCallbacks, rootElement);
|
|
6123
|
-
}
|
|
6193
|
+
const res = make(effectiveCallbacks);
|
|
6124
6194
|
apiRef = res;
|
|
6125
6195
|
if (animatorConfig.debugInstName) {
|
|
6126
6196
|
window[animatorConfig.debugInstName] = res;
|
|
6127
6197
|
}
|
|
6128
6198
|
return res;
|
|
6129
6199
|
}
|
|
6200
|
+
function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
|
|
6201
|
+
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
6202
|
+
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
6203
|
+
if (animatorConfig.mode === PxAnimatorMode.frames) {
|
|
6204
|
+
return createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
6205
|
+
}
|
|
6206
|
+
return createWebApiAnimator(
|
|
6207
|
+
doc,
|
|
6208
|
+
cb,
|
|
6209
|
+
rootElement,
|
|
6210
|
+
animatorConfig.mode === PxAnimatorMode.waapi
|
|
6211
|
+
// forcing waapi
|
|
6212
|
+
) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
6213
|
+
});
|
|
6214
|
+
}
|
|
6215
|
+
|
|
6216
|
+
// src/PxAnimatorDOM.ts
|
|
6217
|
+
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
6218
|
+
function createElement(tagName, normalisedProps, style, children, textContent) {
|
|
6219
|
+
if (DISALLOWED_SVG_TAGS_LOWER.has(tagName.toLowerCase())) {
|
|
6220
|
+
console.warn("SVG tag blocked (dangerous): ", tagName);
|
|
6221
|
+
return null;
|
|
6222
|
+
}
|
|
6223
|
+
const element = document.createElementNS(SVG_NS, tagName);
|
|
6224
|
+
for (const propName in normalisedProps) {
|
|
6225
|
+
const sanitised = sanitiseAttributeValue(propName, normalisedProps[propName]);
|
|
6226
|
+
if (sanitised === void 0) continue;
|
|
6227
|
+
if (CSS_ONLY_STYLE_PROPS.has(propName)) {
|
|
6228
|
+
element.style[propName] = String(sanitised);
|
|
6229
|
+
continue;
|
|
6230
|
+
}
|
|
6231
|
+
element.setAttribute(camelCaseToKebabWordIfNeeded(propName), sanitised);
|
|
6232
|
+
}
|
|
6233
|
+
if (style) {
|
|
6234
|
+
for (const styleProp in style) {
|
|
6235
|
+
element.style[styleProp] = String(style[styleProp]);
|
|
6236
|
+
}
|
|
6237
|
+
}
|
|
6238
|
+
if (children) {
|
|
6239
|
+
for (const child of children) {
|
|
6240
|
+
element.appendChild(child);
|
|
6241
|
+
}
|
|
6242
|
+
}
|
|
6243
|
+
if (textContent) element.textContent = textContent;
|
|
6244
|
+
return element;
|
|
6245
|
+
}
|
|
6246
|
+
function renderNode(node, defs) {
|
|
6247
|
+
if (!node) return null;
|
|
6248
|
+
const _a = node, { type, children, style } = _a, props = __objRest(_a, ["type", "children", "style"]);
|
|
6249
|
+
const domType = props.domType;
|
|
6250
|
+
if (domType !== void 0) delete props.domType;
|
|
6251
|
+
const nodeDefs = getDefs(node) || defs;
|
|
6252
|
+
const resolvedStyle = resolveStyle(style, nodeDefs);
|
|
6253
|
+
let childElements;
|
|
6254
|
+
if (children) {
|
|
6255
|
+
for (const ch of children) {
|
|
6256
|
+
const child = renderNode(ch, nodeDefs);
|
|
6257
|
+
if (child) {
|
|
6258
|
+
if (!childElements) childElements = [];
|
|
6259
|
+
childElements.push(child);
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
}
|
|
6263
|
+
const element = createElement(
|
|
6264
|
+
type || "g",
|
|
6265
|
+
getNormalizedProps(props),
|
|
6266
|
+
resolvedStyle,
|
|
6267
|
+
childElements,
|
|
6268
|
+
props[TEXT_CONTENT_ATTR] || props[TEXT_ATTR]
|
|
6269
|
+
);
|
|
6270
|
+
if (element && domType !== void 0) element.setAttribute("type", domType);
|
|
6271
|
+
return element;
|
|
6272
|
+
}
|
|
6273
|
+
|
|
6274
|
+
// src/PxAnimatorKeys.ts
|
|
6275
|
+
var PX_ANIMATOR_DATA_KEY = "data";
|
|
6276
|
+
|
|
6277
|
+
// src/PxAnimator.ts
|
|
6278
|
+
function createAnimatorFromConfig(doc, adapter, callbacks, rootElement) {
|
|
6279
|
+
return bindWithEngineChoice(doc, adapter, callbacks, rootElement);
|
|
6280
|
+
}
|
|
6130
6281
|
function createAnimatorImpl(doc, adapter, callbacks, containerElement) {
|
|
6131
6282
|
const effectsWarnings = validateNodeEffects(doc);
|
|
6132
6283
|
for (const w of effectsWarnings) console.warn("[PxAnimator] effects shape warning:", w);
|
|
6133
6284
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
6134
|
-
const engine = animatorConfig.mode === PxAnimatorMode.frames ? PxAnimatorEngine.frames : PxAnimatorEngine.
|
|
6285
|
+
const engine = animatorConfig.mode === PxAnimatorMode.frames ? PxAnimatorEngine.frames : PxAnimatorEngine.waapi;
|
|
6135
6286
|
doc = materialiseAllInTree(doc, engine);
|
|
6136
6287
|
let rootElement = null;
|
|
6137
6288
|
if (containerElement) {
|
|
@@ -6146,7 +6297,6 @@ function createAnimatorImpl(doc, adapter, callbacks, containerElement) {
|
|
|
6146
6297
|
}
|
|
6147
6298
|
return createAnimatorFromConfig(doc, adapter, callbacks, rootElement);
|
|
6148
6299
|
}
|
|
6149
|
-
var PX_ANIMATOR_DATA_KEY = "data";
|
|
6150
6300
|
function createAnimator(options) {
|
|
6151
6301
|
const { src, data, adapter, callbacks, container } = options;
|
|
6152
6302
|
if (data !== void 0 && src !== void 0) {
|
|
@@ -6254,6 +6404,7 @@ export {
|
|
|
6254
6404
|
PxGradientType,
|
|
6255
6405
|
PxGradientUnits,
|
|
6256
6406
|
PxKeyframeSchema,
|
|
6407
|
+
PxKeyframeValueSchema,
|
|
6257
6408
|
PxLoopSchema,
|
|
6258
6409
|
PxMaskedByEffectSchema,
|
|
6259
6410
|
PxNodeBase,
|
|
@@ -6265,9 +6416,9 @@ export {
|
|
|
6265
6416
|
PxSvgNodeExtra,
|
|
6266
6417
|
PxTextEffectSchema,
|
|
6267
6418
|
PxTextPathEffectSchema,
|
|
6419
|
+
PxTransformByEffectSchema,
|
|
6268
6420
|
PxTransformPartsSchema,
|
|
6269
6421
|
PxTransformValueSchema,
|
|
6270
|
-
PxTransformationEffectSchema,
|
|
6271
6422
|
PxTriggerSchema,
|
|
6272
6423
|
PxTrimPathEffectSchema,
|
|
6273
6424
|
STYLE_ATTR_NAMES,
|