node_modules: upgrade

This commit is contained in:
Dawid Dziurla
2024-01-17 10:08:10 +01:00
parent 9ff0bc8d99
commit 00765f79cf
320 changed files with 31840 additions and 1039 deletions

View File

@@ -1,10 +1,9 @@
import { Alias } from '../nodes/Alias.js';
import { isEmptyPath, collectionFromPath } from '../nodes/Collection.js';
import { NODE_TYPE, DOC, isNode, isCollection, isScalar } from '../nodes/Node.js';
import { NODE_TYPE, DOC, isNode, isCollection, isScalar } from '../nodes/identity.js';
import { Pair } from '../nodes/Pair.js';
import { toJS } from '../nodes/toJS.js';
import { Schema } from '../schema/Schema.js';
import { stringify } from '../stringify/stringify.js';
import { stringifyDocument } from '../stringify/stringifyDocument.js';
import { anchorNames, findNewAnchor, createNodeAnchors } from './anchors.js';
import { applyReviver } from './applyReviver.js';
@@ -49,11 +48,9 @@ class Document {
else
this.directives = new Directives({ version });
this.setSchema(version, options);
if (value === undefined)
this.contents = null;
else {
this.contents = this.createNode(value, _replacer, options);
}
// @ts-expect-error We can't really know that this matches Contents.
this.contents =
value === undefined ? null : this.createNode(value, _replacer, options);
}
/**
* Create a deep copy of this Document and its contents.
@@ -72,6 +69,7 @@ class Document {
if (this.directives)
copy.directives = this.directives.clone();
copy.schema = this.schema.clone();
// @ts-expect-error We can't really know that this matches Contents.
copy.contents = isNode(this.contents)
? this.contents.clone(copy.schema)
: this.contents;
@@ -167,6 +165,7 @@ class Document {
if (isEmptyPath(path)) {
if (this.contents == null)
return false;
// @ts-expect-error Presumed impossible if Strict extends false
this.contents = null;
return true;
}
@@ -218,6 +217,7 @@ class Document {
*/
set(key, value) {
if (this.contents == null) {
// @ts-expect-error We can't really know that this matches Contents.
this.contents = collectionFromPath(this.schema, [key], value);
}
else if (assertCollection(this.contents)) {
@@ -229,9 +229,12 @@ class Document {
* boolean to add/remove the item from the set.
*/
setIn(path, value) {
if (isEmptyPath(path))
if (isEmptyPath(path)) {
// @ts-expect-error We can't really know that this matches Contents.
this.contents = value;
}
else if (this.contents == null) {
// @ts-expect-error We can't really know that this matches Contents.
this.contents = collectionFromPath(this.schema, Array.from(path), value);
}
else if (assertCollection(this.contents)) {
@@ -291,8 +294,7 @@ class Document {
keep: !json,
mapAsMap: mapAsMap === true,
mapKeyWarned: false,
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100,
stringify
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
};
const res = toJS(this.contents, jsonArg ?? '', ctx);
if (typeof onAnchor === 'function')

View File

@@ -1,4 +1,4 @@
import { isScalar, isCollection } from '../nodes/Node.js';
import { isScalar, isCollection } from '../nodes/identity.js';
import { visit } from '../visit.js';
/**

View File

@@ -1,5 +1,5 @@
import { Alias } from '../nodes/Alias.js';
import { isNode, isPair, MAP, SEQ, isDocument } from '../nodes/Node.js';
import { isNode, isPair, MAP, SEQ, isDocument } from '../nodes/identity.js';
import { Scalar } from '../nodes/Scalar.js';
const defaultTagPrefix = 'tag:yaml.org,2002:';
@@ -74,9 +74,13 @@ function createNode(value, tagName, ctx) {
}
const node = tagObj?.createNode
? tagObj.createNode(ctx.schema, value, ctx)
: new Scalar(value);
: typeof tagObj?.nodeClass?.from === 'function'
? tagObj.nodeClass.from(ctx.schema, value, ctx)
: new Scalar(value);
if (tagName)
node.tag = tagName;
else if (!tagObj.default)
node.tag = tagObj.tag;
if (ref)
ref.node = node;
return node;

View File

@@ -1,4 +1,4 @@
import { isNode } from '../nodes/Node.js';
import { isNode } from '../nodes/identity.js';
import { visit } from '../visit.js';
const escapeChars = {
@@ -116,12 +116,19 @@ class Directives {
onError('Verbatim tags must end with a >');
return verbatim;
}
const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/);
const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s);
if (!suffix)
onError(`The ${source} tag has no suffix`);
const prefix = this.tags[handle];
if (prefix)
return prefix + decodeURIComponent(suffix);
if (prefix) {
try {
return prefix + decodeURIComponent(suffix);
}
catch (error) {
onError(String(error));
return null;
}
}
if (handle === '!')
return source; // local tag
onError(`Could not resolve tag: ${source}`);