@huaqiu/dsh-tool-symbol-footprint 0.5.21 → 0.6.1
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 +58 -8
- package/lib/client.js.map +1 -1
- package/package.json +13 -13
package/lib/client.js
CHANGED
|
@@ -204569,27 +204569,71 @@ ${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
|
+
/**
|
|
204604
|
+
* Re-insert the entry after the New Session row, in the family's intended
|
|
204605
|
+
* order.
|
|
204606
|
+
*
|
|
204607
|
+
* The `familySelectors` array order is the single source of truth for visual
|
|
204608
|
+
* order, so the rendered order is stable regardless of which plugin mounts
|
|
204609
|
+
* first or of observer callback order — a re-render can never swap two rows.
|
|
204610
|
+
* (Earlier builds used the `position: 'before' | 'after'` convention, which
|
|
204611
|
+
* clustered rows by mount order and let a late-mounting `before` row steal the
|
|
204612
|
+
* lead. The array order supersedes it; `position` remains only as a fallback
|
|
204613
|
+
* for a row whose selector is absent from the family list.)
|
|
204614
|
+
*/
|
|
204585
204615
|
function placeEntry(root, entry, options) {
|
|
204586
204616
|
const button = newSessionButton(root);
|
|
204587
204617
|
if (button === void 0) return false;
|
|
204588
204618
|
if (entry.parentElement !== root) {
|
|
204589
204619
|
const row = button.closest("[class*=\"logoRow\"]");
|
|
204590
204620
|
const base = row !== null && row.parentElement === root ? row : button;
|
|
204591
|
-
const
|
|
204592
|
-
const
|
|
204621
|
+
const order = options.familySelectors;
|
|
204622
|
+
const present = Array.from(root.children).filter((el) => el instanceof HTMLElement && el.matches(order.join(", "))).map((el) => ({
|
|
204623
|
+
el,
|
|
204624
|
+
idx: order.findIndex((sel) => el.matches(sel))
|
|
204625
|
+
}));
|
|
204626
|
+
const selfIndex = order.indexOf(options.rowSelector);
|
|
204627
|
+
let anchor;
|
|
204628
|
+
if (selfIndex === -1) anchor = options.position === "before" ? present.length > 0 ? present[0].el : base.nextElementSibling : present.length > 0 ? present[present.length - 1].el.nextElementSibling : base.nextElementSibling;
|
|
204629
|
+
else {
|
|
204630
|
+
const later = present.find((member) => member.idx > selfIndex);
|
|
204631
|
+
if (later !== void 0) anchor = later.el;
|
|
204632
|
+
else {
|
|
204633
|
+
const earlier = [...present].reverse().find((member) => member.idx < selfIndex);
|
|
204634
|
+
anchor = earlier !== void 0 ? earlier.el.nextElementSibling : base.nextElementSibling;
|
|
204635
|
+
}
|
|
204636
|
+
}
|
|
204593
204637
|
root.insertBefore(entry, anchor ?? null);
|
|
204594
204638
|
}
|
|
204595
204639
|
return true;
|
|
@@ -204602,13 +204646,17 @@ ${indent})`;
|
|
|
204602
204646
|
*/
|
|
204603
204647
|
function mountSidebarEntry(options) {
|
|
204604
204648
|
if (typeof document !== "undefined" && document.querySelector(options.rowSelector) !== null) return () => {};
|
|
204605
|
-
const { entry, applyLabel } = createEntry(options);
|
|
204649
|
+
const { entry, applyLabel, applyBadge } = createEntry(options);
|
|
204606
204650
|
let root;
|
|
204607
204651
|
let placed = false;
|
|
204608
204652
|
let unsubscribeRefresh;
|
|
204609
204653
|
if (options.refresh !== void 0) try {
|
|
204610
204654
|
unsubscribeRefresh = options.refresh.subscribe(applyLabel);
|
|
204611
204655
|
} catch {}
|
|
204656
|
+
let unsubscribeBadge;
|
|
204657
|
+
if (options.badge !== void 0) try {
|
|
204658
|
+
unsubscribeBadge = options.badge.subscribe(applyBadge);
|
|
204659
|
+
} catch {}
|
|
204612
204660
|
const tryPlace = () => {
|
|
204613
204661
|
if (root !== void 0 && !root.isConnected) {
|
|
204614
204662
|
rootObserver.disconnect();
|
|
@@ -204644,7 +204692,7 @@ ${indent})`;
|
|
|
204644
204692
|
}
|
|
204645
204693
|
if (!root.contains(entry)) placed = placeEntry(root, entry, options);
|
|
204646
204694
|
});
|
|
204647
|
-
|
|
204695
|
+
options.active === void 0 || (() => {
|
|
204648
204696
|
const syncActive = () => {
|
|
204649
204697
|
if (options.active.isOpen()) entry.dataset.active = "true";
|
|
204650
204698
|
else delete entry.dataset.active;
|
|
@@ -204658,7 +204706,7 @@ ${indent})`;
|
|
|
204658
204706
|
waitObserver.disconnect();
|
|
204659
204707
|
rootObserver.disconnect();
|
|
204660
204708
|
unsubscribeRefresh?.();
|
|
204661
|
-
|
|
204709
|
+
unsubscribeBadge?.();
|
|
204662
204710
|
entry.remove();
|
|
204663
204711
|
};
|
|
204664
204712
|
}
|
|
@@ -204671,9 +204719,11 @@ ${indent})`;
|
|
|
204671
204719
|
* family row means adding its selector here (and to no plugin-local list).
|
|
204672
204720
|
*/
|
|
204673
204721
|
const HUAQIU_SIDEBAR_ENTRY_FAMILY = [
|
|
204722
|
+
"[data-hq-plugin-update-entry]",
|
|
204674
204723
|
"[data-hqcg-footprint-entry]",
|
|
204675
204724
|
"[data-hqcg-symbol-entry]",
|
|
204676
|
-
"[data-hqcg-schematic-entry]"
|
|
204725
|
+
"[data-hqcg-schematic-entry]",
|
|
204726
|
+
"[data-hq-dummy-entry]"
|
|
204677
204727
|
];
|
|
204678
204728
|
//#endregion
|
|
204679
204729
|
//#region src/client/sidebar-entry.ts
|