@effected/toml 0.1.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/LICENSE +21 -0
- package/README.md +140 -0
- package/Toml.js +165 -0
- package/TomlDateTime.js +147 -0
- package/TomlDiagnostic.js +106 -0
- package/TomlDocument.js +133 -0
- package/TomlEdit.js +52 -0
- package/TomlFormat.js +611 -0
- package/TomlNode.js +212 -0
- package/TomlVisitor.js +152 -0
- package/index.d.ts +897 -0
- package/index.js +10 -0
- package/internal/diagnostics.js +53 -0
- package/internal/limits.js +24 -0
- package/internal/parser.js +408 -0
- package/internal/scanner.js +493 -0
- package/internal/semantic.js +253 -0
- package/internal/stringifyValue.js +191 -0
- package/package.json +45 -0
- package/tsdoc-metadata.json +11 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,897 @@
|
|
|
1
|
+
import { Data, Effect, Schema, Stream } from "effect";
|
|
2
|
+
//#region src/TomlDiagnostic.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Error codes emitted by the lexer stage.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
declare const TomlLexErrorCode: Schema.Literals<readonly ["InvalidUtf8", "UnterminatedString", "InvalidEscape", "InvalidUnicodeEscape", "ControlCharacterInString", "ControlCharacterInComment", "InvalidCharacter", "BareCarriageReturn"]>;
|
|
9
|
+
/**
|
|
10
|
+
* The union of all lexer-stage error code string literals.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
type TomlLexErrorCode = typeof TomlLexErrorCode.Type;
|
|
15
|
+
/**
|
|
16
|
+
* Error codes emitted by the parser stage.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
declare const TomlParseErrorCode: Schema.Literals<readonly ["ExpectedKey", "ExpectedEquals", "ExpectedValue", "ExpectedNewline", "ExpectedTableHeaderClose", "UnterminatedArray", "UnterminatedInlineTable", "TrailingCommaInInlineTable", "NewlineInInlineTable", "InvalidValue", "InvalidNumber", "IntegerOutOfRange", "InvalidDateTime", "NestingDepthExceeded"]>;
|
|
21
|
+
/**
|
|
22
|
+
* The union of all parser-stage error code string literals.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
type TomlParseErrorCode = typeof TomlParseErrorCode.Type;
|
|
27
|
+
/**
|
|
28
|
+
* Error codes emitted by the semantic (table/key conflict) stage.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
declare const TomlSemanticErrorCode: Schema.Literals<readonly ["DuplicateKey", "TableRedefined", "ArrayOfTablesConflict", "DottedKeyConflict", "InlineTableExtended"]>;
|
|
33
|
+
/**
|
|
34
|
+
* The union of all semantic-stage error code string literals.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
type TomlSemanticErrorCode = typeof TomlSemanticErrorCode.Type;
|
|
39
|
+
/**
|
|
40
|
+
* Error codes emitted by the stringifier stage.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
declare const TomlStringifyErrorCode: Schema.Literals<readonly ["CircularReference", "UnsupportedValue", "IntegerOutOfRange", "NestingDepthExceeded"]>;
|
|
45
|
+
/**
|
|
46
|
+
* The union of all stringifier-stage error code string literals.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
type TomlStringifyErrorCode = typeof TomlStringifyErrorCode.Type;
|
|
51
|
+
/**
|
|
52
|
+
* Union of all TOML error codes across all pipeline stages. Stage
|
|
53
|
+
* discrimination lives here (in the code), not in separate error classes.
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
declare const TomlErrorCode: Schema.Union<readonly [Schema.Literals<readonly ["InvalidUtf8", "UnterminatedString", "InvalidEscape", "InvalidUnicodeEscape", "ControlCharacterInString", "ControlCharacterInComment", "InvalidCharacter", "BareCarriageReturn"]>, Schema.Literals<readonly ["ExpectedKey", "ExpectedEquals", "ExpectedValue", "ExpectedNewline", "ExpectedTableHeaderClose", "UnterminatedArray", "UnterminatedInlineTable", "TrailingCommaInInlineTable", "NewlineInInlineTable", "InvalidValue", "InvalidNumber", "IntegerOutOfRange", "InvalidDateTime", "NestingDepthExceeded"]>, Schema.Literals<readonly ["DuplicateKey", "TableRedefined", "ArrayOfTablesConflict", "DottedKeyConflict", "InlineTableExtended"]>, Schema.Literals<readonly ["CircularReference", "UnsupportedValue", "IntegerOutOfRange", "NestingDepthExceeded"]>]>;
|
|
58
|
+
/**
|
|
59
|
+
* The union of all TOML error code string literals.
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
type TomlErrorCode = typeof TomlErrorCode.Type;
|
|
64
|
+
declare const TomlDiagnostic_base: Schema.Class<TomlDiagnostic, Schema.Struct<{
|
|
65
|
+
readonly code: Schema.Union<readonly [Schema.Literals<readonly ["InvalidUtf8", "UnterminatedString", "InvalidEscape", "InvalidUnicodeEscape", "ControlCharacterInString", "ControlCharacterInComment", "InvalidCharacter", "BareCarriageReturn"]>, Schema.Literals<readonly ["ExpectedKey", "ExpectedEquals", "ExpectedValue", "ExpectedNewline", "ExpectedTableHeaderClose", "UnterminatedArray", "UnterminatedInlineTable", "TrailingCommaInInlineTable", "NewlineInInlineTable", "InvalidValue", "InvalidNumber", "IntegerOutOfRange", "InvalidDateTime", "NestingDepthExceeded"]>, Schema.Literals<readonly ["DuplicateKey", "TableRedefined", "ArrayOfTablesConflict", "DottedKeyConflict", "InlineTableExtended"]>, Schema.Literals<readonly ["CircularReference", "UnsupportedValue", "IntegerOutOfRange", "NestingDepthExceeded"]>]>;
|
|
66
|
+
readonly message: Schema.String;
|
|
67
|
+
readonly offset: Schema.Number;
|
|
68
|
+
readonly length: Schema.Number;
|
|
69
|
+
readonly line: Schema.Number;
|
|
70
|
+
readonly character: Schema.Number;
|
|
71
|
+
}>, {}>;
|
|
72
|
+
/**
|
|
73
|
+
* One structured diagnostic: its {@link (TomlErrorCode:type)}, a
|
|
74
|
+
* human-readable `message`, and its exact position (`offset`/`length`, plus
|
|
75
|
+
* zero-based `line`/`character`).
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* The five-field positional core (`code`/`offset`/`length`/`line`/`character`)
|
|
79
|
+
* is structurally identical to `@effected/jsonc`'s parse-error detail shape
|
|
80
|
+
* and `@effected/yaml`'s `YamlDiagnostic`; `message` is this package's
|
|
81
|
+
* additive extra.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
declare class TomlDiagnostic extends TomlDiagnostic_base {
|
|
86
|
+
/**
|
|
87
|
+
* Materialize an engine record, deriving `line`/`character` (0-based)
|
|
88
|
+
* from `offset` against the source `text`. Advanced — the parse/stringify
|
|
89
|
+
* entry points call this for you.
|
|
90
|
+
*/
|
|
91
|
+
static fromRaw(source: string, raw: {
|
|
92
|
+
readonly code: TomlErrorCode;
|
|
93
|
+
readonly message: string;
|
|
94
|
+
readonly offset: number;
|
|
95
|
+
readonly length: number;
|
|
96
|
+
}): TomlDiagnostic;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/Toml.d.ts
|
|
100
|
+
declare const TomlStringifyOptions_base: Schema.Class<TomlStringifyOptions, Schema.Struct<{
|
|
101
|
+
readonly newline: Schema.optionalKey<Schema.Literals<readonly ["\n", "\r\n"]>>;
|
|
102
|
+
}>, {}>;
|
|
103
|
+
/**
|
|
104
|
+
* Options controlling stringify behavior. The only knob is `newline` —
|
|
105
|
+
* omitted, it resolves to `"\n"`.
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
declare class TomlStringifyOptions extends TomlStringifyOptions_base {}
|
|
110
|
+
declare const TomlParseError_base: Schema.Class<TomlParseError, Schema.TaggedStruct<"TomlParseError", {
|
|
111
|
+
readonly diagnostics: Schema.$Array<typeof TomlDiagnostic>;
|
|
112
|
+
}>, import("effect/Cause").YieldableError>;
|
|
113
|
+
/**
|
|
114
|
+
* Parse failure: the {@link TomlDiagnostic} entries describing why the
|
|
115
|
+
* document was rejected (first violation wins, so there is one today; the
|
|
116
|
+
* array shape matches `@effected/yaml`'s aggregate contract). Raised by
|
|
117
|
+
* {@link Toml.parse} and the decode direction of the schema factories.
|
|
118
|
+
*
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
declare class TomlParseError extends TomlParseError_base {
|
|
122
|
+
get message(): string;
|
|
123
|
+
}
|
|
124
|
+
declare const TomlStringifyError_base: Schema.Class<TomlStringifyError, Schema.TaggedStruct<"TomlStringifyError", {
|
|
125
|
+
readonly diagnostic: typeof TomlDiagnostic;
|
|
126
|
+
}>, import("effect/Cause").YieldableError>;
|
|
127
|
+
/**
|
|
128
|
+
* Stringification failure: an unsupported value, an out-of-range integer, a
|
|
129
|
+
* circular reference or a tripped depth guard, as one structured
|
|
130
|
+
* {@link TomlDiagnostic} (offset `0` — there is no source text). Raised by
|
|
131
|
+
* {@link Toml.stringify} and the encode direction of the schema factories.
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
*/
|
|
135
|
+
declare class TomlStringifyError extends TomlStringifyError_base {
|
|
136
|
+
get message(): string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Static entry points for TOML parsing, stringification and the schema
|
|
140
|
+
* factories. Not instantiable.
|
|
141
|
+
*
|
|
142
|
+
* @remarks
|
|
143
|
+
* `parse`, `stringify` and the schema factories carry real typed error
|
|
144
|
+
* channels — including the hardening guards (nesting-depth caps on both
|
|
145
|
+
* sides, circular-reference detection on encode) that keep malformed or
|
|
146
|
+
* adversarial input on the typed channel instead of surfacing as an
|
|
147
|
+
* unhandled defect. `parse` takes no options: TOML 1.0.0 parsing has no
|
|
148
|
+
* knobs.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* import { Toml } from "@effected/toml";
|
|
153
|
+
* import { Effect } from "effect";
|
|
154
|
+
*
|
|
155
|
+
* const program = Effect.gen(function* () {
|
|
156
|
+
* const value = yield* Toml.parse('name = "Alice"\nage = 30');
|
|
157
|
+
* return value; // { name: "Alice", age: 30 }
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
declare class Toml {
|
|
164
|
+
private constructor();
|
|
165
|
+
/**
|
|
166
|
+
* Parse a TOML 1.0.0 document into a plain JavaScript value: tables and
|
|
167
|
+
* inline tables become plain objects (`__proto__` lands as an own data
|
|
168
|
+
* property), arrays become plain arrays, integers become `number` (or
|
|
169
|
+
* `bigint` past 2^53) and date-times become the four `TomlDateTime`
|
|
170
|
+
* classes. Fails with {@link TomlParseError} at the first violation;
|
|
171
|
+
* returns `unknown`, never `any`.
|
|
172
|
+
*
|
|
173
|
+
* A nesting-depth bomb (arrays or inline tables past the engine cap) also
|
|
174
|
+
* fails through {@link TomlParseError} with a `NestingDepthExceeded`
|
|
175
|
+
* diagnostic, never as an unhandled defect.
|
|
176
|
+
*/
|
|
177
|
+
static readonly parse: (text: string) => Effect.Effect<unknown, TomlParseError, never>;
|
|
178
|
+
/**
|
|
179
|
+
* Stringify a plain JavaScript value as a canonical TOML document: within
|
|
180
|
+
* a table, non-table pairs first, then sub-tables as `[dotted.header]`
|
|
181
|
+
* sections depth-first, then arrays of tables as `[[dotted.header]]`
|
|
182
|
+
* sections, a blank line before every header except at document start.
|
|
183
|
+
* Fails with {@link TomlStringifyError} on unsupported values (TOML has no
|
|
184
|
+
* null), out-of-int64-range `bigint`s, circular references and
|
|
185
|
+
* depth-guard trips — all on the typed channel.
|
|
186
|
+
*/
|
|
187
|
+
static readonly stringify: (value: unknown, options?: TomlStringifyOptions | undefined) => Effect.Effect<string, TomlStringifyError, never>;
|
|
188
|
+
/**
|
|
189
|
+
* A `Schema<unknown, string>` decoding a TOML document and encoding values
|
|
190
|
+
* back to canonical TOML text.
|
|
191
|
+
*
|
|
192
|
+
* Schema-producing: each call returns a fresh schema whose derivation
|
|
193
|
+
* caches are not shared across calls. Bind the result to a `const` on hot
|
|
194
|
+
* paths; the pre-bound {@link Toml.TomlFromString} covers the common case.
|
|
195
|
+
*/
|
|
196
|
+
static fromString(): Schema.Codec<unknown, string>;
|
|
197
|
+
/**
|
|
198
|
+
* The zero-config `Schema<unknown, string>` — `Toml.fromString()`
|
|
199
|
+
* pre-bound so the common case needs no memoization discipline.
|
|
200
|
+
*/
|
|
201
|
+
static readonly TomlFromString: Schema.Codec<unknown, string>;
|
|
202
|
+
/**
|
|
203
|
+
* Compose {@link Toml.fromString} with a target schema, yielding a
|
|
204
|
+
* `Schema<A, string>` that decodes TOML straight into a validated domain
|
|
205
|
+
* value. The target's decoding/encoding service requirements flow through.
|
|
206
|
+
*
|
|
207
|
+
* Schema-producing: bind the result to a `const` on hot paths (see
|
|
208
|
+
* {@link Toml.fromString}).
|
|
209
|
+
*/
|
|
210
|
+
static schema<T, E, RD = never, RE = never>(target: Schema.Codec<T, E, RD, RE>): Schema.Codec<T, string, RD, RE>;
|
|
211
|
+
}
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/TomlDateTime.d.ts
|
|
214
|
+
declare const TomlLocalDate_base: Schema.Class<TomlLocalDate, Schema.Struct<{
|
|
215
|
+
year: Schema.Int;
|
|
216
|
+
month: Schema.Int;
|
|
217
|
+
day: Schema.Int;
|
|
218
|
+
}>, {}>;
|
|
219
|
+
/**
|
|
220
|
+
* A TOML local date: `year`-`month`-`day` with no time-of-day or offset,
|
|
221
|
+
* validated against the real Gregorian calendar.
|
|
222
|
+
*
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
declare class TomlLocalDate extends TomlLocalDate_base {
|
|
226
|
+
toString(): string;
|
|
227
|
+
}
|
|
228
|
+
declare const TomlLocalTime_base: Schema.Class<TomlLocalTime, Schema.Struct<{
|
|
229
|
+
hour: Schema.Int;
|
|
230
|
+
minute: Schema.Int;
|
|
231
|
+
second: Schema.Int;
|
|
232
|
+
nanosecond: Schema.Int;
|
|
233
|
+
}>, {}>;
|
|
234
|
+
/**
|
|
235
|
+
* A TOML local time: `hour`:`minute`:`second`[.`nanosecond`] with no date or
|
|
236
|
+
* offset. `second` tolerates the RFC 3339 leap second (0-60).
|
|
237
|
+
*
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
declare class TomlLocalTime extends TomlLocalTime_base {
|
|
241
|
+
toString(): string;
|
|
242
|
+
}
|
|
243
|
+
declare const TomlLocalDateTime_base: Schema.Class<TomlLocalDateTime, Schema.Struct<{
|
|
244
|
+
readonly year: Schema.Int;
|
|
245
|
+
readonly month: Schema.Int;
|
|
246
|
+
readonly day: Schema.Int;
|
|
247
|
+
readonly hour: Schema.Int;
|
|
248
|
+
readonly minute: Schema.Int;
|
|
249
|
+
readonly second: Schema.Int;
|
|
250
|
+
readonly nanosecond: Schema.Int;
|
|
251
|
+
}>, {}>;
|
|
252
|
+
/**
|
|
253
|
+
* A TOML local date-time: a {@link TomlLocalDate} and a {@link TomlLocalTime}
|
|
254
|
+
* combined, with no offset.
|
|
255
|
+
*
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
258
|
+
declare class TomlLocalDateTime extends TomlLocalDateTime_base {
|
|
259
|
+
toString(): string;
|
|
260
|
+
}
|
|
261
|
+
declare const TomlOffsetDateTime_base: Schema.Class<TomlOffsetDateTime, Schema.Struct<{
|
|
262
|
+
readonly year: Schema.Int;
|
|
263
|
+
readonly month: Schema.Int;
|
|
264
|
+
readonly day: Schema.Int;
|
|
265
|
+
readonly hour: Schema.Int;
|
|
266
|
+
readonly minute: Schema.Int;
|
|
267
|
+
readonly second: Schema.Int;
|
|
268
|
+
readonly nanosecond: Schema.Int;
|
|
269
|
+
readonly offsetMinutes: Schema.Int;
|
|
270
|
+
}>, {}>;
|
|
271
|
+
/**
|
|
272
|
+
* A TOML offset date-time: a {@link TomlLocalDateTime} plus `offsetMinutes`
|
|
273
|
+
* (-1439-1439). Parsing enforces `hh <= 23` / `mm <= 59` before construction;
|
|
274
|
+
* this class only bounds the combined minute count.
|
|
275
|
+
*
|
|
276
|
+
* @public
|
|
277
|
+
*/
|
|
278
|
+
declare class TomlOffsetDateTime extends TomlOffsetDateTime_base {
|
|
279
|
+
toString(): string;
|
|
280
|
+
}
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/TomlNode.d.ts
|
|
283
|
+
/**
|
|
284
|
+
* The three simple-key spellings: `bare`, `basic` (`"..."`) and `literal`
|
|
285
|
+
* (`'...'`).
|
|
286
|
+
*
|
|
287
|
+
* @public
|
|
288
|
+
*/
|
|
289
|
+
declare const TomlKeyKind: Schema.Literals<readonly ["bare", "basic", "literal"]>;
|
|
290
|
+
/**
|
|
291
|
+
* The union of all key-kind string literals.
|
|
292
|
+
*
|
|
293
|
+
* @public
|
|
294
|
+
*/
|
|
295
|
+
type TomlKeyKind = typeof TomlKeyKind.Type;
|
|
296
|
+
declare const TomlKey_base: Schema.Class<TomlKey, Schema.TaggedStruct<"TomlKey", {
|
|
297
|
+
readonly value: Schema.String;
|
|
298
|
+
readonly kind: Schema.Literals<readonly ["bare", "basic", "literal"]>;
|
|
299
|
+
readonly offset: Schema.Number;
|
|
300
|
+
readonly length: Schema.Number;
|
|
301
|
+
}>, {}>;
|
|
302
|
+
/**
|
|
303
|
+
* One simple key within a (possibly dotted) key path.
|
|
304
|
+
*
|
|
305
|
+
* - `value` — the decoded key text (escapes resolved, quotes stripped).
|
|
306
|
+
* - `kind` — how the key was spelled in the source.
|
|
307
|
+
* - `offset` / `length` — the key's span in the source, quotes included.
|
|
308
|
+
*
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
311
|
+
declare class TomlKey extends TomlKey_base {}
|
|
312
|
+
/**
|
|
313
|
+
* The four TOML string forms.
|
|
314
|
+
*
|
|
315
|
+
* @public
|
|
316
|
+
*/
|
|
317
|
+
declare const TomlStringStyle: Schema.Literals<readonly ["basic", "literal", "multiline-basic", "multiline-literal"]>;
|
|
318
|
+
/**
|
|
319
|
+
* The union of all string-style literals.
|
|
320
|
+
*
|
|
321
|
+
* @public
|
|
322
|
+
*/
|
|
323
|
+
type TomlStringStyle = typeof TomlStringStyle.Type;
|
|
324
|
+
declare const TomlString_base: Schema.Class<TomlString, Schema.TaggedStruct<"TomlString", {
|
|
325
|
+
readonly value: Schema.String;
|
|
326
|
+
readonly style: Schema.Literals<readonly ["basic", "literal", "multiline-basic", "multiline-literal"]>;
|
|
327
|
+
readonly offset: Schema.Number;
|
|
328
|
+
readonly length: Schema.Number;
|
|
329
|
+
}>, {}>;
|
|
330
|
+
/**
|
|
331
|
+
* A string value node. `value` is the decoded text; the raw spelling lives in
|
|
332
|
+
* the source span.
|
|
333
|
+
*
|
|
334
|
+
* @public
|
|
335
|
+
*/
|
|
336
|
+
declare class TomlString extends TomlString_base {}
|
|
337
|
+
declare const TomlInteger_base: Schema.Class<TomlInteger, Schema.TaggedStruct<"TomlInteger", {
|
|
338
|
+
readonly value: Schema.Union<readonly [Schema.Number, Schema.BigInt]>;
|
|
339
|
+
readonly offset: Schema.Number;
|
|
340
|
+
readonly length: Schema.Number;
|
|
341
|
+
}>, {}>;
|
|
342
|
+
/**
|
|
343
|
+
* An integer value node. Decodes to `number` when the magnitude fits in
|
|
344
|
+
* 2^53 - 1, else `bigint` (TOML integers span the full signed 64-bit range).
|
|
345
|
+
*
|
|
346
|
+
* @public
|
|
347
|
+
*/
|
|
348
|
+
declare class TomlInteger extends TomlInteger_base {}
|
|
349
|
+
declare const TomlFloat_base: Schema.Class<TomlFloat, Schema.TaggedStruct<"TomlFloat", {
|
|
350
|
+
readonly value: Schema.Number;
|
|
351
|
+
readonly offset: Schema.Number;
|
|
352
|
+
readonly length: Schema.Number;
|
|
353
|
+
}>, {}>;
|
|
354
|
+
/**
|
|
355
|
+
* A float value node, including the special spellings (`inf`, `nan`).
|
|
356
|
+
*
|
|
357
|
+
* @public
|
|
358
|
+
*/
|
|
359
|
+
declare class TomlFloat extends TomlFloat_base {}
|
|
360
|
+
declare const TomlBoolean_base: Schema.Class<TomlBoolean, Schema.TaggedStruct<"TomlBoolean", {
|
|
361
|
+
readonly value: Schema.Boolean;
|
|
362
|
+
readonly offset: Schema.Number;
|
|
363
|
+
readonly length: Schema.Number;
|
|
364
|
+
}>, {}>;
|
|
365
|
+
/**
|
|
366
|
+
* A boolean value node.
|
|
367
|
+
*
|
|
368
|
+
* @public
|
|
369
|
+
*/
|
|
370
|
+
declare class TomlBoolean extends TomlBoolean_base {}
|
|
371
|
+
declare const TomlDateTimeLiteral_base: Schema.Class<TomlDateTimeLiteral, Schema.TaggedStruct<"TomlDateTimeLiteral", {
|
|
372
|
+
readonly value: Schema.Union<readonly [typeof TomlOffsetDateTime, typeof TomlLocalDateTime, typeof TomlLocalDate, typeof TomlLocalTime]>;
|
|
373
|
+
readonly offset: Schema.Number;
|
|
374
|
+
readonly length: Schema.Number;
|
|
375
|
+
}>, {}>;
|
|
376
|
+
/**
|
|
377
|
+
* A date-time value node wrapping one of the four TOML date-time classes.
|
|
378
|
+
*
|
|
379
|
+
* @public
|
|
380
|
+
*/
|
|
381
|
+
declare class TomlDateTimeLiteral extends TomlDateTimeLiteral_base {}
|
|
382
|
+
declare const TomlArray_base: Schema.Class<TomlArray, Schema.TaggedStruct<"TomlArray", {
|
|
383
|
+
readonly items: Schema.$Array<Schema.suspend<Schema.Codec<TomlValueNode, TomlValueNode, never, never>>>;
|
|
384
|
+
readonly offset: Schema.Number;
|
|
385
|
+
readonly length: Schema.Number;
|
|
386
|
+
}>, {}>;
|
|
387
|
+
/**
|
|
388
|
+
* An array value node. Heterogeneous per TOML 1.0.0; may span multiple lines
|
|
389
|
+
* (the span covers brackets, inner newlines and inner comments).
|
|
390
|
+
*
|
|
391
|
+
* @public
|
|
392
|
+
*/
|
|
393
|
+
declare class TomlArray extends TomlArray_base {}
|
|
394
|
+
declare const TomlInlineEntry_base: Schema.Class<TomlInlineEntry, Schema.TaggedStruct<"TomlInlineEntry", {
|
|
395
|
+
readonly keyPath: Schema.$Array<typeof TomlKey>;
|
|
396
|
+
readonly value: Schema.suspend<Schema.Codec<TomlValueNode, TomlValueNode, never, never>>;
|
|
397
|
+
readonly offset: Schema.Number;
|
|
398
|
+
readonly length: Schema.Number;
|
|
399
|
+
}>, {}>;
|
|
400
|
+
/**
|
|
401
|
+
* One `key = value` entry inside an inline table. `keyPath` has more than one
|
|
402
|
+
* element for dotted keys (`{a.b = 1}`).
|
|
403
|
+
*
|
|
404
|
+
* @public
|
|
405
|
+
*/
|
|
406
|
+
declare class TomlInlineEntry extends TomlInlineEntry_base {}
|
|
407
|
+
declare const TomlInlineTable_base: Schema.Class<TomlInlineTable, Schema.TaggedStruct<"TomlInlineTable", {
|
|
408
|
+
readonly entries: Schema.$Array<typeof TomlInlineEntry>;
|
|
409
|
+
readonly offset: Schema.Number;
|
|
410
|
+
readonly length: Schema.Number;
|
|
411
|
+
}>, {}>;
|
|
412
|
+
/**
|
|
413
|
+
* An inline table value node (`{ k = v, ... }`). Single-line by grammar.
|
|
414
|
+
*
|
|
415
|
+
* @public
|
|
416
|
+
*/
|
|
417
|
+
declare class TomlInlineTable extends TomlInlineTable_base {}
|
|
418
|
+
/**
|
|
419
|
+
* A discriminated-union schema covering all seven TOML value node types.
|
|
420
|
+
* Defined lazily via `Schema.suspend` to break the recursive reference chain
|
|
421
|
+
* `TomlValueNode → TomlArray/TomlInlineTable → TomlValueNode`.
|
|
422
|
+
*
|
|
423
|
+
* @public
|
|
424
|
+
*/
|
|
425
|
+
declare const TomlValueNode: Schema.Codec<TomlString | TomlInteger | TomlFloat | TomlBoolean | TomlDateTimeLiteral | TomlArray | TomlInlineTable>;
|
|
426
|
+
/**
|
|
427
|
+
* The union of all TOML value node types.
|
|
428
|
+
*
|
|
429
|
+
* @public
|
|
430
|
+
*/
|
|
431
|
+
type TomlValueNode = TomlString | TomlInteger | TomlFloat | TomlBoolean | TomlDateTimeLiteral | TomlArray | TomlInlineTable;
|
|
432
|
+
declare const TomlKeyValue_base: Schema.Class<TomlKeyValue, Schema.TaggedStruct<"TomlKeyValue", {
|
|
433
|
+
readonly keyPath: Schema.$Array<typeof TomlKey>;
|
|
434
|
+
readonly value: Schema.suspend<Schema.Codec<TomlValueNode, TomlValueNode, never, never>>;
|
|
435
|
+
readonly comment: Schema.optionalKey<Schema.String>;
|
|
436
|
+
readonly offset: Schema.Number;
|
|
437
|
+
readonly length: Schema.Number;
|
|
438
|
+
}>, {}>;
|
|
439
|
+
/**
|
|
440
|
+
* A `key = value` expression. The span starts at the first character of the
|
|
441
|
+
* line's leading whitespace and ends after the terminating newline (or at
|
|
442
|
+
* EOF); multi-line values extend it. `comment` holds the decoded trailing
|
|
443
|
+
* comment (without `#`, one leading space stripped) when present.
|
|
444
|
+
*
|
|
445
|
+
* @public
|
|
446
|
+
*/
|
|
447
|
+
declare class TomlKeyValue extends TomlKeyValue_base {}
|
|
448
|
+
declare const TomlTableHeader_base: Schema.Class<TomlTableHeader, Schema.TaggedStruct<"TomlTableHeader", {
|
|
449
|
+
readonly keyPath: Schema.$Array<typeof TomlKey>;
|
|
450
|
+
readonly comment: Schema.optionalKey<Schema.String>;
|
|
451
|
+
readonly offset: Schema.Number;
|
|
452
|
+
readonly length: Schema.Number;
|
|
453
|
+
}>, {}>;
|
|
454
|
+
/**
|
|
455
|
+
* A `[table]` header expression. Span contract as in {@link TomlKeyValue}.
|
|
456
|
+
*
|
|
457
|
+
* @public
|
|
458
|
+
*/
|
|
459
|
+
declare class TomlTableHeader extends TomlTableHeader_base {}
|
|
460
|
+
declare const TomlArrayTableHeader_base: Schema.Class<TomlArrayTableHeader, Schema.TaggedStruct<"TomlArrayTableHeader", {
|
|
461
|
+
readonly keyPath: Schema.$Array<typeof TomlKey>;
|
|
462
|
+
readonly comment: Schema.optionalKey<Schema.String>;
|
|
463
|
+
readonly offset: Schema.Number;
|
|
464
|
+
readonly length: Schema.Number;
|
|
465
|
+
}>, {}>;
|
|
466
|
+
/**
|
|
467
|
+
* A `[[array-of-tables]]` header expression. Span contract as in
|
|
468
|
+
* {@link TomlKeyValue}.
|
|
469
|
+
*
|
|
470
|
+
* @public
|
|
471
|
+
*/
|
|
472
|
+
declare class TomlArrayTableHeader extends TomlArrayTableHeader_base {}
|
|
473
|
+
declare const TomlTrivia_base: Schema.Class<TomlTrivia, Schema.TaggedStruct<"TomlTrivia", {
|
|
474
|
+
readonly text: Schema.String;
|
|
475
|
+
readonly offset: Schema.Number;
|
|
476
|
+
readonly length: Schema.Number;
|
|
477
|
+
}>, {}>;
|
|
478
|
+
/**
|
|
479
|
+
* A run of consecutive blank and comment-only lines, coalesced into one
|
|
480
|
+
* expression. `text` is the raw source slice, newlines included.
|
|
481
|
+
*
|
|
482
|
+
* @public
|
|
483
|
+
*/
|
|
484
|
+
declare class TomlTrivia extends TomlTrivia_base {}
|
|
485
|
+
/**
|
|
486
|
+
* The union schema of the four expression types making up a document's
|
|
487
|
+
* linear CST.
|
|
488
|
+
*
|
|
489
|
+
* @public
|
|
490
|
+
*/
|
|
491
|
+
declare const TomlExpression: Schema.Union<readonly [typeof TomlKeyValue, typeof TomlTableHeader, typeof TomlArrayTableHeader, typeof TomlTrivia]>;
|
|
492
|
+
/**
|
|
493
|
+
* The union of all expression node types.
|
|
494
|
+
*
|
|
495
|
+
* @public
|
|
496
|
+
*/
|
|
497
|
+
type TomlExpression = typeof TomlExpression.Type;
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region src/TomlDocument.d.ts
|
|
500
|
+
declare const TomlDocument_base: Schema.Class<TomlDocument, Schema.Struct<{
|
|
501
|
+
readonly source: Schema.String;
|
|
502
|
+
readonly expressions: Schema.$Array<Schema.Union<readonly [typeof TomlKeyValue, typeof TomlTableHeader, typeof TomlArrayTableHeader, typeof TomlTrivia]>>;
|
|
503
|
+
readonly diagnostics: Schema.$Array<typeof TomlDiagnostic>;
|
|
504
|
+
}>, {}>;
|
|
505
|
+
/**
|
|
506
|
+
* A parsed TOML document that never loses a byte: the `source` text, the
|
|
507
|
+
* linear {@link (TomlExpression:type)} CST whose spans tile the source
|
|
508
|
+
* exactly, and
|
|
509
|
+
* any semantic violations as {@link TomlDiagnostic} data.
|
|
510
|
+
*
|
|
511
|
+
* @remarks
|
|
512
|
+
* `parse` fails typed only on lex/parse errors; a syntactically valid but
|
|
513
|
+
* semantically illegal document (say, a duplicate key) still parses with the
|
|
514
|
+
* violation recorded in `diagnostics`, so the text stays inspectable and
|
|
515
|
+
* editable. `stringify` reconstructs the source by concatenating expression
|
|
516
|
+
* spans — that the result equals `source` is the span-bookkeeping proof, held
|
|
517
|
+
* byte-exact across the full toml-test corpus. `toValue` refuses on a
|
|
518
|
+
* non-empty `diagnostics`.
|
|
519
|
+
*
|
|
520
|
+
* Construct via {@link TomlDocument.parse}; `TomlDocument.make` is for
|
|
521
|
+
* synthetic documents.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```ts
|
|
525
|
+
* import { TomlDocument } from "@effected/toml";
|
|
526
|
+
* import { Effect } from "effect";
|
|
527
|
+
*
|
|
528
|
+
* const program = Effect.gen(function* () {
|
|
529
|
+
* const doc = yield* TomlDocument.parse('name = "Alice"\n');
|
|
530
|
+
* doc.stringify(); // 'name = "Alice"\n' — byte-exact
|
|
531
|
+
* return yield* doc.toValue(); // { name: "Alice" }
|
|
532
|
+
* });
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @public
|
|
536
|
+
*/
|
|
537
|
+
declare class TomlDocument extends TomlDocument_base {
|
|
538
|
+
/**
|
|
539
|
+
* Parse TOML text into a lossless document. Fails with
|
|
540
|
+
* {@link TomlParseError} only on lex/parse errors — including a
|
|
541
|
+
* nesting-depth bomb, which surfaces as a `NestingDepthExceeded`
|
|
542
|
+
* diagnostic, never an unhandled defect. Semantic violations do not fail:
|
|
543
|
+
* they land in `diagnostics` as data (first violation wins, so there is at
|
|
544
|
+
* most one today; the array shape is the contract).
|
|
545
|
+
*/
|
|
546
|
+
static readonly parse: (text: string) => Effect.Effect<TomlDocument, TomlParseError, never>;
|
|
547
|
+
/**
|
|
548
|
+
* A `Schema<TomlDocument, string>` decoding TOML text into a full document
|
|
549
|
+
* (source, expressions, diagnostics) and encoding a document back to its
|
|
550
|
+
* byte-exact text.
|
|
551
|
+
*
|
|
552
|
+
* Schema-producing: each call returns a fresh schema whose derivation
|
|
553
|
+
* caches are not shared across calls; bind the result to a `const` on hot
|
|
554
|
+
* paths.
|
|
555
|
+
*/
|
|
556
|
+
static schema(): Schema.Codec<TomlDocument, string>;
|
|
557
|
+
/**
|
|
558
|
+
* Materialize the document's plain JavaScript value. Fails with
|
|
559
|
+
* {@link TomlParseError} carrying the stored `diagnostics` when the parse
|
|
560
|
+
* recorded semantic violations; otherwise builds the value from the
|
|
561
|
+
* expression list (already validated, so the defensive materialization
|
|
562
|
+
* wrapper is belt-and-suspenders).
|
|
563
|
+
*/
|
|
564
|
+
toValue(): Effect.Effect<unknown, TomlParseError>;
|
|
565
|
+
/**
|
|
566
|
+
* Reconstruct the document text by concatenating each expression's source
|
|
567
|
+
* span in order. The expression spans tile the source exactly, so the
|
|
568
|
+
* result equals `source` byte-for-byte — the round-trip contract this
|
|
569
|
+
* class exists to prove. Pure and total.
|
|
570
|
+
*/
|
|
571
|
+
stringify(): string;
|
|
572
|
+
}
|
|
573
|
+
//#endregion
|
|
574
|
+
//#region src/TomlEdit.d.ts
|
|
575
|
+
/**
|
|
576
|
+
* A single path segment: a `string` for table keys or a `number` for array
|
|
577
|
+
* and array-of-tables indices.
|
|
578
|
+
*
|
|
579
|
+
* @public
|
|
580
|
+
*/
|
|
581
|
+
type TomlSegment = string | number;
|
|
582
|
+
/**
|
|
583
|
+
* An ordered sequence of {@link TomlSegment} values describing a location
|
|
584
|
+
* within a TOML document's semantic tree.
|
|
585
|
+
*
|
|
586
|
+
* @public
|
|
587
|
+
*/
|
|
588
|
+
type TomlPath = ReadonlyArray<TomlSegment>;
|
|
589
|
+
declare const TomlRange_base: Schema.Class<TomlRange, Schema.Struct<{
|
|
590
|
+
readonly offset: Schema.Number;
|
|
591
|
+
readonly length: Schema.Number;
|
|
592
|
+
}>, {}>;
|
|
593
|
+
/**
|
|
594
|
+
* A range within a TOML document, expressed as a zero-based character
|
|
595
|
+
* `offset` and a `length` in UTF-16 code units. Pass to `TomlFormat.format`
|
|
596
|
+
* to restrict formatting to the expressions intersecting a region.
|
|
597
|
+
*
|
|
598
|
+
* @public
|
|
599
|
+
*/
|
|
600
|
+
declare class TomlRange extends TomlRange_base {}
|
|
601
|
+
declare const TomlEdit_base: Schema.Class<TomlEdit, Schema.Struct<{
|
|
602
|
+
readonly offset: Schema.Number;
|
|
603
|
+
readonly length: Schema.Number;
|
|
604
|
+
readonly content: Schema.String;
|
|
605
|
+
}>, {}>;
|
|
606
|
+
/**
|
|
607
|
+
* A non-mutating text edit: replace the span `[offset, offset + length)` with
|
|
608
|
+
* `content`. Set `length` to `0` to insert, `content` to `""` to delete.
|
|
609
|
+
*
|
|
610
|
+
* @remarks
|
|
611
|
+
* Structurally identical to `@effected/jsonc`'s and `@effected/yaml`'s edit
|
|
612
|
+
* shapes (same field names, types and semantics) per the jsonc/yaml parity
|
|
613
|
+
* convention, so consumer code can be written once over "a document codec's
|
|
614
|
+
* Edit/Range/Path".
|
|
615
|
+
*
|
|
616
|
+
* @public
|
|
617
|
+
*/
|
|
618
|
+
declare class TomlEdit extends TomlEdit_base {
|
|
619
|
+
/**
|
|
620
|
+
* Apply `edits` to `text`, producing a new string. Edits are applied in
|
|
621
|
+
* reverse-offset order so earlier offsets stay valid; the input `edits`
|
|
622
|
+
* array is not mutated. Overlapping edits are a programmer error and throw
|
|
623
|
+
* as a defect — `TomlFormat` never produces them.
|
|
624
|
+
*/
|
|
625
|
+
static applyAll(text: string, edits: ReadonlyArray<TomlEdit>): string;
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region src/TomlFormat.d.ts
|
|
629
|
+
/**
|
|
630
|
+
* A range accepted at the `format`/`formatToString` call sites: either a
|
|
631
|
+
* {@link TomlRange} instance or a plain `{ offset, length }` literal (the two
|
|
632
|
+
* are structurally interchangeable — only `offset`/`length` are read).
|
|
633
|
+
*
|
|
634
|
+
* @public
|
|
635
|
+
*/
|
|
636
|
+
type TomlRangeLike = TomlRange | {
|
|
637
|
+
readonly offset: number;
|
|
638
|
+
readonly length: number;
|
|
639
|
+
};
|
|
640
|
+
declare const TomlFormattingOptions_base: Schema.Class<TomlFormattingOptions, Schema.Struct<{
|
|
641
|
+
readonly newline: Schema.optionalKey<Schema.Literals<readonly ["\n", "\r\n"]>>;
|
|
642
|
+
}>, {}>;
|
|
643
|
+
/**
|
|
644
|
+
* Options controlling formatting and modification behavior. The only knob is
|
|
645
|
+
* `newline`: for `format` it normalizes every newline outside multi-line
|
|
646
|
+
* strings; for `modify` it overrides the dominant newline inherited by
|
|
647
|
+
* inserted lines.
|
|
648
|
+
*
|
|
649
|
+
* @public
|
|
650
|
+
*/
|
|
651
|
+
declare class TomlFormattingOptions extends TomlFormattingOptions_base {}
|
|
652
|
+
declare const TomlModificationError_base: Schema.Class<TomlModificationError, Schema.TaggedStruct<"TomlModificationError", {
|
|
653
|
+
readonly diagnostic: typeof TomlDiagnostic;
|
|
654
|
+
}>, import("effect/Cause").YieldableError>;
|
|
655
|
+
/**
|
|
656
|
+
* Raised when `TomlFormat.modify` cannot resolve the requested path against
|
|
657
|
+
* the document's semantic view, when the insertion target refuses (an inline
|
|
658
|
+
* table or an implicitly created table), or when the replacement value
|
|
659
|
+
* cannot render as TOML. Carries one structured {@link TomlDiagnostic} —
|
|
660
|
+
* never a collapsed `reason` string.
|
|
661
|
+
*
|
|
662
|
+
* @public
|
|
663
|
+
*/
|
|
664
|
+
declare class TomlModificationError extends TomlModificationError_base {
|
|
665
|
+
get message(): string;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Formatting and modification statics. Not instantiable.
|
|
669
|
+
*
|
|
670
|
+
* @remarks
|
|
671
|
+
* `format`/`formatToString` are pure and total: malformed input yields no
|
|
672
|
+
* edits rather than corrupting the document, and every edit derives from an
|
|
673
|
+
* expression or value span, so bytes inside multi-line strings are
|
|
674
|
+
* untouchable by construction. `modify`/`modifyToString` carry a real error
|
|
675
|
+
* channel — {@link TomlParseError} when the source does not parse and
|
|
676
|
+
* {@link TomlModificationError} for path-resolution and insertion-target
|
|
677
|
+
* failures — and every document they produce reparses cleanly.
|
|
678
|
+
*
|
|
679
|
+
* @public
|
|
680
|
+
*/
|
|
681
|
+
declare class TomlFormat {
|
|
682
|
+
private constructor();
|
|
683
|
+
/**
|
|
684
|
+
* Compute conservative formatting edits: one space around `=`, leading
|
|
685
|
+
* indentation stripped, trailing whitespace stripped with one space before
|
|
686
|
+
* a trailing `#`, one space after a non-empty `#` (unless it starts with
|
|
687
|
+
* space, tab or `!`), a single final newline, and — when
|
|
688
|
+
* `options.newline` is set — every newline normalized outside multi-line
|
|
689
|
+
* strings. Nothing else: no reordering, no blank-line collapsing, no value
|
|
690
|
+
* rewriting. `range` restricts edits to the expressions intersecting it.
|
|
691
|
+
* Non-mutating — apply with `TomlEdit.applyAll` (or use
|
|
692
|
+
* {@link TomlFormat.formatToString}).
|
|
693
|
+
*/
|
|
694
|
+
static format(text: string, range?: TomlRangeLike, options?: TomlFormattingOptions): ReadonlyArray<TomlEdit>;
|
|
695
|
+
/**
|
|
696
|
+
* Format `text` and apply the resulting edits in one step
|
|
697
|
+
* (`TomlEdit.applyAll ∘ format`). Pure and total.
|
|
698
|
+
*/
|
|
699
|
+
static formatToString(text: string, range?: TomlRangeLike, options?: TomlFormattingOptions): string;
|
|
700
|
+
/**
|
|
701
|
+
* Compute the edits that replace, delete, or insert a value at `path`,
|
|
702
|
+
* resolved through the document's semantic view. Every segment but the
|
|
703
|
+
* last must resolve — intermediate tables are never auto-created. A
|
|
704
|
+
* `value` of `undefined` deletes: a key-value's whole line, an inline
|
|
705
|
+
* entry, or an array item, splicing separators. A new key inserts per the
|
|
706
|
+
* pinned placement rules: root keys land after the last root expression
|
|
707
|
+
* (before the first header), section keys after the section's last
|
|
708
|
+
* expression, dotted-table keys as dotted keys appended to the defining
|
|
709
|
+
* section; inline and implicitly created tables refuse. Inserted lines
|
|
710
|
+
* inherit the document's dominant newline unless `options.newline`
|
|
711
|
+
* overrides it. Every modified document reparses cleanly.
|
|
712
|
+
*/
|
|
713
|
+
static readonly modify: (text: string, path: TomlPath, value: unknown, options?: TomlFormattingOptions | undefined) => Effect.Effect<readonly TomlEdit[], TomlModificationError | TomlParseError, never>;
|
|
714
|
+
/**
|
|
715
|
+
* Modify `text` and apply the resulting edits in one step
|
|
716
|
+
* (`TomlEdit.applyAll ∘ modify`).
|
|
717
|
+
*/
|
|
718
|
+
static readonly modifyToString: (text: string, path: TomlPath, value: unknown, options?: TomlFormattingOptions | undefined) => Effect.Effect<string, TomlModificationError | TomlParseError, never>;
|
|
719
|
+
}
|
|
720
|
+
//#endregion
|
|
721
|
+
//#region src/TomlVisitor.d.ts
|
|
722
|
+
/**
|
|
723
|
+
* The discriminated union of TOML visitor events, in document order.
|
|
724
|
+
* `TableStart` fires once for the root with `path: []` before any other
|
|
725
|
+
* event, then again for every `[table]` header. `ArrayTableStart` fires for
|
|
726
|
+
* every `[[array]]` header with the 0-based element `index`. `KeyValue.path`
|
|
727
|
+
* includes the final key. `Comment` covers both standalone (trivia) and
|
|
728
|
+
* trailing comments — see the module remarks for `offset`'s exact meaning.
|
|
729
|
+
*
|
|
730
|
+
* @public
|
|
731
|
+
*/
|
|
732
|
+
type TomlVisitorEvent = Data.TaggedEnum<{
|
|
733
|
+
TableStart: {
|
|
734
|
+
readonly path: ReadonlyArray<string>;
|
|
735
|
+
};
|
|
736
|
+
ArrayTableStart: {
|
|
737
|
+
readonly path: ReadonlyArray<string>;
|
|
738
|
+
readonly index: number;
|
|
739
|
+
};
|
|
740
|
+
KeyValue: {
|
|
741
|
+
readonly path: ReadonlyArray<string>;
|
|
742
|
+
readonly node: TomlKeyValue;
|
|
743
|
+
};
|
|
744
|
+
Comment: {
|
|
745
|
+
readonly text: string;
|
|
746
|
+
readonly offset: number;
|
|
747
|
+
};
|
|
748
|
+
}>;
|
|
749
|
+
/**
|
|
750
|
+
* Constructors and matchers for the `TomlVisitorEvent` union (e.g.
|
|
751
|
+
* `TomlVisitorEvent.KeyValue({ path, node })`, `TomlVisitorEvent.$is("Comment")`).
|
|
752
|
+
*
|
|
753
|
+
* @public
|
|
754
|
+
*/
|
|
755
|
+
declare const TomlVisitorEvent: {
|
|
756
|
+
readonly $is: <Tag extends "ArrayTableStart" | "Comment" | "KeyValue" | "TableStart">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
757
|
+
readonly _tag: "ArrayTableStart";
|
|
758
|
+
readonly path: ReadonlyArray<string>;
|
|
759
|
+
readonly index: number;
|
|
760
|
+
}, {
|
|
761
|
+
readonly _tag: Tag;
|
|
762
|
+
}> | Extract<{
|
|
763
|
+
readonly _tag: "Comment";
|
|
764
|
+
readonly text: string;
|
|
765
|
+
readonly offset: number;
|
|
766
|
+
}, {
|
|
767
|
+
readonly _tag: Tag;
|
|
768
|
+
}> | Extract<{
|
|
769
|
+
readonly _tag: "KeyValue";
|
|
770
|
+
readonly path: ReadonlyArray<string>;
|
|
771
|
+
readonly node: TomlKeyValue;
|
|
772
|
+
}, {
|
|
773
|
+
readonly _tag: Tag;
|
|
774
|
+
}> | Extract<{
|
|
775
|
+
readonly _tag: "TableStart";
|
|
776
|
+
readonly path: ReadonlyArray<string>;
|
|
777
|
+
}, {
|
|
778
|
+
readonly _tag: Tag;
|
|
779
|
+
}>;
|
|
780
|
+
readonly $match: {
|
|
781
|
+
<Cases extends {
|
|
782
|
+
readonly ArrayTableStart: (args: {
|
|
783
|
+
readonly _tag: "ArrayTableStart";
|
|
784
|
+
readonly path: ReadonlyArray<string>;
|
|
785
|
+
readonly index: number;
|
|
786
|
+
}) => any;
|
|
787
|
+
readonly Comment: (args: {
|
|
788
|
+
readonly _tag: "Comment";
|
|
789
|
+
readonly text: string;
|
|
790
|
+
readonly offset: number;
|
|
791
|
+
}) => any;
|
|
792
|
+
readonly KeyValue: (args: {
|
|
793
|
+
readonly _tag: "KeyValue";
|
|
794
|
+
readonly path: ReadonlyArray<string>;
|
|
795
|
+
readonly node: TomlKeyValue;
|
|
796
|
+
}) => any;
|
|
797
|
+
readonly TableStart: (args: {
|
|
798
|
+
readonly _tag: "TableStart";
|
|
799
|
+
readonly path: ReadonlyArray<string>;
|
|
800
|
+
}) => any;
|
|
801
|
+
}>(cases: Cases): (value: {
|
|
802
|
+
readonly _tag: "ArrayTableStart";
|
|
803
|
+
readonly path: ReadonlyArray<string>;
|
|
804
|
+
readonly index: number;
|
|
805
|
+
} | {
|
|
806
|
+
readonly _tag: "Comment";
|
|
807
|
+
readonly text: string;
|
|
808
|
+
readonly offset: number;
|
|
809
|
+
} | {
|
|
810
|
+
readonly _tag: "KeyValue";
|
|
811
|
+
readonly path: ReadonlyArray<string>;
|
|
812
|
+
readonly node: TomlKeyValue;
|
|
813
|
+
} | {
|
|
814
|
+
readonly _tag: "TableStart";
|
|
815
|
+
readonly path: ReadonlyArray<string>;
|
|
816
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["ArrayTableStart" | "Comment" | "KeyValue" | "TableStart"]>>;
|
|
817
|
+
<Cases extends {
|
|
818
|
+
readonly ArrayTableStart: (args: {
|
|
819
|
+
readonly _tag: "ArrayTableStart";
|
|
820
|
+
readonly path: ReadonlyArray<string>;
|
|
821
|
+
readonly index: number;
|
|
822
|
+
}) => any;
|
|
823
|
+
readonly Comment: (args: {
|
|
824
|
+
readonly _tag: "Comment";
|
|
825
|
+
readonly text: string;
|
|
826
|
+
readonly offset: number;
|
|
827
|
+
}) => any;
|
|
828
|
+
readonly KeyValue: (args: {
|
|
829
|
+
readonly _tag: "KeyValue";
|
|
830
|
+
readonly path: ReadonlyArray<string>;
|
|
831
|
+
readonly node: TomlKeyValue;
|
|
832
|
+
}) => any;
|
|
833
|
+
readonly TableStart: (args: {
|
|
834
|
+
readonly _tag: "TableStart";
|
|
835
|
+
readonly path: ReadonlyArray<string>;
|
|
836
|
+
}) => any;
|
|
837
|
+
}>(value: {
|
|
838
|
+
readonly _tag: "ArrayTableStart";
|
|
839
|
+
readonly path: ReadonlyArray<string>;
|
|
840
|
+
readonly index: number;
|
|
841
|
+
} | {
|
|
842
|
+
readonly _tag: "Comment";
|
|
843
|
+
readonly text: string;
|
|
844
|
+
readonly offset: number;
|
|
845
|
+
} | {
|
|
846
|
+
readonly _tag: "KeyValue";
|
|
847
|
+
readonly path: ReadonlyArray<string>;
|
|
848
|
+
readonly node: TomlKeyValue;
|
|
849
|
+
} | {
|
|
850
|
+
readonly _tag: "TableStart";
|
|
851
|
+
readonly path: ReadonlyArray<string>;
|
|
852
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["ArrayTableStart" | "Comment" | "KeyValue" | "TableStart"]>>;
|
|
853
|
+
};
|
|
854
|
+
readonly ArrayTableStart: Data.TaggedEnum.ConstructorFrom<{
|
|
855
|
+
readonly _tag: "ArrayTableStart";
|
|
856
|
+
readonly path: ReadonlyArray<string>;
|
|
857
|
+
readonly index: number;
|
|
858
|
+
}, "_tag">;
|
|
859
|
+
readonly Comment: Data.TaggedEnum.ConstructorFrom<{
|
|
860
|
+
readonly _tag: "Comment";
|
|
861
|
+
readonly text: string;
|
|
862
|
+
readonly offset: number;
|
|
863
|
+
}, "_tag">;
|
|
864
|
+
readonly KeyValue: Data.TaggedEnum.ConstructorFrom<{
|
|
865
|
+
readonly _tag: "KeyValue";
|
|
866
|
+
readonly path: ReadonlyArray<string>;
|
|
867
|
+
readonly node: TomlKeyValue;
|
|
868
|
+
}, "_tag">;
|
|
869
|
+
readonly TableStart: Data.TaggedEnum.ConstructorFrom<{
|
|
870
|
+
readonly _tag: "TableStart";
|
|
871
|
+
readonly path: ReadonlyArray<string>;
|
|
872
|
+
}, "_tag">;
|
|
873
|
+
};
|
|
874
|
+
/**
|
|
875
|
+
* SAX-style TOML visitor statics. Not instantiable.
|
|
876
|
+
*
|
|
877
|
+
* @public
|
|
878
|
+
*/
|
|
879
|
+
declare class TomlVisitor {
|
|
880
|
+
private constructor();
|
|
881
|
+
/**
|
|
882
|
+
* Create a `Stream` of `TomlVisitorEvent` from TOML text, in document
|
|
883
|
+
* order. Fails the stream with {@link TomlParseError} on the first
|
|
884
|
+
* lex/parse or semantic violation — never as an unhandled defect.
|
|
885
|
+
*
|
|
886
|
+
* @remarks
|
|
887
|
+
* Construction is eager, not on-demand: the full text is parsed, walked by
|
|
888
|
+
* `analyze` and sorted into document order up front, inside the `Effect`
|
|
889
|
+
* `Stream.unwrap` runs to build the stream. Only enumeration of the
|
|
890
|
+
* already-built event array is streamed — `Stream.take` still short-circuits
|
|
891
|
+
* consumption, but it does not avoid the initial parse/analyze/sort pass.
|
|
892
|
+
*/
|
|
893
|
+
static visit(text: string): Stream.Stream<TomlVisitorEvent, TomlParseError>;
|
|
894
|
+
}
|
|
895
|
+
//#endregion
|
|
896
|
+
export { Toml, TomlArray, TomlArrayTableHeader, TomlBoolean, TomlDateTimeLiteral, TomlDiagnostic, TomlDocument, TomlEdit, TomlErrorCode, TomlExpression, TomlFloat, TomlFormat, TomlFormattingOptions, TomlInlineEntry, TomlInlineTable, TomlInteger, TomlKey, TomlKeyKind, TomlKeyValue, TomlLexErrorCode, TomlLocalDate, TomlLocalDateTime, TomlLocalTime, TomlModificationError, TomlOffsetDateTime, TomlParseError, TomlParseErrorCode, type TomlPath, TomlRange, type TomlRangeLike, type TomlSegment, TomlSemanticErrorCode, TomlString, TomlStringStyle, TomlStringifyError, TomlStringifyErrorCode, TomlStringifyOptions, TomlTableHeader, TomlTrivia, TomlValueNode, TomlVisitor, TomlVisitorEvent };
|
|
897
|
+
//# sourceMappingURL=index.d.ts.map
|