@number10/jsx-phaser 5.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/LICENSE +667 -0
- package/README.md +44 -0
- package/dist/_virtual/_commonjsHelpers.cjs +7 -0
- package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
- package/dist/_virtual/_commonjsHelpers.js +7 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/index.cjs +7 -0
- package/dist/_virtual/index.cjs.map +1 -0
- package/dist/_virtual/index.js +8 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/animation/index.d.ts +7 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/camera/index.d.ts +5 -0
- package/dist/camera/index.d.ts.map +1 -0
- package/dist/camera/use-camera-fx.cjs +49 -0
- package/dist/camera/use-camera-fx.cjs.map +1 -0
- package/dist/camera/use-camera-fx.d.ts +25 -0
- package/dist/camera/use-camera-fx.d.ts.map +1 -0
- package/dist/camera/use-camera-fx.js +49 -0
- package/dist/camera/use-camera-fx.js.map +1 -0
- package/dist/clip/index.cjs +8 -0
- package/dist/clip/index.cjs.map +1 -0
- package/dist/clip/index.d.ts +3 -0
- package/dist/clip/index.d.ts.map +1 -0
- package/dist/clip/index.js +9 -0
- package/dist/clip/index.js.map +1 -0
- package/dist/clip/stencil-clip-depth.cjs +24 -0
- package/dist/clip/stencil-clip-depth.cjs.map +1 -0
- package/dist/clip/stencil-clip-depth.d.ts +10 -0
- package/dist/clip/stencil-clip-depth.d.ts.map +1 -0
- package/dist/clip/stencil-clip-depth.js +24 -0
- package/dist/clip/stencil-clip-depth.js.map +1 -0
- package/dist/clip/stencil-clip-extension.cjs +113 -0
- package/dist/clip/stencil-clip-extension.cjs.map +1 -0
- package/dist/clip/stencil-clip-extension.d.ts +18 -0
- package/dist/clip/stencil-clip-extension.d.ts.map +1 -0
- package/dist/clip/stencil-clip-extension.js +96 -0
- package/dist/clip/stencil-clip-extension.js.map +1 -0
- package/dist/clip/stencil-clip-fbo-bridge.cjs +46 -0
- package/dist/clip/stencil-clip-fbo-bridge.cjs.map +1 -0
- package/dist/clip/stencil-clip-fbo-bridge.d.ts +7 -0
- package/dist/clip/stencil-clip-fbo-bridge.d.ts.map +1 -0
- package/dist/clip/stencil-clip-fbo-bridge.js +46 -0
- package/dist/clip/stencil-clip-fbo-bridge.js.map +1 -0
- package/dist/clip/stencil-clip-renderer.cjs +300 -0
- package/dist/clip/stencil-clip-renderer.cjs.map +1 -0
- package/dist/clip/stencil-clip-renderer.d.ts +7 -0
- package/dist/clip/stencil-clip-renderer.d.ts.map +1 -0
- package/dist/clip/stencil-clip-renderer.js +300 -0
- package/dist/clip/stencil-clip-renderer.js.map +1 -0
- package/dist/clip/stencil-clip-state.cjs +84 -0
- package/dist/clip/stencil-clip-state.cjs.map +1 -0
- package/dist/clip/stencil-clip-state.d.ts +28 -0
- package/dist/clip/stencil-clip-state.d.ts.map +1 -0
- package/dist/clip/stencil-clip-state.js +84 -0
- package/dist/clip/stencil-clip-state.js.map +1 -0
- package/dist/clip/stencil-clip-types.d.ts +67 -0
- package/dist/clip/stencil-clip-types.d.ts.map +1 -0
- package/dist/clip/stencil-clip.cjs +138 -0
- package/dist/clip/stencil-clip.cjs.map +1 -0
- package/dist/clip/stencil-clip.d.ts +53 -0
- package/dist/clip/stencil-clip.d.ts.map +1 -0
- package/dist/clip/stencil-clip.js +122 -0
- package/dist/clip/stencil-clip.js.map +1 -0
- package/dist/colors/use-color-mode.cjs +28 -0
- package/dist/colors/use-color-mode.cjs.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-color-mode.js +28 -0
- package/dist/colors/use-color-mode.js.map +1 -0
- package/dist/colors/use-colors.cjs +45 -0
- package/dist/colors/use-colors.cjs.map +1 -0
- package/dist/colors/use-colors.d.ts +36 -0
- package/dist/colors/use-colors.d.ts.map +1 -0
- package/dist/colors/use-colors.js +45 -0
- package/dist/colors/use-colors.js.map +1 -0
- package/dist/components/DebugPanel.cjs +88 -0
- package/dist/components/DebugPanel.cjs.map +1 -0
- package/dist/components/DebugPanel.d.ts +45 -0
- package/dist/components/DebugPanel.d.ts.map +1 -0
- package/dist/components/DebugPanel.js +71 -0
- package/dist/components/DebugPanel.js.map +1 -0
- package/dist/components/appliers/applyBackground.cjs +89 -0
- package/dist/components/appliers/applyBackground.cjs.map +1 -0
- package/dist/components/appliers/applyBackground.d.ts +18 -0
- package/dist/components/appliers/applyBackground.d.ts.map +1 -0
- package/dist/components/appliers/applyBackground.js +89 -0
- package/dist/components/appliers/applyBackground.js.map +1 -0
- package/dist/components/appliers/applyGestures.cjs +85 -0
- package/dist/components/appliers/applyGestures.cjs.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/applyGestures.js +68 -0
- package/dist/components/appliers/applyGestures.js.map +1 -0
- package/dist/components/appliers/applyGraphics.cjs +21 -0
- package/dist/components/appliers/applyGraphics.cjs.map +1 -0
- package/dist/components/appliers/applyGraphics.d.ts +13 -0
- package/dist/components/appliers/applyGraphics.d.ts.map +1 -0
- package/dist/components/appliers/applyGraphics.js +21 -0
- package/dist/components/appliers/applyGraphics.js.map +1 -0
- package/dist/components/appliers/applyGraphicsLayout.cjs +18 -0
- package/dist/components/appliers/applyGraphicsLayout.cjs.map +1 -0
- package/dist/components/appliers/applyGraphicsLayout.d.ts +13 -0
- package/dist/components/appliers/applyGraphicsLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyGraphicsLayout.js +18 -0
- package/dist/components/appliers/applyGraphicsLayout.js.map +1 -0
- package/dist/components/appliers/applyImage.cjs +92 -0
- package/dist/components/appliers/applyImage.cjs.map +1 -0
- package/dist/components/appliers/applyImage.d.ts +47 -0
- package/dist/components/appliers/applyImage.d.ts.map +1 -0
- package/dist/components/appliers/applyImage.js +92 -0
- package/dist/components/appliers/applyImage.js.map +1 -0
- package/dist/components/appliers/applyImageLayout.cjs +18 -0
- package/dist/components/appliers/applyImageLayout.cjs.map +1 -0
- package/dist/components/appliers/applyImageLayout.d.ts +18 -0
- package/dist/components/appliers/applyImageLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyImageLayout.js +18 -0
- package/dist/components/appliers/applyImageLayout.js.map +1 -0
- package/dist/components/appliers/applyLayout.cjs +108 -0
- package/dist/components/appliers/applyLayout.cjs.map +1 -0
- package/dist/components/appliers/applyLayout.d.ts +19 -0
- package/dist/components/appliers/applyLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyLayout.js +91 -0
- package/dist/components/appliers/applyLayout.js.map +1 -0
- package/dist/components/appliers/applyNineSlice.cjs +37 -0
- package/dist/components/appliers/applyNineSlice.cjs.map +1 -0
- package/dist/components/appliers/applyNineSlice.d.ts +14 -0
- package/dist/components/appliers/applyNineSlice.d.ts.map +1 -0
- package/dist/components/appliers/applyNineSlice.js +37 -0
- package/dist/components/appliers/applyNineSlice.js.map +1 -0
- package/dist/components/appliers/applyNineSliceLayout.cjs +18 -0
- package/dist/components/appliers/applyNineSliceLayout.cjs.map +1 -0
- package/dist/components/appliers/applyNineSliceLayout.d.ts +18 -0
- package/dist/components/appliers/applyNineSliceLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyNineSliceLayout.js +18 -0
- package/dist/components/appliers/applyNineSliceLayout.js.map +1 -0
- package/dist/components/appliers/applyParticles.cjs +46 -0
- package/dist/components/appliers/applyParticles.cjs.map +1 -0
- package/dist/components/appliers/applyParticles.d.ts +7 -0
- package/dist/components/appliers/applyParticles.d.ts.map +1 -0
- package/dist/components/appliers/applyParticles.js +46 -0
- package/dist/components/appliers/applyParticles.js.map +1 -0
- package/dist/components/appliers/applyParticlesLayout.cjs +7 -0
- package/dist/components/appliers/applyParticlesLayout.cjs.map +1 -0
- package/dist/components/appliers/applyParticlesLayout.d.ts +11 -0
- package/dist/components/appliers/applyParticlesLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyParticlesLayout.js +7 -0
- package/dist/components/appliers/applyParticlesLayout.js.map +1 -0
- package/dist/components/appliers/applyPhaser.cjs +40 -0
- package/dist/components/appliers/applyPhaser.cjs.map +1 -0
- package/dist/components/appliers/applyPhaser.d.ts +24 -0
- package/dist/components/appliers/applyPhaser.d.ts.map +1 -0
- package/dist/components/appliers/applyPhaser.js +40 -0
- package/dist/components/appliers/applyPhaser.js.map +1 -0
- package/dist/components/appliers/applySprite.cjs +124 -0
- package/dist/components/appliers/applySprite.cjs.map +1 -0
- package/dist/components/appliers/applySprite.d.ts +13 -0
- package/dist/components/appliers/applySprite.d.ts.map +1 -0
- package/dist/components/appliers/applySprite.js +124 -0
- package/dist/components/appliers/applySprite.js.map +1 -0
- package/dist/components/appliers/applySpriteLayout.cjs +7 -0
- package/dist/components/appliers/applySpriteLayout.cjs.map +1 -0
- package/dist/components/appliers/applySpriteLayout.d.ts +17 -0
- package/dist/components/appliers/applySpriteLayout.d.ts.map +1 -0
- package/dist/components/appliers/applySpriteLayout.js +7 -0
- package/dist/components/appliers/applySpriteLayout.js.map +1 -0
- package/dist/components/appliers/applyText.cjs +142 -0
- package/dist/components/appliers/applyText.cjs.map +1 -0
- package/dist/components/appliers/applyText.d.ts +32 -0
- package/dist/components/appliers/applyText.d.ts.map +1 -0
- package/dist/components/appliers/applyText.js +142 -0
- package/dist/components/appliers/applyText.js.map +1 -0
- package/dist/components/appliers/applyTextLayout.cjs +16 -0
- package/dist/components/appliers/applyTextLayout.cjs.map +1 -0
- package/dist/components/appliers/applyTextLayout.d.ts +18 -0
- package/dist/components/appliers/applyTextLayout.d.ts.map +1 -0
- package/dist/components/appliers/applyTextLayout.js +16 -0
- package/dist/components/appliers/applyTextLayout.js.map +1 -0
- package/dist/components/appliers/applyTooltip.cjs +247 -0
- package/dist/components/appliers/applyTooltip.cjs.map +1 -0
- package/dist/components/appliers/applyTooltip.d.ts +16 -0
- package/dist/components/appliers/applyTooltip.d.ts.map +1 -0
- package/dist/components/appliers/applyTooltip.js +247 -0
- package/dist/components/appliers/applyTooltip.js.map +1 -0
- package/dist/components/appliers/applyTransform.cjs +61 -0
- package/dist/components/appliers/applyTransform.cjs.map +1 -0
- package/dist/components/appliers/applyTransform.d.ts +24 -0
- package/dist/components/appliers/applyTransform.d.ts.map +1 -0
- package/dist/components/appliers/applyTransform.js +61 -0
- package/dist/components/appliers/applyTransform.js.map +1 -0
- package/dist/components/backgroundImage.cjs +411 -0
- package/dist/components/backgroundImage.cjs.map +1 -0
- package/dist/components/backgroundImage.d.ts +14 -0
- package/dist/components/backgroundImage.d.ts.map +1 -0
- package/dist/components/backgroundImage.js +411 -0
- package/dist/components/backgroundImage.js.map +1 -0
- package/dist/components/creators/createBackground.cjs +18 -0
- package/dist/components/creators/createBackground.cjs.map +1 -0
- package/dist/components/creators/createBackground.d.ts +20 -0
- package/dist/components/creators/createBackground.d.ts.map +1 -0
- package/dist/components/creators/createBackground.js +18 -0
- package/dist/components/creators/createBackground.js.map +1 -0
- package/dist/components/creators/createGestures.cjs +51 -0
- package/dist/components/creators/createGestures.cjs.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/createGestures.js +34 -0
- package/dist/components/creators/createGestures.js.map +1 -0
- package/dist/components/creators/createGraphicsLayout.cjs +24 -0
- package/dist/components/creators/createGraphicsLayout.cjs.map +1 -0
- package/dist/components/creators/createGraphicsLayout.d.ts +12 -0
- package/dist/components/creators/createGraphicsLayout.d.ts.map +1 -0
- package/dist/components/creators/createGraphicsLayout.js +24 -0
- package/dist/components/creators/createGraphicsLayout.js.map +1 -0
- package/dist/components/creators/createImageLayout.cjs +16 -0
- package/dist/components/creators/createImageLayout.cjs.map +1 -0
- package/dist/components/creators/createImageLayout.d.ts +17 -0
- package/dist/components/creators/createImageLayout.d.ts.map +1 -0
- package/dist/components/creators/createImageLayout.js +16 -0
- package/dist/components/creators/createImageLayout.js.map +1 -0
- package/dist/components/creators/createLayout.cjs +61 -0
- package/dist/components/creators/createLayout.cjs.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/createLayout.js +61 -0
- package/dist/components/creators/createLayout.js.map +1 -0
- package/dist/components/creators/createNineSliceLayout.cjs +16 -0
- package/dist/components/creators/createNineSliceLayout.cjs.map +1 -0
- package/dist/components/creators/createNineSliceLayout.d.ts +17 -0
- package/dist/components/creators/createNineSliceLayout.d.ts.map +1 -0
- package/dist/components/creators/createNineSliceLayout.js +16 -0
- package/dist/components/creators/createNineSliceLayout.js.map +1 -0
- package/dist/components/creators/createParticlesLayout.cjs +8 -0
- package/dist/components/creators/createParticlesLayout.cjs.map +1 -0
- package/dist/components/creators/createParticlesLayout.d.ts +14 -0
- package/dist/components/creators/createParticlesLayout.d.ts.map +1 -0
- package/dist/components/creators/createParticlesLayout.js +8 -0
- package/dist/components/creators/createParticlesLayout.js.map +1 -0
- package/dist/components/creators/createPhaser.cjs +36 -0
- package/dist/components/creators/createPhaser.cjs.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/createPhaser.js +36 -0
- package/dist/components/creators/createPhaser.js.map +1 -0
- package/dist/components/creators/createSpriteLayout.cjs +10 -0
- package/dist/components/creators/createSpriteLayout.cjs.map +1 -0
- package/dist/components/creators/createSpriteLayout.d.ts +18 -0
- package/dist/components/creators/createSpriteLayout.d.ts.map +1 -0
- package/dist/components/creators/createSpriteLayout.js +10 -0
- package/dist/components/creators/createSpriteLayout.js.map +1 -0
- package/dist/components/creators/createTextLayout.cjs +16 -0
- package/dist/components/creators/createTextLayout.cjs.map +1 -0
- package/dist/components/creators/createTextLayout.d.ts +17 -0
- package/dist/components/creators/createTextLayout.d.ts.map +1 -0
- package/dist/components/creators/createTextLayout.js +16 -0
- package/dist/components/creators/createTextLayout.js.map +1 -0
- package/dist/components/creators/createTransform.cjs +83 -0
- package/dist/components/creators/createTransform.cjs.map +1 -0
- package/dist/components/creators/createTransform.d.ts +26 -0
- package/dist/components/creators/createTransform.d.ts.map +1 -0
- package/dist/components/creators/createTransform.js +83 -0
- package/dist/components/creators/createTransform.js.map +1 -0
- package/dist/components/custom/Graphics.cjs +13 -0
- package/dist/components/custom/Graphics.cjs.map +1 -0
- package/dist/components/custom/Graphics.d.ts +50 -0
- package/dist/components/custom/Graphics.d.ts.map +1 -0
- package/dist/components/custom/Graphics.js +13 -0
- package/dist/components/custom/Graphics.js.map +1 -0
- package/dist/components/custom/NineSlice.cjs +13 -0
- package/dist/components/custom/NineSlice.cjs.map +1 -0
- package/dist/components/custom/NineSlice.d.ts +87 -0
- package/dist/components/custom/NineSlice.d.ts.map +1 -0
- package/dist/components/custom/NineSlice.js +13 -0
- package/dist/components/custom/NineSlice.js.map +1 -0
- package/dist/components/custom/Particles.cjs +8 -0
- package/dist/components/custom/Particles.cjs.map +1 -0
- package/dist/components/custom/Particles.d.ts +28 -0
- package/dist/components/custom/Particles.d.ts.map +1 -0
- package/dist/components/custom/Particles.js +8 -0
- package/dist/components/custom/Particles.js.map +1 -0
- package/dist/components/custom/RefOriginView.cjs +67 -0
- package/dist/components/custom/RefOriginView.cjs.map +1 -0
- package/dist/components/custom/RefOriginView.d.ts +49 -0
- package/dist/components/custom/RefOriginView.d.ts.map +1 -0
- package/dist/components/custom/RefOriginView.js +67 -0
- package/dist/components/custom/RefOriginView.js.map +1 -0
- package/dist/components/custom/Sprite.cjs +13 -0
- package/dist/components/custom/Sprite.cjs.map +1 -0
- package/dist/components/custom/Sprite.d.ts +79 -0
- package/dist/components/custom/Sprite.d.ts.map +1 -0
- package/dist/components/custom/Sprite.js +13 -0
- package/dist/components/custom/Sprite.js.map +1 -0
- package/dist/components/custom/TileSprite.cjs +13 -0
- package/dist/components/custom/TileSprite.cjs.map +1 -0
- package/dist/components/custom/TileSprite.d.ts +65 -0
- package/dist/components/custom/TileSprite.d.ts.map +1 -0
- package/dist/components/custom/TileSprite.js +13 -0
- package/dist/components/custom/TileSprite.js.map +1 -0
- package/dist/components/custom/index.d.ts +15 -0
- package/dist/components/custom/index.d.ts.map +1 -0
- package/dist/components/index.cjs +33 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +33 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/internal/SceneWrapper.cjs +10 -0
- package/dist/components/internal/SceneWrapper.cjs.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/internal/SceneWrapper.js +10 -0
- package/dist/components/internal/SceneWrapper.js.map +1 -0
- package/dist/components/primitives/graphics.cjs +29 -0
- package/dist/components/primitives/graphics.cjs.map +1 -0
- package/dist/components/primitives/graphics.d.ts +146 -0
- package/dist/components/primitives/graphics.d.ts.map +1 -0
- package/dist/components/primitives/graphics.js +29 -0
- package/dist/components/primitives/graphics.js.map +1 -0
- package/dist/components/primitives/image.cjs +110 -0
- package/dist/components/primitives/image.cjs.map +1 -0
- package/dist/components/primitives/image.d.ts +170 -0
- package/dist/components/primitives/image.d.ts.map +1 -0
- package/dist/components/primitives/image.js +110 -0
- package/dist/components/primitives/image.js.map +1 -0
- package/dist/components/primitives/nineslice.cjs +42 -0
- package/dist/components/primitives/nineslice.cjs.map +1 -0
- package/dist/components/primitives/nineslice.d.ts +271 -0
- package/dist/components/primitives/nineslice.d.ts.map +1 -0
- package/dist/components/primitives/nineslice.js +42 -0
- package/dist/components/primitives/nineslice.js.map +1 -0
- package/dist/components/primitives/particles.cjs +77 -0
- package/dist/components/primitives/particles.cjs.map +1 -0
- package/dist/components/primitives/particles.d.ts +47 -0
- package/dist/components/primitives/particles.d.ts.map +1 -0
- package/dist/components/primitives/particles.js +77 -0
- package/dist/components/primitives/particles.js.map +1 -0
- package/dist/components/primitives/sprite.cjs +100 -0
- package/dist/components/primitives/sprite.cjs.map +1 -0
- package/dist/components/primitives/sprite.d.ts +147 -0
- package/dist/components/primitives/sprite.d.ts.map +1 -0
- package/dist/components/primitives/sprite.js +100 -0
- package/dist/components/primitives/sprite.js.map +1 -0
- package/dist/components/primitives/text.cjs +73 -0
- package/dist/components/primitives/text.cjs.map +1 -0
- package/dist/components/primitives/text.d.ts +155 -0
- package/dist/components/primitives/text.d.ts.map +1 -0
- package/dist/components/primitives/text.js +73 -0
- package/dist/components/primitives/text.js.map +1 -0
- package/dist/components/primitives/tilesprite.cjs +77 -0
- package/dist/components/primitives/tilesprite.cjs.map +1 -0
- package/dist/components/primitives/tilesprite.d.ts +157 -0
- package/dist/components/primitives/tilesprite.d.ts.map +1 -0
- package/dist/components/primitives/tilesprite.js +77 -0
- package/dist/components/primitives/tilesprite.js.map +1 -0
- package/dist/components/primitives/vectorDraw.cjs +73 -0
- package/dist/components/primitives/vectorDraw.cjs.map +1 -0
- package/dist/components/primitives/vectorDraw.d.ts +4 -0
- package/dist/components/primitives/vectorDraw.d.ts.map +1 -0
- package/dist/components/primitives/vectorDraw.js +73 -0
- package/dist/components/primitives/vectorDraw.js.map +1 -0
- package/dist/components/primitives/view.cjs +105 -0
- package/dist/components/primitives/view.cjs.map +1 -0
- package/dist/components/primitives/view.d.ts +23 -0
- package/dist/components/primitives/view.d.ts.map +1 -0
- package/dist/components/primitives/view.js +105 -0
- package/dist/components/primitives/view.js.map +1 -0
- package/dist/core-props.d.ts +105 -0
- package/dist/core-props.d.ts.map +1 -0
- package/dist/core-types.d.ts +71 -0
- package/dist/core-types.d.ts.map +1 -0
- package/dist/design-tokens/resolve-theme-tokens.cjs +27 -0
- package/dist/design-tokens/resolve-theme-tokens.cjs.map +1 -0
- package/dist/design-tokens/resolve-theme-tokens.d.ts +9 -0
- package/dist/design-tokens/resolve-theme-tokens.d.ts.map +1 -0
- package/dist/design-tokens/resolve-theme-tokens.js +27 -0
- package/dist/design-tokens/resolve-theme-tokens.js.map +1 -0
- package/dist/design-tokens/use-theme-tokens.cjs +26 -0
- package/dist/design-tokens/use-theme-tokens.cjs.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/design-tokens/use-theme-tokens.js +26 -0
- package/dist/design-tokens/use-theme-tokens.js.map +1 -0
- package/dist/effects/index.d.ts +2 -0
- package/dist/effects/index.d.ts.map +1 -0
- package/dist/effects/phaser-effects-bridge.cjs +48 -0
- package/dist/effects/phaser-effects-bridge.cjs.map +1 -0
- package/dist/effects/phaser-effects-bridge.d.ts +2 -0
- package/dist/effects/phaser-effects-bridge.d.ts.map +1 -0
- package/dist/effects/phaser-effects-bridge.js +30 -0
- package/dist/effects/phaser-effects-bridge.js.map +1 -0
- package/dist/effects/use-effect.cjs +155 -0
- package/dist/effects/use-effect.cjs.map +1 -0
- package/dist/effects/use-effect.d.ts +30 -0
- package/dist/effects/use-effect.d.ts.map +1 -0
- package/dist/effects/use-effect.js +155 -0
- package/dist/effects/use-effect.js.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.cjs +18 -0
- package/dist/fx/convenience-hooks/use-blur.cjs.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-blur.js +18 -0
- package/dist/fx/convenience-hooks/use-blur.js.map +1 -0
- package/dist/fx/convenience-hooks/use-glow.cjs +18 -0
- package/dist/fx/convenience-hooks/use-glow.cjs.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-glow.js +18 -0
- package/dist/fx/convenience-hooks/use-glow.js.map +1 -0
- package/dist/fx/convenience-hooks/use-shadow.cjs +18 -0
- package/dist/fx/convenience-hooks/use-shadow.cjs.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/convenience-hooks/use-shadow.js +18 -0
- package/dist/fx/convenience-hooks/use-shadow.js.map +1 -0
- package/dist/fx/fx-creators/blur.cjs +20 -0
- package/dist/fx/fx-creators/blur.cjs.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/blur.js +20 -0
- package/dist/fx/fx-creators/blur.js.map +1 -0
- package/dist/fx/fx-creators/color-matrix.cjs +47 -0
- package/dist/fx/fx-creators/color-matrix.cjs.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/color-matrix.js +47 -0
- package/dist/fx/fx-creators/color-matrix.js.map +1 -0
- package/dist/fx/fx-creators/glow.cjs +27 -0
- package/dist/fx/fx-creators/glow.cjs.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/glow.js +27 -0
- package/dist/fx/fx-creators/glow.js.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.cjs +20 -0
- package/dist/fx/fx-creators/pixelate.cjs.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/pixelate.js +20 -0
- package/dist/fx/fx-creators/pixelate.js.map +1 -0
- package/dist/fx/fx-creators/shadow.cjs +28 -0
- package/dist/fx/fx-creators/shadow.cjs.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/shadow.js +28 -0
- package/dist/fx/fx-creators/shadow.js.map +1 -0
- package/dist/fx/fx-creators/vignette.cjs +20 -0
- package/dist/fx/fx-creators/vignette.cjs.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-creators/vignette.js +20 -0
- package/dist/fx/fx-creators/vignette.js.map +1 -0
- package/dist/fx/fx-registry.cjs +43 -0
- package/dist/fx/fx-registry.cjs.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/fx-registry.js +43 -0
- package/dist/fx/fx-registry.js.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.cjs +54 -0
- package/dist/fx/use-fx.cjs.map +1 -0
- package/dist/fx/use-fx.d.ts +53 -0
- package/dist/fx/use-fx.d.ts.map +1 -0
- package/dist/fx/use-fx.js +54 -0
- package/dist/fx/use-fx.js.map +1 -0
- package/dist/gestures/gesture-manager.cjs +773 -0
- package/dist/gestures/gesture-manager.cjs.map +1 -0
- package/dist/gestures/gesture-manager.d.ts +158 -0
- package/dist/gestures/gesture-manager.d.ts.map +1 -0
- package/dist/gestures/gesture-manager.js +773 -0
- package/dist/gestures/gesture-manager.js.map +1 -0
- package/dist/gestures/gesture-types.cjs +9 -0
- package/dist/gestures/gesture-types.cjs.map +1 -0
- package/dist/gestures/gesture-types.d.ts +232 -0
- package/dist/gestures/gesture-types.d.ts.map +1 -0
- package/dist/gestures/gesture-types.js +9 -0
- package/dist/gestures/gesture-types.js.map +1 -0
- package/dist/hooks.cjs +193 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.ts +151 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +146 -0
- package/dist/hooks.js.map +1 -0
- package/dist/host.cjs +85 -0
- package/dist/host.cjs.map +1 -0
- package/dist/host.d.ts +78 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +85 -0
- package/dist/host.js.map +1 -0
- package/dist/index.cjs +614 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +273 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.cjs +20 -0
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +8 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +8 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.cjs +16 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.d.ts +9 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +7 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/jsx-types.d.ts +40 -0
- package/dist/jsx-types.d.ts.map +1 -0
- package/dist/layout/appliers/background-applier.cjs +40 -0
- package/dist/layout/appliers/background-applier.cjs.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/background-applier.js +40 -0
- package/dist/layout/appliers/background-applier.js.map +1 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/layout-engine-test-utils.d.ts +24 -0
- package/dist/layout/layout-engine-test-utils.d.ts.map +1 -0
- package/dist/layout/phaser-layout-bridge.cjs +41 -0
- package/dist/layout/phaser-layout-bridge.cjs.map +1 -0
- package/dist/layout/phaser-layout-bridge.d.ts +9 -0
- package/dist/layout/phaser-layout-bridge.d.ts.map +1 -0
- package/dist/layout/phaser-layout-bridge.js +40 -0
- package/dist/layout/phaser-layout-bridge.js.map +1 -0
- package/dist/layout/types.d.ts +14 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.cjs +39 -0
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.cjs.map +1 -0
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +39 -0
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js.map +1 -0
- package/dist/particles/emit-zone.cjs +205 -0
- package/dist/particles/emit-zone.cjs.map +1 -0
- package/dist/particles/emit-zone.d.ts +88 -0
- package/dist/particles/emit-zone.d.ts.map +1 -0
- package/dist/particles/emit-zone.js +205 -0
- package/dist/particles/emit-zone.js.map +1 -0
- package/dist/particles/index.d.ts +8 -0
- package/dist/particles/index.d.ts.map +1 -0
- package/dist/particles/particle-types.d.ts +25 -0
- package/dist/particles/particle-types.d.ts.map +1 -0
- package/dist/particles/preset-registry.cjs +57 -0
- package/dist/particles/preset-registry.cjs.map +1 -0
- package/dist/particles/preset-registry.d.ts +49 -0
- package/dist/particles/preset-registry.d.ts.map +1 -0
- package/dist/particles/preset-registry.js +57 -0
- package/dist/particles/preset-registry.js.map +1 -0
- package/dist/particles/use-particles.cjs +67 -0
- package/dist/particles/use-particles.cjs.map +1 -0
- package/dist/particles/use-particles.d.ts +19 -0
- package/dist/particles/use-particles.d.ts.map +1 -0
- package/dist/particles/use-particles.js +67 -0
- package/dist/particles/use-particles.js.map +1 -0
- package/dist/particles/utils.cjs +82 -0
- package/dist/particles/utils.cjs.map +1 -0
- package/dist/particles/utils.d.ts +10 -0
- package/dist/particles/utils.d.ts.map +1 -0
- package/dist/particles/utils.js +82 -0
- package/dist/particles/utils.js.map +1 -0
- package/dist/phaser-bridges.cjs +148 -0
- package/dist/phaser-bridges.cjs.map +1 -0
- package/dist/phaser-bridges.d.ts +78 -0
- package/dist/phaser-bridges.d.ts.map +1 -0
- package/dist/phaser-bridges.js +131 -0
- package/dist/phaser-bridges.js.map +1 -0
- package/dist/phaser-host-adapter.cjs +148 -0
- package/dist/phaser-host-adapter.cjs.map +1 -0
- package/dist/phaser-host-adapter.d.ts +30 -0
- package/dist/phaser-host-adapter.d.ts.map +1 -0
- package/dist/phaser-host-adapter.js +148 -0
- package/dist/phaser-host-adapter.js.map +1 -0
- package/dist/phaser-runtime-types.d.ts +89 -0
- package/dist/phaser-runtime-types.d.ts.map +1 -0
- package/dist/phaser-surface-adapter.cjs +488 -0
- package/dist/phaser-surface-adapter.cjs.map +1 -0
- package/dist/phaser-surface-adapter.d.ts +74 -0
- package/dist/phaser-surface-adapter.d.ts.map +1 -0
- package/dist/phaser-surface-adapter.js +471 -0
- package/dist/phaser-surface-adapter.js.map +1 -0
- package/dist/phaser-vdom-runtime.cjs +63 -0
- package/dist/phaser-vdom-runtime.cjs.map +1 -0
- package/dist/phaser-vdom-runtime.d.ts +2 -0
- package/dist/phaser-vdom-runtime.d.ts.map +1 -0
- package/dist/phaser-vdom-runtime.js +63 -0
- package/dist/phaser-vdom-runtime.js.map +1 -0
- package/dist/plugin.cjs +182 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.ts +161 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +165 -0
- package/dist/plugin.js.map +1 -0
- package/dist/render-context.cjs +106 -0
- package/dist/render-context.cjs.map +1 -0
- package/dist/render-context.d.ts +66 -0
- package/dist/render-context.d.ts.map +1 -0
- package/dist/render-context.js +106 -0
- package/dist/render-context.js.map +1 -0
- package/dist/scene-backgrounds.cjs +285 -0
- package/dist/scene-backgrounds.cjs.map +1 -0
- package/dist/scene-backgrounds.d.ts +69 -0
- package/dist/scene-backgrounds.d.ts.map +1 -0
- package/dist/scene-backgrounds.js +268 -0
- package/dist/scene-backgrounds.js.map +1 -0
- package/dist/theme-base.d.ts +133 -0
- package/dist/theme-base.d.ts.map +1 -0
- package/dist/theme-custom.d.ts +13 -0
- package/dist/theme-custom.d.ts.map +1 -0
- package/dist/theme-defaults.cjs +29 -0
- package/dist/theme-defaults.cjs.map +1 -0
- package/dist/theme-defaults.d.ts +1 -0
- package/dist/theme-defaults.d.ts.map +1 -0
- package/dist/theme-defaults.js +28 -0
- package/dist/theme-defaults.js.map +1 -0
- package/dist/theme.cjs +34 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.d.ts +36 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +32 -0
- package/dist/theme.js.map +1 -0
- package/dist/tooltip/tooltip-types.d.ts +6 -0
- package/dist/tooltip/tooltip-types.d.ts.map +1 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/KeyboardInputManager.cjs +112 -0
- package/dist/utils/KeyboardInputManager.cjs.map +1 -0
- package/dist/utils/KeyboardInputManager.d.ts +48 -0
- package/dist/utils/KeyboardInputManager.d.ts.map +1 -0
- package/dist/utils/KeyboardInputManager.js +112 -0
- package/dist/utils/KeyboardInputManager.js.map +1 -0
- package/dist/utils/dom-input-manager.cjs +253 -0
- package/dist/utils/dom-input-manager.cjs.map +1 -0
- package/dist/utils/dom-input-manager.d.ts +113 -0
- package/dist/utils/dom-input-manager.d.ts.map +1 -0
- package/dist/utils/dom-input-manager.js +253 -0
- package/dist/utils/dom-input-manager.js.map +1 -0
- package/dist/utils/fast-deep-equal.cjs +7 -0
- package/dist/utils/fast-deep-equal.cjs.map +1 -0
- package/dist/utils/fast-deep-equal.d.ts +4 -0
- package/dist/utils/fast-deep-equal.d.ts.map +1 -0
- package/dist/utils/fast-deep-equal.js +7 -0
- package/dist/utils/fast-deep-equal.js.map +1 -0
- package/dist/utils/image-subtexture-registry.cjs +98 -0
- package/dist/utils/image-subtexture-registry.cjs.map +1 -0
- package/dist/utils/image-subtexture-registry.d.ts +17 -0
- package/dist/utils/image-subtexture-registry.d.ts.map +1 -0
- package/dist/utils/image-subtexture-registry.js +98 -0
- package/dist/utils/image-subtexture-registry.js.map +1 -0
- package/dist/utils/phaser-guards.cjs +15 -0
- package/dist/utils/phaser-guards.cjs.map +1 -0
- package/dist/utils/phaser-guards.d.ts +7 -0
- package/dist/utils/phaser-guards.d.ts.map +1 -0
- package/dist/utils/phaser-guards.js +15 -0
- package/dist/utils/phaser-guards.js.map +1 -0
- package/dist/utils/svg-texture.cjs +48 -0
- package/dist/utils/svg-texture.cjs.map +1 -0
- package/dist/utils/svg-texture.d.ts +34 -0
- package/dist/utils/svg-texture.d.ts.map +1 -0
- package/dist/utils/svg-texture.js +48 -0
- package/dist/utils/svg-texture.js.map +1 -0
- package/dist/utils/texture-registry.cjs +117 -0
- package/dist/utils/texture-registry.cjs.map +1 -0
- package/dist/utils/texture-registry.d.ts +53 -0
- package/dist/utils/texture-registry.d.ts.map +1 -0
- package/dist/utils/texture-registry.js +117 -0
- package/dist/utils/texture-registry.js.map +1 -0
- package/dist/vdom-host-types.d.ts +12 -0
- package/dist/vdom-host-types.d.ts.map +1 -0
- package/dist/vdom-registry.d.ts +27 -0
- package/dist/vdom-registry.d.ts.map +1 -0
- package/dist/vdom-utils.d.ts +16 -0
- package/dist/vdom-utils.d.ts.map +1 -0
- package/dist/vdom.cjs +36 -0
- package/dist/vdom.cjs.map +1 -0
- package/dist/vdom.d.ts +23 -0
- package/dist/vdom.d.ts.map +1 -0
- package/dist/vdom.js +36 -0
- package/dist/vdom.js.map +1 -0
- package/dist/vector/PhaserVectorDrawContext.cjs +97 -0
- package/dist/vector/PhaserVectorDrawContext.cjs.map +1 -0
- package/dist/vector/PhaserVectorDrawContext.d.ts +27 -0
- package/dist/vector/PhaserVectorDrawContext.d.ts.map +1 -0
- package/dist/vector/PhaserVectorDrawContext.js +97 -0
- package/dist/vector/PhaserVectorDrawContext.js.map +1 -0
- package/dist/vector/index.d.ts +2 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.cjs","sources":["../src/hooks.ts"],"sourcesContent":["/**\n * Phaser-specific hook runtime — render cycle + Phaser-only hooks.\n *\n * Core hooks (useState, useRef, useMemo, useCallback, useEffect, useTheme,\n * useForceRedraw, useRedraw, disposeCtx, shallowEqual, shouldComponentUpdate)\n * are re-exported from @number10/jsx-core — the single source of truth.\n *\n * Phaser provides:\n * - withHooks() — render cycle with scene/shutdown guards\n * - useScene(), useViewportSize() — Phaser-specific hooks\n * - useLayoutEffect() — layout-aware effect (rAF-deferred)\n * - Layout helpers — getLayoutSize, useLayoutRect, etc.\n * - setUpdateHandler() call — injects Phaser's VDOM patching into core\n *\n * @migration(audit:scene-portal-mount) Phase 3G — core hooks extracted to\n * @number10/jsx-core. Phaser keeps only its render cycle and Phaser-specific hooks.\n */\n\nimport type { LayoutContainer, LayoutSize } from '@number10/jsx-core'\nimport {\n useEffect as coreUseEffect,\n useState as coreUseState,\n useTheme as coreUseTheme,\n withHooks as coreWithHooks,\n getCurrentCtx,\n setUpdateHandler,\n type HookContext,\n type UpdateHandler,\n} from '@number10/jsx-core'\nimport type * as Phaser from 'phaser'\nimport type { BackgroundImage } from './components/backgroundImage'\nimport type { BackgroundProps, LayoutProps, TransformProps } from './core-props'\nimport { getContextFromParent } from './render-context'\nimport type { PhaserPartialTheme } from './theme'\nimport type { ParentType, VNodeLike } from './types'\nimport { isPhaserScene } from './utils/phaser-guards'\nimport { normalizeVNodeLike, patchVNode } from './vdom'\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Phaser component context — extends core's HookContext with Phaser-specific fields.\n * The `parent` field is required by withHooks() for scene/shutdown checks.\n */\nexport interface Ctx extends Omit<HookContext, 'vnode' | 'componentVNode' | 'function' | 'theme'> {\n /** Phaser parent (Scene or Container) */\n parent: ParentType\n /** Narrower vnode type (Phaser VNode instead of unknown) */\n vnode: VNode | null\n /** Narrower componentVNode type */\n componentVNode: VNode\n /** Narrower function return type */\n function: (props: unknown) => VNodeLike\n /** Theme context for this component (Phaser-specific theme override map) */\n theme?: PhaserPartialTheme | undefined\n}\n\n// VNode type — re-exported from @number10/jsx-core for consistency.\nimport type { VNode as CoreVNode } from '@number10/jsx-core'\nexport type { VNode as CoreVNode } from '@number10/jsx-core'\n\n/**\n * VNode type used in the Phaser package.\n * Compatible with core's VNode.\n */\nexport type VNode = CoreVNode\n\n// ---------------------------------------------------------------------------\n// getCurrent — thin wrapper casting core's HookContext to Phaser's Ctx\n// ---------------------------------------------------------------------------\n\n/**\n * Get current hook context from active render.\n * Delegates to core's getCurrentCtx() — the single source of truth.\n * @returns Current context or null if not in render\n */\nexport function getCurrent(): Ctx | null {\n return getCurrentCtx() as Ctx | null\n}\n\n// ---------------------------------------------------------------------------\n// withHooks — Phaser-specific render cycle\n// ---------------------------------------------------------------------------\n\n/**\n * Executes a render function with hooks context.\n * Delegates to Core's withHooks() with Phaser-specific lifecycle guards\n * and per-mount context isolation via RenderContext.\n *\n * @migration(audit:scene-portal-mount) Phase 6I — delegates to coreWithHooks()\n * with Phaser scene/shutdown guards. Per-mount context stack preserved\n * via onAfterRender callback.\n * @param ctx - The component context\n * @param render - The render function to execute\n * @returns The result of the render function, or null if scene is shutting down\n */\nexport function withHooks<T>(ctx: Ctx, render: () => T): T {\n const renderContext = getContextFromParent(ctx.parent)\n\n // Per-mount context isolation (pre-Core pattern, preserved for compatibility)\n const prevMount = renderContext.getCurrent()\n\n const result = coreWithHooks(ctx as HookContext, render, {\n isAlive: () => {\n const scene = isPhaserScene(ctx.parent) ? ctx.parent : ctx.parent.scene\n if (!scene || !scene.sys || !scene.sys.settings.active) return false\n if (renderContext.isShutdown()) return false\n return true\n },\n onAfterRender: () => {\n // Restore per-mount context after render\n renderContext.setCurrent(prevMount)\n },\n })\n\n // Set per-mount context before render\n renderContext.setCurrent(ctx)\n // Note: setCurrentCtx is handled by coreWithHooks()\n\n return result as T\n}\n\n// ---------------------------------------------------------------------------\n// Phaser-specific hooks\n// ---------------------------------------------------------------------------\n\n/**\n * Hook to access current Phaser scene.\n * @returns Current Phaser scene\n */\nexport function useScene(): Phaser.Scene {\n const ctx = getCurrent()\n if (!ctx) throw new Error('useScene must be called within a component')\n\n const renderContext = getContextFromParent(ctx.parent)\n return renderContext.scene\n}\n\n/**\n * Hook to get the current viewport size from the active surface context.\n * Reactive — subscribes to Phaser's scene.scale resize events so that\n * overlay components reposition automatically on viewport changes.\n *\n * @migration(audit:surface-access) Phase 7 — scene.scale.on('resize') subscription\n * triggers re-render when the game canvas is resized.\n * @returns Viewport dimensions { width, height }\n */\nexport function useViewportSize(): { width: number; height: number } {\n const ctx = getCurrent()\n const surfaceViewport = ctx?.surface?.viewport\n if (surfaceViewport) {\n return surfaceViewport\n }\n\n const scene = useScene()\n const initialSize = { width: scene.scale.width, height: scene.scale.height }\n const [size, setSize] = coreUseState(initialSize)\n\n coreUseEffect(() => {\n const onResize = () => {\n setSize({ width: scene.scale.width, height: scene.scale.height })\n }\n scene.scale.on('resize', onResize)\n return () => {\n scene.scale.off('resize', onResize)\n }\n }, [scene])\n\n return size\n}\n\n// ---------------------------------------------------------------------------\n// Layout helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Get the layout-computed size of a container.\n * Works with any renderer's container that implements LayoutContainer duck-typing.\n *\n * @migration(audit:scene-portal-mount) Phase 6H — uses LayoutContainer instead of\n * Phaser.GameObjects.Container. Portable across renderers.\n */\nexport function getLayoutSize(\n container: LayoutContainer | null | undefined\n): LayoutSize | undefined {\n if (!container) return undefined\n return container.__getLayoutSize?.()\n}\n\n/**\n * Hook to get the layout size of a ref'd container.\n */\nexport function useLayoutSize(ref: { current: LayoutContainer | null }): LayoutSize | undefined {\n return getLayoutSize(ref.current)\n}\n\n/**\n * Get layout props from a container's metadata.\n *\n * @migration(audit:scene-portal-mount) Phase 6H — uses LayoutContainer.\n */\nexport function getLayoutProps(\n container: LayoutContainer | null | undefined\n): (LayoutProps & BackgroundProps & TransformProps) | undefined {\n if (!container) return undefined\n return container.__layoutProps as (LayoutProps & BackgroundProps & TransformProps) | undefined\n}\n\n/**\n * Get the background graphics object from a container.\n * Phaser-specific: returns Phaser's BackgroundImage type.\n *\n * @phaser-specific Uses Phaser.BackgroundImage via __background duck-typing.\n */\nfunction getBackgroundGraphics(\n container: LayoutContainer | null | undefined\n): BackgroundImage | undefined {\n if (!container) return undefined\n return container.__background as BackgroundImage | undefined\n}\n\n/**\n * Hook to get background graphics from a ref'd container.\n * @phaser-specific\n */\nexport function useBackgroundGraphics(ref: {\n current: LayoutContainer | null\n}): BackgroundImage | undefined {\n return getBackgroundGraphics(ref.current)\n}\n\n/**\n * Get the layout-computed rectangle (position + size) of a container.\n *\n * @migration(audit:scene-portal-mount) Phase 6H — uses LayoutContainer.\n */\nexport function getLayoutRect(\n container: LayoutContainer | null | undefined\n): { x: number; y: number; width: number; height: number } | undefined {\n if (!container) return undefined\n const size = getLayoutSize(container)\n if (!size) return undefined\n return {\n x: container.x ?? 0,\n y: container.y ?? 0,\n width: size.width,\n height: size.height,\n }\n}\n\n/**\n * Hook to get the layout rectangle of a ref'd container.\n */\nexport function useLayoutRect(ref: {\n current: LayoutContainer | null\n}): { x: number; y: number; width: number; height: number } | undefined {\n return getLayoutRect(ref.current)\n}\n\n/**\n * Get the world-space layout rectangle of a Phaser container.\n * Phaser-specific: uses `getWorldTransformMatrix()` which is not portable.\n *\n * @phaser-specific\n */\nexport function getWorldLayoutRect(\n container: Phaser.GameObjects.Container | null | undefined\n): { x: number; y: number; width: number; height: number } | undefined {\n if (!container) return undefined\n\n const size = getLayoutSize(container as unknown as LayoutContainer)\n if (!size) return undefined\n\n const matrix = container.getWorldTransformMatrix()\n\n return {\n x: matrix.tx,\n y: matrix.ty,\n width: size.width * Math.abs(matrix.scaleX),\n height: size.height * Math.abs(matrix.scaleY),\n }\n}\n\n/**\n * Hook to get the world-space layout rectangle.\n * @phaser-specific\n */\nexport function useWorldLayoutRect(ref: {\n current: Phaser.GameObjects.Container | null\n}): { x: number; y: number; width: number; height: number } | undefined {\n return getWorldLayoutRect(ref.current)\n}\n\n// ---------------------------------------------------------------------------\n// useLayoutEffect — now re-exported from Core (Phase 7B dedup)\n// ---------------------------------------------------------------------------\n// Core's useLayoutEffect uses HostScheduler.requestAnimationFrame() with\n// global rAF fallback — identical logic, no Phaser-specific behavior.\n\n// ---------------------------------------------------------------------------\n// Re-exports from @number10/jsx-core — canonical hook implementations\n// ---------------------------------------------------------------------------\n\nexport {\n depsChanged,\n disposeCtx,\n getCurrentCtx,\n getCurrentOrThrow,\n setCurrentCtx,\n shallowEqual,\n shouldComponentUpdate,\n useCallback,\n useEffect,\n useForceRedraw,\n useLayoutEffect,\n useMemo,\n useRedraw,\n useRef,\n useState,\n useTheme,\n} from '@number10/jsx-core'\n\n/**\n * Hook to access current theme context with Phaser-specific component keys.\n * Wraps core's useTheme() and casts to PhaserPartialTheme for typed access\n * to Phaser component themes (Slider, View, Text, etc.).\n *\n * Prefer core's useTheme() for renderer-agnostic code. Use this hook when\n * you need typed access to Phaser-specific component theme properties.\n *\n * @returns Current theme context or undefined if no theme is set\n */\nexport function usePhaserTheme(): PhaserPartialTheme | undefined {\n return coreUseTheme() as PhaserPartialTheme | undefined\n}\n\n// ---------------------------------------------------------------------------\n// Register Phaser's update handler with core\n// ---------------------------------------------------------------------------\n\nconst phaserUpdateHandler: UpdateHandler = (c: HookContext) => {\n const ctx = c as Ctx\n\n if (ctx.disposed) return\n\n const scene = isPhaserScene(ctx.parent) ? ctx.parent : ctx.parent.scene\n if (!scene || !scene.sys || !scene.sys.settings.active) return\n\n const componentProps = ctx.componentVNode.props ?? {}\n const propsWithChildren = ctx.componentVNode.children?.length\n ? { ...componentProps, children: ctx.componentVNode.children }\n : componentProps\n\n const nextVNode = normalizeVNodeLike(withHooks(ctx, () => ctx.function(propsWithChildren)))\n\n patchVNode(ctx.parent, ctx.vnode, nextVNode)\n\n ctx.vnode = nextVNode\n\n for (const run of ctx.effects) run()\n}\n\nsetUpdateHandler(phaserUpdateHandler)\n"],"names":["getCurrentCtx","renderContext","getContextFromParent","coreWithHooks","isPhaserScene","coreUseState","coreUseEffect","coreUseTheme","normalizeVNodeLike","patchVNode","setUpdateHandler"],"mappings":";;;;;;AA8EO,SAAS,aAAyB;AACvC,SAAOA,sBAAA;AACT;AAkBO,SAAS,UAAa,KAAU,QAAoB;AACzD,QAAMC,kBAAgBC,cAAAA,qBAAqB,IAAI,MAAM;AAGrD,QAAM,YAAYD,gBAAc,WAAA;AAEhC,QAAM,SAASE,QAAAA,UAAc,KAAoB,QAAQ;AAAA,IACvD,SAAS,MAAM;AACb,YAAM,QAAQC,2BAAc,IAAI,MAAM,IAAI,IAAI,SAAS,IAAI,OAAO;AAClE,UAAI,CAAC,SAAS,CAAC,MAAM,OAAO,CAAC,MAAM,IAAI,SAAS,OAAQ,QAAO;AAC/D,UAAIH,gBAAc,WAAA,EAAc,QAAO;AACvC,aAAO;AAAA,IACT;AAAA,IACA,eAAe,MAAM;AAEnBA,sBAAc,WAAW,SAAS;AAAA,IACpC;AAAA,EAAA,CACD;AAGDA,kBAAc,WAAW,GAAG;AAG5B,SAAO;AACT;AAUO,SAAS,WAAyB;AACvC,QAAM,MAAM,WAAA;AACZ,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,4CAA4C;AAEtE,QAAMA,kBAAgBC,cAAAA,qBAAqB,IAAI,MAAM;AACrD,SAAOD,gBAAc;AACvB;AAWO,SAAS,kBAAqD;AACnE,QAAM,MAAM,WAAA;AACZ,QAAM,kBAAkB,KAAK,SAAS;AACtC,MAAI,iBAAiB;AACnB,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,SAAA;AACd,QAAM,cAAc,EAAE,OAAO,MAAM,MAAM,OAAO,QAAQ,MAAM,MAAM,OAAA;AACpE,QAAM,CAAC,MAAM,OAAO,IAAII,QAAAA,SAAa,WAAW;AAEhDC,UAAAA,UAAc,MAAM;AAClB,UAAM,WAAW,MAAM;AACrB,cAAQ,EAAE,OAAO,MAAM,MAAM,OAA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mBAAmB,KAEqC;AACtE,SAAO,mBAAmB,IAAI,OAAO;AACvC;AAyCO,SAAS,iBAAiD;AAC/D,SAAOC,iBAAA;AACT;AAMA,MAAM,sBAAqC,CAAC,MAAmB;AAC7D,QAAM,MAAM;AAEZ,MAAI,IAAI,SAAU;AAElB,QAAM,QAAQH,2BAAc,IAAI,MAAM,IAAI,IAAI,SAAS,IAAI,OAAO;AAClE,MAAI,CAAC,SAAS,CAAC,MAAM,OAAO,CAAC,MAAM,IAAI,SAAS,OAAQ;AAExD,QAAM,iBAAiB,IAAI,eAAe,SAAS,CAAA;AACnD,QAAM,oBAAoB,IAAI,eAAe,UAAU,SACnD,EAAE,GAAG,gBAAgB,UAAU,IAAI,eAAe,SAAA,IAClD;AAEJ,QAAM,YAAYI,KAAAA,mBAAmB,UAAU,KAAK,MAAM,IAAI,SAAS,iBAAiB,CAAC,CAAC;AAE1FC,OAAAA,WAAW,IAAI,QAAQ,IAAI,OAAO,SAAS;AAE3C,MAAI,QAAQ;AAEZ,aAAW,OAAO,IAAI,QAAS,KAAA;AACjC;AAEAC,QAAAA,iBAAiB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { LayoutContainer, LayoutSize, HookContext, VNode as CoreVNode } from '@number10/jsx-core';
|
|
2
|
+
import { BackgroundImage } from './components/backgroundImage';
|
|
3
|
+
import { BackgroundProps, LayoutProps, TransformProps } from './core-props';
|
|
4
|
+
import { PhaserPartialTheme } from './theme';
|
|
5
|
+
import { ParentType, VNodeLike } from './types';
|
|
6
|
+
import type * as Phaser from 'phaser';
|
|
7
|
+
/**
|
|
8
|
+
* Phaser component context — extends core's HookContext with Phaser-specific fields.
|
|
9
|
+
* The `parent` field is required by withHooks() for scene/shutdown checks.
|
|
10
|
+
*/
|
|
11
|
+
export interface Ctx extends Omit<HookContext, 'vnode' | 'componentVNode' | 'function' | 'theme'> {
|
|
12
|
+
/** Phaser parent (Scene or Container) */
|
|
13
|
+
parent: ParentType;
|
|
14
|
+
/** Narrower vnode type (Phaser VNode instead of unknown) */
|
|
15
|
+
vnode: VNode | null;
|
|
16
|
+
/** Narrower componentVNode type */
|
|
17
|
+
componentVNode: VNode;
|
|
18
|
+
/** Narrower function return type */
|
|
19
|
+
function: (props: unknown) => VNodeLike;
|
|
20
|
+
/** Theme context for this component (Phaser-specific theme override map) */
|
|
21
|
+
theme?: PhaserPartialTheme | undefined;
|
|
22
|
+
}
|
|
23
|
+
export type { VNode as CoreVNode } from '@number10/jsx-core';
|
|
24
|
+
/**
|
|
25
|
+
* VNode type used in the Phaser package.
|
|
26
|
+
* Compatible with core's VNode.
|
|
27
|
+
*/
|
|
28
|
+
export type VNode = CoreVNode;
|
|
29
|
+
/**
|
|
30
|
+
* Get current hook context from active render.
|
|
31
|
+
* Delegates to core's getCurrentCtx() — the single source of truth.
|
|
32
|
+
* @returns Current context or null if not in render
|
|
33
|
+
*/
|
|
34
|
+
export declare function getCurrent(): Ctx | null;
|
|
35
|
+
/**
|
|
36
|
+
* Executes a render function with hooks context.
|
|
37
|
+
* Delegates to Core's withHooks() with Phaser-specific lifecycle guards
|
|
38
|
+
* and per-mount context isolation via RenderContext.
|
|
39
|
+
*
|
|
40
|
+
* @migration(audit:scene-portal-mount) Phase 6I — delegates to coreWithHooks()
|
|
41
|
+
* with Phaser scene/shutdown guards. Per-mount context stack preserved
|
|
42
|
+
* via onAfterRender callback.
|
|
43
|
+
* @param ctx - The component context
|
|
44
|
+
* @param render - The render function to execute
|
|
45
|
+
* @returns The result of the render function, or null if scene is shutting down
|
|
46
|
+
*/
|
|
47
|
+
export declare function withHooks<T>(ctx: Ctx, render: () => T): T;
|
|
48
|
+
/**
|
|
49
|
+
* Hook to access current Phaser scene.
|
|
50
|
+
* @returns Current Phaser scene
|
|
51
|
+
*/
|
|
52
|
+
export declare function useScene(): Phaser.Scene;
|
|
53
|
+
/**
|
|
54
|
+
* Hook to get the current viewport size from the active surface context.
|
|
55
|
+
* Reactive — subscribes to Phaser's scene.scale resize events so that
|
|
56
|
+
* overlay components reposition automatically on viewport changes.
|
|
57
|
+
*
|
|
58
|
+
* @migration(audit:surface-access) Phase 7 — scene.scale.on('resize') subscription
|
|
59
|
+
* triggers re-render when the game canvas is resized.
|
|
60
|
+
* @returns Viewport dimensions { width, height }
|
|
61
|
+
*/
|
|
62
|
+
export declare function useViewportSize(): {
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Get the layout-computed size of a container.
|
|
68
|
+
* Works with any renderer's container that implements LayoutContainer duck-typing.
|
|
69
|
+
*
|
|
70
|
+
* @migration(audit:scene-portal-mount) Phase 6H — uses LayoutContainer instead of
|
|
71
|
+
* Phaser.GameObjects.Container. Portable across renderers.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getLayoutSize(container: LayoutContainer | null | undefined): LayoutSize | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Hook to get the layout size of a ref'd container.
|
|
76
|
+
*/
|
|
77
|
+
export declare function useLayoutSize(ref: {
|
|
78
|
+
current: LayoutContainer | null;
|
|
79
|
+
}): LayoutSize | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Get layout props from a container's metadata.
|
|
82
|
+
*
|
|
83
|
+
* @migration(audit:scene-portal-mount) Phase 6H — uses LayoutContainer.
|
|
84
|
+
*/
|
|
85
|
+
export declare function getLayoutProps(container: LayoutContainer | null | undefined): (LayoutProps & BackgroundProps & TransformProps) | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Hook to get background graphics from a ref'd container.
|
|
88
|
+
* @phaser-specific
|
|
89
|
+
*/
|
|
90
|
+
export declare function useBackgroundGraphics(ref: {
|
|
91
|
+
current: LayoutContainer | null;
|
|
92
|
+
}): BackgroundImage | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Get the layout-computed rectangle (position + size) of a container.
|
|
95
|
+
*
|
|
96
|
+
* @migration(audit:scene-portal-mount) Phase 6H — uses LayoutContainer.
|
|
97
|
+
*/
|
|
98
|
+
export declare function getLayoutRect(container: LayoutContainer | null | undefined): {
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
width: number;
|
|
102
|
+
height: number;
|
|
103
|
+
} | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Hook to get the layout rectangle of a ref'd container.
|
|
106
|
+
*/
|
|
107
|
+
export declare function useLayoutRect(ref: {
|
|
108
|
+
current: LayoutContainer | null;
|
|
109
|
+
}): {
|
|
110
|
+
x: number;
|
|
111
|
+
y: number;
|
|
112
|
+
width: number;
|
|
113
|
+
height: number;
|
|
114
|
+
} | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Get the world-space layout rectangle of a Phaser container.
|
|
117
|
+
* Phaser-specific: uses `getWorldTransformMatrix()` which is not portable.
|
|
118
|
+
*
|
|
119
|
+
* @phaser-specific
|
|
120
|
+
*/
|
|
121
|
+
export declare function getWorldLayoutRect(container: Phaser.GameObjects.Container | null | undefined): {
|
|
122
|
+
x: number;
|
|
123
|
+
y: number;
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
} | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Hook to get the world-space layout rectangle.
|
|
129
|
+
* @phaser-specific
|
|
130
|
+
*/
|
|
131
|
+
export declare function useWorldLayoutRect(ref: {
|
|
132
|
+
current: Phaser.GameObjects.Container | null;
|
|
133
|
+
}): {
|
|
134
|
+
x: number;
|
|
135
|
+
y: number;
|
|
136
|
+
width: number;
|
|
137
|
+
height: number;
|
|
138
|
+
} | undefined;
|
|
139
|
+
export { depsChanged, disposeCtx, getCurrentCtx, getCurrentOrThrow, setCurrentCtx, shallowEqual, shouldComponentUpdate, useCallback, useEffect, useForceRedraw, useLayoutEffect, useMemo, useRedraw, useRef, useState, useTheme, } from '@number10/jsx-core';
|
|
140
|
+
/**
|
|
141
|
+
* Hook to access current theme context with Phaser-specific component keys.
|
|
142
|
+
* Wraps core's useTheme() and casts to PhaserPartialTheme for typed access
|
|
143
|
+
* to Phaser component themes (Slider, View, Text, etc.).
|
|
144
|
+
*
|
|
145
|
+
* Prefer core's useTheme() for renderer-agnostic code. Use this hook when
|
|
146
|
+
* you need typed access to Phaser-specific component theme properties.
|
|
147
|
+
*
|
|
148
|
+
* @returns Current theme context or undefined if no theme is set
|
|
149
|
+
*/
|
|
150
|
+
export declare function usePhaserTheme(): PhaserPartialTheme | undefined;
|
|
151
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAEhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAQpD;;;GAGG;AACH,MAAM,WAAW,GAAI,SAAQ,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,gBAAgB,GAAG,UAAU,GAAG,OAAO,CAAC;IAC/F,yCAAyC;IACzC,MAAM,EAAE,UAAU,CAAA;IAClB,4DAA4D;IAC5D,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,mCAAmC;IACnC,cAAc,EA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EACN,QAAQ,EACR,QAAQ,GACT,MAAM,oBAAoB,CAAA;AAE3B;;;;;;;;;GASG;AACH,wBAAgB,cAAc,IAAI,kBAAkB,GAAG,SAAS,CAE/D"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { setUpdateHandler, withHooks as withHooks$1, getCurrentCtx, useTheme, useState, useEffect } from "@number10/jsx-core";
|
|
2
|
+
import { depsChanged, disposeCtx, getCurrentCtx as getCurrentCtx2, getCurrentOrThrow, setCurrentCtx, shallowEqual, shouldComponentUpdate, useCallback, useEffect as useEffect2, useForceRedraw, useLayoutEffect, useMemo, useRedraw, useRef, useState as useState2, useTheme as useTheme2 } from "@number10/jsx-core";
|
|
3
|
+
import { getContextFromParent } from "./render-context.js";
|
|
4
|
+
import { isPhaserScene } from "./utils/phaser-guards.js";
|
|
5
|
+
import { normalizeVNodeLike, patchVNode } from "./vdom.js";
|
|
6
|
+
function getCurrent() {
|
|
7
|
+
return getCurrentCtx();
|
|
8
|
+
}
|
|
9
|
+
function withHooks(ctx, render) {
|
|
10
|
+
const renderContext = getContextFromParent(ctx.parent);
|
|
11
|
+
const prevMount = renderContext.getCurrent();
|
|
12
|
+
const result = withHooks$1(ctx, render, {
|
|
13
|
+
isAlive: () => {
|
|
14
|
+
const scene = isPhaserScene(ctx.parent) ? ctx.parent : ctx.parent.scene;
|
|
15
|
+
if (!scene || !scene.sys || !scene.sys.settings.active) return false;
|
|
16
|
+
if (renderContext.isShutdown()) return false;
|
|
17
|
+
return true;
|
|
18
|
+
},
|
|
19
|
+
onAfterRender: () => {
|
|
20
|
+
renderContext.setCurrent(prevMount);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
renderContext.setCurrent(ctx);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function useScene() {
|
|
27
|
+
const ctx = getCurrent();
|
|
28
|
+
if (!ctx) throw new Error("useScene must be called within a component");
|
|
29
|
+
const renderContext = getContextFromParent(ctx.parent);
|
|
30
|
+
return renderContext.scene;
|
|
31
|
+
}
|
|
32
|
+
function useViewportSize() {
|
|
33
|
+
const ctx = getCurrent();
|
|
34
|
+
const surfaceViewport = ctx?.surface?.viewport;
|
|
35
|
+
if (surfaceViewport) {
|
|
36
|
+
return surfaceViewport;
|
|
37
|
+
}
|
|
38
|
+
const scene = useScene();
|
|
39
|
+
const initialSize = { width: scene.scale.width, height: scene.scale.height };
|
|
40
|
+
const [size, setSize] = useState(initialSize);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const onResize = () => {
|
|
43
|
+
setSize({ width: scene.scale.width, height: scene.scale.height });
|
|
44
|
+
};
|
|
45
|
+
scene.scale.on("resize", onResize);
|
|
46
|
+
return () => {
|
|
47
|
+
scene.scale.off("resize", onResize);
|
|
48
|
+
};
|
|
49
|
+
}, [scene]);
|
|
50
|
+
return size;
|
|
51
|
+
}
|
|
52
|
+
function getLayoutSize(container) {
|
|
53
|
+
if (!container) return void 0;
|
|
54
|
+
return container.__getLayoutSize?.();
|
|
55
|
+
}
|
|
56
|
+
function useLayoutSize(ref) {
|
|
57
|
+
return getLayoutSize(ref.current);
|
|
58
|
+
}
|
|
59
|
+
function getLayoutProps(container) {
|
|
60
|
+
if (!container) return void 0;
|
|
61
|
+
return container.__layoutProps;
|
|
62
|
+
}
|
|
63
|
+
function getBackgroundGraphics(container) {
|
|
64
|
+
if (!container) return void 0;
|
|
65
|
+
return container.__background;
|
|
66
|
+
}
|
|
67
|
+
function useBackgroundGraphics(ref) {
|
|
68
|
+
return getBackgroundGraphics(ref.current);
|
|
69
|
+
}
|
|
70
|
+
function getLayoutRect(container) {
|
|
71
|
+
if (!container) return void 0;
|
|
72
|
+
const size = getLayoutSize(container);
|
|
73
|
+
if (!size) return void 0;
|
|
74
|
+
return {
|
|
75
|
+
x: container.x ?? 0,
|
|
76
|
+
y: container.y ?? 0,
|
|
77
|
+
width: size.width,
|
|
78
|
+
height: size.height
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function useLayoutRect(ref) {
|
|
82
|
+
return getLayoutRect(ref.current);
|
|
83
|
+
}
|
|
84
|
+
function getWorldLayoutRect(container) {
|
|
85
|
+
if (!container) return void 0;
|
|
86
|
+
const size = getLayoutSize(container);
|
|
87
|
+
if (!size) return void 0;
|
|
88
|
+
const matrix = container.getWorldTransformMatrix();
|
|
89
|
+
return {
|
|
90
|
+
x: matrix.tx,
|
|
91
|
+
y: matrix.ty,
|
|
92
|
+
width: size.width * Math.abs(matrix.scaleX),
|
|
93
|
+
height: size.height * Math.abs(matrix.scaleY)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function useWorldLayoutRect(ref) {
|
|
97
|
+
return getWorldLayoutRect(ref.current);
|
|
98
|
+
}
|
|
99
|
+
function usePhaserTheme() {
|
|
100
|
+
return useTheme();
|
|
101
|
+
}
|
|
102
|
+
const phaserUpdateHandler = (c) => {
|
|
103
|
+
const ctx = c;
|
|
104
|
+
if (ctx.disposed) return;
|
|
105
|
+
const scene = isPhaserScene(ctx.parent) ? ctx.parent : ctx.parent.scene;
|
|
106
|
+
if (!scene || !scene.sys || !scene.sys.settings.active) return;
|
|
107
|
+
const componentProps = ctx.componentVNode.props ?? {};
|
|
108
|
+
const propsWithChildren = ctx.componentVNode.children?.length ? { ...componentProps, children: ctx.componentVNode.children } : componentProps;
|
|
109
|
+
const nextVNode = normalizeVNodeLike(withHooks(ctx, () => ctx.function(propsWithChildren)));
|
|
110
|
+
patchVNode(ctx.parent, ctx.vnode, nextVNode);
|
|
111
|
+
ctx.vnode = nextVNode;
|
|
112
|
+
for (const run of ctx.effects) run();
|
|
113
|
+
};
|
|
114
|
+
setUpdateHandler(phaserUpdateHandler);
|
|
115
|
+
export {
|
|
116
|
+
depsChanged,
|
|
117
|
+
disposeCtx,
|
|
118
|
+
getCurrent,
|
|
119
|
+
getCurrentCtx2 as getCurrentCtx,
|
|
120
|
+
getCurrentOrThrow,
|
|
121
|
+
getLayoutProps,
|
|
122
|
+
getLayoutRect,
|
|
123
|
+
getLayoutSize,
|
|
124
|
+
getWorldLayoutRect,
|
|
125
|
+
setCurrentCtx,
|
|
126
|
+
shallowEqual,
|
|
127
|
+
shouldComponentUpdate,
|
|
128
|
+
useBackgroundGraphics,
|
|
129
|
+
useCallback,
|
|
130
|
+
useEffect2 as useEffect,
|
|
131
|
+
useForceRedraw,
|
|
132
|
+
useLayoutEffect,
|
|
133
|
+
useLayoutRect,
|
|
134
|
+
useLayoutSize,
|
|
135
|
+
useMemo,
|
|
136
|
+
usePhaserTheme,
|
|
137
|
+
useRedraw,
|
|
138
|
+
useRef,
|
|
139
|
+
useScene,
|
|
140
|
+
useState2 as useState,
|
|
141
|
+
useTheme2 as useTheme,
|
|
142
|
+
useViewportSize,
|
|
143
|
+
useWorldLayoutRect,
|
|
144
|
+
withHooks
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../src/hooks.ts"],"sourcesContent":["/**\n * Phaser-specific hook runtime — render cycle + Phaser-only hooks.\n *\n * Core hooks (useState, useRef, useMemo, useCallback, useEffect, useTheme,\n * useForceRedraw, useRedraw, disposeCtx, shallowEqual, shouldComponentUpdate)\n * are re-exported from @number10/jsx-core — the single source of truth.\n *\n * Phaser provides:\n * - withHooks() — render cycle with scene/shutdown guards\n * - useScene(), useViewportSize() — Phaser-specific hooks\n * - useLayoutEffect() — layout-aware effect (rAF-deferred)\n * - Layout helpers — getLayoutSize, useLayoutRect, etc.\n * - setUpdateHandler() call — injects Phaser's VDOM patching into core\n *\n * @migration(audit:scene-portal-mount) Phase 3G — core hooks extracted to\n * @number10/jsx-core. Phaser keeps only its render cycle and Phaser-specific hooks.\n */\n\nimport type { LayoutContainer, LayoutSize } from '@number10/jsx-core'\nimport {\n useEffect as coreUseEffect,\n useState as coreUseState,\n useTheme as coreUseTheme,\n withHooks as coreWithHooks,\n getCurrentCtx,\n setUpdateHandler,\n type HookContext,\n type UpdateHandler,\n} from '@number10/jsx-core'\nimport type * as Phaser from 'phaser'\nimport type { BackgroundImage } from './components/backgroundImage'\nimport type { BackgroundProps, LayoutProps, TransformProps } from './core-props'\nimport { getContextFromParent } from './render-context'\nimport type { PhaserPartialTheme } from './theme'\nimport type { ParentType, VNodeLike } from './types'\nimport { isPhaserScene } from './utils/phaser-guards'\nimport { normalizeVNodeLike, patchVNode } from './vdom'\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Phaser component context — extends core's HookContext with Phaser-specific fields.\n * The `parent` field is required by withHooks() for scene/shutdown checks.\n */\nexport interface Ctx extends Omit<HookContext, 'vnode' | 'componentVNode' | 'function' | 'theme'> {\n /** Phaser parent (Scene or Container) */\n parent: ParentType\n /** Narrower vnode type (Phaser VNode instead of unknown) */\n vnode: VNode | null\n /** Narrower componentVNode type */\n componentVNode: VNode\n /** Narrower function return type */\n function: (props: unknown) => VNodeLike\n /** Theme context for this component (Phaser-specific theme override map) */\n theme?: PhaserPartialTheme | undefined\n}\n\n// VNode type — re-exported from @number10/jsx-core for consistency.\nimport type { VNode as CoreVNode } from '@number10/jsx-core'\nexport type { VNode as CoreVNode } from '@number10/jsx-core'\n\n/**\n * VNode type used in the Phaser package.\n * Compatible with core's VNode.\n */\nexport type VNode = CoreVNode\n\n// ---------------------------------------------------------------------------\n// getCurrent — thin wrapper casting core's HookContext to Phaser's Ctx\n// ---------------------------------------------------------------------------\n\n/**\n * Get current hook context from active render.\n * Delegates to core's getCurrentCtx() — the single source of truth.\n * @returns Current context or null if not in render\n */\nexport function getCurrent(): Ctx | null {\n return getCurrentCtx() as Ctx | null\n}\n\n// ---------------------------------------------------------------------------\n// withHooks — Phaser-specific render cycle\n// ---------------------------------------------------------------------------\n\n/**\n * Executes a render function with hooks context.\n * Delegates to Core's withHooks() with Phaser-specific lifecycle guards\n * and per-mount context isolation via RenderContext.\n *\n * @migration(audit:scene-portal-mount) Phase 6I — delegates to coreWithHooks()\n * with Phaser scene/shutdown guards. Per-mount context stack preserved\n * via onAfterRender callback.\n * @param ctx - The component context\n * @param render - The render function to execute\n * @returns The result of the render function, or null if scene is shutting down\n */\nexport function withHooks<T>(ctx: Ctx, render: () => T): T {\n const renderContext = getContextFromParent(ctx.parent)\n\n // Per-mount context isolation (pre-Core pattern, preserved for compatibility)\n const prevMount = renderContext.getCurrent()\n\n const result = coreWithHooks(ctx as HookContext, render, {\n isAlive: () => {\n const scene = isPhaserScene(ctx.parent) ? ctx.parent : ctx.parent.scene\n if (!scene || !scene.sys || !scene.sys.settings.active) return false\n if (renderContext.isShutdown()) return false\n return true\n },\n onAfterRender: () => {\n // Restore per-mount context after render\n renderContext.setCurrent(prevMount)\n },\n })\n\n // Set per-mount context before render\n renderContext.setCurrent(ctx)\n // Note: setCurrentCtx is handled by coreWithHooks()\n\n return result as T\n}\n\n// ---------------------------------------------------------------------------\n// Phaser-specific hooks\n// ---------------------------------------------------------------------------\n\n/**\n * Hook to access current Phaser scene.\n * @returns Current Phaser scene\n */\nexport function useScene(): Phaser.Scene {\n const ctx = getCurrent()\n if (!ctx) throw new Error('useScene must be called within a component')\n\n const renderContext = getContextFromParent(ctx.parent)\n return renderContext.scene\n}\n\n/**\n * Hook to get the current viewport size from the active surface context.\n * Reactive — subscribes to Phaser's scene.scale resize events so that\n * overlay components reposition automatically on viewport changes.\n *\n * @migration(audit:surface-access) Phase 7 — scene.scale.on('resize') subscription\n * triggers re-render when the game canvas is resized.\n * @returns Viewport dimensions { width, height }\n */\nexport function useViewportSize(): { width: number; height: number } {\n const ctx = getCurrent()\n const surfaceViewport = ctx?.surface?.viewport\n if (surfaceViewport) {\n return surfaceViewport\n }\n\n const scene = useScene()\n const initialSize = { width: scene.scale.width, height: scene.scale.height }\n const [size, setSize] = coreUseState(initialSize)\n\n coreUseEffect(() => {\n const onResize = () => {\n setSize({ width: scene.scale.width, height: scene.scale.height })\n }\n scene.scale.on('resize', onResize)\n return () => {\n scene.scale.off('resize', onResize)\n }\n }, [scene])\n\n return size\n}\n\n// ---------------------------------------------------------------------------\n// Layout helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Get the layout-computed size of a container.\n * Works with any renderer's container that implements LayoutContainer duck-typing.\n *\n * @migration(audit:scene-portal-mount) Phase 6H — uses LayoutContainer instead of\n * Phaser.GameObjects.Container. Portable across renderers.\n */\nexport function getLayoutSize(\n container: LayoutContainer | null | undefined\n): LayoutSize | undefined {\n if (!container) return undefined\n return container.__getLayoutSize?.()\n}\n\n/**\n * Hook to get the layout size of a ref'd container.\n */\nexport function useLayoutSize(ref: { current: LayoutContainer | null }): LayoutSize | undefined {\n return getLayoutSize(ref.current)\n}\n\n/**\n * Get layout props from a container's metadata.\n *\n * @migration(audit:scene-portal-mount) Phase 6H — uses LayoutContainer.\n */\nexport function getLayoutProps(\n container: LayoutContainer | null | undefined\n): (LayoutProps & BackgroundProps & TransformProps) | undefined {\n if (!container) return undefined\n return container.__layoutProps as (LayoutProps & BackgroundProps & TransformProps) | undefined\n}\n\n/**\n * Get the background graphics object from a container.\n * Phaser-specific: returns Phaser's BackgroundImage type.\n *\n * @phaser-specific Uses Phaser.BackgroundImage via __background duck-typing.\n */\nfunction getBackgroundGraphics(\n container: LayoutContainer | null | undefined\n): BackgroundImage | undefined {\n if (!container) return undefined\n return container.__background as BackgroundImage | undefined\n}\n\n/**\n * Hook to get background graphics from a ref'd container.\n * @phaser-specific\n */\nexport function useBackgroundGraphics(ref: {\n current: LayoutContainer | null\n}): BackgroundImage | undefined {\n return getBackgroundGraphics(ref.current)\n}\n\n/**\n * Get the layout-computed rectangle (position + size) of a container.\n *\n * @migration(audit:scene-portal-mount) Phase 6H — uses LayoutContainer.\n */\nexport function getLayoutRect(\n container: LayoutContainer | null | undefined\n): { x: number; y: number; width: number; height: number } | undefined {\n if (!container) return undefined\n const size = getLayoutSize(container)\n if (!size) return undefined\n return {\n x: container.x ?? 0,\n y: container.y ?? 0,\n width: size.width,\n height: size.height,\n }\n}\n\n/**\n * Hook to get the layout rectangle of a ref'd container.\n */\nexport function useLayoutRect(ref: {\n current: LayoutContainer | null\n}): { x: number; y: number; width: number; height: number } | undefined {\n return getLayoutRect(ref.current)\n}\n\n/**\n * Get the world-space layout rectangle of a Phaser container.\n * Phaser-specific: uses `getWorldTransformMatrix()` which is not portable.\n *\n * @phaser-specific\n */\nexport function getWorldLayoutRect(\n container: Phaser.GameObjects.Container | null | undefined\n): { x: number; y: number; width: number; height: number } | undefined {\n if (!container) return undefined\n\n const size = getLayoutSize(container as unknown as LayoutContainer)\n if (!size) return undefined\n\n const matrix = container.getWorldTransformMatrix()\n\n return {\n x: matrix.tx,\n y: matrix.ty,\n width: size.width * Math.abs(matrix.scaleX),\n height: size.height * Math.abs(matrix.scaleY),\n }\n}\n\n/**\n * Hook to get the world-space layout rectangle.\n * @phaser-specific\n */\nexport function useWorldLayoutRect(ref: {\n current: Phaser.GameObjects.Container | null\n}): { x: number; y: number; width: number; height: number } | undefined {\n return getWorldLayoutRect(ref.current)\n}\n\n// ---------------------------------------------------------------------------\n// useLayoutEffect — now re-exported from Core (Phase 7B dedup)\n// ---------------------------------------------------------------------------\n// Core's useLayoutEffect uses HostScheduler.requestAnimationFrame() with\n// global rAF fallback — identical logic, no Phaser-specific behavior.\n\n// ---------------------------------------------------------------------------\n// Re-exports from @number10/jsx-core — canonical hook implementations\n// ---------------------------------------------------------------------------\n\nexport {\n depsChanged,\n disposeCtx,\n getCurrentCtx,\n getCurrentOrThrow,\n setCurrentCtx,\n shallowEqual,\n shouldComponentUpdate,\n useCallback,\n useEffect,\n useForceRedraw,\n useLayoutEffect,\n useMemo,\n useRedraw,\n useRef,\n useState,\n useTheme,\n} from '@number10/jsx-core'\n\n/**\n * Hook to access current theme context with Phaser-specific component keys.\n * Wraps core's useTheme() and casts to PhaserPartialTheme for typed access\n * to Phaser component themes (Slider, View, Text, etc.).\n *\n * Prefer core's useTheme() for renderer-agnostic code. Use this hook when\n * you need typed access to Phaser-specific component theme properties.\n *\n * @returns Current theme context or undefined if no theme is set\n */\nexport function usePhaserTheme(): PhaserPartialTheme | undefined {\n return coreUseTheme() as PhaserPartialTheme | undefined\n}\n\n// ---------------------------------------------------------------------------\n// Register Phaser's update handler with core\n// ---------------------------------------------------------------------------\n\nconst phaserUpdateHandler: UpdateHandler = (c: HookContext) => {\n const ctx = c as Ctx\n\n if (ctx.disposed) return\n\n const scene = isPhaserScene(ctx.parent) ? ctx.parent : ctx.parent.scene\n if (!scene || !scene.sys || !scene.sys.settings.active) return\n\n const componentProps = ctx.componentVNode.props ?? {}\n const propsWithChildren = ctx.componentVNode.children?.length\n ? { ...componentProps, children: ctx.componentVNode.children }\n : componentProps\n\n const nextVNode = normalizeVNodeLike(withHooks(ctx, () => ctx.function(propsWithChildren)))\n\n patchVNode(ctx.parent, ctx.vnode, nextVNode)\n\n ctx.vnode = nextVNode\n\n for (const run of ctx.effects) run()\n}\n\nsetUpdateHandler(phaserUpdateHandler)\n"],"names":["coreWithHooks","coreUseState","coreUseEffect","coreUseTheme"],"mappings":";;;;;AA8EO,SAAS,aAAyB;AACvC,SAAO,cAAA;AACT;AAkBO,SAAS,UAAa,KAAU,QAAoB;AACzD,QAAM,gBAAgB,qBAAqB,IAAI,MAAM;AAGrD,QAAM,YAAY,cAAc,WAAA;AAEhC,QAAM,SAASA,YAAc,KAAoB,QAAQ;AAAA,IACvD,SAAS,MAAM;AACb,YAAM,QAAQ,cAAc,IAAI,MAAM,IAAI,IAAI,SAAS,IAAI,OAAO;AAClE,UAAI,CAAC,SAAS,CAAC,MAAM,OAAO,CAAC,MAAM,IAAI,SAAS,OAAQ,QAAO;AAC/D,UAAI,cAAc,WAAA,EAAc,QAAO;AACvC,aAAO;AAAA,IACT;AAAA,IACA,eAAe,MAAM;AAEnB,oBAAc,WAAW,SAAS;AAAA,IACpC;AAAA,EAAA,CACD;AAGD,gBAAc,WAAW,GAAG;AAG5B,SAAO;AACT;AAUO,SAAS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"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const phaserGuards = require("./utils/phaser-guards.cjs");
|
|
4
|
+
const nodeRegistry = {};
|
|
5
|
+
function register(type, descriptor) {
|
|
6
|
+
nodeRegistry[type] = descriptor;
|
|
7
|
+
}
|
|
8
|
+
const host = {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a node instance using the registered creator for the given type
|
|
11
|
+
* @param type - Node type name
|
|
12
|
+
* @param props - Node properties
|
|
13
|
+
* @param scene - Phaser scene
|
|
14
|
+
* @returns Created node instance
|
|
15
|
+
* @throws Error if no creator registered for the type
|
|
16
|
+
*/
|
|
17
|
+
// @migration(audit:scene-portal-mount) Root-Container — host.create(scene) → HostAdapter.create(type, props, ctx)
|
|
18
|
+
create(type, props, scene) {
|
|
19
|
+
const descriptor = nodeRegistry[type];
|
|
20
|
+
if (!descriptor) {
|
|
21
|
+
throw new Error(`No host descriptor registered for node type "${String(type)}"`);
|
|
22
|
+
}
|
|
23
|
+
return descriptor.create(scene, props);
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Patches node properties with updates using the registered patcher
|
|
27
|
+
* @param type - Node type name
|
|
28
|
+
* @param node - Node to patch
|
|
29
|
+
* @param prev - Previous props
|
|
30
|
+
* @param next - New props
|
|
31
|
+
*/
|
|
32
|
+
patch(type, node, prev, next) {
|
|
33
|
+
const descriptor = nodeRegistry[type];
|
|
34
|
+
if (!descriptor) {
|
|
35
|
+
throw new Error(`No host descriptor registered for node type "${String(type)}"`);
|
|
36
|
+
}
|
|
37
|
+
descriptor.patch(node, prev, next);
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Appends child node to parent container
|
|
41
|
+
* @param parent - Parent container or scene
|
|
42
|
+
* @param child - Child node to append
|
|
43
|
+
*/
|
|
44
|
+
append(parent, child) {
|
|
45
|
+
if (phaserGuards.isPhaserContainer(parent)) {
|
|
46
|
+
parent.add(child);
|
|
47
|
+
child.parent = parent;
|
|
48
|
+
} else if (phaserGuards.isPhaserScene(parent)) {
|
|
49
|
+
const scene = parent;
|
|
50
|
+
scene.add.existing(child);
|
|
51
|
+
child.parent = void 0;
|
|
52
|
+
} else if (parent && typeof parent === "object" && "scene" in parent) {
|
|
53
|
+
const gameObject = parent;
|
|
54
|
+
if (gameObject.scene?.children) {
|
|
55
|
+
gameObject.scene.children.add(child);
|
|
56
|
+
child.parent = void 0;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Removes child node from parent and destroys it
|
|
62
|
+
* @param parent - Parent container
|
|
63
|
+
* @param child - Child node to remove
|
|
64
|
+
*/
|
|
65
|
+
remove(parent, child) {
|
|
66
|
+
const childObj = child;
|
|
67
|
+
if (!childObj.scene) return;
|
|
68
|
+
if (phaserGuards.isPhaserContainer(parent)) {
|
|
69
|
+
parent.remove(childObj, false);
|
|
70
|
+
}
|
|
71
|
+
childObj.parent = void 0;
|
|
72
|
+
if (childObj.destroy) {
|
|
73
|
+
childObj.destroy(false);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Performs layout update on container (no-op for native Phaser)
|
|
78
|
+
*/
|
|
79
|
+
layout() {
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.host = host;
|
|
83
|
+
exports.nodeRegistry = nodeRegistry;
|
|
84
|
+
exports.register = register;
|
|
85
|
+
//# sourceMappingURL=host.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.cjs","sources":["../src/host.ts"],"sourcesContent":["/**\n * Host layer - Generic bridge between VDOM and Phaser GameObjects\n * Provides type-safe creator/patcher pattern for extensible node types\n */\nimport type * as Phaser from 'phaser'\nimport type { NodeInstance, NodeProps, NodeType } from './core-types'\nimport { isPhaserContainer, isPhaserScene } from './utils/phaser-guards'\n// @migration(audit:scene-portal-mount) Root-Container — host.ts: HostCreator(scene) → HostAdapter.create(ctx)\n\n/**\n * Host creator function type - creates a node instance from props\n */\nexport type HostCreator<T extends NodeType> = (\n scene: Phaser.Scene,\n props: NodeProps<T>\n) => NodeInstance<T>\n\n/**\n * Host patcher function type - updates node properties\n */\nexport type HostPatcher<T extends NodeType> = (\n node: NodeInstance<T>,\n prev: NodeProps<T>,\n next: NodeProps<T>\n) => void\n\n/**\n * Node descriptor combining creator and patcher\n */\nexport interface NodeDescriptor<T extends NodeType> {\n create: HostCreator<T>\n patch: HostPatcher<T>\n}\n\n/**\n * Internal registry of node descriptors\n */\ntype NodeRegistry = {\n [K in NodeType]: NodeDescriptor<K>\n}\n\n/**\n * Node registry - maps node types to their descriptors\n * Exported for external registration of custom node types\n */\nexport const nodeRegistry: Partial<NodeRegistry> = {}\n\n/**\n * Registers a node descriptor (creator + patcher) for a custom node type\n * @param type - Node type name\n * @param descriptor - Node descriptor with create and patch functions\n */\nexport function register<T extends NodeType>(type: T, descriptor: NodeDescriptor<T>): void {\n nodeRegistry[type] = descriptor as NodeRegistry[T]\n}\n\n/**\n * Host API - Generic interface for VDOM to manage Phaser nodes\n */\nexport const host = {\n /**\n * Creates a node instance using the registered creator for the given type\n * @param type - Node type name\n * @param props - Node properties\n * @param scene - Phaser scene\n * @returns Created node instance\n * @throws Error if no creator registered for the type\n */\n // @migration(audit:scene-portal-mount) Root-Container — host.create(scene) → HostAdapter.create(type, props, ctx)\n create<T extends NodeType>(type: T, props: NodeProps<T>, scene: Phaser.Scene): NodeInstance<T> {\n const descriptor = nodeRegistry[type] as NodeDescriptor<T> | undefined\n if (!descriptor) {\n throw new Error(`No host descriptor registered for node type \"${String(type)}\"`)\n }\n return descriptor.create(scene, props)\n },\n\n /**\n * Patches node properties with updates using the registered patcher\n * @param type - Node type name\n * @param node - Node to patch\n * @param prev - Previous props\n * @param next - New props\n */\n patch<T extends NodeType>(\n type: T,\n node: NodeInstance<T>,\n prev: NodeProps<T>,\n next: NodeProps<T>\n ): void {\n const descriptor = nodeRegistry[type] as NodeDescriptor<T> | undefined\n if (!descriptor) {\n throw new Error(`No host descriptor registered for node type \"${String(type)}\"`)\n }\n descriptor.patch(node, prev, next)\n },\n\n /**\n * Appends child node to parent container\n * @param parent - Parent container or scene\n * @param child - Child node to append\n */\n append(parent: unknown, child: unknown) {\n // Parent is a Container\n if (isPhaserContainer(parent)) {\n parent.add(child as Phaser.GameObjects.GameObject)\n ;(child as { parent?: unknown }).parent = parent\n }\n // Parent is a Scene\n else if (isPhaserScene(parent)) {\n const scene = parent as Phaser.Scene\n scene.add.existing(child as Phaser.GameObjects.GameObject)\n ;(child as { parent?: unknown }).parent = undefined\n }\n // Fallback: try to add to display list\n else if (parent && typeof parent === 'object' && 'scene' in parent) {\n const gameObject = parent as Phaser.GameObjects.GameObject\n if (gameObject.scene?.children) {\n gameObject.scene.children.add(child as Phaser.GameObjects.GameObject)\n ;(child as { parent?: unknown }).parent = undefined\n }\n }\n },\n\n /**\n * Removes child node from parent and destroys it\n * @param parent - Parent container\n * @param child - Child node to remove\n */\n remove(parent: unknown, child: unknown) {\n const childObj = child as Phaser.GameObjects.GameObject & { scene?: Phaser.Scene | null }\n\n // Check if child still has a scene (not already destroyed)\n if (!childObj.scene) return\n\n // Remove from parent container first\n if (isPhaserContainer(parent)) {\n parent.remove(childObj, false)\n }\n\n ;(childObj as { parent?: unknown }).parent = undefined\n\n // Destroy the child WITHOUT destroying its children (VDOM handles that)\n if (childObj.destroy) {\n childObj.destroy(false)\n }\n },\n\n /**\n * Performs layout update on container (no-op for native Phaser)\n */\n layout() {\n // Native Phaser containers don't have automatic layout\n // This is a no-op but kept for API compatibility\n },\n}\n"],"names":["isPhaserContainer","isPhaserScene"],"mappings":";;;AA6CO,MAAM,eAAsC,CAAA;AAO5C,SAAS,SAA6B,MAAS,YAAqC;AACzF,eAAa,IAAI,IAAI;AACvB;AAKO,MAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlB,OAA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;AACF;;;;"}
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { NodeInstance, NodeProps, NodeType } from './core-types';
|
|
2
|
+
/**
|
|
3
|
+
* Host layer - Generic bridge between VDOM and Phaser GameObjects
|
|
4
|
+
* Provides type-safe creator/patcher pattern for extensible node types
|
|
5
|
+
*/
|
|
6
|
+
import type * as Phaser from 'phaser';
|
|
7
|
+
/**
|
|
8
|
+
* Host creator function type - creates a node instance from props
|
|
9
|
+
*/
|
|
10
|
+
export type HostCreator<T extends NodeType> = (scene: Phaser.Scene, props: NodeProps<T>) => NodeInstance<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Host patcher function type - updates node properties
|
|
13
|
+
*/
|
|
14
|
+
export type HostPatcher<T extends NodeType> = (node: NodeInstance<T>, prev: NodeProps<T>, next: NodeProps<T>) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Node descriptor combining creator and patcher
|
|
17
|
+
*/
|
|
18
|
+
export interface NodeDescriptor<T extends NodeType> {
|
|
19
|
+
create: HostCreator<T>;
|
|
20
|
+
patch: HostPatcher<T>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Internal registry of node descriptors
|
|
24
|
+
*/
|
|
25
|
+
type NodeRegistry = {
|
|
26
|
+
[K in NodeType]: NodeDescriptor<K>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Node registry - maps node types to their descriptors
|
|
30
|
+
* Exported for external registration of custom node types
|
|
31
|
+
*/
|
|
32
|
+
export declare const nodeRegistry: Partial<NodeRegistry>;
|
|
33
|
+
/**
|
|
34
|
+
* Registers a node descriptor (creator + patcher) for a custom node type
|
|
35
|
+
* @param type - Node type name
|
|
36
|
+
* @param descriptor - Node descriptor with create and patch functions
|
|
37
|
+
*/
|
|
38
|
+
export declare function register<T extends NodeType>(type: T, descriptor: NodeDescriptor<T>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Host API - Generic interface for VDOM to manage Phaser nodes
|
|
41
|
+
*/
|
|
42
|
+
export declare const host: {
|
|
43
|
+
/**
|
|
44
|
+
* Creates a node instance using the registered creator for the given type
|
|
45
|
+
* @param type - Node type name
|
|
46
|
+
* @param props - Node properties
|
|
47
|
+
* @param scene - Phaser scene
|
|
48
|
+
* @returns Created node instance
|
|
49
|
+
* @throws Error if no creator registered for the type
|
|
50
|
+
*/
|
|
51
|
+
create<T extends NodeType>(type: T, props: NodeProps<T>, scene: Phaser.Scene): NodeInstance<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Patches node properties with updates using the registered patcher
|
|
54
|
+
* @param type - Node type name
|
|
55
|
+
* @param node - Node to patch
|
|
56
|
+
* @param prev - Previous props
|
|
57
|
+
* @param next - New props
|
|
58
|
+
*/
|
|
59
|
+
patch<T extends NodeType>(type: T, node: NodeInstance<T>, prev: NodeProps<T>, next: NodeProps<T>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Appends child node to parent container
|
|
62
|
+
* @param parent - Parent container or scene
|
|
63
|
+
* @param child - Child node to append
|
|
64
|
+
*/
|
|
65
|
+
append(parent: unknown, child: unknown): void;
|
|
66
|
+
/**
|
|
67
|
+
* Removes child node from parent and destroys it
|
|
68
|
+
* @param parent - Parent container
|
|
69
|
+
* @param child - Child node to remove
|
|
70
|
+
*/
|
|
71
|
+
remove(parent: unknown, child: unknown): void;
|
|
72
|
+
/**
|
|
73
|
+
* Performs layout update on container (no-op for native Phaser)
|
|
74
|
+
*/
|
|
75
|
+
layout(): void;
|
|
76
|
+
};
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA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ACY,OAAO,SAAS,OAAO;IAsBtC;;;;OAIG;mBACY,OAAO,SAAS,OAAO;IAmBtC;;OAEG;;CAKJ,CAAA"}
|
package/dist/host.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isPhaserContainer, isPhaserScene } from "./utils/phaser-guards.js";
|
|
2
|
+
const nodeRegistry = {};
|
|
3
|
+
function register(type, descriptor) {
|
|
4
|
+
nodeRegistry[type] = descriptor;
|
|
5
|
+
}
|
|
6
|
+
const host = {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a node instance using the registered creator for the given type
|
|
9
|
+
* @param type - Node type name
|
|
10
|
+
* @param props - Node properties
|
|
11
|
+
* @param scene - Phaser scene
|
|
12
|
+
* @returns Created node instance
|
|
13
|
+
* @throws Error if no creator registered for the type
|
|
14
|
+
*/
|
|
15
|
+
// @migration(audit:scene-portal-mount) Root-Container — host.create(scene) → HostAdapter.create(type, props, ctx)
|
|
16
|
+
create(type, props, scene) {
|
|
17
|
+
const descriptor = nodeRegistry[type];
|
|
18
|
+
if (!descriptor) {
|
|
19
|
+
throw new Error(`No host descriptor registered for node type "${String(type)}"`);
|
|
20
|
+
}
|
|
21
|
+
return descriptor.create(scene, props);
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Patches node properties with updates using the registered patcher
|
|
25
|
+
* @param type - Node type name
|
|
26
|
+
* @param node - Node to patch
|
|
27
|
+
* @param prev - Previous props
|
|
28
|
+
* @param next - New props
|
|
29
|
+
*/
|
|
30
|
+
patch(type, node, prev, next) {
|
|
31
|
+
const descriptor = nodeRegistry[type];
|
|
32
|
+
if (!descriptor) {
|
|
33
|
+
throw new Error(`No host descriptor registered for node type "${String(type)}"`);
|
|
34
|
+
}
|
|
35
|
+
descriptor.patch(node, prev, next);
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Appends child node to parent container
|
|
39
|
+
* @param parent - Parent container or scene
|
|
40
|
+
* @param child - Child node to append
|
|
41
|
+
*/
|
|
42
|
+
append(parent, child) {
|
|
43
|
+
if (isPhaserContainer(parent)) {
|
|
44
|
+
parent.add(child);
|
|
45
|
+
child.parent = parent;
|
|
46
|
+
} else if (isPhaserScene(parent)) {
|
|
47
|
+
const scene = parent;
|
|
48
|
+
scene.add.existing(child);
|
|
49
|
+
child.parent = void 0;
|
|
50
|
+
} else if (parent && typeof parent === "object" && "scene" in parent) {
|
|
51
|
+
const gameObject = parent;
|
|
52
|
+
if (gameObject.scene?.children) {
|
|
53
|
+
gameObject.scene.children.add(child);
|
|
54
|
+
child.parent = void 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Removes child node from parent and destroys it
|
|
60
|
+
* @param parent - Parent container
|
|
61
|
+
* @param child - Child node to remove
|
|
62
|
+
*/
|
|
63
|
+
remove(parent, child) {
|
|
64
|
+
const childObj = child;
|
|
65
|
+
if (!childObj.scene) return;
|
|
66
|
+
if (isPhaserContainer(parent)) {
|
|
67
|
+
parent.remove(childObj, false);
|
|
68
|
+
}
|
|
69
|
+
childObj.parent = void 0;
|
|
70
|
+
if (childObj.destroy) {
|
|
71
|
+
childObj.destroy(false);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Performs layout update on container (no-op for native Phaser)
|
|
76
|
+
*/
|
|
77
|
+
layout() {
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export {
|
|
81
|
+
host,
|
|
82
|
+
nodeRegistry,
|
|
83
|
+
register
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=host.js.map
|