viconic-react-icons 1.1.3 → 1.1.5
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 +20 -0
- package/dist/index.mjs +20 -0
- package/package.json +1 -1
- package/src/copyicons-smart-loader.js +31 -0
package/dist/index.js
CHANGED
|
@@ -52,6 +52,26 @@ 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) {
|
|
58
|
+
if (cls.prototype._u) {
|
|
59
|
+
const origU = cls.prototype._u;
|
|
60
|
+
cls.prototype._u = function() {
|
|
61
|
+
if (this.classList.contains("svg-loaded")) return;
|
|
62
|
+
return origU.call(this);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (cls.prototype.connectedCallback) {
|
|
66
|
+
const origCC = cls.prototype.connectedCallback;
|
|
67
|
+
cls.prototype.connectedCallback = function() {
|
|
68
|
+
if (this.classList.contains("svg-loaded")) return;
|
|
69
|
+
return origCC.call(this);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return _origCEDefine(name, cls, opts);
|
|
74
|
+
};
|
|
55
75
|
const CACHE_TTL = 3 * 24 * 60 * 60 * 1e3;
|
|
56
76
|
const CACHE_PREFIX = "copyicons:svg:";
|
|
57
77
|
const ICON_CACHE_PREFIX = "ci:";
|
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,26 @@ 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) {
|
|
23
|
+
if (cls.prototype._u) {
|
|
24
|
+
const origU = cls.prototype._u;
|
|
25
|
+
cls.prototype._u = function() {
|
|
26
|
+
if (this.classList.contains("svg-loaded")) return;
|
|
27
|
+
return origU.call(this);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (cls.prototype.connectedCallback) {
|
|
31
|
+
const origCC = cls.prototype.connectedCallback;
|
|
32
|
+
cls.prototype.connectedCallback = function() {
|
|
33
|
+
if (this.classList.contains("svg-loaded")) return;
|
|
34
|
+
return origCC.call(this);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return _origCEDefine(name, cls, opts);
|
|
39
|
+
};
|
|
20
40
|
const CACHE_TTL = 3 * 24 * 60 * 60 * 1e3;
|
|
21
41
|
const CACHE_PREFIX = "copyicons:svg:";
|
|
22
42
|
const ICON_CACHE_PREFIX = "ci:";
|
package/package.json
CHANGED
|
@@ -42,6 +42,37 @@
|
|
|
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) {
|
|
56
|
+
// Patch _u() to skip elements already handled by Smart Loader
|
|
57
|
+
if (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
|
+
// Patch connectedCallback to also guard svg-loaded
|
|
65
|
+
if (cls.prototype.connectedCallback) {
|
|
66
|
+
const origCC = cls.prototype.connectedCallback;
|
|
67
|
+
cls.prototype.connectedCallback = function() {
|
|
68
|
+
if (this.classList.contains('svg-loaded')) return;
|
|
69
|
+
return origCC.call(this);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return _origCEDefine(name, cls, opts);
|
|
74
|
+
};
|
|
75
|
+
|
|
45
76
|
// === PERFORMANCE CONSTANTS ===
|
|
46
77
|
const CACHE_TTL = 3 * 24 * 60 * 60 * 1000; // 3 days cache
|
|
47
78
|
const CACHE_PREFIX = 'copyicons:svg:';
|