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.
Files changed (1079) hide show
  1. package/ai-docs/package.json +1 -1
  2. package/ai-docs/src/06_schedule/10_schedules.ts +5 -4
  3. package/ai-docs/src/52_graphql/10_basics.ts +19 -13
  4. package/ai-docs/src/52_graphql/30_batching.ts +6 -4
  5. package/ai-docs/src/52_graphql/40_aliased-batching.ts +6 -4
  6. package/ai-docs/tsconfig.json +3 -1
  7. package/dist/Array.d.ts +207 -58
  8. package/dist/Array.d.ts.map +1 -1
  9. package/dist/Array.js +45 -22
  10. package/dist/Array.js.map +1 -1
  11. package/dist/Bytes.d.ts +79 -0
  12. package/dist/Bytes.d.ts.map +1 -0
  13. package/dist/Bytes.js +109 -0
  14. package/dist/Bytes.js.map +1 -0
  15. package/dist/Channel.d.ts +187 -14
  16. package/dist/Channel.d.ts.map +1 -1
  17. package/dist/Channel.js +142 -33
  18. package/dist/Channel.js.map +1 -1
  19. package/dist/ChannelSchema.d.ts.map +1 -1
  20. package/dist/ChannelSchema.js.map +1 -1
  21. package/dist/Chunk.d.ts +39 -21
  22. package/dist/Chunk.d.ts.map +1 -1
  23. package/dist/Chunk.js +26 -17
  24. package/dist/Chunk.js.map +1 -1
  25. package/dist/Config.d.ts.map +1 -1
  26. package/dist/Config.js +8 -3
  27. package/dist/Config.js.map +1 -1
  28. package/dist/ConfigProvider.d.ts.map +1 -1
  29. package/dist/ConfigProvider.js +34 -32
  30. package/dist/ConfigProvider.js.map +1 -1
  31. package/dist/Cron.d.ts +2 -2
  32. package/dist/Cron.d.ts.map +1 -1
  33. package/dist/Cron.js +6 -3
  34. package/dist/Cron.js.map +1 -1
  35. package/dist/Duration.d.ts.map +1 -1
  36. package/dist/Duration.js +58 -21
  37. package/dist/Duration.js.map +1 -1
  38. package/dist/Effect.d.ts +548 -182
  39. package/dist/Effect.d.ts.map +1 -1
  40. package/dist/Effect.js +261 -76
  41. package/dist/Effect.js.map +1 -1
  42. package/dist/Equivalence.d.ts +2 -1
  43. package/dist/Equivalence.d.ts.map +1 -1
  44. package/dist/Equivalence.js +12 -8
  45. package/dist/Equivalence.js.map +1 -1
  46. package/dist/Exit.d.ts +24 -9
  47. package/dist/Exit.d.ts.map +1 -1
  48. package/dist/Exit.js +8 -3
  49. package/dist/Exit.js.map +1 -1
  50. package/dist/FiberHandle.d.ts +2 -0
  51. package/dist/FiberHandle.d.ts.map +1 -1
  52. package/dist/FiberHandle.js +9 -4
  53. package/dist/FiberHandle.js.map +1 -1
  54. package/dist/FiberMap.d.ts +2 -0
  55. package/dist/FiberMap.d.ts.map +1 -1
  56. package/dist/FiberMap.js +5 -2
  57. package/dist/FiberMap.js.map +1 -1
  58. package/dist/FileSystem.d.ts +28 -9
  59. package/dist/FileSystem.d.ts.map +1 -1
  60. package/dist/FileSystem.js +3 -0
  61. package/dist/FileSystem.js.map +1 -1
  62. package/dist/Graph.d.ts.map +1 -1
  63. package/dist/Graph.js.map +1 -1
  64. package/dist/HashSet.d.ts.map +1 -1
  65. package/dist/HashSet.js.map +1 -1
  66. package/dist/Iterable.d.ts.map +1 -1
  67. package/dist/Iterable.js +18 -17
  68. package/dist/Iterable.js.map +1 -1
  69. package/dist/JsonSchema.d.ts +9 -3
  70. package/dist/JsonSchema.d.ts.map +1 -1
  71. package/dist/JsonSchema.js +19 -3
  72. package/dist/JsonSchema.js.map +1 -1
  73. package/dist/Layer.d.ts.map +1 -1
  74. package/dist/Layer.js +2 -2
  75. package/dist/Layer.js.map +1 -1
  76. package/dist/ManagedRuntime.d.ts +19 -1
  77. package/dist/ManagedRuntime.d.ts.map +1 -1
  78. package/dist/ManagedRuntime.js +62 -6
  79. package/dist/ManagedRuntime.js.map +1 -1
  80. package/dist/Match.d.ts +20 -6
  81. package/dist/Match.d.ts.map +1 -1
  82. package/dist/Match.js +2 -2
  83. package/dist/Match.js.map +1 -1
  84. package/dist/Metric.d.ts +132 -0
  85. package/dist/Metric.d.ts.map +1 -1
  86. package/dist/Metric.js +197 -25
  87. package/dist/Metric.js.map +1 -1
  88. package/dist/MutableHashMap.d.ts.map +1 -1
  89. package/dist/MutableHashMap.js.map +1 -1
  90. package/dist/Number.js +2 -2
  91. package/dist/Number.js.map +1 -1
  92. package/dist/Optic.d.ts.map +1 -1
  93. package/dist/Optic.js.map +1 -1
  94. package/dist/Path.d.ts +37 -5
  95. package/dist/Path.d.ts.map +1 -1
  96. package/dist/Path.js +44 -6
  97. package/dist/Path.js.map +1 -1
  98. package/dist/PubSub.d.ts.map +1 -1
  99. package/dist/PubSub.js +12 -7
  100. package/dist/PubSub.js.map +1 -1
  101. package/dist/Queue.d.ts +4 -1
  102. package/dist/Queue.d.ts.map +1 -1
  103. package/dist/Queue.js +4 -1
  104. package/dist/Queue.js.map +1 -1
  105. package/dist/Random.d.ts.map +1 -1
  106. package/dist/Random.js +1 -1
  107. package/dist/Random.js.map +1 -1
  108. package/dist/RcMap.d.ts +12 -7
  109. package/dist/RcMap.d.ts.map +1 -1
  110. package/dist/RcMap.js +9 -6
  111. package/dist/RcMap.js.map +1 -1
  112. package/dist/Record.d.ts +51 -0
  113. package/dist/Record.d.ts.map +1 -1
  114. package/dist/Record.js +17 -0
  115. package/dist/Record.js.map +1 -1
  116. package/dist/Ref.d.ts.map +1 -1
  117. package/dist/Ref.js.map +1 -1
  118. package/dist/References.d.ts +5 -4
  119. package/dist/References.d.ts.map +1 -1
  120. package/dist/References.js +5 -4
  121. package/dist/References.js.map +1 -1
  122. package/dist/RequestResolver.d.ts +31 -1
  123. package/dist/RequestResolver.d.ts.map +1 -1
  124. package/dist/RequestResolver.js +39 -4
  125. package/dist/RequestResolver.js.map +1 -1
  126. package/dist/Resource.js +1 -1
  127. package/dist/Resource.js.map +1 -1
  128. package/dist/Runtime.d.ts +3 -3
  129. package/dist/Runtime.d.ts.map +1 -1
  130. package/dist/Runtime.js +18 -15
  131. package/dist/Runtime.js.map +1 -1
  132. package/dist/Schedule.d.ts.map +1 -1
  133. package/dist/Schedule.js.map +1 -1
  134. package/dist/Schema.d.ts +383 -326
  135. package/dist/Schema.d.ts.map +1 -1
  136. package/dist/Schema.js +338 -17
  137. package/dist/Schema.js.map +1 -1
  138. package/dist/SchemaAST.d.ts +5 -5
  139. package/dist/SchemaAST.d.ts.map +1 -1
  140. package/dist/SchemaAST.js +24 -8
  141. package/dist/SchemaAST.js.map +1 -1
  142. package/dist/SchemaGetter.d.ts +8 -3
  143. package/dist/SchemaGetter.d.ts.map +1 -1
  144. package/dist/SchemaGetter.js +15 -5
  145. package/dist/SchemaGetter.js.map +1 -1
  146. package/dist/SchemaIssue.d.ts +4 -4
  147. package/dist/SchemaIssue.d.ts.map +1 -1
  148. package/dist/SchemaIssue.js +29 -51
  149. package/dist/SchemaIssue.js.map +1 -1
  150. package/dist/SchemaRepresentation.d.ts +56 -1
  151. package/dist/SchemaRepresentation.d.ts.map +1 -1
  152. package/dist/SchemaRepresentation.js +18 -0
  153. package/dist/SchemaRepresentation.js.map +1 -1
  154. package/dist/SchemaTransformation.d.ts +1 -1
  155. package/dist/SchemaTransformation.js +1 -1
  156. package/dist/Scope.d.ts +12 -2
  157. package/dist/Scope.d.ts.map +1 -1
  158. package/dist/Scope.js +5 -0
  159. package/dist/Scope.js.map +1 -1
  160. package/dist/ScopedCache.d.ts +10 -7
  161. package/dist/ScopedCache.d.ts.map +1 -1
  162. package/dist/ScopedCache.js +9 -5
  163. package/dist/ScopedCache.js.map +1 -1
  164. package/dist/SemVer.d.ts +1196 -0
  165. package/dist/SemVer.d.ts.map +1 -0
  166. package/dist/SemVer.js +756 -0
  167. package/dist/SemVer.js.map +1 -0
  168. package/dist/SemVerRange.d.ts +559 -0
  169. package/dist/SemVerRange.d.ts.map +1 -0
  170. package/dist/SemVerRange.js +551 -0
  171. package/dist/SemVerRange.js.map +1 -0
  172. package/dist/Sink.d.ts.map +1 -1
  173. package/dist/Sink.js +6 -2
  174. package/dist/Sink.js.map +1 -1
  175. package/dist/Stream.d.ts +235 -8
  176. package/dist/Stream.d.ts.map +1 -1
  177. package/dist/Stream.js +145 -60
  178. package/dist/Stream.js.map +1 -1
  179. package/dist/String.d.ts +16 -2
  180. package/dist/String.d.ts.map +1 -1
  181. package/dist/String.js +25 -10
  182. package/dist/String.js.map +1 -1
  183. package/dist/TextDiff.d.ts +399 -0
  184. package/dist/TextDiff.d.ts.map +1 -0
  185. package/dist/TextDiff.js +634 -0
  186. package/dist/TextDiff.js.map +1 -0
  187. package/dist/TxHashMap.d.ts.map +1 -1
  188. package/dist/TxHashMap.js.map +1 -1
  189. package/dist/TxHashSet.d.ts.map +1 -1
  190. package/dist/TxHashSet.js.map +1 -1
  191. package/dist/TxRef.d.ts.map +1 -1
  192. package/dist/TxRef.js +3 -2
  193. package/dist/TxRef.js.map +1 -1
  194. package/dist/ai/AiError.d.ts +78 -14
  195. package/dist/ai/AiError.d.ts.map +1 -1
  196. package/dist/ai/AiError.js +51 -3
  197. package/dist/ai/AiError.js.map +1 -1
  198. package/dist/ai/Chat.d.ts +1 -2
  199. package/dist/ai/Chat.d.ts.map +1 -1
  200. package/dist/ai/Chat.js +6 -3
  201. package/dist/ai/Chat.js.map +1 -1
  202. package/dist/ai/Decision.d.ts +116 -20
  203. package/dist/ai/Decision.d.ts.map +1 -1
  204. package/dist/ai/Decision.js +37 -3
  205. package/dist/ai/Decision.js.map +1 -1
  206. package/dist/ai/DecisionModel.d.ts +129 -11
  207. package/dist/ai/DecisionModel.d.ts.map +1 -1
  208. package/dist/ai/DecisionModel.js +183 -95
  209. package/dist/ai/DecisionModel.js.map +1 -1
  210. package/dist/ai/EmbeddingModel.d.ts +10 -0
  211. package/dist/ai/EmbeddingModel.d.ts.map +1 -1
  212. package/dist/ai/EmbeddingModel.js +21 -7
  213. package/dist/ai/EmbeddingModel.js.map +1 -1
  214. package/dist/ai/LanguageModel.d.ts.map +1 -1
  215. package/dist/ai/LanguageModel.js +47 -35
  216. package/dist/ai/LanguageModel.js.map +1 -1
  217. package/dist/ai/McpClient.d.ts +289 -0
  218. package/dist/ai/McpClient.d.ts.map +1 -0
  219. package/dist/ai/McpClient.js +819 -0
  220. package/dist/ai/McpClient.js.map +1 -0
  221. package/dist/ai/McpClientError.d.ts +254 -0
  222. package/dist/ai/McpClientError.d.ts.map +1 -0
  223. package/dist/ai/McpClientError.js +260 -0
  224. package/dist/ai/McpClientError.js.map +1 -0
  225. package/dist/ai/McpProtocol.d.ts +2 -2
  226. package/dist/ai/McpProtocol.d.ts.map +1 -1
  227. package/dist/ai/McpSchema.d.ts +368 -235
  228. package/dist/ai/McpSchema.d.ts.map +1 -1
  229. package/dist/ai/McpSchema.js +94 -24
  230. package/dist/ai/McpSchema.js.map +1 -1
  231. package/dist/ai/McpServer.d.ts +6 -52
  232. package/dist/ai/McpServer.d.ts.map +1 -1
  233. package/dist/ai/McpServer.js +27 -50
  234. package/dist/ai/McpServer.js.map +1 -1
  235. package/dist/ai/Prompt.d.ts +22 -20
  236. package/dist/ai/Prompt.d.ts.map +1 -1
  237. package/dist/ai/Prompt.js +23 -1
  238. package/dist/ai/Prompt.js.map +1 -1
  239. package/dist/ai/Response.d.ts +148 -4
  240. package/dist/ai/Response.d.ts.map +1 -1
  241. package/dist/ai/Response.js +35 -37
  242. package/dist/ai/Response.js.map +1 -1
  243. package/dist/ai/Tool.d.ts +12 -4
  244. package/dist/ai/Tool.d.ts.map +1 -1
  245. package/dist/ai/Tool.js.map +1 -1
  246. package/dist/ai/Toolkit.d.ts +48 -1
  247. package/dist/ai/Toolkit.d.ts.map +1 -1
  248. package/dist/ai/Toolkit.js +65 -12
  249. package/dist/ai/Toolkit.js.map +1 -1
  250. package/dist/ai/index.d.ts +10 -0
  251. package/dist/ai/index.d.ts.map +1 -1
  252. package/dist/ai/index.js +10 -0
  253. package/dist/ai/index.js.map +1 -1
  254. package/dist/ai/internal/mcpCore.js.map +1 -1
  255. package/dist/ai/internal/mcpProtocol/v2024_11_05.js +1 -1
  256. package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
  257. package/dist/ai/internal/mcpProtocol/v2025_03_26.js +1 -1
  258. package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
  259. package/dist/ai/internal/mcpProtocol/v2025_06_18.js +2 -2
  260. package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
  261. package/dist/ai/internal/mcpProtocol/v2025_11_25.js +2 -2
  262. package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
  263. package/dist/ai/internal/mcpProtocol/v2026_07_28.js +4 -7
  264. package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
  265. package/dist/ai/internal/mcpProtocol.js +16 -2
  266. package/dist/ai/internal/mcpProtocol.js.map +1 -1
  267. package/dist/ai/internal/mcpRuntime.js +3 -4
  268. package/dist/ai/internal/mcpRuntime.js.map +1 -1
  269. package/dist/ai/internal/mcpSchema/v2024_11_05.js +19 -13
  270. package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
  271. package/dist/ai/internal/mcpSchema/v2025_03_26.js +3 -2
  272. package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
  273. package/dist/ai/internal/mcpSchema/v2025_06_18.js +7 -7
  274. package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
  275. package/dist/ai/internal/mcpSchema/v2025_11_25.js +8 -8
  276. package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
  277. package/dist/ai/internal/mcpSchema/v2026_07_28.js +43 -42
  278. package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
  279. package/dist/cli/CliError.d.ts +42 -2
  280. package/dist/cli/CliError.d.ts.map +1 -1
  281. package/dist/cli/CliError.js +44 -5
  282. package/dist/cli/CliError.js.map +1 -1
  283. package/dist/cli/Command.d.ts +286 -2
  284. package/dist/cli/Command.d.ts.map +1 -1
  285. package/dist/cli/Command.js +107 -6
  286. package/dist/cli/Command.js.map +1 -1
  287. package/dist/cli/Completions.d.ts +10 -0
  288. package/dist/cli/Completions.d.ts.map +1 -1
  289. package/dist/cli/Completions.js.map +1 -1
  290. package/dist/cli/Flag.d.ts +215 -0
  291. package/dist/cli/Flag.d.ts.map +1 -1
  292. package/dist/cli/Flag.js +89 -0
  293. package/dist/cli/Flag.js.map +1 -1
  294. package/dist/cli/GlobalFlag.d.ts.map +1 -1
  295. package/dist/cli/GlobalFlag.js +3 -3
  296. package/dist/cli/GlobalFlag.js.map +1 -1
  297. package/dist/cli/Param.d.ts +194 -0
  298. package/dist/cli/Param.d.ts.map +1 -1
  299. package/dist/cli/Param.js +86 -0
  300. package/dist/cli/Param.js.map +1 -1
  301. package/dist/cli/TerminalCapabilities.d.ts +84 -0
  302. package/dist/cli/TerminalCapabilities.d.ts.map +1 -0
  303. package/dist/cli/TerminalCapabilities.js +122 -0
  304. package/dist/cli/TerminalCapabilities.js.map +1 -0
  305. package/dist/cli/index.d.ts +5 -0
  306. package/dist/cli/index.d.ts.map +1 -1
  307. package/dist/cli/index.js +5 -0
  308. package/dist/cli/index.js.map +1 -1
  309. package/dist/cli/internal/command.d.ts +2 -1
  310. package/dist/cli/internal/command.d.ts.map +1 -1
  311. package/dist/cli/internal/command.js +7 -3
  312. package/dist/cli/internal/command.js.map +1 -1
  313. package/dist/cli/internal/completions/bash.js +7 -5
  314. package/dist/cli/internal/completions/bash.js.map +1 -1
  315. package/dist/cli/internal/completions/descriptor.js +16 -1
  316. package/dist/cli/internal/completions/descriptor.js.map +1 -1
  317. package/dist/cli/internal/completions/fish.js +12 -10
  318. package/dist/cli/internal/completions/fish.js.map +1 -1
  319. package/dist/cli/internal/completions/powershell.js +20 -10
  320. package/dist/cli/internal/completions/powershell.js.map +1 -1
  321. package/dist/cli/internal/completions/zsh.js +15 -8
  322. package/dist/cli/internal/completions/zsh.js.map +1 -1
  323. package/dist/cli/internal/formatter.d.ts +2 -0
  324. package/dist/cli/internal/formatter.d.ts.map +1 -0
  325. package/dist/cli/internal/formatter.js +15 -0
  326. package/dist/cli/internal/formatter.js.map +1 -0
  327. package/dist/cli/internal/lexer.js +24 -10
  328. package/dist/cli/internal/lexer.js.map +1 -1
  329. package/dist/cli/internal/parser.js +35 -15
  330. package/dist/cli/internal/parser.js.map +1 -1
  331. package/dist/cli/internal/wizard.d.ts.map +1 -1
  332. package/dist/cli/internal/wizard.js +2 -1
  333. package/dist/cli/internal/wizard.js.map +1 -1
  334. package/dist/cluster/ClusterCron.d.ts +29 -1
  335. package/dist/cluster/ClusterCron.d.ts.map +1 -1
  336. package/dist/cluster/ClusterCron.js +64 -32
  337. package/dist/cluster/ClusterCron.js.map +1 -1
  338. package/dist/cluster/ClusterMetrics.d.ts +143 -7
  339. package/dist/cluster/ClusterMetrics.d.ts.map +1 -1
  340. package/dist/cluster/ClusterMetrics.js +151 -7
  341. package/dist/cluster/ClusterMetrics.js.map +1 -1
  342. package/dist/cluster/ClusterWorkflowEngine.d.ts +2 -1
  343. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  344. package/dist/cluster/ClusterWorkflowEngine.js +98 -18
  345. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  346. package/dist/cluster/Entity.d.ts +2 -0
  347. package/dist/cluster/Entity.d.ts.map +1 -1
  348. package/dist/cluster/Entity.js.map +1 -1
  349. package/dist/cluster/MessageStorage.d.ts +21 -0
  350. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  351. package/dist/cluster/MessageStorage.js +20 -12
  352. package/dist/cluster/MessageStorage.js.map +1 -1
  353. package/dist/cluster/Runners.d.ts.map +1 -1
  354. package/dist/cluster/Runners.js +96 -37
  355. package/dist/cluster/Runners.js.map +1 -1
  356. package/dist/cluster/Sharding.d.ts +1 -0
  357. package/dist/cluster/Sharding.d.ts.map +1 -1
  358. package/dist/cluster/Sharding.js +95 -32
  359. package/dist/cluster/Sharding.js.map +1 -1
  360. package/dist/cluster/ShardingConfig.d.ts +20 -0
  361. package/dist/cluster/ShardingConfig.d.ts.map +1 -1
  362. package/dist/cluster/ShardingConfig.js +4 -0
  363. package/dist/cluster/ShardingConfig.js.map +1 -1
  364. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  365. package/dist/cluster/SqlMessageStorage.js +40 -50
  366. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  367. package/dist/cluster/SqlRunnerStorage.d.ts +2 -2
  368. package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
  369. package/dist/cluster/SqlRunnerStorage.js +10 -4
  370. package/dist/cluster/SqlRunnerStorage.js.map +1 -1
  371. package/dist/cluster/internal/entityManager.js +66 -9
  372. package/dist/cluster/internal/entityManager.js.map +1 -1
  373. package/dist/devtools/DevTools.d.ts +3 -2
  374. package/dist/devtools/DevTools.d.ts.map +1 -1
  375. package/dist/devtools/DevTools.js +3 -2
  376. package/dist/devtools/DevTools.js.map +1 -1
  377. package/dist/devtools/DevToolsClient.d.ts +11 -0
  378. package/dist/devtools/DevToolsClient.d.ts.map +1 -1
  379. package/dist/devtools/DevToolsClient.js +31 -4
  380. package/dist/devtools/DevToolsClient.js.map +1 -1
  381. package/dist/encoding/Base64Url.d.ts +29 -0
  382. package/dist/encoding/Base64Url.d.ts.map +1 -1
  383. package/dist/encoding/Base64Url.js +29 -0
  384. package/dist/encoding/Base64Url.js.map +1 -1
  385. package/dist/encoding/Ini.d.ts.map +1 -1
  386. package/dist/encoding/Ini.js +3 -0
  387. package/dist/encoding/Ini.js.map +1 -1
  388. package/dist/encoding/JsonArray.d.ts +270 -0
  389. package/dist/encoding/JsonArray.d.ts.map +1 -0
  390. package/dist/encoding/JsonArray.js +691 -0
  391. package/dist/encoding/JsonArray.js.map +1 -0
  392. package/dist/encoding/Ndjson.d.ts +43 -4
  393. package/dist/encoding/Ndjson.d.ts.map +1 -1
  394. package/dist/encoding/Ndjson.js +169 -18
  395. package/dist/encoding/Ndjson.js.map +1 -1
  396. package/dist/encoding/SchemaBinary.d.ts +9 -1
  397. package/dist/encoding/SchemaBinary.d.ts.map +1 -1
  398. package/dist/encoding/SchemaBinary.js +12 -19
  399. package/dist/encoding/SchemaBinary.js.map +1 -1
  400. package/dist/encoding/Sse.js +1 -1
  401. package/dist/encoding/Sse.js.map +1 -1
  402. package/dist/encoding/Tar.d.ts +309 -0
  403. package/dist/encoding/Tar.d.ts.map +1 -0
  404. package/dist/encoding/Tar.js +1182 -0
  405. package/dist/encoding/Tar.js.map +1 -0
  406. package/dist/encoding/Toml.js +3 -3
  407. package/dist/encoding/Toml.js.map +1 -1
  408. package/dist/encoding/Xml.d.ts +464 -0
  409. package/dist/encoding/Xml.d.ts.map +1 -0
  410. package/dist/encoding/Xml.js +1619 -0
  411. package/dist/encoding/Xml.js.map +1 -0
  412. package/dist/encoding/Yaml.d.ts +6 -2
  413. package/dist/encoding/Yaml.d.ts.map +1 -1
  414. package/dist/encoding/Yaml.js +97 -34
  415. package/dist/encoding/Yaml.js.map +1 -1
  416. package/dist/encoding/Zip.d.ts +413 -0
  417. package/dist/encoding/Zip.d.ts.map +1 -0
  418. package/dist/encoding/Zip.js +1255 -0
  419. package/dist/encoding/Zip.js.map +1 -0
  420. package/dist/encoding/index.d.ts +20 -0
  421. package/dist/encoding/index.d.ts.map +1 -1
  422. package/dist/encoding/index.js +20 -0
  423. package/dist/encoding/index.js.map +1 -1
  424. package/dist/eventlog/EventJournal.d.ts +90 -5
  425. package/dist/eventlog/EventJournal.d.ts.map +1 -1
  426. package/dist/eventlog/EventJournal.js +488 -228
  427. package/dist/eventlog/EventJournal.js.map +1 -1
  428. package/dist/eventlog/EventLog.d.ts +180 -12
  429. package/dist/eventlog/EventLog.d.ts.map +1 -1
  430. package/dist/eventlog/EventLog.js +394 -146
  431. package/dist/eventlog/EventLog.js.map +1 -1
  432. package/dist/eventlog/EventLogEncryption.d.ts +36 -30
  433. package/dist/eventlog/EventLogEncryption.d.ts.map +1 -1
  434. package/dist/eventlog/EventLogEncryption.js +97 -38
  435. package/dist/eventlog/EventLogEncryption.js.map +1 -1
  436. package/dist/eventlog/EventLogMessage.d.ts +74 -34
  437. package/dist/eventlog/EventLogMessage.d.ts.map +1 -1
  438. package/dist/eventlog/EventLogMessage.js +45 -11
  439. package/dist/eventlog/EventLogMessage.js.map +1 -1
  440. package/dist/eventlog/EventLogRemote.d.ts +45 -8
  441. package/dist/eventlog/EventLogRemote.d.ts.map +1 -1
  442. package/dist/eventlog/EventLogRemote.js +51 -14
  443. package/dist/eventlog/EventLogRemote.js.map +1 -1
  444. package/dist/eventlog/EventLogServer.d.ts +46 -3
  445. package/dist/eventlog/EventLogServer.d.ts.map +1 -1
  446. package/dist/eventlog/EventLogServer.js +119 -19
  447. package/dist/eventlog/EventLogServer.js.map +1 -1
  448. package/dist/eventlog/EventLogServerEncrypted.d.ts +23 -33
  449. package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
  450. package/dist/eventlog/EventLogServerEncrypted.js +97 -70
  451. package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
  452. package/dist/eventlog/EventLogServerUnencrypted.d.ts +39 -5
  453. package/dist/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
  454. package/dist/eventlog/EventLogServerUnencrypted.js +151 -69
  455. package/dist/eventlog/EventLogServerUnencrypted.js.map +1 -1
  456. package/dist/eventlog/EventRow.d.ts +288 -0
  457. package/dist/eventlog/EventRow.d.ts.map +1 -0
  458. package/dist/eventlog/EventRow.js +435 -0
  459. package/dist/eventlog/EventRow.js.map +1 -0
  460. package/dist/eventlog/SqlEventJournal.d.ts +18 -18
  461. package/dist/eventlog/SqlEventJournal.d.ts.map +1 -1
  462. package/dist/eventlog/SqlEventJournal.js +387 -159
  463. package/dist/eventlog/SqlEventJournal.js.map +1 -1
  464. package/dist/eventlog/SqlEventLogServerEncrypted.d.ts +10 -18
  465. package/dist/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
  466. package/dist/eventlog/SqlEventLogServerEncrypted.js +179 -69
  467. package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
  468. package/dist/eventlog/SqlEventLogServerUnencrypted.d.ts +23 -3
  469. package/dist/eventlog/SqlEventLogServerUnencrypted.d.ts.map +1 -1
  470. package/dist/eventlog/SqlEventLogServerUnencrypted.js +102 -51
  471. package/dist/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
  472. package/dist/eventlog/index.d.ts +5 -0
  473. package/dist/eventlog/index.d.ts.map +1 -1
  474. package/dist/eventlog/index.js +5 -0
  475. package/dist/eventlog/index.js.map +1 -1
  476. package/dist/eventlog/internal/conflicts.d.ts +47 -0
  477. package/dist/eventlog/internal/conflicts.d.ts.map +1 -0
  478. package/dist/eventlog/internal/conflicts.js +92 -0
  479. package/dist/eventlog/internal/conflicts.js.map +1 -0
  480. package/dist/graphql/GraphQLClient.d.ts.map +1 -1
  481. package/dist/graphql/GraphQLClient.js +12 -5
  482. package/dist/graphql/GraphQLClient.js.map +1 -1
  483. package/dist/graphql/GraphQLClientError.d.ts +2 -2
  484. package/dist/graphql/GraphQLClientError.d.ts.map +1 -1
  485. package/dist/graphql/GraphQLClientError.js +4 -18
  486. package/dist/graphql/GraphQLClientError.js.map +1 -1
  487. package/dist/graphql/GraphQLProtocol.d.ts +252 -11
  488. package/dist/graphql/GraphQLProtocol.d.ts.map +1 -1
  489. package/dist/graphql/GraphQLProtocol.js +99 -8
  490. package/dist/graphql/GraphQLProtocol.js.map +1 -1
  491. package/dist/graphql/GraphQLResolver.d.ts +3 -1
  492. package/dist/graphql/GraphQLResolver.d.ts.map +1 -1
  493. package/dist/graphql/GraphQLResolver.js +91 -19
  494. package/dist/graphql/GraphQLResolver.js.map +1 -1
  495. package/dist/http/FetchHttpClient.d.ts +13 -3
  496. package/dist/http/FetchHttpClient.d.ts.map +1 -1
  497. package/dist/http/FetchHttpClient.js +56 -6
  498. package/dist/http/FetchHttpClient.js.map +1 -1
  499. package/dist/http/FindMyWay/internal/router.js +12 -1
  500. package/dist/http/FindMyWay/internal/router.js.map +1 -1
  501. package/dist/http/Headers.d.ts +230 -3
  502. package/dist/http/Headers.d.ts.map +1 -1
  503. package/dist/http/Headers.js +267 -5
  504. package/dist/http/Headers.js.map +1 -1
  505. package/dist/http/HttpClient.d.ts +105 -0
  506. package/dist/http/HttpClient.d.ts.map +1 -1
  507. package/dist/http/HttpClient.js +69 -17
  508. package/dist/http/HttpClient.js.map +1 -1
  509. package/dist/http/HttpClientError.d.ts.map +1 -1
  510. package/dist/http/HttpClientError.js +8 -6
  511. package/dist/http/HttpClientError.js.map +1 -1
  512. package/dist/http/HttpClientRequest.d.ts +274 -7
  513. package/dist/http/HttpClientRequest.d.ts.map +1 -1
  514. package/dist/http/HttpClientRequest.js +91 -3
  515. package/dist/http/HttpClientRequest.js.map +1 -1
  516. package/dist/http/HttpClientResponse.d.ts +53 -0
  517. package/dist/http/HttpClientResponse.d.ts.map +1 -1
  518. package/dist/http/HttpClientResponse.js +47 -0
  519. package/dist/http/HttpClientResponse.js.map +1 -1
  520. package/dist/http/HttpEffect.d.ts +6 -2
  521. package/dist/http/HttpEffect.d.ts.map +1 -1
  522. package/dist/http/HttpEffect.js +21 -17
  523. package/dist/http/HttpEffect.js.map +1 -1
  524. package/dist/http/HttpIncomingMessage.d.ts +2 -1
  525. package/dist/http/HttpIncomingMessage.d.ts.map +1 -1
  526. package/dist/http/HttpIncomingMessage.js +3 -23
  527. package/dist/http/HttpIncomingMessage.js.map +1 -1
  528. package/dist/http/HttpMiddleware.d.ts +179 -2
  529. package/dist/http/HttpMiddleware.d.ts.map +1 -1
  530. package/dist/http/HttpMiddleware.js +226 -18
  531. package/dist/http/HttpMiddleware.js.map +1 -1
  532. package/dist/http/HttpRouter.d.ts.map +1 -1
  533. package/dist/http/HttpRouter.js +58 -14
  534. package/dist/http/HttpRouter.js.map +1 -1
  535. package/dist/http/HttpServerError.d.ts +5 -2
  536. package/dist/http/HttpServerError.d.ts.map +1 -1
  537. package/dist/http/HttpServerError.js +11 -7
  538. package/dist/http/HttpServerError.js.map +1 -1
  539. package/dist/http/HttpServerRequest.d.ts +25 -5
  540. package/dist/http/HttpServerRequest.d.ts.map +1 -1
  541. package/dist/http/HttpServerRequest.js +38 -12
  542. package/dist/http/HttpServerRequest.js.map +1 -1
  543. package/dist/http/HttpServerResponse.d.ts +17 -8
  544. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  545. package/dist/http/HttpServerResponse.js +37 -21
  546. package/dist/http/HttpServerResponse.js.map +1 -1
  547. package/dist/http/HttpStaticServer.d.ts +0 -12
  548. package/dist/http/HttpStaticServer.d.ts.map +1 -1
  549. package/dist/http/HttpStaticServer.js +25 -17
  550. package/dist/http/HttpStaticServer.js.map +1 -1
  551. package/dist/http/HttpTraceContext.js +1 -1
  552. package/dist/http/HttpTraceContext.js.map +1 -1
  553. package/dist/http/MultipartParser/internal/contentType.d.ts +15 -1
  554. package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
  555. package/dist/http/MultipartParser/internal/contentType.js +87 -5
  556. package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
  557. package/dist/http/MultipartParser/internal/headers.d.ts.map +1 -1
  558. package/dist/http/MultipartParser/internal/headers.js +4 -12
  559. package/dist/http/MultipartParser/internal/headers.js.map +1 -1
  560. package/dist/http/MultipartParser/internal/multipart.d.ts.map +1 -1
  561. package/dist/http/MultipartParser/internal/multipart.js +6 -27
  562. package/dist/http/MultipartParser/internal/multipart.js.map +1 -1
  563. package/dist/http/Url.d.ts.map +1 -1
  564. package/dist/http/Url.js +8 -2
  565. package/dist/http/Url.js.map +1 -1
  566. package/dist/http/UrlParams.d.ts +112 -8
  567. package/dist/http/UrlParams.d.ts.map +1 -1
  568. package/dist/http/UrlParams.js +141 -14
  569. package/dist/http/UrlParams.js.map +1 -1
  570. package/dist/http/internal/compression.d.ts +1 -1
  571. package/dist/http/internal/compression.d.ts.map +1 -1
  572. package/dist/http/internal/compression.js +2 -10
  573. package/dist/http/internal/compression.js.map +1 -1
  574. package/dist/http/internal/compressionBody.d.ts +2 -0
  575. package/dist/http/internal/compressionBody.d.ts.map +1 -0
  576. package/dist/http/internal/compressionBody.js +36 -0
  577. package/dist/http/internal/compressionBody.js.map +1 -0
  578. package/dist/http/internal/decompression.d.ts +2 -0
  579. package/dist/http/internal/decompression.d.ts.map +1 -0
  580. package/dist/http/internal/decompression.js +168 -0
  581. package/dist/http/internal/decompression.js.map +1 -0
  582. package/dist/http/internal/lazyStream.d.ts +2 -0
  583. package/dist/http/internal/lazyStream.d.ts.map +1 -0
  584. package/dist/http/internal/lazyStream.js +18 -0
  585. package/dist/http/internal/lazyStream.js.map +1 -0
  586. package/dist/http/internal/requestState.d.ts +2 -0
  587. package/dist/http/internal/requestState.d.ts.map +1 -0
  588. package/dist/http/internal/requestState.js +28 -0
  589. package/dist/http/internal/requestState.js.map +1 -0
  590. package/dist/http/internal/tracing.js +14 -4
  591. package/dist/http/internal/tracing.js.map +1 -1
  592. package/dist/http/internal/urlParams.d.ts +2 -0
  593. package/dist/http/internal/urlParams.d.ts.map +1 -0
  594. package/dist/http/internal/urlParams.js +4 -0
  595. package/dist/http/internal/urlParams.js.map +1 -0
  596. package/dist/http/internal/webResponse.d.ts +2 -0
  597. package/dist/http/internal/webResponse.d.ts.map +1 -0
  598. package/dist/http/internal/webResponse.js +12 -0
  599. package/dist/http/internal/webResponse.js.map +1 -0
  600. package/dist/http-api/HttpApi.js +1 -1
  601. package/dist/http-api/HttpApi.js.map +1 -1
  602. package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
  603. package/dist/http-api/HttpApiBuilder.js +121 -18
  604. package/dist/http-api/HttpApiBuilder.js.map +1 -1
  605. package/dist/http-api/HttpApiClient.d.ts +29 -4
  606. package/dist/http-api/HttpApiClient.d.ts.map +1 -1
  607. package/dist/http-api/HttpApiClient.js +85 -24
  608. package/dist/http-api/HttpApiClient.js.map +1 -1
  609. package/dist/http-api/HttpApiEndpoint.d.ts +55 -29
  610. package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
  611. package/dist/http-api/HttpApiEndpoint.js +49 -5
  612. package/dist/http-api/HttpApiEndpoint.js.map +1 -1
  613. package/dist/http-api/HttpApiError.d.ts +58 -0
  614. package/dist/http-api/HttpApiError.d.ts.map +1 -1
  615. package/dist/http-api/HttpApiError.js +38 -12
  616. package/dist/http-api/HttpApiError.js.map +1 -1
  617. package/dist/http-api/HttpApiScalar.d.ts +2 -1
  618. package/dist/http-api/HttpApiScalar.d.ts.map +1 -1
  619. package/dist/http-api/HttpApiScalar.js +6 -3
  620. package/dist/http-api/HttpApiScalar.js.map +1 -1
  621. package/dist/http-api/HttpApiSchema.d.ts +191 -9
  622. package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
  623. package/dist/http-api/HttpApiSchema.js +137 -4
  624. package/dist/http-api/HttpApiSchema.js.map +1 -1
  625. package/dist/http-api/HttpApiSwagger.d.ts +5 -0
  626. package/dist/http-api/HttpApiSwagger.d.ts.map +1 -1
  627. package/dist/http-api/HttpApiSwagger.js +14 -4
  628. package/dist/http-api/HttpApiSwagger.js.map +1 -1
  629. package/dist/http-api/HttpApiTest.d.ts +13 -2
  630. package/dist/http-api/HttpApiTest.d.ts.map +1 -1
  631. package/dist/http-api/HttpApiTest.js +30 -9
  632. package/dist/http-api/HttpApiTest.js.map +1 -1
  633. package/dist/http-api/OpenApi.d.ts +17 -3
  634. package/dist/http-api/OpenApi.d.ts.map +1 -1
  635. package/dist/http-api/OpenApi.js +57 -32
  636. package/dist/http-api/OpenApi.js.map +1 -1
  637. package/dist/http-api/internal/path.js +35 -10
  638. package/dist/http-api/internal/path.js.map +1 -1
  639. package/dist/index.d.ts +20 -0
  640. package/dist/index.d.ts.map +1 -1
  641. package/dist/index.js +20 -0
  642. package/dist/index.js.map +1 -1
  643. package/dist/internal/core.js +18 -2
  644. package/dist/internal/core.js.map +1 -1
  645. package/dist/internal/dateTime.js +19 -7
  646. package/dist/internal/dateTime.js.map +1 -1
  647. package/dist/internal/effect.js +89 -76
  648. package/dist/internal/effect.js.map +1 -1
  649. package/dist/internal/graphql.js +12 -2
  650. package/dist/internal/graphql.js.map +1 -1
  651. package/dist/internal/hashMap.js +2 -2
  652. package/dist/internal/hashMap.js.map +1 -1
  653. package/dist/internal/hydration.d.ts +2 -0
  654. package/dist/internal/hydration.d.ts.map +1 -0
  655. package/dist/internal/hydration.js +15 -0
  656. package/dist/internal/hydration.js.map +1 -0
  657. package/dist/internal/inflate.d.ts +2 -0
  658. package/dist/internal/inflate.d.ts.map +1 -0
  659. package/dist/internal/inflate.js +680 -0
  660. package/dist/internal/inflate.js.map +1 -0
  661. package/dist/internal/record.js +6 -0
  662. package/dist/internal/record.js.map +1 -1
  663. package/dist/internal/request.js +20 -7
  664. package/dist/internal/request.js.map +1 -1
  665. package/dist/internal/schedule.js +17 -22
  666. package/dist/internal/schedule.js.map +1 -1
  667. package/dist/internal/schema/fromJsonSchemaDocument.js +136 -126
  668. package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
  669. package/dist/internal/schema/interpreter.js +51 -36
  670. package/dist/internal/schema/interpreter.js.map +1 -1
  671. package/dist/internal/schema/standardSchema.js +34 -33
  672. package/dist/internal/schema/standardSchema.js.map +1 -1
  673. package/dist/internal/schema/toCodeDocument.js +7 -2
  674. package/dist/internal/schema/toCodeDocument.js.map +1 -1
  675. package/dist/internal/schema/toCodec.js +86 -1
  676. package/dist/internal/schema/toCodec.js.map +1 -1
  677. package/dist/internal/schema/toFormatter.js +5 -5
  678. package/dist/internal/schema/toFormatter.js.map +1 -1
  679. package/dist/internal/schema/toJsonSchemaDocument.js +60 -38
  680. package/dist/internal/schema/toJsonSchemaDocument.js.map +1 -1
  681. package/dist/internal/trie.js +1 -3
  682. package/dist/internal/trie.js.map +1 -1
  683. package/dist/internal/uuid.js +7 -3
  684. package/dist/internal/uuid.js.map +1 -1
  685. package/dist/internal/version.js +1 -1
  686. package/dist/net/NetAddress.d.ts.map +1 -1
  687. package/dist/net/NetAddress.js +2 -8
  688. package/dist/net/NetAddress.js.map +1 -1
  689. package/dist/observability/Otlp.d.ts +15 -0
  690. package/dist/observability/Otlp.d.ts.map +1 -1
  691. package/dist/observability/Otlp.js +3 -0
  692. package/dist/observability/Otlp.js.map +1 -1
  693. package/dist/observability/OtlpExporter.d.ts +8 -0
  694. package/dist/observability/OtlpExporter.d.ts.map +1 -1
  695. package/dist/observability/OtlpExporter.js +15 -13
  696. package/dist/observability/OtlpExporter.js.map +1 -1
  697. package/dist/observability/OtlpLogger.d.ts +17 -0
  698. package/dist/observability/OtlpLogger.d.ts.map +1 -1
  699. package/dist/observability/OtlpLogger.js +14 -1
  700. package/dist/observability/OtlpLogger.js.map +1 -1
  701. package/dist/observability/OtlpMetrics.d.ts +17 -0
  702. package/dist/observability/OtlpMetrics.d.ts.map +1 -1
  703. package/dist/observability/OtlpMetrics.js +18 -3
  704. package/dist/observability/OtlpMetrics.js.map +1 -1
  705. package/dist/observability/OtlpResource.d.ts +3 -1
  706. package/dist/observability/OtlpResource.d.ts.map +1 -1
  707. package/dist/observability/OtlpResource.js +11 -4
  708. package/dist/observability/OtlpResource.js.map +1 -1
  709. package/dist/observability/OtlpSerialization.d.ts +5 -0
  710. package/dist/observability/OtlpSerialization.d.ts.map +1 -1
  711. package/dist/observability/OtlpSerialization.js +14 -3
  712. package/dist/observability/OtlpSerialization.js.map +1 -1
  713. package/dist/observability/OtlpTracer.d.ts +17 -0
  714. package/dist/observability/OtlpTracer.d.ts.map +1 -1
  715. package/dist/observability/OtlpTracer.js +15 -2
  716. package/dist/observability/OtlpTracer.js.map +1 -1
  717. package/dist/observability/internal/protobuf.d.ts +0 -9
  718. package/dist/observability/internal/protobuf.d.ts.map +1 -1
  719. package/dist/observability/internal/protobuf.js +2 -10
  720. package/dist/observability/internal/protobuf.js.map +1 -1
  721. package/dist/persistence/PersistedCache.d.ts.map +1 -1
  722. package/dist/persistence/PersistedCache.js +1 -1
  723. package/dist/persistence/PersistedCache.js.map +1 -1
  724. package/dist/persistence/PersistedQueue.d.ts +6 -2
  725. package/dist/persistence/PersistedQueue.d.ts.map +1 -1
  726. package/dist/persistence/PersistedQueue.js +162 -84
  727. package/dist/persistence/PersistedQueue.js.map +1 -1
  728. package/dist/persistence/Persistence.d.ts +28 -0
  729. package/dist/persistence/Persistence.d.ts.map +1 -1
  730. package/dist/persistence/Persistence.js +36 -8
  731. package/dist/persistence/Persistence.js.map +1 -1
  732. package/dist/persistence/RateLimiter.d.ts.map +1 -1
  733. package/dist/persistence/RateLimiter.js +8 -12
  734. package/dist/persistence/RateLimiter.js.map +1 -1
  735. package/dist/persistence/UserDirectories.d.ts +129 -0
  736. package/dist/persistence/UserDirectories.d.ts.map +1 -0
  737. package/dist/persistence/UserDirectories.js +178 -0
  738. package/dist/persistence/UserDirectories.js.map +1 -0
  739. package/dist/persistence/index.d.ts +5 -0
  740. package/dist/persistence/index.d.ts.map +1 -1
  741. package/dist/persistence/index.js +5 -0
  742. package/dist/persistence/index.js.map +1 -1
  743. package/dist/process/ChildProcess.d.ts +2 -1
  744. package/dist/process/ChildProcess.d.ts.map +1 -1
  745. package/dist/process/ChildProcess.js.map +1 -1
  746. package/dist/reactivity/AsyncResult.d.ts +6 -0
  747. package/dist/reactivity/AsyncResult.d.ts.map +1 -1
  748. package/dist/reactivity/AsyncResult.js +28 -1
  749. package/dist/reactivity/AsyncResult.js.map +1 -1
  750. package/dist/reactivity/Atom.d.ts +69 -30
  751. package/dist/reactivity/Atom.d.ts.map +1 -1
  752. package/dist/reactivity/Atom.js +40 -15
  753. package/dist/reactivity/Atom.js.map +1 -1
  754. package/dist/reactivity/AtomHttpApi.d.ts +5 -5
  755. package/dist/reactivity/AtomHttpApi.d.ts.map +1 -1
  756. package/dist/reactivity/AtomHttpApi.js +1 -1
  757. package/dist/reactivity/AtomHttpApi.js.map +1 -1
  758. package/dist/reactivity/AtomRegistry.d.ts +2 -2
  759. package/dist/reactivity/AtomRegistry.d.ts.map +1 -1
  760. package/dist/reactivity/AtomRegistry.js +47 -10
  761. package/dist/reactivity/AtomRegistry.js.map +1 -1
  762. package/dist/reactivity/AtomRpc.d.ts +3 -3
  763. package/dist/reactivity/AtomRpc.d.ts.map +1 -1
  764. package/dist/reactivity/AtomRpc.js +1 -1
  765. package/dist/reactivity/AtomRpc.js.map +1 -1
  766. package/dist/reactivity/Hydration.d.ts.map +1 -1
  767. package/dist/reactivity/Hydration.js +46 -12
  768. package/dist/reactivity/Hydration.js.map +1 -1
  769. package/dist/reactivity/Reactivity.d.ts +71 -7
  770. package/dist/reactivity/Reactivity.d.ts.map +1 -1
  771. package/dist/reactivity/Reactivity.js +21 -12
  772. package/dist/reactivity/Reactivity.js.map +1 -1
  773. package/dist/rpc/Rpc.d.ts +18 -0
  774. package/dist/rpc/Rpc.d.ts.map +1 -1
  775. package/dist/rpc/Rpc.js +20 -0
  776. package/dist/rpc/Rpc.js.map +1 -1
  777. package/dist/rpc/RpcClient.d.ts +26 -2
  778. package/dist/rpc/RpcClient.d.ts.map +1 -1
  779. package/dist/rpc/RpcClient.js +202 -61
  780. package/dist/rpc/RpcClient.js.map +1 -1
  781. package/dist/rpc/RpcSerialization.d.ts +15 -0
  782. package/dist/rpc/RpcSerialization.d.ts.map +1 -1
  783. package/dist/rpc/RpcSerialization.js +21 -5
  784. package/dist/rpc/RpcSerialization.js.map +1 -1
  785. package/dist/rpc/RpcServer.d.ts.map +1 -1
  786. package/dist/rpc/RpcServer.js +9 -18
  787. package/dist/rpc/RpcServer.js.map +1 -1
  788. package/dist/schema/Model.d.ts +1 -1
  789. package/dist/schema/VariantSchema.d.ts +22 -3
  790. package/dist/schema/VariantSchema.d.ts.map +1 -1
  791. package/dist/schema/VariantSchema.js +32 -18
  792. package/dist/schema/VariantSchema.js.map +1 -1
  793. package/dist/socket/Socket.d.ts +23 -1
  794. package/dist/socket/Socket.d.ts.map +1 -1
  795. package/dist/socket/Socket.js +36 -3
  796. package/dist/socket/Socket.js.map +1 -1
  797. package/dist/sql/Migrator.d.ts.map +1 -1
  798. package/dist/sql/Migrator.js +15 -3
  799. package/dist/sql/Migrator.js.map +1 -1
  800. package/dist/sql/SqlClient.d.ts +151 -12
  801. package/dist/sql/SqlClient.d.ts.map +1 -1
  802. package/dist/sql/SqlClient.js +156 -34
  803. package/dist/sql/SqlClient.js.map +1 -1
  804. package/dist/sql/SqlResolver.d.ts +9 -0
  805. package/dist/sql/SqlResolver.d.ts.map +1 -1
  806. package/dist/sql/SqlResolver.js +9 -0
  807. package/dist/sql/SqlResolver.js.map +1 -1
  808. package/dist/sql/Statement.d.ts +3 -1
  809. package/dist/sql/Statement.d.ts.map +1 -1
  810. package/dist/sql/Statement.js +24 -5
  811. package/dist/sql/Statement.js.map +1 -1
  812. package/dist/testing/TestClock.d.ts +16 -3
  813. package/dist/testing/TestClock.d.ts.map +1 -1
  814. package/dist/testing/TestClock.js +115 -23
  815. package/dist/testing/TestClock.js.map +1 -1
  816. package/dist/testing/TestSchema.d.ts +7 -1
  817. package/dist/testing/TestSchema.d.ts.map +1 -1
  818. package/dist/testing/TestSchema.js +9 -3
  819. package/dist/testing/TestSchema.js.map +1 -1
  820. package/dist/workflow/Activity.js +1 -0
  821. package/dist/workflow/Activity.js.map +1 -1
  822. package/dist/workflow/Workflow.d.ts +22 -0
  823. package/dist/workflow/Workflow.d.ts.map +1 -1
  824. package/dist/workflow/Workflow.js +15 -3
  825. package/dist/workflow/Workflow.js.map +1 -1
  826. package/dist/workflow/WorkflowEngine.d.ts +20 -1
  827. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  828. package/dist/workflow/WorkflowEngine.js +52 -24
  829. package/dist/workflow/WorkflowEngine.js.map +1 -1
  830. package/package.json +13 -3
  831. package/src/Array.ts +223 -61
  832. package/src/Bytes.ts +111 -0
  833. package/src/Channel.ts +287 -439
  834. package/src/ChannelSchema.ts +1 -49
  835. package/src/Chunk.ts +55 -61
  836. package/src/Config.ts +12 -86
  837. package/src/ConfigProvider.ts +41 -44
  838. package/src/Cron.ts +6 -3
  839. package/src/Duration.ts +70 -21
  840. package/src/Effect.ts +642 -220
  841. package/src/Equivalence.ts +7 -4
  842. package/src/Exit.ts +24 -9
  843. package/src/FiberHandle.ts +10 -9
  844. package/src/FiberMap.ts +13 -66
  845. package/src/FileSystem.ts +33 -9
  846. package/src/Graph.ts +171 -1263
  847. package/src/HashSet.ts +0 -60
  848. package/src/Iterable.ts +15 -14
  849. package/src/JsonSchema.ts +28 -3
  850. package/src/Layer.ts +2 -2
  851. package/src/ManagedRuntime.ts +72 -6
  852. package/src/Match.ts +65 -12
  853. package/src/Metric.ts +249 -507
  854. package/src/MutableHashMap.ts +4 -473
  855. package/src/Number.ts +2 -2
  856. package/src/Optic.ts +17 -332
  857. package/src/Path.ts +61 -8
  858. package/src/PubSub.ts +12 -7
  859. package/src/Queue.ts +5 -37
  860. package/src/Random.ts +1 -1
  861. package/src/RcMap.ts +14 -8
  862. package/src/Record.ts +51 -0
  863. package/src/Ref.ts +7 -104
  864. package/src/References.ts +5 -4
  865. package/src/RequestResolver.ts +46 -87
  866. package/src/Resource.ts +1 -1
  867. package/src/Runtime.ts +19 -18
  868. package/src/Schedule.ts +2 -94
  869. package/src/Schema.ts +596 -348
  870. package/src/SchemaAST.ts +20 -9
  871. package/src/SchemaGetter.ts +22 -5
  872. package/src/SchemaIssue.ts +44 -53
  873. package/src/SchemaRepresentation.ts +64 -1
  874. package/src/SchemaTransformation.ts +1 -1
  875. package/src/Scope.ts +12 -2
  876. package/src/ScopedCache.ts +17 -142
  877. package/src/SemVer.ts +1528 -0
  878. package/src/SemVerRange.ts +883 -0
  879. package/src/Sink.ts +6 -2
  880. package/src/Stream.ts +334 -1011
  881. package/src/String.ts +25 -12
  882. package/src/TextDiff.ts +766 -0
  883. package/src/TxHashMap.ts +1 -103
  884. package/src/TxHashSet.ts +48 -753
  885. package/src/TxRef.ts +4 -2
  886. package/src/ai/AiError.ts +69 -5
  887. package/src/ai/Chat.ts +10 -5
  888. package/src/ai/Decision.ts +119 -22
  889. package/src/ai/DecisionModel.ts +265 -109
  890. package/src/ai/EmbeddingModel.ts +25 -13
  891. package/src/ai/LanguageModel.ts +57 -51
  892. package/src/ai/McpClient.ts +1211 -0
  893. package/src/ai/McpClientError.ts +329 -0
  894. package/src/ai/McpProtocol.ts +2 -2
  895. package/src/ai/McpSchema.ts +153 -35
  896. package/src/ai/McpServer.ts +232 -275
  897. package/src/ai/Prompt.ts +49 -35
  898. package/src/ai/Response.ts +195 -65
  899. package/src/ai/Tool.ts +12 -4
  900. package/src/ai/Toolkit.ts +78 -10
  901. package/src/ai/index.ts +12 -0
  902. package/src/ai/internal/mcpCore.ts +13 -14
  903. package/src/ai/internal/mcpProtocol/v2024_11_05.ts +1 -1
  904. package/src/ai/internal/mcpProtocol/v2025_03_26.ts +1 -1
  905. package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -3
  906. package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -3
  907. package/src/ai/internal/mcpProtocol/v2026_07_28.ts +12 -14
  908. package/src/ai/internal/mcpProtocol.ts +22 -2
  909. package/src/ai/internal/mcpRuntime.ts +3 -4
  910. package/src/ai/internal/mcpSchema/v2024_11_05.ts +20 -13
  911. package/src/ai/internal/mcpSchema/v2025_03_26.ts +4 -2
  912. package/src/ai/internal/mcpSchema/v2025_06_18.ts +7 -7
  913. package/src/ai/internal/mcpSchema/v2025_11_25.ts +8 -8
  914. package/src/ai/internal/mcpSchema/v2026_07_28.ts +44 -42
  915. package/src/cli/CliError.ts +49 -4
  916. package/src/cli/Command.ts +316 -9
  917. package/src/cli/Completions.ts +10 -0
  918. package/src/cli/Flag.ts +218 -0
  919. package/src/cli/GlobalFlag.ts +3 -3
  920. package/src/cli/Param.ts +218 -0
  921. package/src/cli/TerminalCapabilities.ts +156 -0
  922. package/src/cli/index.ts +6 -0
  923. package/src/cli/internal/command.ts +10 -4
  924. package/src/cli/internal/completions/bash.ts +7 -5
  925. package/src/cli/internal/completions/descriptor.ts +20 -1
  926. package/src/cli/internal/completions/fish.ts +12 -10
  927. package/src/cli/internal/completions/powershell.ts +25 -13
  928. package/src/cli/internal/completions/zsh.ts +15 -8
  929. package/src/cli/internal/formatter.ts +18 -0
  930. package/src/cli/internal/lexer.ts +12 -5
  931. package/src/cli/internal/parser.ts +43 -14
  932. package/src/cli/internal/wizard.ts +2 -1
  933. package/src/cluster/ClusterCron.ts +94 -35
  934. package/src/cluster/ClusterMetrics.ts +149 -7
  935. package/src/cluster/ClusterWorkflowEngine.ts +164 -53
  936. package/src/cluster/Entity.ts +4 -0
  937. package/src/cluster/MessageStorage.ts +21 -3
  938. package/src/cluster/Runners.ts +145 -72
  939. package/src/cluster/Sharding.ts +118 -38
  940. package/src/cluster/ShardingConfig.ts +15 -0
  941. package/src/cluster/SqlMessageStorage.ts +58 -55
  942. package/src/cluster/SqlRunnerStorage.ts +10 -4
  943. package/src/cluster/internal/entityManager.ts +81 -11
  944. package/src/devtools/DevTools.ts +3 -2
  945. package/src/devtools/DevToolsClient.ts +27 -10
  946. package/src/encoding/Base64Url.ts +31 -0
  947. package/src/encoding/Ini.ts +3 -0
  948. package/src/encoding/JsonArray.ts +849 -0
  949. package/src/encoding/Ndjson.ts +211 -20
  950. package/src/encoding/SchemaBinary.ts +14 -48
  951. package/src/encoding/Sse.ts +1 -1
  952. package/src/encoding/Tar.ts +1417 -0
  953. package/src/encoding/Toml.ts +3 -3
  954. package/src/encoding/Xml.ts +2037 -0
  955. package/src/encoding/Yaml.ts +108 -36
  956. package/src/encoding/Zip.ts +1558 -0
  957. package/src/encoding/index.ts +24 -0
  958. package/src/eventlog/EventJournal.ts +611 -227
  959. package/src/eventlog/EventLog.ts +496 -196
  960. package/src/eventlog/EventLogEncryption.ts +128 -43
  961. package/src/eventlog/EventLogMessage.ts +62 -11
  962. package/src/eventlog/EventLogRemote.ts +77 -21
  963. package/src/eventlog/EventLogServer.ts +162 -20
  964. package/src/eventlog/EventLogServerEncrypted.ts +121 -80
  965. package/src/eventlog/EventLogServerUnencrypted.ts +180 -77
  966. package/src/eventlog/EventRow.ts +706 -0
  967. package/src/eventlog/SqlEventJournal.ts +453 -173
  968. package/src/eventlog/SqlEventLogServerEncrypted.ts +212 -83
  969. package/src/eventlog/SqlEventLogServerUnencrypted.ts +141 -62
  970. package/src/eventlog/index.ts +6 -0
  971. package/src/eventlog/internal/conflicts.ts +123 -0
  972. package/src/graphql/GraphQLClient.ts +17 -5
  973. package/src/graphql/GraphQLClientError.ts +5 -12
  974. package/src/graphql/GraphQLProtocol.ts +277 -20
  975. package/src/graphql/GraphQLResolver.ts +109 -230
  976. package/src/http/FetchHttpClient.ts +61 -8
  977. package/src/http/FindMyWay/internal/router.ts +13 -1
  978. package/src/http/Headers.ts +343 -163
  979. package/src/http/HttpClient.ts +144 -136
  980. package/src/http/HttpClientError.ts +10 -6
  981. package/src/http/HttpClientRequest.ts +315 -11
  982. package/src/http/HttpClientResponse.ts +71 -0
  983. package/src/http/HttpEffect.ts +25 -33
  984. package/src/http/HttpIncomingMessage.ts +3 -23
  985. package/src/http/HttpMiddleware.ts +265 -28
  986. package/src/http/HttpRouter.ts +67 -14
  987. package/src/http/HttpServerError.ts +14 -7
  988. package/src/http/HttpServerRequest.ts +73 -14
  989. package/src/http/HttpServerResponse.ts +49 -23
  990. package/src/http/HttpStaticServer.ts +29 -19
  991. package/src/http/HttpTraceContext.ts +1 -1
  992. package/src/http/MultipartParser/internal/contentType.ts +107 -6
  993. package/src/http/MultipartParser/internal/headers.ts +4 -16
  994. package/src/http/MultipartParser/internal/multipart.ts +10 -32
  995. package/src/http/Url.ts +8 -2
  996. package/src/http/UrlParams.ts +225 -26
  997. package/src/http/internal/compression.ts +3 -17
  998. package/src/http/internal/compressionBody.ts +56 -0
  999. package/src/http/internal/decompression.ts +235 -0
  1000. package/src/http/internal/lazyStream.ts +25 -0
  1001. package/src/http/internal/requestState.ts +33 -0
  1002. package/src/http/internal/tracing.ts +21 -4
  1003. package/src/http/internal/urlParams.ts +5 -0
  1004. package/src/http/internal/webResponse.ts +20 -0
  1005. package/src/http-api/HttpApi.ts +1 -1
  1006. package/src/http-api/HttpApiBuilder.ts +151 -23
  1007. package/src/http-api/HttpApiClient.ts +160 -31
  1008. package/src/http-api/HttpApiEndpoint.ts +144 -33
  1009. package/src/http-api/HttpApiError.ts +55 -0
  1010. package/src/http-api/HttpApiScalar.ts +4 -3
  1011. package/src/http-api/HttpApiSchema.ts +275 -13
  1012. package/src/http-api/HttpApiSwagger.ts +11 -4
  1013. package/src/http-api/HttpApiTest.ts +33 -9
  1014. package/src/http-api/OpenApi.ts +84 -42
  1015. package/src/http-api/internal/path.ts +40 -12
  1016. package/src/index.ts +24 -0
  1017. package/src/internal/core.ts +22 -2
  1018. package/src/internal/dateTime.ts +20 -7
  1019. package/src/internal/effect.ts +125 -88
  1020. package/src/internal/graphql.ts +30 -7
  1021. package/src/internal/hashMap.ts +2 -2
  1022. package/src/internal/hydration.ts +15 -0
  1023. package/src/internal/inflate.ts +710 -0
  1024. package/src/internal/record.ts +6 -0
  1025. package/src/internal/request.ts +21 -6
  1026. package/src/internal/schedule.ts +20 -39
  1027. package/src/internal/schema/fromJsonSchemaDocument.ts +262 -193
  1028. package/src/internal/schema/interpreter.ts +58 -45
  1029. package/src/internal/schema/standardSchema.ts +32 -30
  1030. package/src/internal/schema/toCodeDocument.ts +8 -3
  1031. package/src/internal/schema/toCodec.ts +116 -1
  1032. package/src/internal/schema/toFormatter.ts +6 -6
  1033. package/src/internal/schema/toJsonSchemaDocument.ts +69 -39
  1034. package/src/internal/trie.ts +1 -3
  1035. package/src/internal/uuid.ts +15 -10
  1036. package/src/internal/version.ts +1 -1
  1037. package/src/net/NetAddress.ts +2 -9
  1038. package/src/observability/Otlp.ts +18 -0
  1039. package/src/observability/OtlpExporter.ts +19 -15
  1040. package/src/observability/OtlpLogger.ts +31 -2
  1041. package/src/observability/OtlpMetrics.ts +35 -4
  1042. package/src/observability/OtlpResource.ts +16 -6
  1043. package/src/observability/OtlpSerialization.ts +17 -3
  1044. package/src/observability/OtlpTracer.ts +32 -3
  1045. package/src/observability/internal/protobuf.ts +2 -10
  1046. package/src/persistence/PersistedCache.ts +3 -1
  1047. package/src/persistence/PersistedQueue.ts +223 -153
  1048. package/src/persistence/Persistence.ts +64 -30
  1049. package/src/persistence/RateLimiter.ts +18 -21
  1050. package/src/persistence/UserDirectories.ts +273 -0
  1051. package/src/persistence/index.ts +6 -0
  1052. package/src/process/ChildProcess.ts +2 -1
  1053. package/src/reactivity/AsyncResult.ts +35 -38
  1054. package/src/reactivity/Atom.ts +134 -166
  1055. package/src/reactivity/AtomHttpApi.ts +10 -16
  1056. package/src/reactivity/AtomRegistry.ts +53 -30
  1057. package/src/reactivity/AtomRpc.ts +6 -22
  1058. package/src/reactivity/Hydration.ts +53 -12
  1059. package/src/reactivity/Reactivity.ts +97 -39
  1060. package/src/rpc/Rpc.ts +21 -0
  1061. package/src/rpc/RpcClient.ts +285 -104
  1062. package/src/rpc/RpcSerialization.ts +21 -5
  1063. package/src/rpc/RpcServer.ts +11 -20
  1064. package/src/schema/VariantSchema.ts +86 -22
  1065. package/src/socket/Socket.ts +45 -20
  1066. package/src/sql/Migrator.ts +19 -9
  1067. package/src/sql/SqlClient.ts +275 -36
  1068. package/src/sql/SqlResolver.ts +9 -0
  1069. package/src/sql/Statement.ts +35 -8
  1070. package/src/testing/TestClock.ts +147 -29
  1071. package/src/testing/TestSchema.ts +9 -3
  1072. package/src/workflow/Activity.ts +1 -0
  1073. package/src/workflow/Workflow.ts +31 -5
  1074. package/src/workflow/WorkflowEngine.ts +93 -31
  1075. package/dist/http/internal/preResponseHandler.d.ts +0 -2
  1076. package/dist/http/internal/preResponseHandler.d.ts.map +0 -1
  1077. package/dist/http/internal/preResponseHandler.js +0 -14
  1078. package/dist/http/internal/preResponseHandler.js.map +0 -1
  1079. package/src/http/internal/preResponseHandler.ts +0 -19
