rn-gamekit 0.1.0 → 0.2.1
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/CHANGELOG.md +75 -0
- package/README.md +97 -16
- package/lib/module/assets/defineAssets.js +28 -3
- package/lib/module/assets/defineAssets.js.map +1 -1
- package/lib/module/assets.js +11 -0
- package/lib/module/assets.js.map +1 -0
- package/lib/module/audio/createGameAudio.js +784 -0
- package/lib/module/audio/createGameAudio.js.map +1 -0
- package/lib/module/audio/errors.js +12 -0
- package/lib/module/audio/errors.js.map +1 -0
- package/lib/module/audio/index.js +5 -0
- package/lib/module/audio/index.js.map +1 -0
- package/lib/module/audio/resolver.js +37 -0
- package/lib/module/audio/resolver.js.map +1 -0
- package/lib/module/audio/types.js +4 -0
- package/lib/module/audio/types.js.map +1 -0
- package/lib/module/audio.js +9 -0
- package/lib/module/audio.js.map +1 -0
- package/lib/module/camera2d/bounds.js +59 -0
- package/lib/module/camera2d/bounds.js.map +1 -0
- package/lib/module/camera2d/extents.js +25 -0
- package/lib/module/camera2d/extents.js.map +1 -0
- package/lib/module/camera2d/follow.js +138 -0
- package/lib/module/camera2d/follow.js.map +1 -0
- package/lib/module/camera2d/index.js +20 -0
- package/lib/module/camera2d/index.js.map +1 -0
- package/lib/module/camera2d/interpolation.js +98 -0
- package/lib/module/camera2d/interpolation.js.map +1 -0
- package/lib/module/camera2d/shake.js +85 -0
- package/lib/module/camera2d/shake.js.map +1 -0
- package/lib/module/camera2d/transform.js +151 -0
- package/lib/module/camera2d/transform.js.map +1 -0
- package/lib/module/camera2d/types.js +4 -0
- package/lib/module/camera2d/types.js.map +1 -0
- package/lib/module/camera2d/validation.js +98 -0
- package/lib/module/camera2d/validation.js.map +1 -0
- package/lib/module/camera2d/visibility.js +138 -0
- package/lib/module/camera2d/visibility.js.map +1 -0
- package/lib/module/camera2d.js +9 -0
- package/lib/module/camera2d.js.map +1 -0
- package/lib/module/collision2d/colliders.js +266 -0
- package/lib/module/collision2d/colliders.js.map +1 -0
- package/lib/module/collision2d/debug.js +105 -0
- package/lib/module/collision2d/debug.js.map +1 -0
- package/lib/module/collision2d/filters.js +40 -0
- package/lib/module/collision2d/filters.js.map +1 -0
- package/lib/module/collision2d/index.js +12 -0
- package/lib/module/collision2d/index.js.map +1 -0
- package/lib/module/collision2d/intersections.js +67 -0
- package/lib/module/collision2d/intersections.js.map +1 -0
- package/lib/module/collision2d/manifolds.js +218 -0
- package/lib/module/collision2d/manifolds.js.map +1 -0
- package/lib/module/collision2d/segments.js +187 -0
- package/lib/module/collision2d/segments.js.map +1 -0
- package/lib/module/collision2d/spatialHash.js +167 -0
- package/lib/module/collision2d/spatialHash.js.map +1 -0
- package/lib/module/collision2d/sweeps.js +255 -0
- package/lib/module/collision2d/sweeps.js.map +1 -0
- package/lib/module/collision2d.js +9 -0
- package/lib/module/collision2d.js.map +1 -0
- package/lib/module/core/input/buttonPad.js +214 -0
- package/lib/module/core/input/buttonPad.js.map +1 -0
- package/lib/module/core/input/createInputBuffer.js +66 -14
- package/lib/module/core/input/createInputBuffer.js.map +1 -1
- package/lib/module/core/session/createGameSession.js +454 -50
- package/lib/module/core/session/createGameSession.js.map +1 -1
- package/lib/module/core/session/deepFreeze.js +92 -2
- package/lib/module/core/session/deepFreeze.js.map +1 -1
- package/lib/module/core/session/types.js +12 -0
- package/lib/module/core/session/types.js.map +1 -1
- package/lib/module/definition/defineGame.js +23 -0
- package/lib/module/definition/defineGame.js.map +1 -1
- package/lib/module/events/defineGameEvents.js +46 -0
- package/lib/module/events/defineGameEvents.js.map +1 -0
- package/lib/module/events/errors.js +16 -0
- package/lib/module/events/errors.js.map +1 -0
- package/lib/module/events/index.js +7 -0
- package/lib/module/events/index.js.map +1 -0
- package/lib/module/events/payload.js +219 -0
- package/lib/module/events/payload.js.map +1 -0
- package/lib/module/events/seed.js +33 -0
- package/lib/module/events/seed.js.map +1 -0
- package/lib/module/events/types.js +4 -0
- package/lib/module/events/types.js.map +1 -0
- package/lib/module/events.js +13 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/geometry/helpers.js +140 -0
- package/lib/module/geometry/helpers.js.map +1 -0
- package/lib/module/geometry/index.js +5 -0
- package/lib/module/geometry/index.js.map +1 -0
- package/lib/module/geometry/validation.js +104 -0
- package/lib/module/geometry/validation.js.map +1 -0
- package/lib/module/geometry.js +9 -0
- package/lib/module/geometry.js.map +1 -0
- package/lib/module/haptics/createGameHaptics.js +214 -0
- package/lib/module/haptics/createGameHaptics.js.map +1 -0
- package/lib/module/haptics/errors.js +12 -0
- package/lib/module/haptics/errors.js.map +1 -0
- package/lib/module/haptics/index.js +5 -0
- package/lib/module/haptics/index.js.map +1 -0
- package/lib/module/haptics/resolver.js +37 -0
- package/lib/module/haptics/resolver.js.map +1 -0
- package/lib/module/haptics/types.js +4 -0
- package/lib/module/haptics/types.js.map +1 -0
- package/lib/module/haptics.js +9 -0
- package/lib/module/haptics.js.map +1 -0
- package/lib/module/index.js +8 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/particles/createParticleSystem.js +481 -0
- package/lib/module/particles/createParticleSystem.js.map +1 -0
- package/lib/module/particles/defineParticleEffect.js +178 -0
- package/lib/module/particles/defineParticleEffect.js.map +1 -0
- package/lib/module/particles/errors.js +9 -0
- package/lib/module/particles/errors.js.map +1 -0
- package/lib/module/particles/index.js +8 -0
- package/lib/module/particles/index.js.map +1 -0
- package/lib/module/particles/sampling.js +121 -0
- package/lib/module/particles/sampling.js.map +1 -0
- package/lib/module/particles/types.js +4 -0
- package/lib/module/particles/types.js.map +1 -0
- package/lib/module/particles.js +4 -0
- package/lib/module/particles.js.map +1 -0
- package/lib/module/react/GameButtonPad.js +344 -0
- package/lib/module/react/GameButtonPad.js.map +1 -0
- package/lib/module/react/GamePointerInput.js +74 -16
- package/lib/module/react/GamePointerInput.js.map +1 -1
- package/lib/module/react/GameView.js +139 -60
- package/lib/module/react/GameView.js.map +1 -1
- package/lib/module/react/assets/createGameAssetStore.js +145 -95
- package/lib/module/react/assets/createGameAssetStore.js.map +1 -1
- package/lib/module/react/assets/useGameAssets.js +60 -35
- package/lib/module/react/assets/useGameAssets.js.map +1 -1
- package/lib/module/react/bindAppLifecycle.js +46 -17
- package/lib/module/react/bindAppLifecycle.js.map +1 -1
- package/lib/module/react/bindGameSession.js +13 -2
- package/lib/module/react/bindGameSession.js.map +1 -1
- package/lib/module/react/camera2d/GameLayer2D.js +50 -0
- package/lib/module/react/camera2d/GameLayer2D.js.map +1 -0
- package/lib/module/react/camera2d/defineGameCamera2D.js +30 -0
- package/lib/module/react/camera2d/defineGameCamera2D.js.map +1 -0
- package/lib/module/react/camera2d/usePresentedCameraBinding.js +177 -0
- package/lib/module/react/camera2d/usePresentedCameraBinding.js.map +1 -0
- package/lib/module/react/cleanupList.js +38 -0
- package/lib/module/react/cleanupList.js.map +1 -0
- package/lib/module/react/lifecycleSource.js +49 -0
- package/lib/module/react/lifecycleSource.js.map +1 -0
- package/lib/module/react/particles/ParticleView.js +308 -0
- package/lib/module/react/particles/ParticleView.js.map +1 -0
- package/lib/module/react/particles/culling.js +115 -0
- package/lib/module/react/particles/culling.js.map +1 -0
- package/lib/module/react/particles/index.js +7 -0
- package/lib/module/react/particles/index.js.map +1 -0
- package/lib/module/react/particles/spriteXForm.js +45 -0
- package/lib/module/react/particles/spriteXForm.js.map +1 -0
- package/lib/module/react/particles/useParticlePresentation.js +204 -0
- package/lib/module/react/particles/useParticlePresentation.js.map +1 -0
- package/lib/module/react/pointerBinding.js +55 -17
- package/lib/module/react/pointerBinding.js.map +1 -1
- package/lib/module/react/pointerCamera.js +28 -0
- package/lib/module/react/pointerCamera.js.map +1 -0
- package/lib/module/react/pointerCoalescer.js +16 -9
- package/lib/module/react/pointerCoalescer.js.map +1 -1
- package/lib/module/react/sprites/GameSprite.js +5 -17
- package/lib/module/react/sprites/GameSprite.js.map +1 -1
- package/lib/module/react/sprites/GameWorld2D.js +112 -9
- package/lib/module/react/sprites/GameWorld2D.js.map +1 -1
- package/lib/module/react/sprites/Sprite.js +48 -63
- package/lib/module/react/sprites/Sprite.js.map +1 -1
- package/lib/module/react/sprites/SpriteBatch.js +53 -28
- package/lib/module/react/sprites/SpriteBatch.js.map +1 -1
- package/lib/module/react/sprites/batchVisibility.js +58 -0
- package/lib/module/react/sprites/batchVisibility.js.map +1 -0
- package/lib/module/react/sprites/spriteSelection.js +103 -0
- package/lib/module/react/sprites/spriteSelection.js.map +1 -0
- package/lib/module/react/sprites/spriteTransform.js +46 -25
- package/lib/module/react/sprites/spriteTransform.js.map +1 -1
- package/lib/module/react/tilemap/TileMapLayer2D.js +217 -0
- package/lib/module/react/tilemap/TileMapLayer2D.js.map +1 -0
- package/lib/module/react/tilemap/tilePresentation.js +374 -0
- package/lib/module/react/tilemap/tilePresentation.js.map +1 -0
- package/lib/module/react/useGameSession.js +70 -0
- package/lib/module/react/useGameSession.js.map +1 -0
- package/lib/module/react/useGameSessionStatus.js +46 -0
- package/lib/module/react/useGameSessionStatus.js.map +1 -0
- package/lib/module/react/viewportBinding.js +5 -1
- package/lib/module/react/viewportBinding.js.map +1 -1
- package/lib/module/react.js +12 -1
- package/lib/module/react.js.map +1 -1
- package/lib/module/scene/defineScene.js +17 -0
- package/lib/module/scene/defineScene.js.map +1 -1
- package/lib/module/sprites/sampleSpriteClip.js +66 -6
- package/lib/module/sprites/sampleSpriteClip.js.map +1 -1
- package/lib/module/sprites/spriteAnimationState.js +10 -20
- package/lib/module/sprites/spriteAnimationState.js.map +1 -1
- package/lib/module/sprites.js +11 -0
- package/lib/module/sprites.js.map +1 -0
- package/lib/module/storage/adapters/asyncStorage.js +57 -0
- package/lib/module/storage/adapters/asyncStorage.js.map +1 -0
- package/lib/module/storage/adapters/memory.js +50 -0
- package/lib/module/storage/adapters/memory.js.map +1 -0
- package/lib/module/storage/errors.js +34 -0
- package/lib/module/storage/errors.js.map +1 -0
- package/lib/module/storage/index.js +11 -0
- package/lib/module/storage/index.js.map +1 -0
- package/lib/module/storage/schema.js +151 -0
- package/lib/module/storage/schema.js.map +1 -0
- package/lib/module/storage/serialization.js +249 -0
- package/lib/module/storage/serialization.js.map +1 -0
- package/lib/module/storage/store.js +387 -0
- package/lib/module/storage/store.js.map +1 -0
- package/lib/module/storage/types.js +16 -0
- package/lib/module/storage/types.js.map +1 -0
- package/lib/module/storage/validation.js +111 -0
- package/lib/module/storage/validation.js.map +1 -0
- package/lib/module/storage.js +4 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/testing.js +4 -0
- package/lib/module/testing.js.map +1 -1
- package/lib/module/tilemap/chunkStats.js +27 -0
- package/lib/module/tilemap/chunkStats.js.map +1 -0
- package/lib/module/tilemap/definitions.js +308 -0
- package/lib/module/tilemap/definitions.js.map +1 -0
- package/lib/module/tilemap/errors.js +13 -0
- package/lib/module/tilemap/errors.js.map +1 -0
- package/lib/module/tilemap/index.js +10 -0
- package/lib/module/tilemap/index.js.map +1 -0
- package/lib/module/tilemap/movement.js +379 -0
- package/lib/module/tilemap/movement.js.map +1 -0
- package/lib/module/tilemap/queries.js +114 -0
- package/lib/module/tilemap/queries.js.map +1 -0
- package/lib/module/tilemap/tiledAdapter.js +141 -0
- package/lib/module/tilemap/tiledAdapter.js.map +1 -0
- package/lib/module/tilemap/types.js +4 -0
- package/lib/module/tilemap/types.js.map +1 -0
- package/lib/module/tilemap.js +4 -0
- package/lib/module/tilemap.js.map +1 -0
- package/lib/typescript/src/assets/defineAssets.d.ts +1 -1
- package/lib/typescript/src/assets/defineAssets.d.ts.map +1 -1
- package/lib/typescript/src/assets.d.ts +11 -0
- package/lib/typescript/src/assets.d.ts.map +1 -0
- package/lib/typescript/src/audio/createGameAudio.d.ts +5 -0
- package/lib/typescript/src/audio/createGameAudio.d.ts.map +1 -0
- package/lib/typescript/src/audio/errors.d.ts +6 -0
- package/lib/typescript/src/audio/errors.d.ts.map +1 -0
- package/lib/typescript/src/audio/index.d.ts +4 -0
- package/lib/typescript/src/audio/index.d.ts.map +1 -0
- package/lib/typescript/src/audio/resolver.d.ts +44 -0
- package/lib/typescript/src/audio/resolver.d.ts.map +1 -0
- package/lib/typescript/src/audio/types.d.ts +42 -0
- package/lib/typescript/src/audio/types.d.ts.map +1 -0
- package/lib/typescript/src/audio.d.ts +8 -0
- package/lib/typescript/src/audio.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/bounds.d.ts +25 -0
- package/lib/typescript/src/camera2d/bounds.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/extents.d.ts +17 -0
- package/lib/typescript/src/camera2d/extents.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/follow.d.ts +24 -0
- package/lib/typescript/src/camera2d/follow.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/index.d.ts +19 -0
- package/lib/typescript/src/camera2d/index.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/interpolation.d.ts +17 -0
- package/lib/typescript/src/camera2d/interpolation.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/shake.d.ts +20 -0
- package/lib/typescript/src/camera2d/shake.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/transform.d.ts +44 -0
- package/lib/typescript/src/camera2d/transform.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/types.d.ts +74 -0
- package/lib/typescript/src/camera2d/types.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/validation.d.ts +30 -0
- package/lib/typescript/src/camera2d/validation.d.ts.map +1 -0
- package/lib/typescript/src/camera2d/visibility.d.ts +47 -0
- package/lib/typescript/src/camera2d/visibility.d.ts.map +1 -0
- package/lib/typescript/src/camera2d.d.ts +7 -0
- package/lib/typescript/src/camera2d.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/colliders.d.ts +120 -0
- package/lib/typescript/src/collision2d/colliders.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/debug.d.ts +67 -0
- package/lib/typescript/src/collision2d/debug.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/filters.d.ts +28 -0
- package/lib/typescript/src/collision2d/filters.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/index.d.ts +17 -0
- package/lib/typescript/src/collision2d/index.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/intersections.d.ts +24 -0
- package/lib/typescript/src/collision2d/intersections.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/manifolds.d.ts +39 -0
- package/lib/typescript/src/collision2d/manifolds.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/segments.d.ts +24 -0
- package/lib/typescript/src/collision2d/segments.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/spatialHash.d.ts +50 -0
- package/lib/typescript/src/collision2d/spatialHash.d.ts.map +1 -0
- package/lib/typescript/src/collision2d/sweeps.d.ts +60 -0
- package/lib/typescript/src/collision2d/sweeps.d.ts.map +1 -0
- package/lib/typescript/src/collision2d.d.ts +7 -0
- package/lib/typescript/src/collision2d.d.ts.map +1 -0
- package/lib/typescript/src/core/input/buttonPad.d.ts +59 -0
- package/lib/typescript/src/core/input/buttonPad.d.ts.map +1 -0
- package/lib/typescript/src/core/input/createInputBuffer.d.ts +1 -1
- package/lib/typescript/src/core/input/createInputBuffer.d.ts.map +1 -1
- package/lib/typescript/src/core/input/types.d.ts +7 -0
- package/lib/typescript/src/core/input/types.d.ts.map +1 -1
- package/lib/typescript/src/core/session/createGameSession.d.ts +4 -2
- package/lib/typescript/src/core/session/createGameSession.d.ts.map +1 -1
- package/lib/typescript/src/core/session/deepFreeze.d.ts +21 -1
- package/lib/typescript/src/core/session/deepFreeze.d.ts.map +1 -1
- package/lib/typescript/src/core/session/diagnostics.d.ts +2 -0
- package/lib/typescript/src/core/session/diagnostics.d.ts.map +1 -1
- package/lib/typescript/src/core/session/types.d.ts +69 -4
- package/lib/typescript/src/core/session/types.d.ts.map +1 -1
- package/lib/typescript/src/definition/defineGame.d.ts +12 -1
- package/lib/typescript/src/definition/defineGame.d.ts.map +1 -1
- package/lib/typescript/src/definition/types.d.ts +10 -1
- package/lib/typescript/src/definition/types.d.ts.map +1 -1
- package/lib/typescript/src/events/defineGameEvents.d.ts +26 -0
- package/lib/typescript/src/events/defineGameEvents.d.ts.map +1 -0
- package/lib/typescript/src/events/errors.d.ts +12 -0
- package/lib/typescript/src/events/errors.d.ts.map +1 -0
- package/lib/typescript/src/events/index.d.ts +6 -0
- package/lib/typescript/src/events/index.d.ts.map +1 -0
- package/lib/typescript/src/events/payload.d.ts +21 -0
- package/lib/typescript/src/events/payload.d.ts.map +1 -0
- package/lib/typescript/src/events/seed.d.ts +3 -0
- package/lib/typescript/src/events/seed.d.ts.map +1 -0
- package/lib/typescript/src/events/types.d.ts +42 -0
- package/lib/typescript/src/events/types.d.ts.map +1 -0
- package/lib/typescript/src/events.d.ts +12 -0
- package/lib/typescript/src/events.d.ts.map +1 -0
- package/lib/typescript/src/geometry/helpers.d.ts +35 -0
- package/lib/typescript/src/geometry/helpers.d.ts.map +1 -0
- package/lib/typescript/src/geometry/index.d.ts +4 -0
- package/lib/typescript/src/geometry/index.d.ts.map +1 -0
- package/lib/typescript/src/geometry/types.d.ts +49 -0
- package/lib/typescript/src/geometry/types.d.ts.map +1 -1
- package/lib/typescript/src/geometry/validation.d.ts +44 -0
- package/lib/typescript/src/geometry/validation.d.ts.map +1 -0
- package/lib/typescript/src/geometry.d.ts +7 -0
- package/lib/typescript/src/geometry.d.ts.map +1 -0
- package/lib/typescript/src/haptics/createGameHaptics.d.ts +3 -0
- package/lib/typescript/src/haptics/createGameHaptics.d.ts.map +1 -0
- package/lib/typescript/src/haptics/errors.d.ts +6 -0
- package/lib/typescript/src/haptics/errors.d.ts.map +1 -0
- package/lib/typescript/src/haptics/index.d.ts +4 -0
- package/lib/typescript/src/haptics/index.d.ts.map +1 -0
- package/lib/typescript/src/haptics/resolver.d.ts +22 -0
- package/lib/typescript/src/haptics/resolver.d.ts.map +1 -0
- package/lib/typescript/src/haptics/types.d.ts +37 -0
- package/lib/typescript/src/haptics/types.d.ts.map +1 -0
- package/lib/typescript/src/haptics.d.ts +8 -0
- package/lib/typescript/src/haptics.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +10 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/particles/createParticleSystem.d.ts +5 -0
- package/lib/typescript/src/particles/createParticleSystem.d.ts.map +1 -0
- package/lib/typescript/src/particles/defineParticleEffect.d.ts +3 -0
- package/lib/typescript/src/particles/defineParticleEffect.d.ts.map +1 -0
- package/lib/typescript/src/particles/errors.d.ts +5 -0
- package/lib/typescript/src/particles/errors.d.ts.map +1 -0
- package/lib/typescript/src/particles/index.d.ts +6 -0
- package/lib/typescript/src/particles/index.d.ts.map +1 -0
- package/lib/typescript/src/particles/sampling.d.ts +54 -0
- package/lib/typescript/src/particles/sampling.d.ts.map +1 -0
- package/lib/typescript/src/particles/types.d.ts +292 -0
- package/lib/typescript/src/particles/types.d.ts.map +1 -0
- package/lib/typescript/src/particles.d.ts +2 -0
- package/lib/typescript/src/particles.d.ts.map +1 -0
- package/lib/typescript/src/react/GameButtonPad.d.ts +84 -0
- package/lib/typescript/src/react/GameButtonPad.d.ts.map +1 -0
- package/lib/typescript/src/react/GamePointerInput.d.ts.map +1 -1
- package/lib/typescript/src/react/GameView.d.ts +27 -1
- package/lib/typescript/src/react/GameView.d.ts.map +1 -1
- package/lib/typescript/src/react/assets/createGameAssetStore.d.ts.map +1 -1
- package/lib/typescript/src/react/assets/useGameAssets.d.ts.map +1 -1
- package/lib/typescript/src/react/bindAppLifecycle.d.ts +7 -1
- package/lib/typescript/src/react/bindAppLifecycle.d.ts.map +1 -1
- package/lib/typescript/src/react/bindGameSession.d.ts.map +1 -1
- package/lib/typescript/src/react/camera2d/GameLayer2D.d.ts +24 -0
- package/lib/typescript/src/react/camera2d/GameLayer2D.d.ts.map +1 -0
- package/lib/typescript/src/react/camera2d/defineGameCamera2D.d.ts +44 -0
- package/lib/typescript/src/react/camera2d/defineGameCamera2D.d.ts.map +1 -0
- package/lib/typescript/src/react/camera2d/usePresentedCameraBinding.d.ts +22 -0
- package/lib/typescript/src/react/camera2d/usePresentedCameraBinding.d.ts.map +1 -0
- package/lib/typescript/src/react/cleanupList.d.ts +21 -0
- package/lib/typescript/src/react/cleanupList.d.ts.map +1 -0
- package/lib/typescript/src/react/instrumentation.d.ts +33 -3
- package/lib/typescript/src/react/instrumentation.d.ts.map +1 -1
- package/lib/typescript/src/react/lifecycleSource.d.ts +21 -0
- package/lib/typescript/src/react/lifecycleSource.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/ParticleView.d.ts +65 -0
- package/lib/typescript/src/react/particles/ParticleView.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/culling.d.ts +70 -0
- package/lib/typescript/src/react/particles/culling.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/index.d.ts +7 -0
- package/lib/typescript/src/react/particles/index.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/spriteXForm.d.ts +28 -0
- package/lib/typescript/src/react/particles/spriteXForm.d.ts.map +1 -0
- package/lib/typescript/src/react/particles/useParticlePresentation.d.ts +48 -0
- package/lib/typescript/src/react/particles/useParticlePresentation.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerBinding.d.ts +38 -8
- package/lib/typescript/src/react/pointerBinding.d.ts.map +1 -1
- package/lib/typescript/src/react/pointerCamera.d.ts +20 -0
- package/lib/typescript/src/react/pointerCamera.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerCoalescer.d.ts +17 -1
- package/lib/typescript/src/react/pointerCoalescer.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/GameSprite.d.ts +3 -10
- package/lib/typescript/src/react/sprites/GameSprite.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/GameWorld2D.d.ts +51 -6
- package/lib/typescript/src/react/sprites/GameWorld2D.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/Sprite.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/SpriteBatch.d.ts +22 -1
- package/lib/typescript/src/react/sprites/SpriteBatch.d.ts.map +1 -1
- package/lib/typescript/src/react/sprites/batchVisibility.d.ts +28 -0
- package/lib/typescript/src/react/sprites/batchVisibility.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/spriteSelection.d.ts +58 -0
- package/lib/typescript/src/react/sprites/spriteSelection.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/spriteTransform.d.ts +27 -12
- package/lib/typescript/src/react/sprites/spriteTransform.d.ts.map +1 -1
- package/lib/typescript/src/react/tilemap/TileMapLayer2D.d.ts +69 -0
- package/lib/typescript/src/react/tilemap/TileMapLayer2D.d.ts.map +1 -0
- package/lib/typescript/src/react/tilemap/tilePresentation.d.ts +217 -0
- package/lib/typescript/src/react/tilemap/tilePresentation.d.ts.map +1 -0
- package/lib/typescript/src/react/useGameSession.d.ts +48 -0
- package/lib/typescript/src/react/useGameSession.d.ts.map +1 -0
- package/lib/typescript/src/react/useGameSessionStatus.d.ts +23 -0
- package/lib/typescript/src/react/useGameSessionStatus.d.ts.map +1 -0
- package/lib/typescript/src/react/viewportBinding.d.ts +5 -1
- package/lib/typescript/src/react/viewportBinding.d.ts.map +1 -1
- package/lib/typescript/src/react.d.ts +18 -1
- package/lib/typescript/src/react.d.ts.map +1 -1
- package/lib/typescript/src/scene/defineScene.d.ts +22 -2
- package/lib/typescript/src/scene/defineScene.d.ts.map +1 -1
- package/lib/typescript/src/scene/types.d.ts +24 -4
- package/lib/typescript/src/scene/types.d.ts.map +1 -1
- package/lib/typescript/src/sprites/sampleSpriteClip.d.ts +26 -2
- package/lib/typescript/src/sprites/sampleSpriteClip.d.ts.map +1 -1
- package/lib/typescript/src/sprites/spriteAnimationState.d.ts +6 -7
- package/lib/typescript/src/sprites/spriteAnimationState.d.ts.map +1 -1
- package/lib/typescript/src/sprites.d.ts +10 -0
- package/lib/typescript/src/sprites.d.ts.map +1 -0
- package/lib/typescript/src/storage/adapters/asyncStorage.d.ts +18 -0
- package/lib/typescript/src/storage/adapters/asyncStorage.d.ts.map +1 -0
- package/lib/typescript/src/storage/adapters/memory.d.ts +16 -0
- package/lib/typescript/src/storage/adapters/memory.d.ts.map +1 -0
- package/lib/typescript/src/storage/errors.d.ts +37 -0
- package/lib/typescript/src/storage/errors.d.ts.map +1 -0
- package/lib/typescript/src/storage/index.d.ts +11 -0
- package/lib/typescript/src/storage/index.d.ts.map +1 -0
- package/lib/typescript/src/storage/schema.d.ts +22 -0
- package/lib/typescript/src/storage/schema.d.ts.map +1 -0
- package/lib/typescript/src/storage/serialization.d.ts +23 -0
- package/lib/typescript/src/storage/serialization.d.ts.map +1 -0
- package/lib/typescript/src/storage/store.d.ts +3 -0
- package/lib/typescript/src/storage/store.d.ts.map +1 -0
- package/lib/typescript/src/storage/types.d.ts +69 -0
- package/lib/typescript/src/storage/types.d.ts.map +1 -0
- package/lib/typescript/src/storage/validation.d.ts +24 -0
- package/lib/typescript/src/storage/validation.d.ts.map +1 -0
- package/lib/typescript/src/storage.d.ts +2 -0
- package/lib/typescript/src/storage.d.ts.map +1 -0
- package/lib/typescript/src/testing.d.ts +1 -0
- package/lib/typescript/src/testing.d.ts.map +1 -1
- package/lib/typescript/src/tilemap/chunkStats.d.ts +14 -0
- package/lib/typescript/src/tilemap/chunkStats.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/definitions.d.ts +38 -0
- package/lib/typescript/src/tilemap/definitions.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/errors.d.ts +7 -0
- package/lib/typescript/src/tilemap/errors.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/index.d.ts +8 -0
- package/lib/typescript/src/tilemap/index.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/movement.d.ts +52 -0
- package/lib/typescript/src/tilemap/movement.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/queries.d.ts +21 -0
- package/lib/typescript/src/tilemap/queries.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/tiledAdapter.d.ts +32 -0
- package/lib/typescript/src/tilemap/tiledAdapter.d.ts.map +1 -0
- package/lib/typescript/src/tilemap/types.d.ts +127 -0
- package/lib/typescript/src/tilemap/types.d.ts.map +1 -0
- package/lib/typescript/src/tilemap.d.ts +2 -0
- package/lib/typescript/src/tilemap.d.ts.map +1 -0
- package/package.json +100 -10
- package/src/assets/defineAssets.ts +31 -5
- package/src/assets.ts +27 -0
- package/src/audio/createGameAudio.ts +749 -0
- package/src/audio/errors.ts +12 -0
- package/src/audio/index.ts +9 -0
- package/src/audio/resolver.ts +74 -0
- package/src/audio/types.ts +47 -0
- package/src/audio.ts +13 -0
- package/src/camera2d/bounds.ts +69 -0
- package/src/camera2d/extents.ts +25 -0
- package/src/camera2d/follow.ts +165 -0
- package/src/camera2d/index.ts +29 -0
- package/src/camera2d/interpolation.ts +113 -0
- package/src/camera2d/shake.ts +90 -0
- package/src/camera2d/transform.ts +148 -0
- package/src/camera2d/types.ts +73 -0
- package/src/camera2d/validation.ts +126 -0
- package/src/camera2d/visibility.ts +181 -0
- package/src/camera2d.ts +6 -0
- package/src/collision2d/colliders.ts +292 -0
- package/src/collision2d/debug.ts +133 -0
- package/src/collision2d/filters.ts +48 -0
- package/src/collision2d/index.ts +74 -0
- package/src/collision2d/intersections.ts +82 -0
- package/src/collision2d/manifolds.ts +191 -0
- package/src/collision2d/segments.ts +176 -0
- package/src/collision2d/spatialHash.ts +211 -0
- package/src/collision2d/sweeps.ts +269 -0
- package/src/collision2d.ts +6 -0
- package/src/core/input/buttonPad.ts +235 -0
- package/src/core/input/createInputBuffer.ts +95 -14
- package/src/core/input/types.ts +7 -0
- package/src/core/session/createGameSession.ts +480 -53
- package/src/core/session/deepFreeze.ts +104 -3
- package/src/core/session/diagnostics.ts +2 -0
- package/src/core/session/types.ts +77 -4
- package/src/definition/defineGame.ts +61 -3
- package/src/definition/types.ts +10 -0
- package/src/events/defineGameEvents.ts +46 -0
- package/src/events/errors.ts +14 -0
- package/src/events/index.ts +14 -0
- package/src/events/payload.ts +234 -0
- package/src/events/seed.ts +33 -0
- package/src/events/types.ts +53 -0
- package/src/events.ts +20 -0
- package/src/geometry/helpers.ts +136 -0
- package/src/geometry/index.ts +14 -0
- package/src/geometry/types.ts +54 -0
- package/src/geometry/validation.ts +131 -0
- package/src/geometry.ts +6 -0
- package/src/haptics/createGameHaptics.ts +214 -0
- package/src/haptics/errors.ts +12 -0
- package/src/haptics/index.ts +3 -0
- package/src/haptics/resolver.ts +58 -0
- package/src/haptics/types.ts +48 -0
- package/src/haptics.ts +7 -0
- package/src/index.ts +37 -1
- package/src/particles/createParticleSystem.ts +505 -0
- package/src/particles/defineParticleEffect.ts +164 -0
- package/src/particles/errors.ts +6 -0
- package/src/particles/index.ts +5 -0
- package/src/particles/sampling.ts +141 -0
- package/src/particles/types.ts +327 -0
- package/src/particles.ts +1 -0
- package/src/react/GameButtonPad.tsx +436 -0
- package/src/react/GamePointerInput.tsx +73 -8
- package/src/react/GameView.tsx +160 -61
- package/src/react/assets/createGameAssetStore.ts +140 -107
- package/src/react/assets/useGameAssets.ts +63 -31
- package/src/react/bindAppLifecycle.ts +55 -19
- package/src/react/bindGameSession.ts +12 -2
- package/src/react/camera2d/GameLayer2D.tsx +43 -0
- package/src/react/camera2d/defineGameCamera2D.ts +59 -0
- package/src/react/camera2d/usePresentedCameraBinding.ts +185 -0
- package/src/react/cleanupList.ts +48 -0
- package/src/react/instrumentation.ts +31 -3
- package/src/react/lifecycleSource.ts +58 -0
- package/src/react/particles/ParticleView.tsx +358 -0
- package/src/react/particles/culling.ts +145 -0
- package/src/react/particles/index.ts +6 -0
- package/src/react/particles/spriteXForm.ts +72 -0
- package/src/react/particles/useParticlePresentation.ts +261 -0
- package/src/react/pointerBinding.ts +74 -16
- package/src/react/pointerCamera.ts +33 -0
- package/src/react/pointerCoalescer.ts +36 -10
- package/src/react/sprites/GameSprite.tsx +4 -33
- package/src/react/sprites/GameWorld2D.tsx +113 -7
- package/src/react/sprites/Sprite.tsx +51 -72
- package/src/react/sprites/SpriteBatch.tsx +74 -22
- package/src/react/sprites/batchVisibility.ts +76 -0
- package/src/react/sprites/spriteSelection.ts +133 -0
- package/src/react/sprites/spriteTransform.ts +46 -26
- package/src/react/tilemap/TileMapLayer2D.tsx +274 -0
- package/src/react/tilemap/tilePresentation.ts +491 -0
- package/src/react/useGameSession.ts +90 -0
- package/src/react/useGameSessionStatus.ts +53 -0
- package/src/react/viewportBinding.ts +5 -1
- package/src/react.ts +18 -1
- package/src/scene/defineScene.ts +47 -5
- package/src/scene/types.ts +37 -3
- package/src/sprites/sampleSpriteClip.ts +82 -14
- package/src/sprites/spriteAnimationState.ts +29 -25
- package/src/sprites.ts +22 -0
- package/src/storage/adapters/asyncStorage.ts +77 -0
- package/src/storage/adapters/memory.ts +58 -0
- package/src/storage/errors.ts +88 -0
- package/src/storage/index.ts +18 -0
- package/src/storage/schema.ts +147 -0
- package/src/storage/serialization.ts +248 -0
- package/src/storage/store.ts +380 -0
- package/src/storage/types.ts +76 -0
- package/src/storage/validation.ts +102 -0
- package/src/storage.ts +1 -0
- package/src/testing.ts +4 -0
- package/src/tilemap/chunkStats.ts +24 -0
- package/src/tilemap/definitions.ts +327 -0
- package/src/tilemap/errors.ts +11 -0
- package/src/tilemap/index.ts +10 -0
- package/src/tilemap/movement.ts +368 -0
- package/src/tilemap/queries.ts +136 -0
- package/src/tilemap/tiledAdapter.ts +165 -0
- package/src/tilemap/types.ts +119 -0
- package/src/tilemap.ts +1 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared sprite frame selection (GS-ANIMATION-01).
|
|
5
|
+
*
|
|
6
|
+
* The single headless selection contract behind `Sprite`'s rect modifier
|
|
7
|
+
* and `GameSprite`'s frame-name derivation: an explicit frame wins,
|
|
8
|
+
* otherwise clip + elapsed time resolve through the pure sampler. Absent
|
|
9
|
+
* selection (nothing chosen yet) presents nothing without throwing;
|
|
10
|
+
* invalid clips and frames fail clearly instead of masking bad data.
|
|
11
|
+
*
|
|
12
|
+
* Headless-safe: only type imports plus the pure sampler, so the same
|
|
13
|
+
* functions execute identically in tests and on the UI runtime. Every
|
|
14
|
+
* function carries the worklet directive for UI execution; the reachable
|
|
15
|
+
* call graph is plain arithmetic plus plain `Error` construction
|
|
16
|
+
* (GS-ANIMATION-02).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { spriteFrameNameForClip } from "../../sprites/sampleSpriteClip.js";
|
|
20
|
+
|
|
21
|
+
/** A static value or a UI-runtime shared value carrying it. Shared-value
|
|
22
|
+
* payloads list both the exact and the undefined-extended shapes because
|
|
23
|
+
* shared values are invariant in their payload. */
|
|
24
|
+
|
|
25
|
+
/** Selection props as the Sprite/GameSprite call sites declare them. */
|
|
26
|
+
|
|
27
|
+
/** The discrete selection inputs for one sprite (all optional). */
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the source rectangle for a selection.
|
|
31
|
+
*
|
|
32
|
+
* Returns `undefined` for absent selection (present nothing); throws for
|
|
33
|
+
* unknown clips and frames.
|
|
34
|
+
*/
|
|
35
|
+
export function selectSpriteFrameRect(source, selection) {
|
|
36
|
+
'worklet';
|
|
37
|
+
|
|
38
|
+
if (source.descriptor.kind === 'image') {
|
|
39
|
+
const image = source;
|
|
40
|
+
return {
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0,
|
|
43
|
+
width: image.width,
|
|
44
|
+
height: image.height
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const sheet = source;
|
|
48
|
+
let name = selection.frame;
|
|
49
|
+
if (name === undefined) {
|
|
50
|
+
if (selection.clip === undefined) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
name = spriteFrameNameForClip(sheet.descriptor.animations, selection.clip, selection.elapsedMs ?? 0);
|
|
54
|
+
}
|
|
55
|
+
const rect = sheet.frames[name];
|
|
56
|
+
if (rect === undefined) {
|
|
57
|
+
throw new Error(`frame ${JSON.stringify(name)} does not belong to this sprite sheet (loaded frames: ${Object.keys(sheet.frames).join(', ')})`);
|
|
58
|
+
}
|
|
59
|
+
return rect;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Materialize mixed static/shared selection props into one plain selection
|
|
64
|
+
* (GS-SPRITE-03): every worklet that resolves frames — rect, transform, and
|
|
65
|
+
* Group correction — starts from this single helper, so clip-driven frame
|
|
66
|
+
* changes reach every consumer coherently.
|
|
67
|
+
*/
|
|
68
|
+
export function materializeSpriteSelection(frame, clip, elapsedMs) {
|
|
69
|
+
'worklet';
|
|
70
|
+
|
|
71
|
+
const selection = {};
|
|
72
|
+
const frameValue = typeof frame === 'string' ? frame : frame?.value;
|
|
73
|
+
if (frameValue !== undefined) {
|
|
74
|
+
selection.frame = frameValue;
|
|
75
|
+
}
|
|
76
|
+
const clipValue = typeof clip === 'string' ? clip : clip?.value;
|
|
77
|
+
if (clipValue !== undefined) {
|
|
78
|
+
selection.clip = clipValue;
|
|
79
|
+
}
|
|
80
|
+
const elapsedValue = typeof elapsedMs === 'number' ? elapsedMs : elapsedMs?.value;
|
|
81
|
+
if (elapsedValue !== undefined) {
|
|
82
|
+
selection.elapsedMs = elapsedValue;
|
|
83
|
+
}
|
|
84
|
+
return selection;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** A Skia rect-buffer entry (structural: only `setXYWH` is used). */
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Apply a selection to a rect-buffer entry: the component callback logic
|
|
91
|
+
* behind `Sprite`'s modifier, executed here so tests observe it directly.
|
|
92
|
+
*/
|
|
93
|
+
export function applySpriteFrameSelection(rect, source, selection) {
|
|
94
|
+
'worklet';
|
|
95
|
+
|
|
96
|
+
const resolved = selectSpriteFrameRect(source, selection);
|
|
97
|
+
if (resolved === undefined) {
|
|
98
|
+
rect.setXYWH(0, 0, 0, 0);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
rect.setXYWH(resolved.x, resolved.y, resolved.width, resolved.height);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=spriteSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["spriteFrameNameForClip","selectSpriteFrameRect","source","selection","descriptor","kind","image","x","y","width","height","sheet","name","frame","undefined","clip","animations","elapsedMs","rect","frames","Error","JSON","stringify","Object","keys","join","materializeSpriteSelection","frameValue","value","clipValue","elapsedValue","applySpriteFrameSelection","resolved","setXYWH"],"sourceRoot":"../../../../src","sources":["react/sprites/spriteSelection.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,sBAAsB,QAAQ,mCAAgC;;AAGvE;AACA;AACA;;AAGA;;AAQA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,MAAuC,EACvCC,SAA0B,EACG;EAC7B,SAAS;;EACT,IAAID,MAAM,CAACE,UAAU,CAACC,IAAI,KAAK,OAAO,EAAE;IACtC,MAAMC,KAAK,GAAGJ,MAAqB;IACnC,OAAO;MAAEK,CAAC,EAAE,CAAC;MAAEC,CAAC,EAAE,CAAC;MAAEC,KAAK,EAAEH,KAAK,CAACG,KAAK;MAAEC,MAAM,EAAEJ,KAAK,CAACI;IAAO,CAAC;EACjE;EACA,MAAMC,KAAK,GAAGT,MAA2B;EACzC,IAAIU,IAAI,GAAGT,SAAS,CAACU,KAAK;EAC1B,IAAID,IAAI,KAAKE,SAAS,EAAE;IACtB,IAAIX,SAAS,CAACY,IAAI,KAAKD,SAAS,EAAE;MAChC,OAAOA,SAAS;IAClB;IACAF,IAAI,GAAGZ,sBAAsB,CAC3BW,KAAK,CAACP,UAAU,CAACY,UAAU,EAC3Bb,SAAS,CAACY,IAAI,EACdZ,SAAS,CAACc,SAAS,IAAI,CACzB,CAAC;EACH;EACA,MAAMC,IAAI,GAAGP,KAAK,CAACQ,MAAM,CAACP,IAAI,CAAC;EAC/B,IAAIM,IAAI,KAAKJ,SAAS,EAAE;I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F;EACAf,IAAI,CAACe,OAAO,CAACD,QAAQ,CAACzB,CAAC,EAAEyB,QAAQ,CAACxB,CAAC,EAAEwB,QAAQ,CAACvB,KAAK,EAAEuB,QAAQ,CAACtB,MAAM,CAAC;AACvE","ignoreList":[]}
|
|
@@ -47,19 +47,26 @@ export function resolveSpriteFrameRect(source, frame) {
|
|
|
47
47
|
* `[0, 0, frameWidth, frameHeight]` in local space and the documented pivot
|
|
48
48
|
* order is:
|
|
49
49
|
*
|
|
50
|
-
* M = T(x, y) · R(rotation) ·
|
|
50
|
+
* M = T(x, y) · R(rotation) · S(scaleX, scaleY) · T(-anchor)
|
|
51
51
|
*
|
|
52
|
-
* i.e. scale and explicit flips happen around the anchor
|
|
53
|
-
* rotates around the anchor at the world
|
|
54
|
-
*
|
|
55
|
-
*
|
|
52
|
+
* i.e. uniform scale and explicit flips happen around the anchor in the
|
|
53
|
+
* local frame, then the frame rotates around the anchor at the world
|
|
54
|
+
* position. The invariant: the anchor maps to `(x, y)` under every scale,
|
|
55
|
+
* rotation, and flip (GS-SPRITE-01).
|
|
56
|
+
*
|
|
57
|
+
* Split across Skia's retained primitives (the Atlas RSXform is innermost,
|
|
58
|
+
* the wrapping Group is outermost): the RSXform carries `T·R·S` with the
|
|
59
|
+
* pivot pre-compensated, so no-flip sprites need no Group transform at
|
|
60
|
+
* all; reflection — which an RSXform cannot express — is isolated in the
|
|
61
|
+
* Group as a mirror that fixes the world anchor
|
|
62
|
+
* (`T(x,y)·R·F·R⁻¹·T(−x,−y)`).
|
|
56
63
|
*/
|
|
57
64
|
|
|
58
65
|
/** A sprite's presentation input; numbers or UI-runtime animated values. */
|
|
59
66
|
|
|
60
67
|
/** The computed RSXform (rotation + position, pivot-compensated). */
|
|
61
68
|
|
|
62
|
-
/** A Skia-compatible 3x3 transform element list. */
|
|
69
|
+
/** A Skia-compatible 3x3 transform element list (rotation in radians). */
|
|
63
70
|
|
|
64
71
|
function readNumber(value) {
|
|
65
72
|
'worklet';
|
|
@@ -73,9 +80,10 @@ function readBoolean(value) {
|
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
/**
|
|
76
|
-
* The RSXform for the atlas path:
|
|
77
|
-
* compensated (`
|
|
78
|
-
*
|
|
83
|
+
* The RSXform for the atlas path: `T(x,y)·R·S` with the pivot
|
|
84
|
+
* pre-compensated (`t = p − s·R·pivot`), so the anchor lands exactly on
|
|
85
|
+
* `(x, y)` (GS-SPRITE-01/02). Uniform scale is encoded in the
|
|
86
|
+
* coefficients; the batch path shares this helper and needs no Group.
|
|
79
87
|
*/
|
|
80
88
|
export function computeSpriteRsxform(input) {
|
|
81
89
|
'worklet';
|
|
@@ -83,43 +91,56 @@ export function computeSpriteRsxform(input) {
|
|
|
83
91
|
const x = readNumber(input.x);
|
|
84
92
|
const y = readNumber(input.y);
|
|
85
93
|
const rotation = readNumber(input.rotation);
|
|
94
|
+
const scale = readNumber(input.scale);
|
|
86
95
|
const pivotX = input.anchorX * input.frameWidth;
|
|
87
96
|
const pivotY = input.anchorY * input.frameHeight;
|
|
88
97
|
const cos = Math.cos(rotation);
|
|
89
98
|
const sin = Math.sin(rotation);
|
|
90
99
|
return {
|
|
91
|
-
scos: cos,
|
|
92
|
-
ssin: sin,
|
|
93
|
-
tx: x - pivotX * cos
|
|
94
|
-
ty: y - pivotX * sin
|
|
100
|
+
scos: scale * cos,
|
|
101
|
+
ssin: scale * sin,
|
|
102
|
+
tx: x - scale * (pivotX * cos - pivotY * sin),
|
|
103
|
+
ty: y - scale * (pivotX * sin + pivotY * cos)
|
|
95
104
|
};
|
|
96
105
|
}
|
|
97
106
|
|
|
98
107
|
/**
|
|
99
|
-
* The
|
|
100
|
-
*
|
|
101
|
-
*
|
|
108
|
+
* The reflection part as a Skia transform element list, outermost first.
|
|
109
|
+
*
|
|
110
|
+
* Without flips the RSXform alone carries the transform, so the correction
|
|
111
|
+
* is empty (identity). With flips it is the anchor-fixing mirror
|
|
112
|
+
* `T(x,y)·R·F·R⁻¹·T(−x,−y)`: mirroring about the rotated anchor axes while
|
|
113
|
+
* the world anchor stays fixed. Depends on position and rotation (not just
|
|
114
|
+
* the pivot), so callers must derive it on the UI runtime from live values
|
|
115
|
+
* — never memoize it from stale React-render reads (GS-SPRITE-01).
|
|
102
116
|
*/
|
|
103
117
|
export function spriteGroupCorrection(input) {
|
|
104
118
|
'worklet';
|
|
105
119
|
|
|
106
|
-
const scale = readNumber(input.scale);
|
|
107
120
|
const flipX = readBoolean(input.flipX);
|
|
108
121
|
const flipY = readBoolean(input.flipY);
|
|
109
|
-
|
|
110
|
-
|
|
122
|
+
if (!flipX && !flipY) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
const x = readNumber(input.x);
|
|
126
|
+
const y = readNumber(input.y);
|
|
127
|
+
const rotation = readNumber(input.rotation);
|
|
111
128
|
return [{
|
|
112
|
-
translateX:
|
|
129
|
+
translateX: x
|
|
130
|
+
}, {
|
|
131
|
+
translateY: y
|
|
132
|
+
}, {
|
|
133
|
+
rotate: rotation
|
|
113
134
|
}, {
|
|
114
|
-
|
|
135
|
+
scaleX: flipX ? -1 : 1
|
|
115
136
|
}, {
|
|
116
|
-
|
|
137
|
+
scaleY: flipY ? -1 : 1
|
|
117
138
|
}, {
|
|
118
|
-
|
|
139
|
+
rotate: -rotation
|
|
119
140
|
}, {
|
|
120
|
-
translateX: -
|
|
141
|
+
translateX: -x
|
|
121
142
|
}, {
|
|
122
|
-
translateY: -
|
|
143
|
+
translateY: -y
|
|
123
144
|
}];
|
|
124
145
|
}
|
|
125
146
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["resolveSpriteFrameRect","source","frame","descriptor","kind","image","x","y","width","height","sheet","undefined","firstAnimationName","Object","keys","animations","firstAnimation","firstFrameName","frames","baseline","rect","Error","JSON","stringify","join","readNumber","value","readBoolean","computeSpriteRsxform","input","rotation","pivotX","anchorX","frameWidth","pivotY","anchorY","frameHeight","cos","Math","sin","scos","ssin","tx","ty","spriteGroupCorrection","
|
|
1
|
+
{"version":3,"names":["resolveSpriteFrameRect","source","frame","descriptor","kind","image","x","y","width","height","sheet","undefined","firstAnimationName","Object","keys","animations","firstAnimation","firstFrameName","frames","baseline","rect","Error","JSON","stringify","join","readNumber","value","readBoolean","computeSpriteRsxform","input","rotation","scale","pivotX","anchorX","frameWidth","pivotY","anchorY","frameHeight","cos","Math","sin","scos","ssin","tx","ty","spriteGroupCorrection","flipX","flipY","translateX","translateY","rotate","scaleX","scaleY","spriteAnchorWorld"],"sourceRoot":"../../../../src","sources":["react/sprites/spriteTransform.ts"],"mappings":";;AAEA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,sBAAsBA,CACpCC,MAAuC,EACvCC,KAAyB,EACR;EACjB,IAAID,MAAM,CAACE,UAAU,CAACC,IAAI,KAAK,OAAO,EAAE;IACtC,MAAMC,KAAK,GAAGJ,MAAqB;IACnC,OAAO;MAAEK,CAAC,EAAE,CAAC;MAAEC,CAAC,EAAE,CAAC;MAAEC,KAAK,EAAEH,KAAK,CAACG,KAAK;MAAEC,MAAM,EAAEJ,KAAK,CAACI;IAAO,CAAC;EACjE;EACA,MAAMC,KAAK,GAAGT,MAA2B;EACzC,IAAIC,KAAK,KAAKS,SAAS,EAAE;IACvB,MAAMC,kBAAkB,GAAGC,MAAM,CAACC,IAAI,CAACJ,KAAK,CAACP,UAAU,CAACY,UAAU,CAAC,CAAC,CAAC,CAAC;IACtE,MAAMC,cAAc,GAClBJ,kBAAkB,KAAKD,SAAS,GAC5BA,SAAS,GACTD,KAAK,CAACP,UAAU,CAACY,UAAU,CAACH,kBAAkB,CAAC;IACrD,MAAMK,cAAc,GAAGD,cAAc,EAAEE,MAAM,CAAC,CAAC,CAAC;IAChD,MAAMC,QAAQ,GACZF,cAAc,KAAKN,SAAS,GAAGA,SAAS,GAAGD,KAAK,CAACQ,MAAM,CAACD,cAAc,CAAC;IACzE,OAAOE,QAAQ,IAAI;MAAEb,CAAC,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M,MAAM,EAAEL,KAAK,GAAG,CAAC,CAAC,GAAG;EAAE,CAAC,EAC1B;IAAEG,MAAM,EAAE,CAACpB;EAAS,CAAC,EACrB;IAAEkB,UAAU,EAAE,CAAC1C;EAAE,CAAC,EAClB;IAAE2C,UAAU,EAAE,CAAC1C;EAAE,CAAC,CACnB;AACH;;AAEA;AACA,OAAO,SAAS8C,iBAAiBA,CAACxB,KAA2B,EAG3D;EACA,SAAS;;EACT,OAAO;IACLvB,CAAC,EAAEmB,UAAU,CAACI,KAAK,CAACvB,CAAC,CAAC;IACtBC,CAAC,EAAEkB,UAAU,CAACI,KAAK,CAACtB,CAAC;EACvB,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useContext, useMemo, useCallback } from 'react';
|
|
4
|
+
import { Atlas, Group, useRectBuffer, useRSXformBuffer } from '@shopify/react-native-skia';
|
|
5
|
+
import { useDerivedValue, useSharedValue } from 'react-native-reanimated';
|
|
6
|
+
import { scheduleOnRN } from 'react-native-worklets';
|
|
7
|
+
import { GameWorldContext, layerParallaxTransform2D } from "../sprites/GameWorld2D.js";
|
|
8
|
+
import { buildFrameTable, buildTileWindowSnapshot, bindingGeneration, updateTileLayerUI, EMPTY_TILE_WINDOW } from "./tilePresentation.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
/**
|
|
11
|
+
* Stable-topology Atlas tile layer (T16.4, reworked per T16-F3/F4/RF1/RF2).
|
|
12
|
+
*
|
|
13
|
+
* One React node per layer. The slot buffer is sized from the passed
|
|
14
|
+
* surface bounds + minZoom + overscan + cell size — NOT from map
|
|
15
|
+
* dimensions. The worklet never touches the map value, `layer.data`, or a
|
|
16
|
+
* JS `Map`:
|
|
17
|
+
*
|
|
18
|
+
* - Frame rectangles are pre-resolved into a flat numeric table at bind
|
|
19
|
+
* time (validated: missing frames and cell/frame size mismatches throw
|
|
20
|
+
* structured bind errors).
|
|
21
|
+
* - A bounded window snapshot (ids sized by slot capacity) is built on JS
|
|
22
|
+
* and transferred via a shared value ONLY when the visible cell span
|
|
23
|
+
* outgrows the current window; requests cross to React through
|
|
24
|
+
* `scheduleOnRN` (Reanimated 4 / react-native-worklets), and camera
|
|
25
|
+
* interpolation inside the window is allocation-free scalar math.
|
|
26
|
+
* - Culling bounds derive from the presented camera (center/zoom/rotation)
|
|
27
|
+
* with the SAME parallax factor applied to the visual transform and the
|
|
28
|
+
* bounds; without a presented camera the viewport-only world path applies.
|
|
29
|
+
* - Culling here can never affect simulation: collision queries read full
|
|
30
|
+
* layer data through the private chunk index regardless of visibility.
|
|
31
|
+
*/
|
|
32
|
+
export function TileMapLayer2D({
|
|
33
|
+
map,
|
|
34
|
+
layer,
|
|
35
|
+
source,
|
|
36
|
+
width,
|
|
37
|
+
height,
|
|
38
|
+
overscan = 1,
|
|
39
|
+
parallax,
|
|
40
|
+
minZoom = 1
|
|
41
|
+
}) {
|
|
42
|
+
const world = useContext(GameWorldContext);
|
|
43
|
+
const camera = world?.camera ?? null;
|
|
44
|
+
const viewportSV = world?.viewport ?? null;
|
|
45
|
+
const layerData = map.layerById[layer];
|
|
46
|
+
if (layerData === undefined) {
|
|
47
|
+
throw new Error(`[rn-gamekit/tilemap] layer "${layer}" does not exist on this map`);
|
|
48
|
+
}
|
|
49
|
+
if (!(minZoom > 0) || !Number.isFinite(minZoom)) {
|
|
50
|
+
throw new Error(`[rn-gamekit/tilemap] minZoom must be a finite number > 0; got ${String(minZoom)}`);
|
|
51
|
+
}
|
|
52
|
+
if (!Number.isFinite(width) || width <= 0) {
|
|
53
|
+
throw new Error(`[rn-gamekit/tilemap] width must be a finite number > 0; got ${String(width)}`);
|
|
54
|
+
}
|
|
55
|
+
if (!Number.isFinite(height) || height <= 0) {
|
|
56
|
+
throw new Error(`[rn-gamekit/tilemap] height must be a finite number > 0; got ${String(height)}`);
|
|
57
|
+
}
|
|
58
|
+
if (!Number.isFinite(overscan) || overscan < 0 || !Number.isInteger(overscan)) {
|
|
59
|
+
throw new Error(`[rn-gamekit/tilemap] overscan must be a finite integer >= 0; got ${String(overscan)}`);
|
|
60
|
+
}
|
|
61
|
+
const px = parallax?.x ?? 1;
|
|
62
|
+
const py = parallax?.y ?? 1;
|
|
63
|
+
if (!Number.isFinite(px)) {
|
|
64
|
+
throw new Error(`[rn-gamekit/tilemap] parallax.x must be a finite number; got ${String(px)}`);
|
|
65
|
+
}
|
|
66
|
+
if (!Number.isFinite(py)) {
|
|
67
|
+
throw new Error(`[rn-gamekit/tilemap] parallax.y must be a finite number; got ${String(py)}`);
|
|
68
|
+
}
|
|
69
|
+
const cw = map.cellSize.width;
|
|
70
|
+
const ch = map.cellSize.height;
|
|
71
|
+
const originX = map.origin.x;
|
|
72
|
+
const originY = map.origin.y;
|
|
73
|
+
// Pad world is scalar based on the larger cell dimension (T16-SF2
|
|
74
|
+
// overscan contract). Capacity and bounds must share this exact scalar
|
|
75
|
+
// so they cannot drift for non-square cells.
|
|
76
|
+
const padWorld = overscan * Math.max(cw, ch);
|
|
77
|
+
// px/py already validated above
|
|
78
|
+
|
|
79
|
+
// Resolve frames ONCE at bind time (structured errors for missing
|
|
80
|
+
// frames and frame/cell size mismatches — T16-F3).
|
|
81
|
+
const frameTable = useMemo(() => buildFrameTable(map.tileset, source.frames, cw, ch), [map, source, cw, ch]);
|
|
82
|
+
|
|
83
|
+
// Slot capacity covers the worst rotated AABB at minZoom (T16-SF2):
|
|
84
|
+
// conservative extents approach the viewport diagonal at 45 degrees.
|
|
85
|
+
// Must use the same padWorld as writeLayerVisibleBounds so non-square
|
|
86
|
+
// cells (e.g. 8x64) do not under-size one axis.
|
|
87
|
+
const diagonal = Math.hypot(width, height);
|
|
88
|
+
const slotsX = Math.ceil((diagonal / minZoom + 2 * padWorld) / cw) + 1;
|
|
89
|
+
const slotsY = Math.ceil((diagonal / minZoom + 2 * padWorld) / ch) + 1;
|
|
90
|
+
const capacity = slotsX * slotsY;
|
|
91
|
+
const rects = useRectBuffer(capacity, rect => {
|
|
92
|
+
'worklet';
|
|
93
|
+
|
|
94
|
+
rect.setXYWH(0, 0, 0, 0);
|
|
95
|
+
});
|
|
96
|
+
const xforms = useRSXformBuffer(capacity, xform => {
|
|
97
|
+
'worklet';
|
|
98
|
+
|
|
99
|
+
xform.set(1, 0, 0, 0);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Bounded transferred window + guards (T16-F4, T16-SF1). The scratch
|
|
103
|
+
// bounds object is written by the worklet every frame — one stable
|
|
104
|
+
// allocation, never per-frame objects (T16-RF2).
|
|
105
|
+
const windowSV = useSharedValue(EMPTY_TILE_WINDOW);
|
|
106
|
+
// GS-TILE-01: one pending request per BINDING (not per component): the
|
|
107
|
+
// stored generation lets a new binding request even when an old binding
|
|
108
|
+
// left its mark behind.
|
|
109
|
+
const pendingGenSV = useSharedValue(-1);
|
|
110
|
+
const warnedCapacitySV = useSharedValue(false);
|
|
111
|
+
const capacityWarnPendingSV = useSharedValue(false);
|
|
112
|
+
|
|
113
|
+
// GS-TILE-01: binding identity from everything that defines what a
|
|
114
|
+
// window shows — map, layer, frame source, cell size, and
|
|
115
|
+
// capacity-affecting configuration. A fresh identity mints a fresh
|
|
116
|
+
// generation; windows and requests stamped with older generations are
|
|
117
|
+
// ignored, never displayed.
|
|
118
|
+
// Binding-affecting inputs enumerated deliberately: equivalent values
|
|
119
|
+
// must not remint the identity (no reload churn), and any omitted input
|
|
120
|
+
// would reuse a stale window.
|
|
121
|
+
const bindingKey = useMemo(() => ({}), [map, layer, source.frames, cw, ch, overscan, capacity, px, py]);
|
|
122
|
+
const generation = bindingGeneration(bindingKey);
|
|
123
|
+
|
|
124
|
+
// JS handler (React-owned): builds the next bounded snapshot for the
|
|
125
|
+
// requested range. Delivered via scheduleOnRN from the worklet (RF1).
|
|
126
|
+
// GS-TILE-01: the scheduled generation is checked before publishing, and
|
|
127
|
+
// the published window is stamped — the update refuses windows whose
|
|
128
|
+
// stamp differs from the live binding, so late deliveries converge by
|
|
129
|
+
// re-requesting instead of displaying stale tiles.
|
|
130
|
+
const requestWindow = useCallback((gen, x0, y0, x1, y1) => {
|
|
131
|
+
if (gen !== generation) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// Pad by the overscan so small camera motions don't re-request.
|
|
135
|
+
const snapshot = buildTileWindowSnapshot(map, layerData.id, x0 - overscan, y0 - overscan, x1 + overscan, y1 + overscan, frameTable);
|
|
136
|
+
windowSV.value = Object.freeze({
|
|
137
|
+
...snapshot,
|
|
138
|
+
gen
|
|
139
|
+
});
|
|
140
|
+
if (pendingGenSV.value === gen) {
|
|
141
|
+
pendingGenSV.value = -1;
|
|
142
|
+
}
|
|
143
|
+
}, [map, layerData.id, overscan, frameTable, generation, windowSV, pendingGenSV]);
|
|
144
|
+
|
|
145
|
+
// One-shot RN-side diagnostic when a presented camera zooms beyond the
|
|
146
|
+
// declared capacity (T16-RF2): the layer hides instead of under-filling.
|
|
147
|
+
// Uses its own pending guard so the warning never blocks window requests
|
|
148
|
+
// (T16-SF1).
|
|
149
|
+
const onBeyondCapacity = useCallback(() => {
|
|
150
|
+
capacityWarnPendingSV.value = false;
|
|
151
|
+
if (!warnedCapacitySV.value) {
|
|
152
|
+
warnedCapacitySV.value = true;
|
|
153
|
+
console.warn('[rn-gamekit/tilemap] presented camera zoom is below minZoom; tile layer hides until the camera returns inside the declared capacity');
|
|
154
|
+
}
|
|
155
|
+
}, [warnedCapacitySV, capacityWarnPendingSV]);
|
|
156
|
+
|
|
157
|
+
// originX/Y and padWorld already defined above for capacity sizing
|
|
158
|
+
|
|
159
|
+
// GS-TILE-01: the update body lives in `updateTileLayerUI` with an
|
|
160
|
+
// explicit scalar-only parameter list — the worklet closure provably
|
|
161
|
+
// carries no map, layer, or frame-table objects (only layer dims and the
|
|
162
|
+
// binding generation). requestWindow's closure stays on the JS side.
|
|
163
|
+
useDerivedValue(() => {
|
|
164
|
+
'worklet';
|
|
165
|
+
|
|
166
|
+
return updateTileLayerUI({
|
|
167
|
+
camera: camera,
|
|
168
|
+
viewport: viewportSV,
|
|
169
|
+
window: windowSV,
|
|
170
|
+
pendingGen: pendingGenSV,
|
|
171
|
+
warnedCapacity: warnedCapacitySV,
|
|
172
|
+
capacityWarnPending: capacityWarnPendingSV,
|
|
173
|
+
rects,
|
|
174
|
+
xforms,
|
|
175
|
+
requestWindow,
|
|
176
|
+
scheduleOnRN: fn => scheduleOnRN(fn),
|
|
177
|
+
onBeyondCapacity,
|
|
178
|
+
generation,
|
|
179
|
+
capacity,
|
|
180
|
+
originX,
|
|
181
|
+
originY,
|
|
182
|
+
cw,
|
|
183
|
+
ch,
|
|
184
|
+
layerWidth: layerData.width,
|
|
185
|
+
layerHeight: layerData.height,
|
|
186
|
+
padWorld,
|
|
187
|
+
px,
|
|
188
|
+
py,
|
|
189
|
+
minZoom
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// Coherent parallax: the visual correction uses the SAME factor as the
|
|
194
|
+
// culling bounds above, so callers never wrap this component in an outer
|
|
195
|
+
// GameLayer2D (T16-RF2). At factor 1 no transform applies.
|
|
196
|
+
const visualTransform = useDerivedValue(() => {
|
|
197
|
+
'worklet';
|
|
198
|
+
|
|
199
|
+
if (px === 1 && py === 1) {
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
return layerParallaxTransform2D(camera?.value, viewportSV?.value, px, py);
|
|
203
|
+
});
|
|
204
|
+
const atlas = /*#__PURE__*/_jsx(Atlas, {
|
|
205
|
+
image: source.image,
|
|
206
|
+
sprites: rects,
|
|
207
|
+
transforms: xforms
|
|
208
|
+
});
|
|
209
|
+
if (px === 1 && py === 1) {
|
|
210
|
+
return atlas;
|
|
211
|
+
}
|
|
212
|
+
return /*#__PURE__*/_jsx(Group, {
|
|
213
|
+
transform: visualTransform,
|
|
214
|
+
children: atlas
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=TileMapLayer2D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContext","useMemo","useCallback","Atlas","Group","useRectBuffer","useRSXformBuffer","useDerivedValue","useSharedValue","scheduleOnRN","GameWorldContext","layerParallaxTransform2D","buildFrameTable","buildTileWindowSnapshot","bindingGeneration","updateTileLayerUI","EMPTY_TILE_WINDOW","jsx","_jsx","TileMapLayer2D","map","layer","source","width","height","overscan","parallax","minZoom","world","camera","viewportSV","viewport","layerData","layerById","undefined","Error","Number","isFinite","String","isInteger","px","x","py","y","cw","cellSize","ch","originX","origin","originY","padWorld","Math","max","frameTable","tileset","frames","diagonal","hypot","slotsX","ceil","slotsY","capacity","rects","rect","setXYWH","xforms","xform","set","windowSV","pendingGenSV","warnedCapacitySV","capacityWarnPendingSV","bindingKey","generation","requestWindow","gen","x0","y0","x1","y1","snapshot","id","value","Object","freeze","onBeyondCapacity","console","warn","window","pendingGen","warnedCapacity","capacityWarnPending","fn","layerWidth","layerHeight","visualTransform","atlas","image","sprites","transforms","transform","children"],"sourceRoot":"../../../../src","sources":["react/tilemap/TileMapLayer2D.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,OAAO,EAAEC,WAAW,QAAQ,OAAO;AACxD,SACEC,KAAK,EACLC,KAAK,EACLC,aAAa,EACbC,gBAAgB,QACX,4BAA4B;AACnC,SAASC,eAAe,EAAEC,cAAc,QAA0B,yBAAyB;AAC3F,SAASC,YAAY,QAAQ,uBAAuB;AAGpD,SAASC,gBAAgB,EAAEC,wBAAwB,QAAQ,2BAAwB;AAInF,SACEC,eAAe,EACfC,uBAAuB,EACvBC,iBAAiB,EACjBC,iBAAiB,EACjBC,iBAAiB,QAGZ,uBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAsC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAc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