@huaqiu/dsh-tool-symbol-footprint 0.5.21 → 0.5.22

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/lib/client.js CHANGED
@@ -204569,16 +204569,35 @@ ${indent})`;
204569
204569
  iconSpan.className = options.css["entryIcon"] ?? "";
204570
204570
  iconSpan.innerHTML = options.icon;
204571
204571
  entry.append(iconSpan, labelSpan);
204572
+ let badgeSpan = null;
204573
+ const applyBadge = () => {
204574
+ if (options.badge === void 0) return;
204575
+ const count = options.badge.count();
204576
+ if (count <= 0) {
204577
+ badgeSpan?.remove();
204578
+ badgeSpan = null;
204579
+ return;
204580
+ }
204581
+ if (badgeSpan === null) {
204582
+ badgeSpan = document.createElement("span");
204583
+ badgeSpan.className = options.css["entryBadge"] ?? "";
204584
+ entry.append(badgeSpan);
204585
+ }
204586
+ badgeSpan.textContent = String(count);
204587
+ entry.setAttribute("data-has-badge", "");
204588
+ };
204572
204589
  const applyLabel = () => {
204573
204590
  entry.setAttribute("aria-label", options.label());
204574
204591
  if (options.tooltip !== void 0) entry.setAttribute("title", options.tooltip());
204575
204592
  labelSpan.textContent = options.label();
204576
204593
  };
204577
204594
  applyLabel();
204595
+ applyBadge();
204578
204596
  entry.addEventListener("click", options.onToggle);
204579
204597
  return {
204580
204598
  entry,
204581
- applyLabel
204599
+ applyLabel,
204600
+ applyBadge
204582
204601
  };
204583
204602
  }
204584
204603
  /** Re-insert the entry after the New Session row (before the browser region). */
@@ -204602,13 +204621,17 @@ ${indent})`;
204602
204621
  */
204603
204622
  function mountSidebarEntry(options) {
204604
204623
  if (typeof document !== "undefined" && document.querySelector(options.rowSelector) !== null) return () => {};
204605
- const { entry, applyLabel } = createEntry(options);
204624
+ const { entry, applyLabel, applyBadge } = createEntry(options);
204606
204625
  let root;
204607
204626
  let placed = false;
204608
204627
  let unsubscribeRefresh;
204609
204628
  if (options.refresh !== void 0) try {
204610
204629
  unsubscribeRefresh = options.refresh.subscribe(applyLabel);
204611
204630
  } catch {}
204631
+ let unsubscribeBadge;
204632
+ if (options.badge !== void 0) try {
204633
+ unsubscribeBadge = options.badge.subscribe(applyBadge);
204634
+ } catch {}
204612
204635
  const tryPlace = () => {
204613
204636
  if (root !== void 0 && !root.isConnected) {
204614
204637
  rootObserver.disconnect();
@@ -204644,7 +204667,7 @@ ${indent})`;
204644
204667
  }
204645
204668
  if (!root.contains(entry)) placed = placeEntry(root, entry, options);
204646
204669
  });
204647
- const unsubscribeActive = options.active === void 0 ? void 0 : (() => {
204670
+ options.active === void 0 || (() => {
204648
204671
  const syncActive = () => {
204649
204672
  if (options.active.isOpen()) entry.dataset.active = "true";
204650
204673
  else delete entry.dataset.active;
@@ -204658,7 +204681,7 @@ ${indent})`;
204658
204681
  waitObserver.disconnect();
204659
204682
  rootObserver.disconnect();
204660
204683
  unsubscribeRefresh?.();
204661
- unsubscribeActive?.();
204684
+ unsubscribeBadge?.();
204662
204685
  entry.remove();
204663
204686
  };
204664
204687
  }
@@ -204673,7 +204696,8 @@ ${indent})`;
204673
204696
  const HUAQIU_SIDEBAR_ENTRY_FAMILY = [
204674
204697
  "[data-hqcg-footprint-entry]",
204675
204698
  "[data-hqcg-symbol-entry]",
204676
- "[data-hqcg-schematic-entry]"
204699
+ "[data-hqcg-schematic-entry]",
204700
+ "[data-hq-plugin-update-entry]"
204677
204701
  ];
204678
204702
  //#endregion
204679
204703
  //#region src/client/sidebar-entry.ts