viconic-react-icons 1.1.2 → 1.1.4
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/dist/index.js +12 -0
- package/dist/index.mjs +12 -0
- package/package.json +1 -1
- package/src/copyicons-smart-loader.js +24 -0
package/dist/index.js
CHANGED
|
@@ -52,6 +52,17 @@ var import_react = __toESM(require("react"));
|
|
|
52
52
|
document.head.appendChild(style);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
const _origCEDefine = customElements.define.bind(customElements);
|
|
56
|
+
customElements.define = function(name, cls, opts) {
|
|
57
|
+
if (name === "viconic-icon" && cls && cls.prototype && cls.prototype._u) {
|
|
58
|
+
const origU = cls.prototype._u;
|
|
59
|
+
cls.prototype._u = function() {
|
|
60
|
+
if (this.classList.contains("svg-loaded")) return;
|
|
61
|
+
return origU.call(this);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return _origCEDefine(name, cls, opts);
|
|
65
|
+
};
|
|
55
66
|
const CACHE_TTL = 3 * 24 * 60 * 60 * 1e3;
|
|
56
67
|
const CACHE_PREFIX = "copyicons:svg:";
|
|
57
68
|
const ICON_CACHE_PREFIX = "ci:";
|
|
@@ -787,6 +798,7 @@ var import_react = __toESM(require("react"));
|
|
|
787
798
|
}
|
|
788
799
|
element.innerHTML = scopedContent;
|
|
789
800
|
element.classList.add("svg-loaded");
|
|
801
|
+
element.classList.add("vi-ok");
|
|
790
802
|
if (multiColor) {
|
|
791
803
|
element.classList.add("ci-multicolor");
|
|
792
804
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,17 @@ import React, { useEffect, useRef } from "react";
|
|
|
17
17
|
document.head.appendChild(style);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
+
const _origCEDefine = customElements.define.bind(customElements);
|
|
21
|
+
customElements.define = function(name, cls, opts) {
|
|
22
|
+
if (name === "viconic-icon" && cls && cls.prototype && cls.prototype._u) {
|
|
23
|
+
const origU = cls.prototype._u;
|
|
24
|
+
cls.prototype._u = function() {
|
|
25
|
+
if (this.classList.contains("svg-loaded")) return;
|
|
26
|
+
return origU.call(this);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return _origCEDefine(name, cls, opts);
|
|
30
|
+
};
|
|
20
31
|
const CACHE_TTL = 3 * 24 * 60 * 60 * 1e3;
|
|
21
32
|
const CACHE_PREFIX = "copyicons:svg:";
|
|
22
33
|
const ICON_CACHE_PREFIX = "ci:";
|
|
@@ -752,6 +763,7 @@ import React, { useEffect, useRef } from "react";
|
|
|
752
763
|
}
|
|
753
764
|
element.innerHTML = scopedContent;
|
|
754
765
|
element.classList.add("svg-loaded");
|
|
766
|
+
element.classList.add("vi-ok");
|
|
755
767
|
if (multiColor) {
|
|
756
768
|
element.classList.add("ci-multicolor");
|
|
757
769
|
}
|
package/package.json
CHANGED
|
@@ -42,6 +42,27 @@
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// === PROTECT SMART LOADER ICONS FROM KIT LOADER WIPE ===
|
|
46
|
+
// When Kit Loader calls customElements.define('viconic-icon', ...),
|
|
47
|
+
// the browser upgrades ALL existing <viconic-icon> elements and calls
|
|
48
|
+
// connectedCallback() → _u(). The Kit Loader's _u() clears innerHTML
|
|
49
|
+
// and removes vi-ok for any icon NOT in its W.icons registry.
|
|
50
|
+
// This wipes Smart Loader icons (like a:biorxiv-square) that were
|
|
51
|
+
// already successfully injected. We intercept define() to patch _u()
|
|
52
|
+
// so it skips elements that Smart Loader has already handled.
|
|
53
|
+
const _origCEDefine = customElements.define.bind(customElements);
|
|
54
|
+
customElements.define = function(name, cls, opts) {
|
|
55
|
+
if (name === 'viconic-icon' && cls && cls.prototype && cls.prototype._u) {
|
|
56
|
+
const origU = cls.prototype._u;
|
|
57
|
+
cls.prototype._u = function() {
|
|
58
|
+
// If Smart Loader already injected SVG, don't touch this element
|
|
59
|
+
if (this.classList.contains('svg-loaded')) return;
|
|
60
|
+
return origU.call(this);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return _origCEDefine(name, cls, opts);
|
|
64
|
+
};
|
|
65
|
+
|
|
45
66
|
// === PERFORMANCE CONSTANTS ===
|
|
46
67
|
const CACHE_TTL = 3 * 24 * 60 * 60 * 1000; // 3 days cache
|
|
47
68
|
const CACHE_PREFIX = 'copyicons:svg:';
|
|
@@ -721,6 +742,9 @@
|
|
|
721
742
|
|
|
722
743
|
element.innerHTML = scopedContent;
|
|
723
744
|
element.classList.add('svg-loaded');
|
|
745
|
+
// Also add vi-ok so Kit Loader's refresh() skips this element
|
|
746
|
+
// (Kit refresh only checks for vi-ok, not svg-loaded)
|
|
747
|
+
element.classList.add('vi-ok');
|
|
724
748
|
|
|
725
749
|
// Mark multi-color icons so CSS doesn't override their colors
|
|
726
750
|
if (multiColor) {
|