effect 4.0.4 → 4.0.6
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/src/52_graphql/10_basics.ts +19 -13
- package/ai-docs/src/52_graphql/30_batching.ts +6 -4
- package/ai-docs/src/52_graphql/40_aliased-batching.ts +6 -4
- package/ai-docs/tsconfig.json +3 -1
- package/dist/Array.d.ts +207 -58
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +45 -22
- 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 +187 -14
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +142 -33
- 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 +34 -32
- 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/Duration.d.ts.map +1 -1
- package/dist/Duration.js +58 -21
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +548 -182
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +261 -76
- package/dist/Effect.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 +24 -9
- 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 +28 -9
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +3 -0
- package/dist/FileSystem.js.map +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.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/JsonSchema.d.ts +9 -3
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +19 -3
- 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/Match.d.ts +20 -6
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +2 -2
- package/dist/Match.js.map +1 -1
- package/dist/Metric.d.ts +132 -0
- 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/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/Path.d.ts +37 -5
- package/dist/Path.d.ts.map +1 -1
- package/dist/Path.js +44 -6
- package/dist/Path.js.map +1 -1
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +12 -7
- 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.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.map +1 -1
- package/dist/Schema.d.ts +383 -326
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +338 -17
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +5 -5
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +24 -8
- 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/SchemaRepresentation.d.ts +56 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +18 -0
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +1 -1
- package/dist/SchemaTransformation.js +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/Sink.d.ts.map +1 -1
- package/dist/Sink.js +6 -2
- 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 +145 -60
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +16 -2
- package/dist/String.d.ts.map +1 -1
- package/dist/String.js +25 -10
- 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/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/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +3 -2
- package/dist/TxRef.js.map +1 -1
- package/dist/ai/AiError.d.ts +78 -14
- package/dist/ai/AiError.d.ts.map +1 -1
- package/dist/ai/AiError.js +51 -3
- 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 +116 -20
- package/dist/ai/Decision.d.ts.map +1 -1
- package/dist/ai/Decision.js +37 -3
- 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 +183 -95
- 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 +47 -35
- 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 +368 -235
- 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 +6 -52
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +27 -50
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/Prompt.d.ts +22 -20
- package/dist/ai/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +23 -1
- package/dist/ai/Prompt.js.map +1 -1
- package/dist/ai/Response.d.ts +148 -4
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +35 -37
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +12 -4
- package/dist/ai/Tool.d.ts.map +1 -1
- 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 +65 -12
- 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/CliError.d.ts +42 -2
- package/dist/cli/CliError.d.ts.map +1 -1
- package/dist/cli/CliError.js +44 -5
- package/dist/cli/CliError.js.map +1 -1
- package/dist/cli/Command.d.ts +286 -2
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +107 -6
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Completions.d.ts +10 -0
- package/dist/cli/Completions.d.ts.map +1 -1
- package/dist/cli/Completions.js.map +1 -1
- package/dist/cli/Flag.d.ts +215 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +89 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/cli/GlobalFlag.js +3 -3
- package/dist/cli/GlobalFlag.js.map +1 -1
- package/dist/cli/Param.d.ts +194 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +86 -0
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/TerminalCapabilities.d.ts +84 -0
- package/dist/cli/TerminalCapabilities.d.ts.map +1 -0
- package/dist/cli/TerminalCapabilities.js +122 -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 +7 -3
- package/dist/cli/internal/command.js.map +1 -1
- package/dist/cli/internal/completions/bash.js +7 -5
- package/dist/cli/internal/completions/bash.js.map +1 -1
- package/dist/cli/internal/completions/descriptor.js +16 -1
- package/dist/cli/internal/completions/descriptor.js.map +1 -1
- package/dist/cli/internal/completions/fish.js +12 -10
- package/dist/cli/internal/completions/fish.js.map +1 -1
- package/dist/cli/internal/completions/powershell.js +20 -10
- package/dist/cli/internal/completions/powershell.js.map +1 -1
- package/dist/cli/internal/completions/zsh.js +15 -8
- 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 +35 -15
- package/dist/cli/internal/parser.js.map +1 -1
- package/dist/cli/internal/wizard.d.ts.map +1 -1
- package/dist/cli/internal/wizard.js +2 -1
- package/dist/cli/internal/wizard.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 +2 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +98 -18
- 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 +21 -0
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +20 -12
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +96 -37
- 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 +95 -32
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +20 -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/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 +10 -4
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +66 -9
- 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 +31 -4
- package/dist/devtools/DevToolsClient.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.js +1 -1
- 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.js +3 -3
- 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 +387 -159
- 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 +47 -0
- package/dist/eventlog/internal/conflicts.d.ts.map +1 -0
- package/dist/eventlog/internal/conflicts.js +92 -0
- package/dist/eventlog/internal/conflicts.js.map +1 -0
- package/dist/graphql/GraphQLClient.d.ts.map +1 -1
- package/dist/graphql/GraphQLClient.js +12 -5
- package/dist/graphql/GraphQLClient.js.map +1 -1
- 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 +252 -11
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -1
- package/dist/graphql/GraphQLProtocol.js +99 -8
- package/dist/graphql/GraphQLProtocol.js.map +1 -1
- package/dist/graphql/GraphQLResolver.d.ts +3 -1
- package/dist/graphql/GraphQLResolver.d.ts.map +1 -1
- package/dist/graphql/GraphQLResolver.js +91 -19
- package/dist/graphql/GraphQLResolver.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +13 -3
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +56 -6
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/FindMyWay/internal/router.js +12 -1
- package/dist/http/FindMyWay/internal/router.js.map +1 -1
- package/dist/http/Headers.d.ts +230 -3
- package/dist/http/Headers.d.ts.map +1 -1
- package/dist/http/Headers.js +267 -5
- package/dist/http/Headers.js.map +1 -1
- package/dist/http/HttpClient.d.ts +105 -0
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +69 -17
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientError.d.ts.map +1 -1
- package/dist/http/HttpClientError.js +8 -6
- package/dist/http/HttpClientError.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +274 -7
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +91 -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 +179 -2
- package/dist/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/http/HttpMiddleware.js +226 -18
- package/dist/http/HttpMiddleware.js.map +1 -1
- package/dist/http/HttpRouter.d.ts.map +1 -1
- package/dist/http/HttpRouter.js +58 -14
- 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 +11 -7
- package/dist/http/HttpServerError.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts +25 -5
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +38 -12
- 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 +25 -17
- package/dist/http/HttpStaticServer.js.map +1 -1
- package/dist/http/HttpTraceContext.js +1 -1
- package/dist/http/HttpTraceContext.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 +87 -5
- 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 +8 -2
- package/dist/http/Url.js.map +1 -1
- package/dist/http/UrlParams.d.ts +112 -8
- package/dist/http/UrlParams.d.ts.map +1 -1
- package/dist/http/UrlParams.js +141 -14
- package/dist/http/UrlParams.js.map +1 -1
- package/dist/http/internal/compression.d.ts +1 -1
- package/dist/http/internal/compression.d.ts.map +1 -1
- package/dist/http/internal/compression.js +2 -10
- package/dist/http/internal/compression.js.map +1 -1
- package/dist/http/internal/compressionBody.d.ts +2 -0
- package/dist/http/internal/compressionBody.d.ts.map +1 -0
- package/dist/http/internal/compressionBody.js +36 -0
- package/dist/http/internal/compressionBody.js.map +1 -0
- package/dist/http/internal/decompression.d.ts +2 -0
- package/dist/http/internal/decompression.d.ts.map +1 -0
- package/dist/http/internal/decompression.js +168 -0
- package/dist/http/internal/decompression.js.map +1 -0
- 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/tracing.js +14 -4
- package/dist/http/internal/tracing.js.map +1 -1
- package/dist/http/internal/urlParams.d.ts +2 -0
- package/dist/http/internal/urlParams.d.ts.map +1 -0
- package/dist/http/internal/urlParams.js +4 -0
- package/dist/http/internal/urlParams.js.map +1 -0
- 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.js +1 -1
- 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 +121 -18
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +29 -4
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +85 -24
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts +55 -29
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +49 -5
- 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 +191 -9
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +137 -4
- 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 +30 -9
- 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 +57 -32
- 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/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/core.js +18 -2
- 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 +89 -76
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/graphql.js +12 -2
- package/dist/internal/graphql.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/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/fromJsonSchemaDocument.js +136 -126
- package/dist/internal/schema/fromJsonSchemaDocument.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 +34 -33
- package/dist/internal/schema/standardSchema.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +7 -2
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.js +86 -1
- 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 +60 -38
- package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
- 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/Otlp.d.ts +15 -0
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +3 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpExporter.d.ts +8 -0
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +15 -13
- package/dist/observability/OtlpExporter.js.map +1 -1
- package/dist/observability/OtlpLogger.d.ts +17 -0
- package/dist/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/observability/OtlpLogger.js +14 -1
- package/dist/observability/OtlpLogger.js.map +1 -1
- package/dist/observability/OtlpMetrics.d.ts +17 -0
- package/dist/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/observability/OtlpMetrics.js +18 -3
- package/dist/observability/OtlpMetrics.js.map +1 -1
- 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 +17 -0
- package/dist/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/observability/OtlpTracer.js +15 -2
- package/dist/observability/OtlpTracer.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/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/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 +5 -0
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +5 -0
- package/dist/persistence/index.js.map +1 -1
- package/dist/process/ChildProcess.d.ts +2 -1
- package/dist/process/ChildProcess.d.ts.map +1 -1
- package/dist/process/ChildProcess.js.map +1 -1
- package/dist/reactivity/AsyncResult.d.ts +6 -0
- package/dist/reactivity/AsyncResult.d.ts.map +1 -1
- package/dist/reactivity/AsyncResult.js +28 -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 +47 -10
- 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 +202 -61
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts +15 -0
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +21 -5
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +9 -18
- package/dist/rpc/RpcServer.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.map +1 -1
- package/dist/sql/Migrator.js +15 -3
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +151 -12
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +156 -34
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/SqlResolver.d.ts +9 -0
- package/dist/sql/SqlResolver.d.ts.map +1 -1
- package/dist/sql/SqlResolver.js +9 -0
- package/dist/sql/SqlResolver.js.map +1 -1
- package/dist/sql/Statement.d.ts +3 -1
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +24 -5
- package/dist/sql/Statement.js.map +1 -1
- package/dist/testing/TestClock.d.ts +16 -3
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +115 -23
- 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/Activity.js +1 -0
- package/dist/workflow/Activity.js.map +1 -1
- package/dist/workflow/Workflow.d.ts +22 -0
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js +15 -3
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts +20 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +52 -24
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +13 -3
- package/src/Array.ts +223 -61
- package/src/Bytes.ts +111 -0
- package/src/Channel.ts +287 -439
- package/src/ChannelSchema.ts +1 -49
- package/src/Chunk.ts +55 -61
- package/src/Config.ts +12 -86
- package/src/ConfigProvider.ts +41 -44
- package/src/Cron.ts +6 -3
- package/src/Duration.ts +70 -21
- package/src/Effect.ts +642 -220
- package/src/Equivalence.ts +7 -4
- package/src/Exit.ts +24 -9
- package/src/FiberHandle.ts +10 -9
- package/src/FiberMap.ts +13 -66
- package/src/FileSystem.ts +33 -9
- package/src/Graph.ts +171 -1263
- package/src/HashSet.ts +0 -60
- package/src/Iterable.ts +15 -14
- package/src/JsonSchema.ts +28 -3
- package/src/Layer.ts +2 -2
- package/src/ManagedRuntime.ts +72 -6
- package/src/Match.ts +65 -12
- package/src/Metric.ts +249 -507
- package/src/MutableHashMap.ts +4 -473
- package/src/Number.ts +2 -2
- package/src/Optic.ts +17 -332
- package/src/Path.ts +61 -8
- package/src/PubSub.ts +12 -7
- 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 +7 -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 +2 -94
- package/src/Schema.ts +596 -348
- package/src/SchemaAST.ts +20 -9
- package/src/SchemaGetter.ts +22 -5
- package/src/SchemaIssue.ts +44 -53
- package/src/SchemaRepresentation.ts +64 -1
- package/src/SchemaTransformation.ts +1 -1
- 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/Sink.ts +6 -2
- package/src/Stream.ts +334 -1011
- package/src/String.ts +25 -12
- package/src/TextDiff.ts +766 -0
- package/src/TxHashMap.ts +1 -103
- package/src/TxHashSet.ts +48 -753
- package/src/TxRef.ts +4 -2
- package/src/ai/AiError.ts +69 -5
- package/src/ai/Chat.ts +10 -5
- package/src/ai/Decision.ts +119 -22
- package/src/ai/DecisionModel.ts +265 -109
- package/src/ai/EmbeddingModel.ts +25 -13
- package/src/ai/LanguageModel.ts +57 -51
- 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 +232 -275
- package/src/ai/Prompt.ts +49 -35
- package/src/ai/Response.ts +195 -65
- package/src/ai/Tool.ts +12 -4
- package/src/ai/Toolkit.ts +78 -10
- 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/CliError.ts +49 -4
- package/src/cli/Command.ts +316 -9
- package/src/cli/Completions.ts +10 -0
- package/src/cli/Flag.ts +218 -0
- package/src/cli/GlobalFlag.ts +3 -3
- package/src/cli/Param.ts +218 -0
- package/src/cli/TerminalCapabilities.ts +156 -0
- package/src/cli/index.ts +6 -0
- package/src/cli/internal/command.ts +10 -4
- package/src/cli/internal/completions/bash.ts +7 -5
- package/src/cli/internal/completions/descriptor.ts +20 -1
- package/src/cli/internal/completions/fish.ts +12 -10
- package/src/cli/internal/completions/powershell.ts +25 -13
- package/src/cli/internal/completions/zsh.ts +15 -8
- package/src/cli/internal/formatter.ts +18 -0
- package/src/cli/internal/lexer.ts +12 -5
- package/src/cli/internal/parser.ts +43 -14
- package/src/cli/internal/wizard.ts +2 -1
- package/src/cluster/ClusterCron.ts +94 -35
- package/src/cluster/ClusterMetrics.ts +149 -7
- package/src/cluster/ClusterWorkflowEngine.ts +164 -53
- package/src/cluster/Entity.ts +4 -0
- package/src/cluster/MessageStorage.ts +21 -3
- package/src/cluster/Runners.ts +145 -72
- package/src/cluster/Sharding.ts +118 -38
- package/src/cluster/ShardingConfig.ts +15 -0
- package/src/cluster/SqlMessageStorage.ts +58 -55
- package/src/cluster/SqlRunnerStorage.ts +10 -4
- package/src/cluster/internal/entityManager.ts +81 -11
- package/src/devtools/DevTools.ts +3 -2
- package/src/devtools/DevToolsClient.ts +27 -10
- 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 +1 -1
- package/src/encoding/Tar.ts +1417 -0
- package/src/encoding/Toml.ts +3 -3
- 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 +453 -173
- 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 +123 -0
- package/src/graphql/GraphQLClient.ts +17 -5
- package/src/graphql/GraphQLClientError.ts +5 -12
- package/src/graphql/GraphQLProtocol.ts +277 -20
- package/src/graphql/GraphQLResolver.ts +109 -230
- package/src/http/FetchHttpClient.ts +61 -8
- package/src/http/FindMyWay/internal/router.ts +13 -1
- package/src/http/Headers.ts +343 -163
- package/src/http/HttpClient.ts +144 -136
- package/src/http/HttpClientError.ts +10 -6
- package/src/http/HttpClientRequest.ts +315 -11
- 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 +265 -28
- package/src/http/HttpRouter.ts +67 -14
- package/src/http/HttpServerError.ts +14 -7
- package/src/http/HttpServerRequest.ts +73 -14
- package/src/http/HttpServerResponse.ts +49 -23
- package/src/http/HttpStaticServer.ts +29 -19
- package/src/http/HttpTraceContext.ts +1 -1
- package/src/http/MultipartParser/internal/contentType.ts +107 -6
- package/src/http/MultipartParser/internal/headers.ts +4 -16
- package/src/http/MultipartParser/internal/multipart.ts +10 -32
- package/src/http/Url.ts +8 -2
- package/src/http/UrlParams.ts +225 -26
- package/src/http/internal/compression.ts +3 -17
- package/src/http/internal/compressionBody.ts +56 -0
- package/src/http/internal/decompression.ts +235 -0
- package/src/http/internal/lazyStream.ts +25 -0
- package/src/http/internal/requestState.ts +33 -0
- package/src/http/internal/tracing.ts +21 -4
- package/src/http/internal/urlParams.ts +5 -0
- package/src/http/internal/webResponse.ts +20 -0
- package/src/http-api/HttpApi.ts +1 -1
- package/src/http-api/HttpApiBuilder.ts +151 -23
- package/src/http-api/HttpApiClient.ts +160 -31
- package/src/http-api/HttpApiEndpoint.ts +144 -33
- package/src/http-api/HttpApiError.ts +55 -0
- package/src/http-api/HttpApiScalar.ts +4 -3
- package/src/http-api/HttpApiSchema.ts +275 -13
- package/src/http-api/HttpApiSwagger.ts +11 -4
- package/src/http-api/HttpApiTest.ts +33 -9
- package/src/http-api/OpenApi.ts +84 -42
- package/src/http-api/internal/path.ts +40 -12
- package/src/index.ts +24 -0
- package/src/internal/core.ts +22 -2
- package/src/internal/dateTime.ts +20 -7
- package/src/internal/effect.ts +125 -88
- package/src/internal/graphql.ts +30 -7
- package/src/internal/hashMap.ts +2 -2
- package/src/internal/hydration.ts +15 -0
- package/src/internal/inflate.ts +710 -0
- 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/fromJsonSchemaDocument.ts +262 -193
- package/src/internal/schema/interpreter.ts +58 -45
- package/src/internal/schema/standardSchema.ts +32 -30
- package/src/internal/schema/toCodeDocument.ts +8 -3
- package/src/internal/schema/toCodec.ts +116 -1
- package/src/internal/schema/toFormatter.ts +6 -6
- package/src/internal/schema/toJsonSchemaDocument.ts +69 -39
- 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/Otlp.ts +18 -0
- package/src/observability/OtlpExporter.ts +19 -15
- package/src/observability/OtlpLogger.ts +31 -2
- package/src/observability/OtlpMetrics.ts +35 -4
- package/src/observability/OtlpResource.ts +16 -6
- package/src/observability/OtlpSerialization.ts +17 -3
- package/src/observability/OtlpTracer.ts +32 -3
- package/src/observability/internal/protobuf.ts +2 -10
- 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/UserDirectories.ts +273 -0
- package/src/persistence/index.ts +6 -0
- package/src/process/ChildProcess.ts +2 -1
- package/src/reactivity/AsyncResult.ts +35 -38
- package/src/reactivity/Atom.ts +134 -166
- package/src/reactivity/AtomHttpApi.ts +10 -16
- package/src/reactivity/AtomRegistry.ts +53 -30
- 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 +285 -104
- package/src/rpc/RpcSerialization.ts +21 -5
- package/src/rpc/RpcServer.ts +11 -20
- package/src/schema/VariantSchema.ts +86 -22
- package/src/socket/Socket.ts +45 -20
- package/src/sql/Migrator.ts +19 -9
- package/src/sql/SqlClient.ts +275 -36
- package/src/sql/SqlResolver.ts +9 -0
- package/src/sql/Statement.ts +35 -8
- package/src/testing/TestClock.ts +147 -29
- package/src/testing/TestSchema.ts +9 -3
- package/src/workflow/Activity.ts +1 -0
- package/src/workflow/Workflow.ts +31 -5
- package/src/workflow/WorkflowEngine.ts +93 -31
- 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,1255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes and decodes zip archives as streams in Effect channels.
|
|
3
|
+
*
|
|
4
|
+
* `encode` writes each entry as it arrives and adds the central directory once
|
|
5
|
+
* the input ends; `decode` reads entries in archive order from their local
|
|
6
|
+
* headers. `decode` never buffers an entire entry body, and `encode` only
|
|
7
|
+
* collects deflated bodies with a `size` of at most 64 KiB.
|
|
8
|
+
*
|
|
9
|
+
* Entries are stored or compressed with deflate, the methods every zip tool
|
|
10
|
+
* reads. Compression uses the runtime's `CompressionStream("deflate-raw")`;
|
|
11
|
+
* decompression is implemented here, so that `decode` can find the end of
|
|
12
|
+
* entries whose sizes follow their data. ZIP64 fields are written when sizes,
|
|
13
|
+
* offsets or the entry count need them, and read from local headers and data
|
|
14
|
+
* descriptors.
|
|
15
|
+
* Encryption, other compression methods and archives split across files are
|
|
16
|
+
* not supported.
|
|
17
|
+
*
|
|
18
|
+
* This module is experimental and may receive breaking changes in patch
|
|
19
|
+
* releases.
|
|
20
|
+
*
|
|
21
|
+
* @stability experimental
|
|
22
|
+
* @since 4.0.6
|
|
23
|
+
*/
|
|
24
|
+
import * as Arr from "../Array.js";
|
|
25
|
+
import * as Cause from "../Cause.js";
|
|
26
|
+
import * as Channel from "../Channel.js";
|
|
27
|
+
import * as Data from "../Data.js";
|
|
28
|
+
import * as Effect from "../Effect.js";
|
|
29
|
+
import * as Exit from "../Exit.js";
|
|
30
|
+
import { ByteQueue, InflateError, InflateMemory, Inflater, NeedInput } from "../internal/inflate.js";
|
|
31
|
+
import * as Predicate from "../Predicate.js";
|
|
32
|
+
import * as Pull from "../Pull.js";
|
|
33
|
+
import * as Scope from "../Scope.js";
|
|
34
|
+
import * as Semaphore from "../Semaphore.js";
|
|
35
|
+
import * as Stream from "../Stream.js";
|
|
36
|
+
const ZipErrorTypeId = "~effect/encoding/Zip/ZipError";
|
|
37
|
+
/**
|
|
38
|
+
* Error raised when a zip archive cannot be encoded or decoded.
|
|
39
|
+
*
|
|
40
|
+
* **Details**
|
|
41
|
+
*
|
|
42
|
+
* The `kind` field identifies the failure:
|
|
43
|
+
*
|
|
44
|
+
* - `InvalidHeader`: a header has an unknown signature or a malformed field, or
|
|
45
|
+
* an entry has a value that cannot be written.
|
|
46
|
+
* - `InvalidData`: the compressed data of an entry is corrupt.
|
|
47
|
+
* - `Truncated`: the input ended inside an entry or before the central
|
|
48
|
+
* directory.
|
|
49
|
+
* - `Checksum`: the data of an entry does not match its CRC-32.
|
|
50
|
+
* - `SizeMismatch`: an entry body produced a byte count other than its declared
|
|
51
|
+
* `size`, or the data of an entry does not match the sizes in the archive.
|
|
52
|
+
* - `Unsupported`: the archive uses a feature this module does not read, such
|
|
53
|
+
* as encryption or a compression method other than store and deflate.
|
|
54
|
+
* - `BodyConsumed`: an entry body was read after the decoder had moved past it.
|
|
55
|
+
*
|
|
56
|
+
* @stability experimental
|
|
57
|
+
* @category errors
|
|
58
|
+
* @since 4.0.6
|
|
59
|
+
*/
|
|
60
|
+
export class ZipError extends /*#__PURE__*/Data.TaggedError("ZipError") {
|
|
61
|
+
/**
|
|
62
|
+
* Marks this value as a zip error for runtime guards.
|
|
63
|
+
*
|
|
64
|
+
* @stability experimental
|
|
65
|
+
* @since 4.0.6
|
|
66
|
+
*/
|
|
67
|
+
[ZipErrorTypeId] = ZipErrorTypeId;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks whether a value is a `ZipError`.
|
|
71
|
+
*
|
|
72
|
+
* @stability experimental
|
|
73
|
+
* @category guards
|
|
74
|
+
* @since 4.0.6
|
|
75
|
+
*/
|
|
76
|
+
export const isZipError = u => Predicate.hasProperty(u, ZipErrorTypeId);
|
|
77
|
+
const MIN_MTIME = /*#__PURE__*/Date.UTC(1980, 0, 1);
|
|
78
|
+
const makeHeader = (path, type, method, options, size) => ({
|
|
79
|
+
path,
|
|
80
|
+
type,
|
|
81
|
+
method,
|
|
82
|
+
mtime: options?.mtime ?? new Date(MIN_MTIME),
|
|
83
|
+
mode: options?.mode ?? (type === "Directory" ? 0o755 : 0o644),
|
|
84
|
+
...(size === undefined ? undefined : {
|
|
85
|
+
size
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
* Creates a file entry from in-memory content.
|
|
90
|
+
*
|
|
91
|
+
* **Details**
|
|
92
|
+
*
|
|
93
|
+
* String content is encoded as UTF-8, and `size` is the byte length of the
|
|
94
|
+
* content. Because the content is known up front, its sizes and CRC-32 are
|
|
95
|
+
* written in the local header, which every zip reader accepts.
|
|
96
|
+
*
|
|
97
|
+
* @see {@link fileStream} for content that is streamed instead of held in memory
|
|
98
|
+
* @see {@link encode} for writing entries to an archive
|
|
99
|
+
*
|
|
100
|
+
* @stability experimental
|
|
101
|
+
* @category constructors
|
|
102
|
+
* @since 4.0.6
|
|
103
|
+
*/
|
|
104
|
+
export const file = (path, content, options) => {
|
|
105
|
+
const bytes = typeof content === "string" ? textEncoder.encode(content) : content;
|
|
106
|
+
return {
|
|
107
|
+
header: makeHeader(path, "File", options?.method ?? "Deflate", options, bytes.length),
|
|
108
|
+
content: bytes
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Creates a 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.
|
|
118
|
+
*
|
|
119
|
+
* **Details**
|
|
120
|
+
*
|
|
121
|
+
* `body` is not run until the entry is encoded. Its sizes and CRC-32 are
|
|
122
|
+
* written in a data descriptor after the data.
|
|
123
|
+
*
|
|
124
|
+
* **Gotchas**
|
|
125
|
+
*
|
|
126
|
+
* - A stored entry without `size` fails with an `InvalidHeader` `ZipError`.
|
|
127
|
+
* - When `size` is set, `encode` fails with a `SizeMismatch` `ZipError` if the
|
|
128
|
+
* body produces fewer or more bytes.
|
|
129
|
+
* - Non-empty stored entries are followed by a data descriptor, which some
|
|
130
|
+
* streaming readers mishandle. Java's `ZipInputStream` rejects them, and
|
|
131
|
+
* libarchive reading from a pipe (as `bsdtar` does) ends them at the first
|
|
132
|
+
* bytes that look like a descriptor, so content can cut the entry short and
|
|
133
|
+
* add entries. Use `Deflate` or an in-memory `file` for untrusted content
|
|
134
|
+
* and for those readers.
|
|
135
|
+
*
|
|
136
|
+
* @see {@link file} for in-memory content
|
|
137
|
+
* @see {@link encode} for writing entries to an archive
|
|
138
|
+
*
|
|
139
|
+
* @stability experimental
|
|
140
|
+
* @category constructors
|
|
141
|
+
* @since 4.0.6
|
|
142
|
+
*/
|
|
143
|
+
export const fileStream = (path, body, options) => ({
|
|
144
|
+
header: makeHeader(path, "File", options?.method ?? "Deflate", options, options?.size),
|
|
145
|
+
body
|
|
146
|
+
});
|
|
147
|
+
/**
|
|
148
|
+
* Creates a directory entry.
|
|
149
|
+
*
|
|
150
|
+
* **Details**
|
|
151
|
+
*
|
|
152
|
+
* A trailing `/` is added to a non-empty `path` when missing, as zip tools
|
|
153
|
+
* expect for directories.
|
|
154
|
+
*
|
|
155
|
+
* @stability experimental
|
|
156
|
+
* @category constructors
|
|
157
|
+
* @since 4.0.6
|
|
158
|
+
*/
|
|
159
|
+
export const directory = (path, options) => ({
|
|
160
|
+
// An empty path stays empty, so that `encode` rejects it
|
|
161
|
+
header: makeHeader(path === "" || path.endsWith("/") ? path : `${path}/`, "Directory", "Store", options, 0),
|
|
162
|
+
content: emptyBody
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
* Creates a channel that decodes zip archive bytes into entries.
|
|
166
|
+
*
|
|
167
|
+
* **Details**
|
|
168
|
+
*
|
|
169
|
+
* Entries are read in archive order from their local headers, so archives can
|
|
170
|
+
* be decoded as they arrive, for example from an HTTP response. Each output
|
|
171
|
+
* chunk holds one entry, and each body streams the uncompressed bytes of the
|
|
172
|
+
* entry. Pulling the next entry skips whatever is left of the current body.
|
|
173
|
+
* Stored and deflated entries are read, including ZIP64 sizes and deflated
|
|
174
|
+
* entries whose sizes follow their data in a data descriptor. Every body is
|
|
175
|
+
* checked against its CRC-32 and sizes. Reading stops at the central directory.
|
|
176
|
+
*
|
|
177
|
+
* Paths use the UTF-8 flag when set, and otherwise the first Info-ZIP Unicode
|
|
178
|
+
* path field when it matches the name, as Info-ZIP and 7-Zip do; other paths
|
|
179
|
+
* are read as UTF-8 when valid and as CP437 otherwise. Times are read from the
|
|
180
|
+
* extended timestamp field when present, and otherwise from the DOS time and
|
|
181
|
+
* date, which have no time zone and are read as UTC.
|
|
182
|
+
*
|
|
183
|
+
* **Gotchas**
|
|
184
|
+
*
|
|
185
|
+
* - Read each body before pulling the next entry: a body read afterwards fails
|
|
186
|
+
* with a `BodyConsumed` `ZipError`. Operators that pull ahead, such as
|
|
187
|
+
* `Stream.buffer`, therefore can't sit between `decode` and the body reads.
|
|
188
|
+
* - Read bodies while the entry stream runs, for example in `Stream.mapEffect`:
|
|
189
|
+
* once it has ended, as after `Stream.runCollect`, `Stream.runHead` or
|
|
190
|
+
* `Stream.take`, every body fails with a `BodyConsumed` `ZipError`.
|
|
191
|
+
* - A body reads the entry's bytes once: running it again continues where the
|
|
192
|
+
* previous run stopped.
|
|
193
|
+
* - The central directory is not read, so `mode`, comments and entries that
|
|
194
|
+
* only the central directory lists are not reported. Tools that read the
|
|
195
|
+
* central directory can see other entries and paths, for example in
|
|
196
|
+
* archives updated by appending.
|
|
197
|
+
* - Archives that do not start with an entry or a central directory, such as
|
|
198
|
+
* self-extracting archives, fail with an `InvalidHeader` `ZipError`.
|
|
199
|
+
* - Stored entries whose sizes only follow their data fail with an
|
|
200
|
+
* `Unsupported` `ZipError`. Python's `zipfile` writes them for stored
|
|
201
|
+
* entries on unseekable output, and Info-ZIP's `zip` for empty files when
|
|
202
|
+
* writing to a pipe. Searching for their end would let the content of an
|
|
203
|
+
* entry forge the entries after it.
|
|
204
|
+
* - A body that grows past its `size` fails with a `SizeMismatch` `ZipError`
|
|
205
|
+
* before the extra bytes are emitted, so `size` can be checked before reading.
|
|
206
|
+
* - Deflated data can expand about a thousand times, and pulling the next
|
|
207
|
+
* entry inflates the rest of the current body to find its end. To bound the
|
|
208
|
+
* work on untrusted archives, check `size`, count the bytes of bodies
|
|
209
|
+
* without one, and end the stream at an entry that is too large rather than
|
|
210
|
+
* skip it.
|
|
211
|
+
* - Every `ZipError` ends the archive: later entry and body reads fail with
|
|
212
|
+
* the same error.
|
|
213
|
+
* - The channel completes only when its input ends: input after the central
|
|
214
|
+
* directory is read and discarded, so that the upstream done value can be
|
|
215
|
+
* passed on.
|
|
216
|
+
* - Paths are returned as written in the archive: they can be absolute,
|
|
217
|
+
* contain `..`, drive letters, control characters or backslashes, which some
|
|
218
|
+
* tools read as separators, and can repeat. Validate them before writing
|
|
219
|
+
* entries to disk; `encode` rejects absolute paths, drive letters and
|
|
220
|
+
* backslashes. Paths with a NUL character, which other tools take as the end
|
|
221
|
+
* of the name, fail with an `InvalidHeader` `ZipError`.
|
|
222
|
+
*
|
|
223
|
+
* @see {@link encode} for the inverse operation
|
|
224
|
+
*
|
|
225
|
+
* @stability experimental
|
|
226
|
+
* @category decoding
|
|
227
|
+
* @since 4.0.6
|
|
228
|
+
*/
|
|
229
|
+
export const decode = () => Channel.fromTransform((upstream, scope) => Effect.suspend(() => {
|
|
230
|
+
const decoder = new Decoder();
|
|
231
|
+
let done;
|
|
232
|
+
let pulls = 0;
|
|
233
|
+
const pullUpstream = upstream.pipe(Effect.map(chunks => {
|
|
234
|
+
pulls++;
|
|
235
|
+
for (const chunk of chunks) decoder.push(chunk);
|
|
236
|
+
}), Pull.catchDone(value => {
|
|
237
|
+
pulls++;
|
|
238
|
+
done = {
|
|
239
|
+
value: value
|
|
240
|
+
};
|
|
241
|
+
decoder.end();
|
|
242
|
+
return Effect.void;
|
|
243
|
+
}));
|
|
244
|
+
// Serialize entry and body pulls; reuse input pulled while waiting for the lock.
|
|
245
|
+
const lock = Semaphore.makeUnsafe(1);
|
|
246
|
+
const pullInput = seen => lock.withPermit(Effect.suspend(() => pulls === seen ? pullUpstream : Effect.void));
|
|
247
|
+
const run = (f, end) => Effect.suspend(function loop() {
|
|
248
|
+
const seen = pulls;
|
|
249
|
+
let result;
|
|
250
|
+
try {
|
|
251
|
+
result = f();
|
|
252
|
+
} catch (error) {
|
|
253
|
+
return isZipError(error) ? Effect.fail(error) : Effect.die(error);
|
|
254
|
+
}
|
|
255
|
+
if (result === NeedInput) return Effect.flatMap(pullInput(seen), loop);
|
|
256
|
+
return result === undefined ? Cause.done(end()) : Effect.succeed(result);
|
|
257
|
+
});
|
|
258
|
+
const body = id => Stream.fromPull(Effect.succeed(run(() => decoder.read(id), () => undefined)));
|
|
259
|
+
const next = run(() => {
|
|
260
|
+
const header = decoder.next();
|
|
261
|
+
return header === NeedInput || header === undefined ? header : Arr.of({
|
|
262
|
+
header,
|
|
263
|
+
body: body(decoder.generation)
|
|
264
|
+
});
|
|
265
|
+
}, () => done.value);
|
|
266
|
+
return Effect.as(Scope.addFinalizer(scope, Effect.sync(() => decoder.close())), next);
|
|
267
|
+
}));
|
|
268
|
+
/**
|
|
269
|
+
* Creates a channel that encodes entries into zip archive bytes.
|
|
270
|
+
*
|
|
271
|
+
* **Details**
|
|
272
|
+
*
|
|
273
|
+
* Each entry is written as soon as it arrives: a local header, the stored or
|
|
274
|
+
* deflated body and, for entries with a streamed `body`, a data descriptor
|
|
275
|
+
* with the CRC-32 and sizes. A `ContentEntry` has them in its local header.
|
|
276
|
+
* The central directory is written once the input ends. Paths are written as
|
|
277
|
+
* UTF-8, with the UTF-8 flag set when they are not ASCII. `mtime`
|
|
278
|
+
* is written both as a DOS time in UTC, which keeps two-second resolution and
|
|
279
|
+
* covers 1980 to 2107, and as an extended timestamp in whole seconds when it
|
|
280
|
+
* falls between 1970 and 2038. ZIP64 fields are added when a size, an offset
|
|
281
|
+
* or the entry count does not fit the classic fields, and to the local header
|
|
282
|
+
* of a deflated entry streamed without a `size` or with one near 4 GiB, so
|
|
283
|
+
* that readers know the width of the sizes after its data.
|
|
284
|
+
*
|
|
285
|
+
* Headers and body chunks below 16 KiB are gathered into output chunks of
|
|
286
|
+
* about 64 KiB, and larger body chunks pass through without copying. Output is
|
|
287
|
+
* handed out before waiting for more entries, but up to 64 KiB of it can be
|
|
288
|
+
* held while a body is pulled. Each body chunk of a streamed `Deflate` entry is
|
|
289
|
+
* a separate compressor job, so larger chunks compress faster. A `Deflate`
|
|
290
|
+
* body with a `size` of at most 64 KiB is instead collected and compressed in
|
|
291
|
+
* one job, and still gets a data descriptor; omit `size` to stream it.
|
|
292
|
+
*
|
|
293
|
+
* **Gotchas**
|
|
294
|
+
*
|
|
295
|
+
* - Deflated entries need `CompressionStream("deflate-raw")`. On a runtime
|
|
296
|
+
* without it, encoding a deflated entry dies with the runtime's error, as
|
|
297
|
+
* it does when the compressor fails: check for the API or use `Store`.
|
|
298
|
+
* - Deflated bytes come from the runtime's `CompressionStream`, so they can
|
|
299
|
+
* differ between runtimes. Archives of stored entries are byte-identical
|
|
300
|
+
* everywhere.
|
|
301
|
+
* - A body that produces a byte count other than a set `header.size`, or any
|
|
302
|
+
* bytes for a directory, fails with a `SizeMismatch` `ZipError`.
|
|
303
|
+
* - Directories are always stored, whatever their `method`.
|
|
304
|
+
* - Empty paths, paths starting with `/` or a drive letter such as `C:`, paths
|
|
305
|
+
* containing `\` or NUL, `File` paths ending with `/`, `Directory` paths not
|
|
306
|
+
* ending with `/`, and invalid modes, sizes or times fail with an
|
|
307
|
+
* `InvalidHeader` `ZipError`. Other paths are written as given, including
|
|
308
|
+
* `..` segments, so validate untrusted paths before encoding them.
|
|
309
|
+
*
|
|
310
|
+
* **Example** (Writing and reading an archive)
|
|
311
|
+
*
|
|
312
|
+
* ```ts import.meta.vitest
|
|
313
|
+
* import { Effect, Stream } from "effect"
|
|
314
|
+
* import { Zip } from "effect/encoding"
|
|
315
|
+
*
|
|
316
|
+
* const archive = Stream.make(
|
|
317
|
+
* Zip.directory("docs"),
|
|
318
|
+
* Zip.file("docs/readme.txt", "Hello, zip!")
|
|
319
|
+
* ).pipe(Stream.pipeThroughChannel(Zip.encode()))
|
|
320
|
+
*
|
|
321
|
+
* const listing = archive.pipe(
|
|
322
|
+
* Stream.pipeThroughChannel(Zip.decode()),
|
|
323
|
+
* Stream.mapEffect((entry) =>
|
|
324
|
+
* Stream.mkString(Stream.decodeText(entry.body)).pipe(
|
|
325
|
+
* Effect.map((text) => `${entry.header.path} ${JSON.stringify(text)}`)
|
|
326
|
+
* )
|
|
327
|
+
* ),
|
|
328
|
+
* Stream.runCollect
|
|
329
|
+
* )
|
|
330
|
+
* await Effect.runPromise(listing) // => ['docs/ ""', 'docs/readme.txt "Hello, zip!"']
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
333
|
+
* @see {@link decode} for the inverse operation
|
|
334
|
+
* @see {@link file} for building entries from in-memory content
|
|
335
|
+
* @see {@link fileStream} for building entries from streamed content
|
|
336
|
+
*
|
|
337
|
+
* @stability experimental
|
|
338
|
+
* @category encoding
|
|
339
|
+
* @since 4.0.6
|
|
340
|
+
*/
|
|
341
|
+
export const encode = () => {
|
|
342
|
+
return Channel.fromTransform((upstream, scope) => Effect.sync(() => {
|
|
343
|
+
const writer = new Writer();
|
|
344
|
+
let entries = [];
|
|
345
|
+
let index = 0;
|
|
346
|
+
let done;
|
|
347
|
+
let body;
|
|
348
|
+
let bodyScope;
|
|
349
|
+
// In-memory entries are deflated ahead of the one being written, so the
|
|
350
|
+
// deflates overlap
|
|
351
|
+
let deflates = [];
|
|
352
|
+
const startDeflates = from => {
|
|
353
|
+
for (let i = from; i < Math.min(entries.length, from + DEFLATE_AHEAD); i++) {
|
|
354
|
+
if (deflates[i] !== undefined) continue;
|
|
355
|
+
const {
|
|
356
|
+
content,
|
|
357
|
+
header
|
|
358
|
+
} = entries[i];
|
|
359
|
+
if (header.type !== "File" || header.method !== "Deflate" || content === undefined) continue;
|
|
360
|
+
if (i > from && content.length > DEFLATE_AHEAD_SIZE) continue;
|
|
361
|
+
const deflating = {
|
|
362
|
+
promise: deflateBytes(content),
|
|
363
|
+
data: undefined
|
|
364
|
+
};
|
|
365
|
+
// Failures surface when the entry is written; deflates left behind by
|
|
366
|
+
// a failed encode finish on their own
|
|
367
|
+
deflating.promise.then(data => {
|
|
368
|
+
deflating.data = data;
|
|
369
|
+
}, () => {});
|
|
370
|
+
deflates[i] = deflating;
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
const write = f => {
|
|
374
|
+
try {
|
|
375
|
+
f();
|
|
376
|
+
} catch (error) {
|
|
377
|
+
return isZipError(error) ? Effect.fail(error) : Effect.die(error);
|
|
378
|
+
}
|
|
379
|
+
return Effect.void;
|
|
380
|
+
};
|
|
381
|
+
return Effect.gen(function* () {
|
|
382
|
+
while (true) {
|
|
383
|
+
if (writer.buffered >= SLAB_SIZE) return writer.flush();
|
|
384
|
+
if (body !== undefined) {
|
|
385
|
+
const chunks = yield* Pull.catchDone(body, () => Effect.undefined);
|
|
386
|
+
if (chunks !== undefined) {
|
|
387
|
+
yield* write(() => writer.data(chunks));
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
body = undefined;
|
|
391
|
+
yield* Scope.close(bodyScope, Exit.void);
|
|
392
|
+
yield* write(() => writer.end());
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (index < entries.length) {
|
|
396
|
+
const entry = entries[index++];
|
|
397
|
+
const {
|
|
398
|
+
header
|
|
399
|
+
} = entry;
|
|
400
|
+
yield* write(() => validate(header));
|
|
401
|
+
const compress = header.type === "File" && header.method === "Deflate";
|
|
402
|
+
if (entry.content !== undefined) {
|
|
403
|
+
const bytes = entry.content;
|
|
404
|
+
let data = bytes;
|
|
405
|
+
if (compress) {
|
|
406
|
+
startDeflates(index - 1);
|
|
407
|
+
const deflating = deflates[index - 1];
|
|
408
|
+
deflates[index - 1] = undefined;
|
|
409
|
+
data = deflating.data ?? (yield* Effect.promise(() => deflating.promise));
|
|
410
|
+
}
|
|
411
|
+
yield* write(() => writer.entry(header, bytes, data));
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
yield* write(() => writer.begin(header));
|
|
415
|
+
if (compress && header.size !== undefined && header.size <= DEFLATE_AHEAD_SIZE) {
|
|
416
|
+
// A small body costs less to deflate in one piece than as a stream
|
|
417
|
+
const size = header.size;
|
|
418
|
+
const chunks = [];
|
|
419
|
+
let length = 0;
|
|
420
|
+
yield* Stream.runForEachArray(entry.body, array => write(() => {
|
|
421
|
+
for (const chunk of array) {
|
|
422
|
+
chunks.push(chunk);
|
|
423
|
+
length += chunk.length;
|
|
424
|
+
}
|
|
425
|
+
if (length > size) throw sizeMismatch(header.path, length, size);
|
|
426
|
+
writer.update(array);
|
|
427
|
+
}));
|
|
428
|
+
const data = yield* Effect.promise(() => deflateBytes(concat(chunks, length)));
|
|
429
|
+
yield* write(() => {
|
|
430
|
+
writer.data([data]);
|
|
431
|
+
writer.end();
|
|
432
|
+
});
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
const raw = Stream.mapArray(entry.body, chunks => {
|
|
436
|
+
writer.update(chunks);
|
|
437
|
+
return chunks;
|
|
438
|
+
});
|
|
439
|
+
bodyScope = Scope.forkUnsafe(scope);
|
|
440
|
+
body = yield* Channel.toPullScoped((compress ? deflate(raw) : raw).channel, bodyScope);
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (writer.buffered > 0) return writer.flush();
|
|
444
|
+
if (done !== undefined) return yield* Cause.done(done.value);
|
|
445
|
+
const next = yield* Pull.catchDone(upstream, value => {
|
|
446
|
+
done = {
|
|
447
|
+
value: value
|
|
448
|
+
};
|
|
449
|
+
return Effect.undefined;
|
|
450
|
+
});
|
|
451
|
+
if (next === undefined) {
|
|
452
|
+
writer.finish();
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
entries = next;
|
|
456
|
+
index = 0;
|
|
457
|
+
deflates = [];
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}));
|
|
461
|
+
};
|
|
462
|
+
// Compressor failures, including a runtime without `deflate-raw`, are defects
|
|
463
|
+
const deflate = input => Stream.unwrap(Effect.map(Effect.sync(() => new CompressionStream("deflate-raw")), compressor => {
|
|
464
|
+
const writer = compressor.writable.getWriter();
|
|
465
|
+
const feed = Stream.runForEach(input, chunk => Effect.promise(() => writer.write(compressible(chunk)))).pipe(Effect.andThen(Effect.promise(() => writer.close())), Effect.onError(() => Effect.sync(() => {
|
|
466
|
+
writer.abort().catch(() => {});
|
|
467
|
+
})));
|
|
468
|
+
const output = Stream.orDie(Stream.fromReadableStream({
|
|
469
|
+
evaluate: () => compressor.readable,
|
|
470
|
+
onError: cause => cause
|
|
471
|
+
}));
|
|
472
|
+
return Stream.merge(output, Stream.fromEffectDrain(feed));
|
|
473
|
+
}));
|
|
474
|
+
// CompressionStream rejects views of a SharedArrayBuffer
|
|
475
|
+
const compressible = bytes => bytes.buffer instanceof ArrayBuffer ? bytes : bytes.slice();
|
|
476
|
+
// How many in-memory entries are deflated at once, and the largest one that
|
|
477
|
+
// is deflated before its turn
|
|
478
|
+
const DEFLATE_AHEAD = 16;
|
|
479
|
+
const DEFLATE_AHEAD_SIZE = 64 * 1024;
|
|
480
|
+
// One promise per in-memory entry costs less than a stream
|
|
481
|
+
const deflateBytes = async bytes => {
|
|
482
|
+
const compressor = new CompressionStream("deflate-raw");
|
|
483
|
+
const writer = compressor.writable.getWriter();
|
|
484
|
+
// A failed write errors the readable, so the reads report it
|
|
485
|
+
if (bytes.length > 0) writer.write(compressible(bytes)).catch(() => {});
|
|
486
|
+
writer.close().catch(() => {});
|
|
487
|
+
const reader = compressor.readable.getReader();
|
|
488
|
+
const chunks = [];
|
|
489
|
+
let length = 0;
|
|
490
|
+
while (true) {
|
|
491
|
+
const {
|
|
492
|
+
done,
|
|
493
|
+
value
|
|
494
|
+
} = await reader.read();
|
|
495
|
+
if (done) break;
|
|
496
|
+
chunks.push(value);
|
|
497
|
+
length += value.length;
|
|
498
|
+
}
|
|
499
|
+
return concat(chunks, length);
|
|
500
|
+
};
|
|
501
|
+
const concat = (chunks, length) => {
|
|
502
|
+
if (chunks.length === 1) return chunks[0];
|
|
503
|
+
const out = new Uint8Array(length);
|
|
504
|
+
let at = 0;
|
|
505
|
+
for (const chunk of chunks) {
|
|
506
|
+
out.set(chunk, at);
|
|
507
|
+
at += chunk.length;
|
|
508
|
+
}
|
|
509
|
+
return out;
|
|
510
|
+
};
|
|
511
|
+
const invalidHeader = message => new ZipError({
|
|
512
|
+
kind: "InvalidHeader",
|
|
513
|
+
message
|
|
514
|
+
});
|
|
515
|
+
const invalidData = message => new ZipError({
|
|
516
|
+
kind: "InvalidData",
|
|
517
|
+
message
|
|
518
|
+
});
|
|
519
|
+
const truncated = at => new ZipError({
|
|
520
|
+
kind: "Truncated",
|
|
521
|
+
message: `unexpected end of zip archive at byte ${at}`
|
|
522
|
+
});
|
|
523
|
+
const unsupported = message => new ZipError({
|
|
524
|
+
kind: "Unsupported",
|
|
525
|
+
message
|
|
526
|
+
});
|
|
527
|
+
const sizeMismatch = (path, actual, expected) => new ZipError({
|
|
528
|
+
kind: "SizeMismatch",
|
|
529
|
+
message: `body of ${JSON.stringify(path)} has ${actual > expected ? "at least" : "only"} ${actual} bytes, but its size is ${expected}`
|
|
530
|
+
});
|
|
531
|
+
const LOCAL = 0x04034b50;
|
|
532
|
+
const CENTRAL = 0x02014b50;
|
|
533
|
+
const DESCRIPTOR = 0x08074b50;
|
|
534
|
+
const END = 0x06054b50;
|
|
535
|
+
const END64 = 0x06064b50;
|
|
536
|
+
const LOCATOR64 = 0x07064b50;
|
|
537
|
+
const FLAG_ENCRYPTED = 0x0001;
|
|
538
|
+
const FLAG_DESCRIPTOR = 0x0008;
|
|
539
|
+
const FLAG_STRONG_ENCRYPTION = 0x0040;
|
|
540
|
+
const FLAG_UTF8 = 0x0800;
|
|
541
|
+
const EXTRA_ZIP64 = 0x0001;
|
|
542
|
+
const EXTRA_TIMESTAMP = 0x5455;
|
|
543
|
+
const EXTRA_UNICODE_PATH = 0x7075;
|
|
544
|
+
const VERSION = 20;
|
|
545
|
+
const VERSION_ZIP64 = 45;
|
|
546
|
+
const CREATOR_UNIX = 3;
|
|
547
|
+
const MAX16 = 0xffff;
|
|
548
|
+
const MAX32 = 0xffffffff;
|
|
549
|
+
const S_IFDIR = 0o040000;
|
|
550
|
+
const S_IFREG = 0o100000;
|
|
551
|
+
const DOS_DIRECTORY = 0x10;
|
|
552
|
+
const textEncoder = /*#__PURE__*/new TextEncoder();
|
|
553
|
+
// Paths keep a leading byte order mark, as other zip tools do
|
|
554
|
+
const textDecoder = /*#__PURE__*/new TextDecoder("utf-8", {
|
|
555
|
+
ignoreBOM: true
|
|
556
|
+
});
|
|
557
|
+
const strictTextDecoder = /*#__PURE__*/new TextDecoder("utf-8", {
|
|
558
|
+
fatal: true,
|
|
559
|
+
ignoreBOM: true
|
|
560
|
+
});
|
|
561
|
+
const emptyBody = /*#__PURE__*/new Uint8Array(0);
|
|
562
|
+
// May exceed 2^53 - 1; callers check or compare
|
|
563
|
+
const readUint64 = (view, at) => view.getUint32(at, true) + view.getUint32(at + 4, true) * 0x100000000;
|
|
564
|
+
const getUint64 = (view, at) => {
|
|
565
|
+
const value = readUint64(view, at);
|
|
566
|
+
if (!Number.isSafeInteger(value)) throw invalidHeader("a 64-bit field exceeds 2^53 - 1");
|
|
567
|
+
return value;
|
|
568
|
+
};
|
|
569
|
+
const setUint64 = (view, at, value) => {
|
|
570
|
+
view.setUint32(at, value % 0x100000000, true);
|
|
571
|
+
view.setUint32(at + 4, Math.floor(value / 0x100000000), true);
|
|
572
|
+
};
|
|
573
|
+
// DOS times have two-second resolution and cover 1980 to 2107
|
|
574
|
+
const toDos = mtime => {
|
|
575
|
+
const millis = mtime.getTime();
|
|
576
|
+
if (millis < MIN_MTIME) return {
|
|
577
|
+
time: 0,
|
|
578
|
+
date: 1 << 5 | 1
|
|
579
|
+
};
|
|
580
|
+
const date = new Date(millis);
|
|
581
|
+
const year = date.getUTCFullYear();
|
|
582
|
+
if (year > 2107) return {
|
|
583
|
+
time: 23 << 11 | 59 << 5 | 29,
|
|
584
|
+
date: 127 << 9 | 12 << 5 | 31
|
|
585
|
+
};
|
|
586
|
+
return {
|
|
587
|
+
time: date.getUTCHours() << 11 | date.getUTCMinutes() << 5 | date.getUTCSeconds() >> 1,
|
|
588
|
+
date: year - 1980 << 9 | date.getUTCMonth() + 1 << 5 | date.getUTCDate()
|
|
589
|
+
};
|
|
590
|
+
};
|
|
591
|
+
const fromDos = (time, date) => Date.UTC((date >> 9) + 1980, (date >> 5 & 0xf) - 1, date & 0x1f, time >> 11, time >> 5 & 0x3f, (time & 0x1f) * 2);
|
|
592
|
+
const CP437 = "ÇüéâäàåçêëèïîìÄÅ" + "ÉæÆôöòûùÿÖÜ¢£¥₧ƒ" + "áíóúñѪº¿⌐¬½¼¡«»" + "░▒▓│┤╡╢╖╕╣║╗╝╜╛┐" + "└┴┬├─┼╞╟╚╔╩╦╠═╬╧" + "╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀" + "αßΓπΣσµτΦΘΩδ∞φε∩" + "≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";
|
|
593
|
+
const decodeName = (bytes, utf8) => {
|
|
594
|
+
if (utf8) return textDecoder.decode(bytes);
|
|
595
|
+
try {
|
|
596
|
+
return strictTextDecoder.decode(bytes);
|
|
597
|
+
} catch {
|
|
598
|
+
let name = "";
|
|
599
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
600
|
+
name += bytes[i] < 0x80 ? String.fromCharCode(bytes[i]) : CP437[bytes[i] - 0x80];
|
|
601
|
+
}
|
|
602
|
+
return name;
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
// CRC-32 (IEEE) lookup tables for sixteen bytes at a time
|
|
606
|
+
const CRC_TABLE = /*#__PURE__*/(() => {
|
|
607
|
+
const table = /*#__PURE__*/new Int32Array(16 * 256);
|
|
608
|
+
for (let n = 0; n < 256; n++) {
|
|
609
|
+
let c = n;
|
|
610
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ c >>> 1 : c >>> 1;
|
|
611
|
+
table[n] = c;
|
|
612
|
+
}
|
|
613
|
+
for (let n = 0; n < 256; n++) {
|
|
614
|
+
let c = table[n];
|
|
615
|
+
for (let k = 1; k < 16; k++) {
|
|
616
|
+
c = table[c & 0xff] ^ c >>> 8;
|
|
617
|
+
table[k * 256 + n] = c;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return table;
|
|
621
|
+
})();
|
|
622
|
+
const littleEndian = /*#__PURE__*/new Uint8Array(/*#__PURE__*/new Uint32Array([1]).buffer)[0] === 1;
|
|
623
|
+
const crc32 = (crc, bytes) => {
|
|
624
|
+
const t = CRC_TABLE;
|
|
625
|
+
let c = ~crc;
|
|
626
|
+
let i = 0;
|
|
627
|
+
const length = bytes.length;
|
|
628
|
+
// Reading whole words is faster than combining bytes, but needs aligned,
|
|
629
|
+
// little-endian words
|
|
630
|
+
if (littleEndian && length >= 64) {
|
|
631
|
+
for (; (bytes.byteOffset + i & 3) !== 0; i++) c = t[(c ^ bytes[i]) & 0xff] ^ c >>> 8;
|
|
632
|
+
const count = length - i >>> 4 << 2;
|
|
633
|
+
const words = new Int32Array(bytes.buffer, bytes.byteOffset + i, count);
|
|
634
|
+
for (let j = 0; j < count; j += 4) {
|
|
635
|
+
const a = c ^ words[j];
|
|
636
|
+
const b = words[j + 1];
|
|
637
|
+
const d = words[j + 2];
|
|
638
|
+
const e = words[j + 3];
|
|
639
|
+
c = t[3840 + (a & 0xff)] ^ t[3584 + (a >>> 8 & 0xff)] ^ t[3328 + (a >>> 16 & 0xff)] ^ t[3072 + (a >>> 24)] ^ t[2816 + (b & 0xff)] ^ t[2560 + (b >>> 8 & 0xff)] ^ t[2304 + (b >>> 16 & 0xff)] ^ t[2048 + (b >>> 24)] ^ t[1792 + (d & 0xff)] ^ t[1536 + (d >>> 8 & 0xff)] ^ t[1280 + (d >>> 16 & 0xff)] ^ t[1024 + (d >>> 24)] ^ t[768 + (e & 0xff)] ^ t[512 + (e >>> 8 & 0xff)] ^ t[256 + (e >>> 16 & 0xff)] ^ t[e >>> 24];
|
|
640
|
+
}
|
|
641
|
+
i += count * 4;
|
|
642
|
+
}
|
|
643
|
+
for (; i + 16 <= length; i += 16) {
|
|
644
|
+
const a = c ^ (bytes[i] | bytes[i + 1] << 8 | bytes[i + 2] << 16 | bytes[i + 3] << 24);
|
|
645
|
+
c = t[3840 + (a & 0xff)] ^ t[3584 + (a >>> 8 & 0xff)] ^ t[3328 + (a >>> 16 & 0xff)] ^ t[3072 + (a >>> 24)] ^ t[2816 + bytes[i + 4]] ^ t[2560 + bytes[i + 5]] ^ t[2304 + bytes[i + 6]] ^ t[2048 + bytes[i + 7]] ^ t[1792 + bytes[i + 8]] ^ t[1536 + bytes[i + 9]] ^ t[1280 + bytes[i + 10]] ^ t[1024 + bytes[i + 11]] ^ t[768 + bytes[i + 12]] ^ t[512 + bytes[i + 13]] ^ t[256 + bytes[i + 14]] ^ t[bytes[i + 15]];
|
|
646
|
+
}
|
|
647
|
+
for (; i < length; i++) c = t[(c ^ bytes[i]) & 0xff] ^ c >>> 8;
|
|
648
|
+
return ~c >>> 0;
|
|
649
|
+
};
|
|
650
|
+
const validate = header => {
|
|
651
|
+
const {
|
|
652
|
+
method,
|
|
653
|
+
mode,
|
|
654
|
+
mtime,
|
|
655
|
+
path,
|
|
656
|
+
size,
|
|
657
|
+
type
|
|
658
|
+
} = header;
|
|
659
|
+
if (path === "") throw invalidHeader("path is empty");
|
|
660
|
+
const quoted = JSON.stringify(path);
|
|
661
|
+
if (path.startsWith("/")) throw invalidHeader(`path ${quoted} is absolute`);
|
|
662
|
+
// The zip format forbids these, and libarchive reads them as separators and roots
|
|
663
|
+
if (path.includes("\\")) throw invalidHeader(`path ${quoted} contains a backslash`);
|
|
664
|
+
if (/^[A-Za-z]:/.test(path)) throw invalidHeader(`path ${quoted} starts with a drive letter`);
|
|
665
|
+
if (path.includes("\0")) throw invalidHeader(`path ${quoted} contains a NUL character`);
|
|
666
|
+
if (type === "File") {
|
|
667
|
+
if (path.endsWith("/")) throw invalidHeader(`file path ${quoted} ends with "/"`);
|
|
668
|
+
if (method !== "Store" && method !== "Deflate") throw invalidHeader(`unknown method for ${quoted}`);
|
|
669
|
+
} else if (type === "Directory") {
|
|
670
|
+
if (!path.endsWith("/")) throw invalidHeader(`directory path ${quoted} does not end with "/"`);
|
|
671
|
+
if (size !== undefined && size !== 0) throw invalidHeader(`directory ${quoted} has a size`);
|
|
672
|
+
} else {
|
|
673
|
+
throw invalidHeader(`unknown entry type for ${quoted}`);
|
|
674
|
+
}
|
|
675
|
+
if (size !== undefined && !(Number.isSafeInteger(size) && size >= 0)) {
|
|
676
|
+
throw invalidHeader(`size of ${quoted} is not a non-negative safe integer`);
|
|
677
|
+
}
|
|
678
|
+
if (mode !== undefined && !(Number.isInteger(mode) && mode >= 0 && mode <= 0o7777)) {
|
|
679
|
+
throw invalidHeader(`mode of ${quoted} is not a permission mode`);
|
|
680
|
+
}
|
|
681
|
+
if (Number.isNaN(mtime.getTime())) {
|
|
682
|
+
throw invalidHeader(`mtime of ${quoted} is not a valid date`);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
const timestampLength = record => record.seconds === undefined ? 0 : 9;
|
|
686
|
+
const writeTimestamp = (bytes, view, at, record) => {
|
|
687
|
+
if (record.seconds === undefined) return;
|
|
688
|
+
view.setUint16(at, EXTRA_TIMESTAMP, true);
|
|
689
|
+
view.setUint16(at + 2, 5, true);
|
|
690
|
+
bytes[at + 4] = 1;
|
|
691
|
+
view.setUint32(at + 5, record.seconds, true);
|
|
692
|
+
};
|
|
693
|
+
const localHeader = record => {
|
|
694
|
+
const {
|
|
695
|
+
zip64
|
|
696
|
+
} = record;
|
|
697
|
+
const extraLength = (zip64 ? 20 : 0) + timestampLength(record);
|
|
698
|
+
const bytes = new Uint8Array(30 + record.name.length + extraLength);
|
|
699
|
+
const view = new DataView(bytes.buffer);
|
|
700
|
+
view.setUint32(0, LOCAL, true);
|
|
701
|
+
view.setUint16(4, zip64 ? VERSION_ZIP64 : VERSION, true);
|
|
702
|
+
view.setUint16(6, record.flags, true);
|
|
703
|
+
view.setUint16(8, record.method, true);
|
|
704
|
+
view.setUint16(10, record.time, true);
|
|
705
|
+
view.setUint16(12, record.date, true);
|
|
706
|
+
view.setUint32(14, record.crc, true);
|
|
707
|
+
view.setUint32(18, zip64 ? MAX32 : record.compressedSize, true);
|
|
708
|
+
view.setUint32(22, zip64 ? MAX32 : record.size, true);
|
|
709
|
+
view.setUint16(26, record.name.length, true);
|
|
710
|
+
view.setUint16(28, extraLength, true);
|
|
711
|
+
bytes.set(record.name, 30);
|
|
712
|
+
let at = 30 + record.name.length;
|
|
713
|
+
if (zip64) {
|
|
714
|
+
view.setUint16(at, EXTRA_ZIP64, true);
|
|
715
|
+
view.setUint16(at + 2, 16, true);
|
|
716
|
+
setUint64(view, at + 4, record.size);
|
|
717
|
+
setUint64(view, at + 12, record.compressedSize);
|
|
718
|
+
at += 20;
|
|
719
|
+
}
|
|
720
|
+
writeTimestamp(bytes, view, at, record);
|
|
721
|
+
return bytes;
|
|
722
|
+
};
|
|
723
|
+
const dataDescriptor = record => {
|
|
724
|
+
const wide = record.zip64;
|
|
725
|
+
const bytes = new Uint8Array(wide ? 24 : 16);
|
|
726
|
+
const view = new DataView(bytes.buffer);
|
|
727
|
+
view.setUint32(0, DESCRIPTOR, true);
|
|
728
|
+
view.setUint32(4, record.crc, true);
|
|
729
|
+
if (wide) {
|
|
730
|
+
setUint64(view, 8, record.compressedSize);
|
|
731
|
+
setUint64(view, 16, record.size);
|
|
732
|
+
} else {
|
|
733
|
+
view.setUint32(8, record.compressedSize, true);
|
|
734
|
+
view.setUint32(12, record.size, true);
|
|
735
|
+
}
|
|
736
|
+
return bytes;
|
|
737
|
+
};
|
|
738
|
+
const centralHeader = record => {
|
|
739
|
+
// ZIP64 holds only the fields that overflow, in this order
|
|
740
|
+
const wide = [];
|
|
741
|
+
if (record.size >= MAX32) wide.push(record.size);
|
|
742
|
+
if (record.compressedSize >= MAX32) wide.push(record.compressedSize);
|
|
743
|
+
if (record.offset >= MAX32) wide.push(record.offset);
|
|
744
|
+
const zip64Length = wide.length === 0 ? 0 : 4 + 8 * wide.length;
|
|
745
|
+
const extraLength = zip64Length + timestampLength(record);
|
|
746
|
+
const version = wide.length === 0 && !record.zip64 ? VERSION : VERSION_ZIP64;
|
|
747
|
+
const bytes = new Uint8Array(46 + record.name.length + extraLength);
|
|
748
|
+
const view = new DataView(bytes.buffer);
|
|
749
|
+
view.setUint32(0, CENTRAL, true);
|
|
750
|
+
view.setUint16(4, CREATOR_UNIX << 8 | version, true);
|
|
751
|
+
view.setUint16(6, version, true);
|
|
752
|
+
view.setUint16(8, record.flags, true);
|
|
753
|
+
view.setUint16(10, record.method, true);
|
|
754
|
+
view.setUint16(12, record.time, true);
|
|
755
|
+
view.setUint16(14, record.date, true);
|
|
756
|
+
view.setUint32(16, record.crc, true);
|
|
757
|
+
view.setUint32(20, Math.min(record.compressedSize, MAX32), true);
|
|
758
|
+
view.setUint32(24, Math.min(record.size, MAX32), true);
|
|
759
|
+
view.setUint16(28, record.name.length, true);
|
|
760
|
+
view.setUint16(30, extraLength, true);
|
|
761
|
+
view.setUint32(38, record.external, true);
|
|
762
|
+
view.setUint32(42, Math.min(record.offset, MAX32), true);
|
|
763
|
+
bytes.set(record.name, 46);
|
|
764
|
+
let at = 46 + record.name.length;
|
|
765
|
+
if (wide.length > 0) {
|
|
766
|
+
view.setUint16(at, EXTRA_ZIP64, true);
|
|
767
|
+
view.setUint16(at + 2, 8 * wide.length, true);
|
|
768
|
+
for (let i = 0; i < wide.length; i++) setUint64(view, at + 4 + 8 * i, wide[i]);
|
|
769
|
+
at += zip64Length;
|
|
770
|
+
}
|
|
771
|
+
writeTimestamp(bytes, view, at, record);
|
|
772
|
+
return bytes;
|
|
773
|
+
};
|
|
774
|
+
const SLAB_SIZE = 64 * 1024;
|
|
775
|
+
// Room for deflate to grow data that does not compress, when choosing ZIP64
|
|
776
|
+
const DEFLATE_HEADROOM = 16 * 1024 * 1024;
|
|
777
|
+
// Chunks below this size are copied together instead of being handed out alone
|
|
778
|
+
const COPY_LIMIT = 16 * 1024;
|
|
779
|
+
class Writer {
|
|
780
|
+
chunks = [];
|
|
781
|
+
buffered = 0;
|
|
782
|
+
offset = 0;
|
|
783
|
+
records = [];
|
|
784
|
+
current;
|
|
785
|
+
// Hands out the buffered output, joining runs of small chunks; needs `buffered > 0`
|
|
786
|
+
flush() {
|
|
787
|
+
const out = [];
|
|
788
|
+
let run = [];
|
|
789
|
+
let runLength = 0;
|
|
790
|
+
const join = () => {
|
|
791
|
+
if (run.length === 1) {
|
|
792
|
+
out.push(run[0]);
|
|
793
|
+
} else if (run.length > 1) {
|
|
794
|
+
const joined = new Uint8Array(runLength);
|
|
795
|
+
let at = 0;
|
|
796
|
+
for (const chunk of run) {
|
|
797
|
+
joined.set(chunk, at);
|
|
798
|
+
at += chunk.length;
|
|
799
|
+
}
|
|
800
|
+
out.push(joined);
|
|
801
|
+
}
|
|
802
|
+
run = [];
|
|
803
|
+
runLength = 0;
|
|
804
|
+
};
|
|
805
|
+
for (const chunk of this.chunks) {
|
|
806
|
+
if (chunk.length >= COPY_LIMIT) {
|
|
807
|
+
join();
|
|
808
|
+
out.push(chunk);
|
|
809
|
+
} else {
|
|
810
|
+
run.push(chunk);
|
|
811
|
+
runLength += chunk.length;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
join();
|
|
815
|
+
this.chunks = [];
|
|
816
|
+
this.buffered = 0;
|
|
817
|
+
return out;
|
|
818
|
+
}
|
|
819
|
+
push(bytes) {
|
|
820
|
+
if (bytes.length === 0) return;
|
|
821
|
+
this.chunks.push(bytes);
|
|
822
|
+
this.offset += bytes.length;
|
|
823
|
+
this.buffered += bytes.length;
|
|
824
|
+
}
|
|
825
|
+
record(header, flags) {
|
|
826
|
+
const name = textEncoder.encode(header.path);
|
|
827
|
+
if (name.length > MAX16) throw invalidHeader(`path ${JSON.stringify(header.path)} is longer than 65535 bytes`);
|
|
828
|
+
const {
|
|
829
|
+
date,
|
|
830
|
+
time
|
|
831
|
+
} = toDos(header.mtime);
|
|
832
|
+
const seconds = Math.floor(header.mtime.getTime() / 1000);
|
|
833
|
+
const directory = header.type === "Directory";
|
|
834
|
+
const mode = header.mode ?? (directory ? 0o755 : 0o644);
|
|
835
|
+
return {
|
|
836
|
+
name,
|
|
837
|
+
// The UTF-8 byte length equals the string length only for ASCII
|
|
838
|
+
flags: name.length === header.path.length ? flags : flags | FLAG_UTF8,
|
|
839
|
+
method: header.type === "File" && header.method === "Deflate" ? 8 : 0,
|
|
840
|
+
time,
|
|
841
|
+
date,
|
|
842
|
+
seconds: seconds >= 0 && seconds <= 0x7fffffff ? seconds : undefined,
|
|
843
|
+
external: ((directory ? S_IFDIR : S_IFREG) | mode) * 0x10000 + (directory ? DOS_DIRECTORY : 0) >>> 0,
|
|
844
|
+
offset: this.offset,
|
|
845
|
+
zip64: false,
|
|
846
|
+
crc: 0,
|
|
847
|
+
compressedSize: 0,
|
|
848
|
+
size: 0
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
// Writes an entry whose content is known, with its sizes in the local header
|
|
852
|
+
entry(header, content, data) {
|
|
853
|
+
const size = header.type === "Directory" ? 0 : header.size;
|
|
854
|
+
if (size !== undefined && size !== content.length) throw sizeMismatch(header.path, content.length, size);
|
|
855
|
+
const record = this.record(header, 0);
|
|
856
|
+
record.crc = crc32(0, content);
|
|
857
|
+
record.size = content.length;
|
|
858
|
+
record.compressedSize = data.length;
|
|
859
|
+
record.zip64 = record.size >= MAX32 || record.compressedSize >= MAX32;
|
|
860
|
+
this.push(localHeader(record));
|
|
861
|
+
if (data.length > 0) this.push(data);
|
|
862
|
+
this.records.push(record);
|
|
863
|
+
}
|
|
864
|
+
// Starts an entry whose sizes and CRC-32 follow its data
|
|
865
|
+
begin(header) {
|
|
866
|
+
const directory = header.type === "Directory";
|
|
867
|
+
const stored = directory || header.method === "Store";
|
|
868
|
+
const size = directory ? 0 : header.size;
|
|
869
|
+
if (stored && size === undefined) {
|
|
870
|
+
throw invalidHeader(`stored file ${JSON.stringify(header.path)} is streamed without a size`);
|
|
871
|
+
}
|
|
872
|
+
// An empty stored entry needs no descriptor: readers would take its zero
|
|
873
|
+
// sizes for missing ones
|
|
874
|
+
const descriptor = !(stored && size === 0);
|
|
875
|
+
const record = this.record(header, descriptor ? FLAG_DESCRIPTOR : 0);
|
|
876
|
+
// Streaming readers find the end of stored data from its size
|
|
877
|
+
if (stored) {
|
|
878
|
+
record.size = size;
|
|
879
|
+
record.compressedSize = size;
|
|
880
|
+
}
|
|
881
|
+
// The local header fixes the width of the sizes after the data, so declare
|
|
882
|
+
// ZIP64 whenever they could reach 4 GiB
|
|
883
|
+
record.zip64 = size === undefined || size >= (stored ? MAX32 : MAX32 - DEFLATE_HEADROOM);
|
|
884
|
+
this.push(localHeader(record));
|
|
885
|
+
record.size = 0;
|
|
886
|
+
record.compressedSize = 0;
|
|
887
|
+
this.current = {
|
|
888
|
+
header,
|
|
889
|
+
record,
|
|
890
|
+
descriptor
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
// Accounts for uncompressed body bytes
|
|
894
|
+
update(chunks) {
|
|
895
|
+
const {
|
|
896
|
+
record
|
|
897
|
+
} = this.current;
|
|
898
|
+
for (const chunk of chunks) {
|
|
899
|
+
record.crc = crc32(record.crc, chunk);
|
|
900
|
+
record.size += chunk.length;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
// Writes stored or compressed body bytes
|
|
904
|
+
data(chunks) {
|
|
905
|
+
const {
|
|
906
|
+
header,
|
|
907
|
+
record
|
|
908
|
+
} = this.current;
|
|
909
|
+
for (const chunk of chunks) {
|
|
910
|
+
this.push(chunk);
|
|
911
|
+
record.compressedSize += chunk.length;
|
|
912
|
+
}
|
|
913
|
+
const size = header.type === "Directory" ? 0 : header.size;
|
|
914
|
+
if (size !== undefined && record.size > size) throw sizeMismatch(header.path, record.size, size);
|
|
915
|
+
if (!record.zip64 && record.compressedSize >= MAX32) {
|
|
916
|
+
throw new ZipError({
|
|
917
|
+
kind: "SizeMismatch",
|
|
918
|
+
message: `compressed data of ${JSON.stringify(header.path)} reached 4 GiB, ` + `but its local header has no ZIP64 sizes`
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
end() {
|
|
923
|
+
const {
|
|
924
|
+
descriptor,
|
|
925
|
+
header,
|
|
926
|
+
record
|
|
927
|
+
} = this.current;
|
|
928
|
+
this.current = undefined;
|
|
929
|
+
if (header.size !== undefined && record.size !== header.size) {
|
|
930
|
+
throw sizeMismatch(header.path, record.size, header.size);
|
|
931
|
+
}
|
|
932
|
+
if (descriptor) this.push(dataDescriptor(record));
|
|
933
|
+
this.records.push(record);
|
|
934
|
+
}
|
|
935
|
+
finish() {
|
|
936
|
+
const start = this.offset;
|
|
937
|
+
for (const record of this.records) this.push(centralHeader(record));
|
|
938
|
+
const size = this.offset - start;
|
|
939
|
+
const count = this.records.length;
|
|
940
|
+
if (count >= MAX16 || size >= MAX32 || start >= MAX32) {
|
|
941
|
+
const end64 = new Uint8Array(56);
|
|
942
|
+
const view = new DataView(end64.buffer);
|
|
943
|
+
view.setUint32(0, END64, true);
|
|
944
|
+
setUint64(view, 4, 44);
|
|
945
|
+
view.setUint16(12, CREATOR_UNIX << 8 | VERSION_ZIP64, true);
|
|
946
|
+
view.setUint16(14, VERSION_ZIP64, true);
|
|
947
|
+
setUint64(view, 24, count);
|
|
948
|
+
setUint64(view, 32, count);
|
|
949
|
+
setUint64(view, 40, size);
|
|
950
|
+
setUint64(view, 48, start);
|
|
951
|
+
const locator = new Uint8Array(20);
|
|
952
|
+
const locatorView = new DataView(locator.buffer);
|
|
953
|
+
locatorView.setUint32(0, LOCATOR64, true);
|
|
954
|
+
setUint64(locatorView, 8, this.offset);
|
|
955
|
+
locatorView.setUint32(16, 1, true);
|
|
956
|
+
this.push(end64);
|
|
957
|
+
this.push(locator);
|
|
958
|
+
}
|
|
959
|
+
const end = new Uint8Array(22);
|
|
960
|
+
const view = new DataView(end.buffer);
|
|
961
|
+
view.setUint32(0, END, true);
|
|
962
|
+
view.setUint16(8, Math.min(count, MAX16), true);
|
|
963
|
+
view.setUint16(10, Math.min(count, MAX16), true);
|
|
964
|
+
view.setUint32(12, Math.min(size, MAX32), true);
|
|
965
|
+
view.setUint32(16, Math.min(start, MAX32), true);
|
|
966
|
+
this.push(end);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
// `next` skips the rest of the current body; `read` consumes it. Both preserve
|
|
970
|
+
// progress across `NeedInput` retries.
|
|
971
|
+
class Decoder {
|
|
972
|
+
queue = /*#__PURE__*/new ByteQueue();
|
|
973
|
+
ended = false;
|
|
974
|
+
finished = false;
|
|
975
|
+
closed = false;
|
|
976
|
+
// Incremented whenever the current body is invalidated
|
|
977
|
+
generation = 0;
|
|
978
|
+
current;
|
|
979
|
+
inflateMemory;
|
|
980
|
+
// The error that ended the archive, repeated by every later call
|
|
981
|
+
failure;
|
|
982
|
+
push(chunk) {
|
|
983
|
+
if (!this.finished) this.queue.push(chunk);
|
|
984
|
+
}
|
|
985
|
+
end() {
|
|
986
|
+
this.ended = true;
|
|
987
|
+
}
|
|
988
|
+
close() {
|
|
989
|
+
this.closed = true;
|
|
990
|
+
this.generation++;
|
|
991
|
+
this.queue.clear();
|
|
992
|
+
}
|
|
993
|
+
// Returns the next entry header, or `undefined` once the entries and the
|
|
994
|
+
// input have ended. Input after the entries is discarded.
|
|
995
|
+
next() {
|
|
996
|
+
this.generation++;
|
|
997
|
+
return this.guard(() => this.advance());
|
|
998
|
+
}
|
|
999
|
+
guard(f) {
|
|
1000
|
+
if (this.failure !== undefined) throw this.failure;
|
|
1001
|
+
try {
|
|
1002
|
+
return f();
|
|
1003
|
+
} catch (error) {
|
|
1004
|
+
if (isZipError(error)) this.failure = error;
|
|
1005
|
+
throw error;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
advance() {
|
|
1009
|
+
while (this.current !== undefined) {
|
|
1010
|
+
if (this.readCurrent() === NeedInput) return NeedInput;
|
|
1011
|
+
}
|
|
1012
|
+
if (this.finished) return this.finish();
|
|
1013
|
+
const queue = this.queue;
|
|
1014
|
+
if (queue.length < 4) return this.needInput();
|
|
1015
|
+
const at = queue.consumed;
|
|
1016
|
+
const head = queue.peek(Math.min(queue.length, 30));
|
|
1017
|
+
const view = new DataView(head.buffer);
|
|
1018
|
+
const signature = view.getUint32(0, true);
|
|
1019
|
+
if (signature === CENTRAL || signature === END || signature === END64) return this.finish();
|
|
1020
|
+
if (signature !== LOCAL) {
|
|
1021
|
+
throw invalidHeader(`unexpected signature 0x${signature.toString(16).padStart(8, "0")} at byte ${at}`);
|
|
1022
|
+
}
|
|
1023
|
+
if (head.length < 30) return this.needInput();
|
|
1024
|
+
const length = 30 + view.getUint16(26, true) + view.getUint16(28, true);
|
|
1025
|
+
if (queue.length < length) return this.needInput();
|
|
1026
|
+
try {
|
|
1027
|
+
this.current = this.parseLocal(queue.take(length));
|
|
1028
|
+
} catch (error) {
|
|
1029
|
+
if (isZipError(error)) {
|
|
1030
|
+
throw new ZipError({
|
|
1031
|
+
kind: error.kind,
|
|
1032
|
+
message: `${error.message} (header at byte ${at})`
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
throw error;
|
|
1036
|
+
}
|
|
1037
|
+
return this.current.header;
|
|
1038
|
+
}
|
|
1039
|
+
// Returns the buffered body bytes of the entry from generation `id`, or
|
|
1040
|
+
// `undefined` once the whole body has been read and checked
|
|
1041
|
+
read(id) {
|
|
1042
|
+
if (id !== this.generation) {
|
|
1043
|
+
throw new ZipError({
|
|
1044
|
+
kind: "BodyConsumed",
|
|
1045
|
+
message: this.closed ? "zip entry body read after the archive stream ended" : "zip entry body read after moving to the next entry"
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
return this.guard(() => this.readCurrent());
|
|
1049
|
+
}
|
|
1050
|
+
readCurrent() {
|
|
1051
|
+
const current = this.current;
|
|
1052
|
+
if (current === undefined) return undefined;
|
|
1053
|
+
const queue = this.queue;
|
|
1054
|
+
if (!current.dataDone) {
|
|
1055
|
+
if (current.inflater === undefined) {
|
|
1056
|
+
if (current.remaining > 0) {
|
|
1057
|
+
if (queue.length === 0) return this.needInput();
|
|
1058
|
+
const chunks = [];
|
|
1059
|
+
while (current.remaining > 0 && queue.length > 0) {
|
|
1060
|
+
const chunk = queue.takeSome(current.remaining);
|
|
1061
|
+
current.remaining -= chunk.length;
|
|
1062
|
+
current.actualCrc = crc32(current.actualCrc, chunk);
|
|
1063
|
+
current.actualSize += chunk.length;
|
|
1064
|
+
chunks.push(chunk);
|
|
1065
|
+
}
|
|
1066
|
+
current.actualCompressedSize = current.actualSize;
|
|
1067
|
+
return chunks;
|
|
1068
|
+
}
|
|
1069
|
+
} else {
|
|
1070
|
+
let chunk;
|
|
1071
|
+
try {
|
|
1072
|
+
chunk = current.inflater.pull();
|
|
1073
|
+
} catch (error) {
|
|
1074
|
+
throw error instanceof InflateError ? invalidData(error.message) : error;
|
|
1075
|
+
}
|
|
1076
|
+
if (chunk === NeedInput) return this.needInput();
|
|
1077
|
+
if (chunk !== undefined) {
|
|
1078
|
+
current.actualSize += chunk.length;
|
|
1079
|
+
// Fail before handing out bytes past the reported size, so that
|
|
1080
|
+
// consumers can limit what a small compressed entry inflates to
|
|
1081
|
+
const {
|
|
1082
|
+
path,
|
|
1083
|
+
size
|
|
1084
|
+
} = current.header;
|
|
1085
|
+
if (size !== undefined && current.actualSize > size) throw sizeMismatch(path, current.actualSize, size);
|
|
1086
|
+
current.actualCrc = crc32(current.actualCrc, chunk);
|
|
1087
|
+
return [chunk];
|
|
1088
|
+
}
|
|
1089
|
+
current.actualCompressedSize = queue.consumed - current.start;
|
|
1090
|
+
}
|
|
1091
|
+
current.dataDone = true;
|
|
1092
|
+
}
|
|
1093
|
+
if (current.descriptor) {
|
|
1094
|
+
const descriptor = this.descriptor(current);
|
|
1095
|
+
if (descriptor === NeedInput) return NeedInput;
|
|
1096
|
+
this.check(current, descriptor.crc, descriptor.compressedSize, descriptor.size);
|
|
1097
|
+
} else {
|
|
1098
|
+
this.check(current, current.crc, current.compressedSize, current.size);
|
|
1099
|
+
}
|
|
1100
|
+
this.current = undefined;
|
|
1101
|
+
return undefined;
|
|
1102
|
+
}
|
|
1103
|
+
check(current, crc, compressedSize, size) {
|
|
1104
|
+
if (current.actualCrc === crc && current.actualCompressedSize === compressedSize && current.actualSize === size) {
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
const path = JSON.stringify(current.header.path);
|
|
1108
|
+
if (current.actualCrc !== crc) {
|
|
1109
|
+
throw new ZipError({
|
|
1110
|
+
kind: "Checksum",
|
|
1111
|
+
message: `CRC-32 of ${path} is ${hex(current.actualCrc)}, but the archive records ${hex(crc)}`
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
throw new ZipError({
|
|
1115
|
+
kind: "SizeMismatch",
|
|
1116
|
+
message: `${path} has ${current.actualSize} bytes (${current.actualCompressedSize} compressed), ` + `but the archive records ${size} (${compressedSize} compressed)`
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
// Reads a data descriptor, whose signature is optional and whose sizes are
|
|
1120
|
+
// 4 bytes unless the local header has a ZIP64 field. Writers that widen the
|
|
1121
|
+
// sizes only on overflow are handled by matching each layout against the
|
|
1122
|
+
// data read; among several matches, one followed by a header signature wins.
|
|
1123
|
+
descriptor(current) {
|
|
1124
|
+
const queue = this.queue;
|
|
1125
|
+
if (queue.length < DESCRIPTOR_PEEK && !this.ended) return NeedInput;
|
|
1126
|
+
const bytes = queue.peek(Math.min(queue.length, DESCRIPTOR_PEEK));
|
|
1127
|
+
const view = new DataView(bytes.buffer);
|
|
1128
|
+
const candidates = [];
|
|
1129
|
+
const offsets = bytes.length >= 4 && view.getUint32(0, true) === DESCRIPTOR ? [4, 0] : [0];
|
|
1130
|
+
for (const offset of offsets) {
|
|
1131
|
+
for (const wide of current.zip64 ? [true, false] : [false, true]) {
|
|
1132
|
+
const length = offset + (wide ? 20 : 12);
|
|
1133
|
+
if (length > bytes.length) continue;
|
|
1134
|
+
candidates.push({
|
|
1135
|
+
length,
|
|
1136
|
+
crc: view.getUint32(offset, true),
|
|
1137
|
+
compressedSize: wide ? readUint64(view, offset + 4) : view.getUint32(offset + 4, true),
|
|
1138
|
+
size: wide ? readUint64(view, offset + 12) : view.getUint32(offset + 8, true)
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
const matches = candidates.filter(candidate => candidate.crc === current.actualCrc && candidate.compressedSize === current.actualCompressedSize && candidate.size === current.actualSize);
|
|
1143
|
+
const match = matches.find(candidate => candidate.length + 4 <= bytes.length && isHeaderSignature(view.getUint32(candidate.length, true))) ?? matches[0];
|
|
1144
|
+
if (match !== undefined) {
|
|
1145
|
+
queue.skip(match.length);
|
|
1146
|
+
return match;
|
|
1147
|
+
}
|
|
1148
|
+
// A complete archive has at least an end record after the descriptor
|
|
1149
|
+
if (candidates.length === 0 || this.ended && bytes.length < DESCRIPTOR_PEEK) {
|
|
1150
|
+
throw truncated(queue.consumed + queue.length);
|
|
1151
|
+
}
|
|
1152
|
+
queue.skip(candidates[0].length);
|
|
1153
|
+
return candidates[0];
|
|
1154
|
+
}
|
|
1155
|
+
parseLocal(bytes) {
|
|
1156
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
|
|
1157
|
+
const flags = view.getUint16(6, true);
|
|
1158
|
+
const method = view.getUint16(8, true);
|
|
1159
|
+
const crc = view.getUint32(14, true);
|
|
1160
|
+
let compressedSize = view.getUint32(18, true);
|
|
1161
|
+
let size = view.getUint32(22, true);
|
|
1162
|
+
const time = view.getUint16(10, true);
|
|
1163
|
+
const date = view.getUint16(12, true);
|
|
1164
|
+
const nameLength = view.getUint16(26, true);
|
|
1165
|
+
const rawName = bytes.subarray(30, 30 + nameLength);
|
|
1166
|
+
const utf8 = (flags & FLAG_UTF8) !== 0;
|
|
1167
|
+
let path = decodeName(rawName, utf8);
|
|
1168
|
+
// As in Info-ZIP and 7-Zip, only the first Unicode path field is read, and
|
|
1169
|
+
// only without the UTF-8 flag
|
|
1170
|
+
let readUnicodePath = !utf8;
|
|
1171
|
+
let seconds;
|
|
1172
|
+
let zip64 = false;
|
|
1173
|
+
let at = 30 + nameLength;
|
|
1174
|
+
while (at + 4 <= bytes.length) {
|
|
1175
|
+
const id = view.getUint16(at, true);
|
|
1176
|
+
const start = at + 4;
|
|
1177
|
+
const end = start + view.getUint16(at + 2, true);
|
|
1178
|
+
if (end > bytes.length) throw invalidHeader("extra field overflows the header");
|
|
1179
|
+
if (id === EXTRA_ZIP64) {
|
|
1180
|
+
zip64 = true;
|
|
1181
|
+
let field = start;
|
|
1182
|
+
if (size === MAX32 && field + 8 <= end) {
|
|
1183
|
+
size = getUint64(view, field);
|
|
1184
|
+
field += 8;
|
|
1185
|
+
}
|
|
1186
|
+
if (compressedSize === MAX32 && field + 8 <= end) {
|
|
1187
|
+
compressedSize = getUint64(view, field);
|
|
1188
|
+
}
|
|
1189
|
+
} else if (id === EXTRA_TIMESTAMP && end - start >= 5 && (bytes[start] & 1) !== 0) {
|
|
1190
|
+
// Info-ZIP writes times before 1970 as negative numbers, and others
|
|
1191
|
+
// write times after 2038 as unsigned ones; the DOS date tells them apart
|
|
1192
|
+
const value = view.getUint32(start + 1, true);
|
|
1193
|
+
seconds = value >= 0x80000000 && (date >> 9) + 1980 < 2038 ? value - 0x100000000 : value;
|
|
1194
|
+
} else if (id === EXTRA_UNICODE_PATH && readUnicodePath) {
|
|
1195
|
+
readUnicodePath = false;
|
|
1196
|
+
if (end - start >= 5 && bytes[start] === 1 && view.getUint32(start + 1, true) === crc32(0, rawName)) {
|
|
1197
|
+
path = textDecoder.decode(bytes.subarray(start + 5, end));
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
at = end;
|
|
1201
|
+
}
|
|
1202
|
+
const quoted = JSON.stringify(path);
|
|
1203
|
+
// Other tools end the name at a NUL character, or reject it
|
|
1204
|
+
if (path.includes("\0")) throw invalidHeader(`path ${quoted} contains a NUL character`);
|
|
1205
|
+
if ((flags & (FLAG_ENCRYPTED | FLAG_STRONG_ENCRYPTION)) !== 0) throw unsupported(`entry ${quoted} is encrypted`);
|
|
1206
|
+
if (method !== 0 && method !== 8) throw unsupported(`entry ${quoted} uses compression method ${method}`);
|
|
1207
|
+
const descriptor = (flags & FLAG_DESCRIPTOR) !== 0;
|
|
1208
|
+
// Writers that put sizes after the data usually leave zeros here
|
|
1209
|
+
const known = !descriptor || compressedSize !== 0 || size !== 0;
|
|
1210
|
+
// Searching for the descriptor of stored data would let its content forge
|
|
1211
|
+
// the entries after it
|
|
1212
|
+
if (method === 0 && !known) throw unsupported(`stored entry ${quoted} has no size before its data`);
|
|
1213
|
+
if (method === 0 && compressedSize !== size) {
|
|
1214
|
+
throw invalidHeader(`stored entry ${quoted} has different sizes`);
|
|
1215
|
+
}
|
|
1216
|
+
const header = {
|
|
1217
|
+
path,
|
|
1218
|
+
type: path.endsWith("/") ? "Directory" : "File",
|
|
1219
|
+
method: method === 8 ? "Deflate" : "Store",
|
|
1220
|
+
mtime: new Date(seconds === undefined ? fromDos(time, date) : seconds * 1000),
|
|
1221
|
+
...(known && (method === 0 || !descriptor) ? {
|
|
1222
|
+
size
|
|
1223
|
+
} : undefined)
|
|
1224
|
+
};
|
|
1225
|
+
return {
|
|
1226
|
+
header,
|
|
1227
|
+
inflater: method === 8 ? new Inflater(this.queue, this.inflateMemory ??= new InflateMemory()) : undefined,
|
|
1228
|
+
descriptor,
|
|
1229
|
+
zip64,
|
|
1230
|
+
crc,
|
|
1231
|
+
compressedSize: known ? compressedSize : undefined,
|
|
1232
|
+
size: known ? size : undefined,
|
|
1233
|
+
start: this.queue.consumed,
|
|
1234
|
+
remaining: method === 0 ? compressedSize : 0,
|
|
1235
|
+
dataDone: false,
|
|
1236
|
+
actualCrc: 0,
|
|
1237
|
+
actualSize: 0,
|
|
1238
|
+
actualCompressedSize: 0
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
needInput() {
|
|
1242
|
+
if (this.ended) throw truncated(this.queue.consumed + this.queue.length);
|
|
1243
|
+
return NeedInput;
|
|
1244
|
+
}
|
|
1245
|
+
finish() {
|
|
1246
|
+
this.finished = true;
|
|
1247
|
+
this.queue.clear();
|
|
1248
|
+
return this.ended ? undefined : NeedInput;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
const hex = n => `0x${n.toString(16).padStart(8, "0")}`;
|
|
1252
|
+
// A ZIP64 data descriptor with its signature, and the signature after it
|
|
1253
|
+
const DESCRIPTOR_PEEK = 28;
|
|
1254
|
+
const isHeaderSignature = signature => signature === LOCAL || signature === CENTRAL || signature === END || signature === END64;
|
|
1255
|
+
//# sourceMappingURL=Zip.js.map
|