extension-develop 2.0.1 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -150,6 +150,32 @@ Options accepted by each command. Values shown are typical types or enumerations
150
150
  - browser.chrome | .firefox | .edge | .chromium-based | .gecko-based: launch flags, excluded flags, preferences, binaries, and profile reuse.
151
151
  - When detected, a one‑time notice is printed to indicate config is active.
152
152
 
153
+ ### Environment variables in `extension.config.*`
154
+
155
+ - `extension.config.*` runs in a Node context during command startup.
156
+ - Use `process.env.*` to read environment variables inside the config file.
157
+ - `import.meta.env.*` is available in your extension code at bundle time (via the Env plugin), not in the Node config.
158
+ - During config loading, develop preloads environment files from the project directory into `process.env` using the following order (first match wins):
159
+ 1. `.env.defaults` (always merged first when present)
160
+ 2. `.env.development`
161
+ 3. `.env.local`
162
+ 4. `.env`
163
+ - Only variables you read explicitly in the config are used there; client-side injection still requires the `EXTENSION_PUBLIC_*` prefix.
164
+ - Example:
165
+
166
+ ```js
167
+ // extension.config.js (Node-based)
168
+ export default {
169
+ browser: {
170
+ chrome: {
171
+ startingUrl:
172
+ process.env.EXTENSION_PUBLIC_START_URL || 'https://example.com'
173
+ }
174
+ },
175
+ config: (config) => config
176
+ }
177
+ ```
178
+
153
179
  ## Safety and ergonomics
154
180
 
155
181
  - Managed dependency guard: If your `extension.config.*` references dependencies that are managed by Extension.js itself, the command aborts with a detailed message to prevent version conflicts.
@@ -60,7 +60,17 @@ export async function handleFirstRun() {
60
60
  return
61
61
  }
62
62
 
63
- chrome.tabs.create({url: 'pages/welcome.html'})
63
+ // Guard against opening multiple welcome pages
64
+ chrome.tabs.query(
65
+ {url: chrome.runtime.getURL('pages/welcome.html')},
66
+ (tabs) => {
67
+ if (Array.isArray(tabs) && tabs.length > 0) {
68
+ // Already open; do not create another
69
+ return
70
+ }
71
+ chrome.tabs.create({url: 'pages/welcome.html'})
72
+ }
73
+ )
64
74
  // Ensure the welcome page shows only once per extension installation
65
75
  chrome.storage.local.set({[devExtension.id]: {didRun: true}})
66
76
  })
@@ -60,7 +60,17 @@ export async function handleFirstRun() {
60
60
  return
61
61
  }
62
62
 
63
- chrome.tabs.create({url: 'pages/welcome.html'})
63
+ // Guard against opening multiple welcome pages
64
+ chrome.tabs.query(
65
+ {url: chrome.runtime.getURL('pages/welcome.html')},
66
+ (tabs) => {
67
+ if (Array.isArray(tabs) && tabs.length > 0) {
68
+ // Already open; do not create another
69
+ return
70
+ }
71
+ chrome.tabs.create({url: 'pages/welcome.html'})
72
+ }
73
+ )
64
74
  // Ensure the welcome page shows only once per extension installation
65
75
  chrome.storage.local.set({[devExtension.id]: {didRun: true}})
66
76
  })
@@ -60,7 +60,17 @@ export async function handleFirstRun() {
60
60
  return
61
61
  }
62
62
 
63
- chrome.tabs.create({url: 'pages/welcome.html'})
63
+ // Guard against opening multiple welcome pages
64
+ chrome.tabs.query(
65
+ {url: chrome.runtime.getURL('pages/welcome.html')},
66
+ (tabs) => {
67
+ if (Array.isArray(tabs) && tabs.length > 0) {
68
+ // Already open; do not create another
69
+ return
70
+ }
71
+ chrome.tabs.create({url: 'pages/welcome.html'})
72
+ }
73
+ )
64
74
  // Ensure the welcome page shows only once per extension installation
65
75
  chrome.storage.local.set({[devExtension.id]: {didRun: true}})
66
76
  })
@@ -49,8 +49,12 @@ async function handleFirstRun() {
49
49
  return
50
50
  }
51
51
 
52
- // Open the welcome page
53
- await browser.tabs.create({url: './pages/welcome.html'})
52
+ // Open the welcome page only if not already open
53
+ const welcomeUrl = browser.runtime.getURL('./pages/welcome.html')
54
+ const existingWelcome = await browser.tabs.query({url: welcomeUrl})
55
+ if (!existingWelcome || existingWelcome.length === 0) {
56
+ await browser.tabs.create({url: './pages/welcome.html'})
57
+ }
54
58
 
55
59
  // Ensure the welcome page shows only once per extension installation
56
60
  await browser.storage.local.set({[devExtension.id]: {didRun: true}})
@@ -51,8 +51,12 @@ export async function handleFirstRun() {
51
51
  return
52
52
  }
53
53
 
54
- // Open the welcome page
55
- await browser.tabs.create({url: './pages/welcome.html'})
54
+ // Open the welcome page only if not already open
55
+ const welcomeUrl = browser.runtime.getURL('./pages/welcome.html')
56
+ const existingWelcome = await browser.tabs.query({url: welcomeUrl})
57
+ if (!existingWelcome || existingWelcome.length === 0) {
58
+ await browser.tabs.create({url: './pages/welcome.html'})
59
+ }
56
60
 
57
61
  // Ensure the welcome page shows only once per extension installation
58
62
  await browser.storage.local.set({[devExtension.id]: {didRun: true}})
@@ -30,6 +30,8 @@ const external_path_namespaceObject = require("path");
30
30
  const external_fs_namespaceObject = require("fs");
31
31
  const external_loader_utils_namespaceObject = require("loader-utils");
32
32
  const external_schema_utils_namespaceObject = require("schema-utils");
33
+ require("os");
34
+ require("crypto");
33
35
  require("child_process");
34
36
  require("package-manager-detector");
35
37
  require("pintor");
@@ -30,6 +30,8 @@ const external_path_namespaceObject = require("path");
30
30
  const external_fs_namespaceObject = require("fs");
31
31
  const external_loader_utils_namespaceObject = require("loader-utils");
32
32
  const external_schema_utils_namespaceObject = require("schema-utils");
33
+ require("os");
34
+ require("crypto");
33
35
  require("child_process");
34
36
  require("package-manager-detector");
35
37
  require("pintor");
