@histoire/vendors 0.17.16 → 1.0.0-alpha.1

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.
Files changed (231) hide show
  1. package/dist/client/b-floating-vue.d.ts +3 -3
  2. package/dist/client/b-floating-vue.js +2176 -2149
  3. package/dist/client/b-iconify.d.ts +1 -1
  4. package/dist/client/b-iconify.js +751 -825
  5. package/dist/client/b-pinia.d.ts +1 -1
  6. package/dist/client/b-pinia.js +130 -68
  7. package/dist/client/b-scroll.d.ts +2 -2
  8. package/dist/client/b-scroll.js +5 -52
  9. package/dist/client/b-vue-router.d.ts +1 -1
  10. package/dist/client/b-vue-router.js +385 -237
  11. package/dist/client/b-vue-use.d.ts +1 -1
  12. package/dist/client/b-vue-use.js +3898 -2871
  13. package/dist/client/b-vue.d.ts +1 -1
  14. package/dist/client/b-vue.js +1 -1
  15. package/dist/client/index.js +162 -20
  16. package/dist/client/node_modules/@babel/helper-string-parser/package.json +31 -0
  17. package/dist/client/node_modules/@babel/helper-validator-identifier/package.json +31 -0
  18. package/dist/client/node_modules/@babel/parser/package.json +10 -6
  19. package/dist/client/node_modules/@babel/parser/typings/babel-parser.d.ts +47 -31
  20. package/dist/client/node_modules/@babel/types/lib/index-legacy.d.ts +2776 -0
  21. package/dist/client/node_modules/@babel/types/lib/index.d.ts +3275 -0
  22. package/dist/client/node_modules/@babel/types/package.json +39 -0
  23. package/dist/client/node_modules/@floating-ui/core/dist/floating-ui.core.d.ts +525 -0
  24. package/dist/client/node_modules/@floating-ui/core/package.json +32 -39
  25. package/dist/client/node_modules/@floating-ui/dom/package.json +23 -24
  26. package/dist/client/node_modules/@floating-ui/dom/src/autoUpdate.d.ts +31 -0
  27. package/dist/client/node_modules/@floating-ui/dom/src/index.d.ts +11 -7
  28. package/dist/client/node_modules/@floating-ui/dom/src/platform.d.ts +1 -1
  29. package/dist/client/node_modules/@floating-ui/dom/src/types.d.ts +121 -20
  30. package/dist/client/node_modules/@floating-ui/dom/src/utils/getBoundingClientRect.d.ts +1 -1
  31. package/dist/client/node_modules/@floating-ui/dom/src/utils/getClippingRect.d.ts +12 -0
  32. package/dist/client/node_modules/@floating-ui/dom/src/utils/getCssDimensions.d.ts +4 -0
  33. package/dist/client/node_modules/@floating-ui/dom/src/utils/getDimensions.d.ts +1 -1
  34. package/dist/client/node_modules/@floating-ui/dom/src/utils/getNearestOverflowAncestor.d.ts +1 -0
  35. package/dist/client/node_modules/@floating-ui/dom/src/utils/getOverflowAncestors.d.ts +3 -0
  36. package/dist/client/node_modules/@floating-ui/dom/src/utils/getScale.d.ts +7 -0
  37. package/dist/client/node_modules/@floating-ui/dom/src/utils/getViewportRect.d.ts +2 -2
  38. package/dist/client/node_modules/@floating-ui/dom/src/utils/getWindowScrollBarX.d.ts +1 -1
  39. package/dist/client/node_modules/@floating-ui/dom/src/utils/is.d.ts +3 -1
  40. package/dist/client/node_modules/@floating-ui/dom/src/utils/unwrapElement.d.ts +2 -0
  41. package/dist/client/node_modules/@floating-ui/dom/src/utils/userAgent.d.ts +1 -0
  42. package/dist/client/node_modules/@floating-ui/dom/src/utils/window.d.ts +1 -2
  43. package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.ts +103 -0
  44. package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.ts +47 -0
  45. package/dist/client/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.d.ts +47 -0
  46. package/dist/client/node_modules/@floating-ui/utils/dom/package.json +6 -0
  47. package/dist/client/node_modules/@floating-ui/utils/package.json +70 -0
  48. package/dist/client/node_modules/@iconify/types/package.json +23 -0
  49. package/dist/client/node_modules/@iconify/types/provider.d.ts +44 -0
  50. package/dist/client/node_modules/@iconify/types/types.d.ts +272 -0
  51. package/dist/client/node_modules/@iconify/vue/dist/iconify.d.ts +72 -330
  52. package/dist/client/node_modules/@iconify/vue/dist/offline.d.ts +28 -268
  53. package/dist/client/node_modules/@iconify/vue/package.json +64 -60
  54. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/scopes.d.ts +49 -0
  55. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts +2 -0
  56. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/strings.d.ts +15 -0
  57. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/vlq.d.ts +6 -0
  58. package/dist/client/node_modules/@jridgewell/sourcemap-codec/package.json +3 -2
  59. package/dist/client/node_modules/@types/web-bluetooth/index.d.ts +33 -14
  60. package/dist/client/node_modules/@types/web-bluetooth/package.json +12 -12
  61. package/dist/client/node_modules/@vue/compiler-core/dist/compiler-core.d.ts +218 -125
  62. package/dist/client/node_modules/@vue/compiler-core/package.json +20 -5
  63. package/dist/client/node_modules/@vue/compiler-dom/dist/compiler-dom.d.ts +6 -3
  64. package/dist/client/node_modules/@vue/compiler-dom/package.json +17 -3
  65. package/dist/client/node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts +35 -25
  66. package/dist/client/node_modules/@vue/compiler-sfc/package.json +27 -18
  67. package/dist/client/node_modules/@vue/compiler-ssr/dist/compiler-ssr.d.ts +2 -2
  68. package/dist/client/node_modules/@vue/compiler-ssr/package.json +3 -3
  69. package/dist/client/node_modules/@vue/devtools-api/package.json +1 -1
  70. package/dist/client/node_modules/@vue/reactivity/dist/reactivity.d.ts +268 -166
  71. package/dist/client/node_modules/@vue/reactivity/package.json +16 -2
  72. package/dist/client/node_modules/@vue/runtime-core/dist/runtime-core.d.ts +728 -529
  73. package/dist/client/node_modules/@vue/runtime-core/package.json +17 -3
  74. package/dist/client/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +195 -86
  75. package/dist/client/node_modules/@vue/runtime-dom/package.json +22 -4
  76. package/dist/client/node_modules/@vue/server-renderer/dist/server-renderer.d.ts +4 -8
  77. package/dist/client/node_modules/@vue/server-renderer/package.json +18 -4
  78. package/dist/client/node_modules/@vue/shared/dist/shared.d.ts +45 -30
  79. package/dist/client/node_modules/@vue/shared/package.json +15 -1
  80. package/dist/client/node_modules/@vueuse/core/index.d.ts +2040 -633
  81. package/dist/client/node_modules/@vueuse/core/package.json +10 -12
  82. package/dist/client/node_modules/@vueuse/metadata/index.d.ts +7 -5
  83. package/dist/client/node_modules/@vueuse/metadata/package.json +4 -4
  84. package/dist/client/node_modules/@vueuse/shared/index.d.ts +410 -273
  85. package/dist/client/node_modules/@vueuse/shared/package.json +5 -6
  86. package/dist/client/node_modules/compute-scroll-into-view/dist/index.d.ts +75 -0
  87. package/dist/client/node_modules/compute-scroll-into-view/package.json +35 -45
  88. package/dist/client/node_modules/entities/lib/decode.d.ts +211 -0
  89. package/dist/client/node_modules/entities/lib/decode_codepoint.d.ts +19 -0
  90. package/dist/client/node_modules/entities/lib/encode.d.ts +22 -0
  91. package/dist/client/node_modules/entities/lib/escape.d.ts +43 -0
  92. package/dist/client/node_modules/entities/lib/esm/decode.d.ts +211 -0
  93. package/dist/client/node_modules/entities/lib/esm/decode_codepoint.d.ts +19 -0
  94. package/dist/client/node_modules/entities/lib/esm/encode.d.ts +22 -0
  95. package/dist/client/node_modules/entities/lib/esm/escape.d.ts +43 -0
  96. package/dist/client/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +3 -0
  97. package/dist/client/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +3 -0
  98. package/dist/client/node_modules/entities/lib/esm/generated/encode-html.d.ts +8 -0
  99. package/dist/client/node_modules/entities/lib/esm/index.d.ts +96 -0
  100. package/dist/client/node_modules/entities/lib/esm/package.json +1 -0
  101. package/dist/client/node_modules/entities/lib/generated/decode-data-html.d.ts +3 -0
  102. package/dist/client/node_modules/entities/lib/generated/decode-data-xml.d.ts +3 -0
  103. package/dist/client/node_modules/entities/lib/generated/encode-html.d.ts +8 -0
  104. package/dist/client/node_modules/entities/lib/index.d.ts +96 -0
  105. package/dist/client/node_modules/entities/package.json +90 -0
  106. package/dist/client/node_modules/floating-vue/dist/components/Dropdown.d.ts +398 -0
  107. package/dist/client/node_modules/floating-vue/dist/components/Menu.d.ts +398 -0
  108. package/dist/client/node_modules/floating-vue/dist/components/Popper.d.ts +225 -105
  109. package/dist/client/node_modules/floating-vue/dist/components/Popper.vue.d.ts +471 -364
  110. package/dist/client/node_modules/floating-vue/dist/components/PopperContent.vue.d.ts +14 -25
  111. package/dist/client/node_modules/floating-vue/dist/components/PopperWrapper.vue.d.ts +392 -6
  112. package/dist/client/node_modules/floating-vue/dist/components/Tooltip.d.ts +398 -0
  113. package/dist/client/node_modules/floating-vue/dist/components/TooltipDirective.vue.d.ts +49 -10
  114. package/dist/client/node_modules/floating-vue/dist/config.d.ts +1 -1
  115. package/dist/client/node_modules/floating-vue/dist/index.d.ts +2071 -247
  116. package/dist/client/node_modules/floating-vue/dist/util/events.d.ts +2 -0
  117. package/dist/client/node_modules/floating-vue/dist/util/popper.d.ts +1 -1
  118. package/dist/client/node_modules/floating-vue/package.json +42 -33
  119. package/dist/client/node_modules/magic-string/dist/magic-string.cjs.d.ts +250 -229
  120. package/dist/client/node_modules/magic-string/package.json +24 -26
  121. package/dist/client/node_modules/nanoid/package.json +1 -1
  122. package/dist/client/node_modules/picocolors/package.json +2 -2
  123. package/dist/client/node_modules/picocolors/types.d.ts +51 -0
  124. package/dist/client/node_modules/pinia/dist/pinia.d.ts +116 -37
  125. package/dist/client/node_modules/pinia/package.json +7 -11
  126. package/dist/client/node_modules/postcss/lib/at-rule.d.ts +25 -22
  127. package/dist/client/node_modules/postcss/lib/comment.d.ts +10 -9
  128. package/dist/client/node_modules/postcss/lib/container.d.ts +47 -54
  129. package/dist/client/node_modules/postcss/lib/css-syntax-error.d.ts +1 -1
  130. package/dist/client/node_modules/postcss/lib/declaration.d.ts +20 -17
  131. package/dist/client/node_modules/postcss/lib/document.d.ts +4 -4
  132. package/dist/client/node_modules/postcss/lib/input.d.ts +14 -0
  133. package/dist/client/node_modules/postcss/lib/list.d.ts +5 -2
  134. package/dist/client/node_modules/postcss/lib/node.d.ts +19 -14
  135. package/dist/client/node_modules/postcss/lib/postcss.d.ts +25 -8
  136. package/dist/client/node_modules/postcss/lib/processor.d.ts +1 -1
  137. package/dist/client/node_modules/postcss/lib/result.d.ts +0 -1
  138. package/dist/client/node_modules/postcss/lib/root.d.ts +4 -4
  139. package/dist/client/node_modules/postcss/lib/rule.d.ts +27 -18
  140. package/dist/client/node_modules/postcss/package.json +4 -4
  141. package/dist/client/node_modules/scroll-into-view-if-needed/dist/index.d.ts +79 -0
  142. package/dist/client/node_modules/scroll-into-view-if-needed/package.json +28 -67
  143. package/dist/client/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
  144. package/dist/client/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
  145. package/dist/client/node_modules/source-map-js/lib/source-node.d.ts +1 -0
  146. package/dist/client/node_modules/source-map-js/package.json +1 -1
  147. package/dist/client/node_modules/source-map-js/source-map.d.ts +88 -99
  148. package/dist/client/node_modules/vue/dist/vue.d.ts +0 -4
  149. package/dist/client/node_modules/vue/jsx-runtime/index.d.ts +2 -1
  150. package/dist/client/node_modules/vue/jsx.d.ts +2 -1
  151. package/dist/client/node_modules/vue/package.json +13 -14
  152. package/dist/client/node_modules/{pinia/node_modules/vue-demi → vue-demi}/package.json +1 -1
  153. package/dist/client/node_modules/vue-router/dist/vue-router.d.ts +410 -81
  154. package/dist/client/node_modules/vue-router/package.json +66 -37
  155. package/dist/client/node_modules/vue-router/vue-router-auto-routes.d.ts +4 -0
  156. package/dist/client/node_modules/vue-router/vue-router-auto.d.ts +4 -0
  157. package/dist/client/vue.runtime.esm-bundler.js +6458 -4714
  158. package/floating-vue.d.ts +1 -0
  159. package/iconify.d.ts +1 -0
  160. package/package.json +20 -20
  161. package/pinia.d.ts +1 -0
  162. package/rollup.config.mjs +11 -9
  163. package/scroll.d.ts +1 -0
  164. package/src/client/b-floating-vue.ts +2 -0
  165. package/src/client/b-scroll.ts +2 -0
  166. package/tsconfig.json +17 -17
  167. package/vue-router.d.ts +1 -0
  168. package/vue-use.d.ts +1 -0
  169. package/vue.d.ts +1 -0
  170. package/dist/client/index2.js +0 -168
  171. package/dist/client/node_modules/@floating-ui/core/index.d.ts +0 -1
  172. package/dist/client/node_modules/@floating-ui/core/src/_babel.d.ts +0 -1
  173. package/dist/client/node_modules/@floating-ui/core/src/computeCoordsFromPlacement.d.ts +0 -4
  174. package/dist/client/node_modules/@floating-ui/core/src/computePosition.d.ts +0 -2
  175. package/dist/client/node_modules/@floating-ui/core/src/detectOverflow.d.ts +0 -9
  176. package/dist/client/node_modules/@floating-ui/core/src/enums.d.ts +0 -4
  177. package/dist/client/node_modules/@floating-ui/core/src/index.d.ts +0 -11
  178. package/dist/client/node_modules/@floating-ui/core/src/middleware/arrow.d.ts +0 -6
  179. package/dist/client/node_modules/@floating-ui/core/src/middleware/autoPlacement.d.ts +0 -9
  180. package/dist/client/node_modules/@floating-ui/core/src/middleware/flip.d.ts +0 -10
  181. package/dist/client/node_modules/@floating-ui/core/src/middleware/hide.d.ts +0 -2
  182. package/dist/client/node_modules/@floating-ui/core/src/middleware/inline.d.ts +0 -5
  183. package/dist/client/node_modules/@floating-ui/core/src/middleware/offset.d.ts +0 -21
  184. package/dist/client/node_modules/@floating-ui/core/src/middleware/shift.d.ts +0 -32
  185. package/dist/client/node_modules/@floating-ui/core/src/middleware/size.d.ts +0 -6
  186. package/dist/client/node_modules/@floating-ui/core/src/types.d.ts +0 -148
  187. package/dist/client/node_modules/@floating-ui/core/src/utils/expandPaddingObject.d.ts +0 -2
  188. package/dist/client/node_modules/@floating-ui/core/src/utils/getAlignment.d.ts +0 -2
  189. package/dist/client/node_modules/@floating-ui/core/src/utils/getAlignmentSides.d.ts +0 -5
  190. package/dist/client/node_modules/@floating-ui/core/src/utils/getBasePlacement.d.ts +0 -2
  191. package/dist/client/node_modules/@floating-ui/core/src/utils/getCrossAxis.d.ts +0 -2
  192. package/dist/client/node_modules/@floating-ui/core/src/utils/getExpandedPlacements.d.ts +0 -2
  193. package/dist/client/node_modules/@floating-ui/core/src/utils/getLengthFromAxis.d.ts +0 -2
  194. package/dist/client/node_modules/@floating-ui/core/src/utils/getMainAxisFromPlacement.d.ts +0 -2
  195. package/dist/client/node_modules/@floating-ui/core/src/utils/getOppositeAlignmentPlacement.d.ts +0 -2
  196. package/dist/client/node_modules/@floating-ui/core/src/utils/getOppositePlacement.d.ts +0 -1
  197. package/dist/client/node_modules/@floating-ui/core/src/utils/getPaddingObject.d.ts +0 -2
  198. package/dist/client/node_modules/@floating-ui/core/src/utils/math.d.ts +0 -2
  199. package/dist/client/node_modules/@floating-ui/core/src/utils/rectToClientRect.d.ts +0 -2
  200. package/dist/client/node_modules/@floating-ui/core/src/utils/within.d.ts +0 -1
  201. package/dist/client/node_modules/@floating-ui/dom/src/utils/contains.d.ts +0 -1
  202. package/dist/client/node_modules/@floating-ui/dom/src/utils/getClippingClientRect.d.ts +0 -6
  203. package/dist/client/node_modules/@floating-ui/dom/src/utils/getScrollParent.d.ts +0 -1
  204. package/dist/client/node_modules/@floating-ui/dom/src/utils/getScrollParents.d.ts +0 -1
  205. package/dist/client/node_modules/@vue/reactivity-transform/dist/reactivity-transform.d.ts +0 -43
  206. package/dist/client/node_modules/@vue/reactivity-transform/package.json +0 -41
  207. package/dist/client/node_modules/@vueuse/core/node_modules/vue-demi/package.json +0 -47
  208. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/index.d.ts +0 -22
  209. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v2/index.d.ts +0 -33
  210. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v2.7/index.d.ts +0 -38
  211. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v3/index.d.ts +0 -22
  212. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/package.json +0 -47
  213. package/dist/client/node_modules/compute-scroll-into-view/typings/index.d.ts +0 -19
  214. package/dist/client/node_modules/floating-vue/dist/components/Dropdown.vue.d.ts +0 -25
  215. package/dist/client/node_modules/floating-vue/dist/components/Menu.vue.d.ts +0 -25
  216. package/dist/client/node_modules/floating-vue/dist/components/Tooltip.vue.d.ts +0 -25
  217. package/dist/client/node_modules/floating-vue/src/global-shim.d.ts +0 -1
  218. package/dist/client/node_modules/floating-vue/src/vue-shim.d.ts +0 -5
  219. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/index.d.ts +0 -22
  220. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2/index.d.ts +0 -33
  221. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2.7/index.d.ts +0 -38
  222. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v3/index.d.ts +0 -22
  223. package/dist/client/node_modules/scroll-into-view-if-needed/typings/index.d.ts +0 -13
  224. package/dist/client/node_modules/scroll-into-view-if-needed/typings/types.d.ts +0 -19
  225. package/dist/client/node_modules/vue/macros-global.d.ts +0 -19
  226. package/dist/client/node_modules/vue/macros.d.ts +0 -112
  227. package/dist/client/node_modules/vue/ref-macros.d.ts +0 -2
  228. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/index.d.ts +0 -0
  229. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/v2/index.d.ts +0 -0
  230. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/v2.7/index.d.ts +0 -0
  231. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/v3/index.d.ts +0 -0
