@histoire/vendors 0.17.17 → 1.0.0-alpha.2

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 (216) hide show
  1. package/dist/client/b-floating-vue.js +2175 -2150
  2. package/dist/client/b-iconify.js +663 -850
  3. package/dist/client/b-pinia.js +130 -68
  4. package/dist/client/b-scroll.js +3 -52
  5. package/dist/client/b-vue-router.js +385 -237
  6. package/dist/client/b-vue-use.js +4578 -3115
  7. package/dist/client/b-vue.js +1 -1
  8. package/dist/client/index.js +162 -20
  9. package/dist/client/node_modules/@babel/helper-string-parser/package.json +31 -0
  10. package/dist/client/node_modules/@babel/helper-validator-identifier/package.json +31 -0
  11. package/dist/client/node_modules/@babel/parser/package.json +10 -6
  12. package/dist/client/node_modules/@babel/parser/typings/babel-parser.d.ts +167 -188
  13. package/dist/client/node_modules/@babel/types/lib/index-legacy.d.ts +2786 -0
  14. package/dist/client/node_modules/@babel/types/lib/index.d.ts +3286 -0
  15. package/dist/client/node_modules/@babel/types/package.json +39 -0
  16. package/dist/client/node_modules/@floating-ui/core/dist/floating-ui.core.d.ts +525 -0
  17. package/dist/client/node_modules/@floating-ui/core/package.json +32 -39
  18. package/dist/client/node_modules/@floating-ui/dom/package.json +23 -24
  19. package/dist/client/node_modules/@floating-ui/dom/src/autoUpdate.d.ts +31 -0
  20. package/dist/client/node_modules/@floating-ui/dom/src/index.d.ts +11 -7
  21. package/dist/client/node_modules/@floating-ui/dom/src/platform.d.ts +1 -1
  22. package/dist/client/node_modules/@floating-ui/dom/src/types.d.ts +121 -20
  23. package/dist/client/node_modules/@floating-ui/dom/src/utils/getBoundingClientRect.d.ts +1 -1
  24. package/dist/client/node_modules/@floating-ui/dom/src/utils/getClippingRect.d.ts +12 -0
  25. package/dist/client/node_modules/@floating-ui/dom/src/utils/getCssDimensions.d.ts +4 -0
  26. package/dist/client/node_modules/@floating-ui/dom/src/utils/getDimensions.d.ts +1 -1
  27. package/dist/client/node_modules/@floating-ui/dom/src/utils/getNearestOverflowAncestor.d.ts +1 -0
  28. package/dist/client/node_modules/@floating-ui/dom/src/utils/getOverflowAncestors.d.ts +3 -0
  29. package/dist/client/node_modules/@floating-ui/dom/src/utils/getScale.d.ts +7 -0
  30. package/dist/client/node_modules/@floating-ui/dom/src/utils/getViewportRect.d.ts +2 -2
  31. package/dist/client/node_modules/@floating-ui/dom/src/utils/getWindowScrollBarX.d.ts +1 -1
  32. package/dist/client/node_modules/@floating-ui/dom/src/utils/is.d.ts +3 -1
  33. package/dist/client/node_modules/@floating-ui/dom/src/utils/unwrapElement.d.ts +2 -0
  34. package/dist/client/node_modules/@floating-ui/dom/src/utils/userAgent.d.ts +1 -0
  35. package/dist/client/node_modules/@floating-ui/dom/src/utils/window.d.ts +1 -2
  36. package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.d.ts +103 -0
  37. package/dist/client/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.d.ts +47 -0
  38. package/dist/client/node_modules/@floating-ui/utils/dom/floating-ui.utils.dom.d.ts +47 -0
  39. package/dist/client/node_modules/@floating-ui/utils/dom/package.json +6 -0
  40. package/dist/client/node_modules/@floating-ui/utils/package.json +70 -0
  41. package/dist/client/node_modules/@iconify/types/package.json +23 -0
  42. package/dist/client/node_modules/@iconify/types/provider.d.ts +44 -0
  43. package/dist/client/node_modules/@iconify/types/types.d.ts +272 -0
  44. package/dist/client/node_modules/@iconify/vue/dist/iconify.d.ts +122 -327
  45. package/dist/client/node_modules/@iconify/vue/dist/offline.d.ts +36 -269
  46. package/dist/client/node_modules/@iconify/vue/package.json +64 -60
  47. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/scopes.d.ts +49 -0
  48. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts +2 -0
  49. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/strings.d.ts +15 -0
  50. package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/vlq.d.ts +6 -0
  51. package/dist/client/node_modules/@jridgewell/sourcemap-codec/package.json +3 -2
  52. package/dist/client/node_modules/@types/web-bluetooth/index.d.ts +33 -14
  53. package/dist/client/node_modules/@types/web-bluetooth/package.json +12 -12
  54. package/dist/client/node_modules/@vue/compiler-core/dist/compiler-core.d.ts +218 -125
  55. package/dist/client/node_modules/@vue/compiler-core/package.json +20 -5
  56. package/dist/client/node_modules/@vue/compiler-dom/dist/compiler-dom.d.ts +6 -3
  57. package/dist/client/node_modules/@vue/compiler-dom/package.json +17 -3
  58. package/dist/client/node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts +35 -25
  59. package/dist/client/node_modules/@vue/compiler-sfc/package.json +27 -18
  60. package/dist/client/node_modules/@vue/compiler-ssr/dist/compiler-ssr.d.ts +2 -2
  61. package/dist/client/node_modules/@vue/compiler-ssr/package.json +3 -3
  62. package/dist/client/node_modules/@vue/devtools-api/package.json +1 -1
  63. package/dist/client/node_modules/@vue/reactivity/dist/reactivity.d.ts +268 -166
  64. package/dist/client/node_modules/@vue/reactivity/package.json +16 -2
  65. package/dist/client/node_modules/@vue/runtime-core/dist/runtime-core.d.ts +728 -529
  66. package/dist/client/node_modules/@vue/runtime-core/package.json +17 -3
  67. package/dist/client/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +195 -86
  68. package/dist/client/node_modules/@vue/runtime-dom/package.json +22 -4
  69. package/dist/client/node_modules/@vue/server-renderer/dist/server-renderer.d.ts +4 -8
  70. package/dist/client/node_modules/@vue/server-renderer/package.json +18 -4
  71. package/dist/client/node_modules/@vue/shared/dist/shared.d.ts +45 -30
  72. package/dist/client/node_modules/@vue/shared/package.json +15 -1
  73. package/dist/client/node_modules/@vueuse/core/index.d.ts +2323 -666
  74. package/dist/client/node_modules/@vueuse/core/package.json +22 -12
  75. package/dist/client/node_modules/@vueuse/metadata/index.d.ts +7 -5
  76. package/dist/client/node_modules/@vueuse/metadata/package.json +14 -7
  77. package/dist/client/node_modules/@vueuse/shared/index.d.ts +451 -280
  78. package/dist/client/node_modules/@vueuse/shared/package.json +17 -6
  79. package/dist/client/node_modules/compute-scroll-into-view/dist/index.d.ts +75 -0
  80. package/dist/client/node_modules/compute-scroll-into-view/package.json +35 -45
  81. package/dist/client/node_modules/entities/lib/decode.d.ts +211 -0
  82. package/dist/client/node_modules/entities/lib/decode_codepoint.d.ts +19 -0
  83. package/dist/client/node_modules/entities/lib/encode.d.ts +22 -0
  84. package/dist/client/node_modules/entities/lib/escape.d.ts +43 -0
  85. package/dist/client/node_modules/entities/lib/esm/decode.d.ts +211 -0
  86. package/dist/client/node_modules/entities/lib/esm/decode_codepoint.d.ts +19 -0
  87. package/dist/client/node_modules/entities/lib/esm/encode.d.ts +22 -0
  88. package/dist/client/node_modules/entities/lib/esm/escape.d.ts +43 -0
  89. package/dist/client/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +3 -0
  90. package/dist/client/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +3 -0
  91. package/dist/client/node_modules/entities/lib/esm/generated/encode-html.d.ts +8 -0
  92. package/dist/client/node_modules/entities/lib/esm/index.d.ts +96 -0
  93. package/dist/client/node_modules/entities/lib/esm/package.json +1 -0
  94. package/dist/client/node_modules/entities/lib/generated/decode-data-html.d.ts +3 -0
  95. package/dist/client/node_modules/entities/lib/generated/decode-data-xml.d.ts +3 -0
  96. package/dist/client/node_modules/entities/lib/generated/encode-html.d.ts +8 -0
  97. package/dist/client/node_modules/entities/lib/index.d.ts +96 -0
  98. package/dist/client/node_modules/entities/package.json +90 -0
  99. package/dist/client/node_modules/floating-vue/dist/components/Dropdown.d.ts +398 -0
  100. package/dist/client/node_modules/floating-vue/dist/components/Menu.d.ts +398 -0
  101. package/dist/client/node_modules/floating-vue/dist/components/Popper.d.ts +225 -105
  102. package/dist/client/node_modules/floating-vue/dist/components/Popper.vue.d.ts +471 -364
  103. package/dist/client/node_modules/floating-vue/dist/components/PopperContent.vue.d.ts +14 -25
  104. package/dist/client/node_modules/floating-vue/dist/components/PopperWrapper.vue.d.ts +392 -6
  105. package/dist/client/node_modules/floating-vue/dist/components/Tooltip.d.ts +398 -0
  106. package/dist/client/node_modules/floating-vue/dist/components/TooltipDirective.vue.d.ts +49 -10
  107. package/dist/client/node_modules/floating-vue/dist/config.d.ts +1 -1
  108. package/dist/client/node_modules/floating-vue/dist/index.d.ts +2071 -247
  109. package/dist/client/node_modules/floating-vue/dist/util/events.d.ts +2 -0
  110. package/dist/client/node_modules/floating-vue/dist/util/popper.d.ts +1 -1
  111. package/dist/client/node_modules/floating-vue/package.json +42 -33
  112. package/dist/client/node_modules/magic-string/dist/magic-string.cjs.d.ts +250 -229
  113. package/dist/client/node_modules/magic-string/package.json +24 -26
  114. package/dist/client/node_modules/nanoid/package.json +1 -1
  115. package/dist/client/node_modules/picocolors/package.json +2 -2
  116. package/dist/client/node_modules/picocolors/types.d.ts +51 -0
  117. package/dist/client/node_modules/pinia/dist/pinia.d.ts +116 -37
  118. package/dist/client/node_modules/pinia/package.json +7 -11
  119. package/dist/client/node_modules/postcss/lib/at-rule.d.ts +22 -19
  120. package/dist/client/node_modules/postcss/lib/comment.d.ts +6 -5
  121. package/dist/client/node_modules/postcss/lib/container.d.ts +72 -82
  122. package/dist/client/node_modules/postcss/lib/css-syntax-error.d.ts +1 -1
  123. package/dist/client/node_modules/postcss/lib/declaration.d.ts +16 -13
  124. package/dist/client/node_modules/postcss/lib/document.d.ts +4 -4
  125. package/dist/client/node_modules/postcss/lib/input.d.ts +28 -16
  126. package/dist/client/node_modules/postcss/lib/lazy-result.d.ts +40 -40
  127. package/dist/client/node_modules/postcss/lib/list.d.ts +5 -2
  128. package/dist/client/node_modules/postcss/lib/no-work-result.d.ts +5 -5
  129. package/dist/client/node_modules/postcss/lib/node.d.ts +19 -14
  130. package/dist/client/node_modules/postcss/lib/postcss.d.ts +25 -8
  131. package/dist/client/node_modules/postcss/lib/processor.d.ts +1 -1
  132. package/dist/client/node_modules/postcss/lib/result.d.ts +10 -11
  133. package/dist/client/node_modules/postcss/lib/root.d.ts +4 -4
  134. package/dist/client/node_modules/postcss/lib/rule.d.ts +22 -13
  135. package/dist/client/node_modules/postcss/package.json +4 -4
  136. package/dist/client/node_modules/scroll-into-view-if-needed/dist/index.d.ts +79 -0
  137. package/dist/client/node_modules/scroll-into-view-if-needed/package.json +28 -67
  138. package/dist/client/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
  139. package/dist/client/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
  140. package/dist/client/node_modules/source-map-js/lib/source-node.d.ts +1 -0
  141. package/dist/client/node_modules/source-map-js/package.json +1 -1
  142. package/dist/client/node_modules/source-map-js/source-map.d.ts +88 -99
  143. package/dist/client/node_modules/vue/dist/vue.d.ts +0 -4
  144. package/dist/client/node_modules/vue/jsx-runtime/index.d.ts +2 -1
  145. package/dist/client/node_modules/vue/jsx.d.ts +2 -1
  146. package/dist/client/node_modules/vue/package.json +13 -14
  147. package/dist/client/node_modules/{pinia/node_modules/vue-demi → vue-demi}/package.json +1 -1
  148. package/dist/client/node_modules/vue-router/dist/vue-router.d.ts +410 -81
  149. package/dist/client/node_modules/vue-router/package.json +66 -37
  150. package/dist/client/node_modules/vue-router/vue-router-auto-routes.d.ts +4 -0
  151. package/dist/client/node_modules/vue-router/vue-router-auto.d.ts +4 -0
  152. package/dist/client/vue.runtime.esm-bundler.js +6458 -4714
  153. package/package.json +17 -17
  154. package/rollup.config.mjs +6 -6
  155. package/dist/client/index2.js +0 -168
  156. package/dist/client/node_modules/@floating-ui/core/index.d.ts +0 -1
  157. package/dist/client/node_modules/@floating-ui/core/src/_babel.d.ts +0 -1
  158. package/dist/client/node_modules/@floating-ui/core/src/computeCoordsFromPlacement.d.ts +0 -4
  159. package/dist/client/node_modules/@floating-ui/core/src/computePosition.d.ts +0 -2
  160. package/dist/client/node_modules/@floating-ui/core/src/detectOverflow.d.ts +0 -9
  161. package/dist/client/node_modules/@floating-ui/core/src/enums.d.ts +0 -4
  162. package/dist/client/node_modules/@floating-ui/core/src/index.d.ts +0 -11
  163. package/dist/client/node_modules/@floating-ui/core/src/middleware/arrow.d.ts +0 -6
  164. package/dist/client/node_modules/@floating-ui/core/src/middleware/autoPlacement.d.ts +0 -9
  165. package/dist/client/node_modules/@floating-ui/core/src/middleware/flip.d.ts +0 -10
  166. package/dist/client/node_modules/@floating-ui/core/src/middleware/hide.d.ts +0 -2
  167. package/dist/client/node_modules/@floating-ui/core/src/middleware/inline.d.ts +0 -5
  168. package/dist/client/node_modules/@floating-ui/core/src/middleware/offset.d.ts +0 -21
  169. package/dist/client/node_modules/@floating-ui/core/src/middleware/shift.d.ts +0 -32
  170. package/dist/client/node_modules/@floating-ui/core/src/middleware/size.d.ts +0 -6
  171. package/dist/client/node_modules/@floating-ui/core/src/types.d.ts +0 -148
  172. package/dist/client/node_modules/@floating-ui/core/src/utils/expandPaddingObject.d.ts +0 -2
  173. package/dist/client/node_modules/@floating-ui/core/src/utils/getAlignment.d.ts +0 -2
  174. package/dist/client/node_modules/@floating-ui/core/src/utils/getAlignmentSides.d.ts +0 -5
  175. package/dist/client/node_modules/@floating-ui/core/src/utils/getBasePlacement.d.ts +0 -2
  176. package/dist/client/node_modules/@floating-ui/core/src/utils/getCrossAxis.d.ts +0 -2
  177. package/dist/client/node_modules/@floating-ui/core/src/utils/getExpandedPlacements.d.ts +0 -2
  178. package/dist/client/node_modules/@floating-ui/core/src/utils/getLengthFromAxis.d.ts +0 -2
  179. package/dist/client/node_modules/@floating-ui/core/src/utils/getMainAxisFromPlacement.d.ts +0 -2
  180. package/dist/client/node_modules/@floating-ui/core/src/utils/getOppositeAlignmentPlacement.d.ts +0 -2
  181. package/dist/client/node_modules/@floating-ui/core/src/utils/getOppositePlacement.d.ts +0 -1
  182. package/dist/client/node_modules/@floating-ui/core/src/utils/getPaddingObject.d.ts +0 -2
  183. package/dist/client/node_modules/@floating-ui/core/src/utils/math.d.ts +0 -2
  184. package/dist/client/node_modules/@floating-ui/core/src/utils/rectToClientRect.d.ts +0 -2
  185. package/dist/client/node_modules/@floating-ui/core/src/utils/within.d.ts +0 -1
  186. package/dist/client/node_modules/@floating-ui/dom/src/utils/contains.d.ts +0 -1
  187. package/dist/client/node_modules/@floating-ui/dom/src/utils/getClippingClientRect.d.ts +0 -6
  188. package/dist/client/node_modules/@floating-ui/dom/src/utils/getScrollParent.d.ts +0 -1
  189. package/dist/client/node_modules/@floating-ui/dom/src/utils/getScrollParents.d.ts +0 -1
  190. package/dist/client/node_modules/@vue/reactivity-transform/dist/reactivity-transform.d.ts +0 -43
  191. package/dist/client/node_modules/@vue/reactivity-transform/package.json +0 -41
  192. package/dist/client/node_modules/@vueuse/core/node_modules/vue-demi/package.json +0 -47
  193. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/index.d.ts +0 -22
  194. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v2/index.d.ts +0 -33
  195. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v2.7/index.d.ts +0 -38
  196. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v3/index.d.ts +0 -22
  197. package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/package.json +0 -47
  198. package/dist/client/node_modules/compute-scroll-into-view/typings/index.d.ts +0 -19
  199. package/dist/client/node_modules/floating-vue/dist/components/Dropdown.vue.d.ts +0 -25
  200. package/dist/client/node_modules/floating-vue/dist/components/Menu.vue.d.ts +0 -25
  201. package/dist/client/node_modules/floating-vue/dist/components/Tooltip.vue.d.ts +0 -25
  202. package/dist/client/node_modules/floating-vue/src/global-shim.d.ts +0 -1
  203. package/dist/client/node_modules/floating-vue/src/vue-shim.d.ts +0 -5
  204. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/index.d.ts +0 -22
  205. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2/index.d.ts +0 -33
  206. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2.7/index.d.ts +0 -38
  207. package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v3/index.d.ts +0 -22
  208. package/dist/client/node_modules/scroll-into-view-if-needed/typings/index.d.ts +0 -13
  209. package/dist/client/node_modules/scroll-into-view-if-needed/typings/types.d.ts +0 -19
  210. package/dist/client/node_modules/vue/macros-global.d.ts +0 -19
  211. package/dist/client/node_modules/vue/macros.d.ts +0 -112
  212. package/dist/client/node_modules/vue/ref-macros.d.ts +0 -2
  213. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/index.d.ts +0 -0
  214. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/v2/index.d.ts +0 -0
  215. /package/dist/client/node_modules/{@vueuse/core/node_modules/vue-demi → vue-demi}/lib/v2.7/index.d.ts +0 -0
  216. /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,111 @@ 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 !!// Check prefix: cannot be empty, unless allowSimpleName is enabled
