@amazon/vinyl-mpd-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.
Files changed (34) hide show
  1. package/dist/dashTestAssets/types/current/tsconfig.tsbuildinfo +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/test/benchmark.es5.js +111 -201
  5. package/dist/test/benchmark.js +1186 -1758
  6. package/dist/test/benchmark.js.map +4 -4
  7. package/dist/types/current/manifest/dashManifestXmlRules.d.ts.map +1 -1
  8. package/dist/types/current/manifest/dashParser.d.ts.map +1 -1
  9. package/dist/types/current/manifest/dashParser2.d.ts +31 -0
  10. package/dist/types/current/manifest/dashParser2.d.ts.map +1 -0
  11. package/dist/types/current/manifest/dashParser2.js +36 -0
  12. package/dist/types/current/manifest/ext/drm/amzXmlRules.d.ts +8 -0
  13. package/dist/types/current/manifest/ext/drm/amzXmlRules.d.ts.map +1 -0
  14. package/dist/types/current/manifest/ext/drm/amzXmlRules.js +17 -0
  15. package/dist/types/current/manifest/ext/drm/cencXmlRules.d.ts.map +1 -1
  16. package/dist/types/current/manifest/ext/drm/cencXmlRules.js +1 -1
  17. package/dist/types/current/manifest/ext/drm/contentProtection.js +1 -1
  18. package/dist/types/current/manifest/ext/drm/playreadyXmlRules.d.ts.map +1 -1
  19. package/dist/types/current/tsconfig.tsbuildinfo +1 -1
  20. package/dist/types/current/xmlns/amazon/music3p/2020.d.ts +16 -0
  21. package/dist/types/current/xmlns/amazon/music3p/2020.d.ts.map +1 -0
  22. package/dist/types/current/xmlns/amazon/music3p/2020.js +10 -0
  23. package/dist/types/current/xmlns/mpeg/dash/schema/mpd/2011.d.ts.map +1 -1
  24. package/dist/types/ts3.7/manifest/dashParser2.d.ts +31 -0
  25. package/dist/types/ts3.7/manifest/ext/drm/amzXmlRules.d.ts +8 -0
  26. package/dist/types/ts3.7/xmlns/amazon/music3p/2020.d.ts +16 -0
  27. package/dist/types/ts4.1/manifest/dashParser2.d.ts +31 -0
  28. package/dist/types/ts4.1/manifest/ext/drm/amzXmlRules.d.ts +8 -0
  29. package/dist/types/ts4.1/xmlns/amazon/music3p/2020.d.ts +16 -0
  30. package/dist/types/ts4.7/manifest/dashParser2.d.ts +31 -0
  31. package/dist/types/ts4.7/manifest/ext/drm/amzXmlRules.d.ts +8 -0
  32. package/dist/types/ts4.7/xmlns/amazon/music3p/2020.d.ts +16 -0
  33. package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -0
  34. package/package.json +11 -14
@@ -19,41 +19,27 @@
19
19
  return a;
20
20
  };
21
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
-
23
- // ../vinyl-util/dist/browserTestUtil/index.js
24
- var __defProp2 = Object.defineProperty;
25
- var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
26
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
27
- var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
28
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
29
- var __spreadValues2 = (a, b) => {
30
- for (var prop in b || (b = {}))
31
- if (__hasOwnProp2.call(b, prop))
32
- __defNormalProp2(a, prop, b[prop]);
33
- if (__getOwnPropSymbols2)
34
- for (var prop of __getOwnPropSymbols2(b)) {
35
- if (__propIsEnum2.call(b, prop))
36
- __defNormalProp2(a, prop, b[prop]);
37
- }
38
- return a;
39
- };
40
22
  var __objRest = (source, exclude) => {
41
23
  var target = {};
42
24
  for (var prop in source)
43
- if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
44
26
  target[prop] = source[prop];
45
- if (source != null && __getOwnPropSymbols2)
46
- for (var prop of __getOwnPropSymbols2(source)) {
47
- if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop))
27
+ if (source != null && __getOwnPropSymbols)
28
+ for (var prop of __getOwnPropSymbols(source)) {
29
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
48
30
  target[prop] = source[prop];
49
31
  }
50
32
  return target;
51
33
  };
52
- var __publicField = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
34
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
35
+
36
+ // ../vinyl-util/test/browserTestUtil/mock/createSpyFactory.ts
53
37
  var createSpy = jasmine.createSpy;
54
38
  function createSpy2(key) {
55
39
  return createSpy(String(key));
56
40
  }
41
+
42
+ // ../vinyl-util/test/browserTestUtil/mock/dom/lib.dom.ts
57
43
  var MockAbortSignal = class {
58
44
  constructor() {
59
45
  __publicField(this, "aborted", false);
@@ -92,6 +78,8 @@
92
78
  __publicField(this, "dispatchEvent", createSpy2("dispatchEvent"));
93
79
  }
94
80
  };
81
+
82
+ // ../vinyl-util/test/browserTestUtil/mock/dom/globals.ts
95
83
  var MockMediaSourceGlobal = class extends MockMediaSource {
96
84
  };
97
85
  __publicField(MockMediaSourceGlobal, "canConstructInDedicatedWorker", false);
@@ -103,9 +91,13 @@
103
91
  __publicField(MockAbortSignalGlobal, "abort", createSpy2("abort"));
104
92
  __publicField(MockAbortSignalGlobal, "any", createSpy2("any"));
105
93
  __publicField(MockAbortSignalGlobal, "timeout", createSpy2("timeout"));
94
+
95
+ // ../vinyl-util/test/browserTestUtil/expect/expectNothing.ts
106
96
  function expectNothing() {
107
97
  expect(true).toBeTruthy();
108
98
  }
99
+
100
+ // ../vinyl-util/test/browserTestUtil/env/jasmineEnv.ts
109
101
  var nextTestTimeoutOverridden = false;
110
102
  function setTestTimeout(timeout) {
111
103
  let originalTimeout = null;
@@ -119,6 +111,8 @@
119
111
  if (nextTestTimeoutOverridden) nextTestTimeoutOverridden = false;
120
112
  });
121
113
  }
114
+
115
+ // ../vinyl-util/test/browserTestUtil/benchmark/Benchmark.ts
122
116
  var now;
123
117
  if (typeof window !== "undefined" && typeof window.performance !== "undefined" && typeof window.performance.now !== "undefined") {
124
118
  now = () => window.performance.now();
@@ -129,7 +123,7 @@
129
123
  }
130
124
  var BenchmarkRunResults = class {
131
125
  constructor(name) {
132
- this.name = name;
126
+ __publicField(this, "name", name);
133
127
  __publicField(this, "cycleResults", []);
134
128
  __publicField(this, "_totalSamples", 0);
135
129
  }
@@ -182,7 +176,10 @@
182
176
  };
183
177
  var RunResultsComparison = class {
184
178
  constructor(name, results) {
185
- this.name = name;
179
+ __publicField(this, "name", name);
180
+ /**
181
+ * Sorted by median ops/s from slowest to fastest.
182
+ */
186
183
  __publicField(this, "results");
187
184
  this.results = results.sort((a, b) => {
188
185
  return a.meanOpsPerSec - b.meanOpsPerSec;
@@ -228,7 +225,7 @@
228
225
  maxCycleDuration: 0.5,
229
226
  cycles: 9
230
227
  };
231
- var _Benchmark = class _Benchmark2 {
228
+ var _Benchmark = class _Benchmark {
232
229
  /**
233
230
  * Constructs a new Benchmark.
234
231
  *
@@ -238,14 +235,14 @@
238
235
  * @param options Optional configuration for the benchmark.
239
236
  */
240
237
  constructor(name, executor, options) {
241
- this.name = name;
242
- this.executor = executor;
238
+ __publicField(this, "name", name);
239
+ __publicField(this, "executor", executor);
243
240
  __publicField(this, "options");
244
- this.options = __spreadValues2(__spreadValues2({}, defaultBenchmarkOptions), options);
241
+ this.options = __spreadValues(__spreadValues({}, defaultBenchmarkOptions), options);
245
242
  }
246
243
  async run() {
247
244
  const opts = this.options;
248
- await _Benchmark2.semaphore;
245
+ await _Benchmark.semaphore;
249
246
  const warmupTimeMs = opts.warmupTime * 1e3;
250
247
  const cycleStart = now();
251
248
  let isAsync = false;
@@ -263,7 +260,7 @@
263
260
  }
264
261
  return results;
265
262
  })();
266
- _Benchmark2.semaphore = resultsPromise;
263
+ _Benchmark.semaphore = resultsPromise;
267
264
  return await resultsPromise;
268
265
  }
269
266
  /**
@@ -316,7 +313,6 @@
316
313
  const sum = values.reduce((acc, value) => acc + value, 0);
317
314
  return sum / values.length;
318
315
  }
319
- var createSpy3 = jasmine.createSpy;
320
316
 
321
317
  // test/benchmark/setup.ts
322
318
  function setupBenchmark() {
@@ -390,30 +386,12 @@
390
386
  // src/xmlns/microsoft/playready.ts
391
387
  var PLAY_READY_NAMESPACE_URI = "urn:microsoft:playready";
392
388
 
393
- // ../vinyl-util/dist/index.js
394
- var __defProp3 = Object.defineProperty;
395
- var __defProps2 = Object.defineProperties;
396
- var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
397
- var __getOwnPropSymbols3 = Object.getOwnPropertySymbols;
398
- var __hasOwnProp3 = Object.prototype.hasOwnProperty;
399
- var __propIsEnum3 = Object.prototype.propertyIsEnumerable;
400
- var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
401
- var __spreadValues3 = (a, b) => {
402
- for (var prop in b || (b = {}))
403
- if (__hasOwnProp3.call(b, prop))
404
- __defNormalProp3(a, prop, b[prop]);
405
- if (__getOwnPropSymbols3)
406
- for (var prop of __getOwnPropSymbols3(b)) {
407
- if (__propIsEnum3.call(b, prop))
408
- __defNormalProp3(a, prop, b[prop]);
409
- }
410
- return a;
411
- };
412
- var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
413
- var __publicField2 = (obj, key, value) => __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
389
+ // ../vinyl-util/src/util/type.ts
414
390
  function invariant() {
415
391
  return void 0;
416
392
  }
393
+
394
+ // ../vinyl-util/src/error/ErrorOrigin.ts
417
395
  var ErrorOrigin = {
418
396
  /**
419
397
  * The error originated from Vinyl and was reported from the uncaught exception or promise
@@ -458,11 +436,13 @@
458
436
  */
459
437
  DRM: "drm"
460
438
  };
439
+
440
+ // ../vinyl-util/src/error/ReportableError.ts
461
441
  var ReportableError = class _ReportableError extends Error {
462
- constructor(message, origin = ErrorOrigin.INTERNAL, level = "fatal") {
442
+ constructor(message, origin = ErrorOrigin.INTERNAL, level = "fatal" /* FATAL */) {
463
443
  super(message);
464
- this.origin = origin;
465
- this.level = level;
444
+ __publicField(this, "origin", origin);
445
+ __publicField(this, "level", level);
466
446
  Object.setPrototypeOf(this, _ReportableError.prototype);
467
447
  }
468
448
  get [Symbol.toStringTag]() {
@@ -484,25 +464,38 @@
484
464
  };
485
465
  }
486
466
  };
467
+
468
+ // ../vinyl-util/src/error/IllegalArgumentError.ts
487
469
  var IllegalArgumentError = class _IllegalArgumentError extends ReportableError {
488
470
  constructor(message, isInternal = true) {
489
471
  super(message, isInternal ? ErrorOrigin.INTERNAL : ErrorOrigin.API);
490
- this.isInternal = isInternal;
472
+ __publicField(this, "isInternal", isInternal);
491
473
  Object.setPrototypeOf(this, _IllegalArgumentError.prototype);
492
474
  }
493
475
  get [Symbol.toStringTag]() {
494
476
  return "IllegalArgumentError";
495
477
  }
496
478
  };
497
- function getOrSet(map2, key, defaultValue) {
498
- if (map2.has(key)) {
499
- return map2.get(key);
479
+
480
+ // ../vinyl-util/src/util/map/map.ts
481
+ function getOrSet(map, key, defaultValue) {
482
+ if (map.has(key)) {
483
+ return map.get(key);
500
484
  } else {
501
485
  const value = defaultValue(key);
502
- map2.set(key, value);
486
+ map.set(key, value);
503
487
  return value;
504
488
  }
505
489
  }
490
+ function flipMap(map) {
491
+ const result = /* @__PURE__ */ new Map();
492
+ for (const [key, value] of map) {
493
+ result.set(value, key);
494
+ }
495
+ return result;
496
+ }
497
+
498
+ // ../vinyl-util/src/util/string/string.ts
506
499
  var locale = {
507
500
  variableNotDefined: "Variable '{name}' is not defined"
508
501
  };
@@ -547,6 +540,7 @@
547
540
  return str;
548
541
  }
549
542
  }
543
+ var standardEntityValueToNames = flipMap(predefinedDecodeEntities);
550
544
  function eqStr(a, b, ignoreCase = false) {
551
545
  if (a == null && b == null) return true;
552
546
  if (a == null || b == null) return false;
@@ -564,12 +558,16 @@
564
558
  return str.substring(0, maxLength - indicator.length) + indicator;
565
559
  return str;
566
560
  }
567
- function clamp(value, min2, max2) {
568
- return Math.min(Math.max(value, min2), max2);
561
+
562
+ // ../vinyl-util/src/util/math/math.ts
563
+ function clamp(value, min, max) {
564
+ return Math.min(Math.max(value, min), max);
569
565
  }
570
566
  function roundToNearest(value, snap, offset = 0) {
571
567
  return Math.round((value - offset) / snap) * snap + offset;
572
568
  }
569
+
570
+ // ../vinyl-util/src/util/serialization/ParseError.ts
573
571
  function printStringPosition(str, index, options) {
574
572
  var _a2;
575
573
  const caret = (options == null ? void 0 : options.caret) || "^";
@@ -596,13 +594,19 @@
596
594
  out += " ".repeat(leadingChars) + caret;
597
595
  return out;
598
596
  }
597
+
598
+ // ../vinyl-util/src/util/string/StringReader.ts
599
599
  var StringReader = class {
600
600
  /**
601
601
  * @param data The string to read.
602
602
  */
603
603
  constructor(data) {
604
- this.data = data;
605
- __publicField2(this, "position", 0);
604
+ __publicField(this, "data", data);
605
+ /**
606
+ * The current cursor.
607
+ * This should always be between the range 0 and `data.length`
608
+ */
609
+ __publicField(this, "position", 0);
606
610
  }
607
611
  /**
608
612
  * Returns true if the current {@link position} is less than the source data's length.
@@ -800,31 +804,35 @@
800
804
  };
801
805
  var StringParseError = class _StringParseError extends ReportableError {
802
806
  constructor(str, position, reason) {
803
- const location2 = printStringPosition(str, position);
807
+ const location = printStringPosition(str, position);
804
808
  super(
805
- `${reason}${locale2.messageSeparator}${location2}`,
809
+ `${reason}${locale2.messageSeparator}${location}`,
806
810
  ErrorOrigin.PARSING
807
811
  );
808
- this.position = position;
809
- this.reason = reason;
810
- __publicField2(this, "location");
811
- this.location = location2;
812
+ __publicField(this, "position", position);
813
+ __publicField(this, "reason", reason);
814
+ __publicField(this, "location");
815
+ this.location = location;
812
816
  Object.setPrototypeOf(this, _StringParseError.prototype);
813
817
  }
814
818
  get [Symbol.toStringTag]() {
815
819
  return "StringParseError";
816
820
  }
817
821
  toJSON() {
818
- return __spreadProps2(__spreadValues3({}, super.toJSON()), {
822
+ return __spreadProps(__spreadValues({}, super.toJSON()), {
819
823
  position: this.position,
820
824
  location: this.location,
821
825
  reason: this.reason
822
826
  });
823
827
  }
824
828
  };
829
+
830
+ // ../vinyl-util/src/util/set/set.ts
825
831
  function union(a, b) {
826
832
  return /* @__PURE__ */ new Set([...a, ...b]);
827
833
  }
834
+
835
+ // ../vinyl-util/src/util/object/object.ts
828
836
  function ownKeys(obj) {
829
837
  if (!obj) return /* @__PURE__ */ new Set();
830
838
  if (typeof Reflect !== "undefined")
@@ -840,6 +848,8 @@
840
848
  const proto = Object.getPrototypeOf(value);
841
849
  return !proto || !Object.getPrototypeOf(proto);
842
850
  }
851
+
852
+ // ../vinyl-util/src/util/serialization/json.ts
843
853
  function toJson(value) {
844
854
  return toJsonInternal(value, /* @__PURE__ */ new Set());
845
855
  }
@@ -888,6 +898,8 @@
888
898
  }
889
899
  }