@@ -1,19 +1,6 @@
1
- import { v as h, d as defineComponent } from './vue.runtime.esm-bundler.js';
2
-
3
- const matchName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
4
- const iconDefaults = Object.freeze({
5
- left: 0,
6
- top: 0,
7
- width: 16,
8
- height: 16,
9
- rotate: 0,
10
- vFlip: false,
11
- hFlip: false
12
- });
13
- function fullIcon(data) {
14
- return { ...iconDefaults, ...data };
15
- }
1
+ import { x as h, d as defineComponent } from './vue.runtime.esm-bundler.js';
16
2
 
3
+ const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
17
4
  const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
18
5
  const colonSeparated = value.split(":");
19
6
  if (value.slice(0, 1) === "@") {
@@ -29,11 +16,12 @@ const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
29
16
  const name2 = colonSeparated.pop();
30
17
  const prefix = colonSeparated.pop();
31
18
  const result = {
19
+ // Allow provider without '@': "provider:prefix:name"
32
20
  provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
33
21
  prefix,
34
22
  name: name2
35
23
  };
36
- return validate && !validateIcon(result) ? null : result;
24
+ return validate && !validateIconName(result) ? null : result;
37
25
  }
38
26
  const name = colonSeparated[0];
39
27
  const dashSeparated = name.split("-");
@@ -43,7 +31,7 @@ const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
43
31
  prefix: dashSeparated.shift(),
44
32
  name: dashSeparated.join("-")
45
33
  };
46
- return validate && !validateIcon(result) ? null : result;
34
+ return validate && !validateIconName(result) ? null : result;
47
35
  }
48
36
  if (allowSimpleName && provider === "") {
49
37
  const result = {
@@ -51,87 +39,109 @@ const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
51
39
  prefix: "",
52
40
  name
53
41
  };
54
- return validate && !validateIcon(result, allowSimpleName) ? null : result;
42
+ return validate && !validateIconName(result, allowSimpleName) ? null : result;
55
43
  }
56
44
  return null;
57
45
  };
