@number10/phaserjsx 0.6.1 → 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.
Files changed (108) hide show
  1. package/README.md +43 -3
  2. package/dist/chunk-C2EiDwsr.cjs +35 -0
  3. package/dist/clip/index.cjs +696 -0
  4. package/dist/clip/index.cjs.map +1 -0
  5. package/dist/clip/index.d.ts +3 -0
  6. package/dist/clip/index.d.ts.map +1 -0
  7. package/dist/clip/index.js +688 -0
  8. package/dist/clip/index.js.map +1 -0
  9. package/dist/clip/stencil-clip-extension.d.ts +18 -0
  10. package/dist/clip/stencil-clip-extension.d.ts.map +1 -0
  11. package/dist/clip/stencil-clip.d.ts +134 -0
  12. package/dist/clip/stencil-clip.d.ts.map +1 -0
  13. package/dist/components/appliers/applyBackground.d.ts +2 -1
  14. package/dist/components/appliers/applyBackground.d.ts.map +1 -1
  15. package/dist/components/appliers/applyGestures.d.ts.map +1 -1
  16. package/dist/components/appliers/applyTooltip.d.ts.map +1 -1
  17. package/dist/components/backgroundImage.d.ts +12 -0
  18. package/dist/components/backgroundImage.d.ts.map +1 -0
  19. package/dist/components/creators/createBackground.d.ts +2 -1
  20. package/dist/components/creators/createBackground.d.ts.map +1 -1
  21. package/dist/components/creators/createGestures.d.ts.map +1 -1
  22. package/dist/components/custom/Accordion.d.ts.map +1 -1
  23. package/dist/components/custom/CharText/CharText.d.ts.map +1 -1
  24. package/dist/components/custom/Dialog.d.ts +1 -1
  25. package/dist/components/custom/Divider.d.ts +1 -1
  26. package/dist/components/custom/Dropdown.d.ts.map +1 -1
  27. package/dist/components/custom/Graphics.d.ts +1 -1
  28. package/dist/components/custom/Graphics.d.ts.map +1 -1
  29. package/dist/components/custom/Icon.d.ts.map +1 -1
  30. package/dist/components/custom/Image.d.ts.map +1 -1
  31. package/dist/components/custom/Joystick.d.ts +1 -1
  32. package/dist/components/custom/NineSlice.d.ts.map +1 -1
  33. package/dist/components/custom/Particles.d.ts +1 -1
  34. package/dist/components/custom/Particles.d.ts.map +1 -1
  35. package/dist/components/custom/Portal.d.ts.map +1 -1
  36. package/dist/components/custom/RefOriginView.d.ts +1 -1
  37. package/dist/components/custom/ScrollView.d.ts.map +1 -1
  38. package/dist/components/custom/Sprite.d.ts +1 -1
  39. package/dist/components/custom/Sprite.d.ts.map +1 -1
  40. package/dist/components/custom/Text.d.ts.map +1 -1
  41. package/dist/components/custom/TileSprite.d.ts +1 -1
  42. package/dist/components/custom/TileSprite.d.ts.map +1 -1
  43. package/dist/components/custom/View.d.ts.map +1 -1
  44. package/dist/components/custom/index.cjs +34 -36
  45. package/dist/components/custom/index.js +2 -37
  46. package/dist/components/primitives/graphics.d.ts.map +1 -1
  47. package/dist/components/primitives/image.d.ts.map +1 -1
  48. package/dist/components/primitives/nineslice.d.ts.map +1 -1
  49. package/dist/components/primitives/particles.d.ts.map +1 -1
  50. package/dist/components/primitives/sprite.d.ts.map +1 -1
  51. package/dist/components/primitives/text.d.ts.map +1 -1
  52. package/dist/components/primitives/tilesprite.d.ts.map +1 -1
  53. package/dist/components/primitives/view.d.ts.map +1 -1
  54. package/dist/custom-C_w8D39m.js +29259 -0
  55. package/dist/custom-C_w8D39m.js.map +1 -0
  56. package/dist/custom-Dp3yAJdU.cjs +30498 -0
  57. package/dist/custom-Dp3yAJdU.cjs.map +1 -0
  58. package/dist/fx/fx-creators/blur.d.ts.map +1 -1
  59. package/dist/fx/fx-creators/color-matrix.d.ts.map +1 -1
  60. package/dist/fx/fx-creators/glow.d.ts.map +1 -1
  61. package/dist/fx/fx-creators/pixelate.d.ts.map +1 -1
  62. package/dist/fx/fx-creators/shadow.d.ts.map +1 -1
  63. package/dist/fx/fx-creators/vignette.d.ts.map +1 -1
  64. package/dist/fx/use-fx.d.ts +3 -3
  65. package/dist/fx/use-fx.d.ts.map +1 -1
  66. package/dist/gestures/gesture-manager.d.ts +3 -1
  67. package/dist/gestures/gesture-manager.d.ts.map +1 -1
  68. package/dist/gestures/gesture-types.d.ts +1 -1
  69. package/dist/gestures/gesture-types.d.ts.map +1 -1
  70. package/dist/hooks.d.ts +9 -8
  71. package/dist/hooks.d.ts.map +1 -1
  72. package/dist/index.cjs +1628 -2837
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.d.ts +1 -0
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +1430 -2866
  77. package/dist/index.js.map +1 -1
  78. package/dist/jsx-dev-runtime.cjs +12 -7
  79. package/dist/jsx-dev-runtime.cjs.map +1 -1
  80. package/dist/jsx-dev-runtime.js +11 -11
  81. package/dist/jsx-dev-runtime.js.map +1 -1
  82. package/dist/jsx-runtime.cjs +55 -33
  83. package/dist/jsx-runtime.cjs.map +1 -1
  84. package/dist/jsx-runtime.js +56 -37
  85. package/dist/jsx-runtime.js.map +1 -1
  86. package/dist/layout/appliers/background-applier.d.ts.map +1 -1
  87. package/dist/layout/layout-engine.d.ts.map +1 -1
  88. package/dist/layout/types.d.ts +2 -1
  89. package/dist/layout/types.d.ts.map +1 -1
  90. package/dist/scene-backgrounds.d.ts +51 -1
  91. package/dist/scene-backgrounds.d.ts.map +1 -1
  92. package/dist/scripts/generate-icon-loaders.js +146 -143
  93. package/dist/scripts/generate-icon-types.js +94 -83
  94. package/dist/scripts/generate-icons.d.ts +1 -2
  95. package/dist/scripts/generate-icons.d.ts.map +1 -1
  96. package/dist/scripts/generate-icons.js +381 -399
  97. package/dist/scripts/icon-generator-config.d.ts +0 -1
  98. package/dist/scripts/icon-generator-config.js +7 -4
  99. package/dist/theme-base.d.ts.map +1 -1
  100. package/dist/vite-plugin-icons.d.ts +1 -2
  101. package/dist/vite-plugin-icons.js +109 -90
  102. package/package.json +29 -22
  103. package/dist/TransformOriginView-Dw_HKnFH.cjs +0 -17116
  104. package/dist/TransformOriginView-Dw_HKnFH.cjs.map +0 -1
  105. package/dist/TransformOriginView-i8uVBHb1.js +0 -17100
  106. package/dist/TransformOriginView-i8uVBHb1.js.map +0 -1
  107. package/dist/components/custom/index.cjs.map +0 -1
  108. package/dist/components/custom/index.js.map +0 -1
