extension-develop 3.15.1 → 3.16.0

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.
Files changed (39) hide show
  1. package/dist/0~branding.mjs +26 -0
  2. package/dist/0~dev-server.mjs +488 -0
  3. package/dist/0~rslib-runtime.mjs +40 -0
  4. package/dist/0~rspack-config.mjs +8648 -0
  5. package/dist/0~stats-handler.mjs +25 -0
  6. package/dist/0~zip.mjs +34 -0
  7. package/dist/314.mjs +35 -0
  8. package/dist/526.mjs +23 -0
  9. package/dist/946.mjs +1670 -0
  10. package/dist/962.mjs +1389 -0
  11. package/dist/ensure-hmr-for-scripts.js +12 -56
  12. package/dist/{ensure-hmr-for-scripts.cjs → ensure-hmr-for-scripts.mjs} +12 -56
  13. package/dist/feature-scripts-content-script-wrapper.js +23 -98
  14. package/dist/{feature-scripts-content-script-wrapper.cjs → feature-scripts-content-script-wrapper.mjs} +23 -98
  15. package/dist/main-world-bridge.js +0 -18
  16. package/dist/{main-world-bridge.cjs → main-world-bridge.mjs} +0 -18
  17. package/dist/minimum-chromium-file.js +0 -5
  18. package/dist/minimum-chromium-file.mjs +5 -0
  19. package/dist/minimum-firefox-file.js +0 -5
  20. package/dist/minimum-firefox-file.mjs +5 -0
  21. package/dist/minimum-script-file.js +0 -18
  22. package/dist/{minimum-script-file.cjs → minimum-script-file.mjs} +0 -18
  23. package/dist/module.mjs +3 -0
  24. package/dist/package.json +1 -1
  25. package/dist/preact-refresh-shim.mjs +7 -0
  26. package/dist/preview.mjs +2 -0
  27. package/dist/resolve-paths-loader.js +1043 -1093
  28. package/dist/resolve-paths-loader.mjs +1300 -0
  29. package/package.json +8 -8
  30. package/dist/221.cjs +0 -513
  31. package/dist/442.cjs +0 -9226
  32. package/dist/504.cjs +0 -65
  33. package/dist/787.cjs +0 -44
  34. package/dist/minimum-chromium-file.cjs +0 -10
  35. package/dist/minimum-firefox-file.cjs +0 -10
  36. package/dist/module.cjs +0 -3479
  37. package/dist/preact-refresh-shim.cjs +0 -25
  38. package/dist/preview.cjs +0 -1464
  39. package/dist/resolve-paths-loader.cjs +0 -1350
