@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/index.js
CHANGED
|
@@ -440,6 +440,11 @@ var STYLE_ENTRY_CANDIDATES = [
|
|
|
440
440
|
"index.css"
|
|
441
441
|
];
|
|
442
442
|
var TAILWIND_IMPORT = /@import\s+["']tailwindcss["']\s*;?/;
|
|
443
|
+
function getElementClassNames(el) {
|
|
444
|
+
const className = el.className;
|
|
445
|
+
const raw = typeof className === "string" ? className : typeof className?.baseVal === "string" ? className.baseVal : el.getAttribute("class") ?? "";
|
|
446
|
+
return raw.split(/\s+/).filter(Boolean);
|
|
447
|
+
}
|
|
443
448
|
var compilerCache = null;
|
|
444
449
|
function getCachedBuild(cwd) {
|
|
445
450
|
if (compilerCache !== null && resolve(compilerCache.cwd) === resolve(cwd)) {
|
|
@@ -660,8 +665,8 @@ async function renderComponent(filePath, componentName, props, viewportWidth, vi
|
|
|
660
665
|
const classes = await page.evaluate(() => {
|
|
661
666
|
const set = /* @__PURE__ */ new Set();
|
|
662
667
|
document.querySelectorAll("[class]").forEach((el) => {
|
|
663
|
-
for (const c of el
|
|
664
|
-
|
|
668
|
+
for (const c of getElementClassNames(el)) {
|
|
669
|
+
set.add(c);
|
|
665
670
|
}
|
|
666
671
|
});
|
|
667
672
|
return [...set];
|
|
@@ -4054,6 +4059,39 @@ function formatAggregateRenderFailureJson(componentName, failures, scenarioCount
|
|
|
4054
4059
|
}
|
|
4055
4060
|
var MANIFEST_PATH6 = ".reactscope/manifest.json";
|
|
4056
4061
|
var DEFAULT_OUTPUT_DIR = ".reactscope/renders";
|
|
4062
|
+
function renderArtifactBaseName(componentName, scenarioName) {
|
|
4063
|
+
return scenarioName === void 0 ? componentName : `${componentName}-${scenarioName}`;
|
|
4064
|
+
}
|
|
4065
|
+
function removeStaleRenderError(outputDir, componentName, scenarioName) {
|
|
4066
|
+
const errorPath = resolve(
|
|
4067
|
+
outputDir,
|
|
4068
|
+
`${renderArtifactBaseName(componentName, scenarioName)}.error.json`
|
|
4069
|
+
);
|
|
4070
|
+
if (existsSync(errorPath)) {
|
|
4071
|
+
rmSync(errorPath, { force: true });
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
function writeRenderErrorArtifact(outputDir, failure) {
|
|
4075
|
+
const errPath = resolve(
|
|
4076
|
+
outputDir,
|
|
4077
|
+
`${renderArtifactBaseName(failure.component, failure.scenario)}.error.json`
|
|
4078
|
+
);
|
|
4079
|
+
writeFileSync(
|
|
4080
|
+
errPath,
|
|
4081
|
+
JSON.stringify(
|
|
4082
|
+
{
|
|
4083
|
+
component: failure.component,
|
|
4084
|
+
scenario: failure.scenario,
|
|
4085
|
+
errorMessage: failure.errorMessage,
|
|
4086
|
+
heuristicFlags: failure.heuristicFlags,
|
|
4087
|
+
propsAtCrash: failure.propsAtCrash
|
|
4088
|
+
},
|
|
4089
|
+
null,
|
|
4090
|
+
2
|
|
4091
|
+
)
|
|
4092
|
+
);
|
|
4093
|
+
return errPath;
|
|
4094
|
+
}
|
|
4057
4095
|
var _pool3 = null;
|
|
4058
4096
|
async function getPool3(viewportWidth, viewportHeight) {
|
|
4059
4097
|
if (_pool3 === null) {
|
|
@@ -4113,8 +4151,8 @@ function buildRenderer(filePath, componentName, viewportWidth, viewportHeight, g
|
|
|
4113
4151
|
const classes = await page.evaluate(() => {
|
|
4114
4152
|
const set = /* @__PURE__ */ new Set();
|
|
4115
4153
|
document.querySelectorAll("[class]").forEach((el) => {
|
|
4116
|
-
for (const c of el
|
|
4117
|
-
|
|
4154
|
+
for (const c of getElementClassNames(el)) {
|
|
4155
|
+
set.add(c);
|
|
4118
4156
|
}
|
|
4119
4157
|
});
|
|
4120
4158
|
return [...set];
|
|
@@ -4738,20 +4776,12 @@ function registerRenderAll(renderCmd) {
|
|
|
4738
4776
|
success: false,
|
|
4739
4777
|
errorMessage: outcome.error.message
|
|
4740
4778
|
});
|
|
4741
|
-
const errPath =
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
errorMessage: outcome.error.message,
|
|
4748
|
-
heuristicFlags: outcome.error.heuristicFlags,
|
|
4749
|
-
propsAtCrash: outcome.error.propsAtCrash
|
|
4750
|
-
},
|
|
4751
|
-
null,
|
|
4752
|
-
2
|
|
4753
|
-
)
|
|
4754
|
-
);
|
|
4779
|
+
const errPath = writeRenderErrorArtifact(outputDir, {
|
|
4780
|
+
component: name,
|
|
4781
|
+
errorMessage: outcome.error.message,
|
|
4782
|
+
heuristicFlags: outcome.error.heuristicFlags,
|
|
4783
|
+
propsAtCrash: outcome.error.propsAtCrash
|
|
4784
|
+
});
|
|
4755
4785
|
failures.push({
|
|
4756
4786
|
component: name,
|
|
4757
4787
|
stage: "render",
|
|
@@ -4764,13 +4794,14 @@ function registerRenderAll(renderCmd) {
|
|
|
4764
4794
|
}
|
|
4765
4795
|
const result = outcome.result;
|
|
4766
4796
|
results.push({ name, renderTimeMs: result.renderTimeMs, success: true });
|
|
4797
|
+
removeStaleRenderError(outputDir, name);
|
|
4767
4798
|
if (!isIcon) {
|
|
4768
4799
|
const pngPath = resolve(outputDir, `${name}.png`);
|
|
4769
4800
|
writeFileSync(pngPath, result.screenshot);
|
|
4770
4801
|
outputPaths.push(pngPath);
|
|
4771
4802
|
}
|
|
4772
4803
|
const jsonPath = resolve(outputDir, `${name}.json`);
|
|
4773
|
-
const renderJson = formatRenderJson(name,
|
|
4804
|
+
const renderJson = formatRenderJson(name, renderProps, result);
|
|
4774
4805
|
const extResult = result;
|
|
4775
4806
|
if (isIcon && extResult.svgContent) {
|
|
4776
4807
|
renderJson.svgContent = extResult.svgContent;
|
|
@@ -4831,13 +4862,34 @@ function registerRenderAll(renderCmd) {
|
|
|
4831
4862
|
concurrency: 2
|
|
4832
4863
|
});
|
|
4833
4864
|
const matrixResult = await matrix.render();
|
|
4834
|
-
const matrixCells = matrixResult.cells.map((cell) =>
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4865
|
+
const matrixCells = matrixResult.cells.map((cell) => {
|
|
4866
|
+
const scenarioName = scenarioEntries2[cell.axisIndices[0] ?? 0]?.[0] ?? "";
|
|
4867
|
+
const artifactBaseName = renderArtifactBaseName(name, scenarioName);
|
|
4868
|
+
const scenarioPngPath = resolve(outputDir, `${artifactBaseName}.png`);
|
|
4869
|
+
const scenarioJsonPath = resolve(outputDir, `${artifactBaseName}.json`);
|
|
4870
|
+
if (!isIcon) {
|
|
4871
|
+
writeFileSync(scenarioPngPath, cell.result.screenshot);
|
|
4872
|
+
outputPaths.push(scenarioPngPath);
|
|
4873
|
+
}
|
|
4874
|
+
const scenarioJson = formatRenderJson(
|
|
4875
|
+
`${name}:${scenarioName}`,
|
|
4876
|
+
scenarioPropsMap[scenarioName] ?? {},
|
|
4877
|
+
cell.result
|
|
4878
|
+
);
|
|
4879
|
+
writeFileSync(scenarioJsonPath, JSON.stringify(scenarioJson, null, 2));
|
|
4880
|
+
outputPaths.push(scenarioJsonPath);
|
|
4881
|
+
removeStaleRenderError(outputDir, name, scenarioName);
|
|
4882
|
+
return {
|
|
4883
|
+
axisValues: [scenarioName],
|
|
4884
|
+
scenario: scenarioName,
|
|
4885
|
+
outputPath: scenarioJsonPath,
|
|
4886
|
+
screenshotPath: isIcon ? void 0 : scenarioPngPath,
|
|
4887
|
+
screenshot: cell.result.screenshot.toString("base64"),
|
|
4888
|
+
width: cell.result.width,
|
|
4889
|
+
height: cell.result.height,
|
|
4890
|
+
renderTimeMs: cell.result.renderTimeMs
|
|
4891
|
+
};
|
|
4892
|
+
});
|
|
4841
4893
|
const existingJson = JSON.parse(readFileSync(jsonPath, "utf-8"));
|
|
4842
4894
|
existingJson.cells = matrixCells;
|
|
4843
4895
|
existingJson.axisLabels = [scenarioAxis.values];
|
|
@@ -4994,8 +5046,8 @@ async function renderComponent2(filePath, componentName, props, viewportWidth, v
|
|
|
4994
5046
|
const classes = await page.evaluate(() => {
|
|
4995
5047
|
const set = /* @__PURE__ */ new Set();
|
|
4996
5048
|
document.querySelectorAll("[class]").forEach((el) => {
|
|
4997
|
-
for (const c of el
|
|
4998
|
-
|
|
5049
|
+
for (const c of getElementClassNames(el)) {
|
|
5050
|
+
set.add(c);
|
|
4999
5051
|
}
|
|
5000
5052
|
});
|
|
5001
5053
|
return [...set];
|
|
@@ -5332,8 +5384,8 @@ async function renderComponent3(filePath, componentName, props, viewportWidth, v
|
|
|
5332
5384
|
const classes = await page.evaluate(() => {
|
|
5333
5385
|
const set = /* @__PURE__ */ new Set();
|
|
5334
5386
|
document.querySelectorAll("[class]").forEach((el) => {
|
|
5335
|
-
for (const c of el
|
|
5336
|
-
|
|
5387
|
+
for (const c of getElementClassNames(el)) {
|
|
5388
|
+
set.add(c);
|
|
5337
5389
|
}
|
|
5338
5390
|
});
|
|
5339
5391
|
return [...set];
|