@codexo/exojs 0.7.11 → 0.7.13
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 +442 -0
- package/dist/esm/animation/Tween.d.ts +60 -1
- package/dist/esm/animation/Tween.js +60 -1
- package/dist/esm/animation/Tween.js.map +1 -1
- package/dist/esm/animation/TweenManager.d.ts +10 -0
- package/dist/esm/animation/TweenManager.js +10 -0
- package/dist/esm/animation/TweenManager.js.map +1 -1
- package/dist/esm/animation/types.d.ts +15 -0
- package/dist/esm/animation/types.js +6 -0
- package/dist/esm/animation/types.js.map +1 -1
- package/dist/esm/audio/AbstractMedia.d.ts +11 -0
- package/dist/esm/audio/AbstractMedia.js +10 -0
- package/dist/esm/audio/AbstractMedia.js.map +1 -1
- package/dist/esm/audio/AudioAnalyser.d.ts +21 -0
- package/dist/esm/audio/AudioAnalyser.js +16 -0
- package/dist/esm/audio/AudioAnalyser.js.map +1 -1
- package/dist/esm/audio/AudioBus.d.ts +37 -0
- package/dist/esm/audio/AudioBus.js +36 -0
- package/dist/esm/audio/AudioBus.js.map +1 -1
- package/dist/esm/audio/AudioFilter.d.ts +7 -0
- package/dist/esm/audio/AudioFilter.js +6 -0
- package/dist/esm/audio/AudioFilter.js.map +1 -1
- package/dist/esm/audio/AudioListener.d.ts +19 -0
- package/dist/esm/audio/AudioListener.js +11 -0
- package/dist/esm/audio/AudioListener.js.map +1 -1
- package/dist/esm/audio/AudioManager.d.ts +37 -0
- package/dist/esm/audio/AudioManager.js +37 -0
- package/dist/esm/audio/AudioManager.js.map +1 -1
- package/dist/esm/audio/BeatDetector.d.ts +21 -0
- package/dist/esm/audio/BeatDetector.js +21 -0
- package/dist/esm/audio/BeatDetector.js.map +1 -1
- package/dist/esm/audio/Media.d.ts +11 -0
- package/dist/esm/audio/Music.d.ts +12 -0
- package/dist/esm/audio/Music.js +12 -0
- package/dist/esm/audio/Music.js.map +1 -1
- package/dist/esm/audio/Sound.d.ts +25 -0
- package/dist/esm/audio/Sound.js +18 -0
- package/dist/esm/audio/Sound.js.map +1 -1
- package/dist/esm/audio/audio-context.d.ts +48 -0
- package/dist/esm/audio/audio-context.js +48 -5
- package/dist/esm/audio/audio-context.js.map +1 -1
- package/dist/esm/audio/filters/ChorusFilter.d.ts +5 -0
- package/dist/esm/audio/filters/ChorusFilter.js +4 -0
- package/dist/esm/audio/filters/ChorusFilter.js.map +1 -1
- package/dist/esm/audio/filters/CompressorFilter.d.ts +12 -0
- package/dist/esm/audio/filters/CompressorFilter.js +11 -0
- package/dist/esm/audio/filters/CompressorFilter.js.map +1 -1
- package/dist/esm/audio/filters/DelayFilter.d.ts +11 -0
- package/dist/esm/audio/filters/DelayFilter.js +10 -0
- package/dist/esm/audio/filters/DelayFilter.js.map +1 -1
- package/dist/esm/audio/filters/DuckingFilter.d.ts +13 -0
- package/dist/esm/audio/filters/DuckingFilter.js +12 -0
- package/dist/esm/audio/filters/DuckingFilter.js.map +1 -1
- package/dist/esm/audio/filters/EqualizerFilter.d.ts +20 -0
- package/dist/esm/audio/filters/EqualizerFilter.js +40 -0
- package/dist/esm/audio/filters/EqualizerFilter.js.map +1 -1
- package/dist/esm/audio/filters/GranularFilter.d.ts +6 -0
- package/dist/esm/audio/filters/GranularFilter.js +6 -0
- package/dist/esm/audio/filters/GranularFilter.js.map +1 -1
- package/dist/esm/audio/filters/HighpassFilter.d.ts +10 -0
- package/dist/esm/audio/filters/HighpassFilter.js +9 -0
- package/dist/esm/audio/filters/HighpassFilter.js.map +1 -1
- package/dist/esm/audio/filters/LowpassFilter.d.ts +10 -0
- package/dist/esm/audio/filters/LowpassFilter.js +9 -0
- package/dist/esm/audio/filters/LowpassFilter.js.map +1 -1
- package/dist/esm/audio/filters/PitchShiftFilter.d.ts +2 -0
- package/dist/esm/audio/filters/PitchShiftFilter.js +2 -0
- package/dist/esm/audio/filters/PitchShiftFilter.js.map +1 -1
- package/dist/esm/audio/filters/ReverbFilter.d.ts +12 -0
- package/dist/esm/audio/filters/ReverbFilter.js +11 -0
- package/dist/esm/audio/filters/ReverbFilter.js.map +1 -1
- package/dist/esm/audio/filters/VocoderFilter.d.ts +11 -0
- package/dist/esm/audio/filters/VocoderFilter.js +11 -0
- package/dist/esm/audio/filters/VocoderFilter.js.map +1 -1
- package/dist/esm/audio/filters/WorkletFilter.d.ts +6 -1
- package/dist/esm/audio/filters/WorkletFilter.js +6 -1
- package/dist/esm/audio/filters/WorkletFilter.js.map +1 -1
- package/dist/esm/core/Application.d.ts +66 -1
- package/dist/esm/core/Application.js +68 -6
- package/dist/esm/core/Application.js.map +1 -1
- package/dist/esm/core/Bounds.d.ts +23 -0
- package/dist/esm/core/Bounds.js +23 -0
- package/dist/esm/core/Bounds.js.map +1 -1
- package/dist/esm/core/Clock.d.ts +21 -0
- package/dist/esm/core/Clock.js +21 -0
- package/dist/esm/core/Clock.js.map +1 -1
- package/dist/esm/core/Color.d.ts +35 -0
- package/dist/esm/core/Color.js +35 -0
- package/dist/esm/core/Color.js.map +1 -1
- package/dist/esm/core/Scene.d.ts +76 -0
- package/dist/esm/core/Scene.js +83 -0
- package/dist/esm/core/Scene.js.map +1 -1
- package/dist/esm/core/SceneManager.d.ts +62 -0
- package/dist/esm/core/SceneManager.js +51 -2
- package/dist/esm/core/SceneManager.js.map +1 -1
- package/dist/esm/core/SceneNode.d.ts +31 -0
- package/dist/esm/core/SceneNode.js +31 -0
- package/dist/esm/core/SceneNode.js.map +1 -1
- package/dist/esm/core/Signal.d.ts +44 -0
- package/dist/esm/core/Signal.js +39 -0
- package/dist/esm/core/Signal.js.map +1 -1
- package/dist/esm/core/Time.d.ts +21 -0
- package/dist/esm/core/Time.js +21 -0
- package/dist/esm/core/Time.js.map +1 -1
- package/dist/esm/core/Timer.d.ts +7 -0
- package/dist/esm/core/Timer.js +7 -0
- package/dist/esm/core/Timer.js.map +1 -1
- package/dist/esm/core/capabilities.d.ts +12 -0
- package/dist/esm/core/capabilities.js +12 -0
- package/dist/esm/core/capabilities.js.map +1 -1
- package/dist/esm/core/types.d.ts +37 -0
- package/dist/esm/core/utils.d.ts +48 -0
- package/dist/esm/core/utils.js +48 -0
- package/dist/esm/core/utils.js.map +1 -1
- package/dist/esm/debug/BoundingBoxesLayer.d.ts +8 -0
- package/dist/esm/debug/BoundingBoxesLayer.js +8 -0
- package/dist/esm/debug/BoundingBoxesLayer.js.map +1 -1
- package/dist/esm/debug/DebugLayer.d.ts +16 -3
- package/dist/esm/debug/DebugLayer.js +11 -3
- package/dist/esm/debug/DebugLayer.js.map +1 -1
- package/dist/esm/debug/DebugOverlay.d.ts +11 -0
- package/dist/esm/debug/DebugOverlay.js +8 -2
- package/dist/esm/debug/DebugOverlay.js.map +1 -1
- package/dist/esm/debug/HitTestLayer.d.ts +9 -0
- package/dist/esm/debug/HitTestLayer.js +9 -0
- package/dist/esm/debug/HitTestLayer.js.map +1 -1
- package/dist/esm/debug/PerformanceLayer.d.ts +17 -1
- package/dist/esm/debug/PerformanceLayer.js +18 -0
- package/dist/esm/debug/PerformanceLayer.js.map +1 -1
- package/dist/esm/debug/PointerStackLayer.d.ts +8 -0
- package/dist/esm/debug/PointerStackLayer.js +11 -3
- package/dist/esm/debug/PointerStackLayer.js.map +1 -1
- package/dist/esm/index.js +6 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/input/ArcadeStickGamepadMapping.d.ts +7 -0
- package/dist/esm/input/ArcadeStickGamepadMapping.js +25 -19
- package/dist/esm/input/ArcadeStickGamepadMapping.js.map +1 -1
- package/dist/esm/input/GameCubeGamepadMapping.d.ts +9 -0
- package/dist/esm/input/GameCubeGamepadMapping.js +9 -0
- package/dist/esm/input/GameCubeGamepadMapping.js.map +1 -1
- package/dist/esm/input/Gamepad.d.ts +181 -31
- package/dist/esm/input/Gamepad.js +307 -108
- package/dist/esm/input/Gamepad.js.map +1 -1
- package/dist/esm/input/GamepadAxis.d.ts +120 -0
- package/dist/esm/input/GamepadAxis.js +106 -0
- package/dist/esm/input/GamepadAxis.js.map +1 -0
- package/dist/esm/input/GamepadButton.d.ts +110 -0
- package/dist/esm/input/GamepadButton.js +99 -0
- package/dist/esm/input/GamepadButton.js.map +1 -0
- package/dist/esm/input/GamepadDefinitions.d.ts +64 -1
- package/dist/esm/input/GamepadDefinitions.js +44 -1
- package/dist/esm/input/GamepadDefinitions.js.map +1 -1
- package/dist/esm/input/GamepadMapping.d.ts +42 -8
- package/dist/esm/input/GamepadMapping.js +46 -5
- package/dist/esm/input/GamepadMapping.js.map +1 -1
- package/dist/esm/input/GamepadPromptLayouts.d.ts +35 -2
- package/dist/esm/input/GamepadPromptLayouts.js +43 -18
- package/dist/esm/input/GamepadPromptLayouts.js.map +1 -1
- package/dist/esm/input/GenericDualAnalogGamepadMapping.d.ts +13 -0
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js +62 -43
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js.map +1 -1
- package/dist/esm/input/GestureRecognizer.d.ts +11 -2
- package/dist/esm/input/GestureRecognizer.js +11 -2
- package/dist/esm/input/GestureRecognizer.js.map +1 -1
- package/dist/esm/input/InputBinding.d.ts +74 -0
- package/dist/esm/input/InputBinding.js +100 -0
- package/dist/esm/input/InputBinding.js.map +1 -0
- package/dist/esm/input/InputManager.d.ts +100 -21
- package/dist/esm/input/InputManager.js +248 -90
- package/dist/esm/input/InputManager.js.map +1 -1
- package/dist/esm/input/InteractionEvent.d.ts +13 -0
- package/dist/esm/input/InteractionEvent.js +8 -0
- package/dist/esm/input/InteractionEvent.js.map +1 -1
- package/dist/esm/input/InteractionManager.d.ts +34 -5
- package/dist/esm/input/InteractionManager.js +46 -17
- package/dist/esm/input/InteractionManager.js.map +1 -1
- package/dist/esm/input/JoyConLeftGamepadMapping.d.ts +17 -3
- package/dist/esm/input/JoyConLeftGamepadMapping.js +42 -3
- package/dist/esm/input/JoyConLeftGamepadMapping.js.map +1 -1
- package/dist/esm/input/JoyConRightGamepadMapping.d.ts +17 -3
- package/dist/esm/input/JoyConRightGamepadMapping.js +38 -3
- package/dist/esm/input/JoyConRightGamepadMapping.js.map +1 -1
- package/dist/esm/input/PlayStationGamepadMapping.d.ts +8 -0
- package/dist/esm/input/PlayStationGamepadMapping.js +8 -0
- package/dist/esm/input/PlayStationGamepadMapping.js.map +1 -1
- package/dist/esm/input/Pointer.d.ts +106 -71
- package/dist/esm/input/Pointer.js +93 -71
- package/dist/esm/input/Pointer.js.map +1 -1
- package/dist/esm/input/SteamControllerGamepadMapping.d.ts +8 -0
- package/dist/esm/input/SteamControllerGamepadMapping.js +8 -0
- package/dist/esm/input/SteamControllerGamepadMapping.js.map +1 -1
- package/dist/esm/input/SteamDeckGamepadMapping.d.ts +18 -0
- package/dist/esm/input/SteamDeckGamepadMapping.js +76 -0
- package/dist/esm/input/SteamDeckGamepadMapping.js.map +1 -0
- package/dist/esm/input/SwitchProGamepadMapping.d.ts +9 -0
- package/dist/esm/input/SwitchProGamepadMapping.js +9 -0
- package/dist/esm/input/SwitchProGamepadMapping.js.map +1 -1
- package/dist/esm/input/XboxGamepadMapping.d.ts +8 -0
- package/dist/esm/input/XboxGamepadMapping.js +8 -0
- package/dist/esm/input/XboxGamepadMapping.js.map +1 -1
- package/dist/esm/input/index.d.ts +7 -4
- package/dist/esm/input/types.d.ts +17 -73
- package/dist/esm/input/types.js +18 -77
- package/dist/esm/input/types.js.map +1 -1
- package/dist/esm/math/AbstractVector.d.ts +83 -0
- package/dist/esm/math/AbstractVector.js +83 -0
- package/dist/esm/math/AbstractVector.js.map +1 -1
- package/dist/esm/math/Circle.d.ts +32 -0
- package/dist/esm/math/Circle.js +34 -2
- package/dist/esm/math/Circle.js.map +1 -1
- package/dist/esm/math/CircleLike.d.ts +1 -0
- package/dist/esm/math/Collision.d.ts +39 -0
- package/dist/esm/math/Collision.js +5 -0
- package/dist/esm/math/Collision.js.map +1 -1
- package/dist/esm/math/Ellipse.d.ts +11 -0
- package/dist/esm/math/Ellipse.js +18 -2
- package/dist/esm/math/Ellipse.js.map +1 -1
- package/dist/esm/math/EllipseLike.d.ts +3 -0
- package/dist/esm/math/Flags.d.ts +31 -0
- package/dist/esm/math/Flags.js +31 -0
- package/dist/esm/math/Flags.js.map +1 -1
- package/dist/esm/math/Interval.d.ts +15 -0
- package/dist/esm/math/Interval.js +15 -0
- package/dist/esm/math/Interval.js.map +1 -1
- package/dist/esm/math/Line.d.ts +17 -1
- package/dist/esm/math/Line.js +17 -1
- package/dist/esm/math/Line.js.map +1 -1
- package/dist/esm/math/LineLike.d.ts +1 -0
- package/dist/esm/math/Matrix.d.ts +44 -3
- package/dist/esm/math/Matrix.js +44 -3
- package/dist/esm/math/Matrix.js.map +1 -1
- package/dist/esm/math/ObservableSize.d.ts +7 -0
- package/dist/esm/math/ObservableSize.js +7 -0
- package/dist/esm/math/ObservableSize.js.map +1 -1
- package/dist/esm/math/ObservableVector.d.ts +9 -0
- package/dist/esm/math/ObservableVector.js +9 -0
- package/dist/esm/math/ObservableVector.js.map +1 -1
- package/dist/esm/math/PointLike.d.ts +1 -0
- package/dist/esm/math/PolarVector.d.ts +15 -0
- package/dist/esm/math/PolarVector.js +16 -1
- package/dist/esm/math/PolarVector.js.map +1 -1
- package/dist/esm/math/Polygon.d.ts +20 -0
- package/dist/esm/math/Polygon.js +20 -0
- package/dist/esm/math/Polygon.js.map +1 -1
- package/dist/esm/math/PolygonLike.d.ts +4 -0
- package/dist/esm/math/Quadtree.d.ts +40 -3
- package/dist/esm/math/Quadtree.js +39 -3
- package/dist/esm/math/Quadtree.js.map +1 -1
- package/dist/esm/math/Random.d.ts +25 -0
- package/dist/esm/math/Random.js +25 -0
- package/dist/esm/math/Random.js.map +1 -1
- package/dist/esm/math/Rectangle.d.ts +15 -0
- package/dist/esm/math/Rectangle.js +17 -2
- package/dist/esm/math/Rectangle.js.map +1 -1
- package/dist/esm/math/RectangleLike.d.ts +1 -0
- package/dist/esm/math/Segment.d.ts +7 -0
- package/dist/esm/math/Segment.js +7 -0
- package/dist/esm/math/Segment.js.map +1 -1
- package/dist/esm/math/ShapeLike.d.ts +6 -0
- package/dist/esm/math/Size.d.ts +9 -0
- package/dist/esm/math/Size.js +9 -0
- package/dist/esm/math/Size.js.map +1 -1
- package/dist/esm/math/Vector.d.ts +16 -0
- package/dist/esm/math/Vector.js +16 -0
- package/dist/esm/math/Vector.js.map +1 -1
- package/dist/esm/math/collision-detection.d.ts +47 -1
- package/dist/esm/math/collision-detection.js +228 -17
- package/dist/esm/math/collision-detection.js.map +1 -1
- package/dist/esm/math/collision-primitives.d.ts +23 -0
- package/dist/esm/math/collision-primitives.js +23 -0
- package/dist/esm/math/collision-primitives.js.map +1 -1
- package/dist/esm/math/geometry.d.ts +42 -0
- package/dist/esm/math/geometry.js +37 -0
- package/dist/esm/math/geometry.js.map +1 -1
- package/dist/esm/math/utils.d.ts +41 -0
- package/dist/esm/math/utils.js +41 -0
- package/dist/esm/math/utils.js.map +1 -1
- package/dist/esm/particles/Particle.d.ts +37 -0
- package/dist/esm/particles/Particle.js +37 -0
- package/dist/esm/particles/Particle.js.map +1 -1
- package/dist/esm/particles/ParticleProperties.d.ts +15 -0
- package/dist/esm/particles/ParticleSystem.d.ts +69 -0
- package/dist/esm/particles/ParticleSystem.js +69 -0
- package/dist/esm/particles/ParticleSystem.js.map +1 -1
- package/dist/esm/particles/affectors/ColorAffector.d.ts +13 -0
- package/dist/esm/particles/affectors/ColorAffector.js +13 -0
- package/dist/esm/particles/affectors/ColorAffector.js.map +1 -1
- package/dist/esm/particles/affectors/ForceAffector.d.ts +11 -0
- package/dist/esm/particles/affectors/ForceAffector.js +11 -0
- package/dist/esm/particles/affectors/ForceAffector.js.map +1 -1
- package/dist/esm/particles/affectors/ParticleAffector.d.ts +13 -0
- package/dist/esm/particles/affectors/ScaleAffector.d.ts +10 -0
- package/dist/esm/particles/affectors/ScaleAffector.js +10 -0
- package/dist/esm/particles/affectors/ScaleAffector.js.map +1 -1
- package/dist/esm/particles/affectors/TorqueAffector.d.ts +11 -0
- package/dist/esm/particles/affectors/TorqueAffector.js +11 -0
- package/dist/esm/particles/affectors/TorqueAffector.js.map +1 -1
- package/dist/esm/particles/emitters/ParticleEmitter.d.ts +13 -0
- package/dist/esm/particles/emitters/ParticleOptions.d.ts +16 -0
- package/dist/esm/particles/emitters/ParticleOptions.js +16 -0
- package/dist/esm/particles/emitters/ParticleOptions.js.map +1 -1
- package/dist/esm/particles/emitters/UniversalEmitter.d.ts +23 -0
- package/dist/esm/particles/emitters/UniversalEmitter.js +23 -0
- package/dist/esm/particles/emitters/UniversalEmitter.js.map +1 -1
- package/dist/esm/rendering/CallbackRenderPass.d.ts +12 -0
- package/dist/esm/rendering/CallbackRenderPass.js +12 -0
- package/dist/esm/rendering/CallbackRenderPass.js.map +1 -1
- package/dist/esm/rendering/Container.d.ts +43 -0
- package/dist/esm/rendering/Container.js +43 -0
- package/dist/esm/rendering/Container.js.map +1 -1
- package/dist/esm/rendering/Drawable.d.ts +22 -0
- package/dist/esm/rendering/Drawable.js +22 -0
- package/dist/esm/rendering/Drawable.js.map +1 -1
- package/dist/esm/rendering/RenderBackend.d.ts +13 -0
- package/dist/esm/rendering/RenderBackendType.d.ts +4 -0
- package/dist/esm/rendering/RenderBackendType.js +4 -0
- package/dist/esm/rendering/RenderBackendType.js.map +1 -1
- package/dist/esm/rendering/RenderNode.d.ts +18 -0
- package/dist/esm/rendering/RenderNode.js +18 -0
- package/dist/esm/rendering/RenderNode.js.map +1 -1
- package/dist/esm/rendering/RenderPass.d.ts +8 -0
- package/dist/esm/rendering/RenderStats.d.ts +19 -0
- package/dist/esm/rendering/RenderStats.js +7 -0
- package/dist/esm/rendering/RenderStats.js.map +1 -1
- package/dist/esm/rendering/RenderTarget.d.ts +17 -0
- package/dist/esm/rendering/RenderTarget.js +17 -0
- package/dist/esm/rendering/RenderTarget.js.map +1 -1
- package/dist/esm/rendering/RenderTargetPass.d.ts +11 -0
- package/dist/esm/rendering/RenderTargetPass.js +7 -0
- package/dist/esm/rendering/RenderTargetPass.js.map +1 -1
- package/dist/esm/rendering/Renderer.d.ts +15 -0
- package/dist/esm/rendering/RendererRegistry.d.ts +7 -0
- package/dist/esm/rendering/RendererRegistry.js +7 -0
- package/dist/esm/rendering/RendererRegistry.js.map +1 -1
- package/dist/esm/rendering/View.d.ts +67 -2
- package/dist/esm/rendering/View.js +57 -0
- package/dist/esm/rendering/View.js.map +1 -1
- package/dist/esm/rendering/filters/BlurFilter.d.ts +9 -0
- package/dist/esm/rendering/filters/BlurFilter.js +8 -0
- package/dist/esm/rendering/filters/BlurFilter.js.map +1 -1
- package/dist/esm/rendering/filters/ColorFilter.d.ts +7 -0
- package/dist/esm/rendering/filters/ColorFilter.js +7 -0
- package/dist/esm/rendering/filters/ColorFilter.js.map +1 -1
- package/dist/esm/rendering/filters/Filter.d.ts +23 -0
- package/dist/esm/rendering/filters/Filter.js +20 -0
- package/dist/esm/rendering/filters/Filter.js.map +1 -1
- package/dist/esm/rendering/filters/WebGl2ShaderFilter.d.ts +5 -0
- package/dist/esm/rendering/filters/WebGl2ShaderFilter.js +5 -0
- package/dist/esm/rendering/filters/WebGl2ShaderFilter.js.map +1 -1
- package/dist/esm/rendering/filters/WebGpuShaderFilter.d.ts +5 -0
- package/dist/esm/rendering/filters/WebGpuShaderFilter.js +5 -0
- package/dist/esm/rendering/filters/WebGpuShaderFilter.js.map +1 -1
- package/dist/esm/rendering/mesh/Mesh.d.ts +2 -0
- package/dist/esm/rendering/mesh/Mesh.js +2 -0
- package/dist/esm/rendering/mesh/Mesh.js.map +1 -1
- package/dist/esm/rendering/primitives/Graphics.d.ts +34 -0
- package/dist/esm/rendering/primitives/Graphics.js +34 -0
- package/dist/esm/rendering/primitives/Graphics.js.map +1 -1
- package/dist/esm/rendering/shader/Shader.d.ts +36 -0
- package/dist/esm/rendering/shader/Shader.js +26 -0
- package/dist/esm/rendering/shader/Shader.js.map +1 -1
- package/dist/esm/rendering/shader/ShaderAttribute.d.ts +13 -0
- package/dist/esm/rendering/shader/ShaderAttribute.js +13 -0
- package/dist/esm/rendering/shader/ShaderAttribute.js.map +1 -1
- package/dist/esm/rendering/shader/ShaderUniform.d.ts +27 -0
- package/dist/esm/rendering/shader/ShaderUniform.js +28 -1
- package/dist/esm/rendering/shader/ShaderUniform.js.map +1 -1
- package/dist/esm/rendering/sprite/AnimatedSprite.d.ts +38 -0
- package/dist/esm/rendering/sprite/AnimatedSprite.js +36 -0
- package/dist/esm/rendering/sprite/AnimatedSprite.js.map +1 -1
- package/dist/esm/rendering/sprite/Sprite.d.ts +56 -0
- package/dist/esm/rendering/sprite/Sprite.js +56 -0
- package/dist/esm/rendering/sprite/Sprite.js.map +1 -1
- package/dist/esm/rendering/sprite/Spritesheet.d.ts +25 -0
- package/dist/esm/rendering/sprite/Spritesheet.js +20 -0
- package/dist/esm/rendering/sprite/Spritesheet.js.map +1 -1
- package/dist/esm/rendering/text/Text.d.ts +2 -0
- package/dist/esm/rendering/text/Text.js +2 -0
- package/dist/esm/rendering/text/Text.js.map +1 -1
- package/dist/esm/rendering/text/TextStyle.d.ts +29 -0
- package/dist/esm/rendering/text/TextStyle.js +24 -0
- package/dist/esm/rendering/text/TextStyle.js.map +1 -1
- package/dist/esm/rendering/text/types.d.ts +1 -0
- package/dist/esm/rendering/texture/RenderTexture.d.ts +16 -0
- package/dist/esm/rendering/texture/RenderTexture.js +16 -0
- package/dist/esm/rendering/texture/RenderTexture.js.map +1 -1
- package/dist/esm/rendering/texture/Sampler.d.ts +23 -0
- package/dist/esm/rendering/texture/Sampler.js +13 -0
- package/dist/esm/rendering/texture/Sampler.js.map +1 -1
- package/dist/esm/rendering/texture/Texture.d.ts +30 -0
- package/dist/esm/rendering/texture/Texture.js +30 -0
- package/dist/esm/rendering/texture/Texture.js.map +1 -1
- package/dist/esm/rendering/types.d.ts +29 -0
- package/dist/esm/rendering/types.js +29 -0
- package/dist/esm/rendering/types.js.map +1 -1
- package/dist/esm/rendering/utils.d.ts +20 -0
- package/dist/esm/rendering/utils.js +10 -0
- package/dist/esm/rendering/utils.js.map +1 -1
- package/dist/esm/rendering/video/Video.d.ts +35 -1
- package/dist/esm/rendering/video/Video.js +36 -2
- package/dist/esm/rendering/video/Video.js.map +1 -1
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.d.ts +7 -0
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.js +7 -0
- package/dist/esm/rendering/webgl2/AbstractWebGl2BatchedRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2Backend.d.ts +13 -0
- package/dist/esm/rendering/webgl2/WebGl2Backend.js +13 -0
- package/dist/esm/rendering/webgl2/WebGl2Backend.js.map +1 -1
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.d.ts +8 -0
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.js +8 -0
- package/dist/esm/rendering/webgl2/WebGl2RenderBuffer.js.map +1 -1
- package/dist/esm/rendering/webgpu/WebGpuBackend.d.ts +35 -0
- package/dist/esm/rendering/webgpu/WebGpuBackend.js +135 -5
- package/dist/esm/rendering/webgpu/WebGpuBackend.js.map +1 -1
- package/dist/esm/resources/AbstractAssetFactory.d.ts +20 -0
- package/dist/esm/resources/AbstractAssetFactory.js +20 -0
- package/dist/esm/resources/AbstractAssetFactory.js.map +1 -1
- package/dist/esm/resources/AssetFactory.d.ts +26 -0
- package/dist/esm/resources/AssetManifest.d.ts +45 -0
- package/dist/esm/resources/AssetManifest.js +25 -0
- package/dist/esm/resources/AssetManifest.js.map +1 -1
- package/dist/esm/resources/CacheFirstStrategy.d.ts +15 -0
- package/dist/esm/resources/CacheFirstStrategy.js +19 -4
- package/dist/esm/resources/CacheFirstStrategy.js.map +1 -1
- package/dist/esm/resources/CacheStore.d.ts +23 -0
- package/dist/esm/resources/CacheStrategy.d.ts +28 -0
- package/dist/esm/resources/Database.d.ts +45 -0
- package/dist/esm/resources/FactoryRegistry.d.ts +28 -0
- package/dist/esm/resources/FactoryRegistry.js +24 -0
- package/dist/esm/resources/FactoryRegistry.js.map +1 -1
- package/dist/esm/resources/IndexedDbDatabase.d.ts +22 -1
- package/dist/esm/resources/IndexedDbDatabase.js +21 -0
- package/dist/esm/resources/IndexedDbDatabase.js.map +1 -1
- package/dist/esm/resources/IndexedDbStore.d.ts +20 -0
- package/dist/esm/resources/IndexedDbStore.js +12 -0
- package/dist/esm/resources/IndexedDbStore.js.map +1 -1
- package/dist/esm/resources/Loader.d.ts +172 -0
- package/dist/esm/resources/Loader.js +129 -37
- package/dist/esm/resources/Loader.js.map +1 -1
- package/dist/esm/resources/NetworkOnlyStrategy.d.ts +11 -0
- package/dist/esm/resources/NetworkOnlyStrategy.js +16 -3
- package/dist/esm/resources/NetworkOnlyStrategy.js.map +1 -1
- package/dist/esm/resources/factories/BinaryFactory.d.ts +13 -0
- package/dist/esm/resources/factories/BinaryFactory.js +13 -0
- package/dist/esm/resources/factories/BinaryFactory.js.map +1 -1
- package/dist/esm/resources/factories/FontFactory.d.ts +37 -0
- package/dist/esm/resources/factories/FontFactory.js +26 -0
- package/dist/esm/resources/factories/FontFactory.js.map +1 -1
- package/dist/esm/resources/factories/ImageFactory.d.ts +26 -2
- package/dist/esm/resources/factories/ImageFactory.js +19 -0
- package/dist/esm/resources/factories/ImageFactory.js.map +1 -1
- package/dist/esm/resources/factories/JsonFactory.d.ts +13 -0
- package/dist/esm/resources/factories/JsonFactory.js +13 -0
- package/dist/esm/resources/factories/JsonFactory.js.map +1 -1
- package/dist/esm/resources/factories/MusicFactory.d.ts +36 -0
- package/dist/esm/resources/factories/MusicFactory.js +44 -4
- package/dist/esm/resources/factories/MusicFactory.js.map +1 -1
- package/dist/esm/resources/factories/SoundFactory.d.ts +29 -0
- package/dist/esm/resources/factories/SoundFactory.js +18 -0
- package/dist/esm/resources/factories/SoundFactory.js.map +1 -1
- package/dist/esm/resources/factories/SvgFactory.d.ts +19 -0
- package/dist/esm/resources/factories/SvgFactory.js +19 -0
- package/dist/esm/resources/factories/SvgFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextFactory.d.ts +11 -0
- package/dist/esm/resources/factories/TextFactory.js +11 -0
- package/dist/esm/resources/factories/TextFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextureFactory.d.ts +27 -2
- package/dist/esm/resources/factories/TextureFactory.js +20 -0
- package/dist/esm/resources/factories/TextureFactory.js.map +1 -1
- package/dist/esm/resources/factories/VideoFactory.d.ts +37 -0
- package/dist/esm/resources/factories/VideoFactory.js +48 -5
- package/dist/esm/resources/factories/VideoFactory.js.map +1 -1
- package/dist/esm/resources/factories/VttFactory.d.ts +18 -0
- package/dist/esm/resources/factories/VttFactory.js +104 -3
- package/dist/esm/resources/factories/VttFactory.js.map +1 -1
- package/dist/esm/resources/factories/WasmFactory.d.ts +16 -0
- package/dist/esm/resources/factories/WasmFactory.js +16 -0
- package/dist/esm/resources/factories/WasmFactory.js.map +1 -1
- package/dist/esm/resources/utils.d.ts +10 -0
- package/dist/esm/resources/utils.js +10 -0
- package/dist/esm/resources/utils.js.map +1 -1
- package/dist/exo.esm.js +4673 -745
- package/dist/exo.esm.js.map +1 -1
- package/package.json +8 -8
- package/dist/esm/input/GamepadChannels.d.ts +0 -39
- package/dist/esm/input/GamepadChannels.js +0 -45
- package/dist/esm/input/GamepadChannels.js.map +0 -1
- package/dist/esm/input/GamepadControl.d.ts +0 -15
- package/dist/esm/input/GamepadControl.js +0 -29
- package/dist/esm/input/GamepadControl.js.map +0 -1
- package/dist/esm/input/Input.d.ts +0 -28
- package/dist/esm/input/Input.js +0 -68
- package/dist/esm/input/Input.js.map +0 -1
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
import type { AssetFactory } from './AssetFactory';
|
|
2
2
|
import type { CacheStore } from './CacheStore';
|
|
3
|
+
/**
|
|
4
|
+
* All the information a {@link CacheStrategy} needs to resolve a single asset.
|
|
5
|
+
*
|
|
6
|
+
* Bundles the target factory, cache namespace, lookup key, the fetch
|
|
7
|
+
* parameters, and any factory-specific options into one value so strategies
|
|
8
|
+
* remain stateless.
|
|
9
|
+
*/
|
|
3
10
|
export interface CacheRequest {
|
|
11
|
+
/** The {@link AssetFactory.storageName} used as the cache namespace. */
|
|
4
12
|
readonly storageName: string;
|
|
13
|
+
/** The per-asset lookup key (typically the alias). */
|
|
5
14
|
readonly key: string;
|
|
15
|
+
/** The fully resolved URL to fetch from the network if the cache misses. */
|
|
6
16
|
readonly url: string;
|
|
7
17
|
readonly requestOptions: RequestInit;
|
|
8
18
|
readonly factory: AssetFactory;
|
|
19
|
+
/** Factory-specific options forwarded to {@link AssetFactory.create}. */
|
|
20
|
+
readonly options?: unknown;
|
|
9
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Strategy interface that decides how assets are fetched and cached.
|
|
24
|
+
*
|
|
25
|
+
* Implementations own the full pipeline: cache check (if applicable) →
|
|
26
|
+
* network fetch (if needed) → factory.process → factory.create → cache
|
|
27
|
+
* write (if applicable). The returned value is the fully constructed
|
|
28
|
+
* resource (post-{@link AssetFactory.create}), not the intermediate source.
|
|
29
|
+
*
|
|
30
|
+
* ExoJS ships {@link CacheFirstStrategy} (default) and {@link NetworkOnlyStrategy};
|
|
31
|
+
* implement this interface to add custom policies such as network-first,
|
|
32
|
+
* stale-while-revalidate, or cache-only / offline-first.
|
|
33
|
+
*/
|
|
10
34
|
export interface CacheStrategy {
|
|
35
|
+
/**
|
|
36
|
+
* Resolves a single asset according to the strategy's caching policy and
|
|
37
|
+
* returns the fully constructed resource.
|
|
38
|
+
*/
|
|
11
39
|
resolve(request: CacheRequest, stores: ReadonlyArray<CacheStore>): Promise<unknown>;
|
|
12
40
|
}
|
|
@@ -1,13 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level key/value database abstraction used by {@link CacheStore}
|
|
3
|
+
* implementations.
|
|
4
|
+
*
|
|
5
|
+
* Data is organised into named object stores (`type`) that act as namespaces,
|
|
6
|
+
* each holding entries keyed by `name`. {@link IndexedDbDatabase} is the
|
|
7
|
+
* built-in implementation; custom backends can be provided by implementing
|
|
8
|
+
* this interface and wrapping it in a {@link CacheStore}.
|
|
9
|
+
*/
|
|
1
10
|
export interface Database {
|
|
11
|
+
/** Human-readable database identifier, typically an application name. */
|
|
2
12
|
readonly name: string;
|
|
13
|
+
/** Schema version used during `upgradeneeded` migrations. */
|
|
3
14
|
readonly version: number;
|
|
15
|
+
/** Whether a live connection to the underlying database is open. */
|
|
4
16
|
readonly connected: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Opens the database connection, running any pending schema migrations.
|
|
19
|
+
* Resolves to `true` when the connection is ready; rejects on error.
|
|
20
|
+
* Calling this when already connected is a no-op that resolves `true`.
|
|
21
|
+
*/
|
|
5
22
|
connect(): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Closes the live database connection and resets the connected state.
|
|
25
|
+
* Always resolves `true`; safe to call when not connected.
|
|
26
|
+
*/
|
|
6
27
|
disconnect(): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves the entry with the given `name` from the `type` object store,
|
|
30
|
+
* or `null` if no such entry exists.
|
|
31
|
+
*/
|
|
7
32
|
load<T = unknown>(type: string, name: string): Promise<T | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Persists `data` under `name` within the `type` object store, replacing
|
|
35
|
+
* any existing entry with the same name.
|
|
36
|
+
*/
|
|
8
37
|
save(type: string, name: string, data: unknown): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Deletes the entry with the given `name` from the `type` object store.
|
|
40
|
+
* Resolves `true` on success.
|
|
41
|
+
*/
|
|
9
42
|
delete(type: string, name: string): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Removes all entries from the `type` object store without dropping the
|
|
45
|
+
* store itself. Resolves `true` on success.
|
|
46
|
+
*/
|
|
10
47
|
clearStorage(type: string): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Disconnects and then permanently deletes the entire database.
|
|
50
|
+
* Resolves `true` on success.
|
|
51
|
+
*/
|
|
11
52
|
deleteStorage(): Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Synchronously closes any open handles without waiting for pending
|
|
55
|
+
* transactions to complete. Prefer {@link disconnect} for graceful teardown.
|
|
56
|
+
*/
|
|
12
57
|
destroy(): void;
|
|
13
58
|
}
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import type { AssetFactory } from './AssetFactory';
|
|
2
|
+
/**
|
|
3
|
+
* Any abstract or concrete constructor whose instances are the asset type
|
|
4
|
+
* produced by a factory (e.g. `typeof Texture`, `typeof Sound`).
|
|
5
|
+
*/
|
|
2
6
|
export type AssetConstructor<T = unknown> = abstract new (...args: Array<any>) => T;
|
|
7
|
+
/**
|
|
8
|
+
* Maps {@link AssetConstructor} tokens to their corresponding
|
|
9
|
+
* {@link AssetFactory} instances.
|
|
10
|
+
*
|
|
11
|
+
* Resolution is prototype-chain aware: if no factory is registered for the
|
|
12
|
+
* exact constructor, the registry walks up the prototype chain and returns the
|
|
13
|
+
* first ancestor match. This means registering a factory for a base class
|
|
14
|
+
* automatically handles all subclasses.
|
|
15
|
+
*
|
|
16
|
+
* @internal Used by {@link Loader}; consumers interact through `loader.register()`.
|
|
17
|
+
*/
|
|
3
18
|
export declare class FactoryRegistry {
|
|
4
19
|
private readonly _factories;
|
|
20
|
+
/** Registers `factory` as the handler for `type` and its subclasses. */
|
|
5
21
|
register<T>(type: AssetConstructor<T>, factory: AssetFactory<T>): void;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the factory registered for `type`, walking up the prototype
|
|
24
|
+
* chain if necessary. Throws if no matching factory is found.
|
|
25
|
+
*/
|
|
6
26
|
resolve<T>(type: AssetConstructor<T>): AssetFactory<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns `true` if a factory is registered for `type` or any of its
|
|
29
|
+
* prototype-chain ancestors.
|
|
30
|
+
*/
|
|
7
31
|
has(type: AssetConstructor): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Calls {@link AssetFactory.destroy} on every registered factory and
|
|
34
|
+
* clears the registry.
|
|
35
|
+
*/
|
|
8
36
|
destroy(): void;
|
|
9
37
|
}
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps {@link AssetConstructor} tokens to their corresponding
|
|
3
|
+
* {@link AssetFactory} instances.
|
|
4
|
+
*
|
|
5
|
+
* Resolution is prototype-chain aware: if no factory is registered for the
|
|
6
|
+
* exact constructor, the registry walks up the prototype chain and returns the
|
|
7
|
+
* first ancestor match. This means registering a factory for a base class
|
|
8
|
+
* automatically handles all subclasses.
|
|
9
|
+
*
|
|
10
|
+
* @internal Used by {@link Loader}; consumers interact through `loader.register()`.
|
|
11
|
+
*/
|
|
1
12
|
class FactoryRegistry {
|
|
2
13
|
_factories = new Map();
|
|
14
|
+
/** Registers `factory` as the handler for `type` and its subclasses. */
|
|
3
15
|
register(type, factory) {
|
|
4
16
|
this._factories.set(type, factory);
|
|
5
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns the factory registered for `type`, walking up the prototype
|
|
20
|
+
* chain if necessary. Throws if no matching factory is found.
|
|
21
|
+
*/
|
|
6
22
|
resolve(type) {
|
|
7
23
|
let constructor = type;
|
|
8
24
|
let factory = undefined;
|
|
@@ -19,6 +35,10 @@ class FactoryRegistry {
|
|
|
19
35
|
}
|
|
20
36
|
return factory;
|
|
21
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns `true` if a factory is registered for `type` or any of its
|
|
40
|
+
* prototype-chain ancestors.
|
|
41
|
+
*/
|
|
22
42
|
has(type) {
|
|
23
43
|
let constructor = type;
|
|
24
44
|
while (constructor !== null) {
|
|
@@ -30,6 +50,10 @@ class FactoryRegistry {
|
|
|
30
50
|
}
|
|
31
51
|
return false;
|
|
32
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Calls {@link AssetFactory.destroy} on every registered factory and
|
|
55
|
+
* clears the registry.
|
|
56
|
+
*/
|
|
33
57
|
destroy() {
|
|
34
58
|
for (const factory of this._factories.values()) {
|
|
35
59
|
factory.destroy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FactoryRegistry.js","sources":["../../../../src/resources/FactoryRegistry.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FactoryRegistry.js","sources":["../../../../src/resources/FactoryRegistry.ts"],"sourcesContent":[null],"names":[],"mappings":"AASA;;;;;;;;;;AAUG;MACU,eAAe,CAAA;AAEP,IAAA,UAAU,GAAG,IAAI,GAAG,EAAkC;;IAGhE,QAAQ,CAAI,IAAyB,EAAE,OAAwB,EAAA;QAClE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,OAAuB,CAAC;IACtD;AAEA;;;AAGG;AACI,IAAA,OAAO,CAAI,IAAyB,EAAA;QACvC,IAAI,WAAW,GAA4B,IAAI;QAC/C,IAAI,OAAO,GAA6B,SAAS;AAEjD,QAAA,OAAO,WAAW,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE;YACrC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC;YAE1C,IAAI,CAAC,OAAO,EAAE;gBACV,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,CAA8C;AAE3G,gBAAA,WAAW,GAAG,SAAS,EAAE,WAAW,IAAI,IAAI;YAChD;QACJ;QAEA,IAAI,CAAC,OAAO,EAAE;AACV,YAAA,MAAM,IAAI,KAAK,CACX,6BAA6B,IAAI,CAAC,IAAI,CAAA,EAAA;AACpC,kBAAA,qDAAqD,CAC1D;QACL;AAEA,QAAA,OAAO,OAA0B;IACrC;AAEA;;;AAGG;AACI,IAAA,GAAG,CAAC,IAAsB,EAAA;QAC7B,IAAI,WAAW,GAA4B,IAAI;AAE/C,QAAA,OAAO,WAAW,KAAK,IAAI,EAAE;YACzB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;AAClC,gBAAA,OAAO,IAAI;YACf;YAEA,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,CAA8C;AAE3G,YAAA,WAAW,GAAG,SAAS,EAAE,WAAW,IAAI,IAAI;QAChD;AAEA,QAAA,OAAO,KAAK;IAChB;AAEA;;;AAGG;IACI,OAAO,GAAA;QACV,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE;YAC5C,OAAO,CAAC,OAAO,EAAE;QACrB;AAEA,QAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;IAC3B;AACH;;;;"}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import type { Database } from '@/resources/Database';
|
|
2
|
+
/**
|
|
3
|
+
* {@link Database} implementation backed by the browser's IndexedDB API.
|
|
4
|
+
*
|
|
5
|
+
* Each object store is created with a `keyPath` of `"name"`, so records are
|
|
6
|
+
* stored as `{ name, data }` objects. By default the database is initialised
|
|
7
|
+
* with stores for every built-in asset type (font, image, sound, etc.); pass
|
|
8
|
+
* a custom `storeNames` list to restrict or extend the set.
|
|
9
|
+
*
|
|
10
|
+
* Schema migrations are handled in two modes:
|
|
11
|
+
* - **Default** — the constructor-supplied `storeNames` list is diff'd
|
|
12
|
+
* against the existing stores and objects stores added/deleted accordingly.
|
|
13
|
+
* - **Explicit** — a `migrations` map keyed by target version runs the
|
|
14
|
+
* corresponding callback for each version between `oldVersion` and
|
|
15
|
+
* `newVersion`, allowing precise schema evolution.
|
|
16
|
+
*/
|
|
2
17
|
export declare class IndexedDbDatabase implements Database {
|
|
3
18
|
readonly name: string;
|
|
4
19
|
readonly version: number;
|
|
@@ -9,7 +24,13 @@ export declare class IndexedDbDatabase implements Database {
|
|
|
9
24
|
private _database;
|
|
10
25
|
get connected(): boolean;
|
|
11
26
|
constructor(name: string, version?: number, storeNames?: ReadonlyArray<string>, migrations?: Record<number, (db: IDBDatabase, transaction: IDBTransaction) => boolean>);
|
|
12
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Opens (or re-uses) an IDBObjectStore for `type` in the given
|
|
29
|
+
* `transactionMode`. Calls {@link connect} automatically if the database
|
|
30
|
+
* is not yet open. Used internally by the load/save/delete methods;
|
|
31
|
+
* `protected` so subclasses can extend with custom transaction shapes.
|
|
32
|
+
*/
|
|
33
|
+
protected getObjectStore(type: string, transactionMode?: IDBTransactionMode): Promise<IDBObjectStore>;
|
|
13
34
|
connect(): Promise<boolean>;
|
|
14
35
|
disconnect(): Promise<boolean>;
|
|
15
36
|
load<T = unknown>(type: string, name: string): Promise<T | null>;
|
|
@@ -4,6 +4,21 @@ const defaultStoreNames = [
|
|
|
4
4
|
'font', 'video', 'music', 'sound', 'image', 'texture',
|
|
5
5
|
'text', 'svg', 'json', 'binary', 'wasm', 'vtt',
|
|
6
6
|
];
|
|
7
|
+
/**
|
|
8
|
+
* {@link Database} implementation backed by the browser's IndexedDB API.
|
|
9
|
+
*
|
|
10
|
+
* Each object store is created with a `keyPath` of `"name"`, so records are
|
|
11
|
+
* stored as `{ name, data }` objects. By default the database is initialised
|
|
12
|
+
* with stores for every built-in asset type (font, image, sound, etc.); pass
|
|
13
|
+
* a custom `storeNames` list to restrict or extend the set.
|
|
14
|
+
*
|
|
15
|
+
* Schema migrations are handled in two modes:
|
|
16
|
+
* - **Default** — the constructor-supplied `storeNames` list is diff'd
|
|
17
|
+
* against the existing stores and objects stores added/deleted accordingly.
|
|
18
|
+
* - **Explicit** — a `migrations` map keyed by target version runs the
|
|
19
|
+
* corresponding callback for each version between `oldVersion` and
|
|
20
|
+
* `newVersion`, allowing precise schema evolution.
|
|
21
|
+
*/
|
|
7
22
|
class IndexedDbDatabase {
|
|
8
23
|
name;
|
|
9
24
|
version;
|
|
@@ -24,6 +39,12 @@ class IndexedDbDatabase {
|
|
|
24
39
|
this._storeNames = storeNames;
|
|
25
40
|
this._migrations = migrations;
|
|
26
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Opens (or re-uses) an IDBObjectStore for `type` in the given
|
|
44
|
+
* `transactionMode`. Calls {@link connect} automatically if the database
|
|
45
|
+
* is not yet open. Used internally by the load/save/delete methods;
|
|
46
|
+
* `protected` so subclasses can extend with custom transaction shapes.
|
|
47
|
+
*/
|
|
27
48
|
async getObjectStore(type, transactionMode = 'readonly') {
|
|
28
49
|
await this.connect();
|
|
29
50
|
return this._database.transaction([type], transactionMode).objectStore(type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedDbDatabase.js","sources":["../../../../src/resources/IndexedDbDatabase.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA,MAAM,iBAAiB,GAA0B;IAC7C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS;IACrD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK;CACjD;
|
|
1
|
+
{"version":3,"file":"IndexedDbDatabase.js","sources":["../../../../src/resources/IndexedDbDatabase.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA,MAAM,iBAAiB,GAA0B;IAC7C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS;IACrD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK;CACjD;AAED;;;;;;;;;;;;;;AAcG;MACU,iBAAiB,CAAA;AAEV,IAAA,IAAI;AACJ,IAAA,OAAO;AAEN,IAAA,WAAW;AACX,IAAA,WAAW;IACX,eAAe,GAAe,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;IACjE,UAAU,GAAG,KAAK;IAClB,SAAS,GAAuB,IAAI;AAE5C,IAAA,IAAW,SAAS,GAAA;QAChB,OAAO,IAAI,CAAC,UAAU;IAC1B;IAEA,WAAA,CACI,IAAY,EACZ,OAAA,GAAkB,CAAC,EACnB,UAAA,GAAoC,iBAAiB,EACrD,U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acheStore';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for {@link IndexedDbStore}.
|
|
4
|
+
*
|
|
5
|
+
* `name` is the IndexedDB database name; `version` defaults to `1`.
|
|
6
|
+
* `storeNames` overrides the default asset-type object stores, and
|
|
7
|
+
* `migrations` provides explicit per-version schema callbacks (see
|
|
8
|
+
* {@link IndexedDbDatabase} for migration semantics).
|
|
9
|
+
*/
|
|
2
10
|
export interface IndexedDbStoreOptions {
|
|
3
11
|
name: string;
|
|
4
12
|
version?: number;
|
|
5
13
|
storeNames?: ReadonlyArray<string>;
|
|
6
14
|
migrations?: Record<number, (db: IDBDatabase, transaction: IDBTransaction) => boolean>;
|
|
7
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* {@link CacheStore} implementation that persists processed asset data in an
|
|
18
|
+
* IndexedDB database via {@link IndexedDbDatabase}.
|
|
19
|
+
*
|
|
20
|
+
* Pass an instance to {@link LoaderOptions.cache} to enable cross-session
|
|
21
|
+
* asset caching with no additional configuration beyond a database name.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const loader = new Loader({ cache: new IndexedDbStore('my-game-assets') });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
8
28
|
export declare class IndexedDbStore implements CacheStore {
|
|
9
29
|
private readonly _db;
|
|
10
30
|
constructor(nameOrOptions: string | IndexedDbStoreOptions);
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { IndexedDbDatabase } from './IndexedDbDatabase.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* {@link CacheStore} implementation that persists processed asset data in an
|
|
5
|
+
* IndexedDB database via {@link IndexedDbDatabase}.
|
|
6
|
+
*
|
|
7
|
+
* Pass an instance to {@link LoaderOptions.cache} to enable cross-session
|
|
8
|
+
* asset caching with no additional configuration beyond a database name.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const loader = new Loader({ cache: new IndexedDbStore('my-game-assets') });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
3
15
|
class IndexedDbStore {
|
|
4
16
|
_db;
|
|
5
17
|
constructor(nameOrOptions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedDbStore.js","sources":["../../../../src/resources/IndexedDbStore.ts"],"sourcesContent":[null],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"IndexedDbStore.js","sources":["../../../../src/resources/IndexedDbStore.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAkBA;;;;;;;;;;;AAWG;MACU,cAAc,CAAA;AAEN,IAAA,GAAG;AAEpB,IAAA,WAAA,CAAmB,aAA6C,EAAA;AAC5D,QAAA,MAAM,OAAO,GAAG,OAAO,aAAa,KAAK;AACrC,cAAE,EAAE,IAAI,EAAE,aAAa;cACrB,aAAa;AAEnB,QAAA,IAAI,CAAC,GAAG,GAAG,IAAI,iBAAiB,CAC5B,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,OAAO,IAAI,CAAC,EACpB,OAAO,CAAC,UAAU,IAAI;YAClB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS;YACrD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK;AACjD,SAAA,EACD,OAAO,CAAC,UAAU,CACrB;IACL;AAEO,IAAA,MAAM,IAAI,CAAC,WAAmB,EAAE,GAAW,EAAA;QAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC;IAC1C;AAEO,IAAA,MAAM,IAAI,CAAC,WAAmB,EAAE,GAAW,EAAE,IAAa,EAAA;AAC7D,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,IAAI,CAAC;IAChD;AAEO,IAAA,MAAM,MAAM,CAAC,WAAmB,EAAE,GAAW,EAAA;QAChD,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC;IAC5C;IAEO,MAAM,KAAK,CAAC,WAAmB,EAAA;QAClC,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,CAAC;IAC7C;IAEO,OAAO,GAAA;AACV,QAAA,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;IACtB;AACH;;;;"}
|
|
@@ -3,15 +3,66 @@ import { Json, TextAsset, SvgAsset, VttAsset } from './tokens';
|
|
|
3
3
|
import type { AssetFactory } from './AssetFactory';
|
|
4
4
|
import type { AssetConstructor } from './FactoryRegistry';
|
|
5
5
|
import type { CacheStore } from './CacheStore';
|
|
6
|
+
import type { CacheStrategy } from './CacheStrategy';
|
|
6
7
|
import type { AssetManifest, LoadBundleOptions } from './AssetManifest';
|
|
8
|
+
/**
|
|
9
|
+
* Any abstract or concrete constructor that can be used as an asset type token
|
|
10
|
+
* with {@link Loader.load} and related methods.
|
|
11
|
+
*/
|
|
7
12
|
export type Loadable = abstract new (...args: Array<any>) => any;
|
|
13
|
+
/**
|
|
14
|
+
* Maps a {@link Loadable} constructor to the concrete type returned by
|
|
15
|
+
* {@link Loader.load}.
|
|
16
|
+
*
|
|
17
|
+
* Token classes ({@link Json}, {@link TextAsset}, {@link SvgAsset},
|
|
18
|
+
* {@link VttAsset}) are special-cased because their return types do not match
|
|
19
|
+
* their constructor type. All other loadables return the instance type inferred
|
|
20
|
+
* from the constructor.
|
|
21
|
+
*/
|
|
8
22
|
export type LoadReturn<T> = T extends typeof Json ? unknown : T extends typeof TextAsset ? string : T extends typeof SvgAsset ? HTMLImageElement : T extends typeof VttAsset ? Array<VTTCue> : T extends abstract new (...args: Array<any>) => infer R ? R : never;
|
|
23
|
+
/**
|
|
24
|
+
* Construction options for {@link Loader}.
|
|
25
|
+
*
|
|
26
|
+
* `resourcePath` is prepended to relative asset paths at fetch time.
|
|
27
|
+
* `cache` accepts one or more {@link CacheStore} instances. `cacheStrategy`
|
|
28
|
+
* picks the policy used to consult them — defaults to
|
|
29
|
+
* {@link CacheFirstStrategy} (check stores → network → write back).
|
|
30
|
+
* `concurrency` caps the number of simultaneous background-queue fetches
|
|
31
|
+
* (default `6`).
|
|
32
|
+
*/
|
|
9
33
|
export interface LoaderOptions {
|
|
10
34
|
resourcePath?: string;
|
|
11
35
|
requestOptions?: RequestInit;
|
|
12
36
|
cache?: CacheStore | ReadonlyArray<CacheStore>;
|
|
37
|
+
cacheStrategy?: CacheStrategy;
|
|
13
38
|
concurrency?: number;
|
|
14
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Central asset management hub for ExoJS applications.
|
|
42
|
+
*
|
|
43
|
+
* The `Loader` orchestrates fetching, processing, caching, and retrieval of
|
|
44
|
+
* all engine asset types. It ships with built-in factories for every first-party
|
|
45
|
+
* type (Texture, Sound, Music, Video, FontFace, HTMLImageElement, Json, text,
|
|
46
|
+
* SVG, VTT, binary, and WASM) and allows registering custom factories via
|
|
47
|
+
* {@link register}.
|
|
48
|
+
*
|
|
49
|
+
* Assets can be loaded in three ways:
|
|
50
|
+
* - **Direct** — `loader.load(Texture, 'hero.png')` fetches immediately and
|
|
51
|
+
* resolves to the finished asset.
|
|
52
|
+
* - **Bundle** — declare assets in a manifest with {@link registerManifest},
|
|
53
|
+
* then call {@link loadBundle} to load groups on demand.
|
|
54
|
+
* - **Background** — call {@link backgroundLoad} or {@link loadAll} to
|
|
55
|
+
* pre-warm everything registered in the manifest at low priority.
|
|
56
|
+
*
|
|
57
|
+
* Once loaded, assets are stored in memory and returned from cache on
|
|
58
|
+
* subsequent `load` or {@link get} calls without re-fetching.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const loader = new Loader({ resourcePath: '/assets/', cache: new IndexedDbStore('game') });
|
|
63
|
+
* const texture = await loader.load(Texture, 'hero.png');
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
15
66
|
export declare class Loader {
|
|
16
67
|
private readonly _registry;
|
|
17
68
|
private readonly _resources;
|
|
@@ -21,6 +72,7 @@ export declare class Loader {
|
|
|
21
72
|
private readonly _typeIds;
|
|
22
73
|
private readonly _preventStoreKeys;
|
|
23
74
|
private readonly _stores;
|
|
75
|
+
private readonly _cacheStrategy;
|
|
24
76
|
private _resourcePath;
|
|
25
77
|
private _requestOptions;
|
|
26
78
|
private _concurrency;
|
|
@@ -30,38 +82,158 @@ export declare class Loader {
|
|
|
30
82
|
private _backgroundTotal;
|
|
31
83
|
private _backgroundLoaded;
|
|
32
84
|
private _backgroundResolve;
|
|
85
|
+
/** Dispatched after each background-queue item completes, with the running loaded/total counts. */
|
|
33
86
|
readonly onProgress: Signal<[loaded: number, total: number]>;
|
|
87
|
+
/** Dispatched after each asset within a named bundle completes loading. */
|
|
34
88
|
readonly onBundleProgress: Signal<[name: string, loaded: number, total: number]>;
|
|
89
|
+
/** Dispatched when any asset finishes loading and is stored in memory. */
|
|
35
90
|
readonly onLoaded: Signal<[type: AssetConstructor, alias: string, resource: unknown]>;
|
|
91
|
+
/** Dispatched when an asset fails to load during background or bundle loading. */
|
|
36
92
|
readonly onError: Signal<[type: AssetConstructor, alias: string, error: Error]>;
|
|
37
93
|
constructor(options?: LoaderOptions);
|
|
94
|
+
/**
|
|
95
|
+
* Registers a custom {@link AssetFactory} for `type`.
|
|
96
|
+
*
|
|
97
|
+
* Registration is prototype-chain aware: the factory will also handle any
|
|
98
|
+
* subclass of `type` that does not have its own explicit registration.
|
|
99
|
+
* Built-in types can be overridden by registering a replacement factory
|
|
100
|
+
* for the same constructor.
|
|
101
|
+
*/
|
|
38
102
|
register<T>(type: AssetConstructor<T>, factory: AssetFactory<T>): this;
|
|
103
|
+
/**
|
|
104
|
+
* Registers one or more asset aliases in the manifest without immediately
|
|
105
|
+
* loading them.
|
|
106
|
+
*
|
|
107
|
+
* - Single path: the path is used as both the alias and the URL.
|
|
108
|
+
* - Array of paths: each path becomes its own alias.
|
|
109
|
+
* - Record: keys are aliases, values are URLs.
|
|
110
|
+
*
|
|
111
|
+
* Assets pre-registered here can later be loaded by alias, included in
|
|
112
|
+
* background loads via {@link backgroundLoad}, or used as the source of
|
|
113
|
+
* truth when resolving conflicts in {@link registerManifest}.
|
|
114
|
+
*/
|
|
39
115
|
add(type: Loadable, path: string): this;
|
|
40
116
|
add(type: Loadable, paths: ReadonlyArray<string>): this;
|
|
41
117
|
add(type: Loadable, items: Readonly<Record<string, string>>): this;
|
|
118
|
+
/**
|
|
119
|
+
* Validates and registers an {@link AssetManifest}, making its bundles
|
|
120
|
+
* available to {@link loadBundle}.
|
|
121
|
+
*
|
|
122
|
+
* Throws if any bundle name is already registered or if two entries for
|
|
123
|
+
* the same (type, alias) pair have conflicting paths or options.
|
|
124
|
+
* Equivalent definitions (same path, deeply-equal options) are allowed
|
|
125
|
+
* and de-duplicated silently.
|
|
126
|
+
*/
|
|
42
127
|
registerManifest(manifest: AssetManifest): this;
|
|
128
|
+
/**
|
|
129
|
+
* Loads all assets declared in the named bundle concurrently.
|
|
130
|
+
*
|
|
131
|
+
* Dispatches {@link onBundleProgress} (and the optional `onProgress`
|
|
132
|
+
* callback) after each asset completes. If any assets fail, a
|
|
133
|
+
* {@link BundleLoadError} is thrown after all assets have settled,
|
|
134
|
+
* containing every individual failure. Throws immediately if `name` has
|
|
135
|
+
* not been registered.
|
|
136
|
+
*/
|
|
43
137
|
loadBundle(name: string, options?: LoadBundleOptions): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Returns `true` if every asset in the named bundle has been loaded and is
|
|
140
|
+
* currently held in the in-memory resource store.
|
|
141
|
+
*/
|
|
44
142
|
hasBundle(name: string): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Fetches and processes one or more assets of the given type.
|
|
145
|
+
*
|
|
146
|
+
* - **Single path** — resolves with the finished asset.
|
|
147
|
+
* - **Array of paths** — resolves with an ordered array of assets.
|
|
148
|
+
* - **Record** — resolves with a record whose keys match the input keys.
|
|
149
|
+
*
|
|
150
|
+
* In-flight and already-loaded assets are de-duplicated: calling `load`
|
|
151
|
+
* for the same (type, alias) pair while a fetch is in progress attaches
|
|
152
|
+
* to the existing promise rather than issuing a second request.
|
|
153
|
+
*
|
|
154
|
+
* Supply a custom `options` object to pass factory-specific configuration
|
|
155
|
+
* (e.g. audio decoding hints or image format overrides).
|
|
156
|
+
*/
|
|
45
157
|
load<T = unknown>(type: typeof Json, path: string, options?: unknown): Promise<T>;
|
|
46
158
|
load<T = unknown>(type: typeof Json, paths: ReadonlyArray<string>, options?: unknown): Promise<Array<T>>;
|
|
47
159
|
load<T = unknown, K extends string = string>(type: typeof Json, items: Readonly<Record<K, string>>, options?: unknown): Promise<Record<K, T>>;
|
|
48
160
|
load<T extends Loadable>(type: T, path: string, options?: unknown): Promise<LoadReturn<T>>;
|
|
49
161
|
load<T extends Loadable>(type: T, paths: ReadonlyArray<string>, options?: unknown): Promise<Array<LoadReturn<T>>>;
|
|
50
162
|
load<T extends Loadable, K extends string>(type: T, items: Readonly<Record<K, string>>, options?: unknown): Promise<Record<K, LoadReturn<T>>>;
|
|
163
|
+
/**
|
|
164
|
+
* Enqueues all manifest-registered assets that have not yet been loaded
|
|
165
|
+
* into the background fetch queue and begins draining the queue up to
|
|
166
|
+
* {@link setConcurrency | concurrency} simultaneous connections.
|
|
167
|
+
*
|
|
168
|
+
* Progress is reported via {@link onProgress}. In-flight assets and
|
|
169
|
+
* already-loaded assets are skipped automatically. Call {@link loadAll}
|
|
170
|
+
* instead if you need to await completion.
|
|
171
|
+
*/
|
|
51
172
|
backgroundLoad(): void;
|
|
173
|
+
/**
|
|
174
|
+
* Starts {@link backgroundLoad} and returns a promise that resolves when
|
|
175
|
+
* every queued background asset has finished loading (successfully or not).
|
|
176
|
+
*
|
|
177
|
+
* Individual asset errors are reported via {@link onError} but do not
|
|
178
|
+
* reject the returned promise.
|
|
179
|
+
*/
|
|
52
180
|
loadAll(): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Sets the maximum number of simultaneous background-queue fetches.
|
|
183
|
+
* Takes effect on the next {@link backgroundLoad} or {@link loadAll} call.
|
|
184
|
+
*/
|
|
53
185
|
setConcurrency(n: number): this;
|
|
186
|
+
/**
|
|
187
|
+
* Retrieves a previously loaded asset by type and alias.
|
|
188
|
+
*
|
|
189
|
+
* Throws if the asset has not been loaded. Use {@link peek} for a
|
|
190
|
+
* non-throwing alternative, or {@link has} to guard the call.
|
|
191
|
+
*/
|
|
54
192
|
get<T = unknown>(type: typeof Json, alias: string): T;
|
|
55
193
|
get<T extends Loadable>(type: T, alias: string): LoadReturn<T>;
|
|
194
|
+
/**
|
|
195
|
+
* Returns the loaded asset for `alias`, or `null` if it has not been
|
|
196
|
+
* loaded yet. Non-throwing alternative to {@link get}.
|
|
197
|
+
*/
|
|
56
198
|
peek<T = unknown>(type: typeof Json, alias: string): T | null;
|
|
57
199
|
peek<T extends Loadable>(type: T, alias: string): LoadReturn<T> | null;
|
|
200
|
+
/** Returns `true` if the asset is currently held in the in-memory store. */
|
|
58
201
|
has(type: Loadable, alias: string): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Removes a single asset from the in-memory resource store.
|
|
204
|
+
*
|
|
205
|
+
* If a fetch for this asset is still in flight, the result will be
|
|
206
|
+
* discarded once it arrives rather than written to the store, preventing
|
|
207
|
+
* a stale value from being committed after an explicit unload.
|
|
208
|
+
*/
|
|
59
209
|
unload(type: Loadable, alias: string): this;
|
|
210
|
+
/**
|
|
211
|
+
* Removes all loaded assets from the in-memory store.
|
|
212
|
+
*
|
|
213
|
+
* If `type` is provided, only that type's assets are cleared; otherwise
|
|
214
|
+
* all types are flushed. Does not cancel in-flight fetches.
|
|
215
|
+
*/
|
|
60
216
|
unloadAll(type?: Loadable): this;
|
|
217
|
+
/**
|
|
218
|
+
* Base path prepended to every relative asset URL at fetch time.
|
|
219
|
+
* Absolute URLs (starting with `http://`, `https://`, or `//`) are
|
|
220
|
+
* passed through unchanged.
|
|
221
|
+
*/
|
|
61
222
|
get resourcePath(): string;
|
|
62
223
|
set resourcePath(value: string);
|
|
224
|
+
/**
|
|
225
|
+
* Default `RequestInit` options merged into every `fetch` call.
|
|
226
|
+
* Override per-load with the `options` argument of {@link load}.
|
|
227
|
+
*/
|
|
63
228
|
get requestOptions(): RequestInit;
|
|
64
229
|
set requestOptions(value: RequestInit);
|
|
230
|
+
/**
|
|
231
|
+
* Tears down the loader and all resources it owns.
|
|
232
|
+
*
|
|
233
|
+
* Destroys the factory registry (releasing object URLs), destroys every
|
|
234
|
+
* cache store, clears all in-memory assets, manifest entries, bundle
|
|
235
|
+
* definitions, and in-flight tracking, and disconnects all signals.
|
|
236
|
+
*/
|
|
65
237
|
destroy(): void;
|
|
66
238
|
private _loadSingle;
|
|
67
239
|
private _loadSingleBackground;
|