@effect/platform-node 0.19.8 → 0.20.0

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 (117) hide show
  1. package/Command/dist/effect-platform-node-Command.cjs.dev.js +32 -32
  2. package/Command/dist/effect-platform-node-Command.cjs.prod.js +32 -32
  3. package/CommandExecutor/dist/effect-platform-node-CommandExecutor.cjs.dev.js +184 -16
  4. package/CommandExecutor/dist/effect-platform-node-CommandExecutor.cjs.prod.js +184 -16
  5. package/CommandExecutor/dist/effect-platform-node-CommandExecutor.esm.js +158 -13
  6. package/Effectify/dist/effect-platform-node-Effectify.cjs.dev.js +2 -2
  7. package/Effectify/dist/effect-platform-node-Effectify.cjs.prod.js +2 -2
  8. package/Error/dist/effect-platform-node-Error.cjs.dev.js +6 -14
  9. package/Error/dist/effect-platform-node-Error.cjs.mjs +1 -3
  10. package/Error/dist/effect-platform-node-Error.cjs.prod.js +6 -14
  11. package/Error/dist/effect-platform-node-Error.esm.js +1 -1
  12. package/FileSystem/dist/effect-platform-node-FileSystem.cjs.dev.js +423 -17
  13. package/FileSystem/dist/effect-platform-node-FileSystem.cjs.prod.js +423 -17
  14. package/FileSystem/dist/effect-platform-node-FileSystem.esm.js +395 -12
  15. package/Http/FormData/dist/effect-platform-node-Http-FormData.cjs.dev.js +3 -3
  16. package/Http/FormData/dist/effect-platform-node-Http-FormData.cjs.prod.js +3 -3
  17. package/Http/FormData/dist/effect-platform-node-Http-FormData.esm.js +3 -3
  18. package/Http/NodeClient/dist/effect-platform-node-Http-NodeClient.cjs.dev.js +4 -4
  19. package/Http/NodeClient/dist/effect-platform-node-Http-NodeClient.cjs.prod.js +4 -4
  20. package/Http/NodeClient/dist/effect-platform-node-Http-NodeClient.esm.js +4 -4
  21. package/Http/Platform/dist/effect-platform-node-Http-Platform.cjs.dev.js +2 -2
  22. package/Http/Platform/dist/effect-platform-node-Http-Platform.cjs.prod.js +2 -2
  23. package/Http/Platform/dist/effect-platform-node-Http-Platform.esm.js +2 -2
  24. package/Http/Server/dist/effect-platform-node-Http-Server.cjs.dev.js +8 -7
  25. package/Http/Server/dist/effect-platform-node-Http-Server.cjs.prod.js +8 -7
  26. package/Http/Server/dist/effect-platform-node-Http-Server.esm.js +8 -7
  27. package/HttpClient/dist/effect-platform-node-HttpClient.cjs.dev.js +19 -19
  28. package/HttpClient/dist/effect-platform-node-HttpClient.cjs.prod.js +19 -19
  29. package/HttpClient/dist/effect-platform-node-HttpClient.esm.js +4 -4
  30. package/HttpServer/dist/effect-platform-node-HttpServer.cjs.dev.js +23 -23
  31. package/HttpServer/dist/effect-platform-node-HttpServer.cjs.prod.js +23 -23
  32. package/HttpServer/dist/effect-platform-node-HttpServer.esm.js +8 -8
  33. package/KeyValueStore/dist/effect-platform-node-KeyValueStore.cjs.dev.js +39 -9
  34. package/KeyValueStore/dist/effect-platform-node-KeyValueStore.cjs.prod.js +39 -9
  35. package/KeyValueStore/dist/effect-platform-node-KeyValueStore.esm.js +18 -4
  36. package/NodeContext/dist/effect-platform-node-NodeContext.cjs.dev.js +39 -7
  37. package/NodeContext/dist/effect-platform-node-NodeContext.cjs.prod.js +39 -7
  38. package/NodeContext/dist/effect-platform-node-NodeContext.esm.js +22 -6
  39. package/Path/dist/effect-platform-node-Path.cjs.dev.js +91 -11
  40. package/Path/dist/effect-platform-node-Path.cjs.prod.js +91 -11
  41. package/Path/dist/effect-platform-node-Path.esm.js +68 -6
  42. package/Runtime/dist/effect-platform-node-Runtime.cjs.dev.js +57 -6
  43. package/Runtime/dist/effect-platform-node-Runtime.cjs.prod.js +57 -6
  44. package/Runtime/dist/effect-platform-node-Runtime.esm.js +38 -3
  45. package/Sink/dist/effect-platform-node-Sink.cjs.dev.js +15 -3
  46. package/Sink/dist/effect-platform-node-Sink.cjs.prod.js +15 -3
  47. package/Sink/dist/effect-platform-node-Sink.esm.js +18 -2
  48. package/Stream/dist/effect-platform-node-Stream.cjs.dev.js +29 -5
  49. package/Stream/dist/effect-platform-node-Stream.cjs.prod.js +29 -5
  50. package/Stream/dist/effect-platform-node-Stream.esm.js +30 -2
  51. package/dist/{FormData-053407d4.cjs.dev.js → FormData-15af6672.cjs.dev.js} +1 -1
  52. package/dist/{FormData-bafc0b9a.esm.js → FormData-5ea8a8b6.esm.js} +1 -1
  53. package/dist/{FormData-c7339a7b.cjs.prod.js → FormData-d91e8016.cjs.prod.js} +1 -1
  54. package/dist/{NodeClient-ea1a9ab0.cjs.prod.js → NodeClient-3432a6a8.cjs.prod.js} +2 -2
  55. package/dist/{NodeClient-e349733e.esm.js → NodeClient-cd56cae8.esm.js} +2 -2
  56. package/dist/{NodeClient-1df9d813.cjs.dev.js → NodeClient-ebd71893.cjs.dev.js} +2 -2
  57. package/dist/{Server-ea100887.cjs.prod.js → Server-33a0b014.cjs.prod.js} +17 -13
  58. package/dist/{Server-264c702d.cjs.dev.js → Server-cf266586.cjs.dev.js} +17 -13
  59. package/dist/{Server-5237fa52.esm.js → Server-eb4f8a51.esm.js} +16 -13
  60. package/dist/declarations/src/Error.d.ts +7 -6
  61. package/dist/declarations/src/Error.d.ts.map +1 -1
  62. package/dist/declarations/src/index.d.ts.map +1 -1
  63. package/dist/effect-platform-node.cjs.dev.js +58 -86
  64. package/dist/effect-platform-node.cjs.prod.js +58 -86
  65. package/dist/effect-platform-node.esm.js +26 -73
  66. package/dist/{formData-fac89256.cjs.dev.js → formData-632b1146.cjs.dev.js} +1 -1
  67. package/dist/{formData-4330f230.esm.js → formData-dd75bbe1.esm.js} +1 -1
  68. package/dist/{formData-09ad7f6d.cjs.prod.js → formData-ecf6742b.cjs.prod.js} +1 -1
  69. package/dist/{incomingMessage-12764c2c.esm.js → incomingMessage-11c9bea6.esm.js} +1 -1
  70. package/dist/{incomingMessage-8a9a29f7.cjs.prod.js → incomingMessage-86bcf94d.cjs.dev.js} +1 -1
  71. package/dist/{incomingMessage-d7f144e7.cjs.dev.js → incomingMessage-f56be93e.cjs.prod.js} +1 -1
  72. package/dist/{platform-f3d31bb1.esm.js → platform-2c00c2c5.esm.js} +1 -1
  73. package/dist/{platform-1c31462c.cjs.dev.js → platform-5b27475e.cjs.dev.js} +1 -1
  74. package/dist/{platform-d09ef04f.cjs.prod.js → platform-80b90f07.cjs.prod.js} +1 -1
  75. package/package.json +8 -5
  76. package/src/Error.ts +9 -6
  77. package/src/index.ts +13 -13
  78. package/src/internal/http/server.ts +24 -16
  79. package/dist/Command-15b84341.cjs.dev.js +0 -29
  80. package/dist/Command-2fc875e9.cjs.prod.js +0 -29
  81. package/dist/Command-56d67f13.esm.js +0 -27
  82. package/dist/CommandExecutor-b7cb55b8.cjs.dev.js +0 -195
  83. package/dist/CommandExecutor-bccc7563.cjs.prod.js +0 -195
  84. package/dist/CommandExecutor-cfc0af4b.esm.js +0 -165
  85. package/dist/Effectify-1676f59e.cjs.prod.js +0 -14
  86. package/dist/Effectify-24bba5b0.esm.js +0 -12
  87. package/dist/Effectify-c94620ca.cjs.dev.js +0 -14
  88. package/dist/Error-004c8162.cjs.prod.js +0 -18
  89. package/dist/Error-6b032e84.esm.js +0 -16
  90. package/dist/Error-6db0ba89.cjs.dev.js +0 -18
  91. package/dist/FileSystem-a207377d.cjs.prod.js +0 -433
  92. package/dist/FileSystem-d4a3521c.esm.js +0 -403
  93. package/dist/FileSystem-d7b8eeac.cjs.dev.js +0 -433
  94. package/dist/HttpClient-11e2237f.esm.js +0 -26
  95. package/dist/HttpClient-19998c5e.cjs.dev.js +0 -54
  96. package/dist/HttpClient-1ad217ea.cjs.prod.js +0 -54
  97. package/dist/HttpServer-08393436.esm.js +0 -34
  98. package/dist/HttpServer-6652ce27.cjs.dev.js +0 -64
  99. package/dist/HttpServer-d510f888.cjs.prod.js +0 -64
  100. package/dist/KeyValueStore-35cb6494.cjs.prod.js +0 -62
  101. package/dist/KeyValueStore-66bca5fd.esm.js +0 -38
  102. package/dist/KeyValueStore-af7495b6.cjs.dev.js +0 -62
  103. package/dist/NodeContext-3c96e955.cjs.dev.js +0 -50
  104. package/dist/NodeContext-4bca6ed4.esm.js +0 -27
  105. package/dist/NodeContext-dff7bc0b.cjs.prod.js +0 -50
  106. package/dist/Path-7a81561f.esm.js +0 -76
  107. package/dist/Path-bf4c3b07.cjs.prod.js +0 -104
  108. package/dist/Path-feae3dcf.cjs.dev.js +0 -104
  109. package/dist/Runtime-3bc7ee1e.esm.js +0 -44
  110. package/dist/Runtime-6aeac6f0.cjs.dev.js +0 -68
  111. package/dist/Runtime-e746c66d.cjs.prod.js +0 -68
  112. package/dist/Sink-536c2b16.cjs.dev.js +0 -26
  113. package/dist/Sink-554d2819.esm.js +0 -23
  114. package/dist/Sink-735101fa.cjs.prod.js +0 -26
  115. package/dist/Stream-2d5b1ece.esm.js +0 -37
  116. package/dist/Stream-53f57af5.cjs.dev.js +0 -42
  117. package/dist/Stream-7424efca.cjs.prod.js +0 -42
