@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,97 @@
|
|
|
1
|
+
import { default as Phaser } from 'phaser';
|
|
2
|
+
import { VNode } from '../hooks';
|
|
3
|
+
import { PortalTree } from './portal-types';
|
|
4
|
+
/**
|
|
5
|
+
* Global portal registry
|
|
6
|
+
* Manages all portal trees across scenes with depth-based ordering
|
|
7
|
+
*/
|
|
8
|
+
declare class PortalRegistry {
|
|
9
|
+
private portals;
|
|
10
|
+
private idCounter;
|
|
11
|
+
private portalRoots;
|
|
12
|
+
private viewportSizes;
|
|
13
|
+
/**
|
|
14
|
+
* Generate unique portal ID
|
|
15
|
+
* @returns Unique portal ID
|
|
16
|
+
*/
|
|
17
|
+
generateId(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get or create portal root container for scene
|
|
20
|
+
* This container sits at very high depth to ensure portals are above regular content
|
|
21
|
+
* @param scene - Phaser scene
|
|
22
|
+
* @returns Portal root container
|
|
23
|
+
*/
|
|
24
|
+
private getOrCreatePortalRoot;
|
|
25
|
+
/**
|
|
26
|
+
* Register a new portal tree
|
|
27
|
+
* @param id - Portal ID
|
|
28
|
+
* @param depth - Z-depth (higher = foreground)
|
|
29
|
+
* @param scene - Phaser scene
|
|
30
|
+
* @param vnode - Root VNode
|
|
31
|
+
* @param mountedNode - Mounted GameObject
|
|
32
|
+
* @returns Portal container
|
|
33
|
+
*/
|
|
34
|
+
register(id: string, depth: number, scene: Phaser.Scene, vnode: VNode, mountedNode: Phaser.GameObjects.GameObject): Phaser.GameObjects.Container;
|
|
35
|
+
/**
|
|
36
|
+
* Sort portals in scene by depth (highest to lowest)
|
|
37
|
+
* Ensures correct input event order within portal root
|
|
38
|
+
* Phaser processes input from LAST to FIRST child in DisplayList
|
|
39
|
+
* So highest depth should be LAST in the list to receive events first
|
|
40
|
+
* @param scene - Phaser scene
|
|
41
|
+
*/
|
|
42
|
+
private sortPortalsByDepth;
|
|
43
|
+
/**
|
|
44
|
+
* Unregister and cleanup portal
|
|
45
|
+
* @param id - Portal ID
|
|
46
|
+
*/
|
|
47
|
+
unregister(id: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get portal by ID
|
|
50
|
+
* @param id - Portal ID
|
|
51
|
+
* @returns Portal tree or undefined
|
|
52
|
+
*/
|
|
53
|
+
get(id: string): PortalTree | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Get all portals sorted by depth (ascending)
|
|
56
|
+
* @returns Sorted portal trees
|
|
57
|
+
*/
|
|
58
|
+
getByDepth(): PortalTree[];
|
|
59
|
+
/**
|
|
60
|
+
* Get all portals for a specific scene
|
|
61
|
+
* @param scene - Phaser scene
|
|
62
|
+
* @returns Portal trees in scene
|
|
63
|
+
*/
|
|
64
|
+
getByScene(scene: Phaser.Scene): PortalTree[];
|
|
65
|
+
/**
|
|
66
|
+
* Clear all portals
|
|
67
|
+
*/
|
|
68
|
+
clear(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Set viewport size for a scene
|
|
71
|
+
* Used by Portal system to know screen dimensions for centering
|
|
72
|
+
* @param scene - Phaser scene
|
|
73
|
+
* @param width - Viewport width
|
|
74
|
+
* @param height - Viewport height
|
|
75
|
+
*/
|
|
76
|
+
setViewportSize(scene: Phaser.Scene, width: number, height: number): void;
|
|
77
|
+
/**
|
|
78
|
+
* Get viewport size for a scene
|
|
79
|
+
* @param scene - Phaser scene
|
|
80
|
+
* @returns Viewport size or default 800x600
|
|
81
|
+
*/
|
|
82
|
+
getViewportSize(scene: Phaser.Scene): {
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Get portal count
|
|
88
|
+
* @returns Number of registered portals
|
|
89
|
+
*/
|
|
90
|
+
get size(): number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Global portal registry instance
|
|
94
|
+
*/
|
|
95
|
+
export declare const portalRegistry: PortalRegistry;
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=portal-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-registry.d.ts","sourceRoot":"","sources":["../../src/portal/portal-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD;;;GAGG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,SAAS,CAAI;IACrB,OAAO,CAAC,WAAW,CAA6D;IAChF,OAAO,CAAC,aAAa,CAAkE;IAEvF;;;OAGG;IACH,UAAU,IAAI,MAAM;IAIpB;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAe7B;;;;;;;;OAQG;IACH,QAAQ,CACN,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,GACzC,MAAM,CAAC,WAAW,CAAC,SAAS;IA2B/B;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;IAoB1B;;;OAGG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAoB5B;;;;OAIG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIvC;;;OAGG;IACH,UAAU,IAAI,UAAU,EAAE;IAI1B;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,UAAU,EAAE;IAI7C;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb;;;;;;OAMG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAIzE;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAIvE;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,gBAAuB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as Phaser } from 'phaser';
|
|
2
|
+
import { VNode } from '../hooks';
|
|
3
|
+
/**
|
|
4
|
+
* Portal tree instance
|
|
5
|
+
*/
|
|
6
|
+
export interface PortalTree {
|
|
7
|
+
/** Unique portal ID */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Depth/z-index for stacking order (higher = foreground) */
|
|
10
|
+
depth: number;
|
|
11
|
+
/** Root Phaser container for this portal */
|
|
12
|
+
container: Phaser.GameObjects.Container;
|
|
13
|
+
/** Root VNode being rendered */
|
|
14
|
+
vnode: VNode;
|
|
15
|
+
/** Scene this portal belongs to */
|
|
16
|
+
scene: Phaser.Scene;
|
|
17
|
+
/** Mounted GameObject */
|
|
18
|
+
mountedNode: Phaser.GameObjects.GameObject;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=portal-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portal-types.d.ts","sourceRoot":"","sources":["../../src/portal/portal-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAA;IACb,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAA;IACvC,gCAAgC;IAChC,KAAK,EAAE,KAAK,CAAA;IACZ,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAA;IACnB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAA;CAC3C"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { default as Phaser } from 'phaser';
|
|
2
|
+
import { Ctx } from './hooks';
|
|
3
|
+
import { ParentType } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Layout batch entry for deferred recalculation
|
|
6
|
+
*/
|
|
7
|
+
interface LayoutBatchEntry {
|
|
8
|
+
container: Phaser.GameObjects.Container;
|
|
9
|
+
containerProps: unknown;
|
|
10
|
+
parentSize: {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
} | undefined;
|
|
14
|
+
parentPadding: {
|
|
15
|
+
horizontal: number;
|
|
16
|
+
vertical: number;
|
|
17
|
+
} | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Render context - encapsulates all previously global state
|
|
21
|
+
* Each mount point gets its own isolated context
|
|
22
|
+
*/
|
|
23
|
+
export declare class RenderContext {
|
|
24
|
+
scene: Phaser.Scene;
|
|
25
|
+
private currentCtx;
|
|
26
|
+
private textureScene;
|
|
27
|
+
private textures;
|
|
28
|
+
private viewport;
|
|
29
|
+
private viewportParent;
|
|
30
|
+
private deferredCallbacks;
|
|
31
|
+
private deferredScheduled;
|
|
32
|
+
private layoutBatchMap;
|
|
33
|
+
private batchScheduled;
|
|
34
|
+
private isShuttingDown;
|
|
35
|
+
constructor(scene: Phaser.Scene);
|
|
36
|
+
/**
|
|
37
|
+
* Check if context is shutting down
|
|
38
|
+
*/
|
|
39
|
+
isShutdown(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Mark context as shutting down
|
|
42
|
+
*/
|
|
43
|
+
shutdown(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get current hook context
|
|
46
|
+
*/
|
|
47
|
+
getCurrent(): Ctx | null;
|
|
48
|
+
/**
|
|
49
|
+
* Set current hook context
|
|
50
|
+
*/
|
|
51
|
+
setCurrent(ctx: Ctx | null): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get texture scene
|
|
54
|
+
*/
|
|
55
|
+
getTextureScene(): Phaser.Scene | null;
|
|
56
|
+
/**
|
|
57
|
+
* Get textures map
|
|
58
|
+
*/
|
|
59
|
+
getTextures(): Map<string, {
|
|
60
|
+
refCount: number;
|
|
61
|
+
promise: Promise<void> | null;
|
|
62
|
+
loaded: boolean;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Set viewport dimensions
|
|
66
|
+
*/
|
|
67
|
+
setViewport(width: number, height: number, parent?: ParentType): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get viewport dimensions
|
|
70
|
+
*/
|
|
71
|
+
getViewport(): {
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Get viewport parent
|
|
77
|
+
*/
|
|
78
|
+
getViewportParent(): ParentType | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Defer a layout callback to next frame
|
|
81
|
+
*/
|
|
82
|
+
deferLayout(callback: () => void): void;
|
|
83
|
+
/**
|
|
84
|
+
* Flush all deferred layout callbacks
|
|
85
|
+
*/
|
|
86
|
+
private flushDeferred;
|
|
87
|
+
/**
|
|
88
|
+
* Get layout batch map
|
|
89
|
+
*/
|
|
90
|
+
getLayoutBatch(): Map<Phaser.GameObjects.Container, LayoutBatchEntry>;
|
|
91
|
+
/**
|
|
92
|
+
* Clear layout batch
|
|
93
|
+
*/
|
|
94
|
+
clearLayoutBatch(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Check if batch is scheduled
|
|
97
|
+
*/
|
|
98
|
+
isBatchScheduled(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Set batch scheduled flag
|
|
101
|
+
*/
|
|
102
|
+
setBatchScheduled(scheduled: boolean): void;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get or create RenderContext for a scene or container
|
|
106
|
+
* Uses scene.data to store contexts, ensuring proper isolation
|
|
107
|
+
* @param parentOrScene - Scene or Container to get context for
|
|
108
|
+
* @returns RenderContext instance
|
|
109
|
+
*/
|
|
110
|
+
export declare function getRenderContext(parentOrScene: Phaser.Scene | Phaser.GameObjects.Container): RenderContext;
|
|
111
|
+
/**
|
|
112
|
+
* Get RenderContext from a parent (used internally by hooks)
|
|
113
|
+
* @param parent - Parent scene or container
|
|
114
|
+
* @returns RenderContext instance
|
|
115
|
+
*/
|
|
116
|
+
export declare function getContextFromParent(parent: ParentType): RenderContext;
|
|
117
|
+
export {};
|
|
118
|
+
//# sourceMappingURL=render-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-context.d.ts","sourceRoot":"","sources":["../src/render-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;GAEG;AACH,UAAU,gBAAgB;IACxB,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,SAAS,CAAA;IACvC,cAAc,EAAE,OAAO,CAAA;IACvB,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAA;IACzD,aAAa,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAA;CACpE;AAED;;;GAGG;AACH,qBAAa,aAAa;IA0BL,KAAK,EAAE,MAAM,CAAC,KAAK;IAxBtC,OAAO,CAAC,UAAU,CAAmB;IAGrC,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,QAAQ,CAGb;IAGH,OAAO,CAAC,QAAQ,CAAiE;IACjF,OAAO,CAAC,cAAc,CAAwB;IAG9C,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,iBAAiB,CAAQ;IAGjC,OAAO,CAAC,cAAc,CAA4D;IAClF,OAAO,CAAC,cAAc,CAAQ;IAG9B,OAAO,CAAC,cAAc,CAAQ;gBAEX,KAAK,EAAE,MAAM,CAAC,KAAK;IAItC;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAMhB;;OAEG;IACH,UAAU,IAAI,GAAG,GAAG,IAAI;IAIxB;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IAIjC;;OAEG;IACH,eAAe,IAAI,MAAM,CAAC,KAAK,GAAG,IAAI;IAItC;;OAEG;IACH,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IAIhG;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI;IAKrE;;OAEG;IACH,WAAW,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAIhD;;OAEG;IACH,iBAAiB,IAAI,UAAU,GAAG,SAAS;IAI3C;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IASvC;;OAEG;IACH,OAAO,CAAC,aAAa;IAcrB;;OAEG;IACH,cAAc,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,gBAAgB,CAAC;IAIrE;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAIxB;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;OAEG;IACH,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;CAG5C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,GACzD,aAAa,CA8Bf;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,CAKtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-icon-loaders.d.ts","sourceRoot":"","sources":["../../src/scripts/generate-icon-loaders.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFile, writeFile, readdir } from "node:fs/promises";
|
|
3
|
+
import { resolve, join } from "node:path";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
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;
|
|
18
|
+
}
|
|
19
|
+
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;
|
|
47
|
+
}
|
|
48
|
+
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
|
+
}
|
|
67
|
+
}
|
|
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 = `/**
|
|
113
|
+
* Auto-generated icon loader registry
|
|
114
|
+
* Package: ${options2.package}
|
|
115
|
+
* Icons found: ${iconArray.length}
|
|
116
|
+
*
|
|
117
|
+
* @generated by @number10/phaserjsx/generate-icon-loaders
|
|
118
|
+
* @cspell: disable
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Icon loaders - only icons used in the codebase are registered
|
|
123
|
+
* Bundler will create separate chunks for each icon
|
|
124
|
+
*/
|
|
125
|
+
export const iconLoaders: Record<string, () => Promise<{ default: string }>> = {
|
|
126
|
+
${loaders || " // No icons found"}
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
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
|
+
}
|
|
137
|
+
}
|
|
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
|
+
});
|
|
150
|
+
if (values.help || !values.source || !values.output || !values.package) {
|
|
151
|
+
console.log(`
|
|
152
|
+
Usage: generate-icon-loaders [options]
|
|
153
|
+
|
|
154
|
+
Options:
|
|
155
|
+
-s, --source <path> Source directory to scan (e.g., ./src)
|
|
156
|
+
-o, --output <path> Output file path (e.g., ./src/components/icon-loaders.generated.ts)
|
|
157
|
+
-p, --package <name> Icon package name (e.g., bootstrap-icons)
|
|
158
|
+
-i, --iconsPath <path> Relative path to icons in package (default: icons)
|
|
159
|
+
-c, --componentName <name> Icon component name to search for (default: Icon)
|
|
160
|
+
--componentNames <names...> Multiple component names (e.g., Icon BootstrapIcon)
|
|
161
|
+
-t, --typesFile <path> Types file for validation (e.g., ./src/icon-types.generated.ts)
|
|
162
|
+
-h, --help Show this help message
|
|
163
|
+
|
|
164
|
+
Examples:
|
|
165
|
+
# Single component name
|
|
166
|
+
generate-icon-loaders -s ./src -o ./src/icon-loaders.generated.ts -p bootstrap-icons
|
|
167
|
+
|
|
168
|
+
# Multiple component names
|
|
169
|
+
generate-icon-loaders -s ./src -o ./src/icon-loaders.generated.ts -p bootstrap-icons \\
|
|
170
|
+
--componentNames Icon BootstrapIcon CustomIcon
|
|
171
|
+
|
|
172
|
+
# With validation
|
|
173
|
+
generate-icon-loaders -s ./src -o ./src/icon-loaders.generated.ts -p bootstrap-icons \\
|
|
174
|
+
-t ./src/icon-types.generated.ts
|
|
175
|
+
`);
|
|
176
|
+
process.exit(values.help ? 0 : 1);
|
|
177
|
+
}
|
|
178
|
+
const options = {
|
|
179
|
+
source: values.source,
|
|
180
|
+
output: values.output,
|
|
181
|
+
package: values.package
|
|
182
|
+
};
|
|
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
|
+
}
|
|
195
|
+
generateIconLoaders(options);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-icon-types.d.ts","sourceRoot":"","sources":["../../src/scripts/generate-icon-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { resolve, join, basename } from "node:path";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
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}`);
|
|
24
|
+
}
|
|
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 = `/**
|
|
49
|
+
* Auto-generated icon type definitions
|
|
50
|
+
* Source: ${sourceName}
|
|
51
|
+
* Total icons: ${iconNames.length}
|
|
52
|
+
*
|
|
53
|
+
* @generated by @number10/phaserjsx/generate-icon-types
|
|
54
|
+
* @cspell: disable
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* All available icon names from ${sourceName}
|
|
59
|
+
* Type-only definition - no runtime imports, zero bundle impact
|
|
60
|
+
*/
|
|
61
|
+
export type ${typeName} =
|
|
62
|
+
${typeDefinition}
|
|
63
|
+
`;
|
|
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
|
+
}
|
|
77
|
+
}
|
|
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
|
+
});
|
|
88
|
+
if (values.help || !values.package && !values.directory || !values.output) {
|
|
89
|
+
console.log(`
|
|
90
|
+
Usage: generate-icon-types [options]
|
|
91
|
+
|
|
92
|
+
Options:
|
|
93
|
+
-p, --package <name> Icon package name (e.g., bootstrap-icons)
|
|
94
|
+
-d, --directory <path> Local directory with SVG files (alternative to --package)
|
|
95
|
+
-o, --output <path> Output file path (e.g., ./src/types/icons.ts)
|
|
96
|
+
-t, --typeName <name> TypeScript type name (default: IconType)
|
|
97
|
+
-i, --iconsPath <path> Relative path to icons in package (default: icons)
|
|
98
|
+
-h, --help Show this help message
|
|
99
|
+
|
|
100
|
+
Examples:
|
|
101
|
+
# From npm package
|
|
102
|
+
generate-icon-types -p bootstrap-icons -o ./src/icon-types.generated.ts
|
|
103
|
+
|
|
104
|
+
# From local directory
|
|
105
|
+
generate-icon-types -d ./public/icons -o ./src/icon-types.generated.ts
|
|
106
|
+
`);
|
|
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;
|
|
123
|
+
}
|
|
124
|
+
generateIconTypes(options);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IconGeneratorConfig } from './icon-generator-config';
|
|
2
|
+
/**
|
|
3
|
+
* Generate icon types
|
|
4
|
+
* Exported for use by Vite plugin
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateTypes(config: IconGeneratorConfig, cwd: string): Promise<{
|
|
7
|
+
iconNames: string[];
|
|
8
|
+
sourceIconSets: Map<number, Set<string>>;
|
|
9
|
+
} | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Scan icon sources without generating the types file
|
|
12
|
+
* Used by Vite plugin to get sourceIconSets for loader generation without full type regeneration
|
|
13
|
+
* @param config - Icon generator configuration
|
|
14
|
+
* @param cwd - Current working directory
|
|
15
|
+
* @returns Icon names and source mapping
|
|
16
|
+
*/
|
|
17
|
+
export declare function scanIconSources(config: IconGeneratorConfig, cwd: string): Promise<{
|
|
18
|
+
iconNames: string[];
|
|
19
|
+
sourceIconSets: Map<number, Set<string>>;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Generate icon loaders
|
|
23
|
+
* Exported for use by Vite plugin
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateLoaders(config: IconGeneratorConfig, cwd: string, typesResult?: {
|
|
26
|
+
iconNames: string[];
|
|
27
|
+
sourceIconSets: Map<number, Set<string>>;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Load config file
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Load icon generator config file
|
|
34
|
+
* Exported for use by Vite plugin and other tools
|
|
35
|
+
*/
|
|
36
|
+
export declare function loadConfig(configPath: string, cwd?: string): Promise<IconGeneratorConfig>;
|
|
37
|
+
//# sourceMappingURL=generate-icons.d.ts.map
|
|
@@ -0,0 +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"}
|