890
900
  }
901
+
902
+ // ../vinyl-util/src/util/serialization/stringifyForPrint.ts
891
903
  function stringifyForPrint(value, maxLength, indicator = "\u2026") {
892
904
  let str = JSON.stringify(
893
905
  toJson(value),
@@ -910,6 +922,8 @@
910
922
  if (maxLength) str = truncate(str, maxLength, indicator);
911
923
  return str;
912
924
  }
925
+
926
+ // ../vinyl-util/src/util/serialization/primitives.ts
913
927
  function parseBoolean(str) {
914
928
  return str === "true" || str === "1";
915
929
  }
@@ -924,10 +938,12 @@
924
938
  if (!Number.isFinite(value)) return null;
925
939
  return value;
926
940
  }
941
+
942
+ // ../vinyl-util/src/util/collection/LinkedList.ts
927
943
  var LinkedList = class {
928
944
  constructor() {
929
- __publicField2(this, "_head", null);
930
- __publicField2(this, "_tail", null);
945
+ __publicField(this, "_head", null);
946
+ __publicField(this, "_tail", null);
931
947
  }
932
948
  /**
933
949
  * Returns the current head.
@@ -1230,10 +1246,14 @@
1230
1246
  };
1231
1247
  }
1232
1248
  };
1249
+
1250
+ // ../vinyl-util/src/util/collection/array.ts
1233
1251
  function last(arrayLike) {
1234
1252
  if (!arrayLike) return void 0;
1235
1253
  return arrayLike[arrayLike.length - 1];
1236
1254
  }
1255
+
1256
+ // ../vinyl-util/src/util/collection/typedArray.ts
1237
1257
  function cloneTypedArray(array) {
1238
1258
  return new array.constructor(array);
1239
1259
  }
@@ -1251,16 +1271,20 @@
1251
1271
  function isTypedArray(value) {
1252
1272
  return typedArrayTypes.some((type) => value instanceof type);
1253
1273
  }
1274
+
1275
+ // ../vinyl-util/src/core/cloneable.ts
1254
1276
  function isCloneable(value) {
1255
1277
  return value != null && typeof value === "object" && "clone" in value && typeof value.clone === "function" && value.clone.length === 0;
1256
1278
  }
1279
+
1280
+ // ../vinyl-util/src/util/object/mergeDeep.ts
1257
1281
  var locale3 = {
1258
1282
  cyclicRefError: "Cyclic reference found at: {path}",
1259
1283
  mergeReferenceError: `No merge rule found at {path} for "{source}" and reference copy not allowed`
1260
1284
  };
1261
1285
  function mergeDeep(sources, options) {
1262
1286
  if (!sources.length) return void 0;
1263
- const finalOpts = __spreadValues3(__spreadValues3({}, defaultMergeOptions), options);
1287
+ const finalOpts = __spreadValues(__spreadValues({}, defaultMergeOptions), options);
1264
1288
  const stack = new PropStack();
1265
1289
  const n = sources.length;
1266
1290
  if (n === 1)
@@ -1273,9 +1297,15 @@
1273
1297
  }
1274
1298
  var PropStack = class {
1275
1299
  constructor() {
1276
- __publicField2(this, "refsA", /* @__PURE__ */ new Set());
1277
- __publicField2(this, "refsB", /* @__PURE__ */ new Set());
1278
- __publicField2(this, "propStack", []);
1300
+ /**
1301
+ * Object references for sourceA.
1302
+ */
1303
+ __publicField(this, "refsA", /* @__PURE__ */ new Set());
1304
+ /**
1305
+ * Object references for sourceB.
1306
+ */
1307
+ __publicField(this, "refsB", /* @__PURE__ */ new Set());
1308
+ __publicField(this, "propStack", []);
1279
1309
  }
1280
1310
  /**
1281
1311
  * The property stack, joined by .
@@ -1305,7 +1335,7 @@
1305
1335
  };
1306
1336
  function _mergeDeep(sourceA, sourceB, propStack, prop, options) {
1307
1337
  if (typeof sourceB !== "object" || sourceB === null) return sourceB;
1308
- const merge2 = (sourceA2, sourceB2, prop2) => {
1338
+ const merge = (sourceA2, sourceB2, prop2) => {
1309
1339
  return _mergeDeep(sourceA2, sourceB2, propStack, prop2, options);
1310
1340
  };
1311
1341
  for (const rule of options.rules) {
@@ -1314,7 +1344,7 @@
1314
1344
  const result = rule.merge(
1315
1345
  rule.matches(sourceA) ? sourceA : void 0,
1316
1346
  sourceB,
1317
- merge2
1347
+ merge
1318
1348
  );
1319
1349
  propStack.pop();
1320
1350
  return result;
@@ -1349,15 +1379,15 @@
1349
1379
  matches(object) {
1350
1380
  return Array.isArray(object);
1351
1381
  },
1352
- merge(sourceA, sourceB, merge2) {
1382
+ merge(sourceA, sourceB, merge) {
1353
1383
  const out = [];
1354
1384
  if (sourceA) {
1355
1385
  for (const element2 of sourceA) {
1356
- out.push(merge2(void 0, element2, out.length));
1386
+ out.push(merge(void 0, element2, out.length));
1357
1387
  }
1358
1388
  }
1359
1389
  for (const element2 of sourceB) {
1360
- out.push(merge2(void 0, element2, out.length));
1390
+ out.push(merge(void 0, element2, out.length));
1361
1391
  }
1362
1392
  return out;
1363
1393
  }
@@ -1366,15 +1396,15 @@
1366
1396
  matches(object) {
1367
1397
  return isPlainObject(object);
1368
1398
  },
1369
- merge(sourceA, sourceB, merge2) {
1399
+ merge(sourceA, sourceB, merge) {
1370
1400
  const out = {};
1371
1401
  for (const key of union(ownKeys(sourceA), ownKeys(sourceB))) {
1372
1402
  if (sourceA && key in sourceB && key in sourceA) {
1373
- out[key] = merge2(sourceA[key], sourceB[key], key);
1403
+ out[key] = merge(sourceA[key], sourceB[key], key);
1374
1404
  } else if (sourceA && key in sourceA) {
1375
- out[key] = merge2(void 0, sourceA[key], key);
1405
+ out[key] = merge(void 0, sourceA[key], key);
1376
1406
  } else {
1377
- out[key] = merge2(void 0, sourceB[key], key);
1407
+ out[key] = merge(void 0, sourceB[key], key);
1378
1408
  }
1379
1409
  }
1380
1410
  return out;
@@ -1400,7 +1430,7 @@
1400
1430
  matches(object) {
1401
1431
  return object instanceof Map;
1402
1432
  },
1403
- merge(sourceA, sourceB, merge2) {
1433
+ merge(sourceA, sourceB, merge) {
1404
1434
  var _a2;
1405
1435
  const out = /* @__PURE__ */ new Map();
1406
1436
  for (const key of /* @__PURE__ */ new Set([
@@ -1408,11 +1438,11 @@
1408
1438
  ...sourceB.keys()
1409
1439
  ])) {
1410
1440
  if (sourceB.has(key) && (sourceA == null ? void 0 : sourceA.has(key))) {
1411
- out.set(key, merge2(sourceA.get(key), sourceB.get(key), key));
1441
+ out.set(key, merge(sourceA.get(key), sourceB.get(key), key));
1412
1442
  } else if (sourceA == null ? void 0 : sourceA.has(key)) {
1413
- out.set(key, merge2(void 0, sourceA.get(key), key));
1443
+ out.set(key, merge(void 0, sourceA.get(key), key));
1414
1444
  } else {
1415
- out.set(key, merge2(void 0, sourceB.get(key), key));
1445
+ out.set(key, merge(void 0, sourceB.get(key), key));
1416
1446
  }
1417
1447
  }
1418
1448
  return out;
@@ -1422,12 +1452,12 @@
1422
1452
  matches(object) {
1423
1453
  return object instanceof Set;
1424
1454
  },
1425
- merge(sourceA, sourceB, merge2) {
1455
+ merge(sourceA, sourceB, merge) {
1426
1456
  var _a2;
1427
1457
  return new Set(
1428
1458
  [...(_a2 = sourceA == null ? void 0 : sourceA.values()) != null ? _a2 : [], ...sourceB.values()].map(
1429
1459
  (element2, index) => {
1430
- return merge2(void 0, element2, index);
1460
+ return merge(void 0, element2, index);
1431
1461
  }
1432
1462
  )
1433
1463
  );
@@ -1463,11 +1493,8 @@
1463
1493
  urlMergeRule
1464
1494
  ]
1465
1495
  };
1466
- function merge(...sources) {
1467
- if (!sources.length) return void 0;
1468
- if (Array.isArray(sources[0])) return Array.prototype.concat(...sources);
1469
- return Object.assign({}, ...sources);
1470
- }
1496
+
1497
+ // ../vinyl-util/src/error/IllegalStateError.ts
1471
1498
  var IllegalStateError = class _IllegalStateError extends ReportableError {
1472
1499
  get [Symbol.toStringTag]() {
1473
1500
  return "IllegalStateError";
@@ -1477,6 +1504,8 @@
1477
1504
  Object.setPrototypeOf(this, _IllegalStateError.prototype);
1478
1505
  }
1479
1506
  };
