webext-detect-page
Advanced tools
Comparing version 4.2.1 to 5.0.0
@@ -32,3 +32,3 @@ export declare function disableWebextDetectPageCache(): void; | ||
export declare const isMobileSafari: () => boolean; | ||
export declare const contextNames: { | ||
declare const contextChecks: { | ||
readonly contentScript: () => boolean; | ||
@@ -43,3 +43,5 @@ readonly background: () => boolean; | ||
}; | ||
export type ContextName = keyof typeof contextNames; | ||
export type ContextName = keyof typeof contextChecks; | ||
export declare const contextNames: ("contentScript" | "background" | "options" | "sidePanel" | "devTools" | "devToolsPage" | "extension" | "web")[]; | ||
export declare function getContextName(): ContextName | 'unknown'; | ||
export {}; |
@@ -89,3 +89,3 @@ let cache = true; | ||
export const isMobileSafari = () => isSafari() && globalThis.navigator?.userAgent.includes('Mobile'); | ||
export const contextNames = { | ||
const contextChecks = { | ||
contentScript: isContentScript, | ||
@@ -100,4 +100,5 @@ background: isBackground, | ||
}; | ||
export const contextNames = Object.keys(contextChecks); | ||
export function getContextName() { | ||
for (const [name, test] of Object.entries(contextNames)) { | ||
for (const [name, test] of Object.entries(contextChecks)) { | ||
if (test()) { | ||
@@ -104,0 +105,0 @@ return name; |
{ | ||
"name": "webext-detect-page", | ||
"version": "4.2.1", | ||
"version": "5.0.0", | ||
"description": "Detects where the current browser extension code is being run. Compatible with Firefox, Chrome and derivates.", | ||
@@ -21,7 +21,8 @@ "keywords": [ | ||
"repository": "fregante/webext-detect-page", | ||
"funding": "https://github.com/sponsors/fregante", | ||
"license": "MIT", | ||
"author": "Federico Brigante <me@fregante.com> (https://fregante.com)", | ||
"type": "module", | ||
"main": "index.js", | ||
"module": "index.js", | ||
"exports": "./index.js", | ||
"types": "./index.d.ts", | ||
"files": [ | ||
@@ -38,7 +39,10 @@ "index.js", | ||
"devDependencies": { | ||
"@sindresorhus/tsconfig": "^2.0.0", | ||
"@sindresorhus/tsconfig": "^5.0.0", | ||
"@types/chrome": "^0.0.254", | ||
"typescript": "^4.5.3", | ||
"xo": "^0.55.0" | ||
"typescript": "^5.3.3", | ||
"xo": "^0.56.0" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
14238
152