extension-develop 3.1.1 → 3.2.0-next.10
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/547.js +220 -63
- package/dist/928.js +21 -7
- package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +1 -1
- package/dist/extension-js-devtools/chrome/pages/welcome.js +1 -1
- package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +1 -1
- package/dist/extension-js-devtools/chromium/pages/welcome.js +1 -1
- package/dist/extension-js-devtools/edge/pages/centralized-logger.js +1 -1
- package/dist/extension-js-devtools/edge/pages/welcome.js +1 -1
- package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +1 -1
- package/dist/extension-js-devtools/firefox/pages/welcome.js +1 -1
- package/dist/extension-js-theme/chrome/manifest.json +66 -0
- package/dist/extension-js-theme/chromium/manifest.json +66 -0
- package/dist/extension-js-theme/edge/manifest.json +66 -0
- package/dist/extension-js-theme/firefox/manifest.json +66 -0
- package/dist/module.js +286 -103
- package/package.json +1 -3
package/dist/547.js
CHANGED
|
@@ -146,6 +146,8 @@ exports.modules = {
|
|
|
146
146
|
obj[`import.meta.env.${key}`] = JSON.stringify(combinedVars[key]);
|
|
147
147
|
return obj;
|
|
148
148
|
}, {});
|
|
149
|
+
filteredEnvVars['process.env'] = JSON.stringify({});
|
|
150
|
+
filteredEnvVars['process'] = '({env: {}})';
|
|
149
151
|
filteredEnvVars['process.env.EXTENSION_PUBLIC_BROWSER'] = JSON.stringify(this.browser);
|
|
150
152
|
filteredEnvVars['import.meta.env.EXTENSION_PUBLIC_BROWSER'] = JSON.stringify(this.browser);
|
|
151
153
|
filteredEnvVars['process.env.EXTENSION_PUBLIC_MODE'] = JSON.stringify(mode);
|
|
@@ -424,9 +426,12 @@ exports.modules = {
|
|
|
424
426
|
if (this.clean) new CleanDistFolderPlugin({
|
|
425
427
|
browser: this.browser || 'chrome'
|
|
426
428
|
}).apply(compiler);
|
|
427
|
-
|
|
428
|
-
'
|
|
429
|
-
|
|
429
|
+
try {
|
|
430
|
+
const hasRspackInternals = 'function' == typeof compiler.__internal__registerBuiltinPlugin;
|
|
431
|
+
if (hasRspackInternals) new core_.DefinePlugin({
|
|
432
|
+
'process.env.NODE_ENV': JSON.stringify(compiler.options.mode || 'development')
|
|
433
|
+
}).apply(compiler);
|
|
434
|
+
} catch {}
|
|
430
435
|
if ((this.zip || this.zipSource) && 'production' === compiler.options.mode) new ZipPlugin({
|
|
431
436
|
manifestPath: this.manifestPath,
|
|
432
437
|
browser: this.browser || 'chrome',
|
|
@@ -810,6 +815,12 @@ exports.modules = {
|
|
|
810
815
|
}
|
|
811
816
|
};
|
|
812
817
|
const hasCustomSvgRule = compiler.options.module.rules.some((rule)=>rule && rule.test instanceof RegExp && rule.test.test('.svg') && void 0 !== rule.use);
|
|
818
|
+
const hasCustomFontsRule = compiler.options.module.rules.some((thisRule)=>{
|
|
819
|
+
const rule = thisRule;
|
|
820
|
+
if (!rule || !(rule.test instanceof RegExp)) return false;
|
|
821
|
+
if (!rule.test.test('.woff')) return false;
|
|
822
|
+
return void 0 !== rule.type || void 0 !== rule.use;
|
|
823
|
+
});
|
|
813
824
|
const loaders = [
|
|
814
825
|
...hasCustomSvgRule ? [] : [
|
|
815
826
|
defaultSvgRule
|
|
@@ -826,13 +837,15 @@ exports.modules = {
|
|
|
826
837
|
}
|
|
827
838
|
}
|
|
828
839
|
},
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
840
|
+
...hasCustomFontsRule ? [] : [
|
|
841
|
+
{
|
|
842
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
843
|
+
type: 'asset',
|
|
844
|
+
generator: {
|
|
845
|
+
filename: filenamePattern
|
|
846
|
+
}
|
|
834
847
|
}
|
|
835
|
-
|
|
848
|
+
],
|
|
836
849
|
{
|
|
837
850
|
test: /\.(txt|md|csv|tsv|xml|pdf|docx|doc|xls|xlsx|ppt|pptx|zip|gz|gzip|tgz)$/i,
|
|
838
851
|
type: 'asset',
|
|
@@ -904,9 +917,60 @@ exports.modules = {
|
|
|
904
917
|
return obj;
|
|
905
918
|
}
|
|
906
919
|
class JsFrameworksPlugin {
|
|
920
|
+
findVueLoaderRuleIndices(rules) {
|
|
921
|
+
const indices = [];
|
|
922
|
+
for(let i = 0; i < rules.length; i++){
|
|
923
|
+
const rule = rules[i];
|
|
924
|
+
const testStr = String(rule?.test?.toString?.() || rule?.test || '');
|
|
925
|
+
const isVueTest = testStr.includes('\\.vue') || testStr.includes('/.vue') || '.vue' === testStr;
|
|
926
|
+
if (!isVueTest) continue;
|
|
927
|
+
const use = rule?.use;
|
|
928
|
+
const loader = rule?.loader || (Array.isArray(use) ? use?.[0]?.loader : 'object' == typeof use ? use?.loader : void 0);
|
|
929
|
+
const loaderStr = String(loader || '');
|
|
930
|
+
if (loaderStr.includes('vue-loader')) indices.push(i);
|
|
931
|
+
}
|
|
932
|
+
return indices;
|
|
933
|
+
}
|
|
934
|
+
mergeVueRule(userRule, defaultRule) {
|
|
935
|
+
const merged = {
|
|
936
|
+
...userRule
|
|
937
|
+
};
|
|
938
|
+
if (merged.use) {
|
|
939
|
+
if (Array.isArray(merged.use) && merged.use.length > 0) {
|
|
940
|
+
const first = merged.use[0];
|
|
941
|
+
merged.use = [
|
|
942
|
+
{
|
|
943
|
+
...first,
|
|
944
|
+
loader: first?.loader || defaultRule?.loader,
|
|
945
|
+
options: {
|
|
946
|
+
...defaultRule?.options || {},
|
|
947
|
+
...first?.options || {}
|
|
948
|
+
}
|
|
949
|
+
},
|
|
950
|
+
...merged.use.slice(1)
|
|
951
|
+
];
|
|
952
|
+
} else if ('object' == typeof merged.use) merged.use = {
|
|
953
|
+
...merged.use,
|
|
954
|
+
loader: merged.use?.loader || defaultRule?.loader,
|
|
955
|
+
options: {
|
|
956
|
+
...defaultRule?.options || {},
|
|
957
|
+
...merged.use?.options || {}
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
return merged;
|
|
961
|
+
}
|
|
962
|
+
merged.loader = merged.loader || defaultRule?.loader;
|
|
963
|
+
merged.options = {
|
|
964
|
+
...defaultRule?.options || {},
|
|
965
|
+
...merged.options || {}
|
|
966
|
+
};
|
|
967
|
+
return merged;
|
|
968
|
+
}
|
|
907
969
|
async configureOptions(compiler) {
|
|
908
970
|
const mode = compiler.options.mode || 'development';
|
|
909
971
|
const projectPath = compiler.options.context;
|
|
972
|
+
const devtool = compiler.options.devtool;
|
|
973
|
+
const wantsSourceMaps = false !== devtool && ('development' === mode || null != devtool);
|
|
910
974
|
const maybeInstallReact = await (0, react.b)(projectPath);
|
|
911
975
|
const maybeInstallPreact = await (0, preact.b)(projectPath);
|
|
912
976
|
const maybeInstallVue = await (0, vue.K)(projectPath, mode);
|
|
@@ -940,6 +1004,19 @@ exports.modules = {
|
|
|
940
1004
|
...maybeInstallSvelte?.alias || {},
|
|
941
1005
|
...compiler.options.resolve.alias
|
|
942
1006
|
};
|
|
1007
|
+
const existingRules = Array.isArray(compiler.options.module.rules) ? [
|
|
1008
|
+
...compiler.options.module.rules
|
|
1009
|
+
] : [];
|
|
1010
|
+
let vueLoadersToAdd = maybeInstallVue?.loaders || [];
|
|
1011
|
+
if (maybeInstallVue?.loaders?.length) {
|
|
1012
|
+
const vueRuleIndices = this.findVueLoaderRuleIndices(existingRules);
|
|
1013
|
+
if (vueRuleIndices.length > 0) {
|
|
1014
|
+
const primary = vueRuleIndices[0];
|
|
1015
|
+
existingRules[primary] = this.mergeVueRule(existingRules[primary], maybeInstallVue.loaders[0]);
|
|
1016
|
+
for (const idx of vueRuleIndices.slice(1).reverse())existingRules.splice(idx, 1);
|
|
1017
|
+
vueLoadersToAdd = [];
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
943
1020
|
compiler.options.module.rules = [
|
|
944
1021
|
{
|
|
945
1022
|
test: /\.(js|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
|
|
@@ -959,7 +1036,7 @@ exports.modules = {
|
|
|
959
1036
|
},
|
|
960
1037
|
minify: 'production' === mode,
|
|
961
1038
|
isModule: true,
|
|
962
|
-
sourceMap:
|
|
1039
|
+
sourceMap: wantsSourceMaps,
|
|
963
1040
|
env: {
|
|
964
1041
|
targets
|
|
965
1042
|
},
|
|
@@ -990,9 +1067,9 @@ exports.modules = {
|
|
|
990
1067
|
},
|
|
991
1068
|
...maybeInstallReact?.loaders || [],
|
|
992
1069
|
...maybeInstallPreact?.loaders || [],
|
|
993
|
-
...
|
|
1070
|
+
...vueLoadersToAdd,
|
|
994
1071
|
...maybeInstallSvelte?.loaders || [],
|
|
995
|
-
...
|
|
1072
|
+
...existingRules
|
|
996
1073
|
].filter(Boolean);
|
|
997
1074
|
maybeInstallReact?.plugins?.forEach((plugin)=>plugin.apply(compiler));
|
|
998
1075
|
maybeInstallPreact?.plugins?.forEach((plugin)=>plugin.apply(compiler));
|
|
@@ -1671,6 +1748,33 @@ exports.modules = {
|
|
|
1671
1748
|
return require(manifestPath);
|
|
1672
1749
|
}
|
|
1673
1750
|
}
|
|
1751
|
+
function manifest_filterKeysForThisBrowser(manifest, browser) {
|
|
1752
|
+
const CHROMIUM_BASED_BROWSERS = [
|
|
1753
|
+
'chrome',
|
|
1754
|
+
'edge'
|
|
1755
|
+
];
|
|
1756
|
+
const GECKO_BASED_BROWSERS = [
|
|
1757
|
+
'firefox'
|
|
1758
|
+
];
|
|
1759
|
+
const isChromiumTarget = CHROMIUM_BASED_BROWSERS.includes(browser) || String(browser).includes('chromium');
|
|
1760
|
+
const isGeckoTarget = GECKO_BASED_BROWSERS.includes(browser) || String(browser).includes('gecko');
|
|
1761
|
+
const chromiumPrefixes = new Set([
|
|
1762
|
+
'chromium',
|
|
1763
|
+
'chrome',
|
|
1764
|
+
'edge'
|
|
1765
|
+
]);
|
|
1766
|
+
const geckoPrefixes = new Set([
|
|
1767
|
+
'gecko',
|
|
1768
|
+
'firefox'
|
|
1769
|
+
]);
|
|
1770
|
+
const patchedManifest = JSON.parse(JSON.stringify(manifest), function(key, value) {
|
|
1771
|
+
const indexOfColon = key.indexOf(':');
|
|
1772
|
+
if (-1 === indexOfColon) return value;
|
|
1773
|
+
const prefix = key.substring(0, indexOfColon);
|
|
1774
|
+
if (prefix === browser || isChromiumTarget && chromiumPrefixes.has(prefix) || isGeckoTarget && geckoPrefixes.has(prefix)) this[key.substring(indexOfColon + 1)] = value;
|
|
1775
|
+
});
|
|
1776
|
+
return patchedManifest;
|
|
1777
|
+
}
|
|
1674
1778
|
function update_manifest_define_property(obj, key, value) {
|
|
1675
1779
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
1676
1780
|
value: value,
|
|
@@ -1699,9 +1803,10 @@ exports.modules = {
|
|
|
1699
1803
|
}, ()=>{
|
|
1700
1804
|
if (compilation.errors.length > 0) return;
|
|
1701
1805
|
const manifest = getManifestContent(compilation, this.manifestPath);
|
|
1702
|
-
const
|
|
1806
|
+
const manifestForBrowser = manifest_filterKeysForThisBrowser(manifest, this.browser);
|
|
1807
|
+
const overrides = getManifestOverrides(this.manifestPath, manifestForBrowser);
|
|
1703
1808
|
const patchedManifest = {
|
|
1704
|
-
...
|
|
1809
|
+
...manifestForBrowser,
|
|
1705
1810
|
...JSON.parse(overrides)
|
|
1706
1811
|
};
|
|
1707
1812
|
if ('development' === compiler.options.mode) {
|
|
@@ -1726,7 +1831,9 @@ exports.modules = {
|
|
|
1726
1831
|
}
|
|
1727
1832
|
constructor(options){
|
|
1728
1833
|
update_manifest_define_property(this, "manifestPath", void 0);
|
|
1834
|
+
update_manifest_define_property(this, "browser", void 0);
|
|
1729
1835
|
this.manifestPath = options.manifestPath;
|
|
1836
|
+
this.browser = options.browser || 'chrome';
|
|
1730
1837
|
}
|
|
1731
1838
|
}
|
|
1732
1839
|
function add_dependencies_define_property(obj, key, value) {
|
|
@@ -1906,7 +2013,8 @@ exports.modules = {
|
|
|
1906
2013
|
manifestPath: this.manifestPath
|
|
1907
2014
|
}).apply(compiler);
|
|
1908
2015
|
new UpdateManifest({
|
|
1909
|
-
manifestPath: this.manifestPath
|
|
2016
|
+
manifestPath: this.manifestPath,
|
|
2017
|
+
browser: this.browser
|
|
1910
2018
|
}).apply(compiler);
|
|
1911
2019
|
new AddDependencies([
|
|
1912
2020
|
this.manifestPath
|
|
@@ -3476,7 +3584,7 @@ exports.modules = {
|
|
|
3476
3584
|
];
|
|
3477
3585
|
const weakRuntimeCheck = [
|
|
3478
3586
|
...basic,
|
|
3479
|
-
"var runtime = isBrowser ? browser : isChrome ? chrome :
|
|
3587
|
+
"var runtime = isBrowser ? browser : isChrome ? chrome : { runtime: { getURL: x => x } }"
|
|
3480
3588
|
];
|
|
3481
3589
|
class AddPublicPathRuntimeModule {
|
|
3482
3590
|
apply(compiler) {
|
|
@@ -4282,6 +4390,8 @@ Set background.noDynamicEntryWarning to true to disable this warning.
|
|
|
4282
4390
|
protocol: 'ws'
|
|
4283
4391
|
});
|
|
4284
4392
|
setDefault(devServer.client.webSocketURL, 'protocol', 'ws');
|
|
4393
|
+
if (devServer.host) setDefault(devServer.client.webSocketURL, 'hostname', devServer.host);
|
|
4394
|
+
if (devServer.port) setDefault(devServer.client.webSocketURL, 'port', devServer.port);
|
|
4285
4395
|
setDefault(devServer, 'allowedHosts', 'all');
|
|
4286
4396
|
setDefault(devServer, 'headers', {
|
|
4287
4397
|
'Access-Control-Allow-Origin': '*'
|
|
@@ -6418,6 +6528,44 @@ Set background.noDynamicEntryWarning to true to disable this warning.
|
|
|
6418
6528
|
});
|
|
6419
6529
|
}
|
|
6420
6530
|
}
|
|
6531
|
+
const fontExtRe = /\.(woff2?|eot|ttf|otf)$/i;
|
|
6532
|
+
if (3 === manifest.manifest_version) {
|
|
6533
|
+
const assetKeys = Object.keys(compilation.assets || {});
|
|
6534
|
+
const fontAssets = assetKeys.filter((k)=>fontExtRe.test(k)).filter((k)=>!k.startsWith('assets/')).filter((k)=>!k.startsWith("content_scripts/")).sort();
|
|
6535
|
+
if (fontAssets.length > 0) {
|
|
6536
|
+
const allMatches = Array.from(new Set((manifest.content_scripts || []).flatMap((cs)=>cs.matches || [])));
|
|
6537
|
+
const normalizedMatches = cleanMatches(allMatches);
|
|
6538
|
+
if (normalizedMatches.length > 0) {
|
|
6539
|
+
const existing = webAccessibleResourcesV3.find((entry)=>{
|
|
6540
|
+
const a = [
|
|
6541
|
+
...entry.matches
|
|
6542
|
+
].sort();
|
|
6543
|
+
const b = [
|
|
6544
|
+
...normalizedMatches
|
|
6545
|
+
].sort();
|
|
6546
|
+
return a.length === b.length && a.every((v, i)=>v === b[i]);
|
|
6547
|
+
});
|
|
6548
|
+
if (existing) {
|
|
6549
|
+
const candidates = fontAssets.filter((r)=>!existing.resources.includes(r) && !isCoveredByExistingGlobs(existing.resources, r));
|
|
6550
|
+
existing.resources = Array.from(new Set([
|
|
6551
|
+
...existing.resources || [],
|
|
6552
|
+
...candidates
|
|
6553
|
+
])).sort();
|
|
6554
|
+
} else webAccessibleResourcesV3.push({
|
|
6555
|
+
resources: fontAssets,
|
|
6556
|
+
matches: [
|
|
6557
|
+
...normalizedMatches
|
|
6558
|
+
].sort()
|
|
6559
|
+
});
|
|
6560
|
+
}
|
|
6561
|
+
}
|
|
6562
|
+
} else if (2 === manifest.manifest_version) {
|
|
6563
|
+
const assetKeys = Object.keys(compilation.assets || {});
|
|
6564
|
+
const fontAssets = assetKeys.filter((k)=>fontExtRe.test(k)).sort();
|
|
6565
|
+
if (fontAssets.length > 0) {
|
|
6566
|
+
for (const r of fontAssets)if (!webAccessibleResourcesV2.includes(r)) webAccessibleResourcesV2.push(r);
|
|
6567
|
+
}
|
|
6568
|
+
}
|
|
6421
6569
|
if (3 === manifest.manifest_version) {
|
|
6422
6570
|
const assetKeys = Object.keys(compilation.assets || {});
|
|
6423
6571
|
const cssUnderContentScripts = assetKeys.filter((k)=>k.startsWith("content_scripts/")).filter((k)=>k.endsWith('.css')).sort();
|
|
@@ -6527,7 +6675,6 @@ Set background.noDynamicEntryWarning to true to disable this warning.
|
|
|
6527
6675
|
this.browser = options.browser || 'chrome';
|
|
6528
6676
|
}
|
|
6529
6677
|
}
|
|
6530
|
-
var external_chokidar_ = __webpack_require__("chokidar");
|
|
6531
6678
|
function serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving, folder, typeOfAsset) {
|
|
6532
6679
|
return `${external_pintor_default().red('ERROR')} in ${external_pintor_default().yellow('manifest.json')} entrypoint: ${addingOrRemoving} ${external_pintor_default().yellow(typeOfAsset)} in ${external_pintor_default().underline(folder + '/')} requires a dev server restart to apply changes.`;
|
|
6533
6680
|
}
|
|
@@ -6537,6 +6684,16 @@ Set background.noDynamicEntryWarning to true to disable this warning.
|
|
|
6537
6684
|
function specialFolderChangeDetected(action, folder, relativePath) {
|
|
6538
6685
|
return `Special folders change — ${action} in ${folder}/: ${relativePath}`;
|
|
6539
6686
|
}
|
|
6687
|
+
function warn_upon_folder_changes_define_property(obj, key, value) {
|
|
6688
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
6689
|
+
value: value,
|
|
6690
|
+
enumerable: true,
|
|
6691
|
+
configurable: true,
|
|
6692
|
+
writable: true
|
|
6693
|
+
});
|
|
6694
|
+
else obj[key] = value;
|
|
6695
|
+
return obj;
|
|
6696
|
+
}
|
|
6540
6697
|
class WarnUponFolderChanges {
|
|
6541
6698
|
throwCompilationError(compilation, folder, filePath, isAddition) {
|
|
6542
6699
|
const addingOrRemoving = isAddition ? 'Adding' : 'Removing';
|
|
@@ -6556,58 +6713,57 @@ Set background.noDynamicEntryWarning to true to disable this warning.
|
|
|
6556
6713
|
err.details = `Removing from ${folder}/ breaks current build. Restart the dev server to recompile.`;
|
|
6557
6714
|
compilation.errors?.push(err);
|
|
6558
6715
|
}
|
|
6716
|
+
trackChange(projectPath, folder, change, filePath) {
|
|
6717
|
+
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('add' === change ? 'add' : 'remove', folder, external_path_.relative(projectPath, filePath)));
|
|
6718
|
+
this.pendingChanges.push({
|
|
6719
|
+
type: change,
|
|
6720
|
+
folder,
|
|
6721
|
+
filePath
|
|
6722
|
+
});
|
|
6723
|
+
}
|
|
6724
|
+
collectChanges(compiler) {
|
|
6725
|
+
const projectPath = compiler.options.context || process.cwd();
|
|
6726
|
+
const pagesPath = external_path_.join(projectPath, 'pages') + external_path_.sep;
|
|
6727
|
+
const scriptsPath = external_path_.join(projectPath, "scripts") + external_path_.sep;
|
|
6728
|
+
const extensionsSupported = compiler.options.resolve?.extensions;
|
|
6729
|
+
const supportedScripts = new Set((extensionsSupported || []).map((e)=>e.toLowerCase()));
|
|
6730
|
+
const modifiedFiles = compiler.modifiedFiles || new Set();
|
|
6731
|
+
const removedFiles = compiler.removedFiles || new Set();
|
|
6732
|
+
for (const filePath of modifiedFiles){
|
|
6733
|
+
if (filePath.startsWith(pagesPath) && filePath.endsWith('.html')) this.trackChange(projectPath, 'pages', 'add', filePath);
|
|
6734
|
+
if (filePath.startsWith(scriptsPath)) {
|
|
6735
|
+
const ext = external_path_.extname(filePath).toLowerCase();
|
|
6736
|
+
if (supportedScripts.has(ext)) this.trackChange(projectPath, "scripts", 'add', filePath);
|
|
6737
|
+
}
|
|
6738
|
+
}
|
|
6739
|
+
for (const filePath of removedFiles){
|
|
6740
|
+
if (filePath.startsWith(pagesPath) && filePath.endsWith('.html')) this.trackChange(projectPath, 'pages', 'remove', filePath);
|
|
6741
|
+
if (filePath.startsWith(scriptsPath)) {
|
|
6742
|
+
const ext = external_path_.extname(filePath).toLowerCase();
|
|
6743
|
+
if (supportedScripts.has(ext)) this.trackChange(projectPath, "scripts", 'remove', filePath);
|
|
6744
|
+
}
|
|
6745
|
+
}
|
|
6746
|
+
}
|
|
6747
|
+
applyPendingChanges(compilation) {
|
|
6748
|
+
for (const change of this.pendingChanges)this.throwCompilationError(compilation, change.folder, change.filePath, 'add' === change.type);
|
|
6749
|
+
this.pendingChanges = [];
|
|
6750
|
+
}
|
|
6559
6751
|
apply(compiler) {
|
|
6752
|
+
compiler.hooks.watchRun.tap('special-folders:warn-upon-folder-changes', ()=>{
|
|
6753
|
+
this.collectChanges(compiler);
|
|
6754
|
+
});
|
|
6560
6755
|
compiler.hooks.thisCompilation.tap('special-folders:warn-upon-folder-changes', (compilation)=>{
|
|
6561
6756
|
const projectPath = compiler.options.context || process.cwd();
|
|
6562
6757
|
const pagesPath = external_path_.join(projectPath, 'pages');
|
|
6563
6758
|
const scriptsPath = external_path_.join(projectPath, "scripts");
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
const scriptsWatcher = external_chokidar_.watch(scriptsPath, {
|
|
6568
|
-
ignoreInitial: true
|
|
6569
|
-
});
|
|
6570
|
-
const extensionsSupported = compiler.options.resolve?.extensions;
|
|
6571
|
-
pagesWatcher.on('add', (filePath)=>{
|
|
6572
|
-
const ext = external_path_.extname(filePath).toLowerCase();
|
|
6573
|
-
const isHtml = '.html' === ext;
|
|
6574
|
-
if (isHtml) {
|
|
6575
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('add', 'pages', external_path_.relative(projectPath, filePath)));
|
|
6576
|
-
this.throwCompilationError(compilation, 'pages', filePath, true);
|
|
6577
|
-
}
|
|
6578
|
-
});
|
|
6579
|
-
pagesWatcher.on('unlink', (filePath)=>{
|
|
6580
|
-
const ext = external_path_.extname(filePath).toLowerCase();
|
|
6581
|
-
const isHtml = '.html' === ext;
|
|
6582
|
-
if (isHtml) {
|
|
6583
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('remove', 'pages', external_path_.relative(projectPath, filePath)));
|
|
6584
|
-
this.throwCompilationError(compilation, 'pages', filePath);
|
|
6585
|
-
}
|
|
6586
|
-
});
|
|
6587
|
-
scriptsWatcher.on('add', (filePath)=>{
|
|
6588
|
-
const ext = external_path_.extname(filePath).toLowerCase();
|
|
6589
|
-
const supported = new Set((extensionsSupported || []).map((e)=>e.toLowerCase()));
|
|
6590
|
-
const isScript = supported.has(ext);
|
|
6591
|
-
if (isScript) {
|
|
6592
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('add', "scripts", external_path_.relative(projectPath, filePath)));
|
|
6593
|
-
this.throwCompilationError(compilation, "scripts", filePath, true);
|
|
6594
|
-
}
|
|
6595
|
-
});
|
|
6596
|
-
scriptsWatcher.on('unlink', (filePath)=>{
|
|
6597
|
-
const ext = external_path_.extname(filePath).toLowerCase();
|
|
6598
|
-
const supported = new Set((extensionsSupported || []).map((e)=>e.toLowerCase()));
|
|
6599
|
-
const isScript = supported.has(ext);
|
|
6600
|
-
if (isScript) {
|
|
6601
|
-
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('remove', "scripts", external_path_.relative(projectPath, filePath)));
|
|
6602
|
-
this.throwCompilationError(compilation, "scripts", filePath);
|
|
6603
|
-
}
|
|
6604
|
-
});
|
|
6605
|
-
compiler.hooks.watchClose.tap('WarnUponFolderChanges', ()=>{
|
|
6606
|
-
pagesWatcher.close().catch(()=>{});
|
|
6607
|
-
scriptsWatcher.close().catch(()=>{});
|
|
6608
|
-
});
|
|
6759
|
+
compilation.contextDependencies?.add(pagesPath);
|
|
6760
|
+
compilation.contextDependencies?.add(scriptsPath);
|
|
6761
|
+
this.applyPendingChanges(compilation);
|
|
6609
6762
|
});
|
|
6610
6763
|
}
|
|
6764
|
+
constructor(){
|
|
6765
|
+
warn_upon_folder_changes_define_property(this, "pendingChanges", []);
|
|
6766
|
+
}
|
|
6611
6767
|
}
|
|
6612
6768
|
function checkManifestInPublic(compilation, publicDir) {
|
|
6613
6769
|
try {
|
|
@@ -6798,8 +6954,9 @@ Set background.noDynamicEntryWarning to true to disable this warning.
|
|
|
6798
6954
|
try {
|
|
6799
6955
|
const polyfillPath = require.resolve('webextension-polyfill/dist/browser-polyfill.js', {
|
|
6800
6956
|
paths: [
|
|
6957
|
+
compiler.options.context,
|
|
6801
6958
|
__dirname
|
|
6802
|
-
]
|
|
6959
|
+
].filter(Boolean)
|
|
6803
6960
|
});
|
|
6804
6961
|
const currentResolve = compiler.options.resolve || {};
|
|
6805
6962
|
const existingAlias = currentResolve.alias || {};
|
package/dist/928.js
CHANGED
|
@@ -330,6 +330,13 @@ exports.modules = {
|
|
|
330
330
|
const portAllocation = await portManager.allocatePorts(devOptions.browser, packageJsonDir, desiredPort);
|
|
331
331
|
const currentInstance = portManager.getCurrentInstance();
|
|
332
332
|
if (!currentInstance) throw new Error('Failed to create instance');
|
|
333
|
+
const port = portAllocation.port;
|
|
334
|
+
const devServerHost = '127.0.0.1';
|
|
335
|
+
const devServerWebSocketURL = {
|
|
336
|
+
protocol: 'ws',
|
|
337
|
+
hostname: devServerHost,
|
|
338
|
+
port
|
|
339
|
+
};
|
|
333
340
|
const safeBrowserConfig = (0, sanitize.a)(browserConfig);
|
|
334
341
|
const safeCommandConfig = (0, sanitize.a)(commandConfig);
|
|
335
342
|
const safeDevOptions = (0, sanitize.a)(devOptions);
|
|
@@ -349,12 +356,23 @@ exports.modules = {
|
|
|
349
356
|
const customWebpackConfig = await (0, config_loader.Tu)(manifestDir);
|
|
350
357
|
const finalConfig = customWebpackConfig(baseConfig);
|
|
351
358
|
const compilerConfig = (0, external_webpack_merge_.merge)(finalConfig, {});
|
|
359
|
+
compilerConfig.devServer = {
|
|
360
|
+
...compilerConfig.devServer || {},
|
|
361
|
+
host: devServerHost,
|
|
362
|
+
port,
|
|
363
|
+
client: {
|
|
364
|
+
...(compilerConfig.devServer || {}).client || {},
|
|
365
|
+
webSocketURL: {
|
|
366
|
+
...((compilerConfig.devServer || {}).client || {}).webSocketURL || {},
|
|
367
|
+
...devServerWebSocketURL
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
};
|
|
352
371
|
const compiler = (0, core_.rspack)(compilerConfig);
|
|
353
372
|
setupCompilerHooks(compiler, portAllocation.port);
|
|
354
|
-
const port = portAllocation.port;
|
|
355
373
|
if (void 0 !== devOptions.port && devOptions.port !== port) console.log(portInUse(devOptions.port, port));
|
|
356
374
|
const serverConfig = {
|
|
357
|
-
host:
|
|
375
|
+
host: devServerHost,
|
|
358
376
|
allowedHosts: 'all',
|
|
359
377
|
static: {
|
|
360
378
|
watch: {
|
|
@@ -382,11 +400,7 @@ exports.modules = {
|
|
|
382
400
|
logging: 'none',
|
|
383
401
|
progress: false,
|
|
384
402
|
overlay: false,
|
|
385
|
-
webSocketURL:
|
|
386
|
-
protocol: 'ws',
|
|
387
|
-
hostname: '127.0.0.1',
|
|
388
|
-
port
|
|
389
|
-
}
|
|
403
|
+
webSocketURL: devServerWebSocketURL
|
|
390
404
|
},
|
|
391
405
|
headers: {
|
|
392
406
|
'Access-Control-Allow-Origin': '*'
|