@specship/specship-win32-arm64 0.13.0 → 0.13.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 (183) hide show
  1. package/lib/dist/server/cli.js +1 -1
  2. package/lib/dist/server/routes/sse.js +1 -1
  3. package/lib/dist/server/server.js +1 -1
  4. package/lib/node_modules/.package-lock.json +11 -20
  5. package/lib/node_modules/ajv/node_modules/fast-uri/index.js +1 -1
  6. package/lib/node_modules/ajv/node_modules/fast-uri/package.json +1 -1
  7. package/lib/node_modules/ajv/node_modules/fast-uri/test/security.test.js +28 -0
  8. package/lib/node_modules/toad-cache/README.md +10 -9
  9. package/lib/node_modules/toad-cache/dist/toad-cache.cjs +139 -139
  10. package/lib/node_modules/toad-cache/dist/toad-cache.mjs +136 -140
  11. package/lib/node_modules/toad-cache/package.json +8 -8
  12. package/lib/node_modules/toad-cache/toad-cache.d.cts +20 -14
  13. package/lib/node_modules/toad-cache/toad-cache.d.ts +18 -14
  14. package/lib/node_modules/yaml/README.md +14 -31
  15. package/lib/node_modules/yaml/browser/dist/compose/compose-collection.js +3 -3
  16. package/lib/node_modules/yaml/browser/dist/compose/compose-doc.js +0 -1
  17. package/lib/node_modules/yaml/browser/dist/compose/compose-node.js +4 -21
  18. package/lib/node_modules/yaml/browser/dist/compose/compose-scalar.js +8 -14
  19. package/lib/node_modules/yaml/browser/dist/compose/composer.js +2 -4
  20. package/lib/node_modules/yaml/browser/dist/compose/resolve-block-map.js +0 -2
  21. package/lib/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +1 -3
  22. package/lib/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +2 -8
  23. package/lib/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +4 -6
  24. package/lib/node_modules/yaml/browser/dist/compose/resolve-props.js +5 -3
  25. package/lib/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +2 -1
  26. package/lib/node_modules/yaml/browser/dist/compose/util-map-includes.js +5 -1
  27. package/lib/node_modules/yaml/browser/dist/doc/Document.js +2 -3
  28. package/lib/node_modules/yaml/browser/dist/doc/anchors.js +2 -1
  29. package/lib/node_modules/yaml/browser/dist/doc/applyReviver.js +0 -1
  30. package/lib/node_modules/yaml/browser/dist/doc/createNode.js +2 -1
  31. package/lib/node_modules/yaml/browser/dist/errors.js +1 -1
  32. package/lib/node_modules/yaml/browser/dist/log.js +6 -1
  33. package/lib/node_modules/yaml/browser/dist/node_modules/tslib/tslib.es6.js +21 -0
  34. package/lib/node_modules/yaml/browser/dist/nodes/Alias.js +12 -27
  35. package/lib/node_modules/yaml/browser/dist/nodes/YAMLMap.js +1 -1
  36. package/lib/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +49 -8
  37. package/lib/node_modules/yaml/browser/dist/parse/lexer.js +24 -28
  38. package/lib/node_modules/yaml/browser/dist/parse/parser.js +8 -31
  39. package/lib/node_modules/yaml/browser/dist/public-api.js +0 -3
  40. package/lib/node_modules/yaml/browser/dist/schema/Schema.js +2 -1
  41. package/lib/node_modules/yaml/browser/dist/schema/json/schema.js +1 -1
  42. package/lib/node_modules/yaml/browser/dist/schema/tags.js +16 -29
  43. package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +13 -5
  44. package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +1 -1
  45. package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +0 -2
  46. package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +1 -1
  47. package/lib/node_modules/yaml/browser/dist/stringify/stringify.js +5 -10
  48. package/lib/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +3 -13
  49. package/lib/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +2 -3
  50. package/lib/node_modules/yaml/browser/dist/stringify/stringifyPair.js +1 -1
  51. package/lib/node_modules/yaml/browser/dist/stringify/stringifyString.js +16 -24
  52. package/lib/node_modules/yaml/browser/dist/util.js +1 -1
  53. package/lib/node_modules/yaml/dist/cli.d.ts +1 -1
  54. package/lib/node_modules/yaml/dist/cli.mjs +3 -5
  55. package/lib/node_modules/yaml/dist/compose/compose-collection.d.ts +4 -4
  56. package/lib/node_modules/yaml/dist/compose/compose-collection.js +3 -3
  57. package/lib/node_modules/yaml/dist/compose/compose-doc.d.ts +6 -6
  58. package/lib/node_modules/yaml/dist/compose/compose-doc.js +0 -1
  59. package/lib/node_modules/yaml/dist/compose/compose-node.d.ts +7 -8
  60. package/lib/node_modules/yaml/dist/compose/compose-node.js +4 -21
  61. package/lib/node_modules/yaml/dist/compose/compose-scalar.d.ts +4 -4
  62. package/lib/node_modules/yaml/dist/compose/compose-scalar.js +7 -13
  63. package/lib/node_modules/yaml/dist/compose/composer.d.ts +6 -7
  64. package/lib/node_modules/yaml/dist/compose/composer.js +3 -6
  65. package/lib/node_modules/yaml/dist/compose/resolve-block-map.d.ts +5 -5
  66. package/lib/node_modules/yaml/dist/compose/resolve-block-map.js +0 -2
  67. package/lib/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +5 -5
  68. package/lib/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +5 -5
  69. package/lib/node_modules/yaml/dist/compose/resolve-block-seq.js +1 -3
  70. package/lib/node_modules/yaml/dist/compose/resolve-end.d.ts +2 -2
  71. package/lib/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -7
  72. package/lib/node_modules/yaml/dist/compose/resolve-flow-collection.js +2 -8
  73. package/lib/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +4 -4
  74. package/lib/node_modules/yaml/dist/compose/resolve-flow-scalar.js +4 -6
  75. package/lib/node_modules/yaml/dist/compose/resolve-props.d.ts +2 -2
  76. package/lib/node_modules/yaml/dist/compose/resolve-props.js +5 -3
  77. package/lib/node_modules/yaml/dist/compose/util-contains-newline.d.ts +1 -1
  78. package/lib/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +1 -1
  79. package/lib/node_modules/yaml/dist/compose/util-empty-scalar-position.js +2 -1
  80. package/lib/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +2 -2
  81. package/lib/node_modules/yaml/dist/compose/util-map-includes.d.ts +3 -3
  82. package/lib/node_modules/yaml/dist/compose/util-map-includes.js +5 -1
  83. package/lib/node_modules/yaml/dist/doc/Document.d.ts +11 -11
  84. package/lib/node_modules/yaml/dist/doc/Document.js +2 -3
  85. package/lib/node_modules/yaml/dist/doc/anchors.d.ts +2 -2
  86. package/lib/node_modules/yaml/dist/doc/anchors.js +2 -1
  87. package/lib/node_modules/yaml/dist/doc/applyReviver.js +0 -1
  88. package/lib/node_modules/yaml/dist/doc/createNode.d.ts +4 -4
  89. package/lib/node_modules/yaml/dist/doc/createNode.js +2 -1
  90. package/lib/node_modules/yaml/dist/doc/directives.d.ts +1 -1
  91. package/lib/node_modules/yaml/dist/errors.d.ts +1 -1
  92. package/lib/node_modules/yaml/dist/errors.js +1 -1
  93. package/lib/node_modules/yaml/dist/index.d.ts +18 -21
  94. package/lib/node_modules/yaml/dist/log.js +4 -4
  95. package/lib/node_modules/yaml/dist/nodes/Alias.d.ts +9 -10
  96. package/lib/node_modules/yaml/dist/nodes/Alias.js +11 -26
  97. package/lib/node_modules/yaml/dist/nodes/Collection.d.ts +4 -4
  98. package/lib/node_modules/yaml/dist/nodes/Node.d.ts +9 -16
  99. package/lib/node_modules/yaml/dist/nodes/Pair.d.ts +8 -9
  100. package/lib/node_modules/yaml/dist/nodes/Scalar.d.ts +4 -9
  101. package/lib/node_modules/yaml/dist/nodes/YAMLMap.d.ts +10 -10
  102. package/lib/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +10 -10
  103. package/lib/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +3 -3
  104. package/lib/node_modules/yaml/dist/nodes/addPairToJSMap.js +48 -7
  105. package/lib/node_modules/yaml/dist/nodes/identity.d.ts +7 -7
  106. package/lib/node_modules/yaml/dist/nodes/toJS.d.ts +2 -4
  107. package/lib/node_modules/yaml/dist/options.d.ts +10 -22
  108. package/lib/node_modules/yaml/dist/parse/cst-scalar.d.ts +4 -4
  109. package/lib/node_modules/yaml/dist/parse/cst-stringify.d.ts +1 -1
  110. package/lib/node_modules/yaml/dist/parse/cst-visit.d.ts +2 -2
  111. package/lib/node_modules/yaml/dist/parse/cst.d.ts +3 -4
  112. package/lib/node_modules/yaml/dist/parse/lexer.d.ts +1 -1
  113. package/lib/node_modules/yaml/dist/parse/lexer.js +24 -28
  114. package/lib/node_modules/yaml/dist/parse/parser.d.ts +4 -4
  115. package/lib/node_modules/yaml/dist/parse/parser.js +9 -33
  116. package/lib/node_modules/yaml/dist/public-api.d.ts +5 -6
  117. package/lib/node_modules/yaml/dist/public-api.js +0 -3
  118. package/lib/node_modules/yaml/dist/schema/Schema.d.ts +5 -4
  119. package/lib/node_modules/yaml/dist/schema/Schema.js +2 -1
  120. package/lib/node_modules/yaml/dist/schema/common/map.d.ts +1 -1
  121. package/lib/node_modules/yaml/dist/schema/common/null.d.ts +1 -1
  122. package/lib/node_modules/yaml/dist/schema/common/seq.d.ts +1 -1
  123. package/lib/node_modules/yaml/dist/schema/common/string.d.ts +1 -1
  124. package/lib/node_modules/yaml/dist/schema/core/bool.d.ts +1 -1
  125. package/lib/node_modules/yaml/dist/schema/core/float.d.ts +1 -1
  126. package/lib/node_modules/yaml/dist/schema/core/int.d.ts +1 -1
  127. package/lib/node_modules/yaml/dist/schema/core/schema.d.ts +1 -1
  128. package/lib/node_modules/yaml/dist/schema/json/schema.d.ts +1 -1
  129. package/lib/node_modules/yaml/dist/schema/json/schema.js +1 -1
  130. package/lib/node_modules/yaml/dist/schema/tags.d.ts +3 -11
  131. package/lib/node_modules/yaml/dist/schema/tags.js +13 -26
  132. package/lib/node_modules/yaml/dist/schema/types.d.ts +12 -14
  133. package/lib/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +1 -1
  134. package/lib/node_modules/yaml/dist/schema/yaml-1.1/binary.js +7 -9
  135. package/lib/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +1 -1
  136. package/lib/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +1 -1
  137. package/lib/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +1 -1
  138. package/lib/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +17 -11
  139. package/lib/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +7 -7
  140. package/lib/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -1
  141. package/lib/node_modules/yaml/dist/schema/yaml-1.1/schema.js +0 -2
  142. package/lib/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +9 -9
  143. package/lib/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +1 -1
  144. package/lib/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +1 -1
  145. package/lib/node_modules/yaml/dist/stringify/stringify.d.ts +3 -3
  146. package/lib/node_modules/yaml/dist/stringify/stringify.js +5 -10
  147. package/lib/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +2 -2
  148. package/lib/node_modules/yaml/dist/stringify/stringifyCollection.js +3 -13
  149. package/lib/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +3 -3
  150. package/lib/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +1 -1
  151. package/lib/node_modules/yaml/dist/stringify/stringifyNumber.js +2 -3
  152. package/lib/node_modules/yaml/dist/stringify/stringifyPair.d.ts +2 -2
  153. package/lib/node_modules/yaml/dist/stringify/stringifyPair.js +1 -1
  154. package/lib/node_modules/yaml/dist/stringify/stringifyString.d.ts +2 -2
  155. package/lib/node_modules/yaml/dist/stringify/stringifyString.js +15 -23
  156. package/lib/node_modules/yaml/dist/util.d.ts +12 -16
  157. package/lib/node_modules/yaml/dist/util.js +2 -2
  158. package/lib/node_modules/yaml/dist/visit.d.ts +7 -7
  159. package/lib/node_modules/yaml/package.json +14 -13
  160. package/lib/package.json +5 -6
  161. package/package.json +1 -1
  162. package/lib/node_modules/jsonc-parser/CHANGELOG.md +0 -76
  163. package/lib/node_modules/jsonc-parser/LICENSE.md +0 -21
  164. package/lib/node_modules/jsonc-parser/README.md +0 -364
  165. package/lib/node_modules/jsonc-parser/SECURITY.md +0 -41
  166. package/lib/node_modules/jsonc-parser/lib/esm/impl/edit.js +0 -185
  167. package/lib/node_modules/jsonc-parser/lib/esm/impl/format.js +0 -261
  168. package/lib/node_modules/jsonc-parser/lib/esm/impl/parser.js +0 -659
  169. package/lib/node_modules/jsonc-parser/lib/esm/impl/scanner.js +0 -443
  170. package/lib/node_modules/jsonc-parser/lib/esm/impl/string-intern.js +0 -29
  171. package/lib/node_modules/jsonc-parser/lib/esm/main.d.ts +0 -351
  172. package/lib/node_modules/jsonc-parser/lib/esm/main.js +0 -178
  173. package/lib/node_modules/jsonc-parser/lib/umd/impl/edit.js +0 -201
  174. package/lib/node_modules/jsonc-parser/lib/umd/impl/format.js +0 -275
  175. package/lib/node_modules/jsonc-parser/lib/umd/impl/parser.js +0 -682
  176. package/lib/node_modules/jsonc-parser/lib/umd/impl/scanner.js +0 -456
  177. package/lib/node_modules/jsonc-parser/lib/umd/impl/string-intern.js +0 -42
  178. package/lib/node_modules/jsonc-parser/lib/umd/main.d.ts +0 -351
  179. package/lib/node_modules/jsonc-parser/lib/umd/main.js +0 -194
  180. package/lib/node_modules/jsonc-parser/package.json +0 -37
  181. package/lib/node_modules/yaml/browser/dist/schema/yaml-1.1/merge.js +0 -67
  182. package/lib/node_modules/yaml/dist/schema/yaml-1.1/merge.d.ts +0 -9
  183. package/lib/node_modules/yaml/dist/schema/yaml-1.1/merge.js +0 -71
