summaryrefslogtreecommitdiff
path: root/node_modules/yaml/dist
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-08-30 17:21:18 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-08-30 17:21:18 +0800
commitefbc2ffe6a1ee5ec38a4396305561d6515d0943e (patch)
tree2b4c94f18f2c792dfda813050755d5c0273fae22 /node_modules/yaml/dist
parent43acceb75957c880a5ba5a31aae221394a36d5f6 (diff)
node fixes, updates
Diffstat (limited to 'node_modules/yaml/dist')
-rw-r--r--node_modules/yaml/dist/cli.d.ts8
-rw-r--r--node_modules/yaml/dist/cli.mjs199
-rw-r--r--node_modules/yaml/dist/compose/compose-collection.d.ts8
-rw-r--r--node_modules/yaml/dist/compose/compose-collection.js18
-rw-r--r--node_modules/yaml/dist/compose/compose-doc.js1
-rw-r--r--node_modules/yaml/dist/compose/compose-node.d.ts1
-rw-r--r--node_modules/yaml/dist/compose/compose-node.js2
-rw-r--r--node_modules/yaml/dist/compose/compose-scalar.js2
-rw-r--r--node_modules/yaml/dist/compose/resolve-block-map.d.ts3
-rw-r--r--node_modules/yaml/dist/compose/resolve-block-map.js4
-rw-r--r--node_modules/yaml/dist/compose/resolve-block-scalar.d.ts3
-rw-r--r--node_modules/yaml/dist/compose/resolve-block-scalar.js8
-rw-r--r--node_modules/yaml/dist/compose/resolve-block-seq.d.ts2
-rw-r--r--node_modules/yaml/dist/compose/resolve-block-seq.js1
-rw-r--r--node_modules/yaml/dist/compose/resolve-flow-collection.js2
-rw-r--r--node_modules/yaml/dist/compose/resolve-props.d.ts5
-rw-r--r--node_modules/yaml/dist/compose/resolve-props.js34
-rw-r--r--node_modules/yaml/dist/nodes/Collection.d.ts1
-rw-r--r--node_modules/yaml/dist/nodes/Collection.js1
-rw-r--r--node_modules/yaml/dist/nodes/identity.d.ts2
-rw-r--r--node_modules/yaml/dist/parse/cst-scalar.js2
-rw-r--r--node_modules/yaml/dist/parse/cst.d.ts2
-rw-r--r--node_modules/yaml/dist/parse/lexer.js66
-rw-r--r--node_modules/yaml/dist/parse/parser.js23
-rw-r--r--node_modules/yaml/dist/schema/core/float.js2
-rw-r--r--node_modules/yaml/dist/schema/yaml-1.1/float.js2
-rw-r--r--node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts6
-rw-r--r--node_modules/yaml/dist/stringify/foldFlowLines.js2
-rw-r--r--node_modules/yaml/dist/stringify/stringifyPair.js2
29 files changed, 340 insertions, 72 deletions
diff --git a/node_modules/yaml/dist/cli.d.ts b/node_modules/yaml/dist/cli.d.ts
new file mode 100644
index 00000000..7e2ea2a2
--- /dev/null
+++ b/node_modules/yaml/dist/cli.d.ts
@@ -0,0 +1,8 @@
+export declare const help = "yaml: A command-line YAML processor and inspector\n\nReads stdin and writes output to stdout and errors & warnings to stderr.\n\nUsage:\n yaml Process a YAML stream, outputting it as YAML\n yaml cst Parse the CST of a YAML stream\n yaml lex Parse the lexical tokens of a YAML stream\n yaml valid Validate a YAML stream, returning 0 on success\n\nOptions:\n --help, -h Show this message.\n --json, -j Output JSON.\n --indent 2 Output pretty-printed data, indented by the given number of spaces.\n\nAdditional options for bare \"yaml\" command:\n --doc, -d Output pretty-printed JS Document objects.\n --single, -1 Require the input to consist of a single YAML document.\n --strict, -s Stop on errors.\n --visit, -v Apply a visitor to each document (requires a path to import)\n --yaml 1.1 Set the YAML version. (default: 1.2)";
+export declare class UserError extends Error {
+ static ARGS: number;
+ static SINGLE: number;
+ code: number;
+ constructor(code: number, message: string);
+}
+export declare function cli(stdin: NodeJS.ReadableStream, done: (error?: Error) => void, argv?: string[]): Promise<void>;
diff --git a/node_modules/yaml/dist/cli.mjs b/node_modules/yaml/dist/cli.mjs
new file mode 100644
index 00000000..d3c7d43e
--- /dev/null
+++ b/node_modules/yaml/dist/cli.mjs
@@ -0,0 +1,199 @@
+import { resolve } from 'node:path';
+import { parseArgs } from 'node:util';
+import { prettyToken } from './parse/cst.js';
+import { Lexer } from './parse/lexer.js';
+import { Parser } from './parse/parser.js';
+import { Composer } from './compose/composer.js';
+import { LineCounter } from './parse/line-counter.js';
+import { prettifyError } from './errors.js';
+import { visit } from './visit.js';
+
+const help = `\
+yaml: A command-line YAML processor and inspector
+
+Reads stdin and writes output to stdout and errors & warnings to stderr.
+
+Usage:
+ yaml Process a YAML stream, outputting it as YAML
+ yaml cst Parse the CST of a YAML stream
+ yaml lex Parse the lexical tokens of a YAML stream
+ yaml valid Validate a YAML stream, returning 0 on success
+
+Options:
+ --help, -h Show this message.
+ --json, -j Output JSON.
+ --indent 2 Output pretty-printed data, indented by the given number of spaces.
+
+Additional options for bare "yaml" command:
+ --doc, -d Output pretty-printed JS Document objects.
+ --single, -1 Require the input to consist of a single YAML document.
+ --strict, -s Stop on errors.
+ --visit, -v Apply a visitor to each document (requires a path to import)
+ --yaml 1.1 Set the YAML version. (default: 1.2)`;
+class UserError extends Error {
+ constructor(code, message) {
+ super(`Error: ${message}`);
+ this.code = code;
+ }
+}
+UserError.ARGS = 2;
+UserError.SINGLE = 3;
+async function cli(stdin, done, argv) {
+ let args;
+ try {
+ args = parseArgs({
+ args: argv,
+ allowPositionals: true,
+ options: {
+ doc: { type: 'boolean', short: 'd' },
+ help: { type: 'boolean', short: 'h' },
+ indent: { type: 'string', short: 'i' },
+ json: { type: 'boolean', short: 'j' },
+ single: { type: 'boolean', short: '1' },
+ strict: { type: 'boolean', short: 's' },
+ visit: { type: 'string', short: 'v' },
+ yaml: { type: 'string', default: '1.2' }
+ }
+ });
+ }
+ catch (error) {
+ return done(new UserError(UserError.ARGS, error.message));
+ }
+ const { positionals: [mode], values: opt } = args;
+ let indent = Number(opt.indent);
+ stdin.setEncoding('utf-8');
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
+ switch (opt.help || mode) {
+ /* istanbul ignore next */
+ case true: // --help
+ console.log(help);
+ break;
+ case 'lex': {
+ const lexer = new Lexer();
+ const data = [];
+ const add = (tok) => {
+ if (opt.json)
+ data.push(tok);
+ else
+ console.log(prettyToken(tok));
+ };
+ stdin.on('data', (chunk) => {
+ for (const tok of lexer.lex(chunk, true))
+ add(tok);
+ });
+ stdin.on('end', () => {
+ for (const tok of lexer.lex('', false))
+ add(tok);
+ if (opt.json)
+ console.log(JSON.stringify(data, null, indent));
+ done();
+ });
+ break;
+ }
+ case 'cst': {
+ const parser = new Parser();
+ const data = [];
+ const add = (tok) => {
+ if (opt.json)
+ data.push(tok);
+ else
+ console.dir(tok, { depth: null });
+ };
+ stdin.on('data', (chunk) => {
+ for (const tok of parser.parse(chunk, true))
+ add(tok);
+ });
+ stdin.on('end', () => {
+ for (const tok of parser.parse('', false))
+ add(tok);
+ if (opt.json)
+ console.log(JSON.stringify(data, null, indent));
+ done();
+ });
+ break;
+ }
+ case undefined:
+ case 'valid': {
+ const lineCounter = new LineCounter();
+ const parser = new Parser(lineCounter.addNewLine);
+ // @ts-expect-error Version is validated at runtime
+ const composer = new Composer({ version: opt.yaml });
+ const visitor = opt.visit
+ ? (await import(resolve(opt.visit))).default
+ : null;
+ let source = '';
+ let hasDoc = false;
+ let reqDocEnd = false;
+ const data = [];
+ const add = (doc) => {
+ if (hasDoc && opt.single) {
+ return done(new UserError(UserError.SINGLE, 'Input stream contains multiple documents'));
+ }
+ for (const error of doc.errors) {
+ prettifyError(source, lineCounter)(error);
+ if (opt.strict || mode === 'valid')
+ return done(error);
+ console.error(error);
+ }
+ for (const warning of doc.warnings) {
+ prettifyError(source, lineCounter)(warning);
+ console.error(warning);
+ }
+ if (visitor)
+ visit(doc, visitor);
+ if (mode === 'valid')
+ doc.toJS();
+ else if (opt.json)
+ data.push(doc);
+ else if (opt.doc) {
+ Object.defineProperties(doc, {
+ options: { enumerable: false },
+ schema: { enumerable: false }
+ });
+ console.dir(doc, { depth: null });
+ }
+ else {
+ if (reqDocEnd)
+ console.log('...');
+ try {
+ indent || (indent = 2);
+ const str = doc.toString({ indent });
+ console.log(str.endsWith('\n') ? str.slice(0, -1) : str);
+ }
+ catch (error) {
+ done(error);
+ }
+ }
+ hasDoc = true;
+ reqDocEnd = !doc.directives?.docEnd;
+ };
+ stdin.on('data', (chunk) => {
+ source += chunk;
+ for (const tok of parser.parse(chunk, true)) {
+ for (const doc of composer.next(tok))
+ add(doc);
+ }
+ });
+ stdin.on('end', () => {
+ for (const tok of parser.parse('', false)) {
+ for (const doc of composer.next(tok))
+ add(doc);
+ }
+ for (const doc of composer.end(false))
+ add(doc);
+ if (opt.single && !hasDoc) {
+ return done(new UserError(UserError.SINGLE, 'Input stream contained no documents'));
+ }
+ if (mode !== 'valid' && opt.json) {
+ console.log(JSON.stringify(opt.single ? data[0] : data, null, indent));
+ }
+ done();
+ });
+ break;
+ }
+ default:
+ done(new UserError(UserError.ARGS, `Unknown command: ${JSON.stringify(mode)}`));
+ }
+}
+
+export { UserError, cli, help };
diff --git a/node_modules/yaml/dist/compose/compose-collection.d.ts b/node_modules/yaml/dist/compose/compose-collection.d.ts
index b310e2da..22fe5162 100644
--- a/node_modules/yaml/dist/compose/compose-collection.d.ts
+++ b/node_modules/yaml/dist/compose/compose-collection.d.ts
@@ -2,4 +2,10 @@ import type { ParsedNode } from '../nodes/Node.js';
import type { BlockMap, BlockSequence, FlowCollection, SourceToken } from '../parse/cst.js';
import type { ComposeContext, ComposeNode } from './compose-node.js';
import type { ComposeErrorHandler } from './composer.js';
-export declare function composeCollection(CN: ComposeNode, ctx: ComposeContext, token: BlockMap | BlockSequence | FlowCollection, tagToken: SourceToken | null, onError: ComposeErrorHandler): ParsedNode;
+interface Props {
+ anchor: SourceToken | null;
+ tag: SourceToken | null;
+ newlineAfterProp: SourceToken | null;
+}
+export declare function composeCollection(CN: ComposeNode, ctx: ComposeContext, token: BlockMap | BlockSequence | FlowCollection, props: Props, onError: ComposeErrorHandler): ParsedNode;
+export {};
diff --git a/node_modules/yaml/dist/compose/compose-collection.js b/node_modules/yaml/dist/compose/compose-collection.js
index e4b19715..3f91468c 100644
--- a/node_modules/yaml/dist/compose/compose-collection.js
+++ b/node_modules/yaml/dist/compose/compose-collection.js
@@ -25,10 +25,23 @@ function resolveCollection(CN, ctx, token, onError, tagName, tag) {
coll.tag = tagName;
return coll;
}
-function composeCollection(CN, ctx, token, tagToken, onError) {
+function composeCollection(CN, ctx, token, props, onError) {
+ const tagToken = props.tag;
const tagName = !tagToken
? null
: ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
+ if (token.type === 'block-seq') {
+ const { anchor, newlineAfterProp: nl } = props;
+ const lastProp = anchor && tagToken
+ ? anchor.offset > tagToken.offset
+ ? anchor
+ : tagToken
+ : (anchor ?? tagToken);
+ if (lastProp && (!nl || nl.offset < lastProp.offset)) {
+ const message = 'Missing newline after block sequence props';
+ onError(lastProp, 'MISSING_CHAR', message);
+ }
+ }
const expType = token.type === 'block-map'
? 'map'
: token.type === 'block-seq'
@@ -42,8 +55,7 @@ function composeCollection(CN, ctx, token, tagToken, onError) {
!tagName ||
tagName === '!' ||
(tagName === YAMLMap.YAMLMap.tagName && expType === 'map') ||
- (tagName === YAMLSeq.YAMLSeq.tagName && expType === 'seq') ||
- !expType) {
+ (tagName === YAMLSeq.YAMLSeq.tagName && expType === 'seq')) {
return resolveCollection(CN, ctx, token, onError, tagName);
}
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
diff --git a/node_modules/yaml/dist/compose/compose-doc.js b/node_modules/yaml/dist/compose/compose-doc.js
index d19c2276..24f1c14a 100644
--- a/node_modules/yaml/dist/compose/compose-doc.js
+++ b/node_modules/yaml/dist/compose/compose-doc.js
@@ -19,6 +19,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
next: value ?? end?.[0],
offset,
onError,
+ parentIndent: 0,
startOnNewline: true
});
if (props.found) {
diff --git a/node_modules/yaml/dist/compose/compose-node.d.ts b/node_modules/yaml/dist/compose/compose-node.d.ts
index 8d3e4673..85d6820f 100644
--- a/node_modules/yaml/dist/compose/compose-node.d.ts
+++ b/node_modules/yaml/dist/compose/compose-node.d.ts
@@ -15,6 +15,7 @@ interface Props {
comment: string;
anchor: SourceToken | null;
tag: SourceToken | null;
+ newlineAfterProp: SourceToken | null;
end: number;
}
declare const CN: {
diff --git a/node_modules/yaml/dist/compose/compose-node.js b/node_modules/yaml/dist/compose/compose-node.js
index 7eb1daf5..c6c61dd2 100644
--- a/node_modules/yaml/dist/compose/compose-node.js
+++ b/node_modules/yaml/dist/compose/compose-node.js
@@ -28,7 +28,7 @@ function composeNode(ctx, token, props, onError) {
case 'block-map':
case 'block-seq':
case 'flow-collection':
- node = composeCollection.composeCollection(CN, ctx, token, tag, onError);
+ node = composeCollection.composeCollection(CN, ctx, token, props, onError);
if (anchor)
node.anchor = anchor.source.substring(1);
break;
diff --git a/node_modules/yaml/dist/compose/compose-scalar.js b/node_modules/yaml/dist/compose/compose-scalar.js
index ace89644..19cff3bf 100644
--- a/node_modules/yaml/dist/compose/compose-scalar.js
+++ b/node_modules/yaml/dist/compose/compose-scalar.js
@@ -7,7 +7,7 @@ var resolveFlowScalar = require('./resolve-flow-scalar.js');
function composeScalar(ctx, token, tagToken, onError) {
const { value, type, comment, range } = token.type === 'block-scalar'
- ? resolveBlockScalar.resolveBlockScalar(token, ctx.options.strict, onError)
+ ? resolveBlockScalar.resolveBlockScalar(ctx, token, onError)
: resolveFlowScalar.resolveFlowScalar(token, ctx.options.strict, onError);
const tagName = tagToken
? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg))
diff --git a/node_modules/yaml/dist/compose/resolve-block-map.d.ts b/node_modules/yaml/dist/compose/resolve-block-map.d.ts
index 58855c8c..cf82dee9 100644
--- a/node_modules/yaml/dist/compose/resolve-block-map.d.ts
+++ b/node_modules/yaml/dist/compose/resolve-block-map.d.ts
@@ -1,7 +1,6 @@
-import type { ParsedNode } from '../nodes/Node.js';
import { YAMLMap } from '../nodes/YAMLMap.js';
import type { BlockMap } from '../parse/cst.js';
import { CollectionTag } from '../schema/types.js';
import type { ComposeContext, ComposeNode } from './compose-node.js';
import type { ComposeErrorHandler } from './composer.js';
-export declare function resolveBlockMap({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bm: BlockMap, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLMap.Parsed<ParsedNode, ParsedNode | null>;
+export declare function resolveBlockMap({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bm: BlockMap, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLMap.Parsed;
diff --git a/node_modules/yaml/dist/compose/resolve-block-map.js b/node_modules/yaml/dist/compose/resolve-block-map.js
index 8e2b18a9..f9126f62 100644
--- a/node_modules/yaml/dist/compose/resolve-block-map.js
+++ b/node_modules/yaml/dist/compose/resolve-block-map.js
@@ -23,6 +23,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
next: key ?? sep?.[0],
offset,
onError,
+ parentIndent: bm.indent,
startOnNewline: true
});
const implicitKey = !keyProps.found;
@@ -43,7 +44,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
}
continue;
}
- if (keyProps.hasNewlineAfterProp || utilContainsNewline.containsNewline(key)) {
+ if (keyProps.newlineAfterProp || utilContainsNewline.containsNewline(key)) {
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
}
}
@@ -65,6 +66,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, ta
next: value,
offset: keyNode.range[2],
onError,
+ parentIndent: bm.indent,
startOnNewline: !key || key.type === 'block-scalar'
});
offset = valueProps.end;
diff --git a/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts b/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts
index 4855b193..6d229016 100644
--- a/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts
+++ b/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts
@@ -1,8 +1,9 @@
import { Range } from '../nodes/Node.js';
import { Scalar } from '../nodes/Scalar.js';
import type { BlockScalar } from '../parse/cst.js';
+import type { ComposeContext } from './compose-node.js';
import type { ComposeErrorHandler } from './composer.js';
-export declare function resolveBlockScalar(scalar: BlockScalar, strict: boolean, onError: ComposeErrorHandler): {
+export declare function resolveBlockScalar(ctx: ComposeContext, scalar: BlockScalar, onError: ComposeErrorHandler): {
value: string;
type: Scalar.BLOCK_FOLDED | Scalar.BLOCK_LITERAL | null;
comment: string;
diff --git a/node_modules/yaml/dist/compose/resolve-block-scalar.js b/node_modules/yaml/dist/compose/resolve-block-scalar.js
index ba89f978..97eaf2b5 100644
--- a/node_modules/yaml/dist/compose/resolve-block-scalar.js
+++ b/node_modules/yaml/dist/compose/resolve-block-scalar.js
@@ -2,9 +2,9 @@
var Scalar = require('../nodes/Scalar.js');
-function resolveBlockScalar(scalar, strict, onError) {
+function resolveBlockScalar(ctx, scalar, onError) {
const start = scalar.offset;
- const header = parseBlockScalarHeader(scalar, strict, onError);
+ const header = parseBlockScalarHeader(scalar, ctx.options.strict, onError);
if (!header)
return { value: '', type: null, comment: '', range: [start, start, start] };
const type = header.mode === '>' ? Scalar.Scalar.BLOCK_FOLDED : Scalar.Scalar.BLOCK_LITERAL;
@@ -46,6 +46,10 @@ function resolveBlockScalar(scalar, strict, onError) {
if (header.indent === 0)
trimIndent = indent.length;
contentStart = i;
+ if (trimIndent === 0 && !ctx.atRoot) {
+ const message = 'Block scalar values in collections must be indented';
+ onError(offset, 'BAD_INDENT', message);
+ }
break;
}
offset += indent.length + content.length + 1;
diff --git a/node_modules/yaml/dist/compose/resolve-block-seq.d.ts b/node_modules/yaml/dist/compose/resolve-block-seq.d.ts
index 3a15f520..139ad259 100644
--- a/node_modules/yaml/dist/compose/resolve-block-seq.d.ts
+++ b/node_modules/yaml/dist/compose/resolve-block-seq.d.ts
@@ -3,4 +3,4 @@ import type { BlockSequence } from '../parse/cst.js';
import { CollectionTag } from '../schema/types.js';
import type { ComposeContext, ComposeNode } from './compose-node.js';
import type { ComposeErrorHandler } from './composer.js';
-export declare function resolveBlockSeq({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bs: BlockSequence, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLSeq.Parsed<import("../index.js").ParsedNode>;
+export declare function resolveBlockSeq({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bs: BlockSequence, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLSeq.Parsed;
diff --git a/node_modules/yaml/dist/compose/resolve-block-seq.js b/node_modules/yaml/dist/compose/resolve-block-seq.js
index 9bb26dbc..0f175dca 100644
--- a/node_modules/yaml/dist/compose/resolve-block-seq.js
+++ b/node_modules/yaml/dist/compose/resolve-block-seq.js
@@ -17,6 +17,7 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, ta
next: value,
offset,
onError,
+ parentIndent: bs.indent,
startOnNewline: true
});
if (!props.found) {
diff --git a/node_modules/yaml/dist/compose/resolve-flow-collection.js b/node_modules/yaml/dist/compose/resolve-flow-collection.js
index ec29d08e..2eab0a52 100644
--- a/node_modules/yaml/dist/compose/resolve-flow-collection.js
+++ b/node_modules/yaml/dist/compose/resolve-flow-collection.js
@@ -30,6 +30,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
next: key ?? sep?.[0],
offset,
onError,
+ parentIndent: fc.indent,
startOnNewline: false
});
if (!props.found) {
@@ -111,6 +112,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
next: value,
offset: keyNode.range[2],
onError,
+ parentIndent: fc.indent,
startOnNewline: false
});
if (valueProps.found) {
diff --git a/node_modules/yaml/dist/compose/resolve-props.d.ts b/node_modules/yaml/dist/compose/resolve-props.d.ts
index fba44cf7..ea3d8288 100644
--- a/node_modules/yaml/dist/compose/resolve-props.d.ts
+++ b/node_modules/yaml/dist/compose/resolve-props.d.ts
@@ -6,17 +6,18 @@ export interface ResolvePropsArg {
next: Token | null | undefined;
offset: number;
onError: ComposeErrorHandler;
+ parentIndent: number;
startOnNewline: boolean;
}
-export declare function resolveProps(tokens: SourceToken[], { flow, indicator, next, offset, onError, startOnNewline }: ResolvePropsArg): {
+export declare function resolveProps(tokens: SourceToken[], { flow, indicator, next, offset, onError, parentIndent, startOnNewline }: ResolvePropsArg): {
comma: SourceToken | null;
found: SourceToken | null;
spaceBefore: boolean;
comment: string;
hasNewline: boolean;
- hasNewlineAfterProp: boolean;
anchor: SourceToken | null;
tag: SourceToken | null;
+ newlineAfterProp: SourceToken | null;
end: number;
start: number;
};
diff --git a/node_modules/yaml/dist/compose/resolve-props.js b/node_modules/yaml/dist/compose/resolve-props.js
index bc2ef22d..9b63cfd2 100644
--- a/node_modules/yaml/dist/compose/resolve-props.js
+++ b/node_modules/yaml/dist/compose/resolve-props.js
@@ -1,16 +1,17 @@
'use strict';
-function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnNewline }) {
+function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {
let spaceBefore = false;
let atNewline = startOnNewline;
let hasSpace = startOnNewline;
let comment = '';
let commentSep = '';
let hasNewline = false;
- let hasNewlineAfterProp = false;
let reqSpace = false;
+ let tab = null;
let anchor = null;
let tag = null;
+ let newlineAfterProp = null;
let comma = null;
let found = null;
let start = null;
@@ -22,16 +23,22 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
onError(token.offset, 'MISSING_CHAR', 'Tags and anchors must be separated from the next token by white space');
reqSpace = false;
}
+ if (tab) {
+ if (atNewline && token.type !== 'comment' && token.type !== 'newline') {
+ onError(tab, 'TAB_AS_INDENT', 'Tabs are not allowed as indentation');
+ }
+ tab = null;
+ }
switch (token.type) {
case 'space':
// At the doc level, tabs at line start may be parsed
// as leading white space rather than indentation.
// In a flow collection, only the parser handles indent.
if (!flow &&
- atNewline &&
- indicator !== 'doc-start' &&
- token.source[0] === '\t')
- onError(token, 'TAB_AS_INDENT', 'Tabs are not allowed as indentation');
+ (indicator !== 'doc-start' || next?.type !== 'flow-collection') &&
+ token.source.includes('\t')) {
+ tab = token;
+ }
hasSpace = true;
break;
case 'comment': {
@@ -58,7 +65,7 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
atNewline = true;
hasNewline = true;
if (anchor || tag)
- hasNewlineAfterProp = true;
+ newlineAfterProp = token;
hasSpace = true;
break;
case 'anchor':
@@ -91,7 +98,8 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
if (found)
onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow ?? 'collection'}`);
found = token;
- atNewline = false;
+ atNewline =
+ indicator === 'seq-item-ind' || indicator === 'explicit-key-ind';
hasSpace = false;
break;
case 'comma':
@@ -117,17 +125,23 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnN
next.type !== 'space' &&
next.type !== 'newline' &&
next.type !== 'comma' &&
- (next.type !== 'scalar' || next.source !== ''))
+ (next.type !== 'scalar' || next.source !== '')) {
onError(next.offset, 'MISSING_CHAR', 'Tags and anchors must be separated from the next token by white space');
+ }
+ if (tab &&
+ ((atNewline && tab.indent <= parentIndent) ||
+ next?.type === 'block-map' ||
+ next?.type === 'block-seq'))
+ onError(tab, 'TAB_AS_INDENT', 'Tabs are not allowed as indentation');
return {
comma,
found,
spaceBefore,
comment,
hasNewline,
- hasNewlineAfterProp,
anchor,
tag,
+ newlineAfterProp,
end,
start: start ?? end
};
diff --git a/node_modules/yaml/dist/nodes/Collection.d.ts b/node_modules/yaml/dist/nodes/Collection.d.ts
index 981ca115..0b5979d9 100644
--- a/node_modules/yaml/dist/nodes/Collection.d.ts
+++ b/node_modules/yaml/dist/nodes/Collection.d.ts
@@ -4,7 +4,6 @@ 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;
schema: Schema | undefined;
[NODE_TYPE]: symbol;
items: unknown[];
diff --git a/node_modules/yaml/dist/nodes/Collection.js b/node_modules/yaml/dist/nodes/Collection.js
index 1c03294f..bdf8cb4f 100644
--- a/node_modules/yaml/dist/nodes/Collection.js
+++ b/node_modules/yaml/dist/nodes/Collection.js
@@ -145,7 +145,6 @@ class Collection extends Node.NodeBase {
}
}
}
-Collection.maxFlowStringSingleLineLength = 60;
exports.Collection = Collection;
exports.collectionFromPath = collectionFromPath;
diff --git a/node_modules/yaml/dist/nodes/identity.d.ts b/node_modules/yaml/dist/nodes/identity.d.ts
index c12fdf78..a576b1a6 100644
--- a/node_modules/yaml/dist/nodes/identity.d.ts
+++ b/node_modules/yaml/dist/nodes/identity.d.ts
@@ -13,7 +13,7 @@ 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 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>;
diff --git a/node_modules/yaml/dist/parse/cst-scalar.js b/node_modules/yaml/dist/parse/cst-scalar.js
index 11c5fccb..81b8463f 100644
--- a/node_modules/yaml/dist/parse/cst-scalar.js
+++ b/node_modules/yaml/dist/parse/cst-scalar.js
@@ -20,7 +20,7 @@ function resolveAsScalar(token, strict = true, onError) {
case 'double-quoted-scalar':
return resolveFlowScalar.resolveFlowScalar(token, strict, _onError);
case 'block-scalar':
- return resolveBlockScalar.resolveBlockScalar(token, strict, _onError);
+ return resolveBlockScalar.resolveBlockScalar({ options: { strict } }, token, _onError);
}
}
return null;
diff --git a/node_modules/yaml/dist/parse/cst.d.ts b/node_modules/yaml/dist/parse/cst.d.ts
index ec57ace1..18bdb04b 100644
--- a/node_modules/yaml/dist/parse/cst.d.ts
+++ b/node_modules/yaml/dist/parse/cst.d.ts
@@ -51,11 +51,13 @@ export interface BlockMap {
indent: number;
items: Array<{
start: SourceToken[];
+ explicitKey?: true;
key?: never;
sep?: never;
value?: never;
} | {
start: SourceToken[];
+ explicitKey?: true;
key: Token | null;
sep: SourceToken[];
value?: Token;
diff --git a/node_modules/yaml/dist/parse/lexer.js b/node_modules/yaml/dist/parse/lexer.js
index f408ce49..9ac766e9 100644
--- a/node_modules/yaml/dist/parse/lexer.js
+++ b/node_modules/yaml/dist/parse/lexer.js
@@ -81,11 +81,11 @@ function isEmpty(ch) {
return false;
}
}
-const hexDigits = '0123456789ABCDEFabcdef'.split('');
-const tagChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()".split('');
-const invalidFlowScalarChars = ',[]{}'.split('');
-const invalidAnchorChars = ' ,[]{}\n\r\t'.split('');
-const isNotAnchorChar = (ch) => !ch || invalidAnchorChars.includes(ch);
+const hexDigits = new Set('0123456789ABCDEFabcdef');
+const tagChars = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()");
+const flowIndicatorChars = new Set(',[]{}');
+const invalidAnchorChars = new Set(' ,[]{}\n\r\t');
+const isNotAnchorChar = (ch) => !ch || invalidAnchorChars.has(ch);
/**
* Splits an input string into lexical tokens, i.e. smaller strings that are
* easily identifiable by `tokens.tokenType()`.
@@ -151,6 +151,8 @@ class Lexer {
*/
*lex(source, incomplete = false) {
if (source) {
+ if (typeof source !== 'string')
+ throw TypeError('source is not a string');
this.buffer = this.buffer ? this.buffer + source : source;
this.lineEndPos = null;
}
@@ -250,11 +252,16 @@ class Lexer {
}
if (line[0] === '%') {
let dirEnd = line.length;
- const cs = line.indexOf('#');
- if (cs !== -1) {
+ let cs = line.indexOf('#');
+ while (cs !== -1) {
const ch = line[cs - 1];
- if (ch === ' ' || ch === '\t')
+ if (ch === ' ' || ch === '\t') {
dirEnd = cs - 1;
+ break;
+ }
+ else {
+ cs = line.indexOf('#', cs + 1);
+ }
}
while (true) {
const ch = line[dirEnd - 1];
@@ -285,15 +292,11 @@ class Lexer {
if (!this.atEnd && !this.hasChars(4))
return this.setNext('line-start');
const s = this.peek(3);
- if (s === '---' && isEmpty(this.charAt(3))) {
+ if ((s === '---' || s === '...') && isEmpty(this.charAt(3))) {
yield* this.pushCount(3);
this.indentValue = 0;
this.indentNext = 0;
- return 'doc';
- }
- else if (s === '...' && isEmpty(this.charAt(3))) {
- yield* this.pushCount(3);
- return 'stream';
+ return s === '---' ? 'doc' : 'stream';
}
}
this.indentValue = yield* this.pushSpaces(false);
@@ -520,8 +523,10 @@ class Lexer {
if (indent >= this.indentNext) {
if (this.blockScalarIndent === -1)
this.indentNext = indent;
- else
- this.indentNext += this.blockScalarIndent;
+ else {
+ this.indentNext =
+ this.blockScalarIndent + (this.indentNext === 0 ? 1 : this.indentNext);
+ }
do {
const cs = this.continueScalar(nl + 1);
if (cs === -1)
@@ -534,14 +539,25 @@ class Lexer {
nl = this.buffer.length;
}
}
- if (!this.blockScalarKeep) {
+ // Trailing insufficiently indented tabs are invalid.
+ // To catch that during parsing, we include them in the block scalar value.
+ let i = nl + 1;
+ ch = this.buffer[i];
+ while (ch === ' ')
+ ch = this.buffer[++i];
+ if (ch === '\t') {
+ while (ch === '\t' || ch === ' ' || ch === '\r' || ch === '\n')
+ ch = this.buffer[++i];
+ nl = i - 1;
+ }
+ else if (!this.blockScalarKeep) {
do {
let i = nl - 1;
let ch = this.buffer[i];
if (ch === '\r')
ch = this.buffer[--i];
const lastChar = i; // Drop the line if last char not more indented
- while (ch === ' ' || ch === '\t')
+ while (ch === ' ')
ch = this.buffer[--i];
if (ch === '\n' && i >= this.pos && i + 1 + indent > lastChar)
nl = i;
@@ -561,7 +577,7 @@ class Lexer {
while ((ch = this.buffer[++i])) {
if (ch === ':') {
const next = this.buffer[i + 1];
- if (isEmpty(next) || (inFlow && next === ','))
+ if (isEmpty(next) || (inFlow && flowIndicatorChars.has(next)))
break;
end = i;
}
@@ -576,7 +592,7 @@ class Lexer {
else
end = i;
}
- if (next === '#' || (inFlow && invalidFlowScalarChars.includes(next)))
+ if (next === '#' || (inFlow && flowIndicatorChars.has(next)))
break;
if (ch === '\n') {
const cs = this.continueScalar(i + 1);
@@ -586,7 +602,7 @@ class Lexer {
}
}
else {
- if (inFlow && invalidFlowScalarChars.includes(ch))
+ if (inFlow && flowIndicatorChars.has(ch))
break;
end = i;
}
@@ -631,7 +647,7 @@ class Lexer {
case ':': {
const inFlow = this.flowLevel > 0;
const ch1 = this.charAt(1);
- if (isEmpty(ch1) || (inFlow && invalidFlowScalarChars.includes(ch1))) {
+ if (isEmpty(ch1) || (inFlow && flowIndicatorChars.has(ch1))) {
if (!inFlow)
this.indentNext = this.indentValue + 1;
else if (this.flowKey)
@@ -656,11 +672,11 @@ class Lexer {
let i = this.pos + 1;
let ch = this.buffer[i];
while (ch) {
- if (tagChars.includes(ch))
+ if (tagChars.has(ch))
ch = this.buffer[++i];
else if (ch === '%' &&
- hexDigits.includes(this.buffer[i + 1]) &&
- hexDigits.includes(this.buffer[i + 2])) {
+ hexDigits.has(this.buffer[i + 1]) &&
+ hexDigits.has(this.buffer[i + 2])) {
ch = this.buffer[(i += 3)];
}
else
diff --git a/node_modules/yaml/dist/parse/parser.js b/node_modules/yaml/dist/parse/parser.js
index 7a1493d8..91fb676a 100644
--- a/node_modules/yaml/dist/parse/parser.js
+++ b/node_modules/yaml/dist/parse/parser.js
@@ -308,7 +308,7 @@ class Parser {
}
else {
Object.assign(it, { key: token, sep: [] });
- this.onKeyLine = !includesToken(it.start, 'explicit-key-ind');
+ this.onKeyLine = !it.explicitKey;
return;
}
break;
@@ -517,9 +517,9 @@ class Parser {
return;
}
if (this.indent >= map.indent) {
- const atNextItem = !this.onKeyLine &&
- this.indent === map.indent &&
- it.sep &&
+ const atMapIndent = !this.onKeyLine && this.indent === map.indent;
+ const atNextItem = atMapIndent &&
+ (it.sep || it.explicitKey) &&
this.type !== 'seq-item-ind';
// For empty nodes, assign newline-separated not indented empty tokens to following node
let start = [];
@@ -560,25 +560,26 @@ class Parser {
}
return;
case 'explicit-key-ind':
- if (!it.sep && !includesToken(it.start, 'explicit-key-ind')) {
+ if (!it.sep && !it.explicitKey) {
it.start.push(this.sourceToken);
+ it.explicitKey = true;
}
else if (atNextItem || it.value) {
start.push(this.sourceToken);
- map.items.push({ start });
+ map.items.push({ start, explicitKey: true });
}
else {
this.stack.push({
type: 'block-map',
offset: this.offset,
indent: this.indent,
- items: [{ start: [this.sourceToken] }]
+ items: [{ start: [this.sourceToken], explicitKey: true }]
});
}
this.onKeyLine = true;
return;
case 'map-value-ind':
- if (includesToken(it.start, 'explicit-key-ind')) {
+ if (it.explicitKey) {
if (!it.sep) {
if (includesToken(it.start, 'newline')) {
Object.assign(it, { key: null, sep: [this.sourceToken] });
@@ -669,9 +670,7 @@ class Parser {
default: {
const bv = this.startBlockValue(map);
if (bv) {
- if (atNextItem &&
- bv.type !== 'block-seq' &&
- includesToken(it.start, 'explicit-key-ind')) {
+ if (atMapIndent && bv.type !== 'block-seq') {
map.items.push({ start });
}
this.stack.push(bv);
@@ -892,7 +891,7 @@ class Parser {
type: 'block-map',
offset: this.offset,
indent: this.indent,
- items: [{ start }]
+ items: [{ start, explicitKey: true }]
};
}
case 'map-value-ind': {
diff --git a/node_modules/yaml/dist/schema/core/float.js b/node_modules/yaml/dist/schema/core/float.js
index a1c96ddb..8756446e 100644
--- a/node_modules/yaml/dist/schema/core/float.js
+++ b/node_modules/yaml/dist/schema/core/float.js
@@ -7,7 +7,7 @@ const floatNaN = {
identify: value => typeof value === 'number',
default: true,
tag: 'tag:yaml.org,2002:float',
- test: /^(?:[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN))$/,
+ test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
resolve: str => str.slice(-3).toLowerCase() === 'nan'
? NaN
: str[0] === '-'
diff --git a/node_modules/yaml/dist/schema/yaml-1.1/float.js b/node_modules/yaml/dist/schema/yaml-1.1/float.js
index 4aea19a4..39f1eb0c 100644
--- a/node_modules/yaml/dist/schema/yaml-1.1/float.js
+++ b/node_modules/yaml/dist/schema/yaml-1.1/float.js
@@ -7,7 +7,7 @@ const floatNaN = {
identify: value => typeof value === 'number',
default: true,
tag: 'tag:yaml.org,2002:float',
- test: /^[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN)$/,
+ test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
resolve: (str) => str.slice(-3).toLowerCase() === 'nan'
? NaN
: str[0] === '-'
diff --git a/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts b/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts
index 12727dc2..95b03c72 100644
--- a/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts
+++ b/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts
@@ -9,12 +9,12 @@ export declare class YAMLOMap extends YAMLSeq {
add: (pair: import("../../index.js").Pair<any, any> | {
key: any;
value: any;
- }, overwrite?: boolean | undefined) => void;
+ }, overwrite?: boolean) => void;
delete: (key: unknown) => boolean;
get: {
(key: unknown, keepScalar: true): import("../../index.js").Scalar<any> | undefined;
- (key: unknown, keepScalar?: false | undefined): any;
- (key: unknown, keepScalar?: boolean | undefined): any;
+ (key: unknown, keepScalar?: false): any;
+ (key: unknown, keepScalar?: boolean): any;
};
has: (key: unknown) => boolean;
set: (key: any, value: any) => void;
diff --git a/node_modules/yaml/dist/stringify/foldFlowLines.js b/node_modules/yaml/dist/stringify/foldFlowLines.js
index 829a5601..9c610589 100644
--- a/node_modules/yaml/dist/stringify/foldFlowLines.js
+++ b/node_modules/yaml/dist/stringify/foldFlowLines.js
@@ -11,6 +11,8 @@ const FOLD_QUOTED = 'quoted';
function foldFlowLines(text, indent, mode = 'flow', { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
if (!lineWidth || lineWidth < 0)
return text;
+ if (lineWidth < minContentWidth)
+ minContentWidth = 0;
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
if (text.length <= endStep)
return text;
diff --git a/node_modules/yaml/dist/stringify/stringifyPair.js b/node_modules/yaml/dist/stringify/stringifyPair.js
index f5fc0ba9..716ea9a1 100644
--- a/node_modules/yaml/dist/stringify/stringifyPair.js
+++ b/node_modules/yaml/dist/stringify/stringifyPair.js
@@ -12,7 +12,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
if (keyComment) {
throw new Error('With simple keys, key nodes cannot have comments');
}
- if (identity.isCollection(key)) {
+ if (identity.isCollection(key) || (!identity.isNode(key) && typeof key === 'object')) {
const msg = 'With simple keys, collection cannot be used as a key value';
throw new Error(msg);
}