elit 3.6.7 → 3.6.9
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/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +20 -1
- package/dist/cli.cjs +2777 -321
- package/dist/cli.mjs +2764 -308
- package/dist/config.d.ts +6 -6
- package/dist/{contracts-BeW9k0yZ.d.ts → contracts-_0p1-15U.d.ts} +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/dev-build.d.ts +3 -3
- package/dist/http.cjs +160 -41
- package/dist/http.d.ts +5 -11
- package/dist/http.js +160 -41
- package/dist/http.mjs +160 -41
- package/dist/https.cjs +194 -46
- package/dist/https.d.ts +3 -6
- package/dist/https.js +194 -46
- package/dist/https.mjs +194 -46
- package/dist/pm-node-shared-listener-bootstrap.cjs +75 -0
- package/dist/pm.cjs +2390 -160
- package/dist/pm.d.ts +83 -8
- package/dist/pm.js +2388 -188
- package/dist/pm.mjs +2380 -165
- package/dist/preview-build.d.ts +3 -3
- package/dist/server.cjs +417 -168
- package/dist/server.d.ts +4 -4
- package/dist/server.js +453 -179
- package/dist/server.mjs +417 -168
- package/dist/smtp-server.js +37 -12
- package/dist/test-reporter.d.ts +1 -1
- package/dist/test-runtime.d.ts +1 -1
- package/dist/{types-tJn88E1N.d.ts → types-BayMVo_k.d.ts} +39 -3
- package/dist/{types-CIhpN1-K.d.ts → types-C70T-42Z.d.ts} +1 -1
- package/dist/{types-DAisuVr5.d.ts → types-DPOgoGs-.d.ts} +7 -1
- package/dist/{state-DvEkDehk.d.ts → types-fiLday0L.d.ts} +96 -92
- package/dist/types.d.ts +4 -0
- package/dist/{websocket-XfyK23zD.d.ts → websocket-BLBEAnhp.d.ts} +1 -1
- package/dist/ws.d.ts +3 -3
- package/dist/wss.cjs +194 -46
- package/dist/wss.d.ts +3 -3
- package/dist/wss.js +194 -46
- package/dist/wss.mjs +194 -46
- package/package.json +11 -6
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const net = require('node:net');
|
|
2
|
+
|
|
3
|
+
const mode = process.env.ELIT_PM_LISTEN_MODE;
|
|
4
|
+
const publicPort = Number.parseInt(process.env.ELIT_PM_PUBLIC_PORT ?? '', 10);
|
|
5
|
+
const originalListen = net.Server.prototype.listen;
|
|
6
|
+
const state = {
|
|
7
|
+
handle: null,
|
|
8
|
+
waiters: [],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function sendMessage(message) {
|
|
12
|
+
if (typeof process.send === 'function') {
|
|
13
|
+
process.send(message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function wantsSharedListener(args) {
|
|
18
|
+
if (mode !== 'ipc' || !Number.isInteger(publicPort)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const firstArg = args[0];
|
|
23
|
+
if (typeof firstArg === 'number') {
|
|
24
|
+
return firstArg === publicPort;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (firstArg && typeof firstArg === 'object') {
|
|
28
|
+
if (typeof firstArg.fd === 'number') {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const requestedPort = typeof firstArg.port === 'number' ? firstArg.port : publicPort;
|
|
33
|
+
return requestedPort === publicPort;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function attachSharedHandle(server, args, handle) {
|
|
40
|
+
const callback = typeof args[args.length - 1] === 'function' ? args[args.length - 1] : undefined;
|
|
41
|
+
originalListen.call(server, handle, () => {
|
|
42
|
+
if (callback) {
|
|
43
|
+
callback();
|
|
44
|
+
}
|
|
45
|
+
sendMessage({ type: 'elit:pm:listener-ready' });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
net.Server.prototype.listen = function patchedListen(...args) {
|
|
50
|
+
if (!wantsSharedListener(args)) {
|
|
51
|
+
return originalListen.apply(this, args);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (state.handle) {
|
|
55
|
+
attachSharedHandle(this, args, state.handle);
|
|
56
|
+
} else {
|
|
57
|
+
state.waiters.push((handle) => attachSharedHandle(this, args, handle));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return this;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
process.on('message', (message, handle) => {
|
|
64
|
+
if (!message || message.type !== 'elit:pm:listen-handle' || !handle) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
state.handle = handle;
|
|
69
|
+
const waiters = state.waiters.splice(0);
|
|
70
|
+
for (const waiter of waiters) {
|
|
71
|
+
waiter(handle);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
sendMessage({ type: 'elit:pm:bootstrap-ready' });
|