51
+ // Check name: cannot be empty
52
+ ((allowSimpleName && icon.prefix === "" || !!icon.prefix) && !!icon.name);
63
53
  };
64
54
 
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
- }
55
+ const defaultIconDimensions = Object.freeze(
56
+ {
57
+ left: 0,
58
+ top: 0,
59
+ width: 16,
60
+ height: 16
61
+ }
62
+ );
63
+ const defaultIconTransformations = Object.freeze({
64
+ rotate: 0,
65
+ vFlip: false,
66
+ hFlip: false
67
+ });
68
+ const defaultIconProps = Object.freeze({
69
+ ...defaultIconDimensions,
70
+ ...defaultIconTransformations
71
+ });
72
+ const defaultExtendedIconProps = Object.freeze({
73
+ ...defaultIconProps,
74
+ body: "",
75
+ hidden: false
76
+ });
77
+
78
+ function mergeIconTransformations(obj1, obj2) {
79
+ const result = {};
80
+ if (!obj1.hFlip !== !obj2.hFlip) {
81
+ result.hFlip = true;
82
+ }
83
+ if (!obj1.vFlip !== !obj2.vFlip) {
84
+ result.vFlip = true;
85
+ }
86
+ const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
87
+ if (rotate) {
88
+ result.rotate = rotate;
87
89
  }
88
90
  return result;
89
91
  }
