extension 4.0.22 → 4.0.24

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
@@ -58,6 +58,8 @@ If you have used [Plasmo](https://www.plasmo.com), [WXT](https://wxt.dev), or [C
58
58
  | Framework agnostic | [Vanilla](https://templates.extension.dev/javascript), [TS](https://templates.extension.dev/typescript), [React](https://templates.extension.dev/react), [Vue](https://templates.extension.dev/vue), [Svelte](https://templates.extension.dev/svelte), [Preact](https://templates.extension.dev/preact), no lock-in |
59
59
  | Custom Chromium and Gecko binaries | `--chromium-binary`, `--gecko-binary` |
60
60
 
61
+ Extension.js is sponsored by [extension.dev](https://docs.extension.dev/?utm_source=readme), the platform that hosts the build, share and store submission side of shipping an extension. To hand someone an unpublished build behind a link, with no zip and no install on their side, see [Share an unpublished build for review](https://docs.extension.dev/share/unpublished-build-for-review?utm_source=readme).
62
+
61
63
  ## Frameworks
62
64
 
63
65
  <div align="center">
package/dist/49.cjs CHANGED
@@ -209,19 +209,19 @@ exports.modules = {
209
209
  return new Promise((resolve, reject)=>{
210
210
  const ws = new (external_ws_default())(url);
211
211
  ws.on('open', ()=>{
212
- if (isDev) console.log(messages.F1());
212
+ if (isDev) (0, messaging._w)(messages.F1());
213
213
  resolve(ws);
214
214
  });
215
215
  ws.on('message', (data)=>{
216
216
  onMessage(data.toString());
217
217
  });
218
218
  ws.on('error', (error)=>{
219
- if (isDev) console.error(messages.fR(error.message));
219
+ if (isDev) (0, messaging.Gg)(messages.fR(error.message));
220
220
  onRejectPending(error.message);
221
221
  reject(error);
222
222
  });
223
223
  ws.on('close', ()=>{
224
- if (isDev) console.log(messages.hE());
224
+ if (isDev) (0, messaging._w)(messages.hE());
225
225
  onRejectPending('CDP connection closed');
226
226
  reject(new Error('CDP WebSocket closed before the connection opened'));
227
227
  });
@@ -270,7 +270,7 @@ exports.modules = {
270
270
  });
271
271
  this.transport = 'websocket';
272
272
  this.startHeartbeat();
273
- if (this.isDev()) console.log(messages.M3(this.host, this.port));
273
+ if (this.isDev()) (0, messaging._w)(messages.M3(this.host, this.port));
274
274
  } catch (error) {
275
275
  const err = error;
276
276
  throw new Error(`Failed to connect to CDP: ${err.message || err}`);
@@ -294,16 +294,16 @@ exports.modules = {
294
294
  }
295
295
  });
296
296
  input.on('error', (error)=>{
297
- if (this.isDev()) console.error(`[CDP] Pipe read error: ${error.message}`);
297
+ if (this.isDev()) (0, messaging.Gg)(`[CDP] Pipe read error: ${error.message}`);
298
298
  this.rejectAllPending('CDP pipe read error');
299
299
  });
300
300
  input.on('close', ()=>{
301
- if (this.isDev()) console.log('[CDP] Pipe closed');
301
+ if (this.isDev()) (0, messaging._w)('[CDP] Pipe closed');
302
302
  this.rejectAllPending('CDP pipe closed');
303
303
  this.pipeIn = null;
304
304
  });
305
305
  this.startHeartbeat();
306
- if (this.isDev()) console.log(messages.M3(this.host, this.port));
306
+ if (this.isDev()) (0, messaging._w)(messages.M3(this.host, this.port));
307
307
  }
308
308
  rejectAllPending(reason) {
309
309
  this.pendingRequests.forEach(({ reject, timeout }, id)=>{
@@ -342,11 +342,11 @@ exports.modules = {
342
342
  if ('pipe' === this.transport) {
343
343
  if (!this.heartbeatStallWarned) {
344
344
  this.heartbeatStallWarned = true;
345
- console.warn('[CDP] Browser is not answering CDP commands (heartbeat timed out). Keeping the session, it resumes automatically if the browser recovers.');
345
+ (0, messaging.mR)('[CDP] Browser is not answering CDP commands (heartbeat timed out). Keeping the session, it resumes automatically if the browser recovers.');
346
346
  }
347
347
  return;
348
348
  }
349
- if (this.isDev()) console.warn('[CDP] Heartbeat failed, connection appears dead');
349
+ if (this.isDev()) (0, messaging.mR)('[CDP] Heartbeat failed, connection appears dead');
350
350
  this.disconnect();
351
351
  }
352
352
  }, constants.Y$);
@@ -383,7 +383,7 @@ exports.modules = {
383
383
  }
384
384
  if ('Target.attachedToTarget' === message.method) {
385
385
  const params = message.params || {};
386
- if (this.isDev()) console.log(messages.p8(String(params.sessionId || ''), String(params.targetInfo?.type || '')));
386
+ if (this.isDev()) (0, messaging._w)(messages.p8(String(params.sessionId || ''), String(params.targetInfo?.type || '')));
387
387
  }
388
388
  for (const eventCallback of this.eventCallbacks)eventCallback(message);
389
389
  } catch {}
@@ -537,7 +537,7 @@ exports.modules = {
537
537
  const hasMoreAttempts = attempt < maxBootstrapAttempts;
538
538
  if ((0, messaging._o)()) {
539
539
  const base = String(error?.message || error);
540
- console.warn(`[CDP] bootstrap attempt ${attempt}/${maxBootstrapAttempts} failed: ${base}`);
540
+ (0, messaging.mR)(`[CDP] bootstrap attempt ${attempt}/${maxBootstrapAttempts} failed: ${base}`);
541
541
  }
542
542
  if (!retryable || !hasMoreAttempts) throw error;
543
543
  const delayMs = 120 * attempt;
@@ -731,7 +731,7 @@ exports.modules = {
731
731
  } else if ('Runtime.consoleAPICalled' === message.method || 'Log.entryAdded' === message.method) {
732
732
  if ('1' === String(process.env.EXTENSION_VERBOSE || '').trim()) {
733
733
  const ts = new Date().toISOString();
734
- console.log(messages.bv(ts, message.params));
734
+ (0, messaging._w)(messages.bv(ts, message.params));
735
735
  }
736
736
  if (logSink && 'Log.entryAdded' === message.method) {
737
737
  const entry = message.params?.entry || {};
@@ -799,6 +799,7 @@ exports.modules = {
799
799
  const present = await this.waitForExtensionTarget(expectedId, 12, 200);
800
800
  if (present) {
801
801
  if (!this.extensionId) this.extensionId = expectedId;
802
+ (0, ready_stamp.hg)(this.outPath, expectedId);
802
803
  return {
803
804
  status: 'loaded',
804
805
  extensionId: expectedId
@@ -813,7 +814,10 @@ exports.modules = {
813
814
  status: 'unknown'
814
815
  };
815
816
  }
816
- if ('loaded' === outcome.status && !this.extensionId) this.extensionId = outcome.extensionId;
817
+ if ('loaded' === outcome.status) {
818
+ if (!this.extensionId) this.extensionId = outcome.extensionId;
819
+ (0, ready_stamp.hg)(this.outPath, outcome.extensionId);
820
+ }
817
821
  if ('refused' === outcome.status) this.loadRefusalReason = outcome.reason;
818
822
  return outcome;
819
823
  }
@@ -866,28 +870,32 @@ exports.modules = {
866
870
  }
867
871
  }
868
872
  }
869
- if (this.extensionId) try {
870
- let info = null;
873
+ if (this.extensionId) {
874
+ (0, ready_stamp.hg)(this.outPath, this.extensionId);
871
875
  try {
872
- info = await this.cdp.getExtensionInfo(this.extensionId);
873
- } catch {}
874
- if (!info) {
875
- const manifest = JSON.parse(readTextFileCached(external_node_path_.join(this.outPath, 'manifest.json')));
876
+ let info = null;
877
+ try {
878
+ info = await this.cdp.getExtensionInfo(this.extensionId);
879
+ } catch {}
880
+ if (!info) {
881
+ const manifest = JSON.parse(readTextFileCached(external_node_path_.join(this.outPath, 'manifest.json')));
882
+ return {
883
+ extensionId: this.extensionId,
884
+ name: manifest.name,
885
+ version: manifest.version
886
+ };
887
+ }
876
888
  return {
877
889
  extensionId: this.extensionId,
878
- name: manifest.name,
879
- version: manifest.version
890
+ name: info?.extensionInfo?.name,
891
+ version: info?.extensionInfo?.version
880
892
  };
881
- }
882
- return {
883
- extensionId: this.extensionId,
884
- name: info?.extensionInfo?.name,
885
- version: info?.extensionInfo?.version
886
- };
887
- } catch {}
893
+ } catch {}
894
+ }
888
895
  try {
889
896
  if (!this.extensionId) this.extensionId = await this.deriveExtensionIdFromTargets(20, 200);
890
897
  if (!this.extensionId) throw new Error('Failed to determine extension ID via CDP');
898
+ (0, ready_stamp.hg)(this.outPath, this.extensionId);
891
899
  await this.enableLogging();
892
900
  let name;
893
901
  let version;
@@ -901,7 +909,7 @@ exports.modules = {
901
909
  name = String(manifest?.name || '') || void 0;
902
910
  version = String(manifest?.version || '') || void 0;
903
911
  } catch (e2) {
904
- if ((0, messaging._o)()) console.warn('[CDP] Fallback manifest read failed:', String(e2?.message || e2));
912
+ if ((0, messaging._o)()) (0, messaging.mR)('[CDP] Fallback manifest read failed:', String(e2?.message || e2));
905
913
  }
906
914
  }
907
915
  return {
@@ -985,13 +993,13 @@ exports.modules = {
985
993
  } else if ('Runtime.consoleAPICalled' === message.method || 'Log.entryAdded' === message.method) {
986
994
  if ('1' === String(process.env.EXTENSION_VERBOSE || '').trim()) {
987
995
  const ts = new Date().toISOString();
988
- console.log(messages.bv(ts, message.params));
996
+ (0, messaging._w)(messages.bv(ts, message.params));
989
997
  }
990
998
  }
991
999
  } catch {}
992
1000
  });
993
1001
  } catch (e) {
994
- if ((0, messaging._o)()) console.warn('[CDP] enableLogging failed:', String(e));
1002
+ if ((0, messaging._o)()) (0, messaging.mR)('[CDP] enableLogging failed:', String(e));
995
1003
  }
