@elaraai/east 0.0.1-beta.9 → 1.0.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.md +15 -666
- package/README.md +113 -88
- package/dist/src/analyze.d.ts +3 -0
- package/dist/src/analyze.d.ts.map +1 -1
- package/dist/src/analyze.js +223 -111
- package/dist/src/analyze.js.map +1 -1
- package/dist/src/analyze.spec.d.ts +2 -0
- package/dist/src/analyze.spec.d.ts.map +1 -0
- package/dist/src/analyze.spec.js +445 -0
- package/dist/src/analyze.spec.js.map +1 -0
- package/dist/src/ast.d.ts +54 -35
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast_to_ir.coerce_to.spec.d.ts +15 -0
- package/dist/src/ast_to_ir.coerce_to.spec.d.ts.map +1 -0
- package/dist/src/ast_to_ir.coerce_to.spec.js +420 -0
- package/dist/src/ast_to_ir.coerce_to.spec.js.map +1 -0
- package/dist/src/ast_to_ir.d.ts +18 -4
- package/dist/src/ast_to_ir.d.ts.map +1 -1
- package/dist/src/ast_to_ir.js +233 -178
- package/dist/src/ast_to_ir.js.map +1 -1
- package/dist/src/builtins.d.ts +1 -1
- package/dist/src/builtins.d.ts.map +1 -1
- package/dist/src/builtins.js +194 -2
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/comparison.d.ts +2 -2
- package/dist/src/comparison.d.ts.map +1 -1
- package/dist/src/comparison.js +115 -40
- package/dist/src/comparison.js.map +1 -1
- package/dist/src/comparison.spec.d.ts +2 -0
- package/dist/src/comparison.spec.d.ts.map +1 -0
- package/dist/src/comparison.spec.js +1200 -0
- package/dist/src/comparison.spec.js.map +1 -0
- package/dist/src/compile.d.ts +31 -9
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1048 -548
- package/dist/src/compile.js.map +1 -1
- package/dist/src/containers/matrix.d.ts +15 -0
- package/dist/src/containers/matrix.d.ts.map +1 -0
- package/dist/src/containers/matrix.js +15 -0
- package/dist/src/containers/matrix.js.map +1 -0
- package/dist/src/containers/ref.d.ts.map +1 -1
- package/dist/src/containers/ref.js +1 -1
- package/dist/src/containers/ref.js.map +1 -1
- package/dist/src/containers/sortedmap.spec.d.ts +2 -0
- package/dist/src/containers/sortedmap.spec.d.ts.map +1 -0
- package/dist/src/containers/sortedmap.spec.js +180 -0
- package/dist/src/containers/sortedmap.spec.js.map +1 -0
- package/dist/src/containers/sortedset.spec.d.ts +2 -0
- package/dist/src/containers/sortedset.spec.d.ts.map +1 -0
- package/dist/src/containers/sortedset.spec.js +228 -0
- package/dist/src/containers/sortedset.spec.js.map +1 -0
- package/dist/src/containers/variant.d.ts.map +1 -1
- package/dist/src/containers/variant.js +1 -1
- package/dist/src/containers/variant.js.map +1 -1
- package/dist/src/containers/variant.spec.d.ts +2 -0
- package/dist/src/containers/variant.spec.d.ts.map +1 -0
- package/dist/src/containers/variant.spec.js +217 -0
- package/dist/src/containers/variant.spec.js.map +1 -0
- package/dist/src/datetime_format/parse.spec.d.ts +6 -0
- package/dist/src/datetime_format/parse.spec.d.ts.map +1 -0
- package/dist/src/datetime_format/parse.spec.js +379 -0
- package/dist/src/datetime_format/parse.spec.js.map +1 -0
- package/dist/src/datetime_format/print.spec.d.ts +6 -0
- package/dist/src/datetime_format/print.spec.d.ts.map +1 -0
- package/dist/src/datetime_format/print.spec.js +257 -0
- package/dist/src/datetime_format/print.spec.js.map +1 -0
- package/dist/src/datetime_format/tokenize.spec.d.ts +2 -0
- package/dist/src/datetime_format/tokenize.spec.d.ts.map +1 -0
- package/dist/src/datetime_format/tokenize.spec.js +508 -0
- package/dist/src/datetime_format/tokenize.spec.js.map +1 -0
- package/dist/src/datetime_format/types.d.ts +23 -23
- package/dist/src/default.d.ts.map +1 -1
- package/dist/src/default.js +33 -0
- package/dist/src/default.js.map +1 -1
- package/dist/src/default.spec.d.ts +2 -0
- package/dist/src/default.spec.d.ts.map +1 -0
- package/dist/src/default.spec.js +178 -0
- package/dist/src/default.spec.js.map +1 -0
- package/dist/src/eastir.d.ts +7 -0
- package/dist/src/eastir.d.ts.map +1 -1
- package/dist/src/eastir.js +55 -7
- package/dist/src/eastir.js.map +1 -1
- package/dist/src/error.d.ts +14 -4
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +28 -3
- package/dist/src/error.js.map +1 -1
- package/dist/src/example.d.ts +87 -0
- package/dist/src/example.d.ts.map +1 -0
- package/dist/src/example.js +18 -0
- package/dist/src/example.js.map +1 -0
- package/dist/src/expr/array.d.ts +43 -1
- package/dist/src/expr/array.d.ts.map +1 -1
- package/dist/src/expr/array.js +103 -53
- package/dist/src/expr/array.js.map +1 -1
- package/dist/src/expr/ast.d.ts +1 -1
- package/dist/src/expr/ast.d.ts.map +1 -1
- package/dist/src/expr/ast.js +112 -54
- package/dist/src/expr/ast.js.map +1 -1
- package/dist/src/expr/asyncfunction.d.ts.map +1 -1
- package/dist/src/expr/asyncfunction.js +6 -4
- package/dist/src/expr/asyncfunction.js.map +1 -1
- package/dist/src/expr/blob.d.ts +48 -0
- package/dist/src/expr/blob.d.ts.map +1 -1
- package/dist/src/expr/blob.js +63 -8
- package/dist/src/expr/blob.js.map +1 -1
- package/dist/src/expr/block.d.ts +213 -12
- package/dist/src/expr/block.d.ts.map +1 -1
- package/dist/src/expr/block.js +796 -293
- package/dist/src/expr/block.js.map +1 -1
- package/dist/src/expr/boolean.d.ts +44 -0
- package/dist/src/expr/boolean.d.ts.map +1 -1
- package/dist/src/expr/boolean.js +58 -6
- package/dist/src/expr/boolean.js.map +1 -1
- package/dist/src/expr/datetime.d.ts +135 -0
- package/dist/src/expr/datetime.d.ts.map +1 -1
- package/dist/src/expr/datetime.js +184 -34
- package/dist/src/expr/datetime.js.map +1 -1
- package/dist/src/expr/dict.d.ts +47 -2
- package/dist/src/expr/dict.d.ts.map +1 -1
- package/dist/src/expr/dict.js +122 -61
- package/dist/src/expr/dict.js.map +1 -1
- package/dist/src/expr/expr.d.ts +3 -1
- package/dist/src/expr/expr.d.ts.map +1 -1
- package/dist/src/expr/expr.js +4 -3
- package/dist/src/expr/expr.js.map +1 -1
- package/dist/src/expr/float.d.ts +153 -0
- package/dist/src/expr/float.d.ts.map +1 -1
- package/dist/src/expr/float.js +191 -17
- package/dist/src/expr/float.js.map +1 -1
- package/dist/src/expr/function.d.ts +7 -2
- package/dist/src/expr/function.d.ts.map +1 -1
- package/dist/src/expr/function.js +6 -4
- package/dist/src/expr/function.js.map +1 -1
- package/dist/src/expr/index.d.ts +186 -2
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +183 -2
- package/dist/src/expr/index.js.map +1 -1
- package/dist/src/expr/integer.d.ts +180 -0
- package/dist/src/expr/integer.d.ts.map +1 -1
- package/dist/src/expr/integer.js +189 -18
- package/dist/src/expr/integer.js.map +1 -1
- package/dist/src/expr/libs/array.js +3 -3
- package/dist/src/expr/libs/array.js.map +1 -1
- package/dist/src/expr/libs/blob.js +3 -3
- package/dist/src/expr/libs/blob.js.map +1 -1
- package/dist/src/expr/libs/dict.js +1 -1
- package/dist/src/expr/libs/dict.js.map +1 -1
- package/dist/src/expr/libs/matrix.d.ts +17 -0
- package/dist/src/expr/libs/matrix.d.ts.map +1 -0
- package/dist/src/expr/libs/matrix.js +60 -0
- package/dist/src/expr/libs/matrix.js.map +1 -0
- package/dist/src/expr/libs/set.js +1 -1
- package/dist/src/expr/libs/set.js.map +1 -1
- package/dist/src/expr/libs/string.d.ts.map +1 -1
- package/dist/src/expr/libs/string.js +2 -1
- package/dist/src/expr/libs/string.js.map +1 -1
- package/dist/src/expr/libs/vector.d.ts +16 -0
- package/dist/src/expr/libs/vector.d.ts.map +1 -0
- package/dist/src/expr/libs/vector.js +44 -0
- package/dist/src/expr/libs/vector.js.map +1 -0
- package/dist/src/expr/matrix.d.ts +109 -0
- package/dist/src/expr/matrix.d.ts.map +1 -0
- package/dist/src/expr/matrix.js +224 -0
- package/dist/src/expr/matrix.js.map +1 -0
- package/dist/src/expr/recursive.d.ts +83 -0
- package/dist/src/expr/recursive.d.ts.map +1 -0
- package/dist/src/expr/recursive.js +99 -0
- package/dist/src/expr/recursive.js.map +1 -0
- package/dist/src/expr/ref.js +5 -5
- package/dist/src/expr/ref.js.map +1 -1
- package/dist/src/expr/set.d.ts +44 -2
- package/dist/src/expr/set.d.ts.map +1 -1
- package/dist/src/expr/set.js +102 -52
- package/dist/src/expr/set.js.map +1 -1
- package/dist/src/expr/string.d.ts +134 -0
- package/dist/src/expr/string.d.ts.map +1 -1
- package/dist/src/expr/string.js +173 -23
- package/dist/src/expr/string.js.map +1 -1
- package/dist/src/expr/struct.d.ts +1 -1
- package/dist/src/expr/struct.d.ts.map +1 -1
- package/dist/src/expr/struct.js +2 -2
- package/dist/src/expr/struct.js.map +1 -1
- package/dist/src/expr/types.d.ts +12 -9
- package/dist/src/expr/types.d.ts.map +1 -1
- package/dist/src/expr/variant.d.ts +108 -11
- package/dist/src/expr/variant.d.ts.map +1 -1
- package/dist/src/expr/variant.js +76 -38
- package/dist/src/expr/variant.js.map +1 -1
- package/dist/src/expr/vector.d.ts +102 -0
- package/dist/src/expr/vector.d.ts.map +1 -0
- package/dist/src/expr/vector.js +202 -0
- package/dist/src/expr/vector.js.map +1 -0
- package/dist/src/fuzz.d.ts +36 -2
- package/dist/src/fuzz.d.ts.map +1 -1
- package/dist/src/fuzz.js +409 -77
- package/dist/src/fuzz.js.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +12 -2
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +13 -2
- package/dist/src/internal.js.map +1 -1
- package/dist/src/ir.d.ts +1754 -1484
- package/dist/src/ir.d.ts.map +1 -1
- package/dist/src/ir.js +51 -34
- package/dist/src/ir.js.map +1 -1
- package/dist/src/ir.spec.d.ts +2 -0
- package/dist/src/ir.spec.d.ts.map +1 -0
- package/dist/src/ir.spec.js +35 -0
- package/dist/src/ir.spec.js.map +1 -0
- package/dist/src/location.d.ts +56 -17
- package/dist/src/location.d.ts.map +1 -1
- package/dist/src/location.js +226 -29
- package/dist/src/location.js.map +1 -1
- package/dist/src/location.spec.d.ts +2 -0
- package/dist/src/location.spec.d.ts.map +1 -0
- package/dist/src/location.spec.js +102 -0
- package/dist/src/location.spec.js.map +1 -0
- package/dist/src/patch/apply.d.ts +15 -0
- package/dist/src/patch/apply.d.ts.map +1 -0
- package/dist/src/patch/apply.js +352 -0
- package/dist/src/patch/apply.js.map +1 -0
- package/dist/src/patch/compose.d.ts +15 -0
- package/dist/src/patch/compose.d.ts.map +1 -0
- package/dist/src/patch/compose.js +448 -0
- package/dist/src/patch/compose.js.map +1 -0
- package/dist/src/patch/diff.d.ts +15 -0
- package/dist/src/patch/diff.d.ts.map +1 -0
- package/dist/src/patch/diff.js +347 -0
- package/dist/src/patch/diff.js.map +1 -0
- package/dist/src/patch/fuzz.d.ts +73 -0
- package/dist/src/patch/fuzz.d.ts.map +1 -0
- package/dist/src/patch/fuzz.js +159 -0
- package/dist/src/patch/fuzz.js.map +1 -0
- package/dist/src/patch/index.d.ts +32 -0
- package/dist/src/patch/index.d.ts.map +1 -0
- package/dist/src/patch/index.js +48 -0
- package/dist/src/patch/index.js.map +1 -0
- package/dist/src/patch/invert.d.ts +15 -0
- package/dist/src/patch/invert.d.ts.map +1 -0
- package/dist/src/patch/invert.js +284 -0
- package/dist/src/patch/invert.js.map +1 -0
- package/dist/src/patch/merge.d.ts +56 -0
- package/dist/src/patch/merge.d.ts.map +1 -0
- package/dist/src/patch/merge.js +586 -0
- package/dist/src/patch/merge.js.map +1 -0
- package/dist/src/patch/merge.spec.d.ts +2 -0
- package/dist/src/patch/merge.spec.d.ts.map +1 -0
- package/dist/src/patch/merge.spec.js +1139 -0
- package/dist/src/patch/merge.spec.js.map +1 -0
- package/dist/src/patch/patch.spec.d.ts +2 -0
- package/dist/src/patch/patch.spec.d.ts.map +1 -0
- package/dist/src/patch/patch.spec.js +452 -0
- package/dist/src/patch/patch.spec.js.map +1 -0
- package/dist/src/patch/path.d.ts +115 -0
- package/dist/src/patch/path.d.ts.map +1 -0
- package/dist/src/patch/path.js +192 -0
- package/dist/src/patch/path.js.map +1 -0
- package/dist/src/patch/path.spec.d.ts +6 -0
- package/dist/src/patch/path.spec.d.ts.map +1 -0
- package/dist/src/patch/path.spec.js +322 -0
- package/dist/src/patch/path.spec.js.map +1 -0
- package/dist/src/patch/prune.d.ts +77 -0
- package/dist/src/patch/prune.d.ts.map +1 -0
- package/dist/src/patch/prune.js +115 -0
- package/dist/src/patch/prune.js.map +1 -0
- package/dist/src/patch/prune.spec.d.ts +6 -0
- package/dist/src/patch/prune.spec.d.ts.map +1 -0
- package/dist/src/patch/prune.spec.js +473 -0
- package/dist/src/patch/prune.spec.js.map +1 -0
- package/dist/src/patch/type_of_patch.d.ts +25 -0
- package/dist/src/patch/type_of_patch.d.ts.map +1 -0
- package/dist/src/patch/type_of_patch.js +144 -0
- package/dist/src/patch/type_of_patch.js.map +1 -0
- package/dist/src/patch/types.d.ts +220 -0
- package/dist/src/patch/types.d.ts.map +1 -0
- package/dist/src/patch/types.js +62 -0
- package/dist/src/patch/types.js.map +1 -0
- package/dist/src/patch/validate.d.ts +44 -0
- package/dist/src/patch/validate.d.ts.map +1 -0
- package/dist/src/patch/validate.js +190 -0
- package/dist/src/patch/validate.js.map +1 -0
- package/dist/src/patch/validate.spec.d.ts +6 -0
- package/dist/src/patch/validate.spec.d.ts.map +1 -0
- package/dist/src/patch/validate.spec.js +225 -0
- package/dist/src/patch/validate.spec.js.map +1 -0
- package/dist/src/patch/walk.d.ts +121 -0
- package/dist/src/patch/walk.d.ts.map +1 -0
- package/dist/src/patch/walk.js +385 -0
- package/dist/src/patch/walk.js.map +1 -0
- package/dist/src/patch/walk.spec.d.ts +6 -0
- package/dist/src/patch/walk.spec.d.ts.map +1 -0
- package/dist/src/patch/walk.spec.js +621 -0
- package/dist/src/patch/walk.spec.js.map +1 -0
- package/dist/src/platform.d.ts +6 -0
- package/dist/src/platform.d.ts.map +1 -1
- package/dist/src/platform.spec.d.ts +2 -0
- package/dist/src/platform.spec.d.ts.map +1 -0
- package/dist/src/platform.spec.js +330 -0
- package/dist/src/platform.spec.js.map +1 -0
- package/dist/src/serialization/beast.d.ts.map +1 -1
- package/dist/src/serialization/beast.js +12 -0
- package/dist/src/serialization/beast.js.map +1 -1
- package/dist/src/serialization/beast.spec.d.ts +6 -0
- package/dist/src/serialization/beast.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast.spec.js +406 -0
- package/dist/src/serialization/beast.spec.js.map +1 -0
- package/dist/src/serialization/beast2/index.d.ts +50 -0
- package/dist/src/serialization/beast2/index.d.ts.map +1 -0
- package/dist/src/serialization/beast2/index.js +756 -0
- package/dist/src/serialization/beast2/index.js.map +1 -0
- package/dist/src/serialization/beast2/index.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/index.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/index.spec.js +528 -0
- package/dist/src/serialization/beast2/index.spec.js.map +1 -0
- package/dist/src/serialization/beast2/sourcemap-table.d.ts +29 -0
- package/dist/src/serialization/beast2/sourcemap-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/sourcemap-table.js +82 -0
- package/dist/src/serialization/beast2/sourcemap-table.js.map +1 -0
- package/dist/src/serialization/beast2/string-table.d.ts +16 -0
- package/dist/src/serialization/beast2/string-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/string-table.js +38 -0
- package/dist/src/serialization/beast2/string-table.js.map +1 -0
- package/dist/src/serialization/beast2/type-table.d.ts +86 -0
- package/dist/src/serialization/beast2/type-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/type-table.js +618 -0
- package/dist/src/serialization/beast2/type-table.js.map +1 -0
- package/dist/src/serialization/beast2/value-table.d.ts +40 -0
- package/dist/src/serialization/beast2/value-table.d.ts.map +1 -0
- package/dist/src/serialization/beast2/value-table.js +157 -0
- package/dist/src/serialization/beast2/value-table.js.map +1 -0
- package/dist/src/serialization/binary-utils.d.ts +33 -0
- package/dist/src/serialization/binary-utils.d.ts.map +1 -1
- package/dist/src/serialization/binary-utils.js +157 -0
- package/dist/src/serialization/binary-utils.js.map +1 -1
- package/dist/src/serialization/csv.d.ts +17 -17
- package/dist/src/serialization/csv.d.ts.map +1 -1
- package/dist/src/serialization/csv.js +10 -8
- package/dist/src/serialization/csv.js.map +1 -1
- package/dist/src/serialization/csv.spec.d.ts +2 -0
- package/dist/src/serialization/csv.spec.d.ts.map +1 -0
- package/dist/src/serialization/csv.spec.js +556 -0
- package/dist/src/serialization/csv.spec.js.map +1 -0
- package/dist/src/serialization/east-inferred.spec.d.ts +2 -0
- package/dist/src/serialization/east-inferred.spec.d.ts.map +1 -0
- package/dist/src/serialization/east-inferred.spec.js +322 -0
- package/dist/src/serialization/east-inferred.spec.js.map +1 -0
- package/dist/src/serialization/east.d.ts +1 -1
- package/dist/src/serialization/east.d.ts.map +1 -1
- package/dist/src/serialization/east.js +178 -26
- package/dist/src/serialization/east.js.map +1 -1
- package/dist/src/serialization/east.spec.d.ts +2 -0
- package/dist/src/serialization/east.spec.d.ts.map +1 -0
- package/dist/src/serialization/east.spec.js +1548 -0
- package/dist/src/serialization/east.spec.js.map +1 -0
- package/dist/src/serialization/index.d.ts +1 -2
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +1 -2
- package/dist/src/serialization/index.js.map +1 -1
- package/dist/src/serialization/json.d.ts +1 -1
- package/dist/src/serialization/json.d.ts.map +1 -1
- package/dist/src/serialization/json.js +123 -24
- package/dist/src/serialization/json.js.map +1 -1
- package/dist/src/serialization/json.spec.d.ts +2 -0
- package/dist/src/serialization/json.spec.d.ts.map +1 -0
- package/dist/src/serialization/json.spec.js +1297 -0
- package/dist/src/serialization/json.spec.js.map +1 -0
- package/dist/src/type_of_type.d.ts +72 -35
- package/dist/src/type_of_type.d.ts.map +1 -1
- package/dist/src/type_of_type.is_data.spec.d.ts +6 -0
- package/dist/src/type_of_type.is_data.spec.d.ts.map +1 -0
- package/dist/src/type_of_type.is_data.spec.js +221 -0
- package/dist/src/type_of_type.is_data.spec.js.map +1 -0
- package/dist/src/type_of_type.js +355 -80
- package/dist/src/type_of_type.js.map +1 -1
- package/dist/src/type_of_type.to_etv.spec.d.ts +6 -0
- package/dist/src/type_of_type.to_etv.spec.d.ts.map +1 -0
- package/dist/src/type_of_type.to_etv.spec.js +263 -0
- package/dist/src/type_of_type.to_etv.spec.js.map +1 -0
- package/dist/src/types.d.ts +82 -12
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.error.spec.d.ts +2 -0
- package/dist/src/types.error.spec.d.ts.map +1 -0
- package/dist/src/types.error.spec.js +665 -0
- package/dist/src/types.error.spec.js.map +1 -0
- package/dist/src/types.js +663 -156
- package/dist/src/types.js.map +1 -1
- package/dist/src/types.spec.d.ts +2 -0
- package/dist/src/types.spec.d.ts.map +1 -0
- package/dist/src/types.spec.js +946 -0
- package/dist/src/types.spec.js.map +1 -0
- package/dist/src/walker.d.ts +65 -0
- package/dist/src/walker.d.ts.map +1 -0
- package/dist/src/walker.js +165 -0
- package/dist/src/walker.js.map +1 -0
- package/dist/src/walker.spec.d.ts +6 -0
- package/dist/src/walker.spec.d.ts.map +1 -0
- package/dist/src/walker.spec.js +109 -0
- package/dist/src/walker.spec.js.map +1 -0
- package/package.json +16 -38
- package/dist/src/serialization/beast2-stream.d.ts +0 -38
- package/dist/src/serialization/beast2-stream.d.ts.map +0 -1
- package/dist/src/serialization/beast2-stream.js +0 -670
- package/dist/src/serialization/beast2-stream.js.map +0 -1
- package/dist/src/serialization/beast2.d.ts +0 -41
- package/dist/src/serialization/beast2.d.ts.map +0 -1
- package/dist/src/serialization/beast2.js +0 -495
- package/dist/src/serialization/beast2.js.map +0 -1
package/dist/src/location.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Formats a location as a human-readable string.
|
|
2
|
+
* Formats a single location as a human-readable string.
|
|
3
3
|
*
|
|
4
4
|
* @param location - The source location to format
|
|
5
5
|
* @returns A string in the format `"<filename> <line>:<column>"`
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
|
-
* const loc = { filename: "main.ts", line:
|
|
9
|
+
* const loc = { filename: "main.ts", line: 42n, column: 15n };
|
|
10
10
|
* printLocation(loc); // "main.ts 42:15"
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
@@ -14,49 +14,246 @@ export function printLocation(location) {
|
|
|
14
14
|
return `${location.filename} ${location.line}:${location.column}`;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Formats an array of locations as a stack trace string.
|
|
18
18
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @returns A
|
|
19
|
+
* @param locations - The source locations to format
|
|
20
|
+
* @returns A stack trace string with each location on a new line
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const locs = [
|
|
25
|
+
* { filename: "main.ts", line: 42n, column: 15n },
|
|
26
|
+
* { filename: "lib.ts", line: 10n, column: 5n }
|
|
27
|
+
* ];
|
|
28
|
+
* printLocations(locs);
|
|
29
|
+
* // "main.ts 42:15
|
|
30
|
+
* // at lib.ts 10:5"
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function printLocations(locations) {
|
|
34
|
+
if (locations.length === 0)
|
|
35
|
+
return '<unknown>';
|
|
36
|
+
const [first, ...rest] = locations;
|
|
37
|
+
const header = printLocation(first);
|
|
38
|
+
if (rest.length === 0)
|
|
39
|
+
return header;
|
|
40
|
+
return header + '\n' + rest.map(loc => ` at ${printLocation(loc)}`).join('\n');
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Determines if a stack frame should be included in location captures.
|
|
44
|
+
* Filters out internal frames (Node.js internals, node_modules) to show
|
|
45
|
+
* only user code in error stack traces.
|
|
46
|
+
*
|
|
47
|
+
* @param filename - The file path from the stack frame
|
|
48
|
+
* @returns true if the frame should be included, false to filter it out
|
|
49
|
+
*/
|
|
50
|
+
function shouldIncludeFrame(filename) {
|
|
51
|
+
// Skip Node.js internal modules (e.g., node:internal/modules/...)
|
|
52
|
+
if (filename.startsWith('node:'))
|
|
53
|
+
return false;
|
|
54
|
+
// Skip node_modules - filters out third-party packages including East
|
|
55
|
+
// when installed as a dependency. Handles both Unix and Windows paths.
|
|
56
|
+
if (filename.includes('/node_modules/') || filename.includes('\\node_modules\\'))
|
|
57
|
+
return false;
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Captures the call stack as an array of source locations, filtered to
|
|
62
|
+
* show only user code.
|
|
63
|
+
*
|
|
64
|
+
* @returns An array of {@link Location} objects representing the call stack,
|
|
65
|
+
* from innermost (most recent) to outermost frame
|
|
21
66
|
*
|
|
22
67
|
* @remarks
|
|
23
|
-
* This function uses JavaScript's Error stack traces to
|
|
24
|
-
*
|
|
25
|
-
*
|
|
68
|
+
* This function uses JavaScript's Error stack traces to capture the call
|
|
69
|
+
* stack. Internal frames (Node.js internals, node_modules packages) are
|
|
70
|
+
* filtered out to provide clean stack traces showing only user code.
|
|
71
|
+
* Returns an empty array if the stack trace cannot be parsed.
|
|
26
72
|
*
|
|
27
73
|
* @example
|
|
28
74
|
* ```ts
|
|
29
75
|
* function myFunction() {
|
|
30
|
-
* const
|
|
31
|
-
* console.log(
|
|
76
|
+
* const stack = get_location(); // Gets call stack of user code
|
|
77
|
+
* console.log(printLocations(stack));
|
|
32
78
|
* }
|
|
33
79
|
* ```
|
|
34
80
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
81
|
+
// ── Frame path normalization ───────────────────────────────────────────
|
|
82
|
+
//
|
|
83
|
+
// Stack-trace paths are absolute and environment-specific (and `file://` URLs
|
|
84
|
+
// under ESM). Baking them into serialized IR leaks the author's filesystem
|
|
85
|
+
// layout and makes the IR non-reproducible across machines and build modes. We
|
|
86
|
+
// normalize each frame path to a portable form: strip the `file://` scheme,
|
|
87
|
+
// normalize separators, and relativize to a base directory. The base defaults
|
|
88
|
+
// to the working directory when one is available (Node) and can be set with
|
|
89
|
+
// `setLocationBasePath` (e.g. for deterministic fixtures). Browser / no-cwd
|
|
90
|
+
// environments keep the cleaned path. This stays free of `node:` imports
|
|
91
|
+
// (browser-safe) and never throws.
|
|
92
|
+
let explicitBaseSet = false;
|
|
93
|
+
let explicitBase;
|
|
94
|
+
let autoBase;
|
|
95
|
+
let autoBaseComputed = false;
|
|
96
|
+
function normalizeSeparators(p) {
|
|
97
|
+
return p.replace(/\\/g, '/');
|
|
98
|
+
}
|
|
99
|
+
function stripTrailingSlash(p) {
|
|
100
|
+
return p.length > 1 && p.endsWith('/') ? p.slice(0, -1) : p;
|
|
101
|
+
}
|
|
102
|
+
function stripFileUrl(p) {
|
|
103
|
+
if (!p.startsWith('file://'))
|
|
104
|
+
return p;
|
|
105
|
+
try {
|
|
106
|
+
// `URL` is a universal (WHATWG) global — present in Node and browsers, no
|
|
107
|
+
// `node:url` import. `.pathname` is percent-encoded; decode it.
|
|
108
|
+
const pathname = decodeURIComponent(new URL(p).pathname);
|
|
109
|
+
return pathname.replace(/^\/([A-Za-z]:)/, '$1'); // Windows: "/C:/x" → "C:/x"
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return p;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function computeAutoBase() {
|
|
116
|
+
if (!autoBaseComputed) {
|
|
117
|
+
autoBaseComputed = true;
|
|
118
|
+
// Guarded global access (not a `node:` import) — `process` is undefined in
|
|
119
|
+
// the browser, where we simply skip relativization.
|
|
120
|
+
const proc = globalThis.process;
|
|
121
|
+
if (proc !== undefined && typeof proc.cwd === 'function') {
|
|
122
|
+
try {
|
|
123
|
+
autoBase = stripTrailingSlash(normalizeSeparators(String(proc.cwd())));
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
autoBase = undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return autoBase;
|
|
131
|
+
}
|
|
132
|
+
function currentBase() {
|
|
133
|
+
return explicitBaseSet ? explicitBase : computeAutoBase();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Set the base directory that captured locations are relativized against.
|
|
137
|
+
* Pass a path to relativize against it (paths outside it stay absolute); pass
|
|
138
|
+
* `undefined` to reset to the automatic default (the working directory in
|
|
139
|
+
* Node, none in the browser).
|
|
140
|
+
*/
|
|
141
|
+
export function setLocationBasePath(base) {
|
|
142
|
+
if (base === undefined) {
|
|
143
|
+
explicitBaseSet = false;
|
|
144
|
+
explicitBase = undefined;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
explicitBaseSet = true;
|
|
148
|
+
explicitBase = stripTrailingSlash(normalizeSeparators(stripFileUrl(base)));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Normalize a stack-frame path to a portable, deterministic form: `file://`
|
|
153
|
+
* stripped, separators as `/`, and relativized to the current base when the
|
|
154
|
+
* path is under it. Exported for testing. Never throws.
|
|
155
|
+
*/
|
|
156
|
+
export function normalizeFramePath(raw) {
|
|
157
|
+
try {
|
|
158
|
+
const cleaned = normalizeSeparators(stripFileUrl(raw));
|
|
159
|
+
const base = currentBase();
|
|
160
|
+
if (base !== undefined && base !== '') {
|
|
161
|
+
if (cleaned === base)
|
|
162
|
+
return '.';
|
|
163
|
+
if (cleaned.startsWith(base + '/'))
|
|
164
|
+
return cleaned.slice(base.length + 1);
|
|
165
|
+
}
|
|
166
|
+
return cleaned;
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return raw;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function capture_stack_frames() {
|
|
37
173
|
const err = new Error();
|
|
38
|
-
// Parse the stack trace
|
|
39
174
|
const stack = err.stack;
|
|
40
|
-
if (!stack)
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const lines = stack.split('\n').slice(skip + 1);
|
|
45
|
-
// Find the first meaningful stack frame
|
|
175
|
+
if (!stack)
|
|
176
|
+
return [];
|
|
177
|
+
const lines = stack.split('\n').slice(1); // Skip "Error" line
|
|
178
|
+
const frames = [];
|
|
46
179
|
for (const line of lines) {
|
|
47
|
-
//
|
|
48
|
-
const match = line.match(
|
|
180
|
+
// Simple regex that matches file:line:col at end of line
|
|
181
|
+
const match = line.match(/\(?([^()\s]+):(\d+):(\d+)\)?$/);
|
|
49
182
|
if (match) {
|
|
50
|
-
const [,
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
183
|
+
const [, filename, lineNum, column] = match;
|
|
184
|
+
// `shouldIncludeFrame` runs on the raw path so its node_modules/internal
|
|
185
|
+
// filters see absolute paths; the stored path is normalized.
|
|
186
|
+
if (filename && filename !== '' && shouldIncludeFrame(filename)) {
|
|
187
|
+
frames.push({ filename: normalizeFramePath(filename), line: BigInt(lineNum), column: BigInt(column) });
|
|
54
188
|
}
|
|
55
|
-
// TODO should we extract a subset of the fullPath?
|
|
56
|
-
// Return filename with line and column
|
|
57
|
-
return { filename: fullPath, line: Number(line), column: Number(column) };
|
|
58
189
|
}
|
|
59
190
|
}
|
|
60
|
-
return
|
|
191
|
+
return frames;
|
|
192
|
+
}
|
|
193
|
+
export function get_location() {
|
|
194
|
+
return capture_stack_frames();
|
|
195
|
+
}
|
|
196
|
+
// ── SourceMap ──────────────────────────────────────────────────────────
|
|
197
|
+
/** Reserved sentinel: resolve(0n) returns [], the "no/unknown location" id. */
|
|
198
|
+
export const UNKNOWN_LOC_ID = 0n;
|
|
199
|
+
export class SourceMap {
|
|
200
|
+
/** Location stacks, indexed by Number(loc_id). stacks[0] is always []. */
|
|
201
|
+
stacks = [[]];
|
|
202
|
+
/** Content key → loc_id for dedup during construction. */
|
|
203
|
+
intern = new Map();
|
|
204
|
+
/** Intern a location stack. Returns a stable loc_id (bigint).
|
|
205
|
+
* Equal content returns the same id. Empty stack → UNKNOWN_LOC_ID. */
|
|
206
|
+
intern_stack(stack) {
|
|
207
|
+
if (stack.length === 0)
|
|
208
|
+
return UNKNOWN_LOC_ID;
|
|
209
|
+
const key = stack.map(l => `${l.filename}|${l.line}|${l.column}`).join('\n');
|
|
210
|
+
const existing = this.intern.get(key);
|
|
211
|
+
if (existing !== undefined)
|
|
212
|
+
return existing;
|
|
213
|
+
const id = BigInt(this.stacks.length);
|
|
214
|
+
this.stacks.push(stack);
|
|
215
|
+
this.intern.set(key, id);
|
|
216
|
+
return id;
|
|
217
|
+
}
|
|
218
|
+
/** Resolve a loc_id to its stack. Returns [] for UNKNOWN_LOC_ID or out-of-range. */
|
|
219
|
+
resolve(loc_id) {
|
|
220
|
+
return this.stacks[Number(loc_id)] ?? [];
|
|
221
|
+
}
|
|
222
|
+
/** Total number of entries, including the reserved empty entry at index 0. */
|
|
223
|
+
get size() { return BigInt(this.stacks.length); }
|
|
224
|
+
/** All entries in loc_id order (for serialization). Entry 0 is always []. */
|
|
225
|
+
entries() { return this.stacks; }
|
|
226
|
+
}
|
|
227
|
+
// ── Scoped context ─────────────────────────────────────────────────────
|
|
228
|
+
let _currentMap = null;
|
|
229
|
+
/** Run `fn` with `map` as the current scope's source map. Re-entrant safe. */
|
|
230
|
+
export function with_source_map(map, fn) {
|
|
231
|
+
const prev = _currentMap;
|
|
232
|
+
_currentMap = map;
|
|
233
|
+
try {
|
|
234
|
+
return fn();
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
_currentMap = prev;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/** Wraps `fn` in a new `with_source_map` only if no map is currently active.
|
|
241
|
+
* Nested calls inherit the existing map. */
|
|
242
|
+
export function ensure_source_map(fn) {
|
|
243
|
+
if (_currentMap)
|
|
244
|
+
return fn();
|
|
245
|
+
return with_source_map(new SourceMap(), fn);
|
|
246
|
+
}
|
|
247
|
+
/** Returns the current SourceMap, or null if outside any with_source_map scope. */
|
|
248
|
+
export function get_current_source_map() {
|
|
249
|
+
return _currentMap;
|
|
250
|
+
}
|
|
251
|
+
/** Capture current stack and intern into the active SourceMap.
|
|
252
|
+
* Returns UNKNOWN_LOC_ID (0n) if no map is active. */
|
|
253
|
+
export function get_location_id() {
|
|
254
|
+
if (!_currentMap)
|
|
255
|
+
return UNKNOWN_LOC_ID;
|
|
256
|
+
const stack = capture_stack_frames();
|
|
257
|
+
return _currentMap.intern_stack(stack);
|
|
61
258
|
}
|
|
62
259
|
//# sourceMappingURL=location.js.map
|
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
|
|
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;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"file":"location.spec.d.ts","sourceRoot":"","sources":["../../src/location.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { afterEach, describe, test } from "node:test";
|
|
7
|
+
import { normalizeFramePath, setLocationBasePath } from "./location.js";
|
|
8
|
+
describe("normalizeFramePath", () => {
|
|
9
|
+
// Reset to the automatic (cwd) base after every test so cases don't leak.
|
|
10
|
+
afterEach(() => setLocationBasePath(undefined));
|
|
11
|
+
describe("file:// scheme stripping", () => {
|
|
12
|
+
test("strips a Unix file:// URL and relativizes to the base", () => {
|
|
13
|
+
setLocationBasePath("/home/u/proj");
|
|
14
|
+
assert.equal(normalizeFramePath("file:///home/u/proj/dist/src/foo.js"), "dist/src/foo.js");
|
|
15
|
+
});
|
|
16
|
+
test("strips a Windows file:// URL (drops the leading slash before the drive)", () => {
|
|
17
|
+
setLocationBasePath("C:/Users/x/proj");
|
|
18
|
+
assert.equal(normalizeFramePath("file:///C:/Users/x/proj/src/foo.ts"), "src/foo.ts");
|
|
19
|
+
});
|
|
20
|
+
test("decodes percent-encoding (e.g. spaces) in file:// URLs", () => {
|
|
21
|
+
setLocationBasePath("/home/u/my proj");
|
|
22
|
+
assert.equal(normalizeFramePath("file:///home/u/my%20proj/src/foo.ts"), "src/foo.ts");
|
|
23
|
+
});
|
|
24
|
+
test("a file:// URL outside the base is returned cleaned but absolute", () => {
|
|
25
|
+
setLocationBasePath("/home/u/proj");
|
|
26
|
+
assert.equal(normalizeFramePath("file:///opt/other/foo.ts"), "/opt/other/foo.ts");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe("plain paths", () => {
|
|
30
|
+
test("relativizes a plain Unix absolute path under the base", () => {
|
|
31
|
+
setLocationBasePath("/home/u/proj");
|
|
32
|
+
assert.equal(normalizeFramePath("/home/u/proj/src/a/b/foo.ts"), "src/a/b/foo.ts");
|
|
33
|
+
});
|
|
34
|
+
test("normalizes Windows backslashes and relativizes", () => {
|
|
35
|
+
setLocationBasePath("C:\\Users\\x\\proj");
|
|
36
|
+
assert.equal(normalizeFramePath("C:\\Users\\x\\proj\\dist\\foo.js"), "dist/foo.js");
|
|
37
|
+
});
|
|
38
|
+
test("a path not under the base is returned unchanged (cleaned)", () => {
|
|
39
|
+
setLocationBasePath("/home/u/proj");
|
|
40
|
+
assert.equal(normalizeFramePath("/somewhere/else/foo.ts"), "/somewhere/else/foo.ts");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe("base-boundary correctness", () => {
|
|
44
|
+
test("a sibling dir sharing a prefix is NOT falsely relativized", () => {
|
|
45
|
+
setLocationBasePath("/a/proj");
|
|
46
|
+
// "/a/proj-extra/..." must not be treated as inside "/a/proj"
|
|
47
|
+
assert.equal(normalizeFramePath("/a/proj-extra/foo.ts"), "/a/proj-extra/foo.ts");
|
|
48
|
+
});
|
|
49
|
+
test("a trailing slash on the base is handled", () => {
|
|
50
|
+
setLocationBasePath("/a/proj/");
|
|
51
|
+
assert.equal(normalizeFramePath("/a/proj/foo.ts"), "foo.ts");
|
|
52
|
+
});
|
|
53
|
+
test("a path equal to the base resolves to '.'", () => {
|
|
54
|
+
setLocationBasePath("/a/proj");
|
|
55
|
+
assert.equal(normalizeFramePath("/a/proj"), ".");
|
|
56
|
+
});
|
|
57
|
+
test("setLocationBasePath accepts a file:// base", () => {
|
|
58
|
+
setLocationBasePath("file:///home/u/proj");
|
|
59
|
+
assert.equal(normalizeFramePath("file:///home/u/proj/src/foo.ts"), "src/foo.ts");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe("non-file environments", () => {
|
|
63
|
+
test("a browser http(s) URL is left as-is", () => {
|
|
64
|
+
setLocationBasePath("/home/u/proj");
|
|
65
|
+
assert.equal(normalizeFramePath("https://example.com/app/foo.js"), "https://example.com/app/foo.js");
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe("automatic base (process.cwd) and reset", () => {
|
|
69
|
+
test("relativizes paths under the working directory when no base is set", () => {
|
|
70
|
+
setLocationBasePath(undefined); // auto → process.cwd()
|
|
71
|
+
const cwd = process.cwd().replace(/\\/g, "/");
|
|
72
|
+
assert.equal(normalizeFramePath(`${cwd}/dist/src/foo.js`), "dist/src/foo.js");
|
|
73
|
+
});
|
|
74
|
+
test("leaves paths outside the working directory absolute", () => {
|
|
75
|
+
setLocationBasePath(undefined);
|
|
76
|
+
assert.equal(normalizeFramePath("/definitely/not/under/cwd/foo.ts"), "/definitely/not/under/cwd/foo.ts");
|
|
77
|
+
});
|
|
78
|
+
test("an explicit base overrides the automatic one, and undefined resets it", () => {
|
|
79
|
+
setLocationBasePath("/explicit/root");
|
|
80
|
+
assert.equal(normalizeFramePath("/explicit/root/x.ts"), "x.ts");
|
|
81
|
+
setLocationBasePath(undefined);
|
|
82
|
+
// back to cwd-relative: an /explicit/root path is now (almost certainly) absolute
|
|
83
|
+
assert.equal(normalizeFramePath("/explicit/root/x.ts"), "/explicit/root/x.ts");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
describe("robustness — never throws, returns sensible output", () => {
|
|
87
|
+
test("empty string", () => {
|
|
88
|
+
setLocationBasePath("/a/proj");
|
|
89
|
+
assert.equal(normalizeFramePath(""), "");
|
|
90
|
+
});
|
|
91
|
+
test("garbage with no path structure", () => {
|
|
92
|
+
setLocationBasePath("/a/proj");
|
|
93
|
+
assert.equal(normalizeFramePath("<anonymous>"), "<anonymous>");
|
|
94
|
+
});
|
|
95
|
+
test("malformed file:// URL is returned without throwing", () => {
|
|
96
|
+
setLocationBasePath(undefined);
|
|
97
|
+
const out = normalizeFramePath("file://");
|
|
98
|
+
assert.equal(typeof out, "string");
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
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,CAAC;YACtC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC,CAAC;YAChE,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC/B,kFAAkF;YAClF,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAClE,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;YACxB,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC/B,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE;YAC1C,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC/B,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,oDAAoD,EAAE,GAAG,EAAE;YAC9D,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC/B,MAAM,GAAG,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* applyFor - Apply a patch to an East value.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { type EastTypeValue } from "../type_of_type.js";
|
|
11
|
+
import type { EastType, ValueTypeOf } from "../types.js";
|
|
12
|
+
import { type ApplyContext } from "./types.js";
|
|
13
|
+
export declare function applyFor(type: EastTypeValue, ctx?: ApplyContext): (base: any, patch: any) => any;
|
|
14
|
+
export declare function applyFor<T extends EastType>(type: T): (base: ValueTypeOf<T>, patch: any) => ValueTypeOf<T>;
|
|
15
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/patch/apply.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAOzD,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,YAAY,CAAC;AAE9D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AAClG,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC"}
|