mirror of
https://github.com/deployphp/action.git
synced 2025-04-20 19:16:47 +00:00
Add node_modules
This commit is contained in:
parent
e1f786311a
commit
554eb0b122
994 changed files with 195567 additions and 0 deletions
59
node_modules/yaml/browser/dist/compose/compose-collection.js
generated
vendored
Normal file
59
node_modules/yaml/browser/dist/compose/compose-collection.js
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
import { isNode, isMap } from '../nodes/Node.js';
|
||||
import { Scalar } from '../nodes/Scalar.js';
|
||||
import { resolveBlockMap } from './resolve-block-map.js';
|
||||
import { resolveBlockSeq } from './resolve-block-seq.js';
|
||||
import { resolveFlowCollection } from './resolve-flow-collection.js';
|
||||
|
||||
function composeCollection(CN, ctx, token, tagToken, onError) {
|
||||
let coll;
|
||||
switch (token.type) {
|
||||
case 'block-map': {
|
||||
coll = resolveBlockMap(CN, ctx, token, onError);
|
||||
break;
|
||||
}
|
||||
case 'block-seq': {
|
||||
coll = resolveBlockSeq(CN, ctx, token, onError);
|
||||
break;
|
||||
}
|
||||
case 'flow-collection': {
|
||||
coll = 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 = 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 = isNode(res)
|
||||
? res
|
||||
: new Scalar(res);
|
||||
node.range = coll.range;
|
||||
node.tag = tagName;
|
||||
if (tag?.format)
|
||||
node.format = tag.format;
|
||||
return node;
|
||||
}
|
||||
|
||||
export { composeCollection };
|
40
node_modules/yaml/browser/dist/compose/compose-doc.js
generated
vendored
Normal file
40
node_modules/yaml/browser/dist/compose/compose-doc.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { Document } from '../doc/Document.js';
|
||||
import { composeNode, composeEmptyNode } from './compose-node.js';
|
||||
import { resolveEnd } from './resolve-end.js';
|
||||
import { resolveProps } from './resolve-props.js';
|
||||
|
||||
function composeDoc(options, directives, { offset, start, value, end }, onError) {
|
||||
const opts = Object.assign({ _directives: directives }, options);
|
||||
const doc = new Document(undefined, opts);
|
||||
const ctx = {
|
||||
atRoot: true,
|
||||
directives: doc.directives,
|
||||
options: doc.options,
|
||||
schema: doc.schema
|
||||
};
|
||||
const props = resolveProps(start, {
|
||||
indicator: 'doc-start',
|
||||
next: value ?? 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(ctx, value, props, onError)
|
||||
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
||||
const contentEnd = doc.contents.range[2];
|
||||
const re = resolveEnd(end, contentEnd, false, onError);
|
||||
if (re.comment)
|
||||
doc.comment = re.comment;
|
||||
doc.range = [offset, contentEnd, re.offset];
|
||||
return doc;
|
||||
}
|
||||
|
||||
export { composeDoc };
|
92
node_modules/yaml/browser/dist/compose/compose-node.js
generated
vendored
Normal file
92
node_modules/yaml/browser/dist/compose/compose-node.js
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
import { Alias } from '../nodes/Alias.js';
|
||||
import { composeCollection } from './compose-collection.js';
|
||||
import { composeScalar } from './compose-scalar.js';
|
||||
import { resolveEnd } from './resolve-end.js';
|
||||
import { emptyScalarPosition } from './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(ctx, token, tag, onError);
|
||||
if (anchor)
|
||||
node.anchor = anchor.source.substring(1);
|
||||
break;
|
||||
case 'block-map':
|
||||
case 'block-seq':
|
||||
case 'flow-collection':
|
||||
node = 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, end }, onError) {
|
||||
const token = {
|
||||
type: 'scalar',
|
||||
offset: emptyScalarPosition(offset, before, pos),
|
||||
indent: -1,
|
||||
source: ''
|
||||
};
|
||||
const node = 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;
|
||||
node.range[2] = end;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
function composeAlias({ options }, { offset, source, end }, onError) {
|
||||
const alias = new 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(end, valueEnd, options.strict, onError);
|
||||
alias.range = [offset, valueEnd, re.offset];
|
||||
if (re.comment)
|
||||
alias.comment = re.comment;
|
||||
return alias;
|
||||
}
|
||||
|
||||
export { composeEmptyNode, composeNode };
|
80
node_modules/yaml/browser/dist/compose/compose-scalar.js
generated
vendored
Normal file
80
node_modules/yaml/browser/dist/compose/compose-scalar.js
generated
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
import { SCALAR, isScalar } from '../nodes/Node.js';
|
||||
import { Scalar } from '../nodes/Scalar.js';
|
||||
import { resolveBlockScalar } from './resolve-block-scalar.js';
|
||||
import { resolveFlowScalar } from './resolve-flow-scalar.js';
|
||||
|
||||
function composeScalar(ctx, token, tagToken, onError) {
|
||||
const { value, type, comment, range } = token.type === 'block-scalar'
|
||||
? resolveBlockScalar(token, ctx.options.strict, onError)
|
||||
: 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[SCALAR];
|
||||
let scalar;
|
||||
try {
|
||||
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
||||
scalar = isScalar(res) ? res : new Scalar(res);
|
||||
}
|
||||
catch (error) {
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg);
|
||||
scalar = new 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) {
|
||||
if (tagName === '!')
|
||||
return schema[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 (tag.test?.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[SCALAR];
|
||||
}
|
||||
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
||||
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[SCALAR];
|
||||
if (schema.compat) {
|
||||
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
||||
schema[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;
|
||||
}
|
||||
|
||||
export { composeScalar };
|
217
node_modules/yaml/browser/dist/compose/composer.js
generated
vendored
Normal file
217
node_modules/yaml/browser/dist/compose/composer.js
generated
vendored
Normal file
|
@ -0,0 +1,217 @@
|
|||
import { Directives } from '../doc/directives.js';
|
||||
import { Document } from '../doc/Document.js';
|
||||
import { YAMLWarning, YAMLParseError } from '../errors.js';
|
||||
import { isCollection, isPair } from '../nodes/Node.js';
|
||||
import { composeDoc } from './compose-doc.js';
|
||||
import { resolveEnd } from './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) {
|
||||
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 (prelude[i + 1]?.[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 YAMLWarning(pos, code, message));
|
||||
else
|
||||
this.errors.push(new YAMLParseError(pos, code, message));
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
this.directives = new 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 (isCollection(dc) && !dc.flow && dc.items.length > 0) {
|
||||
let it = dc.items[0];
|
||||
if (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) {
|
||||
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(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 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 YAMLParseError(getErrorPos(token), 'UNEXPECTED_TOKEN', msg));
|
||||
break;
|
||||
}
|
||||
this.doc.directives.docEnd = true;
|
||||
const end = 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 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(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { Composer };
|
110
node_modules/yaml/browser/dist/compose/resolve-block-map.js
generated
vendored
Normal file
110
node_modules/yaml/browser/dist/compose/resolve-block-map.js
generated
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
import { Pair } from '../nodes/Pair.js';
|
||||
import { YAMLMap } from '../nodes/YAMLMap.js';
|
||||
import { resolveProps } from './resolve-props.js';
|
||||
import { containsNewline } from './util-contains-newline.js';
|
||||
import { flowIndentCheck } from './util-flow-indent-check.js';
|
||||
import { mapIncludes } from './util-map-includes.js';
|
||||
|
||||
const startColMsg = 'All mapping items must start at the same column';
|
||||
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
||||
const map = new YAMLMap(ctx.schema);
|
||||
if (ctx.atRoot)
|
||||
ctx.atRoot = false;
|
||||
let offset = bm.offset;
|
||||
let commentEnd = null;
|
||||
for (const collItem of bm.items) {
|
||||
const { start, key, sep, value } = collItem;
|
||||
// key properties
|
||||
const keyProps = resolveProps(start, {
|
||||
indicator: 'explicit-key-ind',
|
||||
next: key ?? 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) {
|
||||
commentEnd = keyProps.end;
|
||||
if (keyProps.comment) {
|
||||
if (map.comment)
|
||||
map.comment += '\n' + keyProps.comment;
|
||||
else
|
||||
map.comment = keyProps.comment;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (keyProps.hasNewlineAfterProp || containsNewline(key)) {
|
||||
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line');
|
||||
}
|
||||
}
|
||||
else if (keyProps.found?.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)
|
||||
flowIndentCheck(bm.indent, key, onError);
|
||||
if (mapIncludes(ctx, map.items, keyNode))
|
||||
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
||||
// value properties
|
||||
const valueProps = resolveProps(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?.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)
|
||||
flowIndentCheck(bm.indent, value, onError);
|
||||
offset = valueNode.range[2];
|
||||
const pair = new 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(keyNode);
|
||||
if (ctx.options.keepSourceTokens)
|
||||
pair.srcToken = collItem;
|
||||
map.items.push(pair);
|
||||
}
|
||||
}
|
||||
if (commentEnd && commentEnd < offset)
|
||||
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content');
|
||||
map.range = [bm.offset, offset, commentEnd ?? offset];
|
||||
return map;
|
||||
}
|
||||
|
||||
export { resolveBlockMap };
|
194
node_modules/yaml/browser/dist/compose/resolve-block-scalar.js
generated
vendored
Normal file
194
node_modules/yaml/browser/dist/compose/resolve-block-scalar.js
generated
vendored
Normal file
|
@ -0,0 +1,194 @@
|
|||
import { Scalar } from '../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.BLOCK_FOLDED : 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.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?.[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;
|
||||
}
|
||||
|
||||
export { resolveBlockScalar };
|
45
node_modules/yaml/browser/dist/compose/resolve-block-seq.js
generated
vendored
Normal file
45
node_modules/yaml/browser/dist/compose/resolve-block-seq.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { YAMLSeq } from '../nodes/YAMLSeq.js';
|
||||
import { resolveProps } from './resolve-props.js';
|
||||
import { flowIndentCheck } from './util-flow-indent-check.js';
|
||||
|
||||
function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
||||
const seq = new YAMLSeq(ctx.schema);
|
||||
if (ctx.atRoot)
|
||||
ctx.atRoot = false;
|
||||
let offset = bs.offset;
|
||||
let commentEnd = null;
|
||||
for (const { start, value } of bs.items) {
|
||||
const props = resolveProps(start, {
|
||||
indicator: 'seq-item-ind',
|
||||
next: value,
|
||||
offset,
|
||||
onError,
|
||||
startOnNewline: true
|
||||
});
|
||||
if (!props.found) {
|
||||
if (props.anchor || props.tag || value) {
|
||||
if (value && value.type === 'block-seq')
|
||||
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
||||
else
|
||||
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
||||
}
|
||||
else {
|
||||
commentEnd = props.end;
|
||||
if (props.comment)
|
||||
seq.comment = props.comment;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const node = value
|
||||
? composeNode(ctx, value, props, onError)
|
||||
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
||||
if (ctx.schema.compat)
|
||||
flowIndentCheck(bs.indent, value, onError);
|
||||
offset = node.range[2];
|
||||
seq.items.push(node);
|
||||
}
|
||||
seq.range = [bs.offset, offset, commentEnd ?? offset];
|
||||
return seq;
|
||||
}
|
||||
|
||||
export { resolveBlockSeq };
|
37
node_modules/yaml/browser/dist/compose/resolve-end.js
generated
vendored
Normal file
37
node_modules/yaml/browser/dist/compose/resolve-end.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
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 };
|
||||
}
|
||||
|
||||
export { resolveEnd };
|
200
node_modules/yaml/browser/dist/compose/resolve-flow-collection.js
generated
vendored
Normal file
200
node_modules/yaml/browser/dist/compose/resolve-flow-collection.js
generated
vendored
Normal file
|
@ -0,0 +1,200 @@
|
|||
import { isPair } from '../nodes/Node.js';
|
||||
import { Pair } from '../nodes/Pair.js';
|
||||
import { YAMLMap } from '../nodes/YAMLMap.js';
|
||||
import { YAMLSeq } from '../nodes/YAMLSeq.js';
|
||||
import { resolveEnd } from './resolve-end.js';
|
||||
import { resolveProps } from './resolve-props.js';
|
||||
import { containsNewline } from './util-contains-newline.js';
|
||||
import { mapIncludes } from './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) {
|
||||
const isMap = fc.start.source === '{';
|
||||
const fcName = isMap ? 'flow map' : 'flow sequence';
|
||||
const coll = isMap
|
||||
? new YAMLMap(ctx.schema)
|
||||
: new 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(start, {
|
||||
flow: fcName,
|
||||
indicator: 'explicit-key-ind',
|
||||
next: key ?? 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 && 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 (isPair(prev))
|
||||
prev = prev.value ?? 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(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(keyNode, valueNode);
|
||||
if (ctx.options.keepSourceTokens)
|
||||
pair.srcToken = collItem;
|
||||
if (isMap) {
|
||||
const map = coll;
|
||||
if (mapIncludes(ctx, map.items, keyNode))
|
||||
onError(keyStart, 'DUPLICATE_KEY', 'Map keys must be unique');
|
||||
map.items.push(pair);
|
||||
}
|
||||
else {
|
||||
const map = new 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(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;
|
||||
}
|
||||
|
||||
export { resolveFlowCollection };
|
223
node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js
generated
vendored
Normal file
223
node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js
generated
vendored
Normal file
|
@ -0,0 +1,223 @@
|
|||
import { Scalar } from '../nodes/Scalar.js';
|
||||
import { resolveEnd } from './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.PLAIN;
|
||||
value = plainValue(source, _onError);
|
||||
break;
|
||||
case 'single-quoted-scalar':
|
||||
_type = Scalar.QUOTE_SINGLE;
|
||||
value = singleQuotedValue(source, _onError);
|
||||
break;
|
||||
case 'double-quoted-scalar':
|
||||
_type = 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(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) {
|
||||
/**
|
||||
* 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 + (match?.[1] ?? '');
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
export { resolveFlowScalar };
|
134
node_modules/yaml/browser/dist/compose/resolve-props.js
generated
vendored
Normal file
134
node_modules/yaml/browser/dist/compose/resolve-props.js
generated
vendored
Normal file
|
@ -0,0 +1,134 @@
|
|||
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 ?? '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 ?? end
|
||||
};
|
||||
}
|
||||
|
||||
export { resolveProps };
|
34
node_modules/yaml/browser/dist/compose/util-contains-newline.js
generated
vendored
Normal file
34
node_modules/yaml/browser/dist/compose/util-contains-newline.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
export { containsNewline };
|
27
node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js
generated
vendored
Normal file
27
node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
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?.type === 'space') {
|
||||
offset += st.source.length;
|
||||
st = before[++i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
export { emptyScalarPosition };
|
15
node_modules/yaml/browser/dist/compose/util-flow-indent-check.js
generated
vendored
Normal file
15
node_modules/yaml/browser/dist/compose/util-flow-indent-check.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { containsNewline } from './util-contains-newline.js';
|
||||
|
||||
function flowIndentCheck(indent, fc, onError) {
|
||||
if (fc?.type === 'flow-collection') {
|
||||
const end = fc.end[0];
|
||||
if (end.indent === indent &&
|
||||
(end.source === ']' || end.source === '}') &&
|
||||
containsNewline(fc)) {
|
||||
const msg = 'Flow end indicator should be more indented than parent';
|
||||
onError(end, 'BAD_INDENT', msg, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { flowIndentCheck };
|
17
node_modules/yaml/browser/dist/compose/util-map-includes.js
generated
vendored
Normal file
17
node_modules/yaml/browser/dist/compose/util-map-includes.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { isScalar } from '../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 ||
|
||||
(isScalar(a) &&
|
||||
isScalar(b) &&
|
||||
a.value === b.value &&
|
||||
!(a.value === '<<' && ctx.schema.merge));
|
||||
return items.some(pair => isEqual(pair.key, search));
|
||||
}
|
||||
|
||||
export { mapIncludes };
|
Loading…
Add table
Add a link
Reference in a new issue