@effected/yaml 0.5.1 → 0.6.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/README.md +12 -0
- package/YamlFormat.js +7 -4
- package/index.d.ts +71 -42
- package/internal/composer/block.js +22 -11
- package/internal/composer/flow.js +12 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,6 +73,17 @@ Effect.runPromise(Yaml.stringify({ port: 3000, hosts: ["a", "b"] })).then(consol
|
|
|
73
73
|
// - b
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
Both directions have a synchronous counterpart that returns a `Result` for callers that cannot await an Effect, a `vitest.config.ts` being the motivating case. `Yaml.parse` is defined in terms of `Yaml.parseResult`, so the two forms cannot disagree about what a document means:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { Yaml } from "@effected/yaml";
|
|
80
|
+
import { Result } from "effect";
|
|
81
|
+
|
|
82
|
+
const result = Yaml.parseResult("port: 3000 # dev server");
|
|
83
|
+
console.log(Result.isSuccess(result) ? result.success : result.failure);
|
|
84
|
+
// { port: 3000 }
|
|
85
|
+
```
|
|
86
|
+
|
|
76
87
|
## Hostile input fails typed
|
|
77
88
|
|
|
78
89
|
An alias bomb — nested anchors whose expansion multiplies at every level — is bounded by an expansion budget and surfaces as a `YamlParseError`, not as an out-of-memory kill:
|
|
@@ -99,6 +110,7 @@ Collection nesting past the depth cap behaves the same way, yielding a `NestingD
|
|
|
99
110
|
|
|
100
111
|
- `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`.
|
|
101
112
|
- `Yaml.stringify` — serialize a plain value back to YAML, failing typed with `YamlStringifyError` on circular references or on excessively deep nesting.
|
|
113
|
+
- `Yaml.parseResult` / `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.
|
|
102
114
|
- `Yaml.stripComments` — quote-aware comment removal that keeps line numbers stable, or every byte offset stable when given a replacement character.
|
|
103
115
|
- `Yaml.equals` / `Yaml.equalsValue` — semantic equality that ignores comments, whitespace, formatting and mapping key order while keeping sequence order significant.
|
|
104
116
|
- `Yaml.schema` / `Yaml.fromString` / `Yaml.YamlFromString` / `Yaml.allFromString` — string→domain schema factories that decode a single document or a whole stream into a validated Effect `Schema` value.
|
package/YamlFormat.js
CHANGED
|
@@ -106,7 +106,7 @@ function formatDocument(text, options) {
|
|
|
106
106
|
const doc = composeFirstDocument(text, {});
|
|
107
107
|
if (doc.errors.some((e) => isFatalCode(e.code))) return void 0;
|
|
108
108
|
const preserveComments = options?.preserveComments ?? true;
|
|
109
|
-
|
|
109
|
+
const outputDoc = {
|
|
110
110
|
contents: !preserveComments && doc.contents !== null ? stripNodeComments(doc.contents) : doc.contents,
|
|
111
111
|
errors: doc.errors,
|
|
112
112
|
warnings: doc.warnings,
|
|
@@ -115,7 +115,8 @@ function formatDocument(text, options) {
|
|
|
115
115
|
hasDocumentStart: doc.hasDocumentStart,
|
|
116
116
|
hasDocumentEnd: doc.hasDocumentEnd,
|
|
117
117
|
hasDocumentStartTab: doc.hasDocumentStartTab
|
|
118
|
-
}
|
|
118
|
+
};
|
|
119
|
+
return stringifyDocument(outputDoc, toStringifyInput(options));
|
|
119
120
|
}
|
|
120
121
|
/** Convert a plain JS scalar value into a synthetic `YamlScalar` (offset/length are irrelevant — immediately re-stringified). */
|
|
121
122
|
function jsValueToNode(value) {
|
|
@@ -317,10 +318,12 @@ var YamlFormat = class YamlFormat {
|
|
|
317
318
|
}, text)]
|
|
318
319
|
});
|
|
319
320
|
}
|
|
320
|
-
|
|
321
|
+
const outputDoc = {
|
|
321
322
|
...doc,
|
|
322
323
|
contents: newContents
|
|
323
|
-
}
|
|
324
|
+
};
|
|
325
|
+
const formatted = stringifyDocument(outputDoc, toStringifyInput(options));
|
|
326
|
+
return computeEdits(text, formatted).map((e) => YamlEdit.make(e));
|
|
324
327
|
});
|
|
325
328
|
/**
|
|
326
329
|
* Modify `text` and apply the resulting edits in one step
|
package/index.d.ts
CHANGED
|
@@ -687,6 +687,35 @@ declare class YamlAlias extends YamlAlias_base {
|
|
|
687
687
|
/** See `YamlScalar.toValue`. Pure and total. */
|
|
688
688
|
toValue(anchors?: Map<string, YamlNode>): unknown;
|
|
689
689
|
}
|
|
690
|
+
/**
|
|
691
|
+
* The encoded (plain-object) form of a {@link YamlScalar} — the class fields
|
|
692
|
+
* without the instance methods. Named so the recursive {@link (YamlNode:variable)}
|
|
693
|
+
* codec can state its encoded side without a circular type annotation.
|
|
694
|
+
*
|
|
695
|
+
* @public
|
|
696
|
+
*/
|
|
697
|
+
interface YamlScalarEncoded extends Schema.Codec.Encoded<typeof YamlScalar> {}
|
|
698
|
+
/**
|
|
699
|
+
* The encoded (plain-object) form of a {@link YamlMap}. See
|
|
700
|
+
* {@link YamlScalarEncoded} for why the encoded forms are named interfaces.
|
|
701
|
+
*
|
|
702
|
+
* @public
|
|
703
|
+
*/
|
|
704
|
+
interface YamlMapEncoded extends Schema.Codec.Encoded<typeof YamlMap> {}
|
|
705
|
+
/**
|
|
706
|
+
* The encoded (plain-object) form of a {@link YamlSeq}. See
|
|
707
|
+
* {@link YamlScalarEncoded} for why the encoded forms are named interfaces.
|
|
708
|
+
*
|
|
709
|
+
* @public
|
|
710
|
+
*/
|
|
711
|
+
interface YamlSeqEncoded extends Schema.Codec.Encoded<typeof YamlSeq> {}
|
|
712
|
+
/**
|
|
713
|
+
* The encoded (plain-object) form of a {@link YamlAlias}. See
|
|
714
|
+
* {@link YamlScalarEncoded} for why the encoded forms are named interfaces.
|
|
715
|
+
*
|
|
716
|
+
* @public
|
|
717
|
+
*/
|
|
718
|
+
interface YamlAliasEncoded extends Schema.Codec.Encoded<typeof YamlAlias> {}
|
|
690
719
|
/**
|
|
691
720
|
* A discriminated-union schema covering all four YAML AST value node types:
|
|
692
721
|
* {@link YamlScalar}, {@link YamlMap}, {@link YamlSeq} and {@link YamlAlias}.
|
|
@@ -701,7 +730,7 @@ declare class YamlAlias extends YamlAlias_base {
|
|
|
701
730
|
*
|
|
702
731
|
* @public
|
|
703
732
|
*/
|
|
704
|
-
declare const YamlNode: Schema.
|
|
733
|
+
declare const YamlNode: Schema.Codec<YamlScalar | YamlMap | YamlSeq | YamlAlias, YamlScalarEncoded | YamlMapEncoded | YamlSeqEncoded | YamlAliasEncoded>;
|
|
705
734
|
/**
|
|
706
735
|
* The union of all YAML AST value node types.
|
|
707
736
|
*
|
|
@@ -709,8 +738,8 @@ declare const YamlNode: Schema.Schema<YamlScalar | YamlMap | YamlSeq | YamlAlias
|
|
|
709
738
|
*/
|
|
710
739
|
type YamlNode = YamlScalar | YamlMap | YamlSeq | YamlAlias;
|
|
711
740
|
declare const YamlPair_base: Schema.Class<YamlPair, Schema.TaggedStruct<"YamlPair", {
|
|
712
|
-
readonly key: Schema.suspend<Schema.
|
|
713
|
-
readonly value: Schema.NullOr<Schema.suspend<Schema.
|
|
741
|
+
readonly key: Schema.suspend<Schema.Codec<YamlAlias | YamlMap | YamlScalar | YamlSeq, YamlAliasEncoded | YamlMapEncoded | YamlScalarEncoded | YamlSeqEncoded, never, never>>;
|
|
742
|
+
readonly value: Schema.NullOr<Schema.suspend<Schema.Codec<YamlAlias | YamlMap | YamlScalar | YamlSeq, YamlAliasEncoded | YamlMapEncoded | YamlScalarEncoded | YamlSeqEncoded, never, never>>>;
|
|
714
743
|
readonly comment: Schema.optionalKey<Schema.String>;
|
|
715
744
|
}>, {}>;
|
|
716
745
|
/**
|
|
@@ -721,7 +750,7 @@ declare const YamlPair_base: Schema.Class<YamlPair, Schema.TaggedStruct<"YamlPai
|
|
|
721
750
|
*/
|
|
722
751
|
declare class YamlPair extends YamlPair_base {}
|
|
723
752
|
declare const YamlMap_base: Schema.Class<YamlMap, Schema.TaggedStruct<"YamlMap", {
|
|
724
|
-
readonly items: Schema.$Array<Schema.suspend<
|
|
753
|
+
readonly items: Schema.$Array<Schema.suspend<typeof YamlPair>>;
|
|
725
754
|
readonly tag: Schema.optionalKey<Schema.String>;
|
|
726
755
|
readonly anchor: Schema.optionalKey<Schema.String>;
|
|
727
756
|
readonly style: Schema.Literals<readonly ["block", "flow"]>;
|
|
@@ -751,7 +780,7 @@ declare class YamlMap extends YamlMap_base {
|
|
|
751
780
|
toValue(anchors?: Map<string, YamlNode>): unknown;
|
|
752
781
|
}
|
|
753
782
|
declare const YamlSeq_base: Schema.Class<YamlSeq, Schema.TaggedStruct<"YamlSeq", {
|
|
754
|
-
readonly items: Schema.$Array<Schema.suspend<Schema.
|
|
783
|
+
readonly items: Schema.$Array<Schema.suspend<Schema.Codec<YamlAlias | YamlMap | YamlScalar | YamlSeq, YamlAliasEncoded | YamlMapEncoded | YamlScalarEncoded | YamlSeqEncoded, never, never>>>;
|
|
755
784
|
readonly tag: Schema.optionalKey<Schema.String>;
|
|
756
785
|
readonly anchor: Schema.optionalKey<Schema.String>;
|
|
757
786
|
readonly style: Schema.Literals<readonly ["block", "flow"]>;
|
|
@@ -1139,8 +1168,8 @@ declare const YamlVisitorEvent: {
|
|
|
1139
1168
|
readonly path: YamlPath;
|
|
1140
1169
|
readonly depth: number;
|
|
1141
1170
|
readonly style: CollectionStyle;
|
|
1142
|
-
readonly tag?: string
|
|
1143
|
-
readonly anchor?: string
|
|
1171
|
+
readonly tag?: string;
|
|
1172
|
+
readonly anchor?: string;
|
|
1144
1173
|
}, {
|
|
1145
1174
|
readonly _tag: Tag;
|
|
1146
1175
|
}> | Extract<{
|
|
@@ -1157,8 +1186,8 @@ declare const YamlVisitorEvent: {
|
|
|
1157
1186
|
readonly depth: number;
|
|
1158
1187
|
readonly value: unknown;
|
|
1159
1188
|
readonly style: ScalarStyle;
|
|
1160
|
-
readonly tag?: string
|
|
1161
|
-
readonly anchor?: string
|
|
1189
|
+
readonly tag?: string;
|
|
1190
|
+
readonly anchor?: string;
|
|
1162
1191
|
}, {
|
|
1163
1192
|
readonly _tag: Tag;
|
|
1164
1193
|
}> | Extract<{
|
|
@@ -1172,8 +1201,8 @@ declare const YamlVisitorEvent: {
|
|
|
1172
1201
|
readonly path: YamlPath;
|
|
1173
1202
|
readonly depth: number;
|
|
1174
1203
|
readonly style: CollectionStyle;
|
|
1175
|
-
readonly tag?: string
|
|
1176
|
-
readonly anchor?: string
|
|
1204
|
+
readonly tag?: string;
|
|
1205
|
+
readonly anchor?: string;
|
|
1177
1206
|
}, {
|
|
1178
1207
|
readonly _tag: Tag;
|
|
1179
1208
|
}>;
|
|
@@ -1228,8 +1257,8 @@ declare const YamlVisitorEvent: {
|
|
|
1228
1257
|
readonly path: YamlPath;
|
|
1229
1258
|
readonly depth: number;
|
|
1230
1259
|
readonly style: CollectionStyle;
|
|
1231
|
-
readonly tag?: string
|
|
1232
|
-
readonly anchor?: string
|
|
1260
|
+
readonly tag?: string;
|
|
1261
|
+
readonly anchor?: string;
|
|
1233
1262
|
}) => any;
|
|
1234
1263
|
readonly Pair: (args: {
|
|
1235
1264
|
readonly _tag: "Pair";
|
|
@@ -1244,8 +1273,8 @@ declare const YamlVisitorEvent: {
|
|
|
1244
1273
|
readonly depth: number;
|
|
1245
1274
|
readonly value: unknown;
|
|
1246
1275
|
readonly style: ScalarStyle;
|
|
1247
|
-
readonly tag?: string
|
|
1248
|
-
readonly anchor?: string
|
|
1276
|
+
readonly tag?: string;
|
|
1277
|
+
readonly anchor?: string;
|
|
1249
1278
|
}) => any;
|
|
1250
1279
|
readonly SeqEnd: (args: {
|
|
1251
1280
|
readonly _tag: "SeqEnd";
|
|
@@ -1257,8 +1286,8 @@ declare const YamlVisitorEvent: {
|
|
|
1257
1286
|
readonly path: YamlPath;
|
|
1258
1287
|
readonly depth: number;
|
|
1259
1288
|
readonly style: CollectionStyle;
|
|
1260
|
-
readonly tag?: string
|
|
1261
|
-
readonly anchor?: string
|
|
1289
|
+
readonly tag?: string;
|
|
1290
|
+
readonly anchor?: string;
|
|
1262
1291
|
}) => any;
|
|
1263
1292
|
}>(cases: Cases): (value: {
|
|
1264
1293
|
readonly _tag: "Alias";
|
|
@@ -1302,8 +1331,8 @@ declare const YamlVisitorEvent: {
|
|
|
1302
1331
|
readonly path: YamlPath;
|
|
1303
1332
|
readonly depth: number;
|
|
1304
1333
|
readonly style: CollectionStyle;
|
|
1305
|
-
readonly tag?: string
|
|
1306
|
-
readonly anchor?: string
|
|
1334
|
+
readonly tag?: string;
|
|
1335
|
+
readonly anchor?: string;
|
|
1307
1336
|
} | {
|
|
1308
1337
|
readonly _tag: "Pair";
|
|
1309
1338
|
readonly path: YamlPath;
|
|
@@ -1316,8 +1345,8 @@ declare const YamlVisitorEvent: {
|
|
|
1316
1345
|
readonly depth: number;
|
|
1317
1346
|
readonly value: unknown;
|
|
1318
1347
|
readonly style: ScalarStyle;
|
|
1319
|
-
readonly tag?: string
|
|
1320
|
-
readonly anchor?: string
|
|
1348
|
+
readonly tag?: string;
|
|
1349
|
+
readonly anchor?: string;
|
|
1321
1350
|
} | {
|
|
1322
1351
|
readonly _tag: "SeqEnd";
|
|
1323
1352
|
readonly path: YamlPath;
|
|
@@ -1327,8 +1356,8 @@ declare const YamlVisitorEvent: {
|
|
|
1327
1356
|
readonly path: YamlPath;
|
|
1328
1357
|
readonly depth: number;
|
|
1329
1358
|
readonly style: CollectionStyle;
|
|
1330
|
-
readonly tag?: string
|
|
1331
|
-
readonly anchor?: string
|
|
1359
|
+
readonly tag?: string;
|
|
1360
|
+
readonly anchor?: string;
|
|
1332
1361
|
}) => import("effect/Unify").Unify<ReturnType<Cases["Alias" | "Comment" | "Directive" | "DocumentEnd" | "DocumentStart" | "Error" | "MapEnd" | "MapStart" | "Pair" | "Scalar" | "SeqEnd" | "SeqStart"]>>;
|
|
1333
1362
|
<Cases extends {
|
|
1334
1363
|
readonly Alias: (args: {
|
|
@@ -1380,8 +1409,8 @@ declare const YamlVisitorEvent: {
|
|
|
1380
1409
|
readonly path: YamlPath;
|
|
1381
1410
|
readonly depth: number;
|
|
1382
1411
|
readonly style: CollectionStyle;
|
|
1383
|
-
readonly tag?: string
|
|
1384
|
-
readonly anchor?: string
|
|
1412
|
+
readonly tag?: string;
|
|
1413
|
+
readonly anchor?: string;
|
|
1385
1414
|
}) => any;
|
|
1386
1415
|
readonly Pair: (args: {
|
|
1387
1416
|
readonly _tag: "Pair";
|
|
@@ -1396,8 +1425,8 @@ declare const YamlVisitorEvent: {
|
|
|
1396
1425
|
readonly depth: number;
|
|
1397
1426
|
readonly value: unknown;
|
|
1398
1427
|
readonly style: ScalarStyle;
|
|
1399
|
-
readonly tag?: string
|
|
1400
|
-
readonly anchor?: string
|
|
1428
|
+
readonly tag?: string;
|
|
1429
|
+
readonly anchor?: string;
|
|
1401
1430
|
}) => any;
|
|
1402
1431
|
readonly SeqEnd: (args: {
|
|
1403
1432
|
readonly _tag: "SeqEnd";
|
|
@@ -1409,8 +1438,8 @@ declare const YamlVisitorEvent: {
|
|
|
1409
1438
|
readonly path: YamlPath;
|
|
1410
1439
|
readonly depth: number;
|
|
1411
1440
|
readonly style: CollectionStyle;
|
|
1412
|
-
readonly tag?: string
|
|
1413
|
-
readonly anchor?: string
|
|
1441
|
+
readonly tag?: string;
|
|
1442
|
+
readonly anchor?: string;
|
|
1414
1443
|
}) => any;
|
|
1415
1444
|
}>(value: {
|
|
1416
1445
|
readonly _tag: "Alias";
|
|
@@ -1454,8 +1483,8 @@ declare const YamlVisitorEvent: {
|
|
|
1454
1483
|
readonly path: YamlPath;
|
|
1455
1484
|
readonly depth: number;
|
|
1456
1485
|
readonly style: CollectionStyle;
|
|
1457
|
-
readonly tag?: string
|
|
1458
|
-
readonly anchor?: string
|
|
1486
|
+
readonly tag?: string;
|
|
1487
|
+
readonly anchor?: string;
|
|
1459
1488
|
} | {
|
|
1460
1489
|
readonly _tag: "Pair";
|
|
1461
1490
|
readonly path: YamlPath;
|
|
@@ -1468,8 +1497,8 @@ declare const YamlVisitorEvent: {
|
|
|
1468
1497
|
readonly depth: number;
|
|
1469
1498
|
readonly value: unknown;
|
|
1470
1499
|
readonly style: ScalarStyle;
|
|
1471
|
-
readonly tag?: string
|
|
1472
|
-
readonly anchor?: string
|
|
1500
|
+
readonly tag?: string;
|
|
1501
|
+
readonly anchor?: string;
|
|
1473
1502
|
} | {
|
|
1474
1503
|
readonly _tag: "SeqEnd";
|
|
1475
1504
|
readonly path: YamlPath;
|
|
@@ -1479,8 +1508,8 @@ declare const YamlVisitorEvent: {
|
|
|
1479
1508
|
readonly path: YamlPath;
|
|
1480
1509
|
readonly depth: number;
|
|
1481
1510
|
readonly style: CollectionStyle;
|
|
1482
|
-
readonly tag?: string
|
|
1483
|
-
readonly anchor?: string
|
|
1511
|
+
readonly tag?: string;
|
|
1512
|
+
readonly anchor?: string;
|
|
1484
1513
|
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Alias" | "Comment" | "Directive" | "DocumentEnd" | "DocumentStart" | "Error" | "MapEnd" | "MapStart" | "Pair" | "Scalar" | "SeqEnd" | "SeqStart"]>>;
|
|
1485
1514
|
};
|
|
1486
1515
|
readonly Alias: Data.TaggedEnum.ConstructorFrom<{
|
|
@@ -1532,8 +1561,8 @@ declare const YamlVisitorEvent: {
|
|
|
1532
1561
|
readonly path: YamlPath;
|
|
1533
1562
|
readonly depth: number;
|
|
1534
1563
|
readonly style: CollectionStyle;
|
|
1535
|
-
readonly tag?: string
|
|
1536
|
-
readonly anchor?: string
|
|
1564
|
+
readonly tag?: string;
|
|
1565
|
+
readonly anchor?: string;
|
|
1537
1566
|
}, "_tag">;
|
|
1538
1567
|
readonly Pair: Data.TaggedEnum.ConstructorFrom<{
|
|
1539
1568
|
readonly _tag: "Pair";
|
|
@@ -1548,8 +1577,8 @@ declare const YamlVisitorEvent: {
|
|
|
1548
1577
|
readonly depth: number;
|
|
1549
1578
|
readonly value: unknown;
|
|
1550
1579
|
readonly style: ScalarStyle;
|
|
1551
|
-
readonly tag?: string
|
|
1552
|
-
readonly anchor?: string
|
|
1580
|
+
readonly tag?: string;
|
|
1581
|
+
readonly anchor?: string;
|
|
1553
1582
|
}, "_tag">;
|
|
1554
1583
|
readonly SeqEnd: Data.TaggedEnum.ConstructorFrom<{
|
|
1555
1584
|
readonly _tag: "SeqEnd";
|
|
@@ -1561,8 +1590,8 @@ declare const YamlVisitorEvent: {
|
|
|
1561
1590
|
readonly path: YamlPath;
|
|
1562
1591
|
readonly depth: number;
|
|
1563
1592
|
readonly style: CollectionStyle;
|
|
1564
|
-
readonly tag?: string
|
|
1565
|
-
readonly anchor?: string
|
|
1593
|
+
readonly tag?: string;
|
|
1594
|
+
readonly anchor?: string;
|
|
1566
1595
|
}, "_tag">;
|
|
1567
1596
|
};
|
|
1568
1597
|
/**
|
|
@@ -1588,5 +1617,5 @@ declare class YamlVisitor {
|
|
|
1588
1617
|
static visit(text: string, options?: YamlParseOptions): Stream.Stream<YamlVisitorEvent>;
|
|
1589
1618
|
}
|
|
1590
1619
|
//#endregion
|
|
1591
|
-
export { CollectionStyle, QuoteStyle, ScalarChomp, ScalarStyle, Yaml, YamlAlias, type YamlBoundCodec, YamlComposerErrorCode, YamlDiagnostic, YamlDirective, YamlDocument, YamlEdit, YamlErrorCode, YamlFormat, YamlFormattingOptions, YamlLexErrorCode, YamlMap, YamlModificationError, YamlModifyErrorCode, YamlNode, YamlPair, YamlParseError, YamlParseErrorCode, YamlParseOptions, type YamlPath, YamlRange, type YamlRangeLike, YamlScalar, type YamlSegment, YamlSeq, YamlStringifyError, YamlStringifyErrorCode, YamlStringifyOptions, YamlVisitor, YamlVisitorEvent };
|
|
1620
|
+
export { CollectionStyle, QuoteStyle, ScalarChomp, ScalarStyle, Yaml, YamlAlias, type YamlAliasEncoded, type YamlBoundCodec, YamlComposerErrorCode, YamlDiagnostic, YamlDirective, YamlDocument, YamlEdit, YamlErrorCode, YamlFormat, YamlFormattingOptions, YamlLexErrorCode, YamlMap, type YamlMapEncoded, YamlModificationError, YamlModifyErrorCode, YamlNode, YamlPair, YamlParseError, YamlParseErrorCode, YamlParseOptions, type YamlPath, YamlRange, type YamlRangeLike, YamlScalar, type YamlScalarEncoded, type YamlSegment, YamlSeq, type YamlSeqEncoded, YamlStringifyError, YamlStringifyErrorCode, YamlStringifyOptions, YamlVisitor, YamlVisitorEvent };
|
|
1592
1621
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -39,11 +39,12 @@ function composeBlockMapInner(blockMapCst, state, externalFirstKey, meta) {
|
|
|
39
39
|
if (state.options.uniqueKeys) checkDuplicateKeys(pairs, state);
|
|
40
40
|
checkMultilineImplicitKeys(pairs, state);
|
|
41
41
|
const offset = externalFirstKey ? "offset" in externalFirstKey ? externalFirstKey.offset : blockMapCst.offset : blockMapCst.offset;
|
|
42
|
+
const length = blockMapCst.offset + blockMapCst.length - offset;
|
|
42
43
|
const map = new YamlMap({
|
|
43
44
|
items: pairs,
|
|
44
45
|
style: "block",
|
|
45
46
|
offset,
|
|
46
|
-
length
|
|
47
|
+
length,
|
|
47
48
|
...meta?.tag !== void 0 ? { tag: meta.tag } : {},
|
|
48
49
|
...meta?.anchor !== void 0 ? { anchor: meta.anchor } : {},
|
|
49
50
|
...meta?.comment !== void 0 ? { comment: meta.comment } : {}
|
|
@@ -135,11 +136,12 @@ function flattenBlockMapChildren(children, state, externalKeyColumn, externalKey
|
|
|
135
136
|
const firstC = findFirstContent(sliceChildren);
|
|
136
137
|
const lastC = findLastContent(sliceChildren);
|
|
137
138
|
const innerOffset = firstC ? firstC.offset : child.offset;
|
|
139
|
+
const innerEnd = lastC ? lastC.offset + lastC.length : child.offset + child.length;
|
|
138
140
|
pushNode(new YamlMap({
|
|
139
141
|
items: innerPairs,
|
|
140
142
|
style: "block",
|
|
141
143
|
offset: innerOffset,
|
|
142
|
-
length:
|
|
144
|
+
length: innerEnd - innerOffset
|
|
143
145
|
}), innerOffset);
|
|
144
146
|
i = lookahead.endIdx - 1;
|
|
145
147
|
continue;
|
|
@@ -150,8 +152,9 @@ function flattenBlockMapChildren(children, state, externalKeyColumn, externalKey
|
|
|
150
152
|
validateNoTabAfterContinuationValueSep(child, children, i, state);
|
|
151
153
|
const flushMeta = combinedPending();
|
|
152
154
|
if (hasMeta(flushMeta)) {
|
|
155
|
+
const value = resolveScalar("", "plain", flushMeta.tag, state);
|
|
153
156
|
const scalar = new YamlScalar({
|
|
154
|
-
value
|
|
157
|
+
value,
|
|
155
158
|
style: "plain",
|
|
156
159
|
offset: child.offset,
|
|
157
160
|
length: 0,
|
|
@@ -211,8 +214,9 @@ function flattenBlockMapChildren(children, state, externalKeyColumn, externalKey
|
|
|
211
214
|
if (afterValueSep && sepOnSameLine) {
|
|
212
215
|
const flushMeta = combinedPending();
|
|
213
216
|
if (hasMeta(flushMeta)) {
|
|
217
|
+
const value = resolveScalar("", "plain", flushMeta.tag, state);
|
|
214
218
|
const scalar = new YamlScalar({
|
|
215
|
-
value
|
|
219
|
+
value,
|
|
216
220
|
style: "plain",
|
|
217
221
|
offset: child.offset,
|
|
218
222
|
length: 0,
|
|
@@ -277,8 +281,9 @@ function flattenBlockMapChildren(children, state, externalKeyColumn, externalKey
|
|
|
277
281
|
if (isExplicitKey) {
|
|
278
282
|
const { value: keyValue, nextIdx: keyNextIdx } = collectMultilineKey(children, i);
|
|
279
283
|
const keyMeta = combinedPending();
|
|
284
|
+
const resolved = resolveScalar(keyValue, "plain", keyMeta.tag, state);
|
|
280
285
|
const scalar = new YamlScalar({
|
|
281
|
-
value:
|
|
286
|
+
value: resolved,
|
|
282
287
|
style: "plain",
|
|
283
288
|
offset: child.offset,
|
|
284
289
|
length: child.length,
|
|
@@ -386,7 +391,8 @@ function flattenBlockMapChildren(children, state, externalKeyColumn, externalKey
|
|
|
386
391
|
i = nextAlias.idx;
|
|
387
392
|
continue;
|
|
388
393
|
}
|
|
389
|
-
|
|
394
|
+
const aliasMeta = combinedPending();
|
|
395
|
+
checkAnchorOnAlias(aliasMeta, child, state);
|
|
390
396
|
const alias = makeAlias(child, state);
|
|
391
397
|
resetAllMeta();
|
|
392
398
|
pushNode(alias);
|
|
@@ -451,8 +457,9 @@ function flattenBlockMapChildren(children, state, externalKeyColumn, externalKey
|
|
|
451
457
|
}
|
|
452
458
|
const trailingMeta = combinedPending();
|
|
453
459
|
if (hasMeta(trailingMeta)) {
|
|
460
|
+
const value = resolveScalar("", "plain", trailingMeta.tag, state);
|
|
454
461
|
const scalar = new YamlScalar({
|
|
455
|
-
value
|
|
462
|
+
value,
|
|
456
463
|
style: "plain",
|
|
457
464
|
offset: 0,
|
|
458
465
|
length: 0,
|
|
@@ -643,7 +650,8 @@ function keyIdentity(key, text) {
|
|
|
643
650
|
case "string": return `s:${v}`;
|
|
644
651
|
case "bigint": return `i:${v.toString()}`;
|
|
645
652
|
case "number": {
|
|
646
|
-
|
|
653
|
+
const raw = text.slice(key.offset, key.offset + key.length).trim();
|
|
654
|
+
let kind = classifyPlainNumeric(raw);
|
|
647
655
|
if (key.tag !== void 0) {
|
|
648
656
|
if (key.tag.includes("float")) kind = "float";
|
|
649
657
|
else if (key.tag.includes("int")) kind = "int";
|
|
@@ -1012,8 +1020,9 @@ function composeBlockSeqInner(cst, state, meta) {
|
|
|
1012
1020
|
if (child.type === "flow-scalar" && getScalarStyle(child) === "plain") {
|
|
1013
1021
|
const { value: merged, nextIdx: mergeEnd, partsCount, endOffset } = collectMultilinePlainScalar(children, ci, void 0, state.text);
|
|
1014
1022
|
if (partsCount > 1) {
|
|
1023
|
+
const resolved = resolveScalar(merged, "plain", pendingMeta.tag, state);
|
|
1015
1024
|
const scalar = new YamlScalar({
|
|
1016
|
-
value:
|
|
1025
|
+
value: resolved,
|
|
1017
1026
|
style: "plain",
|
|
1018
1027
|
offset: child.offset,
|
|
1019
1028
|
length: endOffset - child.offset,
|
|
@@ -1100,8 +1109,9 @@ function composeBlockSeqInner(cst, state, meta) {
|
|
|
1100
1109
|
length: 0
|
|
1101
1110
|
}));
|
|
1102
1111
|
if (hasMeta(pendingMeta)) {
|
|
1112
|
+
const value = resolveScalar("", "plain", pendingMeta.tag, state);
|
|
1103
1113
|
const scalar = new YamlScalar({
|
|
1104
|
-
value
|
|
1114
|
+
value,
|
|
1105
1115
|
style: "plain",
|
|
1106
1116
|
offset: 0,
|
|
1107
1117
|
length: 0,
|
|
@@ -1138,11 +1148,12 @@ function composeFlatBlockMap(children, startIdx, parentCst, state, externalFirst
|
|
|
1138
1148
|
if (state.options.uniqueKeys) checkDuplicateKeys(pairs, state);
|
|
1139
1149
|
checkMultilineImplicitKeys(pairs, state);
|
|
1140
1150
|
const offset = "offset" in externalFirstKey ? externalFirstKey.offset : parentCst.offset;
|
|
1151
|
+
const end = parentCst.offset + parentCst.length;
|
|
1141
1152
|
const map = new YamlMap({
|
|
1142
1153
|
items: pairs,
|
|
1143
1154
|
style: "block",
|
|
1144
1155
|
offset,
|
|
1145
|
-
length:
|
|
1156
|
+
length: end - offset,
|
|
1146
1157
|
...meta?.tag !== void 0 ? { tag: meta.tag } : {},
|
|
1147
1158
|
...meta?.anchor !== void 0 ? { anchor: meta.anchor } : {},
|
|
1148
1159
|
...meta?.comment !== void 0 ? { comment: meta.comment } : {}
|
|
@@ -116,7 +116,8 @@ function composeFlowMapInner(cst, state, meta, parentBlockColumn) {
|
|
|
116
116
|
});
|
|
117
117
|
validateFlowContentIndent(cst, state, parentBlockColumn);
|
|
118
118
|
validateFlowSeparators(children, state, "{", "}");
|
|
119
|
-
|
|
119
|
+
const items = flattenFlowChildren(children.filter((c) => !(c.type === "whitespace" && (c.source === "{" || c.source === "}" || c.source.trim() === ""))), state);
|
|
120
|
+
buildPairs(items, pairs, state.text);
|
|
120
121
|
if (state.options.uniqueKeys) checkDuplicateKeys(pairs, state);
|
|
121
122
|
const map = new YamlMap({
|
|
122
123
|
items: pairs,
|
|
@@ -140,8 +141,9 @@ function flattenFlowChildren(children, state) {
|
|
|
140
141
|
if (child.type === "whitespace") {
|
|
141
142
|
if (child.source === ",") {
|
|
142
143
|
if (hasMeta(pendingMeta)) {
|
|
144
|
+
const value = resolveScalar("", "plain", pendingMeta.tag, state);
|
|
143
145
|
const scalar = new YamlScalar({
|
|
144
|
-
value
|
|
146
|
+
value,
|
|
145
147
|
style: "plain",
|
|
146
148
|
offset: child.offset,
|
|
147
149
|
length: 0,
|
|
@@ -159,8 +161,9 @@ function flattenFlowChildren(children, state) {
|
|
|
159
161
|
}
|
|
160
162
|
if (child.source === ":") {
|
|
161
163
|
if (hasMeta(pendingMeta)) {
|
|
164
|
+
const value = resolveScalar("", "plain", pendingMeta.tag, state);
|
|
162
165
|
const scalar = new YamlScalar({
|
|
163
|
-
value
|
|
166
|
+
value,
|
|
164
167
|
style: "plain",
|
|
165
168
|
offset: child.offset,
|
|
166
169
|
length: 0,
|
|
@@ -225,8 +228,9 @@ function flattenFlowChildren(children, state) {
|
|
|
225
228
|
if (child.type === "flow-scalar" && getScalarStyle(child) === "plain") {
|
|
226
229
|
if (hasValueSepThroughPlainScalars(children, i + 1)) {
|
|
227
230
|
const { value, nextIdx } = collectMultilineKey(children, i);
|
|
231
|
+
const resolved = resolveScalar(value, "plain", pendingMeta.tag, state);
|
|
228
232
|
const scalar = new YamlScalar({
|
|
229
|
-
value:
|
|
233
|
+
value: resolved,
|
|
230
234
|
style: "plain",
|
|
231
235
|
offset: child.offset,
|
|
232
236
|
length: child.length,
|
|
@@ -243,8 +247,9 @@ function flattenFlowChildren(children, state) {
|
|
|
243
247
|
continue;
|
|
244
248
|
}
|
|
245
249
|
const { value, nextIdx, partsCount, endOffset } = collectMultilinePlainScalar(children, i, void 0, state.text);
|
|
250
|
+
const resolved = resolveScalar(value, "plain", pendingMeta.tag, state);
|
|
246
251
|
const scalar = new YamlScalar({
|
|
247
|
-
value:
|
|
252
|
+
value: resolved,
|
|
248
253
|
style: "plain",
|
|
249
254
|
offset: child.offset,
|
|
250
255
|
length: partsCount > 1 ? endOffset - child.offset : child.length,
|
|
@@ -297,8 +302,9 @@ function flattenFlowChildren(children, state) {
|
|
|
297
302
|
}
|
|
298
303
|
}
|
|
299
304
|
if (hasMeta(pendingMeta)) {
|
|
305
|
+
const value = resolveScalar("", "plain", pendingMeta.tag, state);
|
|
300
306
|
const scalar = new YamlScalar({
|
|
301
|
-
value
|
|
307
|
+
value,
|
|
302
308
|
style: "plain",
|
|
303
309
|
offset: 0,
|
|
304
310
|
length: 0,
|