| 1 | /** |
| 2 | * Aggregate Bun platform services layer. |
| 3 | * |
| 4 | * This module defines the `BunServices` union and a single `layer` that |
| 5 | * provides Bun-backed child process spawning, crypto, filesystem, path, stdio, |
| 6 | * and terminal services. Use the layer when a Bun program wants the standard |
| 7 | * platform services from one place. |
| 8 | * |
| 9 | * @since 4.0.0 |
| 10 | */ |
| 11 | import type { Crypto } from "effect/Crypto" |
| 12 | import type { FileSystem } from "effect/FileSystem" |
| 13 | import * as Layer from "effect/Layer" |
| 14 | import type { Path } from "effect/Path" |
| 15 | import type { ChildProcessSpawner } from "effect/process/ChildProcessSpawner" |
| 16 | import type { Stdio } from "effect/Stdio" |
| 17 | import type { Terminal } from "effect/Terminal" |
| 18 | import * as BunChildProcessSpawner from "./BunChildProcessSpawner.ts" |
| 19 | import * as BunCrypto from "./BunCrypto.ts" |
| 20 | import * as BunFileSystem from "./BunFileSystem.ts" |
| 21 | import * as BunPath from "./BunPath.ts" |
| 22 | import * as BunStdio from "./BunStdio.ts" |
| 23 | import * as BunTerminal from "./BunTerminal.ts" |
| 24 | |
| 25 | /** |
| 26 | * The union of core services provided by the Bun platform layer, including child |
| 27 | * process spawning, filesystem, path, stdio, and terminal services. |
| 28 | * |
| 29 | * @category models |
| 30 | * @since 4.0.0 |
| 31 | */ |
| 32 | export type BunServices = ChildProcessSpawner | Crypto | FileSystem | Path | Terminal | Stdio |
| 33 | |
| 34 | /** |
| 35 | * Provides the default Bun implementations for child process spawning, |
| 36 | * filesystem, path, stdio, and terminal services. |
| 37 | * |
| 38 | * @category layers |
| 39 | * @since 4.0.0 |
| 40 | */ |
| 41 | export const layer: Layer.Layer<BunServices> = BunChildProcessSpawner.layer.pipe( |
| 42 | Layer.provideMerge(Layer.mergeAll( |
| 43 | BunFileSystem.layer, |
| 44 | BunCrypto.layer, |
| 45 | BunPath.layer, |
| 46 | BunStdio.layer, |
| 47 | BunTerminal.layer |
| 48 | )) |
| 49 | ) |