@cyberalien/svg-utils 1.1.0 → 1.1.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 (191) hide show
  1. package/lib/classname/{toggle.mjs → toggle.js} +1 -1
  2. package/lib/components/export/{exports.d.mts → exports.d.ts} +1 -1
  3. package/lib/components/export/{file.d.mts → file.d.ts} +3 -3
  4. package/lib/components/export/{file.mjs → file.js} +1 -1
  5. package/lib/components/export/{filename.d.mts → filename.d.ts} +2 -2
  6. package/lib/components/export/{fs.d.mts → fs.d.ts} +1 -1
  7. package/lib/components/export/{merge.d.mts → merge.d.ts} +1 -1
  8. package/lib/components/helpers/content/{ratio.d.mts → ratio.d.ts} +1 -1
  9. package/lib/components/helpers/content/{size.d.mts → size.d.ts} +2 -2
  10. package/lib/components/helpers/content/{size.mjs → size.js} +1 -1
  11. package/lib/components/helpers/content/{stringify.d.mts → stringify.d.ts} +2 -2
  12. package/lib/components/helpers/content/{stringify.mjs → stringify.js} +1 -1
  13. package/lib/components/helpers/css/{generate.d.mts → generate.d.ts} +4 -4
  14. package/lib/components/helpers/css/{generate.mjs → generate.js} +3 -3
  15. package/lib/components/helpers/css/{name.mjs → name.js} +1 -1
  16. package/lib/components/helpers/filenames/{asset.d.mts → asset.d.ts} +1 -1
  17. package/lib/components/helpers/filenames/{css.d.mts → css.d.ts} +1 -1
  18. package/lib/components/helpers/filenames/{css.mjs → css.js} +1 -1
  19. package/lib/components/helpers/filenames/{path.d.mts → path.d.ts} +1 -1
  20. package/lib/components/helpers/filenames/{types.d.mts → types.d.ts} +3 -3
  21. package/lib/components/helpers/filenames/{types.mjs → types.js} +3 -3
  22. package/lib/components/helpers/functions/{size.d.mts → size.d.ts} +3 -3
  23. package/lib/components/helpers/functions/{size.mjs → size.js} +1 -1
  24. package/lib/components/helpers/imports/{add.d.mts → add.d.ts} +1 -1
  25. package/lib/components/helpers/imports/{create.d.mts → create.d.ts} +1 -1
  26. package/lib/components/helpers/imports/{stringify.d.mts → stringify.d.ts} +1 -1
  27. package/lib/components/helpers/props/{object.d.mts → object.d.ts} +1 -1
  28. package/lib/components/helpers/props/{object.mjs → object.js} +1 -1
  29. package/lib/components/helpers/props/{stringify.d.mts → stringify.d.ts} +1 -1
  30. package/lib/components/helpers/props/{ts.d.mts → ts.d.ts} +1 -1
  31. package/lib/components/helpers/ts/jsx.d.ts +13 -0
  32. package/lib/components/helpers/ts/{jsx.mjs → jsx.js} +1 -1
  33. package/lib/components/helpers/ts/svelte.d.ts +9 -0
  34. package/lib/components/helpers/ts/{svelte.mjs → svelte.js} +1 -1
  35. package/lib/components/helpers/ts/vue.d.ts +9 -0
  36. package/lib/components/helpers/ts/{vue.mjs → vue.js} +1 -1
  37. package/lib/components/helpers/ts/wrapper.d.ts +9 -0
  38. package/lib/components/helpers/ts/{wrapper.mjs → wrapper.js} +2 -2
  39. package/lib/components/{jsx.d.mts → jsx.d.ts} +4 -4
  40. package/lib/components/{jsx.mjs → jsx.js} +13 -13
  41. package/lib/components/prepare/{iconify.d.mts → iconify.d.ts} +4 -4
  42. package/lib/components/prepare/{iconify.mjs → iconify.js} +3 -3
  43. package/lib/components/prepare/{options.d.mts → options.d.ts} +1 -1
  44. package/lib/components/prepare/{options.mjs → options.js} +2 -2
  45. package/lib/components/raw.d.ts +8 -0
  46. package/lib/components/{raw.mjs → raw.js} +8 -8
  47. package/lib/components/{svelte.d.mts → svelte.d.ts} +3 -3
  48. package/lib/components/{svelte.mjs → svelte.js} +13 -13
  49. package/lib/components/types/{data.d.mts → data.d.ts} +2 -2
  50. package/lib/components/types/{options.d.mts → options.d.ts} +2 -2
  51. package/lib/components/types/{source.d.mts → source.d.ts} +2 -2
  52. package/lib/components/vue-func.d.ts +8 -0
  53. package/lib/components/{vue-func.mjs → vue-func.js} +13 -13
  54. package/lib/components/{vue.d.mts → vue.d.ts} +3 -3
  55. package/lib/components/{vue.mjs → vue.js} +13 -13
  56. package/lib/css/{hash.d.mts → hash.d.ts} +1 -1
  57. package/lib/css/{hash.mjs → hash.js} +2 -2
  58. package/lib/css/{stringify.d.mts → stringify.d.ts} +1 -1
  59. package/lib/css/stylesheet.d.ts +16 -0
  60. package/lib/css/stylesheet.js +64 -0
  61. package/lib/css/types.d.ts +33 -0
  62. package/lib/helpers/hash/{context.d.mts → context.d.ts} +1 -1
  63. package/lib/helpers/hash/{unique.d.mts → unique.d.ts} +1 -1
  64. package/lib/helpers/hash/{unique.mjs → unique.js} +3 -3
  65. package/lib/helpers/misc/{compare.mjs → compare.js} +1 -1
  66. package/lib/helpers/misc/{keys.mjs → keys.js} +1 -1
  67. package/lib/helpers/misc/{promises.d.mts → promises.d.ts} +1 -1
  68. package/lib/helpers/misc/{promises.mjs → promises.js} +1 -1
  69. package/lib/iconify/icon/{nornalise.d.mts → nornalise.d.ts} +1 -1
  70. package/lib/iconify/icon/{nornalise.mjs → nornalise.js} +1 -1
  71. package/lib/iconify/icon/types.d.ts +6 -0
  72. package/lib/iconify/icon-set/{icon.mjs → icon.js} +1 -1
  73. package/lib/iconify/icon-set/{parse.d.mts → parse.d.ts} +1 -1
  74. package/lib/iconify/icon-set/{parse.mjs → parse.js} +1 -1
  75. package/lib/index.d.ts +30 -0
  76. package/lib/index.js +26 -0
  77. package/lib/svg/ids/{change.d.mts → change.d.ts} +2 -2
  78. package/lib/svg/ids/{change.mjs → change.js} +3 -3
  79. package/lib/svg/ids/{duplicate.d.mts → duplicate.d.ts} +2 -2
  80. package/lib/svg/ids/{duplicate.mjs → duplicate.js} +1 -1
  81. package/lib/svg/ids/{types.d.mts → types.d.ts} +2 -2
  82. package/lib/svg/ids/{unique.d.mts → unique.d.ts} +2 -2
  83. package/lib/svg/ids/{unique.mjs → unique.js} +2 -2
  84. package/lib/svg/ids/{unused.d.mts → unused.d.ts} +2 -2
  85. package/lib/svg/ids/{unused.mjs → unused.js} +1 -1
  86. package/lib/svg/viewbox/{minify.d.mts → minify.d.ts} +1 -1
  87. package/lib/svg/viewbox/{parse.d.mts → parse.d.ts} +1 -1
  88. package/lib/svg/viewbox/{square.d.mts → square.d.ts} +1 -1
  89. package/lib/svg/viewbox/{value.d.mts → value.d.ts} +1 -1
  90. package/lib/svg-css/{content.d.mts → content.d.ts} +1 -1
  91. package/lib/svg-css/{content.mjs → content.js} +3 -3
  92. package/lib/svg-css/props/{props.d.mts → props.d.ts} +2 -2
  93. package/lib/svg-css/props/{props.mjs → props.js} +3 -3
  94. package/lib/svg-css/props/{types.d.mts → types.d.ts} +1 -1
  95. package/lib/svg-css/{root.d.mts → root.d.ts} +3 -3
  96. package/lib/svg-css/{root.mjs → root.js} +4 -4
  97. package/lib/svg-css/{types.d.mts → types.d.ts} +2 -2
  98. package/lib/xml/{iterate.d.mts → iterate.d.ts} +1 -1
  99. package/lib/xml/{parse.d.mts → parse.d.ts} +1 -1
  100. package/lib/xml/{stringify.d.mts → stringify.d.ts} +1 -1
  101. package/package.json +7 -7
  102. package/lib/components/helpers/ts/jsx.d.mts +0 -13
  103. package/lib/components/helpers/ts/svelte.d.mts +0 -9
  104. package/lib/components/helpers/ts/vue.d.mts +0 -9
  105. package/lib/components/helpers/ts/wrapper.d.mts +0 -9
  106. package/lib/components/raw.d.mts +0 -8
  107. package/lib/components/vue-func.d.mts +0 -8
  108. package/lib/css/types.d.mts +0 -21
  109. package/lib/iconify/icon/types.d.mts +0 -6
  110. package/lib/index.d.mts +0 -28
  111. package/lib/index.mjs +0 -25
  112. /package/lib/classname/{const.d.mts → const.d.ts} +0 -0
  113. /package/lib/classname/{const.mjs → const.js} +0 -0
  114. /package/lib/classname/{toggle.d.mts → toggle.d.ts} +0 -0
  115. /package/lib/components/export/{exports.mjs → exports.js} +0 -0
  116. /package/lib/components/export/{filename.mjs → filename.js} +0 -0
  117. /package/lib/components/export/{fs.mjs → fs.js} +0 -0
  118. /package/lib/components/export/{merge.mjs → merge.js} +0 -0
  119. /package/lib/components/helpers/code/{lines.d.mts → lines.d.ts} +0 -0
  120. /package/lib/components/helpers/code/{lines.mjs → lines.js} +0 -0
  121. /package/lib/components/helpers/content/{ratio.mjs → ratio.js} +0 -0
  122. /package/lib/components/helpers/css/{name.d.mts → name.d.ts} +0 -0
  123. /package/lib/components/helpers/filenames/{asset.mjs → asset.js} +0 -0
  124. /package/lib/components/helpers/filenames/{path.mjs → path.js} +0 -0
  125. /package/lib/components/helpers/imports/{add.mjs → add.js} +0 -0
  126. /package/lib/components/helpers/imports/{create.mjs → create.js} +0 -0
  127. /package/lib/components/helpers/imports/{stringify.mjs → stringify.js} +0 -0
  128. /package/lib/components/helpers/imports/{types.d.mts → types.d.ts} +0 -0
  129. /package/lib/components/helpers/imports/{types.mjs → types.js} +0 -0
  130. /package/lib/components/helpers/props/{stringify.mjs → stringify.js} +0 -0
  131. /package/lib/components/helpers/props/{ts.mjs → ts.js} +0 -0
  132. /package/lib/components/helpers/props/{types.d.mts → types.d.ts} +0 -0
  133. /package/lib/components/helpers/props/{types.mjs → types.js} +0 -0
  134. /package/lib/components/types/{component.d.mts → component.d.ts} +0 -0
  135. /package/lib/components/types/{component.mjs → component.js} +0 -0
  136. /package/lib/components/types/{css.d.mts → css.d.ts} +0 -0
  137. /package/lib/components/types/{css.mjs → css.js} +0 -0
  138. /package/lib/components/types/{data.mjs → data.js} +0 -0
  139. /package/lib/components/types/{jsx.d.mts → jsx.d.ts} +0 -0
  140. /package/lib/components/types/{jsx.mjs → jsx.js} +0 -0
  141. /package/lib/components/types/{options.mjs → options.js} +0 -0
  142. /package/lib/components/types/{source.mjs → source.js} +0 -0
  143. /package/lib/css/{stringify.mjs → stringify.js} +0 -0
  144. /package/lib/css/{types.mjs → types.js} +0 -0
  145. /package/lib/helpers/hash/{context.mjs → context.js} +0 -0
  146. /package/lib/helpers/hash/{hash.d.mts → hash.d.ts} +0 -0
  147. /package/lib/helpers/hash/{hash.mjs → hash.js} +0 -0
  148. /package/lib/helpers/hash/{stringify.d.mts → stringify.d.ts} +0 -0
  149. /package/lib/helpers/hash/{stringify.mjs → stringify.js} +0 -0
  150. /package/lib/helpers/hash/{types.d.mts → types.d.ts} +0 -0
  151. /package/lib/helpers/hash/{types.mjs → types.js} +0 -0
  152. /package/lib/helpers/misc/{clone.d.mts → clone.d.ts} +0 -0
  153. /package/lib/helpers/misc/{clone.mjs → clone.js} +0 -0
  154. /package/lib/helpers/misc/{compare.d.mts → compare.d.ts} +0 -0
  155. /package/lib/helpers/misc/{keys.d.mts → keys.d.ts} +0 -0
  156. /package/lib/helpers/misc/{sort-object.d.mts → sort-object.d.ts} +0 -0
  157. /package/lib/helpers/misc/{sort-object.mjs → sort-object.js} +0 -0
  158. /package/lib/helpers/misc/{strings.d.mts → strings.d.ts} +0 -0
  159. /package/lib/helpers/misc/{strings.mjs → strings.js} +0 -0
  160. /package/lib/iconify/icon/{types.mjs → types.js} +0 -0
  161. /package/lib/iconify/icon-set/{defaults.d.mts → defaults.d.ts} +0 -0
  162. /package/lib/iconify/icon-set/{defaults.mjs → defaults.js} +0 -0
  163. /package/lib/iconify/icon-set/{icon.d.mts → icon.d.ts} +0 -0
  164. /package/lib/iconify/icon-set/{types.d.mts → types.d.ts} +0 -0
  165. /package/lib/iconify/icon-set/{types.mjs → types.js} +0 -0
  166. /package/lib/svg/content/{defs.d.mts → defs.d.ts} +0 -0
  167. /package/lib/svg/content/{defs.mjs → defs.js} +0 -0
  168. /package/lib/svg/ids/{string.d.mts → string.d.ts} +0 -0
  169. /package/lib/svg/ids/{string.mjs → string.js} +0 -0
  170. /package/lib/svg/ids/{types.mjs → types.js} +0 -0
  171. /package/lib/svg/props/{size.d.mts → size.d.ts} +0 -0
  172. /package/lib/svg/props/{size.mjs → size.js} +0 -0
  173. /package/lib/svg/props/{stringify.d.mts → stringify.d.ts} +0 -0
  174. /package/lib/svg/props/{stringify.mjs → stringify.js} +0 -0
  175. /package/lib/svg/viewbox/{minify.mjs → minify.js} +0 -0
  176. /package/lib/svg/viewbox/{parse.mjs → parse.js} +0 -0
  177. /package/lib/svg/viewbox/{square.mjs → square.js} +0 -0
  178. /package/lib/svg/viewbox/{types.d.mts → types.d.ts} +0 -0
  179. /package/lib/svg/viewbox/{types.mjs → types.js} +0 -0
  180. /package/lib/svg/viewbox/{value.mjs → value.js} +0 -0
  181. /package/lib/svg-css/props/{prop.d.mts → prop.d.ts} +0 -0
  182. /package/lib/svg-css/props/{prop.mjs → prop.js} +0 -0
  183. /package/lib/svg-css/props/{tags.d.mts → tags.d.ts} +0 -0
  184. /package/lib/svg-css/props/{tags.mjs → tags.js} +0 -0
  185. /package/lib/svg-css/props/{types.mjs → types.js} +0 -0
  186. /package/lib/svg-css/{types.mjs → types.js} +0 -0
  187. /package/lib/xml/{iterate.mjs → iterate.js} +0 -0
  188. /package/lib/xml/{parse.mjs → parse.js} +0 -0
  189. /package/lib/xml/{stringify.mjs → stringify.js} +0 -0
  190. /package/lib/xml/{types.d.mts → types.d.ts} +0 -0
  191. /package/lib/xml/{types.mjs → types.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { CSSHashOptions, CSSRules } from "./types.mjs";
1
+ import { CSSHashOptions, CSSRules } from "./types.js";
2
2
  /**
3
3
  * Get class name for CSS rules
4
4
  */
@@ -1,5 +1,5 @@
1
- import { sortObject } from "../helpers/misc/sort-object.mjs";
2
- import { getUniqueHash } from "../helpers/hash/unique.mjs";
1
+ import { sortObject } from "../helpers/misc/sort-object.js";
2
+ import { getUniqueHash } from "../helpers/hash/unique.js";
3
3
 
4
4
  /**
5
5
  * Get class name for CSS rules
@@ -1,4 +1,4 @@
1
- import { CSSKeyframes, CSSRules } from "./types.mjs";
1
+ import { CSSKeyframes, CSSRules } from "./types.js";
2
2
  /**
3
3
  * Stringify CSS rules
4
4
  */
@@ -0,0 +1,16 @@
1
+ import { CSSGeneratedStylesheet, CSSRules } from "./types.js";
2
+ /**
3
+ * Create empty stylesheet
4
+ */
5
+ declare function createEmptyStylesheet(): CSSGeneratedStylesheet;
6
+ /**
7
+ * Add generated selector to stylesheet
8
+ *
9
+ * If item exists, it will be overwritten. Class names should be hashed to avoid conflicts, so this should not cause issues.
10
+ */
11
+ declare function addGeneratedSelector(stylesheet: CSSGeneratedStylesheet, tree: string[], rules: CSSRules | string): void;
12
+ /**
13
+ * Stringify generated stylesheet to CSS string
14
+ */
15
+ declare function stringifyStylesheet(stylesheet: CSSGeneratedStylesheet): string;
16
+ export { addGeneratedSelector, createEmptyStylesheet, stringifyStylesheet };
@@ -0,0 +1,64 @@
1
+ import { stringifyCSSKeyframes, stringifyCSSSelector } from "./stringify.js";
2
+
3
+ /**
4
+ * Create empty stylesheet
5
+ */
6
+ function createEmptyStylesheet() {
7
+ return {
8
+ selectors: Object.create(null),
9
+ keyframes: Object.create(null)
10
+ };
11
+ }
12
+ /**
13
+ * Add generated selector to stylesheet
14
+ *
15
+ * If item exists, it will be overwritten. Class names should be hashed to avoid conflicts, so this should not cause issues.
16
+ */
17
+ function addGeneratedSelector(stylesheet, tree, rules) {
18
+ let parent = stylesheet.selectors;
19
+ for (let i = 0; i < tree.length; i++) {
20
+ const selector = tree[i];
21
+ if (!parent[selector]) parent[selector] = {};
22
+ const parentItem = parent[selector];
23
+ if (i === tree.length - 1) {
24
+ parentItem.rules = rules;
25
+ return;
26
+ }
27
+ if (!parentItem.nested) parentItem.nested = Object.create(null);
28
+ parent = parentItem.nested;
29
+ }
30
+ }
31
+ function indent(depth) {
32
+ return " ".repeat(depth);
33
+ }
34
+ /**
35
+ * Stringify generated selectors to CSS string
36
+ */
37
+ function stringifySelectors(data, depth = 0) {
38
+ const lines = [];
39
+ for (const selector in data) {
40
+ const item = data[selector];
41
+ if (item.rules) lines.push(stringifyCSSSelector(selector, item.rules, depth));
42
+ if (item.nested) {
43
+ const nestedContent = stringifySelectors(item.nested, depth + 1);
44
+ if (nestedContent.length) lines.push(`${indent(depth)}${selector} {\n${nestedContent}${indent(depth)}}\n`);
45
+ }
46
+ }
47
+ return lines.join("\n");
48
+ }
49
+ /**
50
+ * Stringify generated stylesheet to CSS string
51
+ */
52
+ function stringifyStylesheet(stylesheet) {
53
+ const lines = [];
54
+ const selectors = stringifySelectors(stylesheet.selectors);
55
+ if (selectors.length) lines.push(selectors);
56
+ for (const animationName in stylesheet.keyframes) {
57
+ const keyframes = stylesheet.keyframes[animationName];
58
+ const keyframesContent = stringifyCSSKeyframes(animationName, keyframes);
59
+ if (keyframesContent.length) lines.push(keyframesContent);
60
+ }
61
+ return lines.join("\n");
62
+ }
63
+
64
+ export { addGeneratedSelector, createEmptyStylesheet, stringifyStylesheet };
@@ -0,0 +1,33 @@
1
+ import { UniqueHashPartialOptions } from "../helpers/hash/types.js";
2
+ /**
3
+ * CSS rules
4
+ */
5
+ type CSSRules = Record<string, string>;
6
+ /**
7
+ * Animation keyframes
8
+ */
9
+ interface CSSKeyframe {
10
+ time: number;
11
+ value: string;
12
+ }
13
+ interface CSSKeyframes {
14
+ prop: string;
15
+ frames: CSSKeyframe[];
16
+ }
17
+ /**
18
+ * Hash options
19
+ */
20
+ type CSSHashOptions = UniqueHashPartialOptions;
21
+ /**
22
+ * Generated stylesheet
23
+ */
24
+ interface CSSGeneratedSelector {
25
+ rules?: CSSRules | string;
26
+ nested?: CSSGeneratedSelectors;
27
+ }
28
+ type CSSGeneratedSelectors = Record<string, CSSGeneratedSelector>;
29
+ interface CSSGeneratedStylesheet {
30
+ selectors: CSSGeneratedSelectors;
31
+ keyframes: Record<string, CSSKeyframes>;
32
+ }
33
+ export { CSSGeneratedSelector, CSSGeneratedSelectors, CSSGeneratedStylesheet, CSSHashOptions, CSSKeyframe, CSSKeyframes, CSSRules };
@@ -1,4 +1,4 @@
1
- import { HashContext } from "./types.mjs";
1
+ import { HashContext } from "./types.js";
2
2
  /**
3
3
  * Create new hash context, used to make sure all hashes within the same context are unique
4
4
  */
@@ -1,4 +1,4 @@
1
- import { UniqueHashOptions } from "./types.mjs";
1
+ import { UniqueHashOptions } from "./types.js";
2
2
  /**
3
3
  * Hash an object, make sure hash is unique
4
4
  *
@@ -1,6 +1,6 @@
1
- import { sortObject } from "../misc/sort-object.mjs";
2
- import { hashToString } from "./stringify.mjs";
3
- import { hashString } from "./hash.mjs";
1
+ import { sortObject } from "../misc/sort-object.js";
2
+ import { hashToString } from "./stringify.js";
3
+ import { hashString } from "./hash.js";
4
4
 
5
5
  /**
6
6
  * Hash an object, make sure hash is unique
@@ -1,4 +1,4 @@
1
- import { sortObject } from "./sort-object.mjs";
1
+ import { sortObject } from "./sort-object.js";
2
2
 
3
3
  /**
4
4
  * Compare sets, returns true if identical
@@ -1,4 +1,4 @@
1
- import { sortObject } from "./sort-object.mjs";
1
+ import { sortObject } from "./sort-object.js";
2
2
 
3
3
  /**
4
4
  * Compare keys, return true on match
@@ -1,4 +1,4 @@
1
- import { ComparisonKey } from "./keys.mjs";
1
+ import { ComparisonKey } from "./keys.js";
2
2
  /**
3
3
  * Make sure multiple instances of Promise or callback are not ran at the same time
4
4
  */
@@ -1,4 +1,4 @@
1
- import { compareKeys } from "./keys.mjs";
1
+ import { compareKeys } from "./keys.js";
2
2
 
3
3
  let cache = [];
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { ParsedIconifyIcon } from "./types.mjs";
1
+ import { ParsedIconifyIcon } from "./types.js";
2
2
  import { IconifyIcon } from "@iconify/types";
3
3
  /**
4
4
  * Normalise icon: apply transformations
@@ -1,4 +1,4 @@
1
- import { wrapSVGContent } from "../../svg/content/defs.mjs";
1
+ import { wrapSVGContent } from "../../svg/content/defs.js";
2
2
 
3
3
  /**
4
4
  * Normalise icon: apply transformations
@@ -0,0 +1,6 @@
1
+ import { IconViewBox } from "../../svg/viewbox/types.js";
2
+ interface ParsedIconifyIcon {
3
+ body: string;
4
+ viewBox: IconViewBox;
5
+ }
6
+ export { ParsedIconifyIcon };
@@ -1,4 +1,4 @@
1
- import { getIconifyIconSetDefaults } from "./defaults.mjs";
1
+ import { getIconifyIconSetDefaults } from "./defaults.js";
2
2
 
3
3
  /**
4
4
  * Get icon data from Iconify icon set
@@ -1,4 +1,4 @@
1
- import { ParseIconifyIconSetCallback } from "./types.mjs";
1
+ import { ParseIconifyIconSetCallback } from "./types.js";
2
2
  import { IconifyJSON } from "@iconify/types";
3
3
  /**
4
4
  * Parse Iconify icon set and call callback for each icon
@@ -1,4 +1,4 @@
1
- import { getIconifyIconSetDefaults } from "./defaults.mjs";
1
+ import { getIconifyIconSetDefaults } from "./defaults.js";
2
2
 
3
3
  /**
4
4
  * Parse Iconify icon set and call callback for each icon
package/lib/index.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { ClassProp, classProps, defaultClassProp } from "./classname/const.js";
2
+ import { splitClassName, toggleClassName } from "./classname/toggle.js";
3
+ import { HashContext, UniqueHashOptions, UniqueHashPartialOptions } from "./helpers/hash/types.js";
4
+ import { CSSGeneratedSelector, CSSGeneratedSelectors, CSSGeneratedStylesheet, CSSHashOptions, CSSKeyframe, CSSKeyframes, CSSRules } from "./css/types.js";
5
+ import { ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions } from "./xml/types.js";
6
+ import { BaseConvertSVGContentOptions, ConvertSVGContentOptions, ConvertedSVGContent } from "./svg-css/types.js";
7
+ import { createCSSClassName } from "./css/hash.js";
8
+ import { stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector } from "./css/stringify.js";
9
+ import { addGeneratedSelector, createEmptyStylesheet, stringifyStylesheet } from "./css/stylesheet.js";
10
+ import { createUniqueHashContext } from "./helpers/hash/context.js";
11
+ import { hashString } from "./helpers/hash/hash.js";
12
+ import { hashToString } from "./helpers/hash/stringify.js";
13
+ import { getUniqueHash } from "./helpers/hash/unique.js";
14
+ import { cloneObject } from "./helpers/misc/clone.js";
15
+ import { compareSets, compareValues } from "./helpers/misc/compare.js";
16
+ import { ComparisonKey, compareKeys } from "./helpers/misc/keys.js";
17
+ import { uniquePromise } from "./helpers/misc/promises.js";
18
+ import { sortObject } from "./helpers/misc/sort-object.js";
19
+ import { iterateXMLContent } from "./xml/iterate.js";
20
+ import { parseXMLContent } from "./xml/parse.js";
21
+ import { stringifyXMLContent } from "./xml/stringify.js";
22
+ import { ChangeIDResult, UniqueIDOptions } from "./svg/ids/types.js";
23
+ import { changeIDInString } from "./svg/ids/string.js";
24
+ import { removeDuplicateIDs } from "./svg/ids/duplicate.js";
25
+ import { removeUnusedIDs } from "./svg/ids/unused.js";
26
+ import { changeSVGIDs } from "./svg/ids/change.js";
27
+ import { createUniqueIDs } from "./svg/ids/unique.js";
28
+ import { convertSVGRootToCSS } from "./svg-css/root.js";
29
+ import { convertSVGContentToCSSRules } from "./svg-css/content.js";
30
+ export { BaseConvertSVGContentOptions, CSSGeneratedSelector, CSSGeneratedSelectors, CSSGeneratedStylesheet, CSSHashOptions, CSSKeyframe, CSSKeyframes, CSSRules, ChangeIDResult, ClassProp, ComparisonKey, ConvertSVGContentOptions, ConvertedSVGContent, HashContext, ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions, UniqueHashOptions, UniqueHashPartialOptions, UniqueIDOptions, addGeneratedSelector, changeIDInString, changeSVGIDs, classProps, cloneObject, compareKeys, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createEmptyStylesheet, createUniqueHashContext, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyStylesheet, stringifyXMLContent, toggleClassName, uniquePromise };
package/lib/index.js ADDED
@@ -0,0 +1,26 @@
1
+ import { cloneObject } from "./helpers/misc/clone.js";
2
+ import { sortObject } from "./helpers/misc/sort-object.js";
3
+ import { compareSets, compareValues } from "./helpers/misc/compare.js";
4
+ import { compareKeys } from "./helpers/misc/keys.js";
5
+ import { uniquePromise } from "./helpers/misc/promises.js";
6
+ import { createUniqueHashContext } from "./helpers/hash/context.js";
7
+ import { hashToString } from "./helpers/hash/stringify.js";
8
+ import { hashString } from "./helpers/hash/hash.js";
9
+ import { getUniqueHash } from "./helpers/hash/unique.js";
10
+ import { iterateXMLContent } from "./xml/iterate.js";
11
+ import { parseXMLContent } from "./xml/parse.js";
12
+ import { stringifyXMLContent } from "./xml/stringify.js";
13
+ import { createCSSClassName } from "./css/hash.js";
14
+ import { stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector } from "./css/stringify.js";
15
+ import { addGeneratedSelector, createEmptyStylesheet, stringifyStylesheet } from "./css/stylesheet.js";
16
+ import { classProps, defaultClassProp } from "./classname/const.js";
17
+ import { splitClassName, toggleClassName } from "./classname/toggle.js";
18
+ import { changeIDInString } from "./svg/ids/string.js";
19
+ import { removeDuplicateIDs } from "./svg/ids/duplicate.js";
20
+ import { removeUnusedIDs } from "./svg/ids/unused.js";
21
+ import { changeSVGIDs } from "./svg/ids/change.js";
22
+ import { createUniqueIDs } from "./svg/ids/unique.js";
23
+ import { convertSVGRootToCSS } from "./svg-css/root.js";
24
+ import { convertSVGContentToCSSRules } from "./svg-css/content.js";
25
+
26
+ export { addGeneratedSelector, changeIDInString, changeSVGIDs, classProps, cloneObject, compareKeys, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createEmptyStylesheet, createUniqueHashContext, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyStylesheet, stringifyXMLContent, toggleClassName, uniquePromise };
@@ -1,5 +1,5 @@
1
- import { ParsedXMLTagElement } from "../../xml/types.mjs";
2
- import { ChangeIDResult } from "./types.mjs";
1
+ import { ParsedXMLTagElement } from "../../xml/types.js";
2
+ import { ChangeIDResult } from "./types.js";
3
3
  type HashCallback = (id: string, content: string, tagName: string) => string;
4
4
  /**
5
5
  * Change IDs in SVG using a callback function
@@ -1,6 +1,6 @@
1
- import { iterateXMLContent } from "../../xml/iterate.mjs";
2
- import { stringifyXMLContent } from "../../xml/stringify.mjs";
3
- import { changeIDInString } from "./string.mjs";
1
+ import { iterateXMLContent } from "../../xml/iterate.js";
2
+ import { stringifyXMLContent } from "../../xml/stringify.js";
3
+ import { changeIDInString } from "./string.js";
4
4
 
5
5
  /**
6
6
  * Change IDs in SVG using a callback function
@@ -1,5 +1,5 @@
1
- import { ParsedXMLTagElement } from "../../xml/types.mjs";
2
- import { ChangeIDResult } from "./types.mjs";
1
+ import { ParsedXMLTagElement } from "../../xml/types.js";
2
+ import { ChangeIDResult } from "./types.js";
3
3
  /**
4
4
  * Remove duplicate IDs from SVG
5
5
  */
@@ -1,4 +1,4 @@
1
- import { iterateXMLContent } from "../../xml/iterate.mjs";
1
+ import { iterateXMLContent } from "../../xml/iterate.js";
2
2
 
3
3
  /**
4
4
  * Remove duplicate IDs from SVG
@@ -1,5 +1,5 @@
1
- import { UniqueHashPartialOptions } from "../../helpers/hash/types.mjs";
2
- import { ParsedXMLTagElement } from "../../xml/types.mjs";
1
+ import { UniqueHashPartialOptions } from "../../helpers/hash/types.js";
2
+ import { ParsedXMLTagElement } from "../../xml/types.js";
3
3
  interface ChangeIDResult {
4
4
  map: Record<string, ParsedXMLTagElement[]>;
5
5
  usage: Record<string, ParsedXMLTagElement[]>;
@@ -1,5 +1,5 @@
1
- import { ParsedXMLTagElement } from "../../xml/types.mjs";
2
- import { UniqueIDOptions } from "./types.mjs";
1
+ import { ParsedXMLTagElement } from "../../xml/types.js";
2
+ import { UniqueIDOptions } from "./types.js";
3
3
  /**
4
4
  * Create unique IDs for SVG elements
5
5
  */
@@ -1,5 +1,5 @@
1
- import { getUniqueHash } from "../../helpers/hash/unique.mjs";
2
- import { changeSVGIDs } from "./change.mjs";
1
+ import { getUniqueHash } from "../../helpers/hash/unique.js";
2
+ import { changeSVGIDs } from "./change.js";
3
3
 
4
4
  /**
5
5
  * Create unique IDs for SVG elements
@@ -1,5 +1,5 @@
1
- import { ParsedXMLTagElement } from "../../xml/types.mjs";
2
- import { ChangeIDResult } from "./types.mjs";
1
+ import { ParsedXMLTagElement } from "../../xml/types.js";
2
+ import { ChangeIDResult } from "./types.js";
3
3
  /**
4
4
  * Remove duplicate IDs from SVG
5
5
  */
@@ -1,4 +1,4 @@
1
- import { iterateXMLContent } from "../../xml/iterate.mjs";
1
+ import { iterateXMLContent } from "../../xml/iterate.js";
2
2
 
3
3
  /**
4
4
  * Remove duplicate IDs from SVG
@@ -1,4 +1,4 @@
1
- import { IconViewBox } from "./types.mjs";
1
+ import { IconViewBox } from "./types.js";
2
2
  /**
3
3
  * Minify viewBox by removing default values
4
4
  */
@@ -1,4 +1,4 @@
1
- import { IconViewBox } from "./types.mjs";
1
+ import { IconViewBox } from "./types.js";
2
2
  /**
3
3
  * Parse viewBox string to IconViewBox
4
4
  */
@@ -1,4 +1,4 @@
1
- import { IconViewBox } from "./types.mjs";
1
+ import { IconViewBox } from "./types.js";
2
2
  /**
3
3
  * Make viewBox square
4
4
  */
@@ -1,4 +1,4 @@
1
- import { IconViewBox } from "./types.mjs";
1
+ import { IconViewBox } from "./types.js";
2
2
  /**
3
3
  * Convert IconViewBox to string
4
4
  */
@@ -1,4 +1,4 @@
1
- import { ConvertSVGContentOptions, ConvertedSVGContent } from "./types.mjs";
1
+ import { ConvertSVGContentOptions, ConvertedSVGContent } from "./types.js";
2
2
  /**
3
3
  * Convert SVG content string to SVG+CSS
4
4
  */
@@ -1,6 +1,6 @@
1
- import { parseXMLContent } from "../xml/parse.mjs";
2
- import { stringifyXMLContent } from "../xml/stringify.mjs";
3
- import { convertSVGRootToCSS } from "./root.mjs";
1
+ import { parseXMLContent } from "../xml/parse.js";
2
+ import { stringifyXMLContent } from "../xml/stringify.js";
3
+ import { convertSVGRootToCSS } from "./root.js";
4
4
 
5
5
  /**
6
6
  * Convert SVG content string to SVG+CSS
@@ -1,5 +1,5 @@
1
- import { ParsedXMLTagElement } from "../../xml/types.mjs";
2
- import { SVGConvertedToCSSProperties } from "./types.mjs";
1
+ import { ParsedXMLTagElement } from "../../xml/types.js";
2
+ import { SVGConvertedToCSSProperties } from "./types.js";
3
3
  /**
4
4
  * Extract SVG tag properties that can be converted to CSS
5
5
  *
@@ -1,6 +1,6 @@
1
- import { iterateXMLContent } from "../../xml/iterate.mjs";
2
- import { convertSVGPropertyToCSS } from "./prop.mjs";
3
- import { svgAnimateTransformTag, svgAnimationTag, svgSetTag } from "./tags.mjs";
1
+ import { iterateXMLContent } from "../../xml/iterate.js";
2
+ import { convertSVGPropertyToCSS } from "./prop.js";
3
+ import { svgAnimateTransformTag, svgAnimationTag, svgSetTag } from "./tags.js";
4
4
 
5
5
  /**
6
6
  * Extract SVG tag properties that can be converted to CSS
@@ -1,4 +1,4 @@
1
- import { CSSRules } from "../../css/types.mjs";
1
+ import { CSSRules } from "../../css/types.js";
2
2
  /**
3
3
  * Result of converting SVG properties to CSS
4
4
  */
@@ -1,6 +1,6 @@
1
- import { CSSRules } from "../css/types.mjs";
2
- import { ParsedXMLTagElement } from "../xml/types.mjs";
3
- import { BaseConvertSVGContentOptions } from "./types.mjs";
1
+ import { CSSRules } from "../css/types.js";
2
+ import { ParsedXMLTagElement } from "../xml/types.js";
3
+ import { BaseConvertSVGContentOptions } from "./types.js";
4
4
  /**
5
5
  * Convert SVG tags tree to SVG+CSS
6
6
  *
@@ -1,7 +1,7 @@
1
- import { iterateXMLContent } from "../xml/iterate.mjs";
2
- import { createCSSClassName } from "../css/hash.mjs";
3
- import { toggleClassName } from "../classname/toggle.mjs";
4
- import { extractSVGTagPropertiesForCSS } from "./props/props.mjs";
1
+ import { iterateXMLContent } from "../xml/iterate.js";
2
+ import { createCSSClassName } from "../css/hash.js";
3
+ import { toggleClassName } from "../classname/toggle.js";
4
+ import { extractSVGTagPropertiesForCSS } from "./props/props.js";
5
5
 
6
6
  /**
7
7
  * Convert SVG tags tree to SVG+CSS
@@ -1,5 +1,5 @@
1
- import { CSSHashOptions, CSSKeyframes, CSSRules } from "../css/types.mjs";
2
- import { StringifyXMLOptions } from "../xml/types.mjs";
1
+ import { CSSHashOptions, CSSKeyframes, CSSRules } from "../css/types.js";
2
+ import { StringifyXMLOptions } from "../xml/types.js";
3
3
  /**
4
4
  * Options for converting SVG tags to SVG+CSS
5
5
  */
@@ -1,4 +1,4 @@
1
- import { ParsedXMLNode, ParsedXMLTagElement } from "./types.mjs";
1
+ import { ParsedXMLNode, ParsedXMLTagElement } from "./types.js";
2
2
  /**
3
3
  * Callback result
4
4
  *
@@ -1,4 +1,4 @@
1
- import { ParsedXMLTagElement } from "./types.mjs";
1
+ import { ParsedXMLTagElement } from "./types.js";
2
2
  /**
3
3
  * Parse SVG content
4
4
  *
@@ -1,4 +1,4 @@
1
- import { ParsedXMLNode, StringifyXMLOptions } from "./types.mjs";
1
+ import { ParsedXMLNode, StringifyXMLOptions } from "./types.js";
2
2
  /**
3
3
  * Convert parsed XML content to string
4
4
  */
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "Common functions for working with SVG used by various packages.",
5
5
  "author": "Vjacheslav Trushkin",
6
- "version": "1.1.0",
6
+ "version": "1.1.2",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/cyberalien/svg-utils/issues",
9
9
  "homepage": "https://cyberalien.dev/",
@@ -25,14 +25,14 @@
25
25
  "devDependencies": {
26
26
  "@eslint/eslintrc": "^3.3.3",
27
27
  "@eslint/js": "^9.39.2",
28
- "@iconify-json/ri": "^1.2.8",
28
+ "@iconify-json/ri": "^1.2.10",
29
29
  "@types/jest": "^30.0.0",
30
- "@types/node": "^25.1.0",
31
- "@typescript-eslint/eslint-plugin": "^8.54.0",
32
- "@typescript-eslint/parser": "^8.54.0",
30
+ "@types/node": "^25.2.3",
31
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
32
+ "@typescript-eslint/parser": "^8.55.0",
33
33
  "eslint": "^9.39.2",
34
- "globals": "^17.2.0",
35
- "tsdown": "^0.20.1",
34
+ "globals": "^17.3.0",
35
+ "tsdown": "^0.20.3",
36
36
  "typescript": "^5.9.3",
37
37
  "vitest": "^4.0.18"
38
38
  },
@@ -1,13 +0,0 @@
1
- import { GeneratedAssetFile } from "../../types/component.mjs";
2
- import { FactoryIconData } from "../../types/data.mjs";
3
- import { ComponentFactoryOptions } from "../../types/options.mjs";
4
- import { FactoryComponentProps } from "../props/types.mjs";
5
- import { JSXMode } from "../../types/jsx.mjs";
6
- interface Options extends ComponentFactoryOptions {
7
- jsx: JSXMode;
8
- }
9
- /**
10
- * Add JSX component types
11
- */
12
- declare function addJSXComponentTypes(data: FactoryIconData, options: Options, assets: GeneratedAssetFile[], props: FactoryComponentProps): string;
13
- export { addJSXComponentTypes };
@@ -1,9 +0,0 @@
1
- import { GeneratedAssetFile } from "../../types/component.mjs";
2
- import { FactoryIconData } from "../../types/data.mjs";
3
- import { ComponentFactoryOptions } from "../../types/options.mjs";
4
- import { FactoryComponentProps } from "../props/types.mjs";
5
- /**
6
- * Add Svelte component types
7
- */
8
- declare const addSvelteComponentTypes: (data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps) => string;
9
- export { addSvelteComponentTypes };
@@ -1,9 +0,0 @@
1
- import { GeneratedAssetFile } from "../../types/component.mjs";
2
- import { FactoryIconData } from "../../types/data.mjs";
3
- import { ComponentFactoryOptions } from "../../types/options.mjs";
4
- import { FactoryComponentProps } from "../props/types.mjs";
5
- /**
6
- * Add Vue component types
7
- */
8
- declare const addVueComponentTypes: (data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps) => string;
9
- export { addVueComponentTypes };
@@ -1,9 +0,0 @@
1
- import { GeneratedAssetFile } from "../../types/component.mjs";
2
- import { FactoryIconData } from "../../types/data.mjs";
3
- import { ComponentFactoryOptions } from "../../types/options.mjs";
4
- import { FactoryComponentProps } from "../props/types.mjs";
5
- /**
6
- * Add component types
7
- */
8
- declare function addComponentTypes(template: string, data: FactoryIconData, options: ComponentFactoryOptions, assets: GeneratedAssetFile[], props: FactoryComponentProps): string;
9
- export { addComponentTypes };
@@ -1,8 +0,0 @@
1
- import { FactoryGeneratedComponent } from "./types/component.mjs";
2
- import { FactoryIconData } from "./types/data.mjs";
3
- import { ComponentFactoryOptions } from "./types/options.mjs";
4
- /**
5
- * Create raw component code
6
- */
7
- declare function createRawComponent(data: FactoryIconData, options: ComponentFactoryOptions): FactoryGeneratedComponent;
8
- export { createRawComponent };
@@ -1,8 +0,0 @@
1
- import { FactoryGeneratedComponent } from "./types/component.mjs";
2
- import { FactoryIconData } from "./types/data.mjs";
3
- import { ComponentFactoryOptions } from "./types/options.mjs";
4
- /**
5
- * Create functional Vue component code
6
- */
7
- declare function createVueFunctionalComponent(data: FactoryIconData, options: ComponentFactoryOptions): FactoryGeneratedComponent;
8
- export { createVueFunctionalComponent };