@shotstack/shotstack-studio 1.1.2 → 1.2.1
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/dist/core/loaders/asset-loader.d.ts +9 -2
- package/dist/core/schemas/asset.d.ts +10 -14
- package/dist/core/schemas/audio-asset.d.ts +6 -10
- package/dist/core/schemas/clip.d.ts +29 -43
- package/dist/core/schemas/edit.d.ts +87 -115
- package/dist/core/schemas/html-asset.d.ts +2 -2
- package/dist/core/schemas/track.d.ts +33 -47
- package/dist/core/schemas/video-asset.d.ts +6 -10
- package/dist/core/shotstack-canvas.d.ts +1 -0
- package/dist/shotstack-studio.es.js +649 -547
- package/dist/shotstack-studio.umd.js +6 -6
- package/package.json +1 -1
- package/readme.md +2 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Filter as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import { FFmpeg as
|
|
6
|
-
class
|
|
1
|
+
import * as v from "pixi.js";
|
|
2
|
+
import { Filter as Kt, deprecation as Ht, GpuProgram as Bt, GlProgram as $t, Color as jt } from "pixi.js";
|
|
3
|
+
import * as ft from "opentype.js";
|
|
4
|
+
import * as Ut from "howler";
|
|
5
|
+
import { FFmpeg as Wt } from "@ffmpeg/ffmpeg";
|
|
6
|
+
class It {
|
|
7
7
|
events;
|
|
8
8
|
constructor() {
|
|
9
9
|
this.events = {};
|
|
@@ -23,31 +23,92 @@ class At {
|
|
|
23
23
|
i(t);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class
|
|
26
|
+
class Xt extends It {
|
|
27
27
|
registry;
|
|
28
28
|
constructor() {
|
|
29
29
|
super(), this.registry = {};
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
class
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
class Te {
|
|
33
|
+
static VIDEO_EXTENSIONS = [".mp4", ".m4v", ".webm", ".ogg", ".ogv"];
|
|
34
|
+
static VIDEO_MIME = {
|
|
35
|
+
".mp4": "video/mp4",
|
|
36
|
+
".m4v": "video/mp4",
|
|
37
|
+
".webm": "video/webm",
|
|
38
|
+
".ogg": "video/ogg",
|
|
39
|
+
".ogv": "video/ogg"
|
|
40
|
+
};
|
|
41
|
+
loadTracker = new Xt();
|
|
37
42
|
async load(e, t) {
|
|
38
43
|
this.updateAssetLoadMetadata(e, "pending", 0);
|
|
39
44
|
try {
|
|
40
|
-
const i =
|
|
41
|
-
|
|
45
|
+
const i = this.extractUrl(t);
|
|
46
|
+
if (i && await this.isPlayableVideo(i)) {
|
|
47
|
+
const n = await this.loadVideoTexture(e, i, t);
|
|
48
|
+
return this.updateAssetLoadMetadata(e, "success", 1), n;
|
|
49
|
+
}
|
|
50
|
+
const s = await v.Assets.load(t, (n) => {
|
|
51
|
+
this.updateAssetLoadMetadata(e, "loading", n);
|
|
42
52
|
});
|
|
43
|
-
return this.updateAssetLoadMetadata(e, "success", 1),
|
|
53
|
+
return this.updateAssetLoadMetadata(e, "success", 1), s;
|
|
44
54
|
} catch {
|
|
45
55
|
return this.updateAssetLoadMetadata(e, "failed", 1), null;
|
|
46
56
|
}
|
|
47
57
|
}
|
|
48
58
|
getProgress() {
|
|
49
59
|
const e = Object.keys(this.loadTracker.registry);
|
|
50
|
-
return e.reduce((i, s) => i + this.loadTracker.registry[s].progress, 0) / e.length;
|
|
60
|
+
return e.length === 0 ? 0 : e.reduce((i, s) => i + this.loadTracker.registry[s].progress, 0) / e.length;
|
|
61
|
+
}
|
|
62
|
+
extractUrl(e) {
|
|
63
|
+
if (typeof e == "string") return e;
|
|
64
|
+
const t = Array.isArray(e.src) ? e.src[0] : e.src;
|
|
65
|
+
return typeof t == "string" ? t : t?.src;
|
|
66
|
+
}
|
|
67
|
+
hasVideoExtension(e) {
|
|
68
|
+
const t = new URL(e, window.location.origin).pathname.toLowerCase();
|
|
69
|
+
return Te.VIDEO_EXTENSIONS.some((i) => t.endsWith(i));
|
|
70
|
+
}
|
|
71
|
+
async getContentType(e) {
|
|
72
|
+
try {
|
|
73
|
+
return (await fetch(e, { method: "HEAD" })).headers.get("content-type");
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
canPlayVideo(e) {
|
|
79
|
+
const t = new URL(e, window.location.origin).pathname.toLowerCase(), i = t.slice(t.lastIndexOf(".")), s = Te.VIDEO_MIME[i];
|
|
80
|
+
return s ? document.createElement("video").canPlayType(s) !== "" : !1;
|
|
81
|
+
}
|
|
82
|
+
async isPlayableVideo(e) {
|
|
83
|
+
if (this.hasVideoExtension(e)) return this.canPlayVideo(e);
|
|
84
|
+
const t = await this.getContentType(e);
|
|
85
|
+
return t?.startsWith("video/") ? document.createElement("video").canPlayType(t) !== "" : !1;
|
|
86
|
+
}
|
|
87
|
+
async loadVideoTexture(e, t, i) {
|
|
88
|
+
const s = typeof i == "object" ? i.data ?? {} : {};
|
|
89
|
+
return new Promise((n, r) => {
|
|
90
|
+
const o = document.createElement("video");
|
|
91
|
+
o.crossOrigin = "anonymous", o.playsInline = !0, o.preload = "metadata";
|
|
92
|
+
const h = setTimeout(() => r(new Error("Video loading timeout")), 1e4), c = () => clearTimeout(h), l = () => {
|
|
93
|
+
if (c(), o.readyState >= 1)
|
|
94
|
+
try {
|
|
95
|
+
const m = new v.VideoSource({
|
|
96
|
+
resource: o,
|
|
97
|
+
...s
|
|
98
|
+
});
|
|
99
|
+
n(new v.Texture({ source: m }));
|
|
100
|
+
} catch (m) {
|
|
101
|
+
r(m);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
o.addEventListener("loadedmetadata", l, { once: !0 }), o.addEventListener(
|
|
105
|
+
"error",
|
|
106
|
+
() => {
|
|
107
|
+
c(), r(new Error("Video loading failed"));
|
|
108
|
+
},
|
|
109
|
+
{ once: !0 }
|
|
110
|
+
), this.updateAssetLoadMetadata(e, "loading", 0.5), o.src = t;
|
|
111
|
+
});
|
|
51
112
|
}
|
|
52
113
|
updateAssetLoadMetadata(e, t, i) {
|
|
53
114
|
this.loadTracker.registry[e] ? (this.loadTracker.registry[e].progress = i, this.loadTracker.registry[e].status = t) : this.loadTracker.registry[e] = { progress: i, status: t };
|
|
@@ -55,16 +116,16 @@ class Wt {
|
|
|
55
116
|
this.loadTracker.emit("onAssetLoadInfoUpdated", { registry: s });
|
|
56
117
|
}
|
|
57
118
|
}
|
|
58
|
-
class
|
|
119
|
+
class Ve {
|
|
59
120
|
static Name = "FontLoadParser";
|
|
60
121
|
name;
|
|
61
122
|
extension;
|
|
62
123
|
validFontExtensions;
|
|
63
124
|
woff2Decompressor;
|
|
64
125
|
constructor() {
|
|
65
|
-
this.name =
|
|
66
|
-
type: [
|
|
67
|
-
priority:
|
|
126
|
+
this.name = Ve.Name, this.extension = {
|
|
127
|
+
type: [v.ExtensionType.LoadParser],
|
|
128
|
+
priority: v.LoaderParserPriority.High,
|
|
68
129
|
ref: null
|
|
69
130
|
}, this.validFontExtensions = ["ttf", "otf", "woff", "woff2"], this.woff2Decompressor = null;
|
|
70
131
|
}
|
|
@@ -75,13 +136,13 @@ class Ze {
|
|
|
75
136
|
async load(e, t, i) {
|
|
76
137
|
const s = e.split("?")[0]?.split(".").pop()?.toLowerCase() ?? "", n = await fetch(e).then((p) => p.arrayBuffer());
|
|
77
138
|
if (s !== "woff2") {
|
|
78
|
-
const p =
|
|
139
|
+
const p = ft.parse(new Uint8Array(n).buffer), k = p.names.fontFamily.en || p.names.fontFamily[Object.keys(p.names.fontFamily)[0]], A = new FontFace(k, `url(${e})`);
|
|
79
140
|
return await A.load(), document.fonts.add(A), A;
|
|
80
141
|
}
|
|
81
142
|
if (await this.loadWoff2Decompressor(), !this.woff2Decompressor)
|
|
82
143
|
throw new Error("Cannot initialize Woff2 decompressor.");
|
|
83
|
-
const r = this.woff2Decompressor.decompress(n), o =
|
|
84
|
-
return await
|
|
144
|
+
const r = this.woff2Decompressor.decompress(n), o = ft.parse(new Uint8Array(r).buffer), h = o.names.fontFamily.en || o.names.fontFamily[Object.keys(o.names.fontFamily)[0]], c = new Blob([r], { type: "font/ttf" }), l = URL.createObjectURL(c), m = new FontFace(h, `url(${l})`);
|
|
145
|
+
return await m.load(), document.fonts.add(m), m;
|
|
85
146
|
}
|
|
86
147
|
async loadWoff2Decompressor() {
|
|
87
148
|
if (this.woff2Decompressor)
|
|
@@ -131,14 +192,14 @@ var C;
|
|
|
131
192
|
}
|
|
132
193
|
a.joinValues = i, a.jsonStringifyReplacer = (s, n) => typeof n == "bigint" ? n.toString() : n;
|
|
133
194
|
})(C || (C = {}));
|
|
134
|
-
var
|
|
195
|
+
var pt;
|
|
135
196
|
(function(a) {
|
|
136
197
|
a.mergeShapes = (e, t) => ({
|
|
137
198
|
...e,
|
|
138
199
|
...t
|
|
139
200
|
// second overwrites first
|
|
140
201
|
});
|
|
141
|
-
})(
|
|
202
|
+
})(pt || (pt = {}));
|
|
142
203
|
const f = C.arrayToEnum([
|
|
143
204
|
"string",
|
|
144
205
|
"nan",
|
|
@@ -319,7 +380,7 @@ let Yt = ke;
|
|
|
319
380
|
function Ye() {
|
|
320
381
|
return Yt;
|
|
321
382
|
}
|
|
322
|
-
const
|
|
383
|
+
const qe = (a) => {
|
|
323
384
|
const { data: e, path: t, errorMaps: i, issueData: s } = a, n = [...t, ...s.path || []], r = {
|
|
324
385
|
...s,
|
|
325
386
|
path: n
|
|
@@ -341,7 +402,7 @@ const Xe = (a) => {
|
|
|
341
402
|
};
|
|
342
403
|
};
|
|
343
404
|
function d(a, e) {
|
|
344
|
-
const t = Ye(), i =
|
|
405
|
+
const t = Ye(), i = qe({
|
|
345
406
|
issueData: e,
|
|
346
407
|
data: a.data,
|
|
347
408
|
path: a.path,
|
|
@@ -358,7 +419,7 @@ function d(a, e) {
|
|
|
358
419
|
});
|
|
359
420
|
a.common.issues.push(i);
|
|
360
421
|
}
|
|
361
|
-
class
|
|
422
|
+
class z {
|
|
362
423
|
constructor() {
|
|
363
424
|
this.value = "valid";
|
|
364
425
|
}
|
|
@@ -372,7 +433,7 @@ class I {
|
|
|
372
433
|
const i = [];
|
|
373
434
|
for (const s of t) {
|
|
374
435
|
if (s.status === "aborted")
|
|
375
|
-
return
|
|
436
|
+
return w;
|
|
376
437
|
s.status === "dirty" && e.dirty(), i.push(s.value);
|
|
377
438
|
}
|
|
378
439
|
return { status: e.value, value: i };
|
|
@@ -386,36 +447,36 @@ class I {
|
|
|
386
447
|
value: r
|
|
387
448
|
});
|
|
388
449
|
}
|
|
389
|
-
return
|
|
450
|
+
return z.mergeObjectSync(e, i);
|
|
390
451
|
}
|
|
391
452
|
static mergeObjectSync(e, t) {
|
|
392
453
|
const i = {};
|
|
393
454
|
for (const s of t) {
|
|
394
455
|
const { key: n, value: r } = s;
|
|
395
456
|
if (n.status === "aborted" || r.status === "aborted")
|
|
396
|
-
return
|
|
457
|
+
return w;
|
|
397
458
|
n.status === "dirty" && e.dirty(), r.status === "dirty" && e.dirty(), n.value !== "__proto__" && (typeof r.value < "u" || s.alwaysSet) && (i[n.value] = r.value);
|
|
398
459
|
}
|
|
399
460
|
return { status: e.value, value: i };
|
|
400
461
|
}
|
|
401
462
|
}
|
|
402
|
-
const
|
|
463
|
+
const w = Object.freeze({
|
|
403
464
|
status: "aborted"
|
|
404
|
-
}), ye = (a) => ({ status: "dirty", value: a }), M = (a) => ({ status: "valid", value: a }),
|
|
405
|
-
function
|
|
465
|
+
}), ye = (a) => ({ status: "dirty", value: a }), M = (a) => ({ status: "valid", value: a }), mt = (a) => a.status === "aborted", gt = (a) => a.status === "dirty", fe = (a) => a.status === "valid", Oe = (a) => typeof Promise < "u" && a instanceof Promise;
|
|
466
|
+
function Ae(a, e, t, i) {
|
|
406
467
|
if (typeof e == "function" ? a !== e || !0 : !e.has(a)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
407
468
|
return e.get(a);
|
|
408
469
|
}
|
|
409
|
-
function
|
|
470
|
+
function Rt(a, e, t, i, s) {
|
|
410
471
|
if (typeof e == "function" ? a !== e || !0 : !e.has(a)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
411
472
|
return e.set(a, t), t;
|
|
412
473
|
}
|
|
413
|
-
var
|
|
474
|
+
var g;
|
|
414
475
|
(function(a) {
|
|
415
476
|
a.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, a.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
416
|
-
})(
|
|
477
|
+
})(g || (g = {}));
|
|
417
478
|
var ve, xe;
|
|
418
|
-
class
|
|
479
|
+
class V {
|
|
419
480
|
constructor(e, t, i, s) {
|
|
420
481
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = i, this._key = s;
|
|
421
482
|
}
|
|
@@ -423,7 +484,7 @@ class K {
|
|
|
423
484
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
424
485
|
}
|
|
425
486
|
}
|
|
426
|
-
const
|
|
487
|
+
const yt = (a, e) => {
|
|
427
488
|
if (fe(e))
|
|
428
489
|
return { success: !0, data: e.value };
|
|
429
490
|
if (!a.common.issues.length)
|
|
@@ -469,7 +530,7 @@ class b {
|
|
|
469
530
|
}
|
|
470
531
|
_processInputParams(e) {
|
|
471
532
|
return {
|
|
472
|
-
status: new
|
|
533
|
+
status: new z(),
|
|
473
534
|
ctx: {
|
|
474
535
|
common: e.parent.common,
|
|
475
536
|
data: e.data,
|
|
@@ -482,7 +543,7 @@ class b {
|
|
|
482
543
|
}
|
|
483
544
|
_parseSync(e) {
|
|
484
545
|
const t = this._parse(e);
|
|
485
|
-
if (
|
|
546
|
+
if (Oe(t))
|
|
486
547
|
throw new Error("Synchronous parse encountered promise.");
|
|
487
548
|
return t;
|
|
488
549
|
}
|
|
@@ -510,7 +571,7 @@ class b {
|
|
|
510
571
|
data: e,
|
|
511
572
|
parsedType: q(e)
|
|
512
573
|
}, n = this._parseSync({ data: e, path: s.path, parent: s });
|
|
513
|
-
return
|
|
574
|
+
return yt(s, n);
|
|
514
575
|
}
|
|
515
576
|
"~validate"(e) {
|
|
516
577
|
var t, i;
|
|
@@ -563,8 +624,8 @@ class b {
|
|
|
563
624
|
parent: null,
|
|
564
625
|
data: e,
|
|
565
626
|
parsedType: q(e)
|
|
566
|
-
}, s = this._parse({ data: e, path: i.path, parent: i }), n = await (
|
|
567
|
-
return
|
|
627
|
+
}, s = this._parse({ data: e, path: i.path, parent: i }), n = await (Oe(s) ? s : Promise.resolve(s));
|
|
628
|
+
return yt(i, n);
|
|
568
629
|
}
|
|
569
630
|
refine(e, t) {
|
|
570
631
|
const i = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
|
|
@@ -580,9 +641,9 @@ class b {
|
|
|
580
641
|
return this._refinement((i, s) => e(i) ? !0 : (s.addIssue(typeof t == "function" ? t(i, s) : t), !1));
|
|
581
642
|
}
|
|
582
643
|
_refinement(e) {
|
|
583
|
-
return new
|
|
644
|
+
return new X({
|
|
584
645
|
schema: this,
|
|
585
|
-
typeName:
|
|
646
|
+
typeName: x.ZodEffects,
|
|
586
647
|
effect: { type: "refinement", refinement: e }
|
|
587
648
|
});
|
|
588
649
|
}
|
|
@@ -618,36 +679,36 @@ class b {
|
|
|
618
679
|
return ze.create(this, e, this._def);
|
|
619
680
|
}
|
|
620
681
|
transform(e) {
|
|
621
|
-
return new
|
|
682
|
+
return new X({
|
|
622
683
|
..._(this._def),
|
|
623
684
|
schema: this,
|
|
624
|
-
typeName:
|
|
685
|
+
typeName: x.ZodEffects,
|
|
625
686
|
effect: { type: "transform", transform: e }
|
|
626
687
|
});
|
|
627
688
|
}
|
|
628
689
|
default(e) {
|
|
629
690
|
const t = typeof e == "function" ? e : () => e;
|
|
630
|
-
return new
|
|
691
|
+
return new Ne({
|
|
631
692
|
..._(this._def),
|
|
632
693
|
innerType: this,
|
|
633
694
|
defaultValue: t,
|
|
634
|
-
typeName:
|
|
695
|
+
typeName: x.ZodDefault
|
|
635
696
|
});
|
|
636
697
|
}
|
|
637
698
|
brand() {
|
|
638
|
-
return new
|
|
639
|
-
typeName:
|
|
699
|
+
return new Mt({
|
|
700
|
+
typeName: x.ZodBranded,
|
|
640
701
|
type: this,
|
|
641
702
|
..._(this._def)
|
|
642
703
|
});
|
|
643
704
|
}
|
|
644
705
|
catch(e) {
|
|
645
706
|
const t = typeof e == "function" ? e : () => e;
|
|
646
|
-
return new
|
|
707
|
+
return new De({
|
|
647
708
|
..._(this._def),
|
|
648
709
|
innerType: this,
|
|
649
710
|
catchValue: t,
|
|
650
|
-
typeName:
|
|
711
|
+
typeName: x.ZodCatch
|
|
651
712
|
});
|
|
652
713
|
}
|
|
653
714
|
describe(e) {
|
|
@@ -661,7 +722,7 @@ class b {
|
|
|
661
722
|
return Ke.create(this, e);
|
|
662
723
|
}
|
|
663
724
|
readonly() {
|
|
664
|
-
return
|
|
725
|
+
return Ze.create(this);
|
|
665
726
|
}
|
|
666
727
|
isOptional() {
|
|
667
728
|
return this.safeParse(void 0).success;
|
|
@@ -670,26 +731,26 @@ class b {
|
|
|
670
731
|
return this.safeParse(null).success;
|
|
671
732
|
}
|
|
672
733
|
}
|
|
673
|
-
const
|
|
674
|
-
let
|
|
675
|
-
const
|
|
676
|
-
function
|
|
734
|
+
const qt = /^c[^\s-]{8,}$/i, Gt = /^[0-9a-z]+$/, Qt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Jt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, ei = /^[a-z0-9_-]{21}$/i, ti = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ii = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, si = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, ni = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
735
|
+
let Xe;
|
|
736
|
+
const ai = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, ri = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, oi = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, ci = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, li = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, hi = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, zt = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", ui = new RegExp(`^${zt}$`);
|
|
737
|
+
function Lt(a) {
|
|
677
738
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
678
739
|
return a.precision ? e = `${e}\\.\\d{${a.precision}}` : a.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
679
740
|
}
|
|
680
|
-
function ui(a) {
|
|
681
|
-
return new RegExp(`^${zt(a)}$`);
|
|
682
|
-
}
|
|
683
741
|
function di(a) {
|
|
684
|
-
|
|
742
|
+
return new RegExp(`^${Lt(a)}$`);
|
|
743
|
+
}
|
|
744
|
+
function fi(a) {
|
|
745
|
+
let e = `${zt}T${Lt(a)}`;
|
|
685
746
|
const t = [];
|
|
686
747
|
return t.push(a.local ? "Z?" : "Z"), a.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
687
748
|
}
|
|
688
|
-
function fi(a, e) {
|
|
689
|
-
return !!((e === "v4" || !e) && ni.test(a) || (e === "v6" || !e) && ri.test(a));
|
|
690
|
-
}
|
|
691
749
|
function pi(a, e) {
|
|
692
|
-
|
|
750
|
+
return !!((e === "v4" || !e) && ai.test(a) || (e === "v6" || !e) && oi.test(a));
|
|
751
|
+
}
|
|
752
|
+
function mi(a, e) {
|
|
753
|
+
if (!ti.test(a))
|
|
693
754
|
return !1;
|
|
694
755
|
try {
|
|
695
756
|
const [t] = a.split("."), i = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), s = JSON.parse(atob(i));
|
|
@@ -698,8 +759,8 @@ function pi(a, e) {
|
|
|
698
759
|
return !1;
|
|
699
760
|
}
|
|
700
761
|
}
|
|
701
|
-
function
|
|
702
|
-
return !!((e === "v4" || !e) &&
|
|
762
|
+
function gi(a, e) {
|
|
763
|
+
return !!((e === "v4" || !e) && ri.test(a) || (e === "v6" || !e) && ci.test(a));
|
|
703
764
|
}
|
|
704
765
|
class j extends b {
|
|
705
766
|
_parse(e) {
|
|
@@ -709,9 +770,9 @@ class j extends b {
|
|
|
709
770
|
code: u.invalid_type,
|
|
710
771
|
expected: f.string,
|
|
711
772
|
received: n.parsedType
|
|
712
|
-
}),
|
|
773
|
+
}), w;
|
|
713
774
|
}
|
|
714
|
-
const i = new
|
|
775
|
+
const i = new z();
|
|
715
776
|
let s;
|
|
716
777
|
for (const n of this._def.checks)
|
|
717
778
|
if (n.kind === "min")
|
|
@@ -750,43 +811,43 @@ class j extends b {
|
|
|
750
811
|
message: n.message
|
|
751
812
|
}), i.dirty());
|
|
752
813
|
} else if (n.kind === "email")
|
|
753
|
-
|
|
814
|
+
si.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
754
815
|
validation: "email",
|
|
755
816
|
code: u.invalid_string,
|
|
756
817
|
message: n.message
|
|
757
818
|
}), i.dirty());
|
|
758
819
|
else if (n.kind === "emoji")
|
|
759
|
-
|
|
820
|
+
Xe || (Xe = new RegExp(ni, "u")), Xe.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
760
821
|
validation: "emoji",
|
|
761
822
|
code: u.invalid_string,
|
|
762
823
|
message: n.message
|
|
763
824
|
}), i.dirty());
|
|
764
825
|
else if (n.kind === "uuid")
|
|
765
|
-
|
|
826
|
+
Jt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
766
827
|
validation: "uuid",
|
|
767
828
|
code: u.invalid_string,
|
|
768
829
|
message: n.message
|
|
769
830
|
}), i.dirty());
|
|
770
831
|
else if (n.kind === "nanoid")
|
|
771
|
-
|
|
832
|
+
ei.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
772
833
|
validation: "nanoid",
|
|
773
834
|
code: u.invalid_string,
|
|
774
835
|
message: n.message
|
|
775
836
|
}), i.dirty());
|
|
776
837
|
else if (n.kind === "cuid")
|
|
777
|
-
|
|
838
|
+
qt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
778
839
|
validation: "cuid",
|
|
779
840
|
code: u.invalid_string,
|
|
780
841
|
message: n.message
|
|
781
842
|
}), i.dirty());
|
|
782
843
|
else if (n.kind === "cuid2")
|
|
783
|
-
|
|
844
|
+
Gt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
784
845
|
validation: "cuid2",
|
|
785
846
|
code: u.invalid_string,
|
|
786
847
|
message: n.message
|
|
787
848
|
}), i.dirty());
|
|
788
849
|
else if (n.kind === "ulid")
|
|
789
|
-
|
|
850
|
+
Qt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
790
851
|
validation: "ulid",
|
|
791
852
|
code: u.invalid_string,
|
|
792
853
|
message: n.message
|
|
@@ -817,39 +878,39 @@ class j extends b {
|
|
|
817
878
|
code: u.invalid_string,
|
|
818
879
|
validation: { endsWith: n.value },
|
|
819
880
|
message: n.message
|
|
820
|
-
}), i.dirty()) : n.kind === "datetime" ?
|
|
881
|
+
}), i.dirty()) : n.kind === "datetime" ? fi(n).test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
821
882
|
code: u.invalid_string,
|
|
822
883
|
validation: "datetime",
|
|
823
884
|
message: n.message
|
|
824
|
-
}), i.dirty()) : n.kind === "date" ?
|
|
885
|
+
}), i.dirty()) : n.kind === "date" ? ui.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
825
886
|
code: u.invalid_string,
|
|
826
887
|
validation: "date",
|
|
827
888
|
message: n.message
|
|
828
|
-
}), i.dirty()) : n.kind === "time" ?
|
|
889
|
+
}), i.dirty()) : n.kind === "time" ? di(n).test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
829
890
|
code: u.invalid_string,
|
|
830
891
|
validation: "time",
|
|
831
892
|
message: n.message
|
|
832
|
-
}), i.dirty()) : n.kind === "duration" ?
|
|
893
|
+
}), i.dirty()) : n.kind === "duration" ? ii.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
833
894
|
validation: "duration",
|
|
834
895
|
code: u.invalid_string,
|
|
835
896
|
message: n.message
|
|
836
|
-
}), i.dirty()) : n.kind === "ip" ?
|
|
897
|
+
}), i.dirty()) : n.kind === "ip" ? pi(e.data, n.version) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
837
898
|
validation: "ip",
|
|
838
899
|
code: u.invalid_string,
|
|
839
900
|
message: n.message
|
|
840
|
-
}), i.dirty()) : n.kind === "jwt" ?
|
|
901
|
+
}), i.dirty()) : n.kind === "jwt" ? mi(e.data, n.alg) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
841
902
|
validation: "jwt",
|
|
842
903
|
code: u.invalid_string,
|
|
843
904
|
message: n.message
|
|
844
|
-
}), i.dirty()) : n.kind === "cidr" ?
|
|
905
|
+
}), i.dirty()) : n.kind === "cidr" ? gi(e.data, n.version) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
845
906
|
validation: "cidr",
|
|
846
907
|
code: u.invalid_string,
|
|
847
908
|
message: n.message
|
|
848
|
-
}), i.dirty()) : n.kind === "base64" ?
|
|
909
|
+
}), i.dirty()) : n.kind === "base64" ? li.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
849
910
|
validation: "base64",
|
|
850
911
|
code: u.invalid_string,
|
|
851
912
|
message: n.message
|
|
852
|
-
}), i.dirty()) : n.kind === "base64url" ?
|
|
913
|
+
}), i.dirty()) : n.kind === "base64url" ? hi.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
853
914
|
validation: "base64url",
|
|
854
915
|
code: u.invalid_string,
|
|
855
916
|
message: n.message
|
|
@@ -860,7 +921,7 @@ class j extends b {
|
|
|
860
921
|
return this.refinement((s) => e.test(s), {
|
|
861
922
|
validation: t,
|
|
862
923
|
code: u.invalid_string,
|
|
863
|
-
...
|
|
924
|
+
...g.errToObj(i)
|
|
864
925
|
});
|
|
865
926
|
}
|
|
866
927
|
_addCheck(e) {
|
|
@@ -870,46 +931,46 @@ class j extends b {
|
|
|
870
931
|
});
|
|
871
932
|
}
|
|
872
933
|
email(e) {
|
|
873
|
-
return this._addCheck({ kind: "email", ...
|
|
934
|
+
return this._addCheck({ kind: "email", ...g.errToObj(e) });
|
|
874
935
|
}
|
|
875
936
|
url(e) {
|
|
876
|
-
return this._addCheck({ kind: "url", ...
|
|
937
|
+
return this._addCheck({ kind: "url", ...g.errToObj(e) });
|
|
877
938
|
}
|
|
878
939
|
emoji(e) {
|
|
879
|
-
return this._addCheck({ kind: "emoji", ...
|
|
940
|
+
return this._addCheck({ kind: "emoji", ...g.errToObj(e) });
|
|
880
941
|
}
|
|
881
942
|
uuid(e) {
|
|
882
|
-
return this._addCheck({ kind: "uuid", ...
|
|
943
|
+
return this._addCheck({ kind: "uuid", ...g.errToObj(e) });
|
|
883
944
|
}
|
|
884
945
|
nanoid(e) {
|
|
885
|
-
return this._addCheck({ kind: "nanoid", ...
|
|
946
|
+
return this._addCheck({ kind: "nanoid", ...g.errToObj(e) });
|
|
886
947
|
}
|
|
887
948
|
cuid(e) {
|
|
888
|
-
return this._addCheck({ kind: "cuid", ...
|
|
949
|
+
return this._addCheck({ kind: "cuid", ...g.errToObj(e) });
|
|
889
950
|
}
|
|
890
951
|
cuid2(e) {
|
|
891
|
-
return this._addCheck({ kind: "cuid2", ...
|
|
952
|
+
return this._addCheck({ kind: "cuid2", ...g.errToObj(e) });
|
|
892
953
|
}
|
|
893
954
|
ulid(e) {
|
|
894
|
-
return this._addCheck({ kind: "ulid", ...
|
|
955
|
+
return this._addCheck({ kind: "ulid", ...g.errToObj(e) });
|
|
895
956
|
}
|
|
896
957
|
base64(e) {
|
|
897
|
-
return this._addCheck({ kind: "base64", ...
|
|
958
|
+
return this._addCheck({ kind: "base64", ...g.errToObj(e) });
|
|
898
959
|
}
|
|
899
960
|
base64url(e) {
|
|
900
961
|
return this._addCheck({
|
|
901
962
|
kind: "base64url",
|
|
902
|
-
...
|
|
963
|
+
...g.errToObj(e)
|
|
903
964
|
});
|
|
904
965
|
}
|
|
905
966
|
jwt(e) {
|
|
906
|
-
return this._addCheck({ kind: "jwt", ...
|
|
967
|
+
return this._addCheck({ kind: "jwt", ...g.errToObj(e) });
|
|
907
968
|
}
|
|
908
969
|
ip(e) {
|
|
909
|
-
return this._addCheck({ kind: "ip", ...
|
|
970
|
+
return this._addCheck({ kind: "ip", ...g.errToObj(e) });
|
|
910
971
|
}
|
|
911
972
|
cidr(e) {
|
|
912
|
-
return this._addCheck({ kind: "cidr", ...
|
|
973
|
+
return this._addCheck({ kind: "cidr", ...g.errToObj(e) });
|
|
913
974
|
}
|
|
914
975
|
datetime(e) {
|
|
915
976
|
var t, i;
|
|
@@ -924,7 +985,7 @@ class j extends b {
|
|
|
924
985
|
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
925
986
|
offset: (t = e?.offset) !== null && t !== void 0 ? t : !1,
|
|
926
987
|
local: (i = e?.local) !== null && i !== void 0 ? i : !1,
|
|
927
|
-
...
|
|
988
|
+
...g.errToObj(e?.message)
|
|
928
989
|
});
|
|
929
990
|
}
|
|
930
991
|
date(e) {
|
|
@@ -938,17 +999,17 @@ class j extends b {
|
|
|
938
999
|
}) : this._addCheck({
|
|
939
1000
|
kind: "time",
|
|
940
1001
|
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
941
|
-
...
|
|
1002
|
+
...g.errToObj(e?.message)
|
|
942
1003
|
});
|
|
943
1004
|
}
|
|
944
1005
|
duration(e) {
|
|
945
|
-
return this._addCheck({ kind: "duration", ...
|
|
1006
|
+
return this._addCheck({ kind: "duration", ...g.errToObj(e) });
|
|
946
1007
|
}
|
|
947
1008
|
regex(e, t) {
|
|
948
1009
|
return this._addCheck({
|
|
949
1010
|
kind: "regex",
|
|
950
1011
|
regex: e,
|
|
951
|
-
...
|
|
1012
|
+
...g.errToObj(t)
|
|
952
1013
|
});
|
|
953
1014
|
}
|
|
954
1015
|
includes(e, t) {
|
|
@@ -956,49 +1017,49 @@ class j extends b {
|
|
|
956
1017
|
kind: "includes",
|
|
957
1018
|
value: e,
|
|
958
1019
|
position: t?.position,
|
|
959
|
-
...
|
|
1020
|
+
...g.errToObj(t?.message)
|
|
960
1021
|
});
|
|
961
1022
|
}
|
|
962
1023
|
startsWith(e, t) {
|
|
963
1024
|
return this._addCheck({
|
|
964
1025
|
kind: "startsWith",
|
|
965
1026
|
value: e,
|
|
966
|
-
...
|
|
1027
|
+
...g.errToObj(t)
|
|
967
1028
|
});
|
|
968
1029
|
}
|
|
969
1030
|
endsWith(e, t) {
|
|
970
1031
|
return this._addCheck({
|
|
971
1032
|
kind: "endsWith",
|
|
972
1033
|
value: e,
|
|
973
|
-
...
|
|
1034
|
+
...g.errToObj(t)
|
|
974
1035
|
});
|
|
975
1036
|
}
|
|
976
1037
|
min(e, t) {
|
|
977
1038
|
return this._addCheck({
|
|
978
1039
|
kind: "min",
|
|
979
1040
|
value: e,
|
|
980
|
-
...
|
|
1041
|
+
...g.errToObj(t)
|
|
981
1042
|
});
|
|
982
1043
|
}
|
|
983
1044
|
max(e, t) {
|
|
984
1045
|
return this._addCheck({
|
|
985
1046
|
kind: "max",
|
|
986
1047
|
value: e,
|
|
987
|
-
...
|
|
1048
|
+
...g.errToObj(t)
|
|
988
1049
|
});
|
|
989
1050
|
}
|
|
990
1051
|
length(e, t) {
|
|
991
1052
|
return this._addCheck({
|
|
992
1053
|
kind: "length",
|
|
993
1054
|
value: e,
|
|
994
|
-
...
|
|
1055
|
+
...g.errToObj(t)
|
|
995
1056
|
});
|
|
996
1057
|
}
|
|
997
1058
|
/**
|
|
998
1059
|
* Equivalent to `.min(1)`
|
|
999
1060
|
*/
|
|
1000
1061
|
nonempty(e) {
|
|
1001
|
-
return this.min(1,
|
|
1062
|
+
return this.min(1, g.errToObj(e));
|
|
1002
1063
|
}
|
|
1003
1064
|
trim() {
|
|
1004
1065
|
return new j({
|
|
@@ -1083,12 +1144,12 @@ j.create = (a) => {
|
|
|
1083
1144
|
var e;
|
|
1084
1145
|
return new j({
|
|
1085
1146
|
checks: [],
|
|
1086
|
-
typeName:
|
|
1147
|
+
typeName: x.ZodString,
|
|
1087
1148
|
coerce: (e = a?.coerce) !== null && e !== void 0 ? e : !1,
|
|
1088
1149
|
..._(a)
|
|
1089
1150
|
});
|
|
1090
1151
|
};
|
|
1091
|
-
function
|
|
1152
|
+
function yi(a, e) {
|
|
1092
1153
|
const t = (a.toString().split(".")[1] || "").length, i = (e.toString().split(".")[1] || "").length, s = t > i ? t : i, n = parseInt(a.toFixed(s).replace(".", "")), r = parseInt(e.toFixed(s).replace(".", ""));
|
|
1093
1154
|
return n % r / Math.pow(10, s);
|
|
1094
1155
|
}
|
|
@@ -1103,10 +1164,10 @@ class pe extends b {
|
|
|
1103
1164
|
code: u.invalid_type,
|
|
1104
1165
|
expected: f.number,
|
|
1105
1166
|
received: n.parsedType
|
|
1106
|
-
}),
|
|
1167
|
+
}), w;
|
|
1107
1168
|
}
|
|
1108
1169
|
let i;
|
|
1109
|
-
const s = new
|
|
1170
|
+
const s = new z();
|
|
1110
1171
|
for (const n of this._def.checks)
|
|
1111
1172
|
n.kind === "int" ? C.isInteger(e.data) || (i = this._getOrReturnCtx(e, i), d(i, {
|
|
1112
1173
|
code: u.invalid_type,
|
|
@@ -1127,7 +1188,7 @@ class pe extends b {
|
|
|
1127
1188
|
inclusive: n.inclusive,
|
|
1128
1189
|
exact: !1,
|
|
1129
1190
|
message: n.message
|
|
1130
|
-
}), s.dirty()) : n.kind === "multipleOf" ?
|
|
1191
|
+
}), s.dirty()) : n.kind === "multipleOf" ? yi(e.data, n.value) !== 0 && (i = this._getOrReturnCtx(e, i), d(i, {
|
|
1131
1192
|
code: u.not_multiple_of,
|
|
1132
1193
|
multipleOf: n.value,
|
|
1133
1194
|
message: n.message
|
|
@@ -1138,16 +1199,16 @@ class pe extends b {
|
|
|
1138
1199
|
return { status: s.value, value: e.data };
|
|
1139
1200
|
}
|
|
1140
1201
|
gte(e, t) {
|
|
1141
|
-
return this.setLimit("min", e, !0,
|
|
1202
|
+
return this.setLimit("min", e, !0, g.toString(t));
|
|
1142
1203
|
}
|
|
1143
1204
|
gt(e, t) {
|
|
1144
|
-
return this.setLimit("min", e, !1,
|
|
1205
|
+
return this.setLimit("min", e, !1, g.toString(t));
|
|
1145
1206
|
}
|
|
1146
1207
|
lte(e, t) {
|
|
1147
|
-
return this.setLimit("max", e, !0,
|
|
1208
|
+
return this.setLimit("max", e, !0, g.toString(t));
|
|
1148
1209
|
}
|
|
1149
1210
|
lt(e, t) {
|
|
1150
|
-
return this.setLimit("max", e, !1,
|
|
1211
|
+
return this.setLimit("max", e, !1, g.toString(t));
|
|
1151
1212
|
}
|
|
1152
1213
|
setLimit(e, t, i, s) {
|
|
1153
1214
|
return new pe({
|
|
@@ -1158,7 +1219,7 @@ class pe extends b {
|
|
|
1158
1219
|
kind: e,
|
|
1159
1220
|
value: t,
|
|
1160
1221
|
inclusive: i,
|
|
1161
|
-
message:
|
|
1222
|
+
message: g.toString(s)
|
|
1162
1223
|
}
|
|
1163
1224
|
]
|
|
1164
1225
|
});
|
|
@@ -1172,7 +1233,7 @@ class pe extends b {
|
|
|
1172
1233
|
int(e) {
|
|
1173
1234
|
return this._addCheck({
|
|
1174
1235
|
kind: "int",
|
|
1175
|
-
message:
|
|
1236
|
+
message: g.toString(e)
|
|
1176
1237
|
});
|
|
1177
1238
|
}
|
|
1178
1239
|
positive(e) {
|
|
@@ -1180,7 +1241,7 @@ class pe extends b {
|
|
|
1180
1241
|
kind: "min",
|
|
1181
1242
|
value: 0,
|
|
1182
1243
|
inclusive: !1,
|
|
1183
|
-
message:
|
|
1244
|
+
message: g.toString(e)
|
|
1184
1245
|
});
|
|
1185
1246
|
}
|
|
1186
1247
|
negative(e) {
|
|
@@ -1188,7 +1249,7 @@ class pe extends b {
|
|
|
1188
1249
|
kind: "max",
|
|
1189
1250
|
value: 0,
|
|
1190
1251
|
inclusive: !1,
|
|
1191
|
-
message:
|
|
1252
|
+
message: g.toString(e)
|
|
1192
1253
|
});
|
|
1193
1254
|
}
|
|
1194
1255
|
nonpositive(e) {
|
|
@@ -1196,7 +1257,7 @@ class pe extends b {
|
|
|
1196
1257
|
kind: "max",
|
|
1197
1258
|
value: 0,
|
|
1198
1259
|
inclusive: !0,
|
|
1199
|
-
message:
|
|
1260
|
+
message: g.toString(e)
|
|
1200
1261
|
});
|
|
1201
1262
|
}
|
|
1202
1263
|
nonnegative(e) {
|
|
@@ -1204,20 +1265,20 @@ class pe extends b {
|
|
|
1204
1265
|
kind: "min",
|
|
1205
1266
|
value: 0,
|
|
1206
1267
|
inclusive: !0,
|
|
1207
|
-
message:
|
|
1268
|
+
message: g.toString(e)
|
|
1208
1269
|
});
|
|
1209
1270
|
}
|
|
1210
1271
|
multipleOf(e, t) {
|
|
1211
1272
|
return this._addCheck({
|
|
1212
1273
|
kind: "multipleOf",
|
|
1213
1274
|
value: e,
|
|
1214
|
-
message:
|
|
1275
|
+
message: g.toString(t)
|
|
1215
1276
|
});
|
|
1216
1277
|
}
|
|
1217
1278
|
finite(e) {
|
|
1218
1279
|
return this._addCheck({
|
|
1219
1280
|
kind: "finite",
|
|
1220
|
-
message:
|
|
1281
|
+
message: g.toString(e)
|
|
1221
1282
|
});
|
|
1222
1283
|
}
|
|
1223
1284
|
safe(e) {
|
|
@@ -1225,12 +1286,12 @@ class pe extends b {
|
|
|
1225
1286
|
kind: "min",
|
|
1226
1287
|
inclusive: !0,
|
|
1227
1288
|
value: Number.MIN_SAFE_INTEGER,
|
|
1228
|
-
message:
|
|
1289
|
+
message: g.toString(e)
|
|
1229
1290
|
})._addCheck({
|
|
1230
1291
|
kind: "max",
|
|
1231
1292
|
inclusive: !0,
|
|
1232
1293
|
value: Number.MAX_SAFE_INTEGER,
|
|
1233
|
-
message:
|
|
1294
|
+
message: g.toString(e)
|
|
1234
1295
|
});
|
|
1235
1296
|
}
|
|
1236
1297
|
get minValue() {
|
|
@@ -1260,7 +1321,7 @@ class pe extends b {
|
|
|
1260
1321
|
}
|
|
1261
1322
|
pe.create = (a) => new pe({
|
|
1262
1323
|
checks: [],
|
|
1263
|
-
typeName:
|
|
1324
|
+
typeName: x.ZodNumber,
|
|
1264
1325
|
coerce: a?.coerce || !1,
|
|
1265
1326
|
..._(a)
|
|
1266
1327
|
});
|
|
@@ -1278,7 +1339,7 @@ class me extends b {
|
|
|
1278
1339
|
if (this._getType(e) !== f.bigint)
|
|
1279
1340
|
return this._getInvalidInput(e);
|
|
1280
1341
|
let i;
|
|
1281
|
-
const s = new
|
|
1342
|
+
const s = new z();
|
|
1282
1343
|
for (const n of this._def.checks)
|
|
1283
1344
|
n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (i = this._getOrReturnCtx(e, i), d(i, {
|
|
1284
1345
|
code: u.too_small,
|
|
@@ -1305,19 +1366,19 @@ class me extends b {
|
|
|
1305
1366
|
code: u.invalid_type,
|
|
1306
1367
|
expected: f.bigint,
|
|
1307
1368
|
received: t.parsedType
|
|
1308
|
-
}),
|
|
1369
|
+
}), w;
|
|
1309
1370
|
}
|
|
1310
1371
|
gte(e, t) {
|
|
1311
|
-
return this.setLimit("min", e, !0,
|
|
1372
|
+
return this.setLimit("min", e, !0, g.toString(t));
|
|
1312
1373
|
}
|
|
1313
1374
|
gt(e, t) {
|
|
1314
|
-
return this.setLimit("min", e, !1,
|
|
1375
|
+
return this.setLimit("min", e, !1, g.toString(t));
|
|
1315
1376
|
}
|
|
1316
1377
|
lte(e, t) {
|
|
1317
|
-
return this.setLimit("max", e, !0,
|
|
1378
|
+
return this.setLimit("max", e, !0, g.toString(t));
|
|
1318
1379
|
}
|
|
1319
1380
|
lt(e, t) {
|
|
1320
|
-
return this.setLimit("max", e, !1,
|
|
1381
|
+
return this.setLimit("max", e, !1, g.toString(t));
|
|
1321
1382
|
}
|
|
1322
1383
|
setLimit(e, t, i, s) {
|
|
1323
1384
|
return new me({
|
|
@@ -1328,7 +1389,7 @@ class me extends b {
|
|
|
1328
1389
|
kind: e,
|
|
1329
1390
|
value: t,
|
|
1330
1391
|
inclusive: i,
|
|
1331
|
-
message:
|
|
1392
|
+
message: g.toString(s)
|
|
1332
1393
|
}
|
|
1333
1394
|
]
|
|
1334
1395
|
});
|
|
@@ -1344,7 +1405,7 @@ class me extends b {
|
|
|
1344
1405
|
kind: "min",
|
|
1345
1406
|
value: BigInt(0),
|
|
1346
1407
|
inclusive: !1,
|
|
1347
|
-
message:
|
|
1408
|
+
message: g.toString(e)
|
|
1348
1409
|
});
|
|
1349
1410
|
}
|
|
1350
1411
|
negative(e) {
|
|
@@ -1352,7 +1413,7 @@ class me extends b {
|
|
|
1352
1413
|
kind: "max",
|
|
1353
1414
|
value: BigInt(0),
|
|
1354
1415
|
inclusive: !1,
|
|
1355
|
-
message:
|
|
1416
|
+
message: g.toString(e)
|
|
1356
1417
|
});
|
|
1357
1418
|
}
|
|
1358
1419
|
nonpositive(e) {
|
|
@@ -1360,7 +1421,7 @@ class me extends b {
|
|
|
1360
1421
|
kind: "max",
|
|
1361
1422
|
value: BigInt(0),
|
|
1362
1423
|
inclusive: !0,
|
|
1363
|
-
message:
|
|
1424
|
+
message: g.toString(e)
|
|
1364
1425
|
});
|
|
1365
1426
|
}
|
|
1366
1427
|
nonnegative(e) {
|
|
@@ -1368,14 +1429,14 @@ class me extends b {
|
|
|
1368
1429
|
kind: "min",
|
|
1369
1430
|
value: BigInt(0),
|
|
1370
1431
|
inclusive: !0,
|
|
1371
|
-
message:
|
|
1432
|
+
message: g.toString(e)
|
|
1372
1433
|
});
|
|
1373
1434
|
}
|
|
1374
1435
|
multipleOf(e, t) {
|
|
1375
1436
|
return this._addCheck({
|
|
1376
1437
|
kind: "multipleOf",
|
|
1377
1438
|
value: e,
|
|
1378
|
-
message:
|
|
1439
|
+
message: g.toString(t)
|
|
1379
1440
|
});
|
|
1380
1441
|
}
|
|
1381
1442
|
get minValue() {
|
|
@@ -1395,12 +1456,12 @@ me.create = (a) => {
|
|
|
1395
1456
|
var e;
|
|
1396
1457
|
return new me({
|
|
1397
1458
|
checks: [],
|
|
1398
|
-
typeName:
|
|
1459
|
+
typeName: x.ZodBigInt,
|
|
1399
1460
|
coerce: (e = a?.coerce) !== null && e !== void 0 ? e : !1,
|
|
1400
1461
|
..._(a)
|
|
1401
1462
|
});
|
|
1402
1463
|
};
|
|
1403
|
-
class
|
|
1464
|
+
class Ge extends b {
|
|
1404
1465
|
_parse(e) {
|
|
1405
1466
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
|
|
1406
1467
|
const i = this._getOrReturnCtx(e);
|
|
@@ -1408,13 +1469,13 @@ class qe extends b {
|
|
|
1408
1469
|
code: u.invalid_type,
|
|
1409
1470
|
expected: f.boolean,
|
|
1410
1471
|
received: i.parsedType
|
|
1411
|
-
}),
|
|
1472
|
+
}), w;
|
|
1412
1473
|
}
|
|
1413
1474
|
return M(e.data);
|
|
1414
1475
|
}
|
|
1415
1476
|
}
|
|
1416
|
-
|
|
1417
|
-
typeName:
|
|
1477
|
+
Ge.create = (a) => new Ge({
|
|
1478
|
+
typeName: x.ZodBoolean,
|
|
1418
1479
|
coerce: a?.coerce || !1,
|
|
1419
1480
|
..._(a)
|
|
1420
1481
|
});
|
|
@@ -1426,15 +1487,15 @@ class be extends b {
|
|
|
1426
1487
|
code: u.invalid_type,
|
|
1427
1488
|
expected: f.date,
|
|
1428
1489
|
received: n.parsedType
|
|
1429
|
-
}),
|
|
1490
|
+
}), w;
|
|
1430
1491
|
}
|
|
1431
1492
|
if (isNaN(e.data.getTime())) {
|
|
1432
1493
|
const n = this._getOrReturnCtx(e);
|
|
1433
1494
|
return d(n, {
|
|
1434
1495
|
code: u.invalid_date
|
|
1435
|
-
}),
|
|
1496
|
+
}), w;
|
|
1436
1497
|
}
|
|
1437
|
-
const i = new
|
|
1498
|
+
const i = new z();
|
|
1438
1499
|
let s;
|
|
1439
1500
|
for (const n of this._def.checks)
|
|
1440
1501
|
n.kind === "min" ? e.data.getTime() < n.value && (s = this._getOrReturnCtx(e, s), d(s, {
|
|
@@ -1467,14 +1528,14 @@ class be extends b {
|
|
|
1467
1528
|
return this._addCheck({
|
|
1468
1529
|
kind: "min",
|
|
1469
1530
|
value: e.getTime(),
|
|
1470
|
-
message:
|
|
1531
|
+
message: g.toString(t)
|
|
1471
1532
|
});
|
|
1472
1533
|
}
|
|
1473
1534
|
max(e, t) {
|
|
1474
1535
|
return this._addCheck({
|
|
1475
1536
|
kind: "max",
|
|
1476
1537
|
value: e.getTime(),
|
|
1477
|
-
message:
|
|
1538
|
+
message: g.toString(t)
|
|
1478
1539
|
});
|
|
1479
1540
|
}
|
|
1480
1541
|
get minDate() {
|
|
@@ -1493,10 +1554,10 @@ class be extends b {
|
|
|
1493
1554
|
be.create = (a) => new be({
|
|
1494
1555
|
checks: [],
|
|
1495
1556
|
coerce: a?.coerce || !1,
|
|
1496
|
-
typeName:
|
|
1557
|
+
typeName: x.ZodDate,
|
|
1497
1558
|
..._(a)
|
|
1498
1559
|
});
|
|
1499
|
-
class
|
|
1560
|
+
class Qe extends b {
|
|
1500
1561
|
_parse(e) {
|
|
1501
1562
|
if (this._getType(e) !== f.symbol) {
|
|
1502
1563
|
const i = this._getOrReturnCtx(e);
|
|
@@ -1504,16 +1565,16 @@ class Ge extends b {
|
|
|
1504
1565
|
code: u.invalid_type,
|
|
1505
1566
|
expected: f.symbol,
|
|
1506
1567
|
received: i.parsedType
|
|
1507
|
-
}),
|
|
1568
|
+
}), w;
|
|
1508
1569
|
}
|
|
1509
1570
|
return M(e.data);
|
|
1510
1571
|
}
|
|
1511
1572
|
}
|
|
1512
|
-
|
|
1513
|
-
typeName:
|
|
1573
|
+
Qe.create = (a) => new Qe({
|
|
1574
|
+
typeName: x.ZodSymbol,
|
|
1514
1575
|
..._(a)
|
|
1515
1576
|
});
|
|
1516
|
-
class
|
|
1577
|
+
class Pe extends b {
|
|
1517
1578
|
_parse(e) {
|
|
1518
1579
|
if (this._getType(e) !== f.undefined) {
|
|
1519
1580
|
const i = this._getOrReturnCtx(e);
|
|
@@ -1521,16 +1582,16 @@ class Ae extends b {
|
|
|
1521
1582
|
code: u.invalid_type,
|
|
1522
1583
|
expected: f.undefined,
|
|
1523
1584
|
received: i.parsedType
|
|
1524
|
-
}),
|
|
1585
|
+
}), w;
|
|
1525
1586
|
}
|
|
1526
1587
|
return M(e.data);
|
|
1527
1588
|
}
|
|
1528
1589
|
}
|
|
1529
|
-
|
|
1530
|
-
typeName:
|
|
1590
|
+
Pe.create = (a) => new Pe({
|
|
1591
|
+
typeName: x.ZodUndefined,
|
|
1531
1592
|
..._(a)
|
|
1532
1593
|
});
|
|
1533
|
-
class
|
|
1594
|
+
class Ie extends b {
|
|
1534
1595
|
_parse(e) {
|
|
1535
1596
|
if (this._getType(e) !== f.null) {
|
|
1536
1597
|
const i = this._getOrReturnCtx(e);
|
|
@@ -1538,16 +1599,16 @@ class Pe extends b {
|
|
|
1538
1599
|
code: u.invalid_type,
|
|
1539
1600
|
expected: f.null,
|
|
1540
1601
|
received: i.parsedType
|
|
1541
|
-
}),
|
|
1602
|
+
}), w;
|
|
1542
1603
|
}
|
|
1543
1604
|
return M(e.data);
|
|
1544
1605
|
}
|
|
1545
1606
|
}
|
|
1546
|
-
|
|
1547
|
-
typeName:
|
|
1607
|
+
Ie.create = (a) => new Ie({
|
|
1608
|
+
typeName: x.ZodNull,
|
|
1548
1609
|
..._(a)
|
|
1549
1610
|
});
|
|
1550
|
-
class
|
|
1611
|
+
class Je extends b {
|
|
1551
1612
|
constructor() {
|
|
1552
1613
|
super(...arguments), this._any = !0;
|
|
1553
1614
|
}
|
|
@@ -1555,8 +1616,8 @@ class Qe extends b {
|
|
|
1555
1616
|
return M(e.data);
|
|
1556
1617
|
}
|
|
1557
1618
|
}
|
|
1558
|
-
|
|
1559
|
-
typeName:
|
|
1619
|
+
Je.create = (a) => new Je({
|
|
1620
|
+
typeName: x.ZodAny,
|
|
1560
1621
|
..._(a)
|
|
1561
1622
|
});
|
|
1562
1623
|
class ue extends b {
|
|
@@ -1568,7 +1629,7 @@ class ue extends b {
|
|
|
1568
1629
|
}
|
|
1569
1630
|
}
|
|
1570
1631
|
ue.create = (a) => new ue({
|
|
1571
|
-
typeName:
|
|
1632
|
+
typeName: x.ZodUnknown,
|
|
1572
1633
|
..._(a)
|
|
1573
1634
|
});
|
|
1574
1635
|
class G extends b {
|
|
@@ -1578,14 +1639,14 @@ class G extends b {
|
|
|
1578
1639
|
code: u.invalid_type,
|
|
1579
1640
|
expected: f.never,
|
|
1580
1641
|
received: t.parsedType
|
|
1581
|
-
}),
|
|
1642
|
+
}), w;
|
|
1582
1643
|
}
|
|
1583
1644
|
}
|
|
1584
1645
|
G.create = (a) => new G({
|
|
1585
|
-
typeName:
|
|
1646
|
+
typeName: x.ZodNever,
|
|
1586
1647
|
..._(a)
|
|
1587
1648
|
});
|
|
1588
|
-
class
|
|
1649
|
+
class et extends b {
|
|
1589
1650
|
_parse(e) {
|
|
1590
1651
|
if (this._getType(e) !== f.undefined) {
|
|
1591
1652
|
const i = this._getOrReturnCtx(e);
|
|
@@ -1593,13 +1654,13 @@ class Je extends b {
|
|
|
1593
1654
|
code: u.invalid_type,
|
|
1594
1655
|
expected: f.void,
|
|
1595
1656
|
received: i.parsedType
|
|
1596
|
-
}),
|
|
1657
|
+
}), w;
|
|
1597
1658
|
}
|
|
1598
1659
|
return M(e.data);
|
|
1599
1660
|
}
|
|
1600
1661
|
}
|
|
1601
|
-
|
|
1602
|
-
typeName:
|
|
1662
|
+
et.create = (a) => new et({
|
|
1663
|
+
typeName: x.ZodVoid,
|
|
1603
1664
|
..._(a)
|
|
1604
1665
|
});
|
|
1605
1666
|
class Z extends b {
|
|
@@ -1610,7 +1671,7 @@ class Z extends b {
|
|
|
1610
1671
|
code: u.invalid_type,
|
|
1611
1672
|
expected: f.array,
|
|
1612
1673
|
received: t.parsedType
|
|
1613
|
-
}),
|
|
1674
|
+
}), w;
|
|
1614
1675
|
if (s.exactLength !== null) {
|
|
1615
1676
|
const r = t.data.length > s.exactLength.value, o = t.data.length < s.exactLength.value;
|
|
1616
1677
|
(r || o) && (d(t, {
|
|
@@ -1638,9 +1699,9 @@ class Z extends b {
|
|
|
1638
1699
|
exact: !1,
|
|
1639
1700
|
message: s.maxLength.message
|
|
1640
1701
|
}), i.dirty()), t.common.async)
|
|
1641
|
-
return Promise.all([...t.data].map((r, o) => s.type._parseAsync(new
|
|
1642
|
-
const n = [...t.data].map((r, o) => s.type._parseSync(new
|
|
1643
|
-
return
|
|
1702
|
+
return Promise.all([...t.data].map((r, o) => s.type._parseAsync(new V(t, r, t.path, o)))).then((r) => z.mergeArray(i, r));
|
|
1703
|
+
const n = [...t.data].map((r, o) => s.type._parseSync(new V(t, r, t.path, o)));
|
|
1704
|
+
return z.mergeArray(i, n);
|
|
1644
1705
|
}
|
|
1645
1706
|
get element() {
|
|
1646
1707
|
return this._def.type;
|
|
@@ -1648,19 +1709,19 @@ class Z extends b {
|
|
|
1648
1709
|
min(e, t) {
|
|
1649
1710
|
return new Z({
|
|
1650
1711
|
...this._def,
|
|
1651
|
-
minLength: { value: e, message:
|
|
1712
|
+
minLength: { value: e, message: g.toString(t) }
|
|
1652
1713
|
});
|
|
1653
1714
|
}
|
|
1654
1715
|
max(e, t) {
|
|
1655
1716
|
return new Z({
|
|
1656
1717
|
...this._def,
|
|
1657
|
-
maxLength: { value: e, message:
|
|
1718
|
+
maxLength: { value: e, message: g.toString(t) }
|
|
1658
1719
|
});
|
|
1659
1720
|
}
|
|
1660
1721
|
length(e, t) {
|
|
1661
1722
|
return new Z({
|
|
1662
1723
|
...this._def,
|
|
1663
|
-
exactLength: { value: e, message:
|
|
1724
|
+
exactLength: { value: e, message: g.toString(t) }
|
|
1664
1725
|
});
|
|
1665
1726
|
}
|
|
1666
1727
|
nonempty(e) {
|
|
@@ -1672,7 +1733,7 @@ Z.create = (a, e) => new Z({
|
|
|
1672
1733
|
minLength: null,
|
|
1673
1734
|
maxLength: null,
|
|
1674
1735
|
exactLength: null,
|
|
1675
|
-
typeName:
|
|
1736
|
+
typeName: x.ZodArray,
|
|
1676
1737
|
..._(e)
|
|
1677
1738
|
});
|
|
1678
1739
|
function ce(a) {
|
|
@@ -1708,7 +1769,7 @@ class P extends b {
|
|
|
1708
1769
|
code: u.invalid_type,
|
|
1709
1770
|
expected: f.object,
|
|
1710
1771
|
received: c.parsedType
|
|
1711
|
-
}),
|
|
1772
|
+
}), w;
|
|
1712
1773
|
}
|
|
1713
1774
|
const { status: i, ctx: s } = this._processInputParams(e), { shape: n, keys: r } = this._getCached(), o = [];
|
|
1714
1775
|
if (!(this._def.catchall instanceof G && this._def.unknownKeys === "strip"))
|
|
@@ -1716,10 +1777,10 @@ class P extends b {
|
|
|
1716
1777
|
r.includes(c) || o.push(c);
|
|
1717
1778
|
const h = [];
|
|
1718
1779
|
for (const c of r) {
|
|
1719
|
-
const l = n[c],
|
|
1780
|
+
const l = n[c], m = s.data[c];
|
|
1720
1781
|
h.push({
|
|
1721
1782
|
key: { status: "valid", value: c },
|
|
1722
|
-
value: l._parse(new
|
|
1783
|
+
value: l._parse(new V(s, m, s.path, c)),
|
|
1723
1784
|
alwaysSet: c in s.data
|
|
1724
1785
|
});
|
|
1725
1786
|
}
|
|
@@ -1740,11 +1801,11 @@ class P extends b {
|
|
|
1740
1801
|
} else {
|
|
1741
1802
|
const c = this._def.catchall;
|
|
1742
1803
|
for (const l of o) {
|
|
1743
|
-
const
|
|
1804
|
+
const m = s.data[l];
|
|
1744
1805
|
h.push({
|
|
1745
1806
|
key: { status: "valid", value: l },
|
|
1746
1807
|
value: c._parse(
|
|
1747
|
-
new
|
|
1808
|
+
new V(s, m, s.path, l)
|
|
1748
1809
|
//, ctx.child(key), value, getParsedType(value)
|
|
1749
1810
|
),
|
|
1750
1811
|
alwaysSet: l in s.data
|
|
@@ -1754,21 +1815,21 @@ class P extends b {
|
|
|
1754
1815
|
return s.common.async ? Promise.resolve().then(async () => {
|
|
1755
1816
|
const c = [];
|
|
1756
1817
|
for (const l of h) {
|
|
1757
|
-
const
|
|
1818
|
+
const m = await l.key, p = await l.value;
|
|
1758
1819
|
c.push({
|
|
1759
|
-
key:
|
|
1820
|
+
key: m,
|
|
1760
1821
|
value: p,
|
|
1761
1822
|
alwaysSet: l.alwaysSet
|
|
1762
1823
|
});
|
|
1763
1824
|
}
|
|
1764
1825
|
return c;
|
|
1765
|
-
}).then((c) =>
|
|
1826
|
+
}).then((c) => z.mergeObjectSync(i, c)) : z.mergeObjectSync(i, h);
|
|
1766
1827
|
}
|
|
1767
1828
|
get shape() {
|
|
1768
1829
|
return this._def.shape();
|
|
1769
1830
|
}
|
|
1770
1831
|
strict(e) {
|
|
1771
|
-
return
|
|
1832
|
+
return g.errToObj, new P({
|
|
1772
1833
|
...this._def,
|
|
1773
1834
|
unknownKeys: "strict",
|
|
1774
1835
|
...e !== void 0 ? {
|
|
@@ -1776,7 +1837,7 @@ class P extends b {
|
|
|
1776
1837
|
var s, n, r, o;
|
|
1777
1838
|
const h = (r = (n = (s = this._def).errorMap) === null || n === void 0 ? void 0 : n.call(s, t, i).message) !== null && r !== void 0 ? r : i.defaultError;
|
|
1778
1839
|
return t.code === "unrecognized_keys" ? {
|
|
1779
|
-
message: (o =
|
|
1840
|
+
message: (o = g.errToObj(e).message) !== null && o !== void 0 ? o : h
|
|
1780
1841
|
} : {
|
|
1781
1842
|
message: h
|
|
1782
1843
|
};
|
|
@@ -1835,7 +1896,7 @@ class P extends b {
|
|
|
1835
1896
|
...this._def.shape(),
|
|
1836
1897
|
...e._def.shape()
|
|
1837
1898
|
}),
|
|
1838
|
-
typeName:
|
|
1899
|
+
typeName: x.ZodObject
|
|
1839
1900
|
});
|
|
1840
1901
|
}
|
|
1841
1902
|
// merge<
|
|
@@ -1954,28 +2015,28 @@ class P extends b {
|
|
|
1954
2015
|
});
|
|
1955
2016
|
}
|
|
1956
2017
|
keyof() {
|
|
1957
|
-
return
|
|
2018
|
+
return Et(C.objectKeys(this.shape));
|
|
1958
2019
|
}
|
|
1959
2020
|
}
|
|
1960
2021
|
P.create = (a, e) => new P({
|
|
1961
2022
|
shape: () => a,
|
|
1962
2023
|
unknownKeys: "strip",
|
|
1963
2024
|
catchall: G.create(),
|
|
1964
|
-
typeName:
|
|
2025
|
+
typeName: x.ZodObject,
|
|
1965
2026
|
..._(e)
|
|
1966
2027
|
});
|
|
1967
2028
|
P.strictCreate = (a, e) => new P({
|
|
1968
2029
|
shape: () => a,
|
|
1969
2030
|
unknownKeys: "strict",
|
|
1970
2031
|
catchall: G.create(),
|
|
1971
|
-
typeName:
|
|
2032
|
+
typeName: x.ZodObject,
|
|
1972
2033
|
..._(e)
|
|
1973
2034
|
});
|
|
1974
2035
|
P.lazycreate = (a, e) => new P({
|
|
1975
2036
|
shape: a,
|
|
1976
2037
|
unknownKeys: "strip",
|
|
1977
2038
|
catchall: G.create(),
|
|
1978
|
-
typeName:
|
|
2039
|
+
typeName: x.ZodObject,
|
|
1979
2040
|
..._(e)
|
|
1980
2041
|
});
|
|
1981
2042
|
class Re extends b {
|
|
@@ -1992,7 +2053,7 @@ class Re extends b {
|
|
|
1992
2053
|
return d(t, {
|
|
1993
2054
|
code: u.invalid_union,
|
|
1994
2055
|
unionErrors: r
|
|
1995
|
-
}),
|
|
2056
|
+
}), w;
|
|
1996
2057
|
}
|
|
1997
2058
|
if (t.common.async)
|
|
1998
2059
|
return Promise.all(i.map(async (n) => {
|
|
@@ -2039,7 +2100,7 @@ class Re extends b {
|
|
|
2039
2100
|
return d(t, {
|
|
2040
2101
|
code: u.invalid_union,
|
|
2041
2102
|
unionErrors: o
|
|
2042
|
-
}),
|
|
2103
|
+
}), w;
|
|
2043
2104
|
}
|
|
2044
2105
|
}
|
|
2045
2106
|
get options() {
|
|
@@ -2048,11 +2109,11 @@ class Re extends b {
|
|
|
2048
2109
|
}
|
|
2049
2110
|
Re.create = (a, e) => new Re({
|
|
2050
2111
|
options: a,
|
|
2051
|
-
typeName:
|
|
2112
|
+
typeName: x.ZodUnion,
|
|
2052
2113
|
..._(e)
|
|
2053
2114
|
});
|
|
2054
|
-
const $ = (a) => a instanceof
|
|
2055
|
-
class
|
|
2115
|
+
const $ = (a) => a instanceof Ee ? $(a.schema) : a instanceof X ? $(a.innerType()) : a instanceof Me ? [a.value] : a instanceof ie ? a.options : a instanceof Fe ? C.objectValues(a.enum) : a instanceof Ne ? $(a._def.innerType) : a instanceof Pe ? [void 0] : a instanceof Ie ? [null] : a instanceof U ? [void 0, ...$(a.unwrap())] : a instanceof se ? [null, ...$(a.unwrap())] : a instanceof Mt || a instanceof Ze ? $(a.unwrap()) : a instanceof De ? $(a._def.innerType) : [];
|
|
2116
|
+
class at extends b {
|
|
2056
2117
|
_parse(e) {
|
|
2057
2118
|
const { ctx: t } = this._processInputParams(e);
|
|
2058
2119
|
if (t.parsedType !== f.object)
|
|
@@ -2060,7 +2121,7 @@ class nt extends b {
|
|
|
2060
2121
|
code: u.invalid_type,
|
|
2061
2122
|
expected: f.object,
|
|
2062
2123
|
received: t.parsedType
|
|
2063
|
-
}),
|
|
2124
|
+
}), w;
|
|
2064
2125
|
const i = this.discriminator, s = t.data[i], n = this.optionsMap.get(s);
|
|
2065
2126
|
return n ? t.common.async ? n._parseAsync({
|
|
2066
2127
|
data: t.data,
|
|
@@ -2074,7 +2135,7 @@ class nt extends b {
|
|
|
2074
2135
|
code: u.invalid_union_discriminator,
|
|
2075
2136
|
options: Array.from(this.optionsMap.keys()),
|
|
2076
2137
|
path: [i]
|
|
2077
|
-
}),
|
|
2138
|
+
}), w);
|
|
2078
2139
|
}
|
|
2079
2140
|
get discriminator() {
|
|
2080
2141
|
return this._def.discriminator;
|
|
@@ -2105,8 +2166,8 @@ class nt extends b {
|
|
|
2105
2166
|
s.set(o, n);
|
|
2106
2167
|
}
|
|
2107
2168
|
}
|
|
2108
|
-
return new
|
|
2109
|
-
typeName:
|
|
2169
|
+
return new at({
|
|
2170
|
+
typeName: x.ZodDiscriminatedUnion,
|
|
2110
2171
|
discriminator: e,
|
|
2111
2172
|
options: t,
|
|
2112
2173
|
optionsMap: s,
|
|
@@ -2114,14 +2175,14 @@ class nt extends b {
|
|
|
2114
2175
|
});
|
|
2115
2176
|
}
|
|
2116
2177
|
}
|
|
2117
|
-
function
|
|
2178
|
+
function tt(a, e) {
|
|
2118
2179
|
const t = q(a), i = q(e);
|
|
2119
2180
|
if (a === e)
|
|
2120
2181
|
return { valid: !0, data: a };
|
|
2121
2182
|
if (t === f.object && i === f.object) {
|
|
2122
2183
|
const s = C.objectKeys(e), n = C.objectKeys(a).filter((o) => s.indexOf(o) !== -1), r = { ...a, ...e };
|
|
2123
2184
|
for (const o of n) {
|
|
2124
|
-
const h =
|
|
2185
|
+
const h = tt(a[o], e[o]);
|
|
2125
2186
|
if (!h.valid)
|
|
2126
2187
|
return { valid: !1 };
|
|
2127
2188
|
r[o] = h.data;
|
|
@@ -2132,7 +2193,7 @@ function et(a, e) {
|
|
|
2132
2193
|
return { valid: !1 };
|
|
2133
2194
|
const s = [];
|
|
2134
2195
|
for (let n = 0; n < a.length; n++) {
|
|
2135
|
-
const r = a[n], o = e[n], h =
|
|
2196
|
+
const r = a[n], o = e[n], h = tt(r, o);
|
|
2136
2197
|
if (!h.valid)
|
|
2137
2198
|
return { valid: !1 };
|
|
2138
2199
|
s.push(h.data);
|
|
@@ -2143,12 +2204,12 @@ function et(a, e) {
|
|
|
2143
2204
|
class ze extends b {
|
|
2144
2205
|
_parse(e) {
|
|
2145
2206
|
const { status: t, ctx: i } = this._processInputParams(e), s = (n, r) => {
|
|
2146
|
-
if (
|
|
2147
|
-
return
|
|
2148
|
-
const o =
|
|
2149
|
-
return o.valid ? ((
|
|
2207
|
+
if (mt(n) || mt(r))
|
|
2208
|
+
return w;
|
|
2209
|
+
const o = tt(n.value, r.value);
|
|
2210
|
+
return o.valid ? ((gt(n) || gt(r)) && t.dirty(), { status: t.value, value: o.data }) : (d(i, {
|
|
2150
2211
|
code: u.invalid_intersection_types
|
|
2151
|
-
}),
|
|
2212
|
+
}), w);
|
|
2152
2213
|
};
|
|
2153
2214
|
return i.common.async ? Promise.all([
|
|
2154
2215
|
this._def.left._parseAsync({
|
|
@@ -2175,7 +2236,7 @@ class ze extends b {
|
|
|
2175
2236
|
ze.create = (a, e, t) => new ze({
|
|
2176
2237
|
left: a,
|
|
2177
2238
|
right: e,
|
|
2178
|
-
typeName:
|
|
2239
|
+
typeName: x.ZodIntersection,
|
|
2179
2240
|
..._(t)
|
|
2180
2241
|
});
|
|
2181
2242
|
class W extends b {
|
|
@@ -2186,7 +2247,7 @@ class W extends b {
|
|
|
2186
2247
|
code: u.invalid_type,
|
|
2187
2248
|
expected: f.array,
|
|
2188
2249
|
received: i.parsedType
|
|
2189
|
-
}),
|
|
2250
|
+
}), w;
|
|
2190
2251
|
if (i.data.length < this._def.items.length)
|
|
2191
2252
|
return d(i, {
|
|
2192
2253
|
code: u.too_small,
|
|
@@ -2194,7 +2255,7 @@ class W extends b {
|
|
|
2194
2255
|
inclusive: !0,
|
|
2195
2256
|
exact: !1,
|
|
2196
2257
|
type: "array"
|
|
2197
|
-
}),
|
|
2258
|
+
}), w;
|
|
2198
2259
|
!this._def.rest && i.data.length > this._def.items.length && (d(i, {
|
|
2199
2260
|
code: u.too_big,
|
|
2200
2261
|
maximum: this._def.items.length,
|
|
@@ -2204,9 +2265,9 @@ class W extends b {
|
|
|
2204
2265
|
}), t.dirty());
|
|
2205
2266
|
const n = [...i.data].map((r, o) => {
|
|
2206
2267
|
const h = this._def.items[o] || this._def.rest;
|
|
2207
|
-
return h ? h._parse(new
|
|
2268
|
+
return h ? h._parse(new V(i, r, i.path, o)) : null;
|
|
2208
2269
|
}).filter((r) => !!r);
|
|
2209
|
-
return i.common.async ? Promise.all(n).then((r) =>
|
|
2270
|
+
return i.common.async ? Promise.all(n).then((r) => z.mergeArray(t, r)) : z.mergeArray(t, n);
|
|
2210
2271
|
}
|
|
2211
2272
|
get items() {
|
|
2212
2273
|
return this._def.items;
|
|
@@ -2223,12 +2284,12 @@ W.create = (a, e) => {
|
|
|
2223
2284
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2224
2285
|
return new W({
|
|
2225
2286
|
items: a,
|
|
2226
|
-
typeName:
|
|
2287
|
+
typeName: x.ZodTuple,
|
|
2227
2288
|
rest: null,
|
|
2228
2289
|
..._(e)
|
|
2229
2290
|
});
|
|
2230
2291
|
};
|
|
2231
|
-
class
|
|
2292
|
+
class Le extends b {
|
|
2232
2293
|
get keySchema() {
|
|
2233
2294
|
return this._def.keyType;
|
|
2234
2295
|
}
|
|
@@ -2242,34 +2303,34 @@ class Ie extends b {
|
|
|
2242
2303
|
code: u.invalid_type,
|
|
2243
2304
|
expected: f.object,
|
|
2244
2305
|
received: i.parsedType
|
|
2245
|
-
}),
|
|
2306
|
+
}), w;
|
|
2246
2307
|
const s = [], n = this._def.keyType, r = this._def.valueType;
|
|
2247
2308
|
for (const o in i.data)
|
|
2248
2309
|
s.push({
|
|
2249
|
-
key: n._parse(new
|
|
2250
|
-
value: r._parse(new
|
|
2310
|
+
key: n._parse(new V(i, o, i.path, o)),
|
|
2311
|
+
value: r._parse(new V(i, i.data[o], i.path, o)),
|
|
2251
2312
|
alwaysSet: o in i.data
|
|
2252
2313
|
});
|
|
2253
|
-
return i.common.async ?
|
|
2314
|
+
return i.common.async ? z.mergeObjectAsync(t, s) : z.mergeObjectSync(t, s);
|
|
2254
2315
|
}
|
|
2255
2316
|
get element() {
|
|
2256
2317
|
return this._def.valueType;
|
|
2257
2318
|
}
|
|
2258
2319
|
static create(e, t, i) {
|
|
2259
|
-
return t instanceof b ? new
|
|
2320
|
+
return t instanceof b ? new Le({
|
|
2260
2321
|
keyType: e,
|
|
2261
2322
|
valueType: t,
|
|
2262
|
-
typeName:
|
|
2323
|
+
typeName: x.ZodRecord,
|
|
2263
2324
|
..._(i)
|
|
2264
|
-
}) : new
|
|
2325
|
+
}) : new Le({
|
|
2265
2326
|
keyType: j.create(),
|
|
2266
2327
|
valueType: e,
|
|
2267
|
-
typeName:
|
|
2328
|
+
typeName: x.ZodRecord,
|
|
2268
2329
|
..._(t)
|
|
2269
2330
|
});
|
|
2270
2331
|
}
|
|
2271
2332
|
}
|
|
2272
|
-
class
|
|
2333
|
+
class it extends b {
|
|
2273
2334
|
get keySchema() {
|
|
2274
2335
|
return this._def.keyType;
|
|
2275
2336
|
}
|
|
@@ -2283,10 +2344,10 @@ class tt extends b {
|
|
|
2283
2344
|
code: u.invalid_type,
|
|
2284
2345
|
expected: f.map,
|
|
2285
2346
|
received: i.parsedType
|
|
2286
|
-
}),
|
|
2347
|
+
}), w;
|
|
2287
2348
|
const s = this._def.keyType, n = this._def.valueType, r = [...i.data.entries()].map(([o, h], c) => ({
|
|
2288
|
-
key: s._parse(new
|
|
2289
|
-
value: n._parse(new
|
|
2349
|
+
key: s._parse(new V(i, o, i.path, [c, "key"])),
|
|
2350
|
+
value: n._parse(new V(i, h, i.path, [c, "value"]))
|
|
2290
2351
|
}));
|
|
2291
2352
|
if (i.common.async) {
|
|
2292
2353
|
const o = /* @__PURE__ */ new Map();
|
|
@@ -2294,7 +2355,7 @@ class tt extends b {
|
|
|
2294
2355
|
for (const h of r) {
|
|
2295
2356
|
const c = await h.key, l = await h.value;
|
|
2296
2357
|
if (c.status === "aborted" || l.status === "aborted")
|
|
2297
|
-
return
|
|
2358
|
+
return w;
|
|
2298
2359
|
(c.status === "dirty" || l.status === "dirty") && t.dirty(), o.set(c.value, l.value);
|
|
2299
2360
|
}
|
|
2300
2361
|
return { status: t.value, value: o };
|
|
@@ -2304,17 +2365,17 @@ class tt extends b {
|
|
|
2304
2365
|
for (const h of r) {
|
|
2305
2366
|
const c = h.key, l = h.value;
|
|
2306
2367
|
if (c.status === "aborted" || l.status === "aborted")
|
|
2307
|
-
return
|
|
2368
|
+
return w;
|
|
2308
2369
|
(c.status === "dirty" || l.status === "dirty") && t.dirty(), o.set(c.value, l.value);
|
|
2309
2370
|
}
|
|
2310
2371
|
return { status: t.value, value: o };
|
|
2311
2372
|
}
|
|
2312
2373
|
}
|
|
2313
2374
|
}
|
|
2314
|
-
|
|
2375
|
+
it.create = (a, e, t) => new it({
|
|
2315
2376
|
valueType: e,
|
|
2316
2377
|
keyType: a,
|
|
2317
|
-
typeName:
|
|
2378
|
+
typeName: x.ZodMap,
|
|
2318
2379
|
..._(t)
|
|
2319
2380
|
});
|
|
2320
2381
|
class ge extends b {
|
|
@@ -2325,7 +2386,7 @@ class ge extends b {
|
|
|
2325
2386
|
code: u.invalid_type,
|
|
2326
2387
|
expected: f.set,
|
|
2327
2388
|
received: i.parsedType
|
|
2328
|
-
}),
|
|
2389
|
+
}), w;
|
|
2329
2390
|
const s = this._def;
|
|
2330
2391
|
s.minSize !== null && i.data.size < s.minSize.value && (d(i, {
|
|
2331
2392
|
code: u.too_small,
|
|
@@ -2347,24 +2408,24 @@ class ge extends b {
|
|
|
2347
2408
|
const c = /* @__PURE__ */ new Set();
|
|
2348
2409
|
for (const l of h) {
|
|
2349
2410
|
if (l.status === "aborted")
|
|
2350
|
-
return
|
|
2411
|
+
return w;
|
|
2351
2412
|
l.status === "dirty" && t.dirty(), c.add(l.value);
|
|
2352
2413
|
}
|
|
2353
2414
|
return { status: t.value, value: c };
|
|
2354
2415
|
}
|
|
2355
|
-
const o = [...i.data.values()].map((h, c) => n._parse(new
|
|
2416
|
+
const o = [...i.data.values()].map((h, c) => n._parse(new V(i, h, i.path, c)));
|
|
2356
2417
|
return i.common.async ? Promise.all(o).then((h) => r(h)) : r(o);
|
|
2357
2418
|
}
|
|
2358
2419
|
min(e, t) {
|
|
2359
2420
|
return new ge({
|
|
2360
2421
|
...this._def,
|
|
2361
|
-
minSize: { value: e, message:
|
|
2422
|
+
minSize: { value: e, message: g.toString(t) }
|
|
2362
2423
|
});
|
|
2363
2424
|
}
|
|
2364
2425
|
max(e, t) {
|
|
2365
2426
|
return new ge({
|
|
2366
2427
|
...this._def,
|
|
2367
|
-
maxSize: { value: e, message:
|
|
2428
|
+
maxSize: { value: e, message: g.toString(t) }
|
|
2368
2429
|
});
|
|
2369
2430
|
}
|
|
2370
2431
|
size(e, t) {
|
|
@@ -2378,7 +2439,7 @@ ge.create = (a, e) => new ge({
|
|
|
2378
2439
|
valueType: a,
|
|
2379
2440
|
minSize: null,
|
|
2380
2441
|
maxSize: null,
|
|
2381
|
-
typeName:
|
|
2442
|
+
typeName: x.ZodSet,
|
|
2382
2443
|
..._(e)
|
|
2383
2444
|
});
|
|
2384
2445
|
class we extends b {
|
|
@@ -2392,9 +2453,9 @@ class we extends b {
|
|
|
2392
2453
|
code: u.invalid_type,
|
|
2393
2454
|
expected: f.function,
|
|
2394
2455
|
received: t.parsedType
|
|
2395
|
-
}),
|
|
2456
|
+
}), w;
|
|
2396
2457
|
function i(o, h) {
|
|
2397
|
-
return
|
|
2458
|
+
return qe({
|
|
2398
2459
|
data: o,
|
|
2399
2460
|
path: t.path,
|
|
2400
2461
|
errorMaps: [
|
|
@@ -2410,7 +2471,7 @@ class we extends b {
|
|
|
2410
2471
|
});
|
|
2411
2472
|
}
|
|
2412
2473
|
function s(o, h) {
|
|
2413
|
-
return
|
|
2474
|
+
return qe({
|
|
2414
2475
|
data: o,
|
|
2415
2476
|
path: t.path,
|
|
2416
2477
|
errorMaps: [
|
|
@@ -2431,9 +2492,9 @@ class we extends b {
|
|
|
2431
2492
|
return M(async function(...h) {
|
|
2432
2493
|
const c = new F([]), l = await o._def.args.parseAsync(h, n).catch((k) => {
|
|
2433
2494
|
throw c.addIssue(i(h, k)), c;
|
|
2434
|
-
}),
|
|
2435
|
-
return await o._def.returns._def.type.parseAsync(
|
|
2436
|
-
throw c.addIssue(s(
|
|
2495
|
+
}), m = await Reflect.apply(r, this, l);
|
|
2496
|
+
return await o._def.returns._def.type.parseAsync(m, n).catch((k) => {
|
|
2497
|
+
throw c.addIssue(s(m, k)), c;
|
|
2437
2498
|
});
|
|
2438
2499
|
});
|
|
2439
2500
|
} else {
|
|
@@ -2442,10 +2503,10 @@ class we extends b {
|
|
|
2442
2503
|
const c = o._def.args.safeParse(h, n);
|
|
2443
2504
|
if (!c.success)
|
|
2444
2505
|
throw new F([i(h, c.error)]);
|
|
2445
|
-
const l = Reflect.apply(r, this, c.data),
|
|
2446
|
-
if (!
|
|
2447
|
-
throw new F([s(l,
|
|
2448
|
-
return
|
|
2506
|
+
const l = Reflect.apply(r, this, c.data), m = o._def.returns.safeParse(l, n);
|
|
2507
|
+
if (!m.success)
|
|
2508
|
+
throw new F([s(l, m.error)]);
|
|
2509
|
+
return m.data;
|
|
2449
2510
|
});
|
|
2450
2511
|
}
|
|
2451
2512
|
}
|
|
@@ -2477,12 +2538,12 @@ class we extends b {
|
|
|
2477
2538
|
return new we({
|
|
2478
2539
|
args: e || W.create([]).rest(ue.create()),
|
|
2479
2540
|
returns: t || ue.create(),
|
|
2480
|
-
typeName:
|
|
2541
|
+
typeName: x.ZodFunction,
|
|
2481
2542
|
..._(i)
|
|
2482
2543
|
});
|
|
2483
2544
|
}
|
|
2484
2545
|
}
|
|
2485
|
-
class
|
|
2546
|
+
class Ee extends b {
|
|
2486
2547
|
get schema() {
|
|
2487
2548
|
return this._def.getter();
|
|
2488
2549
|
}
|
|
@@ -2491,12 +2552,12 @@ class Le extends b {
|
|
|
2491
2552
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2492
2553
|
}
|
|
2493
2554
|
}
|
|
2494
|
-
|
|
2555
|
+
Ee.create = (a, e) => new Ee({
|
|
2495
2556
|
getter: a,
|
|
2496
|
-
typeName:
|
|
2557
|
+
typeName: x.ZodLazy,
|
|
2497
2558
|
..._(e)
|
|
2498
2559
|
});
|
|
2499
|
-
class
|
|
2560
|
+
class Me extends b {
|
|
2500
2561
|
_parse(e) {
|
|
2501
2562
|
if (e.data !== this._def.value) {
|
|
2502
2563
|
const t = this._getOrReturnCtx(e);
|
|
@@ -2504,7 +2565,7 @@ class Ee extends b {
|
|
|
2504
2565
|
received: t.data,
|
|
2505
2566
|
code: u.invalid_literal,
|
|
2506
2567
|
expected: this._def.value
|
|
2507
|
-
}),
|
|
2568
|
+
}), w;
|
|
2508
2569
|
}
|
|
2509
2570
|
return { status: "valid", value: e.data };
|
|
2510
2571
|
}
|
|
@@ -2512,15 +2573,15 @@ class Ee extends b {
|
|
|
2512
2573
|
return this._def.value;
|
|
2513
2574
|
}
|
|
2514
2575
|
}
|
|
2515
|
-
|
|
2576
|
+
Me.create = (a, e) => new Me({
|
|
2516
2577
|
value: a,
|
|
2517
|
-
typeName:
|
|
2578
|
+
typeName: x.ZodLiteral,
|
|
2518
2579
|
..._(e)
|
|
2519
2580
|
});
|
|
2520
|
-
function
|
|
2581
|
+
function Et(a, e) {
|
|
2521
2582
|
return new ie({
|
|
2522
2583
|
values: a,
|
|
2523
|
-
typeName:
|
|
2584
|
+
typeName: x.ZodEnum,
|
|
2524
2585
|
..._(e)
|
|
2525
2586
|
});
|
|
2526
2587
|
}
|
|
@@ -2535,15 +2596,15 @@ class ie extends b {
|
|
|
2535
2596
|
expected: C.joinValues(i),
|
|
2536
2597
|
received: t.parsedType,
|
|
2537
2598
|
code: u.invalid_type
|
|
2538
|
-
}),
|
|
2599
|
+
}), w;
|
|
2539
2600
|
}
|
|
2540
|
-
if (
|
|
2601
|
+
if (Ae(this, ve) || Rt(this, ve, new Set(this._def.values)), !Ae(this, ve).has(e.data)) {
|
|
2541
2602
|
const t = this._getOrReturnCtx(e), i = this._def.values;
|
|
2542
2603
|
return d(t, {
|
|
2543
2604
|
received: t.data,
|
|
2544
2605
|
code: u.invalid_enum_value,
|
|
2545
2606
|
options: i
|
|
2546
|
-
}),
|
|
2607
|
+
}), w;
|
|
2547
2608
|
}
|
|
2548
2609
|
return M(e.data);
|
|
2549
2610
|
}
|
|
@@ -2582,8 +2643,8 @@ class ie extends b {
|
|
|
2582
2643
|
}
|
|
2583
2644
|
}
|
|
2584
2645
|
ve = /* @__PURE__ */ new WeakMap();
|
|
2585
|
-
ie.create =
|
|
2586
|
-
class
|
|
2646
|
+
ie.create = Et;
|
|
2647
|
+
class Fe extends b {
|
|
2587
2648
|
constructor() {
|
|
2588
2649
|
super(...arguments), xe.set(this, void 0);
|
|
2589
2650
|
}
|
|
@@ -2595,15 +2656,15 @@ class Me extends b {
|
|
|
2595
2656
|
expected: C.joinValues(s),
|
|
2596
2657
|
received: i.parsedType,
|
|
2597
2658
|
code: u.invalid_type
|
|
2598
|
-
}),
|
|
2659
|
+
}), w;
|
|
2599
2660
|
}
|
|
2600
|
-
if (
|
|
2661
|
+
if (Ae(this, xe) || Rt(this, xe, new Set(C.getValidEnumValues(this._def.values))), !Ae(this, xe).has(e.data)) {
|
|
2601
2662
|
const s = C.objectValues(t);
|
|
2602
2663
|
return d(i, {
|
|
2603
2664
|
received: i.data,
|
|
2604
2665
|
code: u.invalid_enum_value,
|
|
2605
2666
|
options: s
|
|
2606
|
-
}),
|
|
2667
|
+
}), w;
|
|
2607
2668
|
}
|
|
2608
2669
|
return M(e.data);
|
|
2609
2670
|
}
|
|
@@ -2612,9 +2673,9 @@ class Me extends b {
|
|
|
2612
2673
|
}
|
|
2613
2674
|
}
|
|
2614
2675
|
xe = /* @__PURE__ */ new WeakMap();
|
|
2615
|
-
|
|
2676
|
+
Fe.create = (a, e) => new Fe({
|
|
2616
2677
|
values: a,
|
|
2617
|
-
typeName:
|
|
2678
|
+
typeName: x.ZodNativeEnum,
|
|
2618
2679
|
..._(e)
|
|
2619
2680
|
});
|
|
2620
2681
|
class Ce extends b {
|
|
@@ -2628,7 +2689,7 @@ class Ce extends b {
|
|
|
2628
2689
|
code: u.invalid_type,
|
|
2629
2690
|
expected: f.promise,
|
|
2630
2691
|
received: t.parsedType
|
|
2631
|
-
}),
|
|
2692
|
+
}), w;
|
|
2632
2693
|
const i = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
|
|
2633
2694
|
return M(i.then((s) => this._def.type.parseAsync(s, {
|
|
2634
2695
|
path: t.path,
|
|
@@ -2638,15 +2699,15 @@ class Ce extends b {
|
|
|
2638
2699
|
}
|
|
2639
2700
|
Ce.create = (a, e) => new Ce({
|
|
2640
2701
|
type: a,
|
|
2641
|
-
typeName:
|
|
2702
|
+
typeName: x.ZodPromise,
|
|
2642
2703
|
..._(e)
|
|
2643
2704
|
});
|
|
2644
|
-
class
|
|
2705
|
+
class X extends b {
|
|
2645
2706
|
innerType() {
|
|
2646
2707
|
return this._def.schema;
|
|
2647
2708
|
}
|
|
2648
2709
|
sourceType() {
|
|
2649
|
-
return this._def.schema._def.typeName ===
|
|
2710
|
+
return this._def.schema._def.typeName === x.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2650
2711
|
}
|
|
2651
2712
|
_parse(e) {
|
|
2652
2713
|
const { status: t, ctx: i } = this._processInputParams(e), s = this._def.effect || null, n = {
|
|
@@ -2662,23 +2723,23 @@ class Y extends b {
|
|
|
2662
2723
|
if (i.common.async)
|
|
2663
2724
|
return Promise.resolve(r).then(async (o) => {
|
|
2664
2725
|
if (t.value === "aborted")
|
|
2665
|
-
return
|
|
2726
|
+
return w;
|
|
2666
2727
|
const h = await this._def.schema._parseAsync({
|
|
2667
2728
|
data: o,
|
|
2668
2729
|
path: i.path,
|
|
2669
2730
|
parent: i
|
|
2670
2731
|
});
|
|
2671
|
-
return h.status === "aborted" ?
|
|
2732
|
+
return h.status === "aborted" ? w : h.status === "dirty" || t.value === "dirty" ? ye(h.value) : h;
|
|
2672
2733
|
});
|
|
2673
2734
|
{
|
|
2674
2735
|
if (t.value === "aborted")
|
|
2675
|
-
return
|
|
2736
|
+
return w;
|
|
2676
2737
|
const o = this._def.schema._parseSync({
|
|
2677
2738
|
data: r,
|
|
2678
2739
|
path: i.path,
|
|
2679
2740
|
parent: i
|
|
2680
2741
|
});
|
|
2681
|
-
return o.status === "aborted" ?
|
|
2742
|
+
return o.status === "aborted" ? w : o.status === "dirty" || t.value === "dirty" ? ye(o.value) : o;
|
|
2682
2743
|
}
|
|
2683
2744
|
}
|
|
2684
2745
|
if (s.type === "refinement") {
|
|
@@ -2696,9 +2757,9 @@ class Y extends b {
|
|
|
2696
2757
|
path: i.path,
|
|
2697
2758
|
parent: i
|
|
2698
2759
|
});
|
|
2699
|
-
return o.status === "aborted" ?
|
|
2760
|
+
return o.status === "aborted" ? w : (o.status === "dirty" && t.dirty(), r(o.value), { status: t.value, value: o.value });
|
|
2700
2761
|
} else
|
|
2701
|
-
return this._def.schema._parseAsync({ data: i.data, path: i.path, parent: i }).then((o) => o.status === "aborted" ?
|
|
2762
|
+
return this._def.schema._parseAsync({ data: i.data, path: i.path, parent: i }).then((o) => o.status === "aborted" ? w : (o.status === "dirty" && t.dirty(), r(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2702
2763
|
}
|
|
2703
2764
|
if (s.type === "transform")
|
|
2704
2765
|
if (i.common.async === !1) {
|
|
@@ -2718,16 +2779,16 @@ class Y extends b {
|
|
|
2718
2779
|
C.assertNever(s);
|
|
2719
2780
|
}
|
|
2720
2781
|
}
|
|
2721
|
-
|
|
2782
|
+
X.create = (a, e, t) => new X({
|
|
2722
2783
|
schema: a,
|
|
2723
|
-
typeName:
|
|
2784
|
+
typeName: x.ZodEffects,
|
|
2724
2785
|
effect: e,
|
|
2725
2786
|
..._(t)
|
|
2726
2787
|
});
|
|
2727
|
-
|
|
2788
|
+
X.createWithPreprocess = (a, e, t) => new X({
|
|
2728
2789
|
schema: e,
|
|
2729
2790
|
effect: { type: "preprocess", transform: a },
|
|
2730
|
-
typeName:
|
|
2791
|
+
typeName: x.ZodEffects,
|
|
2731
2792
|
..._(t)
|
|
2732
2793
|
});
|
|
2733
2794
|
class U extends b {
|
|
@@ -2740,7 +2801,7 @@ class U extends b {
|
|
|
2740
2801
|
}
|
|
2741
2802
|
U.create = (a, e) => new U({
|
|
2742
2803
|
innerType: a,
|
|
2743
|
-
typeName:
|
|
2804
|
+
typeName: x.ZodOptional,
|
|
2744
2805
|
..._(e)
|
|
2745
2806
|
});
|
|
2746
2807
|
class se extends b {
|
|
@@ -2753,10 +2814,10 @@ class se extends b {
|
|
|
2753
2814
|
}
|
|
2754
2815
|
se.create = (a, e) => new se({
|
|
2755
2816
|
innerType: a,
|
|
2756
|
-
typeName:
|
|
2817
|
+
typeName: x.ZodNullable,
|
|
2757
2818
|
..._(e)
|
|
2758
2819
|
});
|
|
2759
|
-
class
|
|
2820
|
+
class Ne extends b {
|
|
2760
2821
|
_parse(e) {
|
|
2761
2822
|
const { ctx: t } = this._processInputParams(e);
|
|
2762
2823
|
let i = t.data;
|
|
@@ -2770,13 +2831,13 @@ class Fe extends b {
|
|
|
2770
2831
|
return this._def.innerType;
|
|
2771
2832
|
}
|
|
2772
2833
|
}
|
|
2773
|
-
|
|
2834
|
+
Ne.create = (a, e) => new Ne({
|
|
2774
2835
|
innerType: a,
|
|
2775
|
-
typeName:
|
|
2836
|
+
typeName: x.ZodDefault,
|
|
2776
2837
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2777
2838
|
..._(e)
|
|
2778
2839
|
});
|
|
2779
|
-
class
|
|
2840
|
+
class De extends b {
|
|
2780
2841
|
_parse(e) {
|
|
2781
2842
|
const { ctx: t } = this._processInputParams(e), i = {
|
|
2782
2843
|
...t,
|
|
@@ -2791,7 +2852,7 @@ class Ne extends b {
|
|
|
2791
2852
|
...i
|
|
2792
2853
|
}
|
|
2793
2854
|
});
|
|
2794
|
-
return
|
|
2855
|
+
return Oe(s) ? s.then((n) => ({
|
|
2795
2856
|
status: "valid",
|
|
2796
2857
|
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2797
2858
|
get error() {
|
|
@@ -2813,13 +2874,13 @@ class Ne extends b {
|
|
|
2813
2874
|
return this._def.innerType;
|
|
2814
2875
|
}
|
|
2815
2876
|
}
|
|
2816
|
-
|
|
2877
|
+
De.create = (a, e) => new De({
|
|
2817
2878
|
innerType: a,
|
|
2818
|
-
typeName:
|
|
2879
|
+
typeName: x.ZodCatch,
|
|
2819
2880
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2820
2881
|
..._(e)
|
|
2821
2882
|
});
|
|
2822
|
-
class
|
|
2883
|
+
class st extends b {
|
|
2823
2884
|
_parse(e) {
|
|
2824
2885
|
if (this._getType(e) !== f.nan) {
|
|
2825
2886
|
const i = this._getOrReturnCtx(e);
|
|
@@ -2827,16 +2888,16 @@ class it extends b {
|
|
|
2827
2888
|
code: u.invalid_type,
|
|
2828
2889
|
expected: f.nan,
|
|
2829
2890
|
received: i.parsedType
|
|
2830
|
-
}),
|
|
2891
|
+
}), w;
|
|
2831
2892
|
}
|
|
2832
2893
|
return { status: "valid", value: e.data };
|
|
2833
2894
|
}
|
|
2834
2895
|
}
|
|
2835
|
-
|
|
2836
|
-
typeName:
|
|
2896
|
+
st.create = (a) => new st({
|
|
2897
|
+
typeName: x.ZodNaN,
|
|
2837
2898
|
..._(a)
|
|
2838
2899
|
});
|
|
2839
|
-
class
|
|
2900
|
+
class Mt extends b {
|
|
2840
2901
|
_parse(e) {
|
|
2841
2902
|
const { ctx: t } = this._processInputParams(e), i = t.data;
|
|
2842
2903
|
return this._def.type._parse({
|
|
@@ -2859,7 +2920,7 @@ class Ke extends b {
|
|
|
2859
2920
|
path: i.path,
|
|
2860
2921
|
parent: i
|
|
2861
2922
|
});
|
|
2862
|
-
return n.status === "aborted" ?
|
|
2923
|
+
return n.status === "aborted" ? w : n.status === "dirty" ? (t.dirty(), ye(n.value)) : this._def.out._parseAsync({
|
|
2863
2924
|
data: n.value,
|
|
2864
2925
|
path: i.path,
|
|
2865
2926
|
parent: i
|
|
@@ -2871,7 +2932,7 @@ class Ke extends b {
|
|
|
2871
2932
|
path: i.path,
|
|
2872
2933
|
parent: i
|
|
2873
2934
|
});
|
|
2874
|
-
return s.status === "aborted" ?
|
|
2935
|
+
return s.status === "aborted" ? w : s.status === "dirty" ? (t.dirty(), {
|
|
2875
2936
|
status: "dirty",
|
|
2876
2937
|
value: s.value
|
|
2877
2938
|
}) : this._def.out._parseSync({
|
|
@@ -2885,62 +2946,62 @@ class Ke extends b {
|
|
|
2885
2946
|
return new Ke({
|
|
2886
2947
|
in: e,
|
|
2887
2948
|
out: t,
|
|
2888
|
-
typeName:
|
|
2949
|
+
typeName: x.ZodPipeline
|
|
2889
2950
|
});
|
|
2890
2951
|
}
|
|
2891
2952
|
}
|
|
2892
|
-
class
|
|
2953
|
+
class Ze extends b {
|
|
2893
2954
|
_parse(e) {
|
|
2894
2955
|
const t = this._def.innerType._parse(e), i = (s) => (fe(s) && (s.value = Object.freeze(s.value)), s);
|
|
2895
|
-
return
|
|
2956
|
+
return Oe(t) ? t.then((s) => i(s)) : i(t);
|
|
2896
2957
|
}
|
|
2897
2958
|
unwrap() {
|
|
2898
2959
|
return this._def.innerType;
|
|
2899
2960
|
}
|
|
2900
2961
|
}
|
|
2901
|
-
|
|
2962
|
+
Ze.create = (a, e) => new Ze({
|
|
2902
2963
|
innerType: a,
|
|
2903
|
-
typeName:
|
|
2964
|
+
typeName: x.ZodReadonly,
|
|
2904
2965
|
..._(e)
|
|
2905
2966
|
});
|
|
2906
2967
|
P.lazycreate;
|
|
2907
|
-
var
|
|
2968
|
+
var x;
|
|
2908
2969
|
(function(a) {
|
|
2909
2970
|
a.ZodString = "ZodString", a.ZodNumber = "ZodNumber", a.ZodNaN = "ZodNaN", a.ZodBigInt = "ZodBigInt", a.ZodBoolean = "ZodBoolean", a.ZodDate = "ZodDate", a.ZodSymbol = "ZodSymbol", a.ZodUndefined = "ZodUndefined", a.ZodNull = "ZodNull", a.ZodAny = "ZodAny", a.ZodUnknown = "ZodUnknown", a.ZodNever = "ZodNever", a.ZodVoid = "ZodVoid", a.ZodArray = "ZodArray", a.ZodObject = "ZodObject", a.ZodUnion = "ZodUnion", a.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", a.ZodIntersection = "ZodIntersection", a.ZodTuple = "ZodTuple", a.ZodRecord = "ZodRecord", a.ZodMap = "ZodMap", a.ZodSet = "ZodSet", a.ZodFunction = "ZodFunction", a.ZodLazy = "ZodLazy", a.ZodLiteral = "ZodLiteral", a.ZodEnum = "ZodEnum", a.ZodEffects = "ZodEffects", a.ZodNativeEnum = "ZodNativeEnum", a.ZodOptional = "ZodOptional", a.ZodNullable = "ZodNullable", a.ZodDefault = "ZodDefault", a.ZodCatch = "ZodCatch", a.ZodPromise = "ZodPromise", a.ZodBranded = "ZodBranded", a.ZodPipeline = "ZodPipeline", a.ZodReadonly = "ZodReadonly";
|
|
2910
|
-
})(
|
|
2971
|
+
})(x || (x = {}));
|
|
2911
2972
|
const L = j.create, y = pe.create;
|
|
2912
|
-
|
|
2973
|
+
st.create;
|
|
2913
2974
|
me.create;
|
|
2914
|
-
qe.create;
|
|
2915
|
-
be.create;
|
|
2916
2975
|
Ge.create;
|
|
2917
|
-
|
|
2918
|
-
Pe.create;
|
|
2976
|
+
be.create;
|
|
2919
2977
|
Qe.create;
|
|
2978
|
+
Pe.create;
|
|
2979
|
+
Ie.create;
|
|
2980
|
+
Je.create;
|
|
2920
2981
|
ue.create;
|
|
2921
2982
|
G.create;
|
|
2922
|
-
|
|
2983
|
+
et.create;
|
|
2923
2984
|
Z.create;
|
|
2924
2985
|
const O = P.create;
|
|
2925
2986
|
P.strictCreate;
|
|
2926
|
-
const
|
|
2927
|
-
|
|
2987
|
+
const vi = Re.create;
|
|
2988
|
+
at.create;
|
|
2928
2989
|
ze.create;
|
|
2929
2990
|
W.create;
|
|
2930
|
-
|
|
2931
|
-
|
|
2991
|
+
Le.create;
|
|
2992
|
+
it.create;
|
|
2932
2993
|
ge.create;
|
|
2933
2994
|
we.create;
|
|
2934
|
-
|
|
2935
|
-
const ne =
|
|
2936
|
-
|
|
2995
|
+
Ee.create;
|
|
2996
|
+
const ne = Me.create, Q = ie.create;
|
|
2997
|
+
Fe.create;
|
|
2937
2998
|
Ce.create;
|
|
2938
|
-
|
|
2999
|
+
X.create;
|
|
2939
3000
|
U.create;
|
|
2940
3001
|
se.create;
|
|
2941
|
-
|
|
3002
|
+
X.createWithPreprocess;
|
|
2942
3003
|
Ke.create;
|
|
2943
|
-
const
|
|
3004
|
+
const xi = Q(["linear", "bezier", "constant"]), wi = Q([
|
|
2944
3005
|
"ease",
|
|
2945
3006
|
"easeIn",
|
|
2946
3007
|
"easeOut",
|
|
@@ -2974,154 +3035,154 @@ const vi = Q(["linear", "bezier", "constant"]), xi = Q([
|
|
|
2974
3035
|
to: y(),
|
|
2975
3036
|
start: y().min(0),
|
|
2976
3037
|
length: y().positive(),
|
|
2977
|
-
interpolation:
|
|
2978
|
-
easing:
|
|
2979
|
-
}),
|
|
3038
|
+
interpolation: xi.optional(),
|
|
3039
|
+
easing: wi.optional()
|
|
3040
|
+
}), _i = L().url("Invalid audio url format."), ki = ae.extend({
|
|
2980
3041
|
from: y().min(0).max(1),
|
|
2981
3042
|
to: y().min(0).max(1)
|
|
2982
|
-
}).array().or(y().min(0).max(1)),
|
|
3043
|
+
}).array().or(y().min(0).max(1)), vt = O({
|
|
2983
3044
|
type: ne("audio"),
|
|
2984
|
-
src:
|
|
3045
|
+
src: _i,
|
|
2985
3046
|
trim: y().optional(),
|
|
2986
|
-
volume:
|
|
2987
|
-
}),
|
|
3047
|
+
volume: ki.optional()
|
|
3048
|
+
}), bi = Q(["top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", "left", "topLeft", "center"]), xt = O({
|
|
2988
3049
|
type: ne("html"),
|
|
2989
3050
|
html: L(),
|
|
2990
3051
|
css: L(),
|
|
2991
3052
|
width: y().positive().optional(),
|
|
2992
3053
|
height: y().positive().optional(),
|
|
2993
|
-
position:
|
|
2994
|
-
}),
|
|
3054
|
+
position: bi.optional()
|
|
3055
|
+
}), Ci = L().url("Invalid image url format."), Si = O({
|
|
2995
3056
|
top: y().min(0).optional(),
|
|
2996
3057
|
right: y().min(0).optional(),
|
|
2997
3058
|
bottom: y().min(0).optional(),
|
|
2998
3059
|
left: y().min(0).optional()
|
|
2999
|
-
}),
|
|
3060
|
+
}), wt = O({
|
|
3000
3061
|
type: ne("image"),
|
|
3001
|
-
src:
|
|
3002
|
-
crop:
|
|
3003
|
-
}),
|
|
3062
|
+
src: Ci,
|
|
3063
|
+
crop: Si.optional()
|
|
3064
|
+
}), Ti = L().url("Invalid luma url format."), _t = O({
|
|
3004
3065
|
type: ne("luma"),
|
|
3005
|
-
src:
|
|
3006
|
-
}),
|
|
3066
|
+
src: Ti
|
|
3067
|
+
}), Ft = L().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/, "Invalid color format."), kt = O({
|
|
3007
3068
|
width: y().positive(),
|
|
3008
3069
|
height: y().positive()
|
|
3009
|
-
}), kt = O({
|
|
3010
|
-
radius: y().positive()
|
|
3011
3070
|
}), bt = O({
|
|
3071
|
+
radius: y().positive()
|
|
3072
|
+
}), Ct = O({
|
|
3012
3073
|
length: y().positive(),
|
|
3013
3074
|
thickness: y().positive()
|
|
3014
|
-
}), Ti = O({
|
|
3015
|
-
color: Et,
|
|
3016
|
-
opacity: y().min(0).max(1)
|
|
3017
3075
|
}), Oi = O({
|
|
3018
|
-
color:
|
|
3076
|
+
color: Ft,
|
|
3077
|
+
opacity: y().min(0).max(1)
|
|
3078
|
+
}), Ai = O({
|
|
3079
|
+
color: Ft,
|
|
3019
3080
|
width: y().positive()
|
|
3020
|
-
}),
|
|
3081
|
+
}), St = O({
|
|
3021
3082
|
type: ne("shape"),
|
|
3022
3083
|
width: y().positive().optional(),
|
|
3023
3084
|
height: y().positive().optional(),
|
|
3024
3085
|
shape: Q(["rectangle", "circle", "line"]),
|
|
3025
|
-
fill:
|
|
3026
|
-
stroke:
|
|
3027
|
-
rectangle:
|
|
3028
|
-
circle:
|
|
3029
|
-
line:
|
|
3030
|
-
}).refine((a) => a.shape === "rectangle" ?
|
|
3031
|
-
color:
|
|
3086
|
+
fill: Oi.optional(),
|
|
3087
|
+
stroke: Ai.optional(),
|
|
3088
|
+
rectangle: kt.optional(),
|
|
3089
|
+
circle: bt.optional(),
|
|
3090
|
+
line: Ct.optional()
|
|
3091
|
+
}).refine((a) => a.shape === "rectangle" ? kt.safeParse(a.rectangle) : a.shape === "circle" ? bt.safeParse(a.circle) : a.shape === "line" ? Ct.safeParse(a.line) : !1), rt = L().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/, "Invalid color format."), Pi = O({
|
|
3092
|
+
color: rt.optional(),
|
|
3032
3093
|
family: L().optional(),
|
|
3033
3094
|
size: y().positive().optional(),
|
|
3034
3095
|
weight: y().optional(),
|
|
3035
3096
|
lineHeight: y().optional()
|
|
3036
|
-
}),
|
|
3097
|
+
}), Ii = O({
|
|
3037
3098
|
horizontal: Q(["left", "center", "right"]).optional(),
|
|
3038
3099
|
vertical: Q(["top", "center", "bottom"]).optional()
|
|
3039
3100
|
}), Ri = O({
|
|
3040
|
-
color:
|
|
3101
|
+
color: rt,
|
|
3041
3102
|
opacity: y().min(0).max(1)
|
|
3042
3103
|
}), zi = O({
|
|
3043
3104
|
width: y().positive(),
|
|
3044
|
-
color:
|
|
3045
|
-
}),
|
|
3105
|
+
color: rt
|
|
3106
|
+
}), Tt = O({
|
|
3046
3107
|
type: ne("text"),
|
|
3047
3108
|
text: L(),
|
|
3048
3109
|
width: y().positive().optional(),
|
|
3049
3110
|
height: y().positive().optional(),
|
|
3050
|
-
font:
|
|
3051
|
-
alignment:
|
|
3111
|
+
font: Pi.optional(),
|
|
3112
|
+
alignment: Ii.optional(),
|
|
3052
3113
|
background: Ri.optional(),
|
|
3053
3114
|
stroke: zi.optional()
|
|
3054
|
-
}),
|
|
3115
|
+
}), Li = L().url("Invalid video url format."), Ei = O({
|
|
3055
3116
|
top: y().min(0).optional(),
|
|
3056
3117
|
right: y().min(0).optional(),
|
|
3057
3118
|
bottom: y().min(0).optional(),
|
|
3058
3119
|
left: y().min(0).optional()
|
|
3059
|
-
}),
|
|
3120
|
+
}), Mi = ae.extend({
|
|
3060
3121
|
from: y().min(0).max(1),
|
|
3061
3122
|
to: y().min(0).max(1)
|
|
3062
|
-
}).array().or(y().min(0).max(1)),
|
|
3123
|
+
}).array().or(y().min(0).max(1)), Ot = O({
|
|
3063
3124
|
type: ne("video"),
|
|
3064
|
-
src:
|
|
3125
|
+
src: Li,
|
|
3065
3126
|
trim: y().optional(),
|
|
3066
|
-
crop:
|
|
3067
|
-
volume:
|
|
3068
|
-
}),
|
|
3127
|
+
crop: Ei.optional(),
|
|
3128
|
+
volume: Mi.optional()
|
|
3129
|
+
}), Fi = vi([Tt, St, xt, wt, Ot, _t, vt]).refine((a) => a.type === "text" ? Tt.safeParse(a) : a.type === "shape" ? St.safeParse(a) : a.type === "html" ? xt.safeParse(a) : a.type === "image" ? wt.safeParse(a) : a.type === "video" ? Ot.safeParse(a) : a.type === "luma" ? _t.safeParse(a) : a.type === "audio" ? vt.safeParse(a) : !1), Ni = Q(["topLeft", "top", "topRight", "left", "center", "right", "bottomLeft", "bottom", "bottomRight"]), Di = Q(["crop", "cover", "contain", "none"]), de = y().min(-10).max(10).default(0), Zi = ae.extend({
|
|
3069
3130
|
from: de,
|
|
3070
3131
|
to: de
|
|
3071
|
-
}).array().or(de),
|
|
3132
|
+
}).array().or(de), Vi = ae.extend({
|
|
3072
3133
|
from: de,
|
|
3073
3134
|
to: de
|
|
3074
3135
|
}).array().or(de), Ki = O({
|
|
3075
|
-
x:
|
|
3076
|
-
y:
|
|
3136
|
+
x: Zi.default(0),
|
|
3137
|
+
y: Vi.default(0)
|
|
3077
3138
|
}), Hi = ae.extend({
|
|
3078
3139
|
from: y().min(0).max(1),
|
|
3079
3140
|
to: y().min(0).max(1)
|
|
3080
3141
|
}).array().or(y().min(0).max(1)), Bi = ae.extend({
|
|
3081
3142
|
from: y().min(0),
|
|
3082
3143
|
to: y().min(0)
|
|
3083
|
-
}).array().or(y().min(0)),
|
|
3144
|
+
}).array().or(y().min(0)), $i = O({
|
|
3084
3145
|
angle: ae.extend({
|
|
3085
3146
|
from: y(),
|
|
3086
3147
|
to: y()
|
|
3087
3148
|
}).array().or(y())
|
|
3088
|
-
}),
|
|
3089
|
-
in:
|
|
3090
|
-
out:
|
|
3091
|
-
}),
|
|
3092
|
-
rotate:
|
|
3093
|
-
}),
|
|
3094
|
-
asset:
|
|
3149
|
+
}), ji = L(), At = L(), Ui = O({
|
|
3150
|
+
in: At.optional(),
|
|
3151
|
+
out: At.optional()
|
|
3152
|
+
}), Wi = O({
|
|
3153
|
+
rotate: $i.default({ angle: 0 })
|
|
3154
|
+
}), Nt = O({
|
|
3155
|
+
asset: Fi,
|
|
3095
3156
|
start: y().min(0),
|
|
3096
3157
|
length: y().positive(),
|
|
3097
|
-
position:
|
|
3098
|
-
fit:
|
|
3158
|
+
position: Ni.default("center").optional(),
|
|
3159
|
+
fit: Di.default("crop").optional(),
|
|
3099
3160
|
offset: Ki.default({ x: 0, y: 0 }).optional(),
|
|
3100
3161
|
opacity: Hi.default(1).optional(),
|
|
3101
3162
|
scale: Bi.default(1).optional(),
|
|
3102
|
-
transform:
|
|
3103
|
-
effect:
|
|
3104
|
-
transition:
|
|
3105
|
-
}),
|
|
3106
|
-
clips:
|
|
3107
|
-
}), Yi = L().url("Invalid image url format."),
|
|
3163
|
+
transform: Wi.default({ rotate: { angle: 0 } }).optional(),
|
|
3164
|
+
effect: ji.optional(),
|
|
3165
|
+
transition: Ui.optional()
|
|
3166
|
+
}), Xi = O({
|
|
3167
|
+
clips: Nt.array()
|
|
3168
|
+
}), Yi = L().url("Invalid image url format."), qi = O({
|
|
3108
3169
|
src: Yi
|
|
3109
|
-
}), qi = O({
|
|
3110
|
-
background: L().optional(),
|
|
3111
|
-
fonts: Xi.array().optional(),
|
|
3112
|
-
tracks: Wi.array()
|
|
3113
3170
|
}), Gi = O({
|
|
3171
|
+
background: L().optional(),
|
|
3172
|
+
fonts: qi.array().optional(),
|
|
3173
|
+
tracks: Xi.array()
|
|
3174
|
+
}), Qi = O({
|
|
3114
3175
|
size: O({
|
|
3115
3176
|
width: y().positive(),
|
|
3116
3177
|
height: y().positive()
|
|
3117
3178
|
}),
|
|
3118
3179
|
fps: y().positive().optional(),
|
|
3119
3180
|
format: L()
|
|
3120
|
-
}),
|
|
3121
|
-
timeline:
|
|
3122
|
-
output:
|
|
3181
|
+
}), Ji = O({
|
|
3182
|
+
timeline: Gi,
|
|
3183
|
+
output: Qi
|
|
3123
3184
|
});
|
|
3124
|
-
class
|
|
3185
|
+
class es {
|
|
3125
3186
|
curves = {};
|
|
3126
3187
|
constructor() {
|
|
3127
3188
|
this.initializeCurves();
|
|
@@ -3243,8 +3304,8 @@ class Ji {
|
|
|
3243
3304
|
};
|
|
3244
3305
|
}
|
|
3245
3306
|
getValue(e, t, i, s) {
|
|
3246
|
-
const n = this.curves[s ?? ""] ?? this.curves.ease, [[r, o], [h, c]] = n, l = i + (3 * r - 3 * h + 1) * i * (1 - i),
|
|
3247
|
-
return N ** 3 *
|
|
3307
|
+
const n = this.curves[s ?? ""] ?? this.curves.ease, [[r, o], [h, c]] = n, l = i + (3 * r - 3 * h + 1) * i * (1 - i), m = e, p = e + (t - e) * o, k = e + (t - e) * c, A = t, S = l, N = 1 - S;
|
|
3308
|
+
return N ** 3 * m + 3 * N ** 2 * S * p + 3 * N * S ** 2 * k + S ** 3 * A;
|
|
3248
3309
|
}
|
|
3249
3310
|
}
|
|
3250
3311
|
class R {
|
|
@@ -3252,7 +3313,7 @@ class R {
|
|
|
3252
3313
|
length;
|
|
3253
3314
|
cubicBuilder;
|
|
3254
3315
|
constructor(e, t, i = 0) {
|
|
3255
|
-
this.property = this.createKeyframes(e, t, i), this.length = t, this.cubicBuilder = new
|
|
3316
|
+
this.property = this.createKeyframes(e, t, i), this.length = t, this.cubicBuilder = new es();
|
|
3256
3317
|
}
|
|
3257
3318
|
getValue(e) {
|
|
3258
3319
|
const t = this.property.find((s) => e >= s.start && e < s.start + s.length);
|
|
@@ -3312,7 +3373,7 @@ class R {
|
|
|
3312
3373
|
}
|
|
3313
3374
|
if (s.push(r), !o) {
|
|
3314
3375
|
if (r.start + r.length < t) {
|
|
3315
|
-
const
|
|
3376
|
+
const m = r.start + r.length, p = { start: m, length: t - m, from: r.to, to: r.to };
|
|
3316
3377
|
s.push(p);
|
|
3317
3378
|
}
|
|
3318
3379
|
break;
|
|
@@ -3332,8 +3393,8 @@ class He {
|
|
|
3332
3393
|
validAudioExtensions;
|
|
3333
3394
|
constructor() {
|
|
3334
3395
|
this.name = He.Name, this.extension = {
|
|
3335
|
-
type: [
|
|
3336
|
-
priority:
|
|
3396
|
+
type: [v.ExtensionType.LoadParser],
|
|
3397
|
+
priority: v.LoaderParserPriority.Normal,
|
|
3337
3398
|
ref: null
|
|
3338
3399
|
}, this.validAudioExtensions = ["mp3", "mpeg", "ogg", "wav"];
|
|
3339
3400
|
}
|
|
@@ -3351,7 +3412,7 @@ class He {
|
|
|
3351
3412
|
e?.unload();
|
|
3352
3413
|
}
|
|
3353
3414
|
}
|
|
3354
|
-
class
|
|
3415
|
+
class ts {
|
|
3355
3416
|
clipConfiguration;
|
|
3356
3417
|
constructor(e) {
|
|
3357
3418
|
this.clipConfiguration = e;
|
|
@@ -3450,7 +3511,7 @@ class es {
|
|
|
3450
3511
|
return 0;
|
|
3451
3512
|
}
|
|
3452
3513
|
}
|
|
3453
|
-
class
|
|
3514
|
+
class is {
|
|
3454
3515
|
clipConfiguration;
|
|
3455
3516
|
constructor(e) {
|
|
3456
3517
|
this.clipConfiguration = e;
|
|
@@ -3473,8 +3534,8 @@ class ts {
|
|
|
3473
3534
|
break;
|
|
3474
3535
|
}
|
|
3475
3536
|
case "zoom": {
|
|
3476
|
-
const l = this.clipConfiguration.scale + 9,
|
|
3477
|
-
s.push({ from: l, to:
|
|
3537
|
+
const l = this.clipConfiguration.scale + 9, m = this.clipConfiguration.scale;
|
|
3538
|
+
s.push({ from: l, to: m, start: r, length: o, interpolation: "bezier", easing: "easeIn" }), i.push({ from: 0, to: 1, start: r, length: o, interpolation: "bezier", easing: "easeIn" });
|
|
3478
3539
|
break;
|
|
3479
3540
|
}
|
|
3480
3541
|
case "slideLeft": {
|
|
@@ -3527,8 +3588,8 @@ class ts {
|
|
|
3527
3588
|
break;
|
|
3528
3589
|
}
|
|
3529
3590
|
case "zoom": {
|
|
3530
|
-
const l = this.clipConfiguration.scale,
|
|
3531
|
-
s.push({ from: l, to:
|
|
3591
|
+
const l = this.clipConfiguration.scale, m = l + 9;
|
|
3592
|
+
s.push({ from: l, to: m, start: o, length: r, interpolation: "bezier", easing: "easeOut" }), i.push({ from: 1, to: 0, start: o, length: r, interpolation: "bezier", easing: "easeOut" });
|
|
3532
3593
|
break;
|
|
3533
3594
|
}
|
|
3534
3595
|
case "slideLeft": {
|
|
@@ -3604,11 +3665,11 @@ class ts {
|
|
|
3604
3665
|
}
|
|
3605
3666
|
}
|
|
3606
3667
|
}
|
|
3607
|
-
class
|
|
3668
|
+
class ss {
|
|
3608
3669
|
static ButtonLeftClick = 0;
|
|
3609
3670
|
static ButtonRightClick = 3;
|
|
3610
3671
|
}
|
|
3611
|
-
class
|
|
3672
|
+
class ns {
|
|
3612
3673
|
containerSize;
|
|
3613
3674
|
constructor(e) {
|
|
3614
3675
|
this.containerSize = e;
|
|
@@ -3714,17 +3775,17 @@ class ss {
|
|
|
3714
3775
|
}
|
|
3715
3776
|
}
|
|
3716
3777
|
}
|
|
3717
|
-
class
|
|
3778
|
+
class ot {
|
|
3718
3779
|
container;
|
|
3719
3780
|
constructor() {
|
|
3720
|
-
this.container = new
|
|
3781
|
+
this.container = new v.Container();
|
|
3721
3782
|
}
|
|
3722
3783
|
/** @internal */
|
|
3723
3784
|
getContainer() {
|
|
3724
3785
|
return this.container;
|
|
3725
3786
|
}
|
|
3726
3787
|
}
|
|
3727
|
-
class
|
|
3788
|
+
class I extends ot {
|
|
3728
3789
|
static SnapThreshold = 20;
|
|
3729
3790
|
static DiscardedFrameCount = Math.ceil(1 / 30 * 1e3);
|
|
3730
3791
|
static ScaleHandleRadius = 10;
|
|
@@ -3760,18 +3821,18 @@ class z extends rt {
|
|
|
3760
3821
|
rotationOffset;
|
|
3761
3822
|
initialClipConfiguration;
|
|
3762
3823
|
constructor(e, t) {
|
|
3763
|
-
super(), this.edit = e, this.layer = 0, this.shouldDispose = !1, this.clipConfiguration = t, this.positionBuilder = new
|
|
3824
|
+
super(), this.edit = e, this.layer = 0, this.shouldDispose = !1, this.clipConfiguration = t, this.positionBuilder = new ns(e.size), this.outline = null, this.topLeftScaleHandle = null, this.topRightScaleHandle = null, this.bottomRightScaleHandle = null, this.bottomLeftScaleHandle = null, this.rotationHandle = null, this.isHovering = !1, this.isDragging = !1, this.dragOffset = { x: 0, y: 0 }, this.scaleDirection = null, this.scaleStart = null, this.scaleOffset = { x: 0, y: 0 }, this.isRotating = !1, this.rotationStart = null, this.rotationOffset = { x: 0, y: 0 }, this.initialClipConfiguration = null;
|
|
3764
3825
|
}
|
|
3765
3826
|
configureKeyframes() {
|
|
3766
3827
|
if (this.offsetXKeyframeBuilder = new R(this.clipConfiguration.offset?.x ?? 0, this.getLength()), this.offsetYKeyframeBuilder = new R(this.clipConfiguration.offset?.y ?? 0, this.getLength()), this.scaleKeyframeBuilder = new R(this.clipConfiguration.scale ?? 1, this.getLength(), 1), this.opacityKeyframeBuilder = new R(this.clipConfiguration.opacity ?? 1, this.getLength(), 1), this.rotationKeyframeBuilder = new R(this.clipConfiguration.transform?.rotate?.angle ?? 0, this.getLength()), this.clipHasKeyframes())
|
|
3767
3828
|
return;
|
|
3768
|
-
const e = [], t = [], i = [], s = [], n = [], r = new
|
|
3829
|
+
const e = [], t = [], i = [], s = [], n = [], r = new ts(this.clipConfiguration).build(this.edit.size, this.getSize());
|
|
3769
3830
|
e.push(...r.offsetXKeyframes), t.push(...r.offsetYKeyframes), i.push(...r.opacityKeyframes), s.push(...r.scaleKeyframes), n.push(...r.rotationKeyframes);
|
|
3770
|
-
const o = new
|
|
3831
|
+
const o = new is(this.clipConfiguration).build();
|
|
3771
3832
|
e.push(...o.offsetXKeyframes), t.push(...o.offsetYKeyframes), i.push(...o.opacityKeyframes), s.push(...o.scaleKeyframes), n.push(...o.rotationKeyframes), e.length && (this.offsetXKeyframeBuilder = new R(e, this.getLength())), t.length && (this.offsetYKeyframeBuilder = new R(t, this.getLength())), i.length && (this.opacityKeyframeBuilder = new R(i, this.getLength(), 1)), s.length && (this.scaleKeyframeBuilder = new R(s, this.getLength(), 1)), n.length && (this.rotationKeyframeBuilder = new R(n, this.getLength()));
|
|
3772
3833
|
}
|
|
3773
3834
|
async load() {
|
|
3774
|
-
this.outline = new
|
|
3835
|
+
this.outline = new v.Graphics(), this.getContainer().addChild(this.outline), this.topLeftScaleHandle = new v.Graphics(), this.topRightScaleHandle = new v.Graphics(), this.bottomRightScaleHandle = new v.Graphics(), this.bottomLeftScaleHandle = new v.Graphics(), this.getContainer().addChild(this.topLeftScaleHandle), this.getContainer().addChild(this.topRightScaleHandle), this.getContainer().addChild(this.bottomRightScaleHandle), this.getContainer().addChild(this.bottomLeftScaleHandle), this.rotationHandle = new v.Graphics(), this.getContainer().addChild(this.rotationHandle), this.getContainer().cursor = "pointer", this.getContainer().eventMode = "static", this.getContainer().on("pointerdown", this.onPointerStart.bind(this)), this.getContainer().on("pointermove", this.onPointerMove.bind(this)), this.getContainer().on("globalpointermove", this.onPointerMove.bind(this)), this.getContainer().on("pointerup", this.onPointerUp.bind(this)), this.getContainer().on("pointerupoutside", this.onPointerUp.bind(this)), this.getContainer().on("pointerover", this.onPointerOver.bind(this)), this.getContainer().on("pointerout", this.onPointerOut.bind(this));
|
|
3775
3836
|
}
|
|
3776
3837
|
update(e, t) {
|
|
3777
3838
|
if (this.getContainer().visible = this.isActive(), this.getContainer().zIndex = this.layer, !this.isActive())
|
|
@@ -3789,14 +3850,14 @@ class z extends rt {
|
|
|
3789
3850
|
return;
|
|
3790
3851
|
}
|
|
3791
3852
|
const e = this.isHovering || this.isDragging ? 65535 : 16777215, t = this.getSize(), i = this.getScale();
|
|
3792
|
-
if (this.outline.clear(), this.outline.strokeStyle = { width:
|
|
3853
|
+
if (this.outline.clear(), this.outline.strokeStyle = { width: I.OutlineWidth / i, color: e }, this.outline.rect(0, 0, t.width, t.height), this.outline.stroke(), !this.topLeftScaleHandle || !this.topRightScaleHandle || !this.bottomRightScaleHandle || !this.bottomLeftScaleHandle || !this.isActive() || this.edit.getSelectedClip() !== this)
|
|
3793
3854
|
return;
|
|
3794
3855
|
this.topLeftScaleHandle.fillStyle = { color: e }, this.topLeftScaleHandle.clear();
|
|
3795
|
-
const s =
|
|
3856
|
+
const s = I.ScaleHandleRadius * 2 / i;
|
|
3796
3857
|
if (this.topLeftScaleHandle.rect(-s / 2, -s / 2, s, s), this.topLeftScaleHandle.fill(), this.topRightScaleHandle.fillStyle = { color: e }, this.topRightScaleHandle.clear(), this.topRightScaleHandle.rect(t.width - s / 2, -s / 2, s, s), this.topRightScaleHandle.fill(), this.bottomRightScaleHandle.fillStyle = { color: e }, this.bottomRightScaleHandle.clear(), this.bottomRightScaleHandle.rect(t.width - s / 2, t.height - s / 2, s, s), this.bottomRightScaleHandle.fill(), this.bottomLeftScaleHandle.fillStyle = { color: e }, this.bottomLeftScaleHandle.clear(), this.bottomLeftScaleHandle.rect(-s / 2, t.height - s / 2, s, s), this.bottomLeftScaleHandle.fill(), !this.rotationHandle)
|
|
3797
3858
|
return;
|
|
3798
3859
|
const n = t.width / 2, r = -50 / i;
|
|
3799
|
-
this.rotationHandle.clear(), this.rotationHandle.fillStyle = { color: e }, this.rotationHandle.circle(n, r,
|
|
3860
|
+
this.rotationHandle.clear(), this.rotationHandle.fillStyle = { color: e }, this.rotationHandle.circle(n, r, I.RotationHandleRadius / i), this.rotationHandle.fill(), this.outline.strokeStyle = { width: I.OutlineWidth / i, color: e }, this.outline.moveTo(n, 0), this.outline.lineTo(n, r), this.outline.stroke();
|
|
3800
3861
|
}
|
|
3801
3862
|
dispose() {
|
|
3802
3863
|
this.outline?.destroy(), this.outline = null, this.topLeftScaleHandle?.destroy(), this.topLeftScaleHandle = null, this.topRightScaleHandle?.destroy(), this.topRightScaleHandle = null, this.bottomLeftScaleHandle?.destroy(), this.bottomLeftScaleHandle = null, this.bottomRightScaleHandle?.destroy(), this.bottomRightScaleHandle = null, this.rotationHandle?.destroy(), this.rotationHandle = null;
|
|
@@ -3851,10 +3912,10 @@ class z extends rt {
|
|
|
3851
3912
|
return this.edit.playbackTime >= this.getStart() && this.edit.playbackTime < this.getEnd();
|
|
3852
3913
|
}
|
|
3853
3914
|
shouldDiscardFrame() {
|
|
3854
|
-
return this.getPlaybackTime() <
|
|
3915
|
+
return this.getPlaybackTime() < I.DiscardedFrameCount;
|
|
3855
3916
|
}
|
|
3856
3917
|
onPointerStart(e) {
|
|
3857
|
-
if (e.button !==
|
|
3918
|
+
if (e.button !== ss.ButtonLeftClick || (this.edit.setSelectedClip(this), this.initialClipConfiguration = structuredClone(this.clipConfiguration), this.clipHasKeyframes()))
|
|
3858
3919
|
return;
|
|
3859
3920
|
if (this.scaleDirection = null, this.topLeftScaleHandle?.getBounds().containsPoint(e.globalX, e.globalY) && (this.scaleDirection = "topLeft"), this.topRightScaleHandle?.getBounds().containsPoint(e.globalX, e.globalY) && (this.scaleDirection = "topRight"), this.bottomRightScaleHandle?.getBounds().containsPoint(e.globalX, e.globalY) && (this.scaleDirection = "bottomRight"), this.bottomLeftScaleHandle?.getBounds().containsPoint(e.globalX, e.globalY) && (this.scaleDirection = "bottomLeft"), this.scaleDirection !== null) {
|
|
3860
3921
|
this.scaleStart = this.getScale() / this.getFitScale();
|
|
@@ -3878,14 +3939,14 @@ class z extends rt {
|
|
|
3878
3939
|
onPointerMove(e) {
|
|
3879
3940
|
if (this.scaleDirection !== null && this.scaleStart !== null) {
|
|
3880
3941
|
const t = e.getLocalPosition(this.edit.getContainer()), i = this.getPosition(), s = this.getPivot(), n = { x: i.x + s.x, y: i.y + s.y }, r = Math.sqrt((this.scaleOffset.x - n.x) ** 2 + (this.scaleOffset.y - n.y) ** 2), h = Math.sqrt((t.x - n.x) ** 2 + (t.y - n.y) ** 2) / r, c = this.scaleStart * h;
|
|
3881
|
-
this.clipConfiguration.scale = Math.max(
|
|
3942
|
+
this.clipConfiguration.scale = Math.max(I.MinScale, Math.min(c, I.MaxScale)), this.scaleKeyframeBuilder = new R(this.clipConfiguration.scale, this.getLength(), 1);
|
|
3882
3943
|
return;
|
|
3883
3944
|
}
|
|
3884
3945
|
if (this.isRotating && this.rotationStart !== null) {
|
|
3885
3946
|
const t = e.getLocalPosition(this.edit.getContainer()), i = this.getPosition(), s = this.getPivot(), n = { x: i.x + s.x, y: i.y + s.y }, r = Math.atan2(this.rotationOffset.y - n.y, this.rotationOffset.x - n.x), h = (Math.atan2(t.y - n.y, t.x - n.x) - r) * (180 / Math.PI);
|
|
3886
3947
|
let c = this.rotationStart + h;
|
|
3887
|
-
const l = 45,
|
|
3888
|
-
Math.abs(
|
|
3948
|
+
const l = 45, m = c % l, p = 2;
|
|
3949
|
+
Math.abs(m) < p ? c = Math.floor(c / l) * l : Math.abs(m - l) < p && (c = Math.ceil(c / l) * l), this.clipConfiguration.transform || (this.clipConfiguration.transform = { rotate: { angle: 0 } }), this.clipConfiguration.transform.rotate || (this.clipConfiguration.transform.rotate = { angle: 0 }), this.clipConfiguration.transform.rotate.angle = c, this.rotationKeyframeBuilder = new R(this.clipConfiguration.transform.rotate.angle, this.getLength());
|
|
3889
3950
|
return;
|
|
3890
3951
|
}
|
|
3891
3952
|
if (this.isDragging) {
|
|
@@ -3899,12 +3960,12 @@ class z extends rt {
|
|
|
3899
3960
|
{ x: n.x + this.getSize().width, y: n.y },
|
|
3900
3961
|
{ x: n.x, y: n.y + this.getSize().height },
|
|
3901
3962
|
{ x: n.x + this.getSize().width, y: n.y + this.getSize().height }
|
|
3902
|
-
], l = { x: n.x + this.getSize().width / 2, y: n.y + this.getSize().height / 2 },
|
|
3903
|
-
let p =
|
|
3904
|
-
for (const J of
|
|
3963
|
+
], l = { x: n.x + this.getSize().width / 2, y: n.y + this.getSize().height / 2 }, m = [...c, l];
|
|
3964
|
+
let p = I.SnapThreshold, k = I.SnapThreshold, A = null, S = null;
|
|
3965
|
+
for (const J of m)
|
|
3905
3966
|
for (const re of h) {
|
|
3906
|
-
const
|
|
3907
|
-
|
|
3967
|
+
const K = Math.abs(J.x - re.x);
|
|
3968
|
+
K < p && (p = K, A = n.x + (re.x - J.x));
|
|
3908
3969
|
const oe = Math.abs(J.y - re.y);
|
|
3909
3970
|
oe < k && (k = oe, S = n.y + (re.y - J.y));
|
|
3910
3971
|
}
|
|
@@ -3943,7 +4004,7 @@ class z extends rt {
|
|
|
3943
4004
|
return n !== void 0 && e !== n || r !== void 0 && t !== r || o !== void 0 && i !== o || s !== h;
|
|
3944
4005
|
}
|
|
3945
4006
|
}
|
|
3946
|
-
class
|
|
4007
|
+
class nt extends I {
|
|
3947
4008
|
audioResource;
|
|
3948
4009
|
isPlaying;
|
|
3949
4010
|
volumeKeyframeBuilder;
|
|
@@ -3956,7 +4017,7 @@ class st extends z {
|
|
|
3956
4017
|
async load() {
|
|
3957
4018
|
await super.load();
|
|
3958
4019
|
const e = this.clipConfiguration.asset, t = e.src, i = { src: t, loadParser: He.Name }, s = await this.edit.assetLoader.load(t, i);
|
|
3959
|
-
if (!(s instanceof
|
|
4020
|
+
if (!(s instanceof Ut.Howl))
|
|
3960
4021
|
throw new Error(`Invalid audio source '${e.src}'.`);
|
|
3961
4022
|
this.audioResource = s, this.configureKeyframes();
|
|
3962
4023
|
}
|
|
@@ -3983,7 +4044,7 @@ class st extends z {
|
|
|
3983
4044
|
return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime());
|
|
3984
4045
|
}
|
|
3985
4046
|
}
|
|
3986
|
-
var
|
|
4047
|
+
var as = `in vec2 aPosition;
|
|
3987
4048
|
out vec2 vTextureCoord;
|
|
3988
4049
|
|
|
3989
4050
|
uniform vec4 uInputSize;
|
|
@@ -4010,7 +4071,7 @@ void main(void)
|
|
|
4010
4071
|
gl_Position = filterVertexPosition();
|
|
4011
4072
|
vTextureCoord = filterTextureCoord();
|
|
4012
4073
|
}
|
|
4013
|
-
`,
|
|
4074
|
+
`, rs = `struct GlobalFilterUniforms {
|
|
4014
4075
|
uInputSize:vec4<f32>,
|
|
4015
4076
|
uInputPixel:vec4<f32>,
|
|
4016
4077
|
uInputClamp:vec4<f32>,
|
|
@@ -4059,7 +4120,7 @@ fn mainVertex(
|
|
|
4059
4120
|
filterVertexPosition(aPosition),
|
|
4060
4121
|
filterTextureCoord(aPosition)
|
|
4061
4122
|
);
|
|
4062
|
-
}`,
|
|
4123
|
+
}`, os = `precision highp float;
|
|
4063
4124
|
in vec2 vTextureCoord;
|
|
4064
4125
|
out vec4 finalColor;
|
|
4065
4126
|
|
|
@@ -4100,7 +4161,7 @@ void main(void) {
|
|
|
4100
4161
|
vec4 outlineColor = vec4(vec3(uColor) * outlineAlpha, outlineAlpha);
|
|
4101
4162
|
finalColor = contentColor + outlineColor;
|
|
4102
4163
|
}
|
|
4103
|
-
`,
|
|
4164
|
+
`, cs = `struct OutlineUniforms {
|
|
4104
4165
|
uThickness:vec2<f32>,
|
|
4105
4166
|
uColor:vec3<f32>,
|
|
4106
4167
|
uAlpha:f32,
|
|
@@ -4164,24 +4225,24 @@ fn outlineMaxAlphaAtPos(uv: vec2<f32>) -> f32 {
|
|
|
4164
4225
|
return maxAlpha;
|
|
4165
4226
|
}
|
|
4166
4227
|
|
|
4167
|
-
const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`,
|
|
4168
|
-
const Be = class ee extends
|
|
4228
|
+
const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`, ls = Object.defineProperty, hs = (a, e, t) => e in a ? ls(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, te = (a, e, t) => (hs(a, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4229
|
+
const Be = class ee extends Kt {
|
|
4169
4230
|
/** @ignore */
|
|
4170
4231
|
constructor(...e) {
|
|
4171
4232
|
let t = e[0] ?? {};
|
|
4172
|
-
typeof t == "number" && (
|
|
4173
|
-
const i = t.quality ?? 0.1, s =
|
|
4233
|
+
typeof t == "number" && (Ht("6.0.0", "OutlineFilter constructor params are now options object. See params: { thickness, color, quality, alpha, knockout }"), t = { thickness: t }, e[1] !== void 0 && (t.color = e[1]), e[2] !== void 0 && (t.quality = e[2]), e[3] !== void 0 && (t.alpha = e[3]), e[4] !== void 0 && (t.knockout = e[4])), t = { ...ee.DEFAULT_OPTIONS, ...t };
|
|
4234
|
+
const i = t.quality ?? 0.1, s = Bt.from({
|
|
4174
4235
|
vertex: {
|
|
4175
|
-
source:
|
|
4236
|
+
source: rs,
|
|
4176
4237
|
entryPoint: "mainVertex"
|
|
4177
4238
|
},
|
|
4178
4239
|
fragment: {
|
|
4179
|
-
source:
|
|
4240
|
+
source: cs,
|
|
4180
4241
|
entryPoint: "mainFragment"
|
|
4181
4242
|
}
|
|
4182
|
-
}), n =
|
|
4183
|
-
vertex:
|
|
4184
|
-
fragment:
|
|
4243
|
+
}), n = $t.from({
|
|
4244
|
+
vertex: as,
|
|
4245
|
+
fragment: os.replace(/\$\{ANGLE_STEP\}/, ee.getAngleStep(i).toFixed(7)),
|
|
4185
4246
|
name: "outline-filter"
|
|
4186
4247
|
});
|
|
4187
4248
|
super({
|
|
@@ -4196,7 +4257,7 @@ const Be = class ee extends Zt {
|
|
|
4196
4257
|
uKnockout: { value: t.knockout ? 1 : 0, type: "f32" }
|
|
4197
4258
|
}
|
|
4198
4259
|
}
|
|
4199
|
-
}), te(this, "uniforms"), te(this, "_thickness"), te(this, "_quality"), te(this, "_color"), this.uniforms = this.resources.outlineUniforms.uniforms, this.uniforms.uAngleStep = ee.getAngleStep(i), this._color = new
|
|
4260
|
+
}), te(this, "uniforms"), te(this, "_thickness"), te(this, "_quality"), te(this, "_color"), this.uniforms = this.resources.outlineUniforms.uniforms, this.uniforms.uAngleStep = ee.getAngleStep(i), this._color = new jt(), this.color = t.color ?? 0, Object.assign(this, t);
|
|
4200
4261
|
}
|
|
4201
4262
|
/**
|
|
4202
4263
|
* Override existing apply method in `Filter`
|
|
@@ -4280,8 +4341,8 @@ te(Be, "DEFAULT_OPTIONS", {
|
|
|
4280
4341
|
});
|
|
4281
4342
|
te(Be, "MIN_SAMPLES", 1);
|
|
4282
4343
|
te(Be, "MAX_SAMPLES", 100);
|
|
4283
|
-
let
|
|
4284
|
-
class
|
|
4344
|
+
let ct = Be;
|
|
4345
|
+
class us extends I {
|
|
4285
4346
|
background;
|
|
4286
4347
|
text;
|
|
4287
4348
|
constructor(e, t) {
|
|
@@ -4292,12 +4353,12 @@ class hs extends z {
|
|
|
4292
4353
|
const e = this.clipConfiguration.asset, t = await this.parseDocument();
|
|
4293
4354
|
if (!t)
|
|
4294
4355
|
return;
|
|
4295
|
-
const i = new
|
|
4356
|
+
const i = new v.Graphics();
|
|
4296
4357
|
t.background.color && (i.fillStyle = {
|
|
4297
4358
|
color: t.background.color,
|
|
4298
4359
|
alpha: t.background.opacity ?? 1
|
|
4299
4360
|
}, i.rect(0, 0, e.width ?? this.edit.size.width, e.height ?? this.edit.size.height), i.fill());
|
|
4300
|
-
const s = new
|
|
4361
|
+
const s = new v.Text();
|
|
4301
4362
|
s.text = t.text;
|
|
4302
4363
|
const { horizontal: n, vertical: r } = t.alignment;
|
|
4303
4364
|
s.style = {
|
|
@@ -4315,7 +4376,7 @@ class hs extends z {
|
|
|
4315
4376
|
x: o,
|
|
4316
4377
|
y: h
|
|
4317
4378
|
}, t.stroke.color && t.stroke.width) {
|
|
4318
|
-
const c = new
|
|
4379
|
+
const c = new ct({
|
|
4319
4380
|
thickness: t.stroke.width,
|
|
4320
4381
|
color: t.stroke.color
|
|
4321
4382
|
});
|
|
@@ -4349,14 +4410,14 @@ class hs extends z {
|
|
|
4349
4410
|
const r = new DOMParser().parseFromString(t, "text/html").body.textContent ?? "", h = (await new CSSStyleSheet().replace(i)).cssRules[0], c = { text: r, font: {}, alignment: {}, background: {}, stroke: {} };
|
|
4350
4411
|
if (h?.constructor.name !== "CSSStyleRule" || !("style" in h))
|
|
4351
4412
|
return console.warn("Unsupported css format."), c;
|
|
4352
|
-
const l = h.style,
|
|
4413
|
+
const l = h.style, m = this.parseAlignment(s ?? "center");
|
|
4353
4414
|
c.font = {
|
|
4354
4415
|
color: l.color.length ? l.color : void 0,
|
|
4355
4416
|
family: l.fontFamily.length ? l.fontFamily : void 0,
|
|
4356
4417
|
size: l.fontSize.length ? parseInt(l.fontSize, 10) : void 0,
|
|
4357
4418
|
weight: l.fontWeight.length ? parseInt(l.fontWeight, 10) : void 0,
|
|
4358
4419
|
lineHeight: l.lineHeight.length ? parseInt(l.lineHeight, 10) : void 0
|
|
4359
|
-
}, c.alignment =
|
|
4420
|
+
}, c.alignment = m;
|
|
4360
4421
|
let p = "";
|
|
4361
4422
|
return l.background.length && (p = l.background), l.backgroundColor.length && (p = l.backgroundColor), c.background = {
|
|
4362
4423
|
color: p.length ? p : void 0,
|
|
@@ -4390,7 +4451,7 @@ class hs extends z {
|
|
|
4390
4451
|
}
|
|
4391
4452
|
}
|
|
4392
4453
|
}
|
|
4393
|
-
class
|
|
4454
|
+
class ds extends I {
|
|
4394
4455
|
texture;
|
|
4395
4456
|
sprite;
|
|
4396
4457
|
constructor(e, t) {
|
|
@@ -4403,9 +4464,9 @@ class us extends z {
|
|
|
4403
4464
|
crossovern: "anonymous",
|
|
4404
4465
|
data: {}
|
|
4405
4466
|
}, s = await this.edit.assetLoader.load(t, i);
|
|
4406
|
-
if (!(s?.source instanceof
|
|
4467
|
+
if (!(s?.source instanceof v.ImageSource))
|
|
4407
4468
|
throw new Error(`Invalid image source '${e.src}'.`);
|
|
4408
|
-
this.texture = this.createCroppedTexture(s), this.sprite = new
|
|
4469
|
+
this.texture = this.createCroppedTexture(s), this.sprite = new v.Sprite(this.texture), this.getContainer().addChild(this.sprite), this.configureKeyframes();
|
|
4409
4470
|
}
|
|
4410
4471
|
update(e, t) {
|
|
4411
4472
|
super.update(e, t);
|
|
@@ -4423,11 +4484,47 @@ class us extends z {
|
|
|
4423
4484
|
const t = this.clipConfiguration.asset;
|
|
4424
4485
|
if (!t.crop)
|
|
4425
4486
|
return e;
|
|
4426
|
-
const i = e.width, s = e.height, n = Math.floor((t.crop?.left ?? 0) * i), r = Math.floor((t.crop?.right ?? 0) * i), o = Math.floor((t.crop?.top ?? 0) * s), h = Math.floor((t.crop?.bottom ?? 0) * s), c = n, l = o,
|
|
4427
|
-
return new
|
|
4487
|
+
const i = e.width, s = e.height, n = Math.floor((t.crop?.left ?? 0) * i), r = Math.floor((t.crop?.right ?? 0) * i), o = Math.floor((t.crop?.top ?? 0) * s), h = Math.floor((t.crop?.bottom ?? 0) * s), c = n, l = o, m = i - n - r, p = s - o - h, k = new v.Rectangle(c, l, m, p);
|
|
4488
|
+
return new v.Texture({ source: e.source, frame: k });
|
|
4428
4489
|
}
|
|
4429
4490
|
}
|
|
4430
|
-
class
|
|
4491
|
+
class Pt extends I {
|
|
4492
|
+
texture;
|
|
4493
|
+
sprite;
|
|
4494
|
+
isPlaying;
|
|
4495
|
+
constructor(e, t) {
|
|
4496
|
+
super(e, t), this.texture = null, this.sprite = null, this.isPlaying = !1;
|
|
4497
|
+
}
|
|
4498
|
+
async load() {
|
|
4499
|
+
await super.load();
|
|
4500
|
+
const e = this.clipConfiguration.asset, t = e.src, i = { src: t, data: { autoPlay: !1, muted: !0 } }, s = await this.edit.assetLoader.load(t, i);
|
|
4501
|
+
if (!(s?.source instanceof v.ImageSource || s?.source instanceof v.VideoSource))
|
|
4502
|
+
throw new Error(`Invalid luma source '${e.src}'.`);
|
|
4503
|
+
this.texture = s, this.sprite = new v.Sprite(this.texture), this.getContainer().addChild(this.sprite), this.configureKeyframes();
|
|
4504
|
+
}
|
|
4505
|
+
update(e, t) {
|
|
4506
|
+
if (super.update(e, t), !this.texture || !(this.texture.source instanceof v.VideoSource))
|
|
4507
|
+
return;
|
|
4508
|
+
const i = this.getPlaybackTime(), s = this.edit.isPlaying && this.isActive();
|
|
4509
|
+
s && (this.isPlaying || (this.isPlaying = !0, this.texture.source.resource.currentTime = i / 1e3, this.texture.source.resource.play().catch(console.error)), this.texture.source.resource.volume !== this.getVolume() && (this.texture.source.resource.volume = this.getVolume()), Math.abs(this.texture.source.resource.currentTime * 1e3 - i) > 100 && (this.texture.source.resource.currentTime = i / 1e3)), !s && this.isPlaying && (this.isPlaying = !1, this.texture.source.resource.pause()), !this.edit.isPlaying && this.isActive() && (this.texture.source.resource.currentTime = i / 1e3);
|
|
4510
|
+
}
|
|
4511
|
+
draw() {
|
|
4512
|
+
super.draw();
|
|
4513
|
+
}
|
|
4514
|
+
dispose() {
|
|
4515
|
+
super.dispose(), this.sprite?.destroy(), this.sprite = null, this.texture?.destroy(), this.texture = null;
|
|
4516
|
+
}
|
|
4517
|
+
getSize() {
|
|
4518
|
+
return { width: this.sprite?.width ?? 0, height: this.sprite?.height ?? 0 };
|
|
4519
|
+
}
|
|
4520
|
+
getVolume() {
|
|
4521
|
+
return 0;
|
|
4522
|
+
}
|
|
4523
|
+
getMask() {
|
|
4524
|
+
return this.sprite;
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
class fs extends I {
|
|
4431
4528
|
shape;
|
|
4432
4529
|
shapeBackground;
|
|
4433
4530
|
constructor(e, t) {
|
|
@@ -4435,9 +4532,9 @@ class ds extends z {
|
|
|
4435
4532
|
}
|
|
4436
4533
|
async load() {
|
|
4437
4534
|
await super.load();
|
|
4438
|
-
const e = this.clipConfiguration.asset, t = new
|
|
4535
|
+
const e = this.clipConfiguration.asset, t = new v.Graphics(), i = e.width ?? this.edit.size.width, s = e.height ?? this.edit.size.height;
|
|
4439
4536
|
t.fillStyle = { color: "transparent" }, t.rect(0, 0, i, s), t.fill();
|
|
4440
|
-
const n = new
|
|
4537
|
+
const n = new v.Graphics();
|
|
4441
4538
|
switch (e.shape) {
|
|
4442
4539
|
case "rectangle": {
|
|
4443
4540
|
const r = e.rectangle, o = i / 2 - r.width / 2, h = s / 2 - r.height / 2;
|
|
@@ -4462,7 +4559,7 @@ class ds extends z {
|
|
|
4462
4559
|
color: e.fill?.color ?? "#ffffff",
|
|
4463
4560
|
alpha: e.fill?.opacity ?? 1
|
|
4464
4561
|
}, n.fill(), e.stroke) {
|
|
4465
|
-
const r = new
|
|
4562
|
+
const r = new ct({
|
|
4466
4563
|
thickness: e.stroke.width,
|
|
4467
4564
|
color: e.stroke.color
|
|
4468
4565
|
});
|
|
@@ -4490,7 +4587,7 @@ class ds extends z {
|
|
|
4490
4587
|
return 1;
|
|
4491
4588
|
}
|
|
4492
4589
|
}
|
|
4493
|
-
class
|
|
4590
|
+
class ps extends I {
|
|
4494
4591
|
background;
|
|
4495
4592
|
text;
|
|
4496
4593
|
constructor(e, t) {
|
|
@@ -4498,12 +4595,12 @@ class fs extends z {
|
|
|
4498
4595
|
}
|
|
4499
4596
|
async load() {
|
|
4500
4597
|
await super.load();
|
|
4501
|
-
const e = this.clipConfiguration.asset, t = new
|
|
4598
|
+
const e = this.clipConfiguration.asset, t = new v.Graphics();
|
|
4502
4599
|
e.background && (t.fillStyle = {
|
|
4503
4600
|
color: e.background.color,
|
|
4504
4601
|
alpha: e.background.opacity
|
|
4505
4602
|
}, t.rect(0, 0, e.width ?? this.edit.size.width, e.height ?? this.edit.size.height), t.fill());
|
|
4506
|
-
const i = new
|
|
4603
|
+
const i = new v.Text();
|
|
4507
4604
|
i.text = e.text;
|
|
4508
4605
|
const s = e.alignment?.horizontal ?? "center", n = e.alignment?.vertical ?? "center";
|
|
4509
4606
|
i.style = {
|
|
@@ -4521,7 +4618,7 @@ class fs extends z {
|
|
|
4521
4618
|
x: r,
|
|
4522
4619
|
y: o
|
|
4523
4620
|
}, e.stroke) {
|
|
4524
|
-
const h = new
|
|
4621
|
+
const h = new ct({
|
|
4525
4622
|
thickness: e.stroke.width,
|
|
4526
4623
|
color: e.stroke.color
|
|
4527
4624
|
});
|
|
@@ -4549,7 +4646,7 @@ class fs extends z {
|
|
|
4549
4646
|
return 1;
|
|
4550
4647
|
}
|
|
4551
4648
|
}
|
|
4552
|
-
class
|
|
4649
|
+
class ms extends I {
|
|
4553
4650
|
texture;
|
|
4554
4651
|
sprite;
|
|
4555
4652
|
isPlaying;
|
|
@@ -4569,9 +4666,9 @@ class ps extends z {
|
|
|
4569
4666
|
if (t.endsWith(".mov") || t.endsWith(".webm"))
|
|
4570
4667
|
throw new Error(`Video source '${e.src}' is not supported. .mov and .webm files are currently not supported.`);
|
|
4571
4668
|
const i = { src: t, data: { autoPlay: !1, muted: !1 } }, s = await this.edit.assetLoader.load(t, i);
|
|
4572
|
-
if (!(s?.source instanceof
|
|
4669
|
+
if (!(s?.source instanceof v.VideoSource))
|
|
4573
4670
|
throw new Error(`Invalid video source '${e.src}'.`);
|
|
4574
|
-
this.texture = this.createCroppedTexture(s), this.sprite = new
|
|
4671
|
+
this.texture = this.createCroppedTexture(s), this.sprite = new v.Sprite(this.texture), this.getContainer().addChild(this.sprite), this.configureKeyframes();
|
|
4575
4672
|
}
|
|
4576
4673
|
update(e, t) {
|
|
4577
4674
|
super.update(e, t);
|
|
@@ -4599,11 +4696,11 @@ class ps extends z {
|
|
|
4599
4696
|
const t = this.clipConfiguration.asset;
|
|
4600
4697
|
if (!t.crop)
|
|
4601
4698
|
return e;
|
|
4602
|
-
const i = e.width, s = e.height, n = Math.floor((t.crop?.left ?? 0) * i), r = Math.floor((t.crop?.right ?? 0) * i), o = Math.floor((t.crop?.top ?? 0) * s), h = Math.floor((t.crop?.bottom ?? 0) * s), c = n, l = o,
|
|
4603
|
-
return new
|
|
4699
|
+
const i = e.width, s = e.height, n = Math.floor((t.crop?.left ?? 0) * i), r = Math.floor((t.crop?.right ?? 0) * i), o = Math.floor((t.crop?.top ?? 0) * s), h = Math.floor((t.crop?.bottom ?? 0) * s), c = n, l = o, m = i - n - r, p = s - o - h, k = new v.Rectangle(c, l, m, p);
|
|
4700
|
+
return new v.Texture({ source: e.source, frame: k });
|
|
4604
4701
|
}
|
|
4605
4702
|
}
|
|
4606
|
-
class le extends
|
|
4703
|
+
class le extends ot {
|
|
4607
4704
|
static ZIndexPadding = 100;
|
|
4608
4705
|
assetLoader;
|
|
4609
4706
|
events;
|
|
@@ -4624,10 +4721,10 @@ class le extends rt {
|
|
|
4624
4721
|
/** @internal */
|
|
4625
4722
|
updatedClip;
|
|
4626
4723
|
constructor(e, t = "#ffffff") {
|
|
4627
|
-
super(), this.assetLoader = new
|
|
4724
|
+
super(), this.assetLoader = new Te(), this.edit = null, this.tracks = [], this.clipsToDispose = [], this.clips = [], this.events = new It(), this.size = e, this.playbackTime = 0, this.totalDuration = 0, this.isPlaying = !1, this.selectedClip = null, this.updatedClip = null, this.backgroundColor = t;
|
|
4628
4725
|
}
|
|
4629
4726
|
async load() {
|
|
4630
|
-
const e = new
|
|
4727
|
+
const e = new v.Graphics();
|
|
4631
4728
|
e.fillStyle = {
|
|
4632
4729
|
color: this.backgroundColor
|
|
4633
4730
|
}, e.rect(0, 0, this.size.width, this.size.height), e.fill(), this.getContainer().addChild(e);
|
|
@@ -4660,9 +4757,9 @@ class le extends rt {
|
|
|
4660
4757
|
this.seek(0);
|
|
4661
4758
|
}
|
|
4662
4759
|
async loadEdit(e) {
|
|
4663
|
-
this.clearClips(), this.edit =
|
|
4760
|
+
this.clearClips(), this.edit = Ji.parse(e), this.backgroundColor = this.edit.timeline.background || "#000000", await Promise.all(
|
|
4664
4761
|
(this.edit.timeline.fonts ?? []).map(async (t) => {
|
|
4665
|
-
const i = t.src, s = { src: i, loadParser:
|
|
4762
|
+
const i = t.src, s = { src: i, loadParser: Ve.Name };
|
|
4666
4763
|
return this.assetLoader.load(i, s);
|
|
4667
4764
|
})
|
|
4668
4765
|
);
|
|
@@ -4690,7 +4787,7 @@ class le extends rt {
|
|
|
4690
4787
|
};
|
|
4691
4788
|
}
|
|
4692
4789
|
addClip(e, t) {
|
|
4693
|
-
const i =
|
|
4790
|
+
const i = Nt.parse(t), s = this.createPlayerFromAssetType(i);
|
|
4694
4791
|
s.layer = e + 1, this.addPlayer(e, s), this.updateTotalDuration();
|
|
4695
4792
|
}
|
|
4696
4793
|
getClip(e, t) {
|
|
@@ -4715,7 +4812,7 @@ class le extends rt {
|
|
|
4715
4812
|
i.forEach(({ clip: s }) => {
|
|
4716
4813
|
const n = 1e5 - s.layer * le.ZIndexPadding, r = `shotstack-track-${n}`;
|
|
4717
4814
|
let o = this.getContainer().getChildByLabel(r, !1);
|
|
4718
|
-
o || (o = new
|
|
4815
|
+
o || (o = new v.Container({
|
|
4719
4816
|
label: r,
|
|
4720
4817
|
zIndex: n
|
|
4721
4818
|
}), this.getContainer().addChild(o)), o.addChild(s.getContainer());
|
|
@@ -4742,7 +4839,7 @@ class le extends rt {
|
|
|
4742
4839
|
i.forEach(({ clip: s }) => {
|
|
4743
4840
|
const n = 1e5 - s.layer * le.ZIndexPadding, r = `shotstack-track-${n}`;
|
|
4744
4841
|
let o = this.getContainer().getChildByLabel(r, !1);
|
|
4745
|
-
o || (o = new
|
|
4842
|
+
o || (o = new v.Container({
|
|
4746
4843
|
label: r,
|
|
4747
4844
|
zIndex: n
|
|
4748
4845
|
}), this.getContainer().addChild(o)), o.addChild(s.getContainer());
|
|
@@ -4799,7 +4896,7 @@ class le extends rt {
|
|
|
4799
4896
|
this.getContainer().removeChildAt(t);
|
|
4800
4897
|
} else
|
|
4801
4898
|
for (const t of this.getContainer().children)
|
|
4802
|
-
if (t instanceof
|
|
4899
|
+
if (t instanceof v.Container && t.label?.toString().startsWith("shotstack-track-") && t.children.includes(e.getContainer())) {
|
|
4803
4900
|
t.removeChild(e.getContainer());
|
|
4804
4901
|
break;
|
|
4805
4902
|
}
|
|
@@ -4812,7 +4909,7 @@ class le extends rt {
|
|
|
4812
4909
|
const { asset: t } = e.clipConfiguration;
|
|
4813
4910
|
if (t && "src" in t && typeof t.src == "string")
|
|
4814
4911
|
try {
|
|
4815
|
-
|
|
4912
|
+
v.Assets.unload(t.src);
|
|
4816
4913
|
} catch (i) {
|
|
4817
4914
|
console.warn(`Failed to unload asset: ${t.src}`, i);
|
|
4818
4915
|
}
|
|
@@ -4835,27 +4932,31 @@ class le extends rt {
|
|
|
4835
4932
|
let t;
|
|
4836
4933
|
switch (e.asset.type) {
|
|
4837
4934
|
case "text": {
|
|
4838
|
-
t = new
|
|
4935
|
+
t = new ps(this, e);
|
|
4839
4936
|
break;
|
|
4840
4937
|
}
|
|
4841
4938
|
case "shape": {
|
|
4842
|
-
t = new
|
|
4939
|
+
t = new fs(this, e);
|
|
4843
4940
|
break;
|
|
4844
4941
|
}
|
|
4845
4942
|
case "html": {
|
|
4846
|
-
t = new
|
|
4943
|
+
t = new us(this, e);
|
|
4847
4944
|
break;
|
|
4848
4945
|
}
|
|
4849
4946
|
case "image": {
|
|
4850
|
-
t = new
|
|
4947
|
+
t = new ds(this, e);
|
|
4851
4948
|
break;
|
|
4852
4949
|
}
|
|
4853
4950
|
case "video": {
|
|
4854
|
-
t = new
|
|
4951
|
+
t = new ms(this, e);
|
|
4855
4952
|
break;
|
|
4856
4953
|
}
|
|
4857
4954
|
case "audio": {
|
|
4858
|
-
t = new
|
|
4955
|
+
t = new nt(this, e);
|
|
4956
|
+
break;
|
|
4957
|
+
}
|
|
4958
|
+
case "luma": {
|
|
4959
|
+
t = new Pt(this, e);
|
|
4859
4960
|
break;
|
|
4860
4961
|
}
|
|
4861
4962
|
default:
|
|
@@ -4869,10 +4970,12 @@ class le extends rt {
|
|
|
4869
4970
|
this.tracks[e].push(t), this.clips.push(t);
|
|
4870
4971
|
const i = 1e5 - (e + 1) * le.ZIndexPadding, s = `shotstack-track-${i}`;
|
|
4871
4972
|
let n = this.getContainer().getChildByLabel(s, !1);
|
|
4872
|
-
n || (n = new
|
|
4973
|
+
n || (n = new v.Container({ label: s, zIndex: i }), this.getContainer().addChild(n)), n.addChild(t.getContainer());
|
|
4974
|
+
const r = t instanceof Pt;
|
|
4975
|
+
await t.load(), r && n.setMask({ mask: t.getMask(), inverse: !0 }), this.updateTotalDuration();
|
|
4873
4976
|
}
|
|
4874
4977
|
}
|
|
4875
|
-
class _e extends
|
|
4978
|
+
class _e extends ot {
|
|
4876
4979
|
static Width = 250;
|
|
4877
4980
|
static Height = 100;
|
|
4878
4981
|
fps;
|
|
@@ -4885,9 +4988,9 @@ class _e extends rt {
|
|
|
4885
4988
|
super(), this.background = null, this.text = null, this.fps = 0, this.playbackTime = 0, this.playbackDuration = 0, this.isPlaying = !1;
|
|
4886
4989
|
}
|
|
4887
4990
|
async load() {
|
|
4888
|
-
const e = new
|
|
4991
|
+
const e = new v.Graphics();
|
|
4889
4992
|
e.fillStyle = { color: "#424242", alpha: 0.5 }, e.rect(0, 0, _e.Width, _e.Height), e.fill(), this.getContainer().addChild(e), this.background = e;
|
|
4890
|
-
const t = new
|
|
4993
|
+
const t = new v.Text();
|
|
4891
4994
|
t.text = "", t.style = {
|
|
4892
4995
|
fontFamily: "monospace",
|
|
4893
4996
|
fontSize: 14,
|
|
@@ -4938,13 +5041,13 @@ class he {
|
|
|
4938
5041
|
maxZoom = 4;
|
|
4939
5042
|
currentZoom = 0.8;
|
|
4940
5043
|
constructor(e, t) {
|
|
4941
|
-
this.size = e, this.application = new
|
|
5044
|
+
this.size = e, this.application = new v.Application(), this.edit = t, this.inspector = new _e();
|
|
4942
5045
|
}
|
|
4943
5046
|
async load() {
|
|
4944
5047
|
const e = document.querySelector(he.CanvasSelector);
|
|
4945
5048
|
if (!e)
|
|
4946
5049
|
throw new Error(`Shotstack canvas root element '${he.CanvasSelector}' not found.`);
|
|
4947
|
-
this.registerExtensions(), this.container = new
|
|
5050
|
+
this.registerExtensions(), this.container = new v.Container(), this.background = new v.Graphics(), this.background.fillStyle = { color: "#424242" }, this.background.rect(0, 0, this.size.width, this.size.height), this.background.fill(), await this.configureApplication(), this.configureStage(), this.setupTouchHandling(e), this.edit.getContainer().scale = this.currentZoom, e.appendChild(this.application.canvas);
|
|
4948
5051
|
}
|
|
4949
5052
|
setupTouchHandling(e) {
|
|
4950
5053
|
const t = this.edit.getContainer();
|
|
@@ -4993,7 +5096,7 @@ class he {
|
|
|
4993
5096
|
t.scale.x = this.currentZoom, t.scale.y = this.currentZoom;
|
|
4994
5097
|
}
|
|
4995
5098
|
registerExtensions() {
|
|
4996
|
-
he.extensionsRegistered || (
|
|
5099
|
+
he.extensionsRegistered || (v.extensions.add(new He()), v.extensions.add(new Ve()), he.extensionsRegistered = !0);
|
|
4997
5100
|
}
|
|
4998
5101
|
async configureApplication() {
|
|
4999
5102
|
const e = {
|
|
@@ -5010,7 +5113,7 @@ class he {
|
|
|
5010
5113
|
configureStage() {
|
|
5011
5114
|
if (!this.container || !this.background)
|
|
5012
5115
|
throw new Error("Shotstack canvas container not set up.");
|
|
5013
|
-
this.container.addChild(this.background), this.container.addChild(this.edit.getContainer()), this.container.addChild(this.inspector.getContainer()), this.application.stage.addChild(this.container), this.application.stage.eventMode = "static", this.application.stage.hitArea = new
|
|
5116
|
+
this.container.addChild(this.background), this.container.addChild(this.edit.getContainer()), this.container.addChild(this.inspector.getContainer()), this.application.stage.addChild(this.container), this.application.stage.eventMode = "static", this.application.stage.hitArea = new v.Rectangle(0, 0, this.size.width, this.size.height), this.application.stage.on("click", this.onClick.bind(this)), this.edit.getContainer().position = {
|
|
5014
5117
|
x: this.application.canvas.width / 2 - this.edit.size.width * this.currentZoom / 2,
|
|
5015
5118
|
y: this.application.canvas.height / 2 - this.edit.size.height * this.currentZoom / 2
|
|
5016
5119
|
};
|
|
@@ -5018,13 +5121,12 @@ class he {
|
|
|
5018
5121
|
onClick() {
|
|
5019
5122
|
this.edit.pause();
|
|
5020
5123
|
}
|
|
5021
|
-
/** @internal */
|
|
5022
5124
|
dispose() {
|
|
5023
5125
|
const e = document.querySelector(he.CanvasSelector);
|
|
5024
5126
|
e && e.contains(this.application.canvas) && e.removeChild(this.application.canvas), this.application.ticker.remove(this.onTick, this), this.application.stage.off("click", this.onClick, this), this.background?.destroy(), this.container?.destroy(), this.inspector.dispose(), this.application.destroy(!0, { children: !0, texture: !0 });
|
|
5025
5127
|
}
|
|
5026
5128
|
}
|
|
5027
|
-
class
|
|
5129
|
+
class vs {
|
|
5028
5130
|
edit;
|
|
5029
5131
|
seekDistance = 50;
|
|
5030
5132
|
seekDistanceLarge = 500;
|
|
@@ -5095,13 +5197,13 @@ class ys {
|
|
|
5095
5197
|
}
|
|
5096
5198
|
};
|
|
5097
5199
|
}
|
|
5098
|
-
class
|
|
5200
|
+
class xs {
|
|
5099
5201
|
ffmpeg;
|
|
5100
5202
|
isReady = !1;
|
|
5101
5203
|
edit;
|
|
5102
5204
|
application;
|
|
5103
5205
|
constructor(e, t) {
|
|
5104
|
-
this.edit = e, this.application = t.application, this.ffmpeg = new
|
|
5206
|
+
this.edit = e, this.application = t.application, this.ffmpeg = new Wt();
|
|
5105
5207
|
}
|
|
5106
5208
|
async init() {
|
|
5107
5209
|
if (!this.isReady)
|
|
@@ -5117,23 +5219,23 @@ class vs {
|
|
|
5117
5219
|
this.edit.pause();
|
|
5118
5220
|
const n = this.edit.getContainer(), r = n.visible, { x: o, y: h } = n.position, { x: c, y: l } = n.scale;
|
|
5119
5221
|
n.visible = !1;
|
|
5120
|
-
const
|
|
5222
|
+
const m = this.createProgressOverlay();
|
|
5121
5223
|
try {
|
|
5122
5224
|
const p = this.edit.getSize ? this.edit.getSize() : { width: 1920, height: 1080 }, k = Math.ceil(this.edit.totalDuration * t / 1e3), A = 1e3 / t, S = 100, N = 50, J = 50, re = (T) => Math.round(T / k * N);
|
|
5123
|
-
this.updateProgressOverlay(
|
|
5124
|
-
const
|
|
5125
|
-
|
|
5126
|
-
const oe =
|
|
5225
|
+
this.updateProgressOverlay(m, 0, S);
|
|
5226
|
+
const K = document.createElement("canvas");
|
|
5227
|
+
K.width = p.width, K.height = p.height;
|
|
5228
|
+
const oe = K.getContext("2d");
|
|
5127
5229
|
if (!oe)
|
|
5128
5230
|
throw new Error("Could not get 2D context for canvas");
|
|
5129
|
-
const
|
|
5130
|
-
this.updateProgressOverlay(
|
|
5131
|
-
const
|
|
5132
|
-
if (
|
|
5133
|
-
this.updateProgressOverlay(
|
|
5134
|
-
for (let T = 0; T <
|
|
5135
|
-
const D = await this.processAudioTrack(
|
|
5136
|
-
D &&
|
|
5231
|
+
const $e = this.findAudioPlayers();
|
|
5232
|
+
this.updateProgressOverlay(m, 2, S);
|
|
5233
|
+
const H = [];
|
|
5234
|
+
if ($e.length > 0) {
|
|
5235
|
+
this.updateProgressOverlay(m, 3, S);
|
|
5236
|
+
for (let T = 0; T < $e.length; T += 1) {
|
|
5237
|
+
const D = await this.processAudioTrack($e[T], T);
|
|
5238
|
+
D && H.push(D), this.updateProgressOverlay(m, 4 + T, S);
|
|
5137
5239
|
}
|
|
5138
5240
|
}
|
|
5139
5241
|
n.position.x = 0, n.position.y = 0, n.scale.x = 1, n.scale.y = 1;
|
|
@@ -5141,26 +5243,26 @@ class vs {
|
|
|
5141
5243
|
this.edit.seek(T * A), this.edit.tick ? this.edit.tick(0, 0) : (this.edit.update?.(0, 0), this.edit.draw?.());
|
|
5142
5244
|
try {
|
|
5143
5245
|
const { extract: D } = this.application.renderer, E = D.canvas(n);
|
|
5144
|
-
oe.clearRect(0, 0,
|
|
5145
|
-
const
|
|
5146
|
-
await this.ffmpeg.writeFile(
|
|
5246
|
+
oe.clearRect(0, 0, K.width, K.height), oe.drawImage(E, 0, 0);
|
|
5247
|
+
const B = K.toDataURL("image/png"), Se = await (await fetch(B)).arrayBuffer(), Vt = `frame_${T.toString().padStart(6, "0")}.png`;
|
|
5248
|
+
await this.ffmpeg.writeFile(Vt, new Uint8Array(Se));
|
|
5147
5249
|
} catch (D) {
|
|
5148
5250
|
console.error(`Error capturing frame ${T}:`, D);
|
|
5149
5251
|
}
|
|
5150
|
-
this.updateProgressOverlay(
|
|
5252
|
+
this.updateProgressOverlay(m, re(T + 1), S);
|
|
5151
5253
|
}
|
|
5152
|
-
this.updateProgressOverlay(
|
|
5153
|
-
let
|
|
5154
|
-
for (const T of
|
|
5155
|
-
|
|
5156
|
-
if (
|
|
5254
|
+
this.updateProgressOverlay(m, N, S);
|
|
5255
|
+
let Y = ["-framerate", t.toString(), "-i", "frame_%06d.png"];
|
|
5256
|
+
for (const T of H)
|
|
5257
|
+
Y = Y.concat(["-i", T.filename]);
|
|
5258
|
+
if (Y = Y.concat(["-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "23"]), H.length > 0) {
|
|
5157
5259
|
let T = "";
|
|
5158
|
-
for (let E = 0; E <
|
|
5159
|
-
const
|
|
5160
|
-
T += `[${
|
|
5260
|
+
for (let E = 0; E < H.length; E += 1) {
|
|
5261
|
+
const B = H[E], dt = E + 1, Se = Math.max(0, B.start);
|
|
5262
|
+
T += `[${dt}:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,apad,afade=t=in:st=0:d=0.05,atrim=start=0:end=${B.duration / 1e3 + 0.1},adelay=${Se}|${Se},volume=${B.volume}[a${E}];`;
|
|
5161
5263
|
}
|
|
5162
|
-
const D =
|
|
5163
|
-
T += D,
|
|
5264
|
+
const D = H.length > 1 ? `${H.map((E, B) => `[a${B}]`).join("")}amix=inputs=${H.length}:duration=longest:dropout_transition=0.5:normalize=0[aout]` : "[a0]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo[aout]";
|
|
5265
|
+
T += D, Y = Y.concat([
|
|
5164
5266
|
"-filter_complex",
|
|
5165
5267
|
T,
|
|
5166
5268
|
"-map",
|
|
@@ -5174,37 +5276,37 @@ class vs {
|
|
|
5174
5276
|
"-shortest"
|
|
5175
5277
|
]);
|
|
5176
5278
|
}
|
|
5177
|
-
const
|
|
5178
|
-
|
|
5179
|
-
let
|
|
5180
|
-
const
|
|
5279
|
+
const je = "output.mp4";
|
|
5280
|
+
Y.push(je);
|
|
5281
|
+
let lt = 0;
|
|
5282
|
+
const ht = ({ message: T }) => {
|
|
5181
5283
|
const D = T.includes("frame=") && T.includes("fps=") ? T.match(/frame=\s*(\d+)/) : null;
|
|
5182
5284
|
if (D?.[1]) {
|
|
5183
5285
|
const E = parseInt(D[1], 10);
|
|
5184
|
-
if (!Number.isNaN(E) && E >
|
|
5185
|
-
const
|
|
5186
|
-
this.updateProgressOverlay(
|
|
5286
|
+
if (!Number.isNaN(E) && E > lt && (lt = E, E <= k)) {
|
|
5287
|
+
const B = Math.round(E / k * J);
|
|
5288
|
+
this.updateProgressOverlay(m, N + B, S);
|
|
5187
5289
|
}
|
|
5188
5290
|
}
|
|
5189
5291
|
};
|
|
5190
|
-
this.ffmpeg.on("log",
|
|
5191
|
-
const
|
|
5192
|
-
|
|
5292
|
+
this.ffmpeg.on("log", ht), await this.ffmpeg.exec(Y), this.ffmpeg.off("log", ht), this.updateProgressOverlay(m, N + J, S);
|
|
5293
|
+
const Ue = await this.ffmpeg.readFile(je), Dt = Ue instanceof Uint8Array ? Ue : new TextEncoder().encode(Ue.toString()), Zt = new Blob([Dt], { type: "video/mp4" }), ut = URL.createObjectURL(Zt), We = document.createElement("a");
|
|
5294
|
+
We.href = ut, We.download = e, We.click(), URL.revokeObjectURL(ut);
|
|
5193
5295
|
for (let T = 0; T < k; T += 1)
|
|
5194
5296
|
try {
|
|
5195
5297
|
await this.ffmpeg.deleteFile(`frame_${T.toString().padStart(6, "0")}.png`);
|
|
5196
5298
|
} catch {
|
|
5197
5299
|
}
|
|
5198
|
-
for (const T of
|
|
5300
|
+
for (const T of H)
|
|
5199
5301
|
try {
|
|
5200
5302
|
await this.ffmpeg.deleteFile(T.filename);
|
|
5201
5303
|
} catch {
|
|
5202
5304
|
}
|
|
5203
|
-
await this.ffmpeg.deleteFile(
|
|
5305
|
+
await this.ffmpeg.deleteFile(je), this.updateProgressOverlay(m, S, S);
|
|
5204
5306
|
} catch (p) {
|
|
5205
5307
|
throw console.error("Error during export:", p), p;
|
|
5206
5308
|
} finally {
|
|
5207
|
-
this.removeProgressOverlay(
|
|
5309
|
+
this.removeProgressOverlay(m), n.position.x = o, n.position.y = h, n.scale.x = c, n.scale.y = l, n.visible = r, this.edit.seek(s), i && this.edit.play();
|
|
5208
5310
|
}
|
|
5209
5311
|
}
|
|
5210
5312
|
findAudioPlayers() {
|
|
@@ -5215,7 +5317,7 @@ class vs {
|
|
|
5215
5317
|
if (Array.isArray(s))
|
|
5216
5318
|
for (let n = 0; n < s.length; n += 1) {
|
|
5217
5319
|
const r = s[n];
|
|
5218
|
-
(r instanceof
|
|
5320
|
+
(r instanceof nt || r.constructor.name === "AudioPlayer" || r.clipConfiguration?.asset?.type === "audio") && (e.includes(r) || e.push(r));
|
|
5219
5321
|
}
|
|
5220
5322
|
}
|
|
5221
5323
|
return this.searchContainerForPlayers(this.edit.getContainer(), e), e;
|
|
@@ -5223,14 +5325,14 @@ class vs {
|
|
|
5223
5325
|
searchContainerForPlayers(e, t) {
|
|
5224
5326
|
if (e) {
|
|
5225
5327
|
for (const i of e.children)
|
|
5226
|
-
if (i instanceof
|
|
5328
|
+
if (i instanceof v.Container) {
|
|
5227
5329
|
if (i.label?.startsWith("shotstack-track-")) {
|
|
5228
5330
|
for (const n of i.children)
|
|
5229
|
-
if (n instanceof
|
|
5331
|
+
if (n instanceof v.Container) {
|
|
5230
5332
|
const r = n, o = ["player", "clip", "audioPlayer", "entity"];
|
|
5231
5333
|
for (const h of o) {
|
|
5232
5334
|
const c = r[h];
|
|
5233
|
-
c instanceof
|
|
5335
|
+
c instanceof nt && !t.includes(c) && t.push(c);
|
|
5234
5336
|
}
|
|
5235
5337
|
}
|
|
5236
5338
|
}
|
|
@@ -5317,7 +5419,7 @@ class vs {
|
|
|
5317
5419
|
}
|
|
5318
5420
|
export {
|
|
5319
5421
|
he as Canvas,
|
|
5320
|
-
|
|
5422
|
+
vs as Controls,
|
|
5321
5423
|
le as Edit,
|
|
5322
|
-
|
|
5424
|
+
xs as VideoExporter
|
|
5323
5425
|
};
|