limina 0.1.3 → 0.2.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/LICENSE.md +535 -794
- package/bin/limina.js +5 -9
- package/checker-host-process.js +49 -0
- package/chunks/dep-BOg2f5FD.js +42 -0
- package/chunks/{dep-BizOzD0V.js → dep-D63Sc9OL.js} +999 -176
- package/chunks/dep-gI8bWpox.js +1092 -0
- package/cli.js +39713 -39849
- package/flow-renderer-process.js +1 -1
- package/index.d.ts +209 -50
- package/index.js +2 -2
- package/package.json +20 -15
- package/schemas/tsconfig-schema.json +4 -1
- package/chunks/dep-BT-sPH_d.js +0 -103
- package/chunks/dep-CDo4z58I.js +0 -191
- package/chunks/dep-Tb3jeYdU.js +0 -240
package/bin/limina.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
4
5
|
import path from 'node:path';
|
|
5
6
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
7
|
|
|
7
8
|
const packageDir = path.resolve(fileURLToPath(new URL('..', import.meta.url)));
|
|
8
9
|
const distCliPath = path.join(packageDir, 'cli.js');
|
|
9
10
|
const sourceCliPath = path.join(packageDir, 'src/cli.ts');
|
|
10
|
-
const
|
|
11
|
-
const tsxCliPath =
|
|
12
|
-
[
|
|
13
|
-
path.join(packageDir, 'node_modules/.bin', tsxBinName),
|
|
14
|
-
path.join(packageDir, '../../node_modules/.bin', tsxBinName),
|
|
15
|
-
].find((candidate) => existsSync(candidate)) ?? 'tsx';
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
16
12
|
|
|
17
13
|
if (existsSync(sourceCliPath)) {
|
|
14
|
+
const tsxCliPath = require.resolve('tsx/cli');
|
|
18
15
|
const result = spawnSync(
|
|
19
|
-
|
|
20
|
-
[sourceCliPath, ...process.argv.slice(2)],
|
|
16
|
+
process.execPath,
|
|
17
|
+
[tsxCliPath, sourceCliPath, ...process.argv.slice(2)],
|
|
21
18
|
{
|
|
22
19
|
stdio: 'inherit',
|
|
23
|
-
shell: process.platform === 'win32',
|
|
24
20
|
},
|
|
25
21
|
);
|
|
26
22
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { t as spawnAndMeasure } from "./chunks/dep-BOg2f5FD.js";
|
|
2
|
+
//#region src/typecheck/host-process.ts
|
|
3
|
+
const PARENT_LIVENESS_TIMEOUT_MS = 3e4;
|
|
4
|
+
const PARENT_LIVENESS_CHECK_INTERVAL_MS = 5e3;
|
|
5
|
+
const liveCheckerChildren = /* @__PURE__ */ new Set();
|
|
6
|
+
let pendingSpawnCount = 0;
|
|
7
|
+
let lastParentSignalAt = Date.now();
|
|
8
|
+
function exitWithCheckerCleanup() {
|
|
9
|
+
for (const child of liveCheckerChildren) if (child.exitCode === null && child.signalCode === null) child.kill();
|
|
10
|
+
process.exit(0);
|
|
11
|
+
}
|
|
12
|
+
function send(message) {
|
|
13
|
+
if (typeof process.send !== "function") return;
|
|
14
|
+
try {
|
|
15
|
+
process.send(message);
|
|
16
|
+
} catch {
|
|
17
|
+
exitWithCheckerCleanup();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
process.on("message", (request) => {
|
|
21
|
+
lastParentSignalAt = Date.now();
|
|
22
|
+
if (request.type !== "spawn") return;
|
|
23
|
+
if (process.env.LIMINA_CHECKER_HOST_TEST_CRASH === "1") process.exit(1);
|
|
24
|
+
pendingSpawnCount += 1;
|
|
25
|
+
spawnAndMeasure(request, { onChild: (child) => {
|
|
26
|
+
liveCheckerChildren.add(child);
|
|
27
|
+
child.on("close", () => {
|
|
28
|
+
liveCheckerChildren.delete(child);
|
|
29
|
+
});
|
|
30
|
+
} }).then((measurement) => {
|
|
31
|
+
pendingSpawnCount -= 1;
|
|
32
|
+
send({
|
|
33
|
+
durationMs: measurement.durationMs,
|
|
34
|
+
...measurement.error ? { errorMessage: measurement.error.message } : {},
|
|
35
|
+
id: request.id,
|
|
36
|
+
status: measurement.status,
|
|
37
|
+
type: "result"
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
process.on("disconnect", () => {
|
|
42
|
+
exitWithCheckerCleanup();
|
|
43
|
+
});
|
|
44
|
+
setInterval(() => {
|
|
45
|
+
if (pendingSpawnCount === 0 && Date.now() - lastParentSignalAt > PARENT_LIVENESS_TIMEOUT_MS) exitWithCheckerCleanup();
|
|
46
|
+
}, PARENT_LIVENESS_CHECK_INTERVAL_MS);
|
|
47
|
+
send({ type: "ready" });
|
|
48
|
+
//#endregion
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
//#region src/typecheck/host-protocol.ts
|
|
3
|
+
/**
|
|
4
|
+
* Spawns one checker command and measures its lifetime from spawn until the
|
|
5
|
+
* close/error event. The measurement is only accurate when the surrounding
|
|
6
|
+
* event loop stays responsive while the child runs, so the checker host
|
|
7
|
+
* process is the primary caller; the parent CLI process uses it directly only
|
|
8
|
+
* as the degraded in-process fallback.
|
|
9
|
+
*/
|
|
10
|
+
function spawnAndMeasure(spec, options = {}) {
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
let settled = false;
|
|
13
|
+
const startedAt = performance.now();
|
|
14
|
+
const finalize = (measurement) => {
|
|
15
|
+
if (settled) return;
|
|
16
|
+
settled = true;
|
|
17
|
+
resolve(measurement);
|
|
18
|
+
};
|
|
19
|
+
const child = spawn(spec.command, spec.args, {
|
|
20
|
+
cwd: spec.cwd,
|
|
21
|
+
env: spec.env,
|
|
22
|
+
shell: spec.shell,
|
|
23
|
+
stdio: spec.stdio
|
|
24
|
+
});
|
|
25
|
+
options.onChild?.(child);
|
|
26
|
+
child.on("error", (error) => {
|
|
27
|
+
finalize({
|
|
28
|
+
durationMs: performance.now() - startedAt,
|
|
29
|
+
error,
|
|
30
|
+
status: 1
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
child.on("close", (code) => {
|
|
34
|
+
finalize({
|
|
35
|
+
durationMs: performance.now() - startedAt,
|
|
36
|
+
status: code ?? 1
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { spawnAndMeasure as t };
|