@code-id-labs/plugin-vite 0.0.0-stage → 1.0.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/dist/icons.cjs ADDED
@@ -0,0 +1,78 @@
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
6
+ let node_fs = require("node:fs");
7
+ node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
8
+ let node_path = require("node:path");
9
+ node_path = require_rolldown_runtime.__toESM(node_path, 1);
10
+ let node_module = require("node:module");
11
+ let node_url = require("node:url");
12
+ let _egoist_tailwindcss_icons = require("@egoist/tailwindcss-icons");
13
+ _egoist_tailwindcss_icons = require_rolldown_runtime.__toESM(_egoist_tailwindcss_icons, 1);
14
+ //#region src/icons.ts
15
+ const CURRENT_FILE = typeof __filename === "string" && node_path.default.isAbsolute(__filename) ? __filename : (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
16
+ const req = (0, node_module.createRequire)(CURRENT_FILE);
17
+ const ICONS_DIR = node_path.default.dirname(CURRENT_FILE);
18
+ function loadJson(filePath) {
19
+ try {
20
+ return req(filePath);
21
+ } catch {
22
+ return null;
23
+ }
24
+ }
25
+ /**
26
+ * Resolves the built-in Lucide collection from `@code-id-labs/plugin-vite`'s own
27
+ * dependencies plus any additional `@iconify-json/*` or `@iconify/json`
28
+ * collections installed in the user's project.
29
+ */
30
+ function resolveCodeUIIconCollections(cwd = process.cwd()) {
31
+ const collections = {};
32
+ try {
33
+ const lucideJson = loadJson(req.resolve("@iconify-json/lucide/icons.json"));
34
+ if (lucideJson) collections.lucide = lucideJson;
35
+ } catch {}
36
+ const searchPaths = [cwd, ICONS_DIR];
37
+ let iconifyFullDir = null;
38
+ try {
39
+ iconifyFullDir = node_path.default.dirname(req.resolve("@iconify/json/package.json", { paths: searchPaths }));
40
+ } catch {
41
+ iconifyFullDir = null;
42
+ }
43
+ if (iconifyFullDir) {
44
+ const jsonDir = node_path.default.join(iconifyFullDir, "json");
45
+ if (node_fs.default.existsSync(jsonDir)) for (const file of node_fs.default.readdirSync(jsonDir)) {
46
+ if (!file.endsWith(".json")) continue;
47
+ const json = loadJson(node_path.default.join(jsonDir, file));
48
+ if (json && json.prefix) collections[json.prefix] = json;
49
+ }
50
+ return collections;
51
+ }
52
+ for (const name of _egoist_tailwindcss_icons.collectionNames) {
53
+ if (collections[name]) continue;
54
+ try {
55
+ const json = loadJson(req.resolve(`@iconify-json/${name}/icons.json`, { paths: searchPaths }));
56
+ if (json) collections[name] = json;
57
+ } catch {}
58
+ }
59
+ return collections;
60
+ }
61
+ /**
62
+ * Tailwind CSS v4 plugin entrypoint used by `@plugin "@code-id-labs/plugin-vite/icons"`.
63
+ * Ships with `@iconify-json/lucide` built in so components render icons with
64
+ * zero extra setup, while automatically picking up any user-installed
65
+ * `@iconify-json/<collection>` packages.
66
+ */
67
+ const twIconsFn = typeof _egoist_tailwindcss_icons.default === "function" ? _egoist_tailwindcss_icons.default : _egoist_tailwindcss_icons.default.default ?? _egoist_tailwindcss_icons.default;
68
+ function codeUIIconsPlugin(options) {
69
+ const collections = options?.collections ?? resolveCodeUIIconCollections(process.cwd());
70
+ return twIconsFn({
71
+ ...options,
72
+ collections
73
+ });
74
+ }
75
+ codeUIIconsPlugin.__isOptionsFunction = true;
76
+ //#endregion
77
+ exports.default = codeUIIconsPlugin;
78
+ exports.resolveCodeUIIconCollections = resolveCodeUIIconCollections;
@@ -0,0 +1,24 @@
1
+ //#region src/icons.d.ts
2
+ export interface CodeUIIconsTailwindOptions {
3
+ collections?: Record<string, any>;
4
+ scale?: number;
5
+ prefix?: string;
6
+ extraProperties?: Record<string, string>;
7
+ strokeWidth?: number;
8
+ collectionNamesAlias?: Record<string, string>;
9
+ }
10
+ /**
11
+ * Resolves the built-in Lucide collection from `@code-id-labs/plugin-vite`'s own
12
+ * dependencies plus any additional `@iconify-json/*` or `@iconify/json`
13
+ * collections installed in the user's project.
14
+ */
15
+ export declare function resolveCodeUIIconCollections(cwd?: string): Record<string, any>;
16
+ declare function codeUIIconsPlugin(options?: CodeUIIconsTailwindOptions): {
17
+ handler: tailwindcss_types_config.PluginCreator;
18
+ config?: Partial<tailwindcss_types_config.Config>;
19
+ };
20
+ declare namespace codeUIIconsPlugin {
21
+ var __isOptionsFunction: true;
22
+ }
23
+ //#endregion
24
+ export { codeUIIconsPlugin as default };
@@ -0,0 +1,24 @@
1
+ //#region src/icons.d.ts
2
+ export interface CodeUIIconsTailwindOptions {
3
+ collections?: Record<string, any>;
4
+ scale?: number;
5
+ prefix?: string;
6
+ extraProperties?: Record<string, string>;
7
+ strokeWidth?: number;
8
+ collectionNamesAlias?: Record<string, string>;
9
+ }
10
+ /**
11
+ * Resolves the built-in Lucide collection from `@code-id-labs/plugin-vite`'s own
12
+ * dependencies plus any additional `@iconify-json/*` or `@iconify/json`
13
+ * collections installed in the user's project.
14
+ */
15
+ export declare function resolveCodeUIIconCollections(cwd?: string): Record<string, any>;
16
+ declare function codeUIIconsPlugin(options?: CodeUIIconsTailwindOptions): {
17
+ handler: tailwindcss_types_config.PluginCreator;
18
+ config?: Partial<tailwindcss_types_config.Config>;
19
+ };
20
+ declare namespace codeUIIconsPlugin {
21
+ var __isOptionsFunction: true;
22
+ }
23
+ //#endregion
24
+ export { codeUIIconsPlugin as default };
package/dist/icons.js ADDED
@@ -0,0 +1,69 @@
1
+ import { createRequire } from "node:module";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import tailwindcssIcons, { collectionNames } from "@egoist/tailwindcss-icons";
6
+ //#region src/icons.ts
7
+ const CURRENT_FILE = typeof __filename === "string" && path.isAbsolute(__filename) ? __filename : fileURLToPath(import.meta.url);
8
+ const req = createRequire(CURRENT_FILE);
9
+ const ICONS_DIR = path.dirname(CURRENT_FILE);
10
+ function loadJson(filePath) {
11
+ try {
12
+ return req(filePath);
13
+ } catch {
14
+ return null;
15
+ }
16
+ }
17
+ /**
18
+ * Resolves the built-in Lucide collection from `@code-id-labs/plugin-vite`'s own
19
+ * dependencies plus any additional `@iconify-json/*` or `@iconify/json`
20
+ * collections installed in the user's project.
21
+ */
22
+ function resolveCodeUIIconCollections(cwd = process.cwd()) {
23
+ const collections = {};
24
+ try {
25
+ const lucideJson = loadJson(req.resolve("@iconify-json/lucide/icons.json"));
26
+ if (lucideJson) collections.lucide = lucideJson;
27
+ } catch {}
28
+ const searchPaths = [cwd, ICONS_DIR];
29
+ let iconifyFullDir = null;
30
+ try {
31
+ iconifyFullDir = path.dirname(req.resolve("@iconify/json/package.json", { paths: searchPaths }));
32
+ } catch {
33
+ iconifyFullDir = null;
34
+ }
35
+ if (iconifyFullDir) {
36
+ const jsonDir = path.join(iconifyFullDir, "json");
37
+ if (fs.existsSync(jsonDir)) for (const file of fs.readdirSync(jsonDir)) {
38
+ if (!file.endsWith(".json")) continue;
39
+ const json = loadJson(path.join(jsonDir, file));
40
+ if (json && json.prefix) collections[json.prefix] = json;
41
+ }
42
+ return collections;
43
+ }
44
+ for (const name of collectionNames) {
45
+ if (collections[name]) continue;
46
+ try {
47
+ const json = loadJson(req.resolve(`@iconify-json/${name}/icons.json`, { paths: searchPaths }));
48
+ if (json) collections[name] = json;
49
+ } catch {}
50
+ }
51
+ return collections;
52
+ }
53
+ /**
54
+ * Tailwind CSS v4 plugin entrypoint used by `@plugin "@code-id-labs/plugin-vite/icons"`.
55
+ * Ships with `@iconify-json/lucide` built in so components render icons with
56
+ * zero extra setup, while automatically picking up any user-installed
57
+ * `@iconify-json/<collection>` packages.
58
+ */
59
+ const twIconsFn = typeof tailwindcssIcons === "function" ? tailwindcssIcons : tailwindcssIcons.default ?? tailwindcssIcons;
60
+ function codeUIIconsPlugin(options) {
61
+ const collections = options?.collections ?? resolveCodeUIIconCollections(process.cwd());
62
+ return twIconsFn({
63
+ ...options,
64
+ collections
65
+ });
66
+ }
67
+ codeUIIconsPlugin.__isOptionsFunction = true;
68
+ //#endregion
69
+ export { codeUIIconsPlugin as default, resolveCodeUIIconCollections };