extension-develop 4.1.39 → 4.1.40-canary.459.2c1ba7b
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/README.md +13 -10
- package/dist/{771~0.mjs → 5h~0.mjs} +13 -3
- package/dist/{273~0.mjs → 6l~0.mjs} +1 -1
- package/dist/{524~0.mjs → 9~0.mjs} +18 -2
- package/dist/{640~0.mjs → bh~0.mjs} +6 -1
- package/dist/bridge.mjs +14 -8
- package/dist/b~0.mjs +8644 -0
- package/dist/command-dev.d.ts +2 -0
- package/dist/command-preview.d.ts +2 -0
- package/dist/contracts.mjs +2 -1
- package/dist/{469~0.mjs → cp~0.mjs} +66 -17
- package/dist/css-parse-guard-loader.mjs +2 -2
- package/dist/c~0.mjs +56 -0
- package/dist/dead-css-url-loader.mjs +20 -119
- package/dist/dev-server/control-bridge/actions-file.d.ts +7 -0
- package/dist/dev-server/control-bridge/broker.d.ts +42 -2
- package/dist/dev-server/control-bridge/consumer-client.d.ts +7 -0
- package/dist/dev-server/control-bridge/contracts.d.ts +29 -1
- package/dist/dev-server/control-bridge/logs-file.d.ts +6 -0
- package/dist/dev-server/control-bridge/loopback.d.ts +1 -0
- package/dist/dev-server/control-bridge/producer-runtime.d.ts +5 -2
- package/dist/dev-server/control-bridge/production-control.d.ts +1 -0
- package/dist/dev-server/control-bridge/session-token.d.ts +5 -2
- package/dist/dev-server/cors.d.ts +4 -2
- package/dist/dev-server/messages.d.ts +6 -0
- package/dist/dev-server/session-restart.d.ts +3 -1
- package/dist/dev-server~0.mjs +71 -129
- package/dist/df~0.mjs +197 -0
- package/dist/{846~0.mjs → d~0.mjs} +4 -3
- package/dist/ensure-hmr-for-scripts.js +3 -3
- package/dist/ensure-hmr-for-scripts.mjs +3 -3
- package/dist/extension-js-devtools/build-stamp.json +2 -2
- package/dist/extension-js-devtools/chrome/background/service_worker.js +2 -2
- package/dist/extension-js-devtools/chrome/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/chromium/background/service_worker.js +2 -2
- package/dist/extension-js-devtools/chromium/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/edge/background/service_worker.js +2 -2
- package/dist/extension-js-devtools/edge/pages/welcome.js +2 -2
- package/dist/extension-js-devtools/firefox/background/scripts.js +2 -2
- package/dist/extension-js-devtools/firefox/pages/welcome.js +2 -2
- package/dist/extension-js-theme/build-stamp.json +2 -2
- package/dist/{143~0.mjs → ey~0.mjs} +2 -2
- package/dist/e~0.mjs +33 -0
- package/dist/feature-scripts-classic-traced-globals-loader.mjs +7 -2
- package/dist/feature-scripts-content-script-wrapper.js +56 -18
- package/dist/feature-scripts-content-script-wrapper.mjs +56 -18
- package/dist/feature-scripts-native-geturl-import-loader.mjs +1 -1
- package/dist/{105~0.mjs → g0~0.mjs} +1 -1
- package/dist/{88~0.mjs → j6~0.mjs} +9 -1
- package/dist/{731~0.mjs → j~0.mjs} +2 -2
- package/dist/{712~0.mjs → ka~0.mjs} +18 -2
- package/dist/{852~0.mjs → k~0.mjs} +4 -2
- package/dist/late-css-import-loader.mjs +1 -1
- package/dist/lib/addon-lint.d.ts +6 -0
- package/dist/lib/build-summary.d.ts +6 -0
- package/dist/lib/dev-additions.d.ts +12 -0
- package/dist/lib/extension-base-from-stack.d.ts +16 -0
- package/dist/lib/localized-manifest-name.d.ts +9 -0
- package/dist/lib/manifest-types.d.ts +276 -0
- package/dist/lib/messages.d.ts +6 -2
- package/dist/lib/process-started-at.d.ts +1 -0
- package/dist/lib/real-path.d.ts +8 -0
- package/dist/lib/resource-path.d.ts +1 -0
- package/dist/lib/session-paths.d.ts +2 -0
- package/dist/lib/split-chunks.d.ts +2 -1
- package/dist/lib/stats-handler.d.ts +1 -0
- package/dist/lib/tsconfig-includes-file.d.ts +1 -0
- package/dist/l~0.mjs +2290 -0
- package/dist/main-world-bridge.js +92 -23
- package/dist/main-world-bridge.mjs +92 -23
- package/dist/manifest-entry.d.ts +2 -0
- package/dist/manifest.mjs +3 -1
- package/dist/module.mjs +3 -3
- package/dist/{832~0.mjs → m~0.mjs} +2244 -288
- package/dist/o~0.mjs +47 -0
- package/dist/plugin-browsers/index.d.ts +7 -0
- package/dist/plugin-browsers/safari-dev-plugin.d.ts +2 -0
- package/dist/plugin-compatibility/compatibility-lib/messages.d.ts +5 -1
- package/dist/plugin-compatibility/compatibility-lib/native-browser-namespace.d.ts +5 -0
- package/dist/plugin-compatibility/feature-browser-global.d.ts +11 -1
- package/dist/plugin-compatibility/index.d.ts +2 -0
- package/dist/plugin-compilation/compilation-lib/messages.d.ts +4 -1
- package/dist/plugin-compilation/env.d.ts +1 -0
- package/dist/plugin-compilation/index.d.ts +2 -0
- package/dist/plugin-compilation/node-builtins.d.ts +5 -0
- package/dist/plugin-compilation/one-diagnostic-per-location.d.ts +13 -0
- package/dist/plugin-compilation/resolve-file-requests.d.ts +16 -0
- package/dist/plugin-compilation/warm-ancestor-watchers.d.ts +19 -0
- package/dist/plugin-compilation/watch-real-project-path.d.ts +27 -0
- package/dist/plugin-compilation/zip.d.ts +2 -0
- package/dist/plugin-css/css-in-content-script-loader.d.ts +1 -1
- package/dist/plugin-css/css-lib/build-css-rules.d.ts +3 -0
- package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +3 -1
- package/dist/plugin-css/css-lib/messages.d.ts +4 -0
- package/dist/plugin-css/css-lib/sfc-style-block.d.ts +26 -0
- package/dist/plugin-css/css-lib/unplaced-style-imports.d.ts +7 -0
- package/dist/plugin-css/css-lib/verbatim-css.d.ts +1 -0
- package/dist/plugin-css/dead-css-url-loader.d.ts +9 -1
- package/dist/plugin-css/index.d.ts +1 -0
- package/dist/plugin-css/sfc-style-block-loader.d.ts +18 -0
- package/dist/plugin-css/unplaced-style-import-loader.d.ts +16 -0
- package/dist/plugin-playwright/index.d.ts +22 -0
- package/dist/plugin-reload/classify-reload.d.ts +20 -0
- package/dist/plugin-reload/index.d.ts +4 -2
- package/dist/plugin-reload/messages.d.ts +1 -0
- package/dist/plugin-reload/reload-dispatch.d.ts +21 -2
- package/dist/plugin-reload/reload-lib/dev-content-scripts.d.ts +6 -0
- package/dist/plugin-reload/reload-lib/scripts-replay-shim.d.ts +1 -1
- package/dist/plugin-reload/steps/inject-bridge-producer.d.ts +6 -0
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/ChunkLoader.d.ts +3 -0
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/AutoPublicPath.d.ts +1 -1
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/BaseUri.d.ts +1 -1
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/LoadScript.d.ts +1 -1
- package/dist/plugin-reload/steps/setup-reload-strategy/webpack-target-webextension-fork/lib/webpack5/RuntimeModules/PublicPath.d.ts +1 -1
- package/dist/plugin-special-folders/get-data.d.ts +2 -0
- package/dist/plugin-special-folders/hint-import-only-scripts.d.ts +4 -0
- package/dist/plugin-special-folders/include-files.d.ts +2 -0
- package/dist/plugin-special-folders/messages.d.ts +1 -0
- package/dist/plugin-web-extension/feature-html/html-lib/inject.d.ts +1 -1
- package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +1 -0
- package/dist/plugin-web-extension/feature-html/steps/update-html-file.d.ts +1 -0
- package/dist/plugin-web-extension/feature-icons/extract-action-theme-icons.d.ts +1 -0
- package/dist/plugin-web-extension/feature-icons/extract-icon-variants.d.ts +2 -0
- package/dist/plugin-web-extension/feature-json/json-validation.d.ts +2 -1
- package/dist/plugin-web-extension/feature-json/messages.d.ts +2 -0
- package/dist/plugin-web-extension/feature-json/process-assets.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-gecko.d.ts +21 -0
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/filter-keys-safari.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/icon-variants-fallback.d.ts +15 -0
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/sanitize-fatal-shapes.d.ts +2 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/webkit-unsupported-keys.d.ts +15 -0
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/content_scripts.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/icons.d.ts +3 -2
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/omnibox.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/page_action.d.ts +2 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/permissions.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/sandbox.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/browser_action.d.ts +4 -3
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/action.d.ts +3 -2
- package/dist/plugin-web-extension/feature-manifest/messages.d.ts +15 -1
- package/dist/plugin-web-extension/feature-manifest/normalize-manifest-path.d.ts +2 -0
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/dev-additions.d.ts +8 -0
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-background.d.ts +2 -2
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-externally-connectable.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/steps/patch-gecko-background.d.ts +1 -0
- package/dist/plugin-web-extension/feature-manifest/steps/warn-content-script-host-access.d.ts +17 -0
- package/dist/plugin-web-extension/feature-manifest/steps/warn-description-length.d.ts +26 -0
- package/dist/plugin-web-extension/feature-manifest/steps/warn-gecko-unsupported-apis.d.ts +37 -2
- package/dist/plugin-web-extension/feature-scripts/contracts.d.ts +3 -0
- package/dist/plugin-web-extension/feature-scripts/index.d.ts +1 -0
- package/dist/plugin-web-extension/feature-scripts/messages.d.ts +10 -1
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/completion-value.d.ts +13 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/injected-sheet-urls.d.ts +5 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/main-world-bridge-pairing.d.ts +5 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/main-world-copy-routing.d.ts +2 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/registration-worlds.d.ts +10 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/runtime-main-world-scripts.d.ts +25 -2
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/runtime-script-sheet.d.ts +14 -0
- package/dist/plugin-web-extension/feature-scripts/scripts-lib/taken-extension-base.d.ts +10 -0
- package/dist/plugin-web-extension/feature-scripts/steps/add-base-uri-runtime-module.d.ts +7 -1
- package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/content-script-wrapper.d.ts +2 -0
- package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/index.d.ts +2 -0
- package/dist/plugin-web-extension/feature-scripts/steps/add-public-path-runtime-module.d.ts +6 -0
- package/dist/plugin-web-extension/feature-scripts/steps/classic-traced-globals-loader.d.ts +1 -0
- package/dist/plugin-web-extension/feature-scripts/steps/compile-main-world-scripts.d.ts +4 -0
- package/dist/plugin-web-extension/feature-scripts/steps/keep-completion-value.d.ts +6 -0
- package/dist/plugin-web-extension/feature-scripts/steps/pair-runtime-main-world-bridges.d.ts +12 -0
- package/dist/plugin-web-extension/feature-scripts/steps/place-runtime-script-sheets.d.ts +12 -0
- package/dist/plugin-web-extension/feature-scripts/steps/prune-main-world-bridges.d.ts +1 -0
- package/dist/plugin-web-extension/feature-scripts/steps/root-injected-sheet-urls.d.ts +9 -0
- package/dist/plugin-web-extension/feature-scripts/steps/route-main-world-copies.d.ts +10 -0
- package/dist/plugin-web-extension/feature-scripts/steps/source-literals.d.ts +24 -0
- package/dist/plugin-web-extension/feature-scripts/steps/take-extension-base.d.ts +11 -0
- package/dist/plugin-web-extension/feature-scripts/steps/trace-runtime-loaded-files.d.ts +18 -3
- package/dist/plugin-web-extension/feature-scripts/steps/warn-main-world-registration-changed.d.ts +12 -0
- package/dist/plugin-web-extension/feature-scripts/steps/warn-moved-page-relative-urls.d.ts +30 -0
- package/dist/plugin-web-extension/feature-scripts/steps/warn-page-relative-script-path.d.ts +10 -0
- package/dist/plugin-web-extension/feature-scripts/steps/warn-unknown-registration-world.d.ts +10 -0
- package/dist/plugin-web-extension/feature-web-resources/collect-entry-imports.d.ts +1 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/messages.d.ts +2 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/page-requests.d.ts +5 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/resolve-war.d.ts +1 -0
- package/dist/plugin-web-extension/feature-web-resources/web-resources-lib/unreachable-resources.d.ts +1 -0
- package/dist/plugin-web-extension/shared/script-graph.d.ts +12 -0
- package/dist/preprocessor-passthrough-loader.mjs +1 -1
- package/dist/preview.mjs +1 -1
- package/dist/public-css-url-loader.mjs +1 -1
- package/dist/{331~0.mjs → q~0.mjs} +2 -2
- package/dist/rj~0.mjs +125 -0
- package/dist/{519~0.mjs → rl~0.mjs} +56 -5
- package/dist/rspack-config~0.mjs +3140 -3302
- package/dist/{177~0.mjs → r~0.mjs} +2 -2
- package/dist/sfc-style-block-loader.mjs +49 -0
- package/dist/stats-handler~0.mjs +15 -7
- package/dist/tm~0.mjs +71 -0
- package/dist/types.d.ts +46 -5
- package/dist/{285~0.mjs → t~0.mjs} +41 -26
- package/dist/unplaced-style-import-loader.mjs +131 -0
- package/dist/x~0.mjs +3 -0
- package/dist/y~0.mjs +234 -0
- package/dist/zip~0.mjs +5 -4
- package/dist/{363~0.mjs → z~0.mjs} +563 -281
- package/package.json +6 -6
- package/dist/527~0.mjs +0 -3
- package/dist/840~0.mjs +0 -5635
- /package/dist/{895~0.mjs → 3~0.mjs} +0 -0
- /package/dist/{374~0.mjs → 5~0.mjs} +0 -0
- /package/dist/{206~0.mjs → 6~0.mjs} +0 -0
- /package/dist/{471~0.mjs → g~0.mjs} +0 -0
- /package/dist/{117~0.mjs → w~0.mjs} +0 -0
|
@@ -1,46 +1,105 @@
|
|
|
1
1
|
const EXTJS_MARK = '__extjs__';
|
|
2
2
|
const REQ_TYPE = 'EXTJS_WTW_LOAD';
|
|
3
3
|
const RES_TYPE = 'EXTJS_WTW_LOADED';
|
|
4
|
-
const EXTJS_BASE_KEY = '__EXTJS_EXTENSION_BASE__';
|
|
5
4
|
const EXTJS_BASE_ATTR = 'data-extjs-extension-base';
|
|
5
|
+
const EXTJS_PAGE_BASE_KEY = 'string' == typeof __EXTJS_PAGE_BASE_GLOBAL__ ? __EXTJS_PAGE_BASE_GLOBAL__ : '';
|
|
6
|
+
const EXTJS_PAGE_BASE_ATTR = 'string' == typeof __EXTJS_PAGE_BASE_ATTRIBUTE__ ? __EXTJS_PAGE_BASE_ATTRIBUTE__ : EXTJS_BASE_ATTR;
|
|
7
|
+
const EXTJS_EXTENSION_SCHEMES = 'string' == typeof __EXTJS_EXTENSION_SCHEME__ ? [
|
|
8
|
+
__EXTJS_EXTENSION_SCHEME__
|
|
9
|
+
] : [
|
|
10
|
+
'chrome-extension',
|
|
11
|
+
'moz-extension',
|
|
12
|
+
'safari-web-extension'
|
|
13
|
+
];
|
|
6
14
|
function safeString(x) {
|
|
7
15
|
return 'string' == typeof x && x.length > 0;
|
|
8
16
|
}
|
|
17
|
+
function isExtensionAddress(url) {
|
|
18
|
+
return 'string' == typeof url && EXTJS_EXTENSION_SCHEMES.some((scheme)=>url.startsWith(`${scheme}://`));
|
|
19
|
+
}
|
|
9
20
|
function hasForbiddenProtocol(url) {
|
|
10
|
-
return /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(url) &&
|
|
21
|
+
return /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(url) && !isExtensionAddress(url);
|
|
11
22
|
}
|
|
12
23
|
function getRuntime() {
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
for (const name of [
|
|
25
|
+
'browser',
|
|
26
|
+
'chrome'
|
|
27
|
+
])try {
|
|
28
|
+
const runtime = globalThis[name]?.runtime;
|
|
29
|
+
if ('function' == typeof runtime?.getURL) return runtime;
|
|
15
30
|
} catch {}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const EXTJS_INJECTED_SOURCE = '<anonymous code>';
|
|
34
|
+
const EXTJS_TAKE_COLUMNS = 227;
|
|
35
|
+
function publishOnDocument(base) {
|
|
16
36
|
try {
|
|
17
|
-
|
|
37
|
+
const docEl = document?.documentElement;
|
|
38
|
+
if (docEl && 'function' == typeof docEl.setAttribute) docEl.setAttribute(EXTJS_PAGE_BASE_ATTR, base);
|
|
18
39
|
} catch {}
|
|
19
|
-
return null;
|
|
20
40
|
}
|
|
21
|
-
function
|
|
41
|
+
function takingSource(stack, base) {
|
|
42
|
+
const callers = String(stack || '').split('\n').filter((frame)=>frame && !frame.includes(`@${base}`));
|
|
43
|
+
if (1 !== callers.length) return '';
|
|
44
|
+
const frame = /^@(.+):(\d+):(\d+)$/.exec(callers[0]);
|
|
45
|
+
if (!frame) return '';
|
|
46
|
+
if (1 !== Number(frame[2])) return '';
|
|
47
|
+
if (Number(frame[3]) > EXTJS_TAKE_COLUMNS) return '';
|
|
48
|
+
return frame[1];
|
|
49
|
+
}
|
|
50
|
+
function isBrowserNamed(source) {
|
|
51
|
+
return source.includes(' ') && !/[:/]/.test(source) && !source.includes(' > ') && 'debugger eval code' !== source;
|
|
52
|
+
}
|
|
53
|
+
function publishToInjectedFile(base) {
|
|
22
54
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
if ('function' != typeof
|
|
26
|
-
const
|
|
27
|
-
if (base)
|
|
28
|
-
|
|
55
|
+
const page = window.wrappedJSObject;
|
|
56
|
+
if (!EXTJS_PAGE_BASE_KEY) return false;
|
|
57
|
+
if (!page || 'function' != typeof exportFunction) return false;
|
|
58
|
+
const own = String(new Error().stack || '').split('\n')[0];
|
|
59
|
+
if (!own.includes(`@${base}`) || !/:\d+:\d+$/.test(own)) return false;
|
|
60
|
+
let published = null;
|
|
61
|
+
let failedClosed = false;
|
|
62
|
+
const answer = ()=>{
|
|
29
63
|
try {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
64
|
+
const held = Object.getOwnPropertyDescriptor(page, EXTJS_PAGE_BASE_KEY);
|
|
65
|
+
if (!published || !held || held.get !== published) return '';
|
|
66
|
+
const source = takingSource(new Error().stack, base);
|
|
67
|
+
if (source === EXTJS_INJECTED_SOURCE) return base;
|
|
68
|
+
if (source && !failedClosed && isBrowserNamed(source)) {
|
|
69
|
+
failedClosed = true;
|
|
70
|
+
publishOnDocument(base);
|
|
71
|
+
}
|
|
32
72
|
} catch {}
|
|
33
|
-
|
|
73
|
+
return '';
|
|
74
|
+
};
|
|
75
|
+
Object.defineProperty(page, EXTJS_PAGE_BASE_KEY, {
|
|
76
|
+
get: exportFunction(answer, window),
|
|
77
|
+
configurable: true,
|
|
78
|
+
enumerable: false
|
|
79
|
+
});
|
|
80
|
+
const held = Object.getOwnPropertyDescriptor(page, EXTJS_PAGE_BASE_KEY);
|
|
81
|
+
published = held && 'function' == typeof held.get ? held.get : null;
|
|
82
|
+
return null !== published;
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function setExtensionBaseUrl() {
|
|
88
|
+
try {
|
|
89
|
+
const runtime = getRuntime();
|
|
90
|
+
if (!runtime) return;
|
|
91
|
+
const base = runtime.getURL('/');
|
|
92
|
+
if (!isExtensionAddress(base)) return;
|
|
93
|
+
if (!publishToInjectedFile(base)) publishOnDocument(base);
|
|
34
94
|
} catch {}
|
|
35
95
|
}
|
|
36
96
|
setExtensionBaseUrl();
|
|
37
97
|
function resolveExtensionUrl(inputUrl) {
|
|
38
98
|
if (!safeString(inputUrl)) return null;
|
|
39
99
|
if (hasForbiddenProtocol(inputUrl)) return null;
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
if ('function' != typeof getURL) return null;
|
|
100
|
+
if (isExtensionAddress(inputUrl)) return inputUrl;
|
|
101
|
+
const runtime = getRuntime();
|
|
102
|
+
if (!runtime) return null;
|
|
44
103
|
let p = inputUrl;
|
|
45
104
|
try {
|
|
46
105
|
if (p.startsWith('/')) p = new URL(`https://example.invalid${p}`).pathname;
|
|
@@ -48,7 +107,8 @@ function resolveExtensionUrl(inputUrl) {
|
|
|
48
107
|
} catch {}
|
|
49
108
|
if (!p) return null;
|
|
50
109
|
if (!p.startsWith('/')) p = `/${p}`;
|
|
51
|
-
|
|
110
|
+
const resolved = runtime.getURL(p);
|
|
111
|
+
return isExtensionAddress(resolved) ? resolved : null;
|
|
52
112
|
}
|
|
53
113
|
function injectScript(src) {
|
|
54
114
|
return new Promise((resolve, reject)=>{
|
|
@@ -75,7 +135,15 @@ function postResponse(res) {
|
|
|
75
135
|
window.postMessage(res, '*');
|
|
76
136
|
} catch {}
|
|
77
137
|
}
|
|
78
|
-
|
|
138
|
+
function loadsFilesForThePage() {
|
|
139
|
+
try {
|
|
140
|
+
const runtime = getRuntime();
|
|
141
|
+
return !(runtime && String(runtime.getURL('/')).startsWith('moz-extension:'));
|
|
142
|
+
} catch {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function answerLoadRequest(event) {
|
|
79
147
|
if (event.source !== window) return;
|
|
80
148
|
const data = event.data;
|
|
81
149
|
if (!data || true !== data[EXTJS_MARK]) return;
|
|
@@ -106,4 +174,5 @@ window.addEventListener('message', (event)=>{
|
|
|
106
174
|
error: e instanceof Error ? e.message : String(e)
|
|
107
175
|
});
|
|
108
176
|
});
|
|
109
|
-
}
|
|
177
|
+
}
|
|
178
|
+
if (loadsFilesForThePage()) window.addEventListener('message', answerLoadRequest);
|
|
@@ -1,46 +1,105 @@
|
|
|
1
1
|
const EXTJS_MARK = '__extjs__';
|
|
2
2
|
const REQ_TYPE = 'EXTJS_WTW_LOAD';
|
|
3
3
|
const RES_TYPE = 'EXTJS_WTW_LOADED';
|
|
4
|
-
const EXTJS_BASE_KEY = '__EXTJS_EXTENSION_BASE__';
|
|
5
4
|
const EXTJS_BASE_ATTR = 'data-extjs-extension-base';
|
|
5
|
+
const EXTJS_PAGE_BASE_KEY = 'string' == typeof __EXTJS_PAGE_BASE_GLOBAL__ ? __EXTJS_PAGE_BASE_GLOBAL__ : '';
|
|
6
|
+
const EXTJS_PAGE_BASE_ATTR = 'string' == typeof __EXTJS_PAGE_BASE_ATTRIBUTE__ ? __EXTJS_PAGE_BASE_ATTRIBUTE__ : EXTJS_BASE_ATTR;
|
|
7
|
+
const EXTJS_EXTENSION_SCHEMES = 'string' == typeof __EXTJS_EXTENSION_SCHEME__ ? [
|
|
8
|
+
__EXTJS_EXTENSION_SCHEME__
|
|
9
|
+
] : [
|
|
10
|
+
'chrome-extension',
|
|
11
|
+
'moz-extension',
|
|
12
|
+
'safari-web-extension'
|
|
13
|
+
];
|
|
6
14
|
function safeString(x) {
|
|
7
15
|
return 'string' == typeof x && x.length > 0;
|
|
8
16
|
}
|
|
17
|
+
function isExtensionAddress(url) {
|
|
18
|
+
return 'string' == typeof url && EXTJS_EXTENSION_SCHEMES.some((scheme)=>url.startsWith(`${scheme}://`));
|
|
19
|
+
}
|
|
9
20
|
function hasForbiddenProtocol(url) {
|
|
10
|
-
return /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(url) &&
|
|
21
|
+
return /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(url) && !isExtensionAddress(url);
|
|
11
22
|
}
|
|
12
23
|
function getRuntime() {
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
for (const name of [
|
|
25
|
+
'browser',
|
|
26
|
+
'chrome'
|
|
27
|
+
])try {
|
|
28
|
+
const runtime = globalThis[name]?.runtime;
|
|
29
|
+
if ('function' == typeof runtime?.getURL) return runtime;
|
|
15
30
|
} catch {}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const EXTJS_INJECTED_SOURCE = '<anonymous code>';
|
|
34
|
+
const EXTJS_TAKE_COLUMNS = 227;
|
|
35
|
+
function publishOnDocument(base) {
|
|
16
36
|
try {
|
|
17
|
-
|
|
37
|
+
const docEl = document?.documentElement;
|
|
38
|
+
if (docEl && 'function' == typeof docEl.setAttribute) docEl.setAttribute(EXTJS_PAGE_BASE_ATTR, base);
|
|
18
39
|
} catch {}
|
|
19
|
-
return null;
|
|
20
40
|
}
|
|
21
|
-
function
|
|
41
|
+
function takingSource(stack, base) {
|
|
42
|
+
const callers = String(stack || '').split('\n').filter((frame)=>frame && !frame.includes(`@${base}`));
|
|
43
|
+
if (1 !== callers.length) return '';
|
|
44
|
+
const frame = /^@(.+):(\d+):(\d+)$/.exec(callers[0]);
|
|
45
|
+
if (!frame) return '';
|
|
46
|
+
if (1 !== Number(frame[2])) return '';
|
|
47
|
+
if (Number(frame[3]) > EXTJS_TAKE_COLUMNS) return '';
|
|
48
|
+
return frame[1];
|
|
49
|
+
}
|
|
50
|
+
function isBrowserNamed(source) {
|
|
51
|
+
return source.includes(' ') && !/[:/]/.test(source) && !source.includes(' > ') && 'debugger eval code' !== source;
|
|
52
|
+
}
|
|
53
|
+
function publishToInjectedFile(base) {
|
|
22
54
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
if ('function' != typeof
|
|
26
|
-
const
|
|
27
|
-
if (base)
|
|
28
|
-
|
|
55
|
+
const page = window.wrappedJSObject;
|
|
56
|
+
if (!EXTJS_PAGE_BASE_KEY) return false;
|
|
57
|
+
if (!page || 'function' != typeof exportFunction) return false;
|
|
58
|
+
const own = String(new Error().stack || '').split('\n')[0];
|
|
59
|
+
if (!own.includes(`@${base}`) || !/:\d+:\d+$/.test(own)) return false;
|
|
60
|
+
let published = null;
|
|
61
|
+
let failedClosed = false;
|
|
62
|
+
const answer = ()=>{
|
|
29
63
|
try {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
64
|
+
const held = Object.getOwnPropertyDescriptor(page, EXTJS_PAGE_BASE_KEY);
|
|
65
|
+
if (!published || !held || held.get !== published) return '';
|
|
66
|
+
const source = takingSource(new Error().stack, base);
|
|
67
|
+
if (source === EXTJS_INJECTED_SOURCE) return base;
|
|
68
|
+
if (source && !failedClosed && isBrowserNamed(source)) {
|
|
69
|
+
failedClosed = true;
|
|
70
|
+
publishOnDocument(base);
|
|
71
|
+
}
|
|
32
72
|
} catch {}
|
|
33
|
-
|
|
73
|
+
return '';
|
|
74
|
+
};
|
|
75
|
+
Object.defineProperty(page, EXTJS_PAGE_BASE_KEY, {
|
|
76
|
+
get: exportFunction(answer, window),
|
|
77
|
+
configurable: true,
|
|
78
|
+
enumerable: false
|
|
79
|
+
});
|
|
80
|
+
const held = Object.getOwnPropertyDescriptor(page, EXTJS_PAGE_BASE_KEY);
|
|
81
|
+
published = held && 'function' == typeof held.get ? held.get : null;
|
|
82
|
+
return null !== published;
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function setExtensionBaseUrl() {
|
|
88
|
+
try {
|
|
89
|
+
const runtime = getRuntime();
|
|
90
|
+
if (!runtime) return;
|
|
91
|
+
const base = runtime.getURL('/');
|
|
92
|
+
if (!isExtensionAddress(base)) return;
|
|
93
|
+
if (!publishToInjectedFile(base)) publishOnDocument(base);
|
|
34
94
|
} catch {}
|
|
35
95
|
}
|
|
36
96
|
setExtensionBaseUrl();
|
|
37
97
|
function resolveExtensionUrl(inputUrl) {
|
|
38
98
|
if (!safeString(inputUrl)) return null;
|
|
39
99
|
if (hasForbiddenProtocol(inputUrl)) return null;
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
if ('function' != typeof getURL) return null;
|
|
100
|
+
if (isExtensionAddress(inputUrl)) return inputUrl;
|
|
101
|
+
const runtime = getRuntime();
|
|
102
|
+
if (!runtime) return null;
|
|
44
103
|
let p = inputUrl;
|
|
45
104
|
try {
|
|
46
105
|
if (p.startsWith('/')) p = new URL(`https://example.invalid${p}`).pathname;
|
|
@@ -48,7 +107,8 @@ function resolveExtensionUrl(inputUrl) {
|
|
|
48
107
|
} catch {}
|
|
49
108
|
if (!p) return null;
|
|
50
109
|
if (!p.startsWith('/')) p = `/${p}`;
|
|
51
|
-
|
|
110
|
+
const resolved = runtime.getURL(p);
|
|
111
|
+
return isExtensionAddress(resolved) ? resolved : null;
|
|
52
112
|
}
|
|
53
113
|
function injectScript(src) {
|
|
54
114
|
return new Promise((resolve, reject)=>{
|
|
@@ -75,7 +135,15 @@ function postResponse(res) {
|
|
|
75
135
|
window.postMessage(res, '*');
|
|
76
136
|
} catch {}
|
|
77
137
|
}
|
|
78
|
-
|
|
138
|
+
function loadsFilesForThePage() {
|
|
139
|
+
try {
|
|
140
|
+
const runtime = getRuntime();
|
|
141
|
+
return !(runtime && String(runtime.getURL('/')).startsWith('moz-extension:'));
|
|
142
|
+
} catch {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function answerLoadRequest(event) {
|
|
79
147
|
if (event.source !== window) return;
|
|
80
148
|
const data = event.data;
|
|
81
149
|
if (!data || true !== data[EXTJS_MARK]) return;
|
|
@@ -106,4 +174,5 @@ window.addEventListener('message', (event)=>{
|
|
|
106
174
|
error: e instanceof Error ? e.message : String(e)
|
|
107
175
|
});
|
|
108
176
|
});
|
|
109
|
-
}
|
|
177
|
+
}
|
|
178
|
+
if (loadsFilesForThePage()) window.addEventListener('message', answerLoadRequest);
|
package/dist/manifest-entry.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
+
export { type LocalizableManifest, type LocalizedNameOptions, resolveLocalizedManifestName } from './lib/localized-manifest-name.js';
|
|
1
2
|
export { type FilterKeysOptions, filterKeysForThisBrowser, findDroppedVendorKeys } from './lib/manifest-utils.js';
|
|
3
|
+
export { type WebkitDroppedPage, type WebkitUnsupportedKey, webkitDroppedSurfacePages, webkitUnsupportedManifestKeys, webkitUnsupportedPermissions } from './plugin-web-extension/feature-manifest/manifest-lib/webkit-unsupported-keys.js';
|
package/dist/manifest.mjs
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
|
|
2
|
-
export { filterKeysForThisBrowser, findDroppedVendorKeys } from "./
|
|
2
|
+
export { filterKeysForThisBrowser, findDroppedVendorKeys } from "./ey~0.mjs";
|
|
3
|
+
export { resolveLocalizedManifestName } from "./e~0.mjs";
|
|
4
|
+
export { webkitDroppedSurfacePages, webkitUnsupportedManifestKeys, webkitUnsupportedPermissions } from "./rj~0.mjs";
|
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
|
|
2
|
-
export { BuildEmitter, extensionBuild, extensionDev } from "./
|
|
3
|
-
export { extensionPreview } from "./
|
|
4
|
-
export { loadCommandConfig, loadProjectConfigDefaults } from "./
|
|
2
|
+
export { BuildEmitter, extensionBuild, extensionDev } from "./b~0.mjs";
|
|
3
|
+
export { extensionPreview } from "./m~0.mjs";
|
|
4
|
+
export { loadCommandConfig, loadProjectConfigDefaults } from "./d~0.mjs";
|