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,46 +1,8 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- default: ()=>ensureHMRForScripts
37
- });
38
- const external_fs_namespaceObject = require("fs");
39
- var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
40
- const external_path_namespaceObject = require("path");
41
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
42
- const external_schema_utils_namespaceObject = require("schema-utils");
43
- const EXTENSIONJS_CONTENT_SCRIPT_LAYER = "extensionjs-content-script";
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { validate } from "schema-utils";
5
+ import { EXTENSIONJS_CONTENT_SCRIPT_LAYER } from "./526.mjs";
44
6
  const schema = {
45
7
  type: 'object',
46
8
  properties: {
@@ -64,7 +26,7 @@ function ensureHMRForScripts(source) {
64
26
  const resourcePath = String(this.resourcePath || '');
65
27
  const moduleLayer = String(this?._module?.layer || '');
66
28
  try {
67
- (0, external_schema_utils_namespaceObject.validate)(schema, options, {
29
+ validate(schema, options, {
68
30
  name: "html:ensure-hmr-for-scripts",
69
31
  baseDataPath: 'options'
70
32
  });
@@ -77,23 +39,23 @@ function ensureHMRForScripts(source) {
77
39
  }
78
40
  try {
79
41
  const manifestPath = String(options?.manifestPath || '');
80
- const manifestDir = manifestPath ? external_path_default().dirname(manifestPath) : '';
42
+ const manifestDir = manifestPath ? path.dirname(manifestPath) : '';
81
43
  if (manifestPath && resourcePath) {
82
- const manifest = JSON.parse(external_fs_default().readFileSync(manifestPath, 'utf-8'));
44
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
83
45
  const contentScripts = Array.isArray(manifest?.content_scripts) ? manifest.content_scripts : [];
84
46
  const contentEntryPaths = new Set();
85
47
  for (const contentScript of contentScripts){
86
48
  const jsList = Array.isArray(contentScript?.js) ? contentScript.js : [];
87
- for (const jsFile of jsList)contentEntryPaths.add(external_path_default().normalize(external_path_default().resolve(manifestDir, jsFile)));
49
+ for (const jsFile of jsList)contentEntryPaths.add(path.normalize(path.resolve(manifestDir, jsFile)));
88
50
  }
89
- if (contentEntryPaths.has(external_path_default().normalize(resourcePath))) {
51
+ if (contentEntryPaths.has(path.normalize(resourcePath))) {
90
52
  if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip direct resource=${resourcePath} manifest=${manifestPath}`);
91
53
  return source;
92
54
  }
93
55
  let issuer = this?._module?.issuer;
94
56
  while(issuer){
95
57
  const issuerResource = String(issuer?.resource || issuer?.userRequest || '');
96
- if (issuerResource && contentEntryPaths.has(external_path_default().normalize(issuerResource))) {
58
+ if (issuerResource && contentEntryPaths.has(path.normalize(issuerResource))) {
97
59
  if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip issuer resource=${resourcePath} issuer=${issuerResource}`);
98
60
  return source;
99
61
  }
@@ -136,10 +98,4 @@ if (import.meta.webpackHot) {
136
98
  `;
137
99
  return `${reloadCode}${source}`;
138
100
  }
139
- exports["default"] = __webpack_exports__["default"];
140
- for(var __rspack_i in __webpack_exports__)if (-1 === [
141
- "default"
142
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
143
- Object.defineProperty(exports, '__esModule', {
144
- value: true
145
- });
101
+ export default ensureHMRForScripts;
@@ -1,46 +1,8 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- default: ()=>ensureHMRForScripts
37
- });
38
- const external_fs_namespaceObject = require("fs");
39
- var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
40
- const external_path_namespaceObject = require("path");
41
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
42
- const external_schema_utils_namespaceObject = require("schema-utils");
43
- const EXTENSIONJS_CONTENT_SCRIPT_LAYER = "extensionjs-content-script";
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { validate } from "schema-utils";
5
+ import { EXTENSIONJS_CONTENT_SCRIPT_LAYER } from "./526.mjs";
44
6
  const schema = {
45
7
  type: 'object',
46
8
  properties: {
@@ -64,7 +26,7 @@ function ensureHMRForScripts(source) {
64
26
  const resourcePath = String(this.resourcePath || '');
65
27
  const moduleLayer = String(this?._module?.layer || '');
66
28
  try {
67
- (0, external_schema_utils_namespaceObject.validate)(schema, options, {
29
+ validate(schema, options, {
68
30
  name: "html:ensure-hmr-for-scripts",
69
31
  baseDataPath: 'options'
70
32
  });
@@ -77,23 +39,23 @@ function ensureHMRForScripts(source) {
77
39
  }
78
40
  try {
79
41
  const manifestPath = String(options?.manifestPath || '');
80
- const manifestDir = manifestPath ? external_path_default().dirname(manifestPath) : '';
42
+ const manifestDir = manifestPath ? path.dirname(manifestPath) : '';
81
43
  if (manifestPath && resourcePath) {
82
- const manifest = JSON.parse(external_fs_default().readFileSync(manifestPath, 'utf-8'));
44
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
83
45
  const contentScripts = Array.isArray(manifest?.content_scripts) ? manifest.content_scripts : [];
84
46
  const contentEntryPaths = new Set();
85
47
  for (const contentScript of contentScripts){
86
48
  const jsList = Array.isArray(contentScript?.js) ? contentScript.js : [];
87
- for (const jsFile of jsList)contentEntryPaths.add(external_path_default().normalize(external_path_default().resolve(manifestDir, jsFile)));
49
+ for (const jsFile of jsList)contentEntryPaths.add(path.normalize(path.resolve(manifestDir, jsFile)));
88
50
  }
89
- if (contentEntryPaths.has(external_path_default().normalize(resourcePath))) {
51
+ if (contentEntryPaths.has(path.normalize(resourcePath))) {
90
52
  if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip direct resource=${resourcePath} manifest=${manifestPath}`);
91
53
  return source;
92
54
  }
93
55
  let issuer = this?._module?.issuer;
94
56
  while(issuer){
95
57
  const issuerResource = String(issuer?.resource || issuer?.userRequest || '');
96
- if (issuerResource && contentEntryPaths.has(external_path_default().normalize(issuerResource))) {
58
+ if (issuerResource && contentEntryPaths.has(path.normalize(issuerResource))) {
97
59
  if (debugHtmlHmr) console.log(`[extjs:html-hmr] skip issuer resource=${resourcePath} issuer=${issuerResource}`);
98
60
  return source;
99
61
  }
@@ -136,10 +98,4 @@ if (import.meta.webpackHot) {
136
98
  `;
137
99
  return `${reloadCode}${source}`;
138
100
  }
139
- exports["default"] = __webpack_exports__["default"];
140
- for(var __rspack_i in __webpack_exports__)if (-1 === [
141
- "default"
142
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
143
- Object.defineProperty(exports, '__esModule', {
144
- value: true
145
- });
101
+ export default ensureHMRForScripts;
@@ -1,79 +1,10 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- default: ()=>contentScriptWrapper
37
- });
38
- const external_fs_namespaceObject = require("fs");
39
- var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
40
- const external_path_namespaceObject = require("path");
41
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
42
- const external_schema_utils_namespaceObject = require("schema-utils");
43
- const core_namespaceObject = require("@swc/core");
44
- const CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX = "content_scripts/content-";
45
- function getCanonicalContentScriptEntryName(index) {
46
- return `${CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX}${index}`;
47
- }
48
- function findUpLocalSync(filename, options) {
49
- const root = external_path_namespaceObject.parse(options.cwd).root;
50
- let currentDir = options.cwd;
51
- while(true){
52
- const candidate = external_path_namespaceObject.join(currentDir, filename);
53
- try {
54
- const stat = external_fs_namespaceObject.statSync(candidate);
55
- if (stat.isFile()) return candidate;
56
- } catch {}
57
- if (currentDir === root) return;
58
- currentDir = external_path_namespaceObject.dirname(currentDir);
59
- }
60
- }
61
- function findNearestPackageJsonSync(manifestPath) {
62
- try {
63
- const manifestDir = external_path_namespaceObject.dirname(manifestPath);
64
- return findUpLocalSync('package.json', {
65
- cwd: manifestDir
66
- }) || null;
67
- } catch {
68
- return null;
69
- }
70
- }
71
- const external_pintor_namespaceObject = require("pintor");
72
- var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_namespaceObject);
73
- function reservedScriptsFolder(relPath, indicators) {
74
- const reasons = indicators.map((r)=>`- ${external_pintor_default().gray(r)}`).join('\n');
75
- return `${external_pintor_default().red('ERROR')} scripts/ is a reserved folder in Extension.js.\nEvery file under ${external_pintor_default().yellow("scripts/")} is wrapped with the browser content-script mount runtime, so Node.js-only files placed here will fail to parse or run.\nRename the folder at the project root (for example ${external_pintor_default().yellow('bin/')}, ${external_pintor_default().yellow('tools/')}, ${external_pintor_default().yellow('ops/')}, ${external_pintor_default().yellow('tasks/')}, or ${external_pintor_default().yellow("ci-scripts/")}) or move the file out of scripts/.\n\n${external_pintor_default().red('NODE.JS SHAPE')}\n${reasons}\n${external_pintor_default().red('NOT ALLOWED')} ${external_pintor_default().underline(relPath)}`;
76
- }
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { validate } from "schema-utils";
5
+ import { parseSync } from "@swc/core";
6
+ import { findNearestPackageJsonSync, reservedScriptsFolder } from "./314.mjs";
7
+ import { getCanonicalContentScriptEntryName, CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX } from "./526.mjs";
77
8
  const schema = {
78
9
  type: 'object',
79
10
  properties: {
@@ -131,10 +62,10 @@ function collectStyleAssetSpecifiers(source) {
131
62
  }
132
63
  function hasDefaultExport(source, resourcePath, compilation) {
133
64
  try {
134
- const ext = external_path_default().extname(resourcePath).toLowerCase();
65
+ const ext = path.extname(resourcePath).toLowerCase();
135
66
  const isTS = '.ts' === ext || '.tsx' === ext || '.mts' === ext || '.mtsx' === ext;
136
67
  const isJSX = '.jsx' === ext || '.tsx' === ext || '.mjsx' === ext || '.mtsx' === ext;
137
- const abs = external_path_default().normalize(resourcePath);
68
+ const abs = path.normalize(resourcePath);
138
69
  const sig = getSourceSignature(source);
139
70
  if (compilation) {
140
71
  compilation.__extjsHasDefaultExportCache ??= new Map();
@@ -142,7 +73,7 @@ function hasDefaultExport(source, resourcePath, compilation) {
142
73
  const cached = compilation.__extjsHasDefaultExportCache.get(cacheKey);
143
74
  if ('boolean' == typeof cached) return cached;
144
75
  }
145
- const ast = (0, core_namespaceObject.parseSync)(source, {
76
+ const ast = parseSync(source, {
146
77
  syntax: isTS ? "typescript" : "ecmascript",
147
78
  tsx: isTS && isJSX,
148
79
  jsx: !isTS && isJSX,
@@ -178,23 +109,23 @@ function hasDefaultExport(source, resourcePath, compilation) {
178
109
  } catch {
179
110
  const fallback = source.includes('export default');
180
111
  try {
181
- compilation?.__extjsHasDefaultExportCache?.set(`${external_path_default().normalize(resourcePath)}|${getSourceSignature(source)}`, fallback);
112
+ compilation?.__extjsHasDefaultExportCache?.set(`${path.normalize(resourcePath)}|${getSourceSignature(source)}`, fallback);
182
113
  } catch {}
183
114
  return fallback;
184
115
  }
185
116
  }
186
117
  function contentScriptWrapper(source) {
187
118
  const options = this.getOptions();
188
- (0, external_schema_utils_namespaceObject.validate)(schema, options, {
119
+ validate(schema, options, {
189
120
  name: "scripts:content-script-wrapper",
190
121
  baseDataPath: 'options'
191
122
  });
192
123
  const compilation = this._compilation;
193
124
  const manifestPath = options.manifestPath;
194
- const manifestDir = external_path_default().dirname(manifestPath);
125
+ const manifestDir = path.dirname(manifestPath);
195
126
  const packageJsonPath = findNearestPackageJsonSync(manifestPath);
196
- const packageJsonDir = packageJsonPath ? external_path_default().dirname(packageJsonPath) : manifestDir;
197
- const manifest = JSON.parse(external_fs_default().readFileSync(manifestPath, 'utf-8'));
127
+ const packageJsonDir = packageJsonPath ? path.dirname(packageJsonPath) : manifestDir;
128
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
198
129
  const isProd = 'production' === String(options && options.mode || '').toLowerCase();
199
130
  const rewrittenSource = String(source);
200
131
  const declaredContentJsAbsEntries = [];
@@ -207,22 +138,22 @@ function contentScriptWrapper(source) {
207
138
  for(let scriptIndex = 0; scriptIndex < jsList.length; scriptIndex++){
208
139
  const jsFile = jsList[scriptIndex];
209
140
  declaredContentJsAbsEntries.push({
210
- abs: external_path_default().resolve(manifestDir, jsFile),
141
+ abs: path.resolve(manifestDir, jsFile),
211
142
  runAt,
212
143
  index,
213
144
  scriptIndex
214
145
  });
215
146
  }
216
147
  }
217
- const resourceAbsPath = external_path_default().normalize(this.resourcePath);
218
- const declaredEntry = declaredContentJsAbsEntries.find((entry)=>resourceAbsPath === external_path_default().normalize(entry.abs));
219
- const scriptsDir = external_path_default().resolve(packageJsonDir, "scripts");
220
- const relToScripts = external_path_default().relative(scriptsDir, resourceAbsPath);
221
- const isScriptsFolderScript = relToScripts && !relToScripts.startsWith('..') && !external_path_default().isAbsolute(relToScripts);
148
+ const resourceAbsPath = path.normalize(this.resourcePath);
149
+ const declaredEntry = declaredContentJsAbsEntries.find((entry)=>resourceAbsPath === path.normalize(entry.abs));
150
+ const scriptsDir = path.resolve(packageJsonDir, "scripts");
151
+ const relToScripts = path.relative(scriptsDir, resourceAbsPath);
152
+ const isScriptsFolderScript = relToScripts && !relToScripts.startsWith('..') && !path.isAbsolute(relToScripts);
222
153
  if (isScriptsFolderScript && !declaredEntry) {
223
154
  const nodeIndicators = detectNodeJsShapedScript(rewrittenSource);
224
155
  if (nodeIndicators.length > 0) {
225
- const relFromProject = external_path_default().relative(packageJsonDir, resourceAbsPath).split(external_path_default().sep).join('/');
156
+ const relFromProject = path.relative(packageJsonDir, resourceAbsPath).split(path.sep).join('/');
226
157
  throw new Error(reservedScriptsFolder(relFromProject, nodeIndicators));
227
158
  }
228
159
  }
@@ -259,10 +190,4 @@ function contentScriptWrapper(source) {
259
190
  }
260
191
  return `var __EXTJS_WRAPPER_KIND="FS3_INLINE";\n${bootstrap}${runtimeInline}${cleaned}\n;/* __EXTENSIONJS_MOUNT_WRAPPED__ */\nvar __EXTENSIONJS_cleanup = function(){};\ntry { __EXTENSIONJS_cleanup = __EXTENSIONJS_mount(__EXTENSIONJS_default__, ${JSON.stringify(runAt)}) } catch (error) {}\ntry { __EXTENSIONJS_REINJECT_REGISTRY[__EXTENSIONJS_REINJECT_KEY] = __EXTENSIONJS_cleanup } catch (error) {}\nexport default __EXTENSIONJS_default__\n`;
261
192
  }
262
- exports["default"] = __webpack_exports__["default"];
263
- for(var __rspack_i in __webpack_exports__)if (-1 === [
264
- "default"
265
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
266
- Object.defineProperty(exports, '__esModule', {
267
- value: true
268
- });
193
+ export default contentScriptWrapper;
@@ -1,79 +1,10 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- default: ()=>contentScriptWrapper
37
- });
38
- const external_fs_namespaceObject = require("fs");
39
- var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
40
- const external_path_namespaceObject = require("path");
41
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
42
- const external_schema_utils_namespaceObject = require("schema-utils");
43
- const core_namespaceObject = require("@swc/core");
44
- const CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX = "content_scripts/content-";
45
- function getCanonicalContentScriptEntryName(index) {
46
- return `${CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX}${index}`;
47
- }
48
- function findUpLocalSync(filename, options) {
49
- const root = external_path_namespaceObject.parse(options.cwd).root;
50
- let currentDir = options.cwd;
51
- while(true){
52
- const candidate = external_path_namespaceObject.join(currentDir, filename);
53
- try {
54
- const stat = external_fs_namespaceObject.statSync(candidate);
55
- if (stat.isFile()) return candidate;
56
- } catch {}
57
- if (currentDir === root) return;
58
- currentDir = external_path_namespaceObject.dirname(currentDir);
59
- }
60
- }
61
- function findNearestPackageJsonSync(manifestPath) {
62
- try {
63
- const manifestDir = external_path_namespaceObject.dirname(manifestPath);
64
- return findUpLocalSync('package.json', {
65
- cwd: manifestDir
66
- }) || null;
67
- } catch {
68
- return null;
69
- }
70
- }
71
- const external_pintor_namespaceObject = require("pintor");
72
- var external_pintor_default = /*#__PURE__*/ __webpack_require__.n(external_pintor_namespaceObject);
73
- function reservedScriptsFolder(relPath, indicators) {
74
- const reasons = indicators.map((r)=>`- ${external_pintor_default().gray(r)}`).join('\n');
75
- return `${external_pintor_default().red('ERROR')} scripts/ is a reserved folder in Extension.js.\nEvery file under ${external_pintor_default().yellow("scripts/")} is wrapped with the browser content-script mount runtime, so Node.js-only files placed here will fail to parse or run.\nRename the folder at the project root (for example ${external_pintor_default().yellow('bin/')}, ${external_pintor_default().yellow('tools/')}, ${external_pintor_default().yellow('ops/')}, ${external_pintor_default().yellow('tasks/')}, or ${external_pintor_default().yellow("ci-scripts/")}) or move the file out of scripts/.\n\n${external_pintor_default().red('NODE.JS SHAPE')}\n${reasons}\n${external_pintor_default().red('NOT ALLOWED')} ${external_pintor_default().underline(relPath)}`;
76
- }
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import { validate } from "schema-utils";
5
+ import { parseSync } from "@swc/core";
6
+ import { findNearestPackageJsonSync, reservedScriptsFolder } from "./314.mjs";
7
+ import { getCanonicalContentScriptEntryName, CANONICAL_CONTENT_SCRIPT_ENTRY_PREFIX } from "./526.mjs";
77
8
  const schema = {
78
9
  type: 'object',
79
10
  properties: {
@@ -131,10 +62,10 @@ function collectStyleAssetSpecifiers(source) {
131
62
  }
132
63
  function hasDefaultExport(source, resourcePath, compilation) {
133
64
  try {
134
- const ext = external_path_default().extname(resourcePath).toLowerCase();
65
+ const ext = path.extname(resourcePath).toLowerCase();
135
66
  const isTS = '.ts' === ext || '.tsx' === ext || '.mts' === ext || '.mtsx' === ext;
136
67
  const isJSX = '.jsx' === ext || '.tsx' === ext || '.mjsx' === ext || '.mtsx' === ext;
137
- const abs = external_path_default().normalize(resourcePath);
68
+ const abs = path.normalize(resourcePath);
138
69
  const sig = getSourceSignature(source);
139
70
  if (compilation) {
140
71
  compilation.__extjsHasDefaultExportCache ??= new Map();
@@ -142,7 +73,7 @@ function hasDefaultExport(source, resourcePath, compilation) {
142
73
  const cached = compilation.__extjsHasDefaultExportCache.get(cacheKey);
143
74
  if ('boolean' == typeof cached) return cached;
144
75
  }
145
- const ast = (0, core_namespaceObject.parseSync)(source, {
76
+ const ast = parseSync(source, {
146
77
  syntax: isTS ? "typescript" : "ecmascript",
147
78
  tsx: isTS && isJSX,
148
79
  jsx: !isTS && isJSX,
@@ -178,23 +109,23 @@ function hasDefaultExport(source, resourcePath, compilation) {
178
109
  } catch {
179
110
  const fallback = source.includes('export default');
180
111
  try {
181
- compilation?.__extjsHasDefaultExportCache?.set(`${external_path_default().normalize(resourcePath)}|${getSourceSignature(source)}`, fallback);
112
+ compilation?.__extjsHasDefaultExportCache?.set(`${path.normalize(resourcePath)}|${getSourceSignature(source)}`, fallback);
182
113
  } catch {}
183
114
  return fallback;
184
115
  }
185
116
  }
186
117
  function contentScriptWrapper(source) {
187
118
  const options = this.getOptions();
188
- (0, external_schema_utils_namespaceObject.validate)(schema, options, {
119
+ validate(schema, options, {
189
120
  name: "scripts:content-script-wrapper",
190
121
  baseDataPath: 'options'
191
122
  });
192
123
  const compilation = this._compilation;
193
124
  const manifestPath = options.manifestPath;
194
- const manifestDir = external_path_default().dirname(manifestPath);
125
+ const manifestDir = path.dirname(manifestPath);
195
126
  const packageJsonPath = findNearestPackageJsonSync(manifestPath);
196
- const packageJsonDir = packageJsonPath ? external_path_default().dirname(packageJsonPath) : manifestDir;
197
- const manifest = JSON.parse(external_fs_default().readFileSync(manifestPath, 'utf-8'));
127
+ const packageJsonDir = packageJsonPath ? path.dirname(packageJsonPath) : manifestDir;
128
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
198
129
  const isProd = 'production' === String(options && options.mode || '').toLowerCase();
199
130
  const rewrittenSource = String(source);
200
131
  const declaredContentJsAbsEntries = [];
@@ -207,22 +138,22 @@ function contentScriptWrapper(source) {
207
138
  for(let scriptIndex = 0; scriptIndex < jsList.length; scriptIndex++){
208
139
  const jsFile = jsList[scriptIndex];
209
140
  declaredContentJsAbsEntries.push({
210
- abs: external_path_default().resolve(manifestDir, jsFile),
141
+ abs: path.resolve(manifestDir, jsFile),
211
142
  runAt,
212
143
  index,
213
144
  scriptIndex
214
145
  });
215
146
  }
216
147
  }
217
- const resourceAbsPath = external_path_default().normalize(this.resourcePath);
218
- const declaredEntry = declaredContentJsAbsEntries.find((entry)=>resourceAbsPath === external_path_default().normalize(entry.abs));
219
- const scriptsDir = external_path_default().resolve(packageJsonDir, "scripts");
220
- const relToScripts = external_path_default().relative(scriptsDir, resourceAbsPath);
221
- const isScriptsFolderScript = relToScripts && !relToScripts.startsWith('..') && !external_path_default().isAbsolute(relToScripts);
148
+ const resourceAbsPath = path.normalize(this.resourcePath);
149
+ const declaredEntry = declaredContentJsAbsEntries.find((entry)=>resourceAbsPath === path.normalize(entry.abs));
150
+ const scriptsDir = path.resolve(packageJsonDir, "scripts");
151
+ const relToScripts = path.relative(scriptsDir, resourceAbsPath);
152
+ const isScriptsFolderScript = relToScripts && !relToScripts.startsWith('..') && !path.isAbsolute(relToScripts);
222
153
  if (isScriptsFolderScript && !declaredEntry) {
223
154
  const nodeIndicators = detectNodeJsShapedScript(rewrittenSource);
224
155
  if (nodeIndicators.length > 0) {
225
- const relFromProject = external_path_default().relative(packageJsonDir, resourceAbsPath).split(external_path_default().sep).join('/');
156
+ const relFromProject = path.relative(packageJsonDir, resourceAbsPath).split(path.sep).join('/');
226
157
  throw new Error(reservedScriptsFolder(relFromProject, nodeIndicators));
227
158
  }
228
159
  }
@@ -259,10 +190,4 @@ function contentScriptWrapper(source) {
259
190
  }
260
191
  return `var __EXTJS_WRAPPER_KIND="FS3_INLINE";\n${bootstrap}${runtimeInline}${cleaned}\n;/* __EXTENSIONJS_MOUNT_WRAPPED__ */\nvar __EXTENSIONJS_cleanup = function(){};\ntry { __EXTENSIONJS_cleanup = __EXTENSIONJS_mount(__EXTENSIONJS_default__, ${JSON.stringify(runAt)}) } catch (error) {}\ntry { __EXTENSIONJS_REINJECT_REGISTRY[__EXTENSIONJS_REINJECT_KEY] = __EXTENSIONJS_cleanup } catch (error) {}\nexport default __EXTENSIONJS_default__\n`;
261
192
  }
262
- exports["default"] = __webpack_exports__["default"];
263
- for(var __rspack_i in __webpack_exports__)if (-1 === [
264
- "default"
265
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
266
- Object.defineProperty(exports, '__esModule', {
267
- value: true
268
- });
193
+ export default contentScriptWrapper;
@@ -1,17 +1,3 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.r = (exports1)=>{
5
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
- value: 'Module'
7
- });
8
- Object.defineProperty(exports1, '__esModule', {
9
- value: true
10
- });
11
- };
12
- })();
13
- var __webpack_exports__ = {};
14
- __webpack_require__.r(__webpack_exports__);
15
1
  const EXTJS_MARK = '__extjs__';
16
2
  const REQ_TYPE = 'EXTJS_WTW_LOAD';
17
3
  const RES_TYPE = 'EXTJS_WTW_LOADED';
@@ -121,7 +107,3 @@ window.addEventListener('message', (event)=>{
121
107
  });
122
108
  });
123
109
  });
124
- for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
125
- Object.defineProperty(exports, '__esModule', {
126
- value: true
127
- });
@@ -1,17 +1,3 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.r = (exports1)=>{
5
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
- value: 'Module'
7
- });
8
- Object.defineProperty(exports1, '__esModule', {
9
- value: true
10
- });
11
- };
12
- })();
13
- var __webpack_exports__ = {};
14
- __webpack_require__.r(__webpack_exports__);
15
1
  const EXTJS_MARK = '__extjs__';
16
2
  const REQ_TYPE = 'EXTJS_WTW_LOAD';
17
3
  const RES_TYPE = 'EXTJS_WTW_LOADED';
@@ -121,7 +107,3 @@ window.addEventListener('message', (event)=>{
121
107
  });
122
108
  });
123
109
  });
124
- for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
125
- Object.defineProperty(exports, '__esModule', {
126
- value: true
127
- });
@@ -1,10 +1,5 @@
1
- var __webpack_exports__ = {};
2
1
  try {
3
2
  const loc = globalThis?.location;
4
3
  if (loc && 'function' != typeof loc.reload) loc.reload = ()=>{};
5
4
  } catch {}
6
5
  console.log('Minimum Chromium file loaded for reload purposes');
7
- for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
8
- Object.defineProperty(exports, '__esModule', {
9
- value: true
10
- });
@@ -0,0 +1,5 @@
1
+ try {
2
+ const loc = globalThis?.location;
3
+ if (loc && 'function' != typeof loc.reload) loc.reload = ()=>{};
4
+ } catch {}
5
+ console.log('Minimum Chromium file loaded for reload purposes');
@@ -1,10 +1,5 @@
1
- var __webpack_exports__ = {};
2
1
  try {
3
2
  const loc = globalThis?.location;
4
3
  if (loc && 'function' != typeof loc.reload) loc.reload = ()=>{};
5
4
  } catch {}
6
5
  console.log('Minimum Firefox file loaded for reload purposes');
7
- for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
8
- Object.defineProperty(exports, '__esModule', {
9
- value: true
10
- });
@@ -0,0 +1,5 @@
1
+ try {
2
+ const loc = globalThis?.location;
3
+ if (loc && 'function' != typeof loc.reload) loc.reload = ()=>{};
4
+ } catch {}
5
+ console.log('Minimum Firefox file loaded for reload purposes');