58
- const validateIcon = (icon, allowSimpleName) => {
46
+ const validateIconName = (icon, allowSimpleName) => {
59
47
  if (!icon) {
60
48
  return false;
61
49
  }
62
- return !!((icon.provider === "" || icon.provider.match(matchName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchName)) && icon.name.match(matchName));
50
+ return !!((icon.provider === "" || icon.provider.match(matchIconName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchIconName)) && icon.name.match(matchIconName));
63
51
  };
64
52
 
65
- function mergeIconData(icon, alias) {
66
- const result = { ...icon };
67
- for (const key in iconDefaults) {
68
- const prop = key;
69
- if (alias[prop] !== void 0) {
70
- const value = alias[prop];
71
- if (result[prop] === void 0) {
72
- result[prop] = value;
73
- continue;
74
- }
75
- switch (prop) {
76
- case "rotate":
77
- result[prop] = (result[prop] + value) % 4;
78
- break;
79
- case "hFlip":
80
- case "vFlip":
81
- result[prop] = value !== result[prop];
82
- break;
83
- default:
84
- result[prop] = value;
85
- }
86
- }
53
+ const defaultIconDimensions = Object.freeze(
54
+ {
55
+ left: 0,
56
+ top: 0,
57
+ width: 16,
58
+ height: 16
59
+ }
60
+ );
61
+ const defaultIconTransformations = Object.freeze({
62
+ rotate: 0,
63
+ vFlip: false,
64
+ hFlip: false
65
+ });
66
+ const defaultIconProps = Object.freeze({
67
+ ...defaultIconDimensions,
68
+ ...defaultIconTransformations
69
+ });
70
+ const defaultExtendedIconProps = Object.freeze({
71
+ ...defaultIconProps,
72
+ body: "",
73
+ hidden: false
74
+ });
75
+
76
+ function mergeIconTransformations(obj1, obj2) {
77
+ const result = {};
78
+ if (!obj1.hFlip !== !obj2.hFlip) {
79
+ result.hFlip = true;
80
+ }
81
+ if (!obj1.vFlip !== !obj2.vFlip) {
82
+ result.vFlip = true;
83
+ }
84
+ const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
85
+ if (rotate) {
86
+ result.rotate = rotate;
87
87
  }
88
88
  return result;
89
89
  }
90
90
 
91
- function getIconData$1(data, name, full = false) {
92
- function getIcon(name2, iteration) {
93
- if (data.icons[name2] !== void 0) {
94
- return Object.assign({}, data.icons[name2]);
95
- }
96
- if (iteration > 5) {
97
- return null;
98
- }
99
- const aliases = data.aliases;
100
- if (aliases && aliases[name2] !== void 0) {
101
- const item = aliases[name2];
102
- const result2 = getIcon(item.parent, iteration + 1);
103
- if (result2) {
104
- return mergeIconData(result2, item);
91
+ function mergeIconData(parent, child) {
92
+ const result = mergeIconTransformations(parent, child);
93
+ for (const key in defaultExtendedIconProps) {
94
+ if (key in defaultIconTransformations) {
95
+ if (key in parent && !(key in result)) {
96
+ result[key] = defaultIconTransformations[key];
105
97
  }
106
- return result2;
107
- }
108
- const chars = data.chars;
109
- if (!iteration && chars && chars[name2] !== void 0) {
110
- return getIcon(chars[name2], iteration + 1);
98
+ } else if (key in child) {
99
+ result[key] = child[key];
100
+ } else if (key in parent) {
101
+ result[key] = parent[key];
111
102
  }
112
- return null;
113
103
  }
114
- const result = getIcon(name, 0);
115
- if (result) {
116
- for (const key in iconDefaults) {
117
- if (result[key] === void 0 && data[key] !== void 0) {
118
- result[key] = data[key];
104
+ return result;
105
+ }
106
+
107
+ function getIconsTree(data, names) {
108
+ const icons = data.icons;
109
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
110
+ const resolved = /* @__PURE__ */ Object.create(null);
111
+ function resolve(name) {
112
+ if (icons[name]) {
113
+ return resolved[name] = [];
114
+ }
115
+ if (!(name in resolved)) {
116
+ resolved[name] = null;
117
+ const parent = aliases[name] && aliases[name].parent;
118
+ const value = parent && resolve(parent);
119
+ if (value) {
120
+ resolved[name] = [parent].concat(value);
119
121
  }
120
122
  }
123
+ return resolved[name];
121
124
  }
122
- return result && full ? fullIcon(result) : result;
125
+ (names || Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
126
+ return resolved;
123
127
  }
124
128
 
125
- function isVariation(item) {
126
- for (const key in iconDefaults) {
127
- if (item[key] !== void 0) {
128
- return true;
129
- }
130
- }
131
- return false;
129
+ function internalGetIconData(data, name, tree) {
130
+ const icons = data.icons;
131
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
132
+ let currentProps = {};
133
+ function parse(name2) {
134
+ currentProps = mergeIconData(
135
+ icons[name2] || aliases[name2],
136
+ currentProps
137
+ );
138
+ }
139
+ parse(name);
140
+ tree.forEach(parse);
141
+ return mergeIconData(data, currentProps);
132
142
  }
133
- function parseIconSet(data, callback, options) {
134
- options = options || {};
143
+
144
+ function parseIconSet(data, callback) {
135
145
  const names = [];
136
146
  if (typeof data !== "object" || typeof data.icons !== "object") {
137
147
  return names;
@@ -142,38 +152,30 @@ function parseIconSet(data, callback, options) {
142
152
  names.push(name);
143
153
  });
144
154
  }
145
- const icons = data.icons;
146
- Object.keys(icons).forEach((name) => {
147
- const iconData = getIconData$1(data, name, true);
148
- if (iconData) {
149
- callback(name, iconData);
155
+ const tree = getIconsTree(data);
156
+ for (const name in tree) {
157
+ const item = tree[name];
158
+ if (item) {
159
+ callback(name, internalGetIconData(data, name, item));
150
160
  names.push(name);
151
161
  }
152
- });
153
- const parseAliases = options.aliases || "all";
154
- if (parseAliases !== "none" && typeof data.aliases === "object") {
155
- const aliases = data.aliases;
156
- Object.keys(aliases).forEach((name) => {
157
- if (parseAliases === "variations" && isVariation(aliases[name])) {
158
- return;
159
- }
160
- const iconData = getIconData$1(data, name, true);
161
- if (iconData) {
162
- callback(name, iconData);
163
- names.push(name);
164
- }
165
- });
166
162
  }
167
163
  return names;
168
164
  }
169
165
 
170
- const optionalProperties = {
171
- provider: "string",
172
- aliases: "object",
173
- not_found: "object"
166
+ const optionalPropertyDefaults = {
167
+ provider: "",
168
+ aliases: {},
169
+ not_found: {},
170
+ ...defaultIconDimensions
174
171
  };
175
- for (const prop in iconDefaults) {
176
- optionalProperties[prop] = typeof iconDefaults[prop];
172
+ function checkOptionalProps(item, defaults) {
173
+ for (const prop in defaults) {
174
+ if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
175
+ return false;
176
+ }
177
+ }
178
+ return true;
177
179
  }
178
180
  function quicklyValidateIconSet(obj) {
179
181
  if (typeof obj !== "object" || obj === null) {
@@ -183,126 +185,80 @@ function quicklyValidateIconSet(obj) {
183
185
  if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
184
186
  return null;
185
187
  }
186
- for (const prop in optionalProperties) {
187
- if (obj[prop] !== void 0 && typeof obj[prop] !== optionalProperties[prop]) {
188
- return null;
189
- }
188
+ if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
189
+ return null;
190
190
  }
191
191
  const icons = data.icons;
192
192
  for (const name in icons) {
193
193
  const icon = icons[name];
194
- if (!name.match(matchName) || typeof icon.body !== "string") {
194
+ if (!name.match(matchIconName) || typeof icon.body !== "string" || !checkOptionalProps(
195
+ icon,
196
+ defaultExtendedIconProps
197
+ )) {
195
198
  return null;
196
199
  }
197
- for (const prop in iconDefaults) {
198
- if (icon[prop] !== void 0 && typeof icon[prop] !== typeof iconDefaults[prop]) {
199
- return null;
200
- }
201
- }
202
200
  }
203
- const aliases = data.aliases;
204
- if (aliases) {
205
- for (const name in aliases) {
206
- const icon = aliases[name];
207
- const parent = icon.parent;
208
- if (!name.match(matchName) || typeof parent !== "string" || !icons[parent] && !aliases[parent]) {
209
- return null;
210
- }
211
- for (const prop in iconDefaults) {
212
- if (icon[prop] !== void 0 && typeof icon[prop] !== typeof iconDefaults[prop]) {
213
- return null;
214
- }
215
- }
201
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
202
+ for (const name in aliases) {
203
+ const icon = aliases[name];
204
+ const parent = icon.parent;
205
+ if (!name.match(matchIconName) || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(
206
+ icon,
207
+ defaultExtendedIconProps
208
+ )) {
209
+ return null;
216
210
  }
217
211
  }
218
212
  return data;
219
213
  }
220
214
 
221
- const storageVersion = 1;
222
- let storage$1 = /* @__PURE__ */ Object.create(null);
223
- try {
224
- const w = window || self;
225
- if (w && w._iconifyStorage.version === storageVersion) {
226
- storage$1 = w._iconifyStorage.storage;
227
- }
228
- } catch (err) {
229
- }
230
- function shareStorage() {
231
- try {
232
- const w = window || self;
233
- if (w && !w._iconifyStorage) {
234
- w._iconifyStorage = {
235
- version: storageVersion,
236
- storage: storage$1
237
- };
238
- }
239
- } catch (err) {
240
- }
241
- }
215
+ const dataStorage = /* @__PURE__ */ Object.create(null);
242
216
  function newStorage(provider, prefix) {
243
217
  return {
244
218
  provider,
245
219
  prefix,
246
220
  icons: /* @__PURE__ */ Object.create(null),
247
- missing: /* @__PURE__ */ Object.create(null)
221
+ missing: /* @__PURE__ */ new Set()
248
222
  };
249
223
  }
250
224
  function getStorage(provider, prefix) {
251
- if (storage$1[provider] === void 0) {
252
- storage$1[provider] = /* @__PURE__ */ Object.create(null);
253
- }
254
- const providerStorage = storage$1[provider];
255
- if (providerStorage[prefix] === void 0) {
256
- providerStorage[prefix] = newStorage(provider, prefix);
257
- }
258
- return providerStorage[prefix];
225
+ const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
226
+ return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
259
227
  }
260
- function addIconSet(storage2, data) {
228
+ function addIconSet(storage, data) {
261
229
  if (!quicklyValidateIconSet(data)) {
262
230
  return [];
263
231
  }
264
- const t = Date.now();
265
232
  return parseIconSet(data, (name, icon) => {
266
233
  if (icon) {
267
- storage2.icons[name] = icon;
234
+ storage.icons[name] = icon;
268
235
  } else {
269
- storage2.missing[name] = t;
236
+ storage.missing.add(name);
270
237
  }
271
238
  });
272
239
  }
273
- function addIconToStorage(storage2, name, icon) {
240
+ function addIconToStorage(storage, name, icon) {
274
241
  try {
275
242
  if (typeof icon.body === "string") {
276
- storage2.icons[name] = Object.freeze(fullIcon(icon));
243
+ storage.icons[name] = { ...icon };
277
244
  return true;
278
245
  }
279
246
  } catch (err) {
280
247
  }
281
248
  return false;
282
249
  }
283
- function getIconFromStorage(storage2, name) {
284
- const value = storage2.icons[name];
285
- return value === void 0 ? null : value;
286
- }
287
250
  function listIcons(provider, prefix) {
288
251
  let allIcons = [];
289
- let providers;
290
- if (typeof provider === "string") {
291
- providers = [provider];
292
- } else {
293
- providers = Object.keys(storage$1);
294
- }
252
+ const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
295
253
  providers.forEach((provider2) => {
296
- let prefixes;
297
- if (typeof provider2 === "string" && typeof prefix === "string") {
298
- prefixes = [prefix];
299
- } else {
300
- prefixes = storage$1[provider2] === void 0 ? [] : Object.keys(storage$1[provider2]);
301
- }
254
+ const prefixes = typeof provider2 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider2] || {});
302
255
  prefixes.forEach((prefix2) => {
303
- const storage2 = getStorage(provider2, prefix2);
304
- const icons = Object.keys(storage2.icons).map((name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name);
305
- allIcons = allIcons.concat(icons);
256
+ const storage = getStorage(provider2, prefix2);
257
+ allIcons = allIcons.concat(
258
+ Object.keys(storage.icons).map(
259
+ (name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name
260
+ )
261
+ );
306
262
  });
307
263
  });
308
264
  return allIcons;
@@ -317,7 +273,11 @@ function allowSimpleNames(allow) {
317
273
  }
318
274
  function getIconData(name) {
319
275
  const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
320
- return icon ? getIconFromStorage(getStorage(icon.provider, icon.prefix), icon.name) : null;
276
+ if (icon) {
277
+ const storage = getStorage(icon.provider, icon.prefix);
278
+ const iconName = icon.name;
279
+ return storage.icons[iconName] || (storage.missing.has(iconName) ? null : void 0);
280
+ }
321
281
  }
322
282
  function addIcon(name, data) {
323
283
  const icon = stringToIcon(name, true, simpleNames);
@@ -332,9 +292,9 @@ function addCollection(data, provider) {
332
292
  return false;
333
293
  }
334
294
  if (typeof provider !== "string") {
335
- provider = typeof data.provider === "string" ? data.provider : "";
295
+ provider = data.provider || "";
336
296
  }
337
- if (simpleNames && provider === "" && (typeof data.prefix !== "string" || data.prefix === "")) {
297
+ if (simpleNames && !provider && !data.prefix) {
338
298
  let added = false;
339
299
  if (quicklyValidateIconSet(data)) {
340
300
  data.prefix = "";
@@ -346,78 +306,38 @@ function addCollection(data, provider) {
346
306
  }
347
307
  return added;
348
308
  }
349
- if (typeof data.prefix !== "string" || !validateIcon({
309
+ const prefix = data.prefix;
310
+ if (!validateIconName({
350
311
  provider,
351
- prefix: data.prefix,
312
+ prefix,
352
313
  name: "a"
353
314
  })) {
354
315
  return false;
355
316
  }
356
- const storage = getStorage(provider, data.prefix);
317
+ const storage = getStorage(provider, prefix);
357
318
  return !!addIconSet(storage, data);
358
319
  }
359
- function iconExists(name) {
360
- return getIconData(name) !== null;
320
+ function iconLoaded(name) {
321
+ return !!getIconData(name);
361
322
  }
362
323
  function getIcon(name) {
363
324
  const result = getIconData(name);
364
- return result ? { ...result } : null;
325
+ return result ? {
326
+ ...defaultIconProps,
327
+ ...result
328
+ } : null;
365
329
  }
366
330
 
367
- const defaults = Object.freeze({
368
- inline: false,
331
+ const defaultIconSizeCustomisations = Object.freeze({
369
332
  width: null,
370
- height: null,
371
- hAlign: "center",
372
- vAlign: "middle",
373
- slice: false,
374
- hFlip: false,
375
- vFlip: false,
376
- rotate: 0
333
+ height: null
334
+ });
335
+ const defaultIconCustomisations = Object.freeze({
336
+ // Dimensions
337
+ ...defaultIconSizeCustomisations,
338
+ // Transformations
339
+ ...defaultIconTransformations
377
340
  });
378
- function mergeCustomisations(defaults2, item) {
379
- const result = {};
380
- for (const key in defaults2) {
381
- const attr = key;
382
- result[attr] = defaults2[attr];
383
- if (item[attr] === void 0) {
384
- continue;
385
- }
386
- const value = item[attr];
387
- switch (attr) {
388
- case "inline":
389
- case "slice":
390
- if (typeof value === "boolean") {
391
- result[attr] = value;
392
- }
393
- break;
394
- case "hFlip":
395
- case "vFlip":
396
- if (value === true) {
397
- result[attr] = !result[attr];
398
- }
399
- break;
400
- case "hAlign":
401
- case "vAlign":
402
- if (typeof value === "string" && value !== "") {
403
- result[attr] = value;
404
- }
405
- break;
406
- case "width":
407
- case "height":
408
- if (typeof value === "string" && value !== "" || typeof value === "number" && value || value === null) {
409
- result[attr] = value;
410
- }
411
- break;
412
- case "rotate":
413
- if (typeof value === "number") {
414
- result[attr] += value;
415
- }
416
- break;
417
- }
418
- }
419
- return result;
420
- }
421
341
 
422
342
  const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
423
343
  const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
@@ -425,7 +345,7 @@ function calculateSize(size, ratio, precision) {
425
345
  if (ratio === 1) {
426
346
  return size;
427
347
  }
428
- precision = precision === void 0 ? 100 : precision;
348
+ precision = precision || 100;
429
349
  if (typeof size === "number") {
430
350
  return Math.ceil(size * ratio * precision) / precision;
431
351
  }
@@ -458,40 +378,53 @@ function calculateSize(size, ratio, precision) {
458
378
  }
459
379
  }
460
380
 
461
- function preserveAspectRatio(props) {
462
- let result = "";
463
- switch (props.hAlign) {
464
- case "left":
465
- result += "xMin";
466
- break;
467
- case "right":
468
- result += "xMax";
381
+ function splitSVGDefs(content, tag = "defs") {
382
+ let defs = "";
383
+ const index = content.indexOf("<" + tag);
384
+ while (index >= 0) {
385
+ const start = content.indexOf(">", index);
386
+ const end = content.indexOf("</" + tag);
387
+ if (start === -1 || end === -1) {
469
388
  break;
470
- default:
471
- result += "xMid";
472
- }
473
- switch (props.vAlign) {
474
- case "top":
475
- result += "YMin";
476
- break;
477
- case "bottom":
478
- result += "YMax";
389
+ }
390
+ const endEnd = content.indexOf(">", end);
391
+ if (endEnd === -1) {
479
392
  break;
480
- default:
481
- result += "YMid";
393
+ }
394
+ defs += content.slice(start + 1, end).trim();
395
+ content = content.slice(0, index).trim() + content.slice(endEnd + 1);
482
396
  }
483
- result += props.slice ? " slice" : " meet";
484
- return result;
397
+ return {
398
+ defs,
399
+ content
400
+ };
485
401
  }
402
+ function mergeDefsAndContent(defs, content) {
403
+ return defs ? "<defs>" + defs + "</defs>" + content : content;
404
+ }
405
+ function wrapSVGContent(body, start, end) {
406
+ const split = splitSVGDefs(body);
407
+ return mergeDefsAndContent(split.defs, start + split.content + end);
408
+ }
409
+
410
+ const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
486
411
  function iconToSVG(icon, customisations) {
412
+ const fullIcon = {
413
+ ...defaultIconProps,
414
+ ...icon
415
+ };
416
+ const fullCustomisations = {
417
+ ...defaultIconCustomisations,
418
+ ...customisations
419
+ };
487
420
  const box = {
488
- left: icon.left,
489
- top: icon.top,
490
- width: icon.width,
491
- height: icon.height
421
+ left: fullIcon.left,
422
+ top: fullIcon.top,
423
+ width: fullIcon.width,
424
+ height: fullIcon.height
492
425
  };
493
- let body = icon.body;
494
- [icon, customisations].forEach((props) => {
426
+ let body = fullIcon.body;
427
+ [fullIcon, fullCustomisations].forEach((props) => {
495
428
  const transformations = [];
496
429
  const hFlip = props.hFlip;
497
430
  const vFlip = props.vFlip;
@@ -500,12 +433,16 @@ function iconToSVG(icon, customisations) {
500
433
  if (vFlip) {
501
434
  rotation += 2;
502
435
  } else {
503
- transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
436
+ transformations.push(
437
+ "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
438
+ );
504
439
  transformations.push("scale(-1 1)");
505
440
  box.top = box.left = 0;
506
441
  }
507
442
  } else if (vFlip) {
508
- transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
443
+ transformations.push(
444
+ "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
445
+ );
509
446
  transformations.push("scale(1 -1)");
510
447
  box.top = box.left = 0;
511
448
  }
@@ -517,18 +454,24 @@ function iconToSVG(icon, customisations) {
517
454
  switch (rotation) {
518
455
  case 1:
519
456
  tempValue = box.height / 2 + box.top;
520
- transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
457
+ transformations.unshift(
458
+ "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
459
+ );
521
460
  break;
522
461
  case 2:
523
- transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
462
+ transformations.unshift(
463
+ "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
464
+ );
524
465
  break;
525
466
  case 3:
526
467
  tempValue = box.width / 2 + box.left;
527
- transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
468
+ transformations.unshift(
469
+ "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
470
+ );
528
471
  break;
529
472
  }
530
473
  if (rotation % 2 === 1) {
531
- if (box.left !== 0 || box.top !== 0) {
474
+ if (box.left !== box.top) {
532
475
  tempValue = box.left;
533
476
  box.left = box.top;
534
477
  box.top = tempValue;
@@ -540,48 +483,41 @@ function iconToSVG(icon, customisations) {
540
483
  }
541
484
  }
542
485
  if (transformations.length) {
543
- body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
486
+ body = wrapSVGContent(
487
+ body,
488
+ '<g transform="' + transformations.join(" ") + '">',
489
+ "</g>"
490
+ );
544
491
  }
545
492
  });
546
- let width, height;
547
- if (customisations.width === null && customisations.height === null) {
548
- height = "1em";
549
- width = calculateSize(height, box.width / box.height);
550
- } else if (customisations.width !== null && customisations.height !== null) {
551
- width = customisations.width;
552
- height = customisations.height;
553
- } else if (customisations.height !== null) {
554
- height = customisations.height;
555
- width = calculateSize(height, box.width / box.height);
493
+ const customisationsWidth = fullCustomisations.width;
494
+ const customisationsHeight = fullCustomisations.height;
495
+ const boxWidth = box.width;
496
+ const boxHeight = box.height;
497
+ let width;
498
+ let height;
499
+ if (customisationsWidth === null) {
500
+ height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
501
+ width = calculateSize(height, boxWidth / boxHeight);
556
502
  } else {
557
- width = customisations.width;
558
- height = calculateSize(width, box.height / box.width);
559
- }
560
- if (width === "auto") {
561
- width = box.width;
562
- }
563
- if (height === "auto") {
564
- height = box.height;
503
+ width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
504
+ height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
565
505
  }
566
- width = typeof width === "string" ? width : width.toString() + "";
567
- height = typeof height === "string" ? height : height.toString() + "";
568
- const result = {
569
- attributes: {
570
- width,
571
- height,
572
- preserveAspectRatio: preserveAspectRatio(customisations),
573
- viewBox: box.left.toString() + " " + box.top.toString() + " " + box.width.toString() + " " + box.height.toString()
574
- },
506
+ const attributes = {};
507
+ const setAttr = (prop, value) => {
508
+ if (!isUnsetKeyword(value)) {
509
+ attributes[prop] = value.toString();
510
+ }
511
+ };
512
+ setAttr("width", width);
513
+ setAttr("height", height);
514
+ const viewBox = [box.left, box.top, boxWidth, boxHeight];
515
+ attributes.viewBox = viewBox.join(" ");
516
+ return {
517
+ attributes,
518
+ viewBox,
575
519
  body
576
520
  };
577
- if (customisations.inline) {
578
- result.inline = true;
579
- }
580
- return result;
581
- }
582
-
583
- function buildIcon(icon, customisations) {
584
- return iconToSVG(fullIcon(icon), customisations ? mergeCustomisations(defaults, customisations) : defaults);
585
521
  }
586
522
 
587
523
  const regex = /\sid="(\S+)"/g;
@@ -596,11 +532,18 @@ function replaceIDs(body, prefix = randomPrefix) {
596
532
  if (!ids.length) {
597
533
  return body;
598
534
  }
535
+ const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
599
536
  ids.forEach((id) => {
600
537
  const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
601
538
  const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
602
- body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + "$3");
539
+ body = body.replace(
540
+ // Allowed characters before id: [#;"]
541
+ // Allowed characters after id: [)"], .[a-z]
542
+ new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"),
543
+ "$1" + newID + suffix + "$3"
544
+ );
603
545
  });
546
+ body = body.replace(new RegExp(suffix, "g"), "");
604
547
  return body;
605
548
  }
606
549
 
@@ -623,13 +566,21 @@ function createAPIConfig(source) {
623
566
  }
624
567
  }
625
568
  const result = {
569
+ // API hosts
626
570
  resources,
627
- path: source.path === void 0 ? "/" : source.path,
628
- maxURL: source.maxURL ? source.maxURL : 500,
629
- rotate: source.rotate ? source.rotate : 750,
630
- timeout: source.timeout ? source.timeout : 5e3,
571
+ // Root path
572
+ path: source.path || "/",
573
+ // URL length limit
574
+ maxURL: source.maxURL || 500,
575
+ // Timeout before next host is used.
576
+ rotate: source.rotate || 750,
577
+ // Timeout before failing query.
578
+ timeout: source.timeout || 5e3,
579
+ // Randomise default API end point.
631
580
  random: source.random === true,
632
- index: source.index ? source.index : 0,
581
+ // Start index
582
+ index: source.index || 0,
583
+ // Receive data after time out (used if time out kicks in first, then API module sends data anyway).
633
584
  dataAfterTimeout: source.dataAfterTimeout !== false
634
585
  };
635
586
  return result;
@@ -669,35 +620,6 @@ function listAPIProviders() {
669
620
  return Object.keys(configStorage);
670
621
  }
671
622
 
672
- const mergeParams = (base, params) => {
673
- let result = base, hasParams = result.indexOf("?") !== -1;
674
- function paramToString(value) {
675
- switch (typeof value) {
676
- case "boolean":
677
- return value ? "true" : "false";
678
- case "number":
679
- return encodeURIComponent(value);
680
- case "string":
681
- return encodeURIComponent(value);
682
- default:
683
- throw new Error("Invalid parameter");
684
- }
685
- }
686
- Object.keys(params).forEach((key) => {
687
- let value;
688
- try {
689
- value = paramToString(params[key]);
690
- } catch (err) {
691
- return;
692
- }
693
- result += (hasParams ? "&" : "?") + encodeURIComponent(key) + "=" + value;
694
- hasParams = true;
695
- });
696
- return result;
697
- };
698
-
699
- const maxLengthCache = {};
700
- const pathCache = {};
701
623
  const detectFetch = () => {
702
624
  let callback;
703
625
  try {
@@ -707,7 +629,6 @@ const detectFetch = () => {
707
629
  }
708
630
  } catch (err) {
709
631
  }
710
- return null;
711
632
  };
712
633
  let fetchModule = detectFetch();
713
634
  function setFetch(fetch2) {
@@ -730,14 +651,9 @@ function calculateMaxLength(provider, prefix) {
730
651
  const host = item;
731
652
  maxHostLength = Math.max(maxHostLength, host.length);
732
653
  });
733
- const url = mergeParams(prefix + ".json", {
734
- icons: ""
735
- });
654
+ const url = prefix + ".json?icons=";
736
655
  result = config.maxURL - maxHostLength - config.path.length - url.length;
737
656
  }
738
- const cacheKey = provider + ":" + prefix;
739
- pathCache[provider] = config.path;
740
- maxLengthCache[cacheKey] = result;
741
657
  return result;
742
658
  }
743
659
  function shouldAbort(status) {
@@ -745,10 +661,7 @@ function shouldAbort(status) {
745
661
  }
746
662
  const prepare = (provider, prefix, icons) => {
747
663
  const results = [];
748
- let maxLength = maxLengthCache[prefix];
749
- if (maxLength === void 0) {
750
- maxLength = calculateMaxLength(provider, prefix);
751
- }
664
+ const maxLength = calculateMaxLength(provider, prefix);
752
665
  const type = "icons";
753
666
  let item = {
754
667
  type,
@@ -776,14 +689,10 @@ const prepare = (provider, prefix, icons) => {
776
689
  };
777
690
  function getPath(provider) {
778
691
  if (typeof provider === "string") {
779
- if (pathCache[provider] === void 0) {
780
- const config = getAPIConfig(provider);
781
- if (!config) {
782
- return "/";
783
- }
784
- pathCache[provider] = config.path;
692
+ const config = getAPIConfig(provider);
693
+ if (config) {
694
+ return config.path;
785
695
  }
786
- return pathCache[provider];
787
696
  }
788
697
  return "/";
789
698
  }
@@ -798,9 +707,10 @@ const send = (host, params, callback) => {
798
707
  const prefix = params.prefix;
799
708
  const icons = params.icons;
800
709
  const iconsList = icons.join(",");
801
- path += mergeParams(prefix + ".json", {
710
+ const urlParams = new URLSearchParams({
802
711
  icons: iconsList
803
712
  });
713
+ path += prefix + ".json?" + urlParams.toString();
804
714
  break;
805
715
  }
806
716
  case "custom": {
@@ -826,7 +736,11 @@ const send = (host, params, callback) => {
826
736
  }).then((data) => {
827
737
  if (typeof data !== "object" || data === null) {
828
738
  setTimeout(() => {
829
- callback("next", defaultError);
739
+ if (data === 404) {
740
+ callback("abort", data);
741
+ } else {
742
+ callback("next", defaultError);
743
+ }
830
744
  });
831
745
  return;
832
746
  }
@@ -871,18 +785,12 @@ function sortIcons(icons) {
871
785
  const provider = icon.provider;
872
786
  const prefix = icon.prefix;
873
787
  const name = icon.name;
874
- if (storage[provider] === void 0) {
875
- storage[provider] = /* @__PURE__ */ Object.create(null);
876
- }
877
- const providerStorage = storage[provider];
878
- if (providerStorage[prefix] === void 0) {
879
- providerStorage[prefix] = getStorage(provider, prefix);
880
- }
881
- const localStorage = providerStorage[prefix];
788
+ const providerStorage = storage[provider] || (storage[provider] = /* @__PURE__ */ Object.create(null));
789
+ const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
882
790
  let list;
883
- if (localStorage.icons[name] !== void 0) {
791
+ if (name in localStorage.icons) {
884
792
  list = result.loaded;
885
- } else if (prefix === "" || localStorage.missing[name] !== void 0) {
793
+ } else if (prefix === "" || localStorage.missing.has(name)) {
886
794
  list = result.missing;
887
795
  } else {
888
796
  list = result.pending;
@@ -897,40 +805,26 @@ function sortIcons(icons) {
897
805
  return result;
898
806
  }
899
807
 
900
- const callbacks = /* @__PURE__ */ Object.create(null);
901
- const pendingUpdates = /* @__PURE__ */ Object.create(null);
902
- function removeCallback(sources, id) {
903
- sources.forEach((source) => {
904
- const provider = source.provider;
905
- if (callbacks[provider] === void 0) {
906
- return;
907
- }
908
- const providerCallbacks = callbacks[provider];
909
- const prefix = source.prefix;
910
- const items = providerCallbacks[prefix];
808
+ function removeCallback(storages, id) {
809
+ storages.forEach((storage) => {
810
+ const items = storage.loaderCallbacks;
911
811
  if (items) {
912
- providerCallbacks[prefix] = items.filter((row) => row.id !== id);
812
+ storage.loaderCallbacks = items.filter((row) => row.id !== id);
913
813
  }
914
814
  });
915
815
  }
916
- function updateCallbacks(provider, prefix) {
917
- if (pendingUpdates[provider] === void 0) {
918
- pendingUpdates[provider] = /* @__PURE__ */ Object.create(null);
919
- }
920
- const providerPendingUpdates = pendingUpdates[provider];
921
- if (!providerPendingUpdates[prefix]) {
922
- providerPendingUpdates[prefix] = true;
816
+ function updateCallbacks(storage) {
817
+ if (!storage.pendingCallbacksFlag) {
818
+ storage.pendingCallbacksFlag = true;
923
819
  setTimeout(() => {
924
- providerPendingUpdates[prefix] = false;
925
- if (callbacks[provider] === void 0 || callbacks[provider][prefix] === void 0) {
926
- return;
927
- }
928
- const items = callbacks[provider][prefix].slice(0);
820
+ storage.pendingCallbacksFlag = false;
821
+ const items = storage.loaderCallbacks ? storage.loaderCallbacks.slice(0) : [];
929
822
  if (!items.length) {
930
823
  return;
931
824
  }
932
- const storage = getStorage(provider, prefix);
933
825
  let hasPending = false;
826
+ const provider = storage.provider;
827
+ const prefix = storage.prefix;
934
828
  items.forEach((item) => {
935
829
  const icons = item.icons;
936
830
  const oldLength = icons.pending.length;
@@ -939,13 +833,13 @@ function updateCallbacks(provider, prefix) {
939
833
  return true;
940
834
  }
941
835
  const name = icon.name;
942
- if (storage.icons[name] !== void 0) {
836
+ if (storage.icons[name]) {
943
837
  icons.loaded.push({
944
838
  provider,
945
839
  prefix,
946
840
  name
947
841
  });
948
- } else if (storage.missing[name] !== void 0) {
842
+ } else if (storage.missing.has(name)) {
949
843
  icons.missing.push({
950
844
  provider,
951
845
  prefix,
@@ -959,14 +853,14 @@ function updateCallbacks(provider, prefix) {
959
853
  });
960
854
  if (icons.pending.length !== oldLength) {
961
855
  if (!hasPending) {
962
- removeCallback([
963
- {
964
- provider,
965
- prefix
966
- }
967
- ], item.id);
856
+ removeCallback([storage], item.id);
968
857
  }
969
- item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
858
+ item.callback(
859
+ icons.loaded.slice(0),
860
+ icons.missing.slice(0),
861
+ icons.pending.slice(0),
862
+ item.abort
863
+ );
970
864
  }
971
865
  });
972
866
  });
@@ -985,17 +879,8 @@ function storeCallback(callback, icons, pendingSources) {
985
879
  callback,
986
880
  abort
987
881
  };
988
- pendingSources.forEach((source) => {
989
- const provider = source.provider;
990
- const prefix = source.prefix;
991
- if (callbacks[provider] === void 0) {
992
- callbacks[provider] = /* @__PURE__ */ Object.create(null);
993
- }
994
- const providerCallbacks = callbacks[provider];
995
- if (providerCallbacks[prefix] === void 0) {
996
- providerCallbacks[prefix] = [];
997
- }
998
- providerCallbacks[prefix].push(item);
882
+ pendingSources.forEach((storage) => {
883
+ (storage.loaderCallbacks || (storage.loaderCallbacks = [])).push(item);
999
884
  });
1000
885
  return abort;
1001
886
  }
@@ -1003,13 +888,9 @@ function storeCallback(callback, icons, pendingSources) {
1003
888
  function listToIcons(list, validate = true, simpleNames = false) {
1004
889
  const result = [];
1005
890
  list.forEach((item) => {
1006
- const icon = typeof item === "string" ? stringToIcon(item, false, simpleNames) : item;
1007
- if (!validate || validateIcon(icon, simpleNames)) {
1008
- result.push({
1009
- provider: icon.provider,
1010
- prefix: icon.prefix,
1011
- name: icon.name
1012
- });
891
+ const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames) : item;
892
+ if (icon) {
893
+ result.push(icon);
1013
894
  }
1014
895
  });
1015
896
  return result;
@@ -1183,42 +1064,34 @@ function sendQuery(config, payload, query, done) {
1183
1064
  }
1184
1065
 
1185
1066
  // src/index.ts
1186
- function setConfig(config) {
1187
- if (typeof config !== "object" || typeof config.resources !== "object" || !(config.resources instanceof Array) || !config.resources.length) {
1188
- throw new Error("Invalid Reduncancy configuration");
1189
- }
1190
- const newConfig = /* @__PURE__ */ Object.create(null);
1191
- let key;
1192
- for (key in defaultConfig) {
1193
- if (config[key] !== void 0) {
1194
- newConfig[key] = config[key];
1195
- } else {
1196
- newConfig[key] = defaultConfig[key];
1197
- }
1198
- }
1199
- return newConfig;
1200
- }
1201
1067
  function initRedundancy(cfg) {
1202
- const config = setConfig(cfg);
1068
+ const config = {
1069
+ ...defaultConfig,
1070
+ ...cfg
1071
+ };
1203
1072
  let queries = [];
1204
1073
  function cleanup() {
1205
1074
  queries = queries.filter((item) => item().status === "pending");
1206
1075
  }
1207
1076
  function query(payload, queryCallback, doneCallback) {
1208
- const query2 = sendQuery(config, payload, queryCallback, (data, error) => {
1209
- cleanup();
1210
- if (doneCallback) {
1211
- doneCallback(data, error);
1077
+ const query2 = sendQuery(
1078
+ config,
1079
+ payload,
1080
+ queryCallback,
1081
+ (data, error) => {
1082
+ cleanup();
1083
+ if (doneCallback) {
1084
+ doneCallback(data, error);
1085
+ }
1212
1086
  }
1213
- });
1087
+ );
1214
1088
  queries.push(query2);
1215
1089
  return query2;
1216
1090
  }
1217
1091
  function find(callback) {
1218
- const result = queries.find((value) => {
1092
+ return queries.find((value) => {
1219
1093
  return callback(value);
1220
- });
1221
- return result !== void 0 ? result : null;
1094
+ }) || null;
1222
1095
  }
1223
1096
  const instance = {
1224
1097
  query,
@@ -1236,7 +1109,7 @@ function emptyCallback$1() {
1236
1109
  }
1237
1110
  const redundancyCache = /* @__PURE__ */ Object.create(null);
1238
1111
  function getRedundancyCache(provider) {
1239
- if (redundancyCache[provider] === void 0) {
1112
+ if (!redundancyCache[provider]) {
1240
1113
  const config = getAPIConfig(provider);
1241
1114
  if (!config) {
1242
1115
  return;
@@ -1282,95 +1155,257 @@ function sendAPIQuery(target, query, callback) {
1282
1155
  return redundancy.query(query, send, callback)().abort;
1283
1156
  }
1284
1157
 
1285
- const cache = {};
1158
+ const browserCacheVersion = "iconify2";
1159
+ const browserCachePrefix = "iconify";
1160
+ const browserCacheCountKey = browserCachePrefix + "-count";
1161
+ const browserCacheVersionKey = browserCachePrefix + "-version";
1162
+ const browserStorageHour = 36e5;
1163
+ const browserStorageCacheExpiration = 168;
1164
+ const browserStorageLimit = 50;
1286
1165
 
1287
- function emptyCallback() {
1166
+ function getStoredItem(func, key) {
1167
+ try {
1168
+ return func.getItem(key);
1169
+ } catch (err) {
1170
+ }
1288
1171
  }
1289
- const pendingIcons = /* @__PURE__ */ Object.create(null);
1290
- const iconsToLoad = /* @__PURE__ */ Object.create(null);
1291
- const loaderFlags = /* @__PURE__ */ Object.create(null);
1292
- const queueFlags = /* @__PURE__ */ Object.create(null);
1293
- function loadedNewIcons(provider, prefix) {
1294
- if (loaderFlags[provider] === void 0) {
1295
- loaderFlags[provider] = /* @__PURE__ */ Object.create(null);
1296
- }
1297
- const providerLoaderFlags = loaderFlags[provider];
1298
- if (!providerLoaderFlags[prefix]) {
1299
- providerLoaderFlags[prefix] = true;
1300
- setTimeout(() => {
1301
- providerLoaderFlags[prefix] = false;
1302
- updateCallbacks(provider, prefix);
1172
+ function setStoredItem(func, key, value) {
1173
+ try {
1174
+ func.setItem(key, value);
1175
+ return true;
1176
+ } catch (err) {
1177
+ }
1178
+ }
1179
+ function removeStoredItem(func, key) {
1180
+ try {
1181
+ func.removeItem(key);
1182
+ } catch (err) {
1183
+ }
1184
+ }
1185
+
1186
+ function setBrowserStorageItemsCount(storage, value) {
1187
+ return setStoredItem(storage, browserCacheCountKey, value.toString());
1188
+ }
1189
+ function getBrowserStorageItemsCount(storage) {
1190
+ return parseInt(getStoredItem(storage, browserCacheCountKey)) || 0;
1191
+ }
1192
+
1193
+ const browserStorageConfig = {
1194
+ local: true,
1195
+ session: true
1196
+ };
1197
+ const browserStorageEmptyItems = {
1198
+ local: /* @__PURE__ */ new Set(),
1199
+ session: /* @__PURE__ */ new Set()
1200
+ };
1201
+ let browserStorageStatus = false;
1202
+ function setBrowserStorageStatus(status) {
1203
+ browserStorageStatus = status;
1204
+ }
1205
+
1206
+ let _window = typeof window === "undefined" ? {} : window;
1207
+ function getBrowserStorage(key) {
1208
+ const attr = key + "Storage";
1209
+ try {
1210
+ if (_window && _window[attr] && typeof _window[attr].length === "number") {
1211
+ return _window[attr];
1212
+ }
1213
+ } catch (err) {
1214
+ }
1215
+ browserStorageConfig[key] = false;
1216
+ }
1217
+
1218
+ function iterateBrowserStorage(key, callback) {
1219
+ const func = getBrowserStorage(key);
1220
+ if (!func) {
1221
+ return;
1222
+ }
1223
+ const version = getStoredItem(func, browserCacheVersionKey);
1224
+ if (version !== browserCacheVersion) {
1225
+ if (version) {
1226
+ const total2 = getBrowserStorageItemsCount(func);
1227
+ for (let i = 0; i < total2; i++) {
1228
+ removeStoredItem(func, browserCachePrefix + i.toString());
1229
+ }
1230
+ }
1231
+ setStoredItem(func, browserCacheVersionKey, browserCacheVersion);
1232
+ setBrowserStorageItemsCount(func, 0);
1233
+ return;
1234
+ }
1235
+ const minTime = Math.floor(Date.now() / browserStorageHour) - browserStorageCacheExpiration;
1236
+ const parseItem = (index) => {
1237
+ const name = browserCachePrefix + index.toString();
1238
+ const item = getStoredItem(func, name);
1239
+ if (typeof item !== "string") {
1240
+ return;
1241
+ }
1242
+ try {
1243
+ const data = JSON.parse(item);
1244
+ if (typeof data === "object" && typeof data.cached === "number" && data.cached > minTime && typeof data.provider === "string" && typeof data.data === "object" && typeof data.data.prefix === "string" && // Valid item: run callback
1245
+ callback(data, index)) {
1246
+ return true;
1247
+ }
1248
+ } catch (err) {
1249
+ }
1250
+ removeStoredItem(func, name);
1251
+ };
1252
+ let total = getBrowserStorageItemsCount(func);
1253
+ for (let i = total - 1; i >= 0; i--) {
1254
+ if (!parseItem(i)) {
1255
+ if (i === total - 1) {
1256
+ total--;
1257
+ setBrowserStorageItemsCount(func, total);
1258
+ } else {
1259
+ browserStorageEmptyItems[key].add(i);
1260
+ }
1261
+ }
1262
+ }
1263
+ }
1264
+
1265
+ function initBrowserStorage() {
1266
+ if (browserStorageStatus) {
1267
+ return;
1268
+ }
1269
+ setBrowserStorageStatus(true);
1270
+ for (const key in browserStorageConfig) {
1271
+ iterateBrowserStorage(key, (item) => {
1272
+ const iconSet = item.data;
1273
+ const provider = item.provider;
1274
+ const prefix = iconSet.prefix;
1275
+ const storage = getStorage(
1276
+ provider,
1277
+ prefix
1278
+ );
1279
+ if (!addIconSet(storage, iconSet).length) {
1280
+ return false;
1281
+ }
1282
+ const lastModified = iconSet.lastModified || -1;
1283
+ storage.lastModifiedCached = storage.lastModifiedCached ? Math.min(storage.lastModifiedCached, lastModified) : lastModified;
1284
+ return true;
1303
1285
  });
1304
1286
  }
1305
1287
  }
1306
- const errorsCache = /* @__PURE__ */ Object.create(null);
1307
- function loadNewIcons(provider, prefix, icons) {
1308
- function err() {
1309
- const key = (provider === "" ? "" : "@" + provider + ":") + prefix;
1310
- const time = Math.floor(Date.now() / 6e4);
1311
- if (errorsCache[key] < time) {
1312
- errorsCache[key] = time;
1313
- console.error('Unable to retrieve icons for "' + key + '" because API is not configured properly.');
1288
+
1289
+ function updateLastModified(storage, lastModified) {
1290
+ const lastValue = storage.lastModifiedCached;
1291
+ if (
1292
+ // Matches or newer
1293
+ lastValue && lastValue >= lastModified
1294
+ ) {
1295
+ return lastValue === lastModified;
1296
+ }
1297
+ storage.lastModifiedCached = lastModified;
1298
+ if (lastValue) {
1299
+ for (const key in browserStorageConfig) {
1300
+ iterateBrowserStorage(key, (item) => {
1301
+ const iconSet = item.data;
1302
+ return item.provider !== storage.provider || iconSet.prefix !== storage.prefix || iconSet.lastModified === lastModified;
1303
+ });
1304
+ }
1305
+ }
1306
+ return true;
1307
+ }
1308
+ function storeInBrowserStorage(storage, data) {
1309
+ if (!browserStorageStatus) {
1310
+ initBrowserStorage();
1311
+ }
1312
+ function store(key) {
1313
+ let func;
1314
+ if (!browserStorageConfig[key] || !(func = getBrowserStorage(key))) {
1315
+ return;
1316
+ }
1317
+ const set = browserStorageEmptyItems[key];
1318
+ let index;
1319
+ if (set.size) {
1320
+ set.delete(index = Array.from(set).shift());
1321
+ } else {
1322
+ index = getBrowserStorageItemsCount(func);
1323
+ if (index >= browserStorageLimit || !setBrowserStorageItemsCount(func, index + 1)) {
1324
+ return;
1325
+ }
1314
1326
  }
1327
+ const item = {
1328
+ cached: Math.floor(Date.now() / browserStorageHour),
1329
+ provider: storage.provider,
1330
+ data
1331
+ };
1332
+ return setStoredItem(
1333
+ func,
1334
+ browserCachePrefix + index.toString(),
1335
+ JSON.stringify(item)
1336
+ );
1315
1337
  }
1316
- if (iconsToLoad[provider] === void 0) {
1317
- iconsToLoad[provider] = /* @__PURE__ */ Object.create(null);
1338
+ if (data.lastModified && !updateLastModified(storage, data.lastModified)) {
1339
+ return;
1318
1340
  }
1319
- const providerIconsToLoad = iconsToLoad[provider];
1320
- if (queueFlags[provider] === void 0) {
1321
- queueFlags[provider] = /* @__PURE__ */ Object.create(null);
1341
+ if (!Object.keys(data.icons).length) {
1342
+ return;
1322
1343
  }
1323
- const providerQueueFlags = queueFlags[provider];
1324
- if (pendingIcons[provider] === void 0) {
1325
- pendingIcons[provider] = /* @__PURE__ */ Object.create(null);
1344
+ if (data.not_found) {
1345
+ data = Object.assign({}, data);
1346
+ delete data.not_found;
1347
+ }
1348
+ if (!store("local")) {
1349
+ store("session");
1326
1350
  }
1327
- const providerPendingIcons = pendingIcons[provider];
1328
- if (providerIconsToLoad[prefix] === void 0) {
1329
- providerIconsToLoad[prefix] = icons;
1351
+ }
1352
+
1353
+ function emptyCallback() {
1354
+ }
1355
+ function loadedNewIcons(storage) {
1356
+ if (!storage.iconsLoaderFlag) {
1357
+ storage.iconsLoaderFlag = true;
1358
+ setTimeout(() => {
1359
+ storage.iconsLoaderFlag = false;
1360
+ updateCallbacks(storage);
1361
+ });
1362
+ }
1363
+ }
1364
+ function loadNewIcons(storage, icons) {
1365
+ if (!storage.iconsToLoad) {
1366
+ storage.iconsToLoad = icons;
1330
1367
  } else {
1331
- providerIconsToLoad[prefix] = providerIconsToLoad[prefix].concat(icons).sort();
1368
+ storage.iconsToLoad = storage.iconsToLoad.concat(icons).sort();
1332
1369
  }
1333
- if (!providerQueueFlags[prefix]) {
1334
- providerQueueFlags[prefix] = true;
1370
+ if (!storage.iconsQueueFlag) {
1371
+ storage.iconsQueueFlag = true;
1335
1372
  setTimeout(() => {
1336
- providerQueueFlags[prefix] = false;
1337
- const icons2 = providerIconsToLoad[prefix];
1338
- delete providerIconsToLoad[prefix];
1339
- const api = getAPIModule(provider);
1340
- if (!api) {
1341
- err();
1373
+ storage.iconsQueueFlag = false;
1374
+ const { provider, prefix } = storage;
1375
+ const icons2 = storage.iconsToLoad;
1376
+ delete storage.iconsToLoad;
1377
+ let api;
1378
+ if (!icons2 || !(api = getAPIModule(provider))) {
1342
1379
  return;
1343
1380
  }
1344
1381
  const params = api.prepare(provider, prefix, icons2);
1345
1382
  params.forEach((item) => {
1346
- sendAPIQuery(provider, item, (data, error) => {
1347
- const storage = getStorage(provider, prefix);
1383
+ sendAPIQuery(provider, item, (data) => {
1348
1384
  if (typeof data !== "object") {
1349
- if (error !== 404) {
1350
- return;
1351
- }
1352
- const t = Date.now();
1353
1385
  item.icons.forEach((name) => {
1354
- storage.missing[name] = t;
1386
+ storage.missing.add(name);
1355
1387
  });
1356
1388
  } else {
1357
1389
  try {
1358
- const parsed = addIconSet(storage, data);
1390
+ const parsed = addIconSet(
1391
+ storage,
1392
+ data
1393
+ );
1359
1394
  if (!parsed.length) {
1360
1395
  return;
1361
1396
  }
1362
- const pending = providerPendingIcons[prefix];
1363
- parsed.forEach((name) => {
1364
- delete pending[name];
1365
- });
1366
- if (cache.store) {
1367
- cache.store(provider, data);
1397
+ const pending = storage.pendingIcons;
1398
+ if (pending) {
1399
+ parsed.forEach((name) => {
1400
+ pending.delete(name);
1401
+ });
1368
1402
  }
1369
- } catch (err2) {
1370
- console.error(err2);
1403
+ storeInBrowserStorage(storage, data);
1404
+ } catch (err) {
1405
+ console.error(err);
1371
1406
  }
1372
1407
  }
1373
- loadedNewIcons(provider, prefix);
1408
+ loadedNewIcons(storage);
1374
1409
  });
1375
1410
  });
1376
1411
  });
@@ -1384,7 +1419,12 @@ const loadIcons = (icons, callback) => {
1384
1419
  if (callback) {
1385
1420
  setTimeout(() => {
1386
1421
  if (callCallback) {
1387
- callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);
1422
+ callback(
1423
+ sortedIcons.loaded,
1424
+ sortedIcons.missing,
1425
+ sortedIcons.pending,
1426
+ emptyCallback
1427
+ );
1388
1428
  }
1389
1429
  });
1390
1430
  }
@@ -1396,61 +1436,50 @@ const loadIcons = (icons, callback) => {
1396
1436
  const sources = [];
1397
1437
  let lastProvider, lastPrefix;
1398
1438
  sortedIcons.pending.forEach((icon) => {
1399
- const provider = icon.provider;
1400
- const prefix = icon.prefix;
1439
+ const { provider, prefix } = icon;
1401
1440
  if (prefix === lastPrefix && provider === lastProvider) {
1402
1441
  return;
1403
1442
  }
1404
1443
  lastProvider = provider;
1405
1444
  lastPrefix = prefix;
1406
- sources.push({
1407
- provider,
1408
- prefix
1409
- });
1410
- if (pendingIcons[provider] === void 0) {
1411
- pendingIcons[provider] = /* @__PURE__ */ Object.create(null);
1412
- }
1413
- const providerPendingIcons = pendingIcons[provider];
1414
- if (providerPendingIcons[prefix] === void 0) {
1415
- providerPendingIcons[prefix] = /* @__PURE__ */ Object.create(null);
1416
- }
1417
- if (newIcons[provider] === void 0) {
1418
- newIcons[provider] = /* @__PURE__ */ Object.create(null);
1419
- }
1420
- const providerNewIcons = newIcons[provider];
1421
- if (providerNewIcons[prefix] === void 0) {
1445
+ sources.push(getStorage(provider, prefix));
1446
+ const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
1447
+ if (!providerNewIcons[prefix]) {
1422
1448
  providerNewIcons[prefix] = [];
1423
1449
  }
1424
1450
  });
1425
- const time = Date.now();
1426
1451
  sortedIcons.pending.forEach((icon) => {
1427
- const provider = icon.provider;
1428
- const prefix = icon.prefix;
1429
- const name = icon.name;
1430
- const pendingQueue = pendingIcons[provider][prefix];
1431
- if (pendingQueue[name] === void 0) {
1432
- pendingQueue[name] = time;
1452
+ const { provider, prefix, name } = icon;
1453
+ const storage = getStorage(provider, prefix);
1454
+ const pendingQueue = storage.pendingIcons || (storage.pendingIcons = /* @__PURE__ */ new Set());
1455
+ if (!pendingQueue.has(name)) {
1456
+ pendingQueue.add(name);
1433
1457
  newIcons[provider][prefix].push(name);
1434
1458
  }
1435
1459
  });
1436
- sources.forEach((source) => {
1437
- const provider = source.provider;
1438
- const prefix = source.prefix;
1460
+ sources.forEach((storage) => {
1461
+ const { provider, prefix } = storage;
1439
1462
  if (newIcons[provider][prefix].length) {
1440
- loadNewIcons(provider, prefix, newIcons[provider][prefix]);
1463
+ loadNewIcons(storage, newIcons[provider][prefix]);
1441
1464
  }
1442
1465
  });
1443
1466
  return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
1444
1467
  };
1445
1468
  const loadIcon = (icon) => {
1446
1469
  return new Promise((fulfill, reject) => {
1447
- const iconObj = typeof icon === "string" ? stringToIcon(icon) : icon;
1470
+ const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
1471
+ if (!iconObj) {
1472
+ reject(icon);
1473
+ return;
1474
+ }
1448
1475
  loadIcons([iconObj || icon], (loaded) => {
1449
1476
  if (loaded.length && iconObj) {
1450
- const storage = getStorage(iconObj.provider, iconObj.prefix);
1451
- const data = getIconFromStorage(storage, iconObj.name);
1477
+ const data = getIconData(iconObj);
1452
1478
  if (data) {
1453
- fulfill(data);
1479
+ fulfill({
1480
+ ...defaultIconProps,
1481
+ ...data
1482
+ });
1454
1483
  return;
1455
1484
  }
1456
1485
  }
@@ -1459,190 +1488,38 @@ const loadIcon = (icon) => {
1459
1488
  });
1460
1489
  };
1461
1490
 
1462
- const cacheVersion = "iconify2";
1463
- const cachePrefix = "iconify";
1464
- const countKey = cachePrefix + "-count";
1465
- const versionKey = cachePrefix + "-version";
1466
- const hour = 36e5;
1467
- const cacheExpiration = 168;
1468
- const config = {
1469
- local: true,
1470
- session: true
1471
- };
1472
- let loaded = false;
1473
- const count = {
1474
- local: 0,
1475
- session: 0
1476
- };
1477
- const emptyList = {
1478
- local: [],
1479
- session: []
1480
- };
1481
- let _window = typeof window === "undefined" ? {} : window;
1482
- function getGlobal(key) {
1483
- const attr = key + "Storage";
1484
- try {
1485
- if (_window && _window[attr] && typeof _window[attr].length === "number") {
1486
- return _window[attr];
1487
- }
1488
- } catch (err) {
1489
- }
1490
- config[key] = false;
1491
- return null;
1492
- }
1493
- function setCount(storage, key, value) {
1494
- try {
1495
- storage.setItem(countKey, value.toString());
1496
- count[key] = value;
1497
- return true;
1498
- } catch (err) {
1499
- return false;
1500
- }
1501
- }
1502
- function getCount(storage) {
1503
- const count2 = storage.getItem(countKey);
1504
- if (count2) {
1505
- const total = parseInt(count2);
1506
- return total ? total : 0;
1507
- }
1508
- return 0;
1509
- }
1510
- function initCache(storage, key) {
1511
- try {
1512
- storage.setItem(versionKey, cacheVersion);
1513
- } catch (err) {
1514
- }
1515
- setCount(storage, key, 0);
1516
- }
1517
- function destroyCache(storage) {
1518
- try {
1519
- const total = getCount(storage);
1520
- for (let i = 0; i < total; i++) {
1521
- storage.removeItem(cachePrefix + i.toString());
1522
- }
1523
- } catch (err) {
1524
- }
1525
- }
1526
- const loadCache = () => {
1527
- if (loaded) {
1528
- return;
1529
- }
1530
- loaded = true;
1531
- const minTime = Math.floor(Date.now() / hour) - cacheExpiration;
1532
- function load(key) {
1533
- const func = getGlobal(key);
1534
- if (!func) {
1535
- return;
1536
- }
1537
- const getItem = (index) => {
1538
- const name = cachePrefix + index.toString();
1539
- const item = func.getItem(name);
1540
- if (typeof item !== "string") {
1541
- return false;
1542
- }
1543
- let valid = true;
1544
- try {
1545
- const data = JSON.parse(item);
1546
- if (typeof data !== "object" || typeof data.cached !== "number" || data.cached < minTime || typeof data.provider !== "string" || typeof data.data !== "object" || typeof data.data.prefix !== "string") {
1547
- valid = false;
1548
- } else {
1549
- const provider = data.provider;
1550
- const prefix = data.data.prefix;
1551
- const storage = getStorage(provider, prefix);
1552
- valid = addIconSet(storage, data.data).length > 0;
1553
- }
1554
- } catch (err) {
1555
- valid = false;
1556
- }
1557
- if (!valid) {
1558
- func.removeItem(name);
1559
- }
1560
- return valid;
1561
- };
1562
- try {
1563
- const version = func.getItem(versionKey);
1564
- if (version !== cacheVersion) {
1565
- if (version) {
1566
- destroyCache(func);
1567
- }
1568
- initCache(func, key);
1569
- return;
1570
- }
1571
- let total = getCount(func);
1572
- for (let i = total - 1; i >= 0; i--) {
1573
- if (!getItem(i)) {
1574
- if (i === total - 1) {
1575
- total--;
1576
- } else {
1577
- emptyList[key].push(i);
1578
- }
1579
- }
1580
- }
1581
- setCount(func, key, total);
1582
- } catch (err) {
1583
- }
1584
- }
1585
- for (const key in config) {
1586
- load(key);
1587
- }
1588
- };
1589
- const storeCache = (provider, data) => {
1590
- if (!loaded) {
1591
- loadCache();
1592
- }
1593
- function store(key) {
1594
- if (!config[key]) {
1595
- return false;
1596
- }
1597
- const func = getGlobal(key);
1598
- if (!func) {
1599
- return false;
1600
- }
1601
- let index = emptyList[key].shift();
1602
- if (index === void 0) {
1603
- index = count[key];
1604
- if (!setCount(func, key, index + 1)) {
1605
- return false;
1606
- }
1607
- }
1608
- try {
1609
- const item = {
1610
- cached: Math.floor(Date.now() / hour),
1611
- provider,
1612
- data
1613
- };
1614
- func.setItem(cachePrefix + index.toString(), JSON.stringify(item));
1615
- } catch (err) {
1616
- return false;
1617
- }
1618
- return true;
1619
- }
1620
- if (!Object.keys(data.icons).length) {
1621
- return;
1622
- }
1623
- if (data.not_found) {
1624
- data = Object.assign({}, data);
1625
- delete data.not_found;
1626
- }
1627
- if (!store("local")) {
1628
- store("session");
1629
- }
1630
- };
1631
-
1632
1491
  function toggleBrowserCache(storage, value) {
1633
1492
  switch (storage) {
1634
1493
  case "local":
1635
1494
  case "session":
1636
- config[storage] = value;
1495
+ browserStorageConfig[storage] = value;
1637
1496
  break;
1638
1497
  case "all":
1639
- for (const key in config) {
1640
- config[key] = value;
1498
+ for (const key in browserStorageConfig) {
1499
+ browserStorageConfig[key] = value;
1641
1500
  }
1642
1501
  break;
1643
1502
  }
1644
1503
  }
1645
1504
 
1505
+ function mergeCustomisations(defaults, item) {
1506
+ const result = {
1507
+ ...defaults
1508
+ };
1509
+ for (const key in item) {
1510
+ const value = item[key];
1511
+ const valueType = typeof value;
1512
+ if (key in defaultIconSizeCustomisations) {
1513
+ if (value === null || value && (valueType === "string" || valueType === "number")) {
1514
+ result[key] = value;
1515
+ }
1516
+ } else if (valueType === typeof result[key]) {
1517
+ result[key] = key === "rotate" ? value % 4 : value;
1518
+ }
1519
+ }
1520
+ return result;
1521
+ }
1522
+
1646
1523
  const separator = /[\s,]+/;
1647
1524
  function flipFromString(custom, flip) {
1648
1525
  flip.split(separator).forEach((str) => {
@@ -1657,29 +1534,6 @@ function flipFromString(custom, flip) {
1657
1534
  }
1658
1535
  });
1659
1536
  }
1660
- function alignmentFromString(custom, align) {
1661
- align.split(separator).forEach((str) => {
1662
- const value = str.trim();
1663
- switch (value) {
1664
- case "left":
1665
- case "center":
1666
- case "right":
1667
- custom.hAlign = value;
1668
- break;
1669
- case "top":
1670
- case "middle":
1671
- case "bottom":
1672
- custom.vAlign = value;
1673
- break;
1674
- case "slice":
1675
- case "crop":
1676
- custom.slice = true;
1677
- break;
1678
- case "meet":
1679
- custom.slice = false;
1680
- }
1681
- });
1682
- }
1683
1537
 
1684
1538
  function rotateFromString(value, defaultValue = 0) {
1685
1539
  const units = value.replace(/^-?[0-9.]*/, "");
@@ -1713,6 +1567,29 @@ function rotateFromString(value, defaultValue = 0) {
1713
1567
  return defaultValue;
1714
1568
  }
1715
1569
 
1570
+ function iconToHTML(body, attributes) {
1571
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1572
+ for (const attr in attributes) {
1573
+ renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
1574
+ }
1575
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1576
+ }
1577
+
1578
+ function encodeSVGforURL(svg) {
1579
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1580
+ }
1581
+ function svgToData(svg) {
1582
+ return "data:image/svg+xml," + encodeSVGforURL(svg);
1583
+ }
1584
+ function svgToURL(svg) {
1585
+ return 'url("' + svgToData(svg) + '")';
1586
+ }
1587
+
1588
+ const defaultExtendedIconCustomisations = {
1589
+ ...defaultIconCustomisations,
1590
+ inline: false,
1591
+ };
1592
+
1716
1593
  /**
1717
1594
  * Default SVG attributes
1718
1595
  */
@@ -1722,27 +1599,55 @@ const svgDefaults = {
1722
1599
  'aria-hidden': true,
1723
1600
  'role': 'img',
1724
1601
  };
1602
+ /**
1603
+ * Style modes
1604
+ */
1605
+ const commonProps = {
1606
+ display: 'inline-block',
1607
+ };
1608
+ const monotoneProps = {
1609
+ backgroundColor: 'currentColor',
1610
+ };
1611
+ const coloredProps = {
1612
+ backgroundColor: 'transparent',
1613
+ };
1614
+ // Dynamically add common props to variables above
1615
+ const propsToAdd = {
1616
+ Image: 'var(--svg)',
1617
+ Repeat: 'no-repeat',
1618
+ Size: '100% 100%',
1619
+ };
1620
+ const propsToAddTo = {
1621
+ webkitMask: monotoneProps,
1622
+ mask: monotoneProps,
1623
+ background: coloredProps,
1624
+ };
1625
+ for (const prefix in propsToAddTo) {
1626
+ const list = propsToAddTo[prefix];
1627
+ for (const prop in propsToAdd) {
1628
+ list[prefix + prop] = propsToAdd[prop];
1629
+ }
1630
+ }
1725
1631
  /**
1726
1632
  * Aliases for customisations.
1727
- * In Vue 'v-' properties are reserved, so v-align and v-flip must be renamed
1633
+ * In Vue 'v-' properties are reserved, so v-flip must be renamed
1728
1634
  */
1729
- let customisationAliases = {};
1635
+ const customisationAliases = {};
1730
1636
  ['horizontal', 'vertical'].forEach((prefix) => {
1731
- ['Align', 'Flip'].forEach((suffix) => {
1732
- const attr = prefix.slice(0, 1) + suffix;
1733
- const value = {
1734
- attr,
1735
- boolean: suffix === 'Flip',
1736
- };
1737
- // vertical-align
1738
- customisationAliases[prefix + '-' + suffix.toLowerCase()] = value;
1739
- // v-align
1740
- customisationAliases[prefix.slice(0, 1) + '-' + suffix.toLowerCase()] =
1741
- value;
1742
- // verticalAlign
1743
- customisationAliases[prefix + suffix] = value;
1744
- });
1637
+ const attr = prefix.slice(0, 1) + 'Flip';
1638
+ // vertical-flip
1639
+ customisationAliases[prefix + '-flip'] = attr;
1640
+ // v-flip
1641
+ customisationAliases[prefix.slice(0, 1) + '-flip'] = attr;
1642
+ // verticalFlip
1643
+ customisationAliases[prefix + 'Flip'] = attr;
1745
1644
  });
1645
+ /**
1646
+ * Fix size: add 'px' to numbers
1647
+ */
1648
+ function fixSize(value) {
1649
+ return value + (value.match(/^[-0-9.]+$/) ? 'px' : '');
1650
+ }
1746
1651
  /**
1747
1652
  * Render icon
1748
1653
  */
@@ -1752,11 +1657,15 @@ icon,
1752
1657
  // Partial properties
1753
1658
  props) => {
1754
1659
  // Split properties
1755
- const customisations = mergeCustomisations(defaults, props);
1660
+ const customisations = mergeCustomisations(defaultExtendedIconCustomisations, props);
1756
1661
  const componentProps = { ...svgDefaults };
1662
+ // Check mode
1663
+ const mode = props.mode || 'svg';
1757
1664
  // Copy style
1758
- let style = typeof props.style === 'object' && !(props.style instanceof Array)
1759
- ? { ...props.style }
1665
+ const style = {};
1666
+ const propsStyle = props.style;
1667
+ const customStyle = typeof propsStyle === 'object' && !(propsStyle instanceof Array)
1668
+ ? propsStyle
1760
1669
  : {};
1761
1670
  // Get element properties
1762
1671
  for (let key in props) {
@@ -1769,6 +1678,7 @@ props) => {
1769
1678
  case 'icon':
1770
1679
  case 'style':
1771
1680
  case 'onLoad':
1681
+ case 'mode':
1772
1682
  break;
1773
1683
  // Boolean attributes
1774
1684
  case 'inline':
@@ -1783,12 +1693,6 @@ props) => {
1783
1693
  flipFromString(customisations, value);
1784
1694
  }
1785
1695
  break;
1786
- // Alignment as string
1787
- case 'align':
1788
- if (typeof value === 'string') {
1789
- alignmentFromString(customisations, value);
1790
- }
1791
- break;
1792
1696
  // Color: override style
1793
1697
  case 'color':
1794
1698
  style.color = value;
@@ -1810,52 +1714,69 @@ props) => {
1810
1714
  delete componentProps['aria-hidden'];
1811
1715
  }
1812
1716
  break;
1813
- default:
1814
- if (customisationAliases[key] !== void 0) {
1815
- // Aliases for customisations
1816
- if (customisationAliases[key].boolean &&
1817
- (value === true || value === 'true' || value === 1)) {
1818
- // Check for boolean
1819
- customisations[customisationAliases[key].attr] = true;
1820
- }
1821
- else if (!customisationAliases[key].boolean &&
1822
- typeof value === 'string' &&
1823
- value !== '') {
1824
- // String
1825
- customisations[customisationAliases[key].attr] = value;
1717
+ default: {
1718
+ const alias = customisationAliases[key];
1719
+ if (alias) {
1720
+ // Aliases for boolean customisations
1721
+ if (value === true || value === 'true' || value === 1) {
1722
+ customisations[alias] = true;
1826
1723
  }
1827
1724
  }
1828
- else if (defaults[key] === void 0) {
1725
+ else if (defaultExtendedIconCustomisations[key] === void 0) {
1829
1726
  // Copy missing property if it does not exist in customisations
1830
1727
  componentProps[key] = value;
1831
1728
  }
1729
+ }
1832
1730
  }
1833
1731
  }
1834
1732
  // Generate icon
1835
1733
  const item = iconToSVG(icon, customisations);
1836
- // Add icon stuff
1837
- for (let key in item.attributes) {
1838
- componentProps[key] = item.attributes[key];
1839
- }
1840
- if (item.inline &&
1841
- style.verticalAlign === void 0 &&
1842
- style['vertical-align'] === void 0) {
1734
+ const renderAttribs = item.attributes;
1735
+ // Inline display
1736
+ if (customisations.inline) {
1843
1737
  style.verticalAlign = '-0.125em';
1844
1738
  }
1845
- // Counter for ids based on "id" property to render icons consistently on server and client
1846
- let localCounter = 0;
1847
- let id = props.id;
1848
- if (typeof id === 'string') {
1849
- // Convert '-' to '_' to avoid errors in animations
1850
- id = id.replace(/-/g, '_');
1851
- }
1852
- // Add innerHTML and style to props
1853
- componentProps['innerHTML'] = replaceIDs(item.body, id ? () => id + 'ID' + localCounter++ : 'iconifyVue');
1854
- if (Object.keys(style).length > 0) {
1855
- componentProps['style'] = style;
1856
- }
1857
- // Render icon
1858
- return h('svg', componentProps);
1739
+ if (mode === 'svg') {
1740
+ // Add style
1741
+ componentProps.style = {
1742
+ ...style,
1743
+ ...customStyle,
1744
+ };
1745
+ // Add icon stuff
1746
+ Object.assign(componentProps, renderAttribs);
1747
+ // Counter for ids based on "id" property to render icons consistently on server and client
1748
+ let localCounter = 0;
1749
+ let id = props.id;
1750
+ if (typeof id === 'string') {
1751
+ // Convert '-' to '_' to avoid errors in animations
1752
+ id = id.replace(/-/g, '_');
1753
+ }
1754
+ // Add innerHTML and style to props
1755
+ componentProps['innerHTML'] = replaceIDs(item.body, id ? () => id + 'ID' + localCounter++ : 'iconifyVue');
1756
+ // Render icon
1757
+ return h('svg', componentProps);
1758
+ }
1759
+ // Render <span> with style
1760
+ const { body, width, height } = icon;
1761
+ const useMask = mode === 'mask' ||
1762
+ (mode === 'bg' ? false : body.indexOf('currentColor') !== -1);
1763
+ // Generate SVG
1764
+ const html = iconToHTML(body, {
1765
+ ...renderAttribs,
1766
+ width: width + '',
1767
+ height: height + '',
1768
+ });
1769
+ // Generate style
1770
+ componentProps.style = {
1771
+ ...style,
1772
+ '--svg': svgToURL(html),
1773
+ 'width': fixSize(renderAttribs.width),
1774
+ 'height': fixSize(renderAttribs.height),
1775
+ ...commonProps,
1776
+ ...(useMask ? monotoneProps : coloredProps),
1777
+ ...customStyle,
1778
+ };
1779
+ return h('span', componentProps);
1859
1780
  };
1860
1781
 
1861
1782
  /**
@@ -1882,8 +1803,7 @@ setAPIModule('', fetchAPIModule);
1882
1803
  */
1883
1804
  if (typeof document !== 'undefined' && typeof window !== 'undefined') {
1884
1805
  // Set cache and load existing cache
1885
- cache.store = storeCache;
1886
- loadCache();
1806
+ initBrowserStorage();
1887
1807
  const _window = window;
1888
1808
  // Load icons from global "IconifyPreload"
1889
1809
  if (_window.IconifyPreload !== void 0) {
@@ -1938,15 +1858,20 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
1938
1858
  /**
1939
1859
  * Empty icon data, rendered when icon is not available
1940
1860
  */
1941
- const emptyIcon = fullIcon({
1861
+ const emptyIcon = {
1862
+ ...defaultIconProps,
1942
1863
  body: '',
1943
- });
1864
+ };
1944
1865
  const Icon = defineComponent({
1945
1866
  // Do not inherit other attributes: it is handled by render()
1946
1867
  inheritAttrs: false,
1947
1868
  // Set initial data
1948
1869
  data() {
1949
1870
  return {
1871
+ // Current icon name
1872
+ _name: '',
1873
+ // Loading
1874
+ _loadingIcon: null,
1950
1875
  // Mounted status
1951
1876
  iconMounted: false,
1952
1877
  // Callback counter to trigger re-render
@@ -1954,10 +1879,6 @@ const Icon = defineComponent({
1954
1879
  };
1955
1880
  },
1956
1881
  mounted() {
1957
- // Current icon name
1958
- this._name = '';
1959
- // Loading
1960
- this._loadingIcon = null;
1961
1882
  // Mark as mounted
1962
1883
  this.iconMounted = true;
1963
1884
  },
@@ -1981,7 +1902,7 @@ const Icon = defineComponent({
1981
1902
  this._name = '';
1982
1903
  this.abortLoading();
1983
1904
  return {
1984
- data: fullIcon(icon),
1905
+ data: icon,
1985
1906
  };
1986
1907
  }
1987
1908
  // Invalid icon?
@@ -1993,18 +1914,21 @@ const Icon = defineComponent({
1993
1914
  }
1994
1915
  // Load icon
1995
1916
  const data = getIconData(iconName);
1996
- if (data === null) {
1997
- // Icon needs to be loaded
1917
+ if (!data) {
1918
+ // Icon data is not available
1998
1919
  if (!this._loadingIcon || this._loadingIcon.name !== icon) {
1999
1920
  // New icon to load
2000
1921
  this.abortLoading();
2001
1922
  this._name = '';
2002
- this._loadingIcon = {
2003
- name: icon,
2004
- abort: loadIcons([iconName], () => {
2005
- this.counter++;
2006
- }),
2007
- };
1923
+ if (data !== null) {
1924
+ // Icon was not loaded
1925
+ this._loadingIcon = {
1926
+ name: icon,
1927
+ abort: loadIcons([iconName], () => {
1928
+ this.counter++;
1929
+ }),
1930
+ };
1931
+ }
2008
1932
  }
2009
1933
  return null;
2010
1934
  }
@@ -2033,7 +1957,7 @@ const Icon = defineComponent({
2033
1957
  this.counter;
2034
1958
  const props = this.$attrs;
2035
1959
  // Get icon data
2036
- const icon = this.iconMounted
1960
+ const icon = (this.iconMounted || props.ssr)
2037
1961
  ? this.getIcon(props.icon, props.onLoad)
2038
1962
  : null;
2039
1963
  // Validate icon object
@@ -2051,7 +1975,10 @@ const Icon = defineComponent({
2051
1975
  };
2052
1976
  }
2053
1977
  // Render icon
2054
- return render(icon.data, newProps);
1978
+ return render({
1979
+ ...defaultIconProps,
1980
+ ...icon.data,
1981
+ }, newProps);
2055
1982
  },
2056
1983
  });
2057
1984
  /**
@@ -2064,7 +1991,6 @@ const _api = {
2064
1991
  setFetch,
2065
1992
  getFetch,
2066
1993
  listAPIProviders,
2067
- mergeParams,
2068
1994
  };
2069
1995
 
2070
- export { Icon, _api, addAPIProvider, addCollection, addIcon, buildIcon, calculateSize, disableCache, enableCache, getIcon, iconExists, listIcons, loadIcon, loadIcons, replaceIDs, shareStorage };
1996
+ export { Icon, _api, addAPIProvider, addCollection, addIcon, iconToSVG as buildIcon, calculateSize, disableCache, enableCache, getIcon, iconLoaded as iconExists, iconLoaded, listIcons, loadIcon, loadIcons, replaceIDs };