Comparing version 2.4.5 to 2.5.0
@@ -26,6 +26,19 @@ import { isNode } from '../nodes/identity.js'; | ||
} | ||
function composeCollection(CN, ctx, token, tagToken, onError) { | ||
function composeCollection(CN, ctx, token, props, onError) { | ||
const tagToken = props.tag; | ||
const tagName = !tagToken | ||
? null | ||
: ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg)); | ||
if (token.type === 'block-seq') { | ||
const { anchor, newlineAfterProp: nl } = props; | ||
const lastProp = anchor && tagToken | ||
? anchor.offset > tagToken.offset | ||
? anchor | ||
: tagToken | ||
: (anchor ?? tagToken); | ||
if (lastProp && (!nl || nl.offset < lastProp.offset)) { | ||
const message = 'Missing newline after block sequence props'; | ||
onError(lastProp, 'MISSING_CHAR', message); | ||
} | ||
} | ||
const expType = token.type === 'block-map' | ||
@@ -44,4 +57,3 @@ ? 'map' | ||
(tagName === YAMLMap.tagName && expType === 'map') || | ||
(tagName === YAMLSeq.tagName && expType === 'seq') || | ||
!expType) { | ||
(tagName === YAMLSeq.tagName && expType === 'seq')) { | ||
return resolveCollection(CN, ctx, token, onError, tagName); | ||
@@ -48,0 +60,0 @@ } |
@@ -29,3 +29,3 @@ import { Alias } from '../nodes/Alias.js'; | ||
case 'flow-collection': | ||
node = composeCollection(CN, ctx, token, tag, onError); | ||
node = composeCollection(CN, ctx, token, props, onError); | ||
if (anchor) | ||
@@ -32,0 +32,0 @@ node.anchor = anchor.source.substring(1); |
@@ -45,3 +45,3 @@ import { Pair } from '../nodes/Pair.js'; | ||
} | ||
if (keyProps.hasNewlineAfterProp || containsNewline(key)) { | ||
if (keyProps.newlineAfterProp || containsNewline(key)) { | ||
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line'); | ||
@@ -48,0 +48,0 @@ } |
@@ -8,3 +8,2 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) { | ||
let hasNewline = false; | ||
let hasNewlineAfterProp = false; | ||
let reqSpace = false; | ||
@@ -14,2 +13,3 @@ let tab = null; | ||
let tag = null; | ||
let newlineAfterProp = null; | ||
let comma = null; | ||
@@ -68,3 +68,3 @@ let found = null; | ||
if (anchor || tag) | ||
hasNewlineAfterProp = true; | ||
newlineAfterProp = token; | ||
hasSpace = true; | ||
@@ -143,5 +143,5 @@ break; | ||
hasNewline, | ||
hasNewlineAfterProp, | ||
anchor, | ||
tag, | ||
newlineAfterProp, | ||
end, | ||
@@ -148,0 +148,0 @@ start: start ?? end |
@@ -146,4 +146,3 @@ import { createNode } from '../doc/createNode.js'; | ||
} | ||
Collection.maxFlowStringSingleLineLength = 60; | ||
export { Collection, collectionFromPath, isEmptyPath }; |
@@ -293,12 +293,8 @@ import { BOM, DOCUMENT, FLOW_END, SCALAR } from './cst.js'; | ||
const s = this.peek(3); | ||
if (s === '---' && isEmpty(this.charAt(3))) { | ||
if ((s === '---' || s === '...') && isEmpty(this.charAt(3))) { | ||
yield* this.pushCount(3); | ||
this.indentValue = 0; | ||
this.indentNext = 0; | ||
return 'doc'; | ||
return s === '---' ? 'doc' : 'stream'; | ||
} | ||
else if (s === '...' && isEmpty(this.charAt(3))) { | ||
yield* this.pushCount(3); | ||
return 'stream'; | ||
} | ||
} | ||
@@ -305,0 +301,0 @@ this.indentValue = yield* this.pushSpaces(false); |
@@ -12,2 +12,4 @@ const FOLD_FLOW = 'flow'; | ||
return text; | ||
if (lineWidth < minContentWidth) | ||
minContentWidth = 0; | ||
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); | ||
@@ -14,0 +16,0 @@ if (text.length <= endStep) |
@@ -1,3 +0,2 @@ | ||
/// <reference types="node" /> | ||
export declare const help = "yaml: A command-line YAML processor and inspector\n\nReads stdin and writes output to stdout and errors & warnings to stderr.\n\nUsage:\n yaml Process a YAML stream, outputting it as YAML\n yaml cst Parse the CST of a YAML stream\n yaml lex Parse the lexical tokens of a YAML stream\n yaml valid Validate a YAML stream, returning 0 on success\n\nOptions:\n --help, -h Show this message.\n --json, -j Output JSON.\n\nAdditional options for bare \"yaml\" command:\n --doc, -d Output pretty-printed JS Document objects.\n --single, -1 Require the input to consist of a single YAML document.\n --strict, -s Stop on errors.\n --visit, -v Apply a visitor to each document (requires a path to import)\n --yaml 1.1 Set the YAML version. (default: 1.2)"; | ||
export declare const help = "yaml: A command-line YAML processor and inspector\n\nReads stdin and writes output to stdout and errors & warnings to stderr.\n\nUsage:\n yaml Process a YAML stream, outputting it as YAML\n yaml cst Parse the CST of a YAML stream\n yaml lex Parse the lexical tokens of a YAML stream\n yaml valid Validate a YAML stream, returning 0 on success\n\nOptions:\n --help, -h Show this message.\n --json, -j Output JSON.\n --indent 2 Output pretty-printed data, indented by the given number of spaces.\n\nAdditional options for bare \"yaml\" command:\n --doc, -d Output pretty-printed JS Document objects.\n --single, -1 Require the input to consist of a single YAML document.\n --strict, -s Stop on errors.\n --visit, -v Apply a visitor to each document (requires a path to import)\n --yaml 1.1 Set the YAML version. (default: 1.2)"; | ||
export declare class UserError extends Error { | ||
@@ -4,0 +3,0 @@ static ARGS: number; |
@@ -5,2 +5,8 @@ import type { ParsedNode } from '../nodes/Node.js'; | ||
import type { ComposeErrorHandler } from './composer.js'; | ||
export declare function composeCollection(CN: ComposeNode, ctx: ComposeContext, token: BlockMap | BlockSequence | FlowCollection, tagToken: SourceToken | null, onError: ComposeErrorHandler): ParsedNode; | ||
interface Props { | ||
anchor: SourceToken | null; | ||
tag: SourceToken | null; | ||
newlineAfterProp: SourceToken | null; | ||
} | ||
export declare function composeCollection(CN: ComposeNode, ctx: ComposeContext, token: BlockMap | BlockSequence | FlowCollection, props: Props, onError: ComposeErrorHandler): ParsedNode; | ||
export {}; |
@@ -28,6 +28,19 @@ 'use strict'; | ||
} | ||
function composeCollection(CN, ctx, token, tagToken, onError) { | ||
function composeCollection(CN, ctx, token, props, onError) { | ||
const tagToken = props.tag; | ||
const tagName = !tagToken | ||
? null | ||
: ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg)); | ||
if (token.type === 'block-seq') { | ||
const { anchor, newlineAfterProp: nl } = props; | ||
const lastProp = anchor && tagToken | ||
? anchor.offset > tagToken.offset | ||
? anchor | ||
: tagToken | ||
: (anchor ?? tagToken); | ||
if (lastProp && (!nl || nl.offset < lastProp.offset)) { | ||
const message = 'Missing newline after block sequence props'; | ||
onError(lastProp, 'MISSING_CHAR', message); | ||
} | ||
} | ||
const expType = token.type === 'block-map' | ||
@@ -46,4 +59,3 @@ ? 'map' | ||
(tagName === YAMLMap.YAMLMap.tagName && expType === 'map') || | ||
(tagName === YAMLSeq.YAMLSeq.tagName && expType === 'seq') || | ||
!expType) { | ||
(tagName === YAMLSeq.YAMLSeq.tagName && expType === 'seq')) { | ||
return resolveCollection(CN, ctx, token, onError, tagName); | ||
@@ -50,0 +62,0 @@ } |
@@ -18,2 +18,3 @@ import type { Directives } from '../doc/directives.js'; | ||
tag: SourceToken | null; | ||
newlineAfterProp: SourceToken | null; | ||
end: number; | ||
@@ -20,0 +21,0 @@ } |
@@ -31,3 +31,3 @@ 'use strict'; | ||
case 'flow-collection': | ||
node = composeCollection.composeCollection(CN, ctx, token, tag, onError); | ||
node = composeCollection.composeCollection(CN, ctx, token, props, onError); | ||
if (anchor) | ||
@@ -34,0 +34,0 @@ node.anchor = anchor.source.substring(1); |
@@ -1,2 +0,1 @@ | ||
import type { ParsedNode } from '../nodes/Node.js'; | ||
import { YAMLMap } from '../nodes/YAMLMap.js'; | ||
@@ -7,2 +6,2 @@ import type { BlockMap } from '../parse/cst.js'; | ||
import type { ComposeErrorHandler } from './composer.js'; | ||
export declare function resolveBlockMap({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bm: BlockMap, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLMap.Parsed<ParsedNode, ParsedNode | null>; | ||
export declare function resolveBlockMap({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bm: BlockMap, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLMap.Parsed; |
@@ -47,3 +47,3 @@ 'use strict'; | ||
} | ||
if (keyProps.hasNewlineAfterProp || utilContainsNewline.containsNewline(key)) { | ||
if (keyProps.newlineAfterProp || utilContainsNewline.containsNewline(key)) { | ||
onError(key ?? start[start.length - 1], 'MULTILINE_IMPLICIT_KEY', 'Implicit keys need to be on a single line'); | ||
@@ -50,0 +50,0 @@ } |
@@ -6,2 +6,2 @@ import { YAMLSeq } from '../nodes/YAMLSeq.js'; | ||
import type { ComposeErrorHandler } from './composer.js'; | ||
export declare function resolveBlockSeq({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bs: BlockSequence, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLSeq.Parsed<import("../index.js").ParsedNode>; | ||
export declare function resolveBlockSeq({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bs: BlockSequence, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLSeq.Parsed; |
@@ -18,7 +18,7 @@ import type { SourceToken, Token } from '../parse/cst.js'; | ||
hasNewline: boolean; | ||
hasNewlineAfterProp: boolean; | ||
anchor: SourceToken | null; | ||
tag: SourceToken | null; | ||
newlineAfterProp: SourceToken | null; | ||
end: number; | ||
start: number; | ||
}; |
@@ -10,3 +10,2 @@ 'use strict'; | ||
let hasNewline = false; | ||
let hasNewlineAfterProp = false; | ||
let reqSpace = false; | ||
@@ -16,2 +15,3 @@ let tab = null; | ||
let tag = null; | ||
let newlineAfterProp = null; | ||
let comma = null; | ||
@@ -70,3 +70,3 @@ let found = null; | ||
if (anchor || tag) | ||
hasNewlineAfterProp = true; | ||
newlineAfterProp = token; | ||
hasSpace = true; | ||
@@ -145,5 +145,5 @@ break; | ||
hasNewline, | ||
hasNewlineAfterProp, | ||
anchor, | ||
tag, | ||
newlineAfterProp, | ||
end, | ||
@@ -150,0 +150,0 @@ start: start ?? end |
@@ -7,3 +7,2 @@ import type { Schema } from '../schema/Schema.js'; | ||
export declare abstract class Collection extends NodeBase { | ||
static maxFlowStringSingleLineLength: number; | ||
schema: Schema | undefined; | ||
@@ -10,0 +9,0 @@ [NODE_TYPE]: symbol; |
@@ -148,3 +148,2 @@ 'use strict'; | ||
} | ||
Collection.maxFlowStringSingleLineLength = 60; | ||
@@ -151,0 +150,0 @@ exports.Collection = Collection; |
@@ -16,3 +16,3 @@ import type { Document } from '../doc/Document.js'; | ||
export declare const isAlias: (node: any) => node is Alias; | ||
export declare const isDocument: <T extends Node = Node>(node: any) => node is Document<T, true>; | ||
export declare const isDocument: <T extends Node = Node>(node: any) => node is Document<T>; | ||
export declare const isMap: <K = unknown, V = unknown>(node: any) => node is YAMLMap<K, V>; | ||
@@ -19,0 +19,0 @@ export declare const isPair: <K = unknown, V = unknown>(node: any) => node is Pair<K, V>; |
@@ -295,12 +295,8 @@ 'use strict'; | ||
const s = this.peek(3); | ||
if (s === '---' && isEmpty(this.charAt(3))) { | ||
if ((s === '---' || s === '...') && isEmpty(this.charAt(3))) { | ||
yield* this.pushCount(3); | ||
this.indentValue = 0; | ||
this.indentNext = 0; | ||
return 'doc'; | ||
return s === '---' ? 'doc' : 'stream'; | ||
} | ||
else if (s === '...' && isEmpty(this.charAt(3))) { | ||
yield* this.pushCount(3); | ||
return 'stream'; | ||
} | ||
} | ||
@@ -307,0 +303,0 @@ this.indentValue = yield* this.pushSpaces(false); |
@@ -12,8 +12,8 @@ import { ToJSContext } from '../../nodes/toJS.js'; | ||
value: any; | ||
}, overwrite?: boolean | undefined) => void; | ||
}, overwrite?: boolean) => void; | ||
delete: (key: unknown) => boolean; | ||
get: { | ||
(key: unknown, keepScalar: true): import("../../index.js").Scalar<any> | undefined; | ||
(key: unknown, keepScalar?: false | undefined): any; | ||
(key: unknown, keepScalar?: boolean | undefined): any; | ||
(key: unknown, keepScalar?: false): any; | ||
(key: unknown, keepScalar?: boolean): any; | ||
}; | ||
@@ -20,0 +20,0 @@ has: (key: unknown) => boolean; |
@@ -14,2 +14,4 @@ 'use strict'; | ||
return text; | ||
if (lineWidth < minContentWidth) | ||
minContentWidth = 0; | ||
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); | ||
@@ -16,0 +18,0 @@ if (text.length <= endStep) |
{ | ||
"name": "yaml", | ||
"version": "2.4.5", | ||
"version": "2.5.0", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "author": "Eemeli Aro <eemeli@gmail.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
675753
17841
10