summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-02 22:57:27 -0500
committerGitHub <noreply@github.com>2024-02-03 03:57:27 +0000
commitd7db65a9b3b8d941c6934597862b8010a1ccac64 (patch)
tree5b406707f95243d786be048f8fc20c5fe90d48ae
parent17ffea6cb907c12c1af47d3f6f27126f126b168f (diff)
Chrome types update (#614)
* Update chrome types * Fix issues * Update manifest author
-rw-r--r--dev/data/manifest-variants.json18
-rw-r--r--ext/js/background/offscreen-proxy.js8
-rw-r--r--package-lock.json14
-rw-r--r--package.json2
-rw-r--r--types/dev/manifest.d.ts10
5 files changed, 38 insertions, 14 deletions
diff --git a/dev/data/manifest-variants.json b/dev/data/manifest-variants.json
index b0cc70a7..93841f46 100644
--- a/dev/data/manifest-variants.json
+++ b/dev/data/manifest-variants.json
@@ -4,7 +4,9 @@
"name": "Yomitan",
"version": "$YOMITAN_VERSION",
"description": "Japanese dictionary with Anki integration",
- "author": "TheMoeWay",
+ "author": {
+ "email": "themoeway@googlegroups.com"
+ },
"icons": {
"16": "images/icon16.png",
"19": "images/icon19.png",
@@ -179,6 +181,13 @@
"fileName": "yomitan-firefox.zip",
"modifications": [
{
+ "action": "set",
+ "path": [
+ "author"
+ ],
+ "value": "TheMoeWay"
+ },
+ {
"action": "delete",
"path": [
"background",
@@ -313,6 +322,13 @@
"name": "safari",
"modifications": [
{
+ "action": "set",
+ "path": [
+ "author"
+ ],
+ "value": "TheMoeWay"
+ },
+ {
"action": "remove",
"path": [
"optional_permissions"
diff --git a/ext/js/background/offscreen-proxy.js b/ext/js/background/offscreen-proxy.js
index 716deddd..8c3f63c9 100644
--- a/ext/js/background/offscreen-proxy.js
+++ b/ext/js/background/offscreen-proxy.js
@@ -59,7 +59,6 @@ export class OffscreenProxy {
*/
async _hasOffscreenDocument() {
const offscreenUrl = chrome.runtime.getURL('offscreen.html');
- // @ts-expect-error - API not defined yet
if (!chrome.runtime.getContexts) { // chrome version below 116
// Clients: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/clients
// @ts-expect-error - Types not set up for service workers yet
@@ -68,12 +67,13 @@ export class OffscreenProxy {
return await matchedClients.some((client) => client.url === offscreenUrl);
}
- // @ts-expect-error - API not defined yet
const contexts = await chrome.runtime.getContexts({
- contextTypes: ['OFFSCREEN_DOCUMENT'],
+ contextTypes: [
+ /** @type {chrome.runtime.ContextType} */ ('OFFSCREEN_DOCUMENT')
+ ],
documentUrls: [offscreenUrl]
});
- return !!contexts.length;
+ return contexts.length > 0;
}
/**
diff --git a/package-lock.json b/package-lock.json
index 8dc1b509..ecbe54c8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -22,7 +22,7 @@
"@stylistic/stylelint-plugin": "^2.0.0",
"@types/assert": "^1.5.10",
"@types/browserify": "^12.0.40",
- "@types/chrome": "^0.0.254",
+ "@types/chrome": "^0.0.260",
"@types/css": "^0.0.37",
"@types/events": "^3.0.3",
"@types/firefox-webext-browser": "^120.0.0",
@@ -1359,9 +1359,9 @@
}
},
"node_modules/@types/chrome": {
- "version": "0.0.254",
- "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.254.tgz",
- "integrity": "sha512-svkOGKwA+6ZZuk9xtrYun8MYpNY/9hD17rgZ19v3KunhsK1ZOKaMESw12/1AXLh1u3UPA8jQIRi2370DXv9wgw==",
+ "version": "0.0.260",
+ "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.260.tgz",
+ "integrity": "sha512-lX6QpgfsZRTDpNcCJ+3vzfFnFXq9bScFRTlfhbK5oecSAjamsno+ejFTCbNtc5O/TPnVK9Tja/PyecvWQe0F2w==",
"dev": true,
"dependencies": {
"@types/filesystem": "*",
@@ -7108,9 +7108,9 @@
}
},
"@types/chrome": {
- "version": "0.0.254",
- "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.254.tgz",
- "integrity": "sha512-svkOGKwA+6ZZuk9xtrYun8MYpNY/9hD17rgZ19v3KunhsK1ZOKaMESw12/1AXLh1u3UPA8jQIRi2370DXv9wgw==",
+ "version": "0.0.260",
+ "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.260.tgz",
+ "integrity": "sha512-lX6QpgfsZRTDpNcCJ+3vzfFnFXq9bScFRTlfhbK5oecSAjamsno+ejFTCbNtc5O/TPnVK9Tja/PyecvWQe0F2w==",
"dev": true,
"requires": {
"@types/filesystem": "*",
diff --git a/package.json b/package.json
index 7497e857..7c56f8e1 100644
--- a/package.json
+++ b/package.json
@@ -50,7 +50,7 @@
"@stylistic/stylelint-plugin": "^2.0.0",
"@types/assert": "^1.5.10",
"@types/browserify": "^12.0.40",
- "@types/chrome": "^0.0.254",
+ "@types/chrome": "^0.0.260",
"@types/css": "^0.0.37",
"@types/events": "^3.0.3",
"@types/firefox-webext-browser": "^120.0.0",
diff --git a/types/dev/manifest.d.ts b/types/dev/manifest.d.ts
index ef2c831c..f07b2355 100644
--- a/types/dev/manifest.d.ts
+++ b/types/dev/manifest.d.ts
@@ -15,7 +15,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-export type Manifest = chrome.runtime.Manifest;
+/**
+ * These overrides provide compatibility between the default chrome types and the minor
+ * differences that other browsers such as Firefox use.
+ */
+export type ManifestOverrides = {
+ author?: chrome.runtime.Manifest['author'] | string;
+};
+
+export type Manifest = Omit<chrome.runtime.Manifest, keyof ManifestOverrides> & ManifestOverrides;
export type ManifestConfig = {
manifest: Manifest;