@memobit/icons 1.0.0 → 1.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.
@@ -0,0 +1,8 @@
1
+ import { __commonJSMin } from "./_rolldown/runtime.js";
2
+ //#region __vite-browser-external
3
+ var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4
+ module.exports = {};
5
+ }));
6
+ //#endregion
7
+ export default require___vite_browser_external();
8
+ export { require___vite_browser_external };
@@ -0,0 +1,4 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
3
+ //#endregion
4
+ export { __commonJSMin };
@@ -0,0 +1,2 @@
1
+ export declare const iconModules: Readonly<Record<string, string>>;
2
+ export declare const iconNameList: readonly string[];
@@ -0,0 +1,501 @@
1
+ //#region src/iconModules.ts
2
+ var iconModules = {
3
+ "active": "active",
4
+ "afternoon": "afternoon",
5
+ "air-conditioning": "airConditioning",
6
+ "ajax": "ajax",
7
+ "alarm": "alarm",
8
+ "analysis": "analysis",
9
+ "angular": "angular",
10
+ "announcement": "announcement",
11
+ "anomaly": "anomaly",
12
+ "ant": "ant",
13
+ "antenna": "antenna",
14
+ "api": "api",
15
+ "appliances": "appliances",
16
+ "archive": "archive",
17
+ "arrow-bidirectional-horizontal": "arrowBidirectionalHorizontal",
18
+ "arrow-bidirectional-vertical": "arrowBidirectionalVertical",
19
+ "arrow-down": "arrowDown",
20
+ "arrow-left": "arrowLeft",
21
+ "arrow-right": "arrowRight",
22
+ "arrow-up": "arrowUp",
23
+ "atom": "atom",
24
+ "avocado": "avocado",
25
+ "backup": "backup",
26
+ "badge": "badge",
27
+ "balcony": "balcony",
28
+ "ball": "ball",
29
+ "balloon": "balloon",
30
+ "banana": "banana",
31
+ "bank": "bank",
32
+ "basement": "basement",
33
+ "bat": "bat",
34
+ "bath": "bath",
35
+ "battery-charging": "batteryCharging",
36
+ "battery-empty": "batteryEmpty",
37
+ "battery-full": "batteryFull",
38
+ "battery-half": "batteryHalf",
39
+ "beans": "beans",
40
+ "bear": "bear",
41
+ "bed": "bed",
42
+ "bee": "bee",
43
+ "beer": "beer",
44
+ "bell": "bell",
45
+ "benefit": "benefit",
46
+ "bill": "bill",
47
+ "birthday-cake": "birthdayCake",
48
+ "blood": "blood",
49
+ "blueberries": "blueberries",
50
+ "bones": "bones",
51
+ "book": "book",
52
+ "bow": "bow",
53
+ "brain": "brain",
54
+ "bread": "bread",
55
+ "breakfast": "breakfast",
56
+ "briefcase": "briefcase",
57
+ "brightness": "brightness",
58
+ "broken-heart": "brokenHeart",
59
+ "broom": "broom",
60
+ "bug": "bug",
61
+ "building": "building",
62
+ "bullet": "bullet",
63
+ "bunny": "bunny",
64
+ "burst": "burst",
65
+ "bus": "bus",
66
+ "butterfly": "butterfly",
67
+ "button-device": "buttonDevice",
68
+ "cake": "cake",
69
+ "calculator": "calculator",
70
+ "calendar": "calendar",
71
+ "calendar-day": "calendarDay",
72
+ "calendar-month": "calendarMonth",
73
+ "calendar-week": "calendarWeek",
74
+ "calendar-year": "calendarYear",
75
+ "calibrate": "calibrate",
76
+ "camera": "camera",
77
+ "candy": "candy",
78
+ "car": "car",
79
+ "carbs": "carbs",
80
+ "caret-down": "caretDown",
81
+ "caret-left": "caretLeft",
82
+ "caret-right": "caretRight",
83
+ "caret-up": "caretUp",
84
+ "carrot": "carrot",
85
+ "cat": "cat",
86
+ "categories": "categories",
87
+ "caterpillar": "caterpillar",
88
+ "cd-dvd": "cdDvd",
89
+ "certificate": "certificate",
90
+ "chart": "chart",
91
+ "checkmark": "checkmark",
92
+ "cheese": "cheese",
93
+ "cherries": "cherries",
94
+ "chestnut": "chestnut",
95
+ "chicken": "chicken",
96
+ "chocolate": "chocolate",
97
+ "christmas-tree": "christmasTree",
98
+ "cigarette": "cigarette",
99
+ "clear": "clear",
100
+ "clipboard": "clipboard",
101
+ "closet": "closet",
102
+ "cloud": "cloud",
103
+ "coffee": "coffee",
104
+ "comment": "comment",
105
+ "compass": "compass",
106
+ "confetti": "confetti",
107
+ "connected": "connected",
108
+ "context": "context",
109
+ "cook": "cook",
110
+ "cookies": "cookies",
111
+ "cooling": "cooling",
112
+ "corn": "corn",
113
+ "correlation": "correlation",
114
+ "cow": "cow",
115
+ "cpu": "cpu",
116
+ "credit-card": "creditCard",
117
+ "crystal-globe": "crystalGlobe",
118
+ "cube": "cube",
119
+ "cucumber": "cucumber",
120
+ "dashboard": "dashboard",
121
+ "death": "death",
122
+ "defect": "defect",
123
+ "delete": "delete_",
124
+ "dental": "dental",
125
+ "deselect-all": "deselectAll",
126
+ "dessert": "dessert",
127
+ "detach": "detach",
128
+ "devices": "devices",
129
+ "digestive": "digestive",
130
+ "digital": "digital",
131
+ "dinner": "dinner",
132
+ "dinosaur": "dinosaur",
133
+ "dishwasher": "dishwasher",
134
+ "dns": "dns",
135
+ "doctor": "doctor",
136
+ "document": "document",
137
+ "documents": "documents",
138
+ "dog": "dog",
139
+ "dolphin": "dolphin",
140
+ "door": "door",
141
+ "dot": "dot",
142
+ "download": "download",
143
+ "dragon": "dragon",
144
+ "drying-machine": "dryingMachine",
145
+ "duck": "duck",
146
+ "duplicates": "duplicates",
147
+ "ears": "ears",
148
+ "earth": "earth",
149
+ "edit": "edit",
150
+ "egg": "egg",
151
+ "eggplant": "eggplant",
152
+ "elephant": "elephant",
153
+ "empty": "empty",
154
+ "endocrine": "endocrine",
155
+ "enlarge": "enlarge",
156
+ "equalizer": "equalizer",
157
+ "evening": "evening",
158
+ "expense": "expense",
159
+ "export": "export_",
160
+ "external-link": "externalLink",
161
+ "fan": "fan",
162
+ "favorite": "favorite",
163
+ "fibers": "fibers",
164
+ "file": "file",
165
+ "filetype-avi": "filetypeAvi",
166
+ "filetype-bat": "filetypeBat",
167
+ "filetype-c": "filetypeC",
168
+ "filetype-css": "filetypeCss",
169
+ "filetype-csv": "filetypeCsv",
170
+ "filetype-doc": "filetypeDoc",
171
+ "filetype-docx": "filetypeDocx",
172
+ "filetype-gif": "filetypeGif",
173
+ "filetype-html": "filetypeHtml",
174
+ "filetype-ico": "filetypeIco",
175
+ "filetype-ini": "filetypeIni",
176
+ "filetype-javascript": "filetypeJavascript",
177
+ "filetype-jpeg": "filetypeJpeg",
178
+ "filetype-jpg": "filetypeJpg",
179
+ "filetype-json": "filetypeJson",
180
+ "filetype-less": "filetypeLess",
181
+ "filetype-mp3": "filetypeMp3",
182
+ "filetype-mp4": "filetypeMp4",
183
+ "filetype-mpg": "filetypeMpg",
184
+ "filetype-pdf": "filetypePdf",
185
+ "filetype-php": "filetypePhp",
186
+ "filetype-png": "filetypePng",
187
+ "filetype-ppt": "filetypePpt",
188
+ "filetype-psd": "filetypePsd",
189
+ "filetype-rar": "filetypeRar",
190
+ "filetype-sass": "filetypeSass",
191
+ "filetype-sql": "filetypeSql",
192
+ "filetype-tiff": "filetypeTiff",
193
+ "filetype-txt": "filetypeTxt",
194
+ "filetype-typescript": "filetypeTypescript",
195
+ "filetype-wav": "filetypeWav",
196
+ "filetype-xls": "filetypeXls",
197
+ "filetype-xlsx": "filetypeXlsx",
198
+ "filetype-xml": "filetypeXml",
199
+ "filetype-zip": "filetypeZip",
200
+ "filters": "filters",
201
+ "fire": "fire",
202
+ "firewall": "firewall",
203
+ "fireworks": "fireworks",
204
+ "fish": "fish",
205
+ "fishing-rod": "fishingRod",
206
+ "fog": "fog",
207
+ "folder": "folder",
208
+ "folder-open": "folderOpen",
209
+ "fondue": "fondue",
210
+ "food": "food",
211
+ "french-fries": "frenchFries",
212
+ "fridge": "fridge",
213
+ "fruits": "fruits",
214
+ "furniture": "furniture",
215
+ "gallery": "gallery",
216
+ "gas-detector": "gasDetector",
217
+ "gateway": "gateway",
218
+ "gauge-high": "gaugeHigh",
219
+ "gauge-low": "gaugeLow",
220
+ "gauge-medium": "gaugeMedium",
221
+ "gift-box": "giftBox",
222
+ "girl": "girl",
223
+ "github": "github",
224
+ "glass": "glass",
225
+ "gloves": "gloves",
226
+ "glycemic-index": "glycemicIndex",
227
+ "goat": "goat",
228
+ "graduation": "graduation",
229
+ "grid": "grid",
230
+ "group": "group",
231
+ "gun": "gun",
232
+ "hammer": "hammer",
233
+ "handshake": "handshake",
234
+ "hd": "hd",
235
+ "headphones": "headphones",
236
+ "heart": "heart",
237
+ "heating": "heating",
238
+ "help": "help",
239
+ "hiking": "hiking",
240
+ "history": "history",
241
+ "home": "home",
242
+ "hospital": "hospital",
243
+ "humidity": "humidity",
244
+ "ice-cream": "iceCream",
245
+ "identity": "identity",
246
+ "image": "image",
247
+ "import": "import_",
248
+ "inactive": "inactive",
249
+ "incognito": "incognito",
250
+ "information": "information",
251
+ "ingredients": "ingredients",
252
+ "ink-cartridge": "inkCartridge",
253
+ "insurance": "insurance",
254
+ "ir-emitter": "irEmitter",
255
+ "job": "job",
256
+ "joystick": "joystick",
257
+ "jupiter": "jupiter",
258
+ "key": "key",
259
+ "knife": "knife",
260
+ "laboratory": "laboratory",
261
+ "language": "language",
262
+ "lantern": "lantern",
263
+ "layers": "layers",
264
+ "leaf": "leaf",
265
+ "lemon": "lemon",
266
+ "light-bulb": "lightBulb",
267
+ "light-switch": "lightSwitch",
268
+ "lightning": "lightning",
269
+ "link": "link",
270
+ "linkedin": "linkedin",
271
+ "lipids": "lipids",
272
+ "list": "list",
273
+ "liver": "liver",
274
+ "location": "location",
275
+ "lock": "lock",
276
+ "lock-open": "lockOpen",
277
+ "logout": "logout",
278
+ "lollipop": "lollipop",
279
+ "lunch": "lunch",
280
+ "lungs": "lungs",
281
+ "magnet": "magnet",
282
+ "mail": "mail",
283
+ "manage": "manage",
284
+ "map": "map",
285
+ "mapping": "mapping",
286
+ "mars": "mars",
287
+ "meat": "meat",
288
+ "meet": "meet",
289
+ "melon": "melon",
290
+ "memory": "memory",
291
+ "mental": "mental",
292
+ "menu-hamburger": "menuHamburger",
293
+ "mercury": "mercury",
294
+ "microphone": "microphone",
295
+ "microscope": "microscope",
296
+ "microwave": "microwave",
297
+ "milk": "milk",
298
+ "minimum": "minimum",
299
+ "minus": "minus",
300
+ "money": "money",
301
+ "monitor": "monitor",
302
+ "monkey": "monkey",
303
+ "moon": "moon",
304
+ "morning": "morning",
305
+ "motion": "motion",
306
+ "mouse": "mouse",
307
+ "movie": "movie",
308
+ "mushroom": "mushroom",
309
+ "musical-note": "musicalNote",
310
+ "mute": "mute",
311
+ "nas": "nas",
312
+ "neptune": "neptune",
313
+ "nervous": "nervous",
314
+ "network": "network",
315
+ "next": "next",
316
+ "night": "night",
317
+ "ninja": "ninja",
318
+ "noon": "noon",
319
+ "nose": "nose",
320
+ "not-found": "notFound",
321
+ "notes": "notes",
322
+ "notice": "notice",
323
+ "offline": "offline",
324
+ "old-person": "oldPerson",
325
+ "olives": "olives",
326
+ "online": "online",
327
+ "optimization": "optimization",
328
+ "other": "other",
329
+ "outdoor": "outdoor",
330
+ "ownership": "ownership",
331
+ "paint": "paint",
332
+ "pause": "pause",
333
+ "pawn": "pawn",
334
+ "peanut": "peanut",
335
+ "pear": "pear",
336
+ "penguin": "penguin",
337
+ "pension": "pension",
338
+ "pepper": "pepper",
339
+ "pharmacy": "pharmacy",
340
+ "phone": "phone",
341
+ "pig": "pig",
342
+ "pill": "pill",
343
+ "pin": "pin",
344
+ "pizza": "pizza",
345
+ "plane": "plane",
346
+ "play": "play",
347
+ "plug": "plug",
348
+ "plus": "plus",
349
+ "pluto": "pluto",
350
+ "polenta": "polenta",
351
+ "police": "police",
352
+ "police-man": "policeMan",
353
+ "popcorn": "popcorn",
354
+ "portions": "portions",
355
+ "potato": "potato",
356
+ "power": "power",
357
+ "predictions": "predictions",
358
+ "prescription": "prescription",
359
+ "previous": "previous",
360
+ "printer": "printer",
361
+ "proteins": "proteins",
362
+ "pudding": "pudding",
363
+ "pumpkin": "pumpkin",
364
+ "purifier": "purifier",
365
+ "puzzle": "puzzle",
366
+ "radio": "radio",
367
+ "rain": "rain",
368
+ "rainbow": "rainbow",
369
+ "raspberry": "raspberry",
370
+ "reading": "reading",
371
+ "referral": "referral",
372
+ "reload": "reload",
373
+ "repeat": "repeat",
374
+ "report": "report",
375
+ "reproductive": "reproductive",
376
+ "return": "returnIcon",
377
+ "rice": "rice",
378
+ "robot": "robot",
379
+ "rocket": "rocket",
380
+ "romania-flag": "romaniaFlag",
381
+ "rooms": "rooms",
382
+ "router": "router",
383
+ "ruler": "ruler",
384
+ "running": "running",
385
+ "salad": "salad",
386
+ "salt": "salt",
387
+ "santa": "santa",
388
+ "satellite": "satellite",
389
+ "saturn": "saturn",
390
+ "save": "save",
391
+ "scales": "scales",
392
+ "scan": "scan",
393
+ "school": "school",
394
+ "scissors": "scissors",
395
+ "score": "score",
396
+ "scss": "scss",
397
+ "sd": "sd",
398
+ "search": "search",
399
+ "security": "security",
400
+ "seeds": "seeds",
401
+ "sequence": "sequence",
402
+ "settings": "settings",
403
+ "shield": "shield",
404
+ "ship": "ship",
405
+ "shopping-cart": "shoppingCart",
406
+ "shrink": "shrink",
407
+ "shuffle": "shuffle",
408
+ "signal-full": "signalFull",
409
+ "signal-low": "signalLow",
410
+ "signal-medium": "signalMedium",
411
+ "skin": "skin",
412
+ "skull": "skull",
413
+ "smartphone": "smartphone",
414
+ "smb": "smb",
415
+ "smoke-detector": "smokeDetector",
416
+ "snake": "snake",
417
+ "snow": "snow",
418
+ "snowman": "snowman",
419
+ "sofa": "sofa",
420
+ "soft-drink": "softDrink",
421
+ "soup": "soup",
422
+ "sources": "sources",
423
+ "sparkle": "sparkle",
424
+ "speaker": "speaker",
425
+ "speedometer": "speedometer",
426
+ "square": "square",
427
+ "ssl": "ssl",
428
+ "staple": "staple",
429
+ "star": "star",
430
+ "status": "status",
431
+ "stethoscope": "stethoscope",
432
+ "stop": "stop",
433
+ "stop-sign": "stopSign",
434
+ "storm": "storm",
435
+ "strawberry": "strawberry",
436
+ "streaming": "streaming",
437
+ "strength": "strength",
438
+ "sugar": "sugar",
439
+ "sun": "sun",
440
+ "surgery": "surgery",
441
+ "synchronize": "synchronize",
442
+ "table": "table",
443
+ "target": "target",
444
+ "taxi": "taxi",
445
+ "technical": "technical",
446
+ "teeth": "teeth",
447
+ "telescope": "telescope",
448
+ "theater": "theater",
449
+ "theme-picker": "themePicker",
450
+ "thermometer": "thermometer",
451
+ "threshold": "threshold",
452
+ "time": "time",
453
+ "toggle-off": "toggleOff",
454
+ "toggle-on": "toggleOn",
455
+ "tomato": "tomato",
456
+ "toolbox": "toolbox",
457
+ "train": "train",
458
+ "transactions": "transactions",
459
+ "transport-box": "transportBox",
460
+ "tree": "tree",
461
+ "trend-down": "trendDown",
462
+ "trend-up": "trendUp",
463
+ "trip": "trip",
464
+ "trophy": "trophy",
465
+ "tune": "tune",
466
+ "turkey": "turkey",
467
+ "turtle": "turtle",
468
+ "tv": "tv",
469
+ "unarchive": "unarchive",
470
+ "unassociated": "unassociated",
471
+ "ungroup": "ungroup",
472
+ "unmute": "unmute",
473
+ "upload": "upload",
474
+ "upnp": "upnp",
475
+ "uranus": "uranus",
476
+ "user": "user",
477
+ "users": "users",
478
+ "vacuum": "vacuum",
479
+ "vegetables": "vegetables",
480
+ "venus": "venus",
481
+ "vertical-dots": "verticalDots",
482
+ "video": "video",
483
+ "view": "view",
484
+ "virus": "virus",
485
+ "wait": "wait",
486
+ "wan": "wan",
487
+ "warning": "warning",
488
+ "washing-machine": "washingMachine",
489
+ "water-leak": "waterLeak",
490
+ "web": "web",
491
+ "website-crawl": "websiteCrawl",
492
+ "wifi": "wifi",
493
+ "wind": "wind",
494
+ "workout": "workout",
495
+ "wrench": "wrench",
496
+ "yoga": "yoga",
497
+ "youtube": "youtube"
498
+ };
499
+ Object.keys(iconModules);
500
+ //#endregion
501
+ export { iconModules };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ interface TrimPlugin {
2
+ name: string;
3
+ enforce: 'pre';
4
+ resolveId(source: string): string | null;
5
+ load(id: string): string | null;
6
+ }
7
+ export interface MemobitIconsOptions {
8
+ /**
9
+ * Names the source scan cannot see because they only exist at runtime — a value from a
10
+ * database, an API response, or an icon picker. Pass 'all' to keep the whole set, which
11
+ * is what an app with a picker needs.
12
+ */
13
+ include?: readonly string[] | 'all';
14
+ /** Directories to scan, relative to `root`. Defaults to ['src']. */
15
+ scanDirs?: readonly string[];
16
+ /**
17
+ * Installed packages whose build output also names icons. Defaults to ['@memobit/libs'],
18
+ * whose components render `<Icon name="caret-down" />` and the like internally — scanning
19
+ * only the app would strip those and break the components at runtime.
20
+ */
21
+ scanPackages?: readonly string[];
22
+ /** Project root. Defaults to the current working directory. */
23
+ root?: string;
24
+ /** Log which icons were kept. Useful when a trim drops something unexpectedly. */
25
+ debug?: boolean;
26
+ }
27
+ /**
28
+ * Replaces the full 495-icon `iconMap` with one holding only the icons an app actually
29
+ * uses, so a bundler can drop the rest.
30
+ *
31
+ * `<Icon name="..." />` resolves through a string key, which no bundler can narrow, so an
32
+ * app that renders a single icon still ships all of them. This scans the app's own source
33
+ * for strings matching a real icon name and generates a map of just those, which the
34
+ * library imports in place of the real one.
35
+ *
36
+ * Opting in is deliberate. A name that only exists in a database or an API response is
37
+ * invisible to any source scan, and trimming it away would break icons at runtime with no
38
+ * build error. An app that does not use this plugin keeps the full set and behaves exactly
39
+ * as before. An app whose names are user-chosen — anything with an icon picker — should
40
+ * pass `include: 'all'`, which keeps everything and simply does nothing.
41
+ */
42
+ export declare const memobitIcons: (options?: MemobitIconsOptions) => TrimPlugin;
43
+ export {};
package/dist/vite.js ADDED
@@ -0,0 +1,99 @@
1
+ import { require___vite_browser_external } from "./_virtual/__vite-browser-external.js";
2
+ import { iconModules } from "./iconModules.js";
3
+ import { readFileSync, readdirSync } from "node:fs";
4
+ import { dirname, extname, join, resolve } from "node:path";
5
+ //#region src/vite.ts
6
+ var import___vite_browser_external = require___vite_browser_external();
7
+ var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
8
+ ".ts",
9
+ ".tsx",
10
+ ".js",
11
+ ".jsx",
12
+ ".mts",
13
+ ".mjs"
14
+ ]);
15
+ var SKIP_DIRECTORIES = /* @__PURE__ */ new Set([
16
+ "node_modules",
17
+ "dist",
18
+ "build",
19
+ ".git",
20
+ "coverage"
21
+ ]);
22
+ var MAP_SPECIFIER = "@memobit/icons/map";
23
+ var VIRTUAL_ID = "\0virtual:memobit-icon-map";
24
+ var QUOTED_STRING = /['"`]([a-z][a-z0-9-]*)['"`]/g;
25
+ var collectSourceFiles = (directory, found) => {
26
+ let dirEntries;
27
+ try {
28
+ dirEntries = readdirSync(directory, { withFileTypes: true });
29
+ } catch {
30
+ return found;
31
+ }
32
+ for (const entry of dirEntries) if (entry.isDirectory()) {
33
+ if (!SKIP_DIRECTORIES.has(entry.name)) collectSourceFiles(join(directory, entry.name), found);
34
+ } else if (SOURCE_EXTENSIONS.has(extname(entry.name))) found.push(join(directory, entry.name));
35
+ return found;
36
+ };
37
+ var resolvePackageDist = (root, packageName) => {
38
+ try {
39
+ return join(dirname((0, import___vite_browser_external.createRequire)(join(root, "noop.js")).resolve(`${packageName}/package.json`)), "dist");
40
+ } catch {
41
+ return null;
42
+ }
43
+ };
44
+ var scanForIconNames = (root, scanDirs, scanPackages) => {
45
+ const names = /* @__PURE__ */ new Set();
46
+ const directories = [...scanDirs.map((dir) => resolve(root, dir)), ...scanPackages.map((name) => resolvePackageDist(root, name)).filter((dir) => dir !== null)];
47
+ for (const directory of directories) for (const file of collectSourceFiles(directory, [])) {
48
+ let contents;
49
+ try {
50
+ contents = readFileSync(file, "utf8");
51
+ } catch {
52
+ continue;
53
+ }
54
+ for (const match of contents.matchAll(QUOTED_STRING)) if (match[1] in iconModules) names.add(match[1]);
55
+ }
56
+ return names;
57
+ };
58
+ var buildMapModule = (names) => {
59
+ return `${names.map((name) => `import { ${iconModules[name]} } from '@memobit/icons/icons/${name}';`).join("\n")}\n\nexport const iconMap = {\n${names.map((name) => ` '${name}': ${iconModules[name]},`).join("\n")}\n};\n`;
60
+ };
61
+ /**
62
+ * Replaces the full 495-icon `iconMap` with one holding only the icons an app actually
63
+ * uses, so a bundler can drop the rest.
64
+ *
65
+ * `<Icon name="..." />` resolves through a string key, which no bundler can narrow, so an
66
+ * app that renders a single icon still ships all of them. This scans the app's own source
67
+ * for strings matching a real icon name and generates a map of just those, which the
68
+ * library imports in place of the real one.
69
+ *
70
+ * Opting in is deliberate. A name that only exists in a database or an API response is
71
+ * invisible to any source scan, and trimming it away would break icons at runtime with no
72
+ * build error. An app that does not use this plugin keeps the full set and behaves exactly
73
+ * as before. An app whose names are user-chosen — anything with an icon picker — should
74
+ * pass `include: 'all'`, which keeps everything and simply does nothing.
75
+ */
76
+ var memobitIcons = (options = {}) => {
77
+ const { include = [], scanDirs = ["src"], scanPackages = ["@memobit/libs"], root = process.cwd(), debug = false } = options;
78
+ return {
79
+ name: "memobit-icons-trim",
80
+ enforce: "pre",
81
+ resolveId(source) {
82
+ return source === MAP_SPECIFIER ? VIRTUAL_ID : null;
83
+ },
84
+ load(id) {
85
+ if (id !== VIRTUAL_ID) return null;
86
+ if (include === "all") return buildMapModule(Object.keys(iconModules));
87
+ const names = scanForIconNames(root, scanDirs, scanPackages);
88
+ for (const name of include) {
89
+ if (!(name in iconModules)) throw new Error(`[memobit-icons] "${name}" was passed to include but is not an icon name.`);
90
+ names.add(name);
91
+ }
92
+ const kept = [...names].sort();
93
+ if (debug) console.log(`[memobit-icons] keeping ${kept.length} of ${Object.keys(iconModules).length} icons: ${kept.join(", ")}`);
94
+ return buildMapModule(kept);
95
+ }
96
+ };
97
+ };
98
+ //#endregion
99
+ export { memobitIcons };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memobit/icons",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "495 hand-built SVG icons for the Memobit apps — individually exported and tree-shakeable, with categories and search aliases. TypeScript-first, ESM-only, React 19.",
5
5
  "keywords": [
6
6
  "react",
@@ -39,6 +39,10 @@
39
39
  "types": "./dist/map.d.ts",
40
40
  "import": "./dist/map.js"
41
41
  },
42
+ "./vite": {
43
+ "types": "./dist/vite.d.ts",
44
+ "import": "./dist/vite.js"
45
+ },
42
46
  "./icons/*": {
43
47
  "types": "./dist/icons/*.d.ts",
44
48
  "import": "./dist/icons/*.js"
@@ -67,6 +71,7 @@
67
71
  },
68
72
  "devDependencies": {
69
73
  "@eslint/js": "9.39.4",
74
+ "@types/node": "25.8.0",
70
75
  "@types/react": "19.2.14",
71
76
  "@vitejs/plugin-react": "6.0.4",
72
77
  "esbuild": "0.28.1",