package/src/Stream.ts CHANGED
@@ -823,8 +823,13 @@ export const sync = <A>(evaluate: LazyArg<A>): Stream<A> => fromChannel(Channel.
823
823
  * @category constructors
824
824
  * @since 2.0.0
825
825
  */
826
- export const suspend = <A, E, R>(stream: LazyArg<Stream<A, E, R>>): Stream<A, E, R> =>
827
- fromChannel(Channel.suspend(() => stream().channel))
826
+ export const suspend = <A, E, R>(stream: LazyArg<Stream<A, E, R>>): Stream<A, E, R> => {
827
+ const suspended = fromChannel(Channel.suspend(() => stream().channel))
828
+ suspendedStreams.set(suspended, stream)
829
+ return suspended
830
+ }
831
+
832
+ const suspendedStreams = new WeakMap<Stream<any, any, any>, LazyArg<Stream<any, any, any>>>()
828
833
 
829
834
  /**
830
835
  * Terminates with the specified error.
@@ -1259,9 +1264,10 @@ export const fromPubSubTake = <A, E>(pubsub: PubSub.PubSub<Take.Take<A, E>>): St
1259
1264
  *
1260
1265
  * **Details**
1261
1266
  *
1262
- * The stream reads from a `ReadableStreamDefaultReader`, maps read failures
1263
- * with `onError`, and closes the reader when the stream finalizes. By default
1264
- * the reader is canceled; set `releaseLockOnEnd` to release the lock instead.
1267
+ * The stream reads from a `ReadableStreamDefaultReader` and maps read failures
1268
+ * with `onError`. Finalization cancels the reader and releases its lock, or
1269
+ * only releases the lock when `releaseLockOnEnd` is set. A rejected cancel
1270
+ * hook becomes a defect.
1265
1271
  *
1266
1272
  * **Example** (Creating a stream from a ReadableStream)
1267
1273
  *
@@ -1433,6 +1439,11 @@ export interface EventListener<A = unknown> {
1433
1439
  /**
1434
1440
  * Creates a stream from an event listener.
1435
1441
  *
1442
+ * **Gotchas**
1443
+ *
1444
+ * Event listeners cannot backpressure the source. When a bounded `bufferSize`
1445
+ * is full, additional events are dropped rather than suspending the listener.
1446
+ *
1436
1447
  * **Example** (Creating a stream from an event listener)
1437
1448
  *
1438
1449
  * ```ts import.meta.vitest
@@ -1882,6 +1893,11 @@ export const as: {
1882
1893
  /**
1883
1894
  * Maps both the failure and success channels of a stream.
1884
1895
  *
1896
+ * **Details**
1897
+ *
1898
+ * Maps every typed error in the cause, preserving defects, interrupts and
1899
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
1900
+ *
1885
1901
  * **Example** (Mapping both the failure and success channels of a stream)
1886
1902
  *
1887
1903
  * ```ts import.meta.vitest
@@ -1918,6 +1934,11 @@ export const mapBoth: {
1918
1934
  /**
1919
1935
  * Maps both the failure and success channels of a stream.
1920
1936
  *
1937
+ * **Details**
1938
+ *
1939
+ * Maps every typed error in the cause, preserving defects, interrupts and
1940
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
1941
+ *
1921
1942
  * **Example** (Mapping both the failure and success channels of a stream)
1922
1943
  *
1923
1944
  * ```ts import.meta.vitest
@@ -1956,6 +1977,11 @@ export const mapBoth: {
1956
1977
  /**
1957
1978
  * Maps both the failure and success channels of a stream.
1958
1979
  *
1980
+ * **Details**
1981
+ *
1982
+ * Maps every typed error in the cause, preserving defects, interrupts and
1983
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
1984
+ *
1959
1985
  * **Example** (Mapping both the failure and success channels of a stream)
1960
1986
  *
1961
1987
  * ```ts import.meta.vitest
@@ -3924,70 +3950,7 @@ export const concat: {
3924
3950
  2,
3925
3951
  <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A | A2, E | E2, R | R2> => {
3926
3952
  const stream = fromChannel(
3927
- Channel.flatten(Channel.fromIterator(() => concatChannels</**
3928
- * Concatenates two streams, emitting all elements from the first stream
3929
- * followed by all elements from the second stream.
3930
- *
3931
- * **Example** (Concatenating streams)
3932
- *
3933
- * ```ts import.meta.vitest
3934
- * import { Effect, Stream } from "effect"
3935
- *
3936
- * const stream = Stream.concat(Stream.make(1, 2, 3), Stream.make(4, 5, 6))
3937
- *
3938
- * await Effect.runPromise(Effect.gen(function*() {
3939
- * const values = yield* Stream.runCollect(stream)
3940
- * values // => [ 1, 2, 3, 4, 5, 6 ]
3941
- * }))
3942
- * ```
3943
- *
3944
- * @stability stable
3945
- * @category sequencing
3946
- * @since 2.0.0
3947
- */
3948
- A | A2, /**
3949
- * Concatenates two streams, emitting all elements from the first stream
3950
- * followed by all elements from the second stream.
3951
- *
3952
- * **Example** (Concatenating streams)
3953
- *
3954
- * ```ts import.meta.vitest
3955
- * import { Effect, Stream } from "effect"
3956
- *
3957
- * const stream = Stream.concat(Stream.make(1, 2, 3), Stream.make(4, 5, 6))
3958
- *
3959
- * await Effect.runPromise(Effect.gen(function*() {
3960
- * const values = yield* Stream.runCollect(stream)
3961
- * values // => [ 1, 2, 3, 4, 5, 6 ]
3962
- * }))
3963
- * ```
3964
- *
3965
- * @stability stable
3966
- * @category sequencing
3967
- * @since 2.0.0
3968
- */
3969
- E | E2, /**
3970
- * Concatenates two streams, emitting all elements from the first stream
3971
- * followed by all elements from the second stream.
3972
- *
3973
- * **Example** (Concatenating streams)
3974
- *
3975
- * ```ts import.meta.vitest
3976
- * import { Effect, Stream } from "effect"
3977
- *
3978
- * const stream = Stream.concat(Stream.make(1, 2, 3), Stream.make(4, 5, 6))
3979
- *
3980
- * await Effect.runPromise(Effect.gen(function*() {
3981
- * const values = yield* Stream.runCollect(stream)
3982
- * values // => [ 1, 2, 3, 4, 5, 6 ]
3983
- * }))
3984
- * ```
3985
- *
3986
- * @stability stable
3987
- * @category sequencing
3988
- * @since 2.0.0
3989
- */
3990
- R | R2>(self, that)))
3953
+ Channel.flatten(Channel.fromIterator(() => concatChannels<A | A2, E | E2, R | R2>(self, that)))
3991
3954
  )
