extension 3.16.1 → 3.17.0-canary.312.672c4f2

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 (26) hide show
  1. package/README.md +0 -15
  2. package/dist/322.cjs +26 -9
  3. package/dist/browsers.cjs +263 -206
  4. package/dist/cli.cjs +867 -414
  5. package/dist/extension/browsers/browsers-lib/messages.d.ts +17 -0
  6. package/dist/extension/browsers/browsers-lib/output-binaries-resolver.d.ts +1 -1
  7. package/dist/extension/browsers/browsers-lib/shared-utils.d.ts +1 -0
  8. package/dist/extension/browsers/browsers-lib/wsl-support.d.ts +3 -0
  9. package/dist/extension/browsers/browsers-types.d.ts +1 -1
  10. package/dist/extension/browsers/run-chromium/chromium-launch/process-handlers.d.ts +8 -1
  11. package/dist/extension/browsers/run-chromium/chromium-launch/wsl-support.d.ts +2 -9
  12. package/dist/extension/browsers/run-chromium/chromium-source-inspection/cdp-extension-controller/logging.d.ts +0 -5
  13. package/dist/extension/browsers/run-chromium/chromium-source-inspection/index.d.ts +1 -0
  14. package/dist/extension/browsers/run-firefox/firefox-launch/binary-detector.d.ts +0 -4
  15. package/dist/extension/browsers/run-firefox/firefox-launch/process-handlers.d.ts +5 -1
  16. package/dist/extension/browsers/run-firefox/firefox-launch/wsl-support.d.ts +2 -4
  17. package/dist/extension/browsers/run-firefox/firefox-source-inspection/remote-firefox/evaluate.d.ts +1 -0
  18. package/dist/extension/browsers/run-safari/safari-launch/dry-run.d.ts +1 -0
  19. package/dist/extension/browsers/run-safari/safari-launch/index.d.ts +5 -0
  20. package/dist/extension/browsers/run-safari/safari-launch/safari-config.d.ts +16 -0
  21. package/dist/extension/browsers/run-safari/safari-launch/toolchain.d.ts +10 -0
  22. package/dist/extension/browsers/run-safari/safari-types.d.ts +18 -0
  23. package/dist/extension/commands/dev-wait.d.ts +2 -0
  24. package/dist/extension/helpers/messages.d.ts +10 -0
  25. package/dist/extension/helpers/vendors.d.ts +2 -1
  26. package/package.json +4 -4
