vde-open 0.0.0 → 0.1.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.
package/dist/daemon.js ADDED
@@ -0,0 +1,34 @@
1
+ import { k as version, t as startDaemon, w as currentPathEnvironment } from "./main-lxBamyBU.js";
2
+ import { E as isVdeError } from "./search-index-C0szMSlZ.js";
3
+ //#region src/daemon.ts
4
+ function notifyParent(message) {
5
+ if (!process.send) return;
6
+ process.send(message, () => {
7
+ if (process.connected) process.disconnect();
8
+ });
9
+ }
10
+ try {
11
+ const daemon = await startDaemon({
12
+ environment: currentPathEnvironment(),
13
+ version
14
+ });
15
+ notifyParent({
16
+ type: "ready",
17
+ daemonId: daemon.daemonId
18
+ });
19
+ const shutdown = (signal) => void daemon.stop(signal);
20
+ process.on("SIGINT", () => shutdown("SIGINT"));
21
+ process.on("SIGTERM", () => shutdown("SIGTERM"));
22
+ await daemon.stopped;
23
+ process.exitCode = 0;
24
+ } catch (error) {
25
+ notifyParent({
26
+ type: "error",
27
+ code: isVdeError(error) ? error.code : "E_DAEMON_START_FAILED",
28
+ message: isVdeError(error) ? error.message : "The daemon could not be started.",
29
+ details: isVdeError(error) ? error.details : {}
30
+ });
31
+ process.exitCode = 1;
32
+ }
33
+ //#endregion
34
+ export {};
@@ -0,0 +1,12 @@
1
+ import { getHeapStatistics, setFlagsFromString } from "node:v8";
2
+ import { runInNewContext } from "node:vm";
3
+ //#region src/diagnostics/heap.ts
4
+ function measureHeap(collectGarbage) {
5
+ if (collectGarbage) {
6
+ setFlagsFromString("--expose-gc");
7
+ runInNewContext("gc")();
8
+ }
9
+ return getHeapStatistics().used_heap_size;
10
+ }
11
+ //#endregion
12
+ export { measureHeap as t };