@number10/phaserjsx 0.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.
- package/LICENSE +667 -0
- package/README.md +238 -0
- package/dist/TransformOriginView-BYPbRH8N.cjs +17045 -0
- package/dist/TransformOriginView-BYPbRH8N.cjs.map +1 -0
- package/dist/TransformOriginView-CO-tJCmV.js +17046 -0
- package/dist/TransformOriginView-CO-tJCmV.js.map +1 -0
- package/dist/animation/animated-signal.d.ts +35 -0
- package/dist/animation/animated-signal.d.ts.map +1 -0
- package/dist/animation/index.d.ts +7 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/animation/spring-physics.d.ts +120 -0
- package/dist/animation/spring-physics.d.ts.map +1 -0
- package/dist/animation/useSpring.d.ts +54 -0
- package/dist/animation/useSpring.d.ts.map +1 -0
- package/dist/colors/color-presets.d.ts +89 -0
- package/dist/colors/color-presets.d.ts.map +1 -0
- package/dist/colors/color-theme-helpers.d.ts +65 -0
- package/dist/colors/color-theme-helpers.d.ts.map +1 -0
- package/dist/colors/color-types.d.ts +100 -0
- package/dist/colors/color-types.d.ts.map +1 -0
- package/dist/colors/color-utils.d.ts +171 -0
- package/dist/colors/color-utils.d.ts.map +1 -0
- package/dist/colors/index.d.ts +17 -0
- package/dist/colors/index.d.ts.map +1 -0
- package/dist/colors/preset-manager.d.ts +35 -0
- package/dist/colors/preset-manager.d.ts.map +1 -0
- package/dist/colors/use-color-mode.d.ts +22 -0
- package/dist/colors/use-color-mode.d.ts.map +1 -0
- package/dist/colors/use-colors.d.ts +40 -0
- package/dist/colors/use-colors.d.ts.map +1 -0
- package/dist/components/appliers/applyBackground.d.ts +13 -0
- package/dist/components/appliers/applyBackground.d.ts.map +1 -0
- package/dist/components/appliers/applyGestures.d.ts +12 -0
- package/dist/components/appliers/applyGestures.d.ts.map +1 -0
- package/dist/components/appliers/applyGraphics.d.ts +10 -0
- package/dist/components/appliers/applyGraphics.d.ts.map +1 -0
- package/dist/components/appliers/applyGraphicsLayout.d.ts +10 -0
- package/dist/components/appliers/applyGraphicsLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyImage.d.ts +10 -0
- package/dist/components/appliers/applyImage.d.ts.map +1 -0
- package/dist/components/appliers/applyImageLayout.d.ts +15 -0
- package/dist/components/appliers/applyImageLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyLayout.d.ts +15 -0
- package/dist/components/appliers/applyLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyNineSlice.d.ts +11 -0
- package/dist/components/appliers/applyNineSlice.d.ts.map +1 -0
- package/dist/components/appliers/applyNineSliceLayout.d.ts +15 -0
- package/dist/components/appliers/applyNineSliceLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyPhaser.d.ts +22 -0
- package/dist/components/appliers/applyPhaser.d.ts.map +1 -0
- package/dist/components/appliers/applySprite.d.ts +10 -0
- package/dist/components/appliers/applySprite.d.ts.map +1 -0
- package/dist/components/appliers/applySpriteLayout.d.ts +14 -0
- package/dist/components/appliers/applySpriteLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyText.d.ts +25 -0
- package/dist/components/appliers/applyText.d.ts.map +1 -0
- package/dist/components/appliers/applyTextLayout.d.ts +15 -0
- package/dist/components/appliers/applyTextLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyTooltip.d.ts +12 -0
- package/dist/components/appliers/applyTooltip.d.ts.map +1 -0
- package/dist/components/appliers/applyTransform.d.ts +21 -0
- package/dist/components/appliers/applyTransform.d.ts.map +1 -0
- package/dist/components/creators/createBackground.d.ts +15 -0
- package/dist/components/creators/createBackground.d.ts.map +1 -0
- package/dist/components/creators/createGestures.d.ts +11 -0
- package/dist/components/creators/createGestures.d.ts.map +1 -0
- package/dist/components/creators/createGraphicsLayout.d.ts +9 -0
- package/dist/components/creators/createGraphicsLayout.d.ts.map +1 -0
- package/dist/components/creators/createImageLayout.d.ts +14 -0
- package/dist/components/creators/createImageLayout.d.ts.map +1 -0
- package/dist/components/creators/createLayout.d.ts +15 -0
- package/dist/components/creators/createLayout.d.ts.map +1 -0
- package/dist/components/creators/createNineSliceLayout.d.ts +14 -0
- package/dist/components/creators/createNineSliceLayout.d.ts.map +1 -0
- package/dist/components/creators/createPhaser.d.ts +14 -0
- package/dist/components/creators/createPhaser.d.ts.map +1 -0
- package/dist/components/creators/createSpriteLayout.d.ts +15 -0
- package/dist/components/creators/createSpriteLayout.d.ts.map +1 -0
- package/dist/components/creators/createTextLayout.d.ts +14 -0
- package/dist/components/creators/createTextLayout.d.ts.map +1 -0
- package/dist/components/creators/createTransform.d.ts +11 -0
- package/dist/components/creators/createTransform.d.ts.map +1 -0
- package/dist/components/custom/Accordion.d.ts +34 -0
- package/dist/components/custom/Accordion.d.ts.map +1 -0
- package/dist/components/custom/AlertDialog.d.ts +63 -0
- package/dist/components/custom/AlertDialog.d.ts.map +1 -0
- package/dist/components/custom/Button.d.ts +44 -0
- package/dist/components/custom/Button.d.ts.map +1 -0
- package/dist/components/custom/CharText/CharText.d.ts +8 -0
- package/dist/components/custom/CharText/CharText.d.ts.map +1 -0
- package/dist/components/custom/CharText/index.d.ts +3 -0
- package/dist/components/custom/CharText/index.d.ts.map +1 -0
- package/dist/components/custom/CharText/types.d.ts +117 -0
- package/dist/components/custom/CharText/types.d.ts.map +1 -0
- package/dist/components/custom/CharText/utils.d.ts +34 -0
- package/dist/components/custom/CharText/utils.d.ts.map +1 -0
- package/dist/components/custom/CharTextInput.d.ts +62 -0
- package/dist/components/custom/CharTextInput.d.ts.map +1 -0
- package/dist/components/custom/Dialog.d.ts +60 -0
- package/dist/components/custom/Dialog.d.ts.map +1 -0
- package/dist/components/custom/Divider.d.ts +21 -0
- package/dist/components/custom/Divider.d.ts.map +1 -0
- package/dist/components/custom/Dropdown.d.ts +91 -0
- package/dist/components/custom/Dropdown.d.ts.map +1 -0
- package/dist/components/custom/Icon.d.ts +75 -0
- package/dist/components/custom/Icon.d.ts.map +1 -0
- package/dist/components/custom/Image.d.ts +50 -0
- package/dist/components/custom/Image.d.ts.map +1 -0
- package/dist/components/custom/Modal.d.ts +37 -0
- package/dist/components/custom/Modal.d.ts.map +1 -0
- package/dist/components/custom/NineSlice.d.ts +81 -0
- package/dist/components/custom/NineSlice.d.ts.map +1 -0
- package/dist/components/custom/NineSliceButton.d.ts +128 -0
- package/dist/components/custom/NineSliceButton.d.ts.map +1 -0
- package/dist/components/custom/Portal.d.ts +43 -0
- package/dist/components/custom/Portal.d.ts.map +1 -0
- package/dist/components/custom/Portal.test.d.ts +2 -0
- package/dist/components/custom/Portal.test.d.ts.map +1 -0
- package/dist/components/custom/RadioButton.d.ts +20 -0
- package/dist/components/custom/RadioButton.d.ts.map +1 -0
- package/dist/components/custom/RadioGroup.d.ts +33 -0
- package/dist/components/custom/RadioGroup.d.ts.map +1 -0
- package/dist/components/custom/RefOriginView.d.ts +45 -0
- package/dist/components/custom/RefOriginView.d.ts.map +1 -0
- package/dist/components/custom/ScrollSlider.d.ts +36 -0
- package/dist/components/custom/ScrollSlider.d.ts.map +1 -0
- package/dist/components/custom/ScrollView.d.ts +48 -0
- package/dist/components/custom/ScrollView.d.ts.map +1 -0
- package/dist/components/custom/Sidebar.d.ts +50 -0
- package/dist/components/custom/Sidebar.d.ts.map +1 -0
- package/dist/components/custom/Slider.d.ts +131 -0
- package/dist/components/custom/Slider.d.ts.map +1 -0
- package/dist/components/custom/Text.d.ts +26 -0
- package/dist/components/custom/Text.d.ts.map +1 -0
- package/dist/components/custom/Toggle.d.ts +51 -0
- package/dist/components/custom/Toggle.d.ts.map +1 -0
- package/dist/components/custom/TransformOriginView.d.ts +34 -0
- package/dist/components/custom/TransformOriginView.d.ts.map +1 -0
- package/dist/components/custom/View.d.ts +33 -0
- package/dist/components/custom/View.d.ts.map +1 -0
- package/dist/components/custom/WrapText.d.ts +60 -0
- package/dist/components/custom/WrapText.d.ts.map +1 -0
- package/dist/components/custom/index.cjs +32 -0
- package/dist/components/custom/index.cjs.map +1 -0
- package/dist/components/custom/index.d.ts +29 -0
- package/dist/components/custom/index.d.ts.map +1 -0
- package/dist/components/custom/index.js +32 -0
- package/dist/components/custom/index.js.map +1 -0
- package/dist/components/index.d.ts +28 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/internal/SceneWrapper.d.ts +20 -0
- package/dist/components/internal/SceneWrapper.d.ts.map +1 -0
- package/dist/components/primitives/graphics.d.ts +40 -0
- package/dist/components/primitives/graphics.d.ts.map +1 -0
- package/dist/components/primitives/image.d.ts +45 -0
- package/dist/components/primitives/image.d.ts.map +1 -0
- package/dist/components/primitives/nineslice.d.ts +111 -0
- package/dist/components/primitives/nineslice.d.ts.map +1 -0
- package/dist/components/primitives/sprite.d.ts +58 -0
- package/dist/components/primitives/sprite.d.ts.map +1 -0
- package/dist/components/primitives/text.d.ts +26 -0
- package/dist/components/primitives/text.d.ts.map +1 -0
- package/dist/components/primitives/tilesprite.d.ts +47 -0
- package/dist/components/primitives/tilesprite.d.ts.map +1 -0
- package/dist/components/primitives/view.d.ts +23 -0
- package/dist/components/primitives/view.d.ts.map +1 -0
- package/dist/core-props.d.ts +605 -0
- package/dist/core-props.d.ts.map +1 -0
- package/dist/core-types.d.ts +59 -0
- package/dist/core-types.d.ts.map +1 -0
- package/dist/design-tokens/design-token-presets.d.ts +26 -0
- package/dist/design-tokens/design-token-presets.d.ts.map +1 -0
- package/dist/design-tokens/design-token-types.d.ts +109 -0
- package/dist/design-tokens/design-token-types.d.ts.map +1 -0
- package/dist/design-tokens/index.d.ts +8 -0
- package/dist/design-tokens/index.d.ts.map +1 -0
- package/dist/design-tokens/use-theme-tokens.d.ts +28 -0
- package/dist/design-tokens/use-theme-tokens.d.ts.map +1 -0
- package/dist/dev-config.d.ts +238 -0
- package/dist/dev-config.d.ts.map +1 -0
- package/dist/effects/effect-registry.d.ts +54 -0
- package/dist/effects/effect-registry.d.ts.map +1 -0
- package/dist/effects/index.d.ts +56 -0
- package/dist/effects/index.d.ts.map +1 -0
- package/dist/effects/use-effect.d.ts +172 -0
- package/dist/effects/use-effect.d.ts.map +1 -0
- package/dist/fx/convenience-hooks/index.d.ts +7 -0
- package/dist/fx/convenience-hooks/index.d.ts.map +1 -0
- package/dist/fx/convenience-hooks/use-blur.d.ts +21 -0
- package/dist/fx/convenience-hooks/use-blur.d.ts.map +1 -0
- package/dist/fx/convenience-hooks/use-glow.d.ts +21 -0
- package/dist/fx/convenience-hooks/use-glow.d.ts.map +1 -0
- package/dist/fx/convenience-hooks/use-shadow.d.ts +21 -0
- package/dist/fx/convenience-hooks/use-shadow.d.ts.map +1 -0
- package/dist/fx/fx-creators/blur.d.ts +37 -0
- package/dist/fx/fx-creators/blur.d.ts.map +1 -0
- package/dist/fx/fx-creators/color-matrix.d.ts +31 -0
- package/dist/fx/fx-creators/color-matrix.d.ts.map +1 -0
- package/dist/fx/fx-creators/glow.d.ts +36 -0
- package/dist/fx/fx-creators/glow.d.ts.map +1 -0
- package/dist/fx/fx-creators/index.d.ts +10 -0
- package/dist/fx/fx-creators/index.d.ts.map +1 -0
- package/dist/fx/fx-creators/pixelate.d.ts +24 -0
- package/dist/fx/fx-creators/pixelate.d.ts.map +1 -0
- package/dist/fx/fx-creators/shadow.d.ts +43 -0
- package/dist/fx/fx-creators/shadow.d.ts.map +1 -0
- package/dist/fx/fx-creators/vignette.d.ts +33 -0
- package/dist/fx/fx-creators/vignette.d.ts.map +1 -0
- package/dist/fx/fx-registry.d.ts +59 -0
- package/dist/fx/fx-registry.d.ts.map +1 -0
- package/dist/fx/index.d.ts +51 -0
- package/dist/fx/index.d.ts.map +1 -0
- package/dist/fx/use-fx.d.ts +53 -0
- package/dist/fx/use-fx.d.ts.map +1 -0
- package/dist/gestures/gesture-manager.d.ts +149 -0
- package/dist/gestures/gesture-manager.d.ts.map +1 -0
- package/dist/gestures/gesture-types.d.ts +229 -0
- package/dist/gestures/gesture-types.d.ts.map +1 -0
- package/dist/hooks-svg.d.ts +104 -0
- package/dist/hooks-svg.d.ts.map +1 -0
- package/dist/hooks.d.ts +135 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/host.d.ts +74 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/index.cjs +584 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +582 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.cjs +10 -0
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +5 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +11 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.cjs +43 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.d.ts +25 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +43 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/jsx-types.d.ts +33 -0
- package/dist/jsx-types.d.ts.map +1 -0
- package/dist/layout/appliers/background-applier.d.ts +16 -0
- package/dist/layout/appliers/background-applier.d.ts.map +1 -0
- package/dist/layout/appliers/container-applier.d.ts +9 -0
- package/dist/layout/appliers/container-applier.d.ts.map +1 -0
- package/dist/layout/appliers/position-applier.d.ts +8 -0
- package/dist/layout/appliers/position-applier.d.ts.map +1 -0
- package/dist/layout/index.d.ts +22 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/layout-engine-test-utils.d.ts +19 -0
- package/dist/layout/layout-engine-test-utils.d.ts.map +1 -0
- package/dist/layout/layout-engine.d.ts +98 -0
- package/dist/layout/layout-engine.d.ts.map +1 -0
- package/dist/layout/strategies/base-strategy.d.ts +59 -0
- package/dist/layout/strategies/base-strategy.d.ts.map +1 -0
- package/dist/layout/strategies/column-layout.d.ts +38 -0
- package/dist/layout/strategies/column-layout.d.ts.map +1 -0
- package/dist/layout/strategies/row-layout.d.ts +38 -0
- package/dist/layout/strategies/row-layout.d.ts.map +1 -0
- package/dist/layout/strategies/stack-layout.d.ts +30 -0
- package/dist/layout/strategies/stack-layout.d.ts.map +1 -0
- package/dist/layout/types.d.ts +137 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout/utils/child-utils.d.ts +74 -0
- package/dist/layout/utils/child-utils.d.ts.map +1 -0
- package/dist/layout/utils/dimension-calculator.d.ts +59 -0
- package/dist/layout/utils/dimension-calculator.d.ts.map +1 -0
- package/dist/layout/utils/flex-distributor.d.ts +18 -0
- package/dist/layout/utils/flex-distributor.d.ts.map +1 -0
- package/dist/layout/utils/size-resolver.d.ts +84 -0
- package/dist/layout/utils/size-resolver.d.ts.map +1 -0
- package/dist/layout/utils/spacing-calculator.d.ts +27 -0
- package/dist/layout/utils/spacing-calculator.d.ts.map +1 -0
- package/dist/memo.d.ts +29 -0
- package/dist/memo.d.ts.map +1 -0
- package/dist/portal/index.d.ts +6 -0
- package/dist/portal/index.d.ts.map +1 -0
- package/dist/portal/portal-registry.d.ts +97 -0
- package/dist/portal/portal-registry.d.ts.map +1 -0
- package/dist/portal/portal-types.d.ts +20 -0
- package/dist/portal/portal-types.d.ts.map +1 -0
- package/dist/render-context.d.ts +118 -0
- package/dist/render-context.d.ts.map +1 -0
- package/dist/scripts/generate-icon-loaders.d.ts +2 -0
- package/dist/scripts/generate-icon-loaders.d.ts.map +1 -0
- package/dist/scripts/generate-icon-loaders.js +195 -0
- package/dist/scripts/generate-icon-types.d.ts +2 -0
- package/dist/scripts/generate-icon-types.d.ts.map +1 -0
- package/dist/scripts/generate-icon-types.js +124 -0
- package/dist/scripts/generate-icons.d.ts +37 -0
- package/dist/scripts/generate-icons.d.ts.map +1 -0
- package/dist/scripts/generate-icons.js +494 -0
- package/dist/scripts/icon-generator-config.d.ts +87 -0
- package/dist/scripts/icon-generator-config.d.ts.map +1 -0
- package/dist/scripts/icon-generator-config.js +6 -0
- package/dist/theme-base.d.ts +116 -0
- package/dist/theme-base.d.ts.map +1 -0
- package/dist/theme-custom.d.ts +262 -0
- package/dist/theme-custom.d.ts.map +1 -0
- package/dist/theme-defaults.d.ts +6 -0
- package/dist/theme-defaults.d.ts.map +1 -0
- package/dist/theme.d.ts +132 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/tooltip/tooltip-types.d.ts +57 -0
- package/dist/tooltip/tooltip-types.d.ts.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/KeyboardInputManager.d.ts +48 -0
- package/dist/utils/KeyboardInputManager.d.ts.map +1 -0
- package/dist/utils/dom-input-manager.d.ts +109 -0
- package/dist/utils/dom-input-manager.d.ts.map +1 -0
- package/dist/utils/svg-texture.d.ts +30 -0
- package/dist/utils/svg-texture.d.ts.map +1 -0
- package/dist/utils/texture-registry.d.ts +49 -0
- package/dist/utils/texture-registry.d.ts.map +1 -0
- package/dist/vdom.d.ts +60 -0
- package/dist/vdom.d.ts.map +1 -0
- package/dist/viewport-context.d.ts +39 -0
- package/dist/viewport-context.d.ts.map +1 -0
- package/dist/vite-plugin-icons.d.ts +29 -0
- package/dist/vite-plugin-icons.d.ts.map +1 -0
- package/dist/vite-plugin-icons.js +95 -0
- package/package.json +117 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { watch } from "node:fs";
|
|
3
|
+
import { readdir, writeFile, readFile, access } from "node:fs/promises";
|
|
4
|
+
import { resolve, extname, join, basename, dirname, relative } from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
const TS_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".mts", ".cts", ".tsx"]);
|
|
8
|
+
async function findIconPackage(packageName, cwd) {
|
|
9
|
+
const fs = await import("node:fs");
|
|
10
|
+
const pnpmBase = join(cwd, "node_modules/.pnpm");
|
|
11
|
+
if (fs.existsSync(pnpmBase)) {
|
|
12
|
+
const entries = await readdir(pnpmBase);
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
if (entry.startsWith(`${packageName}@`)) {
|
|
15
|
+
const packagePath = join(pnpmBase, entry, "node_modules", packageName);
|
|
16
|
+
if (fs.existsSync(packagePath)) {
|
|
17
|
+
return packagePath;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const standardPath = join(cwd, "node_modules", packageName);
|
|
23
|
+
if (fs.existsSync(standardPath)) {
|
|
24
|
+
return standardPath;
|
|
25
|
+
}
|
|
26
|
+
throw new Error(`Could not find package: ${packageName}`);
|
|
27
|
+
}
|
|
28
|
+
async function findTsFiles(dir, exclude = []) {
|
|
29
|
+
const files = [];
|
|
30
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
const fullPath = join(dir, entry.name);
|
|
33
|
+
if (exclude.some((pattern) => fullPath.includes(pattern))) continue;
|
|
34
|
+
if (entry.isDirectory()) {
|
|
35
|
+
if (entry.name === "node_modules" || entry.name === "dist") continue;
|
|
36
|
+
files.push(...await findTsFiles(fullPath, exclude));
|
|
37
|
+
} else if (entry.isFile() && /\.(tsx?|jsx?)$/.test(entry.name)) {
|
|
38
|
+
files.push(fullPath);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return files;
|
|
42
|
+
}
|
|
43
|
+
function extractIconNames(content, componentNames, customPatterns) {
|
|
44
|
+
const iconNames = /* @__PURE__ */ new Set();
|
|
45
|
+
let match;
|
|
46
|
+
for (const componentName of componentNames) {
|
|
47
|
+
const typePattern = new RegExp(
|
|
48
|
+
`<${componentName}\\s+[^>]*type=(?:["']([^"']+)["']|\\{["']([^"']+)["']\\})`,
|
|
49
|
+
"g"
|
|
50
|
+
);
|
|
51
|
+
while ((match = typePattern.exec(content)) !== null) {
|
|
52
|
+
const iconName = match[1] || match[2];
|
|
53
|
+
if (iconName) {
|
|
54
|
+
iconNames.add(iconName);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const themedPattern = /themed\.(\w*[Ii]con)\s*\?\?\s*["']([^"']+)["']/g;
|
|
59
|
+
while ((match = themedPattern.exec(content)) !== null) {
|
|
60
|
+
if (match[2]) {
|
|
61
|
+
iconNames.add(match[2]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const iconPropPattern = /(?:icon|iconType):\s*["']([^"']+)["']/g;
|
|
65
|
+
while ((match = iconPropPattern.exec(content)) !== null) {
|
|
66
|
+
if (match[1]) {
|
|
67
|
+
iconNames.add(match[1]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (customPatterns) {
|
|
71
|
+
for (const customPattern of customPatterns) {
|
|
72
|
+
const pattern = new RegExp(customPattern.pattern, "g");
|
|
73
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
74
|
+
const iconName = match[customPattern.captureGroup];
|
|
75
|
+
if (iconName) {
|
|
76
|
+
iconNames.add(iconName);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return iconNames;
|
|
82
|
+
}
|
|
83
|
+
async function loadAvailableIcons(typesFile) {
|
|
84
|
+
try {
|
|
85
|
+
const content = await readFile(typesFile, "utf-8");
|
|
86
|
+
const match = content.match(/(?:export\s+)?type\s+\w+\s*=\s*([\s\S]+?)(?=\n\nexport|\n\/\/|$)/s);
|
|
87
|
+
if (!match?.[1]) return null;
|
|
88
|
+
const typeContent = match[1];
|
|
89
|
+
const icons = /* @__PURE__ */ new Set();
|
|
90
|
+
const iconPattern = /'([^']+)'/g;
|
|
91
|
+
let iconMatch;
|
|
92
|
+
while ((iconMatch = iconPattern.exec(typeContent)) !== null) {
|
|
93
|
+
const iconName = iconMatch[1];
|
|
94
|
+
if (iconName) {
|
|
95
|
+
icons.add(iconName);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return icons;
|
|
99
|
+
} catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function generateTypes(config, cwd) {
|
|
104
|
+
if (!config.types?.enabled) return null;
|
|
105
|
+
console.log("\n📝 Generating icon types...");
|
|
106
|
+
const sources = Array.isArray(config.source) ? config.source : [config.source];
|
|
107
|
+
const allIconNames = [];
|
|
108
|
+
const sourceInfos = [];
|
|
109
|
+
const sourceIconSets = /* @__PURE__ */ new Map();
|
|
110
|
+
for (let i = 0; i < sources.length; i++) {
|
|
111
|
+
const source = sources[i];
|
|
112
|
+
if (!source) continue;
|
|
113
|
+
let iconsDir;
|
|
114
|
+
let sourceName;
|
|
115
|
+
if (source.directory) {
|
|
116
|
+
iconsDir = resolve(cwd, source.directory);
|
|
117
|
+
sourceName = source.label || source.directory;
|
|
118
|
+
console.log(`📁 Scanning directory: ${source.directory}`);
|
|
119
|
+
} else if (source.package) {
|
|
120
|
+
const packagePath = await findIconPackage(source.package, cwd);
|
|
121
|
+
iconsDir = join(packagePath, source.iconsPath || "icons");
|
|
122
|
+
sourceName = source.label || source.package;
|
|
123
|
+
console.log(`📦 Scanning package: ${source.package}`);
|
|
124
|
+
} else {
|
|
125
|
+
throw new Error("Either source.package or source.directory must be specified");
|
|
126
|
+
}
|
|
127
|
+
const files = await readdir(iconsDir);
|
|
128
|
+
const iconNames = files.filter((file) => file.endsWith(".svg")).map((file) => basename(file, ".svg"));
|
|
129
|
+
console.log(`✓ Found ${iconNames.length} icons from ${sourceName}`);
|
|
130
|
+
allIconNames.push(...iconNames);
|
|
131
|
+
sourceInfos.push({ name: sourceName, count: iconNames.length });
|
|
132
|
+
sourceIconSets.set(i, new Set(iconNames));
|
|
133
|
+
}
|
|
134
|
+
const uniqueIconNames = [...new Set(allIconNames)].sort();
|
|
135
|
+
console.log(`✓ Total unique icons: ${uniqueIconNames.length}`);
|
|
136
|
+
const typeDefinition = uniqueIconNames.map((name) => ` | '${name}'`).join("\n");
|
|
137
|
+
const typeName = config.types.typeName || "IconType";
|
|
138
|
+
const sourceList = sourceInfos.length === 1 && sourceInfos[0] ? sourceInfos[0].name : sourceInfos.map((s) => `${s.name} (${s.count})`).join(", ");
|
|
139
|
+
const output = `/**
|
|
140
|
+
* Auto-generated icon type definitions
|
|
141
|
+
* Sources: ${sourceList}
|
|
142
|
+
* Total unique icons: ${uniqueIconNames.length}
|
|
143
|
+
*
|
|
144
|
+
* @generated by @number10/phaserjsx/generate-icons
|
|
145
|
+
* @cspell: disable
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* All available icon names
|
|
150
|
+
* Type-only definition - no runtime imports, zero bundle impact
|
|
151
|
+
*/
|
|
152
|
+
export type ${typeName} =
|
|
153
|
+
${typeDefinition}
|
|
154
|
+
`;
|
|
155
|
+
const outputPath = resolve(cwd, config.types.output);
|
|
156
|
+
await writeFile(outputPath, output, "utf-8");
|
|
157
|
+
console.log(`✓ Generated: ${outputPath}`);
|
|
158
|
+
console.log(`✓ Type name: ${typeName}`);
|
|
159
|
+
return { iconNames: uniqueIconNames, sourceIconSets };
|
|
160
|
+
}
|
|
161
|
+
async function scanIconSources(config, cwd) {
|
|
162
|
+
const sources = Array.isArray(config.source) ? config.source : [config.source];
|
|
163
|
+
const allIconNames = [];
|
|
164
|
+
const sourceIconSets = /* @__PURE__ */ new Map();
|
|
165
|
+
for (let i = 0; i < sources.length; i++) {
|
|
166
|
+
const source = sources[i];
|
|
167
|
+
if (!source) continue;
|
|
168
|
+
let iconsDir;
|
|
169
|
+
if (source.directory) {
|
|
170
|
+
iconsDir = resolve(cwd, source.directory);
|
|
171
|
+
} else if (source.package) {
|
|
172
|
+
const packagePath = await findIconPackage(source.package, cwd);
|
|
173
|
+
iconsDir = join(packagePath, source.iconsPath || "icons");
|
|
174
|
+
} else {
|
|
175
|
+
throw new Error("Either source.package or source.directory must be specified");
|
|
176
|
+
}
|
|
177
|
+
const files = await readdir(iconsDir);
|
|
178
|
+
const iconNames = files.filter((file) => file.endsWith(".svg")).map((file) => basename(file, ".svg"));
|
|
179
|
+
allIconNames.push(...iconNames);
|
|
180
|
+
sourceIconSets.set(i, new Set(iconNames));
|
|
181
|
+
}
|
|
182
|
+
const uniqueIconNames = [...new Set(allIconNames)].sort();
|
|
183
|
+
return { iconNames: uniqueIconNames, sourceIconSets };
|
|
184
|
+
}
|
|
185
|
+
async function generateLoaders(config, cwd, typesResult) {
|
|
186
|
+
if (!config.loaders?.enabled) return;
|
|
187
|
+
console.log("\n⚡ Generating icon loaders...");
|
|
188
|
+
const scanDir = resolve(cwd, config.loaders.scanDir);
|
|
189
|
+
const componentNames = config.loaders.componentNames || ["Icon"];
|
|
190
|
+
console.log(`📁 Scanning directory: ${scanDir}`);
|
|
191
|
+
console.log(`🔍 Looking for components: ${componentNames.join(", ")}`);
|
|
192
|
+
let availableIconsSet = null;
|
|
193
|
+
let sourceIconSets = null;
|
|
194
|
+
if (typesResult) {
|
|
195
|
+
availableIconsSet = new Set(typesResult.iconNames);
|
|
196
|
+
sourceIconSets = typesResult.sourceIconSets;
|
|
197
|
+
console.log(`✓ Loaded ${availableIconsSet.size} available icons for validation`);
|
|
198
|
+
} else if (config.loaders.validate && config.types?.output) {
|
|
199
|
+
const typesPath = resolve(cwd, config.types.output);
|
|
200
|
+
availableIconsSet = await loadAvailableIcons(typesPath);
|
|
201
|
+
if (availableIconsSet) {
|
|
202
|
+
console.log(`✓ Loaded ${availableIconsSet.size} available icons for validation`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const files = await findTsFiles(scanDir, config.exclude);
|
|
206
|
+
console.log(`📄 Found ${files.length} TypeScript files`);
|
|
207
|
+
const allIconNames = /* @__PURE__ */ new Set();
|
|
208
|
+
for (const file of files) {
|
|
209
|
+
const content = await readFile(file, "utf-8");
|
|
210
|
+
const icons = extractIconNames(content, componentNames, config.customPatterns);
|
|
211
|
+
icons.forEach((icon) => allIconNames.add(icon));
|
|
212
|
+
}
|
|
213
|
+
let iconArray = Array.from(allIconNames).sort();
|
|
214
|
+
if (availableIconsSet) {
|
|
215
|
+
const invalidIcons = iconArray.filter((icon) => !availableIconsSet.has(icon));
|
|
216
|
+
if (invalidIcons.length > 0) {
|
|
217
|
+
console.warn(`⚠️ Found ${invalidIcons.length} icons not in types file:`);
|
|
218
|
+
console.warn(
|
|
219
|
+
` ${invalidIcons.slice(0, 5).join(", ")}${invalidIcons.length > 5 ? "..." : ""}`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
iconArray = iconArray.filter((icon) => availableIconsSet.has(icon));
|
|
223
|
+
}
|
|
224
|
+
console.log(`✓ Found ${iconArray.length} unique icons`);
|
|
225
|
+
if (iconArray.length > 0) {
|
|
226
|
+
console.log(
|
|
227
|
+
` Icons: ${iconArray.slice(0, 10).join(", ")}${iconArray.length > 10 ? "..." : ""}`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
const sources = Array.isArray(config.source) ? config.source : [config.source];
|
|
231
|
+
const iconSourceMap = /* @__PURE__ */ new Map();
|
|
232
|
+
for (const icon of iconArray) {
|
|
233
|
+
if (sourceIconSets) {
|
|
234
|
+
for (let i = 0; i < sources.length; i++) {
|
|
235
|
+
const source = sources[i];
|
|
236
|
+
const iconsForThisSource = sourceIconSets.get(i);
|
|
237
|
+
if (!source || !iconsForThisSource) continue;
|
|
238
|
+
if (iconsForThisSource.has(icon)) {
|
|
239
|
+
let iconPath = "";
|
|
240
|
+
if (source.package) {
|
|
241
|
+
const packageName = source.package;
|
|
242
|
+
const iconsPath = source.iconsPath || "icons";
|
|
243
|
+
iconPath = `${packageName}/${iconsPath}/${icon}.svg`;
|
|
244
|
+
} else if (source.directory) {
|
|
245
|
+
iconPath = `${source.directory}/${icon}.svg`;
|
|
246
|
+
}
|
|
247
|
+
if (iconPath) {
|
|
248
|
+
if (source.directory && config.loaders.output) {
|
|
249
|
+
const loaderDir = dirname(resolve(cwd, config.loaders.output));
|
|
250
|
+
const iconAbsPath = resolve(cwd, iconPath);
|
|
251
|
+
iconPath = relative(loaderDir, iconAbsPath);
|
|
252
|
+
iconPath = "./" + iconPath.replace(/\\/g, "/");
|
|
253
|
+
}
|
|
254
|
+
iconSourceMap.set(icon, {
|
|
255
|
+
path: iconPath,
|
|
256
|
+
isPackage: !!source.package
|
|
257
|
+
});
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
} else {
|
|
263
|
+
for (const source of sources) {
|
|
264
|
+
let iconPath = "";
|
|
265
|
+
let exists = false;
|
|
266
|
+
if (source.package) {
|
|
267
|
+
const packageName = source.package;
|
|
268
|
+
const iconsPath = source.iconsPath || "icons";
|
|
269
|
+
iconPath = `${packageName}/${iconsPath}/${icon}.svg`;
|
|
270
|
+
exists = availableIconsSet ? availableIconsSet.has(icon) : true;
|
|
271
|
+
} else if (source.directory) {
|
|
272
|
+
const dirPath = source.directory;
|
|
273
|
+
iconPath = `${dirPath}/${icon}.svg`;
|
|
274
|
+
try {
|
|
275
|
+
const fullPath = resolve(cwd, dirPath, `${icon}.svg`);
|
|
276
|
+
await access(fullPath);
|
|
277
|
+
exists = true;
|
|
278
|
+
} catch {
|
|
279
|
+
exists = false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (exists && iconPath) {
|
|
283
|
+
if (source.directory && config.loaders.output) {
|
|
284
|
+
const loaderDir = dirname(resolve(cwd, config.loaders.output));
|
|
285
|
+
const iconAbsPath = resolve(cwd, iconPath);
|
|
286
|
+
iconPath = relative(loaderDir, iconAbsPath);
|
|
287
|
+
iconPath = "./" + iconPath.replace(/\\/g, "/");
|
|
288
|
+
}
|
|
289
|
+
iconSourceMap.set(icon, {
|
|
290
|
+
path: iconPath,
|
|
291
|
+
isPackage: !!source.package
|
|
292
|
+
});
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const loaderEntries = Array.from(iconSourceMap.entries()).map(([icon, { path, isPackage }]) => {
|
|
299
|
+
if (isPackage) {
|
|
300
|
+
return ` '${icon}': () => import('${path}?raw'),`;
|
|
301
|
+
} else {
|
|
302
|
+
return ` '${icon}': () => import('${path}?raw'),`;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
const loaders = loaderEntries.join("\n");
|
|
306
|
+
const outputContent = `/**
|
|
307
|
+
* Auto-generated icon loaders
|
|
308
|
+
* Generated by scanning: ${config.loaders.scanDir}
|
|
309
|
+
*
|
|
310
|
+
* @generated by @number10/phaserjsx/generate-icons
|
|
311
|
+
*/
|
|
312
|
+
export type IconLoaderFn = () => Promise<{ default: string }>
|
|
313
|
+
|
|
314
|
+
export const iconLoaders: Record<string, IconLoaderFn> = {
|
|
315
|
+
${loaders}
|
|
316
|
+
}
|
|
317
|
+
`;
|
|
318
|
+
const outputPath = resolve(cwd, config.loaders.output);
|
|
319
|
+
await writeFile(outputPath, outputContent, "utf-8");
|
|
320
|
+
console.log(`✓ Generated: ${outputPath}`);
|
|
321
|
+
console.log(`✓ Registered ${iconArray.length} icon loaders`);
|
|
322
|
+
}
|
|
323
|
+
async function loadConfig(configPath, cwd = process.cwd()) {
|
|
324
|
+
const absolutePath = resolve(cwd, configPath);
|
|
325
|
+
const fileUrl = pathToFileURL(absolutePath).href;
|
|
326
|
+
const extension = extname(absolutePath).toLowerCase();
|
|
327
|
+
try {
|
|
328
|
+
const module = await import(fileUrl);
|
|
329
|
+
return module.default || module;
|
|
330
|
+
} catch (error) {
|
|
331
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
332
|
+
const isUnknownExtension = TS_CONFIG_EXTENSIONS.has(extension) || errorMessage.includes("Unknown file extension");
|
|
333
|
+
if (isUnknownExtension) {
|
|
334
|
+
try {
|
|
335
|
+
const { tsImport } = await import("tsx/esm/api");
|
|
336
|
+
const module = await tsImport(fileUrl, import.meta.url);
|
|
337
|
+
return module.default || module;
|
|
338
|
+
} catch (tsxError) {
|
|
339
|
+
const tsxMessage = tsxError instanceof Error ? tsxError.message : String(tsxError);
|
|
340
|
+
throw new Error(
|
|
341
|
+
`Failed to load config from ${configPath}: ${tsxMessage} (after tsx fallback)`
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
throw new Error(`Failed to load config from ${configPath}: ${errorMessage}`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
async function runGeneration(config, cwd) {
|
|
349
|
+
console.log("🎨 Icon Generator");
|
|
350
|
+
console.log("─".repeat(50));
|
|
351
|
+
const typesResult = await generateTypes(config, cwd);
|
|
352
|
+
await generateLoaders(config, cwd, typesResult || void 0);
|
|
353
|
+
console.log("\n✨ Done!\n");
|
|
354
|
+
}
|
|
355
|
+
async function watchMode(config, cwd) {
|
|
356
|
+
console.log("👁️ Watch mode enabled");
|
|
357
|
+
console.log("📁 Monitoring for changes...\n");
|
|
358
|
+
await runGeneration(config, cwd);
|
|
359
|
+
const watchDirs = /* @__PURE__ */ new Set();
|
|
360
|
+
if (config.loaders?.enabled) {
|
|
361
|
+
const scanDir = resolve(cwd, config.loaders.scanDir);
|
|
362
|
+
watchDirs.add(scanDir);
|
|
363
|
+
}
|
|
364
|
+
const sources = Array.isArray(config.source) ? config.source : [config.source];
|
|
365
|
+
for (const source of sources) {
|
|
366
|
+
if (source.directory) {
|
|
367
|
+
watchDirs.add(resolve(cwd, source.directory));
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
let regenerateTimeout = null;
|
|
371
|
+
const scheduleRegenerate = () => {
|
|
372
|
+
if (regenerateTimeout) {
|
|
373
|
+
clearTimeout(regenerateTimeout);
|
|
374
|
+
}
|
|
375
|
+
regenerateTimeout = setTimeout(async () => {
|
|
376
|
+
console.log("\n🔄 Changes detected, regenerating...");
|
|
377
|
+
try {
|
|
378
|
+
await runGeneration(config, cwd);
|
|
379
|
+
} catch (error) {
|
|
380
|
+
console.error("❌ Error during regeneration:", error);
|
|
381
|
+
}
|
|
382
|
+
}, 300);
|
|
383
|
+
};
|
|
384
|
+
for (const dir of watchDirs) {
|
|
385
|
+
const watcher = watch(dir, { recursive: true }, (eventType, filename) => {
|
|
386
|
+
if (!filename) return;
|
|
387
|
+
if (filename.includes("node_modules") || filename.includes(".git") || filename.endsWith(".generated.ts") || filename.startsWith(".")) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if (/\.(tsx?|svg)$/.test(filename)) {
|
|
391
|
+
console.log(`📝 ${eventType}: ${filename}`);
|
|
392
|
+
scheduleRegenerate();
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
watcher.on("error", (error) => {
|
|
396
|
+
console.error(`❌ Watch error for ${dir}:`, error);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
console.log(`👀 Watching ${watchDirs.size} directories`);
|
|
400
|
+
console.log("Press Ctrl+C to stop\n");
|
|
401
|
+
await new Promise(() => {
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
async function main() {
|
|
405
|
+
const { values } = parseArgs({
|
|
406
|
+
options: {
|
|
407
|
+
config: { type: "string", short: "c" },
|
|
408
|
+
typesOnly: { type: "boolean" },
|
|
409
|
+
loadersOnly: { type: "boolean" },
|
|
410
|
+
watch: { type: "boolean", short: "w" },
|
|
411
|
+
help: { type: "boolean", short: "h" }
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
if (values.help) {
|
|
415
|
+
console.log(`
|
|
416
|
+
Usage: generate-icons [options]
|
|
417
|
+
|
|
418
|
+
Options:
|
|
419
|
+
-c, --config <path> Path to config file (e.g., ./icon-generator.config.ts)
|
|
420
|
+
--typesOnly Only generate types (skip loaders)
|
|
421
|
+
--loadersOnly Only generate loaders (skip types)
|
|
422
|
+
-h, --help Show this help message
|
|
423
|
+
|
|
424
|
+
Config File Example:
|
|
425
|
+
// icon-generator.config.ts
|
|
426
|
+
import { defineIconConfig } from '@number10/phaserjsx/scripts/icon-generator-config'
|
|
427
|
+
|
|
428
|
+
export default defineIconConfig({
|
|
429
|
+
source: {
|
|
430
|
+
package: 'bootstrap-icons',
|
|
431
|
+
iconsPath: 'icons',
|
|
432
|
+
},
|
|
433
|
+
types: {
|
|
434
|
+
enabled: true,
|
|
435
|
+
output: './src/icon-types.generated.ts',
|
|
436
|
+
typeName: 'IconType',
|
|
437
|
+
},
|
|
438
|
+
loaders: {
|
|
439
|
+
enabled: true,
|
|
440
|
+
output: './src/icon-loaders.generated.ts',
|
|
441
|
+
scanDir: './src',
|
|
442
|
+
componentNames: ['Icon', 'BootstrapIcon'],
|
|
443
|
+
validate: true,
|
|
444
|
+
},
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
Examples:
|
|
448
|
+
# Using config file
|
|
449
|
+
generate-icons --config ./icon-generator.config.ts
|
|
450
|
+
|
|
451
|
+
# Generate only types
|
|
452
|
+
generate-icons --config ./icon-generator.config.ts --typesOnly
|
|
453
|
+
|
|
454
|
+
# Generate only loaders
|
|
455
|
+
generate-icons --config ./icon-generator.config.ts --loadersOnly
|
|
456
|
+
|
|
457
|
+
# Watch mode - regenerate on file changes
|
|
458
|
+
generate-icons --config ./icon-generator.config.ts --watch
|
|
459
|
+
`);
|
|
460
|
+
process.exit(0);
|
|
461
|
+
}
|
|
462
|
+
if (!values.config) {
|
|
463
|
+
console.error("❌ Error: --config is required");
|
|
464
|
+
console.error("Run with --help for usage information");
|
|
465
|
+
process.exit(1);
|
|
466
|
+
}
|
|
467
|
+
try {
|
|
468
|
+
const cwd = process.cwd();
|
|
469
|
+
let config = await loadConfig(values.config);
|
|
470
|
+
if (values.typesOnly && config.loaders) {
|
|
471
|
+
config = { ...config, loaders: { ...config.loaders, enabled: false } };
|
|
472
|
+
}
|
|
473
|
+
if (values.loadersOnly && config.types) {
|
|
474
|
+
config = { ...config, types: { ...config.types, enabled: false } };
|
|
475
|
+
}
|
|
476
|
+
if (values.watch) {
|
|
477
|
+
await watchMode(config, cwd);
|
|
478
|
+
} else {
|
|
479
|
+
await runGeneration(config, cwd);
|
|
480
|
+
}
|
|
481
|
+
} catch (error) {
|
|
482
|
+
console.error("❌ Error:", error);
|
|
483
|
+
process.exit(1);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
487
|
+
main();
|
|
488
|
+
}
|
|
489
|
+
export {
|
|
490
|
+
generateLoaders,
|
|
491
|
+
generateTypes,
|
|
492
|
+
loadConfig,
|
|
493
|
+
scanIconSources
|
|
494
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration schema for icon generators
|
|
3
|
+
* This file defines the TypeScript types for icon-generator.config.ts
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Source configuration - where to find icons
|
|
7
|
+
*/
|
|
8
|
+
export interface IconSource {
|
|
9
|
+
/** Icon package name from node_modules (e.g., 'bootstrap-icons') */
|
|
10
|
+
package?: string;
|
|
11
|
+
/** Local directory with SVG files (alternative to package) */
|
|
12
|
+
directory?: string;
|
|
13
|
+
/** Relative path to icons within package (default: 'icons') */
|
|
14
|
+
iconsPath?: string;
|
|
15
|
+
/** Optional label for this source (used in logs for multi-source) */
|
|
16
|
+
label?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Type generation configuration
|
|
20
|
+
*/
|
|
21
|
+
export interface TypesConfig {
|
|
22
|
+
/** Enable types generation */
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
/** Output file path for generated types */
|
|
25
|
+
output: string;
|
|
26
|
+
/** TypeScript type name (default: 'IconType') */
|
|
27
|
+
typeName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* When to scan icon directories (Vite plugin only)
|
|
30
|
+
* - 'never': Never scan (types must be generated manually)
|
|
31
|
+
* - 'start': Scan once at startup
|
|
32
|
+
* - 'watch': Scan at startup and on SVG file changes (default)
|
|
33
|
+
*/
|
|
34
|
+
scanIconDirectory?: 'never' | 'start' | 'watch';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Loader generation configuration
|
|
38
|
+
*/
|
|
39
|
+
export interface LoadersConfig {
|
|
40
|
+
/** Enable loaders generation */
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
/** Output file path for generated loaders */
|
|
43
|
+
output: string;
|
|
44
|
+
/** Source directory to scan for icon usage */
|
|
45
|
+
scanDir: string;
|
|
46
|
+
/** Component names to search for (e.g., ['Icon', 'BootstrapIcon']) */
|
|
47
|
+
componentNames?: string[];
|
|
48
|
+
/** Validate against types file (enables warnings for invalid icons) */
|
|
49
|
+
validate?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* When to generate loaders (Vite plugin only)
|
|
52
|
+
* - 'start': Generate once at startup
|
|
53
|
+
* - 'watch': Generate at startup and on code file changes (default)
|
|
54
|
+
*/
|
|
55
|
+
generateLoaders?: 'start' | 'watch';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Custom pattern for detecting icon usage
|
|
59
|
+
*/
|
|
60
|
+
export interface CustomPattern {
|
|
61
|
+
/** Pattern name/description */
|
|
62
|
+
name: string;
|
|
63
|
+
/** Regex pattern as string (will be compiled with 'g' flag) */
|
|
64
|
+
pattern: string;
|
|
65
|
+
/** Capture group index for icon name (1-based) */
|
|
66
|
+
captureGroup: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Main configuration for icon generator
|
|
70
|
+
*/
|
|
71
|
+
export interface IconGeneratorConfig {
|
|
72
|
+
/** Icon source configuration - single source or array of sources */
|
|
73
|
+
source: IconSource | IconSource[];
|
|
74
|
+
/** Type generation configuration */
|
|
75
|
+
types?: TypesConfig;
|
|
76
|
+
/** Loader generation configuration */
|
|
77
|
+
loaders?: LoadersConfig;
|
|
78
|
+
/** Custom patterns for detecting icon usage in loaders */
|
|
79
|
+
customPatterns?: CustomPattern[];
|
|
80
|
+
/** Exclude patterns (glob) when scanning for icons */
|
|
81
|
+
exclude?: string[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Helper function to define config with type safety
|
|
85
|
+
*/
|
|
86
|
+
export declare function defineIconConfig(config: IconGeneratorConfig): IconGeneratorConfig;
|
|
87
|
+
//# sourceMappingURL=icon-generator-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-generator-config.d.ts","sourceRoot":"","sources":["../../src/scripts/icon-generator-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAA;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAA;IACd,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAA;IACf,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAA;IACf,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,CAAA;IAEjC,oCAAoC;IACpC,KAAK,CAAC,EAAE,WAAW,CAAA;IAEnB,sCAAsC;IACtC,OAAO,CAAC,EAAE,aAAa,CAAA;IAEvB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,aAAa,EAAE,CAAA;IAEhC,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAEjF"}
|