@@ -110627,14 +110627,6 @@ module.exports = require("net");
110627
110627
110628
110628
/***/ }),
110629
110629
110630
- /***/ 4573:
110631
- /***/ ((module) => {
110632
-
110633
- "use strict";
110634
- module.exports = require("node:buffer");
110635
-
110636
- /***/ }),
110637
-
110638
110630
/***/ 77598:
110639
110631
/***/ ((module) => {
110640
110632
@@ -110651,14 +110643,6 @@ module.exports = require("node:events");
110651
110643
110652
110644
/***/ }),
110653
110645
110654
- /***/ 1708:
110655
- /***/ ((module) => {
110656
-
110657
- "use strict";
110658
- module.exports = require("node:process");
110659
-
110660
- /***/ }),
110661
-
110662
110646
/***/ 57075:
110663
110647
/***/ ((module) => {
110664
110648
@@ -112786,7 +112770,7 @@ exports.composeScalar = composeScalar;
112786
112770
"use strict";
112787
112771
112788
112772
112789
- var node_process = __nccwpck_require__(1708 );
112773
+ var node_process = __nccwpck_require__(932 );
112790
112774
var directives = __nccwpck_require__(61342);
112791
112775
var Document = __nccwpck_require__(3021);
112792
112776
var errors = __nccwpck_require__(91464);
@@ -113979,8 +113963,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
113979
113963
if (token.source.endsWith(':'))
113980
113964
onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
113981
113965
anchor = token;
113982
- if (start === null)
113983
- start = token.offset;
113966
+ start ?? (start = token.offset);
113984
113967
atNewline = false;
113985
113968
hasSpace = false;
113986
113969
reqSpace = true;
@@ -113989,8 +113972,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
113989
113972
if (tag)
113990
113973
onError(token, 'MULTIPLE_TAGS', 'A node can have at most one tag');
113991
113974
tag = token;
113992
- if (start === null)
113993
- start = token.offset;
113975
+ start ?? (start = token.offset);
113994
113976
atNewline = false;
113995
113977
hasSpace = false;
113996
113978
reqSpace = true;
@@ -114109,8 +114091,7 @@ exports.containsNewline = containsNewline;
114109
114091
114110
114092
function emptyScalarPosition(offset, before, pos) {
114111
114093
if (before) {
114112
- if (pos === null)
114113
- pos = before.length;
114094
+ pos ?? (pos = before.length);
114114
114095
for (let i = pos - 1; i >= 0; --i) {
114115
114096
let st = before[i];
114116
114097
switch (st.type) {
@@ -114578,8 +114559,7 @@ function createNodeAnchors(doc, prefix) {
114578
114559
return {
114579
114560
onAnchor: (source) => {
114580
114561
aliasObjects.push(source);
114581
- if (!prevAnchors)
114582
- prevAnchors = anchorNames(doc);
114562
+ prevAnchors ?? (prevAnchors = anchorNames(doc));
114583
114563
const anchor = findNewAnchor(prefix, prevAnchors);
114584
114564
prevAnchors.add(anchor);
114585
114565
return anchor;
@@ -114727,8 +114707,7 @@ function createNode(value, tagName, ctx) {
114727
114707
if (aliasDuplicateObjects && value && typeof value === 'object') {
114728
114708
ref = sourceObjects.get(value);
114729
114709
if (ref) {
114730
- if (!ref.anchor)
114731
- ref.anchor = onAnchor(value);
114710
+ ref.anchor ?? (ref.anchor = onAnchor(value));
114732
114711
return new Alias.Alias(ref.anchor);
114733
114712
}
114734
114713
else {
@@ -115100,7 +115079,7 @@ exports.visitAsync = visit.visitAsync;
115100
115079
"use strict";
115101
115080
115102
115081
115103
- var node_process = __nccwpck_require__(1708 );
115082
+ var node_process = __nccwpck_require__(932 );
115104
115083
115105
115084
function debug(logLevel, ...messages) {
115106
115085
if (logLevel === 'debug')
@@ -115147,23 +115126,36 @@ class Alias extends Node.NodeBase {
115147
115126
* Resolve the value of this alias within `doc`, finding the last
115148
115127
* instance of the `source` anchor before this node.
115149
115128
*/
115150
- resolve(doc) {
115129
+ resolve(doc, ctx) {
115130
+ let nodes;
115131
+ if (ctx?.aliasResolveCache) {
115132
+ nodes = ctx.aliasResolveCache;
115133
+ }
115134
+ else {
115135
+ nodes = [];
115136
+ visit.visit(doc, {
115137
+ Node: (_key, node) => {
115138
+ if (identity.isAlias(node) || identity.hasAnchor(node))
115139
+ nodes.push(node);
115140
+ }
115141
+ });
115142
+ if (ctx)
115143
+ ctx.aliasResolveCache = nodes;
115144
+ }
115151
115145
let found = undefined;
115152
- visit.visit(doc, {
115153
- Node: (_key, node) => {
115154
- if (node === this)
115155
- return visit.visit.BREAK;
115156
- if (node.anchor === this.source)
115157
- found = node;
115158
- }
115159
- });
115146
+ for (const node of nodes) {
115147
+ if (node === this)
115148
+ break;
115149
+ if (node.anchor === this.source)
115150
+ found = node;
115151
+ }
115160
115152
return found;
115161
115153
}
115162
115154
toJSON(_arg, ctx) {
115163
115155
if (!ctx)
115164
115156
return { source: this.source };
115165
115157
const { anchors, doc, maxAliasCount } = ctx;
115166
- const source = this.resolve(doc);
115158
+ const source = this.resolve(doc, ctx );
115167
115159
if (!source) {
115168
115160
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
115169
115161
throw new ReferenceError(msg);
@@ -115844,6 +115836,7 @@ function addPairToJSMap(ctx, map, { key, value }) {
115844
115836
function stringifyKey(key, jsKey, ctx) {
115845
115837
if (jsKey === null)
115846
115838
return '';
115839
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
115847
115840
if (typeof jsKey !== 'object')
115848
115841
return String(jsKey);
115849
115842
if (identity.isNode(key) && ctx?.doc) {
@@ -117285,7 +117278,7 @@ exports.LineCounter = LineCounter;
117285
117278
"use strict";
117286
117279
117287
117280
117288
- var node_process = __nccwpck_require__(1708 );
117281
+ var node_process = __nccwpck_require__(932 );
117289
117282
var cst = __nccwpck_require__(3461);
117290
117283
var lexer = __nccwpck_require__(40361);
117291
117284
@@ -118876,7 +118869,7 @@ exports.getTags = getTags;
118876
118869
"use strict";
118877
118870
118878
118871
118879
- var node_buffer = __nccwpck_require__(4573 );
118872
+ var node_buffer = __nccwpck_require__(20181 );
118880
118873
var Scalar = __nccwpck_require__(63301);
118881
118874
var stringifyString = __nccwpck_require__(83069);
118882
118875
@@ -118929,8 +118922,7 @@ const binary = {
118929
118922
else {
118930
118923
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
118931
118924
}
118932
- if (!type)
118933
- type = Scalar.Scalar.BLOCK_LITERAL;
118925
+ type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
118934
118926
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
118935
118927
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
118936
118928
const n = Math.ceil(str.length / lineWidth);
@@ -119880,7 +119872,7 @@ function getTagObject(tags, item) {
119880
119872
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
119881
119873
}
119882
119874
if (!tagObj) {
119883
- const name = obj?.constructor?.name ?? typeof obj;
119875
+ const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj) ;
119884
119876
throw new Error(`Tag not resolved for ${name} value`);
119885
119877
}
119886
119878
return tagObj;
@@ -119895,7 +119887,7 @@ function stringifyProps(node, tagObj, { anchors: anchors$1, doc }) {
119895
119887
anchors$1.add(anchor);
119896
119888
props.push(`&${anchor}`);
119897
119889
}
119898
- const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
119890
+ const tag = node.tag ?? ( tagObj.default ? null : tagObj.tag) ;
119899
119891
if (tag)
119900
119892
props.push(doc.directives.tagString(tag));
119901
119893
return props.join(' ');
@@ -119921,8 +119913,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
119921
119913
const node = identity.isNode(item)
119922
119914
? item
119923
119915
: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
119924
- if (!tagObj)
119925
- tagObj = getTagObject(ctx.doc.schema.tags, node);
119916
+ tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
119926
119917
const props = stringifyProps(node, tagObj, ctx);
119927
119918
if (props.length > 0)
119928
119919
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
@@ -120679,10 +120670,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
120679
120670
(inFlow && /[[\]{},]/.test(value))) {
120680
120671
return quotedString(value, ctx);
120681
120672
}
120682
- if (!value ||
120683
- /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
120673
+ if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
120684
120674
// not allowed:
120685
- // - empty string, '-' or '?'
120675
+ // - '-' or '?'
120686
120676
// - start with an indicator character (except [?:-]) or /[?-] /
120687
120677
// - '\n ', ': ' or ' \n' anywhere
120688
120678
// - '#' not preceded by a non-space char
0 commit comments