@amazon/vinyl-hls-parser 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hlsTestAssets/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs +8 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +9 -2
- package/dist/index.js.map +3 -3
- package/dist/test/benchmark.es5.js +56 -248
- package/dist/test/benchmark.js +164 -972
- package/dist/test/benchmark.js.map +4 -4
- package/dist/types/current/parse/parseMainPlaylist.d.ts.map +1 -1
- package/dist/types/current/parse/parseMainPlaylist.js +16 -2
- package/dist/types/current/parse/parseMediaPlaylist.d.ts.map +1 -1
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/current/types/HlsDateRange.d.ts +51 -0
- package/dist/types/current/types/HlsDateRange.d.ts.map +1 -0
- package/dist/types/current/types/HlsDateRange.js +11 -0
- package/dist/types/current/types/HlsMainPlaylist.d.ts +22 -0
- package/dist/types/current/types/HlsMainPlaylist.d.ts.map +1 -0
- package/dist/types/current/types/HlsMainPlaylist.js +5 -0
- package/dist/types/current/types/HlsMediaPlaylist.d.ts +32 -0
- package/dist/types/current/types/HlsMediaPlaylist.d.ts.map +1 -0
- package/dist/types/current/types/HlsMediaPlaylist.js +5 -0
- package/dist/types/ts3.7/types/HlsDateRange.d.ts +51 -0
- package/dist/types/ts3.7/types/HlsMainPlaylist.d.ts +22 -0
- package/dist/types/ts3.7/types/HlsMediaPlaylist.d.ts +32 -0
- package/dist/types/ts4.1/types/HlsDateRange.d.ts +51 -0
- package/dist/types/ts4.1/types/HlsMainPlaylist.d.ts +22 -0
- package/dist/types/ts4.1/types/HlsMediaPlaylist.d.ts +32 -0
- package/dist/types/ts4.7/types/HlsDateRange.d.ts +51 -0
- package/dist/types/ts4.7/types/HlsMainPlaylist.d.ts +22 -0
- package/dist/types/ts4.7/types/HlsMediaPlaylist.d.ts +32 -0
- package/package.json +24 -14
- package/dist/test/benchmark.css +0 -71
- package/dist/test/benchmark.html +0 -67
- package/dist/test/favicon.png +0 -0
- package/dist/test/index.html +0 -61
- package/dist/test/integ.es5.js +0 -410
- package/dist/test/integ.js +0 -2127
- package/dist/test/integ.js.map +0 -7
- package/dist/test/jasmine.css +0 -304
- package/dist/test/jasmineHtml.es5.js +0 -670
- package/dist/test/jasmineHtml.js +0 -10851
- package/dist/test/jasmineHtml.js.map +0 -7
- package/dist/test/styles.css +0 -42
- package/dist/unit/types/current/index.d.ts +0 -7
- package/dist/unit/types/current/index.d.ts.map +0 -1
- package/dist/unit/types/current/index.js +0 -6
- package/dist/unit/types/current/parse/parseAttributes.test.d.ts +0 -2
- package/dist/unit/types/current/parse/parseAttributes.test.d.ts.map +0 -1
- package/dist/unit/types/current/parse/parseAttributes.test.js +0 -70
- package/dist/unit/types/current/parse/parseMainPlaylist.test.d.ts +0 -2
- package/dist/unit/types/current/parse/parseMainPlaylist.test.d.ts.map +0 -1
- package/dist/unit/types/current/parse/parseMainPlaylist.test.js +0 -194
- package/dist/unit/types/current/parse/parseMediaPlaylist.test.d.ts +0 -2
- package/dist/unit/types/current/parse/parseMediaPlaylist.test.d.ts.map +0 -1
- package/dist/unit/types/current/parse/parseMediaPlaylist.test.js +0 -401
- package/dist/unit/types/current/parse/parseUtil.test.d.ts +0 -2
- package/dist/unit/types/current/parse/parseUtil.test.d.ts.map +0 -1
- package/dist/unit/types/current/parse/parseUtil.test.js +0 -67
- package/dist/unit/types/current/setup.d.ts +0 -2
- package/dist/unit/types/current/setup.d.ts.map +0 -1
- package/dist/unit/types/current/setup.js +0 -19
- package/dist/unit/types/current/tsconfig.tsbuildinfo +0 -1
package/dist/test/benchmark.js
CHANGED
|
@@ -19,31 +19,26 @@
|
|
|
19
19
|
return a;
|
|
20
20
|
};
|
|
21
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var __spreadValues2 = (a, b) => {
|
|
32
|
-
for (var prop in b || (b = {}))
|
|
33
|
-
if (__hasOwnProp2.call(b, prop))
|
|
34
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
35
|
-
if (__getOwnPropSymbols2)
|
|
36
|
-
for (var prop of __getOwnPropSymbols2(b)) {
|
|
37
|
-
if (__propIsEnum2.call(b, prop))
|
|
38
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
22
|
+
var __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
39
31
|
}
|
|
40
|
-
return
|
|
32
|
+
return target;
|
|
41
33
|
};
|
|
42
|
-
var
|
|
43
|
-
|
|
34
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
35
|
+
|
|
36
|
+
// ../vinyl-util/src/util/type.ts
|
|
44
37
|
function invariant() {
|
|
45
38
|
return void 0;
|
|
46
39
|
}
|
|
40
|
+
|
|
41
|
+
// ../vinyl-util/src/error/ErrorOrigin.ts
|
|
47
42
|
var ErrorOrigin = {
|
|
48
43
|
/**
|
|
49
44
|
* The error originated from Vinyl and was reported from the uncaught exception or promise
|
|
@@ -88,11 +83,13 @@
|
|
|
88
83
|
*/
|
|
89
84
|
DRM: "drm"
|
|
90
85
|
};
|
|
86
|
+
|
|
87
|
+
// ../vinyl-util/src/error/ReportableError.ts
|
|
91
88
|
var ReportableError = class _ReportableError extends Error {
|
|
92
|
-
constructor(message, origin = ErrorOrigin.INTERNAL, level = "fatal") {
|
|
89
|
+
constructor(message, origin = ErrorOrigin.INTERNAL, level = "fatal" /* FATAL */) {
|
|
93
90
|
super(message);
|
|
94
|
-
this
|
|
95
|
-
this
|
|
91
|
+
__publicField(this, "origin", origin);
|
|
92
|
+
__publicField(this, "level", level);
|
|
96
93
|
Object.setPrototypeOf(this, _ReportableError.prototype);
|
|
97
94
|
}
|
|
98
95
|
get [Symbol.toStringTag]() {
|
|
@@ -114,16 +111,29 @@
|
|
|
114
111
|
};
|
|
115
112
|
}
|
|
116
113
|
};
|
|
114
|
+
|
|
115
|
+
// ../vinyl-util/src/error/IllegalArgumentError.ts
|
|
117
116
|
var IllegalArgumentError = class _IllegalArgumentError extends ReportableError {
|
|
118
117
|
constructor(message, isInternal = true) {
|
|
119
118
|
super(message, isInternal ? ErrorOrigin.INTERNAL : ErrorOrigin.API);
|
|
120
|
-
this
|
|
119
|
+
__publicField(this, "isInternal", isInternal);
|
|
121
120
|
Object.setPrototypeOf(this, _IllegalArgumentError.prototype);
|
|
122
121
|
}
|
|
123
122
|
get [Symbol.toStringTag]() {
|
|
124
123
|
return "IllegalArgumentError";
|
|
125
124
|
}
|
|
126
125
|
};
|
|
126
|
+
|
|
127
|
+
// ../vinyl-util/src/util/map/map.ts
|
|
128
|
+
function flipMap(map) {
|
|
129
|
+
const result = /* @__PURE__ */ new Map();
|
|
130
|
+
for (const [key, value] of map) {
|
|
131
|
+
result.set(value, key);
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ../vinyl-util/src/util/string/string.ts
|
|
127
137
|
var locale = {
|
|
128
138
|
variableNotDefined: "Variable '{name}' is not defined"
|
|
129
139
|
};
|
|
@@ -144,6 +154,14 @@
|
|
|
144
154
|
charCode === 13 || // '\r' (carriage return)
|
|
145
155
|
charCode === 10;
|
|
146
156
|
}
|
|
157
|
+
var predefinedDecodeEntities = /* @__PURE__ */ new Map([
|
|
158
|
+
["apos", "'"],
|
|
159
|
+
["amp", "&"],
|
|
160
|
+
["lt", "<"],
|
|
161
|
+
["gt", ">"],
|
|
162
|
+
["quot", '"']
|
|
163
|
+
]);
|
|
164
|
+
var standardEntityValueToNames = flipMap(predefinedDecodeEntities);
|
|
147
165
|
function eqStr(a, b, ignoreCase = false) {
|
|
148
166
|
if (a == null && b == null) return true;
|
|
149
167
|
if (a == null || b == null) return false;
|
|
@@ -161,9 +179,13 @@
|
|
|
161
179
|
return str.substring(0, maxLength - indicator.length) + indicator;
|
|
162
180
|
return str;
|
|
163
181
|
}
|
|
164
|
-
|
|
165
|
-
|
|
182
|
+
|
|
183
|
+
// ../vinyl-util/src/util/math/math.ts
|
|
184
|
+
function clamp(value, min, max) {
|
|
185
|
+
return Math.min(Math.max(value, min), max);
|
|
166
186
|
}
|
|
187
|
+
|
|
188
|
+
// ../vinyl-util/src/util/serialization/ParseError.ts
|
|
167
189
|
function printStringPosition(str, index, options) {
|
|
168
190
|
var _a;
|
|
169
191
|
const caret = (options == null ? void 0 : options.caret) || "^";
|
|
@@ -190,12 +212,18 @@
|
|
|
190
212
|
out += " ".repeat(leadingChars) + caret;
|
|
191
213
|
return out;
|
|
192
214
|
}
|
|
215
|
+
|
|
216
|
+
// ../vinyl-util/src/util/string/StringReader.ts
|
|
193
217
|
var StringReader = class {
|
|
194
218
|
/**
|
|
195
219
|
* @param data The string to read.
|
|
196
220
|
*/
|
|
197
221
|
constructor(data) {
|
|
198
|
-
this
|
|
222
|
+
__publicField(this, "data", data);
|
|
223
|
+
/**
|
|
224
|
+
* The current cursor.
|
|
225
|
+
* This should always be between the range 0 and `data.length`
|
|
226
|
+
*/
|
|
199
227
|
__publicField(this, "position", 0);
|
|
200
228
|
}
|
|
201
229
|
/**
|
|
@@ -394,43 +422,38 @@
|
|
|
394
422
|
};
|
|
395
423
|
var StringParseError = class _StringParseError extends ReportableError {
|
|
396
424
|
constructor(str, position, reason) {
|
|
397
|
-
const
|
|
425
|
+
const location = printStringPosition(str, position);
|
|
398
426
|
super(
|
|
399
|
-
`${reason}${locale2.messageSeparator}${
|
|
427
|
+
`${reason}${locale2.messageSeparator}${location}`,
|
|
400
428
|
ErrorOrigin.PARSING
|
|
401
429
|
);
|
|
402
|
-
this
|
|
403
|
-
this
|
|
430
|
+
__publicField(this, "position", position);
|
|
431
|
+
__publicField(this, "reason", reason);
|
|
404
432
|
__publicField(this, "location");
|
|
405
|
-
this.location =
|
|
433
|
+
this.location = location;
|
|
406
434
|
Object.setPrototypeOf(this, _StringParseError.prototype);
|
|
407
435
|
}
|
|
408
436
|
get [Symbol.toStringTag]() {
|
|
409
437
|
return "StringParseError";
|
|
410
438
|
}
|
|
411
439
|
toJSON() {
|
|
412
|
-
return
|
|
440
|
+
return __spreadProps(__spreadValues({}, super.toJSON()), {
|
|
413
441
|
position: this.position,
|
|
414
442
|
location: this.location,
|
|
415
443
|
reason: this.reason
|
|
416
444
|
});
|
|
417
445
|
}
|
|
418
446
|
};
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
if (typeof Reflect !== "undefined")
|
|
422
|
-
return new Set(Reflect.ownKeys(obj));
|
|
423
|
-
const properties = /* @__PURE__ */ new Set();
|
|
424
|
-
Object.getOwnPropertyNames(obj).forEach((item) => properties.add(item));
|
|
425
|
-
Object.getOwnPropertySymbols(obj).forEach((item) => properties.add(item));
|
|
426
|
-
return properties;
|
|
427
|
-
}
|
|
447
|
+
|
|
448
|
+
// ../vinyl-util/src/util/object/object.ts
|
|
428
449
|
function isPlainObject(value) {
|
|
429
450
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
430
451
|
return false;
|
|
431
452
|
const proto = Object.getPrototypeOf(value);
|
|
432
453
|
return !proto || !Object.getPrototypeOf(proto);
|
|
433
454
|
}
|
|
455
|
+
|
|
456
|
+
// ../vinyl-util/src/util/serialization/json.ts
|
|
434
457
|
function toJson(value) {
|
|
435
458
|
return toJsonInternal(value, /* @__PURE__ */ new Set());
|
|
436
459
|
}
|
|
@@ -479,6 +502,8 @@
|
|
|
479
502
|
}
|
|
480
503
|
}
|
|
481
504
|
}
|
|
505
|
+
|
|
506
|
+
// ../vinyl-util/src/util/serialization/stringifyForPrint.ts
|
|
482
507
|
function stringifyForPrint(value, maxLength, indicator = "\u2026") {
|
|
483
508
|
let str = JSON.stringify(
|
|
484
509
|
toJson(value),
|
|
@@ -501,11 +526,8 @@
|
|
|
501
526
|
if (maxLength) str = truncate(str, maxLength, indicator);
|
|
502
527
|
return str;
|
|
503
528
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
if (Array.isArray(sources[0])) return Array.prototype.concat(...sources);
|
|
507
|
-
return Object.assign({}, ...sources);
|
|
508
|
-
}
|
|
529
|
+
|
|
530
|
+
// ../vinyl-util/src/error/ValidationError.ts
|
|
509
531
|
var ValidationError = class _ValidationError extends ReportableError {
|
|
510
532
|
/**
|
|
511
533
|
* @param message The validation error message.
|
|
@@ -514,41 +536,21 @@
|
|
|
514
536
|
*/
|
|
515
537
|
constructor(message, origin = ErrorOrigin.API, path = []) {
|
|
516
538
|
super(message, origin);
|
|
517
|
-
this
|
|
539
|
+
__publicField(this, "path", path);
|
|
518
540
|
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
519
541
|
}
|
|
520
542
|
get [Symbol.toStringTag]() {
|
|
521
543
|
return "ValidationError";
|
|
522
544
|
}
|
|
523
545
|
toJSON() {
|
|
524
|
-
return
|
|
546
|
+
return __spreadProps(__spreadValues({}, super.toJSON()), {
|
|
525
547
|
origin: this.origin,
|
|
526
548
|
path: this.path
|
|
527
549
|
});
|
|
528
550
|
}
|
|
529
551
|
};
|
|
530
552
|
|
|
531
|
-
// ../vinyl-validation/
|
|
532
|
-
var __defProp3 = Object.defineProperty;
|
|
533
|
-
var __defProps3 = Object.defineProperties;
|
|
534
|
-
var __getOwnPropDescs3 = Object.getOwnPropertyDescriptors;
|
|
535
|
-
var __getOwnPropSymbols3 = Object.getOwnPropertySymbols;
|
|
536
|
-
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
537
|
-
var __propIsEnum3 = Object.prototype.propertyIsEnumerable;
|
|
538
|
-
var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
539
|
-
var __spreadValues3 = (a, b) => {
|
|
540
|
-
for (var prop in b || (b = {}))
|
|
541
|
-
if (__hasOwnProp3.call(b, prop))
|
|
542
|
-
__defNormalProp3(a, prop, b[prop]);
|
|
543
|
-
if (__getOwnPropSymbols3)
|
|
544
|
-
for (var prop of __getOwnPropSymbols3(b)) {
|
|
545
|
-
if (__propIsEnum3.call(b, prop))
|
|
546
|
-
__defNormalProp3(a, prop, b[prop]);
|
|
547
|
-
}
|
|
548
|
-
return a;
|
|
549
|
-
};
|
|
550
|
-
var __spreadProps3 = (a, b) => __defProps3(a, __getOwnPropDescs3(b));
|
|
551
|
-
var __publicField2 = (obj, key, value) => __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
553
|
+
// ../vinyl-validation/src/validation/Validator.ts
|
|
552
554
|
var validatorLocale = {
|
|
553
555
|
/**
|
|
554
556
|
* The expectation template string with the following replacement tokens:
|
|
@@ -622,6 +624,8 @@
|
|
|
622
624
|
}
|
|
623
625
|
};
|
|
624
626
|
}
|
|
627
|
+
|
|
628
|
+
// ../vinyl-validation/src/validation/andValidators.ts
|
|
625
629
|
var locale3 = {
|
|
626
630
|
/**
|
|
627
631
|
* {value} The child validators' descriptions, joined with `separator`.
|
|
@@ -650,7 +654,9 @@
|
|
|
650
654
|
}
|
|
651
655
|
);
|
|
652
656
|
}
|
|
653
|
-
|
|
657
|
+
|
|
658
|
+
// ../vinyl-validation/src/validation/orValidators.ts
|
|
659
|
+
var locale4 = {
|
|
654
660
|
/**
|
|
655
661
|
* {value} - The child validators' descriptions, joined with `separator`.
|
|
656
662
|
*/
|
|
@@ -661,8 +667,8 @@
|
|
|
661
667
|
separator: " | "
|
|
662
668
|
};
|
|
663
669
|
function orValidators(...validators) {
|
|
664
|
-
const description = substitute(
|
|
665
|
-
value: validators.map((v) => v.description).join(
|
|
670
|
+
const description = substitute(locale4.template, {
|
|
671
|
+
value: validators.map((v) => v.description).join(locale4.separator)
|
|
666
672
|
});
|
|
667
673
|
return createDeepValidator(description, (input, options, path) => {
|
|
668
674
|
let longestErrors = [];
|
|
@@ -691,22 +697,24 @@
|
|
|
691
697
|
];
|
|
692
698
|
});
|
|
693
699
|
}
|
|
700
|
+
|
|
701
|
+
// ../vinyl-validation/src/validation/SchemaBase.ts
|
|
694
702
|
var requiredValidationOptions = {
|
|
695
703
|
optional: false
|
|
696
704
|
};
|
|
697
705
|
var SchemaBase = class {
|
|
698
706
|
constructor(currentValidator, previousSchema, operation) {
|
|
699
|
-
this
|
|
700
|
-
this
|
|
701
|
-
this
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
707
|
+
__publicField(this, "currentValidator", currentValidator);
|
|
708
|
+
__publicField(this, "previousSchema", previousSchema);
|
|
709
|
+
__publicField(this, "operation", operation);
|
|
710
|
+
__publicField(this, "__type", invariant());
|
|
711
|
+
__publicField(this, "validator");
|
|
712
|
+
__publicField(this, "_options", requiredValidationOptions);
|
|
713
|
+
__publicField(this, "assert", (input, origin, path) => {
|
|
706
714
|
this.validator.assert(input, origin, path);
|
|
707
715
|
});
|
|
708
|
-
|
|
709
|
-
|
|
716
|
+
__publicField(this, "isValid", (input) => this.validator.isValid(input));
|
|
717
|
+
__publicField(this, "validate", (input, options, path) => this.validator.validate(input, options, path));
|
|
710
718
|
this.validator = operation == null ? currentValidator : operation(previousSchema, currentValidator);
|
|
711
719
|
}
|
|
712
720
|
get options() {
|
|
@@ -752,20 +760,22 @@
|
|
|
752
760
|
}
|
|
753
761
|
optional() {
|
|
754
762
|
const cloned = this.clone();
|
|
755
|
-
cloned._options =
|
|
763
|
+
cloned._options = __spreadProps(__spreadValues({}, cloned.options), {
|
|
756
764
|
optional: true
|
|
757
765
|
});
|
|
758
766
|
return cloned;
|
|
759
767
|
}
|
|
760
768
|
required() {
|
|
761
769
|
const cloned = this.clone();
|
|
762
|
-
cloned._options =
|
|
770
|
+
cloned._options = __spreadProps(__spreadValues({}, cloned.options), {
|
|
763
771
|
optional: false
|
|
764
772
|
});
|
|
765
773
|
return cloned;
|
|
766
774
|
}
|
|
767
775
|
};
|
|
768
|
-
|
|
776
|
+
|
|
777
|
+
// ../vinyl-validation/src/validation/ValueSchema.ts
|
|
778
|
+
var locale5 = {
|
|
769
779
|
null: "null",
|
|
770
780
|
nullish: "nullish",
|
|
771
781
|
undefined: "undefined"
|
|
@@ -778,19 +788,19 @@
|
|
|
778
788
|
* Creates a validator that asserts that the input is nullish.
|
|
779
789
|
*/
|
|
780
790
|
nullish() {
|
|
781
|
-
return createValidator(
|
|
791
|
+
return createValidator(locale5.nullish, (input) => input == null);
|
|
782
792
|
},
|
|
783
793
|
/**
|
|
784
794
|
* Creates a validator that asserts that the input is strictly null.
|
|
785
795
|
*/
|
|
786
796
|
null() {
|
|
787
|
-
return createValidator(
|
|
797
|
+
return createValidator(locale5.null, (input) => input === null);
|
|
788
798
|
},
|
|
789
799
|
/**
|
|
790
800
|
* Creates a validator that asserts that the input is strictly undefined.
|
|
791
801
|
*/
|
|
792
802
|
undefined() {
|
|
793
|
-
return createValidator(
|
|
803
|
+
return createValidator(locale5.undefined, (input) => input === void 0);
|
|
794
804
|
}
|
|
795
805
|
};
|
|
796
806
|
var ValueSchema = class _ValueSchema extends SchemaBase {
|
|
@@ -837,817 +847,9 @@
|
|
|
837
847
|
return new _ValueSchema(nextValidator, this, orValidators);
|
|
838
848
|
}
|
|
839
849
|
};
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
minLength: "at least {value} elements",
|
|
843
|
-
maxLength: "at most {value} elements",
|
|
844
|
-
exactlyLength: "exactly {value} elements",
|
|
845
|
-
actualLength: "length {value}",
|
|
846
|
-
withElements: "({value})[]",
|
|
847
|
-
tuple: "[{value}]"
|
|
848
|
-
};
|
|
849
|
-
var arrayValidators = {
|
|
850
|
-
/**
|
|
851
|
-
* Creates a validator that asserts that the input is an array.
|
|
852
|
-
*
|
|
853
|
-
* Note: arrays can only be readonly by type system, there is no native readonly
|
|
854
|
-
* js array. This validator assumes mutability, use the ArraySchema readonly() method
|
|
855
|
-
* to cast to a readonly array.
|
|
856
|
-
*/
|
|
857
|
-
isArray() {
|
|
858
|
-
return createValidator(
|
|
859
|
-
locale4.array,
|
|
860
|
-
(input) => Array.isArray(input)
|
|
861
|
-
);
|
|
862
|
-
},
|
|
863
|
-
/**
|
|
864
|
-
* Creates a validator that asserts that every element passes the given validator.
|
|
865
|
-
*
|
|
866
|
-
* @param elementValidator
|
|
867
|
-
*/
|
|
868
|
-
withElements(elementValidator) {
|
|
869
|
-
return createDeepValidator(
|
|
870
|
-
substitute(locale4.withElements, {
|
|
871
|
-
value: elementValidator.description
|
|
872
|
-
}),
|
|
873
|
-
(input, options, path) => {
|
|
874
|
-
const errors = [];
|
|
875
|
-
for (let i = 0; i < input.length; i++) {
|
|
876
|
-
const element = input[i];
|
|
877
|
-
errors.push(
|
|
878
|
-
...elementValidator.validate(
|
|
879
|
-
element,
|
|
880
|
-
options,
|
|
881
|
-
path.concat(i.toString())
|
|
882
|
-
)
|
|
883
|
-
);
|
|
884
|
-
if (!options.all && errors.length) return errors;
|
|
885
|
-
}
|
|
886
|
-
return errors;
|
|
887
|
-
}
|
|
888
|
-
);
|
|
889
|
-
},
|
|
890
|
-
/**
|
|
891
|
-
* Creates a validator that asserts that the input array is a tuple whose elements match
|
|
892
|
-
* the given validators.
|
|
893
|
-
*
|
|
894
|
-
* @param validators
|
|
895
|
-
*/
|
|
896
|
-
tuple(...validators) {
|
|
897
|
-
const lengthValidator = createValidator(
|
|
898
|
-
substitute(locale4.exactlyLength, {
|
|
899
|
-
value: validators.length
|
|
900
|
-
}),
|
|
901
|
-
(length) => length === validators.length
|
|
902
|
-
);
|
|
903
|
-
return createDeepValidator(
|
|
904
|
-
substitute(locale4.tuple, { value: validators.join(", ") }),
|
|
905
|
-
(input, options, path) => {
|
|
906
|
-
const errors = [];
|
|
907
|
-
errors.push(
|
|
908
|
-
...lengthValidator.validate(input.length, options, path)
|
|
909
|
-
);
|
|
910
|
-
if (!options.all && errors.length) return errors;
|
|
911
|
-
const n = Math.min(validators.length, input.length);
|
|
912
|
-
for (let i = 0; i < n; i++) {
|
|
913
|
-
const element = input[i];
|
|
914
|
-
const validator = validators[i];
|
|
915
|
-
errors.push(
|
|
916
|
-
...validator.validate(
|
|
917
|
-
element,
|
|
918
|
-
options,
|
|
919
|
-
path.concat(i.toString())
|
|
920
|
-
)
|
|
921
|
-
);
|
|
922
|
-
if (!options.all && errors.length) return errors;
|
|
923
|
-
}
|
|
924
|
-
return errors;
|
|
925
|
-
}
|
|
926
|
-
);
|
|
927
|
-
},
|
|
928
|
-
/**
|
|
929
|
-
* Creates a validator that validates the input array has the given minimum length.
|
|
930
|
-
* @param min The minimum number of elements (inclusive)
|
|
931
|
-
*/
|
|
932
|
-
minLength(min) {
|
|
933
|
-
return createValidator(
|
|
934
|
-
substitute(locale4.minLength, { value: min }),
|
|
935
|
-
(input) => input.length >= min,
|
|
936
|
-
(input) => substitute(locale4.actualLength, { value: input.length })
|
|
937
|
-
);
|
|
938
|
-
},
|
|
939
|
-
/**
|
|
940
|
-
*
|
|
941
|
-
* Creates a validator that validates the input array has the given maximum length.
|
|
942
|
-
* @param max The maximum number of elements (inclusive)
|
|
943
|
-
*/
|
|
944
|
-
maxLength(max) {
|
|
945
|
-
return createValidator(
|
|
946
|
-
substitute(locale4.maxLength, { value: max }),
|
|
947
|
-
(input) => input.length <= max,
|
|
948
|
-
(input) => substitute(locale4.actualLength, { value: input.length })
|
|
949
|
-
);
|
|
950
|
-
}
|
|
951
|
-
};
|
|
952
|
-
var _ArraySchema = class _ArraySchema2 extends ValueSchema {
|
|
953
|
-
/**
|
|
954
|
-
* The base ArraySchema instance validating that the input is an Array.
|
|
955
|
-
*/
|
|
956
|
-
static get base() {
|
|
957
|
-
if (this._base == null)
|
|
958
|
-
this._base = new _ArraySchema2(arrayValidators.isArray());
|
|
959
|
-
return this._base;
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Creates a validator that asserts that every element passes the given validator.
|
|
963
|
-
*
|
|
964
|
-
* @param elementValidator
|
|
965
|
-
*/
|
|
966
|
-
withElements(elementValidator) {
|
|
967
|
-
return this.chain(arrayValidators.withElements(elementValidator));
|
|
968
|
-
}
|
|
969
|
-
/**
|
|
970
|
-
* Creates a validator that asserts that the input array is a tuple whose elements match
|
|
971
|
-
* the given validators.
|
|
972
|
-
*
|
|
973
|
-
* @param validators
|
|
974
|
-
*/
|
|
975
|
-
tuple(...validators) {
|
|
976
|
-
return this.chain(arrayValidators.tuple(...validators));
|
|
977
|
-
}
|
|
978
|
-
/**
|
|
979
|
-
* Creates a validator that validates the input array has the given minimum length.
|
|
980
|
-
* @param min The minimum number of elements (inclusive)
|
|
981
|
-
*/
|
|
982
|
-
minLength(min) {
|
|
983
|
-
return this.chain(arrayValidators.minLength(min));
|
|
984
|
-
}
|
|
985
|
-
/**
|
|
986
|
-
*
|
|
987
|
-
* Creates a validator that validates the input array has the given maximum length.
|
|
988
|
-
* @param max The maximum number of elements (inclusive)
|
|
989
|
-
*/
|
|
990
|
-
maxLength(max) {
|
|
991
|
-
return this.chain(arrayValidators.maxLength(max));
|
|
992
|
-
}
|
|
993
|
-
/**
|
|
994
|
-
* Casts to a readonly array.
|
|
995
|
-
* This is a shallow cast, elements of the array will not be changed.
|
|
996
|
-
*/
|
|
997
|
-
readonly() {
|
|
998
|
-
return this;
|
|
999
|
-
}
|
|
1000
|
-
/**
|
|
1001
|
-
* Casts the type parameter.
|
|
1002
|
-
*/
|
|
1003
|
-
cast() {
|
|
1004
|
-
return this;
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
|
-
__publicField2(_ArraySchema, "_base", null);
|
|
1008
|
-
var locale5 = {
|
|
1009
|
-
template: "type {value}"
|
|
1010
|
-
};
|
|
1011
|
-
function typeOfValidator(expected) {
|
|
1012
|
-
return createValidator(
|
|
1013
|
-
substitute(locale5.template, { value: expected }),
|
|
1014
|
-
(input) => {
|
|
1015
|
-
return input != null && typeof input === expected;
|
|
1016
|
-
}
|
|
1017
|
-
);
|
|
1018
|
-
}
|
|
1019
|
-
var typeOfValidatorCache = {};
|
|
1020
|
-
function cachedTypeOfValidator(type) {
|
|
1021
|
-
if (!(type in typeOfValidatorCache)) {
|
|
1022
|
-
typeOfValidatorCache[type] = typeOfValidator(type);
|
|
1023
|
-
}
|
|
1024
|
-
return typeOfValidatorCache[type];
|
|
1025
|
-
}
|
|
1026
|
-
var typeOfValidators = {
|
|
1027
|
-
get boolean() {
|
|
1028
|
-
return cachedTypeOfValidator("boolean");
|
|
1029
|
-
},
|
|
1030
|
-
get func() {
|
|
1031
|
-
return cachedTypeOfValidator("function");
|
|
1032
|
-
},
|
|
1033
|
-
get number() {
|
|
1034
|
-
return cachedTypeOfValidator("number");
|
|
1035
|
-
},
|
|
1036
|
-
get object() {
|
|
1037
|
-
return cachedTypeOfValidator("object");
|
|
1038
|
-
},
|
|
1039
|
-
get string() {
|
|
1040
|
-
return cachedTypeOfValidator("string");
|
|
1041
|
-
},
|
|
1042
|
-
get symbol() {
|
|
1043
|
-
return cachedTypeOfValidator("symbol");
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
850
|
+
|
|
851
|
+
// ../vinyl-validation/src/validation/validators.ts
|
|
1046
852
|
var locale6 = {
|
|
1047
|
-
length: "at most {value} arguments",
|
|
1048
|
-
actualLength: "{value} arguments"
|
|
1049
|
-
};
|
|
1050
|
-
var functionValidators = {
|
|
1051
|
-
length(max) {
|
|
1052
|
-
return createValidator(
|
|
1053
|
-
substitute(locale6.length, { value: max }),
|
|
1054
|
-
(input) => input.length <= max,
|
|
1055
|
-
(input) => substitute(locale6.actualLength, { value: input.length })
|
|
1056
|
-
);
|
|
1057
|
-
}
|
|
1058
|
-
};
|
|
1059
|
-
var _FunctionSchema = class _FunctionSchema2 extends ValueSchema {
|
|
1060
|
-
/**
|
|
1061
|
-
* The base Function validator validating that the input is a function.
|
|
1062
|
-
*/
|
|
1063
|
-
static get base() {
|
|
1064
|
-
if (this._base == null)
|
|
1065
|
-
this._base = new _FunctionSchema2(typeOfValidators.func);
|
|
1066
|
-
return this._base;
|
|
1067
|
-
}
|
|
1068
|
-
length(max) {
|
|
1069
|
-
return this.chain(functionValidators.length(max));
|
|
1070
|
-
}
|
|
1071
|
-
/**
|
|
1072
|
-
* Casts the function signature.
|
|
1073
|
-
* Function signatures, except for their required number of parameters, cannot be
|
|
1074
|
-
* meaningfully validated.
|
|
1075
|
-
*/
|
|
1076
|
-
cast() {
|
|
1077
|
-
return this;
|
|
1078
|
-
}
|
|
1079
|
-
};
|
|
1080
|
-
__publicField2(_FunctionSchema, "_base", null);
|
|
1081
|
-
var locale7 = {
|
|
1082
|
-
set: "Set",
|
|
1083
|
-
withElements: "Set<{value}>"
|
|
1084
|
-
};
|
|
1085
|
-
var setValidators = {
|
|
1086
|
-
/**
|
|
1087
|
-
* Creates a validator that asserts that the input is a set.
|
|
1088
|
-
*/
|
|
1089
|
-
isSet() {
|
|
1090
|
-
return createValidator(
|
|
1091
|
-
locale7.set,
|
|
1092
|
-
(input) => input instanceof Set
|
|
1093
|
-
);
|
|
1094
|
-
},
|
|
1095
|
-
/**
|
|
1096
|
-
* Creates a validator that asserts that every element passes the given validator.
|
|
1097
|
-
*
|
|
1098
|
-
* @param elementValidator
|
|
1099
|
-
*/
|
|
1100
|
-
withElements(elementValidator) {
|
|
1101
|
-
return createDeepValidator(
|
|
1102
|
-
substitute(locale7.withElements, {
|
|
1103
|
-
value: elementValidator.description
|
|
1104
|
-
}),
|
|
1105
|
-
(input, options, path) => {
|
|
1106
|
-
const errors = [];
|
|
1107
|
-
let i = 0;
|
|
1108
|
-
for (const element of input) {
|
|
1109
|
-
errors.push(
|
|
1110
|
-
...elementValidator.validate(
|
|
1111
|
-
element,
|
|
1112
|
-
options,
|
|
1113
|
-
path.concat(i.toString())
|
|
1114
|
-
)
|
|
1115
|
-
);
|
|
1116
|
-
if (!options.all && errors.length) return errors;
|
|
1117
|
-
i++;
|
|
1118
|
-
}
|
|
1119
|
-
return errors;
|
|
1120
|
-
}
|
|
1121
|
-
);
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
var _SetSchema = class _SetSchema2 extends ValueSchema {
|
|
1125
|
-
/**
|
|
1126
|
-
* The base SetSchema instance validating that the input is a Set.
|
|
1127
|
-
*/
|
|
1128
|
-
static get base() {
|
|
1129
|
-
if (this._base == null)
|
|
1130
|
-
this._base = new _SetSchema2(setValidators.isSet());
|
|
1131
|
-
return this._base;
|
|
1132
|
-
}
|
|
1133
|
-
/**
|
|
1134
|
-
* Creates a validator that asserts that every element passes the given validator.
|
|
1135
|
-
*
|
|
1136
|
-
* @param elementValidator
|
|
1137
|
-
*/
|
|
1138
|
-
withElements(elementValidator) {
|
|
1139
|
-
return this.chain(setValidators.withElements(elementValidator));
|
|
1140
|
-
}
|
|
1141
|
-
/**
|
|
1142
|
-
* Casts to a readonly set.
|
|
1143
|
-
* This is a shallow cast, elements of the array will not be changed.
|
|
1144
|
-
*/
|
|
1145
|
-
readonly() {
|
|
1146
|
-
return this;
|
|
1147
|
-
}
|
|
1148
|
-
/**
|
|
1149
|
-
* Casts the parameter type.
|
|
1150
|
-
*/
|
|
1151
|
-
cast() {
|
|
1152
|
-
return this;
|
|
1153
|
-
}
|
|
1154
|
-
};
|
|
1155
|
-
__publicField2(_SetSchema, "_base", null);
|
|
1156
|
-
var locale8 = {
|
|
1157
|
-
gte: "at least {value}",
|
|
1158
|
-
gt: "greater than {value}",
|
|
1159
|
-
lte: "at most {value}",
|
|
1160
|
-
lt: "less than {value}",
|
|
1161
|
-
within: "within {min} and {max}",
|
|
1162
|
-
safeInteger: "safe integer",
|
|
1163
|
-
finite: "finite"
|
|
1164
|
-
};
|
|
1165
|
-
var numberValidators = {
|
|
1166
|
-
/**
|
|
1167
|
-
* Creates a validator that asserts that the input number is at least the provided minimum
|
|
1168
|
-
* value.
|
|
1169
|
-
*
|
|
1170
|
-
* @param min The minimum (inclusive) the value may be.
|
|
1171
|
-
*/
|
|
1172
|
-
gte(min) {
|
|
1173
|
-
return createValidator(
|
|
1174
|
-
substitute(locale8.gte, { value: min }),
|
|
1175
|
-
(input) => input >= min
|
|
1176
|
-
);
|
|
1177
|
-
},
|
|
1178
|
-
/**
|
|
1179
|
-
* Creates a validator that asserts that the input number is greater than the provided minimum
|
|
1180
|
-
* value.
|
|
1181
|
-
*
|
|
1182
|
-
* @param min The minimum (exclusive) the value may be.
|
|
1183
|
-
*/
|
|
1184
|
-
gt(min) {
|
|
1185
|
-
return createValidator(
|
|
1186
|
-
substitute(locale8.gt, { value: min }),
|
|
1187
|
-
(input) => input > min
|
|
1188
|
-
);
|
|
1189
|
-
},
|
|
1190
|
-
/**
|
|
1191
|
-
* Creates a validator that asserts that the input number is at most the provided maximum
|
|
1192
|
-
* value.
|
|
1193
|
-
*
|
|
1194
|
-
* @param max The maximum (inclusive) the value may be.
|
|
1195
|
-
*/
|
|
1196
|
-
lte(max) {
|
|
1197
|
-
return createValidator(
|
|
1198
|
-
substitute(locale8.lte, { value: max }),
|
|
1199
|
-
(input) => input <= max
|
|
1200
|
-
);
|
|
1201
|
-
},
|
|
1202
|
-
/**
|
|
1203
|
-
* Creates a validator that asserts that the input number is less than the provided maximum
|
|
1204
|
-
* value.
|
|
1205
|
-
*
|
|
1206
|
-
* @param max The maximum (exclusive) the value may be.
|
|
1207
|
-
*/
|
|
1208
|
-
lt(max) {
|
|
1209
|
-
return createValidator(
|
|
1210
|
-
substitute(locale8.lt, { value: max }),
|
|
1211
|
-
(input) => input < max
|
|
1212
|
-
);
|
|
1213
|
-
},
|
|
1214
|
-
/**
|
|
1215
|
-
* Creates a validator that asserts that the input number is at least the provided minimum
|
|
1216
|
-
* and at most the provided maximum values.
|
|
1217
|
-
*
|
|
1218
|
-
* @param min The minimum (inclusive) value the input may be.
|
|
1219
|
-
* @param max The maximum (inclusive) value the input may be.
|
|
1220
|
-
*/
|
|
1221
|
-
within(min, max) {
|
|
1222
|
-
return createValidator(
|
|
1223
|
-
substitute(locale8.within, { min, max }),
|
|
1224
|
-
(input) => input >= min && input <= max
|
|
1225
|
-
);
|
|
1226
|
-
},
|
|
1227
|
-
/**
|
|
1228
|
-
* Creates a validator that asserts that the input number is finite.
|
|
1229
|
-
*/
|
|
1230
|
-
finite() {
|
|
1231
|
-
return createValidator(locale8.finite, (input) => Number.isFinite(input));
|
|
1232
|
-
},
|
|
1233
|
-
/**
|
|
1234
|
-
* Creates a validator that asserts that the input number is a safe integer.
|
|
1235
|
-
*/
|
|
1236
|
-
safeInteger() {
|
|
1237
|
-
return createValidator(
|
|
1238
|
-
locale8.safeInteger,
|
|
1239
|
-
(input) => Number.isSafeInteger(input)
|
|
1240
|
-
);
|
|
1241
|
-
}
|
|
1242
|
-
};
|
|
1243
|
-
var _NumberSchema = class _NumberSchema2 extends ValueSchema {
|
|
1244
|
-
/**
|
|
1245
|
-
* The base Object validator validating that the input is an object.
|
|
1246
|
-
*/
|
|
1247
|
-
static get base() {
|
|
1248
|
-
if (this._base == null)
|
|
1249
|
-
this._base = new _NumberSchema2(typeOfValidators.number);
|
|
1250
|
-
return this._base;
|
|
1251
|
-
}
|
|
1252
|
-
/**
|
|
1253
|
-
* Creates a validator that asserts that the input number is at least the provided minimum
|
|
1254
|
-
* value.
|
|
1255
|
-
*
|
|
1256
|
-
* @param min The minimum (inclusive) the value may be.
|
|
1257
|
-
*/
|
|
1258
|
-
gte(min) {
|
|
1259
|
-
return this.chain(numberValidators.gte(min));
|
|
1260
|
-
}
|
|
1261
|
-
/**
|
|
1262
|
-
* Creates a validator that asserts that the input number is greater than the provided minimum
|
|
1263
|
-
* value.
|
|
1264
|
-
*
|
|
1265
|
-
* @param min The minimum (exclusive) the value may be.
|
|
1266
|
-
*/
|
|
1267
|
-
gt(min) {
|
|
1268
|
-
return this.chain(numberValidators.gt(min));
|
|
1269
|
-
}
|
|
1270
|
-
/**
|
|
1271
|
-
* Creates a validator that asserts that the input number is at most the provided maximum
|
|
1272
|
-
* value.
|
|
1273
|
-
*
|
|
1274
|
-
* @param max The maximum (inclusive) the value may be.
|
|
1275
|
-
*/
|
|
1276
|
-
lte(max) {
|
|
1277
|
-
return this.chain(numberValidators.lte(max));
|
|
1278
|
-
}
|
|
1279
|
-
/**
|
|
1280
|
-
* Creates a validator that asserts that the input number is less than the provided maximum
|
|
1281
|
-
* value.
|
|
1282
|
-
*
|
|
1283
|
-
* @param max The maximum (exclusive) the value may be.
|
|
1284
|
-
*/
|
|
1285
|
-
lt(max) {
|
|
1286
|
-
return this.chain(numberValidators.lt(max));
|
|
1287
|
-
}
|
|
1288
|
-
/**
|
|
1289
|
-
* Creates a validator that asserts that the input number is at least the provided minimum
|
|
1290
|
-
* and at most the provided maximum values.
|
|
1291
|
-
*
|
|
1292
|
-
* @param min The minimum (inclusive) value the input may be.
|
|
1293
|
-
* @param max The maximum (inclusive) value the input may be.
|
|
1294
|
-
*/
|
|
1295
|
-
within(min, max) {
|
|
1296
|
-
return this.chain(numberValidators.within(min, max));
|
|
1297
|
-
}
|
|
1298
|
-
/**
|
|
1299
|
-
* Creates a validator that asserts that the input number is finite.
|
|
1300
|
-
*/
|
|
1301
|
-
finite() {
|
|
1302
|
-
return this.chain(numberValidators.finite());
|
|
1303
|
-
}
|
|
1304
|
-
/**
|
|
1305
|
-
* Creates a validator that asserts that the input number is a safe integer.
|
|
1306
|
-
*/
|
|
1307
|
-
safeInteger() {
|
|
1308
|
-
return this.chain(numberValidators.safeInteger());
|
|
1309
|
-
}
|
|
1310
|
-
};
|
|
1311
|
-
__publicField2(_NumberSchema, "_base", null);
|
|
1312
|
-
function isValidatorWithPartial(validator) {
|
|
1313
|
-
return "partial" in validator && "partialDeep" in validator;
|
|
1314
|
-
}
|
|
1315
|
-
function maybeToDeepPartial(validator) {
|
|
1316
|
-
return isValidatorWithPartial(validator) ? validator.partialDeep() : validator;
|
|
1317
|
-
}
|
|
1318
|
-
function maybeToPartial(validator) {
|
|
1319
|
-
return isValidatorWithPartial(validator) ? validator.partial() : validator;
|
|
1320
|
-
}
|
|
1321
|
-
var locale9 = {
|
|
1322
|
-
extend: "{\n{body}\n}",
|
|
1323
|
-
prop: "{key}: {value}",
|
|
1324
|
-
propSeparator: ",\n",
|
|
1325
|
-
indent: " ",
|
|
1326
|
-
required: `property '{key}' is required`
|
|
1327
|
-
};
|
|
1328
|
-
var objectValidators = {
|
|
1329
|
-
/**
|
|
1330
|
-
* Creates a validator that validates the input has properties that pass their respective
|
|
1331
|
-
* validators.
|
|
1332
|
-
*
|
|
1333
|
-
* @param propertyValidators
|
|
1334
|
-
*/
|
|
1335
|
-
properties(propertyValidators) {
|
|
1336
|
-
const propertiesDescriptions = [];
|
|
1337
|
-
const keys = ownKeys(propertyValidators);
|
|
1338
|
-
for (const key of keys) {
|
|
1339
|
-
const validator2 = propertyValidators[key];
|
|
1340
|
-
propertiesDescriptions.push(
|
|
1341
|
-
substitute(locale9.prop, {
|
|
1342
|
-
key: String(key) + (validator2.options.optional ? "?" : ""),
|
|
1343
|
-
value: validator2.description
|
|
1344
|
-
})
|
|
1345
|
-
);
|
|
1346
|
-
}
|
|
1347
|
-
const description = substitute(locale9.extend, {
|
|
1348
|
-
body: propertiesDescriptions.join(locale9.propSeparator).split("\n").map((line) => locale9.indent + line).join("\n")
|
|
1349
|
-
});
|
|
1350
|
-
const validator = createDeepValidator(
|
|
1351
|
-
description,
|
|
1352
|
-
(input, options, path) => {
|
|
1353
|
-
const errors = [];
|
|
1354
|
-
for (const key of keys) {
|
|
1355
|
-
const validator2 = propertyValidators[key];
|
|
1356
|
-
if (key in input) {
|
|
1357
|
-
const value = input[key];
|
|
1358
|
-
errors.push(
|
|
1359
|
-
...validator2.validate(
|
|
1360
|
-
value,
|
|
1361
|
-
options,
|
|
1362
|
-
path.concat(String(key))
|
|
1363
|
-
)
|
|
1364
|
-
);
|
|
1365
|
-
} else {
|
|
1366
|
-
if (!validator2.options.optional) {
|
|
1367
|
-
errors.push({
|
|
1368
|
-
message: substitute(locale9.required, { key }),
|
|
1369
|
-
path: path.concat(String(key))
|
|
1370
|
-
});
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
if (!options.all && errors.length) return errors;
|
|
1374
|
-
}
|
|
1375
|
-
return errors;
|
|
1376
|
-
}
|
|
1377
|
-
);
|
|
1378
|
-
return merge(validator, {
|
|
1379
|
-
partial() {
|
|
1380
|
-
const optionalPropertyValidators = {};
|
|
1381
|
-
for (const key of keys) {
|
|
1382
|
-
optionalPropertyValidators[key] = propertyValidators[key].optional();
|
|
1383
|
-
}
|
|
1384
|
-
return objectValidators.properties(
|
|
1385
|
-
optionalPropertyValidators
|
|
1386
|
-
);
|
|
1387
|
-
},
|
|
1388
|
-
partialDeep() {
|
|
1389
|
-
const optionalPropertyValidators = {};
|
|
1390
|
-
for (const key of keys) {
|
|
1391
|
-
optionalPropertyValidators[key] = maybeToDeepPartial(
|
|
1392
|
-
propertyValidators[key].optional()
|
|
1393
|
-
);
|
|
1394
|
-
}
|
|
1395
|
-
return objectValidators.properties(
|
|
1396
|
-
optionalPropertyValidators
|
|
1397
|
-
);
|
|
1398
|
-
}
|
|
1399
|
-
});
|
|
1400
|
-
}
|
|
1401
|
-
};
|
|
1402
|
-
var _ObjectSchema = class _ObjectSchema2 extends ValueSchema {
|
|
1403
|
-
/**
|
|
1404
|
-
* The base Object validator validating that the input is an object.
|
|
1405
|
-
*/
|
|
1406
|
-
static get base() {
|
|
1407
|
-
if (this._base == null)
|
|
1408
|
-
this._base = new _ObjectSchema2(typeOfValidators.object);
|
|
1409
|
-
return this._base;
|
|
1410
|
-
}
|
|
1411
|
-
/**
|
|
1412
|
-
* Creates a validator that validates the input has properties that pass their respective
|
|
1413
|
-
* validators.
|
|
1414
|
-
*
|
|
1415
|
-
* @param propertyValidators
|
|
1416
|
-
*/
|
|
1417
|
-
extend(propertyValidators) {
|
|
1418
|
-
return this.chain(objectValidators.properties(propertyValidators));
|
|
1419
|
-
}
|
|
1420
|
-
/**
|
|
1421
|
-
* Allows all properties to be undefined.
|
|
1422
|
-
*/
|
|
1423
|
-
partial() {
|
|
1424
|
-
return this.clone(maybeToPartial);
|
|
1425
|
-
}
|
|
1426
|
-
/**
|
|
1427
|
-
* Allows all recursive properties to be undefined.
|
|
1428
|
-
*/
|
|
1429
|
-
partialDeep() {
|
|
1430
|
-
return this.clone(maybeToDeepPartial);
|
|
1431
|
-
}
|
|
1432
|
-
/**
|
|
1433
|
-
* Casts the type parameter.
|
|
1434
|
-
*/
|
|
1435
|
-
cast() {
|
|
1436
|
-
return this;
|
|
1437
|
-
}
|
|
1438
|
-
};
|
|
1439
|
-
__publicField2(_ObjectSchema, "_base", null);
|
|
1440
|
-
var locale10 = {
|
|
1441
|
-
notEmpty: "not empty",
|
|
1442
|
-
minLength: "at least {value} characters",
|
|
1443
|
-
maxLength: "at most {value} characters",
|
|
1444
|
-
noWhitespace: "no whitespace characters",
|
|
1445
|
-
matches: "matches {value}"
|
|
1446
|
-
};
|
|
1447
|
-
var stringValidators = {
|
|
1448
|
-
/**
|
|
1449
|
-
* Creates a validator that asserts that the input is not empty.
|
|
1450
|
-
*/
|
|
1451
|
-
notEmpty() {
|
|
1452
|
-
return createValidator(locale10.notEmpty, (input) => input !== "");
|
|
1453
|
-
},
|
|
1454
|
-
/**
|
|
1455
|
-
* Creates a validator that asserts that the input string has at least the given minimum
|
|
1456
|
-
* length.
|
|
1457
|
-
*
|
|
1458
|
-
* @param min The string must be at least this length.
|
|
1459
|
-
*/
|
|
1460
|
-
minLength(min) {
|
|
1461
|
-
return createValidator(
|
|
1462
|
-
substitute(locale10.minLength, { value: min }),
|
|
1463
|
-
(input) => input.length >= min
|
|
1464
|
-
);
|
|
1465
|
-
},
|
|
1466
|
-
/**
|
|
1467
|
-
* Creates a validator that asserts that the input string has at most the given maximum
|
|
1468
|
-
* length.
|
|
1469
|
-
*
|
|
1470
|
-
* @param max The string must be at most this length.
|
|
1471
|
-
*/
|
|
1472
|
-
maxLength(max) {
|
|
1473
|
-
return createValidator(
|
|
1474
|
-
substitute(locale10.maxLength, { value: max }),
|
|
1475
|
-
(input) => input.length <= max
|
|
1476
|
-
);
|
|
1477
|
-
},
|
|
1478
|
-
/**
|
|
1479
|
-
* Creates a validator that asserts that the input string has no whitespace characters.
|
|
1480
|
-
* Whitespace characters include space, new line, carriage return, and tab.
|
|
1481
|
-
*/
|
|
1482
|
-
noWhitespace() {
|
|
1483
|
-
return createValidator(
|
|
1484
|
-
locale10.noWhitespace,
|
|
1485
|
-
(input) => input.search(/\s/g) === -1
|
|
1486
|
-
);
|
|
1487
|
-
},
|
|
1488
|
-
/**
|
|
1489
|
-
* Creates a validator that asserts that the input string matches the given regex.
|
|
1490
|
-
* @param regex
|
|
1491
|
-
*/
|
|
1492
|
-
matches(regex) {
|
|
1493
|
-
return createValidator(
|
|
1494
|
-
substitute(locale10.matches, { value: regex.toString() }),
|
|
1495
|
-
(input) => {
|
|
1496
|
-
return regex.test(input);
|
|
1497
|
-
}
|
|
1498
|
-
);
|
|
1499
|
-
}
|
|
1500
|
-
};
|
|
1501
|
-
var _StringSchema = class _StringSchema2 extends ValueSchema {
|
|
1502
|
-
/**
|
|
1503
|
-
* The base SetSchema instance validating that the input is a Set.
|
|
1504
|
-
*/
|
|
1505
|
-
static get base() {
|
|
1506
|
-
if (this._base == null)
|
|
1507
|
-
this._base = new _StringSchema2(typeOfValidators.string);
|
|
1508
|
-
return this._base;
|
|
1509
|
-
}
|
|
1510
|
-
/**
|
|
1511
|
-
* Creates a validator that asserts that the input is not empty.
|
|
1512
|
-
*/
|
|
1513
|
-
notEmpty() {
|
|
1514
|
-
return this.chain(stringValidators.notEmpty());
|
|
1515
|
-
}
|
|
1516
|
-
/**
|
|
1517
|
-
* Creates a validator that asserts that the input string has at least the given minimum
|
|
1518
|
-
* length.
|
|
1519
|
-
*
|
|
1520
|
-
* @param min The string must be at least this length.
|
|
1521
|
-
*/
|
|
1522
|
-
minLength(min) {
|
|
1523
|
-
return this.chain(stringValidators.minLength(min));
|
|
1524
|
-
}
|
|
1525
|
-
/**
|
|
1526
|
-
* Creates a validator that asserts that the input string has at most the given maximum
|
|
1527
|
-
* length.
|
|
1528
|
-
*
|
|
1529
|
-
* @param max The string must be at most this length.
|
|
1530
|
-
*/
|
|
1531
|
-
maxLength(max) {
|
|
1532
|
-
return this.chain(stringValidators.maxLength(max));
|
|
1533
|
-
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Creates a validator that asserts that the input string has no whitespace characters.
|
|
1536
|
-
* Whitespace characters include space, new line, carriage return, and tab.
|
|
1537
|
-
*/
|
|
1538
|
-
noWhitespace() {
|
|
1539
|
-
return this.chain(stringValidators.noWhitespace());
|
|
1540
|
-
}
|
|
1541
|
-
/**
|
|
1542
|
-
* Creates a validator that asserts that the input string matches the given regex.
|
|
1543
|
-
* @param regex
|
|
1544
|
-
*/
|
|
1545
|
-
matches(regex) {
|
|
1546
|
-
return this.chain(stringValidators.matches(regex));
|
|
1547
|
-
}
|
|
1548
|
-
};
|
|
1549
|
-
__publicField2(_StringSchema, "_base", null);
|
|
1550
|
-
var StringSchema = _StringSchema;
|
|
1551
|
-
var locale11 = {
|
|
1552
|
-
record: "{ [key: {key}]: {value} }"
|
|
1553
|
-
};
|
|
1554
|
-
var recordValidators = {
|
|
1555
|
-
/**
|
|
1556
|
-
* Returns a validator that asserts that the object's own enumerable properties has keys and
|
|
1557
|
-
* values that match their respective validators.
|
|
1558
|
-
*
|
|
1559
|
-
* Prototype members are not included.
|
|
1560
|
-
* Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed
|
|
1561
|
-
* to the key validator as '0'.
|
|
1562
|
-
*
|
|
1563
|
-
* @param keyValidator Validates each key.
|
|
1564
|
-
* @param valueValidator Validates each value.
|
|
1565
|
-
*/
|
|
1566
|
-
record(keyValidator, valueValidator) {
|
|
1567
|
-
return createDeepValidator(
|
|
1568
|
-
substitute(locale11.record, {
|
|
1569
|
-
key: keyValidator.description,
|
|
1570
|
-
value: valueValidator.description
|
|
1571
|
-
}),
|
|
1572
|
-
(input, options, path) => {
|
|
1573
|
-
const errors = [];
|
|
1574
|
-
for (const key of ownKeys(input)) {
|
|
1575
|
-
const keyStr = String(key);
|
|
1576
|
-
errors.push(
|
|
1577
|
-
...keyValidator.validate(
|
|
1578
|
-
key,
|
|
1579
|
-
options,
|
|
1580
|
-
path.concat(`[${keyStr}]`)
|
|
1581
|
-
)
|
|
1582
|
-
);
|
|
1583
|
-
if (!options.all && errors.length) return errors;
|
|
1584
|
-
const value = input[key];
|
|
1585
|
-
errors.push(
|
|
1586
|
-
...valueValidator.validate(
|
|
1587
|
-
value,
|
|
1588
|
-
options,
|
|
1589
|
-
path.concat(keyStr)
|
|
1590
|
-
)
|
|
1591
|
-
);
|
|
1592
|
-
if (!options.all && errors.length) return errors;
|
|
1593
|
-
}
|
|
1594
|
-
return errors;
|
|
1595
|
-
}
|
|
1596
|
-
);
|
|
1597
|
-
}
|
|
1598
|
-
};
|
|
1599
|
-
var _RecordSchema = class _RecordSchema2 extends ValueSchema {
|
|
1600
|
-
/**
|
|
1601
|
-
* The base Object validator validating that the input is an object.
|
|
1602
|
-
*/
|
|
1603
|
-
static get base() {
|
|
1604
|
-
if (this._base == null)
|
|
1605
|
-
this._base = new _RecordSchema2(typeOfValidators.object);
|
|
1606
|
-
return this._base;
|
|
1607
|
-
}
|
|
1608
|
-
static get defaultKeyValidator() {
|
|
1609
|
-
return StringSchema.base;
|
|
1610
|
-
}
|
|
1611
|
-
/**
|
|
1612
|
-
* Returns a validator that asserts that the object's own enumerable properties has keys and
|
|
1613
|
-
* values that match their respective validators.
|
|
1614
|
-
*
|
|
1615
|
-
* Prototype members are not included.
|
|
1616
|
-
* Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed
|
|
1617
|
-
* to the key validator as '0'.
|
|
1618
|
-
*
|
|
1619
|
-
* @param keyValidator Validates each key.
|
|
1620
|
-
* @param valueValidator Validates each value.
|
|
1621
|
-
*/
|
|
1622
|
-
record(keyValidator, valueValidator) {
|
|
1623
|
-
return this.chain(recordValidators.record(keyValidator, valueValidator));
|
|
1624
|
-
}
|
|
1625
|
-
/**
|
|
1626
|
-
* Returns a validator that asserts that the object's own enumerable properties has
|
|
1627
|
-
* string keys and values that match the given validator.
|
|
1628
|
-
*
|
|
1629
|
-
* Prototype members are not included.
|
|
1630
|
-
*
|
|
1631
|
-
* @param valueValidator Validates each value.
|
|
1632
|
-
*/
|
|
1633
|
-
recordValues(valueValidator) {
|
|
1634
|
-
return this.record(_RecordSchema2.defaultKeyValidator, valueValidator);
|
|
1635
|
-
}
|
|
1636
|
-
/**
|
|
1637
|
-
* Casts to a ReadonlyRecord
|
|
1638
|
-
*/
|
|
1639
|
-
readonly() {
|
|
1640
|
-
return this;
|
|
1641
|
-
}
|
|
1642
|
-
/**
|
|
1643
|
-
* Casts the type parameter.
|
|
1644
|
-
*/
|
|
1645
|
-
cast() {
|
|
1646
|
-
return this;
|
|
1647
|
-
}
|
|
1648
|
-
};
|
|
1649
|
-
__publicField2(_RecordSchema, "_base", null);
|
|
1650
|
-
var locale12 = {
|
|
1651
853
|
isOneOf: "one of: {value}",
|
|
1652
854
|
instanceOf: "instance of {value}",
|
|
1653
855
|
oneOfSeparator: " | "
|
|
@@ -1655,8 +857,8 @@
|
|
|
1655
857
|
function isOneOf(...possibleValues) {
|
|
1656
858
|
return new ValueSchema(
|
|
1657
859
|
createValidator(
|
|
1658
|
-
substitute(
|
|
1659
|
-
value: possibleValues.join(
|
|
860
|
+
substitute(locale6.isOneOf, {
|
|
861
|
+
value: possibleValues.join(locale6.oneOfSeparator)
|
|
1660
862
|
}),
|
|
1661
863
|
(input) => possibleValues.includes(input)
|
|
1662
864
|
)
|
|
@@ -1933,7 +1135,7 @@
|
|
|
1933
1135
|
addIfPresent(
|
|
1934
1136
|
__spreadValues(__spreadValues({
|
|
1935
1137
|
bandwidth: Number(attrs["BANDWIDTH"]),
|
|
1936
|
-
uri
|
|
1138
|
+
uri: substituteHlsVariables(uri, defines)
|
|
1937
1139
|
}, attrs["FRAME-RATE"] && {
|
|
1938
1140
|
frameRate: Number(attrs["FRAME-RATE"])
|
|
1939
1141
|
}), attrs.RESOLUTION && parseResolution(attrs.RESOLUTION)),
|
|
@@ -1953,6 +1155,9 @@
|
|
|
1953
1155
|
const attrs = parseAttributes(attrReader);
|
|
1954
1156
|
const type = attrs["TYPE"];
|
|
1955
1157
|
renditionTypeValidator.assert(type);
|
|
1158
|
+
if (attrs["URI"]) {
|
|
1159
|
+
attrs["URI"] = substituteHlsVariables(attrs["URI"], defines);
|
|
1160
|
+
}
|
|
1956
1161
|
alternativeRenditions.push(
|
|
1957
1162
|
addIfPresent(
|
|
1958
1163
|
__spreadValues(__spreadValues({
|
|
@@ -1999,6 +1204,10 @@
|
|
|
1999
1204
|
}
|
|
2000
1205
|
return { variants, alternativeRenditions, sessionData, defines };
|
|
2001
1206
|
}
|
|
1207
|
+
function substituteHlsVariables(value, variables) {
|
|
1208
|
+
if (!value || Object.keys(variables).length === 0) return value;
|
|
1209
|
+
return substitute(value, variables, HLS_VARIABLE_PATTERN);
|
|
1210
|
+
}
|
|
2002
1211
|
function parseResolution(resolution) {
|
|
2003
1212
|
const parts = resolution.split("x");
|
|
2004
1213
|
if (parts.length !== 2) {
|
|
@@ -2016,92 +1225,71 @@
|
|
|
2016
1225
|
return { width, height };
|
|
2017
1226
|
}
|
|
2018
1227
|
|
|
2019
|
-
// ../vinyl-util/
|
|
2020
|
-
var __defProp4 = Object.defineProperty;
|
|
2021
|
-
var __getOwnPropSymbols4 = Object.getOwnPropertySymbols;
|
|
2022
|
-
var __hasOwnProp4 = Object.prototype.hasOwnProperty;
|
|
2023
|
-
var __propIsEnum4 = Object.prototype.propertyIsEnumerable;
|
|
2024
|
-
var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2025
|
-
var __spreadValues4 = (a, b) => {
|
|
2026
|
-
for (var prop in b || (b = {}))
|
|
2027
|
-
if (__hasOwnProp4.call(b, prop))
|
|
2028
|
-
__defNormalProp4(a, prop, b[prop]);
|
|
2029
|
-
if (__getOwnPropSymbols4)
|
|
2030
|
-
for (var prop of __getOwnPropSymbols4(b)) {
|
|
2031
|
-
if (__propIsEnum4.call(b, prop))
|
|
2032
|
-
__defNormalProp4(a, prop, b[prop]);
|
|
2033
|
-
}
|
|
2034
|
-
return a;
|
|
2035
|
-
};
|
|
2036
|
-
var __objRest = (source, exclude) => {
|
|
2037
|
-
var target = {};
|
|
2038
|
-
for (var prop in source)
|
|
2039
|
-
if (__hasOwnProp4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2040
|
-
target[prop] = source[prop];
|
|
2041
|
-
if (source != null && __getOwnPropSymbols4)
|
|
2042
|
-
for (var prop of __getOwnPropSymbols4(source)) {
|
|
2043
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum4.call(source, prop))
|
|
2044
|
-
target[prop] = source[prop];
|
|
2045
|
-
}
|
|
2046
|
-
return target;
|
|
2047
|
-
};
|
|
2048
|
-
var __publicField3 = (obj, key, value) => __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1228
|
+
// ../vinyl-util/test/browserTestUtil/mock/createSpyFactory.ts
|
|
2049
1229
|
var createSpy = jasmine.createSpy;
|
|
2050
1230
|
function createSpy2(key) {
|
|
2051
1231
|
return createSpy(String(key));
|
|
2052
1232
|
}
|
|
1233
|
+
|
|
1234
|
+
// ../vinyl-util/test/browserTestUtil/mock/dom/lib.dom.ts
|
|
2053
1235
|
var MockAbortSignal = class {
|
|
2054
1236
|
constructor() {
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
1237
|
+
__publicField(this, "aborted", false);
|
|
1238
|
+
__publicField(this, "onabort", null);
|
|
1239
|
+
__publicField(this, "reason");
|
|
1240
|
+
__publicField(this, "throwIfAborted", createSpy2("throwIfAborted"));
|
|
1241
|
+
__publicField(this, "addEventListener", createSpy2("addEventListener"));
|
|
1242
|
+
__publicField(this, "removeEventListener", createSpy2(
|
|
2061
1243
|
"removeEventListener"
|
|
2062
1244
|
));
|
|
2063
|
-
|
|
1245
|
+
__publicField(this, "dispatchEvent", createSpy2("dispatchEvent"));
|
|
2064
1246
|
}
|
|
2065
1247
|
};
|
|
2066
1248
|
var MockMediaSource = class {
|
|
2067
1249
|
constructor() {
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
1250
|
+
__publicField(this, "activeSourceBuffers");
|
|
1251
|
+
__publicField(this, "duration", 0);
|
|
1252
|
+
__publicField(this, "onsourceclose", null);
|
|
1253
|
+
__publicField(this, "onsourceended", null);
|
|
1254
|
+
__publicField(this, "onsourceopen", null);
|
|
1255
|
+
__publicField(this, "readyState", "closed");
|
|
1256
|
+
__publicField(this, "sourceBuffers");
|
|
1257
|
+
__publicField(this, "addSourceBuffer", createSpy2("addSourceBuffer"));
|
|
1258
|
+
__publicField(this, "clearLiveSeekableRange", createSpy2(
|
|
2077
1259
|
"clearLiveSeekableRange"
|
|
2078
1260
|
));
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
1261
|
+
__publicField(this, "endOfStream", createSpy2("endOfStream"));
|
|
1262
|
+
__publicField(this, "removeSourceBuffer", createSpy2("removeSourceBuffer"));
|
|
1263
|
+
__publicField(this, "setLiveSeekableRange", createSpy2(
|
|
2082
1264
|
"setLiveSeekableRange"
|
|
2083
1265
|
));
|
|
2084
|
-
|
|
2085
|
-
|
|
1266
|
+
__publicField(this, "addEventListener", createSpy2("addEventListener"));
|
|
1267
|
+
__publicField(this, "removeEventListener", createSpy2(
|
|
2086
1268
|
"removeEventListener"
|
|
2087
1269
|
));
|
|
2088
|
-
|
|
1270
|
+
__publicField(this, "dispatchEvent", createSpy2("dispatchEvent"));
|
|
2089
1271
|
}
|
|
2090
1272
|
};
|
|
1273
|
+
|
|
1274
|
+
// ../vinyl-util/test/browserTestUtil/mock/dom/globals.ts
|
|
2091
1275
|
var MockMediaSourceGlobal = class extends MockMediaSource {
|
|
2092
1276
|
};
|
|
2093
|
-
|
|
2094
|
-
|
|
1277
|
+
__publicField(MockMediaSourceGlobal, "canConstructInDedicatedWorker", false);
|
|
1278
|
+
__publicField(MockMediaSourceGlobal, "isTypeSupported", createSpy2(
|
|
2095
1279
|
"isTypeSupported"
|
|
2096
1280
|
));
|
|
2097
1281
|
var MockAbortSignalGlobal = class extends MockAbortSignal {
|
|
2098
1282
|
};
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
1283
|
+
__publicField(MockAbortSignalGlobal, "abort", createSpy2("abort"));
|
|
1284
|
+
__publicField(MockAbortSignalGlobal, "any", createSpy2("any"));
|
|
1285
|
+
__publicField(MockAbortSignalGlobal, "timeout", createSpy2("timeout"));
|
|
1286
|
+
|
|
1287
|
+
// ../vinyl-util/test/browserTestUtil/expect/expectNothing.ts
|
|
2102
1288
|
function expectNothing() {
|
|
2103
1289
|
expect(true).toBeTruthy();
|
|
2104
1290
|
}
|
|
1291
|
+
|
|
1292
|
+
// ../vinyl-util/test/browserTestUtil/env/jasmineEnv.ts
|
|
2105
1293
|
var nextTestTimeoutOverridden = false;
|
|
2106
1294
|
function setTestTimeout(timeout) {
|
|
2107
1295
|
let originalTimeout = null;
|
|
@@ -2115,6 +1303,8 @@
|
|
|
2115
1303
|
if (nextTestTimeoutOverridden) nextTestTimeoutOverridden = false;
|
|
2116
1304
|
});
|
|
2117
1305
|
}
|
|
1306
|
+
|
|
1307
|
+
// ../vinyl-util/test/browserTestUtil/benchmark/Benchmark.ts
|
|
2118
1308
|
var now;
|
|
2119
1309
|
if (typeof window !== "undefined" && typeof window.performance !== "undefined" && typeof window.performance.now !== "undefined") {
|
|
2120
1310
|
now = () => window.performance.now();
|
|
@@ -2125,9 +1315,9 @@
|
|
|
2125
1315
|
}
|
|
2126
1316
|
var BenchmarkRunResults = class {
|
|
2127
1317
|
constructor(name) {
|
|
2128
|
-
this
|
|
2129
|
-
|
|
2130
|
-
|
|
1318
|
+
__publicField(this, "name", name);
|
|
1319
|
+
__publicField(this, "cycleResults", []);
|
|
1320
|
+
__publicField(this, "_totalSamples", 0);
|
|
2131
1321
|
}
|
|
2132
1322
|
get totalSamples() {
|
|
2133
1323
|
return this._totalSamples;
|
|
@@ -2178,8 +1368,11 @@
|
|
|
2178
1368
|
};
|
|
2179
1369
|
var RunResultsComparison = class {
|
|
2180
1370
|
constructor(name, results) {
|
|
2181
|
-
this
|
|
2182
|
-
|
|
1371
|
+
__publicField(this, "name", name);
|
|
1372
|
+
/**
|
|
1373
|
+
* Sorted by median ops/s from slowest to fastest.
|
|
1374
|
+
*/
|
|
1375
|
+
__publicField(this, "results");
|
|
2183
1376
|
this.results = results.sort((a, b) => {
|
|
2184
1377
|
return a.meanOpsPerSec - b.meanOpsPerSec;
|
|
2185
1378
|
});
|
|
@@ -2224,7 +1417,7 @@
|
|
|
2224
1417
|
maxCycleDuration: 0.5,
|
|
2225
1418
|
cycles: 9
|
|
2226
1419
|
};
|
|
2227
|
-
var _Benchmark = class
|
|
1420
|
+
var _Benchmark = class _Benchmark {
|
|
2228
1421
|
/**
|
|
2229
1422
|
* Constructs a new Benchmark.
|
|
2230
1423
|
*
|
|
@@ -2234,14 +1427,14 @@
|
|
|
2234
1427
|
* @param options Optional configuration for the benchmark.
|
|
2235
1428
|
*/
|
|
2236
1429
|
constructor(name, executor, options) {
|
|
2237
|
-
this
|
|
2238
|
-
this
|
|
2239
|
-
|
|
2240
|
-
this.options =
|
|
1430
|
+
__publicField(this, "name", name);
|
|
1431
|
+
__publicField(this, "executor", executor);
|
|
1432
|
+
__publicField(this, "options");
|
|
1433
|
+
this.options = __spreadValues(__spreadValues({}, defaultBenchmarkOptions), options);
|
|
2241
1434
|
}
|
|
2242
1435
|
async run() {
|
|
2243
1436
|
const opts = this.options;
|
|
2244
|
-
await
|
|
1437
|
+
await _Benchmark.semaphore;
|
|
2245
1438
|
const warmupTimeMs = opts.warmupTime * 1e3;
|
|
2246
1439
|
const cycleStart = now();
|
|
2247
1440
|
let isAsync = false;
|
|
@@ -2259,7 +1452,7 @@
|
|
|
2259
1452
|
}
|
|
2260
1453
|
return results;
|
|
2261
1454
|
})();
|
|
2262
|
-
|
|
1455
|
+
_Benchmark.semaphore = resultsPromise;
|
|
2263
1456
|
return await resultsPromise;
|
|
2264
1457
|
}
|
|
2265
1458
|
/**
|
|
@@ -2285,7 +1478,7 @@
|
|
|
2285
1478
|
};
|
|
2286
1479
|
}
|
|
2287
1480
|
};
|
|
2288
|
-
|
|
1481
|
+
__publicField(_Benchmark, "semaphore", nextFrame());
|
|
2289
1482
|
var Benchmark = _Benchmark;
|
|
2290
1483
|
function benchmark(name, executor, options) {
|
|
2291
1484
|
const benchmark2 = new Benchmark(name, executor, options);
|
|
@@ -2312,7 +1505,6 @@
|
|
|
2312
1505
|
const sum = values.reduce((acc, value) => acc + value, 0);
|
|
2313
1506
|
return sum / values.length;
|
|
2314
1507
|
}
|
|
2315
|
-
var createSpy3 = jasmine.createSpy;
|
|
2316
1508
|
|
|
2317
1509
|
// test/benchmark/setup.ts
|
|
2318
1510
|
function setupBenchmark() {
|