90
92
 
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);
93
+ function mergeIconData(parent, child) {
94
+ const result = mergeIconTransformations(parent, child);
95
+ for (const key in defaultExtendedIconProps) {
96
+ if (key in defaultIconTransformations) {
97
+ if (key in parent && !(key in result)) {
98
+ result[key] = defaultIconTransformations[key];
105
99
  }
106
- return result2;
107
- }
108
- const chars = data.chars;
109
- if (!iteration && chars && chars[name2] !== void 0) {
110
- return getIcon(chars[name2], iteration + 1);
100
+ } else if (key in child) {
101
+ result[key] = child[key];
102
+ } else if (key in parent) {
103
+ result[key] = parent[key];
111
104
  }
112
- return null;
113
105
  }
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];
106
+ return result;
107
+ }
108
+
109
+ function getIconsTree(data, names) {
110
+ const icons = data.icons;
111
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
112
+ const resolved = /* @__PURE__ */ Object.create(null);
113
+ function resolve(name) {
114
+ if (icons[name]) {
115
+ return resolved[name] = [];
116
+ }
117
+ if (!(name in resolved)) {
118
+ resolved[name] = null;
119
+ const parent = aliases[name] && aliases[name].parent;
120
+ const value = parent && resolve(parent);
121
+ if (value) {
122
+ resolved[name] = [parent].concat(value);
119
123
  }
120
124
  }
125
+ return resolved[name];
121
126
  }
122
- return result && full ? fullIcon(result) : result;
127
+ (Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
128
+ return resolved;
123
129
  }
124
130
 
125
- function isVariation(item) {
126
- for (const key in iconDefaults) {
127
- if (item[key] !== void 0) {
128
- return true;
129
- }
130
- }
131
- return false;
131
+ function internalGetIconData(data, name, tree) {
132
+ const icons = data.icons;
133
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
134
+ let currentProps = {};
135
+ function parse(name2) {
136
+ currentProps = mergeIconData(
137
+ icons[name2] || aliases[name2],
138
+ currentProps
139
+ );
140
+ }
141
+ parse(name);
142
+ tree.forEach(parse);
143
+ return mergeIconData(data, currentProps);
132
144
  }
133
- function parseIconSet(data, callback, options) {
134
- options = options || {};
145
+
146
+ function parseIconSet(data, callback) {
135
147
  const names = [];
136
148
  if (typeof data !== "object" || typeof data.icons !== "object") {
137
149
  return names;
@@ -142,38 +154,30 @@ function parseIconSet(data, callback, options) {
142
154
  names.push(name);
143
155
  });
144
156
  }
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);
157
+ const tree = getIconsTree(data);
158
+ for (const name in tree) {
159
+ const item = tree[name];
160
+ if (item) {
161
+ callback(name, internalGetIconData(data, name, item));
150
162
  names.push(name);
151
163
  }
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
164
  }
167
165
  return names;
168
166
  }
169
167
 
170
- const optionalProperties = {
171
- provider: "string",
172
- aliases: "object",
173
- not_found: "object"
168
+ const optionalPropertyDefaults = {
169
+ provider: "",
170
+ aliases: {},
171
+ not_found: {},
172
+ ...defaultIconDimensions
174
173
  };
175
- for (const prop in iconDefaults) {
176
- optionalProperties[prop] = typeof iconDefaults[prop];
174
+ function checkOptionalProps(item, defaults) {
175
+ for (const prop in defaults) {
176
+ if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
177
+ return false;
178
+ }
179
+ }
180
+ return true;
177
181
  }
178
182
  function quicklyValidateIconSet(obj) {
179
183
  if (typeof obj !== "object" || obj === null) {
@@ -183,126 +187,90 @@ function quicklyValidateIconSet(obj) {
183
187
  if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
184
188
  return null;
185
189
  }
186
- for (const prop in optionalProperties) {
187
- if (obj[prop] !== void 0 && typeof obj[prop] !== optionalProperties[prop]) {
188
- return null;
189
- }
190
+ if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
191
+ return null;
190
192
  }
191
193
  const icons = data.icons;
192
194
  for (const name in icons) {
193
195
  const icon = icons[name];
194
- if (!name.match(matchName) || typeof icon.body !== "string") {
196
+ if (
197
+ // Name cannot be empty
198
+ !name || // Must have body
199
+ typeof icon.body !== "string" || // Check other props
200
+ !checkOptionalProps(
201
+ icon,
202
+ defaultExtendedIconProps
203
+ )
204
+ ) {
195
205
  return null;
196
206
  }
197
- for (const prop in iconDefaults) {
198
- if (icon[prop] !== void 0 && typeof icon[prop] !== typeof iconDefaults[prop]) {
199
- return null;
200
- }
201
- }
202
207
  }
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
- }
208
+ const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
209
+ for (const name in aliases) {
210
+ const icon = aliases[name];
211
+ const parent = icon.parent;
212
+ if (
213
+ // Name cannot be empty
214
+ !name || // Parent must be set and point to existing icon
215
+ typeof parent !== "string" || !icons[parent] && !aliases[parent] || // Check other props
216
+ !checkOptionalProps(
217
+ icon,
218
+ defaultExtendedIconProps
219
+ )
220
+ ) {
221
+ return null;
216
222
  }
217
223
  }
218
224
  return data;
219
225
  }
220
226
 
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
- }
227
+ const dataStorage = /* @__PURE__ */ Object.create(null);
242
228
  function newStorage(provider, prefix) {
243
229
  return {
244
230
  provider,
245
231
  prefix,
246
232
  icons: /* @__PURE__ */ Object.create(null),
247
- missing: /* @__PURE__ */ Object.create(null)
233
+ missing: /* @__PURE__ */ new Set()
248
234
  };
249
235
  }
250
236
  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];
237
+ const providerStorage = dataStorage[provider] || (dataStorage[provider] = /* @__PURE__ */ Object.create(null));
238
+ return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
259
239
  }
260
- function addIconSet(storage2, data) {
240
+ function addIconSet(storage, data) {
261
241
  if (!quicklyValidateIconSet(data)) {
262
242
  return [];
263
243
  }
264
- const t = Date.now();
265
244
  return parseIconSet(data, (name, icon) => {
266
245
  if (icon) {
267
- storage2.icons[name] = icon;
246
+ storage.icons[name] = icon;
268
247
  } else {
269
- storage2.missing[name] = t;
248
+ storage.missing.add(name);
270
249
  }
271
250
  });
272
251
  }
273
- function addIconToStorage(storage2, name, icon) {
252
+ function addIconToStorage(storage, name, icon) {
274
253
  try {
275
254
  if (typeof icon.body === "string") {
276
- storage2.icons[name] = Object.freeze(fullIcon(icon));
255
+ storage.icons[name] = { ...icon };
277
256
  return true;
278
257
  }
279
258
  } catch (err) {
280
259
  }
281
260
  return false;
282
261
  }
283
- function getIconFromStorage(storage2, name) {
284
- const value = storage2.icons[name];
285
- return value === void 0 ? null : value;
286
- }
287
262
  function listIcons(provider, prefix) {
288
263
  let allIcons = [];
289
- let providers;
290
- if (typeof provider === "string") {
291
- providers = [provider];
292
- } else {
293
- providers = Object.keys(storage$1);
294
- }
264
+ const providers = typeof provider === "string" ? [provider] : Object.keys(dataStorage);
295
265
  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
- }
266
+ const prefixes = typeof provider2 === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider2] || {});
302
267
  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);
