FIN INIT
This commit is contained in:
29
node_modules/yaml/dist/nodes/Alias.d.ts
generated
vendored
Normal file
29
node_modules/yaml/dist/nodes/Alias.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
import type { Document } from '../doc/Document';
|
||||
import type { FlowScalar } from '../parse/cst';
|
||||
import type { StringifyContext } from '../stringify/stringify';
|
||||
import type { Range } from './Node';
|
||||
import { NodeBase } from './Node';
|
||||
import type { Scalar } from './Scalar';
|
||||
import type { ToJSContext } from './toJS';
|
||||
import type { YAMLMap } from './YAMLMap';
|
||||
import type { YAMLSeq } from './YAMLSeq';
|
||||
export declare namespace Alias {
|
||||
interface Parsed extends Alias {
|
||||
range: Range;
|
||||
srcToken?: FlowScalar & {
|
||||
type: 'alias';
|
||||
};
|
||||
}
|
||||
}
|
||||
export declare class Alias extends NodeBase {
|
||||
source: string;
|
||||
anchor?: never;
|
||||
constructor(source: string);
|
||||
/**
|
||||
* Resolve the value of this alias within `doc`, finding the last
|
||||
* instance of the `source` anchor before this node.
|
||||
*/
|
||||
resolve(doc: Document, ctx?: ToJSContext): Scalar | YAMLMap | YAMLSeq | undefined;
|
||||
toJSON(_arg?: unknown, ctx?: ToJSContext): unknown;
|
||||
toString(ctx?: StringifyContext, _onComment?: () => void, _onChompKeep?: () => void): string;
|
||||
}
|
116
node_modules/yaml/dist/nodes/Alias.js
generated
vendored
Normal file
116
node_modules/yaml/dist/nodes/Alias.js
generated
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
'use strict';
|
||||
|
||||
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(identity.ALIAS);
|
||||
this.source = source;
|
||||
Object.defineProperty(this, 'tag', {
|
||||
set() {
|
||||
throw new Error('Alias nodes cannot have tags');
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Resolve the value of this alias within `doc`, finding the last
|
||||
* instance of the `source` anchor before this node.
|
||||
*/
|
||||
resolve(doc, ctx) {
|
||||
let nodes;
|
||||
if (ctx?.aliasResolveCache) {
|
||||
nodes = ctx.aliasResolveCache;
|
||||
}
|
||||
else {
|
||||
nodes = [];
|
||||
visit.visit(doc, {
|
||||
Node: (_key, node) => {
|
||||
if (identity.isAlias(node) || identity.hasAnchor(node))
|
||||
nodes.push(node);
|
||||
}
|
||||
});
|
||||
if (ctx)
|
||||
ctx.aliasResolveCache = nodes;
|
||||
}
|
||||
let found = undefined;
|
||||
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, ctx);
|
||||
if (!source) {
|
||||
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
||||
throw new ReferenceError(msg);
|
||||
}
|
||||
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?';
|
||||
throw new ReferenceError(msg);
|
||||
}
|
||||
if (maxAliasCount >= 0) {
|
||||
data.count += 1;
|
||||
if (data.aliasCount === 0)
|
||||
data.aliasCount = getAliasCount(doc, source, anchors);
|
||||
if (data.count * data.aliasCount > maxAliasCount) {
|
||||
const msg = 'Excessive alias count indicates a resource exhaustion attack';
|
||||
throw new ReferenceError(msg);
|
||||
}
|
||||
}
|
||||
return data.res;
|
||||
}
|
||||
toString(ctx, _onComment, _onChompKeep) {
|
||||
const src = `*${this.source}`;
|
||||
if (ctx) {
|
||||
anchors.anchorIsValid(this.source);
|
||||
if (ctx.options.verifyAliasOrder && !ctx.anchors.has(this.source)) {
|
||||
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
||||
throw new Error(msg);
|
||||
}
|
||||
if (ctx.implicitKey)
|
||||
return `${src} `;
|
||||
}
|
||||
return src;
|
||||
}
|
||||
}
|
||||
function getAliasCount(doc, node, anchors) {
|
||||
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 (identity.isCollection(node)) {
|
||||
let count = 0;
|
||||
for (const item of node.items) {
|
||||
const c = getAliasCount(doc, item, anchors);
|
||||
if (c > count)
|
||||
count = c;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
else if (identity.isPair(node)) {
|
||||
const kc = getAliasCount(doc, node.key, anchors);
|
||||
const vc = getAliasCount(doc, node.value, anchors);
|
||||
return Math.max(kc, vc);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
exports.Alias = Alias;
|
73
node_modules/yaml/dist/nodes/Collection.d.ts
generated
vendored
Normal file
73
node_modules/yaml/dist/nodes/Collection.d.ts
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
import type { Schema } from '../schema/Schema';
|
||||
import { NODE_TYPE } from './identity';
|
||||
import { NodeBase } from './Node';
|
||||
export declare function collectionFromPath(schema: Schema, path: unknown[], value: unknown): import('./Node').Node;
|
||||
export declare const isEmptyPath: (path: Iterable<unknown> | null | undefined) => path is null | undefined;
|
||||
export declare abstract class Collection extends NodeBase {
|
||||
schema: Schema | undefined;
|
||||
[NODE_TYPE]: symbol;
|
||||
items: unknown[];
|
||||
/** An optional anchor on this node. Used by alias nodes. */
|
||||
anchor?: string;
|
||||
/**
|
||||
* If true, stringify this and all child nodes using flow rather than
|
||||
* block styles.
|
||||
*/
|
||||
flow?: boolean;
|
||||
constructor(type: symbol, schema?: Schema);
|
||||
/**
|
||||
* Create a copy of this collection.
|
||||
*
|
||||
* @param schema - If defined, overwrites the original's schema
|
||||
*/
|
||||
clone(schema?: Schema): Collection;
|
||||
/** Adds a value to the collection. */
|
||||
abstract add(value: unknown): void;
|
||||
/**
|
||||
* Removes a value from the collection.
|
||||
* @returns `true` if the item was found and removed.
|
||||
*/
|
||||
abstract delete(key: unknown): boolean;
|
||||
/**
|
||||
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
||||
* scalar values from their surrounding node; to disable set `keepScalar` to
|
||||
* `true` (collections are always returned intact).
|
||||
*/
|
||||
abstract get(key: unknown, keepScalar?: boolean): unknown;
|
||||
/**
|
||||
* Checks if the collection includes a value with the key `key`.
|
||||
*/
|
||||
abstract has(key: unknown): boolean;
|
||||
/**
|
||||
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
||||
* boolean to add/remove the item from the set.
|
||||
*/
|
||||
abstract set(key: unknown, value: unknown): void;
|
||||
/**
|
||||
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
||||
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
||||
* that already exists in the map.
|
||||
*/
|
||||
addIn(path: Iterable<unknown>, value: unknown): void;
|
||||
/**
|
||||
* Removes a value from the collection.
|
||||
* @returns `true` if the item was found and removed.
|
||||
*/
|
||||
deleteIn(path: Iterable<unknown>): boolean;
|
||||
/**
|
||||
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
||||
* scalar values from their surrounding node; to disable set `keepScalar` to
|
||||
* `true` (collections are always returned intact).
|
||||
*/
|
||||
getIn(path: Iterable<unknown>, keepScalar?: boolean): unknown;
|
||||
hasAllNullValues(allowScalar?: boolean): boolean;
|
||||
/**
|
||||
* Checks if the collection includes a value with the key `key`.
|
||||
*/
|
||||
hasIn(path: Iterable<unknown>): boolean;
|
||||
/**
|
||||
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
||||
* boolean to add/remove the item from the set.
|
||||
*/
|
||||
setIn(path: Iterable<unknown>, value: unknown): void;
|
||||
}
|
151
node_modules/yaml/dist/nodes/Collection.js
generated
vendored
Normal file
151
node_modules/yaml/dist/nodes/Collection.js
generated
vendored
Normal file
@ -0,0 +1,151 @@
|
||||
'use strict';
|
||||
|
||||
var createNode = require('../doc/createNode.js');
|
||||
var identity = require('./identity.js');
|
||||
var Node = require('./Node.js');
|
||||
|
||||
function collectionFromPath(schema, path, value) {
|
||||
let v = value;
|
||||
for (let i = path.length - 1; i >= 0; --i) {
|
||||
const k = path[i];
|
||||
if (typeof k === 'number' && Number.isInteger(k) && k >= 0) {
|
||||
const a = [];
|
||||
a[k] = v;
|
||||
v = a;
|
||||
}
|
||||
else {
|
||||
v = new Map([[k, v]]);
|
||||
}
|
||||
}
|
||||
return createNode.createNode(v, undefined, {
|
||||
aliasDuplicateObjects: false,
|
||||
keepUndefined: false,
|
||||
onAnchor: () => {
|
||||
throw new Error('This should not happen, please report a bug.');
|
||||
},
|
||||
schema,
|
||||
sourceObjects: new Map()
|
||||
});
|
||||
}
|
||||
// Type guard is intentionally a little wrong so as to be more useful,
|
||||
// as it does not cover untypable empty non-string iterables (e.g. []).
|
||||
const isEmptyPath = (path) => path == null ||
|
||||
(typeof path === 'object' && !!path[Symbol.iterator]().next().done);
|
||||
class Collection extends Node.NodeBase {
|
||||
constructor(type, schema) {
|
||||
super(type);
|
||||
Object.defineProperty(this, 'schema', {
|
||||
value: schema,
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Create a copy of this collection.
|
||||
*
|
||||
* @param schema - If defined, overwrites the original's schema
|
||||
*/
|
||||
clone(schema) {
|
||||
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
||||
if (schema)
|
||||
copy.schema = schema;
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
||||
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
||||
* that already exists in the map.
|
||||
*/
|
||||
addIn(path, value) {
|
||||
if (isEmptyPath(path))
|
||||
this.add(value);
|
||||
else {
|
||||
const [key, ...rest] = path;
|
||||
const node = this.get(key, true);
|
||||
if (identity.isCollection(node))
|
||||
node.addIn(rest, value);
|
||||
else if (node === undefined && this.schema)
|
||||
this.set(key, collectionFromPath(this.schema, rest, value));
|
||||
else
|
||||
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Removes a value from the collection.
|
||||
* @returns `true` if the item was found and removed.
|
||||
*/
|
||||
deleteIn(path) {
|
||||
const [key, ...rest] = path;
|
||||
if (rest.length === 0)
|
||||
return this.delete(key);
|
||||
const node = this.get(key, true);
|
||||
if (identity.isCollection(node))
|
||||
return node.deleteIn(rest);
|
||||
else
|
||||
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
||||
}
|
||||
/**
|
||||
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
||||
* scalar values from their surrounding node; to disable set `keepScalar` to
|
||||
* `true` (collections are always returned intact).
|
||||
*/
|
||||
getIn(path, keepScalar) {
|
||||
const [key, ...rest] = path;
|
||||
const node = this.get(key, true);
|
||||
if (rest.length === 0)
|
||||
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
||||
else
|
||||
return identity.isCollection(node) ? node.getIn(rest, keepScalar) : undefined;
|
||||
}
|
||||
hasAllNullValues(allowScalar) {
|
||||
return this.items.every(node => {
|
||||
if (!identity.isPair(node))
|
||||
return false;
|
||||
const n = node.value;
|
||||
return (n == null ||
|
||||
(allowScalar &&
|
||||
identity.isScalar(n) &&
|
||||
n.value == null &&
|
||||
!n.commentBefore &&
|
||||
!n.comment &&
|
||||
!n.tag));
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Checks if the collection includes a value with the key `key`.
|
||||
*/
|
||||
hasIn(path) {
|
||||
const [key, ...rest] = path;
|
||||
if (rest.length === 0)
|
||||
return this.has(key);
|
||||
const node = this.get(key, true);
|
||||
return identity.isCollection(node) ? node.hasIn(rest) : false;
|
||||
}
|
||||
/**
|
||||
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
||||
* boolean to add/remove the item from the set.
|
||||
*/
|
||||
setIn(path, value) {
|
||||
const [key, ...rest] = path;
|
||||
if (rest.length === 0) {
|
||||
this.set(key, value);
|
||||
}
|
||||
else {
|
||||
const node = this.get(key, true);
|
||||
if (identity.isCollection(node))
|
||||
node.setIn(rest, value);
|
||||
else if (node === undefined && this.schema)
|
||||
this.set(key, collectionFromPath(this.schema, rest, value));
|
||||
else
|
||||
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.Collection = Collection;
|
||||
exports.collectionFromPath = collectionFromPath;
|
||||
exports.isEmptyPath = isEmptyPath;
|
53
node_modules/yaml/dist/nodes/Node.d.ts
generated
vendored
Normal file
53
node_modules/yaml/dist/nodes/Node.d.ts
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
import type { Document } from '../doc/Document';
|
||||
import type { ToJSOptions } from '../options';
|
||||
import type { Token } from '../parse/cst';
|
||||
import type { StringifyContext } from '../stringify/stringify';
|
||||
import type { Alias } from './Alias';
|
||||
import { NODE_TYPE } from './identity';
|
||||
import type { Scalar } from './Scalar';
|
||||
import type { ToJSContext } from './toJS';
|
||||
import type { MapLike, YAMLMap } from './YAMLMap';
|
||||
import type { YAMLSeq } from './YAMLSeq';
|
||||
export type Node<T = unknown> = Alias | Scalar<T> | YAMLMap<unknown, T> | YAMLSeq<T>;
|
||||
/** Utility type mapper */
|
||||
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 type ParsedNode = Alias.Parsed | Scalar.Parsed | YAMLMap.Parsed | YAMLSeq.Parsed;
|
||||
/** `[start, value-end, node-end]` */
|
||||
export type Range = [number, number, number];
|
||||
export declare abstract class NodeBase {
|
||||
readonly [NODE_TYPE]: symbol;
|
||||
/** A comment on or immediately after this */
|
||||
comment?: string | null;
|
||||
/** A comment before this */
|
||||
commentBefore?: string | null;
|
||||
/**
|
||||
* The `[start, value-end, node-end]` character offsets for the part of the
|
||||
* source parsed into this node (undefined if not parsed). The `value-end`
|
||||
* and `node-end` positions are themselves not included in their respective
|
||||
* ranges.
|
||||
*/
|
||||
range?: Range | null;
|
||||
/** A blank line before this node and its commentBefore */
|
||||
spaceBefore?: boolean;
|
||||
/** The CST token that was composed into this node. */
|
||||
srcToken?: Token;
|
||||
/** A fully qualified tag, if required */
|
||||
tag?: string;
|
||||
/**
|
||||
* Customize the way that a key-value pair is resolved.
|
||||
* Used for YAML 1.1 !!merge << handling.
|
||||
*/
|
||||
addToJSMap?: (ctx: ToJSContext | undefined, map: MapLike, value: unknown) => void;
|
||||
/** A plain JS representation of this node */
|
||||
abstract toJSON(): any;
|
||||
abstract toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
||||
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;
|
||||
}
|
40
node_modules/yaml/dist/nodes/Node.js
generated
vendored
Normal file
40
node_modules/yaml/dist/nodes/Node.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
var applyReviver = require('../doc/applyReviver.js');
|
||||
var identity = require('./identity.js');
|
||||
var toJS = require('./toJS.js');
|
||||
|
||||
class NodeBase {
|
||||
constructor(type) {
|
||||
Object.defineProperty(this, identity.NODE_TYPE, { value: type });
|
||||
}
|
||||
/** Create a copy of this node. */
|
||||
clone() {
|
||||
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
||||
if (this.range)
|
||||
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.NodeBase = NodeBase;
|
22
node_modules/yaml/dist/nodes/Pair.d.ts
generated
vendored
Normal file
22
node_modules/yaml/dist/nodes/Pair.d.ts
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import type { CreateNodeContext } from '../doc/createNode';
|
||||
import type { CollectionItem } from '../parse/cst';
|
||||
import type { Schema } from '../schema/Schema';
|
||||
import type { StringifyContext } from '../stringify/stringify';
|
||||
import { addPairToJSMap } from './addPairToJSMap';
|
||||
import { NODE_TYPE } from './identity';
|
||||
import type { Node } from './Node';
|
||||
import type { ToJSContext } from './toJS';
|
||||
export declare function createPair(key: unknown, value: unknown, ctx: CreateNodeContext): Pair<Node, Node>;
|
||||
export declare class Pair<K = unknown, V = unknown> {
|
||||
readonly [NODE_TYPE]: symbol;
|
||||
/** Always Node or null when parsed, but can be set to anything. */
|
||||
key: K;
|
||||
/** Always Node or null when parsed, but can be set to anything. */
|
||||
value: V | null;
|
||||
/** The CST token that was composed into this pair. */
|
||||
srcToken?: CollectionItem;
|
||||
constructor(key: K, value?: V | null);
|
||||
clone(schema?: Schema): Pair<K, V>;
|
||||
toJSON(_?: unknown, ctx?: ToJSContext): ReturnType<typeof addPairToJSMap>;
|
||||
toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
||||
}
|
39
node_modules/yaml/dist/nodes/Pair.js
generated
vendored
Normal file
39
node_modules/yaml/dist/nodes/Pair.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
var createNode = require('../doc/createNode.js');
|
||||
var stringifyPair = require('../stringify/stringifyPair.js');
|
||||
var addPairToJSMap = require('./addPairToJSMap.js');
|
||||
var identity = require('./identity.js');
|
||||
|
||||
function createPair(key, value, ctx) {
|
||||
const k = createNode.createNode(key, undefined, ctx);
|
||||
const v = createNode.createNode(value, undefined, ctx);
|
||||
return new Pair(k, v);
|
||||
}
|
||||
class Pair {
|
||||
constructor(key, value = null) {
|
||||
Object.defineProperty(this, identity.NODE_TYPE, { value: identity.PAIR });
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
clone(schema) {
|
||||
let { key, value } = this;
|
||||
if (identity.isNode(key))
|
||||
key = key.clone(schema);
|
||||
if (identity.isNode(value))
|
||||
value = value.clone(schema);
|
||||
return new Pair(key, value);
|
||||
}
|
||||
toJSON(_, ctx) {
|
||||
const pair = ctx?.mapAsMap ? new Map() : {};
|
||||
return addPairToJSMap.addPairToJSMap(ctx, pair, this);
|
||||
}
|
||||
toString(ctx, onComment, onChompKeep) {
|
||||
return ctx?.doc
|
||||
? stringifyPair.stringifyPair(this, ctx, onComment, onChompKeep)
|
||||
: JSON.stringify(this);
|
||||
}
|
||||
}
|
||||
|
||||
exports.Pair = Pair;
|
||||
exports.createPair = createPair;
|
43
node_modules/yaml/dist/nodes/Scalar.d.ts
generated
vendored
Normal file
43
node_modules/yaml/dist/nodes/Scalar.d.ts
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
import type { BlockScalar, FlowScalar } from '../parse/cst';
|
||||
import type { Range } from './Node';
|
||||
import { NodeBase } from './Node';
|
||||
import type { ToJSContext } from './toJS';
|
||||
export declare const isScalarValue: (value: unknown) => boolean;
|
||||
export declare namespace Scalar {
|
||||
interface Parsed extends Scalar {
|
||||
range: Range;
|
||||
source: string;
|
||||
srcToken?: FlowScalar | BlockScalar;
|
||||
}
|
||||
type BLOCK_FOLDED = 'BLOCK_FOLDED';
|
||||
type BLOCK_LITERAL = 'BLOCK_LITERAL';
|
||||
type PLAIN = 'PLAIN';
|
||||
type QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
||||
type QUOTE_SINGLE = 'QUOTE_SINGLE';
|
||||
type Type = BLOCK_FOLDED | BLOCK_LITERAL | PLAIN | QUOTE_DOUBLE | QUOTE_SINGLE;
|
||||
}
|
||||
export declare class Scalar<T = unknown> extends NodeBase {
|
||||
static readonly BLOCK_FOLDED = "BLOCK_FOLDED";
|
||||
static readonly BLOCK_LITERAL = "BLOCK_LITERAL";
|
||||
static readonly PLAIN = "PLAIN";
|
||||
static readonly QUOTE_DOUBLE = "QUOTE_DOUBLE";
|
||||
static readonly QUOTE_SINGLE = "QUOTE_SINGLE";
|
||||
value: T;
|
||||
/** An optional anchor on this node. Used by alias nodes. */
|
||||
anchor?: string;
|
||||
/**
|
||||
* By default (undefined), numbers use decimal notation.
|
||||
* The YAML 1.2 core schema only supports 'HEX' and 'OCT'.
|
||||
* The YAML 1.1 schema also supports 'BIN' and 'TIME'
|
||||
*/
|
||||
format?: string;
|
||||
/** If `value` is a number, use this value when stringifying this node. */
|
||||
minFractionDigits?: number;
|
||||
/** Set during parsing to the source string value */
|
||||
source?: string;
|
||||
/** The scalar style used for the node's string representation */
|
||||
type?: Scalar.Type;
|
||||
constructor(value: T);
|
||||
toJSON(arg?: any, ctx?: ToJSContext): any;
|
||||
toString(): string;
|
||||
}
|
27
node_modules/yaml/dist/nodes/Scalar.js
generated
vendored
Normal file
27
node_modules/yaml/dist/nodes/Scalar.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
'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(identity.SCALAR);
|
||||
this.value = value;
|
||||
}
|
||||
toJSON(arg, ctx) {
|
||||
return ctx?.keep ? this.value : toJS.toJS(this.value, arg, ctx);
|
||||
}
|
||||
toString() {
|
||||
return String(this.value);
|
||||
}
|
||||
}
|
||||
Scalar.BLOCK_FOLDED = 'BLOCK_FOLDED';
|
||||
Scalar.BLOCK_LITERAL = 'BLOCK_LITERAL';
|
||||
Scalar.PLAIN = 'PLAIN';
|
||||
Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
|
||||
Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
|
||||
|
||||
exports.Scalar = Scalar;
|
||||
exports.isScalarValue = isScalarValue;
|
53
node_modules/yaml/dist/nodes/YAMLMap.d.ts
generated
vendored
Normal file
53
node_modules/yaml/dist/nodes/YAMLMap.d.ts
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
import type { BlockMap, FlowCollection } from '../parse/cst';
|
||||
import type { Schema } from '../schema/Schema';
|
||||
import type { StringifyContext } from '../stringify/stringify';
|
||||
import type { CreateNodeContext } from '../util';
|
||||
import { Collection } from './Collection';
|
||||
import type { ParsedNode, Range } from './Node';
|
||||
import { Pair } from './Pair';
|
||||
import type { Scalar } from './Scalar';
|
||||
import type { ToJSContext } from './toJS';
|
||||
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> {
|
||||
items: Pair<K, V>[];
|
||||
range: Range;
|
||||
srcToken?: BlockMap | FlowCollection;
|
||||
}
|
||||
}
|
||||
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;
|
||||
/**
|
||||
* Adds a value to the collection.
|
||||
*
|
||||
* @param overwrite - If not set `true`, using a key that is already in the
|
||||
* collection will throw. Otherwise, overwrites the previous value.
|
||||
*/
|
||||
add(pair: Pair<K, V> | {
|
||||
key: K;
|
||||
value: V;
|
||||
}, overwrite?: boolean): void;
|
||||
delete(key: unknown): boolean;
|
||||
get(key: unknown, keepScalar: true): Scalar<V> | undefined;
|
||||
get(key: unknown, keepScalar?: false): V | undefined;
|
||||
get(key: unknown, keepScalar?: boolean): V | Scalar<V> | undefined;
|
||||
has(key: unknown): boolean;
|
||||
set(key: K, value: V): void;
|
||||
/**
|
||||
* @param ctx - Conversion context, originally set in Document#toJS()
|
||||
* @param {Class} Type - If set, forces the returned collection type
|
||||
* @returns Instance of Type, Map, or Object
|
||||
*/
|
||||
toJSON<T extends MapLike = Map<unknown, unknown>>(_?: unknown, ctx?: ToJSContext, Type?: {
|
||||
new (): T;
|
||||
}): any;
|
||||
toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
||||
}
|
147
node_modules/yaml/dist/nodes/YAMLMap.js
generated
vendored
Normal file
147
node_modules/yaml/dist/nodes/YAMLMap.js
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
'use strict';
|
||||
|
||||
var stringifyCollection = require('../stringify/stringifyCollection.js');
|
||||
var addPairToJSMap = require('./addPairToJSMap.js');
|
||||
var Collection = require('./Collection.js');
|
||||
var identity = require('./identity.js');
|
||||
var Pair = require('./Pair.js');
|
||||
var Scalar = require('./Scalar.js');
|
||||
|
||||
function findPair(items, key) {
|
||||
const k = identity.isScalar(key) ? key.value : key;
|
||||
for (const it of items) {
|
||||
if (identity.isPair(it)) {
|
||||
if (it.key === key || it.key === k)
|
||||
return it;
|
||||
if (identity.isScalar(it.key) && it.key.value === k)
|
||||
return it;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
class YAMLMap extends Collection.Collection {
|
||||
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.
|
||||
*
|
||||
* @param overwrite - If not set `true`, using a key that is already in the
|
||||
* collection will throw. Otherwise, overwrites the previous value.
|
||||
*/
|
||||
add(pair, overwrite) {
|
||||
let _pair;
|
||||
if (identity.isPair(pair))
|
||||
_pair = pair;
|
||||
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
||||
// In TypeScript, this never happens.
|
||||
_pair = new Pair.Pair(pair, pair?.value);
|
||||
}
|
||||
else
|
||||
_pair = new Pair.Pair(pair.key, pair.value);
|
||||
const prev = findPair(this.items, _pair.key);
|
||||
const sortEntries = this.schema?.sortMapEntries;
|
||||
if (prev) {
|
||||
if (!overwrite)
|
||||
throw new Error(`Key ${_pair.key} already set`);
|
||||
// For scalars, keep the old node & its comments and anchors
|
||||
if (identity.isScalar(prev.value) && Scalar.isScalarValue(_pair.value))
|
||||
prev.value.value = _pair.value;
|
||||
else
|
||||
prev.value = _pair.value;
|
||||
}
|
||||
else if (sortEntries) {
|
||||
const i = this.items.findIndex(item => sortEntries(_pair, item) < 0);
|
||||
if (i === -1)
|
||||
this.items.push(_pair);
|
||||
else
|
||||
this.items.splice(i, 0, _pair);
|
||||
}
|
||||
else {
|
||||
this.items.push(_pair);
|
||||
}
|
||||
}
|
||||
delete(key) {
|
||||
const it = findPair(this.items, key);
|
||||
if (!it)
|
||||
return false;
|
||||
const del = this.items.splice(this.items.indexOf(it), 1);
|
||||
return del.length > 0;
|
||||
}
|
||||
get(key, keepScalar) {
|
||||
const it = findPair(this.items, key);
|
||||
const node = it?.value;
|
||||
return (!keepScalar && identity.isScalar(node) ? node.value : node) ?? undefined;
|
||||
}
|
||||
has(key) {
|
||||
return !!findPair(this.items, key);
|
||||
}
|
||||
set(key, value) {
|
||||
this.add(new Pair.Pair(key, value), true);
|
||||
}
|
||||
/**
|
||||
* @param ctx - Conversion context, originally set in Document#toJS()
|
||||
* @param {Class} Type - If set, forces the returned collection type
|
||||
* @returns Instance of Type, Map, or Object
|
||||
*/
|
||||
toJSON(_, ctx, Type) {
|
||||
const map = Type ? new Type() : ctx?.mapAsMap ? new Map() : {};
|
||||
if (ctx?.onCreate)
|
||||
ctx.onCreate(map);
|
||||
for (const item of this.items)
|
||||
addPairToJSMap.addPairToJSMap(ctx, map, item);
|
||||
return map;
|
||||
}
|
||||
toString(ctx, onComment, onChompKeep) {
|
||||
if (!ctx)
|
||||
return JSON.stringify(this);
|
||||
for (const item of this.items) {
|
||||
if (!identity.isPair(item))
|
||||
throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`);
|
||||
}
|
||||
if (!ctx.allNullValues && this.hasAllNullValues(false))
|
||||
ctx = Object.assign({}, ctx, { allNullValues: true });
|
||||
return stringifyCollection.stringifyCollection(this, ctx, {
|
||||
blockItemPrefix: '',
|
||||
flowChars: { start: '{', end: '}' },
|
||||
itemIndent: ctx.indent || '',
|
||||
onChompKeep,
|
||||
onComment
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
exports.YAMLMap = YAMLMap;
|
||||
exports.findPair = findPair;
|
60
node_modules/yaml/dist/nodes/YAMLSeq.d.ts
generated
vendored
Normal file
60
node_modules/yaml/dist/nodes/YAMLSeq.d.ts
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
import type { CreateNodeContext } from '../doc/createNode';
|
||||
import type { BlockSequence, FlowCollection } from '../parse/cst';
|
||||
import type { Schema } from '../schema/Schema';
|
||||
import type { StringifyContext } from '../stringify/stringify';
|
||||
import { Collection } from './Collection';
|
||||
import type { ParsedNode, Range } from './Node';
|
||||
import type { Pair } from './Pair';
|
||||
import type { Scalar } from './Scalar';
|
||||
import type { ToJSContext } from './toJS';
|
||||
export declare namespace YAMLSeq {
|
||||
interface Parsed<T extends ParsedNode | Pair<ParsedNode, ParsedNode | null> = ParsedNode> extends YAMLSeq<T> {
|
||||
items: T[];
|
||||
range: Range;
|
||||
srcToken?: BlockSequence | FlowCollection;
|
||||
}
|
||||
}
|
||||
export declare class YAMLSeq<T = unknown> extends Collection {
|
||||
static get tagName(): 'tag:yaml.org,2002:seq';
|
||||
items: T[];
|
||||
constructor(schema?: Schema);
|
||||
add(value: T): void;
|
||||
/**
|
||||
* Removes a value from the collection.
|
||||
*
|
||||
* `key` must contain a representation of an integer for this to succeed.
|
||||
* It may be wrapped in a `Scalar`.
|
||||
*
|
||||
* @returns `true` if the item was found and removed.
|
||||
*/
|
||||
delete(key: unknown): boolean;
|
||||
/**
|
||||
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
||||
* scalar values from their surrounding node; to disable set `keepScalar` to
|
||||
* `true` (collections are always returned intact).
|
||||
*
|
||||
* `key` must contain a representation of an integer for this to succeed.
|
||||
* It may be wrapped in a `Scalar`.
|
||||
*/
|
||||
get(key: unknown, keepScalar: true): Scalar<T> | undefined;
|
||||
get(key: unknown, keepScalar?: false): T | undefined;
|
||||
get(key: unknown, keepScalar?: boolean): T | Scalar<T> | undefined;
|
||||
/**
|
||||
* Checks if the collection includes a value with the key `key`.
|
||||
*
|
||||
* `key` must contain a representation of an integer for this to succeed.
|
||||
* It may be wrapped in a `Scalar`.
|
||||
*/
|
||||
has(key: unknown): boolean;
|
||||
/**
|
||||
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
||||
* boolean to add/remove the item from the set.
|
||||
*
|
||||
* If `key` does not contain a representation of an integer, this will throw.
|
||||
* It may be wrapped in a `Scalar`.
|
||||
*/
|
||||
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;
|
||||
}
|
115
node_modules/yaml/dist/nodes/YAMLSeq.js
generated
vendored
Normal file
115
node_modules/yaml/dist/nodes/YAMLSeq.js
generated
vendored
Normal file
@ -0,0 +1,115 @@
|
||||
'use strict';
|
||||
|
||||
var createNode = require('../doc/createNode.js');
|
||||
var stringifyCollection = require('../stringify/stringifyCollection.js');
|
||||
var Collection = require('./Collection.js');
|
||||
var identity = require('./identity.js');
|
||||
var Scalar = require('./Scalar.js');
|
||||
var toJS = require('./toJS.js');
|
||||
|
||||
class YAMLSeq extends Collection.Collection {
|
||||
static get tagName() {
|
||||
return 'tag:yaml.org,2002:seq';
|
||||
}
|
||||
constructor(schema) {
|
||||
super(identity.SEQ, schema);
|
||||
this.items = [];
|
||||
}
|
||||
add(value) {
|
||||
this.items.push(value);
|
||||
}
|
||||
/**
|
||||
* Removes a value from the collection.
|
||||
*
|
||||
* `key` must contain a representation of an integer for this to succeed.
|
||||
* It may be wrapped in a `Scalar`.
|
||||
*
|
||||
* @returns `true` if the item was found and removed.
|
||||
*/
|
||||
delete(key) {
|
||||
const idx = asItemIndex(key);
|
||||
if (typeof idx !== 'number')
|
||||
return false;
|
||||
const del = this.items.splice(idx, 1);
|
||||
return del.length > 0;
|
||||
}
|
||||
get(key, keepScalar) {
|
||||
const idx = asItemIndex(key);
|
||||
if (typeof idx !== 'number')
|
||||
return undefined;
|
||||
const it = this.items[idx];
|
||||
return !keepScalar && identity.isScalar(it) ? it.value : it;
|
||||
}
|
||||
/**
|
||||
* Checks if the collection includes a value with the key `key`.
|
||||
*
|
||||
* `key` must contain a representation of an integer for this to succeed.
|
||||
* It may be wrapped in a `Scalar`.
|
||||
*/
|
||||
has(key) {
|
||||
const idx = asItemIndex(key);
|
||||
return typeof idx === 'number' && idx < this.items.length;
|
||||
}
|
||||
/**
|
||||
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
||||
* boolean to add/remove the item from the set.
|
||||
*
|
||||
* If `key` does not contain a representation of an integer, this will throw.
|
||||
* It may be wrapped in a `Scalar`.
|
||||
*/
|
||||
set(key, value) {
|
||||
const idx = asItemIndex(key);
|
||||
if (typeof idx !== 'number')
|
||||
throw new Error(`Expected a valid index, not ${key}.`);
|
||||
const prev = this.items[idx];
|
||||
if (identity.isScalar(prev) && Scalar.isScalarValue(value))
|
||||
prev.value = value;
|
||||
else
|
||||
this.items[idx] = value;
|
||||
}
|
||||
toJSON(_, ctx) {
|
||||
const seq = [];
|
||||
if (ctx?.onCreate)
|
||||
ctx.onCreate(seq);
|
||||
let i = 0;
|
||||
for (const item of this.items)
|
||||
seq.push(toJS.toJS(item, String(i++), ctx));
|
||||
return seq;
|
||||
}
|
||||
toString(ctx, onComment, onChompKeep) {
|
||||
if (!ctx)
|
||||
return JSON.stringify(this);
|
||||
return stringifyCollection.stringifyCollection(this, ctx, {
|
||||
blockItemPrefix: '- ',
|
||||
flowChars: { start: '[', end: ']' },
|
||||
itemIndent: (ctx.indent || '') + ' ',
|
||||
onChompKeep,
|
||||
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 = identity.isScalar(key) ? key.value : key;
|
||||
if (idx && typeof idx === 'string')
|
||||
idx = Number(idx);
|
||||
return typeof idx === 'number' && Number.isInteger(idx) && idx >= 0
|
||||
? idx
|
||||
: null;
|
||||
}
|
||||
|
||||
exports.YAMLSeq = YAMLSeq;
|
4
node_modules/yaml/dist/nodes/addPairToJSMap.d.ts
generated
vendored
Normal file
4
node_modules/yaml/dist/nodes/addPairToJSMap.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import type { Pair } from './Pair';
|
||||
import type { ToJSContext } from './toJS';
|
||||
import type { MapLike } from './YAMLMap';
|
||||
export declare function addPairToJSMap(ctx: ToJSContext | undefined, map: MapLike, { key, value }: Pair): MapLike;
|
65
node_modules/yaml/dist/nodes/addPairToJSMap.js
generated
vendored
Normal file
65
node_modules/yaml/dist/nodes/addPairToJSMap.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
|
||||
var log = require('../log.js');
|
||||
var merge = require('../schema/yaml-1.1/merge.js');
|
||||
var stringify = require('../stringify/stringify.js');
|
||||
var identity = require('./identity.js');
|
||||
var toJS = require('./toJS.js');
|
||||
|
||||
function addPairToJSMap(ctx, map, { key, value }) {
|
||||
if (identity.isNode(key) && key.addToJSMap)
|
||||
key.addToJSMap(ctx, map, value);
|
||||
// TODO: Should drop this special case for bare << handling
|
||||
else if (merge.isMergeKey(ctx, key))
|
||||
merge.addMergeToJSMap(ctx, map, value);
|
||||
else {
|
||||
const jsKey = toJS.toJS(key, '', ctx);
|
||||
if (map instanceof Map) {
|
||||
map.set(jsKey, toJS.toJS(value, jsKey, ctx));
|
||||
}
|
||||
else if (map instanceof Set) {
|
||||
map.add(jsKey);
|
||||
}
|
||||
else {
|
||||
const stringKey = stringifyKey(key, jsKey, ctx);
|
||||
const jsValue = toJS.toJS(value, stringKey, ctx);
|
||||
if (stringKey in map)
|
||||
Object.defineProperty(map, stringKey, {
|
||||
value: jsValue,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
else
|
||||
map[stringKey] = jsValue;
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
function stringifyKey(key, jsKey, ctx) {
|
||||
if (jsKey === null)
|
||||
return '';
|
||||
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
||||
if (typeof jsKey !== 'object')
|
||||
return String(jsKey);
|
||||
if (identity.isNode(key) && ctx?.doc) {
|
||||
const strCtx = stringify.createStringifyContext(ctx.doc, {});
|
||||
strCtx.anchors = new Set();
|
||||
for (const node of ctx.anchors.keys())
|
||||
strCtx.anchors.add(node.anchor);
|
||||
strCtx.inFlow = true;
|
||||
strCtx.inStringifyKey = true;
|
||||
const strKey = key.toString(strCtx);
|
||||
if (!ctx.mapKeyWarned) {
|
||||
let jsonStr = JSON.stringify(strKey);
|
||||
if (jsonStr.length > 40)
|
||||
jsonStr = jsonStr.substring(0, 36) + '..."';
|
||||
log.warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
|
||||
ctx.mapKeyWarned = true;
|
||||
}
|
||||
return strKey;
|
||||
}
|
||||
return JSON.stringify(jsKey);
|
||||
}
|
||||
|
||||
exports.addPairToJSMap = addPairToJSMap;
|
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';
|
||||
import type { Alias } from './Alias';
|
||||
import type { Node } from './Node';
|
||||
import type { Pair } from './Pair';
|
||||
import type { Scalar } from './Scalar';
|
||||
import type { YAMLMap } from './YAMLMap';
|
||||
import type { YAMLSeq } from './YAMLSeq';
|
||||
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>;
|
||||
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;
|
29
node_modules/yaml/dist/nodes/toJS.d.ts
generated
vendored
Normal file
29
node_modules/yaml/dist/nodes/toJS.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
import type { Document } from '../doc/Document';
|
||||
import type { Node } from './Node';
|
||||
export interface AnchorData {
|
||||
aliasCount: number;
|
||||
count: number;
|
||||
res: unknown;
|
||||
}
|
||||
export interface ToJSContext {
|
||||
anchors: Map<Node, AnchorData>;
|
||||
/** Cached anchor and alias nodes in the order they occur in the document */
|
||||
aliasResolveCache?: Node[];
|
||||
doc: Document<Node, boolean>;
|
||||
keep: boolean;
|
||||
mapAsMap: boolean;
|
||||
mapKeyWarned: boolean;
|
||||
maxAliasCount: number;
|
||||
onCreate?: (res: unknown) => void;
|
||||
}
|
||||
/**
|
||||
* Recursively convert any node or its contents to native JavaScript
|
||||
*
|
||||
* @param value - The input value
|
||||
* @param arg - If `value` defines a `toJSON()` method, use this
|
||||
* as its first argument
|
||||
* @param ctx - Conversion context, originally set in Document#toJS(). If
|
||||
* `{ keep: true }` is not set, output should be suitable for JSON
|
||||
* stringification.
|
||||
*/
|
||||
export declare function toJS(value: any, arg: string | null, ctx?: ToJSContext): any;
|
39
node_modules/yaml/dist/nodes/toJS.js
generated
vendored
Normal file
39
node_modules/yaml/dist/nodes/toJS.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
var identity = require('./identity.js');
|
||||
|
||||
/**
|
||||
* Recursively convert any node or its contents to native JavaScript
|
||||
*
|
||||
* @param value - The input value
|
||||
* @param arg - If `value` defines a `toJSON()` method, use this
|
||||
* as its first argument
|
||||
* @param ctx - Conversion context, originally set in Document#toJS(). If
|
||||
* `{ keep: true }` is not set, output should be suitable for JSON
|
||||
* stringification.
|
||||
*/
|
||||
function toJS(value, arg, ctx) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
if (Array.isArray(value))
|
||||
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 || !identity.hasAnchor(value))
|
||||
return value.toJSON(arg, ctx);
|
||||
const data = { aliasCount: 0, count: 1, res: undefined };
|
||||
ctx.anchors.set(value, data);
|
||||
ctx.onCreate = res => {
|
||||
data.res = res;
|
||||
delete ctx.onCreate;
|
||||
};
|
||||
const res = value.toJSON(arg, ctx);
|
||||
if (ctx.onCreate)
|
||||
ctx.onCreate(res);
|
||||
return res;
|
||||
}
|
||||
if (typeof value === 'bigint' && !ctx?.keep)
|
||||
return Number(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
exports.toJS = toJS;
|
Reference in New Issue
Block a user