vite-awesome-svg-loader 4.0.0 → 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.
package/README.md CHANGED
@@ -8,7 +8,7 @@ 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.
package/dist.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import p from "debounce";
2
- import pe from "imurmurhash";
2
+ import f from "imurmurhash";
3
3
 
4
4
  //#region ../integration-utils/dist/index.mjs
5
5
  const g = "svg-symbols", m = "svg-", d = "data-count";
@@ -7,10 +7,10 @@ function b(t, e) {
7
7
  if (typeof window > "u" || t === e) return {};
8
8
  let n = document.getElementById(g);
9
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 pe(t).result();
10
+ const s = m + new f(t).result();
11
11
  w(document.getElementById(s));
12
12
  }
13
- const i = m + new pe(e).result(), u = document.getElementById(i);
13
+ const i = m + new f(e).result(), u = document.getElementById(i);
14
14
  if (u) return u.setAttribute(d, l(u) + 1 + ""), {
15
15
  id: i,
16
16
  attrs: h(u)
@@ -12,7 +12,6 @@ import { SVG_ID, SYMBOL_ID_PREFIX, USAGES_COUNT_ATTR, onSrcUpdate, onUnmount } f
12
12
  * 1. CSS properties are in camel case: `minWidth`.
13
13
  *
14
14
  * @param props `SvgIcon` props
15
- * @param options Conversion options
16
15
  * @returns Style map
17
16
  */
18
17
  declare function getSvgIconStyle(props: SvgIconStyleProps): Record<string, string>;
@@ -12,7 +12,6 @@ import { SVG_ID, SYMBOL_ID_PREFIX, USAGES_COUNT_ATTR, onSrcUpdate, onUnmount } f
12
12
  * 1. CSS properties are in camel case: `minWidth`.
13
13
  *
14
14
  * @param props `SvgIcon` props
15
- * @param options Conversion options
16
15
  * @returns Style map
17
16
  */
18
17
  declare function getSvgIconStyle(props: SvgIconStyleProps): Record<string, string>;
package/loader.cjs CHANGED
@@ -9,55 +9,71 @@ let svgo_lib_xast_js = require("svgo/lib/xast.js");
9
9
  let css_tree = require("css-tree");
10
10
  css_tree = require_chunk.__toESM(css_tree);
11
11
 
12
+ //#region ../utils/dist/index.mjs
13
+ function a(t) {
14
+ return Array.isArray(t) ? t : [t];
15
+ }
16
+
17
+ //#endregion
12
18
  //#region ../loader/dist/index.mjs
13
- function H(e) {
19
+ function X(e) {
14
20
  return e = e.replaceAll("\\", "/"), e.endsWith("/") && (e = e.substring(0, e.length - 1)), e;
15
21
  }
16
- function Q(e) {
17
- const t = String.fromCodePoint(...new TextEncoder().encode(e));
18
- return btoa(t);
22
+ function Z(e) {
23
+ const o = String.fromCodePoint(...new TextEncoder().encode(e));
24
+ return btoa(o);
19
25
  }
20
- function J(e) {
26
+ function ee(e) {
21
27
  return e.replaceAll("`", "\\`");
22
28
  }
23
- function E(e, t, i) {
24
- return Z(t) || $(e, i);
29
+ function ge(e) {
30
+ return se(e.queryValue) || j(e);
25
31
  }
26
- function Z(e) {
32
+ function se(e) {
27
33
  return !!e && e.toLowerCase() !== "false";
28
34
  }
29
- function $(e, t) {
30
- const a = [path.default.basename(e), e];
31
- for (const o of t) {
32
- const u = o instanceof RegExp;
33
- for (const n of a) if (u ? o.test(n) : n === o) return !0;
34
- }
35
- return !1;
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;
36
47
  }
37
- function Y(e) {
48
+ function te(e) {
38
49
  return e.replaceAll(/\s+/g, " ").trim();
39
50
  }
40
- function A(e, t, i) {
41
- const a = [];
42
- if (i) return a;
43
- for (const o of t) {
44
- if (typeof o == "string") {
45
- a.push(Y(o));
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));
46
56
  continue;
47
57
  }
48
- if ($(e, o.files)) for (const u of o.selectors) a.push(Y(u));
58
+ if (j({
59
+ ...e,
60
+ matchers: i.files
61
+ })) for (const n of i.selectors) r.push(te(n));
49
62
  }
50
- return a;
63
+ return r;
51
64
  }
52
- const ee = svgo_lib_xast_js.matches;
53
- function W(e, t) {
54
- for (const i of t) if (ee(e, i)) return !0;
65
+ const oe = svgo_lib_xast_js.matches;
66
+ function $(e, o) {
67
+ for (const r of o) if (oe(e, r)) return !0;
55
68
  return !1;
56
69
  }
57
- function F(e, t) {
58
- return e ? t.replacements[e.toLowerCase()] || t.default || e : t.default || "";
70
+ function G(e, o) {
71
+ return e ? o.replacements[e.toLowerCase()] || o.default || e : o.default || "";
59
72
  }
60
- const me = {
73
+ function Se(e) {
74
+ return Array.isArray(e?.files);
75
+ }
76
+ const Ce = {
61
77
  circle: !0,
62
78
  ellipse: !0,
63
79
  foreignObject: !0,
@@ -72,73 +88,73 @@ const me = {
72
88
  tspan: !0,
73
89
  use: !0
74
90
  };
75
- function he(e, t) {
76
- if (!me[e.name]) return;
77
- const i = e.attributes["vector-effect"];
78
- i && i !== "non-scaling-stroke" ? console.warn(`"${t}": 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";
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";
79
95
  }
80
- const te = {
96
+ const le = {
81
97
  fill: !0,
82
98
  stroke: !0,
83
99
  "stop-color": !0
84
- }, M = {
100
+ }, V = {
85
101
  none: !0,
86
102
  transparent: !0,
87
103
  currentColor: !0
88
- }, de = [
104
+ }, Le = [
89
105
  "url",
90
106
  "source",
91
107
  "source-data-uri",
92
108
  "base64",
93
109
  "base64-data-uri"
94
110
  ];
95
- function X(e, t, i, a = !1) {
111
+ function re(e, o, r, i = !1) {
96
112
  if (!e || typeof e != "string") return "";
97
- let o = "stylesheet";
98
- a && (e = `{${e}}`, o = "block");
99
- const u = !a && i.length;
100
- let n = [], f = [], L = !1;
101
- const y = css_tree.parse(e, { context: o });
102
- return css_tree.walk(y, {
103
- visit: u ? void 0 : "Declaration",
104
- enter: function(p) {
105
- if (p.__SKIP_SVG_LOADER__ || this.rule?.__SKIP_SVG_LOADER__) return;
106
- if (u) {
107
- if (p.type === "SelectorList") {
108
- n = [], f = [], L = !1;
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;
109
125
  return;
110
126
  }
111
- if (p.type === "Selector") {
112
- const c = css_tree.generate(p);
113
- let h = !1;
114
- for (const s of i) if (ee(s, c)) {
115
- h = !0, p.__ORIG_COLOR__ = !0;
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;
116
132
  break;
117
133
  }
118
- (h ? n : f).push(c);
134
+ (s ? c : p).push(h);
119
135
  return;
120
136
  }
121
137
  }
122
- if (p.type !== "Declaration" || !te[p.property]) return;
123
- const R = p.value?.children?.first, l = R?.value || R?.name;
124
- if (!(!l || M[l])) {
125
- if (u && !L && this.rule?.prelude.type === "SelectorList") {
126
- const c = css_tree.clone(this.rule);
127
- c.__SKIP_SVG_LOADER__ = !0;
128
- const h = new css_tree.List(), s = this.rule.prelude.children;
129
- s.forEach((m, d) => {
130
- m.__ORIG_COLOR__ && (s.remove(d), h.push(m));
131
- }), c.prelude.children = h;
132
- const O = this.atrule?.block?.children || this.stylesheet?.children;
133
- let k;
134
- O?.some((m, d) => m === this.rule ? (k = d, !0) : !1), k ? O?.insertData(c, k) : O?.push(c), L = !0;
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;
135
151
  }
136
- p.value = css_tree.parse(F(css_tree.generate(p.value), t), { context: "value" });
152
+ u.value = css_tree.parse(G(css_tree.generate(u.value), o), { context: "value" });
137
153
  }
138
154
  }
139
- }), css_tree.generate(y);
155
+ }), css_tree.generate(L);
140
156
  }
141
- const _e = {
157
+ const be = {
142
158
  circle: !0,
143
159
  ellipse: !0,
144
160
  path: !0,
@@ -149,178 +165,189 @@ const _e = {
149
165
  textPath: !0,
150
166
  tref: !0,
151
167
  tspan: !0
152
- }, re = { ...te };
153
- delete re.fill;
154
- function Se(e, t, i, a) {
168
+ }, ie = { ...le };
169
+ delete ie.fill;
170
+ function Pe(e, o, r, i) {
155
171
  if (e.name === "style") {
156
- const n = e.children[0], f = X(n?.value, i, a, !1);
157
- f && (n.value = f);
172
+ const c = e.children[0], p = re(c?.value, r, i, !1);
173
+ p && (c.value = p);
158
174
  } else {
159
- const n = X(e.attributes.style, i, a, !0);
160
- n && (e.attributes.style = n);
175
+ const c = re(e.attributes.style, r, i, !0);
176
+ c && (e.attributes.style = c);
161
177
  }
162
- const o = e.name === "svg", u = e.attributes.fill;
163
- o && u && (t = !0), (o && t || !o && !t && _e[e.name]) && !M[u] && (e.attributes.fill = F(u, i));
164
- for (const n in re) {
165
- const f = e.attributes[n];
166
- f && !M[f] && (e.attributes[n] = F(f, i));
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));
167
183
  }
168
- return t;
184
+ return o;
169
185
  }
170
- const Ce = {
171
- tempDir: ".temp",
172
- preserveLineWidthList: [],
173
- skipPreserveLineWidthList: [],
174
- skipPreserveLineWidthSelectors: [],
175
- setCurrentColorList: [],
176
- skipSetCurrentColorList: [],
177
- skipSetCurrentColorSelectors: [],
178
- replaceColorsList: [],
179
- skipReplaceColorsList: [],
180
- skipReplaceColorsSelectors: [],
181
- skipTransformsList: [],
182
- skipTransformsSelectors: [],
183
- skipFilesList: [],
184
- defaultImport: "source",
185
- urlImportsInLibraryMode: "source-data-uri"
186
- };
187
- function ke(e = {}) {
188
- const t = {
189
- ...Ce,
190
- ...e
191
- };
192
- if (t.tempDir = t.tempDir.replaceAll("\\", "/"), t.tempDir.startsWith("/") || t.tempDir.startsWith("./") || t.tempDir.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.`);
193
- t.tempDir.endsWith("/") && (t.tempDir = t.tempDir.substring(0, t.tempDir.length - 1)), t.tempDir = "/" + t.tempDir;
194
- let i = !1, a = !1, o = "", u = "";
195
- const n = e.setCurrentColorList || t.replaceColorsList, f = [], L = [], y = {
196
- files: [/.*/],
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: /.*/,
197
194
  replacements: {},
198
195
  default: ""
199
196
  };
200
- let p = !1;
201
- for (const l of n) {
202
- if (typeof l == "string" || l instanceof RegExp) {
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)) {
203
211
  L.push({
204
- files: [l],
212
+ files: s,
205
213
  replacements: {},
206
214
  default: "currentColor"
207
215
  });
208
216
  continue;
209
217
  }
210
- if (l.files instanceof Array) {
211
- f.push(l);
212
- continue;
213
- }
214
- for (const c in l) p = !0, y.replacements[c] = l[c];
218
+ for (const f in s) b = !0, u.replacements[f] = s[f];
215
219
  }
216
- const R = [...f, ...L];
217
- return p && R.push(y), {
220
+ const h = [...g, ...L];
221
+ return b && h.push(u), {
218
222
  name: "vite-awesome-svg-loader",
219
223
  enforce: "pre",
220
- config(l, { command: c }) {
221
- i = c === "build";
224
+ config(s, { command: f }) {
225
+ i = f === "build";
222
226
  },
223
- configResolved(l) {
224
- a = !!l.build.lib, o = H(l.root), u = H(l.base);
227
+ configResolved(s) {
228
+ n = !!s.build.lib, l = X(s.root), c = X(s.base);
225
229
  },
226
- configureServer(l) {
227
- l.httpServer?.on("close", async () => {
228
- i || await (0, node_fs_promises.rm)(o + t.tempDir, {
230
+ configureServer(s) {
231
+ s.httpServer?.on("close", async () => {
232
+ i || await (0, node_fs_promises.rm)(l + r, {
229
233
  force: !0,
230
234
  recursive: !0
231
235
  });
232
236
  });
233
237
  },
234
- async load(l) {
235
- const h = l.indexOf(".svg");
236
- if (h === -1) return null;
237
- let s = l.substring(0, h + 4).replaceAll("\\", "/");
238
- s.startsWith(o) && (s = s.substring(o.length)), s.startsWith("/") || (s = "/" + s);
239
- const k = (l.split("?", 2)[1] || "").split("&"), m = {};
240
- for (const r of k) {
241
- const [b, D] = r.split("=");
242
- m[b.toLowerCase()] = D || "1";
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";
243
247
  }
244
- if (E(s, m["skip-awesome-svg-loader"], t.skipFilesList)) return null;
245
- const d = E(s, m["skip-transforms"], t.skipTransformsList), I = !d && E(s, m["preserve-line-width"], t.preserveLineWidthList) && !E(s, void 0, t.skipPreserveLineWidthList), G = A(s, t.skipPreserveLineWidthSelectors, !I);
246
- let g = !1;
247
- const C = {
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 = {
248
272
  replacements: {},
249
273
  default: void 0
250
274
  };
251
- if (!d && !E(s, void 0, e.skipSetCurrentColorList || t.skipReplaceColorsList)) {
252
- if (Z(m["set-current-color"])) C.default = "currentColor", g = !0;
253
- else for (const r of R) if ($(s, r.files)) {
254
- g = !0, C.default === void 0 && r.default !== void 0 && (C.default = r.default);
255
- for (const b in r.replacements) C.replacements[b] ||= r.replacements[b];
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];
256
283
  }
257
284
  }
258
- C.default ??= "currentColor";
259
- const P = A(s, e.skipSetCurrentColorSelectors || t.skipReplaceColorsSelectors, !g), w = A(s, t.skipTransformsSelectors, d), x = [s];
260
- for (const r of [
261
- G,
262
- P,
263
- w
264
- ]) x.push(r.join(","));
265
- for (const r of [
266
- d,
267
- I,
268
- g
269
- ]) x.push(r ? "1" : "0");
270
- g && x.push(JSON.stringify(C));
271
- const se = new imurmurhash.default(x.join("__")).result(), V = `${path.default.basename(s).split(".")[0]}-${se}`, j = V + ".svg", oe = path.default.dirname(s) + "/" + j, B = o + s;
272
- let _ = (await (0, node_fs_promises.readFile)(B)).toString(), q = !1;
273
- const z = [], K = V + "__";
274
- let U = !1;
275
- _ = (0, svgo.optimize)(_, {
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, {
276
303
  multipass: !0,
277
304
  plugins: [{
278
305
  name: "prefixIds",
279
306
  params: {
280
307
  prefixIds: !0,
281
308
  prefixClassNames: !0,
282
- prefix: K,
309
+ prefix: J,
283
310
  delim: ""
284
311
  }
285
312
  }, {
286
313
  name: "awesome-svg-loader",
287
- fn: () => U ? null : (U = !0, {
288
- root: { enter: (r) => {
289
- for (const b of [P, w]) for (const D of b) z.push(...(0, svgo_lib_xast_js.querySelectorAll)(r, D));
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));
290
317
  } },
291
- element: { enter: (r) => {
292
- W(r, w) || (I && !W(r, G) && he(r, B), g && !W(r, P) && (q = Se(r, q, C, z)));
318
+ element: { enter: (t) => {
319
+ $(t, F) || (W && !$(t, B) && ye(t, Q), S && !$(t, N) && (U = Pe(t, U, d, H)));
293
320
  } }
294
321
  })
295
322
  }]
296
323
  }).data;
297
- let T = t.defaultImport;
298
- for (const r of de) m[r] && (T = r);
299
- a && T === "url" && t.urlImportsInLibraryMode !== "emit-files" && (T = t.urlImportsInLibraryMode);
300
- const v = (r) => [
301
- `export const src = ${r};`,
302
- `export const prefix = "${K}"`,
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}"`,
303
330
  "export default src"
304
331
  ].join(`
305
332
  `);
306
- switch (T) {
307
- case "source": return v("`" + J(_) + "`");
308
- case "source-data-uri": return v("`data:image/svg+xml," + encodeURIComponent(_) + "`");
309
- case "base64": return v("`" + J(Q(_)) + "`");
310
- case "base64-data-uri": return v("`data:image/svg+xml;base64," + encodeURIComponent(Q(_)) + "`");
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)) + "`");
311
338
  }
312
339
  if (!i) {
313
- const r = t.tempDir + oe;
314
- return await (0, node_fs_promises.writeFile)(o + r, _), v(`"${u + r}"`);
340
+ const t = r + ae;
341
+ return await (0, node_fs_promises.writeFile)(l + t, m), C(`"${c + t}"`);
315
342
  }
316
- return v(`"__VITE_ASSET__${this.emitFile({
343
+ return C(`"__VITE_ASSET__${this.emitFile({
317
344
  type: "asset",
318
- name: j,
319
- source: _
345
+ name: K,
346
+ source: m
320
347
  })}__"`);
321
348
  }
322
349
  };
323
350
  }
324
351
 
325
352
  //#endregion
326
- exports.viteAwesomeSvgLoader = ke;
353
+ exports.viteAwesomeSvgLoader = Ae;