3992
3955
  concatParts.set(stream, [self, that])
3993
3956
  return stream
@@ -3998,14 +3961,30 @@ export const concat: {
3998
3961
  // a single layer instead of one layer per call
3999
3962
  const concatParts = new WeakMap<Stream<any, any, any>, readonly [Stream<any, any, any>, Stream<any, any, any>]>()
4000
3963
 
4001
- // Yields the channel of each non-`concat` stream in a chain, in order
3964
+ // Yields the channel of each non-`concat` stream in a chain, in order. A
3965
+ // `suspend` part is evaluated when it is reached and its result joins the chain
4002
3966
  function* concatChannels<A, E, R>(self: Stream<A, E, R>, that: Stream<A, E, R>) {
4003
3967
  const stack = [that, self]
4004
3968
  while (stack.length > 0) {
4005
3969
  const stream = stack.pop()!
4006
3970
  const parts = concatParts.get(stream)
4007
- if (parts === undefined) yield stream.channel
4008
- else stack.push(parts[1], parts[0])
3971
+ if (parts !== undefined) {
3972
+ stack.push(parts[1], parts[0])
3973
+ continue
3974
+ }
3975
+ const evaluate = suspendedStreams.get(stream)
3976
+ if (evaluate === undefined) {
3977
+ yield stream.channel
3978
+ continue
3979
+ }
3980
+ // Evaluated here rather than in an effect, so retrying an interrupted pull
3981
+ // cannot evaluate it twice. `Channel.empty` keeps a yield point
3982
+ try {
3983
+ stack.push(evaluate())
3984
+ } catch (defect) {
3985
+ stack.push(die(defect))
3986
+ }
3987
+ yield Channel.empty
4009
3988
  }
4010
3989
  }
4011
3990
 
@@ -5104,24 +5083,23 @@ export const zipWith: {
5104
5083
  left: Stream<AL, EL, RL>,
5105
5084
  right: Stream<AR, ER, RR>,
5106
5085
  f: (left: AL, right: AR) => A
5107
- ): Stream<A, EL | ER, RL | RR> => zipWithArray(left, right, zipArrays(f)))
5108
-
5109
- const zipArrays = <AL, AR, A>(
5110
- f: (left: AL, right: AR) => A
5111
- ) =>
5112
- (
5113
- leftArr: Arr.NonEmptyReadonlyArray<AL>,
5114
- rightArr: Arr.NonEmptyReadonlyArray<AR>
5115
- ) => {
5116
- const minLength = Math.min(leftArr.length, rightArr.length)
5117
- const result: Arr.NonEmptyArray<A> = [] as any
5118
-
5119
- for (let i = 0; i < minLength; i++) {
5120
- result.push(f(leftArr[i], rightArr[i]))
5121
- }
5122
-
5123
- return [result, leftArr.slice(minLength), rightArr.slice(minLength)] as const
5124
- }
5086
+ ): Stream<A, EL | ER, RL | RR> =>
5087
+ suspend(() => {
5088
+ // Track consumed elements with cursors instead of slicing leftovers
5089
+ let leftIndex = 0
5090
+ let rightIndex = 0
5091
+ return zipWithArray(left, right, (leftArr, rightArr) => {
5092
+ const length = Math.min(leftArr.length - leftIndex, rightArr.length - rightIndex)
5093
+ const output = Arr.makeBy(length, (i) => f(leftArr[leftIndex + i], rightArr[rightIndex + i]))
5094
+ leftIndex += length
5095
+ rightIndex += length
5096
+ const leftDone = leftIndex === leftArr.length
5097
+ const rightDone = rightIndex === rightArr.length
5098
+ if (leftDone) leftIndex = 0
5099
+ if (rightDone) rightIndex = 0
5100
+ return [output, leftDone ? [] : leftArr, rightDone ? [] : rightArr]
5101
+ })
5102
+ }))
5125
5103
 
