extension-develop 4.0.6 → 4.0.7-canary.1783860631.e2b9b285
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/dist/0~dev-server.mjs +40 -25
- package/dist/0~rspack-config.mjs +744 -137
- package/dist/101.mjs +44 -35
- package/dist/{224.mjs → 266.mjs} +7 -26
- package/dist/291.mjs +4 -1
- package/dist/80.mjs +202 -0
- package/dist/839.mjs +197 -50
- package/dist/ensure-hmr-for-scripts.js +21 -5
- package/dist/ensure-hmr-for-scripts.mjs +21 -5
- package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +4 -4
- package/dist/extension-js-devtools/chrome/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/chrome/pages/welcome.js +1 -1
- package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +4 -4
- package/dist/extension-js-devtools/chromium/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/chromium/pages/welcome.js +1 -1
- package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/edge/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/edge/pages/centralized-logger.js +4 -4
- package/dist/extension-js-devtools/edge/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/edge/pages/welcome.js +1 -1
- package/dist/extension-js-devtools/extension-js/chrome/events.ndjson +102 -2
- package/dist/extension-js-devtools/extension-js/chrome/ready.json +7 -7
- package/dist/extension-js-devtools/extension-js/chromium/events.ndjson +104 -2
- package/dist/extension-js-devtools/extension-js/chromium/ready.json +7 -7
- package/dist/extension-js-devtools/extension-js/edge/events.ndjson +102 -2
- package/dist/extension-js-devtools/extension-js/edge/ready.json +7 -7
- package/dist/extension-js-devtools/extension-js/firefox/events.ndjson +102 -2
- package/dist/extension-js-devtools/extension-js/firefox/ready.json +7 -7
- package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.css +1 -1
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +4 -4
- package/dist/extension-js-devtools/firefox/pages/welcome.css +1 -1
- package/dist/extension-js-devtools/firefox/pages/welcome.js +1 -1
- package/dist/extension-js-theme/extension-js/chrome/events.ndjson +102 -2
- package/dist/extension-js-theme/extension-js/chrome/ready.json +7 -7
- package/dist/extension-js-theme/extension-js/chromium/events.ndjson +102 -2
- package/dist/extension-js-theme/extension-js/chromium/ready.json +7 -7
- package/dist/extension-js-theme/extension-js/edge/events.ndjson +102 -2
- package/dist/extension-js-theme/extension-js/edge/ready.json +7 -7
- package/dist/extension-js-theme/extension-js/firefox/events.ndjson +174 -4
- package/dist/extension-js-theme/extension-js/firefox/ready.json +7 -7
- package/dist/feature-scripts-content-script-wrapper.js +8 -6
- package/dist/feature-scripts-content-script-wrapper.mjs +8 -6
- package/dist/feature-scripts-native-geturl-import-loader.mjs +119 -0
- package/package.json +1 -1
package/dist/0~dev-server.mjs
CHANGED
|
@@ -5,9 +5,10 @@ import { rspack } from "@rspack/core";
|
|
|
5
5
|
import { RspackDevServer } from "@rspack/dev-server";
|
|
6
6
|
import { merge } from "webpack-merge";
|
|
7
7
|
import { WebSocket, WebSocketServer } from "ws";
|
|
8
|
+
import { hasProjectDependency, findNearestProjectManifestDirSync } from "./80.mjs";
|
|
8
9
|
import { createPlaywrightMetadataWriter, autoExitModeEnabled, autoExitForceKill, loadCommandConfig, extensionJsRunnerError, portInUse, devServerStartTimeout, autoExitTriggered, loadCustomConfig, loadBrowserConfig, sanitize, resolveCompanionExtensionsConfig, getSpecialFoldersDataForProjectRoot } from "./101.mjs";
|
|
9
10
|
import { CONTROL_WS_PATH, clearControlToken, writeControlToken } from "./875.mjs";
|
|
10
|
-
import { dispatchReload, readContentScriptCount,
|
|
11
|
+
import { createChangedSourcesTracker, dispatchReload, readContentScriptCount, buildSourceFeatureIndex, classifyReloadFromSources } from "./839.mjs";
|
|
11
12
|
import { setupNoBrowserBannerOnFirstDone, webpackConfig, resolveConnectableHost, setupCompilerLifecycleHooks } from "./0~rspack-config.mjs";
|
|
12
13
|
import * as __rspack_external_path from "path";
|
|
13
14
|
import * as __rspack_external_crypto from "crypto";
|
|
@@ -75,25 +76,9 @@ class PortManager {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
function hasDependency(projectPath, dependency) {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
for(let i = 0; i < maxDepth; i++){
|
|
82
|
-
const candidate = __rspack_external_path.join(currentDirectory, 'package.json');
|
|
83
|
-
if (__rspack_external_fs.existsSync(candidate)) return currentDirectory;
|
|
84
|
-
const parentDirectory = __rspack_external_path.dirname(currentDirectory);
|
|
85
|
-
if (parentDirectory === currentDirectory) break;
|
|
86
|
-
currentDirectory = parentDirectory;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const packageJsonDirectory = findNearestPackageJsonDirectory(projectPath);
|
|
90
|
-
if (!packageJsonDirectory) return false;
|
|
91
|
-
const packageJsonPath = __rspack_external_path.join(packageJsonDirectory, 'package.json');
|
|
92
|
-
if (!__rspack_external_fs.existsSync(packageJsonPath)) return false;
|
|
93
|
-
const packageJson = JSON.parse(__rspack_external_fs.readFileSync(packageJsonPath, 'utf8'));
|
|
94
|
-
const dependencies = packageJson.dependencies || {};
|
|
95
|
-
const devDependencies = packageJson.devDependencies || {};
|
|
96
|
-
return !!dependencies[dependency] || !!devDependencies[dependency];
|
|
79
|
+
const manifestDirectory = findNearestProjectManifestDirSync(projectPath, 4);
|
|
80
|
+
if (!manifestDirectory) return false;
|
|
81
|
+
return hasProjectDependency(manifestDirectory, dependency);
|
|
97
82
|
}
|
|
98
83
|
function isUsingJSFramework(projectPath) {
|
|
99
84
|
const frameworks = [
|
|
@@ -464,6 +449,7 @@ class BridgeBroker {
|
|
|
464
449
|
evalAllowed = new Map();
|
|
465
450
|
pending = new Map();
|
|
466
451
|
staleResyncTimes = [];
|
|
452
|
+
pendingReload;
|
|
467
453
|
constructor(options){
|
|
468
454
|
this.instanceId = options.instanceId;
|
|
469
455
|
this.runId = options.runId;
|
|
@@ -530,8 +516,19 @@ class BridgeBroker {
|
|
|
530
516
|
conn.send(frame);
|
|
531
517
|
notified++;
|
|
532
518
|
} catch {}
|
|
519
|
+
this.pendingReload = 0 === notified ? frame : void 0;
|
|
533
520
|
return notified;
|
|
534
521
|
}
|
|
522
|
+
pingProducers() {
|
|
523
|
+
let pinged = 0;
|
|
524
|
+
for (const [conn, role] of this.roles)if ('producer' === role) try {
|
|
525
|
+
conn.send({
|
|
526
|
+
type: 'ping'
|
|
527
|
+
});
|
|
528
|
+
pinged++;
|
|
529
|
+
} catch {}
|
|
530
|
+
return pinged;
|
|
531
|
+
}
|
|
535
532
|
ingestLog(incoming) {
|
|
536
533
|
const event = this.ring.push(incoming);
|
|
537
534
|
this.file?.write(event);
|
|
@@ -577,6 +574,11 @@ class BridgeBroker {
|
|
|
577
574
|
}
|
|
578
575
|
if ('producer' !== hello.role && 'consumer' !== hello.role) return void conn.close(CLOSE_BAD_HELLO, 'unknown role');
|
|
579
576
|
this.roles.set(conn, hello.role);
|
|
577
|
+
if ('producer' === hello.role && this.pendingReload) {
|
|
578
|
+
const frame = this.pendingReload;
|
|
579
|
+
this.pendingReload = void 0;
|
|
580
|
+
conn.send(frame);
|
|
581
|
+
}
|
|
580
582
|
if ('consumer' === hello.role) {
|
|
581
583
|
const ready = {
|
|
582
584
|
type: 'ready',
|
|
@@ -745,6 +747,7 @@ class BridgeBroker {
|
|
|
745
747
|
}
|
|
746
748
|
const SLOW_CONSUMER_BYTES = 8388608;
|
|
747
749
|
const CLOSE_SLOW_CONSUMER = 4008;
|
|
750
|
+
const PRODUCER_KEEPALIVE_INTERVAL_MS = 20000;
|
|
748
751
|
let connSeq = 0;
|
|
749
752
|
function startControlServer(options) {
|
|
750
753
|
const { broker } = options;
|
|
@@ -793,10 +796,13 @@ function startControlServer(options) {
|
|
|
793
796
|
wss.on('listening', ()=>{
|
|
794
797
|
const address = wss.address();
|
|
795
798
|
const port = 'object' == typeof address && address ? address.port : 0;
|
|
799
|
+
const keepalive = setInterval(()=>broker.pingProducers(), PRODUCER_KEEPALIVE_INTERVAL_MS);
|
|
800
|
+
keepalive.unref?.();
|
|
796
801
|
resolve({
|
|
797
802
|
port,
|
|
798
803
|
broker,
|
|
799
804
|
close: ()=>new Promise((res)=>{
|
|
805
|
+
clearInterval(keepalive);
|
|
800
806
|
for (const client of wss.clients)try {
|
|
801
807
|
client.terminate();
|
|
802
808
|
} catch {}
|
|
@@ -807,6 +813,9 @@ function startControlServer(options) {
|
|
|
807
813
|
});
|
|
808
814
|
}
|
|
809
815
|
function controlPortFilePath(packageJsonDir, browser) {
|
|
816
|
+
return __rspack_external_path.join(packageJsonDir, '.extension-js', `control-port-${browser}`);
|
|
817
|
+
}
|
|
818
|
+
function legacyControlPortFilePath(packageJsonDir, browser) {
|
|
810
819
|
return __rspack_external_path.join(packageJsonDir, 'dist', 'extension-js', browser, 'control-port');
|
|
811
820
|
}
|
|
812
821
|
function readPersistedControlPort(filePath) {
|
|
@@ -826,6 +835,7 @@ function writePersistedControlPort(filePath, port) {
|
|
|
826
835
|
} catch {}
|
|
827
836
|
}
|
|
828
837
|
function shouldWriteAssetToDisk(filePath) {
|
|
838
|
+
if (/(?:^|[/\\])\.\.(?:[/\\]|$)/.test(filePath)) return false;
|
|
829
839
|
return !/(?:^|[/\\])manifest\.json$/i.test(filePath);
|
|
830
840
|
}
|
|
831
841
|
function isSamePath(left, right) {
|
|
@@ -963,8 +973,9 @@ function installManifestDiskWriteGuard(manifestOutputPath) {
|
|
|
963
973
|
}
|
|
964
974
|
async function dev_server_devServer(projectStructure, devOptions) {
|
|
965
975
|
process.env.EXTENSION_BROWSER_LAUNCH_ENABLED = devOptions.noBrowser ? '0' : '1';
|
|
966
|
-
const { manifestPath, packageJsonPath } = projectStructure;
|
|
967
|
-
const
|
|
976
|
+
const { manifestPath, packageJsonPath, denoJsonPath } = projectStructure;
|
|
977
|
+
const projectManifestPath = packageJsonPath || denoJsonPath;
|
|
978
|
+
const packageJsonDir = projectManifestPath ? __rspack_external_path.dirname(projectManifestPath) : __rspack_external_path.dirname(manifestPath);
|
|
968
979
|
const commandConfig = await loadCommandConfig(packageJsonDir, 'dev');
|
|
969
980
|
const browserConfig = await loadBrowserConfig(packageJsonDir, devOptions.browser);
|
|
970
981
|
const portManager = new PortManager(8080);
|
|
@@ -1017,7 +1028,7 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
1017
1028
|
bridgeLogFile.start();
|
|
1018
1029
|
bridgeActionsFile?.start();
|
|
1019
1030
|
const controlPortFile = controlPortFilePath(packageJsonDir, browserName);
|
|
1020
|
-
const preferredControlPort = readPersistedControlPort(controlPortFile);
|
|
1031
|
+
const preferredControlPort = readPersistedControlPort(controlPortFile) ?? readPersistedControlPort(legacyControlPortFilePath(packageJsonDir, browserName));
|
|
1021
1032
|
let controlServer;
|
|
1022
1033
|
try {
|
|
1023
1034
|
controlServer = await startControlServer({
|
|
@@ -1095,11 +1106,14 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
1095
1106
|
return;
|
|
1096
1107
|
}
|
|
1097
1108
|
const outputPath = String(compilation.options?.output?.path || '');
|
|
1109
|
+
const contextDir = String(compilation.options?.context || '');
|
|
1098
1110
|
const { forcedFull, changedSources: sources } = changedSources.snapshot();
|
|
1099
1111
|
const instruction = classifyReloadFromSources({
|
|
1100
1112
|
changedSources: sources,
|
|
1101
1113
|
forcedFull,
|
|
1102
|
-
getContentScriptCount: ()=>readContentScriptCount(compilation, outputPath)
|
|
1114
|
+
getContentScriptCount: ()=>readContentScriptCount(compilation, outputPath),
|
|
1115
|
+
getSourceFeatureIndex: ()=>buildSourceFeatureIndex(compilation, contextDir),
|
|
1116
|
+
outputPath
|
|
1103
1117
|
});
|
|
1104
1118
|
await dispatchReload(instruction, {
|
|
1105
1119
|
broker: bridgeBroker
|
|
@@ -1126,7 +1140,8 @@ async function dev_server_devServer(projectStructure, devOptions) {
|
|
|
1126
1140
|
manifestPath,
|
|
1127
1141
|
readyPath: metadata.readyPath
|
|
1128
1142
|
});
|
|
1129
|
-
|
|
1143
|
+
const requestedPort = Number(devOptions.port);
|
|
1144
|
+
if (Number.isFinite(requestedPort) && requestedPort !== port) console.log(portInUse(requestedPort, port));
|
|
1130
1145
|
const serverConfig = {
|
|
1131
1146
|
host: devServerHost,
|
|
1132
1147
|
allowedHosts: 'all',
|