@@ -1,403 +0,0 @@
1
- import { effectify } from '@effect/platform/Effectify';
2
- import * as Error from '@effect/platform/Error';
3
- import * as FileSystem$1 from '@effect/platform/FileSystem';
4
- import { FileSystem as FileSystem$2, Size } from '@effect/platform/FileSystem';
5
- import * as Effect from 'effect/Effect';
6
- import { pipe } from 'effect/Function';
7
- import * as Layer from 'effect/Layer';
8
- import * as Option from 'effect/Option';
9
- import * as Crypto from 'node:crypto';
10
- import * as NFS from 'node:fs';
11
- import * as OS from 'node:os';
12
- import * as NodePath from 'node:path';
13
- import { h as handleErrnoException } from './error-4865cb95.esm.js';
14
-
15
- const handleBadArgument = method => err => Error.BadArgument({
16
- module: "FileSystem",
17
- method,
18
- message: err.message ?? String(err)
19
- });
20
-
21
- // == access
22
-
23
- const access = /*#__PURE__*/(() => {
24
- const nodeAccess = /*#__PURE__*/effectify(NFS.access, /*#__PURE__*/handleErrnoException("FileSystem", "access"), /*#__PURE__*/handleBadArgument("access"));
25
- return (path, options) => {
26
- let mode = NFS.constants.F_OK;
27
- if (options?.readable) {
28
- mode |= NFS.constants.R_OK;
29
- }
30
- if (options?.writable) {
31
- mode |= NFS.constants.W_OK;
32
- }
33
- return nodeAccess(path, mode);
34
- };
35
- })();
36
-
37
- // == copy
38
-
39
- const copy = /*#__PURE__*/(() => {
40
- const nodeCp = /*#__PURE__*/effectify(NFS.cp, /*#__PURE__*/handleErrnoException("FileSystem", "copy"), /*#__PURE__*/handleBadArgument("copy"));
41
- return (fromPath, toPath, options) => nodeCp(fromPath, toPath, {
42
- force: options?.overwrite ?? false,
43
- preserveTimestamps: options?.preserveTimestamps ?? false,
44
- recursive: true
45
- });
46
- })();
47
-
48
- // == copyFile
49
-
50
- const copyFile = /*#__PURE__*/(() => {
51
- const nodeCopyFile = /*#__PURE__*/effectify(NFS.copyFile, /*#__PURE__*/handleErrnoException("FileSystem", "copyFile"), /*#__PURE__*/handleBadArgument("copyFile"));
52
- return (fromPath, toPath) => nodeCopyFile(fromPath, toPath);
53
- })();
54
-
55
- // == chmod
56
-
57
- const chmod = /*#__PURE__*/(() => {
58
- const nodeChmod = /*#__PURE__*/effectify(NFS.chmod, /*#__PURE__*/handleErrnoException("FileSystem", "chmod"), /*#__PURE__*/handleBadArgument("chmod"));
59
- return (path, mode) => nodeChmod(path, mode);
60
- })();
61
-
62
- // == chown
63
-
64
- const chown = /*#__PURE__*/(() => {
65
- const nodeChown = /*#__PURE__*/effectify(NFS.chown, /*#__PURE__*/handleErrnoException("FileSystem", "chown"), /*#__PURE__*/handleBadArgument("chown"));
66
- return (path, uid, gid) => nodeChown(path, uid, gid);
67
- })();
68
-
69
- // == link
70
-
71
- const link = /*#__PURE__*/(() => {
72
- const nodeLink = /*#__PURE__*/effectify(NFS.link, /*#__PURE__*/handleErrnoException("FileSystem", "link"), /*#__PURE__*/handleBadArgument("link"));
73
- return (existingPath, newPath) => nodeLink(existingPath, newPath);
74
- })();
75
-
76
- // == makeDirectory
77
-
78
- const makeDirectory = /*#__PURE__*/(() => {
79
- const nodeMkdir = /*#__PURE__*/effectify(NFS.mkdir, /*#__PURE__*/handleErrnoException("FileSystem", "makeDirectory"), /*#__PURE__*/handleBadArgument("makeDirectory"));
80
- return (path, options) => nodeMkdir(path, {
81
- recursive: options?.recursive ?? false,
82
- mode: options?.mode
83
- });
84
- })();
85
-
86
- // == makeTempDirectory
87
-
88
- const makeTempDirectoryFactory = method => {
89
- const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method));
90
- return options => Effect.suspend(() => {
91
- const prefix = options?.prefix ?? "";
92
- const directory = typeof options?.directory === "string" ? NodePath.join(options.directory, ".") : OS.tmpdir();
93
- return nodeMkdtemp(prefix ? NodePath.join(directory, prefix) : directory + "/");
94
- });
95
- };
96
- const makeTempDirectory = /*#__PURE__*/makeTempDirectoryFactory("makeTempDirectory");
97
-
98
- // == remove
99
-
100
- const removeFactory = method => {
101
- const nodeRm = effectify(NFS.rm, handleErrnoException("FileSystem", method), handleBadArgument(method));
102
- return (path, options) => nodeRm(path, {
103
- recursive: options?.recursive ?? false
104
- });
105
- };
106
- const remove = /*#__PURE__*/removeFactory("remove");
107
-
108
- // == makeTempDirectoryScoped
109
-
110
- const makeTempDirectoryScoped = /*#__PURE__*/(() => {
111
- const makeDirectory = /*#__PURE__*/makeTempDirectoryFactory("makeTempDirectoryScoped");
112
- const removeDirectory = /*#__PURE__*/removeFactory("makeTempDirectoryScoped");
113
- return options => Effect.acquireRelease(makeDirectory(options), directory => Effect.orDie(removeDirectory(directory, {
114
- recursive: true
115
- })));
116
- })();
117
-
118
- // == open
119
-
120
- const openFactory = method => {
121
- const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method));
122
- const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method));
123
- return (path, options) => pipe(Effect.acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), fd => Effect.orDie(nodeClose(fd))), Effect.map(fd => makeFile(FileSystem$1.FileDescriptor(fd), options?.flag?.startsWith("a") ?? false)));
124
- };
125
- const open = /*#__PURE__*/openFactory("open");
126
- const makeFile = /*#__PURE__*/(() => {
127
- const nodeReadFactory = method => effectify(NFS.read, handleErrnoException("FileSystem", method), handleBadArgument(method));
128
- const nodeRead = /*#__PURE__*/nodeReadFactory("read");
129
- const nodeReadAlloc = /*#__PURE__*/nodeReadFactory("readAlloc");
130
- const nodeStat = /*#__PURE__*/effectify(NFS.fstat, /*#__PURE__*/handleErrnoException("FileSystem", "stat"), /*#__PURE__*/handleBadArgument("stat"));
131
- const nodeTruncate = /*#__PURE__*/effectify(NFS.ftruncate, /*#__PURE__*/handleErrnoException("FileSystem", "truncate"), /*#__PURE__*/handleBadArgument("truncate"));
132
- const nodeWriteFactory = method => effectify(NFS.write, handleErrnoException("FileSystem", method), handleBadArgument(method));
133
- const nodeWrite = /*#__PURE__*/nodeWriteFactory("write");
134
- const nodeWriteAll = /*#__PURE__*/nodeWriteFactory("writeAll");
135
- class FileImpl {
136
- semaphore = Effect.unsafeMakeSemaphore(1);
137
- position = 0n;
138
- constructor(fd, append) {
139
- this.fd = fd;
140
- this.append = append;
141
- this[FileSystem$1.FileTypeId] = FileSystem$1.FileTypeId;
142
- }
143
- get stat() {
144
- return Effect.map(nodeStat(this.fd), makeFileInfo);
145
- }
146
- seek(offset, from) {
147
- const offsetSize = FileSystem$1.Size(offset);
148
- return this.semaphore.withPermits(1)(Effect.sync(() => {
149
- if (from === "start") {
150
- this.position = offsetSize;
151
- } else if (from === "current") {
152
- this.position = this.position + offsetSize;
153
- }
154
- return this.position;
155
- }));
156
- }
157
- read(buffer) {
158
- return this.semaphore.withPermits(1)(Effect.map(Effect.suspend(() => nodeRead(this.fd, {
159
- buffer,
160
- position: this.position
161
- })), bytesRead => {
162
- const sizeRead = FileSystem$1.Size(bytesRead);
163
- this.position = this.position + sizeRead;
164
- return sizeRead;
165
- }));
166
- }
167
- readAlloc(size) {
168
- const sizeNumber = Number(size);
169
- return this.semaphore.withPermits(1)(Effect.flatMap(Effect.sync(() => Buffer.allocUnsafeSlow(sizeNumber)), buffer => Effect.map(nodeReadAlloc(this.fd, {
170
- buffer,
171
- position: this.position
172
- }), bytesRead => {
173
- if (bytesRead === 0) {
174
- return Option.none();
175
- }
176
- this.position = this.position + BigInt(bytesRead);
177
- if (bytesRead === sizeNumber) {
178
- return Option.some(buffer);
179
- }
180
- const dst = Buffer.allocUnsafeSlow(bytesRead);
181
- buffer.copy(dst, 0, 0, bytesRead);
182
- return Option.some(dst);
183
- })));
184
- }
185
- truncate(length) {
186
- return this.semaphore.withPermits(1)(Effect.map(nodeTruncate(this.fd, length ? Number(length) : undefined), () => {
187
- if (!this.append) {
188
- const len = BigInt(length ?? 0);
189
- if (this.position > len) {
190
- this.position = len;
191
- }
192
- }
193
- }));
194
- }
195
- write(buffer) {
196
- return this.semaphore.withPermits(1)(Effect.map(Effect.suspend(() => nodeWrite(this.fd, buffer, undefined, undefined, this.append ? undefined : Number(this.position))), bytesWritten => {
197
- const sizeWritten = FileSystem$1.Size(bytesWritten);
198
- if (!this.append) {
199
- this.position = this.position + sizeWritten;
200
- }
201
- return sizeWritten;
202
- }));
203
- }
204
- writeAllChunk(buffer) {
205
- return Effect.flatMap(Effect.suspend(() => nodeWriteAll(this.fd, buffer, undefined, undefined, this.append ? undefined : Number(this.position))), bytesWritten => {
206
- if (bytesWritten === 0) {
207
- return Effect.fail(Error.SystemError({
208
- module: "FileSystem",
209
- method: "writeAll",
210
- reason: "WriteZero",
211
- pathOrDescriptor: this.fd,
212
- message: "write returned 0 bytes written"
213
- }));
214
- }
215
- if (!this.append) {
216
- this.position = this.position + BigInt(bytesWritten);
217
- }
218
- return bytesWritten < buffer.length ? this.writeAllChunk(buffer.subarray(bytesWritten)) : Effect.unit;
219
- });
220
- }
221
- writeAll(buffer) {
222
- return this.semaphore.withPermits(1)(this.writeAllChunk(buffer));
223
- }
224
- }
225
- return (fd, append) => new FileImpl(fd, append);
226
- })();
227
-
228
- // == makeTempFile
229
-
230
- const makeTempFileFactory = method => {
231
- const makeDirectory = makeTempDirectoryFactory(method);
232
- const open = openFactory(method);
233
- const randomHexString = bytes => Effect.sync(() => Crypto.randomBytes(bytes).toString("hex"));
234
- return options => pipe(Effect.zip(makeDirectory(options), randomHexString(6)), Effect.map(([directory, random]) => NodePath.join(directory, random)), Effect.tap(path => Effect.scoped(open(path, {
235
- flag: "w+"
236
- }))));
237
- };
238
- const makeTempFile = /*#__PURE__*/makeTempFileFactory("makeTempFile");
239
-
240
- // == makeTempFileScoped
241
-
242
- const makeTempFileScoped = /*#__PURE__*/(() => {
243
- const makeFile = /*#__PURE__*/makeTempFileFactory("makeTempFileScoped");
244
- const removeFile = /*#__PURE__*/removeFactory("makeTempFileScoped");
245
- return options => Effect.acquireRelease(makeFile(options), file => Effect.orDie(removeFile(file)));
246
- })();
247
-
248
- // == readDirectory
249
-
250
- const readDirectory = /*#__PURE__*/(() => {
251
- const nodeReadDirectory = /*#__PURE__*/effectify(NFS.readdir, /*#__PURE__*/handleErrnoException("FileSystem", "readDirectory"), /*#__PURE__*/handleBadArgument("readDirectory"));
252
- return (path, options) => nodeReadDirectory(path, options);
253
- })();
254
-
255
- // == readFile
256
-
257
- const readFile = path => Effect.async((resume, signal) => {
258
- try {
259
- NFS.readFile(path, {
260
- signal
261
- }, (err, data) => {
262
- if (err) {
263
- resume(Effect.fail(handleErrnoException("FileSystem", "readFile")(err, [path])));
264
- } else {
265
- resume(Effect.succeed(data));
266
- }
267
- });
268
- } catch (err) {
269
- resume(Effect.fail(handleBadArgument("readFile")(err)));
270
- }
271
- });
272
-
273
- // == readLink
274
-
275
- const readLink = /*#__PURE__*/(() => {
276
- const nodeReadLink = /*#__PURE__*/effectify(NFS.readlink, /*#__PURE__*/handleErrnoException("FileSystem", "readLink"), /*#__PURE__*/handleBadArgument("readLink"));
277
- return path => nodeReadLink(path);
278
- })();
279
-
280
- // == realPath
281
-
282
- const realPath = /*#__PURE__*/(() => {
283
- const nodeRealPath = /*#__PURE__*/effectify(NFS.realpath, /*#__PURE__*/handleErrnoException("FileSystem", "realPath"), /*#__PURE__*/handleBadArgument("realPath"));
284
- return path => nodeRealPath(path);
285
- })();
286
-
287
- // == rename
288
-
289
- const rename = /*#__PURE__*/(() => {
290
- const nodeRename = /*#__PURE__*/effectify(NFS.rename, /*#__PURE__*/handleErrnoException("FileSystem", "rename"), /*#__PURE__*/handleBadArgument("rename"));
291
- return (oldPath, newPath) => nodeRename(oldPath, newPath);
292
- })();
293
-
294
- // == stat
295
-
296
- const makeFileInfo = stat => ({
297
- type: stat.isFile() ? "File" : stat.isDirectory() ? "Directory" : stat.isSymbolicLink() ? "SymbolicLink" : stat.isBlockDevice() ? "BlockDevice" : stat.isCharacterDevice() ? "CharacterDevice" : stat.isFIFO() ? "FIFO" : stat.isSocket() ? "Socket" : "Unknown",
298
- mtime: Option.fromNullable(stat.mtime),
299
- atime: Option.fromNullable(stat.atime),
300
- birthtime: Option.fromNullable(stat.birthtime),
301
- dev: stat.dev,
302
- rdev: Option.fromNullable(stat.rdev),
303
- ino: Option.fromNullable(stat.ino),
304
- mode: stat.mode,
305
- nlink: Option.fromNullable(stat.nlink),
306
- uid: Option.fromNullable(stat.uid),
307
- gid: Option.fromNullable(stat.gid),
308
- size: FileSystem$1.Size(stat.size),
309
- blksize: Option.fromNullable(FileSystem$1.Size(stat.blksize)),
310
- blocks: Option.fromNullable(stat.blocks)
311
- });
312
- const stat = /*#__PURE__*/(() => {
313
- const nodeStat = /*#__PURE__*/effectify(NFS.stat, /*#__PURE__*/handleErrnoException("FileSystem", "stat"), /*#__PURE__*/handleBadArgument("stat"));
314
- return path => Effect.map(nodeStat(path), makeFileInfo);
315
- })();
316
-
317
- // == symlink
318
-
319
- const symlink = /*#__PURE__*/(() => {
320
- const nodeSymlink = /*#__PURE__*/effectify(NFS.symlink, /*#__PURE__*/handleErrnoException("FileSystem", "symlink"), /*#__PURE__*/handleBadArgument("symlink"));
321
- return (target, path) => nodeSymlink(target, path);
322
- })();
323
-
324
- // == truncate
325
-
326
- const truncate = /*#__PURE__*/(() => {
327
- const nodeTruncate = /*#__PURE__*/effectify(NFS.truncate, /*#__PURE__*/handleErrnoException("FileSystem", "truncate"), /*#__PURE__*/handleBadArgument("truncate"));
328
- return (path, length) => nodeTruncate(path, length !== undefined ? Number(length) : undefined);
329
- })();
330
-
331
- // == utimes
332
-
333
- const utimes = /*#__PURE__*/(() => {
334
- const nodeUtimes = /*#__PURE__*/effectify(NFS.utimes, /*#__PURE__*/handleErrnoException("FileSystem", "utime"), /*#__PURE__*/handleBadArgument("utime"));
335
- return (path, atime, mtime) => nodeUtimes(path, atime, mtime);
336
- })();
337
-
338
- // == writeFile
339
-
340
- const writeFile = (path, data, options) => Effect.async((resume, signal) => {
341
- try {
342
- NFS.writeFile(path, data, {
343
- signal,
344
- flag: options?.flag,
345
- mode: options?.mode
346
- }, err => {
347
- if (err) {
348
- resume(Effect.fail(handleErrnoException("FileSystem", "writeFile")(err, [path])));
349
- } else {
350
- resume(Effect.unit);
351
- }
352
- });
353
- } catch (err) {
354
- resume(Effect.fail(handleBadArgument("writeFile")(err)));
355
- }
356
- });
357
- const fileSystemImpl = /*#__PURE__*/FileSystem$1.make({
358
- access,
359
- chmod,
360
- chown,
361
- copy,
362
- copyFile,
363
- link,
364
- makeDirectory,
365
- makeTempDirectory,
366
- makeTempDirectoryScoped,
367
- makeTempFile,
368
- makeTempFileScoped,
369
- open,
370
- readDirectory,
371
- readFile,
372
- readLink,
373
- realPath,
374
- remove,
375
- rename,
376
- stat,
377
- symlink,
378
- truncate,
379
- utimes,
380
- writeFile
381
- });
382
-
383
- /** @internal */
384
- const layer$1 = /*#__PURE__*/Layer.succeed(FileSystem$1.FileSystem, fileSystemImpl);
385
-
386
- /**
387
- * @since 1.0.0
388
- */
389
-
390
- /**
391
- * @since 1.0.0
392
- * @category layer
393
- */
394
- const layer = layer$1;
395
-
396
- var FileSystem = /*#__PURE__*/Object.freeze({
397
- __proto__: null,
398
- layer: layer,
399
- FileSystem: FileSystem$2,
400
- Size: Size
401
- });
402
-
403
- export { FileSystem as F, layer as l };