@effected/yaml 0.3.0 → 0.3.1
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/Yaml.js +16 -5
- package/YamlDocument.js +11 -0
- package/index.d.ts +25 -3
- package/package.json +1 -1
package/Yaml.js
CHANGED
|
@@ -44,7 +44,9 @@ var YamlParseOptions = class extends Schema.Class("YamlParseOptions")({
|
|
|
44
44
|
* no-fold behavior; a positive value folds long plain, double-quoted and
|
|
45
45
|
* block-folded (`>`) scalars at approximately that column, inserting only
|
|
46
46
|
* semantically transparent line breaks. Block-literal (`|`) content is never
|
|
47
|
-
* folded — literal blocks preserve their bytes by definition.
|
|
47
|
+
* folded — literal blocks preserve their bytes by definition. Folding is a
|
|
48
|
+
* value-path feature only: `YamlDocument#stringify` and the `YamlFormat`
|
|
49
|
+
* helpers accept these options but do not fold (see `lineWidth`).
|
|
48
50
|
*
|
|
49
51
|
* `indentSequences` controls the presentation of block sequences nested under
|
|
50
52
|
* a mapping key: `false` (the default) emits them at the key's column — the
|
|
@@ -75,6 +77,15 @@ var YamlStringifyOptions = class extends Schema.Class("YamlStringifyOptions")({
|
|
|
75
77
|
* Column at which to fold long scalars. Default `0` (and any value `<= 0`)
|
|
76
78
|
* never wraps; a positive value folds plain, double-quoted and block-folded
|
|
77
79
|
* (`>`) scalars at approximately that column, never block-literal (`|`).
|
|
80
|
+
*
|
|
81
|
+
* Takes effect only through {@link Yaml.stringify} and
|
|
82
|
+
* {@link Yaml.stringifySync} — the two entry points that accept these
|
|
83
|
+
* options on the value path. The schema factories ({@link Yaml.fromString},
|
|
84
|
+
* {@link Yaml.schema}, {@link Yaml.YamlFromString}) encode with default
|
|
85
|
+
* stringify options (`lineWidth` `0`), so their output never folds. The
|
|
86
|
+
* document/node path — `YamlDocument#stringify` and the `YamlFormat`
|
|
87
|
+
* helpers built on it — threads the field into its render context but
|
|
88
|
+
* never reads it, so it is inert there.
|
|
78
89
|
*/
|
|
79
90
|
lineWidth: Schema.optionalKey(Schema.Number),
|
|
80
91
|
defaultScalarStyle: Schema.optionalKey(ScalarStyle),
|
|
@@ -181,7 +192,7 @@ const stringifyDefectToError = (defect, value) => {
|
|
|
181
192
|
});
|
|
182
193
|
};
|
|
183
194
|
/**
|
|
184
|
-
* Synchronous single-document parse returning a
|
|
195
|
+
* Synchronous single-document parse returning a `Result`. The pure
|
|
185
196
|
* engine bypasses the Effect runtime entirely: the composer, the failure
|
|
186
197
|
* collection and the alias-expansion budget all run inline, and every failure
|
|
187
198
|
* mode (fatal diagnostics, duplicate keys, a "billion laughs" blow-up) yields
|
|
@@ -203,7 +214,7 @@ const parseSyncImpl = (text, options) => {
|
|
|
203
214
|
}
|
|
204
215
|
};
|
|
205
216
|
/**
|
|
206
|
-
* Synchronous stringify returning a
|
|
217
|
+
* Synchronous stringify returning a `Result`. Mirrors {@link Yaml.stringify}
|
|
207
218
|
* without the Effect wrapper: a circular reference or a value nested past the
|
|
208
219
|
* recursion budget yields a `Failure` carrying a typed {@link YamlStringifyError},
|
|
209
220
|
* never a thrown defect.
|
|
@@ -333,7 +344,7 @@ var Yaml = class Yaml {
|
|
|
333
344
|
return yield* stringifyOrFail(value, options);
|
|
334
345
|
});
|
|
335
346
|
/**
|
|
336
|
-
* Synchronous single-document parse, returning a
|
|
347
|
+
* Synchronous single-document parse, returning a `Result` instead of
|
|
337
348
|
* an `Effect`. A pure escape hatch for config-time callers that cannot
|
|
338
349
|
* `await` an Effect (a `vitest.config.ts` is the motivating case): it runs
|
|
339
350
|
* the same engine as {@link Yaml.parse} inline.
|
|
@@ -362,7 +373,7 @@ var Yaml = class Yaml {
|
|
|
362
373
|
return parseSyncImpl(text, options);
|
|
363
374
|
}
|
|
364
375
|
/**
|
|
365
|
-
* Synchronous stringify, returning a
|
|
376
|
+
* Synchronous stringify, returning a `Result` instead of an `Effect`.
|
|
366
377
|
* The pure counterpart to {@link Yaml.stringify} for config-time callers
|
|
367
378
|
* that cannot `await`.
|
|
368
379
|
*
|
package/YamlDocument.js
CHANGED
|
@@ -91,6 +91,17 @@ var YamlDocument = class YamlDocument extends Schema.Class("YamlDocument")({
|
|
|
91
91
|
* deeper than the stringifier's recursion budget (`NestingDepthExceeded`)
|
|
92
92
|
* — both surface through the typed error channel rather than as an
|
|
93
93
|
* unhandled stack-overflow defect.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* `YamlStringifyOptions.lineWidth` is not honored here: column-based
|
|
97
|
+
* scalar folding exists only on the value path, through the entry points
|
|
98
|
+
* that accept stringify options ({@link Yaml.stringify} and
|
|
99
|
+
* {@link Yaml.stringifySync}). The
|
|
100
|
+
* document/node path threads `lineWidth` into its render context but
|
|
101
|
+
* never reads it, so long scalars are emitted unfolded regardless of the
|
|
102
|
+
* option. Callers that need folding should render the plain value
|
|
103
|
+
* instead — `Yaml.stringify(doc.toValue(), options)` — at the cost of
|
|
104
|
+
* the document-level framing and styles this path preserves.
|
|
94
105
|
*/
|
|
95
106
|
stringify(options) {
|
|
96
107
|
return Effect.try({
|
package/index.d.ts
CHANGED
|
@@ -149,6 +149,15 @@ declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Sche
|
|
|
149
149
|
* Column at which to fold long scalars. Default `0` (and any value `<= 0`)
|
|
150
150
|
* never wraps; a positive value folds plain, double-quoted and block-folded
|
|
151
151
|
* (`>`) scalars at approximately that column, never block-literal (`|`).
|
|
152
|
+
*
|
|
153
|
+
* Takes effect only through {@link Yaml.stringify} and
|
|
154
|
+
* {@link Yaml.stringifySync} — the two entry points that accept these
|
|
155
|
+
* options on the value path. The schema factories ({@link Yaml.fromString},
|
|
156
|
+
* {@link Yaml.schema}, {@link Yaml.YamlFromString}) encode with default
|
|
157
|
+
* stringify options (`lineWidth` `0`), so their output never folds. The
|
|
158
|
+
* document/node path — `YamlDocument#stringify` and the `YamlFormat`
|
|
159
|
+
* helpers built on it — threads the field into its render context but
|
|
160
|
+
* never reads it, so it is inert there.
|
|
152
161
|
*/
|
|
153
162
|
readonly lineWidth: Schema.optionalKey<Schema.Number>;
|
|
154
163
|
readonly defaultScalarStyle: Schema.optionalKey<Schema.Literals<readonly ["plain", "single-quoted", "double-quoted", "block-literal", "block-folded"]>>;
|
|
@@ -170,7 +179,9 @@ declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Sche
|
|
|
170
179
|
* no-fold behavior; a positive value folds long plain, double-quoted and
|
|
171
180
|
* block-folded (`>`) scalars at approximately that column, inserting only
|
|
172
181
|
* semantically transparent line breaks. Block-literal (`|`) content is never
|
|
173
|
-
* folded — literal blocks preserve their bytes by definition.
|
|
182
|
+
* folded — literal blocks preserve their bytes by definition. Folding is a
|
|
183
|
+
* value-path feature only: `YamlDocument#stringify` and the `YamlFormat`
|
|
184
|
+
* helpers accept these options but do not fold (see `lineWidth`).
|
|
174
185
|
*
|
|
175
186
|
* `indentSequences` controls the presentation of block sequences nested under
|
|
176
187
|
* a mapping key: `false` (the default) emits them at the key's column — the
|
|
@@ -284,7 +295,7 @@ declare class Yaml {
|
|
|
284
295
|
*/
|
|
285
296
|
static readonly stringify: (value: unknown, options?: YamlStringifyOptions | undefined) => Effect.Effect<string, YamlStringifyError, never>;
|
|
286
297
|
/**
|
|
287
|
-
* Synchronous single-document parse, returning a
|
|
298
|
+
* Synchronous single-document parse, returning a `Result` instead of
|
|
288
299
|
* an `Effect`. A pure escape hatch for config-time callers that cannot
|
|
289
300
|
* `await` an Effect (a `vitest.config.ts` is the motivating case): it runs
|
|
290
301
|
* the same engine as {@link Yaml.parse} inline.
|
|
@@ -311,7 +322,7 @@ declare class Yaml {
|
|
|
311
322
|
*/
|
|
312
323
|
static parseSync(text: string, options?: YamlParseOptions): Result.Result<unknown, YamlParseError>;
|
|
313
324
|
/**
|
|
314
|
-
* Synchronous stringify, returning a
|
|
325
|
+
* Synchronous stringify, returning a `Result` instead of an `Effect`.
|
|
315
326
|
* The pure counterpart to {@link Yaml.stringify} for config-time callers
|
|
316
327
|
* that cannot `await`.
|
|
317
328
|
*
|
|
@@ -720,6 +731,17 @@ declare class YamlDocument extends YamlDocument_base {
|
|
|
720
731
|
* deeper than the stringifier's recursion budget (`NestingDepthExceeded`)
|
|
721
732
|
* — both surface through the typed error channel rather than as an
|
|
722
733
|
* unhandled stack-overflow defect.
|
|
734
|
+
*
|
|
735
|
+
* @remarks
|
|
736
|
+
* `YamlStringifyOptions.lineWidth` is not honored here: column-based
|
|
737
|
+
* scalar folding exists only on the value path, through the entry points
|
|
738
|
+
* that accept stringify options ({@link Yaml.stringify} and
|
|
739
|
+
* {@link Yaml.stringifySync}). The
|
|
740
|
+
* document/node path threads `lineWidth` into its render context but
|
|
741
|
+
* never reads it, so long scalars are emitted unfolded regardless of the
|
|
742
|
+
* option. Callers that need folding should render the plain value
|
|
743
|
+
* instead — `Yaml.stringify(doc.toValue(), options)` — at the cost of
|
|
744
|
+
* the document-level framing and styles this path preserves.
|
|
723
745
|
*/
|
|
724
746
|
stringify(options?: YamlStringifyOptions): Effect.Effect<string, YamlStringifyError>;
|
|
725
747
|
/**
|