5126
5104
  /**
5127
5105
  * Zips two streams by applying a function to non-empty arrays of elements.
@@ -5273,31 +5251,23 @@ export const zipWithArray: {
5273
5251
  ]
5274
5252
  })
5275
5253
 
5276
- type State =
5277
- | { _tag: "PullBoth" }
5278
- | { _tag: "PullLeft"; rightArray: Arr.NonEmptyReadonlyArray<AR> }
5279
- | { _tag: "PullRight"; leftArray: Arr.NonEmptyReadonlyArray<AL> }
5280
- let state: State = { _tag: "PullBoth" }
5254
+ let leftArray: Arr.NonEmptyReadonlyArray<AL> | undefined
5255
+ let rightArray: Arr.NonEmptyReadonlyArray<AR> | undefined
5281
5256
 
5282
5257
  const pull: Effect.Effect<
5283
5258
  Arr.NonEmptyReadonlyArray<A>,
5284
5259
  EL | ER | Cause.Done,
5285
5260
  RL | RR
5286
5261
  > = Effect.gen(function*() {
5287
- const [left, right] = state._tag === "PullBoth"
5288
- ? yield* pullBoth
5289
- : state._tag === "PullLeft"
5290
- ? [yield* pullLeft, state.rightArray]
5291
- : [state.leftArray, yield* pullRight]
5292
- const result = f(left, right)
5293
- if (Arr.isReadonlyArrayNonEmpty(result[1])) {
5294
- state = { _tag: "PullRight", leftArray: result[1] }
5295
- } else if (Arr.isReadonlyArrayNonEmpty(result[2])) {
5296
- state = { _tag: "PullLeft", rightArray: result[2] }
5297
- } else {
5298
- state = { _tag: "PullBoth" }
5299
- }
5300
- return result[0]
5262
+ const [left, right] = leftArray
5263
+ ? [leftArray, rightArray ?? (yield* pullRight)]
5264
+ : rightArray
5265
+ ? [yield* pullLeft, rightArray]
5266
+ : yield* pullBoth
5267
+ const [output, leftoverLeft, leftoverRight] = f(left, right)
5268
+ leftArray = Arr.isReadonlyArrayNonEmpty(leftoverLeft) ? leftoverLeft : undefined
5269
+ rightArray = Arr.isReadonlyArrayNonEmpty(leftoverRight) ? leftoverRight : undefined
5270
+ return output
5301
5271
  })
5302
5272
 
5303
5273
  return pull
@@ -5484,15 +5454,7 @@ export const zipLeft: {
5484
5454
  <AL, EL, RL, AR, ER, RR>(
5485
5455
  left: Stream<AL, EL, RL>,
5486
5456
  right: Stream<AR, ER, RR>
5487
- ): Stream<AL, EL | ER, RL | RR> =>
5488
- zipWithArray(left, right, (leftArr, rightArr) => {
5489
- const minLength = Math.min(leftArr.length, rightArr.length)
5490
- const output = leftArr.slice(0, minLength) as Arr.NonEmptyArray<AL>
5491
- const leftoverLeft = leftArr.slice(minLength)
5492
- const leftoverRight = rightArr.slice(minLength)
5493
-
5494
- return [output, leftoverLeft, leftoverRight] as const
5495
- })
5457
+ ): Stream<AL, EL | ER, RL | RR> => zipWith(left, right, (a) => a)
5496
5458
  )
5497
5459
 
5498
5460
  /**
@@ -5572,15 +5534,7 @@ export const zipRight: {
5572
5534
  <AL, EL, RL, AR, ER, RR>(
5573
5535
  left: Stream<AL, EL, RL>,
5574
5536
  right: Stream<AR, ER, RR>
5575
- ): Stream<AR, EL | ER, RL | RR> =>
5576
- zipWithArray(left, right, (leftArr, rightArr) => {
5577
- const minLength = Math.min(leftArr.length, rightArr.length)
5578
- const output = rightArr.slice(0, minLength) as Arr.NonEmptyArray<AR>
5579
- const leftoverLeft = leftArr.slice(minLength)
5580
- const leftoverRight = rightArr.slice(minLength)
5581
-
5582
- return [output, leftoverLeft, leftoverRight] as const
5583
- })
5537
+ ): Stream<AR, EL | ER, RL | RR> => zipWith(left, right, (_, a) => a)
5584
5538
  )
5585
5539
 
5586
5540
  /**
@@ -6832,144 +6786,8 @@ export const partitionQueue: {
6832
6786
  const scope = yield* Effect.scope
6833
6787
  const pull = yield* Channel.toPullScoped(self.channel, scope)
6834
6788
  const capacity = options?.capacity === "unbounded" ? undefined : options?.capacity ?? DefaultChunkSize
6835
- const passes = yield* Queue.make</**
6836
- * Partitions a stream using a `Filter` and exposes passing and failing values
6837
- * as scoped queues.
6838
- *
6839
- * **Details**
6840
- *
6841
- * The queues are backed by a fiber in the current scope and should be consumed
6842
- * while that scope remains open. Each queue fails with the stream error or
6843
- * `Cause.Done` when the source ends.
6844
- *
6845
- * **Example** (Partitioning a stream into queues)
6846
- *
6847
- * ```ts import.meta.vitest
6848
- * import { Effect, Result, Stream } from "effect"
6849
- *
6850
- * const program = Effect.gen(function*() {
6851
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6852
- * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6853
- * )
6854
- *
6855
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
6856
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
6857
- *
6858
- * passValues // => [ 2, 4 ]
6859
- * failValues // => [ 1, 3 ]
6860
- * })
6861
- *
6862
- * await Effect.runPromise(Effect.scoped(program))
6863
- * ```
6864
- *
6865
- * @stability stable
6866
- * @category filtering
6867
- * @since 4.0.0
6868
- */
6869
- Pass, /**
6870
- * Partitions a stream using a `Filter` and exposes passing and failing values
6871
- * as scoped queues.
6872
- *
6873
- * **Details**
6874
- *
6875
- * The queues are backed by a fiber in the current scope and should be consumed
6876
- * while that scope remains open. Each queue fails with the stream error or
6877
- * `Cause.Done` when the source ends.
6878
- *
6879
- * **Example** (Partitioning a stream into queues)
6880
- *
6881
- * ```ts import.meta.vitest
6882
- * import { Effect, Result, Stream } from "effect"
6883
- *
6884
- * const program = Effect.gen(function*() {
6885
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6886
- * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6887
- * )
6888
- *
6889
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
6890
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
6891
- *
6892
- * passValues // => [ 2, 4 ]
6893
- * failValues // => [ 1, 3 ]
6894
- * })
6895
- *
6896
- * await Effect.runPromise(Effect.scoped(program))
6897
- * ```
6898
- *
6899
- * @stability stable
6900
- * @category filtering
6901
- * @since 4.0.0
6902
- */
6903
- E | Cause.Done>({ capacity })
6904
- const fails = yield* Queue.make</**
6905
- * Partitions a stream using a `Filter` and exposes passing and failing values
6906
- * as scoped queues.
6907
- *
6908
- * **Details**
6909
- *
6910
- * The queues are backed by a fiber in the current scope and should be consumed
6911
- * while that scope remains open. Each queue fails with the stream error or
6912
- * `Cause.Done` when the source ends.
6913
- *
6914
- * **Example** (Partitioning a stream into queues)
6915
- *
6916
- * ```ts import.meta.vitest
6917
- * import { Effect, Result, Stream } from "effect"
6918
- *
6919
- * const program = Effect.gen(function*() {
6920
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6921
- * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6922
- * )
6923
- *
6924
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
6925
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
6926
- *
6927
- * passValues // => [ 2, 4 ]
6928
- * failValues // => [ 1, 3 ]
6929
- * })
6930
- *
6931
- * await Effect.runPromise(Effect.scoped(program))
6932
- * ```
6933
- *
6934
- * @stability stable
6935
- * @category filtering
6936
- * @since 4.0.0
6937
- */
6938
- Fail, /**
6939
- * Partitions a stream using a `Filter` and exposes passing and failing values
6940
- * as scoped queues.
6941
- *
6942
- * **Details**
6943
- *
6944
- * The queues are backed by a fiber in the current scope and should be consumed
6945
- * while that scope remains open. Each queue fails with the stream error or
6946
- * `Cause.Done` when the source ends.
6947
- *
6948
- * **Example** (Partitioning a stream into queues)
6949
- *
6950
- * ```ts import.meta.vitest
6951
- * import { Effect, Result, Stream } from "effect"
6952
- *
6953
- * const program = Effect.gen(function*() {
6954
- * const [passes, fails] = yield* Stream.make(1, 2, 3, 4).pipe(
6955
- * Stream.partitionQueue((n) => n % 2 === 0 ? Result.succeed(n) : Result.fail(n))
6956
- * )
6957
- *
6958
- * const passValues = yield* Stream.fromQueue(passes).pipe(Stream.runCollect)
6959
- * const failValues = yield* Stream.fromQueue(fails).pipe(Stream.runCollect)
6960
- *
6961
- * passValues // => [ 2, 4 ]
6962
- * failValues // => [ 1, 3 ]
6963
- * })
6964
- *
6965
- * await Effect.runPromise(Effect.scoped(program))
6966
- * ```
6967
- *
6968
- * @stability stable
6969
- * @category filtering
6970
- * @since 4.0.0
6971
- */
6972
- E | Cause.Done>({ capacity })
6789
+ const passes = yield* Queue.make<Pass, E | Cause.Done>({ capacity })
6790
+ const fails = yield* Queue.make<Fail, E | Cause.Done>({ capacity })
6973
6791
 
