viconic-react-icons 1.3.0 → 1.4.0
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 +10 -15
- package/dist/index.mjs +10 -15
- package/package.json +1 -1
- package/src/index.jsx +17 -26
package/dist/index.js
CHANGED
|
@@ -2061,11 +2061,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
2061
2061
|
el._u();
|
|
2062
2062
|
}
|
|
2063
2063
|
if (isInjected()) return;
|
|
2064
|
-
|
|
2065
|
-
let attempt = 0;
|
|
2066
|
-
let timerId = null;
|
|
2067
|
-
let reloadTriggered = false;
|
|
2068
|
-
function tryInject() {
|
|
2064
|
+
function tryInjectFromEvent() {
|
|
2069
2065
|
if (isInjected()) return;
|
|
2070
2066
|
const W = window.__viconic;
|
|
2071
2067
|
if (W && W.icons) {
|
|
@@ -2081,8 +2077,12 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
2081
2077
|
if (!isKitIcon && window.CopyIcons && window.CopyIcons.forceProcess) {
|
|
2082
2078
|
window.CopyIcons.forceProcess(el);
|
|
2083
2079
|
}
|
|
2084
|
-
|
|
2085
|
-
|
|
2080
|
+
}
|
|
2081
|
+
document.addEventListener("viconic:ready", tryInjectFromEvent);
|
|
2082
|
+
const fallbackTimer = setTimeout(() => {
|
|
2083
|
+
if (isInjected()) return;
|
|
2084
|
+
tryInjectFromEvent();
|
|
2085
|
+
if (!isInjected() && isKitIcon && prefixMatch) {
|
|
2086
2086
|
const prefix = prefixMatch[1];
|
|
2087
2087
|
if (window.CopyIconsKit) {
|
|
2088
2088
|
for (const kId in window.CopyIconsKit) {
|
|
@@ -2094,15 +2094,10 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
2094
2094
|
}
|
|
2095
2095
|
}
|
|
2096
2096
|
}
|
|
2097
|
-
|
|
2098
|
-
attempt++;
|
|
2099
|
-
if (attempt < delays.length) {
|
|
2100
|
-
timerId = setTimeout(tryInject, delays[attempt]);
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
timerId = setTimeout(tryInject, delays[0]);
|
|
2097
|
+
}, 500);
|
|
2104
2098
|
return () => {
|
|
2105
|
-
|
|
2099
|
+
document.removeEventListener("viconic:ready", tryInjectFromEvent);
|
|
2100
|
+
clearTimeout(fallbackTimer);
|
|
2106
2101
|
};
|
|
2107
2102
|
}, [name, className, size, color, style]);
|
|
2108
2103
|
const combinedStyle = {
|
package/dist/index.mjs
CHANGED
|
@@ -2026,11 +2026,7 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
2026
2026
|
el._u();
|
|
2027
2027
|
}
|
|
2028
2028
|
if (isInjected()) return;
|
|
2029
|
-
|
|
2030
|
-
let attempt = 0;
|
|
2031
|
-
let timerId = null;
|
|
2032
|
-
let reloadTriggered = false;
|
|
2033
|
-
function tryInject() {
|
|
2029
|
+
function tryInjectFromEvent() {
|
|
2034
2030
|
if (isInjected()) return;
|
|
2035
2031
|
const W = window.__viconic;
|
|
2036
2032
|
if (W && W.icons) {
|
|
@@ -2046,8 +2042,12 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
2046
2042
|
if (!isKitIcon && window.CopyIcons && window.CopyIcons.forceProcess) {
|
|
2047
2043
|
window.CopyIcons.forceProcess(el);
|
|
2048
2044
|
}
|
|
2049
|
-
|
|
2050
|
-
|
|
2045
|
+
}
|
|
2046
|
+
document.addEventListener("viconic:ready", tryInjectFromEvent);
|
|
2047
|
+
const fallbackTimer = setTimeout(() => {
|
|
2048
|
+
if (isInjected()) return;
|
|
2049
|
+
tryInjectFromEvent();
|
|
2050
|
+
if (!isInjected() && isKitIcon && prefixMatch) {
|
|
2051
2051
|
const prefix = prefixMatch[1];
|
|
2052
2052
|
if (window.CopyIconsKit) {
|
|
2053
2053
|
for (const kId in window.CopyIconsKit) {
|
|
@@ -2059,15 +2059,10 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
|
|
|
2059
2059
|
}
|
|
2060
2060
|
}
|
|
2061
2061
|
}
|
|
2062
|
-
|
|
2063
|
-
attempt++;
|
|
2064
|
-
if (attempt < delays.length) {
|
|
2065
|
-
timerId = setTimeout(tryInject, delays[attempt]);
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
timerId = setTimeout(tryInject, delays[0]);
|
|
2062
|
+
}, 500);
|
|
2069
2063
|
return () => {
|
|
2070
|
-
|
|
2064
|
+
document.removeEventListener("viconic:ready", tryInjectFromEvent);
|
|
2065
|
+
clearTimeout(fallbackTimer);
|
|
2071
2066
|
};
|
|
2072
2067
|
}, [name, className, size, color, style]);
|
|
2073
2068
|
const combinedStyle = {
|
package/package.json
CHANGED
package/src/index.jsx
CHANGED
|
@@ -145,18 +145,10 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
|
|
|
145
145
|
|
|
146
146
|
if (isInjected()) return;
|
|
147
147
|
|
|
148
|
-
// --- PATH 4:
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
const delays = [50, 100, 200, 400, 800, 500, 500, 500, 500, 500, 500, 500];
|
|
152
|
-
let attempt = 0;
|
|
153
|
-
let timerId = null;
|
|
154
|
-
let reloadTriggered = false;
|
|
155
|
-
|
|
156
|
-
function tryInject() {
|
|
148
|
+
// --- PATH 4: Event-driven — listen for viconic:ready fired by kit loader after register() ---
|
|
149
|
+
// Much faster than polling: icons appear the instant the loader finishes fetching them.
|
|
150
|
+
function tryInjectFromEvent() {
|
|
157
151
|
if (isInjected()) return;
|
|
158
|
-
|
|
159
|
-
// Try W.icons again (kit may have loaded by now)
|
|
160
152
|
const W = window.__viconic;
|
|
161
153
|
if (W && W.icons) {
|
|
162
154
|
const iconBaseName = prefixMatch ? prefixMatch[2] : null;
|
|
@@ -169,16 +161,20 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
|
|
|
169
161
|
return;
|
|
170
162
|
}
|
|
171
163
|
}
|
|
172
|
-
|
|
173
|
-
// Try custom element _u()
|
|
174
164
|
if (el._u) el._u();
|
|
175
165
|
if (!isKitIcon && window.CopyIcons && window.CopyIcons.forceProcess) {
|
|
176
166
|
window.CopyIcons.forceProcess(el);
|
|
177
167
|
}
|
|
168
|
+
}
|
|
178
169
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
170
|
+
document.addEventListener('viconic:ready', tryInjectFromEvent);
|
|
171
|
+
|
|
172
|
+
// --- PATH 5: Short-deadline fallback (500ms) in case script already fired before we listened ---
|
|
173
|
+
const fallbackTimer = setTimeout(() => {
|
|
174
|
+
if (isInjected()) return;
|
|
175
|
+
tryInjectFromEvent();
|
|
176
|
+
// If still not loaded after 500ms, trigger kit reload once
|
|
177
|
+
if (!isInjected() && isKitIcon && prefixMatch) {
|
|
182
178
|
const prefix = prefixMatch[1];
|
|
183
179
|
if (window.CopyIconsKit) {
|
|
184
180
|
for (const kId in window.CopyIconsKit) {
|
|
@@ -190,17 +186,12 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
|
|
|
190
186
|
}
|
|
191
187
|
}
|
|
192
188
|
}
|
|
189
|
+
}, 500);
|
|
193
190
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
timerId = setTimeout(tryInject, delays[attempt]);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
timerId = setTimeout(tryInject, delays[0]);
|
|
203
|
-
return () => { if (timerId) clearTimeout(timerId); };
|
|
191
|
+
return () => {
|
|
192
|
+
document.removeEventListener('viconic:ready', tryInjectFromEvent);
|
|
193
|
+
clearTimeout(fallbackTimer);
|
|
194
|
+
};
|
|
204
195
|
}, [name, className, size, color, style]);
|
|
205
196
|
|
|
206
197
|
const combinedStyle = {
|