node_modules: upgrade

This commit is contained in:
Dawid Dziurla
2025-06-14 23:18:18 +02:00
parent 948e4a4fb8
commit de40b1f21f
268 changed files with 2150 additions and 3858 deletions

View File

@@ -1,6 +1,6 @@
import { anchorIsValid } from '../doc/anchors.js';
import { visit } from '../visit.js';
import { ALIAS, isAlias, isCollection, isPair } from './identity.js';
import { ALIAS, isAlias, isCollection, isPair, hasAnchor } from './identity.js';
import { NodeBase } from './Node.js';
import { toJS } from './toJS.js';
@@ -18,23 +18,36 @@ class Alias extends NodeBase {
* Resolve the value of this alias within `doc`, finding the last
* instance of the `source` anchor before this node.
*/
resolve(doc) {
resolve(doc, ctx) {
let nodes;
if (ctx?.aliasResolveCache) {
nodes = ctx.aliasResolveCache;
}
else {
nodes = [];
visit(doc, {
Node: (_key, node) => {
if (isAlias(node) || hasAnchor(node))
nodes.push(node);
}
});
if (ctx)
ctx.aliasResolveCache = nodes;
}
let found = undefined;
visit(doc, {
Node: (_key, node) => {
if (node === this)
return visit.BREAK;
if (node.anchor === this.source)
found = node;
}
});
for (const node of nodes) {
if (node === this)
break;
if (node.anchor === this.source)
found = node;
}
return found;
}
toJSON(_arg, ctx) {
if (!ctx)
return { source: this.source };
const { anchors, doc, maxAliasCount } = ctx;
const source = this.resolve(doc);
const source = this.resolve(doc, ctx);
if (!source) {
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
throw new ReferenceError(msg);