@effected/yaml 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -193,10 +193,29 @@ The `requoteScalars: true` half of the `singleQuote` row is what buys full parit
193
193
 
194
194
  Multi-document streams — a Kubernetes manifest, or the two-document `pnpm-lock.yaml` pnpm 11 writes under `configDependencies` — format whole: every document is re-emitted in order with its own `---`/`...` framing and comments, so no document is ever dropped. Document detection is CST-level, so a `---` inside a block scalar or quoted string is content and formats normally. The formatter leaves input byte-identical rather than corrupting it in exactly two cases: a fatal parse error in any document, and a stream carrying `%YAML`/`%TAG` directives (which the emitter cannot re-emit faithfully). Validate a whole stream with `Yaml.parseAllResult`, which fails typed when any document carries a fatal diagnostic; `YamlFormat.modify` stays single-document, since a path names no particular document of a stream.
195
195
 
196
+ ## Emitting for a YAML 1.1 consumer
197
+
198
+ YAML 1.2's Core Schema resolves fewer plain scalars to non-strings than YAML 1.1 does. A plain `on` or `yes` round-trips as a string under this package's own parser but becomes a boolean the moment a YAML 1.1 consumer — js-yaml, PyYAML, libyaml, the `yaml` npm package's YAML 1.1 schema, most CI systems' native YAML support — reads it back: the "Norway problem". `quoteCompat: "yaml-1.1"` closes that gap on the way out, quoting every plain scalar a 1.1 resolver would re-type: the extended booleans (`y`/`yes`/`no`/`on`/`off` and case variants), 1.1 timestamps, sexagesimal numbers (`1:30`), underscore-grouped numbers (`1_000`) and the octal/hex/binary integer forms (`0777`, `0x_FF`, `0b1010_0111`). It is strictly additive — nothing the 1.2 rules already quote loses a quote, and no string outside that list gains one — and composes with `quoteStyle` for the quote character and `lineWidth` for folding:
199
+
200
+ ```ts
201
+ import { Yaml, YamlStringifyOptions } from "@effected/yaml";
202
+ import { Effect } from "effect";
203
+
204
+ const frontmatter = { node: "on", released: "2024-01-15", port: "yes" };
205
+ const options = YamlStringifyOptions.make({ lineWidth: 0, quoteCompat: "yaml-1.1", quoteStyle: "double" });
206
+
207
+ Effect.runPromise(Yaml.stringify(frontmatter, options)).then(console.log);
208
+ // node: "on"
209
+ // released: "2024-01-15"
210
+ // port: "yes"
211
+ ```
212
+
213
+ That combination — `lineWidth: 0` (no folding), `quoteCompat: "yaml-1.1"`, `quoteStyle: "double"` — is the shape to reach for when stringifying frontmatter destined for YAML-1.1 tooling: Markdown frontmatter parsers and most static-site generators still resolve on the older rules. The option applies on both the value path (`Yaml.stringify`, `Yaml.stringifyResult`) and the node path (`YamlDocument#stringify`, `YamlFormat`), and scalars carrying an explicit tag are exempt, exactly like the 1.2 type-conflict check it extends.
214
+
196
215
  ## Features
197
216
 
198
217
  - `Yaml.parse` / `Yaml.parseAll` — error-recovery parsing of a single document or a `---`-separated stream into plain values, resolving anchors and aliases and aggregating every diagnostic into one `YamlParseError`.
199
- - `Yaml.stringify` — serialize a plain value back to YAML, failing typed with `YamlStringifyError` on circular references or on excessively deep nesting; a block-mapping key too long to render on one line spills into explicit-key form (`? key` / `: value`) so strict parsers still accept the output.
218
+ - `Yaml.stringify` — serialize a plain value back to YAML, failing typed with `YamlStringifyError` on circular references or on excessively deep nesting; a block-mapping key too long to render on one line spills into explicit-key form (`? key` / `: value`) so strict parsers still accept the output; `quoteCompat: "yaml-1.1"` additionally quotes plain scalars a YAML 1.1 resolver would re-type.
200
219
  - `Yaml.parseResult` / `Yaml.parseAllResult` / `Yaml.stringifyResult` — the pure synchronous counterparts, returning a `Result` instead of an `Effect` for config-time callers that cannot await; each runs the same engine call as its `Effect` variant, so the two forms cannot diverge, and a fatal diagnostic, a duplicate key, an alias bomb or a circular reference still fails typed rather than throwing. `parseAllResult` doubles as a whole-stream validity check: it fails when any document in the stream is invalid.
201
220
  - `Yaml.stripComments` — quote-aware comment removal that keeps line numbers stable, or every byte offset stable when given a replacement character.
202
221
  - `Yaml.equals` / `Yaml.equalsValue` — semantic equality that ignores comments, whitespace, formatting and mapping key order while keeping sequence order significant.
package/Yaml.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AliasExpansionBudgetExceeded, CollectionStyle, QuoteStyle, ScalarStyle, nodeToJsValue } from "./YamlNode.js";
1
+ import { AliasExpansionBudgetExceeded, CollectionStyle, QuoteCompat, QuoteStyle, ScalarStyle, nodeToJsValue } from "./YamlNode.js";
2
2
  import { composeAllDocuments, composeFirstDocument } from "./internal/composer/document.js";
3
3
  import { isFatalCode } from "./internal/diagnostics.js";
4
4
  import { StringifyDepthExceeded, StringifyFailure, stringifyValue } from "./internal/stringifier.js";
