@canyonjs/report-component 0.0.9 → 0.0.10

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.
Files changed (3) hide show
  1. package/README.md +0 -0
  2. package/dist/index.js +68 -26
  3. 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__ */ jsxs("div", {
316
+ children: /* @__PURE__ */ jsx("div", {
288
317
  className: "canyon-changed-code-coverage-table-wrapper",
289
- children: [/* @__PURE__ */ jsxs("div", {
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,9 @@ 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
+ coverage = changeModeFilterIrrelevantData(coverage, diff);
418
+ const { lines } = coreFn(coverage, source);
403
419
  const ref = useRef(null);
404
420
  const hasChangedLines = addLines.length > 0 && coverage["s"] && coverage["statementMap"];
405
421
  const linesState = (() => {
@@ -524,7 +540,7 @@ const SummaryNav = ({ value, onClick, reportName }) => {
524
540
  return /* @__PURE__ */ jsx("div", {
525
541
  style: {
526
542
  display: "flex",
527
- gap: "6px",
543
+ gap: "3px",
528
544
  marginBottom: "6px",
529
545
  fontSize: "16px",
530
546
  fontWeight: "bold"
@@ -534,7 +550,7 @@ const SummaryNav = ({ value, onClick, reportName }) => {
534
550
  return /* @__PURE__ */ jsxs("div", {
535
551
  style: {
536
552
  display: "flex",
537
- gap: "6px"
553
+ gap: "3px"
538
554
  },
539
555
  children: [/* @__PURE__ */ jsx("a", {
540
556
  onClick: () => {
@@ -566,7 +582,7 @@ const SummaryMetric = ({ data, onlyChange }) => {
566
582
  "changestatements"
567
583
  ];
568
584
  return order.indexOf(key1) - order.indexOf(key2);
569
- }).filter(([key]) => (onlyChange ? ["statements", "changestatements"] : [
585
+ }).filter(([key]) => (onlyChange ? ["changestatements"] : [
570
586
  "statements",
571
587
  "branches",
572
588
  "functions",
@@ -735,7 +751,11 @@ const SummaryList = ({ dataSource, onSelect, filenameKeywords, style, onlyChange
735
751
  });
736
752
  }
737
753
  }
738
- ].filter((c) => c.key !== "changestatements" || c.key === "changestatements" && onlyChange)
754
+ ].filter((c) => {
755
+ if (c.key === "path") return true;
756
+ if (onlyChange) return c.key === "changestatements";
757
+ return c.key !== "changestatements";
758
+ })
739
759
  })
740
760
  })
741
761
  });
@@ -852,13 +872,33 @@ const SummaryTree = ({ dataSource, onSelect, style, onlyChange }) => {
852
872
  });
853
873
  }
854
874
  }
855
- ].filter((c) => c.key !== "changestatements" || c.key === "changestatements" && onlyChange)
875
+ ].filter((c) => {
876
+ if (c.key === "path") return true;
877
+ if (onlyChange) return c.key === "changestatements";
878
+ return c.key !== "changestatements";
879
+ })
856
880
  })
857
881
  })
858
882
  });
859
883
  };
860
884
  var SummaryTree_default = SummaryTree;
861
885
 
886
+ //#endregion
887
+ //#region src/icons/PhTreeView.tsx
888
+ function PhTreeViewIcon(props) {
889
+ return /* @__PURE__ */ jsx("svg", {
890
+ xmlns: "http://www.w3.org/2000/svg",
891
+ width: "1em",
892
+ height: "1em",
893
+ viewBox: "0 0 256 256",
894
+ ...props,
895
+ children: /* @__PURE__ */ jsx("path", {
896
+ fill: "currentColor",
897
+ 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"
898
+ })
899
+ });
900
+ }
901
+
862
902
  //#endregion
863
903
  //#region src/widgets/TopControl.tsx
864
904
  const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filenameKeywords, onChangeOnlyChange, onlyChange }) => {
@@ -884,10 +924,12 @@ const TopControl = ({ total, showMode, onChangeShowMode, onChangeKeywords, filen
884
924
  },
885
925
  options: [{
886
926
  label: "Code Tree",
887
- value: "tree"
927
+ value: "tree",
928
+ icon: /* @__PURE__ */ jsx(Icon, { component: PhTreeViewIcon })
888
929
  }, {
889
930
  label: "File List",
890
- value: "list"
931
+ value: "list",
932
+ icon: /* @__PURE__ */ jsx(BarsOutlined, {})
891
933
  }]
892
934
  }), /* @__PURE__ */ jsx("span", {
893
935
  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": "0.0.9",
4
+ "version": "0.0.10",
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": "^7.0.0-dev.20251215.1",
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
  },