mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2025-12-09 22:30:41 -07:00
node_modules: upgrade
This commit is contained in:
2
node_modules/yaml/dist/nodes/Alias.d.ts
generated
vendored
2
node_modules/yaml/dist/nodes/Alias.d.ts
generated
vendored
@@ -3,7 +3,7 @@ import type { FlowScalar } from '../parse/cst.js';
|
||||
import type { StringifyContext } from '../stringify/stringify.js';
|
||||
import { NodeBase, Range } from './Node.js';
|
||||
import type { Scalar } from './Scalar';
|
||||
import type { ToJSContext } from './toJS.js';
|
||||
import { ToJSContext } from './toJS.js';
|
||||
import type { YAMLMap } from './YAMLMap.js';
|
||||
import type { YAMLSeq } from './YAMLSeq.js';
|
||||
export declare namespace Alias {
|
||||
|
||||
17
node_modules/yaml/dist/nodes/Alias.js
generated
vendored
17
node_modules/yaml/dist/nodes/Alias.js
generated
vendored
@@ -2,11 +2,13 @@
|
||||
|
||||
var anchors = require('../doc/anchors.js');
|
||||
var visit = require('../visit.js');
|
||||
var identity = require('./identity.js');
|
||||
var Node = require('./Node.js');
|
||||
var toJS = require('./toJS.js');
|
||||
|
||||
class Alias extends Node.NodeBase {
|
||||
constructor(source) {
|
||||
super(Node.ALIAS);
|
||||
super(identity.ALIAS);
|
||||
this.source = source;
|
||||
Object.defineProperty(this, 'tag', {
|
||||
set() {
|
||||
@@ -39,7 +41,12 @@ class Alias extends Node.NodeBase {
|
||||
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
||||
throw new ReferenceError(msg);
|
||||
}
|
||||
const data = anchors.get(source);
|
||||
let data = anchors.get(source);
|
||||
if (!data) {
|
||||
// Resolve anchors for Node.prototype.toJS()
|
||||
toJS.toJS(source, null, ctx);
|
||||
data = anchors.get(source);
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
if (!data || data.res === undefined) {
|
||||
const msg = 'This should not happen: Alias anchor was not resolved?';
|
||||
@@ -71,12 +78,12 @@ class Alias extends Node.NodeBase {
|
||||
}
|
||||
}
|
||||
function getAliasCount(doc, node, anchors) {
|
||||
if (Node.isAlias(node)) {
|
||||
if (identity.isAlias(node)) {
|
||||
const source = node.resolve(doc);
|
||||
const anchor = anchors && source && anchors.get(source);
|
||||
return anchor ? anchor.count * anchor.aliasCount : 0;
|
||||
}
|
||||
else if (Node.isCollection(node)) {
|
||||
else if (identity.isCollection(node)) {
|
||||
let count = 0;
|
||||
for (const item of node.items) {
|
||||
const c = getAliasCount(doc, item, anchors);
|
||||
@@ -85,7 +92,7 @@ function getAliasCount(doc, node, anchors) {
|
||||
}
|
||||
return count;
|
||||
}
|
||||
else if (Node.isPair(node)) {
|
||||
else if (identity.isPair(node)) {
|
||||
const kc = getAliasCount(doc, node.key, anchors);
|
||||
const vc = getAliasCount(doc, node.value, anchors);
|
||||
return Math.max(kc, vc);
|
||||
|
||||
5
node_modules/yaml/dist/nodes/Collection.d.ts
generated
vendored
5
node_modules/yaml/dist/nodes/Collection.d.ts
generated
vendored
@@ -1,6 +1,7 @@
|
||||
import type { Schema } from '../schema/Schema.js';
|
||||
import { NodeBase, NODE_TYPE } from './Node.js';
|
||||
export declare function collectionFromPath(schema: Schema, path: unknown[], value: unknown): import("./Node.js").Node<unknown>;
|
||||
import { NODE_TYPE } from './identity.js';
|
||||
import { NodeBase } from './Node.js';
|
||||
export declare function collectionFromPath(schema: Schema, path: unknown[], value: unknown): import("./Node.js").Node;
|
||||
export declare const isEmptyPath: (path: Iterable<unknown> | null | undefined) => path is null | undefined;
|
||||
export declare abstract class Collection extends NodeBase {
|
||||
static maxFlowStringSingleLineLength: number;
|
||||
|
||||
19
node_modules/yaml/dist/nodes/Collection.js
generated
vendored
19
node_modules/yaml/dist/nodes/Collection.js
generated
vendored
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var createNode = require('../doc/createNode.js');
|
||||
var identity = require('./identity.js');
|
||||
var Node = require('./Node.js');
|
||||
|
||||
function collectionFromPath(schema, path, value) {
|
||||
@@ -49,7 +50,7 @@ class Collection extends Node.NodeBase {
|
||||
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
||||
if (schema)
|
||||
copy.schema = schema;
|
||||
copy.items = copy.items.map(it => Node.isNode(it) || Node.isPair(it) ? it.clone(schema) : it);
|
||||
copy.items = copy.items.map(it => identity.isNode(it) || identity.isPair(it) ? it.clone(schema) : it);
|
||||
if (this.range)
|
||||
copy.range = this.range.slice();
|
||||
return copy;
|
||||
@@ -65,7 +66,7 @@ class Collection extends Node.NodeBase {
|
||||
else {
|
||||
const [key, ...rest] = path;
|
||||
const node = this.get(key, true);
|
||||
if (Node.isCollection(node))
|
||||
if (identity.isCollection(node))
|
||||
node.addIn(rest, value);
|
||||
else if (node === undefined && this.schema)
|
||||
this.set(key, collectionFromPath(this.schema, rest, value));
|
||||
@@ -82,7 +83,7 @@ class Collection extends Node.NodeBase {
|
||||
if (rest.length === 0)
|
||||
return this.delete(key);
|
||||
const node = this.get(key, true);
|
||||
if (Node.isCollection(node))
|
||||
if (identity.isCollection(node))
|
||||
return node.deleteIn(rest);
|
||||
else
|
||||
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
||||
@@ -96,18 +97,18 @@ class Collection extends Node.NodeBase {
|
||||
const [key, ...rest] = path;
|
||||
const node = this.get(key, true);
|
||||
if (rest.length === 0)
|
||||
return !keepScalar && Node.isScalar(node) ? node.value : node;
|
||||
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
||||
else
|
||||
return Node.isCollection(node) ? node.getIn(rest, keepScalar) : undefined;
|
||||
return identity.isCollection(node) ? node.getIn(rest, keepScalar) : undefined;
|
||||
}
|
||||
hasAllNullValues(allowScalar) {
|
||||
return this.items.every(node => {
|
||||
if (!Node.isPair(node))
|
||||
if (!identity.isPair(node))
|
||||
return false;
|
||||
const n = node.value;
|
||||
return (n == null ||
|
||||
(allowScalar &&
|
||||
Node.isScalar(n) &&
|
||||
identity.isScalar(n) &&
|
||||
n.value == null &&
|
||||
!n.commentBefore &&
|
||||
!n.comment &&
|
||||
@@ -122,7 +123,7 @@ class Collection extends Node.NodeBase {
|
||||
if (rest.length === 0)
|
||||
return this.has(key);
|
||||
const node = this.get(key, true);
|
||||
return Node.isCollection(node) ? node.hasIn(rest) : false;
|
||||
return identity.isCollection(node) ? node.hasIn(rest) : false;
|
||||
}
|
||||
/**
|
||||
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
||||
@@ -135,7 +136,7 @@ class Collection extends Node.NodeBase {
|
||||
}
|
||||
else {
|
||||
const node = this.get(key, true);
|
||||
if (Node.isCollection(node))
|
||||
if (identity.isCollection(node))
|
||||
node.setIn(rest, value);
|
||||
else if (node === undefined && this.schema)
|
||||
this.set(key, collectionFromPath(this.schema, rest, value));
|
||||
|
||||
29
node_modules/yaml/dist/nodes/Node.d.ts
generated
vendored
29
node_modules/yaml/dist/nodes/Node.d.ts
generated
vendored
@@ -1,36 +1,21 @@
|
||||
import type { Document } from '../doc/Document.js';
|
||||
import type { ToJSOptions } from '../options.js';
|
||||
import { Token } from '../parse/cst.js';
|
||||
import type { StringifyContext } from '../stringify/stringify.js';
|
||||
import type { Alias } from './Alias.js';
|
||||
import type { Pair } from './Pair.js';
|
||||
import { NODE_TYPE } from './identity.js';
|
||||
import type { Scalar } from './Scalar.js';
|
||||
import type { YAMLMap } from './YAMLMap.js';
|
||||
import type { YAMLSeq } from './YAMLSeq.js';
|
||||
export declare type Node<T = unknown> = Alias | Scalar<T> | YAMLMap<unknown, T> | YAMLSeq<T>;
|
||||
export type Node<T = unknown> = Alias | Scalar<T> | YAMLMap<unknown, T> | YAMLSeq<T>;
|
||||
/** Utility type mapper */
|
||||
export declare type NodeType<T> = T extends string | number | bigint | boolean | null ? Scalar<T> : T extends Array<any> ? YAMLSeq<NodeType<T[number]>> : T extends {
|
||||
export type NodeType<T> = T extends string | number | bigint | boolean | null | undefined ? Scalar<T> : T extends Date ? Scalar<string | Date> : T extends Array<any> ? YAMLSeq<NodeType<T[number]>> : T extends {
|
||||
[key: string]: any;
|
||||
} ? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>> : T extends {
|
||||
[key: number]: any;
|
||||
} ? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>> : Node;
|
||||
export declare type ParsedNode = Alias.Parsed | Scalar.Parsed | YAMLMap.Parsed | YAMLSeq.Parsed;
|
||||
export declare type Range = [number, number, number];
|
||||
export declare const ALIAS: unique symbol;
|
||||
export declare const DOC: unique symbol;
|
||||
export declare const MAP: unique symbol;
|
||||
export declare const PAIR: unique symbol;
|
||||
export declare const SCALAR: unique symbol;
|
||||
export declare const SEQ: unique symbol;
|
||||
export declare const NODE_TYPE: unique symbol;
|
||||
export declare const isAlias: (node: any) => node is Alias;
|
||||
export declare const isDocument: <T extends Node<unknown> = Node<unknown>>(node: any) => node is Document<T>;
|
||||
export declare const isMap: <K = unknown, V = unknown>(node: any) => node is YAMLMap<K, V>;
|
||||
export declare const isPair: <K = unknown, V = unknown>(node: any) => node is Pair<K, V>;
|
||||
export declare const isScalar: <T = unknown>(node: any) => node is Scalar<T>;
|
||||
export declare const isSeq: <T = unknown>(node: any) => node is YAMLSeq<T>;
|
||||
export declare function isCollection<K = unknown, V = unknown>(node: any): node is YAMLMap<K, V> | YAMLSeq<V>;
|
||||
export declare function isNode<T = unknown>(node: any): node is Node<T>;
|
||||
export declare const hasAnchor: <K = unknown, V = unknown>(node: unknown) => node is Scalar<V> | YAMLMap<K, V> | YAMLSeq<V>;
|
||||
export type ParsedNode = Alias.Parsed | Scalar.Parsed | YAMLMap.Parsed | YAMLSeq.Parsed;
|
||||
export type Range = [number, number, number];
|
||||
export declare abstract class NodeBase {
|
||||
readonly [NODE_TYPE]: symbol;
|
||||
/** A comment on or immediately after this */
|
||||
@@ -56,4 +41,6 @@ export declare abstract class NodeBase {
|
||||
constructor(type: symbol);
|
||||
/** Create a copy of this node. */
|
||||
clone(): NodeBase;
|
||||
/** A plain JavaScript representation of this node. */
|
||||
toJS(doc: Document<Node, boolean>, { mapAsMap, maxAliasCount, onAnchor, reviver }?: ToJSOptions): any;
|
||||
}
|
||||
|
||||
76
node_modules/yaml/dist/nodes/Node.js
generated
vendored
76
node_modules/yaml/dist/nodes/Node.js
generated
vendored
@@ -1,42 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const ALIAS = Symbol.for('yaml.alias');
|
||||
const DOC = Symbol.for('yaml.document');
|
||||
const MAP = Symbol.for('yaml.map');
|
||||
const PAIR = Symbol.for('yaml.pair');
|
||||
const SCALAR = Symbol.for('yaml.scalar');
|
||||
const SEQ = Symbol.for('yaml.seq');
|
||||
const NODE_TYPE = Symbol.for('yaml.node.type');
|
||||
const isAlias = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === ALIAS;
|
||||
const isDocument = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === DOC;
|
||||
const isMap = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === MAP;
|
||||
const isPair = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === PAIR;
|
||||
const isScalar = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SCALAR;
|
||||
const isSeq = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SEQ;
|
||||
function isCollection(node) {
|
||||
if (node && typeof node === 'object')
|
||||
switch (node[NODE_TYPE]) {
|
||||
case MAP:
|
||||
case SEQ:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isNode(node) {
|
||||
if (node && typeof node === 'object')
|
||||
switch (node[NODE_TYPE]) {
|
||||
case ALIAS:
|
||||
case MAP:
|
||||
case SCALAR:
|
||||
case SEQ:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
||||
var applyReviver = require('../doc/applyReviver.js');
|
||||
var identity = require('./identity.js');
|
||||
var toJS = require('./toJS.js');
|
||||
|
||||
class NodeBase {
|
||||
constructor(type) {
|
||||
Object.defineProperty(this, NODE_TYPE, { value: type });
|
||||
Object.defineProperty(this, identity.NODE_TYPE, { value: type });
|
||||
}
|
||||
/** Create a copy of this node. */
|
||||
clone() {
|
||||
@@ -45,22 +15,26 @@ class NodeBase {
|
||||
copy.range = this.range.slice();
|
||||
return copy;
|
||||
}
|
||||
/** A plain JavaScript representation of this node. */
|
||||
toJS(doc, { mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
||||
if (!identity.isDocument(doc))
|
||||
throw new TypeError('A document argument is required');
|
||||
const ctx = {
|
||||
anchors: new Map(),
|
||||
doc,
|
||||
keep: true,
|
||||
mapAsMap: mapAsMap === true,
|
||||
mapKeyWarned: false,
|
||||
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
|
||||
};
|
||||
const res = toJS.toJS(this, '', ctx);
|
||||
if (typeof onAnchor === 'function')
|
||||
for (const { count, res } of ctx.anchors.values())
|
||||
onAnchor(res, count);
|
||||
return typeof reviver === 'function'
|
||||
? applyReviver.applyReviver(reviver, { '': res }, '', res)
|
||||
: res;
|
||||
}
|
||||
}
|
||||
|
||||
exports.ALIAS = ALIAS;
|
||||
exports.DOC = DOC;
|
||||
exports.MAP = MAP;
|
||||
exports.NODE_TYPE = NODE_TYPE;
|
||||
exports.NodeBase = NodeBase;
|
||||
exports.PAIR = PAIR;
|
||||
exports.SCALAR = SCALAR;
|
||||
exports.SEQ = SEQ;
|
||||
exports.hasAnchor = hasAnchor;
|
||||
exports.isAlias = isAlias;
|
||||
exports.isCollection = isCollection;
|
||||
exports.isDocument = isDocument;
|
||||
exports.isMap = isMap;
|
||||
exports.isNode = isNode;
|
||||
exports.isPair = isPair;
|
||||
exports.isScalar = isScalar;
|
||||
exports.isSeq = isSeq;
|
||||
|
||||
4
node_modules/yaml/dist/nodes/Pair.d.ts
generated
vendored
4
node_modules/yaml/dist/nodes/Pair.d.ts
generated
vendored
@@ -3,9 +3,9 @@ import type { CollectionItem } from '../parse/cst.js';
|
||||
import type { Schema } from '../schema/Schema.js';
|
||||
import type { StringifyContext } from '../stringify/stringify.js';
|
||||
import { addPairToJSMap } from './addPairToJSMap.js';
|
||||
import { NODE_TYPE } from './Node.js';
|
||||
import { NODE_TYPE } from './identity.js';
|
||||
import type { ToJSContext } from './toJS.js';
|
||||
export declare function createPair(key: unknown, value: unknown, ctx: CreateNodeContext): Pair<import("./Node.js").Node<unknown>, import("./Alias.js").Alias | import("./Scalar.js").Scalar<unknown> | import("./YAMLMap.js").YAMLMap<unknown, unknown> | import("./YAMLSeq.js").YAMLSeq<unknown>>;
|
||||
export declare function createPair(key: unknown, value: unknown, ctx: CreateNodeContext): Pair<import("./Node.js").Node, import("./YAMLMap.js").YAMLMap<unknown, unknown> | import("./Scalar.js").Scalar<unknown> | import("./Alias.js").Alias | import("./YAMLSeq.js").YAMLSeq<unknown>>;
|
||||
export declare class Pair<K = unknown, V = unknown> {
|
||||
readonly [NODE_TYPE]: symbol;
|
||||
/** Always Node or null when parsed, but can be set to anything. */
|
||||
|
||||
8
node_modules/yaml/dist/nodes/Pair.js
generated
vendored
8
node_modules/yaml/dist/nodes/Pair.js
generated
vendored
@@ -3,7 +3,7 @@
|
||||
var createNode = require('../doc/createNode.js');
|
||||
var stringifyPair = require('../stringify/stringifyPair.js');
|
||||
var addPairToJSMap = require('./addPairToJSMap.js');
|
||||
var Node = require('./Node.js');
|
||||
var identity = require('./identity.js');
|
||||
|
||||
function createPair(key, value, ctx) {
|
||||
const k = createNode.createNode(key, undefined, ctx);
|
||||
@@ -12,15 +12,15 @@ function createPair(key, value, ctx) {
|
||||
}
|
||||
class Pair {
|
||||
constructor(key, value = null) {
|
||||
Object.defineProperty(this, Node.NODE_TYPE, { value: Node.PAIR });
|
||||
Object.defineProperty(this, identity.NODE_TYPE, { value: identity.PAIR });
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
clone(schema) {
|
||||
let { key, value } = this;
|
||||
if (Node.isNode(key))
|
||||
if (identity.isNode(key))
|
||||
key = key.clone(schema);
|
||||
if (Node.isNode(value))
|
||||
if (identity.isNode(value))
|
||||
value = value.clone(schema);
|
||||
return new Pair(key, value);
|
||||
}
|
||||
|
||||
3
node_modules/yaml/dist/nodes/Scalar.js
generated
vendored
3
node_modules/yaml/dist/nodes/Scalar.js
generated
vendored
@@ -1,12 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
var identity = require('./identity.js');
|
||||
var Node = require('./Node.js');
|
||||
var toJS = require('./toJS.js');
|
||||
|
||||
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
||||
class Scalar extends Node.NodeBase {
|
||||
constructor(value) {
|
||||
super(Node.SCALAR);
|
||||
super(identity.SCALAR);
|
||||
this.value = value;
|
||||
}
|
||||
toJSON(arg, ctx) {
|
||||
|
||||
10
node_modules/yaml/dist/nodes/YAMLMap.d.ts
generated
vendored
10
node_modules/yaml/dist/nodes/YAMLMap.d.ts
generated
vendored
@@ -1,12 +1,13 @@
|
||||
import type { BlockMap, FlowCollection } from '../parse/cst.js';
|
||||
import type { Schema } from '../schema/Schema.js';
|
||||
import type { StringifyContext } from '../stringify/stringify.js';
|
||||
import { CreateNodeContext } from '../util.js';
|
||||
import { Collection } from './Collection.js';
|
||||
import { ParsedNode, Range } from './Node.js';
|
||||
import type { ParsedNode, Range } from './Node.js';
|
||||
import { Pair } from './Pair.js';
|
||||
import { Scalar } from './Scalar.js';
|
||||
import type { ToJSContext } from './toJS.js';
|
||||
export declare type MapLike = Map<unknown, unknown> | Set<unknown> | Record<string | number | symbol, unknown>;
|
||||
export type MapLike = Map<unknown, unknown> | Set<unknown> | Record<string | number | symbol, unknown>;
|
||||
export declare function findPair<K = unknown, V = unknown>(items: Iterable<Pair<K, V>>, key: unknown): Pair<K, V> | undefined;
|
||||
export declare namespace YAMLMap {
|
||||
interface Parsed<K extends ParsedNode = ParsedNode, V extends ParsedNode | null = ParsedNode | null> extends YAMLMap<K, V> {
|
||||
@@ -19,6 +20,11 @@ export declare class YAMLMap<K = unknown, V = unknown> extends Collection {
|
||||
static get tagName(): 'tag:yaml.org,2002:map';
|
||||
items: Pair<K, V>[];
|
||||
constructor(schema?: Schema);
|
||||
/**
|
||||
* A generic collection parsing method that can be extended
|
||||
* to other node classes that inherit from YAMLMap
|
||||
*/
|
||||
static from(schema: Schema, obj: unknown, ctx: CreateNodeContext): YAMLMap<unknown, unknown>;
|
||||
/**
|
||||
* Adds a value to the collection.
|
||||
*
|
||||
|
||||
52
node_modules/yaml/dist/nodes/YAMLMap.js
generated
vendored
52
node_modules/yaml/dist/nodes/YAMLMap.js
generated
vendored
@@ -3,30 +3,58 @@
|
||||
var stringifyCollection = require('../stringify/stringifyCollection.js');
|
||||
var addPairToJSMap = require('./addPairToJSMap.js');
|
||||
var Collection = require('./Collection.js');
|
||||
var Node = require('./Node.js');
|
||||
var identity = require('./identity.js');
|
||||
var Pair = require('./Pair.js');
|
||||
var Scalar = require('./Scalar.js');
|
||||
|
||||
function findPair(items, key) {
|
||||
const k = Node.isScalar(key) ? key.value : key;
|
||||
const k = identity.isScalar(key) ? key.value : key;
|
||||
for (const it of items) {
|
||||
if (Node.isPair(it)) {
|
||||
if (identity.isPair(it)) {
|
||||
if (it.key === key || it.key === k)
|
||||
return it;
|
||||
if (Node.isScalar(it.key) && it.key.value === k)
|
||||
if (identity.isScalar(it.key) && it.key.value === k)
|
||||
return it;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
class YAMLMap extends Collection.Collection {
|
||||
constructor(schema) {
|
||||
super(Node.MAP, schema);
|
||||
this.items = [];
|
||||
}
|
||||
static get tagName() {
|
||||
return 'tag:yaml.org,2002:map';
|
||||
}
|
||||
constructor(schema) {
|
||||
super(identity.MAP, schema);
|
||||
this.items = [];
|
||||
}
|
||||
/**
|
||||
* A generic collection parsing method that can be extended
|
||||
* to other node classes that inherit from YAMLMap
|
||||
*/
|
||||
static from(schema, obj, ctx) {
|
||||
const { keepUndefined, replacer } = ctx;
|
||||
const map = new this(schema);
|
||||
const add = (key, value) => {
|
||||
if (typeof replacer === 'function')
|
||||
value = replacer.call(obj, key, value);
|
||||
else if (Array.isArray(replacer) && !replacer.includes(key))
|
||||
return;
|
||||
if (value !== undefined || keepUndefined)
|
||||
map.items.push(Pair.createPair(key, value, ctx));
|
||||
};
|
||||
if (obj instanceof Map) {
|
||||
for (const [key, value] of obj)
|
||||
add(key, value);
|
||||
}
|
||||
else if (obj && typeof obj === 'object') {
|
||||
for (const key of Object.keys(obj))
|
||||
add(key, obj[key]);
|
||||
}
|
||||
if (typeof schema.sortMapEntries === 'function') {
|
||||
map.items.sort(schema.sortMapEntries);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
/**
|
||||
* Adds a value to the collection.
|
||||
*
|
||||
@@ -35,7 +63,7 @@ class YAMLMap extends Collection.Collection {
|
||||
*/
|
||||
add(pair, overwrite) {
|
||||
let _pair;
|
||||
if (Node.isPair(pair))
|
||||
if (identity.isPair(pair))
|
||||
_pair = pair;
|
||||
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
||||
// In TypeScript, this never happens.
|
||||
@@ -49,7 +77,7 @@ class YAMLMap extends Collection.Collection {
|
||||
if (!overwrite)
|
||||
throw new Error(`Key ${_pair.key} already set`);
|
||||
// For scalars, keep the old node & its comments and anchors
|
||||
if (Node.isScalar(prev.value) && Scalar.isScalarValue(_pair.value))
|
||||
if (identity.isScalar(prev.value) && Scalar.isScalarValue(_pair.value))
|
||||
prev.value.value = _pair.value;
|
||||
else
|
||||
prev.value = _pair.value;
|
||||
@@ -75,7 +103,7 @@ class YAMLMap extends Collection.Collection {
|
||||
get(key, keepScalar) {
|
||||
const it = findPair(this.items, key);
|
||||
const node = it?.value;
|
||||
return (!keepScalar && Node.isScalar(node) ? node.value : node) ?? undefined;
|
||||
return (!keepScalar && identity.isScalar(node) ? node.value : node) ?? undefined;
|
||||
}
|
||||
has(key) {
|
||||
return !!findPair(this.items, key);
|
||||
@@ -100,7 +128,7 @@ class YAMLMap extends Collection.Collection {
|
||||
if (!ctx)
|
||||
return JSON.stringify(this);
|
||||
for (const item of this.items) {
|
||||
if (!Node.isPair(item))
|
||||
if (!identity.isPair(item))
|
||||
throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`);
|
||||
}
|
||||
if (!ctx.allNullValues && this.hasAllNullValues(false))
|
||||
|
||||
4
node_modules/yaml/dist/nodes/YAMLSeq.d.ts
generated
vendored
4
node_modules/yaml/dist/nodes/YAMLSeq.d.ts
generated
vendored
@@ -1,8 +1,9 @@
|
||||
import { CreateNodeContext } from '../doc/createNode.js';
|
||||
import type { BlockSequence, FlowCollection } from '../parse/cst.js';
|
||||
import type { Schema } from '../schema/Schema.js';
|
||||
import type { StringifyContext } from '../stringify/stringify.js';
|
||||
import { Collection } from './Collection.js';
|
||||
import { ParsedNode, Range } from './Node.js';
|
||||
import type { ParsedNode, Range } from './Node.js';
|
||||
import type { Pair } from './Pair.js';
|
||||
import { Scalar } from './Scalar.js';
|
||||
import { ToJSContext } from './toJS.js';
|
||||
@@ -55,4 +56,5 @@ export declare class YAMLSeq<T = unknown> extends Collection {
|
||||
set(key: unknown, value: T): void;
|
||||
toJSON(_?: unknown, ctx?: ToJSContext): unknown[];
|
||||
toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
||||
static from(schema: Schema, obj: unknown, ctx: CreateNodeContext): YAMLSeq<unknown>;
|
||||
}
|
||||
|
||||
32
node_modules/yaml/dist/nodes/YAMLSeq.js
generated
vendored
32
node_modules/yaml/dist/nodes/YAMLSeq.js
generated
vendored
@@ -1,19 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var createNode = require('../doc/createNode.js');
|
||||
var stringifyCollection = require('../stringify/stringifyCollection.js');
|
||||
var Collection = require('./Collection.js');
|
||||
var Node = require('./Node.js');
|
||||
var identity = require('./identity.js');
|
||||
var Scalar = require('./Scalar.js');
|
||||
var toJS = require('./toJS.js');
|
||||
|
||||
class YAMLSeq extends Collection.Collection {
|
||||
constructor(schema) {
|
||||
super(Node.SEQ, schema);
|
||||
this.items = [];
|
||||
}
|
||||
static get tagName() {
|
||||
return 'tag:yaml.org,2002:seq';
|
||||
}
|
||||
constructor(schema) {
|
||||
super(identity.SEQ, schema);
|
||||
this.items = [];
|
||||
}
|
||||
add(value) {
|
||||
this.items.push(value);
|
||||
}
|
||||
@@ -37,7 +38,7 @@ class YAMLSeq extends Collection.Collection {
|
||||
if (typeof idx !== 'number')
|
||||
return undefined;
|
||||
const it = this.items[idx];
|
||||
return !keepScalar && Node.isScalar(it) ? it.value : it;
|
||||
return !keepScalar && identity.isScalar(it) ? it.value : it;
|
||||
}
|
||||
/**
|
||||
* Checks if the collection includes a value with the key `key`.
|
||||
@@ -61,7 +62,7 @@ class YAMLSeq extends Collection.Collection {
|
||||
if (typeof idx !== 'number')
|
||||
throw new Error(`Expected a valid index, not ${key}.`);
|
||||
const prev = this.items[idx];
|
||||
if (Node.isScalar(prev) && Scalar.isScalarValue(value))
|
||||
if (identity.isScalar(prev) && Scalar.isScalarValue(value))
|
||||
prev.value = value;
|
||||
else
|
||||
this.items[idx] = value;
|
||||
@@ -86,9 +87,24 @@ class YAMLSeq extends Collection.Collection {
|
||||
onComment
|
||||
});
|
||||
}
|
||||
static from(schema, obj, ctx) {
|
||||
const { replacer } = ctx;
|
||||
const seq = new this(schema);
|
||||
if (obj && Symbol.iterator in Object(obj)) {
|
||||
let i = 0;
|
||||
for (let it of obj) {
|
||||
if (typeof replacer === 'function') {
|
||||
const key = obj instanceof Set ? it : String(i++);
|
||||
it = replacer.call(obj, key, it);
|
||||
}
|
||||
seq.items.push(createNode.createNode(it, undefined, ctx));
|
||||
}
|
||||
}
|
||||
return seq;
|
||||
}
|
||||
}
|
||||
function asItemIndex(key) {
|
||||
let idx = Node.isScalar(key) ? key.value : key;
|
||||
let idx = identity.isScalar(key) ? key.value : key;
|
||||
if (idx && typeof idx === 'string')
|
||||
idx = Number(idx);
|
||||
return typeof idx === 'number' && Number.isInteger(idx) && idx >= 0
|
||||
|
||||
14
node_modules/yaml/dist/nodes/addPairToJSMap.js
generated
vendored
14
node_modules/yaml/dist/nodes/addPairToJSMap.js
generated
vendored
@@ -2,15 +2,15 @@
|
||||
|
||||
var log = require('../log.js');
|
||||
var stringify = require('../stringify/stringify.js');
|
||||
var Node = require('./Node.js');
|
||||
var identity = require('./identity.js');
|
||||
var Scalar = require('./Scalar.js');
|
||||
var toJS = require('./toJS.js');
|
||||
|
||||
const MERGE_KEY = '<<';
|
||||
function addPairToJSMap(ctx, map, { key, value }) {
|
||||
if (ctx?.doc.schema.merge && isMergeKey(key)) {
|
||||
value = Node.isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
if (Node.isSeq(value))
|
||||
value = identity.isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
if (identity.isSeq(value))
|
||||
for (const it of value.items)
|
||||
mergeToJSMap(ctx, map, it);
|
||||
else if (Array.isArray(value))
|
||||
@@ -44,7 +44,7 @@ function addPairToJSMap(ctx, map, { key, value }) {
|
||||
return map;
|
||||
}
|
||||
const isMergeKey = (key) => key === MERGE_KEY ||
|
||||
(Node.isScalar(key) &&
|
||||
(identity.isScalar(key) &&
|
||||
key.value === MERGE_KEY &&
|
||||
(!key.type || key.type === Scalar.Scalar.PLAIN));
|
||||
// If the value associated with a merge key is a single mapping node, each of
|
||||
@@ -55,8 +55,8 @@ const isMergeKey = (key) => key === MERGE_KEY ||
|
||||
// Keys in mapping nodes earlier in the sequence override keys specified in
|
||||
// later mapping nodes. -- http://yaml.org/type/merge.html
|
||||
function mergeToJSMap(ctx, map, value) {
|
||||
const source = ctx && Node.isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
if (!Node.isMap(source))
|
||||
const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
if (!identity.isMap(source))
|
||||
throw new Error('Merge sources must be maps or map aliases');
|
||||
const srcMap = source.toJSON(null, ctx, Map);
|
||||
for (const [key, value] of srcMap) {
|
||||
@@ -83,7 +83,7 @@ function stringifyKey(key, jsKey, ctx) {
|
||||
return '';
|
||||
if (typeof jsKey !== 'object')
|
||||
return String(jsKey);
|
||||
if (Node.isNode(key) && ctx && ctx.doc) {
|
||||
if (identity.isNode(key) && ctx?.doc) {
|
||||
const strCtx = stringify.createStringifyContext(ctx.doc, {});
|
||||
strCtx.anchors = new Set();
|
||||
for (const node of ctx.anchors.keys())
|
||||
|
||||
23
node_modules/yaml/dist/nodes/identity.d.ts
generated
vendored
Normal file
23
node_modules/yaml/dist/nodes/identity.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { Document } from '../doc/Document.js';
|
||||
import type { Alias } from './Alias.js';
|
||||
import type { Node } from './Node.js';
|
||||
import type { Pair } from './Pair.js';
|
||||
import type { Scalar } from './Scalar.js';
|
||||
import type { YAMLMap } from './YAMLMap.js';
|
||||
import type { YAMLSeq } from './YAMLSeq.js';
|
||||
export declare const ALIAS: unique symbol;
|
||||
export declare const DOC: unique symbol;
|
||||
export declare const MAP: unique symbol;
|
||||
export declare const PAIR: unique symbol;
|
||||
export declare const SCALAR: unique symbol;
|
||||
export declare const SEQ: unique symbol;
|
||||
export declare const NODE_TYPE: unique symbol;
|
||||
export declare const isAlias: (node: any) => node is Alias;
|
||||
export declare const isDocument: <T extends Node = Node>(node: any) => node is Document<T, true>;
|
||||
export declare const isMap: <K = unknown, V = unknown>(node: any) => node is YAMLMap<K, V>;
|
||||
export declare const isPair: <K = unknown, V = unknown>(node: any) => node is Pair<K, V>;
|
||||
export declare const isScalar: <T = unknown>(node: any) => node is Scalar<T>;
|
||||
export declare const isSeq: <T = unknown>(node: any) => node is YAMLSeq<T>;
|
||||
export declare function isCollection<K = unknown, V = unknown>(node: any): node is YAMLMap<K, V> | YAMLSeq<V>;
|
||||
export declare function isNode<T = unknown>(node: any): node is Node<T>;
|
||||
export declare const hasAnchor: <K = unknown, V = unknown>(node: unknown) => node is Scalar<V> | YAMLMap<K, V> | YAMLSeq<V>;
|
||||
53
node_modules/yaml/dist/nodes/identity.js
generated
vendored
Normal file
53
node_modules/yaml/dist/nodes/identity.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
const ALIAS = Symbol.for('yaml.alias');
|
||||
const DOC = Symbol.for('yaml.document');
|
||||
const MAP = Symbol.for('yaml.map');
|
||||
const PAIR = Symbol.for('yaml.pair');
|
||||
const SCALAR = Symbol.for('yaml.scalar');
|
||||
const SEQ = Symbol.for('yaml.seq');
|
||||
const NODE_TYPE = Symbol.for('yaml.node.type');
|
||||
const isAlias = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === ALIAS;
|
||||
const isDocument = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === DOC;
|
||||
const isMap = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === MAP;
|
||||
const isPair = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === PAIR;
|
||||
const isScalar = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SCALAR;
|
||||
const isSeq = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SEQ;
|
||||
function isCollection(node) {
|
||||
if (node && typeof node === 'object')
|
||||
switch (node[NODE_TYPE]) {
|
||||
case MAP:
|
||||
case SEQ:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isNode(node) {
|
||||
if (node && typeof node === 'object')
|
||||
switch (node[NODE_TYPE]) {
|
||||
case ALIAS:
|
||||
case MAP:
|
||||
case SCALAR:
|
||||
case SEQ:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
||||
|
||||
exports.ALIAS = ALIAS;
|
||||
exports.DOC = DOC;
|
||||
exports.MAP = MAP;
|
||||
exports.NODE_TYPE = NODE_TYPE;
|
||||
exports.PAIR = PAIR;
|
||||
exports.SCALAR = SCALAR;
|
||||
exports.SEQ = SEQ;
|
||||
exports.hasAnchor = hasAnchor;
|
||||
exports.isAlias = isAlias;
|
||||
exports.isCollection = isCollection;
|
||||
exports.isDocument = isDocument;
|
||||
exports.isMap = isMap;
|
||||
exports.isNode = isNode;
|
||||
exports.isPair = isPair;
|
||||
exports.isScalar = isScalar;
|
||||
exports.isSeq = isSeq;
|
||||
7
node_modules/yaml/dist/nodes/toJS.d.ts
generated
vendored
7
node_modules/yaml/dist/nodes/toJS.d.ts
generated
vendored
@@ -1,6 +1,5 @@
|
||||
import type { Document } from '../doc/Document.js';
|
||||
import type { stringify } from '../stringify/stringify.js';
|
||||
import { Node } from './Node.js';
|
||||
import type { Node } from './Node.js';
|
||||
export interface AnchorData {
|
||||
aliasCount: number;
|
||||
count: number;
|
||||
@@ -8,14 +7,12 @@ export interface AnchorData {
|
||||
}
|
||||
export interface ToJSContext {
|
||||
anchors: Map<Node, AnchorData>;
|
||||
doc: Document;
|
||||
doc: Document<Node, boolean>;
|
||||
keep: boolean;
|
||||
mapAsMap: boolean;
|
||||
mapKeyWarned: boolean;
|
||||
maxAliasCount: number;
|
||||
onCreate?: (res: unknown) => void;
|
||||
/** Requiring this directly in Pair would create circular dependencies */
|
||||
stringify: typeof stringify;
|
||||
}
|
||||
/**
|
||||
* Recursively convert any node or its contents to native JavaScript
|
||||
|
||||
4
node_modules/yaml/dist/nodes/toJS.js
generated
vendored
4
node_modules/yaml/dist/nodes/toJS.js
generated
vendored
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
var Node = require('./Node.js');
|
||||
var identity = require('./identity.js');
|
||||
|
||||
/**
|
||||
* Recursively convert any node or its contents to native JavaScript
|
||||
@@ -18,7 +18,7 @@ function toJS(value, arg, ctx) {
|
||||
return value.map((v, i) => toJS(v, String(i), ctx));
|
||||
if (value && typeof value.toJSON === 'function') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
if (!ctx || !Node.hasAnchor(value))
|
||||
if (!ctx || !identity.hasAnchor(value))
|
||||
return value.toJSON(arg, ctx);
|
||||
const data = { aliasCount: 0, count: 1, res: undefined };
|
||||
ctx.anchors.set(value, data);
|
||||
|
||||
Reference in New Issue
Block a user