initial commit

This commit is contained in:
Brandon4466
2025-03-31 04:45:14 -07:00
commit ff59c4c0b8
2298 changed files with 478992 additions and 0 deletions

2
node_modules/when-exit/dist/browser/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
declare const whenExit: (callback: import("../types.js").Callback) => import("../types.js").Disposer;
export default whenExit;

6
node_modules/when-exit/dist/browser/index.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/* IMPORT */
import Interceptor from './interceptor.js';
/* MAIN */
const whenExit = Interceptor.register;
/* EXPORT */
export default whenExit;

10
node_modules/when-exit/dist/browser/interceptor.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import type { Callback, Disposer } from '../types.js';
declare class Interceptor {
private callbacks;
constructor();
exit: () => void;
hook: () => void;
register: (callback: Callback) => Disposer;
}
declare const _default: Interceptor;
export default _default;

27
node_modules/when-exit/dist/browser/interceptor.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/* IMPORT */
/* MAIN */
class Interceptor {
/* CONSTRUCTOR */
constructor() {
/* VARIABLES */
this.callbacks = new Set();
/* API */
this.exit = () => {
for (const callback of this.callbacks) {
callback();
}
};
this.hook = () => {
window.addEventListener('beforeunload', this.exit);
};
this.register = (callback) => {
this.callbacks.add(callback);
return () => {
this.callbacks.delete(callback);
};
};
this.hook();
}
}
/* EXPORT */
export default new Interceptor();

3
node_modules/when-exit/dist/node/constants.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
declare const IS_LINUX: boolean;
declare const IS_WINDOWS: boolean;
export { IS_LINUX, IS_WINDOWS };

7
node_modules/when-exit/dist/node/constants.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
/* IMPORT */
import process from 'node:process';
/* MAIN */
const IS_LINUX = (process.platform === 'linux');
const IS_WINDOWS = (process.platform === 'win32');
/* EXPORT */
export { IS_LINUX, IS_WINDOWS };

2
node_modules/when-exit/dist/node/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
declare const whenExit: (callback: import("../types.js").Callback) => import("../types.js").Disposer;
export default whenExit;

6
node_modules/when-exit/dist/node/index.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
/* IMPORT */
import Interceptor from './interceptor.js';
/* MAIN */
const whenExit = Interceptor.register;
/* EXPORT */
export default whenExit;

11
node_modules/when-exit/dist/node/interceptor.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import type { Callback, Disposer } from '../types.js';
declare class Interceptor {
private callbacks;
private exited;
constructor();
exit: (signal?: string) => void;
hook: () => void;
register: (callback: Callback) => Disposer;
}
declare const _default: Interceptor;
export default _default;

50
node_modules/when-exit/dist/node/interceptor.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
/* IMPORT */
import process from 'node:process';
import { IS_WINDOWS } from './constants.js';
import Signals from './signals.js';
/* MAIN */
class Interceptor {
/* CONSTRUCTOR */
constructor() {
/* VARIABLES */
this.callbacks = new Set();
this.exited = false;
/* API */
this.exit = (signal) => {
if (this.exited)
return;
this.exited = true;
for (const callback of this.callbacks) {
callback();
}
if (signal) {
if (IS_WINDOWS && (signal !== 'SIGINT' && signal !== 'SIGTERM' && signal !== 'SIGKILL')) { // Windows doesn't support POSIX signals, but Node emulates these 3 signals for us
process.kill(process.pid, 'SIGTERM');
}
else {
process.kill(process.pid, signal);
}
}
};
this.hook = () => {
process.once('exit', () => this.exit());
for (const signal of Signals) {
try {
process.once(signal, () => this.exit(signal));
}
catch {
// Sometimes "process.once" can throw...
}
}
};
this.register = (callback) => {
this.callbacks.add(callback);
return () => {
this.callbacks.delete(callback);
};
};
this.hook();
}
}
/* EXPORT */
export default new Interceptor();

2
node_modules/when-exit/dist/node/signals.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
declare const Signals: string[];
export default Signals;

13
node_modules/when-exit/dist/node/signals.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
/* IMPORT */
import { IS_LINUX, IS_WINDOWS } from './constants.js';
/* MAIN */
//URL: https://github.com/tapjs/signal-exit/blob/03dd77a96caa309c6a02c59274d58c812a2dce45/signals.js
const Signals = ['SIGABRT', 'SIGALRM', 'SIGHUP', 'SIGINT', 'SIGTERM'];
if (!IS_WINDOWS) {
Signals.push('SIGVTALRM', 'SIGXCPU', 'SIGXFSZ', 'SIGUSR2', 'SIGTRAP', 'SIGSYS', 'SIGQUIT', 'SIGIOT');
}
if (IS_LINUX) {
Signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT', 'SIGUNUSED');
}
/* EXPORT */
export default Signals;

3
node_modules/when-exit/dist/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
type Callback = () => void;
type Disposer = () => void;
export type { Callback, Disposer };

2
node_modules/when-exit/dist/types.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
/* MAIN */
export {};

21
node_modules/when-exit/license generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2022-present Fabio Spampinato
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

35
node_modules/when-exit/package.json generated vendored Normal file
View File

@@ -0,0 +1,35 @@
{
"name": "when-exit",
"repository": "github:fabiospampinato/when-exit",
"description": "Execute a function right before the process, or the browser's tab, is about to exit.",
"license": "MIT",
"version": "2.1.4",
"type": "module",
"main": "dist/node/index.js",
"types": "./dist/node/index.d.ts",
"exports": {
"node": "./dist/node/index.js",
"default": "./dist/browser/index.js"
},
"scripts": {
"clean": "tsex clean",
"compile": "tsex compile",
"compile:watch": "tsex compile --watch",
"test": "node test/index.js",
"prepublishOnly": "npm run clean && npm run compile && npm run test"
},
"keywords": [
"exit",
"catch",
"event",
"handle",
"hook",
"intercept",
"signal"
],
"devDependencies": {
"@types/node": "^18.19.70",
"tsex": "^4.0.2",
"typescript": "^5.7.3"
}
}

41
node_modules/when-exit/readme.md generated vendored Normal file
View File

@@ -0,0 +1,41 @@
# WhenExit
Execute a function right before the process, or the browser's tab, is about to exit.
## Install
```sh
npm install when-exit
```
## Usage
```ts
import whenExit from 'when-exit';
// Registering multiple callbacks
onExit ( () => {
console.log ( 'Callback 1' );
});
onExit ( () => {
console.log ( 'Callback 2' );
});
// Registering and disposing a callback
const disposer = onExit ( () => {
console.log ( 'Callback 3' );
});
disposer ();
// Triggering the process to exit
process.exit (); // Callback 1 and 2 are called before exiting
```
## License
MIT © Fabio Spampinato