priiisk 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.
@@ -0,0 +1,988 @@
1
+ import { createRequire as __priiiskCreateRequire } from "node:module";
2
+ const require = __priiiskCreateRequire(import.meta.url);
3
+ import {
4
+ BadArgument,
5
+ CommandExecutor,
6
+ ExitCode,
7
+ FileDescriptor,
8
+ FileSystem,
9
+ FileTypeId,
10
+ Path,
11
+ PlatformWorker,
12
+ ProcessId,
13
+ ProcessTypeId,
14
+ Size,
15
+ SystemError,
16
+ Terminal,
17
+ TypeId,
18
+ WatchBackend,
19
+ WatchEventCreate,
20
+ WatchEventRemove,
21
+ WatchEventUpdate,
22
+ WorkerError,
23
+ effectify,
24
+ flatten,
25
+ layerManager,
26
+ make as make4,
27
+ makeExecutor,
28
+ makePlatform,
29
+ makeRunMain,
30
+ stdin
31
+ } from "./chunk-RJO6Z3SQ.js";
32
+ import {
33
+ BaseProto,
34
+ __export,
35
+ _await2 as _await,
36
+ _void,
37
+ acquireRelease,
38
+ addFinalizer,
39
+ addFinalizer2,
40
+ as,
41
+ asVoid2 as asVoid,
42
+ async,
43
+ asyncScoped,
44
+ catchAllCause,
45
+ complete,
46
+ constUndefined,
47
+ constVoid,
48
+ drain,
49
+ effect,
50
+ embedInput,
51
+ ensuring,
52
+ ensuring3 as ensuring2,
53
+ fail,
54
+ fail4 as fail2,
55
+ failCause2 as failCause,
56
+ flatMap,
57
+ flatMap3 as flatMap2,
58
+ flatMap5 as flatMap3,
59
+ fnUntraced,
60
+ forkDaemon,
61
+ fromChannel,
62
+ fromChannel2,
63
+ fromEffect,
64
+ fromNullable,
65
+ gen,
66
+ get5 as get,
67
+ getOrElse,
68
+ identity,
69
+ ignore,
70
+ interruptible,
71
+ isDone,
72
+ make10 as make3,
73
+ make13 as make5,
74
+ make4 as make,
75
+ make9 as make2,
76
+ map2 as map,
77
+ map7 as map2,
78
+ match,
79
+ matchEffect,
80
+ mergeAll,
81
+ negate,
82
+ none,
83
+ orDie,
84
+ orElse2 as orElse,
85
+ pipe,
86
+ provide2 as provide,
87
+ provideMerge,
88
+ run,
89
+ scoped,
90
+ scoped2,
91
+ serviceOption,
92
+ some,
93
+ succeed3 as succeed,
94
+ succeed4 as succeed2,
95
+ suspend,
96
+ suspend3 as suspend2,
97
+ sync,
98
+ tap,
99
+ timeout,
100
+ transduce,
101
+ tryPromise,
102
+ try_,
103
+ uninterruptible,
104
+ unsafeDone,
105
+ unsafeFromArray,
106
+ unsafeMakeLatch,
107
+ unsafeMakeSemaphore,
108
+ unwrap,
109
+ unwrapScoped,
110
+ void_,
111
+ void_2,
112
+ write,
113
+ zip,
114
+ zipRight
115
+ } from "./chunk-KFSFN6L5.js";
116
+
117
+ // node_modules/.pnpm/@effect+platform-node@0.107.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effect@3.2_9535e05eb804fa0fb275ce283b448483/node_modules/@effect/platform-node/dist/esm/NodeContext.js
118
+ var NodeContext_exports = {};
119
+ __export(NodeContext_exports, {
120
+ layer: () => layer10
121
+ });
122
+
123
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/internal/commandExecutor.js
124
+ import * as ChildProcess from "node:child_process";
125
+
126
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/internal/error.js
127
+ var handleErrnoException = (module, method) => (err, [path]) => {
128
+ let reason = "Unknown";
129
+ switch (err.code) {
130
+ case "ENOENT":
131
+ reason = "NotFound";
132
+ break;
133
+ case "EACCES":
134
+ reason = "PermissionDenied";
135
+ break;
136
+ case "EEXIST":
137
+ reason = "AlreadyExists";
138
+ break;
139
+ case "EISDIR":
140
+ reason = "BadResource";
141
+ break;
142
+ case "ENOTDIR":
143
+ reason = "BadResource";
144
+ break;
145
+ case "EBUSY":
146
+ reason = "Busy";
147
+ break;
148
+ case "ELOOP":
149
+ reason = "BadResource";
150
+ break;
151
+ }
152
+ return new SystemError({
153
+ reason,
154
+ module,
155
+ method,
156
+ pathOrDescriptor: path,
157
+ syscall: err.syscall,
158
+ description: err.message,
159
+ cause: err
160
+ });
161
+ };
162
+
163
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/internal/stream.js
164
+ import { Readable } from "node:stream";
165
+ var fromReadable = (evaluate, onError, options) => fromChannel(fromReadableChannel(evaluate, onError, options));
166
+ var fromReadableChannel = (evaluate, onError, options) => suspend2(() => unsafeReadableRead(evaluate(), onError, make(void 0), options));
167
+ var writeInput = (writable, onFailure, {
168
+ encoding,
169
+ endOnDone = true
170
+ } = {}, onDone = _void) => {
171
+ const write3 = writeEffect(writable, encoding);
172
+ const close2 = endOnDone ? async((resume) => {
173
+ if ("closed" in writable && writable.closed) {
174
+ resume(_void);
175
+ } else {
176
+ writable.once("finish", () => resume(_void));
177
+ writable.end();
178
+ }
179
+ }) : _void;
180
+ return {
181
+ awaitRead: () => _void,
182
+ emit: write3,
183
+ error: (cause) => zipRight(close2, onFailure(cause)),
184
+ done: (_) => zipRight(close2, onDone)
185
+ };
186
+ };
187
+ var writeEffect = (writable, encoding) => (chunk) => chunk.length === 0 ? _void : async((resume) => {
188
+ const iterator = chunk[Symbol.iterator]();
189
+ let next = iterator.next();
190
+ function loop() {
191
+ const item = next;
192
+ next = iterator.next();
193
+ const success = writable.write(item.value, encoding);
194
+ if (next.done) {
195
+ resume(_void);
196
+ } else if (success) {
197
+ loop();
198
+ } else {
199
+ writable.once("drain", loop);
200
+ }
201
+ }
202
+ loop();
203
+ });
204
+ var unsafeReadableRead = (readable, onError, exit, options) => {
205
+ if (!readable.readable) {
206
+ return void_2;
207
+ }
208
+ const latch = unsafeMakeLatch(false);
209
+ function onReadable() {
210
+ latch.unsafeOpen();
211
+ }
212
+ function onErr(err) {
213
+ exit.current = fail(onError(err));
214
+ latch.unsafeOpen();
215
+ }
216
+ function onEnd() {
217
+ exit.current = void_;
218
+ latch.unsafeOpen();
219
+ }
220
+ readable.on("readable", onReadable);
221
+ readable.on("error", onErr);
222
+ readable.on("end", onEnd);
223
+ const chunkSize = options?.chunkSize ? Number(options.chunkSize) : void 0;
224
+ const read2 = suspend2(function loop() {
225
+ let item = readable.read(chunkSize);
226
+ if (item === null) {
227
+ if (exit.current) {
228
+ return fromEffect(exit.current);
229
+ }
230
+ latch.unsafeClose();
231
+ return flatMap3(latch.await, loop);
232
+ }
233
+ const arr = [item];
234
+ while (true) {
235
+ item = readable.read(chunkSize);
236
+ if (item === null) {
237
+ return flatMap3(write(unsafeFromArray(arr)), loop);
238
+ }
239
+ arr.push(item);
240
+ }
241
+ });
242
+ return ensuring2(read2, sync(() => {
243
+ readable.off("readable", onReadable);
244
+ readable.off("error", onErr);
245
+ readable.off("end", onEnd);
246
+ if (options?.closeOnDone !== false && "closed" in readable && !readable.closed) {
247
+ readable.destroy();
248
+ }
249
+ }));
250
+ };
251
+
252
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/internal/sink.js
253
+ var fromWritable = (evaluate, onError, options) => fromChannel2(fromWritableChannel(evaluate, onError, options));
254
+ var fromWritableChannel = (writable, onError, options) => flatMap3(zip(sync(() => writable()), make2()), ([writable2, deferred]) => embedInput(writableOutput(writable2, deferred, onError), writeInput(writable2, (cause) => failCause(deferred, cause), options, complete(deferred, _void))));
255
+ var writableOutput = (writable, deferred, onError) => suspend(() => {
256
+ function handleError(err) {
257
+ unsafeDone(deferred, fail2(onError(err)));
258
+ }
259
+ writable.on("error", handleError);
260
+ return ensuring(_await(deferred), sync(() => {
261
+ writable.removeListener("error", handleError);
262
+ }));
263
+ });
264
+
265
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/internal/commandExecutor.js
266
+ var inputToStdioOption = (stdin2) => typeof stdin2 === "string" ? stdin2 : "pipe";
267
+ var outputToStdioOption = (output) => typeof output === "string" ? output : "pipe";
268
+ var toError = (err) => err instanceof globalThis.Error ? err : new globalThis.Error(String(err));
269
+ var toPlatformError = (method, error, command) => {
270
+ const flattened = flatten(command).reduce((acc, curr) => {
271
+ const command2 = `${curr.command} ${curr.args.join(" ")}`;
272
+ return acc.length === 0 ? command2 : `${acc} | ${command2}`;
273
+ }, "");
274
+ return handleErrnoException("Command", method)(error, [flattened]);
275
+ };
276
+ var ProcessProto = {
277
+ [ProcessTypeId]: ProcessTypeId,
278
+ ...BaseProto,
279
+ toJSON() {
280
+ return {
281
+ _id: "@effect/platform/CommandExecutor/Process",
282
+ pid: this.pid
283
+ };
284
+ }
285
+ };
286
+ var runCommand = (fileSystem) => (command) => {
287
+ switch (command._tag) {
288
+ case "StandardCommand": {
289
+ const spawn2 = flatMap2(make2(), (exitCode) => async((resume) => {
290
+ const handle = ChildProcess.spawn(command.command, command.args, {
291
+ stdio: [inputToStdioOption(command.stdin), outputToStdioOption(command.stdout), outputToStdioOption(command.stderr)],
292
+ cwd: getOrElse(command.cwd, constUndefined),
293
+ shell: command.shell,
294
+ env: {
295
+ ...process.env,
296
+ ...Object.fromEntries(command.env)
297
+ },
298
+ detached: process.platform !== "win32"
299
+ });
300
+ handle.on("error", (err) => {
301
+ resume(fail2(toPlatformError("spawn", err, command)));
302
+ });
303
+ handle.on("exit", (...args) => {
304
+ unsafeDone(exitCode, succeed(args));
305
+ });
306
+ handle.on("spawn", () => {
307
+ resume(succeed([handle, exitCode]));
308
+ });
309
+ return sync(() => {
310
+ handle.kill("SIGTERM");
311
+ });
312
+ }));
313
+ const killProcessGroup = process.platform === "win32" ? (handle, _) => async((resume) => {
314
+ ChildProcess.exec(`taskkill /pid ${handle.pid} /T /F`, (error) => {
315
+ if (error) {
316
+ resume(fail2(toPlatformError("kill", toError(error), command)));
317
+ } else {
318
+ resume(_void);
319
+ }
320
+ });
321
+ }) : (handle, signal) => try_({
322
+ try: () => process.kill(-handle.pid, signal),
323
+ catch: (error) => toPlatformError("kill", toError(error), command)
324
+ });
325
+ const killProcess = (handle, signal) => suspend(() => handle.kill(signal) ? _void : fail2(toPlatformError("kill", new globalThis.Error("Failed to kill process"), command)));
326
+ return pipe(
327
+ // Validate that the directory is accessible
328
+ match(command.cwd, {
329
+ onNone: () => _void,
330
+ onSome: (dir) => fileSystem.access(dir)
331
+ }),
332
+ zipRight(acquireRelease(spawn2, ([handle, exitCode]) => flatMap2(isDone(exitCode), (done) => {
333
+ if (!done) {
334
+ return killProcessGroup(handle, "SIGTERM").pipe(orElse(() => killProcess(handle, "SIGTERM")), zipRight(_await(exitCode)), ignore);
335
+ }
336
+ return flatMap2(_await(exitCode), ([code]) => {
337
+ if (code !== 0 && code !== null) {
338
+ return killProcessGroup(handle, "SIGTERM").pipe(ignore);
339
+ }
340
+ return _void;
341
+ });
342
+ }))),
343
+ map2(([handle, exitCodeDeferred]) => {
344
+ let stdin2 = drain;
345
+ if (handle.stdin !== null) {
346
+ stdin2 = fromWritable(() => handle.stdin, (err) => toPlatformError("toWritable", toError(err), command));
347
+ }
348
+ const exitCode = flatMap2(_await(exitCodeDeferred), ([code, signal]) => {
349
+ if (code !== null) {
350
+ return succeed(ExitCode(code));
351
+ }
352
+ return fail2(toPlatformError("exitCode", new globalThis.Error(`Process interrupted due to receipt of signal: ${signal}`), command));
353
+ });
354
+ const isRunning = negate(isDone(exitCodeDeferred));
355
+ const kill = (signal = "SIGTERM") => killProcessGroup(handle, signal).pipe(orElse(() => killProcess(handle, signal)), zipRight(asVoid(_await(exitCodeDeferred))));
356
+ const pid = ProcessId(handle.pid);
357
+ const stderr = fromReadable(() => handle.stderr, (err) => toPlatformError("fromReadable(stderr)", toError(err), command));
358
+ let stdout = fromReadable(() => handle.stdout, (err) => toPlatformError("fromReadable(stdout)", toError(err), command));
359
+ if (typeof command.stdout !== "string") {
360
+ stdout = transduce(stdout, command.stdout);
361
+ }
362
+ return Object.assign(Object.create(ProcessProto), {
363
+ pid,
364
+ exitCode,
365
+ isRunning,
366
+ kill,
367
+ stdin: stdin2,
368
+ stderr,
369
+ stdout
370
+ });
371
+ }),
372
+ typeof command.stdin === "string" ? identity : tap((process2) => forkDaemon(run(command.stdin, process2.stdin)))
373
+ );
374
+ }
375
+ case "PipedCommand": {
376
+ const flattened = flatten(command);
377
+ if (flattened.length === 1) {
378
+ return pipe(flattened[0], runCommand(fileSystem));
379
+ }
380
+ const head = flattened[0];
381
+ const tail = flattened.slice(1);
382
+ const initial = tail.slice(0, tail.length - 1);
383
+ const last = tail[tail.length - 1];
384
+ const stream = initial.reduce((stdin2, command2) => pipe(stdin(command2, stdin2), runCommand(fileSystem), map2((process2) => process2.stdout), unwrapScoped), pipe(runCommand(fileSystem)(head), map2((process2) => process2.stdout), unwrapScoped));
385
+ return pipe(stdin(last, stream), runCommand(fileSystem));
386
+ }
387
+ }
388
+ };
389
+ var layer = /* @__PURE__ */ effect(CommandExecutor, /* @__PURE__ */ pipe(FileSystem, /* @__PURE__ */ map2((fileSystem) => makeExecutor(runCommand(fileSystem)))));
390
+
391
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/NodeCommandExecutor.js
392
+ var layer2 = layer;
393
+
394
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/internal/fileSystem.js
395
+ import * as Crypto from "node:crypto";
396
+ import * as NFS from "node:fs";
397
+ import * as OS from "node:os";
398
+ import * as Path2 from "node:path";
399
+ var handleBadArgument = (method) => (cause) => new BadArgument({
400
+ module: "FileSystem",
401
+ method,
402
+ cause
403
+ });
404
+ var access2 = /* @__PURE__ */ (() => {
405
+ const nodeAccess = /* @__PURE__ */ effectify(NFS.access, /* @__PURE__ */ handleErrnoException("FileSystem", "access"), /* @__PURE__ */ handleBadArgument("access"));
406
+ return (path, options) => {
407
+ let mode = NFS.constants.F_OK;
408
+ if (options?.readable) {
409
+ mode |= NFS.constants.R_OK;
410
+ }
411
+ if (options?.writable) {
412
+ mode |= NFS.constants.W_OK;
413
+ }
414
+ return nodeAccess(path, mode);
415
+ };
416
+ })();
417
+ var copy = /* @__PURE__ */ (() => {
418
+ const nodeCp = /* @__PURE__ */ effectify(NFS.cp, /* @__PURE__ */ handleErrnoException("FileSystem", "copy"), /* @__PURE__ */ handleBadArgument("copy"));
419
+ return (fromPath, toPath, options) => nodeCp(fromPath, toPath, {
420
+ force: options?.overwrite ?? false,
421
+ preserveTimestamps: options?.preserveTimestamps ?? false,
422
+ recursive: true
423
+ });
424
+ })();
425
+ var copyFile2 = /* @__PURE__ */ (() => {
426
+ const nodeCopyFile = /* @__PURE__ */ effectify(NFS.copyFile, /* @__PURE__ */ handleErrnoException("FileSystem", "copyFile"), /* @__PURE__ */ handleBadArgument("copyFile"));
427
+ return (fromPath, toPath) => nodeCopyFile(fromPath, toPath);
428
+ })();
429
+ var chmod2 = /* @__PURE__ */ (() => {
430
+ const nodeChmod = /* @__PURE__ */ effectify(NFS.chmod, /* @__PURE__ */ handleErrnoException("FileSystem", "chmod"), /* @__PURE__ */ handleBadArgument("chmod"));
431
+ return (path, mode) => nodeChmod(path, mode);
432
+ })();
433
+ var chown2 = /* @__PURE__ */ (() => {
434
+ const nodeChown = /* @__PURE__ */ effectify(NFS.chown, /* @__PURE__ */ handleErrnoException("FileSystem", "chown"), /* @__PURE__ */ handleBadArgument("chown"));
435
+ return (path, uid, gid) => nodeChown(path, uid, gid);
436
+ })();
437
+ var link2 = /* @__PURE__ */ (() => {
438
+ const nodeLink = /* @__PURE__ */ effectify(NFS.link, /* @__PURE__ */ handleErrnoException("FileSystem", "link"), /* @__PURE__ */ handleBadArgument("link"));
439
+ return (existingPath, newPath) => nodeLink(existingPath, newPath);
440
+ })();
441
+ var makeDirectory = /* @__PURE__ */ (() => {
442
+ const nodeMkdir = /* @__PURE__ */ effectify(NFS.mkdir, /* @__PURE__ */ handleErrnoException("FileSystem", "makeDirectory"), /* @__PURE__ */ handleBadArgument("makeDirectory"));
443
+ return (path, options) => nodeMkdir(path, {
444
+ recursive: options?.recursive ?? false,
445
+ mode: options?.mode
446
+ });
447
+ })();
448
+ var makeTempDirectoryFactory = (method) => {
449
+ const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method));
450
+ return (options) => suspend(() => {
451
+ const prefix = options?.prefix ?? "";
452
+ const directory = typeof options?.directory === "string" ? Path2.join(options.directory, ".") : OS.tmpdir();
453
+ return nodeMkdtemp(prefix ? Path2.join(directory, prefix) : directory + "/");
454
+ });
455
+ };
456
+ var makeTempDirectory = /* @__PURE__ */ makeTempDirectoryFactory("makeTempDirectory");
457
+ var removeFactory = (method) => {
458
+ const nodeRm = effectify(NFS.rm, handleErrnoException("FileSystem", method), handleBadArgument(method));
459
+ return (path, options) => nodeRm(path, {
460
+ recursive: options?.recursive ?? false,
461
+ force: options?.force ?? false
462
+ });
463
+ };
464
+ var remove = /* @__PURE__ */ removeFactory("remove");
465
+ var makeTempDirectoryScoped = /* @__PURE__ */ (() => {
466
+ const makeDirectory2 = /* @__PURE__ */ makeTempDirectoryFactory("makeTempDirectoryScoped");
467
+ const removeDirectory = /* @__PURE__ */ removeFactory("makeTempDirectoryScoped");
468
+ return (options) => acquireRelease(makeDirectory2(options), (directory) => orDie(removeDirectory(directory, {
469
+ recursive: true
470
+ })));
471
+ })();
472
+ var openFactory = (method) => {
473
+ const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method));
474
+ const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method));
475
+ return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map2((fd) => makeFile(FileDescriptor(fd), options?.flag?.startsWith("a") ?? false)));
476
+ };
477
+ var open2 = /* @__PURE__ */ openFactory("open");
478
+ var makeFile = /* @__PURE__ */ (() => {
479
+ const nodeReadFactory = (method) => effectify(NFS.read, handleErrnoException("FileSystem", method), handleBadArgument(method));
480
+ const nodeRead = /* @__PURE__ */ nodeReadFactory("read");
481
+ const nodeReadAlloc = /* @__PURE__ */ nodeReadFactory("readAlloc");
482
+ const nodeStat = /* @__PURE__ */ effectify(NFS.fstat, /* @__PURE__ */ handleErrnoException("FileSystem", "stat"), /* @__PURE__ */ handleBadArgument("stat"));
483
+ const nodeTruncate = /* @__PURE__ */ effectify(NFS.ftruncate, /* @__PURE__ */ handleErrnoException("FileSystem", "truncate"), /* @__PURE__ */ handleBadArgument("truncate"));
484
+ const nodeSync = /* @__PURE__ */ effectify(NFS.fsync, /* @__PURE__ */ handleErrnoException("FileSystem", "sync"), /* @__PURE__ */ handleBadArgument("sync"));
485
+ const nodeWriteFactory = (method) => effectify(NFS.write, handleErrnoException("FileSystem", method), handleBadArgument(method));
486
+ const nodeWrite = /* @__PURE__ */ nodeWriteFactory("write");
487
+ const nodeWriteAll = /* @__PURE__ */ nodeWriteFactory("writeAll");
488
+ class FileImpl {
489
+ fd;
490
+ append;
491
+ [FileTypeId];
492
+ semaphore = /* @__PURE__ */ unsafeMakeSemaphore(1);
493
+ position = 0n;
494
+ constructor(fd, append) {
495
+ this.fd = fd;
496
+ this.append = append;
497
+ this[FileTypeId] = FileTypeId;
498
+ }
499
+ get stat() {
500
+ return map2(nodeStat(this.fd), makeFileInfo);
501
+ }
502
+ get sync() {
503
+ return nodeSync(this.fd);
504
+ }
505
+ seek(offset, from) {
506
+ const offsetSize = Size(offset);
507
+ return this.semaphore.withPermits(1)(sync(() => {
508
+ if (from === "start") {
509
+ this.position = offsetSize;
510
+ } else if (from === "current") {
511
+ this.position = this.position + offsetSize;
512
+ }
513
+ return this.position;
514
+ }));
515
+ }
516
+ read(buffer) {
517
+ return this.semaphore.withPermits(1)(map2(suspend(() => nodeRead(this.fd, {
518
+ buffer,
519
+ position: this.position
520
+ })), (bytesRead) => {
521
+ const sizeRead = Size(bytesRead);
522
+ this.position = this.position + sizeRead;
523
+ return sizeRead;
524
+ }));
525
+ }
526
+ readAlloc(size) {
527
+ const sizeNumber = Number(size);
528
+ return this.semaphore.withPermits(1)(flatMap2(sync(() => Buffer.allocUnsafeSlow(sizeNumber)), (buffer) => map2(nodeReadAlloc(this.fd, {
529
+ buffer,
530
+ position: this.position
531
+ }), (bytesRead) => {
532
+ if (bytesRead === 0) {
533
+ return none();
534
+ }
535
+ this.position = this.position + BigInt(bytesRead);
536
+ if (bytesRead === sizeNumber) {
537
+ return some(buffer);
538
+ }
539
+ const dst = Buffer.allocUnsafeSlow(bytesRead);
540
+ buffer.copy(dst, 0, 0, bytesRead);
541
+ return some(dst);
542
+ })));
543
+ }
544
+ truncate(length) {
545
+ return this.semaphore.withPermits(1)(map2(nodeTruncate(this.fd, length ? Number(length) : void 0), () => {
546
+ if (!this.append) {
547
+ const len = BigInt(length ?? 0);
548
+ if (this.position > len) {
549
+ this.position = len;
550
+ }
551
+ }
552
+ }));
553
+ }
554
+ write(buffer) {
555
+ return this.semaphore.withPermits(1)(map2(suspend(() => nodeWrite(this.fd, buffer, void 0, void 0, this.append ? void 0 : Number(this.position))), (bytesWritten) => {
556
+ const sizeWritten = Size(bytesWritten);
557
+ if (!this.append) {
558
+ this.position = this.position + sizeWritten;
559
+ }
560
+ return sizeWritten;
561
+ }));
562
+ }
563
+ writeAllChunk(buffer) {
564
+ return flatMap2(suspend(() => nodeWriteAll(this.fd, buffer, void 0, void 0, this.append ? void 0 : Number(this.position))), (bytesWritten) => {
565
+ if (bytesWritten === 0) {
566
+ return fail2(new SystemError({
567
+ module: "FileSystem",
568
+ method: "writeAll",
569
+ reason: "WriteZero",
570
+ pathOrDescriptor: this.fd,
571
+ description: "write returned 0 bytes written"
572
+ }));
573
+ }
574
+ if (!this.append) {
575
+ this.position = this.position + BigInt(bytesWritten);
576
+ }
577
+ return bytesWritten < buffer.length ? this.writeAllChunk(buffer.subarray(bytesWritten)) : _void;
578
+ });
579
+ }
580
+ writeAll(buffer) {
581
+ return this.semaphore.withPermits(1)(this.writeAllChunk(buffer));
582
+ }
583
+ }
584
+ return (fd, append) => new FileImpl(fd, append);
585
+ })();
586
+ var makeTempFileFactory = (method) => {
587
+ const makeDirectory2 = makeTempDirectoryFactory(method);
588
+ const open3 = openFactory(method);
589
+ const randomHexString = (bytes) => sync(() => Crypto.randomBytes(bytes).toString("hex"));
590
+ return (options) => pipe(zip(makeDirectory2(options), randomHexString(6)), map2(([directory, random]) => Path2.join(directory, random + (options?.suffix ?? ""))), tap((path) => scoped(open3(path, {
591
+ flag: "w+"
592
+ }))));
593
+ };
594
+ var makeTempFile = /* @__PURE__ */ makeTempFileFactory("makeTempFile");
595
+ var makeTempFileScoped = /* @__PURE__ */ (() => {
596
+ const makeFile2 = /* @__PURE__ */ makeTempFileFactory("makeTempFileScoped");
597
+ const removeDirectory = /* @__PURE__ */ removeFactory("makeTempFileScoped");
598
+ return (options) => acquireRelease(makeFile2(options), (file) => orDie(removeDirectory(Path2.dirname(file), {
599
+ recursive: true
600
+ })));
601
+ })();
602
+ var readDirectory = (path, options) => tryPromise({
603
+ try: () => NFS.promises.readdir(path, options),
604
+ catch: (err) => handleErrnoException("FileSystem", "readDirectory")(err, [path])
605
+ });
606
+ var readFile2 = (path) => async((resume, signal) => {
607
+ try {
608
+ NFS.readFile(path, {
609
+ signal
610
+ }, (err, data) => {
611
+ if (err) {
612
+ resume(fail2(handleErrnoException("FileSystem", "readFile")(err, [path])));
613
+ } else {
614
+ resume(succeed(data));
615
+ }
616
+ });
617
+ } catch (err) {
618
+ resume(fail2(handleBadArgument("readFile")(err)));
619
+ }
620
+ });
621
+ var readLink = /* @__PURE__ */ (() => {
622
+ const nodeReadLink = /* @__PURE__ */ effectify(NFS.readlink, /* @__PURE__ */ handleErrnoException("FileSystem", "readLink"), /* @__PURE__ */ handleBadArgument("readLink"));
623
+ return (path) => nodeReadLink(path);
624
+ })();
625
+ var realPath = /* @__PURE__ */ (() => {
626
+ const nodeRealPath = /* @__PURE__ */ effectify(NFS.realpath, /* @__PURE__ */ handleErrnoException("FileSystem", "realPath"), /* @__PURE__ */ handleBadArgument("realPath"));
627
+ return (path) => nodeRealPath(path);
628
+ })();
629
+ var rename2 = /* @__PURE__ */ (() => {
630
+ const nodeRename = /* @__PURE__ */ effectify(NFS.rename, /* @__PURE__ */ handleErrnoException("FileSystem", "rename"), /* @__PURE__ */ handleBadArgument("rename"));
631
+ return (oldPath, newPath) => nodeRename(oldPath, newPath);
632
+ })();
633
+ var makeFileInfo = (stat3) => ({
634
+ type: stat3.isFile() ? "File" : stat3.isDirectory() ? "Directory" : stat3.isSymbolicLink() ? "SymbolicLink" : stat3.isBlockDevice() ? "BlockDevice" : stat3.isCharacterDevice() ? "CharacterDevice" : stat3.isFIFO() ? "FIFO" : stat3.isSocket() ? "Socket" : "Unknown",
635
+ mtime: fromNullable(stat3.mtime),
636
+ atime: fromNullable(stat3.atime),
637
+ birthtime: fromNullable(stat3.birthtime),
638
+ dev: stat3.dev,
639
+ rdev: fromNullable(stat3.rdev),
640
+ ino: fromNullable(stat3.ino),
641
+ mode: stat3.mode,
642
+ nlink: fromNullable(stat3.nlink),
643
+ uid: fromNullable(stat3.uid),
644
+ gid: fromNullable(stat3.gid),
645
+ size: Size(stat3.size),
646
+ blksize: map(fromNullable(stat3.blksize), Size),
647
+ blocks: fromNullable(stat3.blocks)
648
+ });
649
+ var stat2 = /* @__PURE__ */ (() => {
650
+ const nodeStat = /* @__PURE__ */ effectify(NFS.stat, /* @__PURE__ */ handleErrnoException("FileSystem", "stat"), /* @__PURE__ */ handleBadArgument("stat"));
651
+ return (path) => map2(nodeStat(path), makeFileInfo);
652
+ })();
653
+ var symlink2 = /* @__PURE__ */ (() => {
654
+ const nodeSymlink = /* @__PURE__ */ effectify(NFS.symlink, /* @__PURE__ */ handleErrnoException("FileSystem", "symlink"), /* @__PURE__ */ handleBadArgument("symlink"));
655
+ return (target, path) => nodeSymlink(target, path);
656
+ })();
657
+ var truncate2 = /* @__PURE__ */ (() => {
658
+ const nodeTruncate = /* @__PURE__ */ effectify(NFS.truncate, /* @__PURE__ */ handleErrnoException("FileSystem", "truncate"), /* @__PURE__ */ handleBadArgument("truncate"));
659
+ return (path, length) => nodeTruncate(path, length !== void 0 ? Number(length) : void 0);
660
+ })();
661
+ var utimes2 = /* @__PURE__ */ (() => {
662
+ const nodeUtimes = /* @__PURE__ */ effectify(NFS.utimes, /* @__PURE__ */ handleErrnoException("FileSystem", "utime"), /* @__PURE__ */ handleBadArgument("utime"));
663
+ return (path, atime, mtime) => nodeUtimes(path, atime, mtime);
664
+ })();
665
+ var watchNode = (path, options) => asyncScoped((emit) => acquireRelease(sync(() => {
666
+ const watcher = NFS.watch(path, {
667
+ recursive: options?.recursive
668
+ }, (event, path2) => {
669
+ if (!path2) return;
670
+ switch (event) {
671
+ case "rename": {
672
+ emit.fromEffect(matchEffect(stat2(path2), {
673
+ onSuccess: (_) => succeed(WatchEventCreate({
674
+ path: path2
675
+ })),
676
+ onFailure: (err) => err._tag === "SystemError" && err.reason === "NotFound" ? succeed(WatchEventRemove({
677
+ path: path2
678
+ })) : fail2(err)
679
+ }));
680
+ return;
681
+ }
682
+ case "change": {
683
+ emit.single(WatchEventUpdate({
684
+ path: path2
685
+ }));
686
+ return;
687
+ }
688
+ }
689
+ });
690
+ watcher.on("error", (error) => {
691
+ emit.fail(new SystemError({
692
+ module: "FileSystem",
693
+ reason: "Unknown",
694
+ method: "watch",
695
+ pathOrDescriptor: path,
696
+ cause: error
697
+ }));
698
+ });
699
+ watcher.on("close", () => {
700
+ emit.end();
701
+ });
702
+ return watcher;
703
+ }), (watcher) => sync(() => watcher.close())));
704
+ var watch2 = (backend, path, options) => stat2(path).pipe(map2((stat3) => backend.pipe(flatMap((_) => _.register(path, stat3, options)), getOrElse(() => watchNode(path, options)))), unwrap);
705
+ var writeFile2 = (path, data, options) => async((resume, signal) => {
706
+ try {
707
+ NFS.writeFile(path, data, {
708
+ signal,
709
+ flag: options?.flag,
710
+ mode: options?.mode
711
+ }, (err) => {
712
+ if (err) {
713
+ resume(fail2(handleErrnoException("FileSystem", "writeFile")(err, [path])));
714
+ } else {
715
+ resume(_void);
716
+ }
717
+ });
718
+ } catch (err) {
719
+ resume(fail2(handleBadArgument("writeFile")(err)));
720
+ }
721
+ });
722
+ var makeFileSystem = /* @__PURE__ */ map2(/* @__PURE__ */ serviceOption(WatchBackend), (backend) => make4({
723
+ access: access2,
724
+ chmod: chmod2,
725
+ chown: chown2,
726
+ copy,
727
+ copyFile: copyFile2,
728
+ link: link2,
729
+ makeDirectory,
730
+ makeTempDirectory,
731
+ makeTempDirectoryScoped,
732
+ makeTempFile,
733
+ makeTempFileScoped,
734
+ open: open2,
735
+ readDirectory,
736
+ readFile: readFile2,
737
+ readLink,
738
+ realPath,
739
+ remove,
740
+ rename: rename2,
741
+ stat: stat2,
742
+ symlink: symlink2,
743
+ truncate: truncate2,
744
+ utimes: utimes2,
745
+ watch(path, options) {
746
+ return watch2(backend, path, options);
747
+ },
748
+ writeFile: writeFile2
749
+ }));
750
+ var layer3 = /* @__PURE__ */ effect(FileSystem, makeFileSystem);
751
+
752
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/NodeFileSystem.js
753
+ var layer4 = layer3;
754
+
755
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/internal/path.js
756
+ import * as NodePath from "node:path";
757
+ import * as NodeUrl from "node:url";
758
+ var fromFileUrl = (url) => try_({
759
+ try: () => NodeUrl.fileURLToPath(url),
760
+ catch: (error) => new BadArgument({
761
+ module: "Path",
762
+ method: "fromFileUrl",
763
+ description: `Invalid file URL: ${url}`,
764
+ cause: error
765
+ })
766
+ });
767
+ var toFileUrl = (path) => try_({
768
+ try: () => NodeUrl.pathToFileURL(path),
769
+ catch: (error) => new BadArgument({
770
+ module: "Path",
771
+ method: "toFileUrl",
772
+ description: `Invalid path: ${path}`,
773
+ cause: error
774
+ })
775
+ });
776
+ var layerPosix = /* @__PURE__ */ succeed2(Path, /* @__PURE__ */ Path.of({
777
+ [TypeId]: TypeId,
778
+ ...NodePath.posix,
779
+ fromFileUrl,
780
+ toFileUrl
781
+ }));
782
+ var layerWin32 = /* @__PURE__ */ succeed2(Path, /* @__PURE__ */ Path.of({
783
+ [TypeId]: TypeId,
784
+ ...NodePath.win32,
785
+ fromFileUrl,
786
+ toFileUrl
787
+ }));
788
+ var layer5 = /* @__PURE__ */ succeed2(Path, /* @__PURE__ */ Path.of({
789
+ [TypeId]: TypeId,
790
+ ...NodePath,
791
+ fromFileUrl,
792
+ toFileUrl
793
+ }));
794
+
795
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/NodePath.js
796
+ var layer6 = layer5;
797
+
798
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/internal/terminal.js
799
+ import * as readline from "node:readline";
800
+ var defaultShouldQuit = (input) => input.key.ctrl && (input.key.name === "c" || input.key.name === "d");
801
+ var make6 = /* @__PURE__ */ fnUntraced(function* (shouldQuit = defaultShouldQuit) {
802
+ const stdin2 = process.stdin;
803
+ const stdout = process.stdout;
804
+ const rlRef = yield* make3({
805
+ acquire: acquireRelease(sync(() => {
806
+ const rl = readline.createInterface({
807
+ input: stdin2,
808
+ escapeCodeTimeout: 50
809
+ });
810
+ readline.emitKeypressEvents(stdin2, rl);
811
+ if (stdin2.isTTY) {
812
+ stdin2.setRawMode(true);
813
+ }
814
+ return rl;
815
+ }), (rl) => sync(() => {
816
+ if (stdin2.isTTY) {
817
+ stdin2.setRawMode(false);
818
+ }
819
+ rl.close();
820
+ }))
821
+ });
822
+ const columns = sync(() => stdout.columns ?? 0);
823
+ const rows = sync(() => stdout.rows ?? 0);
824
+ const isTTY = sync(() => Boolean(stdout.isTTY));
825
+ const readInput = gen(function* () {
826
+ yield* get(rlRef);
827
+ const mailbox = yield* make5();
828
+ const handleKeypress = (s, k) => {
829
+ const userInput = {
830
+ input: fromNullable(s),
831
+ key: {
832
+ name: k.name ?? "",
833
+ ctrl: !!k.ctrl,
834
+ meta: !!k.meta,
835
+ shift: !!k.shift
836
+ }
837
+ };
838
+ mailbox.unsafeOffer(userInput);
839
+ if (shouldQuit(userInput)) {
840
+ mailbox.unsafeDone(void_);
841
+ }
842
+ };
843
+ yield* addFinalizer2(() => sync(() => stdin2.off("keypress", handleKeypress)));
844
+ stdin2.on("keypress", handleKeypress);
845
+ return mailbox;
846
+ });
847
+ const readLine = get(rlRef).pipe(flatMap2((readlineInterface) => async((resume) => {
848
+ const onLine = (line) => resume(succeed(line));
849
+ readlineInterface.once("line", onLine);
850
+ return sync(() => readlineInterface.off("line", onLine));
851
+ })), scoped);
852
+ const display = (prompt) => uninterruptible(async((resume) => {
853
+ stdout.write(prompt, (err) => err ? resume(fail2(new BadArgument({
854
+ module: "Terminal",
855
+ method: "display",
856
+ description: "Failed to write prompt to stdout",
857
+ cause: err
858
+ }))) : resume(_void));
859
+ }));
860
+ return Terminal.of({
861
+ columns,
862
+ rows,
863
+ isTTY,
864
+ readInput,
865
+ readLine,
866
+ display
867
+ });
868
+ });
869
+ var layer7 = /* @__PURE__ */ scoped2(Terminal, /* @__PURE__ */ make6(defaultShouldQuit));
870
+
871
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/NodeTerminal.js
872
+ var layer8 = layer7;
873
+
874
+ // node_modules/.pnpm/@effect+platform-node@0.107.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effect@3.2_9535e05eb804fa0fb275ce283b448483/node_modules/@effect/platform-node/dist/esm/internal/worker.js
875
+ var platformWorkerImpl = /* @__PURE__ */ makePlatform()({
876
+ setup({
877
+ scope,
878
+ worker
879
+ }) {
880
+ return flatMap2(make2(), (exitDeferred) => {
881
+ const thing = "postMessage" in worker ? {
882
+ postMessage(msg, t) {
883
+ worker.postMessage(msg, t);
884
+ },
885
+ kill: () => worker.terminate(),
886
+ worker
887
+ } : {
888
+ postMessage(msg, _) {
889
+ worker.send(msg);
890
+ },
891
+ kill: () => worker.kill("SIGKILL"),
892
+ worker
893
+ };
894
+ worker.on("exit", () => {
895
+ unsafeDone(exitDeferred, void_);
896
+ });
897
+ return as(addFinalizer(scope, suspend(() => {
898
+ thing.postMessage([1]);
899
+ return _await(exitDeferred);
900
+ }).pipe(interruptible, timeout(5e3), catchAllCause(() => sync(() => thing.kill())))), thing);
901
+ });
902
+ },
903
+ listen({
904
+ deferred,
905
+ emit,
906
+ port
907
+ }) {
908
+ port.worker.on("message", (message) => {
909
+ emit(message);
910
+ });
911
+ port.worker.on("messageerror", (cause) => {
912
+ unsafeDone(deferred, new WorkerError({
913
+ reason: "decode",
914
+ cause
915
+ }));
916
+ });
917
+ port.worker.on("error", (cause) => {
918
+ unsafeDone(deferred, new WorkerError({
919
+ reason: "unknown",
920
+ cause
921
+ }));
922
+ });
923
+ port.worker.on("exit", (code) => {
924
+ unsafeDone(deferred, new WorkerError({
925
+ reason: "unknown",
926
+ cause: new Error(`exited with code ${code}`)
927
+ }));
928
+ });
929
+ return _void;
930
+ }
931
+ });
932
+ var layerWorker = /* @__PURE__ */ succeed2(PlatformWorker, platformWorkerImpl);
933
+ var layerManager2 = /* @__PURE__ */ provide(layerManager, layerWorker);
934
+
935
+ // node_modules/.pnpm/@effect+platform-node@0.107.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effect@3.2_9535e05eb804fa0fb275ce283b448483/node_modules/@effect/platform-node/dist/esm/NodeWorker.js
936
+ var layerManager3 = layerManager2;
937
+
938
+ // node_modules/.pnpm/@effect+platform-node@0.107.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effect@3.2_9535e05eb804fa0fb275ce283b448483/node_modules/@effect/platform-node/dist/esm/NodeContext.js
939
+ var layer10 = /* @__PURE__ */ pipe(/* @__PURE__ */ mergeAll(layer6, layer2, layer8, layerManager3), /* @__PURE__ */ provideMerge(layer4));
940
+
941
+ // node_modules/.pnpm/@effect+platform-node@0.107.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effect@3.2_9535e05eb804fa0fb275ce283b448483/node_modules/@effect/platform-node/dist/esm/NodeRuntime.js
942
+ var NodeRuntime_exports = {};
943
+ __export(NodeRuntime_exports, {
944
+ runMain: () => runMain3
945
+ });
946
+
947
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/internal/runtime.js
948
+ var runMain = /* @__PURE__ */ makeRunMain(({
949
+ fiber,
950
+ teardown
951
+ }) => {
952
+ const keepAlive = setInterval(constVoid, 2 ** 31 - 1);
953
+ let receivedSignal = false;
954
+ fiber.addObserver((exit) => {
955
+ if (!receivedSignal) {
956
+ process.removeListener("SIGINT", onSigint);
957
+ process.removeListener("SIGTERM", onSigint);
958
+ }
959
+ clearInterval(keepAlive);
960
+ teardown(exit, (code) => {
961
+ if (receivedSignal || code !== 0) {
962
+ process.exit(code);
963
+ }
964
+ });
965
+ });
966
+ function onSigint() {
967
+ receivedSignal = true;
968
+ process.removeListener("SIGINT", onSigint);
969
+ process.removeListener("SIGTERM", onSigint);
970
+ fiber.unsafeInterruptAsFork(fiber.id());
971
+ }
972
+ process.on("SIGINT", onSigint);
973
+ process.on("SIGTERM", onSigint);
974
+ });
975
+
976
+ // node_modules/.pnpm/@effect+platform-node-shared@0.60.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effe_4357e823b93d5894c803d1b4f92be74a/node_modules/@effect/platform-node-shared/dist/esm/NodeRuntime.js
977
+ var runMain2 = runMain;
978
+
979
+ // node_modules/.pnpm/@effect+platform-node@0.107.0_@effect+cluster@0.59.0_@effect+platform@0.96.2_effect@3.2_9535e05eb804fa0fb275ce283b448483/node_modules/@effect/platform-node/dist/esm/NodeRuntime.js
980
+ var runMain3 = runMain2;
981
+
982
+ export {
983
+ fromReadable,
984
+ layer10 as layer,
985
+ NodeContext_exports,
986
+ runMain3 as runMain,
987
+ NodeRuntime_exports
988
+ };