@agent-scope/cli 1.17.2 → 1.17.3
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/cli.js +40 -12
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +37 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -11
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/cli.js
CHANGED
|
@@ -61,9 +61,9 @@ import { Command } from "commander";
|
|
|
61
61
|
// src/component-bundler.ts
|
|
62
62
|
import { dirname } from "path";
|
|
63
63
|
import * as esbuild from "esbuild";
|
|
64
|
-
async function buildComponentHarness(filePath, componentName, props, viewportWidth, projectCss) {
|
|
64
|
+
async function buildComponentHarness(filePath, componentName, props, viewportWidth, projectCss, preScript) {
|
|
65
65
|
const bundledScript = await bundleComponentToIIFE(filePath, componentName, props);
|
|
66
|
-
return wrapInHtml(bundledScript, viewportWidth, projectCss);
|
|
66
|
+
return wrapInHtml(bundledScript, viewportWidth, projectCss, preScript);
|
|
67
67
|
}
|
|
68
68
|
async function bundleComponentToIIFE(filePath, componentName, props) {
|
|
69
69
|
const propsJson = JSON.stringify(props).replace(/<\/script>/gi, "<\\/script>");
|
|
@@ -149,10 +149,12 @@ ${msg}`);
|
|
|
149
149
|
}
|
|
150
150
|
return outputFile.text;
|
|
151
151
|
}
|
|
152
|
-
function wrapInHtml(bundledScript, viewportWidth, projectCss) {
|
|
152
|
+
function wrapInHtml(bundledScript, viewportWidth, projectCss, preScript) {
|
|
153
153
|
const projectStyleBlock = projectCss != null && projectCss.length > 0 ? `<style id="scope-project-css">
|
|
154
154
|
${projectCss.replace(/<\/style>/gi, "<\\/style>")}
|
|
155
155
|
</style>` : "";
|
|
156
|
+
const preScriptBlock = preScript != null && preScript.length > 0 ? `<script>${preScript}</script>
|
|
157
|
+
` : "";
|
|
156
158
|
return `<!DOCTYPE html>
|
|
157
159
|
<html lang="en">
|
|
158
160
|
<head>
|
|
@@ -167,7 +169,7 @@ ${projectCss.replace(/<\/style>/gi, "<\\/style>")}
|
|
|
167
169
|
</head>
|
|
168
170
|
<body>
|
|
169
171
|
<div id="scope-root" data-reactscope-root></div>
|
|
170
|
-
<script>${bundledScript}</script>
|
|
172
|
+
${preScriptBlock}<script>${bundledScript}</script>
|
|
171
173
|
</body>
|
|
172
174
|
</html>`;
|
|
173
175
|
}
|
|
@@ -1326,6 +1328,7 @@ function createInitCommand() {
|
|
|
1326
1328
|
|
|
1327
1329
|
// src/instrument/renders.ts
|
|
1328
1330
|
import { resolve as resolve7 } from "path";
|
|
1331
|
+
import { getBrowserEntryScript as getBrowserEntryScript5 } from "@agent-scope/playwright";
|
|
1329
1332
|
import { BrowserPool as BrowserPool2 } from "@agent-scope/render";
|
|
1330
1333
|
import { Command as Command5 } from "commander";
|
|
1331
1334
|
|
|
@@ -1765,8 +1768,15 @@ async function runHooksProfiling(componentName, filePath, props) {
|
|
|
1765
1768
|
try {
|
|
1766
1769
|
const context = await browser.newContext();
|
|
1767
1770
|
const page = await context.newPage();
|
|
1768
|
-
|
|
1769
|
-
const htmlHarness = await buildComponentHarness(
|
|
1771
|
+
const scopeRuntime = getBrowserEntryScript2();
|
|
1772
|
+
const htmlHarness = await buildComponentHarness(
|
|
1773
|
+
filePath,
|
|
1774
|
+
componentName,
|
|
1775
|
+
props,
|
|
1776
|
+
1280,
|
|
1777
|
+
void 0,
|
|
1778
|
+
scopeRuntime
|
|
1779
|
+
);
|
|
1770
1780
|
await page.setContent(htmlHarness, { waitUntil: "load" });
|
|
1771
1781
|
await page.waitForFunction(
|
|
1772
1782
|
() => {
|
|
@@ -1860,6 +1870,7 @@ Available: ${available}`
|
|
|
1860
1870
|
|
|
1861
1871
|
// src/instrument/profile.ts
|
|
1862
1872
|
import { resolve as resolve5 } from "path";
|
|
1873
|
+
import { getBrowserEntryScript as getBrowserEntryScript3 } from "@agent-scope/playwright";
|
|
1863
1874
|
import { Command as Cmd2 } from "commander";
|
|
1864
1875
|
import { chromium as chromium3 } from "playwright";
|
|
1865
1876
|
var MANIFEST_PATH3 = ".reactscope/manifest.json";
|
|
@@ -2030,7 +2041,15 @@ async function runInteractionProfile(componentName, filePath, props, interaction
|
|
|
2030
2041
|
try {
|
|
2031
2042
|
const context = await browser.newContext();
|
|
2032
2043
|
const page = await context.newPage();
|
|
2033
|
-
const
|
|
2044
|
+
const scopeRuntime = getBrowserEntryScript3();
|
|
2045
|
+
const htmlHarness = await buildComponentHarness(
|
|
2046
|
+
filePath,
|
|
2047
|
+
componentName,
|
|
2048
|
+
props,
|
|
2049
|
+
1280,
|
|
2050
|
+
void 0,
|
|
2051
|
+
scopeRuntime
|
|
2052
|
+
);
|
|
2034
2053
|
await page.setContent(htmlHarness, { waitUntil: "load" });
|
|
2035
2054
|
await page.waitForFunction(
|
|
2036
2055
|
() => {
|
|
@@ -2154,7 +2173,7 @@ Available: ${available}`
|
|
|
2154
2173
|
|
|
2155
2174
|
// src/instrument/tree.ts
|
|
2156
2175
|
import { resolve as resolve6 } from "path";
|
|
2157
|
-
import { getBrowserEntryScript as
|
|
2176
|
+
import { getBrowserEntryScript as getBrowserEntryScript4 } from "@agent-scope/playwright";
|
|
2158
2177
|
import { Command as Command4 } from "commander";
|
|
2159
2178
|
import { chromium as chromium4 } from "playwright";
|
|
2160
2179
|
var MANIFEST_PATH4 = ".reactscope/manifest.json";
|
|
@@ -2377,12 +2396,14 @@ async function runInstrumentTree(options) {
|
|
|
2377
2396
|
viewport: { width: DEFAULT_VIEWPORT_WIDTH, height: DEFAULT_VIEWPORT_HEIGHT }
|
|
2378
2397
|
});
|
|
2379
2398
|
const page = await context.newPage();
|
|
2380
|
-
|
|
2399
|
+
const scopeRuntime = getBrowserEntryScript4();
|
|
2381
2400
|
const htmlHarness = await buildComponentHarness(
|
|
2382
2401
|
filePath,
|
|
2383
2402
|
componentName,
|
|
2384
2403
|
{},
|
|
2385
|
-
DEFAULT_VIEWPORT_WIDTH
|
|
2404
|
+
DEFAULT_VIEWPORT_WIDTH,
|
|
2405
|
+
void 0,
|
|
2406
|
+
scopeRuntime
|
|
2386
2407
|
);
|
|
2387
2408
|
await page.setContent(htmlHarness, { waitUntil: "load" });
|
|
2388
2409
|
await page.waitForFunction(
|
|
@@ -2830,13 +2851,20 @@ Available: ${available}`
|
|
|
2830
2851
|
}
|
|
2831
2852
|
const rootDir = process.cwd();
|
|
2832
2853
|
const filePath = resolve7(rootDir, descriptor.filePath);
|
|
2833
|
-
const
|
|
2854
|
+
const preScript = getBrowserEntryScript5() + "\n" + buildInstrumentationScript();
|
|
2855
|
+
const htmlHarness = await buildComponentHarness(
|
|
2856
|
+
filePath,
|
|
2857
|
+
options.componentName,
|
|
2858
|
+
{},
|
|
2859
|
+
1280,
|
|
2860
|
+
void 0,
|
|
2861
|
+
preScript
|
|
2862
|
+
);
|
|
2834
2863
|
const pool = await getPool2();
|
|
2835
2864
|
const slot = await pool.acquire();
|
|
2836
2865
|
const { page } = slot;
|
|
2837
2866
|
const startMs = performance.now();
|
|
2838
2867
|
try {
|
|
2839
|
-
await page.addInitScript(buildInstrumentationScript());
|
|
2840
2868
|
await page.setContent(htmlHarness, { waitUntil: "load" });
|
|
2841
2869
|
await page.waitForFunction(
|
|
2842
2870
|
() => window.__SCOPE_RENDER_COMPLETE__ === true,
|