@@ -1,15 +1,22 @@
1
1
  import { warn } from '../log.js';
2
- import { isMergeKey, addMergeToJSMap } from '../schema/yaml-1.1/merge.js';
3
2
  import { createStringifyContext } from '../stringify/stringify.js';
4
- import { isNode } from './identity.js';
3
+ import { isAlias, isSeq, isScalar, isMap, isNode } from './identity.js';
4
+ import { Scalar } from './Scalar.js';
5
5
  import { toJS } from './toJS.js';
6
6
 
7
+ const MERGE_KEY = '<<';
7
8
  function addPairToJSMap(ctx, map, { key, value }) {
8
- if (isNode(key) && key.addToJSMap)
9
- key.addToJSMap(ctx, map, value);
10
- // TODO: Should drop this special case for bare << handling
11
- else if (isMergeKey(ctx, key))
12
- addMergeToJSMap(ctx, map, value);
9
+ if (ctx?.doc.schema.merge && isMergeKey(key)) {
10
+ value = isAlias(value) ? value.resolve(ctx.doc) : value;
11
+ if (isSeq(value))
12
+ for (const it of value.items)
13
+ mergeToJSMap(ctx, map, it);
14
+ else if (Array.isArray(value))
15
+ for (const it of value)
16
+ mergeToJSMap(ctx, map, it);
17
+ else
18
+ mergeToJSMap(ctx, map, value);
19
+ }
13
20
  else {
14
21
  const jsKey = toJS(key, '', ctx);
15
22
  if (map instanceof Map) {
@@ -34,10 +41,44 @@ function addPairToJSMap(ctx, map, { key, value }) {
34
41
  }
35
42
  return map;
36
43
  }
44
+ const isMergeKey = (key) => key === MERGE_KEY ||
45
+ (isScalar(key) &&
46
+ key.value === MERGE_KEY &&
47
+ (!key.type || key.type === Scalar.PLAIN));
48
+ // If the value associated with a merge key is a single mapping node, each of
49
+ // its key/value pairs is inserted into the current mapping, unless the key
50
+ // already exists in it. If the value associated with the merge key is a
51
+ // sequence, then this sequence is expected to contain mapping nodes and each
52
+ // of these nodes is merged in turn according to its order in the sequence.
53
+ // Keys in mapping nodes earlier in the sequence override keys specified in
54
+ // later mapping nodes. -- http://yaml.org/type/merge.html
55
+ function mergeToJSMap(ctx, map, value) {
56
+ const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
57
+ if (!isMap(source))
58
+ throw new Error('Merge sources must be maps or map aliases');
59
+ const srcMap = source.toJSON(null, ctx, Map);
60
+ for (const [key, value] of srcMap) {
61
+ if (map instanceof Map) {
62
+ if (!map.has(key))
63
+ map.set(key, value);
64
+ }
65
+ else if (map instanceof Set) {
66
+ map.add(key);
67
+ }
68
+ else if (!Object.prototype.hasOwnProperty.call(map, key)) {
69
+ Object.defineProperty(map, key, {
70
+ value,
71
+ writable: true,
72
+ enumerable: true,
73
+ configurable: true
74
+ });
75
+ }
76
+ }
77
+ return map;
78
+ }
37
79
  function stringifyKey(key, jsKey, ctx) {
38
80
  if (jsKey === null)
39
81
  return '';
40
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
41
82
  if (typeof jsKey !== 'object')
42
83
  return String(jsKey);
43
84
  if (isNode(key) && ctx?.doc) {
@@ -310,7 +310,7 @@ class Lexer {
310
310
  const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
311
311
  this.indentNext = this.indentValue + 1;
312
312
  this.indentValue += n;
313
- return 'block-start';
313
+ return yield* this.parseBlockStart();
314
314
  }
315
315
  return 'doc';
316
316
  }
@@ -631,36 +631,32 @@ class Lexer {
631
631
  return 0;
632
632
  }
633
633
  *pushIndicators() {
634
- let n = 0;
635
- loop: while (true) {
636
- switch (this.charAt(0)) {
637
- case '!':
638
- n += yield* this.pushTag();
639
- n += yield* this.pushSpaces(true);
640
- continue loop;
641
- case '&':
642
- n += yield* this.pushUntil(isNotAnchorChar);
643
- n += yield* this.pushSpaces(true);
644
- continue loop;
645
- case '-': // this is an error
646
- case '?': // this is an error outside flow collections
647
- case ':': {
648
- const inFlow = this.flowLevel > 0;
649
- const ch1 = this.charAt(1);
650
- if (isEmpty(ch1) || (inFlow && flowIndicatorChars.has(ch1))) {
651
- if (!inFlow)
652
- this.indentNext = this.indentValue + 1;
653
- else if (this.flowKey)
654
- this.flowKey = false;
655
- n += yield* this.pushCount(1);
656
- n += yield* this.pushSpaces(true);
657
- continue loop;
658
- }
634
+ switch (this.charAt(0)) {
635
+ case '!':
636
+ return ((yield* this.pushTag()) +
637
+ (yield* this.pushSpaces(true)) +
638
+ (yield* this.pushIndicators()));
639
+ case '&':
640
+ return ((yield* this.pushUntil(isNotAnchorChar)) +
641
+ (yield* this.pushSpaces(true)) +
642
+ (yield* this.pushIndicators()));
643
+ case '-': // this is an error
644
+ case '?': // this is an error outside flow collections
645
+ case ':': {
646
+ const inFlow = this.flowLevel > 0;
647
+ const ch1 = this.charAt(1);
648
+ if (isEmpty(ch1) || (inFlow && flowIndicatorChars.has(ch1))) {
649
+ if (!inFlow)
650
+ this.indentNext = this.indentValue + 1;
651
+ else if (this.flowKey)
652
+ this.flowKey = false;
653
+ return ((yield* this.pushCount(1)) +
654
+ (yield* this.pushSpaces(true)) +
655
+ (yield* this.pushIndicators()));
659
656
  }
660
657
  }
661
- break loop;
662
658
  }
663
- return n;
659
+ return 0;
664
660
  }
665
661
  *pushTag() {
666
662
  if (this.charAt(1) === '<') {
@@ -67,14 +67,6 @@ function getFirstKeyStartProps(prev) {
67
67
  }
68
68
  return prev.splice(i, prev.length);
69
69
  }
70
- function arrayPushArray(target, source) {
71
- // May exhaust call stack with large `source` array
72
- if (source.length < 1e5)
73
- Array.prototype.push.apply(target, source);
74
- else
75
- for (let i = 0; i < source.length; ++i)
76
- target.push(source[i]);
77
- }
78
70
  function fixFlowSeqItems(fc) {
79
71
  if (fc.start.type === 'flow-seq-start') {
80
72
  for (const it of fc.items) {
@@ -87,12 +79,12 @@ function fixFlowSeqItems(fc) {
87
79
  delete it.key;
88
80
  if (isFlowToken(it.value)) {
89
81
  if (it.value.end)
90
- arrayPushArray(it.value.end, it.sep);
82
+ Array.prototype.push.apply(it.value.end, it.sep);
91
83
  else
92
84
  it.value.end = it.sep;
93
85
  }
94
86
  else
95
- arrayPushArray(it.start, it.sep);
87
+ Array.prototype.push.apply(it.start, it.sep);
96
88
  delete it.sep;
97
89
  }
98
90
  }
@@ -234,7 +226,7 @@ class Parser {
234
226
  }
235
227
  *step() {
236
228
  const top = this.peek(1);
237
- if (this.type === 'doc-end' && top?.type !== 'doc-end') {
229
+ if (this.type === 'doc-end' && (!top || top.type !== 'doc-end')) {
238
230
  while (this.stack.length > 0)
239
231
  yield* this.pop();
240
232
  this.stack.push({
@@ -510,7 +502,7 @@ class Parser {
510
502
  const prev = map.items[map.items.length - 2];
511
503
  const end = prev?.value?.end;
512
504
  if (Array.isArray(end)) {
513
- arrayPushArray(end, it.start);
505
+ Array.prototype.push.apply(end, it.start);
514
506
  end.push(this.sourceToken);
515
507
  map.items.pop();
516
508
  return;
@@ -616,9 +608,7 @@ class Parser {
616
608
  const sep = it.sep;
617
609
  sep.push(this.sourceToken);
618
610
  // @ts-expect-error type guard is wrong here
619
- delete it.key;
620
- // @ts-expect-error type guard is wrong here
621
- delete it.sep;
611
+ delete it.key, delete it.sep;
622
612
  this.stack.push({
623
613
  type: 'block-map',
624
614
  offset: this.offset,
@@ -676,20 +666,7 @@ class Parser {
676
666
  default: {
677
667
  const bv = this.startBlockValue(map);
678
668
  if (bv) {
679
- if (bv.type === 'block-seq') {
680
- if (!it.explicitKey &&
681
- it.sep &&
682
- !includesToken(it.sep, 'newline')) {
683
- yield* this.pop({
684
- type: 'error',
685
- offset: this.offset,
686
- message: 'Unexpected block-seq-ind on same line with key',
687
- source: this.source
688
- });
689
- return;
690
- }
691
- }
692
- else if (atMapIndent) {
669
+ if (atMapIndent && bv.type !== 'block-seq') {
693
670
  map.items.push({ start });
694
671
  }
695
672
  this.stack.push(bv);
@@ -725,7 +702,7 @@ class Parser {
725
702
  const prev = seq.items[seq.items.length - 2];
726
703
  const end = prev?.value?.end;
727
704
  if (Array.isArray(end)) {
728
- arrayPushArray(end, it.start);
705
+ Array.prototype.push.apply(end, it.start);
729
706
  end.push(this.sourceToken);
730
707
  seq.items.pop();
731
708
  return;
@@ -766,7 +743,7 @@ class Parser {
766
743
  do {
767
744
  yield* this.pop();
768
745
  top = this.peek(1);
769
- } while (top?.type === 'flow-collection');
746
+ } while (top && top.type === 'flow-collection');
770
747
  }
771
748
  else if (fc.end.length === 0) {
772
749
  switch (this.type) {
@@ -2,7 +2,6 @@ import { Composer } from './compose/composer.js';
2
2
  import { Document } from './doc/Document.js';
3
3
  import { prettifyError, YAMLParseError } from './errors.js';
4
4
  import { warn } from './log.js';
5
- import { isDocument } from './nodes/identity.js';
6
5
  import { LineCounter } from './parse/line-counter.js';
7
6
  import { Parser } from './parse/parser.js';
8
7
 
@@ -94,8 +93,6 @@ function stringify(value, replacer, options) {
94
93
  if (!keepUndefined)
95
94
  return undefined;
96
95
  }
97
- if (isDocument(value) && !_replacer)
98
- return value.toString(options);
99
96
  return new Document(value, _replacer, options).toString(options);
100
97
  }
101
98
 
@@ -12,9 +12,10 @@ class Schema {
12
12
  : compat
13
13
  ? getTags(null, compat)
14
14
  : null;
15
+ this.merge = !!merge;
15
16
  this.name = (typeof schema === 'string' && schema) || 'core';
16
17
  this.knownTags = resolveKnownTags ? coreKnownTags : {};
17
- this.tags = getTags(customTags, this.name, merge);
18
+ this.tags = getTags(customTags, this.name);
18
19
  this.toStringOptions = toStringDefaults ?? null;
19
20
  Object.defineProperty(this, MAP, { value: map });
20
21
  Object.defineProperty(this, SCALAR, { value: string });
@@ -27,7 +27,7 @@ const jsonScalars = [
27
27
  identify: value => typeof value === 'boolean',
28
28
  default: true,
29
29
  tag: 'tag:yaml.org,2002:bool',
30
- test: /^true$|^false$/,
30
+ test: /^true|false$/,
31
31
  resolve: str => str === 'true',
32
32
  stringify: stringifyJSON
33
33
  },
@@ -3,17 +3,16 @@ import { nullTag } from './common/null.js';
3
3
  import { seq } from './common/seq.js';
4
4
  import { string } from './common/string.js';
5
5
  import { boolTag } from './core/bool.js';
6
- import { floatNaN, floatExp, float } from './core/float.js';
7
- import { intOct, intHex, int } from './core/int.js';
6
+ import { float, floatExp, floatNaN } from './core/float.js';
7
+ import { int, intHex, intOct } from './core/int.js';
8
8
  import { schema } from './core/schema.js';
9
9
  import { schema as schema$1 } from './json/schema.js';
10
10
  import { binary } from './yaml-1.1/binary.js';
11
- import { merge } from './yaml-1.1/merge.js';
12
11
  import { omap } from './yaml-1.1/omap.js';
13
12
  import { pairs } from './yaml-1.1/pairs.js';
14
13
  import { schema as schema$2 } from './yaml-1.1/schema.js';
15
14
  import { set } from './yaml-1.1/set.js';
16
- import { timestamp, intTime, floatTime } from './yaml-1.1/timestamp.js';
15
+ import { timestamp, floatTime, intTime } from './yaml-1.1/timestamp.js';
17
16
 
18
17
  const schemas = new Map([
19
18
  ['core', schema],
@@ -34,7 +33,6 @@ const tagsByName = {
34
33
  intOct,
35
34
  intTime,
36
35
  map,
37
- merge,
38
36
  null: nullTag,
39
37
  omap,
40
38
  pairs,
@@ -44,20 +42,13 @@ const tagsByName = {
44
42
  };
45
43
  const coreKnownTags = {
46
44
  'tag:yaml.org,2002:binary': binary,
47
- 'tag:yaml.org,2002:merge': merge,
48
45
  'tag:yaml.org,2002:omap': omap,
49
46
  'tag:yaml.org,2002:pairs': pairs,
50
47
  'tag:yaml.org,2002:set': set,
51
48
  'tag:yaml.org,2002:timestamp': timestamp
52
49
  };
53
- function getTags(customTags, schemaName, addMergeTag) {
54
- const schemaTags = schemas.get(schemaName);
55
- if (schemaTags && !customTags) {
56
- return addMergeTag && !schemaTags.includes(merge)
57
- ? schemaTags.concat(merge)
58
- : schemaTags.slice();
59
- }
60
- let tags = schemaTags;
50
+ function getTags(customTags, schemaName) {
51
+ let tags = schemas.get(schemaName);
61
52
  if (!tags) {
62
53
  if (Array.isArray(customTags))
63
54
  tags = [];
@@ -76,21 +67,17 @@ function getTags(customTags, schemaName, addMergeTag) {
76
67
  else if (typeof customTags === 'function') {
77
68
  tags = customTags(tags.slice());
78
69
  }
79
- if (addMergeTag)
80
- tags = tags.concat(merge);
81
- return tags.reduce((tags, tag) => {
82
- const tagObj = typeof tag === 'string' ? tagsByName[tag] : tag;
83
- if (!tagObj) {
84
- const tagName = JSON.stringify(tag);
85
- const keys = Object.keys(tagsByName)
86
- .map(key => JSON.stringify(key))
87
- .join(', ');
88
- throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
89
- }
90
- if (!tags.includes(tagObj))
91
- tags.push(tagObj);
92
- return tags;
93
- }, []);
70
+ return tags.map(tag => {
71
+ if (typeof tag !== 'string')
72
+ return tag;
73
+ const tagObj = tagsByName[tag];
74
+ if (tagObj)
75
+ return tagObj;
76
+ const keys = Object.keys(tagsByName)
77
+ .map(key => JSON.stringify(key))
78
+ .join(', ');
79
+ throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`);
80
+ });
94
81
  }
95
82
 
96
83
  export { coreKnownTags, getTags };
@@ -14,7 +14,10 @@ const binary = {
14
14
  * document.querySelector('#photo').src = URL.createObjectURL(blob)
15
15
  */
16
16
  resolve(src, onError) {
17
- if (typeof atob === 'function') {
17
+ if (typeof Buffer === 'function') {
18
+ return Buffer.from(src, 'base64');
19
+ }
20
+ else if (typeof atob === 'function') {
18
21
  // On IE 11, atob() can't handle newlines
19
22
  const str = atob(src.replace(/[\n\r]/g, ''));
20
23
  const buffer = new Uint8Array(str.length);
@@ -28,11 +31,15 @@ const binary = {
28
31
  }
29
32
  },
30
33
  stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
31
- if (!value)
32
- return '';
33
34
  const buf = value; // checked earlier by binary.identify()
34
35
  let str;
35
- if (typeof btoa === 'function') {
36
+ if (typeof Buffer === 'function') {
37
+ str =
38
+ buf instanceof Buffer
39
+ ? buf.toString('base64')
40
+ : Buffer.from(buf.buffer).toString('base64');
41
+ }
42
+ else if (typeof btoa === 'function') {
36
43
  let s = '';
37
44
  for (let i = 0; i < buf.length; ++i)
38
45
  s += String.fromCharCode(buf[i]);
@@ -41,7 +48,8 @@ const binary = {
41
48
  else {
42
49
  throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
43
50
  }
44
- type ?? (type = Scalar.BLOCK_LITERAL);
51
+ if (!type)
52
+ type = Scalar.BLOCK_LITERAL;
45
53
  if (type !== Scalar.QUOTE_DOUBLE) {
46
54
  const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
47
55
  const n = Math.ceil(str.length / lineWidth);
@@ -1,5 +1,5 @@
1
1
  import { isSeq, isPair, isMap } from '../../nodes/identity.js';
2
- import { createPair, Pair } from '../../nodes/Pair.js';
2
+ import { Pair, createPair } from '../../nodes/Pair.js';
3
3
  import { Scalar } from '../../nodes/Scalar.js';
4
4
  import { YAMLSeq } from '../../nodes/YAMLSeq.js';
5
5
 
@@ -6,7 +6,6 @@ import { binary } from './binary.js';
6
6
  import { trueTag, falseTag } from './bool.js';
7
7
  import { floatNaN, floatExp, float } from './float.js';
8
8
  import { intBin, intOct, int, intHex } from './int.js';
9
- import { merge } from './merge.js';
10
9
  import { omap } from './omap.js';
11
10
  import { pairs } from './pairs.js';
12
11
  import { set } from './set.js';
@@ -27,7 +26,6 @@ const schema = [
27
26
  floatExp,
28
27
  float,
29
28
  binary,
30
- merge,
31
29
  omap,
32
30
  pairs,
33
31
  set,
@@ -95,7 +95,7 @@ const timestamp = {
95
95
  }
96
96
  return new Date(date);
97
97
  },
98
- stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, '') ?? ''
98
+ stringify: ({ value }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
99
99
  };
100
100
 
101
101
  export { floatTime, intTime, timestamp };
@@ -20,7 +20,6 @@ function createStringifyContext(doc, options) {
20
20
  nullStr: 'null',
21
21
  simpleKeys: false,
22
22
  singleQuote: null,
23
- trailingComma: false,
24
23
  trueStr: 'true',
25
24
  verifyAliasOrder: true
26
25
  }, doc.schema.toStringOptions, options);
@@ -55,12 +54,7 @@ function getTagObject(tags, item) {
55
54
  let obj;
56
55
  if (isScalar(item)) {
57
56
  obj = item.value;
58
- let match = tags.filter(t => t.identify?.(obj));
59
- if (match.length > 1) {
60
- const testMatch = match.filter(t => t.test);
61
- if (testMatch.length > 0)
62
- match = testMatch;
63
- }
57
+ const match = tags.filter(t => t.identify?.(obj));
64
58
  tagObj =
65
59
  match.find(t => t.format === item.format) ?? match.find(t => !t.format);
66
60
  }
@@ -69,7 +63,7 @@ function getTagObject(tags, item) {
69
63
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
70
64
  }
71
65
  if (!tagObj) {
72
- const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
66
+ const name = obj?.constructor?.name ?? typeof obj;
73
67
  throw new Error(`Tag not resolved for ${name} value`);
74
68
  }
75
69
  return tagObj;
@@ -84,7 +78,7 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
84
78
  anchors.add(anchor);
85
79
  props.push(`&${anchor}`);
86
80
  }
87
- const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
81
+ const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
88
82
  if (tag)
89
83
  props.push(doc.directives.tagString(tag));
90
84
  return props.join(' ');
@@ -110,7 +104,8 @@ function stringify(item, ctx, onComment, onChompKeep) {
110
104
  const node = isNode(item)
111
105
  ? item
112
106
  : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
113
- tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
107
+ if (!tagObj)
108
+ tagObj = getTagObject(ctx.doc.schema.tags, node);
114
109
  const props = stringifyProps(node, tagObj, ctx);
115
110
  if (props.length > 0)
116
111
  ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
@@ -102,22 +102,12 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
102
102
  if (comment)
103
103
  reqNewline = true;
104
104
  let str = stringify(item, itemCtx, () => (comment = null));
105
- reqNewline || (reqNewline = lines.length > linesAtValue || str.includes('\n'));
106
- if (i < items.length - 1) {
105
+ if (i < items.length - 1)
107
106
  str += ',';
108
- }
109
- else if (ctx.options.trailingComma) {
110
- if (ctx.options.lineWidth > 0) {
111
- reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) +
112
- (str.length + 2) >
113
- ctx.options.lineWidth);
114
- }
115
- if (reqNewline) {
116
- str += ',';
117
- }
118
- }
119
107
  if (comment)
120
108
  str += lineComment(str, itemIndent, commentString(comment));
109
+ if (!reqNewline && (lines.length > linesAtValue || str.includes('\n')))
110
+ reqNewline = true;
121
111
  lines.push(str);
122
112
  linesAtValue = lines.length;
123
113
  }
@@ -4,12 +4,11 @@ function stringifyNumber({ format, minFractionDigits, tag, value }) {
4
4
  const num = typeof value === 'number' ? value : Number(value);
5
5
  if (!isFinite(num))
6
6
  return isNaN(num) ? '.nan' : num < 0 ? '-.inf' : '.inf';
7
- let n = Object.is(value, -0) ? '-0' : JSON.stringify(value);
7
+ let n = JSON.stringify(value);
8
8
  if (!format &&
9
9
  minFractionDigits &&
10
10
  (!tag || tag === 'tag:yaml.org,2002:float') &&
11
- /^-?\d/.test(n) &&
12
- !n.includes('e')) {
11
+ /^\d/.test(n)) {
13
12
  let i = n.indexOf('.');
14
13
  if (i < 0) {
15
14
  i = n.length;
@@ -101,7 +101,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
101
101
  ws += `\n${indentComment(cs, ctx.indent)}`;
102
102
  }
103
103
  if (valueStr === '' && !ctx.inFlow) {
104
- if (ws === '\n' && valueComment)
104
+ if (ws === '\n')
105
105
  ws = '\n\n';
106
106
  }
107
107
  else {
@@ -1,5 +1,5 @@
1
1
  import { Scalar } from '../nodes/Scalar.js';
2
- import { foldFlowLines, FOLD_FLOW, FOLD_QUOTED, FOLD_BLOCK } from './foldFlowLines.js';
2
+ import { foldFlowLines, FOLD_QUOTED, FOLD_FLOW, FOLD_BLOCK } from './foldFlowLines.js';
3
3
 
4
4
  const getFoldOptions = (ctx, isBlock) => ({
5
5
  indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
@@ -159,7 +159,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
159
159
  const { blockQuote, commentString, lineWidth } = ctx.options;
160
160
  // 1. Block can't end in whitespace unless the last line is non-empty.
161
161
  // 2. Strings consisting of only whitespace are best rendered explicitly.
162
- if (!blockQuote || /\n[\t ]+$/.test(value)) {
162
+ if (!blockQuote || /\n[\t ]+$/.test(value) || /^\s*$/.test(value)) {
163
163
  return quotedString(value, ctx);
164
164
  }
165
165
  const indent = ctx.indent ||
@@ -219,32 +219,23 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
219
219
  start = start.replace(/\n+/g, `$&${indent}`);
220
220
  }
221
221
  const indentSize = indent ? '2' : '1'; // root is at -1
222
- // Leading | or > is added later
223
- let header = (startWithSpace ? indentSize : '') + chomp;
222
+ let header = (literal ? '|' : '>') + (startWithSpace ? indentSize : '') + chomp;
224
223
  if (comment) {
225
224
  header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
226
225
  if (onComment)
227
226
  onComment();
228
227
  }
229
- if (!literal) {
230
- const foldedValue = value
231
- .replace(/\n+/g, '\n$&')
232
- .replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
233
- // ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
234
- .replace(/\n+/g, `$&${indent}`);
235
- let literalFallback = false;
236
- const foldOptions = getFoldOptions(ctx, true);
237
- if (blockQuote !== 'folded' && type !== Scalar.BLOCK_FOLDED) {
238
- foldOptions.onOverflow = () => {
239
- literalFallback = true;
240
- };
241
- }
242
- const body = foldFlowLines(`${start}${foldedValue}${end}`, indent, FOLD_BLOCK, foldOptions);
243
- if (!literalFallback)
244
- return `>${header}\n${indent}${body}`;
228
+ if (literal) {
229
+ value = value.replace(/\n+/g, `$&${indent}`);
230
+ return `${header}\n${indent}${start}${value}${end}`;
245
231
  }
246
- value = value.replace(/\n+/g, `$&${indent}`);
247
- return `|${header}\n${indent}${start}${value}${end}`;
232
+ value = value
233
+ .replace(/\n+/g, '\n$&')
234
+ .replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
235
+ // ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
236
+ .replace(/\n+/g, `$&${indent}`);
237
+ const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
238
+ return `${header}\n${indent}${body}`;
248
239
  }
249
240
  function plainString(item, ctx, onComment, onChompKeep) {
250
241
  const { type, value } = item;
@@ -253,9 +244,10 @@ function plainString(item, ctx, onComment, onChompKeep) {
253
244
  (inFlow && /[[\]{},]/.test(value))) {
254
245
  return quotedString(value, ctx);
255
246
  }
256
- if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
247
+ if (!value ||
248
+ /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
257
249
  // not allowed:
258
- // - '-' or '?'
250
+ // - empty string, '-' or '?'
259
251
  // - start with an indicator character (except [?:-]) or /[?-] /
260
252
  // - '\n ', ': ' or ' \n' anywhere
261
253
  // - '#' not preceded by a non-space char
@@ -1,8 +1,8 @@
1
1
  export { createNode } from './doc/createNode.js';
2
2
  export { debug, warn } from './log.js';
3
3
  export { createPair } from './nodes/Pair.js';
4
- export { toJS } from './nodes/toJS.js';
5
4
  export { findPair } from './nodes/YAMLMap.js';
5
+ export { toJS } from './nodes/toJS.js';
6
6
  export { map as mapTag } from './schema/common/map.js';
7
7
  export { seq as seqTag } from './schema/common/seq.js';
8
8
  export { string as stringTag } from './schema/common/string.js';
@@ -1,4 +1,4 @@
1
- export declare const help = "yaml: A command-line YAML processor and inspector\n\nReads stdin and writes output to stdout and errors & warnings to stderr.\n\nUsage:\n yaml Process a YAML stream, outputting it as YAML\n yaml cst Parse the CST of a YAML stream\n yaml lex Parse the lexical tokens of a YAML stream\n yaml valid Validate a YAML stream, returning 0 on success\n\nOptions:\n --help, -h Show this message.\n --json, -j Output JSON.\n --indent 2 Output pretty-printed data, indented by the given number of spaces.\n --merge, -m Enable support for \"<<\" merge keys.\n\nAdditional options for bare \"yaml\" command:\n --doc, -d Output pretty-printed JS Document objects.\n --single, -1 Require the input to consist of a single YAML document.\n --strict, -s Stop on errors.\n --visit, -v Apply a visitor to each document (requires a path to import)\n --yaml 1.1 Set the YAML version. (default: 1.2)";
1
+ export declare const help = "yaml: A command-line YAML processor and inspector\n\nReads stdin and writes output to stdout and errors & warnings to stderr.\n\nUsage:\n yaml Process a YAML stream, outputting it as YAML\n yaml cst Parse the CST of a YAML stream\n yaml lex Parse the lexical tokens of a YAML stream\n yaml valid Validate a YAML stream, returning 0 on success\n\nOptions:\n --help, -h Show this message.\n --json, -j Output JSON.\n --indent 2 Output pretty-printed data, indented by the given number of spaces.\n\nAdditional options for bare \"yaml\" command:\n --doc, -d Output pretty-printed JS Document objects.\n --single, -1 Require the input to consist of a single YAML document.\n --strict, -s Stop on errors.\n --visit, -v Apply a visitor to each document (requires a path to import)\n --yaml 1.1 Set the YAML version. (default: 1.2)";
2
2
  export declare class UserError extends Error {
3
3
  static ARGS: number;
4
4
  static SINGLE: number;