From 1f7f73c23b2de9c557cc23e8e8559cda0bc2663c Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 23 Mar 2022 20:58:46 -0400 Subject: [PATCH] *Remove chrome.runtime check and namespace the package --- package.json | 4 ++-- src/browser-polyfill.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index f790861..9196043 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "webextension-polyfill", + "name": "@lumeweb/webextension-polyfill", "version": "0.8.0", "description": "A lightweight polyfill library for Promise-based WebExtension APIs in Chrome.", - "main": "dist/browser-polyfill.js", + "main": "src/browser-polyfill.js", "files": [ "dist" ], diff --git a/src/browser-polyfill.js b/src/browser-polyfill.js index ca65b3b..d272a47 100644 --- a/src/browser-polyfill.js +++ b/src/browser-polyfill.js @@ -6,10 +6,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -if (typeof globalThis != "object" || typeof chrome != "object" || !chrome || !chrome.runtime || !chrome.runtime.id) { - throw new Error("This script should only be loaded in a browser extension."); -} - if (typeof globalThis.browser === "undefined" || Object.getPrototypeOf(globalThis.browser) !== Object.prototype) { const CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE = "The message port closed before a response was received."; const SEND_RESPONSE_DEPRECATION_WARNING = "Returning a Promise is the preferred way to send a reply from an onMessage/onMessageExternal listener, as the sendResponse will be removed from the specs (See https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage)";