1507
+
1508
+ // ../vinyl-util/src/util/object/clone.ts
1480
1509
  function clone(target, options) {
1481
1510
  var _a2, _b, _c;
1482
1511
  return mergeDeep([target], {
@@ -1487,16 +1516,18 @@
1487
1516
  function toMergeRule(cloneRule) {
1488
1517
  return {
1489
1518
  matches: cloneRule.matches,
1490
- merge(_sourceA, sourceB, merge2) {
1519
+ merge(_sourceA, sourceB, merge) {
1491
1520
  return cloneRule.clone(
1492
1521
  sourceB,
1493
1522
  (source, prop) => {
1494
- return merge2(void 0, source, prop);
1523
+ return merge(void 0, source, prop);
1495
1524
  }
1496
1525
  );
1497
1526
  }
1498
1527
  };
1499
1528
  }
1529
+
1530
+ // ../vinyl-util/src/error/ValidationError.ts
1500
1531
  var ValidationError = class _ValidationError extends ReportableError {
1501
1532
  /**
1502
1533
  * @param message The validation error message.
@@ -1505,19 +1536,21 @@
1505
1536
  */
1506
1537
  constructor(message, origin = ErrorOrigin.API, path = []) {
1507
1538
  super(message, origin);
1508
- this.path = path;
1539
+ __publicField(this, "path", path);
1509
1540
  Object.setPrototypeOf(this, _ValidationError.prototype);
1510
1541
  }
1511
1542
  get [Symbol.toStringTag]() {
1512
1543
  return "ValidationError";
1513
1544
  }
1514
1545
  toJSON() {
1515
- return __spreadProps2(__spreadValues3({}, super.toJSON()), {
1546
+ return __spreadProps(__spreadValues({}, super.toJSON()), {
1516
1547
  origin: this.origin,
1517
1548
  path: this.path
1518
1549
  });
1519
1550
  }
1520
1551
  };
1552
+
1553
+ // ../vinyl-util/src/util/iteration/iterable.ts
1521
1554
  function mapIter(iterable, transform) {
1522
1555
  const it2 = iterable[Symbol.iterator]();
1523
1556
  return {
@@ -1534,13 +1567,34 @@
1534
1567
  }
1535
1568
  };
1536
1569
  }
1570
+
1571
+ // ../vinyl-util/src/util/collection/LruCache.ts
1537
1572
  var LruCache = class {
1538
1573
  constructor(initialCapacity) {
1539
- __publicField2(this, "cache", /* @__PURE__ */ new Map());
1540
- __publicField2(this, "list", /* @__PURE__ */ new LinkedList());
1541
- __publicField2(this, "onEvicting", null);
1542
- __publicField2(this, "onEvict", null);
1543
- __publicField2(this, "_capacity", 0);
1574
+ /**
1575
+ * A map of the list nodes.
1576
+ *
1577
+ * @private
1578
+ */
1579
+ __publicField(this, "cache", /* @__PURE__ */ new Map());
1580
+ /**
1581
+ * Most recently used elements are at the tail, least recently used are at the head.
1582
+ * @private
1583
+ */
1584
+ __publicField(this, "list", new LinkedList());
1585
+ /**
1586
+ * An element is about to be removed. Should return true if the element may be evicted,
1587
+ * otherwise false.
1588
+ * If false is returned for all elements, an IllegalStateError is thrown.
1589
+ */
1590
+ __publicField(this, "onEvicting", null);
1591
+ /**
1592
+ * When an element is added when at capacity, the least recently used element will be removed.
1593
+ * This callback can be set to be notified with the element being evicted, which may be used
1594
+ * for disposal.
1595
+ */
1596
+ __publicField(this, "onEvict", null);
1597
+ __publicField(this, "_capacity", 0);
1544
1598
  this._capacity = initialCapacity;
1545
1599
  }
1546
1600
  get capacity() {
@@ -1669,6 +1723,8 @@
1669
1723
  return "LruCache";
1670
1724
  }
1671
1725
  };
1726
+
1727
+ // ../vinyl-util/src/util/fun/memoize.ts
1672
1728
  function memoize(inner, keyProvider, capacity = 500) {
1673
1729
  if (!keyProvider) {
1674
1730
  let cached = false;
@@ -1735,6 +1791,8 @@
1735
1791
  );
1736
1792
  }
1737
1793
  }
1794
+
1795
+ // ../vinyl-util/src/util/date/date.ts
1738
1796
  var locale4 = {
1739
1797
  invalidDateError: `"{value}" is an invalid date`
1740
1798
  };
@@ -1797,1244 +1855,89 @@
1797
1855
  return `${value[0]}-${end == null ? "" : end}`;
1798
1856
  }
1799
1857
 
1800
- // ../vinyl-validation/dist/index.js
1801
- var __defProp4 = Object.defineProperty;
1802
- var __defProps3 = Object.defineProperties;
1803
- var __getOwnPropDescs3 = Object.getOwnPropertyDescriptors;
1804
- var __getOwnPropSymbols4 = Object.getOwnPropertySymbols;
1805
- var __hasOwnProp4 = Object.prototype.hasOwnProperty;
1806
- var __propIsEnum4 = Object.prototype.propertyIsEnumerable;
1807
- var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1808
- var __spreadValues4 = (a, b) => {
1809
- for (var prop in b || (b = {}))
1810
- if (__hasOwnProp4.call(b, prop))
1811
- __defNormalProp4(a, prop, b[prop]);
1812
- if (__getOwnPropSymbols4)
1813
- for (var prop of __getOwnPropSymbols4(b)) {
1814
- if (__propIsEnum4.call(b, prop))
1815
- __defNormalProp4(a, prop, b[prop]);
1816
- }
1817
- return a;
1818
- };
1819
- var __spreadProps3 = (a, b) => __defProps3(a, __getOwnPropDescs3(b));
1820
- var __publicField3 = (obj, key, value) => __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
1821
- var validatorLocale = {
1822
- /**
1823
- * The expectation template string with the following replacement tokens:
1824
- *
1825
- * `{expected}` - The expected description.
1826
- * `{actual}` - The actual value.
1827
- * `{path}` - The path, dot separated.
1828
- */
1829
- template: "Expected: {expected}, but was: {actual}. At: {path}"
1830
- };
1831
- function createValidationExpectationMessage(expectationMessage, input, path, inputStringify = (input2) => stringifyForPrint(input2, 500)) {
1832
- return substitute(validatorLocale.template, {
1833
- expected: expectationMessage,
1834
- actual: inputStringify(input),
1835
- path: path.join(".")
1858
+ // ../vinyl-xml/src/xml/xmlRules.ts
1859
+ function element(rules, options) {
1860
+ return __spreadProps(__spreadValues({
1861
+ type: "element" /* ELEMENT */,
1862
+ localPart: void 0,
1863
+ namespaceUri: void 0,
1864
+ required: false
1865
+ }, options), {
1866
+ rules
1836
1867
  });
1837
1868
  }
1838
- function createValidator(expectationMessage, isValid, inputStringify = (input) => stringifyForPrint(input, 500)) {
1839
- return {
1840
- description: expectationMessage,
1841
- isValid(input) {
1842
- return isValid(input);
1843
- },
1844
- validate(input, _, path = []) {
1845
- if (!isValid(input)) {
1846
- return [
1847
- {
1848
- message: createValidationExpectationMessage(
1849
- expectationMessage,
1850
- input,
1851
- path,
1852
- inputStringify
1853
- ),
1854
- path
1855
- }
1856
- ];
1857
- }
1858
- return [];
1859
- },
1860
- assert: (input, origin, path = []) => {
1861
- if (!isValid(input)) {
1862
- throw new ValidationError(
1863
- createValidationExpectationMessage(
1864
- expectationMessage,
1865
- input,
1866
- path,
1867
- inputStringify
1868
- ),
1869
- origin,
1870
- path
1871
- );
1872
- }
1873
- }
1874
- };
1875
- }
1876
- function createDeepValidator(description, validate) {
1877
- return {
1878
- description,
1879
- isValid(input) {
1880
- return validate(input, { all: false }, []).length === 0;
1881
- },
1882
- validate(input, options, path = []) {
1883
- return validate(input, options != null ? options : { all: false }, path);
1884
- },
1885
- assert: (input, origin, path = []) => {
1886
- const errors = validate(input, { all: false }, path);
1887
- if (errors.length) {
1888
- const error = errors[0];
1889
- throw new ValidationError(error.message, origin, error.path);
1890
- }
1891
- }
1892
- };
1869
+ function elements(rules, options) {
1870
+ return __spreadProps(__spreadValues({
1871
+ type: "elements" /* ELEMENTS */,
1872
+ localPart: void 0,
1873
+ namespaceUri: void 0,
1874
+ minOccurs: 0,
1875
+ maxOccurs: null,
1876
+ useEmptyArrays: false
1877
+ }, options), {
1878
+ rules
1879
+ });
1893
1880
  }
1894
- var locale5 = {
1895
- /**
1896
- * {value} The child validators' descriptions, joined with `separator`.
1897
- *
1898
- * groupings of and validators is unimportant,
1899
- * and(and(a, b), c) is the same as and(a, and(b, c)), so `a & b & c` is an accurate
1900
- * representation for either.
1901
- */
1902
- template: "{value}",
1903
- /**
1904
- * The separator with which to join child validator descriptions.
1905
- */
1906
- separator: " & "
1907
- };
1908
- function andValidators(...validators) {
1909
- return createDeepValidator(
1910
- substitute(locale5.template, {
1911
- value: validators.map((v) => v.description).join(locale5.separator)
1912
- }),
1913
- (input, options, path) => {
1914
- for (const validator of validators) {
1915
- const errors = validator.validate(input, options, path);
1916
- if (errors.length) return errors;
1917
- }
1918
- return [];
1919
- }
1920
- );
1881
+ function characters(parse, stringify2) {
1882
+ return { type: "characters" /* CHARACTERS */, parse, stringify: stringify2 };
1921
1883
  }
1922
- var locale22 = {
1923
- /**
1924
- * {value} - The child validators' descriptions, joined with `separator`.
1925
- */
1926
- template: "({value})",
1927
- /**
1928
- * The separator with which to join child validator descriptions.
1929
- */
1930
- separator: " | "
1931
- };
1932
- function orValidators(...validators) {
1933
- const description = substitute(locale22.template, {
1934
- value: validators.map((v) => v.description).join(locale22.separator)
1935
- });
1936
- return createDeepValidator(description, (input, options, path) => {
1937
- let longestErrors = [];
1938
- let longestPath = 0;
1939
- for (const validator of validators) {
1940
- const errors = validator.validate(input, options, path);
1941
- if (!errors.length) return errors;
1942
- const pathLength = errors.reduce(
1943
- (max, m) => Math.max(m.path.length, max),
1944
- 0
1945
- );
1946
- if (pathLength >= longestPath) {
1947
- longestErrors = errors;
1948
- longestPath = pathLength;
1949
- }
1950
- }
1951
- return longestPath > path.length ? longestErrors : [
1952
- {
1953
- message: createValidationExpectationMessage(
1954
- description,
1955
- input,
1956
- path
1957
- ),
1958
- path
1959
- }
1960
- ];
1884
+ var charactersString = characters((i) => i, stringify);
1885
+ function attr(parse, stringify2, options) {
1886
+ return __spreadProps(__spreadValues({
1887
+ type: "attribute" /* ATTRIBUTE */,
1888
+ localPart: void 0,
1889
+ namespaceUri: null,
1890
+ required: false,
1891
+ default: void 0
1892
+ }, options), {
1893
+ parse,
1894
+ stringify: stringify2
1961
1895
  });
1962
1896
  }
1963
- var requiredValidationOptions = {
1964
- optional: false
1897
+ function attrString(options) {
1898
+ return attr((i) => i, stringify, options);
1899
+ }
1900
+ function attrInt(options) {
1901
+ return attr(parseInt, stringify, options);
1902
+ }
1903
+ function attrFloat(options) {
1904
+ return attr(parseFloat, stringify, options);
1905
+ }
1906
+ function attrBoolean(options) {
1907
+ return attr(parseBoolean, stringify, options);
1908
+ }
1909
+ function attrDateTime(options) {
1910
+ return attr(parseDate, stringifyDate, options);
1911
+ }
1912
+
1913
+ // ../vinyl-xml/src/xml/XmlSchemaError.ts
1914
+ var xmlSchemaErrorLocale = {
1915
+ atLeastElements: "Expected at least {expected} occurrences of {property} but was {actual}",
1916
+ atMostElements: "Expected at most {expected} occurrences of {property} but was {actual}",
1917
+ cyclicReferences: "Cyclic reference detected",
1918
+ requiredAttribute: `Attribute '{property}' is required`
1965
1919
  };
1966
- var SchemaBase = class {
1967
- constructor(currentValidator, previousSchema, operation) {
1968
- this.currentValidator = currentValidator;
1969
- this.previousSchema = previousSchema;
1970
- this.operation = operation;
1971
- __publicField3(this, "__type", /* @__PURE__ */ invariant());
1972
- __publicField3(this, "validator");
1973
- __publicField3(this, "_options", requiredValidationOptions);
1974
- __publicField3(this, "assert", (input, origin, path) => {
1975
- this.validator.assert(input, origin, path);
1976
- });
1977
- __publicField3(this, "isValid", (input) => this.validator.isValid(input));
1978
- __publicField3(this, "validate", (input, options, path) => this.validator.validate(input, options, path));
1979
- this.validator = operation == null ? currentValidator : operation(previousSchema, currentValidator);
1980
- }
1981
- get options() {
1982
- return this._options;
1920
+ var XmlSchemaError = class _XmlSchemaError extends ReportableError {
1921
+ get [Symbol.toStringTag]() {
1922
+ return "XmlSchemaError";
1983
1923
  }
1984
- get description() {
1985
- return this.validator.description;
1986
- }
1987
- /**
1988
- * Clones this schema, transforming all validators with the given mutator.
1989
- *
1990
- * @param transform A transformer which takes an existing validator in the chain and returns
1991
- * a new one. Validators should be considered to be immutable; transform should not change the
1992
- * input but instead return a new validator.
1993
- */
1994
- clone(transform = (v) => v) {
1995
- const cloned = this.operation ? this.self(
1996
- transform(this.currentValidator),
1997
- this.previousSchema.clone(transform),
1998
- this.operation
1999
- ) : this.self(transform(this.currentValidator));
2000
- cloned._options = this._options;
2001
- return cloned;
2002
- }
2003
- self(current, previous, operation) {
2004
- if (this.constructor.length > 3) {
2005
- throw new IllegalArgumentError(
2006
- "constructor should have at most three required arguments"
2007
- );
2008
- }
2009
- return new this.constructor(current, previous, operation);
2010
- }
2011
- /**
2012
- * Constructs a new schema with a validator chaining the current validator with the
2013
- * provided next in an AND operation.
2014
- *
2015
- * @param nextValidator The validator to run after the current.
2016
- * @return Returns a new Schema instance the same class with a new validator chaining the
2017
- * current validator with the given next in an AND operation.
2018
- */
2019
- chain(nextValidator) {
2020
- return this.self(nextValidator, this, andValidators);
2021
- }
2022
- optional() {
2023
- const cloned = this.clone();
2024
- cloned._options = __spreadProps3(__spreadValues4({}, cloned.options), {
2025
- optional: true
2026
- });
2027
- return cloned;
2028
- }
2029
- required() {
2030
- const cloned = this.clone();
2031
- cloned._options = __spreadProps3(__spreadValues4({}, cloned.options), {
2032
- optional: false
2033
- });
2034
- return cloned;
2035
- }
2036
- };
2037
- var locale32 = {
2038
- null: "null",
2039
- nullish: "nullish",
2040
- undefined: "undefined"
2041
- };
2042
- var valueValidators = {
2043
- any() {
2044
- return createValidator("", () => true);
2045
- },
2046
- /**
2047
- * Creates a validator that asserts that the input is nullish.
2048
- */
2049
- nullish() {
2050
- return createValidator(locale32.nullish, (input) => input == null);
2051
- },
2052
- /**
2053
- * Creates a validator that asserts that the input is strictly null.
2054
- */
2055
- null() {
2056
- return createValidator(locale32.null, (input) => input === null);
2057
- },
2058
- /**
2059
- * Creates a validator that asserts that the input is strictly undefined.
2060
- */
2061
- undefined() {
2062
- return createValidator(locale32.undefined, (input) => input === void 0);
2063
- }
2064
- };
2065
- var ValueSchema = class _ValueSchema extends SchemaBase {
2066
- /**
2067
- * Prepends this validator allowing for null or undefined.
2068
- */
2069
- maybe() {
2070
- return this.or(valueValidators.nullish());
2071
- }
2072
- /**
2073
- * Prepends this validator allowing for null.
2074
- */
2075
- orNull() {
2076
- return this.or(valueValidators.null());
2077
- }
2078
- /**
2079
- * Prepends this validator allowing for undefined.
2080
- */
2081
- orUndefined() {
2082
- return this.or(valueValidators.undefined());
2083
- }
2084
- /**
2085
- * Returns a validator that asserts if this validator and the next passes.
2086
- *
2087
- * @see andValidators
2088
- *
2089
- * @param nextValidator The validator to run after the current.
2090
- * @return Returns a new ValueSchema intersecting this validator and the next.
2091
- */
2092
- and(nextValidator) {
2093
- return new _ValueSchema(nextValidator, this, andValidators);
2094
- }
2095
- /**
2096
- * Returns a validator that asserts if this validator or the next passes.
2097
- *
2098
- * Implementation note:
2099
- * subclasses should not change the schema instance returned unless all chainable validators
2100
- * accept input type 'unknown'.
2101
- *
2102
- * @param nextValidator The validator to run after the current.
2103
- * @return Returns a new ValueSchema providing the union of this validator and the next.
2104
- */
2105
- or(nextValidator) {
2106
- return new _ValueSchema(nextValidator, this, orValidators);
2107
- }
2108
- };
2109
- var locale42 = {
2110
- array: "array",
2111
- minLength: "at least {value} elements",
2112
- maxLength: "at most {value} elements",
2113
- exactlyLength: "exactly {value} elements",
2114
- actualLength: "length {value}",
2115
- withElements: "({value})[]",
2116
- tuple: "[{value}]"
2117
- };
2118
- var arrayValidators = {
2119
- /**
2120
- * Creates a validator that asserts that the input is an array.
2121
- *
2122
- * Note: arrays can only be readonly by type system, there is no native readonly
2123
- * js array. This validator assumes mutability, use the ArraySchema readonly() method
2124
- * to cast to a readonly array.
2125
- */
2126
- isArray() {
2127
- return createValidator(
2128
- locale42.array,
2129
- (input) => Array.isArray(input)
2130
- );
2131
- },
2132
- /**
2133
- * Creates a validator that asserts that every element passes the given validator.
2134
- *
2135
- * @param elementValidator
2136
- */
2137
- withElements(elementValidator) {
2138
- return createDeepValidator(
2139
- substitute(locale42.withElements, {
2140
- value: elementValidator.description
2141
- }),
2142
- (input, options, path) => {
2143
- const errors = [];
2144
- for (let i = 0; i < input.length; i++) {
2145
- const element2 = input[i];
2146
- errors.push(
2147
- ...elementValidator.validate(
2148
- element2,
2149
- options,
2150
- path.concat(i.toString())
2151
- )
2152
- );
2153
- if (!options.all && errors.length) return errors;
2154
- }
2155
- return errors;
2156
- }
2157
- );
2158
- },
2159
- /**
2160
- * Creates a validator that asserts that the input array is a tuple whose elements match
2161
- * the given validators.
2162
- *
2163
- * @param validators
2164
- */
2165
- tuple(...validators) {
2166
- const lengthValidator = createValidator(
2167
- substitute(locale42.exactlyLength, {
2168
- value: validators.length
2169
- }),
2170
- (length) => length === validators.length
2171
- );
2172
- return createDeepValidator(
2173
- substitute(locale42.tuple, { value: validators.join(", ") }),
2174
- (input, options, path) => {
2175
- const errors = [];
2176
- errors.push(
2177
- ...lengthValidator.validate(input.length, options, path)
2178
- );
2179
- if (!options.all && errors.length) return errors;
2180
- const n = Math.min(validators.length, input.length);
2181
- for (let i = 0; i < n; i++) {
2182
- const element2 = input[i];
2183
- const validator = validators[i];
2184
- errors.push(
2185
- ...validator.validate(
2186
- element2,
2187
- options,
2188
- path.concat(i.toString())
2189
- )
2190
- );
2191
- if (!options.all && errors.length) return errors;
2192
- }
2193
- return errors;
2194
- }
2195
- );
2196
- },
2197
- /**
2198
- * Creates a validator that validates the input array has the given minimum length.
2199
- * @param min The minimum number of elements (inclusive)
2200
- */
2201
- minLength(min) {
2202
- return createValidator(
2203
- substitute(locale42.minLength, { value: min }),
2204
- (input) => input.length >= min,
2205
- (input) => substitute(locale42.actualLength, { value: input.length })
2206
- );
2207
- },
2208
- /**
2209
- *
2210
- * Creates a validator that validates the input array has the given maximum length.
2211
- * @param max The maximum number of elements (inclusive)
2212
- */
2213
- maxLength(max) {
2214
- return createValidator(
2215
- substitute(locale42.maxLength, { value: max }),
2216
- (input) => input.length <= max,
2217
- (input) => substitute(locale42.actualLength, { value: input.length })
2218
- );
2219
- }
2220
- };
2221
- var _ArraySchema = class _ArraySchema2 extends ValueSchema {
2222
- /**
2223
- * The base ArraySchema instance validating that the input is an Array.
2224
- */
2225
- static get base() {
2226
- if (this._base == null)
2227
- this._base = new _ArraySchema2(arrayValidators.isArray());
2228
- return this._base;
2229
- }
2230
- /**
2231
- * Creates a validator that asserts that every element passes the given validator.
2232
- *
2233
- * @param elementValidator
2234
- */
2235
- withElements(elementValidator) {
2236
- return this.chain(arrayValidators.withElements(elementValidator));
2237
- }
2238
- /**
2239
- * Creates a validator that asserts that the input array is a tuple whose elements match
2240
- * the given validators.
2241
- *
2242
- * @param validators
2243
- */
2244
- tuple(...validators) {
2245
- return this.chain(arrayValidators.tuple(...validators));
2246
- }
2247
- /**
2248
- * Creates a validator that validates the input array has the given minimum length.
2249
- * @param min The minimum number of elements (inclusive)
2250
- */
2251
- minLength(min) {
2252
- return this.chain(arrayValidators.minLength(min));
2253
- }
2254
- /**
2255
- *
2256
- * Creates a validator that validates the input array has the given maximum length.
2257
- * @param max The maximum number of elements (inclusive)
2258
- */
2259
- maxLength(max) {
2260
- return this.chain(arrayValidators.maxLength(max));
2261
- }
2262
- /**
2263
- * Casts to a readonly array.
2264
- * This is a shallow cast, elements of the array will not be changed.
2265
- */
2266
- readonly() {
2267
- return this;
2268
- }
2269
- /**
2270
- * Casts the type parameter.
2271
- */
2272
- cast() {
2273
- return this;
2274
- }
2275
- };
2276
- __publicField3(_ArraySchema, "_base", null);
2277
- var locale52 = {
2278
- template: "type {value}"
2279
- };
2280
- function typeOfValidator(expected) {
2281
- return createValidator(
2282
- substitute(locale52.template, { value: expected }),
2283
- (input) => {
2284
- return input != null && typeof input === expected;
2285
- }
2286
- );
2287
- }
2288
- var typeOfValidatorCache = {};
2289
- function cachedTypeOfValidator(type) {
2290
- if (!(type in typeOfValidatorCache)) {
2291
- typeOfValidatorCache[type] = typeOfValidator(type);
2292
- }
2293
- return typeOfValidatorCache[type];
2294
- }
2295
- var typeOfValidators = {
2296
- get boolean() {
2297
- return cachedTypeOfValidator("boolean");
2298
- },
2299
- get func() {
2300
- return cachedTypeOfValidator("function");
2301
- },
2302
- get number() {
2303
- return cachedTypeOfValidator("number");
2304
- },
2305
- get object() {
2306
- return cachedTypeOfValidator("object");
2307
- },
2308
- get string() {
2309
- return cachedTypeOfValidator("string");
2310
- },
2311
- get symbol() {
2312
- return cachedTypeOfValidator("symbol");
2313
- }
2314
- };
2315
- var locale6 = {
2316
- length: "at most {value} arguments",
2317
- actualLength: "{value} arguments"
2318
- };
2319
- var functionValidators = {
2320
- length(max) {
2321
- return createValidator(
2322
- substitute(locale6.length, { value: max }),
2323
- (input) => input.length <= max,
2324
- (input) => substitute(locale6.actualLength, { value: input.length })
2325
- );
2326
- }
2327
- };
2328
- var _FunctionSchema = class _FunctionSchema2 extends ValueSchema {
2329
- /**
2330
- * The base Function validator validating that the input is a function.
2331
- */
2332
- static get base() {
2333
- if (this._base == null)
2334
- this._base = new _FunctionSchema2(typeOfValidators.func);
2335
- return this._base;
2336
- }
2337
- length(max) {
2338
- return this.chain(functionValidators.length(max));
2339
- }
2340
- /**
2341
- * Casts the function signature.
2342
- * Function signatures, except for their required number of parameters, cannot be
2343
- * meaningfully validated.
2344
- */
2345
- cast() {
2346
- return this;
2347
- }
2348
- };
2349
- __publicField3(_FunctionSchema, "_base", null);
2350
- var locale7 = {
2351
- set: "Set",
2352
- withElements: "Set<{value}>"
2353
- };
2354
- var setValidators = {
2355
- /**
2356
- * Creates a validator that asserts that the input is a set.
2357
- */
2358
- isSet() {
2359
- return createValidator(
2360
- locale7.set,
2361
- (input) => input instanceof Set
2362
- );
2363
- },
2364
- /**
2365
- * Creates a validator that asserts that every element passes the given validator.
2366
- *
2367
- * @param elementValidator
2368
- */
2369
- withElements(elementValidator) {
2370
- return createDeepValidator(
2371
- substitute(locale7.withElements, {
2372
- value: elementValidator.description
2373
- }),
2374
- (input, options, path) => {
2375
- const errors = [];
2376
- let i = 0;
2377
- for (const element2 of input) {
2378
- errors.push(
2379
- ...elementValidator.validate(
2380
- element2,
2381
- options,
2382
- path.concat(i.toString())
2383
- )
2384
- );
2385
- if (!options.all && errors.length) return errors;
2386
- i++;
2387
- }
2388
- return errors;
2389
- }
2390
- );
2391
- }
2392
- };
2393
- var _SetSchema = class _SetSchema2 extends ValueSchema {
2394
- /**
2395
- * The base SetSchema instance validating that the input is a Set.
2396
- */
2397
- static get base() {
2398
- if (this._base == null)
2399
- this._base = new _SetSchema2(setValidators.isSet());
2400
- return this._base;
2401
- }
2402
- /**
2403
- * Creates a validator that asserts that every element passes the given validator.
2404
- *
2405
- * @param elementValidator
2406
- */
2407
- withElements(elementValidator) {
2408
- return this.chain(setValidators.withElements(elementValidator));
2409
- }
2410
- /**
2411
- * Casts to a readonly set.
2412
- * This is a shallow cast, elements of the array will not be changed.
2413
- */
2414
- readonly() {
2415
- return this;
2416
- }
2417
- /**
2418
- * Casts the parameter type.
2419
- */
2420
- cast() {
2421
- return this;
2422
- }
2423
- };
2424
- __publicField3(_SetSchema, "_base", null);
2425
- var locale8 = {
2426
- gte: "at least {value}",
2427
- gt: "greater than {value}",
2428
- lte: "at most {value}",
2429
- lt: "less than {value}",
2430
- within: "within {min} and {max}",
2431
- safeInteger: "safe integer",
2432
- finite: "finite"
2433
- };
2434
- var numberValidators = {
2435
- /**
2436
- * Creates a validator that asserts that the input number is at least the provided minimum
2437
- * value.
2438
- *
2439
- * @param min The minimum (inclusive) the value may be.
2440
- */
2441
- gte(min) {
2442
- return createValidator(
2443
- substitute(locale8.gte, { value: min }),
2444
- (input) => input >= min
2445
- );
2446
- },
2447
- /**
2448
- * Creates a validator that asserts that the input number is greater than the provided minimum
2449
- * value.
2450
- *
2451
- * @param min The minimum (exclusive) the value may be.
2452
- */
2453
- gt(min) {
2454
- return createValidator(
2455
- substitute(locale8.gt, { value: min }),
2456
- (input) => input > min
2457
- );
2458
- },
2459
- /**
2460
- * Creates a validator that asserts that the input number is at most the provided maximum
2461
- * value.
2462
- *
2463
- * @param max The maximum (inclusive) the value may be.
2464
- */
2465
- lte(max) {
2466
- return createValidator(
2467
- substitute(locale8.lte, { value: max }),
2468
- (input) => input <= max
2469
- );
2470
- },
2471
- /**
2472
- * Creates a validator that asserts that the input number is less than the provided maximum
2473
- * value.
2474
- *
2475
- * @param max The maximum (exclusive) the value may be.
2476
- */
2477
- lt(max) {
2478
- return createValidator(
2479
- substitute(locale8.lt, { value: max }),
2480
- (input) => input < max
2481
- );
2482
- },
2483
- /**
2484
- * Creates a validator that asserts that the input number is at least the provided minimum
2485
- * and at most the provided maximum values.
2486
- *
2487
- * @param min The minimum (inclusive) value the input may be.
2488
- * @param max The maximum (inclusive) value the input may be.
2489
- */
2490
- within(min, max) {
2491
- return createValidator(
2492
- substitute(locale8.within, { min, max }),
2493
- (input) => input >= min && input <= max
2494
- );
2495
- },
2496
- /**
2497
- * Creates a validator that asserts that the input number is finite.
2498
- */
2499
- finite() {
2500
- return createValidator(locale8.finite, (input) => Number.isFinite(input));
2501
- },
2502
- /**
2503
- * Creates a validator that asserts that the input number is a safe integer.
2504
- */
2505
- safeInteger() {
2506
- return createValidator(
2507
- locale8.safeInteger,
2508
- (input) => Number.isSafeInteger(input)
2509
- );
2510
- }
2511
- };
2512
- var _NumberSchema = class _NumberSchema2 extends ValueSchema {
2513
- /**
2514
- * The base Object validator validating that the input is an object.
2515
- */
2516
- static get base() {
2517
- if (this._base == null)
2518
- this._base = new _NumberSchema2(typeOfValidators.number);
2519
- return this._base;
2520
- }
2521
- /**
2522
- * Creates a validator that asserts that the input number is at least the provided minimum
2523
- * value.
2524
- *
2525
- * @param min The minimum (inclusive) the value may be.
2526
- */
2527
- gte(min) {
2528
- return this.chain(numberValidators.gte(min));
2529
- }
2530
- /**
2531
- * Creates a validator that asserts that the input number is greater than the provided minimum
2532
- * value.
2533
- *
2534
- * @param min The minimum (exclusive) the value may be.
2535
- */
2536
- gt(min) {
2537
- return this.chain(numberValidators.gt(min));
2538
- }
2539
- /**
2540
- * Creates a validator that asserts that the input number is at most the provided maximum
2541
- * value.
2542
- *
2543
- * @param max The maximum (inclusive) the value may be.
2544
- */
2545
- lte(max) {
2546
- return this.chain(numberValidators.lte(max));
2547
- }
2548
- /**
2549
- * Creates a validator that asserts that the input number is less than the provided maximum
2550
- * value.
2551
- *
2552
- * @param max The maximum (exclusive) the value may be.
2553
- */
2554
- lt(max) {
2555
- return this.chain(numberValidators.lt(max));
2556
- }
2557
- /**
2558
- * Creates a validator that asserts that the input number is at least the provided minimum
2559
- * and at most the provided maximum values.
2560
- *
2561
- * @param min The minimum (inclusive) value the input may be.
2562
- * @param max The maximum (inclusive) value the input may be.
2563
- */
2564
- within(min, max) {
2565
- return this.chain(numberValidators.within(min, max));
2566
- }
2567
- /**
2568
- * Creates a validator that asserts that the input number is finite.
2569
- */
2570
- finite() {
2571
- return this.chain(numberValidators.finite());
2572
- }
2573
- /**
2574
- * Creates a validator that asserts that the input number is a safe integer.
2575
- */
2576
- safeInteger() {
2577
- return this.chain(numberValidators.safeInteger());
2578
- }
2579
- };
2580
- __publicField3(_NumberSchema, "_base", null);
2581
- var NumberSchema = _NumberSchema;
2582
- function isValidatorWithPartial(validator) {
2583
- return "partial" in validator && "partialDeep" in validator;
2584
- }
2585
- function maybeToDeepPartial(validator) {
2586
- return isValidatorWithPartial(validator) ? validator.partialDeep() : validator;
2587
- }
2588
- function maybeToPartial(validator) {
2589
- return isValidatorWithPartial(validator) ? validator.partial() : validator;
2590
- }
2591
- var locale9 = {
2592
- extend: "{\n{body}\n}",
2593
- prop: "{key}: {value}",
2594
- propSeparator: ",\n",
2595
- indent: " ",
2596
- required: `property '{key}' is required`
2597
- };
2598
- var objectValidators = {
2599
- /**
2600
- * Creates a validator that validates the input has properties that pass their respective
2601
- * validators.
2602
- *
2603
- * @param propertyValidators
2604
- */
2605
- properties(propertyValidators) {
2606
- const propertiesDescriptions = [];
2607
- const keys = ownKeys(propertyValidators);
2608
- for (const key of keys) {
2609
- const validator2 = propertyValidators[key];
2610
- propertiesDescriptions.push(
2611
- substitute(locale9.prop, {
2612
- key: String(key) + (validator2.options.optional ? "?" : ""),
2613
- value: validator2.description
2614
- })
2615
- );
2616
- }
2617
- const description = substitute(locale9.extend, {
2618
- body: propertiesDescriptions.join(locale9.propSeparator).split("\n").map((line) => locale9.indent + line).join("\n")
2619
- });
2620
- const validator = createDeepValidator(
2621
- description,
2622
- (input, options, path) => {
2623
- const errors = [];
2624
- for (const key of keys) {
2625
- const validator2 = propertyValidators[key];
2626
- if (key in input) {
2627
- const value = input[key];
2628
- errors.push(
2629
- ...validator2.validate(
2630
- value,
2631
- options,
2632
- path.concat(String(key))
2633
- )
2634
- );
2635
- } else {
2636
- if (!validator2.options.optional) {
2637
- errors.push({
2638
- message: substitute(locale9.required, { key }),
2639
- path: path.concat(String(key))
2640
- });
2641
- }
2642
- }
2643
- if (!options.all && errors.length) return errors;
2644
- }
2645
- return errors;
2646
- }
2647
- );
2648
- return merge(validator, {
2649
- partial() {
2650
- const optionalPropertyValidators = {};
2651
- for (const key of keys) {
2652
- optionalPropertyValidators[key] = propertyValidators[key].optional();
2653
- }
2654
- return objectValidators.properties(
2655
- optionalPropertyValidators
2656
- );
2657
- },
2658
- partialDeep() {
2659
- const optionalPropertyValidators = {};
2660
- for (const key of keys) {
2661
- optionalPropertyValidators[key] = maybeToDeepPartial(
2662
- propertyValidators[key].optional()
2663
- );
2664
- }
2665
- return objectValidators.properties(
2666
- optionalPropertyValidators
2667
- );
2668
- }
2669
- });
2670
- }
2671
- };
2672
- var _ObjectSchema = class _ObjectSchema2 extends ValueSchema {
2673
- /**
2674
- * The base Object validator validating that the input is an object.
2675
- */
2676
- static get base() {
2677
- if (this._base == null)
2678
- this._base = new _ObjectSchema2(typeOfValidators.object);
2679
- return this._base;
2680
- }
2681
- /**
2682
- * Creates a validator that validates the input has properties that pass their respective
2683
- * validators.
2684
- *
2685
- * @param propertyValidators
2686
- */
2687
- extend(propertyValidators) {
2688
- return this.chain(objectValidators.properties(propertyValidators));
2689
- }
2690
- /**
2691
- * Allows all properties to be undefined.
2692
- */
2693
- partial() {
2694
- return this.clone(maybeToPartial);
2695
- }
2696
- /**
2697
- * Allows all recursive properties to be undefined.
2698
- */
2699
- partialDeep() {
2700
- return this.clone(maybeToDeepPartial);
2701
- }
2702
- /**
2703
- * Casts the type parameter.
2704
- */
2705
- cast() {
2706
- return this;
2707
- }
2708
- };
2709
- __publicField3(_ObjectSchema, "_base", null);
2710
- var locale10 = {
2711
- notEmpty: "not empty",
2712
- minLength: "at least {value} characters",
2713
- maxLength: "at most {value} characters",
2714
- noWhitespace: "no whitespace characters",
2715
- matches: "matches {value}"
2716
- };
2717
- var stringValidators = {
2718
- /**
2719
- * Creates a validator that asserts that the input is not empty.
2720
- */
2721
- notEmpty() {
2722
- return createValidator(locale10.notEmpty, (input) => input !== "");
2723
- },
2724
- /**
2725
- * Creates a validator that asserts that the input string has at least the given minimum
2726
- * length.
2727
- *
2728
- * @param min The string must be at least this length.
2729
- */
2730
- minLength(min) {
2731
- return createValidator(
2732
- substitute(locale10.minLength, { value: min }),
2733
- (input) => input.length >= min
2734
- );
2735
- },
2736
- /**
2737
- * Creates a validator that asserts that the input string has at most the given maximum
2738
- * length.
2739
- *
2740
- * @param max The string must be at most this length.
2741
- */
2742
- maxLength(max) {
2743
- return createValidator(
2744
- substitute(locale10.maxLength, { value: max }),
2745
- (input) => input.length <= max
2746
- );
2747
- },
2748
- /**
2749
- * Creates a validator that asserts that the input string has no whitespace characters.
2750
- * Whitespace characters include space, new line, carriage return, and tab.
2751
- */
2752
- noWhitespace() {
2753
- return createValidator(
2754
- locale10.noWhitespace,
2755
- (input) => input.search(/\s/g) === -1
2756
- );
2757
- },
2758
- /**
2759
- * Creates a validator that asserts that the input string matches the given regex.
2760
- * @param regex
2761
- */
2762
- matches(regex) {
2763
- return createValidator(
2764
- substitute(locale10.matches, { value: regex.toString() }),
2765
- (input) => {
2766
- return regex.test(input);
2767
- }
2768
- );
2769
- }
2770
- };
2771
- var _StringSchema = class _StringSchema2 extends ValueSchema {
2772
- /**
2773
- * The base SetSchema instance validating that the input is a Set.
2774
- */
2775
- static get base() {
2776
- if (this._base == null)
2777
- this._base = new _StringSchema2(typeOfValidators.string);
2778
- return this._base;
2779
- }
2780
- /**
2781
- * Creates a validator that asserts that the input is not empty.
2782
- */
2783
- notEmpty() {
2784
- return this.chain(stringValidators.notEmpty());
2785
- }
2786
- /**
2787
- * Creates a validator that asserts that the input string has at least the given minimum
2788
- * length.
2789
- *
2790
- * @param min The string must be at least this length.
2791
- */
2792
- minLength(min) {
2793
- return this.chain(stringValidators.minLength(min));
2794
- }
2795
- /**
2796
- * Creates a validator that asserts that the input string has at most the given maximum
2797
- * length.
2798
- *
2799
- * @param max The string must be at most this length.
2800
- */
2801
- maxLength(max) {
2802
- return this.chain(stringValidators.maxLength(max));
2803
- }
2804
- /**
2805
- * Creates a validator that asserts that the input string has no whitespace characters.
2806
- * Whitespace characters include space, new line, carriage return, and tab.
2807
- */
2808
- noWhitespace() {
2809
- return this.chain(stringValidators.noWhitespace());
2810
- }
2811
- /**
2812
- * Creates a validator that asserts that the input string matches the given regex.
2813
- * @param regex
2814
- */
2815
- matches(regex) {
2816
- return this.chain(stringValidators.matches(regex));
2817
- }
2818
- };
2819
- __publicField3(_StringSchema, "_base", null);
2820
- var StringSchema = _StringSchema;
2821
- var locale11 = {
2822
- record: "{ [key: {key}]: {value} }"
2823
- };
2824
- var recordValidators = {
2825
- /**
2826
- * Returns a validator that asserts that the object's own enumerable properties has keys and
2827
- * values that match their respective validators.
2828
- *
2829
- * Prototype members are not included.
2830
- * Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed
2831
- * to the key validator as '0'.
2832
- *
2833
- * @param keyValidator Validates each key.
2834
- * @param valueValidator Validates each value.
2835
- */
2836
- record(keyValidator, valueValidator) {
2837
- return createDeepValidator(
2838
- substitute(locale11.record, {
2839
- key: keyValidator.description,
2840
- value: valueValidator.description
2841
- }),
2842
- (input, options, path) => {
2843
- const errors = [];
2844
- for (const key of ownKeys(input)) {
2845
- const keyStr = String(key);
2846
- errors.push(
2847
- ...keyValidator.validate(
2848
- key,
2849
- options,
2850
- path.concat(`[${keyStr}]`)
2851
- )
2852
- );
2853
- if (!options.all && errors.length) return errors;
2854
- const value = input[key];
2855
- errors.push(
2856
- ...valueValidator.validate(
2857
- value,
2858
- options,
2859
- path.concat(keyStr)
2860
- )
2861
- );
2862
- if (!options.all && errors.length) return errors;
2863
- }
2864
- return errors;
2865
- }
2866
- );
2867
- }
2868
- };
2869
- var _RecordSchema = class _RecordSchema2 extends ValueSchema {
2870
- /**
2871
- * The base Object validator validating that the input is an object.
2872
- */
2873
- static get base() {
2874
- if (this._base == null)
2875
- this._base = new _RecordSchema2(typeOfValidators.object);
2876
- return this._base;
2877
- }
2878
- static get defaultKeyValidator() {
2879
- return StringSchema.base;
2880
- }
2881
- /**
2882
- * Returns a validator that asserts that the object's own enumerable properties has keys and
2883
- * values that match their respective validators.
2884
- *
2885
- * Prototype members are not included.
2886
- * Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed
2887
- * to the key validator as '0'.
2888
- *
2889
- * @param keyValidator Validates each key.
2890
- * @param valueValidator Validates each value.
2891
- */
2892
- record(keyValidator, valueValidator) {
2893
- return this.chain(recordValidators.record(keyValidator, valueValidator));
2894
- }
2895
- /**
2896
- * Returns a validator that asserts that the object's own enumerable properties has
2897
- * string keys and values that match the given validator.
2898
- *
2899
- * Prototype members are not included.
2900
- *
2901
- * @param valueValidator Validates each value.
2902
- */
2903
- recordValues(valueValidator) {
2904
- return this.record(_RecordSchema2.defaultKeyValidator, valueValidator);
2905
- }
2906
- /**
2907
- * Casts to a ReadonlyRecord
2908
- */
2909
- readonly() {
2910
- return this;
2911
- }
2912
- /**
2913
- * Casts the type parameter.
2914
- */
2915
- cast() {
2916
- return this;
2917
- }
2918
- };
2919
- __publicField3(_RecordSchema, "_base", null);
2920
- var locale12 = {
2921
- isOneOf: "one of: {value}",
2922
- instanceOf: "instance of {value}",
2923
- oneOfSeparator: " | "
2924
- };
2925
- function isOneOf(...possibleValues) {
2926
- return new ValueSchema(
2927
- createValidator(
2928
- substitute(locale12.isOneOf, {
2929
- value: possibleValues.join(locale12.oneOfSeparator)
2930
- }),
2931
- (input) => possibleValues.includes(input)
2932
- )
2933
- );
2934
- }
2935
- function number() {
2936
- return NumberSchema.base;
2937
- }
2938
-
2939
- // ../vinyl-xml/dist/index.js
2940
- var __defProp5 = Object.defineProperty;
2941
- var __defProps4 = Object.defineProperties;
2942
- var __getOwnPropDescs4 = Object.getOwnPropertyDescriptors;
2943
- var __getOwnPropSymbols5 = Object.getOwnPropertySymbols;
2944
- var __hasOwnProp5 = Object.prototype.hasOwnProperty;
2945
- var __propIsEnum5 = Object.prototype.propertyIsEnumerable;
2946
- var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2947
- var __spreadValues5 = (a, b) => {
2948
- for (var prop in b || (b = {}))
2949
- if (__hasOwnProp5.call(b, prop))
2950
- __defNormalProp5(a, prop, b[prop]);
2951
- if (__getOwnPropSymbols5)
2952
- for (var prop of __getOwnPropSymbols5(b)) {
2953
- if (__propIsEnum5.call(b, prop))
2954
- __defNormalProp5(a, prop, b[prop]);
2955
- }
2956
- return a;
2957
- };
2958
- var __spreadProps4 = (a, b) => __defProps4(a, __getOwnPropDescs4(b));
2959
- var __publicField4 = (obj, key, value) => __defNormalProp5(obj, typeof key !== "symbol" ? key + "" : key, value);
2960
- function element(rules, options) {
2961
- return __spreadProps4(__spreadValues5({
2962
- type: "element",
2963
- localPart: void 0,
2964
- namespaceUri: void 0,
2965
- required: false
2966
- }, options), {
2967
- rules
2968
- });
2969
- }
2970
- function elements(rules, options) {
2971
- return __spreadProps4(__spreadValues5({
2972
- type: "elements",
2973
- localPart: void 0,
2974
- namespaceUri: void 0,
2975
- minOccurs: 0,
2976
- maxOccurs: null,
2977
- useEmptyArrays: false
2978
- }, options), {
2979
- rules
2980
- });
2981
- }
2982
- function characters(parse, stringify2) {
2983
- return { type: "characters", parse, stringify: stringify2 };
2984
- }
2985
- var charactersString = /* @__PURE__ */ characters((i) => i, stringify);
2986
- function attr(parse, stringify2, options) {
2987
- return __spreadProps4(__spreadValues5({
2988
- type: "attribute",
2989
- localPart: void 0,
2990
- namespaceUri: null,
2991
- required: false,
2992
- default: void 0
2993
- }, options), {
2994
- parse,
2995
- stringify: stringify2
2996
- });
2997
- }
2998
- function attrString(options) {
2999
- return attr((i) => i, stringify, options);
3000
- }
3001
- function attrInt(options) {
3002
- return attr(parseInt, stringify, options);
3003
- }
3004
- function attrFloat(options) {
3005
- return attr(parseFloat, stringify, options);
3006
- }
3007
- function attrBoolean(options) {
3008
- return attr(parseBoolean, stringify, options);
3009
- }
3010
- function attrDateTime(options) {
3011
- return attr(parseDate, stringifyDate, options);
3012
- }
3013
- var xmlSchemaErrorLocale = {
3014
- atLeastElements: "Expected at least {expected} occurrences of {property} but was {actual}",
3015
- atMostElements: "Expected at most {expected} occurrences of {property} but was {actual}",
3016
- cyclicReferences: "Cyclic reference detected",
3017
- requiredAttribute: `Attribute '{property}' is required`
3018
- };
3019
- var XmlSchemaError = class _XmlSchemaError extends ReportableError {
3020
- get [Symbol.toStringTag]() {
3021
- return "XmlSchemaError";
3022
- }
3023
- constructor(message) {
3024
- super(message, ErrorOrigin.PARSING);
3025
- Object.setPrototypeOf(this, _XmlSchemaError.prototype);
1924
+ constructor(message) {
1925
+ super(message, ErrorOrigin.PARSING);
1926
+ Object.setPrototypeOf(this, _XmlSchemaError.prototype);
3026
1927
  }
3027
1928
  };
1929
+
1930
+ // ../vinyl-xml/src/xml/parseXml.ts
3028
1931
  var XMLNS = "http://www.w3.org/2000/xmlns/";
3029
- var LT = /* @__PURE__ */ char("<");
3030
- var GT = /* @__PURE__ */ char(">");
3031
- var EQ = /* @__PURE__ */ char("=");
3032
- var SLASH = /* @__PURE__ */ char("/");
3033
- var COLON = /* @__PURE__ */ char(":");
3034
- var QMARK = /* @__PURE__ */ char("?");
3035
- var EXCL = /* @__PURE__ */ char("!");
3036
- var APOS = /* @__PURE__ */ char("'");
3037
- var QUOT = /* @__PURE__ */ char('"');
1932
+ var LT = char("<");
1933
+ var GT = char(">");
1934
+ var EQ = char("=");
1935
+ var SLASH = char("/");
1936
+ var COLON = char(":");
1937
+ var QMARK = char("?");
1938
+ var EXCL = char("!");
1939
+ var APOS = char("'");
1940
+ var QUOT = char('"');
3038
1941
  var QUOTES = /* @__PURE__ */ new Set([APOS, QUOT]);
3039
1942
  function parseXml(str, handler) {
3040
1943
  const c = new StringReader(str);
@@ -3126,479 +2029,1004 @@
3126
2029
  } catch (e) {
3127
2030
  c.err(e.message);
3128
2031
  }
3129
- if (c.charIf(SLASH)) {
3130
- c.readChar(GT);
3131
- stack.pop();
3132
- current = last(stack);
3133
- try {
3134
- handler.endElement();
3135
- } catch (e) {
3136
- c.err(e.message);
2032
+ if (c.charIf(SLASH)) {
2033
+ c.readChar(GT);
2034
+ stack.pop();
2035
+ current = last(stack);
2036
+ try {
2037
+ handler.endElement();
2038
+ } catch (e) {
2039
+ c.err(e.message);
2040
+ }
2041
+ } else {
2042
+ c.readChar(GT);
2043
+ }
2044
+ }
2045
+ }
2046
+ try {
2047
+ return handler.endDocument();
2048
+ } catch (e) {
2049
+ return c.err(e.message);
2050
+ }
2051
+ }
2052
+ function readAttributeValue(c) {
2053
+ const quote = c.next();
2054
+ if (!QUOTES.has(quote)) c.err(`Expected ' or "`);
2055
+ const value = c.substringUntil((charCode) => charCode === quote);
2056
+ c.readChar(quote);
2057
+ return decodeEntities(value);
2058
+ }
2059
+ function untilTagClose(c) {
2060
+ while (true) {
2061
+ c.until((c2) => c2 === APOS || c2 === QUOT || c2 === GT);
2062
+ const char2 = c.next();
2063
+ if (QUOTES.has(char2)) {
2064
+ c.untilChar(char2);
2065
+ c.next();
2066
+ } else {
2067
+ break;
2068
+ }
2069
+ }
2070
+ }
2071
+ function isNameChar(charCode) {
2072
+ if (charCode >= 97) {
2073
+ if (charCode >= 183) {
2074
+ if (charCode >= 768) {
2075
+ if (charCode >= 8255) {
2076
+ return charCode <= 8256;
2077
+ } else {
2078
+ return charCode <= 879;
2079
+ }
2080
+ } else {
2081
+ return charCode === 183;
2082
+ }
2083
+ } else {
2084
+ return charCode <= 122;
2085
+ }
2086
+ } else {
2087
+ if (charCode >= 95) {
2088
+ return charCode === 95;
2089
+ } else {
2090
+ if (charCode >= 65) {
2091
+ return charCode <= 90;
2092
+ } else {
2093
+ if (charCode >= 45) {
2094
+ if (charCode >= 48) {
2095
+ return charCode <= 57;
2096
+ } else {
2097
+ return charCode <= 46;
2098
+ }
2099
+ } else {
2100
+ return false;
2101
+ }
2102
+ }
2103
+ }
2104
+ }
2105
+ }
2106
+ function readQName(reader) {
2107
+ const prefixOrLocalName = reader.substringWhile(isNameChar);
2108
+ let prefix, localPart, name;
2109
+ if (reader.charIf(COLON)) {
2110
+ prefix = prefixOrLocalName;
2111
+ localPart = reader.substringWhile(isNameChar);
2112
+ name = `${prefix}:${localPart}`;
2113
+ } else {
2114
+ prefix = null;
2115
+ localPart = prefixOrLocalName;
2116
+ name = localPart;
2117
+ }
2118
+ return { prefix, localPart, qName: name, namespaceUri: null };
2119
+ }
2120
+ function xmlAttributes(reader, stackElement) {
2121
+ const attributes = {};
2122
+ while (true) {
2123
+ reader.white();
2124
+ if (!isNameChar(reader.peek)) break;
2125
+ const name = readQName(reader);
2126
+ reader.white();
2127
+ let value = "";
2128
+ if (reader.charIf(EQ)) {
2129
+ reader.white();
2130
+ value = readAttributeValue(reader);
2131
+ } else {
2132
+ }
2133
+ if (name.prefix === "xmlns") {
2134
+ name.namespaceUri = XMLNS;
2135
+ stackElement.namespaceMap.set(
2136
+ name.localPart,
2137
+ value === "" ? null : value
2138
+ );
2139
+ } else if (!name.prefix && name.localPart === "xmlns") {
2140
+ name.namespaceUri = XMLNS;
2141
+ stackElement.defaultNamespaceUri = !value ? null : value;
2142
+ }
2143
+ if (attributes[name.qName] != null)
2144
+ reader.err(`Attribute '${name.qName}' is already specified.`);
2145
+ attributes[name.qName] = { name, value };
2146
+ }
2147
+ return attributes;
2148
+ }
2149
+
2150
+ // ../vinyl-xml/src/xml/mergeXmlRules.ts
2151
+ var locale5 = {
2152
+ illegalRuleOverrideTypeError: "Cannot override the rule {property} of type {sourceType} with a rule of type {overrideType}",
2153
+ illegalQNameOverrideError: "Cannot override the rule {property} with a different localPart or namespace"
2154
+ };
2155
+ function mergeXmlRules(...rules) {
2156
+ let finalRule = rules[0];
2157
+ for (let i = 1; i < rules.length; i++) {
2158
+ finalRule = plainObjectMergeRule.merge(
2159
+ finalRule,
2160
+ rules[i],
2161
+ mergeXmlRule
2162
+ );
2163
+ }
2164
+ return finalRule;
2165
+ }
2166
+ function mergeXmlRule(sourceA, sourceB, prop) {
2167
+ var _a2, _b, _c, _d;
2168
+ if (sourceA == null) return sourceB;
2169
+ const sourceAIsLazy = typeof sourceA === "function";
2170
+ const sourceBIsLazy = typeof sourceB === "function";
2171
+ if (sourceAIsLazy || sourceBIsLazy) {
2172
+ return () => {
2173
+ const a = sourceAIsLazy ? sourceA() : sourceA;
2174
+ const b = sourceBIsLazy ? sourceB() : sourceB;
2175
+ return mergeXmlRule(a, b, prop);
2176
+ };
2177
+ }
2178
+ if (sourceA.type !== sourceB.type) {
2179
+ throw new ValidationError(
2180
+ substitute(locale5.illegalRuleOverrideTypeError, {
2181
+ property: prop,
2182
+ sourceType: sourceA.type,
2183
+ overrideType: sourceB.type
2184
+ })
2185
+ );
2186
+ }
2187
+ switch (sourceA.type) {
2188
+ case "attribute" /* ATTRIBUTE */:
2189
+ case "element" /* ELEMENT */:
2190
+ case "elements" /* ELEMENTS */: {
2191
+ const b = sourceB;
2192
+ if (sourceA.namespaceUri !== b.namespaceUri || ((_a2 = sourceA.localPart) != null ? _a2 : prop) !== ((_b = b.localPart) != null ? _b : prop)) {
2193
+ throw new ValidationError(
2194
+ substitute(locale5.illegalQNameOverrideError, {
2195
+ property: prop
2196
+ })
2197
+ );
2198
+ }
2199
+ break;
2200
+ }
2201
+ }
2202
+ switch (sourceA.type) {
2203
+ case "attribute" /* ATTRIBUTE */: {
2204
+ const b = sourceB;
2205
+ return __spreadProps(__spreadValues({}, b), {
2206
+ default: (_c = b.default) != null ? _c : sourceA.default
2207
+ });
2208
+ }
2209
+ case "characters" /* CHARACTERS */:
2210
+ return sourceB;
2211
+ case "element" /* ELEMENT */: {
2212
+ const b = sourceB;
2213
+ return __spreadProps(__spreadValues({}, b), {
2214
+ required: sourceA.required || b.required,
2215
+ rules: mergeXmlRules(sourceA.rules, b.rules)
2216
+ });
2217
+ }
2218
+ case "elements" /* ELEMENTS */: {
2219
+ const b = sourceB;
2220
+ const maxOccurs = sourceA.maxOccurs != null && b.maxOccurs != null ? Math.min(sourceA.maxOccurs, b.maxOccurs) : (_d = sourceA.maxOccurs) != null ? _d : b.maxOccurs;
2221
+ return __spreadProps(__spreadValues({}, b), {
2222
+ minOccurs: Math.max(sourceA.minOccurs, b.minOccurs),
2223
+ maxOccurs,
2224
+ useEmptyArrays: sourceA.useEmptyArrays || b.useEmptyArrays,
2225
+ rules: mergeXmlRules(sourceA.rules, b.rules)
2226
+ });
2227
+ }
2228
+ }
2229
+ }
2230
+
2231
+ // ../vinyl-xml/src/xml/mappedXmlRules.ts
2232
+ var EmptyRules = {
2233
+ __type: invariant(),
2234
+ attributes: /* @__PURE__ */ new Map(),
2235
+ elements: /* @__PURE__ */ new Map(),
2236
+ characters: void 0
2237
+ };
2238
+ function mapXmlRules(rules, parentNamespaceUri = null) {
2239
+ var _a2, _b, _c;
2240
+ const attributeRules = /* @__PURE__ */ new Map();
2241
+ const elementRules = /* @__PURE__ */ new Map();
2242
+ let charactersRule = void 0;
2243
+ for (const property in rules) {
2244
+ const handlerOrFunction = rules[property];
2245
+ let handler;
2246
+ if (typeof handlerOrFunction === "function") {
2247
+ handler = handlerOrFunction();
2248
+ } else {
2249
+ handler = handlerOrFunction;
2250
+ }
2251
+ let key;
2252
+ switch (handler.type) {
2253
+ case "characters" /* CHARACTERS */:
2254
+ if (charactersRule !== void 0)
2255
+ throw new IllegalArgumentError(
2256
+ "characters handler already defined"
2257
+ );
2258
+ charactersRule = {
2259
+ property,
2260
+ parse: handler.parse,
2261
+ stringify: handler.stringify
2262
+ };
2263
+ break;
2264
+ case "element" /* ELEMENT */:
2265
+ case "elements" /* ELEMENTS */: {
2266
+ const localPart = (_a2 = handler.localPart) != null ? _a2 : property;
2267
+ const namespaceUri = handler.namespaceUri === void 0 ? parentNamespaceUri : handler.namespaceUri;
2268
+ key = xmlRuleKey(localPart, namespaceUri);
2269
+ if (elementRules.has(key)) {
2270
+ throw new IllegalArgumentError(
2271
+ `Multiple element rules for ${key}`
2272
+ );
2273
+ }
2274
+ if (handler.type === "element" /* ELEMENT */) {
2275
+ const rules2 = handler.rules;
2276
+ elementRules.set(key, {
2277
+ array: false,
2278
+ property,
2279
+ minOccurs: handler.required ? 1 : 0,
2280
+ maxOccurs: 1,
2281
+ rules: memoize(() => mapXmlRules(rules2, namespaceUri)),
2282
+ useEmptyArrays: false,
2283
+ localPart,
2284
+ namespaceUri
2285
+ });
2286
+ } else {
2287
+ const rules2 = handler.rules;
2288
+ elementRules.set(key, {
2289
+ array: true,
2290
+ property,
2291
+ maxOccurs: handler.maxOccurs,
2292
+ minOccurs: handler.minOccurs,
2293
+ rules: memoize(() => mapXmlRules(rules2, namespaceUri)),
2294
+ useEmptyArrays: handler.useEmptyArrays,
2295
+ localPart,
2296
+ namespaceUri
2297
+ });
2298
+ }
2299
+ break;
2300
+ }
2301
+ case "attribute" /* ATTRIBUTE */: {
2302
+ const namespaceUri = handler.namespaceUri;
2303
+ const localPart = (_b = handler.localPart) != null ? _b : property;
2304
+ key = xmlRuleKey(localPart, namespaceUri);
2305
+ if (attributeRules.has(key)) {
2306
+ throw new IllegalArgumentError(
2307
+ `Multiple attribute rules for ${key}`
2308
+ );
3137
2309
  }
3138
- } else {
3139
- c.readChar(GT);
2310
+ attributeRules.set(key, {
2311
+ property,
2312
+ default: handler.default,
2313
+ parse: handler.parse,
2314
+ stringify: handler.stringify,
2315
+ required: handler.required,
2316
+ localPart,
2317
+ namespaceUri: (_c = handler.namespaceUri) != null ? _c : null
2318
+ });
2319
+ break;
3140
2320
  }
3141
2321
  }
3142
2322
  }
3143
- try {
3144
- return handler.endDocument();
3145
- } catch (e) {
3146
- return c.err(e.message);
3147
- }
2323
+ return {
2324
+ __type: invariant(),
2325
+ attributes: attributeRules,
2326
+ elements: elementRules,
2327
+ characters: charactersRule
2328
+ };
3148
2329
  }
3149
- function readAttributeValue(c) {
3150
- const quote = c.next();
3151
- if (!QUOTES.has(quote)) c.err(`Expected ' or "`);
3152
- const value = c.substringUntil((charCode) => charCode === quote);
3153
- c.readChar(quote);
3154
- return decodeEntities(value);
2330
+ function xmlRuleKey(localPart, namespaceUri = null) {
2331
+ return `${namespaceUri != null ? namespaceUri : ""}:${localPart}`;
3155
2332
  }
3156
- function untilTagClose(c) {
3157
- while (true) {
3158
- c.until((c2) => c2 === APOS || c2 === QUOT || c2 === GT);
3159
- const char2 = c.next();
3160
- if (QUOTES.has(char2)) {
3161
- c.untilChar(char2);
3162
- c.next();
3163
- } else {
3164
- break;
3165
- }
3166
- }
2333
+
2334
+ // ../vinyl-xml/src/xml/ParseXmlHandlerImpl.ts
2335
+ function getRule(name, rules) {
2336
+ return rules.get(xmlRuleKey(name.localPart, name.namespaceUri));
3167
2337
  }
3168
- function isNameChar(charCode) {
3169
- if (charCode >= 97) {
3170
- if (charCode >= 183) {
3171
- if (charCode >= 768) {
3172
- if (charCode >= 8255) {
3173
- return charCode <= 8256;
2338
+ var ParseXmlHandlerImpl = class {
2339
+ constructor(rules, options) {
2340
+ __publicField(this, "rules", rules);
2341
+ __publicField(this, "stack", []);
2342
+ __publicField(this, "options");
2343
+ __publicField(this, "busy", false);
2344
+ this.options = __spreadValues({ validateRules: true }, options);
2345
+ }
2346
+ startDocument() {
2347
+ if (this.busy)
2348
+ throw new IllegalStateError("XML content handler is busy");
2349
+ this.busy = true;
2350
+ const rules = this.rules;
2351
+ this.stack.push({
2352
+ element: new XmlElementImpl(),
2353
+ rules,
2354
+ characters: ""
2355
+ });
2356
+ }
2357
+ startElement(name, attributes) {
2358
+ var _a2;
2359
+ const parent = last(this.stack);
2360
+ let element2 = null;
2361
+ const elementRule = getRule(name, parent.rules.elements);
2362
+ const rules = (_a2 = elementRule == null ? void 0 : elementRule.rules()) != null ? _a2 : EmptyRules;
2363
+ if (elementRule) {
2364
+ const prop = elementRule.property;
2365
+ element2 = new XmlElementImpl(parent.element);
2366
+ if (elementRule.array) {
2367
+ const arr = parent.element[prop];
2368
+ if (Array.isArray(arr)) {
2369
+ arr.push(element2);
3174
2370
  } else {
3175
- return charCode <= 879;
2371
+ parent.element[prop] = [element2];
3176
2372
  }
3177
2373
  } else {
3178
- return charCode === 183;
3179
- }
3180
- } else {
3181
- return charCode <= 122;
3182
- }
3183
- } else {
3184
- if (charCode >= 95) {
3185
- return charCode === 95;
3186
- } else {
3187
- if (charCode >= 65) {
3188
- return charCode <= 90;
3189
- } else {
3190
- if (charCode >= 45) {
3191
- if (charCode >= 48) {
3192
- return charCode <= 57;
3193
- } else {
3194
- return charCode <= 46;
3195
- }
2374
+ if (parent.element[prop]) {
2375
+ throw new XmlSchemaError(
2376
+ `Expected single element with name ${name.qName}`
2377
+ );
3196
2378
  } else {
3197
- return false;
2379
+ parent.element[prop] = element2;
2380
+ }
2381
+ }
2382
+ const attributeRules = rules.attributes;
2383
+ for (const k in attributes) {
2384
+ const attribute = attributes[k];
2385
+ const name2 = attribute.name;
2386
+ const attributeRule = getRule(name2, attributeRules);
2387
+ if (attributeRule) {
2388
+ element2[attributeRule.property] = attributeRule.parse(
2389
+ attribute.value
2390
+ );
3198
2391
  }
3199
2392
  }
2393
+ attributeRules.forEach((_value, key) => {
2394
+ const rule = attributeRules.get(key);
2395
+ if (!(rule.property in element2)) {
2396
+ if (rule.default != null) {
2397
+ element2[rule.property] = rule.default;
2398
+ } else if (this.options.validateRules && rule.required) {
2399
+ throw new XmlSchemaError(
2400
+ substitute(xmlSchemaErrorLocale.requiredAttribute, {
2401
+ property: rule.property
2402
+ })
2403
+ );
2404
+ }
2405
+ }
2406
+ });
3200
2407
  }
2408
+ this.stack.push({
2409
+ element: element2,
2410
+ rules,
2411
+ characters: ""
2412
+ });
3201
2413
  }
3202
- }
3203
- function readQName(reader) {
3204
- const prefixOrLocalName = reader.substringWhile(isNameChar);
3205
- let prefix, localPart, name;
3206
- if (reader.charIf(COLON)) {
3207
- prefix = prefixOrLocalName;
3208
- localPart = reader.substringWhile(isNameChar);
3209
- name = `${prefix}:${localPart}`;
3210
- } else {
3211
- prefix = null;
3212
- localPart = prefixOrLocalName;
3213
- name = localPart;
2414
+ textNode(str) {
2415
+ const current = last(this.stack);
2416
+ if (!current.rules.characters) return;
2417
+ current.characters += decodeEntities(str.trim());
3214
2418
  }
3215
- return { prefix, localPart, qName: name, namespaceUri: null };
3216
- }
3217
- function xmlAttributes(reader, stackElement) {
3218
- const attributes = {};
3219
- while (true) {
3220
- reader.white();
3221
- if (!isNameChar(reader.peek)) break;
3222
- const name = readQName(reader);
3223
- reader.white();
3224
- let value = "";
3225
- if (reader.charIf(EQ)) {
3226
- reader.white();
3227
- value = readAttributeValue(reader);
3228
- } else {
2419
+ cDataNode(str) {
2420
+ const current = last(this.stack);
2421
+ if (!current.rules.characters) return;
2422
+ current.characters += str;
2423
+ }
2424
+ endElement() {
2425
+ const lastEl = this.stack.pop();
2426
+ const charactersRule = lastEl.rules.characters;
2427
+ if (charactersRule)
2428
+ lastEl.element[charactersRule.property] = charactersRule.parse(
2429
+ lastEl.characters
2430
+ );
2431
+ lastEl.rules.elements.forEach((rule) => {
2432
+ if (rule.array && !(rule.property in lastEl.element)) {
2433
+ if (rule.useEmptyArrays) {
2434
+ lastEl.element[rule.property] = [];
2435
+ }
2436
+ }
2437
+ });
2438
+ this.validate(lastEl);
2439
+ }
2440
+ endDocument() {
2441
+ this.busy = false;
2442
+ const last2 = this.stack.pop();
2443
+ this.validate(last2);
2444
+ return last2.element;
2445
+ }
2446
+ validate(current) {
2447
+ if (!this.options.validateRules) return;
2448
+ current.rules.elements.forEach((rule) => {
2449
+ var _a2, _b;
2450
+ const length = rule.array ? (_b = (_a2 = current.element[rule.property]) == null ? void 0 : _a2.length) != null ? _b : 0 : current.element[rule.property] ? 1 : 0;
2451
+ if (length < rule.minOccurs) {
2452
+ throw new XmlSchemaError(
2453
+ substitute(xmlSchemaErrorLocale.atLeastElements, {
2454
+ property: rule.property,
2455
+ expected: rule.minOccurs,
2456
+ actual: length
2457
+ })
2458
+ );
2459
+ }
2460
+ if (rule.maxOccurs != null && length > rule.maxOccurs) {
2461
+ throw new XmlSchemaError(
2462
+ substitute(xmlSchemaErrorLocale.atMostElements, {
2463
+ property: rule.property,
2464
+ expected: rule.maxOccurs,
2465
+ actual: length
2466
+ })
2467
+ );
2468
+ }
2469
+ });
2470
+ }
2471
+ };
2472
+ var parentSymbol = /* @__PURE__ */ Symbol("parent");
2473
+ var _a;
2474
+ _a = parentSymbol;
2475
+ var _XmlElementImpl = class _XmlElementImpl {
2476
+ constructor(parent = null) {
2477
+ __publicField(this, _a);
2478
+ this[parentSymbol] = parent;
2479
+ }
2480
+ get parent() {
2481
+ return this[parentSymbol];
2482
+ }
2483
+ set parent(value) {
2484
+ this[parentSymbol] = value;
2485
+ }
2486
+ clone() {
2487
+ const out = new _XmlElementImpl(this.parent);
2488
+ for (const key in this) {
2489
+ const child = clone(this[key]);
2490
+ if (Array.isArray(child)) {
2491
+ for (const e of child) {
2492
+ if (typeof e === "object" && "parent" in e) e.parent = out;
2493
+ }
2494
+ } else if (typeof child === "object" && "parent" in child) {
2495
+ child.parent = out;
2496
+ }
2497
+ out[key] = child;
3229
2498
  }
3230
- if (name.prefix === "xmlns") {
3231
- name.namespaceUri = XMLNS;
3232
- stackElement.namespaceMap.set(
3233
- name.localPart,
3234
- value === "" ? null : value
3235
- );
3236
- } else if (!name.prefix && name.localPart === "xmlns") {
3237
- name.namespaceUri = XMLNS;
3238
- stackElement.defaultNamespaceUri = !value ? null : value;
2499
+ return out;
2500
+ }
2501
+ toJSON() {
2502
+ const out = {};
2503
+ for (const key in this) {
2504
+ out[key] = toJson(this[key]);
3239
2505
  }
3240
- if (attributes[name.qName] != null)
3241
- reader.err(`Attribute '${name.qName}' is already specified.`);
3242
- attributes[name.qName] = { name, value };
2506
+ return out;
3243
2507
  }
3244
- return attributes;
3245
- }
3246
- var locale23 = {
3247
- illegalRuleOverrideTypeError: "Cannot override the rule {property} of type {sourceType} with a rule of type {overrideType}",
3248
- illegalQNameOverrideError: "Cannot override the rule {property} with a different localPart or namespace"
3249
2508
  };
3250
- function mergeXmlRules(...rules) {
3251
- let finalRule = rules[0];
3252
- for (let i = 1; i < rules.length; i++) {
3253
- finalRule = plainObjectMergeRule.merge(
3254
- finalRule,
3255
- rules[i],
3256
- mergeXmlRule
3257
- );
3258
- }
3259
- return finalRule;
2509
+ var XmlElementImpl = _XmlElementImpl;
2510
+
2511
+ // ../vinyl-validation/src/validation/Validator.ts
2512
+ var validatorLocale = {
2513
+ /**
2514
+ * The expectation template string with the following replacement tokens:
2515
+ *
2516
+ * `{expected}` - The expected description.
2517
+ * `{actual}` - The actual value.
2518
+ * `{path}` - The path, dot separated.
2519
+ */
2520
+ template: "Expected: {expected}, but was: {actual}. At: {path}"
2521
+ };
2522
+ function createValidationExpectationMessage(expectationMessage, input, path, inputStringify = (input2) => stringifyForPrint(input2, 500)) {
2523
+ return substitute(validatorLocale.template, {
2524
+ expected: expectationMessage,
2525
+ actual: inputStringify(input),
2526
+ path: path.join(".")
2527
+ });
3260
2528
  }
3261
- function mergeXmlRule(sourceA, sourceB, prop) {
3262
- var _a2, _b, _c, _d;
3263
- if (sourceA == null) return sourceB;
3264
- const sourceAIsLazy = typeof sourceA === "function";
3265
- const sourceBIsLazy = typeof sourceB === "function";
3266
- if (sourceAIsLazy || sourceBIsLazy) {
3267
- return () => {
3268
- const a = sourceAIsLazy ? sourceA() : sourceA;
3269
- const b = sourceBIsLazy ? sourceB() : sourceB;
3270
- return mergeXmlRule(a, b, prop);
3271
- };
3272
- }
3273
- if (sourceA.type !== sourceB.type) {
3274
- throw new ValidationError(
3275
- substitute(locale23.illegalRuleOverrideTypeError, {
3276
- property: prop,
3277
- sourceType: sourceA.type,
3278
- overrideType: sourceB.type
3279
- })
3280
- );
3281
- }
3282
- switch (sourceA.type) {
3283
- case "attribute":
3284
- case "element":
3285
- case "elements": {
3286
- const b = sourceB;
3287
- if (sourceA.namespaceUri !== b.namespaceUri || ((_a2 = sourceA.localPart) != null ? _a2 : prop) !== ((_b = b.localPart) != null ? _b : prop)) {
2529
+ function createValidator(expectationMessage, isValid, inputStringify = (input) => stringifyForPrint(input, 500)) {
2530
+ return {
2531
+ description: expectationMessage,
2532
+ isValid(input) {
2533
+ return isValid(input);
2534
+ },
2535
+ validate(input, _, path = []) {
2536
+ if (!isValid(input)) {
2537
+ return [
2538
+ {
2539
+ message: createValidationExpectationMessage(
2540
+ expectationMessage,
2541
+ input,
2542
+ path,
2543
+ inputStringify
2544
+ ),
2545
+ path
2546
+ }
2547
+ ];
2548
+ }
2549
+ return [];
2550
+ },
2551
+ assert: (input, origin, path = []) => {
2552
+ if (!isValid(input)) {
3288
2553
  throw new ValidationError(
3289
- substitute(locale23.illegalQNameOverrideError, {
3290
- property: prop
3291
- })
2554
+ createValidationExpectationMessage(
2555
+ expectationMessage,
2556
+ input,
2557
+ path,
2558
+ inputStringify
2559
+ ),
2560
+ origin,
2561
+ path
3292
2562
  );
3293
2563
  }
3294
- break;
3295
- }
3296
- }
3297
- switch (sourceA.type) {
3298
- case "attribute": {
3299
- const b = sourceB;
3300
- return __spreadProps4(__spreadValues5({}, b), {
3301
- default: (_c = b.default) != null ? _c : sourceA.default
3302
- });
3303
- }
3304
- case "characters":
3305
- return sourceB;
3306
- case "element": {
3307
- const b = sourceB;
3308
- return __spreadProps4(__spreadValues5({}, b), {
3309
- required: sourceA.required || b.required,
3310
- rules: mergeXmlRules(sourceA.rules, b.rules)
3311
- });
3312
2564
  }
3313
- case "elements": {
3314
- const b = sourceB;
3315
- const maxOccurs = sourceA.maxOccurs != null && b.maxOccurs != null ? Math.min(sourceA.maxOccurs, b.maxOccurs) : (_d = sourceA.maxOccurs) != null ? _d : b.maxOccurs;
3316
- return __spreadProps4(__spreadValues5({}, b), {
3317
- minOccurs: Math.max(sourceA.minOccurs, b.minOccurs),
3318
- maxOccurs,
3319
- useEmptyArrays: sourceA.useEmptyArrays || b.useEmptyArrays,
3320
- rules: mergeXmlRules(sourceA.rules, b.rules)
3321
- });
2565
+ };
2566
+ }
2567
+ function createDeepValidator(description, validate) {
2568
+ return {
2569
+ description,
2570
+ isValid(input) {
2571
+ return validate(input, { all: false }, []).length === 0;
2572
+ },
2573
+ validate(input, options, path = []) {
2574
+ return validate(input, options != null ? options : { all: false }, path);
2575
+ },
2576
+ assert: (input, origin, path = []) => {
2577
+ const errors = validate(input, { all: false }, path);
2578
+ if (errors.length) {
2579
+ const error = errors[0];
2580
+ throw new ValidationError(error.message, origin, error.path);
2581
+ }
3322
2582
  }
3323
- }
2583
+ };
3324
2584
  }
3325
- var EmptyRules = {
3326
- __type: /* @__PURE__ */ invariant(),
3327
- attributes: /* @__PURE__ */ new Map(),
3328
- elements: /* @__PURE__ */ new Map(),
3329
- characters: void 0
2585
+
2586
+ // ../vinyl-validation/src/validation/andValidators.ts
2587
+ var locale6 = {
2588
+ /**
2589
+ * {value} The child validators' descriptions, joined with `separator`.
2590
+ *
2591
+ * groupings of and validators is unimportant,
2592
+ * and(and(a, b), c) is the same as and(a, and(b, c)), so `a & b & c` is an accurate
2593
+ * representation for either.
2594
+ */
2595
+ template: "{value}",
2596
+ /**
2597
+ * The separator with which to join child validator descriptions.
2598
+ */
2599
+ separator: " & "
3330
2600
  };
3331
- function mapXmlRules(rules, parentNamespaceUri = null) {
3332
- var _a2, _b, _c;
3333
- const attributeRules = /* @__PURE__ */ new Map();
3334
- const elementRules = /* @__PURE__ */ new Map();
3335
- let charactersRule = void 0;
3336
- for (const property in rules) {
3337
- const handlerOrFunction = rules[property];
3338
- let handler;
3339
- if (typeof handlerOrFunction === "function") {
3340
- handler = handlerOrFunction();
3341
- } else {
3342
- handler = handlerOrFunction;
2601
+ function andValidators(...validators) {
2602
+ return createDeepValidator(
2603
+ substitute(locale6.template, {
2604
+ value: validators.map((v) => v.description).join(locale6.separator)
2605
+ }),
2606
+ (input, options, path) => {
2607
+ for (const validator of validators) {
2608
+ const errors = validator.validate(input, options, path);
2609
+ if (errors.length) return errors;
2610
+ }
2611
+ return [];
3343
2612
  }
3344
- let key;
3345
- switch (handler.type) {
3346
- case "characters":
3347
- if (charactersRule !== void 0)
3348
- throw new IllegalArgumentError(
3349
- "characters handler already defined"
3350
- );
3351
- charactersRule = {
3352
- property,
3353
- parse: handler.parse,
3354
- stringify: handler.stringify
3355
- };
3356
- break;
3357
- case "element":
3358
- case "elements": {
3359
- const localPart = (_a2 = handler.localPart) != null ? _a2 : property;
3360
- const namespaceUri = handler.namespaceUri === void 0 ? parentNamespaceUri : handler.namespaceUri;
3361
- key = xmlRuleKey(localPart, namespaceUri);
3362
- if (elementRules.has(key)) {
3363
- throw new IllegalArgumentError(
3364
- `Multiple element rules for ${key}`
3365
- );
3366
- }
3367
- if (handler.type === "element") {
3368
- const rules2 = handler.rules;
3369
- elementRules.set(key, {
3370
- array: false,
3371
- property,
3372
- minOccurs: handler.required ? 1 : 0,
3373
- maxOccurs: 1,
3374
- rules: memoize(() => mapXmlRules(rules2, namespaceUri)),
3375
- useEmptyArrays: false,
3376
- localPart,
3377
- namespaceUri
3378
- });
3379
- } else {
3380
- const rules2 = handler.rules;
3381
- elementRules.set(key, {
3382
- array: true,
3383
- property,
3384
- maxOccurs: handler.maxOccurs,
3385
- minOccurs: handler.minOccurs,
3386
- rules: memoize(() => mapXmlRules(rules2, namespaceUri)),
3387
- useEmptyArrays: handler.useEmptyArrays,
3388
- localPart,
3389
- namespaceUri
3390
- });
3391
- }
3392
- break;
2613
+ );
2614
+ }
2615
+
2616
+ // ../vinyl-validation/src/validation/orValidators.ts
2617
+ var locale7 = {
2618
+ /**
2619
+ * {value} - The child validators' descriptions, joined with `separator`.
2620
+ */
2621
+ template: "({value})",
2622
+ /**
2623
+ * The separator with which to join child validator descriptions.
2624
+ */
2625
+ separator: " | "
2626
+ };
2627
+ function orValidators(...validators) {
2628
+ const description = substitute(locale7.template, {
2629
+ value: validators.map((v) => v.description).join(locale7.separator)
2630
+ });
2631
+ return createDeepValidator(description, (input, options, path) => {
2632
+ let longestErrors = [];
2633
+ let longestPath = 0;
2634
+ for (const validator of validators) {
2635
+ const errors = validator.validate(input, options, path);
2636
+ if (!errors.length) return errors;
2637
+ const pathLength = errors.reduce(
2638
+ (max, m) => Math.max(m.path.length, max),
2639
+ 0
2640
+ );
2641
+ if (pathLength >= longestPath) {
2642
+ longestErrors = errors;
2643
+ longestPath = pathLength;
3393
2644
  }
3394
- case "attribute": {
3395
- const namespaceUri = handler.namespaceUri;
3396
- const localPart = (_b = handler.localPart) != null ? _b : property;
3397
- key = xmlRuleKey(localPart, namespaceUri);
3398
- if (attributeRules.has(key)) {
3399
- throw new IllegalArgumentError(
3400
- `Multiple attribute rules for ${key}`
3401
- );
3402
- }
3403
- attributeRules.set(key, {
3404
- property,
3405
- default: handler.default,
3406
- parse: handler.parse,
3407
- stringify: handler.stringify,
3408
- required: handler.required,
3409
- localPart,
3410
- namespaceUri: (_c = handler.namespaceUri) != null ? _c : null
3411
- });
3412
- break;
2645
+ }
2646
+ return longestPath > path.length ? longestErrors : [
2647
+ {
2648
+ message: createValidationExpectationMessage(
2649
+ description,
2650
+ input,
2651
+ path
2652
+ ),
2653
+ path
3413
2654
  }
2655
+ ];
2656
+ });
2657
+ }
2658
+
2659
+ // ../vinyl-validation/src/validation/SchemaBase.ts
2660
+ var requiredValidationOptions = {
2661
+ optional: false
2662
+ };
2663
+ var SchemaBase = class {
2664
+ constructor(currentValidator, previousSchema, operation) {
2665
+ __publicField(this, "currentValidator", currentValidator);
2666
+ __publicField(this, "previousSchema", previousSchema);
2667
+ __publicField(this, "operation", operation);
2668
+ __publicField(this, "__type", invariant());
2669
+ __publicField(this, "validator");
2670
+ __publicField(this, "_options", requiredValidationOptions);
2671
+ __publicField(this, "assert", (input, origin, path) => {
2672
+ this.validator.assert(input, origin, path);
2673
+ });
2674
+ __publicField(this, "isValid", (input) => this.validator.isValid(input));
2675
+ __publicField(this, "validate", (input, options, path) => this.validator.validate(input, options, path));
2676
+ this.validator = operation == null ? currentValidator : operation(previousSchema, currentValidator);
2677
+ }
2678
+ get options() {
2679
+ return this._options;
2680
+ }
2681
+ get description() {
2682
+ return this.validator.description;
2683
+ }
2684
+ /**
2685
+ * Clones this schema, transforming all validators with the given mutator.
2686
+ *
2687
+ * @param transform A transformer which takes an existing validator in the chain and returns
2688
+ * a new one. Validators should be considered to be immutable; transform should not change the
2689
+ * input but instead return a new validator.
2690
+ */
2691
+ clone(transform = (v) => v) {
2692
+ const cloned = this.operation ? this.self(
2693
+ transform(this.currentValidator),
2694
+ this.previousSchema.clone(transform),
2695
+ this.operation
2696
+ ) : this.self(transform(this.currentValidator));
2697
+ cloned._options = this._options;
2698
+ return cloned;
2699
+ }
2700
+ self(current, previous, operation) {
2701
+ if (this.constructor.length > 3) {
2702
+ throw new IllegalArgumentError(
2703
+ "constructor should have at most three required arguments"
2704
+ );
3414
2705
  }
2706
+ return new this.constructor(current, previous, operation);
3415
2707
  }
3416
- return {
3417
- __type: invariant(),
3418
- attributes: attributeRules,
3419
- elements: elementRules,
3420
- characters: charactersRule
3421
- };
3422
- }
3423
- function xmlRuleKey(localPart, namespaceUri = null) {
3424
- return `${namespaceUri != null ? namespaceUri : ""}:${localPart}`;
3425
- }
3426
- function getRule(name, rules) {
3427
- return rules.get(xmlRuleKey(name.localPart, name.namespaceUri));
3428
- }
3429
- var ParseXmlHandlerImpl = class {
3430
- constructor(rules, options) {
3431
- this.rules = rules;
3432
- __publicField4(this, "stack", []);
3433
- __publicField4(this, "options");
3434
- __publicField4(this, "busy", false);
3435
- this.options = __spreadValues5({ validateRules: true }, options);
2708
+ /**
2709
+ * Constructs a new schema with a validator chaining the current validator with the
2710
+ * provided next in an AND operation.
2711
+ *
2712
+ * @param nextValidator The validator to run after the current.
2713
+ * @return Returns a new Schema instance the same class with a new validator chaining the
2714
+ * current validator with the given next in an AND operation.
2715
+ */
2716
+ chain(nextValidator) {
2717
+ return this.self(nextValidator, this, andValidators);
3436
2718
  }
3437
- startDocument() {
3438
- if (this.busy)
3439
- throw new IllegalStateError("XML content handler is busy");
3440
- this.busy = true;
3441
- const rules = this.rules;
3442
- this.stack.push({
3443
- element: new XmlElementImpl(),
3444
- rules,
3445
- characters: ""
2719
+ optional() {
2720
+ const cloned = this.clone();
2721
+ cloned._options = __spreadProps(__spreadValues({}, cloned.options), {
2722
+ optional: true
3446
2723
  });
2724
+ return cloned;
3447
2725
  }
3448
- startElement(name, attributes) {
3449
- var _a2;
3450
- const parent = last(this.stack);
3451
- let element2 = null;
3452
- const elementRule = getRule(name, parent.rules.elements);
3453
- const rules = (_a2 = elementRule == null ? void 0 : elementRule.rules()) != null ? _a2 : EmptyRules;
3454
- if (elementRule) {
3455
- const prop = elementRule.property;
3456
- element2 = new XmlElementImpl(parent.element);
3457
- if (elementRule.array) {
3458
- const arr = parent.element[prop];
3459
- if (Array.isArray(arr)) {
3460
- arr.push(element2);
3461
- } else {
3462
- parent.element[prop] = [element2];
3463
- }
3464
- } else {
3465
- if (parent.element[prop]) {
3466
- throw new XmlSchemaError(
3467
- `Expected single element with name ${name.qName}`
3468
- );
3469
- } else {
3470
- parent.element[prop] = element2;
3471
- }
3472
- }
3473
- const attributeRules = rules.attributes;
3474
- for (const k in attributes) {
3475
- const attribute = attributes[k];
3476
- const name2 = attribute.name;
3477
- const attributeRule = getRule(name2, attributeRules);
3478
- if (attributeRule) {
3479
- element2[attributeRule.property] = attributeRule.parse(
3480
- attribute.value
3481
- );
3482
- }
3483
- }
3484
- attributeRules.forEach((_value, key) => {
3485
- const rule = attributeRules.get(key);
3486
- if (!(rule.property in element2)) {
3487
- if (rule.default != null) {
3488
- element2[rule.property] = rule.default;
3489
- } else if (this.options.validateRules && rule.required) {
3490
- throw new XmlSchemaError(
3491
- substitute(xmlSchemaErrorLocale.requiredAttribute, {
3492
- property: rule.property
3493
- })
3494
- );
3495
- }
3496
- }
3497
- });
3498
- }
3499
- this.stack.push({
3500
- element: element2,
3501
- rules,
3502
- characters: ""
2726
+ required() {
2727
+ const cloned = this.clone();
2728
+ cloned._options = __spreadProps(__spreadValues({}, cloned.options), {
2729
+ optional: false
3503
2730
  });
2731
+ return cloned;
2732
+ }
2733
+ };
2734
+
2735
+ // ../vinyl-validation/src/validation/ValueSchema.ts
2736
+ var locale8 = {
2737
+ null: "null",
2738
+ nullish: "nullish",
2739
+ undefined: "undefined"
2740
+ };
2741
+ var valueValidators = {
2742
+ any() {
2743
+ return createValidator("", () => true);
2744
+ },
2745
+ /**
2746
+ * Creates a validator that asserts that the input is nullish.
2747
+ */
2748
+ nullish() {
2749
+ return createValidator(locale8.nullish, (input) => input == null);
2750
+ },
2751
+ /**
2752
+ * Creates a validator that asserts that the input is strictly null.
2753
+ */
2754
+ null() {
2755
+ return createValidator(locale8.null, (input) => input === null);
2756
+ },
2757
+ /**
2758
+ * Creates a validator that asserts that the input is strictly undefined.
2759
+ */
2760
+ undefined() {
2761
+ return createValidator(locale8.undefined, (input) => input === void 0);
2762
+ }
2763
+ };
2764
+ var ValueSchema = class _ValueSchema extends SchemaBase {
2765
+ /**
2766
+ * Prepends this validator allowing for null or undefined.
2767
+ */
2768
+ maybe() {
2769
+ return this.or(valueValidators.nullish());
2770
+ }
2771
+ /**
2772
+ * Prepends this validator allowing for null.
2773
+ */
2774
+ orNull() {
2775
+ return this.or(valueValidators.null());
2776
+ }
2777
+ /**
2778
+ * Prepends this validator allowing for undefined.
2779
+ */
2780
+ orUndefined() {
2781
+ return this.or(valueValidators.undefined());
2782
+ }
2783
+ /**
2784
+ * Returns a validator that asserts if this validator and the next passes.
2785
+ *
2786
+ * @see andValidators
2787
+ *
2788
+ * @param nextValidator The validator to run after the current.
2789
+ * @return Returns a new ValueSchema intersecting this validator and the next.
2790
+ */
2791
+ and(nextValidator) {
2792
+ return new _ValueSchema(nextValidator, this, andValidators);
2793
+ }
2794
+ /**
2795
+ * Returns a validator that asserts if this validator or the next passes.
2796
+ *
2797
+ * Implementation note:
2798
+ * subclasses should not change the schema instance returned unless all chainable validators
2799
+ * accept input type 'unknown'.
2800
+ *
2801
+ * @param nextValidator The validator to run after the current.
2802
+ * @return Returns a new ValueSchema providing the union of this validator and the next.
2803
+ */
2804
+ or(nextValidator) {
2805
+ return new _ValueSchema(nextValidator, this, orValidators);
2806
+ }
2807
+ };
2808
+
2809
+ // ../vinyl-validation/src/validation/typeOfValidators.ts
2810
+ var locale9 = {
2811
+ template: "type {value}"
2812
+ };
2813
+ function typeOfValidator(expected) {
2814
+ return createValidator(
2815
+ substitute(locale9.template, { value: expected }),
2816
+ (input) => {
2817
+ return input != null && typeof input === expected;
2818
+ }
2819
+ );
2820
+ }
2821
+ var typeOfValidatorCache = {};
2822
+ function cachedTypeOfValidator(type) {
2823
+ if (!(type in typeOfValidatorCache)) {
2824
+ typeOfValidatorCache[type] = typeOfValidator(type);
3504
2825
  }
3505
- textNode(str) {
3506
- const current = last(this.stack);
3507
- if (!current.rules.characters) return;
3508
- current.characters += decodeEntities(str.trim());
2826
+ return typeOfValidatorCache[type];
2827
+ }
2828
+ var typeOfValidators = {
2829
+ get boolean() {
2830
+ return cachedTypeOfValidator("boolean");
2831
+ },
2832
+ get func() {
2833
+ return cachedTypeOfValidator("function");
2834
+ },
2835
+ get number() {
2836
+ return cachedTypeOfValidator("number");
2837
+ },
2838
+ get object() {
2839
+ return cachedTypeOfValidator("object");
2840
+ },
2841
+ get string() {
2842
+ return cachedTypeOfValidator("string");
2843
+ },
2844
+ get symbol() {
2845
+ return cachedTypeOfValidator("symbol");
3509
2846
  }
3510
- cDataNode(str) {
3511
- const current = last(this.stack);
3512
- if (!current.rules.characters) return;
3513
- current.characters += str;
2847
+ };
2848
+
2849
+ // ../vinyl-validation/src/validation/NumberSchema.ts
2850
+ var locale10 = {
2851
+ gte: "at least {value}",
2852
+ gt: "greater than {value}",
2853
+ lte: "at most {value}",
2854
+ lt: "less than {value}",
2855
+ within: "within {min} and {max}",
2856
+ safeInteger: "safe integer",
2857
+ finite: "finite"
2858
+ };
2859
+ var numberValidators = {
2860
+ /**
2861
+ * Creates a validator that asserts that the input number is at least the provided minimum
2862
+ * value.
2863
+ *
2864
+ * @param min The minimum (inclusive) the value may be.
2865
+ */
2866
+ gte(min) {
2867
+ return createValidator(
2868
+ substitute(locale10.gte, { value: min }),
2869
+ (input) => input >= min
2870
+ );
2871
+ },
2872
+ /**
2873
+ * Creates a validator that asserts that the input number is greater than the provided minimum
2874
+ * value.
2875
+ *
2876
+ * @param min The minimum (exclusive) the value may be.
2877
+ */
2878
+ gt(min) {
2879
+ return createValidator(
2880
+ substitute(locale10.gt, { value: min }),
2881
+ (input) => input > min
2882
+ );
2883
+ },
2884
+ /**
2885
+ * Creates a validator that asserts that the input number is at most the provided maximum
2886
+ * value.
2887
+ *
2888
+ * @param max The maximum (inclusive) the value may be.
2889
+ */
2890
+ lte(max) {
2891
+ return createValidator(
2892
+ substitute(locale10.lte, { value: max }),
2893
+ (input) => input <= max
2894
+ );
2895
+ },
2896
+ /**
2897
+ * Creates a validator that asserts that the input number is less than the provided maximum
2898
+ * value.
2899
+ *
2900
+ * @param max The maximum (exclusive) the value may be.
2901
+ */
2902
+ lt(max) {
2903
+ return createValidator(
2904
+ substitute(locale10.lt, { value: max }),
2905
+ (input) => input < max
2906
+ );
2907
+ },
2908
+ /**
2909
+ * Creates a validator that asserts that the input number is at least the provided minimum
2910
+ * and at most the provided maximum values.
2911
+ *
2912
+ * @param min The minimum (inclusive) value the input may be.
2913
+ * @param max The maximum (inclusive) value the input may be.
2914
+ */
2915
+ within(min, max) {
2916
+ return createValidator(
2917
+ substitute(locale10.within, { min, max }),
2918
+ (input) => input >= min && input <= max
2919
+ );
2920
+ },
2921
+ /**
2922
+ * Creates a validator that asserts that the input number is finite.
2923
+ */
2924
+ finite() {
2925
+ return createValidator(locale10.finite, (input) => Number.isFinite(input));
2926
+ },
2927
+ /**
2928
+ * Creates a validator that asserts that the input number is a safe integer.
2929
+ */
2930
+ safeInteger() {
2931
+ return createValidator(
2932
+ locale10.safeInteger,
2933
+ (input) => Number.isSafeInteger(input)
2934
+ );
3514
2935
  }
3515
- endElement() {
3516
- const lastEl = this.stack.pop();
3517
- const charactersRule = lastEl.rules.characters;
3518
- if (charactersRule)
3519
- lastEl.element[charactersRule.property] = charactersRule.parse(
3520
- lastEl.characters
3521
- );
3522
- lastEl.rules.elements.forEach((rule) => {
3523
- if (rule.array && !(rule.property in lastEl.element)) {
3524
- if (rule.useEmptyArrays) {
3525
- lastEl.element[rule.property] = [];
3526
- }
3527
- }
3528
- });
3529
- this.validate(lastEl);
2936
+ };
2937
+ var _NumberSchema = class _NumberSchema extends ValueSchema {
2938
+ /**
2939
+ * The base Object validator validating that the input is an object.
2940
+ */
2941
+ static get base() {
2942
+ if (this._base == null)
2943
+ this._base = new _NumberSchema(typeOfValidators.number);
2944
+ return this._base;
3530
2945
  }
3531
- endDocument() {
3532
- this.busy = false;
3533
- const last3 = this.stack.pop();
3534
- this.validate(last3);
3535
- return last3.element;
2946
+ /**
2947
+ * Creates a validator that asserts that the input number is at least the provided minimum
2948
+ * value.
2949
+ *
2950
+ * @param min The minimum (inclusive) the value may be.
2951
+ */
2952
+ gte(min) {
2953
+ return this.chain(numberValidators.gte(min));
3536
2954
  }
3537
- validate(current) {
3538
- if (!this.options.validateRules) return;
3539
- current.rules.elements.forEach((rule) => {
3540
- var _a2, _b;
3541
- const length = rule.array ? (_b = (_a2 = current.element[rule.property]) == null ? void 0 : _a2.length) != null ? _b : 0 : current.element[rule.property] ? 1 : 0;
3542
- if (length < rule.minOccurs) {
3543
- throw new XmlSchemaError(
3544
- substitute(xmlSchemaErrorLocale.atLeastElements, {
3545
- property: rule.property,
3546
- expected: rule.minOccurs,
3547
- actual: length
3548
- })
3549
- );
3550
- }
3551
- if (rule.maxOccurs != null && length > rule.maxOccurs) {
3552
- throw new XmlSchemaError(
3553
- substitute(xmlSchemaErrorLocale.atMostElements, {
3554
- property: rule.property,
3555
- expected: rule.maxOccurs,
3556
- actual: length
3557
- })
3558
- );
3559
- }
3560
- });
2955
+ /**
2956
+ * Creates a validator that asserts that the input number is greater than the provided minimum
2957
+ * value.
2958
+ *
2959
+ * @param min The minimum (exclusive) the value may be.
2960
+ */
2961
+ gt(min) {
2962
+ return this.chain(numberValidators.gt(min));
3561
2963
  }
3562
- };
3563
- var parentSymbol = /* @__PURE__ */ Symbol("parent");
3564
- var _a;
3565
- _a = parentSymbol;
3566
- var _XmlElementImpl = class _XmlElementImpl2 {
3567
- constructor(parent = null) {
3568
- __publicField4(this, _a);
3569
- this[parentSymbol] = parent;
2964
+ /**
2965
+ * Creates a validator that asserts that the input number is at most the provided maximum
2966
+ * value.
2967
+ *
2968
+ * @param max The maximum (inclusive) the value may be.
2969
+ */
2970
+ lte(max) {
2971
+ return this.chain(numberValidators.lte(max));
3570
2972
  }
3571
- get parent() {
3572
- return this[parentSymbol];
2973
+ /**
2974
+ * Creates a validator that asserts that the input number is less than the provided maximum
2975
+ * value.
2976
+ *
2977
+ * @param max The maximum (exclusive) the value may be.
2978
+ */
2979
+ lt(max) {
2980
+ return this.chain(numberValidators.lt(max));
3573
2981
  }
3574
- set parent(value) {
3575
- this[parentSymbol] = value;
2982
+ /**
2983
+ * Creates a validator that asserts that the input number is at least the provided minimum
2984
+ * and at most the provided maximum values.
2985
+ *
2986
+ * @param min The minimum (inclusive) value the input may be.
2987
+ * @param max The maximum (inclusive) value the input may be.
2988
+ */
2989
+ within(min, max) {
2990
+ return this.chain(numberValidators.within(min, max));
3576
2991
  }
3577
- clone() {
3578
- const out = new _XmlElementImpl2(this.parent);
3579
- for (const key in this) {
3580
- const child = clone(this[key]);
3581
- if (Array.isArray(child)) {
3582
- for (const e of child) {
3583
- if (typeof e === "object" && "parent" in e) e.parent = out;
3584
- }
3585
- } else if (typeof child === "object" && "parent" in child) {
3586
- child.parent = out;
3587
- }
3588
- out[key] = child;
3589
- }
3590
- return out;
2992
+ /**
2993
+ * Creates a validator that asserts that the input number is finite.
2994
+ */
2995
+ finite() {
2996
+ return this.chain(numberValidators.finite());
3591
2997
  }
3592
- toJSON() {
3593
- const out = {};
3594
- for (const key in this) {
3595
- out[key] = toJson(this[key]);
3596
- }
3597
- return out;
2998
+ /**
2999
+ * Creates a validator that asserts that the input number is a safe integer.
3000
+ */
3001
+ safeInteger() {
3002
+ return this.chain(numberValidators.safeInteger());
3598
3003
  }
3599
3004
  };
3600
- var XmlElementImpl = _XmlElementImpl;
3601
- var actuateValidator = /* @__PURE__ */ isOneOf("onLoad", "onRequest");
3005
+ __publicField(_NumberSchema, "_base", null);
3006
+ var NumberSchema = _NumberSchema;
3007
+
3008
+ // ../vinyl-validation/src/validation/validators.ts
3009
+ var locale11 = {
3010
+ isOneOf: "one of: {value}",
3011
+ instanceOf: "instance of {value}",
3012
+ oneOfSeparator: " | "
3013
+ };
3014
+ function isOneOf(...possibleValues) {
3015
+ return new ValueSchema(
3016
+ createValidator(
3017
+ substitute(locale11.isOneOf, {
3018
+ value: possibleValues.join(locale11.oneOfSeparator)
3019
+ }),
3020
+ (input) => possibleValues.includes(input)
3021
+ )
3022
+ );
3023
+ }
3024
+ function number() {
3025
+ return NumberSchema.base;
3026
+ }
3027
+
3028
+ // ../vinyl-xml/src/xlink/actuateValidator.ts
3029
+ var actuateValidator = isOneOf("onLoad", "onRequest");
3602
3030
  function assertActuateEnum(str) {
3603
3031
  actuateValidator.assert(str, ErrorOrigin.PARSING);
3604
3032
  return str;