@caperjs/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +62 -0
- package/cli/add.mjs +197 -0
- package/cli/audio/cc.mjs +128 -0
- package/cli/audio/index.mjs +42 -0
- package/cli/audio/utils.mjs +56 -0
- package/cli/create-caper.mjs +8 -0
- package/cli/create.mjs +351 -0
- package/cli/install-peerdeps.mjs +57 -0
- package/cli/update.mjs +9 -0
- package/cli/utils.mjs +81 -0
- package/cli/vite.mjs +55 -0
- package/cli/voiceover/generateVoiceoverCSV.mjs +158 -0
- package/cli/voiceover/index.mjs +1 -0
- package/cli.mjs +157 -0
- package/client.d.ts +7 -0
- package/config/assetpack.mjs +212 -0
- package/config/tsconfig.base.json +28 -0
- package/config/vite.mjs +2464 -0
- package/extras/css/accessibility.css +9 -0
- package/extras/css/fullscreen.css +28 -0
- package/extras/css/loader.css +67 -0
- package/extras/llms.txt +1602 -0
- package/lib/CaptionsPlugin-Dc8fIrjy.js +277 -0
- package/lib/CaptionsPlugin-Dc8fIrjy.js.map +1 -0
- package/lib/DataAdapter-BY2114sp.js +84 -0
- package/lib/DataAdapter-BY2114sp.js.map +1 -0
- package/lib/DebugRenderer-BJMLILqI.js +1385 -0
- package/lib/DebugRenderer-BJMLILqI.js.map +1 -0
- package/lib/DevToolsPlugin-wQ5rOkn0.js +31 -0
- package/lib/DevToolsPlugin-wQ5rOkn0.js.map +1 -0
- package/lib/GSAPPlugin-DHhSZKv8.js +350 -0
- package/lib/GSAPPlugin-DHhSZKv8.js.map +1 -0
- package/lib/LayoutPlugin-B-DF9SYM.js +1271 -0
- package/lib/LayoutPlugin-B-DF9SYM.js.map +1 -0
- package/lib/SpinePlugin-Dz_3dljz.js +6077 -0
- package/lib/SpinePlugin-Dz_3dljz.js.map +1 -0
- package/lib/StatsPlugin-Cg82JMBD.js +70 -0
- package/lib/StatsPlugin-Cg82JMBD.js.map +1 -0
- package/lib/VoiceOverPlugin-BR3ImT8C.js +114 -0
- package/lib/VoiceOverPlugin-BR3ImT8C.js.map +1 -0
- package/lib/caper.mjs +1233 -0
- package/lib/caper.mjs.map +1 -0
- package/lib/core/Application.d.ts +268 -0
- package/lib/core/Application.d.ts.map +1 -0
- package/lib/core/config.d.ts +39 -0
- package/lib/core/config.d.ts.map +1 -0
- package/lib/core/create.d.ts +41 -0
- package/lib/core/create.d.ts.map +1 -0
- package/lib/core/globals.d.ts +51 -0
- package/lib/core/globals.d.ts.map +1 -0
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/interfaces/IApplication.d.ts +566 -0
- package/lib/core/interfaces/IApplication.d.ts.map +1 -0
- package/lib/core/interfaces/IApplicationOptions.d.ts +65 -0
- package/lib/core/interfaces/IApplicationOptions.d.ts.map +1 -0
- package/lib/core/interfaces/ICoreFunctions.d.ts +49 -0
- package/lib/core/interfaces/ICoreFunctions.d.ts.map +1 -0
- package/lib/core/interfaces/ICoreSignals.d.ts +57 -0
- package/lib/core/interfaces/ICoreSignals.d.ts.map +1 -0
- package/lib/core/interfaces/IStorageCapability.d.ts +20 -0
- package/lib/core/interfaces/IStorageCapability.d.ts.map +1 -0
- package/lib/core/interfaces/IStorageCapability.test.d.ts +2 -0
- package/lib/core/interfaces/IStorageCapability.test.d.ts.map +1 -0
- package/lib/core/interfaces/index.d.ts +7 -0
- package/lib/core/interfaces/index.d.ts.map +1 -0
- package/lib/core/registries.d.ts +8 -0
- package/lib/core/registries.d.ts.map +1 -0
- package/lib/core/types.d.ts +12 -0
- package/lib/core/types.d.ts.map +1 -0
- package/lib/display/AnimatedSprite.d.ts +40 -0
- package/lib/display/AnimatedSprite.d.ts.map +1 -0
- package/lib/display/Camera.d.ts +102 -0
- package/lib/display/Camera.d.ts.map +1 -0
- package/lib/display/Container.d.ts +115 -0
- package/lib/display/Container.d.ts.map +1 -0
- package/lib/display/Entity.d.ts +46 -0
- package/lib/display/Entity.d.ts.map +1 -0
- package/lib/display/ParticleContainer.d.ts +58 -0
- package/lib/display/ParticleContainer.d.ts.map +1 -0
- package/lib/display/Scene.d.ts +250 -0
- package/lib/display/Scene.d.ts.map +1 -0
- package/lib/display/SceneTransition.d.ts +41 -0
- package/lib/display/SceneTransition.d.ts.map +1 -0
- package/lib/display/SpineAnimation.d.ts +76 -0
- package/lib/display/SpineAnimation.d.ts.map +1 -0
- package/lib/display/Svg.d.ts +5 -0
- package/lib/display/Svg.d.ts.map +1 -0
- package/lib/display/index.d.ts +10 -0
- package/lib/display/index.d.ts.map +1 -0
- package/lib/env.d.ts +6 -0
- package/lib/hello.d.ts +2 -0
- package/lib/hello.d.ts.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/mixins/animated.d.ts +53 -0
- package/lib/mixins/animated.d.ts.map +1 -0
- package/lib/mixins/factory/Factory.d.ts +8 -0
- package/lib/mixins/factory/Factory.d.ts.map +1 -0
- package/lib/mixins/factory/const.d.ts +67 -0
- package/lib/mixins/factory/const.d.ts.map +1 -0
- package/lib/mixins/factory/index.d.ts +8 -0
- package/lib/mixins/factory/index.d.ts.map +1 -0
- package/lib/mixins/factory/methods.d.ts +3 -0
- package/lib/mixins/factory/methods.d.ts.map +1 -0
- package/lib/mixins/factory/props.d.ts +160 -0
- package/lib/mixins/factory/props.d.ts.map +1 -0
- package/lib/mixins/factory/registry.d.ts +27 -0
- package/lib/mixins/factory/registry.d.ts.map +1 -0
- package/lib/mixins/factory/registry.test.d.ts +2 -0
- package/lib/mixins/factory/registry.test.d.ts.map +1 -0
- package/lib/mixins/factory/schema.d.ts +71 -0
- package/lib/mixins/factory/schema.d.ts.map +1 -0
- package/lib/mixins/factory/ui-registry.d.ts +20 -0
- package/lib/mixins/factory/ui-registry.d.ts.map +1 -0
- package/lib/mixins/factory/utils.d.ts +11 -0
- package/lib/mixins/factory/utils.d.ts.map +1 -0
- package/lib/mixins/focus.d.ts +15 -0
- package/lib/mixins/focus.d.ts.map +1 -0
- package/lib/mixins/index.d.ts +6 -0
- package/lib/mixins/index.d.ts.map +1 -0
- package/lib/mixins/interaction.d.ts +20 -0
- package/lib/mixins/interaction.d.ts.map +1 -0
- package/lib/mixins/signals.d.ts +15 -0
- package/lib/mixins/signals.d.ts.map +1 -0
- package/lib/plugins/AssetsPlugin.d.ts +79 -0
- package/lib/plugins/AssetsPlugin.d.ts.map +1 -0
- package/lib/plugins/DataAdapter.d.ts +95 -0
- package/lib/plugins/DataAdapter.d.ts.map +1 -0
- package/lib/plugins/DevToolsPlugin.d.ts +97 -0
- package/lib/plugins/DevToolsPlugin.d.ts.map +1 -0
- package/lib/plugins/FullScreenPlugin.d.ts +240 -0
- package/lib/plugins/FullScreenPlugin.d.ts.map +1 -0
- package/lib/plugins/GSAPPlugin.d.ts +634 -0
- package/lib/plugins/GSAPPlugin.d.ts.map +1 -0
- package/lib/plugins/KeyboardPlugin.d.ts +53 -0
- package/lib/plugins/KeyboardPlugin.d.ts.map +1 -0
- package/lib/plugins/LayoutPlugin.d.ts +100 -0
- package/lib/plugins/LayoutPlugin.d.ts.map +1 -0
- package/lib/plugins/LookupPlugin.d.ts +223 -0
- package/lib/plugins/LookupPlugin.d.ts.map +1 -0
- package/lib/plugins/Plugin.d.ts +132 -0
- package/lib/plugins/Plugin.d.ts.map +1 -0
- package/lib/plugins/Plugin.test.d.ts +2 -0
- package/lib/plugins/Plugin.test.d.ts.map +1 -0
- package/lib/plugins/PopupManagerPlugin.d.ts +108 -0
- package/lib/plugins/PopupManagerPlugin.d.ts.map +1 -0
- package/lib/plugins/ResizerPlugin.d.ts +62 -0
- package/lib/plugins/ResizerPlugin.d.ts.map +1 -0
- package/lib/plugins/SceneManagerPlugin.d.ts +122 -0
- package/lib/plugins/SceneManagerPlugin.d.ts.map +1 -0
- package/lib/plugins/StatsPlugin.d.ts +8 -0
- package/lib/plugins/StatsPlugin.d.ts.map +1 -0
- package/lib/plugins/TimerPlugin.d.ts +401 -0
- package/lib/plugins/TimerPlugin.d.ts.map +1 -0
- package/lib/plugins/WebEventsPlugin.d.ts +60 -0
- package/lib/plugins/WebEventsPlugin.d.ts.map +1 -0
- package/lib/plugins/actions/ActionsPlugin.d.ts +39 -0
- package/lib/plugins/actions/ActionsPlugin.d.ts.map +1 -0
- package/lib/plugins/actions/constants.d.ts +52 -0
- package/lib/plugins/actions/constants.d.ts.map +1 -0
- package/lib/plugins/actions/index.d.ts +5 -0
- package/lib/plugins/actions/index.d.ts.map +1 -0
- package/lib/plugins/actions/methods.d.ts +11 -0
- package/lib/plugins/actions/methods.d.ts.map +1 -0
- package/lib/plugins/actions/types.d.ts +25 -0
- package/lib/plugins/actions/types.d.ts.map +1 -0
- package/lib/plugins/audio/AudioChannel.d.ts +46 -0
- package/lib/plugins/audio/AudioChannel.d.ts.map +1 -0
- package/lib/plugins/audio/AudioChannel.test.d.ts +2 -0
- package/lib/plugins/audio/AudioChannel.test.d.ts.map +1 -0
- package/lib/plugins/audio/AudioInstance.d.ts +79 -0
- package/lib/plugins/audio/AudioInstance.d.ts.map +1 -0
- package/lib/plugins/audio/AudioManagerPlugin.d.ts +323 -0
- package/lib/plugins/audio/AudioManagerPlugin.d.ts.map +1 -0
- package/lib/plugins/audio/VoiceOverPlugin.d.ts +69 -0
- package/lib/plugins/audio/VoiceOverPlugin.d.ts.map +1 -0
- package/lib/plugins/audio/index.d.ts +4 -0
- package/lib/plugins/audio/index.d.ts.map +1 -0
- package/lib/plugins/breakpoints/BreakpointPlugin.d.ts +109 -0
- package/lib/plugins/breakpoints/BreakpointPlugin.d.ts.map +1 -0
- package/lib/plugins/breakpoints/BreakpointPlugin.test.d.ts +2 -0
- package/lib/plugins/breakpoints/BreakpointPlugin.test.d.ts.map +1 -0
- package/lib/plugins/breakpoints/evaluate.d.ts +53 -0
- package/lib/plugins/breakpoints/evaluate.d.ts.map +1 -0
- package/lib/plugins/breakpoints/evaluate.test.d.ts +2 -0
- package/lib/plugins/breakpoints/evaluate.test.d.ts.map +1 -0
- package/lib/plugins/breakpoints/index.d.ts +4 -0
- package/lib/plugins/breakpoints/index.d.ts.map +1 -0
- package/lib/plugins/breakpoints/methods.d.ts +23 -0
- package/lib/plugins/breakpoints/methods.d.ts.map +1 -0
- package/lib/plugins/breakpoints/types.d.ts +70 -0
- package/lib/plugins/breakpoints/types.d.ts.map +1 -0
- package/lib/plugins/captions/CaptionsPlugin.d.ts +150 -0
- package/lib/plugins/captions/CaptionsPlugin.d.ts.map +1 -0
- package/lib/plugins/captions/CaptionsRenderer.d.ts +37 -0
- package/lib/plugins/captions/CaptionsRenderer.d.ts.map +1 -0
- package/lib/plugins/captions/index.d.ts +3 -0
- package/lib/plugins/captions/index.d.ts.map +1 -0
- package/lib/plugins/defaults.d.ts +4 -0
- package/lib/plugins/defaults.d.ts.map +1 -0
- package/lib/plugins/focus/FocusManagerPlugin.d.ts +148 -0
- package/lib/plugins/focus/FocusManagerPlugin.d.ts.map +1 -0
- package/lib/plugins/focus/FocusOutliner.d.ts +32 -0
- package/lib/plugins/focus/FocusOutliner.d.ts.map +1 -0
- package/lib/plugins/focus/index.d.ts +3 -0
- package/lib/plugins/focus/index.d.ts.map +1 -0
- package/lib/plugins/i18nPlugin.d.ts +128 -0
- package/lib/plugins/i18nPlugin.d.ts.map +1 -0
- package/lib/plugins/index.d.ts +18 -0
- package/lib/plugins/index.d.ts.map +1 -0
- package/lib/plugins/input/AbstractControls.d.ts +8 -0
- package/lib/plugins/input/AbstractControls.d.ts.map +1 -0
- package/lib/plugins/input/Controls.d.ts +16 -0
- package/lib/plugins/input/Controls.d.ts.map +1 -0
- package/lib/plugins/input/InputPlugin.d.ts +52 -0
- package/lib/plugins/input/InputPlugin.d.ts.map +1 -0
- package/lib/plugins/input/constants.d.ts +8 -0
- package/lib/plugins/input/constants.d.ts.map +1 -0
- package/lib/plugins/input/index.d.ts +10 -0
- package/lib/plugins/input/index.d.ts.map +1 -0
- package/lib/plugins/input/interfaces.d.ts +30 -0
- package/lib/plugins/input/interfaces.d.ts.map +1 -0
- package/lib/plugins/input/keyboard/KeyboardContols.d.ts +28 -0
- package/lib/plugins/input/keyboard/KeyboardContols.d.ts.map +1 -0
- package/lib/plugins/input/keyboard/index.d.ts +3 -0
- package/lib/plugins/input/keyboard/index.d.ts.map +1 -0
- package/lib/plugins/input/keyboard/interfaces.d.ts +18 -0
- package/lib/plugins/input/keyboard/interfaces.d.ts.map +1 -0
- package/lib/plugins/input/methods.d.ts +4 -0
- package/lib/plugins/input/methods.d.ts.map +1 -0
- package/lib/plugins/input/touch/TouchControls.d.ts +35 -0
- package/lib/plugins/input/touch/TouchControls.d.ts.map +1 -0
- package/lib/plugins/input/touch/constants.d.ts +14 -0
- package/lib/plugins/input/touch/constants.d.ts.map +1 -0
- package/lib/plugins/input/touch/index.d.ts +4 -0
- package/lib/plugins/input/touch/index.d.ts.map +1 -0
- package/lib/plugins/input/touch/interfaces.d.ts +15 -0
- package/lib/plugins/input/touch/interfaces.d.ts.map +1 -0
- package/lib/plugins/input/types.d.ts +32 -0
- package/lib/plugins/input/types.d.ts.map +1 -0
- package/lib/plugins/input/utils.d.ts +23 -0
- package/lib/plugins/input/utils.d.ts.map +1 -0
- package/lib/plugins/spine/SpinePlugin.d.ts +6 -0
- package/lib/plugins/spine/SpinePlugin.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/BatchableSpineSlot.d.ts +31 -0
- package/lib/plugins/spine/pixi-spine/BatchableSpineSlot.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/Spine.d.ts +211 -0
- package/lib/plugins/spine/pixi-spine/Spine.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/SpineDebugRenderer.d.ts +81 -0
- package/lib/plugins/spine/pixi-spine/SpineDebugRenderer.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/SpinePipe.d.ts +21 -0
- package/lib/plugins/spine/pixi-spine/SpinePipe.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/SpineTexture.d.ts +16 -0
- package/lib/plugins/spine/pixi-spine/SpineTexture.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/assets/atlasLoader.d.ts +10 -0
- package/lib/plugins/spine/pixi-spine/assets/atlasLoader.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/assets/skeletonLoader.d.ts +6 -0
- package/lib/plugins/spine/pixi-spine/assets/skeletonLoader.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/darktint/DarkTintBatchGeometry.d.ts +5 -0
- package/lib/plugins/spine/pixi-spine/darktint/DarkTintBatchGeometry.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/darktint/DarkTintBatcher.d.ts +22 -0
- package/lib/plugins/spine/pixi-spine/darktint/DarkTintBatcher.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/darktint/DarkTintShader.d.ts +5 -0
- package/lib/plugins/spine/pixi-spine/darktint/DarkTintShader.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/darktint/darkTintBit.d.ts +51 -0
- package/lib/plugins/spine/pixi-spine/darktint/darkTintBit.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/index.d.ts +9 -0
- package/lib/plugins/spine/pixi-spine/index.d.ts.map +1 -0
- package/lib/plugins/spine/pixi-spine/require-shim.d.ts +34 -0
- package/lib/plugins/spine/pixi-spine/require-shim.d.ts.map +1 -0
- package/lib/registries-CYCaYKZI.js +6885 -0
- package/lib/registries-CYCaYKZI.js.map +1 -0
- package/lib/signals/Signal.d.ts +16 -0
- package/lib/signals/Signal.d.ts.map +1 -0
- package/lib/signals/Signal.test.d.ts +2 -0
- package/lib/signals/Signal.test.d.ts.map +1 -0
- package/lib/signals/index.d.ts +3 -0
- package/lib/signals/index.d.ts.map +1 -0
- package/lib/store/Store.d.ts +56 -0
- package/lib/store/Store.d.ts.map +1 -0
- package/lib/store/Store.test.d.ts +2 -0
- package/lib/store/Store.test.d.ts.map +1 -0
- package/lib/store/index.d.ts +2 -0
- package/lib/store/index.d.ts.map +1 -0
- package/lib/types/framework.d.ts +46 -0
- package/lib/types/gsap.d.ts +23 -0
- package/lib/ui/Button.d.ts +162 -0
- package/lib/ui/Button.d.ts.map +1 -0
- package/lib/ui/FlexContainer.d.ts +109 -0
- package/lib/ui/FlexContainer.d.ts.map +1 -0
- package/lib/ui/Input.d.ts +384 -0
- package/lib/ui/Input.d.ts.map +1 -0
- package/lib/ui/Joystick.d.ts +61 -0
- package/lib/ui/Joystick.d.ts.map +1 -0
- package/lib/ui/Popup.d.ts +109 -0
- package/lib/ui/Popup.d.ts.map +1 -0
- package/lib/ui/Toast.d.ts +131 -0
- package/lib/ui/Toast.d.ts.map +1 -0
- package/lib/ui/Toaster.d.ts +188 -0
- package/lib/ui/Toaster.d.ts.map +1 -0
- package/lib/ui/UICanvas.d.ts +155 -0
- package/lib/ui/UICanvas.d.ts.map +1 -0
- package/lib/ui/index.d.ts +9 -0
- package/lib/ui/index.d.ts.map +1 -0
- package/lib/utils/array.d.ts +11 -0
- package/lib/utils/array.d.ts.map +1 -0
- package/lib/utils/bind.d.ts +21 -0
- package/lib/utils/bind.d.ts.map +1 -0
- package/lib/utils/canvas.d.ts +2 -0
- package/lib/utils/canvas.d.ts.map +1 -0
- package/lib/utils/color.d.ts +66 -0
- package/lib/utils/color.d.ts.map +1 -0
- package/lib/utils/console/Logger.d.ts +15 -0
- package/lib/utils/console/Logger.d.ts.map +1 -0
- package/lib/utils/console/index.d.ts +2 -0
- package/lib/utils/console/index.d.ts.map +1 -0
- package/lib/utils/debug.d.ts +34 -0
- package/lib/utils/debug.d.ts.map +1 -0
- package/lib/utils/define.d.ts +100 -0
- package/lib/utils/define.d.ts.map +1 -0
- package/lib/utils/env.d.ts +4 -0
- package/lib/utils/env.d.ts.map +1 -0
- package/lib/utils/events.d.ts +12 -0
- package/lib/utils/events.d.ts.map +1 -0
- package/lib/utils/framework.d.ts +12 -0
- package/lib/utils/framework.d.ts.map +1 -0
- package/lib/utils/index.d.ts +28 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/map.d.ts +31 -0
- package/lib/utils/map.d.ts.map +1 -0
- package/lib/utils/math.d.ts +15 -0
- package/lib/utils/math.d.ts.map +1 -0
- package/lib/utils/misc.d.ts +13 -0
- package/lib/utils/misc.d.ts.map +1 -0
- package/lib/utils/number.d.ts +2 -0
- package/lib/utils/number.d.ts.map +1 -0
- package/lib/utils/object.d.ts +21 -0
- package/lib/utils/object.d.ts.map +1 -0
- package/lib/utils/padding.d.ts +4 -0
- package/lib/utils/padding.d.ts.map +1 -0
- package/lib/utils/pixi.d.ts +42 -0
- package/lib/utils/pixi.d.ts.map +1 -0
- package/lib/utils/platform.d.ts +20 -0
- package/lib/utils/platform.d.ts.map +1 -0
- package/lib/utils/point.d.ts +66 -0
- package/lib/utils/point.d.ts.map +1 -0
- package/lib/utils/promise/Queue.d.ts +60 -0
- package/lib/utils/promise/Queue.d.ts.map +1 -0
- package/lib/utils/promise/functions.d.ts +14 -0
- package/lib/utils/promise/functions.d.ts.map +1 -0
- package/lib/utils/promise/index.d.ts +3 -0
- package/lib/utils/promise/index.d.ts.map +1 -0
- package/lib/utils/random.d.ts +42 -0
- package/lib/utils/random.d.ts.map +1 -0
- package/lib/utils/rect.d.ts +26 -0
- package/lib/utils/rect.d.ts.map +1 -0
- package/lib/utils/set.d.ts +15 -0
- package/lib/utils/set.d.ts.map +1 -0
- package/lib/utils/string.d.ts +3 -0
- package/lib/utils/string.d.ts.map +1 -0
- package/lib/utils/text.d.ts +3 -0
- package/lib/utils/text.d.ts.map +1 -0
- package/lib/utils/typefilters.d.ts +4 -0
- package/lib/utils/typefilters.d.ts.map +1 -0
- package/lib/utils/types.d.ts +209 -0
- package/lib/utils/types.d.ts.map +1 -0
- package/lib/utils/vite.d.ts +25 -0
- package/lib/utils/vite.d.ts.map +1 -0
- package/lib/utils/web.d.ts +3 -0
- package/lib/utils/web.d.ts.map +1 -0
- package/lib/version.d.ts +3 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/webgl-check.d.ts +2 -0
- package/lib/webgl-check.d.ts.map +1 -0
- package/package.json +138 -0
- package/src/core/Application.ts +1091 -0
- package/src/core/config.ts +168 -0
- package/src/core/create.ts +186 -0
- package/src/core/globals.ts +299 -0
- package/src/core/index.ts +6 -0
- package/src/core/interfaces/IApplication.ts +628 -0
- package/src/core/interfaces/IApplicationOptions.ts +81 -0
- package/src/core/interfaces/ICoreFunctions.ts +86 -0
- package/src/core/interfaces/ICoreSignals.ts +77 -0
- package/src/core/interfaces/IStorageCapability.test.ts +27 -0
- package/src/core/interfaces/IStorageCapability.ts +26 -0
- package/src/core/interfaces/index.ts +6 -0
- package/src/core/registries.ts +7 -0
- package/src/core/types.ts +13 -0
- package/src/display/AnimatedSprite.ts +227 -0
- package/src/display/Camera.ts +371 -0
- package/src/display/Container.ts +240 -0
- package/src/display/Entity.ts +50 -0
- package/src/display/ParticleContainer.ts +107 -0
- package/src/display/Scene.ts +305 -0
- package/src/display/SceneTransition.ts +108 -0
- package/src/display/SpineAnimation.ts +170 -0
- package/src/display/Svg.ts +9 -0
- package/src/display/index.ts +11 -0
- package/src/env.d.ts +6 -0
- package/src/hello.ts +20 -0
- package/src/index.ts +17 -0
- package/src/mixins/animated.ts +340 -0
- package/src/mixins/factory/Factory.ts +24 -0
- package/src/mixins/factory/const.ts +363 -0
- package/src/mixins/factory/index.ts +7 -0
- package/src/mixins/factory/methods.ts +21 -0
- package/src/mixins/factory/props.ts +207 -0
- package/src/mixins/factory/registry.test.ts +83 -0
- package/src/mixins/factory/registry.ts +61 -0
- package/src/mixins/factory/schema.ts +153 -0
- package/src/mixins/factory/ui-registry.ts +54 -0
- package/src/mixins/factory/utils.ts +130 -0
- package/src/mixins/focus.ts +124 -0
- package/src/mixins/index.ts +5 -0
- package/src/mixins/interaction.ts +74 -0
- package/src/mixins/signals.ts +49 -0
- package/src/plugins/AssetsPlugin.ts +407 -0
- package/src/plugins/DataAdapter.ts +259 -0
- package/src/plugins/DevToolsPlugin.ts +103 -0
- package/src/plugins/FullScreenPlugin.ts +359 -0
- package/src/plugins/GSAPPlugin.ts +811 -0
- package/src/plugins/KeyboardPlugin.ts +160 -0
- package/src/plugins/LayoutPlugin.ts +127 -0
- package/src/plugins/LookupPlugin.ts +308 -0
- package/src/plugins/Plugin.test.ts +73 -0
- package/src/plugins/Plugin.ts +200 -0
- package/src/plugins/PopupManagerPlugin.ts +263 -0
- package/src/plugins/ResizerPlugin.ts +220 -0
- package/src/plugins/SceneManagerPlugin.ts +669 -0
- package/src/plugins/StatsPlugin.ts +24 -0
- package/src/plugins/TimerPlugin.ts +841 -0
- package/src/plugins/WebEventsPlugin.ts +132 -0
- package/src/plugins/actions/ActionsPlugin.ts +113 -0
- package/src/plugins/actions/constants.ts +45 -0
- package/src/plugins/actions/index.ts +4 -0
- package/src/plugins/actions/methods.ts +28 -0
- package/src/plugins/actions/types.ts +47 -0
- package/src/plugins/audio/AudioChannel.test.ts +101 -0
- package/src/plugins/audio/AudioChannel.ts +164 -0
- package/src/plugins/audio/AudioInstance.ts +228 -0
- package/src/plugins/audio/AudioManagerPlugin.ts +903 -0
- package/src/plugins/audio/VoiceOverPlugin.ts +354 -0
- package/src/plugins/audio/index.ts +3 -0
- package/src/plugins/breakpoints/BreakpointPlugin.test.ts +228 -0
- package/src/plugins/breakpoints/BreakpointPlugin.ts +293 -0
- package/src/plugins/breakpoints/evaluate.test.ts +239 -0
- package/src/plugins/breakpoints/evaluate.ts +201 -0
- package/src/plugins/breakpoints/index.ts +3 -0
- package/src/plugins/breakpoints/methods.ts +22 -0
- package/src/plugins/breakpoints/types.ts +86 -0
- package/src/plugins/captions/CaptionsPlugin.ts +468 -0
- package/src/plugins/captions/CaptionsRenderer.ts +184 -0
- package/src/plugins/captions/font/Sans.fnt +116 -0
- package/src/plugins/captions/font/Sans.png +0 -0
- package/src/plugins/captions/index.ts +2 -0
- package/src/plugins/defaults.ts +95 -0
- package/src/plugins/focus/FocusManagerPlugin.ts +773 -0
- package/src/plugins/focus/FocusOutliner.ts +111 -0
- package/src/plugins/focus/index.ts +2 -0
- package/src/plugins/i18nPlugin.ts +284 -0
- package/src/plugins/index.ts +17 -0
- package/src/plugins/input/AbstractControls.ts +15 -0
- package/src/plugins/input/Controls.ts +55 -0
- package/src/plugins/input/InputPlugin.ts +168 -0
- package/src/plugins/input/constants.ts +12 -0
- package/src/plugins/input/index.ts +9 -0
- package/src/plugins/input/interfaces.ts +37 -0
- package/src/plugins/input/keyboard/KeyboardContols.ts +182 -0
- package/src/plugins/input/keyboard/index.ts +2 -0
- package/src/plugins/input/keyboard/interfaces.ts +21 -0
- package/src/plugins/input/methods.ts +9 -0
- package/src/plugins/input/touch/TouchControls.ts +237 -0
- package/src/plugins/input/touch/constants.ts +34 -0
- package/src/plugins/input/touch/index.ts +3 -0
- package/src/plugins/input/touch/interfaces.ts +15 -0
- package/src/plugins/input/types.ts +41 -0
- package/src/plugins/input/utils.ts +10 -0
- package/src/plugins/spine/SpinePlugin.ts +14 -0
- package/src/plugins/spine/pixi-spine/BatchableSpineSlot.ts +138 -0
- package/src/plugins/spine/pixi-spine/Spine.ts +897 -0
- package/src/plugins/spine/pixi-spine/SpineDebugRenderer.ts +615 -0
- package/src/plugins/spine/pixi-spine/SpinePipe.ts +197 -0
- package/src/plugins/spine/pixi-spine/SpineTexture.ts +143 -0
- package/src/plugins/spine/pixi-spine/assets/atlasLoader.ts +156 -0
- package/src/plugins/spine/pixi-spine/assets/skeletonLoader.ts +80 -0
- package/src/plugins/spine/pixi-spine/darktint/DarkTintBatchGeometry.ts +92 -0
- package/src/plugins/spine/pixi-spine/darktint/DarkTintBatcher.ts +186 -0
- package/src/plugins/spine/pixi-spine/darktint/DarkTintShader.ts +74 -0
- package/src/plugins/spine/pixi-spine/darktint/darkTintBit.ts +77 -0
- package/src/plugins/spine/pixi-spine/index.ts +43 -0
- package/src/plugins/spine/pixi-spine/require-shim.ts +43 -0
- package/src/signals/Signal.test.ts +54 -0
- package/src/signals/Signal.ts +68 -0
- package/src/signals/index.ts +10 -0
- package/src/store/Store.test.ts +146 -0
- package/src/store/Store.ts +192 -0
- package/src/store/index.ts +1 -0
- package/src/types/framework.d.ts +47 -0
- package/src/types/gsap.d.ts +26 -0
- package/src/ui/Button.ts +454 -0
- package/src/ui/FlexContainer.ts +526 -0
- package/src/ui/Input.ts +1274 -0
- package/src/ui/Joystick.ts +288 -0
- package/src/ui/Popup.ts +242 -0
- package/src/ui/Toast.ts +399 -0
- package/src/ui/Toaster.ts +409 -0
- package/src/ui/UICanvas.ts +812 -0
- package/src/ui/index.ts +8 -0
- package/src/utils/array.ts +24 -0
- package/src/utils/bind.ts +79 -0
- package/src/utils/canvas.ts +26 -0
- package/src/utils/color.ts +126 -0
- package/src/utils/console/Logger.ts +86 -0
- package/src/utils/console/index.ts +1 -0
- package/src/utils/debug.ts +69 -0
- package/src/utils/define.ts +120 -0
- package/src/utils/env.ts +3 -0
- package/src/utils/events.ts +10 -0
- package/src/utils/framework.ts +45 -0
- package/src/utils/index.ts +27 -0
- package/src/utils/map.ts +59 -0
- package/src/utils/math.ts +19 -0
- package/src/utils/misc.ts +45 -0
- package/src/utils/number.ts +3 -0
- package/src/utils/object.ts +43 -0
- package/src/utils/padding.ts +43 -0
- package/src/utils/pixi.ts +116 -0
- package/src/utils/platform.ts +33 -0
- package/src/utils/point.ts +123 -0
- package/src/utils/promise/Queue.ts +125 -0
- package/src/utils/promise/functions.ts +16 -0
- package/src/utils/promise/index.ts +2 -0
- package/src/utils/random.ts +69 -0
- package/src/utils/rect.ts +50 -0
- package/src/utils/set.ts +32 -0
- package/src/utils/string.ts +9 -0
- package/src/utils/text.ts +30 -0
- package/src/utils/typefilters.ts +29 -0
- package/src/utils/types.ts +426 -0
- package/src/utils/vite.ts +41 -0
- package/src/utils/web.ts +7 -0
- package/src/version.ts +3 -0
- package/src/webgl-check.ts +12 -0
- package/templates/app/default/.eslintrc.json +21 -0
- package/templates/app/default/.meta.json +4 -0
- package/templates/app/default/.nvmrc +1 -0
- package/templates/app/default/.prettierrc.json +7 -0
- package/templates/app/default/README.md +8 -0
- package/templates/app/default/assets/audio{m}/music/Cheerful Annoyance.ogg +0 -0
- package/templates/app/default/assets/audio{m}/music/Drumming Sticks.ogg +0 -0
- package/templates/app/default/assets/audio{m}/music/Game Over.ogg +0 -0
- package/templates/app/default/assets/audio{m}/music/Mishief Stroll.ogg +0 -0
- package/templates/app/default/assets/audio{m}/music/Night at the Beach.ogg +0 -0
- package/templates/app/default/assets/audio{m}/sfx/click.ogg +0 -0
- package/templates/app/default/assets/audio{m}/sfx/hover.ogg +0 -0
- package/templates/app/default/assets/required{m}/caper.png +0 -0
- package/templates/app/default/assets/required{m}/fonts{fix}/SpaceGrotesk-Bold{family=Space Grotesk}{wf}.ttf +0 -0
- package/templates/app/default/assets/required{m}/fonts{fix}/SpaceGrotesk-Medium{family=Space Grotesk}{wf}.ttf +0 -0
- package/templates/app/default/assets/required{m}/fonts{fix}/SpaceGrotesk-Regular{family=Space Grotesk}{wf}.ttf +0 -0
- package/templates/app/default/assets/required{m}/fonts{fix}/Syncopate-Bold{family=Syncopate}{wf}.ttf +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn/blue.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn/green.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn/grey.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn/orange.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn/purple.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn/red.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn/yellow.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn_a/down.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn_a/over.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn_a/up.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn_b/down.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn_b/over.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/btn_b/up.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/joystick/base.png +0 -0
- package/templates/app/default/assets/required{m}/ui{tps}/joystick/handle.png +0 -0
- package/templates/app/default/assets/required{m}/wordmark.svg +1 -0
- package/templates/app/default/assets/spine{m}/spineboy-pro.png +0 -0
- package/templates/app/default/assets/spine{m}/spineboy-pro.skel +0 -0
- package/templates/app/default/assets/spine{m}/spineboy-pro{fix}.atlas +94 -0
- package/templates/app/default/caper.config.ts +60 -0
- package/templates/app/default/index.html +23 -0
- package/templates/app/default/package.template.json +17 -0
- package/templates/app/default/public/favicon.ico +0 -0
- package/templates/app/default/src/__APPLICATION_NAME__.ts +3 -0
- package/templates/app/default/src/main.ts +9 -0
- package/templates/app/default/src/scenes/Base.ts +39 -0
- package/templates/app/default/src/scenes/Game.ts +34 -0
- package/templates/app/default/src/scenes/Splash.ts +70 -0
- package/templates/app/default/src/scenes/Start.ts +90 -0
- package/templates/app/default/src/utils/Constants.ts +3 -0
- package/templates/app/default/tsconfig.json +1 -0
- package/templates/plugin/package.template.json +33 -0
- package/templates/plugin/src/Plugin.template.ts +24 -0
- package/templates/plugin/src/index.template.ts +3 -0
- package/templates/plugin/tsconfig.template.json +43 -0
- package/templates/plugin/vite-env.template.d.ts +16 -0
- package/templates/plugin/vite.config.template.ts +19 -0
package/src/utils/map.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the map entry that comes before the entry with the provided key.
|
|
3
|
+
* If the provided key is the first entry in the map or doesn't exist in the map, the function returns undefined.
|
|
4
|
+
* @param {Map<K, V>} map The map to search in.
|
|
5
|
+
* @param {any} currentKey The key of the map entry that comes after the desired entry.
|
|
6
|
+
* @returns {[K, V] | undefined} The map entry that comes before the entry with the provided key, or undefined if such an entry doesn't exist.
|
|
7
|
+
*/
|
|
8
|
+
export function getPreviousMapEntry<K = any, V = any>(map: Map<K, V>, currentKey: any): [K, V] | undefined {
|
|
9
|
+
let previous: [any, any] | undefined;
|
|
10
|
+
|
|
11
|
+
for (const entry of map) {
|
|
12
|
+
if (entry[0] === currentKey) {
|
|
13
|
+
return previous;
|
|
14
|
+
}
|
|
15
|
+
previous = entry;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the map entry that comes after the entry with the provided key.
|
|
22
|
+
* If the provided key is the first entry in the map or doesn't exist in the map, the function returns undefined.
|
|
23
|
+
* @param {Map<K, V>} map The map to search in.
|
|
24
|
+
* @param {any} currentKey The key of the map entry that comes after the desired entry.
|
|
25
|
+
* @returns {[K, V] | undefined} The map entry that comes before the entry with the provided key, or undefined if such an entry doesn't exist.
|
|
26
|
+
*/
|
|
27
|
+
export function getNextMapEntry<K = any, V = any>(map: Map<K, V>, currentKey: any): [K, V] | undefined {
|
|
28
|
+
let next: [any, any] | undefined;
|
|
29
|
+
// go in reverse
|
|
30
|
+
const entries = Array.from(map.entries());
|
|
31
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
32
|
+
const entry = entries[i];
|
|
33
|
+
if (entry[0] === currentKey) {
|
|
34
|
+
return next;
|
|
35
|
+
}
|
|
36
|
+
next = entry;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns the last entry in the provided map.
|
|
43
|
+
* If the map is empty, the function returns undefined.
|
|
44
|
+
* @param {Map<K, V>} map The map to get the last entry from.
|
|
45
|
+
* @returns {[K, V] | undefined} The last entry in the map, or undefined if the map is empty.
|
|
46
|
+
*/
|
|
47
|
+
export function getLastMapEntry<K = any, V = any>(map: Map<K, V>): [K, V] | undefined {
|
|
48
|
+
return Array.from(map.entries()).pop() as [K, V];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Returns the first entry in the provided map.
|
|
53
|
+
* If the map is empty, the function returns undefined.
|
|
54
|
+
* @param {Map<K, V>} map The map to get the last entry from.
|
|
55
|
+
* @returns {[K, V] | undefined} The last entry in the map, or undefined if the map is empty.
|
|
56
|
+
*/
|
|
57
|
+
export function getFirstMapEntry<K = any, V = any>(map: Map<K, V>): [K, V] | undefined {
|
|
58
|
+
return Array.from(map.entries()).shift() as [K, V];
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clamp a number
|
|
3
|
+
* @param pValue
|
|
4
|
+
* @param pMin
|
|
5
|
+
* @param pMax
|
|
6
|
+
*/
|
|
7
|
+
export function clamp(pValue: number, pMin: number, pMax: number): number {
|
|
8
|
+
return Math.max(pMin, Math.min(pMax, pValue));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* lerp
|
|
13
|
+
* @param pMin
|
|
14
|
+
* @param pMax
|
|
15
|
+
* @param pPerc
|
|
16
|
+
*/
|
|
17
|
+
export function lerp(pMin: number, pMax: number, pPerc: number): number {
|
|
18
|
+
return pMin + (pMax - pMin) * pPerc;
|
|
19
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Point } from 'pixi.js';
|
|
2
|
+
import type { Size, SizeLike } from './types';
|
|
3
|
+
|
|
4
|
+
export function resolveSizeLike(size?: SizeLike): Size {
|
|
5
|
+
if (size === undefined) {
|
|
6
|
+
return { width: 0, height: 0 };
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(size)) {
|
|
9
|
+
return { width: size[0], height: size[1] === undefined ? size[0] : size[1] };
|
|
10
|
+
} else if (size instanceof Point) {
|
|
11
|
+
return { width: size.x, height: size.y };
|
|
12
|
+
} else if (typeof size === 'object') {
|
|
13
|
+
// cast as an object
|
|
14
|
+
const obj = size as { width: number; height: number };
|
|
15
|
+
return { width: obj.width || 0, height: obj.height || 0 };
|
|
16
|
+
} else {
|
|
17
|
+
return { width: size ?? 0, height: size ?? 0 };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type DebouncedFunction<T extends (...args: any[]) => any> = (...args: Parameters<T>) => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Debounce a function
|
|
25
|
+
* @param func - function to debounce
|
|
26
|
+
* @param wait - time in milliseconds
|
|
27
|
+
* @example const debounced = debounce(() => console.log('debounced'), 1000);
|
|
28
|
+
* @example window.addEventListener('resize', debounced);
|
|
29
|
+
*/
|
|
30
|
+
export function debounce<T extends (...args: any[]) => any>(func: T, wait: number): DebouncedFunction<T> {
|
|
31
|
+
let timeoutId: NodeJS.Timeout | null = null;
|
|
32
|
+
|
|
33
|
+
return function (this: any, ...args: Parameters<T>) {
|
|
34
|
+
// Clear existing timeout if any
|
|
35
|
+
if (timeoutId) {
|
|
36
|
+
clearTimeout(timeoutId);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Set new timeout
|
|
40
|
+
timeoutId = setTimeout(() => {
|
|
41
|
+
func.apply(this, args);
|
|
42
|
+
timeoutId = null;
|
|
43
|
+
}, wait);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DeepPartial } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plucks the specified keys from an object and returns a new object with only those keys.
|
|
5
|
+
* @template T The type of the original object.
|
|
6
|
+
* @template K The keys to pluck from the original object.
|
|
7
|
+
* @param {T} obj The original object.
|
|
8
|
+
* @param {K[]} keys The keys to pluck from the original object.
|
|
9
|
+
* @returns {Pick<T, K>} A new object with only the plucked keys.
|
|
10
|
+
*/
|
|
11
|
+
export function pluck<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {
|
|
12
|
+
return keys.reduce((acc, key) => (key in obj ? { ...acc, [key]: obj[key] } : acc), {} as Pick<T, K>);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Omits the specified keys from an object and returns a new object without those keys.
|
|
17
|
+
* @template T The type of the original object.
|
|
18
|
+
* @template K The keys to omit from the original object.
|
|
19
|
+
* @param {K[]} keysToOmit The keys to omit from the original object.
|
|
20
|
+
* @param {Partial<T>} obj The original object.
|
|
21
|
+
* @returns {Omit<T, K>} A new object without the omitted keys.
|
|
22
|
+
*/
|
|
23
|
+
export function omitKeys<T extends object, K extends keyof T>(keysToOmit: K[], obj: Partial<T>): Omit<T, K> {
|
|
24
|
+
return Object.entries(obj)
|
|
25
|
+
.filter(([key]) => !keysToOmit.includes(key as K))
|
|
26
|
+
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {} as Omit<T, K>);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function deepMerge<T extends Record<string, any>>(target: T, source: DeepPartial<T>): T {
|
|
30
|
+
for (const key in source) {
|
|
31
|
+
if (
|
|
32
|
+
source[key] !== undefined &&
|
|
33
|
+
Object.prototype.toString.call(source[key]) === '[object Object]' &&
|
|
34
|
+
key in target &&
|
|
35
|
+
typeof target[key] === 'object'
|
|
36
|
+
) {
|
|
37
|
+
target[key] = deepMerge(target[key], source[key] as T[Extract<keyof T, string>]);
|
|
38
|
+
} else if (source[key] !== undefined) {
|
|
39
|
+
target[key] = source[key] as T[Extract<keyof T, string>];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return target;
|
|
43
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Padding, PointLike } from './types';
|
|
2
|
+
|
|
3
|
+
export function resolvePadding(paddingNum: number, size: number) {
|
|
4
|
+
// check of the paddingNum is a decimal between 0 and 1
|
|
5
|
+
// if it is, return a number that is the percentage of the size
|
|
6
|
+
if (paddingNum >= 0 && paddingNum <= 1) {
|
|
7
|
+
return paddingNum * size;
|
|
8
|
+
}
|
|
9
|
+
return paddingNum;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ensurePadding(padding: Partial<Padding> | PointLike): Padding {
|
|
13
|
+
if (Array.isArray(padding)) {
|
|
14
|
+
return {
|
|
15
|
+
top: padding[0],
|
|
16
|
+
right: padding?.[1] ?? padding[0],
|
|
17
|
+
bottom: padding?.[2] ?? padding[0],
|
|
18
|
+
left: padding?.[3] ?? padding?.[1] ?? padding[0] ?? 0,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (typeof padding === 'number') {
|
|
22
|
+
return { top: padding, right: padding, bottom: padding, left: padding };
|
|
23
|
+
} else if (typeof padding === 'object') {
|
|
24
|
+
const paddingAsPointLike = padding as { x?: number; y?: number };
|
|
25
|
+
if (paddingAsPointLike.x !== undefined && paddingAsPointLike.y !== undefined) {
|
|
26
|
+
return {
|
|
27
|
+
top: paddingAsPointLike.y,
|
|
28
|
+
right: paddingAsPointLike.x,
|
|
29
|
+
bottom: paddingAsPointLike.y,
|
|
30
|
+
left: paddingAsPointLike.x,
|
|
31
|
+
};
|
|
32
|
+
} else {
|
|
33
|
+
return {
|
|
34
|
+
top: (padding as Padding).top ?? 0,
|
|
35
|
+
right: (padding as Padding).right ?? 0,
|
|
36
|
+
bottom: (padding as Padding).bottom ?? 0,
|
|
37
|
+
left: (padding as Padding).left ?? 0,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Circle, Container, ContainerChild, Ellipse, Point, Polygon, Rectangle, RoundedRectangle } from 'pixi.js';
|
|
2
|
+
import { PointLike, Size } from './types';
|
|
3
|
+
import { resolvePointLike } from './point';
|
|
4
|
+
|
|
5
|
+
export type PixiSimpleShape = Rectangle | Circle | Ellipse | RoundedRectangle;
|
|
6
|
+
export type PixiShape = PixiSimpleShape | Polygon;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Reassigns the displays object parent while maintaing it's world position
|
|
10
|
+
* @param pChild
|
|
11
|
+
* @param pParent
|
|
12
|
+
*/
|
|
13
|
+
export function reParent(pChild: ContainerChild, pParent: Container): void {
|
|
14
|
+
if (pChild.parent) {
|
|
15
|
+
pChild.parent.worldTransform.apply(pChild.position as Point, pChild.position as Point);
|
|
16
|
+
}
|
|
17
|
+
pParent.worldTransform.applyInverse(pChild.position as Point, pChild.position as Point);
|
|
18
|
+
pChild.parent?.removeChild(pChild);
|
|
19
|
+
pParent.addChild(pChild);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param pObject
|
|
25
|
+
*/
|
|
26
|
+
export function objectDiagonal(pObject: Container): number {
|
|
27
|
+
return Math.sqrt(pObject.width * pObject.width + pObject.height * pObject.height);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Removes provided object from its parent and re-adds it.
|
|
32
|
+
* @param pObject The object to send to the back.
|
|
33
|
+
*/
|
|
34
|
+
export function sendToFront(pObject: Container): void {
|
|
35
|
+
const parent = pObject.parent;
|
|
36
|
+
if (!parent) return;
|
|
37
|
+
parent.removeChild(pObject);
|
|
38
|
+
parent.addChild(pObject);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Removes provided object from its parent and re-adds it at index 0.
|
|
43
|
+
* @param pObject The object to send to the back.
|
|
44
|
+
*/
|
|
45
|
+
export function sendToBack(pObject: Container): void {
|
|
46
|
+
const parent = pObject.parent;
|
|
47
|
+
if (!parent) return;
|
|
48
|
+
parent.removeChild(pObject);
|
|
49
|
+
parent.addChildAt(pObject, 0);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param pShape
|
|
55
|
+
* @param pDelta
|
|
56
|
+
*/
|
|
57
|
+
export function offsetShape(pShape: PixiShape, pDelta: Point): PixiShape {
|
|
58
|
+
if (pShape instanceof Polygon) {
|
|
59
|
+
for (let i = 0; i < pShape.points.length; i += 2) {
|
|
60
|
+
pShape.points[i] += pDelta.x;
|
|
61
|
+
pShape.points[i + 1] += pDelta.y;
|
|
62
|
+
}
|
|
63
|
+
return pShape;
|
|
64
|
+
} else {
|
|
65
|
+
pShape.x += pDelta.x;
|
|
66
|
+
pShape.y += pDelta.y;
|
|
67
|
+
return pShape;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param pShape
|
|
74
|
+
* @param pDelta
|
|
75
|
+
*/
|
|
76
|
+
export function offsetSimpleShape(pShape: PixiSimpleShape, pDelta: Point): PixiSimpleShape {
|
|
77
|
+
pShape.x += pDelta.x;
|
|
78
|
+
pShape.y += pDelta.y;
|
|
79
|
+
return pShape;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function scaleUniform(obj: any, scaleNum: number, scaleProp: 'width' | 'height' = 'width') {
|
|
83
|
+
const scaleVal: 'x' | 'y' = scaleProp === 'width' ? 'y' : 'x';
|
|
84
|
+
const otherScaleVal: 'x' | 'y' = scaleProp === 'width' ? 'x' : 'y';
|
|
85
|
+
obj[scaleProp] = scaleNum;
|
|
86
|
+
obj.scale[scaleVal] = obj.scale[otherScaleVal];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function scaleToWidth(obj: Container, width: number) {
|
|
90
|
+
scaleUniform(obj, width, 'width');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function scaleToHeight(obj: Container, height: number) {
|
|
94
|
+
scaleUniform(obj, height, 'height');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function scaleToSize(obj: Container, size: PointLike | Size, firstProp: 'width' | 'height' = 'width') {
|
|
98
|
+
let resolvedSize;
|
|
99
|
+
if ((size as Size)?.width && (size as Size)?.height) {
|
|
100
|
+
resolvedSize = { x: (size as Size).width, y: (size as Size).height };
|
|
101
|
+
} else {
|
|
102
|
+
resolvedSize = resolvePointLike(size as PointLike);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (firstProp === 'width') {
|
|
106
|
+
scaleToWidth(obj, resolvedSize.x);
|
|
107
|
+
if (obj.height < resolvedSize.y) {
|
|
108
|
+
scaleToHeight(obj, resolvedSize.y);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
scaleToHeight(obj, resolvedSize.y);
|
|
112
|
+
if (obj.width < resolvedSize.x) {
|
|
113
|
+
scaleToWidth(obj, resolvedSize.x);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isMobile as PIXIUtilsIsMobile } from 'pixi.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the device has a retina display.
|
|
5
|
+
* A device is considered to have a retina display if its device pixel ratio is greater than 1,
|
|
6
|
+
* or if it matches the media query for high resolution displays.
|
|
7
|
+
* @type {boolean}
|
|
8
|
+
*/
|
|
9
|
+
export const isRetina =
|
|
10
|
+
typeof window !== 'undefined'
|
|
11
|
+
? window.devicePixelRatio > 1 ||
|
|
12
|
+
(window.matchMedia &&
|
|
13
|
+
window.matchMedia(
|
|
14
|
+
'(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)',
|
|
15
|
+
).matches)
|
|
16
|
+
: false;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Check if we're on a touch device
|
|
20
|
+
*/
|
|
21
|
+
export const isTouch: boolean =
|
|
22
|
+
typeof window !== 'undefined'
|
|
23
|
+
? 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator?.maxTouchPoints > 0
|
|
24
|
+
: false;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the device is a mobile device.
|
|
28
|
+
* This uses the `isMobile` function from the `@pixi/utils` package.
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
*/
|
|
31
|
+
export const isMobile = PIXIUtilsIsMobile.any;
|
|
32
|
+
export const isAndroid = PIXIUtilsIsMobile.android.device;
|
|
33
|
+
export const isIos = PIXIUtilsIsMobile.apple.device;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Point, PointLike } from 'pixi.js';
|
|
2
|
+
import { lerp } from './math';
|
|
3
|
+
import { PointLike as CaperPointLike } from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Add the x and the y values of two Points together and return a new point.
|
|
7
|
+
* @returns Point
|
|
8
|
+
* @param a
|
|
9
|
+
* @param b
|
|
10
|
+
*/
|
|
11
|
+
export function add(a: PointLike, b: PointLike): Point {
|
|
12
|
+
return new Point(a.x + b.x, a.y + b.y);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Increase the x,y of point A by the x,y of point B.
|
|
17
|
+
* @param a
|
|
18
|
+
* @param b
|
|
19
|
+
*/
|
|
20
|
+
export function addToPoint(a: PointLike, b: PointLike): void {
|
|
21
|
+
a.x += b.x;
|
|
22
|
+
a.y += b.y;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Subtract the x and the y values of point B from Point A and return a new point.
|
|
27
|
+
* @param a
|
|
28
|
+
* @param b
|
|
29
|
+
*/
|
|
30
|
+
export function subtract(a: PointLike, b: PointLike): Point {
|
|
31
|
+
return new Point(a.x - b.x, a.y - b.y);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Decrease the x,y of point A by the x,y of point B.
|
|
36
|
+
* @param a
|
|
37
|
+
* @param b
|
|
38
|
+
*/
|
|
39
|
+
export function subtractFromPoint(a: PointLike, b: PointLike): void {
|
|
40
|
+
a.x -= b.x;
|
|
41
|
+
a.y -= b.y;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Multply the x,y values of a point by the provided value.
|
|
46
|
+
* @param a
|
|
47
|
+
* @param pMult
|
|
48
|
+
*/
|
|
49
|
+
export function multiply(a: PointLike, pMult: number): Point {
|
|
50
|
+
const point: Point = new Point(a.x, a.y);
|
|
51
|
+
point.x *= pMult;
|
|
52
|
+
point.y *= pMult;
|
|
53
|
+
return point;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param pt
|
|
59
|
+
* @param percent
|
|
60
|
+
*/
|
|
61
|
+
export function lerpPoint(pt: PointLike, percent: number): number {
|
|
62
|
+
return lerp(pt.x, pt.y, percent);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get the distance between two points.
|
|
67
|
+
* @param a
|
|
68
|
+
* @param b
|
|
69
|
+
*/
|
|
70
|
+
export function distance(a: PointLike, b: Point): number {
|
|
71
|
+
return Math.sqrt(distanceSq(a, b));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get the squared distance between two points.
|
|
76
|
+
* @param a
|
|
77
|
+
* @param b
|
|
78
|
+
*/
|
|
79
|
+
export function distanceSq(a: PointLike, b: Point): number {
|
|
80
|
+
return (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Gets the magnitude of a point.
|
|
85
|
+
* @param pt
|
|
86
|
+
*/
|
|
87
|
+
export function magnitude(pt: PointLike): number {
|
|
88
|
+
return Math.sqrt(pt.x * pt.x + pt.y * pt.y);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type PointLikeResult = { x: number; y: number } | Point;
|
|
92
|
+
|
|
93
|
+
export function resolvePointLike(
|
|
94
|
+
position?: CaperPointLike,
|
|
95
|
+
asPoint?: false,
|
|
96
|
+
x?: number,
|
|
97
|
+
y?: number,
|
|
98
|
+
): { x: number; y: number };
|
|
99
|
+
export function resolvePointLike(position?: CaperPointLike, asPoint?: true, x?: number, y?: number): Point;
|
|
100
|
+
export function resolvePointLike(
|
|
101
|
+
position?: CaperPointLike,
|
|
102
|
+
asPoint: boolean = false,
|
|
103
|
+
x: number = 0,
|
|
104
|
+
y: number = 0,
|
|
105
|
+
): PointLikeResult {
|
|
106
|
+
if (position instanceof Point) {
|
|
107
|
+
x = position.x;
|
|
108
|
+
y = position.y;
|
|
109
|
+
} else if (Array.isArray(position)) {
|
|
110
|
+
x = position[0];
|
|
111
|
+
y = position[1] === undefined ? position[0] : position[1];
|
|
112
|
+
} else if (typeof position === 'object') {
|
|
113
|
+
// cast as an object
|
|
114
|
+
const obj = position as { x: number; y: number };
|
|
115
|
+
x = obj.x || 0;
|
|
116
|
+
y = obj.y || 0;
|
|
117
|
+
} else {
|
|
118
|
+
x = position ?? x;
|
|
119
|
+
y = position ?? y;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return asPoint ? new Point(x, y) : { x, y };
|
|
123
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { triggerViteError } from '../vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new Queue with the given promises.
|
|
5
|
+
* @param {...(Promise<any> | (() => Promise<any | void>))[]} promises The promises to add to the queue.
|
|
6
|
+
* @returns {Queue} The created Queue.
|
|
7
|
+
*/
|
|
8
|
+
export function createQueue(...promises: (Promise<any> | (() => Promise<any | void>))[]): Queue {
|
|
9
|
+
return new Queue(promises);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A class representing a queue of promises.
|
|
14
|
+
* @template T The type of the values that the promises in the queue resolve to.
|
|
15
|
+
*/
|
|
16
|
+
export class Queue<T = any | void> {
|
|
17
|
+
private _promises: (Promise<any> | (() => Promise<T>))[];
|
|
18
|
+
private _currentIndex: number = 0;
|
|
19
|
+
private _isPaused: boolean = false;
|
|
20
|
+
private _isCanceled: boolean = false;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new Queue.
|
|
24
|
+
* @param {(Promise<any> | (() => Promise<T>))[]} promises The promises to add to the queue.
|
|
25
|
+
*/
|
|
26
|
+
constructor(promises: (Promise<any> | (() => Promise<T>))[] = []) {
|
|
27
|
+
this._promises = promises;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private _results: T[];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets the results of the promises that have been resolved so far.
|
|
34
|
+
* @returns {T[]} The results.
|
|
35
|
+
*/
|
|
36
|
+
public get results(): T[] {
|
|
37
|
+
return this._results;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Gets the progress of the queue.
|
|
42
|
+
* @returns {number} The progress (0-1)
|
|
43
|
+
*/
|
|
44
|
+
public get progress(): number {
|
|
45
|
+
return this._currentIndex / this._promises.length;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Adds promises to the queue.
|
|
50
|
+
* @param {...(Promise<any> | (() => Promise<T>))[]} args The promises to add.
|
|
51
|
+
*/
|
|
52
|
+
public add(...args: (Promise<any> | (() => Promise<T>))[]) {
|
|
53
|
+
this._promises.push(...args);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Starts the execution of the promises in the queue.
|
|
58
|
+
*/
|
|
59
|
+
public start(): void {
|
|
60
|
+
if (this._currentIndex === 0) {
|
|
61
|
+
// don't start if already started
|
|
62
|
+
this._results = [];
|
|
63
|
+
void this._next();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Pauses the execution of the promises in the queue.
|
|
69
|
+
*/
|
|
70
|
+
public pause(): void {
|
|
71
|
+
this._isPaused = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Resumes the execution of the promises in the queue.
|
|
76
|
+
*/
|
|
77
|
+
public resume(): void {
|
|
78
|
+
if (this._isPaused) {
|
|
79
|
+
this._isPaused = false;
|
|
80
|
+
void this._next();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Cancels the execution of the promises in the queue.
|
|
86
|
+
*/
|
|
87
|
+
public cancel(): void {
|
|
88
|
+
this._isCanceled = true;
|
|
89
|
+
this._promises = [];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Executes the next promise in the queue.
|
|
94
|
+
* @private
|
|
95
|
+
* @returns {Promise<void>} A promise that resolves when the next promise in the queue has been executed.
|
|
96
|
+
*/
|
|
97
|
+
private async _next(): Promise<void> {
|
|
98
|
+
if (this._isPaused || this._isCanceled || this._currentIndex >= this._promises.length) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const currentFunction = this._promises[this._currentIndex];
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const result = typeof currentFunction === 'function' ? await currentFunction() : await currentFunction;
|
|
106
|
+
this._results.push(result);
|
|
107
|
+
this._currentIndex++;
|
|
108
|
+
void this._next();
|
|
109
|
+
} catch (error: any) {
|
|
110
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
111
|
+
// Log the original error object directly (outside Logger's collapsed
|
|
112
|
+
// groups) so DevTools renders a source-mapped, clickable stack.
|
|
113
|
+
console.error("Queue didn't complete due to an error:", error);
|
|
114
|
+
triggerViteError({
|
|
115
|
+
message: `Queue didn't complete due to an error: ${err.message}`,
|
|
116
|
+
stack: err.stack,
|
|
117
|
+
id: error?.id,
|
|
118
|
+
});
|
|
119
|
+
// this._isCanceled = true;
|
|
120
|
+
// remove the current promise from the queue
|
|
121
|
+
this._promises.splice(this._currentIndex, 1);
|
|
122
|
+
void this._next();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delays the execution of the subsequent code.
|
|
3
|
+
* @param {number} seconds The delay time in seconds. Default is 0.
|
|
4
|
+
* @returns {Promise<void>} A promise that resolves after the specified delay.
|
|
5
|
+
*/
|
|
6
|
+
export const delay = (seconds: number = 0): Promise<void> =>
|
|
7
|
+
new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
8
|
+
|
|
9
|
+
export const wait = (seconds: number = 0): Promise<void> => delay(seconds);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the given value is a promise.
|
|
13
|
+
* @param {any} value The value to check.
|
|
14
|
+
* @returns {boolean} True if the value is a promise, false otherwise.
|
|
15
|
+
*/
|
|
16
|
+
export const isPromise = (value: any): value is Promise<any> => value && typeof value.then === 'function';
|