extension-develop 4.0.5 → 4.0.6-canary.1783350491.2c449344
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 +363 -34
- package/dist/101.mjs +1 -1
- package/dist/224.mjs +9 -1
- package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +4 -4
- 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.js +4 -4
- 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.js +4 -4
- package/dist/extension-js-devtools/edge/pages/welcome.js +1 -1
- package/dist/extension-js-devtools/extension-js/chrome/events.ndjson +2 -2
- package/dist/extension-js-devtools/extension-js/chrome/ready.json +7 -7
- package/dist/extension-js-devtools/extension-js/chromium/events.ndjson +2 -2
- package/dist/extension-js-devtools/extension-js/chromium/ready.json +7 -7
- package/dist/extension-js-devtools/extension-js/edge/events.ndjson +2 -2
- package/dist/extension-js-devtools/extension-js/edge/ready.json +7 -7
- package/dist/extension-js-devtools/extension-js/firefox/events.ndjson +2 -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.js +4 -4
- package/dist/extension-js-devtools/firefox/pages/welcome.js +1 -1
- package/dist/extension-js-theme/chromium/Cached Theme.pak +0 -0
- package/dist/extension-js-theme/extension-js/chrome/events.ndjson +2 -2
- package/dist/extension-js-theme/extension-js/chrome/ready.json +7 -7
- package/dist/extension-js-theme/extension-js/chromium/events.ndjson +2 -2
- package/dist/extension-js-theme/extension-js/chromium/ready.json +7 -7
- package/dist/extension-js-theme/extension-js/edge/events.ndjson +2 -2
- package/dist/extension-js-theme/extension-js/edge/ready.json +7 -7
- package/dist/extension-js-theme/extension-js/firefox/events.ndjson +20 -6
- package/dist/extension-js-theme/extension-js/firefox/ready.json +7 -7
- package/package.json +1 -1
package/dist/0~rspack-config.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import { stripBom, parseJsonSafe } from "./23.mjs";
|
|
|
19
19
|
import { scrubBrand, makeSanitizedConsole } from "./0~branding.mjs";
|
|
20
20
|
import { cssIntegrationsEnabled, cssConfigsDetected, missingSassDependency, isUsingIntegration } from "./845.mjs";
|
|
21
21
|
import { isUsingTypeScript, jsFrameworksIntegrationsEnabled, ensureTypeScriptConfig, ensureOptionalContractModuleLoaded, resolveDevelopInstallRoot, getUserTypeScriptConfigFile, isUsingCustomLoader, isUsingIntegration as messages_isUsingIntegration, loadOptionalContractModuleWithoutInstall, resolveOptionalContractPackageWithoutInstall, jsFrameworksHmrSummary, jsFrameworksConfigsDetected, hasDependency, resolveDevelopDistFile, optional_deps_resolver_ensureOptionalContractPackageResolved } from "./839.mjs";
|
|
22
|
-
import { findNearestPackageJsonSync, backgroundIsRequiredMessageOnly } from "./224.mjs";
|
|
22
|
+
import { injectedFileDependencyMissing, findNearestPackageJsonSync, backgroundIsRequiredMessageOnly, importScriptsDependencyMissing } from "./224.mjs";
|
|
23
23
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
24
24
|
import { dirname as __rspack_dirname } from "node:path";
|
|
25
25
|
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
@@ -376,6 +376,9 @@ function envInjectedPublicVars(count) {
|
|
|
376
376
|
`${pintor.gray('INJECTED')} ${pintor.gray(String(count))} EXTENSION_PUBLIC_*`
|
|
377
377
|
].join('\n');
|
|
378
378
|
}
|
|
379
|
+
function envNoMatchingFile(browser, mode, presentFiles, expectedCandidates) {
|
|
380
|
+
return `Found ${presentFiles.map((file)=>pintor.yellow(file)).join(', ')} but none match browser ${pintor.yellow(browser)} (mode ${pintor.yellow(mode)}), so EXTENSION_PUBLIC_* variables read from code will be ${pintor.yellow('undefined')} in this build.\nMatching names, in priority order: ${expectedCandidates.map((file)=>pintor.gray(file)).join(', ')}.\nFamily names apply to every family member — e.g. ${pintor.yellow('.env.chrome')} also matches ${pintor.yellow('chromium')} and ${pintor.yellow('edge')} targets.`;
|
|
381
|
+
}
|
|
379
382
|
function isFromFilepathList(filePath, filepathList) {
|
|
380
383
|
return Object.values(filepathList || {}).some((value)=>value === filePath);
|
|
381
384
|
}
|
|
@@ -1025,6 +1028,32 @@ function resolveEnvPaths(projectPath, envFiles) {
|
|
|
1025
1028
|
defaultsPath: localDefaultsPath
|
|
1026
1029
|
};
|
|
1027
1030
|
}
|
|
1031
|
+
function getEnvFileCandidates(browser, mode) {
|
|
1032
|
+
const browserName = String(browser);
|
|
1033
|
+
const isChromiumTarget = isChromiumBasedBrowser(browserName) || 'safari' === browserName || browserName.includes('webkit');
|
|
1034
|
+
const familyNames = isChromiumTarget ? [
|
|
1035
|
+
'chromium',
|
|
1036
|
+
'chrome',
|
|
1037
|
+
'edge',
|
|
1038
|
+
'chromium-based'
|
|
1039
|
+
] : constants_isGeckoBasedBrowser(browserName) ? [
|
|
1040
|
+
'firefox',
|
|
1041
|
+
'gecko-based'
|
|
1042
|
+
] : [];
|
|
1043
|
+
const names = [
|
|
1044
|
+
browserName,
|
|
1045
|
+
...familyNames.filter((name)=>name !== browserName)
|
|
1046
|
+
];
|
|
1047
|
+
return [
|
|
1048
|
+
...names.flatMap((name)=>[
|
|
1049
|
+
`.env.${name}.${mode}`,
|
|
1050
|
+
`.env.${name}`
|
|
1051
|
+
]),
|
|
1052
|
+
`.env.${mode}`,
|
|
1053
|
+
'.env.local',
|
|
1054
|
+
'.env'
|
|
1055
|
+
];
|
|
1056
|
+
}
|
|
1028
1057
|
class EnvPlugin {
|
|
1029
1058
|
browser;
|
|
1030
1059
|
manifestPath;
|
|
@@ -1035,23 +1064,22 @@ class EnvPlugin {
|
|
|
1035
1064
|
apply(compiler) {
|
|
1036
1065
|
const projectPath = compiler.options.context || (this.manifestPath ? __rspack_external_path.dirname(this.manifestPath) : '');
|
|
1037
1066
|
const mode = compiler.options.mode || 'development';
|
|
1038
|
-
const envFiles =
|
|
1039
|
-
`.env.${this.browser}.${mode}`,
|
|
1040
|
-
`.env.${this.browser}`,
|
|
1041
|
-
`.env.${mode}`,
|
|
1042
|
-
'.env.local',
|
|
1043
|
-
'.env'
|
|
1044
|
-
];
|
|
1067
|
+
const envFiles = getEnvFileCandidates(this.browser, mode);
|
|
1045
1068
|
const { envPath, defaultsPath } = resolveEnvPaths(projectPath, envFiles);
|
|
1046
1069
|
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(envSelectedFile(envPath));
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1070
|
+
if (!envPath && projectPath) {
|
|
1071
|
+
let unmatchedEnvFiles = [];
|
|
1072
|
+
try {
|
|
1073
|
+
unmatchedEnvFiles = __rspack_external_fs.readdirSync(projectPath).filter((file)=>file.startsWith('.env') && '.env.defaults' !== file && '.env.example' !== file).sort();
|
|
1074
|
+
} catch {}
|
|
1075
|
+
if (unmatchedEnvFiles.length > 0) compiler.hooks.thisCompilation.tap('env:warn-unmatched', (compilation)=>{
|
|
1076
|
+
const warn = new core_WebpackError(envNoMatchingFile(String(this.browser), String(mode), unmatchedEnvFiles, envFiles));
|
|
1077
|
+
warn.name = 'EnvNoMatchingFile';
|
|
1078
|
+
compilation.warnings.push(warn);
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
const envVars = envPath ? __rspack_external_dotenv.parse(__rspack_external_fs.readFileSync(envPath)) : {};
|
|
1082
|
+
const defaultsVars = __rspack_external_fs.existsSync(defaultsPath) ? __rspack_external_dotenv.parse(__rspack_external_fs.readFileSync(defaultsPath)) : {};
|
|
1055
1083
|
const combinedVars = {
|
|
1056
1084
|
...defaultsVars,
|
|
1057
1085
|
...envVars,
|
|
@@ -1074,6 +1102,9 @@ class EnvPlugin {
|
|
|
1074
1102
|
filteredEnvVars['import.meta.env.BROWSER'] = JSON.stringify(this.browser);
|
|
1075
1103
|
filteredEnvVars['process.env.MODE'] = JSON.stringify(mode);
|
|
1076
1104
|
filteredEnvVars['import.meta.env.MODE'] = JSON.stringify(mode);
|
|
1105
|
+
const importMetaEnvObject = {};
|
|
1106
|
+
for (const [key, value] of Object.entries(filteredEnvVars))if (key.startsWith('import.meta.env.')) importMetaEnvObject[key.slice(16)] = JSON.parse(value);
|
|
1107
|
+
filteredEnvVars['import.meta.env'] = JSON.stringify(importMetaEnvObject);
|
|
1077
1108
|
filteredEnvVars['import.meta.dirname'] = 'undefined';
|
|
1078
1109
|
filteredEnvVars['import.meta.filename'] = 'undefined';
|
|
1079
1110
|
const injectedCount = Object.keys(filteredEnvVars).filter((k)=>k.startsWith('process.env.EXTENSION_PUBLIC_')).length;
|
|
@@ -4896,6 +4927,22 @@ class AddAssetsToCompilation {
|
|
|
4896
4927
|
});
|
|
4897
4928
|
}
|
|
4898
4929
|
}
|
|
4930
|
+
function isClassicScript(filePath) {
|
|
4931
|
+
try {
|
|
4932
|
+
const src = __rspack_external_fs.readFileSync(filePath, 'utf8');
|
|
4933
|
+
return !/^\s*import[\s{('"*]/m.test(src) && !/^\s*export[\s{*( ]/m.test(src);
|
|
4934
|
+
} catch {
|
|
4935
|
+
return false;
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4938
|
+
function classicConcatEntry(feature, jsFiles) {
|
|
4939
|
+
const queryData = encodeURIComponent(JSON.stringify({
|
|
4940
|
+
feature,
|
|
4941
|
+
js: jsFiles,
|
|
4942
|
+
css: []
|
|
4943
|
+
}));
|
|
4944
|
+
return `${jsFiles[0]}?__extensionjs_classic_concat__=${queryData}`;
|
|
4945
|
+
}
|
|
4899
4946
|
const WILDCARD_HOSTS = new Set([
|
|
4900
4947
|
'0.0.0.0',
|
|
4901
4948
|
'::',
|
|
@@ -5012,8 +5059,13 @@ class AddScriptsAndStylesToCompilation {
|
|
|
5012
5059
|
const looksLikePublicRootUrl = (p)=>p.startsWith('/public/') || p.startsWith('/') && !p.startsWith(projectRoot) && hasPublicDir;
|
|
5013
5060
|
const jsAssets = (htmlAssets?.js || []).filter((asset)=>!looksLikePublicRootUrl(asset) && !isRemoteUrl(asset));
|
|
5014
5061
|
const cssAssets = (htmlAssets?.css || []).filter((asset)=>!looksLikePublicRootUrl(asset) && !isRemoteUrl(asset));
|
|
5062
|
+
const moduleJsAssets = new Set(htmlAssets?.moduleJs || []);
|
|
5063
|
+
const concatenateClassic = jsAssets.length > 1 && jsAssets.every((asset)=>!moduleJsAssets.has(asset) && /\.(js|cjs)$/i.test(asset) && isClassicScript(asset));
|
|
5064
|
+
const jsImports = concatenateClassic ? [
|
|
5065
|
+
classicConcatEntry(feature, jsAssets)
|
|
5066
|
+
] : jsAssets;
|
|
5015
5067
|
const fileAssets = [
|
|
5016
|
-
...
|
|
5068
|
+
...jsImports,
|
|
5017
5069
|
...cssAssets
|
|
5018
5070
|
];
|
|
5019
5071
|
if ('development' === compiler.options.mode) {
|
|
@@ -5504,23 +5556,8 @@ const isScriptsFolderFeature = (feature)=>feature.startsWith("scripts/");
|
|
|
5504
5556
|
const isBackgroundScriptsFeature = (feature)=>"background/scripts" === feature;
|
|
5505
5557
|
function createSequentialEntryModule(feature, scriptImports) {
|
|
5506
5558
|
const jsFiles = scriptImports;
|
|
5507
|
-
const
|
|
5508
|
-
|
|
5509
|
-
const src = __rspack_external_fs.readFileSync(p, 'utf8');
|
|
5510
|
-
return !/^\s*import[\s{('"*]/m.test(src) && !/^\s*export[\s{*( ]/m.test(src);
|
|
5511
|
-
} catch {
|
|
5512
|
-
return false;
|
|
5513
|
-
}
|
|
5514
|
-
};
|
|
5515
|
-
const concatenateClassic = jsFiles.length > 1 && jsFiles.every(isClassic);
|
|
5516
|
-
if (concatenateClassic) {
|
|
5517
|
-
const queryData = encodeURIComponent(JSON.stringify({
|
|
5518
|
-
feature,
|
|
5519
|
-
js: jsFiles,
|
|
5520
|
-
css: []
|
|
5521
|
-
}));
|
|
5522
|
-
return `${jsFiles[0]}?__extensionjs_classic_concat__=${queryData}`;
|
|
5523
|
-
}
|
|
5559
|
+
const concatenateClassic = jsFiles.length > 1 && jsFiles.every(isClassicScript);
|
|
5560
|
+
if (concatenateClassic) return classicConcatEntry(feature, jsFiles);
|
|
5524
5561
|
const source = [
|
|
5525
5562
|
`/* extension.js sequential entry: ${feature} */`,
|
|
5526
5563
|
...jsFiles.map((entryImport)=>`import ${JSON.stringify(String(entryImport))};`)
|
|
@@ -7817,6 +7854,295 @@ class StripContentScriptDevServerRuntime {
|
|
|
7817
7854
|
});
|
|
7818
7855
|
}
|
|
7819
7856
|
}
|
|
7857
|
+
const EMITTED_WORKER_PATH = 'background/service_worker.js';
|
|
7858
|
+
const MAX_TRACE_DEPTH = 8;
|
|
7859
|
+
const SOURCE_SIBLING_EXTENSIONS = [
|
|
7860
|
+
'.ts',
|
|
7861
|
+
'.mts',
|
|
7862
|
+
'.tsx',
|
|
7863
|
+
'.jsx',
|
|
7864
|
+
'.mjs'
|
|
7865
|
+
];
|
|
7866
|
+
class TraceRuntimeLoadedFiles {
|
|
7867
|
+
manifestPath;
|
|
7868
|
+
constructor(options){
|
|
7869
|
+
this.manifestPath = options.manifestPath;
|
|
7870
|
+
}
|
|
7871
|
+
apply(compiler) {
|
|
7872
|
+
compiler.hooks.thisCompilation.tap(TraceRuntimeLoadedFiles.name, (compilation)=>{
|
|
7873
|
+
compilation.hooks.processAssets.tap({
|
|
7874
|
+
name: TraceRuntimeLoadedFiles.name,
|
|
7875
|
+
stage: core_Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
7876
|
+
}, ()=>{
|
|
7877
|
+
this.traceWorkerImportScripts(compilation);
|
|
7878
|
+
this.traceInjectedFilePayloads(compilation);
|
|
7879
|
+
});
|
|
7880
|
+
});
|
|
7881
|
+
}
|
|
7882
|
+
readManifest() {
|
|
7883
|
+
try {
|
|
7884
|
+
return JSON.parse(__rspack_external_fs.readFileSync(this.manifestPath, 'utf-8'));
|
|
7885
|
+
} catch {
|
|
7886
|
+
return;
|
|
7887
|
+
}
|
|
7888
|
+
}
|
|
7889
|
+
traceWorkerImportScripts(compilation) {
|
|
7890
|
+
const manifest = this.readManifest();
|
|
7891
|
+
const workerRef = manifest?.background?.service_worker;
|
|
7892
|
+
if (!workerRef || manifest?.background?.type === 'module') return;
|
|
7893
|
+
const workerAsset = compilation.getAsset(EMITTED_WORKER_PATH);
|
|
7894
|
+
if (!workerAsset) return;
|
|
7895
|
+
const manifestDir = __rspack_external_path.dirname(this.manifestPath);
|
|
7896
|
+
const sourceWorkerPath = trace_runtime_loaded_files_unixify(String(workerRef)).replace(/^\/+/, '');
|
|
7897
|
+
let pending = [
|
|
7898
|
+
workerAsset.source.source().toString()
|
|
7899
|
+
];
|
|
7900
|
+
const seen = new Set();
|
|
7901
|
+
for(let depth = 0; depth < MAX_TRACE_DEPTH && pending.length; depth++){
|
|
7902
|
+
const next = [];
|
|
7903
|
+
for (const content of pending)for (const literal of extractImportScriptsLiterals(content)){
|
|
7904
|
+
const sourceRel = resolveExtensionPath(literal, sourceWorkerPath);
|
|
7905
|
+
const distRel = resolveExtensionPath(literal, EMITTED_WORKER_PATH);
|
|
7906
|
+
if (!sourceRel || !distRel || seen.has(distRel)) continue;
|
|
7907
|
+
seen.add(distRel);
|
|
7908
|
+
const copied = copyThroughOrWarn(compilation, {
|
|
7909
|
+
manifestDir,
|
|
7910
|
+
sourceRel,
|
|
7911
|
+
distRel,
|
|
7912
|
+
warning: (expected, sourceSibling)=>importScriptsDependencyMissing(sourceWorkerPath, literal, expected, sourceSibling),
|
|
7913
|
+
warningName: 'ImportScriptsDependencyMissing',
|
|
7914
|
+
warningFile: EMITTED_WORKER_PATH
|
|
7915
|
+
});
|
|
7916
|
+
if (null != copied) {
|
|
7917
|
+
next.push(copied);
|
|
7918
|
+
if (sourceRel.endsWith('.js')) copyIfExists(compilation, __rspack_external_path.join(manifestDir, sourceRel.replace(/\.js$/, '_bg.wasm')), distRel.replace(/\.js$/, '_bg.wasm'));
|
|
7919
|
+
}
|
|
7920
|
+
}
|
|
7921
|
+
pending = next;
|
|
7922
|
+
}
|
|
7923
|
+
}
|
|
7924
|
+
traceInjectedFilePayloads(compilation) {
|
|
7925
|
+
const manifestDir = __rspack_external_path.dirname(this.manifestPath);
|
|
7926
|
+
const seen = new Set();
|
|
7927
|
+
const jsAssets = compilation.getAssets().filter((asset)=>/\.js$/i.test(asset.name));
|
|
7928
|
+
for (const asset of jsAssets){
|
|
7929
|
+
const content = asset.source.source().toString();
|
|
7930
|
+
for (const literal of extractInjectedFileLiterals(content)){
|
|
7931
|
+
const distRel = resolveExtensionPath(literal, '');
|
|
7932
|
+
if (!(!distRel || seen.has(distRel))) {
|
|
7933
|
+
seen.add(distRel);
|
|
7934
|
+
copyThroughOrWarn(compilation, {
|
|
7935
|
+
manifestDir,
|
|
7936
|
+
sourceRel: distRel,
|
|
7937
|
+
distRel,
|
|
7938
|
+
warning: (expected, sourceSibling)=>injectedFileDependencyMissing(asset.name, literal, expected, sourceSibling),
|
|
7939
|
+
warningName: 'InjectedScriptFilesMissing',
|
|
7940
|
+
warningFile: asset.name
|
|
7941
|
+
});
|
|
7942
|
+
}
|
|
7943
|
+
}
|
|
7944
|
+
}
|
|
7945
|
+
}
|
|
7946
|
+
}
|
|
7947
|
+
function copyIfExists(compilation, abs, distRel) {
|
|
7948
|
+
if (compilation.getAsset(distRel)) return;
|
|
7949
|
+
if (!__rspack_external_fs.existsSync(abs) || !__rspack_external_fs.statSync(abs).isFile()) return;
|
|
7950
|
+
compilation.emitAsset(distRel, new core_sources.RawSource(__rspack_external_fs.readFileSync(abs)));
|
|
7951
|
+
try {
|
|
7952
|
+
compilation.fileDependencies.add(abs);
|
|
7953
|
+
} catch {}
|
|
7954
|
+
}
|
|
7955
|
+
function copyThroughOrWarn(compilation, opts) {
|
|
7956
|
+
if (compilation.getAsset(opts.distRel)) return null;
|
|
7957
|
+
if (__rspack_external_fs.existsSync(__rspack_external_path.join(opts.manifestDir, 'public', opts.distRel))) return null;
|
|
7958
|
+
const abs = __rspack_external_path.join(opts.manifestDir, opts.sourceRel);
|
|
7959
|
+
if (__rspack_external_fs.existsSync(abs) && __rspack_external_fs.statSync(abs).isFile()) {
|
|
7960
|
+
const buffer = __rspack_external_fs.readFileSync(abs);
|
|
7961
|
+
compilation.emitAsset(opts.distRel, new core_sources.RawSource(buffer));
|
|
7962
|
+
try {
|
|
7963
|
+
compilation.fileDependencies.add(abs);
|
|
7964
|
+
} catch {}
|
|
7965
|
+
return buffer.toString();
|
|
7966
|
+
}
|
|
7967
|
+
const sourceSibling = trace_runtime_loaded_files_findSourceSibling(abs);
|
|
7968
|
+
const warn = new core_WebpackError(opts.warning(opts.sourceRel, sourceSibling ? trace_runtime_loaded_files_unixify(__rspack_external_path.relative(opts.manifestDir, sourceSibling)) : void 0));
|
|
7969
|
+
warn.name = opts.warningName;
|
|
7970
|
+
warn.file = opts.warningFile;
|
|
7971
|
+
compilation.warnings ||= [];
|
|
7972
|
+
compilation.warnings.push(warn);
|
|
7973
|
+
return null;
|
|
7974
|
+
}
|
|
7975
|
+
function trace_runtime_loaded_files_findSourceSibling(abs) {
|
|
7976
|
+
if (!abs.endsWith('.js')) return;
|
|
7977
|
+
const base = abs.slice(0, -3);
|
|
7978
|
+
return SOURCE_SIBLING_EXTENSIONS.map((ext)=>base + ext).find((candidate)=>__rspack_external_fs.existsSync(candidate));
|
|
7979
|
+
}
|
|
7980
|
+
function trace_runtime_loaded_files_unixify(filePath) {
|
|
7981
|
+
return filePath.replace(/\\/g, '/');
|
|
7982
|
+
}
|
|
7983
|
+
function resolveExtensionPath(literal, basePath) {
|
|
7984
|
+
const trimmed = literal.trim();
|
|
7985
|
+
if (!trimmed) return null;
|
|
7986
|
+
if (/^[a-zA-Z][\w+.-]*:/.test(trimmed)) return null;
|
|
7987
|
+
if (trimmed.startsWith('//')) return null;
|
|
7988
|
+
try {
|
|
7989
|
+
const base = new URL('chrome-extension://extension-js/' + trace_runtime_loaded_files_unixify(basePath));
|
|
7990
|
+
const resolved = new URL(trimmed, base);
|
|
7991
|
+
if ('extension-js' !== resolved.hostname) return null;
|
|
7992
|
+
const pathname = decodeURIComponent(resolved.pathname).replace(/^\/+/, '');
|
|
7993
|
+
return pathname || null;
|
|
7994
|
+
} catch {
|
|
7995
|
+
return null;
|
|
7996
|
+
}
|
|
7997
|
+
}
|
|
7998
|
+
function extractImportScriptsLiterals(source) {
|
|
7999
|
+
const code = blankComments(source);
|
|
8000
|
+
const literals = [];
|
|
8001
|
+
const callRe = /\bimportScripts\s*\(/g;
|
|
8002
|
+
let match;
|
|
8003
|
+
while(match = callRe.exec(code)){
|
|
8004
|
+
const args = readBalancedArgs(code, match.index + match[0].length - 1);
|
|
8005
|
+
if (null == args) continue;
|
|
8006
|
+
for (const arg of splitTopLevelArgs(args)){
|
|
8007
|
+
const literal = pureStringLiteral(arg);
|
|
8008
|
+
if (null != literal) literals.push(literal);
|
|
8009
|
+
}
|
|
8010
|
+
}
|
|
8011
|
+
return literals;
|
|
8012
|
+
}
|
|
8013
|
+
function extractInjectedFileLiterals(source) {
|
|
8014
|
+
const code = blankComments(source);
|
|
8015
|
+
const literals = [];
|
|
8016
|
+
const callRe = /\b(?:executeScript|insertCSS|removeCSS)\s*\(/g;
|
|
8017
|
+
let match;
|
|
8018
|
+
while(match = callRe.exec(code)){
|
|
8019
|
+
const args = readBalancedArgs(code, match.index + match[0].length - 1);
|
|
8020
|
+
if (null == args) continue;
|
|
8021
|
+
const filesRe = /["']?files["']?\s*:\s*\[([^\]]*)\]/g;
|
|
8022
|
+
let filesMatch;
|
|
8023
|
+
while(filesMatch = filesRe.exec(args))for (const element of splitTopLevelArgs(filesMatch[1])){
|
|
8024
|
+
const literal = pureStringLiteral(element);
|
|
8025
|
+
if (null != literal) literals.push(literal);
|
|
8026
|
+
}
|
|
8027
|
+
const fileRe = /["']?file["']?\s*:\s*(['"])((?:\\.|(?!\1)[^\\])*)\1/g;
|
|
8028
|
+
let fileMatch;
|
|
8029
|
+
while(fileMatch = fileRe.exec(args))literals.push(unescapeStringBody(fileMatch[2]));
|
|
8030
|
+
}
|
|
8031
|
+
return literals;
|
|
8032
|
+
}
|
|
8033
|
+
function blankComments(source) {
|
|
8034
|
+
let out = '';
|
|
8035
|
+
let i = 0;
|
|
8036
|
+
const n = source.length;
|
|
8037
|
+
while(i < n){
|
|
8038
|
+
const char = source[i];
|
|
8039
|
+
const next = source[i + 1];
|
|
8040
|
+
if ('/' === char && '/' === next) {
|
|
8041
|
+
while(i < n && '\n' !== source[i]){
|
|
8042
|
+
out += ' ';
|
|
8043
|
+
i++;
|
|
8044
|
+
}
|
|
8045
|
+
continue;
|
|
8046
|
+
}
|
|
8047
|
+
if ('/' === char && '*' === next) {
|
|
8048
|
+
out += ' ';
|
|
8049
|
+
i += 2;
|
|
8050
|
+
while(i < n && !('*' === source[i] && '/' === source[i + 1])){
|
|
8051
|
+
out += '\n' === source[i] ? '\n' : ' ';
|
|
8052
|
+
i++;
|
|
8053
|
+
}
|
|
8054
|
+
if (i < n) {
|
|
8055
|
+
out += ' ';
|
|
8056
|
+
i += 2;
|
|
8057
|
+
}
|
|
8058
|
+
continue;
|
|
8059
|
+
}
|
|
8060
|
+
if ('"' === char || "'" === char || '`' === char) {
|
|
8061
|
+
const quote = char;
|
|
8062
|
+
out += char;
|
|
8063
|
+
i++;
|
|
8064
|
+
while(i < n){
|
|
8065
|
+
if ('\\' === source[i]) {
|
|
8066
|
+
out += source[i] + (source[i + 1] ?? '');
|
|
8067
|
+
i += 2;
|
|
8068
|
+
continue;
|
|
8069
|
+
}
|
|
8070
|
+
out += source[i];
|
|
8071
|
+
if (source[i] === quote) {
|
|
8072
|
+
i++;
|
|
8073
|
+
break;
|
|
8074
|
+
}
|
|
8075
|
+
i++;
|
|
8076
|
+
}
|
|
8077
|
+
continue;
|
|
8078
|
+
}
|
|
8079
|
+
out += char;
|
|
8080
|
+
i++;
|
|
8081
|
+
}
|
|
8082
|
+
return out;
|
|
8083
|
+
}
|
|
8084
|
+
function readBalancedArgs(code, openIndex) {
|
|
8085
|
+
if ('(' !== code[openIndex]) return null;
|
|
8086
|
+
const cap = Math.min(code.length, openIndex + 5000);
|
|
8087
|
+
let depth = 0;
|
|
8088
|
+
for(let i = openIndex; i < cap; i++){
|
|
8089
|
+
const char = code[i];
|
|
8090
|
+
if ('"' === char || "'" === char || '`' === char) {
|
|
8091
|
+
i = skipString(code, i, cap);
|
|
8092
|
+
continue;
|
|
8093
|
+
}
|
|
8094
|
+
if ('(' === char) depth++;
|
|
8095
|
+
if (')' === char) {
|
|
8096
|
+
depth--;
|
|
8097
|
+
if (0 === depth) return code.slice(openIndex + 1, i);
|
|
8098
|
+
}
|
|
8099
|
+
}
|
|
8100
|
+
return null;
|
|
8101
|
+
}
|
|
8102
|
+
function skipString(code, start, cap) {
|
|
8103
|
+
const quote = code[start];
|
|
8104
|
+
for(let i = start + 1; i < cap; i++){
|
|
8105
|
+
if ('\\' === code[i]) {
|
|
8106
|
+
i++;
|
|
8107
|
+
continue;
|
|
8108
|
+
}
|
|
8109
|
+
if (code[i] === quote) return i;
|
|
8110
|
+
}
|
|
8111
|
+
return cap;
|
|
8112
|
+
}
|
|
8113
|
+
function splitTopLevelArgs(args) {
|
|
8114
|
+
const parts = [];
|
|
8115
|
+
let depth = 0;
|
|
8116
|
+
let current = '';
|
|
8117
|
+
for(let i = 0; i < args.length; i++){
|
|
8118
|
+
const char = args[i];
|
|
8119
|
+
if ('"' === char || "'" === char || '`' === char) {
|
|
8120
|
+
const end = skipString(args, i, args.length);
|
|
8121
|
+
current += args.slice(i, end + 1);
|
|
8122
|
+
i = end;
|
|
8123
|
+
continue;
|
|
8124
|
+
}
|
|
8125
|
+
if ('(' === char || '[' === char || '{' === char) depth++;
|
|
8126
|
+
if (')' === char || ']' === char || '}' === char) depth--;
|
|
8127
|
+
if (',' === char && 0 === depth) {
|
|
8128
|
+
parts.push(current);
|
|
8129
|
+
current = '';
|
|
8130
|
+
continue;
|
|
8131
|
+
}
|
|
8132
|
+
current += char;
|
|
8133
|
+
}
|
|
8134
|
+
if (current.trim()) parts.push(current);
|
|
8135
|
+
return parts;
|
|
8136
|
+
}
|
|
8137
|
+
function pureStringLiteral(arg) {
|
|
8138
|
+
const match = /^\s*(['"`])((?:\\.|(?!\1)[^\\])*)\1\s*$/.exec(arg);
|
|
8139
|
+
if (!match) return null;
|
|
8140
|
+
if ('`' === match[1] && match[2].includes('${')) return null;
|
|
8141
|
+
return unescapeStringBody(match[2]);
|
|
8142
|
+
}
|
|
8143
|
+
function unescapeStringBody(body) {
|
|
8144
|
+
return body.replace(/\\(.)/g, '$1');
|
|
8145
|
+
}
|
|
7820
8146
|
const basic = [
|
|
7821
8147
|
'var isBrowser = !!(() => { try { return globalThis.browser.runtime.getURL("/") } catch(e) {} })()',
|
|
7822
8148
|
'var isChrome = !!(() => { try { return globalThis.chrome.runtime.getURL("/") } catch(e) {} })()'
|
|
@@ -7884,6 +8210,9 @@ class ScriptsPlugin {
|
|
|
7884
8210
|
manifestPath: this.manifestPath,
|
|
7885
8211
|
includeList: this.includeList || {}
|
|
7886
8212
|
}).apply(compiler);
|
|
8213
|
+
new TraceRuntimeLoadedFiles({
|
|
8214
|
+
manifestPath: this.manifestPath
|
|
8215
|
+
}).apply(compiler);
|
|
7887
8216
|
new AddContentScriptWrapper({
|
|
7888
8217
|
manifestPath: this.manifestPath,
|
|
7889
8218
|
browser: this.browser
|
package/dist/101.mjs
CHANGED
|
@@ -670,7 +670,7 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
|
|
|
670
670
|
}
|
|
671
671
|
return false;
|
|
672
672
|
}
|
|
673
|
-
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.
|
|
673
|
+
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.6-canary.1783350491.2c449344","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@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.26","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.9","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","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","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","typescript":"5.9.3","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","ws":"^8.20.1"}}');
|
|
674
674
|
function asAbsolute(p) {
|
|
675
675
|
return __rspack_external_path.isAbsolute(p) ? p : __rspack_external_path.resolve(p);
|
|
676
676
|
}
|
package/dist/224.mjs
CHANGED
|
@@ -28,8 +28,16 @@ function findNearestPackageJsonSync(manifestPath) {
|
|
|
28
28
|
function backgroundIsRequiredMessageOnly(backgroundChunkName) {
|
|
29
29
|
return `Check the ${pintor.yellow(backgroundChunkName.replace('/', '.'))} field in your ${pintor.yellow('manifest.json')} file.`;
|
|
30
30
|
}
|
|
31
|
+
function importScriptsDependencyMissing(workerPath, literal, expectedPath, sourceSibling) {
|
|
32
|
+
const sibling = sourceSibling ? `Found ${pintor.yellow(sourceSibling)}, but importScripts dependencies are copied as-is, not compiled.\n` : '';
|
|
33
|
+
return `The background service_worker ${pintor.yellow(workerPath)} calls importScripts(${pintor.yellow(`'${literal}'`)}), but ${pintor.yellow(expectedPath)} is not part of the output. The call will fail at runtime.\n` + sibling + `Move the file to ${pintor.yellow(expectedPath)} (or ${pintor.yellow('public/')}) so it ships with the extension, or import it from the worker so it ` + "gets bundled.";
|
|
34
|
+
}
|
|
35
|
+
function injectedFileDependencyMissing(assetName, literal, expectedPath, sourceSibling) {
|
|
36
|
+
const sibling = sourceSibling ? `Found ${pintor.yellow(sourceSibling)}, but injected files are copied as-is, not compiled.\n` : '';
|
|
37
|
+
return `${pintor.yellow(assetName)} injects ${pintor.yellow(`'${literal}'`)} via executeScript/insertCSS, but ${pintor.yellow(expectedPath)} is not part of the output. The injection will fail at runtime.\n` + sibling + `Move the file to ${pintor.yellow(expectedPath)} (or ${pintor.yellow('public/')}) so it ships with the extension.`;
|
|
38
|
+
}
|
|
31
39
|
function reservedScriptsFolder(relPath, indicators) {
|
|
32
40
|
const reasons = indicators.map((r)=>`- ${pintor.gray(r)}`).join('\n');
|
|
33
41
|
return `${pintor.red('ERROR')} scripts/ is a reserved folder in Extension.js.\nEvery file under ${pintor.yellow("scripts/")} is wrapped with the browser content-script mount runtime, so Node.js-only files placed here will fail to parse or run.\nRename the folder at the project root (for example ${pintor.yellow('bin/')}, ${pintor.yellow('tools/')}, ${pintor.yellow('ops/')}, ${pintor.yellow('tasks/')}, or ${pintor.yellow("ci-scripts/")}) or move the file out of scripts/.\n\n${pintor.red('NODE.JS SHAPE')}\n${reasons}\n${pintor.red('NOT ALLOWED')} ${pintor.underline(relPath)}`;
|
|
34
42
|
}
|
|
35
|
-
export { backgroundIsRequiredMessageOnly, findNearestPackageJsonSync, reservedScriptsFolder };
|
|
43
|
+
export { backgroundIsRequiredMessageOnly, findNearestPackageJsonSync, importScriptsDependencyMissing, injectedFileDependencyMissing, reservedScriptsFolder };
|