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