rivetkit 2.0.24-rc.1 → 2.0.25-rc.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/schemas/actor-persist/v1.ts +6 -0
- package/dist/schemas/actor-persist/v2.ts +9 -3
- package/dist/schemas/actor-persist/v3.ts +280 -0
- package/dist/schemas/client-protocol/v1.ts +6 -0
- package/dist/schemas/client-protocol/v2.ts +438 -0
- package/dist/schemas/file-system-driver/v1.ts +6 -0
- package/dist/schemas/file-system-driver/v2.ts +142 -0
- package/dist/tsup/actor/errors.cjs +2 -4
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +7 -10
- package/dist/tsup/actor/errors.d.ts +7 -10
- package/dist/tsup/actor/errors.js +9 -11
- package/dist/tsup/{actor-router-consts-B3Lu87yJ.d.cts → actor-router-consts-DzI2szci.d.cts} +5 -9
- package/dist/tsup/{actor-router-consts-B3Lu87yJ.d.ts → actor-router-consts-DzI2szci.d.ts} +5 -9
- package/dist/tsup/{chunk-ZTH3KYFH.cjs → chunk-3FG5OJ3G.cjs} +3 -3
- package/dist/tsup/{chunk-ZTH3KYFH.cjs.map → chunk-3FG5OJ3G.cjs.map} +1 -1
- package/dist/tsup/{chunk-BLK27ES3.js → chunk-6JN6W6G3.js} +44 -56
- package/dist/tsup/chunk-6JN6W6G3.js.map +1 -0
- package/dist/tsup/chunk-7IBNNGQ2.js +514 -0
- package/dist/tsup/chunk-7IBNNGQ2.js.map +1 -0
- package/dist/tsup/{chunk-36JJ4IQB.cjs → chunk-AZATXPR4.cjs} +4 -8
- package/dist/tsup/chunk-AZATXPR4.cjs.map +1 -0
- package/dist/tsup/chunk-B7MENRD5.cjs +5694 -0
- package/dist/tsup/chunk-B7MENRD5.cjs.map +1 -0
- package/dist/tsup/{chunk-BOMZS2TJ.js → chunk-BBVFDEYD.js} +9 -9
- package/dist/tsup/chunk-BBVFDEYD.js.map +1 -0
- package/dist/tsup/{chunk-KSRXX3Z4.cjs → chunk-D6762AOA.cjs} +20 -25
- package/dist/tsup/chunk-D6762AOA.cjs.map +1 -0
- package/dist/tsup/{chunk-2JYPS5YM.cjs → chunk-E63WZNMR.cjs} +6 -6
- package/dist/tsup/chunk-E63WZNMR.cjs.map +1 -0
- package/dist/tsup/{chunk-YBG6R7LX.js → chunk-EDGN4OC7.js} +3 -7
- package/dist/tsup/chunk-EDGN4OC7.js.map +1 -0
- package/dist/tsup/{chunk-BYMKMOBS.js → chunk-FLOQ3UWM.js} +1844 -1681
- package/dist/tsup/chunk-FLOQ3UWM.js.map +1 -0
- package/dist/tsup/{chunk-7L65NNWP.cjs → chunk-H7GV5DIW.cjs} +187 -185
- package/dist/tsup/chunk-H7GV5DIW.cjs.map +1 -0
- package/dist/tsup/{chunk-227FEWMB.js → chunk-HZYZ7JSF.js} +3322 -2251
- package/dist/tsup/chunk-HZYZ7JSF.js.map +1 -0
- package/dist/tsup/{chunk-FX7TWFQR.js → chunk-IDJK7ILQ.js} +2 -6
- package/dist/tsup/chunk-IDJK7ILQ.js.map +1 -0
- package/dist/tsup/{chunk-VHGY7PU5.cjs → chunk-ILFXA4AL.cjs} +1900 -1737
- package/dist/tsup/chunk-ILFXA4AL.cjs.map +1 -0
- package/dist/tsup/chunk-MV6M3FDL.cjs +514 -0
- package/dist/tsup/chunk-MV6M3FDL.cjs.map +1 -0
- package/dist/tsup/{chunk-PLUN2NQT.js → chunk-NWBKMCWC.js} +189 -187
- package/dist/tsup/chunk-NWBKMCWC.js.map +1 -0
- package/dist/tsup/{chunk-CD33GT6Z.js → chunk-QIHBDXTO.js} +2 -2
- package/dist/tsup/{chunk-G64QUEDJ.js → chunk-W6RDS6NW.js} +23 -28
- package/dist/tsup/chunk-W6RDS6NW.js.map +1 -0
- package/dist/tsup/{chunk-INNFK746.cjs → chunk-WQU4M4ZC.cjs} +10 -14
- package/dist/tsup/chunk-WQU4M4ZC.cjs.map +1 -0
- package/dist/tsup/{chunk-SHVX2QUR.cjs → chunk-XKZA47XS.cjs} +17 -17
- package/dist/tsup/chunk-XKZA47XS.cjs.map +1 -0
- package/dist/tsup/{chunk-HHFKKVLR.cjs → chunk-YHWIOWVA.cjs} +45 -57
- package/dist/tsup/chunk-YHWIOWVA.cjs.map +1 -0
- package/dist/tsup/{chunk-YBHYXIP6.js → chunk-YVL6IRUM.js} +3 -3
- package/dist/tsup/chunk-YVL6IRUM.js.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -7
- package/dist/tsup/client/mod.d.ts +5 -7
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{conn-B3Vhbgnd.d.ts → config-BRDYDraU.d.cts} +1119 -1047
- package/dist/tsup/{conn-DJWL3nGx.d.cts → config-Bo-blHpJ.d.ts} +1119 -1047
- package/dist/tsup/driver-helpers/mod.cjs +5 -13
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +11 -9
- package/dist/tsup/driver-helpers/mod.d.ts +11 -9
- package/dist/tsup/driver-helpers/mod.js +14 -22
- package/dist/tsup/driver-test-suite/mod.cjs +474 -303
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +6 -9
- package/dist/tsup/driver-test-suite/mod.d.ts +6 -9
- package/dist/tsup/driver-test-suite/mod.js +1085 -914
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.d.cts +5 -7
- package/dist/tsup/inspector/mod.d.ts +5 -7
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +10 -16
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +23 -25
- package/dist/tsup/mod.d.ts +23 -25
- package/dist/tsup/mod.js +17 -23
- package/dist/tsup/test/mod.cjs +11 -11
- package/dist/tsup/test/mod.d.cts +4 -6
- package/dist/tsup/test/mod.d.ts +4 -6
- package/dist/tsup/test/mod.js +10 -10
- package/dist/tsup/utils.cjs +3 -5
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +1 -2
- package/dist/tsup/utils.d.ts +1 -2
- package/dist/tsup/utils.js +2 -4
- package/package.json +13 -6
- package/src/actor/config.ts +56 -44
- package/src/actor/conn/driver.ts +61 -0
- package/src/actor/conn/drivers/http.ts +17 -0
- package/src/actor/conn/drivers/raw-request.ts +24 -0
- package/src/actor/conn/drivers/raw-websocket.ts +65 -0
- package/src/actor/conn/drivers/websocket.ts +129 -0
- package/src/actor/conn/mod.ts +232 -0
- package/src/actor/conn/persisted.ts +81 -0
- package/src/actor/conn/state-manager.ts +196 -0
- package/src/actor/contexts/action.ts +23 -0
- package/src/actor/{context.ts → contexts/actor.ts} +19 -8
- package/src/actor/contexts/conn-init.ts +31 -0
- package/src/actor/contexts/conn.ts +48 -0
- package/src/actor/contexts/create-conn-state.ts +13 -0
- package/src/actor/contexts/on-before-connect.ts +13 -0
- package/src/actor/contexts/on-connect.ts +22 -0
- package/src/actor/contexts/request.ts +48 -0
- package/src/actor/contexts/websocket.ts +48 -0
- package/src/actor/definition.ts +3 -3
- package/src/actor/driver.ts +36 -5
- package/src/actor/errors.ts +19 -24
- package/src/actor/instance/connection-manager.ts +465 -0
- package/src/actor/instance/event-manager.ts +292 -0
- package/src/actor/instance/kv.ts +15 -0
- package/src/actor/instance/mod.ts +1107 -0
- package/src/actor/instance/persisted.ts +67 -0
- package/src/actor/instance/schedule-manager.ts +349 -0
- package/src/actor/instance/state-manager.ts +502 -0
- package/src/actor/mod.ts +13 -16
- package/src/actor/protocol/old.ts +131 -43
- package/src/actor/protocol/serde.ts +19 -4
- package/src/actor/router-endpoints.ts +61 -586
- package/src/actor/router-websocket-endpoints.ts +408 -0
- package/src/actor/router.ts +63 -197
- package/src/actor/schedule.ts +1 -1
- package/src/client/actor-conn.ts +183 -249
- package/src/client/actor-handle.ts +29 -6
- package/src/client/client.ts +0 -4
- package/src/client/config.ts +1 -4
- package/src/client/mod.ts +0 -1
- package/src/client/raw-utils.ts +3 -3
- package/src/client/utils.ts +85 -39
- package/src/common/actor-router-consts.ts +5 -12
- package/src/common/{inline-websocket-adapter2.ts → inline-websocket-adapter.ts} +26 -48
- package/src/common/log.ts +1 -1
- package/src/common/router.ts +28 -17
- package/src/common/utils.ts +2 -0
- package/src/driver-helpers/mod.ts +7 -10
- package/src/driver-helpers/utils.ts +18 -9
- package/src/driver-test-suite/mod.ts +26 -50
- package/src/driver-test-suite/test-inline-client-driver.ts +27 -51
- package/src/driver-test-suite/tests/actor-conn-hibernation.ts +150 -0
- package/src/driver-test-suite/tests/actor-conn-state.ts +1 -4
- package/src/driver-test-suite/tests/actor-conn.ts +5 -9
- package/src/driver-test-suite/tests/actor-destroy.ts +294 -0
- package/src/driver-test-suite/tests/actor-driver.ts +0 -7
- package/src/driver-test-suite/tests/actor-handle.ts +12 -12
- package/src/driver-test-suite/tests/actor-metadata.ts +1 -1
- package/src/driver-test-suite/tests/manager-driver.ts +1 -1
- package/src/driver-test-suite/tests/raw-http-direct-registry.ts +8 -8
- package/src/driver-test-suite/tests/raw-http-request-properties.ts +6 -5
- package/src/driver-test-suite/tests/raw-http.ts +5 -5
- package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +7 -7
- package/src/driver-test-suite/tests/request-access.ts +4 -4
- package/src/driver-test-suite/utils.ts +6 -10
- package/src/drivers/engine/actor-driver.ts +614 -424
- package/src/drivers/engine/mod.ts +0 -1
- package/src/drivers/file-system/actor.ts +24 -12
- package/src/drivers/file-system/global-state.ts +427 -37
- package/src/drivers/file-system/manager.ts +71 -83
- package/src/drivers/file-system/mod.ts +3 -0
- package/src/drivers/file-system/utils.ts +18 -8
- package/src/engine-process/mod.ts +38 -38
- package/src/inspector/utils.ts +7 -5
- package/src/manager/driver.ts +11 -4
- package/src/manager/gateway.ts +4 -29
- package/src/manager/protocol/mod.ts +0 -2
- package/src/manager/protocol/query.ts +0 -4
- package/src/manager/router.ts +67 -64
- package/src/manager-api/actors.ts +13 -0
- package/src/mod.ts +1 -3
- package/src/registry/mod.ts +20 -20
- package/src/registry/serve.ts +9 -14
- package/src/remote-manager-driver/actor-websocket-client.ts +1 -16
- package/src/remote-manager-driver/api-endpoints.ts +13 -1
- package/src/remote-manager-driver/api-utils.ts +8 -0
- package/src/remote-manager-driver/metadata.ts +58 -0
- package/src/remote-manager-driver/mod.ts +47 -62
- package/src/remote-manager-driver/ws-proxy.ts +1 -1
- package/src/schemas/actor-persist/mod.ts +1 -1
- package/src/schemas/actor-persist/versioned.ts +56 -31
- package/src/schemas/client-protocol/mod.ts +1 -1
- package/src/schemas/client-protocol/versioned.ts +41 -21
- package/src/schemas/client-protocol-zod/mod.ts +103 -0
- package/src/schemas/file-system-driver/mod.ts +1 -1
- package/src/schemas/file-system-driver/versioned.ts +42 -19
- package/src/serde.ts +33 -11
- package/src/test/mod.ts +7 -3
- package/src/utils/node.ts +173 -0
- package/src/utils.ts +0 -4
- package/dist/tsup/chunk-227FEWMB.js.map +0 -1
- package/dist/tsup/chunk-2JYPS5YM.cjs.map +0 -1
- package/dist/tsup/chunk-36JJ4IQB.cjs.map +0 -1
- package/dist/tsup/chunk-7L65NNWP.cjs.map +0 -1
- package/dist/tsup/chunk-BLK27ES3.js.map +0 -1
- package/dist/tsup/chunk-BOMZS2TJ.js.map +0 -1
- package/dist/tsup/chunk-BYMKMOBS.js.map +0 -1
- package/dist/tsup/chunk-FX7TWFQR.js.map +0 -1
- package/dist/tsup/chunk-G64QUEDJ.js.map +0 -1
- package/dist/tsup/chunk-HHFKKVLR.cjs.map +0 -1
- package/dist/tsup/chunk-INNFK746.cjs.map +0 -1
- package/dist/tsup/chunk-KSRXX3Z4.cjs.map +0 -1
- package/dist/tsup/chunk-O44LFKSB.cjs +0 -4623
- package/dist/tsup/chunk-O44LFKSB.cjs.map +0 -1
- package/dist/tsup/chunk-PLUN2NQT.js.map +0 -1
- package/dist/tsup/chunk-S4UJG7ZE.js +0 -1119
- package/dist/tsup/chunk-S4UJG7ZE.js.map +0 -1
- package/dist/tsup/chunk-SHVX2QUR.cjs.map +0 -1
- package/dist/tsup/chunk-VFB23BYZ.cjs +0 -1119
- package/dist/tsup/chunk-VFB23BYZ.cjs.map +0 -1
- package/dist/tsup/chunk-VHGY7PU5.cjs.map +0 -1
- package/dist/tsup/chunk-YBG6R7LX.js.map +0 -1
- package/dist/tsup/chunk-YBHYXIP6.js.map +0 -1
- package/src/actor/action.ts +0 -178
- package/src/actor/conn-drivers.ts +0 -216
- package/src/actor/conn-socket.ts +0 -8
- package/src/actor/conn.ts +0 -272
- package/src/actor/instance.ts +0 -2336
- package/src/actor/persisted.ts +0 -49
- package/src/actor/unstable-react.ts +0 -110
- package/src/driver-test-suite/tests/actor-reconnect.ts +0 -170
- package/src/drivers/engine/kv.ts +0 -3
- package/src/manager/hono-websocket-adapter.ts +0 -393
- /package/dist/tsup/{chunk-CD33GT6Z.js.map → chunk-QIHBDXTO.js.map} +0 -0
package/src/test/mod.ts
CHANGED
|
@@ -17,7 +17,10 @@ import { RunnerConfigSchema } from "@/registry/run-config";
|
|
|
17
17
|
import { ConfigSchema, type InputConfig } from "./config";
|
|
18
18
|
import { logger } from "./log";
|
|
19
19
|
|
|
20
|
-
function serve(
|
|
20
|
+
async function serve(
|
|
21
|
+
registry: Registry<any>,
|
|
22
|
+
inputConfig?: InputConfig,
|
|
23
|
+
): Promise<ServerType> {
|
|
21
24
|
// Configure default configuration
|
|
22
25
|
inputConfig ??= {};
|
|
23
26
|
|
|
@@ -30,7 +33,8 @@ function serve(registry: Registry<any>, inputConfig?: InputConfig): ServerType {
|
|
|
30
33
|
|
|
31
34
|
// Create router
|
|
32
35
|
const runConfig = RunnerConfigSchema.parse(inputConfig);
|
|
33
|
-
const driver =
|
|
36
|
+
const driver =
|
|
37
|
+
inputConfig.driver ?? (await createFileSystemOrMemoryDriver(false));
|
|
34
38
|
const managerDriver = driver.manager(registry.config, config);
|
|
35
39
|
const client = createClientWithDriver(
|
|
36
40
|
managerDriver,
|
|
@@ -92,7 +96,7 @@ export async function setupTest<A extends Registry<any>>(
|
|
|
92
96
|
|
|
93
97
|
// Start server with a random port
|
|
94
98
|
const port = await getPort();
|
|
95
|
-
const server = serve(registry, { port });
|
|
99
|
+
const server = await serve(registry, { port });
|
|
96
100
|
c.onTestFinished(
|
|
97
101
|
async () =>
|
|
98
102
|
await new Promise((resolve) => server.close(() => resolve())),
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
// Global variables for Node.js modules.
|
|
4
|
+
//
|
|
5
|
+
// We use synchronous require() instead of async import() for Node.js module loading because:
|
|
6
|
+
// 1. These modules are only needed in Node.js environments (not browser/edge)
|
|
7
|
+
// 2. registry.start() cannot be async and needs immediate access to Node modules
|
|
8
|
+
// 3. The setup process must be synchronous to avoid breaking the API
|
|
9
|
+
//
|
|
10
|
+
// Biome only allows imports of node modules in this file in order to ensure
|
|
11
|
+
// we're forcing the use of dynamic imports.
|
|
12
|
+
let nodeCrypto: typeof import("node:crypto") | undefined;
|
|
13
|
+
let nodeFsSync: typeof import("node:fs") | undefined;
|
|
14
|
+
let nodeFs: typeof import("node:fs/promises") | undefined;
|
|
15
|
+
let nodePath: typeof import("node:path") | undefined;
|
|
16
|
+
let nodeOs: typeof import("node:os") | undefined;
|
|
17
|
+
let nodeChildProcess: typeof import("node:child_process") | undefined;
|
|
18
|
+
let nodeStream: typeof import("node:stream/promises") | undefined;
|
|
19
|
+
|
|
20
|
+
let hasImportedDependencies = false;
|
|
21
|
+
|
|
22
|
+
// Helper to get a require function that works in both CommonJS and ESM.
|
|
23
|
+
// We use require() instead of await import() because registry.start() cannot
|
|
24
|
+
// be async and needs immediate access to Node.js modules during setup.
|
|
25
|
+
function getRequireFn() {
|
|
26
|
+
// TODO: This causes issues in tsup
|
|
27
|
+
// CommonJS context - use global require
|
|
28
|
+
// if (typeof require !== "undefined") {
|
|
29
|
+
// console.log("existing require");
|
|
30
|
+
// return require;
|
|
31
|
+
// }
|
|
32
|
+
|
|
33
|
+
// ESM context - use createRequire with import.meta.url
|
|
34
|
+
// @ts-ignore - import.meta.url is available in ESM
|
|
35
|
+
return createRequire(import.meta.url);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Dynamically imports all required Node.js dependencies. We do this early in a
|
|
40
|
+
* single function call in order to surface errors early.
|
|
41
|
+
*
|
|
42
|
+
* This function is idempotent and will only import once.
|
|
43
|
+
*
|
|
44
|
+
* @throws Error if Node.js modules are not available (e.g., in browser/edge environments)
|
|
45
|
+
*/
|
|
46
|
+
export function importNodeDependencies(): void {
|
|
47
|
+
// Check if already loaded
|
|
48
|
+
if (hasImportedDependencies) return;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
// Get a require function that works in both CommonJS and ESM
|
|
52
|
+
const requireFn = getRequireFn();
|
|
53
|
+
|
|
54
|
+
// Use requireFn with webpack ignore comment to prevent bundling
|
|
55
|
+
// @ts-ignore - dynamic require usage
|
|
56
|
+
nodeCrypto = requireFn(/* webpackIgnore: true */ "node:crypto");
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
nodeFsSync = requireFn(/* webpackIgnore: true */ "node:fs");
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
nodeFs = requireFn(/* webpackIgnore: true */ "node:fs/promises");
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
nodePath = requireFn(/* webpackIgnore: true */ "node:path");
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
nodeOs = requireFn(/* webpackIgnore: true */ "node:os");
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
nodeChildProcess = requireFn(
|
|
67
|
+
/* webpackIgnore: true */ "node:child_process",
|
|
68
|
+
);
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
nodeStream = requireFn(
|
|
71
|
+
/* webpackIgnore: true */ "node:stream/promises",
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
hasImportedDependencies = true;
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.warn(
|
|
77
|
+
"Node.js modules not available, file system driver will not work",
|
|
78
|
+
err,
|
|
79
|
+
);
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Gets the Node.js crypto module.
|
|
86
|
+
* @throws Error if crypto module is not loaded
|
|
87
|
+
*/
|
|
88
|
+
export function getNodeCrypto(): typeof import("node:crypto") {
|
|
89
|
+
if (!nodeCrypto) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
"Node crypto module not loaded. Ensure importNodeDependencies() has been called.",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
return nodeCrypto;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Gets the Node.js fs module.
|
|
99
|
+
* @throws Error if fs module is not loaded
|
|
100
|
+
*/
|
|
101
|
+
export function getNodeFsSync(): typeof import("node:fs") {
|
|
102
|
+
if (!nodeFsSync) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
"Node fs module not loaded. Ensure importNodeDependencies() has been called.",
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
return nodeFsSync;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Gets the Node.js fs/promises module.
|
|
112
|
+
* @throws Error if fs/promises module is not loaded
|
|
113
|
+
*/
|
|
114
|
+
export function getNodeFs(): typeof import("node:fs/promises") {
|
|
115
|
+
if (!nodeFs) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
"Node fs/promises module not loaded. Ensure importNodeDependencies() has been called.",
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return nodeFs;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Gets the Node.js path module.
|
|
125
|
+
* @throws Error if path module is not loaded
|
|
126
|
+
*/
|
|
127
|
+
export function getNodePath(): typeof import("node:path") {
|
|
128
|
+
if (!nodePath) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
"Node path module not loaded. Ensure importNodeDependencies() has been called.",
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
return nodePath;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Gets the Node.js os module.
|
|
138
|
+
* @throws Error if os module is not loaded
|
|
139
|
+
*/
|
|
140
|
+
export function getNodeOs(): typeof import("node:os") {
|
|
141
|
+
if (!nodeOs) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
"Node os module not loaded. Ensure importNodeDependencies() has been called.",
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
return nodeOs;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Gets the Node.js child_process module.
|
|
151
|
+
* @throws Error if child_process module is not loaded
|
|
152
|
+
*/
|
|
153
|
+
export function getNodeChildProcess(): typeof import("node:child_process") {
|
|
154
|
+
if (!nodeChildProcess) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
"Node child_process module not loaded. Ensure importNodeDependencies() has been called.",
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return nodeChildProcess;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Gets the Node.js stream/promises module.
|
|
164
|
+
* @throws Error if stream/promises module is not loaded
|
|
165
|
+
*/
|
|
166
|
+
export function getNodeStream(): typeof import("node:stream/promises") {
|
|
167
|
+
if (!nodeStream) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
"Node stream/promises module not loaded. Ensure importNodeDependencies() has been called.",
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
return nodeStream;
|
|
173
|
+
}
|