@haoduo-icon/memory 1.0.1 → 1.0.3
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/package.json +1 -1
- package/pkg-index.js +34 -6
package/package.json
CHANGED
package/pkg-index.js
CHANGED
|
@@ -580,9 +580,11 @@ class HdIcon extends HTMLElement {
|
|
|
580
580
|
static get observedAttributes() {
|
|
581
581
|
return ["icon"];
|
|
582
582
|
}
|
|
583
|
+
_root;
|
|
583
584
|
_use = null;
|
|
584
585
|
constructor() {
|
|
585
586
|
super();
|
|
587
|
+
this._root = this.attachShadow({ mode: "open" });
|
|
586
588
|
}
|
|
587
589
|
ensureTemplate() {
|
|
588
590
|
if (this._use)
|
|
@@ -597,7 +599,7 @@ class HdIcon extends HTMLElement {
|
|
|
597
599
|
use.setAttribute("width", "100%");
|
|
598
600
|
use.setAttribute("height", "100%");
|
|
599
601
|
svg.appendChild(use);
|
|
600
|
-
this.appendChild(svg);
|
|
602
|
+
this._root.appendChild(svg);
|
|
601
603
|
this._use = use;
|
|
602
604
|
}
|
|
603
605
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
@@ -617,10 +619,35 @@ class HdIcon extends HTMLElement {
|
|
|
617
619
|
window.removeEventListener("hd-icon-registered", this.handleRegistration);
|
|
618
620
|
}
|
|
619
621
|
}
|
|
622
|
+
parseIconKey(iconKey) {
|
|
623
|
+
if (!iconKey)
|
|
624
|
+
return null;
|
|
625
|
+
const colonIndex = iconKey.indexOf(":");
|
|
626
|
+
if (colonIndex > 0 && colonIndex < iconKey.length - 1) {
|
|
627
|
+
return {
|
|
628
|
+
pkg: iconKey.slice(0, colonIndex),
|
|
629
|
+
name: iconKey.slice(colonIndex + 1)
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
const registry = getRegistry();
|
|
633
|
+
let matchedPkg = "";
|
|
634
|
+
for (const pkg of registry.keys()) {
|
|
635
|
+
if (iconKey.startsWith(pkg + "-") && pkg.length > matchedPkg.length) {
|
|
636
|
+
matchedPkg = pkg;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (matchedPkg) {
|
|
640
|
+
return {
|
|
641
|
+
pkg: matchedPkg,
|
|
642
|
+
name: iconKey.slice(matchedPkg.length + 1)
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
620
647
|
handleRegistration = (e) => {
|
|
621
648
|
const detail = e.detail;
|
|
622
649
|
const iconKey = this.getAttribute("icon");
|
|
623
|
-
if (iconKey && iconKey.startsWith(detail.pkg + ":")) {
|
|
650
|
+
if (iconKey && (iconKey.startsWith(detail.pkg + ":") || iconKey.startsWith(detail.pkg + "-"))) {
|
|
624
651
|
this.render();
|
|
625
652
|
}
|
|
626
653
|
};
|
|
@@ -629,11 +656,12 @@ class HdIcon extends HTMLElement {
|
|
|
629
656
|
const iconKey = this.getAttribute("icon");
|
|
630
657
|
if (!iconKey)
|
|
631
658
|
return;
|
|
632
|
-
const
|
|
633
|
-
if (!
|
|
634
|
-
console.warn(`[hd-icon] Invalid icon format: "${iconKey}". Expected "pkg:name".`);
|
|
659
|
+
const parsed = this.parseIconKey(iconKey);
|
|
660
|
+
if (!parsed) {
|
|
661
|
+
console.warn(`[hd-icon] Invalid icon format: "${iconKey}". Expected "pkg:name" or "pkg-name".`);
|
|
635
662
|
return;
|
|
636
663
|
}
|
|
664
|
+
const { pkg, name } = parsed;
|
|
637
665
|
const registry = getRegistry().get(pkg);
|
|
638
666
|
if (!registry) {
|
|
639
667
|
return;
|
|
@@ -678,7 +706,7 @@ if (typeof window !== "undefined") {
|
|
|
678
706
|
}
|
|
679
707
|
|
|
680
708
|
// iconpkg/memory/src-index.ts
|
|
681
|
-
var lookup = "
|
|
709
|
+
var lookup = "AAADfYkZAosYgxoAI7o2WEInYXnERSOhRnUThmRUVEdCc4iWFyNYlUcyUhZWNjp1h0kRZCgpJaE0NEQ1FZQ1ZidWZmBER3ZHVmpCZ1UzWmMjZ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MHKAAVCAAAAAAAAAABAAAAA1tZW1vcnktMDEuc3ZnAAAADW1lbW9yeS0wMi5zdmcAAAANbWVtb3J5LTAzLnN2ZwAAAA1tZW1vcnktMDQuc3Zn/////wAAAAMAAAD1AQQMC4RIyQYByyBFEpBMCZQMmiQpCIBgCCAkGrREE4ApECAhkJQgk6IAiDJkmhRMmqJokyAFghBBEpIkAZIMCIAIAaQFg6JA0wBJ0jQBCpRICBBFEBBFUjIgiBJBGyIBSxINEBAJAiJBgAZAQgIhABIEyiJFURIFAIYIwxBIApIIgRQpAAAkURApCQYJESBkCRBFAwIFQaJAUaQoQhIliYQgipBISRQogJQokpRIEJAMkYQEySJIAABAkJQoAKRIUCANABIkAjRFQYRAwBBhiQQEUAIAkSAhQSAJSJIISKIEkgJJESBpgqJkiKIlUBAISRIFQQAAAAAA";
|
|
682
710
|
var chunks = {
|
|
683
711
|
"memory-01.svg": new URL("./memory-01.svg", import.meta.url).href,
|
|
684
712
|
"memory-02.svg": new URL("./memory-02.svg", import.meta.url).href,
|