webext-messenger 0.25.0 → 0.25.2
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/distribution/thisTarget.js +8 -2
- package/package.json +16 -14
@@ -1,4 +1,4 @@
|
|
1
|
-
import { isBackground, isContentScript, isExtensionContext, } from "webext-detect-page";
|
1
|
+
import { getContextName, isBackground, isContentScript, isExtensionContext, } from "webext-detect-page";
|
2
2
|
import { messenger } from "./sender.js";
|
3
3
|
import { registerMethods } from "./receiver.js";
|
4
4
|
import { MessengerError, once } from "./shared.js";
|
@@ -112,11 +112,17 @@ const storeTabData = once(async () => {
|
|
112
112
|
export function __getTabData() {
|
113
113
|
return { tabId: this.trace[0]?.tab?.id, frameId: this.trace[0]?.frameId };
|
114
114
|
}
|
115
|
+
// TODO: Add tests
|
115
116
|
export async function getThisFrame() {
|
116
117
|
await storeTabData(); // It should already have been called but we still need to await it
|
117
118
|
const { tabId, frameId } = thisTarget;
|
118
119
|
if (typeof tabId !== "number" || typeof frameId !== "number") {
|
119
|
-
|
120
|
+
let moreInfo = "(error retrieving context information)";
|
121
|
+
try {
|
122
|
+
moreInfo = `(context: ${getContextName()}, url: ${globalThis.location?.href})`;
|
123
|
+
}
|
124
|
+
catch { }
|
125
|
+
throw new TypeError(`This target is not in a frame ${moreInfo}`);
|
120
126
|
}
|
121
127
|
// Rebuild object to return exactly these two properties and nothing more
|
122
128
|
return { tabId, frameId };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webext-messenger",
|
3
|
-
"version": "0.25.
|
3
|
+
"version": "0.25.2",
|
4
4
|
"description": "Browser Extension component messaging framework",
|
5
5
|
"keywords": [],
|
6
6
|
"repository": "pixiebrix/webext-messenger",
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"scripts": {
|
18
18
|
"build": "tsc",
|
19
19
|
"demo:watch": "parcel watch --no-cache --no-hmr",
|
20
|
-
"demo:build": "parcel build --no-cache",
|
20
|
+
"demo:build": "parcel build --no-cache --no-scope-hoist",
|
21
21
|
"prepack": "tsc --sourceMap false",
|
22
22
|
"test": "eslint . && tsc --noEmit",
|
23
23
|
"lint": "eslint .",
|
@@ -27,36 +27,38 @@
|
|
27
27
|
"dependencies": {
|
28
28
|
"p-retry": "^6.2.0",
|
29
29
|
"serialize-error": "^11.0.2",
|
30
|
-
"type-fest": "^4.
|
31
|
-
"webext-detect-page": "^
|
30
|
+
"type-fest": "^4.10.2",
|
31
|
+
"webext-detect-page": "^5.0.0"
|
32
|
+
},
|
33
|
+
"@parcel/resolver-default": {
|
34
|
+
"packageExports": true
|
32
35
|
},
|
33
36
|
"devDependencies": {
|
34
|
-
"@parcel/config-webextension": "^2.
|
37
|
+
"@parcel/config-webextension": "^2.11.0",
|
35
38
|
"@sindresorhus/tsconfig": "^5.0.0",
|
36
|
-
"@types/chrome": "^0.0.
|
39
|
+
"@types/chrome": "^0.0.259",
|
37
40
|
"@types/tape": "^5.6.4",
|
38
41
|
"@types/webextension-polyfill": "^0.10.7",
|
39
42
|
"buffer": "^6.0.3",
|
40
43
|
"eslint": "^8.56.0",
|
41
|
-
"eslint-config-pixiebrix": "^0.
|
44
|
+
"eslint-config-pixiebrix": "^0.34.1",
|
42
45
|
"events": "^3.3.0",
|
43
46
|
"npm-run-all": "^4.1.5",
|
44
|
-
"parcel": "^2.
|
47
|
+
"parcel": "^2.11.0",
|
45
48
|
"path-browserify": "^1.0.1",
|
46
49
|
"process": "^0.11.10",
|
47
50
|
"stream-browserify": "^3.0.0",
|
48
|
-
"tape": "^5.7.
|
51
|
+
"tape": "^5.7.4",
|
49
52
|
"typescript": "^5.3.3",
|
50
|
-
"webext-content-scripts": "^2.6.
|
53
|
+
"webext-content-scripts": "^2.6.1",
|
51
54
|
"webextension-polyfill": "^0.10.0"
|
52
55
|
},
|
53
|
-
"alias": {
|
54
|
-
"./this-stuff-is-just-for-local-parcel-tests": "https://github.com/parcel-bundler/parcel/issues/4936",
|
55
|
-
"./source/**/*.js": "./source/$1/$2.ts"
|
56
|
-
},
|
57
56
|
"targets": {
|
58
57
|
"main": false,
|
59
58
|
"default": {
|
59
|
+
"engines": {
|
60
|
+
"browsers": "Chrome 110"
|
61
|
+
},
|
60
62
|
"source": "source/test/manifest.json",
|
61
63
|
"sourceMap": {
|
62
64
|
"inline": true
|