@effect/platform-node-shared 0.3.29 → 0.4.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.
- package/dist/cjs/NodeFileSystem/ParcelWatcher.js +44 -0
- package/dist/cjs/NodeFileSystem/ParcelWatcher.js.map +1 -0
- package/dist/cjs/NodeSocket.js +3 -3
- package/dist/cjs/NodeSocket.js.map +1 -1
- package/dist/cjs/internal/commandExecutor.js +5 -5
- package/dist/cjs/internal/commandExecutor.js.map +1 -1
- package/dist/cjs/internal/fileSystem/parcelWatcher.js +92 -0
- package/dist/cjs/internal/fileSystem/parcelWatcher.js.map +1 -0
- package/dist/cjs/internal/fileSystem.js +9 -54
- package/dist/cjs/internal/fileSystem.js.map +1 -1
- package/dist/cjs/internal/runtime.js +1 -1
- package/dist/cjs/internal/runtime.js.map +1 -1
- package/dist/cjs/internal/sink.js +1 -1
- package/dist/cjs/internal/sink.js.map +1 -1
- package/dist/cjs/internal/stream.js +10 -10
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/terminal.js +1 -1
- package/dist/cjs/internal/terminal.js.map +1 -1
- package/dist/dts/NodeFileSystem/ParcelWatcher.d.ts +13 -0
- package/dist/dts/NodeFileSystem/ParcelWatcher.d.ts.map +1 -0
- package/dist/dts/NodeSocket.d.ts.map +1 -1
- package/dist/dts/internal/fileSystem/parcelWatcher.d.ts +4 -0
- package/dist/dts/internal/fileSystem/parcelWatcher.d.ts.map +1 -0
- package/dist/esm/NodeFileSystem/ParcelWatcher.js +12 -0
- package/dist/esm/NodeFileSystem/ParcelWatcher.js.map +1 -0
- package/dist/esm/NodeSocket.js +3 -3
- package/dist/esm/NodeSocket.js.map +1 -1
- package/dist/esm/internal/commandExecutor.js +5 -5
- package/dist/esm/internal/commandExecutor.js.map +1 -1
- package/dist/esm/internal/fileSystem/parcelWatcher.js +61 -0
- package/dist/esm/internal/fileSystem/parcelWatcher.js.map +1 -0
- package/dist/esm/internal/fileSystem.js +9 -54
- package/dist/esm/internal/fileSystem.js.map +1 -1
- package/dist/esm/internal/runtime.js +1 -1
- package/dist/esm/internal/runtime.js.map +1 -1
- package/dist/esm/internal/sink.js +1 -1
- package/dist/esm/internal/sink.js.map +1 -1
- package/dist/esm/internal/stream.js +10 -10
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/terminal.js +1 -1
- package/dist/esm/internal/terminal.js.map +1 -1
- package/package.json +3 -3
- package/src/NodeFileSystem/ParcelWatcher.ts +15 -0
- package/src/NodeSocket.ts +3 -3
- package/src/internal/commandExecutor.ts +5 -5
- package/src/internal/fileSystem/parcelWatcher.ts +62 -0
- package/src/internal/fileSystem.ts +39 -82
- package/src/internal/runtime.ts +1 -1
- package/src/internal/sink.ts +1 -1
- package/src/internal/stream.ts +10 -10
- package/src/internal/terminal.ts +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { effectify } from "@effect/platform/Effectify"
|
|
2
2
|
import * as Error from "@effect/platform/Error"
|
|
3
3
|
import * as FileSystem from "@effect/platform/FileSystem"
|
|
4
|
-
import type * as
|
|
5
|
-
import * as Chunk from "effect/Chunk"
|
|
4
|
+
import type * as Context from "effect/Context"
|
|
6
5
|
import * as Effect from "effect/Effect"
|
|
7
6
|
import { pipe } from "effect/Function"
|
|
8
7
|
import * as Layer from "effect/Layer"
|
|
@@ -349,7 +348,7 @@ const makeFile = (() => {
|
|
|
349
348
|
this.position = this.position + BigInt(bytesWritten)
|
|
350
349
|
}
|
|
351
350
|
|
|
352
|
-
return bytesWritten < buffer.length ? this.writeAllChunk(buffer.subarray(bytesWritten)) : Effect.
|
|
351
|
+
return bytesWritten < buffer.length ? this.writeAllChunk(buffer.subarray(bytesWritten)) : Effect.void
|
|
353
352
|
}
|
|
354
353
|
)
|
|
355
354
|
}
|
|
@@ -524,49 +523,6 @@ const utimes = (() => {
|
|
|
524
523
|
|
|
525
524
|
// == watch
|
|
526
525
|
|
|
527
|
-
const watchParcel = (Watcher: typeof ParcelWatcher, path: string) =>
|
|
528
|
-
Stream.asyncScoped<FileSystem.WatchEvent, Error.PlatformError>((emit) =>
|
|
529
|
-
Effect.acquireRelease(
|
|
530
|
-
Effect.tryPromise({
|
|
531
|
-
try: () =>
|
|
532
|
-
Watcher.subscribe(path, (error, events) => {
|
|
533
|
-
if (error) {
|
|
534
|
-
emit.fail(Error.SystemError({
|
|
535
|
-
reason: "Unknown",
|
|
536
|
-
module: "FileSystem",
|
|
537
|
-
method: "watch",
|
|
538
|
-
pathOrDescriptor: path,
|
|
539
|
-
message: error.message
|
|
540
|
-
}))
|
|
541
|
-
} else {
|
|
542
|
-
emit.chunk(Chunk.unsafeFromArray(events.map((event) => {
|
|
543
|
-
switch (event.type) {
|
|
544
|
-
case "create": {
|
|
545
|
-
return FileSystem.WatchEventCreate({ path: event.path })
|
|
546
|
-
}
|
|
547
|
-
case "update": {
|
|
548
|
-
return FileSystem.WatchEventUpdate({ path: event.path })
|
|
549
|
-
}
|
|
550
|
-
case "delete": {
|
|
551
|
-
return FileSystem.WatchEventRemove({ path: event.path })
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
})))
|
|
555
|
-
}
|
|
556
|
-
}),
|
|
557
|
-
catch: (error) =>
|
|
558
|
-
Error.SystemError({
|
|
559
|
-
reason: "Unknown",
|
|
560
|
-
module: "FileSystem",
|
|
561
|
-
method: "watch",
|
|
562
|
-
pathOrDescriptor: path,
|
|
563
|
-
message: (error as Error).message
|
|
564
|
-
})
|
|
565
|
-
}),
|
|
566
|
-
(sub) => Effect.promise(() => sub.unsubscribe())
|
|
567
|
-
)
|
|
568
|
-
)
|
|
569
|
-
|
|
570
526
|
const watchNode = (path: string) =>
|
|
571
527
|
Stream.asyncScoped<FileSystem.WatchEvent, Error.PlatformError>((emit) =>
|
|
572
528
|
Effect.acquireRelease(
|
|
@@ -605,15 +561,13 @@ const watchNode = (path: string) =>
|
|
|
605
561
|
)
|
|
606
562
|
)
|
|
607
563
|
|
|
608
|
-
const watch = (path: string) =>
|
|
564
|
+
const watch = (backend: Option.Option<Context.Tag.Service<FileSystem.WatchBackend>>, path: string) =>
|
|
609
565
|
stat(path).pipe(
|
|
610
|
-
Effect.
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
}) :
|
|
616
|
-
Effect.succeed(watchNode(path))
|
|
566
|
+
Effect.map((stat) =>
|
|
567
|
+
backend.pipe(
|
|
568
|
+
Option.flatMap((_) => _.register(path, stat)),
|
|
569
|
+
Option.getOrElse(() => watchNode(path))
|
|
570
|
+
)
|
|
617
571
|
),
|
|
618
572
|
Stream.unwrap
|
|
619
573
|
)
|
|
@@ -631,7 +585,7 @@ const writeFile = (path: string, data: Uint8Array, options?: FileSystem.WriteFil
|
|
|
631
585
|
if (err) {
|
|
632
586
|
resume(Effect.fail(handleErrnoException("FileSystem", "writeFile")(err, [path])))
|
|
633
587
|
} else {
|
|
634
|
-
resume(Effect.
|
|
588
|
+
resume(Effect.void)
|
|
635
589
|
}
|
|
636
590
|
})
|
|
637
591
|
} catch (err) {
|
|
@@ -639,32 +593,35 @@ const writeFile = (path: string, data: Uint8Array, options?: FileSystem.WriteFil
|
|
|
639
593
|
}
|
|
640
594
|
})
|
|
641
595
|
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
596
|
+
const makeFileSystem = Effect.map(Effect.serviceOption(FileSystem.WatchBackend), (backend) =>
|
|
597
|
+
FileSystem.make({
|
|
598
|
+
access,
|
|
599
|
+
chmod,
|
|
600
|
+
chown,
|
|
601
|
+
copy,
|
|
602
|
+
copyFile,
|
|
603
|
+
link,
|
|
604
|
+
makeDirectory,
|
|
605
|
+
makeTempDirectory,
|
|
606
|
+
makeTempDirectoryScoped,
|
|
607
|
+
makeTempFile,
|
|
608
|
+
makeTempFileScoped,
|
|
609
|
+
open,
|
|
610
|
+
readDirectory,
|
|
611
|
+
readFile,
|
|
612
|
+
readLink,
|
|
613
|
+
realPath,
|
|
614
|
+
remove,
|
|
615
|
+
rename,
|
|
616
|
+
stat,
|
|
617
|
+
symlink,
|
|
618
|
+
truncate,
|
|
619
|
+
utimes,
|
|
620
|
+
watch(path) {
|
|
621
|
+
return watch(backend, path)
|
|
622
|
+
},
|
|
623
|
+
writeFile
|
|
624
|
+
}))
|
|
668
625
|
|
|
669
626
|
/** @internal */
|
|
670
|
-
export const layer = Layer.
|
|
627
|
+
export const layer = Layer.effect(FileSystem.FileSystem, makeFileSystem)
|
package/src/internal/runtime.ts
CHANGED
package/src/internal/sink.ts
CHANGED
package/src/internal/stream.ts
CHANGED
|
@@ -224,21 +224,21 @@ export const writeInput = <IE, A>(
|
|
|
224
224
|
writable: Writable | NodeJS.WritableStream,
|
|
225
225
|
onFailure: (cause: Cause.Cause<IE>) => Effect.Effect<void>,
|
|
226
226
|
{ encoding, endOnDone = true }: FromWritableOptions = {},
|
|
227
|
-
onDone = Effect.
|
|
227
|
+
onDone = Effect.void
|
|
228
228
|
): AsyncInput.AsyncInputProducer<IE, Chunk.Chunk<A>, unknown> => {
|
|
229
229
|
const write = writeEffect(writable, encoding)
|
|
230
230
|
const close = endOnDone
|
|
231
231
|
? Effect.async<void>((resume) => {
|
|
232
232
|
if ("closed" in writable && writable.closed) {
|
|
233
|
-
resume(Effect.
|
|
233
|
+
resume(Effect.void)
|
|
234
234
|
} else {
|
|
235
|
-
writable.once("finish", () => resume(Effect.
|
|
235
|
+
writable.once("finish", () => resume(Effect.void))
|
|
236
236
|
writable.end()
|
|
237
237
|
}
|
|
238
238
|
})
|
|
239
|
-
: Effect.
|
|
239
|
+
: Effect.void
|
|
240
240
|
return {
|
|
241
|
-
awaitRead: () => Effect.
|
|
241
|
+
awaitRead: () => Effect.void,
|
|
242
242
|
emit: write,
|
|
243
243
|
error: (cause) => Effect.zipRight(close, onFailure(cause)),
|
|
244
244
|
done: (_) => Effect.zipRight(close, onDone)
|
|
@@ -252,7 +252,7 @@ export const writeEffect = <A>(
|
|
|
252
252
|
) =>
|
|
253
253
|
(chunk: Chunk.Chunk<A>) =>
|
|
254
254
|
chunk.length === 0 ?
|
|
255
|
-
Effect.
|
|
255
|
+
Effect.void :
|
|
256
256
|
Effect.async<void>((resume) => {
|
|
257
257
|
const iterator = chunk[Symbol.iterator]()
|
|
258
258
|
let next = iterator.next()
|
|
@@ -261,7 +261,7 @@ export const writeEffect = <A>(
|
|
|
261
261
|
next = iterator.next()
|
|
262
262
|
const success = writable.write(item.value, encoding as any)
|
|
263
263
|
if (next.done) {
|
|
264
|
-
resume(Effect.
|
|
264
|
+
resume(Effect.void)
|
|
265
265
|
} else if (success) {
|
|
266
266
|
loop()
|
|
267
267
|
} else {
|
|
@@ -287,7 +287,7 @@ const readableOffer = <E>(
|
|
|
287
287
|
queue.unsafeOffer(Either.left(Exit.fail(onError(err))))
|
|
288
288
|
})
|
|
289
289
|
readable.on("end", () => {
|
|
290
|
-
queue.unsafeOffer(Either.left(Exit.
|
|
290
|
+
queue.unsafeOffer(Either.left(Exit.void))
|
|
291
291
|
})
|
|
292
292
|
if (readable.readable) {
|
|
293
293
|
queue.unsafeOffer(Either.right(void 0))
|
|
@@ -305,7 +305,7 @@ const readableTake = <E, A>(
|
|
|
305
305
|
Either.match({
|
|
306
306
|
onLeft: Exit.match({
|
|
307
307
|
onFailure: Channel.failCause,
|
|
308
|
-
onSuccess: (_) => Channel.
|
|
308
|
+
onSuccess: (_) => Channel.void
|
|
309
309
|
}),
|
|
310
310
|
onRight: (_) => Channel.flatMap(read, () => loop)
|
|
311
311
|
})
|
|
@@ -376,7 +376,7 @@ class StreamAdapter<E, R> extends Readable {
|
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
_destroy(_error: Error | null, callback: (error?: Error | null | undefined) => void): void {
|
|
379
|
-
Runtime.runFork(this.runtime)(Scope.close(this.scope, Exit.
|
|
379
|
+
Runtime.runFork(this.runtime)(Scope.close(this.scope, Exit.void)).addObserver((exit) => {
|
|
380
380
|
callback(exit._tag === "Failure" ? Cause.squash(exit.cause) as any : null)
|
|
381
381
|
})
|
|
382
382
|
}
|