@speclynx/apidom-parser-adapter-yaml-1-2 4.9.1 → 4.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.10.1](https://github.com/speclynx/apidom/compare/v4.10.0...v4.10.1) (2026-05-20)
7
+
8
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-yaml-1-2
9
+
10
+ # [4.10.0](https://github.com/speclynx/apidom/compare/v4.9.1...v4.10.0) (2026-05-12)
11
+
12
+ **Note:** Version bump only for package @speclynx/apidom-parser-adapter-yaml-1-2
13
+
6
14
  ## [4.9.1](https://github.com/speclynx/apidom/compare/v4.9.0...v4.9.1) (2026-04-21)
7
15
 
8
16
  **Note:** Version bump only for package @speclynx/apidom-parser-adapter-yaml-1-2
@@ -12569,8 +12569,10 @@ class Composer {
12569
12569
  }
12570
12570
  }
12571
12571
  if (afterDoc) {
12572
- Array.prototype.push.apply(doc.errors, this.errors);
12573
- Array.prototype.push.apply(doc.warnings, this.warnings);
12572
+ for (let i = 0; i < this.errors.length; ++i)
12573
+ doc.errors.push(this.errors[i]);
12574
+ for (let i = 0; i < this.warnings.length; ++i)
12575
+ doc.warnings.push(this.warnings[i]);
12574
12576
  }