@@ -1,117 +1,105 @@
1
1
  #!/usr/bin/env node
2
- import { readFile, writeFile, readdir } from "node:fs/promises";
3
- import { resolve, join } from "node:path";
2
+ import { readFile, readdir, writeFile } from "node:fs/promises";
3
+ import { join, resolve } from "node:path";
4
4
  import { parseArgs } from "node:util";
5
+ //#region src/scripts/generate-icon-loaders.ts
6
+ /**
7
+ * Auto-generates icon loader registry from actual icon usage in the codebase
8
+ * Scans TSX/TS files for Icon component usage and generates loaders
9
+ *
10
+ * Usage:
11
+ * generate-icon-loaders --source ./src --output ./src/components/icon-loaders.generated.ts --package bootstrap-icons
12
+ */
13
+ /**
14
+ * Recursively find all TypeScript files
15
+ */
5
16
  async function findTsFiles(dir) {
6
- const files = [];
7
- const entries = await readdir(dir, { withFileTypes: true });
8
- for (const entry of entries) {
9
- const fullPath = join(dir, entry.name);
10
- if (entry.isDirectory()) {
11
- if (entry.name === "node_modules" || entry.name === "dist") continue;
12
- files.push(...await findTsFiles(fullPath));
13
- } else if (entry.isFile() && /\.(tsx?|jsx?)$/.test(entry.name)) {
14
- files.push(fullPath);
15
- }
16
- }
17
- return files;
17
+ const files = [];
18
+ const entries = await readdir(dir, { withFileTypes: true });
19
+ for (const entry of entries) {
20
+ const fullPath = join(dir, entry.name);
21
+ if (entry.isDirectory()) {
22
+ if (entry.name === "node_modules" || entry.name === "dist") continue;
23
+ files.push(...await findTsFiles(fullPath));
24
+ } else if (entry.isFile() && /\.(tsx?|jsx?)$/.test(entry.name)) files.push(fullPath);
25
+ }
26
+ return files;
18
27
  }
