effect 4.0.0-rc.112 → 4.0.0-rc.113
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/AGENTS.md +24 -9
- package/CLAUDE.md +24 -9
- package/ai-docs/package.json +2 -2
- package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +18 -5
- package/ai-docs/src/01_effect/01_basics/index.md +5 -3
- package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
- package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +2 -2
- package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +2 -2
- package/ai-docs/src/03_stream/30_encoding.ts +5 -7
- package/ai-docs/src/08_observability/10_logging.ts +1 -1
- package/ai-docs/src/70_cli/10_basics.ts +7 -7
- package/ai-docs/src/71_ai/10_language-model.ts +2 -2
- package/ai-docs/src/71_ai/20_tools.ts +1 -1
- package/ai-docs/src/71_ai/30_chat.ts +1 -1
- package/dist/Array.d.ts +86 -50
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +58 -32
- package/dist/Array.js.map +1 -1
- package/dist/BigDecimal.d.ts +5 -1
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +40 -23
- package/dist/BigDecimal.js.map +1 -1
- package/dist/ByteSize.d.ts +633 -0
- package/dist/ByteSize.d.ts.map +1 -0
- package/dist/ByteSize.js +524 -0
- package/dist/ByteSize.js.map +1 -0
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +17 -3
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +1 -1
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Channel.d.ts +97 -24
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +66 -39
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +49 -28
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +27 -18
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts +162 -201
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +103 -212
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +4 -4
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +7 -7
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Context.d.ts +31 -0
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +2 -2
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +2 -2
- package/dist/Cron.js.map +1 -1
- package/dist/Crypto.d.ts +1 -1
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +3 -2
- package/dist/Crypto.js.map +1 -1
- package/dist/DateTime.d.ts +2 -2
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/Deferred.d.ts.map +1 -1
- package/dist/Deferred.js +6 -6
- package/dist/Deferred.js.map +1 -1
- package/dist/Duration.d.ts +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +1 -1
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +220 -113
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +27 -26
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.d.ts +58 -2
- package/dist/Effectable.d.ts.map +1 -1
- package/dist/Effectable.js +58 -6
- package/dist/Effectable.js.map +1 -1
- package/dist/Encoding.d.ts +3 -1
- package/dist/Encoding.d.ts.map +1 -1
- package/dist/Encoding.js +40 -10
- package/dist/Encoding.js.map +1 -1
- package/dist/Equal.d.ts +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +1 -1
- package/dist/Equal.js.map +1 -1
- package/dist/ExecutionPlan.d.ts.map +1 -1
- package/dist/ExecutionPlan.js +1 -0
- package/dist/ExecutionPlan.js.map +1 -1
- package/dist/Fiber.d.ts +32 -8
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FiberHandle.js +3 -3
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +12 -6
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +11 -6
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +42 -210
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +16 -148
- package/dist/FileSystem.js.map +1 -1
- package/dist/Formatter.d.ts +1 -0
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +19 -3
- package/dist/Formatter.js.map +1 -1
- package/dist/Graph.d.ts +48 -20
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +20 -5
- package/dist/Graph.js.map +1 -1
- package/dist/Hash.d.ts +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +5 -14
- package/dist/Hash.js.map +1 -1
- package/dist/HashMap.d.ts +1 -1
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashRing.d.ts +6 -1
- package/dist/HashRing.d.ts.map +1 -1
- package/dist/HashRing.js +9 -2
- package/dist/HashRing.js.map +1 -1
- package/dist/HashSet.d.ts +1 -1
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js.map +1 -1
- package/dist/Iterable.d.ts +33 -15
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +58 -45
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.js +4 -4
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonPointer.d.ts +68 -4
- package/dist/JsonPointer.d.ts.map +1 -1
- package/dist/JsonPointer.js +90 -4
- package/dist/JsonPointer.js.map +1 -1
- package/dist/JsonSchema.js +8 -22
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Layer.d.ts +47 -4
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +4 -6
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +1 -3
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +7 -5
- package/dist/LayerMap.js.map +1 -1
- package/dist/LayerRef.d.ts.map +1 -1
- package/dist/LayerRef.js +7 -5
- package/dist/LayerRef.js.map +1 -1
- package/dist/Logger.d.ts +114 -9
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +109 -9
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.js +1 -1
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Match.d.ts +43 -31
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +5 -2
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +11 -4
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +14 -18
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts +1 -1
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +1 -1
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableHashSet.d.ts +1 -1
- package/dist/MutableHashSet.d.ts.map +1 -1
- package/dist/MutableHashSet.js +1 -1
- package/dist/MutableHashSet.js.map +1 -1
- package/dist/MutableList.d.ts +13 -2
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +18 -2
- package/dist/MutableList.js.map +1 -1
- package/dist/Number.d.ts +6 -0
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +3 -1
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +5 -4
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +1 -1
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +1 -1
- package/dist/Option.js.map +1 -1
- package/dist/Order.d.ts +1 -0
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +3 -1
- package/dist/Order.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +1 -2
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts +1 -1
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +1 -1
- package/dist/Path.js.map +1 -1
- package/dist/PlatformError.d.ts +1 -1
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +1 -1
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +38 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +81 -5
- package/dist/Pool.js.map +1 -1
- package/dist/PrimaryKey.d.ts +1 -1
- package/dist/PrimaryKey.d.ts.map +1 -1
- package/dist/PrimaryKey.js +1 -1
- package/dist/PrimaryKey.js.map +1 -1
- package/dist/PubSub.d.ts +21 -9
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +18 -14
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +82 -6
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +116 -27
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +17 -4
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +1 -1
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +15 -9
- package/dist/RcMap.js.map +1 -1
- package/dist/Redacted.d.ts +1 -1
- package/dist/Redacted.d.ts.map +1 -1
- package/dist/Redacted.js +1 -1
- package/dist/Redacted.js.map +1 -1
- package/dist/RequestResolver.d.ts +15 -9
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +33 -15
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Result.d.ts +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +1 -1
- package/dist/Result.js.map +1 -1
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +19 -10
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +2155 -2415
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2755 -4174
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +354 -183
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +277 -601
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +46 -22
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +56 -53
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +122 -188
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +48 -263
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.js +2 -9
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +1099 -16
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +1341 -20
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +49 -16
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +75 -98
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +10 -3
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Sink.d.ts +9 -4
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +49 -31
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +221 -35
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +168 -84
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +16 -6
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +12 -5
- package/dist/String.js.map +1 -1
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +7 -4
- package/dist/Struct.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +3 -2
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Terminal.d.ts +3 -3
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +3 -3
- package/dist/Terminal.js.map +1 -1
- package/dist/Tracer.d.ts +27 -7
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +38 -13
- package/dist/Tracer.js.map +1 -1
- package/dist/Trie.d.ts +1 -1
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Tuple.d.ts +2 -1
- package/dist/Tuple.d.ts.map +1 -1
- package/dist/Tuple.js.map +1 -1
- package/dist/TxChunk.d.ts +1 -1
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +1 -1
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +1 -1
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +1 -1
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +1 -1
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +1 -1
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +1 -1
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +1 -1
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +1 -1
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +1 -1
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +1 -1
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +1 -1
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +9 -9
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +93 -86
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +29 -1
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +29 -1
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +1 -1
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +1 -1
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +1 -1
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +1 -1
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +1 -1
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +1 -1
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/Types.d.ts +33 -19
- package/dist/Types.d.ts.map +1 -1
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +2 -1
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/arbitrary/model.d.ts +2 -0
- package/dist/internal/arbitrary/model.d.ts.map +1 -0
- package/dist/internal/arbitrary/model.js +495 -0
- package/dist/internal/arbitrary/model.js.map +1 -0
- package/dist/internal/arbitrary/regexp.d.ts +2 -0
- package/dist/internal/arbitrary/regexp.d.ts.map +1 -0
- package/dist/internal/arbitrary/regexp.js +789 -0
- package/dist/internal/arbitrary/regexp.js.map +1 -0
- package/dist/internal/arbitrary/runner.d.ts +2 -0
- package/dist/internal/arbitrary/runner.d.ts.map +1 -0
- package/dist/internal/arbitrary/runner.js +496 -0
- package/dist/internal/arbitrary/runner.js.map +1 -0
- package/dist/internal/arbitrary/schema.d.ts.map +1 -0
- package/dist/internal/arbitrary/schema.js +1340 -0
- package/dist/internal/arbitrary/schema.js.map +1 -0
- package/dist/internal/core.js +27 -13
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/count.d.ts +2 -0
- package/dist/internal/count.d.ts.map +1 -0
- package/dist/internal/count.js +14 -0
- package/dist/internal/count.js.map +1 -0
- package/dist/internal/dateTime.js +4 -10
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +386 -251
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/graph.js +3 -1
- package/dist/internal/graph.js.map +1 -1
- package/dist/internal/hashMap.js +5 -3
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hashSet.js +1 -1
- package/dist/internal/hashSet.js.map +1 -1
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/metric.js +1 -1
- package/dist/internal/metric.js.map +1 -1
- package/dist/internal/option.js +6 -5
- package/dist/internal/option.js.map +1 -1
- package/dist/internal/random.js +17 -0
- package/dist/internal/random.js.map +1 -1
- package/dist/internal/rcRef.js +10 -7
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/references.js +1 -0
- package/dist/internal/references.js.map +1 -1
- package/dist/internal/request.js +13 -6
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/result.js +11 -9
- package/dist/internal/result.js.map +1 -1
- package/dist/internal/schema/annotations.js +1 -1
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +14 -12
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +5 -5
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/make.d.ts +2 -0
- package/dist/internal/schema/make.d.ts.map +1 -0
- package/dist/internal/schema/{schema.js → make.js} +1 -25
- package/dist/internal/schema/make.js.map +1 -0
- package/dist/internal/schema/parser.d.ts +0 -12
- package/dist/internal/schema/parser.d.ts.map +1 -1
- package/dist/internal/schema/parser.js +7 -0
- package/dist/internal/schema/parser.js.map +1 -1
- package/dist/internal/schema/standardSchema.d.ts +2 -0
- package/dist/internal/schema/standardSchema.d.ts.map +1 -0
- package/dist/internal/schema/standardSchema.js +112 -0
- package/dist/internal/schema/standardSchema.js.map +1 -0
- package/dist/internal/schema/toCodeDocument.js +34 -22
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.d.ts +2 -0
- package/dist/internal/schema/toCodec.d.ts.map +1 -0
- package/dist/internal/schema/toCodec.js +242 -0
- package/dist/internal/schema/toCodec.js.map +1 -0
- package/dist/internal/schema/toDifferJsonPatch.d.ts +2 -0
- package/dist/internal/schema/toDifferJsonPatch.d.ts.map +1 -0
- package/dist/internal/schema/toDifferJsonPatch.js +20 -0
- package/dist/internal/schema/toDifferJsonPatch.js.map +1 -0
- package/dist/internal/schema/toEncoderXml.d.ts +2 -0
- package/dist/internal/schema/toEncoderXml.d.ts.map +1 -0
- package/dist/internal/schema/toEncoderXml.js +104 -0
- package/dist/internal/schema/toEncoderXml.js.map +1 -0
- package/dist/internal/schema/toEquivalence.js +66 -0
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toFormatter.d.ts +2 -0
- package/dist/internal/schema/toFormatter.d.ts.map +1 -0
- package/dist/internal/schema/toFormatter.js +227 -0
- package/dist/internal/schema/toFormatter.js.map +1 -0
- package/dist/internal/schema/toIso.d.ts +2 -0
- package/dist/internal/schema/toIso.d.ts.map +1 -0
- package/dist/internal/schema/toIso.js +17 -0
- package/dist/internal/schema/toIso.js.map +1 -0
- package/dist/internal/schema/toJsonSchemaDocument.js +122 -71
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +3 -1
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/schemaError.d.ts +4 -0
- package/dist/internal/schemaError.d.ts.map +1 -0
- package/dist/internal/schemaError.js +6 -0
- package/dist/internal/schemaError.js.map +1 -0
- package/dist/internal/stream.js +5 -6
- package/dist/internal/stream.js.map +1 -1
- package/dist/internal/tracer.d.ts +1 -3
- package/dist/internal/tracer.d.ts.map +1 -1
- package/dist/internal/tracer.js +6 -0
- package/dist/internal/tracer.js.map +1 -1
- package/dist/internal/trie.js +2 -2
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/uuid.d.ts +1 -2
- package/dist/internal/uuid.d.ts.map +1 -1
- package/dist/internal/uuid.js +2 -0
- package/dist/internal/uuid.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +9 -11
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +20 -18
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +0 -4
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +0 -4
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +74 -23
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +59 -5
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js +2 -1
- package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +27 -32
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +10 -13
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.d.ts +23 -16
- package/dist/unstable/ai/EmbeddingModel.d.ts.map +1 -1
- package/dist/unstable/ai/EmbeddingModel.js +13 -11
- package/dist/unstable/ai/EmbeddingModel.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +48 -37
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +150 -47
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +2 -2
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +21 -12
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +2 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +1 -1
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Prompt.js +15 -4
- package/dist/unstable/ai/Prompt.js.map +1 -1
- package/dist/unstable/ai/Response.d.ts +37 -94
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +46 -96
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tokenizer.js +4 -5
- package/dist/unstable/ai/Tokenizer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +38 -20
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +27 -1
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +30 -18
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/internal/structured-output.js +8 -5
- package/dist/unstable/ai/internal/structured-output.js.map +1 -1
- package/dist/unstable/arbitrary/Arbitrary.d.ts +626 -0
- package/dist/unstable/arbitrary/Arbitrary.d.ts.map +1 -0
- package/dist/unstable/arbitrary/Arbitrary.js +238 -0
- package/dist/unstable/arbitrary/Arbitrary.js.map +1 -0
- package/dist/unstable/arbitrary/index.d.ts +8 -0
- package/dist/unstable/arbitrary/index.d.ts.map +1 -0
- package/dist/unstable/arbitrary/index.js +9 -0
- package/dist/unstable/arbitrary/index.js.map +1 -0
- package/dist/unstable/cli/Argument.d.ts +104 -108
- package/dist/unstable/cli/Argument.d.ts.map +1 -1
- package/dist/unstable/cli/Argument.js +56 -57
- package/dist/unstable/cli/Argument.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +2 -0
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +2 -0
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.js +26 -3
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +73 -73
- package/dist/unstable/cli/Command.js +18 -18
- package/dist/unstable/cli/Completions.d.ts +4 -4
- package/dist/unstable/cli/Completions.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.d.ts +150 -161
- package/dist/unstable/cli/Flag.d.ts.map +1 -1
- package/dist/unstable/cli/Flag.js +79 -90
- package/dist/unstable/cli/Flag.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +3 -3
- package/dist/unstable/cli/GlobalFlag.js +13 -13
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/Param.d.ts +118 -126
- package/dist/unstable/cli/Param.d.ts.map +1 -1
- package/dist/unstable/cli/Param.js +104 -113
- package/dist/unstable/cli/Param.js.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +69 -58
- package/dist/unstable/cli/Primitive.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.js +65 -66
- package/dist/unstable/cli/Primitive.js.map +1 -1
- package/dist/unstable/cli/Prompt.d.ts +23 -24
- package/dist/unstable/cli/Prompt.d.ts.map +1 -1
- package/dist/unstable/cli/Prompt.js +68 -63
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/completions/descriptor.js +23 -11
- package/dist/unstable/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/unstable/cli/internal/completions/zsh.js +2 -2
- package/dist/unstable/cli/internal/completions/zsh.js.map +1 -1
- package/dist/unstable/cli/internal/config.js +4 -4
- package/dist/unstable/cli/internal/parser.js +1 -1
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cli/internal/wizard.d.ts.map +1 -1
- package/dist/unstable/cli/internal/wizard.js +14 -13
- package/dist/unstable/cli/internal/wizard.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +13 -0
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.js +16 -1
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +57 -14
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +2 -0
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.d.ts +2 -2
- package/dist/unstable/cluster/EntityProxyServer.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityProxyServer.js.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +4 -4
- package/dist/unstable/cluster/Envelope.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.js +2 -3
- package/dist/unstable/cluster/Envelope.js.map +1 -1
- package/dist/unstable/cluster/HttpRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/HttpRunner.js +5 -2
- package/dist/unstable/cluster/HttpRunner.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +34 -4
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +28 -9
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +32 -17
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +23 -23
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SocketRunner.d.ts +2 -2
- package/dist/unstable/cluster/SocketRunner.d.ts.map +1 -1
- package/dist/unstable/cluster/SocketRunner.js +4 -3
- package/dist/unstable/cluster/SocketRunner.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +11 -8
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +11 -4
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/clusterAbandon.d.ts +5 -0
- package/dist/unstable/cluster/internal/clusterAbandon.d.ts.map +1 -0
- package/dist/unstable/cluster/internal/clusterAbandon.js +9 -0
- package/dist/unstable/cluster/internal/clusterAbandon.js.map +1 -0
- package/dist/unstable/cluster/internal/entityManager.js +7 -4
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/interruptors.js +30 -1
- package/dist/unstable/cluster/internal/interruptors.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +12 -7
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/unstable/devtools/DevToolsClient.js +12 -7
- package/dist/unstable/devtools/DevToolsClient.js.map +1 -1
- package/dist/unstable/encoding/Ini.d.ts +2 -0
- package/dist/unstable/encoding/Ini.d.ts.map +1 -1
- package/dist/unstable/encoding/Ini.js +2 -0
- package/dist/unstable/encoding/Ini.js.map +1 -1
- package/dist/unstable/encoding/SchemaBinary.d.ts +27 -3
- package/dist/unstable/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/unstable/encoding/SchemaBinary.js +108 -39
- package/dist/unstable/encoding/SchemaBinary.js.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/encoding/Toml.d.ts +2 -0
- package/dist/unstable/encoding/Toml.d.ts.map +1 -1
- package/dist/unstable/encoding/Toml.js +6 -4
- package/dist/unstable/encoding/Toml.js.map +1 -1
- package/dist/unstable/encoding/Yaml.d.ts +2 -0
- package/dist/unstable/encoding/Yaml.d.ts.map +1 -1
- package/dist/unstable/encoding/Yaml.js +16 -5
- package/dist/unstable/encoding/Yaml.js.map +1 -1
- package/dist/unstable/encoding/index.d.ts +0 -4
- package/dist/unstable/encoding/index.d.ts.map +1 -1
- package/dist/unstable/encoding/index.js +0 -4
- package/dist/unstable/encoding/index.js.map +1 -1
- package/dist/unstable/eventlog/Event.d.ts +5 -5
- package/dist/unstable/eventlog/Event.d.ts.map +1 -1
- package/dist/unstable/eventlog/Event.js +3 -3
- package/dist/unstable/eventlog/Event.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +7 -7
- package/dist/unstable/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +9 -9
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts +1 -1
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +4 -4
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.d.ts +11 -5
- package/dist/unstable/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogMessage.js +25 -15
- package/dist/unstable/eventlog/EventLogMessage.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +7 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.js +13 -3
- package/dist/unstable/eventlog/EventLogRemote.js.map +1 -1
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js +2 -2
- package/dist/unstable/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventJournal.js +26 -13
- package/dist/unstable/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js +5 -1
- package/dist/unstable/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/unstable/http/Cookies.d.ts +1 -45
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +2 -64
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/FetchHttpClient.js +1 -1
- package/dist/unstable/http/FetchHttpClient.js.map +1 -1
- package/dist/unstable/http/FindMyWay/internal/router.js +124 -33
- package/dist/unstable/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/unstable/http/FindMyWay.d.ts +15 -5
- package/dist/unstable/http/FindMyWay.d.ts.map +1 -1
- package/dist/unstable/http/FindMyWay.js +3 -1
- package/dist/unstable/http/FindMyWay.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +0 -22
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +3 -34
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +41 -10
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +64 -10
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +28 -18
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientRequest.d.ts +28 -6
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +8 -19
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +6 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +10 -6
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +16 -0
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +121 -65
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +3 -3
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js +1 -13
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +29 -21
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpPlatform.d.ts +12 -11
- package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
- package/dist/unstable/http/HttpPlatform.js +36 -10
- package/dist/unstable/http/HttpPlatform.js.map +1 -1
- package/dist/unstable/http/HttpRouter.d.ts +5 -1
- package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
- package/dist/unstable/http/HttpRouter.js +22 -8
- package/dist/unstable/http/HttpRouter.js.map +1 -1
- package/dist/unstable/http/HttpServer.d.ts +11 -42
- package/dist/unstable/http/HttpServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpServer.js +16 -20
- package/dist/unstable/http/HttpServer.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +11 -11
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +1 -1
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +9 -13
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +34 -44
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +2 -2
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/unstable/http/HttpStaticServer.js +19 -19
- package/dist/unstable/http/HttpStaticServer.js.map +1 -1
- package/dist/unstable/http/Mime.d.ts +28 -0
- package/dist/unstable/http/Mime.d.ts.map +1 -0
- package/dist/unstable/http/Mime.js +72 -0
- package/dist/unstable/http/Mime.js.map +1 -0
- package/dist/unstable/http/Multipart.d.ts +22 -9
- package/dist/unstable/http/Multipart.d.ts.map +1 -1
- package/dist/unstable/http/Multipart.js +26 -10
- package/dist/unstable/http/Multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.d.ts.map +1 -1
- package/dist/unstable/http/MultipartParser/internal/multipart.js +8 -3
- package/dist/unstable/http/MultipartParser/internal/multipart.js.map +1 -1
- package/dist/unstable/http/MultipartParser.d.ts +4 -3
- package/dist/unstable/http/MultipartParser.d.ts.map +1 -1
- package/dist/unstable/http/MultipartParser.js.map +1 -1
- package/dist/unstable/http/UrlParams.d.ts +0 -97
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +3 -104
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +4 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +4 -0
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/compression.js +8 -11
- package/dist/unstable/http/internal/compression.js.map +1 -1
- package/dist/unstable/http/internal/headers.d.ts +2 -0
- package/dist/unstable/http/internal/headers.d.ts.map +1 -0
- package/dist/unstable/http/internal/headers.js +5 -0
- package/dist/unstable/http/internal/headers.js.map +1 -0
- package/dist/unstable/http/internal/httpBody.js +8 -0
- package/dist/unstable/http/internal/httpBody.js.map +1 -1
- package/dist/unstable/http/internal/mimeTypes.d.ts +361 -0
- package/dist/unstable/http/internal/mimeTypes.d.ts.map +1 -0
- package/dist/unstable/http/internal/mimeTypes.js +363 -0
- package/dist/unstable/http/internal/mimeTypes.js.map +1 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +13 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +23 -6
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +4 -3
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +25 -13
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +8 -3
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +9 -6
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +3 -1
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js +7 -5
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +12 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +8 -10
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiTest.js +8 -2
- package/dist/unstable/httpapi/HttpApiTest.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +31 -20
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/net/IpInterface.d.ts +140 -0
- package/dist/unstable/net/IpInterface.d.ts.map +1 -0
- package/dist/unstable/net/IpInterface.js +149 -0
- package/dist/unstable/net/IpInterface.js.map +1 -0
- package/dist/unstable/net/IpNetwork.d.ts +227 -0
- package/dist/unstable/net/IpNetwork.d.ts.map +1 -0
- package/dist/unstable/net/IpNetwork.js +239 -0
- package/dist/unstable/net/IpNetwork.js.map +1 -0
- package/dist/unstable/net/NetAddress.d.ts +705 -0
- package/dist/unstable/net/NetAddress.d.ts.map +1 -0
- package/dist/unstable/net/NetAddress.js +956 -0
- package/dist/unstable/net/NetAddress.js.map +1 -0
- package/dist/unstable/net/index.d.ts +16 -0
- package/dist/unstable/net/index.d.ts.map +1 -0
- package/dist/unstable/net/index.js +17 -0
- package/dist/unstable/net/index.js.map +1 -0
- package/dist/unstable/observability/OtlpExporter.d.ts +1 -0
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +4 -6
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +9 -9
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.js +9 -8
- package/dist/unstable/observability/OtlpMetrics.js.map +1 -1
- package/dist/unstable/observability/OtlpResource.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpResource.js +2 -2
- package/dist/unstable/observability/OtlpResource.js.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.js +82 -55
- package/dist/unstable/observability/OtlpTracer.js.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.d.ts +1 -1
- package/dist/unstable/observability/internal/otlpEnv.d.ts.map +1 -1
- package/dist/unstable/observability/internal/otlpEnv.js +5 -9
- package/dist/unstable/observability/internal/otlpEnv.js.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +1 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +114 -14
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +799 -234
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +28 -15
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +33 -41
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +8 -2
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +7 -2
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +6 -3
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +3 -6
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +6 -3
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +2 -3
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +2 -2
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +1 -1
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +6 -4
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -1
- package/dist/unstable/reactivity/Hydration.js +20 -6
- package/dist/unstable/reactivity/Hydration.js.map +1 -1
- package/dist/unstable/reactivity/Reactivity.d.ts +26 -26
- package/dist/unstable/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/unstable/reactivity/Reactivity.js +10 -12
- package/dist/unstable/reactivity/Reactivity.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +64 -64
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcClientError.d.ts +1 -1
- package/dist/unstable/rpc/RpcMessage.d.ts +3 -1
- package/dist/unstable/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMessage.js +1 -1
- package/dist/unstable/rpc/RpcMessage.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js +7 -5
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts +5 -39
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +22 -115
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +104 -57
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +7 -6
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +3 -0
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +287 -102
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +408 -215
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +5 -32
- package/dist/unstable/socket/SocketServer.d.ts.map +1 -1
- package/dist/unstable/socket/SocketServer.js +3 -3
- package/dist/unstable/socket/SocketServer.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +20 -0
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlClient.js +14 -7
- package/dist/unstable/sql/SqlClient.js.map +1 -1
- package/dist/unstable/sql/SqlConnection.d.ts +15 -0
- package/dist/unstable/sql/SqlConnection.d.ts.map +1 -1
- package/dist/unstable/sql/SqlConnection.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +1 -1
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +13 -5
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +29 -15
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Transferable.js +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +3 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +7 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +14 -4
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +1 -1
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +2 -2
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/DurableQueue.d.ts +8 -0
- package/dist/unstable/workflow/DurableQueue.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableQueue.js +8 -0
- package/dist/unstable/workflow/DurableQueue.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +5 -0
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +70 -12
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +6 -0
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +11 -0
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +7 -9
- package/src/Array.ts +118 -67
- package/src/BigDecimal.ts +50 -28
- package/src/ByteSize.ts +838 -0
- package/src/Cache.ts +17 -3
- package/src/Cause.ts +1 -1
- package/src/Channel.ts +183 -48
- package/src/Chunk.ts +65 -36
- package/src/Config.ts +237 -248
- package/src/ConfigProvider.ts +7 -8
- package/src/Context.ts +31 -0
- package/src/Cron.ts +2 -2
- package/src/Crypto.ts +3 -2
- package/src/Deferred.ts +7 -6
- package/src/Duration.ts +1 -1
- package/src/Effect.ts +226 -122
- package/src/Effectable.ts +78 -9
- package/src/Encoding.ts +101 -11
- package/src/Equal.ts +1 -1
- package/src/ExecutionPlan.ts +3 -0
- package/src/Fiber.ts +33 -8
- package/src/FiberHandle.ts +3 -3
- package/src/FiberMap.ts +19 -10
- package/src/FileSystem.ts +55 -230
- package/src/Formatter.ts +21 -3
- package/src/Graph.ts +55 -25
- package/src/Hash.ts +5 -16
- package/src/HashRing.ts +9 -2
- package/src/HashSet.ts +56 -0
- package/src/Iterable.ts +66 -41
- package/src/JsonPatch.ts +4 -4
- package/src/JsonPointer.ts +97 -4
- package/src/JsonSchema.ts +8 -26
- package/src/Layer.ts +59 -18
- package/src/LayerMap.ts +8 -6
- package/src/LayerRef.ts +7 -5
- package/src/Logger.ts +125 -18
- package/src/ManagedRuntime.ts +1 -1
- package/src/Match.ts +33 -14
- package/src/Metric.ts +24 -21
- package/src/MutableHashMap.ts +1 -1
- package/src/MutableHashSet.ts +1 -1
- package/src/MutableList.ts +18 -2
- package/src/Number.ts +7 -1
- package/src/Optic.ts +8 -4
- package/src/Option.ts +1 -1
- package/src/Order.ts +3 -1
- package/src/PartitionedSemaphore.ts +1 -2
- package/src/Path.ts +1 -1
- package/src/PlatformError.ts +1 -1
- package/src/Pool.ts +125 -8
- package/src/PrimaryKey.ts +1 -1
- package/src/PubSub.ts +32 -20
- package/src/Queue.ts +119 -28
- package/src/Random.ts +20 -6
- package/src/RcMap.ts +20 -13
- package/src/Redacted.ts +1 -1
- package/src/RequestResolver.ts +49 -26
- package/src/Result.ts +1 -1
- package/src/Scheduler.ts +21 -11
- package/src/Schema.ts +4809 -6368
- package/src/SchemaAST.ts +1031 -284
- package/src/SchemaGetter.ts +75 -21
- package/src/SchemaIssue.ts +259 -15
- package/src/SchemaParser.ts +2 -12
- package/src/SchemaRepresentation.ts +1593 -29
- package/src/SchemaTransformation.ts +145 -22
- package/src/ScopedCache.ts +10 -3
- package/src/Sink.ts +31 -15
- package/src/Stream.ts +294 -76
- package/src/String.ts +20 -9
- package/src/Struct.ts +8 -4
- package/src/SynchronizedRef.ts +3 -5
- package/src/Terminal.ts +3 -3
- package/src/Tracer.ts +43 -14
- package/src/Tuple.ts +3 -1
- package/src/TxChunk.ts +1 -1
- package/src/TxDeferred.ts +1 -1
- package/src/TxHashMap.ts +1 -1
- package/src/TxHashSet.ts +92 -11
- package/src/TxPriorityQueue.ts +1 -1
- package/src/TxPubSub.ts +1 -1
- package/src/TxQueue.ts +22 -17
- package/src/TxReentrantLock.ts +29 -1
- package/src/TxRef.ts +1 -1
- package/src/TxSemaphore.ts +1 -1
- package/src/TxSubscriptionRef.ts +1 -1
- package/src/Types.ts +40 -17
- package/src/Utils.ts +3 -1
- package/src/index.ts +5 -0
- package/src/internal/arbitrary/model.ts +701 -0
- package/src/internal/arbitrary/regexp.ts +855 -0
- package/src/internal/arbitrary/runner.ts +608 -0
- package/src/internal/arbitrary/schema.ts +1800 -0
- package/src/internal/core.ts +48 -22
- package/src/internal/count.ts +14 -0
- package/src/internal/dateTime.ts +8 -10
- package/src/internal/effect.ts +475 -295
- package/src/internal/graph.ts +6 -1
- package/src/internal/hashMap.ts +5 -3
- package/src/internal/hashSet.ts +1 -1
- package/src/internal/matcher.ts +34 -19
- package/src/internal/metric.ts +1 -1
- package/src/internal/option.ts +8 -6
- package/src/internal/random.ts +20 -7
- package/src/internal/rcRef.ts +10 -7
- package/src/internal/references.ts +1 -0
- package/src/internal/request.ts +12 -7
- package/src/internal/result.ts +15 -11
- package/src/internal/schema/annotations.ts +3 -3
- package/src/internal/schema/fromJsonSchemaDocument.ts +14 -29
- package/src/internal/schema/fromRepresentation.ts +5 -3
- package/src/internal/schema/{schema.ts → make.ts} +0 -40
- package/src/internal/schema/parser.ts +8 -0
- package/src/internal/schema/standardSchema.ts +125 -0
- package/src/internal/schema/toCodeDocument.ts +58 -44
- package/src/internal/schema/toCodec.ts +312 -0
- package/src/internal/schema/toDifferJsonPatch.ts +24 -0
- package/src/internal/schema/toEncoderXml.ts +110 -0
- package/src/internal/schema/toEquivalence.ts +76 -0
- package/src/internal/schema/toFormatter.ts +230 -0
- package/src/internal/schema/toIso.ts +20 -0
- package/src/internal/schema/toJsonSchemaDocument.ts +125 -67
- package/src/internal/schema/toRepresentation.ts +1 -1
- package/src/internal/schemaError.ts +8 -0
- package/src/internal/stream.ts +14 -6
- package/src/internal/tracer.ts +4 -0
- package/src/internal/trie.ts +5 -2
- package/src/internal/uuid.ts +4 -0
- package/src/testing/TestSchema.ts +36 -30
- package/src/testing/index.ts +0 -5
- package/src/unstable/ai/AiError.ts +69 -5
- package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -1
- package/src/unstable/ai/Chat.ts +35 -36
- package/src/unstable/ai/EmbeddingModel.ts +27 -15
- package/src/unstable/ai/LanguageModel.ts +283 -100
- package/src/unstable/ai/McpServer.ts +36 -20
- package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -1
- package/src/unstable/ai/Prompt.ts +19 -4
- package/src/unstable/ai/Response.ts +107 -189
- package/src/unstable/ai/Tokenizer.ts +4 -5
- package/src/unstable/ai/Tool.ts +58 -35
- package/src/unstable/ai/Toolkit.ts +43 -37
- package/src/unstable/ai/internal/structured-output.ts +5 -5
- package/src/unstable/arbitrary/Arbitrary.ts +715 -0
- package/src/unstable/arbitrary/index.ts +10 -0
- package/src/unstable/cli/Argument.ts +111 -115
- package/src/unstable/cli/CliError.ts +2 -0
- package/src/unstable/cli/CliOutput.ts +40 -3
- package/src/unstable/cli/Command.ts +74 -74
- package/src/unstable/cli/Completions.ts +4 -4
- package/src/unstable/cli/Flag.ts +158 -169
- package/src/unstable/cli/GlobalFlag.ts +13 -13
- package/src/unstable/cli/Param.ts +150 -159
- package/src/unstable/cli/Primitive.ts +75 -76
- package/src/unstable/cli/Prompt.ts +88 -87
- package/src/unstable/cli/internal/completions/descriptor.ts +23 -11
- package/src/unstable/cli/internal/completions/zsh.ts +2 -2
- package/src/unstable/cli/internal/config.ts +4 -4
- package/src/unstable/cli/internal/parser.ts +1 -1
- package/src/unstable/cli/internal/wizard.ts +18 -13
- package/src/unstable/cluster/ClusterSchema.ts +19 -1
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +66 -16
- package/src/unstable/cluster/Entity.ts +3 -0
- package/src/unstable/cluster/EntityProxyServer.ts +6 -2
- package/src/unstable/cluster/Envelope.ts +3 -3
- package/src/unstable/cluster/HttpRunner.ts +7 -2
- package/src/unstable/cluster/MessageStorage.ts +62 -21
- package/src/unstable/cluster/Reply.ts +2 -2
- package/src/unstable/cluster/Sharding.ts +44 -19
- package/src/unstable/cluster/ShardingConfig.ts +23 -23
- package/src/unstable/cluster/SocketRunner.ts +5 -4
- package/src/unstable/cluster/SqlMessageStorage.ts +12 -8
- package/src/unstable/cluster/SqlRunnerStorage.ts +18 -10
- package/src/unstable/cluster/internal/clusterAbandon.ts +14 -0
- package/src/unstable/cluster/internal/entityManager.ts +12 -4
- package/src/unstable/cluster/internal/interruptors.ts +58 -1
- package/src/unstable/cluster/internal/resourceRef.ts +15 -7
- package/src/unstable/devtools/DevToolsClient.ts +13 -3
- package/src/unstable/encoding/Ini.ts +2 -0
- package/src/unstable/encoding/SchemaBinary.ts +150 -44
- package/src/unstable/encoding/Sse.ts +1 -1
- package/src/unstable/encoding/Toml.ts +7 -5
- package/src/unstable/encoding/Yaml.ts +18 -5
- package/src/unstable/encoding/index.ts +0 -5
- package/src/unstable/eventlog/Event.ts +7 -7
- package/src/unstable/eventlog/EventJournal.ts +9 -9
- package/src/unstable/eventlog/EventLog.ts +5 -5
- package/src/unstable/eventlog/EventLogMessage.ts +25 -15
- package/src/unstable/eventlog/EventLogRemote.ts +15 -4
- package/src/unstable/eventlog/EventLogServerUnencrypted.ts +2 -2
- package/src/unstable/eventlog/SqlEventJournal.ts +32 -9
- package/src/unstable/eventlog/SqlEventLogServerUnencrypted.ts +11 -1
- package/src/unstable/http/Cookies.ts +2 -102
- package/src/unstable/http/FetchHttpClient.ts +1 -1
- package/src/unstable/http/FindMyWay/internal/router.ts +139 -33
- package/src/unstable/http/FindMyWay.ts +15 -5
- package/src/unstable/http/Headers.ts +3 -48
- package/src/unstable/http/HttpBody.ts +107 -36
- package/src/unstable/http/HttpClient.ts +41 -30
- package/src/unstable/http/HttpClientRequest.ts +32 -18
- package/src/unstable/http/HttpClientResponse.ts +16 -3
- package/src/unstable/http/HttpEffect.ts +145 -73
- package/src/unstable/http/HttpIncomingMessage.ts +4 -4
- package/src/unstable/http/HttpMiddleware.ts +43 -24
- package/src/unstable/http/HttpPlatform.ts +62 -20
- package/src/unstable/http/HttpRouter.ts +27 -16
- package/src/unstable/http/HttpServer.ts +18 -57
- package/src/unstable/http/HttpServerRequest.ts +17 -15
- package/src/unstable/http/HttpServerRespondable.ts +1 -1
- package/src/unstable/http/HttpServerResponse.ts +49 -40
- package/src/unstable/http/HttpStaticServer.ts +30 -28
- package/src/unstable/http/Mime.ts +76 -0
- package/src/unstable/http/Multipart.ts +35 -18
- package/src/unstable/http/MultipartParser/internal/multipart.ts +10 -3
- package/src/unstable/http/MultipartParser.ts +4 -3
- package/src/unstable/http/UrlParams.ts +3 -161
- package/src/unstable/http/index.ts +5 -0
- package/src/unstable/http/internal/compression.ts +11 -12
- package/src/unstable/http/internal/headers.ts +7 -0
- package/src/unstable/http/internal/httpBody.ts +9 -0
- package/src/unstable/http/internal/mimeTypes.ts +395 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +52 -6
- package/src/unstable/httpapi/HttpApiClient.ts +44 -24
- package/src/unstable/httpapi/HttpApiEndpoint.ts +24 -11
- package/src/unstable/httpapi/HttpApiError.ts +3 -1
- package/src/unstable/httpapi/HttpApiMiddleware.ts +7 -5
- package/src/unstable/httpapi/HttpApiSchema.ts +14 -7
- package/src/unstable/httpapi/HttpApiTest.ts +6 -1
- package/src/unstable/httpapi/OpenApi.ts +32 -22
- package/src/unstable/net/IpInterface.ts +242 -0
- package/src/unstable/net/IpNetwork.ts +357 -0
- package/src/unstable/net/NetAddress.ts +1271 -0
- package/src/unstable/net/index.ts +20 -0
- package/src/unstable/observability/OtlpExporter.ts +5 -6
- package/src/unstable/observability/OtlpLogger.ts +9 -9
- package/src/unstable/observability/OtlpMetrics.ts +9 -8
- package/src/unstable/observability/OtlpResource.ts +5 -4
- package/src/unstable/observability/OtlpTracer.ts +103 -81
- package/src/unstable/observability/internal/otlpEnv.ts +10 -13
- package/src/unstable/persistence/PersistedCache.ts +1 -1
- package/src/unstable/persistence/PersistedQueue.ts +1100 -291
- package/src/unstable/persistence/RateLimiter.ts +64 -58
- package/src/unstable/process/ChildProcess.ts +15 -4
- package/src/unstable/process/ChildProcessSpawner.ts +1 -1
- package/src/unstable/reactivity/Atom.ts +6 -3
- package/src/unstable/reactivity/AtomHttpApi.ts +21 -10
- package/src/unstable/reactivity/AtomRegistry.ts +2 -4
- package/src/unstable/reactivity/AtomRpc.ts +6 -5
- package/src/unstable/reactivity/Hydration.ts +26 -7
- package/src/unstable/reactivity/Reactivity.ts +49 -36
- package/src/unstable/rpc/RpcClient.ts +62 -59
- package/src/unstable/rpc/RpcMessage.ts +3 -1
- package/src/unstable/rpc/RpcMiddleware.ts +7 -5
- package/src/unstable/rpc/RpcSerialization.ts +27 -117
- package/src/unstable/rpc/RpcServer.ts +143 -80
- package/src/unstable/schema/Model.ts +8 -7
- package/src/unstable/schema/VariantSchema.ts +3 -0
- package/src/unstable/socket/Socket.ts +714 -383
- package/src/unstable/socket/SocketServer.ts +5 -35
- package/src/unstable/sql/SqlClient.ts +42 -7
- package/src/unstable/sql/SqlConnection.ts +18 -0
- package/src/unstable/sql/SqlModel.ts +1 -1
- package/src/unstable/sql/Statement.ts +46 -20
- package/src/unstable/workers/Transferable.ts +1 -1
- package/src/unstable/workers/Worker.ts +3 -1
- package/src/unstable/workflow/Activity.ts +20 -9
- package/src/unstable/workflow/DurableClock.ts +1 -1
- package/src/unstable/workflow/DurableDeferred.ts +6 -0
- package/src/unstable/workflow/DurableQueue.ts +8 -0
- package/src/unstable/workflow/Workflow.ts +105 -28
- package/src/unstable/workflow/WorkflowEngine.ts +22 -0
- package/dist/internal/schema/schema.d.ts.map +0 -1
- package/dist/internal/schema/schema.js.map +0 -1
- package/dist/internal/schema/toArbitrary.d.ts +0 -2
- package/dist/internal/schema/toArbitrary.d.ts.map +0 -1
- package/dist/internal/schema/toArbitrary.js +0 -705
- package/dist/internal/schema/toArbitrary.js.map +0 -1
- package/dist/testing/FastCheck.d.ts +0 -90
- package/dist/testing/FastCheck.d.ts.map +0 -1
- package/dist/testing/FastCheck.js +0 -90
- package/dist/testing/FastCheck.js.map +0 -1
- package/dist/unstable/encoding/Msgpack.d.ts +0 -185
- package/dist/unstable/encoding/Msgpack.d.ts.map +0 -1
- package/dist/unstable/encoding/Msgpack.js +0 -227
- package/dist/unstable/encoding/Msgpack.js.map +0 -1
- package/src/internal/schema/toArbitrary.ts +0 -843
- package/src/testing/FastCheck.ts +0 -90
- package/src/unstable/encoding/Msgpack.ts +0 -432
- /package/dist/internal/{schema → arbitrary}/schema.d.ts +0 -0
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Models bidirectional socket connections in Effect.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* A `Socket` exposes a pull-based `reader` and a scoped `writer`. Acquiring
|
|
5
|
+
* the reader dials the connection and returns an `Effect` that yields batches
|
|
6
|
+
* of incoming frames with end-to-end backpressure: nothing is read from the
|
|
7
|
+
* transport until the consumer pulls. Every termination, including clean
|
|
8
|
+
* closes, surfaces as a `SocketError`, so reconnecting is a plain
|
|
9
|
+
* `Effect.retry` around the scoped consume loop.
|
|
8
10
|
*
|
|
9
11
|
* @since 4.0.0
|
|
10
12
|
*/
|
|
11
|
-
import type { NonEmptyReadonlyArray } from "../../Array.ts"
|
|
13
|
+
import type { NonEmptyArray, NonEmptyReadonlyArray } from "../../Array.ts"
|
|
12
14
|
import type * as Cause from "../../Cause.ts"
|
|
13
15
|
import * as Channel from "../../Channel.ts"
|
|
14
16
|
import * as Context from "../../Context.ts"
|
|
15
|
-
import * as Deferred from "../../Deferred.ts"
|
|
16
17
|
import type * as Duration from "../../Duration.ts"
|
|
17
18
|
import * as Effect from "../../Effect.ts"
|
|
18
19
|
import * as Exit from "../../Exit.ts"
|
|
19
|
-
import * as FiberSet from "../../FiberSet.ts"
|
|
20
20
|
import { constVoid, dual, flow } from "../../Function.ts"
|
|
21
21
|
import * as Latch from "../../Latch.ts"
|
|
22
22
|
import * as Layer from "../../Layer.ts"
|
|
23
23
|
import * as Predicate from "../../Predicate.ts"
|
|
24
24
|
import * as Pull from "../../Pull.ts"
|
|
25
|
-
import * as
|
|
26
|
-
import * as Result from "../../Result.ts"
|
|
25
|
+
import type * as Redacted from "../../Redacted.ts"
|
|
27
26
|
import * as Schema from "../../Schema.ts"
|
|
28
27
|
import * as Scope from "../../Scope.ts"
|
|
28
|
+
import * as Stream from "../../Stream.ts"
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Runtime type identifier attached to `Socket` services.
|
|
@@ -57,96 +57,202 @@ export const isSocket = (u: unknown): u is Socket => Predicate.hasProperty(u, Ty
|
|
|
57
57
|
export const Socket: Context.Service<Socket, Socket> = Context.Service<Socket>("effect/socket/Socket")
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Effect-based socket abstraction
|
|
61
|
-
*
|
|
60
|
+
* Effect-based socket abstraction exposing a pull-based read side and a
|
|
61
|
+
* scoped writer.
|
|
62
|
+
*
|
|
63
|
+
* **Details**
|
|
64
|
+
*
|
|
65
|
+
* Acquiring `reader` establishes the connection; the scope of the acquisition
|
|
66
|
+
* owns the connection lifecycle. Its `pull` yields non-empty batches of incoming
|
|
67
|
+
* frames and never completes via `Cause.Done`: every termination, clean close
|
|
68
|
+
* included, fails with a `SocketError` wrapping the close reason. Code placed
|
|
69
|
+
* between the acquisition and the first pull runs exactly once per
|
|
70
|
+
* (re)connection, which makes handshakes plain code placement.
|
|
71
|
+
*
|
|
72
|
+
* Closing the acquisition scope must fail a pull that is currently suspended,
|
|
73
|
+
* rather than leaving it blocked. Consumers such as `toChannel` rely on this
|
|
74
|
+
* to shut a connection down without racing every pull against a separate
|
|
75
|
+
* failure signal.
|
|
76
|
+
*
|
|
77
|
+
* The writer is detached from any single connection: acquiring it cannot
|
|
78
|
+
* fail, and writes made while disconnected suspend until the next connection
|
|
79
|
+
* is established. Releasing the writer scope half-closes the write side
|
|
80
|
+
* where the transport supports it.
|
|
81
|
+
*
|
|
82
|
+
* **Example** (Consuming with automatic reconnect)
|
|
83
|
+
*
|
|
84
|
+
* ```ts skip-type-checking
|
|
85
|
+
* Effect.gen(function*() {
|
|
86
|
+
* const { pull } = yield* socket.reader
|
|
87
|
+
* while (true) {
|
|
88
|
+
* yield* handle(yield* pull)
|
|
89
|
+
* }
|
|
90
|
+
* }).pipe(
|
|
91
|
+
* Effect.scoped,
|
|
92
|
+
* Effect.retry({ schedule: Schedule.exponential(200) })
|
|
93
|
+
* )
|
|
94
|
+
* ```
|
|
62
95
|
*
|
|
63
96
|
* @category models
|
|
64
97
|
* @since 4.0.0
|
|
65
98
|
*/
|
|
66
99
|
export interface Socket {
|
|
67
100
|
readonly [TypeId]: typeof TypeId
|
|
68
|
-
readonly
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
readonly reader: Effect.Effect<Reader, SocketError, Scope.Scope>
|
|
102
|
+
readonly writer: Effect.Effect<Writer, never, Scope.Scope>
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The read side of a live `Socket` connection.
|
|
107
|
+
*
|
|
108
|
+
* **Details**
|
|
109
|
+
*
|
|
110
|
+
* `pull` reads the next non-empty batch. `upgrade` wraps this connection with
|
|
111
|
+
* TLS when the transport supports it. Unsupported readers fail with a
|
|
112
|
+
* `SocketUpgradeError`. The upgrade also fails with `SocketUpgradeError` when
|
|
113
|
+
* the selected TLS role requires an identity but `key` and `cert` are not both
|
|
114
|
+
* provided. Calling `upgrade()` without an options object uses the adapter's
|
|
115
|
+
* client defaults.
|
|
116
|
+
*
|
|
117
|
+
* @category models
|
|
118
|
+
* @since 4.0.0
|
|
119
|
+
*/
|
|
120
|
+
export interface Reader<A extends Uint8Array | string = Uint8Array | string> {
|
|
121
|
+
readonly pull: Effect.Effect<NonEmptyReadonlyArray<A>, SocketError>
|
|
122
|
+
readonly upgrade: (options?: TlsUpgradeOptions) => Effect.Effect<void, SocketError>
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The write side of a `Socket`.
|
|
127
|
+
*
|
|
128
|
+
* **Details**
|
|
129
|
+
*
|
|
130
|
+
* `write` sends a single frame or a `CloseEvent`; `writeAll` sends a batch of
|
|
131
|
+
* frames, allowing transports to coalesce them into a single flush. Both
|
|
132
|
+
* apply the transport's native backpressure before succeeding.
|
|
133
|
+
*
|
|
134
|
+
* @category models
|
|
135
|
+
* @since 4.0.0
|
|
136
|
+
*/
|
|
137
|
+
export interface Writer {
|
|
138
|
+
readonly write: (chunk: Uint8Array | string | CloseEvent) => Effect.Effect<void, SocketError>
|
|
139
|
+
readonly writeAll: (chunks: NonEmptyReadonlyArray<Uint8Array | string>) => Effect.Effect<void, SocketError>
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* TLS credentials and handshake settings used to upgrade a live socket.
|
|
144
|
+
*
|
|
145
|
+
* **Details**
|
|
146
|
+
*
|
|
147
|
+
* `key` and `cert` are optional for client upgrades that do not present a
|
|
148
|
+
* client certificate. Server upgrades require both, and providing only one is
|
|
149
|
+
* invalid. Missing or incomplete credentials fail the upgrade with a
|
|
150
|
+
* `SocketUpgradeError` when the adapter needs an identity.
|
|
151
|
+
*
|
|
152
|
+
* @category models
|
|
153
|
+
* @since 4.0.0
|
|
154
|
+
*/
|
|
155
|
+
export interface TlsUpgradeOptions {
|
|
156
|
+
readonly key?:
|
|
157
|
+
| Redacted.Redacted<string | Uint8Array>
|
|
158
|
+
| ReadonlyArray<Redacted.Redacted<string | Uint8Array>>
|
|
159
|
+
| undefined
|
|
160
|
+
readonly cert?: string | Uint8Array | ReadonlyArray<string | Uint8Array> | undefined
|
|
161
|
+
readonly ca?: string | Uint8Array | ReadonlyArray<string | Uint8Array> | undefined
|
|
162
|
+
readonly passphrase?: Redacted.Redacted<string> | undefined
|
|
163
|
+
readonly alpnProtocols?: ReadonlyArray<string> | undefined
|
|
164
|
+
readonly requestCert?: boolean | undefined
|
|
165
|
+
readonly rejectUnauthorized?: boolean | undefined
|
|
91
166
|
}
|
|
92
167
|
|
|
93
168
|
/**
|
|
94
|
-
* Constructs a `Socket` from a
|
|
95
|
-
*
|
|
169
|
+
* Constructs a `Socket` from a reader acquisition and a scoped writer.
|
|
170
|
+
*
|
|
171
|
+
* **Details**
|
|
172
|
+
*
|
|
173
|
+
* The reader must fail a suspended pull when its acquisition scope closes; see
|
|
174
|
+
* `Socket` for why. A reader that leaves a pull blocked forever will hang any
|
|
175
|
+
* consumer that shuts the socket down by closing that scope.
|
|
96
176
|
*
|
|
97
177
|
* @category constructors
|
|
98
178
|
* @since 4.0.0
|
|
99
179
|
*/
|
|
100
180
|
export const make = (options: {
|
|
101
|
-
readonly
|
|
102
|
-
|
|
103
|
-
options?: {
|
|
104
|
-
readonly onOpen?: Effect.Effect<void> | undefined
|
|
105
|
-
}
|
|
106
|
-
) => Effect.Effect<void, SocketError | E, R>
|
|
107
|
-
readonly run?: <_, E, R>(
|
|
108
|
-
handler: (_: Uint8Array) => Effect.Effect<_, E, R> | void,
|
|
109
|
-
options?: {
|
|
110
|
-
readonly onOpen?: Effect.Effect<void> | undefined
|
|
111
|
-
}
|
|
112
|
-
) => Effect.Effect<void, SocketError | E, R>
|
|
113
|
-
readonly runString?: <_, E, R>(
|
|
114
|
-
handler: (_: string) => Effect.Effect<_, E, R> | void,
|
|
115
|
-
options?: {
|
|
116
|
-
readonly onOpen?: Effect.Effect<void> | undefined
|
|
117
|
-
}
|
|
118
|
-
) => Effect.Effect<void, SocketError | E, R>
|
|
119
|
-
readonly writer: Effect.Effect<
|
|
120
|
-
(chunk: Uint8Array | string | CloseEvent) => Effect.Effect<void, SocketError>,
|
|
121
|
-
never,
|
|
122
|
-
Scope.Scope
|
|
123
|
-
>
|
|
181
|
+
readonly reader: Socket["reader"]
|
|
182
|
+
readonly writer: Socket["writer"]
|
|
124
183
|
}): Socket =>
|
|
125
184
|
Socket.of({
|
|
126
185
|
[TypeId]: TypeId,
|
|
127
|
-
|
|
128
|
-
run: options.run ?? ((handler, opts) =>
|
|
129
|
-
options.runRaw((data) =>
|
|
130
|
-
typeof data === "string"
|
|
131
|
-
? handler(encoder.encode(data))
|
|
132
|
-
: data instanceof Uint8Array
|
|
133
|
-
? handler(data)
|
|
134
|
-
: handler(new Uint8Array(data)), opts)),
|
|
135
|
-
runString: options.runString ??
|
|
136
|
-
(options.run ?
|
|
137
|
-
(handler, opts) => options.run!((data) => handler(decoder.decode(data)), opts) :
|
|
138
|
-
(handler, opts) =>
|
|
139
|
-
options.runRaw((data) =>
|
|
140
|
-
typeof data === "string"
|
|
141
|
-
? handler(data)
|
|
142
|
-
: data instanceof Uint8Array
|
|
143
|
-
? handler(decoder.decode(data))
|
|
144
|
-
: handler(decoder.decode(new Uint8Array(data))), opts)),
|
|
186
|
+
reader: options.reader,
|
|
145
187
|
writer: options.writer
|
|
146
188
|
})
|
|
147
189
|
|
|
148
190
|
const encoder = new TextEncoder()
|
|
149
|
-
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Acquires the socket's binary `pull`, encoding any string frames as UTF-8
|
|
194
|
+
* bytes.
|
|
195
|
+
*
|
|
196
|
+
* **Details**
|
|
197
|
+
*
|
|
198
|
+
* When a pulled batch contains no string frames it is returned as-is, so
|
|
199
|
+
* transports that only emit bytes (TCP) pay no per-chunk cost.
|
|
200
|
+
*
|
|
201
|
+
* @category combinators
|
|
202
|
+
* @since 4.0.0
|
|
203
|
+
*/
|
|
204
|
+
export const readerBytes = (
|
|
205
|
+
self: Socket
|
|
206
|
+
): Effect.Effect<
|
|
207
|
+
Effect.Effect<NonEmptyReadonlyArray<Uint8Array>, SocketError>,
|
|
208
|
+
SocketError,
|
|
209
|
+
Scope.Scope
|
|
210
|
+
> =>
|
|
211
|
+
Effect.map(self.reader, ({ pull }) =>
|
|
212
|
+
Effect.map(pull, (chunk) => {
|
|
213
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
214
|
+
if (typeof chunk[i] === "string") {
|
|
215
|
+
const out = new Array<Uint8Array>(chunk.length) as NonEmptyArray<Uint8Array>
|
|
216
|
+
for (let j = 0; j < chunk.length; j++) {
|
|
217
|
+
const item = chunk[j]
|
|
218
|
+
out[j] = typeof item === "string" ? encoder.encode(item) : item
|
|
219
|
+
}
|
|
220
|
+
return out
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return chunk as NonEmptyReadonlyArray<Uint8Array>
|
|
224
|
+
}))
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Acquires the socket's string `pull`, decoding binary frames with the optional
|
|
228
|
+
* text encoding.
|
|
229
|
+
*
|
|
230
|
+
* **Details**
|
|
231
|
+
*
|
|
232
|
+
* The `TextDecoder` is created once per acquisition.
|
|
233
|
+
*
|
|
234
|
+
* @category combinators
|
|
235
|
+
* @since 4.0.0
|
|
236
|
+
*/
|
|
237
|
+
export const readerString = (
|
|
238
|
+
self: Socket,
|
|
239
|
+
encoding?: string | undefined
|
|
240
|
+
): Effect.Effect<
|
|
241
|
+
Effect.Effect<NonEmptyReadonlyArray<string>, SocketError>,
|
|
242
|
+
SocketError,
|
|
243
|
+
Scope.Scope
|
|
244
|
+
> =>
|
|
245
|
+
Effect.map(self.reader, ({ pull }) => {
|
|
246
|
+
const decoder = new TextDecoder(encoding)
|
|
247
|
+
return Effect.map(pull, (chunk) => {
|
|
248
|
+
const out = new Array<string>(chunk.length)
|
|
249
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
250
|
+
const item = chunk[i]
|
|
251
|
+
out[i] = typeof item === "string" ? item : decoder.decode(item)
|
|
252
|
+
}
|
|
253
|
+
return out as unknown as NonEmptyReadonlyArray<string>
|
|
254
|
+
})
|
|
255
|
+
})
|
|
150
256
|
|
|
151
257
|
const CloseEventTypeId = "~effect/socket/Socket/CloseEvent"
|
|
152
258
|
|
|
@@ -275,30 +381,51 @@ export class SocketOpenError extends Schema.Error<SocketOpenError>("effect/socke
|
|
|
275
381
|
}
|
|
276
382
|
|
|
277
383
|
/**
|
|
278
|
-
* Typed error for
|
|
279
|
-
* close reason.
|
|
384
|
+
* Typed error for an unsupported or failed in-place TLS upgrade.
|
|
280
385
|
*
|
|
281
386
|
* @category errors
|
|
282
387
|
* @since 4.0.0
|
|
283
388
|
*/
|
|
284
|
-
export class
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
389
|
+
export class SocketUpgradeError extends Schema.Error<SocketUpgradeError>(
|
|
390
|
+
"effect/socket/Socket/SocketUpgradeError"
|
|
391
|
+
)({
|
|
392
|
+
_tag: Schema.tag("SocketUpgradeError"),
|
|
393
|
+
cause: Schema.optional(Schema.Defect())
|
|
288
394
|
}) {
|
|
289
395
|
/**
|
|
290
|
-
*
|
|
396
|
+
* An upgrade implementation for transports that cannot wrap the connection
|
|
397
|
+
* with TLS.
|
|
291
398
|
*
|
|
292
399
|
* @since 4.0.0
|
|
293
400
|
*/
|
|
294
|
-
static
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
401
|
+
static readonly unsupported: Reader["upgrade"] = () =>
|
|
402
|
+
Effect.fail(new SocketError({ reason: new SocketUpgradeError({}) }))
|
|
403
|
+
|
|
404
|
+
override get message() {
|
|
405
|
+
return this.cause === undefined
|
|
406
|
+
? `Socket does not support TLS upgrade`
|
|
407
|
+
: `An error occurred during TLS upgrade`
|
|
300
408
|
}
|
|
409
|
+
}
|
|
301
410
|
|
|
411
|
+
/**
|
|
412
|
+
* Typed error for a socket close, carrying the close code and optional close
|
|
413
|
+
* reason.
|
|
414
|
+
*
|
|
415
|
+
* **Details**
|
|
416
|
+
*
|
|
417
|
+
* Sockets never classify closes: any close, whatever the code, fails the
|
|
418
|
+
* reader with a `SocketError` wrapping this reason. Consumers that treat a
|
|
419
|
+
* close as normal catch it.
|
|
420
|
+
*
|
|
421
|
+
* @category errors
|
|
422
|
+
* @since 4.0.0
|
|
423
|
+
*/
|
|
424
|
+
export class SocketCloseError extends Schema.Error<SocketCloseError>("effect/socket/Socket/SocketCloseError")({
|
|
425
|
+
_tag: Schema.tag("SocketCloseError"),
|
|
426
|
+
code: Schema.Int,
|
|
427
|
+
closeReason: Schema.optional(Schema.String)
|
|
428
|
+
}) {
|
|
302
429
|
override get message() {
|
|
303
430
|
if (this.closeReason) {
|
|
304
431
|
return `${this.code}: ${this.closeReason}`
|
|
@@ -317,11 +444,12 @@ export const SocketErrorReason = Schema.Union([
|
|
|
317
444
|
SocketReadError,
|
|
318
445
|
SocketWriteError,
|
|
319
446
|
SocketOpenError,
|
|
447
|
+
SocketUpgradeError,
|
|
320
448
|
SocketCloseError
|
|
321
449
|
])
|
|
322
450
|
|
|
323
451
|
/**
|
|
324
|
-
* Union of socket-specific read, write, open, and close error reasons.
|
|
452
|
+
* Union of socket-specific read, write, open, upgrade, and close error reasons.
|
|
325
453
|
*
|
|
326
454
|
* @category errors
|
|
327
455
|
* @since 4.0.0
|
|
@@ -330,11 +458,12 @@ export type SocketErrorReason =
|
|
|
330
458
|
| SocketReadError
|
|
331
459
|
| SocketWriteError
|
|
332
460
|
| SocketOpenError
|
|
461
|
+
| SocketUpgradeError
|
|
333
462
|
| SocketCloseError
|
|
334
463
|
|
|
335
464
|
/**
|
|
336
|
-
* Tagged error that wraps socket read, write, open, and close failures
|
|
337
|
-
* preserving the underlying reason.
|
|
465
|
+
* Tagged error that wraps socket read, write, open, upgrade, and close failures
|
|
466
|
+
* while preserving the underlying reason.
|
|
338
467
|
*
|
|
339
468
|
* @category errors
|
|
340
469
|
* @since 4.0.0
|
|
@@ -345,7 +474,7 @@ export class SocketError extends Schema.TaggedError<SocketError>(SocketErrorType
|
|
|
345
474
|
}) {
|
|
346
475
|
// @effect-diagnostics-next-line overriddenSchemaConstructor:off
|
|
347
476
|
constructor(props: {
|
|
348
|
-
readonly reason: SocketReadError | SocketWriteError | SocketOpenError | SocketCloseError
|
|
477
|
+
readonly reason: SocketReadError | SocketWriteError | SocketOpenError | SocketUpgradeError | SocketCloseError
|
|
349
478
|
}) {
|
|
350
479
|
if ("cause" in props.reason) {
|
|
351
480
|
super({
|
|
@@ -376,16 +505,32 @@ export class SocketError extends Schema.TaggedError<SocketError>(SocketErrorType
|
|
|
376
505
|
override readonly message = this.reason.message
|
|
377
506
|
}
|
|
378
507
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
508
|
+
const closeError = (code: number, closeReason?: string | undefined) =>
|
|
509
|
+
new SocketError({ reason: new SocketCloseError({ code, closeReason }) })
|
|
510
|
+
|
|
511
|
+
const writeChunk = (
|
|
512
|
+
writer: Writer,
|
|
513
|
+
chunk: NonEmptyReadonlyArray<Uint8Array | string | CloseEvent>
|
|
514
|
+
): Effect.Effect<void, SocketError> => {
|
|
515
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
516
|
+
if (isCloseEvent(chunk[i])) {
|
|
517
|
+
return Effect.gen(function*() {
|
|
518
|
+
for (let index = 0; index <= i; index++) {
|
|
519
|
+
yield* writer.write(chunk[index])
|
|
520
|
+
}
|
|
521
|
+
})
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
return writer.writeAll(chunk as NonEmptyReadonlyArray<Uint8Array | string>)
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const toChannelWithReader = <A extends Uint8Array | string, IE>(
|
|
387
528
|
self: Socket,
|
|
388
|
-
|
|
529
|
+
reader: Effect.Effect<
|
|
530
|
+
Effect.Effect<NonEmptyReadonlyArray<A>, SocketError>,
|
|
531
|
+
SocketError,
|
|
532
|
+
Scope.Scope
|
|
533
|
+
>
|
|
389
534
|
): Channel.Channel<
|
|
390
535
|
NonEmptyReadonlyArray<A>,
|
|
391
536
|
SocketError | IE,
|
|
@@ -394,54 +539,57 @@ export const toChannelMap = <IE, A>(
|
|
|
394
539
|
IE
|
|
395
540
|
> =>
|
|
396
541
|
Channel.fromTransform(Effect.fnUntraced(function*(upstream, scope) {
|
|
397
|
-
const
|
|
398
|
-
|
|
542
|
+
const readScope = yield* Scope.fork(scope)
|
|
543
|
+
const pull = yield* Scope.provide(reader, readScope)
|
|
399
544
|
const writeScope = yield* Scope.fork(scope)
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
let
|
|
403
|
-
let index = 0
|
|
404
|
-
const writeChunk = Effect.whileLoop({
|
|
405
|
-
while: () => index < chunk!.length,
|
|
406
|
-
body: () => write(chunk![index++]),
|
|
407
|
-
step: constVoid
|
|
408
|
-
})
|
|
545
|
+
const writer = yield* Scope.provide(self.writer, writeScope)
|
|
546
|
+
|
|
547
|
+
let writeFailure: Cause.Cause<SocketError | IE> | undefined
|
|
409
548
|
|
|
410
549
|
yield* upstream.pipe(
|
|
411
|
-
Effect.flatMap((
|
|
412
|
-
if (arr.length === 1) return write(arr[0])
|
|
413
|
-
chunk = arr
|
|
414
|
-
index = 0
|
|
415
|
-
return writeChunk
|
|
416
|
-
}),
|
|
550
|
+
Effect.flatMap((chunk) => writeChunk(writer, chunk)),
|
|
417
551
|
Effect.forever({ disableYield: true }),
|
|
418
552
|
Effect.catchCauseFilter(
|
|
419
553
|
Pull.filterNoDone,
|
|
420
|
-
(cause) =>
|
|
554
|
+
(cause) =>
|
|
555
|
+
Effect.suspend(() => {
|
|
556
|
+
writeFailure = cause as Cause.Cause<SocketError | IE>
|
|
557
|
+
// closing the read scope fails a suspended pull, which is the
|
|
558
|
+
// reader contract, so the read side needs no per-pull failure race
|
|
559
|
+
return Scope.close(readScope, Exit.void)
|
|
560
|
+
})
|
|
421
561
|
),
|
|
422
562
|
Effect.ensuring(Scope.close(writeScope, Exit.void)),
|
|
423
563
|
Effect.forkIn(scope)
|
|
424
564
|
)
|
|
425
565
|
|
|
426
|
-
yield* self.runRaw((data) => {
|
|
427
|
-
Queue.offerUnsafe(queue, f(data))
|
|
428
|
-
}).pipe(
|
|
429
|
-
Queue.into(queue),
|
|
430
|
-
Effect.forkIn(scope)
|
|
431
|
-
)
|
|
432
|
-
|
|
433
566
|
// @effect-diagnostics-next-line returnEffectInGen:off
|
|
434
|
-
return
|
|
567
|
+
return Effect.catchCause(
|
|
568
|
+
Effect.suspend(
|
|
569
|
+
(): Pull.Pull<NonEmptyReadonlyArray<A>, SocketError | IE> =>
|
|
570
|
+
writeFailure !== undefined ? Effect.failCause(writeFailure) : pull
|
|
571
|
+
),
|
|
572
|
+
(cause) =>
|
|
573
|
+
Effect.failCause(
|
|
574
|
+
(writeFailure ?? cause) as Cause.Cause<SocketError | IE | Cause.Done<void>>
|
|
575
|
+
)
|
|
576
|
+
)
|
|
435
577
|
}))
|
|
436
578
|
|
|
437
579
|
/**
|
|
438
|
-
* Converts a `Socket` into a binary `Channel`, encoding
|
|
439
|
-
* as UTF-8 bytes
|
|
580
|
+
* Converts a `Socket` into a bidirectional binary `Channel`, encoding
|
|
581
|
+
* incoming string frames as UTF-8 bytes and writing outgoing frame batches to
|
|
582
|
+
* the socket.
|
|
583
|
+
*
|
|
584
|
+
* **Details**
|
|
585
|
+
*
|
|
586
|
+
* The read side is the socket's pull, so the channel is backpressured
|
|
587
|
+
* end-to-end.
|
|
440
588
|
*
|
|
441
589
|
* @category combinators
|
|
442
590
|
* @since 4.0.0
|
|
443
591
|
*/
|
|
444
|
-
export const toChannel = <IE>(
|
|
592
|
+
export const toChannel = <IE = never>(
|
|
445
593
|
self: Socket
|
|
446
594
|
): Channel.Channel<
|
|
447
595
|
NonEmptyReadonlyArray<Uint8Array>,
|
|
@@ -449,22 +597,19 @@ export const toChannel = <IE>(
|
|
|
449
597
|
void,
|
|
450
598
|
NonEmptyReadonlyArray<Uint8Array | string | CloseEvent>,
|
|
451
599
|
IE
|
|
452
|
-
> =>
|
|
453
|
-
const encoder = new TextEncoder()
|
|
454
|
-
return toChannelMap(self, (data) => typeof data === "string" ? encoder.encode(data) : data)
|
|
455
|
-
}
|
|
600
|
+
> => toChannelWithReader<Uint8Array, IE>(self, readerBytes(self))
|
|
456
601
|
|
|
457
602
|
/**
|
|
458
|
-
* Converts a `Socket` into a string `Channel`, decoding binary
|
|
459
|
-
* optional text encoding.
|
|
603
|
+
* Converts a `Socket` into a bidirectional string `Channel`, decoding binary
|
|
604
|
+
* frames with the optional text encoding.
|
|
460
605
|
*
|
|
461
606
|
* @category combinators
|
|
462
607
|
* @since 4.0.0
|
|
463
608
|
*/
|
|
464
609
|
export const toChannelString: {
|
|
465
610
|
/**
|
|
466
|
-
* Converts a `Socket` into a string `Channel`, decoding binary
|
|
467
|
-
* optional text encoding.
|
|
611
|
+
* Converts a `Socket` into a bidirectional string `Channel`, decoding binary
|
|
612
|
+
* frames with the optional text encoding.
|
|
468
613
|
*
|
|
469
614
|
* @category combinators
|
|
470
615
|
* @since 4.0.0
|
|
@@ -477,8 +622,8 @@ export const toChannelString: {
|
|
|
477
622
|
IE
|
|
478
623
|
>
|
|
479
624
|
/**
|
|
480
|
-
* Converts a `Socket` into a string `Channel`, decoding binary
|
|
481
|
-
* optional text encoding.
|
|
625
|
+
* Converts a `Socket` into a bidirectional string `Channel`, decoding binary
|
|
626
|
+
* frames with the optional text encoding.
|
|
482
627
|
*
|
|
483
628
|
* @category combinators
|
|
484
629
|
* @since 4.0.0
|
|
@@ -499,10 +644,21 @@ export const toChannelString: {
|
|
|
499
644
|
void,
|
|
500
645
|
NonEmptyReadonlyArray<Uint8Array | string | CloseEvent>,
|
|
501
646
|
IE
|
|
502
|
-
> =>
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
647
|
+
> => toChannelWithReader</**
|
|
648
|
+
* Converts a `Socket` into a bidirectional string `Channel`, decoding binary
|
|
649
|
+
* frames with the optional text encoding.
|
|
650
|
+
*
|
|
651
|
+
* @category combinators
|
|
652
|
+
* @since 4.0.0
|
|
653
|
+
*/
|
|
654
|
+
string, /**
|
|
655
|
+
* Converts a `Socket` into a bidirectional string `Channel`, decoding binary
|
|
656
|
+
* frames with the optional text encoding.
|
|
657
|
+
*
|
|
658
|
+
* @category combinators
|
|
659
|
+
* @since 4.0.0
|
|
660
|
+
*/
|
|
661
|
+
IE>(self, readerString(self, encoding)))
|
|
506
662
|
|
|
507
663
|
/**
|
|
508
664
|
* Creates a `Socket` to binary `Channel` adapter with a fixed upstream error
|
|
@@ -522,6 +678,18 @@ export const toChannelWith = <IE = never>() =>
|
|
|
522
678
|
IE
|
|
523
679
|
> => toChannel(self)
|
|
524
680
|
|
|
681
|
+
/**
|
|
682
|
+
* Converts a `Socket` into a read-only binary `Stream` backed by the socket's
|
|
683
|
+
* pull, so consumption is backpressured end-to-end.
|
|
684
|
+
*
|
|
685
|
+
* @category combinators
|
|
686
|
+
* @since 4.0.0
|
|
687
|
+
*/
|
|
688
|
+
export const toStream = (self: Socket): Stream.Stream<Uint8Array, SocketError> =>
|
|
689
|
+
Stream.fromChannel(
|
|
690
|
+
Channel.fromTransform((_, scope) => Scope.provide(readerBytes(self), scope))
|
|
691
|
+
)
|
|
692
|
+
|
|
525
693
|
/**
|
|
526
694
|
* Creates a binary socket `Channel` from the `Socket` service in the
|
|
527
695
|
* environment.
|
|
@@ -540,35 +708,104 @@ export const makeChannel = <IE = never>(): Channel.Channel<
|
|
|
540
708
|
> => Channel.unwrap(Effect.map(Socket, toChannelWith<IE>()))
|
|
541
709
|
|
|
542
710
|
/**
|
|
543
|
-
*
|
|
544
|
-
*
|
|
711
|
+
* Event payload exposed by a WebSocket implementation.
|
|
712
|
+
*
|
|
713
|
+
* **Details**
|
|
714
|
+
*
|
|
715
|
+
* The socket adapter only reads `data`, `code`, and `reason`; implementations
|
|
716
|
+
* may expose additional fields.
|
|
717
|
+
*
|
|
718
|
+
* @category models
|
|
719
|
+
* @since 4.0.0
|
|
720
|
+
*/
|
|
721
|
+
export interface WebSocketEvent {
|
|
722
|
+
readonly type?: string
|
|
723
|
+
readonly data?: unknown
|
|
724
|
+
readonly code?: number
|
|
725
|
+
readonly reason?: string
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* The subset of the WebSocket API required by `Socket`.
|
|
730
|
+
*
|
|
731
|
+
* **Details**
|
|
732
|
+
*
|
|
733
|
+
* This structural interface is intentionally independent of the DOM
|
|
734
|
+
* `WebSocket` type. Node implementations such as `ws` expose the same
|
|
735
|
+
* event-target methods, but are not assignable to `globalThis.WebSocket`
|
|
736
|
+
* because their event payload types are runtime-specific.
|
|
737
|
+
*
|
|
738
|
+
* @category models
|
|
739
|
+
* @since 4.0.0
|
|
740
|
+
*/
|
|
741
|
+
export interface WebSocketLike {
|
|
742
|
+
readonly readyState: number
|
|
743
|
+
addEventListener(
|
|
744
|
+
type: "open" | "message" | "error" | "close",
|
|
745
|
+
listener: (event: WebSocketEvent) => void,
|
|
746
|
+
options?: {
|
|
747
|
+
readonly once?: boolean
|
|
748
|
+
}
|
|
749
|
+
): void
|
|
750
|
+
removeEventListener(
|
|
751
|
+
type: "open" | "message" | "error" | "close",
|
|
752
|
+
listener: (event: WebSocketEvent) => void
|
|
753
|
+
): void
|
|
754
|
+
close(code?: number, reason?: string): void
|
|
755
|
+
send(data: string | Uint8Array<ArrayBuffer>): void
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Common options understood by a WebSocket client implementation.
|
|
545
760
|
*
|
|
546
|
-
* @category
|
|
761
|
+
* @category models
|
|
762
|
+
* @since 4.0.0
|
|
763
|
+
*/
|
|
764
|
+
export interface WebSocketClientOptions {
|
|
765
|
+
/**
|
|
766
|
+
* Headers to include in the opening handshake.
|
|
767
|
+
*
|
|
768
|
+
* **Details**
|
|
769
|
+
*
|
|
770
|
+
* This is supported by Node and Bun WebSocket clients. Browser constructors
|
|
771
|
+
* cannot set arbitrary handshake headers and must reject this option.
|
|
772
|
+
*/
|
|
773
|
+
readonly headers?: Readonly<Record<string, string>> | undefined
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Options accepted by a `WebSocketConstructor`.
|
|
778
|
+
*
|
|
779
|
+
* **Details**
|
|
780
|
+
*
|
|
781
|
+
* Browser-compatible constructors accept a protocol string or list. Node and
|
|
782
|
+
* Bun constructors additionally accept `WebSocketClientOptions`.
|
|
783
|
+
*
|
|
784
|
+
* @category models
|
|
547
785
|
* @since 4.0.0
|
|
548
786
|
*/
|
|
549
|
-
export
|
|
787
|
+
export type WebSocketConstructorOptions = string | Array<string> | WebSocketClientOptions
|
|
550
788
|
|
|
551
789
|
/**
|
|
552
|
-
* Context service for the active `WebSocket` instance
|
|
553
|
-
* WebSocket-backed socket run is handling events.
|
|
790
|
+
* Context service for the active `WebSocket` instance.
|
|
554
791
|
*
|
|
555
792
|
* @category services
|
|
556
793
|
* @since 4.0.0
|
|
557
794
|
*/
|
|
558
|
-
export class WebSocket extends Context.Service<WebSocket,
|
|
795
|
+
export class WebSocket extends Context.Service<WebSocket, WebSocketLike>()(
|
|
559
796
|
"~effect/socket/Socket/WebSocket"
|
|
560
797
|
) {}
|
|
561
798
|
|
|
562
799
|
/**
|
|
563
800
|
* Context service for constructing `WebSocket` instances from a URL and
|
|
564
|
-
* optional protocols.
|
|
801
|
+
* optional protocols or platform-specific options.
|
|
565
802
|
*
|
|
566
803
|
* @category services
|
|
567
804
|
* @since 4.0.0
|
|
568
805
|
*/
|
|
569
806
|
export class WebSocketConstructor extends Context.Service<
|
|
570
807
|
WebSocketConstructor,
|
|
571
|
-
(url: string,
|
|
808
|
+
(url: string, options?: WebSocketConstructorOptions | undefined) => WebSocketLike
|
|
572
809
|
>()("@effect/platform/Socket/WebSocketConstructor") {}
|
|
573
810
|
|
|
574
811
|
/**
|
|
@@ -578,21 +815,25 @@ export class WebSocketConstructor extends Context.Service<
|
|
|
578
815
|
* @since 4.0.0
|
|
579
816
|
*/
|
|
580
817
|
export const layerWebSocketConstructorGlobal: Layer.Layer<WebSocketConstructor> = Layer.succeed(WebSocketConstructor)(
|
|
581
|
-
(url,
|
|
818
|
+
(url, options) => {
|
|
819
|
+
if (options !== undefined && typeof options !== "string" && !Array.isArray(options)) {
|
|
820
|
+
throw new TypeError("WebSocket client options are not supported by the global WebSocket constructor")
|
|
821
|
+
}
|
|
822
|
+
return new globalThis.WebSocket(url, options)
|
|
823
|
+
}
|
|
582
824
|
)
|
|
583
825
|
|
|
584
826
|
/**
|
|
585
|
-
* Creates a `Socket` backed by a `WebSocketConstructor`,
|
|
586
|
-
* WebSocket for each
|
|
587
|
-
* closes fail the run.
|
|
827
|
+
* Creates a `Socket` backed by a `WebSocketConstructor`, dialing the
|
|
828
|
+
* WebSocket for each reader acquisition.
|
|
588
829
|
*
|
|
589
830
|
* @category constructors
|
|
590
831
|
* @since 4.0.0
|
|
591
832
|
*/
|
|
592
833
|
export const makeWebSocket = (url: string | Effect.Effect<string>, options?: {
|
|
593
|
-
readonly closeCodeIsError?: ((code: number) => boolean) | undefined
|
|
594
834
|
readonly openTimeout?: Duration.Input | undefined
|
|
595
835
|
readonly protocols?: string | Array<string> | undefined
|
|
836
|
+
readonly highWaterMark?: number | undefined
|
|
596
837
|
}): Effect.Effect<Socket, never, WebSocketConstructor> =>
|
|
597
838
|
WebSocketConstructor.use((makeWs) =>
|
|
598
839
|
fromWebSocket(
|
|
@@ -606,170 +847,271 @@ export const makeWebSocket = (url: string | Effect.Effect<string>, options?: {
|
|
|
606
847
|
)
|
|
607
848
|
)
|
|
608
849
|
|
|
850
|
+
interface Pausable {
|
|
851
|
+
pause(): void
|
|
852
|
+
resume(): void
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
const isPausable = (ws: WebSocketLike): ws is WebSocketLike & Pausable =>
|
|
856
|
+
"pause" in ws && typeof (ws as any).pause === "function"
|
|
857
|
+
|
|
609
858
|
/**
|
|
610
|
-
* Builds a `Socket` from a scoped WebSocket acquisition effect
|
|
611
|
-
*
|
|
612
|
-
*
|
|
859
|
+
* Builds a `Socket` from a scoped WebSocket acquisition effect.
|
|
860
|
+
*
|
|
861
|
+
* **Details**
|
|
862
|
+
*
|
|
863
|
+
* Reader acquisition runs `acquire`, attaches event listeners, then waits for
|
|
864
|
+
* the socket to open. Implementations exposing `pause`/`resume` (the `ws`
|
|
865
|
+
* package) remain flowing until buffered frames reach the configured
|
|
866
|
+
* `highWaterMark` (64 KiB by default). Draining the buffer resumes the
|
|
867
|
+
* transport. Incoming frames that arrive in the same tick are coalesced into
|
|
868
|
+
* one batch. Implementations without pause (browsers) buffer incoming frames,
|
|
869
|
+
* optionally failing the socket with a `SocketReadError` when `highWaterMark`
|
|
870
|
+
* bytes are exceeded (default unbounded). Message boundaries survive: each
|
|
871
|
+
* pulled batch contains one element per frame.
|
|
613
872
|
*
|
|
614
873
|
* @category constructors
|
|
615
874
|
* @since 4.0.0
|
|
616
875
|
*/
|
|
617
|
-
export const fromWebSocket = <RO>(
|
|
618
|
-
acquire: Effect.Effect<
|
|
876
|
+
export const fromWebSocket = <RO, WS extends WebSocketLike>(
|
|
877
|
+
acquire: Effect.Effect<WS, SocketError, RO>,
|
|
619
878
|
options?: {
|
|
620
|
-
readonly closeCodeIsError?: ((code: number) => boolean) | undefined
|
|
621
879
|
readonly openTimeout?: Duration.Input | undefined
|
|
622
|
-
|
|
623
|
-
* Replays buffered events on the first run after the socket opens and before
|
|
624
|
-
* the run's `onOpen` effect.
|
|
625
|
-
*
|
|
626
|
-
* @category options
|
|
627
|
-
* @since 4.0.0
|
|
628
|
-
*/
|
|
629
|
-
readonly onInitialRun?: ((ws: globalThis.WebSocket) => ReadonlyArray<MessageEvent>) | undefined
|
|
880
|
+
readonly highWaterMark?: number | undefined
|
|
630
881
|
} | undefined
|
|
631
882
|
): Effect.Effect<Socket, never, Exclude<RO, Scope.Scope>> =>
|
|
632
883
|
Effect.withFiber((fiber) => {
|
|
633
|
-
let currentWS:
|
|
634
|
-
let initial = true
|
|
884
|
+
let currentWS: WebSocketLike | undefined
|
|
635
885
|
const latch = Latch.makeUnsafe(false)
|
|
636
886
|
const acquireContext = fiber.context as Context.Context<RO>
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
const result = handler(event.data instanceof ArrayBuffer ? new Uint8Array(event.data) : event.data)
|
|
662
|
-
if (Effect.isEffect(result)) {
|
|
663
|
-
run(result)
|
|
664
|
-
}
|
|
887
|
+
|
|
888
|
+
const reader: Socket["reader"] = Effect.gen(function*() {
|
|
889
|
+
const scope = yield* Effect.scope
|
|
890
|
+
const ws = yield* Scope.provide(acquire, scope)
|
|
891
|
+
if ("binaryType" in ws) {
|
|
892
|
+
;(ws as { binaryType: string }).binaryType = "arraybuffer"
|
|
893
|
+
}
|
|
894
|
+
const pausable = isPausable(ws)
|
|
895
|
+
const highWaterMark = options?.highWaterMark ?? (pausable ? defaultHighWaterMark : undefined)
|
|
896
|
+
|
|
897
|
+
type ReadResume = (
|
|
898
|
+
effect: Effect.Effect<NonEmptyReadonlyArray<Uint8Array | string>, SocketError>
|
|
899
|
+
) => void
|
|
900
|
+
|
|
901
|
+
let open = ws.readyState === 1
|
|
902
|
+
let paused = pausable && "isPaused" in ws && ws.isPaused === true
|
|
903
|
+
let buffer: Array<Uint8Array | string> = []
|
|
904
|
+
let bufferSize = 0
|
|
905
|
+
let error: SocketError | undefined
|
|
906
|
+
let waiter: ReadResume | undefined
|
|
907
|
+
let openWaiter:
|
|
908
|
+
| {
|
|
909
|
+
readonly resume: (effect: Effect.Effect<void, SocketError>) => void
|
|
910
|
+
readonly cleanup: () => void
|
|
665
911
|
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
912
|
+
| undefined
|
|
913
|
+
|
|
914
|
+
function pauseWebSocket() {
|
|
915
|
+
if (!pausable || paused) return
|
|
916
|
+
ws.pause()
|
|
917
|
+
paused = true
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function resumeWebSocket() {
|
|
921
|
+
if (!pausable || !paused) return
|
|
922
|
+
ws.resume()
|
|
923
|
+
paused = false
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
function takeBuffer(): NonEmptyReadonlyArray<Uint8Array | string> {
|
|
927
|
+
const chunk = buffer
|
|
928
|
+
buffer = []
|
|
929
|
+
bufferSize = 0
|
|
930
|
+
if (error === undefined) resumeWebSocket()
|
|
931
|
+
return chunk as unknown as NonEmptyReadonlyArray<Uint8Array | string>
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function deliver() {
|
|
935
|
+
if (waiter === undefined || buffer.length === 0) return
|
|
936
|
+
const resume = waiter
|
|
937
|
+
waiter = undefined
|
|
938
|
+
resume(Effect.succeed(takeBuffer()))
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function push(data: Uint8Array | string) {
|
|
942
|
+
buffer.push(data)
|
|
943
|
+
if (highWaterMark !== undefined) {
|
|
944
|
+
bufferSize += typeof data === "string" ? encoder.encode(data).byteLength : data.byteLength
|
|
684
945
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
reason: new SocketCloseError({
|
|
694
|
-
code,
|
|
695
|
-
closeReason: event.reason
|
|
696
|
-
})
|
|
946
|
+
if (waiter !== undefined) deliver()
|
|
947
|
+
if (pausable && bufferSize >= highWaterMark!) {
|
|
948
|
+
pauseWebSocket()
|
|
949
|
+
} else if (!pausable && !waiter && highWaterMark !== undefined && bufferSize > highWaterMark) {
|
|
950
|
+
fail(
|
|
951
|
+
new SocketError({
|
|
952
|
+
reason: new SocketReadError({
|
|
953
|
+
cause: new Error(`Socket highWaterMark of ${highWaterMark} bytes exceeded`)
|
|
697
954
|
})
|
|
698
|
-
)
|
|
955
|
+
})
|
|
699
956
|
)
|
|
700
957
|
}
|
|
958
|
+
}
|
|
701
959
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
open = true
|
|
710
|
-
Deferred.doneUnsafe(openDeferred, Effect.void)
|
|
711
|
-
}, { once: true })
|
|
712
|
-
yield* Deferred.await(openDeferred).pipe(
|
|
713
|
-
Effect.timeoutOrElse({
|
|
714
|
-
duration: options?.openTimeout ?? 10000,
|
|
715
|
-
orElse: () =>
|
|
716
|
-
Effect.fail(
|
|
717
|
-
new SocketError({
|
|
718
|
-
reason: new SocketOpenError({
|
|
719
|
-
kind: "Timeout",
|
|
720
|
-
cause: new Error("timeout waiting for \"open\"")
|
|
721
|
-
})
|
|
722
|
-
})
|
|
723
|
-
)
|
|
724
|
-
}),
|
|
725
|
-
Effect.raceFirst(FiberSet.join(fiberSet))
|
|
726
|
-
)
|
|
960
|
+
function fail(err: SocketError) {
|
|
961
|
+
if (error === undefined) error = err
|
|
962
|
+
if (openWaiter !== undefined) {
|
|
963
|
+
const { cleanup, resume } = openWaiter
|
|
964
|
+
openWaiter = undefined
|
|
965
|
+
cleanup()
|
|
966
|
+
resume(Effect.fail(error))
|
|
727
967
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
968
|
+
if (waiter !== undefined) {
|
|
969
|
+
const resume = waiter
|
|
970
|
+
waiter = undefined
|
|
971
|
+
resume(buffer.length > 0 ? Effect.succeed(takeBuffer()) : Effect.fail(error))
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
function onMessage(event: WebSocketEvent) {
|
|
976
|
+
const data = event.data as Uint8Array | ArrayBuffer | Blob | string
|
|
977
|
+
if (typeof Blob !== "undefined" && data instanceof Blob) {
|
|
978
|
+
data.arrayBuffer().then((buf) => push(new Uint8Array(buf)), (cause) => {
|
|
979
|
+
fail(new SocketError({ reason: new SocketReadError({ cause }) }))
|
|
980
|
+
})
|
|
981
|
+
return
|
|
734
982
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
(
|
|
983
|
+
push(data instanceof ArrayBuffer ? new Uint8Array(data) : data as Uint8Array | string)
|
|
984
|
+
}
|
|
985
|
+
function onError(event: WebSocketEvent) {
|
|
986
|
+
fail(
|
|
987
|
+
new SocketError({
|
|
988
|
+
reason: open
|
|
989
|
+
? new SocketReadError({ cause: event })
|
|
990
|
+
: new SocketOpenError({ kind: "Unknown", cause: event })
|
|
991
|
+
})
|
|
740
992
|
)
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
currentWS = undefined
|
|
746
|
-
}))
|
|
747
|
-
)
|
|
993
|
+
}
|
|
994
|
+
function onClose(event: WebSocketEvent) {
|
|
995
|
+
fail(closeError(typeof event.code === "number" ? event.code : 1006, event.reason))
|
|
996
|
+
}
|
|
748
997
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
998
|
+
ws.addEventListener("message", onMessage)
|
|
999
|
+
ws.addEventListener("error", onError, { once: true })
|
|
1000
|
+
ws.addEventListener("close", onClose, { once: true })
|
|
1001
|
+
yield* Scope.addFinalizer(
|
|
1002
|
+
scope,
|
|
1003
|
+
Effect.sync(() => {
|
|
1004
|
+
// resume a pull blocked in another fiber before detaching
|
|
1005
|
+
fail(closeError(1006))
|
|
1006
|
+
ws.removeEventListener("message", onMessage)
|
|
1007
|
+
ws.removeEventListener("error", onError)
|
|
1008
|
+
ws.removeEventListener("close", onClose)
|
|
1009
|
+
// let the close handshake proceed once nothing is pulling
|
|
1010
|
+
if (pausable) {
|
|
1011
|
+
try {
|
|
1012
|
+
resumeWebSocket()
|
|
1013
|
+
} catch {
|
|
1014
|
+
// the underlying stream may already be gone
|
|
758
1015
|
}
|
|
759
|
-
return Effect.void
|
|
760
|
-
} catch (cause) {
|
|
761
|
-
return Effect.fail(new SocketError({ reason: new SocketWriteError({ cause }) }))
|
|
762
1016
|
}
|
|
1017
|
+
latch.closeUnsafe()
|
|
1018
|
+
currentWS = undefined
|
|
763
1019
|
})
|
|
764
1020
|
)
|
|
765
|
-
const writer = Effect.succeed(write)
|
|
766
1021
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
1022
|
+
if (ws.readyState >= 2) {
|
|
1023
|
+
// @effect-diagnostics-next-line unnecessaryFailYieldableError:off
|
|
1024
|
+
return yield* Effect.fail(error ?? closeError(1006))
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
if (!open) {
|
|
1028
|
+
yield* Effect.callback<void, SocketError>((resume) => {
|
|
1029
|
+
const onOpen = () => {
|
|
1030
|
+
if (openWaiter?.resume !== resume) return
|
|
1031
|
+
openWaiter = undefined
|
|
1032
|
+
ws.removeEventListener("open", onOpen)
|
|
1033
|
+
resume(Effect.void)
|
|
1034
|
+
}
|
|
1035
|
+
const cleanup = () => ws.removeEventListener("open", onOpen)
|
|
1036
|
+
openWaiter = { resume, cleanup }
|
|
1037
|
+
ws.addEventListener("open", onOpen, { once: true })
|
|
1038
|
+
return Effect.sync(() => {
|
|
1039
|
+
if (openWaiter?.resume === resume) openWaiter = undefined
|
|
1040
|
+
cleanup()
|
|
1041
|
+
})
|
|
1042
|
+
}).pipe(
|
|
1043
|
+
Effect.timeoutOrElse({
|
|
1044
|
+
duration: options?.openTimeout ?? 10000,
|
|
1045
|
+
orElse: () =>
|
|
1046
|
+
Effect.fail(
|
|
1047
|
+
new SocketError({
|
|
1048
|
+
reason: new SocketOpenError({
|
|
1049
|
+
kind: "Timeout",
|
|
1050
|
+
cause: new Error("timeout waiting for \"open\"")
|
|
1051
|
+
})
|
|
1052
|
+
})
|
|
1053
|
+
)
|
|
1054
|
+
})
|
|
1055
|
+
)
|
|
1056
|
+
open = true
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
if (error === undefined && bufferSize < highWaterMark!) resumeWebSocket()
|
|
1060
|
+
currentWS = ws
|
|
1061
|
+
latch.openUnsafe()
|
|
1062
|
+
|
|
1063
|
+
return {
|
|
1064
|
+
pull: Effect.callback<NonEmptyReadonlyArray<Uint8Array | string>, SocketError>((resume) => {
|
|
1065
|
+
if (buffer.length > 0) return resume(Effect.succeed(takeBuffer()))
|
|
1066
|
+
if (error !== undefined) return resume(Effect.fail(error))
|
|
1067
|
+
waiter = resume
|
|
1068
|
+
return Effect.sync(() => {
|
|
1069
|
+
if (waiter === resume) waiter = undefined
|
|
1070
|
+
})
|
|
1071
|
+
}),
|
|
1072
|
+
upgrade: SocketUpgradeError.unsupported
|
|
1073
|
+
}
|
|
1074
|
+
}).pipe(
|
|
1075
|
+
Effect.updateContext((input: Context.Context<Scope.Scope>) => Context.merge(acquireContext, input))
|
|
1076
|
+
) as Socket["reader"]
|
|
1077
|
+
|
|
1078
|
+
const write = (chunk: Uint8Array | string | CloseEvent): Effect.Effect<void, SocketError> =>
|
|
1079
|
+
Effect.suspend(() => {
|
|
1080
|
+
const ws = currentWS
|
|
1081
|
+
if (ws === undefined) return latch.whenOpen(write(chunk))
|
|
1082
|
+
try {
|
|
1083
|
+
if (isCloseEvent(chunk)) {
|
|
1084
|
+
ws.close(chunk.code, chunk.reason)
|
|
1085
|
+
} else {
|
|
1086
|
+
ws.send(chunk as string | Uint8Array<ArrayBuffer>)
|
|
1087
|
+
}
|
|
1088
|
+
return Effect.void
|
|
1089
|
+
} catch (cause) {
|
|
1090
|
+
return Effect.fail(new SocketError({ reason: new SocketWriteError({ cause }) }))
|
|
1091
|
+
}
|
|
1092
|
+
})
|
|
1093
|
+
const writeAll = (
|
|
1094
|
+
chunks: NonEmptyReadonlyArray<Uint8Array | string>
|
|
1095
|
+
): Effect.Effect<void, SocketError> =>
|
|
1096
|
+
Effect.suspend(() => {
|
|
1097
|
+
const ws = currentWS
|
|
1098
|
+
if (ws === undefined) return latch.whenOpen(writeAll(chunks))
|
|
1099
|
+
try {
|
|
1100
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
1101
|
+
ws.send(chunks[i] as string | Uint8Array<ArrayBuffer>)
|
|
1102
|
+
}
|
|
1103
|
+
return Effect.void
|
|
1104
|
+
} catch (cause) {
|
|
1105
|
+
return Effect.fail(new SocketError({ reason: new SocketWriteError({ cause }) }))
|
|
1106
|
+
}
|
|
1107
|
+
})
|
|
1108
|
+
const writer: Socket["writer"] = Effect.succeed({ write, writeAll })
|
|
1109
|
+
|
|
1110
|
+
return Effect.succeed(make({ reader, writer }))
|
|
771
1111
|
})
|
|
772
1112
|
|
|
1113
|
+
const defaultHighWaterMark = 64 * 1024
|
|
1114
|
+
|
|
773
1115
|
/**
|
|
774
1116
|
* Creates a binary `Channel` backed by a WebSocket URL, requiring a
|
|
775
1117
|
* `WebSocketConstructor` service.
|
|
@@ -780,7 +1122,9 @@ export const fromWebSocket = <RO>(
|
|
|
780
1122
|
export const makeWebSocketChannel = <IE = never>(
|
|
781
1123
|
url: string,
|
|
782
1124
|
options?: {
|
|
783
|
-
readonly
|
|
1125
|
+
readonly openTimeout?: Duration.Input | undefined
|
|
1126
|
+
readonly protocols?: string | Array<string> | undefined
|
|
1127
|
+
readonly highWaterMark?: number | undefined
|
|
784
1128
|
}
|
|
785
1129
|
): Channel.Channel<
|
|
786
1130
|
NonEmptyReadonlyArray<Uint8Array>,
|
|
@@ -805,22 +1149,12 @@ export const makeWebSocketChannel = <IE = never>(
|
|
|
805
1149
|
export const layerWebSocket: (
|
|
806
1150
|
url: string | Effect.Effect<string>,
|
|
807
1151
|
options?: {
|
|
808
|
-
readonly closeCodeIsError?: ((code: number) => boolean) | undefined
|
|
809
1152
|
readonly openTimeout?: Duration.Input | undefined
|
|
810
1153
|
readonly protocols?: string | Array<string> | undefined
|
|
1154
|
+
readonly highWaterMark?: number | undefined
|
|
811
1155
|
} | undefined
|
|
812
1156
|
) => Layer.Layer<Socket, never, WebSocketConstructor> = flow(makeWebSocket, Layer.effect(Socket))
|
|
813
1157
|
|
|
814
|
-
/**
|
|
815
|
-
* Context reference for socket send queue capacity, defaulting to `16`.
|
|
816
|
-
*
|
|
817
|
-
* @category services
|
|
818
|
-
* @since 4.0.0
|
|
819
|
-
*/
|
|
820
|
-
export const SendQueueCapacity = Context.Reference<number>("~effect/socket/Socket/SendQueueCapacity", {
|
|
821
|
-
defaultValue: () => 16
|
|
822
|
-
})
|
|
823
|
-
|
|
824
1158
|
/**
|
|
825
1159
|
* Readable and writable stream pair used to adapt transform-style streams into
|
|
826
1160
|
* a `Socket`.
|
|
@@ -834,75 +1168,23 @@ export interface InputTransformStream {
|
|
|
834
1168
|
}
|
|
835
1169
|
|
|
836
1170
|
/**
|
|
837
|
-
* Builds a `Socket` from a scoped `InputTransformStream`,
|
|
838
|
-
* chunks
|
|
839
|
-
* stream, encoding strings as UTF-8
|
|
840
|
-
* `CloseEvent` values.
|
|
1171
|
+
* Builds a `Socket` from a scoped `InputTransformStream`, pulling incoming
|
|
1172
|
+
* chunks from the readable side and writing outgoing chunks to the writable
|
|
1173
|
+
* stream, encoding strings as UTF-8.
|
|
841
1174
|
*
|
|
842
1175
|
* @category constructors
|
|
843
1176
|
* @since 4.0.0
|
|
844
1177
|
*/
|
|
845
|
-
export const fromTransformStream = <R>(
|
|
846
|
-
|
|
847
|
-
|
|
1178
|
+
export const fromTransformStream = <R>(
|
|
1179
|
+
acquire: Effect.Effect<InputTransformStream, SocketError, R>
|
|
1180
|
+
): Effect.Effect<Socket, never, Exclude<R, Scope.Scope>> =>
|
|
848
1181
|
Effect.withFiber((fiber) => {
|
|
849
1182
|
const latch = Latch.makeUnsafe(false)
|
|
850
1183
|
let currentStream: {
|
|
851
1184
|
readonly stream: InputTransformStream
|
|
852
|
-
readonly
|
|
1185
|
+
readonly fail: (error: SocketError) => void
|
|
853
1186
|
} | undefined
|
|
854
|
-
const
|
|
855
|
-
const closeCodeIsError = options?.closeCodeIsError ?? defaultCloseCodeIsError
|
|
856
|
-
const runRaw = <_, E, R>(handler: (_: string | Uint8Array) => Effect.Effect<_, E, R> | void, opts?: {
|
|
857
|
-
readonly onOpen?: Effect.Effect<void> | undefined
|
|
858
|
-
}) =>
|
|
859
|
-
Effect.scopedWith(Effect.fnUntraced(function*(scope) {
|
|
860
|
-
const stream = yield* Scope.provide(acquire, scope)
|
|
861
|
-
const reader = stream.readable.getReader()
|
|
862
|
-
yield* Scope.addFinalizer(scope, Effect.promise(() => reader.cancel()))
|
|
863
|
-
const fiberSet = yield* FiberSet.make<any, E | SocketError>().pipe(
|
|
864
|
-
Scope.provide(scope)
|
|
865
|
-
)
|
|
866
|
-
const runFork = yield* FiberSet.runtime(fiberSet)<R>()
|
|
867
|
-
|
|
868
|
-
yield* Effect.tryPromise({
|
|
869
|
-
try: async () => {
|
|
870
|
-
while (true) {
|
|
871
|
-
const { done, value } = await reader.read()
|
|
872
|
-
if (done) {
|
|
873
|
-
throw new SocketError({ reason: new SocketCloseError({ code: 1000 }) })
|
|
874
|
-
}
|
|
875
|
-
const result = handler(value)
|
|
876
|
-
if (Effect.isEffect(result)) {
|
|
877
|
-
runFork(result)
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
},
|
|
881
|
-
catch: (cause) =>
|
|
882
|
-
isSocketError(cause) ? cause : new SocketError({
|
|
883
|
-
reason: new SocketReadError({ cause })
|
|
884
|
-
})
|
|
885
|
-
}).pipe(
|
|
886
|
-
FiberSet.run(fiberSet)
|
|
887
|
-
)
|
|
888
|
-
|
|
889
|
-
currentStream = { stream, fiberSet }
|
|
890
|
-
yield* latch.open
|
|
891
|
-
if (opts?.onOpen) yield* opts.onOpen
|
|
892
|
-
|
|
893
|
-
return yield* Effect.catchFilter(
|
|
894
|
-
FiberSet.join(fiberSet),
|
|
895
|
-
SocketCloseError.filterClean((_) => !closeCodeIsError(_)),
|
|
896
|
-
() => Effect.void
|
|
897
|
-
)
|
|
898
|
-
})).pipe(
|
|
899
|
-
(_) => _,
|
|
900
|
-
Effect.updateContext((input: Context.Context<R>) => Context.merge(acquireServices, input)),
|
|
901
|
-
Effect.ensuring(Effect.sync(() => {
|
|
902
|
-
latch.closeUnsafe()
|
|
903
|
-
currentStream = undefined
|
|
904
|
-
}))
|
|
905
|
-
)
|
|
1187
|
+
const acquireContext = fiber.context as Context.Context<R>
|
|
906
1188
|
|
|
907
1189
|
const writers = new WeakMap<InputTransformStream, WritableStreamDefaultWriter<Uint8Array>>()
|
|
908
1190
|
const getWriter = (stream: InputTransformStream) => {
|
|
@@ -913,33 +1195,82 @@ export const fromTransformStream = <R>(acquire: Effect.Effect<InputTransformStre
|
|
|
913
1195
|
}
|
|
914
1196
|
return writer
|
|
915
1197
|
}
|
|
1198
|
+
|
|
1199
|
+
const reader: Socket["reader"] = Effect.gen(function*() {
|
|
1200
|
+
const scope = yield* Effect.scope
|
|
1201
|
+
const stream = yield* Scope.provide(acquire, scope)
|
|
1202
|
+
const readerHandle = (stream.readable as ReadableStream<Uint8Array | string>).getReader()
|
|
1203
|
+
let error: SocketError | undefined
|
|
1204
|
+
yield* Scope.addFinalizer(
|
|
1205
|
+
scope,
|
|
1206
|
+
Effect.suspend(() => {
|
|
1207
|
+
latch.closeUnsafe()
|
|
1208
|
+
currentStream = undefined
|
|
1209
|
+
return Effect.promise(() => readerHandle.cancel().catch(constVoid))
|
|
1210
|
+
})
|
|
1211
|
+
)
|
|
1212
|
+
currentStream = {
|
|
1213
|
+
stream,
|
|
1214
|
+
fail(err) {
|
|
1215
|
+
if (error === undefined) error = err
|
|
1216
|
+
readerHandle.cancel().catch(constVoid)
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
latch.openUnsafe()
|
|
1220
|
+
|
|
1221
|
+
const read = Effect.tryPromise({
|
|
1222
|
+
try: () => readerHandle.read(),
|
|
1223
|
+
catch: (cause) =>
|
|
1224
|
+
error ?? new SocketError({
|
|
1225
|
+
reason: new SocketReadError({ cause })
|
|
1226
|
+
})
|
|
1227
|
+
})
|
|
1228
|
+
return {
|
|
1229
|
+
pull: Effect.suspend(() => {
|
|
1230
|
+
if (error !== undefined) return Effect.fail(error)
|
|
1231
|
+
return Effect.flatMap(read, ({ done, value }) =>
|
|
1232
|
+
done
|
|
1233
|
+
? Effect.fail(error ?? closeError(1000))
|
|
1234
|
+
: Effect.succeed([value] as unknown as NonEmptyReadonlyArray<Uint8Array | string>))
|
|
1235
|
+
}),
|
|
1236
|
+
upgrade: SocketUpgradeError.unsupported
|
|
1237
|
+
}
|
|
1238
|
+
}).pipe(
|
|
1239
|
+
Effect.updateContext((input: Context.Context<Scope.Scope>) => Context.merge(acquireContext, input))
|
|
1240
|
+
) as Socket["reader"]
|
|
1241
|
+
|
|
916
1242
|
const write = (chunk: Uint8Array | string | CloseEvent) =>
|
|
917
1243
|
latch.whenOpen(Effect.suspend(() => {
|
|
918
|
-
const
|
|
1244
|
+
const current = currentStream!
|
|
919
1245
|
if (isCloseEvent(chunk)) {
|
|
920
|
-
return
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
reason: new SocketCloseError({ code: chunk.code, closeReason: chunk.reason })
|
|
924
|
-
})
|
|
925
|
-
)
|
|
1246
|
+
return Effect.sync(() => {
|
|
1247
|
+
current.fail(closeError(chunk.code, chunk.reason))
|
|
1248
|
+
})
|
|
926
1249
|
}
|
|
927
1250
|
return Effect.tryPromise({
|
|
928
|
-
try: () => getWriter(stream).write(typeof chunk === "string" ? encoder.encode(chunk) : chunk),
|
|
1251
|
+
try: () => getWriter(current.stream).write(typeof chunk === "string" ? encoder.encode(chunk) : chunk),
|
|
929
1252
|
catch: (cause) => new SocketError({ reason: new SocketWriteError({ cause }) })
|
|
930
1253
|
})
|
|
931
1254
|
}))
|
|
932
|
-
const
|
|
933
|
-
Effect.
|
|
1255
|
+
const writeAll = (chunks: NonEmptyReadonlyArray<Uint8Array | string>) =>
|
|
1256
|
+
latch.whenOpen(Effect.tryPromise({
|
|
1257
|
+
try: async () => {
|
|
1258
|
+
const writer = getWriter(currentStream!.stream)
|
|
1259
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
1260
|
+
const chunk = chunks[i]
|
|
1261
|
+
await writer.write(typeof chunk === "string" ? encoder.encode(chunk) : chunk)
|
|
1262
|
+
}
|
|
1263
|
+
},
|
|
1264
|
+
catch: (cause) => new SocketError({ reason: new SocketWriteError({ cause }) })
|
|
1265
|
+
}))
|
|
1266
|
+
const writer: Socket["writer"] = Effect.acquireRelease(
|
|
1267
|
+
Effect.succeed({ write, writeAll }),
|
|
934
1268
|
() =>
|
|
935
1269
|
Effect.promise(async () => {
|
|
936
1270
|
if (!currentStream) return
|
|
937
|
-
await getWriter(currentStream.stream).close()
|
|
1271
|
+
await getWriter(currentStream.stream).close().catch(constVoid)
|
|
938
1272
|
})
|
|
939
1273
|
)
|
|
940
1274
|
|
|
941
|
-
return Effect.succeed(make({
|
|
942
|
-
runRaw,
|
|
943
|
-
writer
|
|
944
|
-
}))
|
|
1275
|
+
return Effect.succeed(make({ reader, writer }))
|
|
945
1276
|
})
|