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 +1 -1
- package/dist.js +3 -3
- package/integration-utils.d.cts +0 -1
- package/integration-utils.d.ts +0 -1
- package/loader.cjs +216 -189
- package/loader.d.cts +258 -214
- package/loader.d.ts +258 -214
- package/loader.js +219 -192
- package/package.json +3 -1
- package/vue-integration.d.cts +3 -3
- package/vue-integration.d.ts +3 -3
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
|
|
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
|
|
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
|
|
10
|
+
const s = m + new f(t).result();
|
|
11
11
|
w(document.getElementById(s));
|
|
12
12
|
}
|
|
13
|
-
const i = m + new
|
|
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)
|
package/integration-utils.d.cts
CHANGED
|
@@ -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/integration-utils.d.ts
CHANGED
|
@@ -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
|
|
19
|
+
function X(e) {
|
|
14
20
|
return e = e.replaceAll("\\", "/"), e.endsWith("/") && (e = e.substring(0, e.length - 1)), e;
|
|
15
21
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
return btoa(
|
|
22
|
+
function Z(e) {
|
|
23
|
+
const o = String.fromCodePoint(...new TextEncoder().encode(e));
|
|
24
|
+
return btoa(o);
|
|
19
25
|
}
|
|
20
|
-
function
|
|
26
|
+
function ee(e) {
|
|
21
27
|
return e.replaceAll("`", "\\`");
|
|
22
28
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
29
|
+
function ge(e) {
|
|
30
|
+
return se(e.queryValue) || j(e);
|
|
25
31
|
}
|
|
26
|
-
function
|
|
32
|
+
function se(e) {
|
|
27
33
|
return !!e && e.toLowerCase() !== "false";
|
|
28
34
|
}
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
48
|
+
function te(e) {
|
|
38
49
|
return e.replaceAll(/\s+/g, " ").trim();
|
|
39
50
|
}
|
|
40
|
-
function
|
|
41
|
-
const a = [];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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 (
|
|
58
|
+
if (j({
|
|
59
|
+
...e,
|
|
60
|
+
matchers: i.files
|
|
61
|
+
})) for (const n of i.selectors) r.push(te(n));
|
|
49
62
|
}
|
|
50
|
-
return
|
|
63
|
+
return r;
|
|
51
64
|
}
|
|
52
|
-
const
|
|
53
|
-
function
|
|
54
|
-
for (const
|
|
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
|
|
58
|
-
return e ?
|
|
70
|
+
function G(e, o) {
|
|
71
|
+
return e ? o.replacements[e.toLowerCase()] || o.default || e : o.default || "";
|
|
59
72
|
}
|
|
60
|
-
|
|
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
|
|
76
|
-
if (!
|
|
77
|
-
const
|
|
78
|
-
|
|
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
|
|
96
|
+
const le = {
|
|
81
97
|
fill: !0,
|
|
82
98
|
stroke: !0,
|
|
83
99
|
"stop-color": !0
|
|
84
|
-
},
|
|
100
|
+
}, V = {
|
|
85
101
|
none: !0,
|
|
86
102
|
transparent: !0,
|
|
87
103
|
currentColor: !0
|
|
88
|
-
},
|
|
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
|
|
111
|
+
function re(e, o, r, i = !1) {
|
|
96
112
|
if (!e || typeof e != "string") return "";
|
|
97
|
-
let
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
let
|
|
101
|
-
const
|
|
102
|
-
return css_tree.walk(
|
|
103
|
-
visit:
|
|
104
|
-
enter: function(
|
|
105
|
-
if (
|
|
106
|
-
if (
|
|
107
|
-
if (
|
|
108
|
-
|
|
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 (
|
|
112
|
-
const
|
|
113
|
-
let
|
|
114
|
-
for (const
|
|
115
|
-
|
|
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
|
-
(
|
|
134
|
+
(s ? c : p).push(h);
|
|
119
135
|
return;
|
|
120
136
|
}
|
|
121
137
|
}
|
|
122
|
-
if (
|
|
123
|
-
const
|
|
124
|
-
if (!(!
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}),
|
|
132
|
-
const
|
|
133
|
-
let
|
|
134
|
-
|
|
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
|
-
|
|
152
|
+
u.value = css_tree.parse(G(css_tree.generate(u.value), o), { context: "value" });
|
|
137
153
|
}
|
|
138
154
|
}
|
|
139
|
-
}), css_tree.generate(
|
|
155
|
+
}), css_tree.generate(L);
|
|
140
156
|
}
|
|
141
|
-
const
|
|
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
|
-
},
|
|
153
|
-
delete
|
|
154
|
-
function
|
|
168
|
+
}, ie = { ...le };
|
|
169
|
+
delete ie.fill;
|
|
170
|
+
function Pe(e, o, r, i) {
|
|
155
171
|
if (e.name === "style") {
|
|
156
|
-
const
|
|
157
|
-
|
|
172
|
+
const c = e.children[0], p = re(c?.value, r, i, !1);
|
|
173
|
+
p && (c.value = p);
|
|
158
174
|
} else {
|
|
159
|
-
const
|
|
160
|
-
|
|
175
|
+
const c = re(e.attributes.style, r, i, !0);
|
|
176
|
+
c && (e.attributes.style = c);
|
|
161
177
|
}
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
for (const
|
|
165
|
-
const
|
|
166
|
-
|
|
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
|
|
184
|
+
return o;
|
|
169
185
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
|
201
|
-
|
|
202
|
-
|
|
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:
|
|
212
|
+
files: s,
|
|
205
213
|
replacements: {},
|
|
206
214
|
default: "currentColor"
|
|
207
215
|
});
|
|
208
216
|
continue;
|
|
209
217
|
}
|
|
210
|
-
|
|
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
|
|
217
|
-
return
|
|
220
|
+
const h = [...g, ...L];
|
|
221
|
+
return b && h.push(u), {
|
|
218
222
|
name: "vite-awesome-svg-loader",
|
|
219
223
|
enforce: "pre",
|
|
220
|
-
config(
|
|
221
|
-
i =
|
|
224
|
+
config(s, { command: f }) {
|
|
225
|
+
i = f === "build";
|
|
222
226
|
},
|
|
223
|
-
configResolved(
|
|
224
|
-
|
|
227
|
+
configResolved(s) {
|
|
228
|
+
n = !!s.build.lib, l = X(s.root), c = X(s.base);
|
|
225
229
|
},
|
|
226
|
-
configureServer(
|
|
227
|
-
|
|
228
|
-
i || await (0, node_fs_promises.rm)(
|
|
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(
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
let
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
for (const
|
|
241
|
-
const [
|
|
242
|
-
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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 = {
|
|
248
272
|
replacements: {},
|
|
249
273
|
default: void 0
|
|
250
274
|
};
|
|
251
|
-
if (!
|
|
252
|
-
if (
|
|
253
|
-
else for (const
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
|
|
259
|
-
const
|
|
260
|
-
for (const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
])
|
|
265
|
-
for (const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
])
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
let
|
|
273
|
-
const
|
|
274
|
-
let
|
|
275
|
-
|
|
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:
|
|
309
|
+
prefix: J,
|
|
283
310
|
delim: ""
|
|
284
311
|
}
|
|
285
312
|
}, {
|
|
286
313
|
name: "awesome-svg-loader",
|
|
287
|
-
fn: () =>
|
|
288
|
-
root: { enter: (
|
|
289
|
-
for (const
|
|
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: (
|
|
292
|
-
|
|
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
|
|
298
|
-
for (const
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
`export const src = ${
|
|
302
|
-
`export const prefix = "${
|
|
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 (
|
|
307
|
-
case "source": return
|
|
308
|
-
case "source-data-uri": return
|
|
309
|
-
case "base64": return
|
|
310
|
-
case "base64-data-uri": return
|
|
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
|
|
314
|
-
return await (0, node_fs_promises.writeFile)(
|
|
340
|
+
const t = r + ae;
|
|
341
|
+
return await (0, node_fs_promises.writeFile)(l + t, m), C(`"${c + t}"`);
|
|
315
342
|
}
|
|
316
|
-
return
|
|
343
|
+
return C(`"__VITE_ASSET__${this.emitFile({
|
|
317
344
|
type: "asset",
|
|
318
|
-
name:
|
|
319
|
-
source:
|
|
345
|
+
name: K,
|
|
346
|
+
source: m
|
|
320
347
|
})}__"`);
|
|
321
348
|
}
|
|
322
349
|
};
|
|
323
350
|
}
|
|
324
351
|
|
|
325
352
|
//#endregion
|
|
326
|
-
exports.viteAwesomeSvgLoader =
|
|
353
|
+
exports.viteAwesomeSvgLoader = Ae;
|