@dubium/icons 0.0.2-alpha.2 → 0.0.2-alpha.3

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.
@@ -1,13 +1,14 @@
1
- import { require___vite_browser_external as e } from "../_virtual/__vite-browser-external.js";
1
+ import { readFile as e, readdir as t } from "node:fs/promises";
2
+ import { extname as n, isAbsolute as r, join as i, relative as a, resolve as o } from "node:path";
2
3
  //#region src/icons/vite/index.ts
3
- var t = e(), n = "virtual:@dubium/icons-registry", r = `\0${n}`, i = /* @__PURE__ */ new Set([
4
+ var s = "virtual:@dubium/icons-registry", c = `\0${s}`, l = /* @__PURE__ */ new Set([
4
5
  ".js",
5
6
  ".jsx",
6
7
  ".mjs",
7
8
  ".cjs",
8
9
  ".ts",
9
10
  ".tsx"
10
- ]), a = /* @__PURE__ */ new Set([
11
+ ]), u = /* @__PURE__ */ new Set([
11
12
  ".git",
12
13
  ".next",
13
14
  ".nuxt",
@@ -17,14 +18,14 @@ var t = e(), n = "virtual:@dubium/icons-registry", r = `\0${n}`, i = /* @__PURE_
17
18
  "coverage",
18
19
  "dist",
19
20
  "node_modules"
20
- ]), o = (e) => e.replaceAll("\\", "/"), s = (e, t) => {
21
+ ]), d = (e) => e.replaceAll("\\", "/"), f = (e, t) => {
21
22
  if (e.size !== t.size) return !1;
22
23
  for (let n of e) if (!t.has(n)) return !1;
23
24
  return !0;
24
- }, c = (e) => {
25
+ }, p = (e) => {
25
26
  let t = e.map((e) => e.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"));
26
27
  return RegExp(`<\\s*(?:${t.join("|")})\\b`, "gu");
27
- }, l = (e, t) => {
28
+ }, m = (e, t) => {
28
29
  let n = null, r = !1, i = 0;
29
30
  for (let a = t; a < e.length; a += 1) {
30
31
  let t = e[a];
@@ -55,112 +56,112 @@ var t = e(), n = "virtual:@dubium/icons-registry", r = `\0${n}`, i = /* @__PURE_
55
56
  if (t === ">" && i === 0) return a;
56
57
  }
57
58
  return -1;
58
- }, u = (e) => {
59
+ }, h = (e) => {
59
60
  let t = /\bname\s*=\s*(["'])(.*?)\1/su.exec(e);
60
61
  if (t) return t[2].trim();
61
62
  let n = /\bname\s*=\s*\{\s*(?:(["'])(.*?)\1|`([^`${}]*)`)\s*\}/su.exec(e);
62
63
  return n ? (n[2] ?? n[3] ?? "").trim() : null;
63
- }, d = (e) => /\bname\s*=/u.test(e), f = (e, t) => {
64
- let n = /* @__PURE__ */ new Set(), r = c(t), i = 0;
64
+ }, g = (e) => /\bname\s*=/u.test(e), _ = (e, t) => {
65
+ let n = /* @__PURE__ */ new Set(), r = p(t), i = 0;
65
66
  for (let t of e.matchAll(r)) {
66
- let r = t.index ?? 0, a = l(e, r);
67
+ let r = t.index ?? 0, a = m(e, r);
67
68
  if (a === -1) continue;
68
- let o = e.slice(r, a + 1), s = u(o);
69
+ let o = e.slice(r, a + 1), s = h(o);
69
70
  if (s) {
70
71
  n.add(s);
71
72
  continue;
72
73
  }
73
- d(o) && (i += 1);
74
+ g(o) && (i += 1);
74
75
  }
75
76
  return {
76
77
  dynamicNames: i,
77
78
  icons: n
78
79
  };
79
- }, p = async (e) => {
80
- let n;
80
+ }, v = async (e) => {
81
+ let r;
81
82
  try {
82
- n = await (0, t.readdir)(e, { withFileTypes: !0 });
83
+ r = await t(e, { withFileTypes: !0 });
83
84
  } catch {
84
85
  return [];
85
86
  }
86
- let r = [];
87
- for (let o of n) {
88
- let n = (0, t.join)(e, o.name);
89
- if (o.isDirectory()) {
90
- a.has(o.name) || r.push(...await p(n));
87
+ let a = [];
88
+ for (let t of r) {
89
+ let r = i(e, t.name);
90
+ if (t.isDirectory()) {
91
+ u.has(t.name) || a.push(...await v(r));
91
92
  continue;
92
93
  }
93
- o.isFile() && i.has((0, t.extname)(o.name).toLowerCase()) && r.push(n);
94
+ t.isFile() && l.has(n(t.name).toLowerCase()) && a.push(r);
94
95
  }
95
- return r;
96
- }, m = (e, t) => `/**
96
+ return a;
97
+ }, y = (e, t) => `/**
97
98
  * AUTO-GENERATED in memory by @dubium/icons/vite.
98
99
  * Contains only icons used by the current application.
99
100
  */
100
101
  export const iconRegistry = {
101
102
  ${e.map((e) => `\t${JSON.stringify(e)}: () => import(${JSON.stringify(`${t}/icons/${e}`)}),`).join("\n")}
102
103
  }
103
- `, h = (e = {}) => {
104
- let a = e.componentNames?.length ? [...e.componentNames] : ["Icon"], c = e.packageName ?? "@dubium/icons", l = e.scan?.length ? [...e.scan] : ["src"], u = new Set(e.include ?? []), d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = process.cwd(), _, v = () => {
105
- let e = new Set(u);
106
- for (let t of d.values()) for (let n of t) e.add(n);
104
+ `, b = (t = {}) => {
105
+ let i = t.componentNames?.length ? [...t.componentNames] : ["Icon"], u = t.packageName ?? "@dubium/icons", p = t.scan?.length ? [...t.scan] : ["src"], m = new Set(t.include ?? []), h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), b = process.cwd(), x, S = () => {
106
+ let e = new Set(m);
107
+ for (let t of h.values()) for (let n of t) e.add(n);
107
108
  return [...e].sort((e, t) => e.localeCompare(t));
108
- }, y = async (e) => {
109
- let n = o(e);
110
- if (!i.has((0, t.extname)(e).toLowerCase())) return d.delete(n), h.delete(n), !1;
111
- let r;
109
+ }, C = async (t) => {
110
+ let r = d(t);
111
+ if (!l.has(n(t).toLowerCase())) return h.delete(r), g.delete(r), !1;
112
+ let a;
112
113
  try {
113
- r = await (0, t.readFile)(e, "utf8");
114
+ a = await e(t, "utf8");
114
115
  } catch {
115
- let e = d.delete(n), t = h.delete(n);
116
+ let e = h.delete(r), t = g.delete(r);
116
117
  return e || t;
117
118
  }
118
- let c = d.get(n) ?? /* @__PURE__ */ new Set(), l = h.get(n) ?? 0, u = f(r, a);
119
- return d.set(n, u.icons), u.dynamicNames > 0 ? h.set(n, u.dynamicNames) : h.delete(n), !s(c, u.icons) || l !== u.dynamicNames;
120
- }, b = async (e) => {
121
- d.clear(), h.clear();
122
- for (let n of l) {
123
- let r = await p((0, t.isAbsolute)(n) ? n : (0, t.resolve)(g, n));
124
- for (let t of r) e?.addWatchFile(t), await y(t);
119
+ let o = h.get(r) ?? /* @__PURE__ */ new Set(), s = g.get(r) ?? 0, c = _(a, i);
120
+ return h.set(r, c.icons), c.dynamicNames > 0 ? g.set(r, c.dynamicNames) : g.delete(r), !f(o, c.icons) || s !== c.dynamicNames;
121
+ }, w = async (e) => {
122
+ h.clear(), g.clear();
123
+ for (let t of p) {
124
+ let n = await v(r(t) ? t : o(b, t));
125
+ for (let t of n) e?.addWatchFile(t), await C(t);
125
126
  }
126
- }, x = () => h.size === 0 ? null : `[@dubium/icons] Найдены динамические name у <Icon>:\n${[...h.entries()].map(([e, n]) => ` - ${o((0, t.relative)(g, e))}: ${n}`).join("\n")}\nVite не может определить такие иконки на этапе сборки. Добавьте допустимые имена в dubiumIcons({ include: [...] }).`, S = () => {
127
- if (!_) return;
128
- let e = _.moduleGraph.getModuleById(r);
129
- e && _.moduleGraph.invalidateModule(e), _.ws.send({ type: "full-reload" });
127
+ }, T = () => g.size === 0 ? null : `[@dubium/icons] Найдены динамические name у <Icon>:\n${[...g.entries()].map(([e, t]) => ` - ${d(a(b, e))}: ${t}`).join("\n")}\nVite не может определить такие иконки на этапе сборки. Добавьте допустимые имена в dubiumIcons({ include: [...] }).`, E = () => {
128
+ if (!x) return;
129
+ let e = x.moduleGraph.getModuleById(c);
130
+ e && x.moduleGraph.invalidateModule(e), x.ws.send({ type: "full-reload" });
130
131
  };
131
132
  return {
132
133
  name: "dubium-icons",
133
134
  enforce: "pre",
134
135
  configResolved(e) {
135
- g = e.root;
136
+ b = e.root;
136
137
  },
137
138
  async buildStart() {
138
- await b(this);
139
- let t = x();
140
- t && (e.strictDynamicNames ? this.error(t) : this.warn(t));
139
+ await w(this);
140
+ let e = T();
141
+ e && (t.strictDynamicNames ? this.error(e) : this.warn(e));
141
142
  },
142
143
  configureServer(e) {
143
- _ = e;
144
+ x = e;
144
145
  let t = async (e) => {
145
- await y(e) && S();
146
+ await C(e) && E();
146
147
  }, n = async (e) => {
147
- let t = o(e);
148
- (d.delete(t) || h.delete(t)) && S();
148
+ let t = d(e);
149
+ (h.delete(t) || g.delete(t)) && E();
149
150
  };
150
151
  return e.watcher.on("add", t), e.watcher.on("unlink", n), () => {
151
152
  e.watcher.off("add", t), e.watcher.off("unlink", n);
152
153
  };
153
154
  },
154
155
  resolveId(e) {
155
- return e === n ? r : null;
156
+ return e === s ? c : null;
156
157
  },
157
158
  load(e) {
158
- return e === r ? m(v(), c) : null;
159
+ return e === c ? y(S(), u) : null;
159
160
  },
160
161
  async handleHotUpdate(e) {
161
- if (await y(e.file)) return S(), [];
162
+ if (await C(e.file)) return E(), [];
162
163
  }
163
164
  };
164
165
  };
165
166
  //#endregion
166
- export { h as default, h as dubiumIcons };
167
+ export { b as default, b as dubiumIcons };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dubium/icons",
3
- "version": "0.0.2-alpha.2",
3
+ "version": "0.0.2-alpha.3",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist"
@@ -1,8 +0,0 @@
1
- import { __commonJSMin as e } from "./_rolldown/runtime.js";
2
- //#region __vite-browser-external
3
- var t = /* @__PURE__ */ e(((e, t) => {
4
- t.exports = {};
5
- }));
6
- //#endregion
7
- export default t();
8
- export { t as require___vite_browser_external };
@@ -1,4 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var e = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports);
3
- //#endregion
4
- export { e as __commonJSMin };