@shotstack/shotstack-studio 1.2.0 → 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 +4 -4
- package/dist/core/schemas/clip.d.ts +8 -8
- package/dist/core/schemas/edit.d.ts +45 -45
- package/dist/core/schemas/html-asset.d.ts +2 -2
- package/dist/core/schemas/track.d.ts +12 -12
- package/dist/shotstack-studio.es.js +561 -500
- package/dist/shotstack-studio.umd.js +3 -3
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Filter as Kt, deprecation as Ht, GpuProgram as Bt, GlProgram 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 Pt {
|
|
|
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 Yt {
|
|
|
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",
|
|
@@ -259,7 +320,7 @@ class F extends Error {
|
|
|
259
320
|
}
|
|
260
321
|
}
|
|
261
322
|
F.create = (a) => new F(a);
|
|
262
|
-
const
|
|
323
|
+
const ke = (a, e) => {
|
|
263
324
|
let t;
|
|
264
325
|
switch (a.code) {
|
|
265
326
|
case u.invalid_type:
|
|
@@ -315,11 +376,11 @@ const _e = (a, e) => {
|
|
|
315
376
|
}
|
|
316
377
|
return { message: t };
|
|
317
378
|
};
|
|
318
|
-
let
|
|
379
|
+
let Yt = ke;
|
|
319
380
|
function Ye() {
|
|
320
|
-
return
|
|
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,
|
|
@@ -352,13 +413,13 @@ function d(a, e) {
|
|
|
352
413
|
// then schema-bound map if available
|
|
353
414
|
t,
|
|
354
415
|
// then global override map
|
|
355
|
-
t ===
|
|
416
|
+
t === ke ? void 0 : ke
|
|
356
417
|
// then global default map
|
|
357
418
|
].filter((s) => !!s)
|
|
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
|
}
|
|
@@ -386,7 +447,7 @@ 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 = {};
|
|
@@ -401,8 +462,8 @@ class I {
|
|
|
401
462
|
}
|
|
402
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
|
}
|
|
@@ -410,12 +471,12 @@ 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)
|
|
@@ -438,7 +499,7 @@ const gt = (a, e) => {
|
|
|
438
499
|
}
|
|
439
500
|
};
|
|
440
501
|
};
|
|
441
|
-
function
|
|
502
|
+
function _(a) {
|
|
442
503
|
if (!a)
|
|
443
504
|
return {};
|
|
444
505
|
const { errorMap: e, invalid_type_error: t, required_error: i, description: s } = a;
|
|
@@ -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
|
|
622
|
-
...
|
|
682
|
+
return new X({
|
|
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
|
|
631
|
-
...
|
|
691
|
+
return new Ne({
|
|
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
|
|
647
|
-
...
|
|
707
|
+
return new De({
|
|
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;
|
|
@@ -671,17 +732,17 @@ class b {
|
|
|
671
732
|
}
|
|
672
733
|
}
|
|
673
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})+$";
|
|
674
|
-
let
|
|
735
|
+
let Xe;
|
|
675
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}$`);
|
|
676
|
-
function
|
|
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
741
|
function di(a) {
|
|
681
|
-
return new RegExp(`^${
|
|
742
|
+
return new RegExp(`^${Lt(a)}$`);
|
|
682
743
|
}
|
|
683
744
|
function fi(a) {
|
|
684
|
-
let e = `${zt}T${
|
|
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
|
}
|
|
@@ -711,7 +772,7 @@ class j extends b {
|
|
|
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")
|
|
@@ -756,7 +817,7 @@ class j extends b {
|
|
|
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
|
|
@@ -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,9 +1144,9 @@ 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
1152
|
function yi(a, e) {
|
|
@@ -1106,7 +1167,7 @@ class pe extends b {
|
|
|
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,
|
|
@@ -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,9 +1321,9 @@ 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
|
});
|
|
1267
1328
|
class me extends b {
|
|
1268
1329
|
constructor() {
|
|
@@ -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,
|
|
@@ -1308,16 +1369,16 @@ class me extends b {
|
|
|
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);
|
|
@@ -1413,10 +1474,10 @@ class qe extends b {
|
|
|
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
|
});
|
|
1421
1482
|
class be extends b {
|
|
1422
1483
|
_parse(e) {
|
|
@@ -1434,7 +1495,7 @@ class be extends b {
|
|
|
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:
|
|
1497
|
-
...
|
|
1557
|
+
typeName: x.ZodDate,
|
|
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);
|
|
@@ -1509,11 +1570,11 @@ class Ge extends b {
|
|
|
1509
1570
|
return M(e.data);
|
|
1510
1571
|
}
|
|
1511
1572
|
}
|
|
1512
|
-
|
|
1513
|
-
typeName:
|
|
1514
|
-
...
|
|
1573
|
+
Qe.create = (a) => new Qe({
|
|
1574
|
+
typeName: x.ZodSymbol,
|
|
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);
|
|
@@ -1526,11 +1587,11 @@ class Ae extends b {
|
|
|
1526
1587
|
return M(e.data);
|
|
1527
1588
|
}
|
|
1528
1589
|
}
|
|
1529
|
-
|
|
1530
|
-
typeName:
|
|
1531
|
-
...
|
|
1590
|
+
Pe.create = (a) => new Pe({
|
|
1591
|
+
typeName: x.ZodUndefined,
|
|
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);
|
|
@@ -1543,11 +1604,11 @@ class Pe extends b {
|
|
|
1543
1604
|
return M(e.data);
|
|
1544
1605
|
}
|
|
1545
1606
|
}
|
|
1546
|
-
|
|
1547
|
-
typeName:
|
|
1548
|
-
...
|
|
1607
|
+
Ie.create = (a) => new Ie({
|
|
1608
|
+
typeName: x.ZodNull,
|
|
1609
|
+
..._(a)
|
|
1549
1610
|
});
|
|
1550
|
-
class
|
|
1611
|
+
class Je extends b {
|
|
1551
1612
|
constructor() {
|
|
1552
1613
|
super(...arguments), this._any = !0;
|
|
1553
1614
|
}
|
|
@@ -1555,9 +1616,9 @@ class Qe extends b {
|
|
|
1555
1616
|
return M(e.data);
|
|
1556
1617
|
}
|
|
1557
1618
|
}
|
|
1558
|
-
|
|
1559
|
-
typeName:
|
|
1560
|
-
...
|
|
1619
|
+
Je.create = (a) => new Je({
|
|
1620
|
+
typeName: x.ZodAny,
|
|
1621
|
+
..._(a)
|
|
1561
1622
|
});
|
|
1562
1623
|
class ue extends b {
|
|
1563
1624
|
constructor() {
|
|
@@ -1568,8 +1629,8 @@ class ue extends b {
|
|
|
1568
1629
|
}
|
|
1569
1630
|
}
|
|
1570
1631
|
ue.create = (a) => new ue({
|
|
1571
|
-
typeName:
|
|
1572
|
-
...
|
|
1632
|
+
typeName: x.ZodUnknown,
|
|
1633
|
+
..._(a)
|
|
1573
1634
|
});
|
|
1574
1635
|
class G extends b {
|
|
1575
1636
|
_parse(e) {
|
|
@@ -1582,10 +1643,10 @@ class G extends b {
|
|
|
1582
1643
|
}
|
|
1583
1644
|
}
|
|
1584
1645
|
G.create = (a) => new G({
|
|
1585
|
-
typeName:
|
|
1586
|
-
...
|
|
1646
|
+
typeName: x.ZodNever,
|
|
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);
|
|
@@ -1598,9 +1659,9 @@ class Je extends b {
|
|
|
1598
1659
|
return M(e.data);
|
|
1599
1660
|
}
|
|
1600
1661
|
}
|
|
1601
|
-
|
|
1602
|
-
typeName:
|
|
1603
|
-
...
|
|
1662
|
+
et.create = (a) => new et({
|
|
1663
|
+
typeName: x.ZodVoid,
|
|
1664
|
+
..._(a)
|
|
1604
1665
|
});
|
|
1605
1666
|
class Z extends b {
|
|
1606
1667
|
_parse(e) {
|
|
@@ -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,8 +1733,8 @@ Z.create = (a, e) => new Z({
|
|
|
1672
1733
|
minLength: null,
|
|
1673
1734
|
maxLength: null,
|
|
1674
1735
|
exactLength: null,
|
|
1675
|
-
typeName:
|
|
1676
|
-
...
|
|
1736
|
+
typeName: x.ZodArray,
|
|
1737
|
+
..._(e)
|
|
1677
1738
|
});
|
|
1678
1739
|
function ce(a) {
|
|
1679
1740
|
if (a instanceof P) {
|
|
@@ -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,29 +2015,29 @@ 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:
|
|
1965
|
-
...
|
|
2025
|
+
typeName: x.ZodObject,
|
|
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:
|
|
1972
|
-
...
|
|
2032
|
+
typeName: x.ZodObject,
|
|
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:
|
|
1979
|
-
...
|
|
2039
|
+
typeName: x.ZodObject,
|
|
2040
|
+
..._(e)
|
|
1980
2041
|
});
|
|
1981
2042
|
class Re extends b {
|
|
1982
2043
|
_parse(e) {
|
|
@@ -2048,11 +2109,11 @@ class Re extends b {
|
|
|
2048
2109
|
}
|
|
2049
2110
|
Re.create = (a, e) => new Re({
|
|
2050
2111
|
options: a,
|
|
2051
|
-
typeName:
|
|
2052
|
-
...
|
|
2112
|
+
typeName: x.ZodUnion,
|
|
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)
|
|
@@ -2105,23 +2166,23 @@ 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,
|
|
2113
|
-
...
|
|
2174
|
+
..._(i)
|
|
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,10 +2204,10 @@ 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 (
|
|
2207
|
+
if (mt(n) || mt(r))
|
|
2147
2208
|
return w;
|
|
2148
|
-
const o =
|
|
2149
|
-
return o.valid ? ((
|
|
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
|
};
|
|
@@ -2175,8 +2236,8 @@ class ze extends b {
|
|
|
2175
2236
|
ze.create = (a, e, t) => new ze({
|
|
2176
2237
|
left: a,
|
|
2177
2238
|
right: e,
|
|
2178
|
-
typeName:
|
|
2179
|
-
...
|
|
2239
|
+
typeName: x.ZodIntersection,
|
|
2240
|
+
..._(t)
|
|
2180
2241
|
});
|
|
2181
2242
|
class W extends b {
|
|
2182
2243
|
_parse(e) {
|
|
@@ -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
|
}
|
|
@@ -2246,30 +2307,30 @@ class Ie extends b {
|
|
|
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:
|
|
2263
|
-
...
|
|
2264
|
-
}) : new
|
|
2323
|
+
typeName: x.ZodRecord,
|
|
2324
|
+
..._(i)
|
|
2325
|
+
}) : new Le({
|
|
2265
2326
|
keyType: j.create(),
|
|
2266
2327
|
valueType: e,
|
|
2267
|
-
typeName:
|
|
2268
|
-
...
|
|
2328
|
+
typeName: x.ZodRecord,
|
|
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
|
}
|
|
@@ -2285,8 +2346,8 @@ class tt extends b {
|
|
|
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();
|
|
@@ -2311,11 +2372,11 @@ class tt extends b {
|
|
|
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:
|
|
2318
|
-
...
|
|
2378
|
+
typeName: x.ZodMap,
|
|
2379
|
+
..._(t)
|
|
2319
2380
|
});
|
|
2320
2381
|
class ge extends b {
|
|
2321
2382
|
_parse(e) {
|
|
@@ -2352,19 +2413,19 @@ class ge extends b {
|
|
|
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,8 +2439,8 @@ ge.create = (a, e) => new ge({
|
|
|
2378
2439
|
valueType: a,
|
|
2379
2440
|
minSize: null,
|
|
2380
2441
|
maxSize: null,
|
|
2381
|
-
typeName:
|
|
2382
|
-
...
|
|
2442
|
+
typeName: x.ZodSet,
|
|
2443
|
+
..._(e)
|
|
2383
2444
|
});
|
|
2384
2445
|
class we extends b {
|
|
2385
2446
|
constructor() {
|
|
@@ -2394,14 +2455,14 @@ class we extends b {
|
|
|
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: [
|
|
2401
2462
|
t.common.contextualErrorMap,
|
|
2402
2463
|
t.schemaErrorMap,
|
|
2403
2464
|
Ye(),
|
|
2404
|
-
|
|
2465
|
+
ke
|
|
2405
2466
|
].filter((c) => !!c),
|
|
2406
2467
|
issueData: {
|
|
2407
2468
|
code: u.invalid_arguments,
|
|
@@ -2410,14 +2471,14 @@ 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: [
|
|
2417
2478
|
t.common.contextualErrorMap,
|
|
2418
2479
|
t.schemaErrorMap,
|
|
2419
2480
|
Ye(),
|
|
2420
|
-
|
|
2481
|
+
ke
|
|
2421
2482
|
].filter((c) => !!c),
|
|
2422
2483
|
issueData: {
|
|
2423
2484
|
code: u.invalid_return_type,
|
|
@@ -2429,11 +2490,11 @@ class we extends b {
|
|
|
2429
2490
|
if (this._def.returns instanceof Ce) {
|
|
2430
2491
|
const o = this;
|
|
2431
2492
|
return M(async function(...h) {
|
|
2432
|
-
const c = new F([]), l = await o._def.args.parseAsync(h, n).catch((
|
|
2433
|
-
throw c.addIssue(i(h,
|
|
2434
|
-
}),
|
|
2435
|
-
return await o._def.returns._def.type.parseAsync(
|
|
2436
|
-
throw c.addIssue(s(
|
|
2493
|
+
const c = new F([]), l = await o._def.args.parseAsync(h, n).catch((k) => {
|
|
2494
|
+
throw c.addIssue(i(h, k)), c;
|
|
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:
|
|
2481
|
-
...
|
|
2541
|
+
typeName: x.ZodFunction,
|
|
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:
|
|
2497
|
-
...
|
|
2557
|
+
typeName: x.ZodLazy,
|
|
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);
|
|
@@ -2512,16 +2573,16 @@ 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:
|
|
2518
|
-
...
|
|
2578
|
+
typeName: x.ZodLiteral,
|
|
2579
|
+
..._(e)
|
|
2519
2580
|
});
|
|
2520
|
-
function
|
|
2581
|
+
function Et(a, e) {
|
|
2521
2582
|
return new ie({
|
|
2522
2583
|
values: a,
|
|
2523
|
-
typeName:
|
|
2524
|
-
...
|
|
2584
|
+
typeName: x.ZodEnum,
|
|
2585
|
+
..._(e)
|
|
2525
2586
|
});
|
|
2526
2587
|
}
|
|
2527
2588
|
class ie extends b {
|
|
@@ -2537,7 +2598,7 @@ class ie extends b {
|
|
|
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,
|
|
@@ -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
|
}
|
|
@@ -2597,7 +2658,7 @@ class Me extends b {
|
|
|
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,
|
|
@@ -2612,10 +2673,10 @@ 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:
|
|
2618
|
-
...
|
|
2678
|
+
typeName: x.ZodNativeEnum,
|
|
2679
|
+
..._(e)
|
|
2619
2680
|
});
|
|
2620
2681
|
class Ce extends b {
|
|
2621
2682
|
unwrap() {
|
|
@@ -2638,15 +2699,15 @@ class Ce extends b {
|
|
|
2638
2699
|
}
|
|
2639
2700
|
Ce.create = (a, e) => new Ce({
|
|
2640
2701
|
type: a,
|
|
2641
|
-
typeName:
|
|
2642
|
-
...
|
|
2702
|
+
typeName: x.ZodPromise,
|
|
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 = {
|
|
@@ -2718,17 +2779,17 @@ 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:
|
|
2731
|
-
...
|
|
2791
|
+
typeName: x.ZodEffects,
|
|
2792
|
+
..._(t)
|
|
2732
2793
|
});
|
|
2733
2794
|
class U extends b {
|
|
2734
2795
|
_parse(e) {
|
|
@@ -2740,8 +2801,8 @@ class U extends b {
|
|
|
2740
2801
|
}
|
|
2741
2802
|
U.create = (a, e) => new U({
|
|
2742
2803
|
innerType: a,
|
|
2743
|
-
typeName:
|
|
2744
|
-
...
|
|
2804
|
+
typeName: x.ZodOptional,
|
|
2805
|
+
..._(e)
|
|
2745
2806
|
});
|
|
2746
2807
|
class se extends b {
|
|
2747
2808
|
_parse(e) {
|
|
@@ -2753,10 +2814,10 @@ class se extends b {
|
|
|
2753
2814
|
}
|
|
2754
2815
|
se.create = (a, e) => new se({
|
|
2755
2816
|
innerType: a,
|
|
2756
|
-
typeName:
|
|
2757
|
-
...
|
|
2817
|
+
typeName: x.ZodNullable,
|
|
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);
|
|
@@ -2832,11 +2893,11 @@ class it extends b {
|
|
|
2832
2893
|
return { status: "valid", value: e.data };
|
|
2833
2894
|
}
|
|
2834
2895
|
}
|
|
2835
|
-
|
|
2836
|
-
typeName:
|
|
2837
|
-
...
|
|
2896
|
+
st.create = (a) => new st({
|
|
2897
|
+
typeName: x.ZodNaN,
|
|
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({
|
|
@@ -2885,60 +2946,60 @@ 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:
|
|
2904
|
-
...
|
|
2964
|
+
typeName: x.ZodReadonly,
|
|
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
2987
|
const vi = Re.create;
|
|
2927
|
-
|
|
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
3004
|
const xi = Q(["linear", "bezier", "constant"]), wi = Q([
|
|
2944
3005
|
"ease",
|
|
@@ -2976,15 +3037,15 @@ const xi = Q(["linear", "bezier", "constant"]), wi = Q([
|
|
|
2976
3037
|
length: y().positive(),
|
|
2977
3038
|
interpolation: xi.optional(),
|
|
2978
3039
|
easing: wi.optional()
|
|
2979
|
-
}),
|
|
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
|
-
}), bi = Q(["top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", "left", "topLeft", "center"]),
|
|
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(),
|
|
@@ -2996,28 +3057,28 @@ const xi = Q(["linear", "bezier", "constant"]), wi = Q([
|
|
|
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
3062
|
src: Ci,
|
|
3002
3063
|
crop: Si.optional()
|
|
3003
|
-
}), Ti = L().url("Invalid luma url format."),
|
|
3064
|
+
}), Ti = L().url("Invalid luma url format."), _t = O({
|
|
3004
3065
|
type: ne("luma"),
|
|
3005
3066
|
src: Ti
|
|
3006
|
-
}),
|
|
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
|
-
}), _t = 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
3075
|
}), Oi = O({
|
|
3015
|
-
color:
|
|
3076
|
+
color: Ft,
|
|
3016
3077
|
opacity: y().min(0).max(1)
|
|
3017
3078
|
}), Ai = O({
|
|
3018
|
-
color:
|
|
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(),
|
|
@@ -3025,32 +3086,32 @@ const xi = Q(["linear", "bezier", "constant"]), wi = Q([
|
|
|
3025
3086
|
fill: Oi.optional(),
|
|
3026
3087
|
stroke: Ai.optional(),
|
|
3027
3088
|
rectangle: kt.optional(),
|
|
3028
|
-
circle:
|
|
3029
|
-
line:
|
|
3030
|
-
}).refine((a) => a.shape === "rectangle" ? kt.safeParse(a.rectangle) : a.shape === "circle" ?
|
|
3031
|
-
color:
|
|
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
|
-
}),
|
|
3040
|
-
color:
|
|
3100
|
+
}), Ri = O({
|
|
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
3111
|
font: Pi.optional(),
|
|
3051
|
-
alignment:
|
|
3052
|
-
background:
|
|
3053
|
-
stroke:
|
|
3112
|
+
alignment: Ii.optional(),
|
|
3113
|
+
background: Ri.optional(),
|
|
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(),
|
|
@@ -3059,25 +3120,25 @@ const xi = Q(["linear", "bezier", "constant"]), wi = Q([
|
|
|
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
3125
|
src: Li,
|
|
3065
3126
|
trim: y().optional(),
|
|
3066
3127
|
crop: Ei.optional(),
|
|
3067
3128
|
volume: Mi.optional()
|
|
3068
|
-
}), Fi = vi([
|
|
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
|
-
}).array().or(de),
|
|
3135
|
+
}).array().or(de), Ki = O({
|
|
3075
3136
|
x: Zi.default(0),
|
|
3076
|
-
y:
|
|
3077
|
-
}),
|
|
3137
|
+
y: Vi.default(0)
|
|
3138
|
+
}), Hi = ae.extend({
|
|
3078
3139
|
from: y().min(0).max(1),
|
|
3079
3140
|
to: y().min(0).max(1)
|
|
3080
|
-
}).array().or(y().min(0).max(1)),
|
|
3141
|
+
}).array().or(y().min(0).max(1)), Bi = ae.extend({
|
|
3081
3142
|
from: y().min(0),
|
|
3082
3143
|
to: y().min(0)
|
|
3083
3144
|
}).array().or(y().min(0)), $i = O({
|
|
@@ -3085,31 +3146,31 @@ const xi = Q(["linear", "bezier", "constant"]), wi = Q([
|
|
|
3085
3146
|
from: y(),
|
|
3086
3147
|
to: y()
|
|
3087
3148
|
}).array().or(y())
|
|
3088
|
-
}), ji = L(),
|
|
3089
|
-
in:
|
|
3090
|
-
out:
|
|
3149
|
+
}), ji = L(), At = L(), Ui = O({
|
|
3150
|
+
in: At.optional(),
|
|
3151
|
+
out: At.optional()
|
|
3091
3152
|
}), Wi = O({
|
|
3092
3153
|
rotate: $i.default({ angle: 0 })
|
|
3093
|
-
}),
|
|
3154
|
+
}), Nt = O({
|
|
3094
3155
|
asset: Fi,
|
|
3095
3156
|
start: y().min(0),
|
|
3096
3157
|
length: y().positive(),
|
|
3097
3158
|
position: Ni.default("center").optional(),
|
|
3098
3159
|
fit: Di.default("crop").optional(),
|
|
3099
|
-
offset:
|
|
3100
|
-
opacity:
|
|
3101
|
-
scale:
|
|
3160
|
+
offset: Ki.default({ x: 0, y: 0 }).optional(),
|
|
3161
|
+
opacity: Hi.default(1).optional(),
|
|
3162
|
+
scale: Bi.default(1).optional(),
|
|
3102
3163
|
transform: Wi.default({ rotate: { angle: 0 } }).optional(),
|
|
3103
3164
|
effect: ji.optional(),
|
|
3104
3165
|
transition: Ui.optional()
|
|
3105
|
-
}),
|
|
3106
|
-
clips:
|
|
3107
|
-
}),
|
|
3108
|
-
src:
|
|
3166
|
+
}), Xi = O({
|
|
3167
|
+
clips: Nt.array()
|
|
3168
|
+
}), Yi = L().url("Invalid image url format."), qi = O({
|
|
3169
|
+
src: Yi
|
|
3109
3170
|
}), Gi = O({
|
|
3110
3171
|
background: L().optional(),
|
|
3111
3172
|
fonts: qi.array().optional(),
|
|
3112
|
-
tracks:
|
|
3173
|
+
tracks: Xi.array()
|
|
3113
3174
|
}), Qi = O({
|
|
3114
3175
|
size: O({
|
|
3115
3176
|
width: y().positive(),
|
|
@@ -3243,11 +3304,11 @@ class es {
|
|
|
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
|
-
class
|
|
3311
|
+
class R {
|
|
3251
3312
|
property;
|
|
3252
3313
|
length;
|
|
3253
3314
|
cubicBuilder;
|
|
@@ -3312,7 +3373,7 @@ class z {
|
|
|
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
|
}
|
|
@@ -3363,20 +3424,20 @@ class ts {
|
|
|
3363
3424
|
const l = 0;
|
|
3364
3425
|
switch (this.getPresetName()) {
|
|
3365
3426
|
case "zoomIn": {
|
|
3366
|
-
const p = this.getZoomSpeed(),
|
|
3367
|
-
r.push({ from:
|
|
3427
|
+
const p = this.getZoomSpeed(), k = 1 * this.clipConfiguration.scale, A = p * this.clipConfiguration.scale;
|
|
3428
|
+
r.push({ from: k, to: A, start: l, length: c, interpolation: "linear" });
|
|
3368
3429
|
break;
|
|
3369
3430
|
}
|
|
3370
3431
|
case "zoomOut": {
|
|
3371
|
-
const
|
|
3372
|
-
r.push({ from:
|
|
3432
|
+
const k = this.getZoomSpeed() * this.clipConfiguration.scale, A = 1 * this.clipConfiguration.scale;
|
|
3433
|
+
r.push({ from: k, to: A, start: l, length: c, interpolation: "linear" });
|
|
3373
3434
|
break;
|
|
3374
3435
|
}
|
|
3375
3436
|
case "slideLeft": {
|
|
3376
3437
|
let p = this.getSlideStart();
|
|
3377
|
-
const
|
|
3378
|
-
if (A <
|
|
3379
|
-
const S = Math.abs(
|
|
3438
|
+
const k = e.width + e.width * p * 2, A = t.height / t.width * e.height;
|
|
3439
|
+
if (A < k) {
|
|
3440
|
+
const S = Math.abs(k / e.width);
|
|
3380
3441
|
r.push({ from: S, to: S, start: l, length: c, interpolation: "linear" });
|
|
3381
3442
|
} else
|
|
3382
3443
|
p = (A - e.width) / 2 / e.width;
|
|
@@ -3385,9 +3446,9 @@ class ts {
|
|
|
3385
3446
|
}
|
|
3386
3447
|
case "slideRight": {
|
|
3387
3448
|
let p = this.getSlideStart();
|
|
3388
|
-
const
|
|
3389
|
-
if (A <
|
|
3390
|
-
const S = Math.abs(
|
|
3449
|
+
const k = e.width + e.width * p * 2, A = t.height / t.width * e.height;
|
|
3450
|
+
if (A < k) {
|
|
3451
|
+
const S = Math.abs(k / e.width);
|
|
3391
3452
|
r.push({ from: S, to: S, start: l, length: c, interpolation: "linear" });
|
|
3392
3453
|
} else
|
|
3393
3454
|
p = (A - e.width) / 2 / e.width;
|
|
@@ -3396,9 +3457,9 @@ class ts {
|
|
|
3396
3457
|
}
|
|
3397
3458
|
case "slideUp": {
|
|
3398
3459
|
let p = this.getSlideStart();
|
|
3399
|
-
const
|
|
3400
|
-
if (A <
|
|
3401
|
-
const S = Math.abs(
|
|
3460
|
+
const k = e.height + e.height * p * 2, A = t.height / t.width * e.width;
|
|
3461
|
+
if (A < k) {
|
|
3462
|
+
const S = Math.abs(k / e.height);
|
|
3402
3463
|
r.push({ from: S, to: S, start: l, length: c, interpolation: "linear" });
|
|
3403
3464
|
} else
|
|
3404
3465
|
p = (A - e.height) / 2 / e.height;
|
|
@@ -3407,9 +3468,9 @@ class ts {
|
|
|
3407
3468
|
}
|
|
3408
3469
|
case "slideDown": {
|
|
3409
3470
|
let p = this.getSlideStart();
|
|
3410
|
-
const
|
|
3411
|
-
if (A <
|
|
3412
|
-
const S = Math.abs(
|
|
3471
|
+
const k = e.height + e.height * p * 2, A = t.height / t.width * e.width;
|
|
3472
|
+
if (A < k) {
|
|
3473
|
+
const S = Math.abs(k / e.height);
|
|
3413
3474
|
r.push({ from: S, to: S, start: l, length: c, interpolation: "linear" });
|
|
3414
3475
|
} else
|
|
3415
3476
|
p = (A - e.height) / 2 / e.height;
|
|
@@ -3473,8 +3534,8 @@ class is {
|
|
|
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 is {
|
|
|
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": {
|
|
@@ -3714,17 +3775,17 @@ class ns {
|
|
|
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;
|
|
@@ -3763,15 +3824,15 @@ class R extends rt {
|
|
|
3763
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
|
-
if (this.offsetXKeyframeBuilder = new
|
|
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
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
3831
|
const o = new is(this.clipConfiguration).build();
|
|
3771
|
-
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
|
|
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 R 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,7 +3912,7 @@ class R 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
3918
|
if (e.button !== ss.ButtonLeftClick || (this.edit.setSelectedClip(this), this.initialClipConfiguration = structuredClone(this.clipConfiguration), this.clipHasKeyframes()))
|
|
@@ -3878,14 +3939,14 @@ class R 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,14 +3960,14 @@ class R 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
|
-
oe <
|
|
3970
|
+
oe < k && (k = oe, S = n.y + (re.y - J.y));
|
|
3910
3971
|
}
|
|
3911
3972
|
A !== null && (n.x = A), S !== null && (n.y = S);
|
|
3912
3973
|
const N = this.positionBuilder.absoluteToRelative(
|
|
@@ -3914,7 +3975,7 @@ class R extends rt {
|
|
|
3914
3975
|
this.clipConfiguration.position ?? "center",
|
|
3915
3976
|
n
|
|
3916
3977
|
);
|
|
3917
|
-
this.clipConfiguration.offset || (this.clipConfiguration.offset = { x: 0, y: 0 }), this.clipConfiguration.offset.x = N.x, this.clipConfiguration.offset.y = N.y, this.offsetXKeyframeBuilder = new
|
|
3978
|
+
this.clipConfiguration.offset || (this.clipConfiguration.offset = { x: 0, y: 0 }), this.clipConfiguration.offset.x = N.x, this.clipConfiguration.offset.y = N.y, this.offsetXKeyframeBuilder = new R(this.clipConfiguration.offset.x, this.getLength()), this.offsetYKeyframeBuilder = new R(this.clipConfiguration.offset.y, this.getLength());
|
|
3918
3979
|
}
|
|
3919
3980
|
}
|
|
3920
3981
|
onPointerUp() {
|
|
@@ -3943,7 +4004,7 @@ class R 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;
|
|
@@ -3951,12 +4012,12 @@ class st extends R {
|
|
|
3951
4012
|
constructor(e, t) {
|
|
3952
4013
|
super(e, t), this.audioResource = null, this.isPlaying = !1;
|
|
3953
4014
|
const i = t.asset;
|
|
3954
|
-
this.volumeKeyframeBuilder = new
|
|
4015
|
+
this.volumeKeyframeBuilder = new R(i.volume ?? 1, this.getLength()), this.syncTimer = 0;
|
|
3955
4016
|
}
|
|
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
|
}
|
|
@@ -4179,7 +4240,7 @@ const Be = class ee extends Kt {
|
|
|
4179
4240
|
source: cs,
|
|
4180
4241
|
entryPoint: "mainFragment"
|
|
4181
4242
|
}
|
|
4182
|
-
}), n =
|
|
4243
|
+
}), n = $t.from({
|
|
4183
4244
|
vertex: as,
|
|
4184
4245
|
fragment: os.replace(/\$\{ANGLE_STEP\}/, ee.getAngleStep(i).toFixed(7)),
|
|
4185
4246
|
name: "outline-filter"
|
|
@@ -4196,7 +4257,7 @@ const Be = class ee extends Kt {
|
|
|
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 us extends
|
|
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 us extends R {
|
|
|
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 us extends R {
|
|
|
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 us extends R {
|
|
|
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 us extends R {
|
|
|
4390
4451
|
}
|
|
4391
4452
|
}
|
|
4392
4453
|
}
|
|
4393
|
-
class ds extends
|
|
4454
|
+
class ds extends I {
|
|
4394
4455
|
texture;
|
|
4395
4456
|
sprite;
|
|
4396
4457
|
constructor(e, t) {
|
|
@@ -4403,9 +4464,9 @@ class ds extends R {
|
|
|
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,11 @@ class ds extends R {
|
|
|
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 {
|
|
4431
4492
|
texture;
|
|
4432
4493
|
sprite;
|
|
4433
4494
|
isPlaying;
|
|
@@ -4437,12 +4498,12 @@ class At extends R {
|
|
|
4437
4498
|
async load() {
|
|
4438
4499
|
await super.load();
|
|
4439
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);
|
|
4440
|
-
if (!(s?.source instanceof
|
|
4501
|
+
if (!(s?.source instanceof v.ImageSource || s?.source instanceof v.VideoSource))
|
|
4441
4502
|
throw new Error(`Invalid luma source '${e.src}'.`);
|
|
4442
|
-
this.texture = s, this.sprite = new
|
|
4503
|
+
this.texture = s, this.sprite = new v.Sprite(this.texture), this.getContainer().addChild(this.sprite), this.configureKeyframes();
|
|
4443
4504
|
}
|
|
4444
4505
|
update(e, t) {
|
|
4445
|
-
if (super.update(e, t), !this.texture || !(this.texture.source instanceof
|
|
4506
|
+
if (super.update(e, t), !this.texture || !(this.texture.source instanceof v.VideoSource))
|
|
4446
4507
|
return;
|
|
4447
4508
|
const i = this.getPlaybackTime(), s = this.edit.isPlaying && this.isActive();
|
|
4448
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);
|
|
@@ -4463,7 +4524,7 @@ class At extends R {
|
|
|
4463
4524
|
return this.sprite;
|
|
4464
4525
|
}
|
|
4465
4526
|
}
|
|
4466
|
-
class fs extends
|
|
4527
|
+
class fs extends I {
|
|
4467
4528
|
shape;
|
|
4468
4529
|
shapeBackground;
|
|
4469
4530
|
constructor(e, t) {
|
|
@@ -4471,9 +4532,9 @@ class fs extends R {
|
|
|
4471
4532
|
}
|
|
4472
4533
|
async load() {
|
|
4473
4534
|
await super.load();
|
|
4474
|
-
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;
|
|
4475
4536
|
t.fillStyle = { color: "transparent" }, t.rect(0, 0, i, s), t.fill();
|
|
4476
|
-
const n = new
|
|
4537
|
+
const n = new v.Graphics();
|
|
4477
4538
|
switch (e.shape) {
|
|
4478
4539
|
case "rectangle": {
|
|
4479
4540
|
const r = e.rectangle, o = i / 2 - r.width / 2, h = s / 2 - r.height / 2;
|
|
@@ -4498,7 +4559,7 @@ class fs extends R {
|
|
|
4498
4559
|
color: e.fill?.color ?? "#ffffff",
|
|
4499
4560
|
alpha: e.fill?.opacity ?? 1
|
|
4500
4561
|
}, n.fill(), e.stroke) {
|
|
4501
|
-
const r = new
|
|
4562
|
+
const r = new ct({
|
|
4502
4563
|
thickness: e.stroke.width,
|
|
4503
4564
|
color: e.stroke.color
|
|
4504
4565
|
});
|
|
@@ -4526,7 +4587,7 @@ class fs extends R {
|
|
|
4526
4587
|
return 1;
|
|
4527
4588
|
}
|
|
4528
4589
|
}
|
|
4529
|
-
class ps extends
|
|
4590
|
+
class ps extends I {
|
|
4530
4591
|
background;
|
|
4531
4592
|
text;
|
|
4532
4593
|
constructor(e, t) {
|
|
@@ -4534,12 +4595,12 @@ class ps extends R {
|
|
|
4534
4595
|
}
|
|
4535
4596
|
async load() {
|
|
4536
4597
|
await super.load();
|
|
4537
|
-
const e = this.clipConfiguration.asset, t = new
|
|
4598
|
+
const e = this.clipConfiguration.asset, t = new v.Graphics();
|
|
4538
4599
|
e.background && (t.fillStyle = {
|
|
4539
4600
|
color: e.background.color,
|
|
4540
4601
|
alpha: e.background.opacity
|
|
4541
4602
|
}, t.rect(0, 0, e.width ?? this.edit.size.width, e.height ?? this.edit.size.height), t.fill());
|
|
4542
|
-
const i = new
|
|
4603
|
+
const i = new v.Text();
|
|
4543
4604
|
i.text = e.text;
|
|
4544
4605
|
const s = e.alignment?.horizontal ?? "center", n = e.alignment?.vertical ?? "center";
|
|
4545
4606
|
i.style = {
|
|
@@ -4557,7 +4618,7 @@ class ps extends R {
|
|
|
4557
4618
|
x: r,
|
|
4558
4619
|
y: o
|
|
4559
4620
|
}, e.stroke) {
|
|
4560
|
-
const h = new
|
|
4621
|
+
const h = new ct({
|
|
4561
4622
|
thickness: e.stroke.width,
|
|
4562
4623
|
color: e.stroke.color
|
|
4563
4624
|
});
|
|
@@ -4585,7 +4646,7 @@ class ps extends R {
|
|
|
4585
4646
|
return 1;
|
|
4586
4647
|
}
|
|
4587
4648
|
}
|
|
4588
|
-
class ms extends
|
|
4649
|
+
class ms extends I {
|
|
4589
4650
|
texture;
|
|
4590
4651
|
sprite;
|
|
4591
4652
|
isPlaying;
|
|
@@ -4594,7 +4655,7 @@ class ms extends R {
|
|
|
4594
4655
|
constructor(e, t) {
|
|
4595
4656
|
super(e, t), this.texture = null, this.sprite = null, this.isPlaying = !1;
|
|
4596
4657
|
const i = this.clipConfiguration.asset;
|
|
4597
|
-
this.volumeKeyframeBuilder = new
|
|
4658
|
+
this.volumeKeyframeBuilder = new R(i.volume ?? 1, this.getLength()), this.syncTimer = 0;
|
|
4598
4659
|
}
|
|
4599
4660
|
/**
|
|
4600
4661
|
* TODO: Add support for .mov and .webm files
|
|
@@ -4605,9 +4666,9 @@ class ms extends R {
|
|
|
4605
4666
|
if (t.endsWith(".mov") || t.endsWith(".webm"))
|
|
4606
4667
|
throw new Error(`Video source '${e.src}' is not supported. .mov and .webm files are currently not supported.`);
|
|
4607
4668
|
const i = { src: t, data: { autoPlay: !1, muted: !1 } }, s = await this.edit.assetLoader.load(t, i);
|
|
4608
|
-
if (!(s?.source instanceof
|
|
4669
|
+
if (!(s?.source instanceof v.VideoSource))
|
|
4609
4670
|
throw new Error(`Invalid video source '${e.src}'.`);
|
|
4610
|
-
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();
|
|
4611
4672
|
}
|
|
4612
4673
|
update(e, t) {
|
|
4613
4674
|
super.update(e, t);
|
|
@@ -4635,11 +4696,11 @@ class ms extends R {
|
|
|
4635
4696
|
const t = this.clipConfiguration.asset;
|
|
4636
4697
|
if (!t.crop)
|
|
4637
4698
|
return e;
|
|
4638
|
-
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,
|
|
4639
|
-
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 });
|
|
4640
4701
|
}
|
|
4641
4702
|
}
|
|
4642
|
-
class le extends
|
|
4703
|
+
class le extends ot {
|
|
4643
4704
|
static ZIndexPadding = 100;
|
|
4644
4705
|
assetLoader;
|
|
4645
4706
|
events;
|
|
@@ -4660,10 +4721,10 @@ class le extends rt {
|
|
|
4660
4721
|
/** @internal */
|
|
4661
4722
|
updatedClip;
|
|
4662
4723
|
constructor(e, t = "#ffffff") {
|
|
4663
|
-
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;
|
|
4664
4725
|
}
|
|
4665
4726
|
async load() {
|
|
4666
|
-
const e = new
|
|
4727
|
+
const e = new v.Graphics();
|
|
4667
4728
|
e.fillStyle = {
|
|
4668
4729
|
color: this.backgroundColor
|
|
4669
4730
|
}, e.rect(0, 0, this.size.width, this.size.height), e.fill(), this.getContainer().addChild(e);
|
|
@@ -4698,7 +4759,7 @@ class le extends rt {
|
|
|
4698
4759
|
async loadEdit(e) {
|
|
4699
4760
|
this.clearClips(), this.edit = Ji.parse(e), this.backgroundColor = this.edit.timeline.background || "#000000", await Promise.all(
|
|
4700
4761
|
(this.edit.timeline.fonts ?? []).map(async (t) => {
|
|
4701
|
-
const i = t.src, s = { src: i, loadParser:
|
|
4762
|
+
const i = t.src, s = { src: i, loadParser: Ve.Name };
|
|
4702
4763
|
return this.assetLoader.load(i, s);
|
|
4703
4764
|
})
|
|
4704
4765
|
);
|
|
@@ -4726,7 +4787,7 @@ class le extends rt {
|
|
|
4726
4787
|
};
|
|
4727
4788
|
}
|
|
4728
4789
|
addClip(e, t) {
|
|
4729
|
-
const i =
|
|
4790
|
+
const i = Nt.parse(t), s = this.createPlayerFromAssetType(i);
|
|
4730
4791
|
s.layer = e + 1, this.addPlayer(e, s), this.updateTotalDuration();
|
|
4731
4792
|
}
|
|
4732
4793
|
getClip(e, t) {
|
|
@@ -4751,7 +4812,7 @@ class le extends rt {
|
|
|
4751
4812
|
i.forEach(({ clip: s }) => {
|
|
4752
4813
|
const n = 1e5 - s.layer * le.ZIndexPadding, r = `shotstack-track-${n}`;
|
|
4753
4814
|
let o = this.getContainer().getChildByLabel(r, !1);
|
|
4754
|
-
o || (o = new
|
|
4815
|
+
o || (o = new v.Container({
|
|
4755
4816
|
label: r,
|
|
4756
4817
|
zIndex: n
|
|
4757
4818
|
}), this.getContainer().addChild(o)), o.addChild(s.getContainer());
|
|
@@ -4778,7 +4839,7 @@ class le extends rt {
|
|
|
4778
4839
|
i.forEach(({ clip: s }) => {
|
|
4779
4840
|
const n = 1e5 - s.layer * le.ZIndexPadding, r = `shotstack-track-${n}`;
|
|
4780
4841
|
let o = this.getContainer().getChildByLabel(r, !1);
|
|
4781
|
-
o || (o = new
|
|
4842
|
+
o || (o = new v.Container({
|
|
4782
4843
|
label: r,
|
|
4783
4844
|
zIndex: n
|
|
4784
4845
|
}), this.getContainer().addChild(o)), o.addChild(s.getContainer());
|
|
@@ -4835,7 +4896,7 @@ class le extends rt {
|
|
|
4835
4896
|
this.getContainer().removeChildAt(t);
|
|
4836
4897
|
} else
|
|
4837
4898
|
for (const t of this.getContainer().children)
|
|
4838
|
-
if (t instanceof
|
|
4899
|
+
if (t instanceof v.Container && t.label?.toString().startsWith("shotstack-track-") && t.children.includes(e.getContainer())) {
|
|
4839
4900
|
t.removeChild(e.getContainer());
|
|
4840
4901
|
break;
|
|
4841
4902
|
}
|
|
@@ -4848,7 +4909,7 @@ class le extends rt {
|
|
|
4848
4909
|
const { asset: t } = e.clipConfiguration;
|
|
4849
4910
|
if (t && "src" in t && typeof t.src == "string")
|
|
4850
4911
|
try {
|
|
4851
|
-
|
|
4912
|
+
v.Assets.unload(t.src);
|
|
4852
4913
|
} catch (i) {
|
|
4853
4914
|
console.warn(`Failed to unload asset: ${t.src}`, i);
|
|
4854
4915
|
}
|
|
@@ -4891,11 +4952,11 @@ class le extends rt {
|
|
|
4891
4952
|
break;
|
|
4892
4953
|
}
|
|
4893
4954
|
case "audio": {
|
|
4894
|
-
t = new
|
|
4955
|
+
t = new nt(this, e);
|
|
4895
4956
|
break;
|
|
4896
4957
|
}
|
|
4897
4958
|
case "luma": {
|
|
4898
|
-
t = new
|
|
4959
|
+
t = new Pt(this, e);
|
|
4899
4960
|
break;
|
|
4900
4961
|
}
|
|
4901
4962
|
default:
|
|
@@ -4909,12 +4970,12 @@ class le extends rt {
|
|
|
4909
4970
|
this.tracks[e].push(t), this.clips.push(t);
|
|
4910
4971
|
const i = 1e5 - (e + 1) * le.ZIndexPadding, s = `shotstack-track-${i}`;
|
|
4911
4972
|
let n = this.getContainer().getChildByLabel(s, !1);
|
|
4912
|
-
n || (n = new
|
|
4913
|
-
const r = t instanceof
|
|
4973
|
+
n || (n = new v.Container({ label: s, zIndex: i }), this.getContainer().addChild(n)), n.addChild(t.getContainer());
|
|
4974
|
+
const r = t instanceof Pt;
|
|
4914
4975
|
await t.load(), r && n.setMask({ mask: t.getMask(), inverse: !0 }), this.updateTotalDuration();
|
|
4915
4976
|
}
|
|
4916
4977
|
}
|
|
4917
|
-
class
|
|
4978
|
+
class _e extends ot {
|
|
4918
4979
|
static Width = 250;
|
|
4919
4980
|
static Height = 100;
|
|
4920
4981
|
fps;
|
|
@@ -4927,15 +4988,15 @@ class ke extends rt {
|
|
|
4927
4988
|
super(), this.background = null, this.text = null, this.fps = 0, this.playbackTime = 0, this.playbackDuration = 0, this.isPlaying = !1;
|
|
4928
4989
|
}
|
|
4929
4990
|
async load() {
|
|
4930
|
-
const e = new
|
|
4931
|
-
e.fillStyle = { color: "#424242", alpha: 0.5 }, e.rect(0, 0,
|
|
4932
|
-
const t = new
|
|
4991
|
+
const e = new v.Graphics();
|
|
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;
|
|
4993
|
+
const t = new v.Text();
|
|
4933
4994
|
t.text = "", t.style = {
|
|
4934
4995
|
fontFamily: "monospace",
|
|
4935
4996
|
fontSize: 14,
|
|
4936
4997
|
fill: "#ffffff",
|
|
4937
4998
|
wordWrap: !0,
|
|
4938
|
-
wordWrapWidth:
|
|
4999
|
+
wordWrapWidth: _e.Width
|
|
4939
5000
|
}, this.getContainer().addChild(t), this.text = t;
|
|
4940
5001
|
}
|
|
4941
5002
|
update(e, t) {
|
|
@@ -4980,13 +5041,13 @@ class he {
|
|
|
4980
5041
|
maxZoom = 4;
|
|
4981
5042
|
currentZoom = 0.8;
|
|
4982
5043
|
constructor(e, t) {
|
|
4983
|
-
this.size = e, this.application = new
|
|
5044
|
+
this.size = e, this.application = new v.Application(), this.edit = t, this.inspector = new _e();
|
|
4984
5045
|
}
|
|
4985
5046
|
async load() {
|
|
4986
5047
|
const e = document.querySelector(he.CanvasSelector);
|
|
4987
5048
|
if (!e)
|
|
4988
5049
|
throw new Error(`Shotstack canvas root element '${he.CanvasSelector}' not found.`);
|
|
4989
|
-
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);
|
|
4990
5051
|
}
|
|
4991
5052
|
setupTouchHandling(e) {
|
|
4992
5053
|
const t = this.edit.getContainer();
|
|
@@ -5035,7 +5096,7 @@ class he {
|
|
|
5035
5096
|
t.scale.x = this.currentZoom, t.scale.y = this.currentZoom;
|
|
5036
5097
|
}
|
|
5037
5098
|
registerExtensions() {
|
|
5038
|
-
he.extensionsRegistered || (
|
|
5099
|
+
he.extensionsRegistered || (v.extensions.add(new He()), v.extensions.add(new Ve()), he.extensionsRegistered = !0);
|
|
5039
5100
|
}
|
|
5040
5101
|
async configureApplication() {
|
|
5041
5102
|
const e = {
|
|
@@ -5052,7 +5113,7 @@ class he {
|
|
|
5052
5113
|
configureStage() {
|
|
5053
5114
|
if (!this.container || !this.background)
|
|
5054
5115
|
throw new Error("Shotstack canvas container not set up.");
|
|
5055
|
-
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 = {
|
|
5056
5117
|
x: this.application.canvas.width / 2 - this.edit.size.width * this.currentZoom / 2,
|
|
5057
5118
|
y: this.application.canvas.height / 2 - this.edit.size.height * this.currentZoom / 2
|
|
5058
5119
|
};
|
|
@@ -5142,7 +5203,7 @@ class xs {
|
|
|
5142
5203
|
edit;
|
|
5143
5204
|
application;
|
|
5144
5205
|
constructor(e, t) {
|
|
5145
|
-
this.edit = e, this.application = t.application, this.ffmpeg = new
|
|
5206
|
+
this.edit = e, this.application = t.application, this.ffmpeg = new Wt();
|
|
5146
5207
|
}
|
|
5147
5208
|
async init() {
|
|
5148
5209
|
if (!this.isReady)
|
|
@@ -5158,50 +5219,50 @@ class xs {
|
|
|
5158
5219
|
this.edit.pause();
|
|
5159
5220
|
const n = this.edit.getContainer(), r = n.visible, { x: o, y: h } = n.position, { x: c, y: l } = n.scale;
|
|
5160
5221
|
n.visible = !1;
|
|
5161
|
-
const
|
|
5222
|
+
const m = this.createProgressOverlay();
|
|
5162
5223
|
try {
|
|
5163
|
-
const p = this.edit.getSize ? this.edit.getSize() : { width: 1920, height: 1080 },
|
|
5164
|
-
this.updateProgressOverlay(
|
|
5165
|
-
const
|
|
5166
|
-
|
|
5167
|
-
const oe =
|
|
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);
|
|
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");
|
|
5168
5229
|
if (!oe)
|
|
5169
5230
|
throw new Error("Could not get 2D context for canvas");
|
|
5170
|
-
const
|
|
5171
|
-
this.updateProgressOverlay(
|
|
5172
|
-
const
|
|
5173
|
-
if (
|
|
5174
|
-
this.updateProgressOverlay(
|
|
5175
|
-
for (let T = 0; T <
|
|
5176
|
-
const D = await this.processAudioTrack(
|
|
5177
|
-
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);
|
|
5178
5239
|
}
|
|
5179
5240
|
}
|
|
5180
5241
|
n.position.x = 0, n.position.y = 0, n.scale.x = 1, n.scale.y = 1;
|
|
5181
|
-
for (let T = 0; T <
|
|
5242
|
+
for (let T = 0; T < k; T += 1) {
|
|
5182
5243
|
this.edit.seek(T * A), this.edit.tick ? this.edit.tick(0, 0) : (this.edit.update?.(0, 0), this.edit.draw?.());
|
|
5183
5244
|
try {
|
|
5184
5245
|
const { extract: D } = this.application.renderer, E = D.canvas(n);
|
|
5185
|
-
oe.clearRect(0, 0,
|
|
5186
|
-
const
|
|
5187
|
-
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));
|
|
5188
5249
|
} catch (D) {
|
|
5189
5250
|
console.error(`Error capturing frame ${T}:`, D);
|
|
5190
5251
|
}
|
|
5191
|
-
this.updateProgressOverlay(
|
|
5252
|
+
this.updateProgressOverlay(m, re(T + 1), S);
|
|
5192
5253
|
}
|
|
5193
|
-
this.updateProgressOverlay(
|
|
5194
|
-
let
|
|
5195
|
-
for (const T of
|
|
5196
|
-
|
|
5197
|
-
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) {
|
|
5198
5259
|
let T = "";
|
|
5199
|
-
for (let E = 0; E <
|
|
5200
|
-
const
|
|
5201
|
-
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}];`;
|
|
5202
5263
|
}
|
|
5203
|
-
const D =
|
|
5204
|
-
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([
|
|
5205
5266
|
"-filter_complex",
|
|
5206
5267
|
T,
|
|
5207
5268
|
"-map",
|
|
@@ -5215,37 +5276,37 @@ class xs {
|
|
|
5215
5276
|
"-shortest"
|
|
5216
5277
|
]);
|
|
5217
5278
|
}
|
|
5218
|
-
const
|
|
5219
|
-
|
|
5220
|
-
let
|
|
5221
|
-
const
|
|
5279
|
+
const je = "output.mp4";
|
|
5280
|
+
Y.push(je);
|
|
5281
|
+
let lt = 0;
|
|
5282
|
+
const ht = ({ message: T }) => {
|
|
5222
5283
|
const D = T.includes("frame=") && T.includes("fps=") ? T.match(/frame=\s*(\d+)/) : null;
|
|
5223
5284
|
if (D?.[1]) {
|
|
5224
5285
|
const E = parseInt(D[1], 10);
|
|
5225
|
-
if (!Number.isNaN(E) && E >
|
|
5226
|
-
const
|
|
5227
|
-
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);
|
|
5228
5289
|
}
|
|
5229
5290
|
}
|
|
5230
5291
|
};
|
|
5231
|
-
this.ffmpeg.on("log",
|
|
5232
|
-
const
|
|
5233
|
-
|
|
5234
|
-
for (let T = 0; T <
|
|
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);
|
|
5295
|
+
for (let T = 0; T < k; T += 1)
|
|
5235
5296
|
try {
|
|
5236
5297
|
await this.ffmpeg.deleteFile(`frame_${T.toString().padStart(6, "0")}.png`);
|
|
5237
5298
|
} catch {
|
|
5238
5299
|
}
|
|
5239
|
-
for (const T of
|
|
5300
|
+
for (const T of H)
|
|
5240
5301
|
try {
|
|
5241
5302
|
await this.ffmpeg.deleteFile(T.filename);
|
|
5242
5303
|
} catch {
|
|
5243
5304
|
}
|
|
5244
|
-
await this.ffmpeg.deleteFile(
|
|
5305
|
+
await this.ffmpeg.deleteFile(je), this.updateProgressOverlay(m, S, S);
|
|
5245
5306
|
} catch (p) {
|
|
5246
5307
|
throw console.error("Error during export:", p), p;
|
|
5247
5308
|
} finally {
|
|
5248
|
-
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();
|
|
5249
5310
|
}
|
|
5250
5311
|
}
|
|
5251
5312
|
findAudioPlayers() {
|
|
@@ -5256,7 +5317,7 @@ class xs {
|
|
|
5256
5317
|
if (Array.isArray(s))
|
|
5257
5318
|
for (let n = 0; n < s.length; n += 1) {
|
|
5258
5319
|
const r = s[n];
|
|
5259
|
-
(r instanceof
|
|
5320
|
+
(r instanceof nt || r.constructor.name === "AudioPlayer" || r.clipConfiguration?.asset?.type === "audio") && (e.includes(r) || e.push(r));
|
|
5260
5321
|
}
|
|
5261
5322
|
}
|
|
5262
5323
|
return this.searchContainerForPlayers(this.edit.getContainer(), e), e;
|
|
@@ -5264,14 +5325,14 @@ class xs {
|
|
|
5264
5325
|
searchContainerForPlayers(e, t) {
|
|
5265
5326
|
if (e) {
|
|
5266
5327
|
for (const i of e.children)
|
|
5267
|
-
if (i instanceof
|
|
5328
|
+
if (i instanceof v.Container) {
|
|
5268
5329
|
if (i.label?.startsWith("shotstack-track-")) {
|
|
5269
5330
|
for (const n of i.children)
|
|
5270
|
-
if (n instanceof
|
|
5331
|
+
if (n instanceof v.Container) {
|
|
5271
5332
|
const r = n, o = ["player", "clip", "audioPlayer", "entity"];
|
|
5272
5333
|
for (const h of o) {
|
|
5273
5334
|
const c = r[h];
|
|
5274
|
-
c instanceof
|
|
5335
|
+
c instanceof nt && !t.includes(c) && t.push(c);
|
|
5275
5336
|
}
|
|
5276
5337
|
}
|
|
5277
5338
|
}
|