vite-awesome-svg-loader 3.0.3 → 4.1.0

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 (53) hide show
  1. package/README.md +12 -7
  2. package/chunk.cjs +34 -0
  3. package/dist.cjs +120 -0
  4. package/dist.js +82 -0
  5. package/integration-utils.cjs +8 -0
  6. package/integration-utils.d.cts +19 -0
  7. package/integration-utils.d.ts +19 -0
  8. package/integration-utils.js +3 -0
  9. package/loader.cjs +353 -0
  10. package/loader.d.cts +450 -0
  11. package/loader.d.ts +450 -0
  12. package/loader.js +349 -0
  13. package/package.json +73 -38
  14. package/react-integration.cjs +61 -0
  15. package/react-integration.d.cts +23 -0
  16. package/react-integration.d.ts +23 -0
  17. package/react-integration.js +59 -0
  18. package/{integration-utils/index.d.ts → svg-symbols.d.cts} +18 -15
  19. package/svg-symbols.d.ts +41 -0
  20. package/types.d.cts +58 -0
  21. package/types.d.ts +58 -0
  22. package/vanilla-integration.cjs +231 -0
  23. package/vanilla-integration.d.cts +259 -0
  24. package/vanilla-integration.d.ts +259 -0
  25. package/vanilla-integration.js +227 -0
  26. package/vue-integration.cjs +60 -0
  27. package/vue-integration.d.cts +10 -0
  28. package/vue-integration.d.ts +10 -0
  29. package/vue-integration.js +58 -0
  30. package/index.d.mts +0 -402
  31. package/index.d.ts +0 -402
  32. package/index.js +0 -576
  33. package/index.mjs +0 -542
  34. package/integration-utils/index.js +0 -1
  35. package/integration-utils/index.js.map +0 -1
  36. package/integration-utils/index.mjs +0 -1
  37. package/integration-utils/index.mjs.map +0 -1
  38. package/react-integration/index.cjs +0 -3
  39. package/react-integration/index.cjs.map +0 -1
  40. package/react-integration/index.d.ts +0 -72
  41. package/react-integration/index.js +0 -182
  42. package/react-integration/index.js.map +0 -1
  43. package/vanilla-integration/index.cjs +0 -3
  44. package/vanilla-integration/index.cjs.map +0 -1
  45. package/vanilla-integration/index.d.ts +0 -268
  46. package/vanilla-integration/index.js +0 -379
  47. package/vanilla-integration/index.js.map +0 -1
  48. package/vue-integration/index.cjs +0 -3
  49. package/vue-integration/index.cjs.map +0 -1
  50. package/vue-integration/index.d.ts +0 -67
  51. package/vue-integration/index.js +0 -194
  52. package/vue-integration/index.js.map +0 -1
  53. /package/{integration-utils/styles.css → integration-utils-styles.css} +0 -0