268
+ const storage = getStorage(provider2, prefix2);
269
+ allIcons = allIcons.concat(
270
+ Object.keys(storage.icons).map(
271
+ (name) => (provider2 !== "" ? "@" + provider2 + ":" : "") + prefix2 + ":" + name
272
+ )
273
+ );
306
274
  });
307
275
  });
308
276
  return allIcons;
@@ -317,7 +285,11 @@ function allowSimpleNames(allow) {
317
285
  }
318
286
  function getIconData(name) {
319
287
  const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
320
- return icon ? getIconFromStorage(getStorage(icon.provider, icon.prefix), icon.name) : null;
288
+ if (icon) {
289
+ const storage = getStorage(icon.provider, icon.prefix);
290
+ const iconName = icon.name;
291
+ return storage.icons[iconName] || (storage.missing.has(iconName) ? null : void 0);
292
+ }
321
293
  }
322
294
  function addIcon(name, data) {
323
295
  const icon = stringToIcon(name, true, simpleNames);
@@ -325,99 +297,64 @@ function addIcon(name, data) {
325
297
  return false;
326
298
  }
327
299
  const storage = getStorage(icon.provider, icon.prefix);
328
- return addIconToStorage(storage, icon.name, data);
300
+ if (data) {
301
+ return addIconToStorage(storage, icon.name, data);
302
+ } else {
303
+ storage.missing.add(icon.name);
304
+ return true;
305
+ }
329
306
  }
