@@ -104945,14 +104945,6 @@ module.exports = require("net");
104945
104945
104946
104946
/***/ }),
104947
104947
104948
- /***/ 4573:
104949
- /***/ ((module) => {
104950
-
104951
- "use strict";
104952
- module.exports = require("node:buffer");
104953
-
104954
- /***/ }),
104955
-
104956
104948
/***/ 77598:
104957
104949
/***/ ((module) => {
104958
104950
@@ -104969,14 +104961,6 @@ module.exports = require("node:events");
104969
104961
104970
104962
/***/ }),
104971
104963
104972
- /***/ 1708:
104973
- /***/ ((module) => {
104974
-
104975
- "use strict";
104976
- module.exports = require("node:process");
104977
-
104978
- /***/ }),
104979
-
104980
104964
/***/ 57075:
104981
104965
/***/ ((module) => {
104982
104966
@@ -107104,7 +107088,7 @@ exports.composeScalar = composeScalar;
107104
107088
"use strict";
107105
107089
107106
107090
107107
- var node_process = __nccwpck_require__(1708 );
107091
+ var node_process = __nccwpck_require__(932 );
107108
107092
var directives = __nccwpck_require__(61342);
107109
107093
var Document = __nccwpck_require__(3021);
107110
107094
var errors = __nccwpck_require__(91464);
@@ -108297,8 +108281,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
108297
108281
if (token.source.endsWith(':'))
108298
108282
onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true);
108299
108283
anchor = token;
108300
- if (start === null)
108301
- start = token.offset;
108284
+ start ?? (start = token.offset);
108302
108285
atNewline = false;
108303
108286
hasSpace = false;
108304
108287
reqSpace = true;
@@ -108307,8 +108290,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIn
108307
108290
if (tag)
108308
108291
onError(token, 'MULTIPLE_TAGS', 'A node can have at most one tag');
108309
108292
tag = token;
108310
- if (start === null)
108311
- start = token.offset;
108293
+ start ?? (start = token.offset);
108312
108294
atNewline = false;
108313
108295
hasSpace = false;
108314
108296
reqSpace = true;
@@ -108427,8 +108409,7 @@ exports.containsNewline = containsNewline;
108427
108409
108428
108410
function emptyScalarPosition(offset, before, pos) {
108429
108411
if (before) {
108430
- if (pos === null)
108431
- pos = before.length;
108412
+ pos ?? (pos = before.length);
108432
108413
for (let i = pos - 1; i >= 0; --i) {
108433
108414
let st = before[i];
108434
108415
switch (st.type) {
@@ -108896,8 +108877,7 @@ function createNodeAnchors(doc, prefix) {
108896
108877
return {
108897
108878
onAnchor: (source) => {
108898
108879
aliasObjects.push(source);
108899
- if (!prevAnchors)
108900
- prevAnchors = anchorNames(doc);
108880
+ prevAnchors ?? (prevAnchors = anchorNames(doc));
108901
108881
const anchor = findNewAnchor(prefix, prevAnchors);
108902
108882
prevAnchors.add(anchor);
108903
108883
return anchor;
@@ -109045,8 +109025,7 @@ function createNode(value, tagName, ctx) {
109045
109025
if (aliasDuplicateObjects && value && typeof value === 'object') {
109046
109026
ref = sourceObjects.get(value);
109047
109027
if (ref) {
109048
- if (!ref.anchor)
109049
- ref.anchor = onAnchor(value);
109028
+ ref.anchor ?? (ref.anchor = onAnchor(value));
109050
109029
return new Alias.Alias(ref.anchor);
109051
109030
}
109052
109031
else {
@@ -109418,7 +109397,7 @@ exports.visitAsync = visit.visitAsync;
109418
109397
"use strict";
109419
109398
109420
109399
109421
- var node_process = __nccwpck_require__(1708 );
109400
+ var node_process = __nccwpck_require__(932 );
109422
109401
109423
109402
function debug(logLevel, ...messages) {
109424
109403
if (logLevel === 'debug')
@@ -109465,23 +109444,36 @@ class Alias extends Node.NodeBase {
109465
109444
* Resolve the value of this alias within `doc`, finding the last
109466
109445
* instance of the `source` anchor before this node.
109467
109446
*/
109468
- resolve(doc) {
109447
+ resolve(doc, ctx) {
109448
+ let nodes;
109449
+ if (ctx?.aliasResolveCache) {
109450
+ nodes = ctx.aliasResolveCache;
109451
+ }
109452
+ else {
109453
+ nodes = [];
109454
+ visit.visit(doc, {
109455
+ Node: (_key, node) => {
109456
+ if (identity.isAlias(node) || identity.hasAnchor(node))
109457
+ nodes.push(node);
109458
+ }
109459
+ });
109460
+ if (ctx)
109461
+ ctx.aliasResolveCache = nodes;
109462
+ }
109469
109463
let found = undefined;
109470
- visit.visit(doc, {
109471
- Node: (_key, node) => {
109472
- if (node === this)
109473
- return visit.visit.BREAK;
109474
- if (node.anchor === this.source)
109475
- found = node;
109476
- }
109477
- });
109464
+ for (const node of nodes) {
109465
+ if (node === this)
109466
+ break;
109467
+ if (node.anchor === this.source)
109468
+ found = node;
109469
+ }
109478
109470
return found;
109479
109471
}
109480
109472
toJSON(_arg, ctx) {
109481
109473
if (!ctx)
109482
109474
return { source: this.source };
109483
109475
const { anchors, doc, maxAliasCount } = ctx;
109484
- const source = this.resolve(doc);
109476
+ const source = this.resolve(doc, ctx );
109485
109477
if (!source) {
109486
109478
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
109487
109479
throw new ReferenceError(msg);
@@ -110162,6 +110154,7 @@ function addPairToJSMap(ctx, map, { key, value }) {
110162
110154
function stringifyKey(key, jsKey, ctx) {
110163
110155
if (jsKey === null)
110164
110156
return '';
110157
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
110165
110158
if (typeof jsKey !== 'object')
110166
110159
return String(jsKey);
110167
110160
if (identity.isNode(key) && ctx?.doc) {
@@ -111603,7 +111596,7 @@ exports.LineCounter = LineCounter;
111603
111596
"use strict";
111604
111597
111605
111598
111606
- var node_process = __nccwpck_require__(1708 );
111599
+ var node_process = __nccwpck_require__(932 );
111607
111600
var cst = __nccwpck_require__(3461);
111608
111601
var lexer = __nccwpck_require__(40361);
111609
111602
@@ -113194,7 +113187,7 @@ exports.getTags = getTags;
113194
113187
"use strict";
113195
113188
113196
113189
113197
- var node_buffer = __nccwpck_require__(4573 );
113190
+ var node_buffer = __nccwpck_require__(20181 );
113198
113191
var Scalar = __nccwpck_require__(63301);
113199
113192
var stringifyString = __nccwpck_require__(83069);
113200
113193
@@ -113247,8 +113240,7 @@ const binary = {
113247
113240
else {
113248
113241
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
113249
113242
}
113250
- if (!type)
113251
- type = Scalar.Scalar.BLOCK_LITERAL;
113243
+ type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
113252
113244
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
113253
113245
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
113254
113246
const n = Math.ceil(str.length / lineWidth);
@@ -114198,7 +114190,7 @@ function getTagObject(tags, item) {
114198
114190
tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
114199
114191
}
114200
114192
if (!tagObj) {
114201
- const name = obj?.constructor?.name ?? typeof obj;
114193
+ const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj) ;
114202
114194
throw new Error(`Tag not resolved for ${name} value`);
114203
114195
}
114204
114196
return tagObj;
@@ -114213,7 +114205,7 @@ function stringifyProps(node, tagObj, { anchors: anchors$1, doc }) {
114213
114205
anchors$1.add(anchor);
114214
114206
props.push(`&${anchor}`);
114215
114207
}
114216
- const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
114208
+ const tag = node.tag ?? ( tagObj.default ? null : tagObj.tag) ;
114217
114209
if (tag)
114218
114210
props.push(doc.directives.tagString(tag));
114219
114211
return props.join(' ');
@@ -114239,8 +114231,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
114239
114231
const node = identity.isNode(item)
114240
114232
? item
114241
114233
: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
114242
- if (!tagObj)
114243
- tagObj = getTagObject(ctx.doc.schema.tags, node);
114234
+ tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
114244
114235
const props = stringifyProps(node, tagObj, ctx);
114245
114236
if (props.length > 0)
114246
114237
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
@@ -114997,10 +114988,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
114997
114988
(inFlow && /[[\]{},]/.test(value))) {
114998
114989
return quotedString(value, ctx);
114999
114990
}
115000
- if (!value ||
115001
- /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
114991
+ if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
115002
114992
// not allowed:
115003
- // - empty string, '-' or '?'
114993
+ // - '-' or '?'
115004
114994
// - start with an indicator character (except [?:-]) or /[?-] /
115005
114995
// - '\n ', ': ' or ' \n' anywhere
115006
114996
// - '#' not preceded by a non-space char
0 commit comments