@canyonjs/report-component 0.0.9 → 1.0.15
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/README.md +0 -0
- package/dist/index.js +69 -26
- package/package.json +2 -2
package/README.md
ADDED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
import { genSummaryTreeItem } from "canyon-data";
|
|
5
5
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
6
6
|
import Highlighter from "react-highlight-words";
|
|
7
|
-
import { FileOutlined, FolderFilled } from "@ant-design/icons";
|
|
7
|
+
import Icon, { BarsOutlined, FileOutlined, FolderFilled } from "@ant-design/icons";
|
|
8
8
|
|
|
9
9
|
//#region src/components/RIf.tsx
|
|
10
10
|
const RIf = ({ condition, children }) => {
|
|
@@ -155,6 +155,35 @@ function annotateBranches(fileCoverage, structuredText) {
|
|
|
155
155
|
return arr;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/helpers/changeModeFilterIrrelevantData.ts
|
|
160
|
+
function changeModeFilterIrrelevantData(coverage, diff) {
|
|
161
|
+
const addLines = diff.additions || [];
|
|
162
|
+
const statementMap = coverage["statementMap"] || {};
|
|
163
|
+
const s = coverage["s"] || {};
|
|
164
|
+
const newStatementMap = {};
|
|
165
|
+
const newS = {};
|
|
166
|
+
Object.keys(statementMap).forEach((key) => {
|
|
167
|
+
const statement = statementMap[key];
|
|
168
|
+
const startLine = statement.start.line;
|
|
169
|
+
const endLine = statement.end.line;
|
|
170
|
+
for (let line = startLine; line <= endLine; line++) if (addLines.includes(line)) {
|
|
171
|
+
newStatementMap[key] = statement;
|
|
172
|
+
newS[key] = s[key];
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
path: coverage["path"],
|
|
178
|
+
branchMap: {},
|
|
179
|
+
b: {},
|
|
180
|
+
fnMap: {},
|
|
181
|
+
f: {},
|
|
182
|
+
statementMap: newStatementMap,
|
|
183
|
+
s: newS
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
158
187
|
//#endregion
|
|
159
188
|
//#region src/helpers/coreFn.ts
|
|
160
189
|
function coreFn(fileCoverage, fileDetail) {
|
|
@@ -284,23 +313,9 @@ const ChangedCodeCoverageTable = ({ coverage, addLines }) => {
|
|
|
284
313
|
}), /* @__PURE__ */ jsx("div", {
|
|
285
314
|
className: "canyon-changed-code-coverage-content",
|
|
286
315
|
style: { maxHeight: isOpen ? "350px" : "0" },
|
|
287
|
-
children: /* @__PURE__ */
|
|
316
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
288
317
|
className: "canyon-changed-code-coverage-table-wrapper",
|
|
289
|
-
children:
|
|
290
|
-
className: "canyon-changed-code-coverage-table-title",
|
|
291
|
-
children: [
|
|
292
|
-
"Changed Code Statements (",
|
|
293
|
-
coverageStats.totalCount,
|
|
294
|
-
") - Coverage:",
|
|
295
|
-
" ",
|
|
296
|
-
coverageStats.coveragePercent,
|
|
297
|
-
"% (",
|
|
298
|
-
coverageStats.coveredCount,
|
|
299
|
-
"/",
|
|
300
|
-
coverageStats.totalCount,
|
|
301
|
-
")"
|
|
302
|
-
]
|
|
303
|
-
}), /* @__PURE__ */ jsx(ConfigProvider, {
|
|
318
|
+
children: /* @__PURE__ */ jsx(ConfigProvider, {
|
|
304
319
|
theme: { token: { borderRadius: 0 } },
|
|
305
320
|
children: /* @__PURE__ */ jsx(Table, {
|
|
306
321
|
dataSource: relatedStatements,
|
|
@@ -334,7 +349,7 @@ const ChangedCodeCoverageTable = ({ coverage, addLines }) => {
|
|
|
334
349
|
size: "small",
|
|
335
350
|
bordered: true
|
|
336
351
|
})
|
|
337
|
-
})
|
|
352
|
+
})
|
|
338
353
|
})
|
|
339
354
|
})]
|
|
340
355
|
});
|
|
@@ -398,8 +413,10 @@ function lineNumbers(lineNumber, linesState, _addLines) {
|
|
|
398
413
|
//#endregion
|
|
399
414
|
//#region src/widgets/CoverageDetail.tsx
|
|
400
415
|
const CoverageDetail = ({ source, coverage, diff }) => {
|
|
401
|
-
const { lines } = coreFn(coverage, source);
|
|
402
416
|
const addLines = diff.additions || [];
|
|
417
|
+
console.log(addLines, "addLines");
|
|
418
|
+
coverage = addLines.length > 0 ? changeModeFilterIrrelevantData(coverage, diff) : coverage;
|
|
419
|
+
const { lines } = coreFn(coverage, source);
|
|
403
420
|
const ref = useRef(null);
|
|
404
421
|
const hasChangedLines = addLines.length > 0 && coverage["s"] && coverage["statementMap"];
|
|
405
422
|
const linesState = (() => {
|
|
@@ -524,7 +541,7 @@ const SummaryNav = ({ value, onClick, reportName }) => {
|
|
|
524
541
|
return /* @__PURE__ */ jsx("div", {
|
|
525
542
|
style: {
|
|
526
543
|
display: "flex",
|
|
527
|
-
gap: "
|
|
544
|
+
gap: "3px",
|
|
528
545
|
marginBottom: "6px",
|
|
529
546
|
fontSize: "16px",
|
|
530
547
|
fontWeight: "bold"
|
|
@@ -534,7 +551,7 @@ const SummaryNav = ({ value, onClick, reportName }) => {
|
|
|
534
551
|
return /* @__PURE__ */ jsxs("div", {
|
|
535
552
|
style: {
|
|
536
553
|
display: "flex",
|
|
537
|
-
gap: "
|
|
554
|
+
gap: "3px"
|
|
538
555
|
},
|
|
539
556
|
children: [/* @__PURE__ */ jsx("a", {
|
|
540
557
|
onClick: () => {
|
|
@@ -566,7 +583,7 @@ const SummaryMetric = ({ data, onlyChange }) => {
|
|
|
566
583
|
"changestatements"
|
|
567
584
|
];
|
|
568
585
|
return order.indexOf(key1) - order.indexOf(key2);
|
|
569
|
-
}).filter(([key]) => (onlyChange ? ["
|
|
586
|
+
}).filter(([key]) => (onlyChange ? ["changestatements"] : [
|
|
570
587
|
"statements",
|
|
571
588
|
"branches",
|
|
572
589
|
"functions",
|
|
@@ -735,7 +752,11 @@ const SummaryList = ({ dataSource, onSelect, filenameKeywords, style, onlyChange
|
|
|
735
752
|
});
|
|
736
753
|
}
|
|
737
754
|
}
|
|
738
|
-
].filter((c) =>
|
|
755
|
+
].filter((c) => {
|
|
756
|
+
if (c.key === "path") return true;
|
|
757
|
+
if (onlyChange) return c.key === "changestatements";
|
|
758
|
+
return c.key !== "changestatements";
|
|
759
|
+
})
|
|
739
760
|
})
|
|
740
761
|
})
|
|
741
762
|
});
|
|
@@ -852,13 +873,33 @@ const SummaryTree = ({ dataSource, onSelect, style, onlyChange }) => {
|
|
|
852
873
|
});
|
|
853
874
|
}
|
|
854
875
|
}
|
|
855
|
-
].filter((c) =>
|
|
876
|
+
].filter((c) => {
|
|
877
|
+
if (c.key === "path") return true;
|
|
878
|
+
if (onlyChange) return c.key === "changestatements";
|
|
879
|
+
return c.key !== "changestatements";
|
|
880
|
+
})
|
|
856
881
|
})
|
|
857
882
|
})
|
|
858
883
|
});
|
|
859
884
|
};
|
|
860
885
|
var SummaryTree_default = SummaryTree;
|
|
861
886
|
|
|
887
|
+
//#endregion
|
|
888
|
+
//#region src/icons/PhTreeView.tsx
|
|
889
|
+
function PhTreeViewIcon(props) {
|
|
890
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
891
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
892
|
+
width: "1em",
|
|
893
|
+
height: "1em",
|
|
894
|
+
viewBox: "0 0 256 256",
|
|
895
|
+
...props,
|
|
896
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
897
|
+
fill: "currentColor",
|
|
898
|
+
d: "M176 152h32a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16h-32a16 16 0 0 0-16 16v8H88V80h8a16 16 0 0 0 16-16V32a16 16 0 0 0-16-16H64a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h8v112a24 24 0 0 0 24 24h64v8a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16h-32a16 16 0 0 0-16 16v8H96a8 8 0 0 1-8-8v-64h72v8a16 16 0 0 0 16 16M64 32h32v32H64Zm112 160h32v32h-32Zm0-88h32v32h-32Z"
|
|
899
|
+
})
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
|
|
862
903
|
//#endregion
|
|
863
904
|
//#region src/widgets/TopControl.tsx
|
|
864
905
|
const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filenameKeywords, onChangeOnlyChange, onlyChange }) => {
|
|
@@ -884,10 +925,12 @@ const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filen
|
|
|
884
925
|
},
|
|
885
926
|
options: [{
|
|
886
927
|
label: "Code Tree",
|
|
887
|
-
value: "tree"
|
|
928
|
+
value: "tree",
|
|
929
|
+
icon: /* @__PURE__ */ jsx(Icon, { component: PhTreeViewIcon })
|
|
888
930
|
}, {
|
|
889
931
|
label: "File List",
|
|
890
|
-
value: "list"
|
|
932
|
+
value: "list",
|
|
933
|
+
icon: /* @__PURE__ */ jsx(BarsOutlined, {})
|
|
891
934
|
}]
|
|
892
935
|
}), /* @__PURE__ */ jsx("span", {
|
|
893
936
|
style: { fontSize: "14px" },
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canyonjs/report-component",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.15",
|
|
5
5
|
"author": "Travis Zhang<https://github.com/travzhang>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@vitejs/plugin-react": "^5.1.1",
|
|
33
33
|
"istanbul-lib-coverage": "^3.2.2",
|
|
34
34
|
"tsdown": "^0.17.0",
|
|
35
|
-
"@typescript/native-preview": "
|
|
35
|
+
"@typescript/native-preview": "7.0.0-dev.20260119.1",
|
|
36
36
|
"vite": "8.0.0-beta.0",
|
|
37
37
|
"@monaco-editor/react": "4.7.0"
|
|
38
38
|
},
|