viconic-react-icons 1.1.6 → 1.1.7

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 CHANGED
@@ -2019,7 +2019,8 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
2019
2019
  const isLoaded = el.classList.contains("vi-ok") || el.classList.contains("svg-loaded");
2020
2020
  if (isLoaded) return;
2021
2021
  let retries = 0;
2022
- const maxRetries = 50;
2022
+ const maxRetries = 100;
2023
+ let hasTriggeredReload = false;
2023
2024
  const timer = setInterval(() => {
2024
2025
  retries++;
2025
2026
  if (el.classList.contains("vi-ok") || el.classList.contains("svg-loaded")) {
@@ -2030,6 +2031,20 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
2030
2031
  if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
2031
2032
  window.CopyIcons.forceProcess(el);
2032
2033
  }
2034
+ if (isKitIcon && !hasTriggeredReload && retries === 10) {
2035
+ hasTriggeredReload = true;
2036
+ const prefixMatch = name.match(/^@([^\/]+)/);
2037
+ if (prefixMatch && window.CopyIconsKit) {
2038
+ const prefix = prefixMatch[1];
2039
+ for (const kitId in window.CopyIconsKit) {
2040
+ const kit = window.CopyIconsKit[kitId];
2041
+ if (kit.config && kit.config.prefix === prefix && typeof kit.reload === "function") {
2042
+ kit.reload();
2043
+ break;
2044
+ }
2045
+ }
2046
+ }
2047
+ }
2033
2048
  if (retries >= maxRetries) clearInterval(timer);
2034
2049
  }, 100);
2035
2050
  return () => clearInterval(timer);
package/dist/index.mjs CHANGED
@@ -1984,7 +1984,8 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
1984
1984
  const isLoaded = el.classList.contains("vi-ok") || el.classList.contains("svg-loaded");
1985
1985
  if (isLoaded) return;
1986
1986
  let retries = 0;
1987
- const maxRetries = 50;
1987
+ const maxRetries = 100;
1988
+ let hasTriggeredReload = false;
1988
1989
  const timer = setInterval(() => {
1989
1990
  retries++;
1990
1991
  if (el.classList.contains("vi-ok") || el.classList.contains("svg-loaded")) {
@@ -1995,6 +1996,20 @@ var ViconicIcon = ({ name, className, style, size, color, ...props }) => {
1995
1996
  if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
1996
1997
  window.CopyIcons.forceProcess(el);
1997
1998
  }
1999
+ if (isKitIcon && !hasTriggeredReload && retries === 10) {
2000
+ hasTriggeredReload = true;
2001
+ const prefixMatch = name.match(/^@([^\/]+)/);
2002
+ if (prefixMatch && window.CopyIconsKit) {
2003
+ const prefix = prefixMatch[1];
2004
+ for (const kitId in window.CopyIconsKit) {
2005
+ const kit = window.CopyIconsKit[kitId];
2006
+ if (kit.config && kit.config.prefix === prefix && typeof kit.reload === "function") {
2007
+ kit.reload();
2008
+ break;
2009
+ }
2010
+ }
2011
+ }
2012
+ }
1998
2013
  if (retries >= maxRetries) clearInterval(timer);
1999
2014
  }, 100);
2000
2015
  return () => clearInterval(timer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viconic-react-icons",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Viconic Smart Icons loader for React — supports Kit and 200k+ system icons",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/index.jsx CHANGED
@@ -93,7 +93,9 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
93
93
  if (isLoaded) return;
94
94
 
95
95
  let retries = 0;
96
- const maxRetries = 50; // 50 × 100ms = 5 seconds max
96
+ const maxRetries = 100; // 100 × 100ms = 10 seconds max
97
+ let hasTriggeredReload = false;
98
+
97
99
  const timer = setInterval(() => {
98
100
  retries++;
99
101
  if (el.classList.contains('vi-ok') || el.classList.contains('svg-loaded')) {
@@ -106,6 +108,25 @@ export const ViconicIcon = ({ name, className, style, size, color, ...props }) =
106
108
  if (window.CopyIcons && window.CopyIcons.forceProcess && !isKitIcon) {
107
109
  window.CopyIcons.forceProcess(el);
108
110
  }
111
+
112
+ // HMR / Missing Kit Icon Fallback:
113
+ // If it's a kit icon and hasn't loaded after 1 second, it might be newly added
114
+ // in the Viconic Dashboard. We trigger a background reload of the kit.
115
+ if (isKitIcon && !hasTriggeredReload && retries === 10) {
116
+ hasTriggeredReload = true;
117
+ const prefixMatch = name.match(/^@([^\/]+)/);
118
+ if (prefixMatch && window.CopyIconsKit) {
119
+ const prefix = prefixMatch[1];
120
+ for (const kitId in window.CopyIconsKit) {
121
+ const kit = window.CopyIconsKit[kitId];
122
+ if (kit.config && kit.config.prefix === prefix && typeof kit.reload === 'function') {
123
+ kit.reload();
124
+ break;
125
+ }
126
+ }
127
+ }
128
+ }
129
+
109
130
  if (retries >= maxRetries) clearInterval(timer);
110
131
  }, 100);
111
132