@@ -35,8 +35,9 @@ var YamlParseOptions = class extends Schema.Class("YamlParseOptions")({
35
35
  * Options controlling stringify behavior. All fields are omissible; absent
36
36
  * fields resolve to `indent` `2`, `lineWidth` `0`, `defaultScalarStyle`
37
37
  * `"plain"`, `defaultCollectionStyle` `"block"`, `sortKeys` `false`,
38
- * `indentSequences` `false`, `quoteStyle` `"single"`, `finalNewline` `true`
39
- * and `forceDefaultStyles` `false`.
38
+ * `indentSequences` `false`, `quoteStyle` `"single"`, `quoteCompat` absent
39
+ * (no dialect-compat quoting), `finalNewline` `true` and `forceDefaultStyles`
40
+ * `false`.
40
41
  *
41
42
  * `lineWidth` controls column-based scalar folding. The default `0` (and any
42
43
  * value `<= 0`) never wraps, emitting byte-identical output to the historic
@@ -114,6 +115,33 @@ var YamlStringifyOptions = class extends Schema.Class("YamlStringifyOptions")({
114
115
  * `"double-quoted"` is unaffected.
115
116
  */
116
117
  quoteStyle: Schema.optionalKey(QuoteStyle),
118
+ /**
119
+ * Additionally quote plain scalars a foreign resolution dialect would
120
+ * coerce to a non-string. Absent (the default) adds no quoting beyond the
121
+ * YAML 1.2 Core Schema rules — byte-identical to the released output.
122
+ *
123
+ * `"yaml-1.1"` quotes every plain scalar a YAML 1.1 parser (js-yaml,
124
+ * PyYAML, libyaml, and the `yaml` npm package's YAML 1.1 schema, whose
125
+ * lenient resolvers set the outer bound) would implicitly resolve to a
126
+ * non-string: the extended
127
+ * boolean spellings (`y`/`yes`/`on`/`off` and case variants — the "Norway
128
+ * problem"), timestamps (`2024-01-15`, `2001-12-15T02:59:43.1Z`, the
129
+ * space-separated 1.1 forms), sexagesimal numbers (`1:30`,
130
+ * `190:20:30.15`), underscore-separated numbers (`1_000`) and the
131
+ * base-2/8/16 integer forms (`0b1010_0111`, `0777`, `0x_FF`). Use it when
132
+ * emitted output is parsed downstream by a YAML 1.1 consumer and blanket
133
+ * `defaultScalarStyle` quoting is too noisy.
134
+ *
135
+ * Strictly additive: it never un-quotes anything the 1.2 rules require
136
+ * quoted, strings no 1.1 parser coerces stay plain, and the quote
137
+ * character stays governed by `quoteStyle`. Scalars carrying an explicit
138
+ * tag are exempt, exactly like the 1.2 type-conflict check. Applies
139
+ * wherever the plain fallback renders — values, mapping keys, flow items —
140
+ * on both the value path ({@link Yaml.stringify},
141
+ * {@link Yaml.stringifyResult}) and the node path (`YamlDocument#stringify`
142
+ * and the `YamlFormat` helpers).
143
+ */
144
+ quoteCompat: Schema.optionalKey(QuoteCompat),
117
145
  finalNewline: Schema.optionalKey(Schema.Boolean),
118
146
  forceDefaultStyles: Schema.optionalKey(Schema.Boolean)
119
147
  }) {};
@@ -167,6 +195,7 @@ const toStringifyInput = (options) => options === void 0 ? {} : {
167
195
  sortKeys: options.sortKeys,
168
196
  indentSequences: options.indentSequences,
169
197
  quoteStyle: options.quoteStyle,
198
+ quoteCompat: options.quoteCompat,
170
199
  finalNewline: options.finalNewline,
171
200
  forceDefaultStyles: options.forceDefaultStyles
172
201
  };
package/YamlDocument.js CHANGED
@@ -163,6 +163,8 @@ const toStringifyInput = (options) => options === void 0 ? {} : {
163
163
  defaultCollectionStyle: options.defaultCollectionStyle,
164
164
  sortKeys: options.sortKeys,
165
165
  indentSequences: options.indentSequences,
166
+ quoteStyle: options.quoteStyle,
167
+ quoteCompat: options.quoteCompat,
166
168
  finalNewline: options.finalNewline,
167
169
  forceDefaultStyles: options.forceDefaultStyles
168
170
  };
package/YamlFormat.js CHANGED
@@ -12,8 +12,8 @@ import { Effect, Schema } from "effect";
12
12
  //#region src/YamlFormat.ts
13
13
  /**
14
14
  * Options controlling formatting behavior: every {@link YamlStringifyOptions}
15
- * field (derived, not hand-duplicated — including `indentSequences` and
16
- * `quoteStyle`) plus
15
+ * field (derived, not hand-duplicated — including `indentSequences`,
16
+ * `quoteStyle` and `quoteCompat`) plus
17
17
  * `preserveComments` (default `true`), `range` (restrict edits to a
18
18
  * region; see the module-level remarks on the `range` parameter vs. this
19
19
  * field) and `requoteScalars` (default `false`).
@@ -105,6 +105,7 @@ const toStringifyInput = (options) => options === void 0 ? {} : {
105
105
  sortKeys: options.sortKeys,
106
106
  indentSequences: options.indentSequences,
107
107
  quoteStyle: options.quoteStyle,
108
+ quoteCompat: options.quoteCompat,
108
109
  finalNewline: options.finalNewline,
109
110
  forceDefaultStyles: options.forceDefaultStyles
110
111
  };
package/YamlNode.js CHANGED
@@ -30,6 +30,21 @@ const CollectionStyle = Schema.Literals(["block", "flow"]);
30
30
  */
31
31
  const QuoteStyle = Schema.Literals(["single", "double"]);
32
32
  /**
33
+ * Foreign resolution dialects the stringifier's plain-scalar fallback can
34
+ * defend against: setting the `quoteCompat` field of `YamlStringifyOptions`
35
+ * to `"yaml-1.1"` additionally quotes every plain scalar a YAML 1.1 parser
36
+ * (js-yaml, PyYAML, libyaml, and the `yaml` npm package's YAML 1.1 schema,
37
+ * whose lenient resolvers set the outer bound) would implicitly resolve to a
38
+ * non-string —
39
+ * `yes`/`no`/`on`/`off` booleans, ISO 8601 and space-separated timestamps,
40
+ * sexagesimal `1:30`, underscored `1_000` and base-2/8/16 numbers. Like
41
+ * `QuoteStyle` it is a stringify-option vocabulary, never a property of a
42
+ * composed node.
43
+ *
44
+ * @public
45
+ */
46
+ const QuoteCompat = Schema.Literals(["yaml-1.1"]);
47
+ /**
33
48
  * Block-scalar chomping indicators (`-` strip, default clip, `+` keep).
34
49
  * Referenced by the {@link YamlScalar} `chomp` field schema.
35
50
  *
@@ -442,4 +457,4 @@ function nodeToValue(node, anchors, budget, counting = false) {
442
457
  }
443
458
 
444
459
  //#endregion
445
- export { AliasExpansionBudgetExceeded, CollectionStyle, QuoteStyle, ScalarChomp, ScalarStyle, YamlAlias, YamlMap, YamlNode, YamlPair, YamlScalar, YamlSeq, aliasExpansionLimit, nodeToJsValue };
460
+ export { AliasExpansionBudgetExceeded, CollectionStyle, QuoteCompat, QuoteStyle, ScalarChomp, ScalarStyle, YamlAlias, YamlMap, YamlNode, YamlPair, YamlScalar, YamlSeq, aliasExpansionLimit, nodeToJsValue };
package/index.d.ts CHANGED
@@ -5,75 +5,75 @@ import { Data, Effect, Option, Result, Schema, Stream } from "effect";
5
5
  *
6
6
  * @public
7
7
  */
8
- declare const YamlLexErrorCode: Schema.Literals<readonly ["UnexpectedCharacter", "UnterminatedString", "InvalidEscapeSequence", "InvalidUnicode", "UnterminatedBlockScalar", "UnterminatedFlowCollection", "InvalidDirective", "InvalidTagHandle", "InvalidAnchorName", "UnexpectedByteOrderMark"]>;
8
+ export declare const YamlLexErrorCode: Schema.Literals<readonly ["UnexpectedCharacter", "UnterminatedString", "InvalidEscapeSequence", "InvalidUnicode", "UnterminatedBlockScalar", "UnterminatedFlowCollection", "InvalidDirective", "InvalidTagHandle", "InvalidAnchorName", "UnexpectedByteOrderMark"]>;
9
9
  /**
10
10
  * The union of all lexer-stage error code string literals.
11
11
  *
12
12
  * @public
13
13
  */
14
- type YamlLexErrorCode = typeof YamlLexErrorCode.Type;
14
+ export type YamlLexErrorCode = typeof YamlLexErrorCode.Type;
15
15
  /**
16
16
  * Error codes emitted by the CST-parser stage.
17
17
  *
18
18
  * @public
19
19
  */
20
- declare const YamlParseErrorCode: Schema.Literals<readonly ["InvalidIndentation", "DuplicateKey", "UnexpectedToken", "MissingValue", "MissingKey", "TabIndentation", "InvalidBlockStructure", "MalformedFlowCollection", "NestingDepthExceeded"]>;
20
+ export declare const YamlParseErrorCode: Schema.Literals<readonly ["InvalidIndentation", "DuplicateKey", "UnexpectedToken", "MissingValue", "MissingKey", "TabIndentation", "InvalidBlockStructure", "MalformedFlowCollection", "NestingDepthExceeded"]>;
21
21
  /**
22
22
  * The union of all parser-stage error code string literals.
23
23
  *
24
24
  * @public
25
25
  */
26
- type YamlParseErrorCode = typeof YamlParseErrorCode.Type;
26
+ export type YamlParseErrorCode = typeof YamlParseErrorCode.Type;
27
27
  /**
28
28
  * Error codes emitted by the composer stage.
29
29
  *
30
30
  * @public
31
31
  */
32
- declare const YamlComposerErrorCode: Schema.Literals<readonly ["UndefinedAlias", "DuplicateAnchor", "CircularAlias", "UnresolvedTag", "InvalidTagValue", "AliasCountExceeded", "InvalidDirective"]>;
32
+ export declare const YamlComposerErrorCode: Schema.Literals<readonly ["UndefinedAlias", "DuplicateAnchor", "CircularAlias", "UnresolvedTag", "InvalidTagValue", "AliasCountExceeded", "InvalidDirective"]>;
33
33
  /**
34
34
  * The union of all composer-stage error code string literals.
35
35
  *
36
36
  * @public
37
37
  */
38
- type YamlComposerErrorCode = typeof YamlComposerErrorCode.Type;
38
+ export type YamlComposerErrorCode = typeof YamlComposerErrorCode.Type;
39
39
  /**
40
40
  * Error codes emitted by the stringifier (the circular-reference guard).
41
41
  *
42
42
  * @public
43
43
  */
44
- declare const YamlStringifyErrorCode: Schema.Literals<readonly ["CircularReference"]>;
44
+ export declare const YamlStringifyErrorCode: Schema.Literals<readonly ["CircularReference"]>;
45
45
  /**
46
46
  * The union of all stringifier-stage error code string literals.
47
47
  *
48
48
  * @public
49
49
  */
50
- type YamlStringifyErrorCode = typeof YamlStringifyErrorCode.Type;
50
+ export type YamlStringifyErrorCode = typeof YamlStringifyErrorCode.Type;
51
51
  /**
52
52
  * Error codes emitted by `YamlFormat.modify`'s path navigation against an
53
53
  * already-composed AST — not raised by the parser/composer/stringifier.
54
54
  *
55
55
  * @public
56
56
  */
57
- declare const YamlModifyErrorCode: Schema.Literals<readonly ["EmptyDocument", "PathNotFound", "InvalidIndex", "NotNavigable", "MultiDocumentStream", "DirectiveCarryingDocument"]>;
57
+ export declare const YamlModifyErrorCode: Schema.Literals<readonly ["EmptyDocument", "PathNotFound", "InvalidIndex", "NotNavigable", "MultiDocumentStream", "DirectiveCarryingDocument"]>;
58
58
  /**
59
59
  * The union of all modify-stage error code string literals.
60
60
  *
61
61
  * @public
62
62
  */
63
- type YamlModifyErrorCode = typeof YamlModifyErrorCode.Type;
63
+ export type YamlModifyErrorCode = typeof YamlModifyErrorCode.Type;
64
64
  /**
65
65
  * Union of all YAML error codes across all pipeline stages. Stage
66
66
  * discrimination lives here (in the code), not in separate error classes.
67
67
  *
68
68
  * @public
69
69
  */
70
- declare const YamlErrorCode: Schema.Union<readonly [Schema.Literals<readonly ["UnexpectedCharacter", "UnterminatedString", "InvalidEscapeSequence", "InvalidUnicode", "UnterminatedBlockScalar", "UnterminatedFlowCollection", "InvalidDirective", "InvalidTagHandle", "InvalidAnchorName", "UnexpectedByteOrderMark"]>, Schema.Literals<readonly ["InvalidIndentation", "DuplicateKey", "UnexpectedToken", "MissingValue", "MissingKey", "TabIndentation", "InvalidBlockStructure", "MalformedFlowCollection", "NestingDepthExceeded"]>, Schema.Literals<readonly ["UndefinedAlias", "DuplicateAnchor", "CircularAlias", "UnresolvedTag", "InvalidTagValue", "AliasCountExceeded", "InvalidDirective"]>, Schema.Literals<readonly ["CircularReference"]>, Schema.Literals<readonly ["EmptyDocument", "PathNotFound", "InvalidIndex", "NotNavigable", "MultiDocumentStream", "DirectiveCarryingDocument"]>]>;
70
+ export declare const YamlErrorCode: Schema.Union<readonly [Schema.Literals<readonly ["UnexpectedCharacter", "UnterminatedString", "InvalidEscapeSequence", "InvalidUnicode", "UnterminatedBlockScalar", "UnterminatedFlowCollection", "InvalidDirective", "InvalidTagHandle", "InvalidAnchorName", "UnexpectedByteOrderMark"]>, Schema.Literals<readonly ["InvalidIndentation", "DuplicateKey", "UnexpectedToken", "MissingValue", "MissingKey", "TabIndentation", "InvalidBlockStructure", "MalformedFlowCollection", "NestingDepthExceeded"]>, Schema.Literals<readonly ["UndefinedAlias", "DuplicateAnchor", "CircularAlias", "UnresolvedTag", "InvalidTagValue", "AliasCountExceeded", "InvalidDirective"]>, Schema.Literals<readonly ["CircularReference"]>, Schema.Literals<readonly ["EmptyDocument", "PathNotFound", "InvalidIndex", "NotNavigable", "MultiDocumentStream", "DirectiveCarryingDocument"]>]>;
71
71
  /**
72
72
  * The union of all YAML error code string literals.
73
73
  *
74
74
  * @public
75
75
  */
76
- type YamlErrorCode = typeof YamlErrorCode.Type;
76
+ export type YamlErrorCode = typeof YamlErrorCode.Type;
77
77
  declare const YamlDiagnostic_base: Schema.Class<YamlDiagnostic, Schema.Struct<{
78
78
  readonly code: Schema.Union<readonly [Schema.Literals<readonly ["UnexpectedCharacter", "UnterminatedString", "InvalidEscapeSequence", "InvalidUnicode", "UnterminatedBlockScalar", "UnterminatedFlowCollection", "InvalidDirective", "InvalidTagHandle", "InvalidAnchorName", "UnexpectedByteOrderMark"]>, Schema.Literals<readonly ["InvalidIndentation", "DuplicateKey", "UnexpectedToken", "MissingValue", "MissingKey", "TabIndentation", "InvalidBlockStructure", "MalformedFlowCollection", "NestingDepthExceeded"]>, Schema.Literals<readonly ["UndefinedAlias", "DuplicateAnchor", "CircularAlias", "UnresolvedTag", "InvalidTagValue", "AliasCountExceeded", "InvalidDirective"]>, Schema.Literals<readonly ["CircularReference"]>, Schema.Literals<readonly ["EmptyDocument", "PathNotFound", "InvalidIndex", "NotNavigable", "MultiDocumentStream", "DirectiveCarryingDocument"]>]>;
79
79
  readonly message: Schema.String;
@@ -95,7 +95,7 @@ declare const YamlDiagnostic_base: Schema.Class<YamlDiagnostic, Schema.Struct<{
95
95
  *
96
96
  * @public
97
97
  */
98
- declare class YamlDiagnostic extends YamlDiagnostic_base {
98
+ export declare class YamlDiagnostic extends YamlDiagnostic_base {
99
99
  /**
100
100
  * The single fatal-code predicate: whether diagnostics with this code
101
101
  * abort a parse (vs. being recoverable warnings-as-data). Declared once,
@@ -142,7 +142,7 @@ declare const YamlParseOptions_base: Schema.Class<YamlParseOptions, Schema.Struc
142
142
  *
143
143
  * @public
144
144
  */
145
- declare class YamlParseOptions extends YamlParseOptions_base {}
145
+ export declare class YamlParseOptions extends YamlParseOptions_base {}
146
146
  declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Schema.Struct<{
147
147
  readonly indent: Schema.optionalKey<Schema.Number>;
148
148
  /**
@@ -175,6 +175,33 @@ declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Sche
175
175
  * `"double-quoted"` is unaffected.
176
176
  */
177
177
  readonly quoteStyle: Schema.optionalKey<Schema.Literals<readonly ["single", "double"]>>;
178
+ /**
179
+ * Additionally quote plain scalars a foreign resolution dialect would
180
+ * coerce to a non-string. Absent (the default) adds no quoting beyond the
181
+ * YAML 1.2 Core Schema rules — byte-identical to the released output.
182
+ *
183
+ * `"yaml-1.1"` quotes every plain scalar a YAML 1.1 parser (js-yaml,
184
+ * PyYAML, libyaml, and the `yaml` npm package's YAML 1.1 schema, whose
185
+ * lenient resolvers set the outer bound) would implicitly resolve to a
186
+ * non-string: the extended
187
+ * boolean spellings (`y`/`yes`/`on`/`off` and case variants — the "Norway
188
+ * problem"), timestamps (`2024-01-15`, `2001-12-15T02:59:43.1Z`, the
189
+ * space-separated 1.1 forms), sexagesimal numbers (`1:30`,
190
+ * `190:20:30.15`), underscore-separated numbers (`1_000`) and the
191
+ * base-2/8/16 integer forms (`0b1010_0111`, `0777`, `0x_FF`). Use it when
192
+ * emitted output is parsed downstream by a YAML 1.1 consumer and blanket
193
+ * `defaultScalarStyle` quoting is too noisy.
194
+ *
195
+ * Strictly additive: it never un-quotes anything the 1.2 rules require
196
+ * quoted, strings no 1.1 parser coerces stay plain, and the quote
197
+ * character stays governed by `quoteStyle`. Scalars carrying an explicit
198
+ * tag are exempt, exactly like the 1.2 type-conflict check. Applies
199
+ * wherever the plain fallback renders — values, mapping keys, flow items —
200
+ * on both the value path ({@link Yaml.stringify},
201
+ * {@link Yaml.stringifyResult}) and the node path (`YamlDocument#stringify`
202
+ * and the `YamlFormat` helpers).
203
+ */
204
+ readonly quoteCompat: Schema.optionalKey<Schema.Literals<readonly ["yaml-1.1"]>>;
178
205
  readonly finalNewline: Schema.optionalKey<Schema.Boolean>;
179
206
  readonly forceDefaultStyles: Schema.optionalKey<Schema.Boolean>;
180
207
  }>, {}>;
@@ -182,8 +209,9 @@ declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Sche
182
209
  * Options controlling stringify behavior. All fields are omissible; absent
183
210
  * fields resolve to `indent` `2`, `lineWidth` `0`, `defaultScalarStyle`
184
211
  * `"plain"`, `defaultCollectionStyle` `"block"`, `sortKeys` `false`,
185
- * `indentSequences` `false`, `quoteStyle` `"single"`, `finalNewline` `true`
186
- * and `forceDefaultStyles` `false`.
212
+ * `indentSequences` `false`, `quoteStyle` `"single"`, `quoteCompat` absent
213
+ * (no dialect-compat quoting), `finalNewline` `true` and `forceDefaultStyles`
214
+ * `false`.
187
215
  *
188
216
  * `lineWidth` controls column-based scalar folding. The default `0` (and any
189
217
  * value `<= 0`) never wraps, emitting byte-identical output to the historic
@@ -229,7 +257,7 @@ declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Sche
229
257
  *
230
258
  * @public
231
259
  */
232
- declare class YamlStringifyOptions extends YamlStringifyOptions_base {}
260
+ export declare class YamlStringifyOptions extends YamlStringifyOptions_base {}
233
261
  declare const YamlParseError_base: Schema.Class<YamlParseError, Schema.TaggedStruct<"YamlParseError", {
234
262
  readonly diagnostics: Schema.$Array<typeof YamlDiagnostic>;
235
263
  readonly input: Schema.String;
@@ -244,7 +272,7 @@ declare const YamlParseError_base: Schema.Class<YamlParseError, Schema.TaggedStr
244
272
  *
245
273
  * @public
246
274
  */
247
- declare class YamlParseError extends YamlParseError_base {
275
+ export declare class YamlParseError extends YamlParseError_base {
248
276
  get message(): string;
249
277
  }
250
278
  declare const YamlStringifyError_base: Schema.Class<YamlStringifyError, Schema.TaggedStruct<"YamlStringifyError", {
@@ -260,7 +288,7 @@ declare const YamlStringifyError_base: Schema.Class<YamlStringifyError, Schema.T
260
288
  *
261
289
  * @public
262
290
  */
263
- declare class YamlStringifyError extends YamlStringifyError_base {
291
+ export declare class YamlStringifyError extends YamlStringifyError_base {
264
292
  get message(): string;
265
293
  }
266
294
  /**
@@ -303,7 +331,7 @@ interface YamlBoundCodec<T, RD = never, RE = never> {
303
331
  *
304
332
  * @public
305
333
  */
306
- declare class Yaml {
334
+ export declare class Yaml {
307
335
  private constructor();
308
336
  /**
309
337
  * Parse a single YAML document into a plain JavaScript value, resolving
@@ -573,7 +601,7 @@ declare const YamlRange_base: Schema.Class<YamlRange, Schema.Struct<{
573
601
  *
574
602
  * @public
575
603
  */
576
- declare class YamlRange extends YamlRange_base {}
604
+ export declare class YamlRange extends YamlRange_base {}
577
605
  declare const YamlEdit_base: Schema.Class<YamlEdit, Schema.Struct<{
578
606
  readonly offset: Schema.Number;
579
607
  readonly length: Schema.Number;
@@ -590,7 +618,7 @@ declare const YamlEdit_base: Schema.Class<YamlEdit, Schema.Struct<{
590
618
  *
591
619
  * @public
592
620
  */
593
- declare class YamlEdit extends YamlEdit_base {
621
+ export declare class YamlEdit extends YamlEdit_base {
594
622
  /**
595
623
  * Apply `edits` to `text`, producing a new string. Edits are applied in
596
624
  * reverse-offset order so earlier offsets stay valid; the input `edits`
@@ -606,25 +634,25 @@ declare class YamlEdit extends YamlEdit_base {
606
634
  *
607
635
  * @public
608
636
  */
609
- declare const ScalarStyle: Schema.Literals<readonly ["plain", "single-quoted", "double-quoted", "block-literal", "block-folded"]>;
637
+ export declare const ScalarStyle: Schema.Literals<readonly ["plain", "single-quoted", "double-quoted", "block-literal", "block-folded"]>;
610
638
  /**
611
639
  * The union of all scalar style string literals.
612
640
  *
613
641
  * @public
614
642
  */
615
- type ScalarStyle = typeof ScalarStyle.Type;
643
+ export type ScalarStyle = typeof ScalarStyle.Type;
616
644
  /**
617
645
  * YAML collection presentation styles.
618
646
  *
619
647
  * @public
620
648
  */
621
- declare const CollectionStyle: Schema.Literals<readonly ["block", "flow"]>;
649
+ export declare const CollectionStyle: Schema.Literals<readonly ["block", "flow"]>;
622
650
  /**
623
651
  * The union of all collection style string literals.
624
652
  *
625
653
  * @public
626
654
  */
627
- type CollectionStyle = typeof CollectionStyle.Type;
655
+ export type CollectionStyle = typeof CollectionStyle.Type;
628
656
  /**
629
657
  * Quote characters available to the stringifier's plain-scalar fallback: the
630
658
  * style a `plain`-styled scalar is rendered in when it turns out to require
@@ -634,26 +662,47 @@ type CollectionStyle = typeof CollectionStyle.Type;
634
662
  *
635
663
  * @public
636
664
  */
637
- declare const QuoteStyle: Schema.Literals<readonly ["single", "double"]>;
665
+ export declare const QuoteStyle: Schema.Literals<readonly ["single", "double"]>;
638
666
  /**
639
667
  * The union of all fallback quote style string literals.
640
668
  *
641
669
  * @public
642
670
  */
643
- type QuoteStyle = typeof QuoteStyle.Type;
671
+ export type QuoteStyle = typeof QuoteStyle.Type;
672
+ /**
673
+ * Foreign resolution dialects the stringifier's plain-scalar fallback can
674
+ * defend against: setting the `quoteCompat` field of `YamlStringifyOptions`
675
+ * to `"yaml-1.1"` additionally quotes every plain scalar a YAML 1.1 parser
676
+ * (js-yaml, PyYAML, libyaml, and the `yaml` npm package's YAML 1.1 schema,
677
+ * whose lenient resolvers set the outer bound) would implicitly resolve to a
678
+ * non-string —
679
+ * `yes`/`no`/`on`/`off` booleans, ISO 8601 and space-separated timestamps,
680
+ * sexagesimal `1:30`, underscored `1_000` and base-2/8/16 numbers. Like
681
+ * `QuoteStyle` it is a stringify-option vocabulary, never a property of a
682
+ * composed node.
683
+ *
684
+ * @public
685
+ */
686
+ export declare const QuoteCompat: Schema.Literals<readonly ["yaml-1.1"]>;
687
+ /**
688
+ * The union of all quote-compat dialect string literals.
689
+ *
690
+ * @public
691
+ */
692
+ export type QuoteCompat = typeof QuoteCompat.Type;
644
693
  /**
645
694
  * Block-scalar chomping indicators (`-` strip, default clip, `+` keep).
646
695
  * Referenced by the {@link YamlScalar} `chomp` field schema.
647
696
  *
648
697
  * @public
649
698
  */
650
- declare const ScalarChomp: Schema.Literals<readonly ["strip", "clip", "keep"]>;
699
+ export declare const ScalarChomp: Schema.Literals<readonly ["strip", "clip", "keep"]>;
651
700
  /**
652
701
  * The union of all block-scalar chomping indicator string literals.
653
702
  *
654
703
  * @public
655
704
  */
656
- type ScalarChomp = typeof ScalarChomp.Type;
705
+ export type ScalarChomp = typeof ScalarChomp.Type;
657
706
  declare const YamlScalar_base: Schema.Class<YamlScalar, Schema.TaggedStruct<"YamlScalar", {
658
707
  readonly value: Schema.Unknown;
659
708
  readonly tag: Schema.optionalKey<Schema.String>;
@@ -697,7 +746,7 @@ declare const YamlScalar_base: Schema.Class<YamlScalar, Schema.TaggedStruct<"Yam
697
746
  *
698
747
  * @public
699
748
  */
700
- declare class YamlScalar extends YamlScalar_base {
749
+ export declare class YamlScalar extends YamlScalar_base {
701
750
  /**
702
751
  * Navigate to a descendant by path (string segments for mapping keys,
703
752
  * numbers for sequence indices). `Option.none()` when any segment cannot
@@ -741,7 +790,7 @@ declare const YamlAlias_base: Schema.Class<YamlAlias, Schema.TaggedStruct<"YamlA
741
790
  *
742
791
  * @public
743
792
  */
744
- declare class YamlAlias extends YamlAlias_base {
793
+ export declare class YamlAlias extends YamlAlias_base {
745
794
  /** See `YamlScalar.find`. Pure. */
746
795
  find(path: YamlPath): Option.Option<YamlNode>;
747
796
  /** See `YamlScalar.findAtOffset`. Pure. */
@@ -794,13 +843,13 @@ interface YamlAliasEncoded extends Schema.Codec.Encoded<typeof YamlAlias> {}
794
843
  *
795
844
  * @public
796
845
  */
797
- declare const YamlNode: Schema.Codec<YamlScalar | YamlMap | YamlSeq | YamlAlias, YamlScalarEncoded | YamlMapEncoded | YamlSeqEncoded | YamlAliasEncoded>;
846
+ export declare const YamlNode: Schema.Codec<YamlScalar | YamlMap | YamlSeq | YamlAlias, YamlScalarEncoded | YamlMapEncoded | YamlSeqEncoded | YamlAliasEncoded>;
798
847
  /**
799
848
  * The union of all YAML AST value node types.
800
849
  *
801
850
  * @public
802
851
  */
803
- type YamlNode = YamlScalar | YamlMap | YamlSeq | YamlAlias;
852
+ export type YamlNode = YamlScalar | YamlMap | YamlSeq | YamlAlias;
804
853
  declare const YamlPair_base: Schema.Class<YamlPair, Schema.TaggedStruct<"YamlPair", {
805
854
  readonly key: Schema.suspend<Schema.Codec<YamlAlias | YamlMap | YamlScalar | YamlSeq, YamlAliasEncoded | YamlMapEncoded | YamlScalarEncoded | YamlSeqEncoded, never, never>>;
806
855
  readonly value: Schema.NullOr<Schema.suspend<Schema.Codec<YamlAlias | YamlMap | YamlScalar | YamlSeq, YamlAliasEncoded | YamlMapEncoded | YamlScalarEncoded | YamlSeqEncoded, never, never>>>;
@@ -818,7 +867,7 @@ declare const YamlPair_base: Schema.Class<YamlPair, Schema.TaggedStruct<"YamlPai
818
867
  *
819
868
  * @public
820
869
  */
821
- declare class YamlPair extends YamlPair_base {}
870
+ export declare class YamlPair extends YamlPair_base {}
822
871
  declare const YamlMap_base: Schema.Class<YamlMap, Schema.TaggedStruct<"YamlMap", {
823
872
  readonly items: Schema.$Array<Schema.suspend<typeof YamlPair>>;
824
873
  readonly tag: Schema.optionalKey<Schema.String>;
@@ -846,7 +895,7 @@ declare const YamlMap_base: Schema.Class<YamlMap, Schema.TaggedStruct<"YamlMap",
846
895
  *
847
896
  * @public
848
897
  */
849
- declare class YamlMap extends YamlMap_base {
898
+ export declare class YamlMap extends YamlMap_base {
850
899
  /** See `YamlScalar.find`. Pure. */
851
900
  find(path: YamlPath): Option.Option<YamlNode>;
852
901
  /** See `YamlScalar.findAtOffset`. Pure. */
@@ -880,7 +929,7 @@ declare const YamlSeq_base: Schema.Class<YamlSeq, Schema.TaggedStruct<"YamlSeq",
880
929
  *
881
930
  * @public
882
931
  */
883
- declare class YamlSeq extends YamlSeq_base {
932
+ export declare class YamlSeq extends YamlSeq_base {
884
933
  /** See `YamlScalar.find`. Pure. */
885
934
  find(path: YamlPath): Option.Option<YamlNode>;
886
935
  /** See `YamlScalar.findAtOffset`. Pure. */
@@ -904,7 +953,7 @@ declare const YamlDirective_base: Schema.Class<YamlDirective, Schema.Struct<{
904
953
  *
905
954
  * @public
906
955
  */
907
- declare class YamlDirective extends YamlDirective_base {}
956
+ export declare class YamlDirective extends YamlDirective_base {}
908
957
  declare const YamlDocument_base: Schema.Class<YamlDocument, Schema.Struct<{
909
958
  readonly contents: Schema.NullOr<Schema.suspend<Schema.Schema<YamlNode>>>;
910
959
  readonly errors: Schema.$Array<typeof YamlDiagnostic>;
@@ -933,7 +982,7 @@ declare const YamlDocument_base: Schema.Class<YamlDocument, Schema.Struct<{
933
982
  *
934
983
  * @public
935
984
  */
936
- declare class YamlDocument extends YamlDocument_base {
985
+ export declare class YamlDocument extends YamlDocument_base {
937
986
  /**
938
987
  * Parse a single YAML document, keeping the full AST, directives and
939
988
  * recovered diagnostics. Fails with the aggregate {@link YamlParseError}
@@ -1005,6 +1054,7 @@ declare const YamlFormattingOptions_base: Schema.Class<YamlFormattingOptions, Sc
1005
1054
  readonly sortKeys: Schema.optionalKey<Schema.Boolean>;
1006
1055
  readonly indentSequences: Schema.optionalKey<Schema.Boolean>;
1007
1056
  readonly quoteStyle: Schema.optionalKey<Schema.Literals<readonly ["single", "double"]>>;
1057
+ readonly quoteCompat: Schema.optionalKey<Schema.Literals<readonly ["yaml-1.1"]>>;
1008
1058
  readonly finalNewline: Schema.optionalKey<Schema.Boolean>;
1009
1059
  readonly forceDefaultStyles: Schema.optionalKey<Schema.Boolean>;
1010
1060
  readonly preserveComments: Schema.optionalKey<Schema.Boolean>;
@@ -1013,8 +1063,8 @@ declare const YamlFormattingOptions_base: Schema.Class<YamlFormattingOptions, Sc
1013
1063
  }>, {}>;
1014
1064
  /**
1015
1065
  * Options controlling formatting behavior: every {@link YamlStringifyOptions}
1016
- * field (derived, not hand-duplicated — including `indentSequences` and
1017
- * `quoteStyle`) plus
1066
+ * field (derived, not hand-duplicated — including `indentSequences`,
1067
+ * `quoteStyle` and `quoteCompat`) plus
1018
1068
  * `preserveComments` (default `true`), `range` (restrict edits to a
1019
1069
  * region; see the module-level remarks on the `range` parameter vs. this
1020
1070
  * field) and `requoteScalars` (default `false`).
@@ -1052,7 +1102,7 @@ declare const YamlFormattingOptions_base: Schema.Class<YamlFormattingOptions, Sc
1052
1102
  *
1053
1103
  * @public
1054
1104
  */
1055
- declare class YamlFormattingOptions extends YamlFormattingOptions_base {}
1105
+ export declare class YamlFormattingOptions extends YamlFormattingOptions_base {}
1056
1106
  declare const YamlModificationError_base: Schema.Class<YamlModificationError, Schema.TaggedStruct<"YamlModificationError", {
1057
1107
  readonly path: Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>;
1058
1108
  readonly diagnostics: Schema.$Array<typeof YamlDiagnostic>;
@@ -1072,7 +1122,7 @@ declare const YamlModificationError_base: Schema.Class<YamlModificationError, Sc
1072
1122
  *
1073
1123
  * @public
1074
1124
  */
1075
- declare class YamlModificationError extends YamlModificationError_base {
1125
+ export declare class YamlModificationError extends YamlModificationError_base {
1076
1126
  get message(): string;
1077
1127
  }
1078
1128
  /**
@@ -1107,7 +1157,7 @@ declare class YamlModificationError extends YamlModificationError_base {
1107
1157
  *
1108
1158
  * @public
1109
1159
  */
1110
- declare class YamlFormat {
1160
+ export declare class YamlFormat {
1111
1161
  private constructor();
1112
1162
  /**
1113
1163
  * Compute formatting edits for a YAML document. Non-mutating — apply the
@@ -1214,13 +1264,13 @@ declare class YamlFormat {
1214
1264
  *
1215
1265
  * @public
1216
1266
  */
1217
- declare const YamlTokenKind: Schema.Literals<readonly ["document-start", "document-end", "directive", "tag", "anchor", "alias", "scalar", "block-map-start", "block-map-key", "block-map-value", "block-seq-start", "block-seq-entry", "flow-map-start", "flow-map-end", "flow-seq-start", "flow-seq-end", "flow-separator", "newline", "whitespace", "comment", "byte-order-mark", "error"]>;
1267
+ export declare const YamlTokenKind: Schema.Literals<readonly ["document-start", "document-end", "directive", "tag", "anchor", "alias", "scalar", "block-map-start", "block-map-key", "block-map-value", "block-seq-start", "block-seq-entry", "flow-map-start", "flow-map-end", "flow-seq-start", "flow-seq-end", "flow-separator", "newline", "whitespace", "comment", "byte-order-mark", "error"]>;
1218
1268
  /**
1219
1269
  * The union of all lexical token kind string literals.
1220
1270
  *
1221
1271
  * @public
1222
1272
  */
1223
- type YamlTokenKind = typeof YamlTokenKind.Type;
1273
+ export type YamlTokenKind = typeof YamlTokenKind.Type;
1224
1274
  declare const YamlToken_base: Schema.Class<YamlToken, Schema.Struct<{
1225
1275
  readonly kind: Schema.Literals<readonly ["document-start", "document-end", "directive", "tag", "anchor", "alias", "scalar", "block-map-start", "block-map-key", "block-map-value", "block-seq-start", "block-seq-entry", "flow-map-start", "flow-map-end", "flow-seq-start", "flow-seq-end", "flow-separator", "newline", "whitespace", "comment", "byte-order-mark", "error"]>;
1226
1276
  readonly text: Schema.String;
@@ -1241,13 +1291,13 @@ declare const YamlToken_base: Schema.Class<YamlToken, Schema.Struct<{
1241
1291
  *
1242
1292
  * @public
1243
1293
  */
1244
- declare class YamlToken extends YamlToken_base {}
1294
+ export declare class YamlToken extends YamlToken_base {}
1245
1295
  /**
1246
1296
  * Tokenizer statics. Not instantiable.
1247
1297
  *
1248
1298
  * @public
1249
1299
  */
1250
- declare class YamlTokens {
1300
+ export declare class YamlTokens {
1251
1301
  private constructor();
1252
1302
  /**
1253
1303
  * Tokenize YAML text into the full positioned token array — the sync
@@ -1296,13 +1346,13 @@ declare class YamlTokens {
1296
1346
  *
1297
1347
  * @public
1298
1348
  */
1299
- declare const YamlLintSeverity: Schema.Literals<readonly ["error", "warning"]>;
1349
+ export declare const YamlLintSeverity: Schema.Literals<readonly ["error", "warning"]>;
1300
1350
  /**
1301
1351
  * The union of lint severity string literals.
1302
1352
  *
1303
1353
  * @public
1304
1354
  */
1305
- type YamlLintSeverity = typeof YamlLintSeverity.Type;
1355
+ export type YamlLintSeverity = typeof YamlLintSeverity.Type;
1306
1356
  declare const YamlLintDiagnostic_base: Schema.Class<YamlLintDiagnostic, Schema.Struct<{
1307
1357
  readonly rule: Schema.String;
1308
1358
  readonly severity: Schema.Literals<readonly ["error", "warning"]>;
@@ -1325,7 +1375,7 @@ declare const YamlLintDiagnostic_base: Schema.Class<YamlLintDiagnostic, Schema.S
1325
1375
  *
1326
1376
  * @public
1327
1377
  */
1328
- declare class YamlLintDiagnostic extends YamlLintDiagnostic_base {}
1378
+ export declare class YamlLintDiagnostic extends YamlLintDiagnostic_base {}
1329
1379
  /**
1330
1380
  * One source line of the linted document: its text (without the line
1331
1381
  * terminator — the `\n`, and for CRLF input the `\r\n` pair), the offset of
@@ -1388,7 +1438,7 @@ declare const StyleVote_base: Schema.Class<StyleVote, Schema.TaggedStruct<"Style
1388
1438
  *
1389
1439
  * @public
1390
1440
  */
1391
- declare class StyleVote extends StyleVote_base {}
1441
+ export declare class StyleVote extends StyleVote_base {}
1392
1442
  declare const StyleFloor_base: Schema.Class<StyleFloor, Schema.TaggedStruct<"StyleFloor", {
1393
1443
  readonly dimension: Schema.String;
1394
1444
  readonly value: Schema.Number;
@@ -1406,7 +1456,7 @@ declare const StyleFloor_base: Schema.Class<StyleFloor, Schema.TaggedStruct<"Sty
1406
1456
  *
1407
1457
  * @public
1408
1458
  */
1409
- declare class StyleFloor extends StyleFloor_base {}
1459
+ export declare class StyleFloor extends StyleFloor_base {}
1410
1460
  /**
1411
1461
  * What a rule's `infer` hook yields per occurrence: a categorical
1412
1462
  * {@link StyleVote} or a measured {@link StyleFloor}.
@@ -1447,13 +1497,13 @@ interface YamlRule {
1447
1497
  *
1448
1498
  * @public
1449
1499
  */
1450
- declare const YamlLintRuleSetting: Schema.Union<readonly [Schema.Literals<readonly ["error", "warning", "off"]>, Schema.$Record<Schema.String, Schema.Unknown>]>;
1500
+ export declare const YamlLintRuleSetting: Schema.Union<readonly [Schema.Literals<readonly ["error", "warning", "off"]>, Schema.$Record<Schema.String, Schema.Unknown>]>;
1451
1501
  /**
1452
1502
  * The union type of one `rules`-map entry.
1453
1503
  *
1454
1504
  * @public
1455
1505
  */
1456
- type YamlLintRuleSetting = typeof YamlLintRuleSetting.Type;
1506
+ export type YamlLintRuleSetting = typeof YamlLintRuleSetting.Type;
1457
1507
  declare const YamlLintConfig_base: Schema.Class<YamlLintConfig, Schema.Struct<{
1458
1508
  readonly rules: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Literals<readonly ["error", "warning", "off"]>, Schema.$Record<Schema.String, Schema.Unknown>]>>;
1459
1509
  }>, {}>;
@@ -1474,7 +1524,7 @@ declare const YamlLintConfig_base: Schema.Class<YamlLintConfig, Schema.Struct<{
1474
1524
  *
1475
1525
  * @public
1476
1526
  */
1477
- declare class YamlLintConfig extends YamlLintConfig_base {
1527
+ export declare class YamlLintConfig extends YamlLintConfig_base {
1478
1528
  /**
1479
1529
  * The default preset. Rule entries accrete as built-ins land; the
1480
1530
  * `quoted-strings` rule defaults to DOUBLE quotes here (the one taste
@@ -1502,7 +1552,7 @@ declare const StyleVoteTally_base: Schema.Class<StyleVoteTally, Schema.Struct<{
1502
1552
  *
1503
1553
  * @public
1504
1554
  */
1505
- declare class StyleVoteTally extends StyleVoteTally_base {}
1555
+ export declare class StyleVoteTally extends StyleVoteTally_base {}
1506
1556
  declare const StyleFloorTally_base: Schema.Class<StyleFloorTally, Schema.Struct<{
1507
1557
  readonly rule: Schema.String;
1508
1558
  readonly dimension: Schema.String;
@@ -1516,7 +1566,7 @@ declare const StyleFloorTally_base: Schema.Class<StyleFloorTally, Schema.Struct<
1516
1566
  *
1517
1567
  * @public
1518
1568
  */
1519
- declare class StyleFloorTally extends StyleFloorTally_base {}
1569
+ export declare class StyleFloorTally extends StyleFloorTally_base {}
1520
1570
  declare const StyleEvidence_base: Schema.Class<StyleEvidence, Schema.Struct<{
1521
1571
  readonly votes: Schema.$Array<typeof StyleVoteTally>;
1522
1572
  readonly floors: Schema.$Array<typeof StyleFloorTally>;
@@ -1537,7 +1587,7 @@ declare const StyleEvidence_base: Schema.Class<StyleEvidence, Schema.Struct<{
1537
1587
  *
1538
1588
  * @public
1539
1589
  */
1540
- declare class StyleEvidence extends StyleEvidence_base {
1590
+ export declare class StyleEvidence extends StyleEvidence_base {
1541
1591
  /** The monoid identity: no observations. */
1542
1592
  static readonly empty: StyleEvidence;
1543
1593
  /**
@@ -1568,7 +1618,7 @@ declare const StyleConflict_base: Schema.Class<StyleConflict, Schema.Struct<{
1568
1618
  *
1569
1619
  * @public
1570
1620
  */
1571
- declare class StyleConflict extends StyleConflict_base {}
1621
+ export declare class StyleConflict extends StyleConflict_base {}
1572
1622
  declare const YamlStyleConflictError_base: Schema.Class<YamlStyleConflictError, Schema.TaggedStruct<"YamlStyleConflictError", {
1573
1623
  readonly conflicts: Schema.$Array<typeof StyleConflict>;
1574
1624
  }>, import("effect/Cause").YieldableError>;
@@ -1582,7 +1632,7 @@ declare const YamlStyleConflictError_base: Schema.Class<YamlStyleConflictError,
1582
1632
  *
1583
1633
  * @public
1584
1634
  */
1585
- declare class YamlStyleConflictError extends YamlStyleConflictError_base {
1635
+ export declare class YamlStyleConflictError extends YamlStyleConflictError_base {
1586
1636
  get message(): string;
1587
1637
  }
1588
1638
  /**
@@ -1606,7 +1656,7 @@ interface YamlLintInference {
1606
1656
  *
1607
1657
  * @public
1608
1658
  */
1609
- declare class YamlLint {
1659
+ export declare class YamlLint {
1610
1660
  private constructor();
1611
1661
  /**
1612
1662
  * The built-in rule catalog. Custom usage is array concatenation:
@@ -1702,7 +1752,7 @@ declare class YamlLint {
1702
1752
  *
1703
1753
  * @public
1704
1754
  */
1705
- type YamlVisitorEvent = Data.TaggedEnum<{
1755
+ export type YamlVisitorEvent = Data.TaggedEnum<{
1706
1756
  DocumentStart: {
1707
1757
  readonly path: YamlPath;
1708
1758
  readonly depth: number;
@@ -1782,7 +1832,7 @@ type YamlVisitorEvent = Data.TaggedEnum<{
1782
1832
  *
1783
1833
  * @public
1784
1834
  */
1785
- declare const YamlVisitorEvent: {
1835
+ export declare const YamlVisitorEvent: {
1786
1836
  readonly $is: <Tag extends "Alias" | "Comment" | "Directive" | "DocumentEnd" | "DocumentStart" | "Error" | "MapEnd" | "MapStart" | "Pair" | "Scalar" | "SeqEnd" | "SeqStart">(tag: Tag) => (u: unknown) => u is Extract<{
1787
1837
  readonly _tag: "Alias";
1788
1838
  readonly path: YamlPath;
@@ -2276,7 +2326,7 @@ declare const YamlVisitorEvent: {
2276
2326
  *
2277
2327
  * @public
2278
2328
  */
2279
- declare class YamlVisitor {
2329
+ export declare class YamlVisitor {
2280
2330
  private constructor();
2281
2331
  /**
2282
2332
  * Create a lazy `Stream` of `YamlVisitorEvent` from YAML text, in document
@@ -2294,5 +2344,5 @@ declare class YamlVisitor {
2294
2344
  static visit(text: string, options?: YamlParseOptions): Stream.Stream<YamlVisitorEvent>;
2295
2345
  }
2296
2346
  //#endregion
2297
- export { CollectionStyle, type LintContext, type LintLine, QuoteStyle, ScalarChomp, ScalarStyle, StyleConflict, StyleEvidence, StyleFloor, StyleFloorTally, type StyleObservation, StyleVote, StyleVoteTally, Yaml, YamlAlias, type YamlAliasEncoded, type YamlBoundCodec, YamlComposerErrorCode, YamlDiagnostic, YamlDirective, YamlDocument, YamlEdit, YamlErrorCode, YamlFormat, YamlFormattingOptions, YamlLexErrorCode, YamlLint, YamlLintConfig, YamlLintDiagnostic, type YamlLintInference, YamlLintRuleSetting, YamlLintSeverity, YamlMap, type YamlMapEncoded, YamlModificationError, YamlModifyErrorCode, YamlNode, YamlPair, YamlParseError, YamlParseErrorCode, YamlParseOptions, type YamlPath, YamlRange, type YamlRangeLike, type YamlRule, YamlScalar, type YamlScalarEncoded, type YamlSegment, YamlSeq, type YamlSeqEncoded, YamlStringifyError, YamlStringifyErrorCode, YamlStringifyOptions, YamlStyleConflictError, YamlToken, YamlTokenKind, YamlTokens, YamlVisitor, YamlVisitorEvent };
2347
+ export type { LintContext, LintLine, StyleObservation, YamlAliasEncoded, YamlBoundCodec, YamlLintInference, YamlMapEncoded, YamlPath, YamlRangeLike, YamlRule, YamlScalarEncoded, YamlSegment, YamlSeqEncoded };
2298
2348
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CollectionStyle, QuoteStyle, ScalarChomp, ScalarStyle, YamlAlias, YamlMap, YamlNode, YamlPair, YamlScalar, YamlSeq } from "./YamlNode.js";
1
+ import { CollectionStyle, QuoteCompat, QuoteStyle, ScalarChomp, ScalarStyle, YamlAlias, YamlMap, YamlNode, YamlPair, YamlScalar, YamlSeq } from "./YamlNode.js";
2
2
  import { YamlComposerErrorCode, YamlDiagnostic, YamlErrorCode, YamlLexErrorCode, YamlModifyErrorCode, YamlParseErrorCode, YamlStringifyErrorCode } from "./YamlDiagnostic.js";
3
3
  import { Yaml, YamlParseError, YamlParseOptions, YamlStringifyError, YamlStringifyOptions } from "./Yaml.js";
4
4
  import { YamlDirective, YamlDocument } from "./YamlDocument.js";
@@ -9,4 +9,4 @@ import { YamlToken, YamlTokenKind, YamlTokens } from "./YamlToken.js";
9
9
  import { StyleConflict, StyleEvidence, StyleFloorTally, StyleVoteTally, YamlLint, YamlLintConfig, YamlLintRuleSetting, YamlStyleConflictError } from "./YamlLint.js";
10
10
  import { YamlVisitor, YamlVisitorEvent } from "./YamlVisitor.js";
11
11
 
12
- export { CollectionStyle, QuoteStyle, ScalarChomp, ScalarStyle, StyleConflict, StyleEvidence, StyleFloor, StyleFloorTally, StyleVote, StyleVoteTally, Yaml, YamlAlias, YamlComposerErrorCode, YamlDiagnostic, YamlDirective, YamlDocument, YamlEdit, YamlErrorCode, YamlFormat, YamlFormattingOptions, YamlLexErrorCode, YamlLint, YamlLintConfig, YamlLintDiagnostic, YamlLintRuleSetting, YamlLintSeverity, YamlMap, YamlModificationError, YamlModifyErrorCode, YamlNode, YamlPair, YamlParseError, YamlParseErrorCode, YamlParseOptions, YamlRange, YamlScalar, YamlSeq, YamlStringifyError, YamlStringifyErrorCode, YamlStringifyOptions, YamlStyleConflictError, YamlToken, YamlTokenKind, YamlTokens, YamlVisitor, YamlVisitorEvent };
12
+ export { CollectionStyle, QuoteCompat, QuoteStyle, ScalarChomp, ScalarStyle, StyleConflict, StyleEvidence, StyleFloor, StyleFloorTally, StyleVote, StyleVoteTally, Yaml, YamlAlias, YamlComposerErrorCode, YamlDiagnostic, YamlDirective, YamlDocument, YamlEdit, YamlErrorCode, YamlFormat, YamlFormattingOptions, YamlLexErrorCode, YamlLint, YamlLintConfig, YamlLintDiagnostic, YamlLintRuleSetting, YamlLintSeverity, YamlMap, YamlModificationError, YamlModifyErrorCode, YamlNode, YamlPair, YamlParseError, YamlParseErrorCode, YamlParseOptions, YamlRange, YamlScalar, YamlSeq, YamlStringifyError, YamlStringifyErrorCode, YamlStringifyOptions, YamlStyleConflictError, YamlToken, YamlTokenKind, YamlTokens, YamlVisitor, YamlVisitorEvent };
@@ -105,6 +105,23 @@ function wouldBeResolved(s) {
105
105
  if (FLOAT_RE.test(s)) return true;
106
106
  return false;
107
107
  }
108
+ const BOOL_11_RE = /^(?:y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF)$/;
109
+ const INT_11_RE = /^[-+]?(?:0b[0-1_]+|0o?[0-7_]+|[0-9][0-9_]*|0x[0-9a-fA-F_]+|[1-9][0-9_]*(?::[0-5]?[0-9])+)$/;
110
+ const FLOAT_11_RE = /^[-+]?(?:[0-9][0-9_]*(?:\.[0-9_]*(?:[eE][-+]?[0-9]+)?|[eE][-+]?[0-9]+)|\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/;
111
+ const TIMESTAMP_11_RE = /^[0-9][0-9][0-9][0-9]-[0-9][0-9]?-[0-9][0-9]?(?:(?:[Tt]|[ \t]+)[0-9][0-9]?:[0-9][0-9]:[0-9][0-9](?:\.[0-9]*)?(?:[ \t]*(?:Z|[-+][0-9][0-9]?(?::?[0-9][0-9])?))?)?$/;
112
+ /**
113
+ * Returns true if a string value would be resolved as a non-string type by a
114
+ * YAML 1.1 parser. The delta over {@link wouldBeResolved}: null spellings are
115
+ * identical in both editions (and already covered), so only the boolean,
116
+ * integer, float and timestamp families are tested here.
117
+ */
118
+ function wouldBeResolved11(s) {
119
+ if (BOOL_11_RE.test(s)) return true;
120
+ if (INT_11_RE.test(s)) return true;
121
+ if (FLOAT_11_RE.test(s)) return true;
122
+ if (TIMESTAMP_11_RE.test(s)) return true;
123
+ return false;
124
+ }
108
125
  /**
109
126
  * Returns true if a string requires quoting to be safely represented as a plain scalar.
110
127
  *
@@ -112,11 +129,16 @@ function wouldBeResolved(s) {
112
129
  * embedded newlines, leading indicator characters or whitespace, and inline
113
130
  * comment/mapping-value patterns (`: `, ` #`). This is the single gate that
114
131
  * decides whether a plain scalar is safe or must be wrapped in quotes.
132
+ *
133
+ * `quoteCompat` is strictly additive: `"yaml-1.1"` additionally quotes
134
+ * strings a YAML 1.1 parser would coerce ({@link wouldBeResolved11}) and can
135
+ * never un-quote anything the 1.2 rules require quoted.
115
136
  */
116
- function requiresQuoting(s, ignoreType = false) {
137
+ function requiresQuoting(s, ignoreType = false, quoteCompat) {
117
138
  if (s === "") return true;
118
139
  if (s.includes("\n")) return true;
119
140
  if (!ignoreType && wouldBeResolved(s)) return true;
141
+ if (!ignoreType && quoteCompat === "yaml-1.1" && wouldBeResolved11(s)) return true;
120
142
  const first = s[0];
121
143
  if (first === " " || first === " ") return true;
122
144
  if (first !== void 0 && INDICATOR_CHARS.has(first)) {
@@ -197,7 +219,7 @@ function renderSingleQuoted(s) {
197
219
  * Block literal and block folded styles are always accepted for single-line
198
220
  * strings even though the output is unusual.
199
221
  */
200
- function renderString(s, style, indent, ignoreType = false, canonical = false, explicitChomp, parentPosition, quoteStyle = "single", explicitIndent) {
222
+ function renderString(s, style, indent, ignoreType = false, canonical = false, explicitChomp, parentPosition, quoteStyle = "single", explicitIndent, quoteCompat) {
201
223
  const fidelity = !canonical;
202
224
  const fidelityIndent = fidelity ? explicitIndent : void 0;
203
225
  if (s.includes("\n")) {
@@ -230,7 +252,7 @@ function renderString(s, style, indent, ignoreType = false, canonical = false, e
230
252
  if (s === "" && (style === "block-literal" || style === "block-folded")) return renderDoubleQuoted(s, canonical);
231
253
  switch (style) {
232
254
  case "plain":
233
- if (requiresQuoting(s, ignoreType)) {
255
+ if (requiresQuoting(s, ignoreType, quoteCompat)) {
234
256
  if (s.includes(" ") || s.includes("\r")) return renderDoubleQuoted(s, canonical);
235
257
  for (let i = 0; i < s.length; i++) if (isControlChar(s.charCodeAt(i))) return renderDoubleQuoted(s, canonical);
236
258
  return quoteStyle === "double" ? renderDoubleQuoted(s, canonical) : renderSingleQuoted(s);
@@ -289,6 +311,7 @@ function createContext(options) {
289
311
  sortKeys: options?.sortKeys ?? false,
290
312
  indentSequences: options?.indentSequences ?? false,
291
313
  quoteStyle: options?.quoteStyle ?? "single",
314
+ quoteCompat: options?.quoteCompat,
292
315
  forceDefaultStyles: options?.forceDefaultStyles ?? false,
293
316
  seen: /* @__PURE__ */ new Set()
294
317
  };
@@ -308,7 +331,7 @@ function stringifyLines(value, ctx, depth, allowFold = true) {
308
331
  if (typeof value === "bigint") return [value.toString()];
309
332
  if (typeof value === "string") {
310
333
  const indentStr = " ".repeat(ctx.indent);
311
- const rendered = renderString(value, ctx.defaultScalarStyle, indentStr, false, ctx.forceDefaultStyles, void 0, void 0, ctx.quoteStyle);
334
+ const rendered = renderString(value, ctx.defaultScalarStyle, indentStr, false, ctx.forceDefaultStyles, void 0, void 0, ctx.quoteStyle, void 0, ctx.quoteCompat);
312
335
  return (allowFold && ctx.lineWidth > 0 ? foldRenderedScalar(rendered, indentStr, ctx.lineWidth) : rendered).split("\n");
313
336
  }
314
337
  if (Array.isArray(value)) {
@@ -373,7 +396,7 @@ function stringifyObjectLines(obj, ctx, depth) {
373
396
  const keys = Object.keys(obj);
374
397
  if (keys.length === 0) return ["{}"];
375
398
  if (ctx.sortKeys) keys.sort();
376
- const renderPlainKey = (k) => renderString(k, "plain", "", false, false, void 0, void 0, ctx.quoteStyle);
399
+ const renderPlainKey = (k) => renderString(k, "plain", "", false, false, void 0, void 0, ctx.quoteStyle, void 0, ctx.quoteCompat);
377
400
  if (ctx.defaultCollectionStyle === "flow") return [`{${keys.map((k) => {
378
401
  return `${renderPlainKey(k)}: ${stringifyLines(obj[k], ctx, depth + 1, false).join(" ")}`;
379
402
  }).join(", ")}}`];
@@ -584,7 +607,7 @@ function stringifyScalarNodeLines(node, ctx) {
584
607
  else lines = ["null"];
585
608
  } else if (typeof val === "boolean") lines = [val ? "true" : "false"];
586
609
  else if (typeof val === "number") lines = [node.raw !== void 0 ? node.raw : renderNumber(val)];
587
- else if (typeof val === "string") lines = renderString(val, style, " ".repeat(ctx.indent), !!node.tag, ctx.forceDefaultStyles, node.chomp, ctx.parentPosition, ctx.quoteStyle, node.blockIndent).split("\n");
610
+ else if (typeof val === "string") lines = renderString(val, style, " ".repeat(ctx.indent), !!node.tag, ctx.forceDefaultStyles, node.chomp, ctx.parentPosition, ctx.quoteStyle, node.blockIndent, ctx.quoteCompat).split("\n");
588
611
  else lines = [renderDoubleQuoted(String(val))];
589
612
  if (node.tag) lines[0] = `${node.tag} ${lines[0]}`;
590
613
  if (node.anchor) lines[0] = `&${node.anchor} ${lines[0]}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/yaml",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "private": false,
5
5
  "description": "Zero-dependency YAML parsing, editing, formatting and linting as Effect schemas.",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "peerDependencies": {
44
- "effect": "4.0.0-rc.109"
44
+ "effect": "4.0.0-rc.112"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24.11.0"