@elaraai/east 1.0.70 → 1.0.72
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/dist/src/expr/libs/string.d.ts +15 -2
- package/dist/src/expr/libs/string.d.ts.map +1 -1
- package/dist/src/expr/libs/string.js +15 -2
- package/dist/src/expr/libs/string.js.map +1 -1
- package/dist/src/location.d.ts +12 -0
- package/dist/src/location.d.ts.map +1 -1
- package/dist/src/location.js +15 -3
- package/dist/src/location.js.map +1 -1
- package/dist/src/serialization/index.d.ts +2 -0
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +2 -0
- package/dist/src/serialization/index.js.map +1 -1
- package/dist/src/serialization/json.d.ts +43 -2
- package/dist/src/serialization/json.d.ts.map +1 -1
- package/dist/src/serialization/json.js +138 -9
- package/dist/src/serialization/json.js.map +1 -1
- package/dist/src/serialization/json.spec.js +99 -15
- package/dist/src/serialization/json.spec.js.map +1 -1
- package/dist/src/serialization/json_schema.d.ts +81 -0
- package/dist/src/serialization/json_schema.d.ts.map +1 -0
- package/dist/src/serialization/json_schema.js +305 -0
- package/dist/src/serialization/json_schema.js.map +1 -0
- package/dist/src/serialization/json_schema.spec.d.ts +2 -0
- package/dist/src/serialization/json_schema.spec.d.ts.map +1 -0
- package/dist/src/serialization/json_schema.spec.js +427 -0
- package/dist/src/serialization/json_schema.spec.js.map +1 -0
- package/dist/src/serialization/json_schema_to_type.d.ts +76 -0
- package/dist/src/serialization/json_schema_to_type.d.ts.map +1 -0
- package/dist/src/serialization/json_schema_to_type.js +576 -0
- package/dist/src/serialization/json_schema_to_type.js.map +1 -0
- package/dist/src/serialization/json_schema_to_type.spec.d.ts +2 -0
- package/dist/src/serialization/json_schema_to_type.spec.d.ts.map +1 -0
- package/dist/src/serialization/json_schema_to_type.spec.js +428 -0
- package/dist/src/serialization/json_schema_to_type.spec.js.map +1 -0
- package/package.json +2 -1
|
@@ -52,7 +52,7 @@ declare const _default: {
|
|
|
52
52
|
* $.return(East.String.printJson(person));
|
|
53
53
|
* });
|
|
54
54
|
* const compiled = East.compile(toJson.toIR(), []);
|
|
55
|
-
* compiled({ name: "Alice", age: 30n }); // '{"name":"Alice","age":30}'
|
|
55
|
+
* compiled({ name: "Alice", age: 30n }); // '{"name":"Alice","age":"30"}' — an Integer is a decimal string
|
|
56
56
|
* ```
|
|
57
57
|
*
|
|
58
58
|
* @example
|
|
@@ -62,7 +62,20 @@ declare const _default: {
|
|
|
62
62
|
* $.return(East.String.printJson(arr));
|
|
63
63
|
* });
|
|
64
64
|
* const compiled = East.compile(arrayToJson.toIR(), []);
|
|
65
|
-
* compiled([1n, 2n, 3n]); // '[1,2,3]'
|
|
65
|
+
* compiled([1n, 2n, 3n]); // '["1","2","3"]'
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* // An Option is null for none and the payload itself for some, wherever the
|
|
71
|
+
* // payload cannot itself encode as null (Option<Null> and Option<Option<T>>
|
|
72
|
+
* // keep the tagged {"type": …, "value": …} object)
|
|
73
|
+
* const optionToJson = East.function([OptionType(StringType)], StringType, ($, note) => {
|
|
74
|
+
* $.return(East.String.printJson(note));
|
|
75
|
+
* });
|
|
76
|
+
* const compiled = East.compile(optionToJson.toIR(), []);
|
|
77
|
+
* compiled(none); // 'null'
|
|
78
|
+
* compiled(some("x")); // '"x"'
|
|
66
79
|
* ```
|
|
67
80
|
*/
|
|
68
81
|
printJson(value: Expr): StringExpr;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/expr/libs/string.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,yCAAyC;;IAEvC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;wBACiB,UAAU,SAAS,SAAS,CAAC,UAAU,CAAC;QAAE,QAAQ,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC,GAAG,UAAU;IAI3I
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../src/expr/libs/string.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,yCAAyC;;IAEvC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;wBACiB,UAAU,SAAS,SAAS,CAAC,UAAU,CAAC;QAAE,QAAQ,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC,GAAG,UAAU;IAI3I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;qBACc,IAAI,GAAG,UAAU;;AAtEpC,wBAgFC"}
|
|
@@ -49,7 +49,7 @@ export default {
|
|
|
49
49
|
* $.return(East.String.printJson(person));
|
|
50
50
|
* });
|
|
51
51
|
* const compiled = East.compile(toJson.toIR(), []);
|
|
52
|
-
* compiled({ name: "Alice", age: 30n }); // '{"name":"Alice","age":30}'
|
|
52
|
+
* compiled({ name: "Alice", age: 30n }); // '{"name":"Alice","age":"30"}' — an Integer is a decimal string
|
|
53
53
|
* ```
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
@@ -59,7 +59,20 @@ export default {
|
|
|
59
59
|
* $.return(East.String.printJson(arr));
|
|
60
60
|
* });
|
|
61
61
|
* const compiled = East.compile(arrayToJson.toIR(), []);
|
|
62
|
-
* compiled([1n, 2n, 3n]); // '[1,2,3]'
|
|
62
|
+
* compiled([1n, 2n, 3n]); // '["1","2","3"]'
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* // An Option is null for none and the payload itself for some, wherever the
|
|
68
|
+
* // payload cannot itself encode as null (Option<Null> and Option<Option<T>>
|
|
69
|
+
* // keep the tagged {"type": …, "value": …} object)
|
|
70
|
+
* const optionToJson = East.function([OptionType(StringType)], StringType, ($, note) => {
|
|
71
|
+
* $.return(East.String.printJson(note));
|
|
72
|
+
* });
|
|
73
|
+
* const compiled = East.compile(optionToJson.toIR(), []);
|
|
74
|
+
* compiled(none); // 'null'
|
|
75
|
+
* compiled(some("x")); // '"x"'
|
|
63
76
|
* ```
|
|
64
77
|
*/
|
|
65
78
|
printJson(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../src/expr/libs/string.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAmB,UAAU,EAAoB,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlC,yCAAyC;AACzC,eAAe;IACb;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,UAAU,CAAC,OAAmB,EAAE,KAA8F;QAC5H,OAAO,IAAI,CAAC,GAAG,CAAA,UAAU,OAAO,SAAS,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE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}
|
package/dist/src/location.d.ts
CHANGED
|
@@ -82,6 +82,18 @@ export declare function setLocationBasePath(base: string | undefined): void;
|
|
|
82
82
|
* path is under it. Exported for testing. Never throws.
|
|
83
83
|
*/
|
|
84
84
|
export declare function normalizeFramePath(raw: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Parse a stack string into the author's source locations, innermost first.
|
|
87
|
+
*
|
|
88
|
+
* The filtering is the same one {@link get_location} applies while building a
|
|
89
|
+
* node: East's own frames, node internals and installed packages drop out, so
|
|
90
|
+
* the result heads with the line the author wrote.
|
|
91
|
+
*
|
|
92
|
+
* @param stack - An `Error.stack` string, or undefined
|
|
93
|
+
* @returns The author's locations, innermost first; empty when the stack is
|
|
94
|
+
* absent or holds no author frame
|
|
95
|
+
*/
|
|
96
|
+
export declare function locationsFromStack(stack: string | undefined): Location[];
|
|
85
97
|
export declare function get_location(): Location[];
|
|
86
98
|
/** Reserved sentinel: resolve(0n) returns [], the "no/unknown location" id. */
|
|
87
99
|
export declare const UNKNOWN_LOC_ID: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/location.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAExD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAM5D;AAED;;;;;;;GAOG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,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AQ,CAAC,MAAM,CAAsB;IAC7C,0DAA0D;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IAEpD;2EACuE;IACvE,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM;IAWvC,oFAAoF;IACpF,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,QAAQ,EAAE;IAI5C,8EAA8E;IAC9E,IAAI,IAAI,IAAI,MAAM,CAAuC;IAEzD,6EAA6E;IAC7E,OAAO,IAAI,SAAS,QAAQ,EAAE,EAAE;CACjC;AAeD;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,MAAM,CAKrE;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAajE;AAED;6CAC6C;AAC7C,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAGnD;AAED,mFAAmF;AACnF,wBAAgB,sBAAsB,IAAI,SAAS,GAAG,IAAI,CAEzD;AAED;uDACuD;AACvD,wBAAgB,eAAe,IAAI,MAAM,CAIxC"}
|
package/dist/src/location.js
CHANGED
|
@@ -209,9 +209,18 @@ export function normalizeFramePath(raw) {
|
|
|
209
209
|
return raw;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
/**
|
|
213
|
+
* Parse a stack string into the author's source locations, innermost first.
|
|
214
|
+
*
|
|
215
|
+
* The filtering is the same one {@link get_location} applies while building a
|
|
216
|
+
* node: East's own frames, node internals and installed packages drop out, so
|
|
217
|
+
* the result heads with the line the author wrote.
|
|
218
|
+
*
|
|
219
|
+
* @param stack - An `Error.stack` string, or undefined
|
|
220
|
+
* @returns The author's locations, innermost first; empty when the stack is
|
|
221
|
+
* absent or holds no author frame
|
|
222
|
+
*/
|
|
223
|
+
export function locationsFromStack(stack) {
|
|
215
224
|
if (!stack)
|
|
216
225
|
return [];
|
|
217
226
|
const lines = stack.split('\n').slice(1); // Skip "Error" line
|
|
@@ -230,6 +239,9 @@ function capture_stack_frames() {
|
|
|
230
239
|
}
|
|
231
240
|
return frames;
|
|
232
241
|
}
|
|
242
|
+
function capture_stack_frames() {
|
|
243
|
+
return locationsFromStack(new Error().stack);
|
|
244
|
+
}
|
|
233
245
|
export function get_location() {
|
|
234
246
|
return capture_stack_frames();
|
|
235
247
|
}
|
package/dist/src/location.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location.js","sourceRoot":"","sources":["../../src/location.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC9C,OAAO,GAAG,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;AACpE,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,SAAqB;IAClD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAC/C,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IACnC,MAAM,MAAM,GAAG,aAAa,CAAC,KAAM,CAAC,CAAC;IACrC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IACrC,OAAO,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClF,CAAC;AAED;;;;;;;GAOG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CAAC,SAA6B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Y,KAAK;YAAE,CAAC,CAAC,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAClE,MAAM,CAAC,CAAC;IACV,CAAC;YAAS,CAAC;QACT,WAAW,GAAG,IAAI,CAAC;IACrB,CAAC;AACH,CAAC;AAED;6CAC6C;AAC7C,MAAM,UAAU,iBAAiB,CAAI,EAAW;IAC9C,IAAI,WAAW;QAAE,OAAO,EAAE,EAAE,CAAC;IAC7B,OAAO,eAAe,CAAC,IAAI,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,sBAAsB;IACpC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;uDACuD;AACvD,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,WAAW;QAAE,OAAO,cAAc,CAAC;IACxC,MAAM,KAAK,GAAG,oBAAoB,EAAE,CAAC;IACrC,OAAO,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -7,5 +7,7 @@ export * from "./binary-utils.js";
|
|
|
7
7
|
export * from "./beast.js";
|
|
8
8
|
export { encodeBeast2For, decodeBeast2For, decodeBeast2ForAsync, decodeBeast2, compileFunctionIR, compileAsyncFunctionIR, encodeEastIR, decodeEastIR, decodeAsyncEastIR, Beast2Writer, encodeBeast2SegmentsFor, encodeBeast2PagedFor, iterBeast2SegmentsFor, Beast2Pages, openBeast2PagesFor, beast2HasIndex, readBeast2Type, readBeast2Extents, carveBeast2, spliceBeast2, rebuildBeast2, openBeast2LazyFor, isBeast2LazySafe, readBeast2ExtentsRanged, readBeast2ExtentsSync, isBeast2SyncRangeReader, carveBeast2Ranged, spliceBeast2Tail, BEAST2_WRITE_VERSION, BEAST2_READ_VERSIONS, BEAST2_PAGED_BATCH_DEFAULT, BEAST2_PAGED_TARGET_BYTES_DEFAULT, type Beast2EncodeOptions, type Beast2DecodeOptions, type Beast2WriterOptions, type Beast2PagedEncodeOptions, type Beast2Codec, type Beast2Version, type Beast2Extents, type RebuildBeast2Options, type Beast2LazySafeOptions, type Beast2RangeReader, type Beast2SyncRangeReader, type Beast2RangedExtents, type ReadBeast2ExtentsRangedOptions, } from "./beast2/index.js";
|
|
9
9
|
export * from "./json.js";
|
|
10
|
+
export * from "./json_schema.js";
|
|
11
|
+
export * from "./json_schema_to_type.js";
|
|
10
12
|
export * from "./csv.js";
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/serialization/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,eAAe,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EACpE,iBAAiB,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EACxF,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EACnJ,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAChG,uBAAuB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,gBAAgB,EAC5G,oBAAoB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,iCAAiC,EACzG,KAAK,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EACjJ,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EACzE,KAAK,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,KAAK,mBAAmB,EAAE,KAAK,8BAA8B,GAClH,MAAM,mBAAmB,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/serialization/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,eAAe,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EACpE,iBAAiB,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EACxF,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EACnJ,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAChG,uBAAuB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,gBAAgB,EAC5G,oBAAoB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,iCAAiC,EACzG,KAAK,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EACjJ,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EACzE,KAAK,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,KAAK,mBAAmB,EAAE,KAAK,8BAA8B,GAClH,MAAM,mBAAmB,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC"}
|
|
@@ -7,6 +7,8 @@ export * from "./binary-utils.js";
|
|
|
7
7
|
export * from "./beast.js";
|
|
8
8
|
export { encodeBeast2For, decodeBeast2For, decodeBeast2ForAsync, decodeBeast2, compileFunctionIR, compileAsyncFunctionIR, encodeEastIR, decodeEastIR, decodeAsyncEastIR, Beast2Writer, encodeBeast2SegmentsFor, encodeBeast2PagedFor, iterBeast2SegmentsFor, Beast2Pages, openBeast2PagesFor, beast2HasIndex, readBeast2Type, readBeast2Extents, carveBeast2, spliceBeast2, rebuildBeast2, openBeast2LazyFor, isBeast2LazySafe, readBeast2ExtentsRanged, readBeast2ExtentsSync, isBeast2SyncRangeReader, carveBeast2Ranged, spliceBeast2Tail, BEAST2_WRITE_VERSION, BEAST2_READ_VERSIONS, BEAST2_PAGED_BATCH_DEFAULT, BEAST2_PAGED_TARGET_BYTES_DEFAULT, } from "./beast2/index.js";
|
|
9
9
|
export * from "./json.js";
|
|
10
|
+
export * from "./json_schema.js";
|
|
11
|
+
export * from "./json_schema_to_type.js";
|
|
10
12
|
export * from "./csv.js";
|
|
11
13
|
// export * from "./beast-stream.js";
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/serialization/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,eAAe,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EACpE,iBAAiB,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EACxF,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EACnJ,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAChG,uBAAuB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,gBAAgB,EAC5G,oBAAoB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,iCAAiC,GAI1G,MAAM,mBAAmB,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AAEzB,qCAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/serialization/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,eAAe,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EACpE,iBAAiB,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EACxF,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EACnJ,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,gBAAgB,EAChG,uBAAuB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,gBAAgB,EAC5G,oBAAoB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,iCAAiC,GAI1G,MAAM,mBAAmB,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AAEzB,qCAAqC"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { type EastTypeValue } from "../type_of_type.js";
|
|
2
2
|
import type { EastType, ValueTypeOf } from "../types.js";
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Per-walk state for recursive types while an encoder is built.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* `fns` holds each wrapper's encoder so a back-reference reuses it; `scope`
|
|
8
|
+
* holds each wrapper's inner type so {@link jsonFlatOptionPayload} can judge
|
|
9
|
+
* an Option whose payload is a back-reference.
|
|
10
|
+
*/
|
|
11
|
+
type JSONEncodeTypeContext = {
|
|
12
|
+
fns: Map<bigint, (value: any, ctx?: JSONEncodeValueContext) => unknown>;
|
|
13
|
+
scope: Map<bigint, EastTypeValue>;
|
|
14
|
+
};
|
|
5
15
|
/**
|
|
6
16
|
* Value-level context for tracking seen mutable containers during JSON encoding.
|
|
7
17
|
*
|
|
@@ -12,6 +22,37 @@ type JSONEncodeValueContext = {
|
|
|
12
22
|
refs: Map<any, string[]>;
|
|
13
23
|
currentPath: string[];
|
|
14
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* The payload type of an Option that East JSON encodes flat, or `null`.
|
|
27
|
+
*
|
|
28
|
+
* @internal Not an authoring API — `printJson`, `parseJson`, `Json.next` and
|
|
29
|
+
* the schema pair apply the rule on their own. It is exported only so the
|
|
30
|
+
* east-node-std reader applies the same function as the codec and the schema
|
|
31
|
+
* here (east-c carries the same rule for itself and python), rather than a
|
|
32
|
+
* copy that could drift.
|
|
33
|
+
*
|
|
34
|
+
* @param type - The type at this position of the document
|
|
35
|
+
* @param scope - Every enclosing `Recursive` wrapper's inner type by id, for
|
|
36
|
+
* a payload that is a back-reference into one of them
|
|
37
|
+
* @returns The `some` payload's type when `Option<T>` encodes as `null` or as
|
|
38
|
+
* `T`'s own encoding; `null` when `type` is not an Option, or when its payload
|
|
39
|
+
* keeps the tagged form
|
|
40
|
+
* @throws {Error} When the payload is a back-reference `scope` does not resolve
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* East JSON encodes `Option<T>` as `null` for `none` and as the encoding of
|
|
44
|
+
* `T` for `some` whenever the encoding of `T` can never itself be `null` —
|
|
45
|
+
* every decode knows `T` at its position, so `null` then has one reading.
|
|
46
|
+
* The only encodings that can be `null` are `Null`'s and a flat Option's, so
|
|
47
|
+
* those two payloads keep the tagged `{"type": …, "value": …}` form: that is
|
|
48
|
+
* what keeps `some(none)` distinct from `none`, and `some(null)` from `none`.
|
|
49
|
+
* A `Recursive` payload is judged by what it wraps — a wrapper by its inner
|
|
50
|
+
* type, a back-reference by the inner type of the wrapper it names — so the
|
|
51
|
+
* `next: Option<self>` of a linked list is flat like the struct it refers to.
|
|
52
|
+
* The rule is a total function of the type, the same on every runtime, with
|
|
53
|
+
* no option, mode or policy.
|
|
54
|
+
*/
|
|
55
|
+
export declare function jsonFlatOptionPayload(type: EastTypeValue, scope?: ReadonlyMap<bigint, EastTypeValue>): EastTypeValue | null;
|
|
15
56
|
export declare function encodeJSONFor(type: EastTypeValue): (x: any) => Uint8Array;
|
|
16
57
|
export declare function encodeJSONFor<T extends EastType>(type: T): (x: ValueTypeOf<T>) => Uint8Array;
|
|
17
58
|
export declare function decodeJSONFor(type: EastTypeValue, frozen?: boolean): (x: Uint8Array) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/serialization/json.ts"],"names":[],"mappings":"AAOA,OAAO,EAAsC,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAuBzD
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/serialization/json.ts"],"names":[],"mappings":"AAOA,OAAO,EAAsC,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAuBzD;;;;;;;GAOG;AACH,KAAK,qBAAqB,GAAG;IAC3B,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,CAAC;IACxE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;IACzB,WAAW,EAAE,MAA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G,CAAA;AAC3F,wBAAgB,WAAW,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -100,6 +100,75 @@ function _decodeRelativeRef(refStr, currentPath) {
|
|
|
100
100
|
function _decodeJSONPointerComponent(component) {
|
|
101
101
|
return component.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
102
102
|
}
|
|
103
|
+
/** Whether `type` is the exact Option shape — `Variant{ none: Null, some: T }`. */
|
|
104
|
+
function isOptionTypeValue(type) {
|
|
105
|
+
if (type.type !== "Variant")
|
|
106
|
+
return false;
|
|
107
|
+
const cases = type.value;
|
|
108
|
+
return cases.length === 2
|
|
109
|
+
&& cases[0].name === "none" && cases[0].type.type === "Null"
|
|
110
|
+
&& cases[1].name === "some";
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The payload type of an Option that East JSON encodes flat, or `null`.
|
|
114
|
+
*
|
|
115
|
+
* @internal Not an authoring API — `printJson`, `parseJson`, `Json.next` and
|
|
116
|
+
* the schema pair apply the rule on their own. It is exported only so the
|
|
117
|
+
* east-node-std reader applies the same function as the codec and the schema
|
|
118
|
+
* here (east-c carries the same rule for itself and python), rather than a
|
|
119
|
+
* copy that could drift.
|
|
120
|
+
*
|
|
121
|
+
* @param type - The type at this position of the document
|
|
122
|
+
* @param scope - Every enclosing `Recursive` wrapper's inner type by id, for
|
|
123
|
+
* a payload that is a back-reference into one of them
|
|
124
|
+
* @returns The `some` payload's type when `Option<T>` encodes as `null` or as
|
|
125
|
+
* `T`'s own encoding; `null` when `type` is not an Option, or when its payload
|
|
126
|
+
* keeps the tagged form
|
|
127
|
+
* @throws {Error} When the payload is a back-reference `scope` does not resolve
|
|
128
|
+
*
|
|
129
|
+
* @remarks
|
|
130
|
+
* East JSON encodes `Option<T>` as `null` for `none` and as the encoding of
|
|
131
|
+
* `T` for `some` whenever the encoding of `T` can never itself be `null` —
|
|
132
|
+
* every decode knows `T` at its position, so `null` then has one reading.
|
|
133
|
+
* The only encodings that can be `null` are `Null`'s and a flat Option's, so
|
|
134
|
+
* those two payloads keep the tagged `{"type": …, "value": …}` form: that is
|
|
135
|
+
* what keeps `some(none)` distinct from `none`, and `some(null)` from `none`.
|
|
136
|
+
* A `Recursive` payload is judged by what it wraps — a wrapper by its inner
|
|
137
|
+
* type, a back-reference by the inner type of the wrapper it names — so the
|
|
138
|
+
* `next: Option<self>` of a linked list is flat like the struct it refers to.
|
|
139
|
+
* The rule is a total function of the type, the same on every runtime, with
|
|
140
|
+
* no option, mode or policy.
|
|
141
|
+
*/
|
|
142
|
+
export function jsonFlatOptionPayload(type, scope) {
|
|
143
|
+
if (!isOptionTypeValue(type))
|
|
144
|
+
return null;
|
|
145
|
+
const payload = type.value[1].type;
|
|
146
|
+
// Look through Recursive to the type actually encoded there. Each scope is
|
|
147
|
+
// entered once, so a wrapper that only refers back to itself — a type with
|
|
148
|
+
// no values — cannot loop.
|
|
149
|
+
let inner = payload;
|
|
150
|
+
const entered = new Set();
|
|
151
|
+
while (inner.type === "Recursive") {
|
|
152
|
+
const rec = inner.value;
|
|
153
|
+
const id = rec.type === "wrapper" ? rec.value.id : rec.value;
|
|
154
|
+
if (entered.has(id))
|
|
155
|
+
break;
|
|
156
|
+
entered.add(id);
|
|
157
|
+
if (rec.type === "wrapper") {
|
|
158
|
+
inner = rec.value.inner;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const resolved = scope?.get(id);
|
|
162
|
+
if (resolved === undefined) {
|
|
163
|
+
throw new Error(`jsonFlatOptionPayload: unresolved recursive reference ${id}`);
|
|
164
|
+
}
|
|
165
|
+
inner = resolved;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (inner.type === "Null" || isOptionTypeValue(inner))
|
|
169
|
+
return null;
|
|
170
|
+
return payload;
|
|
171
|
+
}
|
|
103
172
|
export function encodeJSONFor(type) {
|
|
104
173
|
// Convert EastType to EastTypeValue if necessary
|
|
105
174
|
if (!isVariant(type)) {
|
|
@@ -157,7 +226,7 @@ export function decodeJSONFor(type, frozen = false) {
|
|
|
157
226
|
}
|
|
158
227
|
};
|
|
159
228
|
}
|
|
160
|
-
export function toJSONFor(type, typeCtx = new Map()) {
|
|
229
|
+
export function toJSONFor(type, typeCtx = { fns: new Map(), scope: new Map() }) {
|
|
161
230
|
// Convert EastType to EastTypeValue if necessary
|
|
162
231
|
if (!isVariant(type)) {
|
|
163
232
|
type = toEastTypeValue(type);
|
|
@@ -190,7 +259,11 @@ export function toJSONFor(type, typeCtx = new Map()) {
|
|
|
190
259
|
// Encode as RFC 3339 date-time string (see RFC 3339 Section 5.6)
|
|
191
260
|
// Always use UTC timezone (+00:00) for consistency
|
|
192
261
|
return (date, _ctx) => {
|
|
193
|
-
|
|
262
|
+
// Pad the year like east-c's "%04d": a year below 1000 written bare
|
|
263
|
+
// ("500-01-01T…") fails the decoder's own \d{4} check, so it would
|
|
264
|
+
// not survive its own round trip.
|
|
265
|
+
const y = date.getUTCFullYear();
|
|
266
|
+
const year = y < 0 ? `-${(-y).toString().padStart(3, '0')}` : y.toString().padStart(4, '0');
|
|
194
267
|
const month = (date.getUTCMonth() + 1).toString().padStart(2, '0');
|
|
195
268
|
const day = date.getUTCDate().toString().padStart(2, '0');
|
|
196
269
|
const hour = date.getUTCHours().toString().padStart(2, '0');
|
|
@@ -330,6 +403,16 @@ export function toJSONFor(type, typeCtx = new Map()) {
|
|
|
330
403
|
return ret;
|
|
331
404
|
}
|
|
332
405
|
else if (type.type === "Variant") {
|
|
406
|
+
const flat = jsonFlatOptionPayload(type, typeCtx.scope);
|
|
407
|
+
if (flat !== null) {
|
|
408
|
+
// An Option whose payload never encodes as null: none is null and
|
|
409
|
+
// some is the payload itself, at the Option's own position — so
|
|
410
|
+
// the aliasing path gains no segment here, on either side.
|
|
411
|
+
let payloadToJson;
|
|
412
|
+
const ret = (value, ctx) => value.type === "none" ? null : payloadToJson(value.value, ctx);
|
|
413
|
+
payloadToJson = toJSONFor(flat, typeCtx);
|
|
414
|
+
return ret;
|
|
415
|
+
}
|
|
333
416
|
const caseToJson = {};
|
|
334
417
|
const ret = (value, ctx = { refs: new Map(), currentPath: [] }) => {
|
|
335
418
|
const type = value.type;
|
|
@@ -346,12 +429,14 @@ export function toJSONFor(type, typeCtx = new Map()) {
|
|
|
346
429
|
else if (type.type === "Recursive" && type.value.type === "wrapper") {
|
|
347
430
|
let inner;
|
|
348
431
|
const ret = (...args) => inner(...args);
|
|
349
|
-
|
|
350
|
-
|
|
432
|
+
const wrapper = type.value.value;
|
|
433
|
+
typeCtx.fns.set(wrapper.id, ret);
|
|
434
|
+
typeCtx.scope.set(wrapper.id, wrapper.inner);
|
|
435
|
+
inner = toJSONFor(wrapper.inner, typeCtx);
|
|
351
436
|
return ret;
|
|
352
437
|
}
|
|
353
438
|
else if (type.type === "Recursive") {
|
|
354
|
-
const ret = typeCtx.get(type.value.value);
|
|
439
|
+
const ret = typeCtx.fns.get(type.value.value);
|
|
355
440
|
if (ret === undefined) {
|
|
356
441
|
throw new Error(`Internal error: Recursive type context not found`);
|
|
357
442
|
}
|
|
@@ -427,7 +512,7 @@ export function fromJSONFor(type, frozen = false) {
|
|
|
427
512
|
* When called without a context (the normal case), it operates independently.
|
|
428
513
|
* When called with a context (inside a RecursiveType), it resolves `$ref` references.
|
|
429
514
|
*/
|
|
430
|
-
function createJSONDecoder(type, frozen = false, typeCtx = new Map()) {
|
|
515
|
+
function createJSONDecoder(type, frozen = false, typeCtx = { fns: new Map(), scope: new Map() }) {
|
|
431
516
|
if (type.type === "Never") {
|
|
432
517
|
return ((_, _ctx) => { throw new Error("Cannot decode Never type from JSON"); });
|
|
433
518
|
}
|
|
@@ -450,6 +535,13 @@ function createJSONDecoder(type, frozen = false, typeCtx = new Map()) {
|
|
|
450
535
|
else if (type.type === "Integer") {
|
|
451
536
|
return (value, _ctx) => {
|
|
452
537
|
if (typeof value === "string" && value.length > 0) {
|
|
538
|
+
// Only the decimal form the encoder writes. `BigInt()` alone
|
|
539
|
+
// also swallows "0x10", "0b101", "0o17", " 7 ", "+7", "007" and
|
|
540
|
+
// "-0" — none of which east-c accepts, so taking them here made
|
|
541
|
+
// the same document decode differently per runtime.
|
|
542
|
+
if (!/^(?:0|-?[1-9][0-9]*)$/.test(value)) {
|
|
543
|
+
throw new JSONDecodeError(`expected string representing integer, got ${JSON.stringify(value)}`);
|
|
544
|
+
}
|
|
453
545
|
let bigint;
|
|
454
546
|
try {
|
|
455
547
|
bigint = BigInt(value);
|
|
@@ -511,6 +603,25 @@ function createJSONDecoder(type, frozen = false, typeCtx = new Map()) {
|
|
|
511
603
|
if (!iso8601WithTimezone.test(value)) {
|
|
512
604
|
throw new JSONDecodeError(`expected ISO 8601 date string with timezone (e.g. "2022-06-29T13:43:00.123Z" or "2022-06-29T13:43:00.123+05:00"), got ${JSON.stringify(value)}`);
|
|
513
605
|
}
|
|
606
|
+
// `new Date` rejects month 13 and hour 25 but rolls a day its month
|
|
607
|
+
// does not have — 2026-02-30 becomes 2 March — so the calendar has
|
|
608
|
+
// to be checked before the value is trusted. The offset cannot
|
|
609
|
+
// change whether the written day exists, so this reads the literal.
|
|
610
|
+
const y = Number(value.slice(0, 4));
|
|
611
|
+
const mo = Number(value.slice(5, 7));
|
|
612
|
+
const d = Number(value.slice(8, 10));
|
|
613
|
+
const h = Number(value.slice(11, 13));
|
|
614
|
+
const mi = Number(value.slice(14, 16));
|
|
615
|
+
const sec = Number(value.slice(17, 19));
|
|
616
|
+
const leap = (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0;
|
|
617
|
+
const daysInMonth = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
618
|
+
// Hour 24 is the one `new Date` normalises rather than rejecting
|
|
619
|
+
// (it rolls to 00:00 the next day), so the time of day is bounded
|
|
620
|
+
// here as well — east-c bounds all three.
|
|
621
|
+
if (mo < 1 || mo > 12 || d < 1 || d > daysInMonth[mo - 1]
|
|
622
|
+
|| h > 23 || mi > 59 || sec > 59) {
|
|
623
|
+
throw new JSONDecodeError(`invalid date string, got ${JSON.stringify(value)}`);
|
|
624
|
+
}
|
|
514
625
|
const date = new Date(value);
|
|
515
626
|
if (isNaN(date.getTime())) {
|
|
516
627
|
throw new JSONDecodeError(`invalid date string, got ${JSON.stringify(value)}`);
|
|
@@ -813,6 +924,22 @@ function createJSONDecoder(type, frozen = false, typeCtx = new Map()) {
|
|
|
813
924
|
return ret;
|
|
814
925
|
}
|
|
815
926
|
else if (type.type === "Variant") {
|
|
927
|
+
const flat = jsonFlatOptionPayload(type, typeCtx.scope);
|
|
928
|
+
if (flat !== null) {
|
|
929
|
+
// The twin of the flat encoder: null is none, anything else is the
|
|
930
|
+
// payload, read where the Option stands. A tagged object here is
|
|
931
|
+
// refused by the payload's own decoder, as the type says it must be.
|
|
932
|
+
let payloadFromJson;
|
|
933
|
+
const ret = (json, ctx) => {
|
|
934
|
+
const v = json === null ? variant("none", null) : variant("some", payloadFromJson(json, ctx));
|
|
935
|
+
if (frozen) {
|
|
936
|
+
Object.freeze(v);
|
|
937
|
+
}
|
|
938
|
+
return v;
|
|
939
|
+
};
|
|
940
|
+
payloadFromJson = createJSONDecoder(flat, frozen, typeCtx);
|
|
941
|
+
return ret;
|
|
942
|
+
}
|
|
816
943
|
const caseFromJson = {};
|
|
817
944
|
const ret = (json, ctx = { refs: new Map(), currentPath: [] }) => {
|
|
818
945
|
if (typeof json !== "object" || json === null || !("type" in json) || !("value" in json)) {
|
|
@@ -855,12 +982,14 @@ function createJSONDecoder(type, frozen = false, typeCtx = new Map()) {
|
|
|
855
982
|
else if (type.type === "Recursive" && type.value.type === "wrapper") {
|
|
856
983
|
let inner;
|
|
857
984
|
const ret = (...args) => inner(...args);
|
|
858
|
-
|
|
859
|
-
|
|
985
|
+
const wrapper = type.value.value;
|
|
986
|
+
typeCtx.fns.set(wrapper.id, ret);
|
|
987
|
+
typeCtx.scope.set(wrapper.id, wrapper.inner);
|
|
988
|
+
inner = createJSONDecoder(wrapper.inner, frozen, typeCtx);
|
|
860
989
|
return ret;
|
|
861
990
|
}
|
|
862
991
|
else if (type.type === "Recursive") {
|
|
863
|
-
const ret = typeCtx.get(type.value.value);
|
|
992
|
+
const ret = typeCtx.fns.get(type.value.value);
|
|
864
993
|
if (ret === undefined) {
|
|
865
994
|
throw new Error(`Internal error: Recursive type context not found`);
|
|
866
995
|
}
|