28
+ /**
29
+ * Extract icon names from file content
30
+ */
19
31
  function extractIconNames(content, componentNames) {
20
- const iconNames = /* @__PURE__ */ new Set();
21
- let match;
22
- for (const componentName of componentNames) {
23
- const typePattern = new RegExp(
24
- `<${componentName}\\s+[^>]*type=(?:["']([^"']+)["']|\\{['"]([^"']+)["']}})`,
25
- "g"
26
- );
27
- while ((match = typePattern.exec(content)) !== null) {
28
- const iconName = match[1] || match[2];
29
- if (iconName) {
30
- iconNames.add(iconName);
31
- }
32
- }
33
- }
34
- const themedPattern = /themed\.(\w*[Ii]con)\s*\?\?\s*["']([^"']+)["']/g;
35
- while ((match = themedPattern.exec(content)) !== null) {
36
- if (match[2]) {
37
- iconNames.add(match[2]);
38
- }
39
- }
40
- const iconPropPattern = /(?:icon|iconType):\s*["']([^"']+)["']/g;
41
- while ((match = iconPropPattern.exec(content)) !== null) {
42
- if (match[1]) {
43
- iconNames.add(match[1]);
44
- }
45
- }
46
- return iconNames;
32
+ const iconNames = /* @__PURE__ */ new Set();
33
+ let match;
34
+ for (const componentName of componentNames) {
35
+ const typePattern = new RegExp(`<${componentName}\\s+[^>]*type=(?:["']([^"']+)["']|\\{['"]([^"']+)["']}})`, "g");
36
+ while ((match = typePattern.exec(content)) !== null) {
37
+ const iconName = match[1] || match[2];
38
+ if (iconName) iconNames.add(iconName);
39
+ }
40
+ }
41
+ const themedPattern = /themed\.(\w*[Ii]con)\s*\?\?\s*["']([^"']+)["']/g;
42
+ while ((match = themedPattern.exec(content)) !== null) if (match[2]) iconNames.add(match[2]);
43
+ const iconPropPattern = /(?:icon|iconType):\s*["']([^"']+)["']/g;
44
+ while ((match = iconPropPattern.exec(content)) !== null) if (match[1]) iconNames.add(match[1]);
45
+ return iconNames;
47
46
  }