@@ -1,630 +1,631 @@
1
- "use strict";
2
- var __webpack_modules__ = {
3
- "@swc/core" (module) {
4
- module.exports = require("@swc/core");
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import magic_string from "magic-string";
3
+ import { createRequire } from "module";
4
+ import { __webpack_require__ } from "./0~rslib-runtime.mjs";
5
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
6
+ import * as __rspack_external__swc_core_81ba23c0 from "@swc/core";
7
+ import * as __rspack_external_path from "path";
8
+ import * as __rspack_external_fs from "fs";
9
+ __webpack_require__.add({
10
+ "@swc/core?1153" (module) {
11
+ module.exports = __rspack_external__swc_core_81ba23c0;
5
12
  }
6
- };
7
- var __webpack_module_cache__ = {};
8
- function __webpack_require__(moduleId) {
9
- var cachedModule = __webpack_module_cache__[moduleId];
10
- if (void 0 !== cachedModule) return cachedModule.exports;
11
- var module = __webpack_module_cache__[moduleId] = {
12
- exports: {}
13
- };
14
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
- return module.exports;
13
+ });
14
+ function getFilename(feature, filePath) {
15
+ const entryExt = __rspack_external_path.extname(filePath);
16
+ let fileOutputpath = feature;
17
+ if ([
18
+ '.js',
19
+ '.jsx',
20
+ '.tsx',
21
+ '.ts'
22
+ ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.js');
23
+ if ([
24
+ '.html',
25
+ '.njk',
26
+ '.nunjucks'
27
+ ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.html');
28
+ if ([
29
+ '.css',
30
+ '.scss',
31
+ '.sass',
32
+ '.less'
33
+ ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.css');
34
+ return unixify(fileOutputpath || '');
16
35
  }
17
- (()=>{
18
- __webpack_require__.n = (module)=>{
19
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
20
- __webpack_require__.d(getter, {
21
- a: getter
22
- });
23
- return getter;
24
- };
25
- })();
26
- (()=>{
27
- __webpack_require__.d = (exports1, definition)=>{
28
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
- enumerable: true,
30
- get: definition[key]
31
- });
32
- };
33
- })();
34
- (()=>{
35
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
36
- })();
37
- (()=>{
38
- __webpack_require__.r = (exports1)=>{
39
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
40
- value: 'Module'
41
- });
42
- Object.defineProperty(exports1, '__esModule', {
43
- value: true
44
- });
45
- };
46
- })();
47
- var __webpack_exports__ = {};
48
- (()=>{
49
- __webpack_require__.r(__webpack_exports__);
50
- __webpack_require__.d(__webpack_exports__, {
51
- default: ()=>resolvePathsLoader
52
- });
53
- const external_path_namespaceObject = require("path");
54
- const external_fs_namespaceObject = require("fs");
55
- const external_magic_string_namespaceObject = require("magic-string");
56
- var external_magic_string_default = /*#__PURE__*/ __webpack_require__.n(external_magic_string_namespaceObject);
57
- function getFilename(feature, filePath) {
58
- const entryExt = external_path_namespaceObject.extname(filePath);
59
- let fileOutputpath = feature;
60
- if ([
61
- '.js',
62
- '.jsx',
63
- '.tsx',
64
- '.ts'
65
- ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.js');
66
- if ([
67
- '.html',
68
- '.njk',
69
- '.nunjucks'
70
- ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.html');
71
- if ([
72
- '.css',
73
- '.scss',
74
- '.sass',
75
- '.less'
76
- ].includes(entryExt)) fileOutputpath = fileOutputpath.replace(entryExt, '.css');
77
- return unixify(fileOutputpath || '');
78
- }
79
- function unixify(filePath) {
80
- return filePath.replace(/\\/g, '/');
81
- }
82
- function memberChainFromCallee(callee) {
83
- const memberParts = [];
84
- let currentExpression = callee;
85
- while(currentExpression && 'ParenExpression' === currentExpression.type)currentExpression = currentExpression.expression;
86
- while(currentExpression){
87
- if ('Identifier' === currentExpression.type) {
88
- memberParts.unshift(currentExpression.value);
89
- break;
90
- }
91
- if ('MemberExpression' === currentExpression.type) {
92
- const propertyNode = currentExpression.property;
93
- if (propertyNode?.type === 'Identifier') memberParts.unshift(propertyNode.value);
94
- currentExpression = currentExpression.object;
95
- continue;
96
- }
36
+ function unixify(filePath) {
37
+ return filePath.replace(/\\/g, '/');
38
+ }
39
+ function memberChainFromCallee(callee) {
40
+ const memberParts = [];
41
+ let currentExpression = callee;
42
+ while(currentExpression && 'ParenExpression' === currentExpression.type)currentExpression = currentExpression.expression;
43
+ while(currentExpression){
44
+ if ('Identifier' === currentExpression.type) {
45
+ memberParts.unshift(currentExpression.value);
97
46
  break;
98
47
  }
99
- return memberParts;
100
- }
101
- function getPropName(propertyNode) {
102
- if (!propertyNode || 'KeyValueProperty' !== propertyNode.type) return;
103
- const keyNode = propertyNode.key;
104
- if (keyNode?.type === 'Identifier') return keyNode.value;
105
- if (keyNode?.type === 'StringLiteral') return keyNode.value;
48
+ if ('MemberExpression' === currentExpression.type) {
49
+ const propertyNode = currentExpression.property;
50
+ if (propertyNode?.type === 'Identifier') memberParts.unshift(propertyNode.value);
51
+ currentExpression = currentExpression.object;
52
+ continue;
53
+ }
54
+ break;
106
55
  }
107
- function isHttpLike(input) {
108
- return /^https?:\/\//i.test(input) || /^data:/i.test(input) || /^chrome:\/\//i.test(input) || /^moz-extension:\/\//i.test(input);
56
+ return memberParts;
57
+ }
58
+ function getPropName(propertyNode) {
59
+ if (!propertyNode || 'KeyValueProperty' !== propertyNode.type) return;
60
+ const keyNode = propertyNode.key;
61
+ if (keyNode?.type === 'Identifier') return keyNode.value;
62
+ if (keyNode?.type === 'StringLiteral') return keyNode.value;
63
+ }
64
+ function isHttpLike(input) {
65
+ return /^https?:\/\//i.test(input) || /^data:/i.test(input) || /^chrome:\/\//i.test(input) || /^moz-extension:\/\//i.test(input);
66
+ }
67
+ function hasGlob(input) {
68
+ return /[*?\[\]{}]/.test(input);
69
+ }
70
+ function resolveLiteralToOutput(literal, opts) {
71
+ const { manifestPath, packageJsonDir, authorFilePath } = opts;
72
+ const root = packageJsonDir || __rspack_external_path.dirname(manifestPath);
73
+ const canonicalUnixPath = unixify(literal || '');
74
+ if (!literal || isHttpLike(literal) || hasGlob(literal)) return;
75
+ if (/^\/public\//i.test(canonicalUnixPath)) {
76
+ const out = canonicalUnixPath.replace(/^\/public\//i, '');
77
+ return out;
109
78
  }
110
- function hasGlob(input) {
111
- return /[*?\[\]{}]/.test(input);
79
+ if (/^(?:\.\/)?public\//i.test(canonicalUnixPath)) {
80
+ const out = canonicalUnixPath.replace(/^(?:\.\/)?public\//i, '');
81
+ return out;
112
82
  }
113
- function resolveLiteralToOutput(literal, opts) {
114
- const { manifestPath, packageJsonDir, authorFilePath } = opts;
115
- const root = packageJsonDir || external_path_namespaceObject.dirname(manifestPath);
116
- const canonicalUnixPath = unixify(literal || '');
117
- if (!literal || isHttpLike(literal) || hasGlob(literal)) return;
118
- if (/^\/public\//i.test(canonicalUnixPath)) {
119
- const out = canonicalUnixPath.replace(/^\/public\//i, '');
120
- return out;
121
- }
122
- if (/^(?:\.\/)?public\//i.test(canonicalUnixPath)) {
123
- const out = canonicalUnixPath.replace(/^(?:\.\/)?public\//i, '');
124
- return out;
125
- }
126
- if (/^\//.test(canonicalUnixPath)) {
127
- const trimmed = canonicalUnixPath.replace(/^\//, '');
128
- if (/^(?:pages|scripts)\//i.test(trimmed)) {
129
- const abs = external_path_namespaceObject.join(root, trimmed);
130
- return unixify(getFilename(trimmed, abs));
131
- }
132
- return trimmed;
83
+ if (/^\//.test(canonicalUnixPath)) {
84
+ const trimmed = canonicalUnixPath.replace(/^\//, '');
85
+ if (/^(?:pages|scripts)\//i.test(trimmed)) {
86
+ const abs = __rspack_external_path.join(root, trimmed);
87
+ return unixify(getFilename(trimmed, abs));
133
88
  }
134
- const baseDir = /^(\.\/|\.\.\/)/.test(canonicalUnixPath) && authorFilePath ? external_path_namespaceObject.dirname(authorFilePath) : root;
135
- const candidateAbsolutePath = external_path_namespaceObject.isAbsolute(literal) ? literal : external_path_namespaceObject.resolve(baseDir, literal);
136
- const pathWithoutDotPrefix = canonicalUnixPath.replace(/^\.\//, '');
137
- if (/^pages\//i.test(pathWithoutDotPrefix)) return unixify(getFilename(pathWithoutDotPrefix, candidateAbsolutePath));
138
- if (/^scripts\//i.test(pathWithoutDotPrefix)) return unixify(getFilename(pathWithoutDotPrefix, candidateAbsolutePath));
139
- try {
140
- const normalizedRel = unixify(external_path_namespaceObject.relative(root, candidateAbsolutePath));
141
- const relNoDotPrefix = normalizedRel.replace(/^\.\//, '');
142
- if (/^public\//i.test(relNoDotPrefix)) return relNoDotPrefix.replace(/^public\//i, '');
143
- if (/^pages\//i.test(relNoDotPrefix)) return unixify(getFilename(relNoDotPrefix, candidateAbsolutePath));
144
- if (/^scripts\//i.test(relNoDotPrefix)) return unixify(getFilename(relNoDotPrefix, candidateAbsolutePath));
145
- } catch {}
89
+ return trimmed;
146
90
  }
147
- function isStringLiteral(node) {
148
- return node && 'StringLiteral' === node.type && 'string' == typeof node.value;
149
- }
150
- function isStaticTemplate(node) {
151
- return node && 'TemplateLiteral' === node.type && Array.isArray(node.expressions) && 0 === node.expressions.length;
91
+ const baseDir = /^(\.\/|\.\.\/)/.test(canonicalUnixPath) && authorFilePath ? __rspack_external_path.dirname(authorFilePath) : root;
92
+ const candidateAbsolutePath = __rspack_external_path.isAbsolute(literal) ? literal : __rspack_external_path.resolve(baseDir, literal);
93
+ const pathWithoutDotPrefix = canonicalUnixPath.replace(/^\.\//, '');
94
+ if (/^pages\//i.test(pathWithoutDotPrefix)) return unixify(getFilename(pathWithoutDotPrefix, candidateAbsolutePath));
95
+ if (/^scripts\//i.test(pathWithoutDotPrefix)) return unixify(getFilename(pathWithoutDotPrefix, candidateAbsolutePath));
96
+ try {
97
+ const normalizedRel = unixify(__rspack_external_path.relative(root, candidateAbsolutePath));
98
+ const relNoDotPrefix = normalizedRel.replace(/^\.\//, '');
99
+ if (/^public\//i.test(relNoDotPrefix)) return relNoDotPrefix.replace(/^public\//i, '');
100
+ if (/^pages\//i.test(relNoDotPrefix)) return unixify(getFilename(relNoDotPrefix, candidateAbsolutePath));
101
+ if (/^scripts\//i.test(relNoDotPrefix)) return unixify(getFilename(relNoDotPrefix, candidateAbsolutePath));
102
+ } catch {}
103
+ }
104
+ function isStringLiteral(node) {
105
+ return node && 'StringLiteral' === node.type && 'string' == typeof node.value;
106
+ }
107
+ function isStaticTemplate(node) {
108
+ return node && 'TemplateLiteral' === node.type && Array.isArray(node.expressions) && 0 === node.expressions.length;
109
+ }
110
+ function evalStaticString(node) {
111
+ if (!node) return;
112
+ if (node && 'ParenExpression' === node.type) return evalStaticString(node.expression);
113
+ if (isStringLiteral(node)) return node.value;
114
+ if (isStaticTemplate(node)) return node.quasis?.map((quasi)=>quasi.raw ?? '').join('');
115
+ if (node && 'BinaryExpression' === node.type && '+' === node.operator) {
116
+ const left = evalStaticString(node.left);
117
+ const right = evalStaticString(node.right);
118
+ if ('string' == typeof left && 'string' == typeof right) return left + right;
152
119
  }
153
- function evalStaticString(node) {
154
- if (!node) return;
155
- if (node && 'ParenExpression' === node.type) return evalStaticString(node.expression);
156
- if (isStringLiteral(node)) return node.value;
157
- if (isStaticTemplate(node)) return node.quasis?.map((quasi)=>quasi.raw ?? '').join('');
158
- if (node && 'BinaryExpression' === node.type && '+' === node.operator) {
159
- const left = evalStaticString(node.left);
160
- const right = evalStaticString(node.right);
161
- if ('string' == typeof left && 'string' == typeof right) return left + right;
120
+ }
121
+ function handleRuntimeCalls(node, source, rewriteValue, manifestPath) {
122
+ if ('CallExpression' !== node.type) return false;
123
+ const memberChain = memberChainFromCallee(node.callee);
124
+ const apiRoot = memberChain[0];
125
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
126
+ const method = memberChain.join('.');
127
+ if ((method.endsWith('runtime.getURL') || method.endsWith('extension.getURL')) && node.arguments?.[0]) {
128
+ const firstArgument = node.arguments[0].expression;
129
+ if (isStringLiteral(firstArgument)) {
130
+ const resolved = resolveLiteralToOutput(firstArgument.value, {
131
+ manifestPath
132
+ });
133
+ rewriteValue(firstArgument, resolved, firstArgument.value);
134
+ } else if (isStaticTemplate(firstArgument)) {
135
+ const rawTemplate = source.slice(firstArgument.span.start + 1, firstArgument.span.end - 1);
136
+ const resolved = resolveLiteralToOutput(rawTemplate, {
137
+ manifestPath
138
+ });
139
+ rewriteValue(firstArgument, resolved, rawTemplate);
162
140
  }
141
+ return true;
163
142
  }
164
- function handleRuntimeCalls(node, source, rewriteValue, manifestPath) {
165
- if ('CallExpression' !== node.type) return false;
166
- const memberChain = memberChainFromCallee(node.callee);
167
- const apiRoot = memberChain[0];
168
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
169
- const method = memberChain.join('.');
170
- if ((method.endsWith('runtime.getURL') || method.endsWith('extension.getURL')) && node.arguments?.[0]) {
171
- const firstArgument = node.arguments[0].expression;
172
- if (isStringLiteral(firstArgument)) {
173
- const resolved = resolveLiteralToOutput(firstArgument.value, {
174
- manifestPath
175
- });
176
- rewriteValue(firstArgument, resolved, firstArgument.value);
177
- } else if (isStaticTemplate(firstArgument)) {
178
- const rawTemplate = source.slice(firstArgument.span.start + 1, firstArgument.span.end - 1);
179
- const resolved = resolveLiteralToOutput(rawTemplate, {
143
+ return false;
144
+ }
145
+ function handleActionAndPopup(node, source, rewriteValue, manifestPath) {
146
+ if ('CallExpression' !== node.type) return false;
147
+ const memberChain = memberChainFromCallee(node.callee);
148
+ const apiRoot = memberChain[0];
149
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
150
+ const method = memberChain.join('.');
151
+ if (method.endsWith('action.setIcon') || method.endsWith('pageAction.setIcon') || method.endsWith('browserAction.setIcon')) {
152
+ const firstArgument = node.arguments?.[0]?.expression;
153
+ if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
154
+ if ('KeyValueProperty' !== propertyNode.type) continue;
155
+ const keyName = getPropName(propertyNode);
156
+ if ('path' !== keyName) continue;
157
+ const valueNode = propertyNode.value;
158
+ if (isStringLiteral(valueNode)) {
159
+ const resolved = resolveLiteralToOutput(valueNode.value, {
180
160
  manifestPath
181
161
  });
182
- rewriteValue(firstArgument, resolved, rawTemplate);
183
- }
184
- return true;
185
- }
186
- return false;
187
- }
188
- function handleActionAndPopup(node, source, rewriteValue, manifestPath) {
189
- if ('CallExpression' !== node.type) return false;
190
- const memberChain = memberChainFromCallee(node.callee);
191
- const apiRoot = memberChain[0];
192
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
193
- const method = memberChain.join('.');
194
- if (method.endsWith('action.setIcon') || method.endsWith('pageAction.setIcon') || method.endsWith('browserAction.setIcon')) {
195
- const firstArgument = node.arguments?.[0]?.expression;
196
- if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
197
- if ('KeyValueProperty' !== propertyNode.type) continue;
198
- const keyName = getPropName(propertyNode);
199
- if ('path' !== keyName) continue;
200
- const valueNode = propertyNode.value;
201
- if (isStringLiteral(valueNode)) {
202
- const resolved = resolveLiteralToOutput(valueNode.value, {
162
+ rewriteValue(valueNode, resolved, valueNode.value);
163
+ } else if (valueNode?.type === 'ObjectExpression') {
164
+ for (const innerProperty of valueNode.properties || [])if ('KeyValueProperty' === innerProperty.type && isStringLiteral(innerProperty.value)) {
165
+ const resolved = resolveLiteralToOutput(innerProperty.value.value, {
203
166
  manifestPath
204
167
  });
205
- rewriteValue(valueNode, resolved, valueNode.value);
206
- } else if (valueNode?.type === 'ObjectExpression') {
207
- for (const innerProperty of valueNode.properties || [])if ('KeyValueProperty' === innerProperty.type && isStringLiteral(innerProperty.value)) {
208
- const resolved = resolveLiteralToOutput(innerProperty.value.value, {
209
- manifestPath
210
- });
211
- rewriteValue(innerProperty.value, resolved, innerProperty.value.value);
212
- } else if ('KeyValueProperty' === innerProperty.type && isStaticTemplate(innerProperty.value)) {
213
- const raw = source.slice(innerProperty.value.span.start + 1, innerProperty.value.span.end - 1);
214
- const resolved = resolveLiteralToOutput(raw, {
215
- manifestPath
216
- });
217
- rewriteValue(innerProperty.value, resolved, raw);
218
- } else if ('KeyValueProperty' === innerProperty.type) {
219
- const raw = evalStaticString(innerProperty.value);
220
- if ('string' == typeof raw) {
221
- const resolved = resolveLiteralToOutput(raw, {
222
- manifestPath
223
- });
224
- const originalExpr = source.slice(innerProperty.value.span.start, innerProperty.value.span.end);
225
- rewriteValue(innerProperty.value, resolved, originalExpr);
226
- }
227
- }
228
- } else if (isStaticTemplate(valueNode)) {
229
- const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
168
+ rewriteValue(innerProperty.value, resolved, innerProperty.value.value);
169
+ } else if ('KeyValueProperty' === innerProperty.type && isStaticTemplate(innerProperty.value)) {
170
+ const raw = source.slice(innerProperty.value.span.start + 1, innerProperty.value.span.end - 1);
230
171
  const resolved = resolveLiteralToOutput(raw, {
231
172
  manifestPath
232
173
  });
233
- rewriteValue(valueNode, resolved, raw);
234
- } else {
235
- const raw = evalStaticString(valueNode);
174
+ rewriteValue(innerProperty.value, resolved, raw);
175
+ } else if ('KeyValueProperty' === innerProperty.type) {
176
+ const raw = evalStaticString(innerProperty.value);
236
177
  if ('string' == typeof raw) {
237
178
  const resolved = resolveLiteralToOutput(raw, {
238
179
  manifestPath
239
180
  });
240
- const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
241
- rewriteValue(valueNode, resolved, originalExpr);
181
+ const originalExpr = source.slice(innerProperty.value.span.start, innerProperty.value.span.end);
182
+ rewriteValue(innerProperty.value, resolved, originalExpr);
242
183
  }
243
184
  }
244
- }
245
- return true;
246
- }
247
- if (method.endsWith('action.setPopup') || method.endsWith('pageAction.setPopup') || method.endsWith('browserAction.setPopup')) {
248
- const firstArgument = node.arguments?.[0]?.expression;
249
- if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
250
- if ('KeyValueProperty' !== propertyNode.type) continue;
251
- const keyName = getPropName(propertyNode);
252
- if ('popup' !== keyName) continue;
253
- const valueNode = propertyNode.value;
254
- if (isStringLiteral(valueNode)) {
255
- const resolved = resolveLiteralToOutput(valueNode.value, {
256
- manifestPath
257
- });
258
- rewriteValue(valueNode, resolved);
259
- } else if (isStaticTemplate(valueNode)) {
260
- const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
185
+ } else if (isStaticTemplate(valueNode)) {
186
+ const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
187
+ const resolved = resolveLiteralToOutput(raw, {
188
+ manifestPath
189
+ });
190
+ rewriteValue(valueNode, resolved, raw);
191
+ } else {
192
+ const raw = evalStaticString(valueNode);
193
+ if ('string' == typeof raw) {
261
194
  const resolved = resolveLiteralToOutput(raw, {
262
195
  manifestPath
263
196
  });
264
- rewriteValue(valueNode, resolved);
265
- } else {
266
- const raw = evalStaticString(valueNode);
267
- if ('string' == typeof raw) {
268
- const resolved = resolveLiteralToOutput(raw, {
269
- manifestPath
270
- });
271
- const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
272
- rewriteValue(valueNode, resolved, originalExpr);
273
- }
197
+ const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
198
+ rewriteValue(valueNode, resolved, originalExpr);
274
199
  }
275
200
  }
276
- return true;
277
201
  }
278
- return false;
202
+ return true;
279
203
  }
280
- function handleDevtools(node, source, rewriteValue, manifestPath) {
281
- if ('CallExpression' !== node.type) return false;
282
- const memberChain = memberChainFromCallee(node.callee);
283
- const apiRoot = memberChain[0];
284
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
285
- const method = memberChain.join('.');
286
- if (method.endsWith('devtools.panels.create')) {
287
- const iconArg = node.arguments?.[1]?.expression;
288
- const pageArg = node.arguments?.[2]?.expression;
289
- let touched = false;
290
- if (isStringLiteral(iconArg)) {
291
- const resolved = resolveLiteralToOutput(iconArg.value, {
204
+ if (method.endsWith('action.setPopup') || method.endsWith('pageAction.setPopup') || method.endsWith('browserAction.setPopup')) {
205
+ const firstArgument = node.arguments?.[0]?.expression;
206
+ if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
207
+ if ('KeyValueProperty' !== propertyNode.type) continue;
208
+ const keyName = getPropName(propertyNode);
209
+ if ('popup' !== keyName) continue;
210
+ const valueNode = propertyNode.value;
211
+ if (isStringLiteral(valueNode)) {
212
+ const resolved = resolveLiteralToOutput(valueNode.value, {
292
213
  manifestPath
293
214
  });
294
- rewriteValue(iconArg, resolved, iconArg.value);
295
- touched = true;
296
- } else if (isStaticTemplate(iconArg)) {
297
- const rawTemplate = source.slice(iconArg.span.start + 1, iconArg.span.end - 1);
298
- const resolved = resolveLiteralToOutput(rawTemplate, {
215
+ rewriteValue(valueNode, resolved);
216
+ } else if (isStaticTemplate(valueNode)) {
217
+ const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
218
+ const resolved = resolveLiteralToOutput(raw, {
299
219
  manifestPath
300
220
  });
301
- rewriteValue(iconArg, resolved, rawTemplate);
221
+ rewriteValue(valueNode, resolved);
302
222
  } else {
303
- const staticallyEvaluated = evalStaticString(iconArg);
304
- if ('string' == typeof staticallyEvaluated) {
305
- const resolved = resolveLiteralToOutput(staticallyEvaluated, {
223
+ const raw = evalStaticString(valueNode);
224
+ if ('string' == typeof raw) {
225
+ const resolved = resolveLiteralToOutput(raw, {
306
226
  manifestPath
307
227
  });
308
- const originalExpr = source.slice(iconArg.span.start, iconArg.span.end);
309
- rewriteValue(iconArg, resolved, originalExpr);
310
- touched = true;
228
+ const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
229
+ rewriteValue(valueNode, resolved, originalExpr);
311
230
  }
312
231
  }
313
- if (isStringLiteral(pageArg)) {
314
- const resolved = resolveLiteralToOutput(pageArg.value, {
232
+ }
233
+ return true;
234
+ }
235
+ return false;
236
+ }
237
+ function handleDevtools(node, source, rewriteValue, manifestPath) {
238
+ if ('CallExpression' !== node.type) return false;
239
+ const memberChain = memberChainFromCallee(node.callee);
240
+ const apiRoot = memberChain[0];
241
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
242
+ const method = memberChain.join('.');
243
+ if (method.endsWith('devtools.panels.create')) {
244
+ const iconArg = node.arguments?.[1]?.expression;
245
+ const pageArg = node.arguments?.[2]?.expression;
246
+ let touched = false;
247
+ if (isStringLiteral(iconArg)) {
248
+ const resolved = resolveLiteralToOutput(iconArg.value, {
249
+ manifestPath
250
+ });
251
+ rewriteValue(iconArg, resolved, iconArg.value);
252
+ touched = true;
253
+ } else if (isStaticTemplate(iconArg)) {
254
+ const rawTemplate = source.slice(iconArg.span.start + 1, iconArg.span.end - 1);
255
+ const resolved = resolveLiteralToOutput(rawTemplate, {
256
+ manifestPath
257
+ });
258
+ rewriteValue(iconArg, resolved, rawTemplate);
259
+ } else {
260
+ const staticallyEvaluated = evalStaticString(iconArg);
261
+ if ('string' == typeof staticallyEvaluated) {
262
+ const resolved = resolveLiteralToOutput(staticallyEvaluated, {
315
263
  manifestPath
316
264
  });
317
- rewriteValue(pageArg, resolved, pageArg.value);
265
+ const originalExpr = source.slice(iconArg.span.start, iconArg.span.end);
266
+ rewriteValue(iconArg, resolved, originalExpr);
318
267
  touched = true;
319
- } else if (isStaticTemplate(pageArg)) {
320
- const rawTemplate = source.slice(pageArg.span.start + 1, pageArg.span.end - 1);
321
- const resolved = resolveLiteralToOutput(rawTemplate, {
268
+ }
269
+ }
270
+ if (isStringLiteral(pageArg)) {
271
+ const resolved = resolveLiteralToOutput(pageArg.value, {
272
+ manifestPath
273
+ });
274
+ rewriteValue(pageArg, resolved, pageArg.value);
275
+ touched = true;
276
+ } else if (isStaticTemplate(pageArg)) {
277
+ const rawTemplate = source.slice(pageArg.span.start + 1, pageArg.span.end - 1);
278
+ const resolved = resolveLiteralToOutput(rawTemplate, {
279
+ manifestPath
280
+ });
281
+ rewriteValue(pageArg, resolved, rawTemplate);
282
+ } else {
283
+ const staticallyEvaluated = evalStaticString(pageArg);
284
+ if ('string' == typeof staticallyEvaluated) {
285
+ const resolved = resolveLiteralToOutput(staticallyEvaluated, {
322
286
  manifestPath
323
287
  });
324
- rewriteValue(pageArg, resolved, rawTemplate);
325
- } else {
326
- const staticallyEvaluated = evalStaticString(pageArg);
327
- if ('string' == typeof staticallyEvaluated) {
328
- const resolved = resolveLiteralToOutput(staticallyEvaluated, {
329
- manifestPath
330
- });
331
- const originalExpr = source.slice(pageArg.span.start, pageArg.span.end);
332
- rewriteValue(pageArg, resolved, originalExpr);
333
- touched = true;
334
- }
288
+ const originalExpr = source.slice(pageArg.span.start, pageArg.span.end);
289
+ rewriteValue(pageArg, resolved, originalExpr);
290
+ touched = true;
335
291
  }
336
- return touched;
337
292
  }
338
- return false;
293
+ return touched;
339
294
  }
340
- function handleTabsAndWindows(node, source, rewriteValue, manifestPath) {
341
- if ('CallExpression' !== node.type) return false;
342
- const memberChain = memberChainFromCallee(node.callee);
343
- const apiRoot = memberChain[0];
344
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
345
- const method = memberChain.join('.');
346
- if (method.endsWith('tabs.create') || method.endsWith('windows.create')) {
347
- const firstArgument = node.arguments?.[0]?.expression;
348
- if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
349
- if ('KeyValueProperty' !== propertyNode.type) continue;
350
- const keyName = getPropName(propertyNode);
351
- if ('url' !== keyName) continue;
352
- const valueNode = propertyNode.value;
353
- if (isStringLiteral(valueNode)) {
354
- const resolved = resolveLiteralToOutput(valueNode.value, {
295
+ return false;
296
+ }
297
+ function handleTabsAndWindows(node, source, rewriteValue, manifestPath) {
298
+ if ('CallExpression' !== node.type) return false;
299
+ const memberChain = memberChainFromCallee(node.callee);
300
+ const apiRoot = memberChain[0];
301
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
302
+ const method = memberChain.join('.');
303
+ if (method.endsWith('tabs.create') || method.endsWith('windows.create')) {
304
+ const firstArgument = node.arguments?.[0]?.expression;
305
+ if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
306
+ if ('KeyValueProperty' !== propertyNode.type) continue;
307
+ const keyName = getPropName(propertyNode);
308
+ if ('url' !== keyName) continue;
309
+ const valueNode = propertyNode.value;
310
+ if (isStringLiteral(valueNode)) {
311
+ const resolved = resolveLiteralToOutput(valueNode.value, {
312
+ manifestPath
313
+ });
314
+ rewriteValue(valueNode, resolved, valueNode.value);
315
+ } else if (valueNode?.type === 'ArrayExpression') for (const arrayElement of valueNode.elements || []){
316
+ const literalNode = arrayElement?.expression;
317
+ if (isStringLiteral(literalNode)) {
318
+ const resolved = resolveLiteralToOutput(literalNode.value, {
355
319
  manifestPath
356
320
  });
357
- rewriteValue(valueNode, resolved, valueNode.value);
358
- } else if (valueNode?.type === 'ArrayExpression') for (const arrayElement of valueNode.elements || []){
359
- const literalNode = arrayElement?.expression;
360
- if (isStringLiteral(literalNode)) {
361
- const resolved = resolveLiteralToOutput(literalNode.value, {
362
- manifestPath
363
- });
364
- rewriteValue(literalNode, resolved, literalNode.value);
365
- } else if (isStaticTemplate(literalNode)) {
366
- const raw = source.slice(literalNode.span.start + 1, literalNode.span.end - 1);
367
- const resolved = resolveLiteralToOutput(raw, {
368
- manifestPath
369
- });
370
- rewriteValue(literalNode, resolved, raw);
371
- } else {
372
- const raw = evalStaticString(literalNode);
373
- if ('string' == typeof raw) {
374
- const resolved = resolveLiteralToOutput(raw, {
375
- manifestPath
376
- });
377
- const originalExpr = source.slice(literalNode.span.start, literalNode.span.end);
378
- rewriteValue(literalNode, resolved, originalExpr);
379
- }
380
- }
381
- }
382
- else if (isStaticTemplate(valueNode)) {
383
- const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
321
+ rewriteValue(literalNode, resolved, literalNode.value);
322
+ } else if (isStaticTemplate(literalNode)) {
323
+ const raw = source.slice(literalNode.span.start + 1, literalNode.span.end - 1);
384
324
  const resolved = resolveLiteralToOutput(raw, {
385
325
  manifestPath
386
326
  });
387
- rewriteValue(valueNode, resolved, raw);
327
+ rewriteValue(literalNode, resolved, raw);
388
328
  } else {
389
- const raw = evalStaticString(valueNode);
329
+ const raw = evalStaticString(literalNode);
390
330
  if ('string' == typeof raw) {
391
331
  const resolved = resolveLiteralToOutput(raw, {
392
332
  manifestPath
393
333
  });
394
- const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
395
- rewriteValue(valueNode, resolved, originalExpr);
334
+ const originalExpr = source.slice(literalNode.span.start, literalNode.span.end);
335
+ rewriteValue(literalNode, resolved, originalExpr);
396
336
  }
397
337
  }
398
338
  }
399
- return true;
400
- }
401
- if (method.endsWith('tabs.update')) {
402
- const optionsArgument = node.arguments?.[1]?.expression || node.arguments?.[0]?.expression;
403
- if (optionsArgument?.type === 'ObjectExpression') for (const propertyNode of optionsArgument.properties || []){
404
- if ('KeyValueProperty' !== propertyNode.type) continue;
405
- const keyName = getPropName(propertyNode);
406
- if ('url' !== keyName) continue;
407
- const valueNode = propertyNode.value;
408
- if (isStringLiteral(valueNode)) {
409
- const resolved = resolveLiteralToOutput(valueNode.value, {
339
+ else if (isStaticTemplate(valueNode)) {
340
+ const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
341
+ const resolved = resolveLiteralToOutput(raw, {
342
+ manifestPath
343
+ });
344
+ rewriteValue(valueNode, resolved, raw);
345
+ } else {
346
+ const raw = evalStaticString(valueNode);
347
+ if ('string' == typeof raw) {
348
+ const resolved = resolveLiteralToOutput(raw, {
410
349
  manifestPath
411
350
  });
412
- rewriteValue(valueNode, resolved, valueNode.value);
413
- } else if (isStaticTemplate(valueNode)) {
414
- const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
351
+ const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
352
+ rewriteValue(valueNode, resolved, originalExpr);
353
+ }
354
+ }
355
+ }
356
+ return true;
357
+ }
358
+ if (method.endsWith('tabs.update')) {
359
+ const optionsArgument = node.arguments?.[1]?.expression || node.arguments?.[0]?.expression;
360
+ if (optionsArgument?.type === 'ObjectExpression') for (const propertyNode of optionsArgument.properties || []){
361
+ if ('KeyValueProperty' !== propertyNode.type) continue;
362
+ const keyName = getPropName(propertyNode);
363
+ if ('url' !== keyName) continue;
364
+ const valueNode = propertyNode.value;
365
+ if (isStringLiteral(valueNode)) {
366
+ const resolved = resolveLiteralToOutput(valueNode.value, {
367
+ manifestPath
368
+ });
369
+ rewriteValue(valueNode, resolved, valueNode.value);
370
+ } else if (isStaticTemplate(valueNode)) {
371
+ const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
372
+ const resolved = resolveLiteralToOutput(raw, {
373
+ manifestPath
374
+ });
375
+ rewriteValue(valueNode, resolved, raw);
376
+ } else {
377
+ const raw = evalStaticString(valueNode);
378
+ if ('string' == typeof raw) {
415
379
  const resolved = resolveLiteralToOutput(raw, {
416
380
  manifestPath
417
381
  });
418
- rewriteValue(valueNode, resolved, raw);
419
- } else {
420
- const raw = evalStaticString(valueNode);
421
- if ('string' == typeof raw) {
422
- const resolved = resolveLiteralToOutput(raw, {
423
- manifestPath
424
- });
425
- const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
426
- rewriteValue(valueNode, resolved, originalExpr);
427
- }
382
+ const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
383
+ rewriteValue(valueNode, resolved, originalExpr);
428
384
  }
429
385
  }
430
- return true;
431
386
  }
432
- return false;
387
+ return true;
433
388
  }
434
- function handleScripting(node, source, rewriteValue, manifestPath) {
435
- if ('CallExpression' !== node.type) return false;
436
- const memberChain = memberChainFromCallee(node.callee);
437
- const apiRoot = memberChain[0];
438
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
439
- const method = memberChain.join('.');
440
- if (method.endsWith("scripting.registerContentScripts")) {
441
- for (const argumentNode of node.arguments || []){
442
- const arrayExpressionNode = argumentNode?.expression;
443
- if (arrayExpressionNode && 'ArrayExpression' === arrayExpressionNode.type) for (const arrayElement of arrayExpressionNode.elements || []){
444
- const objectExpressionNode = arrayElement?.expression;
445
- if (objectExpressionNode && 'ObjectExpression' === objectExpressionNode.type) for (const propertyNode of objectExpressionNode.properties || []){
446
- if ('KeyValueProperty' !== propertyNode.type) continue;
447
- const keyName = getPropName(propertyNode);
448
- if ('js' !== keyName && 'css' !== keyName) continue;
449
- const valueNode = propertyNode.value;
450
- if ('ArrayExpression' === valueNode.type) for (const innerItem of valueNode.elements || []){
451
- const literalNode = innerItem?.expression;
452
- if (isStringLiteral(literalNode)) {
453
- const resolved = resolveLiteralToOutput(literalNode.value, {
454
- manifestPath
455
- });
456
- rewriteValue(literalNode, resolved, literalNode.value);
457
- } else if (isStaticTemplate(literalNode)) {
458
- const raw = source.slice(literalNode.span.start + 1, literalNode.span.end - 1);
459
- const resolved = resolveLiteralToOutput(raw, {
460
- manifestPath
461
- });
462
- rewriteValue(literalNode, resolved, raw);
463
- } else {
464
- const raw = evalStaticString(literalNode);
465
- if ('string' == typeof raw) {
466
- const resolved = resolveLiteralToOutput(raw, {
467
- manifestPath
468
- });
469
- const originalExpr = source.slice(literalNode.span.start, literalNode.span.end);
470
- rewriteValue(literalNode, resolved, originalExpr);
471
- }
472
- }
473
- }
474
- else if (isStringLiteral(valueNode)) {
475
- const resolved = resolveLiteralToOutput(valueNode.value, {
389
+ return false;
390
+ }
391
+ function handleScripting(node, source, rewriteValue, manifestPath) {
392
+ if ('CallExpression' !== node.type) return false;
393
+ const memberChain = memberChainFromCallee(node.callee);
394
+ const apiRoot = memberChain[0];
395
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
396
+ const method = memberChain.join('.');
397
+ if (method.endsWith("scripting.registerContentScripts")) {
398
+ for (const argumentNode of node.arguments || []){
399
+ const arrayExpressionNode = argumentNode?.expression;
400
+ if (arrayExpressionNode && 'ArrayExpression' === arrayExpressionNode.type) for (const arrayElement of arrayExpressionNode.elements || []){
401
+ const objectExpressionNode = arrayElement?.expression;
402
+ if (objectExpressionNode && 'ObjectExpression' === objectExpressionNode.type) for (const propertyNode of objectExpressionNode.properties || []){
403
+ if ('KeyValueProperty' !== propertyNode.type) continue;
404
+ const keyName = getPropName(propertyNode);
405
+ if ('js' !== keyName && 'css' !== keyName) continue;
406
+ const valueNode = propertyNode.value;
407
+ if ('ArrayExpression' === valueNode.type) for (const innerItem of valueNode.elements || []){
408
+ const literalNode = innerItem?.expression;
409
+ if (isStringLiteral(literalNode)) {
410
+ const resolved = resolveLiteralToOutput(literalNode.value, {
476
411
  manifestPath
477
412
  });
478
- rewriteValue(valueNode, resolved, valueNode.value);
479
- } else if (isStaticTemplate(valueNode)) {
480
- const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
413
+ rewriteValue(literalNode, resolved, literalNode.value);
414
+ } else if (isStaticTemplate(literalNode)) {
415
+ const raw = source.slice(literalNode.span.start + 1, literalNode.span.end - 1);
481
416
  const resolved = resolveLiteralToOutput(raw, {
482
417
  manifestPath
483
418
  });
484
- rewriteValue(valueNode, resolved, raw);
419
+ rewriteValue(literalNode, resolved, raw);
485
420
  } else {
486
- const raw = evalStaticString(valueNode);
421
+ const raw = evalStaticString(literalNode);
487
422
  if ('string' == typeof raw) {
488
423
  const resolved = resolveLiteralToOutput(raw, {
489
424
  manifestPath
490
425
  });
491
- const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
492
- rewriteValue(valueNode, resolved, originalExpr);
426
+ const originalExpr = source.slice(literalNode.span.start, literalNode.span.end);
427
+ rewriteValue(literalNode, resolved, originalExpr);
493
428
  }
494
429
  }
495
430
  }
496
- }
497
- }
498
- return true;
499
- }
500
- if (method.endsWith("scripting.executeScript") || method.endsWith("scripting.insertCSS")) {
501
- const firstArgument = node.arguments?.[0]?.expression;
502
- if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
503
- if ('KeyValueProperty' !== propertyNode.type) continue;
504
- const keyName = getPropName(propertyNode);
505
- if ('files' !== keyName) continue;
506
- const valueNode = propertyNode.value;
507
- if (valueNode?.type === 'ArrayExpression') for (const arrayElement of valueNode.elements || []){
508
- const literalNode = arrayElement?.expression;
509
- if (isStringLiteral(literalNode)) {
510
- const resolved = resolveLiteralToOutput(literalNode.value, {
431
+ else if (isStringLiteral(valueNode)) {
432
+ const resolved = resolveLiteralToOutput(valueNode.value, {
511
433
  manifestPath
512
434
  });
513
- rewriteValue(literalNode, resolved, literalNode.value);
514
- } else if (isStaticTemplate(literalNode)) {
515
- const raw = source.slice(literalNode.span.start + 1, literalNode.span.end - 1);
435
+ rewriteValue(valueNode, resolved, valueNode.value);
436
+ } else if (isStaticTemplate(valueNode)) {
437
+ const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
516
438
  const resolved = resolveLiteralToOutput(raw, {
517
439
  manifestPath
518
440
  });
519
- rewriteValue(literalNode, resolved, raw);
441
+ rewriteValue(valueNode, resolved, raw);
520
442
  } else {
521
- const raw = evalStaticString(literalNode);
443
+ const raw = evalStaticString(valueNode);
522
444
  if ('string' == typeof raw) {
523
445
  const resolved = resolveLiteralToOutput(raw, {
524
446
  manifestPath
525
447
  });
526
- const originalExpr = source.slice(literalNode.span.start, literalNode.span.end);
527
- rewriteValue(literalNode, resolved, originalExpr);
448
+ const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
449
+ rewriteValue(valueNode, resolved, originalExpr);
528
450
  }
529
451
  }
530
452
  }
531
453
  }
532
- return true;
533
454
  }
534
- return false;
455
+ return true;
535
456
  }
536
- function handleMv2Tabs(node, source, rewriteValue, manifestPath) {
537
- if ('CallExpression' !== node.type) return false;
538
- const memberChain = memberChainFromCallee(node.callee);
539
- const apiRoot = memberChain[0];
540
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
541
- const method = memberChain.join('.');
542
- if (method.endsWith('tabs.executeScript') || method.endsWith('tabs.insertCSS')) {
543
- const firstArgument = node.arguments?.[0]?.expression;
544
- if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
545
- if ('KeyValueProperty' !== propertyNode.type) continue;
546
- const keyName = getPropName(propertyNode);
547
- if ('file' !== keyName) continue;
548
- const valueNode = propertyNode.value;
549
- if (isStringLiteral(valueNode)) {
550
- const resolved = resolveLiteralToOutput(valueNode.value, {
457
+ if (method.endsWith("scripting.executeScript") || method.endsWith("scripting.insertCSS")) {
458
+ const firstArgument = node.arguments?.[0]?.expression;
459
+ if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
460
+ if ('KeyValueProperty' !== propertyNode.type) continue;
461
+ const keyName = getPropName(propertyNode);
462
+ if ('files' !== keyName) continue;
463
+ const valueNode = propertyNode.value;
464
+ if (valueNode?.type === 'ArrayExpression') for (const arrayElement of valueNode.elements || []){
465
+ const literalNode = arrayElement?.expression;
466
+ if (isStringLiteral(literalNode)) {
467
+ const resolved = resolveLiteralToOutput(literalNode.value, {
551
468
  manifestPath
552
469
  });
553
- rewriteValue(valueNode, resolved, valueNode.value);
554
- } else if (isStaticTemplate(valueNode)) {
555
- const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
470
+ rewriteValue(literalNode, resolved, literalNode.value);
471
+ } else if (isStaticTemplate(literalNode)) {
472
+ const raw = source.slice(literalNode.span.start + 1, literalNode.span.end - 1);
556
473
  const resolved = resolveLiteralToOutput(raw, {
557
474
  manifestPath
558
475
  });
559
- rewriteValue(valueNode, resolved, raw);
476
+ rewriteValue(literalNode, resolved, raw);
560
477
  } else {
561
- const raw = evalStaticString(valueNode);
478
+ const raw = evalStaticString(literalNode);
562
479
  if ('string' == typeof raw) {
563
480
  const resolved = resolveLiteralToOutput(raw, {
564
481
  manifestPath
565
482
  });
566
- const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
567
- rewriteValue(valueNode, resolved, originalExpr);
483
+ const originalExpr = source.slice(literalNode.span.start, literalNode.span.end);
484
+ rewriteValue(literalNode, resolved, originalExpr);
568
485
  }
569
486
  }
570
487
  }
571
- return true;
572
488
  }
573
- return false;
489
+ return true;
574
490
  }
575
- function handlePanels(node, source, rewriteValue, manifestPath) {
576
- if ('CallExpression' !== node.type) return false;
577
- const memberChain = memberChainFromCallee(node.callee);
578
- const apiRoot = memberChain[0];
579
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
580
- const method = memberChain.join('.');
581
- if (method.endsWith('sidePanel.setOptions') || method.endsWith('sidebarAction.setPanel')) {
582
- const firstArgument = node.arguments?.[0]?.expression;
583
- if (method.endsWith('sidebarAction.setPanel')) {
584
- const arg = firstArgument;
585
- if (isStringLiteral(arg)) {
586
- const resolved = resolveLiteralToOutput(arg.value, {
491
+ return false;
492
+ }
493
+ function handleMv2Tabs(node, source, rewriteValue, manifestPath) {
494
+ if ('CallExpression' !== node.type) return false;
495
+ const memberChain = memberChainFromCallee(node.callee);
496
+ const apiRoot = memberChain[0];
497
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
498
+ const method = memberChain.join('.');
499
+ if (method.endsWith('tabs.executeScript') || method.endsWith('tabs.insertCSS')) {
500
+ const firstArgument = node.arguments?.[0]?.expression;
501
+ if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
502
+ if ('KeyValueProperty' !== propertyNode.type) continue;
503
+ const keyName = getPropName(propertyNode);
504
+ if ('file' !== keyName) continue;
505
+ const valueNode = propertyNode.value;
506
+ if (isStringLiteral(valueNode)) {
507
+ const resolved = resolveLiteralToOutput(valueNode.value, {
508
+ manifestPath
509
+ });
510
+ rewriteValue(valueNode, resolved, valueNode.value);
511
+ } else if (isStaticTemplate(valueNode)) {
512
+ const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
513
+ const resolved = resolveLiteralToOutput(raw, {
514
+ manifestPath
515
+ });
516
+ rewriteValue(valueNode, resolved, raw);
517
+ } else {
518
+ const raw = evalStaticString(valueNode);
519
+ if ('string' == typeof raw) {
520
+ const resolved = resolveLiteralToOutput(raw, {
587
521
  manifestPath
588
522
  });
589
- rewriteValue(arg, resolved, arg.value);
590
- return true;
523
+ const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
524
+ rewriteValue(valueNode, resolved, originalExpr);
591
525
  }
592
- if (isStaticTemplate(arg)) {
593
- const raw = source.slice(arg.span.start + 1, arg.span.end - 1);
526
+ }
527
+ }
528
+ return true;
529
+ }
530
+ return false;
531
+ }
532
+ function handlePanels(node, source, rewriteValue, manifestPath) {
533
+ if ('CallExpression' !== node.type) return false;
534
+ const memberChain = memberChainFromCallee(node.callee);
535
+ const apiRoot = memberChain[0];
536
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
537
+ const method = memberChain.join('.');
538
+ if (method.endsWith('sidePanel.setOptions') || method.endsWith('sidebarAction.setPanel')) {
539
+ const firstArgument = node.arguments?.[0]?.expression;
540
+ if (method.endsWith('sidebarAction.setPanel')) {
541
+ const arg = firstArgument;
542
+ if (isStringLiteral(arg)) {
543
+ const resolved = resolveLiteralToOutput(arg.value, {
544
+ manifestPath
545
+ });
546
+ rewriteValue(arg, resolved, arg.value);
547
+ return true;
548
+ }
549
+ if (isStaticTemplate(arg)) {
550
+ const raw = source.slice(arg.span.start + 1, arg.span.end - 1);
551
+ const resolved = resolveLiteralToOutput(raw, {
552
+ manifestPath
553
+ });
554
+ rewriteValue(arg, resolved, raw);
555
+ return true;
556
+ }
557
+ {
558
+ const raw = evalStaticString(arg);
559
+ if ('string' == typeof raw) {
594
560
  const resolved = resolveLiteralToOutput(raw, {
595
561
  manifestPath
596
562
  });
597
- rewriteValue(arg, resolved, raw);
563
+ const originalExpr = source.slice(arg.span.start, arg.span.end);
564
+ rewriteValue(arg, resolved, originalExpr);
598
565
  return true;
599
566
  }
600
- {
601
- const raw = evalStaticString(arg);
567
+ }
568
+ }
569
+ if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
570
+ if ('KeyValueProperty' !== propertyNode.type) continue;
571
+ const keyName = getPropName(propertyNode);
572
+ if ('path' === keyName || 'panel' === keyName || 'page' === keyName) {
573
+ const valueNode = propertyNode.value;
574
+ if (isStringLiteral(valueNode)) {
575
+ const resolved = resolveLiteralToOutput(valueNode.value, {
576
+ manifestPath
577
+ });
578
+ rewriteValue(valueNode, resolved, valueNode.value);
579
+ } else if (isStaticTemplate(valueNode)) {
580
+ const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
581
+ const resolved = resolveLiteralToOutput(raw, {
582
+ manifestPath
583
+ });
584
+ rewriteValue(valueNode, resolved, raw);
585
+ } else {
586
+ const raw = evalStaticString(valueNode);
602
587
  if ('string' == typeof raw) {
603
588
  const resolved = resolveLiteralToOutput(raw, {
604
589
  manifestPath
605
590
  });
606
- const originalExpr = source.slice(arg.span.start, arg.span.end);
607
- rewriteValue(arg, resolved, originalExpr);
608
- return true;
591
+ const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
592
+ rewriteValue(valueNode, resolved, originalExpr);
609
593
  }
610
594
  }
611
595
  }
612
- if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
596
+ }
597
+ return true;
598
+ }
599
+ return false;
600
+ }
601
+ function handleNotifications(node, source, rewriteValue, manifestPath) {
602
+ if ('CallExpression' !== node.type) return false;
603
+ const memberChain = memberChainFromCallee(node.callee);
604
+ const apiRoot = memberChain[0];
605
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
606
+ const method = memberChain.join('.');
607
+ if (method.endsWith('notifications.create') || method.endsWith('notifications.update')) {
608
+ const optionsArgument = node.arguments?.[1]?.expression || node.arguments?.[0]?.expression;
609
+ if (optionsArgument?.type === 'ObjectExpression') {
610
+ let touched = false;
611
+ for (const propertyNode of optionsArgument.properties || []){
613
612
  if ('KeyValueProperty' !== propertyNode.type) continue;
614
613
  const keyName = getPropName(propertyNode);
615
- if ('path' === keyName || 'panel' === keyName || 'page' === keyName) {
614
+ if ('iconUrl' === keyName || 'imageUrl' === keyName) {
616
615
  const valueNode = propertyNode.value;
617
616
  if (isStringLiteral(valueNode)) {
618
617
  const resolved = resolveLiteralToOutput(valueNode.value, {
619
618
  manifestPath
620
619
  });
621
620
  rewriteValue(valueNode, resolved, valueNode.value);
621
+ touched = true;
622
622
  } else if (isStaticTemplate(valueNode)) {
623
623
  const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
624
624
  const resolved = resolveLiteralToOutput(raw, {
625
625
  manifestPath
626
626
  });
627
627
  rewriteValue(valueNode, resolved, raw);
628
+ touched = true;
628
629
  } else {
629
630
  const raw = evalStaticString(valueNode);
630
631
  if ('string' == typeof raw) {
@@ -633,291 +634,268 @@ var __webpack_exports__ = {};
633
634
  });
634
635
  const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
635
636
  rewriteValue(valueNode, resolved, originalExpr);
637
+ touched = true;
636
638
  }
637
639
  }
638
640
  }
639
641
  }
640
- return true;
642
+ if (touched) return true;
641
643
  }
642
- return false;
643
644
  }
644
- function handleNotifications(node, source, rewriteValue, manifestPath) {
645
- if ('CallExpression' !== node.type) return false;
646
- const memberChain = memberChainFromCallee(node.callee);
647
- const apiRoot = memberChain[0];
648
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
649
- const method = memberChain.join('.');
650
- if (method.endsWith('notifications.create') || method.endsWith('notifications.update')) {
651
- const optionsArgument = node.arguments?.[1]?.expression || node.arguments?.[0]?.expression;
652
- if (optionsArgument?.type === 'ObjectExpression') {
653
- let touched = false;
654
- for (const propertyNode of optionsArgument.properties || []){
655
- if ('KeyValueProperty' !== propertyNode.type) continue;
656
- const keyName = getPropName(propertyNode);
657
- if ('iconUrl' === keyName || 'imageUrl' === keyName) {
658
- const valueNode = propertyNode.value;
659
- if (isStringLiteral(valueNode)) {
660
- const resolved = resolveLiteralToOutput(valueNode.value, {
661
- manifestPath
662
- });
663
- rewriteValue(valueNode, resolved, valueNode.value);
664
- touched = true;
665
- } else if (isStaticTemplate(valueNode)) {
666
- const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
667
- const resolved = resolveLiteralToOutput(raw, {
668
- manifestPath
669
- });
670
- rewriteValue(valueNode, resolved, raw);
671
- touched = true;
672
- } else {
673
- const raw = evalStaticString(valueNode);
674
- if ('string' == typeof raw) {
675
- const resolved = resolveLiteralToOutput(raw, {
676
- manifestPath
677
- });
678
- const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
679
- rewriteValue(valueNode, resolved, originalExpr);
680
- touched = true;
681
- }
682
- }
683
- }
684
- }
685
- if (touched) return true;
686
- }
687
- }
688
- return false;
689
- }
690
- function handleMenus(node, source, rewriteValue, manifestPath) {
691
- if ('CallExpression' !== node.type) return false;
692
- const memberChain = memberChainFromCallee(node.callee);
693
- const apiRoot = memberChain[0];
694
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
695
- const method = memberChain.join('.');
696
- if (method.endsWith('contextMenus.create') || method.endsWith('contextMenus.update') || method.endsWith('menus.create') || method.endsWith('menus.update')) {
697
- const firstArgument = node.arguments?.[0]?.expression;
698
- if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
699
- if ('KeyValueProperty' !== propertyNode.type) continue;
700
- const keyNode = propertyNode.key;
701
- const keyName = keyNode?.type === 'Identifier' ? keyNode.value : keyNode?.value;
702
- if ('icons' !== keyName) continue;
703
- const valueNode = propertyNode.value;
704
- if (valueNode?.type === 'ObjectExpression') for (const innerProperty of valueNode.properties || []){
705
- if ('KeyValueProperty' !== innerProperty.type) continue;
706
- const innerValue = innerProperty.value;
707
- if (isStringLiteral(innerValue)) {
708
- const resolved = resolveLiteralToOutput(innerValue.value, {
709
- manifestPath
710
- });
711
- rewriteValue(innerValue, resolved, innerValue.value);
712
- } else if (isStaticTemplate(innerValue)) {
713
- const raw = source.slice(innerValue.span.start + 1, innerValue.span.end - 1);
645
+ return false;
646
+ }
647
+ function handleMenus(node, source, rewriteValue, manifestPath) {
648
+ if ('CallExpression' !== node.type) return false;
649
+ const memberChain = memberChainFromCallee(node.callee);
650
+ const apiRoot = memberChain[0];
651
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
652
+ const method = memberChain.join('.');
653
+ if (method.endsWith('contextMenus.create') || method.endsWith('contextMenus.update') || method.endsWith('menus.create') || method.endsWith('menus.update')) {
654
+ const firstArgument = node.arguments?.[0]?.expression;
655
+ if (firstArgument?.type === 'ObjectExpression') for (const propertyNode of firstArgument.properties || []){
656
+ if ('KeyValueProperty' !== propertyNode.type) continue;
657
+ const keyNode = propertyNode.key;
658
+ const keyName = keyNode?.type === 'Identifier' ? keyNode.value : keyNode?.value;
659
+ if ('icons' !== keyName) continue;
660
+ const valueNode = propertyNode.value;
661
+ if (valueNode?.type === 'ObjectExpression') for (const innerProperty of valueNode.properties || []){
662
+ if ('KeyValueProperty' !== innerProperty.type) continue;
663
+ const innerValue = innerProperty.value;
664
+ if (isStringLiteral(innerValue)) {
665
+ const resolved = resolveLiteralToOutput(innerValue.value, {
666
+ manifestPath
667
+ });
668
+ rewriteValue(innerValue, resolved, innerValue.value);
669
+ } else if (isStaticTemplate(innerValue)) {
670
+ const raw = source.slice(innerValue.span.start + 1, innerValue.span.end - 1);
671
+ const resolved = resolveLiteralToOutput(raw, {
672
+ manifestPath
673
+ });
674
+ rewriteValue(innerValue, resolved, raw);
675
+ } else {
676
+ const raw = evalStaticString(innerValue);
677
+ if ('string' == typeof raw) {
714
678
  const resolved = resolveLiteralToOutput(raw, {
715
679
  manifestPath
716
680
  });
717
- rewriteValue(innerValue, resolved, raw);
718
- } else {
719
- const raw = evalStaticString(innerValue);
720
- if ('string' == typeof raw) {
721
- const resolved = resolveLiteralToOutput(raw, {
722
- manifestPath
723
- });
724
- const originalExpr = source.slice(innerValue.span.start, innerValue.span.end);
725
- rewriteValue(innerValue, resolved, originalExpr);
726
- }
681
+ const originalExpr = source.slice(innerValue.span.start, innerValue.span.end);
682
+ rewriteValue(innerValue, resolved, originalExpr);
727
683
  }
728
684
  }
729
685
  }
730
- return true;
731
686
  }
732
- return false;
687
+ return true;
733
688
  }
734
- function handleDeclarativeContent(node, source, rewriteValue, manifestPath) {
735
- if ('NewExpression' !== node.type) return false;
736
- const memberChain = memberChainFromCallee(node.callee);
737
- const apiRoot = memberChain[0];
738
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
739
- const method = memberChain.join('.');
740
- if (method.endsWith('declarativeContent.SetIcon')) {
741
- const arg0 = node.arguments?.[0];
742
- const optionsArgument = arg0 && arg0.expression || arg0;
743
- if (optionsArgument?.type === 'ObjectExpression') for (const propertyNode of optionsArgument.properties || []){
744
- if ('KeyValueProperty' !== propertyNode.type) continue;
745
- const keyNode = propertyNode.key;
746
- const keyName = keyNode?.type === 'Identifier' ? keyNode.value : keyNode?.value;
747
- if ('path' !== keyName) continue;
748
- const valueNode = propertyNode.value;
749
- if (isStringLiteral(valueNode)) {
750
- const resolved = resolveLiteralToOutput(valueNode.value, {
689
+ return false;
690
+ }
691
+ function handleDeclarativeContent(node, source, rewriteValue, manifestPath) {
692
+ if ('NewExpression' !== node.type) return false;
693
+ const memberChain = memberChainFromCallee(node.callee);
694
+ const apiRoot = memberChain[0];
695
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
696
+ const method = memberChain.join('.');
697
+ if (method.endsWith('declarativeContent.SetIcon')) {
698
+ const arg0 = node.arguments?.[0];
699
+ const optionsArgument = arg0 && arg0.expression || arg0;
700
+ if (optionsArgument?.type === 'ObjectExpression') for (const propertyNode of optionsArgument.properties || []){
701
+ if ('KeyValueProperty' !== propertyNode.type) continue;
702
+ const keyNode = propertyNode.key;
703
+ const keyName = keyNode?.type === 'Identifier' ? keyNode.value : keyNode?.value;
704
+ if ('path' !== keyName) continue;
705
+ const valueNode = propertyNode.value;
706
+ if (isStringLiteral(valueNode)) {
707
+ const resolved = resolveLiteralToOutput(valueNode.value, {
708
+ manifestPath
709
+ });
710
+ rewriteValue(valueNode, resolved, valueNode.value);
711
+ } else if (valueNode?.type === 'ObjectExpression') for (const innerProperty of valueNode.properties || []){
712
+ if ('KeyValueProperty' !== innerProperty.type) continue;
713
+ const innerValue = innerProperty.value;
714
+ if (isStringLiteral(innerValue)) {
715
+ const resolved = resolveLiteralToOutput(innerValue.value, {
751
716
  manifestPath
752
717
  });
753
- rewriteValue(valueNode, resolved, valueNode.value);
754
- } else if (valueNode?.type === 'ObjectExpression') for (const innerProperty of valueNode.properties || []){
755
- if ('KeyValueProperty' !== innerProperty.type) continue;
756
- const innerValue = innerProperty.value;
757
- if (isStringLiteral(innerValue)) {
758
- const resolved = resolveLiteralToOutput(innerValue.value, {
759
- manifestPath
760
- });
761
- rewriteValue(innerValue, resolved, innerValue.value);
762
- } else if (isStaticTemplate(innerValue)) {
763
- const raw = source.slice(innerValue.span.start + 1, innerValue.span.end - 1);
764
- const resolved = resolveLiteralToOutput(raw, {
765
- manifestPath
766
- });
767
- rewriteValue(innerValue, resolved, raw);
768
- } else {
769
- const raw = evalStaticString(innerValue);
770
- if ('string' == typeof raw) {
771
- const resolved = resolveLiteralToOutput(raw, {
772
- manifestPath
773
- });
774
- const originalExpr = source.slice(innerValue.span.start, innerValue.span.end);
775
- rewriteValue(innerValue, resolved, originalExpr);
776
- }
777
- }
778
- }
779
- else if (isStaticTemplate(valueNode)) {
780
- const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
718
+ rewriteValue(innerValue, resolved, innerValue.value);
719
+ } else if (isStaticTemplate(innerValue)) {
720
+ const raw = source.slice(innerValue.span.start + 1, innerValue.span.end - 1);
781
721
  const resolved = resolveLiteralToOutput(raw, {
782
722
  manifestPath
783
723
  });
784
- rewriteValue(valueNode, resolved, raw);
724
+ rewriteValue(innerValue, resolved, raw);
785
725
  } else {
786
- const raw = evalStaticString(valueNode);
726
+ const raw = evalStaticString(innerValue);
787
727
  if ('string' == typeof raw) {
788
728
  const resolved = resolveLiteralToOutput(raw, {
789
729
  manifestPath
790
730
  });
791
- const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
792
- rewriteValue(valueNode, resolved, originalExpr);
731
+ const originalExpr = source.slice(innerValue.span.start, innerValue.span.end);
732
+ rewriteValue(innerValue, resolved, originalExpr);
793
733
  }
794
734
  }
795
735
  }
796
- return true;
797
- }
798
- return false;
799
- }
800
- const ALLOWED_KEYS = new Set([
801
- 'url',
802
- 'file',
803
- 'files',
804
- 'path',
805
- 'popup',
806
- 'panel',
807
- 'page',
808
- 'iconUrl',
809
- 'imageUrl',
810
- 'default_icon',
811
- 'default_popup',
812
- 'default_panel'
813
- ]);
814
- function processValue(valueNode, source, rewriteValue, manifestPath) {
815
- if (!valueNode) return;
816
- if (isStringLiteral(valueNode)) {
817
- const out = resolveLiteralToOutput(valueNode.value, {
818
- manifestPath
819
- });
820
- rewriteValue(valueNode, out, valueNode.value);
821
- return;
822
- }
823
- if (isStaticTemplate(valueNode)) {
824
- const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
825
- const out = resolveLiteralToOutput(raw, {
826
- manifestPath
827
- });
828
- rewriteValue(valueNode, out, raw);
829
- return;
830
- }
831
- const raw = evalStaticString(valueNode);
832
- if ('string' == typeof raw) {
833
- const out = resolveLiteralToOutput(raw, {
834
- manifestPath
835
- });
836
- const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
837
- rewriteValue(valueNode, out, originalExpr);
838
- return;
839
- }
840
- }
841
- function walkCandidate(containerNode, onCandidateValue) {
842
- if (!containerNode) return;
843
- if ('ArrayExpression' === containerNode.type) {
844
- for (const elementNode of containerNode.elements || [])onCandidateValue(elementNode?.expression);
845
- return;
846
- }
847
- if ('ObjectExpression' === containerNode.type) for (const propertyNode of containerNode.properties || []){
848
- if ('KeyValueProperty' !== propertyNode.type) continue;
849
- const key = getPropName(propertyNode);
850
- if (key) {
851
- if (ALLOWED_KEYS.has(key)) onCandidateValue(propertyNode.value);
852
- if (propertyNode.value?.type === 'ArrayExpression' || propertyNode.value?.type === 'ObjectExpression') if (('default_icon' === key || 'path' === key) && propertyNode.value?.type === 'ObjectExpression') {
853
- for (const sizeProp of propertyNode.value.properties || [])if ('KeyValueProperty' === sizeProp.type) onCandidateValue(sizeProp.value);
854
- } else walkCandidate(propertyNode.value, onCandidateValue);
855
- }
856
- }
857
- }
858
- function handleGenericApiPaths(node, source, rewriteValue, manifestPath) {
859
- if ('CallExpression' !== node.type) return false;
860
- const memberChain = memberChainFromCallee(node.callee);
861
- const apiRoot = memberChain[0];
862
- if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
863
- let touched = false;
864
- for (const argumentNode of node.arguments || []){
865
- const expressionNode = argumentNode?.expression;
866
- if (expressionNode) {
867
- if ('ObjectExpression' === expressionNode.type || 'ArrayExpression' === expressionNode.type) walkCandidate(expressionNode, (candidateValue)=>{
868
- const touchedBefore = touched;
869
- processValue(candidateValue, source, rewriteValue, manifestPath);
870
- if (!touchedBefore) touched = true;
736
+ else if (isStaticTemplate(valueNode)) {
737
+ const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
738
+ const resolved = resolveLiteralToOutput(raw, {
739
+ manifestPath
871
740
  });
741
+ rewriteValue(valueNode, resolved, raw);
742
+ } else {
743
+ const raw = evalStaticString(valueNode);
744
+ if ('string' == typeof raw) {
745
+ const resolved = resolveLiteralToOutput(raw, {
746
+ manifestPath
747
+ });
748
+ const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
749
+ rewriteValue(valueNode, resolved, originalExpr);
750
+ }
872
751
  }
873
752
  }
874
- return touched;
753
+ return true;
875
754
  }
876
- function handleCallExpression(node, source, rewriteValue, manifestPath) {
877
- if (handleRuntimeCalls(node, source, rewriteValue, manifestPath)) return;
878
- if (handleActionAndPopup(node, source, rewriteValue, manifestPath)) return;
879
- if (handleDevtools(node, source, rewriteValue, manifestPath)) return;
880
- if (handleTabsAndWindows(node, source, rewriteValue, manifestPath)) return;
881
- if (handleScripting(node, source, rewriteValue, manifestPath)) return;
882
- if (handleMv2Tabs(node, source, rewriteValue, manifestPath)) return;
883
- if (handlePanels(node, source, rewriteValue, manifestPath)) return;
884
- if (handleNotifications(node, source, rewriteValue, manifestPath)) return;
885
- if (handleMenus(node, source, rewriteValue, manifestPath)) return;
886
- if (handleDeclarativeContent(node, source, rewriteValue, manifestPath)) return;
887
- try {
888
- handleGenericApiPaths(node, source, rewriteValue, manifestPath);
889
- } catch {}
755
+ return false;
756
+ }
757
+ const ALLOWED_KEYS = new Set([
758
+ 'url',
759
+ 'file',
760
+ 'files',
761
+ 'path',
762
+ 'popup',
763
+ 'panel',
764
+ 'page',
765
+ 'iconUrl',
766
+ 'imageUrl',
767
+ 'default_icon',
768
+ 'default_popup',
769
+ 'default_panel'
770
+ ]);
771
+ function processValue(valueNode, source, rewriteValue, manifestPath) {
772
+ if (!valueNode) return;
773
+ if (isStringLiteral(valueNode)) {
774
+ const out = resolveLiteralToOutput(valueNode.value, {
775
+ manifestPath
776
+ });
777
+ rewriteValue(valueNode, out, valueNode.value);
778
+ return;
890
779
  }
891
- function isJsxLikePath(filePath) {
892
- return 'string' == typeof filePath && /\.[cm]?[jt]sx$/.test(String(filePath));
780
+ if (isStaticTemplate(valueNode)) {
781
+ const raw = source.slice(valueNode.span.start + 1, valueNode.span.end - 1);
782
+ const out = resolveLiteralToOutput(raw, {
783
+ manifestPath
784
+ });
785
+ rewriteValue(valueNode, out, raw);
786
+ return;
893
787
  }
894
- function stripNestedQuotes(value) {
895
- const match = /^(['"])(.*)\1$/.exec(value);
896
- return match ? match[2] : value;
788
+ const raw = evalStaticString(valueNode);
789
+ if ('string' == typeof raw) {
790
+ const out = resolveLiteralToOutput(raw, {
791
+ manifestPath
792
+ });
793
+ const originalExpr = source.slice(valueNode.span.start, valueNode.span.end);
794
+ rewriteValue(valueNode, out, originalExpr);
795
+ return;
897
796
  }
898
- function normalizeLiteralPayload(value) {
899
- const withForwardSlashes = value.replace(/\\/g, '/');
900
- const withCollapsed = withForwardSlashes.replace(/\/{2,}/g, '/');
901
- return stripNestedQuotes(withCollapsed);
797
+ }
798
+ function walkCandidate(containerNode, onCandidateValue) {
799
+ if (!containerNode) return;
800
+ if ('ArrayExpression' === containerNode.type) {
801
+ for (const elementNode of containerNode.elements || [])onCandidateValue(elementNode?.expression);
802
+ return;
902
803
  }
903
- function isLikelyApiContextAt(source, atIndex) {
904
- if ('number' != typeof atIndex) return false;
905
- const start = Math.max(0, atIndex - 200);
906
- const neighborhood = source.slice(start, atIndex);
907
- return /(chrome|browser)\s*\.(?:tabs|windows|scripting|action|sidePanel|sidebarAction|devtools|runtime|extension)\b/.test(neighborhood);
804
+ if ('ObjectExpression' === containerNode.type) for (const propertyNode of containerNode.properties || []){
805
+ if ('KeyValueProperty' !== propertyNode.type) continue;
806
+ const key = getPropName(propertyNode);
807
+ if (key) {
808
+ if (ALLOWED_KEYS.has(key)) onCandidateValue(propertyNode.value);
809
+ if (propertyNode.value?.type === 'ArrayExpression' || propertyNode.value?.type === 'ObjectExpression') if (('default_icon' === key || 'path' === key) && propertyNode.value?.type === 'ObjectExpression') {
810
+ for (const sizeProp of propertyNode.value.properties || [])if ('KeyValueProperty' === sizeProp.type) onCandidateValue(sizeProp.value);
811
+ } else walkCandidate(propertyNode.value, onCandidateValue);
812
+ }
908
813
  }
909
- function resolveAndNormalizeLiteral(literal, ctx) {
910
- const normalizedInput = normalizeLiteralPayload(literal);
911
- const resolved = resolveLiteralToOutput(normalizedInput, {
912
- manifestPath: ctx.manifestPath,
913
- packageJsonDir: ctx.packageJsonDir,
914
- authorFilePath: ctx.authorFilePath
915
- });
916
- return normalizeLiteralPayload(resolved ?? normalizedInput);
814
+ }
815
+ function handleGenericApiPaths(node, source, rewriteValue, manifestPath) {
816
+ if ('CallExpression' !== node.type) return false;
817
+ const memberChain = memberChainFromCallee(node.callee);
818
+ const apiRoot = memberChain[0];
819
+ if ('chrome' !== apiRoot && 'browser' !== apiRoot) return false;
820
+ let touched = false;
821
+ for (const argumentNode of node.arguments || []){
822
+ const expressionNode = argumentNode?.expression;
823
+ if (expressionNode) {
824
+ if ('ObjectExpression' === expressionNode.type || 'ArrayExpression' === expressionNode.type) walkCandidate(expressionNode, (candidateValue)=>{
825
+ const touchedBefore = touched;
826
+ processValue(candidateValue, source, rewriteValue, manifestPath);
827
+ if (!touchedBefore) touched = true;
828
+ });
829
+ }
830
+ }
831
+ return touched;
832
+ }
833
+ function handleCallExpression(node, source, rewriteValue, manifestPath) {
834
+ if (handleRuntimeCalls(node, source, rewriteValue, manifestPath)) return;
835
+ if (handleActionAndPopup(node, source, rewriteValue, manifestPath)) return;
836
+ if (handleDevtools(node, source, rewriteValue, manifestPath)) return;
837
+ if (handleTabsAndWindows(node, source, rewriteValue, manifestPath)) return;
838
+ if (handleScripting(node, source, rewriteValue, manifestPath)) return;
839
+ if (handleMv2Tabs(node, source, rewriteValue, manifestPath)) return;
840
+ if (handlePanels(node, source, rewriteValue, manifestPath)) return;
841
+ if (handleNotifications(node, source, rewriteValue, manifestPath)) return;
842
+ if (handleMenus(node, source, rewriteValue, manifestPath)) return;
843
+ if (handleDeclarativeContent(node, source, rewriteValue, manifestPath)) return;
844
+ try {
845
+ handleGenericApiPaths(node, source, rewriteValue, manifestPath);
846
+ } catch {}
847
+ }
848
+ function isJsxLikePath(filePath) {
849
+ return 'string' == typeof filePath && /\.[cm]?[jt]sx$/.test(String(filePath));
850
+ }
851
+ function stripNestedQuotes(value) {
852
+ const match = /^(['"])(.*)\1$/.exec(value);
853
+ return match ? match[2] : value;
854
+ }
855
+ function normalizeLiteralPayload(value) {
856
+ const withForwardSlashes = value.replace(/\\/g, '/');
857
+ const withCollapsed = withForwardSlashes.replace(/\/{2,}/g, '/');
858
+ return stripNestedQuotes(withCollapsed);
859
+ }
860
+ function isLikelyApiContextAt(source, atIndex) {
861
+ if ('number' != typeof atIndex) return false;
862
+ const start = Math.max(0, atIndex - 200);
863
+ const neighborhood = source.slice(start, atIndex);
864
+ return /(chrome|browser)\s*\.(?:tabs|windows|scripting|action|sidePanel|sidebarAction|devtools|runtime|extension)\b/.test(neighborhood);
865
+ }
866
+ function resolveAndNormalizeLiteral(literal, ctx) {
867
+ const normalizedInput = normalizeLiteralPayload(literal);
868
+ const resolved = resolveLiteralToOutput(normalizedInput, {
869
+ manifestPath: ctx.manifestPath,
870
+ packageJsonDir: ctx.packageJsonDir,
871
+ authorFilePath: ctx.authorFilePath
872
+ });
873
+ return normalizeLiteralPayload(resolved ?? normalizedInput);
874
+ }
875
+ function replaceRuntimeGetURL(source, input, ctx) {
876
+ const rx = /(\.(?:runtime|extension)\.getURL\()\s*(['"])(.*?)\2(\))/g;
877
+ function onMatch(full, pre, q, p, post, offset) {
878
+ try {
879
+ const resolved = resolveLiteralToOutput(normalizeLiteralPayload(p), {
880
+ manifestPath: ctx.manifestPath,
881
+ packageJsonDir: ctx.packageJsonDir,
882
+ authorFilePath: ctx.authorFilePath
883
+ });
884
+ const computed = normalizeLiteralPayload(resolved ?? p);
885
+ try {
886
+ ctx.onResolvedLiteral?.(p, resolved ?? void 0, offset);
887
+ } catch {}
888
+ return `${pre}${q}${computed}${q}${post}`;
889
+ } catch {
890
+ return full;
891
+ }
917
892
  }
918
- function replaceRuntimeGetURL(source, input, ctx) {
919
- const rx = /(\.(?:runtime|extension)\.getURL\()\s*(['"])(.*?)\2(\))/g;
920
- function onMatch(full, pre, q, p, post, offset) {
893
+ return input.replace(rx, onMatch);
894
+ }
895
+ function replaceObjectKeyLiterals(source, input, keys, ctx) {
896
+ for (const key of keys){
897
+ const rx = new RegExp(`(${key}\\s*:\\s*)(['"])(.*?)\\2`, 'g');
898
+ function onMatch(full, pre, q, p, offset) {
921
899
  try {
922
900
  const resolved = resolveLiteralToOutput(normalizeLiteralPayload(p), {
923
901
  manifestPath: ctx.manifestPath,
@@ -926,87 +904,104 @@ var __webpack_exports__ = {};
926
904
  });
927
905
  const computed = normalizeLiteralPayload(resolved ?? p);
928
906
  try {
929
- ctx.onResolvedLiteral?.(p, resolved ?? void 0, offset);
907
+ if (isLikelyApiContextAt(source, offset)) ctx.onResolvedLiteral?.(p, resolved ?? void 0, offset);
930
908
  } catch {}
931
- return `${pre}${q}${computed}${q}${post}`;
909
+ return `${pre}${q}${computed}${q}`;
932
910
  } catch {
933
911
  return full;
934
912
  }
935
913
  }
936
- return input.replace(rx, onMatch);
914
+ input = input.replace(rx, onMatch);
937
915
  }
938
- function replaceObjectKeyLiterals(source, input, keys, ctx) {
939
- for (const key of keys){
940
- const rx = new RegExp(`(${key}\\s*:\\s*)(['"])(.*?)\\2`, 'g');
941
- function onMatch(full, pre, q, p, offset) {
942
- try {
943
- const resolved = resolveLiteralToOutput(normalizeLiteralPayload(p), {
944
- manifestPath: ctx.manifestPath,
945
- packageJsonDir: ctx.packageJsonDir,
946
- authorFilePath: ctx.authorFilePath
947
- });
948
- const computed = normalizeLiteralPayload(resolved ?? p);
949
- try {
950
- if (isLikelyApiContextAt(source, offset)) ctx.onResolvedLiteral?.(p, resolved ?? void 0, offset);
951
- } catch {}
952
- return `${pre}${q}${computed}${q}`;
953
- } catch {
954
- return full;
955
- }
956
- }
957
- input = input.replace(rx, onMatch);
916
+ return input;
917
+ }
918
+ function replaceStaticTemplateForKeys(source, input, keys, ctx) {
919
+ const rx = new RegExp(`((?:${keys.join('|')})\\s*:\\s*)\`([^\\\`$]*)\``, 'g');
920
+ function onMatch(full, pre, inner, offset) {
921
+ try {
922
+ const resolved = resolveLiteralToOutput(normalizeLiteralPayload(inner), {
923
+ manifestPath: ctx.manifestPath,
924
+ packageJsonDir: ctx.packageJsonDir,
925
+ authorFilePath: ctx.authorFilePath
926
+ });
927
+ const computed = normalizeLiteralPayload(resolved ?? inner);
928
+ try {
929
+ if (isLikelyApiContextAt(source, offset)) ctx.onResolvedLiteral?.(inner, resolved ?? void 0, offset);
930
+ } catch {}
931
+ return `${pre}'${computed}'`;
932
+ } catch {
933
+ return full;
958
934
  }
959
- return input;
960
935
  }
961
- function replaceStaticTemplateForKeys(source, input, keys, ctx) {
962
- const rx = new RegExp(`((?:${keys.join('|')})\\s*:\\s*)\`([^\\\`$]*)\``, 'g');
963
- function onMatch(full, pre, inner, offset) {
936
+ return input.replace(rx, onMatch);
937
+ }
938
+ function replaceConcatForKeys(source, input, keys, ctx) {
939
+ const rx = new RegExp(`((?:${keys.join('|')})\\s*:\\s*)((?:['"][^'"]*['"]\\s*\\+\\s*)+['"][^'"]*['"])`, 'g');
940
+ function onMatch(full, pre, expr, offset) {
941
+ try {
942
+ const partRe = /(['"])([^'"]*?)\1/g;
943
+ let m;
944
+ let concatenated = '';
945
+ while(m = partRe.exec(expr))concatenated += m[2];
946
+ const resolved = resolveLiteralToOutput(normalizeLiteralPayload(concatenated), {
947
+ manifestPath: ctx.manifestPath,
948
+ packageJsonDir: ctx.packageJsonDir,
949
+ authorFilePath: ctx.authorFilePath
950
+ });
951
+ const computed = normalizeLiteralPayload(resolved ?? concatenated);
964
952
  try {
965
- const resolved = resolveLiteralToOutput(normalizeLiteralPayload(inner), {
966
- manifestPath: ctx.manifestPath,
967
- packageJsonDir: ctx.packageJsonDir,
968
- authorFilePath: ctx.authorFilePath
969
- });
970
- const computed = normalizeLiteralPayload(resolved ?? inner);
971
- try {
972
- if (isLikelyApiContextAt(source, offset)) ctx.onResolvedLiteral?.(inner, resolved ?? void 0, offset);
973
- } catch {}
974
- return `${pre}'${computed}'`;
975
- } catch {
976
- return full;
977
- }
953
+ if (isLikelyApiContextAt(source, offset)) ctx.onResolvedLiteral?.(concatenated, resolved ?? void 0, offset);
954
+ } catch {}
955
+ return `${pre}'${computed}'`;
956
+ } catch {
957
+ return full;
978
958
  }
979
- return input.replace(rx, onMatch);
980
959
  }
981
- function replaceConcatForKeys(source, input, keys, ctx) {
982
- const rx = new RegExp(`((?:${keys.join('|')})\\s*:\\s*)((?:['"][^'"]*['"]\\s*\\+\\s*)+['"][^'"]*['"])`, 'g');
983
- function onMatch(full, pre, expr, offset) {
984
- try {
985
- const partRe = /(['"])([^'"]*?)\1/g;
986
- let m;
987
- let concatenated = '';
988
- while(m = partRe.exec(expr))concatenated += m[2];
989
- const resolved = resolveLiteralToOutput(normalizeLiteralPayload(concatenated), {
990
- manifestPath: ctx.manifestPath,
991
- packageJsonDir: ctx.packageJsonDir,
992
- authorFilePath: ctx.authorFilePath
993
- });
994
- const computed = normalizeLiteralPayload(resolved ?? concatenated);
960
+ return input.replace(rx, onMatch);
961
+ }
962
+ function replaceFilesArray(source, input, ctx) {
963
+ const rx = /(files\s*:\s*\[)([^\]]*)(\])/g;
964
+ function onMatch(full, pre, inner, post, offset) {
965
+ try {
966
+ const replacedInner = inner.replace(/(['"])(.*?)(\1)/g, function(_m, q, p) {
995
967
  try {
996
- if (isLikelyApiContextAt(source, offset)) ctx.onResolvedLiteral?.(concatenated, resolved ?? void 0, offset);
997
- } catch {}
998
- return `${pre}'${computed}'`;
999
- } catch {
1000
- return full;
1001
- }
968
+ const computed = resolveAndNormalizeLiteral(p, ctx);
969
+ return `${q}${computed ?? p}${q}`;
970
+ } catch {
971
+ return `${q}${p}${q}`;
972
+ }
973
+ });
974
+ try {
975
+ if (isLikelyApiContextAt(source, offset)) {
976
+ const re = /(['"])(.*?)(\1)/g;
977
+ let match;
978
+ while(match = re.exec(inner)){
979
+ const raw = match[2];
980
+ const resolved = resolveLiteralToOutput(normalizeLiteralPayload(raw), {
981
+ manifestPath: ctx.manifestPath,
982
+ packageJsonDir: ctx.packageJsonDir,
983
+ authorFilePath: ctx.authorFilePath
984
+ });
985
+ ctx.onResolvedLiteral?.(raw, resolved ?? void 0, offset + match.index);
986
+ }
987
+ }
988
+ } catch {}
989
+ return `${pre}${replacedInner}${post}`;
990
+ } catch {
991
+ return full;
1002
992
  }
1003
- return input.replace(rx, onMatch);
1004
993
  }
1005
- function replaceFilesArray(source, input, ctx) {
1006
- const rx = /(files\s*:\s*\[)([^\]]*)(\])/g;
994
+ return input.replace(rx, onMatch);
995
+ }
996
+ function replaceJsCssArrays(source, input, ctx) {
997
+ for (const key of [
998
+ 'js',
999
+ 'css'
1000
+ ]){
1001
+ const rxArr = new RegExp(`(${key}\\s*:\\s*\\[)([^\\]]*)(\\])`, 'g');
1007
1002
  function onMatch(full, pre, inner, post, offset) {
1008
1003
  try {
1009
- const replacedInner = inner.replace(/(['"])(.*?)(\1)/g, function(_m, q, p) {
1004
+ const replacedInner = String(inner).replace(/(['"])(.*?)(\1)/g, function(_m, q, p) {
1010
1005
  try {
1011
1006
  const computed = resolveAndNormalizeLiteral(p, ctx);
1012
1007
  return `${q}${computed ?? p}${q}`;
@@ -1034,317 +1029,272 @@ var __webpack_exports__ = {};
1034
1029
  return full;
1035
1030
  }
1036
1031
  }
1037
- return input.replace(rx, onMatch);
1032
+ input = input.replace(rxArr, onMatch);
1038
1033
  }
1039
- function replaceJsCssArrays(source, input, ctx) {
1040
- for (const key of [
1041
- 'js',
1042
- 'css'
1043
- ]){
1044
- const rxArr = new RegExp(`(${key}\\s*:\\s*\\[)([^\\]]*)(\\])`, 'g');
1045
- function onMatch(full, pre, inner, post, offset) {
1046
- try {
1047
- const replacedInner = String(inner).replace(/(['"])(.*?)(\1)/g, function(_m, q, p) {
1048
- try {
1049
- const computed = resolveAndNormalizeLiteral(p, ctx);
1050
- return `${q}${computed ?? p}${q}`;
1051
- } catch {
1052
- return `${q}${p}${q}`;
1053
- }
1054
- });
1055
- try {
1056
- if (isLikelyApiContextAt(source, offset)) {
1057
- const re = /(['"])(.*?)(\1)/g;
1058
- let match;
1059
- while(match = re.exec(inner)){
1060
- const raw = match[2];
1061
- const resolved = resolveLiteralToOutput(normalizeLiteralPayload(raw), {
1062
- manifestPath: ctx.manifestPath,
1063
- packageJsonDir: ctx.packageJsonDir,
1064
- authorFilePath: ctx.authorFilePath
1065
- });
1066
- ctx.onResolvedLiteral?.(raw, resolved ?? void 0, offset + match.index);
1067
- }
1068
- }
1069
- } catch {}
1070
- return `${pre}${replacedInner}${post}`;
1071
- } catch {
1072
- return full;
1034
+ return input;
1035
+ }
1036
+ function cleanupPublicRootLiterals(input) {
1037
+ input = input.replace(/(['"])\/public\/([^'"]+?)\1/g, function(_m, q, p) {
1038
+ return `${q}${normalizeLiteralPayload(p)}${q}`;
1039
+ });
1040
+ input = input.replace(/(['"])public\/(.*?)\1/g, function(_m, q, p) {
1041
+ return `${q}${normalizeLiteralPayload(p)}${q}`;
1042
+ });
1043
+ return input;
1044
+ }
1045
+ function normalizeSpecialFolderExtensions(input) {
1046
+ input = input.replace(/(['"])((?:pages|scripts)\/[^'"]+?)\.(ts|tsx)\1/g, function(_m, q, p) {
1047
+ return `${q}${p}.js${q}`;
1048
+ });
1049
+ input = input.replace(/(['"])((?:pages|scripts)\/[^'"]+?)\.(njk|nunjucks)\1/g, function(_m, q, p) {
1050
+ return `${q}${p}.html${q}`;
1051
+ });
1052
+ input = input.replace(/(['"])((?:pages|scripts)\/[^'"]+?)\.(scss|sass|less)\1/g, function(_m, q, p) {
1053
+ return `${q}${p}.css${q}`;
1054
+ });
1055
+ return input;
1056
+ }
1057
+ function collapseAccidentalDoubleQuotes(input, keys) {
1058
+ const keyUnion = `(?:${keys.join('|')})`;
1059
+ input = input.replace(new RegExp(`(${keyUnion}\\s*:\\s*)''`, 'g'), "$1'");
1060
+ input = input.replace(new RegExp(`(${keyUnion}\\s*:\\s*)""`, 'g'), '$1"');
1061
+ input = input.replace(/:\s*''/g, ": '");
1062
+ input = input.replace(/:\s*""/g, ': "');
1063
+ input = input.replace(/:\s*''([^']+)'/g, ": '$1'");
1064
+ input = input.replace(/:\s*\"\"([^\"]+)\"/g, ': "$1"');
1065
+ input = input.replace(/''([^']*?)''/g, "'$1'");
1066
+ input = input.replace(/""([^"]*?)""/g, '"$1"');
1067
+ return input;
1068
+ }
1069
+ function textFallbackTransform(source, opts) {
1070
+ let output = String(source);
1071
+ const ctx = {
1072
+ manifestPath: opts.manifestPath,
1073
+ packageJsonDir: opts.packageJsonDir,
1074
+ authorFilePath: opts.authorFilePath,
1075
+ onResolvedLiteral: opts.onResolvedLiteral
1076
+ };
1077
+ output = replaceRuntimeGetURL(source, output, ctx);
1078
+ const supportedKeys = [
1079
+ 'url',
1080
+ 'file',
1081
+ 'path',
1082
+ 'iconUrl',
1083
+ 'imageUrl',
1084
+ 'default_icon'
1085
+ ];
1086
+ output = replaceObjectKeyLiterals(source, output, supportedKeys, ctx);
1087
+ output = replaceStaticTemplateForKeys(source, output, supportedKeys, ctx);
1088
+ output = replaceConcatForKeys(source, output, supportedKeys, ctx);
1089
+ output = replaceFilesArray(source, output, ctx);
1090
+ output = replaceJsCssArrays(source, output, ctx);
1091
+ if (!isJsxLikePath(opts.authorFilePath)) output = cleanupPublicRootLiterals(output);
1092
+ output = normalizeSpecialFolderExtensions(output);
1093
+ output = collapseAccidentalDoubleQuotes(output, supportedKeys);
1094
+ return output;
1095
+ }
1096
+ var swc_filename = __rspack_fileURLToPath(import.meta.url);
1097
+ let swcRuntimeModule;
1098
+ async function loadSwc() {
1099
+ if (swcRuntimeModule) return swcRuntimeModule;
1100
+ try {
1101
+ const mod = await import("@swc/core");
1102
+ swcRuntimeModule = mod?.default && mod.default.parse ? mod.default : mod;
1103
+ } catch {
1104
+ try {
1105
+ const mod = __webpack_require__("@swc/core?1153") || createRequire(swc_filename)('@swc/core');
1106
+ swcRuntimeModule = mod?.default && mod.default.parse ? mod.default : mod;
1107
+ } catch {}
1108
+ }
1109
+ return swcRuntimeModule || null;
1110
+ }
1111
+ async function parseWithSwc(swc, source, flags) {
1112
+ return swc.parse(source, {
1113
+ syntax: flags.isTS ? "typescript" : "ecmascript",
1114
+ tsx: flags.isTS && flags.isJSX,
1115
+ jsx: !flags.isTS && flags.isJSX,
1116
+ target: 'es2022',
1117
+ isModule: true
1118
+ });
1119
+ }
1120
+ async function resolvePathsLoader(source) {
1121
+ const callback = this.async();
1122
+ const options = this.getOptions?.() || {};
1123
+ const manifestPath = options.manifestPath;
1124
+ const packageJsonDir = options.packageJsonDir;
1125
+ const outputPath = String(options.outputPath || '');
1126
+ const sourceMapsOpt = 'boolean' == typeof options.sourceMaps || 'auto' === options.sourceMaps ? options.sourceMaps : 'auto';
1127
+ this.cacheable && this.cacheable();
1128
+ const emittedBodies = new Set();
1129
+ const emitStandardWarning = (headerFilePath, bodyLines)=>{
1130
+ const bodyMessage = bodyLines.join('\n');
1131
+ if (emittedBodies.has(bodyMessage)) return;
1132
+ emittedBodies.add(bodyMessage);
1133
+ const warning = new Error(bodyMessage);
1134
+ warning.file = headerFilePath;
1135
+ this.emitWarning?.(warning);
1136
+ };
1137
+ const warnIfMissingPublic = (original, computed)=>{
1138
+ try {
1139
+ const canonical = unixify(original || '');
1140
+ const authorUsedRoot = /^\//.test(canonical);
1141
+ if (computed) {
1142
+ if (/^(?:pages|scripts)\//i.test(computed)) return;
1143
+ const root = packageJsonDir || __rspack_external_path.dirname(manifestPath);
1144
+ const sourcePublicAbs = __rspack_external_path.join(root, 'public', computed);
1145
+ if (!__rspack_external_fs.existsSync(sourcePublicAbs)) {
1146
+ const displayPath = authorUsedRoot && outputPath ? __rspack_external_path.join(outputPath, computed) : sourcePublicAbs;
1147
+ const lines = [
1148
+ 'Check the path used in your extension API call.',
1149
+ 'The path must point to an existing file that will be packaged with the extension.',
1150
+ `Found value: ${original ?? ''}`,
1151
+ `Resolved path: ${authorUsedRoot && outputPath ? __rspack_external_path.join(outputPath, computed) : sourcePublicAbs}`
1152
+ ];
1153
+ if (authorUsedRoot) lines.push("Paths starting with '/' are resolved from the extension output root (served from public/), not your source directory.");
1154
+ lines.push('', `NOT FOUND ${displayPath}`);
1155
+ emitStandardWarning(String(this.resourcePath), lines);
1156
+ }
1157
+ } else if (original) {
1158
+ const looksNested = /(^|\/)src\/pages\//i.test(canonical) || /(^|\/)src\/scripts\//i.test(canonical);
1159
+ if (looksNested) {
1160
+ const root = packageJsonDir || __rspack_external_path.dirname(manifestPath);
1161
+ const abs = __rspack_external_path.join(root, canonical);
1162
+ const lines = [
1163
+ 'Check the path used in your extension API call.',
1164
+ 'The path must point to an existing file that will be packaged with the extension.',
1165
+ `Found value: ${original}`
1166
+ ];
1167
+ lines.push('', `NOT FOUND ${abs}`);
1168
+ emitStandardWarning(String(this.resourcePath), lines);
1073
1169
  }
1074
1170
  }
1075
- input = input.replace(rxArr, onMatch);
1076
- }
1077
- return input;
1078
- }
1079
- function cleanupPublicRootLiterals(input) {
1080
- input = input.replace(/(['"])\/public\/([^'"]+?)\1/g, function(_m, q, p) {
1081
- return `${q}${normalizeLiteralPayload(p)}${q}`;
1082
- });
1083
- input = input.replace(/(['"])public\/(.*?)\1/g, function(_m, q, p) {
1084
- return `${q}${normalizeLiteralPayload(p)}${q}`;
1085
- });
1086
- return input;
1087
- }
1088
- function normalizeSpecialFolderExtensions(input) {
1089
- input = input.replace(/(['"])((?:pages|scripts)\/[^'"]+?)\.(ts|tsx)\1/g, function(_m, q, p) {
1090
- return `${q}${p}.js${q}`;
1091
- });
1092
- input = input.replace(/(['"])((?:pages|scripts)\/[^'"]+?)\.(njk|nunjucks)\1/g, function(_m, q, p) {
1093
- return `${q}${p}.html${q}`;
1094
- });
1095
- input = input.replace(/(['"])((?:pages|scripts)\/[^'"]+?)\.(scss|sass|less)\1/g, function(_m, q, p) {
1096
- return `${q}${p}.css${q}`;
1171
+ } catch {}
1172
+ };
1173
+ try {
1174
+ const resourcePathUnix = unixify(String(this.resourcePath || ''));
1175
+ if (resourcePathUnix.split('/').includes('public')) return callback(null, source);
1176
+ } catch {}
1177
+ try {
1178
+ const sourceString = String(source);
1179
+ const containsEligiblePatterns = /(?:^|[^A-Za-z0-9_$])(chrome|browser)\s*\./.test(sourceString) || /(?:^|[^A-Za-z0-9_$])(?:runtime|extension)\s*\.?\s*getURL\s*\(/.test(sourceString) || /(?:^|[^A-Za-z0-9_$])\/public\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])public\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])\/pages\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])pages\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])\/scripts\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])scripts\//.test(sourceString);
1180
+ if (!containsEligiblePatterns) return callback(null, source);
1181
+ } catch {}
1182
+ let postTextSource;
1183
+ try {
1184
+ const out = textFallbackTransform(String(source), {
1185
+ manifestPath,
1186
+ packageJsonDir,
1187
+ authorFilePath: String(this.resourcePath || ''),
1188
+ onResolvedLiteral: (original, computed)=>warnIfMissingPublic(original, computed)
1097
1189
  });
1098
- return input;
1099
- }
1100
- function collapseAccidentalDoubleQuotes(input, keys) {
1101
- const keyUnion = `(?:${keys.join('|')})`;
1102
- input = input.replace(new RegExp(`(${keyUnion}\\s*:\\s*)''`, 'g'), "$1'");
1103
- input = input.replace(new RegExp(`(${keyUnion}\\s*:\\s*)""`, 'g'), '$1"');
1104
- input = input.replace(/:\s*''/g, ": '");
1105
- input = input.replace(/:\s*""/g, ': "');
1106
- input = input.replace(/:\s*''([^']+)'/g, ": '$1'");
1107
- input = input.replace(/:\s*\"\"([^\"]+)\"/g, ': "$1"');
1108
- input = input.replace(/''([^']*?)''/g, "'$1'");
1109
- input = input.replace(/""([^"]*?)""/g, '"$1"');
1110
- return input;
1111
- }
1112
- function textFallbackTransform(source, opts) {
1113
- let output = String(source);
1114
- const ctx = {
1115
- manifestPath: opts.manifestPath,
1116
- packageJsonDir: opts.packageJsonDir,
1117
- authorFilePath: opts.authorFilePath,
1118
- onResolvedLiteral: opts.onResolvedLiteral
1119
- };
1120
- output = replaceRuntimeGetURL(source, output, ctx);
1121
- const supportedKeys = [
1122
- 'url',
1123
- 'file',
1124
- 'path',
1125
- 'iconUrl',
1126
- 'imageUrl',
1127
- 'default_icon'
1128
- ];
1129
- output = replaceObjectKeyLiterals(source, output, supportedKeys, ctx);
1130
- output = replaceStaticTemplateForKeys(source, output, supportedKeys, ctx);
1131
- output = replaceConcatForKeys(source, output, supportedKeys, ctx);
1132
- output = replaceFilesArray(source, output, ctx);
1133
- output = replaceJsCssArrays(source, output, ctx);
1134
- if (!isJsxLikePath(opts.authorFilePath)) output = cleanupPublicRootLiterals(output);
1135
- output = normalizeSpecialFolderExtensions(output);
1136
- output = collapseAccidentalDoubleQuotes(output, supportedKeys);
1137
- return output;
1138
- }
1139
- const external_module_namespaceObject = require("module");
1140
- let swcRuntimeModule;
1141
- async function loadSwc() {
1142
- if (swcRuntimeModule) return swcRuntimeModule;
1143
- try {
1144
- const mod = await import("@swc/core");
1145
- swcRuntimeModule = mod?.default && mod.default.parse ? mod.default : mod;
1146
- } catch {
1147
- try {
1148
- const mod = __webpack_require__("@swc/core") || (0, external_module_namespaceObject.createRequire)(__filename)('@swc/core');
1149
- swcRuntimeModule = mod?.default && mod.default.parse ? mod.default : mod;
1150
- } catch {}
1190
+ postTextSource = out;
1191
+ const hasStaticTemplates = /`[^$`]*`/.test(out);
1192
+ const hasBinaryConcats = /(['"`][^'"`]*['"`]\s*\+\s*['"`][^'"`]*['"`])/.test(out);
1193
+ const hasApiRoots = /(?:^|[^A-Za-z0-9_$])(chrome|browser)\s*\./.test(out);
1194
+ const needsStaticEval = (hasStaticTemplates || hasBinaryConcats) && hasApiRoots;
1195
+ const enableMaps = 'auto' === sourceMapsOpt ? Boolean(this.sourceMap) : Boolean(sourceMapsOpt);
1196
+ if (!needsStaticEval) {
1197
+ if (out !== String(source) || enableMaps && /\.[cm]?tsx?$/.test(String(this.resourcePath || ''))) {
1198
+ const msAll = new magic_string(String(source));
1199
+ msAll.overwrite(0, String(source).length, out);
1200
+ const map = enableMaps ? msAll.generateMap({
1201
+ hires: true,
1202
+ source: String(this.resourcePath),
1203
+ includeContent: true
1204
+ }) : void 0;
1205
+ return callback(null, out, map);
1206
+ }
1151
1207
  }
1152
- return swcRuntimeModule || null;
1153
- }
1154
- async function parseWithSwc(swc, source, flags) {
1155
- return swc.parse(source, {
1156
- syntax: flags.isTS ? "typescript" : "ecmascript",
1157
- tsx: flags.isTS && flags.isJSX,
1158
- jsx: !flags.isTS && flags.isJSX,
1159
- target: 'es2022',
1160
- isModule: true
1208
+ } catch {}
1209
+ const swc = await loadSwc();
1210
+ if (!swc) return callback(null, source);
1211
+ let programAst;
1212
+ try {
1213
+ const isTS = /\.[cm]?tsx?$/.test(this.resourcePath);
1214
+ const isJSX = /\.[cm]?[jt]sx$/.test(this.resourcePath);
1215
+ const parseSource = 'string' == typeof postTextSource ? postTextSource : source;
1216
+ programAst = await parseWithSwc(swc, parseSource, {
1217
+ isTS,
1218
+ isJSX
1161
1219
  });
1220
+ } catch {
1221
+ return callback(null, source);
1162
1222
  }
1163
- async function resolvePathsLoader(source) {
1164
- const callback = this.async();
1165
- const options = this.getOptions?.() || {};
1166
- const manifestPath = options.manifestPath;
1167
- const packageJsonDir = options.packageJsonDir;
1168
- const outputPath = String(options.outputPath || '');
1169
- const sourceMapsOpt = 'boolean' == typeof options.sourceMaps || 'auto' === options.sourceMaps ? options.sourceMaps : 'auto';
1170
- this.cacheable && this.cacheable();
1171
- const emittedBodies = new Set();
1172
- const emitStandardWarning = (headerFilePath, bodyLines)=>{
1173
- const bodyMessage = bodyLines.join('\n');
1174
- if (emittedBodies.has(bodyMessage)) return;
1175
- emittedBodies.add(bodyMessage);
1176
- const warning = new Error(bodyMessage);
1177
- warning.file = headerFilePath;
1178
- this.emitWarning?.(warning);
1179
- };
1180
- const warnIfMissingPublic = (original, computed)=>{
1181
- try {
1182
- const canonical = unixify(original || '');
1183
- const authorUsedRoot = /^\//.test(canonical);
1184
- if (computed) {
1185
- if (/^(?:pages|scripts)\//i.test(computed)) return;
1186
- const root = packageJsonDir || external_path_namespaceObject.dirname(manifestPath);
1187
- const sourcePublicAbs = external_path_namespaceObject.join(root, 'public', computed);
1188
- if (!external_fs_namespaceObject.existsSync(sourcePublicAbs)) {
1189
- const displayPath = authorUsedRoot && outputPath ? external_path_namespaceObject.join(outputPath, computed) : sourcePublicAbs;
1190
- const lines = [
1191
- 'Check the path used in your extension API call.',
1192
- 'The path must point to an existing file that will be packaged with the extension.',
1193
- `Found value: ${original ?? ''}`,
1194
- `Resolved path: ${authorUsedRoot && outputPath ? external_path_namespaceObject.join(outputPath, computed) : sourcePublicAbs}`
1195
- ];
1196
- if (authorUsedRoot) lines.push("Paths starting with '/' are resolved from the extension output root (served from public/), not your source directory.");
1197
- lines.push('', `NOT FOUND ${displayPath}`);
1198
- emitStandardWarning(String(this.resourcePath), lines);
1199
- }
1200
- } else if (original) {
1201
- const looksNested = /(^|\/)src\/pages\//i.test(canonical) || /(^|\/)src\/scripts\//i.test(canonical);
1202
- if (looksNested) {
1203
- const root = packageJsonDir || external_path_namespaceObject.dirname(manifestPath);
1204
- const abs = external_path_namespaceObject.join(root, canonical);
1205
- const lines = [
1206
- 'Check the path used in your extension API call.',
1207
- 'The path must point to an existing file that will be packaged with the extension.',
1208
- `Found value: ${original}`
1209
- ];
1210
- lines.push('', `NOT FOUND ${abs}`);
1211
- emitStandardWarning(String(this.resourcePath), lines);
1212
- }
1213
- }
1214
- } catch {}
1215
- };
1216
- try {
1217
- const resourcePathUnix = unixify(String(this.resourcePath || ''));
1218
- if (resourcePathUnix.split('/').includes('public')) return callback(null, source);
1219
- } catch {}
1220
- try {
1221
- const sourceString = String(source);
1222
- const containsEligiblePatterns = /(?:^|[^A-Za-z0-9_$])(chrome|browser)\s*\./.test(sourceString) || /(?:^|[^A-Za-z0-9_$])(?:runtime|extension)\s*\.?\s*getURL\s*\(/.test(sourceString) || /(?:^|[^A-Za-z0-9_$])\/public\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])public\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])\/pages\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])pages\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])\/scripts\//.test(sourceString) || /(?:^|[^A-Za-z0-9_$])scripts\//.test(sourceString);
1223
- if (!containsEligiblePatterns) return callback(null, source);
1224
- } catch {}
1225
- let postTextSource;
1226
- try {
1227
- const out = textFallbackTransform(String(source), {
1223
+ const inputSource = 'string' == typeof postTextSource ? postTextSource : String(source);
1224
+ const ms = new magic_string(inputSource);
1225
+ let edited = false;
1226
+ const rewriteValue = (node, computed, rawInput)=>{
1227
+ if (!computed && 'string' == typeof rawInput) try {
1228
+ const recomputed = resolveLiteralToOutput(rawInput, {
1228
1229
  manifestPath,
1229
1230
  packageJsonDir,
1230
- authorFilePath: String(this.resourcePath || ''),
1231
- onResolvedLiteral: (original, computed)=>warnIfMissingPublic(original, computed)
1231
+ authorFilePath: String(this.resourcePath || '')
1232
1232
  });
1233
- postTextSource = out;
1234
- const hasStaticTemplates = /`[^$`]*`/.test(out);
1235
- const hasBinaryConcats = /(['"`][^'"`]*['"`]\s*\+\s*['"`][^'"`]*['"`])/.test(out);
1236
- const hasApiRoots = /(?:^|[^A-Za-z0-9_$])(chrome|browser)\s*\./.test(out);
1237
- const needsStaticEval = (hasStaticTemplates || hasBinaryConcats) && hasApiRoots;
1238
- const enableMaps = 'auto' === sourceMapsOpt ? Boolean(this.sourceMap) : Boolean(sourceMapsOpt);
1239
- if (!needsStaticEval) {
1240
- if (out !== String(source) || enableMaps && /\.[cm]?tsx?$/.test(String(this.resourcePath || ''))) {
1241
- const msAll = new (external_magic_string_default())(String(source));
1242
- msAll.overwrite(0, String(source).length, out);
1243
- const map = enableMaps ? msAll.generateMap({
1244
- hires: true,
1245
- source: String(this.resourcePath),
1246
- includeContent: true
1247
- }) : void 0;
1248
- return callback(null, out, map);
1249
- }
1250
- }
1233
+ if (recomputed) computed = recomputed;
1251
1234
  } catch {}
1252
- const swc = await loadSwc();
1253
- if (!swc) return callback(null, source);
1254
- let programAst;
1235
+ if (!computed) return;
1255
1236
  try {
1256
- const isTS = /\.[cm]?tsx?$/.test(this.resourcePath);
1257
- const isJSX = /\.[cm]?[jt]sx$/.test(this.resourcePath);
1258
- const parseSource = 'string' == typeof postTextSource ? postTextSource : source;
1259
- programAst = await parseWithSwc(swc, parseSource, {
1260
- isTS,
1261
- isJSX
1262
- });
1263
- } catch {
1264
- return callback(null, source);
1265
- }
1266
- const inputSource = 'string' == typeof postTextSource ? postTextSource : String(source);
1267
- const ms = new (external_magic_string_default())(inputSource);
1268
- let edited = false;
1269
- const rewriteValue = (node, computed, rawInput)=>{
1270
- if (!computed && 'string' == typeof rawInput) try {
1271
- const recomputed = resolveLiteralToOutput(rawInput, {
1272
- manifestPath,
1273
- packageJsonDir,
1274
- authorFilePath: String(this.resourcePath || '')
1275
- });
1276
- if (recomputed) computed = recomputed;
1277
- } catch {}
1278
- if (!computed) return;
1279
- try {
1280
- const span = node?.span;
1281
- if (span && 'number' == typeof span.start && 'number' == typeof span.end) {
1282
- const src = String(inputSource);
1283
- const before = src[span.start - 1];
1284
- const after = src[span.end];
1285
- const isQuote = (c)=>"'" === c || '"' === c;
1286
- if (isQuote(before) && before === after) {
1287
- let start = span.start - 1;
1288
- let end = span.end + 1;
1289
- const q = before;
1290
- const json = JSON.stringify(String(computed));
1291
- if ('"' === q) ms.overwrite(start, end, json);
1292
- else {
1293
- const inner = json.slice(1, -1).replace(/'/g, "\\'");
1294
- ms.overwrite(start, end, `'${inner}'`);
1295
- }
1296
- } else ms.overwrite(span.start, span.end, JSON.stringify(computed));
1297
- edited = true;
1298
- }
1299
- } catch {}
1300
- };
1301
- const walk = (currentNode)=>{
1302
- if (!currentNode || 'object' != typeof currentNode) return;
1303
- if ('CallExpression' === currentNode.type) try {
1304
- handleCallExpression(currentNode, String(inputSource), rewriteValue, manifestPath);
1305
- } catch {}
1306
- for(const key in currentNode){
1307
- if (!Object.prototype.hasOwnProperty.call(currentNode, key)) continue;
1308
- const childNode = currentNode[key];
1309
- if (childNode) {
1310
- if (Array.isArray(childNode)) childNode.forEach(walk);
1311
- else if (childNode && 'string' == typeof childNode.type) walk(childNode);
1312
- }
1237
+ const span = node?.span;
1238
+ if (span && 'number' == typeof span.start && 'number' == typeof span.end) {
1239
+ const src = String(inputSource);
1240
+ const before = src[span.start - 1];
1241
+ const after = src[span.end];
1242
+ const isQuote = (c)=>"'" === c || '"' === c;
1243
+ if (isQuote(before) && before === after) {
1244
+ let start = span.start - 1;
1245
+ let end = span.end + 1;
1246
+ const q = before;
1247
+ const json = JSON.stringify(String(computed));
1248
+ if ('"' === q) ms.overwrite(start, end, json);
1249
+ else {
1250
+ const inner = json.slice(1, -1).replace(/'/g, "\\'");
1251
+ ms.overwrite(start, end, `'${inner}'`);
1252
+ }
1253
+ } else ms.overwrite(span.start, span.end, JSON.stringify(computed));
1254
+ edited = true;
1313
1255
  }
1314
- };
1315
- walk(programAst);
1316
- try {
1317
- if (!edited) {
1318
- if ('string' == typeof postTextSource && postTextSource !== String(source)) {
1319
- const enableMaps = 'auto' === sourceMapsOpt ? Boolean(this.sourceMap) : Boolean(sourceMapsOpt);
1320
- const msAll = new (external_magic_string_default())(String(source));
1321
- msAll.overwrite(0, String(source).length, postTextSource);
1322
- const map = enableMaps ? msAll.generateMap({
1323
- hires: true,
1324
- source: String(this.resourcePath),
1325
- includeContent: true
1326
- }) : void 0;
1327
- return callback(null, postTextSource, map);
1328
- }
1329
- return callback(null, source);
1256
+ } catch {}
1257
+ };
1258
+ const walk = (currentNode)=>{
1259
+ if (!currentNode || 'object' != typeof currentNode) return;
1260
+ if ('CallExpression' === currentNode.type) try {
1261
+ handleCallExpression(currentNode, String(inputSource), rewriteValue, manifestPath);
1262
+ } catch {}
1263
+ for(const key in currentNode){
1264
+ if (!Object.prototype.hasOwnProperty.call(currentNode, key)) continue;
1265
+ const childNode = currentNode[key];
1266
+ if (childNode) {
1267
+ if (Array.isArray(childNode)) childNode.forEach(walk);
1268
+ else if (childNode && 'string' == typeof childNode.type) walk(childNode);
1269
+ }
1270
+ }
1271
+ };
1272
+ walk(programAst);
1273
+ try {
1274
+ if (!edited) {
1275
+ if ('string' == typeof postTextSource && postTextSource !== String(source)) {
1276
+ const enableMaps = 'auto' === sourceMapsOpt ? Boolean(this.sourceMap) : Boolean(sourceMapsOpt);
1277
+ const msAll = new magic_string(String(source));
1278
+ msAll.overwrite(0, String(source).length, postTextSource);
1279
+ const map = enableMaps ? msAll.generateMap({
1280
+ hires: true,
1281
+ source: String(this.resourcePath),
1282
+ includeContent: true
1283
+ }) : void 0;
1284
+ return callback(null, postTextSource, map);
1330
1285
  }
1331
- const enableMaps = 'auto' === sourceMapsOpt ? Boolean(this.sourceMap) : Boolean(sourceMapsOpt);
1332
- const code = ms.toString();
1333
- const map = enableMaps ? ms.generateMap({
1334
- hires: true,
1335
- source: String(this.resourcePath),
1336
- includeContent: true
1337
- }) : void 0;
1338
- return callback(null, code, map);
1339
- } catch {
1340
1286
  return callback(null, source);
1341
1287
  }
1288
+ const enableMaps = 'auto' === sourceMapsOpt ? Boolean(this.sourceMap) : Boolean(sourceMapsOpt);
1289
+ const code = ms.toString();
1290
+ const map = enableMaps ? ms.generateMap({
1291
+ hires: true,
1292
+ source: String(this.resourcePath),
1293
+ includeContent: true
1294
+ }) : void 0;
1295
+ return callback(null, code, map);
1296
+ } catch {
1297
+ return callback(null, source);
1342
1298
  }
1343
- })();
1344
- exports["default"] = __webpack_exports__["default"];
1345
- for(var __rspack_i in __webpack_exports__)if (-1 === [
1346
- "default"
1347
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
1348
- Object.defineProperty(exports, '__esModule', {
1349
- value: true
1350
- });
1299
+ }
1300
+ export default resolvePathsLoader;