6974
6792
  yield* Effect.gen(function*() {
6975
6793
  while (true) {
@@ -7138,122 +6956,7 @@ export const partitionEffect: {
7138
6956
  R | RX | Scope.Scope
7139
6957
  > =>
7140
6958
  Effect.map(
7141
- partitionQueue</**
7142
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7143
- * filter successes and failures.
7144
- *
7145
- * **When to use**
7146
- *
7147
- * Use when you need to classify each stream element with an effectful `Filter`
7148
- * and consume both passing and failing mapped values as streams.
7149
- *
7150
- * **Details**
7151
- *
7152
- * The returned streams are backed by queues in the current scope and should be
7153
- * consumed while that scope remains open. The first stream emits success values
7154
- * from the filter, and the second emits failure values.
7155
- *
7156
- * @see {@link partition} for the pure `Filter` variant
7157
- * @see {@link partitionQueue} for the lower-level queue result
7158
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7159
- *
7160
- * @stability stable
7161
- * @category filtering
7162
- * @since 4.0.0
7163
- */
7164
- Result.Result<Pass, Fail>, /**
7165
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7166
- * filter successes and failures.
7167
- *
7168
- * **When to use**
7169
- *
7170
- * Use when you need to classify each stream element with an effectful `Filter`
7171
- * and consume both passing and failing mapped values as streams.
7172
- *
7173
- * **Details**
7174
- *
7175
- * The returned streams are backed by queues in the current scope and should be
7176
- * consumed while that scope remains open. The first stream emits success values
7177
- * from the filter, and the second emits failure values.
7178
- *
7179
- * @see {@link partition} for the pure `Filter` variant
7180
- * @see {@link partitionQueue} for the lower-level queue result
7181
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7182
- *
7183
- * @stability stable
7184
- * @category filtering
7185
- * @since 4.0.0
7186
- */
7187
- E | EX, /**
7188
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7189
- * filter successes and failures.
7190
- *
7191
- * **When to use**
7192
- *
7193
- * Use when you need to classify each stream element with an effectful `Filter`
7194
- * and consume both passing and failing mapped values as streams.
7195
- *
7196
- * **Details**
7197
- *
7198
- * The returned streams are backed by queues in the current scope and should be
7199
- * consumed while that scope remains open. The first stream emits success values
7200
- * from the filter, and the second emits failure values.
7201
- *
7202
- * @see {@link partition} for the pure `Filter` variant
7203
- * @see {@link partitionQueue} for the lower-level queue result
7204
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7205
- *
7206
- * @stability stable
7207
- * @category filtering
7208
- * @since 4.0.0
7209
- */
7210
- R | RX, /**
7211
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7212
- * filter successes and failures.
7213
- *
7214
- * **When to use**
7215
- *
7216
- * Use when you need to classify each stream element with an effectful `Filter`
7217
- * and consume both passing and failing mapped values as streams.
7218
- *
7219
- * **Details**
7220
- *
7221
- * The returned streams are backed by queues in the current scope and should be
7222
- * consumed while that scope remains open. The first stream emits success values
7223
- * from the filter, and the second emits failure values.
7224
- *
7225
- * @see {@link partition} for the pure `Filter` variant
7226
- * @see {@link partitionQueue} for the lower-level queue result
7227
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7228
- *
7229
- * @stability stable
7230
- * @category filtering
7231
- * @since 4.0.0
7232
- */
7233
- Pass, /**
7234
- * Splits a stream with an effectful `Filter`, returning scoped streams for
7235
- * filter successes and failures.
7236
- *
7237
- * **When to use**
7238
- *
7239
- * Use when you need to classify each stream element with an effectful `Filter`
7240
- * and consume both passing and failing mapped values as streams.
7241
- *
7242
- * **Details**
7243
- *
7244
- * The returned streams are backed by queues in the current scope and should be
7245
- * consumed while that scope remains open. The first stream emits success values
7246
- * from the filter, and the second emits failure values.
7247
- *
7248
- * @see {@link partition} for the pure `Filter` variant
7249
- * @see {@link partitionQueue} for the lower-level queue result
7250
- * @see {@link filterMapEffect} for effectful filtering that discards failed filter results
7251
- *
7252
- * @stability stable
7253
- * @category filtering
7254
- * @since 4.0.0
7255
- */
7256
- Fail>(
6959
+ partitionQueue<Result.Result<Pass, Fail>, E | EX, R | RX, Pass, Fail>(
7257
6960
  mapEffect(self, (a) => filter(a as NoInfer<A>), options),
7258
6961
  (result) => result,
7259
6962
  options
@@ -7953,6 +7656,12 @@ export const catchCause: {
7953
7656
  *
7954
7657
  * Typed failures and interruptions are not caught.
7955
7658
  *
7659
+ * **Gotchas**
7660
+ *
7661
+ * `catchDefect` recovers any cause that contains a defect, including causes
7662
+ * that also contain typed errors. Typed error handlers such as `catch` skip
7663
+ * those causes, so defects always take precedence.
7664
+ *
7956
7665
  * **Example** (Recovering from a defect)
7957
7666
  *
7958
7667
  * ```ts import.meta.vitest
@@ -7978,6 +7687,12 @@ export const catchDefect: {
7978
7687
  *
7979
7688
  * Typed failures and interruptions are not caught.
7980
7689
  *
7690
+ * **Gotchas**
7691
+ *
7692
+ * `catchDefect` recovers any cause that contains a defect, including causes
7693
+ * that also contain typed errors. Typed error handlers such as `catch` skip
7694
+ * those causes, so defects always take precedence.
7695
+ *
7981
7696
  * **Example** (Recovering from a defect)
7982
7697
  *
7983
7698
  * ```ts import.meta.vitest
@@ -8003,6 +7718,12 @@ export const catchDefect: {
8003
7718
  *
8004
7719
  * Typed failures and interruptions are not caught.
8005
7720
  *
7721
+ * **Gotchas**
7722
+ *
7723
+ * `catchDefect` recovers any cause that contains a defect, including causes
7724
+ * that also contain typed errors. Typed error handlers such as `catch` skip
7725
+ * those causes, so defects always take precedence.
7726
+ *
8006
7727
  * **Example** (Recovering from a defect)
8007
7728
  *
8008
7729
  * ```ts import.meta.vitest
@@ -8149,6 +7870,13 @@ export {
8149
7870
  /**
8150
7871
  * Switches over to the stream produced by the provided function if this one fails.
8151
7872
  *
7873
+ * **Gotchas**
7874
+ *
7875
+ * Defects take precedence over typed errors. If the cause also contains a
7876
+ * defect, the handler does not run and the failure is propagated with every
7877
+ * typed error converted to a defect. An interruption alongside a typed error
7878
+ * does not prevent recovery.
7879
+ *
8152
7880
  * **Example** (Catching stream failures)
8153
7881
  *
8154
7882
  * ```ts import.meta.vitest
@@ -8553,6 +8281,12 @@ export const tapDefect: {
8553
8281
  * stream. Non-matching failures propagate downstream, so the error type is
8554
8282
  * preserved unless the filter narrows it.
8555
8283
  *
8284
+ * **Gotchas**
8285
+ *
8286
+ * If the cause contains a defect, the handler is skipped and every typed error
8287
+ * is converted to a defect, preserving reason order and interrupts. An
8288
+ * interruption alongside a typed error does not prevent recovery.
8289
+ *
8556
8290
  * **Example** (Catching matching failures)
8557
8291
  *
8558
8292
  * ```ts import.meta.vitest
@@ -8588,6 +8322,12 @@ export const catchIf: {
8588
8322
  * stream. Non-matching failures propagate downstream, so the error type is
8589
8323
  * preserved unless the filter narrows it.
8590
8324
  *
8325
+ * **Gotchas**
8326
+ *
8327
+ * If the cause contains a defect, the handler is skipped and every typed error
8328
+ * is converted to a defect, preserving reason order and interrupts. An
8329
+ * interruption alongside a typed error does not prevent recovery.
8330
+ *
8591
8331
  * **Example** (Catching matching failures)
8592
8332
  *
8593
8333
  * ```ts import.meta.vitest
@@ -8629,6 +8369,12 @@ export const catchIf: {
8629
8369
  * stream. Non-matching failures propagate downstream, so the error type is
8630
8370
  * preserved unless the filter narrows it.
8631
8371
  *
8372
+ * **Gotchas**
8373
+ *
8374
+ * If the cause contains a defect, the handler is skipped and every typed error
8375
+ * is converted to a defect, preserving reason order and interrupts. An
8376
+ * interruption alongside a typed error does not prevent recovery.
8377
+ *
8632
8378
  * **Example** (Catching matching failures)
8633
8379
  *
8634
8380
  * ```ts import.meta.vitest
@@ -8670,6 +8416,12 @@ export const catchIf: {
8670
8416
  * stream. Non-matching failures propagate downstream, so the error type is
8671
8417
  * preserved unless the filter narrows it.
8672
8418
  *
8419
+ * **Gotchas**
8420
+ *
8421
+ * If the cause contains a defect, the handler is skipped and every typed error
8422
+ * is converted to a defect, preserving reason order and interrupts. An
8423
+ * interruption alongside a typed error does not prevent recovery.
8424
+ *
8673
8425
  * **Example** (Catching matching failures)
8674
8426
  *
8675
8427
  * ```ts import.meta.vitest
@@ -8697,7 +8449,7 @@ export const catchIf: {
8697
8449
  */
8698
8450
  <A, E, R, EB extends E, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(
8699
8451
  self: Stream<A, E, R>,
8700
- refinement: Refinement<E, EB>,
8452
+ refinement: Refinement<NoInfer<E>, EB>,
8701
8453
  f: (e: EB) => Stream<A2, E2, R2>,
8702
8454
  orElse?: ((e: Exclude<E, EB>) => Stream<A3, E3, R3>) | undefined
8703
8455
  ): Stream<A | A2 | Exclude<A3, unassigned>, E2 | E3 | (A3 extends unassigned ? Exclude<E, EB> : never), R | R2 | R3>
@@ -8710,6 +8462,12 @@ export const catchIf: {
8710
8462
  * stream. Non-matching failures propagate downstream, so the error type is
8711
8463
  * preserved unless the filter narrows it.
8712
8464
  *
8465
+ * **Gotchas**
8466
+ *
8467
+ * If the cause contains a defect, the handler is skipped and every typed error
8468
+ * is converted to a defect, preserving reason order and interrupts. An
8469
+ * interruption alongside a typed error does not prevent recovery.
8470
+ *
8713
8471
  * **Example** (Catching matching failures)
8714
8472
  *
8715
8473
  * ```ts import.meta.vitest
@@ -8780,6 +8538,12 @@ export const catchIf: {
8780
8538
  * Successful filter results are passed to `f`. Failed filter results go to
8781
8539
  * `orElse` when provided; otherwise the filter failure is re-failed.
8782
8540
  *
8541
+ * **Gotchas**
8542
+ *
8543
+ * If the cause contains a defect, the handler is skipped and every typed error
8544
+ * is converted to a defect, preserving reason order and interrupts. An
8545
+ * interruption alongside a typed error does not prevent recovery.
8546
+ *
8783
8547
  * @see {@link catchIf} for predicate or refinement based recovery
8784
8548
  * @see {@link catchTag} for `_tag` based recovery from one tagged error
8785
8549
  * @see {@link catchTags} for `_tag` based recovery from multiple tagged errors
@@ -8804,6 +8568,12 @@ export const catchFilter: {
8804
8568
  * Successful filter results are passed to `f`. Failed filter results go to
8805
8569
  * `orElse` when provided; otherwise the filter failure is re-failed.
8806
8570
  *
8571
+ * **Gotchas**
8572
+ *
8573
+ * If the cause contains a defect, the handler is skipped and every typed error
8574
+ * is converted to a defect, preserving reason order and interrupts. An
8575
+ * interruption alongside a typed error does not prevent recovery.
8576
+ *
8807
8577
  * @see {@link catchIf} for predicate or refinement based recovery
8808
8578
  * @see {@link catchTag} for `_tag` based recovery from one tagged error
8809
8579
  * @see {@link catchTags} for `_tag` based recovery from multiple tagged errors
@@ -8834,6 +8604,12 @@ export const catchFilter: {
8834
8604
  * Successful filter results are passed to `f`. Failed filter results go to
8835
8605
  * `orElse` when provided; otherwise the filter failure is re-failed.
8836
8606
  *
8607
+ * **Gotchas**
8608
+ *
8609
+ * If the cause contains a defect, the handler is skipped and every typed error
8610
+ * is converted to a defect, preserving reason order and interrupts. An
8611
+ * interruption alongside a typed error does not prevent recovery.
8612
+ *
8837
8613
  * @see {@link catchIf} for predicate or refinement based recovery
8838
8614
  * @see {@link catchTag} for `_tag` based recovery from one tagged error
8839
8615
  * @see {@link catchTags} for `_tag` based recovery from multiple tagged errors
@@ -8885,6 +8661,12 @@ export const catchFilter: {
8885
8661
  * Use when you need to handle a specific error case from a stream whose error
8886
8662
  * type is a tagged union with a readonly `_tag` field.
8887
8663
  *
8664
+ * **Gotchas**
8665
+ *
8666
+ * If the cause contains a defect, the handler is skipped and every typed error
8667
+ * is converted to a defect, preserving reason order and interrupts. An
8668
+ * interruption alongside a typed error does not prevent recovery.
8669
+ *
8888
8670
  * **Example** (Catching tagged failures)
8889
8671
  *
8890
8672
  * ```ts import.meta.vitest
@@ -8920,6 +8702,12 @@ export const catchTag: {
8920
8702
  * Use when you need to handle a specific error case from a stream whose error
8921
8703
  * type is a tagged union with a readonly `_tag` field.
8922
8704
  *
8705
+ * **Gotchas**
8706
+ *
8707
+ * If the cause contains a defect, the handler is skipped and every typed error
8708
+ * is converted to a defect, preserving reason order and interrupts. An
8709
+ * interruption alongside a typed error does not prevent recovery.
8710
+ *
8923
8711
  * **Example** (Catching tagged failures)
8924
8712
  *
8925
8713
  * ```ts import.meta.vitest
@@ -8980,6 +8768,12 @@ export const catchTag: {
8980
8768
  * Use when you need to handle a specific error case from a stream whose error
8981
8769
  * type is a tagged union with a readonly `_tag` field.
8982
8770
  *
8771
+ * **Gotchas**
8772
+ *
8773
+ * If the cause contains a defect, the handler is skipped and every typed error
8774
+ * is converted to a defect, preserving reason order and interrupts. An
8775
+ * interruption alongside a typed error does not prevent recovery.
8776
+ *
8983
8777
  * **Example** (Catching tagged failures)
8984
8778
  *
8985
8779
  * ```ts import.meta.vitest
@@ -9061,6 +8855,12 @@ export const catchTag: {
9061
8855
  /**
9062
8856
  * Switches to a recovery stream based on matching `_tag` handlers.
9063
8857
  *
8858
+ * **Gotchas**
8859
+ *
8860
+ * If the cause contains a defect, the handler is skipped and every typed error
8861
+ * is converted to a defect, preserving reason order and interrupts. An
8862
+ * interruption alongside a typed error does not prevent recovery.
8863
+ *
9064
8864
  * **Example** (Catching tagged failures with handlers)
9065
8865
  *
9066
8866
  * ```ts import.meta.vitest
@@ -9100,6 +8900,12 @@ export const catchTags: {
9100
8900
  /**
9101
8901
  * Switches to a recovery stream based on matching `_tag` handlers.
9102
8902
  *
8903
+ * **Gotchas**
8904
+ *
8905
+ * If the cause contains a defect, the handler is skipped and every typed error
8906
+ * is converted to a defect, preserving reason order and interrupts. An
8907
+ * interruption alongside a typed error does not prevent recovery.
8908
+ *
9103
8909
  * **Example** (Catching tagged failures with handlers)
9104
8910
  *
9105
8911
  * ```ts import.meta.vitest
@@ -9166,6 +8972,12 @@ export const catchTags: {
9166
8972
  /**
9167
8973
  * Switches to a recovery stream based on matching `_tag` handlers.
9168
8974
  *
8975
+ * **Gotchas**
8976
+ *
8977
+ * If the cause contains a defect, the handler is skipped and every typed error
8978
+ * is converted to a defect, preserving reason order and interrupts. An
8979
+ * interruption alongside a typed error does not prevent recovery.
8980
+ *
9169
8981
  * **Example** (Catching tagged failures with handlers)
9170
8982
  *
9171
8983
  * ```ts import.meta.vitest
@@ -9259,6 +9071,12 @@ export const catchTags: {
9259
9071
  *
9260
9072
  * The handler receives the unwrapped reason.
9261
9073
  *
9074
+ * **Gotchas**
9075
+ *
9076
+ * If the cause contains a defect, the handler is skipped and every typed error
9077
+ * is converted to a defect, preserving reason order and interrupts. An
9078
+ * interruption alongside a typed error does not prevent recovery.
9079
+ *
9262
9080
  * **Example** (Catching a tagged error reason)
9263
9081
  *
9264
9082
  * ```ts import.meta.vitest
@@ -9310,6 +9128,12 @@ export const catchReason: {
9310
9128
  *
9311
9129
  * The handler receives the unwrapped reason.
9312
9130
  *
9131
+ * **Gotchas**
9132
+ *
9133
+ * If the cause contains a defect, the handler is skipped and every typed error
9134
+ * is converted to a defect, preserving reason order and interrupts. An
9135
+ * interruption alongside a typed error does not prevent recovery.
9136
+ *
9313
9137
  * **Example** (Catching a tagged error reason)
9314
9138
  *
9315
9139
  * ```ts import.meta.vitest
@@ -9390,6 +9214,12 @@ export const catchReason: {
9390
9214
  *
9391
9215
  * The handler receives the unwrapped reason.
9392
9216
  *
9217
+ * **Gotchas**
9218
+ *
9219
+ * If the cause contains a defect, the handler is skipped and every typed error
9220
+ * is converted to a defect, preserving reason order and interrupts. An
9221
+ * interruption alongside a typed error does not prevent recovery.
9222
+ *
9393
9223
  * **Example** (Catching a tagged error reason)
9394
9224
  *
9395
9225
  * ```ts import.meta.vitest
@@ -9494,6 +9324,12 @@ export const catchReason: {
9494
9324
  /**
9495
9325
  * Catches multiple reasons within a tagged error using an object of handlers.
9496
9326
  *
9327
+ * **Gotchas**
9328
+ *
9329
+ * If the cause contains a defect, the handler is skipped and every typed error
9330
+ * is converted to a defect, preserving reason order and interrupts. An
9331
+ * interruption alongside a typed error does not prevent recovery.
9332
+ *
9497
9333
  * **Example** (Catching tagged error reasons)
9498
9334
  *
9499
9335
  * ```ts import.meta.vitest
@@ -9537,6 +9373,12 @@ export const catchReasons: {
9537
9373
  /**
9538
9374
  * Catches multiple reasons within a tagged error using an object of handlers.
9539
9375
  *
9376
+ * **Gotchas**
9377
+ *
9378
+ * If the cause contains a defect, the handler is skipped and every typed error
9379
+ * is converted to a defect, preserving reason order and interrupts. An
9380
+ * interruption alongside a typed error does not prevent recovery.
9381
+ *
9540
9382
  * **Example** (Catching tagged error reasons)
9541
9383
  *
9542
9384
  * ```ts import.meta.vitest
@@ -9618,6 +9460,12 @@ export const catchReasons: {
9618
9460
  /**
9619
9461
  * Catches multiple reasons within a tagged error using an object of handlers.
9620
9462
  *
9463
+ * **Gotchas**
9464
+ *
9465
+ * If the cause contains a defect, the handler is skipped and every typed error
9466
+ * is converted to a defect, preserving reason order and interrupts. An
9467
+ * interruption alongside a typed error does not prevent recovery.
9468
+ *
9621
9469
  * **Example** (Catching tagged error reasons)
9622
9470
  *
9623
9471
  * ```ts import.meta.vitest
@@ -9889,6 +9737,11 @@ export const unwrapReason: {
9889
9737
  /**
9890
9738
  * Transforms the errors emitted by this stream using `f`.
9891
9739
  *
9740
+ * **Details**
9741
+ *
9742
+ * Maps every typed error in the cause, preserving defects, interrupts and
9743
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
9744
+ *
9892
9745
  * **Example** (Mapping stream errors)
9893
9746
  *
9894
9747
  * ```ts import.meta.vitest
@@ -9914,6 +9767,11 @@ export const mapError: {
9914
9767
  /**
9915
9768
  * Transforms the errors emitted by this stream using `f`.
9916
9769
  *
9770
+ * **Details**
9771
+ *
9772
+ * Maps every typed error in the cause, preserving defects, interrupts and
9773
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
9774
+ *
9917
9775
  * **Example** (Mapping stream errors)
9918
9776
  *
9919
9777
  * ```ts import.meta.vitest
@@ -9939,6 +9797,11 @@ export const mapError: {
9939
9797
  /**
9940
9798
  * Transforms the errors emitted by this stream using `f`.
9941
9799
  *
9800
+ * **Details**
9801
+ *
9802
+ * Maps every typed error in the cause, preserving defects, interrupts and
9803
+ * reason order. Unlike typed recovery, mapping does not convert errors to defects.
9804
+ *
9942
9805
  * **Example** (Mapping stream errors)
9943
9806
  *
9944
9807
  * ```ts import.meta.vitest
@@ -10256,6 +10119,12 @@ export const orElseIfEmpty: {
10256
10119
  /**
10257
10120
  * Returns a stream that emits a fallback value when this stream fails.
10258
10121
  *
10122
+ * **Gotchas**
10123
+ *
10124
+ * If the cause contains a defect, the handler is skipped and every typed error
10125
+ * is converted to a defect, preserving reason order and interrupts. An
10126
+ * interruption alongside a typed error does not prevent recovery.
10127
+ *
10259
10128
  * **Example** (Recovering with a fallback value)
10260
10129
  *
10261
10130
  * ```ts import.meta.vitest
@@ -10281,6 +10150,12 @@ export const orElseSucceed: {
10281
10150
  /**
10282
10151
  * Returns a stream that emits a fallback value when this stream fails.
10283
10152
  *
10153
+ * **Gotchas**
10154
+ *
10155
+ * If the cause contains a defect, the handler is skipped and every typed error
10156
+ * is converted to a defect, preserving reason order and interrupts. An
10157
+ * interruption alongside a typed error does not prevent recovery.
10158
+ *
10284
10159
  * **Example** (Recovering with a fallback value)
10285
10160
  *
10286
10161
  * ```ts import.meta.vitest
@@ -10306,6 +10181,12 @@ export const orElseSucceed: {
10306
10181
  /**
10307
10182
  * Returns a stream that emits a fallback value when this stream fails.
10308
10183
  *
10184
+ * **Gotchas**
10185
+ *
10186
+ * If the cause contains a defect, the handler is skipped and every typed error
10187
+ * is converted to a defect, preserving reason order and interrupts. An
10188
+ * interruption alongside a typed error does not prevent recovery.
10189
+ *
10309
10190
  * **Example** (Recovering with a fallback value)
10310
10191
  *
10311
10192
  * ```ts import.meta.vitest
@@ -10372,6 +10253,13 @@ export const orDie = <A, E, R>(self: Stream<A, E, R>): Stream<A, never, R> => fr
10372
10253
  * The `log` option controls whether the failure is logged before the stream
10373
10254
  * terminates.
10374
10255
  *
10256
+ * **Gotchas**
10257
+ *
10258
+ * Defects take precedence over typed errors. If the cause also contains a
10259
+ * defect, the failure is not ignored and is propagated with every typed error
10260
+ * converted to a defect. An interruption alongside a typed error does not
10261
+ * prevent the error from being ignored.
10262
+ *
10375
10263
  * **Example** (Ignoring stream failures)
10376
10264
  *
10377
10265
  * ```ts import.meta.vitest
@@ -10489,6 +10377,12 @@ export const ignoreCause: <
10489
10377
  * The schedule is reset as soon as the first element passes through the
10490
10378
  * stream again.
10491
10379
  *
10380
+ * **Gotchas**
10381
+ *
10382
+ * Defects take precedence over typed errors. A failure whose cause contains a
10383
+ * defect is not retried and is propagated with every typed error converted to a
10384
+ * defect. A typed error alongside an interruption is retried.
10385
+ *
10492
10386
  * **Example** (Retrying stream failures)
10493
10387
  *
10494
10388
  * ```ts import.meta.vitest
@@ -10524,6 +10418,12 @@ export const retry: {
10524
10418
  * The schedule is reset as soon as the first element passes through the
10525
10419
  * stream again.
10526
10420
  *
10421
+ * **Gotchas**
10422
+ *
10423
+ * Defects take precedence over typed errors. A failure whose cause contains a
10424
+ * defect is not retried and is propagated with every typed error converted to a
10425
+ * defect. A typed error alongside an interruption is retried.
10426
+ *
10527
10427
  * **Example** (Retrying stream failures)
10528
10428
  *
10529
10429
  * ```ts import.meta.vitest
@@ -10565,6 +10465,12 @@ export const retry: {
10565
10465
  * The schedule is reset as soon as the first element passes through the
10566
10466
  * stream again.
10567
10467
  *
10468
+ * **Gotchas**
10469
+ *
10470
+ * Defects take precedence over typed errors. A failure whose cause contains a
10471
+ * defect is not retried and is propagated with every typed error converted to a
10472
+ * defect. A typed error alongside an interruption is retried.
10473
+ *
10568
10474
  * **Example** (Retrying stream failures)
10569
10475
  *
10570
10476
  * ```ts import.meta.vitest
@@ -10847,57 +10753,7 @@ export const withExecutionPlan: {
10847
10753
  return emitter.end(state, exit)
10848
10754
  })
10849
10755
  )
10850
- let lastError = Option.none</**
10851
- * Applies an `ExecutionPlan` to a stream, retrying with step-provided resources
10852
- * until it succeeds or the plan is exhausted.
10853
- *
10854
- * **Details**
10855
- *
10856
- * By default, a failing step can fallback even after emitting elements; set
10857
- * `preventFallbackOnPartialStream` to fail instead of mixing partial output with
10858
- * a later fallback.
10859
- *
10860
- * Attempts can be observed from outside the stream by passing
10861
- * `options.onEvent`, which receives an `ExecutionPlan.Event` before each
10862
- * attempt and after it settles; see `Effect.withExecutionPlan` for the handler
10863
- * semantics. When a downstream consumer stops pulling early (for example
10864
- * `Stream.take` outside the plan), the truncated attempt reports
10865
- * `AttemptSuccess`: the consumer stopped, not the source.
10866
- *
10867
- * **Example** (Applying an execution plan)
10868
- *
10869
- * ```ts import.meta.vitest
10870
- * import { Context, Effect, ExecutionPlan, Layer, Stream } from "effect"
10871
- *
10872
- * class Service extends Context.Service<Service>()("Service", {
10873
- * make: Effect.succeed({
10874
- * stream: Stream.fail("A") as Stream.Stream<number, string>
10875
- * })
10876
- * }) {
10877
- * static Bad = Layer.succeed(Service, Service.of({ stream: Stream.fail("A") }))
10878
- * static Good = Layer.succeed(Service, Service.of({ stream: Stream.make(1, 2, 3) }))
10879
- * }
10880
- *
10881
- * const plan = ExecutionPlan.make(
10882
- * { provide: Service.Bad },
10883
- * { provide: Service.Good }
10884
- * )
10885
- *
10886
- * const stream = Stream.unwrap(Effect.map(Service, (_) => _.stream))
10887
- *
10888
- * const program = Effect.gen(function*() {
10889
- * const items = yield* stream.pipe(Stream.withExecutionPlan(plan), Stream.runCollect)
10890
- * items // => [ 1, 2, 3 ]
10891
- * })
10892
- *
10893
- * await Effect.runPromise(program)
10894
- * ```
10895
- *
10896
- * @stability unstable
10897
- * @category error handling
10898
- * @since 3.16.0
10899
- */
10900
- E | PolicyE>()
10756
+ let lastError = Option.none<E | PolicyE>()
10901
10757
  const loop: Stream<
10902
10758
  A,
10903
10759
  E | PolicyE,
@@ -12533,36 +12389,7 @@ export const dropRight: {
12533
12389
  if (count === 0) return self
12534
12390
  return transformPull(self, (pull, _scope) =>
12535
12391
  Effect.sync(() => {
12536
- const list = MutableList.make</**
12537
- * Drops the last specified number of elements from this stream.
12538
- *
12539
- * **Details**
12540
- *
12541
- * Keeps the last `n` elements in memory to drop them on completion. Finite
12542
- * fractional values of `n` are rounded down. `NaN` and non-positive values
12543
- * return the source stream unchanged.
12544
- *
12545
- * **Example** (Dropping values from the right)
12546
- *
12547
- * ```ts import.meta.vitest
12548
- * import { Effect, Stream } from "effect"
12549
- *
12550
- * const program = Effect.gen(function*() {
12551
- * const result = yield* Stream.make(1, 2, 3, 4, 5).pipe(
12552
- * Stream.dropRight(2),
12553
- * Stream.runCollect
12554
- * )
12555
- * result // => [ 1, 2, 3 ]
12556
- * })
12557
- *
12558
- * await Effect.runPromise(program)
12559
- * ```
12560
- *
12561
- * @stability stable
12562
- * @category filtering
12563
- * @since 2.0.0
12564
- */
12565
- A>()
12392
+ const list = MutableList.make<A>()
12566
12393
  const emit: Pull.Pull<Arr.NonEmptyReadonlyArray<A>, E> = Effect.flatMap(pull, (arr) => {
12567
12394
  MutableList.appendAllUnsafe(list, arr)
12568
12395
  const toTake = list.length - count
@@ -12570,7 +12397,7 @@ export const dropRight: {
12570
12397
  return Arr.isArrayNonEmpty(items) ? Effect.succeed(items) : emit
12571
12398
  })
12572
12399
  return emit
12573
- }));
12400
+ }))
12574
12401
  }
12575
12402
  )
12576
12403
 
@@ -12698,36 +12525,7 @@ export const rechunk: {
12698
12525
  target = Count.normalizeNonEmpty(target)
12699
12526
  return transformPull(self, (pull, _scope) =>
12700
12527
  Effect.sync(() => {
12701
- let chunk = Arr.empty</**
12702
- * Groups the stream into arrays of the specified size, preserving element order.
12703
- *
12704
- * **Details**
12705
- *
12706
- * Finite fractional sizes are rounded down. `NaN` and non-positive sizes are
12707
- * treated as `1`.
12708
- *
12709
- * **Example** (Rechunking stream elements)
12710
- *
12711
- * ```ts import.meta.vitest
12712
- * import { Effect, Stream } from "effect"
12713
- *
12714
- * const program = Effect.gen(function*() {
12715
- * const result = yield* Stream.make(1, 2, 3, 4, 5).pipe(
12716
- * Stream.rechunk(2),
12717
- * Stream.chunks,
12718
- * Stream.runCollect
12719
- * )
12720
- * result // => [ [ 1, 2 ], [ 3, 4 ], [ 5 ] ]
12721
- * })
12722
- *
12723
- * await Effect.runPromise(program)
12724
- * ```
12725
- *
12726
- * @stability stable
12727
- * @category grouping
12728
- * @since 2.0.0
12729
- */
12730
- A>() as Arr.NonEmptyArray<A>
12528
+ let chunk = Arr.empty<A>() as Arr.NonEmptyArray<A>
12731
12529
  let index = 0
12732
12530
  let current: Arr.NonEmptyReadonlyArray<A> | undefined
12733
12531
  let done = false
@@ -12768,7 +12566,7 @@ export const rechunk: {
12768
12566
  return Effect.succeed(result)
12769
12567
  })
12770
12568
  )
12771
- }));
12569
+ }))
12772
12570
  })
12773
12571
 
12774
12572
  /**
@@ -12956,35 +12754,7 @@ export const slidingSize: {
12956
12754
  return transformPull(self, (upstream, _scope) =>
12957
12755
  Effect.sync(() => {
12958
12756
  let cause: Cause.Cause<E | Cause.Done> | null = null
12959
- const list = MutableList.make</**
12960
- * Emits sliding windows of `chunkSize` elements, advancing by `stepSize`.
12961
- *
12962
- * **Details**
12963
- *
12964
- * Finite fractional window and step sizes are rounded down. `NaN` and
12965
- * non-positive sizes are treated as `1`.
12966
- *
12967
- * **Example** (Emitting sliding windows with a step size)
12968
- *
12969
- * ```ts import.meta.vitest
12970
- * import { Effect, Stream } from "effect"
12971
- *
12972
- * const program = Effect.gen(function*() {
12973
- * const chunks = yield* Stream.make(1, 2, 3, 4, 5).pipe(
12974
- * Stream.slidingSize(3, 2),
12975
- * Stream.runCollect
12976
- * )
12977
- * chunks // => [ [ 1, 2, 3 ], [ 3, 4, 5 ] ]
12978
- * })
12979
- *
12980
- * await Effect.runPromise(program)
12981
- * ```
12982
- *
12983
- * @stability stable
12984
- * @category grouping
12985
- * @since 2.0.0
12986
- */
12987
- A>()
12757
+ const list = MutableList.make<A>()
12988
12758
  let emitted = false
12989
12759
  let skip = 0
12990
12760
  const pull: Pull.Pull<
@@ -13022,7 +12792,7 @@ export const slidingSize: {
13022
12792
  })
13023
12793
 
13024
12794
  return Effect.suspend(() => cause ? Effect.failCause(cause) : pull)
13025
- }));
12795
+ }))
13026
12796
  }