47
+ /**
48
+ * Load available icon names from generated types file
49
+ */
48
50
  async function loadAvailableIcons(typesFile) {
49
- try {
50
- const content = await readFile(typesFile, "utf-8");
51
- const match = content.match(/(?:export\s+)?type\s+\w+\s*=\s*([\s\S]+?)(?=\n\nexport|\n\/\/|$)/s);
52
- if (!match?.[1]) return null;
53
- const typeContent = match[1];
54
- const icons = /* @__PURE__ */ new Set();
55
- const iconPattern = /'([^']+)'/g;
56
- let iconMatch;
57
- while ((iconMatch = iconPattern.exec(typeContent)) !== null) {
58
- const iconName = iconMatch[1];
59
- if (iconName) {
60
- icons.add(iconName);
61
- }
62
- }
63
- return icons;
64
- } catch {
65
- return null;
66
- }
51
+ try {
52
+ const match = (await readFile(typesFile, "utf-8")).match(/(?:export\s+)?type\s+\w+\s*=\s*([\s\S]+?)(?=\n\nexport|\n\/\/|$)/s);
53
+ if (!match?.[1]) return null;
54
+ const typeContent = match[1];
55
+ const icons = /* @__PURE__ */ new Set();
56
+ const iconPattern = /'([^']+)'/g;
57
+ let iconMatch;
58
+ while ((iconMatch = iconPattern.exec(typeContent)) !== null) {
59
+ const iconName = iconMatch[1];
60
+ if (iconName) icons.add(iconName);
61
+ }
62
+ return icons;
63
+ } catch {
64
+ return null;
65
+ }
67
66
  }
