@blade-hq/agent-client 1.1.1 → 1.1.3
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,33 @@
|
|
|
1
|
+
export type Fn<args extends readonly any[] = readonly any[], returns = unknown> = (...args: args) => returns;
|
|
2
|
+
export declare const cached: <t>(thunk: () => t) => (() => t);
|
|
3
|
+
export declare const isThunk: <value>(value: value) => value is Extract<value, Thunk> extends never ? value & Thunk : Extract<value, Thunk>;
|
|
4
|
+
export type Thunk<ret = unknown> = () => ret;
|
|
5
|
+
export type thunkable<t> = t | Thunk<t>;
|
|
6
|
+
export declare const tryCatch: <returns, onError = never>(fn: () => returns, onError?: (e: unknown) => onError) => returns | onError;
|
|
7
|
+
export declare const DynamicFunction: DynamicFunction;
|
|
8
|
+
export type DynamicFunction = new <fn extends Fn>(...args: ConstructorParameters<typeof Function>) => fn & {
|
|
9
|
+
apply(thisArg: null, args: Parameters<fn>): ReturnType<fn>;
|
|
10
|
+
call(thisArg: null, ...args: Parameters<fn>): ReturnType<fn>;
|
|
11
|
+
};
|
|
12
|
+
export type CallableOptions<attachments extends object> = {
|
|
13
|
+
attach?: attachments;
|
|
14
|
+
bind?: object;
|
|
15
|
+
};
|
|
16
|
+
/** @ts-ignore required to cast function type */
|
|
17
|
+
export interface Callable<fn extends Fn, attachments extends object> extends fn, attachments {
|
|
18
|
+
}
|
|
19
|
+
export declare class Callable<fn extends Fn, attachments extends object = {}> {
|
|
20
|
+
constructor(fn: fn, ...[opts]: {} extends attachments ? [opts?: CallableOptions<attachments>] : [opts: CallableOptions<attachments>]);
|
|
21
|
+
}
|
|
22
|
+
export type GuardablePredicate<input = unknown, narrowed extends input = input> = ((In: input) => In is narrowed) | ((In: input) => boolean);
|
|
23
|
+
export type TypeGuard<input = unknown, narrowed extends input = input> = (In: input) => In is narrowed;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the environment has Content Security Policy (CSP) enabled,
|
|
26
|
+
* preventing JIT-optimized code from being compiled via new Function().
|
|
27
|
+
*
|
|
28
|
+
* @returns `true` if a function created using new Function() can be
|
|
29
|
+
* successfully invoked in the environment, `false` otherwise.
|
|
30
|
+
*
|
|
31
|
+
* The result is cached for subsequent invocations.
|
|
32
|
+
*/
|
|
33
|
+
export declare const envHasCsp: () => boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { throwInternalError } from "./errors.js";
|
|
2
|
+
import { unset } from "./records.js";
|
|
3
|
+
export const cached = (thunk) => {
|
|
4
|
+
let result = unset;
|
|
5
|
+
return () => (result === unset ? (result = thunk()) : result);
|
|
6
|
+
};
|
|
7
|
+
export const isThunk = (value) => typeof value === "function" && value.length === 0;
|
|
8
|
+
export const tryCatch = (fn, onError) => {
|
|
9
|
+
try {
|
|
10
|
+
return fn();
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
return onError?.(e);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const DynamicFunction = class extends Function {
|
|
17
|
+
constructor(...args) {
|
|
18
|
+
const params = args.slice(0, -1);
|
|
19
|
+
const body = args[args.length - 1];
|
|
20
|
+
try {
|
|
21
|
+
super(...params, body);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
return throwInternalError(`Encountered an unexpected error while compiling your definition:
|
|
25
|
+
Message: ${e}
|
|
26
|
+
Source: (${args.slice(0, -1)}) => {
|
|
27
|
+
${args[args.length - 1]}
|
|
28
|
+
}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export class Callable {
|
|
33
|
+
constructor(fn, ...[opts]) {
|
|
34
|
+
return Object.assign(Object.setPrototypeOf(fn.bind(opts?.bind ?? this), this.constructor.prototype), opts?.attach);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Checks if the environment has Content Security Policy (CSP) enabled,
|
|
39
|
+
* preventing JIT-optimized code from being compiled via new Function().
|
|
40
|
+
*
|
|
41
|
+
* @returns `true` if a function created using new Function() can be
|
|
42
|
+
* successfully invoked in the environment, `false` otherwise.
|
|
43
|
+
*
|
|
44
|
+
* The result is cached for subsequent invocations.
|
|
45
|
+
*/
|
|
46
|
+
export const envHasCsp = cached(() => {
|
|
47
|
+
try {
|
|
48
|
+
return new Function("return false")();
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Primitive } from "./domain.ts";
|
|
2
|
+
import { type ErrorMessage } from "./errors.ts";
|
|
3
|
+
import type { unionToTuple } from "./unionToTuple.ts";
|
|
4
|
+
export type Stringifiable = string | boolean | number | bigint | null | undefined;
|
|
5
|
+
/** Force an operation like `{ a: 0 } & { b: 1 }` to be computed so that it displays `{ a: 0; b: 1 }`. */
|
|
6
|
+
export type show<t> = {
|
|
7
|
+
[k in keyof t]: t[k];
|
|
8
|
+
} & unknown;
|
|
9
|
+
/** @deprecated use "show" instead */
|
|
10
|
+
export type evaluate<t> = {
|
|
11
|
+
[k in keyof t]: t[k];
|
|
12
|
+
} & unknown;
|
|
13
|
+
export type get<t, k extends PropertyKey> = t[k & keyof t];
|
|
14
|
+
export type exact<t extends object, u extends object> = {
|
|
15
|
+
[k in keyof t]: k extends keyof u ? conform<t[k], u[k]> : never;
|
|
16
|
+
};
|
|
17
|
+
export type exactMessageOnError<t extends object, u extends object> = {
|
|
18
|
+
[k in keyof t]: k extends keyof u ? conform<t[k], u[k]> : ErrorMessage<`'${k & string}' is not a valid key`>;
|
|
19
|
+
} & u;
|
|
20
|
+
export type promisable<t> = t | Promise<t>;
|
|
21
|
+
export type leftIfEqual<l, r> = [l, r] extends [r, l] ? l : r;
|
|
22
|
+
export type UnknownUnion = string | number | symbol | bigint | boolean | object | null | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Interesection (`&`) that avoids evaluating `unknown` to `{}`
|
|
25
|
+
*/
|
|
26
|
+
export type andPreserveUnknown<l, r> = unknown extends l & r ? unknown : show<l & r>;
|
|
27
|
+
/** Can be used to test for the universal subtypes, `any` and `never`, e.g.:
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* type isAnyOrNever<t> = [t] extends [anyOrNever] ? true : false
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* The actual value is a string literal, but the only realistic subtypes
|
|
34
|
+
* of that literal are `any` and `never`.
|
|
35
|
+
*/
|
|
36
|
+
export type anyOrNever = " anyOrNever";
|
|
37
|
+
export type conform<t, base> = t extends base ? t : base;
|
|
38
|
+
export type equals<l, r> = [l, r] extends [r, l] ? true : false;
|
|
39
|
+
export type exactEquals<l, r> = (<_>() => _ extends l ? 1 : 2) extends <_>() => _ extends r ? 1 : 2 ? true : false;
|
|
40
|
+
export declare const brand: " brand";
|
|
41
|
+
export type Brand<t = unknown, id = unknown> = t & {
|
|
42
|
+
readonly [brand]: [t, id];
|
|
43
|
+
};
|
|
44
|
+
export type unbrand<t> = t extends Brand<infer base, string> ? base : never;
|
|
45
|
+
export type satisfy<base, t extends base> = t;
|
|
46
|
+
export type defined<t> = t & ({} | null);
|
|
47
|
+
export type autocomplete<suggestions extends string> = suggestions | (string & {});
|
|
48
|
+
export type widen<t, supertypes> = collectWidenedType<t, unionToTuple<supertypes>>;
|
|
49
|
+
type collectWidenedType<t, remaining extends unknown[], result = never> = remaining extends [infer head, ...infer tail] ? collectWidenedType<t, tail, t extends head ? result | head : result> : result;
|
|
50
|
+
type narrowTuple<t extends readonly unknown[]> = t extends readonly [infer head, ...infer tail] ? readonly [head, ...narrowTuple<tail>] : [];
|
|
51
|
+
export type narrow<t> = t extends Primitive ? t : t extends readonly unknown[] ? narrowTuple<t> : {
|
|
52
|
+
[k in keyof t]: narrow<t[k]>;
|
|
53
|
+
};
|
|
54
|
+
export declare const narrow: <t>(t: narrow<t>) => t;
|
|
55
|
+
/** primitive key used to represent an inferred type at compile-time */
|
|
56
|
+
export declare const inferred: " arkInferred";
|
|
57
|
+
/** primitive key used to represent an inferred type at compile-time */
|
|
58
|
+
export type inferred = typeof inferred;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { conform } from "./generics.ts";
|
|
2
|
+
import type { keyOf } from "./records.ts";
|
|
3
|
+
type getKey<o, k> = k extends keyof o ? o[k] : k extends `${infer n extends number & keyof o}` ? o[n] : never;
|
|
4
|
+
type getPath<o, path extends string> = path extends `${infer head}.${infer tail}` ? getPath<getKey<o, head>, tail> : getKey<o, path>;
|
|
5
|
+
type validatePath<o, path extends string, prefix extends string = ""> = path extends `${infer head}.${infer tail}` ? head extends keyOf<o> ? validatePath<getKey<o, head>, tail, `${prefix}${head}.`> : `Key '${head}' is not valid following '${prefix}'` : {
|
|
6
|
+
[k in keyOf<o>]: k extends `${path}${string}` ? `${prefix}${k}` : never;
|
|
7
|
+
}[keyOf<o>];
|
|
8
|
+
export declare const get: <const o extends object, path extends string>(data: o, pathStr: conform<path, string & validatePath<o, path>>) => getPath<o, path>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const args: " args";
|
|
2
|
+
type args = typeof args;
|
|
3
|
+
export declare abstract class Hkt<constraints extends unknown[] = any> {
|
|
4
|
+
[args]: unknown[];
|
|
5
|
+
constraints: constraints;
|
|
6
|
+
args: this[args] extends infer args extends unknown[] ? args : never;
|
|
7
|
+
0: this[args] extends [infer arg, ...any] ? arg : never;
|
|
8
|
+
1: this[args] extends [any, infer arg, ...any] ? arg : never;
|
|
9
|
+
2: this[args] extends [any, any, infer arg, ...any] ? arg : never;
|
|
10
|
+
3: this[args] extends [any, any, any, infer arg, ...any] ? arg : never;
|
|
11
|
+
abstract body: unknown;
|
|
12
|
+
description?: string;
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
/** A small set of HKT utility types based on https://github.com/gvergnaud/hotscript
|
|
16
|
+
* See https://github.com/gvergnaud/hotscript/blob/main/src/internals/core/Core.ts
|
|
17
|
+
*/
|
|
18
|
+
export declare namespace Hkt {
|
|
19
|
+
type constructor<constraints extends unknown[] = any> = new () => Hkt<constraints>;
|
|
20
|
+
type args = typeof args;
|
|
21
|
+
type apply<hkt extends Hkt, args extends {
|
|
22
|
+
[i in keyof args]: hkt["constraints"][i];
|
|
23
|
+
}> = (hkt & {
|
|
24
|
+
[args]: args;
|
|
25
|
+
})["body"];
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from "./arrays.ts";
|
|
2
|
+
export * from "./clone.ts";
|
|
3
|
+
export * from "./describe.ts";
|
|
4
|
+
export * from "./domain.ts";
|
|
5
|
+
export * from "./errors.ts";
|
|
6
|
+
export * from "./flatMorph.ts";
|
|
7
|
+
export * from "./functions.ts";
|
|
8
|
+
export * from "./generics.ts";
|
|
9
|
+
export * from "./hkt.ts";
|
|
10
|
+
export * from "./intersections.ts";
|
|
11
|
+
export * from "./isomorphic.ts";
|
|
12
|
+
export * from "./keys.ts";
|
|
13
|
+
export * from "./lazily.ts";
|
|
14
|
+
export * from "./numbers.ts";
|
|
15
|
+
export * from "./objectKinds.ts";
|
|
16
|
+
export * from "./path.ts";
|
|
17
|
+
export * from "./primitive.ts";
|
|
18
|
+
export * from "./records.ts";
|
|
19
|
+
export * from "./registry.ts";
|
|
20
|
+
export * from "./scanner.ts";
|
|
21
|
+
export * from "./serialize.ts";
|
|
22
|
+
export * from "./strings.ts";
|
|
23
|
+
export * from "./traits.ts";
|
|
24
|
+
export * from "./unionToTuple.ts";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from "./arrays.js";
|
|
2
|
+
export * from "./clone.js";
|
|
3
|
+
export * from "./describe.js";
|
|
4
|
+
export * from "./domain.js";
|
|
5
|
+
export * from "./errors.js";
|
|
6
|
+
export * from "./flatMorph.js";
|
|
7
|
+
export * from "./functions.js";
|
|
8
|
+
export * from "./generics.js";
|
|
9
|
+
export * from "./hkt.js";
|
|
10
|
+
export * from "./intersections.js";
|
|
11
|
+
export * from "./isomorphic.js";
|
|
12
|
+
export * from "./keys.js";
|
|
13
|
+
export * from "./lazily.js";
|
|
14
|
+
export * from "./numbers.js";
|
|
15
|
+
export * from "./objectKinds.js";
|
|
16
|
+
export * from "./path.js";
|
|
17
|
+
export * from "./primitive.js";
|
|
18
|
+
export * from "./records.js";
|
|
19
|
+
export * from "./registry.js";
|
|
20
|
+
export * from "./scanner.js";
|
|
21
|
+
export * from "./serialize.js";
|
|
22
|
+
export * from "./strings.js";
|
|
23
|
+
export * from "./traits.js";
|
|
24
|
+
export * from "./unionToTuple.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { array } from "./arrays.ts";
|
|
2
|
+
import type { domainOf } from "./domain.ts";
|
|
3
|
+
import type { andPreserveUnknown } from "./generics.ts";
|
|
4
|
+
import type { Hkt } from "./hkt.ts";
|
|
5
|
+
import type { propValueOf, requiredKeyOf } from "./records.ts";
|
|
6
|
+
export interface AndPreserveUnknown extends Hkt<[unknown, unknown]> {
|
|
7
|
+
body: andPreserveUnknown<this[0], this[1]>;
|
|
8
|
+
}
|
|
9
|
+
type SequenceIntersectionKind = "array" | "parameters";
|
|
10
|
+
export type intersectArrays<l extends array, r extends array, operator extends Hkt = AndPreserveUnknown> = intersectSequences<l, r, [], [], operator, "array">;
|
|
11
|
+
export type intersectParameters<l extends array, r extends array, operator extends Hkt = AndPreserveUnknown> = intersectSequences<l, r, [], [], operator, "parameters">;
|
|
12
|
+
type intersectSequences<l extends array, r extends array, acc extends array, postfix extends array, operation extends Hkt, kind extends SequenceIntersectionKind> = l extends readonly [] ? kind extends "array" ? [
|
|
13
|
+
] extends r ? [
|
|
14
|
+
...acc,
|
|
15
|
+
...postfix
|
|
16
|
+
] : never : [...acc, ...r, ...postfix] : r extends readonly [] ? kind extends "array" ? [
|
|
17
|
+
] extends l ? [
|
|
18
|
+
...acc,
|
|
19
|
+
...postfix
|
|
20
|
+
] : never : [...acc, ...l, ...postfix] : [
|
|
21
|
+
l,
|
|
22
|
+
r
|
|
23
|
+
] extends ([
|
|
24
|
+
readonly [(infer lHead)?, ...infer lTail],
|
|
25
|
+
readonly [(infer rHead)?, ...infer rTail]
|
|
26
|
+
]) ? [
|
|
27
|
+
"0",
|
|
28
|
+
lHead,
|
|
29
|
+
rHead
|
|
30
|
+
] extends [keyof l | keyof r, l[0], r[0]] ? intersectSequences<lTail, rTail, [
|
|
31
|
+
[],
|
|
32
|
+
[]
|
|
33
|
+
] extends [l, r] ? [
|
|
34
|
+
...acc,
|
|
35
|
+
Hkt.apply<operation, [lHead, rHead]>?
|
|
36
|
+
] : [...acc, Hkt.apply<operation, [lHead, rHead]>], postfix, operation, kind> : l extends readonly [...infer lInit, infer lLast] ? r extends readonly [...infer rInit, infer rLast] ? intersectSequences<lInit, rInit, acc, [
|
|
37
|
+
Hkt.apply<operation, [lLast, rLast]>,
|
|
38
|
+
...postfix
|
|
39
|
+
], operation, kind> : intersectSequences<lInit, r, acc, [
|
|
40
|
+
Hkt.apply<operation, [lLast, r[number]]>,
|
|
41
|
+
...postfix
|
|
42
|
+
], operation, kind> : r extends readonly [...infer rInit, infer rLast] ? intersectSequences<l, rInit, acc, [
|
|
43
|
+
Hkt.apply<operation, [l[number], rLast]>,
|
|
44
|
+
...postfix
|
|
45
|
+
], operation, kind> : [...acc, ...Hkt.apply<operation, [lHead, rHead]>[], ...postfix] : never;
|
|
46
|
+
export type isDisjoint<l, r> = overlaps<l, r> extends true ? false : true;
|
|
47
|
+
export type overlaps<l, r> = l & r extends never ? false : domainOf<l> & domainOf<r> extends never ? false : [l, r] extends [object, object] ? false extends (propValueOf<{
|
|
48
|
+
[k in Extract<keyof l & keyof r, requiredKeyOf<l> | requiredKeyOf<r>>]: overlaps<l[k], r[k]>;
|
|
49
|
+
}>) ? false : true : true;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// based on the util of the same name in @ark/fs
|
|
2
|
+
// isolated here for use with registry
|
|
3
|
+
/** get a CJS/ESM compatible string representing the current file */
|
|
4
|
+
const fileName = () => {
|
|
5
|
+
try {
|
|
6
|
+
const error = new Error();
|
|
7
|
+
const stackLine = error.stack?.split("\n")[2]?.trim() || ""; // [1]=this func, [2]=caller
|
|
8
|
+
const filePath = stackLine.match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1] || "unknown";
|
|
9
|
+
return filePath.replace(/^file:\/\//, "");
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return "unknown";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const env = globalThis.process?.env ?? {};
|
|
16
|
+
export const isomorphic = {
|
|
17
|
+
fileName,
|
|
18
|
+
env
|
|
19
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { array, join } from "./arrays.ts";
|
|
2
|
+
import type { NonNegativeIntegerLiteral } from "./numbers.ts";
|
|
3
|
+
export type Key = string | symbol;
|
|
4
|
+
export type toArkKey<o, k extends keyof o> = k extends number ? [
|
|
5
|
+
o,
|
|
6
|
+
number
|
|
7
|
+
] extends [array, k] ? NonNegativeIntegerLiteral : `${k}` : k;
|
|
8
|
+
export type arkIndexableOf<o> = arkKeyOf<o> extends infer k ? k extends `${infer index extends number}` ? index | k : k : never;
|
|
9
|
+
export type arkKeyOf<o> = [
|
|
10
|
+
o
|
|
11
|
+
] extends [object] ? [
|
|
12
|
+
o
|
|
13
|
+
] extends [array] ? arkArrayKeyOf<o> : arkObjectLiteralKeyOf<o> : never;
|
|
14
|
+
type arkArrayKeyOf<a extends array> = number extends a["length"] ? NonNegativeIntegerLiteral : keyof a extends infer i ? i extends `${number}` ? i : never : never;
|
|
15
|
+
type arkObjectLiteralKeyOf<o extends object> = keyof o extends infer k ? k extends number ? `${k}` : k : never;
|
|
16
|
+
export type arkGet<o, k extends arkIndexableOf<o>> = o[k extends keyof o ? k : NonNegativeIntegerLiteral extends k ? number & keyof o : k extends number ? `${k}` & keyof o : never];
|
|
17
|
+
export type writeInvalidKeysMessage<o extends string, keys extends array<string>> = `Key${keys["length"] extends 1 ? "" : "s"} ${join<keys, ", ">} ${keys["length"] extends 1 ? "does" : "do"} not exist on ${o}`;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const lazily: <t extends object>(thunk: () => t) => t;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const lazily = (thunk) => {
|
|
2
|
+
let cached;
|
|
3
|
+
return new Proxy({}, {
|
|
4
|
+
get: (_, prop) => {
|
|
5
|
+
if (!cached)
|
|
6
|
+
cached = thunk();
|
|
7
|
+
return cached[prop];
|
|
8
|
+
},
|
|
9
|
+
set: (_, prop, value) => {
|
|
10
|
+
if (!cached)
|
|
11
|
+
cached = thunk();
|
|
12
|
+
cached[prop] = value;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
2
|
+
export type NumberLiteral<n extends number = number> = `${n}`;
|
|
3
|
+
export type BigintLiteral<n extends bigint = bigint> = `${n}n`;
|
|
4
|
+
export type IntegerLiteral<n extends bigint = bigint> = `${n}`;
|
|
5
|
+
export type NonNegativeIntegerLiteral<n extends bigint = bigint> = `${Digit}` | (`${Exclude<Digit, 0>}${string}` & `${n}`);
|
|
6
|
+
/**
|
|
7
|
+
* Matches a well-formatted numeric expression according to the following rules:
|
|
8
|
+
* 1. Must include an integer portion (i.e. '.321' must be written as '0.321')
|
|
9
|
+
* 2. The first digit of the value must not be 0, unless the entire integer portion is 0
|
|
10
|
+
* 3. If the value includes a decimal, its last digit may not be 0
|
|
11
|
+
* 4. The value may not be "-0"
|
|
12
|
+
*/
|
|
13
|
+
export declare const wellFormedNumberMatcher: RegExp;
|
|
14
|
+
export declare const isWellFormedNumber: RegExp["test"];
|
|
15
|
+
/**
|
|
16
|
+
* Similar to wellFormedNumber but more permissive in the following ways:
|
|
17
|
+
*
|
|
18
|
+
* - Allows numbers without an integer portion like ".5" (well-formed equivalent is "0.5")
|
|
19
|
+
* - Allows decimals with trailing zeroes like "0.10" (well-formed equivalent is "0.1")
|
|
20
|
+
*/
|
|
21
|
+
export declare const numericStringMatcher: RegExp;
|
|
22
|
+
export declare const isNumericString: (string: string) => boolean;
|
|
23
|
+
export declare const numberLikeMatcher: RegExp;
|
|
24
|
+
/**
|
|
25
|
+
* Matches a well-formatted integer according to the following rules:
|
|
26
|
+
* 1. must begin with an integer, the first digit of which cannot be 0 unless the entire value is 0
|
|
27
|
+
* 2. The value may not be "-0"
|
|
28
|
+
*/
|
|
29
|
+
export declare const wellFormedIntegerMatcher: RegExp;
|
|
30
|
+
export declare const isWellFormedInteger: RegExp["test"];
|
|
31
|
+
export declare const integerLikeMatcher: RegExp;
|
|
32
|
+
type NumericLiteralKind = "number" | "bigint" | "integer";
|
|
33
|
+
declare const numericLiteralDescriptions: {
|
|
34
|
+
readonly number: "a number";
|
|
35
|
+
readonly bigint: "a bigint";
|
|
36
|
+
readonly integer: "an integer";
|
|
37
|
+
};
|
|
38
|
+
type numericLiteralDescriptions = typeof numericLiteralDescriptions;
|
|
39
|
+
export type writeMalformedNumericLiteralMessage<def extends string, kind extends NumericLiteralKind> = `'${def}' was parsed as ${numericLiteralDescriptions[kind]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`;
|
|
40
|
+
export declare const writeMalformedNumericLiteralMessage: <def extends string, kind extends NumericLiteralKind>(def: def, kind: kind) => writeMalformedNumericLiteralMessage<def, kind>;
|
|
41
|
+
export declare const tryParseNumber: <errorOnFail extends boolean | string>(token: string, options?: NumericParseOptions<errorOnFail>) => errorOnFail extends true | string ? number : number | undefined;
|
|
42
|
+
export declare const tryParseWellFormedNumber: typeof tryParseNumber;
|
|
43
|
+
export type tryParseNumber<token extends string, messageOnFail extends string> = token extends `${infer n extends number}` ? number extends n ? writeMalformedNumericLiteralMessage<token, "number"> : n : messageOnFail;
|
|
44
|
+
export type parseNumber<token extends string> = token extends `${infer n extends number}` ? n : never;
|
|
45
|
+
export declare const tryParseInteger: <errorOnFail extends boolean | string>(token: string, options?: NumericParseOptions<errorOnFail>) => errorOnFail extends true | string ? number : number | undefined;
|
|
46
|
+
export type tryParseInteger<token extends string, messageOnFail extends string> = token extends `${infer b extends bigint}` ? bigint extends b ? writeMalformedNumericLiteralMessage<token, "integer"> : token extends `${infer n extends number}` ? n : never : messageOnFail;
|
|
47
|
+
export type parseInteger<token extends string> = token extends `${bigint}` ? token extends `${infer n extends number}` ? n : never : never;
|
|
48
|
+
export type parseNonNegativeInteger<token extends string> = token extends `-${string}` ? never : parseInteger<token>;
|
|
49
|
+
export type NumericParseOptions<errorOnFail extends boolean | string> = {
|
|
50
|
+
errorOnFail?: errorOnFail;
|
|
51
|
+
strict?: boolean;
|
|
52
|
+
};
|
|
53
|
+
export declare const tryParseWellFormedBigint: (def: string) => bigint | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the next or previous representable floating-point number after the given input.
|
|
56
|
+
*
|
|
57
|
+
* @param {"+" | "-"} [direction="+"] - The direction to find the nearest float. "+" for the next float, "-" for the previous float.
|
|
58
|
+
* @throws {Error} If the input is not a finite number.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* console.log(nearestFloat(0)); // Smallest positive number
|
|
62
|
+
* console.log(nearestFloat(2)); // 2.0000000000000004
|
|
63
|
+
* console.log(nearestFloat(2.1)); // 2.1000000000000005
|
|
64
|
+
* console.log(nearestFloat(2, "-")); // 1.9999999999999998
|
|
65
|
+
* console.log(nearestFloat(2.1, "-")); // 2.0999999999999996
|
|
66
|
+
* // as size of input increases, the increments become larger to stay within what
|
|
67
|
+
* // JS can represent in a numeric value
|
|
68
|
+
* console.log(nearestFloat(5555555555555555)); // 5555555555555556
|
|
69
|
+
* console.log(nearestFloat(5555555555555555, "-")); // 5555555555555554
|
|
70
|
+
*/
|
|
71
|
+
export declare const nearestFloat: (n: number, direction?: "+" | "-") => number;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { throwParseError } from "./errors.js";
|
|
2
|
+
import { anchoredRegex, RegexPatterns } from "./strings.js";
|
|
3
|
+
/*
|
|
4
|
+
* The goal of the number literal and bigint literal regular expressions is to:
|
|
5
|
+
*
|
|
6
|
+
* 1. Ensure definitions form a bijection with the values they represent.
|
|
7
|
+
* 2. Attempt to mirror TypeScript's own format for stringification of numeric
|
|
8
|
+
* values such that the regex should match a given definition if any only if
|
|
9
|
+
* a precise literal type will be inferred (in TS4.8+).
|
|
10
|
+
*/
|
|
11
|
+
const anchoredNegativeZeroPattern = /^-0\.?0*$/.source;
|
|
12
|
+
const positiveIntegerPattern = /[1-9]\d*/.source;
|
|
13
|
+
const looseDecimalPattern = /\.\d+/.source;
|
|
14
|
+
const strictDecimalPattern = /\.\d*[1-9]/.source;
|
|
15
|
+
const createNumberMatcher = (opts) => anchoredRegex(RegexPatterns.negativeLookahead(anchoredNegativeZeroPattern) +
|
|
16
|
+
RegexPatterns.nonCapturingGroup("-?" +
|
|
17
|
+
RegexPatterns.nonCapturingGroup(RegexPatterns.nonCapturingGroup("0|" + positiveIntegerPattern) +
|
|
18
|
+
RegexPatterns.nonCapturingGroup(opts.decimalPattern) +
|
|
19
|
+
"?") +
|
|
20
|
+
(opts.allowDecimalOnly ? "|" + opts.decimalPattern : "") +
|
|
21
|
+
"?"));
|
|
22
|
+
/**
|
|
23
|
+
* Matches a well-formatted numeric expression according to the following rules:
|
|
24
|
+
* 1. Must include an integer portion (i.e. '.321' must be written as '0.321')
|
|
25
|
+
* 2. The first digit of the value must not be 0, unless the entire integer portion is 0
|
|
26
|
+
* 3. If the value includes a decimal, its last digit may not be 0
|
|
27
|
+
* 4. The value may not be "-0"
|
|
28
|
+
*/
|
|
29
|
+
export const wellFormedNumberMatcher = createNumberMatcher({
|
|
30
|
+
decimalPattern: strictDecimalPattern,
|
|
31
|
+
allowDecimalOnly: false
|
|
32
|
+
});
|
|
33
|
+
export const isWellFormedNumber = wellFormedNumberMatcher.test.bind(wellFormedNumberMatcher);
|
|
34
|
+
/**
|
|
35
|
+
* Similar to wellFormedNumber but more permissive in the following ways:
|
|
36
|
+
*
|
|
37
|
+
* - Allows numbers without an integer portion like ".5" (well-formed equivalent is "0.5")
|
|
38
|
+
* - Allows decimals with trailing zeroes like "0.10" (well-formed equivalent is "0.1")
|
|
39
|
+
*/
|
|
40
|
+
export const numericStringMatcher = createNumberMatcher({
|
|
41
|
+
decimalPattern: looseDecimalPattern,
|
|
42
|
+
allowDecimalOnly: true
|
|
43
|
+
});
|
|
44
|
+
export const isNumericString = numericStringMatcher.test.bind(numericStringMatcher);
|
|
45
|
+
export const numberLikeMatcher = /^-?\d*\.?\d*$/;
|
|
46
|
+
const isNumberLike = (s) => s.length !== 0 && numberLikeMatcher.test(s);
|
|
47
|
+
/**
|
|
48
|
+
* Matches a well-formatted integer according to the following rules:
|
|
49
|
+
* 1. must begin with an integer, the first digit of which cannot be 0 unless the entire value is 0
|
|
50
|
+
* 2. The value may not be "-0"
|
|
51
|
+
*/
|
|
52
|
+
export const wellFormedIntegerMatcher = anchoredRegex(RegexPatterns.negativeLookahead("^-0$") +
|
|
53
|
+
"-?" +
|
|
54
|
+
RegexPatterns.nonCapturingGroup(RegexPatterns.nonCapturingGroup("0|" + positiveIntegerPattern)));
|
|
55
|
+
export const isWellFormedInteger = wellFormedIntegerMatcher.test.bind(wellFormedIntegerMatcher);
|
|
56
|
+
export const integerLikeMatcher = /^-?\d+$/;
|
|
57
|
+
const isIntegerLike = integerLikeMatcher.test.bind(integerLikeMatcher);
|
|
58
|
+
const numericLiteralDescriptions = {
|
|
59
|
+
number: "a number",
|
|
60
|
+
bigint: "a bigint",
|
|
61
|
+
integer: "an integer"
|
|
62
|
+
};
|
|
63
|
+
export const writeMalformedNumericLiteralMessage = (def, kind) => `'${def}' was parsed as ${numericLiteralDescriptions[kind]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`;
|
|
64
|
+
const isWellFormed = (def, kind) => kind === "number" ? isWellFormedNumber(def) : isWellFormedInteger(def);
|
|
65
|
+
const parseKind = (def, kind) => kind === "number" ? Number(def) : Number.parseInt(def);
|
|
66
|
+
const isKindLike = (def, kind) => kind === "number" ? isNumberLike(def) : isIntegerLike(def);
|
|
67
|
+
export const tryParseNumber = (token, options) => parseNumeric(token, "number", options);
|
|
68
|
+
export const tryParseWellFormedNumber = (token, options) => parseNumeric(token, "number", { ...options, strict: true });
|
|
69
|
+
export const tryParseInteger = (token, options) => parseNumeric(token, "integer", options);
|
|
70
|
+
const parseNumeric = (token, kind, options) => {
|
|
71
|
+
const value = parseKind(token, kind);
|
|
72
|
+
if (!Number.isNaN(value)) {
|
|
73
|
+
if (isKindLike(token, kind)) {
|
|
74
|
+
if (options?.strict) {
|
|
75
|
+
return isWellFormed(token, kind) ? value : (throwParseError(writeMalformedNumericLiteralMessage(token, kind)));
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return (options?.errorOnFail ?
|
|
81
|
+
throwParseError(options?.errorOnFail === true ?
|
|
82
|
+
`Failed to parse ${numericLiteralDescriptions[kind]} from '${token}'`
|
|
83
|
+
: options?.errorOnFail)
|
|
84
|
+
: undefined);
|
|
85
|
+
};
|
|
86
|
+
export const tryParseWellFormedBigint = (def) => {
|
|
87
|
+
if (def[def.length - 1] !== "n")
|
|
88
|
+
return;
|
|
89
|
+
const maybeIntegerLiteral = def.slice(0, -1);
|
|
90
|
+
let value;
|
|
91
|
+
try {
|
|
92
|
+
value = BigInt(maybeIntegerLiteral);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (wellFormedIntegerMatcher.test(maybeIntegerLiteral))
|
|
98
|
+
return value;
|
|
99
|
+
if (integerLikeMatcher.test(maybeIntegerLiteral)) {
|
|
100
|
+
// If the definition looks like a bigint but is
|
|
101
|
+
// not well-formed, throw.
|
|
102
|
+
return throwParseError(writeMalformedNumericLiteralMessage(def, "bigint"));
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Returns the next or previous representable floating-point number after the given input.
|
|
107
|
+
*
|
|
108
|
+
* @param {"+" | "-"} [direction="+"] - The direction to find the nearest float. "+" for the next float, "-" for the previous float.
|
|
109
|
+
* @throws {Error} If the input is not a finite number.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* console.log(nearestFloat(0)); // Smallest positive number
|
|
113
|
+
* console.log(nearestFloat(2)); // 2.0000000000000004
|
|
114
|
+
* console.log(nearestFloat(2.1)); // 2.1000000000000005
|
|
115
|
+
* console.log(nearestFloat(2, "-")); // 1.9999999999999998
|
|
116
|
+
* console.log(nearestFloat(2.1, "-")); // 2.0999999999999996
|
|
117
|
+
* // as size of input increases, the increments become larger to stay within what
|
|
118
|
+
* // JS can represent in a numeric value
|
|
119
|
+
* console.log(nearestFloat(5555555555555555)); // 5555555555555556
|
|
120
|
+
* console.log(nearestFloat(5555555555555555, "-")); // 5555555555555554
|
|
121
|
+
*/
|
|
122
|
+
export const nearestFloat = (n, direction = "+") => {
|
|
123
|
+
const buffer = new ArrayBuffer(8);
|
|
124
|
+
const f64 = new Float64Array(buffer);
|
|
125
|
+
const u32 = new Uint32Array(buffer);
|
|
126
|
+
f64[0] = n;
|
|
127
|
+
if (n === 0) {
|
|
128
|
+
u32[0] = 1;
|
|
129
|
+
u32[1] = direction === "-" ? 1 << 31 : 0;
|
|
130
|
+
}
|
|
131
|
+
else if ((n > 0 && direction === "+") || (n < 0 && direction === "-")) {
|
|
132
|
+
if (u32[0]++ === 0xffffffff)
|
|
133
|
+
u32[1]++;
|
|
134
|
+
}
|
|
135
|
+
else if (u32[0]-- === 0)
|
|
136
|
+
u32[1]--;
|
|
137
|
+
return f64[0];
|
|
138
|
+
};
|