effect 4.1.4 → 4.1.5
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/THIRD_PARTY_NOTICES.md +88 -0
- package/ai-docs/package.json +2 -2
- package/dist/Arbitrary.d.ts +44 -2
- package/dist/Arbitrary.d.ts.map +1 -1
- package/dist/Arbitrary.js +9 -1
- package/dist/Arbitrary.js.map +1 -1
- package/dist/BigInt.d.ts +200 -1
- package/dist/BigInt.d.ts.map +1 -1
- package/dist/BigInt.js +105 -9
- package/dist/BigInt.js.map +1 -1
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +4 -2
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +3 -3
- package/dist/Cause.js +1 -1
- package/dist/Chunk.d.ts +5 -0
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +7 -2
- package/dist/Chunk.js.map +1 -1
- package/dist/Clock.d.ts +5 -2
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +2 -1
- package/dist/Clock.js.map +1 -1
- package/dist/Codegen.d.ts +295 -0
- package/dist/Codegen.d.ts.map +1 -0
- package/dist/Codegen.js +521 -0
- package/dist/Codegen.js.map +1 -0
- package/dist/Config.d.ts +31 -2
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +12 -1
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +11 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +17 -6
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Effect.d.ts +869 -109
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +400 -47
- package/dist/Effect.js.map +1 -1
- package/dist/Equivalence.d.ts +11 -9
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +15 -12
- package/dist/Equivalence.js.map +1 -1
- package/dist/Fiber.d.ts +58 -8
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js +28 -4
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.d.ts +81 -10
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +40 -8
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +80 -10
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +37 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FiberSet.d.ts +93 -8
- package/dist/FiberSet.d.ts.map +1 -1
- package/dist/FiberSet.js +46 -4
- package/dist/FiberSet.js.map +1 -1
- package/dist/Formatter.d.ts +2 -0
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +2 -0
- package/dist/Formatter.js.map +1 -1
- package/dist/LayerMap.d.ts +12 -3
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +12 -2
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts +2 -2
- package/dist/Match.d.ts +12 -0
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +16 -0
- package/dist/Match.js.map +1 -1
- package/dist/Metric.js +1 -1
- package/dist/Metric.js.map +1 -1
- package/dist/Option.d.ts +4 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +6 -2
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +7 -5
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +7 -2
- package/dist/Order.js.map +1 -1
- package/dist/Pool.d.ts +4 -3
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +21 -18
- package/dist/Pool.js.map +1 -1
- package/dist/Predicate.d.ts +4 -1
- package/dist/Predicate.d.ts.map +1 -1
- package/dist/Predicate.js +5 -1
- package/dist/Predicate.js.map +1 -1
- package/dist/Queue.d.ts +69 -22
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +40 -18
- package/dist/Queue.js.map +1 -1
- package/dist/Rational.d.ts +179 -0
- package/dist/Rational.d.ts.map +1 -1
- package/dist/Rational.js +63 -0
- package/dist/Rational.js.map +1 -1
- package/dist/Request.d.ts +20 -0
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +20 -0
- package/dist/Request.js.map +1 -1
- package/dist/Result.d.ts +3 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +5 -2
- package/dist/Result.js.map +1 -1
- package/dist/Schema.d.ts +49 -19
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +44 -27
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +11 -4
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +5 -6
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +14 -10
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +19 -64
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +1 -28
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +11 -10
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +12 -11
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +12 -6
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +12 -6
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +2 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +18 -4
- package/dist/Semaphore.js.map +1 -1
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +55 -14
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +57 -3
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +62 -4
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts +135 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +64 -5
- package/dist/Struct.js.map +1 -1
- package/dist/TextDiff.d.ts +105 -0
- package/dist/TextDiff.d.ts.map +1 -1
- package/dist/TextDiff.js +137 -24
- package/dist/TextDiff.js.map +1 -1
- package/dist/TxPriorityQueue.js +2 -2
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +1 -1
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +88 -88
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpServer.d.ts +47 -2
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +135 -16
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Tool.d.ts +3 -2
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +3 -2
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +5 -1
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/chat/Chat.d.ts +90 -0
- package/dist/chat/Chat.d.ts.map +1 -0
- package/dist/chat/Chat.js +127 -0
- package/dist/chat/Chat.js.map +1 -0
- package/dist/chat/ChatAdapter.d.ts +386 -0
- package/dist/chat/ChatAdapter.d.ts.map +1 -0
- package/dist/chat/ChatAdapter.js +110 -0
- package/dist/chat/ChatAdapter.js.map +1 -0
- package/dist/chat/ChatError.d.ts +500 -0
- package/dist/chat/ChatError.d.ts.map +1 -0
- package/dist/chat/ChatError.js +521 -0
- package/dist/chat/ChatError.js.map +1 -0
- package/dist/chat/ChatEvent.d.ts +321 -0
- package/dist/chat/ChatEvent.d.ts.map +1 -0
- package/dist/chat/ChatEvent.js +163 -0
- package/dist/chat/ChatEvent.js.map +1 -0
- package/dist/chat/ChatHandler.d.ts +81 -0
- package/dist/chat/ChatHandler.d.ts.map +1 -0
- package/dist/chat/ChatHandler.js +85 -0
- package/dist/chat/ChatHandler.js.map +1 -0
- package/dist/chat/ChatInteraction.d.ts +1519 -0
- package/dist/chat/ChatInteraction.d.ts.map +1 -0
- package/dist/chat/ChatInteraction.js +1052 -0
- package/dist/chat/ChatInteraction.js.map +1 -0
- package/dist/chat/ChatMarkdown.d.ts +280 -0
- package/dist/chat/ChatMarkdown.d.ts.map +1 -0
- package/dist/chat/ChatMarkdown.js +1172 -0
- package/dist/chat/ChatMarkdown.js.map +1 -0
- package/dist/chat/ChatMessage.d.ts +224 -0
- package/dist/chat/ChatMessage.d.ts.map +1 -0
- package/dist/chat/ChatMessage.js +172 -0
- package/dist/chat/ChatMessage.js.map +1 -0
- package/dist/chat/ChatTest.d.ts +407 -0
- package/dist/chat/ChatTest.d.ts.map +1 -0
- package/dist/chat/ChatTest.js +2145 -0
- package/dist/chat/ChatTest.js.map +1 -0
- package/dist/chat/ChatThread.d.ts +92 -0
- package/dist/chat/ChatThread.d.ts.map +1 -0
- package/dist/chat/ChatThread.js +116 -0
- package/dist/chat/ChatThread.js.map +1 -0
- package/dist/chat/ChatUi.d.ts +362 -0
- package/dist/chat/ChatUi.d.ts.map +1 -0
- package/dist/chat/ChatUi.js +209 -0
- package/dist/chat/ChatUi.js.map +1 -0
- package/dist/chat/index.d.ts +60 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +61 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/internal/retries.d.ts +2 -0
- package/dist/chat/internal/retries.d.ts.map +1 -0
- package/dist/chat/internal/retries.js +7 -0
- package/dist/chat/internal/retries.js.map +1 -0
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +6 -7
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +20 -2
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +4 -0
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Prompt.d.ts +5 -6
- package/dist/cli/Prompt.d.ts.map +1 -1
- package/dist/cli/Prompt.js +9 -4
- package/dist/cli/Prompt.js.map +1 -1
- package/dist/cli/internal/command.d.ts +1 -1
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/config.d.ts +1 -1
- package/dist/cli/internal/config.d.ts.map +1 -1
- package/dist/cli/internal/config.js +3 -3
- package/dist/cli/internal/config.js.map +1 -1
- package/dist/cluster/ClusterCron.d.ts +21 -1
- package/dist/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/cluster/ClusterCron.js +24 -6
- package/dist/cluster/ClusterCron.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +30 -22
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +15 -3
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +6 -0
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +13 -15
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +18 -8
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +12 -8
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/cluster/internal/entityReaper.js +1 -1
- package/dist/cluster/internal/entityReaper.js.map +1 -1
- package/dist/crypto/Kdf.d.ts +2 -1
- package/dist/crypto/Kdf.d.ts.map +1 -1
- package/dist/crypto/Kdf.js +2 -1
- package/dist/crypto/Kdf.js.map +1 -1
- package/dist/crypto/Password.d.ts +162 -0
- package/dist/crypto/Password.d.ts.map +1 -0
- package/dist/crypto/Password.js +217 -0
- package/dist/crypto/Password.js.map +1 -0
- package/dist/crypto/index.d.ts +5 -0
- package/dist/crypto/index.d.ts.map +1 -1
- package/dist/crypto/index.js +5 -0
- package/dist/crypto/index.js.map +1 -1
- package/dist/encoding/Base64.d.ts +63 -0
- package/dist/encoding/Base64.d.ts.map +1 -1
- package/dist/encoding/Base64.js +77 -0
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts +1 -0
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +1 -0
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Csv.d.ts.map +1 -1
- package/dist/encoding/Csv.js +44 -16
- package/dist/encoding/Csv.js.map +1 -1
- package/dist/encoding/Hex.d.ts +5 -0
- package/dist/encoding/Hex.d.ts.map +1 -1
- package/dist/encoding/Hex.js +5 -0
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +13 -124
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Sse.d.ts +1 -0
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +7 -5
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/encoding/Xml.d.ts +117 -11
- package/dist/encoding/Xml.d.ts.map +1 -1
- package/dist/encoding/Xml.js +332 -42
- package/dist/encoding/Xml.js.map +1 -1
- package/dist/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/eventlog/EventJournal.js +3 -8
- package/dist/eventlog/EventJournal.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.js +6 -8
- package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +163 -116
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/FindMyWay.d.ts +99 -0
- package/dist/http/FindMyWay.d.ts.map +1 -1
- package/dist/http/FindMyWay.js +39 -0
- package/dist/http/FindMyWay.js.map +1 -1
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +1 -1
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +15 -8
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts +49 -1
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +70 -20
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +24 -58
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/Mime.d.ts.map +1 -1
- package/dist/http/Mime.js +3 -2
- package/dist/http/Mime.js.map +1 -1
- package/dist/http/internal/compression.d.ts.map +1 -1
- package/dist/http/internal/compression.js +2 -2
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/mediaType.d.ts.map +1 -0
- package/dist/{http-api → http}/internal/mediaType.js +4 -0
- package/dist/{http-api → http}/internal/mediaType.js.map +1 -1
- package/dist/http/internal/redactedPath.d.ts +2 -0
- package/dist/http/internal/redactedPath.d.ts.map +1 -0
- package/dist/http/internal/redactedPath.js +138 -0
- package/dist/http/internal/redactedPath.js.map +1 -0
- package/dist/http/internal/requestState.js +1 -0
- package/dist/http/internal/requestState.js.map +1 -1
- package/dist/http-api/HttpApi.d.ts +13 -2
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +16 -2
- package/dist/http-api/HttpApi.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +3 -2
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +6 -6
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +1 -1
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiScalar.d.ts +4 -0
- package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
- package/dist/http-api/HttpApiScalar.js +10 -1
- package/dist/http-api/HttpApiScalar.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +1 -1
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/http-api/OpenApi.d.ts +2 -0
- package/dist/http-api/OpenApi.d.ts.map +1 -1
- package/dist/http-api/internal/httpApiScalar.js +5 -2
- package/dist/http-api/internal/httpApiScalar.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/arbitrary/model.js +0 -5
- package/dist/internal/arbitrary/model.js.map +1 -1
- package/dist/internal/arbitrary/regexp.js +2 -1
- package/dist/internal/arbitrary/regexp.js.map +1 -1
- package/dist/internal/arbitrary/runner.d.ts.map +1 -1
- package/dist/internal/arbitrary/runner.js +21 -16
- package/dist/internal/arbitrary/runner.js.map +1 -1
- package/dist/internal/arbitrary/schema.js +140 -23
- package/dist/internal/arbitrary/schema.js.map +1 -1
- package/dist/internal/codegen.d.ts +2 -0
- package/dist/internal/codegen.d.ts.map +1 -0
- package/dist/internal/codegen.js +59 -0
- package/dist/internal/codegen.js.map +1 -0
- package/dist/internal/core.js +3 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +26 -12
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +21 -7
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +7 -7
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/matcher.js +2 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/record.js +18 -4
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/result.js +1 -1
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schema/codeExpression.d.ts +4 -0
- package/dist/internal/schema/codeExpression.d.ts.map +1 -0
- package/dist/internal/schema/codeExpression.js +179 -0
- package/dist/internal/schema/codeExpression.js.map +1 -0
- package/dist/internal/schema/codeImports.d.ts +8 -0
- package/dist/internal/schema/codeImports.d.ts.map +1 -0
- package/dist/internal/schema/codeImports.js +135 -0
- package/dist/internal/schema/codeImports.js.map +1 -0
- package/dist/internal/schema/codeTokens.d.ts +8 -0
- package/dist/internal/schema/codeTokens.d.ts.map +1 -0
- package/dist/internal/schema/codeTokens.js +17 -0
- package/dist/internal/schema/codeTokens.js.map +1 -0
- package/dist/internal/schema/passthrough.d.ts +2 -0
- package/dist/internal/schema/passthrough.d.ts.map +1 -0
- package/dist/internal/schema/passthrough.js +8 -0
- package/dist/internal/schema/passthrough.js.map +1 -0
- package/dist/internal/schema/schemaCodegen.d.ts +2 -0
- package/dist/internal/schema/schemaCodegen.d.ts.map +1 -0
- package/dist/internal/schema/schemaCodegen.js +377 -0
- package/dist/internal/schema/schemaCodegen.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +11 -4
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/trie.js +51 -64
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/utf8.d.ts +2 -0
- package/dist/internal/utf8.d.ts.map +1 -0
- package/dist/internal/utf8.js +151 -0
- package/dist/internal/utf8.js.map +1 -0
- package/dist/internal/version.js +1 -1
- package/dist/jose/Jwks.d.ts +13 -0
- package/dist/jose/Jwks.d.ts.map +1 -1
- package/dist/jose/Jwks.js +10 -2
- package/dist/jose/Jwks.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +12 -10
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +5 -3
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/internal/otlpProtobuf.d.ts +4 -2
- package/dist/observability/internal/otlpProtobuf.d.ts.map +1 -1
- package/dist/observability/internal/otlpProtobuf.js +238 -156
- package/dist/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +20 -3
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/protobuf/ProtobufDescriptor.d.ts +377 -0
- package/dist/protobuf/ProtobufDescriptor.d.ts.map +1 -0
- package/dist/protobuf/ProtobufDescriptor.js +135 -0
- package/dist/protobuf/ProtobufDescriptor.js.map +1 -0
- package/dist/protobuf/ProtobufDescriptorProto.d.ts +2083 -0
- package/dist/protobuf/ProtobufDescriptorProto.d.ts.map +1 -0
- package/dist/protobuf/ProtobufDescriptorProto.js +2674 -0
- package/dist/protobuf/ProtobufDescriptorProto.js.map +1 -0
- package/dist/protobuf/ProtobufMessage.d.ts +183 -0
- package/dist/protobuf/ProtobufMessage.d.ts.map +1 -0
- package/dist/protobuf/ProtobufMessage.js +232 -0
- package/dist/protobuf/ProtobufMessage.js.map +1 -0
- package/dist/protobuf/ProtobufReader.d.ts +350 -0
- package/dist/protobuf/ProtobufReader.d.ts.map +1 -0
- package/dist/protobuf/ProtobufReader.js +698 -0
- package/dist/protobuf/ProtobufReader.js.map +1 -0
- package/dist/protobuf/ProtobufWriter.d.ts +224 -0
- package/dist/protobuf/ProtobufWriter.d.ts.map +1 -0
- package/dist/protobuf/ProtobufWriter.js +483 -0
- package/dist/protobuf/ProtobufWriter.js.map +1 -0
- package/dist/protobuf/index.d.ts +30 -0
- package/dist/protobuf/index.d.ts.map +1 -0
- package/dist/protobuf/index.js +31 -0
- package/dist/protobuf/index.js.map +1 -0
- package/dist/protobuf/internal/binary.d.ts +2 -0
- package/dist/protobuf/internal/binary.d.ts.map +1 -0
- package/dist/protobuf/internal/binary.js +966 -0
- package/dist/protobuf/internal/binary.js.map +1 -0
- package/dist/protobuf/internal/resolve.d.ts +2 -0
- package/dist/protobuf/internal/resolve.d.ts.map +1 -0
- package/dist/protobuf/internal/resolve.js +463 -0
- package/dist/protobuf/internal/resolve.js.map +1 -0
- package/dist/protobuf/internal/wireType.d.ts +2 -0
- package/dist/protobuf/internal/wireType.d.ts.map +1 -0
- package/dist/protobuf/internal/wireType.js +10 -0
- package/dist/protobuf/internal/wireType.js.map +1 -0
- package/dist/reactivity/AsyncResult.d.ts +3 -0
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/AsyncResult.js +4 -1
- package/dist/reactivity/AsyncResult.js.map +1 -1
- package/dist/reactivity/Atom.d.ts +10 -4
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +38 -13
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomHttpApi.d.ts +5 -0
- package/dist/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/reactivity/AtomHttpApi.js +5 -1
- package/dist/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/reactivity/AtomRegistry.js +13 -0
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/reactivity/AtomRpc.d.ts +5 -0
- package/dist/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/reactivity/AtomRpc.js +6 -1
- package/dist/reactivity/AtomRpc.js.map +1 -1
- package/dist/rpc/Rpc.d.ts +25 -0
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js +18 -0
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +38 -21
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcGroup.d.ts +5 -0
- package/dist/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/rpc/RpcGroup.js.map +1 -1
- package/dist/rpc/RpcMiddleware.d.ts +9 -0
- package/dist/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/rpc/RpcMiddleware.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts +7 -1
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +22 -5
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +33 -18
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/schema/SchemaCompiler/runtime.js +2 -1
- package/dist/schema/SchemaCompiler/runtime.js.map +1 -1
- package/dist/schema/VariantSchema.d.ts +10 -2
- package/dist/schema/VariantSchema.d.ts.map +1 -1
- package/dist/schema/VariantSchema.js +7 -1
- package/dist/schema/VariantSchema.js.map +1 -1
- package/dist/socket/Socket.d.ts +24 -10
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js +52 -17
- package/dist/socket/Socket.js.map +1 -1
- package/dist/sql/Migrator.d.ts +3 -0
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +10 -1
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlModel.d.ts.map +1 -1
- package/dist/sql/SqlModel.js +1 -0
- package/dist/sql/SqlModel.js.map +1 -1
- package/dist/testing/TestConsole.d.ts +96 -0
- package/dist/testing/TestConsole.d.ts.map +1 -1
- package/dist/testing/TestConsole.js +78 -6
- package/dist/testing/TestConsole.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +5 -1
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +7 -2
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/workers/SharedMemory.d.ts +115 -0
- package/dist/workers/SharedMemory.d.ts.map +1 -0
- package/dist/workers/SharedMemory.js +149 -0
- package/dist/workers/SharedMemory.js.map +1 -0
- package/dist/workers/Transferable.d.ts.map +1 -1
- package/dist/workers/Transferable.js +1 -4
- package/dist/workers/Transferable.js.map +1 -1
- package/dist/workers/index.d.ts +5 -0
- package/dist/workers/index.d.ts.map +1 -1
- package/dist/workers/index.js +5 -0
- package/dist/workers/index.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +3 -1
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +7 -4
- package/src/Arbitrary.ts +60 -3
- package/src/BigInt.ts +247 -9
- package/src/Cache.ts +4 -2
- package/src/Cause.ts +3 -3
- package/src/Chunk.ts +7 -3
- package/src/Clock.ts +5 -2
- package/src/Codegen.ts +741 -0
- package/src/Config.ts +35 -4
- package/src/ConfigProvider.ts +24 -7
- package/src/Effect.ts +871 -109
- package/src/Equivalence.ts +16 -13
- package/src/Fiber.ts +58 -8
- package/src/FiberHandle.ts +86 -12
- package/src/FiberMap.ts +83 -10
- package/src/FiberSet.ts +96 -8
- package/src/Formatter.ts +2 -0
- package/src/LayerMap.ts +14 -4
- package/src/LayerRef.ts +2 -2
- package/src/Match.ts +16 -0
- package/src/Metric.ts +1 -1
- package/src/Option.ts +9 -5
- package/src/Order.ts +9 -4
- package/src/Pool.ts +22 -17
- package/src/Predicate.ts +7 -3
- package/src/Queue.ts +84 -31
- package/src/Rational.ts +198 -0
- package/src/Request.ts +20 -0
- package/src/Result.ts +9 -6
- package/src/Schema.ts +69 -32
- package/src/SchemaAST.ts +15 -4
- package/src/SchemaGetter.ts +17 -10
- package/src/SchemaRepresentation.ts +19 -74
- package/src/SchemaTransformation.ts +12 -11
- package/src/Scope.ts +12 -6
- package/src/ScopedCache.ts +2 -1
- package/src/Semaphore.ts +18 -4
- package/src/Stream.ts +66 -20
- package/src/String.ts +83 -6
- package/src/Struct.ts +138 -5
- package/src/TextDiff.ts +186 -30
- package/src/TxPriorityQueue.ts +2 -2
- package/src/ai/LanguageModel.ts +2 -1
- package/src/ai/McpServer.ts +145 -22
- package/src/ai/Tool.ts +3 -2
- package/src/ai/Toolkit.ts +3 -1
- package/src/chat/Chat.ts +164 -0
- package/src/chat/ChatAdapter.ts +444 -0
- package/src/chat/ChatError.ts +684 -0
- package/src/chat/ChatEvent.ts +221 -0
- package/src/chat/ChatHandler.ts +102 -0
- package/src/chat/ChatInteraction.ts +1979 -0
- package/src/chat/ChatMarkdown.ts +1406 -0
- package/src/chat/ChatMessage.ts +213 -0
- package/src/chat/ChatTest.ts +2606 -0
- package/src/chat/ChatThread.ts +132 -0
- package/src/chat/ChatUi.ts +320 -0
- package/src/chat/index.ts +72 -0
- package/src/chat/internal/retries.ts +7 -0
- package/src/cli/CliOutput.ts +4 -5
- package/src/cli/Command.ts +20 -2
- package/src/cli/Prompt.ts +15 -9
- package/src/cli/internal/config.ts +8 -8
- package/src/cluster/ClusterCron.ts +33 -10
- package/src/cluster/ClusterWorkflowEngine.ts +42 -23
- package/src/cluster/Sharding.ts +17 -3
- package/src/cluster/ShardingConfig.ts +3 -0
- package/src/cluster/SqlMessageStorage.ts +16 -20
- package/src/cluster/SqlRunnerStorage.ts +21 -8
- package/src/cluster/internal/entityManager.ts +19 -10
- package/src/cluster/internal/entityReaper.ts +1 -1
- package/src/crypto/Kdf.ts +2 -1
- package/src/crypto/Password.ts +258 -0
- package/src/crypto/index.ts +6 -0
- package/src/encoding/Base64.ts +79 -0
- package/src/encoding/Base64Url.ts +1 -0
- package/src/encoding/Csv.ts +47 -20
- package/src/encoding/Hex.ts +5 -0
- package/src/encoding/SchemaBinary.ts +13 -79
- package/src/encoding/Sse.ts +7 -5
- package/src/encoding/Xml.ts +394 -47
- package/src/eventlog/EventJournal.ts +3 -8
- package/src/eventlog/SqlEventLogServerEncrypted.ts +9 -9
- package/src/http/FindMyWay/internal/router.ts +181 -129
- package/src/http/FindMyWay.ts +106 -0
- package/src/http/HttpClient.ts +2 -1
- package/src/http/HttpMiddleware.ts +22 -9
- package/src/http/HttpRouter.ts +84 -20
- package/src/http/HttpServerResponse.ts +33 -61
- package/src/http/Mime.ts +3 -2
- package/src/http/internal/compression.ts +2 -2
- package/src/{http-api → http}/internal/mediaType.ts +4 -0
- package/src/http/internal/redactedPath.ts +144 -0
- package/src/http/internal/requestState.ts +2 -0
- package/src/http-api/HttpApi.ts +25 -2
- package/src/http-api/HttpApiBuilder.ts +5 -2
- package/src/http-api/HttpApiClient.ts +10 -6
- package/src/http-api/HttpApiEndpoint.ts +1 -1
- package/src/http-api/HttpApiScalar.ts +9 -1
- package/src/http-api/HttpApiSchema.ts +1 -1
- package/src/http-api/OpenApi.ts +2 -0
- package/src/http-api/internal/httpApiScalar.ts +5 -1
- package/src/index.ts +6 -0
- package/src/internal/arbitrary/model.ts +3 -9
- package/src/internal/arbitrary/regexp.ts +3 -1
- package/src/internal/arbitrary/runner.ts +28 -14
- package/src/internal/arbitrary/schema.ts +140 -35
- package/src/internal/codegen.ts +53 -0
- package/src/internal/core.ts +3 -3
- package/src/internal/dateTime.ts +30 -13
- package/src/internal/effect.ts +25 -9
- package/src/internal/hashMap.ts +8 -7
- package/src/internal/matcher.ts +2 -1
- package/src/internal/record.ts +19 -4
- package/src/internal/result.ts +1 -1
- package/src/internal/schema/codeExpression.ts +179 -0
- package/src/internal/schema/codeImports.ts +142 -0
- package/src/internal/schema/codeTokens.ts +39 -0
- package/src/internal/schema/passthrough.ts +8 -0
- package/src/internal/schema/schemaCodegen.ts +543 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +13 -4
- package/src/internal/trie.ts +46 -60
- package/src/internal/utf8.ts +106 -0
- package/src/internal/version.ts +1 -1
- package/src/jose/Jwks.ts +23 -4
- package/src/observability/OtlpExporter.ts +12 -10
- package/src/observability/OtlpLogger.ts +5 -3
- package/src/observability/internal/otlpProtobuf.ts +386 -457
- package/src/persistence/PersistedQueue.ts +21 -4
- package/src/protobuf/ProtobufDescriptor.ts +503 -0
- package/src/protobuf/ProtobufDescriptorProto.ts +3611 -0
- package/src/protobuf/ProtobufMessage.ts +277 -0
- package/src/protobuf/ProtobufReader.ts +756 -0
- package/src/protobuf/ProtobufWriter.ts +530 -0
- package/src/protobuf/index.ts +36 -0
- package/src/protobuf/internal/binary.ts +1215 -0
- package/src/protobuf/internal/resolve.ts +533 -0
- package/src/protobuf/internal/wireType.ts +9 -0
- package/src/reactivity/AsyncResult.ts +6 -1
- package/src/reactivity/Atom.ts +55 -16
- package/src/reactivity/AtomHttpApi.ts +10 -1
- package/src/reactivity/AtomRegistry.ts +16 -0
- package/src/reactivity/AtomRpc.ts +11 -1
- package/src/rpc/Rpc.ts +31 -0
- package/src/rpc/RpcClient.ts +30 -21
- package/src/rpc/RpcGroup.ts +5 -0
- package/src/rpc/RpcMiddleware.ts +9 -0
- package/src/rpc/RpcSerialization.ts +26 -6
- package/src/rpc/RpcServer.ts +33 -20
- package/src/schema/SchemaCompiler/runtime.ts +2 -3
- package/src/schema/VariantSchema.ts +12 -4
- package/src/socket/Socket.ts +67 -20
- package/src/sql/Migrator.ts +8 -1
- package/src/sql/SqlModel.ts +4 -0
- package/src/testing/TestConsole.ts +119 -9
- package/src/testing/TestSchema.ts +8 -3
- package/src/workers/SharedMemory.ts +227 -0
- package/src/workers/Transferable.ts +1 -5
- package/src/workers/index.ts +6 -0
- package/src/workflow/WorkflowEngine.ts +3 -1
- package/dist/http-api/internal/mediaType.d.ts.map +0 -1
- package/dist/internal/schema/toCodeDocument.d.ts +0 -2
- package/dist/internal/schema/toCodeDocument.d.ts.map +0 -1
- package/dist/internal/schema/toCodeDocument.js +0 -447
- package/dist/internal/schema/toCodeDocument.js.map +0 -1
- package/dist/observability/internal/protobuf.d.ts +0 -2
- package/dist/observability/internal/protobuf.d.ts.map +0 -1
- package/dist/observability/internal/protobuf.js +0 -169
- package/dist/observability/internal/protobuf.js.map +0 -1
- package/src/internal/schema/toCodeDocument.ts +0 -578
- package/src/observability/internal/protobuf.ts +0 -225
- /package/dist/{http-api → http}/internal/mediaType.d.ts +0 -0
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the protobuf wire format: tags, varints, fixed-width numbers, and
|
|
3
|
+
* length-delimited data, from a byte array.
|
|
4
|
+
*
|
|
5
|
+
* **Mental model**
|
|
6
|
+
*
|
|
7
|
+
* - A message is a sequence of fields. Each field is a tag, made of a field
|
|
8
|
+
* number and a {@link WireType}, followed by its value.
|
|
9
|
+
* - The reader knows nothing about messages or schemas. The caller reads a
|
|
10
|
+
* tag, picks the value to read by its field number, and skips the fields it
|
|
11
|
+
* does not know with {@link ProtobufReader.skip}.
|
|
12
|
+
* - {@link ProtobufReader.delimited} reads a length prefix and returns a child
|
|
13
|
+
* reader restricted to that range. The parent advances past the range.
|
|
14
|
+
* Both readers report offsets in the original input.
|
|
15
|
+
* - The reader borrows its input. {@link ProtobufReader.bytes} returns an
|
|
16
|
+
* independent copy; {@link ProtobufReader.bytesView} returns a view sharing
|
|
17
|
+
* the input's memory.
|
|
18
|
+
*
|
|
19
|
+
* **Gotchas**
|
|
20
|
+
*
|
|
21
|
+
* - Malformed input throws a {@link ProtobufReaderError}: a truncated value, a
|
|
22
|
+
* varint longer than ten bytes, a length past the end of the input, a tag
|
|
23
|
+
* with field number 0 or wire type 6 or 7, an unmatched group tag, or a
|
|
24
|
+
* string that is not valid UTF-8, unless validation is explicitly disabled.
|
|
25
|
+
* - As in protobuf, `int32`, `uint32`, `sint32`, and enum varints of up to ten
|
|
26
|
+
* bytes are accepted and truncated to 32 bits.
|
|
27
|
+
* - Skipping unknown groups uses a bounded stack. Callers can supply the
|
|
28
|
+
* remaining nesting budget to {@link ProtobufReader.skip}.
|
|
29
|
+
*
|
|
30
|
+
* **Example** (Reading a message with a nested message)
|
|
31
|
+
*
|
|
32
|
+
* ```ts import.meta.vitest
|
|
33
|
+
* import { ProtobufReader, ProtobufWriter } from "effect/protobuf"
|
|
34
|
+
*
|
|
35
|
+
* // message Point { int32 x = 1; int32 y = 2; }
|
|
36
|
+
* const readPoint = (r: ProtobufReader.ProtobufReader) => {
|
|
37
|
+
* let x = 0
|
|
38
|
+
* let y = 0
|
|
39
|
+
* while (!r.isDone()) {
|
|
40
|
+
* const tag = r.tag()
|
|
41
|
+
* switch (ProtobufReader.fieldNumber(tag)) {
|
|
42
|
+
* case 1:
|
|
43
|
+
* x = r.int32()
|
|
44
|
+
* break
|
|
45
|
+
* case 2:
|
|
46
|
+
* y = r.int32()
|
|
47
|
+
* break
|
|
48
|
+
* default:
|
|
49
|
+
* r.skip(tag)
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* return { x, y }
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* // message Shape { string name = 1; Point origin = 2; }
|
|
56
|
+
* const { Len, Varint } = ProtobufWriter.WireType
|
|
57
|
+
* const w = ProtobufWriter.make()
|
|
58
|
+
* w.tag(1, Len).string("box")
|
|
59
|
+
* w.tag(2, Len).fork().tag(2, Varint).int32(-1).join()
|
|
60
|
+
*
|
|
61
|
+
* const r = ProtobufReader.make(w.finish())
|
|
62
|
+
* r.tag()
|
|
63
|
+
* r.string() // => "box"
|
|
64
|
+
* r.tag()
|
|
65
|
+
* readPoint(r.delimited()) // => { x: 0, y: -1 }
|
|
66
|
+
* r.isDone() // => true
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @stability experimental
|
|
70
|
+
* @since 4.1.5
|
|
71
|
+
*/
|
|
72
|
+
import * as Data from "../Data.js";
|
|
73
|
+
import * as Utf8 from "../internal/utf8.js";
|
|
74
|
+
import * as internal from "./internal/wireType.js";
|
|
75
|
+
/**
|
|
76
|
+
* The wire types of the protobuf format, which a tag carries with the field
|
|
77
|
+
* number. The same as `ProtobufWriter.WireType`.
|
|
78
|
+
*
|
|
79
|
+
* @stability experimental
|
|
80
|
+
* @category constants
|
|
81
|
+
* @since 4.1.5
|
|
82
|
+
*/
|
|
83
|
+
export const WireType = internal.WireType;
|
|
84
|
+
/**
|
|
85
|
+
* The error thrown by a {@link ProtobufReader} for malformed input.
|
|
86
|
+
*
|
|
87
|
+
* **Details**
|
|
88
|
+
*
|
|
89
|
+
* `offset` is the position in the input where reading failed.
|
|
90
|
+
*
|
|
91
|
+
* **Example** (Catching malformed input)
|
|
92
|
+
*
|
|
93
|
+
* ```ts import.meta.vitest
|
|
94
|
+
* import { ProtobufReader } from "effect/protobuf"
|
|
95
|
+
*
|
|
96
|
+
* // A varint whose last byte is missing
|
|
97
|
+
* const r = ProtobufReader.make(new Uint8Array([0x08, 0x96]))
|
|
98
|
+
* r.tag()
|
|
99
|
+
* try {
|
|
100
|
+
* r.int32()
|
|
101
|
+
* } catch (e) {
|
|
102
|
+
* e instanceof ProtobufReader.ProtobufReaderError // => true
|
|
103
|
+
* String((e as ProtobufReader.ProtobufReaderError).message) // => "Expected a complete value at offset 2"
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @stability experimental
|
|
108
|
+
* @category errors
|
|
109
|
+
* @since 4.1.5
|
|
110
|
+
*/
|
|
111
|
+
export class ProtobufReaderError extends /*#__PURE__*/Data.TaggedError("ProtobufReaderError") {}
|
|
112
|
+
/**
|
|
113
|
+
* A reader of the protobuf wire format, positioned at its current offset.
|
|
114
|
+
*
|
|
115
|
+
* **Details**
|
|
116
|
+
*
|
|
117
|
+
* Every method throws a {@link ProtobufReaderError} for malformed input.
|
|
118
|
+
* 64-bit integers are read as a `bigint`, or as a `number` with
|
|
119
|
+
* {@link ProtobufReader.int64Number} and its siblings. Create one with
|
|
120
|
+
* {@link make}.
|
|
121
|
+
*
|
|
122
|
+
* **Example** (Reading a field)
|
|
123
|
+
*
|
|
124
|
+
* ```ts import.meta.vitest
|
|
125
|
+
* import { ProtobufReader } from "effect/protobuf"
|
|
126
|
+
*
|
|
127
|
+
* // message Test { int32 a = 1; } with a = 150
|
|
128
|
+
* const r = ProtobufReader.make(new Uint8Array([0x08, 0x96, 0x01]))
|
|
129
|
+
* const tag = r.tag()
|
|
130
|
+
* ProtobufReader.fieldNumber(tag) // => 1
|
|
131
|
+
* r.int32() // => 150
|
|
132
|
+
* r.isDone() // => true
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @stability experimental
|
|
136
|
+
* @category models
|
|
137
|
+
* @since 4.1.5
|
|
138
|
+
*/
|
|
139
|
+
export class ProtobufReader {
|
|
140
|
+
buf;
|
|
141
|
+
pos = 0;
|
|
142
|
+
// The end of this reader's range in the original input.
|
|
143
|
+
limit;
|
|
144
|
+
// The halves of the last 64-bit varint.
|
|
145
|
+
lo = 0;
|
|
146
|
+
hi = 0;
|
|
147
|
+
/**
|
|
148
|
+
* Creates a reader borrowing `bytes`. Mutating `bytes` affects subsequent
|
|
149
|
+
* reads and any views returned by {@link ProtobufReader.bytesView}.
|
|
150
|
+
*
|
|
151
|
+
* @since 4.1.5
|
|
152
|
+
*/
|
|
153
|
+
constructor(bytes) {
|
|
154
|
+
this.buf = bytes;
|
|
155
|
+
this.limit = bytes.length;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The position of the next byte to read.
|
|
159
|
+
*
|
|
160
|
+
* @since 4.1.5
|
|
161
|
+
*/
|
|
162
|
+
get offset() {
|
|
163
|
+
return this.pos;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Whether every byte of the message being read has been read.
|
|
167
|
+
*
|
|
168
|
+
* @since 4.1.5
|
|
169
|
+
*/
|
|
170
|
+
isDone() {
|
|
171
|
+
return this.pos >= this.limit;
|
|
172
|
+
}
|
|
173
|
+
fail(expected) {
|
|
174
|
+
throw new ProtobufReaderError({
|
|
175
|
+
message: `Expected ${expected} at offset ${this.pos}`,
|
|
176
|
+
offset: this.pos
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Reads a tag, which {@link fieldNumber} and {@link wireType} take apart.
|
|
181
|
+
*
|
|
182
|
+
* @since 4.1.5
|
|
183
|
+
*/
|
|
184
|
+
tag() {
|
|
185
|
+
const tag = this.length32();
|
|
186
|
+
if (tag >>> 3 === 0 || (tag & 7) > I32) this.fail("a tag with a nonzero field number and a wire type up to 5");
|
|
187
|
+
return tag;
|
|
188
|
+
}
|
|
189
|
+
byte() {
|
|
190
|
+
if (this.pos >= this.limit) this.fail(COMPLETE);
|
|
191
|
+
return this.buf[this.pos++];
|
|
192
|
+
}
|
|
193
|
+
need(n) {
|
|
194
|
+
if (this.pos + n > this.limit) this.fail(COMPLETE);
|
|
195
|
+
}
|
|
196
|
+
// A varint of at most 32 bits, as tags and lengths are. Longer ones are
|
|
197
|
+
// rejected rather than truncated, so that bytes cannot be framed two ways.
|
|
198
|
+
length32() {
|
|
199
|
+
let result = 0;
|
|
200
|
+
for (let i = 0; i < 5; i++) {
|
|
201
|
+
const b = this.byte();
|
|
202
|
+
if (i === 4 && b > 0x0F) break;
|
|
203
|
+
result |= (b & 0x7F) << 7 * i;
|
|
204
|
+
if (b < 0x80) return result >>> 0;
|
|
205
|
+
}
|
|
206
|
+
return this.fail("a varint of at most 32 bits");
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Reads a `uint32` varint.
|
|
210
|
+
*
|
|
211
|
+
* @since 4.1.5
|
|
212
|
+
*/
|
|
213
|
+
uint32() {
|
|
214
|
+
const buf = this.buf;
|
|
215
|
+
let p = this.pos;
|
|
216
|
+
let b = buf[p];
|
|
217
|
+
// Most varints are a single byte.
|
|
218
|
+
if (b < 0x80 && p < this.limit) {
|
|
219
|
+
this.pos = p + 1;
|
|
220
|
+
return b;
|
|
221
|
+
}
|
|
222
|
+
// With ten bytes left, no varint can run past the end.
|
|
223
|
+
if (p + 10 > this.limit) return this.uint32Checked();
|
|
224
|
+
b = buf[p++];
|
|
225
|
+
let result = b & 0x7F;
|
|
226
|
+
if (b >= 0x80) {
|
|
227
|
+
b = buf[p++];
|
|
228
|
+
result |= (b & 0x7F) << 7;
|
|
229
|
+
if (b >= 0x80) {
|
|
230
|
+
b = buf[p++];
|
|
231
|
+
result |= (b & 0x7F) << 14;
|
|
232
|
+
if (b >= 0x80) {
|
|
233
|
+
b = buf[p++];
|
|
234
|
+
result |= (b & 0x7F) << 21;
|
|
235
|
+
if (b >= 0x80) {
|
|
236
|
+
b = buf[p++];
|
|
237
|
+
result |= (b & 0x7F) << 28;
|
|
238
|
+
for (let i = 0; b >= 0x80; i++) {
|
|
239
|
+
if (i === 5) {
|
|
240
|
+
this.pos = p;
|
|
241
|
+
this.fail(VARINT_64);
|
|
242
|
+
}
|
|
243
|
+
b = buf[p++];
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
this.pos = p;
|
|
250
|
+
return result >>> 0;
|
|
251
|
+
}
|
|
252
|
+
uint32Checked() {
|
|
253
|
+
let result = 0;
|
|
254
|
+
for (let i = 0; i < 10; i++) {
|
|
255
|
+
const b = this.byte();
|
|
256
|
+
if (i < 5) result |= (b & 0x7F) << 7 * i;
|
|
257
|
+
if (b < 0x80) return result >>> 0;
|
|
258
|
+
}
|
|
259
|
+
return this.fail(VARINT_64);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Reads an `int32` varint.
|
|
263
|
+
*
|
|
264
|
+
* @since 4.1.5
|
|
265
|
+
*/
|
|
266
|
+
int32() {
|
|
267
|
+
return this.uint32() | 0;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Reads a `sint32` varint, with the zigzag encoding.
|
|
271
|
+
*
|
|
272
|
+
* @since 4.1.5
|
|
273
|
+
*/
|
|
274
|
+
sint32() {
|
|
275
|
+
const n = this.uint32();
|
|
276
|
+
return n >>> 1 ^ -(n & 1);
|
|
277
|
+
}
|
|
278
|
+
// Reads a varint of up to ten bytes into `lo` and `hi`.
|
|
279
|
+
varint64() {
|
|
280
|
+
const buf = this.buf;
|
|
281
|
+
let p = this.pos;
|
|
282
|
+
let b = buf[p];
|
|
283
|
+
if (b < 0x80 && p < this.limit) {
|
|
284
|
+
this.pos = p + 1;
|
|
285
|
+
this.lo = b;
|
|
286
|
+
this.hi = 0;
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (p + 10 > this.limit) return this.varint64Checked();
|
|
290
|
+
b = buf[p++];
|
|
291
|
+
let lo = b & 0x7F;
|
|
292
|
+
let hi = 0;
|
|
293
|
+
if (b >= 0x80) {
|
|
294
|
+
for (let shift = 7; shift < 28; shift += 7) {
|
|
295
|
+
b = buf[p++];
|
|
296
|
+
lo |= (b & 0x7F) << shift;
|
|
297
|
+
if (b < 0x80) break;
|
|
298
|
+
}
|
|
299
|
+
if (b >= 0x80) {
|
|
300
|
+
b = buf[p++];
|
|
301
|
+
lo |= (b & 0x0F) << 28;
|
|
302
|
+
hi = (b & 0x7F) >> 4;
|
|
303
|
+
for (let shift = 3; b >= 0x80; shift += 7) {
|
|
304
|
+
if (shift > 31) {
|
|
305
|
+
this.pos = p;
|
|
306
|
+
this.fail(VARINT_64);
|
|
307
|
+
}
|
|
308
|
+
b = buf[p++];
|
|
309
|
+
hi |= (b & 0x7F) << shift;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
this.pos = p;
|
|
314
|
+
this.lo = lo >>> 0;
|
|
315
|
+
this.hi = hi >>> 0;
|
|
316
|
+
}
|
|
317
|
+
varint64Checked() {
|
|
318
|
+
let lo = 0;
|
|
319
|
+
let hi = 0;
|
|
320
|
+
let b = 0x80;
|
|
321
|
+
for (let shift = 0; shift < 28 && b >= 0x80; shift += 7) {
|
|
322
|
+
b = this.byte();
|
|
323
|
+
lo |= (b & 0x7F) << shift;
|
|
324
|
+
}
|
|
325
|
+
if (b >= 0x80) {
|
|
326
|
+
b = this.byte();
|
|
327
|
+
lo |= (b & 0x0F) << 28;
|
|
328
|
+
hi = (b & 0x7F) >> 4;
|
|
329
|
+
for (let shift = 3; b >= 0x80; shift += 7) {
|
|
330
|
+
if (shift > 31) this.fail(VARINT_64);
|
|
331
|
+
b = this.byte();
|
|
332
|
+
hi |= (b & 0x7F) << shift;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
this.lo = lo >>> 0;
|
|
336
|
+
this.hi = hi >>> 0;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Reads a `uint64` varint.
|
|
340
|
+
*
|
|
341
|
+
* @since 4.1.5
|
|
342
|
+
*/
|
|
343
|
+
uint64() {
|
|
344
|
+
this.varint64();
|
|
345
|
+
return uint64FromHalves(this.lo, this.hi);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Reads an `int64` varint.
|
|
349
|
+
*
|
|
350
|
+
* @since 4.1.5
|
|
351
|
+
*/
|
|
352
|
+
int64() {
|
|
353
|
+
this.varint64();
|
|
354
|
+
return int64FromHalves(this.lo, this.hi);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Reads a `sint64` varint, with the zigzag encoding.
|
|
358
|
+
*
|
|
359
|
+
* @since 4.1.5
|
|
360
|
+
*/
|
|
361
|
+
sint64() {
|
|
362
|
+
this.varint64();
|
|
363
|
+
const mask = -(this.lo & 1);
|
|
364
|
+
const lo = (this.lo >>> 1 | this.hi << 31) ^ mask;
|
|
365
|
+
const hi = this.hi >>> 1 ^ mask;
|
|
366
|
+
return int64FromHalves(lo >>> 0, hi >>> 0);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Reads a `uint64` varint as a `number`.
|
|
370
|
+
*
|
|
371
|
+
* **Details**
|
|
372
|
+
*
|
|
373
|
+
* Outside the safe integer range the number is rounded, as `Number` rounds
|
|
374
|
+
* a `bigint`, which `Number.isSafeInteger` detects. It saves creating a
|
|
375
|
+
* `bigint` for each value.
|
|
376
|
+
*
|
|
377
|
+
* @since 4.1.5
|
|
378
|
+
*/
|
|
379
|
+
uint64Number() {
|
|
380
|
+
this.varint64();
|
|
381
|
+
return this.hi * TWO_32 + this.lo;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Reads an `int64` varint as a `number`.
|
|
385
|
+
*
|
|
386
|
+
* **Details**
|
|
387
|
+
*
|
|
388
|
+
* Outside the safe integer range the number is rounded, as `Number` rounds
|
|
389
|
+
* a `bigint`, which `Number.isSafeInteger` detects. It saves creating a
|
|
390
|
+
* `bigint` for each value.
|
|
391
|
+
*
|
|
392
|
+
* **Example** (Reading an `int64` as a number)
|
|
393
|
+
*
|
|
394
|
+
* ```ts import.meta.vitest
|
|
395
|
+
* import { ProtobufReader, ProtobufWriter } from "effect/protobuf"
|
|
396
|
+
*
|
|
397
|
+
* const bytes = ProtobufWriter.make().int64(-2).int64(2n ** 60n).finish()
|
|
398
|
+
* const r = ProtobufReader.make(bytes)
|
|
399
|
+
* r.int64Number() // => -2
|
|
400
|
+
* Number.isSafeInteger(r.int64Number()) // => false
|
|
401
|
+
* ```
|
|
402
|
+
*
|
|
403
|
+
* @since 4.1.5
|
|
404
|
+
*/
|
|
405
|
+
int64Number() {
|
|
406
|
+
this.varint64();
|
|
407
|
+
return (this.hi | 0) * TWO_32 + this.lo;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Reads a `sint64` varint, with the zigzag encoding, as a `number`.
|
|
411
|
+
*
|
|
412
|
+
* **Details**
|
|
413
|
+
*
|
|
414
|
+
* Outside the safe integer range the number is rounded, as `Number` rounds
|
|
415
|
+
* a `bigint`, which `Number.isSafeInteger` detects. It saves creating a
|
|
416
|
+
* `bigint` for each value.
|
|
417
|
+
*
|
|
418
|
+
* @since 4.1.5
|
|
419
|
+
*/
|
|
420
|
+
sint64Number() {
|
|
421
|
+
this.varint64();
|
|
422
|
+
const mask = -(this.lo & 1);
|
|
423
|
+
const lo = (this.lo >>> 1 | this.hi << 31) ^ mask;
|
|
424
|
+
const hi = this.hi >>> 1 ^ mask;
|
|
425
|
+
return hi * TWO_32 + (lo >>> 0);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Reads a `bool` varint: any nonzero value is `true`.
|
|
429
|
+
*
|
|
430
|
+
* @since 4.1.5
|
|
431
|
+
*/
|
|
432
|
+
bool() {
|
|
433
|
+
this.varint64();
|
|
434
|
+
return this.lo !== 0 || this.hi !== 0;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Reads a little-endian `sfixed32`.
|
|
438
|
+
*
|
|
439
|
+
* @since 4.1.5
|
|
440
|
+
*/
|
|
441
|
+
sfixed32() {
|
|
442
|
+
this.need(4);
|
|
443
|
+
const buf = this.buf;
|
|
444
|
+
const p = this.pos;
|
|
445
|
+
this.pos = p + 4;
|
|
446
|
+
return buf[p] | buf[p + 1] << 8 | buf[p + 2] << 16 | buf[p + 3] << 24;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Reads a little-endian `fixed32`.
|
|
450
|
+
*
|
|
451
|
+
* @since 4.1.5
|
|
452
|
+
*/
|
|
453
|
+
fixed32() {
|
|
454
|
+
return this.sfixed32() >>> 0;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Reads a little-endian `fixed64`.
|
|
458
|
+
*
|
|
459
|
+
* @since 4.1.5
|
|
460
|
+
*/
|
|
461
|
+
fixed64() {
|
|
462
|
+
this.need(8);
|
|
463
|
+
const lo = this.fixed32();
|
|
464
|
+
return uint64FromHalves(lo, this.fixed32());
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Reads a little-endian `sfixed64`.
|
|
468
|
+
*
|
|
469
|
+
* @since 4.1.5
|
|
470
|
+
*/
|
|
471
|
+
sfixed64() {
|
|
472
|
+
this.need(8);
|
|
473
|
+
const lo = this.fixed32();
|
|
474
|
+
return int64FromHalves(lo, this.fixed32());
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Reads a little-endian `fixed64` as a `number`.
|
|
478
|
+
*
|
|
479
|
+
* **Details**
|
|
480
|
+
*
|
|
481
|
+
* Outside the safe integer range the number is rounded, as `Number` rounds
|
|
482
|
+
* a `bigint`, which `Number.isSafeInteger` detects. It saves creating a
|
|
483
|
+
* `bigint` for each value.
|
|
484
|
+
*
|
|
485
|
+
* @since 4.1.5
|
|
486
|
+
*/
|
|
487
|
+
fixed64Number() {
|
|
488
|
+
this.need(8);
|
|
489
|
+
const lo = this.fixed32();
|
|
490
|
+
return this.fixed32() * TWO_32 + lo;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Reads a little-endian `sfixed64` as a `number`.
|
|
494
|
+
*
|
|
495
|
+
* **Details**
|
|
496
|
+
*
|
|
497
|
+
* Outside the safe integer range the number is rounded, as `Number` rounds
|
|
498
|
+
* a `bigint`, which `Number.isSafeInteger` detects. It saves creating a
|
|
499
|
+
* `bigint` for each value.
|
|
500
|
+
*
|
|
501
|
+
* @since 4.1.5
|
|
502
|
+
*/
|
|
503
|
+
sfixed64Number() {
|
|
504
|
+
this.need(8);
|
|
505
|
+
const lo = this.fixed32();
|
|
506
|
+
return this.sfixed32() * TWO_32 + lo;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Reads a little-endian 32-bit `float`.
|
|
510
|
+
*
|
|
511
|
+
* @since 4.1.5
|
|
512
|
+
*/
|
|
513
|
+
float() {
|
|
514
|
+
halvesView.setInt32(0, this.sfixed32(), true);
|
|
515
|
+
return halvesView.getFloat32(0, true);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Reads a little-endian 64-bit `double`.
|
|
519
|
+
*
|
|
520
|
+
* @since 4.1.5
|
|
521
|
+
*/
|
|
522
|
+
double() {
|
|
523
|
+
this.need(8);
|
|
524
|
+
halvesView.setInt32(0, this.sfixed32(), true);
|
|
525
|
+
halvesView.setInt32(4, this.sfixed32(), true);
|
|
526
|
+
return halvesView.getFloat64(0, true);
|
|
527
|
+
}
|
|
528
|
+
// Reads a length prefix and returns the offset where the data ends.
|
|
529
|
+
end() {
|
|
530
|
+
const length = this.length32();
|
|
531
|
+
this.need(length);
|
|
532
|
+
return this.pos + length;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Reads length-prefixed bytes, as a copy.
|
|
536
|
+
*
|
|
537
|
+
* @since 4.1.5
|
|
538
|
+
*/
|
|
539
|
+
bytes() {
|
|
540
|
+
// A copy, also of a Node.js `Buffer`, whose `slice` is a view.
|
|
541
|
+
return new Uint8Array(this.bytesView());
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Reads length-prefixed bytes as a view of the input. Mutating the input or
|
|
545
|
+
* the returned view changes the other; use {@link ProtobufReader.bytes}
|
|
546
|
+
* when the result must own its bytes.
|
|
547
|
+
*
|
|
548
|
+
* @since 4.1.5
|
|
549
|
+
*/
|
|
550
|
+
bytesView() {
|
|
551
|
+
const end = this.end();
|
|
552
|
+
const out = this.buf.subarray(this.pos, end);
|
|
553
|
+
this.pos = end;
|
|
554
|
+
return out;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Reads a length-prefixed string. Invalid UTF-8 fails by default; setting
|
|
558
|
+
* `validateUtf8` to `false` replaces invalid sequences with U+FFFD.
|
|
559
|
+
*
|
|
560
|
+
* @since 4.1.5
|
|
561
|
+
*/
|
|
562
|
+
string(options) {
|
|
563
|
+
const end = this.end();
|
|
564
|
+
const out = options?.validateUtf8 === false ? Utf8.decodeLax(this.buf, this.pos, end) : Utf8.decode(this.buf, this.pos, end);
|
|
565
|
+
if (out === undefined) return this.fail("valid UTF-8");
|
|
566
|
+
this.pos = end;
|
|
567
|
+
return out;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Reads a length prefix and returns a child reader restricted to its payload.
|
|
571
|
+
* Advances this reader past the payload immediately. The child borrows the
|
|
572
|
+
* same input and reports absolute offsets; it cannot read enclosing fields.
|
|
573
|
+
* Leaving part of the child unread does not affect the parent's position.
|
|
574
|
+
*
|
|
575
|
+
* @since 4.1.5
|
|
576
|
+
*/
|
|
577
|
+
delimited() {
|
|
578
|
+
const end = this.end();
|
|
579
|
+
const child = new ProtobufReader(this.buf);
|
|
580
|
+
child.pos = this.pos;
|
|
581
|
+
child.limit = end;
|
|
582
|
+
this.pos = end;
|
|
583
|
+
return child;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Skips the value of the field of `tag`, including all of a group. Group
|
|
587
|
+
* nesting is bounded by `maxDepth`, 512 by default, and uses an explicit
|
|
588
|
+
* stack. A zero limit rejects groups but permits other wire types. The limit
|
|
589
|
+
* must be a non-negative integer; otherwise this throws `RangeError`.
|
|
590
|
+
*
|
|
591
|
+
* @since 4.1.5
|
|
592
|
+
*/
|
|
593
|
+
skip(tag, maxDepth = MAX_GROUP_DEPTH) {
|
|
594
|
+
if (!Number.isInteger(maxDepth) || maxDepth < 0) {
|
|
595
|
+
throw new RangeError("ProtobufReader.skip maxDepth must be a non-negative integer");
|
|
596
|
+
}
|
|
597
|
+
let groups;
|
|
598
|
+
while (true) {
|
|
599
|
+
switch (tag & 7) {
|
|
600
|
+
case VARINT:
|
|
601
|
+
this.varint64();
|
|
602
|
+
break;
|
|
603
|
+
case I64:
|
|
604
|
+
this.need(8);
|
|
605
|
+
this.pos += 8;
|
|
606
|
+
break;
|
|
607
|
+
case LEN:
|
|
608
|
+
this.pos = this.end();
|
|
609
|
+
break;
|
|
610
|
+
case START_GROUP:
|
|
611
|
+
groups ??= [];
|
|
612
|
+
if (groups.length >= maxDepth) this.fail(`groups nested at most ${maxDepth} deep`);
|
|
613
|
+
groups.push(tag >>> 3);
|
|
614
|
+
break;
|
|
615
|
+
case END_GROUP:
|
|
616
|
+
{
|
|
617
|
+
const number = groups?.pop();
|
|
618
|
+
if (number === undefined) this.fail(`a start group tag before the end group tag of field ${tag >>> 3}`);
|
|
619
|
+
if (tag >>> 3 !== number) this.fail(`an end group tag for field ${number}`);
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
case I32:
|
|
623
|
+
this.need(4);
|
|
624
|
+
this.pos += 4;
|
|
625
|
+
break;
|
|
626
|
+
default:
|
|
627
|
+
this.fail("a wire type up to 5");
|
|
628
|
+
}
|
|
629
|
+
if (groups === undefined || groups.length === 0) return;
|
|
630
|
+
tag = this.tag();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* The field number of a tag from {@link ProtobufReader.tag}.
|
|
636
|
+
*
|
|
637
|
+
* @stability experimental
|
|
638
|
+
* @category utils
|
|
639
|
+
* @since 4.1.5
|
|
640
|
+
*/
|
|
641
|
+
export const fieldNumber = tag => tag >>> 3;
|
|
642
|
+
/**
|
|
643
|
+
* The wire type of a tag from {@link ProtobufReader.tag}.
|
|
644
|
+
*
|
|
645
|
+
* @stability experimental
|
|
646
|
+
* @category utils
|
|
647
|
+
* @since 4.1.5
|
|
648
|
+
*/
|
|
649
|
+
export const wireType = tag => tag & 7;
|
|
650
|
+
/**
|
|
651
|
+
* Creates a reader of `bytes`, which are not copied.
|
|
652
|
+
*
|
|
653
|
+
* **Example** (Creating a reader)
|
|
654
|
+
*
|
|
655
|
+
* ```ts import.meta.vitest
|
|
656
|
+
* import { ProtobufReader } from "effect/protobuf"
|
|
657
|
+
*
|
|
658
|
+
* ProtobufReader.make(new Uint8Array([0x96, 0x01])).uint32() // => 150
|
|
659
|
+
* ```
|
|
660
|
+
*
|
|
661
|
+
* @stability experimental
|
|
662
|
+
* @category constructors
|
|
663
|
+
* @since 4.1.5
|
|
664
|
+
*/
|
|
665
|
+
export const make = bytes => new ProtobufReader(bytes);
|
|
666
|
+
// -----------------------------------------------------------------------------
|
|
667
|
+
// internal
|
|
668
|
+
// -----------------------------------------------------------------------------
|
|
669
|
+
const {
|
|
670
|
+
EndGroup: END_GROUP,
|
|
671
|
+
I32,
|
|
672
|
+
I64,
|
|
673
|
+
Len: LEN,
|
|
674
|
+
StartGroup: START_GROUP,
|
|
675
|
+
Varint: VARINT
|
|
676
|
+
} = internal.WireType;
|
|
677
|
+
// Default bound on the explicit stack used to skip unknown groups.
|
|
678
|
+
const MAX_GROUP_DEPTH = 512;
|
|
679
|
+
const COMPLETE = "a complete value";
|
|
680
|
+
const VARINT_64 = "a varint of at most 10 bytes";
|
|
681
|
+
// 64-bit integers are read as their unsigned 32-bit halves, and joined through
|
|
682
|
+
// a view, which is faster than bigint arithmetic. Floats are read through it
|
|
683
|
+
// too, which saves a `DataView` of the input for each reader.
|
|
684
|
+
const halvesView = /*#__PURE__*/new DataView(/*#__PURE__*/new ArrayBuffer(8));
|
|
685
|
+
// A 64-bit integer is its high half times this plus its unsigned low half,
|
|
686
|
+
// which rounds once, as `Number` rounds a `bigint`.
|
|
687
|
+
const TWO_32 = 4294967296;
|
|
688
|
+
const int64FromHalves = (lo, hi) => {
|
|
689
|
+
halvesView.setUint32(0, lo, true);
|
|
690
|
+
halvesView.setUint32(4, hi, true);
|
|
691
|
+
return halvesView.getBigInt64(0, true);
|
|
692
|
+
};
|
|
693
|
+
const uint64FromHalves = (lo, hi) => {
|
|
694
|
+
halvesView.setUint32(0, lo, true);
|
|
695
|
+
halvesView.setUint32(4, hi, true);
|
|
696
|
+
return halvesView.getBigUint64(0, true);
|
|
697
|
+
};
|
|
698
|
+
//# sourceMappingURL=ProtobufReader.js.map
|