12575
12577
  else {
12576
12578
  doc.errors = this.errors;
@@ -13532,7 +13534,7 @@ function doubleQuotedValue(source, onError) {
13532
13534
  next = source[++i + 1];
13533
13535
  }
13534
13536
  else if (next === 'x' || next === 'u' || next === 'U') {
13535
- const length = { x: 2, u: 4, U: 8 }[next];
13537
+ const length = next === 'x' ? 2 : next === 'u' ? 4 : 8;
13536
13538
  res += parseCharCode(source, i + 1, length, onError);
13537
13539
  i += length;
13538
13540
  }
@@ -13602,12 +13604,14 @@ function parseCharCode(source, offset, length, onError) {
13602
13604
  const cc = source.substr(offset, length);
13603
13605
  const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
13604
13606
  const code = ok ? parseInt(cc, 16) : NaN;
13605
- if (isNaN(code)) {
13607
+ try {
13608
+ return String.fromCodePoint(code);
13609
+ }
13610
+ catch {
13606
13611
  const raw = source.substr(offset - 2, length + 2);
13607
13612
  onError(offset - 2, 'BAD_DQ_ESCAPE', `Invalid escape sequence ${raw}`);
13608
13613
  return raw;
13609
13614
  }
13610
- return String.fromCodePoint(code);
13611
13615
  }
13612
13616
 
13613
13617
 
@@ -14920,6 +14924,8 @@ class Alias extends _Node_js__WEBPACK_IMPORTED_MODULE_3__.NodeBase {
14920
14924
  * instance of the `source` anchor before this node.
14921
14925
  */
14922
14926
  resolve(doc, ctx) {
14927
+ if (ctx?.maxAliasCount === 0)
14928
+ throw new ReferenceError('Alias resolution is disabled');
14923
14929
  let nodes;
14924
14930
  if (ctx?.aliasResolveCache) {
14925
14931
  nodes = ctx.aliasResolveCache;
@@ -16674,7 +16680,7 @@ class Lexer {
16674
16680
  const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
16675
16681
  this.indentNext = this.indentValue + 1;
16676
16682
  this.indentValue += n;
16677
- return yield* this.parseBlockStart();
16683
+ return 'block-start';
16678
16684
  }
16679
16685
  return 'doc';
16680
16686
  }
@@ -16995,32 +17001,36 @@ class Lexer {
16995
17001
  return 0;
16996
17002
  }
16997
17003
  *pushIndicators() {
16998
- switch (this.charAt(0)) {
16999
- case '!':
17000
- return ((yield* this.pushTag()) +
17001
- (yield* this.pushSpaces(true)) +
17002
- (yield* this.pushIndicators()));
17003
- case '&':
17004
- return ((yield* this.pushUntil(isNotAnchorChar)) +
17005
- (yield* this.pushSpaces(true)) +
17006
- (yield* this.pushIndicators()));
17007
- case '-': // this is an error
17008
- case '?': // this is an error outside flow collections
17009
- case ':': {
17010
- const inFlow = this.flowLevel > 0;
17011
- const ch1 = this.charAt(1);
17012
- if (isEmpty(ch1) || (inFlow && flowIndicatorChars.has(ch1))) {
17013
- if (!inFlow)
17014
- this.indentNext = this.indentValue + 1;
17015
- else if (this.flowKey)
17016
- this.flowKey = false;
17017
- return ((yield* this.pushCount(1)) +
17018
- (yield* this.pushSpaces(true)) +
17019
- (yield* this.pushIndicators()));
17004
+ let n = 0;
17005
+ loop: while (true) {
17006
+ switch (this.charAt(0)) {
17007
+ case '!':
17008
+ n += yield* this.pushTag();
17009
+ n += yield* this.pushSpaces(true);
17010
+ continue loop;
17011
+ case '&':
17012
+ n += yield* this.pushUntil(isNotAnchorChar);
17013
+ n += yield* this.pushSpaces(true);
17014
+ continue loop;
17015
+ case '-': // this is an error
17016
+ case '?': // this is an error outside flow collections
17017
+ case ':': {
17018
+ const inFlow = this.flowLevel > 0;
17019
+ const ch1 = this.charAt(1);
17020
+ if (isEmpty(ch1) || (inFlow && flowIndicatorChars.has(ch1))) {
17021
+ if (!inFlow)
17022
+ this.indentNext = this.indentValue + 1;
17023
+ else if (this.flowKey)
17024
+ this.flowKey = false;
17025
+ n += yield* this.pushCount(1);
17026
+ n += yield* this.pushSpaces(true);
17027
+ continue loop;
17028
+ }
17020
17029
  }
17021
17030
  }
17031
+ break loop;
17022
17032
  }
17023
- return 0;
17033
+ return n;
17024
17034
  }
17025
17035
  *pushTag() {
17026
17036
  if (this.charAt(1) === '<') {
@@ -17213,6 +17223,14 @@ function getFirstKeyStartProps(prev) {
17213
17223
  }
17214
17224
  return prev.splice(i, prev.length);
17215
17225
  }
17226
+ function arrayPushArray(target, source) {
17227
+ // May exhaust call stack with large `source` array
17228
+ if (source.length < 1e5)
17229
+ Array.prototype.push.apply(target, source);
17230
+ else
17231
+ for (let i = 0; i < source.length; ++i)
17232
+ target.push(source[i]);
17233
+ }
17216
17234
  function fixFlowSeqItems(fc) {
17217
17235
  if (fc.start.type === 'flow-seq-start') {
17218
17236
  for (const it of fc.items) {
@@ -17225,12 +17243,12 @@ function fixFlowSeqItems(fc) {
17225
17243
  delete it.key;
17226
17244
  if (isFlowToken(it.value)) {
17227
17245
  if (it.value.end)
17228
- Array.prototype.push.apply(it.value.end, it.sep);
17246
+ arrayPushArray(it.value.end, it.sep);
17229
17247
  else
17230
17248
  it.value.end = it.sep;
17231
17249
  }
17232
17250
  else
17233
- Array.prototype.push.apply(it.start, it.sep);
17251
+ arrayPushArray(it.start, it.sep);
17234
17252
  delete it.sep;
17235
17253
  }
17236
17254
  }
@@ -17648,7 +17666,7 @@ class Parser {
17648
17666
  const prev = map.items[map.items.length - 2];
17649
17667
  const end = prev?.value?.end;
17650
17668
  if (Array.isArray(end)) {
17651
- Array.prototype.push.apply(end, it.start);
17669
+ arrayPushArray(end, it.start);
17652
17670
  end.push(this.sourceToken);
17653
17671
  map.items.pop();
17654
17672
  return;
@@ -17863,7 +17881,7 @@ class Parser {
17863
17881
  const prev = seq.items[seq.items.length - 2];
17864
17882
  const end = prev?.value?.end;
17865
17883
  if (Array.isArray(end)) {
17866
- Array.prototype.push.apply(end, it.start);
17884
+ arrayPushArray(end, it.start);
17867
17885
  end.push(this.sourceToken);
17868
17886
  seq.items.pop();
17869
17887
  return;
@@ -19099,18 +19117,18 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
19099
19117
  merge.identify(key.value))) &&
19100
19118
  ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
19101
19119
  function addMergeToJSMap(ctx, map, value) {
19102
- value = ctx && (0,_nodes_identity_js__WEBPACK_IMPORTED_MODULE_0__.isAlias)(value) ? value.resolve(ctx.doc) : value;
19103
- if ((0,_nodes_identity_js__WEBPACK_IMPORTED_MODULE_0__.isSeq)(value))
19104
- for (const it of value.items)
19120
+ const source = resolveAliasValue(ctx, value);
19121
+ if ((0,_nodes_identity_js__WEBPACK_IMPORTED_MODULE_0__.isSeq)(source))
19122
+ for (const it of source.items)
19105
19123
  mergeValue(ctx, map, it);
19106
- else if (Array.isArray(value))
19107
- for (const it of value)
19124
+ else if (Array.isArray(source))
19125
+ for (const it of source)
19108
19126
  mergeValue(ctx, map, it);
19109
19127
  else
19110
- mergeValue(ctx, map, value);
19128
+ mergeValue(ctx, map, source);
19111
19129
  }
19112
19130
  function mergeValue(ctx, map, value) {
19113
- const source = ctx && (0,_nodes_identity_js__WEBPACK_IMPORTED_MODULE_0__.isAlias)(value) ? value.resolve(ctx.doc) : value;
19131
+ const source = resolveAliasValue(ctx, value);
19114
19132
  if (!(0,_nodes_identity_js__WEBPACK_IMPORTED_MODULE_0__.isMap)(source))
19115
19133
  throw new Error('Merge sources must be maps or map aliases');
19116
19134
  const srcMap = source.toJSON(null, ctx, Map);
@@ -19133,6 +19151,9 @@ function mergeValue(ctx, map, value) {
19133
19151
  }
19134
19152
  return map;
19135
19153
  }
19154
+ function resolveAliasValue(ctx, value) {
19155
+ return ctx && (0,_nodes_identity_js__WEBPACK_IMPORTED_MODULE_0__.isAlias)(value) ? value.resolve(ctx.doc, ctx) : value;
19156
+ }
19136
19157
 
19137
19158
 
19138
19159
 
@@ -20243,7 +20264,8 @@ function stringifyNumber({ format, minFractionDigits, tag, value }) {
20243
20264
  if (!format &&
20244
20265
  minFractionDigits &&
20245
20266
  (!tag || tag === 'tag:yaml.org,2002:float') &&
20246
- /^\d/.test(n)) {
20267
+ /^-?\d/.test(n) &&
20268
+ !n.includes('e')) {
20247
20269
  let i = n.indexOf('.');
20248
20270
  if (i < 0) {
20249
20271
  i = n.length;