extension-develop 3.8.7 → 3.8.8-canary.210.3d6cbc7

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 (33) hide show
  1. package/dist/215.cjs +4 -0
  2. package/dist/323.cjs +92 -30
  3. package/dist/535.cjs +28 -46
  4. package/dist/extension-js-devtools/chrome/background/service_worker.js +2 -2
  5. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +5 -0
  6. package/dist/extension-js-devtools/chrome/content_scripts/styles.24e59c3d.css +2 -0
  7. package/dist/extension-js-devtools/chrome/manifest.json +13 -0
  8. package/dist/extension-js-devtools/chrome/pages/centralized-logger.css +1 -1
  9. package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +3 -3
  10. package/dist/extension-js-devtools/chrome/pages/welcome.css +1 -1
  11. package/dist/extension-js-devtools/chromium/background/service_worker.js +2 -2
  12. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +5 -0
  13. package/dist/extension-js-devtools/chromium/content_scripts/styles.24e59c3d.css +2 -0
  14. package/dist/extension-js-devtools/chromium/manifest.json +13 -0
  15. package/dist/extension-js-devtools/chromium/pages/centralized-logger.css +1 -1
  16. package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +3 -3
  17. package/dist/extension-js-devtools/chromium/pages/welcome.css +1 -1
  18. package/dist/extension-js-devtools/edge/background/service_worker.js +2 -2
  19. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +5 -0
  20. package/dist/extension-js-devtools/edge/content_scripts/styles.24e59c3d.css +2 -0
  21. package/dist/extension-js-devtools/edge/manifest.json +13 -0
  22. package/dist/extension-js-devtools/edge/pages/centralized-logger.css +1 -1
  23. package/dist/extension-js-devtools/edge/pages/centralized-logger.js +3 -3
  24. package/dist/extension-js-devtools/edge/pages/welcome.css +1 -1
  25. package/dist/extension-js-devtools/firefox/background/scripts.js +2 -2
  26. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +5 -0
  27. package/dist/extension-js-devtools/firefox/content_scripts/styles.24e59c3d.css +2 -0
  28. package/dist/extension-js-devtools/firefox/manifest.json +15 -0
  29. package/dist/extension-js-devtools/firefox/pages/centralized-logger.css +1 -1
  30. package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +3 -3
  31. package/dist/extension-js-devtools/firefox/pages/welcome.css +1 -1
  32. package/dist/module.cjs +59 -10
  33. package/package.json +2 -2
package/dist/215.cjs CHANGED
@@ -495,6 +495,7 @@ exports.modules = {
495
495
  var http__rspack_import_0 = __webpack_require__("http");
496
496
  var net__rspack_import_1 = __webpack_require__("net");
497
497
  var _browsers_lib_messages__rspack_import_2 = __webpack_require__("./webpack/plugin-browsers/browsers-lib/messages.ts");
498
+ const CDP_HTTP_REQUEST_TIMEOUT_MS = 1200;
498
499
  async function getJson(host, port, path) {
499
500
  return new Promise((resolve, reject)=>{
500
501
  const req = http__rspack_import_0.request({
@@ -514,6 +515,9 @@ exports.modules = {
514
515
  });
515
516
  });
516
517
  req.on('error', (err)=>reject(err));
518
+ req.setTimeout(CDP_HTTP_REQUEST_TIMEOUT_MS, ()=>{
519
+ req.destroy(new Error(`CDP endpoint timed out: ${path}`));
520
+ });
517
521
  req.end();
518
522
  });
519
523
  }
package/dist/323.cjs CHANGED
@@ -97,6 +97,9 @@ exports.modules = {
97
97
  return null;
98
98
  };
99
99
  let retries = 0;
100
+ let deferredFirstEvalId = null;
101
+ let deferredUrlDerivedId = null;
102
+ const hasExpectedManifestIdentity = Boolean(expectedName || expectedVersion || expectedManifestVersion);
100
103
  while(retries <= maxRetries){
101
104
  try {
102
105
  const targets = await cdp.getTargets();
@@ -137,17 +140,27 @@ exports.modules = {
137
140
  if (expectedVersion && versionMatches && (expectedManifestVersion ? manifestVersionMatches : true) && (!profileCandidateId || id === profileCandidateId)) return id;
138
141
  } catch {}
139
142
  }
140
- if (1 === evalIdCount && firstEvalId) return firstEvalId;
143
+ if (1 === evalIdCount && firstEvalId) {
144
+ if (!hasExpectedManifestIdentity) return firstEvalId;
145
+ deferredFirstEvalId = deferredFirstEvalId || firstEvalId;
146
+ }
141
147
  if (profileCandidateId) return profileCandidateId;
142
- if (urlDerivedId) return urlDerivedId;
148
+ if (urlDerivedId) {
149
+ if (!hasExpectedManifestIdentity) return urlDerivedId;
150
+ deferredUrlDerivedId = deferredUrlDerivedId || urlDerivedId;
151
+ }
143
152
  } catch {}
144
153
  await new Promise((r)=>setTimeout(r, backoffMs));
