@industry-theme/file-city-panel 0.2.5 → 0.2.7

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.
@@ -77,6 +77,8 @@ export declare const QUALITY_COLOR_MODES: ColorModeConfig[];
77
77
  export interface FileCityColorModesSliceData {
78
78
  /** Additional color modes to enable (beyond fileTypes and git) */
79
79
  enabledModes?: ColorMode[];
80
+ /** The currently selected color mode (set by PanelContext via events) */
81
+ selectedColorMode?: ColorMode | null;
80
82
  /** Quality data for quality-based color modes */
81
83
  qualityData?: QualitySliceData;
82
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"qualityLayers.d.ts","sourceRoot":"","sources":["../../../src/panels/utils/qualityLayers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,WAAW,CAAC,EAAE;QACZ,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;QAC1B,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;QAC9B,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;QAC5B,IAAI,CAAC,EAAE,cAAc,EAAE,CAAC;QACxB,UAAU,CAA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description: "Color by unused exports" },
14275
14275
  { id: "alexandria", name: "Documentation", description: "Color by doc coverage" }
14276
14276
  ];
14277
+ function normalizePath(path) {
14278
+ return path.startsWith("/") ? path.slice(1) : path;
14279
+ }
14277
14280
  function createCoverageHighlightLayers(buildings, fileCoverage) {
14278
14281
  const buildingsByPath = new Map(buildings.map((b) => [b.path, b]));
14279
14282
  const layerGroups = {
@@ -14291,7 +14294,8 @@ function createCoverageHighlightLayers(buildings, fileCoverage) {
14291
14294
  // No coverage data
14292
14295
  };
14293
14296
  for (const [path, building] of buildingsByPath) {
14294
- const coverage = fileCoverage[path];
14297
+ const normalizedPath = normalizePath(path);
14298
+ const coverage = fileCoverage[normalizedPath];
14295
14299
  if (coverage === void 0) {
14296
14300
  layerGroups.noData.push({
14297
14301
  path: building.path,
@@ -14395,7 +14399,7 @@ function createCoverageHighlightLayers(buildings, fileCoverage) {
14395
14399
  }
14396
14400
  function createMetricHighlightLayers(buildings, metrics, metricId, _metricName) {
14397
14401
  const buildingsByPath = new Map(buildings.map((b) => [b.path, b]));
14398
- const metricsByPath = new Map(metrics.map((m) => [m.file, m]));
14402
+ const metricsByPath = new Map(metrics.map((m) => [normalizePath(m.file), m]));
14399
14403
  const layerGroups = {
14400
14404
  clean: [],
14401
14405
  // 0 issues
@@ -14411,7 +14415,8 @@ function createMetricHighlightLayers(buildings, metrics, metricId, _metricName)
14411
14415
  // No metric data
14412
14416
  };
14413
14417
  for (const [path, building] of buildingsByPath) {
14414
- const metric = metricsByPath.get(path);
14418
+ const normalizedPath = normalizePath(path);
14419
+ const metric = metricsByPath.get(normalizedPath);
14415
14420
  if (!metric) {
14416
14421
  layerGroups.noData.push({
14417
14422
  path: building.path,
@@ -14589,7 +14594,7 @@ const CodeCityPanelContent = ({
14589
14594
  actions,
14590
14595
  events
14591
14596
  }) => {
14592
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
14597
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
14593
14598
  const { theme: theme2 } = useTheme();
14594
14599
  const [cityData, setCityData] = useState(null);
14595
14600
  const [hoverInfo, setHoverInfo] = useState(null);
@@ -14681,18 +14686,17 @@ const CodeCityPanelContent = ({
14681
14686
  const payload = event.payload;
14682
14687
  setSelectedPackagePath((payload == null ? void 0 : payload.packagePath) ?? null);
14683
14688
  });
14684
- const cleanupColorMode = events.on("quality:colorMode:select", (event) => {
14685
- const payload = event.payload;
14686
- if (payload == null ? void 0 : payload.colorMode) {
14687
- setColorMode(payload.colorMode);
14688
- }
14689
- });
14690
14689
  return () => {
14691
14690
  cleanupHover == null ? void 0 : cleanupHover();
14692
14691
  cleanupSelect == null ? void 0 : cleanupSelect();
14693
- cleanupColorMode == null ? void 0 : cleanupColorMode();
14694
14692
  };
14695
14693
  }, [events]);
14694
+ const sliceSelectedColorMode = (_c = colorModesSlice == null ? void 0 : colorModesSlice.data) == null ? void 0 : _c.selectedColorMode;
14695
+ useEffect(() => {
14696
+ if (sliceSelectedColorMode) {
14697
+ setColorMode(sliceSelectedColorMode);
14698
+ }
14699
+ }, [sliceSelectedColorMode]);
14696
14700
  const availableColorModes = useMemo(() => {
14697
14701
  var _a2;
14698
14702
  const hasGitData = (gitSlice == null ? void 0 : gitSlice.data) && (gitSlice.data.staged.length > 0 || gitSlice.data.unstaged.length > 0 || gitSlice.data.untracked.length > 0 || gitSlice.data.deleted.length > 0);
@@ -14703,7 +14707,7 @@ const CodeCityPanelContent = ({
14703
14707
  if (!(enabledModes == null ? void 0 : enabledModes.includes(mode.id))) return false;
14704
14708
  return isColorModeAvailable(mode.id, qualityData, !!hasGitData);
14705
14709
  });
14706
- }, [gitSlice == null ? void 0 : gitSlice.data, (_c = colorModesSlice == null ? void 0 : colorModesSlice.data) == null ? void 0 : _c.enabledModes, qualityData]);
14710
+ }, [gitSlice == null ? void 0 : gitSlice.data, (_d = colorModesSlice == null ? void 0 : colorModesSlice.data) == null ? void 0 : _d.enabledModes, qualityData]);
14707
14711
  useEffect(() => {
14708
14712
  const currentModeAvailable = availableColorModes.some((m) => m.id === colorMode);
14709
14713
  if (!currentModeAvailable) {
@@ -14714,7 +14718,7 @@ const CodeCityPanelContent = ({
14714
14718
  return COLOR_MODES.find((m) => m.id === colorMode) || COLOR_MODES[0];
14715
14719
  }, [colorMode]);
14716
14720
  const hoveredFileMetric = useMemo(() => {
14717
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l;
14721
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2;
14718
14722
  if (!((_a2 = hoverInfo == null ? void 0 : hoverInfo.hoveredBuilding) == null ? void 0 : _a2.path)) return null;
14719
14723
  const filePath = hoverInfo.hoveredBuilding.path;
14720
14724
  if (!qualityData) return null;
@@ -14761,7 +14765,7 @@ const CodeCityPanelContent = ({
14761
14765
  return { type: "knip", value: null, label: "No dead code data" };
14762
14766
  }
14763
14767
  case "alexandria": {
14764
- const metric = (_l = (_k2 = qualityData.fileMetrics) == null ? void 0 : _k2.alexandria) == null ? void 0 : _l.find((m) => m.file === filePath);
14768
+ const metric = (_l2 = (_k2 = qualityData.fileMetrics) == null ? void 0 : _k2.alexandria) == null ? void 0 : _l2.find((m) => m.file === filePath);
14765
14769
  if (metric) {
14766
14770
  const issues = metric.issueCount;
14767
14771
  return { type: "alexandria", value: metric, label: issues > 0 ? `${issues} doc issue${issues > 1 ? "s" : ""}` : "Well documented" };
@@ -14771,7 +14775,7 @@ const CodeCityPanelContent = ({
14771
14775
  default:
14772
14776
  return null;
14773
14777
  }
14774
- }, [(_d = hoverInfo == null ? void 0 : hoverInfo.hoveredBuilding) == null ? void 0 : _d.path, colorMode, qualityData]);
14778
+ }, [(_e = hoverInfo == null ? void 0 : hoverInfo.hoveredBuilding) == null ? void 0 : _e.path, colorMode, qualityData]);
14775
14779
  const computedTreeStats = useMemo(() => {
14776
14780
  var _a2, _b2, _c2;
14777
14781
  if (!cityData) {
@@ -15155,7 +15159,7 @@ const CodeCityPanelContent = ({
15155
15159
  } finally {
15156
15160
  setLoading(false);
15157
15161
  }
15158
- }, [fileTreeSlice == null ? void 0 : fileTreeSlice.data, fileTreeSlice == null ? void 0 : fileTreeSlice.loading, (_e = context.currentScope.repository) == null ? void 0 : _e.path]);
15162
+ }, [fileTreeSlice == null ? void 0 : fileTreeSlice.data, fileTreeSlice == null ? void 0 : fileTreeSlice.loading, (_f = context.currentScope.repository) == null ? void 0 : _f.path]);
15159
15163
  const handleFileClick = useCallback(
15160
15164
  (filePath) => {
15161
15165
  if (actions.openFile) {
@@ -15469,7 +15473,7 @@ const CodeCityPanelContent = ({
15469
15473
  textOverflow: "ellipsis",
15470
15474
  whiteSpace: "nowrap"
15471
15475
  },
15472
- children: ((_f = hoverInfo.fileTooltip) == null ? void 0 : _f.text) || ((_h = (_g = hoverInfo.hoveredDistrict) == null ? void 0 : _g.path) == null ? void 0 : _h.split("/").pop()) || ((_i = hoverInfo.hoveredDistrict) == null ? void 0 : _i.path) || "Unknown"
15476
+ children: ((_g = hoverInfo.fileTooltip) == null ? void 0 : _g.text) || ((_i = (_h = hoverInfo.hoveredDistrict) == null ? void 0 : _h.path) == null ? void 0 : _i.split("/").pop()) || ((_j = hoverInfo.hoveredDistrict) == null ? void 0 : _j.path) || "Unknown"
15473
15477
  }
15474
15478
  ),
15475
15479
  /* @__PURE__ */ jsx(
@@ -15483,7 +15487,7 @@ const CodeCityPanelContent = ({
15483
15487
  textOverflow: "ellipsis",
15484
15488
  whiteSpace: "nowrap"
15485
15489
  },
15486
- children: ((_j = hoverInfo.hoveredBuilding) == null ? void 0 : _j.path) || ((_k = hoverInfo.hoveredDistrict) == null ? void 0 : _k.path) || "/"
15490
+ children: ((_k = hoverInfo.hoveredBuilding) == null ? void 0 : _k.path) || ((_l = hoverInfo.hoveredDistrict) == null ? void 0 : _l.path) || "/"
15487
15491
  }
15488
15492
  )
15489
15493
  ]