viconic-react-icons 1.5.2 → 1.5.3

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
@@ -2013,6 +2013,7 @@ if (typeof document !== "undefined") {
2013
2013
  }
2014
2014
  var _kitMissQueues = {};
2015
2015
  var _kitMissTimers = {};
2016
+ var _kitQueued = {};
2016
2017
  function _resolveRegistry(prefix) {
2017
2018
  if (_kitRegistry[prefix]) return _kitRegistry[prefix];
2018
2019
  const kits = window.CopyIconsKit || {};
@@ -2036,6 +2037,9 @@ function _flushPendingMisses(prefix) {
2036
2037
  }
2037
2038
  function _dispatchBatchFetch(prefix, iconBaseName, entry) {
2038
2039
  const { kitId, api } = entry;
2040
+ if (!_kitQueued[kitId]) _kitQueued[kitId] = /* @__PURE__ */ new Set();
2041
+ if (_kitQueued[kitId].has(iconBaseName)) return;
2042
+ _kitQueued[kitId].add(iconBaseName);
2039
2043
  if (!_kitMissQueues[kitId]) _kitMissQueues[kitId] = /* @__PURE__ */ new Set();
2040
2044
  _kitMissQueues[kitId].add(iconBaseName);
2041
2045
  if (_kitMissTimers[kitId]) return;
@@ -2058,11 +2062,13 @@ function _dispatchBatchFetch(prefix, iconBaseName, entry) {
2058
2062
  W.icons[`${prefix}/${n}`] = svg;
2059
2063
  W.icons[n] = W.icons[n] || svg;
2060
2064
  }
2065
+ delete _kitQueued[kitId];
2061
2066
  try {
2062
2067
  document.dispatchEvent(new CustomEvent("viconic:ready", { detail: { prefix, kitId } }));
2063
2068
  } catch (e) {
2064
2069
  }
2065
2070
  }).catch(() => {
2071
+ delete _kitQueued[kitId];
2066
2072
  });
2067
2073
  }, 150);
2068
2074
  }
package/dist/index.mjs CHANGED
@@ -1978,6 +1978,7 @@ if (typeof document !== "undefined") {
1978
1978
  }
1979
1979
  var _kitMissQueues = {};
1980
1980
  var _kitMissTimers = {};
1981
+ var _kitQueued = {};
1981
1982
  function _resolveRegistry(prefix) {
1982
1983
  if (_kitRegistry[prefix]) return _kitRegistry[prefix];
1983
1984
  const kits = window.CopyIconsKit || {};
@@ -2001,6 +2002,9 @@ function _flushPendingMisses(prefix) {
2001
2002
  }
2002
2003
  function _dispatchBatchFetch(prefix, iconBaseName, entry) {
2003
2004
  const { kitId, api } = entry;
2005
+ if (!_kitQueued[kitId]) _kitQueued[kitId] = /* @__PURE__ */ new Set();
2006
+ if (_kitQueued[kitId].has(iconBaseName)) return;
2007
+ _kitQueued[kitId].add(iconBaseName);
2004
2008
  if (!_kitMissQueues[kitId]) _kitMissQueues[kitId] = /* @__PURE__ */ new Set();
2005
2009
  _kitMissQueues[kitId].add(iconBaseName);
2006
2010
  if (_kitMissTimers[kitId]) return;
@@ -2023,11 +2027,13 @@ function _dispatchBatchFetch(prefix, iconBaseName, entry) {
2023
2027
  W.icons[`${prefix}/${n}`] = svg;
2024
2028
  W.icons[n] = W.icons[n] || svg;
2025
2029
  }
2030
+ delete _kitQueued[kitId];
2026
2031
  try {
2027
2032
  document.dispatchEvent(new CustomEvent("viconic:ready", { detail: { prefix, kitId } }));
2028
2033
  } catch (e) {
2029
2034
  }
2030
2035
  }).catch(() => {
2036
+ delete _kitQueued[kitId];
2031
2037
  });
2032
2038
  }, 150);
2033
2039
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viconic-react-icons",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
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
@@ -62,6 +62,7 @@ if (typeof document !== 'undefined') {
62
62
  // ============================================
63
63
  const _kitMissQueues = {}; // kitId -> Set of icon names
64
64
  const _kitMissTimers = {}; // kitId -> timer handle
65
+ const _kitQueued = {}; // kitId -> Set of icon names already queued (prevents Strict Mode double-queue)
65
66
 
66
67
  function _resolveRegistry(prefix) {
67
68
  if (_kitRegistry[prefix]) return _kitRegistry[prefix];
@@ -89,10 +90,14 @@ function _flushPendingMisses(prefix) {
89
90
 
90
91
  function _dispatchBatchFetch(prefix, iconBaseName, entry) {
91
92
  const { kitId, api } = entry;
93
+ // Skip if already queued — prevents React Strict Mode double-invoke from making 2 requests
94
+ if (!_kitQueued[kitId]) _kitQueued[kitId] = new Set();
95
+ if (_kitQueued[kitId].has(iconBaseName)) return;
96
+ _kitQueued[kitId].add(iconBaseName);
92
97
  if (!_kitMissQueues[kitId]) _kitMissQueues[kitId] = new Set();
93
98
  _kitMissQueues[kitId].add(iconBaseName);
94
99
  if (_kitMissTimers[kitId]) return; // already scheduled, will pick up new additions
95
- // 150ms debounce: long enough to collect all icons across a full React render cycle
100
+ // 150ms debounce: collect all icons across the full React render cycle
96
101
  _kitMissTimers[kitId] = setTimeout(() => {
97
102
  delete _kitMissTimers[kitId];
98
103
  const names = [...(_kitMissQueues[kitId] || [])];
@@ -114,9 +119,11 @@ function _dispatchBatchFetch(prefix, iconBaseName, entry) {
114
119
  W.icons[`${prefix}/${n}`] = svg;
115
120
  W.icons[n] = W.icons[n] || svg;
116
121
  }
122
+ // Clear queued tracking so future kit updates can refetch
123
+ delete _kitQueued[kitId];
117
124
  try { document.dispatchEvent(new CustomEvent('viconic:ready', { detail: { prefix, kitId } })); } catch(e) {}
118
125
  })
119
- .catch(() => {});
126
+ .catch(() => { delete _kitQueued[kitId]; });
120
127
  }, 150);
121
128
  }
122
129