145
154
  retries++;
146
155
  }
147
- return null;
156
+ return deriveFromProfile() || deferredFirstEvalId || deferredUrlDerivedId;
148
157
  }
149
158
  var cdp_client = __webpack_require__("./webpack/plugin-browsers/run-chromium/chromium-source-inspection/cdp-client.ts");
150
159
  var discovery = __webpack_require__("./webpack/plugin-browsers/run-chromium/chromium-source-inspection/discovery.ts");
160
+ function isRecoverableBootstrapError(error) {
161
+ const msg = String(error?.message || error || '').toLowerCase();
162
+ return msg.includes('econnreset') || msg.includes('websocket is not open') || msg.includes('cdp connection closed') || msg.includes('socket hang up') || msg.includes('timed out') || msg.includes('no cdp websocket url');
163
+ }
151
164
  async function connectToChromeCdp(cdpPort) {
152
165
  let retries = 0;
153
166
  const maxRetries = 60;
@@ -158,21 +171,36 @@ exports.modules = {
158
171
  retries++;
159
172
  await new Promise((r)=>setTimeout(r, backoffMs));
160
173
  }
161
- const cdp = new cdp_client.n(cdpPort, '127.0.0.1');
162
- await cdp.connect();
163
- try {
164
- await cdp.sendCommand('Target.setDiscoverTargets', {
165
- discover: true
166
- });
167
- await cdp.sendCommand('Target.setAutoAttach', {
168
- autoAttach: true,
169
- waitForDebuggerOnStart: false,
170
- flatten: true
171
- });
172
- } catch (error) {
173
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.warn(messages.wXK(String(error?.message || error)));
174
+ const maxBootstrapAttempts = 4;
175
+ let lastError = null;
176
+ for(let attempt = 1; attempt <= maxBootstrapAttempts; attempt++){
177
+ const cdp = new cdp_client.n(cdpPort, '127.0.0.1');
178
+ try {
179
+ await cdp.connect();
180
+ await cdp.sendCommand('Target.setDiscoverTargets', {
181
+ discover: true
182
+ });
183
+ await cdp.sendCommand('Target.setAutoAttach', {
184
+ autoAttach: true,
185
+ waitForDebuggerOnStart: false,
186
+ flatten: true
187
+ });
188
+ return cdp;
189
+ } catch (error) {
190
+ lastError = error;
191
+ cdp.disconnect();
192
+ const retryable = isRecoverableBootstrapError(error);
193
+ const hasMoreAttempts = attempt < maxBootstrapAttempts;
194
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) {
195
+ const base = String(error?.message || error);
196
+ console.warn(`[CDP] bootstrap attempt ${attempt}/${maxBootstrapAttempts} failed: ${base}`);
197
+ }
198
+ if (!retryable || !hasMoreAttempts) throw error;
199
+ const delayMs = 120 * attempt;
200
+ await new Promise((r)=>setTimeout(r, delayMs));
201
+ }
174
202
  }
175
- return cdp;
203
+ throw lastError instanceof Error ? lastError : new Error('Failed to bootstrap CDP connection');
176
204
  }