package/dist/module.js CHANGED
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
3
+ return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
4
+ }();
2
5
  var __webpack_modules__ = {
3
6
  "./webpack/plugin-browsers/browsers-lib/add-progress-bar.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
4
7
  __webpack_require__.d(__webpack_exports__, {
@@ -29,9 +32,10 @@ var __webpack_modules__ = {
29
32
  f: ()=>DynamicExtensionManager
30
33
  });
31
34
  var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs/promises");
32
- var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("path");
33
- var crypto__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("crypto");
34
- var _webpack_lib_messages__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./webpack/webpack-lib/messages.ts");
35
+ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("fs");
36
+ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("path");
37
+ var crypto__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("crypto");
38
+ var _webpack_lib_messages__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./webpack/webpack-lib/messages.ts");
35
39
  function _define_property(obj, key, value) {
36
40
  if (key in obj) Object.defineProperty(obj, key, {
37
41
  value: value,
@@ -44,7 +48,7 @@ var __webpack_modules__ = {
44
48
  }
45
49
  class DynamicExtensionManager {
46
50
  generateExtensionKey() {
47
- const keyData = crypto__WEBPACK_IMPORTED_MODULE_2__.randomBytes(128);
51
+ const keyData = crypto__WEBPACK_IMPORTED_MODULE_3__.randomBytes(128);
48
52
  return keyData.toString('base64');
49
53
  }
50
54
  getBaseExtensionPath(browser) {
@@ -56,17 +60,17 @@ var __webpack_modules__ = {
56
60
  'gecko-based': 'gecko-based-manager-extension'
57
61
  };
58
62
  const extensionName = browserMap[browser] || 'chrome-manager-extension';
59
- return path__WEBPACK_IMPORTED_MODULE_1__.join(this.baseExtensionPath, extensionName);
63
+ return path__WEBPACK_IMPORTED_MODULE_2__.join(this.baseExtensionPath, extensionName);
60
64
  }
61
65
  async readBaseManifest(browser) {
62
66
  const basePath = this.getBaseExtensionPath(browser);
63
- const manifestPath = path__WEBPACK_IMPORTED_MODULE_1__.join(basePath, 'manifest.json');
67
+ const manifestPath = path__WEBPACK_IMPORTED_MODULE_2__.join(basePath, 'manifest.json');
64
68
  const manifestContent = await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(manifestPath, 'utf-8');
65
69
  return JSON.parse(manifestContent);
66
70
  }
67
71
  async readBaseServiceWorker(browser) {
68
72
  const basePath = this.getBaseExtensionPath(browser);
69
- const serviceWorkerPath = path__WEBPACK_IMPORTED_MODULE_1__.join(basePath, 'reload-service.js');
73
+ const serviceWorkerPath = path__WEBPACK_IMPORTED_MODULE_2__.join(basePath, 'reload-service.js');
70
74
  return await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(serviceWorkerPath, 'utf-8');
71
75
  }
72
76
  async generateExtension(instance) {
@@ -84,14 +88,14 @@ var __webpack_modules__ = {
84
88
  };
85
89
  const serviceWorkerContent = baseServiceWorker.replace(/const\s+port\s*=\s*['"](__RELOAD_PORT__|\d+)['"]/, `const port = '${instance.webSocketPort}'`).replace(/const\s+instanceId\s*=\s*['"](__INSTANCE_ID__|\w+)['"]/, `const instanceId = '${instance.instanceId}'`);
86
90
  const enhancedServiceWorker = `// Instance: ${instanceId}\n// Generated: ${new Date().toISOString()}\n// Cache-buster: ${Date.now()}\n\n${serviceWorkerContent}\n\n// Instance-specific logging\n${'development' === process.env.EXTENSION_ENV ? `console.log('[Extension.js DevTools] Instance ${instanceId} initialized on port ${instance.webSocketPort}');` : ''}\n`;
87
- const extensionPath = path__WEBPACK_IMPORTED_MODULE_1__.join(this.userExtensionsPath, `${instance.browser}-manager-${instance.port}`);
91
+ const extensionPath = path__WEBPACK_IMPORTED_MODULE_2__.join(this.userExtensionsPath, `${instance.browser}-manager-${instance.port}`);
88
92
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir(extensionPath, {
89
93
  recursive: true
90
94
  });
91
- const manifestPath = path__WEBPACK_IMPORTED_MODULE_1__.join(extensionPath, 'manifest.json');
95
+ const manifestPath = path__WEBPACK_IMPORTED_MODULE_2__.join(extensionPath, 'manifest.json');
92
96
  const manifestContent = JSON.stringify(manifest, null, 2).replace(/__INSTANCE_ID__/g, instance.instanceId);
93
97
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(manifestPath, manifestContent);
94
- const serviceWorkerPath = path__WEBPACK_IMPORTED_MODULE_1__.join(extensionPath, 'reload-service.js');
98
+ const serviceWorkerPath = path__WEBPACK_IMPORTED_MODULE_2__.join(extensionPath, 'reload-service.js');
95
99
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(serviceWorkerPath, enhancedServiceWorker);
96
100
  await this.copyExtensionFiles(instance.browser, extensionPath);
97
101
  return {
@@ -108,8 +112,8 @@ var __webpack_modules__ = {
108
112
  withFileTypes: true
109
113
  });
110
114
  for (const entry of entries)if (entry.isDirectory() && 'images' === entry.name) {
111
- const sourceImagesPath = path__WEBPACK_IMPORTED_MODULE_1__.join(basePath, 'images');
112
- const targetImagesPath = path__WEBPACK_IMPORTED_MODULE_1__.join(targetPath, 'images');
115
+ const sourceImagesPath = path__WEBPACK_IMPORTED_MODULE_2__.join(basePath, 'images');
116
+ const targetImagesPath = path__WEBPACK_IMPORTED_MODULE_2__.join(targetPath, 'images');
113
117
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir(targetImagesPath, {
114
118
  recursive: true
115
119
  });
@@ -117,13 +121,13 @@ var __webpack_modules__ = {
117
121
  withFileTypes: true
118
122
  });
119
123
  for (const imageEntry of imageEntries)if (imageEntry.isFile()) {
120
- const sourceImagePath = path__WEBPACK_IMPORTED_MODULE_1__.join(sourceImagesPath, imageEntry.name);
121
- const targetImagePath = path__WEBPACK_IMPORTED_MODULE_1__.join(targetImagesPath, imageEntry.name);
124
+ const sourceImagePath = path__WEBPACK_IMPORTED_MODULE_2__.join(sourceImagesPath, imageEntry.name);
125
+ const targetImagePath = path__WEBPACK_IMPORTED_MODULE_2__.join(targetImagesPath, imageEntry.name);
122
126
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.copyFile(sourceImagePath, targetImagePath);
123
127
  }
124
128
  } else if (entry.isDirectory() && 'pages' === entry.name) {
125
- const sourcePagesPath = path__WEBPACK_IMPORTED_MODULE_1__.join(basePath, 'pages');
126
- const targetPagesPath = path__WEBPACK_IMPORTED_MODULE_1__.join(targetPath, 'pages');
129
+ const sourcePagesPath = path__WEBPACK_IMPORTED_MODULE_2__.join(basePath, 'pages');
130
+ const targetPagesPath = path__WEBPACK_IMPORTED_MODULE_2__.join(targetPath, 'pages');
127
131
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir(targetPagesPath, {
128
132
  recursive: true
129
133
  });
@@ -131,17 +135,17 @@ var __webpack_modules__ = {
131
135
  withFileTypes: true
132
136
  });
133
137
  for (const pageEntry of pageEntries)if (pageEntry.isFile()) {
134
- const sourcePagePath = path__WEBPACK_IMPORTED_MODULE_1__.join(sourcePagesPath, pageEntry.name);
135
- const targetPagePath = path__WEBPACK_IMPORTED_MODULE_1__.join(targetPagesPath, pageEntry.name);
138
+ const sourcePagePath = path__WEBPACK_IMPORTED_MODULE_2__.join(sourcePagesPath, pageEntry.name);
139
+ const targetPagePath = path__WEBPACK_IMPORTED_MODULE_2__.join(targetPagesPath, pageEntry.name);
136
140
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.copyFile(sourcePagePath, targetPagePath);
137
141
  }
138
142
  } else if (entry.isFile() && 'manifest.json' !== entry.name && 'reload-service.js' !== entry.name) {
139
- const sourceFilePath = path__WEBPACK_IMPORTED_MODULE_1__.join(basePath, entry.name);
140
- const targetFilePath = path__WEBPACK_IMPORTED_MODULE_1__.join(targetPath, entry.name);
143
+ const sourceFilePath = path__WEBPACK_IMPORTED_MODULE_2__.join(basePath, entry.name);
144
+ const targetFilePath = path__WEBPACK_IMPORTED_MODULE_2__.join(targetPath, entry.name);
141
145
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.copyFile(sourceFilePath, targetFilePath);
142
146
  }
143
147
  } catch (error) {
144
- if ('development' === process.env.EXTENSION_ENV) console.warn(_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_3__.O3(error));
148
+ if ('development' === process.env.EXTENSION_ENV) console.warn(_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_4__.O3(error));
145
149
  }
146
150
  }
147
151
  async cleanupExtension(instanceId) {
@@ -149,10 +153,10 @@ var __webpack_modules__ = {
149
153
  const instanceManager = new InstanceManager(this.projectPath);
150
154
  const instance = await instanceManager.getInstance(instanceId);
151
155
  if (!instance) {
152
- if ('development' === process.env.EXTENSION_ENV) console.warn(_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_3__.ej(instanceId));
156
+ if ('development' === process.env.EXTENSION_ENV) console.warn(_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_4__.ej(instanceId));
153
157
  return;
154
158
  }
155
- const extensionPath = path__WEBPACK_IMPORTED_MODULE_1__.join(this.userExtensionsPath, `${instance.browser}-manager-${instance.port}`);
159
+ const extensionPath = path__WEBPACK_IMPORTED_MODULE_2__.join(this.userExtensionsPath, `${instance.browser}-manager-${instance.port}`);
156
160
  try {
157
161
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.rm(extensionPath, {
158
162
  recursive: true,
@@ -169,18 +173,18 @@ var __webpack_modules__ = {
169
173
  force: true
170
174
  });
171
175
  } catch (error) {
172
- if ('development' === process.env.EXTENSION_ENV) console.warn(_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_3__.rH(error));
176
+ if ('development' === process.env.EXTENSION_ENV) console.warn(_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_4__.rH(error));
173
177
  }
174
178
  }
175
179
  getExtensionPath(instanceId) {
176
- return path__WEBPACK_IMPORTED_MODULE_1__.join(this.userExtensionsPath, `manager-port-${instanceId}`);
180
+ return path__WEBPACK_IMPORTED_MODULE_2__.join(this.userExtensionsPath, `manager-port-${instanceId}`);
177
181
  }
178
182
  async extensionExists(instanceId) {
179
183
  const { InstanceManager } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "./webpack/plugin-browsers/browsers-lib/instance-manager.ts"));
180
184
  const instanceManager = new InstanceManager(this.projectPath);
181
185
  const instance = await instanceManager.getInstance(instanceId);
182
186
  if (!instance) return false;
183
- const extensionPath = path__WEBPACK_IMPORTED_MODULE_1__.join(this.userExtensionsPath, `${instance.browser}-manager-${instance.port}`);
187
+ const extensionPath = path__WEBPACK_IMPORTED_MODULE_2__.join(this.userExtensionsPath, `${instance.browser}-manager-${instance.port}`);
184
188
  try {
185
189
  await fs_promises__WEBPACK_IMPORTED_MODULE_0__.access(extensionPath);
186
190
  return true;
@@ -192,7 +196,7 @@ var __webpack_modules__ = {
192
196
  const exists = await this.extensionExists(instance.instanceId);
193
197
  if (!exists) return await this.generateExtension(instance);
194
198
  const extensionPath = this.getExtensionPath(instance.instanceId);
195
- const serviceWorkerPath = path__WEBPACK_IMPORTED_MODULE_1__.join(extensionPath, 'reload-service.js');
199
+ const serviceWorkerPath = path__WEBPACK_IMPORTED_MODULE_2__.join(extensionPath, 'reload-service.js');
196
200
  try {
197
201
  const content = await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(serviceWorkerPath, 'utf-8');
198
202
  const portMatch = content.match(/const\s+port\s*=\s*['"](\d+)['"]/);
@@ -208,7 +212,7 @@ var __webpack_modules__ = {
208
212
  return {
209
213
  extensionId: instance.managerExtensionId,
210
214
  manifest,
211
- serviceWorkerPath: path__WEBPACK_IMPORTED_MODULE_1__.join(extensionPath, 'reload-service.js'),
215
+ serviceWorkerPath: path__WEBPACK_IMPORTED_MODULE_2__.join(extensionPath, 'reload-service.js'),
212
216
  extensionPath
213
217
  };
214
218
  }
@@ -216,9 +220,27 @@ var __webpack_modules__ = {
216
220
  _define_property(this, "baseExtensionPath", void 0);
217
221
  _define_property(this, "projectPath", void 0);
218
222
  _define_property(this, "userExtensionsPath", void 0);
219
- this.baseExtensionPath = path__WEBPACK_IMPORTED_MODULE_1__.join(__dirname, '../webpack/plugin-reload/extensions');
223
+ const candidateBasePaths = [];
224
+ try {
225
+ const entryPath = require.resolve('extension-develop');
226
+ const distDir = path__WEBPACK_IMPORTED_MODULE_2__.dirname(entryPath);
227
+ candidateBasePaths.push(path__WEBPACK_IMPORTED_MODULE_2__.join(distDir, 'extensions'));
228
+ } catch {}
229
+ candidateBasePaths.push(path__WEBPACK_IMPORTED_MODULE_2__.join(__dirname, 'extensions'));
230
+ candidateBasePaths.push(path__WEBPACK_IMPORTED_MODULE_2__.join(__dirname, 'dist', 'extensions'));
231
+ candidateBasePaths.push(path__WEBPACK_IMPORTED_MODULE_2__.join(__dirname, 'programs', 'develop', 'dist', 'extensions'));
232
+ candidateBasePaths.push(path__WEBPACK_IMPORTED_MODULE_2__.join(process.cwd(), 'node_modules', 'extension-develop', 'dist', 'extensions'));
233
+ candidateBasePaths.push(path__WEBPACK_IMPORTED_MODULE_2__.join(__dirname, '..', '..', 'plugin-reload', 'extensions'));
234
+ let resolvedBasePath = candidateBasePaths[0];
235
+ for (const candidate of candidateBasePaths)try {
236
+ if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(candidate)) {
237
+ resolvedBasePath = candidate;
238
+ break;
239
+ }
240
+ } catch {}
241
+ this.baseExtensionPath = resolvedBasePath;
220
242
  this.projectPath = projectPath || process.cwd();
221
- this.userExtensionsPath = path__WEBPACK_IMPORTED_MODULE_1__.join(this.projectPath, 'dist', 'extension-js', 'extensions');
243
+ this.userExtensionsPath = path__WEBPACK_IMPORTED_MODULE_2__.join(this.projectPath, 'dist', 'extension-js', 'extensions');
222
244
  }
223
245
  }
224
246
  },
@@ -226,12 +248,12 @@ var __webpack_modules__ = {
226
248
  __webpack_require__.d(__webpack_exports__, {
227
249
  InstanceManager: ()=>InstanceManager
228
250
  });
229
- var promises_ = __webpack_require__("fs/promises");
230
- var external_path_ = __webpack_require__("path");
231
- const external_os_namespaceObject = require("os");
232
- var external_crypto_ = __webpack_require__("crypto");
233
- var external_net_ = __webpack_require__("net");
234
- var messages = __webpack_require__("./webpack/webpack-lib/messages.ts");
251
+ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("fs/promises");
252
+ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("path");
253
+ var os__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("os");
254
+ var crypto__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("crypto");
255
+ var net__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("net");
256
+ var _webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./webpack/webpack-lib/messages.ts");
235
257
  function _define_property(obj, key, value) {
236
258
  if (key in obj) Object.defineProperty(obj, key, {
237
259
  value: value,
@@ -248,21 +270,21 @@ var __webpack_modules__ = {
248
270
  const isWSL = process.env.WSL_DISTRO_NAME || process.env.WSLENV;
249
271
  switch(platform){
250
272
  case 'darwin':
251
- return external_path_.join(external_os_namespaceObject.homedir(), 'Library', 'Application Support', 'extension-js');
273
+ return path__WEBPACK_IMPORTED_MODULE_1__.join(os__WEBPACK_IMPORTED_MODULE_2__.homedir(), 'Library', 'Application Support', 'extension-js');
252
274
  case 'win32':
253
- return external_path_.join(process.env.APPDATA || '', 'extension-js');
275
+ return path__WEBPACK_IMPORTED_MODULE_1__.join(process.env.APPDATA || '', 'extension-js');
254
276
  case 'linux':
255
277
  if (isWSL) {
256
278
  const windowsAppData = process.env.APPDATA;
257
- if (windowsAppData) return external_path_.join(windowsAppData, 'extension-js');
279
+ if (windowsAppData) return path__WEBPACK_IMPORTED_MODULE_1__.join(windowsAppData, 'extension-js');
258
280
  }
259
- return external_path_.join(external_os_namespaceObject.homedir(), '.config', 'extension-js');
281
+ return path__WEBPACK_IMPORTED_MODULE_1__.join(os__WEBPACK_IMPORTED_MODULE_2__.homedir(), '.config', 'extension-js');
260
282
  default:
261
- return external_path_.join(external_os_namespaceObject.homedir(), '.extension-js');
283
+ return path__WEBPACK_IMPORTED_MODULE_1__.join(os__WEBPACK_IMPORTED_MODULE_2__.homedir(), '.extension-js');
262
284
  }
263
285
  }
264
286
  generateInstanceId() {
265
- return external_crypto_.randomBytes(8).toString('hex');
287
+ return crypto__WEBPACK_IMPORTED_MODULE_3__.randomBytes(8).toString('hex');
266
288
  }
267
289
  generateManagerExtensionId() {
268
290
  const chars = 'abcdefghijklmnopqrstuvwxyz';
@@ -271,11 +293,11 @@ var __webpack_modules__ = {
271
293
  return result;
272
294
  }
273
295
  async ensureRegistryDir() {
274
- const dir = external_path_.dirname(this.registryPath);
296
+ const dir = path__WEBPACK_IMPORTED_MODULE_1__.dirname(this.registryPath);
275
297
  try {
276
- await promises_.access(dir);
298
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.access(dir);
277
299
  } catch {
278
- await promises_.mkdir(dir, {
300
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir(dir, {
279
301
  recursive: true
280
302
  });
281
303
  }
@@ -283,7 +305,7 @@ var __webpack_modules__ = {
283
305
  async loadRegistry() {
284
306
  try {
285
307
  await this.ensureRegistryDir();
286
- const data = await promises_.readFile(this.registryPath, 'utf-8');
308
+ const data = await fs_promises__WEBPACK_IMPORTED_MODULE_0__.readFile(this.registryPath, 'utf-8');
287
309
  return JSON.parse(data);
288
310
  } catch {
289
311
  return {
@@ -296,16 +318,16 @@ var __webpack_modules__ = {
296
318
  try {
297
319
  await this.ensureRegistryDir();
298
320
  const data = JSON.stringify(registry, null, 2);
299
- await promises_.writeFile(this.registryPath, data);
300
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.xc(this.registryPath));
321
+ await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(this.registryPath, data);
322
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.xc(this.registryPath));
301
323
  } catch (error) {
302
- if ('development' === process.env.EXTENSION_ENV) console.error(messages.b9(error));
324
+ if ('development' === process.env.EXTENSION_ENV) console.error(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.b9(error));
303
325
  throw error;
304
326
  }
305
327
  }
306
328
  async isPortAvailable(port) {
307
329
  const check = (host)=>new Promise((resolve)=>{
308
- const server = external_net_.createServer();
330
+ const server = net__WEBPACK_IMPORTED_MODULE_4__.createServer();
309
331
  const complete = (result)=>{
310
332
  try {
311
333
  server.close(()=>resolve(result));
@@ -345,25 +367,25 @@ var __webpack_modules__ = {
345
367
  const usedPorts = existingInstances.filter((instance)=>'running' === instance.status).map((instance)=>instance.port);
346
368
  const usedWebSocketPorts = existingInstances.filter((instance)=>'running' === instance.status).map((instance)=>instance.webSocketPort);
347
369
  if ('development' === process.env.EXTENSION_ENV) {
348
- console.log(messages.EP(usedPorts));
349
- console.log(messages.Hh(usedWebSocketPorts));
370
+ console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.EP(usedPorts));
371
+ console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.Hh(usedWebSocketPorts));
350
372
  }
351
373
  if (requestedPort) {
352
374
  const isPortAvailable = await this.isPortAvailable(requestedPort);
353
375
  if (isPortAvailable && !usedPorts.includes(requestedPort)) {
354
376
  const webSocketPort = await this.findAvailableWebSocketPort(usedWebSocketPorts);
355
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.G(requestedPort, webSocketPort));
377
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.G(requestedPort, webSocketPort));
356
378
  return {
357
379
  port: requestedPort,
358
380
  webSocketPort
359
381
  };
360
382
  }
361
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.S8(requestedPort));
383
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.S8(requestedPort));
362
384
  }
363
385
  let port = this.basePort;
364
386
  while(usedPorts.includes(port) || !await this.isPortAvailable(port))port++;
365
387
  const webSocketPort = await this.findAvailableWebSocketPort(usedWebSocketPorts);
366
- if ('development' === process.env.EXTENSION_ENV) console.log(messages._Z(port, webSocketPort));
388
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__._Z(port, webSocketPort));
367
389
  return {
368
390
  port,
369
391
  webSocketPort
@@ -383,18 +405,18 @@ var __webpack_modules__ = {
383
405
  if ('terminated' === instance.status || 'error' === instance.status || now - instance.startTime > maxAge) shouldRemove = true;
384
406
  else if (await this.isProcessRunning(instance.processId)) {
385
407
  if (await this.isPortAvailable(instance.port) && await this.isPortAvailable(instance.webSocketPort)) {
386
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.Y_(instanceId, instance.port, instance.webSocketPort));
408
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.Y_(instanceId, instance.port, instance.webSocketPort));
387
409
  shouldRemove = true;
388
410
  }
389
411
  } else {
390
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.jQ(instanceId, instance.processId));
412
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.jQ(instanceId, instance.processId));
391
413
  shouldRemove = true;
392
414
  }
393
415
  if (shouldRemove) instancesToRemove.push(instanceId);
394
416
  }
395
417
  for (const instanceId of instancesToRemove){
396
418
  delete registry.instances[instanceId];
397
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.Hl(instanceId));
419
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.Hl(instanceId));
398
420
  }
399
421
  registry.lastCleanup = now;
400
422
  }
@@ -409,7 +431,7 @@ var __webpack_modules__ = {
409
431
  async monitorProcessHealth(instanceId) {
410
432
  const instance = await this.getInstance(instanceId);
411
433
  if (!instance) return;
412
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.oN(instanceId));
434
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.oN(instanceId));
413
435
  const healthCheck = setInterval(async ()=>{
414
436
  try {
415
437
  const isHealthy = await this.isProcessRunning(instance.processId);
@@ -417,13 +439,13 @@ var __webpack_modules__ = {
417
439
  const isCurrentProcess = instance.processId === process.pid;
418
440
  const definitelyOrphaned = !isCurrentProcess && !isHealthy && !portsInUse;
419
441
  if (definitelyOrphaned) {
420
- console.log(messages.zd(instanceId));
442
+ console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.zd(instanceId));
421
443
  await this.terminateInstance(instanceId);
422
444
  clearInterval(healthCheck);
423
445
  this.healthChecks.delete(instanceId);
424
- } else if ('development' === process.env.EXTENSION_ENV) console.log(messages.IV(instanceId));
446
+ } else if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.IV(instanceId));
425
447
  } catch (error) {
426
- console.error(messages.Es(instanceId, error));
448
+ console.error(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.Es(instanceId, error));
427
449
  clearInterval(healthCheck);
428
450
  this.healthChecks.delete(instanceId);
429
451
  }
@@ -436,32 +458,32 @@ var __webpack_modules__ = {
436
458
  return portInUse || webSocketPortInUse;
437
459
  }
438
460
  async forceCleanupProjectProcesses(projectPath) {
439
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.r6(projectPath));
461
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.r6(projectPath));
440
462
  const registry = await this.loadRegistry();
441
463
  const projectInstances = Object.values(registry.instances).filter((instance)=>instance.projectPath === projectPath);
442
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.dQ(projectInstances.length));
464
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.dQ(projectInstances.length));
443
465
  for (const instance of projectInstances)try {
444
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.j4(instance.instanceId));
466
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.j4(instance.instanceId));
445
467
  if (await this.isProcessRunning(instance.processId)) {
446
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.qb(instance.processId));
468
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.qb(instance.processId));
447
469
  process.kill(instance.processId, 'SIGTERM');
448
470
  setTimeout(()=>{
449
471
  try {
450
472
  process.kill(instance.processId, 'SIGKILL');
451
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.o2(instance.processId));
473
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.o2(instance.processId));
452
474
  } catch (error) {}
453
475
  }, 3000);
454
476
  }
455
477
  instance.status = 'terminated';
456
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.J9(instance.instanceId));
478
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.J9(instance.instanceId));
457
479
  } catch (error) {
458
- if ('development' === process.env.EXTENSION_ENV) console.error(messages.Wc(instance.instanceId, error));
480
+ if ('development' === process.env.EXTENSION_ENV) console.error(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.Wc(instance.instanceId, error));
459
481
  }
