@akterjs/cli 0.0.0-stage → 0.1.1

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 (109) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +47 -2
  3. package/dist/Argument-D81dqizB.mjs +57 -0
  4. package/dist/Array-B4kuTQeW.mjs +2323 -0
  5. package/dist/Boolean-kILIvmhE.mjs +26 -0
  6. package/dist/ChildProcess-BCIwxPGc.mjs +577 -0
  7. package/dist/CliError-Cf5xqkkj.mjs +633 -0
  8. package/dist/Command-Dzq9KM-h.mjs +5135 -0
  9. package/dist/Config-B6OND9WR.mjs +854 -0
  10. package/dist/Console-BKHUkH6a.mjs +141 -0
  11. package/dist/Data-CeCULr0-.mjs +251 -0
  12. package/dist/Digest-CBd3uv5B.mjs +348 -0
  13. package/dist/Duration-EH9Vy4U6.mjs +791 -0
  14. package/dist/Effect-CKFpqbmw.mjs +12911 -0
  15. package/dist/FileSystem-4pPcEb_i.mjs +1366 -0
  16. package/dist/HttpClientError-BUeMWx70.mjs +303 -0
  17. package/dist/HttpClientResponse-D5ZKICVV.mjs +855 -0
  18. package/dist/Match-CGPLZYrV.mjs +434 -0
  19. package/dist/MutableHashMap-f8nW8AJR.mjs +376 -0
  20. package/dist/MutableHashSet-_HI572Ya.mjs +155 -0
  21. package/dist/MutableRef-D4Qv592C.mjs +107 -0
  22. package/dist/Number-BvkRkfc-.mjs +137 -0
  23. package/dist/Option-DkxSnBhp.mjs +3967 -0
  24. package/dist/Order-C1JC991I.mjs +481 -0
  25. package/dist/Path-Djdv_eF5.mjs +130 -0
  26. package/dist/Queue-CO5UQ6os.mjs +1394 -0
  27. package/dist/Redacted-RkJrG5Me.mjs +160 -0
  28. package/dist/Ref-BIPOxJNH.mjs +267 -0
  29. package/dist/Runtime-BInIAwK3.mjs +297 -0
  30. package/dist/Schema-MiKt5K1v.mjs +10999 -0
  31. package/dist/SecureRandom-B_U4ysO3.mjs +279 -0
  32. package/dist/Semaphore-DOVJ4ZGS.mjs +177 -0
  33. package/dist/Stdio-KylmOBX_.mjs +74 -0
  34. package/dist/Stream-bK9QIETN.mjs +4012 -0
  35. package/dist/String-q5dcsVe4.mjs +351 -0
  36. package/dist/TerminalCapabilities-w_44MAca.mjs +1769 -0
  37. package/dist/WebCrypto-ZI_GNVlw.mjs +33 -0
  38. package/dist/actor-call.service-CGM_vD9u.mjs +1269 -0
  39. package/dist/actor-client.adapter-Coem7gF1.mjs +3691 -0
  40. package/dist/akter-program.config-D8yb9xQP.mjs +7034 -0
  41. package/dist/akter.cli.mjs +5 -0
  42. package/dist/app-cli.config.mjs +49 -0
  43. package/dist/app-entry.pure.mjs +31 -0
  44. package/dist/archive/akter-archive.schema.mjs +65 -0
  45. package/dist/archive/akter-archive.service.mjs +309 -0
  46. package/dist/archive/archive-cli.config.mjs +45 -0
  47. package/dist/archive/archive-invalid.errors.mjs +5 -0
  48. package/dist/archive/archived-lineage.pure.mjs +13 -0
  49. package/dist/archive/tar.pure.mjs +291 -0
  50. package/dist/archive/zstd.adapter.mjs +46 -0
  51. package/dist/bench/bench-report.pure.mjs +120 -0
  52. package/dist/bench/bench-runner.pure.mjs +89 -0
  53. package/dist/bench/bench.service.mjs +301 -0
  54. package/dist/cli-runtime.layer-BqK2mmVL.mjs +1191 -0
  55. package/dist/cli-runtime.layer.mjs +1 -0
  56. package/dist/cloud-client.adapter-Cy1BjDbG.mjs +3186 -0
  57. package/dist/cloud-client.adapter-DOVMoYAj.mjs +304 -0
  58. package/dist/command/akter-commands.config.mjs +32 -0
  59. package/dist/command/akter-program.config.mjs +1 -0
  60. package/dist/credentials/credentials.service.mjs +226 -0
  61. package/dist/credentials/keychain.adapter.mjs +92 -0
  62. package/dist/credentials/login.config.mjs +251 -0
  63. package/dist/deploy/auth/api-attempt.service.mjs +30 -0
  64. package/dist/deploy/auth/token-refresh.errors.mjs +4 -0
  65. package/dist/deploy/build-bundle.adapter.mjs +133 -0
  66. package/dist/deploy/build-manifest.pure.mjs +44 -0
  67. package/dist/deploy/cloud-client.adapter.mjs +1 -0
  68. package/dist/deploy/cloud-url.pure.mjs +17 -0
  69. package/dist/deploy/deploy-failed.errors.mjs +17 -0
  70. package/dist/deploy/deploy.service.mjs +156 -0
  71. package/dist/deploy/request-failure.pure.mjs +87 -0
  72. package/dist/dev-runner.pure.mjs +30 -0
  73. package/dist/docs/doc-topics.pure.mjs +21 -0
  74. package/dist/docs/docs.config.mjs +1 -0
  75. package/dist/docs.config-D2amjsje.mjs +190 -0
  76. package/dist/docs.config-D3zzLzLR.mjs +190 -0
  77. package/dist/export/actor-export.service.mjs +267 -0
  78. package/dist/export/export-failed.errors.mjs +4 -0
  79. package/dist/export/export-failure.pure.mjs +18 -0
  80. package/dist/export/ordered-lines.pure.mjs +43 -0
  81. package/dist/export/ranged-download.pure.mjs +66 -0
  82. package/dist/export/snapshot-download.pure.mjs +86 -0
  83. package/dist/history-runner.pure.mjs +186 -0
  84. package/dist/history-since.pure.mjs +17 -0
  85. package/dist/hosted-runtime.layer-Cx3IPsEd.mjs +16358 -0
  86. package/dist/local/environment-cli.config.mjs +90 -0
  87. package/dist/local/environment-runner.pure.mjs +75 -0
  88. package/dist/local/local-cli.config.mjs +159 -0
  89. package/dist/logs/log-follow.config.mjs +21 -0
  90. package/dist/logs/log-follow.service.mjs +87 -0
  91. package/dist/logs/log-lines.pure.mjs +44 -0
  92. package/dist/migrate-runner.pure.mjs +28 -0
  93. package/dist/operation-input.pure-CS9iUhqK.mjs +1383 -0
  94. package/dist/operation-registry.pure-DVC8EDgj.mjs +283 -0
  95. package/dist/registry/actor-call.service.mjs +1 -0
  96. package/dist/registry/actor-commands.config.mjs +127 -0
  97. package/dist/registry/actor-refusal.pure.mjs +34 -0
  98. package/dist/registry/approval.service.mjs +80 -0
  99. package/dist/registry/cloud-commands.config.mjs +151 -0
  100. package/dist/registry/cloud-served.pure.mjs +31 -0
  101. package/dist/registry/operation-call.service.mjs +262 -0
  102. package/dist/registry/operation-input.pure.mjs +1 -0
  103. package/dist/registry/operation-output.pure.mjs +91 -0
  104. package/dist/registry/served-command.config.mjs +57 -0
  105. package/dist/runner-exited.errors.mjs +10 -0
  106. package/dist/terminal/cli-exit.errors.mjs +38 -0
  107. package/dist/terminal/cli-failure.pure.mjs +31 -0
  108. package/dist/terminal/confirm.adapter.mjs +27 -0
  109. package/package.json +61 -3
