@mtcute/bun 0.14.0 → 0.16.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.
|
@@ -2,25 +2,27 @@
|
|
|
2
2
|
let installed = false;
|
|
3
3
|
let handled = false;
|
|
4
4
|
const callbacks = new Set();
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// eslint-disable-next-line func-call-spacing
|
|
6
|
+
const myHandlers = new Map();
|
|
7
|
+
function register(shouldManuallyExit, signal, event) {
|
|
8
|
+
function eventHandler() {
|
|
7
9
|
if (handled) {
|
|
8
10
|
return;
|
|
9
11
|
}
|
|
10
12
|
handled = true;
|
|
11
|
-
const exitCode = 128 + signal;
|
|
12
13
|
for (const callback of callbacks) {
|
|
13
14
|
callback();
|
|
14
15
|
}
|
|
16
|
+
for (const [event, handler] of myHandlers) {
|
|
17
|
+
process.off(event, handler);
|
|
18
|
+
}
|
|
15
19
|
if (shouldManuallyExit) {
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
const idx = listeners.indexOf(eventHandler);
|
|
19
|
-
if (idx === listeners.length - 1) {
|
|
20
|
-
process.exit(exitCode);
|
|
21
|
-
}
|
|
20
|
+
// send the signal again and let node handle it
|
|
21
|
+
process.kill(process.pid, signal);
|
|
22
22
|
}
|
|
23
|
-
}
|
|
23
|
+
}
|
|
24
|
+
process.on(event, eventHandler);
|
|
25
|
+
myHandlers.set(event, eventHandler);
|
|
24
26
|
}
|
|
25
27
|
export function beforeExit(fn) {
|
|
26
28
|
// unsupported platform
|
|
@@ -28,10 +30,10 @@ export function beforeExit(fn) {
|
|
|
28
30
|
return () => { };
|
|
29
31
|
if (!installed) {
|
|
30
32
|
installed = true;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
register(true, 0, 'beforeExit');
|
|
34
|
+
register(true, 2, 'SIGINT');
|
|
35
|
+
register(true, 15, 'SIGTERM');
|
|
36
|
+
register(false, 15, 'exit');
|
|
35
37
|
}
|
|
36
38
|
callbacks.add(fn);
|
|
37
39
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-hook.js","sourceRoot":"","sources":["../../src/common-internals-node/exit-hook.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAE7F,IAAI,SAAS,GAAG,KAAK,CAAA;AACrB,IAAI,OAAO,GAAG,KAAK,CAAA;AAEnB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"exit-hook.js","sourceRoot":"","sources":["../../src/common-internals-node/exit-hook.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAE7F,IAAI,SAAS,GAAG,KAAK,CAAA;AACrB,IAAI,OAAO,GAAG,KAAK,CAAA;AAEnB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;AACvC,6CAA6C;AAC7C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAsB,CAAA;AAEhD,SAAS,QAAQ,CAAC,kBAA2B,EAAE,MAAc,EAAE,KAAa;IACxE,SAAS,YAAY;QACjB,IAAI,OAAO,EAAE,CAAC;YACV,OAAM;QACV,CAAC;QAED,OAAO,GAAG,IAAI,CAAA;QAEd,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YAC/B,QAAQ,EAAE,CAAA;QACd,CAAC;QAED,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,UAAU,EAAE,CAAC;YACxC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC/B,CAAC;QAED,IAAI,kBAAkB,EAAE,CAAC;YACrB,+CAA+C;YAC/C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACrC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;IAC/B,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAc;IACrC,uBAAuB;IACvB,IAAI,OAAO,OAAO,KAAK,WAAW;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;IAEnD,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,SAAS,GAAG,IAAI,CAAA;QAEhB,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,YAAY,CAAC,CAAA;QAC/B,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAA;QAC3B,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;QAC7B,QAAQ,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;IAC/B,CAAC;IAED,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEjB,OAAO,GAAG,EAAE;QACR,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACxB,CAAC,CAAA;AACL,CAAC","sourcesContent":["// roughly based on https://github.com/sindresorhus/exit-hook/blob/main/index.js, MIT license\n\nlet installed = false\nlet handled = false\n\nconst callbacks = new Set<() => void>()\n// eslint-disable-next-line func-call-spacing\nconst myHandlers = new Map<string, () => void>()\n\nfunction register(shouldManuallyExit: boolean, signal: number, event: string) {\n function eventHandler() {\n if (handled) {\n return\n }\n\n handled = true\n\n for (const callback of callbacks) {\n callback()\n }\n\n for (const [event, handler] of myHandlers) {\n process.off(event, handler)\n }\n\n if (shouldManuallyExit) {\n // send the signal again and let node handle it\n process.kill(process.pid, signal)\n }\n }\n\n process.on(event, eventHandler)\n myHandlers.set(event, eventHandler)\n}\n\nexport function beforeExit(fn: () => void): () => void {\n // unsupported platform\n if (typeof process === 'undefined') return () => {}\n\n if (!installed) {\n installed = true\n\n register(true, 0, 'beforeExit')\n register(true, 2, 'SIGINT')\n register(true, 15, 'SIGTERM')\n register(false, 15, 'exit')\n }\n\n callbacks.add(fn)\n\n return () => {\n callbacks.delete(fn)\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/bun",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Meta-package for Bun",
|
|
5
5
|
"author": "alina sireneva <alina@tei.su>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
"./utils.js": "./utils.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@mtcute/core": "^0.
|
|
16
|
-
"@mtcute/wasm": "^0.
|
|
17
|
-
"@mtcute/markdown-parser": "^0.
|
|
18
|
-
"@mtcute/html-parser": "^0.
|
|
15
|
+
"@mtcute/core": "^0.16.0",
|
|
16
|
+
"@mtcute/wasm": "^0.16.0",
|
|
17
|
+
"@mtcute/markdown-parser": "^0.16.0",
|
|
18
|
+
"@mtcute/html-parser": "^0.16.0"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://mtcute.dev",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/mtcute/mtcute"
|
|
19
24
|
}
|
|
20
25
|
}
|