diff options
author | Minteck <contact@minteck.org> | 2022-06-04 08:51:19 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-06-04 08:51:19 +0200 |
commit | b22f6770c8bd084d66950655203c61dd701b3d90 (patch) | |
tree | 873d7fb19584ec2709b95cc1ca05a1fc7cfd0fc4 /node_modules/yaml/dist/compose | |
parent | 383285ecd5292bf9a825e05904955b937de84cc9 (diff) | |
download | equestriadb-b22f6770c8bd084d66950655203c61dd701b3d90.tar.gz equestriadb-b22f6770c8bd084d66950655203c61dd701b3d90.tar.bz2 equestriadb-b22f6770c8bd084d66950655203c61dd701b3d90.zip |
Remove node_modules
Diffstat (limited to 'node_modules/yaml/dist/compose')
32 files changed, 0 insertions, 1739 deletions
diff --git a/node_modules/yaml/dist/compose/compose-collection.d.ts b/node_modules/yaml/dist/compose/compose-collection.d.ts deleted file mode 100644 index 7ba83ac..0000000 --- a/node_modules/yaml/dist/compose/compose-collection.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { 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; diff --git a/node_modules/yaml/dist/compose/compose-collection.js b/node_modules/yaml/dist/compose/compose-collection.js deleted file mode 100644 index 52ad885..0000000 --- a/node_modules/yaml/dist/compose/compose-collection.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; - -var Node = require('../nodes/Node.js'); -var Scalar = require('../nodes/Scalar.js'); -var resolveBlockMap = require('./resolve-block-map.js'); -var resolveBlockSeq = require('./resolve-block-seq.js'); -var resolveFlowCollection = require('./resolve-flow-collection.js'); - -function composeCollection(CN, ctx, token, tagToken, onError) { - let coll; - switch (token.type) { - case 'block-map': { - coll = resolveBlockMap.resolveBlockMap(CN, ctx, token, onError); - break; - } - case 'block-seq': { - coll = resolveBlockSeq.resolveBlockSeq(CN, ctx, token, onError); - break; - } - case 'flow-collection': { - coll = resolveFlowCollection.resolveFlowCollection(CN, ctx, token, onError); - break; - } - } - if (!tagToken) - return coll; - const tagName = ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg)); - if (!tagName) - return coll; - // Cast needed due to: https://github.com/Microsoft/TypeScript/issues/3841 - const Coll = coll.constructor; - if (tagName === '!' || tagName === Coll.tagName) { - coll.tag = Coll.tagName; - return coll; - } - const expType = Node.isMap(coll) ? 'map' : 'seq'; - let tag = ctx.schema.tags.find(t => t.collection === expType && t.tag === tagName); - if (!tag) { - const kt = ctx.schema.knownTags[tagName]; - if (kt && kt.collection === expType) { - ctx.schema.tags.push(Object.assign({}, kt, { default: false })); - tag = kt; - } - else { - onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, true); - coll.tag = tagName; - return coll; - } - } - const res = tag.resolve(coll, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg), ctx.options); - const node = Node.isNode(res) - ? res - : new Scalar.Scalar(res); - node.range = coll.range; - node.tag = tagName; - if (tag === null || tag === void 0 ? void 0 : tag.format) - node.format = tag.format; - return node; -} - -exports.composeCollection = composeCollection; diff --git a/node_modules/yaml/dist/compose/compose-doc.d.ts b/node_modules/yaml/dist/compose/compose-doc.d.ts deleted file mode 100644 index 2068f87..0000000 --- a/node_modules/yaml/dist/compose/compose-doc.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { Directives } from '../doc/directives.js'; -import { Document } from '../doc/Document.js'; -import type { DocumentOptions, ParseOptions, SchemaOptions } from '../options.js'; -import type * as CST from '../parse/cst.js'; -import type { ComposeErrorHandler } from './composer.js'; -export declare function composeDoc(options: ParseOptions & DocumentOptions & SchemaOptions, directives: Directives, { offset, start, value, end }: CST.Document, onError: ComposeErrorHandler): Document.Parsed<import("../index.js").ParsedNode>; diff --git a/node_modules/yaml/dist/compose/compose-doc.js b/node_modules/yaml/dist/compose/compose-doc.js deleted file mode 100644 index bb6453a..0000000 --- a/node_modules/yaml/dist/compose/compose-doc.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -var Document = require('../doc/Document.js'); -var composeNode = require('./compose-node.js'); -var resolveEnd = require('./resolve-end.js'); -var resolveProps = require('./resolve-props.js'); - -function composeDoc(options, directives, { offset, start, value, end }, onError) { - const opts = Object.assign({ directives }, options); - const doc = new Document.Document(undefined, opts); - const ctx = { - atRoot: true, - directives: doc.directives, - options: doc.options, - schema: doc.schema - }; - const props = resolveProps.resolveProps(start, { - indicator: 'doc-start', - next: value !== null && value !== void 0 ? value : end === null || end === void 0 ? void 0 : end[0], - offset, - onError, - startOnNewline: true - }); - if (props.found) { - doc.directives.docStart = true; - if (value && - (value.type === 'block-map' || value.type === 'block-seq') && - !props.hasNewline) - onError(props.end, 'MISSING_CHAR', 'Block collection cannot start on same line with directives-end marker'); - } - doc.contents = value - ? composeNode.composeNode(ctx, value, props, onError) - : composeNode.composeEmptyNode(ctx, props.end, start, null, props, onError); - const contentEnd = doc.contents.range[2]; - const re = resolveEnd.resolveEnd(end, contentEnd, false, onError); - if (re.comment) - doc.comment = re.comment; - doc.range = [offset, contentEnd, re.offset]; - return doc; -} - -exports.composeDoc = composeDoc; diff --git a/node_modules/yaml/dist/compose/compose-node.d.ts b/node_modules/yaml/dist/compose/compose-node.d.ts deleted file mode 100644 index a2f7810..0000000 --- a/node_modules/yaml/dist/compose/compose-node.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { Directives } from '../doc/directives.js'; -import type { ParsedNode } from '../nodes/Node.js'; -import type { ParseOptions } from '../options.js'; -import type { SourceToken, Token } from '../parse/cst.js'; -import type { Schema } from '../schema/Schema.js'; -import type { ComposeErrorHandler } from './composer.js'; -export interface ComposeContext { - atRoot: boolean; - directives: Directives; - options: Readonly<Required<Omit<ParseOptions, 'lineCounter'>>>; - schema: Readonly<Schema>; -} -interface Props { - spaceBefore: boolean; - comment: string; - anchor: SourceToken | null; - tag: SourceToken | null; -} -declare const CN: { - composeNode: typeof composeNode; - composeEmptyNode: typeof composeEmptyNode; -}; -export declare type ComposeNode = typeof CN; -export declare function composeNode(ctx: ComposeContext, token: Token, props: Props, onError: ComposeErrorHandler): ParsedNode; -export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag }: Props, onError: ComposeErrorHandler): import("../index.js").Scalar.Parsed; -export {}; diff --git a/node_modules/yaml/dist/compose/compose-node.js b/node_modules/yaml/dist/compose/compose-node.js deleted file mode 100644 index df193ca..0000000 --- a/node_modules/yaml/dist/compose/compose-node.js +++ /dev/null @@ -1,93 +0,0 @@ -'use strict'; - -var Alias = require('../nodes/Alias.js'); -var composeCollection = require('./compose-collection.js'); -var composeScalar = require('./compose-scalar.js'); -var resolveEnd = require('./resolve-end.js'); -var utilEmptyScalarPosition = require('./util-empty-scalar-position.js'); - -const CN = { composeNode, composeEmptyNode }; -function composeNode(ctx, token, props, onError) { - const { spaceBefore, comment, anchor, tag } = props; - let node; - let isSrcToken = true; - switch (token.type) { - case 'alias': - node = composeAlias(ctx, token, onError); - if (anchor || tag) - onError(token, 'ALIAS_PROPS', 'An alias node must not specify any properties'); - break; - case 'scalar': - case 'single-quoted-scalar': - case 'double-quoted-scalar': - case 'block-scalar': - node = composeScalar.composeScalar(ctx, token, tag, onError); - if (anchor) - node.anchor = anchor.source.substring(1); - break; - case 'block-map': - case 'block-seq': - case 'flow-collection': - node = composeCollection.composeCollection(CN, ctx, token, tag, onError); - if (anchor) - node.anchor = anchor.source.substring(1); - break; - default: { - const message = token.type === 'error' - ? token.message - : `Unsupported token (type: ${token.type})`; - onError(token, 'UNEXPECTED_TOKEN', message); - node = composeEmptyNode(ctx, token.offset, undefined, null, props, onError); - isSrcToken = false; - } - } - if (anchor && node.anchor === '') - onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string'); - if (spaceBefore) - node.spaceBefore = true; - if (comment) { - if (token.type === 'scalar' && token.source === '') - node.comment = comment; - else - node.commentBefore = comment; - } - // @ts-expect-error Type checking misses meaning of isSrcToken - if (ctx.options.keepSourceTokens && isSrcToken) - node.srcToken = token; - return node; -} -function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) { - const token = { - type: 'scalar', - offset: utilEmptyScalarPosition.emptyScalarPosition(offset, before, pos), - indent: -1, - source: '' - }; - const node = composeScalar.composeScalar(ctx, token, tag, onError); - if (anchor) { - node.anchor = anchor.source.substring(1); - if (node.anchor === '') - onError(anchor, 'BAD_ALIAS', 'Anchor cannot be an empty string'); - } - if (spaceBefore) - node.spaceBefore = true; - if (comment) - node.comment = comment; - return node; -} -function composeAlias({ options }, { offset, source, end }, onError) { - const alias = new Alias.Alias(source.substring(1)); - if (alias.source === '') - onError(offset, 'BAD_ALIAS', 'Alias cannot be an empty string'); - if (alias.source.endsWith(':')) - onError(offset + source.length - 1, 'BAD_ALIAS', 'Alias ending in : is ambiguous', true); - const valueEnd = offset + source.length; - const re = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError); - alias.range = [offset, valueEnd, re.offset]; - if (re.comment) - alias.comment = re.comment; - return alias; -} - -exports.composeEmptyNode = composeEmptyNode; -exports.composeNode = composeNode; diff --git a/node_modules/yaml/dist/compose/compose-scalar.d.ts b/node_modules/yaml/dist/compose/compose-scalar.d.ts deleted file mode 100644 index d5d0f79..0000000 --- a/node_modules/yaml/dist/compose/compose-scalar.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Scalar } from '../nodes/Scalar.js'; -import type { BlockScalar, FlowScalar, SourceToken } from '../parse/cst.js'; -import type { ComposeContext } from './compose-node.js'; -import type { ComposeErrorHandler } from './composer.js'; -export declare function composeScalar(ctx: ComposeContext, token: FlowScalar | BlockScalar, tagToken: SourceToken | null, onError: ComposeErrorHandler): Scalar.Parsed; diff --git a/node_modules/yaml/dist/compose/compose-scalar.js b/node_modules/yaml/dist/compose/compose-scalar.js deleted file mode 100644 index ad2963c..0000000 --- a/node_modules/yaml/dist/compose/compose-scalar.js +++ /dev/null @@ -1,83 +0,0 @@ -'use strict'; - -var Node = require('../nodes/Node.js'); -var Scalar = require('../nodes/Scalar.js'); -var resolveBlockScalar = require('./resolve-block-scalar.js'); -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) - : resolveFlowScalar.resolveFlowScalar(token, ctx.options.strict, onError); - const tagName = tagToken - ? ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg)) - : null; - const tag = tagToken && tagName - ? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError) - : token.type === 'scalar' - ? findScalarTagByTest(ctx, value, token, onError) - : ctx.schema[Node.SCALAR]; - let scalar; - try { - const res = tag.resolve(value, msg => onError(tagToken !== null && tagToken !== void 0 ? tagToken : token, 'TAG_RESOLVE_FAILED', msg), ctx.options); - scalar = Node.isScalar(res) ? res : new Scalar.Scalar(res); - } - catch (error) { - const msg = error instanceof Error ? error.message : String(error); - onError(tagToken !== null && tagToken !== void 0 ? tagToken : token, 'TAG_RESOLVE_FAILED', msg); - scalar = new Scalar.Scalar(value); - } - scalar.range = range; - scalar.source = value; - if (type) - scalar.type = type; - if (tagName) - scalar.tag = tagName; - if (tag.format) - scalar.format = tag.format; - if (comment) - scalar.comment = comment; - return scalar; -} -function findScalarTagByName(schema, value, tagName, tagToken, onError) { - var _a; - if (tagName === '!') - return schema[Node.SCALAR]; // non-specific tag - const matchWithTest = []; - for (const tag of schema.tags) { - if (!tag.collection && tag.tag === tagName) { - if (tag.default && tag.test) - matchWithTest.push(tag); - else - return tag; - } - } - for (const tag of matchWithTest) - if ((_a = tag.test) === null || _a === void 0 ? void 0 : _a.test(value)) - return tag; - const kt = schema.knownTags[tagName]; - if (kt && !kt.collection) { - // Ensure that the known tag is available for stringifying, - // but does not get used by default. - schema.tags.push(Object.assign({}, kt, { default: false, test: undefined })); - return kt; - } - onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str'); - return schema[Node.SCALAR]; -} -function findScalarTagByTest({ directives, schema }, value, token, onError) { - var _a; - const tag = schema.tags.find(tag => { var _a; return tag.default && ((_a = tag.test) === null || _a === void 0 ? void 0 : _a.test(value)); }) || schema[Node.SCALAR]; - if (schema.compat) { - const compat = (_a = schema.compat.find(tag => { var _a; return tag.default && ((_a = tag.test) === null || _a === void 0 ? void 0 : _a.test(value)); })) !== null && _a !== void 0 ? _a : schema[Node.SCALAR]; - if (tag.tag !== compat.tag) { - const ts = directives.tagString(tag.tag); - const cs = directives.tagString(compat.tag); - const msg = `Value may be parsed as either ${ts} or ${cs}`; - onError(token, 'TAG_RESOLVE_FAILED', msg, true); - } - } - return tag; -} - -exports.composeScalar = composeScalar; diff --git a/node_modules/yaml/dist/compose/composer.d.ts b/node_modules/yaml/dist/compose/composer.d.ts deleted file mode 100644 index 9db2477..0000000 --- a/node_modules/yaml/dist/compose/composer.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { Directives } from '../doc/directives.js'; -import { Document } from '../doc/Document.js'; -import { ErrorCode, YAMLParseError, YAMLWarning } from '../errors.js'; -import { Range } from '../nodes/Node.js'; -import type { DocumentOptions, ParseOptions, SchemaOptions } from '../options.js'; -import type { Token } from '../parse/cst.js'; -declare type ErrorSource = number | [number, number] | Range | { - offset: number; - source?: string; -}; -export declare type ComposeErrorHandler = (source: ErrorSource, code: ErrorCode, message: string, warning?: boolean) => void; -/** - * Compose a stream of CST nodes into a stream of YAML Documents. - * - * ```ts - * import { Composer, Parser } from 'yaml' - * - * const src: string = ... - * const tokens = new Parser().parse(src) - * const docs = new Composer().compose(tokens) - * ``` - */ -export declare class Composer { - private directives; - private doc; - private options; - private atDirectives; - private prelude; - private errors; - private warnings; - constructor(options?: ParseOptions & DocumentOptions & SchemaOptions); - private onError; - private decorate; - /** - * Current stream status information. - * - * Mostly useful at the end of input for an empty stream. - */ - streamInfo(): { - comment: string; - directives: Directives; - errors: YAMLParseError[]; - warnings: YAMLWarning[]; - }; - /** - * Compose tokens into documents. - * - * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document. - * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly. - */ - compose(tokens: Iterable<Token>, forceDoc?: boolean, endOffset?: number): Generator<Document.Parsed<import("../nodes/Node.js").ParsedNode>, void, unknown>; - /** Advance the composer by one CST token. */ - next(token: Token): Generator<Document.Parsed<import("../nodes/Node.js").ParsedNode>, void, unknown>; - /** - * Call at end of input to yield any remaining document. - * - * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document. - * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly. - */ - end(forceDoc?: boolean, endOffset?: number): Generator<Document.Parsed<import("../nodes/Node.js").ParsedNode>, void, unknown>; -} -export {}; diff --git a/node_modules/yaml/dist/compose/composer.js b/node_modules/yaml/dist/compose/composer.js deleted file mode 100644 index 2477a49..0000000 --- a/node_modules/yaml/dist/compose/composer.js +++ /dev/null @@ -1,222 +0,0 @@ -'use strict'; - -var directives = require('../doc/directives.js'); -var Document = require('../doc/Document.js'); -var errors = require('../errors.js'); -var Node = require('../nodes/Node.js'); -var composeDoc = require('./compose-doc.js'); -var resolveEnd = require('./resolve-end.js'); - -function getErrorPos(src) { - if (typeof src === 'number') - return [src, src + 1]; - if (Array.isArray(src)) - return src.length === 2 ? src : [src[0], src[1]]; - const { offset, source } = src; - return [offset, offset + (typeof source === 'string' ? source.length : 1)]; -} -function parsePrelude(prelude) { - var _a; - let comment = ''; - let atComment = false; - let afterEmptyLine = false; - for (let i = 0; i < prelude.length; ++i) { - const source = prelude[i]; - switch (source[0]) { - case '#': - comment += - (comment === '' ? '' : afterEmptyLine ? '\n\n' : '\n') + - (source.substring(1) || ' '); - atComment = true; - afterEmptyLine = false; - break; - case '%': - if (((_a = prelude[i + 1]) === null || _a === void 0 ? void 0 : _a[0]) !== '#') - i += 1; - atComment = false; - break; - default: - // This may be wrong after doc-end, but in that case it doesn't matter - if (!atComment) - afterEmptyLine = true; - atComment = false; - } - } - return { comment, afterEmptyLine }; -} -/** - * Compose a stream of CST nodes into a stream of YAML Documents. - * - * ```ts - * import { Composer, Parser } from 'yaml' - * - * const src: string = ... - * const tokens = new Parser().parse(src) - * const docs = new Composer().compose(tokens) - * ``` - */ -class Composer { - constructor(options = {}) { - this.doc = null; - this.atDirectives = false; - this.prelude = []; - this.errors = []; - this.warnings = []; - this.onError = (source, code, message, warning) => { - const pos = getErrorPos(source); - if (warning) - this.warnings.push(new errors.YAMLWarning(pos, code, message)); - else - this.errors.push(new errors.YAMLParseError(pos, code, message)); - }; - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - this.directives = new directives.Directives({ version: options.version || '1.2' }); - this.options = options; - } - decorate(doc, afterDoc) { - const { comment, afterEmptyLine } = parsePrelude(this.prelude); - //console.log({ dc: doc.comment, prelude, comment }) - if (comment) { - const dc = doc.contents; - if (afterDoc) { - doc.comment = doc.comment ? `${doc.comment}\n${comment}` : comment; - } - else if (afterEmptyLine || doc.directives.docStart || !dc) { - doc.commentBefore = comment; - } - else if (Node.isCollection(dc) && !dc.flow && dc.items.length > 0) { - let it = dc.items[0]; - if (Node.isPair(it)) - it = it.key; - const cb = it.commentBefore; - it.commentBefore = cb ? `${comment}\n${cb}` : comment; - } - else { - const cb = dc.commentBefore; - dc.commentBefore = cb ? `${comment}\n${cb}` : comment; - } - } - if (afterDoc) { - Array.prototype.push.apply(doc.errors, this.errors); - Array.prototype.push.apply(doc.warnings, this.warnings); - } - else { - doc.errors = this.errors; - doc.warnings = this.warnings; - } - this.prelude = []; - this.errors = []; - this.warnings = []; - } - /** - * Current stream status information. - * - * Mostly useful at the end of input for an empty stream. - */ - streamInfo() { - return { - comment: parsePrelude(this.prelude).comment, - directives: this.directives, - errors: this.errors, - warnings: this.warnings - }; - } - /** - * Compose tokens into documents. - * - * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document. - * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly. - */ - *compose(tokens, forceDoc = false, endOffset = -1) { - for (const token of tokens) - yield* this.next(token); - yield* this.end(forceDoc, endOffset); - } - /** Advance the composer by one CST token. */ - *next(token) { - if (process.env.LOG_STREAM) - console.dir(token, { depth: null }); - switch (token.type) { - case 'directive': - this.directives.add(token.source, (offset, message, warning) => { - const pos = getErrorPos(token); - pos[0] += offset; - this.onError(pos, 'BAD_DIRECTIVE', message, warning); - }); - this.prelude.push(token.source); - this.atDirectives = true; - break; - case 'document': { - const doc = composeDoc.composeDoc(this.options, this.directives, token, this.onError); - if (this.atDirectives && !doc.directives.docStart) - this.onError(token, 'MISSING_CHAR', 'Missing directives-end/doc-start indicator line'); - this.decorate(doc, false); - if (this.doc) - yield this.doc; - this.doc = doc; - this.atDirectives = false; - break; - } - case 'byte-order-mark': - case 'space': - break; - case 'comment': - case 'newline': - this.prelude.push(token.source); - break; - case 'error': { - const msg = token.source - ? `${token.message}: ${JSON.stringify(token.source)}` - : token.message; - const error = new errors.YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg); - if (this.atDirectives || !this.doc) - this.errors.push(error); - else - this.doc.errors.push(error); - break; - } - case 'doc-end': { - if (!this.doc) { - const msg = 'Unexpected doc-end without preceding document'; - this.errors.push(new errors.YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg)); - break; - } - this.doc.directives.docEnd = true; - const end = resolveEnd.resolveEnd(token.end, token.offset + token.source.length, this.doc.options.strict, this.onError); - this.decorate(this.doc, true); - if (end.comment) { - const dc = this.doc.comment; - this.doc.comment = dc ? `${dc}\n${end.comment}` : end.comment; - } - this.doc.range[2] = end.offset; - break; - } - default: - this.errors.push(new errors.YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', `Unsupported token ${token.type}`)); - } - } - /** - * Call at end of input to yield any remaining document. - * - * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document. - * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly. - */ - *end(forceDoc = false, endOffset = -1) { - if (this.doc) { - this.decorate(this.doc, true); - yield this.doc; - this.doc = null; - } - else if (forceDoc) { - const opts = Object.assign({ directives: this.directives }, this.options); - const doc = new Document.Document(undefined, opts); - if (this.atDirectives) - this.onError(endOffset, 'MISSING_CHAR', 'Missing directives-end indicator line'); - doc.range = [0, endOffset, endOffset]; - this.decorate(doc, false); - yield doc; - } - } -} - -exports.Composer = Composer; diff --git a/node_modules/yaml/dist/compose/resolve-block-map.d.ts b/node_modules/yaml/dist/compose/resolve-block-map.d.ts deleted file mode 100644 index dbcd3fa..0000000 --- a/node_modules/yaml/dist/compose/resolve-block-map.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { ParsedNode } from '../nodes/Node.js'; -import { YAMLMap } from '../nodes/YAMLMap.js'; -import type { BlockMap } from '../parse/cst.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): YAMLMap.Parsed<ParsedNode, ParsedNode | null>; diff --git a/node_modules/yaml/dist/compose/resolve-block-map.js b/node_modules/yaml/dist/compose/resolve-block-map.js deleted file mode 100644 index 142848b..0000000 --- a/node_modules/yaml/dist/compose/resolve-block-map.js +++ /dev/null @@ -1,110 +0,0 @@ -'use strict'; - -var Pair = require('../nodes/Pair.js'); -var YAMLMap = require('../nodes/YAMLMap.js'); -var resolveProps = require('./resolve-props.js'); -var utilContainsNewline = require('./util-contains-newline.js'); -var utilFlowIndentCheck = require('./util-flow-indent-check.js'); -var utilMapIncludes = require('./util-map-includes.js'); - -const startColMsg = 'All mapping items must start at the same column'; -function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) { - var _a; - const map = new YAMLMap.YAMLMap(ctx.schema); - if (ctx.atRoot) - ctx.atRoot = false; - let offset = bm.offset; - for (const collItem of bm.items) { - const { start, key, sep, value } = collItem; - // key properties - const keyProps = resolveProps.resolveProps(start, { - indicator: 'explicit-key-ind', - next: key !== null && key !== void 0 ? key : sep === null || sep === void 0 ? void 0 : sep[0], - offset, - onError, - startOnNewline: true - }); - const implicitKey = !keyProps.found; - if (implicitKey) { - if (key) { - if (key.type === 'block-seq') - onError(offset, 'BLOCK_AS_IMPLICIT_KEY', 'A block sequence may not be used as an implicit map key'); - else if ('indent' in key && key.indent !== bm.indent) - onError(offset, 'BAD_INDENT', startColMsg); - } - if (!keyProps.anchor && !keyProps.tag && !sep) { - // TODO: assert being at last item? - if (keyProps.comment) { - if (map.comment) - map.comment += '\n' + keyProps.comment; - else - map.comment = keyProps.comment; - } - continue; - } - if (keyProps.hasNewlineAfterProp || utilContainsNewline.containsNewline(key)) { - onError(key !== null && key !== void 0 ? key : start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line'); - } - } - else if (((_a = keyProps.found) === null || _a === void 0 ? void 0 : _a.indent) !== bm.indent) { - onError(offset, 'BAD_INDENT', startColMsg); - } - // key value - const keyStart = keyProps.end; - const keyNode = key - ? composeNode(ctx, key, keyProps, onError) - : composeEmptyNode(ctx, keyStart, start, null, keyProps, onError); - if (ctx.schema.compat) - utilFlowIndentCheck.flowIndentCheck(bm.indent, key, onError); - if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode)) - onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique'); - // value properties - const valueProps = resolveProps.resolveProps(sep !== null && sep !== void 0 ? sep : [], { - indicator: 'map-value-ind', - next: value, - offset: keyNode.range[2], - onError, - startOnNewline: !key || key.type === 'block-scalar' - }); - offset = valueProps.end; - if (valueProps.found) { - if (implicitKey) { - if ((value === null || value === void 0 ? void 0 : value.type) === 'block-map' && !valueProps.hasNewline) - onError(offset, 'BLOCK_AS_IMPLICIT_KEY', 'Nested mappings are not allowed in compact mappings'); - if (ctx.options.strict && - keyProps.start < valueProps.found.offset - 1024) - onError(keyNode.range, 'KEY_OVER_1024_CHARS', 'The : indicator must be at most 1024 chars after the start of an implicit block mapping key'); - } - // value value - const valueNode = value - ? composeNode(ctx, value, valueProps, onError) - : composeEmptyNode(ctx, offset, sep, null, valueProps, onError); - if (ctx.schema.compat) - utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError); - offset = valueNode.range[2]; - const pair = new Pair.Pair(keyNode, valueNode); - if (ctx.options.keepSourceTokens) - pair.srcToken = collItem; - map.items.push(pair); - } - else { - // key with no value - if (implicitKey) - onError(keyNode.range, 'MISSING_CHAR', 'Implicit map keys need to be followed by map values'); - if (valueProps.comment) { - if (keyNode.comment) - keyNode.comment += '\n' + valueProps.comment; - else - keyNode.comment = valueProps.comment; - } - const pair = new Pair.Pair(keyNode); - if (ctx.options.keepSourceTokens) - pair.srcToken = collItem; - map.items.push(pair); - } - } - map.range = [bm.offset, offset, offset]; - return map; -} - -exports.resolveBlockMap = resolveBlockMap; diff --git a/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts b/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts deleted file mode 100644 index 4855b19..0000000 --- a/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Range } from '../nodes/Node.js'; -import { Scalar } from '../nodes/Scalar.js'; -import type { BlockScalar } from '../parse/cst.js'; -import type { ComposeErrorHandler } from './composer.js'; -export declare function resolveBlockScalar(scalar: BlockScalar, strict: boolean, onError: ComposeErrorHandler): { - value: string; - type: Scalar.BLOCK_FOLDED | Scalar.BLOCK_LITERAL | null; - comment: string; - range: Range; -}; diff --git a/node_modules/yaml/dist/compose/resolve-block-scalar.js b/node_modules/yaml/dist/compose/resolve-block-scalar.js deleted file mode 100644 index b5a350d..0000000 --- a/node_modules/yaml/dist/compose/resolve-block-scalar.js +++ /dev/null @@ -1,196 +0,0 @@ -'use strict'; - -var Scalar = require('../nodes/Scalar.js'); - -function resolveBlockScalar(scalar, strict, onError) { - const start = scalar.offset; - const header = parseBlockScalarHeader(scalar, 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; - const lines = scalar.source ? splitLines(scalar.source) : []; - // determine the end of content & start of chomping - let chompStart = lines.length; - for (let i = lines.length - 1; i >= 0; --i) { - const content = lines[i][1]; - if (content === '' || content === '\r') - chompStart = i; - else - break; - } - // shortcut for empty contents - if (chompStart === 0) { - const value = header.chomp === '+' && lines.length > 0 - ? '\n'.repeat(Math.max(1, lines.length - 1)) - : ''; - let end = start + header.length; - if (scalar.source) - end += scalar.source.length; - return { value, type, comment: header.comment, range: [start, end, end] }; - } - // find the indentation level to trim from start - let trimIndent = scalar.indent + header.indent; - let offset = scalar.offset + header.length; - let contentStart = 0; - for (let i = 0; i < chompStart; ++i) { - const [indent, content] = lines[i]; - if (content === '' || content === '\r') { - if (header.indent === 0 && indent.length > trimIndent) - trimIndent = indent.length; - } - else { - if (indent.length < trimIndent) { - const message = 'Block scalars with more-indented leading empty lines must use an explicit indentation indicator'; - onError(offset + indent.length, 'MISSING_CHAR', message); - } - if (header.indent === 0) - trimIndent = indent.length; - contentStart = i; - break; - } - offset += indent.length + content.length + 1; - } - // include trailing more-indented empty lines in content - for (let i = lines.length - 1; i >= chompStart; --i) { - if (lines[i][0].length > trimIndent) - chompStart = i + 1; - } - let value = ''; - let sep = ''; - let prevMoreIndented = false; - // leading whitespace is kept intact - for (let i = 0; i < contentStart; ++i) - value += lines[i][0].slice(trimIndent) + '\n'; - for (let i = contentStart; i < chompStart; ++i) { - let [indent, content] = lines[i]; - offset += indent.length + content.length + 1; - const crlf = content[content.length - 1] === '\r'; - if (crlf) - content = content.slice(0, -1); - /* istanbul ignore if already caught in lexer */ - if (content && indent.length < trimIndent) { - const src = header.indent - ? 'explicit indentation indicator' - : 'first line'; - const message = `Block scalar lines must not be less indented than their ${src}`; - onError(offset - content.length - (crlf ? 2 : 1), 'BAD_INDENT', message); - indent = ''; - } - if (type === Scalar.Scalar.BLOCK_LITERAL) { - value += sep + indent.slice(trimIndent) + content; - sep = '\n'; - } - else if (indent.length > trimIndent || content[0] === '\t') { - // more-indented content within a folded block - if (sep === ' ') - sep = '\n'; - else if (!prevMoreIndented && sep === '\n') - sep = '\n\n'; - value += sep + indent.slice(trimIndent) + content; - sep = '\n'; - prevMoreIndented = true; - } - else if (content === '') { - // empty line - if (sep === '\n') - value += '\n'; - else - sep = '\n'; - } - else { - value += sep + content; - sep = ' '; - prevMoreIndented = false; - } - } - switch (header.chomp) { - case '-': - break; - case '+': - for (let i = chompStart; i < lines.length; ++i) - value += '\n' + lines[i][0].slice(trimIndent); - if (value[value.length - 1] !== '\n') - value += '\n'; - break; - default: - value += '\n'; - } - const end = start + header.length + scalar.source.length; - return { value, type, comment: header.comment, range: [start, end, end] }; -} -function parseBlockScalarHeader({ offset, props }, strict, onError) { - /* istanbul ignore if should not happen */ - if (props[0].type !== 'block-scalar-header') { - onError(props[0], 'IMPOSSIBLE', 'Block scalar header not found'); - return null; - } - const { source } = props[0]; - const mode = source[0]; - let indent = 0; - let chomp = ''; - let error = -1; - for (let i = 1; i < source.length; ++i) { - const ch = source[i]; - if (!chomp && (ch === '-' || ch === '+')) - chomp = ch; - else { - const n = Number(ch); - if (!indent && n) - indent = n; - else if (error === -1) - error = offset + i; - } - } - if (error !== -1) - onError(error, 'UNEXPECTED_TOKEN', `Block scalar header includes extra characters: ${source}`); - let hasSpace = false; - let comment = ''; - let length = source.length; - for (let i = 1; i < props.length; ++i) { - const token = props[i]; - switch (token.type) { - case 'space': - hasSpace = true; - // fallthrough - case 'newline': - length += token.source.length; - break; - case 'comment': - if (strict && !hasSpace) { - const message = 'Comments must be separated from other tokens by white space characters'; - onError(token, 'MISSING_CHAR', message); - } - length += token.source.length; - comment = token.source.substring(1); - break; - case 'error': - onError(token, 'UNEXPECTED_TOKEN', token.message); - length += token.source.length; - break; - /* istanbul ignore next should not happen */ - default: { - const message = `Unexpected token in block scalar header: ${token.type}`; - onError(token, 'UNEXPECTED_TOKEN', message); - const ts = token.source; - if (ts && typeof ts === 'string') - length += ts.length; - } - } - } - return { mode, indent, chomp, comment, length }; -} -/** @returns Array of lines split up as `[indent, content]` */ -function splitLines(source) { - const split = source.split(/\n( *)/); - const first = split[0]; - const m = first.match(/^( *)/); - const line0 = (m === null || m === void 0 ? void 0 : m[1]) - ? [m[1], first.slice(m[1].length)] - : ['', first]; - const lines = [line0]; - for (let i = 1; i < split.length; i += 2) - lines.push([split[i], split[i + 1]]); - return lines; -} - -exports.resolveBlockScalar = resolveBlockScalar; diff --git a/node_modules/yaml/dist/compose/resolve-block-seq.d.ts b/node_modules/yaml/dist/compose/resolve-block-seq.d.ts deleted file mode 100644 index 25ed558..0000000 --- a/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { YAMLSeq } from '../nodes/YAMLSeq.js'; -import type { BlockSequence } from '../parse/cst.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): YAMLSeq.Parsed<import("../index.js").ParsedNode>; diff --git a/node_modules/yaml/dist/compose/resolve-block-seq.js b/node_modules/yaml/dist/compose/resolve-block-seq.js deleted file mode 100644 index 1e7e86a..0000000 --- a/node_modules/yaml/dist/compose/resolve-block-seq.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -var YAMLSeq = require('../nodes/YAMLSeq.js'); -var resolveProps = require('./resolve-props.js'); -var utilFlowIndentCheck = require('./util-flow-indent-check.js'); - -function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) { - const seq = new YAMLSeq.YAMLSeq(ctx.schema); - if (ctx.atRoot) - ctx.atRoot = false; - let offset = bs.offset; - for (const { start, value } of bs.items) { - const props = resolveProps.resolveProps(start, { - indicator: 'seq-item-ind', - next: value, - offset, - onError, - startOnNewline: true - }); - offset = props.end; - if (!props.found) { - if (props.anchor || props.tag || value) { - if (value && value.type === 'block-seq') - onError(offset, 'BAD_INDENT', 'All sequence items must start at the same column'); - else - onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator'); - } - else { - // TODO: assert being at last item? - if (props.comment) - seq.comment = props.comment; - continue; - } - } - const node = value - ? composeNode(ctx, value, props, onError) - : composeEmptyNode(ctx, offset, start, null, props, onError); - if (ctx.schema.compat) - utilFlowIndentCheck.flowIndentCheck(bs.indent, value, onError); - offset = node.range[2]; - seq.items.push(node); - } - seq.range = [bs.offset, offset, offset]; - return seq; -} - -exports.resolveBlockSeq = resolveBlockSeq; diff --git a/node_modules/yaml/dist/compose/resolve-end.d.ts b/node_modules/yaml/dist/compose/resolve-end.d.ts deleted file mode 100644 index bb2d0b8..0000000 --- a/node_modules/yaml/dist/compose/resolve-end.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { SourceToken } from '../parse/cst.js'; -import type { ComposeErrorHandler } from './composer.js'; -export declare function resolveEnd(end: SourceToken[] | undefined, offset: number, reqSpace: boolean, onError: ComposeErrorHandler): { - comment: string; - offset: number; -}; diff --git a/node_modules/yaml/dist/compose/resolve-end.js b/node_modules/yaml/dist/compose/resolve-end.js deleted file mode 100644 index 3a58347..0000000 --- a/node_modules/yaml/dist/compose/resolve-end.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -function resolveEnd(end, offset, reqSpace, onError) { - let comment = ''; - if (end) { - let hasSpace = false; - let sep = ''; - for (const token of end) { - const { source, type } = token; - switch (type) { - case 'space': - hasSpace = true; - break; - case 'comment': { - if (reqSpace && !hasSpace) - onError(token, 'MISSING_CHAR', 'Comments must be separated from other tokens by white space characters'); - const cb = source.substring(1) || ' '; - if (!comment) - comment = cb; - else - comment += sep + cb; - sep = ''; - break; - } - case 'newline': - if (comment) - sep += source; - hasSpace = true; - break; - default: - onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${type} at node end`); - } - offset += source.length; - } - } - return { comment, offset }; -} - -exports.resolveEnd = resolveEnd; diff --git a/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts b/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts deleted file mode 100644 index 06d32f5..0000000 --- a/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { YAMLMap } from '../nodes/YAMLMap.js'; -import { YAMLSeq } from '../nodes/YAMLSeq.js'; -import type { FlowCollection } from '../parse/cst.js'; -import type { ComposeContext, ComposeNode } from './compose-node.js'; -import type { ComposeErrorHandler } from './composer.js'; -export declare function resolveFlowCollection({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, fc: FlowCollection, onError: ComposeErrorHandler): YAMLMap.Parsed<import("../nodes/Node.js").ParsedNode, import("../nodes/Node.js").ParsedNode | null> | YAMLSeq.Parsed<import("../nodes/Node.js").ParsedNode>; diff --git a/node_modules/yaml/dist/compose/resolve-flow-collection.js b/node_modules/yaml/dist/compose/resolve-flow-collection.js deleted file mode 100644 index cf848d9..0000000 --- a/node_modules/yaml/dist/compose/resolve-flow-collection.js +++ /dev/null @@ -1,203 +0,0 @@ -'use strict'; - -var Node = require('../nodes/Node.js'); -var Pair = require('../nodes/Pair.js'); -var YAMLMap = require('../nodes/YAMLMap.js'); -var YAMLSeq = require('../nodes/YAMLSeq.js'); -var resolveEnd = require('./resolve-end.js'); -var resolveProps = require('./resolve-props.js'); -var utilContainsNewline = require('./util-contains-newline.js'); -var utilMapIncludes = require('./util-map-includes.js'); - -const blockMsg = 'Block collections are not allowed within flow collections'; -const isBlock = (token) => token && (token.type === 'block-map' || token.type === 'block-seq'); -function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError) { - var _a; - const isMap = fc.start.source === '{'; - const fcName = isMap ? 'flow map' : 'flow sequence'; - const coll = isMap - ? new YAMLMap.YAMLMap(ctx.schema) - : new YAMLSeq.YAMLSeq(ctx.schema); - coll.flow = true; - const atRoot = ctx.atRoot; - if (atRoot) - ctx.atRoot = false; - let offset = fc.offset + fc.start.source.length; - for (let i = 0; i < fc.items.length; ++i) { - const collItem = fc.items[i]; - const { start, key, sep, value } = collItem; - const props = resolveProps.resolveProps(start, { - flow: fcName, - indicator: 'explicit-key-ind', - next: key !== null && key !== void 0 ? key : sep === null || sep === void 0 ? void 0 : sep[0], - offset, - onError, - startOnNewline: false - }); - if (!props.found) { - if (!props.anchor && !props.tag && !sep && !value) { - if (i === 0 && props.comma) - onError(props.comma, 'UNEXPECTED_TOKEN', `Unexpected , in ${fcName}`); - else if (i < fc.items.length - 1) - onError(props.start, 'UNEXPECTED_TOKEN', `Unexpected empty item in ${fcName}`); - if (props.comment) { - if (coll.comment) - coll.comment += '\n' + props.comment; - else - coll.comment = props.comment; - } - offset = props.end; - continue; - } - if (!isMap && ctx.options.strict && utilContainsNewline.containsNewline(key)) - onError(key, // checked by containsNewline() - 'MULTILINE_IMPLICIT_KEY', 'Implicit keys of flow sequence pairs need to be on a single line'); - } - if (i === 0) { - if (props.comma) - onError(props.comma, 'UNEXPECTED_TOKEN', `Unexpected , in ${fcName}`); - } - else { - if (!props.comma) - onError(props.start, 'MISSING_CHAR', `Missing , between ${fcName} items`); - if (props.comment) { - let prevItemComment = ''; - loop: for (const st of start) { - switch (st.type) { - case 'comma': - case 'space': - break; - case 'comment': - prevItemComment = st.source.substring(1); - break loop; - default: - break loop; - } - } - if (prevItemComment) { - let prev = coll.items[coll.items.length - 1]; - if (Node.isPair(prev)) - prev = (_a = prev.value) !== null && _a !== void 0 ? _a : prev.key; - if (prev.comment) - prev.comment += '\n' + prevItemComment; - else - prev.comment = prevItemComment; - props.comment = props.comment.substring(prevItemComment.length + 1); - } - } - } - if (!isMap && !sep && !props.found) { - // item is a value in a seq - // → key & sep are empty, start does not include ? or : - const valueNode = value - ? composeNode(ctx, value, props, onError) - : composeEmptyNode(ctx, props.end, sep, null, props, onError); - coll.items.push(valueNode); - offset = valueNode.range[2]; - if (isBlock(value)) - onError(valueNode.range, 'BLOCK_IN_FLOW', blockMsg); - } - else { - // item is a key+value pair - // key value - const keyStart = props.end; - const keyNode = key - ? composeNode(ctx, key, props, onError) - : composeEmptyNode(ctx, keyStart, start, null, props, onError); - if (isBlock(key)) - onError(keyNode.range, 'BLOCK_IN_FLOW', blockMsg); - // value properties - const valueProps = resolveProps.resolveProps(sep !== null && sep !== void 0 ? sep : [], { - flow: fcName, - indicator: 'map-value-ind', - next: value, - offset: keyNode.range[2], - onError, - startOnNewline: false - }); - if (valueProps.found) { - if (!isMap && !props.found && ctx.options.strict) { - if (sep) - for (const st of sep) { - if (st === valueProps.found) - break; - if (st.type === 'newline') { - onError(st, 'MULTILINE_IMPLICIT_KEY', 'Implicit keys of flow sequence pairs need to be on a single line'); - break; - } - } - if (props.start < valueProps.found.offset - 1024) - onError(valueProps.found, 'KEY_OVER_1024_CHARS', 'The : indicator must be at most 1024 chars after the start of an implicit flow sequence key'); - } - } - else if (value) { - if ('source' in value && value.source && value.source[0] === ':') - onError(value, 'MISSING_CHAR', `Missing space after : in ${fcName}`); - else - onError(valueProps.start, 'MISSING_CHAR', `Missing , or : between ${fcName} items`); - } - // value value - const valueNode = value - ? composeNode(ctx, value, valueProps, onError) - : valueProps.found - ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError) - : null; - if (valueNode) { - if (isBlock(value)) - onError(valueNode.range, 'BLOCK_IN_FLOW', blockMsg); - } - else if (valueProps.comment) { - if (keyNode.comment) - keyNode.comment += '\n' + valueProps.comment; - else - keyNode.comment = valueProps.comment; - } - const pair = new Pair.Pair(keyNode, valueNode); - if (ctx.options.keepSourceTokens) - pair.srcToken = collItem; - if (isMap) { - const map = coll; - if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode)) - onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique'); - map.items.push(pair); - } - else { - const map = new YAMLMap.YAMLMap(ctx.schema); - map.flow = true; - map.items.push(pair); - coll.items.push(map); - } - offset = valueNode ? valueNode.range[2] : valueProps.end; - } - } - const expectedEnd = isMap ? '}' : ']'; - const [ce, ...ee] = fc.end; - let cePos = offset; - if (ce && ce.source === expectedEnd) - cePos = ce.offset + ce.source.length; - else { - const name = fcName[0].toUpperCase() + fcName.substring(1); - const msg = atRoot - ? `${name} must end with a ${expectedEnd}` - : `${name} in block collection must be sufficiently indented and end with a ${expectedEnd}`; - onError(offset, atRoot ? 'MISSING_CHAR' : 'BAD_INDENT', msg); - if (ce && ce.source.length !== 1) - ee.unshift(ce); - } - if (ee.length > 0) { - const end = resolveEnd.resolveEnd(ee, cePos, ctx.options.strict, onError); - if (end.comment) { - if (coll.comment) - coll.comment += '\n' + end.comment; - else - coll.comment = end.comment; - } - coll.range = [fc.offset, cePos, end.offset]; - } - else { - coll.range = [fc.offset, cePos, cePos]; - } - return coll; -} - -exports.resolveFlowCollection = resolveFlowCollection; diff --git a/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts b/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts deleted file mode 100644 index 0c9204d..0000000 --- a/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Range } from '../nodes/Node.js'; -import { Scalar } from '../nodes/Scalar.js'; -import type { FlowScalar } from '../parse/cst.js'; -import type { ComposeErrorHandler } from './composer.js'; -export declare function resolveFlowScalar(scalar: FlowScalar, strict: boolean, onError: ComposeErrorHandler): { - value: string; - type: Scalar.PLAIN | Scalar.QUOTE_DOUBLE | Scalar.QUOTE_SINGLE | null; - comment: string; - range: Range; -}; diff --git a/node_modules/yaml/dist/compose/resolve-flow-scalar.js b/node_modules/yaml/dist/compose/resolve-flow-scalar.js deleted file mode 100644 index f7bf4e5..0000000 --- a/node_modules/yaml/dist/compose/resolve-flow-scalar.js +++ /dev/null @@ -1,226 +0,0 @@ -'use strict'; - -var Scalar = require('../nodes/Scalar.js'); -var resolveEnd = require('./resolve-end.js'); - -function resolveFlowScalar(scalar, strict, onError) { - const { offset, type, source, end } = scalar; - let _type; - let value; - const _onError = (rel, code, msg) => onError(offset + rel, code, msg); - switch (type) { - case 'scalar': - _type = Scalar.Scalar.PLAIN; - value = plainValue(source, _onError); - break; - case 'single-quoted-scalar': - _type = Scalar.Scalar.QUOTE_SINGLE; - value = singleQuotedValue(source, _onError); - break; - case 'double-quoted-scalar': - _type = Scalar.Scalar.QUOTE_DOUBLE; - value = doubleQuotedValue(source, _onError); - break; - /* istanbul ignore next should not happen */ - default: - onError(scalar, 'UNEXPECTED_TOKEN', `Expected a flow scalar value, but found: ${type}`); - return { - value: '', - type: null, - comment: '', - range: [offset, offset + source.length, offset + source.length] - }; - } - const valueEnd = offset + source.length; - const re = resolveEnd.resolveEnd(end, valueEnd, strict, onError); - return { - value, - type: _type, - comment: re.comment, - range: [offset, valueEnd, re.offset] - }; -} -function plainValue(source, onError) { - let badChar = ''; - switch (source[0]) { - /* istanbul ignore next should not happen */ - case '\t': - badChar = 'a tab character'; - break; - case ',': - badChar = 'flow indicator character ,'; - break; - case '%': - badChar = 'directive indicator character %'; - break; - case '|': - case '>': { - badChar = `block scalar indicator ${source[0]}`; - break; - } - case '@': - case '`': { - badChar = `reserved character ${source[0]}`; - break; - } - } - if (badChar) - onError(0, 'BAD_SCALAR_START', `Plain value cannot start with ${badChar}`); - return foldLines(source); -} -function singleQuotedValue(source, onError) { - if (source[source.length - 1] !== "'" || source.length === 1) - onError(source.length, 'MISSING_CHAR', "Missing closing 'quote"); - return foldLines(source.slice(1, -1)).replace(/''/g, "'"); -} -function foldLines(source) { - var _a; - /** - * The negative lookbehind here and in the `re` RegExp is to - * prevent causing a polynomial search time in certain cases. - * - * The try-catch is for Safari, which doesn't support this yet: - * https://caniuse.com/js-regexp-lookbehind - */ - let first, line; - try { - first = new RegExp('(.*?)(?<![ \t])[ \t]*\r?\n', 'sy'); - line = new RegExp('[ \t]*(.*?)(?:(?<![ \t])[ \t]*)?\r?\n', 'sy'); - } - catch (_) { - first = /(.*?)[ \t]*\r?\n/sy; - line = /[ \t]*(.*?)[ \t]*\r?\n/sy; - } - let match = first.exec(source); - if (!match) - return source; - let res = match[1]; - let sep = ' '; - let pos = first.lastIndex; - line.lastIndex = pos; - while ((match = line.exec(source))) { - if (match[1] === '') { - if (sep === '\n') - res += sep; - else - sep = '\n'; - } - else { - res += sep + match[1]; - sep = ' '; - } - pos = line.lastIndex; - } - const last = /[ \t]*(.*)/sy; - last.lastIndex = pos; - match = last.exec(source); - return res + sep + ((_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : ''); -} -function doubleQuotedValue(source, onError) { - let res = ''; - for (let i = 1; i < source.length - 1; ++i) { - const ch = source[i]; - if (ch === '\r' && source[i + 1] === '\n') - continue; - if (ch === '\n') { - const { fold, offset } = foldNewline(source, i); - res += fold; - i = offset; - } - else if (ch === '\\') { - let next = source[++i]; - const cc = escapeCodes[next]; - if (cc) - res += cc; - else if (next === '\n') { - // skip escaped newlines, but still trim the following line - next = source[i + 1]; - while (next === ' ' || next === '\t') - next = source[++i + 1]; - } - else if (next === '\r' && source[i + 1] === '\n') { - // skip escaped CRLF newlines, but still trim the following line - next = source[++i + 1]; - while (next === ' ' || next === '\t') - next = source[++i + 1]; - } - else if (next === 'x' || next === 'u' || next === 'U') { - const length = { x: 2, u: 4, U: 8 }[next]; - res += parseCharCode(source, i + 1, length, onError); - i += length; - } - else { - const raw = source.substr(i - 1, 2); - onError(i - 1, 'BAD_DQ_ESCAPE', `Invalid escape sequence ${raw}`); - res += raw; - } - } - else if (ch === ' ' || ch === '\t') { - // trim trailing whitespace - const wsStart = i; - let next = source[i + 1]; - while (next === ' ' || next === '\t') - next = source[++i + 1]; - if (next !== '\n' && !(next === '\r' && source[i + 2] === '\n')) - res += i > wsStart ? source.slice(wsStart, i + 1) : ch; - } - else { - res += ch; - } - } - if (source[source.length - 1] !== '"' || source.length === 1) - onError(source.length, 'MISSING_CHAR', 'Missing closing "quote'); - return res; -} -/** - * Fold a single newline into a space, multiple newlines to N - 1 newlines. - * Presumes `source[offset] === '\n'` - */ -function foldNewline(source, offset) { - let fold = ''; - let ch = source[offset + 1]; - while (ch === ' ' || ch === '\t' || ch === '\n' || ch === '\r') { - if (ch === '\r' && source[offset + 2] !== '\n') - break; - if (ch === '\n') - fold += '\n'; - offset += 1; - ch = source[offset + 1]; - } - if (!fold) - fold = ' '; - return { fold, offset }; -} -const escapeCodes = { - '0': '\0', - a: '\x07', - b: '\b', - e: '\x1b', - f: '\f', - n: '\n', - r: '\r', - t: '\t', - v: '\v', - N: '\u0085', - _: '\u00a0', - L: '\u2028', - P: '\u2029', - ' ': ' ', - '"': '"', - '/': '/', - '\\': '\\', - '\t': '\t' -}; -function parseCharCode(source, offset, length, onError) { - const cc = source.substr(offset, length); - const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc); - const code = ok ? parseInt(cc, 16) : NaN; - if (isNaN(code)) { - const raw = source.substr(offset - 2, length + 2); - onError(offset - 2, 'BAD_DQ_ESCAPE', `Invalid escape sequence ${raw}`); - return raw; - } - return String.fromCodePoint(code); -} - -exports.resolveFlowScalar = resolveFlowScalar; diff --git a/node_modules/yaml/dist/compose/resolve-props.d.ts b/node_modules/yaml/dist/compose/resolve-props.d.ts deleted file mode 100644 index fba44cf..0000000 --- a/node_modules/yaml/dist/compose/resolve-props.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { SourceToken, Token } from '../parse/cst.js'; -import type { ComposeErrorHandler } from './composer.js'; -export interface ResolvePropsArg { - flow?: 'flow map' | 'flow sequence'; - indicator: 'doc-start' | 'explicit-key-ind' | 'map-value-ind' | 'seq-item-ind'; - next: Token | null | undefined; - offset: number; - onError: ComposeErrorHandler; - startOnNewline: boolean; -} -export declare function resolveProps(tokens: SourceToken[], { flow, indicator, next, offset, onError, startOnNewline }: ResolvePropsArg): { - comma: SourceToken | null; - found: SourceToken | null; - spaceBefore: boolean; - comment: string; - hasNewline: boolean; - hasNewlineAfterProp: boolean; - anchor: SourceToken | null; - tag: 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 deleted file mode 100644 index 5281cca..0000000 --- a/node_modules/yaml/dist/compose/resolve-props.js +++ /dev/null @@ -1,136 +0,0 @@ -'use strict'; - -function resolveProps(tokens, { flow, indicator, next, offset, onError, startOnNewline }) { - let spaceBefore = false; - let atNewline = startOnNewline; - let hasSpace = startOnNewline; - let comment = ''; - let commentSep = ''; - let hasNewline = false; - let hasNewlineAfterProp = false; - let reqSpace = false; - let anchor = null; - let tag = null; - let comma = null; - let found = null; - let start = null; - for (const token of tokens) { - if (reqSpace) { - if (token.type !== 'space' && - token.type !== 'newline' && - token.type !== 'comma') - onError(token.offset, 'MISSING_CHAR', 'Tags and anchors must be separated from the next token by white space'); - reqSpace = false; - } - 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'); - hasSpace = true; - break; - case 'comment': { - if (!hasSpace) - onError(token, 'MISSING_CHAR', 'Comments must be separated from other tokens by white space characters'); - const cb = token.source.substring(1) || ' '; - if (!comment) - comment = cb; - else - comment += commentSep + cb; - commentSep = ''; - atNewline = false; - break; - } - case 'newline': - if (atNewline) { - if (comment) - comment += token.source; - else - spaceBefore = true; - } - else - commentSep += token.source; - atNewline = true; - hasNewline = true; - if (anchor || tag) - hasNewlineAfterProp = true; - hasSpace = true; - break; - case 'anchor': - if (anchor) - onError(token, 'MULTIPLE_ANCHORS', 'A node can have at most one anchor'); - if (token.source.endsWith(':')) - onError(token.offset + token.source.length - 1, 'BAD_ALIAS', 'Anchor ending in : is ambiguous', true); - anchor = token; - if (start === null) - start = token.offset; - atNewline = false; - hasSpace = false; - reqSpace = true; - break; - case 'tag': { - if (tag) - onError(token, 'MULTIPLE_TAGS', 'A node can have at most one tag'); - tag = token; - if (start === null) - start = token.offset; - atNewline = false; - hasSpace = false; - reqSpace = true; - break; - } - case indicator: - // Could here handle preceding comments differently - if (anchor || tag) - onError(token, 'BAD_PROP_ORDER', `Anchors and tags must be after the ${token.source} indicator`); - if (found) - onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.source} in ${flow !== null && flow !== void 0 ? flow : 'collection'}`); - found = token; - atNewline = false; - hasSpace = false; - break; - case 'comma': - if (flow) { - if (comma) - onError(token, 'UNEXPECTED_TOKEN', `Unexpected , in ${flow}`); - comma = token; - atNewline = false; - hasSpace = false; - break; - } - // else fallthrough - default: - onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${token.type} token`); - atNewline = false; - hasSpace = false; - } - } - const last = tokens[tokens.length - 1]; - const end = last ? last.offset + last.source.length : offset; - if (reqSpace && - next && - next.type !== 'space' && - next.type !== 'newline' && - next.type !== 'comma' && - (next.type !== 'scalar' || next.source !== '')) - onError(next.offset, 'MISSING_CHAR', 'Tags and anchors must be separated from the next token by white space'); - return { - comma, - found, - spaceBefore, - comment, - hasNewline, - hasNewlineAfterProp, - anchor, - tag, - end, - start: start !== null && start !== void 0 ? start : end - }; -} - -exports.resolveProps = resolveProps; diff --git a/node_modules/yaml/dist/compose/util-contains-newline.d.ts b/node_modules/yaml/dist/compose/util-contains-newline.d.ts deleted file mode 100644 index 8155be0..0000000 --- a/node_modules/yaml/dist/compose/util-contains-newline.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Token } from '../parse/cst.js'; -export declare function containsNewline(key: Token | null | undefined): boolean | null; diff --git a/node_modules/yaml/dist/compose/util-contains-newline.js b/node_modules/yaml/dist/compose/util-contains-newline.js deleted file mode 100644 index e7aa82d..0000000 --- a/node_modules/yaml/dist/compose/util-contains-newline.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -function containsNewline(key) { - if (!key) - return null; - switch (key.type) { - case 'alias': - case 'scalar': - case 'double-quoted-scalar': - case 'single-quoted-scalar': - if (key.source.includes('\n')) - return true; - if (key.end) - for (const st of key.end) - if (st.type === 'newline') - return true; - return false; - case 'flow-collection': - for (const it of key.items) { - for (const st of it.start) - if (st.type === 'newline') - return true; - if (it.sep) - for (const st of it.sep) - if (st.type === 'newline') - return true; - if (containsNewline(it.key) || containsNewline(it.value)) - return true; - } - return false; - default: - return true; - } -} - -exports.containsNewline = containsNewline; diff --git a/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts b/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts deleted file mode 100644 index 90499b8..0000000 --- a/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import type { Token } from '../parse/cst.js'; -export declare function emptyScalarPosition(offset: number, before: Token[] | undefined, pos: number | null): number; diff --git a/node_modules/yaml/dist/compose/util-empty-scalar-position.js b/node_modules/yaml/dist/compose/util-empty-scalar-position.js deleted file mode 100644 index 32951b3..0000000 --- a/node_modules/yaml/dist/compose/util-empty-scalar-position.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -function emptyScalarPosition(offset, before, pos) { - if (before) { - if (pos === null) - pos = before.length; - for (let i = pos - 1; i >= 0; --i) { - let st = before[i]; - switch (st.type) { - case 'space': - case 'comment': - case 'newline': - offset -= st.source.length; - continue; - } - // Technically, an empty scalar is immediately after the last non-empty - // node, but it's more useful to place it after any whitespace. - st = before[++i]; - while ((st === null || st === void 0 ? void 0 : st.type) === 'space') { - offset += st.source.length; - st = before[++i]; - } - break; - } - } - return offset; -} - -exports.emptyScalarPosition = emptyScalarPosition; diff --git a/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts b/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts deleted file mode 100644 index 64ed1fc..0000000 --- a/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Token } from '../parse/cst'; -import { ComposeErrorHandler } from './composer'; -export declare function flowIndentCheck(indent: number, fc: Token | null | undefined, onError: ComposeErrorHandler): void; diff --git a/node_modules/yaml/dist/compose/util-flow-indent-check.js b/node_modules/yaml/dist/compose/util-flow-indent-check.js deleted file mode 100644 index aa7c998..0000000 --- a/node_modules/yaml/dist/compose/util-flow-indent-check.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var utilContainsNewline = require('./util-contains-newline.js'); - -function flowIndentCheck(indent, fc, onError) { - if ((fc === null || fc === void 0 ? void 0 : fc.type) === 'flow-collection') { - const end = fc.end[0]; - if (end.indent === indent && - (end.source === ']' || end.source === '}') && - utilContainsNewline.containsNewline(fc)) { - const msg = 'Flow end indicator should be more indented than parent'; - onError(end, 'BAD_INDENT', msg, true); - } - } -} - -exports.flowIndentCheck = flowIndentCheck; diff --git a/node_modules/yaml/dist/compose/util-map-includes.d.ts b/node_modules/yaml/dist/compose/util-map-includes.d.ts deleted file mode 100644 index 5d2c4b3..0000000 --- a/node_modules/yaml/dist/compose/util-map-includes.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ParsedNode } from '../nodes/Node'; -import { Pair } from '../nodes/Pair'; -import { ComposeContext } from './compose-node'; -export declare function mapIncludes(ctx: ComposeContext, items: Pair<ParsedNode>[], search: ParsedNode): boolean; diff --git a/node_modules/yaml/dist/compose/util-map-includes.js b/node_modules/yaml/dist/compose/util-map-includes.js deleted file mode 100644 index ab03be1..0000000 --- a/node_modules/yaml/dist/compose/util-map-includes.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var Node = require('../nodes/Node.js'); - -function mapIncludes(ctx, items, search) { - const { uniqueKeys } = ctx.options; - if (uniqueKeys === false) - return false; - const isEqual = typeof uniqueKeys === 'function' - ? uniqueKeys - : (a, b) => a === b || - (Node.isScalar(a) && - Node.isScalar(b) && - a.value === b.value && - !(a.value === '<<' && ctx.schema.merge)); - return items.some(pair => isEqual(pair.key, search)); -} - -exports.mapIncludes = mapIncludes; |