@blade-hq/agent-client 1.1.1 → 1.1.2
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 +48 -25
- package/dist/blade-client.d.ts +2 -14
- package/dist/index.d.ts +5 -2
- package/dist/index.js +212 -106
- package/dist/index.js.map +1 -1
- package/dist/resources/models.d.ts +15 -0
- package/dist/resources/sessions.d.ts +8 -1
- package/dist/session/agent-session.d.ts +10 -0
- package/dist/session/definition.d.ts +49 -0
- package/dist/shared/projection/helpers.d.ts +1 -1
- package/dist/types/rest.d.ts +378 -10
- package/dist/version.d.ts +4 -42
- package/node_modules/@ark/schema/LICENSE +7 -0
- package/node_modules/@ark/schema/README.md +18 -0
- package/node_modules/@ark/schema/out/config.d.ts +58 -0
- package/node_modules/@ark/schema/out/config.js +95 -0
- package/node_modules/@ark/schema/out/constraint.d.ts +67 -0
- package/node_modules/@ark/schema/out/constraint.js +136 -0
- package/node_modules/@ark/schema/out/generic.d.ts +73 -0
- package/node_modules/@ark/schema/out/generic.js +76 -0
- package/node_modules/@ark/schema/out/index.d.ts +47 -0
- package/node_modules/@ark/schema/out/index.js +47 -0
- package/node_modules/@ark/schema/out/intrinsic.d.ts +24 -0
- package/node_modules/@ark/schema/out/intrinsic.js +56 -0
- package/node_modules/@ark/schema/out/kinds.d.ts +73 -0
- package/node_modules/@ark/schema/out/kinds.js +71 -0
- package/node_modules/@ark/schema/out/module.d.ts +24 -0
- package/node_modules/@ark/schema/out/module.js +15 -0
- package/node_modules/@ark/schema/out/node.d.ts +154 -0
- package/node_modules/@ark/schema/out/node.js +438 -0
- package/node_modules/@ark/schema/out/parse.d.ts +52 -0
- package/node_modules/@ark/schema/out/parse.js +215 -0
- package/node_modules/@ark/schema/out/predicate.d.ts +52 -0
- package/node_modules/@ark/schema/out/predicate.js +63 -0
- package/node_modules/@ark/schema/out/refinements/after.d.ts +41 -0
- package/node_modules/@ark/schema/out/refinements/after.js +35 -0
- package/node_modules/@ark/schema/out/refinements/before.d.ts +41 -0
- package/node_modules/@ark/schema/out/refinements/before.js +41 -0
- package/node_modules/@ark/schema/out/refinements/divisor.d.ts +43 -0
- package/node_modules/@ark/schema/out/refinements/divisor.js +58 -0
- package/node_modules/@ark/schema/out/refinements/exactLength.d.ts +49 -0
- package/node_modules/@ark/schema/out/refinements/exactLength.js +55 -0
- package/node_modules/@ark/schema/out/refinements/kinds.d.ts +34 -0
- package/node_modules/@ark/schema/out/refinements/kinds.js +25 -0
- package/node_modules/@ark/schema/out/refinements/max.d.ts +37 -0
- package/node_modules/@ark/schema/out/refinements/max.js +45 -0
- package/node_modules/@ark/schema/out/refinements/maxLength.d.ts +40 -0
- package/node_modules/@ark/schema/out/refinements/maxLength.js +49 -0
- package/node_modules/@ark/schema/out/refinements/min.d.ts +37 -0
- package/node_modules/@ark/schema/out/refinements/min.js +39 -0
- package/node_modules/@ark/schema/out/refinements/minLength.d.ts +40 -0
- package/node_modules/@ark/schema/out/refinements/minLength.js +47 -0
- package/node_modules/@ark/schema/out/refinements/pattern.d.ts +43 -0
- package/node_modules/@ark/schema/out/refinements/pattern.js +52 -0
- package/node_modules/@ark/schema/out/refinements/range.d.ts +106 -0
- package/node_modules/@ark/schema/out/refinements/range.js +103 -0
- package/node_modules/@ark/schema/out/roots/alias.d.ts +45 -0
- package/node_modules/@ark/schema/out/roots/alias.js +115 -0
- package/node_modules/@ark/schema/out/roots/basis.d.ts +12 -0
- package/node_modules/@ark/schema/out/roots/basis.js +26 -0
- package/node_modules/@ark/schema/out/roots/domain.d.ts +45 -0
- package/node_modules/@ark/schema/out/roots/domain.js +72 -0
- package/node_modules/@ark/schema/out/roots/intersection.d.ts +98 -0
- package/node_modules/@ark/schema/out/roots/intersection.js +292 -0
- package/node_modules/@ark/schema/out/roots/morph.d.ts +62 -0
- package/node_modules/@ark/schema/out/roots/morph.js +159 -0
- package/node_modules/@ark/schema/out/roots/proto.d.ts +53 -0
- package/node_modules/@ark/schema/out/roots/proto.js +101 -0
- package/node_modules/@ark/schema/out/roots/root.d.ts +145 -0
- package/node_modules/@ark/schema/out/roots/root.js +455 -0
- package/node_modules/@ark/schema/out/roots/union.d.ts +99 -0
- package/node_modules/@ark/schema/out/roots/union.js +718 -0
- package/node_modules/@ark/schema/out/roots/unit.d.ts +41 -0
- package/node_modules/@ark/schema/out/roots/unit.js +86 -0
- package/node_modules/@ark/schema/out/roots/utils.d.ts +3 -0
- package/node_modules/@ark/schema/out/roots/utils.js +6 -0
- package/node_modules/@ark/schema/out/scope.d.ts +158 -0
- package/node_modules/@ark/schema/out/scope.js +481 -0
- package/node_modules/@ark/schema/out/shared/compile.d.ts +62 -0
- package/node_modules/@ark/schema/out/shared/compile.js +145 -0
- package/node_modules/@ark/schema/out/shared/declare.d.ts +80 -0
- package/node_modules/@ark/schema/out/shared/declare.js +1 -0
- package/node_modules/@ark/schema/out/shared/disjoint.d.ts +41 -0
- package/node_modules/@ark/schema/out/shared/disjoint.js +65 -0
- package/node_modules/@ark/schema/out/shared/errors.d.ts +145 -0
- package/node_modules/@ark/schema/out/shared/errors.js +252 -0
- package/node_modules/@ark/schema/out/shared/implement.d.ts +151 -0
- package/node_modules/@ark/schema/out/shared/implement.js +98 -0
- package/node_modules/@ark/schema/out/shared/intersections.d.ts +10 -0
- package/node_modules/@ark/schema/out/shared/intersections.js +132 -0
- package/node_modules/@ark/schema/out/shared/jsonSchema.d.ts +93 -0
- package/node_modules/@ark/schema/out/shared/jsonSchema.js +1 -0
- package/node_modules/@ark/schema/out/shared/registry.d.ts +7 -0
- package/node_modules/@ark/schema/out/shared/registry.js +10 -0
- package/node_modules/@ark/schema/out/shared/standardSchema.d.ts +122 -0
- package/node_modules/@ark/schema/out/shared/standardSchema.js +2 -0
- package/node_modules/@ark/schema/out/shared/toJsonSchema.d.ts +139 -0
- package/node_modules/@ark/schema/out/shared/toJsonSchema.js +40 -0
- package/node_modules/@ark/schema/out/shared/traversal.d.ts +117 -0
- package/node_modules/@ark/schema/out/shared/traversal.js +226 -0
- package/node_modules/@ark/schema/out/shared/utils.d.ts +34 -0
- package/node_modules/@ark/schema/out/shared/utils.js +8 -0
- package/node_modules/@ark/schema/out/structure/index.d.ts +46 -0
- package/node_modules/@ark/schema/out/structure/index.js +89 -0
- package/node_modules/@ark/schema/out/structure/optional.d.ts +49 -0
- package/node_modules/@ark/schema/out/structure/optional.js +127 -0
- package/node_modules/@ark/schema/out/structure/prop.d.ts +45 -0
- package/node_modules/@ark/schema/out/structure/prop.js +85 -0
- package/node_modules/@ark/schema/out/structure/required.d.ts +39 -0
- package/node_modules/@ark/schema/out/structure/required.js +38 -0
- package/node_modules/@ark/schema/out/structure/sequence.d.ts +110 -0
- package/node_modules/@ark/schema/out/structure/sequence.js +521 -0
- package/node_modules/@ark/schema/out/structure/shared.d.ts +4 -0
- package/node_modules/@ark/schema/out/structure/shared.js +4 -0
- package/node_modules/@ark/schema/out/structure/structure.d.ts +113 -0
- package/node_modules/@ark/schema/out/structure/structure.js +747 -0
- package/node_modules/@ark/schema/package.json +51 -0
- package/node_modules/@ark/util/LICENSE +7 -0
- package/node_modules/@ark/util/out/arrays.d.ts +166 -0
- package/node_modules/@ark/util/out/arrays.js +147 -0
- package/node_modules/@ark/util/out/clone.d.ts +4 -0
- package/node_modules/@ark/util/out/clone.js +33 -0
- package/node_modules/@ark/util/out/describe.d.ts +25 -0
- package/node_modules/@ark/util/out/describe.js +1 -0
- package/node_modules/@ark/util/out/domain.d.ts +48 -0
- package/node_modules/@ark/util/out/domain.js +25 -0
- package/node_modules/@ark/util/out/errors.d.ts +29 -0
- package/node_modules/@ark/util/out/errors.js +17 -0
- package/node_modules/@ark/util/out/flatMorph.d.ts +41 -0
- package/node_modules/@ark/util/out/flatMorph.js +24 -0
- package/node_modules/@ark/util/out/functions.d.ts +33 -0
- package/node_modules/@ark/util/out/functions.js +53 -0
- package/node_modules/@ark/util/out/generics.d.ts +59 -0
- package/node_modules/@ark/util/out/generics.js +5 -0
- package/node_modules/@ark/util/out/get.d.ts +9 -0
- package/node_modules/@ark/util/out/get.js +7 -0
- package/node_modules/@ark/util/out/hkt.d.ts +27 -0
- package/node_modules/@ark/util/out/hkt.js +5 -0
- package/node_modules/@ark/util/out/index.d.ts +24 -0
- package/node_modules/@ark/util/out/index.js +24 -0
- package/node_modules/@ark/util/out/intersections.d.ts +50 -0
- package/node_modules/@ark/util/out/intersections.js +1 -0
- package/node_modules/@ark/util/out/isomorphic.d.ts +5 -0
- package/node_modules/@ark/util/out/isomorphic.js +19 -0
- package/node_modules/@ark/util/out/keys.d.ts +18 -0
- package/node_modules/@ark/util/out/keys.js +1 -0
- package/node_modules/@ark/util/out/lazily.d.ts +1 -0
- package/node_modules/@ark/util/out/lazily.js +16 -0
- package/node_modules/@ark/util/out/numbers.d.ts +72 -0
- package/node_modules/@ark/util/out/numbers.js +138 -0
- package/node_modules/@ark/util/out/objectKinds.d.ts +205 -0
- package/node_modules/@ark/util/out/objectKinds.js +150 -0
- package/node_modules/@ark/util/out/path.d.ts +22 -0
- package/node_modules/@ark/util/out/path.js +65 -0
- package/node_modules/@ark/util/out/primitive.d.ts +16 -0
- package/node_modules/@ark/util/out/primitive.js +3 -0
- package/node_modules/@ark/util/out/records.d.ts +183 -0
- package/node_modules/@ark/util/out/records.js +63 -0
- package/node_modules/@ark/util/out/registry.d.ts +21 -0
- package/node_modules/@ark/util/out/registry.js +49 -0
- package/node_modules/@ark/util/out/scanner.d.ts +44 -0
- package/node_modules/@ark/util/out/scanner.js +87 -0
- package/node_modules/@ark/util/out/serialize.d.ts +34 -0
- package/node_modules/@ark/util/out/serialize.js +150 -0
- package/node_modules/@ark/util/out/strings.d.ts +33 -0
- package/node_modules/@ark/util/out/strings.js +59 -0
- package/node_modules/@ark/util/out/traits.d.ts +89 -0
- package/node_modules/@ark/util/out/traits.js +75 -0
- package/node_modules/@ark/util/out/unionToTuple.d.ts +14 -0
- package/node_modules/@ark/util/out/unionToTuple.js +1 -0
- package/node_modules/@ark/util/package.json +39 -0
- package/node_modules/@ark/util/tsconfig.base.json +18 -0
- package/node_modules/@socket.io/component-emitter/LICENSE +24 -0
- package/node_modules/@socket.io/component-emitter/Readme.md +79 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +176 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.js +169 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/package.json +28 -0
- package/node_modules/arkregex/LICENSE +7 -0
- package/node_modules/arkregex/README.md +61 -0
- package/node_modules/arkregex/out/charset.d.ts +15 -0
- package/node_modules/arkregex/out/charset.js +1 -0
- package/node_modules/arkregex/out/escape.d.ts +29 -0
- package/node_modules/arkregex/out/escape.js +10 -0
- package/node_modules/arkregex/out/execArray.d.ts +23 -0
- package/node_modules/arkregex/out/execArray.js +1 -0
- package/node_modules/arkregex/out/group.d.ts +33 -0
- package/node_modules/arkregex/out/group.js +6 -0
- package/node_modules/arkregex/out/index.d.ts +1 -0
- package/node_modules/arkregex/out/index.js +1 -0
- package/node_modules/arkregex/out/parse.d.ts +10 -0
- package/node_modules/arkregex/out/parse.js +1 -0
- package/node_modules/arkregex/out/quantify.d.ts +43 -0
- package/node_modules/arkregex/out/quantify.js +2 -0
- package/node_modules/arkregex/out/regex.d.ts +38 -0
- package/node_modules/arkregex/out/regex.js +2 -0
- package/node_modules/arkregex/out/state.d.ts +359 -0
- package/node_modules/arkregex/out/state.js +2 -0
- package/node_modules/arkregex/package.json +42 -0
- package/node_modules/arktype/LICENSE +7 -0
- package/node_modules/arktype/README.md +157 -0
- package/node_modules/arktype/out/attributes.d.ts +104 -0
- package/node_modules/arktype/out/attributes.js +3 -0
- package/node_modules/arktype/out/config.d.ts +35 -0
- package/node_modules/arktype/out/config.js +3 -0
- package/node_modules/arktype/out/declare.d.ts +35 -0
- package/node_modules/arktype/out/declare.js +1 -0
- package/node_modules/arktype/out/fn.d.ts +61 -0
- package/node_modules/arktype/out/fn.js +54 -0
- package/node_modules/arktype/out/generic.d.ts +118 -0
- package/node_modules/arktype/out/generic.js +37 -0
- package/node_modules/arktype/out/index.d.ts +12 -0
- package/node_modules/arktype/out/index.js +9 -0
- package/node_modules/arktype/out/keywords/Array.d.ts +20 -0
- package/node_modules/arktype/out/keywords/Array.js +21 -0
- package/node_modules/arktype/out/keywords/FormData.d.ts +15 -0
- package/node_modules/arktype/out/keywords/FormData.js +40 -0
- package/node_modules/arktype/out/keywords/TypedArray.d.ts +19 -0
- package/node_modules/arktype/out/keywords/TypedArray.js +16 -0
- package/node_modules/arktype/out/keywords/builtins.d.ts +18 -0
- package/node_modules/arktype/out/keywords/builtins.js +11 -0
- package/node_modules/arktype/out/keywords/constructors.d.ts +31 -0
- package/node_modules/arktype/out/keywords/constructors.js +16 -0
- package/node_modules/arktype/out/keywords/keywords.d.ts +70 -0
- package/node_modules/arktype/out/keywords/keywords.js +48 -0
- package/node_modules/arktype/out/keywords/number.d.ts +23 -0
- package/node_modules/arktype/out/keywords/number.js +49 -0
- package/node_modules/arktype/out/keywords/string.d.ts +334 -0
- package/node_modules/arktype/out/keywords/string.js +463 -0
- package/node_modules/arktype/out/keywords/ts.d.ts +108 -0
- package/node_modules/arktype/out/keywords/ts.js +82 -0
- package/node_modules/arktype/out/match.d.ts +152 -0
- package/node_modules/arktype/out/match.js +95 -0
- package/node_modules/arktype/out/module.d.ts +22 -0
- package/node_modules/arktype/out/module.js +3 -0
- package/node_modules/arktype/out/nary.d.ts +473 -0
- package/node_modules/arktype/out/nary.js +1 -0
- package/node_modules/arktype/out/parser/ast/bounds.d.ts +18 -0
- package/node_modules/arktype/out/parser/ast/bounds.js +1 -0
- package/node_modules/arktype/out/parser/ast/default.d.ts +8 -0
- package/node_modules/arktype/out/parser/ast/default.js +1 -0
- package/node_modules/arktype/out/parser/ast/divisor.d.ts +9 -0
- package/node_modules/arktype/out/parser/ast/divisor.js +1 -0
- package/node_modules/arktype/out/parser/ast/generic.d.ts +17 -0
- package/node_modules/arktype/out/parser/ast/generic.js +1 -0
- package/node_modules/arktype/out/parser/ast/infer.d.ts +25 -0
- package/node_modules/arktype/out/parser/ast/infer.js +1 -0
- package/node_modules/arktype/out/parser/ast/keyof.d.ts +7 -0
- package/node_modules/arktype/out/parser/ast/keyof.js +1 -0
- package/node_modules/arktype/out/parser/ast/utils.d.ts +8 -0
- package/node_modules/arktype/out/parser/ast/utils.js +1 -0
- package/node_modules/arktype/out/parser/ast/validate.d.ts +30 -0
- package/node_modules/arktype/out/parser/ast/validate.js +3 -0
- package/node_modules/arktype/out/parser/definition.d.ts +30 -0
- package/node_modules/arktype/out/parser/definition.js +74 -0
- package/node_modules/arktype/out/parser/objectLiteral.d.ts +70 -0
- package/node_modules/arktype/out/parser/objectLiteral.js +113 -0
- package/node_modules/arktype/out/parser/property.d.ts +34 -0
- package/node_modules/arktype/out/parser/property.js +16 -0
- package/node_modules/arktype/out/parser/reduce/dynamic.d.ts +42 -0
- package/node_modules/arktype/out/parser/reduce/dynamic.js +153 -0
- package/node_modules/arktype/out/parser/reduce/shared.d.ts +39 -0
- package/node_modules/arktype/out/parser/reduce/shared.js +25 -0
- package/node_modules/arktype/out/parser/reduce/static.d.ts +186 -0
- package/node_modules/arktype/out/parser/reduce/static.js +1 -0
- package/node_modules/arktype/out/parser/shift/operand/date.d.ts +11 -0
- package/node_modules/arktype/out/parser/shift/operand/date.js +23 -0
- package/node_modules/arktype/out/parser/shift/operand/enclosed.d.ts +57 -0
- package/node_modules/arktype/out/parser/shift/operand/enclosed.js +78 -0
- package/node_modules/arktype/out/parser/shift/operand/genericArgs.d.ts +27 -0
- package/node_modules/arktype/out/parser/shift/operand/genericArgs.js +16 -0
- package/node_modules/arktype/out/parser/shift/operand/operand.d.ts +8 -0
- package/node_modules/arktype/out/parser/shift/operand/operand.js +16 -0
- package/node_modules/arktype/out/parser/shift/operand/unenclosed.d.ts +43 -0
- package/node_modules/arktype/out/parser/shift/operand/unenclosed.js +59 -0
- package/node_modules/arktype/out/parser/shift/operator/bounds.d.ts +24 -0
- package/node_modules/arktype/out/parser/shift/operator/bounds.js +91 -0
- package/node_modules/arktype/out/parser/shift/operator/brand.d.ts +7 -0
- package/node_modules/arktype/out/parser/shift/operator/brand.js +6 -0
- package/node_modules/arktype/out/parser/shift/operator/default.d.ts +24 -0
- package/node_modules/arktype/out/parser/shift/operator/default.js +15 -0
- package/node_modules/arktype/out/parser/shift/operator/divisor.d.ts +8 -0
- package/node_modules/arktype/out/parser/shift/operator/divisor.js +13 -0
- package/node_modules/arktype/out/parser/shift/operator/operator.d.ts +14 -0
- package/node_modules/arktype/out/parser/shift/operator/operator.js +28 -0
- package/node_modules/arktype/out/parser/shift/tokens.d.ts +33 -0
- package/node_modules/arktype/out/parser/shift/tokens.js +37 -0
- package/node_modules/arktype/out/parser/string.d.ts +30 -0
- package/node_modules/arktype/out/parser/string.js +42 -0
- package/node_modules/arktype/out/parser/tupleExpressions.d.ts +79 -0
- package/node_modules/arktype/out/parser/tupleExpressions.js +75 -0
- package/node_modules/arktype/out/parser/tupleLiteral.d.ts +95 -0
- package/node_modules/arktype/out/parser/tupleLiteral.js +128 -0
- package/node_modules/arktype/out/scope.d.ts +158 -0
- package/node_modules/arktype/out/scope.js +106 -0
- package/node_modules/arktype/out/type.d.ts +144 -0
- package/node_modules/arktype/out/type.js +55 -0
- package/node_modules/arktype/out/variants/array.d.ts +12 -0
- package/node_modules/arktype/out/variants/array.js +1 -0
- package/node_modules/arktype/out/variants/base.d.ts +542 -0
- package/node_modules/arktype/out/variants/base.js +1 -0
- package/node_modules/arktype/out/variants/date.d.ts +10 -0
- package/node_modules/arktype/out/variants/date.js +1 -0
- package/node_modules/arktype/out/variants/instantiate.d.ts +12 -0
- package/node_modules/arktype/out/variants/instantiate.js +1 -0
- package/node_modules/arktype/out/variants/number.d.ts +11 -0
- package/node_modules/arktype/out/variants/number.js +1 -0
- package/node_modules/arktype/out/variants/object.d.ts +107 -0
- package/node_modules/arktype/out/variants/object.js +1 -0
- package/node_modules/arktype/out/variants/string.d.ts +15 -0
- package/node_modules/arktype/out/variants/string.js +1 -0
- package/node_modules/arktype/package.json +57 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/engine.io-client/LICENSE +22 -0
- package/node_modules/engine.io-client/README.md +331 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +14 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +38 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +67 -0
- package/node_modules/engine.io-client/build/cjs/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/cjs/globals.js +26 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.js +97 -0
- package/node_modules/engine.io-client/build/cjs/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/index.js +32 -0
- package/node_modules/engine.io-client/build/cjs/package.json +10 -0
- package/node_modules/engine.io-client/build/cjs/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/cjs/socket.js +765 -0
- package/node_modules/engine.io-client/build/cjs/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/cjs/transport.js +153 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.js +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +60 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +285 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +44 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.js +165 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.js +136 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +68 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +94 -0
- package/node_modules/engine.io-client/build/cjs/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/cjs/util.js +65 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/index.js +15 -0
- package/node_modules/engine.io-client/build/esm/package.json +10 -0
- package/node_modules/engine.io-client/build/esm/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm/socket.js +727 -0
- package/node_modules/engine.io-client/build/esm/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm/transport.js +142 -0
- package/node_modules/engine.io-client/build/esm/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +271 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.js +145 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.js +125 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.js +80 -0
- package/node_modules/engine.io-client/build/esm/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm/util.js +59 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm-debug/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/index.js +15 -0
- package/node_modules/engine.io-client/build/esm-debug/package.json +10 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.js +756 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.js +145 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +276 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +158 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +128 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +87 -0
- package/node_modules/engine.io-client/build/esm-debug/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm-debug/util.js +59 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.js +3064 -0
- package/node_modules/engine.io-client/dist/engine.io.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -0
- package/node_modules/engine.io-client/package.json +95 -0
- package/node_modules/engine.io-parser/LICENSE +22 -0
- package/node_modules/engine.io-parser/Readme.md +158 -0
- package/node_modules/engine.io-parser/build/cjs/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/cjs/commons.js +19 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +48 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +66 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.js +59 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +72 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.js +38 -0
- package/node_modules/engine.io-parser/build/cjs/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/cjs/index.js +164 -0
- package/node_modules/engine.io-parser/build/cjs/package.json +8 -0
- package/node_modules/engine.io-parser/build/esm/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/esm/commons.js +14 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +43 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +62 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.js +55 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +68 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.js +33 -0
- package/node_modules/engine.io-parser/build/esm/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/esm/index.js +156 -0
- package/node_modules/engine.io-parser/build/esm/package.json +8 -0
- package/node_modules/engine.io-parser/package.json +46 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/socket.io-client/LICENSE +21 -0
- package/node_modules/socket.io-client/README.md +29 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +69 -0
- package/node_modules/socket.io-client/build/cjs/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/cjs/index.js +76 -0
- package/node_modules/socket.io-client/build/cjs/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/cjs/manager.js +416 -0
- package/node_modules/socket.io-client/build/cjs/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/on.js +9 -0
- package/node_modules/socket.io-client/build/cjs/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/cjs/socket.js +909 -0
- package/node_modules/socket.io-client/build/cjs/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/cjs/url.js +69 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm/index.js +58 -0
- package/node_modules/socket.io-client/build/esm/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm/manager.js +367 -0
- package/node_modules/socket.io-client/build/esm/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/on.js +6 -0
- package/node_modules/socket.io-client/build/esm/package.json +5 -0
- package/node_modules/socket.io-client/build/esm/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm/socket.js +880 -0
- package/node_modules/socket.io-client/build/esm/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm/url.js +59 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm-debug/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm-debug/index.js +62 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.js +386 -0
- package/node_modules/socket.io-client/build/esm-debug/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/on.js +6 -0
- package/node_modules/socket.io-client/build/esm-debug/package.json +5 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.js +902 -0
- package/node_modules/socket.io-client/build/esm-debug/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm-debug/url.js +63 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.js +4955 -0
- package/node_modules/socket.io-client/dist/socket.io.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -0
- package/node_modules/socket.io-client/package.json +101 -0
- package/node_modules/socket.io-parser/LICENSE +20 -0
- package/node_modules/socket.io-parser/Readme.md +81 -0
- package/node_modules/socket.io-parser/build/cjs/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/cjs/binary.js +87 -0
- package/node_modules/socket.io-parser/build/cjs/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/cjs/index.js +359 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.js +54 -0
- package/node_modules/socket.io-parser/build/cjs/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/esm/index.js +348 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.js +353 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm-debug/package.json +3 -0
- package/node_modules/socket.io-parser/package.json +44 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +13 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +18 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +550 -0
- package/node_modules/ws/lib/websocket.js +1388 -0
- package/node_modules/ws/package.json +69 -0
- package/node_modules/ws/wrapper.mjs +8 -0
- package/node_modules/xmlhttprequest-ssl/LICENSE +22 -0
- package/node_modules/xmlhttprequest-ssl/README.md +67 -0
- package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +689 -0
- package/node_modules/xmlhttprequest-ssl/package.json +40 -0
- package/package.json +34 -4
- package/public-api.md +85 -23
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import { ParseError, flatMorph, hasDomain, isArray, isThunk, printable, throwInternalError, throwParseError } from "@ark/util";
|
|
2
|
+
import { mergeConfigs } from "./config.js";
|
|
3
|
+
import { GenericRoot, LazyGenericBody } from "./generic.js";
|
|
4
|
+
import { nodeImplementationsByKind } from "./kinds.js";
|
|
5
|
+
import { RootModule, bindModule } from "./module.js";
|
|
6
|
+
import { nodesByRegisteredId, parseNode, registerNodeId, schemaKindOf, withId } from "./parse.js";
|
|
7
|
+
import { Alias } from "./roots/alias.js";
|
|
8
|
+
import { CompiledFunction, NodeCompiler } from "./shared/compile.js";
|
|
9
|
+
import { $ark } from "./shared/registry.js";
|
|
10
|
+
import { Traversal } from "./shared/traversal.js";
|
|
11
|
+
import { arkKind, hasArkKind, isNode } from "./shared/utils.js";
|
|
12
|
+
const schemaBranchesOf = (schema) => isArray(schema) ? schema
|
|
13
|
+
: "branches" in schema && isArray(schema.branches) ? schema.branches
|
|
14
|
+
: undefined;
|
|
15
|
+
const throwMismatchedNodeRootError = (expected, actual) => throwParseError(`Node of kind ${actual} is not valid as a ${expected} definition`);
|
|
16
|
+
export const writeDuplicateAliasError = (alias) => `#${alias} duplicates public alias ${alias}`;
|
|
17
|
+
const scopesByName = {};
|
|
18
|
+
$ark.ambient ??= {};
|
|
19
|
+
let rawUnknownUnion;
|
|
20
|
+
const rootScopeFnName = "function $";
|
|
21
|
+
const precompile = (references) => bindPrecompilation(references, precompileReferences(references));
|
|
22
|
+
const bindPrecompilation = (references, precompiler) => {
|
|
23
|
+
const precompilation = precompiler.write(rootScopeFnName, 4);
|
|
24
|
+
const compiledTraversals = precompiler.compile()();
|
|
25
|
+
for (const node of references) {
|
|
26
|
+
if (node.precompilation) {
|
|
27
|
+
// if node has already been bound to another scope or anonymous type, don't rebind it
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
node.traverseAllows =
|
|
31
|
+
compiledTraversals[`${node.id}Allows`].bind(compiledTraversals);
|
|
32
|
+
if (node.isRoot() && !node.allowsRequiresContext) {
|
|
33
|
+
// if the reference doesn't require context, we can assign over
|
|
34
|
+
// it directly to avoid having to initialize it
|
|
35
|
+
node.allows = node.traverseAllows;
|
|
36
|
+
}
|
|
37
|
+
node.traverseApply =
|
|
38
|
+
compiledTraversals[`${node.id}Apply`].bind(compiledTraversals);
|
|
39
|
+
if (compiledTraversals[`${node.id}Optimistic`]) {
|
|
40
|
+
;
|
|
41
|
+
node.traverseOptimistic =
|
|
42
|
+
compiledTraversals[`${node.id}Optimistic`].bind(compiledTraversals);
|
|
43
|
+
}
|
|
44
|
+
node.precompilation = precompilation;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const precompileReferences = (references) => new CompiledFunction().return(references.reduce((js, node) => {
|
|
48
|
+
const allowsCompiler = new NodeCompiler({ kind: "Allows" }).indent();
|
|
49
|
+
node.compile(allowsCompiler);
|
|
50
|
+
const allowsJs = allowsCompiler.write(`${node.id}Allows`);
|
|
51
|
+
const applyCompiler = new NodeCompiler({ kind: "Apply" }).indent();
|
|
52
|
+
node.compile(applyCompiler);
|
|
53
|
+
const applyJs = applyCompiler.write(`${node.id}Apply`);
|
|
54
|
+
const result = `${js}${allowsJs},\n${applyJs},\n`;
|
|
55
|
+
if (!node.hasKind("union"))
|
|
56
|
+
return result;
|
|
57
|
+
const optimisticCompiler = new NodeCompiler({
|
|
58
|
+
kind: "Allows",
|
|
59
|
+
optimistic: true
|
|
60
|
+
}).indent();
|
|
61
|
+
node.compile(optimisticCompiler);
|
|
62
|
+
const optimisticJs = optimisticCompiler.write(`${node.id}Optimistic`);
|
|
63
|
+
return `${result}${optimisticJs},\n`;
|
|
64
|
+
}, "{\n") + "}");
|
|
65
|
+
export class BaseScope {
|
|
66
|
+
config;
|
|
67
|
+
resolvedConfig;
|
|
68
|
+
name;
|
|
69
|
+
get [arkKind]() {
|
|
70
|
+
return "scope";
|
|
71
|
+
}
|
|
72
|
+
referencesById = {};
|
|
73
|
+
references = [];
|
|
74
|
+
resolutions = {};
|
|
75
|
+
exportedNames = [];
|
|
76
|
+
aliases = {};
|
|
77
|
+
resolved = false;
|
|
78
|
+
nodesByHash = {};
|
|
79
|
+
intrinsic;
|
|
80
|
+
constructor(
|
|
81
|
+
/** The set of names defined at the root-level of the scope mapped to their
|
|
82
|
+
* corresponding definitions.**/
|
|
83
|
+
def, config) {
|
|
84
|
+
this.config = mergeConfigs($ark.config, config);
|
|
85
|
+
this.resolvedConfig = mergeConfigs($ark.resolvedConfig, config);
|
|
86
|
+
this.name =
|
|
87
|
+
this.resolvedConfig.name ??
|
|
88
|
+
`anonymousScope${Object.keys(scopesByName).length}`;
|
|
89
|
+
if (this.name in scopesByName)
|
|
90
|
+
throwParseError(`A Scope already named ${this.name} already exists`);
|
|
91
|
+
scopesByName[this.name] = this;
|
|
92
|
+
const aliasEntries = Object.entries(def).map(entry => this.preparseOwnAliasEntry(...entry));
|
|
93
|
+
for (const [k, v] of aliasEntries) {
|
|
94
|
+
let name = k;
|
|
95
|
+
if (k[0] === "#") {
|
|
96
|
+
name = k.slice(1);
|
|
97
|
+
if (name in this.aliases)
|
|
98
|
+
throwParseError(writeDuplicateAliasError(name));
|
|
99
|
+
this.aliases[name] = v;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
if (name in this.aliases)
|
|
103
|
+
throwParseError(writeDuplicateAliasError(k));
|
|
104
|
+
this.aliases[name] = v;
|
|
105
|
+
this.exportedNames.push(name);
|
|
106
|
+
}
|
|
107
|
+
if (!hasArkKind(v, "module") &&
|
|
108
|
+
!hasArkKind(v, "generic") &&
|
|
109
|
+
!isThunk(v)) {
|
|
110
|
+
const preparsed = this.preparseOwnDefinitionFormat(v, { alias: name });
|
|
111
|
+
this.resolutions[name] =
|
|
112
|
+
hasArkKind(preparsed, "root") ?
|
|
113
|
+
this.bindReference(preparsed)
|
|
114
|
+
: this.createParseContext(preparsed).id;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// reduce union of all possible values reduces to unknown
|
|
118
|
+
rawUnknownUnion ??= this.node("union", {
|
|
119
|
+
branches: [
|
|
120
|
+
"string",
|
|
121
|
+
"number",
|
|
122
|
+
"object",
|
|
123
|
+
"bigint",
|
|
124
|
+
"symbol",
|
|
125
|
+
{ unit: true },
|
|
126
|
+
{ unit: false },
|
|
127
|
+
{ unit: undefined },
|
|
128
|
+
{ unit: null }
|
|
129
|
+
]
|
|
130
|
+
}, { prereduced: true });
|
|
131
|
+
this.nodesByHash[rawUnknownUnion.hash] = this.node("intersection", {}, { prereduced: true });
|
|
132
|
+
this.intrinsic =
|
|
133
|
+
$ark.intrinsic ?
|
|
134
|
+
flatMorph($ark.intrinsic, (k, v) =>
|
|
135
|
+
// don't include cyclic aliases from JSON scope
|
|
136
|
+
k.startsWith("json") ? [] : [k, this.bindReference(v)])
|
|
137
|
+
// intrinsic won't be available during bootstrapping, so we lie
|
|
138
|
+
// about the type here as an extrnal convenience
|
|
139
|
+
: {};
|
|
140
|
+
}
|
|
141
|
+
cacheGetter(name, value) {
|
|
142
|
+
Object.defineProperty(this, name, { value });
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
145
|
+
get internal() {
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
// json is populated when the scope is exported, so ensure it is populated
|
|
149
|
+
// before allowing external access
|
|
150
|
+
_json;
|
|
151
|
+
get json() {
|
|
152
|
+
if (!this._json)
|
|
153
|
+
this.export();
|
|
154
|
+
return this._json;
|
|
155
|
+
}
|
|
156
|
+
defineSchema(def) {
|
|
157
|
+
return def;
|
|
158
|
+
}
|
|
159
|
+
generic = (...params) => {
|
|
160
|
+
const $ = this;
|
|
161
|
+
return (def, possibleHkt) => new GenericRoot(params, possibleHkt ? new LazyGenericBody(def) : def, $, $, possibleHkt ?? null);
|
|
162
|
+
};
|
|
163
|
+
units = (values, opts) => {
|
|
164
|
+
const uniqueValues = [];
|
|
165
|
+
for (const value of values)
|
|
166
|
+
if (!uniqueValues.includes(value))
|
|
167
|
+
uniqueValues.push(value);
|
|
168
|
+
const branches = uniqueValues.map(unit => this.node("unit", { unit }, opts));
|
|
169
|
+
return this.node("union", branches, {
|
|
170
|
+
...opts,
|
|
171
|
+
prereduced: true
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
lazyResolutions = [];
|
|
175
|
+
lazilyResolve(resolve, syntheticAlias) {
|
|
176
|
+
const node = this.node("alias", {
|
|
177
|
+
reference: syntheticAlias ?? "synthetic",
|
|
178
|
+
resolve
|
|
179
|
+
}, { prereduced: true });
|
|
180
|
+
if (!this.resolved)
|
|
181
|
+
this.lazyResolutions.push(node);
|
|
182
|
+
return node;
|
|
183
|
+
}
|
|
184
|
+
schema = (schema, opts) => this.finalize(this.parseSchema(schema, opts));
|
|
185
|
+
parseSchema = (schema, opts) => this.node(schemaKindOf(schema), schema, opts);
|
|
186
|
+
preparseNode(kinds, schema, opts) {
|
|
187
|
+
let kind = typeof kinds === "string" ? kinds : schemaKindOf(schema, kinds);
|
|
188
|
+
if (isNode(schema) && schema.kind === kind)
|
|
189
|
+
return schema;
|
|
190
|
+
if (kind === "alias" && !opts?.prereduced) {
|
|
191
|
+
const { reference } = Alias.implementation.normalize(schema, this);
|
|
192
|
+
if (reference.startsWith("$")) {
|
|
193
|
+
const resolution = this.resolveRoot(reference.slice(1));
|
|
194
|
+
schema = resolution;
|
|
195
|
+
kind = resolution.kind;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (kind === "union" && hasDomain(schema, "object")) {
|
|
199
|
+
const branches = schemaBranchesOf(schema);
|
|
200
|
+
if (branches?.length === 1) {
|
|
201
|
+
schema = branches[0];
|
|
202
|
+
kind = schemaKindOf(schema);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (isNode(schema) && schema.kind === kind)
|
|
206
|
+
return schema;
|
|
207
|
+
const impl = nodeImplementationsByKind[kind];
|
|
208
|
+
const normalizedSchema = impl.normalize?.(schema, this) ?? schema;
|
|
209
|
+
// check again after normalization in case a node is a valid collapsed
|
|
210
|
+
// schema for the kind (e.g. sequence can collapse to element accepting a Node')
|
|
211
|
+
if (isNode(normalizedSchema)) {
|
|
212
|
+
return normalizedSchema.kind === kind ?
|
|
213
|
+
normalizedSchema
|
|
214
|
+
: throwMismatchedNodeRootError(kind, normalizedSchema.kind);
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
...opts,
|
|
218
|
+
$: this,
|
|
219
|
+
kind,
|
|
220
|
+
def: normalizedSchema,
|
|
221
|
+
prefix: opts.alias ?? kind
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
bindReference(reference) {
|
|
225
|
+
let bound;
|
|
226
|
+
if (isNode(reference)) {
|
|
227
|
+
bound =
|
|
228
|
+
reference.$ === this ?
|
|
229
|
+
reference
|
|
230
|
+
: new reference.constructor(reference.attachments, this);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
bound =
|
|
234
|
+
reference.$ === this ?
|
|
235
|
+
reference
|
|
236
|
+
: new GenericRoot(reference.params, reference.bodyDef, reference.$, this, reference.hkt);
|
|
237
|
+
}
|
|
238
|
+
if (!this.resolved) {
|
|
239
|
+
// we're still parsing the scope itself, so defer compilation but
|
|
240
|
+
// add the node as a reference
|
|
241
|
+
Object.assign(this.referencesById, bound.referencesById);
|
|
242
|
+
}
|
|
243
|
+
return bound;
|
|
244
|
+
}
|
|
245
|
+
resolveRoot(name) {
|
|
246
|
+
return (this.maybeResolveRoot(name) ??
|
|
247
|
+
throwParseError(writeUnresolvableMessage(name)));
|
|
248
|
+
}
|
|
249
|
+
maybeResolveRoot(name) {
|
|
250
|
+
const result = this.maybeResolve(name);
|
|
251
|
+
if (hasArkKind(result, "generic"))
|
|
252
|
+
return;
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
/** If name is a valid reference to a submodule alias, return its resolution */
|
|
256
|
+
maybeResolveSubalias(name) {
|
|
257
|
+
return (maybeResolveSubalias(this.aliases, name) ??
|
|
258
|
+
maybeResolveSubalias(this.ambient, name));
|
|
259
|
+
}
|
|
260
|
+
get ambient() {
|
|
261
|
+
return $ark.ambient;
|
|
262
|
+
}
|
|
263
|
+
maybeResolve(name) {
|
|
264
|
+
const cached = this.resolutions[name];
|
|
265
|
+
if (cached) {
|
|
266
|
+
if (typeof cached !== "string")
|
|
267
|
+
return this.bindReference(cached);
|
|
268
|
+
const v = nodesByRegisteredId[cached];
|
|
269
|
+
if (hasArkKind(v, "root"))
|
|
270
|
+
return (this.resolutions[name] = v);
|
|
271
|
+
if (hasArkKind(v, "context")) {
|
|
272
|
+
if (v.phase === "resolving") {
|
|
273
|
+
return this.node("alias", { reference: `$${name}` }, { prereduced: true });
|
|
274
|
+
}
|
|
275
|
+
if (v.phase === "resolved") {
|
|
276
|
+
return throwInternalError(`Unexpected resolved context for was uncached by its scope: ${printable(v)}`);
|
|
277
|
+
}
|
|
278
|
+
v.phase = "resolving";
|
|
279
|
+
const node = this.bindReference(this.parseOwnDefinitionFormat(v.def, v));
|
|
280
|
+
v.phase = "resolved";
|
|
281
|
+
nodesByRegisteredId[node.id] = node;
|
|
282
|
+
nodesByRegisteredId[v.id] = node;
|
|
283
|
+
return (this.resolutions[name] = node);
|
|
284
|
+
}
|
|
285
|
+
return throwInternalError(`Unexpected nodesById entry for ${cached}: ${printable(v)}`);
|
|
286
|
+
}
|
|
287
|
+
let def = this.aliases[name] ?? this.ambient?.[name];
|
|
288
|
+
if (!def)
|
|
289
|
+
return this.maybeResolveSubalias(name);
|
|
290
|
+
def = this.normalizeRootScopeValue(def);
|
|
291
|
+
if (hasArkKind(def, "generic"))
|
|
292
|
+
return (this.resolutions[name] = this.bindReference(def));
|
|
293
|
+
if (hasArkKind(def, "module")) {
|
|
294
|
+
if (!def.root)
|
|
295
|
+
throwParseError(writeMissingSubmoduleAccessMessage(name));
|
|
296
|
+
return (this.resolutions[name] = this.bindReference(def.root));
|
|
297
|
+
}
|
|
298
|
+
return (this.resolutions[name] = this.parse(def, {
|
|
299
|
+
alias: name
|
|
300
|
+
}));
|
|
301
|
+
}
|
|
302
|
+
createParseContext(input) {
|
|
303
|
+
const id = input.id ?? registerNodeId(input.prefix);
|
|
304
|
+
return (nodesByRegisteredId[id] = Object.assign(input, {
|
|
305
|
+
[arkKind]: "context",
|
|
306
|
+
$: this,
|
|
307
|
+
id,
|
|
308
|
+
phase: "unresolved"
|
|
309
|
+
}));
|
|
310
|
+
}
|
|
311
|
+
traversal(root) {
|
|
312
|
+
return new Traversal(root, this.resolvedConfig);
|
|
313
|
+
}
|
|
314
|
+
import(...names) {
|
|
315
|
+
return new RootModule(flatMorph(this.export(...names), (alias, value) => [
|
|
316
|
+
`#${alias}`,
|
|
317
|
+
value
|
|
318
|
+
]));
|
|
319
|
+
}
|
|
320
|
+
precompilation;
|
|
321
|
+
_exportedResolutions;
|
|
322
|
+
_exports;
|
|
323
|
+
export(...names) {
|
|
324
|
+
if (!this._exports) {
|
|
325
|
+
this._exports = {};
|
|
326
|
+
for (const name of this.exportedNames) {
|
|
327
|
+
const def = this.aliases[name];
|
|
328
|
+
this._exports[name] =
|
|
329
|
+
hasArkKind(def, "module") ?
|
|
330
|
+
bindModule(def, this)
|
|
331
|
+
: bootstrapAliasReferences(this.maybeResolve(name));
|
|
332
|
+
}
|
|
333
|
+
// force node.resolution getter evaluation
|
|
334
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
335
|
+
for (const node of this.lazyResolutions)
|
|
336
|
+
node.resolution;
|
|
337
|
+
this._exportedResolutions = resolutionsOfModule(this, this._exports);
|
|
338
|
+
this._json = resolutionsToJson(this._exportedResolutions);
|
|
339
|
+
Object.assign(this.resolutions, this._exportedResolutions);
|
|
340
|
+
this.references = Object.values(this.referencesById);
|
|
341
|
+
if (!this.resolvedConfig.jitless) {
|
|
342
|
+
const precompiler = precompileReferences(this.references);
|
|
343
|
+
this.precompilation = precompiler.write(rootScopeFnName, 4);
|
|
344
|
+
bindPrecompilation(this.references, precompiler);
|
|
345
|
+
}
|
|
346
|
+
this.resolved = true;
|
|
347
|
+
}
|
|
348
|
+
const namesToExport = names.length ? names : this.exportedNames;
|
|
349
|
+
return new RootModule(flatMorph(namesToExport, (_, name) => [
|
|
350
|
+
name,
|
|
351
|
+
this._exports[name]
|
|
352
|
+
]));
|
|
353
|
+
}
|
|
354
|
+
resolve(name) {
|
|
355
|
+
return this.export()[name];
|
|
356
|
+
}
|
|
357
|
+
node = (kinds, nodeSchema, opts = {}) => {
|
|
358
|
+
const ctxOrNode = this.preparseNode(kinds, nodeSchema, opts);
|
|
359
|
+
if (isNode(ctxOrNode))
|
|
360
|
+
return this.bindReference(ctxOrNode);
|
|
361
|
+
const ctx = this.createParseContext(ctxOrNode);
|
|
362
|
+
const node = parseNode(ctx);
|
|
363
|
+
const bound = this.bindReference(node);
|
|
364
|
+
return (nodesByRegisteredId[ctx.id] = bound);
|
|
365
|
+
};
|
|
366
|
+
parse = (def, opts = {}) => this.finalize(this.parseDefinition(def, opts));
|
|
367
|
+
parseDefinition(def, opts = {}) {
|
|
368
|
+
if (hasArkKind(def, "root"))
|
|
369
|
+
return this.bindReference(def);
|
|
370
|
+
const ctxInputOrNode = this.preparseOwnDefinitionFormat(def, opts);
|
|
371
|
+
if (hasArkKind(ctxInputOrNode, "root"))
|
|
372
|
+
return this.bindReference(ctxInputOrNode);
|
|
373
|
+
const ctx = this.createParseContext(ctxInputOrNode);
|
|
374
|
+
nodesByRegisteredId[ctx.id] = ctx;
|
|
375
|
+
let node = this.bindReference(this.parseOwnDefinitionFormat(def, ctx));
|
|
376
|
+
// if the node is recursive e.g. { box: "this" }, we need to make sure it
|
|
377
|
+
// has the original id from context so that its references compile correctly
|
|
378
|
+
if (node.isCyclic)
|
|
379
|
+
node = withId(node, ctx.id);
|
|
380
|
+
nodesByRegisteredId[ctx.id] = node;
|
|
381
|
+
return node;
|
|
382
|
+
}
|
|
383
|
+
finalize(node) {
|
|
384
|
+
bootstrapAliasReferences(node);
|
|
385
|
+
if (!node.precompilation && !this.resolvedConfig.jitless)
|
|
386
|
+
precompile(node.references);
|
|
387
|
+
return node;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
export class SchemaScope extends BaseScope {
|
|
391
|
+
parseOwnDefinitionFormat(def, ctx) {
|
|
392
|
+
return parseNode(ctx);
|
|
393
|
+
}
|
|
394
|
+
preparseOwnDefinitionFormat(schema, opts) {
|
|
395
|
+
return this.preparseNode(schemaKindOf(schema), schema, opts);
|
|
396
|
+
}
|
|
397
|
+
preparseOwnAliasEntry(k, v) {
|
|
398
|
+
return [k, v];
|
|
399
|
+
}
|
|
400
|
+
normalizeRootScopeValue(v) {
|
|
401
|
+
return v;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const bootstrapAliasReferences = (resolution) => {
|
|
405
|
+
const aliases = resolution.references.filter(node => node.hasKind("alias"));
|
|
406
|
+
for (const aliasNode of aliases) {
|
|
407
|
+
Object.assign(aliasNode.referencesById, aliasNode.resolution.referencesById);
|
|
408
|
+
for (const ref of resolution.references) {
|
|
409
|
+
if (aliasNode.id in ref.referencesById)
|
|
410
|
+
Object.assign(ref.referencesById, aliasNode.referencesById);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return resolution;
|
|
414
|
+
};
|
|
415
|
+
const resolutionsToJson = (resolutions) => flatMorph(resolutions, (k, v) => [
|
|
416
|
+
k,
|
|
417
|
+
hasArkKind(v, "root") || hasArkKind(v, "generic") ? v.json
|
|
418
|
+
: hasArkKind(v, "module") ? resolutionsToJson(v)
|
|
419
|
+
: throwInternalError(`Unexpected resolution ${printable(v)}`)
|
|
420
|
+
]);
|
|
421
|
+
const maybeResolveSubalias = (base, name) => {
|
|
422
|
+
const dotIndex = name.indexOf(".");
|
|
423
|
+
if (dotIndex === -1)
|
|
424
|
+
return;
|
|
425
|
+
const dotPrefix = name.slice(0, dotIndex);
|
|
426
|
+
const prefixSchema = base[dotPrefix];
|
|
427
|
+
// if the name includes ".", but the prefix is not an alias, it
|
|
428
|
+
// might be something like a decimal literal, so just fall through to return
|
|
429
|
+
if (prefixSchema === undefined)
|
|
430
|
+
return;
|
|
431
|
+
if (!hasArkKind(prefixSchema, "module"))
|
|
432
|
+
return throwParseError(writeNonSubmoduleDotMessage(dotPrefix));
|
|
433
|
+
const subalias = name.slice(dotIndex + 1);
|
|
434
|
+
const resolution = prefixSchema[subalias];
|
|
435
|
+
if (resolution === undefined)
|
|
436
|
+
return maybeResolveSubalias(prefixSchema, subalias);
|
|
437
|
+
if (hasArkKind(resolution, "root") || hasArkKind(resolution, "generic"))
|
|
438
|
+
return resolution;
|
|
439
|
+
if (hasArkKind(resolution, "module")) {
|
|
440
|
+
return (resolution.root ??
|
|
441
|
+
throwParseError(writeMissingSubmoduleAccessMessage(name)));
|
|
442
|
+
}
|
|
443
|
+
throwInternalError(`Unexpected resolution for alias '${name}': ${printable(resolution)}`);
|
|
444
|
+
};
|
|
445
|
+
export const schemaScope = (aliases, config) => new SchemaScope(aliases, config);
|
|
446
|
+
export const rootSchemaScope = new SchemaScope({});
|
|
447
|
+
export const parseAsSchema = (def, opts) => {
|
|
448
|
+
try {
|
|
449
|
+
return rootSchema(def, opts);
|
|
450
|
+
}
|
|
451
|
+
catch (e) {
|
|
452
|
+
if (e instanceof ParseError)
|
|
453
|
+
return e;
|
|
454
|
+
throw e;
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
const resolutionsOfModule = ($, typeSet) => {
|
|
458
|
+
const result = {};
|
|
459
|
+
for (const k in typeSet) {
|
|
460
|
+
const v = typeSet[k];
|
|
461
|
+
if (hasArkKind(v, "module")) {
|
|
462
|
+
const innerResolutions = resolutionsOfModule($, v);
|
|
463
|
+
const prefixedResolutions = flatMorph(innerResolutions, (innerK, innerV) => [`${k}.${innerK}`, innerV]);
|
|
464
|
+
Object.assign(result, prefixedResolutions);
|
|
465
|
+
}
|
|
466
|
+
else if (hasArkKind(v, "root") || hasArkKind(v, "generic"))
|
|
467
|
+
result[k] = v;
|
|
468
|
+
else
|
|
469
|
+
throwInternalError(`Unexpected scope resolution ${printable(v)}`);
|
|
470
|
+
}
|
|
471
|
+
return result;
|
|
472
|
+
};
|
|
473
|
+
export const writeUnresolvableMessage = (token) => `'${token}' is unresolvable`;
|
|
474
|
+
export const writeNonSubmoduleDotMessage = (name) => `'${name}' must reference a module to be accessed using dot syntax`;
|
|
475
|
+
export const writeMissingSubmoduleAccessMessage = (name) => `Reference to submodule '${name}' must specify an alias`;
|
|
476
|
+
// ensure the scope is resolved so JIT will be applied to future types
|
|
477
|
+
rootSchemaScope.export();
|
|
478
|
+
export const rootSchema = rootSchemaScope.schema;
|
|
479
|
+
export const node = rootSchemaScope.node;
|
|
480
|
+
export const defineSchema = rootSchemaScope.defineSchema;
|
|
481
|
+
export const genericNode = rootSchemaScope.generic;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CastableBase, type Fn } from "@ark/util";
|
|
2
|
+
import type { BaseNode } from "../node.ts";
|
|
3
|
+
import type { NodeId } from "../parse.ts";
|
|
4
|
+
import type { TraversalKind } from "./traversal.ts";
|
|
5
|
+
export type CoercibleValue = string | number | boolean | null | undefined;
|
|
6
|
+
export declare class CompiledFunction<compiledSignature = (...args: unknown[]) => unknown, args extends readonly string[] = readonly string[]> extends CastableBase<{
|
|
7
|
+
[k in args[number]]: k;
|
|
8
|
+
}> {
|
|
9
|
+
readonly argNames: args;
|
|
10
|
+
readonly body = "";
|
|
11
|
+
constructor(...args: args);
|
|
12
|
+
indentation: number;
|
|
13
|
+
indent(): this;
|
|
14
|
+
dedent(): this;
|
|
15
|
+
prop(key: PropertyKey, optional?: boolean): string;
|
|
16
|
+
index(key: string | number, optional?: boolean): string;
|
|
17
|
+
line(statement: string): this;
|
|
18
|
+
const(identifier: string, expression: CoercibleValue): this;
|
|
19
|
+
let(identifier: string, expression: CoercibleValue): this;
|
|
20
|
+
set(identifier: string, expression: CoercibleValue): this;
|
|
21
|
+
if(condition: string, then: (self: this) => this): this;
|
|
22
|
+
elseIf(condition: string, then: (self: this) => this): this;
|
|
23
|
+
else(then: (self: this) => this): this;
|
|
24
|
+
/** Current index is "i" */
|
|
25
|
+
for(until: string, body: (self: this) => this, initialValue?: CoercibleValue): this;
|
|
26
|
+
/** Current key is "k" */
|
|
27
|
+
forIn(object: string, body: (self: this) => this): this;
|
|
28
|
+
block(prefix: string, contents: (self: this) => this, suffix?: string): this;
|
|
29
|
+
return(expression?: CoercibleValue): this;
|
|
30
|
+
write(name?: string, indent?: number): string;
|
|
31
|
+
compile(): compiledSignature;
|
|
32
|
+
}
|
|
33
|
+
export declare const compileSerializedValue: (value: unknown) => string;
|
|
34
|
+
export declare const compileLiteralPropAccess: (key: PropertyKey, optional?: boolean) => string;
|
|
35
|
+
export declare const serializeLiteralKey: (key: PropertyKey) => string;
|
|
36
|
+
export declare const indexPropAccess: (key: string, optional?: boolean) => string;
|
|
37
|
+
export interface InvokeOptions extends ReferenceOptions {
|
|
38
|
+
arg?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ReferenceOptions {
|
|
41
|
+
kind?: TraversalKind;
|
|
42
|
+
bind?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare namespace NodeCompiler {
|
|
45
|
+
interface Context {
|
|
46
|
+
kind: TraversalKind;
|
|
47
|
+
optimistic?: true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export declare class NodeCompiler extends CompiledFunction<Fn, ["data", "ctx"]> {
|
|
51
|
+
traversalKind: TraversalKind;
|
|
52
|
+
optimistic: boolean;
|
|
53
|
+
constructor(ctx: NodeCompiler.Context);
|
|
54
|
+
invoke(node: BaseNode | NodeId, opts?: InvokeOptions): string;
|
|
55
|
+
referenceToId(id: NodeId, opts?: ReferenceOptions): string;
|
|
56
|
+
requiresContextFor(node: BaseNode): boolean;
|
|
57
|
+
initializeErrorCount(): this;
|
|
58
|
+
returnIfFail(): this;
|
|
59
|
+
returnIfFailFast(): this;
|
|
60
|
+
traverseKey(keyExpression: string, accessExpression: string, node: BaseNode): this;
|
|
61
|
+
check(node: BaseNode, opts?: InvokeOptions): this;
|
|
62
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { CastableBase, DynamicFunction, hasDomain, isDotAccessible, serializePrimitive } from "@ark/util";
|
|
2
|
+
import { registeredReference } from "./registry.js";
|
|
3
|
+
export class CompiledFunction extends CastableBase {
|
|
4
|
+
argNames;
|
|
5
|
+
body = "";
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super();
|
|
8
|
+
this.argNames = args;
|
|
9
|
+
for (const arg of args) {
|
|
10
|
+
if (arg in this) {
|
|
11
|
+
throw new Error(`Arg name '${arg}' would overwrite an existing property on FunctionBody`);
|
|
12
|
+
}
|
|
13
|
+
;
|
|
14
|
+
this[arg] = arg;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
indentation = 0;
|
|
18
|
+
indent() {
|
|
19
|
+
this.indentation += 4;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
dedent() {
|
|
23
|
+
this.indentation -= 4;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
prop(key, optional = false) {
|
|
27
|
+
return compileLiteralPropAccess(key, optional);
|
|
28
|
+
}
|
|
29
|
+
index(key, optional = false) {
|
|
30
|
+
return indexPropAccess(`${key}`, optional);
|
|
31
|
+
}
|
|
32
|
+
line(statement) {
|
|
33
|
+
;
|
|
34
|
+
this.body += `${" ".repeat(this.indentation)}${statement}\n`;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
const(identifier, expression) {
|
|
38
|
+
this.line(`const ${identifier} = ${expression}`);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
let(identifier, expression) {
|
|
42
|
+
return this.line(`let ${identifier} = ${expression}`);
|
|
43
|
+
}
|
|
44
|
+
set(identifier, expression) {
|
|
45
|
+
return this.line(`${identifier} = ${expression}`);
|
|
46
|
+
}
|
|
47
|
+
if(condition, then) {
|
|
48
|
+
return this.block(`if (${condition})`, then);
|
|
49
|
+
}
|
|
50
|
+
elseIf(condition, then) {
|
|
51
|
+
return this.block(`else if (${condition})`, then);
|
|
52
|
+
}
|
|
53
|
+
else(then) {
|
|
54
|
+
return this.block("else", then);
|
|
55
|
+
}
|
|
56
|
+
/** Current index is "i" */
|
|
57
|
+
for(until, body, initialValue = 0) {
|
|
58
|
+
return this.block(`for (let i = ${initialValue}; ${until}; i++)`, body);
|
|
59
|
+
}
|
|
60
|
+
/** Current key is "k" */
|
|
61
|
+
forIn(object, body) {
|
|
62
|
+
return this.block(`for (const k in ${object})`, body);
|
|
63
|
+
}
|
|
64
|
+
block(prefix, contents, suffix = "") {
|
|
65
|
+
this.line(`${prefix} {`);
|
|
66
|
+
this.indent();
|
|
67
|
+
contents(this);
|
|
68
|
+
this.dedent();
|
|
69
|
+
return this.line(`}${suffix}`);
|
|
70
|
+
}
|
|
71
|
+
return(expression = "") {
|
|
72
|
+
return this.line(`return ${expression}`);
|
|
73
|
+
}
|
|
74
|
+
write(name = "anonymous", indent = 0) {
|
|
75
|
+
return `${name}(${this.argNames.join(", ")}) { ${indent ?
|
|
76
|
+
this.body
|
|
77
|
+
.split("\n")
|
|
78
|
+
.map(l => " ".repeat(indent) + `${l}`)
|
|
79
|
+
.join("\n")
|
|
80
|
+
: this.body} }`;
|
|
81
|
+
}
|
|
82
|
+
compile() {
|
|
83
|
+
return new DynamicFunction(...this.argNames, this.body);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export const compileSerializedValue = (value) => hasDomain(value, "object") || typeof value === "symbol" ?
|
|
87
|
+
registeredReference(value)
|
|
88
|
+
: serializePrimitive(value);
|
|
89
|
+
export const compileLiteralPropAccess = (key, optional = false) => {
|
|
90
|
+
if (typeof key === "string" && isDotAccessible(key))
|
|
91
|
+
return `${optional ? "?" : ""}.${key}`;
|
|
92
|
+
return indexPropAccess(serializeLiteralKey(key), optional);
|
|
93
|
+
};
|
|
94
|
+
export const serializeLiteralKey = (key) => typeof key === "symbol" ? registeredReference(key) : JSON.stringify(key);
|
|
95
|
+
export const indexPropAccess = (key, optional = false) => `${optional ? "?." : ""}[${key}]`;
|
|
96
|
+
export class NodeCompiler extends CompiledFunction {
|
|
97
|
+
traversalKind;
|
|
98
|
+
optimistic;
|
|
99
|
+
constructor(ctx) {
|
|
100
|
+
super("data", "ctx");
|
|
101
|
+
this.traversalKind = ctx.kind;
|
|
102
|
+
this.optimistic = ctx.optimistic === true;
|
|
103
|
+
}
|
|
104
|
+
invoke(node, opts) {
|
|
105
|
+
const arg = opts?.arg ?? this.data;
|
|
106
|
+
const requiresContext = typeof node === "string" ? true : this.requiresContextFor(node);
|
|
107
|
+
const id = typeof node === "string" ? node : node.id;
|
|
108
|
+
if (requiresContext)
|
|
109
|
+
return `${this.referenceToId(id, opts)}(${arg}, ${this.ctx})`;
|
|
110
|
+
return `${this.referenceToId(id, opts)}(${arg})`;
|
|
111
|
+
}
|
|
112
|
+
referenceToId(id, opts) {
|
|
113
|
+
const invokedKind = opts?.kind ?? this.traversalKind;
|
|
114
|
+
const base = `this.${id}${invokedKind}`;
|
|
115
|
+
return opts?.bind ? `${base}.bind(${opts?.bind})` : base;
|
|
116
|
+
}
|
|
117
|
+
requiresContextFor(node) {
|
|
118
|
+
return this.traversalKind === "Apply" || node.allowsRequiresContext;
|
|
119
|
+
}
|
|
120
|
+
initializeErrorCount() {
|
|
121
|
+
return this.const("errorCount", "ctx.currentErrorCount");
|
|
122
|
+
}
|
|
123
|
+
returnIfFail() {
|
|
124
|
+
return this.if("ctx.currentErrorCount > errorCount", () => this.return());
|
|
125
|
+
}
|
|
126
|
+
returnIfFailFast() {
|
|
127
|
+
return this.if("ctx.failFast && ctx.currentErrorCount > errorCount", () => this.return());
|
|
128
|
+
}
|
|
129
|
+
traverseKey(keyExpression, accessExpression, node) {
|
|
130
|
+
const requiresContext = this.requiresContextFor(node);
|
|
131
|
+
if (requiresContext)
|
|
132
|
+
this.line(`${this.ctx}.path.push(${keyExpression})`);
|
|
133
|
+
this.check(node, {
|
|
134
|
+
arg: accessExpression
|
|
135
|
+
});
|
|
136
|
+
if (requiresContext)
|
|
137
|
+
this.line(`${this.ctx}.path.pop()`);
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
check(node, opts) {
|
|
141
|
+
return this.traversalKind === "Allows" ?
|
|
142
|
+
this.if(`!${this.invoke(node, opts)}`, () => this.return(false))
|
|
143
|
+
: this.line(this.invoke(node, opts));
|
|
144
|
+
}
|
|
145
|
+
}
|