@depup/js-yaml 5.2.2-depup.8 → 5.2.3-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! js-yaml 5.2.2 https://github.com/nodeca/js-yaml @license MIT */
1
+ /*! js-yaml 5.2.3 https://github.com/nodeca/js-yaml @license MIT */
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  //#region src/tag.ts
4
4
  var NOT_RESOLVED = Symbol("NOT_RESOLVED");
@@ -457,6 +457,11 @@ var binaryTag = defineScalarTag("tag:yaml.org,2002:binary", {
457
457
  //#region src/tag/scalar/timestamp.ts
458
458
  var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
459
459
  var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
460
+ function makeUtcDate(year, month, day, hour = 0, minute = 0, second = 0, fraction = 0) {
461
+ const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
462
+ date.setUTCFullYear(year, month, day);
463
+ return date;
464
+ }
460
465
  function resolveYamlTimestamp(source) {
461
466
  let match = YAML_DATE_REGEXP.exec(source);
462
467
  if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(source);
@@ -465,7 +470,7 @@ function resolveYamlTimestamp(source) {
465
470
  const month = +match[2] - 1;
466
471
  const day = +match[3];
467
472
  if (!match[4]) {
468
- const date = new Date(Date.UTC(year, month, day));
473
+ const date = makeUtcDate(year, month, day);
469
474
  if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
470
475
  return date;
471
476
  }
@@ -479,7 +484,7 @@ function resolveYamlTimestamp(source) {
479
484
  while (value.length < 3) value += "0";
480
485
  fraction = +value;
481
486
  }
482
- const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
487
+ const date = makeUtcDate(year, month, day, hour, minute, second, fraction);
483
488
  if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
484
489
  if (match[9]) {
485
490
  const offsetHour = +match[10];
@@ -587,7 +592,11 @@ var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
587
592
  return Object.prototype.hasOwnProperty.call(container, String(key));
588
593
  },
589
594
  keys: (container) => Object.keys(container),
590
- get: (container, key) => container[String(key)]
595
+ get: (container, key) => {
596
+ const normalizedKey = String(key);
597
+ if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
598
+ return container[normalizedKey];
599
+ }
591
600
  });
592
601
  //#endregion
593
602
  //#region src/tag/mapping/set.ts
@@ -650,9 +659,9 @@ function _defineProperty(e, r, t) {
650
659
  //#region src/schema.ts
651
660
  function createTagDefinitionMap() {
652
661
  return {
653
- scalar: {},
654
- sequence: {},
655
- mapping: {}
662
+ scalar: Object.create(null),
663
+ sequence: Object.create(null),
664
+ mapping: Object.create(null)
656
665
  };
657
666
  }
658
667
  function createTagDefinitionListMap() {
@@ -826,7 +835,11 @@ var legacyMapTag = defineMappingTag("tag:yaml.org,2002:map", {
826
835
  return normalizedKey !== null && Object.prototype.hasOwnProperty.call(container, normalizedKey);
827
836
  },
828
837
  keys: (container) => Object.keys(container),
829
- get: (container, key) => container[String(key)]
838
+ get: (container, key) => {
839
+ const normalizedKey = String(key);
840
+ if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
841
+ return container[normalizedKey];
842
+ }
830
843
  });
831
844
  //#endregion
832
845
  //#region \0@oxc-project+runtime@0.137.0/helpers/esm/objectSpread2.js
@@ -1178,10 +1191,10 @@ function getScalarValue(input, scalar) {
1178
1191
  }
1179
1192
  //#endregion
1180
1193
  //#region src/common/tagname.ts
1181
- var DEFAULT_TAG_HANDLERS = {
1194
+ var DEFAULT_TAG_HANDLERS = Object.assign(Object.create(null), {
1182
1195
  "!": "!",
1183
1196
  "!!": "tag:yaml.org,2002:"
1184
- };
1197
+ });
1185
1198
  function tagPercentEncode(source) {
1186
1199
  return encodeURI(source).replace(/!/g, "%21");
1187
1200
  }
@@ -1439,6 +1452,10 @@ function constructFromEvents(events, options) {
1439
1452
  }
1440
1453
  case 6: {
1441
1454
  const frame = state.frames.pop();
1455
+ if (frame.kind === "mapping" && frame.hasKey) {
1456
+ state.position = frame.keyPosition;
1457
+ throwError$1(state, "incomplete mapping pair in event stream");
1458
+ }
1442
1459
  if (frame.kind === "document") state.documents.push(frame.value);
1443
1460
  else {
1444
1461
  const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
@@ -2111,10 +2128,6 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
2111
2128
  else if (state.lineIndent === parentIndent) indentStatus = 0;
2112
2129
  else indentStatus = -1;
2113
2130
  }
2114
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
2115
- state.depth--;
2116
- return false;
2117
- }
2118
2131
  if (indentStatus === 1) while (true) {
2119
2132
  const ch = state.input.charCodeAt(state.position);
2120
2133
  const propertyState = snapshotState(state);
@@ -2671,14 +2684,14 @@ function chooseScalarStyle(state, string, layout, singleLineOnly, forceQuote, in
2671
2684
  if (char === CHAR_LINE_FEED) {
2672
2685
  hasLineBreak = true;
2673
2686
  if (shouldTrackWidth) {
2674
- hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2687
+ hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && !isMoreIndented(string[previousLineBreak + 1]);
2675
2688
  previousLineBreak = i;
2676
2689
  }
2677
2690
  } else if (!isPrintable(char)) return STYLE_DOUBLE;
2678
2691
  plain = plain && isPlainSafe(char, prevChar, inblock);
2679
2692
  prevChar = char;
2680
2693
  }
2681
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2694
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && !isMoreIndented(string[previousLineBreak + 1]);
2682
2695
  }
2683
2696
  if (!hasLineBreak && !hasFoldableLine) {
2684
2697
  if (plain && !forceQuote) return STYLE_PLAIN;
@@ -2737,27 +2750,30 @@ function encodeFlowBreaks(string, indent) {
2737
2750
  function dropEndingNewline(string) {
2738
2751
  return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
2739
2752
  }
2753
+ function isMoreIndented(char) {
2754
+ return char === " " || char === " ";
2755
+ }
2740
2756
  function foldBlockScalar(string, width) {
2741
2757
  const lineRe = /(\n+)([^\n]*)/g;
2742
2758
  let nextLF = string.indexOf("\n");
2743
2759
  if (nextLF === -1) nextLF = string.length;
2744
2760
  lineRe.lastIndex = nextLF;
2745
2761
  let result = foldLine(string.slice(0, nextLF), width);
2746
- let prevMoreIndented = string[0] === "\n" || string[0] === " ";
2762
+ let prevMoreIndented = string[0] === "\n" || isMoreIndented(string[0]);
2747
2763
  let moreIndented;
2748
2764
  let match;
2749
2765
  while (match = lineRe.exec(string)) {
2750
2766
  const prefix = match[1];
2751
2767
  const line = match[2];
2752
- moreIndented = line[0] === " ";
2768
+ moreIndented = line !== "" && isMoreIndented(line[0]);
2753
2769
  result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
2754
2770
  prevMoreIndented = moreIndented;
2755
2771
  }
2756
2772
  return result;
2757
2773
  }
2758
2774
  function foldLine(line, width) {
2759
- if (line === "" || line[0] === " ") return line;
2760
- const breakRe = / [^ ]/g;
2775
+ if (line === "" || isMoreIndented(line[0])) return line;
2776
+ const breakRe = / [^ \t]/g;
2761
2777
  let match;
2762
2778
  let start = 0;
2763
2779
  let end;
@@ -3172,6 +3188,7 @@ function eventsToAst(events, options) {
3172
3188
  }
3173
3189
  case 6: {
3174
3190
  const frame = state.frames.pop();
3191
+ if (frame.kind === "mapping" && frame.key) throw new Error("incomplete mapping pair in event stream");
3175
3192
  if (frame.kind === "document") state.documents.push(frame.doc);
3176
3193
  else addNode(state, frame.node);
3177
3194
  break;