@robosophy/ui-vue 1.0.9 → 1.0.11

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=test-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAA4B,MAAM,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEhG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,KAAK,SAAS,GAAG,MAAM,GAAG;IAAE,MAAM,CAAC,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;AAE3E,MAAM,MAAM,+BAA+B,GAAG;IAC5C,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,KAAK,YAAY,GAAG,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAAE,CAAC;CAC3C,CAAC;AAuCF,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,+BAAoC,GAC5C,MAAM,CAuER;AAED,KAAK,kBA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,YAAY,UAIjE"}
package/dist/vite.js CHANGED
@@ -1,9 +1,14 @@
1
- import { createHash as M } from "node:crypto";
2
- import { readFile as b, readdir as x } from "node:fs/promises";
3
- import { join as y, extname as P, sep as N } from "node:path";
4
- import { createRequire as _ } from "node:module";
5
- import { fileURLToPath as H } from "node:url";
6
- const l = ["outlined", "rounded", "sharp"], u = "outlined", k = /^[a-z0-9_]+$/, z = /* @__PURE__ */ new Set([".js", ".jsx", ".mjs", ".ts", ".tsx", ".vue"]), I = /* @__PURE__ */ new Set([".git", "dist", "node_modules", "storybook-static"]), T = [
1
+ import { createHash } from "node:crypto";
2
+ import { readFile, readdir } from "node:fs/promises";
3
+ import { join, extname, sep } from "node:path";
4
+ import { createRequire } from "node:module";
5
+ import { fileURLToPath } from "node:url";
6
+ const families = ["outlined", "rounded", "sharp"];
7
+ const defaultFamily = "outlined";
8
+ const iconNamePattern = /^[a-z0-9_]+$/;
9
+ const sourceExtensions = /* @__PURE__ */ new Set([".js", ".jsx", ".mjs", ".ts", ".tsx", ".vue"]);
10
+ const skippedDirs = /* @__PURE__ */ new Set([".git", "dist", "node_modules", "storybook-static"]);
11
+ const internalIconNames = [
7
12
  "arrow_drop_down",
8
13
  "arrow_drop_up",
9
14
  "arrow_left",
@@ -11,125 +16,157 @@ const l = ["outlined", "rounded", "sharp"], u = "outlined", k = /^[a-z0-9_]+$/,
11
16
  "close",
12
17
  "login",
13
18
  "nest_eco_leaf"
14
- ], d = {
19
+ ];
20
+ const familyFontNames = {
15
21
  outlined: "Material Symbols Outlined Variable",
16
22
  rounded: "Material Symbols Rounded Variable",
17
23
  sharp: "Material Symbols Sharp Variable"
18
- }, R = {
24
+ };
25
+ const familyPackages = {
19
26
  outlined: "@fontsource-variable/material-symbols-outlined",
20
27
  rounded: "@fontsource-variable/material-symbols-rounded",
21
28
  sharp: "@fontsource-variable/material-symbols-sharp"
22
- }, D = {
29
+ };
30
+ const familyFontVariants = {
23
31
  outlined: "wght",
24
32
  rounded: "wght",
25
33
  sharp: "wght"
26
- }, $ = "swap", L = !1, U = _(import.meta.url);
27
- function st(t = {}) {
28
- let e;
34
+ };
35
+ const defaultFontDisplay = "swap";
36
+ const defaultPreload = false;
37
+ const require$1 = createRequire(import.meta.url);
38
+ function robosophyMaterialSymbols(options = {}) {
39
+ let config;
40
+ let cachedAssets = null;
41
+ let cacheValid = false;
42
+ async function getAssets() {
43
+ if (cacheValid && cachedAssets) return cachedAssets;
44
+ cachedAssets = await ensureGeneratedAssets(config, options);
45
+ cacheValid = true;
46
+ return cachedAssets;
47
+ }
29
48
  return {
30
49
  name: "robosophy-material-symbols",
31
- async configResolved(s) {
32
- e = s;
50
+ async configResolved(resolvedConfig) {
51
+ config = resolvedConfig;
33
52
  },
34
53
  async transformIndexHtml() {
35
- const s = await p(e, t);
36
- return S(s, t);
54
+ const assets = await getAssets();
55
+ return buildMaterialSymbolsHtmlTags(assets, options);
37
56
  },
38
- configureServer(s) {
39
- s.middlewares.use(async (o, n, a) => {
40
- if (!o.url?.startsWith("/@robosophy-material-symbols/")) {
41
- a();
57
+ configureServer(server) {
58
+ server.watcher.on("all", (_event, file) => {
59
+ if (sourceExtensions.has(extname(file))) {
60
+ cacheValid = false;
61
+ }
62
+ });
63
+ server.middlewares.use(async (request, response, next) => {
64
+ if (!request.url?.startsWith("/@robosophy-material-symbols/")) {
65
+ next();
42
66
  return;
43
67
  }
44
68
  try {
45
- const r = await p(e, t), i = decodeURIComponent(
46
- o.url.replace("/@robosophy-material-symbols/", "").split("?")[0] ?? ""
69
+ const assets = await getAssets();
70
+ const fileName = decodeURIComponent(
71
+ request.url.replace("/@robosophy-material-symbols/", "").split("?")[0] ?? ""
47
72
  );
48
- if (i === "rs-material-symbols.css") {
49
- n.setHeader("Content-Type", "text/css; charset=utf-8"), n.end(r.css);
73
+ if (fileName === "rs-material-symbols.css") {
74
+ response.setHeader("Content-Type", "text/css; charset=utf-8");
75
+ response.end(assets.css);
50
76
  return;
51
77
  }
52
- const c = r.fonts.find((f) => f.fileName === i);
53
- if (c) {
54
- n.setHeader("Content-Type", "font/woff2"), n.end(c.source);
78
+ const font = assets.fonts.find((asset) => asset.fileName === fileName);
79
+ if (font) {
80
+ response.setHeader("Content-Type", "font/woff2");
81
+ response.end(font.source);
55
82
  return;
56
83
  }
57
- a();
58
- } catch (r) {
59
- a(r);
84
+ next();
85
+ } catch (error) {
86
+ next(error);
60
87
  }
61
88
  });
62
89
  },
63
- async generateBundle(s, o) {
64
- const n = await p(e, t);
65
- for (const a of n.fonts)
90
+ async generateBundle(_outputOptions, bundle) {
91
+ const assets = await getAssets();
92
+ for (const font of assets.fonts) {
66
93
  this.emitFile({
67
- fileName: `assets/${a.fileName}`,
68
- name: a.fileName,
69
- source: a.source,
94
+ fileName: `assets/${font.fileName}`,
95
+ name: font.fileName,
96
+ source: font.source,
70
97
  type: "asset"
71
98
  });
99
+ }
72
100
  this.emitFile({
73
101
  fileName: "assets/rs-material-symbols.css",
74
102
  name: "rs-material-symbols.css",
75
- source: n.css,
103
+ source: assets.css,
76
104
  type: "asset"
77
105
  });
78
- for (const a of Object.values(o))
79
- a.type === "asset" && a.fileName.endsWith(".html") && (a.source = O(String(a.source), n, t));
80
106
  }
81
107
  };
82
108
  }
83
- async function p(t, e) {
84
- const s = await A(t, e), o = t.command === "serve", n = await V(s, o, t.base);
109
+ async function ensureGeneratedAssets(config, options) {
110
+ const usages = await collectMaterialSymbolUsages(config, options);
111
+ const devMode = config.command === "serve";
112
+ const fonts = await generateFontAssets(usages, devMode, config.base);
113
+ const css = buildMaterialSymbolsCss(
114
+ usages,
115
+ fonts,
116
+ devMode,
117
+ options.fontDisplay ?? defaultFontDisplay
118
+ );
85
119
  return {
86
- css: C(
87
- s,
88
- n,
89
- o,
90
- e.fontDisplay ?? $
91
- ),
92
- cssHref: o ? "/@robosophy-material-symbols/rs-material-symbols.css" : F(t.base, "assets/rs-material-symbols.css"),
93
- fonts: n
120
+ css,
121
+ cssHref: devMode ? "/@robosophy-material-symbols/rs-material-symbols.css" : withBase(config.base, "assets/rs-material-symbols.css"),
122
+ fonts
94
123
  };
95
124
  }
96
- async function A(t, e = {}) {
97
- const s = Q(), o = await K();
98
- if (o)
99
- for (const n of l)
100
- for (const a of o[n] ?? [])
101
- m(s, { family: n, name: a });
102
- else
103
- for (const n of T)
104
- for (const a of l)
105
- m(s, { family: a, name: n });
106
- for (const n of e.include ?? [])
107
- m(s, typeof n == "string" ? { family: u, name: n } : n);
108
- if (e.scan !== !1) {
109
- const n = e.roots ?? [y(t.root, "src")];
110
- for (const a of n)
111
- for (const r of await j(a)) {
112
- const i = await b(r, "utf8");
113
- E(i, s);
125
+ async function collectMaterialSymbolUsages(config, options = {}) {
126
+ const usages = createUsageMap();
127
+ const manifest = await loadIconManifest();
128
+ if (manifest) {
129
+ for (const family of families) {
130
+ for (const name of manifest[family] ?? []) {
131
+ addUsage(usages, { family, name });
132
+ }
133
+ }
134
+ } else {
135
+ for (const name of internalIconNames) {
136
+ for (const family of families) {
137
+ addUsage(usages, { family, name });
114
138
  }
139
+ }
140
+ }
141
+ for (const icon of options.include ?? []) {
142
+ addUsage(usages, typeof icon === "string" ? { family: defaultFamily, name: icon } : icon);
143
+ }
144
+ if (options.scan !== false) {
145
+ const roots = options.roots ?? [join(config.root, "src")];
146
+ for (const root of roots) {
147
+ for (const filePath of await listSourceFiles(root)) {
148
+ const source = await readFile(filePath, "utf8");
149
+ collectFromSource(source, usages);
150
+ }
151
+ }
115
152
  }
116
- return s;
153
+ return usages;
117
154
  }
118
- function C(t, e, s = !1, o = $) {
119
- const n = [];
120
- for (const r of e) {
121
- const i = s ? `/@robosophy-material-symbols/${r.fileName}` : `./${r.fileName}`;
122
- n.push(
155
+ function buildMaterialSymbolsCss(usages, fonts, devMode = false, fontDisplay = defaultFontDisplay) {
156
+ const lines = [];
157
+ for (const font of fonts) {
158
+ const fontUrl = devMode ? `/@robosophy-material-symbols/${font.fileName}` : `./${font.fileName}`;
159
+ lines.push(
123
160
  "@font-face {",
124
- ` font-family: "${d[r.family]}";`,
125
- ` font-display: ${o};`,
161
+ ` font-family: "${familyFontNames[font.family]}";`,
162
+ ` font-display: ${fontDisplay};`,
126
163
  " font-style: normal;",
127
164
  " font-weight: 100 700;",
128
- ` src: url("${i}") format("woff2-variations");`,
165
+ ` src: url("${fontUrl}") format("woff2-variations");`,
129
166
  "}"
130
167
  );
131
168
  }
132
- n.push(
169
+ lines.push(
133
170
  ".rs-icon {",
134
171
  " --rs-icon-color: currentColor;",
135
172
  " --rs-icon-fill: 0;",
@@ -141,7 +178,7 @@ function C(t, e, s = !1, o = $) {
141
178
  " color: var(--rs-icon-color);",
142
179
  " display: inline-flex;",
143
180
  " flex: 0 0 auto;",
144
- ` font-family: "${d.outlined}";`,
181
+ ` font-family: "${familyFontNames.outlined}";`,
145
182
  " font-size: var(--rs-icon-size);",
146
183
  " font-style: normal;",
147
184
  ' font-feature-settings: "liga";',
@@ -157,162 +194,231 @@ function C(t, e, s = !1, o = $) {
157
194
  " white-space: nowrap;",
158
195
  " word-wrap: normal;",
159
196
  "}",
160
- `.rs-icon--rounded { font-family: "${d.rounded}"; }`,
161
- `.rs-icon--sharp { font-family: "${d.sharp}"; }`,
197
+ `.rs-icon--rounded { font-family: "${familyFontNames.rounded}"; }`,
198
+ `.rs-icon--sharp { font-family: "${familyFontNames.sharp}"; }`,
162
199
  ".rs-icon--prime::before { content: var(--rs-icon-content); }"
163
200
  );
164
- const a = /* @__PURE__ */ new Set();
165
- for (const r of l)
166
- for (const i of t.get(r) ?? [])
167
- a.add(i);
168
- for (const r of [...a].sort())
169
- n.push(`.rs-icon-${r} { --rs-icon-content: "${r}"; }`);
170
- return `${n.join(`
171
- `)}
201
+ const names = /* @__PURE__ */ new Set();
202
+ for (const family of families) {
203
+ for (const name of usages.get(family) ?? []) {
204
+ names.add(name);
205
+ }
206
+ }
207
+ for (const name of [...names].sort()) {
208
+ lines.push(`.rs-icon-${name} { --rs-icon-content: "${name}"; }`);
209
+ }
210
+ return `${lines.join("\n")}
172
211
  `;
173
212
  }
174
- function S(t, e = {}) {
175
- const s = [];
176
- if (e.preload ?? L)
177
- for (const o of t.fonts)
178
- s.push({
213
+ function buildMaterialSymbolsHtmlTags(assets, options = {}) {
214
+ const tags = [];
215
+ if (options.preload ?? defaultPreload) {
216
+ for (const font of assets.fonts) {
217
+ tags.push({
179
218
  attrs: {
180
219
  as: "font",
181
220
  crossorigin: "",
182
- href: o.href,
221
+ href: font.href,
183
222
  rel: "preload",
184
223
  type: "font/woff2"
185
224
  },
186
225
  tag: "link",
187
226
  injectTo: "head"
188
227
  });
189
- return s.push({
228
+ }
229
+ }
230
+ tags.push({
190
231
  attrs: {
191
- href: t.cssHref,
232
+ href: assets.cssHref,
192
233
  rel: "stylesheet"
193
234
  },
194
235
  tag: "link",
195
236
  injectTo: "head"
196
- }), s;
237
+ });
238
+ return tags;
197
239
  }
198
- function O(t, e, s = {}) {
199
- const o = S(e, s).map(G).filter((n) => !t.includes(`href="${q(n)}"`));
200
- return o.length === 0 ? t : t.replace("</head>", `${o.map((n) => ` ${n}`).join(`
201
- `)}
240
+ function injectMaterialSymbolsHtmlLinks(html, assets, options = {}) {
241
+ const links = buildMaterialSymbolsHtmlTags(assets, options).map(formatHtmlLinkTag).filter((link) => !html.includes(`href="${getLinkHref(link)}"`));
242
+ return links.length === 0 ? html : html.replace("</head>", `${links.map((link) => ` ${link}`).join("\n")}
202
243
  </head>`);
203
244
  }
204
- async function V(t, e, s) {
205
- const o = (await import("subset-font")).default, n = [];
206
- for (const a of l) {
207
- const r = [...t.get(a) ?? []].sort();
208
- if (r.length === 0)
245
+ async function generateFontAssets(usages, devMode, base) {
246
+ const subsetFont = (await import("subset-font")).default;
247
+ const fonts = [];
248
+ for (const family of families) {
249
+ const names = [...usages.get(family) ?? []].sort();
250
+ if (names.length === 0) {
209
251
  continue;
210
- const i = B(a), c = await b(i), f = await o(c, r.join(" "), {
252
+ }
253
+ const sourcePath = resolveFontPath(family);
254
+ const source = await readFile(sourcePath);
255
+ const subset = await subsetFont(source, names.join(" "), {
211
256
  targetFormat: "woff2"
212
- }), h = M("sha256").update(f).digest("hex").slice(0, 8), w = `rs-material-symbols-${a}-${h}.woff2`;
213
- n.push({
214
- family: a,
215
- fileName: w,
216
- href: W(w, e, s),
217
- source: f
257
+ });
258
+ const hash = createHash("sha256").update(subset).digest("hex").slice(0, 8);
259
+ const fileName = `rs-material-symbols-${family}-${hash}.woff2`;
260
+ fonts.push({
261
+ family,
262
+ fileName,
263
+ href: fontHref(fileName, devMode, base),
264
+ source: subset
218
265
  });
219
266
  }
220
- return n;
267
+ return fonts;
221
268
  }
222
- function B(t) {
223
- return U.resolve(
224
- `${R[t]}/files/material-symbols-${t}-latin-${D[t]}-normal.woff2`
269
+ function resolveFontPath(family) {
270
+ return require$1.resolve(
271
+ `${familyPackages[family]}/files/material-symbols-${family}-latin-${familyFontVariants[family]}-normal.woff2`
225
272
  );
226
273
  }
227
- function W(t, e, s) {
228
- return e ? `/@robosophy-material-symbols/${t}` : F(s, `assets/${t}`);
274
+ function fontHref(fileName, devMode, base) {
275
+ return devMode ? `/@robosophy-material-symbols/${fileName}` : withBase(base, `assets/${fileName}`);
229
276
  }
230
- function G(t) {
231
- const e = Object.entries(t.attrs ?? {}).map(([s, o]) => o === "" ? s : `${s}="${o}"`).join(" ");
232
- return `<${t.tag}${e ? ` ${e}` : ""}>`;
277
+ function formatHtmlLinkTag(tag) {
278
+ const attrs = Object.entries(tag.attrs ?? {}).map(([name, value]) => value === "" ? name : `${name}="${value}"`).join(" ");
279
+ return `<${tag.tag}${attrs ? ` ${attrs}` : ""}>`;
233
280
  }
234
- function q(t) {
235
- return t.match(/\bhref="([^"]+)"/)?.[1] ?? "";
281
+ function getLinkHref(link) {
282
+ return link.match(/\bhref="([^"]+)"/)?.[1] ?? "";
236
283
  }
237
- function E(t, e) {
238
- const s = /<RsIcon\b([^>]*)>/g;
239
- let o;
240
- for (; o = s.exec(t); ) {
241
- const c = J(o[1] ?? ""), f = c.name ?? c[":name"], h = g(c.family ?? c[":family"]);
242
- f && m(e, { family: h ?? u, name: v(f) });
284
+ function collectFromSource(source, usages) {
285
+ const rsIconTagPattern = /<RsIcon\b([^>]*)>/g;
286
+ let tagMatch;
287
+ while (tagMatch = rsIconTagPattern.exec(source)) {
288
+ const attrs = parseStaticAttributes(tagMatch[1] ?? "");
289
+ const rawName = attrs.name ?? attrs[":name"];
290
+ const hasFamily = "family" in attrs || ":family" in attrs;
291
+ const rawFamily = attrs.family ?? attrs[":family"] ?? "";
292
+ if (rawName) {
293
+ const familyList = resolveFamilies(rawFamily, hasFamily);
294
+ const names = resolveNames(rawName);
295
+ for (const family of familyList) {
296
+ for (const name of names) {
297
+ addUsage(usages, { family, name });
298
+ }
299
+ }
300
+ }
243
301
  }
244
- const n = /\brsPrimeIcon\(\s*["']([a-z0-9_]+)["'](?:\s*,\s*\{([^)]*)\})?/g;
245
- let a;
246
- for (; a = n.exec(t); ) {
247
- const c = g(a[2]?.match(/\bfamily\s*:\s*["'](\w+)["']/)?.[1]);
248
- m(e, {
249
- family: c ?? u,
250
- name: a[1] ?? ""
302
+ const primeHelperPattern = /\brsPrimeIcon\(\s*["']([a-z0-9_]+)["'](?:\s*,\s*\{([^)]*)\})?/g;
303
+ let helperMatch;
304
+ while (helperMatch = primeHelperPattern.exec(source)) {
305
+ const family = toFamily(helperMatch[2]?.match(/\bfamily\s*:\s*["'](\w+)["']/)?.[1]);
306
+ addUsage(usages, {
307
+ family: family ?? defaultFamily,
308
+ name: helperMatch[1] ?? ""
251
309
  });
252
310
  }
253
- const r = /\bicon\s*:\s*["']([a-z0-9_]+)["']/g;
254
- let i;
255
- for (; i = r.exec(t); )
256
- m(e, {
257
- family: u,
258
- name: i[1] ?? ""
311
+ const objectIconPattern = /\bicon\s*:\s*["']([a-z0-9_]+)["']/g;
312
+ let objectMatch;
313
+ while (objectMatch = objectIconPattern.exec(source)) {
314
+ addUsage(usages, {
315
+ family: defaultFamily,
316
+ name: objectMatch[1] ?? ""
259
317
  });
318
+ }
260
319
  }
261
- function J(t) {
262
- const e = {}, s = /([:@\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
263
- let o;
264
- for (; o = s.exec(t); )
265
- e[o[1] ?? ""] = o[2] ?? o[3] ?? "";
266
- return e;
320
+ function parseStaticAttributes(source) {
321
+ const attrs = {};
322
+ const attrPattern = /([:@\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
323
+ let match;
324
+ while (match = attrPattern.exec(source)) {
325
+ attrs[match[1] ?? ""] = match[2] ?? match[3] ?? "";
326
+ }
327
+ return attrs;
267
328
  }
268
- function v(t) {
269
- return t.replace(/^['"](.+)['"]$/, "$1");
329
+ function unwrapStaticValue(value) {
330
+ return value.replace(/^['"](.+)['"]$/, "$1");
270
331
  }
271
- function m(t, e) {
272
- const s = e.family ?? u, o = e.name.trim();
273
- !l.includes(s) || !k.test(o) || t.get(s)?.add(o);
332
+ function addUsage(usages, icon) {
333
+ const family = icon.family ?? defaultFamily;
334
+ const name = icon.name.trim();
335
+ if (!families.includes(family) || !iconNamePattern.test(name)) {
336
+ return;
337
+ }
338
+ usages.get(family)?.add(name);
274
339
  }
275
- async function K() {
340
+ async function loadIconManifest() {
276
341
  try {
277
- const t = y(H(import.meta.url), ".."), e = y(t, "icon-manifest.json"), s = await b(e, "utf8");
278
- return JSON.parse(s);
342
+ const dir = join(fileURLToPath(import.meta.url), "..");
343
+ const manifestPath = join(dir, "icon-manifest.json");
344
+ const source = await readFile(manifestPath, "utf8");
345
+ return JSON.parse(source);
279
346
  } catch {
280
347
  return null;
281
348
  }
282
349
  }
283
- function g(t) {
284
- const e = t ? v(t) : "";
285
- return l.includes(e) ? e : void 0;
350
+ function toFamily(value) {
351
+ const normalized = value ? unwrapStaticValue(value) : "";
352
+ return families.includes(normalized) ? normalized : void 0;
286
353
  }
287
- function Q() {
288
- return new Map(l.map((t) => [t, /* @__PURE__ */ new Set()]));
354
+ function resolveNames(rawName) {
355
+ const stringLiterals = /["']([a-z0-9_]+)["']/g;
356
+ let strMatch;
357
+ const names = [];
358
+ while (strMatch = stringLiterals.exec(rawName)) {
359
+ const candidate = strMatch[1] ?? "";
360
+ if (iconNamePattern.test(candidate)) {
361
+ names.push(candidate);
362
+ }
363
+ }
364
+ if (names.length === 0) {
365
+ const name = unwrapStaticValue(rawName);
366
+ if (iconNamePattern.test(name)) {
367
+ names.push(name);
368
+ }
369
+ }
370
+ return names;
289
371
  }
290
- async function j(t) {
372
+ function resolveFamilies(rawFamily, hasFamily = true) {
373
+ const family = toFamily(rawFamily);
374
+ if (family) return [family];
375
+ const stringLiterals = /["'](\w+)["']/g;
376
+ let strMatch;
377
+ const found = /* @__PURE__ */ new Set();
378
+ while (strMatch = stringLiterals.exec(rawFamily)) {
379
+ const candidate = strMatch[1] ?? "";
380
+ const f = toFamily(candidate);
381
+ if (f) {
382
+ found.add(f);
383
+ }
384
+ }
385
+ if (found.size > 0) return [...found];
386
+ if (!hasFamily) return [defaultFamily];
387
+ return [...families];
388
+ }
389
+ function createUsageMap() {
390
+ return new Map(families.map((family) => [family, /* @__PURE__ */ new Set()]));
391
+ }
392
+ async function listSourceFiles(root) {
291
393
  try {
292
- const e = await x(t, { withFileTypes: !0 });
293
- return (await Promise.all(
294
- e.map(async (o) => {
295
- const n = y(t, o.name);
296
- return o.isDirectory() ? I.has(o.name) ? [] : j(n) : z.has(P(o.name)) ? [n] : [];
394
+ const entries = await readdir(root, { withFileTypes: true });
395
+ const files = await Promise.all(
396
+ entries.map(async (entry) => {
397
+ const path = join(root, entry.name);
398
+ if (entry.isDirectory()) {
399
+ return skippedDirs.has(entry.name) ? [] : listSourceFiles(path);
400
+ }
401
+ return sourceExtensions.has(extname(entry.name)) ? [path] : [];
297
402
  })
298
- )).flat();
403
+ );
404
+ return files.flat();
299
405
  } catch {
300
406
  return [];
301
407
  }
302
408
  }
303
- function F(t, e) {
304
- return `${t.endsWith("/") ? t : `${t}/`}${e}`.replaceAll(`${N}`, "/");
409
+ function withBase(base, path) {
410
+ const cleanBase = base.endsWith("/") ? base : `${base}/`;
411
+ return `${cleanBase}${path}`.replaceAll(`${sep}`, "/");
305
412
  }
306
- function ot(t) {
307
- return l.map((e) => `${e}: ${[...t.get(e) ?? []].sort().join(", ")}`).join(`
308
- `);
413
+ function formatDetectedMaterialSymbols(usages) {
414
+ return families.map((family) => `${family}: ${[...usages.get(family) ?? []].sort().join(", ")}`).join("\n");
309
415
  }
310
416
  export {
311
- C as buildMaterialSymbolsCss,
312
- S as buildMaterialSymbolsHtmlTags,
313
- A as collectMaterialSymbolUsages,
314
- ot as formatDetectedMaterialSymbols,
315
- O as injectMaterialSymbolsHtmlLinks,
316
- st as robosophyMaterialSymbols
417
+ buildMaterialSymbolsCss,
418
+ buildMaterialSymbolsHtmlTags,
419
+ collectMaterialSymbolUsages,
420
+ formatDetectedMaterialSymbols,
421
+ injectMaterialSymbolsHtmlLinks,
422
+ robosophyMaterialSymbols
317
423
  };
318
424
  //# sourceMappingURL=vite.js.map