package/README.md CHANGED
@@ -172,21 +172,6 @@ npx extension@latest dev https://github.com/GoogleChrome/chrome-extensions-sampl
172
172
  - Open issues and feature requests on [GitHub](https://github.com/extension-js/extension.js/issues)
173
173
  - Browse production-ready [examples](https://github.com/extension-js/examples)
174
174
 
175
- ## Sponsors
176
-
177
- <div align="center">
178
- <p>
179
- <span style="font-size:21px">Browser testing via</span><br>
180
- <a href="https://www.testmuai.com/?utm_medium=sponsor&utm_source=extensionjs" target="_blank" rel="noopener noreferrer">
181
- <picture>
182
- <source media="(prefers-color-scheme: dark)" srcset="https://assets.testmu.ai/resources/images/testmu-ai/common/whiteTestmulogo.svg" />
183
- <source media="(prefers-color-scheme: light)" srcset="https://assets.testmu.ai/resources/images/logos/black-logo.png" />
184
- <img src="https://assets.testmu.ai/resources/images/logos/black-logo.png" width="250" height="45" alt="TestMu AI Logo" />
185
- </picture>
186
- </a>
187
- </p>
188
- </div>
189
-
190
175
  ## License
191
176
 
192
177
  MIT (c) Cezar Augusto and the Extension.js authors.
package/dist/322.cjs CHANGED
@@ -60,7 +60,6 @@ exports.modules = {
60
60
  }
61
61
  }
62
62
  const CONTENT_ROOT_SELECTOR = '#extension-root,[data-extension-root]:not([data-extension-root="extension-js-devtools"])';
63
- const NON_DEVTOOLS_CONTENT_ROOT_SELECTOR = '#extension-root,[data-extension-root]:not([data-extension-root="extension-js-devtools"])';
64
63
  const EXTENSION_ROOT_META_EXPRESSION = `(() => {
65
64
  const readGeneration = (node) => {
66
65
  try {
@@ -149,7 +148,7 @@ exports.modules = {
149
148
  const generations = roots
150
149
  .concat(markers)
151
150
  .map((entry) => entry.generation)
152
- .concat(typeof page.generation === 'number' ? [page.generation] : [])
151
+ .concat(page && typeof page.generation === 'number' ? [page.generation] : [])
153
152
  .concat(
154
153
  registries
155
154
  .map((entry) => entry.generation)
@@ -321,7 +320,7 @@ exports.modules = {
321
320
  if ('off' === includeShadow) return mainHTML;
322
321
  const hasVisibleContentRoot = await evaluateWithContentContext(cdp, sessionId, `(() => {
323
322
  try {
324
- return !!document.querySelector(${JSON.stringify(NON_DEVTOOLS_CONTENT_ROOT_SELECTOR)})
323
+ return !!document.querySelector(${JSON.stringify(CONTENT_ROOT_SELECTOR)})
325
324
  } catch {
326
325
  return false
327
326
  }
@@ -330,7 +329,7 @@ exports.modules = {
330
329
  try {
331
330
  const mergedHtmlRaw = await evaluateWithContentContext(cdp, sessionId, `(() => { try {
332
331
  var cloned = document.documentElement.cloneNode(true);
333
- var selector = ${JSON.stringify(NON_DEVTOOLS_CONTENT_ROOT_SELECTOR)};
332
+ var selector = ${JSON.stringify(CONTENT_ROOT_SELECTOR)};
334
333
  var s = new XMLSerializer();
335
334
  try {
336
335
  var liveHosts = Array.from(document.querySelectorAll(selector));
@@ -488,6 +487,7 @@ exports.modules = {
488
487
  ws.on('close', ()=>{
489
488
  if (isDev) console.log(messages.hE8());
490
489
  onRejectPending('CDP connection closed');
490
+ reject(new Error('CDP WebSocket closed before the connection opened'));
491
491
  });
492
492
  });
493
493
  }
@@ -1127,6 +1127,23 @@ exports.modules = {
1127
1127
  else obj[key] = value;
1128
1128
  return obj;
1129
1129
  }
1130
+ const __fileReadCache = new Map();
1131
+ function readTextFileCached(filePath) {
1132
+ try {
1133
+ const stat = external_fs_.statSync(filePath);
1134
+ const key = `${stat.mtimeMs}:${stat.size}`;
1135
+ const cached = __fileReadCache.get(filePath);
1136
+ if (cached && cached.key === key) return cached.text;
1137
+ const text = external_fs_.readFileSync(filePath, 'utf-8');
1138
+ __fileReadCache.set(filePath, {
1139
+ key,
1140
+ text
1141
+ });
1142
+ return text;
1143
+ } catch {
1144
+ return external_fs_.readFileSync(filePath, 'utf-8');
1145
+ }
1146
+ }
1130
1147
  class CDPExtensionController {
1131
1148
  async connect() {
1132
1149
  if (this.cdp) return;
@@ -1155,7 +1172,7 @@ exports.modules = {
1155
1172
  info = await this.cdp.getExtensionInfo(this.extensionId);
1156
1173
  } catch {}
1157
1174
  if (!info) {
1158
- const manifest = JSON.parse(external_fs_.readFileSync(external_path_.join(this.outPath, 'manifest.json'), 'utf-8'));
1175
+ const manifest = JSON.parse(readTextFileCached(external_path_.join(this.outPath, 'manifest.json')));
1159
1176
  return {
1160
1177
  extensionId: this.extensionId,
1161
1178
  name: manifest.name,
@@ -1402,7 +1419,7 @@ exports.modules = {
1402
1419
  for (const rule of matchingRules){
1403
1420
  const bundlePath = (0, content_script_targets.nG)(this.outPath, rule.index, 'js');
1404
1421
  if (!bundlePath || !external_fs_.existsSync(bundlePath)) continue;
1405
- const source = this.patchReinjectSourceForInvalidatedRuntime(external_fs_.readFileSync(bundlePath, 'utf-8'));
1422
+ const source = this.patchReinjectSourceForInvalidatedRuntime(readTextFileCached(bundlePath));
1406
1423
  if (!source.trim()) continue;
1407
1424
  const bundleId = (0, content_script_contracts.Y)(rule.index);
1408
1425
  const expression = this.buildReinjectExpression(bundleId, source, true);
@@ -1441,7 +1458,7 @@ exports.modules = {
1441
1458
  if (!jsPath || !external_fs_.existsSync(jsPath)) return null;
1442
1459
  const jsFile = external_path_.relative(this.outPath, jsPath).replace(/\\/g, '/');
1443
1460
  const cssFile = cssPath && external_fs_.existsSync(cssPath) ? external_path_.relative(this.outPath, cssPath).replace(/\\/g, '/') : null;
1444
- const jsSource = external_fs_.readFileSync(jsPath, 'utf-8');
1461
+ const jsSource = readTextFileCached(jsPath);
1445
1462
  const buildTokenMatch = jsSource.match(/__EXTENSIONJS_REINJECT_BUILD_TOKEN\s*=\s*"([^"]+)"/);
1446
1463
  const proofMatch = jsSource.match(/extjs-chromium-live-content-css-modules:script-primary-\d+/) || jsSource.match(/Live Update Proof [A-Za-z0-9_-]+/);
1447
1464
  return {
@@ -1778,7 +1795,7 @@ exports.modules = {
1778
1795
  version = info?.extensionInfo?.version;
1779
1796
  } catch {
1780
1797
  try {
1781
- const manifest = JSON.parse(external_fs_.readFileSync(external_path_.join(this.outPath, 'manifest.json'), 'utf-8'));
1798
+ const manifest = JSON.parse(readTextFileCached(external_path_.join(this.outPath, 'manifest.json')));
1782
1799
  name = manifest?.name;
1783
1800
  version = manifest?.version;
1784
1801
  } catch {}
@@ -1798,7 +1815,7 @@ exports.modules = {
1798
1815
  const bundlePath = (0, content_script_targets.nG)(this.outPath, rule.index, 'js');
1799
1816
  if (!bundlePath || !external_fs_.existsSync(bundlePath)) return false;
1800
1817
  const sourceOverride = sourceOverridesByBundleId && 'object' == typeof sourceOverridesByBundleId ? sourceOverridesByBundleId[bundleId] : void 0;
1801
- const source = this.patchReinjectSourceForInvalidatedRuntime('string' == typeof sourceOverride ? sourceOverride : external_fs_.readFileSync(bundlePath, 'utf-8'));
1818
+ const source = this.patchReinjectSourceForInvalidatedRuntime('string' == typeof sourceOverride ? sourceOverride : readTextFileCached(bundlePath));
1802
1819
  const buildTokenMatch = source.match(/__EXTENSIONJS_REINJECT_BUILD_TOKEN\s*=\s*"([^"]+)"/);
1803
1820
  const proofMatch = source.match(/extjs-chromium-live-content-css-modules:script-primary-\d+/) || source.match(/Live Update Proof [A-Za-z0-9_-]+/);
1804
1821
  if (!source.trim()) return false;