13027
12797
  )
13028
12798
 
@@ -13171,34 +12941,7 @@ export const split: {
13171
12941
  predicate: Predicate<NoInfer<A>>
13172
12942
  ): Stream<Arr.NonEmptyReadonlyArray<A>, E, R> =>
13173
12943
  mapAccumArray(self, Arr.empty<A>, (acc, arr) => {
13174
- const out = Arr.empty</**
13175
- * Splits the stream into non-empty groups whenever the predicate matches.
13176
- *
13177
- * **Details**
13178
- *
13179
- * Matching elements act as delimiters and are not included in the output.
13180
- *
13181
- * **Example** (Splitting on matching values)
13182
- *
13183
- * ```ts import.meta.vitest
13184
- * import { Effect, Stream } from "effect"
13185
- *
13186
- * const program = Effect.gen(function*() {
13187
- * const result = yield* Stream.range(0, 9).pipe(
13188
- * Stream.split((n) => n % 4 === 0),
13189
- * Stream.runCollect
13190
- * )
13191
- * result // => [ [ 1, 2, 3 ], [ 5, 6, 7 ], [ 9 ] ]
13192
- * })
13193
- *
13194
- * await Effect.runPromise(program)
13195
- * ```
13196
- *
13197
- * @stability stable
13198
- * @category grouping
13199
- * @since 2.0.0
13200
- */
13201
- Arr.NonEmptyReadonlyArray<A>>()
12944
+ const out = Arr.empty<Arr.NonEmptyReadonlyArray<A>>()
13202
12945
  for (let i = 0; i < arr.length; i++) {
13203
12946
  if (predicate(arr[i])) {
13204
12947
  if (Arr.isArrayNonEmpty(acc)) {
@@ -13639,38 +13382,13 @@ export const mapAccum: {
13639
13382
  self.channel,
13640
13383
  initial,
13641
13384
  (state, arr) => {
13642
- const acc = Arr.empty</**
13643
- * Maps elements statefully, emitting zero or more outputs per input.
13644
- *
13645
- * **Example** (Statefully mapping stream values)
13646
- *
13647
- * ```ts import.meta.vitest
13648
- * import { Console, Effect, Stream } from "effect"
13649
- *
13650
- * const program = Effect.gen(function*() {
13651
- * const totals = yield* Stream.make(0, 1, 2, 3, 4, 5, 6).pipe(
13652
- * Stream.mapAccum(() => 0, (total, n) => {
13653
- * const next = total + n
13654
- * return [next, [next]] as const
13655
- * }),
13656
- * Stream.runCollect
13657
- * )
13658
- *
13659
- * totals // => [0, 1, 3, 6, 10, 15, 21]
13660
- * })
13661
- *
13662
- * await Effect.runPromise(program)
13663
- * ```
13664
- *
13665
- * @stability stable
13666
- * @category mapping
13667
- * @since 2.0.0
13668
- */
13669
- B>()
13385
+ const acc = Arr.empty<B>()
13670
13386
  for (let index = 0; index < arr.length; index++) {
13671
13387
  const [newState, values] = f(state, arr[index])
13672
13388
  state = newState
13673
- acc.push(...values)
13389
+ for (let i = 0; i < values.length; i++) {
13390
+ acc.push(values[i])
13391
+ }
13674
13392
  }
13675
13393
  return [state, Arr.isArrayNonEmpty(acc) ? Arr.of(acc) : emptyArr]
13676
13394
  },
@@ -13968,45 +13686,7 @@ export const mapAccumEffect: {
13968
13686
  f(state, a),
13969
13687
  ([state, values]) => [
13970
13688
  state,
13971
- Arr.isReadonlyArrayNonEmpty(values) ? Arr.of(values) : Arr.empty</**
13972
- * Maps each element statefully and effectfully, emitting zero or more output
13973
- * values per input.
13974
- *
13975
- * **When to use**
13976
- *
13977
- * Use when stateful element mapping needs Effects or can fail while emitting
13978
- * zero or more values per input element.
13979
- *
13980
- * **Details**
13981
- *
13982
- * The mapping effect receives the current state and element, then returns the
13983
- * next state plus the values to emit. The state is threaded through the
13984
- * stream.
13985
- *
13986
- * **Example** (Effectfully mapping stream values with state)
13987
- *
13988
- * ```ts import.meta.vitest
13989
- * import { Effect, Stream } from "effect"
13990
- *
13991
- * const program = Effect.gen(function*() {
13992
- * const result = yield* Stream.make(1, 1, 1).pipe(
13993
- * Stream.mapAccumEffect(() => 0, (total, n) =>
13994
- * Effect.succeed([total + n, [total + n]])
13995
- * ),
13996
- * Stream.runCollect
13997
- * )
13998
- *
13999
- * result // => [ 1, 2, 3 ]
14000
- * })
14001
- *
14002
- * await Effect.runPromise(program)
14003
- * ```
14004
- *
14005
- * @stability stable
14006
- * @category mapping
14007
- * @since 2.0.0
14008
- */
14009
- Arr.NonEmptyReadonlyArray<B>>()
13689
+ Arr.isReadonlyArrayNonEmpty(values) ? Arr.of(values) : Arr.empty<Arr.NonEmptyReadonlyArray<B>>()
14010
13690
  ]
14011
13691
  ),
14012
13692
  options?.onHalt ?
@@ -14270,37 +13950,14 @@ export const scan: {
14270
13950
  return concat(
14271
13951
  succeed(seed),
14272
13952
  fromChannel(Channel.mapAccum(self.channel, () => seed, (state, arr) => {
14273
- const states = Arr.empty</**
14274
- * Accumulates state across the stream, emitting the initial state and each updated state.
14275
- *
14276
- * **Example** (Scanning stream state)
14277
- *
14278
- * ```ts import.meta.vitest
14279
- * import { Effect, Stream } from "effect"
14280
- *
14281
- * const program = Effect.gen(function*() {
14282
- * const values = yield* Stream.make(1, 2, 3).pipe(
14283
- * Stream.scan(() => 0, (acc, n) => acc + n),
14284
- * Stream.runCollect
14285
- * )
14286
- * values // => [ 0, 1, 3, 6 ]
14287
- * })
14288
- *
14289
- * await Effect.runPromise(program)
14290
- * ```
14291
- *
14292
- * @stability stable
14293
- * @category accumulation
14294
- * @since 2.0.0
14295
- */
14296
- S>() as Arr.NonEmptyArray<S>
13953
+ const states = Arr.empty<S>() as Arr.NonEmptyArray<S>
14297
13954
  for (let index = 0; index < arr.length; index++) {
14298
13955
  state = f(state, arr[index])
14299
13956
  states.push(state)
14300
13957
  }
14301
13958
  return [state, Arr.of(states)]
14302
13959
  }))
14303
- );
13960
+ )
14304
13961
  }))
14305
13962
 
14306
13963
  /**
@@ -15397,67 +15054,7 @@ export const groupByKey: {
15397
15054
  }
15398
15055
  ): Stream<readonly [K, Stream<A>], E, R> =>
15399
15056
  suspend(() => {
15400
- const batch = MutableHashMap.empty</**
15401
- * Groups elements by a key and emits a stream per key.
15402
- *
15403
- * **Example** (Grouping elements by key)
15404
- *
15405
- * ```ts import.meta.vitest
15406
- * import { Effect, Stream } from "effect"
15407
- *
15408
- * const program = Effect.gen(function*() {
15409
- * const grouped = yield* Stream.make(1, 2, 3, 4, 5).pipe(
15410
- * Stream.groupByKey((n) => n % 2 === 0 ? "even" : "odd"),
15411
- * Stream.mapEffect(
15412
- * ([key, stream]) =>
15413
- * Stream.runCollect(stream).pipe(
15414
- * Effect.map((values) => [key, values] as const)
15415
- * ),
15416
- * { concurrency: "unbounded" }
15417
- * ),
15418
- * Stream.runCollect
15419
- * )
15420
- * grouped // => [ [ 'odd', [ 1, 3, 5 ] ], [ 'even', [ 2, 4 ] ] ]
15421
- * })
15422
- *
15423
- * await Effect.runPromise(program)
15424
- * ```
15425
- *
15426
- * @stability stable
15427
- * @category grouping
15428
- * @since 2.0.0
15429
- */
15430
- K, /**
15431
- * Groups elements by a key and emits a stream per key.
15432
- *
15433
- * **Example** (Grouping elements by key)
15434
- *
15435
- * ```ts import.meta.vitest
15436
- * import { Effect, Stream } from "effect"
15437
- *
15438
- * const program = Effect.gen(function*() {
15439
- * const grouped = yield* Stream.make(1, 2, 3, 4, 5).pipe(
15440
- * Stream.groupByKey((n) => n % 2 === 0 ? "even" : "odd"),
15441
- * Stream.mapEffect(
15442
- * ([key, stream]) =>
15443
- * Stream.runCollect(stream).pipe(
15444
- * Effect.map((values) => [key, values] as const)
15445
- * ),
15446
- * { concurrency: "unbounded" }
15447
- * ),
15448
- * Stream.runCollect
15449
- * )
15450
- * grouped // => [ [ 'odd', [ 1, 3, 5 ] ], [ 'even', [ 2, 4 ] ] ]
15451
- * })
15452
- *
15453
- * await Effect.runPromise(program)
15454
- * ```
15455
- *
15456
- * @stability stable
15457
- * @category grouping
15458
- * @since 2.0.0
15459
- */
15460
- Arr.NonEmptyArray<A>>()
15057
+ const batch = MutableHashMap.empty<K, Arr.NonEmptyArray<A>>()
15461
15058
  return groupByImpl(
15462
15059
  self,
15463
15060
  Effect.fnUntraced(function*(arr, queues, queueMap) {
@@ -15610,29 +15207,7 @@ export const groupAdjacentBy: {
15610
15207
  Effect.sync(() => {
15611
15208
  let currentKey: K = undefined as any
15612
15209
  let group: Arr.NonEmptyArray<A> | undefined
15613
- let toEmit = Arr.empty</**
15614
- * Groups consecutive elements that have equal keys into non-empty arrays.
15615
- *
15616
- * **When to use**
15617
- *
15618
- * Use when you already have a stream ordered by the grouping key and want to
15619
- * emit each consecutive run as a non-empty array while keeping later
15620
- * non-adjacent runs separate.
15621
- *
15622
- * **Details**
15623
- *
15624
- * The key is computed with `f`; adjacent elements whose keys are equal by
15625
- * `Equal.equals` are emitted as one `[key, group]`. Later non-adjacent runs
15626
- * with the same key are emitted separately.
15627
- *
15628
- * @see {@link groupByKey} for grouping all elements with the same key across the stream
15629
- * @see {@link groupBy} for custom grouped stream construction
15630
- *
15631
- * @stability stable
15632
- * @category grouping
15633
- * @since 2.0.0
15634
- */
15635
- readonly [K, Arr.NonEmptyArray<A>]>()
15210
+ let toEmit = Arr.empty<readonly [K, Arr.NonEmptyArray<A>]>()
15636
15211
  const loop: Pull.Pull<
15637
15212
  Arr.NonEmptyReadonlyArray<readonly [K, Arr.NonEmptyArray<A>]>,
15638
15213
  E
@@ -16019,89 +15594,7 @@ export const aggregateWithin: {
16019
15594
 
16020
15595
  const pullLatch = Latch.makeUnsafe(false)
16021
15596
  const scheduleStep = Symbol()
16022
- const buffer = yield* Queue.make</**
16023
- * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.
16024
- *
16025
- * **Details**
16026
- *
16027
- * The schedule can flush the current aggregation even if the sink has not finished.
16028
- * It is stepped at most once per aggregation, when the aggregation receives its
16029
- * first element, with the previous aggregation's output as input. An aggregation
16030
- * the sink completes immediately, such as one built from leftovers, may finish
16031
- * without stepping the schedule.
16032
- *
16033
- * Time between aggregations is hidden from the schedule, so an idle stream does
16034
- * not run it. Time-based schedules such as `Schedule.fixed` and
16035
- * `Schedule.upTo({ duration })` only count time spent aggregating; use
16036
- * `Schedule.spaced` for a flush timer.
16037
- *
16038
- * When the schedule ends, the stream emits the current aggregation and any sink
16039
- * leftovers, then ends without pulling more from upstream.
16040
- *
16041
- * **Example** (Aggregating with a sink and schedule)
16042
- *
16043
- * ```ts import.meta.vitest
16044
- * import { Effect, Schedule, Sink, Stream } from "effect"
16045
- *
16046
- * await Effect.runPromise(Effect.gen(function* () {
16047
- * const aggregated = yield* Stream.runCollect(
16048
- * Stream.make(1, 2, 3, 4, 5, 6).pipe(
16049
- * Stream.aggregateWithin(
16050
- * Sink.foldUntil(() => 0, 3, (sum, n) => Effect.succeed(sum + n)),
16051
- * Schedule.forever
16052
- * )
16053
- * )
16054
- * )
16055
- * aggregated // => [ 6, 15 ]
16056
- * }))
16057
- * ```
16058
- *
16059
- * @stability stable
16060
- * @category aggregation
16061
- * @since 2.0.0
16062
- */
16063
- Arr.NonEmptyReadonlyArray<A> | typeof scheduleStep, /**
16064
- * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.
16065
- *
16066
- * **Details**
16067
- *
16068
- * The schedule can flush the current aggregation even if the sink has not finished.
16069
- * It is stepped at most once per aggregation, when the aggregation receives its
16070
- * first element, with the previous aggregation's output as input. An aggregation
16071
- * the sink completes immediately, such as one built from leftovers, may finish
16072
- * without stepping the schedule.
16073
- *
16074
- * Time between aggregations is hidden from the schedule, so an idle stream does
16075
- * not run it. Time-based schedules such as `Schedule.fixed` and
16076
- * `Schedule.upTo({ duration })` only count time spent aggregating; use
16077
- * `Schedule.spaced` for a flush timer.
16078
- *
16079
- * When the schedule ends, the stream emits the current aggregation and any sink
16080
- * leftovers, then ends without pulling more from upstream.
16081
- *
16082
- * **Example** (Aggregating with a sink and schedule)
16083
- *
16084
- * ```ts import.meta.vitest
16085
- * import { Effect, Schedule, Sink, Stream } from "effect"
16086
- *
16087
- * await Effect.runPromise(Effect.gen(function* () {
16088
- * const aggregated = yield* Stream.runCollect(
16089
- * Stream.make(1, 2, 3, 4, 5, 6).pipe(
16090
- * Stream.aggregateWithin(
16091
- * Sink.foldUntil(() => 0, 3, (sum, n) => Effect.succeed(sum + n)),
16092
- * Schedule.forever
16093
- * )
16094
- * )
16095
- * )
16096
- * aggregated // => [ 6, 15 ]
16097
- * }))
16098
- * ```
16099
- *
16100
- * @stability stable
16101
- * @category aggregation
16102
- * @since 2.0.0
16103
- */
16104
- E | Cause.Done<void>>({
15597
+ const buffer = yield* Queue.make<Arr.NonEmptyReadonlyArray<A> | typeof scheduleStep, E | Cause.Done<void>>({
16105
15598
  capacity: 0
16106
15599
  })
16107
15600
 
@@ -16122,48 +15615,7 @@ export const aggregateWithin: {
16122
15615
  const hasInput = Latch.makeUnsafe(false)
16123
15616
  let scheduleTime = clock.currentTimeMillisUnsafe()
16124
15617
  let openedAt = 0
16125
- let lastOutput = Option.none</**
16126
- * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers.
16127
- *
16128
- * **Details**
16129
- *
16130
- * The schedule can flush the current aggregation even if the sink has not finished.
16131
- * It is stepped at most once per aggregation, when the aggregation receives its
16132
- * first element, with the previous aggregation's output as input. An aggregation
16133
- * the sink completes immediately, such as one built from leftovers, may finish
16134
- * without stepping the schedule.
16135
- *
16136
- * Time between aggregations is hidden from the schedule, so an idle stream does
16137
- * not run it. Time-based schedules such as `Schedule.fixed` and
16138
- * `Schedule.upTo({ duration })` only count time spent aggregating; use
16139
- * `Schedule.spaced` for a flush timer.
16140
- *
16141
- * When the schedule ends, the stream emits the current aggregation and any sink
16142
- * leftovers, then ends without pulling more from upstream.
16143
- *
16144
- * **Example** (Aggregating with a sink and schedule)
16145
- *
16146
- * ```ts import.meta.vitest
16147
- * import { Effect, Schedule, Sink, Stream } from "effect"
16148
- *
16149
- * await Effect.runPromise(Effect.gen(function* () {
16150
- * const aggregated = yield* Stream.runCollect(
16151
- * Stream.make(1, 2, 3, 4, 5, 6).pipe(
16152
- * Stream.aggregateWithin(
16153
- * Sink.foldUntil(() => 0, 3, (sum, n) => Effect.succeed(sum + n)),
16154
- * Schedule.forever
16155
- * )
16156
- * )
16157
- * )
16158
- * aggregated // => [ 6, 15 ]
16159
- * }))
16160
- * ```
16161
- *
16162
- * @stability stable
16163
- * @category aggregation
16164
- * @since 2.0.0
16165
- */
16166
- B>()
15618
+ let lastOutput = Option.none<B>()
16167
15619
  let leftover: Arr.NonEmptyReadonlyArray<A2> | undefined
16168
15620
  const onInput = <X>(chunk: X): Effect.Effect<X> => {
16169
15621
  if (hasInput.openUnsafe()) {
@@ -16374,47 +15826,7 @@ export const broadcastN: {
16374
15826
  }
16375
15827
  ) {
16376
15828
  const n = Count.normalize(options.n)
16377
- const pubsub = yield* makePubSub</**
16378
- * Creates a fixed-size tuple of streams that each emit
16379
- * the same elements as the source stream.
16380
- *
16381
- * **Details**
16382
- *
16383
- * The source stream starts after all downstream streams have been subscribed.
16384
- * With the default suspend strategy, the source can only advance `capacity`
16385
- * chunks ahead of the slowest downstream stream. If a downstream stream is
16386
- * interrupted, it unsubscribes from the broadcast so it no longer contributes
16387
- * backpressure. Finite fractional values of `n` are rounded down. `NaN` and
16388
- * non-positive values create no downstream streams.
16389
- *
16390
- * **Example** (Broadcasting to two consumers)
16391
- *
16392
- * ```ts import.meta.vitest
16393
- * import { Effect, Stream } from "effect"
16394
- *
16395
- * const program = Effect.scoped(
16396
- * Effect.gen(function*() {
16397
- * const [left, right] = yield* Stream.make(1, 2, 3).pipe(
16398
- * Stream.broadcastN({ n: 2, capacity: 8 })
16399
- * )
16400
- *
16401
- * const values = yield* Effect.all([
16402
- * Stream.runCollect(left),
16403
- * Stream.runCollect(right)
16404
- * ], { concurrency: "unbounded" })
16405
- *
16406
- * values // => [ [ 1, 2, 3 ], [ 1, 2, 3 ] ]
16407
- * })
16408
- * )
16409
- *
16410
- * await Effect.runPromise(program)
16411
- * ```
16412
- *
16413
- * @stability stable
16414
- * @category broadcasting
16415
- * @since 4.0.0
16416
- */
16417
- Take.Take<A, E>>(options)
15829
+ const pubsub = yield* makePubSub<Take.Take<A, E>>(options)
16418
15830
  const streams = new Array(n)
16419
15831
  const parentScope = yield* Scope.Scope
16420
15832
  for (let i = 0; i < n; i++) {
@@ -17469,10 +16881,10 @@ export const decodeText: <
17469
16881
  <E, R>(self: Stream<Uint8Array, E, R>, options?: {
17470
16882
  readonly encoding?: string | undefined
17471
16883
  }): Stream<string, E, R> =>
17472
- suspend(() => {
17473
- const decoder = new TextDecoder(options?.encoding)
17474
- return map(self, (chunk) => decoder.decode(chunk, { stream: true }))
17475
- })
16884
+ self.channel.pipe(
16885
+ Channel.pipeTo(Channel.decodeText(options?.encoding)),
16886
+ fromChannel
16887
+ )
17476
16888
  )
17477
16889
 
17478
16890
  /**
@@ -17923,39 +17335,7 @@ export const interleaveWith: {
17923
17335
  )).pipe(
17924
17336
  Pull.catchDone(() => {
17925
17337
  leftDone = true
17926
- return Effect.succeed</**
17927
- * Interleaves two streams deterministically by following a boolean decider stream.
17928
- *
17929
- * **Details**
17930
- *
17931
- * The decider controls how many elements are pulled; if one side ends, pulls for
17932
- * that side are ignored.
17933
- *
17934
- * **Example** (Interleaving two streams deterministically by following a boolean decider stream)
17935
- *
17936
- * ```ts import.meta.vitest
17937
- * import { Effect, Stream } from "effect"
17938
- *
17939
- * const program = Effect.gen(function*() {
17940
- * const left = Stream.make(1, 3, 5)
17941
- * const right = Stream.make(2, 4, 6)
17942
- * const decider = Stream.make(true, false, false, true, true)
17943
- *
17944
- * const values = yield* Stream.runCollect(
17945
- * Stream.interleaveWith(left, right, decider)
17946
- * )
17947
- *
17948
- * values // => [ 1, 2, 4, 3, 5 ]
17949
- * })
17950
- *
17951
- * await Effect.runPromise(program)
17952
- * ```
17953
- *
17954
- * @stability stable
17955
- * @category merging
17956
- * @since 2.0.0
17957
- */
17958
- retry>(retry);
17338
+ return Effect.succeed<retry>(retry)
17959
17339
  })
17960
17340
  )
17961
17341
  const pullRight = (yield* Channel.toTransform(Channel.flattenArray(that.channel))(
@@ -17964,39 +17344,7 @@ export const interleaveWith: {
17964
17344
  )).pipe(
17965
17345
  Pull.catchDone(() => {
17966
17346
  rightDone = true
17967
- return Effect.succeed</**
17968
- * Interleaves two streams deterministically by following a boolean decider stream.
17969
- *
17970
- * **Details**
17971
- *
17972
- * The decider controls how many elements are pulled; if one side ends, pulls for
17973
- * that side are ignored.
17974
- *
17975
- * **Example** (Interleaving two streams deterministically by following a boolean decider stream)
17976
- *
17977
- * ```ts import.meta.vitest
17978
- * import { Effect, Stream } from "effect"
17979
- *
17980
- * const program = Effect.gen(function*() {
17981
- * const left = Stream.make(1, 3, 5)
17982
- * const right = Stream.make(2, 4, 6)
17983
- * const decider = Stream.make(true, false, false, true, true)
17984
- *
17985
- * const values = yield* Stream.runCollect(
17986
- * Stream.interleaveWith(left, right, decider)
17987
- * )
17988
- *
17989
- * values // => [ 1, 2, 4, 3, 5 ]
17990
- * })
17991
- *
17992
- * await Effect.runPromise(program)
17993
- * ```
17994
- *
17995
- * @stability stable
17996
- * @category merging
17997
- * @since 2.0.0
17998
- */
17999
- retry>(retry);
17347
+ return Effect.succeed<retry>(retry)
18000
17348
  })
18001
17349
  )
18002
17350
 
@@ -18804,7 +18152,8 @@ export const ensuring: {
18804
18152
  /**
18805
18153
  * Provides a layer or context to the stream, removing the corresponding
18806
18154
  * service requirements. Use `options.local` to build the layer every time; by
18807
- * default, layers are shared between provide calls.
18155
+ * default, a layer already built by an enclosing provide or runtime is reused;
18156
+ * sibling provide calls build their own copies.
18808
18157
  *
18809
18158
  * **Example** (Providing stream requirements)
18810
18159
  *
@@ -18835,7 +18184,8 @@ export const provide: {
18835
18184
  /**
18836
18185
  * Provides a layer or context to the stream, removing the corresponding
18837
18186
  * service requirements. Use `options.local` to build the layer every time; by
18838
- * default, layers are shared between provide calls.
18187
+ * default, a layer already built by an enclosing provide or runtime is reused;
18188
+ * sibling provide calls build their own copies.
18839
18189
  *
18840
18190
  * **Example** (Providing stream requirements)
18841
18191
  *
@@ -18873,7 +18223,8 @@ export const provide: {
18873
18223
  /**
18874
18224
  * Provides a layer or context to the stream, removing the corresponding
18875
18225
  * service requirements. Use `options.local` to build the layer every time; by
18876
- * default, layers are shared between provide calls.
18226
+ * default, a layer already built by an enclosing provide or runtime is reused;
18227
+ * sibling provide calls build their own copies.
18877
18228
  *
18878
18229
  * **Example** (Providing stream requirements)
18879
18230
  *
@@ -20752,7 +20103,7 @@ export const mkArrayBuffer = <E, R>(self: Stream<Uint8Array, E, R>): Effect.Effe
20752
20103
  * @category destructors
20753
20104
  * @since 4.0.0
20754
20105
  */
20755
- export const mkUint8Array = <E, R>(self: Stream<Uint8Array, E, R>): Effect.Effect<Uint8Array, E, R> =>
20106
+ export const mkUint8Array = <E, R>(self: Stream<Uint8Array, E, R>): Effect.Effect<Uint8Array<ArrayBuffer>, E, R> =>
20756
20107
  Channel.mkUint8Array(self.channel)
20757
20108
 
20758
20109
  /**
@@ -20882,15 +20233,18 @@ export const toReadableStreamWith: {
20882
20233
  return new ReadableStream<A>({
20883
20234
  start(controller) {
20884
20235
  fiber = Effect.runFork(Effect.provideContext(
20885
- runForEachArray(self, (chunk) =>
20886
- latch.whenOpen(Effect.sync(() => {
20887
- latch.closeUnsafe()
20888
- for (let i = 0; i < chunk.length; i++) {
20889
- controller.enqueue(chunk[i])
20890
- }
20891
- currentResolve!()
20892
- currentResolve = undefined
20893
- }))),
20236
+ Channel.runForEach(
20237
+ Channel.transformPull(self.channel, (pull) => Effect.succeed(latch.whenOpen(pull))),
20238
+ (chunk) =>
20239
+ Effect.sync(() => {
20240
+ latch.closeUnsafe()
20241
+ for (let i = 0; i < chunk.length; i++) {
20242
+ controller.enqueue(chunk[i])
20243
+ }
20244
+ currentResolve!()
20245
+ currentResolve = undefined
20246
+ })
20247
+ ),
20894
20248
  context
20895
20249
  ))
20896
20250
  fiber.addObserver((exit) => {
@@ -21109,38 +20463,7 @@ export const toReadableStreamEffect: {
21109
20463
  options?: { readonly strategy?: QueuingStrategy<A> | undefined }
21110
20464
  ): Effect.Effect<ReadableStream<A>, never, R> =>
21111
20465
  Effect.map(
21112
- Effect.context</**
21113
- * Creates an Effect that builds a ReadableStream from the stream.
21114
- *
21115
- * **When to use**
21116
- *
21117
- * Use when bridging to Web Streams from inside an `Effect` so the required
21118
- * services can be captured from the current context.
21119
- *
21120
- * **Details**
21121
- *
21122
- * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream.
21123
- *
21124
- * **Example** (Creating a ReadableStream effect)
21125
- *
21126
- * ```ts import.meta.vitest
21127
- * import { Effect, Stream } from "effect"
21128
- *
21129
- * const stream = Stream.make(1, 2, 3, 4, 5)
21130
- *
21131
- * const effect = Effect.gen(function*() {
21132
- * const readableStream = yield* Stream.toReadableStreamEffect(stream)
21133
- * readableStream instanceof ReadableStream // => true
21134
- * })
21135
- *
21136
- * await Effect.runPromise(effect)
21137
- * ```
21138
- *
21139
- * @stability stable
21140
- * @category destructors
21141
- * @since 2.0.0
21142
- */
21143
- R>(),
20466
+ Effect.context<R>(),
21144
20467
  (context) => toReadableStreamWith(self, context, options)
21145
20468
  )
21146
20469
  )