460
482
  await this.saveRegistry(registry);
461
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.JJ());
483
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.JJ());
462
484
  }
463
485
  async createInstance(browser, projectPath, requestedPort) {
464
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.jE({
486
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.jE({
465
487
  browser,
466
488
  projectPath,
467
489
  requestedPort
@@ -481,12 +503,12 @@ var __webpack_modules__ = {
481
503
  startTime: Date.now(),
482
504
  status: 'running',
483
505
  processId: process.pid,
484
- profilePath: external_path_.join(external_os_namespaceObject.tmpdir(), `extension-js-${instanceId}`)
506
+ profilePath: path__WEBPACK_IMPORTED_MODULE_1__.join(os__WEBPACK_IMPORTED_MODULE_2__.tmpdir(), `extension-js-${instanceId}`)
485
507
  };
486
508
  registry.instances[instanceId] = instance;
487
509
  await this.saveRegistry(registry);
488
510
  await this.monitorProcessHealth(instanceId);
489
- if ('development' === process.env.EXTENSION_ENV) console.log(messages.pU(registry));
511
+ if ('development' === process.env.EXTENSION_ENV) console.log(_webpack_webpack_lib_messages__WEBPACK_IMPORTED_MODULE_5__.pU(registry));
490
512
  return instance;
491
513
  }
492
514
  async updateInstance(instanceId, updates) {
@@ -569,7 +591,7 @@ var __webpack_modules__ = {
569
591
  _define_property(this, "healthChecks", new Map());
570
592
  this.basePort = basePort;
571
593
  this.baseWebSocketPort = baseWebSocketPort;
572
- this.registryPath = external_path_.join(this.getDataDirectory(), 'instances.json');
594
+ this.registryPath = path__WEBPACK_IMPORTED_MODULE_1__.join(this.getDataDirectory(), 'instances.json');
573
595
  }
574
596
  }
575
597
  },
@@ -3309,6 +3331,9 @@ var __webpack_modules__ = {
3309
3331
  net: function(module) {
3310
3332
  module.exports = require("net");
3311
3333
  },
3334
+ os: function(module) {
3335
+ module.exports = require("os");
3336
+ },
3312
3337
  path: function(module) {
3313
3338
  module.exports = require("path");
3314
3339
  },
@@ -3319,7 +3344,7 @@ var __webpack_modules__ = {
3319
3344
  module.exports = require("util");
3320
3345
  },
3321
3346
  "./package.json": function(module) {
3322
- module.exports = JSON.parse('{"i8":"2.0.1","HO":{"@rspack/core":"^1.4.8","@rspack/dev-server":"^1.1.3","@swc/helpers":"^0.5.15","@types/webextension-polyfill":"0.12.3","@vue/compiler-sfc":"^3.5.13","adm-zip":"^0.5.16","axios":"^1.9.0","case-sensitive-paths-webpack-plugin":"^2.4.0","chokidar":"^4.0.1","chrome-location2":"2.0.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^16.4.7","dotenv-webpack":"^8.1.0","edge-location":"^1.1.1","firefox-location2":"1.0.0","firefox-profile":"^4.7.0","go-git-it":"^5.0.0","ignore":"^6.0.2","loader-utils":"^3.3.1","locate-path":"^7.2.0","micromatch":"^4.0.8","package-manager-detector":"^0.2.7","parse5":"^7.2.1","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"^8.4.49","preact":"^10.22.0","progress":"^2.0.3","schema-utils":"^4.2.0","slugify":"^1.6.6","tiny-glob":"^0.2.9","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.18.0"},"Lq":{"@prefresh/core":"^1.5.2","@prefresh/utils":"^1.2.0","@prefresh/webpack":"^4.0.1","@rspack/plugin-preact-refresh":"^1.1.2","@rspack/plugin-react-refresh":"^1.0.1","babel-loader":"^9.2.1","less-loader":"^12.2.0","postcss-loader":"^8.1.1","postcss-preset-env":"^10.1.1","react-refresh":"^0.14.2","sass-loader":"^16.0.4","svelte-loader":"^3.2.4","vue-loader":"^17.4.2","vue-style-loader":"^4.1.3"}}');
3347
+ module.exports = JSON.parse('{"i8":"2.0.4","HO":{"@rspack/core":"^1.4.8","@rspack/dev-server":"^1.1.3","@swc/helpers":"^0.5.15","@types/webextension-polyfill":"0.12.3","@vue/compiler-sfc":"^3.5.13","adm-zip":"^0.5.16","axios":"^1.9.0","case-sensitive-paths-webpack-plugin":"^2.4.0","chokidar":"^4.0.1","chrome-location2":"2.0.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^16.4.7","dotenv-webpack":"^8.1.0","edge-location":"^1.1.1","firefox-location2":"1.0.0","firefox-profile":"^4.7.0","go-git-it":"^5.0.0","ignore":"^6.0.2","loader-utils":"^3.3.1","locate-path":"^7.2.0","micromatch":"^4.0.8","package-manager-detector":"^0.2.7","parse5":"^7.2.1","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"^8.4.49","preact":"^10.22.0","progress":"^2.0.3","schema-utils":"^4.2.0","slugify":"^1.6.6","tiny-glob":"^0.2.9","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.18.0"},"Lq":{"@prefresh/core":"^1.5.2","@prefresh/utils":"^1.2.0","@prefresh/webpack":"^4.0.1","@rspack/plugin-preact-refresh":"^1.1.2","@rspack/plugin-react-refresh":"^1.0.1","babel-loader":"^9.2.1","less-loader":"^12.2.0","postcss-loader":"^8.1.1","postcss-preset-env":"^10.1.1","react-refresh":"^0.14.2","sass-loader":"^16.0.4","svelte-loader":"^3.2.4","vue-loader":"^17.4.2","vue-style-loader":"^4.1.3"}}');
3323
3348
  }
3324
3349
  };
3325
3350
  var __webpack_module_cache__ = {};
@@ -3383,6 +3408,7 @@ var __webpack_exports__ = {};
3383
3408
  const external_case_sensitive_paths_webpack_plugin_namespaceObject = require("case-sensitive-paths-webpack-plugin");
3384
3409
  var external_case_sensitive_paths_webpack_plugin_default = /*#__PURE__*/ __webpack_require__.n(external_case_sensitive_paths_webpack_plugin_namespaceObject);
3385
3410
  const external_dotenv_namespaceObject = require("dotenv");
3411
+ var external_dotenv_default = /*#__PURE__*/ __webpack_require__.n(external_dotenv_namespaceObject);
3386
3412
  function _define_property(obj, key, value) {
3387
3413
  if (key in obj) Object.defineProperty(obj, key, {
3388
3414
  value: value,
@@ -3562,6 +3588,8 @@ var __webpack_exports__ = {};
3562
3588
  }
3563
3589
  }
3564
3590
  plugin_compilation_define_property(CompilationPlugin, "name", 'plugin-compilation');
3591
+ var external_os_ = __webpack_require__("os");
3592
+ var external_crypto_ = __webpack_require__("crypto");
3565
3593
  var external_child_process_ = __webpack_require__("child_process");
3566
3594
  const external_package_manager_detector_namespaceObject = require("package-manager-detector");
3567
3595
  var constants = __webpack_require__("./webpack/webpack-lib/constants.ts");
@@ -3682,6 +3710,62 @@ var __webpack_exports__ = {};
3682
3710
  const distPath = external_path_.dirname(outputPath);
3683
3711
  return !external_fs_.existsSync(external_path_.resolve(distPath, 'extension-js', 'profiles', `${browser}-profile`));
3684
3712
  }
3713
+ function getDataDirectory() {
3714
+ const platform = process.platform;
3715
+ const isWSL = process.env.WSL_DISTRO_NAME || process.env.WSLENV;
3716
+ switch(platform){
3717
+ case 'darwin':
3718
+ return external_path_.join(external_os_.homedir(), 'Library', 'Application Support', 'extension-js');
3719
+ case 'win32':
3720
+ return external_path_.join(process.env.APPDATA || '', 'extension-js');
3721
+ case 'linux':
3722
+ if (isWSL) {
3723
+ const windowsAppData = process.env.APPDATA;
3724
+ if (windowsAppData) return external_path_.join(windowsAppData, 'extension-js');
3725
+ }
3726
+ return external_path_.join(external_os_.homedir(), '.config', 'extension-js');
3727
+ default:
3728
+ return external_path_.join(external_os_.homedir(), '.extension-js');
3729
+ }
3730
+ }
3731
+ function getFirstRunFlagsDir() {
3732
+ return external_path_.join(getDataDirectory(), 'first-run');
3733
+ }
3734
+ function hashProject(projectPath) {
3735
+ try {
3736
+ return external_crypto_.createHash('sha1').update(projectPath).digest('hex').slice(0, 12);
3737
+ } catch {
3738
+ return Buffer.from(projectPath).toString('hex').slice(0, 12);
3739
+ }
3740
+ }
3741
+ function getFirstRunFlagPath(projectPath, browser) {
3742
+ const dir = getFirstRunFlagsDir();
3743
+ const key = `${hashProject(projectPath)}-${browser}.flag`;
3744
+ return external_path_.join(dir, key);
3745
+ }
3746
+ function hasShownFirstRunMessage(projectPath, browser) {
3747
+ try {
3748
+ const flagPath = getFirstRunFlagPath(projectPath, browser);
3749
+ return external_fs_.existsSync(flagPath);
3750
+ } catch {
3751
+ return false;
3752
+ }
3753
+ }
3754
+ function markFirstRunMessageShown(projectPath, browser) {
3755
+ try {
3756
+ const dir = getFirstRunFlagsDir();
3757
+ if (!external_fs_.existsSync(dir)) external_fs_.mkdirSync(dir, {
3758
+ recursive: true
3759
+ });
3760
+ const flagPath = getFirstRunFlagPath(projectPath, browser);
3761
+ external_fs_.writeFileSync(flagPath, '1', 'utf8');
3762
+ } catch {}
3763
+ }
3764
+ function shouldShowFirstRun(outputPath, browser, projectPath) {
3765
+ const firstByProfile = isFirstRun(outputPath, browser);
3766
+ if (!firstByProfile) return false;
3767
+ return !hasShownFirstRunMessage(projectPath, browser);
3768
+ }
3685
3769
  function filterKeysForThisBrowser(manifest, browser) {
3686
3770
  const patchedManifest = JSON.parse(JSON.stringify(manifest), function(key, value) {
3687
3771
  const indexOfColon = key.indexOf(':');
@@ -7815,9 +7899,12 @@ var __webpack_exports__ = {};
7815
7899
  });
7816
7900
  console.log(emptyLine());
7817
7901
  console.log(runningInDevelopment(manifest, options.browser, message));
7818
- if (isFirstRun(compiler.options.output.path, options.browser)) {
7902
+ const projectPath = compiler.options.context || process.cwd();
7903
+ const outPath = compiler.options.output.path;
7904
+ if (shouldShowFirstRun(outPath, options.browser, projectPath)) {
7819
7905
  console.log(emptyLine());
7820
7906
  console.log(messages_isFirstRun(options.browser));
7907
+ markFirstRunMessageShown(projectPath, options.browser);
7821
7908
  }
7822
7909
  console.log(emptyLine());
7823
7910
  }
@@ -9948,13 +10035,77 @@ var __webpack_exports__ = {};
9948
10035
  throw error;
9949
10036
  }
9950
10037
  }
10038
+ function preloadEnvFiles(projectDir) {
10039
+ try {
10040
+ const defaultsPath = external_path_.join(projectDir, '.env.defaults');
10041
+ if (external_fs_.existsSync(defaultsPath)) external_dotenv_default().config({
10042
+ path: defaultsPath
10043
+ });
10044
+ const envCandidates = [
10045
+ '.env.development',
10046
+ '.env.local',
10047
+ '.env'
10048
+ ];
10049
+ for (const filename of envCandidates){
10050
+ const filePath = external_path_.join(projectDir, filename);
10051
+ if (external_fs_.existsSync(filePath)) {
10052
+ external_dotenv_default().config({
10053
+ path: filePath
10054
+ });
10055
+ break;
10056
+ }
10057
+ }
10058
+ } catch {}
10059
+ }
9951
10060
  async function loadConfigFile(configPath) {
9952
10061
  const absolutePath = external_path_.resolve(configPath);
10062
+ const projectDir = external_path_.dirname(absolutePath);
10063
+ preloadEnvFiles(projectDir);
9953
10064
  try {
9954
- const module = await import((0, external_url_namespaceObject.pathToFileURL)(absolutePath).href);
10065
+ if (absolutePath.endsWith('.cjs')) {
10066
+ const requireFn = (0, external_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
10067
+ const required = requireFn(absolutePath);
10068
+ return (null == required ? void 0 : required.default) || required;
10069
+ }
10070
+ let esmImportPath = absolutePath;
10071
+ try {
10072
+ const originalContent = external_fs_.readFileSync(absolutePath, 'utf-8');
10073
+ if (originalContent.includes('import.meta.env')) {
10074
+ const tmpDir = external_fs_.mkdtempSync(external_path_.join(external_os_.tmpdir(), 'extension-config-esm-'));
10075
+ const tmpPath = external_path_.join(tmpDir, external_path_.basename(absolutePath));
10076
+ const envObjectLiteral = JSON.stringify(Object.fromEntries(Object.entries(process.env).map(([k, v])=>[
10077
+ k,
10078
+ v
10079
+ ])), null, 0);
10080
+ const shimHeader = `const __IMPORT_META_ENV__ = Object.freeze(${envObjectLiteral});\n`;
10081
+ const replaced = originalContent.replace(/import\.meta\.env/g, '__IMPORT_META_ENV__');
10082
+ external_fs_.writeFileSync(tmpPath, `${shimHeader}${replaced}`, 'utf-8');
10083
+ esmImportPath = tmpPath;
10084
+ }
10085
+ } catch {}
10086
+ const module = await import((0, external_url_namespaceObject.pathToFileURL)(esmImportPath).href);
9955
10087
  return module.default || module;
9956
10088
  } catch (err) {
9957
10089
  const error = err;
10090
+ try {
10091
+ if (!absolutePath.endsWith('.mjs')) {
10092
+ const requireFn = (0, external_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
10093
+ let required;
10094
+ try {
10095
+ required = requireFn(absolutePath);
10096
+ } catch (requireErr) {
10097
+ const message = String((null == error ? void 0 : error.message) || '') + ' ' + String((null == requireErr ? void 0 : requireErr.message) || '');
10098
+ const looksLikeCommonJsInEsm = message.includes('require is not defined in ES module scope') || message.includes('Cannot use import statement outside a module') || message.includes('ERR_REQUIRE_ESM');
10099
+ if (looksLikeCommonJsInEsm) {
10100
+ const tmpDir = external_fs_.mkdtempSync(external_path_.join(external_os_.tmpdir(), 'extension-config-'));
10101
+ const tmpCjsPath = external_path_.join(tmpDir, external_path_.basename(absolutePath, external_path_.extname(absolutePath)) + '.cjs');
10102
+ external_fs_.copyFileSync(absolutePath, tmpCjsPath);
10103
+ required = requireFn(tmpCjsPath);
10104
+ } else throw requireErr;
10105
+ }
10106
+ return (null == required ? void 0 : required.default) || required;
10107
+ }
10108
+ } catch {}
9958
10109
  try {
9959
10110
  const content = external_fs_.readFileSync(absolutePath, 'utf-8');
9960
10111
  return JSON.parse(content);
@@ -9966,14 +10117,20 @@ var __webpack_exports__ = {};
9966
10117
  async function loadCustomWebpackConfig(projectPath) {
9967
10118
  const userConfigPath = external_path_.join(projectPath, 'extension.config.js');
9968
10119
  const moduleUserConfigPath = external_path_.join(projectPath, 'extension.config.mjs');
9969
- if (external_fs_.existsSync(userConfigPath) || external_fs_.existsSync(moduleUserConfigPath)) {
9970
- const configPath = external_fs_.existsSync(userConfigPath) ? userConfigPath : moduleUserConfigPath;
10120
+ const commonJsUserConfigPath = external_path_.join(projectPath, 'extension.config.cjs');
10121
+ const candidates = [
10122
+ userConfigPath,
10123
+ moduleUserConfigPath,
10124
+ commonJsUserConfigPath
10125
+ ];
10126
+ const configPath = candidates.find((p)=>external_fs_.existsSync(p));
10127
+ if (configPath) {
9971
10128
  if (await get_extension_config_isUsingExperimentalConfig(projectPath)) try {
9972
10129
  const userConfig = await loadConfigFile(configPath);
9973
10130
  if (userConfig && 'function' == typeof userConfig.config) return userConfig.config;
9974
10131
  } catch (err) {
9975
10132
  const error = err;
9976
- console.error(configLoadingError('extension.config.js', error));
10133
+ console.error(configLoadingError(configPath, error));
9977
10134
  throw err;
9978
10135
  }
9979
10136
  }
@@ -9982,14 +10139,20 @@ var __webpack_exports__ = {};
9982
10139
  async function loadCommandConfig(projectPath, command) {
9983
10140
  const userConfigPath = external_path_.join(projectPath, 'extension.config.js');
9984
10141
  const moduleUserConfigPath = external_path_.join(projectPath, 'extension.config.mjs');
9985
- const configPath = external_fs_.existsSync(userConfigPath) ? userConfigPath : moduleUserConfigPath;
9986
- if (external_fs_.existsSync(userConfigPath) || external_fs_.existsSync(moduleUserConfigPath)) {
10142
+ const commonJsUserConfigPath = external_path_.join(projectPath, 'extension.config.cjs');
10143
+ const candidates = [
10144
+ userConfigPath,
10145
+ moduleUserConfigPath,
10146
+ commonJsUserConfigPath
10147
+ ];
10148
+ const configPath = candidates.find((p)=>external_fs_.existsSync(p));
10149
+ if (configPath) {
9987
10150
  if (await get_extension_config_isUsingExperimentalConfig(projectPath)) try {
9988
10151
  const userConfig = await loadConfigFile(configPath);
9989
10152
  if (userConfig && userConfig.commands && userConfig.commands[command]) return userConfig.commands[command];
9990
10153
  } catch (err) {
9991
10154
  const error = err;
9992
- console.error(configLoadingError('command config', error));
10155
+ console.error(configLoadingError(configPath, error));
9993
10156
  throw err;
9994
10157
  }
9995
10158
  }
@@ -9998,14 +10161,20 @@ var __webpack_exports__ = {};
9998
10161
  async function loadBrowserConfig(projectPath, browser = 'chrome') {
9999
10162
  const userConfigPath = external_path_.join(projectPath, 'extension.config.js');
10000
10163
  const moduleUserConfigPath = external_path_.join(projectPath, 'extension.config.mjs');
10001
- const configPath = external_fs_.existsSync(userConfigPath) ? userConfigPath : moduleUserConfigPath;
10002
- if (external_fs_.existsSync(userConfigPath) || external_fs_.existsSync(moduleUserConfigPath)) {
10164
+ const commonJsUserConfigPath = external_path_.join(projectPath, 'extension.config.cjs');
10165
+ const candidates = [
10166
+ userConfigPath,
10167
+ moduleUserConfigPath,
10168
+ commonJsUserConfigPath
10169
+ ];
10170
+ const configPath = candidates.find((p)=>external_fs_.existsSync(p));
10171
+ if (configPath) {
10003
10172
  if (await get_extension_config_isUsingExperimentalConfig(projectPath)) try {
10004
10173
  const userConfig = await loadConfigFile(configPath);
10005
10174
  if (userConfig && userConfig.browser && userConfig.browser[browser]) return userConfig.browser[browser];
10006
10175
  } catch (err) {
10007
10176
  const error = err;
10008
- console.error(configLoadingError('browser config', error));
10177
+ console.error(configLoadingError(configPath, error));
10009
10178
  throw err;
10010
10179
  }
10011
10180
  }
@@ -10017,8 +10186,14 @@ var __webpack_exports__ = {};
10017
10186
  async function get_extension_config_isUsingExperimentalConfig(projectPath) {
10018
10187
  const userConfigPath = external_path_.join(projectPath, 'extension.config.js');
10019
10188
  const moduleUserConfigPath = external_path_.join(projectPath, 'extension.config.mjs');
10020
- const configPath = external_fs_.existsSync(userConfigPath) ? userConfigPath : moduleUserConfigPath;
10021
- if (external_fs_.existsSync(configPath) || external_fs_.existsSync(moduleUserConfigPath)) {
10189
+ const commonJsUserConfigPath = external_path_.join(projectPath, 'extension.config.cjs');
10190
+ const candidates = [
10191
+ userConfigPath,
10192
+ moduleUserConfigPath,
10193
+ commonJsUserConfigPath
10194
+ ];
10195
+ const configPath = candidates.find((p)=>external_fs_.existsSync(p));
10196
+ if (configPath) {
10022
10197
  if (!get_extension_config_userMessageDelivered) {
10023
10198
  console.log(isUsingExperimentalConfig('extension.config.js'));
10024
10199
  get_extension_config_userMessageDelivered = true;
@@ -10314,7 +10489,11 @@ var __webpack_exports__ = {};
10314
10489
  });
10315
10490
  const customWebpackConfig = await loadCustomWebpackConfig(manifestDir);
10316
10491
  const finalConfig = customWebpackConfig(baseConfig);
10317
- const compilerConfig = (0, external_webpack_merge_namespaceObject.merge)(finalConfig);
10492
+ const compilerConfig = (0, external_webpack_merge_namespaceObject.merge)(finalConfig, {
10493
+ infrastructureLogging: {
10494
+ level: 'error'
10495
+ }
10496
+ });
10318
10497
  const compiler = (0, core_namespaceObject.rspack)(compilerConfig);
10319
10498
  const port = portAllocation.port;
10320
10499
  if (void 0 !== devOptions.port && devOptions.port !== port) {
@@ -10343,7 +10522,7 @@ var __webpack_exports__ = {};
10343
10522
  }
10344
10523
  },
10345
10524
  client: {
10346
- logging: 'development' === process.env.EXTENSION_ENV ? 'error' : 'none',
10525
+ logging: 'none',
10347
10526
  progress: false,
10348
10527
  overlay: false
10349
10528
  },
@@ -16,5 +16,8 @@ export declare function isFromNpx(): false | "npm";
16
16
  export declare function installOptionalDependencies(integration: string, dependencies: string[]): Promise<void>;
17
17
  export declare function isUsingJSFramework(projectPath: string): boolean;
18
18
  export declare function isFirstRun(outputPath: string, browser: DevOptions['browser']): boolean;
19
+ export declare function hasShownFirstRunMessage(projectPath: string, browser: DevOptions['browser']): boolean;
20
+ export declare function markFirstRunMessageShown(projectPath: string, browser: DevOptions['browser']): void;
21
+ export declare function shouldShowFirstRun(outputPath: string, browser: DevOptions['browser'], projectPath: string): boolean;
19
22
  export declare function filterKeysForThisBrowser(manifest: Manifest, browser: DevOptions['browser']): any;
20
23
  export declare function hasDependency(projectPath: string, dependency: string): boolean;
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "name": "extension-develop",
24
- "version": "2.0.1",
24
+ "version": "2.0.4",
25
25
  "description": "The develop step of Extension.js",
26
26
  "author": {
27
27
  "name": "Cezar Augusto",