177
205
  async function loadUnpackedIfNeeded(cdp, outPath) {
178
206
  try {
@@ -263,6 +291,10 @@ exports.modules = {
263
291
  const id = await this.deriveExtensionIdFromTargets();
264
292
  if (id) this.extensionId = id;
265
293
  }
294
+ if (this.extensionId) {
295
+ const belongsToOutPath = this.extensionIdBelongsToOutPath(this.extensionId);
296
+ if (false === belongsToOutPath) this.extensionId = null;
297
+ }
266
298
  if (this.extensionId) try {
267
299
  let info = null;
268
300
  try {
@@ -283,7 +315,7 @@ exports.modules = {
283
315
  };
284
316
  } catch {}
285
317
  try {
286
- if (!this.extensionId) {
318
+ if (!this.extensionId && this.shouldAttemptLoadUnpacked()) {
287
319
  const id = await loadUnpackedIfNeeded(this.cdp, this.outPath);
288
320
  if (id) this.extensionId = id;
289
321
  }
@@ -318,6 +350,43 @@ exports.modules = {
318
350
  if (!this.cdp) return null;
319
351
  return await deriveExtensionIdFromTargetsHelper(this.cdp, this.outPath, maxRetries, backoffMs, this.profilePath, this.extensionPaths);
320
352
  }
353
+ shouldAttemptLoadUnpacked() {
354
+ const normalizedOutPath = this.normalizePath(this.outPath);
355
+ const normalizedExtensionPaths = (this.extensionPaths || []).map((candidate)=>String(candidate || '').trim()).filter(Boolean).map((candidate)=>this.normalizePath(candidate));
356
+ if (0 === normalizedExtensionPaths.length) return true;
357
+ return !normalizedExtensionPaths.includes(normalizedOutPath);
358
+ }
359
+ normalizePath(input) {
360
+ try {
361
+ return external_fs_.realpathSync(external_path_.resolve(input));
362
+ } catch {
363
+ return external_path_.resolve(input);
364
+ }
365
+ }
366
+ extensionIdBelongsToOutPath(extensionId) {
367
+ if (!this.profilePath || !extensionId) return null;
368
+ const prefCandidates = [];
369
+ const addPrefCandidate = (dir)=>{
370
+ const prefPath = external_path_.join(dir, 'Preferences');
371
+ if (external_fs_.existsSync(prefPath)) prefCandidates.push(prefPath);
372
+ };
373
+ try {
374
+ addPrefCandidate(this.profilePath);
375
+ addPrefCandidate(external_path_.join(this.profilePath, 'Default'));
376
+ for (const entry of external_fs_.readdirSync(this.profilePath))if (/^Profile\s+\d+$/i.test(entry)) addPrefCandidate(external_path_.join(this.profilePath, entry));
377
+ } catch {}
378
+ if (0 === prefCandidates.length) return null;
379
+ const normalizedOutPath = this.normalizePath(this.outPath);
380
+ for (const prefPath of prefCandidates)try {
381
+ const prefs = JSON.parse(external_fs_.readFileSync(prefPath, 'utf-8'));
382
+ const settings = prefs?.extensions?.settings;
383
+ const info = settings?.[extensionId];
384
+ const storedPath = String(info?.path || '');
385
+ if (!storedPath) continue;
386
+ return this.normalizePath(storedPath) === normalizedOutPath;
387
+ } catch {}
388
+ return null;
389
+ }
321
390
  async hardReload() {
322
391
  if (!this.cdp || !this.extensionId) return false;
323
392
  try {
@@ -397,6 +466,10 @@ exports.modules = {
397
466
  try {
398
467
  if (!this.cdp) return null;
399
468
  if (!this.extensionId) this.extensionId = await this.deriveExtensionIdFromTargets(6, 150);
469
+ if (this.extensionId) {
470
+ const belongsToOutPath = this.extensionIdBelongsToOutPath(this.extensionId);
471
+ if (false === belongsToOutPath) this.extensionId = await this.deriveExtensionIdFromTargets(10, 150);
472
+ }
400
473
  if (!this.extensionId) return null;
401
474
  let name;
402
475
  let version;
@@ -458,18 +531,7 @@ exports.modules = {
458
531
  profilePath: userDataDir || void 0,
459
532
  extensionPaths: selectedExtensionPaths
460
533
  });
461
- const retryAsync = async (operation, attempts = 5, initialDelayMs = 150)=>{
462
- let lastError;
463
- for(let attempt = 0; attempt < attempts; attempt++)try {
464
- return await operation();
465
- } catch (error) {
466
- lastError = error;
467
- const backoffMs = initialDelayMs * Math.pow(2, attempt);
468
- await new Promise((resolve)=>setTimeout(resolve, backoffMs));
469
- }
470
- throw lastError;
471
- };
472
- await retryAsync(()=>cdpExtensionController.connect());
534
+ await cdpExtensionController.connect();
473
535
  if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(messages.M3V('127.0.0.1', chromeRemoteDebugPort));
474
536
  const mode = compilation?.options?.mode || 'development';
475
537
  let earlyBannerPrinted = false;
package/dist/535.cjs CHANGED
@@ -8048,12 +8048,20 @@ Set background.noDynamicEntryWarning to true to disable this warning.
8048
8048
  const normalizedModifiedFilePaths = Array.from(modifiedFiles).map((filePath)=>String(filePath).replace(/\\/g, '/'));
8049
8049
  const compilerContextRoot = String(compiler?.options?.context || '').replace(/\\/g, '/');
8050
8050
  const filesInCurrentCompilerContext = compilerContextRoot ? normalizedModifiedFilePaths.filter((filePath)=>filePath === compilerContextRoot || filePath.startsWith(`${compilerContextRoot}/`)) : normalizedModifiedFilePaths;
8051
- const watchedModifiedFilePaths = filesInCurrentCompilerContext.length > 0 ? filesInCurrentCompilerContext : normalizedModifiedFilePaths;
8052
- const hitManifest = watchedModifiedFilePaths.some((filePath)=>/(^|\/)manifest\.json$/i.test(filePath));
8053
- const localeChanged = watchedModifiedFilePaths.some((filePath)=>/(^|\/)__?locales\/.+\.json$/i.test(filePath));
8051
+ const watchedModifiedFilePaths = compilerContextRoot ? filesInCurrentCompilerContext : normalizedModifiedFilePaths;
8052
+ const normalizedOutputPath = String(compiler?.options?.output?.path || '').replace(/\\/g, '/');
8053
+ const normalizedSourceRootPath = compilerContextRoot ? `${compilerContextRoot}/src` : '';
8054
+ const sourceModifiedFilePaths = watchedModifiedFilePaths.filter((filePath)=>!(normalizedOutputPath && (filePath === normalizedOutputPath || filePath.startsWith(`${normalizedOutputPath}/`))));
8055
+ const hitManifest = sourceModifiedFilePaths.some((filePath)=>{
8056
+ if (normalizedSourceRootPath) return filePath === `${normalizedSourceRootPath}/manifest.json`;
8057
+ return /(^|\/)manifest\.json$/i.test(filePath);
8058
+ });
8059
+ const localeChanged = sourceModifiedFilePaths.some((filePath)=>{
8060
+ if (normalizedSourceRootPath) return filePath.startsWith(`${normalizedSourceRootPath}/_locales/`);
8061
+ return /(^|\/)__?locales\/.+\.json$/i.test(filePath);
8062
+ });
8054
8063
  let serviceWorkerChanged = false;
8055
- let contentScriptChanged = false;
8056
- if (this.serviceWorkerSourceDependencyPaths.size > 0) serviceWorkerChanged = watchedModifiedFilePaths.some((modifiedFilePath)=>{
8064
+ if (this.serviceWorkerSourceDependencyPaths.size > 0) serviceWorkerChanged = sourceModifiedFilePaths.some((modifiedFilePath)=>{
8057
8065
  if (this.serviceWorkerSourceDependencyPaths.has(modifiedFilePath)) return true;
8058
8066
  for (const serviceWorkerSourceDependencyPath of this.serviceWorkerSourceDependencyPaths)if (modifiedFilePath.endsWith(serviceWorkerSourceDependencyPath)) return true;
8059
8067
  return false;
@@ -8062,21 +8070,15 @@ Set background.noDynamicEntryWarning to true to disable this warning.
8062
8070
  const { absolutePath: serviceWorkerAbsolutePath, relativePath: serviceWorkerRelativePath } = this.ctx.getServiceWorkerPaths() || {};
8063
8071
  if (serviceWorkerAbsolutePath) {
8064
8072
  const normalizedServiceWorkerAbsolutePath = serviceWorkerAbsolutePath.replace(/\\/g, '/');
8065
- serviceWorkerChanged = watchedModifiedFilePaths.some((filePath)=>{
8073
+ serviceWorkerChanged = sourceModifiedFilePaths.some((filePath)=>{
8066
8074
  const normalizedPath = filePath.replace(/\\/g, '/');
8067
8075
  return normalizedPath === normalizedServiceWorkerAbsolutePath || normalizedPath.endsWith(normalizedServiceWorkerAbsolutePath) || (serviceWorkerRelativePath ? normalizedPath === serviceWorkerRelativePath.replace(/\\/g, '/') || normalizedPath.endsWith('/' + serviceWorkerRelativePath.replace(/\\/g, '/')) : false);
8068
8076
  });
8069
8077
  }
8070
8078
  }
8071
- if (this.contentScriptSourceDependencyPaths.size > 0) contentScriptChanged = watchedModifiedFilePaths.some((modifiedFilePath)=>{
8072
- if (this.contentScriptSourceDependencyPaths.has(modifiedFilePath)) return true;
8073
- for (const contentPath of this.contentScriptSourceDependencyPaths)if (modifiedFilePath.endsWith(contentPath)) return true;
8074
- return false;
8075
- });
8076
8079
  if (hitManifest) this.ctx.setPendingReloadReason('manifest');
8077
8080
  else if (localeChanged) this.ctx.setPendingReloadReason('locales');
8078
8081
  else if (serviceWorkerChanged) this.ctx.setPendingReloadReason('sw');
8079
- else if (contentScriptChanged) this.ctx.setPendingReloadReason('content');
8080
8082
  } catch (error) {
8081
8083
  this.logger?.warn?.('[reload-debug] watchRun inspect failed:', String(error));
8082
8084
  }
@@ -8087,12 +8089,18 @@ Set background.noDynamicEntryWarning to true to disable this warning.
8087
8089
  if (hasErrors) return;
8088
8090
  this.refreshSWFromManifest(stats.compilation);
8089
8091
  this.refreshServiceWorkerSourceDependencyPaths(stats.compilation);
8090
- this.refreshContentScriptSourceDependencyPaths(stats.compilation);
8092
+ if (!this.hasCompletedSuccessfulBuild) {
8093
+ this.hasCompletedSuccessfulBuild = true;
8094
+ this.firstSuccessfulBuildAtMs = Date.now();
8095
+ this.ctx.clearPendingReloadReason();
8096
+ return;
8097
+ }
8091
8098
  const pendingReason = this.ctx.getPendingReloadReason();
8092
- const contentScriptEmitted = this.didEmitContentScripts(stats);
8093
- const reason = pendingReason || (contentScriptEmitted ? 'content' : void 0);
8099
+ const reason = pendingReason;
8094
8100
  if (!reason) return;
8095
8101
  this.ctx.clearPendingReloadReason();
8102
+ const now = Date.now();
8103
+ if (this.firstSuccessfulBuildAtMs && now - this.firstSuccessfulBuildAtMs < ChromiumHardReloadPlugin.INITIAL_RELOAD_COOLDOWN_MS) return void this.logger?.info?.(`[reload] skipping early reload during startup cooldown (reason:${reason})`);
8096
8104
  const ctrl = this.ctx.getController();
8097
8105
  if (!ctrl) return;
8098
8106
  this.logger?.info?.(`[reload] reloading extension (reason:${reason})`);
@@ -8137,35 +8145,6 @@ Set background.noDynamicEntryWarning to true to disable this warning.
8137
8145
  this.serviceWorkerSourceDependencyPaths = discovered;
8138
8146
  } catch {}
8139
8147
  }
8140
- didEmitContentScripts(stats) {
8141
- try {
8142
- const json = 'function' == typeof stats?.toJson ? stats.toJson({
8143
- assets: true
8144
- }) : null;
8145
- const assets = json?.assets || [];
8146
- return assets.some((asset)=>{
8147
- const name = String(asset?.name || '');
8148
- if (!/(^|\/)content_scripts\/content-\d+\.(js|css)$/.test(name)) return false;
8149
- if ('boolean' == typeof asset?.emitted) return asset.emitted;
8150
- return true;
8151
- });
8152
- } catch {
8153
- return false;
8154
- }
8155
- }
8156
- refreshContentScriptSourceDependencyPaths(compilation) {
8157
- try {
8158
- const entrypoints = compilation?.entrypoints;
8159
- if (!entrypoints) return;
8160
- const discovered = new Set();
8161
- for (const [name] of entrypoints){
8162
- if (!String(name).startsWith("content_scripts/content-")) continue;
8163
- const deps = this.collectEntrypointModuleResourcePaths(compilation, String(name));
8164
- for (const dep of deps)discovered.add(dep);
8165
- }
8166
- this.contentScriptSourceDependencyPaths = discovered;
8167
- } catch {}
8168
- }
8169
8148
  collectEntrypointModuleResourcePaths(compilation, entrypointName) {
8170
8149
  const collectedResourcePaths = new Set();
8171
8150
  const entrypoints = compilation?.entrypoints;
@@ -8191,14 +8170,17 @@ Set background.noDynamicEntryWarning to true to disable this warning.
8191
8170
  chromium_hard_reload_define_property(this, "ctx", void 0);
8192
8171
  chromium_hard_reload_define_property(this, "logger", void 0);
8193
8172
  chromium_hard_reload_define_property(this, "warnedDevMode", void 0);
8173
+ chromium_hard_reload_define_property(this, "hasCompletedSuccessfulBuild", void 0);
8174
+ chromium_hard_reload_define_property(this, "firstSuccessfulBuildAtMs", void 0);
8194
8175
  chromium_hard_reload_define_property(this, "serviceWorkerSourceDependencyPaths", void 0);
8195
- chromium_hard_reload_define_property(this, "contentScriptSourceDependencyPaths", void 0);
8196
8176
  this.options = options;
8197
8177
  this.ctx = ctx;
8178
+ this.hasCompletedSuccessfulBuild = false;
8179
+ this.firstSuccessfulBuildAtMs = null;
8198
8180
  this.serviceWorkerSourceDependencyPaths = new Set();
8199
- this.contentScriptSourceDependencyPaths = new Set();
8200
8181
  }
8201
8182
  }
8183
+ chromium_hard_reload_define_property(ChromiumHardReloadPlugin, "INITIAL_RELOAD_COOLDOWN_MS", 5000);
8202
8184
  var shared_utils = __webpack_require__("./webpack/plugin-browsers/browsers-lib/shared-utils.ts");
8203
8185
  var cdp_client = __webpack_require__("./webpack/plugin-browsers/run-chromium/chromium-source-inspection/cdp-client.ts");
8204
8186
  var instance_registry = __webpack_require__("./webpack/plugin-browsers/browsers-lib/instance-registry.ts");
@@ -1,4 +1,4 @@
1
- (()=>{"use strict";var e={},r={};function t(a){var o=r[a];if(void 0!==o)return o.exports;var n=r[a]={exports:{}};return e[a](n,n.exports,t),n.exports}async function a(){try{if(!chrome.management.getAll)return[];return(await new Promise(e=>{chrome.management.getAll(e)})||[]).filter(e=>{let r;return e.id!==chrome.runtime.id&&"igcijhgmihmjbbahdabahfbpffalcfnn"!==e.id&&"development"===e.installType&&"theme"!==e.type&&!0===e.enabled&&!((r=String(e.name||"").toLowerCase()).includes("extension.js built-in developer tools")||r.includes("extension.js theme"))})}catch{return[]}}async function o(){let e=await a();return e[e.length-1]}function n(e,r){let t="chrome://extensions/";chrome.tabs.query({url:t},r=>{r.length>0||chrome.tabs.create({url:t,active:!1},function(r){chrome.tabs.move(r.id,{index:0},()=>{setTimeout(()=>{chrome.tabs.update(e.id,{active:!0})},500)})})})}async function i(){let e,r,t="chrome://extensions/";try{chrome.tabs.query({active:!0,currentWindow:!0},r=>{let t=Array.isArray(r)?r[0]:void 0;t&&"number"==typeof t.id&&(e=t.id)})}catch{console.error("Error querying active tab")}r=await o();let a=String("chrome").toLowerCase(),n=r?.id||`__first_run__:${a}`;chrome.storage.local.get(n,r=>{if(r?.[n]?.didRun)return;let a=()=>{try{let r=chrome.runtime.getURL("pages/welcome.html");1;chrome.tabs.create({url:r,active:!0});try{if("number"==typeof e)try{chrome.tabs.update(e,{url:t})}catch{console.error("Error updating original active tab")}}catch{console.error("Error updating original active tab")}}catch{try{chrome.tabs.create({url:"pages/welcome.html",active:!0})}catch{console.error("Error creating welcome tab")}}};try{chrome.tabs.query({url:chrome.runtime.getURL("pages/welcome.html")},e=>{Array.isArray(e)&&e.length>0||a()})}catch{a()}chrome.storage.local.set({[n]:{didRun:!0}})})}async function c(){try{chrome.tabs.query({active:!0,currentWindow:!0},async e=>{let r=Array.isArray(e)?e[0]:void 0,t="chrome",a=`${t}://extensions/`;if(console.log(`%c
1
+ (()=>{"use strict";var e={},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}async function n(){try{if(!chrome.management.getAll)return[];return(await new Promise(e=>{chrome.management.getAll(e)})||[]).filter(e=>{let t;return e.id!==chrome.runtime.id&&"igcijhgmihmjbbahdabahfbpffalcfnn"!==e.id&&"development"===e.installType&&"theme"!==e.type&&!0===e.enabled&&!((t=String(e.name||"").toLowerCase()).includes("extension.js built-in developer tools")||t.includes("extension.js theme"))})}catch{return[]}}async function a(){let e=await n();return e[e.length-1]}function o(e,t){let r="chrome://extensions/";chrome.tabs.query({url:r},t=>{t.length>0||chrome.tabs.create({url:r,active:!1},function(t){chrome.tabs.move(t.id,{index:0},()=>{setTimeout(()=>{chrome.tabs.update(e.id,{active:!0})},500)})})})}async function i(){let e,t,r="chrome://extensions/";try{chrome.tabs.query({active:!0,currentWindow:!0},t=>{let r=Array.isArray(t)?t[0]:void 0;r&&"number"==typeof r.id&&(e=r.id)})}catch{console.error("Error querying active tab")}t=await a();let n=String("chrome").toLowerCase(),o=t?.id||`__first_run__:${n}`;chrome.storage.local.get(o,t=>{if(t?.[o]?.didRun)return;let n=()=>{try{let t=chrome.runtime.getURL("pages/welcome.html");1;chrome.tabs.create({url:t,active:!0});try{if("number"==typeof e)try{chrome.tabs.update(e,{url:r})}catch{console.error("Error updating original active tab")}}catch{console.error("Error updating original active tab")}}catch{try{chrome.tabs.create({url:"pages/welcome.html",active:!0})}catch{console.error("Error creating welcome tab")}}};try{chrome.tabs.query({url:chrome.runtime.getURL("pages/welcome.html")},e=>{Array.isArray(e)&&e.length>0||n()})}catch{n()}chrome.storage.local.set({[o]:{didRun:!0}})})}async function s(){try{chrome.tabs.query({active:!0,currentWindow:!0},async e=>{let t=Array.isArray(e)?e[0]:void 0,r="chrome",n=`${r}://extensions/`;if(console.log(`%c
2
2
  ██████████████████████████████████████████████████████████
3
3
  ██████████████████████████████████████████████████████████
4
4
  ████████████████████████████ ██████████████████████████
@@ -23,4 +23,4 @@
23
23
  ██████████████████████████████████████████████████████████
24
24
  ██████████████████████████████████████████████████████████
25
25
  MIT (c) ${new Date().getFullYear()} - Cezar Augusto and the Extension.js Authors.
26
- `,"background: transparent; color: #0971fe; "),!r){try{await i()}catch{try{chrome.tabs.create({url:a})}catch{}}return}let o=String(r.url||""),c=o.startsWith(`${t}://newtab`)||o.startsWith(`${t}://welcome`);0;c?await i():n(r,a)})}catch{}}async function s(e){if(e.startsWith("data:"))return e;let r=await fetch(e);if(!r.ok)throw Error(`Failed to fetch icon: ${r.status}`);let t=await r.blob();return await new Promise((e,r)=>{let a=new FileReader;a.onload=()=>e(String(a.result||"")),a.onerror=()=>r(Error("Failed to read icon blob")),a.readAsDataURL(t)})}t.rv=()=>"1.7.5",t.ruid="bundler=rspack@1.7.5",chrome.runtime.onMessage.addListener((e,r,t)=>{if((!r?.id||r.id===chrome.runtime.id)&&e&&"resolve-icon-url"===e.type)return e.url&&function(e){if(e.startsWith("data:"))return!0;try{let r=new URL(e);return"moz-extension:"===r.protocol||"chrome-extension:"===r.protocol}catch{return!1}}(e.url)?(s(e.url).then(e=>t({ok:!0,dataUrl:e})).catch(e=>t({ok:!1,error:String(e)})),!0):void t({ok:!1,error:"Unsupported icon URL"})}),chrome.runtime.onStartup.addListener(async()=>{await c()}),chrome.runtime.onInstalled.addListener(async()=>{await c()})})();
26
+ `,"background: transparent; color: #0971fe; "),!t){try{await i()}catch{try{chrome.tabs.create({url:n})}catch{}}return}let a=String(t.url||""),s=a.startsWith(`${r}://newtab`)||a.startsWith(`${r}://welcome`);0;s?await i():o(t,n)})}catch{}}r.rv=()=>"1.7.5",r.ruid="bundler=rspack@1.7.5";let c=[],l=new Map,d=new Set;try{chrome.storage.session.get(["logger_capture_stacks"],e=>{e?.logger_capture_stacks}),chrome.storage.session.onChanged.addListener((e,t)=>{"session"===t&&"logger_capture_stacks"in e&&e.logger_capture_stacks?.newValue})}catch{}function u(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function m(e){if(c.push(e),c.length>2e3&&c.shift(),"number"==typeof e.tabId){let t=l.get(e.tabId)||[];t.push(e),t.length>1e3&&t.shift(),l.set(e.tabId,t)}for(let t of d)try{let r={type:"append",event:e};t.postMessage(r)}catch{}}chrome.runtime.onConnect.addListener(e=>{if("logger"!==e.name)return;let t=t=>(function(e,t){var r;let n,a;if("subscribe"===t.type){d.add(e);try{e.postMessage({type:"init",events:c})}catch{}return}let o=e.sender?.id;if(o&&o===chrome.runtime.id)return;let i=e.sender?.tab?.id,s=e.sender?.frameId,l=e.sender?.tab?.incognito,m=e.sender?.tab?.windowId;if(r=o||`tab:${i??"unknown"}`,n=Date.now(),(a=y.get(r))?n-a.ts>1e3?(a.ts=n,a.count=1,!!0):(a.count+=1,!!(a.count>200)):(y.set(r,{ts:n,count:1}),!!0))return;let g=x(t.messageParts),h={id:u(),timestamp:Date.now(),level:t.level,context:t.context,messageParts:g,eventType:"dx.signal"===t.eventType||"log"===t.eventType?t.eventType:"log",code:"string"==typeof t.code?b(t.code,128):void 0,status:"ok"===t.status||"warn"===t.status||"fail"===t.status?t.status:void 0,data:w(t.data),remediation:"string"==typeof t.remediation?b(t.remediation,512):void 0,url:t.url,stack:t.stack,errorName:t.errorName,tabId:i,frameId:s,sourceExtensionId:o,incognito:l,windowId:m};p(h)})(e,t);e.onMessage.addListener(t),e.onDisconnect.addListener(()=>{d.delete(e);try{e.onMessage.removeListener(t)}catch{}})}),chrome.action.onClicked.addListener(async()=>{try{await chrome.sidePanel.setPanelBehavior({openPanelOnActionClick:!0})}catch{}});let g=[],h=new Set;function f(e){try{return JSON.stringify(e)}catch{return String(e)}}function p(e){let t=`${e.eventType??"log"}|${e.code??""}|${e.status??""}|${e.level}|${e.context}|${e.tabId??""}|${e.frameId??""}|${e.url??""}|${f(e.messageParts)}|${f(e.data)}`.slice(0,512);if(!h.has(t)){if(h.add(t),g.push(t),g.length>2e3){let e=g.shift();e&&h.delete(e)}if(e.url&&!e.hostname)try{let t=new URL(e.url);e.hostname=`${t.hostname}${t.pathname}`}catch{}if(null!=e.tabId&&null==e.title)try{chrome.tabs.get(e.tabId,t=>{if(chrome.runtime.lastError)return m(e);e.title=t?.title||e.title,m(e)});return}catch{}m(e)}}let y=new Map;function b(e,t=2048){return e.length<=t?e:e.slice(0,t)+"..."}function v(e){try{return JSON.stringify(e)}catch{try{return String(e)}catch{return"[unserializable]"}}}function x(e){try{let t=[];for(let r of e??[])if("string"==typeof r?t.push(b(r)):r instanceof Error?t.push(b(`${r.name}: ${r.message}`)):t.push(b(v(r))),t.join(" ").length>8192)break;return t}catch{return[v(e)]}}function w(e){if(e&&"object"==typeof e)try{let t=JSON.stringify(e);if(!t)return;let r=JSON.parse(t);if(0===Object.keys(r).length)return;return r}catch{return}}function I(e,t,r={}){p({id:u(),timestamp:Date.now(),level:e,context:"background",messageParts:t,url:"string"==typeof r.url?r.url:void 0,tabId:"number"==typeof r.tabId?r.tabId:void 0,frameId:"number"==typeof r.frameId?r.frameId:void 0})}async function k(){let e=(await new Promise(e=>{chrome.management.getAll(e)})||[]).filter(e=>{let t;return e.id!==chrome.runtime.id&&"igcijhgmihmjbbahdabahfbpffalcfnn"!==e.id&&"development"===e.installType&&"theme"!==e.type&&!((t=String(e.name||"").toLowerCase()).includes("extension.js built-in developer tools")||t.includes("extension.js theme"))});if(0===e.length)return{ok:!0,extensionEnabled:null};let t=e.find(e=>e.enabled)||e[e.length-1];return{ok:!0,extensionEnabled:!!t?.enabled,extensionName:t?.name,extensionId:t?.id}}async function L(e){if(e.startsWith("data:"))return e;let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch icon: ${t.status}`);let r=await t.blob();return await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(String(n.result||"")),n.onerror=()=>t(Error("Failed to read icon blob")),n.readAsDataURL(r)})}chrome.runtime.onInstalled.addListener(e=>{I("info",["extension installed",e.reason,e.previousVersion??null])}),chrome.storage.session.get(["logger_events"],e=>{let t=Array.isArray(e?.logger_events)?e.logger_events:[];if(t.length)for(let e of t.slice(-2e3))c.push(e)}),setInterval(()=>{chrome.storage.session.set({logger_events:c.slice(-200)})},2e3),chrome.runtime.onStartup.addListener(()=>{I("info",["extension startup"]);try{I("info",["TEST_LOG: background-start"])}catch{}}),chrome.tabs.onCreated.addListener(e=>{I("info",["tab created"],{tabId:e.id??void 0,url:e.url})}),chrome.tabs.onUpdated.addListener((e,t,r)=>{"loading"===t.status&&I("debug",["tab loading"],{tabId:e,url:r.url}),"complete"===t.status&&I("debug",["tab complete"],{tabId:e,url:r.url}),"string"==typeof t.url&&I("info",["tab url changed",t.url],{tabId:e,url:t.url})}),chrome.tabs.onRemoved.addListener((e,t)=>{I("info",["tab removed",{windowId:t.windowId,isWindowClosing:t.isWindowClosing}],{tabId:e})}),chrome.webNavigation.onBeforeNavigate.addListener(e=>{0===e.frameId&&I("info",["Before navigate"],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.webNavigation.onCommitted.addListener(e=>{0===e.frameId&&I("info",["Navigation committed"],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.webNavigation.onCompleted.addListener(e=>{0===e.frameId&&I("info",["Navigation completed"],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.webNavigation.onErrorOccurred.addListener(e=>{0===e.frameId&&I("error",["Navigation error",e.error],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.webNavigation.onHistoryStateUpdated.addListener(e=>{0===e.frameId&&I("info",["History state updated"],{tabId:e.tabId,frameId:e.frameId,url:e.url,title:"[navigation]"})}),chrome.runtime.onMessage.addListener((e,t,r)=>e&&"get-events"===e.type?(r({events:c.slice(-500)}),!0):!!e&&"clear-events"===e.type&&(c.length=0,r({ok:!0}),!0)),chrome.runtime.onMessage.addListener((e,t,r)=>{if((!t?.id||t.id===chrome.runtime.id)&&e){if("resolve-icon-url"===e.type)return e.url&&function(e){if(e.startsWith("data:"))return!0;try{let t=new URL(e);return"moz-extension:"===t.protocol||"chrome-extension:"===t.protocol}catch{return!1}}(e.url)?(L(e.url).then(e=>r({ok:!0,dataUrl:e})).catch(e=>r({ok:!1,error:String(e)})),!0):void r({ok:!1,error:"Unsupported icon URL"});if("get-dx-status"===e.type)return k().then(e=>r(e)).catch(e=>r({ok:!1,error:String(e||"Unknown error")})),!0;if("dx-signal"===e.type){try{var n={level:e.level||"info",context:e.context||"content",messageParts:Array.isArray(e.messageParts)&&e.messageParts.length>0?e.messageParts:[e.code||"DX_SIGNAL"],eventType:e.eventType||"dx.signal",code:e.code,status:e.status,data:e.data,remediation:e.remediation,url:"string"==typeof e.url?e.url:void 0,stack:"string"==typeof e.stack?e.stack:void 0,errorName:"string"==typeof e.errorName?e.errorName:void 0};p({id:u(),timestamp:Date.now(),level:n.level,context:n.context,messageParts:x(n.messageParts||[]),eventType:"dx.signal"===n.eventType||"log"===n.eventType?n.eventType:"log",code:"string"==typeof n.code?b(String(n.code),128):void 0,status:"ok"===n.status||"warn"===n.status||"fail"===n.status?n.status:void 0,data:w(n.data),remediation:"string"==typeof n.remediation?b(n.remediation,512):void 0,url:n.url,stack:n.stack,errorName:n.errorName,tabId:n.tabId,frameId:n.frameId}),r({ok:!0})}catch(e){r({ok:!1,error:String(e||"Unknown error")})}return!0}}}),chrome.runtime.onStartup.addListener(async()=>{await s()}),chrome.runtime.onInstalled.addListener(async()=>{await s()})})();