@shotstack/shotstack-studio 1.0.0 → 1.1.0
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/shotstack-studio.es.js +538 -785
- package/dist/shotstack-studio.umd.js +6 -6
- package/package.json +4 -2
- package/readme.md +23 -5
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as w from "pixi.js";
|
|
2
|
-
import { Filter as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
|
|
2
|
+
import { Filter as Zt, deprecation as Kt, GpuProgram as Ht, GlProgram as Bt, Color as Vt } from "pixi.js";
|
|
3
|
+
import * as dt from "opentype.js";
|
|
4
|
+
import * as $t from "howler";
|
|
5
|
+
import { FFmpeg as jt } from "@ffmpeg/ffmpeg";
|
|
6
|
+
class At {
|
|
6
7
|
events;
|
|
7
8
|
constructor() {
|
|
8
9
|
this.events = {};
|
|
@@ -22,16 +23,16 @@ class Et {
|
|
|
22
23
|
i(t);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
|
-
class
|
|
26
|
+
class Ut extends At {
|
|
26
27
|
registry;
|
|
27
28
|
constructor() {
|
|
28
29
|
super(), this.registry = {};
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
class
|
|
32
|
+
class Wt {
|
|
32
33
|
loadTracker;
|
|
33
34
|
constructor() {
|
|
34
|
-
this.loadTracker = new
|
|
35
|
+
this.loadTracker = new Ut();
|
|
35
36
|
}
|
|
36
37
|
async load(e, t) {
|
|
37
38
|
this.updateAssetLoadMetadata(e, "pending", 0);
|
|
@@ -54,14 +55,14 @@ class Xt {
|
|
|
54
55
|
this.loadTracker.emit("onAssetLoadInfoUpdated", { registry: s });
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
class
|
|
58
|
+
class Ze {
|
|
58
59
|
static Name = "FontLoadParser";
|
|
59
60
|
name;
|
|
60
61
|
extension;
|
|
61
62
|
validFontExtensions;
|
|
62
63
|
woff2Decompressor;
|
|
63
64
|
constructor() {
|
|
64
|
-
this.name =
|
|
65
|
+
this.name = Ze.Name, this.extension = {
|
|
65
66
|
type: [w.ExtensionType.LoadParser],
|
|
66
67
|
priority: w.LoaderParserPriority.High,
|
|
67
68
|
ref: null
|
|
@@ -74,12 +75,12 @@ class Be {
|
|
|
74
75
|
async load(e, t, i) {
|
|
75
76
|
const s = e.split("?")[0]?.split(".").pop()?.toLowerCase() ?? "", n = await fetch(e).then((p) => p.arrayBuffer());
|
|
76
77
|
if (s !== "woff2") {
|
|
77
|
-
const p =
|
|
78
|
-
return await
|
|
78
|
+
const p = dt.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
|
+
return await A.load(), document.fonts.add(A), A;
|
|
79
80
|
}
|
|
80
81
|
if (await this.loadWoff2Decompressor(), !this.woff2Decompressor)
|
|
81
82
|
throw new Error("Cannot initialize Woff2 decompressor.");
|
|
82
|
-
const r = this.woff2Decompressor.decompress(n), o =
|
|
83
|
+
const r = this.woff2Decompressor.decompress(n), o = dt.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), g = new FontFace(h, `url(${l})`);
|
|
83
84
|
return await g.load(), document.fonts.add(g), g;
|
|
84
85
|
}
|
|
85
86
|
async loadWoff2Decompressor() {
|
|
@@ -130,14 +131,14 @@ var C;
|
|
|
130
131
|
}
|
|
131
132
|
a.joinValues = i, a.jsonStringifyReplacer = (s, n) => typeof n == "bigint" ? n.toString() : n;
|
|
132
133
|
})(C || (C = {}));
|
|
133
|
-
var
|
|
134
|
+
var ft;
|
|
134
135
|
(function(a) {
|
|
135
136
|
a.mergeShapes = (e, t) => ({
|
|
136
137
|
...e,
|
|
137
138
|
...t
|
|
138
139
|
// second overwrites first
|
|
139
140
|
});
|
|
140
|
-
})(
|
|
141
|
+
})(ft || (ft = {}));
|
|
141
142
|
const f = C.arrayToEnum([
|
|
142
143
|
"string",
|
|
143
144
|
"nan",
|
|
@@ -198,7 +199,7 @@ const f = C.arrayToEnum([
|
|
|
198
199
|
"not_multiple_of",
|
|
199
200
|
"not_finite"
|
|
200
201
|
]);
|
|
201
|
-
class
|
|
202
|
+
class F extends Error {
|
|
202
203
|
get errors() {
|
|
203
204
|
return this.issues;
|
|
204
205
|
}
|
|
@@ -235,7 +236,7 @@ class M extends Error {
|
|
|
235
236
|
return s(this), i;
|
|
236
237
|
}
|
|
237
238
|
static assert(e) {
|
|
238
|
-
if (!(e instanceof
|
|
239
|
+
if (!(e instanceof F))
|
|
239
240
|
throw new Error(`Not a ZodError: ${e}`);
|
|
240
241
|
}
|
|
241
242
|
toString() {
|
|
@@ -257,8 +258,8 @@ class M extends Error {
|
|
|
257
258
|
return this.flatten();
|
|
258
259
|
}
|
|
259
260
|
}
|
|
260
|
-
|
|
261
|
-
const
|
|
261
|
+
F.create = (a) => new F(a);
|
|
262
|
+
const ke = (a, e) => {
|
|
262
263
|
let t;
|
|
263
264
|
switch (a.code) {
|
|
264
265
|
case u.invalid_type:
|
|
@@ -314,11 +315,11 @@ const be = (a, e) => {
|
|
|
314
315
|
}
|
|
315
316
|
return { message: t };
|
|
316
317
|
};
|
|
317
|
-
let Yt =
|
|
318
|
+
let Yt = ke;
|
|
318
319
|
function Ye() {
|
|
319
320
|
return Yt;
|
|
320
321
|
}
|
|
321
|
-
const
|
|
322
|
+
const Xe = (a) => {
|
|
322
323
|
const { data: e, path: t, errorMaps: i, issueData: s } = a, n = [...t, ...s.path || []], r = {
|
|
323
324
|
...s,
|
|
324
325
|
path: n
|
|
@@ -340,7 +341,7 @@ const Ge = (a) => {
|
|
|
340
341
|
};
|
|
341
342
|
};
|
|
342
343
|
function d(a, e) {
|
|
343
|
-
const t = Ye(), i =
|
|
344
|
+
const t = Ye(), i = Xe({
|
|
344
345
|
issueData: e,
|
|
345
346
|
data: a.data,
|
|
346
347
|
path: a.path,
|
|
@@ -351,13 +352,13 @@ function d(a, e) {
|
|
|
351
352
|
// then schema-bound map if available
|
|
352
353
|
t,
|
|
353
354
|
// then global override map
|
|
354
|
-
t ===
|
|
355
|
+
t === ke ? void 0 : ke
|
|
355
356
|
// then global default map
|
|
356
357
|
].filter((s) => !!s)
|
|
357
358
|
});
|
|
358
359
|
a.common.issues.push(i);
|
|
359
360
|
}
|
|
360
|
-
class
|
|
361
|
+
class I {
|
|
361
362
|
constructor() {
|
|
362
363
|
this.value = "valid";
|
|
363
364
|
}
|
|
@@ -385,7 +386,7 @@ class L {
|
|
|
385
386
|
value: r
|
|
386
387
|
});
|
|
387
388
|
}
|
|
388
|
-
return
|
|
389
|
+
return I.mergeObjectSync(e, i);
|
|
389
390
|
}
|
|
390
391
|
static mergeObjectSync(e, t) {
|
|
391
392
|
const i = {};
|
|
@@ -400,8 +401,8 @@ class L {
|
|
|
400
401
|
}
|
|
401
402
|
const x = Object.freeze({
|
|
402
403
|
status: "aborted"
|
|
403
|
-
}),
|
|
404
|
-
function
|
|
404
|
+
}), ye = (a) => ({ status: "dirty", value: a }), M = (a) => ({ status: "valid", value: a }), pt = (a) => a.status === "aborted", mt = (a) => a.status === "dirty", fe = (a) => a.status === "valid", Te = (a) => typeof Promise < "u" && a instanceof Promise;
|
|
405
|
+
function Oe(a, e, t, i) {
|
|
405
406
|
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");
|
|
406
407
|
return e.get(a);
|
|
407
408
|
}
|
|
@@ -413,7 +414,7 @@ var m;
|
|
|
413
414
|
(function(a) {
|
|
414
415
|
a.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, a.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
415
416
|
})(m || (m = {}));
|
|
416
|
-
var
|
|
417
|
+
var ve, xe;
|
|
417
418
|
class K {
|
|
418
419
|
constructor(e, t, i, s) {
|
|
419
420
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = i, this._key = s;
|
|
@@ -422,8 +423,8 @@ class K {
|
|
|
422
423
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
423
424
|
}
|
|
424
425
|
}
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
426
|
+
const gt = (a, e) => {
|
|
427
|
+
if (fe(e))
|
|
427
428
|
return { success: !0, data: e.value };
|
|
428
429
|
if (!a.common.issues.length)
|
|
429
430
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -432,7 +433,7 @@ const yt = (a, e) => {
|
|
|
432
433
|
get error() {
|
|
433
434
|
if (this._error)
|
|
434
435
|
return this._error;
|
|
435
|
-
const t = new
|
|
436
|
+
const t = new F(a.common.issues);
|
|
436
437
|
return this._error = t, this._error;
|
|
437
438
|
}
|
|
438
439
|
};
|
|
@@ -468,7 +469,7 @@ class b {
|
|
|
468
469
|
}
|
|
469
470
|
_processInputParams(e) {
|
|
470
471
|
return {
|
|
471
|
-
status: new
|
|
472
|
+
status: new I(),
|
|
472
473
|
ctx: {
|
|
473
474
|
common: e.parent.common,
|
|
474
475
|
data: e.data,
|
|
@@ -509,7 +510,7 @@ class b {
|
|
|
509
510
|
data: e,
|
|
510
511
|
parsedType: q(e)
|
|
511
512
|
}, n = this._parseSync({ data: e, path: s.path, parent: s });
|
|
512
|
-
return
|
|
513
|
+
return gt(s, n);
|
|
513
514
|
}
|
|
514
515
|
"~validate"(e) {
|
|
515
516
|
var t, i;
|
|
@@ -527,7 +528,7 @@ class b {
|
|
|
527
528
|
if (!this["~standard"].async)
|
|
528
529
|
try {
|
|
529
530
|
const n = this._parseSync({ data: e, path: [], parent: s });
|
|
530
|
-
return
|
|
531
|
+
return fe(n) ? {
|
|
531
532
|
value: n.value
|
|
532
533
|
} : {
|
|
533
534
|
issues: s.common.issues
|
|
@@ -538,7 +539,7 @@ class b {
|
|
|
538
539
|
async: !0
|
|
539
540
|
};
|
|
540
541
|
}
|
|
541
|
-
return this._parseAsync({ data: e, path: [], parent: s }).then((n) =>
|
|
542
|
+
return this._parseAsync({ data: e, path: [], parent: s }).then((n) => fe(n) ? {
|
|
542
543
|
value: n.value
|
|
543
544
|
} : {
|
|
544
545
|
issues: s.common.issues
|
|
@@ -563,7 +564,7 @@ class b {
|
|
|
563
564
|
data: e,
|
|
564
565
|
parsedType: q(e)
|
|
565
566
|
}, s = this._parse({ data: e, path: i.path, parent: i }), n = await (Te(s) ? s : Promise.resolve(s));
|
|
566
|
-
return
|
|
567
|
+
return gt(i, n);
|
|
567
568
|
}
|
|
568
569
|
refine(e, t) {
|
|
569
570
|
const i = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
|
|
@@ -596,25 +597,25 @@ class b {
|
|
|
596
597
|
};
|
|
597
598
|
}
|
|
598
599
|
optional() {
|
|
599
|
-
return
|
|
600
|
+
return U.create(this, this._def);
|
|
600
601
|
}
|
|
601
602
|
nullable() {
|
|
602
|
-
return
|
|
603
|
+
return se.create(this, this._def);
|
|
603
604
|
}
|
|
604
605
|
nullish() {
|
|
605
606
|
return this.nullable().optional();
|
|
606
607
|
}
|
|
607
608
|
array() {
|
|
608
|
-
return
|
|
609
|
+
return Z.create(this);
|
|
609
610
|
}
|
|
610
611
|
promise() {
|
|
611
|
-
return
|
|
612
|
+
return Ce.create(this, this._def);
|
|
612
613
|
}
|
|
613
614
|
or(e) {
|
|
614
|
-
return
|
|
615
|
+
return Re.create([this, e], this._def);
|
|
615
616
|
}
|
|
616
617
|
and(e) {
|
|
617
|
-
return
|
|
618
|
+
return ze.create(this, e, this._def);
|
|
618
619
|
}
|
|
619
620
|
transform(e) {
|
|
620
621
|
return new Y({
|
|
@@ -626,7 +627,7 @@ class b {
|
|
|
626
627
|
}
|
|
627
628
|
default(e) {
|
|
628
629
|
const t = typeof e == "function" ? e : () => e;
|
|
629
|
-
return new
|
|
630
|
+
return new Fe({
|
|
630
631
|
..._(this._def),
|
|
631
632
|
innerType: this,
|
|
632
633
|
defaultValue: t,
|
|
@@ -634,7 +635,7 @@ class b {
|
|
|
634
635
|
});
|
|
635
636
|
}
|
|
636
637
|
brand() {
|
|
637
|
-
return new
|
|
638
|
+
return new Lt({
|
|
638
639
|
typeName: v.ZodBranded,
|
|
639
640
|
type: this,
|
|
640
641
|
..._(this._def)
|
|
@@ -642,7 +643,7 @@ class b {
|
|
|
642
643
|
}
|
|
643
644
|
catch(e) {
|
|
644
645
|
const t = typeof e == "function" ? e : () => e;
|
|
645
|
-
return new
|
|
646
|
+
return new Ne({
|
|
646
647
|
..._(this._def),
|
|
647
648
|
innerType: this,
|
|
648
649
|
catchValue: t,
|
|
@@ -660,7 +661,7 @@ class b {
|
|
|
660
661
|
return Ke.create(this, e);
|
|
661
662
|
}
|
|
662
663
|
readonly() {
|
|
663
|
-
return
|
|
664
|
+
return De.create(this);
|
|
664
665
|
}
|
|
665
666
|
isOptional() {
|
|
666
667
|
return this.safeParse(void 0).success;
|
|
@@ -669,26 +670,26 @@ class b {
|
|
|
669
670
|
return this.safeParse(null).success;
|
|
670
671
|
}
|
|
671
672
|
}
|
|
672
|
-
const
|
|
673
|
-
let
|
|
674
|
-
const
|
|
675
|
-
function
|
|
673
|
+
const Xt = /^c[^\s-]{8,}$/i, qt = /^[0-9a-z]+$/, Gt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Qt = /^[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, Jt = /^[a-z0-9_-]{21}$/i, ei = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ti = /^[-+]?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)?)??$/, ii = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, si = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
674
|
+
let We;
|
|
675
|
+
const ni = /^(?:(?: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])$/, 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])\/(3[0-2]|[12]?[0-9])$/, ri = /^(([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]))$/, 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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, ci = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, li = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Rt = "((\\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])))", hi = new RegExp(`^${Rt}$`);
|
|
676
|
+
function zt(a) {
|
|
676
677
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
677
678
|
return a.precision ? e = `${e}\\.\\d{${a.precision}}` : a.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
678
679
|
}
|
|
679
|
-
function
|
|
680
|
-
return new RegExp(`^${
|
|
680
|
+
function ui(a) {
|
|
681
|
+
return new RegExp(`^${zt(a)}$`);
|
|
681
682
|
}
|
|
682
|
-
function
|
|
683
|
-
let e = `${
|
|
683
|
+
function di(a) {
|
|
684
|
+
let e = `${Rt}T${zt(a)}`;
|
|
684
685
|
const t = [];
|
|
685
686
|
return t.push(a.local ? "Z?" : "Z"), a.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
686
687
|
}
|
|
687
|
-
function
|
|
688
|
-
return !!((e === "v4" || !e) &&
|
|
688
|
+
function fi(a, e) {
|
|
689
|
+
return !!((e === "v4" || !e) && ni.test(a) || (e === "v6" || !e) && ri.test(a));
|
|
689
690
|
}
|
|
690
|
-
function
|
|
691
|
-
if (!
|
|
691
|
+
function pi(a, e) {
|
|
692
|
+
if (!ei.test(a))
|
|
692
693
|
return !1;
|
|
693
694
|
try {
|
|
694
695
|
const [t] = a.split("."), i = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), s = JSON.parse(atob(i));
|
|
@@ -697,10 +698,10 @@ function mi(a, e) {
|
|
|
697
698
|
return !1;
|
|
698
699
|
}
|
|
699
700
|
}
|
|
700
|
-
function
|
|
701
|
-
return !!((e === "v4" || !e) &&
|
|
701
|
+
function mi(a, e) {
|
|
702
|
+
return !!((e === "v4" || !e) && ai.test(a) || (e === "v6" || !e) && oi.test(a));
|
|
702
703
|
}
|
|
703
|
-
class
|
|
704
|
+
class j extends b {
|
|
704
705
|
_parse(e) {
|
|
705
706
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
|
|
706
707
|
const n = this._getOrReturnCtx(e);
|
|
@@ -710,7 +711,7 @@ class U extends b {
|
|
|
710
711
|
received: n.parsedType
|
|
711
712
|
}), x;
|
|
712
713
|
}
|
|
713
|
-
const i = new
|
|
714
|
+
const i = new I();
|
|
714
715
|
let s;
|
|
715
716
|
for (const n of this._def.checks)
|
|
716
717
|
if (n.kind === "min")
|
|
@@ -749,31 +750,31 @@ class U extends b {
|
|
|
749
750
|
message: n.message
|
|
750
751
|
}), i.dirty());
|
|
751
752
|
} else if (n.kind === "email")
|
|
752
|
-
|
|
753
|
+
ii.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
753
754
|
validation: "email",
|
|
754
755
|
code: u.invalid_string,
|
|
755
756
|
message: n.message
|
|
756
757
|
}), i.dirty());
|
|
757
758
|
else if (n.kind === "emoji")
|
|
758
|
-
|
|
759
|
+
We || (We = new RegExp(si, "u")), We.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
759
760
|
validation: "emoji",
|
|
760
761
|
code: u.invalid_string,
|
|
761
762
|
message: n.message
|
|
762
763
|
}), i.dirty());
|
|
763
764
|
else if (n.kind === "uuid")
|
|
764
|
-
|
|
765
|
+
Qt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
765
766
|
validation: "uuid",
|
|
766
767
|
code: u.invalid_string,
|
|
767
768
|
message: n.message
|
|
768
769
|
}), i.dirty());
|
|
769
770
|
else if (n.kind === "nanoid")
|
|
770
|
-
|
|
771
|
+
Jt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
771
772
|
validation: "nanoid",
|
|
772
773
|
code: u.invalid_string,
|
|
773
774
|
message: n.message
|
|
774
775
|
}), i.dirty());
|
|
775
776
|
else if (n.kind === "cuid")
|
|
776
|
-
|
|
777
|
+
Xt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
777
778
|
validation: "cuid",
|
|
778
779
|
code: u.invalid_string,
|
|
779
780
|
message: n.message
|
|
@@ -785,7 +786,7 @@ class U extends b {
|
|
|
785
786
|
message: n.message
|
|
786
787
|
}), i.dirty());
|
|
787
788
|
else if (n.kind === "ulid")
|
|
788
|
-
|
|
789
|
+
Gt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
789
790
|
validation: "ulid",
|
|
790
791
|
code: u.invalid_string,
|
|
791
792
|
message: n.message
|
|
@@ -816,39 +817,39 @@ class U extends b {
|
|
|
816
817
|
code: u.invalid_string,
|
|
817
818
|
validation: { endsWith: n.value },
|
|
818
819
|
message: n.message
|
|
819
|
-
}), i.dirty()) : n.kind === "datetime" ?
|
|
820
|
+
}), i.dirty()) : n.kind === "datetime" ? di(n).test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
820
821
|
code: u.invalid_string,
|
|
821
822
|
validation: "datetime",
|
|
822
823
|
message: n.message
|
|
823
|
-
}), i.dirty()) : n.kind === "date" ?
|
|
824
|
+
}), i.dirty()) : n.kind === "date" ? hi.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
824
825
|
code: u.invalid_string,
|
|
825
826
|
validation: "date",
|
|
826
827
|
message: n.message
|
|
827
|
-
}), i.dirty()) : n.kind === "time" ?
|
|
828
|
+
}), i.dirty()) : n.kind === "time" ? ui(n).test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
828
829
|
code: u.invalid_string,
|
|
829
830
|
validation: "time",
|
|
830
831
|
message: n.message
|
|
831
|
-
}), i.dirty()) : n.kind === "duration" ?
|
|
832
|
+
}), i.dirty()) : n.kind === "duration" ? ti.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
832
833
|
validation: "duration",
|
|
833
834
|
code: u.invalid_string,
|
|
834
835
|
message: n.message
|
|
835
|
-
}), i.dirty()) : n.kind === "ip" ?
|
|
836
|
+
}), i.dirty()) : n.kind === "ip" ? fi(e.data, n.version) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
836
837
|
validation: "ip",
|
|
837
838
|
code: u.invalid_string,
|
|
838
839
|
message: n.message
|
|
839
|
-
}), i.dirty()) : n.kind === "jwt" ?
|
|
840
|
+
}), i.dirty()) : n.kind === "jwt" ? pi(e.data, n.alg) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
840
841
|
validation: "jwt",
|
|
841
842
|
code: u.invalid_string,
|
|
842
843
|
message: n.message
|
|
843
|
-
}), i.dirty()) : n.kind === "cidr" ?
|
|
844
|
+
}), i.dirty()) : n.kind === "cidr" ? mi(e.data, n.version) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
844
845
|
validation: "cidr",
|
|
845
846
|
code: u.invalid_string,
|
|
846
847
|
message: n.message
|
|
847
|
-
}), i.dirty()) : n.kind === "base64" ?
|
|
848
|
+
}), i.dirty()) : n.kind === "base64" ? ci.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
848
849
|
validation: "base64",
|
|
849
850
|
code: u.invalid_string,
|
|
850
851
|
message: n.message
|
|
851
|
-
}), i.dirty()) : n.kind === "base64url" ?
|
|
852
|
+
}), i.dirty()) : n.kind === "base64url" ? li.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
852
853
|
validation: "base64url",
|
|
853
854
|
code: u.invalid_string,
|
|
854
855
|
message: n.message
|
|
@@ -863,7 +864,7 @@ class U extends b {
|
|
|
863
864
|
});
|
|
864
865
|
}
|
|
865
866
|
_addCheck(e) {
|
|
866
|
-
return new
|
|
867
|
+
return new j({
|
|
867
868
|
...this._def,
|
|
868
869
|
checks: [...this._def.checks, e]
|
|
869
870
|
});
|
|
@@ -1000,19 +1001,19 @@ class U extends b {
|
|
|
1000
1001
|
return this.min(1, m.errToObj(e));
|
|
1001
1002
|
}
|
|
1002
1003
|
trim() {
|
|
1003
|
-
return new
|
|
1004
|
+
return new j({
|
|
1004
1005
|
...this._def,
|
|
1005
1006
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
1006
1007
|
});
|
|
1007
1008
|
}
|
|
1008
1009
|
toLowerCase() {
|
|
1009
|
-
return new
|
|
1010
|
+
return new j({
|
|
1010
1011
|
...this._def,
|
|
1011
1012
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1012
1013
|
});
|
|
1013
1014
|
}
|
|
1014
1015
|
toUpperCase() {
|
|
1015
|
-
return new
|
|
1016
|
+
return new j({
|
|
1016
1017
|
...this._def,
|
|
1017
1018
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1018
1019
|
});
|
|
@@ -1078,20 +1079,20 @@ class U extends b {
|
|
|
1078
1079
|
return e;
|
|
1079
1080
|
}
|
|
1080
1081
|
}
|
|
1081
|
-
|
|
1082
|
+
j.create = (a) => {
|
|
1082
1083
|
var e;
|
|
1083
|
-
return new
|
|
1084
|
+
return new j({
|
|
1084
1085
|
checks: [],
|
|
1085
1086
|
typeName: v.ZodString,
|
|
1086
1087
|
coerce: (e = a?.coerce) !== null && e !== void 0 ? e : !1,
|
|
1087
1088
|
..._(a)
|
|
1088
1089
|
});
|
|
1089
1090
|
};
|
|
1090
|
-
function
|
|
1091
|
+
function gi(a, e) {
|
|
1091
1092
|
const t = (a.toString().split(".")[1] || "").length, i = (e.toString().split(".")[1] || "").length, s = t > i ? t : i, n = parseInt(a.toFixed(s).replace(".", "")), r = parseInt(e.toFixed(s).replace(".", ""));
|
|
1092
1093
|
return n % r / Math.pow(10, s);
|
|
1093
1094
|
}
|
|
1094
|
-
class
|
|
1095
|
+
class pe extends b {
|
|
1095
1096
|
constructor() {
|
|
1096
1097
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1097
1098
|
}
|
|
@@ -1105,7 +1106,7 @@ class me extends b {
|
|
|
1105
1106
|
}), x;
|
|
1106
1107
|
}
|
|
1107
1108
|
let i;
|
|
1108
|
-
const s = new
|
|
1109
|
+
const s = new I();
|
|
1109
1110
|
for (const n of this._def.checks)
|
|
1110
1111
|
n.kind === "int" ? C.isInteger(e.data) || (i = this._getOrReturnCtx(e, i), d(i, {
|
|
1111
1112
|
code: u.invalid_type,
|
|
@@ -1126,7 +1127,7 @@ class me extends b {
|
|
|
1126
1127
|
inclusive: n.inclusive,
|
|
1127
1128
|
exact: !1,
|
|
1128
1129
|
message: n.message
|
|
1129
|
-
}), s.dirty()) : n.kind === "multipleOf" ?
|
|
1130
|
+
}), s.dirty()) : n.kind === "multipleOf" ? gi(e.data, n.value) !== 0 && (i = this._getOrReturnCtx(e, i), d(i, {
|
|
1130
1131
|
code: u.not_multiple_of,
|
|
1131
1132
|
multipleOf: n.value,
|
|
1132
1133
|
message: n.message
|
|
@@ -1149,7 +1150,7 @@ class me extends b {
|
|
|
1149
1150
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
1150
1151
|
}
|
|
1151
1152
|
setLimit(e, t, i, s) {
|
|
1152
|
-
return new
|
|
1153
|
+
return new pe({
|
|
1153
1154
|
...this._def,
|
|
1154
1155
|
checks: [
|
|
1155
1156
|
...this._def.checks,
|
|
@@ -1163,7 +1164,7 @@ class me extends b {
|
|
|
1163
1164
|
});
|
|
1164
1165
|
}
|
|
1165
1166
|
_addCheck(e) {
|
|
1166
|
-
return new
|
|
1167
|
+
return new pe({
|
|
1167
1168
|
...this._def,
|
|
1168
1169
|
checks: [...this._def.checks, e]
|
|
1169
1170
|
});
|
|
@@ -1257,13 +1258,13 @@ class me extends b {
|
|
|
1257
1258
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1258
1259
|
}
|
|
1259
1260
|
}
|
|
1260
|
-
|
|
1261
|
+
pe.create = (a) => new pe({
|
|
1261
1262
|
checks: [],
|
|
1262
1263
|
typeName: v.ZodNumber,
|
|
1263
1264
|
coerce: a?.coerce || !1,
|
|
1264
1265
|
..._(a)
|
|
1265
1266
|
});
|
|
1266
|
-
class
|
|
1267
|
+
class me extends b {
|
|
1267
1268
|
constructor() {
|
|
1268
1269
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1269
1270
|
}
|
|
@@ -1277,7 +1278,7 @@ class ge extends b {
|
|
|
1277
1278
|
if (this._getType(e) !== f.bigint)
|
|
1278
1279
|
return this._getInvalidInput(e);
|
|
1279
1280
|
let i;
|
|
1280
|
-
const s = new
|
|
1281
|
+
const s = new I();
|
|
1281
1282
|
for (const n of this._def.checks)
|
|
1282
1283
|
n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (i = this._getOrReturnCtx(e, i), d(i, {
|
|
1283
1284
|
code: u.too_small,
|
|
@@ -1319,7 +1320,7 @@ class ge extends b {
|
|
|
1319
1320
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
1320
1321
|
}
|
|
1321
1322
|
setLimit(e, t, i, s) {
|
|
1322
|
-
return new
|
|
1323
|
+
return new me({
|
|
1323
1324
|
...this._def,
|
|
1324
1325
|
checks: [
|
|
1325
1326
|
...this._def.checks,
|
|
@@ -1333,7 +1334,7 @@ class ge extends b {
|
|
|
1333
1334
|
});
|
|
1334
1335
|
}
|
|
1335
1336
|
_addCheck(e) {
|
|
1336
|
-
return new
|
|
1337
|
+
return new me({
|
|
1337
1338
|
...this._def,
|
|
1338
1339
|
checks: [...this._def.checks, e]
|
|
1339
1340
|
});
|
|
@@ -1390,9 +1391,9 @@ class ge extends b {
|
|
|
1390
1391
|
return e;
|
|
1391
1392
|
}
|
|
1392
1393
|
}
|
|
1393
|
-
|
|
1394
|
+
me.create = (a) => {
|
|
1394
1395
|
var e;
|
|
1395
|
-
return new
|
|
1396
|
+
return new me({
|
|
1396
1397
|
checks: [],
|
|
1397
1398
|
typeName: v.ZodBigInt,
|
|
1398
1399
|
coerce: (e = a?.coerce) !== null && e !== void 0 ? e : !1,
|
|
@@ -1409,7 +1410,7 @@ class qe extends b {
|
|
|
1409
1410
|
received: i.parsedType
|
|
1410
1411
|
}), x;
|
|
1411
1412
|
}
|
|
1412
|
-
return
|
|
1413
|
+
return M(e.data);
|
|
1413
1414
|
}
|
|
1414
1415
|
}
|
|
1415
1416
|
qe.create = (a) => new qe({
|
|
@@ -1417,7 +1418,7 @@ qe.create = (a) => new qe({
|
|
|
1417
1418
|
coerce: a?.coerce || !1,
|
|
1418
1419
|
..._(a)
|
|
1419
1420
|
});
|
|
1420
|
-
class
|
|
1421
|
+
class be extends b {
|
|
1421
1422
|
_parse(e) {
|
|
1422
1423
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
|
|
1423
1424
|
const n = this._getOrReturnCtx(e);
|
|
@@ -1433,7 +1434,7 @@ class Ce extends b {
|
|
|
1433
1434
|
code: u.invalid_date
|
|
1434
1435
|
}), x;
|
|
1435
1436
|
}
|
|
1436
|
-
const i = new
|
|
1437
|
+
const i = new I();
|
|
1437
1438
|
let s;
|
|
1438
1439
|
for (const n of this._def.checks)
|
|
1439
1440
|
n.kind === "min" ? e.data.getTime() < n.value && (s = this._getOrReturnCtx(e, s), d(s, {
|
|
@@ -1457,7 +1458,7 @@ class Ce extends b {
|
|
|
1457
1458
|
};
|
|
1458
1459
|
}
|
|
1459
1460
|
_addCheck(e) {
|
|
1460
|
-
return new
|
|
1461
|
+
return new be({
|
|
1461
1462
|
...this._def,
|
|
1462
1463
|
checks: [...this._def.checks, e]
|
|
1463
1464
|
});
|
|
@@ -1489,13 +1490,13 @@ class Ce extends b {
|
|
|
1489
1490
|
return e != null ? new Date(e) : null;
|
|
1490
1491
|
}
|
|
1491
1492
|
}
|
|
1492
|
-
|
|
1493
|
+
be.create = (a) => new be({
|
|
1493
1494
|
checks: [],
|
|
1494
1495
|
coerce: a?.coerce || !1,
|
|
1495
1496
|
typeName: v.ZodDate,
|
|
1496
1497
|
..._(a)
|
|
1497
1498
|
});
|
|
1498
|
-
class
|
|
1499
|
+
class Ge extends b {
|
|
1499
1500
|
_parse(e) {
|
|
1500
1501
|
if (this._getType(e) !== f.symbol) {
|
|
1501
1502
|
const i = this._getOrReturnCtx(e);
|
|
@@ -1505,14 +1506,14 @@ class Qe extends b {
|
|
|
1505
1506
|
received: i.parsedType
|
|
1506
1507
|
}), x;
|
|
1507
1508
|
}
|
|
1508
|
-
return
|
|
1509
|
+
return M(e.data);
|
|
1509
1510
|
}
|
|
1510
1511
|
}
|
|
1511
|
-
|
|
1512
|
+
Ge.create = (a) => new Ge({
|
|
1512
1513
|
typeName: v.ZodSymbol,
|
|
1513
1514
|
..._(a)
|
|
1514
1515
|
});
|
|
1515
|
-
class
|
|
1516
|
+
class Ae extends b {
|
|
1516
1517
|
_parse(e) {
|
|
1517
1518
|
if (this._getType(e) !== f.undefined) {
|
|
1518
1519
|
const i = this._getOrReturnCtx(e);
|
|
@@ -1522,14 +1523,14 @@ class Re extends b {
|
|
|
1522
1523
|
received: i.parsedType
|
|
1523
1524
|
}), x;
|
|
1524
1525
|
}
|
|
1525
|
-
return
|
|
1526
|
+
return M(e.data);
|
|
1526
1527
|
}
|
|
1527
1528
|
}
|
|
1528
|
-
|
|
1529
|
+
Ae.create = (a) => new Ae({
|
|
1529
1530
|
typeName: v.ZodUndefined,
|
|
1530
1531
|
..._(a)
|
|
1531
1532
|
});
|
|
1532
|
-
class
|
|
1533
|
+
class Pe extends b {
|
|
1533
1534
|
_parse(e) {
|
|
1534
1535
|
if (this._getType(e) !== f.null) {
|
|
1535
1536
|
const i = this._getOrReturnCtx(e);
|
|
@@ -1539,38 +1540,38 @@ class Ee extends b {
|
|
|
1539
1540
|
received: i.parsedType
|
|
1540
1541
|
}), x;
|
|
1541
1542
|
}
|
|
1542
|
-
return
|
|
1543
|
+
return M(e.data);
|
|
1543
1544
|
}
|
|
1544
1545
|
}
|
|
1545
|
-
|
|
1546
|
+
Pe.create = (a) => new Pe({
|
|
1546
1547
|
typeName: v.ZodNull,
|
|
1547
1548
|
..._(a)
|
|
1548
1549
|
});
|
|
1549
|
-
class
|
|
1550
|
+
class Qe extends b {
|
|
1550
1551
|
constructor() {
|
|
1551
1552
|
super(...arguments), this._any = !0;
|
|
1552
1553
|
}
|
|
1553
1554
|
_parse(e) {
|
|
1554
|
-
return
|
|
1555
|
+
return M(e.data);
|
|
1555
1556
|
}
|
|
1556
1557
|
}
|
|
1557
|
-
|
|
1558
|
+
Qe.create = (a) => new Qe({
|
|
1558
1559
|
typeName: v.ZodAny,
|
|
1559
1560
|
..._(a)
|
|
1560
1561
|
});
|
|
1561
|
-
class
|
|
1562
|
+
class ue extends b {
|
|
1562
1563
|
constructor() {
|
|
1563
1564
|
super(...arguments), this._unknown = !0;
|
|
1564
1565
|
}
|
|
1565
1566
|
_parse(e) {
|
|
1566
|
-
return
|
|
1567
|
+
return M(e.data);
|
|
1567
1568
|
}
|
|
1568
1569
|
}
|
|
1569
|
-
|
|
1570
|
+
ue.create = (a) => new ue({
|
|
1570
1571
|
typeName: v.ZodUnknown,
|
|
1571
1572
|
..._(a)
|
|
1572
1573
|
});
|
|
1573
|
-
class
|
|
1574
|
+
class G extends b {
|
|
1574
1575
|
_parse(e) {
|
|
1575
1576
|
const t = this._getOrReturnCtx(e);
|
|
1576
1577
|
return d(t, {
|
|
@@ -1580,11 +1581,11 @@ class Q extends b {
|
|
|
1580
1581
|
}), x;
|
|
1581
1582
|
}
|
|
1582
1583
|
}
|
|
1583
|
-
|
|
1584
|
+
G.create = (a) => new G({
|
|
1584
1585
|
typeName: v.ZodNever,
|
|
1585
1586
|
..._(a)
|
|
1586
1587
|
});
|
|
1587
|
-
class
|
|
1588
|
+
class Je extends b {
|
|
1588
1589
|
_parse(e) {
|
|
1589
1590
|
if (this._getType(e) !== f.undefined) {
|
|
1590
1591
|
const i = this._getOrReturnCtx(e);
|
|
@@ -1594,14 +1595,14 @@ class et extends b {
|
|
|
1594
1595
|
received: i.parsedType
|
|
1595
1596
|
}), x;
|
|
1596
1597
|
}
|
|
1597
|
-
return
|
|
1598
|
+
return M(e.data);
|
|
1598
1599
|
}
|
|
1599
1600
|
}
|
|
1600
|
-
|
|
1601
|
+
Je.create = (a) => new Je({
|
|
1601
1602
|
typeName: v.ZodVoid,
|
|
1602
1603
|
..._(a)
|
|
1603
1604
|
});
|
|
1604
|
-
class
|
|
1605
|
+
class Z extends b {
|
|
1605
1606
|
_parse(e) {
|
|
1606
1607
|
const { ctx: t, status: i } = this._processInputParams(e), s = this._def;
|
|
1607
1608
|
if (t.parsedType !== f.array)
|
|
@@ -1637,27 +1638,27 @@ class B extends b {
|
|
|
1637
1638
|
exact: !1,
|
|
1638
1639
|
message: s.maxLength.message
|
|
1639
1640
|
}), i.dirty()), t.common.async)
|
|
1640
|
-
return Promise.all([...t.data].map((r, o) => s.type._parseAsync(new K(t, r, t.path, o)))).then((r) =>
|
|
1641
|
+
return Promise.all([...t.data].map((r, o) => s.type._parseAsync(new K(t, r, t.path, o)))).then((r) => I.mergeArray(i, r));
|
|
1641
1642
|
const n = [...t.data].map((r, o) => s.type._parseSync(new K(t, r, t.path, o)));
|
|
1642
|
-
return
|
|
1643
|
+
return I.mergeArray(i, n);
|
|
1643
1644
|
}
|
|
1644
1645
|
get element() {
|
|
1645
1646
|
return this._def.type;
|
|
1646
1647
|
}
|
|
1647
1648
|
min(e, t) {
|
|
1648
|
-
return new
|
|
1649
|
+
return new Z({
|
|
1649
1650
|
...this._def,
|
|
1650
1651
|
minLength: { value: e, message: m.toString(t) }
|
|
1651
1652
|
});
|
|
1652
1653
|
}
|
|
1653
1654
|
max(e, t) {
|
|
1654
|
-
return new
|
|
1655
|
+
return new Z({
|
|
1655
1656
|
...this._def,
|
|
1656
1657
|
maxLength: { value: e, message: m.toString(t) }
|
|
1657
1658
|
});
|
|
1658
1659
|
}
|
|
1659
1660
|
length(e, t) {
|
|
1660
|
-
return new
|
|
1661
|
+
return new Z({
|
|
1661
1662
|
...this._def,
|
|
1662
1663
|
exactLength: { value: e, message: m.toString(t) }
|
|
1663
1664
|
});
|
|
@@ -1666,7 +1667,7 @@ class B extends b {
|
|
|
1666
1667
|
return this.min(1, e);
|
|
1667
1668
|
}
|
|
1668
1669
|
}
|
|
1669
|
-
|
|
1670
|
+
Z.create = (a, e) => new Z({
|
|
1670
1671
|
type: a,
|
|
1671
1672
|
minLength: null,
|
|
1672
1673
|
maxLength: null,
|
|
@@ -1674,23 +1675,23 @@ B.create = (a, e) => new B({
|
|
|
1674
1675
|
typeName: v.ZodArray,
|
|
1675
1676
|
..._(e)
|
|
1676
1677
|
});
|
|
1677
|
-
function
|
|
1678
|
-
if (a instanceof
|
|
1678
|
+
function ce(a) {
|
|
1679
|
+
if (a instanceof P) {
|
|
1679
1680
|
const e = {};
|
|
1680
1681
|
for (const t in a.shape) {
|
|
1681
1682
|
const i = a.shape[t];
|
|
1682
|
-
e[t] =
|
|
1683
|
+
e[t] = U.create(ce(i));
|
|
1683
1684
|
}
|
|
1684
|
-
return new
|
|
1685
|
+
return new P({
|
|
1685
1686
|
...a._def,
|
|
1686
1687
|
shape: () => e
|
|
1687
1688
|
});
|
|
1688
|
-
} else return a instanceof
|
|
1689
|
+
} else return a instanceof Z ? new Z({
|
|
1689
1690
|
...a._def,
|
|
1690
|
-
type:
|
|
1691
|
-
}) : a instanceof
|
|
1691
|
+
type: ce(a.element)
|
|
1692
|
+
}) : a instanceof U ? U.create(ce(a.unwrap())) : a instanceof se ? se.create(ce(a.unwrap())) : a instanceof W ? W.create(a.items.map((e) => ce(e))) : a;
|
|
1692
1693
|
}
|
|
1693
|
-
class
|
|
1694
|
+
class P extends b {
|
|
1694
1695
|
constructor() {
|
|
1695
1696
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1696
1697
|
}
|
|
@@ -1710,7 +1711,7 @@ class E extends b {
|
|
|
1710
1711
|
}), x;
|
|
1711
1712
|
}
|
|
1712
1713
|
const { status: i, ctx: s } = this._processInputParams(e), { shape: n, keys: r } = this._getCached(), o = [];
|
|
1713
|
-
if (!(this._def.catchall instanceof
|
|
1714
|
+
if (!(this._def.catchall instanceof G && this._def.unknownKeys === "strip"))
|
|
1714
1715
|
for (const c in s.data)
|
|
1715
1716
|
r.includes(c) || o.push(c);
|
|
1716
1717
|
const h = [];
|
|
@@ -1722,7 +1723,7 @@ class E extends b {
|
|
|
1722
1723
|
alwaysSet: c in s.data
|
|
1723
1724
|
});
|
|
1724
1725
|
}
|
|
1725
|
-
if (this._def.catchall instanceof
|
|
1726
|
+
if (this._def.catchall instanceof G) {
|
|
1726
1727
|
const c = this._def.unknownKeys;
|
|
1727
1728
|
if (c === "passthrough")
|
|
1728
1729
|
for (const l of o)
|
|
@@ -1761,13 +1762,13 @@ class E extends b {
|
|
|
1761
1762
|
});
|
|
1762
1763
|
}
|
|
1763
1764
|
return c;
|
|
1764
|
-
}).then((c) =>
|
|
1765
|
+
}).then((c) => I.mergeObjectSync(i, c)) : I.mergeObjectSync(i, h);
|
|
1765
1766
|
}
|
|
1766
1767
|
get shape() {
|
|
1767
1768
|
return this._def.shape();
|
|
1768
1769
|
}
|
|
1769
1770
|
strict(e) {
|
|
1770
|
-
return m.errToObj, new
|
|
1771
|
+
return m.errToObj, new P({
|
|
1771
1772
|
...this._def,
|
|
1772
1773
|
unknownKeys: "strict",
|
|
1773
1774
|
...e !== void 0 ? {
|
|
@@ -1784,13 +1785,13 @@ class E extends b {
|
|
|
1784
1785
|
});
|
|
1785
1786
|
}
|
|
1786
1787
|
strip() {
|
|
1787
|
-
return new
|
|
1788
|
+
return new P({
|
|
1788
1789
|
...this._def,
|
|
1789
1790
|
unknownKeys: "strip"
|
|
1790
1791
|
});
|
|
1791
1792
|
}
|
|
1792
1793
|
passthrough() {
|
|
1793
|
-
return new
|
|
1794
|
+
return new P({
|
|
1794
1795
|
...this._def,
|
|
1795
1796
|
unknownKeys: "passthrough"
|
|
1796
1797
|
});
|
|
@@ -1813,7 +1814,7 @@ class E extends b {
|
|
|
1813
1814
|
// }) as any;
|
|
1814
1815
|
// };
|
|
1815
1816
|
extend(e) {
|
|
1816
|
-
return new
|
|
1817
|
+
return new P({
|
|
1817
1818
|
...this._def,
|
|
1818
1819
|
shape: () => ({
|
|
1819
1820
|
...this._def.shape(),
|
|
@@ -1827,7 +1828,7 @@ class E extends b {
|
|
|
1827
1828
|
* upgrade if you are experiencing issues.
|
|
1828
1829
|
*/
|
|
1829
1830
|
merge(e) {
|
|
1830
|
-
return new
|
|
1831
|
+
return new P({
|
|
1831
1832
|
unknownKeys: e._def.unknownKeys,
|
|
1832
1833
|
catchall: e._def.catchall,
|
|
1833
1834
|
shape: () => ({
|
|
@@ -1897,7 +1898,7 @@ class E extends b {
|
|
|
1897
1898
|
// return merged;
|
|
1898
1899
|
// }
|
|
1899
1900
|
catchall(e) {
|
|
1900
|
-
return new
|
|
1901
|
+
return new P({
|
|
1901
1902
|
...this._def,
|
|
1902
1903
|
catchall: e
|
|
1903
1904
|
});
|
|
@@ -1906,7 +1907,7 @@ class E extends b {
|
|
|
1906
1907
|
const t = {};
|
|
1907
1908
|
return C.objectKeys(e).forEach((i) => {
|
|
1908
1909
|
e[i] && this.shape[i] && (t[i] = this.shape[i]);
|
|
1909
|
-
}), new
|
|
1910
|
+
}), new P({
|
|
1910
1911
|
...this._def,
|
|
1911
1912
|
shape: () => t
|
|
1912
1913
|
});
|
|
@@ -1915,7 +1916,7 @@ class E extends b {
|
|
|
1915
1916
|
const t = {};
|
|
1916
1917
|
return C.objectKeys(this.shape).forEach((i) => {
|
|
1917
1918
|
e[i] || (t[i] = this.shape[i]);
|
|
1918
|
-
}), new
|
|
1919
|
+
}), new P({
|
|
1919
1920
|
...this._def,
|
|
1920
1921
|
shape: () => t
|
|
1921
1922
|
});
|
|
@@ -1924,14 +1925,14 @@ class E extends b {
|
|
|
1924
1925
|
* @deprecated
|
|
1925
1926
|
*/
|
|
1926
1927
|
deepPartial() {
|
|
1927
|
-
return
|
|
1928
|
+
return ce(this);
|
|
1928
1929
|
}
|
|
1929
1930
|
partial(e) {
|
|
1930
1931
|
const t = {};
|
|
1931
1932
|
return C.objectKeys(this.shape).forEach((i) => {
|
|
1932
1933
|
const s = this.shape[i];
|
|
1933
1934
|
e && !e[i] ? t[i] = s : t[i] = s.optional();
|
|
1934
|
-
}), new
|
|
1935
|
+
}), new P({
|
|
1935
1936
|
...this._def,
|
|
1936
1937
|
shape: () => t
|
|
1937
1938
|
});
|
|
@@ -1943,41 +1944,41 @@ class E extends b {
|
|
|
1943
1944
|
t[i] = this.shape[i];
|
|
1944
1945
|
else {
|
|
1945
1946
|
let n = this.shape[i];
|
|
1946
|
-
for (; n instanceof
|
|
1947
|
+
for (; n instanceof U; )
|
|
1947
1948
|
n = n._def.innerType;
|
|
1948
1949
|
t[i] = n;
|
|
1949
1950
|
}
|
|
1950
|
-
}), new
|
|
1951
|
+
}), new P({
|
|
1951
1952
|
...this._def,
|
|
1952
1953
|
shape: () => t
|
|
1953
1954
|
});
|
|
1954
1955
|
}
|
|
1955
1956
|
keyof() {
|
|
1956
|
-
return
|
|
1957
|
+
return It(C.objectKeys(this.shape));
|
|
1957
1958
|
}
|
|
1958
1959
|
}
|
|
1959
|
-
|
|
1960
|
+
P.create = (a, e) => new P({
|
|
1960
1961
|
shape: () => a,
|
|
1961
1962
|
unknownKeys: "strip",
|
|
1962
|
-
catchall:
|
|
1963
|
+
catchall: G.create(),
|
|
1963
1964
|
typeName: v.ZodObject,
|
|
1964
1965
|
..._(e)
|
|
1965
1966
|
});
|
|
1966
|
-
|
|
1967
|
+
P.strictCreate = (a, e) => new P({
|
|
1967
1968
|
shape: () => a,
|
|
1968
1969
|
unknownKeys: "strict",
|
|
1969
|
-
catchall:
|
|
1970
|
+
catchall: G.create(),
|
|
1970
1971
|
typeName: v.ZodObject,
|
|
1971
1972
|
..._(e)
|
|
1972
1973
|
});
|
|
1973
|
-
|
|
1974
|
+
P.lazycreate = (a, e) => new P({
|
|
1974
1975
|
shape: a,
|
|
1975
1976
|
unknownKeys: "strip",
|
|
1976
|
-
catchall:
|
|
1977
|
+
catchall: G.create(),
|
|
1977
1978
|
typeName: v.ZodObject,
|
|
1978
1979
|
..._(e)
|
|
1979
1980
|
});
|
|
1980
|
-
class
|
|
1981
|
+
class Re extends b {
|
|
1981
1982
|
_parse(e) {
|
|
1982
1983
|
const { ctx: t } = this._processInputParams(e), i = this._def.options;
|
|
1983
1984
|
function s(n) {
|
|
@@ -1987,7 +1988,7 @@ class Pe extends b {
|
|
|
1987
1988
|
for (const o of n)
|
|
1988
1989
|
if (o.result.status === "dirty")
|
|
1989
1990
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1990
|
-
const r = n.map((o) => new
|
|
1991
|
+
const r = n.map((o) => new F(o.ctx.common.issues));
|
|
1991
1992
|
return d(t, {
|
|
1992
1993
|
code: u.invalid_union,
|
|
1993
1994
|
unionErrors: r
|
|
@@ -2034,7 +2035,7 @@ class Pe extends b {
|
|
|
2034
2035
|
}
|
|
2035
2036
|
if (n)
|
|
2036
2037
|
return t.common.issues.push(...n.ctx.common.issues), n.result;
|
|
2037
|
-
const o = r.map((h) => new
|
|
2038
|
+
const o = r.map((h) => new F(h));
|
|
2038
2039
|
return d(t, {
|
|
2039
2040
|
code: u.invalid_union,
|
|
2040
2041
|
unionErrors: o
|
|
@@ -2045,13 +2046,13 @@ class Pe extends b {
|
|
|
2045
2046
|
return this._def.options;
|
|
2046
2047
|
}
|
|
2047
2048
|
}
|
|
2048
|
-
|
|
2049
|
+
Re.create = (a, e) => new Re({
|
|
2049
2050
|
options: a,
|
|
2050
2051
|
typeName: v.ZodUnion,
|
|
2051
2052
|
..._(e)
|
|
2052
2053
|
});
|
|
2053
|
-
const
|
|
2054
|
-
class
|
|
2054
|
+
const $ = (a) => a instanceof Le ? $(a.schema) : a instanceof Y ? $(a.innerType()) : a instanceof Ee ? [a.value] : a instanceof ie ? a.options : a instanceof Me ? C.objectValues(a.enum) : a instanceof Fe ? $(a._def.innerType) : a instanceof Ae ? [void 0] : a instanceof Pe ? [null] : a instanceof U ? [void 0, ...$(a.unwrap())] : a instanceof se ? [null, ...$(a.unwrap())] : a instanceof Lt || a instanceof De ? $(a.unwrap()) : a instanceof Ne ? $(a._def.innerType) : [];
|
|
2055
|
+
class nt extends b {
|
|
2055
2056
|
_parse(e) {
|
|
2056
2057
|
const { ctx: t } = this._processInputParams(e);
|
|
2057
2058
|
if (t.parsedType !== f.object)
|
|
@@ -2095,7 +2096,7 @@ class at extends b {
|
|
|
2095
2096
|
static create(e, t, i) {
|
|
2096
2097
|
const s = /* @__PURE__ */ new Map();
|
|
2097
2098
|
for (const n of t) {
|
|
2098
|
-
const r =
|
|
2099
|
+
const r = $(n.shape[e]);
|
|
2099
2100
|
if (!r.length)
|
|
2100
2101
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2101
2102
|
for (const o of r) {
|
|
@@ -2104,7 +2105,7 @@ class at extends b {
|
|
|
2104
2105
|
s.set(o, n);
|
|
2105
2106
|
}
|
|
2106
2107
|
}
|
|
2107
|
-
return new
|
|
2108
|
+
return new nt({
|
|
2108
2109
|
typeName: v.ZodDiscriminatedUnion,
|
|
2109
2110
|
discriminator: e,
|
|
2110
2111
|
options: t,
|
|
@@ -2113,14 +2114,14 @@ class at extends b {
|
|
|
2113
2114
|
});
|
|
2114
2115
|
}
|
|
2115
2116
|
}
|
|
2116
|
-
function
|
|
2117
|
+
function et(a, e) {
|
|
2117
2118
|
const t = q(a), i = q(e);
|
|
2118
2119
|
if (a === e)
|
|
2119
2120
|
return { valid: !0, data: a };
|
|
2120
2121
|
if (t === f.object && i === f.object) {
|
|
2121
2122
|
const s = C.objectKeys(e), n = C.objectKeys(a).filter((o) => s.indexOf(o) !== -1), r = { ...a, ...e };
|
|
2122
2123
|
for (const o of n) {
|
|
2123
|
-
const h =
|
|
2124
|
+
const h = et(a[o], e[o]);
|
|
2124
2125
|
if (!h.valid)
|
|
2125
2126
|
return { valid: !1 };
|
|
2126
2127
|
r[o] = h.data;
|
|
@@ -2131,7 +2132,7 @@ function tt(a, e) {
|
|
|
2131
2132
|
return { valid: !1 };
|
|
2132
2133
|
const s = [];
|
|
2133
2134
|
for (let n = 0; n < a.length; n++) {
|
|
2134
|
-
const r = a[n], o = e[n], h =
|
|
2135
|
+
const r = a[n], o = e[n], h = et(r, o);
|
|
2135
2136
|
if (!h.valid)
|
|
2136
2137
|
return { valid: !1 };
|
|
2137
2138
|
s.push(h.data);
|
|
@@ -2139,13 +2140,13 @@ function tt(a, e) {
|
|
|
2139
2140
|
return { valid: !0, data: s };
|
|
2140
2141
|
} else return t === f.date && i === f.date && +a == +e ? { valid: !0, data: a } : { valid: !1 };
|
|
2141
2142
|
}
|
|
2142
|
-
class
|
|
2143
|
+
class ze extends b {
|
|
2143
2144
|
_parse(e) {
|
|
2144
2145
|
const { status: t, ctx: i } = this._processInputParams(e), s = (n, r) => {
|
|
2145
|
-
if (
|
|
2146
|
+
if (pt(n) || pt(r))
|
|
2146
2147
|
return x;
|
|
2147
|
-
const o =
|
|
2148
|
-
return o.valid ? ((
|
|
2148
|
+
const o = et(n.value, r.value);
|
|
2149
|
+
return o.valid ? ((mt(n) || mt(r)) && t.dirty(), { status: t.value, value: o.data }) : (d(i, {
|
|
2149
2150
|
code: u.invalid_intersection_types
|
|
2150
2151
|
}), x);
|
|
2151
2152
|
};
|
|
@@ -2171,13 +2172,13 @@ class Ie extends b {
|
|
|
2171
2172
|
}));
|
|
2172
2173
|
}
|
|
2173
2174
|
}
|
|
2174
|
-
|
|
2175
|
+
ze.create = (a, e, t) => new ze({
|
|
2175
2176
|
left: a,
|
|
2176
2177
|
right: e,
|
|
2177
2178
|
typeName: v.ZodIntersection,
|
|
2178
2179
|
..._(t)
|
|
2179
2180
|
});
|
|
2180
|
-
class
|
|
2181
|
+
class W extends b {
|
|
2181
2182
|
_parse(e) {
|
|
2182
2183
|
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2183
2184
|
if (i.parsedType !== f.array)
|
|
@@ -2205,29 +2206,29 @@ class X extends b {
|
|
|
2205
2206
|
const h = this._def.items[o] || this._def.rest;
|
|
2206
2207
|
return h ? h._parse(new K(i, r, i.path, o)) : null;
|
|
2207
2208
|
}).filter((r) => !!r);
|
|
2208
|
-
return i.common.async ? Promise.all(n).then((r) =>
|
|
2209
|
+
return i.common.async ? Promise.all(n).then((r) => I.mergeArray(t, r)) : I.mergeArray(t, n);
|
|
2209
2210
|
}
|
|
2210
2211
|
get items() {
|
|
2211
2212
|
return this._def.items;
|
|
2212
2213
|
}
|
|
2213
2214
|
rest(e) {
|
|
2214
|
-
return new
|
|
2215
|
+
return new W({
|
|
2215
2216
|
...this._def,
|
|
2216
2217
|
rest: e
|
|
2217
2218
|
});
|
|
2218
2219
|
}
|
|
2219
2220
|
}
|
|
2220
|
-
|
|
2221
|
+
W.create = (a, e) => {
|
|
2221
2222
|
if (!Array.isArray(a))
|
|
2222
2223
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2223
|
-
return new
|
|
2224
|
+
return new W({
|
|
2224
2225
|
items: a,
|
|
2225
2226
|
typeName: v.ZodTuple,
|
|
2226
2227
|
rest: null,
|
|
2227
2228
|
..._(e)
|
|
2228
2229
|
});
|
|
2229
2230
|
};
|
|
2230
|
-
class
|
|
2231
|
+
class Ie extends b {
|
|
2231
2232
|
get keySchema() {
|
|
2232
2233
|
return this._def.keyType;
|
|
2233
2234
|
}
|
|
@@ -2249,26 +2250,26 @@ class Le extends b {
|
|
|
2249
2250
|
value: r._parse(new K(i, i.data[o], i.path, o)),
|
|
2250
2251
|
alwaysSet: o in i.data
|
|
2251
2252
|
});
|
|
2252
|
-
return i.common.async ?
|
|
2253
|
+
return i.common.async ? I.mergeObjectAsync(t, s) : I.mergeObjectSync(t, s);
|
|
2253
2254
|
}
|
|
2254
2255
|
get element() {
|
|
2255
2256
|
return this._def.valueType;
|
|
2256
2257
|
}
|
|
2257
2258
|
static create(e, t, i) {
|
|
2258
|
-
return t instanceof b ? new
|
|
2259
|
+
return t instanceof b ? new Ie({
|
|
2259
2260
|
keyType: e,
|
|
2260
2261
|
valueType: t,
|
|
2261
2262
|
typeName: v.ZodRecord,
|
|
2262
2263
|
..._(i)
|
|
2263
|
-
}) : new
|
|
2264
|
-
keyType:
|
|
2264
|
+
}) : new Ie({
|
|
2265
|
+
keyType: j.create(),
|
|
2265
2266
|
valueType: e,
|
|
2266
2267
|
typeName: v.ZodRecord,
|
|
2267
2268
|
..._(t)
|
|
2268
2269
|
});
|
|
2269
2270
|
}
|
|
2270
2271
|
}
|
|
2271
|
-
class
|
|
2272
|
+
class tt extends b {
|
|
2272
2273
|
get keySchema() {
|
|
2273
2274
|
return this._def.keyType;
|
|
2274
2275
|
}
|
|
@@ -2310,13 +2311,13 @@ class it extends b {
|
|
|
2310
2311
|
}
|
|
2311
2312
|
}
|
|
2312
2313
|
}
|
|
2313
|
-
|
|
2314
|
+
tt.create = (a, e, t) => new tt({
|
|
2314
2315
|
valueType: e,
|
|
2315
2316
|
keyType: a,
|
|
2316
2317
|
typeName: v.ZodMap,
|
|
2317
2318
|
..._(t)
|
|
2318
2319
|
});
|
|
2319
|
-
class
|
|
2320
|
+
class ge extends b {
|
|
2320
2321
|
_parse(e) {
|
|
2321
2322
|
const { status: t, ctx: i } = this._processInputParams(e);
|
|
2322
2323
|
if (i.parsedType !== f.set)
|
|
@@ -2355,13 +2356,13 @@ class ye extends b {
|
|
|
2355
2356
|
return i.common.async ? Promise.all(o).then((h) => r(h)) : r(o);
|
|
2356
2357
|
}
|
|
2357
2358
|
min(e, t) {
|
|
2358
|
-
return new
|
|
2359
|
+
return new ge({
|
|
2359
2360
|
...this._def,
|
|
2360
2361
|
minSize: { value: e, message: m.toString(t) }
|
|
2361
2362
|
});
|
|
2362
2363
|
}
|
|
2363
2364
|
max(e, t) {
|
|
2364
|
-
return new
|
|
2365
|
+
return new ge({
|
|
2365
2366
|
...this._def,
|
|
2366
2367
|
maxSize: { value: e, message: m.toString(t) }
|
|
2367
2368
|
});
|
|
@@ -2373,14 +2374,14 @@ class ye extends b {
|
|
|
2373
2374
|
return this.min(1, e);
|
|
2374
2375
|
}
|
|
2375
2376
|
}
|
|
2376
|
-
|
|
2377
|
+
ge.create = (a, e) => new ge({
|
|
2377
2378
|
valueType: a,
|
|
2378
2379
|
minSize: null,
|
|
2379
2380
|
maxSize: null,
|
|
2380
2381
|
typeName: v.ZodSet,
|
|
2381
2382
|
..._(e)
|
|
2382
2383
|
});
|
|
2383
|
-
class
|
|
2384
|
+
class we extends b {
|
|
2384
2385
|
constructor() {
|
|
2385
2386
|
super(...arguments), this.validate = this.implement;
|
|
2386
2387
|
}
|
|
@@ -2393,14 +2394,14 @@ class _e extends b {
|
|
|
2393
2394
|
received: t.parsedType
|
|
2394
2395
|
}), x;
|
|
2395
2396
|
function i(o, h) {
|
|
2396
|
-
return
|
|
2397
|
+
return Xe({
|
|
2397
2398
|
data: o,
|
|
2398
2399
|
path: t.path,
|
|
2399
2400
|
errorMaps: [
|
|
2400
2401
|
t.common.contextualErrorMap,
|
|
2401
2402
|
t.schemaErrorMap,
|
|
2402
2403
|
Ye(),
|
|
2403
|
-
|
|
2404
|
+
ke
|
|
2404
2405
|
].filter((c) => !!c),
|
|
2405
2406
|
issueData: {
|
|
2406
2407
|
code: u.invalid_arguments,
|
|
@@ -2409,14 +2410,14 @@ class _e extends b {
|
|
|
2409
2410
|
});
|
|
2410
2411
|
}
|
|
2411
2412
|
function s(o, h) {
|
|
2412
|
-
return
|
|
2413
|
+
return Xe({
|
|
2413
2414
|
data: o,
|
|
2414
2415
|
path: t.path,
|
|
2415
2416
|
errorMaps: [
|
|
2416
2417
|
t.common.contextualErrorMap,
|
|
2417
2418
|
t.schemaErrorMap,
|
|
2418
2419
|
Ye(),
|
|
2419
|
-
|
|
2420
|
+
ke
|
|
2420
2421
|
].filter((c) => !!c),
|
|
2421
2422
|
issueData: {
|
|
2422
2423
|
code: u.invalid_return_type,
|
|
@@ -2425,10 +2426,10 @@ class _e extends b {
|
|
|
2425
2426
|
});
|
|
2426
2427
|
}
|
|
2427
2428
|
const n = { errorMap: t.common.contextualErrorMap }, r = t.data;
|
|
2428
|
-
if (this._def.returns instanceof
|
|
2429
|
+
if (this._def.returns instanceof Ce) {
|
|
2429
2430
|
const o = this;
|
|
2430
|
-
return
|
|
2431
|
-
const c = new
|
|
2431
|
+
return M(async function(...h) {
|
|
2432
|
+
const c = new F([]), l = await o._def.args.parseAsync(h, n).catch((k) => {
|
|
2432
2433
|
throw c.addIssue(i(h, k)), c;
|
|
2433
2434
|
}), g = await Reflect.apply(r, this, l);
|
|
2434
2435
|
return await o._def.returns._def.type.parseAsync(g, n).catch((k) => {
|
|
@@ -2437,13 +2438,13 @@ class _e extends b {
|
|
|
2437
2438
|
});
|
|
2438
2439
|
} else {
|
|
2439
2440
|
const o = this;
|
|
2440
|
-
return
|
|
2441
|
+
return M(function(...h) {
|
|
2441
2442
|
const c = o._def.args.safeParse(h, n);
|
|
2442
2443
|
if (!c.success)
|
|
2443
|
-
throw new
|
|
2444
|
+
throw new F([i(h, c.error)]);
|
|
2444
2445
|
const l = Reflect.apply(r, this, c.data), g = o._def.returns.safeParse(l, n);
|
|
2445
2446
|
if (!g.success)
|
|
2446
|
-
throw new
|
|
2447
|
+
throw new F([s(l, g.error)]);
|
|
2447
2448
|
return g.data;
|
|
2448
2449
|
});
|
|
2449
2450
|
}
|
|
@@ -2455,13 +2456,13 @@ class _e extends b {
|
|
|
2455
2456
|
return this._def.returns;
|
|
2456
2457
|
}
|
|
2457
2458
|
args(...e) {
|
|
2458
|
-
return new
|
|
2459
|
+
return new we({
|
|
2459
2460
|
...this._def,
|
|
2460
|
-
args:
|
|
2461
|
+
args: W.create(e).rest(ue.create())
|
|
2461
2462
|
});
|
|
2462
2463
|
}
|
|
2463
2464
|
returns(e) {
|
|
2464
|
-
return new
|
|
2465
|
+
return new we({
|
|
2465
2466
|
...this._def,
|
|
2466
2467
|
returns: e
|
|
2467
2468
|
});
|
|
@@ -2473,15 +2474,15 @@ class _e extends b {
|
|
|
2473
2474
|
return this.parse(e);
|
|
2474
2475
|
}
|
|
2475
2476
|
static create(e, t, i) {
|
|
2476
|
-
return new
|
|
2477
|
-
args: e ||
|
|
2478
|
-
returns: t ||
|
|
2477
|
+
return new we({
|
|
2478
|
+
args: e || W.create([]).rest(ue.create()),
|
|
2479
|
+
returns: t || ue.create(),
|
|
2479
2480
|
typeName: v.ZodFunction,
|
|
2480
2481
|
..._(i)
|
|
2481
2482
|
});
|
|
2482
2483
|
}
|
|
2483
2484
|
}
|
|
2484
|
-
class
|
|
2485
|
+
class Le extends b {
|
|
2485
2486
|
get schema() {
|
|
2486
2487
|
return this._def.getter();
|
|
2487
2488
|
}
|
|
@@ -2490,12 +2491,12 @@ class ze extends b {
|
|
|
2490
2491
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2491
2492
|
}
|
|
2492
2493
|
}
|
|
2493
|
-
|
|
2494
|
+
Le.create = (a, e) => new Le({
|
|
2494
2495
|
getter: a,
|
|
2495
2496
|
typeName: v.ZodLazy,
|
|
2496
2497
|
..._(e)
|
|
2497
2498
|
});
|
|
2498
|
-
class
|
|
2499
|
+
class Ee extends b {
|
|
2499
2500
|
_parse(e) {
|
|
2500
2501
|
if (e.data !== this._def.value) {
|
|
2501
2502
|
const t = this._getOrReturnCtx(e);
|
|
@@ -2511,21 +2512,21 @@ class De extends b {
|
|
|
2511
2512
|
return this._def.value;
|
|
2512
2513
|
}
|
|
2513
2514
|
}
|
|
2514
|
-
|
|
2515
|
+
Ee.create = (a, e) => new Ee({
|
|
2515
2516
|
value: a,
|
|
2516
2517
|
typeName: v.ZodLiteral,
|
|
2517
2518
|
..._(e)
|
|
2518
2519
|
});
|
|
2519
|
-
function
|
|
2520
|
-
return new
|
|
2520
|
+
function It(a, e) {
|
|
2521
|
+
return new ie({
|
|
2521
2522
|
values: a,
|
|
2522
2523
|
typeName: v.ZodEnum,
|
|
2523
2524
|
..._(e)
|
|
2524
2525
|
});
|
|
2525
2526
|
}
|
|
2526
|
-
class
|
|
2527
|
+
class ie extends b {
|
|
2527
2528
|
constructor() {
|
|
2528
|
-
super(...arguments),
|
|
2529
|
+
super(...arguments), ve.set(this, void 0);
|
|
2529
2530
|
}
|
|
2530
2531
|
_parse(e) {
|
|
2531
2532
|
if (typeof e.data != "string") {
|
|
@@ -2536,7 +2537,7 @@ class se extends b {
|
|
|
2536
2537
|
code: u.invalid_type
|
|
2537
2538
|
}), x;
|
|
2538
2539
|
}
|
|
2539
|
-
if (
|
|
2540
|
+
if (Oe(this, ve) || Pt(this, ve, new Set(this._def.values)), !Oe(this, ve).has(e.data)) {
|
|
2540
2541
|
const t = this._getOrReturnCtx(e), i = this._def.values;
|
|
2541
2542
|
return d(t, {
|
|
2542
2543
|
received: t.data,
|
|
@@ -2544,7 +2545,7 @@ class se extends b {
|
|
|
2544
2545
|
options: i
|
|
2545
2546
|
}), x;
|
|
2546
2547
|
}
|
|
2547
|
-
return
|
|
2548
|
+
return M(e.data);
|
|
2548
2549
|
}
|
|
2549
2550
|
get options() {
|
|
2550
2551
|
return this._def.values;
|
|
@@ -2568,23 +2569,23 @@ class se extends b {
|
|
|
2568
2569
|
return e;
|
|
2569
2570
|
}
|
|
2570
2571
|
extract(e, t = this._def) {
|
|
2571
|
-
return
|
|
2572
|
+
return ie.create(e, {
|
|
2572
2573
|
...this._def,
|
|
2573
2574
|
...t
|
|
2574
2575
|
});
|
|
2575
2576
|
}
|
|
2576
2577
|
exclude(e, t = this._def) {
|
|
2577
|
-
return
|
|
2578
|
+
return ie.create(this.options.filter((i) => !e.includes(i)), {
|
|
2578
2579
|
...this._def,
|
|
2579
2580
|
...t
|
|
2580
2581
|
});
|
|
2581
2582
|
}
|
|
2582
2583
|
}
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
class
|
|
2584
|
+
ve = /* @__PURE__ */ new WeakMap();
|
|
2585
|
+
ie.create = It;
|
|
2586
|
+
class Me extends b {
|
|
2586
2587
|
constructor() {
|
|
2587
|
-
super(...arguments),
|
|
2588
|
+
super(...arguments), xe.set(this, void 0);
|
|
2588
2589
|
}
|
|
2589
2590
|
_parse(e) {
|
|
2590
2591
|
const t = C.getValidEnumValues(this._def.values), i = this._getOrReturnCtx(e);
|
|
@@ -2596,7 +2597,7 @@ class Ne extends b {
|
|
|
2596
2597
|
code: u.invalid_type
|
|
2597
2598
|
}), x;
|
|
2598
2599
|
}
|
|
2599
|
-
if (
|
|
2600
|
+
if (Oe(this, xe) || Pt(this, xe, new Set(C.getValidEnumValues(this._def.values))), !Oe(this, xe).has(e.data)) {
|
|
2600
2601
|
const s = C.objectValues(t);
|
|
2601
2602
|
return d(i, {
|
|
2602
2603
|
received: i.data,
|
|
@@ -2604,19 +2605,19 @@ class Ne extends b {
|
|
|
2604
2605
|
options: s
|
|
2605
2606
|
}), x;
|
|
2606
2607
|
}
|
|
2607
|
-
return
|
|
2608
|
+
return M(e.data);
|
|
2608
2609
|
}
|
|
2609
2610
|
get enum() {
|
|
2610
2611
|
return this._def.values;
|
|
2611
2612
|
}
|
|
2612
2613
|
}
|
|
2613
|
-
|
|
2614
|
-
|
|
2614
|
+
xe = /* @__PURE__ */ new WeakMap();
|
|
2615
|
+
Me.create = (a, e) => new Me({
|
|
2615
2616
|
values: a,
|
|
2616
2617
|
typeName: v.ZodNativeEnum,
|
|
2617
2618
|
..._(e)
|
|
2618
2619
|
});
|
|
2619
|
-
class
|
|
2620
|
+
class Ce extends b {
|
|
2620
2621
|
unwrap() {
|
|
2621
2622
|
return this._def.type;
|
|
2622
2623
|
}
|
|
@@ -2629,13 +2630,13 @@ class Se extends b {
|
|
|
2629
2630
|
received: t.parsedType
|
|
2630
2631
|
}), x;
|
|
2631
2632
|
const i = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
|
|
2632
|
-
return
|
|
2633
|
+
return M(i.then((s) => this._def.type.parseAsync(s, {
|
|
2633
2634
|
path: t.path,
|
|
2634
2635
|
errorMap: t.common.contextualErrorMap
|
|
2635
2636
|
})));
|
|
2636
2637
|
}
|
|
2637
2638
|
}
|
|
2638
|
-
|
|
2639
|
+
Ce.create = (a, e) => new Ce({
|
|
2639
2640
|
type: a,
|
|
2640
2641
|
typeName: v.ZodPromise,
|
|
2641
2642
|
..._(e)
|
|
@@ -2667,7 +2668,7 @@ class Y extends b {
|
|
|
2667
2668
|
path: i.path,
|
|
2668
2669
|
parent: i
|
|
2669
2670
|
});
|
|
2670
|
-
return h.status === "aborted" ? x : h.status === "dirty" || t.value === "dirty" ?
|
|
2671
|
+
return h.status === "aborted" ? x : h.status === "dirty" || t.value === "dirty" ? ye(h.value) : h;
|
|
2671
2672
|
});
|
|
2672
2673
|
{
|
|
2673
2674
|
if (t.value === "aborted")
|
|
@@ -2677,7 +2678,7 @@ class Y extends b {
|
|
|
2677
2678
|
path: i.path,
|
|
2678
2679
|
parent: i
|
|
2679
2680
|
});
|
|
2680
|
-
return o.status === "aborted" ? x : o.status === "dirty" || t.value === "dirty" ?
|
|
2681
|
+
return o.status === "aborted" ? x : o.status === "dirty" || t.value === "dirty" ? ye(o.value) : o;
|
|
2681
2682
|
}
|
|
2682
2683
|
}
|
|
2683
2684
|
if (s.type === "refinement") {
|
|
@@ -2706,14 +2707,14 @@ class Y extends b {
|
|
|
2706
2707
|
path: i.path,
|
|
2707
2708
|
parent: i
|
|
2708
2709
|
});
|
|
2709
|
-
if (!
|
|
2710
|
+
if (!fe(r))
|
|
2710
2711
|
return r;
|
|
2711
2712
|
const o = s.transform(r.value, n);
|
|
2712
2713
|
if (o instanceof Promise)
|
|
2713
2714
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2714
2715
|
return { status: t.value, value: o };
|
|
2715
2716
|
} else
|
|
2716
|
-
return this._def.schema._parseAsync({ data: i.data, path: i.path, parent: i }).then((r) =>
|
|
2717
|
+
return this._def.schema._parseAsync({ data: i.data, path: i.path, parent: i }).then((r) => fe(r) ? Promise.resolve(s.transform(r.value, n)).then((o) => ({ status: t.value, value: o })) : r);
|
|
2717
2718
|
C.assertNever(s);
|
|
2718
2719
|
}
|
|
2719
2720
|
}
|
|
@@ -2729,33 +2730,33 @@ Y.createWithPreprocess = (a, e, t) => new Y({
|
|
|
2729
2730
|
typeName: v.ZodEffects,
|
|
2730
2731
|
..._(t)
|
|
2731
2732
|
});
|
|
2732
|
-
class
|
|
2733
|
+
class U extends b {
|
|
2733
2734
|
_parse(e) {
|
|
2734
|
-
return this._getType(e) === f.undefined ?
|
|
2735
|
+
return this._getType(e) === f.undefined ? M(void 0) : this._def.innerType._parse(e);
|
|
2735
2736
|
}
|
|
2736
2737
|
unwrap() {
|
|
2737
2738
|
return this._def.innerType;
|
|
2738
2739
|
}
|
|
2739
2740
|
}
|
|
2740
|
-
|
|
2741
|
+
U.create = (a, e) => new U({
|
|
2741
2742
|
innerType: a,
|
|
2742
2743
|
typeName: v.ZodOptional,
|
|
2743
2744
|
..._(e)
|
|
2744
2745
|
});
|
|
2745
|
-
class
|
|
2746
|
+
class se extends b {
|
|
2746
2747
|
_parse(e) {
|
|
2747
|
-
return this._getType(e) === f.null ?
|
|
2748
|
+
return this._getType(e) === f.null ? M(null) : this._def.innerType._parse(e);
|
|
2748
2749
|
}
|
|
2749
2750
|
unwrap() {
|
|
2750
2751
|
return this._def.innerType;
|
|
2751
2752
|
}
|
|
2752
2753
|
}
|
|
2753
|
-
|
|
2754
|
+
se.create = (a, e) => new se({
|
|
2754
2755
|
innerType: a,
|
|
2755
2756
|
typeName: v.ZodNullable,
|
|
2756
2757
|
..._(e)
|
|
2757
2758
|
});
|
|
2758
|
-
class
|
|
2759
|
+
class Fe extends b {
|
|
2759
2760
|
_parse(e) {
|
|
2760
2761
|
const { ctx: t } = this._processInputParams(e);
|
|
2761
2762
|
let i = t.data;
|
|
@@ -2769,13 +2770,13 @@ class Me extends b {
|
|
|
2769
2770
|
return this._def.innerType;
|
|
2770
2771
|
}
|
|
2771
2772
|
}
|
|
2772
|
-
|
|
2773
|
+
Fe.create = (a, e) => new Fe({
|
|
2773
2774
|
innerType: a,
|
|
2774
2775
|
typeName: v.ZodDefault,
|
|
2775
2776
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2776
2777
|
..._(e)
|
|
2777
2778
|
});
|
|
2778
|
-
class
|
|
2779
|
+
class Ne extends b {
|
|
2779
2780
|
_parse(e) {
|
|
2780
2781
|
const { ctx: t } = this._processInputParams(e), i = {
|
|
2781
2782
|
...t,
|
|
@@ -2794,7 +2795,7 @@ class Fe extends b {
|
|
|
2794
2795
|
status: "valid",
|
|
2795
2796
|
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2796
2797
|
get error() {
|
|
2797
|
-
return new
|
|
2798
|
+
return new F(i.common.issues);
|
|
2798
2799
|
},
|
|
2799
2800
|
input: i.data
|
|
2800
2801
|
})
|
|
@@ -2802,7 +2803,7 @@ class Fe extends b {
|
|
|
2802
2803
|
status: "valid",
|
|
2803
2804
|
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
2804
2805
|
get error() {
|
|
2805
|
-
return new
|
|
2806
|
+
return new F(i.common.issues);
|
|
2806
2807
|
},
|
|
2807
2808
|
input: i.data
|
|
2808
2809
|
})
|
|
@@ -2812,13 +2813,13 @@ class Fe extends b {
|
|
|
2812
2813
|
return this._def.innerType;
|
|
2813
2814
|
}
|
|
2814
2815
|
}
|
|
2815
|
-
|
|
2816
|
+
Ne.create = (a, e) => new Ne({
|
|
2816
2817
|
innerType: a,
|
|
2817
2818
|
typeName: v.ZodCatch,
|
|
2818
2819
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2819
2820
|
..._(e)
|
|
2820
2821
|
});
|
|
2821
|
-
class
|
|
2822
|
+
class it extends b {
|
|
2822
2823
|
_parse(e) {
|
|
2823
2824
|
if (this._getType(e) !== f.nan) {
|
|
2824
2825
|
const i = this._getOrReturnCtx(e);
|
|
@@ -2831,11 +2832,11 @@ class st extends b {
|
|
|
2831
2832
|
return { status: "valid", value: e.data };
|
|
2832
2833
|
}
|
|
2833
2834
|
}
|
|
2834
|
-
|
|
2835
|
+
it.create = (a) => new it({
|
|
2835
2836
|
typeName: v.ZodNaN,
|
|
2836
2837
|
..._(a)
|
|
2837
2838
|
});
|
|
2838
|
-
class
|
|
2839
|
+
class Lt extends b {
|
|
2839
2840
|
_parse(e) {
|
|
2840
2841
|
const { ctx: t } = this._processInputParams(e), i = t.data;
|
|
2841
2842
|
return this._def.type._parse({
|
|
@@ -2858,7 +2859,7 @@ class Ke extends b {
|
|
|
2858
2859
|
path: i.path,
|
|
2859
2860
|
parent: i
|
|
2860
2861
|
});
|
|
2861
|
-
return n.status === "aborted" ? x : n.status === "dirty" ? (t.dirty(),
|
|
2862
|
+
return n.status === "aborted" ? x : n.status === "dirty" ? (t.dirty(), ye(n.value)) : this._def.out._parseAsync({
|
|
2862
2863
|
data: n.value,
|
|
2863
2864
|
path: i.path,
|
|
2864
2865
|
parent: i
|
|
@@ -2888,58 +2889,58 @@ class Ke extends b {
|
|
|
2888
2889
|
});
|
|
2889
2890
|
}
|
|
2890
2891
|
}
|
|
2891
|
-
class
|
|
2892
|
+
class De extends b {
|
|
2892
2893
|
_parse(e) {
|
|
2893
|
-
const t = this._def.innerType._parse(e), i = (s) => (
|
|
2894
|
+
const t = this._def.innerType._parse(e), i = (s) => (fe(s) && (s.value = Object.freeze(s.value)), s);
|
|
2894
2895
|
return Te(t) ? t.then((s) => i(s)) : i(t);
|
|
2895
2896
|
}
|
|
2896
2897
|
unwrap() {
|
|
2897
2898
|
return this._def.innerType;
|
|
2898
2899
|
}
|
|
2899
2900
|
}
|
|
2900
|
-
|
|
2901
|
+
De.create = (a, e) => new De({
|
|
2901
2902
|
innerType: a,
|
|
2902
2903
|
typeName: v.ZodReadonly,
|
|
2903
2904
|
..._(e)
|
|
2904
2905
|
});
|
|
2905
|
-
|
|
2906
|
+
P.lazycreate;
|
|
2906
2907
|
var v;
|
|
2907
2908
|
(function(a) {
|
|
2908
2909
|
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";
|
|
2909
2910
|
})(v || (v = {}));
|
|
2910
|
-
const
|
|
2911
|
-
|
|
2912
|
-
|
|
2911
|
+
const L = j.create, y = pe.create;
|
|
2912
|
+
it.create;
|
|
2913
|
+
me.create;
|
|
2913
2914
|
qe.create;
|
|
2914
|
-
|
|
2915
|
+
be.create;
|
|
2916
|
+
Ge.create;
|
|
2917
|
+
Ae.create;
|
|
2918
|
+
Pe.create;
|
|
2915
2919
|
Qe.create;
|
|
2916
|
-
|
|
2917
|
-
|
|
2920
|
+
ue.create;
|
|
2921
|
+
G.create;
|
|
2918
2922
|
Je.create;
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
at.create;
|
|
2923
|
+
Z.create;
|
|
2924
|
+
const O = P.create;
|
|
2925
|
+
P.strictCreate;
|
|
2926
|
+
const yi = Re.create;
|
|
2927
|
+
nt.create;
|
|
2928
|
+
ze.create;
|
|
2929
|
+
W.create;
|
|
2927
2930
|
Ie.create;
|
|
2928
|
-
|
|
2931
|
+
tt.create;
|
|
2932
|
+
ge.create;
|
|
2933
|
+
we.create;
|
|
2929
2934
|
Le.create;
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
ze.create;
|
|
2934
|
-
const ae = De.create, J = se.create;
|
|
2935
|
-
Ne.create;
|
|
2936
|
-
Se.create;
|
|
2935
|
+
const ne = Ee.create, Q = ie.create;
|
|
2936
|
+
Me.create;
|
|
2937
|
+
Ce.create;
|
|
2937
2938
|
Y.create;
|
|
2938
|
-
|
|
2939
|
-
|
|
2939
|
+
U.create;
|
|
2940
|
+
se.create;
|
|
2940
2941
|
Y.createWithPreprocess;
|
|
2941
2942
|
Ke.create;
|
|
2942
|
-
const
|
|
2943
|
+
const vi = Q(["linear", "bezier", "constant"]), xi = Q([
|
|
2943
2944
|
"ease",
|
|
2944
2945
|
"easeIn",
|
|
2945
2946
|
"easeOut",
|
|
@@ -2968,159 +2969,159 @@ const xi = J(["linear", "bezier", "constant"]), wi = J([
|
|
|
2968
2969
|
"easeInOutExpo",
|
|
2969
2970
|
"easeInOutCirc",
|
|
2970
2971
|
"easeInOutBack"
|
|
2971
|
-
]),
|
|
2972
|
+
]), ae = O({
|
|
2972
2973
|
from: y(),
|
|
2973
2974
|
to: y(),
|
|
2974
2975
|
start: y().min(0),
|
|
2975
2976
|
length: y().positive(),
|
|
2976
|
-
interpolation:
|
|
2977
|
-
easing:
|
|
2978
|
-
}),
|
|
2977
|
+
interpolation: vi.optional(),
|
|
2978
|
+
easing: xi.optional()
|
|
2979
|
+
}), wi = L().url("Invalid audio url format."), _i = ae.extend({
|
|
2979
2980
|
from: y().min(0).max(1),
|
|
2980
2981
|
to: y().min(0).max(1)
|
|
2981
|
-
}).array().or(y().min(0).max(1)),
|
|
2982
|
-
type:
|
|
2983
|
-
src:
|
|
2982
|
+
}).array().or(y().min(0).max(1)), yt = O({
|
|
2983
|
+
type: ne("audio"),
|
|
2984
|
+
src: wi,
|
|
2984
2985
|
trim: y().optional(),
|
|
2985
|
-
volume:
|
|
2986
|
-
}),
|
|
2987
|
-
type:
|
|
2988
|
-
html:
|
|
2989
|
-
css:
|
|
2986
|
+
volume: _i.optional()
|
|
2987
|
+
}), ki = Q(["top", "topRight", "right", "bottomRight", "bottom", "bottomLeft", "left", "topLeft", "center"]), vt = O({
|
|
2988
|
+
type: ne("html"),
|
|
2989
|
+
html: L(),
|
|
2990
|
+
css: L(),
|
|
2990
2991
|
width: y().positive().optional(),
|
|
2991
2992
|
height: y().positive().optional(),
|
|
2992
|
-
position:
|
|
2993
|
-
}),
|
|
2993
|
+
position: ki.optional()
|
|
2994
|
+
}), bi = L().url("Invalid image url format."), Ci = O({
|
|
2994
2995
|
top: y().min(0).optional(),
|
|
2995
2996
|
right: y().min(0).optional(),
|
|
2996
2997
|
bottom: y().min(0).optional(),
|
|
2997
2998
|
left: y().min(0).optional()
|
|
2998
|
-
}),
|
|
2999
|
-
type:
|
|
3000
|
-
src:
|
|
3001
|
-
crop:
|
|
3002
|
-
}),
|
|
3003
|
-
type:
|
|
3004
|
-
src:
|
|
3005
|
-
}),
|
|
2999
|
+
}), xt = O({
|
|
3000
|
+
type: ne("image"),
|
|
3001
|
+
src: bi,
|
|
3002
|
+
crop: Ci.optional()
|
|
3003
|
+
}), Si = L().url("Invalid luma url format."), wt = O({
|
|
3004
|
+
type: ne("luma"),
|
|
3005
|
+
src: Si
|
|
3006
|
+
}), Et = L().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/, "Invalid color format."), _t = O({
|
|
3006
3007
|
width: y().positive(),
|
|
3007
3008
|
height: y().positive()
|
|
3008
|
-
}),
|
|
3009
|
+
}), kt = O({
|
|
3009
3010
|
radius: y().positive()
|
|
3010
|
-
}),
|
|
3011
|
+
}), bt = O({
|
|
3011
3012
|
length: y().positive(),
|
|
3012
3013
|
thickness: y().positive()
|
|
3013
|
-
}), Ti =
|
|
3014
|
-
color:
|
|
3014
|
+
}), Ti = O({
|
|
3015
|
+
color: Et,
|
|
3015
3016
|
opacity: y().min(0).max(1)
|
|
3016
|
-
}),
|
|
3017
|
-
color:
|
|
3017
|
+
}), Oi = O({
|
|
3018
|
+
color: Et,
|
|
3018
3019
|
width: y().positive()
|
|
3019
|
-
}),
|
|
3020
|
-
type:
|
|
3020
|
+
}), Ct = O({
|
|
3021
|
+
type: ne("shape"),
|
|
3021
3022
|
width: y().positive().optional(),
|
|
3022
3023
|
height: y().positive().optional(),
|
|
3023
|
-
shape:
|
|
3024
|
+
shape: Q(["rectangle", "circle", "line"]),
|
|
3024
3025
|
fill: Ti.optional(),
|
|
3025
|
-
stroke:
|
|
3026
|
-
rectangle:
|
|
3027
|
-
circle:
|
|
3028
|
-
line:
|
|
3029
|
-
}).refine((a) => a.shape === "rectangle" ?
|
|
3030
|
-
color:
|
|
3031
|
-
family:
|
|
3026
|
+
stroke: Oi.optional(),
|
|
3027
|
+
rectangle: _t.optional(),
|
|
3028
|
+
circle: kt.optional(),
|
|
3029
|
+
line: bt.optional()
|
|
3030
|
+
}).refine((a) => a.shape === "rectangle" ? _t.safeParse(a.rectangle) : a.shape === "circle" ? kt.safeParse(a.circle) : a.shape === "line" ? bt.safeParse(a.line) : !1), at = L().regex(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|transparent$/, "Invalid color format."), Ai = O({
|
|
3031
|
+
color: at.optional(),
|
|
3032
|
+
family: L().optional(),
|
|
3032
3033
|
size: y().positive().optional(),
|
|
3033
3034
|
weight: y().optional(),
|
|
3034
3035
|
lineHeight: y().optional()
|
|
3035
|
-
}),
|
|
3036
|
-
horizontal:
|
|
3037
|
-
vertical:
|
|
3038
|
-
}),
|
|
3039
|
-
color:
|
|
3036
|
+
}), Pi = O({
|
|
3037
|
+
horizontal: Q(["left", "center", "right"]).optional(),
|
|
3038
|
+
vertical: Q(["top", "center", "bottom"]).optional()
|
|
3039
|
+
}), Ri = O({
|
|
3040
|
+
color: at,
|
|
3040
3041
|
opacity: y().min(0).max(1)
|
|
3041
|
-
}),
|
|
3042
|
+
}), zi = O({
|
|
3042
3043
|
width: y().positive(),
|
|
3043
|
-
color:
|
|
3044
|
-
}),
|
|
3045
|
-
type:
|
|
3046
|
-
text:
|
|
3044
|
+
color: at
|
|
3045
|
+
}), St = O({
|
|
3046
|
+
type: ne("text"),
|
|
3047
|
+
text: L(),
|
|
3047
3048
|
width: y().positive().optional(),
|
|
3048
3049
|
height: y().positive().optional(),
|
|
3049
|
-
font:
|
|
3050
|
-
alignment:
|
|
3051
|
-
background:
|
|
3052
|
-
stroke:
|
|
3053
|
-
}),
|
|
3050
|
+
font: Ai.optional(),
|
|
3051
|
+
alignment: Pi.optional(),
|
|
3052
|
+
background: Ri.optional(),
|
|
3053
|
+
stroke: zi.optional()
|
|
3054
|
+
}), Ii = L().url("Invalid video url format."), Li = O({
|
|
3054
3055
|
top: y().min(0).optional(),
|
|
3055
3056
|
right: y().min(0).optional(),
|
|
3056
3057
|
bottom: y().min(0).optional(),
|
|
3057
3058
|
left: y().min(0).optional()
|
|
3058
|
-
}),
|
|
3059
|
+
}), Ei = ae.extend({
|
|
3059
3060
|
from: y().min(0).max(1),
|
|
3060
3061
|
to: y().min(0).max(1)
|
|
3061
|
-
}).array().or(y().min(0).max(1)), Tt =
|
|
3062
|
-
type:
|
|
3063
|
-
src:
|
|
3062
|
+
}).array().or(y().min(0).max(1)), Tt = O({
|
|
3063
|
+
type: ne("video"),
|
|
3064
|
+
src: Ii,
|
|
3064
3065
|
trim: y().optional(),
|
|
3065
|
-
crop:
|
|
3066
|
-
volume:
|
|
3067
|
-
}),
|
|
3068
|
-
from:
|
|
3069
|
-
to:
|
|
3070
|
-
}).array().or(
|
|
3071
|
-
from:
|
|
3072
|
-
to:
|
|
3073
|
-
}).array().or(
|
|
3074
|
-
x:
|
|
3075
|
-
y:
|
|
3076
|
-
}), Hi =
|
|
3066
|
+
crop: Li.optional(),
|
|
3067
|
+
volume: Ei.optional()
|
|
3068
|
+
}), Mi = yi([St, Ct, vt, xt, Tt, wt, yt]).refine((a) => a.type === "text" ? St.safeParse(a) : a.type === "shape" ? Ct.safeParse(a) : a.type === "html" ? vt.safeParse(a) : a.type === "image" ? xt.safeParse(a) : a.type === "video" ? Tt.safeParse(a) : a.type === "luma" ? wt.safeParse(a) : a.type === "audio" ? yt.safeParse(a) : !1), Fi = Q(["topLeft", "top", "topRight", "left", "center", "right", "bottomLeft", "bottom", "bottomRight"]), Ni = Q(["crop", "cover", "contain", "none"]), de = y().min(-10).max(10).default(0), Di = ae.extend({
|
|
3069
|
+
from: de,
|
|
3070
|
+
to: de
|
|
3071
|
+
}).array().or(de), Zi = ae.extend({
|
|
3072
|
+
from: de,
|
|
3073
|
+
to: de
|
|
3074
|
+
}).array().or(de), Ki = O({
|
|
3075
|
+
x: Di.default(0),
|
|
3076
|
+
y: Zi.default(0)
|
|
3077
|
+
}), Hi = ae.extend({
|
|
3077
3078
|
from: y().min(0).max(1),
|
|
3078
3079
|
to: y().min(0).max(1)
|
|
3079
|
-
}).array().or(y().min(0).max(1)),
|
|
3080
|
+
}).array().or(y().min(0).max(1)), Bi = ae.extend({
|
|
3080
3081
|
from: y().min(0),
|
|
3081
3082
|
to: y().min(0)
|
|
3082
|
-
}).array().or(y().min(0)),
|
|
3083
|
-
angle:
|
|
3083
|
+
}).array().or(y().min(0)), Vi = O({
|
|
3084
|
+
angle: ae.extend({
|
|
3084
3085
|
from: y(),
|
|
3085
3086
|
to: y()
|
|
3086
3087
|
}).array().or(y())
|
|
3087
|
-
}),
|
|
3088
|
-
in:
|
|
3089
|
-
out:
|
|
3090
|
-
}),
|
|
3091
|
-
rotate:
|
|
3092
|
-
}), Mt =
|
|
3093
|
-
asset:
|
|
3088
|
+
}), $i = L(), Ot = L(), ji = O({
|
|
3089
|
+
in: Ot.optional(),
|
|
3090
|
+
out: Ot.optional()
|
|
3091
|
+
}), Ui = O({
|
|
3092
|
+
rotate: Vi.default({ angle: 0 })
|
|
3093
|
+
}), Mt = O({
|
|
3094
|
+
asset: Mi,
|
|
3094
3095
|
start: y().min(0),
|
|
3095
3096
|
length: y().positive(),
|
|
3096
|
-
position:
|
|
3097
|
-
fit:
|
|
3097
|
+
position: Fi.default("center").optional(),
|
|
3098
|
+
fit: Ni.default("crop").optional(),
|
|
3098
3099
|
offset: Ki.default({ x: 0, y: 0 }).optional(),
|
|
3099
3100
|
opacity: Hi.default(1).optional(),
|
|
3100
|
-
scale:
|
|
3101
|
-
transform:
|
|
3102
|
-
effect:
|
|
3103
|
-
transition:
|
|
3104
|
-
}),
|
|
3101
|
+
scale: Bi.default(1).optional(),
|
|
3102
|
+
transform: Ui.default({ rotate: { angle: 0 } }).optional(),
|
|
3103
|
+
effect: $i.optional(),
|
|
3104
|
+
transition: ji.optional()
|
|
3105
|
+
}), Wi = O({
|
|
3105
3106
|
clips: Mt.array()
|
|
3106
|
-
}), Yi =
|
|
3107
|
+
}), Yi = L().url("Invalid image url format."), Xi = O({
|
|
3107
3108
|
src: Yi
|
|
3108
|
-
}), qi =
|
|
3109
|
-
background:
|
|
3110
|
-
fonts:
|
|
3111
|
-
tracks:
|
|
3112
|
-
}),
|
|
3113
|
-
size:
|
|
3109
|
+
}), qi = O({
|
|
3110
|
+
background: L().optional(),
|
|
3111
|
+
fonts: Xi.array().optional(),
|
|
3112
|
+
tracks: Wi.array()
|
|
3113
|
+
}), Gi = O({
|
|
3114
|
+
size: O({
|
|
3114
3115
|
width: y().positive(),
|
|
3115
3116
|
height: y().positive()
|
|
3116
3117
|
}),
|
|
3117
3118
|
fps: y().positive().optional(),
|
|
3118
|
-
format:
|
|
3119
|
-
}),
|
|
3119
|
+
format: L()
|
|
3120
|
+
}), Qi = O({
|
|
3120
3121
|
timeline: qi,
|
|
3121
|
-
output:
|
|
3122
|
+
output: Gi
|
|
3122
3123
|
});
|
|
3123
|
-
class
|
|
3124
|
+
class Ji {
|
|
3124
3125
|
curves = {};
|
|
3125
3126
|
constructor() {
|
|
3126
3127
|
this.initializeCurves();
|
|
@@ -3242,16 +3243,16 @@ class es {
|
|
|
3242
3243
|
};
|
|
3243
3244
|
}
|
|
3244
3245
|
getValue(e, t, i, s) {
|
|
3245
|
-
const n = this.curves[s ?? ""] ?? this.curves.ease, [[r, o], [h, c]] = n, l = i + (3 * r - 3 * h + 1) * i * (1 - i), g = e, p = e + (t - e) * o, k = e + (t - e) * c,
|
|
3246
|
-
return
|
|
3246
|
+
const n = this.curves[s ?? ""] ?? this.curves.ease, [[r, o], [h, c]] = n, l = i + (3 * r - 3 * h + 1) * i * (1 - i), g = e, p = e + (t - e) * o, k = e + (t - e) * c, A = t, S = l, N = 1 - S;
|
|
3247
|
+
return N ** 3 * g + 3 * N ** 2 * S * p + 3 * N * S ** 2 * k + S ** 3 * A;
|
|
3247
3248
|
}
|
|
3248
3249
|
}
|
|
3249
|
-
class
|
|
3250
|
+
class R {
|
|
3250
3251
|
property;
|
|
3251
3252
|
length;
|
|
3252
3253
|
cubicBuilder;
|
|
3253
3254
|
constructor(e, t, i = 0) {
|
|
3254
|
-
this.property = this.createKeyframes(e, t, i), this.length = t, this.cubicBuilder = new
|
|
3255
|
+
this.property = this.createKeyframes(e, t, i), this.length = t, this.cubicBuilder = new Ji();
|
|
3255
3256
|
}
|
|
3256
3257
|
getValue(e) {
|
|
3257
3258
|
const t = this.property.find((s) => e >= s.start && e < s.start + s.length);
|
|
@@ -3350,7 +3351,7 @@ class He {
|
|
|
3350
3351
|
e?.unload();
|
|
3351
3352
|
}
|
|
3352
3353
|
}
|
|
3353
|
-
class
|
|
3354
|
+
class es {
|
|
3354
3355
|
clipConfiguration;
|
|
3355
3356
|
constructor(e) {
|
|
3356
3357
|
this.clipConfiguration = e;
|
|
@@ -3362,56 +3363,56 @@ class ts {
|
|
|
3362
3363
|
const l = 0;
|
|
3363
3364
|
switch (this.getPresetName()) {
|
|
3364
3365
|
case "zoomIn": {
|
|
3365
|
-
const p = this.getZoomSpeed(), k = 1 * this.clipConfiguration.scale,
|
|
3366
|
-
r.push({ from: k, to:
|
|
3366
|
+
const p = this.getZoomSpeed(), k = 1 * this.clipConfiguration.scale, A = p * this.clipConfiguration.scale;
|
|
3367
|
+
r.push({ from: k, to: A, start: l, length: c, interpolation: "linear" });
|
|
3367
3368
|
break;
|
|
3368
3369
|
}
|
|
3369
3370
|
case "zoomOut": {
|
|
3370
|
-
const k = this.getZoomSpeed() * this.clipConfiguration.scale,
|
|
3371
|
-
r.push({ from: k, to:
|
|
3371
|
+
const k = this.getZoomSpeed() * this.clipConfiguration.scale, A = 1 * this.clipConfiguration.scale;
|
|
3372
|
+
r.push({ from: k, to: A, start: l, length: c, interpolation: "linear" });
|
|
3372
3373
|
break;
|
|
3373
3374
|
}
|
|
3374
3375
|
case "slideLeft": {
|
|
3375
3376
|
let p = this.getSlideStart();
|
|
3376
|
-
const k = e.width + e.width * p * 2,
|
|
3377
|
-
if (
|
|
3377
|
+
const k = e.width + e.width * p * 2, A = t.height / t.width * e.height;
|
|
3378
|
+
if (A < k) {
|
|
3378
3379
|
const S = Math.abs(k / e.width);
|
|
3379
3380
|
r.push({ from: S, to: S, start: l, length: c, interpolation: "linear" });
|
|
3380
3381
|
} else
|
|
3381
|
-
p = (
|
|
3382
|
+
p = (A - e.width) / 2 / e.width;
|
|
3382
3383
|
i.push({ from: p, to: -p, start: l, length: c });
|
|
3383
3384
|
break;
|
|
3384
3385
|
}
|
|
3385
3386
|
case "slideRight": {
|
|
3386
3387
|
let p = this.getSlideStart();
|
|
3387
|
-
const k = e.width + e.width * p * 2,
|
|
3388
|
-
if (
|
|
3388
|
+
const k = e.width + e.width * p * 2, A = t.height / t.width * e.height;
|
|
3389
|
+
if (A < k) {
|
|
3389
3390
|
const S = Math.abs(k / e.width);
|
|
3390
3391
|
r.push({ from: S, to: S, start: l, length: c, interpolation: "linear" });
|
|
3391
3392
|
} else
|
|
3392
|
-
p = (
|
|
3393
|
+
p = (A - e.width) / 2 / e.width;
|
|
3393
3394
|
i.push({ from: -p, to: p, start: l, length: c });
|
|
3394
3395
|
break;
|
|
3395
3396
|
}
|
|
3396
3397
|
case "slideUp": {
|
|
3397
3398
|
let p = this.getSlideStart();
|
|
3398
|
-
const k = e.height + e.height * p * 2,
|
|
3399
|
-
if (
|
|
3399
|
+
const k = e.height + e.height * p * 2, A = t.height / t.width * e.width;
|
|
3400
|
+
if (A < k) {
|
|
3400
3401
|
const S = Math.abs(k / e.height);
|
|
3401
3402
|
r.push({ from: S, to: S, start: l, length: c, interpolation: "linear" });
|
|
3402
3403
|
} else
|
|
3403
|
-
p = (
|
|
3404
|
+
p = (A - e.height) / 2 / e.height;
|
|
3404
3405
|
s.push({ from: p, to: -p, start: l, length: c });
|
|
3405
3406
|
break;
|
|
3406
3407
|
}
|
|
3407
3408
|
case "slideDown": {
|
|
3408
3409
|
let p = this.getSlideStart();
|
|
3409
|
-
const k = e.height + e.height * p * 2,
|
|
3410
|
-
if (
|
|
3410
|
+
const k = e.height + e.height * p * 2, A = t.height / t.width * e.width;
|
|
3411
|
+
if (A < k) {
|
|
3411
3412
|
const S = Math.abs(k / e.height);
|
|
3412
3413
|
r.push({ from: S, to: S, start: l, length: c, interpolation: "linear" });
|
|
3413
3414
|
} else
|
|
3414
|
-
p = (
|
|
3415
|
+
p = (A - e.height) / 2 / e.height;
|
|
3415
3416
|
s.push({ from: -p, to: p, start: l, length: c });
|
|
3416
3417
|
break;
|
|
3417
3418
|
}
|
|
@@ -3449,7 +3450,7 @@ class ts {
|
|
|
3449
3450
|
return 0;
|
|
3450
3451
|
}
|
|
3451
3452
|
}
|
|
3452
|
-
class
|
|
3453
|
+
class ts {
|
|
3453
3454
|
clipConfiguration;
|
|
3454
3455
|
constructor(e) {
|
|
3455
3456
|
this.clipConfiguration = e;
|
|
@@ -3603,11 +3604,11 @@ class is {
|
|
|
3603
3604
|
}
|
|
3604
3605
|
}
|
|
3605
3606
|
}
|
|
3606
|
-
class
|
|
3607
|
+
class is {
|
|
3607
3608
|
static ButtonLeftClick = 0;
|
|
3608
3609
|
static ButtonRightClick = 3;
|
|
3609
3610
|
}
|
|
3610
|
-
class
|
|
3611
|
+
class ss {
|
|
3611
3612
|
containerSize;
|
|
3612
3613
|
constructor(e) {
|
|
3613
3614
|
this.containerSize = e;
|
|
@@ -3713,7 +3714,7 @@ class ns {
|
|
|
3713
3714
|
}
|
|
3714
3715
|
}
|
|
3715
3716
|
}
|
|
3716
|
-
class
|
|
3717
|
+
class rt {
|
|
3717
3718
|
container;
|
|
3718
3719
|
constructor() {
|
|
3719
3720
|
this.container = new w.Container();
|
|
@@ -3723,7 +3724,7 @@ class ot {
|
|
|
3723
3724
|
return this.container;
|
|
3724
3725
|
}
|
|
3725
3726
|
}
|
|
3726
|
-
class
|
|
3727
|
+
class z extends rt {
|
|
3727
3728
|
static SnapThreshold = 20;
|
|
3728
3729
|
static DiscardedFrameCount = Math.ceil(1 / 30 * 1e3);
|
|
3729
3730
|
static ScaleHandleRadius = 10;
|
|
@@ -3758,15 +3759,15 @@ class I extends ot {
|
|
|
3758
3759
|
rotationStart;
|
|
3759
3760
|
rotationOffset;
|
|
3760
3761
|
constructor(e, t) {
|
|
3761
|
-
super(), this.edit = e, this.layer = 0, this.shouldDispose = !1, this.clipConfiguration = t, this.positionBuilder = new
|
|
3762
|
+
super(), this.edit = e, this.layer = 0, this.shouldDispose = !1, this.clipConfiguration = t, this.positionBuilder = new ss(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 };
|
|
3762
3763
|
}
|
|
3763
3764
|
configureKeyframes() {
|
|
3764
|
-
if (this.offsetXKeyframeBuilder = new
|
|
3765
|
+
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())
|
|
3765
3766
|
return;
|
|
3766
|
-
const e = [], t = [], i = [], s = [], n = [], r = new
|
|
3767
|
+
const e = [], t = [], i = [], s = [], n = [], r = new es(this.clipConfiguration).build(this.edit.size, this.getSize());
|
|
3767
3768
|
e.push(...r.offsetXKeyframes), t.push(...r.offsetYKeyframes), i.push(...r.opacityKeyframes), s.push(...r.scaleKeyframes), n.push(...r.rotationKeyframes);
|
|
3768
|
-
const o = new
|
|
3769
|
-
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
|
|
3769
|
+
const o = new ts(this.clipConfiguration).build();
|
|
3770
|
+
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()));
|
|
3770
3771
|
}
|
|
3771
3772
|
async load() {
|
|
3772
3773
|
this.outline = new w.Graphics(), this.getContainer().addChild(this.outline), this.topLeftScaleHandle = new w.Graphics(), this.topRightScaleHandle = new w.Graphics(), this.bottomRightScaleHandle = new w.Graphics(), this.bottomLeftScaleHandle = new w.Graphics(), this.getContainer().addChild(this.topLeftScaleHandle), this.getContainer().addChild(this.topRightScaleHandle), this.getContainer().addChild(this.bottomRightScaleHandle), this.getContainer().addChild(this.bottomLeftScaleHandle), this.rotationHandle = new w.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));
|
|
@@ -3787,14 +3788,14 @@ class I extends ot {
|
|
|
3787
3788
|
return;
|
|
3788
3789
|
}
|
|
3789
3790
|
const e = this.isHovering || this.isDragging ? 65535 : 16777215, t = this.getSize(), i = this.getScale();
|
|
3790
|
-
if (this.outline.clear(), this.outline.strokeStyle = { width:
|
|
3791
|
+
if (this.outline.clear(), this.outline.strokeStyle = { width: z.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)
|
|
3791
3792
|
return;
|
|
3792
3793
|
this.topLeftScaleHandle.fillStyle = { color: e }, this.topLeftScaleHandle.clear();
|
|
3793
|
-
const s =
|
|
3794
|
+
const s = z.ScaleHandleRadius * 2 / i;
|
|
3794
3795
|
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)
|
|
3795
3796
|
return;
|
|
3796
3797
|
const n = t.width / 2, r = -50 / i;
|
|
3797
|
-
this.rotationHandle.clear(), this.rotationHandle.fillStyle = { color: e }, this.rotationHandle.circle(n, r,
|
|
3798
|
+
this.rotationHandle.clear(), this.rotationHandle.fillStyle = { color: e }, this.rotationHandle.circle(n, r, z.RotationHandleRadius / i), this.rotationHandle.fill(), this.outline.strokeStyle = { width: z.OutlineWidth / i, color: e }, this.outline.moveTo(n, 0), this.outline.lineTo(n, r), this.outline.stroke();
|
|
3798
3799
|
}
|
|
3799
3800
|
dispose() {
|
|
3800
3801
|
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;
|
|
@@ -3849,10 +3850,10 @@ class I extends ot {
|
|
|
3849
3850
|
return this.edit.playbackTime >= this.getStart() && this.edit.playbackTime < this.getEnd();
|
|
3850
3851
|
}
|
|
3851
3852
|
shouldDiscardFrame() {
|
|
3852
|
-
return this.getPlaybackTime() <
|
|
3853
|
+
return this.getPlaybackTime() < z.DiscardedFrameCount;
|
|
3853
3854
|
}
|
|
3854
3855
|
onPointerStart(e) {
|
|
3855
|
-
if (e.button !==
|
|
3856
|
+
if (e.button !== is.ButtonLeftClick || this.clipHasKeyframes())
|
|
3856
3857
|
return;
|
|
3857
3858
|
if (this.scaleDirection = null, this.topLeftScaleHandle?.getBounds().containsPoint(e.globalX, e.globalY) && (this.scaleDirection = "topLeft"), this.topRightScaleHandle?.getBounds().containsPoint(e.globalX, e.globalY) && (this.scaleDirection = "topRight"), this.bottomRightScaleHandle?.getBounds().containsPoint(e.globalX, e.globalY) && (this.scaleDirection = "bottomRight"), this.bottomLeftScaleHandle?.getBounds().containsPoint(e.globalX, e.globalY) && (this.scaleDirection = "bottomLeft"), this.scaleDirection !== null) {
|
|
3858
3859
|
this.scaleStart = this.getScale() / this.getFitScale();
|
|
@@ -3876,14 +3877,14 @@ class I extends ot {
|
|
|
3876
3877
|
onPointerMove(e) {
|
|
3877
3878
|
if (this.scaleDirection !== null && this.scaleStart !== null) {
|
|
3878
3879
|
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;
|
|
3879
|
-
this.clipConfiguration.scale = Math.max(
|
|
3880
|
+
this.clipConfiguration.scale = Math.max(z.MinScale, Math.min(c, z.MaxScale)), this.scaleKeyframeBuilder = new R(this.clipConfiguration.scale, this.getLength(), 1);
|
|
3880
3881
|
return;
|
|
3881
3882
|
}
|
|
3882
3883
|
if (this.isRotating && this.rotationStart !== null) {
|
|
3883
3884
|
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);
|
|
3884
3885
|
let c = this.rotationStart + h;
|
|
3885
3886
|
const l = 45, g = c % l, p = 2;
|
|
3886
|
-
Math.abs(g) < p ? c = Math.floor(c / l) * l : Math.abs(g - 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
|
|
3887
|
+
Math.abs(g) < p ? c = Math.floor(c / l) * l : Math.abs(g - 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());
|
|
3887
3888
|
return;
|
|
3888
3889
|
}
|
|
3889
3890
|
if (this.isDragging) {
|
|
@@ -3898,21 +3899,21 @@ class I extends ot {
|
|
|
3898
3899
|
{ x: n.x, y: n.y + this.getSize().height },
|
|
3899
3900
|
{ x: n.x + this.getSize().width, y: n.y + this.getSize().height }
|
|
3900
3901
|
], l = { x: n.x + this.getSize().width / 2, y: n.y + this.getSize().height / 2 }, g = [...c, l];
|
|
3901
|
-
let p =
|
|
3902
|
-
for (const
|
|
3903
|
-
for (const
|
|
3904
|
-
const H = Math.abs(
|
|
3905
|
-
H < p && (p = H,
|
|
3906
|
-
const
|
|
3907
|
-
|
|
3902
|
+
let p = z.SnapThreshold, k = z.SnapThreshold, A = null, S = null;
|
|
3903
|
+
for (const J of g)
|
|
3904
|
+
for (const re of h) {
|
|
3905
|
+
const H = Math.abs(J.x - re.x);
|
|
3906
|
+
H < p && (p = H, A = n.x + (re.x - J.x));
|
|
3907
|
+
const oe = Math.abs(J.y - re.y);
|
|
3908
|
+
oe < k && (k = oe, S = n.y + (re.y - J.y));
|
|
3908
3909
|
}
|
|
3909
|
-
|
|
3910
|
-
const
|
|
3910
|
+
A !== null && (n.x = A), S !== null && (n.y = S);
|
|
3911
|
+
const N = this.positionBuilder.absoluteToRelative(
|
|
3911
3912
|
this.getSize(),
|
|
3912
3913
|
this.clipConfiguration.position ?? "center",
|
|
3913
3914
|
n
|
|
3914
3915
|
);
|
|
3915
|
-
this.clipConfiguration.offset || (this.clipConfiguration.offset = { x: 0, y: 0 }), this.clipConfiguration.offset.x =
|
|
3916
|
+
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());
|
|
3916
3917
|
}
|
|
3917
3918
|
}
|
|
3918
3919
|
onPointerUp() {
|
|
@@ -3936,7 +3937,7 @@ class I extends ot {
|
|
|
3936
3937
|
].some((e) => e && typeof e != "number");
|
|
3937
3938
|
}
|
|
3938
3939
|
}
|
|
3939
|
-
class
|
|
3940
|
+
class st extends z {
|
|
3940
3941
|
audioResource;
|
|
3941
3942
|
isPlaying;
|
|
3942
3943
|
volumeKeyframeBuilder;
|
|
@@ -3944,12 +3945,12 @@ class nt extends I {
|
|
|
3944
3945
|
constructor(e, t) {
|
|
3945
3946
|
super(e, t), this.audioResource = null, this.isPlaying = !1;
|
|
3946
3947
|
const i = t.asset;
|
|
3947
|
-
this.volumeKeyframeBuilder = new
|
|
3948
|
+
this.volumeKeyframeBuilder = new R(i.volume ?? 1, this.getLength()), this.syncTimer = 0;
|
|
3948
3949
|
}
|
|
3949
3950
|
async load() {
|
|
3950
3951
|
await super.load();
|
|
3951
3952
|
const e = this.clipConfiguration.asset, t = e.src, i = { src: t, loadParser: He.Name }, s = await this.edit.assetLoader.load(t, i);
|
|
3952
|
-
if (!(s instanceof
|
|
3953
|
+
if (!(s instanceof $t.Howl))
|
|
3953
3954
|
throw new Error(`Invalid audio source '${e.src}'.`);
|
|
3954
3955
|
this.audioResource = s, this.configureKeyframes();
|
|
3955
3956
|
}
|
|
@@ -3976,7 +3977,7 @@ class nt extends I {
|
|
|
3976
3977
|
return this.volumeKeyframeBuilder.getValue(this.getPlaybackTime());
|
|
3977
3978
|
}
|
|
3978
3979
|
}
|
|
3979
|
-
var
|
|
3980
|
+
var ns = `in vec2 aPosition;
|
|
3980
3981
|
out vec2 vTextureCoord;
|
|
3981
3982
|
|
|
3982
3983
|
uniform vec4 uInputSize;
|
|
@@ -4003,7 +4004,7 @@ void main(void)
|
|
|
4003
4004
|
gl_Position = filterVertexPosition();
|
|
4004
4005
|
vTextureCoord = filterTextureCoord();
|
|
4005
4006
|
}
|
|
4006
|
-
`,
|
|
4007
|
+
`, as = `struct GlobalFilterUniforms {
|
|
4007
4008
|
uInputSize:vec4<f32>,
|
|
4008
4009
|
uInputPixel:vec4<f32>,
|
|
4009
4010
|
uInputClamp:vec4<f32>,
|
|
@@ -4052,7 +4053,7 @@ fn mainVertex(
|
|
|
4052
4053
|
filterVertexPosition(aPosition),
|
|
4053
4054
|
filterTextureCoord(aPosition)
|
|
4054
4055
|
);
|
|
4055
|
-
}`,
|
|
4056
|
+
}`, rs = `precision highp float;
|
|
4056
4057
|
in vec2 vTextureCoord;
|
|
4057
4058
|
out vec4 finalColor;
|
|
4058
4059
|
|
|
@@ -4093,7 +4094,7 @@ void main(void) {
|
|
|
4093
4094
|
vec4 outlineColor = vec4(vec3(uColor) * outlineAlpha, outlineAlpha);
|
|
4094
4095
|
finalColor = contentColor + outlineColor;
|
|
4095
4096
|
}
|
|
4096
|
-
`,
|
|
4097
|
+
`, os = `struct OutlineUniforms {
|
|
4097
4098
|
uThickness:vec2<f32>,
|
|
4098
4099
|
uColor:vec3<f32>,
|
|
4099
4100
|
uAlpha:f32,
|
|
@@ -4157,24 +4158,24 @@ fn outlineMaxAlphaAtPos(uv: vec2<f32>) -> f32 {
|
|
|
4157
4158
|
return maxAlpha;
|
|
4158
4159
|
}
|
|
4159
4160
|
|
|
4160
|
-
const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`,
|
|
4161
|
-
const
|
|
4161
|
+
const DOUBLE_PI: f32 = 3.14159265358979323846264 * 2.;`, cs = Object.defineProperty, ls = (a, e, t) => e in a ? cs(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, te = (a, e, t) => (ls(a, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4162
|
+
const Be = class ee extends Zt {
|
|
4162
4163
|
/** @ignore */
|
|
4163
4164
|
constructor(...e) {
|
|
4164
4165
|
let t = e[0] ?? {};
|
|
4165
|
-
typeof t == "number" && (
|
|
4166
|
-
const i = t.quality ?? 0.1, s =
|
|
4166
|
+
typeof t == "number" && (Kt("6.0.0", "OutlineFilter constructor params are now options object. See params: { thickness, color, quality, alpha, knockout }"), t = { thickness: t }, e[1] !== void 0 && (t.color = e[1]), e[2] !== void 0 && (t.quality = e[2]), e[3] !== void 0 && (t.alpha = e[3]), e[4] !== void 0 && (t.knockout = e[4])), t = { ...ee.DEFAULT_OPTIONS, ...t };
|
|
4167
|
+
const i = t.quality ?? 0.1, s = Ht.from({
|
|
4167
4168
|
vertex: {
|
|
4168
|
-
source:
|
|
4169
|
+
source: as,
|
|
4169
4170
|
entryPoint: "mainVertex"
|
|
4170
4171
|
},
|
|
4171
4172
|
fragment: {
|
|
4172
|
-
source:
|
|
4173
|
+
source: os,
|
|
4173
4174
|
entryPoint: "mainFragment"
|
|
4174
4175
|
}
|
|
4175
|
-
}), n =
|
|
4176
|
-
vertex:
|
|
4177
|
-
fragment:
|
|
4176
|
+
}), n = Bt.from({
|
|
4177
|
+
vertex: ns,
|
|
4178
|
+
fragment: rs.replace(/\$\{ANGLE_STEP\}/, ee.getAngleStep(i).toFixed(7)),
|
|
4178
4179
|
name: "outline-filter"
|
|
4179
4180
|
});
|
|
4180
4181
|
super({
|
|
@@ -4189,7 +4190,7 @@ const $e = class te extends Kt {
|
|
|
4189
4190
|
uKnockout: { value: t.knockout ? 1 : 0, type: "f32" }
|
|
4190
4191
|
}
|
|
4191
4192
|
}
|
|
4192
|
-
}),
|
|
4193
|
+
}), 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 Vt(), this.color = t.color ?? 0, Object.assign(this, t);
|
|
4193
4194
|
}
|
|
4194
4195
|
/**
|
|
4195
4196
|
* Override existing apply method in `Filter`
|
|
@@ -4205,8 +4206,8 @@ const $e = class te extends Kt {
|
|
|
4205
4206
|
*/
|
|
4206
4207
|
static getAngleStep(e) {
|
|
4207
4208
|
return parseFloat((Math.PI * 2 / Math.max(
|
|
4208
|
-
e *
|
|
4209
|
-
|
|
4209
|
+
e * ee.MAX_SAMPLES,
|
|
4210
|
+
ee.MIN_SAMPLES
|
|
4210
4211
|
)).toFixed(7));
|
|
4211
4212
|
}
|
|
4212
4213
|
/**
|
|
@@ -4251,7 +4252,7 @@ const $e = class te extends Kt {
|
|
|
4251
4252
|
return this._quality;
|
|
4252
4253
|
}
|
|
4253
4254
|
set quality(e) {
|
|
4254
|
-
this._quality = e, this.uniforms.uAngleStep =
|
|
4255
|
+
this._quality = e, this.uniforms.uAngleStep = ee.getAngleStep(e);
|
|
4255
4256
|
}
|
|
4256
4257
|
/**
|
|
4257
4258
|
* Whether to only render outline, not the contents.
|
|
@@ -4264,17 +4265,17 @@ const $e = class te extends Kt {
|
|
|
4264
4265
|
this.uniforms.uKnockout = e ? 1 : 0;
|
|
4265
4266
|
}
|
|
4266
4267
|
};
|
|
4267
|
-
|
|
4268
|
+
te(Be, "DEFAULT_OPTIONS", {
|
|
4268
4269
|
thickness: 1,
|
|
4269
4270
|
color: 0,
|
|
4270
4271
|
alpha: 1,
|
|
4271
4272
|
quality: 0.1,
|
|
4272
4273
|
knockout: !1
|
|
4273
4274
|
});
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
let
|
|
4277
|
-
class
|
|
4275
|
+
te(Be, "MIN_SAMPLES", 1);
|
|
4276
|
+
te(Be, "MAX_SAMPLES", 100);
|
|
4277
|
+
let ot = Be;
|
|
4278
|
+
class hs extends z {
|
|
4278
4279
|
background;
|
|
4279
4280
|
text;
|
|
4280
4281
|
constructor(e, t) {
|
|
@@ -4308,7 +4309,7 @@ class us extends I {
|
|
|
4308
4309
|
x: o,
|
|
4309
4310
|
y: h
|
|
4310
4311
|
}, t.stroke.color && t.stroke.width) {
|
|
4311
|
-
const c = new
|
|
4312
|
+
const c = new ot({
|
|
4312
4313
|
thickness: t.stroke.width,
|
|
4313
4314
|
color: t.stroke.color
|
|
4314
4315
|
});
|
|
@@ -4383,7 +4384,7 @@ class us extends I {
|
|
|
4383
4384
|
}
|
|
4384
4385
|
}
|
|
4385
4386
|
}
|
|
4386
|
-
class
|
|
4387
|
+
class us extends z {
|
|
4387
4388
|
texture;
|
|
4388
4389
|
sprite;
|
|
4389
4390
|
constructor(e, t) {
|
|
@@ -4420,7 +4421,7 @@ class ds extends I {
|
|
|
4420
4421
|
return new w.Texture({ source: e.source, frame: k });
|
|
4421
4422
|
}
|
|
4422
4423
|
}
|
|
4423
|
-
class
|
|
4424
|
+
class ds extends z {
|
|
4424
4425
|
shape;
|
|
4425
4426
|
shapeBackground;
|
|
4426
4427
|
constructor(e, t) {
|
|
@@ -4455,7 +4456,7 @@ class fs extends I {
|
|
|
4455
4456
|
color: e.fill?.color ?? "#ffffff",
|
|
4456
4457
|
alpha: e.fill?.opacity ?? 1
|
|
4457
4458
|
}, n.fill(), e.stroke) {
|
|
4458
|
-
const r = new
|
|
4459
|
+
const r = new ot({
|
|
4459
4460
|
thickness: e.stroke.width,
|
|
4460
4461
|
color: e.stroke.color
|
|
4461
4462
|
});
|
|
@@ -4483,7 +4484,7 @@ class fs extends I {
|
|
|
4483
4484
|
return 1;
|
|
4484
4485
|
}
|
|
4485
4486
|
}
|
|
4486
|
-
class
|
|
4487
|
+
class fs extends z {
|
|
4487
4488
|
background;
|
|
4488
4489
|
text;
|
|
4489
4490
|
constructor(e, t) {
|
|
@@ -4514,7 +4515,7 @@ class ps extends I {
|
|
|
4514
4515
|
x: r,
|
|
4515
4516
|
y: o
|
|
4516
4517
|
}, e.stroke) {
|
|
4517
|
-
const h = new
|
|
4518
|
+
const h = new ot({
|
|
4518
4519
|
thickness: e.stroke.width,
|
|
4519
4520
|
color: e.stroke.color
|
|
4520
4521
|
});
|
|
@@ -4542,7 +4543,7 @@ class ps extends I {
|
|
|
4542
4543
|
return 1;
|
|
4543
4544
|
}
|
|
4544
4545
|
}
|
|
4545
|
-
class
|
|
4546
|
+
class ps extends z {
|
|
4546
4547
|
texture;
|
|
4547
4548
|
sprite;
|
|
4548
4549
|
isPlaying;
|
|
@@ -4551,7 +4552,7 @@ class ms extends I {
|
|
|
4551
4552
|
constructor(e, t) {
|
|
4552
4553
|
super(e, t), this.texture = null, this.sprite = null, this.isPlaying = !1;
|
|
4553
4554
|
const i = this.clipConfiguration.asset;
|
|
4554
|
-
this.volumeKeyframeBuilder = new
|
|
4555
|
+
this.volumeKeyframeBuilder = new R(i.volume ?? 1, this.getLength()), this.syncTimer = 0;
|
|
4555
4556
|
}
|
|
4556
4557
|
/**
|
|
4557
4558
|
* TODO: Add support for .mov and .webm files
|
|
@@ -4596,7 +4597,7 @@ class ms extends I {
|
|
|
4596
4597
|
return new w.Texture({ source: e.source, frame: k });
|
|
4597
4598
|
}
|
|
4598
4599
|
}
|
|
4599
|
-
class
|
|
4600
|
+
class le extends rt {
|
|
4600
4601
|
static ZIndexPadding = 100;
|
|
4601
4602
|
assetLoader;
|
|
4602
4603
|
events;
|
|
@@ -4615,7 +4616,7 @@ class he extends ot {
|
|
|
4615
4616
|
/** @internal */
|
|
4616
4617
|
selectedClip;
|
|
4617
4618
|
constructor(e, t = "#ffffff") {
|
|
4618
|
-
super(), this.assetLoader = new
|
|
4619
|
+
super(), this.assetLoader = new Wt(), this.edit = null, this.tracks = [], this.clipsToDispose = [], this.clips = [], this.events = new At(), this.size = e, this.playbackTime = 0, this.totalDuration = 0, this.isPlaying = !1, this.selectedClip = null, this.backgroundColor = t;
|
|
4619
4620
|
}
|
|
4620
4621
|
async load() {
|
|
4621
4622
|
const e = new w.Graphics();
|
|
@@ -4651,9 +4652,9 @@ class he extends ot {
|
|
|
4651
4652
|
this.seek(0);
|
|
4652
4653
|
}
|
|
4653
4654
|
async loadEdit(e) {
|
|
4654
|
-
this.edit =
|
|
4655
|
+
this.edit = Qi.parse(e), this.backgroundColor = this.edit.timeline.background || "#000000", await Promise.all(
|
|
4655
4656
|
(this.edit.timeline.fonts ?? []).map(async (t) => {
|
|
4656
|
-
const i = t.src, s = { src: i, loadParser:
|
|
4657
|
+
const i = t.src, s = { src: i, loadParser: Ze.Name };
|
|
4657
4658
|
return this.assetLoader.load(i, s);
|
|
4658
4659
|
})
|
|
4659
4660
|
);
|
|
@@ -4697,13 +4698,13 @@ class he extends ot {
|
|
|
4697
4698
|
this.tracks.splice(e, 0, []);
|
|
4698
4699
|
const i = this.clips.map((s, n) => ({ clip: s, index: n })).filter(({ clip: s }) => s.layer >= e + 1);
|
|
4699
4700
|
i.forEach(({ clip: s }) => {
|
|
4700
|
-
const r = `shotstack-track-${1e5 - s.layer *
|
|
4701
|
+
const r = `shotstack-track-${1e5 - s.layer * le.ZIndexPadding}`;
|
|
4701
4702
|
this.getContainer().getChildByLabel(r, !1)?.removeChild(s.getContainer());
|
|
4702
4703
|
});
|
|
4703
4704
|
for (const { index: s } of i)
|
|
4704
4705
|
this.clips[s].layer += 1;
|
|
4705
4706
|
i.forEach(({ clip: s }) => {
|
|
4706
|
-
const n = 1e5 - s.layer *
|
|
4707
|
+
const n = 1e5 - s.layer * le.ZIndexPadding, r = `shotstack-track-${n}`;
|
|
4707
4708
|
let o = this.getContainer().getChildByLabel(r, !1);
|
|
4708
4709
|
o || (o = new w.Container({
|
|
4709
4710
|
label: r,
|
|
@@ -4724,13 +4725,13 @@ class he extends ot {
|
|
|
4724
4725
|
this.disposeClips(), this.tracks.splice(e, 1);
|
|
4725
4726
|
const i = this.clips.map((s, n) => ({ clip: s, index: n })).filter(({ clip: s }) => s.layer > e + 1);
|
|
4726
4727
|
i.forEach(({ clip: s }) => {
|
|
4727
|
-
const r = `shotstack-track-${1e5 - s.layer *
|
|
4728
|
+
const r = `shotstack-track-${1e5 - s.layer * le.ZIndexPadding}`;
|
|
4728
4729
|
this.getContainer().getChildByLabel(r, !1)?.removeChild(s.getContainer());
|
|
4729
4730
|
});
|
|
4730
4731
|
for (const { index: s } of i)
|
|
4731
4732
|
this.clips[s].layer -= 1;
|
|
4732
4733
|
i.forEach(({ clip: s }) => {
|
|
4733
|
-
const n = 1e5 - s.layer *
|
|
4734
|
+
const n = 1e5 - s.layer * le.ZIndexPadding, r = `shotstack-track-${n}`;
|
|
4734
4735
|
let o = this.getContainer().getChildByLabel(r, !1);
|
|
4735
4736
|
o || (o = new w.Container({
|
|
4736
4737
|
label: r,
|
|
@@ -4810,27 +4811,27 @@ class he extends ot {
|
|
|
4810
4811
|
let t;
|
|
4811
4812
|
switch (e.asset.type) {
|
|
4812
4813
|
case "text": {
|
|
4813
|
-
t = new
|
|
4814
|
+
t = new fs(this, e);
|
|
4814
4815
|
break;
|
|
4815
4816
|
}
|
|
4816
4817
|
case "shape": {
|
|
4817
|
-
t = new
|
|
4818
|
+
t = new ds(this, e);
|
|
4818
4819
|
break;
|
|
4819
4820
|
}
|
|
4820
4821
|
case "html": {
|
|
4821
|
-
t = new
|
|
4822
|
+
t = new hs(this, e);
|
|
4822
4823
|
break;
|
|
4823
4824
|
}
|
|
4824
4825
|
case "image": {
|
|
4825
|
-
t = new
|
|
4826
|
+
t = new us(this, e);
|
|
4826
4827
|
break;
|
|
4827
4828
|
}
|
|
4828
4829
|
case "video": {
|
|
4829
|
-
t = new
|
|
4830
|
+
t = new ps(this, e);
|
|
4830
4831
|
break;
|
|
4831
4832
|
}
|
|
4832
4833
|
case "audio": {
|
|
4833
|
-
t = new
|
|
4834
|
+
t = new st(this, e);
|
|
4834
4835
|
break;
|
|
4835
4836
|
}
|
|
4836
4837
|
default:
|
|
@@ -4842,12 +4843,12 @@ class he extends ot {
|
|
|
4842
4843
|
for (; this.tracks.length <= e; )
|
|
4843
4844
|
this.tracks.push([]);
|
|
4844
4845
|
this.tracks[e].push(t), this.clips.push(t);
|
|
4845
|
-
const i = 1e5 - (e + 1) *
|
|
4846
|
+
const i = 1e5 - (e + 1) * le.ZIndexPadding, s = `shotstack-track-${i}`;
|
|
4846
4847
|
let n = this.getContainer().getChildByLabel(s, !1);
|
|
4847
4848
|
n || (n = new w.Container({ label: s, zIndex: i }), this.getContainer().addChild(n)), n.addChild(t.getContainer()), await t.load(), this.updateTotalDuration();
|
|
4848
4849
|
}
|
|
4849
4850
|
}
|
|
4850
|
-
class
|
|
4851
|
+
class _e extends rt {
|
|
4851
4852
|
static Width = 250;
|
|
4852
4853
|
static Height = 100;
|
|
4853
4854
|
fps;
|
|
@@ -4861,14 +4862,14 @@ class ke extends ot {
|
|
|
4861
4862
|
}
|
|
4862
4863
|
async load() {
|
|
4863
4864
|
const e = new w.Graphics();
|
|
4864
|
-
e.fillStyle = { color: "#424242", alpha: 0.5 }, e.rect(0, 0,
|
|
4865
|
+
e.fillStyle = { color: "#424242", alpha: 0.5 }, e.rect(0, 0, _e.Width, _e.Height), e.fill(), this.getContainer().addChild(e), this.background = e;
|
|
4865
4866
|
const t = new w.Text();
|
|
4866
4867
|
t.text = "", t.style = {
|
|
4867
4868
|
fontFamily: "monospace",
|
|
4868
4869
|
fontSize: 14,
|
|
4869
4870
|
fill: "#ffffff",
|
|
4870
4871
|
wordWrap: !0,
|
|
4871
|
-
wordWrapWidth:
|
|
4872
|
+
wordWrapWidth: _e.Width
|
|
4872
4873
|
}, this.getContainer().addChild(t), this.text = t;
|
|
4873
4874
|
}
|
|
4874
4875
|
update(e, t) {
|
|
@@ -4898,7 +4899,7 @@ class ke extends ot {
|
|
|
4898
4899
|
return Math.round(e / 1024 / 1024);
|
|
4899
4900
|
}
|
|
4900
4901
|
}
|
|
4901
|
-
class
|
|
4902
|
+
class he {
|
|
4902
4903
|
/** @internal */
|
|
4903
4904
|
static CanvasSelector = "[data-shotstack-studio]";
|
|
4904
4905
|
static extensionsRegistered = !1;
|
|
@@ -4913,12 +4914,12 @@ class ue {
|
|
|
4913
4914
|
maxZoom = 4;
|
|
4914
4915
|
currentZoom = 0.8;
|
|
4915
4916
|
constructor(e, t) {
|
|
4916
|
-
this.size = e, this.application = new w.Application(), this.edit = t, this.inspector = new
|
|
4917
|
+
this.size = e, this.application = new w.Application(), this.edit = t, this.inspector = new _e();
|
|
4917
4918
|
}
|
|
4918
4919
|
async load() {
|
|
4919
|
-
const e = document.querySelector(
|
|
4920
|
+
const e = document.querySelector(he.CanvasSelector);
|
|
4920
4921
|
if (!e)
|
|
4921
|
-
throw new Error(`Shotstack canvas root element '${
|
|
4922
|
+
throw new Error(`Shotstack canvas root element '${he.CanvasSelector}' not found.`);
|
|
4922
4923
|
this.registerExtensions(), this.container = new w.Container(), this.background = new w.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);
|
|
4923
4924
|
}
|
|
4924
4925
|
setupTouchHandling(e) {
|
|
@@ -4968,7 +4969,7 @@ class ue {
|
|
|
4968
4969
|
t.scale.x = this.currentZoom, t.scale.y = this.currentZoom;
|
|
4969
4970
|
}
|
|
4970
4971
|
registerExtensions() {
|
|
4971
|
-
|
|
4972
|
+
he.extensionsRegistered || (w.extensions.add(new He()), w.extensions.add(new Ze()), he.extensionsRegistered = !0);
|
|
4972
4973
|
}
|
|
4973
4974
|
async configureApplication() {
|
|
4974
4975
|
const e = {
|
|
@@ -4995,11 +4996,11 @@ class ue {
|
|
|
4995
4996
|
}
|
|
4996
4997
|
/** @internal */
|
|
4997
4998
|
dispose() {
|
|
4998
|
-
const e = document.querySelector(
|
|
4999
|
+
const e = document.querySelector(he.CanvasSelector);
|
|
4999
5000
|
e && e.contains(this.application.canvas) && e.removeChild(this.application.canvas), this.application.ticker.remove(this.onTick, this), this.application.stage.off("click", this.onClick, this), this.background?.destroy(), this.container?.destroy(), this.inspector.dispose(), this.application.destroy(!0, { children: !0, texture: !0 });
|
|
5000
5001
|
}
|
|
5001
5002
|
}
|
|
5002
|
-
class
|
|
5003
|
+
class ys {
|
|
5003
5004
|
edit;
|
|
5004
5005
|
seekDistance = 50;
|
|
5005
5006
|
seekDistanceLarge = 500;
|
|
@@ -5070,261 +5071,13 @@ class _s {
|
|
|
5070
5071
|
}
|
|
5071
5072
|
};
|
|
5072
5073
|
}
|
|
5073
|
-
|
|
5074
|
-
(function(a) {
|
|
5075
|
-
a.LOAD = "LOAD", a.EXEC = "EXEC", a.FFPROBE = "FFPROBE", a.WRITE_FILE = "WRITE_FILE", a.READ_FILE = "READ_FILE", a.DELETE_FILE = "DELETE_FILE", a.RENAME = "RENAME", a.CREATE_DIR = "CREATE_DIR", a.LIST_DIR = "LIST_DIR", a.DELETE_DIR = "DELETE_DIR", a.ERROR = "ERROR", a.DOWNLOAD = "DOWNLOAD", a.PROGRESS = "PROGRESS", a.LOG = "LOG", a.MOUNT = "MOUNT", a.UNMOUNT = "UNMOUNT";
|
|
5076
|
-
})(A || (A = {}));
|
|
5077
|
-
const gs = /* @__PURE__ */ (() => {
|
|
5078
|
-
let a = 0;
|
|
5079
|
-
return () => a++;
|
|
5080
|
-
})(), ys = new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"), vs = new Error("called FFmpeg.terminate()");
|
|
5081
|
-
class xs {
|
|
5082
|
-
#t = null;
|
|
5083
|
-
/**
|
|
5084
|
-
* #resolves and #rejects tracks Promise resolves and rejects to
|
|
5085
|
-
* be called when we receive message from web worker.
|
|
5086
|
-
*/
|
|
5087
|
-
#s = {};
|
|
5088
|
-
#i = {};
|
|
5089
|
-
#n = [];
|
|
5090
|
-
#a = [];
|
|
5091
|
-
loaded = !1;
|
|
5092
|
-
/**
|
|
5093
|
-
* register worker message event handlers.
|
|
5094
|
-
*/
|
|
5095
|
-
#r = () => {
|
|
5096
|
-
this.#t && (this.#t.onmessage = ({ data: { id: e, type: t, data: i } }) => {
|
|
5097
|
-
switch (t) {
|
|
5098
|
-
case A.LOAD:
|
|
5099
|
-
this.loaded = !0, this.#s[e](i);
|
|
5100
|
-
break;
|
|
5101
|
-
case A.MOUNT:
|
|
5102
|
-
case A.UNMOUNT:
|
|
5103
|
-
case A.EXEC:
|
|
5104
|
-
case A.FFPROBE:
|
|
5105
|
-
case A.WRITE_FILE:
|
|
5106
|
-
case A.READ_FILE:
|
|
5107
|
-
case A.DELETE_FILE:
|
|
5108
|
-
case A.RENAME:
|
|
5109
|
-
case A.CREATE_DIR:
|
|
5110
|
-
case A.LIST_DIR:
|
|
5111
|
-
case A.DELETE_DIR:
|
|
5112
|
-
this.#s[e](i);
|
|
5113
|
-
break;
|
|
5114
|
-
case A.LOG:
|
|
5115
|
-
this.#n.forEach((s) => s(i));
|
|
5116
|
-
break;
|
|
5117
|
-
case A.PROGRESS:
|
|
5118
|
-
this.#a.forEach((s) => s(i));
|
|
5119
|
-
break;
|
|
5120
|
-
case A.ERROR:
|
|
5121
|
-
this.#i[e](i);
|
|
5122
|
-
break;
|
|
5123
|
-
}
|
|
5124
|
-
delete this.#s[e], delete this.#i[e];
|
|
5125
|
-
});
|
|
5126
|
-
};
|
|
5127
|
-
/**
|
|
5128
|
-
* Generic function to send messages to web worker.
|
|
5129
|
-
*/
|
|
5130
|
-
#e = ({ type: e, data: t }, i = [], s) => this.#t ? new Promise((n, r) => {
|
|
5131
|
-
const o = gs();
|
|
5132
|
-
this.#t && this.#t.postMessage({ id: o, type: e, data: t }, i), this.#s[o] = n, this.#i[o] = r, s?.addEventListener("abort", () => {
|
|
5133
|
-
r(new DOMException(`Message # ${o} was aborted`, "AbortError"));
|
|
5134
|
-
}, { once: !0 });
|
|
5135
|
-
}) : Promise.reject(ys);
|
|
5136
|
-
on(e, t) {
|
|
5137
|
-
e === "log" ? this.#n.push(t) : e === "progress" && this.#a.push(t);
|
|
5138
|
-
}
|
|
5139
|
-
off(e, t) {
|
|
5140
|
-
e === "log" ? this.#n = this.#n.filter((i) => i !== t) : e === "progress" && (this.#a = this.#a.filter((i) => i !== t));
|
|
5141
|
-
}
|
|
5142
|
-
/**
|
|
5143
|
-
* Loads ffmpeg-core inside web worker. It is required to call this method first
|
|
5144
|
-
* as it initializes WebAssembly and other essential variables.
|
|
5145
|
-
*
|
|
5146
|
-
* @category FFmpeg
|
|
5147
|
-
* @returns `true` if ffmpeg core is loaded for the first time.
|
|
5148
|
-
*/
|
|
5149
|
-
load = ({ classWorkerURL: e, ...t } = {}, { signal: i } = {}) => (this.#t || (this.#t = e ? new Worker(new URL(e, import.meta.url), {
|
|
5150
|
-
type: "module"
|
|
5151
|
-
}) : (
|
|
5152
|
-
// We need to duplicated the code here to enable webpack
|
|
5153
|
-
// to bundle worekr.js here.
|
|
5154
|
-
new Worker(new URL(
|
|
5155
|
-
/* @vite-ignore */
|
|
5156
|
-
"/assets/worker-BAOIWoxA.js",
|
|
5157
|
-
import.meta.url
|
|
5158
|
-
), {
|
|
5159
|
-
type: "module"
|
|
5160
|
-
})
|
|
5161
|
-
), this.#r()), this.#e({
|
|
5162
|
-
type: A.LOAD,
|
|
5163
|
-
data: t
|
|
5164
|
-
}, void 0, i));
|
|
5165
|
-
/**
|
|
5166
|
-
* Execute ffmpeg command.
|
|
5167
|
-
*
|
|
5168
|
-
* @remarks
|
|
5169
|
-
* To avoid common I/O issues, ["-nostdin", "-y"] are prepended to the args
|
|
5170
|
-
* by default.
|
|
5171
|
-
*
|
|
5172
|
-
* @example
|
|
5173
|
-
* ```ts
|
|
5174
|
-
* const ffmpeg = new FFmpeg();
|
|
5175
|
-
* await ffmpeg.load();
|
|
5176
|
-
* await ffmpeg.writeFile("video.avi", ...);
|
|
5177
|
-
* // ffmpeg -i video.avi video.mp4
|
|
5178
|
-
* await ffmpeg.exec(["-i", "video.avi", "video.mp4"]);
|
|
5179
|
-
* const data = ffmpeg.readFile("video.mp4");
|
|
5180
|
-
* ```
|
|
5181
|
-
*
|
|
5182
|
-
* @returns `0` if no error, `!= 0` if timeout (1) or error.
|
|
5183
|
-
* @category FFmpeg
|
|
5184
|
-
*/
|
|
5185
|
-
exec = (e, t = -1, { signal: i } = {}) => this.#e({
|
|
5186
|
-
type: A.EXEC,
|
|
5187
|
-
data: { args: e, timeout: t }
|
|
5188
|
-
}, void 0, i);
|
|
5189
|
-
/**
|
|
5190
|
-
* Execute ffprobe command.
|
|
5191
|
-
*
|
|
5192
|
-
* @example
|
|
5193
|
-
* ```ts
|
|
5194
|
-
* const ffmpeg = new FFmpeg();
|
|
5195
|
-
* await ffmpeg.load();
|
|
5196
|
-
* await ffmpeg.writeFile("video.avi", ...);
|
|
5197
|
-
* // Getting duration of a video in seconds: ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 video.avi -o output.txt
|
|
5198
|
-
* await ffmpeg.ffprobe(["-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", "video.avi", "-o", "output.txt"]);
|
|
5199
|
-
* const data = ffmpeg.readFile("output.txt");
|
|
5200
|
-
* ```
|
|
5201
|
-
*
|
|
5202
|
-
* @returns `0` if no error, `!= 0` if timeout (1) or error.
|
|
5203
|
-
* @category FFmpeg
|
|
5204
|
-
*/
|
|
5205
|
-
ffprobe = (e, t = -1, { signal: i } = {}) => this.#e({
|
|
5206
|
-
type: A.FFPROBE,
|
|
5207
|
-
data: { args: e, timeout: t }
|
|
5208
|
-
}, void 0, i);
|
|
5209
|
-
/**
|
|
5210
|
-
* Terminate all ongoing API calls and terminate web worker.
|
|
5211
|
-
* `FFmpeg.load()` must be called again before calling any other APIs.
|
|
5212
|
-
*
|
|
5213
|
-
* @category FFmpeg
|
|
5214
|
-
*/
|
|
5215
|
-
terminate = () => {
|
|
5216
|
-
const e = Object.keys(this.#i);
|
|
5217
|
-
for (const t of e)
|
|
5218
|
-
this.#i[t](vs), delete this.#i[t], delete this.#s[t];
|
|
5219
|
-
this.#t && (this.#t.terminate(), this.#t = null, this.loaded = !1);
|
|
5220
|
-
};
|
|
5221
|
-
/**
|
|
5222
|
-
* Write data to ffmpeg.wasm.
|
|
5223
|
-
*
|
|
5224
|
-
* @example
|
|
5225
|
-
* ```ts
|
|
5226
|
-
* const ffmpeg = new FFmpeg();
|
|
5227
|
-
* await ffmpeg.load();
|
|
5228
|
-
* await ffmpeg.writeFile("video.avi", await fetchFile("../video.avi"));
|
|
5229
|
-
* await ffmpeg.writeFile("text.txt", "hello world");
|
|
5230
|
-
* ```
|
|
5231
|
-
*
|
|
5232
|
-
* @category File System
|
|
5233
|
-
*/
|
|
5234
|
-
writeFile = (e, t, { signal: i } = {}) => {
|
|
5235
|
-
const s = [];
|
|
5236
|
-
return t instanceof Uint8Array && s.push(t.buffer), this.#e({
|
|
5237
|
-
type: A.WRITE_FILE,
|
|
5238
|
-
data: { path: e, data: t }
|
|
5239
|
-
}, s, i);
|
|
5240
|
-
};
|
|
5241
|
-
mount = (e, t, i) => {
|
|
5242
|
-
const s = [];
|
|
5243
|
-
return this.#e({
|
|
5244
|
-
type: A.MOUNT,
|
|
5245
|
-
data: { fsType: e, options: t, mountPoint: i }
|
|
5246
|
-
}, s);
|
|
5247
|
-
};
|
|
5248
|
-
unmount = (e) => {
|
|
5249
|
-
const t = [];
|
|
5250
|
-
return this.#e({
|
|
5251
|
-
type: A.UNMOUNT,
|
|
5252
|
-
data: { mountPoint: e }
|
|
5253
|
-
}, t);
|
|
5254
|
-
};
|
|
5255
|
-
/**
|
|
5256
|
-
* Read data from ffmpeg.wasm.
|
|
5257
|
-
*
|
|
5258
|
-
* @example
|
|
5259
|
-
* ```ts
|
|
5260
|
-
* const ffmpeg = new FFmpeg();
|
|
5261
|
-
* await ffmpeg.load();
|
|
5262
|
-
* const data = await ffmpeg.readFile("video.mp4");
|
|
5263
|
-
* ```
|
|
5264
|
-
*
|
|
5265
|
-
* @category File System
|
|
5266
|
-
*/
|
|
5267
|
-
readFile = (e, t = "binary", { signal: i } = {}) => this.#e({
|
|
5268
|
-
type: A.READ_FILE,
|
|
5269
|
-
data: { path: e, encoding: t }
|
|
5270
|
-
}, void 0, i);
|
|
5271
|
-
/**
|
|
5272
|
-
* Delete a file.
|
|
5273
|
-
*
|
|
5274
|
-
* @category File System
|
|
5275
|
-
*/
|
|
5276
|
-
deleteFile = (e, { signal: t } = {}) => this.#e({
|
|
5277
|
-
type: A.DELETE_FILE,
|
|
5278
|
-
data: { path: e }
|
|
5279
|
-
}, void 0, t);
|
|
5280
|
-
/**
|
|
5281
|
-
* Rename a file or directory.
|
|
5282
|
-
*
|
|
5283
|
-
* @category File System
|
|
5284
|
-
*/
|
|
5285
|
-
rename = (e, t, { signal: i } = {}) => this.#e({
|
|
5286
|
-
type: A.RENAME,
|
|
5287
|
-
data: { oldPath: e, newPath: t }
|
|
5288
|
-
}, void 0, i);
|
|
5289
|
-
/**
|
|
5290
|
-
* Create a directory.
|
|
5291
|
-
*
|
|
5292
|
-
* @category File System
|
|
5293
|
-
*/
|
|
5294
|
-
createDir = (e, { signal: t } = {}) => this.#e({
|
|
5295
|
-
type: A.CREATE_DIR,
|
|
5296
|
-
data: { path: e }
|
|
5297
|
-
}, void 0, t);
|
|
5298
|
-
/**
|
|
5299
|
-
* List directory contents.
|
|
5300
|
-
*
|
|
5301
|
-
* @category File System
|
|
5302
|
-
*/
|
|
5303
|
-
listDir = (e, { signal: t } = {}) => this.#e({
|
|
5304
|
-
type: A.LIST_DIR,
|
|
5305
|
-
data: { path: e }
|
|
5306
|
-
}, void 0, t);
|
|
5307
|
-
/**
|
|
5308
|
-
* Delete an empty directory.
|
|
5309
|
-
*
|
|
5310
|
-
* @category File System
|
|
5311
|
-
*/
|
|
5312
|
-
deleteDir = (e, { signal: t } = {}) => this.#e({
|
|
5313
|
-
type: A.DELETE_DIR,
|
|
5314
|
-
data: { path: e }
|
|
5315
|
-
}, void 0, t);
|
|
5316
|
-
}
|
|
5317
|
-
var Rt;
|
|
5318
|
-
(function(a) {
|
|
5319
|
-
a.MEMFS = "MEMFS", a.NODEFS = "NODEFS", a.NODERAWFS = "NODERAWFS", a.IDBFS = "IDBFS", a.WORKERFS = "WORKERFS", a.PROXYFS = "PROXYFS";
|
|
5320
|
-
})(Rt || (Rt = {}));
|
|
5321
|
-
class ks {
|
|
5074
|
+
class vs {
|
|
5322
5075
|
ffmpeg;
|
|
5323
5076
|
isReady = !1;
|
|
5324
5077
|
edit;
|
|
5325
5078
|
application;
|
|
5326
5079
|
constructor(e, t) {
|
|
5327
|
-
this.edit = e, this.application = t.application, this.ffmpeg = new
|
|
5080
|
+
this.edit = e, this.application = t.application, this.ffmpeg = new jt();
|
|
5328
5081
|
}
|
|
5329
5082
|
async init() {
|
|
5330
5083
|
if (!this.isReady)
|
|
@@ -5342,50 +5095,50 @@ class ks {
|
|
|
5342
5095
|
n.visible = !1;
|
|
5343
5096
|
const g = this.createProgressOverlay();
|
|
5344
5097
|
try {
|
|
5345
|
-
const p = this.edit.getSize ? this.edit.getSize() : { width: 1920, height: 1080 }, k = Math.ceil(this.edit.totalDuration * t / 1e3),
|
|
5098
|
+
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);
|
|
5346
5099
|
this.updateProgressOverlay(g, 0, S);
|
|
5347
5100
|
const H = document.createElement("canvas");
|
|
5348
5101
|
H.width = p.width, H.height = p.height;
|
|
5349
|
-
const
|
|
5350
|
-
if (!
|
|
5102
|
+
const oe = H.getContext("2d");
|
|
5103
|
+
if (!oe)
|
|
5351
5104
|
throw new Error("Could not get 2D context for canvas");
|
|
5352
|
-
const
|
|
5105
|
+
const Ve = this.findAudioPlayers();
|
|
5353
5106
|
this.updateProgressOverlay(g, 2, S);
|
|
5354
|
-
const
|
|
5355
|
-
if (
|
|
5107
|
+
const B = [];
|
|
5108
|
+
if (Ve.length > 0) {
|
|
5356
5109
|
this.updateProgressOverlay(g, 3, S);
|
|
5357
|
-
for (let
|
|
5358
|
-
const
|
|
5359
|
-
|
|
5110
|
+
for (let T = 0; T < Ve.length; T += 1) {
|
|
5111
|
+
const D = await this.processAudioTrack(Ve[T], T);
|
|
5112
|
+
D && B.push(D), this.updateProgressOverlay(g, 4 + T, S);
|
|
5360
5113
|
}
|
|
5361
5114
|
}
|
|
5362
5115
|
n.position.x = 0, n.position.y = 0, n.scale.x = 1, n.scale.y = 1;
|
|
5363
|
-
for (let
|
|
5364
|
-
this.edit.seek(
|
|
5116
|
+
for (let T = 0; T < k; T += 1) {
|
|
5117
|
+
this.edit.seek(T * A), this.edit.tick ? this.edit.tick(0, 0) : (this.edit.update?.(0, 0), this.edit.draw?.());
|
|
5365
5118
|
try {
|
|
5366
|
-
const { extract:
|
|
5367
|
-
|
|
5368
|
-
const
|
|
5369
|
-
await this.ffmpeg.writeFile(
|
|
5370
|
-
} catch (
|
|
5371
|
-
console.error(`Error capturing frame ${
|
|
5119
|
+
const { extract: D } = this.application.renderer, E = D.canvas(n);
|
|
5120
|
+
oe.clearRect(0, 0, H.width, H.height), oe.drawImage(E, 0, 0);
|
|
5121
|
+
const V = H.toDataURL("image/png"), Se = await (await fetch(V)).arrayBuffer(), Dt = `frame_${T.toString().padStart(6, "0")}.png`;
|
|
5122
|
+
await this.ffmpeg.writeFile(Dt, new Uint8Array(Se));
|
|
5123
|
+
} catch (D) {
|
|
5124
|
+
console.error(`Error capturing frame ${T}:`, D);
|
|
5372
5125
|
}
|
|
5373
|
-
this.updateProgressOverlay(g,
|
|
5126
|
+
this.updateProgressOverlay(g, re(T + 1), S);
|
|
5374
5127
|
}
|
|
5375
|
-
this.updateProgressOverlay(g,
|
|
5376
|
-
let
|
|
5377
|
-
for (const
|
|
5378
|
-
|
|
5379
|
-
if (
|
|
5380
|
-
let
|
|
5381
|
-
for (let
|
|
5382
|
-
const
|
|
5383
|
-
|
|
5128
|
+
this.updateProgressOverlay(g, N, S);
|
|
5129
|
+
let X = ["-framerate", t.toString(), "-i", "frame_%06d.png"];
|
|
5130
|
+
for (const T of B)
|
|
5131
|
+
X = X.concat(["-i", T.filename]);
|
|
5132
|
+
if (X = X.concat(["-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "23"]), B.length > 0) {
|
|
5133
|
+
let T = "";
|
|
5134
|
+
for (let E = 0; E < B.length; E += 1) {
|
|
5135
|
+
const V = B[E], ut = E + 1, Se = Math.max(0, V.start);
|
|
5136
|
+
T += `[${ut}:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,apad,afade=t=in:st=0:d=0.05,atrim=start=0:end=${V.duration / 1e3 + 0.1},adelay=${Se}|${Se},volume=${V.volume}[a${E}];`;
|
|
5384
5137
|
}
|
|
5385
|
-
const
|
|
5386
|
-
|
|
5138
|
+
const D = B.length > 1 ? `${B.map((E, V) => `[a${V}]`).join("")}amix=inputs=${B.length}:duration=longest:dropout_transition=0.5:normalize=0[aout]` : "[a0]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo[aout]";
|
|
5139
|
+
T += D, X = X.concat([
|
|
5387
5140
|
"-filter_complex",
|
|
5388
|
-
|
|
5141
|
+
T,
|
|
5389
5142
|
"-map",
|
|
5390
5143
|
"0:v",
|
|
5391
5144
|
"-map",
|
|
@@ -5397,33 +5150,33 @@ class ks {
|
|
|
5397
5150
|
"-shortest"
|
|
5398
5151
|
]);
|
|
5399
5152
|
}
|
|
5400
|
-
const
|
|
5401
|
-
|
|
5402
|
-
let
|
|
5403
|
-
const
|
|
5404
|
-
const
|
|
5405
|
-
if (
|
|
5406
|
-
const
|
|
5407
|
-
if (!Number.isNaN(
|
|
5408
|
-
const
|
|
5409
|
-
this.updateProgressOverlay(g,
|
|
5153
|
+
const $e = "output.mp4";
|
|
5154
|
+
X.push($e);
|
|
5155
|
+
let ct = 0;
|
|
5156
|
+
const lt = ({ message: T }) => {
|
|
5157
|
+
const D = T.includes("frame=") && T.includes("fps=") ? T.match(/frame=\s*(\d+)/) : null;
|
|
5158
|
+
if (D?.[1]) {
|
|
5159
|
+
const E = parseInt(D[1], 10);
|
|
5160
|
+
if (!Number.isNaN(E) && E > ct && (ct = E, E <= k)) {
|
|
5161
|
+
const V = Math.round(E / k * J);
|
|
5162
|
+
this.updateProgressOverlay(g, N + V, S);
|
|
5410
5163
|
}
|
|
5411
5164
|
}
|
|
5412
5165
|
};
|
|
5413
|
-
this.ffmpeg.on("log",
|
|
5414
|
-
const
|
|
5415
|
-
|
|
5416
|
-
for (let
|
|
5166
|
+
this.ffmpeg.on("log", lt), await this.ffmpeg.exec(X), this.ffmpeg.off("log", lt), this.updateProgressOverlay(g, N + J, S);
|
|
5167
|
+
const je = await this.ffmpeg.readFile($e), Ft = je instanceof Uint8Array ? je : new TextEncoder().encode(je.toString()), Nt = new Blob([Ft], { type: "video/mp4" }), ht = URL.createObjectURL(Nt), Ue = document.createElement("a");
|
|
5168
|
+
Ue.href = ht, Ue.download = e, Ue.click(), URL.revokeObjectURL(ht);
|
|
5169
|
+
for (let T = 0; T < k; T += 1)
|
|
5417
5170
|
try {
|
|
5418
|
-
await this.ffmpeg.deleteFile(`frame_${
|
|
5171
|
+
await this.ffmpeg.deleteFile(`frame_${T.toString().padStart(6, "0")}.png`);
|
|
5419
5172
|
} catch {
|
|
5420
5173
|
}
|
|
5421
|
-
for (const
|
|
5174
|
+
for (const T of B)
|
|
5422
5175
|
try {
|
|
5423
|
-
await this.ffmpeg.deleteFile(
|
|
5176
|
+
await this.ffmpeg.deleteFile(T.filename);
|
|
5424
5177
|
} catch {
|
|
5425
5178
|
}
|
|
5426
|
-
await this.ffmpeg.deleteFile(
|
|
5179
|
+
await this.ffmpeg.deleteFile($e), this.updateProgressOverlay(g, S, S);
|
|
5427
5180
|
} catch (p) {
|
|
5428
5181
|
throw console.error("Error during export:", p), p;
|
|
5429
5182
|
} finally {
|
|
@@ -5438,7 +5191,7 @@ class ks {
|
|
|
5438
5191
|
if (Array.isArray(s))
|
|
5439
5192
|
for (let n = 0; n < s.length; n += 1) {
|
|
5440
5193
|
const r = s[n];
|
|
5441
|
-
(r instanceof
|
|
5194
|
+
(r instanceof st || r.constructor.name === "AudioPlayer" || r.clipConfiguration?.asset?.type === "audio") && (e.includes(r) || e.push(r));
|
|
5442
5195
|
}
|
|
5443
5196
|
}
|
|
5444
5197
|
return this.searchContainerForPlayers(this.edit.getContainer(), e), e;
|
|
@@ -5453,7 +5206,7 @@ class ks {
|
|
|
5453
5206
|
const r = n, o = ["player", "clip", "audioPlayer", "entity"];
|
|
5454
5207
|
for (const h of o) {
|
|
5455
5208
|
const c = r[h];
|
|
5456
|
-
c instanceof
|
|
5209
|
+
c instanceof st && !t.includes(c) && t.push(c);
|
|
5457
5210
|
}
|
|
5458
5211
|
}
|
|
5459
5212
|
}
|
|
@@ -5539,8 +5292,8 @@ class ks {
|
|
|
5539
5292
|
}
|
|
5540
5293
|
}
|
|
5541
5294
|
export {
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5295
|
+
he as Canvas,
|
|
5296
|
+
ys as Controls,
|
|
5297
|
+
le as Edit,
|
|
5298
|
+
vs as VideoExporter
|
|
5546
5299
|
};
|