@number10/phaserjsx 0.6.1 → 4.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/README.md +13 -3
- package/dist/clip/stencil-clip.d.ts +86 -0
- package/dist/clip/stencil-clip.d.ts.map +1 -0
- package/dist/components/appliers/applyGestures.d.ts.map +1 -1
- package/dist/components/creators/createGestures.d.ts.map +1 -1
- package/dist/components/custom/CharText/CharText.d.ts.map +1 -1
- package/dist/components/custom/Dialog.d.ts +1 -1
- package/dist/components/custom/Divider.d.ts +1 -1
- package/dist/components/custom/Graphics.d.ts +1 -1
- package/dist/components/custom/Graphics.d.ts.map +1 -1
- package/dist/components/custom/Icon.d.ts.map +1 -1
- package/dist/components/custom/Image.d.ts.map +1 -1
- package/dist/components/custom/Joystick.d.ts +1 -1
- package/dist/components/custom/NineSlice.d.ts.map +1 -1
- package/dist/components/custom/Particles.d.ts +1 -1
- package/dist/components/custom/Particles.d.ts.map +1 -1
- package/dist/components/custom/Portal.d.ts.map +1 -1
- package/dist/components/custom/RefOriginView.d.ts +1 -1
- package/dist/components/custom/ScrollView.d.ts.map +1 -1
- package/dist/components/custom/Sprite.d.ts +1 -1
- package/dist/components/custom/Sprite.d.ts.map +1 -1
- package/dist/components/custom/Text.d.ts.map +1 -1
- package/dist/components/custom/TileSprite.d.ts +1 -1
- package/dist/components/custom/TileSprite.d.ts.map +1 -1
- package/dist/components/custom/View.d.ts.map +1 -1
- package/dist/components/custom/index.cjs +34 -36
- package/dist/components/custom/index.js +2 -37
- package/dist/components/primitives/graphics.d.ts.map +1 -1
- package/dist/components/primitives/image.d.ts.map +1 -1
- package/dist/components/primitives/nineslice.d.ts.map +1 -1
- package/dist/components/primitives/particles.d.ts.map +1 -1
- package/dist/components/primitives/sprite.d.ts.map +1 -1
- package/dist/components/primitives/text.d.ts.map +1 -1
- package/dist/components/primitives/tilesprite.d.ts.map +1 -1
- package/dist/components/primitives/view.d.ts.map +1 -1
- package/dist/custom-BN31OAJq.cjs +30826 -0
- package/dist/custom-BN31OAJq.cjs.map +1 -0
- package/dist/custom-oy3mBnrW.js +29562 -0
- package/dist/custom-oy3mBnrW.js.map +1 -0
- package/dist/fx/fx-creators/blur.d.ts.map +1 -1
- package/dist/fx/fx-creators/color-matrix.d.ts.map +1 -1
- package/dist/fx/fx-creators/glow.d.ts.map +1 -1
- package/dist/fx/fx-creators/pixelate.d.ts.map +1 -1
- package/dist/fx/fx-creators/shadow.d.ts.map +1 -1
- package/dist/fx/fx-creators/vignette.d.ts.map +1 -1
- package/dist/fx/use-fx.d.ts +3 -3
- package/dist/fx/use-fx.d.ts.map +1 -1
- package/dist/gestures/gesture-manager.d.ts +3 -1
- package/dist/gestures/gesture-manager.d.ts.map +1 -1
- package/dist/gestures/gesture-types.d.ts +1 -1
- package/dist/gestures/gesture-types.d.ts.map +1 -1
- package/dist/index.cjs +1547 -2837
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1356 -2866
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.cjs +12 -7
- package/dist/jsx-dev-runtime.cjs.map +1 -1
- package/dist/jsx-dev-runtime.js +11 -11
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.cjs +55 -33
- package/dist/jsx-runtime.cjs.map +1 -1
- package/dist/jsx-runtime.js +56 -37
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/layout/layout-engine.d.ts.map +1 -1
- package/dist/scripts/generate-icon-loaders.js +146 -143
- package/dist/scripts/generate-icon-types.js +94 -83
- package/dist/scripts/generate-icons.d.ts +1 -2
- package/dist/scripts/generate-icons.d.ts.map +1 -1
- package/dist/scripts/generate-icons.js +381 -399
- package/dist/scripts/icon-generator-config.d.ts +0 -1
- package/dist/scripts/icon-generator-config.js +7 -4
- package/dist/theme-base.d.ts.map +1 -1
- package/dist/vite-plugin-icons.d.ts +1 -2
- package/dist/vite-plugin-icons.js +109 -90
- package/package.json +24 -22
- package/dist/TransformOriginView-Dw_HKnFH.cjs +0 -17116
- package/dist/TransformOriginView-Dw_HKnFH.cjs.map +0 -1
- package/dist/TransformOriginView-i8uVBHb1.js +0 -17100
- package/dist/TransformOriginView-i8uVBHb1.js.map +0 -1
- package/dist/components/custom/index.cjs.map +0 -1
- package/dist/components/custom/index.js.map +0 -1
|
@@ -1,117 +1,105 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { readFile,
|
|
3
|
-
import {
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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: ${
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
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
|
-
|
|
186
|
+
process.exit(values.help ? 0 : 1);
|
|
177
187
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
188
|
+
var options = {
|
|
189
|
+
source: values.source,
|
|
190
|
+
output: values.output,
|
|
191
|
+
package: values.package
|
|
182
192
|
};
|
|
183
|
-
if (values.iconsPath)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (values.
|
|
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 {
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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"}
|