@agent-scope/cli 1.20.1 → 1.20.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 +85 -33
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +82 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +82 -30
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/cli.js
CHANGED
|
@@ -492,6 +492,11 @@ var STYLE_ENTRY_CANDIDATES = [
|
|
|
492
492
|
"index.css"
|
|
493
493
|
];
|
|
494
494
|
var TAILWIND_IMPORT = /@import\s+["']tailwindcss["']\s*;?/;
|
|
495
|
+
function getElementClassNames(el) {
|
|
496
|
+
const className = el.className;
|
|
497
|
+
const raw = typeof className === "string" ? className : typeof className?.baseVal === "string" ? className.baseVal : el.getAttribute("class") ?? "";
|
|
498
|
+
return raw.split(/\s+/).filter(Boolean);
|
|
499
|
+
}
|
|
495
500
|
var compilerCache = null;
|
|
496
501
|
function getCachedBuild(cwd) {
|
|
497
502
|
if (compilerCache !== null && resolve(compilerCache.cwd) === resolve(cwd)) {
|
|
@@ -712,8 +717,8 @@ async function renderComponent(filePath, componentName, props, viewportWidth, vi
|
|
|
712
717
|
const classes = await page.evaluate(() => {
|
|
713
718
|
const set = /* @__PURE__ */ new Set();
|
|
714
719
|
document.querySelectorAll("[class]").forEach((el) => {
|
|
715
|
-
for (const c of el
|
|
716
|
-
|
|
720
|
+
for (const c of getElementClassNames(el)) {
|
|
721
|
+
set.add(c);
|
|
717
722
|
}
|
|
718
723
|
});
|
|
719
724
|
return [...set];
|
|
@@ -3894,7 +3899,7 @@ Examples:
|
|
|
3894
3899
|
}
|
|
3895
3900
|
|
|
3896
3901
|
// src/render-commands.ts
|
|
3897
|
-
import { existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "fs";
|
|
3902
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync9, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
3898
3903
|
import { resolve as resolve11 } from "path";
|
|
3899
3904
|
import {
|
|
3900
3905
|
ALL_CONTEXT_IDS,
|
|
@@ -4152,6 +4157,39 @@ function formatAggregateRenderFailureJson(componentName, failures, scenarioCount
|
|
|
4152
4157
|
}
|
|
4153
4158
|
var MANIFEST_PATH6 = ".reactscope/manifest.json";
|
|
4154
4159
|
var DEFAULT_OUTPUT_DIR = ".reactscope/renders";
|
|
4160
|
+
function renderArtifactBaseName(componentName, scenarioName) {
|
|
4161
|
+
return scenarioName === void 0 ? componentName : `${componentName}-${scenarioName}`;
|
|
4162
|
+
}
|
|
4163
|
+
function removeStaleRenderError(outputDir, componentName, scenarioName) {
|
|
4164
|
+
const errorPath = resolve11(
|
|
4165
|
+
outputDir,
|
|
4166
|
+
`${renderArtifactBaseName(componentName, scenarioName)}.error.json`
|
|
4167
|
+
);
|
|
4168
|
+
if (existsSync9(errorPath)) {
|
|
4169
|
+
rmSync2(errorPath, { force: true });
|
|
4170
|
+
}
|
|
4171
|
+
}
|
|
4172
|
+
function writeRenderErrorArtifact(outputDir, failure) {
|
|
4173
|
+
const errPath = resolve11(
|
|
4174
|
+
outputDir,
|
|
4175
|
+
`${renderArtifactBaseName(failure.component, failure.scenario)}.error.json`
|
|
4176
|
+
);
|
|
4177
|
+
writeFileSync6(
|
|
4178
|
+
errPath,
|
|
4179
|
+
JSON.stringify(
|
|
4180
|
+
{
|
|
4181
|
+
component: failure.component,
|
|
4182
|
+
scenario: failure.scenario,
|
|
4183
|
+
errorMessage: failure.errorMessage,
|
|
4184
|
+
heuristicFlags: failure.heuristicFlags,
|
|
4185
|
+
propsAtCrash: failure.propsAtCrash
|
|
4186
|
+
},
|
|
4187
|
+
null,
|
|
4188
|
+
2
|
|
4189
|
+
)
|
|
4190
|
+
);
|
|
4191
|
+
return errPath;
|
|
4192
|
+
}
|
|
4155
4193
|
var _pool3 = null;
|
|
4156
4194
|
async function getPool3(viewportWidth, viewportHeight) {
|
|
4157
4195
|
if (_pool3 === null) {
|
|
@@ -4211,8 +4249,8 @@ function buildRenderer(filePath, componentName, viewportWidth, viewportHeight, g
|
|
|
4211
4249
|
const classes = await page.evaluate(() => {
|
|
4212
4250
|
const set = /* @__PURE__ */ new Set();
|
|
4213
4251
|
document.querySelectorAll("[class]").forEach((el) => {
|
|
4214
|
-
for (const c of el
|
|
4215
|
-
|
|
4252
|
+
for (const c of getElementClassNames(el)) {
|
|
4253
|
+
set.add(c);
|
|
4216
4254
|
}
|
|
4217
4255
|
});
|
|
4218
4256
|
return [...set];
|
|
@@ -4836,20 +4874,12 @@ function registerRenderAll(renderCmd) {
|
|
|
4836
4874
|
success: false,
|
|
4837
4875
|
errorMessage: outcome.error.message
|
|
4838
4876
|
});
|
|
4839
|
-
const errPath =
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
errorMessage: outcome.error.message,
|
|
4846
|
-
heuristicFlags: outcome.error.heuristicFlags,
|
|
4847
|
-
propsAtCrash: outcome.error.propsAtCrash
|
|
4848
|
-
},
|
|
4849
|
-
null,
|
|
4850
|
-
2
|
|
4851
|
-
)
|
|
4852
|
-
);
|
|
4877
|
+
const errPath = writeRenderErrorArtifact(outputDir, {
|
|
4878
|
+
component: name,
|
|
4879
|
+
errorMessage: outcome.error.message,
|
|
4880
|
+
heuristicFlags: outcome.error.heuristicFlags,
|
|
4881
|
+
propsAtCrash: outcome.error.propsAtCrash
|
|
4882
|
+
});
|
|
4853
4883
|
failures.push({
|
|
4854
4884
|
component: name,
|
|
4855
4885
|
stage: "render",
|
|
@@ -4862,13 +4892,14 @@ function registerRenderAll(renderCmd) {
|
|
|
4862
4892
|
}
|
|
4863
4893
|
const result = outcome.result;
|
|
4864
4894
|
results.push({ name, renderTimeMs: result.renderTimeMs, success: true });
|
|
4895
|
+
removeStaleRenderError(outputDir, name);
|
|
4865
4896
|
if (!isIcon) {
|
|
4866
4897
|
const pngPath = resolve11(outputDir, `${name}.png`);
|
|
4867
4898
|
writeFileSync6(pngPath, result.screenshot);
|
|
4868
4899
|
outputPaths.push(pngPath);
|
|
4869
4900
|
}
|
|
4870
4901
|
const jsonPath = resolve11(outputDir, `${name}.json`);
|
|
4871
|
-
const renderJson = formatRenderJson(name,
|
|
4902
|
+
const renderJson = formatRenderJson(name, renderProps, result);
|
|
4872
4903
|
const extResult = result;
|
|
4873
4904
|
if (isIcon && extResult.svgContent) {
|
|
4874
4905
|
renderJson.svgContent = extResult.svgContent;
|
|
@@ -4929,13 +4960,34 @@ function registerRenderAll(renderCmd) {
|
|
|
4929
4960
|
concurrency: 2
|
|
4930
4961
|
});
|
|
4931
4962
|
const matrixResult = await matrix.render();
|
|
4932
|
-
const matrixCells = matrixResult.cells.map((cell) =>
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4963
|
+
const matrixCells = matrixResult.cells.map((cell) => {
|
|
4964
|
+
const scenarioName = scenarioEntries2[cell.axisIndices[0] ?? 0]?.[0] ?? "";
|
|
4965
|
+
const artifactBaseName = renderArtifactBaseName(name, scenarioName);
|
|
4966
|
+
const scenarioPngPath = resolve11(outputDir, `${artifactBaseName}.png`);
|
|
4967
|
+
const scenarioJsonPath = resolve11(outputDir, `${artifactBaseName}.json`);
|
|
4968
|
+
if (!isIcon) {
|
|
4969
|
+
writeFileSync6(scenarioPngPath, cell.result.screenshot);
|
|
4970
|
+
outputPaths.push(scenarioPngPath);
|
|
4971
|
+
}
|
|
4972
|
+
const scenarioJson = formatRenderJson(
|
|
4973
|
+
`${name}:${scenarioName}`,
|
|
4974
|
+
scenarioPropsMap[scenarioName] ?? {},
|
|
4975
|
+
cell.result
|
|
4976
|
+
);
|
|
4977
|
+
writeFileSync6(scenarioJsonPath, JSON.stringify(scenarioJson, null, 2));
|
|
4978
|
+
outputPaths.push(scenarioJsonPath);
|
|
4979
|
+
removeStaleRenderError(outputDir, name, scenarioName);
|
|
4980
|
+
return {
|
|
4981
|
+
axisValues: [scenarioName],
|
|
4982
|
+
scenario: scenarioName,
|
|
4983
|
+
outputPath: scenarioJsonPath,
|
|
4984
|
+
screenshotPath: isIcon ? void 0 : scenarioPngPath,
|
|
4985
|
+
screenshot: cell.result.screenshot.toString("base64"),
|
|
4986
|
+
width: cell.result.width,
|
|
4987
|
+
height: cell.result.height,
|
|
4988
|
+
renderTimeMs: cell.result.renderTimeMs
|
|
4989
|
+
};
|
|
4990
|
+
});
|
|
4939
4991
|
const existingJson = JSON.parse(readFileSync9(jsonPath, "utf-8"));
|
|
4940
4992
|
existingJson.cells = matrixCells;
|
|
4941
4993
|
existingJson.axisLabels = [scenarioAxis.values];
|
|
@@ -5042,7 +5094,7 @@ function createRenderCommand() {
|
|
|
5042
5094
|
}
|
|
5043
5095
|
|
|
5044
5096
|
// src/report/baseline.ts
|
|
5045
|
-
import { existsSync as existsSync10, mkdirSync as mkdirSync6, rmSync as
|
|
5097
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync6, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "fs";
|
|
5046
5098
|
import { resolve as resolve12 } from "path";
|
|
5047
5099
|
import { generateManifest as generateManifest4 } from "@agent-scope/manifest";
|
|
5048
5100
|
import { BrowserPool as BrowserPool4, safeRender as safeRender3 } from "@agent-scope/render";
|
|
@@ -5099,8 +5151,8 @@ async function renderComponent2(filePath, componentName, props, viewportWidth, v
|
|
|
5099
5151
|
const classes = await page.evaluate(() => {
|
|
5100
5152
|
const set = /* @__PURE__ */ new Set();
|
|
5101
5153
|
document.querySelectorAll("[class]").forEach((el) => {
|
|
5102
|
-
for (const c of el
|
|
5103
|
-
|
|
5154
|
+
for (const c of getElementClassNames(el)) {
|
|
5155
|
+
set.add(c);
|
|
5104
5156
|
}
|
|
5105
5157
|
});
|
|
5106
5158
|
return [...set];
|
|
@@ -5203,7 +5255,7 @@ async function runBaseline(options = {}) {
|
|
|
5203
5255
|
const baselineDir = resolve12(rootDir, outputDir);
|
|
5204
5256
|
const rendersDir = resolve12(baselineDir, "renders");
|
|
5205
5257
|
if (existsSync10(baselineDir)) {
|
|
5206
|
-
|
|
5258
|
+
rmSync3(baselineDir, { recursive: true, force: true });
|
|
5207
5259
|
}
|
|
5208
5260
|
mkdirSync6(rendersDir, { recursive: true });
|
|
5209
5261
|
let manifest;
|
|
@@ -5444,8 +5496,8 @@ async function renderComponent3(filePath, componentName, props, viewportWidth, v
|
|
|
5444
5496
|
const classes = await page.evaluate(() => {
|
|
5445
5497
|
const set = /* @__PURE__ */ new Set();
|
|
5446
5498
|
document.querySelectorAll("[class]").forEach((el) => {
|
|
5447
|
-
for (const c of el
|
|
5448
|
-
|
|
5499
|
+
for (const c of getElementClassNames(el)) {
|
|
5500
|
+
set.add(c);
|
|
5449
5501
|
}
|
|
5450
5502
|
});
|
|
5451
5503
|
return [...set];
|