@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":"dom-input-manager.js","sources":["../../src/utils/dom-input-manager.ts"],"sourcesContent":["/**\n * DOM input element manager for text input overlay\n * Handles creation, positioning, and lifecycle of DOM input elements\n */\nimport type * as Phaser from 'phaser'\n\n/**\n * Configuration for DOM input element\n */\nexport interface DOMInputConfig {\n /** Input type (text, password, email, etc.) */\n type?: string\n /** Placeholder text */\n placeholder?: string\n /** Initial value */\n value?: string\n /** Whether input is disabled */\n disabled?: boolean\n /** Maximum length of input */\n maxLength?: number\n /** Autocomplete behavior */\n autocomplete?: string\n /** Autocorrect behavior (Safari) */\n autocorrect?: string\n /** Autocapitalize behavior (mobile) */\n autocapitalize?: string\n /** Spellcheck behavior */\n spellcheck?: boolean\n /** CSS styles to apply */\n styles?: Partial<CSSStyleDeclaration>\n /** Input event callback */\n onInput?: (value: string, event: Event) => void\n /** Keyboard event callbacks */\n onKeyDown?: (event: KeyboardEvent) => void\n onKeyUp?: (event: KeyboardEvent) => void\n /** Focus event callbacks */\n onFocus?: (event: FocusEvent) => void\n onBlur?: (event: FocusEvent) => void\n}\n\n/**\n * DOM input element wrapper with automatic positioning\n */\nexport class DOMInputElement {\n private input: HTMLInputElement\n private container: Phaser.GameObjects.Container\n private scene: Phaser.Scene\n private scrollHandler: () => void\n private resizeHandler: () => void\n private throttledScrollHandler: () => void\n private throttledResizeHandler: () => void\n private intersectionObserver: IntersectionObserver | null = null\n private isDestroyed = false\n private lastValues = { left: 0, top: 0, width: 0, height: 0 }\n private counter = 0\n private scrollThrottleTimeout: number | null = null\n private resizeThrottleTimeout: number | null = null\n\n constructor(container: Phaser.GameObjects.Container, config: DOMInputConfig = {}) {\n this.container = container\n this.scene = container.scene\n\n // Create input element\n this.input = document.createElement('input')\n this.input.type = config.type ?? 'text'\n if (config.placeholder) this.input.placeholder = config.placeholder\n if (config.value) this.input.value = config.value\n if (config.disabled) this.input.disabled = config.disabled\n if (config.maxLength) this.input.maxLength = config.maxLength\n if (config.autocomplete) this.input.setAttribute('autocomplete', config.autocomplete)\n if (config.autocorrect) this.input.setAttribute('autocorrect', config.autocorrect)\n if (config.autocapitalize) this.input.setAttribute('autocapitalize', config.autocapitalize)\n if (config.spellcheck !== undefined)\n this.input.setAttribute('spellcheck', config.spellcheck.toString())\n\n // Apply default styles\n this.applyDefaultStyles()\n\n // Apply custom styles\n if (config.styles) {\n Object.assign(this.input.style, config.styles)\n }\n\n // Add to DOM - use document.body for absolute positioning\n document.body.appendChild(this.input)\n\n // Setup event listeners\n if (config.onInput) {\n this.input.addEventListener('input', (e) => {\n config.onInput?.(this.input.value, e)\n })\n }\n\n if (config.onKeyDown) {\n this.input.addEventListener('keydown', config.onKeyDown)\n }\n\n if (config.onKeyUp) {\n this.input.addEventListener('keyup', config.onKeyUp)\n }\n\n if (config.onFocus) {\n this.input.addEventListener('focus', (e) => {\n config.onFocus?.(e)\n })\n }\n\n if (config.onBlur) {\n this.input.addEventListener('blur', (e) => {\n config.onBlur?.(e)\n })\n }\n\n // Initial position update\n this.updatePosition()\n\n // Bind handlers for page scrolling and resizing\n this.scrollHandler = this.updatePosition.bind(this)\n this.resizeHandler = this.updatePosition.bind(this)\n\n // Throttled handlers to limit update frequency\n this.throttledScrollHandler = this.throttle(this.scrollHandler, 20) // ~50fps max\n this.throttledResizeHandler = this.throttle(this.resizeHandler, 20) // ~50fps max\n\n // Setup event listeners immediately (always active)\n // Use capture phase to catch scroll events from any scrollable ancestor\n document.addEventListener('scroll', this.throttledScrollHandler, {\n passive: true,\n capture: true,\n })\n window.addEventListener('resize', this.throttledResizeHandler, { passive: true })\n\n // Setup IntersectionObserver to detect when canvas moves in viewport\n this.setupIntersectionObserver()\n\n // Cleanup on container destroy\n this.container.once('destroy', () => {\n this.destroy()\n })\n\n // Cleanup on scene shutdown\n this.scene.events.once('shutdown', () => {\n this.destroy()\n })\n }\n\n /**\n * Setup IntersectionObserver to detect canvas position changes\n */\n private setupIntersectionObserver(): void {\n const canvas = this.scene.game.canvas\n\n this.intersectionObserver = new IntersectionObserver(\n () => {\n // Canvas moved in viewport, update position\n this.updatePosition()\n },\n {\n threshold: [0, 0.1, 0.5, 0.9, 1.0], // Trigger on various visibility changes\n }\n )\n\n this.intersectionObserver.observe(canvas)\n }\n\n /**\n * Throttle function to limit call frequency\n * @param func - Function to throttle\n * @param delay - Minimum delay between calls in ms\n * @returns Throttled function\n */\n private throttle(func: () => void, delay: number): () => void {\n let timeoutId: number | null = null\n return () => {\n if (timeoutId !== null) return\n timeoutId = window.setTimeout(() => {\n func()\n timeoutId = null\n }, delay)\n }\n }\n\n /**\n * Apply default styles to input element\n */\n private applyDefaultStyles(): void {\n Object.assign(this.input.style, {\n position: 'absolute',\n pointerEvents: 'auto',\n boxSizing: 'border-box',\n fontFamily: 'Arial, sans-serif',\n fontSize: '16px',\n padding: '0px',\n margin: '0px',\n border: 'none',\n borderRadius: '0px',\n backgroundColor: 'transparent',\n color: 'transparent',\n outline: 'none',\n caretColor: 'transparent',\n } as Partial<CSSStyleDeclaration>)\n\n // Inject CSS to disable selection highlighting\n const styleId = 'phaserjsx-input-no-selection'\n if (!document.getElementById(styleId)) {\n const style = document.createElement('style')\n style.id = styleId\n style.textContent = `\n input[type=\"text\"]::selection,\n input[type=\"password\"]::selection,\n input[type=\"email\"]::selection {\n background: transparent !important;\n color: transparent !important;\n }\n `\n document.head.appendChild(style)\n }\n }\n\n /**\n * Update input element position to match Phaser container\n */\n private updatePosition(): void {\n if (this.isDestroyed || !this.container.scene) return\n\n const canvas = this.scene.game.canvas\n const canvasRect = canvas.getBoundingClientRect()\n\n // Get container world position\n const worldTransform = this.container.getWorldTransformMatrix()\n const worldX = worldTransform.tx\n const worldY = worldTransform.ty\n\n // Get container dimensions - prefer actual computed size over layoutProps\n // This ensures minHeight, maxHeight, and other constraints are respected\n const containerWidth = this.container.width ?? 200\n const containerHeight = this.container.height ?? 40\n\n // Calculate position relative to canvas\n const scale = this.scene.game.scale\n const zoom = this.scene.cameras.main.zoom\n\n // Calculate position and size with proper scaling\n const left = Math.round(canvasRect.left + worldX * zoom * scale.displayScale.x)\n const top = Math.round(canvasRect.top + worldY * zoom * scale.displayScale.y)\n const width = Math.round(containerWidth * zoom * scale.displayScale.x)\n const height = Math.round(containerHeight * zoom * scale.displayScale.y)\n this.counter++\n\n // apply only if changed to minimize layout thrashing\n if (\n this.lastValues.left === left &&\n this.lastValues.top === top &&\n this.lastValues.width === width &&\n this.lastValues.height === height\n ) {\n return\n }\n this.lastValues = { left, top, width, height }\n\n /* // Debug output for testing purposes\n console.log('[DOMInputElement] Updating position', {\n counter: this.counter,\n left,\n top,\n width,\n height,\n })\n */\n\n // Apply position and size\n this.input.style.left = `${left}px`\n this.input.style.top = `${top}px`\n this.input.style.width = `${width}px`\n this.input.style.height = `${height}px`\n }\n\n /**\n * Get the DOM input element\n */\n getElement(): HTMLInputElement {\n return this.input\n }\n\n /**\n * Set input value\n */\n setValue(value: string): void {\n if (!this.isDestroyed) {\n this.input.value = value\n }\n }\n\n /**\n * Get input value\n */\n getValue(): string {\n return this.isDestroyed ? '' : this.input.value\n }\n\n /**\n * Focus the input\n */\n focus(): void {\n if (!this.isDestroyed) {\n this.input.focus()\n }\n }\n\n /**\n * Blur the input\n */\n blur(): void {\n if (!this.isDestroyed) {\n this.input.blur()\n }\n }\n\n /**\n * Set disabled state\n */\n setDisabled(disabled: boolean): void {\n if (!this.isDestroyed) {\n this.input.disabled = disabled\n }\n }\n\n /**\n * Set placeholder\n */\n setPlaceholder(placeholder: string): void {\n if (!this.isDestroyed) {\n this.input.placeholder = placeholder\n }\n }\n\n /**\n * Update styles\n */\n setStyles(styles: Partial<CSSStyleDeclaration>): void {\n if (!this.isDestroyed) {\n Object.assign(this.input.style, styles)\n }\n }\n\n /**\n * Destroy the input element and cleanup\n */\n destroy(): void {\n if (this.isDestroyed) return\n this.isDestroyed = true\n\n // Clear any pending throttle timeouts\n if (this.scrollThrottleTimeout !== null) {\n clearTimeout(this.scrollThrottleTimeout)\n }\n if (this.resizeThrottleTimeout !== null) {\n clearTimeout(this.resizeThrottleTimeout)\n }\n\n // Disconnect IntersectionObserver\n if (this.intersectionObserver) {\n this.intersectionObserver.disconnect()\n this.intersectionObserver = null\n }\n\n // Remove event listeners\n document.removeEventListener('scroll', this.throttledScrollHandler, { capture: true })\n window.removeEventListener('resize', this.throttledResizeHandler)\n\n // Remove from DOM\n if (this.input.parentElement) {\n this.input.parentElement.removeChild(this.input)\n }\n }\n}\n"],"names":[],"mappings":"AA2CO,MAAM,gBAAgB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,uBAAoD;AAAA,EACpD,cAAc;AAAA,EACd,aAAa,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,EAAA;AAAA,EAClD,UAAU;AAAA,EACV,wBAAuC;AAAA,EACvC,wBAAuC;AAAA,EAE/C,YAAY,WAAyC,SAAyB,IAAI;AAChF,SAAK,YAAY;AACjB,SAAK,QAAQ,UAAU;AAGvB,SAAK,QAAQ,SAAS,cAAc,OAAO;AAC3C,SAAK,MAAM,OAAO,OAAO,QAAQ;AACjC,QAAI,OAAO,YAAa,MAAK,MAAM,cAAc,OAAO;AACxD,QAAI,OAAO,MAAO,MAAK,MAAM,QAAQ,OAAO;AAC5C,QAAI,OAAO,SAAU,MAAK,MAAM,WAAW,OAAO;AAClD,QAAI,OAAO,UAAW,MAAK,MAAM,YAAY,OAAO;AACpD,QAAI,OAAO,aAAc,MAAK,MAAM,aAAa,gBAAgB,OAAO,YAAY;AACpF,QAAI,OAAO,YAAa,MAAK,MAAM,aAAa,eAAe,OAAO,WAAW;AACjF,QAAI,OAAO,eAAgB,MAAK,MAAM,aAAa,kBAAkB,OAAO,cAAc;AAC1F,QAAI,OAAO,eAAe;AACxB,WAAK,MAAM,aAAa,cAAc,OAAO,WAAW,UAAU;AAGpE,SAAK,mBAAA;AAGL,QAAI,OAAO,QAAQ;AACjB,aAAO,OAAO,KAAK,MAAM,OAAO,OAA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AAAA,EAKA,OAAa;AACX,QAAI,CAAC,KAAK,aAAa;AACrB,WAAK,MAAM,KAAA;AAAA,IACb;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,YAAY,UAAyB;AACnC,QAAI,CAAC,KAAK,aAAa;AACrB,WAAK,MAAM,WAAW;AAAA,IACxB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,aAA2B;AACxC,QAAI,CAAC,KAAK,aAAa;AACrB,WAAK,MAAM,cAAc;AAAA,IAC3B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,QAA4C;AACpD,QAAI,CAAC,KAAK,aAAa;AACrB,aAAO,OAAO,KAAK,MAAM,OAAO,MAAM;AAAA,IACxC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgB;AACd,QAAI,KAAK,YAAa;AACtB,SAAK,cAAc;AAGnB,QAAI,KAAK,0BAA0B,MAAM;AACvC,mBAAa,KAAK,qBAAqB;AAAA,IACzC;AACA,QAAI,KAAK,0BAA0B,MAAM;AACvC,mBAAa,KAAK,qBAAqB;AAAA,IACzC;AAGA,QAAI,KAAK,sBAAsB;AAC7B,WAAK,qBAAqB,WAAA;AAC1B,WAAK,uBAAuB;AAAA,IAC9B;AAGA,aAAS,oBAAoB,UAAU,KAAK,wBAAwB,EAAE,SAAS,MAAM;AACrF,WAAO,oBAAoB,UAAU,KAAK,sBAAsB;AAGhE,QAAI,KAAK,MAAM,eAAe;AAC5B,WAAK,MAAM,cAAc,YAAY,KAAK,KAAK;AAAA,IACjD;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const index = require("../_virtual/index.cjs");
|
|
3
|
+
const _interopNamespaceDefaultOnly = (e) => Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: "Module" }));
|
|
4
|
+
const index__namespace = /* @__PURE__ */ _interopNamespaceDefaultOnly(index);
|
|
5
|
+
const equal = typeof index__namespace === "function" ? index__namespace : index;
|
|
6
|
+
module.exports = equal;
|
|
7
|
+
//# sourceMappingURL=fast-deep-equal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-deep-equal.cjs","sources":["../../src/utils/fast-deep-equal.ts"],"sourcesContent":["import * as equalImport from 'fast-deep-equal'\n\ntype EqualFn = (a: unknown, b: unknown) => boolean\n\n// Normalize the CJS export shape for ESM usage.\nconst equal =\n typeof equalImport === 'function'\n ? (equalImport as unknown as EqualFn)\n : (equalImport as { default: EqualFn }).default\n\nexport default equal\n"],"names":["equalImport","equalImport.default"],"mappings":";;;;AAKA,MAAM,QACJ,OAAOA,qBAAgB,aAClBA,mBACAC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-deep-equal.d.ts","sourceRoot":"","sources":["../../src/utils/fast-deep-equal.ts"],"names":[],"mappings":"AAEA,KAAK,OAAO,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,KAAK,OAAO,CAAA;AAGlD,QAAA,MAAM,KAAK,SAGwC,CAAA;AAEnD,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-deep-equal.js","sources":["../../src/utils/fast-deep-equal.ts"],"sourcesContent":["import * as equalImport from 'fast-deep-equal'\n\ntype EqualFn = (a: unknown, b: unknown) => boolean\n\n// Normalize the CJS export shape for ESM usage.\nconst equal =\n typeof equalImport === 'function'\n ? (equalImport as unknown as EqualFn)\n : (equalImport as { default: EqualFn }).default\n\nexport default equal\n"],"names":["equalImport","equalImport.default"],"mappings":";;AAKA,MAAM,QACJ,OAAOA,UAAgB,aAClBA,QACAC;"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const sceneTextureEntries = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
let nextDerivedTextureId = 0;
|
|
5
|
+
function getSceneEntries(scene) {
|
|
6
|
+
let entries = sceneTextureEntries.get(scene);
|
|
7
|
+
if (!entries) {
|
|
8
|
+
entries = /* @__PURE__ */ new Map();
|
|
9
|
+
sceneTextureEntries.set(scene, entries);
|
|
10
|
+
}
|
|
11
|
+
return entries;
|
|
12
|
+
}
|
|
13
|
+
function clampRectToFrame(frame, sourceRect) {
|
|
14
|
+
const x = Math.max(0, sourceRect.x);
|
|
15
|
+
const y = Math.max(0, sourceRect.y);
|
|
16
|
+
const w = Math.max(0, Math.min(sourceRect.w, frame.cutWidth - x));
|
|
17
|
+
const h = Math.max(0, Math.min(sourceRect.h, frame.cutHeight - y));
|
|
18
|
+
return {
|
|
19
|
+
sx: frame.cutX + x,
|
|
20
|
+
sy: frame.cutY + y,
|
|
21
|
+
sw: w,
|
|
22
|
+
sh: h
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function resolveFrame(scene, texture, frame) {
|
|
26
|
+
return scene.textures.getFrame(texture, frame);
|
|
27
|
+
}
|
|
28
|
+
function createDerivedTexture(scene, textureKey, frame, sourceRect) {
|
|
29
|
+
const { sx, sy, sw, sh } = clampRectToFrame(frame, sourceRect);
|
|
30
|
+
if (sw <= 0 || sh <= 0) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const sourceImage = frame.texture.source?.[frame.sourceIndex ?? 0]?.image ?? frame.texture.source?.[0]?.image;
|
|
34
|
+
if (!sourceImage) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const canvas = document.createElement("canvas");
|
|
38
|
+
canvas.width = sw;
|
|
39
|
+
canvas.height = sh;
|
|
40
|
+
const ctx = canvas.getContext("2d");
|
|
41
|
+
if (!ctx) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
ctx.clearRect(0, 0, sw, sh);
|
|
45
|
+
ctx.drawImage(sourceImage, sx, sy, sw, sh, 0, 0, sw, sh);
|
|
46
|
+
if (scene.textures.exists(textureKey)) {
|
|
47
|
+
scene.textures.remove(textureKey);
|
|
48
|
+
}
|
|
49
|
+
scene.textures.addCanvas(textureKey, canvas);
|
|
50
|
+
const texture = scene.textures.get(textureKey);
|
|
51
|
+
texture?.source?.[0]?.update();
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
function getImageSubTextureCacheKey(texture, frame, sourceRect) {
|
|
55
|
+
return `${texture}::${frame ?? "__BASE"}::${sourceRect.x},${sourceRect.y},${sourceRect.w},${sourceRect.h}`;
|
|
56
|
+
}
|
|
57
|
+
function retainImageSubTexture(scene, texture, frame, sourceRect) {
|
|
58
|
+
if (!sourceRect) {
|
|
59
|
+
return { texture, frame };
|
|
60
|
+
}
|
|
61
|
+
const resolvedFrame = resolveFrame(scene, texture, frame);
|
|
62
|
+
if (!resolvedFrame) {
|
|
63
|
+
return { texture, frame };
|
|
64
|
+
}
|
|
65
|
+
const cacheKey = getImageSubTextureCacheKey(texture, frame, sourceRect);
|
|
66
|
+
const entries = getSceneEntries(scene);
|
|
67
|
+
const existing = entries.get(cacheKey);
|
|
68
|
+
if (existing) {
|
|
69
|
+
existing.refCount += 1;
|
|
70
|
+
return { texture: existing.textureKey, cacheKey };
|
|
71
|
+
}
|
|
72
|
+
const textureKey = `__phaserjsx_img_subtex_${nextDerivedTextureId++}`;
|
|
73
|
+
const created = createDerivedTexture(scene, textureKey, resolvedFrame, sourceRect);
|
|
74
|
+
if (!created) {
|
|
75
|
+
return { texture, frame };
|
|
76
|
+
}
|
|
77
|
+
entries.set(cacheKey, { textureKey, refCount: 1 });
|
|
78
|
+
return { texture: textureKey, cacheKey };
|
|
79
|
+
}
|
|
80
|
+
function releaseImageSubTexture(scene, cacheKey) {
|
|
81
|
+
if (!cacheKey) return;
|
|
82
|
+
const entries = sceneTextureEntries.get(scene);
|
|
83
|
+
if (!entries) return;
|
|
84
|
+
const entry = entries.get(cacheKey);
|
|
85
|
+
if (!entry) return;
|
|
86
|
+
entry.refCount -= 1;
|
|
87
|
+
if (entry.refCount > 0) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (scene.textures.exists(entry.textureKey)) {
|
|
91
|
+
scene.textures.remove(entry.textureKey);
|
|
92
|
+
}
|
|
93
|
+
entries.delete(cacheKey);
|
|
94
|
+
}
|
|
95
|
+
exports.getImageSubTextureCacheKey = getImageSubTextureCacheKey;
|
|
96
|
+
exports.releaseImageSubTexture = releaseImageSubTexture;
|
|
97
|
+
exports.retainImageSubTexture = retainImageSubTexture;
|
|
98
|
+
//# sourceMappingURL=image-subtexture-registry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-subtexture-registry.cjs","sources":["../../src/utils/image-subtexture-registry.ts"],"sourcesContent":["import type * as Phaser from 'phaser'\n\ninterface SourceRect {\n x: number\n y: number\n w: number\n h: number\n}\n\ninterface DerivedTextureEntry {\n textureKey: string\n refCount: number\n}\n\ninterface DerivedTextureSource {\n texture: string\n frame?: string | number | undefined\n cacheKey?: string | undefined\n}\n\nconst sceneTextureEntries = new WeakMap<Phaser.Scene, Map<string, DerivedTextureEntry>>()\nlet nextDerivedTextureId = 0\n\nfunction getSceneEntries(scene: Phaser.Scene): Map<string, DerivedTextureEntry> {\n let entries = sceneTextureEntries.get(scene)\n if (!entries) {\n entries = new Map()\n sceneTextureEntries.set(scene, entries)\n }\n return entries\n}\n\nfunction clampRectToFrame(\n frame: Phaser.Textures.Frame,\n sourceRect: SourceRect\n): { sx: number; sy: number; sw: number; sh: number } {\n const x = Math.max(0, sourceRect.x)\n const y = Math.max(0, sourceRect.y)\n const w = Math.max(0, Math.min(sourceRect.w, frame.cutWidth - x))\n const h = Math.max(0, Math.min(sourceRect.h, frame.cutHeight - y))\n\n return {\n sx: frame.cutX + x,\n sy: frame.cutY + y,\n sw: w,\n sh: h,\n }\n}\n\nfunction resolveFrame(\n scene: Phaser.Scene,\n texture: string,\n frame?: string | number | undefined\n): Phaser.Textures.Frame | null {\n return scene.textures.getFrame(texture, frame as string | number | undefined)\n}\n\nfunction createDerivedTexture(\n scene: Phaser.Scene,\n textureKey: string,\n frame: Phaser.Textures.Frame,\n sourceRect: SourceRect\n): boolean {\n const { sx, sy, sw, sh } = clampRectToFrame(frame, sourceRect)\n if (sw <= 0 || sh <= 0) {\n return false\n }\n\n const sourceImage = (frame.texture.source?.[frame.sourceIndex ?? 0]?.image ??\n frame.texture.source?.[0]?.image) as CanvasImageSource | undefined\n if (!sourceImage) {\n return false\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = sw\n canvas.height = sh\n const ctx = canvas.getContext('2d')\n if (!ctx) {\n return false\n }\n\n ctx.clearRect(0, 0, sw, sh)\n ctx.drawImage(sourceImage, sx, sy, sw, sh, 0, 0, sw, sh)\n\n if (scene.textures.exists(textureKey)) {\n scene.textures.remove(textureKey)\n }\n\n scene.textures.addCanvas(textureKey, canvas)\n const texture = scene.textures.get(textureKey)\n texture?.source?.[0]?.update()\n return true\n}\n\nexport function getImageSubTextureCacheKey(\n texture: string,\n frame: string | number | undefined,\n sourceRect: SourceRect\n): string {\n return `${texture}::${frame ?? '__BASE'}::${sourceRect.x},${sourceRect.y},${sourceRect.w},${sourceRect.h}`\n}\n\nexport function retainImageSubTexture(\n scene: Phaser.Scene,\n texture: string,\n frame: string | number | undefined,\n sourceRect: SourceRect | undefined\n): DerivedTextureSource {\n if (!sourceRect) {\n return { texture, frame }\n }\n\n const resolvedFrame = resolveFrame(scene, texture, frame)\n if (!resolvedFrame) {\n return { texture, frame }\n }\n\n const cacheKey = getImageSubTextureCacheKey(texture, frame, sourceRect)\n const entries = getSceneEntries(scene)\n const existing = entries.get(cacheKey)\n\n if (existing) {\n existing.refCount += 1\n return { texture: existing.textureKey, cacheKey }\n }\n\n const textureKey = `__phaserjsx_img_subtex_${nextDerivedTextureId++}`\n const created = createDerivedTexture(scene, textureKey, resolvedFrame, sourceRect)\n if (!created) {\n return { texture, frame }\n }\n\n entries.set(cacheKey, { textureKey, refCount: 1 })\n return { texture: textureKey, cacheKey }\n}\n\nexport function releaseImageSubTexture(scene: Phaser.Scene, cacheKey: string | undefined): void {\n if (!cacheKey) return\n\n const entries = sceneTextureEntries.get(scene)\n if (!entries) return\n\n const entry = entries.get(cacheKey)\n if (!entry) return\n\n entry.refCount -= 1\n if (entry.refCount > 0) {\n return\n }\n\n if (scene.textures.exists(entry.textureKey)) {\n scene.textures.remove(entry.textureKey)\n }\n entries.delete(cacheKey)\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,0CAA0B,QAAA;AAChC,IAAI,uBAAuB;AAE3B,SAAS,gBAAgB,OAAuD;AAC9E,MAAI,UAAU,oBAAoB,IAAI,KAAK;AAC3C,MAAI,CAAC,SAAS;AACZ,kCAAc,IAAA;AACd,wBAAoB,IAAI,OAAO,OAAO;AAAA,EACxC;AACA,SAAO;AACT;AAEA,SAAS,iBACP,OACA,YACoD;AACpD,QAAM,IAAI,KAAK,IAAI,GAAG,WAAW,CAAC;AAClC,QAAM,IAAI,KAAK,IAAI,GAAG,WAAW,CAAC;AAClC,QAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,GAAG,MAAM,WAAW,CAAC,CAAC;AAChE,QAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,GAAG,MAAM,YAAY,CAAC,CAAC;AAEjE,SAAO;AAAA,IACL,IAAI,MAAM,OAAO;AAAA,IACjB,IAAI,MAAM,OAAO;AAAA,IACjB,IAAI;AAAA,IACJ,IAAI;AAAA,EAAA;AAER;AAEA,SAAS,aACP,OACA,SACA,OAC8B;AAC9B,SAAO,MAAM,SAAS,SAAS,SAAS,KAAoC;AAC9E;AAEA,SAAS,qBACP,OACA,YACA,OACA,YACS;AACT,QAAM,EAAE,IAAI,IAAI,IAAI,OAAO,iBAAiB,OAAO,UAAU;AAC7D,MAAI,MAAM,KAAK,MAAM,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,c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B;AACnE,QAAM,UAAU,qBAAqB,OAAO,YAAY,eAAe,UAAU;AACjF,MAAI,CAAC,SAAS;AACZ,WAAO,EAAE,SAAS,MAAA;AAAA,EACpB;AAEA,UAAQ,IAAI,UAAU,EAAE,YAAY,UAAU,GAAG;AACjD,SAAO,EAAE,SAAS,YAAY,SAAA;AAChC;AAEO,SAAS,uBAAuB,OAAqB,UAAoC;AAC9F,MAAI,CAAC,SAAU;AAEf,QAAM,UAAU,oBAAoB,IAAI,KAAK;AAC7C,MAAI,CAAC,QAAS;AAEd,QAAM,QAAQ,QAAQ,IAAI,QAAQ;AAClC,MAAI,CAAC,MAAO;AAEZ,QAAM,YAAY;AAClB,MAAI,MAAM,WAAW,GAAG;AACtB;AAAA,EACF;AAEA,MAAI,MAAM,SAAS,OAAO,MAAM,UAAU,GAAG;AAC3C,UAAM,SAAS,OAAO,MAAM,UAAU;AAAA,EACxC;AACA,UAAQ,OAAO,QAAQ;AACzB;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as Phaser from 'phaser';
|
|
2
|
+
interface SourceRect {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
}
|
|
8
|
+
interface DerivedTextureSource {
|
|
9
|
+
texture: string;
|
|
10
|
+
frame?: string | number | undefined;
|
|
11
|
+
cacheKey?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function getImageSubTextureCacheKey(texture: string, frame: string | number | undefined, sourceRect: SourceRect): string;
|
|
14
|
+
export declare function retainImageSubTexture(scene: Phaser.Scene, texture: string, frame: string | number | undefined, sourceRect: SourceRect | undefined): DerivedTextureSource;
|
|
15
|
+
export declare function releaseImageSubTexture(scene: Phaser.Scene, cacheKey: string | undefined): void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=image-subtexture-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-subtexture-registry.d.ts","sourceRoot":"","sources":["../../src/utils/image-subtexture-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAA;AAErC,UAAU,UAAU;IAClB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAOD,UAAU,oBAAoB;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B;AA6ED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAClC,UAAU,EAAE,UAAU,GACrB,MAAM,CAER;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAClC,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,oBAAoB,CA2BtB;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAkB9F"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const sceneTextureEntries = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
let nextDerivedTextureId = 0;
|
|
3
|
+
function getSceneEntries(scene) {
|
|
4
|
+
let entries = sceneTextureEntries.get(scene);
|
|
5
|
+
if (!entries) {
|
|
6
|
+
entries = /* @__PURE__ */ new Map();
|
|
7
|
+
sceneTextureEntries.set(scene, entries);
|
|
8
|
+
}
|
|
9
|
+
return entries;
|
|
10
|
+
}
|
|
11
|
+
function clampRectToFrame(frame, sourceRect) {
|
|
12
|
+
const x = Math.max(0, sourceRect.x);
|
|
13
|
+
const y = Math.max(0, sourceRect.y);
|
|
14
|
+
const w = Math.max(0, Math.min(sourceRect.w, frame.cutWidth - x));
|
|
15
|
+
const h = Math.max(0, Math.min(sourceRect.h, frame.cutHeight - y));
|
|
16
|
+
return {
|
|
17
|
+
sx: frame.cutX + x,
|
|
18
|
+
sy: frame.cutY + y,
|
|
19
|
+
sw: w,
|
|
20
|
+
sh: h
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function resolveFrame(scene, texture, frame) {
|
|
24
|
+
return scene.textures.getFrame(texture, frame);
|
|
25
|
+
}
|
|
26
|
+
function createDerivedTexture(scene, textureKey, frame, sourceRect) {
|
|
27
|
+
const { sx, sy, sw, sh } = clampRectToFrame(frame, sourceRect);
|
|
28
|
+
if (sw <= 0 || sh <= 0) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const sourceImage = frame.texture.source?.[frame.sourceIndex ?? 0]?.image ?? frame.texture.source?.[0]?.image;
|
|
32
|
+
if (!sourceImage) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const canvas = document.createElement("canvas");
|
|
36
|
+
canvas.width = sw;
|
|
37
|
+
canvas.height = sh;
|
|
38
|
+
const ctx = canvas.getContext("2d");
|
|
39
|
+
if (!ctx) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
ctx.clearRect(0, 0, sw, sh);
|
|
43
|
+
ctx.drawImage(sourceImage, sx, sy, sw, sh, 0, 0, sw, sh);
|
|
44
|
+
if (scene.textures.exists(textureKey)) {
|
|
45
|
+
scene.textures.remove(textureKey);
|
|
46
|
+
}
|
|
47
|
+
scene.textures.addCanvas(textureKey, canvas);
|
|
48
|
+
const texture = scene.textures.get(textureKey);
|
|
49
|
+
texture?.source?.[0]?.update();
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
function getImageSubTextureCacheKey(texture, frame, sourceRect) {
|
|
53
|
+
return `${texture}::${frame ?? "__BASE"}::${sourceRect.x},${sourceRect.y},${sourceRect.w},${sourceRect.h}`;
|
|
54
|
+
}
|
|
55
|
+
function retainImageSubTexture(scene, texture, frame, sourceRect) {
|
|
56
|
+
if (!sourceRect) {
|
|
57
|
+
return { texture, frame };
|
|
58
|
+
}
|
|
59
|
+
const resolvedFrame = resolveFrame(scene, texture, frame);
|
|
60
|
+
if (!resolvedFrame) {
|
|
61
|
+
return { texture, frame };
|
|
62
|
+
}
|
|
63
|
+
const cacheKey = getImageSubTextureCacheKey(texture, frame, sourceRect);
|
|
64
|
+
const entries = getSceneEntries(scene);
|
|
65
|
+
const existing = entries.get(cacheKey);
|
|
66
|
+
if (existing) {
|
|
67
|
+
existing.refCount += 1;
|
|
68
|
+
return { texture: existing.textureKey, cacheKey };
|
|
69
|
+
}
|
|
70
|
+
const textureKey = `__phaserjsx_img_subtex_${nextDerivedTextureId++}`;
|
|
71
|
+
const created = createDerivedTexture(scene, textureKey, resolvedFrame, sourceRect);
|
|
72
|
+
if (!created) {
|
|
73
|
+
return { texture, frame };
|
|
74
|
+
}
|
|
75
|
+
entries.set(cacheKey, { textureKey, refCount: 1 });
|
|
76
|
+
return { texture: textureKey, cacheKey };
|
|
77
|
+
}
|
|
78
|
+
function releaseImageSubTexture(scene, cacheKey) {
|
|
79
|
+
if (!cacheKey) return;
|
|
80
|
+
const entries = sceneTextureEntries.get(scene);
|
|
81
|
+
if (!entries) return;
|
|
82
|
+
const entry = entries.get(cacheKey);
|
|
83
|
+
if (!entry) return;
|
|
84
|
+
entry.refCount -= 1;
|
|
85
|
+
if (entry.refCount > 0) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (scene.textures.exists(entry.textureKey)) {
|
|
89
|
+
scene.textures.remove(entry.textureKey);
|
|
90
|
+
}
|
|
91
|
+
entries.delete(cacheKey);
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
getImageSubTextureCacheKey,
|
|
95
|
+
releaseImageSubTexture,
|
|
96
|
+
retainImageSubTexture
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=image-subtexture-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-subtexture-registry.js","sources":["../../src/utils/image-subtexture-registry.ts"],"sourcesContent":["import type * as Phaser from 'phaser'\n\ninterface SourceRect {\n x: number\n y: number\n w: number\n h: number\n}\n\ninterface DerivedTextureEntry {\n textureKey: string\n refCount: number\n}\n\ninterface DerivedTextureSource {\n texture: string\n frame?: string | number | undefined\n cacheKey?: string | undefined\n}\n\nconst sceneTextureEntries = new WeakMap<Phaser.Scene, Map<string, DerivedTextureEntry>>()\nlet nextDerivedTextureId = 0\n\nfunction getSceneEntries(scene: Phaser.Scene): Map<string, DerivedTextureEntry> {\n let entries = sceneTextureEntries.get(scene)\n if (!entries) {\n entries = new Map()\n sceneTextureEntries.set(scene, entries)\n }\n return entries\n}\n\nfunction clampRectToFrame(\n frame: Phaser.Textures.Frame,\n sourceRect: SourceRect\n): { sx: number; sy: number; sw: number; sh: number } {\n const x = Math.max(0, sourceRect.x)\n const y = Math.max(0, sourceRect.y)\n const w = Math.max(0, Math.min(sourceRect.w, frame.cutWidth - x))\n const h = Math.max(0, Math.min(sourceRect.h, frame.cutHeight - y))\n\n return {\n sx: frame.cutX + x,\n sy: frame.cutY + y,\n sw: w,\n sh: h,\n }\n}\n\nfunction resolveFrame(\n scene: Phaser.Scene,\n texture: string,\n frame?: string | number | undefined\n): Phaser.Textures.Frame | null {\n return scene.textures.getFrame(texture, frame as string | number | undefined)\n}\n\nfunction createDerivedTexture(\n scene: Phaser.Scene,\n textureKey: string,\n frame: Phaser.Textures.Frame,\n sourceRect: SourceRect\n): boolean {\n const { sx, sy, sw, sh } = clampRectToFrame(frame, sourceRect)\n if (sw <= 0 || sh <= 0) {\n return false\n }\n\n const sourceImage = (frame.texture.source?.[frame.sourceIndex ?? 0]?.image ??\n frame.texture.source?.[0]?.image) as CanvasImageSource | undefined\n if (!sourceImage) {\n return false\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = sw\n canvas.height = sh\n const ctx = canvas.getContext('2d')\n if (!ctx) {\n return false\n }\n\n ctx.clearRect(0, 0, sw, sh)\n ctx.drawImage(sourceImage, sx, sy, sw, sh, 0, 0, sw, sh)\n\n if (scene.textures.exists(textureKey)) {\n scene.textures.remove(textureKey)\n }\n\n scene.textures.addCanvas(textureKey, canvas)\n const texture = scene.textures.get(textureKey)\n texture?.source?.[0]?.update()\n return true\n}\n\nexport function getImageSubTextureCacheKey(\n texture: string,\n frame: string | number | undefined,\n sourceRect: SourceRect\n): string {\n return `${texture}::${frame ?? '__BASE'}::${sourceRect.x},${sourceRect.y},${sourceRect.w},${sourceRect.h}`\n}\n\nexport function retainImageSubTexture(\n scene: Phaser.Scene,\n texture: string,\n frame: string | number | undefined,\n sourceRect: SourceRect | undefined\n): DerivedTextureSource {\n if (!sourceRect) {\n return { texture, frame }\n }\n\n const resolvedFrame = resolveFrame(scene, texture, frame)\n if (!resolvedFrame) {\n return { texture, frame }\n }\n\n const cacheKey = getImageSubTextureCacheKey(texture, frame, sourceRect)\n const entries = getSceneEntries(scene)\n const existing = entries.get(cacheKey)\n\n if (existing) {\n existing.refCount += 1\n return { texture: existing.textureKey, cacheKey }\n }\n\n const textureKey = `__phaserjsx_img_subtex_${nextDerivedTextureId++}`\n const created = createDerivedTexture(scene, textureKey, resolvedFrame, sourceRect)\n if (!created) {\n return { texture, frame }\n }\n\n entries.set(cacheKey, { textureKey, refCount: 1 })\n return { texture: textureKey, cacheKey }\n}\n\nexport function releaseImageSubTexture(scene: Phaser.Scene, cacheKey: string | undefined): void {\n if (!cacheKey) return\n\n const entries = sceneTextureEntries.get(scene)\n if (!entries) return\n\n const entry = entries.get(cacheKey)\n if (!entry) return\n\n entry.refCount -= 1\n if (entry.refCount > 0) {\n return\n }\n\n if (scene.textures.exists(entry.textureKey)) {\n scene.textures.remove(entry.textureKey)\n }\n entries.delete(cacheKey)\n}\n"],"names":[],"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AAS;AAEd,QAAM,QAAQ,QAAQ,IAAI,QAAQ;AAClC,MAAI,CAAC,MAAO;AAEZ,QAAM,YAAY;AAClB,MAAI,MAAM,WAAW,GAAG;AACtB;AAAA,EACF;AAEA,MAAI,MAAM,SAAS,OAAO,MAAM,UAAU,GAAG;AAC3C,UAAM,SAAS,OAAO,MAAM,UAAU;AAAA,EACxC;AACA,UAAQ,OAAO,QAAQ;AACzB;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function isPhaserScene(value) {
|
|
4
|
+
if (!value || typeof value !== "object") return false;
|
|
5
|
+
const maybe = value;
|
|
6
|
+
return maybe.sys !== null && maybe.sys !== void 0 && typeof maybe.sys === "object" && maybe.add !== null && maybe.add !== void 0 && typeof maybe.add === "object";
|
|
7
|
+
}
|
|
8
|
+
function isPhaserContainer(value) {
|
|
9
|
+
if (!value || typeof value !== "object") return false;
|
|
10
|
+
const maybe = value;
|
|
11
|
+
return Array.isArray(maybe.list) && typeof maybe.add === "function" && typeof maybe.remove === "function";
|
|
12
|
+
}
|
|
13
|
+
exports.isPhaserContainer = isPhaserContainer;
|
|
14
|
+
exports.isPhaserScene = isPhaserScene;
|
|
15
|
+
//# sourceMappingURL=phaser-guards.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phaser-guards.cjs","sources":["../../src/utils/phaser-guards.ts"],"sourcesContent":["import type * as Phaser from 'phaser'\n\n/**\n * Duck-typed Phaser guards to avoid instanceof issues when multiple Phaser copies exist.\n */\nexport function isPhaserScene(value: unknown): value is Phaser.Scene {\n if (!value || typeof value !== 'object') return false\n const maybe = value as Phaser.Scene & { sys?: unknown; add?: unknown }\n return (\n maybe.sys !== null &&\n maybe.sys !== undefined &&\n typeof maybe.sys === 'object' &&\n maybe.add !== null &&\n maybe.add !== undefined &&\n typeof maybe.add === 'object'\n )\n}\n\nexport function isPhaserContainer(value: unknown): value is Phaser.GameObjects.Container {\n if (!value || typeof value !== 'object') return false\n const maybe = value as Phaser.GameObjects.Container & {\n list?: unknown\n add?: unknown\n remove?: unknown\n }\n return (\n Array.isArray(maybe.list) &&\n typeof maybe.add === 'function' &&\n typeof maybe.remove === 'function'\n )\n}\n"],"names":[],"mappings":";;AAKO,SAAS,cAAc,OAAuC;AACnE,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,QAAQ;AACd,SACE,MAAM,QAAQ,QACd,MAAM,QAAQ,UACd,OAAO,MAAM,QAAQ,YACrB,MAAM,QAAQ,QACd,MAAM,QAAQ,UACd,OAAO,MAAM,QAAQ;AAEzB;AAEO,SAAS,kBAAkB,OAAuD;AACvF,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,QAAQ;AAKd,SACE,MAAM,QAAQ,MAAM,IAAI,KACxB,OAAO,MAAM,QAAQ,cACrB,OAAO,MAAM,WAAW;AAE5B;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as Phaser from 'phaser';
|
|
2
|
+
/**
|
|
3
|
+
* Duck-typed Phaser guards to avoid instanceof issues when multiple Phaser copies exist.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isPhaserScene(value: unknown): value is Phaser.Scene;
|
|
6
|
+
export declare function isPhaserContainer(value: unknown): value is Phaser.GameObjects.Container;
|
|
7
|
+
//# sourceMappingURL=phaser-guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phaser-guards.d.ts","sourceRoot":"","sources":["../../src/utils/phaser-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAA;AAErC;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,KAAK,CAWnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,WAAW,CAAC,SAAS,CAYvF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function isPhaserScene(value) {
|
|
2
|
+
if (!value || typeof value !== "object") return false;
|
|
3
|
+
const maybe = value;
|
|
4
|
+
return maybe.sys !== null && maybe.sys !== void 0 && typeof maybe.sys === "object" && maybe.add !== null && maybe.add !== void 0 && typeof maybe.add === "object";
|
|
5
|
+
}
|
|
6
|
+
function isPhaserContainer(value) {
|
|
7
|
+
if (!value || typeof value !== "object") return false;
|
|
8
|
+
const maybe = value;
|
|
9
|
+
return Array.isArray(maybe.list) && typeof maybe.add === "function" && typeof maybe.remove === "function";
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
isPhaserContainer,
|
|
13
|
+
isPhaserScene
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=phaser-guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phaser-guards.js","sources":["../../src/utils/phaser-guards.ts"],"sourcesContent":["import type * as Phaser from 'phaser'\n\n/**\n * Duck-typed Phaser guards to avoid instanceof issues when multiple Phaser copies exist.\n */\nexport function isPhaserScene(value: unknown): value is Phaser.Scene {\n if (!value || typeof value !== 'object') return false\n const maybe = value as Phaser.Scene & { sys?: unknown; add?: unknown }\n return (\n maybe.sys !== null &&\n maybe.sys !== undefined &&\n typeof maybe.sys === 'object' &&\n maybe.add !== null &&\n maybe.add !== undefined &&\n typeof maybe.add === 'object'\n )\n}\n\nexport function isPhaserContainer(value: unknown): value is Phaser.GameObjects.Container {\n if (!value || typeof value !== 'object') return false\n const maybe = value as Phaser.GameObjects.Container & {\n list?: unknown\n add?: unknown\n remove?: unknown\n }\n return (\n Array.isArray(maybe.list) &&\n typeof maybe.add === 'function' &&\n typeof maybe.remove === 'function'\n )\n}\n"],"names":[],"mappings":"AAKO,SAAS,cAAc,OAAuC;AACnE,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,QAAQ;AACd,SACE,MAAM,QAAQ,QACd,MAAM,QAAQ,UACd,OAAO,MAAM,QAAQ,YACrB,MAAM,QAAQ,QACd,MAAM,QAAQ,UACd,OAAO,MAAM,QAAQ;AAEzB;AAEO,SAAS,kBAAkB,OAAuD;AACvF,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,QAAQ;AAKd,SACE,MAAM,QAAQ,MAAM,IAAI,KACxB,OAAO,MAAM,QAAQ,cACrB,OAAO,MAAM,WAAW;AAE5B;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function preprocessSvgForTinting(svg) {
|
|
4
|
+
return svg.replace(/fill="currentColor"/gi, 'fill="#FFFFFF"').replace(/fill='currentColor'/gi, "fill='#FFFFFF'").replace(/fill:\s*currentColor/gi, "fill: #FFFFFF").replace(/stroke="currentColor"/gi, 'stroke="#FFFFFF"').replace(/stroke='currentColor'/gi, "stroke='#FFFFFF'").replace(/stroke:\s*currentColor/gi, "stroke: #FFFFFF").replace(/fill="#000000"/gi, 'fill="#FFFFFF"').replace(/fill="#000"/gi, 'fill="#FFFFFF"').replace(/fill='#000000'/gi, "fill='#FFFFFF'").replace(/fill='#000'/gi, "fill='#FFFFFF'").replace(/stroke="#000000"/gi, 'stroke="#FFFFFF"').replace(/stroke="#000"/gi, 'stroke="#FFFFFF"').replace(/stroke='#000000'/gi, "stroke='#FFFFFF'").replace(/stroke='#000'/gi, "stroke='#FFFFFF'");
|
|
5
|
+
}
|
|
6
|
+
async function svgToTexture(scene, key, svgOrUrl, width = 32, height = 32) {
|
|
7
|
+
const trimmed = svgOrUrl.trim();
|
|
8
|
+
let finalUrl;
|
|
9
|
+
let shouldRevokeUrl = false;
|
|
10
|
+
const isSvgString = trimmed.startsWith("<svg") || trimmed.startsWith("<!--");
|
|
11
|
+
if (isSvgString && trimmed.includes("<svg")) {
|
|
12
|
+
const processedSvg = preprocessSvgForTinting(trimmed);
|
|
13
|
+
const blob = new Blob([processedSvg], { type: "image/svg+xml" });
|
|
14
|
+
finalUrl = URL.createObjectURL(blob);
|
|
15
|
+
shouldRevokeUrl = true;
|
|
16
|
+
} else {
|
|
17
|
+
finalUrl = svgOrUrl;
|
|
18
|
+
}
|
|
19
|
+
const img = await new Promise((resolve, reject) => {
|
|
20
|
+
const image = new Image();
|
|
21
|
+
image.crossOrigin = "anonymous";
|
|
22
|
+
image.onload = () => resolve(image);
|
|
23
|
+
image.onerror = () => reject(new Error(`Failed to load SVG: ${key}`));
|
|
24
|
+
image.src = finalUrl;
|
|
25
|
+
});
|
|
26
|
+
const canvas = document.createElement("canvas");
|
|
27
|
+
canvas.width = width;
|
|
28
|
+
canvas.height = height;
|
|
29
|
+
const ctx = canvas.getContext("2d");
|
|
30
|
+
if (!ctx) {
|
|
31
|
+
throw new Error("Failed to get canvas 2D context");
|
|
32
|
+
}
|
|
33
|
+
ctx.clearRect(0, 0, width, height);
|
|
34
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
35
|
+
if (scene.textures.exists(key)) {
|
|
36
|
+
scene.textures.remove(key);
|
|
37
|
+
}
|
|
38
|
+
scene.textures.addCanvas(key, canvas);
|
|
39
|
+
if (shouldRevokeUrl) {
|
|
40
|
+
URL.revokeObjectURL(finalUrl);
|
|
41
|
+
}
|
|
42
|
+
const texture = scene.textures.get(key);
|
|
43
|
+
if (texture && texture.source[0]) {
|
|
44
|
+
texture.source[0].update();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.svgToTexture = svgToTexture;
|
|
48
|
+
//# sourceMappingURL=svg-texture.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-texture.cjs","sources":["../../src/utils/svg-texture.ts"],"sourcesContent":["/**\n * SVG to Phaser Texture Utilities\n * Provides conversion from SVG strings/URLs to Phaser texture resources\n */\nimport type * as Phaser from 'phaser'\n\n/**\n * Preprocesses SVG string to ensure tinting works correctly\n * Replaces fill/stroke=\"currentColor\" and other colors with white (#FFFFFF)\n * This allows Phaser's tint to work by multiplication (white × tint = tint color)\n * @param svg - Raw SVG string\n * @returns Preprocessed SVG string with white fills/strokes\n */\nfunction preprocessSvgForTinting(svg: string): string {\n return (\n svg\n // Replace fill=\"currentColor\" with fill=\"#FFFFFF\"\n .replace(/fill=\"currentColor\"/gi, 'fill=\"#FFFFFF\"')\n // Replace fill='currentColor' with fill='#FFFFFF'\n .replace(/fill='currentColor'/gi, \"fill='#FFFFFF'\")\n // Replace fill:currentColor in style attributes\n .replace(/fill:\\s*currentColor/gi, 'fill: #FFFFFF')\n // Replace stroke=\"currentColor\" with stroke=\"#FFFFFF\" (for outline icons like Lucide)\n .replace(/stroke=\"currentColor\"/gi, 'stroke=\"#FFFFFF\"')\n // Replace stroke='currentColor' with stroke='#FFFFFF'\n .replace(/stroke='currentColor'/gi, \"stroke='#FFFFFF'\")\n // Replace stroke:currentColor in style attributes\n .replace(/stroke:\\s*currentColor/gi, 'stroke: #FFFFFF')\n // Replace black fills (common fallback)\n .replace(/fill=\"#000000\"/gi, 'fill=\"#FFFFFF\"')\n .replace(/fill=\"#000\"/gi, 'fill=\"#FFFFFF\"')\n .replace(/fill='#000000'/gi, \"fill='#FFFFFF'\")\n .replace(/fill='#000'/gi, \"fill='#FFFFFF'\")\n // Replace black strokes\n .replace(/stroke=\"#000000\"/gi, 'stroke=\"#FFFFFF\"')\n .replace(/stroke=\"#000\"/gi, 'stroke=\"#FFFFFF\"')\n .replace(/stroke='#000000'/gi, \"stroke='#FFFFFF'\")\n .replace(/stroke='#000'/gi, \"stroke='#FFFFFF'\")\n )\n}\n\n/**\n * Converts an SVG (string or URL) into a Phaser texture\n *\n * Supports multiple input formats:\n * - Raw SVG string (must start with '<svg')\n * - data:image/svg+xml URL\n * - External URL (http/https)\n *\n * The function creates a canvas element, renders the SVG at the specified dimensions,\n * and registers it as a Phaser texture. If a texture with the same key already exists,\n * it will be replaced.\n *\n * @param scene - Phaser scene instance\n * @param key - Unique texture key for registration\n * @param svgOrUrl - SVG string or URL\n * @param width - Desired texture width in pixels (default: 32)\n * @param height - Desired texture height in pixels (default: 32)\n * @throws {Error} If SVG loading or canvas rendering fails\n * @example\n * ```typescript\n * // Raw SVG string\n * await svgToTexture(scene, 'my-icon', '<svg>...</svg>', 64, 64)\n *\n * // URL\n * await svgToTexture(scene, 'external-icon', 'https://example.com/icon.svg')\n * ```\n */\nexport async function svgToTexture(\n scene: Phaser.Scene,\n key: string,\n svgOrUrl: string,\n width: number = 32,\n height: number = 32\n): Promise<void> {\n const trimmed = svgOrUrl.trim()\n let finalUrl: string\n let shouldRevokeUrl = false\n\n // Detect input type: raw SVG string or URL\n // SVG strings can start with <!-- comment --> or <svg\n const isSvgString = trimmed.startsWith('<svg') || trimmed.startsWith('<!--')\n\n if (isSvgString && trimmed.includes('<svg')) {\n // Raw SVG string - preprocess for tinting, then create blob URL\n const processedSvg = preprocessSvgForTinting(trimmed)\n const blob = new Blob([processedSvg], { type: 'image/svg+xml' })\n finalUrl = URL.createObjectURL(blob)\n shouldRevokeUrl = true\n } else {\n // Already a URL (data: or http/https)\n finalUrl = svgOrUrl\n }\n\n // Load SVG as HTMLImageElement\n const img = await new Promise<HTMLImageElement>((resolve, reject) => {\n const image = new Image()\n image.crossOrigin = 'anonymous'\n image.onload = () => resolve(image)\n image.onerror = () => reject(new Error(`Failed to load SVG: ${key}`))\n image.src = finalUrl\n })\n\n // Create canvas and render scaled SVG\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n\n const ctx = canvas.getContext('2d')\n if (!ctx) {\n throw new Error('Failed to get canvas 2D context')\n }\n\n ctx.clearRect(0, 0, width, height)\n ctx.drawImage(img, 0, 0, width, height)\n\n // Remove existing texture if present\n if (scene.textures.exists(key)) {\n scene.textures.remove(key)\n }\n\n // Register canvas as Phaser texture\n scene.textures.addCanvas(key, canvas)\n\n // Cleanup blob URL after canvas is added\n if (shouldRevokeUrl) {\n URL.revokeObjectURL(finalUrl)\n }\n\n // Force texture refresh to ensure GL texture is created\n const texture = scene.textures.get(key)\n if (texture && texture.source[0]) {\n texture.source[0].update()\n }\n}\n"],"names":[],"mappings":";;AAaA,SAAS,wBAAwB,KAAqB;AACpD,SACE,IAEG,QAAQ,yBAAyB,gBAAgB,EAEjD,QAAQ,yBAAyB,gBAAgB,EAEjD,QAAQ,0BAA0B,eAAe,EAEjD,QAAQ,2BAA2B,kBAAkB,EAErD,QAAQ,2BAA2B,kBAAkB,EAErD,QAAQ,4BAA4B,iBAAiB,EAErD,QAAQ,oBAAoB,gBAAgB,EAC5C,QAAQ,iBAAiB,gBAAgB,EACzC,QAAQ,oBAAoB,gBAAgB,EAC5C,QAAQ,iBAAiB,gBAAgB,EAEzC,QAAQ,sBAAsB,kBAAkB,EAChD,QAAQ,mBAAmB,kBAAkB,EAC7C,QAAQ,sBAAsB,kBAAkB,EAChD,QAAQ,mBAAmB,kBAAkB;AAEpD;AA6BA,eAAsB,aACpB,OACA,KACA,UACA,QAAgB,IAChB,SAAiB,IACF;AACf,QAAM,UAAU,SAAS,KAAA;AACzB,MAAI;AACJ,MAAI,kBAAkB;AAItB,QAAM,cAAc,QAAQ,WAAW,MAAM,KAAK,QAAQ,WAAW,MAAM;AAE3E,MAAI,eAAe,QAAQ,SAAS,MAAM,GAAG;AAE3C,UAAM,eAAe,wBAAwB,OAAO;AACpD,UAAM,OAAO,IAAI,KAAK,CAAC,YAAY,GAAG,EAAE,MAAM,iBAAiB;AAC/D,eAAW,IAAI,gBAAgB,IAAI;AACnC,sBAAkB;AAAA,EACpB,OAAO;AAEL,eAAW;AAAA,EACb;AAGA,QAAM,MAAM,MAAM,IAAI,QAA0B,CAAC,SAAS,WAAW;AACnE,UAAM,QAAQ,IAAI,MAAA;AAClB,UAAM,cAAc;AACpB,UAAM,SAAS,MAAM,QAAQ,KAAK;AAClC,UAAM,UAAU,MAAM,OAAO,IAAI,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACpE,UAAM,MAAM;AAAA,EACd,CAAC;AAGD,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,QAAQ;AACf,SAAO,SAAS;AAEhB,QAAM,MAAM,OAAO,WAAW,IAAI;AAClC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,MAAI,UAAU,GAAG,GAAG,OAAO,MAAM;AACjC,MAAI,UAAU,KAAK,GAAG,GAAG,OAAO,MAAM;AAGtC,MAAI,MAAM,SAAS,OAAO,GAAG,GAAG;AAC9B,UAAM,SAAS,OAAO,GAAG;AAAA,EAC3B;AAGA,QAAM,SAAS,UAAU,KAAK,MAAM;AAGpC,MAAI,iBAAiB;AACnB,QAAI,gBAAgB,QAAQ;AAAA,EAC9B;AAGA,QAAM,UAAU,MAAM,SAAS,IAAI,GAAG;AACtC,MAAI,WAAW,QAAQ,OAAO,CAAC,GAAG;AAChC,YAAQ,OAAO,CAAC,EAAE,OAAA;AAAA,EACpB;AACF;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG to Phaser Texture Utilities
|
|
3
|
+
* Provides conversion from SVG strings/URLs to Phaser texture resources
|
|
4
|
+
*/
|
|
5
|
+
import type * as Phaser from 'phaser';
|
|
6
|
+
/**
|
|
7
|
+
* Converts an SVG (string or URL) into a Phaser texture
|
|
8
|
+
*
|
|
9
|
+
* Supports multiple input formats:
|
|
10
|
+
* - Raw SVG string (must start with '<svg')
|
|
11
|
+
* - data:image/svg+xml URL
|
|
12
|
+
* - External URL (http/https)
|
|
13
|
+
*
|
|
14
|
+
* The function creates a canvas element, renders the SVG at the specified dimensions,
|
|
15
|
+
* and registers it as a Phaser texture. If a texture with the same key already exists,
|
|
16
|
+
* it will be replaced.
|
|
17
|
+
*
|
|
18
|
+
* @param scene - Phaser scene instance
|
|
19
|
+
* @param key - Unique texture key for registration
|
|
20
|
+
* @param svgOrUrl - SVG string or URL
|
|
21
|
+
* @param width - Desired texture width in pixels (default: 32)
|
|
22
|
+
* @param height - Desired texture height in pixels (default: 32)
|
|
23
|
+
* @throws {Error} If SVG loading or canvas rendering fails
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Raw SVG string
|
|
27
|
+
* await svgToTexture(scene, 'my-icon', '<svg>...</svg>', 64, 64)
|
|
28
|
+
*
|
|
29
|
+
* // URL
|
|
30
|
+
* await svgToTexture(scene, 'external-icon', 'https://example.com/icon.svg')
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function svgToTexture(scene: Phaser.Scene, key: string, svgOrUrl: string, width?: number, height?: number): Promise<void>;
|
|
34
|
+
//# sourceMappingURL=svg-texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-texture.d.ts","sourceRoot":"","sources":["../../src/utils/svg-texture.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAA;AAqCrC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,MAAW,EAClB,MAAM,GAAE,MAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CA4Df"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function preprocessSvgForTinting(svg) {
|
|
2
|
+
return svg.replace(/fill="currentColor"/gi, 'fill="#FFFFFF"').replace(/fill='currentColor'/gi, "fill='#FFFFFF'").replace(/fill:\s*currentColor/gi, "fill: #FFFFFF").replace(/stroke="currentColor"/gi, 'stroke="#FFFFFF"').replace(/stroke='currentColor'/gi, "stroke='#FFFFFF'").replace(/stroke:\s*currentColor/gi, "stroke: #FFFFFF").replace(/fill="#000000"/gi, 'fill="#FFFFFF"').replace(/fill="#000"/gi, 'fill="#FFFFFF"').replace(/fill='#000000'/gi, "fill='#FFFFFF'").replace(/fill='#000'/gi, "fill='#FFFFFF'").replace(/stroke="#000000"/gi, 'stroke="#FFFFFF"').replace(/stroke="#000"/gi, 'stroke="#FFFFFF"').replace(/stroke='#000000'/gi, "stroke='#FFFFFF'").replace(/stroke='#000'/gi, "stroke='#FFFFFF'");
|
|
3
|
+
}
|
|
4
|
+
async function svgToTexture(scene, key, svgOrUrl, width = 32, height = 32) {
|
|
5
|
+
const trimmed = svgOrUrl.trim();
|
|
6
|
+
let finalUrl;
|
|
7
|
+
let shouldRevokeUrl = false;
|
|
8
|
+
const isSvgString = trimmed.startsWith("<svg") || trimmed.startsWith("<!--");
|
|
9
|
+
if (isSvgString && trimmed.includes("<svg")) {
|
|
10
|
+
const processedSvg = preprocessSvgForTinting(trimmed);
|
|
11
|
+
const blob = new Blob([processedSvg], { type: "image/svg+xml" });
|
|
12
|
+
finalUrl = URL.createObjectURL(blob);
|
|
13
|
+
shouldRevokeUrl = true;
|
|
14
|
+
} else {
|
|
15
|
+
finalUrl = svgOrUrl;
|
|
16
|
+
}
|
|
17
|
+
const img = await new Promise((resolve, reject) => {
|
|
18
|
+
const image = new Image();
|
|
19
|
+
image.crossOrigin = "anonymous";
|
|
20
|
+
image.onload = () => resolve(image);
|
|
21
|
+
image.onerror = () => reject(new Error(`Failed to load SVG: ${key}`));
|
|
22
|
+
image.src = finalUrl;
|
|
23
|
+
});
|
|
24
|
+
const canvas = document.createElement("canvas");
|
|
25
|
+
canvas.width = width;
|
|
26
|
+
canvas.height = height;
|
|
27
|
+
const ctx = canvas.getContext("2d");
|
|
28
|
+
if (!ctx) {
|
|
29
|
+
throw new Error("Failed to get canvas 2D context");
|
|
30
|
+
}
|
|
31
|
+
ctx.clearRect(0, 0, width, height);
|
|
32
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
33
|
+
if (scene.textures.exists(key)) {
|
|
34
|
+
scene.textures.remove(key);
|
|
35
|
+
}
|
|
36
|
+
scene.textures.addCanvas(key, canvas);
|
|
37
|
+
if (shouldRevokeUrl) {
|
|
38
|
+
URL.revokeObjectURL(finalUrl);
|
|
39
|
+
}
|
|
40
|
+
const texture = scene.textures.get(key);
|
|
41
|
+
if (texture && texture.source[0]) {
|
|
42
|
+
texture.source[0].update();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
svgToTexture
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=svg-texture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-texture.js","sources":["../../src/utils/svg-texture.ts"],"sourcesContent":["/**\n * SVG to Phaser Texture Utilities\n * Provides conversion from SVG strings/URLs to Phaser texture resources\n */\nimport type * as Phaser from 'phaser'\n\n/**\n * Preprocesses SVG string to ensure tinting works correctly\n * Replaces fill/stroke=\"currentColor\" and other colors with white (#FFFFFF)\n * This allows Phaser's tint to work by multiplication (white × tint = tint color)\n * @param svg - Raw SVG string\n * @returns Preprocessed SVG string with white fills/strokes\n */\nfunction preprocessSvgForTinting(svg: string): string {\n return (\n svg\n // Replace fill=\"currentColor\" with fill=\"#FFFFFF\"\n .replace(/fill=\"currentColor\"/gi, 'fill=\"#FFFFFF\"')\n // Replace fill='currentColor' with fill='#FFFFFF'\n .replace(/fill='currentColor'/gi, \"fill='#FFFFFF'\")\n // Replace fill:currentColor in style attributes\n .replace(/fill:\\s*currentColor/gi, 'fill: #FFFFFF')\n // Replace stroke=\"currentColor\" with stroke=\"#FFFFFF\" (for outline icons like Lucide)\n .replace(/stroke=\"currentColor\"/gi, 'stroke=\"#FFFFFF\"')\n // Replace stroke='currentColor' with stroke='#FFFFFF'\n .replace(/stroke='currentColor'/gi, \"stroke='#FFFFFF'\")\n // Replace stroke:currentColor in style attributes\n .replace(/stroke:\\s*currentColor/gi, 'stroke: #FFFFFF')\n // Replace black fills (common fallback)\n .replace(/fill=\"#000000\"/gi, 'fill=\"#FFFFFF\"')\n .replace(/fill=\"#000\"/gi, 'fill=\"#FFFFFF\"')\n .replace(/fill='#000000'/gi, \"fill='#FFFFFF'\")\n .replace(/fill='#000'/gi, \"fill='#FFFFFF'\")\n // Replace black strokes\n .replace(/stroke=\"#000000\"/gi, 'stroke=\"#FFFFFF\"')\n .replace(/stroke=\"#000\"/gi, 'stroke=\"#FFFFFF\"')\n .replace(/stroke='#000000'/gi, \"stroke='#FFFFFF'\")\n .replace(/stroke='#000'/gi, \"stroke='#FFFFFF'\")\n )\n}\n\n/**\n * Converts an SVG (string or URL) into a Phaser texture\n *\n * Supports multiple input formats:\n * - Raw SVG string (must start with '<svg')\n * - data:image/svg+xml URL\n * - External URL (http/https)\n *\n * The function creates a canvas element, renders the SVG at the specified dimensions,\n * and registers it as a Phaser texture. If a texture with the same key already exists,\n * it will be replaced.\n *\n * @param scene - Phaser scene instance\n * @param key - Unique texture key for registration\n * @param svgOrUrl - SVG string or URL\n * @param width - Desired texture width in pixels (default: 32)\n * @param height - Desired texture height in pixels (default: 32)\n * @throws {Error} If SVG loading or canvas rendering fails\n * @example\n * ```typescript\n * // Raw SVG string\n * await svgToTexture(scene, 'my-icon', '<svg>...</svg>', 64, 64)\n *\n * // URL\n * await svgToTexture(scene, 'external-icon', 'https://example.com/icon.svg')\n * ```\n */\nexport async function svgToTexture(\n scene: Phaser.Scene,\n key: string,\n svgOrUrl: string,\n width: number = 32,\n height: number = 32\n): Promise<void> {\n const trimmed = svgOrUrl.trim()\n let finalUrl: string\n let shouldRevokeUrl = false\n\n // Detect input type: raw SVG string or URL\n // SVG strings can start with <!-- comment --> or <svg\n const isSvgString = trimmed.startsWith('<svg') || trimmed.startsWith('<!--')\n\n if (isSvgString && trimmed.includes('<svg')) {\n // Raw SVG string - preprocess for tinting, then create blob URL\n const processedSvg = preprocessSvgForTinting(trimmed)\n const blob = new Blob([processedSvg], { type: 'image/svg+xml' })\n finalUrl = URL.createObjectURL(blob)\n shouldRevokeUrl = true\n } else {\n // Already a URL (data: or http/https)\n finalUrl = svgOrUrl\n }\n\n // Load SVG as HTMLImageElement\n const img = await new Promise<HTMLImageElement>((resolve, reject) => {\n const image = new Image()\n image.crossOrigin = 'anonymous'\n image.onload = () => resolve(image)\n image.onerror = () => reject(new Error(`Failed to load SVG: ${key}`))\n image.src = finalUrl\n })\n\n // Create canvas and render scaled SVG\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n\n const ctx = canvas.getContext('2d')\n if (!ctx) {\n throw new Error('Failed to get canvas 2D context')\n }\n\n ctx.clearRect(0, 0, width, height)\n ctx.drawImage(img, 0, 0, width, height)\n\n // Remove existing texture if present\n if (scene.textures.exists(key)) {\n scene.textures.remove(key)\n }\n\n // Register canvas as Phaser texture\n scene.textures.addCanvas(key, canvas)\n\n // Cleanup blob URL after canvas is added\n if (shouldRevokeUrl) {\n URL.revokeObjectURL(finalUrl)\n }\n\n // Force texture refresh to ensure GL texture is created\n const texture = scene.textures.get(key)\n if (texture && texture.source[0]) {\n texture.source[0].update()\n }\n}\n"],"names":[],"mappings":"AAaA,SAAS,wBAAwB,KAAqB;AACpD,SACE,IAEG,QAAQ,yBAAyB,gBAAgB,EAEjD,QAAQ,yBAAyB,gBAAgB,EAEjD,QAAQ,0BAA0B,eAAe,EAEjD,QAAQ,2BAA2B,kBAAkB,EAErD,QAAQ,2BAA2B,kBAAkB,EAErD,QAAQ,4BAA4B,iBAAiB,EAErD,QAAQ,oBAAoB,gBAAgB,EAC5C,QAAQ,iBAAiB,gBAAgB,EACzC,QAAQ,oBAAoB,gBAAgB,EAC5C,QAAQ,iBAAiB,gBAAgB,EAEzC,QAAQ,sBAAsB,kBAAkB,EAChD,QAAQ,mBAAmB,kBAAkB,EAC7C,QAAQ,sBAAsB,kBAAkB,EAChD,QAAQ,mBAAmB,kBAAkB;AAEpD;AA6BA,eAAsB,aACpB,OACA,KACA,UACA,QAAgB,IAChB,SAAiB,IACF;AACf,Q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