@agent-scope/cli 1.17.0 → 1.17.1

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/dist/index.cjs CHANGED
@@ -9,8 +9,8 @@ var commander = require('commander');
9
9
  var esbuild = require('esbuild');
10
10
  var module$1 = require('module');
11
11
  var readline = require('readline');
12
- var playwright$1 = require('playwright');
13
12
  var playwright = require('@agent-scope/playwright');
13
+ var playwright$1 = require('playwright');
14
14
  var http = require('http');
15
15
  var site = require('@agent-scope/site');
16
16
 
@@ -1706,6 +1706,7 @@ async function runHooksProfiling(componentName, filePath, props) {
1706
1706
  try {
1707
1707
  const context = await browser.newContext();
1708
1708
  const page = await context.newPage();
1709
+ await page.addInitScript({ content: playwright.getBrowserEntryScript() });
1709
1710
  const htmlHarness = await buildComponentHarness(filePath, componentName, props, 1280);
1710
1711
  await page.setContent(htmlHarness, { waitUntil: "load" });
1711
1712
  await page.waitForFunction(
@@ -2089,24 +2090,6 @@ Available: ${available}`
2089
2090
  var MANIFEST_PATH4 = ".reactscope/manifest.json";
2090
2091
  var DEFAULT_VIEWPORT_WIDTH = 375;
2091
2092
  var DEFAULT_VIEWPORT_HEIGHT = 812;
2092
- var _pool2 = null;
2093
- async function getPool2() {
2094
- if (_pool2 === null) {
2095
- _pool2 = new render.BrowserPool({
2096
- size: { browsers: 1, pagesPerBrowser: 1 },
2097
- viewportWidth: DEFAULT_VIEWPORT_WIDTH,
2098
- viewportHeight: DEFAULT_VIEWPORT_HEIGHT
2099
- });
2100
- await _pool2.init();
2101
- }
2102
- return _pool2;
2103
- }
2104
- async function shutdownPool2() {
2105
- if (_pool2 !== null) {
2106
- await _pool2.close();
2107
- _pool2 = null;
2108
- }
2109
- }
2110
2093
  function mapNodeType(node) {
2111
2094
  if (node.type === "forward_ref") return "forwardRef";
2112
2095
  if (node.type === "host") return "host";
@@ -2316,10 +2299,12 @@ function formatInstrumentTree(root, showProviderDepth = false) {
2316
2299
  }
2317
2300
  async function runInstrumentTree(options) {
2318
2301
  const { componentName, filePath } = options;
2319
- const pool = await getPool2();
2320
- const slot = await pool.acquire();
2321
- const { page } = slot;
2302
+ const browser = await playwright$1.chromium.launch({ headless: true });
2322
2303
  try {
2304
+ const context = await browser.newContext({
2305
+ viewport: { width: DEFAULT_VIEWPORT_WIDTH, height: DEFAULT_VIEWPORT_HEIGHT }
2306
+ });
2307
+ const page = await context.newPage();
2323
2308
  await page.addInitScript({ content: playwright.getBrowserEntryScript() });
2324
2309
  const htmlHarness = await buildComponentHarness(
2325
2310
  filePath,
@@ -2373,7 +2358,7 @@ async function runInstrumentTree(options) {
2373
2358
  }
2374
2359
  return instrumentRoot;
2375
2360
  } finally {
2376
- pool.release(slot);
2361
+ await browser.close();
2377
2362
  }
2378
2363
  }
2379
2364
  function createInstrumentTreeCommand() {
@@ -2413,7 +2398,6 @@ Available: ${available}`
2413
2398
  providerDepth: opts.providerDepth,
2414
2399
  wastedRenders: opts.wastedRenders
2415
2400
  });
2416
- await shutdownPool2();
2417
2401
  const fmt2 = resolveFormat2(opts.format);
2418
2402
  if (fmt2 === "json") {
2419
2403
  process.stdout.write(`${JSON.stringify(instrumentRoot, null, 2)}
@@ -2424,7 +2408,6 @@ Available: ${available}`
2424
2408
  `);
2425
2409
  }
2426
2410
  } catch (err) {
2427
- await shutdownPool2();
2428
2411
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
2429
2412
  `);
2430
2413
  process.exit(1);
@@ -2742,22 +2725,22 @@ async function replayInteraction2(page, steps) {
2742
2725
  }
2743
2726
  }
2744
2727
  }
