extension-develop 3.16.0 → 3.16.1
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~rspack-config.mjs +190 -6
- package/dist/946.mjs +62 -5
- package/dist/extension-js-devtools/chrome/background/service_worker.js +1 -1
- 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/welcome.css +1 -1
- package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -1
- package/dist/extension-js-devtools/chromium/background/service_worker.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/welcome.css +1 -1
- package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -1
- package/dist/extension-js-devtools/edge/background/service_worker.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/welcome.css +1 -1
- package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -1
- package/dist/extension-js-devtools/firefox/background/scripts.js +1 -1
- 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/welcome.css +1 -1
- package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -1
- package/dist/feature-scripts-content-script-wrapper.js +1 -1
- package/dist/feature-scripts-content-script-wrapper.mjs +1 -1
- package/package.json +1 -1
package/dist/0~rspack-config.mjs
CHANGED
|
@@ -208,6 +208,45 @@ function specialFolderChangeDetected(action, folder, relativePath) {
|
|
|
208
208
|
}
|
|
209
209
|
class WarnUponFolderChanges {
|
|
210
210
|
pendingChanges = [];
|
|
211
|
+
knownFolderFiles = new Set();
|
|
212
|
+
hasSnapshot = false;
|
|
213
|
+
snapshotFolderFiles(projectPath) {
|
|
214
|
+
if (this.hasSnapshot) return;
|
|
215
|
+
this.hasSnapshot = true;
|
|
216
|
+
const SKIP_DIRS = new Set([
|
|
217
|
+
'node_modules',
|
|
218
|
+
'dist',
|
|
219
|
+
'build',
|
|
220
|
+
'.git',
|
|
221
|
+
'.turbo',
|
|
222
|
+
'.next',
|
|
223
|
+
'coverage'
|
|
224
|
+
]);
|
|
225
|
+
const walk = (dir)=>{
|
|
226
|
+
let entries;
|
|
227
|
+
try {
|
|
228
|
+
entries = __rspack_external_fs.readdirSync(dir, {
|
|
229
|
+
withFileTypes: true
|
|
230
|
+
});
|
|
231
|
+
} catch {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
for (const entry of entries){
|
|
235
|
+
if (entry.name.startsWith('.')) continue;
|
|
236
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
237
|
+
const full = __rspack_external_path.join(dir, entry.name);
|
|
238
|
+
if (entry.isFile()) this.knownFolderFiles.add(full);
|
|
239
|
+
else if (entry.isDirectory()) walk(full);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
for (const folder of [
|
|
243
|
+
'pages',
|
|
244
|
+
"scripts"
|
|
245
|
+
]){
|
|
246
|
+
const folderPath = __rspack_external_path.join(projectPath, folder);
|
|
247
|
+
if (__rspack_external_fs.existsSync(folderPath)) walk(folderPath);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
211
250
|
getContextDependencyPaths(projectPath) {
|
|
212
251
|
const dependencies = new Set();
|
|
213
252
|
for (const folder of [
|
|
@@ -247,6 +286,7 @@ class WarnUponFolderChanges {
|
|
|
247
286
|
}
|
|
248
287
|
collectChanges(compiler) {
|
|
249
288
|
const projectPath = compiler.options.context || process.cwd();
|
|
289
|
+
this.snapshotFolderFiles(projectPath);
|
|
250
290
|
const pagesPath = __rspack_external_path.join(projectPath, 'pages') + __rspack_external_path.sep;
|
|
251
291
|
const scriptsPath = __rspack_external_path.join(projectPath, "scripts") + __rspack_external_path.sep;
|
|
252
292
|
const extensionsSupported = compiler.options.resolve?.extensions;
|
|
@@ -254,13 +294,23 @@ class WarnUponFolderChanges {
|
|
|
254
294
|
const modifiedFiles = compiler.modifiedFiles || new Set();
|
|
255
295
|
const removedFiles = compiler.removedFiles || new Set();
|
|
256
296
|
for (const filePath of modifiedFiles){
|
|
257
|
-
|
|
297
|
+
const isPreexisting = this.knownFolderFiles.has(filePath);
|
|
298
|
+
if (filePath.startsWith(pagesPath) && filePath.endsWith('.html')) {
|
|
299
|
+
if (isPreexisting) continue;
|
|
300
|
+
this.knownFolderFiles.add(filePath);
|
|
301
|
+
this.trackChange(projectPath, 'pages', 'add', filePath);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
258
304
|
if (filePath.startsWith(scriptsPath)) {
|
|
259
305
|
const ext = __rspack_external_path.extname(filePath).toLowerCase();
|
|
260
|
-
if (supportedScripts.has(ext))
|
|
306
|
+
if (!supportedScripts.has(ext)) continue;
|
|
307
|
+
if (isPreexisting) continue;
|
|
308
|
+
this.knownFolderFiles.add(filePath);
|
|
309
|
+
this.trackChange(projectPath, "scripts", 'add', filePath);
|
|
261
310
|
}
|
|
262
311
|
}
|
|
263
312
|
for (const filePath of removedFiles){
|
|
313
|
+
this.knownFolderFiles.delete(filePath);
|
|
264
314
|
if (filePath.startsWith(pagesPath) && filePath.endsWith('.html')) this.trackChange(projectPath, 'pages', 'remove', filePath);
|
|
265
315
|
if (filePath.startsWith(scriptsPath)) {
|
|
266
316
|
const ext = __rspack_external_path.extname(filePath).toLowerCase();
|
|
@@ -6585,8 +6635,9 @@ class SetupBackgroundEntry {
|
|
|
6585
6635
|
const browser = this.browser;
|
|
6586
6636
|
const minimumBgScript = resolveDevelopDistFile('firefox' === browser || 'gecko-based' === browser ? 'minimum-firefox-file' : 'minimum-chromium-file');
|
|
6587
6637
|
const dirname = __rspack_external_path.dirname(this.manifestPath);
|
|
6588
|
-
|
|
6589
|
-
manifestBg =
|
|
6638
|
+
const filteredManifest = scripts_lib_manifest_filterKeysForThisBrowser(manifest, browser) || manifest;
|
|
6639
|
+
const manifestBg = filteredManifest?.background ?? manifest.background;
|
|
6640
|
+
const manifestVersion = filteredManifest?.manifest_version ?? manifest.manifest_version;
|
|
6590
6641
|
function hookError(maybeError) {
|
|
6591
6642
|
compiler.hooks.thisCompilation.tap('run-chromium:setup-background-entry', (compilation)=>{
|
|
6592
6643
|
utils_reportToCompilation(compilation, compiler, maybeError, 'error');
|
|
@@ -6601,7 +6652,7 @@ class SetupBackgroundEntry {
|
|
|
6601
6652
|
} else this.addDefaultEntry(compiler, "background/script", minimumBgScript);
|
|
6602
6653
|
return;
|
|
6603
6654
|
}
|
|
6604
|
-
if (3 ===
|
|
6655
|
+
if (3 === manifestVersion) {
|
|
6605
6656
|
const serviceWorker = manifestBg?.service_worker;
|
|
6606
6657
|
if (serviceWorker) {
|
|
6607
6658
|
const swPath = __rspack_external_path.join(dirname, serviceWorker);
|
|
@@ -6610,7 +6661,7 @@ class SetupBackgroundEntry {
|
|
|
6610
6661
|
const existingEntry = compiler.options.entry && 'background/service_worker' in compiler.options.entry ? compiler.options.entry['background/service_worker'] : void 0;
|
|
6611
6662
|
if (!existingEntry && __rspack_external_fs.existsSync(swPath)) this.addDefaultEntry(compiler, 'background/service_worker', swPath);
|
|
6612
6663
|
} else this.addDefaultEntry(compiler, 'background/service_worker', minimumBgScript);
|
|
6613
|
-
} else if (2 ===
|
|
6664
|
+
} else if (2 === manifestVersion) {
|
|
6614
6665
|
const bgScripts = manifestBg?.scripts;
|
|
6615
6666
|
if (bgScripts && bgScripts.length > 0) {
|
|
6616
6667
|
const bgScriptPath = __rspack_external_path.join(dirname, bgScripts[0]);
|
|
@@ -6949,6 +7000,138 @@ class SetupReloadStrategy {
|
|
|
6949
7000
|
}).apply(compiler);
|
|
6950
7001
|
}
|
|
6951
7002
|
}
|
|
7003
|
+
const SCRIPTS_REPLAY_SHIM_SOURCE = `;(function () {
|
|
7004
|
+
try {
|
|
7005
|
+
if (typeof globalThis !== "object" || !globalThis) return;
|
|
7006
|
+
var chromeRef =
|
|
7007
|
+
(globalThis.chrome && globalThis.chrome.scripting && typeof globalThis.chrome.scripting.executeScript === "function")
|
|
7008
|
+
? globalThis.chrome
|
|
7009
|
+
: (globalThis.browser && globalThis.browser.scripting && typeof globalThis.browser.scripting.executeScript === "function")
|
|
7010
|
+
? globalThis.browser
|
|
7011
|
+
: null;
|
|
7012
|
+
if (!chromeRef) return;
|
|
7013
|
+
if (globalThis.__extjsScriptsReplayInstalled) return;
|
|
7014
|
+
globalThis.__extjsScriptsReplayInstalled = true;
|
|
7015
|
+
|
|
7016
|
+
var registry = new Map();
|
|
7017
|
+
var originalExecuteScript = chromeRef.scripting.executeScript.bind(chromeRef.scripting);
|
|
7018
|
+
|
|
7019
|
+
var serialize = function (entry) {
|
|
7020
|
+
try {
|
|
7021
|
+
return JSON.stringify({
|
|
7022
|
+
files: entry && Array.isArray(entry.files) ? entry.files : [],
|
|
7023
|
+
world: entry && entry.world ? String(entry.world) : ""
|
|
7024
|
+
});
|
|
7025
|
+
} catch (error) {
|
|
7026
|
+
return "";
|
|
7027
|
+
}
|
|
7028
|
+
};
|
|
7029
|
+
|
|
7030
|
+
var track = function (injection) {
|
|
7031
|
+
try {
|
|
7032
|
+
var tabId = injection && injection.target && injection.target.tabId;
|
|
7033
|
+
var files =
|
|
7034
|
+
injection && Array.isArray(injection.files) ? injection.files.slice() : null;
|
|
7035
|
+
if (typeof tabId !== "number") return;
|
|
7036
|
+
if (!files || !files.length) return;
|
|
7037
|
+
var world = injection.world ? String(injection.world) : undefined;
|
|
7038
|
+
var entry = { files: files, world: world, sig: serialize({ files: files, world: world }) };
|
|
7039
|
+
var existing = registry.get(tabId) || [];
|
|
7040
|
+
// Dedupe by signature — repeated identical injections (e.g. user
|
|
7041
|
+
// clicks the action twice) shouldn't stack in the replay list.
|
|
7042
|
+
if (existing.some(function (e) { return e.sig === entry.sig; })) return;
|
|
7043
|
+
existing.push(entry);
|
|
7044
|
+
// Cap to the most recent 50 distinct injections per tab so a misbehaving
|
|
7045
|
+
// user loop can't grow the registry unbounded.
|
|
7046
|
+
registry.set(tabId, existing.slice(-50));
|
|
7047
|
+
} catch (error) {
|
|
7048
|
+
// Tracking is best-effort; never break the user's executeScript call.
|
|
7049
|
+
}
|
|
7050
|
+
};
|
|
7051
|
+
|
|
7052
|
+
chromeRef.scripting.executeScript = function (injection, callback) {
|
|
7053
|
+
track(injection);
|
|
7054
|
+
return originalExecuteScript(injection, callback);
|
|
7055
|
+
};
|
|
7056
|
+
|
|
7057
|
+
var normalizeFile = function (value) {
|
|
7058
|
+
return String(value || "").replace(/^[/\\\\]+/, "");
|
|
7059
|
+
};
|
|
7060
|
+
|
|
7061
|
+
var fileMatches = function (entryFile, changedNormalized) {
|
|
7062
|
+
var fn = normalizeFile(entryFile);
|
|
7063
|
+
for (var i = 0; i < changedNormalized.length; i++) {
|
|
7064
|
+
var c = changedNormalized[i];
|
|
7065
|
+
if (!c) continue;
|
|
7066
|
+
if (fn === c) return true;
|
|
7067
|
+
if (fn.length > c.length && fn.slice(fn.length - c.length - 1) === "/" + c) return true;
|
|
7068
|
+
if (c.length > fn.length && c.slice(c.length - fn.length - 1) === "/" + fn) return true;
|
|
7069
|
+
}
|
|
7070
|
+
return false;
|
|
7071
|
+
};
|
|
7072
|
+
|
|
7073
|
+
globalThis.__extjsScriptsReplay = function (changedFiles) {
|
|
7074
|
+
var changedNormalized = (Array.isArray(changedFiles) ? changedFiles : []).map(normalizeFile);
|
|
7075
|
+
var promises = [];
|
|
7076
|
+
registry.forEach(function (entries, tabId) {
|
|
7077
|
+
entries.forEach(function (entry) {
|
|
7078
|
+
var matches = false;
|
|
7079
|
+
for (var i = 0; i < entry.files.length; i++) {
|
|
7080
|
+
if (fileMatches(entry.files[i], changedNormalized)) {
|
|
7081
|
+
matches = true;
|
|
7082
|
+
break;
|
|
7083
|
+
}
|
|
7084
|
+
}
|
|
7085
|
+
if (!matches) return;
|
|
7086
|
+
try {
|
|
7087
|
+
promises.push(
|
|
7088
|
+
originalExecuteScript({
|
|
7089
|
+
target: { tabId: tabId },
|
|
7090
|
+
files: entry.files,
|
|
7091
|
+
world: entry.world
|
|
7092
|
+
}).then(
|
|
7093
|
+
function () { return { ok: true, tabId: tabId, files: entry.files }; },
|
|
7094
|
+
function (error) {
|
|
7095
|
+
return {
|
|
7096
|
+
ok: false,
|
|
7097
|
+
tabId: tabId,
|
|
7098
|
+
files: entry.files,
|
|
7099
|
+
error: String((error && error.message) || error)
|
|
7100
|
+
};
|
|
7101
|
+
}
|
|
7102
|
+
)
|
|
7103
|
+
);
|
|
7104
|
+
} catch (error) {
|
|
7105
|
+
// Tab may have closed; skip silently.
|
|
7106
|
+
}
|
|
7107
|
+
});
|
|
7108
|
+
});
|
|
7109
|
+
return Promise.all(promises);
|
|
7110
|
+
};
|
|
7111
|
+
} catch (error) {
|
|
7112
|
+
// Best-effort shim; do not break the SW bootstrap on any failure.
|
|
7113
|
+
}
|
|
7114
|
+
})();
|
|
7115
|
+
`;
|
|
7116
|
+
const BACKGROUND_ASSET = /(^|\/)background\/(?:service_worker|script)\.js$/i;
|
|
7117
|
+
class InjectScriptsReplayShim {
|
|
7118
|
+
apply(compiler) {
|
|
7119
|
+
compiler.hooks.thisCompilation.tap(InjectScriptsReplayShim.name, (compilation)=>{
|
|
7120
|
+
compilation.hooks.processAssets.tap({
|
|
7121
|
+
name: InjectScriptsReplayShim.name,
|
|
7122
|
+
stage: core_Compilation.PROCESS_ASSETS_STAGE_REPORT + 100
|
|
7123
|
+
}, ()=>{
|
|
7124
|
+
for (const asset of compilation.getAssets()){
|
|
7125
|
+
if (!BACKGROUND_ASSET.test(asset.name)) continue;
|
|
7126
|
+
const original = asset.source.source().toString();
|
|
7127
|
+
if (-1 !== original.indexOf('__extjsScriptsReplayInstalled')) continue;
|
|
7128
|
+
const next = SCRIPTS_REPLAY_SHIM_SOURCE + '\n' + original;
|
|
7129
|
+
compilation.updateAsset(asset.name, new core_sources.RawSource(next));
|
|
7130
|
+
}
|
|
7131
|
+
});
|
|
7132
|
+
});
|
|
7133
|
+
}
|
|
7134
|
+
}
|
|
6952
7135
|
const DEV_SERVER_CLIENT_MARKERS = [
|
|
6953
7136
|
'@rspack/dev-server/client/index.js?',
|
|
6954
7137
|
'@rspack/dev-server/client/utils/ansiHTML.js',
|
|
@@ -7105,6 +7288,7 @@ class ScriptsPlugin {
|
|
|
7105
7288
|
manifestPath: this.manifestPath,
|
|
7106
7289
|
browser: this.browser
|
|
7107
7290
|
}).apply(compiler);
|
|
7291
|
+
new InjectScriptsReplayShim().apply(compiler);
|
|
7108
7292
|
}
|
|
7109
7293
|
}
|
|
7110
7294
|
}
|
package/dist/946.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import * as __rspack_external_path from "path";
|
|
|
12
12
|
import * as __rspack_external_fs from "fs";
|
|
13
13
|
import * as __rspack_external_os from "os";
|
|
14
14
|
import * as __rspack_external_vm from "vm";
|
|
15
|
-
var package_namespaceObject = JSON.parse('{"rE":"3.16.
|
|
15
|
+
var package_namespaceObject = JSON.parse('{"rE":"3.16.1","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.0.1","@rspack/dev-server":"^2.0.1","@rspack/plugin-preact-refresh":"1.1.5","@rspack/plugin-react-refresh":"1.6.2","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","@vue/compiler-sfc":"3.5.26","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.3","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.5.1","less-loader":"12.3.2","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.10","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","react-refresh":"0.18.0","sass-loader":"16.0.7","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","typescript":"5.9.3","unique-names-generator":"^4.7.1","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3"}}');
|
|
16
16
|
const fmt = {
|
|
17
17
|
heading: (title)=>pintor.underline(pintor.blue(title)),
|
|
18
18
|
label: (key)=>pintor.gray(key.toUpperCase()),
|
|
@@ -49,8 +49,24 @@ function getLoggingPrefix(type) {
|
|
|
49
49
|
function isPathLike(input) {
|
|
50
50
|
return input.includes('/') || input.includes('\\') || __rspack_external_path.isAbsolute(input);
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
52
|
+
function resolvedWorkspaceManifest(projectPath, manifestPath) {
|
|
53
|
+
const manifestDir = __rspack_external_path.dirname(manifestPath);
|
|
54
|
+
const packageDir = 'src' === __rspack_external_path.basename(manifestDir) ? __rspack_external_path.dirname(manifestDir) : manifestDir;
|
|
55
|
+
const display = __rspack_external_path.relative(projectPath, packageDir) || packageDir;
|
|
56
|
+
return `${getLoggingPrefix('info')} ${pintor.gray('Workspace root detected — resolved extension package:')} ${pintor.brightBlue(display)}`;
|
|
57
|
+
}
|
|
58
|
+
function manifestNotFoundError(manifestPath, candidates = []) {
|
|
59
|
+
const base = `${getLoggingPrefix('error')} Manifest file not found.\n${pintor.red('Ensure the path to your extension exists and try again.')}\n${pintor.red('NOT FOUND')}\n${pintor.gray('PATH')} ${pintor.underline(manifestPath)}`;
|
|
60
|
+
if (!candidates.length) return base;
|
|
61
|
+
const projectRoot = __rspack_external_path.dirname(manifestPath);
|
|
62
|
+
const hint = 1 === candidates.length ? "Did you mean to point at this workspace package?" : "Did you mean to point at one of these workspace packages?";
|
|
63
|
+
const suggestions = candidates.map((candidate)=>{
|
|
64
|
+
const dir = 'manifest.json' === __rspack_external_path.basename(candidate) ? __rspack_external_path.dirname(candidate) : candidate;
|
|
65
|
+
const normalized = 'src' === __rspack_external_path.basename(dir) ? __rspack_external_path.dirname(dir) : dir;
|
|
66
|
+
const display = __rspack_external_path.isAbsolute(normalized) ? __rspack_external_path.relative(projectRoot, normalized) || normalized : normalized;
|
|
67
|
+
return ` extension dev ${display}`;
|
|
68
|
+
}).join('\n');
|
|
69
|
+
return `${base}\n\n${pintor.gray(hint)}\n${pintor.brightBlue(suggestions)}`;
|
|
54
70
|
}
|
|
55
71
|
function previewing(browser) {
|
|
56
72
|
return `${getLoggingPrefix('info')} Previewing the extension on ${capitalizedBrowserName(browser)}...`;
|
|
@@ -502,6 +518,41 @@ async function getProjectPath(pathOrRemoteUrl) {
|
|
|
502
518
|
}
|
|
503
519
|
return __rspack_external_path.resolve(process.cwd(), pathOrRemoteUrl);
|
|
504
520
|
}
|
|
521
|
+
function collectManifestCandidates(rootDir, maxDepth) {
|
|
522
|
+
const SKIP_DIRS = new Set([
|
|
523
|
+
'node_modules',
|
|
524
|
+
'dist',
|
|
525
|
+
'build',
|
|
526
|
+
'out',
|
|
527
|
+
'.git',
|
|
528
|
+
'.turbo',
|
|
529
|
+
'.next',
|
|
530
|
+
'coverage',
|
|
531
|
+
'.cache',
|
|
532
|
+
'.vercel'
|
|
533
|
+
]);
|
|
534
|
+
const results = [];
|
|
535
|
+
const walk = (dir, depth)=>{
|
|
536
|
+
if (depth > maxDepth || results.length >= 10) return;
|
|
537
|
+
let entries;
|
|
538
|
+
try {
|
|
539
|
+
entries = __rspack_external_fs.readdirSync(dir, {
|
|
540
|
+
withFileTypes: true
|
|
541
|
+
});
|
|
542
|
+
} catch {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
for (const entry of entries){
|
|
546
|
+
if (entry.isFile() && 'manifest.json' === entry.name) {
|
|
547
|
+
results.push(__rspack_external_path.join(dir, entry.name));
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
if (entry.isDirectory() && !entry.name.startsWith('.') && !SKIP_DIRS.has(entry.name)) walk(__rspack_external_path.join(dir, entry.name), depth + 1);
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
walk(rootDir, 0);
|
|
554
|
+
return results;
|
|
555
|
+
}
|
|
505
556
|
async function getProjectStructure(pathOrRemoteUrl) {
|
|
506
557
|
const projectPath = await getProjectPath(pathOrRemoteUrl);
|
|
507
558
|
const isUnderDir = (baseDir, candidatePath)=>{
|
|
@@ -513,8 +564,14 @@ async function getProjectStructure(pathOrRemoteUrl) {
|
|
|
513
564
|
const rootManifestPath = __rspack_external_path.join(projectPath, 'manifest.json');
|
|
514
565
|
const srcManifestPath = __rspack_external_path.join(projectPath, 'src', 'manifest.json');
|
|
515
566
|
let manifestPath = __rspack_external_fs.existsSync(srcManifestPath) ? srcManifestPath : rootManifestPath;
|
|
516
|
-
if (!__rspack_external_fs.existsSync(manifestPath)) {
|
|
517
|
-
|
|
567
|
+
if (!__rspack_external_fs.existsSync(manifestPath)) if (packageJsonDirFromProject) {
|
|
568
|
+
const absoluteCandidates = collectManifestCandidates(projectPath, 3);
|
|
569
|
+
const relativeCandidates = absoluteCandidates.map((candidate)=>__rspack_external_path.relative(projectPath, candidate) || candidate);
|
|
570
|
+
if (1 === absoluteCandidates.length) {
|
|
571
|
+
manifestPath = absoluteCandidates[0];
|
|
572
|
+
console.log(resolvedWorkspaceManifest(projectPath, manifestPath));
|
|
573
|
+
} else throw new Error(manifestNotFoundError(manifestPath, relativeCandidates));
|
|
574
|
+
} else {
|
|
518
575
|
const findManifest = (dir)=>{
|
|
519
576
|
const files = __rspack_external_fs.readdirSync(dir, {
|
|
520
577
|
withFileTypes: true
|
|
@@ -23,4 +23,4 @@
|
|
|
23
23
|
██████████████████████████████████████████████████████████
|
|
24
24
|
██████████████████████████████████████████████████████████
|
|
25
25
|
MIT (c) ${new Date().getFullYear()} - Cezar Augusto and the Extension.js authors.
|
|
26
|
-
`,"background: transparent; color: #0971fe; "),!t){try{await n()}catch{try{chrome.tabs.create({url:o})}catch{}}return}let i=String(t.url||""),s=i.startsWith(`${a}://newtab`)||i.startsWith(`${a}://welcome`);0;s?await n():r(t,o)})}catch{}}let o=[],i=new Map,s=new Set;try{chrome.storage.session.get(["logger_capture_stacks"],e=>{e?.logger_capture_stacks}),chrome.storage.session.onChanged.addListener((e,t)=>{"session"===t&&"logger_capture_stacks"in e&&e.logger_capture_stacks?.newValue})}catch{}function
|
|
26
|
+
`,"background: transparent; color: #0971fe; "),!t){try{await n()}catch{try{chrome.tabs.create({url:o})}catch{}}return}let i=String(t.url||""),s=i.startsWith(`${a}://newtab`)||i.startsWith(`${a}://welcome`);0;s?await n():r(t,o)})}catch{}}let o=[],i=new Map,s=new Set;try{chrome.storage.session.get(["logger_capture_stacks"],e=>{e?.logger_capture_stacks}),chrome.storage.session.onChanged.addListener((e,t)=>{"session"===t&&"logger_capture_stacks"in e&&e.logger_capture_stacks?.newValue})}catch{}function d(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function c(e){if(o.push(e),o.length>2e3&&o.shift(),"number"==typeof e.tabId){let t=i.get(e.tabId)||[];t.push(e),t.length>1e3&&t.shift(),i.set(e.tabId,t)}for(let t of s)try{let r={type:"append",event:e};t.postMessage(r)}catch{}}chrome.runtime.onConnect.addListener(e=>{if("logger"!==e.name)return;let t=t=>(function(e,t){var r;let n,a;if("subscribe"===t.type){s.add(e);try{e.postMessage({type:"init",events:o})}catch{}return}let i=e.sender?.id;if(i&&i===chrome.runtime.id)return;let c=e.sender?.tab?.id,l=e.sender?.frameId,u=e.sender?.tab?.incognito,m=e.sender?.tab?.windowId;if(r=i||`tab:${c??"unknown"}`,n=Date.now(),(a=h.get(r))?n-a.ts>1e3?(a.ts=n,a.count=1,!!0):(a.count+=1,!!(a.count>200)):(h.set(r,{ts:n,count:1}),!!0))return;let y=p(t.messageParts),v={id:d(),timestamp:Date.now(),level:t.level,context:t.context,messageParts:y,eventType:"dx.signal"===t.eventType||"log"===t.eventType?t.eventType:"log",code:"string"==typeof t.code?f(t.code,128):void 0,status:"ok"===t.status||"warn"===t.status||"fail"===t.status?t.status:void 0,data:b(t.data),remediation:"string"==typeof t.remediation?f(t.remediation,512):void 0,url:t.url,stack:t.stack,errorName:t.errorName,tabId:c,frameId:l,sourceExtensionId:i,incognito:u,windowId:m};g(v)})(e,t);e.onMessage.addListener(t),e.onDisconnect.addListener(()=>{s.delete(e);try{e.onMessage.removeListener(t)}catch{}})}),chrome.action.onClicked.addListener(async()=>{try{await chrome.sidePanel.setPanelBehavior({openPanelOnActionClick:!0})}catch{}});let l=[],u=new Set;function m(e){try{return JSON.stringify(e)}catch{return String(e)}}function g(e){let t=`${e.eventType??"log"}|${e.code??""}|${e.status??""}|${e.level}|${e.context}|${e.tabId??""}|${e.frameId??""}|${e.url??""}|${m(e.messageParts)}|${m(e.data)}`.slice(0,512);if(!u.has(t)){if(u.add(t),l.push(t),l.length>2e3){let e=l.shift();e&&u.delete(e)}if(e.url&&!e.hostname)try{let t=new URL(e.url);e.hostname=`${t.hostname}${t.pathname}`}catch{}if(null!=e.tabId&&null==e.title)try{chrome.tabs.get(e.tabId,t=>{if(chrome.runtime.lastError)return c(e);e.title=t?.title||e.title,c(e)});return}catch{}c(e)}}let h=new Map;function f(e,t=2048){return e.length<=t?e:e.slice(0,t)+"..."}function y(e){try{return JSON.stringify(e)}catch{try{return String(e)}catch{return"[unserializable]"}}}function p(e){try{let t=[];for(let r of e??[])if("string"==typeof r?t.push(f(r)):r instanceof Error?t.push(f(`${r.name}: ${r.message}`)):t.push(f(y(r))),t.join(" ").length>8192)break;return t}catch{return[y(e)]}}function b(e){if(e&&"object"==typeof e)try{let t=JSON.stringify(e);if(!t)return;let r=JSON.parse(t);if(0===Object.keys(r).length)return;return r}catch{return}}function v(e,t,r={}){g({id:d(),timestamp:Date.now(),level:e,context:"background",messageParts:t,url:"string"==typeof r.url?r.url:void 0,tabId:"number"==typeof r.tabId?r.tabId:void 0,frameId:"number"==typeof r.frameId?r.frameId:void 0})}function x(e){let t=String(e.name||"").toLowerCase();return t.includes("extension.js built-in developer tools")||t.includes("extension.js theme")}async function w(){let e=(await new Promise(e=>{chrome.management.getAll(e)})||[]).filter(e=>e.id!==chrome.runtime.id&&"igcijhgmihmjbbahdabahfbpffalcfnn"!==e.id&&"development"===e.installType&&"theme"!==e.type&&!x(e));if(0===e.length)return{ok:!0,extensionEnabled:null};let t=e.find(e=>e.enabled)||e[e.length-1];return{ok:!0,extensionEnabled:!!t?.enabled,extensionName:t?.name,extensionId:t?.id}}async function I(e){if(e.startsWith("data:"))return e;let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch icon: ${t.status}`);let r=await t.blob();return await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(String(n.result||"")),n.onerror=()=>t(Error("Failed to read icon blob")),n.readAsDataURL(r)})}function L(e){return!!e&&e.id!==chrome.runtime.id&&"development"===e.installType&&"theme"!==e.type&&!x(e)}function k(e){try{chrome.tabs.query({},t=>{for(let r of t||[])if("number"==typeof r.id)try{chrome.tabs.sendMessage(r.id,{type:"extjs-dev-reload",state:e}).catch(()=>{})}catch{}})}catch{}}chrome.runtime.onInstalled.addListener(e=>{v("info",["extension installed",e.reason,e.previousVersion??null])}),chrome.storage.session.get(["logger_events"],e=>{let t=Array.isArray(e?.logger_events)?e.logger_events:[];if(t.length)for(let e of t.slice(-2e3))o.push(e)}),setInterval(()=>{chrome.storage.session.set({logger_events:o.slice(-200)})},2e3),chrome.runtime.onStartup.addListener(()=>{v("info",["extension startup"]);try{v("info",["TEST_LOG: background-start"])}catch{}}),chrome.tabs.onCreated.addListener(e=>{v("info",["tab created"],{tabId:e.id??void 0,url:e.url})}),chrome.tabs.onUpdated.addListener((e,t,r)=>{"loading"===t.status&&v("debug",["tab loading"],{tabId:e,url:r.url}),"complete"===t.status&&v("debug",["tab complete"],{tabId:e,url:r.url}),"string"==typeof t.url&&v("info",["tab url changed",t.url],{tabId:e,url:t.url})}),chrome.tabs.onRemoved.addListener((e,t)=>{v("info",["tab removed",{windowId:t.windowId,isWindowClosing:t.isWindowClosing}],{tabId:e})}),chrome.webNavigation.onBeforeNavigate.addListener(e=>{0===e.frameId&&v("info",["Before navigate"],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.webNavigation.onCommitted.addListener(e=>{0===e.frameId&&v("info",["Navigation committed"],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.webNavigation.onCompleted.addListener(e=>{0===e.frameId&&v("info",["Navigation completed"],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.webNavigation.onErrorOccurred.addListener(e=>{0===e.frameId&&v("error",["Navigation error",e.error],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.webNavigation.onHistoryStateUpdated.addListener(e=>{0===e.frameId&&v("info",["History state updated"],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.runtime.onMessage.addListener((e,t,r)=>e&&"get-events"===e.type?(r({events:o.slice(-500)}),!0):!!e&&"clear-events"===e.type&&(o.length=0,r({ok:!0}),!0)),chrome.runtime.onMessage.addListener((e,t,r)=>{if((!t?.id||t.id===chrome.runtime.id)&&e){if("resolve-icon-url"===e.type)return e.url&&function(e){if(e.startsWith("data:"))return!0;try{let t=new URL(e);return"moz-extension:"===t.protocol||"chrome-extension:"===t.protocol}catch{return!1}}(e.url)?(I(e.url).then(e=>r({ok:!0,dataUrl:e})).catch(e=>r({ok:!1,error:String(e)})),!0):void r({ok:!1,error:"Unsupported icon URL"});if("get-dx-status"===e.type)return w().then(e=>r(e)).catch(e=>r({ok:!1,error:String(e||"Unknown error")})),!0;if("dx-signal"===e.type){try{var n={level:e.level||"info",context:e.context||"content",messageParts:Array.isArray(e.messageParts)&&e.messageParts.length>0?e.messageParts:[e.code||"DX_SIGNAL"],eventType:e.eventType||"dx.signal",code:e.code,status:e.status,data:e.data,remediation:e.remediation,url:"string"==typeof e.url?e.url:void 0,stack:"string"==typeof e.stack?e.stack:void 0,errorName:"string"==typeof e.errorName?e.errorName:void 0};g({id:d(),timestamp:Date.now(),level:n.level,context:n.context,messageParts:p(n.messageParts||[]),eventType:"dx.signal"===n.eventType||"log"===n.eventType?n.eventType:"log",code:"string"==typeof n.code?f(String(n.code),128):void 0,status:"ok"===n.status||"warn"===n.status||"fail"===n.status?n.status:void 0,data:b(n.data),remediation:"string"==typeof n.remediation?f(n.remediation,512):void 0,url:n.url,stack:n.stack,errorName:n.errorName,tabId:n.tabId,frameId:n.frameId}),r({ok:!0})}catch(e){r({ok:!1,error:String(e||"Unknown error")})}return!0}}}),chrome.runtime.onStartup.addListener(async()=>{await a()}),chrome.runtime.onInstalled.addListener(async()=>{await a()}),"function"==typeof chrome.management?.onDisabled?.addListener&&chrome.management.onDisabled.addListener(e=>{L(e)&&k("reloading")}),"function"==typeof chrome.management?.onEnabled?.addListener&&chrome.management.onEnabled.addListener(e=>{L(e)&&k("reloaded")}),"function"==typeof chrome.management?.onInstalled?.addListener&&chrome.management.onInstalled.addListener(e=>{L(e)&&k("reloaded")})})();
|