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
|
@@ -2,23 +2,28 @@ import { createRequire as __extjsCreateRequire } from "node:module"; const requi
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import pintor from "pintor";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
5
6
|
import { fetchExtensionFromStore } from "extension-from-store";
|
|
6
7
|
import node_fs from "node:fs";
|
|
7
8
|
import node_path from "node:path";
|
|
8
9
|
import { getSpecialFoldersData } from "browser-extension-manifest-fields";
|
|
9
|
-
import content_security_policy_parser from "content-security-policy-parser";
|
|
10
10
|
import { Compilation, sources } from "@rspack/core";
|
|
11
|
+
import content_security_policy_parser from "content-security-policy-parser";
|
|
11
12
|
import { WebSocket, WebSocketServer } from "ws";
|
|
12
|
-
import { browserRowValue, humanWarn, CODES, artifactNoun, prefix as messaging_prefix, card, humanLine, debugLine, stripChannelPrefix, isDebug } from "./
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
13
|
+
import { browserRowValue, humanWarn, CODES, artifactNoun, prefix as messaging_prefix, card, humanLine, debugLine, stripChannelPrefix, isDebug } from "./k~0.mjs";
|
|
14
|
+
import { resolveLocalizedManifestName } from "./e~0.mjs";
|
|
15
|
+
import { productionControlOpen, devtoolsEngineFor, remoteArchiveCacheRoot, getDirs, computePreviewOutputPath, previewHasNothingToRun, asAbsolute, anotherDevSessionActive, previewingSourceFallback, displayPath, previewing, starting, debugPreviewOutput, normalizeBrowser, debugDirs, debugBrowser, collapseHomeDir, previewingCustomOutput, getDistPath, managedDependencyCopyWarning, getProjectStructure, configBrowserOrThrow } from "./cp~0.mjs";
|
|
16
|
+
import { package_namespaceObject } from "./x~0.mjs";
|
|
17
|
+
import { readProjectDependencies } from "./j~0.mjs";
|
|
18
|
+
import { loadCommandConfig, loadBrowserConfig, loadProjectConfigDefaults, findConfigFile } from "./d~0.mjs";
|
|
19
|
+
import { stripBom, parseJsonSafe } from "./5~0.mjs";
|
|
20
|
+
import { isChromiumBasedBrowser, isEmulatorBrowser, isWebkitBasedBrowser, isGeckoBasedBrowser } from "./q~0.mjs";
|
|
21
|
+
import { renameSyncWithRetry } from "./6~0.mjs";
|
|
22
|
+
import { eventsPath as session_paths_eventsPath, actionsPath, logsPath, readyContractPath, ensureSessionArtifactsIgnoreFile, browserArtifactsDir } from "./5h~0.mjs";
|
|
23
|
+
import { real_path_isInsidePath, real_path_isSameOrInsidePath } from "./tm~0.mjs";
|
|
24
|
+
import { omitDevOnlyEntries, excludedFiles, omitExcludedEntries, isScriptsFolderEntry, rememberedFolders, publicFolderSetting } from "./g~0.mjs";
|
|
25
|
+
import { prependBehindTakeBlock } from "./c~0.mjs";
|
|
26
|
+
import { CONTROL_WS_PATH, clearControlToken, writeControlToken } from "./t~0.mjs";
|
|
22
27
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
23
28
|
import { dirname as __rspack_dirname } from "node:path";
|
|
24
29
|
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
@@ -70,7 +75,10 @@ function browserRunnerDisabled(args) {
|
|
|
70
75
|
const runId = String(ready?.runId || '').trim();
|
|
71
76
|
const pid = Number.isInteger(ready?.pid) ? String(ready?.pid) : '';
|
|
72
77
|
const runLabel = runId ? `${runId}${pid ? ` · PID ${pid}` : ''}` : pid ? `PID ${pid}` : '';
|
|
73
|
-
const extensionName =
|
|
78
|
+
const extensionName = resolveLocalizedManifestName(manifest, [
|
|
79
|
+
__rspack_external_node_path_806ed179.dirname(args.manifestPath),
|
|
80
|
+
String(args.distPath || '')
|
|
81
|
+
]) || 'Extension';
|
|
74
82
|
const extensionVersion = String(manifest?.version || '').trim();
|
|
75
83
|
const extensionLabel = extensionVersion ? `${extensionName} ${extensionVersion}` : extensionName;
|
|
76
84
|
const extensionJsVersion = getExtensionVersion();
|
|
@@ -99,6 +107,32 @@ function browserRunnerDisabled(args) {
|
|
|
99
107
|
]
|
|
100
108
|
});
|
|
101
109
|
}
|
|
110
|
+
function devAdditionsNote(additions) {
|
|
111
|
+
const row = (label, value)=>` ${label.padEnd(15)}${pintor.gray(value)}`;
|
|
112
|
+
const valuesOf = (kind)=>[
|
|
113
|
+
...new Set(additions.filter((entry)=>entry.kind === kind).map((e)=>e.value))
|
|
114
|
+
];
|
|
115
|
+
const lines = [];
|
|
116
|
+
const kinds = [
|
|
117
|
+
[
|
|
118
|
+
'permission',
|
|
119
|
+
'permissions'
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
'host_permission',
|
|
123
|
+
'host access'
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
'web_accessible_resource',
|
|
127
|
+
'web_accessible_resources'
|
|
128
|
+
]
|
|
129
|
+
];
|
|
130
|
+
for (const [kind, noun] of kinds){
|
|
131
|
+
const values = valuesOf(kind);
|
|
132
|
+
if (values.length) lines.push(row('Dev only', `${noun} ${values.join(', ')}`));
|
|
133
|
+
}
|
|
134
|
+
return lines.join('\n');
|
|
135
|
+
}
|
|
102
136
|
function shouldWarnPortConflict(requested, actual) {
|
|
103
137
|
const requestedPort = Number(requested);
|
|
104
138
|
return Number.isFinite(requestedPort) && 0 !== requestedPort && requestedPort !== actual;
|
|
@@ -113,6 +147,13 @@ function devServerHostRefused(host) {
|
|
|
113
147
|
const name = host || 'an empty Host header';
|
|
114
148
|
return `${getLoggingPrefix('warn')} The dev server refused a request for the host ${pintor.yellow(name)}.\nAllow it with ${pintor.blue(`--allowed-hosts ${host || '<host>'}`)} or ${pintor.blue('commands.dev.allowedHosts')} in extension.config.js. Both take more than one host, comma-separated on the flag.`;
|
|
115
149
|
}
|
|
150
|
+
function debugSessionPorts(port, controlPort) {
|
|
151
|
+
return `${getLoggingPrefix('debug')} ports port=${port} controlPort=${controlPort ?? 'none'}`;
|
|
152
|
+
}
|
|
153
|
+
function lateBootRegistration(afterMs) {
|
|
154
|
+
const when = 'number' == typeof afterMs ? `${String(Math.round(afterMs / 100) / 10)}s after it started` : 'after it started';
|
|
155
|
+
return `${getLoggingPrefix('warn')} The background registered a content script ${when}, when the first page was already open. If the script did not run on that page, reload it.`;
|
|
156
|
+
}
|
|
116
157
|
function controlBridgeUnavailable(reason) {
|
|
117
158
|
return `${getLoggingPrefix('error')} Extension.js couldn't open the control port.\n${pintor.red(reason)}\nSaves will compile but nothing reloads in the browser. Restart the dev session, and if you passed --host make sure it is an address this machine can listen on.`;
|
|
118
159
|
}
|
|
@@ -145,6 +186,12 @@ function bundlerFatalError(error) {
|
|
|
145
186
|
return `${getLoggingPrefix('error')} The build failed to start.\n${pintor.red(text)}`;
|
|
146
187
|
}
|
|
147
188
|
function devServerRestarting(request) {
|
|
189
|
+
if ('main-world' === request.reason && request.pathChanged) {
|
|
190
|
+
const file = displayPath(request.pathChanged);
|
|
191
|
+
const others = request.alsoChanged ? ` and ${request.alsoChanged} more` : '';
|
|
192
|
+
const why = request.registeredBy ? `for the MAIN world, where ${displayPath(request.registeredBy)} now registers it` : "as a content script, now that nothing registers it into the MAIN world";
|
|
193
|
+
return `${getLoggingPrefix('info')} Restarting the dev server to build ${file}${others} ${why}…`;
|
|
194
|
+
}
|
|
148
195
|
const what = 'icons' === request.reason ? 'a manifest icon' : 'html' === request.reason ? 'an HTML entrypoint' : 'json' === request.reason ? 'a manifest JSON entry' : 'env' === request.reason ? 'an environment file' : 'public' === request.reason ? 'a public folder' : "a manifest script entry";
|
|
149
196
|
const lines = [
|
|
150
197
|
`${getLoggingPrefix('info')} Restarting the dev server to pick up ${what} change…`
|
|
@@ -180,7 +227,6 @@ function runnerUncaughtException(error) {
|
|
|
180
227
|
function runnerUnhandledRejection(reason) {
|
|
181
228
|
return `${messaging_prefix('error')} Unhandled rejection in the dev server: ${String(reason?.message || reason)}`;
|
|
182
229
|
}
|
|
183
|
-
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.39","El":{"@babel/core":"7.29.7","@babel/preset-typescript":"7.29.7","@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"2.2.3","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.43","acorn":"^8.16.0","babel-loader":"10.1.1","babel-preset-solid":"1.9.15","browser-extension-manifest-fields":"^3.0.2","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^18.0.0","es-module-lexer":"^3.0.2","extension-from-store":"^0.2.5","fflate":"^0.8.3","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.9.1","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.23","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"11.0.0","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","vue":"3.5.43","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
|
|
184
230
|
const CONTROL_PORT_ASSET_NAME = 'extension-js-control.json';
|
|
185
231
|
const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
186
232
|
try {
|
|
@@ -194,7 +240,11 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
194
240
|
// connectable host (loopback locally; the public host for remote/devcontainer).
|
|
195
241
|
var HOST = "__EXTJS_CONTROL_HOST__";
|
|
196
242
|
if (!HOST || HOST.indexOf("__EXTJS") === 0) HOST = "127.0.0.1";
|
|
197
|
-
|
|
243
|
+
// A dev background names no session, so its file is the same bytes in
|
|
244
|
+
// every session and a kept profile's cached copy of it is not stale.
|
|
245
|
+
var SESSION_FROM_FILE = "__EXTJS_SESSION_FROM_FILE__" === "1";
|
|
246
|
+
if (SESSION_FROM_FILE) { PORT = 0; INSTANCE_ID = ""; }
|
|
247
|
+
else if (!PORT || PORT < 1) return;
|
|
198
248
|
|
|
199
249
|
var WS = g.WebSocket;
|
|
200
250
|
if (typeof WS !== "function") return;
|
|
@@ -293,9 +343,25 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
293
343
|
} catch (e) { return "chromium"; }
|
|
294
344
|
}
|
|
295
345
|
|
|
346
|
+
// A cycle cannot cross as JSON. Each repeat of an ancestor becomes null,
|
|
347
|
+
// which is what Chromium answers for a value returned from a tab.
|
|
348
|
+
function cycleSafeJson(v) {
|
|
349
|
+
var stack = [];
|
|
350
|
+
return JSON.stringify(v, function (_key, val) {
|
|
351
|
+
while (stack.length && stack[stack.length - 1] !== this) stack.pop();
|
|
352
|
+
if (typeof val === "bigint") val = {__type: "bigint", value: String(val)};
|
|
353
|
+
if (val && typeof val === "object") {
|
|
354
|
+
if (stack.indexOf(val) !== -1) return null;
|
|
355
|
+
stack.push(val);
|
|
356
|
+
}
|
|
357
|
+
return val;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
296
361
|
function safeValue(v) {
|
|
297
362
|
try {
|
|
298
|
-
var s
|
|
363
|
+
var s;
|
|
364
|
+
try { s = JSON.stringify(v); } catch (eCycle) { s = cycleSafeJson(v); }
|
|
299
365
|
if (s === undefined) return {value: undefined, truncated: false};
|
|
300
366
|
if (s.length > MAX_RESULT_BYTES) {
|
|
301
367
|
return {value: {__type: "truncated", preview: s.slice(0, 1024)}, truncated: true};
|
|
@@ -339,9 +405,10 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
339
405
|
}
|
|
340
406
|
}
|
|
341
407
|
|
|
342
|
-
function replyErr(cmdId, name, message, code) {
|
|
408
|
+
function replyErr(cmdId, name, message, code, hint) {
|
|
343
409
|
var frame = {type: "result", cmdId: cmdId, ok: false, error: {name: name, message: String(message), engine: engineName()}};
|
|
344
410
|
if (code) frame.error.code = code;
|
|
411
|
+
if (hint) frame.error.hint = hint;
|
|
345
412
|
try { socket && socket.send(JSON.stringify(frame)); } catch (e) {
|
|
346
413
|
// Ignore
|
|
347
414
|
}
|
|
@@ -364,6 +431,26 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
364
431
|
replyErr(cmdId, fallbackName, msg);
|
|
365
432
|
}
|
|
366
433
|
|
|
434
|
+
// extension open reaches the popup, options and sidebar only. A devtools
|
|
435
|
+
// page runs while DevTools is open on a tab, an override page in its tab.
|
|
436
|
+
// The advice names extension open only where that engine lets it work.
|
|
437
|
+
function surfaceNotOpen(ctx) {
|
|
438
|
+
var engine = engineName();
|
|
439
|
+
var how = "open it first: extension open " + ctx;
|
|
440
|
+
if (engine === "chromium" && (ctx === "popup" || ctx === "sidebar")) {
|
|
441
|
+
how = "open it first: click the extension's toolbar entry, or its row in the extensions menu";
|
|
442
|
+
} else if (engine === "firefox" && ctx === "sidebar") {
|
|
443
|
+
how = "open it first: the sidebar button in the toolbar, or View > Sidebar";
|
|
444
|
+
}
|
|
445
|
+
if (ctx === "devtools") {
|
|
446
|
+
var flag = engine === "firefox" ? "--devtools" : engine === "chromium" ? "--auto-open-devtools-for-tabs" : "";
|
|
447
|
+
how = "the devtools page runs only while DevTools is open on a tab, and extension open cannot open DevTools. Open DevTools on a tab first" + (flag ? ", or start the session with " + flag + " added to EXTENSION_BROWSER_FLAGS" : "");
|
|
448
|
+
} else if (ctx === "newtab" || ctx === "history" || ctx === "bookmarks") {
|
|
449
|
+
how = "open that page in a tab first";
|
|
450
|
+
}
|
|
451
|
+
return {code: "surface_not_open", message: "surface '" + ctx + "' is not open (" + how + ")"};
|
|
452
|
+
}
|
|
453
|
+
|
|
367
454
|
// A surface relay that answered nothing is closed only when the engine
|
|
368
455
|
// says no receiver exists. Any other lastError (a reply the engine could
|
|
369
456
|
// not clone, a channel that closed) means the surface WAS open and ran the
|
|
@@ -376,7 +463,7 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
376
463
|
if (!le && resp) return null;
|
|
377
464
|
var lem = le ? String((le && le.message) || le) : "";
|
|
378
465
|
if (!lem || /receiving end does not exist|could not establish connection/i.test(lem)) {
|
|
379
|
-
return
|
|
466
|
+
return surfaceNotOpen(ctx);
|
|
380
467
|
}
|
|
381
468
|
return {code: "surface_reply_failed", message: "surface '" + ctx + "' answered but the reply did not arrive: " + lem};
|
|
382
469
|
}
|
|
@@ -391,7 +478,8 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
391
478
|
if (mv >= 3) {
|
|
392
479
|
var perms = stringList(m.permissions);
|
|
393
480
|
if (perms.indexOf("scripting") === -1) {
|
|
394
|
-
|
|
481
|
+
var gate = engineName() === "firefox" ? " (Firefox exposes it only with that permission)" : "";
|
|
482
|
+
return "cannot inject into tab " + tabId + ": this MV3 build's manifest has no \\"scripting\\" permission, so chrome.scripting is missing" + gate + ". Add \\"scripting\\" to permissions, or use a dev session (extension dev), which adds it; --context background still works";
|
|
395
483
|
}
|
|
396
484
|
return "cannot inject into tab " + tabId + ": chrome.scripting is missing on this engine even though the manifest declares \\"scripting\\"; use --context background";
|
|
397
485
|
}
|
|
@@ -399,6 +487,47 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
399
487
|
return "cannot inject into tab " + tabId + ": chrome.scripting is not available on this engine; use --context background";
|
|
400
488
|
}
|
|
401
489
|
|
|
490
|
+
// A tab id nobody has is a missing target on any build, so the engine is
|
|
491
|
+
// asked for the tab before the missing permission gets the blame.
|
|
492
|
+
function replyScriptingMissing(cmdId, tabId) {
|
|
493
|
+
nsCall("tabs", "get", [tabId], function (err) {
|
|
494
|
+
var msg = String((err && err.message) || err || "");
|
|
495
|
+
if (err && /no tab with id|invalid tab id/i.test(msg)) {
|
|
496
|
+
replyErr(cmdId, "TargetNotFound", msg, "tab_not_found");
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
replyErr(cmdId, "Unsupported", scriptingMissingReason(tabId), "scripting_unavailable");
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function ownPopupIsOpen(cb) {
|
|
504
|
+
try {
|
|
505
|
+
var ext = (g.browser && g.browser.extension) || (g.chrome && g.chrome.extension);
|
|
506
|
+
if (ext && typeof ext.getViews === "function") { cb(ext.getViews({type: "popup"}).length > 0); return; }
|
|
507
|
+
} catch (e) {
|
|
508
|
+
// Ignore
|
|
509
|
+
}
|
|
510
|
+
var rt = g.chrome && g.chrome.runtime;
|
|
511
|
+
if (!rt || typeof rt.getContexts !== "function") { cb(false); return; }
|
|
512
|
+
try {
|
|
513
|
+
Promise.resolve(rt.getContexts({contextTypes: ["POPUP"]})).then(function (list) { cb(!!(list && list.length)); }, function () { cb(false); });
|
|
514
|
+
} catch (e2) { cb(false); }
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Firefox refuses openPopup while any panel shows. When that panel is this
|
|
518
|
+
// extension's own popup, the caller already has what it asked for.
|
|
519
|
+
function replyOpenPopupFailure(cmdId, err, surface, okValue) {
|
|
520
|
+
var msg = String((err && err.message) || err);
|
|
521
|
+
if (!/another panel is open/i.test(msg)) {
|
|
522
|
+
replyErr(cmdId, "Unsupported", "openPopup: " + msg, openRefusalCode(msg));
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
ownPopupIsOpen(function (open) {
|
|
526
|
+
if (open) { okValue.alreadyOpen = true; replyOk(cmdId, okValue); return; }
|
|
527
|
+
replyErr(cmdId, "Unsupported", "another panel is open in the browser window, and one panel shows at a time (" + msg + ")", "panel_already_open", "Close the open panel, then run extension open " + surface + " again.");
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
|
|
402
531
|
// The page a surface lives in, as the manifest names it, so the background
|
|
403
532
|
// can ask the engine whether that page is open at all.
|
|
404
533
|
function surfacePagePath(ctx) {
|
|
@@ -409,12 +538,30 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
409
538
|
if (ctx === "popup") p = (m.action && m.action.default_popup) || (m.browser_action && m.browser_action.default_popup) || (m.page_action && m.page_action.default_popup);
|
|
410
539
|
else if (ctx === "options") p = (m.options_ui && m.options_ui.page) || m.options_page;
|
|
411
540
|
else if (ctx === "sidebar") p = (m.side_panel && m.side_panel.default_path) || (m.sidebar_action && m.sidebar_action.default_panel);
|
|
541
|
+
else if (ctx === "devtools") p = m.devtools_page;
|
|
412
542
|
else if (ctx === "newtab" || ctx === "history" || ctx === "bookmarks") p = m.chrome_url_overrides && m.chrome_url_overrides[ctx];
|
|
413
543
|
// Character classes on purpose: this source is a template literal, and
|
|
414
544
|
// a backslash escape in a regex would be eaten before it ever ran.
|
|
415
545
|
return typeof p === "string" && p ? p.replace(/^[.]?[/]/, "") : null;
|
|
416
546
|
}
|
|
417
547
|
|
|
548
|
+
function surfaceManifestKeys(ctx) {
|
|
549
|
+
if (ctx === "popup") return "action.default_popup, browser_action.default_popup or page_action.default_popup";
|
|
550
|
+
if (ctx === "options") return "options_ui.page or options_page";
|
|
551
|
+
if (ctx === "sidebar") return "side_panel.default_path or sidebar_action.default_panel";
|
|
552
|
+
if (ctx === "devtools") return "devtools_page";
|
|
553
|
+
return "chrome_url_overrides." + ctx;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// A surface the manifest never declares has no page to open, so asking
|
|
557
|
+
// the caller to open it first would send them after nothing.
|
|
558
|
+
function surfaceNotDeclared(ctx) {
|
|
559
|
+
var m = null;
|
|
560
|
+
try { m = g.chrome.runtime.getManifest(); } catch (e) { return null; }
|
|
561
|
+
if (!m || surfacePagePath(ctx)) return null;
|
|
562
|
+
return {code: "surface_not_declared", message: "the manifest declares no " + ctx + " page: it has no " + surfaceManifestKeys(ctx)};
|
|
563
|
+
}
|
|
564
|
+
|
|
418
565
|
// Chrome says "message port closed" both when the surface died mid-op and
|
|
419
566
|
// when a bystander extension page (the options page, a new tab override)
|
|
420
567
|
// received the message and passed, since a relay returns nothing for a
|
|
@@ -429,7 +576,7 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
429
576
|
if (!page || !rt || typeof rt.getContexts !== "function") { cb(relayErr); return; }
|
|
430
577
|
var wanted = "";
|
|
431
578
|
try { wanted = String(rt.getURL(page)).split(/[?#]/)[0]; } catch (e) { cb(relayErr); return; }
|
|
432
|
-
var notOpen =
|
|
579
|
+
var notOpen = surfaceNotOpen(ctx);
|
|
433
580
|
try {
|
|
434
581
|
Promise.resolve(rt.getContexts({})).then(function (list) {
|
|
435
582
|
var open = false;
|
|
@@ -549,7 +696,8 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
549
696
|
|
|
550
697
|
function replyInjectionErr(cmdId, err) {
|
|
551
698
|
var msg = (err && err.message) || err;
|
|
552
|
-
|
|
699
|
+
var name = injectionErrorName(err);
|
|
700
|
+
replyErr(cmdId, name, msg, injectionRefused(msg) ? "injection_refused" : name === "TargetNotFound" ? "tab_not_found" : undefined);
|
|
553
701
|
}
|
|
554
702
|
|
|
555
703
|
function executeCommand(cmd) {
|
|
@@ -605,7 +753,24 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
605
753
|
target: {tabId: target.tabId},
|
|
606
754
|
world: ctx === "page" ? "MAIN" : "ISOLATED",
|
|
607
755
|
func: async function (src) {
|
|
608
|
-
|
|
756
|
+
// Firefox refuses to clone a cycle or a DOM node out of a tab and
|
|
757
|
+
// Chromium nulls them, so the value takes its JSON form in the tab.
|
|
758
|
+
function __extjsJsonForm(v) {
|
|
759
|
+
var stack = [];
|
|
760
|
+
try {
|
|
761
|
+
var json = JSON.stringify(v, function (_key, val) {
|
|
762
|
+
while (stack.length && stack[stack.length - 1] !== this) stack.pop();
|
|
763
|
+
if (typeof val === "bigint") val = {__type: "bigint", value: String(val)};
|
|
764
|
+
if (val && typeof val === "object") {
|
|
765
|
+
if (stack.indexOf(val) !== -1) return null;
|
|
766
|
+
stack.push(val);
|
|
767
|
+
}
|
|
768
|
+
return val;
|
|
769
|
+
});
|
|
770
|
+
return json === undefined ? undefined : JSON.parse(json);
|
|
771
|
+
} catch (e) { return v; }
|
|
772
|
+
}
|
|
773
|
+
try { return {__extjsEval: 1, ok: true, value: __extjsJsonForm(await eval(src))}; }
|
|
609
774
|
catch (e) { return {__extjsEval: 1, ok: false, name: (e && e.name) || "EvalError", message: (e && e.message) || String(e)}; }
|
|
610
775
|
},
|
|
611
776
|
args: [String(args.expression)]
|
|
@@ -624,6 +789,8 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
624
789
|
replyErr(cmdId, frame.name || "EvalError", frame.message);
|
|
625
790
|
});
|
|
626
791
|
} else if (ctx === "popup" || ctx === "options" || ctx === "sidebar" || ctx === "devtools" || ctx === "newtab" || ctx === "history" || ctx === "bookmarks") {
|
|
792
|
+
var evalUndeclared = surfaceNotDeclared(ctx);
|
|
793
|
+
if (evalUndeclared) { replyErr(cmdId, "Unsupported", evalUndeclared.message, evalUndeclared.code); return; }
|
|
627
794
|
// The SW can't eval in another extension page; ask the surface's
|
|
628
795
|
// own in-bundle relay (only the open, matching-context page responds).
|
|
629
796
|
chrome.runtime.sendMessage(
|
|
@@ -641,9 +808,8 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
641
808
|
}
|
|
642
809
|
);
|
|
643
810
|
} else if (ctx === "content" || ctx === "page") {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
: "eval in context " + ctx + " requires a tabId", target.tabId ? "scripting_unavailable" : undefined);
|
|
811
|
+
if (target.tabId) replyScriptingMissing(cmdId, target.tabId);
|
|
812
|
+
else replyErr(cmdId, "Unsupported", "eval in context " + ctx + " requires a tabId");
|
|
647
813
|
} else {
|
|
648
814
|
replyErr(cmdId, "BadRequest", "unknown eval context: " + ctx);
|
|
649
815
|
}
|
|
@@ -764,10 +930,8 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
764
930
|
var popupNS = popupKey && ACTION_NAMESPACES[popupKey];
|
|
765
931
|
if (popupNS && chrome[popupNS] && chrome[popupNS].openPopup) {
|
|
766
932
|
nsCall(popupNS, "openPopup", [], function (err) {
|
|
767
|
-
if (err) {
|
|
768
|
-
|
|
769
|
-
replyErr(cmdId, "Unsupported", "openPopup: " + openMsg, openRefusalCode(openMsg));
|
|
770
|
-
} else replyOk(cmdId, {opened: "popup"});
|
|
933
|
+
if (err) replyOpenPopupFailure(cmdId, err, "popup", {opened: "popup"});
|
|
934
|
+
else replyOk(cmdId, {opened: "popup"});
|
|
771
935
|
});
|
|
772
936
|
} else { replyErr(cmdId, "Unsupported", (popupNS || "action") + ".openPopup not available", "api_unavailable"); }
|
|
773
937
|
} else if (surface === "options") {
|
|
@@ -797,7 +961,11 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
797
961
|
} else replyOk(cmdId, {opened: "sidebar"});
|
|
798
962
|
});
|
|
799
963
|
});
|
|
800
|
-
} else
|
|
964
|
+
} else if (engineName() === "firefox") {
|
|
965
|
+
// Firefox has no side panel API, and its sidebar opens only inside
|
|
966
|
+
// a user action handler, which a bridge command is not.
|
|
967
|
+
replyErr(cmdId, "Unsupported", "the sidebar comes from sidebar_action here and opens only on a user action, so the CLI cannot open it", "api_unavailable", "Open it from the Firefox sidebar button, or View > Sidebar. Once it is open, extension eval --context sidebar and extension inspect --context sidebar reach it.");
|
|
968
|
+
} else { replyErr(cmdId, "Unsupported", "sidePanel is not available", "api_unavailable"); }
|
|
801
969
|
} else if (surface === "action") {
|
|
802
970
|
// With a popup the click opens it; without one, replay the
|
|
803
971
|
// onClicked listeners captured at install time. The answer names
|
|
@@ -810,10 +978,8 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
810
978
|
getActionPopup(actionKey, tab, function (popup) {
|
|
811
979
|
if (popup) {
|
|
812
980
|
nsCall(actionNS, "openPopup", [], function (err) {
|
|
813
|
-
if (err) {
|
|
814
|
-
|
|
815
|
-
replyErr(cmdId, "Unsupported", "openPopup: " + actMsg, openRefusalCode(actMsg));
|
|
816
|
-
} else replyOk(cmdId, {triggered: "popup", manifestKey: actionKey});
|
|
981
|
+
if (err) replyOpenPopupFailure(cmdId, err, "action", {triggered: "popup", manifestKey: actionKey});
|
|
982
|
+
else replyOk(cmdId, {triggered: "popup", manifestKey: actionKey});
|
|
817
983
|
});
|
|
818
984
|
} else if (clicked.length) {
|
|
819
985
|
var fired = 0;
|
|
@@ -831,7 +997,7 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
831
997
|
}
|
|
832
998
|
});
|
|
833
999
|
});
|
|
834
|
-
} else { replyErr(cmdId, "Unsupported", "the manifest declares no action, browser_action or page_action
|
|
1000
|
+
} else { replyErr(cmdId, "Unsupported", "the manifest declares no action, browser_action or page_action", "surface_not_declared"); }
|
|
835
1001
|
} else if (surface === "command") {
|
|
836
1002
|
var commandName = (args && args.name) || undefined;
|
|
837
1003
|
if (!commandListeners.length) {
|
|
@@ -930,6 +1096,8 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
930
1096
|
replyOk(cmdId, fitSnapshot(snap));
|
|
931
1097
|
});
|
|
932
1098
|
} else if (ctx === "popup" || ctx === "options" || ctx === "sidebar" || ctx === "devtools" || ctx === "newtab" || ctx === "history" || ctx === "bookmarks") {
|
|
1099
|
+
var inspectUndeclared = surfaceNotDeclared(ctx);
|
|
1100
|
+
if (inspectUndeclared) { replyErr(cmdId, "Unsupported", inspectUndeclared.message, inspectUndeclared.code); return; }
|
|
933
1101
|
// The SW can't read a surface page's DOM; ask the surface's own
|
|
934
1102
|
// in-bundle relay (only the open, matching-context page responds).
|
|
935
1103
|
chrome.runtime.sendMessage(
|
|
@@ -947,9 +1115,9 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
947
1115
|
}
|
|
948
1116
|
);
|
|
949
1117
|
} else if ((ctx === "content" || ctx === "page") && target.tabId) {
|
|
950
|
-
|
|
1118
|
+
replyScriptingMissing(cmdId, target.tabId);
|
|
951
1119
|
} else if (ctx === "background") {
|
|
952
|
-
replyErr(cmdId, "Unsupported", "the service worker has no DOM; inspect a content/page (with --tab) or an open surface");
|
|
1120
|
+
replyErr(cmdId, "Unsupported", (engineName() === "chromium" ? "the service worker has no DOM" : "the background has no page to read") + "; inspect a content/page (with --tab) or an open surface");
|
|
953
1121
|
} else {
|
|
954
1122
|
replyErr(cmdId, "Unsupported", "inspect of " + ctx + " requires a tabId (content/page) or an open surface");
|
|
955
1123
|
}
|
|
@@ -1213,8 +1381,20 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1213
1381
|
return match && kinds.indexOf(match[1]) !== -1 ? match[1] : null;
|
|
1214
1382
|
}
|
|
1215
1383
|
|
|
1216
|
-
//
|
|
1217
|
-
//
|
|
1384
|
+
// A reload closes the extension's own tabs on Chromium and leaves them on
|
|
1385
|
+
// the old document on Gecko, so the next generation brings each one back.
|
|
1386
|
+
var PAGE_TABS_KEY = "__extjsDevPageTabs";
|
|
1387
|
+
|
|
1388
|
+
function ownPageUrl(url) {
|
|
1389
|
+
var base = "";
|
|
1390
|
+
try { base = String(g.chrome.runtime.getURL("")); } catch (e) {
|
|
1391
|
+
// Ignore
|
|
1392
|
+
}
|
|
1393
|
+
return !!base && typeof url === "string" && url.indexOf(base) === 0;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
// Records the override tabs and the extension's own page tabs, and answers
|
|
1397
|
+
// with the former. The guard keeps a silent tabs.query off the reload.
|
|
1218
1398
|
function rememberOverrideTabs(cb) {
|
|
1219
1399
|
var chrome = g.chrome;
|
|
1220
1400
|
var answered = false;
|
|
@@ -1230,7 +1410,7 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1230
1410
|
}
|
|
1231
1411
|
};
|
|
1232
1412
|
var kinds = overriddenKinds();
|
|
1233
|
-
if (!
|
|
1413
|
+
if (!chrome.tabs || !chrome.tabs.query || !chrome.storage || !chrome.storage.local) return answer([]);
|
|
1234
1414
|
try { guard = setTimeout(function () { answer([]); }, 1000); } catch (e) {
|
|
1235
1415
|
// Ignore
|
|
1236
1416
|
}
|
|
@@ -1238,15 +1418,21 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1238
1418
|
chrome.tabs.query({}, function (tabs) {
|
|
1239
1419
|
noopLastError();
|
|
1240
1420
|
var list = [];
|
|
1421
|
+
var pages = [];
|
|
1241
1422
|
for (var i = 0; tabs && i < tabs.length; i++) {
|
|
1242
1423
|
var t = tabs[i];
|
|
1243
|
-
|
|
1424
|
+
if (!t || t.id == null) continue;
|
|
1425
|
+
var kind = kinds.length ? overrideKindOf(t.url, kinds) : null;
|
|
1244
1426
|
if (kind) list.push({tabId: t.id, surface: kind, url: t.url});
|
|
1427
|
+
else if (ownPageUrl(t.url)) {
|
|
1428
|
+
pages.push({tabId: t.id, url: t.url, windowId: t.windowId, index: t.index, active: t.active === true, pinned: t.pinned === true});
|
|
1429
|
+
}
|
|
1245
1430
|
}
|
|
1246
|
-
if (!list.length) return answer(list);
|
|
1431
|
+
if (!list.length && !pages.length) return answer(list);
|
|
1247
1432
|
try {
|
|
1248
1433
|
var rec = {};
|
|
1249
|
-
rec[OVERRIDE_TABS_KEY] = {at: Date.now(), tabs: list};
|
|
1434
|
+
if (list.length) rec[OVERRIDE_TABS_KEY] = {at: Date.now(), tabs: list};
|
|
1435
|
+
if (pages.length) rec[PAGE_TABS_KEY] = {at: Date.now(), tabs: pages};
|
|
1250
1436
|
chrome.storage.local.set(rec, function () { noopLastError(); answer(list); });
|
|
1251
1437
|
} catch (e) { answer([]); }
|
|
1252
1438
|
});
|
|
@@ -1316,6 +1502,107 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1316
1502
|
});
|
|
1317
1503
|
}
|
|
1318
1504
|
|
|
1505
|
+
function reopenPageTab(page) {
|
|
1506
|
+
var chrome = g.chrome;
|
|
1507
|
+
var plain = function () {
|
|
1508
|
+
try { chrome.tabs.create({url: page.url, active: page.active === true}, noopLastError); } catch (e) {
|
|
1509
|
+
// Ignore
|
|
1510
|
+
}
|
|
1511
|
+
};
|
|
1512
|
+
try {
|
|
1513
|
+
chrome.tabs.create(
|
|
1514
|
+
{url: page.url, windowId: page.windowId, index: page.index, active: page.active === true, pinned: page.pinned === true},
|
|
1515
|
+
function () {
|
|
1516
|
+
var failed = false;
|
|
1517
|
+
try { failed = !!chrome.runtime.lastError; } catch (e) {
|
|
1518
|
+
// Ignore
|
|
1519
|
+
}
|
|
1520
|
+
// The window went with its last tab, so any window will do.
|
|
1521
|
+
if (failed) plain();
|
|
1522
|
+
}
|
|
1523
|
+
);
|
|
1524
|
+
} catch (e) { plain(); }
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// A tab still open is reloaded, one the browser closed is opened again
|
|
1528
|
+
// unless the extension did so itself. Each recorded tab once.
|
|
1529
|
+
function restorePageTabsAtBoot() {
|
|
1530
|
+
var chrome = g.chrome;
|
|
1531
|
+
if (!chrome || !chrome.storage || !chrome.storage.local || !chrome.tabs || !chrome.tabs.query) return;
|
|
1532
|
+
chrome.storage.local.get(PAGE_TABS_KEY, function (res) {
|
|
1533
|
+
noopLastError();
|
|
1534
|
+
var rec = res && res[PAGE_TABS_KEY];
|
|
1535
|
+
if (!rec || typeof rec !== "object" || !Array.isArray(rec.tabs)) return;
|
|
1536
|
+
try { chrome.storage.local.remove(PAGE_TABS_KEY, noopLastError); } catch (e) {
|
|
1537
|
+
// Ignore
|
|
1538
|
+
}
|
|
1539
|
+
if (typeof rec.at !== "number" || Date.now() - rec.at > 30000) return;
|
|
1540
|
+
setTimeout(function () {
|
|
1541
|
+
try {
|
|
1542
|
+
chrome.tabs.query({}, function (tabs) {
|
|
1543
|
+
noopLastError();
|
|
1544
|
+
var open = {};
|
|
1545
|
+
var byId = {};
|
|
1546
|
+
for (var i = 0; tabs && i < tabs.length; i++) {
|
|
1547
|
+
var t = tabs[i];
|
|
1548
|
+
if (!t || t.id == null) continue;
|
|
1549
|
+
byId[t.id] = t;
|
|
1550
|
+
if (typeof t.url === "string") open[t.url] = true;
|
|
1551
|
+
}
|
|
1552
|
+
for (var p = 0; p < rec.tabs.length; p++) {
|
|
1553
|
+
var page = rec.tabs[p];
|
|
1554
|
+
if (!page || typeof page.url !== "string" || !ownPageUrl(page.url)) continue;
|
|
1555
|
+
var kept = byId[page.tabId];
|
|
1556
|
+
// A tab that is still there and shows something else moved on.
|
|
1557
|
+
if (kept) {
|
|
1558
|
+
if (kept.url === page.url) {
|
|
1559
|
+
try { chrome.tabs.reload(page.tabId, {bypassCache: true}, noopLastError); } catch (e) {
|
|
1560
|
+
// Ignore
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
continue;
|
|
1564
|
+
}
|
|
1565
|
+
if (open[page.url] || !chrome.tabs.create) continue;
|
|
1566
|
+
open[page.url] = true;
|
|
1567
|
+
reopenPageTab(page);
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
} catch (e) {
|
|
1571
|
+
// Ignore
|
|
1572
|
+
}
|
|
1573
|
+
}, 500);
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
// A page the build ships as written has no dev client to refresh it, so
|
|
1578
|
+
// the open tabs that show it are reloaded from here.
|
|
1579
|
+
function reloadStandalonePages(files) {
|
|
1580
|
+
var chrome = g.chrome;
|
|
1581
|
+
if (!Array.isArray(files) || !files.length || !chrome || !chrome.tabs || !chrome.tabs.query || !chrome.tabs.reload) return;
|
|
1582
|
+
var wanted = {};
|
|
1583
|
+
for (var i = 0; i < files.length; i++) {
|
|
1584
|
+
if (typeof files[i] !== "string") continue;
|
|
1585
|
+
try { wanted[String(chrome.runtime.getURL(scriptFileName(files[i])))] = true; } catch (e) {
|
|
1586
|
+
// Ignore
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
try {
|
|
1590
|
+
chrome.tabs.query({}, function (tabs) {
|
|
1591
|
+
noopLastError();
|
|
1592
|
+
for (var t = 0; tabs && t < tabs.length; t++) {
|
|
1593
|
+
var tab = tabs[t];
|
|
1594
|
+
if (!tab || tab.id == null || typeof tab.url !== "string") continue;
|
|
1595
|
+
if (!wanted[tab.url.replace(/[?#].*$/, "")]) continue;
|
|
1596
|
+
try { chrome.tabs.reload(tab.id, {bypassCache: true}, noopLastError); } catch (e) {
|
|
1597
|
+
// Ignore
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
} catch (e) {
|
|
1602
|
+
// Ignore
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1319
1606
|
// Dev-loop reload without the CDP controller: content-scripts reload the
|
|
1320
1607
|
// matching tabs at the new bundle, or re-inject in place where no registry
|
|
1321
1608
|
// exists; service-worker/full/manifest restart the extension.
|
|
@@ -1359,34 +1646,984 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1359
1646
|
// ISOLATED-world console also lands it in the dev-server log stream.
|
|
1360
1647
|
function announceReloadInTabs(text) {
|
|
1361
1648
|
var chrome = g.chrome;
|
|
1362
|
-
if (!chrome || !chrome.tabs || !chrome.tabs.query) return;
|
|
1649
|
+
if (!chrome || !chrome.tabs || !chrome.tabs.query) return;
|
|
1650
|
+
try {
|
|
1651
|
+
chrome.tabs.query({}, function (tabs) {
|
|
1652
|
+
noopLastError();
|
|
1653
|
+
if (!tabs) return;
|
|
1654
|
+
for (var i = 0; i < tabs.length; i++) {
|
|
1655
|
+
(function (tab) {
|
|
1656
|
+
if (!tab || tab.id == null || !isInjectableUrl(tab.url)) return;
|
|
1657
|
+
if (chrome.scripting && chrome.scripting.executeScript) {
|
|
1658
|
+
try {
|
|
1659
|
+
chrome.scripting.executeScript(
|
|
1660
|
+
{target: {tabId: tab.id}, func: function (t) { console.log(t); }, args: [text]},
|
|
1661
|
+
noopLastError
|
|
1662
|
+
);
|
|
1663
|
+
return;
|
|
1664
|
+
} catch (e) {
|
|
1665
|
+
// Ignore
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
// MV2 fallback (Firefox without the scripting API).
|
|
1669
|
+
if (chrome.tabs.executeScript) {
|
|
1670
|
+
try {
|
|
1671
|
+
chrome.tabs.executeScript(tab.id, {code: "console.log(" + JSON.stringify(text) + ");"}, noopLastError);
|
|
1672
|
+
} catch (e) {
|
|
1673
|
+
// Ignore
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
})(tabs[i]);
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
} catch (e) {
|
|
1680
|
+
// Ignore
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
// The scripts-replay shim (plugin-reload) keeps the SW's own
|
|
1685
|
+
// executeScript registry; the replay is fire-and-forget by design.
|
|
1686
|
+
// The answer is the number of open tabs a changed file ran in again.
|
|
1687
|
+
function replayProgrammaticScripts(changedScriptFiles, done) {
|
|
1688
|
+
var answer = function (outcomes) {
|
|
1689
|
+
var tabs = {};
|
|
1690
|
+
var count = 0;
|
|
1691
|
+
for (var i = 0; Array.isArray(outcomes) && i < outcomes.length; i++) {
|
|
1692
|
+
var one = outcomes[i];
|
|
1693
|
+
if (!one || !one.ok || tabs[one.tabId]) continue;
|
|
1694
|
+
tabs[one.tabId] = true;
|
|
1695
|
+
count++;
|
|
1696
|
+
}
|
|
1697
|
+
if (done) done(count);
|
|
1698
|
+
};
|
|
1699
|
+
if (!Array.isArray(changedScriptFiles) || changedScriptFiles.length === 0) return answer();
|
|
1700
|
+
var replay = g.__extjsScriptsReplay;
|
|
1701
|
+
if (typeof replay !== "function") return answer();
|
|
1702
|
+
try {
|
|
1703
|
+
var outcome = replay(changedScriptFiles);
|
|
1704
|
+
if (outcome && typeof outcome.then === "function") {
|
|
1705
|
+
outcome.then(answer, function () { answer(); });
|
|
1706
|
+
} else answer();
|
|
1707
|
+
} catch (e) { answer(); }
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
// The receipt of a reload that reloads nothing itself waits a moment
|
|
1711
|
+
// for its replay, so it can say how many tabs ran the file again.
|
|
1712
|
+
var REPLAY_RECEIPT_WAIT_MS = 500;
|
|
1713
|
+
var sendHeldReloadAck = null;
|
|
1714
|
+
|
|
1715
|
+
// The browser reads a file named in scripting.registerContentScripts when
|
|
1716
|
+
// the script is registered, so an edit reaches no page until it reads again.
|
|
1717
|
+
var REGISTERED_RELOAD_KEY = "__extjsDevRegisteredReload";
|
|
1718
|
+
|
|
1719
|
+
function scriptFileName(value) {
|
|
1720
|
+
return String(value || "").replace(/^[/]+/, "");
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
// Gecko reads a registered file once per address and keeps that copy
|
|
1724
|
+
// through an update and a tab reload. A new address is read from disk.
|
|
1725
|
+
var SCRIPT_ADDRESS_QUERY = "?extjs-dev=";
|
|
1726
|
+
var SCRIPT_VERSIONS_KEY = "__extjsDevScriptVersions";
|
|
1727
|
+
var scriptVersions = null;
|
|
1728
|
+
var scriptVersionWaiters = [];
|
|
1729
|
+
var scriptVersionCount = 0;
|
|
1730
|
+
var wrappedRegistries = [];
|
|
1731
|
+
var nativeRegistry = null;
|
|
1732
|
+
var registryCalls = 0;
|
|
1733
|
+
// An entry no registration has, so the browser refuses a call that
|
|
1734
|
+
// names it and changes nothing.
|
|
1735
|
+
var SHAPE_REFUSED = {id: "_extjs-dev-shape", js: ["extjs-dev-shape.js"], matches: ["*://extjs.invalid/*"]};
|
|
1736
|
+
var registryCalledAt = 0;
|
|
1737
|
+
|
|
1738
|
+
function plainScriptAddress(value) {
|
|
1739
|
+
var name = String(value || "");
|
|
1740
|
+
var at = name.indexOf(SCRIPT_ADDRESS_QUERY);
|
|
1741
|
+
return at === -1 ? name : name.slice(0, at);
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
// A name that carries its own query or fragment is the author's address.
|
|
1745
|
+
function scriptAddress(value) {
|
|
1746
|
+
var plain = plainScriptAddress(value);
|
|
1747
|
+
if (plain.indexOf("?") !== -1 || plain.indexOf("#") !== -1) return plain;
|
|
1748
|
+
var version = scriptVersions ? scriptVersions[scriptFileName(plain)] : null;
|
|
1749
|
+
return typeof version === "string" ? plain + SCRIPT_ADDRESS_QUERY + version : plain;
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
function withFileNames(scripts, rename) {
|
|
1753
|
+
if (!Array.isArray(scripts)) return scripts;
|
|
1754
|
+
var renamed = function (files) {
|
|
1755
|
+
var out = [];
|
|
1756
|
+
for (var f = 0; f < files.length; f++) out.push(typeof files[f] === "string" ? rename(files[f]) : files[f]);
|
|
1757
|
+
return out;
|
|
1758
|
+
};
|
|
1759
|
+
var list = [];
|
|
1760
|
+
for (var i = 0; i < scripts.length; i++) {
|
|
1761
|
+
var script = scripts[i];
|
|
1762
|
+
if (!script || typeof script !== "object") { list.push(script); continue; }
|
|
1763
|
+
var copy = {};
|
|
1764
|
+
for (var key in script) {
|
|
1765
|
+
if (Object.prototype.hasOwnProperty.call(script, key)) copy[key] = script[key];
|
|
1766
|
+
}
|
|
1767
|
+
if (Array.isArray(script.js)) copy.js = renamed(script.js);
|
|
1768
|
+
if (Array.isArray(script.css)) copy.css = renamed(script.css);
|
|
1769
|
+
list.push(copy);
|
|
1770
|
+
}
|
|
1771
|
+
return list;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// Session storage outlives a suspended background and is emptied by an
|
|
1775
|
+
// extension reload, which is when every address is read again anyway.
|
|
1776
|
+
function withScriptVersions(cb) {
|
|
1777
|
+
if (scriptVersions) return cb();
|
|
1778
|
+
scriptVersionWaiters.push(cb);
|
|
1779
|
+
if (scriptVersionWaiters.length > 1) return;
|
|
1780
|
+
var done = function (map) {
|
|
1781
|
+
if (!scriptVersions) scriptVersions = map && typeof map === "object" ? map : {};
|
|
1782
|
+
var fns = scriptVersionWaiters;
|
|
1783
|
+
scriptVersionWaiters = [];
|
|
1784
|
+
for (var i = 0; i < fns.length; i++) { try { fns[i](); } catch (e) {
|
|
1785
|
+
// Ignore
|
|
1786
|
+
} }
|
|
1787
|
+
};
|
|
1788
|
+
try { setTimeout(function () { done(null); }, 1000); } catch (e) {
|
|
1789
|
+
// Ignore
|
|
1790
|
+
}
|
|
1791
|
+
try {
|
|
1792
|
+
g.chrome.storage.session.get(SCRIPT_VERSIONS_KEY, function (res) {
|
|
1793
|
+
noopLastError();
|
|
1794
|
+
done(res && res[SCRIPT_VERSIONS_KEY]);
|
|
1795
|
+
});
|
|
1796
|
+
} catch (e) { done(null); }
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// The author's calls keep the names they wrote: a write takes the current
|
|
1800
|
+
// address of each file, and a read gives the plain names back.
|
|
1801
|
+
function wrapScriptRegistry(scripting) {
|
|
1802
|
+
if (!scripting || wrappedRegistries.indexOf(scripting) !== -1) return;
|
|
1803
|
+
if (typeof scripting.registerContentScripts !== "function" || typeof scripting.updateContentScripts !== "function") return;
|
|
1804
|
+
wrappedRegistries.push(scripting);
|
|
1805
|
+
var natives = {};
|
|
1806
|
+
// One namespace of an engine can answer a callback and hand nothing
|
|
1807
|
+
// back, so a single read tells which of the two forms this one has.
|
|
1808
|
+
var style = null;
|
|
1809
|
+
var answersCallback = function () {
|
|
1810
|
+
if (style === null) {
|
|
1811
|
+
var read;
|
|
1812
|
+
try { read = natives.getRegisteredContentScripts(); } catch (e) { style = false; return style; }
|
|
1813
|
+
style = !(read && typeof read.then === "function");
|
|
1814
|
+
if (!style) read.then(function () {}, function () {});
|
|
1815
|
+
}
|
|
1816
|
+
return style;
|
|
1817
|
+
};
|
|
1818
|
+
var wrapWrite = function (method, addresses) {
|
|
1819
|
+
if (typeof scripting[method] !== "function") return;
|
|
1820
|
+
var native = scripting[method].bind(scripting);
|
|
1821
|
+
natives[method] = native;
|
|
1822
|
+
scripting[method] = function () {
|
|
1823
|
+
var args = [].slice.call(arguments);
|
|
1824
|
+
var last = args.length - 1;
|
|
1825
|
+
var done = last >= 0 && typeof args[last] === "function" ? args[last] : null;
|
|
1826
|
+
registryCalls++;
|
|
1827
|
+
registryCalledAt = Date.now();
|
|
1828
|
+
var settled = false;
|
|
1829
|
+
var settle = function () {
|
|
1830
|
+
if (settled) return;
|
|
1831
|
+
settled = true;
|
|
1832
|
+
registryCalls--;
|
|
1833
|
+
registryCalledAt = Date.now();
|
|
1834
|
+
};
|
|
1835
|
+
var call = function () {
|
|
1836
|
+
if (addresses) args[0] = withFileNames(args[0], scriptAddress);
|
|
1837
|
+
if (done) args[last] = function () { settle(); return done.apply(this, arguments); };
|
|
1838
|
+
// The error is left unread, so the browser still names it.
|
|
1839
|
+
else if (answersCallback()) args.push(function () { settle(); });
|
|
1840
|
+
var ret = native.apply(null, args);
|
|
1841
|
+
if (done) return ret;
|
|
1842
|
+
if (ret && typeof ret.then === "function") ret.then(settle, settle);
|
|
1843
|
+
else if (!answersCallback()) settle();
|
|
1844
|
+
return ret;
|
|
1845
|
+
};
|
|
1846
|
+
if (!addresses || scriptVersions || !Array.isArray(args[0])) {
|
|
1847
|
+
try { return call(); } catch (e) { settle(); throw e; }
|
|
1848
|
+
}
|
|
1849
|
+
// The browser checks the shape of a call as it is made. The same
|
|
1850
|
+
// call with an entry it refuses later throws that check here.
|
|
1851
|
+
try {
|
|
1852
|
+
var refusal = method === "registerContentScripts" ? [SHAPE_REFUSED, SHAPE_REFUSED] : [{id: SHAPE_REFUSED.id}];
|
|
1853
|
+
var probe = [args[0].concat(refusal)];
|
|
1854
|
+
if (done || answersCallback()) probe.push(noopLastError);
|
|
1855
|
+
var refused;
|
|
1856
|
+
try { refused = native.apply(null, probe); } catch (e) {
|
|
1857
|
+
if (!done) throw e;
|
|
1858
|
+
probe.pop();
|
|
1859
|
+
refused = native.apply(null, probe);
|
|
1860
|
+
}
|
|
1861
|
+
if (refused && typeof refused.then === "function") refused.then(function () {}, function () {});
|
|
1862
|
+
} catch (e) { settle(); throw e; }
|
|
1863
|
+
// A call that hands nothing back is answered the same way here.
|
|
1864
|
+
if (done || answersCallback()) {
|
|
1865
|
+
withScriptVersions(function () { try { call(); } catch (e) { settle(); } });
|
|
1866
|
+
return undefined;
|
|
1867
|
+
}
|
|
1868
|
+
return new Promise(function (resolve, reject) {
|
|
1869
|
+
withScriptVersions(function () { try { resolve(call()); } catch (e) { settle(); reject(e); } });
|
|
1870
|
+
});
|
|
1871
|
+
};
|
|
1872
|
+
};
|
|
1873
|
+
if (typeof scripting.getRegisteredContentScripts !== "function") style = false;
|
|
1874
|
+
else natives.getRegisteredContentScripts = scripting.getRegisteredContentScripts.bind(scripting);
|
|
1875
|
+
wrapWrite("registerContentScripts", true);
|
|
1876
|
+
wrapWrite("updateContentScripts", true);
|
|
1877
|
+
wrapWrite("unregisterContentScripts", false);
|
|
1878
|
+
if (typeof scripting.getRegisteredContentScripts === "function") {
|
|
1879
|
+
var nativeRead = natives.getRegisteredContentScripts;
|
|
1880
|
+
var plain = function (list) { return withFileNames(list, plainScriptAddress); };
|
|
1881
|
+
scripting.getRegisteredContentScripts = function () {
|
|
1882
|
+
var args = [].slice.call(arguments);
|
|
1883
|
+
var last = args.length - 1;
|
|
1884
|
+
if (last >= 0 && typeof args[last] === "function") {
|
|
1885
|
+
var done = args[last];
|
|
1886
|
+
args[last] = function (list) { return done.call(this, plain(list)); };
|
|
1887
|
+
return nativeRead.apply(null, args);
|
|
1888
|
+
}
|
|
1889
|
+
var ret = nativeRead.apply(null, args);
|
|
1890
|
+
return ret && typeof ret.then === "function" ? ret.then(plain) : ret;
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
wrapInjection(scripting, answersCallback);
|
|
1894
|
+
if (!nativeRegistry) nativeRegistry = natives;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
// Gecko runs the copy of an injected file it read first at an address,
|
|
1898
|
+
// so a file edited since is named at its current one, as a registration is.
|
|
1899
|
+
function wrapInjection(scripting, answersCallback) {
|
|
1900
|
+
if (typeof scripting.executeScript !== "function") return;
|
|
1901
|
+
var native = scripting.executeScript.bind(scripting);
|
|
1902
|
+
scripting.executeScript = function (injection) {
|
|
1903
|
+
var args = [].slice.call(arguments);
|
|
1904
|
+
var last = args.length - 1;
|
|
1905
|
+
var done = last > 0 && typeof args[last] === "function";
|
|
1906
|
+
var target = injection && typeof injection === "object" ? injection.target : null;
|
|
1907
|
+
if (!target || typeof target !== "object" || !Array.isArray(injection.files)) return native.apply(null, args);
|
|
1908
|
+
var call = function () {
|
|
1909
|
+
var copy = {};
|
|
1910
|
+
for (var key in injection) {
|
|
1911
|
+
if (Object.prototype.hasOwnProperty.call(injection, key)) copy[key] = injection[key];
|
|
1912
|
+
}
|
|
1913
|
+
copy.files = [];
|
|
1914
|
+
for (var f = 0; f < injection.files.length; f++) {
|
|
1915
|
+
copy.files.push(typeof injection.files[f] === "string" ? scriptAddress(injection.files[f]) : injection.files[f]);
|
|
1916
|
+
}
|
|
1917
|
+
args[0] = copy;
|
|
1918
|
+
return native.apply(null, args);
|
|
1919
|
+
};
|
|
1920
|
+
if (scriptVersions) return call();
|
|
1921
|
+
if (typeof target.tabId !== "number") return native.apply(null, args);
|
|
1922
|
+
// The browser checks the shape of a call as it is made. The same
|
|
1923
|
+
// call on a tab that cannot exist throws that check here.
|
|
1924
|
+
var probe = args.slice();
|
|
1925
|
+
var nowhere = {};
|
|
1926
|
+
for (var name in target) {
|
|
1927
|
+
if (Object.prototype.hasOwnProperty.call(target, name)) nowhere[name] = target[name];
|
|
1928
|
+
}
|
|
1929
|
+
nowhere.tabId = -1;
|
|
1930
|
+
probe[0] = {};
|
|
1931
|
+
for (var field in injection) {
|
|
1932
|
+
if (Object.prototype.hasOwnProperty.call(injection, field)) probe[0][field] = injection[field];
|
|
1933
|
+
}
|
|
1934
|
+
probe[0].target = nowhere;
|
|
1935
|
+
var unanswered = !done && answersCallback();
|
|
1936
|
+
if (done) probe[last] = noopLastError;
|
|
1937
|
+
else if (unanswered) probe.push(noopLastError);
|
|
1938
|
+
var refused = native.apply(null, probe);
|
|
1939
|
+
if (refused && typeof refused.then === "function") refused.then(function () {}, function () {});
|
|
1940
|
+
if (done || unanswered) {
|
|
1941
|
+
withScriptVersions(function () { try { call(); } catch (e) {
|
|
1942
|
+
// Ignore
|
|
1943
|
+
} });
|
|
1944
|
+
return undefined;
|
|
1945
|
+
}
|
|
1946
|
+
return new Promise(function (resolve, reject) {
|
|
1947
|
+
withScriptVersions(function () { try { resolve(call()); } catch (e) { reject(e); } });
|
|
1948
|
+
});
|
|
1949
|
+
};
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
function canAddressRegisteredScripts() {
|
|
1953
|
+
var chrome = g.chrome;
|
|
1954
|
+
return !!(
|
|
1955
|
+
engineName() === "firefox" && nativeRegistry && nativeRegistry.updateContentScripts &&
|
|
1956
|
+
chrome && chrome.storage && chrome.storage.session && chrome.storage.session.get && chrome.storage.session.set
|
|
1957
|
+
);
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
// Installed before the background's own code runs, so its first call
|
|
1961
|
+
// already goes through here.
|
|
1962
|
+
function installScriptAddresses() {
|
|
1963
|
+
var chrome = g.chrome;
|
|
1964
|
+
if (engineName() !== "firefox" || !chrome || !chrome.storage || !chrome.storage.session || !chrome.storage.session.get) return;
|
|
1965
|
+
var roots = [g.chrome, g.browser];
|
|
1966
|
+
for (var i = 0; i < roots.length; i++) {
|
|
1967
|
+
try { wrapScriptRegistry(roots[i] && roots[i].scripting); } catch (e) {
|
|
1968
|
+
// Ignore
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
if (nativeRegistry) withScriptVersions(function () {});
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
// The first page of a session waits for the registrations a background
|
|
1975
|
+
// makes as it starts, so its boot is watched from the first line.
|
|
1976
|
+
var BOOT_IDLE_CHECK_MS = 25;
|
|
1977
|
+
var BOOT_EVENTS_GRACE_MS = 250;
|
|
1978
|
+
var BOOT_GIVE_UP_MS = 4000;
|
|
1979
|
+
var BOOT_LATE_WINDOW_MS = 15000;
|
|
1980
|
+
|
|
1981
|
+
function watchBootRegistrations() {
|
|
1982
|
+
if (g.__extjsDevBootRegisters !== true) return;
|
|
1983
|
+
var bootedAt = Date.now();
|
|
1984
|
+
var inFlight = 0;
|
|
1985
|
+
var calls = 0;
|
|
1986
|
+
var landed = false;
|
|
1987
|
+
var reported = false;
|
|
1988
|
+
var lateSaid = false;
|
|
1989
|
+
var counted = [];
|
|
1990
|
+
var failed = function () {
|
|
1991
|
+
try { return !!(g.chrome && g.chrome.runtime && g.chrome.runtime.lastError); } catch (e) { return false; }
|
|
1992
|
+
};
|
|
1993
|
+
var devId = function (entry) {
|
|
1994
|
+
var id = entry && typeof entry === "object" ? entry.id : entry;
|
|
1995
|
+
return typeof id === "string" && id.indexOf("extjs-dev-cs-") === 0;
|
|
1996
|
+
};
|
|
1997
|
+
// The dev build registers the manifest's own scripts through the same
|
|
1998
|
+
// calls, and those are not the author's registrations.
|
|
1999
|
+
var ownCall = function (first) {
|
|
2000
|
+
var list = Array.isArray(first) ? first : first && Array.isArray(first.ids) ? first.ids : null;
|
|
2001
|
+
if (!list || !list.length) return false;
|
|
2002
|
+
for (var i = 0; i < list.length; i++) if (!devId(list[i])) return false;
|
|
2003
|
+
return true;
|
|
2004
|
+
};
|
|
2005
|
+
// A registration that answers after the page was let go is on no open
|
|
2006
|
+
// page, which the author is told once.
|
|
2007
|
+
var land = function () {
|
|
2008
|
+
landed = true;
|
|
2009
|
+
if (!reported || lateSaid || Date.now() - bootedAt > BOOT_LATE_WINDOW_MS) return;
|
|
2010
|
+
lateSaid = true;
|
|
2011
|
+
send({type: "boot-registrations", late: true, afterMs: Date.now() - bootedAt});
|
|
2012
|
+
};
|
|
2013
|
+
// Any call the boot code is waiting on can be the one a registration
|
|
2014
|
+
// follows, so each is counted until the browser answers it.
|
|
2015
|
+
var count = function (owner, key, registry, method) {
|
|
2016
|
+
var inner = owner[key];
|
|
2017
|
+
if (typeof inner !== "function" || inner.__extjsBootCounted) return;
|
|
2018
|
+
var wrapper = function () {
|
|
2019
|
+
var args = [].slice.call(arguments);
|
|
2020
|
+
var self = method ? this : owner;
|
|
2021
|
+
if (registry && ownCall(args[0])) return inner.apply(self, args);
|
|
2022
|
+
var last = args.length - 1;
|
|
2023
|
+
var done = last >= 0 && typeof args[last] === "function" ? args[last] : null;
|
|
2024
|
+
var settled = false;
|
|
2025
|
+
var settle = function (ok) {
|
|
2026
|
+
if (settled) return;
|
|
2027
|
+
settled = true;
|
|
2028
|
+
inFlight--;
|
|
2029
|
+
if (ok && registry === "write") land();
|
|
2030
|
+
};
|
|
2031
|
+
inFlight++;
|
|
2032
|
+
if (registry) calls++;
|
|
2033
|
+
if (done) args[last] = function () { settle(!failed()); return done.apply(this, arguments); };
|
|
2034
|
+
var ret;
|
|
2035
|
+
try { ret = inner.apply(self, args); } catch (e) { settle(false); throw e; }
|
|
2036
|
+
if (done) return ret;
|
|
2037
|
+
if (!ret || typeof ret.then !== "function") { settle(true); return ret; }
|
|
2038
|
+
// The caller gets the same outcome, so a rejection it ignores is
|
|
2039
|
+
// still reported as unhandled.
|
|
2040
|
+
return ret.then(function (value) { settle(true); return value; }, function (error) { settle(false); throw error; });
|
|
2041
|
+
};
|
|
2042
|
+
wrapper.__extjsBootCounted = true;
|
|
2043
|
+
try {
|
|
2044
|
+
owner[key] = wrapper;
|
|
2045
|
+
if (owner[key] === wrapper) counted.push({owner: owner, key: key, inner: inner, wrapper: wrapper, kept: !!registry});
|
|
2046
|
+
} catch (e) {
|
|
2047
|
+
// Ignore
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
var walk = function (owner, depth, seen) {
|
|
2051
|
+
var keys = [];
|
|
2052
|
+
try { keys = Object.keys(owner); } catch (e) {
|
|
2053
|
+
// Ignore
|
|
2054
|
+
}
|
|
2055
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2056
|
+
var value;
|
|
2057
|
+
try { value = owner[keys[i]]; } catch (e) { continue; }
|
|
2058
|
+
if (typeof value === "function") { count(owner, keys[i], null); continue; }
|
|
2059
|
+
if (!value || typeof value !== "object" || depth >= 3 || seen.indexOf(value) !== -1) continue;
|
|
2060
|
+
// An event has listeners, not answers.
|
|
2061
|
+
if (typeof value.addListener === "function") continue;
|
|
2062
|
+
seen.push(value);
|
|
2063
|
+
walk(value, depth + 1, seen);
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
// A registration a profile kept from an earlier session is already
|
|
2067
|
+
// there for the first page, whatever the background does next.
|
|
2068
|
+
var readKept = function (scripting) {
|
|
2069
|
+
if (typeof scripting.getRegisteredContentScripts !== "function") return;
|
|
2070
|
+
inFlight++;
|
|
2071
|
+
var answered = false;
|
|
2072
|
+
var answer = function (list) {
|
|
2073
|
+
if (answered) return;
|
|
2074
|
+
answered = true;
|
|
2075
|
+
inFlight--;
|
|
2076
|
+
for (var i = 0; list && i < list.length; i++) {
|
|
2077
|
+
if (list[i] && typeof list[i].id === "string" && !devId(list[i])) landed = true;
|
|
2078
|
+
}
|
|
2079
|
+
};
|
|
2080
|
+
try {
|
|
2081
|
+
var ret = scripting.getRegisteredContentScripts(function (list) { noopLastError(); answer(list); });
|
|
2082
|
+
if (ret && typeof ret.then === "function") ret.then(answer, function () { answer(null); });
|
|
2083
|
+
} catch (e) { answer(null); }
|
|
2084
|
+
};
|
|
2085
|
+
var roots = [g.chrome, g.browser];
|
|
2086
|
+
var seen = [];
|
|
2087
|
+
var read = false;
|
|
2088
|
+
for (var r = 0; r < roots.length; r++) {
|
|
2089
|
+
var root = roots[r];
|
|
2090
|
+
if (!root || seen.indexOf(root) !== -1) continue;
|
|
2091
|
+
seen.push(root);
|
|
2092
|
+
var scripting = null;
|
|
2093
|
+
try { scripting = root.scripting; } catch (e) {
|
|
2094
|
+
// Ignore
|
|
2095
|
+
}
|
|
2096
|
+
if (scripting && seen.indexOf(scripting) === -1) {
|
|
2097
|
+
if (!read) { read = true; readKept(scripting); }
|
|
2098
|
+
count(scripting, "registerContentScripts", "write");
|
|
2099
|
+
count(scripting, "updateContentScripts", "write");
|
|
2100
|
+
count(scripting, "unregisterContentScripts", "call");
|
|
2101
|
+
count(scripting, "getRegisteredContentScripts", "call");
|
|
2102
|
+
}
|
|
2103
|
+
walk(root, 1, seen);
|
|
2104
|
+
}
|
|
2105
|
+
if (typeof g.fetch === "function") count(g, "fetch", null);
|
|
2106
|
+
// A response is read after it arrived, and the read is waited on too.
|
|
2107
|
+
var body = g.Response && g.Response.prototype;
|
|
2108
|
+
var reads = ["json", "text", "arrayBuffer", "blob", "formData"];
|
|
2109
|
+
for (var b = 0; body && b < reads.length; b++) count(body, reads[b], null, true);
|
|
2110
|
+
|
|
2111
|
+
// Once it has reported, the background runs on the browser's own calls
|
|
2112
|
+
// again. The registry stays counted for a late registration.
|
|
2113
|
+
var release = function () {
|
|
2114
|
+
for (var i = 0; i < counted.length; i++) {
|
|
2115
|
+
var c = counted[i];
|
|
2116
|
+
if (c.kept) continue;
|
|
2117
|
+
try { if (c.owner[c.key] === c.wrapper) c.owner[c.key] = c.inner; } catch (e) {
|
|
2118
|
+
// Ignore
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
};
|
|
2122
|
+
|
|
2123
|
+
// The browser hands a starting background its install events right
|
|
2124
|
+
// after its top level ran, and their listeners are boot code too.
|
|
2125
|
+
var eventsDone = false;
|
|
2126
|
+
var eventsDue = function () { eventsDone = true; };
|
|
2127
|
+
var worker = null;
|
|
2128
|
+
try { worker = g.serviceWorker && typeof g.serviceWorker.state === "string" ? g.serviceWorker : null; } catch (e) {
|
|
2129
|
+
// Ignore
|
|
2130
|
+
}
|
|
2131
|
+
var doc = null;
|
|
2132
|
+
try { doc = g.document && typeof g.document.readyState === "string" ? g.document : null; } catch (e) {
|
|
2133
|
+
// Ignore
|
|
2134
|
+
}
|
|
2135
|
+
if (worker && worker.state !== "activated" && typeof g.addEventListener === "function") {
|
|
2136
|
+
// An installing worker gets onInstalled before it activates.
|
|
2137
|
+
g.addEventListener("activate", function () { setTimeout(eventsDue, 0); });
|
|
2138
|
+
setTimeout(eventsDue, 1000);
|
|
2139
|
+
} else if (!worker && doc && g.chrome && g.chrome.runtime && g.chrome.runtime.onInstalled) {
|
|
2140
|
+
// Gecko fires onInstalled a moment after the page loaded, and not at
|
|
2141
|
+
// all for a background it only woke.
|
|
2142
|
+
var afterLoad = function () { setTimeout(eventsDue, BOOT_EVENTS_GRACE_MS); };
|
|
2143
|
+
g.chrome.runtime.onInstalled.addListener(function () { setTimeout(eventsDue, 0); });
|
|
2144
|
+
if (doc.readyState === "complete" || typeof g.addEventListener !== "function") afterLoad();
|
|
2145
|
+
else g.addEventListener("load", afterLoad);
|
|
2146
|
+
} else {
|
|
2147
|
+
setTimeout(eventsDue, worker ? 0 : BOOT_EVENTS_GRACE_MS);
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
var idleOnce = false;
|
|
2151
|
+
var check = function () {
|
|
2152
|
+
if (reported) return;
|
|
2153
|
+
var gaveUp = Date.now() - bootedAt >= BOOT_GIVE_UP_MS;
|
|
2154
|
+
var idle = eventsDone && inFlight <= 0;
|
|
2155
|
+
if ((idle && idleOnce) || gaveUp) {
|
|
2156
|
+
reported = true;
|
|
2157
|
+
release();
|
|
2158
|
+
var frame = {type: "boot-registrations", calls: calls, landed: landed};
|
|
2159
|
+
if (!(idle && idleOnce)) { frame.pending = true; lateSaid = true; }
|
|
2160
|
+
send(frame);
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
idleOnce = idle;
|
|
2164
|
+
try { setTimeout(check, BOOT_IDLE_CHECK_MS); } catch (e) {
|
|
2165
|
+
// Ignore
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
setTimeout(check, 0);
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
// Every changed file gets a new address, registered now or later.
|
|
2172
|
+
function moveScriptAddresses(changedScriptFiles, cb) {
|
|
2173
|
+
withScriptVersions(function () {
|
|
2174
|
+
var version = Date.now().toString(36) + "-" + (scriptVersionCount++).toString(36);
|
|
2175
|
+
for (var i = 0; i < changedScriptFiles.length; i++) {
|
|
2176
|
+
var name = typeof changedScriptFiles[i] === "string" ? scriptFileName(changedScriptFiles[i]) : "";
|
|
2177
|
+
// A hot update file has a new name on every edit and is never registered.
|
|
2178
|
+
if (name && name.indexOf("hot/") !== 0) scriptVersions[name] = version;
|
|
2179
|
+
}
|
|
2180
|
+
var rec = {};
|
|
2181
|
+
rec[SCRIPT_VERSIONS_KEY] = scriptVersions;
|
|
2182
|
+
try { g.chrome.storage.session.set(rec, noopLastError); } catch (e) {
|
|
2183
|
+
// Ignore
|
|
2184
|
+
}
|
|
2185
|
+
cb();
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
// A background started for this edit may be between its own unregister
|
|
2190
|
+
// and register calls, and a read in that gap finds no registration.
|
|
2191
|
+
function whenRegistryQuiet(cb) {
|
|
2192
|
+
var waited = 0;
|
|
2193
|
+
// A loaded machine answers a call seconds late, and a read made
|
|
2194
|
+
// before that answer finds the gap and reloads no tab.
|
|
2195
|
+
var check = function () {
|
|
2196
|
+
if (waited >= 15000 || (registryCalls <= 0 && Date.now() - registryCalledAt >= 300)) return cb();
|
|
2197
|
+
waited += 100;
|
|
2198
|
+
try { setTimeout(check, 100); } catch (e) { cb(); }
|
|
2199
|
+
};
|
|
2200
|
+
check();
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
function registrationsNaming(existing, changedScriptFiles) {
|
|
2204
|
+
var changed = {};
|
|
2205
|
+
for (var c = 0; c < changedScriptFiles.length; c++) changed[scriptFileName(changedScriptFiles[c])] = true;
|
|
2206
|
+
var out = [];
|
|
2207
|
+
for (var i = 0; existing && i < existing.length; i++) {
|
|
2208
|
+
var s = existing[i];
|
|
2209
|
+
if (!s || typeof s.id !== "string" || s.id.indexOf("extjs-dev-cs-") === 0) continue;
|
|
2210
|
+
var files = stringList(s.js).concat(stringList(s.css));
|
|
2211
|
+
for (var f = 0; f < files.length; f++) {
|
|
2212
|
+
if (changed[scriptFileName(plainScriptAddress(files[f]))]) { out.push(s); break; }
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
return out;
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
// The ids of the open tabs the registrations match, excludeMatches honored.
|
|
2219
|
+
function tabIdsForRegistrations(scripts, cb) {
|
|
2220
|
+
var chrome = g.chrome;
|
|
2221
|
+
var ids = {};
|
|
2222
|
+
var pending = 1;
|
|
2223
|
+
var step = function () {
|
|
2224
|
+
pending--;
|
|
2225
|
+
if (pending > 0) return;
|
|
2226
|
+
var out = [];
|
|
2227
|
+
for (var id in ids) out.push(Number(id));
|
|
2228
|
+
cb(out);
|
|
2229
|
+
};
|
|
2230
|
+
var query = function (patterns, each) {
|
|
2231
|
+
if (!patterns.length || !chrome.tabs || !chrome.tabs.query) return each([]);
|
|
2232
|
+
try {
|
|
2233
|
+
chrome.tabs.query({url: patterns}, function (tabs) { noopLastError(); each(tabs || []); });
|
|
2234
|
+
} catch (e) { each([]); }
|
|
2235
|
+
};
|
|
2236
|
+
for (var i = 0; i < scripts.length; i++) {
|
|
2237
|
+
(function (script) {
|
|
2238
|
+
pending++;
|
|
2239
|
+
query(stringList(script.excludeMatches), function (excludedTabs) {
|
|
2240
|
+
var excluded = {};
|
|
2241
|
+
for (var x = 0; x < excludedTabs.length; x++) {
|
|
2242
|
+
if (excludedTabs[x] && excludedTabs[x].id != null) excluded[excludedTabs[x].id] = true;
|
|
2243
|
+
}
|
|
2244
|
+
query(stringList(script.matches), function (tabs) {
|
|
2245
|
+
for (var t = 0; t < tabs.length; t++) {
|
|
2246
|
+
var tab = tabs[t];
|
|
2247
|
+
if (!tab || tab.id == null || excluded[tab.id] || !isInjectableUrl(tab.url)) continue;
|
|
2248
|
+
ids[tab.id] = true;
|
|
2249
|
+
}
|
|
2250
|
+
step();
|
|
2251
|
+
});
|
|
2252
|
+
});
|
|
2253
|
+
})(scripts[i]);
|
|
2254
|
+
}
|
|
2255
|
+
step();
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
function reloadTabIds(tabIds) {
|
|
2259
|
+
var chrome = g.chrome;
|
|
2260
|
+
if (!chrome.tabs || !chrome.tabs.reload) return;
|
|
2261
|
+
for (var i = 0; i < tabIds.length; i++) {
|
|
2262
|
+
try { chrome.tabs.reload(tabIds[i], {}, noopLastError); } catch (e) {
|
|
2263
|
+
// Ignore
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
// The update names each file at its current address, in the browser's
|
|
2269
|
+
// own call so nothing between here and it reads the names another way.
|
|
2270
|
+
function moveRegisteredScripts(scripts, cb) {
|
|
2271
|
+
var updates = [];
|
|
2272
|
+
for (var i = 0; i < scripts.length; i++) {
|
|
2273
|
+
var update = {id: scripts[i].id};
|
|
2274
|
+
if (stringList(scripts[i].js).length) update.js = stringList(scripts[i].js);
|
|
2275
|
+
if (stringList(scripts[i].css).length) update.css = stringList(scripts[i].css);
|
|
2276
|
+
updates.push(update);
|
|
2277
|
+
}
|
|
2278
|
+
try {
|
|
2279
|
+
nativeRegistry.updateContentScripts(withFileNames(updates, scriptAddress), function () {
|
|
2280
|
+
var failed = false;
|
|
2281
|
+
try { failed = !!g.chrome.runtime.lastError; } catch (e) {
|
|
2282
|
+
// Ignore
|
|
2283
|
+
}
|
|
2284
|
+
cb(!failed);
|
|
2285
|
+
});
|
|
2286
|
+
} catch (e) { cb(false); }
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
function restartForRegisteredScripts(scripts, tabIds) {
|
|
2290
|
+
var scriptIds = [];
|
|
2291
|
+
for (var i = 0; i < scripts.length; i++) scriptIds.push(scripts[i].id);
|
|
2292
|
+
try {
|
|
2293
|
+
var rec = {};
|
|
2294
|
+
rec[REGISTERED_RELOAD_KEY] = {at: Date.now(), tabs: tabIds, scripts: scriptIds};
|
|
2295
|
+
g.chrome.storage.local.set(rec, noopLastError);
|
|
2296
|
+
} catch (e) {
|
|
2297
|
+
// Ignore
|
|
2298
|
+
}
|
|
2299
|
+
if (sendHeldReloadAck) sendHeldReloadAck();
|
|
2300
|
+
restartExtension(150);
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
// Answers true when the extension restarts for the edit. Chromium reads the
|
|
2304
|
+
// files again on an update, Gecko reads them again at a new address.
|
|
2305
|
+
function refreshRegisteredScripts(changedScriptFiles, cb, moved) {
|
|
2306
|
+
var chrome = g.chrome;
|
|
2307
|
+
var answered = false;
|
|
2308
|
+
var guard = null;
|
|
2309
|
+
var answer = function (restarting) {
|
|
2310
|
+
if (answered) return;
|
|
2311
|
+
answered = true;
|
|
2312
|
+
if (guard) { try { clearTimeout(guard); } catch (e) {
|
|
2313
|
+
// Ignore
|
|
2314
|
+
} }
|
|
2315
|
+
try { cb(restarting); } catch (e) {
|
|
2316
|
+
// Ignore
|
|
2317
|
+
}
|
|
2318
|
+
};
|
|
2319
|
+
if (
|
|
2320
|
+
!Array.isArray(changedScriptFiles) || !changedScriptFiles.length ||
|
|
2321
|
+
!chrome || !chrome.scripting || !chrome.scripting.getRegisteredContentScripts
|
|
2322
|
+
) return answer(false);
|
|
2323
|
+
var addressed = canAddressRegisteredScripts();
|
|
2324
|
+
var refresh = function () {
|
|
2325
|
+
try { guard = setTimeout(function () { answer(false); }, 1000); } catch (e) {
|
|
2326
|
+
// Ignore
|
|
2327
|
+
}
|
|
2328
|
+
// The update below is the browser's own call, so the read is too: a
|
|
2329
|
+
// wrapped read answers the names the author wrote, not the files run.
|
|
2330
|
+
var read = addressed && nativeRegistry.getRegisteredContentScripts
|
|
2331
|
+
? nativeRegistry.getRegisteredContentScripts
|
|
2332
|
+
: function (done) { return chrome.scripting.getRegisteredContentScripts(done); };
|
|
2333
|
+
try {
|
|
2334
|
+
read(function (existing) {
|
|
2335
|
+
noopLastError();
|
|
2336
|
+
// The files already have their new address, so a slow answer
|
|
2337
|
+
// still moves the registrations and reloads their tabs.
|
|
2338
|
+
if (answered && !addressed) return;
|
|
2339
|
+
var scripts = registrationsNaming(existing, changedScriptFiles);
|
|
2340
|
+
if (!scripts.length) return answer(false);
|
|
2341
|
+
tabIdsForRegistrations(scripts, function (tabIds) {
|
|
2342
|
+
if (addressed) {
|
|
2343
|
+
return moveRegisteredScripts(scripts, function (moved) {
|
|
2344
|
+
if (moved) { reloadTabIds(tabIds); return answer(false); }
|
|
2345
|
+
if (answered) return;
|
|
2346
|
+
restartForRegisteredScripts(scripts, tabIds);
|
|
2347
|
+
answer(true);
|
|
2348
|
+
});
|
|
2349
|
+
}
|
|
2350
|
+
if (answered) return;
|
|
2351
|
+
if (engineName() === "firefox") {
|
|
2352
|
+
restartForRegisteredScripts(scripts, tabIds);
|
|
2353
|
+
return answer(true);
|
|
2354
|
+
}
|
|
2355
|
+
var updates = [];
|
|
2356
|
+
for (var u = 0; u < scripts.length; u++) {
|
|
2357
|
+
var update = {id: scripts[u].id};
|
|
2358
|
+
if (stringList(scripts[u].js).length) update.js = stringList(scripts[u].js);
|
|
2359
|
+
if (stringList(scripts[u].css).length) update.css = stringList(scripts[u].css);
|
|
2360
|
+
updates.push(update);
|
|
2361
|
+
}
|
|
2362
|
+
var finish = function () { noopLastError(); reloadTabIds(tabIds); answer(false); };
|
|
2363
|
+
if (!chrome.scripting.updateContentScripts) return finish();
|
|
2364
|
+
try { chrome.scripting.updateContentScripts(updates, finish); } catch (e) { finish(); }
|
|
2365
|
+
});
|
|
2366
|
+
});
|
|
2367
|
+
} catch (e) { answer(false); }
|
|
2368
|
+
};
|
|
2369
|
+
if (!addressed) return refresh();
|
|
2370
|
+
if (moved) return whenRegistryQuiet(refresh);
|
|
2371
|
+
moveScriptAddresses(changedScriptFiles, function () { whenRegistryQuiet(refresh); });
|
|
2372
|
+
}
|
|
2373
|
+
|
|
2374
|
+
// The generation after that restart reloads the recorded tabs once two
|
|
2375
|
+
// reads in a row show the scripts registered, or a few seconds passed.
|
|
2376
|
+
function reloadRegisteredScriptTabsAtBoot() {
|
|
2377
|
+
var chrome = g.chrome;
|
|
2378
|
+
if (!chrome || !chrome.storage || !chrome.storage.local) return;
|
|
2379
|
+
chrome.storage.local.get(REGISTERED_RELOAD_KEY, function (res) {
|
|
2380
|
+
noopLastError();
|
|
2381
|
+
var rec = res && res[REGISTERED_RELOAD_KEY];
|
|
2382
|
+
if (!rec || typeof rec !== "object") return;
|
|
2383
|
+
try { chrome.storage.local.remove(REGISTERED_RELOAD_KEY, noopLastError); } catch (e) {
|
|
2384
|
+
// Ignore
|
|
2385
|
+
}
|
|
2386
|
+
if (typeof rec.at !== "number" || Date.now() - rec.at > 30000 || !Array.isArray(rec.tabs)) return;
|
|
2387
|
+
var wanted = stringList(rec.scripts);
|
|
2388
|
+
var attempts = 0;
|
|
2389
|
+
var settled = 0;
|
|
2390
|
+
var check = function () {
|
|
2391
|
+
attempts++;
|
|
2392
|
+
var proceed = function (existing) {
|
|
2393
|
+
var have = {};
|
|
2394
|
+
for (var i = 0; existing && i < existing.length; i++) if (existing[i]) have[existing[i].id] = true;
|
|
2395
|
+
var missing = false;
|
|
2396
|
+
for (var w = 0; w < wanted.length; w++) if (!have[wanted[w]]) missing = true;
|
|
2397
|
+
// A background that unregisters before it registers leaves a gap.
|
|
2398
|
+
settled = missing ? 0 : settled + 1;
|
|
2399
|
+
if (settled < 2 && attempts < 20) return setTimeout(check, 250);
|
|
2400
|
+
reloadTabIds(rec.tabs);
|
|
2401
|
+
};
|
|
2402
|
+
try {
|
|
2403
|
+
chrome.scripting.getRegisteredContentScripts(function (existing) { noopLastError(); proceed(existing); });
|
|
2404
|
+
} catch (e) { reloadTabIds(rec.tabs); }
|
|
2405
|
+
};
|
|
2406
|
+
setTimeout(check, 250);
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
// Gecko keeps a declared content script stylesheet by its address, for
|
|
2411
|
+
// open tabs and for later navigations, until the extension reloads.
|
|
2412
|
+
var SHEET_OVERRIDES_KEY = "__extjsDevSheetOverrides";
|
|
2413
|
+
var SHEET_SESSION_KEY = "__extjsDevSheetSession";
|
|
2414
|
+
var SHEET_SIGNAL = "__extjsDevSheets";
|
|
2415
|
+
var SHEET_ENTRIES_KEY = "__extjsDevSheetEntries";
|
|
2416
|
+
var SHEET_REGISTRATION_PREFIX = "extjs-dev-cs-sheet-";
|
|
2417
|
+
var sheetSessionChecked = false;
|
|
2418
|
+
var sheetSessionWaiters = [];
|
|
2419
|
+
var sheetOverrides = null;
|
|
2420
|
+
|
|
2421
|
+
function sheetAddress(file, digest) {
|
|
2422
|
+
return file + "?v=" + String(digest).slice(0, 16);
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
// Gecko's getManifest names each content script file by its full address.
|
|
2426
|
+
function declaredFileName(value) {
|
|
2427
|
+
var name = String(value || "");
|
|
2428
|
+
var base = "";
|
|
2429
|
+
try { base = String(g.chrome.runtime.getURL("")); } catch (e) {
|
|
2430
|
+
// Ignore
|
|
2431
|
+
}
|
|
2432
|
+
if (base && name.indexOf(base) === 0) name = name.slice(base.length);
|
|
2433
|
+
return scriptFileName(name);
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
function declaredEntries() {
|
|
2437
|
+
try { return g.chrome.runtime.getManifest().content_scripts || []; } catch (e) { return []; }
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
function declaredEntriesNaming(file) {
|
|
2441
|
+
var out = [];
|
|
2442
|
+
var entries = declaredEntries();
|
|
2443
|
+
var wanted = scriptFileName(file);
|
|
2444
|
+
for (var i = 0; i < entries.length; i++) {
|
|
2445
|
+
var css = stringList(entries[i] && entries[i].css);
|
|
2446
|
+
for (var c = 0; c < css.length; c++) {
|
|
2447
|
+
if (declaredFileName(css[c]) === wanted) { out.push(entries[i]); break; }
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
return out;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
// A frame names the bundles the browser ran in it, which is the browser's
|
|
2454
|
+
// own answer for matches, excludes, globs, frames and origin fallback.
|
|
2455
|
+
function entryRuns(entry, bundles) {
|
|
2456
|
+
var js = stringList(entry && entry.js);
|
|
2457
|
+
for (var i = 0; i < js.length; i++) {
|
|
2458
|
+
if (bundles.indexOf(declaredFileName(js[i])) !== -1) return true;
|
|
2459
|
+
}
|
|
2460
|
+
return false;
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
// Sent in this order and not awaited, so the new address is in the frame
|
|
2464
|
+
// before the old copies go. An address already there adds no second copy.
|
|
2465
|
+
function swapDeclaredSheet(target, file, previousDigest, digest) {
|
|
2466
|
+
var chrome = g.chrome;
|
|
2467
|
+
var stale = [file];
|
|
2468
|
+
if (previousDigest && previousDigest !== digest) stale.push(sheetAddress(file, previousDigest));
|
|
2469
|
+
try { chrome.scripting.insertCSS({target: target, files: [sheetAddress(file, digest)]}, noopLastError); } catch (e) {
|
|
2470
|
+
// Ignore
|
|
2471
|
+
}
|
|
2472
|
+
for (var i = 0; i < stale.length; i++) {
|
|
2473
|
+
try { chrome.scripting.removeCSS({target: target, files: [stale[i]]}, noopLastError); } catch (e) {
|
|
2474
|
+
// Ignore
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
function canSwapDeclaredSheets() {
|
|
2480
|
+
var chrome = g.chrome;
|
|
2481
|
+
return !!(
|
|
2482
|
+
engineName() === "firefox" && chrome && chrome.scripting && chrome.scripting.insertCSS &&
|
|
2483
|
+
chrome.scripting.removeCSS && chrome.scripting.executeScript && chrome.tabs && chrome.tabs.query &&
|
|
2484
|
+
chrome.storage && chrome.storage.local && chrome.storage.session
|
|
2485
|
+
);
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2488
|
+
// A registered sheet at the entry's own run_at lands after the declared
|
|
2489
|
+
// copy, so a later document starts on the new rules with no one awake.
|
|
2490
|
+
function registerSheetOverrides(overrides) {
|
|
2491
|
+
var chrome = g.chrome;
|
|
2492
|
+
if (
|
|
2493
|
+
!chrome.scripting.registerContentScripts || !chrome.scripting.getRegisteredContentScripts ||
|
|
2494
|
+
!chrome.scripting.updateContentScripts || !chrome.scripting.unregisterContentScripts
|
|
2495
|
+
) return;
|
|
2496
|
+
var entries = declaredEntries();
|
|
2497
|
+
var wanted = [];
|
|
2498
|
+
for (var i = 0; i < entries.length; i++) {
|
|
2499
|
+
var entry = entries[i] || {};
|
|
2500
|
+
var matches = stringList(entry.matches);
|
|
2501
|
+
// A globbed entry has no registered form, its frames ask one by one.
|
|
2502
|
+
if (!matches.length || stringList(entry.include_globs).length || stringList(entry.exclude_globs).length) continue;
|
|
2503
|
+
var css = stringList(entry.css);
|
|
2504
|
+
var files = [];
|
|
2505
|
+
for (var c = 0; c < css.length; c++) {
|
|
2506
|
+
var name = declaredFileName(css[c]);
|
|
2507
|
+
if (typeof overrides[name] === "string") files.push(sheetAddress(name, overrides[name]));
|
|
2508
|
+
}
|
|
2509
|
+
if (!files.length) continue;
|
|
2510
|
+
wanted.push({
|
|
2511
|
+
id: SHEET_REGISTRATION_PREFIX + i,
|
|
2512
|
+
matches: matches,
|
|
2513
|
+
excludeMatches: stringList(entry.exclude_matches),
|
|
2514
|
+
css: files,
|
|
2515
|
+
runAt: mapRunAt(entry.run_at),
|
|
2516
|
+
allFrames: entry.all_frames === true,
|
|
2517
|
+
matchOriginAsFallback: entry.match_origin_as_fallback === true,
|
|
2518
|
+
persistAcrossSessions: false
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
try {
|
|
2522
|
+
chrome.scripting.getRegisteredContentScripts(function (existing) {
|
|
2523
|
+
noopLastError();
|
|
2524
|
+
var have = {};
|
|
2525
|
+
for (var k = 0; existing && k < existing.length; k++) {
|
|
2526
|
+
var id = existing[k] && existing[k].id;
|
|
2527
|
+
if (typeof id === "string" && id.indexOf(SHEET_REGISTRATION_PREFIX) === 0) have[id] = true;
|
|
2528
|
+
}
|
|
2529
|
+
var toRegister = [], toUpdate = [], toDrop = [], keep = {};
|
|
2530
|
+
for (var j = 0; j < wanted.length; j++) {
|
|
2531
|
+
keep[wanted[j].id] = true;
|
|
2532
|
+
(have[wanted[j].id] ? toUpdate : toRegister).push(wanted[j]);
|
|
2533
|
+
}
|
|
2534
|
+
for (var old in have) if (!keep[old]) toDrop.push(old);
|
|
2535
|
+
try {
|
|
2536
|
+
if (toDrop.length) chrome.scripting.unregisterContentScripts({ids: toDrop}, noopLastError);
|
|
2537
|
+
if (toUpdate.length) chrome.scripting.updateContentScripts(toUpdate, noopLastError);
|
|
2538
|
+
if (toRegister.length) chrome.scripting.registerContentScripts(toRegister, noopLastError);
|
|
2539
|
+
} catch (e) {
|
|
2540
|
+
// Ignore
|
|
2541
|
+
}
|
|
2542
|
+
});
|
|
2543
|
+
} catch (e) {
|
|
2544
|
+
// Ignore
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
// The overrides belong to one load of the extension: a reload reads every
|
|
2549
|
+
// declared file again, and session storage is what a reload empties.
|
|
2550
|
+
function checkSheetSession() {
|
|
2551
|
+
var chrome = g.chrome;
|
|
2552
|
+
var done = function () {
|
|
2553
|
+
sheetSessionChecked = true;
|
|
2554
|
+
var fns = sheetSessionWaiters;
|
|
2555
|
+
sheetSessionWaiters = [];
|
|
2556
|
+
for (var i = 0; i < fns.length; i++) { try { fns[i](); } catch (e) {
|
|
2557
|
+
// Ignore
|
|
2558
|
+
} }
|
|
2559
|
+
};
|
|
2560
|
+
if (!canSwapDeclaredSheets()) return done();
|
|
2561
|
+
try {
|
|
2562
|
+
chrome.storage.session.get(SHEET_SESSION_KEY, function (res) {
|
|
2563
|
+
noopLastError();
|
|
2564
|
+
if (res && res[SHEET_SESSION_KEY]) return done();
|
|
2565
|
+
var mark = {};
|
|
2566
|
+
mark[SHEET_SESSION_KEY] = Date.now();
|
|
2567
|
+
try { chrome.storage.session.set(mark, noopLastError); } catch (e) {
|
|
2568
|
+
// Ignore
|
|
2569
|
+
}
|
|
2570
|
+
sheetOverrides = {};
|
|
2571
|
+
try { registerSheetOverrides({}); } catch (e) {
|
|
2572
|
+
// Ignore
|
|
2573
|
+
}
|
|
2574
|
+
try { chrome.storage.local.remove(SHEET_OVERRIDES_KEY, function () { noopLastError(); done(); }); } catch (e) { done(); }
|
|
2575
|
+
});
|
|
2576
|
+
} catch (e) { done(); }
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
function withSheetOverrides(cb) {
|
|
2580
|
+
var read = function () {
|
|
2581
|
+
if (sheetOverrides) return cb(sheetOverrides);
|
|
2582
|
+
try {
|
|
2583
|
+
g.chrome.storage.local.get(SHEET_OVERRIDES_KEY, function (res) {
|
|
2584
|
+
noopLastError();
|
|
2585
|
+
var map = res && res[SHEET_OVERRIDES_KEY];
|
|
2586
|
+
sheetOverrides = map && typeof map === "object" ? map : {};
|
|
2587
|
+
cb(sheetOverrides);
|
|
2588
|
+
});
|
|
2589
|
+
} catch (e) { cb({}); }
|
|
2590
|
+
};
|
|
2591
|
+
if (sheetSessionChecked) read(); else sheetSessionWaiters.push(read);
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
// Asks every frame of a tab which declared bundles run in it.
|
|
2595
|
+
function bundlesByFrame(tabId, cb) {
|
|
2596
|
+
try {
|
|
2597
|
+
g.chrome.scripting.executeScript({
|
|
2598
|
+
target: {tabId: tabId, allFrames: true},
|
|
2599
|
+
args: [SHEET_ENTRIES_KEY],
|
|
2600
|
+
func: function (key) {
|
|
2601
|
+
try { return Object.keys(globalThis[key] || {}); } catch (e) { return []; }
|
|
2602
|
+
}
|
|
2603
|
+
}, function (results) { noopLastError(); cb(Array.isArray(results) ? results : []); });
|
|
2604
|
+
} catch (e) { cb([]); }
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
function swapInOpenFrames(jobs, previous) {
|
|
2608
|
+
var chrome = g.chrome;
|
|
1363
2609
|
try {
|
|
1364
2610
|
chrome.tabs.query({}, function (tabs) {
|
|
1365
2611
|
noopLastError();
|
|
1366
|
-
|
|
1367
|
-
for (var i = 0; i < tabs.length; i++) {
|
|
2612
|
+
for (var t = 0; tabs && t < tabs.length; t++) {
|
|
1368
2613
|
(function (tab) {
|
|
1369
|
-
if (!tab || tab.id == null || !isInjectableUrl(tab.url)) return;
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
)
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
// MV2 fallback (Firefox without the scripting API).
|
|
1382
|
-
if (chrome.tabs.executeScript) {
|
|
1383
|
-
try {
|
|
1384
|
-
chrome.tabs.executeScript(tab.id, {code: "console.log(" + JSON.stringify(text) + ");"}, noopLastError);
|
|
1385
|
-
} catch (e) {
|
|
1386
|
-
// Ignore
|
|
2614
|
+
if (!tab || tab.id == null || (tab.url && !isInjectableUrl(tab.url))) return;
|
|
2615
|
+
bundlesByFrame(tab.id, function (frames) {
|
|
2616
|
+
for (var f = 0; f < frames.length; f++) {
|
|
2617
|
+
var frame = frames[f];
|
|
2618
|
+
if (!frame || !Array.isArray(frame.result) || !frame.result.length) continue;
|
|
2619
|
+
var target = {tabId: tab.id, frameIds: [typeof frame.frameId === "number" ? frame.frameId : 0]};
|
|
2620
|
+
for (var j = 0; j < jobs.length; j++) {
|
|
2621
|
+
if (!entryRuns(jobs[j].entry, frame.result)) continue;
|
|
2622
|
+
swapDeclaredSheet(target, jobs[j].file, previous[jobs[j].file], jobs[j].digest);
|
|
2623
|
+
}
|
|
1387
2624
|
}
|
|
1388
|
-
}
|
|
1389
|
-
})(tabs[
|
|
2625
|
+
});
|
|
2626
|
+
})(tabs[t]);
|
|
1390
2627
|
}
|
|
1391
2628
|
});
|
|
1392
2629
|
} catch (e) {
|
|
@@ -1394,20 +2631,61 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1394
2631
|
}
|
|
1395
2632
|
}
|
|
1396
2633
|
|
|
1397
|
-
//
|
|
1398
|
-
//
|
|
1399
|
-
function
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
var
|
|
1405
|
-
if (
|
|
1406
|
-
|
|
2634
|
+
// Answers false when only a reload delivers the edit: no API for the swap,
|
|
2635
|
+
// or an entry with no script to ask for it again on a later navigation.
|
|
2636
|
+
function refreshDeclaredSheets(sheets, cb) {
|
|
2637
|
+
var chrome = g.chrome;
|
|
2638
|
+
if (!Array.isArray(sheets) || !sheets.length || !canSwapDeclaredSheets()) return cb(false);
|
|
2639
|
+
var jobs = [];
|
|
2640
|
+
for (var i = 0; i < sheets.length; i++) {
|
|
2641
|
+
var sheet = sheets[i];
|
|
2642
|
+
if (!sheet || typeof sheet.file !== "string" || typeof sheet.digest !== "string") return cb(false);
|
|
2643
|
+
var entries = declaredEntriesNaming(sheet.file);
|
|
2644
|
+
for (var e = 0; e < entries.length; e++) {
|
|
2645
|
+
if (!stringList(entries[e].js).length) return cb(false);
|
|
2646
|
+
jobs.push({file: scriptFileName(sheet.file), digest: sheet.digest, entry: entries[e]});
|
|
1407
2647
|
}
|
|
1408
|
-
} catch (e) {
|
|
1409
|
-
// Ignore
|
|
1410
2648
|
}
|
|
2649
|
+
if (!jobs.length) return cb(false);
|
|
2650
|
+
withSheetOverrides(function (previous) {
|
|
2651
|
+
var next = {};
|
|
2652
|
+
for (var key in previous) next[key] = previous[key];
|
|
2653
|
+
for (var s = 0; s < sheets.length; s++) next[scriptFileName(sheets[s].file)] = sheets[s].digest;
|
|
2654
|
+
var rec = {};
|
|
2655
|
+
rec[SHEET_OVERRIDES_KEY] = next;
|
|
2656
|
+
sheetOverrides = next;
|
|
2657
|
+
// Recorded before any frame is asked: one that loads meanwhile either
|
|
2658
|
+
// reads the record and asks, or is already there to be asked.
|
|
2659
|
+
var apply = function () {
|
|
2660
|
+
noopLastError();
|
|
2661
|
+
try { registerSheetOverrides(next); } catch (e) {
|
|
2662
|
+
// Ignore
|
|
2663
|
+
}
|
|
2664
|
+
swapInOpenFrames(jobs, previous);
|
|
2665
|
+
};
|
|
2666
|
+
try { chrome.storage.local.set(rec, apply); } catch (e) { apply(); }
|
|
2667
|
+
cb(true);
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
// A document loaded after a swap starts on the declared copy again, and
|
|
2672
|
+
// each bundle in it says so. Only the frame that asked is corrected.
|
|
2673
|
+
function correctSheetsFor(sender, signal) {
|
|
2674
|
+
if (!sender || !sender.tab || sender.tab.id == null || !canSwapDeclaredSheets()) return;
|
|
2675
|
+
if (!signal || typeof signal.file !== "string") return;
|
|
2676
|
+
var target = {tabId: sender.tab.id, frameIds: [typeof sender.frameId === "number" ? sender.frameId : 0]};
|
|
2677
|
+
var bundles = [scriptFileName(signal.file)];
|
|
2678
|
+
withSheetOverrides(function (overrides) {
|
|
2679
|
+
var entries = declaredEntries();
|
|
2680
|
+
for (var i = 0; i < entries.length; i++) {
|
|
2681
|
+
if (!entryRuns(entries[i], bundles)) continue;
|
|
2682
|
+
var css = stringList(entries[i].css);
|
|
2683
|
+
for (var c = 0; c < css.length; c++) {
|
|
2684
|
+
var file = declaredFileName(css[c]);
|
|
2685
|
+
if (typeof overrides[file] === "string") swapDeclaredSheet(target, file, null, overrides[file]);
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
});
|
|
1411
2689
|
}
|
|
1412
2690
|
|
|
1413
2691
|
function handleDevReloadFrame(frame) {
|
|
@@ -1426,20 +2704,54 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1426
2704
|
// the correlation id is echoed so it confirms only this broadcast.
|
|
1427
2705
|
var ack = {type: "reload-ack", reloadType: kind, label: label};
|
|
1428
2706
|
if (frame.reloadId) ack.reloadId = frame.reloadId;
|
|
1429
|
-
|
|
2707
|
+
var changedScripts = frame.changedScriptFiles;
|
|
2708
|
+
var acked = false;
|
|
2709
|
+
var sendAck = function (replayedTabs) {
|
|
2710
|
+
if (acked) return;
|
|
2711
|
+
acked = true;
|
|
2712
|
+
sendHeldReloadAck = null;
|
|
2713
|
+
if (typeof replayedTabs === "number" && replayedTabs > 0) ack.replayedTabs = replayedTabs;
|
|
2714
|
+
send(ack);
|
|
2715
|
+
};
|
|
2716
|
+
var replays = kind === "page" && Array.isArray(changedScripts) && changedScripts.length > 0 &&
|
|
2717
|
+
typeof g.__extjsScriptsReplay === "function";
|
|
2718
|
+
if (replays) {
|
|
2719
|
+
if (sendHeldReloadAck) sendHeldReloadAck();
|
|
2720
|
+
sendHeldReloadAck = sendAck;
|
|
2721
|
+
try { setTimeout(function () { sendAck(); }, REPLAY_RECEIPT_WAIT_MS); } catch (e) { sendAck(); }
|
|
2722
|
+
} else sendAck();
|
|
2723
|
+
|
|
2724
|
+
// The replay names each file at its address, so on Gecko the edited
|
|
2725
|
+
// files get their new one before it runs.
|
|
2726
|
+
if (Array.isArray(changedScripts) && changedScripts.length && canAddressRegisteredScripts()) {
|
|
2727
|
+
return moveScriptAddresses(changedScripts, function () { replayThenRefresh(frame, kind, announced, true, sendAck); });
|
|
2728
|
+
}
|
|
2729
|
+
replayThenRefresh(frame, kind, announced, false, sendAck);
|
|
2730
|
+
}
|
|
1430
2731
|
|
|
2732
|
+
function replayThenRefresh(frame, kind, announced, moved, replayed) {
|
|
1431
2733
|
// A scripts/ bundle edit: re-run the executeScript calls that named it
|
|
1432
2734
|
// on their recorded tabs, before any reload decision below.
|
|
1433
|
-
replayProgrammaticScripts(frame.changedScriptFiles);
|
|
2735
|
+
replayProgrammaticScripts(frame.changedScriptFiles, replayed);
|
|
1434
2736
|
|
|
1435
|
-
|
|
2737
|
+
refreshRegisteredScripts(frame.changedScriptFiles, function (restarting) {
|
|
2738
|
+
if (restarting) return;
|
|
2739
|
+
// A restart brings every own tab back itself, so only the reloads
|
|
2740
|
+
// that keep the extension running reload a standalone page here.
|
|
2741
|
+
if (kind !== "full" && kind !== "service-worker") reloadStandalonePages(frame.standalonePages);
|
|
1436
2742
|
// Notify-only: rspack-dev-server's livereload refreshes the open
|
|
1437
2743
|
// surface; reloading the extension here would race it.
|
|
1438
|
-
return;
|
|
1439
|
-
}
|
|
2744
|
+
if (kind === "page") return;
|
|
1440
2745
|
|
|
1441
|
-
|
|
1442
|
-
|
|
2746
|
+
announceReloadInTabs(announced);
|
|
2747
|
+
if (!Array.isArray(frame.refreshedStylesheets) || !frame.refreshedStylesheets.length) {
|
|
2748
|
+
return performDevReload(kind, function () {}, frame);
|
|
2749
|
+
}
|
|
2750
|
+
// A sheet-only edit: swap it where the browser can, reload otherwise.
|
|
2751
|
+
refreshDeclaredSheets(frame.refreshedStylesheets, function (swapped) {
|
|
2752
|
+
if (!swapped) restartExtension(150);
|
|
2753
|
+
});
|
|
2754
|
+
}, moved);
|
|
1443
2755
|
}
|
|
1444
2756
|
|
|
1445
2757
|
function sanitize(args) {
|
|
@@ -1518,7 +2830,9 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1518
2830
|
}
|
|
1519
2831
|
function replayable(frame) {
|
|
1520
2832
|
var ev = frame && frame.event;
|
|
1521
|
-
if (!ev
|
|
2833
|
+
if (!ev) return false;
|
|
2834
|
+
// A background that died before it read its session parked no run id.
|
|
2835
|
+
if (ev.runId !== INSTANCE_ID && !(SESSION_FROM_FILE && ev.runId === "")) return false;
|
|
1522
2836
|
if (parkedHere(ev.id)) return false;
|
|
1523
2837
|
return typeof ev.timestamp === "number" && Date.now() - ev.timestamp <= PENDING_ERROR_TTL;
|
|
1524
2838
|
}
|
|
@@ -1563,8 +2877,10 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1563
2877
|
readParked(area, function (list) {
|
|
1564
2878
|
if (inheritedParked !== null) return;
|
|
1565
2879
|
inheritedParked = [];
|
|
2880
|
+
// Before the session is read nothing can be told apart yet, and the
|
|
2881
|
+
// lines are filtered again when they are shipped.
|
|
1566
2882
|
for (var i = 0; i < list.length; i++) {
|
|
1567
|
-
if (replayable(list[i])) inheritedParked.push(list[i]);
|
|
2883
|
+
if (!INSTANCE_ID || replayable(list[i])) inheritedParked.push(list[i]);
|
|
1568
2884
|
}
|
|
1569
2885
|
if (parkedErrors.length && !open) writeParked();
|
|
1570
2886
|
});
|
|
@@ -1622,6 +2938,20 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1622
2938
|
// The baked PORT is a snapshot of an ephemeral port. After a dev-server
|
|
1623
2939
|
// restart, the port file shipped in the unpacked extension names the
|
|
1624
2940
|
// live one, and unpacked resources are read from disk on every fetch.
|
|
2941
|
+
// Lines logged before the session was read get its id once it is known.
|
|
2942
|
+
function adoptSession(id) {
|
|
2943
|
+
if (!SESSION_FROM_FILE || typeof id !== "string" || !id || id === INSTANCE_ID) return;
|
|
2944
|
+
INSTANCE_ID = id;
|
|
2945
|
+
var lists = [queue, parkedErrors];
|
|
2946
|
+
for (var l = 0; l < lists.length; l++) {
|
|
2947
|
+
for (var i = 0; i < lists[l].length; i++) {
|
|
2948
|
+
var ev = lists[l][i] && lists[l][i].event;
|
|
2949
|
+
if (ev && ev.runId === "") ev.runId = id;
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
if (parkedErrors.length && !open) writeParked();
|
|
2953
|
+
}
|
|
2954
|
+
|
|
1625
2955
|
function refreshControlPort(done) {
|
|
1626
2956
|
try {
|
|
1627
2957
|
var runtime = (g.chrome && g.chrome.runtime) || (g.browser && g.browser.runtime);
|
|
@@ -1631,12 +2961,24 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1631
2961
|
.then(function (data) {
|
|
1632
2962
|
var next = data && parseInt(data.port, 10);
|
|
1633
2963
|
if (next && next > 0 && next < 65536 && next !== PORT) PORT = next;
|
|
2964
|
+
adoptSession(data && data.instanceId);
|
|
1634
2965
|
done();
|
|
1635
2966
|
})
|
|
1636
2967
|
.catch(function () { done(); });
|
|
1637
2968
|
} catch (e) { done(); }
|
|
1638
2969
|
}
|
|
1639
2970
|
|
|
2971
|
+
function sessionKnown() {
|
|
2972
|
+
return !SESSION_FROM_FILE || (!!INSTANCE_ID && PORT > 0);
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
// The session file is there before the browser starts, so a read that
|
|
2976
|
+
// found none is retried like a server that is not listening yet.
|
|
2977
|
+
function dial() {
|
|
2978
|
+
if (sessionKnown()) connect();
|
|
2979
|
+
else schedule();
|
|
2980
|
+
}
|
|
2981
|
+
|
|
1640
2982
|
function schedule() {
|
|
1641
2983
|
var delay = backoff;
|
|
1642
2984
|
backoff = Math.min(backoff * 2, MAX_BACKOFF);
|
|
@@ -1645,8 +2987,8 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1645
2987
|
setTimeout(function () {
|
|
1646
2988
|
// Two straight failures make the baked port suspect (a restarted
|
|
1647
2989
|
// server dials out on a new port): re-resolve before re-dialing.
|
|
1648
|
-
if (connectFailures >= 2) refreshControlPort(
|
|
1649
|
-
else
|
|
2990
|
+
if (connectFailures >= 2 || !sessionKnown()) refreshControlPort(dial);
|
|
2991
|
+
else dial();
|
|
1650
2992
|
}, delay);
|
|
1651
2993
|
} catch (e) {
|
|
1652
2994
|
// Ignore
|
|
@@ -1665,7 +3007,7 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1665
3007
|
backoff = 250;
|
|
1666
3008
|
connectFailures = 0;
|
|
1667
3009
|
try {
|
|
1668
|
-
socket.send(JSON.stringify({type: "hello", v: 1, role: "producer", instanceId: INSTANCE_ID, acksReloads: true}));
|
|
3010
|
+
socket.send(JSON.stringify({type: "hello", v: 1, role: "producer", instanceId: INSTANCE_ID, acksReloads: true, build: g.__extjsDevBuild}));
|
|
1669
3011
|
} catch (e) {
|
|
1670
3012
|
// Ignore
|
|
1671
3013
|
}
|
|
@@ -1928,10 +3270,40 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1928
3270
|
// Ignore
|
|
1929
3271
|
}
|
|
1930
3272
|
|
|
3273
|
+
try { installScriptAddresses(); } catch (e) {
|
|
3274
|
+
// Ignore
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
try { watchBootRegistrations(); } catch (e) {
|
|
3278
|
+
// Ignore
|
|
3279
|
+
}
|
|
3280
|
+
|
|
1931
3281
|
try { restoreOverrideTabsAtBoot(); } catch (e) {
|
|
1932
3282
|
// Ignore
|
|
1933
3283
|
}
|
|
1934
3284
|
|
|
3285
|
+
try { restorePageTabsAtBoot(); } catch (e) {
|
|
3286
|
+
// Ignore
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3289
|
+
try { reloadRegisteredScriptTabsAtBoot(); } catch (e) {
|
|
3290
|
+
// Ignore
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3293
|
+
try { checkSheetSession(); } catch (e) {
|
|
3294
|
+
sheetSessionChecked = true;
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
try {
|
|
3298
|
+
if (engineName() === "firefox" && g.chrome && g.chrome.runtime && g.chrome.runtime.onMessage) {
|
|
3299
|
+
g.chrome.runtime.onMessage.addListener(function (msg, sender) {
|
|
3300
|
+
if (msg && msg[SHEET_SIGNAL]) correctSheetsFor(sender, msg[SHEET_SIGNAL]);
|
|
3301
|
+
});
|
|
3302
|
+
}
|
|
3303
|
+
} catch (e) {
|
|
3304
|
+
// Ignore
|
|
3305
|
+
}
|
|
3306
|
+
|
|
1935
3307
|
// Chromium 146 fires no onInstalled on runtime.reload() while 151 reports
|
|
1936
3308
|
// an "update": the pre-reload storage flag (fresh only) covers the former.
|
|
1937
3309
|
try {
|
|
@@ -1953,7 +3325,8 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
1953
3325
|
}
|
|
1954
3326
|
|
|
1955
3327
|
adoptInheritedParked();
|
|
1956
|
-
|
|
3328
|
+
if (SESSION_FROM_FILE) refreshControlPort(dial);
|
|
3329
|
+
else connect();
|
|
1957
3330
|
} catch (e) {
|
|
1958
3331
|
// Ignore
|
|
1959
3332
|
}
|
|
@@ -1970,6 +3343,7 @@ const BRIDGE_RELAY_SOURCE = `;(function () {
|
|
|
1970
3343
|
var canRelay = typeof chrome.runtime.connect === "function";
|
|
1971
3344
|
|
|
1972
3345
|
g.__extjsBridgeRelayInstalled = true;
|
|
3346
|
+
|
|
1973
3347
|
var consoleRef = g.console || {};
|
|
1974
3348
|
var LEVELS = ["log", "info", "warn", "error", "debug", "trace"];
|
|
1975
3349
|
// Same filter as the producer: HMR chatter is not the page's output.
|
|
@@ -2127,8 +3501,25 @@ const BRIDGE_RELAY_SOURCE = `;(function () {
|
|
|
2127
3501
|
chrome.runtime.onMessage.addListener(function (msg, _sender, sendResponse) {
|
|
2128
3502
|
if (!msg || !msg.__extjsEvalRequest) return;
|
|
2129
3503
|
if (!msg.target || msg.target.context !== CONTEXT) return; // not for me
|
|
3504
|
+
// The reply crosses as JSON on Chromium and as a clone on Firefox.
|
|
3505
|
+
// Its JSON form, with each cycle nulled, reads the same on both.
|
|
3506
|
+
var jsonForm = function (v) {
|
|
3507
|
+
var stack = [];
|
|
3508
|
+
try {
|
|
3509
|
+
var json = JSON.stringify(v, function (_key, val) {
|
|
3510
|
+
while (stack.length && stack[stack.length - 1] !== this) stack.pop();
|
|
3511
|
+
if (typeof val === "bigint") val = {__type: "bigint", value: String(val)};
|
|
3512
|
+
if (val && typeof val === "object") {
|
|
3513
|
+
if (stack.indexOf(val) !== -1) return null;
|
|
3514
|
+
stack.push(val);
|
|
3515
|
+
}
|
|
3516
|
+
return val;
|
|
3517
|
+
});
|
|
3518
|
+
return json === undefined ? undefined : JSON.parse(json);
|
|
3519
|
+
} catch (e) { return v; }
|
|
3520
|
+
};
|
|
2130
3521
|
var respondValue = function (value) {
|
|
2131
|
-
try { sendResponse({ok: true, value: value}); }
|
|
3522
|
+
try { sendResponse({ok: true, value: jsonForm(value)}); }
|
|
2132
3523
|
catch (eSend) { sendResponse({ok: true, value: String(value)}); }
|
|
2133
3524
|
};
|
|
2134
3525
|
var respondError = function (e) {
|
|
@@ -2209,18 +3600,52 @@ const BRIDGE_RELAY_SOURCE = `;(function () {
|
|
|
2209
3600
|
}
|
|
2210
3601
|
})();
|
|
2211
3602
|
`;
|
|
3603
|
+
function buildDeclaredSheetSignalSource(assetName) {
|
|
3604
|
+
return `;(function () {
|
|
3605
|
+
try {
|
|
3606
|
+
var g = (typeof globalThis === "object" && globalThis) ? globalThis : this;
|
|
3607
|
+
var chrome = g && g.chrome;
|
|
3608
|
+
var FILE = ${JSON.stringify(assetName)};
|
|
3609
|
+
if (!chrome || !chrome.runtime || !/^moz-extension:/.test(String(chrome.runtime.getURL("")))) return;
|
|
3610
|
+
var running = g.__extjsDevSheetEntries = g.__extjsDevSheetEntries || {};
|
|
3611
|
+
if (running[FILE]) return;
|
|
3612
|
+
running[FILE] = true;
|
|
3613
|
+
if (!chrome.storage || !chrome.storage.local) return;
|
|
3614
|
+
chrome.storage.local.get("__extjsDevSheetOverrides", function (res) {
|
|
3615
|
+
try {
|
|
3616
|
+
void chrome.runtime.lastError;
|
|
3617
|
+
var overrides = res && res.__extjsDevSheetOverrides;
|
|
3618
|
+
if (!overrides || typeof overrides !== "object") return;
|
|
3619
|
+
for (var file in overrides) {
|
|
3620
|
+
chrome.runtime.sendMessage({__extjsDevSheets: {file: FILE}}, function () { try { void chrome.runtime.lastError; } catch (e) {
|
|
3621
|
+
// Ignore
|
|
3622
|
+
} });
|
|
3623
|
+
return;
|
|
3624
|
+
}
|
|
3625
|
+
} catch (e) {
|
|
3626
|
+
// Ignore
|
|
3627
|
+
}
|
|
3628
|
+
});
|
|
3629
|
+
} catch (e) {
|
|
3630
|
+
// Ignore
|
|
3631
|
+
}
|
|
3632
|
+
})();
|
|
3633
|
+
`;
|
|
3634
|
+
}
|
|
2212
3635
|
function buildBridgeRelaySource(opts) {
|
|
2213
3636
|
return BRIDGE_RELAY_SOURCE.replace(/__EXTJS_CONTEXT__/g, String(opts.context || 'content'));
|
|
2214
3637
|
}
|
|
3638
|
+
const DEV_BOOT_REGISTERS_GLOBAL = '__extjsDevBootRegisters';
|
|
2215
3639
|
function buildBridgeProducerSource(opts) {
|
|
2216
3640
|
if (!opts.controlPort || opts.controlPort < 1) return '';
|
|
2217
|
-
|
|
3641
|
+
const fromFile = true === opts.sessionFromFile;
|
|
3642
|
+
return BRIDGE_PRODUCER_SOURCE.replace(/__EXTJS_CONTROL_PORT__/g, fromFile ? '0' : String(opts.controlPort)).replace(/__EXTJS_INSTANCE_ID__/g, fromFile ? '' : String(opts.instanceId)).replace(/__EXTJS_SESSION_FROM_FILE__/g, fromFile ? '1' : '0').replace(/__EXTJS_CONTEXT__/g, String(opts.context || 'background')).replace(/__EXTJS_CONTROL_HOST__/g, String(opts.host || '127.0.0.1'));
|
|
2218
3643
|
}
|
|
2219
3644
|
function sanitize(obj) {
|
|
2220
3645
|
return Object.fromEntries(Object.entries(obj || {}).filter(([, value])=>void 0 !== value));
|
|
2221
3646
|
}
|
|
2222
3647
|
const DEV_COMMAND_DEFAULTS = {
|
|
2223
|
-
polyfill:
|
|
3648
|
+
polyfill: false,
|
|
2224
3649
|
logFormat: 'pretty',
|
|
2225
3650
|
logTimestamps: true,
|
|
2226
3651
|
logColor: true,
|
|
@@ -2241,7 +3666,7 @@ const SERVE_COMMAND_DEFAULTS = {
|
|
|
2241
3666
|
logLevel: 'off'
|
|
2242
3667
|
};
|
|
2243
3668
|
const START_BUILD_DEFAULTS = {
|
|
2244
|
-
polyfill:
|
|
3669
|
+
polyfill: false,
|
|
2245
3670
|
silent: true,
|
|
2246
3671
|
addonLint: false
|
|
2247
3672
|
};
|
|
@@ -2349,6 +3774,21 @@ function warnOnce(message) {
|
|
|
2349
3774
|
warned.add(message);
|
|
2350
3775
|
console.warn(message);
|
|
2351
3776
|
}
|
|
3777
|
+
const additionsByCompilation = new WeakMap();
|
|
3778
|
+
function recordDevAdditions(compilation, additions) {
|
|
3779
|
+
additionsByCompilation.set(compilation, additions);
|
|
3780
|
+
}
|
|
3781
|
+
function devAdditionsOf(compilation) {
|
|
3782
|
+
return compilation ? additionsByCompilation.get(compilation) : void 0;
|
|
3783
|
+
}
|
|
3784
|
+
function mergeDevAdditions(compiled, previous) {
|
|
3785
|
+
const earlier = Array.isArray(previous) ? previous.filter((entry)=>entry && 'object' == typeof entry) : [];
|
|
3786
|
+
if (!compiled) return earlier.length ? earlier : void 0;
|
|
3787
|
+
return [
|
|
3788
|
+
...compiled,
|
|
3789
|
+
...earlier.filter((entry)=>'browser_flag' === entry.kind || 'browser_preference' === entry.kind)
|
|
3790
|
+
];
|
|
3791
|
+
}
|
|
2352
3792
|
function idFromHash(hash) {
|
|
2353
3793
|
const hex = hash.subarray(0, 16).toString('hex');
|
|
2354
3794
|
let id = '';
|
|
@@ -2418,6 +3858,43 @@ function managedExtensionRecords(browser, extensionDirs) {
|
|
|
2418
3858
|
};
|
|
2419
3859
|
});
|
|
2420
3860
|
}
|
|
3861
|
+
const PROCESS_START_PROBE_TIMEOUT_MS = 5000;
|
|
3862
|
+
function startedAtFromProcessTable() {
|
|
3863
|
+
try {
|
|
3864
|
+
const result = spawnSync('ps', [
|
|
3865
|
+
'-o',
|
|
3866
|
+
'lstart=',
|
|
3867
|
+
'-p',
|
|
3868
|
+
String(process.pid)
|
|
3869
|
+
], {
|
|
3870
|
+
encoding: 'utf-8',
|
|
3871
|
+
stdio: [
|
|
3872
|
+
'ignore',
|
|
3873
|
+
'pipe',
|
|
3874
|
+
'ignore'
|
|
3875
|
+
],
|
|
3876
|
+
timeout: PROCESS_START_PROBE_TIMEOUT_MS,
|
|
3877
|
+
env: {
|
|
3878
|
+
...process.env,
|
|
3879
|
+
LC_ALL: 'C'
|
|
3880
|
+
}
|
|
3881
|
+
});
|
|
3882
|
+
if (result.error || 0 !== result.status) return;
|
|
3883
|
+
const started = Date.parse(String(result.stdout || '').trim());
|
|
3884
|
+
return Number.isNaN(started) ? void 0 : new Date(started).toISOString();
|
|
3885
|
+
} catch {
|
|
3886
|
+
return;
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
function startedAtFromOwnClock() {
|
|
3890
|
+
return new Date(Date.now() - 1000 * process.uptime()).toISOString();
|
|
3891
|
+
}
|
|
3892
|
+
let ownStartedAt;
|
|
3893
|
+
function ownProcessStartedAt() {
|
|
3894
|
+
if (!ownStartedAt) ownStartedAt = ('win32' === process.platform ? void 0 : startedAtFromProcessTable()) || startedAtFromOwnClock();
|
|
3895
|
+
return ownStartedAt;
|
|
3896
|
+
}
|
|
3897
|
+
const READY_EXECUTOR_WAIT_MS = 10000;
|
|
2421
3898
|
function nowISO() {
|
|
2422
3899
|
return new Date().toISOString();
|
|
2423
3900
|
}
|
|
@@ -2618,6 +4095,7 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
2618
4095
|
const toManagedRecords = (dirs)=>Array.isArray(dirs) && dirs.length > 0 && !isEmulatorBrowser(options.browser) ? managedExtensionRecords(options.browser, dirs) : void 0;
|
|
2619
4096
|
let managedExtensionsExplicit = void 0 !== options.managedExtensionDirs;
|
|
2620
4097
|
let managedExtensions = toManagedRecords(options.managedExtensionDirs);
|
|
4098
|
+
let compiledDevAdditions;
|
|
2621
4099
|
let openedEpoch = null;
|
|
2622
4100
|
let eventsBytes = null;
|
|
2623
4101
|
let eventsLines = 0;
|
|
@@ -2659,6 +4137,23 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
2659
4137
|
} : {}
|
|
2660
4138
|
};
|
|
2661
4139
|
const ownsDocument = (prev)=>!isSuperseded() && prev.runId === base.runId;
|
|
4140
|
+
const awaitsExecutor = true === options.readyAwaitsExecutor && 'dev' === options.command && !isWebkitBasedBrowser(options.browser) && !isEmulatorBrowser(options.browser);
|
|
4141
|
+
let executorWaitOver = false;
|
|
4142
|
+
let executorWaitTimer;
|
|
4143
|
+
const awaitsRdpPort = true === options.readyAwaitsRdpPort && 'dev' === options.command && isGeckoBasedBrowser(options.browser);
|
|
4144
|
+
const isHeldReady = (prev)=>'starting' === prev.status && 'string' == typeof prev.compiledAt && !prev.code && (!awaitsRdpPort || 'number' == typeof prev.rdpPort || 'string' == typeof prev.rdpPortError);
|
|
4145
|
+
function releaseHeldReady() {
|
|
4146
|
+
executorWaitOver = true;
|
|
4147
|
+
const prev = readContract();
|
|
4148
|
+
if (!prev || !ownsDocument(prev)) return;
|
|
4149
|
+
if ('string' != typeof prev.awaitingExecutorSince) return;
|
|
4150
|
+
delete prev.awaitingExecutorSince;
|
|
4151
|
+
if (isHeldReady(prev)) prev.status = 'ready';
|
|
4152
|
+
prev.ts = nowISO();
|
|
4153
|
+
try {
|
|
4154
|
+
writeJsonAtomic(readyPath, prev);
|
|
4155
|
+
} catch {}
|
|
4156
|
+
}
|
|
2662
4157
|
function writeReady(status, extra) {
|
|
2663
4158
|
if (foreignLiveDevSession || isSuperseded()) return;
|
|
2664
4159
|
ensureDirSync(metadataDir);
|
|
@@ -2669,6 +4164,7 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
2669
4164
|
...base,
|
|
2670
4165
|
status,
|
|
2671
4166
|
pid: process.pid,
|
|
4167
|
+
pidStartedAt: ownProcessStartedAt(),
|
|
2672
4168
|
ts: nowISO(),
|
|
2673
4169
|
compiledAt,
|
|
2674
4170
|
errors: Array.isArray(extra?.errors) ? extra.errors : []
|
|
@@ -2685,6 +4181,8 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
2685
4181
|
payload.extensionIdSource = 'derived';
|
|
2686
4182
|
}
|
|
2687
4183
|
const sameRun = Boolean(prev && prev.runId === base.runId);
|
|
4184
|
+
const devAdditions = mergeDevAdditions(compiledDevAdditions, sameRun ? prev?.devAdditions : void 0);
|
|
4185
|
+
if (devAdditions) payload.devAdditions = devAdditions;
|
|
2688
4186
|
if (prev && sameRun) {
|
|
2689
4187
|
if ('number' == typeof prev.cdpPort) payload.cdpPort = prev.cdpPort;
|
|
2690
4188
|
if ('number' == typeof prev.rdpPort) payload.rdpPort = prev.rdpPort;
|
|
@@ -2702,9 +4200,16 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
2702
4200
|
if ('string' == typeof prev.webdriverSessionId) payload.webdriverSessionId = prev.webdriverSessionId;
|
|
2703
4201
|
if ('string' == typeof prev.webdriverUnavailableReason) payload.webdriverUnavailableReason = prev.webdriverUnavailableReason;
|
|
2704
4202
|
if ('string' == typeof prev.webdriverRequestPath) payload.webdriverRequestPath = prev.webdriverRequestPath;
|
|
4203
|
+
if (prev.safari && 'object' == typeof prev.safari) payload.safari = prev.safari;
|
|
2705
4204
|
if ('string' == typeof prev.profilePath) payload.profilePath = prev.profilePath;
|
|
2706
|
-
if ('number' == typeof prev.browserPid)
|
|
2707
|
-
|
|
4205
|
+
if ('number' == typeof prev.browserPid) {
|
|
4206
|
+
payload.browserPid = prev.browserPid;
|
|
4207
|
+
if ('string' == typeof prev.browserStartedAt) payload.browserStartedAt = prev.browserStartedAt;
|
|
4208
|
+
}
|
|
4209
|
+
if ('number' == typeof prev.launcherPid) {
|
|
4210
|
+
payload.launcherPid = prev.launcherPid;
|
|
4211
|
+
if ('string' == typeof prev.launcherStartedAt) payload.launcherStartedAt = prev.launcherStartedAt;
|
|
4212
|
+
}
|
|
2708
4213
|
if ('string' == typeof prev.binary && prev.binary) payload.binary = prev.binary;
|
|
2709
4214
|
if ('string' == typeof prev.binaryProvenance && prev.binaryProvenance) payload.binaryProvenance = prev.binaryProvenance;
|
|
2710
4215
|
if ('string' == typeof prev.extensionId && prev.extensionId && ('browser' === prev.extensionIdSource || 'packager' === prev.extensionIdSource)) {
|
|
@@ -2756,7 +4261,17 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
2756
4261
|
}
|
|
2757
4262
|
}
|
|
2758
4263
|
const rdpPortSettled = sameRun && ('number' == typeof prev?.rdpPort || 'string' == typeof prev?.rdpPortError);
|
|
2759
|
-
|
|
4264
|
+
const heldForRdpPort = 'ready' === payload.status && awaitsRdpPort && !rdpPortSettled;
|
|
4265
|
+
const executorSettled = sameRun && 'string' == typeof prev?.executorAttachedAt;
|
|
4266
|
+
if ('ready' === payload.status && awaitsExecutor && !executorWaitOver && !executorSettled) {
|
|
4267
|
+
payload.status = 'starting';
|
|
4268
|
+
payload.awaitingExecutorSince = 'string' == typeof prev?.awaitingExecutorSince && sameRun ? prev.awaitingExecutorSince : nowISO();
|
|
4269
|
+
if (!executorWaitTimer) {
|
|
4270
|
+
executorWaitTimer = setTimeout(releaseHeldReady, READY_EXECUTOR_WAIT_MS);
|
|
4271
|
+
executorWaitTimer.unref?.();
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
if (heldForRdpPort) payload.status = 'starting';
|
|
2760
4275
|
writeJsonAtomic(readyPath, payload);
|
|
2761
4276
|
}
|
|
2762
4277
|
function appendEvent(event) {
|
|
@@ -2788,6 +4303,9 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
2788
4303
|
managedExtensionsExplicit = true;
|
|
2789
4304
|
managedExtensions = toManagedRecords(dirs);
|
|
2790
4305
|
},
|
|
4306
|
+
setDevAdditions (additions) {
|
|
4307
|
+
compiledDevAdditions = additions;
|
|
4308
|
+
},
|
|
2791
4309
|
isSuperseded,
|
|
2792
4310
|
writeStarting () {
|
|
2793
4311
|
if (foreignLiveDevSession) return;
|
|
@@ -2870,6 +4388,10 @@ function createPlaywrightMetadataWriter(options) {
|
|
|
2870
4388
|
return;
|
|
2871
4389
|
}
|
|
2872
4390
|
prev.executorAttachedAt = nowISO();
|
|
4391
|
+
if ('string' == typeof prev.awaitingExecutorSince) {
|
|
4392
|
+
delete prev.awaitingExecutorSince;
|
|
4393
|
+
if (isHeldReady(prev)) prev.status = 'ready';
|
|
4394
|
+
}
|
|
2873
4395
|
delete prev.browserUpNotAttachedAt;
|
|
2874
4396
|
delete prev.browserUpNotAttachedWaitMs;
|
|
2875
4397
|
delete prev.browserUpNotAttachedHint;
|
|
@@ -2914,7 +4436,8 @@ class PlaywrightPlugin {
|
|
|
2914
4436
|
controlPath: options.controlPath,
|
|
2915
4437
|
logsPath: options.logsPath,
|
|
2916
4438
|
managedExtensionDirs: options.managedExtensionDirs,
|
|
2917
|
-
readyAwaitsRdpPort: true === options.readyAwaitsRdpPort
|
|
4439
|
+
readyAwaitsRdpPort: true === options.readyAwaitsRdpPort,
|
|
4440
|
+
readyAwaitsExecutor: true === options.readyAwaitsExecutor
|
|
2918
4441
|
});
|
|
2919
4442
|
}
|
|
2920
4443
|
apply(compiler) {
|
|
@@ -2960,6 +4483,8 @@ class PlaywrightPlugin {
|
|
|
2960
4483
|
durationMs: Number.isFinite(durationMs) ? durationMs : void 0,
|
|
2961
4484
|
errorCount: 0
|
|
2962
4485
|
});
|
|
4486
|
+
const devAdditions = devAdditionsOf(stats?.compilation);
|
|
4487
|
+
if (devAdditions) this.writer.setDevAdditions(devAdditions);
|
|
2963
4488
|
if (this.launchFollows) this.writer.writeCompiled(nowISO());
|
|
2964
4489
|
else this.writer.writeReady(nowISO());
|
|
2965
4490
|
});
|
|
@@ -3055,10 +4580,6 @@ function isPathLike(value) {
|
|
|
3055
4580
|
if (value.startsWith('./') || value.startsWith('../')) return true;
|
|
3056
4581
|
return value.includes('/') || value.includes('\\');
|
|
3057
4582
|
}
|
|
3058
|
-
function isSubpathOf(parent, child) {
|
|
3059
|
-
const rel = __rspack_external_node_path_806ed179.relative(parent, child);
|
|
3060
|
-
return '' !== rel && !rel.startsWith('..') && !__rspack_external_node_path_806ed179.isAbsolute(rel);
|
|
3061
|
-
}
|
|
3062
4583
|
function getBrowserFolder(browser) {
|
|
3063
4584
|
if (browser && isGeckoBasedBrowser(String(browser))) return 'firefox';
|
|
3064
4585
|
if ('edge' === browser) return 'edge';
|
|
@@ -3126,7 +4647,7 @@ function ensurePathsUnderExtensions(projectRoot, paths) {
|
|
|
3126
4647
|
const extensionsRoot = __rspack_external_node_path_806ed179.resolve(projectRoot, 'extensions');
|
|
3127
4648
|
return paths.map((p)=>{
|
|
3128
4649
|
const abs = toAbs(projectRoot, p);
|
|
3129
|
-
if (
|
|
4650
|
+
if (!real_path_isSameOrInsidePath(extensionsRoot, abs)) throw new Error(`Companion extensions must be inside ${extensionsRoot}.\nInvalid path: ${abs}`);
|
|
3130
4651
|
return abs;
|
|
3131
4652
|
});
|
|
3132
4653
|
}
|
|
@@ -3223,7 +4744,7 @@ async function resolveCompanionExtensionsConfig(opts) {
|
|
|
3223
4744
|
if ('string' == typeof normalized.dir) {
|
|
3224
4745
|
const absDir = toAbs(projectRoot, normalized.dir);
|
|
3225
4746
|
const extensionsRoot = __rspack_external_node_path_806ed179.resolve(projectRoot, 'extensions');
|
|
3226
|
-
if (
|
|
4747
|
+
if (!real_path_isSameOrInsidePath(extensionsRoot, absDir)) throw new Error(`extensions.dir must be inside ${extensionsRoot}.\nInvalid dir: ${absDir}`);
|
|
3227
4748
|
output.dir = normalized.dir;
|
|
3228
4749
|
}
|
|
3229
4750
|
if (resolvedPaths.length > 0) output.paths = resolvedPaths;
|
|
@@ -3280,6 +4801,12 @@ function includeSourceMissing(outputPath, sourcePath, projectRoot) {
|
|
|
3280
4801
|
function includeOutputPathInvalid(outputPath, reason) {
|
|
3281
4802
|
return `${pintor.blue('include')} in extension.config.js cannot write ${pintor.yellow(outputPath)}: ${reason}.\nEach key is an output path relative to the extension root, such as ${pintor.blue('models/x.onnx')}.`;
|
|
3282
4803
|
}
|
|
4804
|
+
function scriptsEntriesOnlyImported(relativePaths, folder) {
|
|
4805
|
+
const one = 1 === relativePaths.length;
|
|
4806
|
+
const list = relativePaths.map((entry)=>pintor.yellow(entry)).join(', ');
|
|
4807
|
+
const value = relativePaths.map((entry)=>`'${entry}'`).join(', ');
|
|
4808
|
+
return `${list} ${one ? 'is' : 'are'} built as ${one ? 'an entry' : 'entries'} of ${one ? 'its' : 'their'} own because every file in ${pintor.yellow(folder)} is, yet other files import ${one ? 'it' : 'them'} and nothing names ${one ? 'its' : 'their'} output path. For a helper module, add ${pintor.blue('exclude')}: ${pintor.yellow(`[${value}]`)} to extension.config.js. For a script the extension injects, keep it.`;
|
|
4809
|
+
}
|
|
3283
4810
|
const NODE_BUILTINS = new Set([
|
|
3284
4811
|
'assert',
|
|
3285
4812
|
'buffer',
|
|
@@ -3563,8 +5090,7 @@ function isUnderPublicDir(entry, projectRoot, publicDir) {
|
|
|
3563
5090
|
if (!entry) return false;
|
|
3564
5091
|
const normalizedEntry = String(entry);
|
|
3565
5092
|
const candidate = node_path.isAbsolute(normalizedEntry) ? normalizedEntry : node_path.join(projectRoot, normalizedEntry);
|
|
3566
|
-
|
|
3567
|
-
return Boolean(rel && !rel.startsWith('..') && !node_path.isAbsolute(rel));
|
|
5093
|
+
return real_path_isInsidePath(publicDir, candidate);
|
|
3568
5094
|
}
|
|
3569
5095
|
function filterPublicEntrypoints(list, projectRoot, publicDir) {
|
|
3570
5096
|
const next = {};
|
|
@@ -3733,7 +5259,7 @@ function withDarkMode(config) {
|
|
|
3733
5259
|
function prependToEmittedAsset(compilation, asset, prefix) {
|
|
3734
5260
|
const assetName = asset.name;
|
|
3735
5261
|
const original = asset.source.source().toString();
|
|
3736
|
-
compilation.updateAsset(assetName, new sources.RawSource(
|
|
5262
|
+
compilation.updateAsset(assetName, new sources.RawSource(prependBehindTakeBlock(original, prefix)));
|
|
3737
5263
|
const mapAsset = 'function' == typeof compilation.getAsset ? compilation.getAsset(`${assetName}.map`) : void 0;
|
|
3738
5264
|
if (!mapAsset) return;
|
|
3739
5265
|
const prefixLines = prefix.split('\n').length - 1;
|
|
@@ -3778,45 +5304,232 @@ const RELAY_TARGETS = [
|
|
|
3778
5304
|
re: /(^|\/)chrome_url_overrides\/bookmarks\.js$/i,
|
|
3779
5305
|
context: 'bookmarks'
|
|
3780
5306
|
}
|
|
3781
|
-
];
|
|
3782
|
-
class InjectBridgeRelay {
|
|
3783
|
-
apply(compiler) {
|
|
3784
|
-
const controlPort = parseInt(String(process.env.EXTENSION_CONTROL_PORT || ''), 10);
|
|
3785
|
-
if (!Number.isFinite(controlPort) || controlPort < 1) return;
|
|
3786
|
-
const sourceFor = new Map();
|
|
3787
|
-
for (const t of RELAY_TARGETS)if (!sourceFor.has(t.context)) sourceFor.set(t.context, buildBridgeRelaySource({
|
|
3788
|
-
context: t.context
|
|
3789
|
-
}));
|
|
3790
|
-
compiler.hooks.thisCompilation.tap(InjectBridgeRelay.name, (compilation)=>{
|
|
3791
|
-
compilation.hooks.processAssets.tap({
|
|
3792
|
-
name: InjectBridgeRelay.name,
|
|
3793
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_REPORT + 101
|
|
3794
|
-
}, ()=>{
|
|
3795
|
-
for (const asset of compilation.getAssets()){
|
|
3796
|
-
const target = RELAY_TARGETS.find((t)=>t.re.test(asset.name));
|
|
3797
|
-
if (!target) continue;
|
|
3798
|
-
const original = asset.source.source().toString();
|
|
3799
|
-
if (-1
|
|
3800
|
-
|
|
5307
|
+
];
|
|
5308
|
+
class InjectBridgeRelay {
|
|
5309
|
+
apply(compiler) {
|
|
5310
|
+
const controlPort = parseInt(String(process.env.EXTENSION_CONTROL_PORT || ''), 10);
|
|
5311
|
+
if (!Number.isFinite(controlPort) || controlPort < 1) return;
|
|
5312
|
+
const sourceFor = new Map();
|
|
5313
|
+
for (const t of RELAY_TARGETS)if (!sourceFor.has(t.context)) sourceFor.set(t.context, buildBridgeRelaySource({
|
|
5314
|
+
context: t.context
|
|
5315
|
+
}));
|
|
5316
|
+
compiler.hooks.thisCompilation.tap(InjectBridgeRelay.name, (compilation)=>{
|
|
5317
|
+
compilation.hooks.processAssets.tap({
|
|
5318
|
+
name: InjectBridgeRelay.name,
|
|
5319
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_REPORT + 101
|
|
5320
|
+
}, ()=>{
|
|
5321
|
+
for (const asset of compilation.getAssets()){
|
|
5322
|
+
const target = RELAY_TARGETS.find((t)=>t.re.test(asset.name));
|
|
5323
|
+
if (!target) continue;
|
|
5324
|
+
const original = asset.source.source().toString();
|
|
5325
|
+
if (-1 !== original.indexOf('__extjsBridgeRelayInstalled')) continue;
|
|
5326
|
+
const sheetSignal = 'content' === target.context ? buildDeclaredSheetSignalSource(asset.name) : '';
|
|
5327
|
+
prependToEmittedAsset(compilation, asset, `${sheetSignal}${sourceFor.get(target.context)}\n`);
|
|
5328
|
+
}
|
|
5329
|
+
});
|
|
5330
|
+
});
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5333
|
+
const DEFAULTS = {
|
|
5334
|
+
maxBytes: 8388608,
|
|
5335
|
+
maxLines: 50000,
|
|
5336
|
+
generations: 3,
|
|
5337
|
+
flushIntervalMs: 250,
|
|
5338
|
+
maxQueue: 20000
|
|
5339
|
+
};
|
|
5340
|
+
const HEADER_PROBE_BYTES = 1024;
|
|
5341
|
+
function closeQuietly(fd) {
|
|
5342
|
+
if (void 0 === fd) return;
|
|
5343
|
+
try {
|
|
5344
|
+
__rspack_external_node_fs_1b05aee1.closeSync(fd);
|
|
5345
|
+
} catch {}
|
|
5346
|
+
}
|
|
5347
|
+
function readLogDescriptorRunId(fd) {
|
|
5348
|
+
try {
|
|
5349
|
+
const buffer = Buffer.alloc(HEADER_PROBE_BYTES);
|
|
5350
|
+
const read = __rspack_external_node_fs_1b05aee1.readSync(fd, buffer, 0, HEADER_PROBE_BYTES, 0);
|
|
5351
|
+
const firstLine = buffer.toString('utf-8', 0, read).split(/\r?\n/)[0];
|
|
5352
|
+
const header = JSON.parse(firstLine);
|
|
5353
|
+
return header?.type === 'header' && 'string' == typeof header.runId ? header.runId : void 0;
|
|
5354
|
+
} catch {
|
|
5355
|
+
return;
|
|
5356
|
+
}
|
|
5357
|
+
}
|
|
5358
|
+
function readLogFileRunId(filePath) {
|
|
5359
|
+
let fd;
|
|
5360
|
+
try {
|
|
5361
|
+
fd = __rspack_external_node_fs_1b05aee1.openSync(filePath, 'r');
|
|
5362
|
+
return readLogDescriptorRunId(fd);
|
|
5363
|
+
} catch {
|
|
5364
|
+
return;
|
|
5365
|
+
} finally{
|
|
5366
|
+
closeQuietly(fd);
|
|
5367
|
+
}
|
|
5368
|
+
}
|
|
5369
|
+
function isForeignRunId(owner, runId) {
|
|
5370
|
+
return void 0 !== owner && '' !== owner && owner !== runId;
|
|
5371
|
+
}
|
|
5372
|
+
function isLogFileOwnedByAnotherRun(filePath, runId) {
|
|
5373
|
+
return isForeignRunId(readLogFileRunId(filePath), runId);
|
|
5374
|
+
}
|
|
5375
|
+
function appendToOwnedLogFile(filePath, runId, payload) {
|
|
5376
|
+
let fd;
|
|
5377
|
+
try {
|
|
5378
|
+
fd = __rspack_external_node_fs_1b05aee1.openSync(filePath, 'a+');
|
|
5379
|
+
if (isForeignRunId(readLogDescriptorRunId(fd), runId)) return 'foreign';
|
|
5380
|
+
__rspack_external_node_fs_1b05aee1.appendFileSync(fd, payload, 'utf-8');
|
|
5381
|
+
return 'written';
|
|
5382
|
+
} catch {
|
|
5383
|
+
return 'failed';
|
|
5384
|
+
} finally{
|
|
5385
|
+
closeQuietly(fd);
|
|
5386
|
+
}
|
|
5387
|
+
}
|
|
5388
|
+
function replaceLogFile(filePath, content) {
|
|
5389
|
+
const tempPath = `${filePath}.${process.pid}.tmp`;
|
|
5390
|
+
try {
|
|
5391
|
+
__rspack_external_node_fs_1b05aee1.writeFileSync(tempPath, content, 'utf-8');
|
|
5392
|
+
renameSyncWithRetry(tempPath, filePath);
|
|
5393
|
+
} catch {
|
|
5394
|
+
__rspack_external_node_fs_1b05aee1.rmSync(tempPath, {
|
|
5395
|
+
force: true
|
|
5396
|
+
});
|
|
5397
|
+
__rspack_external_node_fs_1b05aee1.writeFileSync(filePath, content, 'utf-8');
|
|
5398
|
+
}
|
|
5399
|
+
}
|
|
5400
|
+
class LogsFileWriter {
|
|
5401
|
+
opts;
|
|
5402
|
+
queue = [];
|
|
5403
|
+
bytes = 0;
|
|
5404
|
+
lines = 0;
|
|
5405
|
+
droppedToDisk = 0;
|
|
5406
|
+
timer = null;
|
|
5407
|
+
started = false;
|
|
5408
|
+
constructor(options){
|
|
5409
|
+
this.opts = {
|
|
5410
|
+
...DEFAULTS,
|
|
5411
|
+
...options
|
|
5412
|
+
};
|
|
5413
|
+
}
|
|
5414
|
+
start() {
|
|
5415
|
+
if (this.started) return;
|
|
5416
|
+
this.started = true;
|
|
5417
|
+
try {
|
|
5418
|
+
__rspack_external_node_fs_1b05aee1.mkdirSync(__rspack_external_node_path_806ed179.dirname(this.opts.filePath), {
|
|
5419
|
+
recursive: true
|
|
5420
|
+
});
|
|
5421
|
+
if (__rspack_external_node_fs_1b05aee1.existsSync(this.opts.filePath)) this.rotate();
|
|
5422
|
+
} catch {}
|
|
5423
|
+
this.writeHeader(null);
|
|
5424
|
+
this.timer = setInterval(()=>this.flush(), this.opts.flushIntervalMs);
|
|
5425
|
+
if (this.timer.unref) this.timer.unref();
|
|
5426
|
+
}
|
|
5427
|
+
write(event) {
|
|
5428
|
+
this.enqueue(JSON.stringify(event));
|
|
5429
|
+
}
|
|
5430
|
+
enqueue(line) {
|
|
5431
|
+
this.queue.push(line);
|
|
5432
|
+
if (this.queue.length > this.opts.maxQueue) {
|
|
5433
|
+
this.queue.shift();
|
|
5434
|
+
this.droppedToDisk++;
|
|
5435
|
+
}
|
|
5436
|
+
}
|
|
5437
|
+
flush() {
|
|
5438
|
+
if (!this.started || 0 === this.queue.length) return void this.maybeNoteDrops();
|
|
5439
|
+
const batch = this.queue;
|
|
5440
|
+
this.queue = [];
|
|
5441
|
+
const payload = `${batch.join('\n')}\n`;
|
|
5442
|
+
const result = appendToOwnedLogFile(this.opts.filePath, this.opts.runId, payload);
|
|
5443
|
+
if ('foreign' === result) {
|
|
5444
|
+
this.droppedToDisk = 0;
|
|
5445
|
+
return;
|
|
5446
|
+
}
|
|
5447
|
+
if ('written' === result) {
|
|
5448
|
+
this.bytes += Buffer.byteLength(payload);
|
|
5449
|
+
this.lines += batch.length;
|
|
5450
|
+
} else this.droppedToDisk += batch.length;
|
|
5451
|
+
this.maybeNoteDrops();
|
|
5452
|
+
if (this.bytes >= this.opts.maxBytes || this.lines >= this.opts.maxLines) {
|
|
5453
|
+
this.rotate();
|
|
5454
|
+
this.writeHeader(this.opts.runId);
|
|
5455
|
+
}
|
|
5456
|
+
}
|
|
5457
|
+
close() {
|
|
5458
|
+
if (this.timer) {
|
|
5459
|
+
clearInterval(this.timer);
|
|
5460
|
+
this.timer = null;
|
|
5461
|
+
}
|
|
5462
|
+
this.flush();
|
|
5463
|
+
this.started = false;
|
|
5464
|
+
}
|
|
5465
|
+
maybeNoteDrops() {
|
|
5466
|
+
if (0 === this.droppedToDisk) return;
|
|
5467
|
+
const dropped = this.droppedToDisk;
|
|
5468
|
+
this.droppedToDisk = 0;
|
|
5469
|
+
const sentinel = `${JSON.stringify({
|
|
5470
|
+
v: 1,
|
|
5471
|
+
type: 'gap',
|
|
5472
|
+
reason: 'disk_slow',
|
|
5473
|
+
dropped
|
|
5474
|
+
})}\n`;
|
|
5475
|
+
const result = appendToOwnedLogFile(this.opts.filePath, this.opts.runId, sentinel);
|
|
5476
|
+
if ('written' !== result) return;
|
|
5477
|
+
this.bytes += Buffer.byteLength(sentinel);
|
|
5478
|
+
this.lines += 1;
|
|
5479
|
+
}
|
|
5480
|
+
writeHeader(rotatedFrom) {
|
|
5481
|
+
const header = `${JSON.stringify({
|
|
5482
|
+
v: 1,
|
|
5483
|
+
type: 'header',
|
|
5484
|
+
runId: this.opts.runId,
|
|
5485
|
+
startedAt: new Date().toISOString(),
|
|
5486
|
+
rotatedFrom
|
|
5487
|
+
})}\n`;
|
|
5488
|
+
try {
|
|
5489
|
+
replaceLogFile(this.opts.filePath, header);
|
|
5490
|
+
this.bytes = Buffer.byteLength(header);
|
|
5491
|
+
this.lines = 1;
|
|
5492
|
+
} catch {
|
|
5493
|
+
this.bytes = 0;
|
|
5494
|
+
this.lines = 0;
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
rotatedName(n) {
|
|
5498
|
+
return this.opts.filePath.replace(/\.ndjson$/, `.${n}.ndjson`);
|
|
5499
|
+
}
|
|
5500
|
+
rotate() {
|
|
5501
|
+
const { generations } = this.opts;
|
|
5502
|
+
try {
|
|
5503
|
+
const oldest = this.rotatedName(generations);
|
|
5504
|
+
if (__rspack_external_node_fs_1b05aee1.existsSync(oldest)) __rspack_external_node_fs_1b05aee1.rmSync(oldest, {
|
|
5505
|
+
force: true
|
|
3801
5506
|
});
|
|
3802
|
-
|
|
5507
|
+
for(let n = generations - 1; n >= 1; n--){
|
|
5508
|
+
const from = this.rotatedName(n);
|
|
5509
|
+
if (__rspack_external_node_fs_1b05aee1.existsSync(from)) renameSyncWithRetry(from, this.rotatedName(n + 1));
|
|
5510
|
+
}
|
|
5511
|
+
if (__rspack_external_node_fs_1b05aee1.existsSync(this.opts.filePath)) renameSyncWithRetry(this.opts.filePath, this.rotatedName(1));
|
|
5512
|
+
} catch {}
|
|
3803
5513
|
}
|
|
3804
5514
|
}
|
|
3805
|
-
const
|
|
5515
|
+
const actions_file_DEFAULTS = {
|
|
3806
5516
|
maxBytes: 8388608,
|
|
3807
5517
|
maxLines: 50000,
|
|
3808
5518
|
generations: 3
|
|
3809
5519
|
};
|
|
3810
5520
|
class ActionsFileWriter {
|
|
3811
5521
|
opts;
|
|
5522
|
+
owner;
|
|
3812
5523
|
bytes = 0;
|
|
3813
5524
|
lines = 0;
|
|
3814
5525
|
started = false;
|
|
3815
5526
|
constructor(options){
|
|
5527
|
+
const { owner, ...rest } = options;
|
|
3816
5528
|
this.opts = {
|
|
3817
|
-
...
|
|
3818
|
-
...
|
|
5529
|
+
...actions_file_DEFAULTS,
|
|
5530
|
+
...rest
|
|
3819
5531
|
};
|
|
5532
|
+
this.owner = owner;
|
|
3820
5533
|
}
|
|
3821
5534
|
start() {
|
|
3822
5535
|
if (this.started) return;
|
|
@@ -3831,14 +5544,22 @@ class ActionsFileWriter {
|
|
|
3831
5544
|
this.lines = 0;
|
|
3832
5545
|
}
|
|
3833
5546
|
write(record) {
|
|
5547
|
+
if (this.isSuperseded()) return;
|
|
3834
5548
|
if (!this.started) this.start();
|
|
3835
5549
|
const line = `${JSON.stringify(record)}\n`;
|
|
5550
|
+
let fd;
|
|
3836
5551
|
try {
|
|
3837
|
-
__rspack_external_node_fs_1b05aee1.
|
|
5552
|
+
fd = __rspack_external_node_fs_1b05aee1.openSync(this.opts.filePath, 'a');
|
|
5553
|
+
if (this.isSuperseded()) return;
|
|
5554
|
+
__rspack_external_node_fs_1b05aee1.appendFileSync(fd, line, 'utf-8');
|
|
3838
5555
|
this.bytes += Buffer.byteLength(line);
|
|
3839
5556
|
this.lines += 1;
|
|
3840
5557
|
} catch {
|
|
3841
5558
|
return;
|
|
5559
|
+
} finally{
|
|
5560
|
+
if (void 0 !== fd) try {
|
|
5561
|
+
__rspack_external_node_fs_1b05aee1.closeSync(fd);
|
|
5562
|
+
} catch {}
|
|
3842
5563
|
}
|
|
3843
5564
|
if (this.bytes >= this.opts.maxBytes || this.lines >= this.opts.maxLines) {
|
|
3844
5565
|
this.rotate();
|
|
@@ -3849,6 +5570,9 @@ class ActionsFileWriter {
|
|
|
3849
5570
|
close() {
|
|
3850
5571
|
this.started = false;
|
|
3851
5572
|
}
|
|
5573
|
+
isSuperseded() {
|
|
5574
|
+
return Boolean(this.owner && isLogFileOwnedByAnotherRun(this.owner.logsFilePath, this.owner.runId));
|
|
5575
|
+
}
|
|
3852
5576
|
rotatedName(n) {
|
|
3853
5577
|
return this.opts.filePath.replace(/\.ndjson$/, `.${n}.ndjson`);
|
|
3854
5578
|
}
|
|
@@ -4095,6 +5819,112 @@ function createEmulatorFilesMiddleware(holder, viewerOrigin = resolveEmulatorOri
|
|
|
4095
5819
|
}
|
|
4096
5820
|
};
|
|
4097
5821
|
}
|
|
5822
|
+
const EXTENSION_ORIGIN = /^[a-z][a-z0-9+.-]*-extension:\/\/[^/]/i;
|
|
5823
|
+
function isExtensionOrigin(value) {
|
|
5824
|
+
return EXTENSION_ORIGIN.test(String(value ?? '').trim());
|
|
5825
|
+
}
|
|
5826
|
+
function resolveAllowedCorsOrigin(requestOrigin, allowedWebOrigins = [], isSessionExtensionOrigin = ()=>false) {
|
|
5827
|
+
const origin = String(requestOrigin ?? '').trim();
|
|
5828
|
+
if (!origin) return null;
|
|
5829
|
+
if (isExtensionOrigin(origin)) return isSessionExtensionOrigin(origin) ? origin : null;
|
|
5830
|
+
for (const allowed of allowedWebOrigins)if (isSameWebOrigin(origin, allowed)) return normalizeWebOrigin(origin);
|
|
5831
|
+
return null;
|
|
5832
|
+
}
|
|
5833
|
+
function devServerCorsHeaders(requestOrigin, allowedWebOrigins = [], isSessionExtensionOrigin = ()=>false) {
|
|
5834
|
+
const headers = [
|
|
5835
|
+
{
|
|
5836
|
+
key: 'Vary',
|
|
5837
|
+
value: 'Origin'
|
|
5838
|
+
}
|
|
5839
|
+
];
|
|
5840
|
+
const allowed = resolveAllowedCorsOrigin(requestOrigin, allowedWebOrigins, isSessionExtensionOrigin);
|
|
5841
|
+
if (!allowed) return headers;
|
|
5842
|
+
headers.push({
|
|
5843
|
+
key: 'Access-Control-Allow-Origin',
|
|
5844
|
+
value: allowed
|
|
5845
|
+
});
|
|
5846
|
+
if (!isExtensionOrigin(allowed)) headers.push({
|
|
5847
|
+
key: 'Access-Control-Allow-Private-Network',
|
|
5848
|
+
value: 'true'
|
|
5849
|
+
});
|
|
5850
|
+
return headers;
|
|
5851
|
+
}
|
|
5852
|
+
function parseAllowedHosts(value) {
|
|
5853
|
+
const items = Array.isArray(value) ? value : String(value ?? '').split(',');
|
|
5854
|
+
const hosts = items.map((item)=>String(item ?? '').trim()).filter((item)=>item.length > 0);
|
|
5855
|
+
return [
|
|
5856
|
+
...new Set(hosts)
|
|
5857
|
+
];
|
|
5858
|
+
}
|
|
5859
|
+
function refusedHostName(header) {
|
|
5860
|
+
const raw = String(header ?? '').trim();
|
|
5861
|
+
if (!raw) return '';
|
|
5862
|
+
let name = raw;
|
|
5863
|
+
try {
|
|
5864
|
+
name = new URL(`http://${raw}`).hostname;
|
|
5865
|
+
} catch {}
|
|
5866
|
+
return name.replace(/[^A-Za-z0-9.:_[\]-]/g, '?').slice(0, 255);
|
|
5867
|
+
}
|
|
5868
|
+
function refusedHostResponse(host) {
|
|
5869
|
+
const name = host || 'an empty Host header';
|
|
5870
|
+
return `Extension.js dev server refused the host "${name}".\nAllow it with: extension dev --allowed-hosts ${host || '<host>'}\nOr set commands.dev.allowedHosts in extension.config.js. Both take more than one host, comma-separated on the flag.\n`;
|
|
5871
|
+
}
|
|
5872
|
+
function createHostCheckMiddleware(devServer, onRefused) {
|
|
5873
|
+
const announced = new Set();
|
|
5874
|
+
const maxAnnounced = 20;
|
|
5875
|
+
return (req, res, next)=>{
|
|
5876
|
+
const server = devServer;
|
|
5877
|
+
const headerName = req.headers[':authority'] ? ':authority' : 'host';
|
|
5878
|
+
if (server?.isValidHost?.(req.headers, headerName)) return void next();
|
|
5879
|
+
const host = refusedHostName(req.headers[headerName]);
|
|
5880
|
+
if (!announced.has(host) && announced.size < maxAnnounced) {
|
|
5881
|
+
announced.add(host);
|
|
5882
|
+
onRefused(host);
|
|
5883
|
+
}
|
|
5884
|
+
res.statusCode = 403;
|
|
5885
|
+
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
|
5886
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
5887
|
+
res.end(refusedHostResponse(host));
|
|
5888
|
+
};
|
|
5889
|
+
}
|
|
5890
|
+
const HOST_CHECK_MIDDLEWARE_NAME = 'host-header-check';
|
|
5891
|
+
function withHostCheckMiddleware(middlewares, devServer, onRefused) {
|
|
5892
|
+
const entry = {
|
|
5893
|
+
name: HOST_CHECK_MIDDLEWARE_NAME,
|
|
5894
|
+
middleware: createHostCheckMiddleware(devServer, onRefused)
|
|
5895
|
+
};
|
|
5896
|
+
const index = middlewares.findIndex((item)=>item?.name === HOST_CHECK_MIDDLEWARE_NAME);
|
|
5897
|
+
if (-1 === index) return [
|
|
5898
|
+
entry,
|
|
5899
|
+
...middlewares
|
|
5900
|
+
];
|
|
5901
|
+
return middlewares.map((item, position)=>position === index ? entry : item);
|
|
5902
|
+
}
|
|
5903
|
+
function devServerAccessConfig(options) {
|
|
5904
|
+
const viewerOrigin = normalizeWebOrigin(options.emulatorOrigin);
|
|
5905
|
+
const viewerHost = viewerOrigin ? new URL(viewerOrigin).hostname : null;
|
|
5906
|
+
const allowedWebOrigins = viewerOrigin ? [
|
|
5907
|
+
viewerOrigin
|
|
5908
|
+
] : [];
|
|
5909
|
+
const hosts = [
|
|
5910
|
+
options.connectableHost,
|
|
5911
|
+
viewerHost,
|
|
5912
|
+
...parseAllowedHosts(options.allowedHosts)
|
|
5913
|
+
].filter((host)=>Boolean(host));
|
|
5914
|
+
return {
|
|
5915
|
+
allowedHosts: [
|
|
5916
|
+
...new Set(hosts)
|
|
5917
|
+
],
|
|
5918
|
+
headers: (req)=>devServerCorsHeaders(req.headers.origin, allowedWebOrigins, options.isSessionExtensionOrigin)
|
|
5919
|
+
};
|
|
5920
|
+
}
|
|
5921
|
+
function isLoopbackAddress(address) {
|
|
5922
|
+
const value = String(address ?? '').trim().toLowerCase();
|
|
5923
|
+
if (!value) return false;
|
|
5924
|
+
const bare = value.startsWith('::ffff:') ? value.slice(7) : value;
|
|
5925
|
+
if ('::1' === bare || 'localhost' === bare) return true;
|
|
5926
|
+
return /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(bare);
|
|
5927
|
+
}
|
|
4098
5928
|
const DEFAULT_RING_CAPACITY = 5000;
|
|
4099
5929
|
class LogRingBuffer {
|
|
4100
5930
|
capacity;
|
|
@@ -4149,10 +5979,14 @@ class LogRingBuffer {
|
|
|
4149
5979
|
};
|
|
4150
5980
|
}
|
|
4151
5981
|
}
|
|
5982
|
+
function sessionNoun(command) {
|
|
5983
|
+
return 'dev' === command ? 'dev session' : `extension ${command} session`;
|
|
5984
|
+
}
|
|
4152
5985
|
const DEFAULT_CMD_TIMEOUT_MS = 5000;
|
|
4153
5986
|
const MAX_CMD_TIMEOUT_MS = 30000;
|
|
4154
5987
|
const WAKE_HELLO_WAIT_MS = 5000;
|
|
4155
5988
|
const RELOAD_ACK_TIMEOUT_MS = 3000;
|
|
5989
|
+
const RELOAD_RESTART_TIMEOUT_MS = 15000;
|
|
4156
5990
|
const CONTROL_OPS = new Set([
|
|
4157
5991
|
'eval',
|
|
4158
5992
|
'storage.get',
|
|
@@ -4164,33 +5998,37 @@ const CONTROL_OPS = new Set([
|
|
|
4164
5998
|
'inspect'
|
|
4165
5999
|
]);
|
|
4166
6000
|
const EVAL_DENIED = {
|
|
4167
|
-
'eval-disabled':
|
|
4168
|
-
'no-token':
|
|
4169
|
-
'token-mismatch':
|
|
6001
|
+
'eval-disabled': (command)=>`eval is disabled for this session: restart the ${sessionNoun(command)} with --allow-eval`,
|
|
6002
|
+
'no-token': (command)=>`eval session token missing from the hello: the controller could not read the session token under .extension-js/, run the command against the same project root the ${sessionNoun(command)} was started in`,
|
|
6003
|
+
'token-mismatch': (command)=>`eval session token mismatch: the token on disk belongs to another session, reconnect the controller, or restart the ${sessionNoun(command)}`
|
|
4170
6004
|
};
|
|
4171
6005
|
const EVAL_DENIED_NAME = {
|
|
4172
6006
|
'eval-disabled': 'EvalDisabled',
|
|
4173
6007
|
'no-token': 'EvalTokenMissing',
|
|
4174
6008
|
'token-mismatch': 'EvalTokenMismatch'
|
|
4175
6009
|
};
|
|
6010
|
+
function backgroundNoun(engine) {
|
|
6011
|
+
return 'firefox' === engine ? 'background page' : 'service worker';
|
|
6012
|
+
}
|
|
4176
6013
|
const EXECUTOR_ABSENT = {
|
|
4177
|
-
'no-control-port': ()
|
|
4178
|
-
'
|
|
4179
|
-
'
|
|
4180
|
-
'
|
|
4181
|
-
'
|
|
4182
|
-
'
|
|
6014
|
+
'no-control-port': (_secs, _engine, command = 'dev')=>`no executor connected: this ${sessionNoun(command)} has no control port, so the extension was built with no port to dial and nothing can connect. Restart extension ${command}`,
|
|
6015
|
+
'no-background': (_secs, _engine, command = 'dev')=>`no executor connected: the build this session loaded has no background, so nothing in it dials the control channel and no retry changes that. Add a background script or service worker to the manifest, build again and restart extension ${command}`,
|
|
6016
|
+
'stale-resync-pending': (secs, engine, command = 'dev')=>`no executor connected: a ${backgroundNoun(engine)} from a previous ${sessionNoun(command)} dialed in ${secs}s ago and was told to full-reload; the resynced ${'firefox' === engine ? 'page' : 'worker'} should connect shortly, retry in a few seconds`,
|
|
6017
|
+
'never-connected': (_secs, engine, command = 'dev')=>`no executor connected: no extension ${backgroundNoun(engine)} has connected since this ${sessionNoun(command)} started. The browser may still be launching, the profile's cached ${backgroundNoun(engine)} may predate this session, or the session runs with --no-browser; check ready.json status and retry`,
|
|
6018
|
+
'suspended-event-page': (secs, _engine, command = 'dev')=>`no executor connected: Firefox suspended the extension's idle background event page${null != secs ? ` ${secs}s ago` : ''}, and a suspended page does not reconnect on its own: only an extension event wakes it, and waking it over the debugger brought nothing back. Click the extension's toolbar button or open one of its pages in the browser, then retry; if it stays down, restart extension ${command}`,
|
|
6019
|
+
'recently-disconnected': (secs, _engine, command = 'dev')=>`no executor connected: the extension's service worker disconnected${null != secs ? ` ${secs}s ago` : ''}, MV3 workers idle out and reconnect on their own, or the browser may have exited (see browserExitedAt in dist/extension-js/<browser>/ready.json); retry, and if it persists reload the extension or restart the ${sessionNoun(command)}`,
|
|
6020
|
+
'browser-exited': (_secs, _engine, command = 'dev')=>`no executor connected: the browser exited and nothing reconnects on its own. Restart extension ${command} to relaunch it`
|
|
4183
6021
|
};
|
|
4184
|
-
function executorAbsentNoControlPort(reason) {
|
|
4185
|
-
if (!reason) return EXECUTOR_ABSENT['no-control-port']();
|
|
4186
|
-
return `no executor connected: this
|
|
6022
|
+
function executorAbsentNoControlPort(reason, command) {
|
|
6023
|
+
if (!reason) return EXECUTOR_ABSENT['no-control-port'](void 0, void 0, command);
|
|
6024
|
+
return `no executor connected: this ${sessionNoun(command)} has no control port, the control bridge could not bind (${reason}), so the extension was built with no port to dial and nothing can connect. Restart extension ${command}`;
|
|
4187
6025
|
}
|
|
4188
6026
|
function undeliveredReloadWarnNoControlPort(reason) {
|
|
4189
6027
|
const named = reason ? ` (${reason})` : '';
|
|
4190
6028
|
return `No control port, your edit compiled but this dev session has no transport to deliver it. The control bridge could not bind${named}, so the extension was built with no port to dial. Restart extension dev to try again.`;
|
|
4191
6029
|
}
|
|
4192
|
-
function executorAbsentBrowserExited(at, how) {
|
|
4193
|
-
return `no executor connected: the browser exited at ${at}${how ? ` (${how})` : ''} and nothing reconnects on its own. Restart extension
|
|
6030
|
+
function executorAbsentBrowserExited(at, how, command) {
|
|
6031
|
+
return `no executor connected: the browser exited at ${at}${how ? ` (${how})` : ''} and nothing reconnects on its own. Restart extension ${command} to relaunch it`;
|
|
4194
6032
|
}
|
|
4195
6033
|
const STALE_RESYNC_HINT_MS = 30000;
|
|
4196
6034
|
const UNDELIVERED_RELOAD_GRACE_MS = 10000;
|
|
@@ -4203,6 +6041,9 @@ const UNDELIVERED_RELOAD_WARN_EMULATOR = {
|
|
|
4203
6041
|
'never-connected': "No emulated Chromium page is connected, your edit compiled but no page received it. Open the emulated Chromium URL the dev server printed; reloads resume automatically once the page connects.",
|
|
4204
6042
|
'recently-disconnected': "The emulated Chromium page disconnected, your edit compiled but no page received it. Reopen the emulated Chromium URL the dev server printed; reloads resume automatically once the page reconnects."
|
|
4205
6043
|
};
|
|
6044
|
+
function alreadyRunsLatchedBuild(hello, frame) {
|
|
6045
|
+
return 'service-worker' === frame.reloadType && 'string' == typeof frame.build && '' !== frame.build && hello.build === frame.build && !frame.changedContentScriptEntries?.length && !frame.changedScriptFiles?.length && !frame.refreshedStylesheets?.length && !frame.standalonePages?.length;
|
|
6046
|
+
}
|
|
4206
6047
|
class BridgeBroker {
|
|
4207
6048
|
instanceId;
|
|
4208
6049
|
runId;
|
|
@@ -4212,6 +6053,7 @@ class BridgeBroker {
|
|
|
4212
6053
|
ring;
|
|
4213
6054
|
file;
|
|
4214
6055
|
roles = new Map();
|
|
6056
|
+
sessionExtensionOrigins = new Set();
|
|
4215
6057
|
allowControl;
|
|
4216
6058
|
allowEval;
|
|
4217
6059
|
controlToken;
|
|
@@ -4230,17 +6072,29 @@ class BridgeBroker {
|
|
|
4230
6072
|
onExecutorAttached;
|
|
4231
6073
|
onExecutorDetached;
|
|
4232
6074
|
wakeExecutor;
|
|
6075
|
+
bootRegistrations;
|
|
6076
|
+
bootRegistrationsAwaited = false;
|
|
6077
|
+
lateBootRegistrationSaid = false;
|
|
6078
|
+
bootRegistrationWaiters = new Set();
|
|
6079
|
+
onLateBootRegistration;
|
|
4233
6080
|
executorWaiters = new Set();
|
|
4234
6081
|
waking = new Set();
|
|
4235
6082
|
onReloadApplied;
|
|
6083
|
+
sessionCommand;
|
|
6084
|
+
producerless = false;
|
|
4236
6085
|
lastProducerDisconnectedAt = null;
|
|
4237
6086
|
browserExitedAt = null;
|
|
4238
6087
|
browserExitHow = null;
|
|
4239
6088
|
lastStaleHelloAt = null;
|
|
4240
6089
|
pendingReload;
|
|
6090
|
+
replayedTabs = 0;
|
|
6091
|
+
latchedReloadDelivered;
|
|
4241
6092
|
ackingProducers = new Set();
|
|
6093
|
+
sessionBuilds = new Set();
|
|
6094
|
+
producerBuilds = new Map();
|
|
4242
6095
|
reloadSeq = 0;
|
|
4243
6096
|
reloadAck = null;
|
|
6097
|
+
reloadRestart = null;
|
|
4244
6098
|
constructor(options){
|
|
4245
6099
|
this.instanceId = options.instanceId;
|
|
4246
6100
|
this.runId = options.runId;
|
|
@@ -4257,6 +6111,8 @@ class BridgeBroker {
|
|
|
4257
6111
|
this.onExecutorDetached = options.onExecutorDetached;
|
|
4258
6112
|
this.wakeExecutor = options.wakeExecutor;
|
|
4259
6113
|
this.onReloadApplied = options.onReloadApplied;
|
|
6114
|
+
this.onLateBootRegistration = options.onLateBootRegistration;
|
|
6115
|
+
this.sessionCommand = options.sessionCommand ?? 'dev';
|
|
4260
6116
|
this.now = options.now ?? (()=>Date.now());
|
|
4261
6117
|
this.setTimer = options.setTimer ?? ((fn, ms)=>setTimeout(fn, ms));
|
|
4262
6118
|
this.clearTimer = options.clearTimer ?? ((h)=>clearTimeout(h));
|
|
@@ -4291,6 +6147,9 @@ class BridgeBroker {
|
|
|
4291
6147
|
case 'result':
|
|
4292
6148
|
if ('producer' === this.roles.get(conn)) this.onResult(frame);
|
|
4293
6149
|
return;
|
|
6150
|
+
case 'boot-registrations':
|
|
6151
|
+
if ('producer' === this.roles.get(conn)) this.onBootRegistrations(conn, frame);
|
|
6152
|
+
return;
|
|
4294
6153
|
case 'reload-ack':
|
|
4295
6154
|
if (this.isReloadReceiver(this.roles.get(conn))) this.onReloadAck(frame);
|
|
4296
6155
|
return;
|
|
@@ -4303,6 +6162,7 @@ class BridgeBroker {
|
|
|
4303
6162
|
this.roles.delete(conn);
|
|
4304
6163
|
this.evalGate.delete(conn);
|
|
4305
6164
|
this.ackingProducers.delete(conn);
|
|
6165
|
+
this.producerBuilds.delete(conn);
|
|
4306
6166
|
if ('producer' === role) {
|
|
4307
6167
|
this.lastProducerDisconnectedAt = this.now();
|
|
4308
6168
|
this.failCommandsOf(conn);
|
|
@@ -4361,6 +6221,15 @@ class BridgeBroker {
|
|
|
4361
6221
|
changedFiles: instruction.changedFiles,
|
|
4362
6222
|
...instruction.changedScriptFiles?.length ? {
|
|
4363
6223
|
changedScriptFiles: instruction.changedScriptFiles
|
|
6224
|
+
} : {},
|
|
6225
|
+
...instruction.refreshedStylesheets?.length ? {
|
|
6226
|
+
refreshedStylesheets: instruction.refreshedStylesheets
|
|
6227
|
+
} : {},
|
|
6228
|
+
...instruction.standalonePages?.length ? {
|
|
6229
|
+
standalonePages: instruction.standalonePages
|
|
6230
|
+
} : {},
|
|
6231
|
+
...instruction.build ? {
|
|
6232
|
+
build: instruction.build
|
|
4364
6233
|
} : {}
|
|
4365
6234
|
};
|
|
4366
6235
|
let notified = 0;
|
|
@@ -4374,6 +6243,15 @@ class BridgeBroker {
|
|
|
4374
6243
|
this.armReloadAck(awaitingAck > 0 ? frame : void 0);
|
|
4375
6244
|
return notified;
|
|
4376
6245
|
}
|
|
6246
|
+
runsBuild(build) {
|
|
6247
|
+
if (!build) return false;
|
|
6248
|
+
let producers = 0;
|
|
6249
|
+
for (const [conn, role] of this.roles)if ('producer' === role) {
|
|
6250
|
+
if (this.producerBuilds.get(conn) !== build) return false;
|
|
6251
|
+
producers++;
|
|
6252
|
+
}
|
|
6253
|
+
return producers > 0;
|
|
6254
|
+
}
|
|
4377
6255
|
noteReloadApplied(kind, label) {
|
|
4378
6256
|
try {
|
|
4379
6257
|
this.onReloadApplied?.(kind, label);
|
|
@@ -4382,9 +6260,15 @@ class BridgeBroker {
|
|
|
4382
6260
|
awaitReloadAck() {
|
|
4383
6261
|
return this.reloadAck?.outcome ?? Promise.resolve('not-expected');
|
|
4384
6262
|
}
|
|
6263
|
+
reloadReplayedTabs() {
|
|
6264
|
+
return this.replayedTabs;
|
|
6265
|
+
}
|
|
4385
6266
|
armReloadAck(frame) {
|
|
4386
6267
|
this.reloadAck?.settle('not-expected');
|
|
4387
6268
|
this.reloadAck = null;
|
|
6269
|
+
this.replayedTabs = 0;
|
|
6270
|
+
this.reloadRestart?.settle('not-expected');
|
|
6271
|
+
this.reloadRestart = null;
|
|
4388
6272
|
const reloadId = frame?.reloadId;
|
|
4389
6273
|
if (!reloadId) return;
|
|
4390
6274
|
let settled = false;
|
|
@@ -4399,6 +6283,9 @@ class BridgeBroker {
|
|
|
4399
6283
|
}, RELOAD_ACK_TIMEOUT_MS);
|
|
4400
6284
|
this.reloadAck = {
|
|
4401
6285
|
reloadId,
|
|
6286
|
+
...frame?.build ? {
|
|
6287
|
+
build: frame.build
|
|
6288
|
+
} : {},
|
|
4402
6289
|
outcome,
|
|
4403
6290
|
settle: (next)=>{
|
|
4404
6291
|
if (settled) return;
|
|
@@ -4412,7 +6299,113 @@ class BridgeBroker {
|
|
|
4412
6299
|
const pending = this.pendingReload;
|
|
4413
6300
|
const confirmsPending = pending ? frame.reloadId ? pending.reloadId === frame.reloadId : pending.reloadType === frame.reloadType : false;
|
|
4414
6301
|
if (confirmsPending) this.pendingReload = void 0;
|
|
4415
|
-
if (frame.reloadId && this.reloadAck?.reloadId === frame.reloadId)
|
|
6302
|
+
if (frame.reloadId && this.reloadAck?.reloadId === frame.reloadId) {
|
|
6303
|
+
const tabs = Number(frame.replayedTabs);
|
|
6304
|
+
this.replayedTabs = Number.isInteger(tabs) && tabs > 0 ? tabs : 0;
|
|
6305
|
+
this.reloadAck.settle('acked');
|
|
6306
|
+
if ('full' === frame.reloadType || 'service-worker' === frame.reloadType) this.armReloadRestart(frame.reloadId, this.reloadAck.build);
|
|
6307
|
+
}
|
|
6308
|
+
}
|
|
6309
|
+
awaitBootRegistrations(timeoutMs) {
|
|
6310
|
+
this.bootRegistrationsAwaited = true;
|
|
6311
|
+
if (this.bootRegistrations) return Promise.resolve(this.bootRegistrations.outcome);
|
|
6312
|
+
return new Promise((resolve)=>{
|
|
6313
|
+
const release = (outcome)=>{
|
|
6314
|
+
this.clearTimer(timer);
|
|
6315
|
+
this.bootRegistrationWaiters.delete(release);
|
|
6316
|
+
resolve(outcome);
|
|
6317
|
+
};
|
|
6318
|
+
const timer = this.setTimer(()=>{
|
|
6319
|
+
this.bootRegistrationWaiters.delete(release);
|
|
6320
|
+
resolve('timeout');
|
|
6321
|
+
}, timeoutMs);
|
|
6322
|
+
timer.unref?.();
|
|
6323
|
+
this.bootRegistrationWaiters.add(release);
|
|
6324
|
+
});
|
|
6325
|
+
}
|
|
6326
|
+
onBootRegistrations(conn, frame) {
|
|
6327
|
+
if (frame.late) {
|
|
6328
|
+
if (this.bootRegistrations?.conn !== conn || 'settled' !== this.bootRegistrations.outcome || !this.bootRegistrationsAwaited || this.lateBootRegistrationSaid) return;
|
|
6329
|
+
this.lateBootRegistrationSaid = true;
|
|
6330
|
+
try {
|
|
6331
|
+
this.onLateBootRegistration?.('number' == typeof frame.afterMs ? frame.afterMs : void 0);
|
|
6332
|
+
} catch {}
|
|
6333
|
+
return;
|
|
6334
|
+
}
|
|
6335
|
+
if (this.bootRegistrations) return;
|
|
6336
|
+
const outcome = frame.pending ? 'timeout' : 'settled';
|
|
6337
|
+
this.bootRegistrations = {
|
|
6338
|
+
conn,
|
|
6339
|
+
outcome
|
|
6340
|
+
};
|
|
6341
|
+
for (const release of [
|
|
6342
|
+
...this.bootRegistrationWaiters
|
|
6343
|
+
])release(outcome);
|
|
6344
|
+
}
|
|
6345
|
+
awaitReloadRestart() {
|
|
6346
|
+
return this.reloadRestart?.outcome ?? Promise.resolve('not-expected');
|
|
6347
|
+
}
|
|
6348
|
+
awaitLateReloadRestart() {
|
|
6349
|
+
return this.reloadRestart?.late ?? Promise.resolve(null);
|
|
6350
|
+
}
|
|
6351
|
+
armReloadRestart(reloadId, build) {
|
|
6352
|
+
const armedAt = this.now();
|
|
6353
|
+
let settled = false;
|
|
6354
|
+
let overdue = false;
|
|
6355
|
+
let resolve = ()=>void 0;
|
|
6356
|
+
let resolveLate = ()=>void 0;
|
|
6357
|
+
const outcome = new Promise((r)=>{
|
|
6358
|
+
resolve = r;
|
|
6359
|
+
});
|
|
6360
|
+
const late = new Promise((r)=>{
|
|
6361
|
+
resolveLate = r;
|
|
6362
|
+
});
|
|
6363
|
+
const timer = this.setTimer(()=>{
|
|
6364
|
+
if (settled) return;
|
|
6365
|
+
settled = true;
|
|
6366
|
+
if (null !== this.browserExitedAt) {
|
|
6367
|
+
resolve('not-expected');
|
|
6368
|
+
resolveLate(null);
|
|
6369
|
+
return;
|
|
6370
|
+
}
|
|
6371
|
+
this.wakeExecutor?.().catch(()=>false);
|
|
6372
|
+
overdue = true;
|
|
6373
|
+
resolve('not-restarted');
|
|
6374
|
+
}, RELOAD_RESTART_TIMEOUT_MS);
|
|
6375
|
+
timer.unref?.();
|
|
6376
|
+
this.reloadRestart = {
|
|
6377
|
+
reloadId,
|
|
6378
|
+
outcome,
|
|
6379
|
+
late,
|
|
6380
|
+
settle: (next, helloBuild)=>{
|
|
6381
|
+
if (!settled) {
|
|
6382
|
+
settled = true;
|
|
6383
|
+
this.clearTimer(timer);
|
|
6384
|
+
resolve(next);
|
|
6385
|
+
resolveLate(null);
|
|
6386
|
+
return;
|
|
6387
|
+
}
|
|
6388
|
+
if (!overdue) return;
|
|
6389
|
+
overdue = false;
|
|
6390
|
+
resolveLate('restarted' === next ? {
|
|
6391
|
+
afterMs: this.now() - armedAt,
|
|
6392
|
+
runsBuild: !this.compiledBefore(helloBuild, build)
|
|
6393
|
+
} : null);
|
|
6394
|
+
}
|
|
6395
|
+
};
|
|
6396
|
+
}
|
|
6397
|
+
async deliverLatchedReload() {
|
|
6398
|
+
const frame = this.pendingReload;
|
|
6399
|
+
if (!frame || !this.canWakeExecutor()) return false;
|
|
6400
|
+
let woke = false;
|
|
6401
|
+
try {
|
|
6402
|
+
woke = await this.wakeExecutor?.() === true;
|
|
6403
|
+
} catch {
|
|
6404
|
+
woke = false;
|
|
6405
|
+
}
|
|
6406
|
+
if (!woke) return false;
|
|
6407
|
+
if (this.pendingReload === frame) await this.waitForExecutor(WAKE_HELLO_WAIT_MS);
|
|
6408
|
+
return this.latchedReloadDelivered === frame;
|
|
4416
6409
|
}
|
|
4417
6410
|
undeliveredReloadWarning(options) {
|
|
4418
6411
|
const now = this.now();
|
|
@@ -4459,6 +6452,42 @@ class BridgeBroker {
|
|
|
4459
6452
|
this.staleResyncTimes.push(now);
|
|
4460
6453
|
return true;
|
|
4461
6454
|
}
|
|
6455
|
+
noteSessionBuild(build) {
|
|
6456
|
+
if (!build) return;
|
|
6457
|
+
const first = 0 === this.sessionBuilds.size;
|
|
6458
|
+
this.sessionBuilds.add(build);
|
|
6459
|
+
if (!first) return;
|
|
6460
|
+
for (const [conn, role] of [
|
|
6461
|
+
...this.roles
|
|
6462
|
+
]){
|
|
6463
|
+
if ('producer' !== role) continue;
|
|
6464
|
+
const running = this.producerBuilds.get(conn);
|
|
6465
|
+
if (running && !this.sessionBuilds.has(running)) this.resyncEarlierSessionProducer(conn, running);
|
|
6466
|
+
}
|
|
6467
|
+
}
|
|
6468
|
+
compiledBefore(build, than) {
|
|
6469
|
+
if (!build || !than) return false;
|
|
6470
|
+
const order = [
|
|
6471
|
+
...this.sessionBuilds
|
|
6472
|
+
];
|
|
6473
|
+
const at = order.indexOf(build);
|
|
6474
|
+
return -1 !== at && at < order.indexOf(than);
|
|
6475
|
+
}
|
|
6476
|
+
runsEarlierSessionBuild(hello) {
|
|
6477
|
+
return 'string' == typeof hello.build && '' !== hello.build && this.sessionBuilds.size > 0 && !this.sessionBuilds.has(hello.build);
|
|
6478
|
+
}
|
|
6479
|
+
resyncEarlierSessionProducer(conn, build) {
|
|
6480
|
+
this.lastStaleHelloAt = this.now();
|
|
6481
|
+
if (this.allowStaleProducerResync()) {
|
|
6482
|
+
if (this.authorMode) debugLine(`[control-bridge] stale producer (build ${build}) → full-reload resync`);
|
|
6483
|
+
conn.send({
|
|
6484
|
+
type: 'reload',
|
|
6485
|
+
reloadType: 'full',
|
|
6486
|
+
label: 'extension (resyncing previous dev session)'
|
|
6487
|
+
});
|
|
6488
|
+
}
|
|
6489
|
+
conn.close(4001, 'build from an earlier session');
|
|
6490
|
+
}
|
|
4462
6491
|
onHello(conn, hello) {
|
|
4463
6492
|
if (1 !== hello.v) return void conn.close(4002, 'unsupported envelope version');
|
|
4464
6493
|
const fromViewerOrigin = isSameWebOrigin(conn.origin, this.viewerOrigin);
|
|
@@ -4496,6 +6525,11 @@ class BridgeBroker {
|
|
|
4496
6525
|
conn.close(4001, 'instanceId mismatch');
|
|
4497
6526
|
return;
|
|
4498
6527
|
}
|
|
6528
|
+
if ('producer' === hello.role && this.runsEarlierSessionBuild(hello)) return void this.resyncEarlierSessionProducer(conn, String(hello.build));
|
|
6529
|
+
if ('producer' !== hello.role && this.isRemotePeer(conn)) {
|
|
6530
|
+
if (!this.controlToken || hello.token !== this.controlToken) return void conn.close(4004, 'session token required from beyond loopback');
|
|
6531
|
+
}
|
|
6532
|
+
if (isExtensionOrigin(conn.origin)) this.sessionExtensionOrigins.add(String(conn.origin).trim());
|
|
4499
6533
|
if ('controller' === hello.role) {
|
|
4500
6534
|
if (!this.allowControl) return void conn.close(4003, 'control channel not available');
|
|
4501
6535
|
this.roles.set(conn, 'controller');
|
|
@@ -4508,6 +6542,8 @@ class BridgeBroker {
|
|
|
4508
6542
|
if ('producer' === hello.role) {
|
|
4509
6543
|
this.producerEverConnected = true;
|
|
4510
6544
|
if (hello.acksReloads) this.ackingProducers.add(conn);
|
|
6545
|
+
if ('string' == typeof hello.build && hello.build) this.producerBuilds.set(conn, hello.build);
|
|
6546
|
+
this.reloadRestart?.settle('restarted', 'string' == typeof hello.build ? hello.build : void 0);
|
|
4511
6547
|
this.lastUndeliveredWarnKind = null;
|
|
4512
6548
|
this.browserExitedAt = null;
|
|
4513
6549
|
this.browserExitHow = null;
|
|
@@ -4523,7 +6559,8 @@ class BridgeBroker {
|
|
|
4523
6559
|
if ('producer' === hello.role && this.pendingReload) {
|
|
4524
6560
|
const frame = this.pendingReload;
|
|
4525
6561
|
this.pendingReload = void 0;
|
|
4526
|
-
|
|
6562
|
+
if (alreadyRunsLatchedBuild(hello, frame)) this.latchedReloadDelivered = frame;
|
|
6563
|
+
else if (conn.send(frame)) this.latchedReloadDelivered = frame;
|
|
4527
6564
|
}
|
|
4528
6565
|
if ('consumer' === hello.role) {
|
|
4529
6566
|
const ready = {
|
|
@@ -4540,6 +6577,9 @@ class BridgeBroker {
|
|
|
4540
6577
|
});
|
|
4541
6578
|
}
|
|
4542
6579
|
}
|
|
6580
|
+
noteNoBackground() {
|
|
6581
|
+
this.producerless = true;
|
|
6582
|
+
}
|
|
4543
6583
|
noteControlPortUnavailable(reason) {
|
|
4544
6584
|
this.controlPortUnavailable = String(reason ?? '');
|
|
4545
6585
|
}
|
|
@@ -4549,12 +6589,19 @@ class BridgeBroker {
|
|
|
4549
6589
|
}
|
|
4550
6590
|
diagnoseExecutorAbsence() {
|
|
4551
6591
|
const now = this.now();
|
|
4552
|
-
if (null != this.controlPortUnavailable) return executorAbsentNoControlPort(this.controlPortUnavailable);
|
|
4553
|
-
if (this.browserExitedAt) return executorAbsentBrowserExited(this.browserExitedAt, this.browserExitHow);
|
|
4554
|
-
if (
|
|
4555
|
-
if (
|
|
4556
|
-
if (
|
|
4557
|
-
return EXECUTOR_ABSENT['
|
|
6592
|
+
if (null != this.controlPortUnavailable) return executorAbsentNoControlPort(this.controlPortUnavailable, this.sessionCommand);
|
|
6593
|
+
if (this.browserExitedAt) return executorAbsentBrowserExited(this.browserExitedAt, this.browserExitHow, this.sessionCommand);
|
|
6594
|
+
if (this.producerless && !this.producerEverConnected) return EXECUTOR_ABSENT['no-background'](void 0, this.engine, this.sessionCommand);
|
|
6595
|
+
if (null != this.lastStaleHelloAt && now - this.lastStaleHelloAt < STALE_RESYNC_HINT_MS) return EXECUTOR_ABSENT['stale-resync-pending'](Math.round((now - this.lastStaleHelloAt) / 1000), this.engine, this.sessionCommand);
|
|
6596
|
+
if (!this.producerEverConnected) return EXECUTOR_ABSENT['never-connected'](void 0, this.engine, this.sessionCommand);
|
|
6597
|
+
if ('firefox' === this.engine) return EXECUTOR_ABSENT['suspended-event-page'](null != this.lastProducerDisconnectedAt ? Math.round((now - this.lastProducerDisconnectedAt) / 1000) : void 0, this.engine, this.sessionCommand);
|
|
6598
|
+
return EXECUTOR_ABSENT['recently-disconnected'](null != this.lastProducerDisconnectedAt ? Math.round((now - this.lastProducerDisconnectedAt) / 1000) : void 0, this.engine, this.sessionCommand);
|
|
6599
|
+
}
|
|
6600
|
+
isSessionExtensionOrigin(origin) {
|
|
6601
|
+
return this.sessionExtensionOrigins.has(String(origin ?? '').trim());
|
|
6602
|
+
}
|
|
6603
|
+
isRemotePeer(conn) {
|
|
6604
|
+
return void 0 !== conn.remoteAddress && !isLoopbackAddress(conn.remoteAddress);
|
|
4558
6605
|
}
|
|
4559
6606
|
gateEval(token) {
|
|
4560
6607
|
if (!this.allowEval) return 'eval-disabled';
|
|
@@ -4619,7 +6666,7 @@ class BridgeBroker {
|
|
|
4619
6666
|
};
|
|
4620
6667
|
if (!CONTROL_OPS.has(cmd.op)) return void deny('BadRequest', `unknown op: ${String(cmd.op)}`);
|
|
4621
6668
|
const evalGate = this.evalGate.get(controller) ?? 'eval-disabled';
|
|
4622
|
-
if (isEval && 'ok' !== evalGate) return void deny(EVAL_DENIED_NAME[evalGate], EVAL_DENIED[evalGate]);
|
|
6669
|
+
if (isEval && 'ok' !== evalGate) return void deny(EVAL_DENIED_NAME[evalGate], EVAL_DENIED[evalGate](this.sessionCommand));
|
|
4623
6670
|
if (this.pending.has(cmd.cmdId) || this.waking.has(cmd.cmdId)) return void deny('BadRequest', `cmdId ${cmd.cmdId} is still pending for another command, send a fresh id`);
|
|
4624
6671
|
const executor = this.firstExecutor();
|
|
4625
6672
|
if (!executor && this.canWakeExecutor()) return void this.wakeThenRoute(controller, cmd, deny, {
|
|
@@ -4746,127 +6793,6 @@ class BridgeBroker {
|
|
|
4746
6793
|
return n;
|
|
4747
6794
|
}
|
|
4748
6795
|
}
|
|
4749
|
-
const logs_file_DEFAULTS = {
|
|
4750
|
-
maxBytes: 8388608,
|
|
4751
|
-
maxLines: 50000,
|
|
4752
|
-
generations: 3,
|
|
4753
|
-
flushIntervalMs: 250,
|
|
4754
|
-
maxQueue: 20000
|
|
4755
|
-
};
|
|
4756
|
-
class LogsFileWriter {
|
|
4757
|
-
opts;
|
|
4758
|
-
queue = [];
|
|
4759
|
-
bytes = 0;
|
|
4760
|
-
lines = 0;
|
|
4761
|
-
droppedToDisk = 0;
|
|
4762
|
-
timer = null;
|
|
4763
|
-
started = false;
|
|
4764
|
-
constructor(options){
|
|
4765
|
-
this.opts = {
|
|
4766
|
-
...logs_file_DEFAULTS,
|
|
4767
|
-
...options
|
|
4768
|
-
};
|
|
4769
|
-
}
|
|
4770
|
-
start() {
|
|
4771
|
-
if (this.started) return;
|
|
4772
|
-
this.started = true;
|
|
4773
|
-
try {
|
|
4774
|
-
__rspack_external_node_fs_1b05aee1.mkdirSync(__rspack_external_node_path_806ed179.dirname(this.opts.filePath), {
|
|
4775
|
-
recursive: true
|
|
4776
|
-
});
|
|
4777
|
-
if (__rspack_external_node_fs_1b05aee1.existsSync(this.opts.filePath)) this.rotate();
|
|
4778
|
-
} catch {}
|
|
4779
|
-
this.writeHeader(null);
|
|
4780
|
-
this.timer = setInterval(()=>this.flush(), this.opts.flushIntervalMs);
|
|
4781
|
-
if (this.timer.unref) this.timer.unref();
|
|
4782
|
-
}
|
|
4783
|
-
write(event) {
|
|
4784
|
-
this.enqueue(JSON.stringify(event));
|
|
4785
|
-
}
|
|
4786
|
-
enqueue(line) {
|
|
4787
|
-
this.queue.push(line);
|
|
4788
|
-
if (this.queue.length > this.opts.maxQueue) {
|
|
4789
|
-
this.queue.shift();
|
|
4790
|
-
this.droppedToDisk++;
|
|
4791
|
-
}
|
|
4792
|
-
}
|
|
4793
|
-
flush() {
|
|
4794
|
-
if (!this.started || 0 === this.queue.length) return void this.maybeNoteDrops();
|
|
4795
|
-
const batch = this.queue;
|
|
4796
|
-
this.queue = [];
|
|
4797
|
-
const payload = `${batch.join('\n')}\n`;
|
|
4798
|
-
try {
|
|
4799
|
-
__rspack_external_node_fs_1b05aee1.appendFileSync(this.opts.filePath, payload, 'utf-8');
|
|
4800
|
-
this.bytes += Buffer.byteLength(payload);
|
|
4801
|
-
this.lines += batch.length;
|
|
4802
|
-
} catch {
|
|
4803
|
-
this.droppedToDisk += batch.length;
|
|
4804
|
-
}
|
|
4805
|
-
this.maybeNoteDrops();
|
|
4806
|
-
if (this.bytes >= this.opts.maxBytes || this.lines >= this.opts.maxLines) {
|
|
4807
|
-
this.rotate();
|
|
4808
|
-
this.writeHeader(this.opts.runId);
|
|
4809
|
-
}
|
|
4810
|
-
}
|
|
4811
|
-
close() {
|
|
4812
|
-
if (this.timer) {
|
|
4813
|
-
clearInterval(this.timer);
|
|
4814
|
-
this.timer = null;
|
|
4815
|
-
}
|
|
4816
|
-
this.flush();
|
|
4817
|
-
this.started = false;
|
|
4818
|
-
}
|
|
4819
|
-
maybeNoteDrops() {
|
|
4820
|
-
if (0 === this.droppedToDisk) return;
|
|
4821
|
-
const dropped = this.droppedToDisk;
|
|
4822
|
-
this.droppedToDisk = 0;
|
|
4823
|
-
try {
|
|
4824
|
-
const sentinel = `${JSON.stringify({
|
|
4825
|
-
v: 1,
|
|
4826
|
-
type: 'gap',
|
|
4827
|
-
reason: 'disk_slow',
|
|
4828
|
-
dropped
|
|
4829
|
-
})}\n`;
|
|
4830
|
-
__rspack_external_node_fs_1b05aee1.appendFileSync(this.opts.filePath, sentinel, 'utf-8');
|
|
4831
|
-
this.bytes += Buffer.byteLength(sentinel);
|
|
4832
|
-
this.lines += 1;
|
|
4833
|
-
} catch {}
|
|
4834
|
-
}
|
|
4835
|
-
writeHeader(rotatedFrom) {
|
|
4836
|
-
const header = `${JSON.stringify({
|
|
4837
|
-
v: 1,
|
|
4838
|
-
type: 'header',
|
|
4839
|
-
runId: this.opts.runId,
|
|
4840
|
-
startedAt: new Date().toISOString(),
|
|
4841
|
-
rotatedFrom
|
|
4842
|
-
})}\n`;
|
|
4843
|
-
try {
|
|
4844
|
-
__rspack_external_node_fs_1b05aee1.writeFileSync(this.opts.filePath, header, 'utf-8');
|
|
4845
|
-
this.bytes = Buffer.byteLength(header);
|
|
4846
|
-
this.lines = 1;
|
|
4847
|
-
} catch {
|
|
4848
|
-
this.bytes = 0;
|
|
4849
|
-
this.lines = 0;
|
|
4850
|
-
}
|
|
4851
|
-
}
|
|
4852
|
-
rotatedName(n) {
|
|
4853
|
-
return this.opts.filePath.replace(/\.ndjson$/, `.${n}.ndjson`);
|
|
4854
|
-
}
|
|
4855
|
-
rotate() {
|
|
4856
|
-
const { generations } = this.opts;
|
|
4857
|
-
try {
|
|
4858
|
-
const oldest = this.rotatedName(generations);
|
|
4859
|
-
if (__rspack_external_node_fs_1b05aee1.existsSync(oldest)) __rspack_external_node_fs_1b05aee1.rmSync(oldest, {
|
|
4860
|
-
force: true
|
|
4861
|
-
});
|
|
4862
|
-
for(let n = generations - 1; n >= 1; n--){
|
|
4863
|
-
const from = this.rotatedName(n);
|
|
4864
|
-
if (__rspack_external_node_fs_1b05aee1.existsSync(from)) renameSyncWithRetry(from, this.rotatedName(n + 1));
|
|
4865
|
-
}
|
|
4866
|
-
if (__rspack_external_node_fs_1b05aee1.existsSync(this.opts.filePath)) renameSyncWithRetry(this.opts.filePath, this.rotatedName(1));
|
|
4867
|
-
} catch {}
|
|
4868
|
-
}
|
|
4869
|
-
}
|
|
4870
6796
|
const SLOW_CONSUMER_BYTES = 8388608;
|
|
4871
6797
|
const PRODUCER_KEEPALIVE_INTERVAL_MS = 20000;
|
|
4872
6798
|
let connSeq = 0;
|
|
@@ -4895,6 +6821,7 @@ function startControlServer(options) {
|
|
|
4895
6821
|
const conn = {
|
|
4896
6822
|
id: `c${++connSeq}`,
|
|
4897
6823
|
origin: 'string' == typeof origin ? origin : void 0,
|
|
6824
|
+
remoteAddress: String(request?.socket?.remoteAddress ?? ''),
|
|
4898
6825
|
send (frame) {
|
|
4899
6826
|
if (socket.readyState !== WebSocket.OPEN) return false;
|
|
4900
6827
|
if (socket.bufferedAmount > SLOW_CONSUMER_BYTES) {
|
|
@@ -4949,8 +6876,7 @@ function startControlServer(options) {
|
|
|
4949
6876
|
}
|
|
4950
6877
|
const BACKGROUND_ASSET = /(^|\/)background\/(?:service_worker|scripts?|index)\.js$/i;
|
|
4951
6878
|
function isSameOrInside(parent, child) {
|
|
4952
|
-
|
|
4953
|
-
return '' === rel || !__rspack_external_node_path_806ed179.isAbsolute(rel) && '..' !== rel.split(__rspack_external_node_path_806ed179.sep)[0];
|
|
6879
|
+
return real_path_isSameOrInsidePath(parent, child);
|
|
4954
6880
|
}
|
|
4955
6881
|
function controlledBuildDir(packageJsonDir, browser, distPath) {
|
|
4956
6882
|
const inProject = __rspack_external_node_path_806ed179.join(browserArtifactsDir(packageJsonDir, browser), 'controlled');
|
|
@@ -5037,9 +6963,9 @@ function prepareControlledBuild(input) {
|
|
|
5037
6963
|
if (relay) {
|
|
5038
6964
|
const file = __rspack_external_node_path_806ed179.join(input.controlledPath, rel);
|
|
5039
6965
|
const original = __rspack_external_node_fs_1b05aee1.readFileSync(file, 'utf-8');
|
|
5040
|
-
if (!original.includes('__extjsBridgeRelayInstalled')) __rspack_external_node_fs_1b05aee1.writeFileSync(file, `${buildBridgeRelaySource({
|
|
6966
|
+
if (!original.includes('__extjsBridgeRelayInstalled')) __rspack_external_node_fs_1b05aee1.writeFileSync(file, prependBehindTakeBlock(original, `${buildBridgeRelaySource({
|
|
5041
6967
|
context: relay.context
|
|
5042
|
-
})}\n
|
|
6968
|
+
})}\n`));
|
|
5043
6969
|
continue;
|
|
5044
6970
|
}
|
|
5045
6971
|
if (!BACKGROUND_ASSET.test(rel)) continue;
|
|
@@ -5058,12 +6984,17 @@ async function startProductionControl(options) {
|
|
|
5058
6984
|
const allowControl = Boolean(options.allowControl) || allowEval;
|
|
5059
6985
|
const instanceId = randomUUID();
|
|
5060
6986
|
const runId = options.runId || instanceId;
|
|
6987
|
+
const logsFilePath = logsPath(packageJsonDir, browser);
|
|
5061
6988
|
const logFile = new LogsFileWriter({
|
|
5062
|
-
filePath:
|
|
6989
|
+
filePath: logsFilePath,
|
|
5063
6990
|
runId
|
|
5064
6991
|
});
|
|
5065
6992
|
const actions = allowControl ? new ActionsFileWriter({
|
|
5066
|
-
filePath: actionsPath(packageJsonDir, browser)
|
|
6993
|
+
filePath: actionsPath(packageJsonDir, browser),
|
|
6994
|
+
owner: {
|
|
6995
|
+
runId,
|
|
6996
|
+
logsFilePath
|
|
6997
|
+
}
|
|
5067
6998
|
}) : void 0;
|
|
5068
6999
|
const controlToken = allowEval ? writeControlToken(packageJsonDir, browser) : void 0;
|
|
5069
7000
|
const broker = new BridgeBroker({
|
|
@@ -5077,6 +7008,7 @@ async function startProductionControl(options) {
|
|
|
5077
7008
|
allowEval,
|
|
5078
7009
|
controlToken,
|
|
5079
7010
|
actions,
|
|
7011
|
+
sessionCommand: options.command ?? 'preview',
|
|
5080
7012
|
onExecutorAttached: options.onExecutorAttached,
|
|
5081
7013
|
onExecutorDetached: options.onExecutorDetached,
|
|
5082
7014
|
...isGeckoBasedBrowser(browser) && options.wakeExecutor ? {
|
|
@@ -5097,6 +7029,7 @@ async function startProductionControl(options) {
|
|
|
5097
7029
|
instanceId,
|
|
5098
7030
|
host: options.host
|
|
5099
7031
|
});
|
|
7032
|
+
if (0 === backgroundAssets.length) broker.noteNoBackground();
|
|
5100
7033
|
let closed = false;
|
|
5101
7034
|
const release = ()=>{
|
|
5102
7035
|
try {
|
|
@@ -5105,7 +7038,7 @@ async function startProductionControl(options) {
|
|
|
5105
7038
|
try {
|
|
5106
7039
|
actions?.close();
|
|
5107
7040
|
} catch {}
|
|
5108
|
-
if (controlToken) clearControlToken(packageJsonDir, browser);
|
|
7041
|
+
if (controlToken) clearControlToken(packageJsonDir, browser, controlToken);
|
|
5109
7042
|
};
|
|
5110
7043
|
process.once('exit', release);
|
|
5111
7044
|
return {
|
|
@@ -5267,8 +7200,7 @@ function withoutNestedRoots(found) {
|
|
|
5267
7200
|
return unique.filter((dir)=>!unique.some((other)=>other !== dir && isInside(dir, other)));
|
|
5268
7201
|
}
|
|
5269
7202
|
function isInside(dir, parent) {
|
|
5270
|
-
|
|
5271
|
-
return Boolean(rel) && !rel.startsWith('..') && !__rspack_external_node_path_806ed179.isAbsolute(rel);
|
|
7203
|
+
return real_path_isInsidePath(parent, dir);
|
|
5272
7204
|
}
|
|
5273
7205
|
function readRunIdFromReadyFile(readyPath) {
|
|
5274
7206
|
try {
|
|
@@ -5307,6 +7239,16 @@ function previewArchiveTarget(metadataCommand, outputPath) {
|
|
|
5307
7239
|
cacheRoot: remoteArchiveCacheRoot()
|
|
5308
7240
|
};
|
|
5309
7241
|
}
|
|
7242
|
+
const EXECUTOR_ATTACH_WAIT_MS = 10000;
|
|
7243
|
+
function firstOf(settled, ms) {
|
|
7244
|
+
return new Promise((resolve)=>{
|
|
7245
|
+
const timer = setTimeout(resolve, ms);
|
|
7246
|
+
settled.then(()=>{
|
|
7247
|
+
clearTimeout(timer);
|
|
7248
|
+
resolve();
|
|
7249
|
+
});
|
|
7250
|
+
});
|
|
7251
|
+
}
|
|
5310
7252
|
async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher) {
|
|
5311
7253
|
const metadataCommand = 'start' === previewOptions.metadataCommand ? 'start' : 'preview';
|
|
5312
7254
|
const projectStructure = await getProjectStructure(pathOrRemoteUrl, {
|
|
@@ -5370,18 +7312,27 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
5370
7312
|
}
|
|
5371
7313
|
let launchPath = outputPath;
|
|
5372
7314
|
let launched;
|
|
7315
|
+
let executorAttached;
|
|
5373
7316
|
if (previewOptions.allowControl || previewOptions.allowEval) {
|
|
7317
|
+
let noteAttached = ()=>void 0;
|
|
7318
|
+
executorAttached = new Promise((resolve)=>{
|
|
7319
|
+
noteAttached = resolve;
|
|
7320
|
+
});
|
|
5374
7321
|
let stampAttached;
|
|
5375
7322
|
let stampDetached;
|
|
5376
7323
|
const control = await startProductionControl({
|
|
5377
7324
|
packageJsonDir,
|
|
5378
7325
|
browser: String(browser),
|
|
7326
|
+
command: metadataCommand,
|
|
5379
7327
|
distPath: outputPath,
|
|
5380
7328
|
allowControl: previewOptions.allowControl,
|
|
5381
7329
|
allowEval: previewOptions.allowEval,
|
|
5382
7330
|
host: previewOptions.host,
|
|
5383
7331
|
runId: getSessionRunId(packageJsonDir, String(browser)),
|
|
5384
|
-
onExecutorAttached: ()=>
|
|
7332
|
+
onExecutorAttached: ()=>{
|
|
7333
|
+
stampAttached?.();
|
|
7334
|
+
noteAttached();
|
|
7335
|
+
},
|
|
5385
7336
|
onExecutorDetached: ()=>stampDetached?.(),
|
|
5386
7337
|
wakeExecutor: async ()=>{
|
|
5387
7338
|
try {
|
|
@@ -5391,6 +7342,7 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
5391
7342
|
}
|
|
5392
7343
|
}
|
|
5393
7344
|
});
|
|
7345
|
+
if (0 === control.backgroundAssets.length) executorAttached = void 0;
|
|
5394
7346
|
launchPath = control.controlledPath;
|
|
5395
7347
|
metadata = createPlaywrightMetadataWriter({
|
|
5396
7348
|
packageJsonDir,
|
|
@@ -5406,7 +7358,7 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
5406
7358
|
});
|
|
5407
7359
|
stampAttached = ()=>metadata.stampExecutorAttached();
|
|
5408
7360
|
stampDetached = ()=>metadata.stampExecutorDetached();
|
|
5409
|
-
humanLine(productionControlOpen(browser, launchPath, outputPath, Boolean(previewOptions.allowEval)));
|
|
7361
|
+
humanLine(productionControlOpen(browser, launchPath, outputPath, Boolean(previewOptions.allowEval), control.backgroundAssets.length > 0));
|
|
5410
7362
|
}
|
|
5411
7363
|
humanLine(runningMessage(browser));
|
|
5412
7364
|
if (warnings.length) humanLine(previewOptions.outputPath ? previewingCustomOutput(browser, outputPath, distPath) : previewingSourceFallback(browser, distPath));
|
|
@@ -5447,6 +7399,9 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
5447
7399
|
const resolvedOpts = {
|
|
5448
7400
|
browser,
|
|
5449
7401
|
outPath: launchPath,
|
|
7402
|
+
...launchPath === outputPath ? {} : {
|
|
7403
|
+
shippedPath: outputPath
|
|
7404
|
+
},
|
|
5450
7405
|
contextDir: packageJsonDir,
|
|
5451
7406
|
readyPath: metadata.readyPath,
|
|
5452
7407
|
extensionsToLoad: unpackedExtensionDirsToLoad,
|
|
@@ -5473,6 +7428,7 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
5473
7428
|
};
|
|
5474
7429
|
if (!browserLauncher) throw new Error("extensionPreview requires a browserLauncher callback. The browser launch code has moved to programs/extension/browsers/.");
|
|
5475
7430
|
launched = await browserLauncher(resolvedOpts) || void 0;
|
|
7431
|
+
if (executorAttached && !merged.dryRun) await firstOf(executorAttached, EXECUTOR_ATTACH_WAIT_MS);
|
|
5476
7432
|
metadata.writeReady();
|
|
5477
7433
|
process.once('exit', ()=>{
|
|
5478
7434
|
metadata.writeShutdown(`the ${metadataCommand} session ended`);
|
|
@@ -5481,4 +7437,4 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
|
|
|
5481
7437
|
warnings
|
|
5482
7438
|
};
|
|
5483
7439
|
}
|
|
5484
|
-
export { ActionsFileWriter, BUILD_COMMAND_DEFAULTS, BridgeBroker, CONTROL_PORT_ASSET_NAME, DEV_COMMAND_DEFAULTS, InjectBridgeRelay, LogRingBuffer, LogsFileWriter, PlaywrightPlugin, START_BUILD_DEFAULTS, assertNoManagedDependencyConflicts, attachEmulatorFileIndex, autoExitForceKill, autoExitModeEnabled, autoExitTriggered, browserRunnerDisabled, buildBridgeProducerSource, buildEmulatorViewerUrl, bundlerFatalError, bundlerRecompiling, computeExtensionsToLoad, controlBridgeUnavailable, createEmulatorFileIndexHolder, createEmulatorFilesMiddlewareEntry, createPlaywrightMetadataWriter, detectLiveDevSessionOwner, devServerHostRefused, devServerRestarting, devServerStartTimeout, emulatorViewerUrl, excludeEntryMissing, extensionJsRunnerError, extensionPreview, falseProfileSource, getSessionRunId, getSpecialFoldersDataForCompiler, getSpecialFoldersDataForProjectRoot, includeOutputPathInvalid, includeSourceMissing,
|
|
7440
|
+
export { ActionsFileWriter, BUILD_COMMAND_DEFAULTS, BridgeBroker, CONTROL_PORT_ASSET_NAME, DEV_BOOT_REGISTERS_GLOBAL, DEV_COMMAND_DEFAULTS, InjectBridgeRelay, LogRingBuffer, LogsFileWriter, PlaywrightPlugin, START_BUILD_DEFAULTS, assertNoManagedDependencyConflicts, attachEmulatorFileIndex, autoExitForceKill, autoExitModeEnabled, autoExitTriggered, browserRunnerDisabled, buildBridgeProducerSource, buildEmulatorViewerUrl, bundlerFatalError, bundlerRecompiling, collectReferenceCorpus, computeExtensionsToLoad, controlBridgeUnavailable, createEmulatorFileIndexHolder, createEmulatorFilesMiddlewareEntry, createPlaywrightMetadataWriter, debugSessionPorts, detectLiveDevSessionOwner, devAdditionsNote, devAdditionsOf, devServerAccessConfig, devServerHostRefused, devServerRestarting, devServerStartTimeout, emulatorViewerUrl, excludeEntryMissing, extensionJsRunnerError, extensionPreview, falseProfileSource, getSessionRunId, getSpecialFoldersDataForCompiler, getSpecialFoldersDataForProjectRoot, includeOutputPathInvalid, includeSourceMissing, isLoopbackAddress, lateBootRegistration, manifestGoneDuringSession, manifestNamesExcludedFile, mergeOptionLayers, messages_ready, noEntrypointsDetected, portInUse, prependToEmittedAsset, publicFileCollidesWithEntry, publicFolderAppeared, publicFolderOffRef, publicFolderShadowed, publicMustBeAtProjectRoot, recordCodedWarning, recordDevAdditions, referenceSpellings, resolveCompanionExtensionDirs, resolveCompanionExtensionsConfig, resolveEmulatorOrigin, runnerCleanupError, runnerUncaughtException, runnerUnhandledRejection, sanitize, scriptsEntriesOnlyImported, serverRestartRequiredFromSpecialFolderMessageOnly, shouldWarnPortConflict, spacerLine, specialFolderChangeDetected, specialFoldersSetupSummary, stampReadyDistExtensionId, stampReadyKnownExtensionId, startControlServer, takeCodedWarnings, withDarkMode, withHostCheckMiddleware };
|