68
- async function generateIconLoaders(options2) {
69
- try {
70
- const cwd = process.cwd();
71
- const srcDir = resolve(cwd, options2.source);
72
- const componentNames = options2.componentNames || [options2.componentName || "Icon"];
73
- console.log(`📁 Scanning directory: ${srcDir}`);
74
- console.log(`🔍 Looking for components: ${componentNames.join(", ")}`);
75
- let availableIcons = null;
76
- if (options2.typesFile) {
77
- const typesPath = resolve(cwd, options2.typesFile);
78
- availableIcons = await loadAvailableIcons(typesPath);
79
- if (availableIcons) {
80
- console.log(`✓ Loaded ${availableIcons.size} available icons from ${options2.typesFile}`);
81
- } else {
82
- console.warn(`⚠️ Could not parse types file: ${options2.typesFile}`);
83
- }
84
- }
85
- const files = await findTsFiles(srcDir);
86
- console.log(`📄 Found ${files.length} TypeScript files`);
87
- const allIconNames = /* @__PURE__ */ new Set();
88
- for (const file of files) {
89
- const content = await readFile(file, "utf-8");
90
- const icons = extractIconNames(content, componentNames);
91
- icons.forEach((icon) => allIconNames.add(icon));
92
- }
93
- let iconArray = Array.from(allIconNames).sort();
94
- if (availableIcons) {
95
- const invalidIcons = iconArray.filter((icon) => !availableIcons.has(icon));
96
- if (invalidIcons.length > 0) {
97
- console.warn(`⚠️ Found ${invalidIcons.length} icons not in types file:`);
98
- console.warn(
99
- ` ${invalidIcons.slice(0, 5).join(", ")}${invalidIcons.length > 5 ? "..." : ""}`
100
- );
101
- }
102
- iconArray = iconArray.filter((icon) => availableIcons.has(icon));
103
- }
104
- console.log(`✓ Found ${iconArray.length} unique icons`);
105
- if (iconArray.length > 0) {
106
- console.log(
107
- ` Icons: ${iconArray.slice(0, 10).join(", ")}${iconArray.length > 10 ? "..." : ""}`
108
- );
109
- }
110
- const iconsPath = options2.iconsPath || "icons";
111
- const loaders = iconArray.map((icon) => ` '${icon}': () => import('${options2.package}/${iconsPath}/${icon}.svg'),`).join("\n");
112
- const output = `/**
67
+ /**
68
+ * Main generator function
69
+ */
70
+ async function generateIconLoaders(options) {
71
+ try {
72
+ const cwd = process.cwd();
73
+ const srcDir = resolve(cwd, options.source);
74
+ const componentNames = options.componentNames || [options.componentName || "Icon"];
75
+ console.log(`📁 Scanning directory: ${srcDir}`);
76
+ console.log(`🔍 Looking for components: ${componentNames.join(", ")}`);
77
+ let availableIcons = null;
78
+ if (options.typesFile) {
79
+ availableIcons = await loadAvailableIcons(resolve(cwd, options.typesFile));
80
+ if (availableIcons) console.log(`✓ Loaded ${availableIcons.size} available icons from ${options.typesFile}`);
81
+ else console.warn(`⚠️ Could not parse types file: ${options.typesFile}`);
82
+ }
83
+ const files = await findTsFiles(srcDir);
84
+ console.log(`📄 Found ${files.length} TypeScript files`);
85
+ const allIconNames = /* @__PURE__ */ new Set();
86
+ for (const file of files) extractIconNames(await readFile(file, "utf-8"), componentNames).forEach((icon) => allIconNames.add(icon));
87
+ let iconArray = Array.from(allIconNames).sort();
88
+ if (availableIcons) {
89
+ const invalidIcons = iconArray.filter((icon) => !availableIcons.has(icon));
90
+ if (invalidIcons.length > 0) {
91
+ console.warn(`⚠️ Found ${invalidIcons.length} icons not in types file:`);
92
+ console.warn(` ${invalidIcons.slice(0, 5).join(", ")}${invalidIcons.length > 5 ? "..." : ""}`);
93
+ }
94
+ iconArray = iconArray.filter((icon) => availableIcons.has(icon));
95
+ }
96
+ console.log(`✓ Found ${iconArray.length} unique icons`);
97
+ if (iconArray.length > 0) console.log(` Icons: ${iconArray.slice(0, 10).join(", ")}${iconArray.length > 10 ? "..." : ""}`);
98
+ const iconsPath = options.iconsPath || "icons";
99
+ const loaders = iconArray.map((icon) => ` '${icon}': () => import('${options.package}/${iconsPath}/${icon}.svg'),`).join("\n");
100
+ const output = `/**
113
101
  * Auto-generated icon loader registry
114
- * Package: ${options2.package}
102
+ * Package: ${options.package}
115
103
  * Icons found: ${iconArray.length}
116
104
  *
117
105
  * @generated by @number10/phaserjsx/generate-icon-loaders
@@ -126,29 +114,51 @@ export const iconLoaders: Record<string, () => Promise<{ default: string }>> = {
126
114
  ${loaders || " // No icons found"}
127
115
  }
128
116
  `;
129
- const outputPath = resolve(cwd, options2.output);
130
- await writeFile(outputPath, output, "utf-8");
131
- console.log(`✓ Generated: ${outputPath}`);
132
- console.log(`✓ Registered ${iconArray.length} icon loaders`);
133
- } catch (error) {
134
- console.error("❌ Error generating icon loaders:", error);
135
- process.exit(1);
136
- }
117
+ const outputPath = resolve(cwd, options.output);
118
+ await writeFile(outputPath, output, "utf-8");
119
+ console.log(`✓ Generated: ${outputPath}`);
120
+ console.log(`✓ Registered ${iconArray.length} icon loaders`);
121
+ } catch (error) {
122
+ console.error("❌ Error generating icon loaders:", error);
123
+ process.exit(1);
124
+ }
137
125
  }
138
- const { values } = parseArgs({
139
- options: {
140
- source: { type: "string", short: "s" },
141
- output: { type: "string", short: "o" },
142
- package: { type: "string", short: "p" },
143
- iconsPath: { type: "string", short: "i" },
144
- componentName: { type: "string", short: "c" },
145
- componentNames: { type: "string", multiple: true },
146
- typesFile: { type: "string", short: "t" },
147
- help: { type: "boolean", short: "h" }
148
- }
149
- });
126
+ var { values } = parseArgs({ options: {
127
+ source: {
128
+ type: "string",
129
+ short: "s"
130
+ },
131
+ output: {
132
+ type: "string",
133
+ short: "o"
134
+ },
135
+ package: {
136
+ type: "string",
137
+ short: "p"
138
+ },
139
+ iconsPath: {
140
+ type: "string",
141
+ short: "i"
142
+ },
143
+ componentName: {
144
+ type: "string",
145
+ short: "c"
146
+ },
147
+ componentNames: {
148
+ type: "string",
149
+ multiple: true
150
+ },
151
+ typesFile: {
152
+ type: "string",
153
+ short: "t"
154
+ },
155
+ help: {
156
+ type: "boolean",
157
+ short: "h"
158
+ }
159
+ } });
150
160
  if (values.help || !values.source || !values.output || !values.package) {
151
- console.log(`
161
+ console.log(`
152
162
  Usage: generate-icon-loaders [options]
153
163
 
154
164
  Options:
@@ -173,23 +183,16 @@ Examples:
173
183
  generate-icon-loaders -s ./src -o ./src/icon-loaders.generated.ts -p bootstrap-icons \\
174
184
  -t ./src/icon-types.generated.ts
175
185
  `);
176
- process.exit(values.help ? 0 : 1);
186
+ process.exit(values.help ? 0 : 1);
177
187
  }
178
- const options = {
179
- source: values.source,
180
- output: values.output,
181
- package: values.package
188
+ var options = {
189
+ source: values.source,
190
+ output: values.output,
191
+ package: values.package
182
192
  };
183
- if (values.iconsPath) {
184
- options.iconsPath = values.iconsPath;
185
- }
186
- if (values.componentName) {
187
- options.componentName = values.componentName;
188
- }
189
- if (values.componentNames && values.componentNames.length > 0) {
190
- options.componentNames = values.componentNames;
191
- }
192
- if (values.typesFile) {
193
- options.typesFile = values.typesFile;
194
- }
193
+ if (values.iconsPath) options.iconsPath = values.iconsPath;
194
+ if (values.componentName) options.componentName = values.componentName;
195
+ if (values.componentNames && values.componentNames.length > 0) options.componentNames = values.componentNames;
196
+ if (values.typesFile) options.typesFile = values.typesFile;
195
197
  generateIconLoaders(options);
198
+ //#endregion
@@ -1,51 +1,55 @@
1
1
  #!/usr/bin/env node
2
2
  import { readdir, writeFile } from "node:fs/promises";
3
- import { resolve, join, basename } from "node:path";
3
+ import { basename, join, resolve } from "node:path";
4
4
  import { parseArgs } from "node:util";
5
+ //#region src/scripts/generate-icon-types.ts
6
+ /**
7
+ * Generator for icon type definitions from any icon library
8
+ * Scans an icon package and generates TypeScript union type
9
+ *
10
+ * Usage:
11
+ * generate-icon-types --package bootstrap-icons --output ./src/types/icons.ts
12
+ */
13
+ /**
14
+ * Find icon package in node_modules
15
+ */
5
16
  async function findIconPackage(packageName, cwd) {
6
- const fs = await import("node:fs");
7
- const pnpmBase = join(cwd, "node_modules/.pnpm");
8
- if (fs.existsSync(pnpmBase)) {
9
- const entries = await readdir(pnpmBase);
10
- for (const entry of entries) {
11
- if (entry.startsWith(`${packageName}@`)) {
12
- const packagePath = join(pnpmBase, entry, "node_modules", packageName);
13
- if (fs.existsSync(packagePath)) {
14
- return packagePath;
15
- }
16
- }
17
- }
18
- }
19
- const standardPath = join(cwd, "node_modules", packageName);
20
- if (fs.existsSync(standardPath)) {
21
- return standardPath;
22
- }
23
- throw new Error(`Could not find package: ${packageName}`);
17
+ const fs = await import("node:fs");
18
+ const pnpmBase = join(cwd, "node_modules/.pnpm");
19
+ if (fs.existsSync(pnpmBase)) {
20
+ const entries = await readdir(pnpmBase);
21
+ for (const entry of entries) if (entry.startsWith(`${packageName}@`)) {
22
+ const packagePath = join(pnpmBase, entry, "node_modules", packageName);
23
+ if (fs.existsSync(packagePath)) return packagePath;
24
+ }
25
+ }
26
+ const standardPath = join(cwd, "node_modules", packageName);
27
+ if (fs.existsSync(standardPath)) return standardPath;
28
+ throw new Error(`Could not find package: ${packageName}`);
24
29
  }
25
- async function generateIconTypes(options2) {
26
- try {
27
- const cwd = process.cwd();
28
- let iconsDir;
29
- let sourceName;
30
- if (options2.directory) {
31
- iconsDir = resolve(cwd, options2.directory);
32
- sourceName = options2.directory;
33
- console.log(`📁 Scanning directory: ${options2.directory}`);
34
- } else if (options2.package) {
35
- const packagePath = await findIconPackage(options2.package, cwd);
36
- iconsDir = join(packagePath, options2.iconsPath || "icons");
37
- sourceName = options2.package;
38
- console.log(`📦 Scanning package: ${options2.package}`);
39
- } else {
40
- throw new Error("Either --package or --directory must be specified");
41
- }
42
- console.log(`📁 Icons directory: ${iconsDir}`);
43
- const files = await readdir(iconsDir);
44
- const iconNames = files.filter((file) => file.endsWith(".svg")).map((file) => basename(file, ".svg")).sort();
45
- console.log(`✓ Found ${iconNames.length} icons`);
46
- const typeDefinition = iconNames.map((name) => ` | '${name}'`).join("\n");
47
- const typeName = options2.typeName || "IconType";
48
- const output = `/**
30
+ /**
31
+ * Main generator function
32
+ */
33
+ async function generateIconTypes(options) {
34
+ try {
35
+ const cwd = process.cwd();
36
+ let iconsDir;
37
+ let sourceName;
38
+ if (options.directory) {
39
+ iconsDir = resolve(cwd, options.directory);
40
+ sourceName = options.directory;
41
+ console.log(`📁 Scanning directory: ${options.directory}`);
42
+ } else if (options.package) {
43
+ iconsDir = join(await findIconPackage(options.package, cwd), options.iconsPath || "icons");
44
+ sourceName = options.package;
45
+ console.log(`📦 Scanning package: ${options.package}`);
46
+ } else throw new Error("Either --package or --directory must be specified");
47
+ console.log(`📁 Icons directory: ${iconsDir}`);
48
+ const iconNames = (await readdir(iconsDir)).filter((file) => file.endsWith(".svg")).map((file) => basename(file, ".svg")).sort();
49
+ console.log(`✓ Found ${iconNames.length} icons`);
50
+ const typeDefinition = iconNames.map((name) => ` | '${name}'`).join("\n");
51
+ const typeName = options.typeName || "IconType";
52
+ const output = `/**
49
53
  * Auto-generated icon type definitions
50
54
  * Source: ${sourceName}
51
55
  * Total icons: ${iconNames.length}
@@ -61,32 +65,48 @@ async function generateIconTypes(options2) {
61
65
  export type ${typeName} =
62
66
  ${typeDefinition}
63
67
  `;
64
- const outputPath = resolve(cwd, options2.output);
65
- await writeFile(outputPath, output, "utf-8");
66
- console.log(`✓ Generated: ${outputPath}`);
67
- console.log(`✓ Type name: ${typeName}`);
68
- console.log(`✓ Total icons: ${iconNames.length}`);
69
- if (iconNames.length > 0) {
70
- console.log(` First: ${iconNames[0]}`);
71
- console.log(` Last: ${iconNames[iconNames.length - 1]}`);
72
- }
73
- } catch (error) {
74
- console.error("❌ Error generating icon types:", error);
75
- process.exit(1);
76
- }
68
+ const outputPath = resolve(cwd, options.output);
69
+ await writeFile(outputPath, output, "utf-8");
70
+ console.log(`✓ Generated: ${outputPath}`);
71
+ console.log(`✓ Type name: ${typeName}`);
72
+ console.log(`✓ Total icons: ${iconNames.length}`);
73
+ if (iconNames.length > 0) {
74
+ console.log(` First: ${iconNames[0]}`);
75
+ console.log(` Last: ${iconNames[iconNames.length - 1]}`);
76
+ }
77
+ } catch (error) {
78
+ console.error("❌ Error generating icon types:", error);
79
+ process.exit(1);
80
+ }
77
81
  }
78
- const { values } = parseArgs({
79
- options: {
80
- package: { type: "string", short: "p" },
81
- directory: { type: "string", short: "d" },
82
- output: { type: "string", short: "o" },
83
- typeName: { type: "string", short: "t" },
84
- iconsPath: { type: "string", short: "i" },
85
- help: { type: "boolean", short: "h" }
86
- }
87
- });
82
+ var { values } = parseArgs({ options: {
83
+ package: {
84
+ type: "string",
85
+ short: "p"
86
+ },
87
+ directory: {
88
+ type: "string",
89
+ short: "d"
90
+ },
91
+ output: {
92
+ type: "string",
93
+ short: "o"
94
+ },
95
+ typeName: {
96
+ type: "string",
97
+ short: "t"
98
+ },
99
+ iconsPath: {
100
+ type: "string",
101
+ short: "i"
102
+ },
103
+ help: {
104
+ type: "boolean",
105
+ short: "h"
106
+ }
107
+ } });
88
108
  if (values.help || !values.package && !values.directory || !values.output) {
89
- console.log(`
109
+ console.log(`
90
110
  Usage: generate-icon-types [options]
91
111
 
92
112
  Options:
@@ -104,21 +124,12 @@ Examples:
104
124
  # From local directory
105
125
  generate-icon-types -d ./public/icons -o ./src/icon-types.generated.ts
106
126
  `);
107
- process.exit(values.help ? 0 : 1);
108
- }
109
- const options = {
110
- output: values.output
111
- };
112
- if (values.package) {
113
- options.package = values.package;
114
- }
115
- if (values.directory) {
116
- options.directory = values.directory;
117
- }
118
- if (values.typeName) {
119
- options.typeName = values.typeName;
120
- }
121
- if (values.iconsPath) {
122
- options.iconsPath = values.iconsPath;
127
+ process.exit(values.help ? 0 : 1);
123
128
  }
129
+ var options = { output: values.output };
130
+ if (values.package) options.package = values.package;
131
+ if (values.directory) options.directory = values.directory;
132
+ if (values.typeName) options.typeName = values.typeName;
133
+ if (values.iconsPath) options.iconsPath = values.iconsPath;
124
134
  generateIconTypes(options);
135
+ //#endregion
@@ -1,4 +1,4 @@
1
- import { IconGeneratorConfig } from './icon-generator-config';
1
+ import type { IconGeneratorConfig } from './icon-generator-config';
2
2
  /**
3
3
  * Generate icon types
4
4
  * Exported for use by Vite plugin
@@ -34,4 +34,3 @@ export declare function generateLoaders(config: IconGeneratorConfig, cwd: string
34
34
  * Exported for use by Vite plugin and other tools
35
35
  */
36
36
  export declare function loadConfig(configPath: string, cwd?: string): Promise<IconGeneratorConfig>;
37
- //# sourceMappingURL=generate-icons.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-icons.d.ts","sourceRoot":"","sources":["../../src/scripts/generate-icons.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AA8IlE;;;GAGG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,EAC3B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,GAAG,IAAI,CAAC,CA+EnF;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,mBAAmB,EAC3B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC,CAgC5E;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,mBAAmB,EAC3B,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,GAC9E,OAAO,CAAC,IAAI,CAAC,CAgLf;AAED;;GAEG;AACH;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,GAAG,SAAgB,GAClB,OAAO,CAAC,mBAAmB,CAAC,CA6B9B"}
1
+ {"version":3,"file":"generate-icons.d.ts","sourceRoot":"","sources":["../../src/scripts/generate-icons.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AA8IlE;;;GAGG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,EAC3B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,GAAG,IAAI,CAAC,CA+EnF;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,mBAAmB,EAC3B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC,CAgC5E;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,mBAAmB,EAC3B,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,GAC9E,OAAO,CAAC,IAAI,CAAC,CAgLf;AAED;;GAEG;AACH;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,GAAG,SAAgB,GAClB,OAAO,CAAC,mBAAmB,CAAC,CA8B9B"}