package/README.md CHANGED
@@ -8,16 +8,21 @@ A Vite plugin that:
8
8
  1. Source code [data URI](https://en.wikipedia.org/wiki/Data_URI_scheme).
9
9
  1. Source code base64.
10
10
  1. Source code base64 [data URI](https://en.wikipedia.org/wiki/Data_URI_scheme).
11
- 1. Can preserve line width, i.e. make icons and line art have same line width when scaling.
11
+ 1. Can preserve line width, i.e. make images retain line width regardless of the image size.
12
12
  1. Can replace colors with `currentColor` or a custom color via configuration (see `replaceColorsList` option).
13
13
  1. Will automatically minimize your SVGs using [SVGO](https://github.com/svg/svgo).
14
14
  1. Allows you to create SVG sprites using provided integrations.
15
15
 
16
- `vite-awesome-svg-loader` is framework-agnostic. All integrations are done as subpath imports
17
- (for example, `vite-awesome-svg-loader/vue-integration`). This means that you'll get only what you need in your
18
- app bundle. This also means that you can
19
- [develop your own integration](https://matafokka.github.io/vite-awesome-svg-loader/guides/custom-integrations)
20
- using `vite-awesome-svg-loader/integration-utils` import.
16
+ `vite-awesome-svg-loader` is framework-agnostic.
17
+
18
+ However, to create SVG symbols, some boilerplate code in form of components is required. These components are provided
19
+ in the integrations.
20
+
21
+ All integrations are provided as ES modules in separate subpath imports
22
+ (for example, `vite-awesome-svg-loader/vue-integration`), so your app will contain only required code.
23
+
24
+ You can integrate `vite-awesome-svg-loader` with [any framework](https://matafokka.github.io/vite-awesome-svg-loader/other-frameworks/quick-start)
25
+ using `vite-awesome-svg-loader/integration-utils` package.
21
26
 
22
27
  ## Installation
23
28
 
@@ -40,4 +45,4 @@ npm i vite-awesome-svg-loader
40
45
  - [React](https://matafokka.github.io/vite-awesome-svg-loader/react/quick-start/)
41
46
  - [Vue](https://matafokka.github.io/vite-awesome-svg-loader/vue/quick-start/)
42
47
  - [Vanilla JS](https://matafokka.github.io/vite-awesome-svg-loader/vanilla-js/quick-start/)
43
- - [Custom framework](https://matafokka.github.io/vite-awesome-svg-loader/guides/custom-integrations/)
48
+ - [Other frameworks](https://matafokka.github.io/vite-awesome-svg-loader/other-frameworks/quick-start/)
package/chunk.cjs ADDED
@@ -0,0 +1,34 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ Object.defineProperty(exports, '__toESM', {
30
+ enumerable: true,
31
+ get: function () {
32
+ return __toESM;
33
+ }
34
+ });
package/dist.cjs ADDED
@@ -0,0 +1,120 @@
1
+ const require_chunk = require('./chunk.cjs');
2
+ let debounce = require("debounce");
3
+ debounce = require_chunk.__toESM(debounce);
4
+ let imurmurhash = require("imurmurhash");
5
+ imurmurhash = require_chunk.__toESM(imurmurhash);
6
+
7
+ //#region ../integration-utils/dist/index.mjs
8
+ const g = "svg-symbols", m = "svg-", d = "data-count";
9
+ function b(t, e) {
10
+ if (typeof window > "u" || t === e) return {};
11
+ let n = document.getElementById(g);
12
+ if (n || (n = document.createElementNS("http://www.w3.org/2000/svg", "svg"), n.id = g, n.setAttribute("aria-hidden", "true"), n.setAttribute("style", "position:fixed;top:-99999px;left:-99999px;z-index:0;opacity:0;"), document.body.appendChild(n)), t) {
13
+ const s = m + new imurmurhash.default(t).result();
14
+ w(document.getElementById(s));
15
+ }
16
+ const i = m + new imurmurhash.default(e).result(), u = document.getElementById(i);
17
+ if (u) return u.setAttribute(d, l(u) + 1 + ""), {
18
+ id: i,
19
+ attrs: h(u)
20
+ };
21
+ const o = new DOMParser().parseFromString(e, "application/xml").firstElementChild;
22
+ if (o?.querySelector("parsererror")) return console.error("Provided source code is not a valid SVG: " + e), { id: i };
23
+ if (!o) return console.error("Missing child in SVG: " + e), { id: i };
24
+ const r = document.createElementNS("http://www.w3.org/2000/svg", "symbol");
25
+ for (let s = 0; s < o.attributes.length; s++) {
26
+ const a = o.attributes[s];
27
+ r.setAttribute(a.name, a.value);
28
+ }
29
+ for (r.id = i, r.setAttribute(d, "1"); o.children.length;) r.appendChild(o.children[0]);
30
+ return n.appendChild(r), {
31
+ id: i,
32
+ attrs: h(r)
33
+ };
34
+ }
35
+ function x(t) {
36
+ !t || typeof window > "u" || w(typeof t == "string" ? document.getElementById(t) : t);
37
+ }
38
+ function w(t) {
39
+ if (!t) return;
40
+ const e = l(t, 1) - 1;
41
+ t.setAttribute(d, e + ""), e <= 0 && (c.push(t), v());
42
+ }
43
+ const c = [], v = (0, debounce.default)(() => {
44
+ for (let t = c.length - 1; t >= 0; t--) {
45
+ const e = c[t];
46
+ e.parentElement && l(e) <= 0 && e.parentElement.removeChild(e), c.pop();
47
+ }
48
+ }, 5e3);
49
+ function l(t, e = 0) {
50
+ if (!t) return e;
51
+ const n = parseInt(t.getAttribute(d) || "1");
52
+ return isNaN(n) ? e : n;
53
+ }
54
+ function h(t) {
55
+ let e = t.getAttribute("viewBox") || "";
56
+ if (!e) for (const n of [
57
+ "x",
58
+ "y",
59
+ "width",
60
+ "height"
61
+ ]) {
62
+ const i = t.getAttribute(n);
63
+ e += (i || "0") + " ";
64
+ }
65
+ return {
66
+ viewBox: e,
67
+ width: "100%",
68
+ height: "100%"
69
+ };
70
+ }
71
+ function A(t) {
72
+ const e = {};
73
+ if (t.size && t.size !== "unset") for (const n of [
74
+ "width",
75
+ "minWidth",
76
+ "maxWidth",
77
+ "height",
78
+ "minHeight",
79
+ "maxHeight"
80
+ ]) e[n] = t.size;
81
+ return t.color && (e["--icon-color"] = t.color), e["--icon-transition"] = t.colorTransition || "0.3s linear", e;
82
+ }
83
+
84
+ //#endregion
85
+ Object.defineProperty(exports, 'A', {
86
+ enumerable: true,
87
+ get: function () {
88
+ return A;
89
+ }
90
+ });
91
+ Object.defineProperty(exports, 'b', {
92
+ enumerable: true,
93
+ get: function () {
94
+ return b;
95
+ }
96
+ });
97
+ Object.defineProperty(exports, 'd', {
98
+ enumerable: true,
99
+ get: function () {
100
+ return d;
101
+ }
102
+ });
103
+ Object.defineProperty(exports, 'g', {
104
+ enumerable: true,
105
+ get: function () {
106
+ return g;
107
+ }
108
+ });
109
+ Object.defineProperty(exports, 'm', {
110
+ enumerable: true,
111
+ get: function () {
112
+ return m;
113
+ }
114
+ });
115
+ Object.defineProperty(exports, 'x', {
116
+ enumerable: true,
117
+ get: function () {
118
+ return x;
119
+ }
120
+ });
package/dist.js ADDED
@@ -0,0 +1,82 @@
1
+ import p from "debounce";
2
+ import f from "imurmurhash";
3
+
4
+ //#region ../integration-utils/dist/index.mjs
5
+ const g = "svg-symbols", m = "svg-", d = "data-count";
6
+ function b(t, e) {
7
+ if (typeof window > "u" || t === e) return {};
8
+ let n = document.getElementById(g);
9
+ if (n || (n = document.createElementNS("http://www.w3.org/2000/svg", "svg"), n.id = g, n.setAttribute("aria-hidden", "true"), n.setAttribute("style", "position:fixed;top:-99999px;left:-99999px;z-index:0;opacity:0;"), document.body.appendChild(n)), t) {
10
+ const s = m + new f(t).result();
11
+ w(document.getElementById(s));
12
+ }
13
+ const i = m + new f(e).result(), u = document.getElementById(i);
14
+ if (u) return u.setAttribute(d, l(u) + 1 + ""), {
15
+ id: i,
16
+ attrs: h(u)
17
+ };
18
+ const o = new DOMParser().parseFromString(e, "application/xml").firstElementChild;
19
+ if (o?.querySelector("parsererror")) return console.error("Provided source code is not a valid SVG: " + e), { id: i };
20
+ if (!o) return console.error("Missing child in SVG: " + e), { id: i };
21
+ const r = document.createElementNS("http://www.w3.org/2000/svg", "symbol");
22
+ for (let s = 0; s < o.attributes.length; s++) {
23
+ const a = o.attributes[s];
24
+ r.setAttribute(a.name, a.value);
25
+ }
26
+ for (r.id = i, r.setAttribute(d, "1"); o.children.length;) r.appendChild(o.children[0]);
27
+ return n.appendChild(r), {
28
+ id: i,
29
+ attrs: h(r)
30
+ };
31
+ }
32
+ function x(t) {
33
+ !t || typeof window > "u" || w(typeof t == "string" ? document.getElementById(t) : t);
34
+ }
35
+ function w(t) {
36
+ if (!t) return;
37
+ const e = l(t, 1) - 1;
38
+ t.setAttribute(d, e + ""), e <= 0 && (c.push(t), v());
39
+ }
40
+ const c = [], v = p(() => {
41
+ for (let t = c.length - 1; t >= 0; t--) {
42
+ const e = c[t];
43
+ e.parentElement && l(e) <= 0 && e.parentElement.removeChild(e), c.pop();
44
+ }
45
+ }, 5e3);
46
+ function l(t, e = 0) {
47
+ if (!t) return e;
48
+ const n = parseInt(t.getAttribute(d) || "1");
49
+ return isNaN(n) ? e : n;
50
+ }
51
+ function h(t) {
52
+ let e = t.getAttribute("viewBox") || "";
53
+ if (!e) for (const n of [
54
+ "x",
55
+ "y",
56
+ "width",
57
+ "height"
58
+ ]) {
59
+ const i = t.getAttribute(n);
60
+ e += (i || "0") + " ";
61
+ }
62
+ return {
63
+ viewBox: e,
64
+ width: "100%",
65
+ height: "100%"
66
+ };
67
+ }
68
+ function A(t) {
69
+ const e = {};
70
+ if (t.size && t.size !== "unset") for (const n of [
71
+ "width",
72
+ "minWidth",
73
+ "maxWidth",
74
+ "height",
75
+ "minHeight",
76
+ "maxHeight"
77
+ ]) e[n] = t.size;
78
+ return t.color && (e["--icon-color"] = t.color), e["--icon-transition"] = t.colorTransition || "0.3s linear", e;
79
+ }
80
+
81
+ //#endregion
82
+ export { A, b, d, g, m, x };
@@ -0,0 +1,8 @@
1
+ const require_dist = require('./dist.cjs');
2
+
3
+ exports.SVG_ID = require_dist.g;
4
+ exports.SYMBOL_ID_PREFIX = require_dist.m;
5
+ exports.USAGES_COUNT_ATTR = require_dist.d;
6
+ exports.getSvgIconStyle = require_dist.A;
7
+ exports.onSrcUpdate = require_dist.b;
8
+ exports.onUnmount = require_dist.x;
@@ -0,0 +1,19 @@
1
+ import { SvgIconProps, SvgIconStyleProps, SvgImageProps } from "./types.cjs";
2
+ import { SVG_ID, SYMBOL_ID_PREFIX, USAGES_COUNT_ATTR, onSrcUpdate, onUnmount } from "./svg-symbols.cjs";
3
+
4
+ //#region ../integration-utils/dist/svg-icon.d.ts
5
+
6
+ /**
7
+ * Converts `SvgIcon` props into a key-value pairs that should be passed to the element's `style` attribute.
8
+ *
9
+ * Keys format:
10
+ *
11
+ * 1. CSS variables are in snake case: `--var-name`.
12
+ * 1. CSS properties are in camel case: `minWidth`.
13
+ *
14
+ * @param props `SvgIcon` props
15
+ * @returns Style map
16
+ */
17
+ declare function getSvgIconStyle(props: SvgIconStyleProps): Record<string, string>;
18
+ //#endregion
19
+ export { SVG_ID, SYMBOL_ID_PREFIX, SvgIconProps, SvgIconStyleProps, SvgImageProps, USAGES_COUNT_ATTR, getSvgIconStyle, onSrcUpdate, onUnmount };
@@ -0,0 +1,19 @@
1
+ import { SvgIconProps, SvgIconStyleProps, SvgImageProps } from "./types.js";
2
+ import { SVG_ID, SYMBOL_ID_PREFIX, USAGES_COUNT_ATTR, onSrcUpdate, onUnmount } from "./svg-symbols.js";
3
+
4
+ //#region ../integration-utils/dist/svg-icon.d.ts
5
+
6
+ /**
7
+ * Converts `SvgIcon` props into a key-value pairs that should be passed to the element's `style` attribute.
8
+ *
9
+ * Keys format:
10
+ *
11
+ * 1. CSS variables are in snake case: `--var-name`.
12
+ * 1. CSS properties are in camel case: `minWidth`.
13
+ *
14
+ * @param props `SvgIcon` props
15
+ * @returns Style map
16
+ */
17
+ declare function getSvgIconStyle(props: SvgIconStyleProps): Record<string, string>;
18
+ //#endregion
19
+ export { SVG_ID, SYMBOL_ID_PREFIX, SvgIconProps, SvgIconStyleProps, SvgImageProps, USAGES_COUNT_ATTR, getSvgIconStyle, onSrcUpdate, onUnmount };
@@ -0,0 +1,3 @@
1
+ import { A, b, d, g, m, x } from "./dist.js";
2
+
3
+ export { g as SVG_ID, m as SYMBOL_ID_PREFIX, d as USAGES_COUNT_ATTR, A as getSvgIconStyle, b as onSrcUpdate, x as onUnmount };
package/loader.cjs ADDED
@@ -0,0 +1,353 @@
1
+ const require_chunk = require('./chunk.cjs');
2
+ let imurmurhash = require("imurmurhash");
3
+ imurmurhash = require_chunk.__toESM(imurmurhash);
4
+ let node_fs_promises = require("node:fs/promises");
5
+ let path = require("path");
6
+ path = require_chunk.__toESM(path);
7
+ let svgo = require("svgo");
8
+ let svgo_lib_xast_js = require("svgo/lib/xast.js");
9
+ let css_tree = require("css-tree");
10
+ css_tree = require_chunk.__toESM(css_tree);
11
+
12
+ //#region ../utils/dist/index.mjs
13
+ function a(t) {
14
+ return Array.isArray(t) ? t : [t];
15
+ }
16
+
17
+ //#endregion
18
+ //#region ../loader/dist/index.mjs
19
+ function X(e) {
20
+ return e = e.replaceAll("\\", "/"), e.endsWith("/") && (e = e.substring(0, e.length - 1)), e;
21
+ }
22
+ function Z(e) {
23
+ const o = String.fromCodePoint(...new TextEncoder().encode(e));
24
+ return btoa(o);
25
+ }
26
+ function ee(e) {
27
+ return e.replaceAll("`", "\\`");
28
+ }
29
+ function ge(e) {
30
+ return se(e.queryValue) || j(e);
31
+ }
32
+ function se(e) {
33
+ return !!e && e.toLowerCase() !== "false";
34
+ }
35
+ function j(e) {
36
+ const r = [path.default.basename(e.relativePath), e.relativePath], i = a(e.matchers);
37
+ return i.length ? i.some((n) => {
38
+ switch (typeof n) {
39
+ case "string": return r.some((l) => l === n);
40
+ case "function": return n({
41
+ fullPath: e.fullPath,
42
+ relativePath: e.relativePath
43
+ });
44
+ }
45
+ return r.some((l) => n.test(l));
46
+ }) : !1;
47
+ }
48
+ function te(e) {
49
+ return e.replaceAll(/\s+/g, " ").trim();
50
+ }
51
+ function ve(e) {
52
+ const o = a(e.selectors), r = [];
53
+ for (const i of o) {
54
+ if (typeof i == "string") {
55
+ r.push(te(i));
56
+ continue;
57
+ }
58
+ if (j({
59
+ ...e,
60
+ matchers: i.files
61
+ })) for (const n of i.selectors) r.push(te(n));
62
+ }
63
+ return r;
64
+ }
65
+ const oe = svgo_lib_xast_js.matches;
66
+ function $(e, o) {
67
+ for (const r of o) if (oe(e, r)) return !0;
68
+ return !1;
69
+ }
70
+ function G(e, o) {
71
+ return e ? o.replacements[e.toLowerCase()] || o.default || e : o.default || "";
72
+ }
73
+ function Se(e) {
74
+ return Array.isArray(e?.files);
75
+ }
76
+ const Ce = {
77
+ circle: !0,
78
+ ellipse: !0,
79
+ foreignObject: !0,
80
+ image: !0,
81
+ line: !0,
82
+ path: !0,
83
+ polygon: !0,
84
+ polyline: !0,
85
+ rect: !0,
86
+ text: !0,
87
+ textPath: !0,
88
+ tspan: !0,
89
+ use: !0
90
+ };
91
+ function ye(e, o) {
92
+ if (!Ce[e.name]) return;
93
+ const r = e.attributes["vector-effect"];
94
+ r && r !== "non-scaling-stroke" ? console.warn(`"${o}": Element "${e.name}" already contains "vector-effect" property. Please remove it, so it can scale correctly. This element will not be transformed.`) : e.attributes["vector-effect"] = "non-scaling-stroke";
95
+ }
96
+ const le = {
97
+ fill: !0,
98
+ stroke: !0,
99
+ "stop-color": !0
100
+ }, V = {
101
+ none: !0,
102
+ transparent: !0,
103
+ currentColor: !0
104
+ }, Le = [
105
+ "url",
106
+ "source",
107
+ "source-data-uri",
108
+ "base64",
109
+ "base64-data-uri"
110
+ ];
111
+ function re(e, o, r, i = !1) {
112
+ if (!e || typeof e != "string") return "";
113
+ let n = "stylesheet";
114
+ i && (e = `{${e}}`, n = "block");
115
+ const l = !i && r.length;
116
+ let c = [], p = [], g = !1;
117
+ const L = css_tree.parse(e, { context: n });
118
+ return css_tree.walk(L, {
119
+ visit: l ? void 0 : "Declaration",
120
+ enter: function(u) {
121
+ if (u.__SKIP_SVG_LOADER__ || this.rule?.__SKIP_SVG_LOADER__) return;
122
+ if (l) {
123
+ if (u.type === "SelectorList") {
124
+ c = [], p = [], g = !1;
125
+ return;
126
+ }
127
+ if (u.type === "Selector") {
128
+ const h = css_tree.generate(u);
129
+ let s = !1;
130
+ for (const f of r) if (oe(f, h)) {
131
+ s = !0, u.__ORIG_COLOR__ = !0;
132
+ break;
133
+ }
134
+ (s ? c : p).push(h);
135
+ return;
136
+ }
137
+ }
138
+ if (u.type !== "Declaration" || !le[u.property]) return;
139
+ const b = u.value?.children?.first, x = b?.value || b?.name;
140
+ if (!(!x || V[x])) {
141
+ if (l && !g && this.rule?.prelude.type === "SelectorList") {
142
+ const h = css_tree.clone(this.rule);
143
+ h.__SKIP_SVG_LOADER__ = !0;
144
+ const s = new css_tree.List(), f = this.rule.prelude.children;
145
+ f.forEach((P, R) => {
146
+ P.__ORIG_COLOR__ && (f.remove(R), s.push(P));
147
+ }), h.prelude.children = s;
148
+ const v = this.atrule?.block?.children || this.stylesheet?.children;
149
+ let a$1;
150
+ v?.some((P, R) => P === this.rule ? (a$1 = R, !0) : !1), a$1 ? v?.insertData(h, a$1) : v?.push(h), g = !0;
151
+ }
152
+ u.value = css_tree.parse(G(css_tree.generate(u.value), o), { context: "value" });
153
+ }
154
+ }
155
+ }), css_tree.generate(L);
156
+ }
157
+ const be = {
158
+ circle: !0,
159
+ ellipse: !0,
160
+ path: !0,
161
+ polygon: !0,
162
+ polyline: !0,
163
+ rect: !0,
164
+ text: !0,
165
+ textPath: !0,
166
+ tref: !0,
167
+ tspan: !0
168
+ }, ie = { ...le };
169
+ delete ie.fill;
170
+ function Pe(e, o, r, i) {
171
+ if (e.name === "style") {
172
+ const c = e.children[0], p = re(c?.value, r, i, !1);
173
+ p && (c.value = p);
174
+ } else {
175
+ const c = re(e.attributes.style, r, i, !0);
176
+ c && (e.attributes.style = c);
177
+ }
178
+ const n = e.name === "svg", l = e.attributes.fill;
179
+ n && l && (o = !0), (n && o || !n && !o && be[e.name]) && !V[l] && (e.attributes.fill = G(l, r));
180
+ for (const c in ie) {
181
+ const p = e.attributes[c];
182
+ p && !V[p] && (e.attributes[c] = G(p, r));
183
+ }
184
+ return o;
185
+ }
186
+ function Ae(e = {}) {
187
+ const { urlImportsInLibraryMode: o = "source-data-uri" } = e;
188
+ let r = e.tempDir || ".temp";
189
+ if (r.startsWith("/") || r.startsWith("./") || r.indexOf(":/") !== -1) throw new Error(`"tempDir" option must be in format "path/to/temp/dir",i.e. it shouldn't be an absolute path, or start with "./".It'll be resolved to the project's root by the plugin.`);
190
+ r.endsWith("/") && (r = r.substring(0, r.length - 1)), r = "/" + r;
191
+ let i = !1, n = !1, l = "", c = "";
192
+ const p = a(e.setCurrentColorList || e.replaceColorsList || []), g = [], L = [], u = {
193
+ files: /.*/,
194
+ replacements: {},
195
+ default: ""
196
+ };
197
+ let b = !1;
198
+ const x = (s) => {
199
+ switch (typeof s) {
200
+ case "string":
201
+ case "function": return !0;
202
+ }
203
+ return s instanceof RegExp;
204
+ };
205
+ for (const s of p) {
206
+ if (Se(s)) {
207
+ g.push(s);
208
+ continue;
209
+ }
210
+ if (x(s)) {
211
+ L.push({
212
+ files: s,
213
+ replacements: {},
214
+ default: "currentColor"
215
+ });
216
+ continue;
217
+ }
218
+ for (const f in s) b = !0, u.replacements[f] = s[f];
219
+ }
220
+ const h = [...g, ...L];
221
+ return b && h.push(u), {
222
+ name: "vite-awesome-svg-loader",
223
+ enforce: "pre",
224
+ config(s, { command: f }) {
225
+ i = f === "build";
226
+ },
227
+ configResolved(s) {
228
+ n = !!s.build.lib, l = X(s.root), c = X(s.base);
229
+ },
230
+ configureServer(s) {
231
+ s.httpServer?.on("close", async () => {
232
+ i || await (0, node_fs_promises.rm)(l + r, {
233
+ force: !0,
234
+ recursive: !0
235
+ });
236
+ });
237
+ },
238
+ async load(s) {
239
+ const v = s.indexOf(".svg");
240
+ if (v === -1) return null;
241
+ let a$1 = s.substring(0, v + 4).replaceAll("\\", "/");
242
+ a$1.startsWith(l) && (a$1 = a$1.substring(l.length)), a$1.startsWith("/") || (a$1 = "/" + a$1);
243
+ const R = (s.split("?", 2)[1] || "").split("&"), O = {};
244
+ for (const t of R) {
245
+ const [y, D] = t.split("=");
246
+ O[y.toLowerCase()] = D || "1";
247
+ }
248
+ const A = {
249
+ fullPath: (l.endsWith("/") ? l.substring(l.length) : l) + a$1,
250
+ relativePath: a$1
251
+ }, E = (t) => ge({
252
+ ...A,
253
+ matchers: t.matchers || [],
254
+ queryValue: O[t.param]
255
+ }), I = (t) => ve({
256
+ ...A,
257
+ selectors: t || []
258
+ });
259
+ if (E({
260
+ param: "skip-awesome-svg-loader",
261
+ matchers: e.skipFilesList
262
+ })) return null;
263
+ const w = E({
264
+ param: "skip-transforms",
265
+ matchers: e.skipTransformsList
266
+ }), W = !w && E({
267
+ param: "preserve-line-width",
268
+ matchers: e.preserveLineWidthList
269
+ }) && !E({ matchers: e.skipPreserveLineWidthList }), B = W ? I(e.skipPreserveLineWidthSelectors) : [];
270
+ let S = !1;
271
+ const d = {
272
+ replacements: {},
273
+ default: void 0
274
+ };
275
+ if (!w && !E({ matchers: e.skipSetCurrentColorList || e.skipReplaceColorsList })) {
276
+ if (se(O["set-current-color"])) d.default = "currentColor", S = !0;
277
+ else for (const t of h) if (j({
278
+ ...A,
279
+ matchers: t.files
280
+ })) {
281
+ S = !0, d.default === void 0 && t.default !== void 0 && (d.default = t.default);
282
+ for (const y in t.replacements) d.replacements[y] ||= t.replacements[y];
283
+ }
284
+ }
285
+ d.default ??= "currentColor";
286
+ const N = S ? I(e.skipSetCurrentColorSelectors || e.skipReplaceColorsSelectors) : [], F = w ? [] : I(e.skipTransformsSelectors), T = [a$1];
287
+ for (const t of [
288
+ B,
289
+ N,
290
+ F
291
+ ]) T.push(t.join(","));
292
+ for (const t of [
293
+ w,
294
+ W,
295
+ S
296
+ ]) T.push(t ? "1" : "0");
297
+ S && T.push(JSON.stringify(d));
298
+ const ne = new imurmurhash.default(T.join("__")).result(), z = `${path.default.basename(a$1).split(".")[0]}-${ne}`, K = z + ".svg", ae = path.default.dirname(a$1) + "/" + K, Q = l + a$1;
299
+ let m = (await (0, node_fs_promises.readFile)(Q)).toString(), U = !1;
300
+ const H = [], J = z + "__";
301
+ let Y = !1;
302
+ m = (0, svgo.optimize)(m, {
303
+ multipass: !0,
304
+ plugins: [{
305
+ name: "prefixIds",
306
+ params: {
307
+ prefixIds: !0,
308
+ prefixClassNames: !0,
309
+ prefix: J,
310
+ delim: ""
311
+ }
312
+ }, {
313
+ name: "awesome-svg-loader",
314
+ fn: () => Y ? null : (Y = !0, {
315
+ root: { enter: (t) => {
316
+ for (const y of [N, F]) for (const D of y) H.push(...(0, svgo_lib_xast_js.querySelectorAll)(t, D));
317
+ } },
318
+ element: { enter: (t) => {
319
+ $(t, F) || (W && !$(t, B) && ye(t, Q), S && !$(t, N) && (U = Pe(t, U, d, H)));
320
+ } }
321
+ })
322
+ }]
323
+ }).data;
324
+ let k = e.defaultImport || "source";
325
+ for (const t of Le) O[t] && (k = t);
326
+ n && k === "url" && o !== "emit-files" && (k = o);
327
+ const C = (t) => [
328
+ `export const src = ${t};`,
329
+ `export const prefix = "${J}"`,
330
+ "export default src"
331
+ ].join(`
332
+ `);
333
+ switch (k) {
334
+ case "source": return C("`" + ee(m) + "`");
335
+ case "source-data-uri": return C("`data:image/svg+xml," + encodeURIComponent(m) + "`");
336
+ case "base64": return C("`" + ee(Z(m)) + "`");
337
+ case "base64-data-uri": return C("`data:image/svg+xml;base64," + encodeURIComponent(Z(m)) + "`");
338
+ }
339
+ if (!i) {
340
+ const t = r + ae;
341
+ return await (0, node_fs_promises.writeFile)(l + t, m), C(`"${c + t}"`);
342
+ }
343
+ return C(`"__VITE_ASSET__${this.emitFile({
344
+ type: "asset",
345
+ name: K,
346
+ source: m
347
+ })}__"`);
348
+ }
349
+ };
350
+ }
351
+
352
+ //#endregion
353
+ exports.viteAwesomeSvgLoader = Ae;