@amazon/vinyl-mpd-parser 3.2.2 → 3.2.3-next.20261001143710

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.
@@ -603,7 +603,8 @@
603
603
  return true;
604
604
  }
605
605
  /**
606
- * Executes a provided function once per each key/value pair in the Map, in insertion order.
606
+ * Executes a provided function once per each key/value pair in the Map,
607
+ * ordered from least recently used to most.
607
608
  *
608
609
  * @param callback A callback to invoke for every element in the cache.
609
610
  * @param thisArg Value to use as this when executing callback
@@ -648,8 +649,8 @@
648
649
  let value = void 0;
649
650
  const memoized = () => {
650
651
  if (!cached) {
651
- cached = true;
652
652
  value = inner();
653
+ cached = true;
653
654
  }
654
655
  return value;
655
656
  };
@@ -678,9 +679,9 @@
678
679
  const memoized = (...args) => {
679
680
  const key = keyProvider(...args);
680
681
  if (!hasValue || cachedKey !== key) {
681
- hasValue = true;
682
- cachedKey = key;
683
682
  cachedValue = inner(...args);
683
+ cachedKey = key;
684
+ hasValue = true;
684
685
  }
685
686
  return cachedValue;
686
687
  };
@@ -730,7 +731,8 @@
730
731
  charCode === 13 || // '\r' (carriage return)
731
732
  charCode === 10;
732
733
  }
733
- var encodedEntitiesRegex = /&(#(\d+)|\w+);/gi;
734
+ var encodedEntitiesRegex = /&(?:#(?:x([\da-f]+)|(\d+))|(\w+));/gi;
735
+ var MAX_CODE_POINT = 1114111;
734
736
  var predefinedDecodeEntities = /* @__PURE__ */ new Map([
735
737
  ["apos", "'"],
736
738
  ["amp", "&"],
@@ -739,20 +741,22 @@
739
741
  ["quot", '"']
740
742
  ]);
741
743
  function decodeEntities(str, namedEntities = predefinedDecodeEntities) {
742
- if (encodedEntitiesRegex.test(str)) {
743
- return str.replace(
744
- encodedEntitiesRegex,
745
- (substring, entityName, codePoint) => {
746
- if (codePoint !== void 0)
747
- return String.fromCharCode(parseInt(codePoint));
748
- const entityValue = namedEntities.get(entityName.toLowerCase());
749
- if (!entityValue) return substring;
750
- return entityValue;
744
+ return str.replace(
745
+ encodedEntitiesRegex,
746
+ (substring, hex, decimal, entityName) => {
747
+ var _a2;
748
+ if (hex == null && decimal == null) {
749
+ return (_a2 = namedEntities.get(entityName.toLowerCase())) != null ? _a2 : substring;
751
750
  }
752
- );
753
- } else {
754
- return str;
755
- }
751
+ const codePoint = hex != null ? parseInt(hex, 16) : parseInt(decimal, 10);
752
+ if (codePoint > MAX_CODE_POINT || isSurrogate(codePoint))
753
+ return substring;
754
+ return String.fromCodePoint(codePoint);
755
+ }
756
+ );
757
+ }
758
+ function isSurrogate(codePoint) {
759
+ return codePoint >= 55296 && codePoint <= 57343;
756
760
  }
757
761
  var standardEntityValueToNames = flipMap(predefinedDecodeEntities);
758
762
  function eqStr(a, b, ignoreCase = false) {
@@ -1481,20 +1485,21 @@
1481
1485
  let abs = Math.abs(value);
1482
1486
  const years = Math.floor(abs / Y);
1483
1487
  abs -= years * Y;
1484
- const months = Math.floor(abs % Y / M);
1488
+ const months = Math.floor(abs / M);
1485
1489
  const days = Math.floor(abs % M / D);
1486
1490
  const hours = Math.floor(abs % D / H);
1487
1491
  const minutes = Math.floor(abs % H / I);
1488
1492
  const seconds = abs % I;
1489
- let isoString = `${sign}P`;
1490
- if (years > 0) isoString += `${years}Y`;
1491
- if (months > 0) isoString += `${months}M`;
1492
- if (days > 0) isoString += `${days}D`;
1493
- isoString += "T";
1494
- if (hours > 0) isoString += `${hours}H`;
1495
- if (minutes > 0) isoString += `${minutes}M`;
1496
- if (seconds > 0 || !value) isoString += `${roundToNearest(seconds, 1e-3)}S`;
1497
- return isoString;
1493
+ let date = "";
1494
+ if (years > 0) date += `${years}Y`;
1495
+ if (months > 0) date += `${months}M`;
1496
+ if (days > 0) date += `${days}D`;
1497
+ let time = "";
1498
+ if (hours > 0) time += `${hours}H`;
1499
+ if (minutes > 0) time += `${minutes}M`;
1500
+ if (seconds > 0) time += `${roundToNearest(seconds, 1e-3)}S`;
1501
+ if (!date && !time) time = "0S";
1502
+ return `${sign}P${date}${time && `T${time}`}`;
1498
1503
  }
1499
1504
 
1500
1505
  // src/error/parsingError.ts
@@ -2040,7 +2045,7 @@
2040
2045
  };
2041
2046
  var _NumberSchema = class _NumberSchema extends ValueSchema {
2042
2047
  /**
2043
- * The base Object validator validating that the input is an object.
2048
+ * The base NumberSchema instance validating that the input is a number.
2044
2049
  */
2045
2050
  static get base() {
2046
2051
  if (this._base == null)