996
1004
  }
997
1005
  async getInfoBestEffort() {
@@ -1072,8 +1080,8 @@ exports.modules = {
1072
1080
  const userDataDir = userDataDirFlag ? userDataDirFlag.replace('--user-data-dir=', '').replace(/^"|"$/g, '') : '';
1073
1081
  const profileOnCard = Boolean(extensionOutputPath) && !(0, messaging.VR)(`${plugin.browser}::${external_node_path_.resolve(extensionOutputPath)}`);
1074
1082
  if ((0, messaging._o)()) {
1075
- if (userDataDir && !profileOnCard) console.log(messages.aI(userDataDir));
1076
- console.log(messages.CY(chromeRemoteDebugPort, chromeRemoteDebugPort));
1083
+ if (userDataDir && !profileOnCard) (0, messaging._w)(messages.aI(userDataDir));
1084
+ (0, messaging._w)(messages.CY(chromeRemoteDebugPort, chromeRemoteDebugPort));
1077
1085
  }
1078
1086
  const cdpExtensionController = new CDPExtensionController({
1079
1087
  outPath: extensionOutputPath,
@@ -1086,7 +1094,7 @@ exports.modules = {
1086
1094
  logSink: plugin.logSink
1087
1095
  });
1088
1096
  await cdpExtensionController.connect();
1089
- if ((0, messaging._o)()) console.log(messages.M3('127.0.0.1', chromeRemoteDebugPort));
1097
+ if ((0, messaging._o)()) (0, messaging._w)(messages.M3('127.0.0.1', chromeRemoteDebugPort));
1090
1098
  try {
1091
1099
  if (extensionOutputPath && Number.isFinite(chromeRemoteDebugPort)) {
1092
1100
  const readyPath = external_node_path_.join(external_node_path_.dirname(extensionOutputPath), 'extension-js', external_node_path_.basename(extensionOutputPath), 'ready.json');
@@ -1104,7 +1112,7 @@ exports.modules = {
1104
1112
  };
1105
1113
  if ('unknown' === loadOutcome.status && loadOutcome.unsupported) {
1106
1114
  const unconfirmedPath = extensionOutputPath || selectedExtensionPaths[0] || '';
1107
- console.warn(messages.SH(unconfirmedPath));
1115
+ (0, messaging.mR)(messages.SH(unconfirmedPath));
1108
1116
  plugin.logSink?.({
1109
1117
  level: 'warn',
1110
1118
  text: `extension_load_unconfirmed: ${unconfirmedPath}`,
@@ -1113,14 +1121,14 @@ exports.modules = {
1113
1121
  }
1114
1122
  if ('refused' === loadOutcome.status) {
1115
1123
  const refusedPath = extensionOutputPath || selectedExtensionPaths[0] || '';
1116
- console.error(messages.M6(refusedPath, loadOutcome.reason));
1124
+ (0, messaging.Gg)(messages.M6(refusedPath, loadOutcome.reason));
1117
1125
  plugin.logSink?.({
1118
1126
  level: 'error',
1119
1127
  text: `extension_load_refused: ${refusedPath}${loadOutcome.reason ? ` - ${loadOutcome.reason}` : ''}`,
1120
1128
  source: 'browser'
1121
1129
  });
1122
1130
  (0, ready_stamp.sf)(extensionOutputPath, loadOutcome.reason);
1123
- if ((0, messaging._o)() && userDataDir && profileOnCard) console.log(messages.aI(userDataDir));
1131
+ if ((0, messaging._o)() && userDataDir && profileOnCard) (0, messaging._w)(messages.aI(userDataDir));
1124
1132
  plugin.extensionLoadRefused = loadOutcome.reason;
1125
1133
  plugin.cdpController = cdpExtensionController;
1126
1134
  plugin.printBannerOnRecovery = async ()=>{
@@ -1182,7 +1190,7 @@ exports.modules = {
1182
1190
  })
1183
1191
  ]);
1184
1192
  } catch (error) {
1185
- if ((0, messaging._o)()) console.warn(`[CDP] ensureLoaded failed: ${String(error?.message || error)}`);
1193
+ if ((0, messaging._o)()) (0, messaging.mR)(`[CDP] ensureLoaded failed: ${String(error?.message || error)}`);
1186
1194
  }
1187
1195
  try {
1188
1196
  if ('development' === mode) {
@@ -1231,7 +1239,7 @@ exports.modules = {
1231
1239
  });
1232
1240
  }
1233
1241
  } catch (bannerErr) {
1234
- if ((0, messaging._o)()) console.warn(messages.$w(String(bannerErr)));
1242
+ if ((0, messaging._o)()) (0, messaging.mR)(messages.$w(String(bannerErr)));
1235
1243
  try {
1236
1244
  const mode = compilation?.options?.mode || 'development';
1237
1245
  if ('production' === mode) await (0, banner.MK)({