2745
- var _pool3 = null;
2746
- async function getPool3() {
2747
- if (_pool3 === null) {
2748
- _pool3 = new render.BrowserPool({
2728
+ var _pool2 = null;
2729
+ async function getPool2() {
2730
+ if (_pool2 === null) {
2731
+ _pool2 = new render.BrowserPool({
2749
2732
  size: { browsers: 1, pagesPerBrowser: 2 },
2750
2733
  viewportWidth: 1280,
2751
2734
  viewportHeight: 800
2752
2735
  });
2753
- await _pool3.init();
2736
+ await _pool2.init();
2754
2737
  }
2755
- return _pool3;
2738
+ return _pool2;
2756
2739
  }
2757
- async function shutdownPool3() {
2758
- if (_pool3 !== null) {
2759
- await _pool3.close();
2760
- _pool3 = null;
2740
+ async function shutdownPool2() {
2741
+ if (_pool2 !== null) {
2742
+ await _pool2.close();
2743
+ _pool2 = null;
2761
2744
  }
2762
2745
  }
2763
2746
  async function analyzeRenders(options) {
@@ -2774,7 +2757,7 @@ Available: ${available}`
2774
2757
  const rootDir = process.cwd();
2775
2758
  const filePath = path.resolve(rootDir, descriptor.filePath);
2776
2759
  const htmlHarness = await buildComponentHarness(filePath, options.componentName, {}, 1280);
2777
- const pool = await getPool3();
2760
+ const pool = await getPool2();
2778
2761
  const slot = await pool.acquire();
2779
2762
  const { page } = slot;
2780
2763
  const startMs = performance.now();
@@ -2882,7 +2865,7 @@ function createInstrumentRendersCommand() {
2882
2865
  interaction,
2883
2866
  manifestPath: opts.manifest
2884
2867
  });
2885
- await shutdownPool3();
2868
+ await shutdownPool2();
2886
2869
  if (opts.json || !isTTY()) {
2887
2870
  process.stdout.write(`${JSON.stringify(result, null, 2)}
2888
2871
  `);
@@ -2891,7 +2874,7 @@ function createInstrumentRendersCommand() {
2891
2874
  `);
2892
2875
  }
2893
2876
  } catch (err) {
2894
- await shutdownPool3();
2877
+ await shutdownPool2();
2895
2878
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
2896
2879
  `);
2897
2880
  process.exit(1);
@@ -2951,22 +2934,22 @@ function writeReportToFile(report, outputPath, pretty) {
2951
2934
  }
2952
2935
  var MANIFEST_PATH6 = ".reactscope/manifest.json";
2953
2936
  var DEFAULT_OUTPUT_DIR = ".reactscope/renders";
2954
- var _pool4 = null;
2955
- async function getPool4(viewportWidth, viewportHeight) {
2956
- if (_pool4 === null) {
2957
- _pool4 = new render.BrowserPool({
2937
+ var _pool3 = null;
2938
+ async function getPool3(viewportWidth, viewportHeight) {
2939
+ if (_pool3 === null) {
2940
+ _pool3 = new render.BrowserPool({
2958
2941
  size: { browsers: 1, pagesPerBrowser: 4 },
2959
2942
  viewportWidth,
2960
2943
  viewportHeight
2961
2944
  });
2962
- await _pool4.init();
2945
+ await _pool3.init();
2963
2946
  }
2964
- return _pool4;
2947
+ return _pool3;
2965
2948
  }
2966
- async function shutdownPool4() {
2967
- if (_pool4 !== null) {
2968
- await _pool4.close();
2969
- _pool4 = null;
2949
+ async function shutdownPool3() {
2950
+ if (_pool3 !== null) {
2951
+ await _pool3.close();
2952
+ _pool3 = null;
2970
2953
  }
2971
2954
  }
2972
2955
  function buildRenderer(filePath, componentName, viewportWidth, viewportHeight) {
@@ -2977,7 +2960,7 @@ function buildRenderer(filePath, componentName, viewportWidth, viewportHeight) {
2977
2960
  _satori: satori,
2978
2961
  async renderCell(props, _complexityClass) {
2979
2962
  const startMs = performance.now();
2980
- const pool = await getPool4(viewportWidth, viewportHeight);
2963
+ const pool = await getPool3(viewportWidth, viewportHeight);
2981
2964
  const htmlHarness = await buildComponentHarness(
2982
2965
  filePath,
2983
2966
  componentName,
@@ -3113,7 +3096,7 @@ Available: ${available}`
3113
3096
  }
3114
3097
  }
3115
3098
  );
3116
- await shutdownPool4();
3099
+ await shutdownPool3();
3117
3100
  if (outcome.crashed) {
3118
3101
  process.stderr.write(`\u2717 Render failed: ${outcome.error.message}
3119
3102
  `);
@@ -3161,7 +3144,7 @@ Available: ${available}`
3161
3144
  );
3162
3145
  }
3163
3146
  } catch (err) {
3164
- await shutdownPool4();
3147
+ await shutdownPool3();
3165
3148
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
3166
3149
  `);
3167
3150
  process.exit(1);
@@ -3246,7 +3229,7 @@ Available: ${available}`
3246
3229
  concurrency
3247
3230
  });
3248
3231
  const result = await matrix.render();
3249
- await shutdownPool4();
3232
+ await shutdownPool3();
3250
3233
  process.stderr.write(
3251
3234
  `Done. ${result.stats.totalCells} cells, avg ${result.stats.avgRenderTimeMs.toFixed(1)}ms
3252
3235
  `
@@ -3291,7 +3274,7 @@ Available: ${available}`
3291
3274
  process.stdout.write(formatMatrixCsv(componentName, result));
3292
3275
  }
3293
3276
  } catch (err) {
3294
- await shutdownPool4();
3277
+ await shutdownPool3();
3295
3278
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
3296
3279
  `);
3297
3280
  process.exit(1);
@@ -3388,13 +3371,13 @@ function registerRenderAll(renderCmd) {
3388
3371
  workers.push(worker());
3389
3372
  }
3390
3373
  await Promise.all(workers);
3391
- await shutdownPool4();
3374
+ await shutdownPool3();
3392
3375
  process.stderr.write("\n");
3393
3376
  const summary = formatSummaryText(results, outputDir);
3394
3377
  process.stderr.write(`${summary}
3395
3378
  `);
3396
3379
  } catch (err) {
3397
- await shutdownPool4();
3380
+ await shutdownPool3();
3398
3381
  process.stderr.write(`Error: ${err instanceof Error ? err.message : String(err)}
3399
3382
  `);
3400
3383
  process.exit(1);
@@ -3436,26 +3419,26 @@ function createRenderCommand() {
3436
3419
  return renderCmd;
3437
3420
  }
3438
3421
  var DEFAULT_BASELINE_DIR = ".reactscope/baseline";
3439
- var _pool5 = null;
3440
- async function getPool5(viewportWidth, viewportHeight) {
3441
- if (_pool5 === null) {
3442
- _pool5 = new render.BrowserPool({
3422
+ var _pool4 = null;
3423
+ async function getPool4(viewportWidth, viewportHeight) {
3424
+ if (_pool4 === null) {
3425
+ _pool4 = new render.BrowserPool({
3443
3426
  size: { browsers: 1, pagesPerBrowser: 4 },
3444
3427
  viewportWidth,
3445
3428
  viewportHeight
3446
3429
  });
3447
- await _pool5.init();
3430
+ await _pool4.init();
3448
3431
  }
3449
- return _pool5;
3432
+ return _pool4;
3450
3433
  }
3451
- async function shutdownPool5() {
3452
- if (_pool5 !== null) {
3453
- await _pool5.close();
3454
- _pool5 = null;
3434
+ async function shutdownPool4() {
3435
+ if (_pool4 !== null) {
3436
+ await _pool4.close();
3437
+ _pool4 = null;
3455
3438
  }
3456
3439
  }
3457
3440
  async function renderComponent2(filePath, componentName, props, viewportWidth, viewportHeight) {
3458
- const pool = await getPool5(viewportWidth, viewportHeight);
3441
+ const pool = await getPool4(viewportWidth, viewportHeight);
3459
3442
  const htmlHarness = await buildComponentHarness(filePath, componentName, props, viewportWidth);
3460
3443
  const slot = await pool.acquire();
3461
3444
  const { page } = slot;
@@ -3705,7 +3688,7 @@ async function runBaseline(options = {}) {
3705
3688
  workers.push(worker());
3706
3689
  }
3707
3690
  await Promise.all(workers);
3708
- await shutdownPool5();
3691
+ await shutdownPool4();
3709
3692
  if (isTTY()) {
3710
3693
  process.stderr.write("\n");
3711
3694
  }
@@ -3766,26 +3749,26 @@ function loadBaselineRenderJson2(baselineDir, componentName) {
3766
3749
  if (!fs.existsSync(jsonPath)) return null;
3767
3750
  return JSON.parse(fs.readFileSync(jsonPath, "utf-8"));
3768
3751
  }
3769
- var _pool6 = null;
3770
- async function getPool6(viewportWidth, viewportHeight) {
3771
- if (_pool6 === null) {
3772
- _pool6 = new render.BrowserPool({
3752
+ var _pool5 = null;
3753
+ async function getPool5(viewportWidth, viewportHeight) {
3754
+ if (_pool5 === null) {
3755
+ _pool5 = new render.BrowserPool({
3773
3756
  size: { browsers: 1, pagesPerBrowser: 4 },
3774
3757
  viewportWidth,
3775
3758
  viewportHeight
3776
3759
  });
3777
- await _pool6.init();
3760
+ await _pool5.init();
3778
3761
  }
3779
- return _pool6;
3762
+ return _pool5;
3780
3763
  }
3781
- async function shutdownPool6() {
3782
- if (_pool6 !== null) {
3783
- await _pool6.close();
3784
- _pool6 = null;
3764
+ async function shutdownPool5() {
3765
+ if (_pool5 !== null) {
3766
+ await _pool5.close();
3767
+ _pool5 = null;
3785
3768
  }
3786
3769
  }
3787
3770
  async function renderComponent3(filePath, componentName, props, viewportWidth, viewportHeight) {
3788
- const pool = await getPool6(viewportWidth, viewportHeight);
3771
+ const pool = await getPool5(viewportWidth, viewportHeight);
3789
3772
  const htmlHarness = await buildComponentHarness(filePath, componentName, props, viewportWidth);
3790
3773
  const slot = await pool.acquire();
3791
3774
  const { page } = slot;
@@ -4034,7 +4017,7 @@ async function runDiff(options = {}) {
4034
4017
  }
4035
4018
  await Promise.all(workers);
4036
4019
  }
4037
- await shutdownPool6();
4020
+ await shutdownPool5();
4038
4021
  if (isTTY() && total > 0) {
4039
4022
  process.stderr.write("\n");
4040
4023
  }