330
307
  function addCollection(data, provider) {
331
308
  if (typeof data !== "object") {
332
309
  return false;
333
310
  }
334
311
  if (typeof provider !== "string") {
335
- provider = typeof data.provider === "string" ? data.provider : "";
312
+ provider = data.provider || "";
336
313
  }
337
- if (simpleNames && provider === "" && (typeof data.prefix !== "string" || data.prefix === "")) {
314
+ if (simpleNames && !provider && !data.prefix) {
338
315
  let added = false;
339
316
  if (quicklyValidateIconSet(data)) {
340
317
  data.prefix = "";
341
318
  parseIconSet(data, (name, icon) => {
342
- if (icon && addIcon(name, icon)) {
319
+ if (addIcon(name, icon)) {
343
320
  added = true;
344
321
  }
345
322
  });
346
323
  }
347
324
  return added;
348
325
  }
349
- if (typeof data.prefix !== "string" || !validateIcon({
326
+ const prefix = data.prefix;
327
+ if (!validateIconName({
350
328
  provider,
351
- prefix: data.prefix,
329
+ prefix,
352
330
  name: "a"
353
331
  })) {
354
332
  return false;
355
333
  }
356
- const storage = getStorage(provider, data.prefix);
334
+ const storage = getStorage(provider, prefix);
357
335
  return !!addIconSet(storage, data);
358
336
  }
359
- function iconExists(name) {
360
- return getIconData(name) !== null;
337
+ function iconLoaded(name) {
338
+ return !!getIconData(name);
361
339
  }
362
340
  function getIcon(name) {
363
341
  const result = getIconData(name);
364
- return result ? { ...result } : null;
342
+ return result ? {
343
+ ...defaultIconProps,
344
+ ...result
345
+ } : result;
365
346
  }
366
347
 
367
- const defaults = Object.freeze({
368
- inline: false,
348
+ const defaultIconSizeCustomisations = Object.freeze({
369
349
  width: null,
370
- height: null,
371
- hAlign: "center",
372
- vAlign: "middle",
373
- slice: false,
374
- hFlip: false,
375
- vFlip: false,
376
- rotate: 0
350
+ height: null
351
+ });
352
+ const defaultIconCustomisations = Object.freeze({
353
+ // Dimensions
354
+ ...defaultIconSizeCustomisations,
355
+ // Transformations
356
+ ...defaultIconTransformations
377
357
  });
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
358
 
422
359
  const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
423
360
  const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
@@ -425,7 +362,7 @@ function calculateSize(size, ratio, precision) {
425
362
  if (ratio === 1) {
426
363
  return size;
427
364
  }
428
- precision = precision === void 0 ? 100 : precision;
365
+ precision = precision || 100;
429
366
  if (typeof size === "number") {
430
367
  return Math.ceil(size * ratio * precision) / precision;
431
368
  }
@@ -458,40 +395,53 @@ function calculateSize(size, ratio, precision) {
458
395
  }
459
396
  }
460
397
 
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";
469
- break;
470
- default:
471
- result += "xMid";
472
- }
473
- switch (props.vAlign) {
474
- case "top":
475
- result += "YMin";
398
+ function splitSVGDefs(content, tag = "defs") {
399
+ let defs = "";
400
+ const index = content.indexOf("<" + tag);
401
+ while (index >= 0) {
402
+ const start = content.indexOf(">", index);
403
+ const end = content.indexOf("</" + tag);
404
+ if (start === -1 || end === -1) {
476
405
  break;
477
- case "bottom":
478
- result += "YMax";
406
+ }
407
+ const endEnd = content.indexOf(">", end);
408
+ if (endEnd === -1) {
479
409
  break;
480
- default:
481
- result += "YMid";
410
+ }
411
+ defs += content.slice(start + 1, end).trim();
412
+ content = content.slice(0, index).trim() + content.slice(endEnd + 1);
482
413
  }
483
- result += props.slice ? " slice" : " meet";
484
- return result;
414
+ return {
415
+ defs,
416
+ content
417
+ };
418
+ }
419
+ function mergeDefsAndContent(defs, content) {
420
+ return defs ? "<defs>" + defs + "</defs>" + content : content;
421
+ }
422
+ function wrapSVGContent(body, start, end) {
423
+ const split = splitSVGDefs(body);
424
+ return mergeDefsAndContent(split.defs, start + split.content + end);
485
425
  }
426
+
427
+ const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
486
428
  function iconToSVG(icon, customisations) {
429
+ const fullIcon = {
430
+ ...defaultIconProps,
431
+ ...icon
432
+ };
433
+ const fullCustomisations = {
434
+ ...defaultIconCustomisations,
435
+ ...customisations
436
+ };
487
437
  const box = {
488
- left: icon.left,
489
- top: icon.top,
490
- width: icon.width,
491
- height: icon.height
438
+ left: fullIcon.left,
439
+ top: fullIcon.top,
440
+ width: fullIcon.width,
441
+ height: fullIcon.height
492
442
  };
493
- let body = icon.body;
494
- [icon, customisations].forEach((props) => {
443
+ let body = fullIcon.body;
444
+ [fullIcon, fullCustomisations].forEach((props) => {
495
445
  const transformations = [];
496
446
  const hFlip = props.hFlip;
497
447
  const vFlip = props.vFlip;
@@ -500,12 +450,16 @@ function iconToSVG(icon, customisations) {
500
450
  if (vFlip) {
501
451
  rotation += 2;
502
452
  } else {
503
- transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
453
+ transformations.push(
454
+ "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
455
+ );
504
456
  transformations.push("scale(-1 1)");
505
457
  box.top = box.left = 0;
506
458
  }
507
459
  } else if (vFlip) {
508
- transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
460
+ transformations.push(
461
+ "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
462
+ );
509
463
  transformations.push("scale(1 -1)");
510
464
  box.top = box.left = 0;
511
465
  }
@@ -517,18 +471,24 @@ function iconToSVG(icon, customisations) {
517
471
  switch (rotation) {
518
472
  case 1:
519
473
  tempValue = box.height / 2 + box.top;
520
- transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
474
+ transformations.unshift(
475
+ "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
476
+ );
521
477
  break;
522
478
  case 2:
523
- transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
479
+ transformations.unshift(
480
+ "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
481
+ );
524
482
  break;
525
483
  case 3:
526
484
  tempValue = box.width / 2 + box.left;
527
- transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
485
+ transformations.unshift(
486
+ "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
487
+ );
528
488
  break;
529
489
  }
530
490
  if (rotation % 2 === 1) {
531
- if (box.left !== 0 || box.top !== 0) {
491
+ if (box.left !== box.top) {
532
492
  tempValue = box.left;
533
493
  box.left = box.top;
534
494
  box.top = tempValue;
@@ -540,48 +500,41 @@ function iconToSVG(icon, customisations) {
540
500
  }
541
501
  }
542
502
  if (transformations.length) {
543
- body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
503
+ body = wrapSVGContent(
504
+ body,
505
+ '<g transform="' + transformations.join(" ") + '">',
506
+ "</g>"
507
+ );
544
508
  }
545
509
  });
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);
510
+ const customisationsWidth = fullCustomisations.width;
511
+ const customisationsHeight = fullCustomisations.height;
512
+ const boxWidth = box.width;
513
+ const boxHeight = box.height;
514
+ let width;
515
+ let height;
516
+ if (customisationsWidth === null) {
517
+ height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
518
+ width = calculateSize(height, boxWidth / boxHeight);
556
519
  } 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;
520
+ width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
521
+ height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
565
522
  }
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
- },
523
+ const attributes = {};
524
+ const setAttr = (prop, value) => {
525
+ if (!isUnsetKeyword(value)) {
526
+ attributes[prop] = value.toString();
527
+ }
528
+ };
529
+ setAttr("width", width);
530
+ setAttr("height", height);
531
+ const viewBox = [box.left, box.top, boxWidth, boxHeight];
532
+ attributes.viewBox = viewBox.join(" ");
533
+ return {
534
+ attributes,
535
+ viewBox,
575
536
  body
576
537
  };
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
538
  }
586
539
 
587
540
  const regex = /\sid="(\S+)"/g;
@@ -596,11 +549,18 @@ function replaceIDs(body, prefix = randomPrefix) {
596
549
  if (!ids.length) {
597
550
  return body;
598
551
  }
552
+ const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
599
553
  ids.forEach((id) => {
600
554
  const newID = typeof prefix === "function" ? prefix(id) : prefix + (counter++).toString();
601
555
  const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
602
- body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + "$3");
556
+ body = body.replace(
557
+ // Allowed characters before id: [#;"]
558
+ // Allowed characters after id: [)"], .[a-z]
559
+ new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"),
560
+ "$1" + newID + suffix + "$3"
561
+ );
603
562
  });
563
+ body = body.replace(new RegExp(suffix, "g"), "");
604
564
  return body;
605
565
  }
606
566
 
@@ -623,13 +583,21 @@ function createAPIConfig(source) {
623
583
  }
624
584
  }
625
585
  const result = {
586
+ // API hosts
626
587
  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,
588
+ // Root path
589
+ path: source.path || "/",
590
+ // URL length limit
591
+ maxURL: source.maxURL || 500,
592
+ // Timeout before next host is used.
593
+ rotate: source.rotate || 750,
594
+ // Timeout before failing query.
595
+ timeout: source.timeout || 5e3,
596
+ // Randomise default API end point.
631
597
  random: source.random === true,
632
- index: source.index ? source.index : 0,
598
+ // Start index
599
+ index: source.index || 0,
600
+ // Receive data after time out (used if time out kicks in first, then API module sends data anyway).
633
601
  dataAfterTimeout: source.dataAfterTimeout !== false
634
602
  };
635
603
  return result;
@@ -669,35 +637,6 @@ function listAPIProviders() {
669
637
  return Object.keys(configStorage);
670
638
  }
671
639
 
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
640
  const detectFetch = () => {
702
641
  let callback;
703
642
  try {
@@ -707,7 +646,6 @@ const detectFetch = () => {
707
646
  }
708
647
  } catch (err) {
709
648
  }
710
- return null;
711
649
  };
712
650
  let fetchModule = detectFetch();
713
651
  function setFetch(fetch2) {
@@ -730,14 +668,9 @@ function calculateMaxLength(provider, prefix) {
730
668
  const host = item;
731
669
  maxHostLength = Math.max(maxHostLength, host.length);
732
670
  });
733
- const url = mergeParams(prefix + ".json", {
734
- icons: ""
735
- });
671
+ const url = prefix + ".json?icons=";
736
672
  result = config.maxURL - maxHostLength - config.path.length - url.length;
737
673
  }
738
- const cacheKey = provider + ":" + prefix;
739
- pathCache[provider] = config.path;
740
- maxLengthCache[cacheKey] = result;
741
674
  return result;
742
675
  }
743
676
  function shouldAbort(status) {
@@ -745,10 +678,7 @@ function shouldAbort(status) {
745
678
  }
746
679
  const prepare = (provider, prefix, icons) => {
747
680
  const results = [];
748
- let maxLength = maxLengthCache[prefix];
749
- if (maxLength === void 0) {
750
- maxLength = calculateMaxLength(provider, prefix);
751
- }
681
+ const maxLength = calculateMaxLength(provider, prefix);
752
682
  const type = "icons";
753
683
  let item = {
754
684
  type,
@@ -776,14 +706,10 @@ const prepare = (provider, prefix, icons) => {
776
706
  };
777
707
  function getPath(provider) {
778
708
  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;
709
+ const config = getAPIConfig(provider);
710
+ if (config) {
711
+ return config.path;
785
712
  }
786
- return pathCache[provider];
787
713
  }
788
714
  return "/";
789
715
  }
@@ -798,9 +724,10 @@ const send = (host, params, callback) => {
798
724
  const prefix = params.prefix;
799
725
  const icons = params.icons;
800
726
  const iconsList = icons.join(",");
801
- path += mergeParams(prefix + ".json", {
727
+ const urlParams = new URLSearchParams({
802
728
  icons: iconsList
803
729
  });
730
+ path += prefix + ".json?" + urlParams.toString();
804
731
  break;
805
732
  }
806
733
  case "custom": {
@@ -826,7 +753,11 @@ const send = (host, params, callback) => {
826
753
  }).then((data) => {
827
754
  if (typeof data !== "object" || data === null) {
828
755
  setTimeout(() => {
829
- callback("next", defaultError);
756
+ if (data === 404) {
757
+ callback("abort", data);
758
+ } else {
759
+ callback("next", defaultError);
760
+ }
830
761
  });
831
762
  return;
832
763
  }
@@ -871,18 +802,12 @@ function sortIcons(icons) {
871
802
  const provider = icon.provider;
872
803
  const prefix = icon.prefix;
873
804
  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];
805
+ const providerStorage = storage[provider] || (storage[provider] = /* @__PURE__ */ Object.create(null));
806
+ const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
882
807
  let list;
883
- if (localStorage.icons[name] !== void 0) {
808
+ if (name in localStorage.icons) {
884
809
  list = result.loaded;
885
- } else if (prefix === "" || localStorage.missing[name] !== void 0) {
810
+ } else if (prefix === "" || localStorage.missing.has(name)) {
886
811
  list = result.missing;
887
812
  } else {
888
813
  list = result.pending;
@@ -897,40 +822,26 @@ function sortIcons(icons) {
897
822
  return result;
898
823
  }
899
824
 
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];
825
+ function removeCallback(storages, id) {
826
+ storages.forEach((storage) => {
827
+ const items = storage.loaderCallbacks;
911
828
  if (items) {
912
- providerCallbacks[prefix] = items.filter((row) => row.id !== id);
829
+ storage.loaderCallbacks = items.filter((row) => row.id !== id);
913
830
  }
914
831
  });
915
832
  }
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;
833
+ function updateCallbacks(storage) {
834
+ if (!storage.pendingCallbacksFlag) {
835
+ storage.pendingCallbacksFlag = true;
923
836
  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);
837
+ storage.pendingCallbacksFlag = false;
838
+ const items = storage.loaderCallbacks ? storage.loaderCallbacks.slice(0) : [];
929
839
  if (!items.length) {
930
840
  return;
931
841
  }
932
- const storage = getStorage(provider, prefix);
933
842
  let hasPending = false;
843
+ const provider = storage.provider;
844
+ const prefix = storage.prefix;
934
845
  items.forEach((item) => {
935
846
  const icons = item.icons;
936
847
  const oldLength = icons.pending.length;
@@ -939,13 +850,13 @@ function updateCallbacks(provider, prefix) {
939
850
  return true;
940
851
  }
941
852
  const name = icon.name;
942
- if (storage.icons[name] !== void 0) {
853
+ if (storage.icons[name]) {
943
854
  icons.loaded.push({
944
855
  provider,
945
856
  prefix,
946
857
  name
947
858
  });
948
- } else if (storage.missing[name] !== void 0) {
859
+ } else if (storage.missing.has(name)) {
949
860
  icons.missing.push({
950
861
  provider,
951
862
  prefix,
@@ -959,14 +870,14 @@ function updateCallbacks(provider, prefix) {
959
870
  });
960
871
  if (icons.pending.length !== oldLength) {
961
872
  if (!hasPending) {
962
- removeCallback([
963
- {
964
- provider,
965
- prefix
966
- }
967
- ], item.id);
873
+ removeCallback([storage], item.id);
968
874
  }
969
- item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
875
+ item.callback(
876
+ icons.loaded.slice(0),
877
+ icons.missing.slice(0),
878
+ icons.pending.slice(0),
879
+ item.abort
880
+ );
970
881
  }
971
882
  });
972
883
  });
@@ -985,17 +896,8 @@ function storeCallback(callback, icons, pendingSources) {
985
896
  callback,
986
897
  abort
987
898
  };
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);
899
+ pendingSources.forEach((storage) => {
900
+ (storage.loaderCallbacks || (storage.loaderCallbacks = [])).push(item);
999
901
  });
1000
902
  return abort;
1001
903
  }
@@ -1003,13 +905,9 @@ function storeCallback(callback, icons, pendingSources) {
1003
905
  function listToIcons(list, validate = true, simpleNames = false) {
1004
906
  const result = [];
1005
907
  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
- });
908
+ const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames) : item;
909
+ if (icon) {
910
+ result.push(icon);
1013
911
  }
1014
912
  });
1015
913
  return result;
@@ -1183,42 +1081,34 @@ function sendQuery(config, payload, query, done) {
1183
1081
  }
1184
1082
 
1185
1083
  // 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
1084
  function initRedundancy(cfg) {
1202
- const config = setConfig(cfg);
1085
+ const config = {
1086
+ ...defaultConfig,
1087
+ ...cfg
1088
+ };
1203
1089
  let queries = [];
1204
1090
  function cleanup() {
1205
1091
  queries = queries.filter((item) => item().status === "pending");
1206
1092
  }
1207
1093
  function query(payload, queryCallback, doneCallback) {
1208
- const query2 = sendQuery(config, payload, queryCallback, (data, error) => {
1209
- cleanup();
1210
- if (doneCallback) {
1211
- doneCallback(data, error);
1094
+ const query2 = sendQuery(
1095
+ config,
1096
+ payload,
1097
+ queryCallback,
1098
+ (data, error) => {
1099
+ cleanup();
1100
+ if (doneCallback) {
1101
+ doneCallback(data, error);
1102
+ }
1212
1103
  }
1213
- });
1104
+ );
1214
1105
  queries.push(query2);
1215
1106
  return query2;
1216
1107
  }
1217
1108
  function find(callback) {
1218
- const result = queries.find((value) => {
1109
+ return queries.find((value) => {
1219
1110
  return callback(value);
1220
- });
1221
- return result !== void 0 ? result : null;
1111
+ }) || null;
1222
1112
  }
1223
1113
  const instance = {
1224
1114
  query,
@@ -1236,7 +1126,7 @@ function emptyCallback$1() {
1236
1126
  }
1237
1127
  const redundancyCache = /* @__PURE__ */ Object.create(null);
1238
1128
  function getRedundancyCache(provider) {
1239
- if (redundancyCache[provider] === void 0) {
1129
+ if (!redundancyCache[provider]) {
1240
1130
  const config = getAPIConfig(provider);
1241
1131
  if (!config) {
1242
1132
  return;
@@ -1282,95 +1172,122 @@ function sendAPIQuery(target, query, callback) {
1282
1172
  return redundancy.query(query, send, callback)().abort;
1283
1173
  }
1284
1174
 
1285
- const cache = {};
1286
-
1287
1175
  function emptyCallback() {
1288
1176
  }
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;
1177
+ function loadedNewIcons(storage) {
1178
+ if (!storage.iconsLoaderFlag) {
1179
+ storage.iconsLoaderFlag = true;
1300
1180
  setTimeout(() => {
1301
- providerLoaderFlags[prefix] = false;
1302
- updateCallbacks(provider, prefix);
1181
+ storage.iconsLoaderFlag = false;
1182
+ updateCallbacks(storage);
1303
1183
  });
1304
1184
  }
1305
1185
  }
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.');
1314
- }
1315
- }
1316
- if (iconsToLoad[provider] === void 0) {
1317
- iconsToLoad[provider] = /* @__PURE__ */ Object.create(null);
1186
+ function checkIconNamesForAPI(icons) {
1187
+ const valid = [];
1188
+ const invalid = [];
1189
+ icons.forEach((name) => {
1190
+ (name.match(matchIconName) ? valid : invalid).push(name);
1191
+ });
1192
+ return {
1193
+ valid,
1194
+ invalid
1195
+ };
1196
+ }
1197
+ function parseLoaderResponse(storage, icons, data) {
1198
+ function checkMissing() {
1199
+ const pending = storage.pendingIcons;
1200
+ icons.forEach((name) => {
1201
+ if (pending) {
1202
+ pending.delete(name);
1203
+ }
1204
+ if (!storage.icons[name]) {
1205
+ storage.missing.add(name);
1206
+ }
1207
+ });
1318
1208
  }
1319
- const providerIconsToLoad = iconsToLoad[provider];
1320
- if (queueFlags[provider] === void 0) {
1321
- queueFlags[provider] = /* @__PURE__ */ Object.create(null);
1209
+ if (data && typeof data === "object") {
1210
+ try {
1211
+ const parsed = addIconSet(storage, data);
1212
+ if (!parsed.length) {
1213
+ checkMissing();
1214
+ return;
1215
+ }
1216
+ } catch (err) {
1217
+ console.error(err);
1218
+ }
1322
1219
  }
1323
- const providerQueueFlags = queueFlags[provider];
1324
- if (pendingIcons[provider] === void 0) {
1325
- pendingIcons[provider] = /* @__PURE__ */ Object.create(null);
1220
+ checkMissing();
1221
+ loadedNewIcons(storage);
1222
+ }
1223
+ function parsePossiblyAsyncResponse(response, callback) {
1224
+ if (response instanceof Promise) {
1225
+ response.then((data) => {
1226
+ callback(data);
1227
+ }).catch(() => {
1228
+ callback(null);
1229
+ });
1230
+ } else {
1231
+ callback(response);
1326
1232
  }
1327
- const providerPendingIcons = pendingIcons[provider];
1328
- if (providerIconsToLoad[prefix] === void 0) {
1329
- providerIconsToLoad[prefix] = icons;
1233
+ }
1234
+ function loadNewIcons(storage, icons) {
1235
+ if (!storage.iconsToLoad) {
1236
+ storage.iconsToLoad = icons;
1330
1237
  } else {
1331
- providerIconsToLoad[prefix] = providerIconsToLoad[prefix].concat(icons).sort();
1238
+ storage.iconsToLoad = storage.iconsToLoad.concat(icons).sort();
1332
1239
  }
1333
- if (!providerQueueFlags[prefix]) {
1334
- providerQueueFlags[prefix] = true;
1240
+ if (!storage.iconsQueueFlag) {
1241
+ storage.iconsQueueFlag = true;
1335
1242
  setTimeout(() => {
1336
- providerQueueFlags[prefix] = false;
1337
- const icons2 = providerIconsToLoad[prefix];
1338
- delete providerIconsToLoad[prefix];
1339
- const api = getAPIModule(provider);
1243
+ storage.iconsQueueFlag = false;
1244
+ const { provider, prefix } = storage;
1245
+ const icons2 = storage.iconsToLoad;
1246
+ delete storage.iconsToLoad;
1247
+ if (!icons2 || !icons2.length) {
1248
+ return;
1249
+ }
1250
+ const customIconLoader = storage.loadIcon;
1251
+ if (storage.loadIcons && (icons2.length > 1 || !customIconLoader)) {
1252
+ parsePossiblyAsyncResponse(
1253
+ storage.loadIcons(icons2, prefix, provider),
1254
+ (data) => {
1255
+ parseLoaderResponse(storage, icons2, data);
1256
+ }
1257
+ );
1258
+ return;
1259
+ }
1260
+ if (customIconLoader) {
1261
+ icons2.forEach((name) => {
1262
+ const response = customIconLoader(name, prefix, provider);
1263
+ parsePossiblyAsyncResponse(response, (data) => {
1264
+ const iconSet = data ? {
1265
+ prefix,
1266
+ icons: {
1267
+ [name]: data
1268
+ }
1269
+ } : null;
1270
+ parseLoaderResponse(storage, [name], iconSet);
1271
+ });
1272
+ });
1273
+ return;
1274
+ }
1275
+ const { valid, invalid } = checkIconNamesForAPI(icons2);
1276
+ if (invalid.length) {
1277
+ parseLoaderResponse(storage, invalid, null);
1278
+ }
1279
+ if (!valid.length) {
1280
+ return;
1281
+ }
1282
+ const api = prefix.match(matchIconName) ? getAPIModule(provider) : null;
1340
1283
  if (!api) {
1341
- err();
1284
+ parseLoaderResponse(storage, valid, null);
1342
1285
  return;
1343
1286
  }
1344
- const params = api.prepare(provider, prefix, icons2);
1287
+ const params = api.prepare(provider, prefix, valid);
1345
1288
  params.forEach((item) => {
1346
- sendAPIQuery(provider, item, (data, error) => {
1347
- const storage = getStorage(provider, prefix);
1348
- if (typeof data !== "object") {
1349
- if (error !== 404) {
1350
- return;
1351
- }
1352
- const t = Date.now();
1353
- item.icons.forEach((name) => {
1354
- storage.missing[name] = t;
1355
- });
1356
- } else {
1357
- try {
1358
- const parsed = addIconSet(storage, data);
1359
- if (!parsed.length) {
1360
- return;
1361
- }
1362
- const pending = providerPendingIcons[prefix];
1363
- parsed.forEach((name) => {
1364
- delete pending[name];
1365
- });
1366
- if (cache.store) {
1367
- cache.store(provider, data);
1368
- }
1369
- } catch (err2) {
1370
- console.error(err2);
1371
- }
1372
- }
1373
- loadedNewIcons(provider, prefix);
1289
+ sendAPIQuery(provider, item, (data) => {
1290
+ parseLoaderResponse(storage, item.icons, data);
1374
1291
  });
1375
1292
  });
1376
1293
  });
@@ -1384,7 +1301,12 @@ const loadIcons = (icons, callback) => {
1384
1301
  if (callback) {
1385
1302
  setTimeout(() => {
1386
1303
  if (callCallback) {
1387
- callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);
1304
+ callback(
1305
+ sortedIcons.loaded,
1306
+ sortedIcons.missing,
1307
+ sortedIcons.pending,
1308
+ emptyCallback
1309
+ );
1388
1310
  }
1389
1311
  });
1390
1312
  }
@@ -1396,61 +1318,50 @@ const loadIcons = (icons, callback) => {
1396
1318
  const sources = [];
1397
1319
  let lastProvider, lastPrefix;
1398
1320
  sortedIcons.pending.forEach((icon) => {
1399
- const provider = icon.provider;
1400
- const prefix = icon.prefix;
1321
+ const { provider, prefix } = icon;
1401
1322
  if (prefix === lastPrefix && provider === lastProvider) {
1402
1323
  return;
1403
1324
  }
1404
1325
  lastProvider = provider;
1405
1326
  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) {
1327
+ sources.push(getStorage(provider, prefix));
1328
+ const providerNewIcons = newIcons[provider] || (newIcons[provider] = /* @__PURE__ */ Object.create(null));
1329
+ if (!providerNewIcons[prefix]) {
1422
1330
  providerNewIcons[prefix] = [];
1423
1331
  }
1424
1332
  });
1425
- const time = Date.now();
1426
1333
  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;
1334
+ const { provider, prefix, name } = icon;
1335
+ const storage = getStorage(provider, prefix);
1336
+ const pendingQueue = storage.pendingIcons || (storage.pendingIcons = /* @__PURE__ */ new Set());
1337
+ if (!pendingQueue.has(name)) {
1338
+ pendingQueue.add(name);
1433
1339
  newIcons[provider][prefix].push(name);
1434
1340
  }
1435
1341
  });
1436
- sources.forEach((source) => {
1437
- const provider = source.provider;
1438
- const prefix = source.prefix;
1439
- if (newIcons[provider][prefix].length) {
1440
- loadNewIcons(provider, prefix, newIcons[provider][prefix]);
1342
+ sources.forEach((storage) => {
1343
+ const list = newIcons[storage.provider][storage.prefix];
1344
+ if (list.length) {
1345
+ loadNewIcons(storage, list);
1441
1346
  }
1442
1347
  });
1443
1348
  return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
1444
1349
  };
1445
1350
  const loadIcon = (icon) => {
1446
1351
  return new Promise((fulfill, reject) => {
1447
- const iconObj = typeof icon === "string" ? stringToIcon(icon) : icon;
1352
+ const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
1353
+ if (!iconObj) {
1354
+ reject(icon);
1355
+ return;
1356
+ }
1448
1357
  loadIcons([iconObj || icon], (loaded) => {
1449
1358
  if (loaded.length && iconObj) {
1450
- const storage = getStorage(iconObj.provider, iconObj.prefix);
1451
- const data = getIconFromStorage(storage, iconObj.name);
1359
+ const data = getIconData(iconObj);
1452
1360
  if (data) {
1453
- fulfill(data);
1361
+ fulfill({
1362
+ ...defaultIconProps,
1363
+ ...data
1364
+ });
1454
1365
  return;
1455
1366
  }
1456
1367
  }
@@ -1459,188 +1370,29 @@ const loadIcon = (icon) => {
1459
1370
  });
1460
1371
  };
1461
1372
 
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);
1373
+ function setCustomIconsLoader(loader, prefix, provider) {
1374
+ getStorage(provider || "", prefix).loadIcons = loader;
1516
1375
  }
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
- }
1376
+ function setCustomIconLoader(loader, prefix, provider) {
1377
+ getStorage(provider || "", prefix).loadIcon = loader;
1525
1378
  }
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
1379
 
1632
- function toggleBrowserCache(storage, value) {
1633
- switch (storage) {
1634
- case "local":
1635
- case "session":
1636
- config[storage] = value;
1637
- break;
1638
- case "all":
1639
- for (const key in config) {
1640
- config[key] = value;
1380
+ function mergeCustomisations(defaults, item) {
1381
+ const result = {
1382
+ ...defaults
1383
+ };
1384
+ for (const key in item) {
1385
+ const value = item[key];
1386
+ const valueType = typeof value;
1387
+ if (key in defaultIconSizeCustomisations) {
1388
+ if (value === null || value && (valueType === "string" || valueType === "number")) {
1389
+ result[key] = value;
1641
1390
  }
1642
- break;
1391
+ } else if (valueType === typeof result[key]) {
1392
+ result[key] = key === "rotate" ? value % 4 : value;
1393
+ }
1643
1394
  }
1395
+ return result;
1644
1396
  }
1645
1397
 
1646
1398
  const separator = /[\s,]+/;
@@ -1657,29 +1409,6 @@ function flipFromString(custom, flip) {
1657
1409
  }
1658
1410
  });
1659
1411
  }
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
1412
 
1684
1413
  function rotateFromString(value, defaultValue = 0) {
1685
1414
  const units = value.replace(/^-?[0-9.]*/, "");
@@ -1713,6 +1442,29 @@ function rotateFromString(value, defaultValue = 0) {
1713
1442
  return defaultValue;
1714
1443
  }
1715
1444
 
1445
+ function iconToHTML(body, attributes) {
1446
+ let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : ' xmlns:xlink="http://www.w3.org/1999/xlink"';
1447
+ for (const attr in attributes) {
1448
+ renderAttribsHTML += " " + attr + '="' + attributes[attr] + '"';
1449
+ }
1450
+ return '<svg xmlns="http://www.w3.org/2000/svg"' + renderAttribsHTML + ">" + body + "</svg>";
1451
+ }
1452
+
1453
+ function encodeSVGforURL(svg) {
1454
+ return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
1455
+ }
1456
+ function svgToData(svg) {
1457
+ return "data:image/svg+xml," + encodeSVGforURL(svg);
1458
+ }
1459
+ function svgToURL(svg) {
1460
+ return 'url("' + svgToData(svg) + '")';
1461
+ }
1462
+
1463
+ const defaultExtendedIconCustomisations = {
1464
+ ...defaultIconCustomisations,
1465
+ inline: false,
1466
+ };
1467
+
1716
1468
  /**
1717
1469
  * Default SVG attributes
1718
1470
  */
@@ -1722,27 +1474,55 @@ const svgDefaults = {
1722
1474
  'aria-hidden': true,
1723
1475
  'role': 'img',
1724
1476
  };
1477
+ /**
1478
+ * Style modes
1479
+ */
1480
+ const commonProps = {
1481
+ display: 'inline-block',
1482
+ };
1483
+ const monotoneProps = {
1484
+ backgroundColor: 'currentColor',
1485
+ };
1486
+ const coloredProps = {
1487
+ backgroundColor: 'transparent',
1488
+ };
1489
+ // Dynamically add common props to variables above
1490
+ const propsToAdd = {
1491
+ Image: 'var(--svg)',
1492
+ Repeat: 'no-repeat',
1493
+ Size: '100% 100%',
1494
+ };
1495
+ const propsToAddTo = {
1496
+ webkitMask: monotoneProps,
1497
+ mask: monotoneProps,
1498
+ background: coloredProps,
1499
+ };
1500
+ for (const prefix in propsToAddTo) {
1501
+ const list = propsToAddTo[prefix];
1502
+ for (const prop in propsToAdd) {
1503
+ list[prefix + prop] = propsToAdd[prop];
1504
+ }
1505
+ }
1725
1506
  /**
1726
1507
  * Aliases for customisations.
1727
- * In Vue 'v-' properties are reserved, so v-align and v-flip must be renamed
1508
+ * In Vue 'v-' properties are reserved, so v-flip must be renamed
1728
1509
  */
1729
- let customisationAliases = {};
1510
+ const customisationAliases = {};
1730
1511
  ['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
- });
1512
+ const attr = prefix.slice(0, 1) + 'Flip';
1513
+ // vertical-flip
1514
+ customisationAliases[prefix + '-flip'] = attr;
1515
+ // v-flip
1516
+ customisationAliases[prefix.slice(0, 1) + '-flip'] = attr;
1517
+ // verticalFlip
1518
+ customisationAliases[prefix + 'Flip'] = attr;
1745
1519
  });
1520
+ /**
1521
+ * Fix size: add 'px' to numbers
1522
+ */
1523
+ function fixSize(value) {
1524
+ return value + (value.match(/^[-0-9.]+$/) ? 'px' : '');
1525
+ }
1746
1526
  /**
1747
1527
  * Render icon
1748
1528
  */
@@ -1752,11 +1532,15 @@ icon,
1752
1532
  // Partial properties
1753
1533
  props) => {
1754
1534
  // Split properties
1755
- const customisations = mergeCustomisations(defaults, props);
1535
+ const customisations = mergeCustomisations(defaultExtendedIconCustomisations, props);
1756
1536
  const componentProps = { ...svgDefaults };
1537
+ // Check mode
1538
+ const mode = props.mode || 'svg';
1757
1539
  // Copy style
1758
- let style = typeof props.style === 'object' && !(props.style instanceof Array)
1759
- ? { ...props.style }
1540
+ const style = {};
1541
+ const propsStyle = props.style;
1542
+ const customStyle = typeof propsStyle === 'object' && !(propsStyle instanceof Array)
1543
+ ? propsStyle
1760
1544
  : {};
1761
1545
  // Get element properties
1762
1546
  for (let key in props) {
@@ -1769,6 +1553,8 @@ props) => {
1769
1553
  case 'icon':
1770
1554
  case 'style':
1771
1555
  case 'onLoad':
1556
+ case 'mode':
1557
+ case 'ssr':
1772
1558
  break;
1773
1559
  // Boolean attributes
1774
1560
  case 'inline':
@@ -1783,12 +1569,6 @@ props) => {
1783
1569
  flipFromString(customisations, value);
1784
1570
  }
1785
1571
  break;
1786
- // Alignment as string
1787
- case 'align':
1788
- if (typeof value === 'string') {
1789
- alignmentFromString(customisations, value);
1790
- }
1791
- break;
1792
1572
  // Color: override style
1793
1573
  case 'color':
1794
1574
  style.color = value;
@@ -1810,65 +1590,86 @@ props) => {
1810
1590
  delete componentProps['aria-hidden'];
1811
1591
  }
1812
1592
  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;
1593
+ default: {
1594
+ const alias = customisationAliases[key];
1595
+ if (alias) {
1596
+ // Aliases for boolean customisations
1597
+ if (value === true || value === 'true' || value === 1) {
1598
+ customisations[alias] = true;
1826
1599
  }
1827
1600
  }
1828
- else if (defaults[key] === void 0) {
1601
+ else if (defaultExtendedIconCustomisations[key] === void 0) {
1829
1602
  // Copy missing property if it does not exist in customisations
1830
1603
  componentProps[key] = value;
1831
1604
  }
1605
+ }
1832
1606
  }
1833
1607
  }
1834
1608
  // Generate icon
1835
1609
  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) {
1610
+ const renderAttribs = item.attributes;
1611
+ // Inline display
1612
+ if (customisations.inline) {
1843
1613
  style.verticalAlign = '-0.125em';
1844
1614
  }
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);
1615
+ if (mode === 'svg') {
1616
+ // Add style
1617
+ componentProps.style = {
1618
+ ...style,
1619
+ ...customStyle,
1620
+ };
1621
+ // Add icon stuff
1622
+ Object.assign(componentProps, renderAttribs);
1623
+ // Counter for ids based on "id" property to render icons consistently on server and client
1624
+ let localCounter = 0;
1625
+ let id = props.id;
1626
+ if (typeof id === 'string') {
1627
+ // Convert '-' to '_' to avoid errors in animations
1628
+ id = id.replace(/-/g, '_');
1629
+ }
1630
+ // Add innerHTML and style to props
1631
+ componentProps['innerHTML'] = replaceIDs(item.body, id ? () => id + 'ID' + localCounter++ : 'iconifyVue');
1632
+ // Render icon
1633
+ return h('svg', componentProps);
1634
+ }
1635
+ // Render <span> with style
1636
+ const { body, width, height } = icon;
1637
+ const useMask = mode === 'mask' ||
1638
+ (mode === 'bg' ? false : body.indexOf('currentColor') !== -1);
1639
+ // Generate SVG
1640
+ const html = iconToHTML(body, {
1641
+ ...renderAttribs,
1642
+ width: width + '',
1643
+ height: height + '',
1644
+ });
1645
+ // Generate style
1646
+ componentProps.style = {
1647
+ ...style,
1648
+ '--svg': svgToURL(html),
1649
+ 'width': fixSize(renderAttribs.width),
1650
+ 'height': fixSize(renderAttribs.height),
1651
+ ...commonProps,
1652
+ ...(useMask ? monotoneProps : coloredProps),
1653
+ ...customStyle,
1654
+ };
1655
+ return h('span', componentProps);
1859
1656
  };
1860
1657
 
1861
1658
  /**
1862
1659
  * Enable cache
1660
+ *
1661
+ * @deprecated No longer used
1863
1662
  */
1864
1663
  function enableCache(storage) {
1865
- toggleBrowserCache(storage, true);
1664
+ //
1866
1665
  }
1867
1666
  /**
1868
1667
  * Disable cache
1668
+ *
1669
+ * @deprecated No longer used
1869
1670
  */
1870
1671
  function disableCache(storage) {
1871
- toggleBrowserCache(storage, false);
1672
+ //
1872
1673
  }
1873
1674
  /**
1874
1675
  * Initialise stuff
@@ -1881,9 +1682,6 @@ setAPIModule('', fetchAPIModule);
1881
1682
  * Browser stuff
1882
1683
  */
1883
1684
  if (typeof document !== 'undefined' && typeof window !== 'undefined') {
1884
- // Set cache and load existing cache
1885
- cache.store = storeCache;
1886
- loadCache();
1887
1685
  const _window = window;
1888
1686
  // Load icons from global "IconifyPreload"
1889
1687
  if (_window.IconifyPreload !== void 0) {
@@ -1938,15 +1736,20 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
1938
1736
  /**
1939
1737
  * Empty icon data, rendered when icon is not available
1940
1738
  */
1941
- const emptyIcon = fullIcon({
1739
+ const emptyIcon = {
1740
+ ...defaultIconProps,
1942
1741
  body: '',
1943
- });
1742
+ };
1944
1743
  const Icon = defineComponent({
1945
1744
  // Do not inherit other attributes: it is handled by render()
1946
1745
  inheritAttrs: false,
1947
1746
  // Set initial data
1948
1747
  data() {
1949
1748
  return {
1749
+ // Current icon name
1750
+ _name: '',
1751
+ // Loading
1752
+ _loadingIcon: null,
1950
1753
  // Mounted status
1951
1754
  iconMounted: false,
1952
1755
  // Callback counter to trigger re-render
@@ -1954,10 +1757,6 @@ const Icon = defineComponent({
1954
1757
  };
1955
1758
  },
1956
1759
  mounted() {
1957
- // Current icon name
1958
- this._name = '';
1959
- // Loading
1960
- this._loadingIcon = null;
1961
1760
  // Mark as mounted
1962
1761
  this.iconMounted = true;
1963
1762
  },
@@ -1972,7 +1771,7 @@ const Icon = defineComponent({
1972
1771
  }
1973
1772
  },
1974
1773
  // Get data for icon to render or null
1975
- getIcon(icon, onload) {
1774
+ getIcon(icon, onload, customise) {
1976
1775
  // Icon is an object
1977
1776
  if (typeof icon === 'object' &&
1978
1777
  icon !== null &&
@@ -1981,7 +1780,7 @@ const Icon = defineComponent({
1981
1780
  this._name = '';
1982
1781
  this.abortLoading();
1983
1782
  return {
1984
- data: fullIcon(icon),
1783
+ data: icon,
1985
1784
  };
1986
1785
  }
1987
1786
  // Invalid icon?
@@ -1992,19 +1791,22 @@ const Icon = defineComponent({
1992
1791
  return null;
1993
1792
  }
1994
1793
  // Load icon
1995
- const data = getIconData(iconName);
1996
- if (data === null) {
1997
- // Icon needs to be loaded
1794
+ let data = getIconData(iconName);
1795
+ if (!data) {
1796
+ // Icon data is not available
1998
1797
  if (!this._loadingIcon || this._loadingIcon.name !== icon) {
1999
1798
  // New icon to load
2000
1799
  this.abortLoading();
2001
1800
  this._name = '';
2002
- this._loadingIcon = {
2003
- name: icon,
2004
- abort: loadIcons([iconName], () => {
2005
- this.counter++;
2006
- }),
2007
- };
1801
+ if (data !== null) {
1802
+ // Icon was not loaded
1803
+ this._loadingIcon = {
1804
+ name: icon,
1805
+ abort: loadIcons([iconName], () => {
1806
+ this.counter++;
1807
+ }),
1808
+ };
1809
+ }
2008
1810
  }
2009
1811
  return null;
2010
1812
  }
@@ -2016,6 +1818,15 @@ const Icon = defineComponent({
2016
1818
  onload(icon);
2017
1819
  }
2018
1820
  }
1821
+ // Customise icon
1822
+ if (customise) {
1823
+ // Clone data and customise it
1824
+ data = Object.assign({}, data);
1825
+ const customised = customise(data.body, iconName.name, iconName.prefix, iconName.provider);
1826
+ if (typeof customised === 'string') {
1827
+ data.body = customised;
1828
+ }
1829
+ }
2019
1830
  // Add classes
2020
1831
  const classes = ['iconify'];
2021
1832
  if (iconName.prefix !== '') {
@@ -2033,8 +1844,8 @@ const Icon = defineComponent({
2033
1844
  this.counter;
2034
1845
  const props = this.$attrs;
2035
1846
  // Get icon data
2036
- const icon = this.iconMounted
2037
- ? this.getIcon(props.icon, props.onLoad)
1847
+ const icon = this.iconMounted || props.ssr
1848
+ ? this.getIcon(props.icon, props.onLoad, props.customise)
2038
1849
  : null;
2039
1850
  // Validate icon object
2040
1851
  if (!icon) {
@@ -2051,7 +1862,10 @@ const Icon = defineComponent({
2051
1862
  };
2052
1863
  }
2053
1864
  // Render icon
2054
- return render(icon.data, newProps);
1865
+ return render({
1866
+ ...defaultIconProps,
1867
+ ...icon.data,
1868
+ }, newProps);
2055
1869
  },
2056
1870
  });
2057
1871
  /**
@@ -2064,7 +1878,6 @@ const _api = {
2064
1878
  setFetch,
2065
1879
  getFetch,
2066
1880
  listAPIProviders,
2067
- mergeParams,
2068
1881
  };
2069
1882
 
2070
- export { Icon, _api, addAPIProvider, addCollection, addIcon, buildIcon, calculateSize, disableCache, enableCache, getIcon, iconExists, listIcons, loadIcon, loadIcons, replaceIDs, shareStorage };
1883
+ export { Icon, _api, addAPIProvider, addCollection, addIcon, iconToSVG as buildIcon, calculateSize, disableCache, enableCache, getIcon, iconLoaded as iconExists, iconLoaded, listIcons, loadIcon, loadIcons, replaceIDs, setCustomIconLoader, setCustomIconsLoader };