viconic-react-icons 1.1.3 → 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 +11 -0
- package/dist/index.mjs +11 -0
- package/package.json +1 -1
- package/src/copyicons-smart-loader.js +21 -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:";
|
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:";
|
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:';
|