effect 4.0.5 → 4.0.7
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/ai-docs/package.json +1 -1
- package/ai-docs/src/06_schedule/10_schedules.ts +5 -4
- package/ai-docs/tsconfig.json +3 -1
- package/dist/Arbitrary.d.ts +10 -2
- package/dist/Arbitrary.d.ts.map +1 -1
- package/dist/Arbitrary.js +2 -1
- package/dist/Arbitrary.js.map +1 -1
- package/dist/Array.d.ts +117 -52
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +41 -20
- package/dist/Array.js.map +1 -1
- package/dist/Bytes.d.ts +79 -0
- package/dist/Bytes.d.ts.map +1 -0
- package/dist/Bytes.js +109 -0
- package/dist/Bytes.js.map +1 -0
- package/dist/Channel.d.ts +181 -13
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +144 -34
- package/dist/Channel.js.map +1 -1
- package/dist/ChannelSchema.d.ts.map +1 -1
- package/dist/ChannelSchema.js.map +1 -1
- package/dist/Chunk.d.ts +39 -21
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +26 -17
- package/dist/Chunk.js.map +1 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +8 -3
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +2 -1
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Cron.d.ts +2 -2
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +6 -3
- package/dist/Cron.js.map +1 -1
- package/dist/Data.d.ts +54 -235
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js.map +1 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +56 -16
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +488 -164
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +204 -38
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +8 -1
- package/dist/Equal.js.map +1 -1
- package/dist/Equivalence.d.ts +2 -1
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +12 -8
- package/dist/Equivalence.js.map +1 -1
- package/dist/Exit.d.ts +27 -12
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +8 -3
- package/dist/Exit.js.map +1 -1
- package/dist/FiberHandle.d.ts +2 -0
- package/dist/FiberHandle.d.ts.map +1 -1
- package/dist/FiberHandle.js +9 -4
- package/dist/FiberHandle.js.map +1 -1
- package/dist/FiberMap.d.ts +2 -0
- package/dist/FiberMap.d.ts.map +1 -1
- package/dist/FiberMap.js +5 -2
- package/dist/FiberMap.js.map +1 -1
- package/dist/FileSystem.d.ts +5 -0
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +3 -0
- package/dist/FileSystem.js.map +1 -1
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +27 -13
- package/dist/Formatter.js.map +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js.map +1 -1
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +4 -1
- package/dist/Hash.js.map +1 -1
- package/dist/HashSet.d.ts.map +1 -1
- package/dist/HashSet.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +18 -17
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonPatch.js +4 -0
- package/dist/JsonPatch.js.map +1 -1
- package/dist/JsonSchema.d.ts +9 -3
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +32 -43
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +2 -2
- package/dist/Layer.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +19 -1
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +62 -6
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/Metric.d.ts +135 -3
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +197 -25
- package/dist/Metric.js.map +1 -1
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/MutableList.d.ts +5 -2
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +7 -5
- package/dist/MutableList.js.map +1 -1
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +7 -0
- package/dist/MutableRef.js.map +1 -1
- package/dist/Number.js +2 -2
- package/dist/Number.js.map +1 -1
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js.map +1 -1
- package/dist/PartitionedSemaphore.d.ts +2 -1
- package/dist/PartitionedSemaphore.d.ts.map +1 -1
- package/dist/PartitionedSemaphore.js +22 -12
- package/dist/PartitionedSemaphore.js.map +1 -1
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +8 -1
- package/dist/Path.js.map +1 -1
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +77 -27
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +17 -13
- package/dist/PubSub.js.map +1 -1
- package/dist/Queue.d.ts +4 -1
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +4 -1
- package/dist/Queue.js.map +1 -1
- 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 +12 -7
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +9 -6
- package/dist/RcMap.js.map +1 -1
- package/dist/Record.d.ts +51 -0
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +17 -0
- package/dist/Record.js.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +8 -0
- package/dist/Ref.js.map +1 -1
- package/dist/References.d.ts +5 -4
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +5 -4
- package/dist/References.js.map +1 -1
- package/dist/RequestResolver.d.ts +31 -1
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +39 -4
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Resource.js +1 -1
- package/dist/Resource.js.map +1 -1
- package/dist/Runtime.d.ts +3 -3
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +18 -15
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +1 -1
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +408 -340
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +370 -47
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +9 -7
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +38 -25
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +8 -3
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +15 -5
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaIssue.d.ts +4 -4
- package/dist/SchemaIssue.d.ts.map +1 -1
- package/dist/SchemaIssue.js +29 -51
- package/dist/SchemaIssue.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +48 -22
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +75 -11
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +41 -13
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +5 -2
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +10 -3
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/Scope.d.ts +12 -2
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +5 -0
- package/dist/Scope.js.map +1 -1
- package/dist/ScopedCache.d.ts +10 -7
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +9 -5
- package/dist/ScopedCache.js.map +1 -1
- package/dist/SemVer.d.ts +1196 -0
- package/dist/SemVer.d.ts.map +1 -0
- package/dist/SemVer.js +756 -0
- package/dist/SemVer.js.map +1 -0
- package/dist/SemVerRange.d.ts +559 -0
- package/dist/SemVerRange.d.ts.map +1 -0
- package/dist/SemVerRange.js +551 -0
- package/dist/SemVerRange.js.map +1 -0
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +54 -35
- package/dist/Semaphore.js.map +1 -1
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +13 -4
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +235 -8
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +167 -70
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +7 -2
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +11 -6
- package/dist/String.js.map +1 -1
- package/dist/TextDiff.d.ts +399 -0
- package/dist/TextDiff.d.ts.map +1 -0
- package/dist/TextDiff.js +634 -0
- package/dist/TextDiff.js.map +1 -0
- package/dist/Tracer.d.ts +11 -1
- package/dist/Tracer.d.ts.map +1 -1
- package/dist/Tracer.js +6 -1
- package/dist/Tracer.js.map +1 -1
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js.map +1 -1
- package/dist/ai/AiError.d.ts +68 -4
- package/dist/ai/AiError.d.ts.map +1 -1
- package/dist/ai/AiError.js +50 -2
- package/dist/ai/AiError.js.map +1 -1
- package/dist/ai/Chat.d.ts +1 -2
- package/dist/ai/Chat.d.ts.map +1 -1
- package/dist/ai/Chat.js +6 -3
- package/dist/ai/Chat.js.map +1 -1
- package/dist/ai/Decision.d.ts +46 -1
- package/dist/ai/Decision.d.ts.map +1 -1
- package/dist/ai/Decision.js.map +1 -1
- package/dist/ai/DecisionModel.d.ts +129 -11
- package/dist/ai/DecisionModel.d.ts.map +1 -1
- package/dist/ai/DecisionModel.js +182 -94
- package/dist/ai/DecisionModel.js.map +1 -1
- package/dist/ai/EmbeddingModel.d.ts +10 -0
- package/dist/ai/EmbeddingModel.d.ts.map +1 -1
- package/dist/ai/EmbeddingModel.js +21 -7
- package/dist/ai/EmbeddingModel.js.map +1 -1
- package/dist/ai/LanguageModel.d.ts.map +1 -1
- package/dist/ai/LanguageModel.js +9 -0
- package/dist/ai/LanguageModel.js.map +1 -1
- package/dist/ai/McpClient.d.ts +289 -0
- package/dist/ai/McpClient.d.ts.map +1 -0
- package/dist/ai/McpClient.js +819 -0
- package/dist/ai/McpClient.js.map +1 -0
- package/dist/ai/McpClientError.d.ts +254 -0
- package/dist/ai/McpClientError.d.ts.map +1 -0
- package/dist/ai/McpClientError.js +260 -0
- package/dist/ai/McpClientError.js.map +1 -0
- package/dist/ai/McpProtocol.d.ts +2 -2
- package/dist/ai/McpProtocol.d.ts.map +1 -1
- package/dist/ai/McpSchema.d.ts +258 -125
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpSchema.js +94 -24
- package/dist/ai/McpSchema.js.map +1 -1
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +46 -37
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +74 -20
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +61 -1
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +160 -3
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +39 -37
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +36 -4
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +5 -2
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/Toolkit.d.ts +48 -1
- package/dist/ai/Toolkit.d.ts.map +1 -1
- package/dist/ai/Toolkit.js +73 -13
- package/dist/ai/Toolkit.js.map +1 -1
- package/dist/ai/index.d.ts +10 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +10 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +2 -2
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +2 -2
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +4 -7
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +16 -2
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +3 -4
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2024_11_05.js +19 -13
- package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_03_26.js +3 -2
- package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_06_18.js +7 -7
- package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2025_11_25.js +8 -8
- package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpSchema/v2026_07_28.js +43 -42
- package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
- package/dist/cli/Argument.d.ts +15 -0
- package/dist/cli/Argument.d.ts.map +1 -1
- package/dist/cli/Argument.js +5 -0
- package/dist/cli/Argument.js.map +1 -1
- package/dist/cli/CliError.d.ts +120 -2
- package/dist/cli/CliError.d.ts.map +1 -1
- package/dist/cli/CliError.js +106 -5
- package/dist/cli/CliError.js.map +1 -1
- package/dist/cli/CliOutput.d.ts +155 -6
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +62 -6
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +310 -18
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +164 -33
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Completions.d.ts +63 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js +49 -9
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +130 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +61 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/cli/GlobalFlag.js +14 -6
- package/dist/cli/GlobalFlag.js.map +1 -1
- package/dist/cli/Param.d.ts +116 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +77 -2
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/TerminalCapabilities.d.ts +85 -0
- package/dist/cli/TerminalCapabilities.d.ts.map +1 -0
- package/dist/cli/TerminalCapabilities.js +124 -0
- package/dist/cli/TerminalCapabilities.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +5 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/internal/command.d.ts +2 -1
- package/dist/cli/internal/command.d.ts.map +1 -1
- package/dist/cli/internal/command.js +5 -2
- package/dist/cli/internal/command.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +77 -30
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cli/internal/completions/descriptor.js +9 -1
- package/dist/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/cli/internal/completions/fish.js +10 -8
- package/dist/cli/internal/completions/fish.js.map +1 -1
- package/dist/cli/internal/completions/powershell.js +18 -9
- package/dist/cli/internal/completions/powershell.js.map +1 -1
- package/dist/cli/internal/completions/zsh.js +8 -5
- package/dist/cli/internal/completions/zsh.js.map +1 -1
- package/dist/cli/internal/formatter.d.ts +2 -0
- package/dist/cli/internal/formatter.d.ts.map +1 -0
- package/dist/cli/internal/formatter.js +15 -0
- package/dist/cli/internal/formatter.js.map +1 -0
- package/dist/cli/internal/lexer.js +24 -10
- package/dist/cli/internal/lexer.js.map +1 -1
- package/dist/cli/internal/parser.js +24 -12
- package/dist/cli/internal/parser.js.map +1 -1
- package/dist/cluster/ClusterCron.d.ts +29 -1
- package/dist/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/cluster/ClusterCron.js +64 -32
- package/dist/cluster/ClusterCron.js.map +1 -1
- package/dist/cluster/ClusterMetrics.d.ts +143 -7
- package/dist/cluster/ClusterMetrics.d.ts.map +1 -1
- package/dist/cluster/ClusterMetrics.js +151 -7
- package/dist/cluster/ClusterMetrics.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +82 -21
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Entity.d.ts +2 -0
- package/dist/cluster/Entity.d.ts.map +1 -1
- package/dist/cluster/Entity.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +44 -45
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +6 -7
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +54 -15
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts +1 -0
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +155 -52
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +30 -0
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js +4 -0
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/Snowflake.d.ts.map +1 -1
- package/dist/cluster/Snowflake.js +3 -7
- package/dist/cluster/Snowflake.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +40 -50
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts +2 -2
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +97 -43
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +119 -28
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/devtools/DevTools.d.ts +3 -2
- package/dist/devtools/DevTools.d.ts.map +1 -1
- package/dist/devtools/DevTools.js +3 -2
- package/dist/devtools/DevTools.js.map +1 -1
- package/dist/devtools/DevToolsClient.d.ts +11 -0
- package/dist/devtools/DevToolsClient.d.ts.map +1 -1
- package/dist/devtools/DevToolsClient.js +33 -4
- package/dist/devtools/DevToolsClient.js.map +1 -1
- package/dist/encoding/Base64.js +36 -0
- package/dist/encoding/Base64.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts +29 -0
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +29 -0
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Ini.d.ts.map +1 -1
- package/dist/encoding/Ini.js +3 -0
- package/dist/encoding/Ini.js.map +1 -1
- package/dist/encoding/JsonArray.d.ts +270 -0
- package/dist/encoding/JsonArray.d.ts.map +1 -0
- package/dist/encoding/JsonArray.js +691 -0
- package/dist/encoding/JsonArray.js.map +1 -0
- package/dist/encoding/Ndjson.d.ts +43 -4
- package/dist/encoding/Ndjson.d.ts.map +1 -1
- package/dist/encoding/Ndjson.js +169 -18
- package/dist/encoding/Ndjson.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts +9 -1
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +12 -19
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +3 -3
- package/dist/encoding/Sse.js.map +1 -1
- package/dist/encoding/Tar.d.ts +309 -0
- package/dist/encoding/Tar.d.ts.map +1 -0
- package/dist/encoding/Tar.js +1182 -0
- package/dist/encoding/Tar.js.map +1 -0
- package/dist/encoding/Toml.d.ts.map +1 -1
- package/dist/encoding/Toml.js +24 -19
- package/dist/encoding/Toml.js.map +1 -1
- package/dist/encoding/Xml.d.ts +464 -0
- package/dist/encoding/Xml.d.ts.map +1 -0
- package/dist/encoding/Xml.js +1619 -0
- package/dist/encoding/Xml.js.map +1 -0
- package/dist/encoding/Yaml.d.ts +6 -2
- package/dist/encoding/Yaml.d.ts.map +1 -1
- package/dist/encoding/Yaml.js +97 -34
- package/dist/encoding/Yaml.js.map +1 -1
- package/dist/encoding/Zip.d.ts +413 -0
- package/dist/encoding/Zip.d.ts.map +1 -0
- package/dist/encoding/Zip.js +1255 -0
- package/dist/encoding/Zip.js.map +1 -0
- package/dist/encoding/index.d.ts +20 -0
- package/dist/encoding/index.d.ts.map +1 -1
- package/dist/encoding/index.js +20 -0
- package/dist/encoding/index.js.map +1 -1
- package/dist/eventlog/EventJournal.d.ts +90 -5
- package/dist/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/eventlog/EventJournal.js +488 -228
- package/dist/eventlog/EventJournal.js.map +1 -1
- package/dist/eventlog/EventLog.d.ts +180 -12
- package/dist/eventlog/EventLog.d.ts.map +1 -1
- package/dist/eventlog/EventLog.js +394 -146
- package/dist/eventlog/EventLog.js.map +1 -1
- package/dist/eventlog/EventLogEncryption.d.ts +36 -30
- package/dist/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/eventlog/EventLogEncryption.js +97 -38
- package/dist/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/eventlog/EventLogMessage.d.ts +74 -34
- package/dist/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/eventlog/EventLogMessage.js +45 -11
- package/dist/eventlog/EventLogMessage.js.map +1 -1
- package/dist/eventlog/EventLogRemote.d.ts +45 -8
- package/dist/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/eventlog/EventLogRemote.js +51 -14
- package/dist/eventlog/EventLogRemote.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts +46 -3
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +119 -19
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.d.ts +23 -33
- package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.js +97 -70
- package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/EventLogServerUnencrypted.d.ts +39 -5
- package/dist/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerUnencrypted.js +151 -69
- package/dist/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/EventRow.d.ts +288 -0
- package/dist/eventlog/EventRow.d.ts.map +1 -0
- package/dist/eventlog/EventRow.js +435 -0
- package/dist/eventlog/EventRow.js.map +1 -0
- package/dist/eventlog/SqlEventJournal.d.ts +18 -18
- package/dist/eventlog/SqlEventJournal.d.ts.map +1 -1
- package/dist/eventlog/SqlEventJournal.js +417 -169
- package/dist/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts +10 -18
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.js +179 -69
- package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerUnencrypted.d.ts +23 -3
- package/dist/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/eventlog/SqlEventLogServerUnencrypted.js +102 -51
- package/dist/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/index.d.ts +5 -0
- package/dist/eventlog/index.d.ts.map +1 -1
- package/dist/eventlog/index.js +5 -0
- package/dist/eventlog/index.js.map +1 -1
- package/dist/eventlog/internal/conflicts.d.ts +46 -0
- package/dist/eventlog/internal/conflicts.d.ts.map +1 -0
- package/dist/eventlog/internal/conflicts.js +89 -0
- package/dist/eventlog/internal/conflicts.js.map +1 -0
- package/dist/graphql/GraphQLClientError.d.ts +2 -2
- package/dist/graphql/GraphQLClientError.d.ts.map +1 -1
- package/dist/graphql/GraphQLClientError.js +4 -18
- package/dist/graphql/GraphQLClientError.js.map +1 -1
- package/dist/graphql/GraphQLProtocol.d.ts +12 -9
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -1
- package/dist/graphql/GraphQLProtocol.js +4 -3
- package/dist/graphql/GraphQLProtocol.js.map +1 -1
- package/dist/graphql/GraphQLResolver.d.ts +2 -0
- package/dist/graphql/GraphQLResolver.d.ts.map +1 -1
- package/dist/graphql/GraphQLResolver.js +74 -32
- package/dist/graphql/GraphQLResolver.js.map +1 -1
- package/dist/http/Cookies.d.ts.map +1 -1
- package/dist/http/Cookies.js +10 -9
- package/dist/http/Cookies.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +8 -1
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +51 -4
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +10 -0
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/Headers.d.ts +227 -0
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +261 -0
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts +516 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +286 -23
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts +8 -1
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +37 -1
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +127 -3
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +45 -3
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpClientResponse.d.ts +53 -0
- package/dist/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/http/HttpClientResponse.js +47 -0
- package/dist/http/HttpClientResponse.js.map +1 -1
- package/dist/http/HttpEffect.d.ts +6 -2
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +21 -17
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/http/HttpIncomingMessage.d.ts +2 -1
- package/dist/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/http/HttpIncomingMessage.js +3 -23
- package/dist/http/HttpIncomingMessage.js.map +1 -1
- package/dist/http/HttpMiddleware.d.ts +119 -2
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +173 -29
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +9 -3
- package/dist/http/HttpRouter.js.map +1 -1
- package/dist/http/HttpServerError.d.ts +5 -2
- package/dist/http/HttpServerError.d.ts.map +1 -1
- package/dist/http/HttpServerError.js +7 -5
- package/dist/http/HttpServerError.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts +30 -5
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +109 -20
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts +17 -8
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +37 -21
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/HttpStaticServer.d.ts +0 -12
- package/dist/http/HttpStaticServer.d.ts.map +1 -1
- package/dist/http/HttpStaticServer.js +65 -24
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.d.ts +15 -1
- package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/contentType.js +89 -7
- package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
- package/dist/http/MultipartParser/internal/headers.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/headers.js +4 -12
- package/dist/http/MultipartParser/internal/headers.js.map +1 -1
- package/dist/http/MultipartParser/internal/multipart.d.ts.map +1 -1
- package/dist/http/MultipartParser/internal/multipart.js +6 -27
- package/dist/http/MultipartParser/internal/multipart.js.map +1 -1
- package/dist/http/Url.d.ts.map +1 -1
- package/dist/http/Url.js +6 -1
- package/dist/http/Url.js.map +1 -1
- package/dist/http/UrlParams.d.ts +3 -1
- package/dist/http/UrlParams.d.ts.map +1 -1
- package/dist/http/UrlParams.js +4 -2
- package/dist/http/UrlParams.js.map +1 -1
- package/dist/http/internal/compression.js +4 -5
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/decompression.js +20 -11
- package/dist/http/internal/decompression.js.map +1 -1
- package/dist/http/internal/httpBody.js +8 -1
- package/dist/http/internal/httpBody.js.map +1 -1
- package/dist/http/internal/lazyStream.d.ts +2 -0
- package/dist/http/internal/lazyStream.d.ts.map +1 -0
- package/dist/http/internal/lazyStream.js +18 -0
- package/dist/http/internal/lazyStream.js.map +1 -0
- package/dist/http/internal/requestState.d.ts +2 -0
- package/dist/http/internal/requestState.d.ts.map +1 -0
- package/dist/http/internal/requestState.js +28 -0
- package/dist/http/internal/requestState.js.map +1 -0
- package/dist/http/internal/urlParams.js +25 -0
- package/dist/http/internal/urlParams.js.map +1 -1
- package/dist/http/internal/webResponse.d.ts +2 -0
- package/dist/http/internal/webResponse.d.ts.map +1 -0
- package/dist/http/internal/webResponse.js +12 -0
- package/dist/http/internal/webResponse.js.map +1 -0
- package/dist/http-api/HttpApi.d.ts +3 -6
- package/dist/http-api/HttpApi.d.ts.map +1 -1
- package/dist/http-api/HttpApi.js +4 -7
- package/dist/http-api/HttpApi.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +142 -23
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +99 -4
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +218 -60
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts +72 -29
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +140 -14
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiError.d.ts +58 -0
- package/dist/http-api/HttpApiError.d.ts.map +1 -1
- package/dist/http-api/HttpApiError.js +38 -12
- package/dist/http-api/HttpApiError.js.map +1 -1
- package/dist/http-api/HttpApiScalar.d.ts +2 -1
- package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
- package/dist/http-api/HttpApiScalar.js +6 -3
- package/dist/http-api/HttpApiScalar.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +242 -13
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +149 -5
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/http-api/HttpApiSwagger.d.ts +5 -0
- package/dist/http-api/HttpApiSwagger.d.ts.map +1 -1
- package/dist/http-api/HttpApiSwagger.js +14 -4
- package/dist/http-api/HttpApiSwagger.js.map +1 -1
- package/dist/http-api/HttpApiTest.d.ts +13 -2
- package/dist/http-api/HttpApiTest.d.ts.map +1 -1
- package/dist/http-api/HttpApiTest.js +33 -11
- package/dist/http-api/HttpApiTest.js.map +1 -1
- package/dist/http-api/OpenApi.d.ts +17 -3
- package/dist/http-api/OpenApi.d.ts.map +1 -1
- package/dist/http-api/OpenApi.js +81 -47
- package/dist/http-api/OpenApi.js.map +1 -1
- package/dist/http-api/internal/path.js +35 -10
- package/dist/http-api/internal/path.js.map +1 -1
- package/dist/http-api/internal/toCodecHttpProperties.d.ts +2 -0
- package/dist/http-api/internal/toCodecHttpProperties.d.ts.map +1 -0
- package/dist/http-api/internal/toCodecHttpProperties.js +38 -0
- package/dist/http-api/internal/toCodecHttpProperties.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/arbitrary/runner.d.ts.map +1 -1
- package/dist/internal/arbitrary/runner.js +120 -44
- package/dist/internal/arbitrary/runner.js.map +1 -1
- package/dist/internal/core.js +3 -1
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +19 -7
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +106 -87
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/equal.js +14 -0
- package/dist/internal/equal.js.map +1 -1
- package/dist/internal/hashMap.js +2 -2
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/hydration.d.ts +2 -0
- package/dist/internal/hydration.d.ts.map +1 -0
- package/dist/internal/hydration.js +15 -0
- package/dist/internal/hydration.js.map +1 -0
- package/dist/internal/inflate.d.ts +2 -0
- package/dist/internal/inflate.d.ts.map +1 -0
- package/dist/internal/inflate.js +680 -0
- package/dist/internal/inflate.js.map +1 -0
- package/dist/internal/jsonSchema.d.ts +2 -0
- package/dist/internal/jsonSchema.d.ts.map +1 -0
- package/dist/internal/jsonSchema.js +28 -0
- package/dist/internal/jsonSchema.js.map +1 -0
- package/dist/internal/matcher.js +1 -1
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/record.js +6 -0
- package/dist/internal/record.js.map +1 -1
- package/dist/internal/request.js +20 -7
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schedule.js +17 -22
- package/dist/internal/schedule.js.map +1 -1
- package/dist/internal/schema/compilerRegistry.js +4 -1
- package/dist/internal/schema/compilerRegistry.js.map +1 -1
- package/dist/internal/schema/content.d.ts +2 -0
- package/dist/internal/schema/content.d.ts.map +1 -0
- package/dist/internal/schema/content.js +13 -0
- package/dist/internal/schema/content.js.map +1 -0
- package/dist/internal/schema/fromJsonSchemaDocument.js +253 -255
- package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/fromRepresentation.js +2 -1
- package/dist/internal/schema/fromRepresentation.js.map +1 -1
- package/dist/internal/schema/interpreter.js +51 -36
- package/dist/internal/schema/interpreter.js.map +1 -1
- package/dist/internal/schema/standardSchema.js +42 -35
- package/dist/internal/schema/standardSchema.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +10 -5
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.js +99 -17
- package/dist/internal/schema/toCodec.js.map +1 -1
- package/dist/internal/schema/toFormatter.js +5 -5
- package/dist/internal/schema/toFormatter.js.map +1 -1
- package/dist/internal/schema/toJsonSchemaDocument.js +257 -170
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- package/dist/internal/schema/toRepresentation.js +107 -129
- package/dist/internal/schema/toRepresentation.js.map +1 -1
- package/dist/internal/sql.d.ts +2 -0
- package/dist/internal/sql.d.ts.map +1 -0
- package/dist/internal/sql.js +13 -0
- package/dist/internal/sql.js.map +1 -0
- package/dist/internal/trie.js +1 -3
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/uuid.js +7 -3
- package/dist/internal/uuid.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/net/NetAddress.d.ts.map +1 -1
- package/dist/net/NetAddress.js +2 -8
- package/dist/net/NetAddress.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +5 -12
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +5 -3
- package/dist/observability/OtlpMetrics.js.map +1 -1
- package/dist/observability/OtlpProxy.d.ts +154 -0
- package/dist/observability/OtlpProxy.d.ts.map +1 -0
- package/dist/observability/OtlpProxy.js +235 -0
- package/dist/observability/OtlpProxy.js.map +1 -0
- package/dist/observability/OtlpResource.d.ts +3 -1
- package/dist/observability/OtlpResource.d.ts.map +1 -1
- package/dist/observability/OtlpResource.js +11 -4
- package/dist/observability/OtlpResource.js.map +1 -1
- package/dist/observability/OtlpSerialization.d.ts +5 -0
- package/dist/observability/OtlpSerialization.d.ts.map +1 -1
- package/dist/observability/OtlpSerialization.js +14 -3
- package/dist/observability/OtlpSerialization.js.map +1 -1
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +4 -0
- package/dist/observability/OtlpTracer.js.map +1 -1
- package/dist/observability/index.d.ts +5 -0
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +5 -0
- package/dist/observability/index.js.map +1 -1
- package/dist/observability/internal/protobuf.d.ts +0 -9
- package/dist/observability/internal/protobuf.d.ts.map +1 -1
- package/dist/observability/internal/protobuf.js +2 -10
- package/dist/observability/internal/protobuf.js.map +1 -1
- package/dist/persistence/CircuitBreaker.d.ts +897 -0
- package/dist/persistence/CircuitBreaker.d.ts.map +1 -0
- package/dist/persistence/CircuitBreaker.js +1165 -0
- package/dist/persistence/CircuitBreaker.js.map +1 -0
- package/dist/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/persistence/PersistedCache.js +1 -1
- package/dist/persistence/PersistedCache.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts +6 -2
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +162 -84
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/persistence/Persistence.d.ts +28 -0
- package/dist/persistence/Persistence.d.ts.map +1 -1
- package/dist/persistence/Persistence.js +36 -8
- package/dist/persistence/Persistence.js.map +1 -1
- package/dist/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/persistence/RateLimiter.js +8 -12
- package/dist/persistence/RateLimiter.js.map +1 -1
- package/dist/persistence/Redis.d.ts +78 -2
- package/dist/persistence/Redis.d.ts.map +1 -1
- package/dist/persistence/Redis.js +62 -7
- package/dist/persistence/Redis.js.map +1 -1
- package/dist/persistence/UserDirectories.d.ts +129 -0
- package/dist/persistence/UserDirectories.d.ts.map +1 -0
- package/dist/persistence/UserDirectories.js +178 -0
- package/dist/persistence/UserDirectories.js.map +1 -0
- package/dist/persistence/index.d.ts +10 -0
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +10 -0
- package/dist/persistence/index.js.map +1 -1
- package/dist/process/ChildProcess.d.ts +32 -5
- package/dist/process/ChildProcess.d.ts.map +1 -1
- package/dist/process/ChildProcess.js.map +1 -1
- package/dist/process/ChildProcessSpawner.d.ts +30 -0
- package/dist/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/process/ChildProcessSpawner.js +5 -2
- package/dist/process/ChildProcessSpawner.js.map +1 -1
- package/dist/reactivity/AsyncResult.d.ts +1 -1
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/AsyncResult.js +1 -1
- package/dist/reactivity/AsyncResult.js.map +1 -1
- package/dist/reactivity/Atom.d.ts +69 -30
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +40 -15
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomHttpApi.d.ts +5 -5
- package/dist/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/reactivity/AtomHttpApi.js +1 -1
- package/dist/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/reactivity/AtomRegistry.d.ts +2 -2
- package/dist/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/reactivity/AtomRegistry.js +44 -9
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/reactivity/AtomRpc.d.ts +3 -3
- package/dist/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/reactivity/AtomRpc.js +1 -1
- package/dist/reactivity/AtomRpc.js.map +1 -1
- package/dist/reactivity/Hydration.d.ts.map +1 -1
- package/dist/reactivity/Hydration.js +46 -12
- package/dist/reactivity/Hydration.js.map +1 -1
- package/dist/reactivity/Reactivity.d.ts +71 -7
- package/dist/reactivity/Reactivity.d.ts.map +1 -1
- package/dist/reactivity/Reactivity.js +21 -12
- package/dist/reactivity/Reactivity.js.map +1 -1
- package/dist/rpc/Rpc.d.ts +18 -0
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js +20 -0
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +26 -2
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +198 -61
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts +29 -0
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +41 -13
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +20 -19
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/rpc/RpcTest.d.ts +1 -0
- package/dist/rpc/RpcTest.d.ts.map +1 -1
- package/dist/rpc/RpcTest.js +1 -0
- package/dist/rpc/RpcTest.js.map +1 -1
- package/dist/schema/Model.d.ts +1 -1
- package/dist/schema/VariantSchema.d.ts +22 -3
- package/dist/schema/VariantSchema.d.ts.map +1 -1
- package/dist/schema/VariantSchema.js +32 -18
- package/dist/schema/VariantSchema.js.map +1 -1
- package/dist/socket/Socket.d.ts +23 -1
- package/dist/socket/Socket.d.ts.map +1 -1
- package/dist/socket/Socket.js +36 -3
- package/dist/socket/Socket.js.map +1 -1
- package/dist/sql/Migrator.d.ts +2 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +21 -6
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +148 -5
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +155 -27
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/SqlResolver.d.ts +13 -0
- package/dist/sql/SqlResolver.d.ts.map +1 -1
- package/dist/sql/SqlResolver.js +27 -4
- package/dist/sql/SqlResolver.js.map +1 -1
- package/dist/sql/Statement.d.ts +10 -1
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +45 -7
- package/dist/sql/Statement.js.map +1 -1
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +4 -2
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +7 -1
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +9 -3
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/workflow/DurableDeferred.js +21 -2
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +18 -4
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +13 -3
- package/src/Arbitrary.ts +10 -2
- package/src/Array.ts +128 -55
- package/src/Bytes.ts +111 -0
- package/src/Channel.ts +308 -452
- package/src/ChannelSchema.ts +1 -49
- package/src/Chunk.ts +55 -61
- package/src/Config.ts +12 -86
- package/src/ConfigProvider.ts +2 -1
- package/src/Cron.ts +6 -3
- package/src/Data.ts +60 -265
- package/src/Duration.ts +66 -16
- package/src/Effect.ts +503 -168
- package/src/Equal.ts +8 -1
- package/src/Equivalence.ts +7 -4
- package/src/Exit.ts +27 -12
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +13 -66
- package/src/FileSystem.ts +10 -0
- package/src/Formatter.ts +28 -13
- package/src/Graph.ts +171 -1263
- package/src/Hash.ts +4 -1
- package/src/HashSet.ts +0 -60
- package/src/Iterable.ts +15 -14
- package/src/JsonPatch.ts +4 -0
- package/src/JsonSchema.ts +40 -43
- package/src/Layer.ts +2 -2
- package/src/ManagedRuntime.ts +72 -6
- package/src/Metric.ts +252 -510
- package/src/MutableHashMap.ts +4 -473
- package/src/MutableList.ts +7 -5
- package/src/MutableRef.ts +8 -1
- package/src/Number.ts +2 -2
- package/src/Optic.ts +17 -332
- package/src/PartitionedSemaphore.ts +24 -13
- package/src/Path.ts +9 -1
- package/src/Pool.ts +109 -37
- package/src/PubSub.ts +17 -13
- package/src/Queue.ts +5 -37
- package/src/Random.ts +1 -1
- package/src/RcMap.ts +14 -8
- package/src/Record.ts +51 -0
- package/src/Ref.ts +15 -104
- package/src/References.ts +5 -4
- package/src/RequestResolver.ts +46 -87
- package/src/Resource.ts +1 -1
- package/src/Runtime.ts +19 -18
- package/src/Schedule.ts +3 -95
- package/src/Schema.ts +639 -381
- package/src/SchemaAST.ts +40 -29
- package/src/SchemaGetter.ts +22 -5
- package/src/SchemaIssue.ts +44 -53
- package/src/SchemaParser.ts +51 -18
- package/src/SchemaRepresentation.ts +95 -35
- package/src/SchemaTransformation.ts +10 -3
- package/src/Scope.ts +12 -2
- package/src/ScopedCache.ts +17 -142
- package/src/SemVer.ts +1528 -0
- package/src/SemVerRange.ts +883 -0
- package/src/Semaphore.ts +67 -40
- package/src/Sink.ts +21 -4
- package/src/Stream.ts +367 -1027
- package/src/String.ts +11 -8
- package/src/TextDiff.ts +766 -0
- package/src/Tracer.ts +15 -1
- package/src/TxHashMap.ts +1 -103
- package/src/TxHashSet.ts +48 -753
- package/src/ai/AiError.ts +66 -4
- package/src/ai/Chat.ts +10 -5
- package/src/ai/Decision.ts +49 -1
- package/src/ai/DecisionModel.ts +264 -108
- package/src/ai/EmbeddingModel.ts +25 -13
- package/src/ai/LanguageModel.ts +9 -0
- package/src/ai/McpClient.ts +1211 -0
- package/src/ai/McpClientError.ts +329 -0
- package/src/ai/McpProtocol.ts +2 -2
- package/src/ai/McpSchema.ts +153 -35
- package/src/ai/McpServer.ts +231 -233
- package/src/ai/Prompt.ts +114 -35
- package/src/ai/Response.ts +220 -65
- package/src/ai/Tool.ts +50 -6
- package/src/ai/Toolkit.ts +82 -11
- package/src/ai/index.ts +12 -0
- package/src/ai/internal/mcpCore.ts +13 -14
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +1 -1
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +1 -1
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -3
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -3
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +12 -14
- package/src/ai/internal/mcpProtocol.ts +22 -2
- package/src/ai/internal/mcpRuntime.ts +3 -4
- package/src/ai/internal/mcpSchema/v2024_11_05.ts +20 -13
- package/src/ai/internal/mcpSchema/v2025_03_26.ts +4 -2
- package/src/ai/internal/mcpSchema/v2025_06_18.ts +7 -7
- package/src/ai/internal/mcpSchema/v2025_11_25.ts +8 -8
- package/src/ai/internal/mcpSchema/v2026_07_28.ts +44 -42
- package/src/cli/Argument.ts +15 -0
- package/src/cli/CliError.ts +136 -4
- package/src/cli/CliOutput.ts +183 -6
- package/src/cli/Command.ts +367 -48
- package/src/cli/Completions.ts +56 -0
- package/src/cli/Flag.ts +132 -0
- package/src/cli/GlobalFlag.ts +5 -6
- package/src/cli/Param.ts +151 -6
- package/src/cli/TerminalCapabilities.ts +159 -0
- package/src/cli/index.ts +6 -0
- package/src/cli/internal/command.ts +8 -3
- package/src/cli/internal/completions/bash.ts +83 -32
- package/src/cli/internal/completions/descriptor.ts +11 -1
- package/src/cli/internal/completions/fish.ts +10 -8
- package/src/cli/internal/completions/powershell.ts +23 -14
- package/src/cli/internal/completions/zsh.ts +8 -5
- package/src/cli/internal/formatter.ts +18 -0
- package/src/cli/internal/lexer.ts +12 -5
- package/src/cli/internal/parser.ts +31 -11
- package/src/cluster/ClusterCron.ts +94 -35
- package/src/cluster/ClusterMetrics.ts +149 -7
- package/src/cluster/ClusterWorkflowEngine.ts +130 -57
- package/src/cluster/Entity.ts +4 -0
- package/src/cluster/MessageStorage.ts +26 -14
- package/src/cluster/Runners.ts +76 -25
- package/src/cluster/Sharding.ts +200 -58
- package/src/cluster/ShardingConfig.ts +20 -0
- package/src/cluster/Snowflake.ts +3 -7
- package/src/cluster/SqlMessageStorage.ts +58 -55
- package/src/cluster/SqlRunnerStorage.ts +120 -51
- package/src/cluster/internal/entityManager.ts +155 -32
- package/src/devtools/DevTools.ts +3 -2
- package/src/devtools/DevToolsClient.ts +29 -10
- package/src/encoding/Base64.ts +38 -0
- package/src/encoding/Base64Url.ts +31 -0
- package/src/encoding/Ini.ts +3 -0
- package/src/encoding/JsonArray.ts +849 -0
- package/src/encoding/Ndjson.ts +211 -20
- package/src/encoding/SchemaBinary.ts +14 -48
- package/src/encoding/Sse.ts +4 -3
- package/src/encoding/Tar.ts +1417 -0
- package/src/encoding/Toml.ts +36 -19
- package/src/encoding/Xml.ts +2037 -0
- package/src/encoding/Yaml.ts +108 -36
- package/src/encoding/Zip.ts +1558 -0
- package/src/encoding/index.ts +24 -0
- package/src/eventlog/EventJournal.ts +611 -227
- package/src/eventlog/EventLog.ts +496 -196
- package/src/eventlog/EventLogEncryption.ts +128 -43
- package/src/eventlog/EventLogMessage.ts +62 -11
- package/src/eventlog/EventLogRemote.ts +77 -21
- package/src/eventlog/EventLogServer.ts +162 -20
- package/src/eventlog/EventLogServerEncrypted.ts +121 -80
- package/src/eventlog/EventLogServerUnencrypted.ts +180 -77
- package/src/eventlog/EventRow.ts +706 -0
- package/src/eventlog/SqlEventJournal.ts +496 -193
- package/src/eventlog/SqlEventLogServerEncrypted.ts +212 -83
- package/src/eventlog/SqlEventLogServerUnencrypted.ts +141 -62
- package/src/eventlog/index.ts +6 -0
- package/src/eventlog/internal/conflicts.ts +119 -0
- package/src/graphql/GraphQLClientError.ts +5 -12
- package/src/graphql/GraphQLProtocol.ts +12 -9
- package/src/graphql/GraphQLResolver.ts +90 -239
- package/src/http/Cookies.ts +10 -11
- package/src/http/FetchHttpClient.ts +56 -6
- package/src/http/FindMyWay/internal/router.ts +11 -0
- package/src/http/Headers.ts +337 -154
- package/src/http/HttpClient.ts +673 -142
- package/src/http/HttpClientError.ts +35 -1
- package/src/http/HttpClientRequest.ts +151 -5
- package/src/http/HttpClientResponse.ts +71 -0
- package/src/http/HttpEffect.ts +25 -33
- package/src/http/HttpIncomingMessage.ts +3 -23
- package/src/http/HttpMiddleware.ts +194 -40
- package/src/http/HttpRouter.ts +10 -3
- package/src/http/HttpServerError.ts +8 -5
- package/src/http/HttpServerRequest.ts +172 -27
- package/src/http/HttpServerResponse.ts +49 -23
- package/src/http/HttpStaticServer.ts +71 -26
- package/src/http/MultipartParser/internal/contentType.ts +109 -8
- package/src/http/MultipartParser/internal/headers.ts +4 -16
- package/src/http/MultipartParser/internal/multipart.ts +10 -32
- package/src/http/Url.ts +6 -1
- package/src/http/UrlParams.ts +6 -1
- package/src/http/internal/compression.ts +4 -5
- package/src/http/internal/decompression.ts +32 -17
- package/src/http/internal/httpBody.ts +10 -2
- package/src/http/internal/lazyStream.ts +25 -0
- package/src/http/internal/requestState.ts +33 -0
- package/src/http/internal/urlParams.ts +29 -0
- package/src/http/internal/webResponse.ts +20 -0
- package/src/http-api/HttpApi.ts +4 -7
- package/src/http-api/HttpApiBuilder.ts +190 -32
- package/src/http-api/HttpApiClient.ts +364 -90
- package/src/http-api/HttpApiEndpoint.ts +248 -46
- package/src/http-api/HttpApiError.ts +55 -0
- package/src/http-api/HttpApiScalar.ts +4 -3
- package/src/http-api/HttpApiSchema.ts +373 -18
- package/src/http-api/HttpApiSwagger.ts +11 -4
- package/src/http-api/HttpApiTest.ts +36 -11
- package/src/http-api/OpenApi.ts +103 -58
- package/src/http-api/internal/path.ts +40 -12
- package/src/http-api/internal/toCodecHttpProperties.ts +56 -0
- package/src/index.ts +24 -0
- package/src/internal/arbitrary/runner.ts +133 -36
- package/src/internal/core.ts +3 -1
- package/src/internal/dateTime.ts +20 -7
- package/src/internal/effect.ts +144 -100
- package/src/internal/equal.ts +17 -0
- package/src/internal/hashMap.ts +2 -2
- package/src/internal/hydration.ts +15 -0
- package/src/internal/inflate.ts +710 -0
- package/src/internal/jsonSchema.ts +27 -0
- package/src/internal/matcher.ts +1 -1
- package/src/internal/record.ts +6 -0
- package/src/internal/request.ts +21 -6
- package/src/internal/schedule.ts +20 -39
- package/src/internal/schema/compilerRegistry.ts +6 -1
- package/src/internal/schema/content.ts +18 -0
- package/src/internal/schema/fromJsonSchemaDocument.ts +458 -351
- package/src/internal/schema/fromRepresentation.ts +2 -1
- package/src/internal/schema/interpreter.ts +58 -45
- package/src/internal/schema/standardSchema.ts +34 -32
- package/src/internal/schema/toCodeDocument.ts +12 -7
- package/src/internal/schema/toCodec.ts +134 -15
- package/src/internal/schema/toFormatter.ts +6 -6
- package/src/internal/schema/toJsonSchemaDocument.ts +246 -194
- package/src/internal/schema/toRepresentation.ts +122 -140
- package/src/internal/sql.ts +14 -0
- package/src/internal/trie.ts +1 -3
- package/src/internal/uuid.ts +15 -10
- package/src/internal/version.ts +1 -1
- package/src/net/NetAddress.ts +2 -9
- package/src/observability/OtlpExporter.ts +5 -12
- package/src/observability/OtlpMetrics.ts +5 -3
- package/src/observability/OtlpProxy.ts +314 -0
- package/src/observability/OtlpResource.ts +16 -6
- package/src/observability/OtlpSerialization.ts +17 -3
- package/src/observability/OtlpTracer.ts +4 -0
- package/src/observability/index.ts +6 -0
- package/src/observability/internal/protobuf.ts +2 -10
- package/src/persistence/CircuitBreaker.ts +1678 -0
- package/src/persistence/PersistedCache.ts +3 -1
- package/src/persistence/PersistedQueue.ts +223 -153
- package/src/persistence/Persistence.ts +64 -30
- package/src/persistence/RateLimiter.ts +18 -21
- package/src/persistence/Redis.ts +129 -8
- package/src/persistence/UserDirectories.ts +273 -0
- package/src/persistence/index.ts +12 -0
- package/src/process/ChildProcess.ts +32 -5
- package/src/process/ChildProcessSpawner.ts +41 -2
- package/src/reactivity/AsyncResult.ts +5 -39
- package/src/reactivity/Atom.ts +134 -166
- package/src/reactivity/AtomHttpApi.ts +10 -16
- package/src/reactivity/AtomRegistry.ts +50 -29
- package/src/reactivity/AtomRpc.ts +6 -22
- package/src/reactivity/Hydration.ts +53 -12
- package/src/reactivity/Reactivity.ts +97 -39
- package/src/rpc/Rpc.ts +21 -0
- package/src/rpc/RpcClient.ts +283 -104
- package/src/rpc/RpcSerialization.ts +53 -14
- package/src/rpc/RpcServer.ts +27 -21
- package/src/rpc/RpcTest.ts +3 -0
- package/src/schema/VariantSchema.ts +86 -22
- package/src/socket/Socket.ts +45 -20
- package/src/sql/Migrator.ts +26 -11
- package/src/sql/SqlClient.ts +273 -29
- package/src/sql/SqlResolver.ts +32 -9
- package/src/sql/Statement.ts +65 -10
- package/src/testing/TestClock.ts +4 -1
- package/src/testing/TestSchema.ts +9 -3
- package/src/workflow/DurableDeferred.ts +23 -6
- package/src/workflow/WorkflowEngine.ts +34 -10
- package/dist/http/internal/preResponseHandler.d.ts +0 -2
- package/dist/http/internal/preResponseHandler.d.ts.map +0 -1
- package/dist/http/internal/preResponseHandler.js +0 -14
- package/dist/http/internal/preResponseHandler.js.map +0 -1
- package/src/http/internal/preResponseHandler.ts +0 -19
|
@@ -0,0 +1,1182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes and decodes tar archives as streams in Effect channels.
|
|
3
|
+
*
|
|
4
|
+
* `decode` streams entry bodies from the archive input; `encode` streams them
|
|
5
|
+
* back into archive bytes. Neither buffers an entire entry body.
|
|
6
|
+
*
|
|
7
|
+
* The decoder reads the formats produced by common tools: v7, USTAR, PAX
|
|
8
|
+
* extended headers, and GNU long names and base-256 numbers. The encoder writes
|
|
9
|
+
* USTAR, adding PAX extended headers for fields that do not fit or for custom
|
|
10
|
+
* metadata. It does not access the file system or compress archives.
|
|
11
|
+
*
|
|
12
|
+
* @stability unstable
|
|
13
|
+
* @since 4.0.5
|
|
14
|
+
*/
|
|
15
|
+
import * as Arr from "../Array.js";
|
|
16
|
+
import * as Cause from "../Cause.js";
|
|
17
|
+
import * as Channel from "../Channel.js";
|
|
18
|
+
import * as Data from "../Data.js";
|
|
19
|
+
import * as Effect from "../Effect.js";
|
|
20
|
+
import * as Exit from "../Exit.js";
|
|
21
|
+
import * as Predicate from "../Predicate.js";
|
|
22
|
+
import * as Pull from "../Pull.js";
|
|
23
|
+
import * as Scope from "../Scope.js";
|
|
24
|
+
import * as Semaphore from "../Semaphore.js";
|
|
25
|
+
import * as Stream from "../Stream.js";
|
|
26
|
+
const TarErrorTypeId = "~effect/encoding/Tar/TarError";
|
|
27
|
+
/**
|
|
28
|
+
* Error raised when a tar archive cannot be encoded or decoded.
|
|
29
|
+
*
|
|
30
|
+
* **Details**
|
|
31
|
+
*
|
|
32
|
+
* The `kind` field identifies the failure:
|
|
33
|
+
*
|
|
34
|
+
* - `InvalidHeader`: a header has a bad checksum, a malformed field, or a value
|
|
35
|
+
* that cannot be written.
|
|
36
|
+
* - `Truncated`: the input ended inside a header or an entry body.
|
|
37
|
+
* - `SizeMismatch`: an entry body produced a byte count other than its declared
|
|
38
|
+
* `size`.
|
|
39
|
+
* - `Unsupported`: the archive uses a feature this module does not read, such
|
|
40
|
+
* as GNU sparse files.
|
|
41
|
+
* - `BodyConsumed`: an entry body was read after the decoder had moved past it.
|
|
42
|
+
*
|
|
43
|
+
* @stability unstable
|
|
44
|
+
* @category errors
|
|
45
|
+
* @since 4.0.5
|
|
46
|
+
*/
|
|
47
|
+
export class TarError extends /*#__PURE__*/Data.TaggedError("TarError") {
|
|
48
|
+
/**
|
|
49
|
+
* Marks this value as a tar error for runtime guards.
|
|
50
|
+
*
|
|
51
|
+
* @stability unstable
|
|
52
|
+
* @since 4.0.5
|
|
53
|
+
*/
|
|
54
|
+
[TarErrorTypeId] = TarErrorTypeId;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks whether a value is a `TarError`.
|
|
58
|
+
*
|
|
59
|
+
* @stability unstable
|
|
60
|
+
* @category guards
|
|
61
|
+
* @since 4.0.5
|
|
62
|
+
*/
|
|
63
|
+
export const isTarError = u => Predicate.hasProperty(u, TarErrorTypeId);
|
|
64
|
+
const makeHeader = (path, type, size, options, linkTarget) => ({
|
|
65
|
+
path,
|
|
66
|
+
type,
|
|
67
|
+
typeflag: typeflags[type],
|
|
68
|
+
size,
|
|
69
|
+
mode: options?.mode ?? (type === "Directory" ? 0o755 : type === "Symlink" ? 0o777 : 0o644),
|
|
70
|
+
uid: options?.uid ?? 0,
|
|
71
|
+
gid: options?.gid ?? 0,
|
|
72
|
+
uname: options?.uname ?? "",
|
|
73
|
+
gname: options?.gname ?? "",
|
|
74
|
+
mtime: options?.mtime ?? new Date(0),
|
|
75
|
+
...(linkTarget === undefined || linkTarget === "" ? undefined : {
|
|
76
|
+
linkTarget
|
|
77
|
+
}),
|
|
78
|
+
pax: options?.pax ?? {}
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* Creates a regular file entry from in-memory content.
|
|
82
|
+
*
|
|
83
|
+
* **Details**
|
|
84
|
+
*
|
|
85
|
+
* String content is encoded as UTF-8, and `size` is the byte length of the
|
|
86
|
+
* content.
|
|
87
|
+
*
|
|
88
|
+
* @see {@link fileStream} for content that is streamed instead of held in memory
|
|
89
|
+
* @see {@link encode} for writing entries to an archive
|
|
90
|
+
*
|
|
91
|
+
* @stability unstable
|
|
92
|
+
* @category constructors
|
|
93
|
+
* @since 4.0.5
|
|
94
|
+
*/
|
|
95
|
+
export const file = (path, content, options) => {
|
|
96
|
+
const bytes = typeof content === "string" ? textEncoder.encode(content) : content;
|
|
97
|
+
const header = makeHeader(path, "File", bytes.length, options);
|
|
98
|
+
if (bytes.length === 0) return {
|
|
99
|
+
header,
|
|
100
|
+
body: Stream.empty
|
|
101
|
+
};
|
|
102
|
+
const body = Stream.succeed(bytes);
|
|
103
|
+
inMemoryBodies.set(body, bytes);
|
|
104
|
+
return {
|
|
105
|
+
header,
|
|
106
|
+
body
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
// Key by body identity so replacing an entry body bypasses the encode fast path.
|
|
110
|
+
const inMemoryBodies = /*#__PURE__*/new WeakMap();
|
|
111
|
+
/**
|
|
112
|
+
* Creates a regular file entry whose content is streamed from `body`.
|
|
113
|
+
*
|
|
114
|
+
* **When to use**
|
|
115
|
+
*
|
|
116
|
+
* Use when the content is too large to hold in memory, or is read from a file
|
|
117
|
+
* or another stream, and its byte length is known up front.
|
|
118
|
+
*
|
|
119
|
+
* **Details**
|
|
120
|
+
*
|
|
121
|
+
* The defaults match `file`: mode `0o644`, uid and gid `0`, and an mtime at the
|
|
122
|
+
* Unix epoch. `body` is not run until the entry is encoded.
|
|
123
|
+
*
|
|
124
|
+
* **Gotchas**
|
|
125
|
+
*
|
|
126
|
+
* `size` must be the exact byte length of `body`: `encode` fails with a
|
|
127
|
+
* `SizeMismatch` `TarError` when the body produces fewer or more bytes.
|
|
128
|
+
*
|
|
129
|
+
* @see {@link file} for in-memory content
|
|
130
|
+
* @see {@link encode} for writing entries to an archive
|
|
131
|
+
*
|
|
132
|
+
* @stability unstable
|
|
133
|
+
* @category constructors
|
|
134
|
+
* @since 4.0.5
|
|
135
|
+
*/
|
|
136
|
+
export const fileStream = (path, size, body, options) => ({
|
|
137
|
+
header: makeHeader(path, "File", size, options),
|
|
138
|
+
body
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* Creates a directory entry.
|
|
142
|
+
*
|
|
143
|
+
* **Details**
|
|
144
|
+
*
|
|
145
|
+
* A trailing `/` is added to a non-empty `path` when missing, as tar tools
|
|
146
|
+
* expect for directories.
|
|
147
|
+
*
|
|
148
|
+
* @stability unstable
|
|
149
|
+
* @category constructors
|
|
150
|
+
* @since 4.0.5
|
|
151
|
+
*/
|
|
152
|
+
export const directory = (path, options) => ({
|
|
153
|
+
// An empty path stays empty, so that `encode` rejects it
|
|
154
|
+
header: makeHeader(path === "" || path.endsWith("/") ? path : `${path}/`, "Directory", 0, options),
|
|
155
|
+
body: Stream.empty
|
|
156
|
+
});
|
|
157
|
+
/**
|
|
158
|
+
* Creates a symbolic link entry pointing at `target`.
|
|
159
|
+
*
|
|
160
|
+
* @stability unstable
|
|
161
|
+
* @category constructors
|
|
162
|
+
* @since 4.0.5
|
|
163
|
+
*/
|
|
164
|
+
export const symlink = (path, target, options) => ({
|
|
165
|
+
header: makeHeader(path, "Symlink", 0, options, target),
|
|
166
|
+
body: Stream.empty
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* Creates a hard link entry pointing at another entry of the archive.
|
|
170
|
+
*
|
|
171
|
+
* **Details**
|
|
172
|
+
*
|
|
173
|
+
* `target` is the archive path of an entry written earlier in the same
|
|
174
|
+
* archive.
|
|
175
|
+
*
|
|
176
|
+
* @stability unstable
|
|
177
|
+
* @category constructors
|
|
178
|
+
* @since 4.0.5
|
|
179
|
+
*/
|
|
180
|
+
export const hardlink = (path, target, options) => ({
|
|
181
|
+
header: makeHeader(path, "Hardlink", 0, options, target),
|
|
182
|
+
body: Stream.empty
|
|
183
|
+
});
|
|
184
|
+
/**
|
|
185
|
+
* Creates a channel that decodes tar archive bytes into entries.
|
|
186
|
+
*
|
|
187
|
+
* **Details**
|
|
188
|
+
*
|
|
189
|
+
* Each output chunk holds one entry, and each entry body streams exactly
|
|
190
|
+
* `header.size` bytes straight from the input. Pulling the next entry skips
|
|
191
|
+
* whatever is left of the current body, like Go's `tar.Reader`. The decoder
|
|
192
|
+
* reads v7, USTAR, PAX extended headers (applying `path`, `linkpath`, `size`,
|
|
193
|
+
* `uid`, `gid`, `uname`, `gname` and `mtime`), GNU long names and links, and
|
|
194
|
+
* base-256 numbers. The records of a PAX global header apply to every entry
|
|
195
|
+
* that follows, except `path`, `linkpath` and `size`, which describe a single
|
|
196
|
+
* entry. Anything after the end-of-archive marker is ignored.
|
|
197
|
+
*
|
|
198
|
+
* **Gotchas**
|
|
199
|
+
*
|
|
200
|
+
* - Read each body before pulling the next entry: a body read afterwards fails
|
|
201
|
+
* with a `BodyConsumed` `TarError`. Operators that pull ahead, such as
|
|
202
|
+
* `Stream.buffer`, therefore can't sit between `decode` and the body reads.
|
|
203
|
+
* - Read bodies while the entry stream runs, for example in `Stream.mapEffect`:
|
|
204
|
+
* once it has ended, as after `Stream.runCollect`, `Stream.runHead` or
|
|
205
|
+
* `Stream.take`, every body fails with a `BodyConsumed` `TarError`.
|
|
206
|
+
* - A body reads the entry's bytes once: running it again continues where the
|
|
207
|
+
* previous run stopped.
|
|
208
|
+
* - Directories, links, devices and FIFOs have no body, and their `size` is
|
|
209
|
+
* reported as `0`.
|
|
210
|
+
* - Paths and link targets are returned as written in the archive, so they can
|
|
211
|
+
* be absolute or contain `..`, and a symlink entry can redirect a later entry
|
|
212
|
+
* outside the target directory. Validate both before writing entries to disk.
|
|
213
|
+
* - Names that are not valid UTF-8 are decoded with replacement characters.
|
|
214
|
+
* - PAX extended headers and GNU long names of more than 1 MiB fail with an
|
|
215
|
+
* `InvalidHeader` `TarError`.
|
|
216
|
+
* - The channel completes only when its input ends: input after the
|
|
217
|
+
* end-of-archive marker is read and discarded, so that the upstream done
|
|
218
|
+
* value can be passed on.
|
|
219
|
+
* - GNU sparse entries fail with an `Unsupported` `TarError`.
|
|
220
|
+
*
|
|
221
|
+
* @see {@link encode} for the inverse operation
|
|
222
|
+
*
|
|
223
|
+
* @stability unstable
|
|
224
|
+
* @category decoding
|
|
225
|
+
* @since 4.0.5
|
|
226
|
+
*/
|
|
227
|
+
export const decode = () => Channel.fromTransform((upstream, scope) => Effect.suspend(() => {
|
|
228
|
+
const decoder = new Decoder();
|
|
229
|
+
let done;
|
|
230
|
+
let pulls = 0;
|
|
231
|
+
const pullUpstream = upstream.pipe(Effect.map(chunks => {
|
|
232
|
+
pulls++;
|
|
233
|
+
for (const chunk of chunks) decoder.push(chunk);
|
|
234
|
+
}), Pull.catchDone(value => {
|
|
235
|
+
pulls++;
|
|
236
|
+
done = {
|
|
237
|
+
value: value
|
|
238
|
+
};
|
|
239
|
+
decoder.end();
|
|
240
|
+
return Effect.void;
|
|
241
|
+
}));
|
|
242
|
+
// Serialize entry and body pulls; reuse input pulled while waiting for the lock.
|
|
243
|
+
const lock = Semaphore.makeUnsafe(1);
|
|
244
|
+
const pullInput = seen => lock.withPermit(Effect.suspend(() => pulls === seen ? pullUpstream : Effect.void));
|
|
245
|
+
const run = (f, end) => Effect.suspend(function loop() {
|
|
246
|
+
const seen = pulls;
|
|
247
|
+
let result;
|
|
248
|
+
try {
|
|
249
|
+
result = f();
|
|
250
|
+
} catch (error) {
|
|
251
|
+
return isTarError(error) ? Effect.fail(error) : Effect.die(error);
|
|
252
|
+
}
|
|
253
|
+
if (result === NeedInput) return Effect.flatMap(pullInput(seen), loop);
|
|
254
|
+
return result === undefined ? Cause.done(end()) : Effect.succeed(result);
|
|
255
|
+
});
|
|
256
|
+
const body = id => Stream.fromPull(Effect.succeed(run(() => decoder.read(id), () => undefined)));
|
|
257
|
+
const next = run(() => {
|
|
258
|
+
const header = decoder.next();
|
|
259
|
+
return header === NeedInput || header === undefined ? header : Arr.of({
|
|
260
|
+
header,
|
|
261
|
+
body: body(decoder.generation)
|
|
262
|
+
});
|
|
263
|
+
}, () => done.value);
|
|
264
|
+
return Effect.as(Scope.addFinalizer(scope, Effect.sync(() => decoder.close())), next);
|
|
265
|
+
}));
|
|
266
|
+
/**
|
|
267
|
+
* Creates a channel that encodes entries into tar archive bytes.
|
|
268
|
+
*
|
|
269
|
+
* **Details**
|
|
270
|
+
*
|
|
271
|
+
* Each entry is written as a USTAR header, with the path split into the USTAR
|
|
272
|
+
* prefix and name fields when it is longer than 100 bytes. A PAX extended
|
|
273
|
+
* header is added only for what USTAR cannot hold: a long or non-ASCII path,
|
|
274
|
+
* link target, user or group name, a size of 8 GiB or more, a uid or gid above
|
|
275
|
+
* `2097151`, an mtime outside the USTAR range, or custom `pax` records. The
|
|
276
|
+
* archive ends with two zero blocks.
|
|
277
|
+
*
|
|
278
|
+
* Headers, padding and body chunks below 16 KiB are gathered into output chunks
|
|
279
|
+
* of up to 64 KiB, and larger body chunks pass through without copying, so
|
|
280
|
+
* bodies stream without being held in memory. Output is handed out before
|
|
281
|
+
* waiting for more entries, but up to 64 KiB of it can be held while a body is
|
|
282
|
+
* pulled.
|
|
283
|
+
*
|
|
284
|
+
* **Gotchas**
|
|
285
|
+
*
|
|
286
|
+
* - A body that produces any byte count other than `header.size` fails with a
|
|
287
|
+
* `SizeMismatch` `TarError`, so the size must be known before the body is
|
|
288
|
+
* written.
|
|
289
|
+
* - `header.pax` may contain custom metadata such as `SCHILY.xattr.*`. Keys
|
|
290
|
+
* `path`, `linkpath`, `size`, `uid`, `gid`, `uname`, `gname` and `mtime` must
|
|
291
|
+
* be set through the corresponding header fields. These keys and
|
|
292
|
+
* `GNU.sparse.*` records fail with an `InvalidHeader` `TarError`.
|
|
293
|
+
* - A `File` entry whose path ends with `/` fails with an `InvalidHeader`
|
|
294
|
+
* `TarError`, because other tools read it as a directory.
|
|
295
|
+
* - Entries other than `File` and `Other` must have `size` 0, and `devMajor`
|
|
296
|
+
* and `devMinor` must not exceed `2097151`; otherwise encoding fails with an
|
|
297
|
+
* `InvalidHeader` `TarError`.
|
|
298
|
+
* - mtime is rounded down to whole seconds.
|
|
299
|
+
* - `typeflag` is only written for `Other` entries; every other type writes its
|
|
300
|
+
* standard flag.
|
|
301
|
+
*
|
|
302
|
+
* @see {@link decode} for the inverse operation
|
|
303
|
+
* @see {@link file} for building entries from in-memory content
|
|
304
|
+
* @see {@link fileStream} for building entries from streamed content
|
|
305
|
+
*
|
|
306
|
+
* @stability unstable
|
|
307
|
+
* @category encoding
|
|
308
|
+
* @since 4.0.5
|
|
309
|
+
*/
|
|
310
|
+
export const encode = () => {
|
|
311
|
+
return Channel.fromTransform((upstream, scope) => Effect.sync(() => {
|
|
312
|
+
const encoder = new Encoder();
|
|
313
|
+
let entries = [];
|
|
314
|
+
let index = 0;
|
|
315
|
+
let done;
|
|
316
|
+
let body;
|
|
317
|
+
let bodyScope;
|
|
318
|
+
const write = f => {
|
|
319
|
+
try {
|
|
320
|
+
f();
|
|
321
|
+
} catch (error) {
|
|
322
|
+
return isTarError(error) ? Effect.fail(error) : Effect.die(error);
|
|
323
|
+
}
|
|
324
|
+
return Effect.void;
|
|
325
|
+
};
|
|
326
|
+
return Effect.gen(function* () {
|
|
327
|
+
while (true) {
|
|
328
|
+
if (encoder.buffered >= SLAB_SIZE) return encoder.flush();
|
|
329
|
+
if (body !== undefined) {
|
|
330
|
+
const chunks = yield* Pull.catchDone(body, () => Effect.undefined);
|
|
331
|
+
if (chunks !== undefined) {
|
|
332
|
+
yield* write(() => {
|
|
333
|
+
for (const chunk of chunks) encoder.body(chunk);
|
|
334
|
+
});
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
body = undefined;
|
|
338
|
+
yield* Scope.close(bodyScope, Exit.void);
|
|
339
|
+
yield* write(() => encoder.end());
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (index < entries.length) {
|
|
343
|
+
const entry = entries[index++];
|
|
344
|
+
// Directories, links and in-memory files have nothing to stream
|
|
345
|
+
const bytes = entry.body === Stream.empty ? emptyBody : inMemoryBodies.get(entry.body);
|
|
346
|
+
yield* write(() => {
|
|
347
|
+
encoder.begin(entry.header);
|
|
348
|
+
if (bytes !== undefined) {
|
|
349
|
+
encoder.body(bytes);
|
|
350
|
+
encoder.end();
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
if (bytes !== undefined) continue;
|
|
354
|
+
bodyScope = Scope.forkUnsafe(scope);
|
|
355
|
+
body = yield* Channel.toPullScoped(entry.body.channel, bodyScope);
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (encoder.buffered > 0) return encoder.flush();
|
|
359
|
+
if (done !== undefined) return yield* Cause.done(done.value);
|
|
360
|
+
const next = yield* Pull.catchDone(upstream, value => {
|
|
361
|
+
done = {
|
|
362
|
+
value: value
|
|
363
|
+
};
|
|
364
|
+
encoder.finish();
|
|
365
|
+
return Effect.undefined;
|
|
366
|
+
});
|
|
367
|
+
if (next !== undefined) {
|
|
368
|
+
entries = next;
|
|
369
|
+
index = 0;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}));
|
|
374
|
+
};
|
|
375
|
+
const invalidHeader = message => new TarError({
|
|
376
|
+
kind: "InvalidHeader",
|
|
377
|
+
message
|
|
378
|
+
});
|
|
379
|
+
const truncated = at => new TarError({
|
|
380
|
+
kind: "Truncated",
|
|
381
|
+
message: `unexpected end of tar archive at byte ${at}`
|
|
382
|
+
});
|
|
383
|
+
const unsupported = message => new TarError({
|
|
384
|
+
kind: "Unsupported",
|
|
385
|
+
message
|
|
386
|
+
});
|
|
387
|
+
const sizeMismatch = (header, written) => new TarError({
|
|
388
|
+
kind: "SizeMismatch",
|
|
389
|
+
message: `body of ${JSON.stringify(header.path)} has ${written > header.size ? "at least" : "only"} ${written} bytes, but its size is ${header.size}`
|
|
390
|
+
});
|
|
391
|
+
const BLOCK = 512;
|
|
392
|
+
const PERMISSION_BITS = 0o7777;
|
|
393
|
+
const padding = size => (BLOCK - size % BLOCK) % BLOCK;
|
|
394
|
+
const isZeroBlock = block => {
|
|
395
|
+
for (let i = 0; i < BLOCK; i++) {
|
|
396
|
+
if (block[i] !== 0) return false;
|
|
397
|
+
}
|
|
398
|
+
return true;
|
|
399
|
+
};
|
|
400
|
+
const sumBlock = block => {
|
|
401
|
+
// Four sums let the loop run faster than one
|
|
402
|
+
let a = 0;
|
|
403
|
+
let b = 0;
|
|
404
|
+
let c = 0;
|
|
405
|
+
let d = 0;
|
|
406
|
+
for (let i = 0; i < BLOCK; i += 4) {
|
|
407
|
+
a += block[i];
|
|
408
|
+
b += block[i + 1];
|
|
409
|
+
c += block[i + 2];
|
|
410
|
+
d += block[i + 3];
|
|
411
|
+
}
|
|
412
|
+
return a + b + c + d;
|
|
413
|
+
};
|
|
414
|
+
const USTAR_MAGIC = [0x75, 0x73, 0x74, 0x61, 0x72, 0x00]; // "ustar\0"
|
|
415
|
+
const GNU_MAGIC = [0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00]; // "ustar \0"
|
|
416
|
+
const STAR_TRAILER = [0x74, 0x61, 0x72, 0x00]; // "tar\0"
|
|
417
|
+
const USTAR_MAGIC_VERSION = /*#__PURE__*/new Uint8Array([0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30]); // "ustar\0" "00"
|
|
418
|
+
const hasBytes = (block, offset, bytes) => {
|
|
419
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
420
|
+
if (block[offset + i] !== bytes[i]) return false;
|
|
421
|
+
}
|
|
422
|
+
return true;
|
|
423
|
+
};
|
|
424
|
+
const typeflags = {
|
|
425
|
+
File: "0",
|
|
426
|
+
Hardlink: "1",
|
|
427
|
+
Symlink: "2",
|
|
428
|
+
CharDevice: "3",
|
|
429
|
+
BlockDevice: "4",
|
|
430
|
+
Directory: "5",
|
|
431
|
+
Fifo: "6"
|
|
432
|
+
};
|
|
433
|
+
const types = {
|
|
434
|
+
... /*#__PURE__*/Object.fromEntries(/*#__PURE__*/Object.entries(typeflags).map(([type, typeflag]) => [typeflag, type])),
|
|
435
|
+
// Contiguous files
|
|
436
|
+
"7": "File"
|
|
437
|
+
};
|
|
438
|
+
const typeOf = (typeflag, path) => {
|
|
439
|
+
// Legacy archives mark directories with a trailing slash only
|
|
440
|
+
if (typeflag === "\0") return path.endsWith("/") ? "Directory" : "File";
|
|
441
|
+
return types[typeflag] ?? "Other";
|
|
442
|
+
};
|
|
443
|
+
const typeflagOf = header => header.type === "Other" ? header.typeflag : typeflags[header.type];
|
|
444
|
+
// Entries of these types never carry body bytes, whatever their size field says
|
|
445
|
+
const isHeaderOnly = type => type !== "File" && type !== "Other";
|
|
446
|
+
const textEncoder = /*#__PURE__*/new TextEncoder();
|
|
447
|
+
// Keeps a leading byte order mark as part of the decoded field
|
|
448
|
+
const textDecoder = /*#__PURE__*/new TextDecoder("utf-8", {
|
|
449
|
+
ignoreBOM: true
|
|
450
|
+
});
|
|
451
|
+
const isAscii = s => {
|
|
452
|
+
for (let i = 0; i < s.length; i++) {
|
|
453
|
+
const c = s.charCodeAt(i);
|
|
454
|
+
if (c === 0 || c >= 0x80) return false;
|
|
455
|
+
}
|
|
456
|
+
return true;
|
|
457
|
+
};
|
|
458
|
+
// Keeps the ASCII characters of a value that is also stored in a PAX record
|
|
459
|
+
const toAscii = s => {
|
|
460
|
+
let out = "";
|
|
461
|
+
for (let i = 0; i < s.length; i++) {
|
|
462
|
+
const c = s.charCodeAt(i);
|
|
463
|
+
if (c > 0 && c < 0x80) out += s[i];
|
|
464
|
+
}
|
|
465
|
+
return out;
|
|
466
|
+
};
|
|
467
|
+
const fits = (value, length) => value.length <= length && isAscii(value);
|
|
468
|
+
const paxStringKeys = /*#__PURE__*/new Set(["path", "linkpath", "uname", "gname"]);
|
|
469
|
+
const paxHeaderKeys = /*#__PURE__*/new Set(["path", "linkpath", "size", "uid", "gid", "uname", "gname", "mtime"]);
|
|
470
|
+
const noPax = /*#__PURE__*/Object.freeze({});
|
|
471
|
+
// Parses records of the form "<length> <key>=<value>\n", where the length counts
|
|
472
|
+
// the bytes of the whole record
|
|
473
|
+
const parsePax = data => {
|
|
474
|
+
const records = new Map();
|
|
475
|
+
let offset = 0;
|
|
476
|
+
while (offset < data.length) {
|
|
477
|
+
let space = offset;
|
|
478
|
+
while (space < data.length && space - offset < 16 && data[space] !== 0x20) space++;
|
|
479
|
+
const lengthField = String.fromCharCode.apply(null, data.subarray(offset, space));
|
|
480
|
+
const length = /^\d+$/.test(lengthField) ? Number(lengthField) : Number.NaN;
|
|
481
|
+
const end = offset + length;
|
|
482
|
+
if (!(length >= 5) || end > data.length || data[space] !== 0x20 || space + 1 >= end || data[end - 1] !== 0x0a) {
|
|
483
|
+
throw invalidHeader("malformed PAX record");
|
|
484
|
+
}
|
|
485
|
+
const record = data.subarray(space + 1, end - 1);
|
|
486
|
+
const equals = record.indexOf(0x3d);
|
|
487
|
+
if (equals <= 0) {
|
|
488
|
+
throw invalidHeader("malformed PAX record");
|
|
489
|
+
}
|
|
490
|
+
const key = textDecoder.decode(record.subarray(0, equals));
|
|
491
|
+
const value = textDecoder.decode(record.subarray(equals + 1));
|
|
492
|
+
if (key.includes("\0") || paxStringKeys.has(key) && value.includes("\0")) {
|
|
493
|
+
throw invalidHeader(`invalid PAX record ${key}`);
|
|
494
|
+
}
|
|
495
|
+
records.set(key, value);
|
|
496
|
+
offset = end;
|
|
497
|
+
}
|
|
498
|
+
return records;
|
|
499
|
+
};
|
|
500
|
+
const paxInteger = (key, value) => {
|
|
501
|
+
const n = /^\d+$/.test(value) ? Number(value) : Number.NaN;
|
|
502
|
+
if (!Number.isSafeInteger(n)) {
|
|
503
|
+
throw invalidHeader(`invalid PAX ${key} ${JSON.stringify(value)}`);
|
|
504
|
+
}
|
|
505
|
+
return n;
|
|
506
|
+
};
|
|
507
|
+
// Parses a PAX time of decimal seconds into milliseconds, rounded down. The
|
|
508
|
+
// digits are added up separately, because `Number(value) * 1000` is inexact.
|
|
509
|
+
const paxMillis = value => {
|
|
510
|
+
const match = /^(-?)(\d+)(?:\.(\d+))?$/.exec(value);
|
|
511
|
+
if (match === null) {
|
|
512
|
+
throw invalidHeader(`invalid PAX mtime ${JSON.stringify(value)}`);
|
|
513
|
+
}
|
|
514
|
+
const [, sign, seconds, fraction = ""] = match;
|
|
515
|
+
const millis = Number(seconds) * 1000 + Number(fraction.slice(0, 3).padEnd(3, "0"));
|
|
516
|
+
if (sign === "") return millis;
|
|
517
|
+
// A negative time with digits below a millisecond rounds down past them
|
|
518
|
+
return -millis - (/[1-9]/.test(fraction.slice(3)) ? 1 : 0);
|
|
519
|
+
};
|
|
520
|
+
// Applies the records that override header fields and returns the rest. An
|
|
521
|
+
// empty value keeps the field from the header block.
|
|
522
|
+
const applyPax = (header, records) => {
|
|
523
|
+
const rest = {};
|
|
524
|
+
for (const [key, value] of records) {
|
|
525
|
+
if (key.startsWith("GNU.sparse.")) {
|
|
526
|
+
throw unsupported("GNU sparse files are not supported");
|
|
527
|
+
}
|
|
528
|
+
if (!paxHeaderKeys.has(key)) {
|
|
529
|
+
// Defined rather than assigned, so that a `__proto__` key stays a record
|
|
530
|
+
Object.defineProperty(rest, key, {
|
|
531
|
+
value,
|
|
532
|
+
enumerable: true,
|
|
533
|
+
writable: true,
|
|
534
|
+
configurable: true
|
|
535
|
+
});
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
if (value === "") continue;
|
|
539
|
+
switch (key) {
|
|
540
|
+
case "path":
|
|
541
|
+
header.path = value;
|
|
542
|
+
break;
|
|
543
|
+
case "linkpath":
|
|
544
|
+
header.linkTarget = value;
|
|
545
|
+
break;
|
|
546
|
+
case "uname":
|
|
547
|
+
case "gname":
|
|
548
|
+
header[key] = value;
|
|
549
|
+
break;
|
|
550
|
+
case "uid":
|
|
551
|
+
case "gid":
|
|
552
|
+
case "size":
|
|
553
|
+
header[key] = paxInteger(key, value);
|
|
554
|
+
break;
|
|
555
|
+
case "mtime":
|
|
556
|
+
header.mtimeMillis = paxMillis(value);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return rest;
|
|
560
|
+
};
|
|
561
|
+
const paxRecord = (key, value) => {
|
|
562
|
+
const rest = textEncoder.encode(` ${key}=${value}\n`);
|
|
563
|
+
// The length counts its own digits
|
|
564
|
+
const length = rest.length + String(rest.length + String(rest.length).length).length;
|
|
565
|
+
const out = new Uint8Array(length);
|
|
566
|
+
writeString(out, 0, length, String(length));
|
|
567
|
+
out.set(rest, length - rest.length);
|
|
568
|
+
return out;
|
|
569
|
+
};
|
|
570
|
+
const paxHeaderName = path => {
|
|
571
|
+
const trimmed = path.replace(/\/+$/, "");
|
|
572
|
+
const i = trimmed.lastIndexOf("/");
|
|
573
|
+
const name = i === -1 ? `PaxHeaders.0/${trimmed}` : `${trimmed.slice(0, i)}/PaxHeaders.0/${trimmed.slice(i + 1)}`;
|
|
574
|
+
return toAscii(name).slice(0, 100);
|
|
575
|
+
};
|
|
576
|
+
const readString = (block, offset, length) => {
|
|
577
|
+
let end = offset;
|
|
578
|
+
let ascii = true;
|
|
579
|
+
const limit = offset + length;
|
|
580
|
+
while (end < limit && block[end] !== 0) {
|
|
581
|
+
if (block[end] >= 0x80) ascii = false;
|
|
582
|
+
end++;
|
|
583
|
+
}
|
|
584
|
+
if (end === offset) return "";
|
|
585
|
+
if (!ascii || end - offset > 256) return textDecoder.decode(block.subarray(offset, end));
|
|
586
|
+
// Most header strings are short ASCII, which is cheaper to build directly
|
|
587
|
+
return String.fromCharCode.apply(null, block.subarray(offset, end));
|
|
588
|
+
};
|
|
589
|
+
const readOctal = (block, offset, length) => {
|
|
590
|
+
let start = offset;
|
|
591
|
+
let end = offset + length;
|
|
592
|
+
while (start < end && (block[start] === 0 || block[start] === 0x20)) start++;
|
|
593
|
+
while (end > start && (block[end - 1] === 0 || block[end - 1] === 0x20)) end--;
|
|
594
|
+
let value = 0;
|
|
595
|
+
for (let i = start; i < end; i++) {
|
|
596
|
+
const c = block[i];
|
|
597
|
+
if (c < 0x30 || c > 0x37) {
|
|
598
|
+
throw invalidHeader(`invalid octal number in the header field at offset ${offset}`);
|
|
599
|
+
}
|
|
600
|
+
value = value * 8 + (c - 0x30);
|
|
601
|
+
}
|
|
602
|
+
return value;
|
|
603
|
+
};
|
|
604
|
+
// GNU base-256: the high bit of the first byte is set, and the next bit is the
|
|
605
|
+
// sign of a two's complement big-endian number
|
|
606
|
+
const readNumber = (block, offset, length) => {
|
|
607
|
+
if ((block[offset] & 0x80) === 0) return readOctal(block, offset, length);
|
|
608
|
+
const negative = (block[offset] & 0x40) !== 0;
|
|
609
|
+
// Negative numbers are read as the bitwise inverse of their magnitude minus one
|
|
610
|
+
let value = 0;
|
|
611
|
+
for (let i = 0; i < length; i++) {
|
|
612
|
+
let c = block[offset + i];
|
|
613
|
+
if (negative) c ^= 0xff;
|
|
614
|
+
if (i === 0) c &= 0x7f;
|
|
615
|
+
value = value * 256 + c;
|
|
616
|
+
if (value > Number.MAX_SAFE_INTEGER) {
|
|
617
|
+
throw invalidHeader(`base-256 number in the header field at offset ${offset} is out of range`);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return negative ? -value - 1 : value;
|
|
621
|
+
};
|
|
622
|
+
const readUnsigned = (block, offset, length, field) => {
|
|
623
|
+
const value = readNumber(block, offset, length);
|
|
624
|
+
if (value < 0) {
|
|
625
|
+
throw invalidHeader(`negative ${field}`);
|
|
626
|
+
}
|
|
627
|
+
return value;
|
|
628
|
+
};
|
|
629
|
+
// The checksum is the sum of the block bytes with the checksum field counted as
|
|
630
|
+
// spaces. Some old tar writers summed signed bytes, which is accepted too.
|
|
631
|
+
const verifyChecksum = block => {
|
|
632
|
+
const stored = readOctal(block, 148, 8);
|
|
633
|
+
let unsigned = sumBlock(block) + 8 * 0x20;
|
|
634
|
+
for (let i = 148; i < 156; i++) unsigned -= block[i];
|
|
635
|
+
if (stored === unsigned) return true;
|
|
636
|
+
let high = 0;
|
|
637
|
+
for (let i = 0; i < BLOCK; i++) {
|
|
638
|
+
if (block[i] > 0x7f && (i < 148 || i >= 156)) high++;
|
|
639
|
+
}
|
|
640
|
+
return stored === unsigned - 0x100 * high;
|
|
641
|
+
};
|
|
642
|
+
const parseHeader = block => {
|
|
643
|
+
if (!verifyChecksum(block)) {
|
|
644
|
+
throw invalidHeader("header checksum mismatch");
|
|
645
|
+
}
|
|
646
|
+
const isUstar = hasBytes(block, 257, USTAR_MAGIC);
|
|
647
|
+
const isGnu = !isUstar && hasBytes(block, 257, GNU_MAGIC);
|
|
648
|
+
const header = {
|
|
649
|
+
typeflag: String.fromCharCode(block[156]),
|
|
650
|
+
path: readString(block, 0, 100),
|
|
651
|
+
linkTarget: readString(block, 157, 100),
|
|
652
|
+
size: readUnsigned(block, 124, 12, "size"),
|
|
653
|
+
mode: readUnsigned(block, 100, 8, "mode"),
|
|
654
|
+
uid: readUnsigned(block, 108, 8, "uid"),
|
|
655
|
+
gid: readUnsigned(block, 116, 8, "gid"),
|
|
656
|
+
mtimeMillis: readNumber(block, 136, 12) * 1000,
|
|
657
|
+
uname: "",
|
|
658
|
+
gname: "",
|
|
659
|
+
devMajor: 0,
|
|
660
|
+
devMinor: 0
|
|
661
|
+
};
|
|
662
|
+
if (!isUstar && !isGnu) return header;
|
|
663
|
+
header.uname = readString(block, 265, 32);
|
|
664
|
+
header.gname = readString(block, 297, 32);
|
|
665
|
+
header.devMajor = readUnsigned(block, 329, 8, "devMajor");
|
|
666
|
+
header.devMinor = readUnsigned(block, 337, 8, "devMinor");
|
|
667
|
+
if (isUstar) {
|
|
668
|
+
// star archives end the block with "tar\0" and keep times after a shorter prefix
|
|
669
|
+
const prefix = hasBytes(block, 508, STAR_TRAILER) ? readString(block, 345, 131) : readString(block, 345, 155);
|
|
670
|
+
if (prefix.length > 0) header.path = `${prefix}/${header.path}`;
|
|
671
|
+
}
|
|
672
|
+
return header;
|
|
673
|
+
};
|
|
674
|
+
const MAX_OCTAL_7 = 0o7777777; // 8-byte numeric fields
|
|
675
|
+
const MAX_OCTAL_11 = 0o77777777777; // 12-byte numeric fields
|
|
676
|
+
const writeString = (block, offset, length, value) => {
|
|
677
|
+
const n = Math.min(value.length, length);
|
|
678
|
+
for (let i = 0; i < n; i++) block[offset + i] = value.charCodeAt(i);
|
|
679
|
+
};
|
|
680
|
+
// Writes `length - 1` zero-padded octal digits; the value must fit
|
|
681
|
+
const writeOctal = (block, offset, length, value) => {
|
|
682
|
+
let i = offset + length - 2;
|
|
683
|
+
// Bit operations are faster, but only cover 32 bits
|
|
684
|
+
for (; value > 0x3fffffff && i >= offset; i--) {
|
|
685
|
+
block[i] = 0x30 + value % 8;
|
|
686
|
+
value = Math.floor(value / 8);
|
|
687
|
+
}
|
|
688
|
+
for (; i >= offset; i--) {
|
|
689
|
+
block[i] = 0x30 + (value & 7);
|
|
690
|
+
value >>>= 3;
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
// Split at the last slash that fits the 155-byte USTAR prefix.
|
|
694
|
+
const splitPath = path => {
|
|
695
|
+
if (path.length <= 100 || !isAscii(path)) return undefined;
|
|
696
|
+
let length = path.length;
|
|
697
|
+
if (length > 156) length = 156;else if (path[length - 1] === "/") length--;
|
|
698
|
+
const i = path.lastIndexOf("/", length - 1);
|
|
699
|
+
if (i <= 0 || path.length - i - 1 > 100) return undefined;
|
|
700
|
+
return [path.slice(0, i), path.slice(i + 1)];
|
|
701
|
+
};
|
|
702
|
+
const paxHeaderFields = {
|
|
703
|
+
name: "",
|
|
704
|
+
prefix: "",
|
|
705
|
+
typeflag: "x",
|
|
706
|
+
size: 0,
|
|
707
|
+
mode: 0o644,
|
|
708
|
+
uid: 0,
|
|
709
|
+
gid: 0,
|
|
710
|
+
mtime: 0,
|
|
711
|
+
linkname: "",
|
|
712
|
+
uname: "",
|
|
713
|
+
gname: "",
|
|
714
|
+
devMajor: 0,
|
|
715
|
+
devMinor: 0
|
|
716
|
+
};
|
|
717
|
+
const writeUstarBlock = (block, fields) => {
|
|
718
|
+
writeString(block, 0, 100, fields.name);
|
|
719
|
+
writeOctal(block, 100, 8, fields.mode);
|
|
720
|
+
writeOctal(block, 108, 8, fields.uid);
|
|
721
|
+
writeOctal(block, 116, 8, fields.gid);
|
|
722
|
+
writeOctal(block, 124, 12, fields.size);
|
|
723
|
+
writeOctal(block, 136, 12, fields.mtime);
|
|
724
|
+
block[156] = fields.typeflag.charCodeAt(0);
|
|
725
|
+
writeString(block, 157, 100, fields.linkname);
|
|
726
|
+
block.set(USTAR_MAGIC_VERSION, 257);
|
|
727
|
+
writeString(block, 265, 32, fields.uname);
|
|
728
|
+
writeString(block, 297, 32, fields.gname);
|
|
729
|
+
writeOctal(block, 329, 8, fields.devMajor);
|
|
730
|
+
writeOctal(block, 337, 8, fields.devMinor);
|
|
731
|
+
writeString(block, 345, 155, fields.prefix);
|
|
732
|
+
block.fill(0x20, 148, 156);
|
|
733
|
+
// Six digits, a NUL and the space left from the fill
|
|
734
|
+
writeOctal(block, 148, 7, sumBlock(block));
|
|
735
|
+
block[154] = 0;
|
|
736
|
+
};
|
|
737
|
+
const checkNumber = (field, value, max) => {
|
|
738
|
+
const n = value ?? 0;
|
|
739
|
+
if (!Number.isSafeInteger(n) || n < 0 || n > max) {
|
|
740
|
+
throw invalidHeader(`invalid ${field} ${n}`);
|
|
741
|
+
}
|
|
742
|
+
return n;
|
|
743
|
+
};
|
|
744
|
+
const checkNoNul = (field, value) => {
|
|
745
|
+
if (value.includes("\0")) {
|
|
746
|
+
throw invalidHeader(`${field} must not contain NUL characters`);
|
|
747
|
+
}
|
|
748
|
+
return value;
|
|
749
|
+
};
|
|
750
|
+
// Writes the header blocks of an entry, with a PAX header first when needed, into
|
|
751
|
+
// zeroed memory from `alloc`. Throws before allocating when the header is invalid.
|
|
752
|
+
const encodeHeader = (header, alloc) => {
|
|
753
|
+
const path = checkNoNul("path", header.path);
|
|
754
|
+
if (path === "") {
|
|
755
|
+
throw invalidHeader("path must not be empty");
|
|
756
|
+
}
|
|
757
|
+
// GNU tar and node-tar read such an entry as a directory
|
|
758
|
+
if (header.type === "File" && path.endsWith("/")) {
|
|
759
|
+
throw invalidHeader(`File entry ${JSON.stringify(path)} must not end with "/"`);
|
|
760
|
+
}
|
|
761
|
+
const typeflag = typeflagOf(header);
|
|
762
|
+
if (typeflag.length !== 1 || typeflag.charCodeAt(0) >= 0x80 || "xgLKS".includes(typeflag)) {
|
|
763
|
+
throw invalidHeader(`invalid typeflag ${JSON.stringify(typeflag)}`);
|
|
764
|
+
}
|
|
765
|
+
const size = checkNumber("size", header.size, Number.MAX_SAFE_INTEGER);
|
|
766
|
+
if (size > 0 && isHeaderOnly(header.type)) {
|
|
767
|
+
throw invalidHeader(`${header.type} entry ${JSON.stringify(path)} must have size 0`);
|
|
768
|
+
}
|
|
769
|
+
const mode = checkNumber("mode", header.mode, Number.MAX_SAFE_INTEGER) & PERMISSION_BITS;
|
|
770
|
+
const uid = checkNumber("uid", header.uid, Number.MAX_SAFE_INTEGER);
|
|
771
|
+
const gid = checkNumber("gid", header.gid, Number.MAX_SAFE_INTEGER);
|
|
772
|
+
const devMajor = checkNumber("devMajor", header.devMajor, MAX_OCTAL_7);
|
|
773
|
+
const devMinor = checkNumber("devMinor", header.devMinor, MAX_OCTAL_7);
|
|
774
|
+
const millis = header.mtime.getTime();
|
|
775
|
+
if (Number.isNaN(millis)) {
|
|
776
|
+
throw invalidHeader("mtime must be a valid date");
|
|
777
|
+
}
|
|
778
|
+
const mtime = Math.floor(millis / 1000);
|
|
779
|
+
// Records of the PAX header, created when one is needed. Their keys are
|
|
780
|
+
// unique, as custom records cannot use the keys of header fields.
|
|
781
|
+
let pax;
|
|
782
|
+
for (const key of Object.keys(header.pax)) {
|
|
783
|
+
if (key.startsWith("GNU.sparse.")) {
|
|
784
|
+
throw invalidHeader(`PAX record ${JSON.stringify(key)} is not supported`);
|
|
785
|
+
}
|
|
786
|
+
if (paxHeaderKeys.has(key)) {
|
|
787
|
+
throw invalidHeader(`PAX record ${JSON.stringify(key)} must be set through its header field`);
|
|
788
|
+
}
|
|
789
|
+
if (key === "" || key.includes("=") || key.includes("\0")) {
|
|
790
|
+
throw invalidHeader(`invalid PAX record ${JSON.stringify(key)}`);
|
|
791
|
+
}
|
|
792
|
+
pax ??= [];
|
|
793
|
+
pax.push([key, header.pax[key]]);
|
|
794
|
+
}
|
|
795
|
+
// PAX holds overflow values; USTAR keeps truncated ASCII strings or zero.
|
|
796
|
+
const split = splitPath(path);
|
|
797
|
+
const linkTarget = checkNoNul("linkTarget", header.linkTarget ?? "");
|
|
798
|
+
const uname = checkNoNul("uname", header.uname);
|
|
799
|
+
const gname = checkNoNul("gname", header.gname);
|
|
800
|
+
const pathFits = split !== undefined || fits(path, 100);
|
|
801
|
+
const linkTargetFits = fits(linkTarget, 100);
|
|
802
|
+
const unameFits = fits(uname, 32);
|
|
803
|
+
const gnameFits = fits(gname, 32);
|
|
804
|
+
if (!pathFits) (pax ??= []).push(["path", path]);
|
|
805
|
+
if (!linkTargetFits) (pax ??= []).push(["linkpath", linkTarget]);
|
|
806
|
+
if (!unameFits) (pax ??= []).push(["uname", uname]);
|
|
807
|
+
if (!gnameFits) (pax ??= []).push(["gname", gname]);
|
|
808
|
+
if (size > MAX_OCTAL_11) (pax ??= []).push(["size", String(size)]);
|
|
809
|
+
if (uid > MAX_OCTAL_7) (pax ??= []).push(["uid", String(uid)]);
|
|
810
|
+
if (gid > MAX_OCTAL_7) (pax ??= []).push(["gid", String(gid)]);
|
|
811
|
+
if (mtime < 0 || mtime > MAX_OCTAL_11) (pax ??= []).push(["mtime", String(mtime)]);
|
|
812
|
+
const ustar = {
|
|
813
|
+
name: split !== undefined ? split[1] : pathFits ? path : toAscii(path).slice(0, 100),
|
|
814
|
+
prefix: split !== undefined ? split[0] : "",
|
|
815
|
+
typeflag,
|
|
816
|
+
size: size > MAX_OCTAL_11 ? 0 : size,
|
|
817
|
+
mode,
|
|
818
|
+
uid: uid > MAX_OCTAL_7 ? 0 : uid,
|
|
819
|
+
gid: gid > MAX_OCTAL_7 ? 0 : gid,
|
|
820
|
+
mtime: mtime < 0 || mtime > MAX_OCTAL_11 ? 0 : mtime,
|
|
821
|
+
linkname: linkTargetFits ? linkTarget : toAscii(linkTarget).slice(0, 100),
|
|
822
|
+
uname: unameFits ? uname : toAscii(uname).slice(0, 32),
|
|
823
|
+
gname: gnameFits ? gname : toAscii(gname).slice(0, 32),
|
|
824
|
+
devMajor,
|
|
825
|
+
devMinor
|
|
826
|
+
};
|
|
827
|
+
if (pax === undefined) {
|
|
828
|
+
writeUstarBlock(alloc(BLOCK), ustar);
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
const records = pax.sort(([a], [b]) => a < b ? -1 : 1).map(([key, value]) => paxRecord(key, value));
|
|
832
|
+
let dataLength = 0;
|
|
833
|
+
for (const record of records) dataLength += record.length;
|
|
834
|
+
const paxBlocks = 1 + Math.ceil(dataLength / BLOCK);
|
|
835
|
+
const out = alloc(BLOCK * (paxBlocks + 1));
|
|
836
|
+
writeUstarBlock(out, {
|
|
837
|
+
...paxHeaderFields,
|
|
838
|
+
name: paxHeaderName(path),
|
|
839
|
+
size: dataLength
|
|
840
|
+
});
|
|
841
|
+
let offset = BLOCK;
|
|
842
|
+
for (const record of records) {
|
|
843
|
+
out.set(record, offset);
|
|
844
|
+
offset += record.length;
|
|
845
|
+
}
|
|
846
|
+
writeUstarBlock(out.subarray(BLOCK * paxBlocks), ustar);
|
|
847
|
+
};
|
|
848
|
+
const MAX_META_SIZE = 1024 * 1024; // PAX and GNU long name data
|
|
849
|
+
const MAX_DATE_MILLIS = 8.64e15; // the range of `Date`
|
|
850
|
+
// A queue of byte chunks that hands out views without copying where possible.
|
|
851
|
+
// Consumed chunks are released right away.
|
|
852
|
+
class ByteQueue {
|
|
853
|
+
chunks = [];
|
|
854
|
+
head = 0;
|
|
855
|
+
offset = 0;
|
|
856
|
+
length = 0;
|
|
857
|
+
consumed = 0;
|
|
858
|
+
push(chunk) {
|
|
859
|
+
if (chunk.length === 0) return;
|
|
860
|
+
this.chunks.push(chunk);
|
|
861
|
+
this.length += chunk.length;
|
|
862
|
+
}
|
|
863
|
+
takeSome(max) {
|
|
864
|
+
const chunk = this.chunks[this.head];
|
|
865
|
+
const available = chunk.length - this.offset;
|
|
866
|
+
if (max < available) {
|
|
867
|
+
const out = chunk.subarray(this.offset, this.offset + max);
|
|
868
|
+
this.offset += max;
|
|
869
|
+
this.length -= max;
|
|
870
|
+
this.consumed += max;
|
|
871
|
+
return out;
|
|
872
|
+
}
|
|
873
|
+
const out = this.offset === 0 ? chunk : chunk.subarray(this.offset);
|
|
874
|
+
this.chunks[this.head++] = undefined;
|
|
875
|
+
this.length -= available;
|
|
876
|
+
this.consumed += available;
|
|
877
|
+
this.offset = 0;
|
|
878
|
+
if (this.head === this.chunks.length) {
|
|
879
|
+
this.chunks = [];
|
|
880
|
+
this.head = 0;
|
|
881
|
+
} else if (this.head >= 1024) {
|
|
882
|
+
this.chunks = this.chunks.slice(this.head);
|
|
883
|
+
this.head = 0;
|
|
884
|
+
}
|
|
885
|
+
return out;
|
|
886
|
+
}
|
|
887
|
+
// Takes exactly `n` bytes; the queue must hold at least `n`
|
|
888
|
+
take(n) {
|
|
889
|
+
if (n === 0) return new Uint8Array(0);
|
|
890
|
+
const first = this.takeSome(n);
|
|
891
|
+
if (first.length === n) return first;
|
|
892
|
+
const out = new Uint8Array(n);
|
|
893
|
+
out.set(first);
|
|
894
|
+
let filled = first.length;
|
|
895
|
+
while (filled < n) {
|
|
896
|
+
const part = this.takeSome(n - filled);
|
|
897
|
+
out.set(part, filled);
|
|
898
|
+
filled += part.length;
|
|
899
|
+
}
|
|
900
|
+
return out;
|
|
901
|
+
}
|
|
902
|
+
clear() {
|
|
903
|
+
this.chunks = [];
|
|
904
|
+
this.head = 0;
|
|
905
|
+
this.offset = 0;
|
|
906
|
+
this.length = 0;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
// Returned by the decoder when the buffered input is not enough to continue
|
|
910
|
+
const NeedInput = /*#__PURE__*/Symbol("effect/encoding/Tar/NeedInput");
|
|
911
|
+
// `next` skips unread body bytes; `read` consumes the current body.
|
|
912
|
+
// Both preserve progress across `NeedInput` retries.
|
|
913
|
+
class Decoder {
|
|
914
|
+
queue = /*#__PURE__*/new ByteQueue();
|
|
915
|
+
ended = false;
|
|
916
|
+
finished = false;
|
|
917
|
+
closed = false;
|
|
918
|
+
// Incremented whenever the current body is invalidated
|
|
919
|
+
generation = 0;
|
|
920
|
+
remaining = 0;
|
|
921
|
+
pad = 0;
|
|
922
|
+
// Bytes to discard before the next header
|
|
923
|
+
skip = 0;
|
|
924
|
+
zeroBlock = false;
|
|
925
|
+
// Archive offset of the last header block read, for error messages
|
|
926
|
+
at = 0;
|
|
927
|
+
// An extended header whose data is still to be read
|
|
928
|
+
meta;
|
|
929
|
+
pax;
|
|
930
|
+
// Records of the PAX global headers read so far
|
|
931
|
+
global;
|
|
932
|
+
longName = "";
|
|
933
|
+
longLink = "";
|
|
934
|
+
push(chunk) {
|
|
935
|
+
if (!this.finished) this.queue.push(chunk);
|
|
936
|
+
}
|
|
937
|
+
end() {
|
|
938
|
+
this.ended = true;
|
|
939
|
+
}
|
|
940
|
+
close() {
|
|
941
|
+
this.closed = true;
|
|
942
|
+
this.generation++;
|
|
943
|
+
this.queue.clear();
|
|
944
|
+
}
|
|
945
|
+
// Returns the next entry header, or `undefined` once the archive and the
|
|
946
|
+
// input have ended. Input after the end of the archive is discarded.
|
|
947
|
+
next() {
|
|
948
|
+
try {
|
|
949
|
+
return this.advance();
|
|
950
|
+
} catch (error) {
|
|
951
|
+
// Header errors are thrown where the archive offset is not known
|
|
952
|
+
if (isTarError(error) && (error.kind === "InvalidHeader" || error.kind === "Unsupported")) {
|
|
953
|
+
throw new TarError({
|
|
954
|
+
kind: error.kind,
|
|
955
|
+
message: `${error.message} (header at byte ${this.at})`
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
throw error;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
advance() {
|
|
962
|
+
this.generation++;
|
|
963
|
+
this.skip += this.remaining + this.pad;
|
|
964
|
+
this.remaining = 0;
|
|
965
|
+
this.pad = 0;
|
|
966
|
+
const queue = this.queue;
|
|
967
|
+
while (true) {
|
|
968
|
+
if (this.finished) return this.finish();
|
|
969
|
+
while (this.skip > 0) {
|
|
970
|
+
if (queue.length === 0) return this.needInput();
|
|
971
|
+
this.skip -= queue.takeSome(this.skip).length;
|
|
972
|
+
}
|
|
973
|
+
if (this.meta !== undefined) {
|
|
974
|
+
const {
|
|
975
|
+
size,
|
|
976
|
+
typeflag
|
|
977
|
+
} = this.meta;
|
|
978
|
+
const total = size + padding(size);
|
|
979
|
+
if (queue.length < total) return this.needInput();
|
|
980
|
+
const data = queue.take(total).subarray(0, size);
|
|
981
|
+
this.meta = undefined;
|
|
982
|
+
if (typeflag === "x") this.pax = parsePax(data);else if (typeflag === "g") this.addGlobal(parsePax(data));else if (typeflag === "L") this.longName = readString(data, 0, size);else this.longLink = readString(data, 0, size);
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
if (queue.length < BLOCK) {
|
|
986
|
+
if (queue.length === 0 && this.ended) return this.finish();
|
|
987
|
+
return this.needInput();
|
|
988
|
+
}
|
|
989
|
+
this.at = queue.consumed;
|
|
990
|
+
const block = queue.take(BLOCK);
|
|
991
|
+
if (isZeroBlock(block)) {
|
|
992
|
+
if (this.zeroBlock) return this.finish();
|
|
993
|
+
this.zeroBlock = true;
|
|
994
|
+
continue;
|
|
995
|
+
}
|
|
996
|
+
if (this.zeroBlock) {
|
|
997
|
+
throw invalidHeader("non-zero block after an end-of-archive block");
|
|
998
|
+
}
|
|
999
|
+
const raw = parseHeader(block);
|
|
1000
|
+
switch (raw.typeflag) {
|
|
1001
|
+
case "x":
|
|
1002
|
+
case "g":
|
|
1003
|
+
case "L":
|
|
1004
|
+
case "K":
|
|
1005
|
+
{
|
|
1006
|
+
if (raw.size > MAX_META_SIZE) {
|
|
1007
|
+
throw invalidHeader(`extended header of ${raw.size} bytes exceeds the limit`);
|
|
1008
|
+
}
|
|
1009
|
+
this.meta = raw;
|
|
1010
|
+
continue;
|
|
1011
|
+
}
|
|
1012
|
+
case "S":
|
|
1013
|
+
{
|
|
1014
|
+
throw unsupported("GNU sparse files are not supported");
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
const header = this.toHeader(raw);
|
|
1018
|
+
this.remaining = header.size;
|
|
1019
|
+
this.pad = padding(header.size);
|
|
1020
|
+
return header;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
// Returns the buffered body bytes of the entry from generation `id`, or
|
|
1024
|
+
// `undefined` once the whole body has been read
|
|
1025
|
+
read(id) {
|
|
1026
|
+
if (id !== this.generation) {
|
|
1027
|
+
throw new TarError({
|
|
1028
|
+
kind: "BodyConsumed",
|
|
1029
|
+
message: this.closed ? "tar entry body read after the archive stream ended" : "tar entry body read after moving to the next entry"
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
if (this.remaining === 0) return undefined;
|
|
1033
|
+
if (this.queue.length === 0) return this.needInput();
|
|
1034
|
+
const chunks = Arr.of(this.queue.takeSome(this.remaining));
|
|
1035
|
+
this.remaining -= chunks[0].length;
|
|
1036
|
+
while (this.remaining > 0 && this.queue.length > 0) {
|
|
1037
|
+
const chunk = this.queue.takeSome(this.remaining);
|
|
1038
|
+
this.remaining -= chunk.length;
|
|
1039
|
+
chunks.push(chunk);
|
|
1040
|
+
}
|
|
1041
|
+
return chunks;
|
|
1042
|
+
}
|
|
1043
|
+
needInput() {
|
|
1044
|
+
if (this.ended) throw truncated(this.queue.consumed + this.queue.length);
|
|
1045
|
+
return NeedInput;
|
|
1046
|
+
}
|
|
1047
|
+
finish() {
|
|
1048
|
+
// An extended header must be followed by the entry it describes
|
|
1049
|
+
if (!this.finished && (this.pax !== undefined || this.longName !== "" || this.longLink !== "")) {
|
|
1050
|
+
throw truncated(this.queue.consumed);
|
|
1051
|
+
}
|
|
1052
|
+
this.finished = true;
|
|
1053
|
+
this.queue.clear();
|
|
1054
|
+
return this.ended ? undefined : NeedInput;
|
|
1055
|
+
}
|
|
1056
|
+
// Global records apply to every entry that follows, except the ones that only
|
|
1057
|
+
// describe a single entry, and an empty value removes a record
|
|
1058
|
+
addGlobal(records) {
|
|
1059
|
+
for (const [key, value] of records) {
|
|
1060
|
+
if (key === "path" || key === "linkpath" || key === "size") continue;
|
|
1061
|
+
if (value !== "") (this.global ??= new Map()).set(key, value);else this.global?.delete(key);
|
|
1062
|
+
}
|
|
1063
|
+
if (this.global?.size === 0) this.global = undefined;
|
|
1064
|
+
}
|
|
1065
|
+
toHeader(raw) {
|
|
1066
|
+
// The records of the entry's own extended header override global ones
|
|
1067
|
+
const records = this.global === undefined ? this.pax : this.pax === undefined ? this.global : new Map([...this.global, ...this.pax]);
|
|
1068
|
+
const rest = records === undefined ? noPax : applyPax(raw, records);
|
|
1069
|
+
// Empty GNU long names are ignored, as in Go
|
|
1070
|
+
if (this.longName !== "") raw.path = this.longName;
|
|
1071
|
+
if (this.longLink !== "") raw.linkTarget = this.longLink;
|
|
1072
|
+
this.pax = undefined;
|
|
1073
|
+
this.longName = "";
|
|
1074
|
+
this.longLink = "";
|
|
1075
|
+
if (!(Math.abs(raw.mtimeMillis) <= MAX_DATE_MILLIS)) {
|
|
1076
|
+
throw invalidHeader("mtime is out of range");
|
|
1077
|
+
}
|
|
1078
|
+
const type = typeOf(raw.typeflag, raw.path);
|
|
1079
|
+
const header = {
|
|
1080
|
+
path: raw.path,
|
|
1081
|
+
type,
|
|
1082
|
+
typeflag: raw.typeflag,
|
|
1083
|
+
size: isHeaderOnly(type) ? 0 : raw.size,
|
|
1084
|
+
mode: raw.mode & PERMISSION_BITS,
|
|
1085
|
+
uid: raw.uid,
|
|
1086
|
+
gid: raw.gid,
|
|
1087
|
+
uname: raw.uname,
|
|
1088
|
+
gname: raw.gname,
|
|
1089
|
+
mtime: new Date(raw.mtimeMillis),
|
|
1090
|
+
pax: rest
|
|
1091
|
+
};
|
|
1092
|
+
if (raw.linkTarget !== "") header.linkTarget = raw.linkTarget;
|
|
1093
|
+
if (type === "CharDevice" || type === "BlockDevice") {
|
|
1094
|
+
header.devMajor = raw.devMajor;
|
|
1095
|
+
header.devMinor = raw.devMinor;
|
|
1096
|
+
}
|
|
1097
|
+
return header;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
const SLAB_SIZE = 64 * 1024;
|
|
1101
|
+
const emptyBody = /*#__PURE__*/new Uint8Array(0);
|
|
1102
|
+
// Bodies below this size are copied next to their header instead of being
|
|
1103
|
+
// handed out as chunks of their own
|
|
1104
|
+
const COPY_LIMIT = 16 * 1024;
|
|
1105
|
+
// Pack headers, padding and small body chunks into slabs; pass large chunks
|
|
1106
|
+
// through without copying. Flushed slab regions are never overwritten.
|
|
1107
|
+
class Encoder {
|
|
1108
|
+
slab = /*#__PURE__*/new Uint8Array(0);
|
|
1109
|
+
// Start of the bytes in `slab` that have not been flushed, and their end
|
|
1110
|
+
start = 0;
|
|
1111
|
+
offset = 0;
|
|
1112
|
+
chunks = [];
|
|
1113
|
+
buffered = 0;
|
|
1114
|
+
// The entry whose body is being written, and the body bytes written so far
|
|
1115
|
+
header;
|
|
1116
|
+
written = 0;
|
|
1117
|
+
begin(header) {
|
|
1118
|
+
encodeHeader(header, this.alloc);
|
|
1119
|
+
this.header = header;
|
|
1120
|
+
this.written = 0;
|
|
1121
|
+
}
|
|
1122
|
+
body(chunk) {
|
|
1123
|
+
const header = this.header;
|
|
1124
|
+
this.written += chunk.length;
|
|
1125
|
+
if (this.written > header.size) {
|
|
1126
|
+
throw sizeMismatch(header, this.written);
|
|
1127
|
+
}
|
|
1128
|
+
if (chunk.length < COPY_LIMIT) {
|
|
1129
|
+
// `reserve` can start a new slab, so it must run before `slab` is read
|
|
1130
|
+
const offset = this.reserve(chunk.length);
|
|
1131
|
+
this.slab.set(chunk, offset);
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
this.cut();
|
|
1135
|
+
this.chunks.push(chunk);
|
|
1136
|
+
this.buffered += chunk.length;
|
|
1137
|
+
}
|
|
1138
|
+
end() {
|
|
1139
|
+
const header = this.header;
|
|
1140
|
+
this.header = undefined;
|
|
1141
|
+
if (this.written !== header.size) {
|
|
1142
|
+
throw sizeMismatch(header, this.written);
|
|
1143
|
+
}
|
|
1144
|
+
this.reserve(padding(header.size));
|
|
1145
|
+
}
|
|
1146
|
+
finish() {
|
|
1147
|
+
this.reserve(BLOCK * 2);
|
|
1148
|
+
}
|
|
1149
|
+
flush() {
|
|
1150
|
+
this.cut();
|
|
1151
|
+
const chunks = this.chunks;
|
|
1152
|
+
this.chunks = [];
|
|
1153
|
+
this.buffered = 0;
|
|
1154
|
+
return chunks;
|
|
1155
|
+
}
|
|
1156
|
+
// Ends the current run of slab bytes as a chunk
|
|
1157
|
+
cut() {
|
|
1158
|
+
if (this.offset > this.start) {
|
|
1159
|
+
this.chunks.push(this.slab.subarray(this.start, this.offset));
|
|
1160
|
+
this.start = this.offset;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
// Returns `size` zeroed bytes of the output
|
|
1164
|
+
alloc = size => {
|
|
1165
|
+
const offset = this.reserve(size);
|
|
1166
|
+
return this.slab.subarray(offset, offset + size);
|
|
1167
|
+
};
|
|
1168
|
+
// Reserves `size` zeroed bytes of the output in `slab`, and returns their offset
|
|
1169
|
+
reserve(size) {
|
|
1170
|
+
if (this.offset + size > this.slab.length) {
|
|
1171
|
+
this.cut();
|
|
1172
|
+
this.slab = new Uint8Array(Math.max(SLAB_SIZE, size));
|
|
1173
|
+
this.start = 0;
|
|
1174
|
+
this.offset = 0;
|
|
1175
|
+
}
|
|
1176
|
+
const offset = this.offset;
|
|
1177
|
+
this.offset += size;
|
|
1178
|
+
this.buffered += size;
|
|
1179
|
+
return offset;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
//# sourceMappingURL=Tar.js.map
|