@@ -0,0 +1,1366 @@
1
+ import { F as of, z as sort } from "./Array-B4kuTQeW.mjs";
2
+ import { $t as suspend, A as ensuring, B as flatMap, Br as done, Cn as zipWith, Fn as catchDone, J as forkChild, K as forEach$1, M as fail, N as failCause, Nt as raceFirst, W as fnUntraced, Xt as succeed, a as all, aa as Service, at as isEffect, b as catchReason, dt as map, en as sync, gr as makeUnsafe, l as as, ln as try_, lr as doneUnsafe, q as forever, sr as _await, x as catchTag, xt as onError, y as catchIf } from "./Effect-CKFpqbmw.mjs";
3
+ import { On as pipeArguments, Sn as identity, Tn as pipe, nn as isNotUndefined, qt as hasProperty, x as match } from "./Option-DkxSnBhp.mjs";
4
+ import { b as fromPull, ct as toTransform, it as fromTransform$1, lt as unwrap$1, nt as unwrap$2, yt as join$1 } from "./Stream-bK9QIETN.mjs";
5
+ import { a as String$1, f as mapInput } from "./Order-C1JC991I.mjs";
6
+ import { i as TaggedError, n as Error$1 } from "./Data-CeCULr0-.mjs";
7
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/ByteSize.js
8
+ const bigint0 = /*#__PURE__*/ BigInt(0);
9
+ const bigint1 = /*#__PURE__*/ BigInt(1);
10
+ const decimalBase = /*#__PURE__*/ BigInt(1e3);
11
+ const binaryBase = /*#__PURE__*/ BigInt(1024);
12
+ const decimalUnits = [
13
+ {
14
+ symbol: "B",
15
+ factor: bigint1,
16
+ names: [
17
+ "B",
18
+ "byte",
19
+ "bytes"
20
+ ]
21
+ },
22
+ {
23
+ symbol: "kB",
24
+ factor: decimalBase,
25
+ names: [
26
+ "kB",
27
+ "kilobyte",
28
+ "kilobytes"
29
+ ]
30
+ },
31
+ {
32
+ symbol: "MB",
33
+ factor: decimalBase ** /*#__PURE__*/ BigInt(2),
34
+ names: [
35
+ "MB",
36
+ "megabyte",
37
+ "megabytes"
38
+ ]
39
+ },
40
+ {
41
+ symbol: "GB",
42
+ factor: decimalBase ** /*#__PURE__*/ BigInt(3),
43
+ names: [
44
+ "GB",
45
+ "gigabyte",
46
+ "gigabytes"
47
+ ]
48
+ },
49
+ {
50
+ symbol: "TB",
51
+ factor: decimalBase ** /*#__PURE__*/ BigInt(4),
52
+ names: [
53
+ "TB",
54
+ "terabyte",
55
+ "terabytes"
56
+ ]
57
+ },
58
+ {
59
+ symbol: "PB",
60
+ factor: decimalBase ** /*#__PURE__*/ BigInt(5),
61
+ names: [
62
+ "PB",
63
+ "petabyte",
64
+ "petabytes"
65
+ ]
66
+ },
67
+ {
68
+ symbol: "EB",
69
+ factor: decimalBase ** /*#__PURE__*/ BigInt(6),
70
+ names: [
71
+ "EB",
72
+ "exabyte",
73
+ "exabytes"
74
+ ]
75
+ },
76
+ {
77
+ symbol: "ZB",
78
+ factor: decimalBase ** /*#__PURE__*/ BigInt(7),
79
+ names: [
80
+ "ZB",
81
+ "zettabyte",
82
+ "zettabytes"
83
+ ]
84
+ },
85
+ {
86
+ symbol: "YB",
87
+ factor: decimalBase ** /*#__PURE__*/ BigInt(8),
88
+ names: [
89
+ "YB",
90
+ "yottabyte",
91
+ "yottabytes"
92
+ ]
93
+ },
94
+ {
95
+ symbol: "RB",
96
+ factor: decimalBase ** /*#__PURE__*/ BigInt(9),
97
+ names: [
98
+ "RB",
99
+ "ronnabyte",
100
+ "ronnabytes"
101
+ ]
102
+ },
103
+ {
104
+ symbol: "QB",
105
+ factor: decimalBase ** /*#__PURE__*/ BigInt(10),
106
+ names: [
107
+ "QB",
108
+ "quettabyte",
109
+ "quettabytes"
110
+ ]
111
+ }
112
+ ];
113
+ const binaryUnits = [
114
+ decimalUnits[0],
115
+ {
116
+ symbol: "KiB",
117
+ factor: binaryBase,
118
+ names: [
119
+ "KiB",
120
+ "kibibyte",
121
+ "kibibytes"
122
+ ]
123
+ },
124
+ {
125
+ symbol: "MiB",
126
+ factor: binaryBase ** /*#__PURE__*/ BigInt(2),
127
+ names: [
128
+ "MiB",
129
+ "mebibyte",
130
+ "mebibytes"
131
+ ]
132
+ },
133
+ {
134
+ symbol: "GiB",
135
+ factor: binaryBase ** /*#__PURE__*/ BigInt(3),
136
+ names: [
137
+ "GiB",
138
+ "gibibyte",
139
+ "gibibytes"
140
+ ]
141
+ },
142
+ {
143
+ symbol: "TiB",
144
+ factor: binaryBase ** /*#__PURE__*/ BigInt(4),
145
+ names: [
146
+ "TiB",
147
+ "tebibyte",
148
+ "tebibytes"
149
+ ]
150
+ },
151
+ {
152
+ symbol: "PiB",
153
+ factor: binaryBase ** /*#__PURE__*/ BigInt(5),
154
+ names: [
155
+ "PiB",
156
+ "pebibyte",
157
+ "pebibytes"
158
+ ]
159
+ },
160
+ {
161
+ symbol: "EiB",
162
+ factor: binaryBase ** /*#__PURE__*/ BigInt(6),
163
+ names: [
164
+ "EiB",
165
+ "exbibyte",
166
+ "exbibytes"
167
+ ]
168
+ },
169
+ {
170
+ symbol: "ZiB",
171
+ factor: binaryBase ** /*#__PURE__*/ BigInt(7),
172
+ names: [
173
+ "ZiB",
174
+ "zebibyte",
175
+ "zebibytes"
176
+ ]
177
+ },
178
+ {
179
+ symbol: "YiB",
180
+ factor: binaryBase ** /*#__PURE__*/ BigInt(8),
181
+ names: [
182
+ "YiB",
183
+ "yobibyte",
184
+ "yobibytes"
185
+ ]
186
+ }
187
+ ];
188
+ const allUnits = [...decimalUnits, .../*#__PURE__*/ binaryUnits.slice(1)];
189
+ const unitsByName = /*#__PURE__*/ new Map(/*#__PURE__*/ allUnits.flatMap((unit) => unit.names.map((name) => [name, unit])));
190
+ const unitsBySymbol = /*#__PURE__*/ new Map(/*#__PURE__*/ allUnits.map((unit) => [unit.symbol, unit]));
191
+ const make$2 = (value) => value;
192
+ const invalid = (message) => {
193
+ throw new Error(`Invalid ByteSize: ${message}`);
194
+ };
195
+ const fromNumber = (input) => {
196
+ if (!Number.isSafeInteger(input) || input < 0) return invalid(`expected a non-negative safe integer, received ${input}`);
197
+ return make$2(BigInt(input));
198
+ };
199
+ const maxSafeInteger = /*#__PURE__*/ BigInt(Number.MAX_SAFE_INTEGER);
200
+ const scaleDecimal = (quantity, factor) => {
201
+ const match = /^(\d+)(?:\.(\d+))?(?:e([+-]\d+))?$/.exec(quantity);
202
+ if (match === null) return void 0;
203
+ const fraction = match[2] ?? "";
204
+ const numerator = BigInt(match[1] + fraction) * factor;
205
+ const shift = Number(match[3] ?? 0) - fraction.length;
206
+ if (shift >= 0) return numerator * BigInt(10) ** BigInt(shift);
207
+ const scale = BigInt(10) ** BigInt(-shift);
208
+ return numerator % scale === bigint0 ? numerator / scale : void 0;
209
+ };
210
+ const fromQuantity = (quantity, unit) => {
211
+ if (typeof quantity === "bigint") {
212
+ if (quantity < bigint0) return invalid(`expected a non-negative quantity, received ${quantity}`);
213
+ return make$2(quantity * unit.factor);
214
+ }
215
+ if (binaryUnits.includes(unit)) {
216
+ const value = quantity * Number(unit.factor);
217
+ if (Number.isSafeInteger(value) && value >= 0) return make$2(BigInt(value));
218
+ } else {
219
+ const value = scaleDecimal(String(quantity), unit.factor);
220
+ if (value !== void 0 && value <= maxSafeInteger) return make$2(value);
221
+ }
222
+ return invalid(`expected an exact non-negative safe-integer byte result, received ${quantity} ${unit.symbol}`);
223
+ };
224
+ /**
225
+ * Parses a byte-size string and throws for invalid syntax, unsupported units,
226
+ * or quantities that do not represent non-negative integral bytes.
227
+ *
228
+ * **Details**
229
+ *
230
+ * Accepts decimal fractions, canonical SI and IEC symbols, lowercase unit
231
+ * names, and whitespace around the quantity and unit. Parsing uses exact
232
+ * bigint arithmetic, including above the safe integer range.
233
+ *
234
+ * @see {@link fromString} for non-throwing validation
235
+ * @stability unstable
236
+ * @category constructors
237
+ * @since 4.0.0
238
+ */
239
+ const fromStringUnsafe = (input) => {
240
+ const match = /^\s*(\d+(?:\.\d+)?)\s*([A-Za-z]+)\s*$/.exec(input);
241
+ if (match === null) return invalid(`unsupported syntax ${JSON.stringify(input)}`);
242
+ const unit = unitsByName.get(match[2]);
243
+ if (unit === void 0) return invalid(`unsupported unit ${JSON.stringify(match[2])}`);
244
+ const value = scaleDecimal(match[1], unit.factor);
245
+ if (value === void 0) return invalid(`${JSON.stringify(input)} does not represent an integral number of bytes`);
246
+ return make$2(value);
247
+ };
248
+ /**
249
+ * Decodes a trusted input into a byte size and throws for invalid input.
250
+ *
251
+ * @stability unstable
252
+ * @category constructors
253
+ * @since 4.0.0
254
+ */
255
+ const fromInputUnsafe = (input) => {
256
+ switch (typeof input) {
257
+ case "bigint":
258
+ if (input < bigint0) return invalid(`expected a non-negative bigint, received ${input}`);
259
+ return make$2(input);
260
+ case "number": return fromNumber(input);
261
+ case "string": return fromStringUnsafe(input);
262
+ }
263
+ return invalid(`unsupported input ${input}`);
264
+ };
265
+ /**
266
+ * Creates a byte size from a non-negative byte count.
267
+ *
268
+ * @stability unstable
269
+ * @category constructors
270
+ * @since 4.0.0
271
+ */
272
+ const bytes = (value) => typeof value === "bigint" ? fromInputUnsafe(value) : fromNumber(value);
273
+ const unitConstructor = (symbol) => (value) => fromQuantity(value, unitsBySymbol.get(symbol));
274
+ /**
275
+ * Creates a binary mebibyte value.
276
+ *
277
+ * @stability unstable
278
+ * @category constructors
279
+ * @since 4.0.0
280
+ */
281
+ const mebibytes = /*#__PURE__*/ unitConstructor("MiB");
282
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/internal/glob.js
283
+ const maxExpansions = 1e4;
284
+ const maxExpandedLength = 2 ** 22;
285
+ const maxBraceDepth = 64;
286
+ /** @internal */
287
+ const compile = (patterns, dot) => {
288
+ const nodes = [];
289
+ const starts = /* @__PURE__ */ new Set();
290
+ for (const pattern of patterns) for (const expanded of expandBraces(pattern)) {
291
+ const start = nodes.length;
292
+ if (compilePattern(expanded, nodes)) starts.add(start);
293
+ }
294
+ const initial = closure(nodes, starts);
295
+ return {
296
+ nodes,
297
+ initial,
298
+ dot,
299
+ masks: nodes.length <= 32 ? compileMasks(nodes, initial) : void 0
300
+ };
301
+ };
302
+ const compileMasks = (nodes, initial) => {
303
+ let start = 0;
304
+ for (const state of initial) start |= 1 << state;
305
+ let globstar = 0;
306
+ let end = 0;
307
+ let endFile = 0;
308
+ for (let i = 0; i < nodes.length; i++) {
309
+ const node = nodes[i];
310
+ const bit = 1 << i;
311
+ if (node._tag === "Globstar") globstar |= bit;
312
+ else if (node._tag === "End") {
313
+ end |= bit;
314
+ if (!node.directoryOnly) endFile |= bit;
315
+ }
316
+ }
317
+ return {
318
+ initial: start,
319
+ globstar,
320
+ end,
321
+ endFile
322
+ };
323
+ };
324
+ const isUnc = (path) => path.startsWith("//") && path[2] !== void 0 && path[2] !== "/";
325
+ const compilePattern = (pattern, nodes) => {
326
+ if (pattern === "" || isUnc(pattern)) return false;
327
+ const raw = splitSegments(pattern);
328
+ const globstar = raw.indexOf("**");
329
+ if (globstar !== -1 && raw.some((segment, i) => i > globstar && (segment === "." || segment === ".."))) return false;
330
+ const { directory, segments } = normalize(raw);
331
+ if (segments.length === 0) return false;
332
+ for (const segment of segments) if (segment !== "**") nodes.push(compileSegment(Array.from(segment)));
333
+ else if (nodes[nodes.length - 1] !== globstarNode) nodes.push(globstarNode);
334
+ nodes.push({
335
+ _tag: "End",
336
+ directoryOnly: directory
337
+ });
338
+ return true;
339
+ };
340
+ const globstarNode = { _tag: "Globstar" };
341
+ const splitSegments = (pattern) => {
342
+ const segments = [];
343
+ let start = 0;
344
+ for (let i = 0; i < pattern.length; i++) if (pattern[i] === "\\") i++;
345
+ else if (pattern[i] === "/") {
346
+ segments.push(pattern.slice(start, i));
347
+ start = i + 1;
348
+ }
349
+ segments.push(pattern.slice(start));
350
+ return segments;
351
+ };
352
+ const drive = /^[A-Za-z]:/;
353
+ const isDrive = (segment) => segment.length === 2 && drive.test(segment);
354
+ const isRoot = (name) => name === "" || name.length === 3 && name[2] === "/" && drive.test(name);
355
+ const isAbsolute = (path) => path.startsWith("/") || path[2] === "/" && drive.test(path);
356
+ const normalize = (raw) => {
357
+ const segments = [];
358
+ let i = 0;
359
+ if (raw.length > 1 && (raw[0] === "" || isDrive(raw[0]))) {
360
+ segments.push(raw[0] === "" ? "" : `${raw[0]}/`);
361
+ i = 1;
362
+ }
363
+ let directory = false;
364
+ for (; i < raw.length; i++) {
365
+ const segment = raw[i];
366
+ if (segment === "" || segment === ".") directory = i === raw.length - 1 && segments.length > 0;
367
+ else {
368
+ segments.push(segment);
369
+ directory = false;
370
+ }
371
+ }
372
+ if (segments.length === 0 && raw.includes(".")) segments.push(".");
373
+ return {
374
+ segments,
375
+ directory
376
+ };
377
+ };
378
+ const compileSegment = (chars) => {
379
+ const tokens = [];
380
+ let literal = "";
381
+ let magic = false;
382
+ let classes = true;
383
+ for (let i = 0; i < chars.length; i++) {
384
+ const char = chars[i];
385
+ if (char === "\\" && i + 1 < chars.length) {
386
+ literal += chars[++i];
387
+ tokens.push({
388
+ _tag: "Char",
389
+ code: chars[i].codePointAt(0)
390
+ });
391
+ } else if (char === "*") {
392
+ magic = true;
393
+ if (tokens[tokens.length - 1]?._tag !== "Star") tokens.push({ _tag: "Star" });
394
+ } else if (char === "?") {
395
+ magic = true;
396
+ tokens.push({ _tag: "Any" });
397
+ } else if (char === "[" && classes) {
398
+ const parsed = parseClass(chars, i);
399
+ if (parsed === void 0) {
400
+ classes = false;
401
+ literal += char;
402
+ tokens.push({
403
+ _tag: "Char",
404
+ code: char.codePointAt(0)
405
+ });
406
+ } else {
407
+ magic = true;
408
+ tokens.push(parsed.token);
409
+ i = parsed.end;
410
+ }
411
+ } else {
412
+ literal += char;
413
+ tokens.push({
414
+ _tag: "Char",
415
+ code: char.codePointAt(0)
416
+ });
417
+ }
418
+ }
419
+ if (!magic) return {
420
+ _tag: "Literal",
421
+ value: literal
422
+ };
423
+ const first = tokens[0];
424
+ return {
425
+ _tag: "Wildcard",
426
+ tokens,
427
+ leadingDot: first._tag === "Char" && first.code === 46,
428
+ affixes: compileAffixes(tokens)
429
+ };
430
+ };
431
+ const compileAffixes = (tokens) => {
432
+ let prefix = "";
433
+ let suffix;
434
+ for (const token of tokens) if (token._tag === "Star" && suffix === void 0) suffix = "";
435
+ else if (token._tag === "Char" && (token.code < 55296 || token.code > 57343)) {
436
+ const char = String.fromCodePoint(token.code);
437
+ if (suffix === void 0) prefix += char;
438
+ else suffix += char;
439
+ } else return;
440
+ return suffix === void 0 ? void 0 : {
441
+ prefix,
442
+ suffix
443
+ };
444
+ };
445
+ const range = (from, to) => [from.codePointAt(0), to.codePointAt(0)];
446
+ const posixClasses = {
447
+ alnum: [
448
+ .../*#__PURE__*/ range("0", "9"),
449
+ .../*#__PURE__*/ range("A", "Z"),
450
+ .../*#__PURE__*/ range("a", "z")
451
+ ],
452
+ alpha: [.../*#__PURE__*/ range("A", "Z"), .../*#__PURE__*/ range("a", "z")],
453
+ blank: [
454
+ 9,
455
+ 9,
456
+ 32,
457
+ 32
458
+ ],
459
+ cntrl: [
460
+ 0,
461
+ 31,
462
+ 127,
463
+ 127
464
+ ],
465
+ digit: /*#__PURE__*/ range("0", "9"),
466
+ graph: [33, 126],
467
+ lower: /*#__PURE__*/ range("a", "z"),
468
+ print: [32, 126],
469
+ punct: [
470
+ 33,
471
+ 47,
472
+ 58,
473
+ 64,
474
+ 91,
475
+ 96,
476
+ 123,
477
+ 126
478
+ ],
479
+ space: [
480
+ 9,
481
+ 13,
482
+ 32,
483
+ 32
484
+ ],
485
+ upper: /*#__PURE__*/ range("A", "Z"),
486
+ word: [
487
+ .../*#__PURE__*/ range("0", "9"),
488
+ .../*#__PURE__*/ range("A", "Z"),
489
+ 95,
490
+ 95,
491
+ .../*#__PURE__*/ range("a", "z")
492
+ ],
493
+ xdigit: [
494
+ .../*#__PURE__*/ range("0", "9"),
495
+ .../*#__PURE__*/ range("A", "F"),
496
+ .../*#__PURE__*/ range("a", "f")
497
+ ]
498
+ };
499
+ const parsePosixClass = (chars, open) => {
500
+ for (let i = open + 2; i < chars.length && i <= open + 8; i++) if (chars[i] === ":" && chars[i + 1] === "]") {
501
+ const ranges = posixClasses[chars.slice(open + 2, i).join("")];
502
+ return ranges === void 0 ? void 0 : {
503
+ ranges,
504
+ end: i + 1
505
+ };
506
+ }
507
+ };
508
+ const parseClass = (chars, open) => {
509
+ let i = open + 1;
510
+ const negated = chars[i] === "!" || chars[i] === "^";
511
+ if (negated) i++;
512
+ const ranges = [];
513
+ for (let first = true; i < chars.length; i++, first = false) {
514
+ let char = chars[i];
515
+ if (char === "/") return;
516
+ if (char === "]" && !first) return {
517
+ token: {
518
+ _tag: "Class",
519
+ ranges,
520
+ negated
521
+ },
522
+ end: i
523
+ };
524
+ if (char === "[" && chars[i + 1] === ":") {
525
+ const posix = parsePosixClass(chars, i);
526
+ if (posix !== void 0) {
527
+ ranges.push(...posix.ranges);
528
+ i = posix.end;
529
+ continue;
530
+ }
531
+ }
532
+ if (char === "\\" && i + 1 < chars.length) char = chars[++i];
533
+ if (chars[i + 1] === "-" && i + 2 < chars.length && chars[i + 2] !== "]") {
534
+ let next = i + 2;
535
+ if (chars[next] === "/") return;
536
+ if (chars[next] === "\\" && next + 1 < chars.length) next++;
537
+ ranges.push(...range(char, chars[next]));
538
+ i = next;
539
+ continue;
540
+ }
541
+ ranges.push(...range(char, char));
542
+ }
543
+ };
544
+ const expandBraces = (pattern) => {
545
+ const chars = Array.from(pattern);
546
+ const groups = matchBraceGroups(chars);
547
+ if (groups.size === 0) return [pattern];
548
+ const sequence = parseBraceSequence(chars, 0, chars.length, groups, 0);
549
+ if (sequence === void 0) return [pattern];
550
+ const count = countExpansions(sequence);
551
+ return count > maxExpansions || count * pattern.length > maxExpandedLength ? [pattern] : expandSequence(sequence);
552
+ };
553
+ const matchBraceGroups = (chars) => {
554
+ const groups = /* @__PURE__ */ new Map();
555
+ const stack = [];
556
+ let classes = true;
557
+ for (let i = 0; i < chars.length; i++) {
558
+ const char = chars[i];
559
+ if (char === "\\") i++;
560
+ else if (char === "/") classes = true;
561
+ else if (char === "[" && classes) {
562
+ const parsed = parseClass(chars, i);
563
+ if (parsed === void 0) classes = false;
564
+ else i = parsed.end;
565
+ } else if (char === "{") stack.push({
566
+ open: i,
567
+ commas: []
568
+ });
569
+ else if (char === ",") stack[stack.length - 1]?.commas.push(i);
570
+ else if (char === "}") {
571
+ const group = stack.pop();
572
+ if (group !== void 0 && group.commas.length > 0) groups.set(group.open, {
573
+ commas: group.commas,
574
+ close: i
575
+ });
576
+ }
577
+ }
578
+ return groups;
579
+ };
580
+ const parseBraceSequence = (chars, start, end, groups, depth) => {
581
+ if (depth > maxBraceDepth) return;
582
+ const parts = [];
583
+ let text = "";
584
+ for (let i = start; i < end; i++) {
585
+ const group = groups.get(i);
586
+ if (group === void 0) {
587
+ if (chars[i] === "\\" && i + 1 < end) text += chars[i++];
588
+ text += chars[i];
589
+ continue;
590
+ }
591
+ const alternatives = [];
592
+ let from = i + 1;
593
+ for (const to of [...group.commas, group.close]) {
594
+ const alternative = parseBraceSequence(chars, from, to, groups, depth + 1);
595
+ if (alternative === void 0) return;
596
+ alternatives.push(alternative);
597
+ from = to + 1;
598
+ }
599
+ if (text !== "") {
600
+ parts.push(text);
601
+ text = "";
602
+ }
603
+ parts.push(alternatives);
604
+ i = group.close;
605
+ }
606
+ if (text !== "") parts.push(text);
607
+ return parts;
608
+ };
609
+ const countExpansions = (sequence) => {
610
+ let count = 1;
611
+ for (const part of sequence) if (typeof part !== "string") {
612
+ let sum = 0;
613
+ for (const alternative of part) sum += countExpansions(alternative);
614
+ count *= sum;
615
+ if (count > maxExpansions) return Infinity;
616
+ }
617
+ return count;
618
+ };
619
+ const expandSequence = (sequence) => {
620
+ let out = [""];
621
+ for (const part of sequence) if (typeof part === "string") out = out.map((prefix) => prefix + part);
622
+ else {
623
+ const alternatives = part.flatMap(expandSequence);
624
+ out = out.flatMap((prefix) => alternatives.map((alternative) => prefix + alternative));
625
+ }
626
+ return out;
627
+ };
628
+ const matchToken = (token, code) => {
629
+ switch (token._tag) {
630
+ case "Char": return token.code === code;
631
+ case "Any": return true;
632
+ case "Star": return false;
633
+ case "Class": {
634
+ let found = false;
635
+ for (let i = 0; i < token.ranges.length && !found; i += 2) found = code >= token.ranges[i] && code <= token.ranges[i + 1];
636
+ return found !== token.negated;
637
+ }
638
+ }
639
+ };
640
+ const width = (code) => code > 65535 ? 2 : 1;
641
+ const matchWildcard = (node, name, dot) => {
642
+ if (name === "." || name === ".." || name.startsWith(".") && !dot && !node.leadingDot) return false;
643
+ if (node.affixes !== void 0) {
644
+ const { prefix, suffix } = node.affixes;
645
+ return name.length >= prefix.length + suffix.length && name.startsWith(prefix) && name.endsWith(suffix);
646
+ }
647
+ const { tokens } = node;
648
+ let t = 0;
649
+ let c = 0;
650
+ let star = -1;
651
+ let resume = 0;
652
+ while (c < name.length) {
653
+ if (tokens[t]?._tag === "Star") {
654
+ star = t++;
655
+ resume = c;
656
+ continue;
657
+ }
658
+ const code = name.codePointAt(c);
659
+ if (t < tokens.length && matchToken(tokens[t], code)) {
660
+ t++;
661
+ c += width(code);
662
+ } else if (star !== -1) {
663
+ t = star + 1;
664
+ resume += width(name.codePointAt(resume));
665
+ c = resume;
666
+ } else return false;
667
+ }
668
+ while (tokens[t]?._tag === "Star") t++;
669
+ return t === tokens.length;
670
+ };
671
+ const closure = (nodes, states) => {
672
+ for (const state of states) if (nodes[state]._tag === "Globstar") states.add(state + 1);
673
+ return states;
674
+ };
675
+ const step = (compiled, states, name) => {
676
+ const explicit = /* @__PURE__ */ new Set();
677
+ const viaGlobstar = /* @__PURE__ */ new Set();
678
+ const root = isRoot(name);
679
+ for (const state of states) {
680
+ const node = compiled.nodes[state];
681
+ switch (node._tag) {
682
+ case "Globstar":
683
+ if (!root && name !== "." && name !== ".." && (compiled.dot || !name.startsWith("."))) viaGlobstar.add(state);
684
+ break;
685
+ case "Literal":
686
+ if (node.value === name) explicit.add(state + 1);
687
+ break;
688
+ case "Wildcard": if (!root && matchWildcard(node, name, compiled.dot)) explicit.add(state + 1);
689
+ }
690
+ }
691
+ return {
692
+ explicit: closure(compiled.nodes, explicit),
693
+ globstar: closure(compiled.nodes, viaGlobstar)
694
+ };
695
+ };
696
+ const union = (step) => {
697
+ if (step.globstar.size === 0) return step.explicit;
698
+ const states = new Set(step.explicit);
699
+ for (const state of step.globstar) states.add(state);
700
+ return states;
701
+ };
702
+ const accepts = (compiled, states, isDirectory) => {
703
+ for (const state of states) {
704
+ const node = compiled.nodes[state];
705
+ if (node._tag === "End" && (isDirectory || !node.directoryOnly)) return true;
706
+ }
707
+ return false;
708
+ };
709
+ const canDescend = (compiled, states) => {
710
+ for (const state of states) if (compiled.nodes[state]._tag !== "End") return true;
711
+ return false;
712
+ };
713
+ const needsDirectory = (compiled, states) => {
714
+ for (const state of states) {
715
+ const node = compiled.nodes[state];
716
+ if (node._tag === "End" && node.directoryOnly) return true;
717
+ }
718
+ return false;
719
+ };
720
+ const join = (parent, name) => {
721
+ if (parent === "") return name === "" ? "/" : name;
722
+ return parent.endsWith("/") ? parent + name : `${parent}/${name}`;
723
+ };
724
+ const isMissing = (error) => error.reason._tag === "NotFound" || error.reason._tag === "BadResource";
725
+ const isIgnorable = (error) => isMissing(error) || error.reason._tag === "PermissionDenied";
726
+ const isNotLink = (error) => isIgnorable(error) || error.reason._tag === "Unknown";
727
+ const DIRECTORY_CONCURRENCY = 16;
728
+ const byName = /*#__PURE__*/ mapInput(String$1, (entry) => entry.name);
729
+ /** @internal */
730
+ const make$1 = (fs) => (pattern, options) => walk(fs, compile([pattern], options?.dot ?? false), options);
731
+ const walk = /*#__PURE__*/ fnUntraced(function* (fs, compiled, options) {
732
+ if (compiled.initial.size === 0) return [];
733
+ const root = options?.root ?? "";
734
+ const excludes = compile(options?.exclude ?? [], true);
735
+ const excludeNeedsDirectory = excludes.nodes.some((node) => node._tag === "End" && node.directoryOnly);
736
+ const toFsPath = (relative) => isAbsolute(relative) ? relative : relative === "" ? root === "" ? "." : root : join(root, relative);
737
+ const isUnlisted = (value) => value === "." || value === ".." || isRoot(value);
738
+ const probe = (parent, name, named) => {
739
+ const path = toFsPath(join(parent, name));
740
+ return fs.stat(path).pipe(map((info) => info.type), catchReason("PlatformError", "NotFound", () => fs.readLink(path).pipe(as("SymbolicLink"), catchIf(isNotLink, () => succeed(void 0)))), catchIf(named ? isMissing : isIgnorable, () => succeed(void 0)), map((type) => type === void 0 ? void 0 : {
741
+ name,
742
+ type
743
+ }));
744
+ };
745
+ const entries = (relative, states, named) => {
746
+ const literals = /* @__PURE__ */ new Set();
747
+ let listed = !named;
748
+ for (const state of states) {
749
+ const node = compiled.nodes[state];
750
+ if (node._tag === "Literal") literals.add(node.value);
751
+ else if (node._tag !== "End") listed = true;
752
+ }
753
+ const probed = listed ? [...literals].filter(isUnlisted) : [...literals];
754
+ return zipWith(listed ? catchIf(fs.readDirectoryEntries(toFsPath(relative)), named ? isMissing : isIgnorable, () => succeed([])) : succeed([]), forEach$1(probed, (name) => probe(relative, name, named), { concurrency: 16 }), (listing, found) => ({
755
+ entries: sort([...listing, ...found.filter(isNotUndefined)], byName),
756
+ named: named && !listed
757
+ }));
758
+ };
759
+ const visit = ({ name, type }, parent, states, excluded) => {
760
+ const result = step(compiled, states, name);
761
+ const next = union(result);
762
+ if (next.size === 0) return;
763
+ const relative = join(parent, name);
764
+ const nextExcluded = union(step(excludes, excluded, name));
765
+ const descend = canDescend(compiled, next);
766
+ const child = (isDirectory, link) => {
767
+ const accepted = accepts(compiled, next, isDirectory);
768
+ if (!accepted && (!isDirectory || !descend) || accepts(excludes, nextExcluded, isDirectory)) return;
769
+ return {
770
+ relative,
771
+ accepted,
772
+ excluded: nextExcluded,
773
+ next: !isDirectory || !descend ? void 0 : !link || result.globstar.size === 0 ? next : canDescend(compiled, result.explicit) ? result.explicit : void 0
774
+ };
775
+ };
776
+ if (!descend && !needsDirectory(compiled, next) && !excludeNeedsDirectory) return child(false, false);
777
+ if (type !== "Unknown" && type !== "SymbolicLink") return child(type === "Directory", false);
778
+ const path = toFsPath(relative);
779
+ return fs.stat(path).pipe(map((info) => info.type === "Directory"), catchIf(isIgnorable, () => succeed(false)), flatMap((isDirectory) => {
780
+ const resolved = child(isDirectory, type === "SymbolicLink");
781
+ if (type === "SymbolicLink" || resolved?.next === void 0 || result.globstar.size === 0) return succeed(resolved);
782
+ return fs.readLink(path).pipe(as(child(isDirectory, true)), catchIf(isNotLink, () => succeed(resolved)));
783
+ }));
784
+ };
785
+ let slots = DIRECTORY_CONCURRENCY;
786
+ let finishing = false;
787
+ const failed = makeUnsafe();
788
+ const fork = (walk) => walk.pipe(onError((cause) => sync(() => {
789
+ if (!finishing) doneUnsafe(failed, failCause(cause));
790
+ })), ensuring(sync(() => {
791
+ slots++;
792
+ })), forkChild);
793
+ const directory = fnUntraced(function* (relative, states, excluded, named) {
794
+ const listing = yield* entries(relative, states, named);
795
+ const children = [];
796
+ const pending = [];
797
+ for (const entry of listing.entries) {
798
+ const child = visit(entry, relative, states, excluded);
799
+ if (isEffect(child)) {
800
+ const index = children.push(void 0) - 1;
801
+ pending.push(map(child, (child) => {
802
+ children[index] = child;
803
+ }));
804
+ } else children.push(child);
805
+ }
806
+ if (pending.length > 0) yield* all(pending, {
807
+ concurrency: 16,
808
+ discard: true
809
+ });
810
+ const subtrees = [];
811
+ for (const child of children) if (child?.next !== void 0) {
812
+ const walk = directory(child.relative, child.next, child.excluded, listing.named);
813
+ if (slots > 0) {
814
+ slots--;
815
+ subtrees.push(join$1(yield* fork(walk)));
816
+ } else subtrees.push(succeed(yield* walk));
817
+ }
818
+ const out = [];
819
+ let index = 0;
820
+ for (const child of children) {
821
+ if (child === void 0) continue;
822
+ if (child.accepted) out.push(child.relative);
823
+ if (child.next !== void 0) for (const path of yield* subtrees[index++]) out.push(path);
824
+ }
825
+ return out;
826
+ });
827
+ return yield* raceFirst(ensuring(directory("", compiled.initial, excludes.initial, true), sync(() => {
828
+ finishing = true;
829
+ })), _await(failed));
830
+ });
831
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/PlatformError.js
832
+ /**
833
+ * Normalized errors for platform APIs.
834
+ *
835
+ * Platform services such as file systems, terminals, and sockets use
836
+ * `PlatformError` to report host-level failures in a consistent shape. The
837
+ * wrapper records whether the problem came from an invalid argument or from the
838
+ * operating system, while preserving useful details such as the module, method,
839
+ * path, descriptor, description, and original cause when available.
840
+ *
841
+ * @stability unstable
842
+ * @since 4.0.0
843
+ */
844
+ const TypeId$2 = "~effect/PlatformError";
845
+ /**
846
+ * Error data for an invalid argument passed to a platform API.
847
+ *
848
+ * **When to use**
849
+ *
850
+ * Use when you need to model caller input rejected before a platform operation
851
+ * runs, including invalid-argument reason data.
852
+ *
853
+ * **Details**
854
+ *
855
+ * The error records the module and method that rejected the argument, with an
856
+ * optional description and cause. It is usually wrapped in `PlatformError`.
857
+ *
858
+ * @see {@link badArgument} for creating a wrapped `PlatformError` whose reason is `BadArgument`
859
+ * @see {@link SystemError} for failures reported by the host platform or operating system
860
+ * @see {@link PlatformError} for the wrapper used by most platform APIs
861
+ *
862
+ * @stability unstable
863
+ * @category errors
864
+ * @since 4.0.0
865
+ */
866
+ var BadArgument = class extends (/*#__PURE__*/ TaggedError("BadArgument")) {
867
+ /**
868
+ * Formats the module, method, and optional description that rejected the argument.
869
+ *
870
+ * **When to use**
871
+ *
872
+ * Use to read the formatted error message for a rejected platform argument.
873
+ *
874
+ * @since 4.0.0
875
+ */
876
+ get message() {
877
+ return `${this.module}.${this.method}${this.description ? `: ${this.description}` : ""}`;
878
+ }
879
+ };
880
+ /**
881
+ * Error data for a platform or system operation failure.
882
+ *
883
+ * **When to use**
884
+ *
885
+ * Use when you need normalized reason data for a platform or system operation
886
+ * failure, including the operation details.
887
+ *
888
+ * **Details**
889
+ *
890
+ * The error records a normalized `_tag`, the module and method that failed,
891
+ * and optional details such as the syscall, path or descriptor, description,
892
+ * and original cause. It is usually wrapped in `PlatformError`.
893
+ *
894
+ * @see {@link systemError} for creating the usual `PlatformError` wrapper from this reason data
895
+ * @see {@link BadArgument} for platform API failures caused by rejected caller input before an operation runs
896
+ * @see {@link SystemErrorTag} for the normalized tag values stored in `_tag`
897
+ *
898
+ * @stability unstable
899
+ * @category errors
900
+ * @since 4.0.0
901
+ */
902
+ var SystemError = class extends Error$1 {
903
+ /**
904
+ * Formats the normalized system error tag with operation and path details.
905
+ *
906
+ * **When to use**
907
+ *
908
+ * Use to read the formatted error message for a normalized system failure.
909
+ *
910
+ * @since 4.0.0
911
+ */
912
+ get message() {
913
+ return `${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor !== void 0 ? ` (${this.pathOrDescriptor})` : ""}${this.description ? `: ${this.description}` : ""}`;
914
+ }
915
+ };
916
+ /**
917
+ * Tagged error used by platform APIs to report either invalid arguments or
918
+ * system-level failures.
919
+ *
920
+ * **When to use**
921
+ *
922
+ * Use as the shared error type for platform APIs that expose invalid arguments
923
+ * and host or operating-system failures through a single `Effect` error
924
+ * channel.
925
+ *
926
+ * **Details**
927
+ *
928
+ * The `reason` field contains the underlying `BadArgument` or `SystemError`.
929
+ * When that reason has a cause, the cause is preserved on the wrapper.
930
+ *
931
+ * @see {@link BadArgument} for invalid inputs rejected before an operation runs
932
+ * @see {@link SystemError} for failures reported by the host platform or operating system
933
+ * @see {@link badArgument} for creating this wrapper from rejected caller input
934
+ * @see {@link systemError} for creating this wrapper from a host or operating-system failure
935
+ *
936
+ * @stability unstable
937
+ * @category errors
938
+ * @since 4.0.0
939
+ */
940
+ var PlatformError = class extends (/*#__PURE__*/ TaggedError("PlatformError")) {
941
+ constructor(reason) {
942
+ if ("cause" in reason) super({
943
+ reason,
944
+ cause: reason.cause
945
+ });
946
+ else super({ reason });
947
+ }
948
+ /**
949
+ * Marks this value as a platform error wrapper for runtime guards.
950
+ *
951
+ * **When to use**
952
+ *
953
+ * Use to identify `PlatformError` values through their runtime type marker.
954
+ *
955
+ * @since 4.0.0
956
+ */
957
+ [TypeId$2] = TypeId$2;
958
+ get message() {
959
+ return this.reason.message;
960
+ }
961
+ };
962
+ /**
963
+ * Creates a `PlatformError` whose reason is a `SystemError`.
964
+ *
965
+ * **When to use**
966
+ *
967
+ * Use to adapt an operating-system or platform failure into the normalized
968
+ * platform error model.
969
+ *
970
+ * @stability unstable
971
+ * @category constructors
972
+ * @since 4.0.0
973
+ */
974
+ const systemError = (options) => new PlatformError(new SystemError(options));
975
+ /**
976
+ * Creates a `PlatformError` whose reason is a `BadArgument`.
977
+ *
978
+ * **When to use**
979
+ *
980
+ * Use to report a platform API rejecting caller input before performing the
981
+ * underlying operation.
982
+ *
983
+ * @stability unstable
984
+ * @category constructors
985
+ * @since 4.0.0
986
+ */
987
+ const badArgument = (options) => new PlatformError(new BadArgument(options));
988
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/Sink.js
989
+ const TypeId$1 = "~effect/Sink";
990
+ const endVoid = /*#__PURE__*/ succeed([void 0]);
991
+ const sinkVariance = {
992
+ _A: identity,
993
+ _In: identity,
994
+ _L: identity,
995
+ _E: identity,
996
+ _R: identity
997
+ };
998
+ const SinkProto = {
999
+ [TypeId$1]: sinkVariance,
1000
+ pipe() {
1001
+ return pipeArguments(this, arguments);
1002
+ }
1003
+ };
1004
+ /**
1005
+ * Checks whether a value is a Sink.
1006
+ *
1007
+ * **Example** (Checking for a sink)
1008
+ *
1009
+ * ```ts import.meta.vitest
1010
+ * import { Sink } from "effect"
1011
+ *
1012
+ * const sink = Sink.never
1013
+ * const notStream = { data: [1, 2, 3] }
1014
+ *
1015
+ * Sink.isSink(sink) // => true
1016
+ * Sink.isSink(notStream) // => false
1017
+ * ```
1018
+ *
1019
+ * @stability stable
1020
+ * @category guards
1021
+ * @since 4.0.0
1022
+ */
1023
+ const isSink = (u) => hasProperty(u, TypeId$1);
1024
+ /**
1025
+ * Creates a sink from a `Channel`.
1026
+ *
1027
+ * **When to use**
1028
+ *
1029
+ * Use to create a `Sink` from a `Channel` that processes non-empty arrays of
1030
+ * input values.
1031
+ *
1032
+ * **Example** (Using channel completion as the sink result)
1033
+ *
1034
+ * ```ts import.meta.vitest
1035
+ * import { Channel, Effect, Sink, Stream } from "effect"
1036
+ *
1037
+ * const channel = Channel.identity<readonly [number, ...Array<number>], never, void>().pipe(
1038
+ * Channel.drain,
1039
+ * Channel.mapDone(() => ["consumed"] as const)
1040
+ * )
1041
+ * const sink = Sink.fromChannel(channel)
1042
+ *
1043
+ * await Effect.runPromise(Stream.run(Stream.make(1, 2, 3), sink)) // => "consumed"
1044
+ * ```
1045
+ *
1046
+ * @see {@link toChannel} for converting a `Sink` back to a `Channel`
1047
+ * @stability stable
1048
+ * @category constructors
1049
+ * @since 2.0.0
1050
+ */
1051
+ const fromChannel = (channel) => fromTransform((upstream, scope) => toTransform(channel)(upstream, scope).pipe(flatMap(forever({ disableYield: true })), catchDone(succeed)));
1052
+ /**
1053
+ * Creates a `Sink` from a low-level transform function.
1054
+ *
1055
+ * **Details**
1056
+ *
1057
+ * The transform receives the upstream pull of non-empty input arrays and the
1058
+ * active scope, and returns an effect that completes with the sink's `End`
1059
+ * value.
1060
+ *
1061
+ * @stability stable
1062
+ * @category constructors
1063
+ * @since 4.0.0
1064
+ */
1065
+ const fromTransform = (transform) => {
1066
+ const self = Object.create(SinkProto);
1067
+ self.transform = transform;
1068
+ return self;
1069
+ };
1070
+ /**
1071
+ * Creates a `Channel` from a Sink.
1072
+ *
1073
+ * **Example** (Running a sink as a channel)
1074
+ *
1075
+ * ```ts import.meta.vitest
1076
+ * import { Channel, Effect, Sink, Stream } from "effect"
1077
+ *
1078
+ * const channel = Stream.toChannel(Stream.make(1, 2, 3)).pipe(
1079
+ * Channel.pipeTo(Sink.toChannel(Sink.sum))
1080
+ * )
1081
+ *
1082
+ * await Effect.runPromise(Channel.runDrain(channel)) // => [6]
1083
+ * ```
1084
+ *
1085
+ * @stability stable
1086
+ * @category constructors
1087
+ * @since 2.0.0
1088
+ */
1089
+ const toChannel = (self) => fromTransform$1((upstream, scope) => succeed(flatMap(self.transform(upstream, scope), done)));
1090
+ /**
1091
+ * Consumes and ignores all stream inputs.
1092
+ *
1093
+ * **When to use**
1094
+ *
1095
+ * Use to consume all upstream input and complete with void when the input
1096
+ * values and any aggregate result are not needed.
1097
+ *
1098
+ * @see {@link count} for consuming all input while returning the number of elements
1099
+ * @see {@link forEach} for consuming all input while running an effect for each element
1100
+ *
1101
+ * @stability stable
1102
+ * @category constructors
1103
+ * @since 2.0.0
1104
+ */
1105
+ const drain = /*#__PURE__*/ fromTransform((upstream) => catchDone(forever(upstream, { disableYield: true }), () => endVoid));
1106
+ /**
1107
+ * A sink that executes the provided effectful function for every item fed
1108
+ * to it.
1109
+ *
1110
+ * **Example** (Running effects for each item)
1111
+ *
1112
+ * ```ts import.meta.vitest
1113
+ * import { Effect, Sink, Stream } from "effect"
1114
+ *
1115
+ * const processed: Array<number> = []
1116
+ * const sink = Sink.forEach((item: number) => Effect.sync(() => processed.push(item)))
1117
+ *
1118
+ * // Use it with a stream
1119
+ * const stream = Stream.make(1, 2, 3)
1120
+ * await Effect.runPromise(Stream.run(stream, sink))
1121
+ * processed // => [1, 2, 3]
1122
+ * ```
1123
+ *
1124
+ * @stability stable
1125
+ * @category constructors
1126
+ * @since 2.0.0
1127
+ */
1128
+ const forEach = (f) => forEachArray(forEach$1((_) => f(_), { discard: true }));
1129
+ /**
1130
+ * A sink that executes the provided effectful function for every Chunk fed
1131
+ * to it.
1132
+ *
1133
+ * **Example** (Running effects for each chunk)
1134
+ *
1135
+ * ```ts import.meta.vitest
1136
+ * import { Effect, Sink, Stream } from "effect"
1137
+ *
1138
+ * const processed: Array<Array<number>> = []
1139
+ * const sink = Sink.forEachArray((chunk: ReadonlyArray<number>) => Effect.sync(() => processed.push([...chunk])))
1140
+ *
1141
+ * // Use it with a stream
1142
+ * const stream = Stream.make(1, 2, 3, 4, 5)
1143
+ * await Effect.runPromise(Stream.run(stream, sink))
1144
+ * processed // => [[1, 2, 3, 4, 5]]
1145
+ * ```
1146
+ *
1147
+ * @stability stable
1148
+ * @category constructors
1149
+ * @since 4.0.0
1150
+ */
1151
+ const forEachArray = (f) => fromTransform((upstream) => upstream.pipe(flatMap(f), forever({ disableYield: true }), catchDone(() => endVoid)));
1152
+ /**
1153
+ * Creates a sink produced from a scoped effect.
1154
+ *
1155
+ * **Example** (Unwrapping a sink effect)
1156
+ *
1157
+ * ```ts import.meta.vitest
1158
+ * import { Effect, Sink, Stream } from "effect"
1159
+ *
1160
+ * // Create a sink from an effect that produces a sink
1161
+ * const processed: Array<number> = []
1162
+ * const sinkEffect = Effect.succeed(
1163
+ * Sink.forEach((item: number) => Effect.sync(() => processed.push(item)))
1164
+ * )
1165
+ * const sink = Sink.unwrap(sinkEffect)
1166
+ *
1167
+ * // Use it with a stream
1168
+ * const stream = Stream.make(1, 2, 3)
1169
+ * await Effect.runPromise(Stream.run(stream, sink))
1170
+ * processed // => [1, 2, 3]
1171
+ * ```
1172
+ *
1173
+ * @stability stable
1174
+ * @category constructors
1175
+ * @since 2.0.0
1176
+ */
1177
+ const unwrap = (effect) => fromChannel(unwrap$1(map(effect, toChannel)));
1178
+ // ../../node_modules/.pnpm/effect@4.1.2_patch_hash=0e61176203bb1256381ce1c5b488d7951983ce38ff698647d3f4617383abbf07/node_modules/effect/dist/FileSystem.js
1179
+ /**
1180
+ * Defines the portable file system service for Effect programs.
1181
+ *
1182
+ * `FileSystem` is the boundary between Effect code and the host file system.
1183
+ * Platform packages provide concrete layers, while this module defines the
1184
+ * operations for reading, writing, inspecting, streaming, and watching files.
1185
+ * Operations return `Effect`, `Stream`, or `Sink` values and fail with
1186
+ * `PlatformError`. The module also includes file handles, open flags, watch
1187
+ * events, and the watch backend service.
1188
+ *
1189
+ * @stability unstable
1190
+ * @since 4.0.0
1191
+ */
1192
+ const TypeId = "~effect/FileSystem";
1193
+ /**
1194
+ * Service tag for platform file-system operations.
1195
+ *
1196
+ * **When to use**
1197
+ *
1198
+ * Use to access or provide operations for files, directories, permissions,
1199
+ * streams, and sinks through the Effect context.
1200
+ *
1201
+ * **Details**
1202
+ *
1203
+ * This key is used to provide and access the FileSystem service in the Effect context.
1204
+ *
1205
+ * **Example** (Accessing and providing FileSystem)
1206
+ *
1207
+ * ```ts import.meta.vitest
1208
+ * import { Effect, FileSystem } from "effect"
1209
+ *
1210
+ * const customFs = FileSystem.makeNoop({
1211
+ * exists: () => Effect.succeed(true),
1212
+ * readFileString: () => Effect.succeed("contents")
1213
+ * })
1214
+ *
1215
+ * // Access the FileSystem service
1216
+ * const program = Effect.gen(function*() {
1217
+ * const fs = yield* FileSystem.FileSystem
1218
+ *
1219
+ * const exists = yield* fs.exists("./data.txt")
1220
+ * return exists ? yield* fs.readFileString("./data.txt") : undefined
1221
+ * })
1222
+ *
1223
+ * const withCustomFs = Effect.provideService(
1224
+ * program,
1225
+ * FileSystem.FileSystem,
1226
+ * customFs
1227
+ * )
1228
+ * Effect.runSync(withCustomFs) // => "contents"
1229
+ * ```
1230
+ *
1231
+ * @stability unstable
1232
+ * @category services
1233
+ * @since 4.0.0
1234
+ */
1235
+ const FileSystem = /*#__PURE__*/ Service("effect/FileSystem");
1236
+ /**
1237
+ * Creates a FileSystem implementation from a partial implementation.
1238
+ *
1239
+ * **When to use**
1240
+ *
1241
+ * Use to build a concrete `FileSystem` service from platform-specific core
1242
+ * operations while deriving the convenience methods that can be implemented
1243
+ * from them.
1244
+ *
1245
+ * **Details**
1246
+ *
1247
+ * This function takes a partial FileSystem implementation and automatically provides
1248
+ * default implementations for `exists`, `glob`, `readFileString`, `stream`, `sink`,
1249
+ * and `writeFileString` methods based on the provided core methods. `glob` walks
1250
+ * the tree with `readDirectoryEntries`, using `stat` and `readLink` for entries
1251
+ * whose type is `"Unknown"`.
1252
+ *
1253
+ * @see {@link makeNoop} for a testing stub that accepts method overrides without requiring a complete implementation
1254
+ * @see {@link layerNoop} for providing a no-op `FileSystem` as a `Layer` in tests
1255
+ *
1256
+ * @stability unstable
1257
+ * @category constructors
1258
+ * @since 4.0.0
1259
+ */
1260
+ const make = (impl) => FileSystem.of({
1261
+ ...impl,
1262
+ [TypeId]: TypeId,
1263
+ glob: make$1(impl),
1264
+ exists: (path) => pipe(impl.access(path), as(true), catchTag("PlatformError", (e) => e.reason._tag === "NotFound" ? succeed(false) : fail(e))),
1265
+ readFileString: (path, encoding) => flatMap(impl.readFile(path), (_) => try_({
1266
+ try: () => new TextDecoder(encoding).decode(_),
1267
+ catch: (cause) => badArgument({
1268
+ module: "FileSystem",
1269
+ method: "readFileString",
1270
+ description: "invalid encoding",
1271
+ cause
1272
+ })
1273
+ })),
1274
+ stream: fnUntraced(function* (path, options) {
1275
+ const file = yield* impl.open(path, { flag: "r" });
1276
+ const offset = options?.offset === void 0 ? void 0 : fromInputUnsafe(options.offset);
1277
+ if (offset) yield* file.seek(offset, "start");
1278
+ const bytesToRead = options?.bytesToRead === void 0 ? void 0 : fromInputUnsafe(options.bytesToRead);
1279
+ let totalBytesRead = BigInt(0);
1280
+ const chunkSize = Number(BigInt(options?.chunkSize ?? 65536));
1281
+ const readChunk = file.readAlloc(chunkSize);
1282
+ return fromPull(succeed(flatMap(suspend(() => {
1283
+ if (bytesToRead !== void 0 && bytesToRead <= totalBytesRead) return done();
1284
+ return bytesToRead !== void 0 && bytesToRead - totalBytesRead < chunkSize ? file.readAlloc(Number(bytesToRead - totalBytesRead)) : readChunk;
1285
+ }), match({
1286
+ onNone: () => done(),
1287
+ onSome: (buf) => {
1288
+ totalBytesRead += BigInt(buf.length);
1289
+ return succeed(of(buf));
1290
+ }
1291
+ }))));
1292
+ }, unwrap$2),
1293
+ sink: (path, options) => pipe(impl.open(path, {
1294
+ ...options,
1295
+ flag: options?.flag ?? "w"
1296
+ }), map((file) => forEach((_) => file.writeAll(_))), unwrap),
1297
+ writeFileString: (path, data, options) => flatMap(try_({
1298
+ try: () => new TextEncoder().encode(data),
1299
+ catch: (cause) => badArgument({
1300
+ module: "FileSystem",
1301
+ method: "writeFileString",
1302
+ description: "could not encode string",
1303
+ cause
1304
+ })
1305
+ }), (_) => impl.writeFile(path, _, options))
1306
+ });
1307
+ /**
1308
+ * Runtime type identifier attached to `FileSystem.File` handles and used by
1309
+ * `isFile` to recognize them.
1310
+ *
1311
+ * **Details**
1312
+ *
1313
+ * This marker is part of the runtime representation of file handles. Prefer
1314
+ * `isFile` when narrowing unknown values.
1315
+ *
1316
+ * @see {@link File} for the open file handle shape that carries this marker
1317
+ * @see {@link isFile} for the public guard that checks this marker
1318
+ *
1319
+ * @stability unstable
1320
+ * @category type IDs
1321
+ * @since 4.0.0
1322
+ */
1323
+ const FileTypeId = "~effect/FileSystem/File";
1324
+ /**
1325
+ * Service key for file system watch backend implementations.
1326
+ *
1327
+ * **Details**
1328
+ *
1329
+ * This service provides the low-level file watching capabilities that can be
1330
+ * implemented differently on various platforms (e.g., inotify on Linux,
1331
+ * FSEvents on macOS, etc.).
1332
+ *
1333
+ * **Example** (Providing a custom watch backend)
1334
+ *
1335
+ * ```ts import.meta.vitest
1336
+ * import { Effect, FileSystem, Option, Stream } from "effect"
1337
+ *
1338
+ * // Custom watch backend implementation
1339
+ * const customWatchBackend = {
1340
+ * register: (path: string, stat: FileSystem.File.Info) => {
1341
+ * // Implementation would depend on platform
1342
+ * return Option.some(Stream.empty) // Placeholder implementation
1343
+ * }
1344
+ * }
1345
+ *
1346
+ * const program = Effect.gen(function*() {
1347
+ * const backend = yield* FileSystem.WatchBackend
1348
+ * return Option.isSome(
1349
+ * backend.register("./directory", { type: "Directory" } as FileSystem.File.Info)
1350
+ * )
1351
+ * })
1352
+ *
1353
+ * const withCustomBackend = Effect.provideService(
1354
+ * program,
1355
+ * FileSystem.WatchBackend,
1356
+ * customWatchBackend
1357
+ * )
1358
+ * Effect.runSync(withCustomBackend) // => true
1359
+ * ```
1360
+ *
1361
+ * @stability unstable
1362
+ * @category services
1363
+ * @since 4.0.0
1364
+ */
1365
+ var WatchBackend = class extends (/*#__PURE__*/ Service()("effect/FileSystem/WatchBackend")) {};
1366
+ export { drain as a, BadArgument as c, bytes as d, fromInputUnsafe as f, make as i, badArgument as l, FileTypeId as n, fromChannel as o, mebibytes as p, WatchBackend as r, isSink as s, FileSystem as t, systemError as u };