webext-messenger 0.15.1-0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ import browser from "webextension-polyfill";
2
2
  import { serializeError } from "serialize-error";
3
3
  import { messenger } from "./sender.js";
4
4
  import { handlers, isObject, MessengerError, debug, __webextMessenger, } from "./shared.js";
5
- import { getContextName, isBackgroundPage } from "webext-detect-page";
5
+ import { getContextName, isBackground } from "webext-detect-page";
6
6
  import { getActionForMessage, nameThisTarget } from "./thisTarget.js";
7
7
  export function isMessengerMessage(message) {
8
8
  return (isObject(message) &&
@@ -55,7 +55,7 @@ action) {
55
55
  return { ...response, __webextMessenger };
56
56
  }
57
57
  export function registerMethods(methods) {
58
- if (!isBackgroundPage()) {
58
+ if (!isBackground()) {
59
59
  void nameThisTarget();
60
60
  }
61
61
  for (const [type, method] of Object.entries(methods)) {
@@ -1,6 +1,6 @@
1
1
  import browser from "webextension-polyfill";
2
2
  import pRetry from "p-retry";
3
- import { isBackgroundPage } from "webext-detect-page";
3
+ import { isBackground } from "webext-detect-page";
4
4
  import { deserializeError } from "serialize-error";
5
5
  import { isObject, MessengerError, __webextMessenger, handlers, debug, warn, } from "./shared.js";
6
6
  export const errorNonExistingTarget = "Could not establish connection. Receiving end does not exist.";
@@ -58,7 +58,7 @@ async function manageMessage(type, target, sendMessage) {
58
58
  function messenger(type, options, target, ...args) {
59
59
  // Message goes to extension page
60
60
  if ("page" in target) {
61
- if (target.page === "background" && isBackgroundPage()) {
61
+ if (target.page === "background" && isBackground()) {
62
62
  const handler = handlers.get(type);
63
63
  if (handler) {
64
64
  warn(type, "is being handled locally");
@@ -1,4 +1,4 @@
1
- import { isBackgroundPage, isContentScript, isExtensionContext, } from "webext-detect-page";
1
+ import { isBackground, isContentScript, isExtensionContext, } from "webext-detect-page";
2
2
  import { messenger } from "./sender.js";
3
3
  import { registerMethods } from "./receiver.js";
4
4
  import { debug } from "./shared.js";
@@ -53,7 +53,7 @@ function __getTabData() {
53
53
  return { tabId: (_b = (_a = this.trace[0]) === null || _a === void 0 ? void 0 : _a.tab) === null || _b === void 0 ? void 0 : _b.id, frameId: (_c = this.trace[0]) === null || _c === void 0 ? void 0 : _c.frameId };
54
54
  }
55
55
  export function initPrivateApi() {
56
- if (isBackgroundPage()) {
56
+ if (isBackground()) {
57
57
  thisTarget = { page: "background" };
58
58
  }
59
59
  if (isExtensionContext()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webext-messenger",
3
- "version": "0.15.1-0",
3
+ "version": "0.16.0",
4
4
  "description": "Browser Extension component messaging framework",
5
5
  "keywords": [],
6
6
  "repository": "pixiebrix/webext-messenger",
@@ -107,19 +107,19 @@
107
107
  "dependencies": {
108
108
  "p-retry": "^5.0.0",
109
109
  "serialize-error": "^9.0.0",
110
- "type-fest": "^2.6.0",
111
- "webext-detect-page": "^3.1.0",
110
+ "type-fest": "^2.8.0",
111
+ "webext-detect-page": "^4.0.0",
112
112
  "webextension-polyfill": "^0.8.0"
113
113
  },
114
114
  "devDependencies": {
115
115
  "@parcel/config-webextension": "^2.0.1",
116
116
  "@sindresorhus/tsconfig": "^2.0.0",
117
- "@types/chrome": "^0.0.164",
117
+ "@types/chrome": "^0.0.171",
118
118
  "@types/tape": "^4.13.2",
119
119
  "@types/webextension-polyfill": "^0.8.2",
120
- "@typescript-eslint/eslint-plugin": "^5.4.0",
121
- "@typescript-eslint/parser": "^5.4.0",
122
- "eslint": "^8.3.0",
120
+ "@typescript-eslint/eslint-plugin": "^5.7.0",
121
+ "@typescript-eslint/parser": "^5.7.0",
122
+ "eslint": "^8.4.1",
123
123
  "eslint-config-prettier": "^8.3.0",
124
124
  "eslint-config-xo": "^0.39.0",
125
125
  "eslint-config-xo-typescript": "^0.47.1",
@@ -128,8 +128,8 @@
128
128
  "npm-run-all": "^4.1.5",
129
129
  "parcel": "^2.0.1",
130
130
  "tape": "^5.3.2",
131
- "typescript": "^4.5.2",
132
- "webext-content-scripts": "^0.10.1"
131
+ "typescript": "^4.5.4",
132
+ "webext-content-scripts": "^0.12.0"
133
133
  },
134
134
  "targets": {
135
135
  "main": false,