@pixpilot/chrome-lifecycle 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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 pixpilot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=new Map;let t=!1;function n(){t||(t=!0,chrome.windows.onRemoved.addListener(t=>{let n=e.get(t);n&&(n.forEach(e=>{e()}),e.delete(t))}))}function r(t,r){n();let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(r),()=>{let n=e.get(t);n&&(n.delete(r),n.size===0&&e.delete(t))}}exports.onWindowClose=r;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/on-window-close.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Manages callbacks for when specific Chrome windows are closed.
|
|
4
|
+
* Useful for triggering alerts, saving data, or cleaning up resources
|
|
5
|
+
* when a specific popup or window is removed.
|
|
6
|
+
*/
|
|
7
|
+
type CloseCallback = () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Registers a callback to be executed when a specific window is closed.
|
|
10
|
+
* @param windowId - The chrome window ID to watch
|
|
11
|
+
* @param callback - Function to execute when the window closes
|
|
12
|
+
* @returns A function to unsubscribe (remove) this specific listener
|
|
13
|
+
* @example
|
|
14
|
+
* const unsubscribe = onWindowClose(123, () => {
|
|
15
|
+
* console.log("Window 123 was closed!");
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
declare function onWindowClose(windowId: number, callback: CloseCallback): () => void;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { onWindowClose };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/on-window-close.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Manages callbacks for when specific Chrome windows are closed.
|
|
4
|
+
* Useful for triggering alerts, saving data, or cleaning up resources
|
|
5
|
+
* when a specific popup or window is removed.
|
|
6
|
+
*/
|
|
7
|
+
type CloseCallback = () => void;
|
|
8
|
+
/**
|
|
9
|
+
* Registers a callback to be executed when a specific window is closed.
|
|
10
|
+
* @param windowId - The chrome window ID to watch
|
|
11
|
+
* @param callback - Function to execute when the window closes
|
|
12
|
+
* @returns A function to unsubscribe (remove) this specific listener
|
|
13
|
+
* @example
|
|
14
|
+
* const unsubscribe = onWindowClose(123, () => {
|
|
15
|
+
* console.log("Window 123 was closed!");
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
declare function onWindowClose(windowId: number, callback: CloseCallback): () => void;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { onWindowClose };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=new Map;let t=!1;function n(){t||(t=!0,chrome.windows.onRemoved.addListener(t=>{let n=e.get(t);n&&(n.forEach(e=>{e()}),e.delete(t))}))}function r(t,r){n();let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(r),()=>{let n=e.get(t);n&&(n.delete(r),n.size===0&&e.delete(t))}}export{r as onWindowClose};
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pixpilot/chrome-lifecycle",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Lifecycle management utilities for Chrome extensions.",
|
|
6
|
+
"author": "m.doaie <m.doaie@hotmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/pixpilot/chrome-extension-toolkit.git",
|
|
11
|
+
"directory": "packages/chrome-lifecycle"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"require": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.18.12",
|
|
29
|
+
"eslint": "^9.38.0",
|
|
30
|
+
"tsdown": "^0.15.9",
|
|
31
|
+
"typescript": "^5.9.3",
|
|
32
|
+
"@internal/eslint-config": "0.3.0",
|
|
33
|
+
"@internal/prettier-config": "0.1.0",
|
|
34
|
+
"@internal/tsdown-config": "0.1.0",
|
|
35
|
+
"@internal/vitest-config": "0.1.0",
|
|
36
|
+
"@internal/tsconfig": "0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"prettier": "@internal/prettier-config",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"clean": "git clean -xdf .cache .turbo dist",
|
|
41
|
+
"clean:all": "git clean -xdf .cache .turbo dist node_modules",
|
|
42
|
+
"build": "tsdown",
|
|
43
|
+
"build:watch": "tsdown --watch",
|
|
44
|
+
"test": "vitest --run --passWithNoTests",
|
|
45
|
+
"test:watch": "vitest --watch",
|
|
46
|
+
"test:ui": "vitest --ui",
|
|
47
|
+
"test:coverage": "vitest --coverage",
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"lint": "eslint",
|
|
50
|
+
"format": "prettier --check . --ignore-path ../../.gitignore --ignore-path ../../.prettierignore"
|
|
51
|
+
},
|
|
52
|
+
"main": "./dist/index.cjs",
|
|
53
|
+
"module": "./dist/index.js",
|
|
54
|
+
"types": "./dist/index.d.ts"
|
|
55
|
+
}
|