fraxel 0.1.0-alpha.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/dist/animation/easing.d.ts +29 -0
- package/dist/animation/easing.d.ts.map +1 -0
- package/dist/animation/easing.js +50 -0
- package/dist/animation/easing.js.map +1 -0
- package/dist/animation/index.d.ts +7 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/animation/index.js +7 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/animation/multiple.d.ts +26 -0
- package/dist/animation/multiple.d.ts.map +1 -0
- package/dist/animation/multiple.js +27 -0
- package/dist/animation/multiple.js.map +1 -0
- package/dist/animation/properties.d.ts +30 -0
- package/dist/animation/properties.d.ts.map +1 -0
- package/dist/animation/properties.js +32 -0
- package/dist/animation/properties.js.map +1 -0
- package/dist/animation/sequences.d.ts +30 -0
- package/dist/animation/sequences.d.ts.map +1 -0
- package/dist/animation/sequences.js +50 -0
- package/dist/animation/sequences.js.map +1 -0
- package/dist/animation/sprite-sheet.d.ts +81 -0
- package/dist/animation/sprite-sheet.d.ts.map +1 -0
- package/dist/animation/sprite-sheet.js +103 -0
- package/dist/animation/sprite-sheet.js.map +1 -0
- package/dist/animation/tween.d.ts +78 -0
- package/dist/animation/tween.d.ts.map +1 -0
- package/dist/animation/tween.js +103 -0
- package/dist/animation/tween.js.map +1 -0
- package/dist/assets/index.d.ts +6 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/assets/index.js +5 -0
- package/dist/assets/index.js.map +1 -0
- package/dist/assets/load-sound.d.ts +17 -0
- package/dist/assets/load-sound.d.ts.map +1 -0
- package/dist/assets/load-sound.js +35 -0
- package/dist/assets/load-sound.js.map +1 -0
- package/dist/assets/load-texture.d.ts +12 -0
- package/dist/assets/load-texture.d.ts.map +1 -0
- package/dist/assets/load-texture.js +40 -0
- package/dist/assets/load-texture.js.map +1 -0
- package/dist/assets/loader.d.ts +59 -0
- package/dist/assets/loader.d.ts.map +1 -0
- package/dist/assets/loader.js +65 -0
- package/dist/assets/loader.js.map +1 -0
- package/dist/assets/texture.d.ts +36 -0
- package/dist/assets/texture.d.ts.map +1 -0
- package/dist/assets/texture.js +49 -0
- package/dist/assets/texture.js.map +1 -0
- package/dist/audio/audio-context.d.ts +14 -0
- package/dist/audio/audio-context.d.ts.map +1 -0
- package/dist/audio/audio-context.js +20 -0
- package/dist/audio/audio-context.js.map +1 -0
- package/dist/audio/index.d.ts +2 -0
- package/dist/audio/index.d.ts.map +1 -0
- package/dist/audio/index.js +2 -0
- package/dist/audio/index.js.map +1 -0
- package/dist/collision/broadphase/spatial-hash.d.ts +32 -0
- package/dist/collision/broadphase/spatial-hash.d.ts.map +1 -0
- package/dist/collision/broadphase/spatial-hash.js +87 -0
- package/dist/collision/broadphase/spatial-hash.js.map +1 -0
- package/dist/collision/collision-system.d.ts +52 -0
- package/dist/collision/collision-system.d.ts.map +1 -0
- package/dist/collision/collision-system.js +278 -0
- package/dist/collision/collision-system.js.map +1 -0
- package/dist/collision/events/collision-emitter.d.ts +38 -0
- package/dist/collision/events/collision-emitter.d.ts.map +1 -0
- package/dist/collision/events/collision-emitter.js +47 -0
- package/dist/collision/events/collision-emitter.js.map +1 -0
- package/dist/collision/index.d.ts +13 -0
- package/dist/collision/index.d.ts.map +1 -0
- package/dist/collision/index.js +11 -0
- package/dist/collision/index.js.map +1 -0
- package/dist/collision/narrowphase/detector.d.ts +26 -0
- package/dist/collision/narrowphase/detector.d.ts.map +1 -0
- package/dist/collision/narrowphase/detector.js +70 -0
- package/dist/collision/narrowphase/detector.js.map +1 -0
- package/dist/collision/narrowphase/shapes.d.ts +91 -0
- package/dist/collision/narrowphase/shapes.d.ts.map +1 -0
- package/dist/collision/narrowphase/shapes.js +52 -0
- package/dist/collision/narrowphase/shapes.js.map +1 -0
- package/dist/collision/physics/physics-body.d.ts +38 -0
- package/dist/collision/physics/physics-body.d.ts.map +1 -0
- package/dist/collision/physics/physics-body.js +53 -0
- package/dist/collision/physics/physics-body.js.map +1 -0
- package/dist/collision/physics/physics-system.d.ts +23 -0
- package/dist/collision/physics/physics-system.d.ts.map +1 -0
- package/dist/collision/physics/physics-system.js +86 -0
- package/dist/collision/physics/physics-system.js.map +1 -0
- package/dist/collision/physics/resolver.d.ts +16 -0
- package/dist/collision/physics/resolver.d.ts.map +1 -0
- package/dist/collision/physics/resolver.js +91 -0
- package/dist/collision/physics/resolver.js.map +1 -0
- package/dist/collision/types.d.ts +22 -0
- package/dist/collision/types.d.ts.map +1 -0
- package/dist/collision/types.js +2 -0
- package/dist/collision/types.js.map +1 -0
- package/dist/core/game-config.d.ts +34 -0
- package/dist/core/game-config.d.ts.map +1 -0
- package/dist/core/game-config.js +31 -0
- package/dist/core/game-config.js.map +1 -0
- package/dist/core/game.d.ts +86 -0
- package/dist/core/game.d.ts.map +1 -0
- package/dist/core/game.js +166 -0
- package/dist/core/game.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/scene-manager.d.ts +28 -0
- package/dist/core/scene-manager.d.ts.map +1 -0
- package/dist/core/scene-manager.js +65 -0
- package/dist/core/scene-manager.js.map +1 -0
- package/dist/core/scene.d.ts +43 -0
- package/dist/core/scene.d.ts.map +1 -0
- package/dist/core/scene.js +48 -0
- package/dist/core/scene.js.map +1 -0
- package/dist/core/theme.d.ts +63 -0
- package/dist/core/theme.d.ts.map +1 -0
- package/dist/core/theme.js +59 -0
- package/dist/core/theme.js.map +1 -0
- package/dist/errors/animation.d.ts +24 -0
- package/dist/errors/animation.d.ts.map +1 -0
- package/dist/errors/animation.js +29 -0
- package/dist/errors/animation.js.map +1 -0
- package/dist/errors/assets.d.ts +34 -0
- package/dist/errors/assets.d.ts.map +1 -0
- package/dist/errors/assets.js +41 -0
- package/dist/errors/assets.js.map +1 -0
- package/dist/errors/base.d.ts +12 -0
- package/dist/errors/base.d.ts.map +1 -0
- package/dist/errors/base.js +15 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/env.d.ts +24 -0
- package/dist/errors/env.d.ts.map +1 -0
- package/dist/errors/env.js +29 -0
- package/dist/errors/env.js.map +1 -0
- package/dist/errors/hook.d.ts +46 -0
- package/dist/errors/hook.d.ts.map +1 -0
- package/dist/errors/hook.js +55 -0
- package/dist/errors/hook.js.map +1 -0
- package/dist/errors/index.d.ts +11 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +11 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/jsx.d.ts +26 -0
- package/dist/errors/jsx.d.ts.map +1 -0
- package/dist/errors/jsx.js +45 -0
- package/dist/errors/jsx.js.map +1 -0
- package/dist/errors/lifecycle.d.ts +35 -0
- package/dist/errors/lifecycle.d.ts.map +1 -0
- package/dist/errors/lifecycle.js +42 -0
- package/dist/errors/lifecycle.js.map +1 -0
- package/dist/errors/math.d.ts +24 -0
- package/dist/errors/math.d.ts.map +1 -0
- package/dist/errors/math.js +34 -0
- package/dist/errors/math.js.map +1 -0
- package/dist/errors/node.d.ts +68 -0
- package/dist/errors/node.d.ts.map +1 -0
- package/dist/errors/node.js +87 -0
- package/dist/errors/node.js.map +1 -0
- package/dist/errors/scene.d.ts +35 -0
- package/dist/errors/scene.d.ts.map +1 -0
- package/dist/errors/scene.js +42 -0
- package/dist/errors/scene.js.map +1 -0
- package/dist/events/event.d.ts +106 -0
- package/dist/events/event.d.ts.map +1 -0
- package/dist/events/event.js +125 -0
- package/dist/events/event.js.map +1 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +2 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/types.d.ts +20 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +2 -0
- package/dist/events/types.js.map +1 -0
- package/dist/hooks/context.d.ts +15 -0
- package/dist/hooks/context.d.ts.map +1 -0
- package/dist/hooks/context.js +26 -0
- package/dist/hooks/context.js.map +1 -0
- package/dist/hooks/deriveds/by-nodes/index.d.ts +7 -0
- package/dist/hooks/deriveds/by-nodes/index.d.ts.map +1 -0
- package/dist/hooks/deriveds/by-nodes/index.js +7 -0
- package/dist/hooks/deriveds/by-nodes/index.js.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-animation.d.ts +44 -0
- package/dist/hooks/deriveds/by-nodes/use-animation.d.ts.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-animation.js +61 -0
- package/dist/hooks/deriveds/by-nodes/use-animation.js.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-audio.d.ts +33 -0
- package/dist/hooks/deriveds/by-nodes/use-audio.d.ts.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-audio.js +43 -0
- package/dist/hooks/deriveds/by-nodes/use-audio.js.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-clickable.d.ts +32 -0
- package/dist/hooks/deriveds/by-nodes/use-clickable.d.ts.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-clickable.js +43 -0
- package/dist/hooks/deriveds/by-nodes/use-clickable.js.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-collider.d.ts +35 -0
- package/dist/hooks/deriveds/by-nodes/use-collider.d.ts.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-collider.js +55 -0
- package/dist/hooks/deriveds/by-nodes/use-collider.js.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-ray-cast.d.ts +35 -0
- package/dist/hooks/deriveds/by-nodes/use-ray-cast.d.ts.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-ray-cast.js +47 -0
- package/dist/hooks/deriveds/by-nodes/use-ray-cast.js.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-timer.d.ts +34 -0
- package/dist/hooks/deriveds/by-nodes/use-timer.d.ts.map +1 -0
- package/dist/hooks/deriveds/by-nodes/use-timer.js +48 -0
- package/dist/hooks/deriveds/by-nodes/use-timer.js.map +1 -0
- package/dist/hooks/deriveds/index.d.ts +5 -0
- package/dist/hooks/deriveds/index.d.ts.map +1 -0
- package/dist/hooks/deriveds/index.js +5 -0
- package/dist/hooks/deriveds/index.js.map +1 -0
- package/dist/hooks/deriveds/use-condition.d.ts +37 -0
- package/dist/hooks/deriveds/use-condition.d.ts.map +1 -0
- package/dist/hooks/deriveds/use-condition.js +47 -0
- package/dist/hooks/deriveds/use-condition.js.map +1 -0
- package/dist/hooks/deriveds/use-match.d.ts +26 -0
- package/dist/hooks/deriveds/use-match.d.ts.map +1 -0
- package/dist/hooks/deriveds/use-match.js +38 -0
- package/dist/hooks/deriveds/use-match.js.map +1 -0
- package/dist/hooks/deriveds/use-partial-node.d.ts +22 -0
- package/dist/hooks/deriveds/use-partial-node.d.ts.map +1 -0
- package/dist/hooks/deriveds/use-partial-node.js +25 -0
- package/dist/hooks/deriveds/use-partial-node.js.map +1 -0
- package/dist/hooks/deriveds/use-when.d.ts +28 -0
- package/dist/hooks/deriveds/use-when.d.ts.map +1 -0
- package/dist/hooks/deriveds/use-when.js +35 -0
- package/dist/hooks/deriveds/use-when.js.map +1 -0
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-child.d.ts +24 -0
- package/dist/hooks/use-child.d.ts.map +1 -0
- package/dist/hooks/use-child.js +37 -0
- package/dist/hooks/use-child.js.map +1 -0
- package/dist/hooks/use-computed.d.ts +28 -0
- package/dist/hooks/use-computed.d.ts.map +1 -0
- package/dist/hooks/use-computed.js +41 -0
- package/dist/hooks/use-computed.js.map +1 -0
- package/dist/hooks/use-context.d.ts +58 -0
- package/dist/hooks/use-context.d.ts.map +1 -0
- package/dist/hooks/use-context.js +77 -0
- package/dist/hooks/use-context.js.map +1 -0
- package/dist/hooks/use-effect.d.ts +24 -0
- package/dist/hooks/use-effect.d.ts.map +1 -0
- package/dist/hooks/use-effect.js +63 -0
- package/dist/hooks/use-effect.js.map +1 -0
- package/dist/hooks/use-event.d.ts +29 -0
- package/dist/hooks/use-event.d.ts.map +1 -0
- package/dist/hooks/use-event.js +30 -0
- package/dist/hooks/use-event.js.map +1 -0
- package/dist/hooks/use-game.d.ts +17 -0
- package/dist/hooks/use-game.d.ts.map +1 -0
- package/dist/hooks/use-game.js +35 -0
- package/dist/hooks/use-game.js.map +1 -0
- package/dist/hooks/use-mount.d.ts +21 -0
- package/dist/hooks/use-mount.d.ts.map +1 -0
- package/dist/hooks/use-mount.js +33 -0
- package/dist/hooks/use-mount.js.map +1 -0
- package/dist/hooks/use-node.d.ts +42 -0
- package/dist/hooks/use-node.d.ts.map +1 -0
- package/dist/hooks/use-node.js +63 -0
- package/dist/hooks/use-node.js.map +1 -0
- package/dist/hooks/use-ref.d.ts +27 -0
- package/dist/hooks/use-ref.d.ts.map +1 -0
- package/dist/hooks/use-ref.js +33 -0
- package/dist/hooks/use-ref.js.map +1 -0
- package/dist/hooks/use-script.d.ts +33 -0
- package/dist/hooks/use-script.d.ts.map +1 -0
- package/dist/hooks/use-script.js +40 -0
- package/dist/hooks/use-script.js.map +1 -0
- package/dist/hooks/use-signal.d.ts +25 -0
- package/dist/hooks/use-signal.d.ts.map +1 -0
- package/dist/hooks/use-signal.js +36 -0
- package/dist/hooks/use-signal.js.map +1 -0
- package/dist/hooks/use-spawn.d.ts +27 -0
- package/dist/hooks/use-spawn.d.ts.map +1 -0
- package/dist/hooks/use-spawn.js +39 -0
- package/dist/hooks/use-spawn.js.map +1 -0
- package/dist/hooks/use-trigger.d.ts +51 -0
- package/dist/hooks/use-trigger.d.ts.map +1 -0
- package/dist/hooks/use-trigger.js +68 -0
- package/dist/hooks/use-trigger.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/input/input.d.ts +46 -0
- package/dist/input/input.d.ts.map +1 -0
- package/dist/input/input.js +159 -0
- package/dist/input/input.js.map +1 -0
- package/dist/jsx/components/fragment.d.ts +3 -0
- package/dist/jsx/components/fragment.d.ts.map +1 -0
- package/dist/jsx/components/fragment.js +7 -0
- package/dist/jsx/components/fragment.js.map +1 -0
- package/dist/jsx/components/game.d.ts +21 -0
- package/dist/jsx/components/game.d.ts.map +1 -0
- package/dist/jsx/components/game.js +17 -0
- package/dist/jsx/components/game.js.map +1 -0
- package/dist/jsx/components/index.d.ts +5 -0
- package/dist/jsx/components/index.d.ts.map +1 -0
- package/dist/jsx/components/index.js +5 -0
- package/dist/jsx/components/index.js.map +1 -0
- package/dist/jsx/components/list.d.ts +88 -0
- package/dist/jsx/components/list.d.ts.map +1 -0
- package/dist/jsx/components/list.js +93 -0
- package/dist/jsx/components/list.js.map +1 -0
- package/dist/jsx/components/scene.d.ts +40 -0
- package/dist/jsx/components/scene.d.ts.map +1 -0
- package/dist/jsx/components/scene.js +20 -0
- package/dist/jsx/components/scene.js.map +1 -0
- package/dist/jsx/index.d.ts +5 -0
- package/dist/jsx/index.d.ts.map +1 -0
- package/dist/jsx/index.js +5 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/jsx.d.ts +3 -0
- package/dist/jsx/jsx.d.ts.map +1 -0
- package/dist/jsx/jsx.js +4 -0
- package/dist/jsx/jsx.js.map +1 -0
- package/dist/jsx/render/game.d.ts +41 -0
- package/dist/jsx/render/game.d.ts.map +1 -0
- package/dist/jsx/render/game.js +86 -0
- package/dist/jsx/render/game.js.map +1 -0
- package/dist/jsx/render/index.d.ts +3 -0
- package/dist/jsx/render/index.d.ts.map +1 -0
- package/dist/jsx/render/index.js +3 -0
- package/dist/jsx/render/index.js.map +1 -0
- package/dist/jsx/render/to-nodes.d.ts +10 -0
- package/dist/jsx/render/to-nodes.d.ts.map +1 -0
- package/dist/jsx/render/to-nodes.js +52 -0
- package/dist/jsx/render/to-nodes.js.map +1 -0
- package/dist/jsx/render/types/class-component.d.ts +4 -0
- package/dist/jsx/render/types/class-component.d.ts.map +1 -0
- package/dist/jsx/render/types/class-component.js +8 -0
- package/dist/jsx/render/types/class-component.js.map +1 -0
- package/dist/jsx/render/types/func-components.d.ts +4 -0
- package/dist/jsx/render/types/func-components.d.ts.map +1 -0
- package/dist/jsx/render/types/func-components.js +8 -0
- package/dist/jsx/render/types/func-components.js.map +1 -0
- package/dist/jsx/render/types/instrinsic-elements.d.ts +6 -0
- package/dist/jsx/render/types/instrinsic-elements.d.ts.map +1 -0
- package/dist/jsx/render/types/instrinsic-elements.js +41 -0
- package/dist/jsx/render/types/instrinsic-elements.js.map +1 -0
- package/dist/jsx/types.d.ts +41 -0
- package/dist/jsx/types.d.ts.map +1 -0
- package/dist/jsx/types.js +2 -0
- package/dist/jsx/types.js.map +1 -0
- package/dist/jsx/utils.d.ts +4 -0
- package/dist/jsx/utils.d.ts.map +1 -0
- package/dist/jsx/utils.js +15 -0
- package/dist/jsx/utils.js.map +1 -0
- package/dist/jsx-runtime.d.ts +6 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +6 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/math/index.d.ts +3 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/math/index.js +2 -0
- package/dist/math/index.js.map +1 -0
- package/dist/math/types.d.ts +13 -0
- package/dist/math/types.d.ts.map +1 -0
- package/dist/math/types.js +2 -0
- package/dist/math/types.js.map +1 -0
- package/dist/math/vector2.d.ts +145 -0
- package/dist/math/vector2.d.ts.map +1 -0
- package/dist/math/vector2.js +164 -0
- package/dist/math/vector2.js.map +1 -0
- package/dist/nodes/_node.d.ts +283 -0
- package/dist/nodes/_node.d.ts.map +1 -0
- package/dist/nodes/_node.js +371 -0
- package/dist/nodes/_node.js.map +1 -0
- package/dist/nodes/animation-player.d.ts +208 -0
- package/dist/nodes/animation-player.d.ts.map +1 -0
- package/dist/nodes/animation-player.js +249 -0
- package/dist/nodes/animation-player.js.map +1 -0
- package/dist/nodes/audio-player.d.ts +128 -0
- package/dist/nodes/audio-player.d.ts.map +1 -0
- package/dist/nodes/audio-player.js +173 -0
- package/dist/nodes/audio-player.js.map +1 -0
- package/dist/nodes/group.d.ts +55 -0
- package/dist/nodes/group.d.ts.map +1 -0
- package/dist/nodes/group.js +54 -0
- package/dist/nodes/group.js.map +1 -0
- package/dist/nodes/index.d.ts +8 -0
- package/dist/nodes/index.d.ts.map +1 -0
- package/dist/nodes/index.js +7 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/nodes/lib/enum.d.ts +42 -0
- package/dist/nodes/lib/enum.d.ts.map +1 -0
- package/dist/nodes/lib/enum.js +43 -0
- package/dist/nodes/lib/enum.js.map +1 -0
- package/dist/nodes/lib/index.d.ts +5 -0
- package/dist/nodes/lib/index.d.ts.map +1 -0
- package/dist/nodes/lib/index.js +5 -0
- package/dist/nodes/lib/index.js.map +1 -0
- package/dist/nodes/lib/registry.d.ts +43 -0
- package/dist/nodes/lib/registry.d.ts.map +1 -0
- package/dist/nodes/lib/registry.js +46 -0
- package/dist/nodes/lib/registry.js.map +1 -0
- package/dist/nodes/lib/types.d.ts +89 -0
- package/dist/nodes/lib/types.d.ts.map +1 -0
- package/dist/nodes/lib/types.js +2 -0
- package/dist/nodes/lib/types.js.map +1 -0
- package/dist/nodes/lib/utils.d.ts +35 -0
- package/dist/nodes/lib/utils.d.ts.map +1 -0
- package/dist/nodes/lib/utils.js +58 -0
- package/dist/nodes/lib/utils.js.map +1 -0
- package/dist/nodes/node2d/_node2d.d.ts +59 -0
- package/dist/nodes/node2d/_node2d.d.ts.map +1 -0
- package/dist/nodes/node2d/_node2d.js +57 -0
- package/dist/nodes/node2d/_node2d.js.map +1 -0
- package/dist/nodes/node2d/camera.d.ts +64 -0
- package/dist/nodes/node2d/camera.d.ts.map +1 -0
- package/dist/nodes/node2d/camera.js +72 -0
- package/dist/nodes/node2d/camera.js.map +1 -0
- package/dist/nodes/node2d/clickable.d.ts +96 -0
- package/dist/nodes/node2d/clickable.d.ts.map +1 -0
- package/dist/nodes/node2d/clickable.js +117 -0
- package/dist/nodes/node2d/clickable.js.map +1 -0
- package/dist/nodes/node2d/collider.d.ts +96 -0
- package/dist/nodes/node2d/collider.d.ts.map +1 -0
- package/dist/nodes/node2d/collider.js +116 -0
- package/dist/nodes/node2d/collider.js.map +1 -0
- package/dist/nodes/node2d/index.d.ts +12 -0
- package/dist/nodes/node2d/index.d.ts.map +1 -0
- package/dist/nodes/node2d/index.js +11 -0
- package/dist/nodes/node2d/index.js.map +1 -0
- package/dist/nodes/node2d/lib/index.d.ts +2 -0
- package/dist/nodes/node2d/lib/index.d.ts.map +1 -0
- package/dist/nodes/node2d/lib/index.js +2 -0
- package/dist/nodes/node2d/lib/index.js.map +1 -0
- package/dist/nodes/node2d/lib/utils.d.ts +4 -0
- package/dist/nodes/node2d/lib/utils.d.ts.map +1 -0
- package/dist/nodes/node2d/lib/utils.js +14 -0
- package/dist/nodes/node2d/lib/utils.js.map +1 -0
- package/dist/nodes/node2d/ray-cast.d.ts +115 -0
- package/dist/nodes/node2d/ray-cast.d.ts.map +1 -0
- package/dist/nodes/node2d/ray-cast.js +129 -0
- package/dist/nodes/node2d/ray-cast.js.map +1 -0
- package/dist/nodes/node2d/rectangle.d.ts +87 -0
- package/dist/nodes/node2d/rectangle.d.ts.map +1 -0
- package/dist/nodes/node2d/rectangle.js +60 -0
- package/dist/nodes/node2d/rectangle.js.map +1 -0
- package/dist/nodes/node2d/rigid-body.d.ts +65 -0
- package/dist/nodes/node2d/rigid-body.d.ts.map +1 -0
- package/dist/nodes/node2d/rigid-body.js +56 -0
- package/dist/nodes/node2d/rigid-body.js.map +1 -0
- package/dist/nodes/node2d/sprite.d.ts +285 -0
- package/dist/nodes/node2d/sprite.d.ts.map +1 -0
- package/dist/nodes/node2d/sprite.js +226 -0
- package/dist/nodes/node2d/sprite.js.map +1 -0
- package/dist/nodes/node2d/text.d.ts +62 -0
- package/dist/nodes/node2d/text.d.ts.map +1 -0
- package/dist/nodes/node2d/text.js +52 -0
- package/dist/nodes/node2d/text.js.map +1 -0
- package/dist/nodes/node2d/transform.d.ts +32 -0
- package/dist/nodes/node2d/transform.d.ts.map +1 -0
- package/dist/nodes/node2d/transform.js +30 -0
- package/dist/nodes/node2d/transform.js.map +1 -0
- package/dist/nodes/timer.d.ts +107 -0
- package/dist/nodes/timer.d.ts.map +1 -0
- package/dist/nodes/timer.js +108 -0
- package/dist/nodes/timer.js.map +1 -0
- package/dist/reactivity/index.d.ts +5 -0
- package/dist/reactivity/index.d.ts.map +1 -0
- package/dist/reactivity/index.js +5 -0
- package/dist/reactivity/index.js.map +1 -0
- package/dist/reactivity/reactive.d.ts +4 -0
- package/dist/reactivity/reactive.d.ts.map +1 -0
- package/dist/reactivity/reactive.js +50 -0
- package/dist/reactivity/reactive.js.map +1 -0
- package/dist/reactivity/register.d.ts +7 -0
- package/dist/reactivity/register.d.ts.map +1 -0
- package/dist/reactivity/register.js +18 -0
- package/dist/reactivity/register.js.map +1 -0
- package/dist/reactivity/signal.d.ts +126 -0
- package/dist/reactivity/signal.d.ts.map +1 -0
- package/dist/reactivity/signal.js +152 -0
- package/dist/reactivity/signal.js.map +1 -0
- package/dist/reactivity/types.d.ts +31 -0
- package/dist/reactivity/types.d.ts.map +1 -0
- package/dist/reactivity/types.js +2 -0
- package/dist/reactivity/types.js.map +1 -0
- package/dist/scripts/index.d.ts +2 -0
- package/dist/scripts/index.d.ts.map +1 -0
- package/dist/scripts/index.js +2 -0
- package/dist/scripts/index.js.map +1 -0
- package/dist/scripts/script.d.ts +80 -0
- package/dist/scripts/script.d.ts.map +1 -0
- package/dist/scripts/script.js +75 -0
- package/dist/scripts/script.js.map +1 -0
- package/dist/utils/dpr.d.ts +2 -0
- package/dist/utils/dpr.d.ts.map +1 -0
- package/dist/utils/dpr.js +14 -0
- package/dist/utils/dpr.js.map +1 -0
- package/dist/utils/ternaries.d.ts +6 -0
- package/dist/utils/ternaries.d.ts.map +1 -0
- package/dist/utils/ternaries.js +17 -0
- package/dist/utils/ternaries.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { KeyframeNotFoundError } from '../errors/animation.js';
|
|
2
|
+
import { Event } from '../events/event.js';
|
|
3
|
+
import { PrimaryNode } from './lib/enum.js';
|
|
4
|
+
import { Node } from './_node.js';
|
|
5
|
+
import { Nodes } from './lib/registry.js';
|
|
6
|
+
import { subReactive } from '../reactivity/reactive.js';
|
|
7
|
+
export class AnimationPlayer extends Node {
|
|
8
|
+
#animations = new Map();
|
|
9
|
+
#currentAnim = null;
|
|
10
|
+
#nextAnim = null;
|
|
11
|
+
#index = 0;
|
|
12
|
+
#destroyOnEnd = false;
|
|
13
|
+
/** The read-only **`currentAnim`** property returns the current animation name */
|
|
14
|
+
get currentAnim() {
|
|
15
|
+
return this.#currentAnim;
|
|
16
|
+
}
|
|
17
|
+
/** The read-only **`index`** property returns the current index */
|
|
18
|
+
get index() {
|
|
19
|
+
return Math.floor(this.#index);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new `AnimationPlayer` node.
|
|
23
|
+
*
|
|
24
|
+
* If `animations` is provided, it is invoked when the node starts.
|
|
25
|
+
* If `currentAnim` is a `SignalGetter`, the player reactively tracks
|
|
26
|
+
* the signal and switches animations automatically.
|
|
27
|
+
*
|
|
28
|
+
* @param options AnimationPlayer configuration options
|
|
29
|
+
*/
|
|
30
|
+
constructor(options) {
|
|
31
|
+
super(PrimaryNode.AnimationPlayer, options);
|
|
32
|
+
this.#destroyOnEnd = options.destroyOnEnd ?? false;
|
|
33
|
+
this.started.on(() => {
|
|
34
|
+
if (options.animations) {
|
|
35
|
+
this.define(subReactive(options.animations, (animations) => {
|
|
36
|
+
this.#animations.clear();
|
|
37
|
+
this.define(animations);
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
if (options.currentAnim != null) {
|
|
41
|
+
this.play(subReactive(options.currentAnim, (anim) => this.play(anim), (fn) => this.destroyed.on(fn)));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// Events
|
|
46
|
+
/**
|
|
47
|
+
* Detects whether `currentAnim` **change**
|
|
48
|
+
*/
|
|
49
|
+
animationChanged = new Event('animationChange', (_newAnim, _oldAnim) => { });
|
|
50
|
+
/**
|
|
51
|
+
* Detects whether `stop` is **called**
|
|
52
|
+
*/
|
|
53
|
+
animationStopped = new Event('animationStop', (_anim) => { });
|
|
54
|
+
/**
|
|
55
|
+
* Detects whether this `index` **change**
|
|
56
|
+
*/
|
|
57
|
+
animationIndexChanged = new Event('animationIndexChange', (_index) => { });
|
|
58
|
+
/**
|
|
59
|
+
* Detects whether the current animation **end**
|
|
60
|
+
*/
|
|
61
|
+
animationEnded = new Event('animationEnd', (_anim) => { });
|
|
62
|
+
// utils
|
|
63
|
+
/**
|
|
64
|
+
* The **`add`** method adds an animation with a key.
|
|
65
|
+
* @param animName Animation identifier
|
|
66
|
+
* @param animation Animation object
|
|
67
|
+
* @returns This instance for chaining
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* const sprite = useNode(PrimaryNode.Sprite)
|
|
72
|
+
* const anim = useNode(PrimaryNode.AnimationPlayer)
|
|
73
|
+
*
|
|
74
|
+
* useMount(() => {
|
|
75
|
+
* anim.node
|
|
76
|
+
* .add('idle', {
|
|
77
|
+
* fps: 4,
|
|
78
|
+
* keyframes: keyframesFromSheet(sprite.node, IDLE_TEXTURE, 4),
|
|
79
|
+
* loop: true,
|
|
80
|
+
* })
|
|
81
|
+
* .add('walk', {
|
|
82
|
+
* fps: 4,
|
|
83
|
+
* keyframes: keyframesFromSheet(sprite.node, WALK_TEXTURE, 4),
|
|
84
|
+
* loop: true,
|
|
85
|
+
* })
|
|
86
|
+
* .play('idle')
|
|
87
|
+
* })
|
|
88
|
+
*
|
|
89
|
+
* return (
|
|
90
|
+
* <sprite ref={sprite} textureId={IDLE_TEXTURE} sourceSize={new Vector2(16, 16)}>
|
|
91
|
+
* <animation-player ref={anim} />
|
|
92
|
+
* </sprite>
|
|
93
|
+
* )
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
add(animName, animation) {
|
|
97
|
+
this.#animations.set(animName, animation);
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The **`define`** method adds multiple animations at once.
|
|
102
|
+
* @param animations Record of animation names to animation objects
|
|
103
|
+
* @returns This instance for chaining
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* const sprite = useNode(PrimaryNode.Sprite)
|
|
108
|
+
* const anim = useNode(PrimaryNode.AnimationPlayer)
|
|
109
|
+
*
|
|
110
|
+
* useMount(() => {
|
|
111
|
+
* anim.node
|
|
112
|
+
* .define({
|
|
113
|
+
* idle: {
|
|
114
|
+
* fps: 4,
|
|
115
|
+
* keyframes: keyframesFromSheet(sprite.node, IDLE_TEXTURE, 4),
|
|
116
|
+
* loop: true,
|
|
117
|
+
* },
|
|
118
|
+
* walk: {
|
|
119
|
+
* fps: 4,
|
|
120
|
+
* keyframes: keyframesFromSheet(sprite.node, WALK_TEXTURE, 4),
|
|
121
|
+
* loop: true,
|
|
122
|
+
* },
|
|
123
|
+
* })
|
|
124
|
+
* .play('idle')
|
|
125
|
+
* })
|
|
126
|
+
*
|
|
127
|
+
* return (
|
|
128
|
+
* <sprite ref={sprite} textureId={IDLE_TEXTURE} sourceSize={new Vector2(16, 16)}>
|
|
129
|
+
* <animation-player ref={anim} />
|
|
130
|
+
* </sprite>
|
|
131
|
+
* )
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
define(animations) {
|
|
135
|
+
for (const animName in animations) {
|
|
136
|
+
if (!Object.hasOwn(animations, animName))
|
|
137
|
+
continue;
|
|
138
|
+
const animation = animations[animName];
|
|
139
|
+
if (animation == null)
|
|
140
|
+
continue;
|
|
141
|
+
this.add(animName, animation);
|
|
142
|
+
}
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The **`play`** method plays an animation by name.
|
|
147
|
+
* @param animName Animation identifier
|
|
148
|
+
* @param index Index to start from (default `0`)
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```tsx
|
|
152
|
+
* const anim = useNode(PrimaryNode.AnimationPlayer)
|
|
153
|
+
*
|
|
154
|
+
* useMount(() => {
|
|
155
|
+
* anim.node.play('idle')
|
|
156
|
+
* })
|
|
157
|
+
*
|
|
158
|
+
* return <animation-player ref={anim} />
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
play(animName, index) {
|
|
162
|
+
if (this.#currentAnim === animName && (index == null || Math.floor(this.#index) === index))
|
|
163
|
+
return;
|
|
164
|
+
if (this.#currentAnim != null)
|
|
165
|
+
this.stop();
|
|
166
|
+
const oldAnim = this.#currentAnim;
|
|
167
|
+
this.#index = index ?? 0;
|
|
168
|
+
this.#currentAnim = animName;
|
|
169
|
+
this.animationChanged.emit(animName, oldAnim);
|
|
170
|
+
this.animationIndexChanged.emit(index ?? 0);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The **`setNext`** method sets the animation to play after the current one ends.
|
|
174
|
+
* @param animName Animation to play next, or `null` to stop
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```tsx
|
|
178
|
+
* const anim = useNode(PrimaryNode.AnimationPlayer)
|
|
179
|
+
*
|
|
180
|
+
* useEvent(anim, 'animationEnded', () => {
|
|
181
|
+
* anim.node.setNext('idle')
|
|
182
|
+
* })
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
setNext(animName) {
|
|
186
|
+
this.#nextAnim = animName;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The **`stop`** method stops the current animation.
|
|
190
|
+
*/
|
|
191
|
+
stop() {
|
|
192
|
+
if (this.#currentAnim == null)
|
|
193
|
+
return;
|
|
194
|
+
this.animationStopped.emit(this.#currentAnim);
|
|
195
|
+
this.#index = 0;
|
|
196
|
+
this.#currentAnim = null;
|
|
197
|
+
}
|
|
198
|
+
#updateAnim(delta) {
|
|
199
|
+
if (this.#currentAnim == null)
|
|
200
|
+
return;
|
|
201
|
+
const anim = this.#animations.get(this.#currentAnim);
|
|
202
|
+
if (anim == null)
|
|
203
|
+
return;
|
|
204
|
+
if (this.#index >= anim.keyframes.length) {
|
|
205
|
+
if (!anim.loop) {
|
|
206
|
+
const animName = this.#currentAnim;
|
|
207
|
+
this.stop();
|
|
208
|
+
this.animationEnded.emit(animName);
|
|
209
|
+
if (this.#destroyOnEnd) {
|
|
210
|
+
this.destroy();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (this.#nextAnim == null)
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (this.#nextAnim != null) {
|
|
217
|
+
if (this.#currentAnim != null) {
|
|
218
|
+
this.stop();
|
|
219
|
+
}
|
|
220
|
+
this.play(this.#nextAnim);
|
|
221
|
+
this.#nextAnim = null;
|
|
222
|
+
}
|
|
223
|
+
this.#index = 0;
|
|
224
|
+
this.animationIndexChanged.emit(0);
|
|
225
|
+
}
|
|
226
|
+
const i = Math.floor(this.#index);
|
|
227
|
+
const kf = anim.keyframes[i];
|
|
228
|
+
if (kf == null)
|
|
229
|
+
throw new KeyframeNotFoundError(i);
|
|
230
|
+
kf(this.#index % 1);
|
|
231
|
+
this.#index += delta * anim.fps;
|
|
232
|
+
if (this.#index < anim.keyframes.length && i !== Math.floor(this.#index)) {
|
|
233
|
+
this.animationIndexChanged.emit(Math.floor(this.#index));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
update(delta) {
|
|
237
|
+
this.#updateAnim(delta);
|
|
238
|
+
super.update(delta);
|
|
239
|
+
}
|
|
240
|
+
cleanEvents() {
|
|
241
|
+
this.animationChanged.clean();
|
|
242
|
+
this.animationEnded.clean();
|
|
243
|
+
this.animationIndexChanged.clean();
|
|
244
|
+
this.animationStopped.clean();
|
|
245
|
+
super.cleanEvents();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
Nodes['animation-player'] = AnimationPlayer;
|
|
249
|
+
//# sourceMappingURL=animation-player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-player.js","sourceRoot":"","sources":["../../src/nodes/animation-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAsDvD,MAAM,OAAO,eAAgB,SAAQ,IAAiC;IACpE,WAAW,GAAG,IAAI,GAAG,EAAqB,CAAA;IAC1C,YAAY,GAAkB,IAAI,CAAA;IAClC,SAAS,GAAkB,IAAI,CAAA;IAC/B,MAAM,GAAG,CAAC,CAAA;IACV,aAAa,GAAG,KAAK,CAAA;IAErB,kFAAkF;IAClF,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IACD,mEAAmE;IACnE,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC;IAED;;;;;;;;OAQG;IACH,YAAY,OAA+B;QACzC,KAAK,CAAC,WAAW,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;QAC3C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,IAAI,KAAK,CAAA;QAElD,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE;YACnB,IAAI,OAAO,CAAC,UAAU,EAAE,CAA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AAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEjC,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAE5B,IAAI,EAAE,IAAI,IAAI;YAAE,MAAM,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAA;QAElD,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAEnB,IAAI,CAAC,MAAM,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAA;QAE/B,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;QAC1D,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QACvB,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC;IAED,WAAW;QACT,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAA;QAC7B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAA;QAC3B,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAA;QAClC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAA;QAC7B,KAAK,CAAC,WAAW,EAAE,CAAA;IACrB,CAAC;CACF;AAED,KAAK,CAAC,kBAAkB,CAAC,GAAG,eAAe,CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Event } from '../events/event.js';
|
|
2
|
+
import { PrimaryNode } from './lib/enum.js';
|
|
3
|
+
import { Node, type NodeOptions } from './_node.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options for the `AudioPlayer` node.
|
|
6
|
+
*/
|
|
7
|
+
export interface AudioPlayerOptions extends NodeOptions<PrimaryNode.AudioPlayer> {
|
|
8
|
+
/**
|
|
9
|
+
* The **`soundId`** property defines which sound to play.
|
|
10
|
+
* Obtain a sound ID via `loadSound()`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <audio-player soundId={shootSound} />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
soundId: symbol;
|
|
18
|
+
/**
|
|
19
|
+
* The **`loop`** property determines whether the sound loops.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
loop?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The **`volume`** property sets the playback volume (0 to 1).
|
|
25
|
+
* @default 1
|
|
26
|
+
*/
|
|
27
|
+
volume?: number;
|
|
28
|
+
/**
|
|
29
|
+
* The **`playbackRate`** property sets the playback speed.
|
|
30
|
+
* @default 1
|
|
31
|
+
*/
|
|
32
|
+
playbackRate?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The **`persistUntilEnd`** property keeps the node alive until playback finishes.
|
|
35
|
+
* When `true`, calling `destroy()` while audio is playing will defer destruction
|
|
36
|
+
* until the sound ends. Useful for components that play a sound and are destroyed
|
|
37
|
+
* immediately after.
|
|
38
|
+
*
|
|
39
|
+
* @default false
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* // Pea plays splat sound and destroys itself.
|
|
44
|
+
* // AudioPlayer survives until the sound finishes.
|
|
45
|
+
* <audio-player ref={audio} soundId={SPLAT} persistUntilEnd />
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
persistUntilEnd?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The **`AudioPlayer`** node plays audio buffers. It manages `AudioBufferSourceNode`
|
|
52
|
+
* and `GainNode` for volume control. The `AudioContext` is created lazily on first use.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* import { useNode, useEvent } from 'dinix/hooks'
|
|
57
|
+
* import { PrimaryNode } from 'dinix/nodes/enum'
|
|
58
|
+
*
|
|
59
|
+
* function Gun() {
|
|
60
|
+
* const audio = useNode(PrimaryNode.AudioPlayer)
|
|
61
|
+
* const clickable = useNode(PrimaryNode.Clickable)
|
|
62
|
+
*
|
|
63
|
+
* useEvent(clickable, 'click', () => {
|
|
64
|
+
* audio.node.play()
|
|
65
|
+
* })
|
|
66
|
+
*
|
|
67
|
+
* return (
|
|
68
|
+
* <sprite ref={clickable} textureId={GUN}>
|
|
69
|
+
* <audio-player ref={audio} soundId={shootSound} volume={0.8} />
|
|
70
|
+
* </sprite>
|
|
71
|
+
* )
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* For one-shot sounds on components that destroy themselves, use `persistUntilEnd`:
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* function Pea({ position }: { position: VectorLike }) {
|
|
80
|
+
* const audio = useNode(PrimaryNode.AudioPlayer)
|
|
81
|
+
* const collider = useNode(PrimaryNode.Collider)
|
|
82
|
+
*
|
|
83
|
+
* useEvent(collider, 'colliderEntered', () => {
|
|
84
|
+
* audio.node.play()
|
|
85
|
+
* pea.node.destroy() // audio survives until sound finishes
|
|
86
|
+
* })
|
|
87
|
+
*
|
|
88
|
+
* return (
|
|
89
|
+
* <transform ref={pea} position={position}>
|
|
90
|
+
* <sprite textureId={PEA}>
|
|
91
|
+
* <collider ref={collider} ... />
|
|
92
|
+
* </sprite>
|
|
93
|
+
* <audio-player ref={audio} soundId={SPLAT} persistUntilEnd />
|
|
94
|
+
* </transform>
|
|
95
|
+
* )
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare class AudioPlayer extends Node<PrimaryNode.AudioPlayer> {
|
|
100
|
+
#private;
|
|
101
|
+
constructor(options: AudioPlayerOptions);
|
|
102
|
+
/** The `ended` event fires when playback reaches the end (non-looping only). */
|
|
103
|
+
ended: Event<[], "ended">;
|
|
104
|
+
/** The `error` event fires if playback fails. */
|
|
105
|
+
error: Event<[_err: Error], "error">;
|
|
106
|
+
/**
|
|
107
|
+
* Starts or resumes playback.
|
|
108
|
+
* @param offset Time in seconds to start from (default: 0 or pause position)
|
|
109
|
+
*/
|
|
110
|
+
play(offset?: number): void;
|
|
111
|
+
/** Pauses playback without resetting position. */
|
|
112
|
+
pause(): void;
|
|
113
|
+
/** Stops playback and resets position to 0. */
|
|
114
|
+
stop(): void;
|
|
115
|
+
/** Whether the sound is currently playing. */
|
|
116
|
+
get isPlaying(): boolean;
|
|
117
|
+
/** Sets the volume (0 to 1). */
|
|
118
|
+
set volume(value: number);
|
|
119
|
+
/** Gets the current volume. */
|
|
120
|
+
get volume(): number;
|
|
121
|
+
/** Sets the playback rate. */
|
|
122
|
+
set playbackRate(value: number);
|
|
123
|
+
/** Gets the current playback rate. */
|
|
124
|
+
get playbackRate(): number;
|
|
125
|
+
/** @internal Cleans up audio resources on destroy. */
|
|
126
|
+
destroy(): void;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=audio-player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-player.d.ts","sourceRoot":"","sources":["../../src/nodes/audio-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAKnD;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAC9E;;;;;;;;OAQG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,qBAAa,WAAY,SAAQ,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;;gBAYhD,OAAO,EAAE,kBAAkB;IASvC,gFAAgF;IAChF,KAAK,qBAA+B;IAEpC,iDAAiD;IACjD,KAAK,gCAA0C;IAE/C;;;OAGG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAsC3B,kDAAkD;IAClD,KAAK,IAAI,IAAI;IAOb,+CAA+C;IAC/C,IAAI,IAAI,IAAI;IAaZ,8CAA8C;IAC9C,IAAI,SAAS,YAEZ;IAED,gCAAgC;IAChC,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAKvB;IAED,+BAA+B;IAC/B,IAAI,MAAM,IARQ,MAAM,CAUvB;IAED,8BAA8B;IAC9B,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAK7B;IAED,sCAAsC;IACtC,IAAI,YAAY,IARQ,MAAM,CAU7B;IAED,sDAAsD;IACtD,OAAO,IAAI,IAAI;CAQhB"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Event } from '../events/event.js';
|
|
2
|
+
import { PrimaryNode } from './lib/enum.js';
|
|
3
|
+
import { Node } from './_node.js';
|
|
4
|
+
import { Nodes } from './lib/registry.js';
|
|
5
|
+
import { getAudioContext } from '../audio/audio-context.js';
|
|
6
|
+
import { getSound } from '../assets/load-sound.js';
|
|
7
|
+
/**
|
|
8
|
+
* The **`AudioPlayer`** node plays audio buffers. It manages `AudioBufferSourceNode`
|
|
9
|
+
* and `GainNode` for volume control. The `AudioContext` is created lazily on first use.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { useNode, useEvent } from 'dinix/hooks'
|
|
14
|
+
* import { PrimaryNode } from 'dinix/nodes/enum'
|
|
15
|
+
*
|
|
16
|
+
* function Gun() {
|
|
17
|
+
* const audio = useNode(PrimaryNode.AudioPlayer)
|
|
18
|
+
* const clickable = useNode(PrimaryNode.Clickable)
|
|
19
|
+
*
|
|
20
|
+
* useEvent(clickable, 'click', () => {
|
|
21
|
+
* audio.node.play()
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <sprite ref={clickable} textureId={GUN}>
|
|
26
|
+
* <audio-player ref={audio} soundId={shootSound} volume={0.8} />
|
|
27
|
+
* </sprite>
|
|
28
|
+
* )
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* For one-shot sounds on components that destroy themselves, use `persistUntilEnd`:
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* function Pea({ position }: { position: VectorLike }) {
|
|
37
|
+
* const audio = useNode(PrimaryNode.AudioPlayer)
|
|
38
|
+
* const collider = useNode(PrimaryNode.Collider)
|
|
39
|
+
*
|
|
40
|
+
* useEvent(collider, 'colliderEntered', () => {
|
|
41
|
+
* audio.node.play()
|
|
42
|
+
* pea.node.destroy() // audio survives until sound finishes
|
|
43
|
+
* })
|
|
44
|
+
*
|
|
45
|
+
* return (
|
|
46
|
+
* <transform ref={pea} position={position}>
|
|
47
|
+
* <sprite textureId={PEA}>
|
|
48
|
+
* <collider ref={collider} ... />
|
|
49
|
+
* </sprite>
|
|
50
|
+
* <audio-player ref={audio} soundId={SPLAT} persistUntilEnd />
|
|
51
|
+
* </transform>
|
|
52
|
+
* )
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export class AudioPlayer extends Node {
|
|
57
|
+
#soundId;
|
|
58
|
+
#source = null;
|
|
59
|
+
#gainNode = null;
|
|
60
|
+
#loop;
|
|
61
|
+
#volume;
|
|
62
|
+
#playbackRate;
|
|
63
|
+
#persistUntilEnd;
|
|
64
|
+
#startTime = 0;
|
|
65
|
+
#pauseOffset = 0;
|
|
66
|
+
#isPlaying = false;
|
|
67
|
+
constructor(options) {
|
|
68
|
+
super(PrimaryNode.AudioPlayer, options);
|
|
69
|
+
this.#soundId = options.soundId;
|
|
70
|
+
this.#loop = options.loop ?? false;
|
|
71
|
+
this.#volume = options.volume ?? 1;
|
|
72
|
+
this.#playbackRate = options.playbackRate ?? 1;
|
|
73
|
+
this.#persistUntilEnd = options.persistUntilEnd ?? false;
|
|
74
|
+
}
|
|
75
|
+
/** The `ended` event fires when playback reaches the end (non-looping only). */
|
|
76
|
+
ended = new Event('ended', () => { });
|
|
77
|
+
/** The `error` event fires if playback fails. */
|
|
78
|
+
error = new Event('error', (_err) => { });
|
|
79
|
+
/**
|
|
80
|
+
* Starts or resumes playback.
|
|
81
|
+
* @param offset Time in seconds to start from (default: 0 or pause position)
|
|
82
|
+
*/
|
|
83
|
+
play(offset) {
|
|
84
|
+
try {
|
|
85
|
+
const ctx = getAudioContext();
|
|
86
|
+
const buffer = getSound(this.#soundId);
|
|
87
|
+
this.stop();
|
|
88
|
+
this.#source = ctx.createBufferSource();
|
|
89
|
+
this.#gainNode = ctx.createGain();
|
|
90
|
+
this.#source.buffer = buffer;
|
|
91
|
+
this.#source.loop = this.#loop;
|
|
92
|
+
this.#source.playbackRate.value = this.#playbackRate;
|
|
93
|
+
this.#gainNode.gain.value = this.#volume;
|
|
94
|
+
this.#source.connect(this.#gainNode);
|
|
95
|
+
this.#gainNode.connect(ctx.destination);
|
|
96
|
+
this.#pauseOffset = offset ?? this.#pauseOffset;
|
|
97
|
+
this.#source.start(0, this.#pauseOffset);
|
|
98
|
+
this.#startTime = ctx.currentTime - this.#pauseOffset;
|
|
99
|
+
this.#isPlaying = true;
|
|
100
|
+
this.#source.onended = () => {
|
|
101
|
+
if (!this.#isPlaying)
|
|
102
|
+
return;
|
|
103
|
+
this.#isPlaying = false;
|
|
104
|
+
this.#pauseOffset = 0;
|
|
105
|
+
this.ended.emit();
|
|
106
|
+
if (this.#persistUntilEnd && this.isDestroyed) {
|
|
107
|
+
super.destroy();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
this.error.emit(err instanceof Error ? err : new Error(String(err)));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** Pauses playback without resetting position. */
|
|
116
|
+
pause() {
|
|
117
|
+
if (!this.#isPlaying || this.#source == null)
|
|
118
|
+
return;
|
|
119
|
+
const ctx = getAudioContext();
|
|
120
|
+
this.#pauseOffset = (ctx.currentTime - this.#startTime) * this.#playbackRate;
|
|
121
|
+
this.stop();
|
|
122
|
+
}
|
|
123
|
+
/** Stops playback and resets position to 0. */
|
|
124
|
+
stop() {
|
|
125
|
+
if (this.#source != null) {
|
|
126
|
+
this.#source.onended = null;
|
|
127
|
+
this.#source.disconnect();
|
|
128
|
+
this.#source = null;
|
|
129
|
+
}
|
|
130
|
+
if (this.#gainNode != null) {
|
|
131
|
+
this.#gainNode.disconnect();
|
|
132
|
+
this.#gainNode = null;
|
|
133
|
+
}
|
|
134
|
+
this.#isPlaying = false;
|
|
135
|
+
}
|
|
136
|
+
/** Whether the sound is currently playing. */
|
|
137
|
+
get isPlaying() {
|
|
138
|
+
return this.#isPlaying;
|
|
139
|
+
}
|
|
140
|
+
/** Sets the volume (0 to 1). */
|
|
141
|
+
set volume(value) {
|
|
142
|
+
this.#volume = value;
|
|
143
|
+
if (this.#gainNode != null) {
|
|
144
|
+
this.#gainNode.gain.value = value;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Gets the current volume. */
|
|
148
|
+
get volume() {
|
|
149
|
+
return this.#volume;
|
|
150
|
+
}
|
|
151
|
+
/** Sets the playback rate. */
|
|
152
|
+
set playbackRate(value) {
|
|
153
|
+
this.#playbackRate = value;
|
|
154
|
+
if (this.#source != null) {
|
|
155
|
+
this.#source.playbackRate.value = value;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** Gets the current playback rate. */
|
|
159
|
+
get playbackRate() {
|
|
160
|
+
return this.#playbackRate;
|
|
161
|
+
}
|
|
162
|
+
/** @internal Cleans up audio resources on destroy. */
|
|
163
|
+
destroy() {
|
|
164
|
+
if (this.#persistUntilEnd && this.#isPlaying) {
|
|
165
|
+
this.isDestroyed = true;
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.stop();
|
|
169
|
+
super.destroy();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
Nodes['audio-player'] = AudioPlayer;
|
|
173
|
+
//# sourceMappingURL=audio-player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-player.js","sourceRoot":"","sources":["../../src/nodes/audio-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAiDlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,OAAO,WAAY,SAAQ,IAA6B;IAC5D,QAAQ,CAAQ;IAChB,OAAO,GAAiC,IAAI,CAAA;IAC5C,SAAS,GAAoB,IAAI,CAAA;IACjC,KAAK,CAAS;IACd,OAAO,CAAQ;IACf,aAAa,CAAQ;IACrB,gBAAgB,CAAS;IACzB,UAAU,GAAG,CAAC,CAAA;IACd,YAAY,GAAG,CAA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ACtC,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,sDAAsD;IACtD,OAAO;QACL,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAC7C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;YACvB,OAAM;QACR,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,CAAA;QACX,KAAK,CAAC,OAAO,EAAE,CAAA;IACjB,CAAC;CACF;AAED,KAAK,CAAC,cAAc,CAAC,GAAG,WAAW,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Node, type NodeOptions } from './_node.js';
|
|
2
|
+
import { PrimaryNode } from './lib/enum.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for the `Group` node.
|
|
5
|
+
*/
|
|
6
|
+
export interface GroupOptions extends NodeOptions<PrimaryNode.Group> {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The **`Group`** node is a lightweight container for organizing child nodes
|
|
10
|
+
* without spatial positioning. Unlike `Transform`, it does not manage position,
|
|
11
|
+
* rotation, or scale — it purely serves as a logical grouping mechanism.
|
|
12
|
+
*
|
|
13
|
+
* Use `Group` when you need to:
|
|
14
|
+
* - Batch-destroy a set of nodes by destroying the parent
|
|
15
|
+
* - Organize nodes in the hierarchy without affecting their position
|
|
16
|
+
* - Apply `deltaIncrease` to a subset of nodes
|
|
17
|
+
* - Attach a script to a group of nodes
|
|
18
|
+
*
|
|
19
|
+
* For nodes that need spatial positioning, use `Transform` instead.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { useNode } from 'dinix/hooks'
|
|
24
|
+
* import { PrimaryNode } from 'dinix/nodes/enum'
|
|
25
|
+
*
|
|
26
|
+
* function EnemySpawner() {
|
|
27
|
+
* const enemies = useNode(PrimaryNode.Group)
|
|
28
|
+
*
|
|
29
|
+
* useMount(() => {
|
|
30
|
+
* // All enemies are children of the group
|
|
31
|
+
* // Destroying the group destroys all enemies
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* return (
|
|
35
|
+
* <group ref={enemies}>
|
|
36
|
+
* <Enemy position={[0, 0]} />
|
|
37
|
+
* <Enemy position={[50, 0]} />
|
|
38
|
+
* </group>
|
|
39
|
+
* )
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* // Slowing down a subset of nodes
|
|
46
|
+
* <group deltaIncrease={0.5}>
|
|
47
|
+
* <SlowEnemy />
|
|
48
|
+
* <SlowProjectile />
|
|
49
|
+
* </group>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare class Group extends Node<PrimaryNode.Group> {
|
|
53
|
+
constructor(options: GroupOptions);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/nodes/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3C;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC;CAAG;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBAAa,KAAM,SAAQ,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;gBACpC,OAAO,EAAE,YAAY;CAGlC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Node } from './_node.js';
|
|
2
|
+
import { PrimaryNode } from './lib/enum.js';
|
|
3
|
+
import { Nodes } from './lib/registry.js';
|
|
4
|
+
/**
|
|
5
|
+
* The **`Group`** node is a lightweight container for organizing child nodes
|
|
6
|
+
* without spatial positioning. Unlike `Transform`, it does not manage position,
|
|
7
|
+
* rotation, or scale — it purely serves as a logical grouping mechanism.
|
|
8
|
+
*
|
|
9
|
+
* Use `Group` when you need to:
|
|
10
|
+
* - Batch-destroy a set of nodes by destroying the parent
|
|
11
|
+
* - Organize nodes in the hierarchy without affecting their position
|
|
12
|
+
* - Apply `deltaIncrease` to a subset of nodes
|
|
13
|
+
* - Attach a script to a group of nodes
|
|
14
|
+
*
|
|
15
|
+
* For nodes that need spatial positioning, use `Transform` instead.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { useNode } from 'dinix/hooks'
|
|
20
|
+
* import { PrimaryNode } from 'dinix/nodes/enum'
|
|
21
|
+
*
|
|
22
|
+
* function EnemySpawner() {
|
|
23
|
+
* const enemies = useNode(PrimaryNode.Group)
|
|
24
|
+
*
|
|
25
|
+
* useMount(() => {
|
|
26
|
+
* // All enemies are children of the group
|
|
27
|
+
* // Destroying the group destroys all enemies
|
|
28
|
+
* })
|
|
29
|
+
*
|
|
30
|
+
* return (
|
|
31
|
+
* <group ref={enemies}>
|
|
32
|
+
* <Enemy position={[0, 0]} />
|
|
33
|
+
* <Enemy position={[50, 0]} />
|
|
34
|
+
* </group>
|
|
35
|
+
* )
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* // Slowing down a subset of nodes
|
|
42
|
+
* <group deltaIncrease={0.5}>
|
|
43
|
+
* <SlowEnemy />
|
|
44
|
+
* <SlowProjectile />
|
|
45
|
+
* </group>
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export class Group extends Node {
|
|
49
|
+
constructor(options) {
|
|
50
|
+
super(PrimaryNode.Group, options);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
Nodes.group = Group;
|
|
54
|
+
//# sourceMappingURL=group.js.map
|