@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
|
@@ -0,0 +1,812 @@
|
|
|
1
|
+
import type { LayoutOptions } from '@pixi/layout';
|
|
2
|
+
import { ContainerChild, Graphics, RenderLayer, Container as PIXIContainer, Text } from 'pixi.js';
|
|
3
|
+
import { Application } from '../core/Application';
|
|
4
|
+
import { Container } from '../display';
|
|
5
|
+
import { Factory, WithSignals } from '../mixins';
|
|
6
|
+
import type { AppTypeOverrides, Padding, PointLike, Size, SizeLike } from '../utils';
|
|
7
|
+
import {
|
|
8
|
+
bindAllMethods,
|
|
9
|
+
createDebugGraphics,
|
|
10
|
+
createDebugLabel,
|
|
11
|
+
DebugAlpha,
|
|
12
|
+
DebugColors,
|
|
13
|
+
ensurePadding,
|
|
14
|
+
Logger,
|
|
15
|
+
registerDebug,
|
|
16
|
+
resolveSizeLike,
|
|
17
|
+
unregisterDebug,
|
|
18
|
+
} from '../utils';
|
|
19
|
+
import { FlexContainer } from './FlexContainer';
|
|
20
|
+
|
|
21
|
+
export type UICanvasEdge =
|
|
22
|
+
| 'top right'
|
|
23
|
+
| 'top left'
|
|
24
|
+
| 'top center'
|
|
25
|
+
| 'top'
|
|
26
|
+
| 'bottom right'
|
|
27
|
+
| 'bottom left'
|
|
28
|
+
| 'bottom center'
|
|
29
|
+
| 'bottom'
|
|
30
|
+
| 'left top'
|
|
31
|
+
| 'left bottom'
|
|
32
|
+
| 'left center'
|
|
33
|
+
| 'left'
|
|
34
|
+
| 'right top'
|
|
35
|
+
| 'right bottom'
|
|
36
|
+
| 'right center'
|
|
37
|
+
| 'right'
|
|
38
|
+
| 'center';
|
|
39
|
+
|
|
40
|
+
export interface UICanvasChildSettings {
|
|
41
|
+
align: UICanvasEdge;
|
|
42
|
+
padding: Padding;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Anchor box handed to a binding's placement callback, in canvas-local space
|
|
46
|
+
* (origin = canvas top-left), derived from the anchor's computed layout so it
|
|
47
|
+
* never lags the render transform. */
|
|
48
|
+
export interface UICanvasBindRect {
|
|
49
|
+
left: number;
|
|
50
|
+
top: number;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Places a bound (free-floating) element from its anchor's rect. Both the
|
|
56
|
+
* rect and the element's `position` are in canvas-local space. */
|
|
57
|
+
export type UICanvasBindFn = (rect: UICanvasBindRect, child: PIXIContainer) => void;
|
|
58
|
+
|
|
59
|
+
interface UICanvasBinding {
|
|
60
|
+
child: PIXIContainer;
|
|
61
|
+
anchor: PIXIContainer;
|
|
62
|
+
place: UICanvasBindFn;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface UICanvasChildProps {
|
|
66
|
+
align: UICanvasEdge;
|
|
67
|
+
padding: Partial<Padding> | PointLike;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type UICanvasConfig = {
|
|
71
|
+
debug: boolean;
|
|
72
|
+
padding: Padding;
|
|
73
|
+
size: Size;
|
|
74
|
+
useAppSize: boolean;
|
|
75
|
+
layout?: Omit<LayoutOptions, 'target'> | null | boolean;
|
|
76
|
+
autoLayoutChildren?: boolean;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const UICanvasConfigKeys: (keyof UICanvasConfig)[] = ['debug', 'padding', 'size', 'useAppSize', 'layout'];
|
|
80
|
+
|
|
81
|
+
export type UICanvasProps = {
|
|
82
|
+
debug: boolean;
|
|
83
|
+
padding: Partial<Padding> | PointLike;
|
|
84
|
+
size?: SizeLike;
|
|
85
|
+
useAppSize?: boolean;
|
|
86
|
+
layout?: Omit<LayoutOptions, 'target'> | null | boolean;
|
|
87
|
+
autoLayoutChildren?: boolean;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const defaultLayout = {
|
|
91
|
+
flexGrow: 0,
|
|
92
|
+
flexShrink: 0,
|
|
93
|
+
autoLayoutChildren: true,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const _UICanvas = WithSignals(Factory());
|
|
97
|
+
|
|
98
|
+
export class UICanvas extends _UICanvas {
|
|
99
|
+
public config: UICanvasConfig;
|
|
100
|
+
protected settingsMap = new Map<PIXIContainer, UICanvasChildSettings>();
|
|
101
|
+
protected _childMap = new Map<PIXIContainer, PIXIContainer>();
|
|
102
|
+
protected _debugGraphics: Graphics | null = null;
|
|
103
|
+
protected _debugLabel: Text | null = null;
|
|
104
|
+
protected _regionLabels: Text[] = [];
|
|
105
|
+
private _disableAddChildError: boolean = false;
|
|
106
|
+
private _positionContainers: Map<UICanvasEdge, Container>;
|
|
107
|
+
private _bindings: UICanvasBinding[] = [];
|
|
108
|
+
|
|
109
|
+
public topRow: FlexContainer;
|
|
110
|
+
public middleRow: FlexContainer;
|
|
111
|
+
public bottomRow: FlexContainer;
|
|
112
|
+
|
|
113
|
+
constructor(config: Partial<UICanvasProps>) {
|
|
114
|
+
super();
|
|
115
|
+
|
|
116
|
+
if (!this.app.config.useLayout) {
|
|
117
|
+
throw new Error('You must set useLayout to true in your app config to use UICanvas');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
bindAllMethods(this);
|
|
121
|
+
this._positionContainers = new Map();
|
|
122
|
+
this.config = {
|
|
123
|
+
debug: config.debug === true,
|
|
124
|
+
padding: ensurePadding(config?.padding ?? 0),
|
|
125
|
+
size: config.size !== undefined ? resolveSizeLike(config.size) : { width: 0, height: 0 },
|
|
126
|
+
useAppSize: config.useAppSize === true,
|
|
127
|
+
autoLayoutChildren: config.autoLayoutChildren ?? true,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
if (config.layout) {
|
|
131
|
+
if (typeof config.layout === 'boolean') {
|
|
132
|
+
this.config.layout = config.layout;
|
|
133
|
+
} else {
|
|
134
|
+
this.config.layout = { ...defaultLayout, ...config.layout };
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
this.config.layout = { ...defaultLayout };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (this.config.useAppSize) {
|
|
141
|
+
this.config.size = this.app.size;
|
|
142
|
+
}
|
|
143
|
+
this.layout = {
|
|
144
|
+
width: this.config.size.width,
|
|
145
|
+
height: this.config.size.height,
|
|
146
|
+
flexDirection: 'column',
|
|
147
|
+
justifyContent: 'space-between',
|
|
148
|
+
...(typeof this.config.layout === 'object' ? this.config.layout : {}),
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
this.on('childRemoved', this._childRemoved);
|
|
152
|
+
this.once('added', this._added);
|
|
153
|
+
|
|
154
|
+
this.addSignalConnection(this.app.onResize.connect(this.resize));
|
|
155
|
+
|
|
156
|
+
this._initializeLayout();
|
|
157
|
+
this._updateLayout();
|
|
158
|
+
|
|
159
|
+
if (this.config.debug) {
|
|
160
|
+
registerDebug(`UICanvas:${this.uid}`, this.label || 'UICanvas', DebugColors.outerBounds);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private _updateLayout() {
|
|
165
|
+
this.app.ticker.addOnce(this.updateLayout);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
private _initializeLayout() {
|
|
169
|
+
this._disableAddChildError = true;
|
|
170
|
+
// Create top row
|
|
171
|
+
this.topRow = this.add.flexContainer({
|
|
172
|
+
label: 'Top',
|
|
173
|
+
layout: {
|
|
174
|
+
width: '100%',
|
|
175
|
+
height: 'auto',
|
|
176
|
+
flexDirection: 'row',
|
|
177
|
+
justifyContent: 'space-between',
|
|
178
|
+
alignItems: 'flex-start',
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Create middle row
|
|
183
|
+
this.middleRow = this.add.flexContainer({
|
|
184
|
+
label: 'Middle',
|
|
185
|
+
layout: {
|
|
186
|
+
width: '100%',
|
|
187
|
+
flexDirection: 'row',
|
|
188
|
+
justifyContent: 'space-between',
|
|
189
|
+
alignItems: 'center',
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// Create bottom row
|
|
194
|
+
this.bottomRow = this.add.flexContainer({
|
|
195
|
+
label: 'Bottom',
|
|
196
|
+
layout: {
|
|
197
|
+
width: '100%',
|
|
198
|
+
height: 'auto',
|
|
199
|
+
flexDirection: 'row',
|
|
200
|
+
justifyContent: 'space-between',
|
|
201
|
+
alignItems: 'flex-end',
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
this._disableAddChildError = false;
|
|
206
|
+
|
|
207
|
+
// Create the 9 actual position containers
|
|
208
|
+
const topLeft = this._createPositionContainer(
|
|
209
|
+
this.topRow,
|
|
210
|
+
{
|
|
211
|
+
justifyContent: 'flex-start',
|
|
212
|
+
alignItems: 'flex-start',
|
|
213
|
+
flexGrow: 0,
|
|
214
|
+
flexShrink: 0,
|
|
215
|
+
},
|
|
216
|
+
'Left',
|
|
217
|
+
);
|
|
218
|
+
const topCenter = this._createPositionContainer(
|
|
219
|
+
this.topRow,
|
|
220
|
+
{
|
|
221
|
+
justifyContent: 'center',
|
|
222
|
+
alignItems: 'flex-start',
|
|
223
|
+
flexGrow: 1,
|
|
224
|
+
flexShrink: 0,
|
|
225
|
+
},
|
|
226
|
+
'Center',
|
|
227
|
+
);
|
|
228
|
+
const topRight = this._createPositionContainer(
|
|
229
|
+
this.topRow,
|
|
230
|
+
{
|
|
231
|
+
justifyContent: 'flex-end',
|
|
232
|
+
alignItems: 'flex-start',
|
|
233
|
+
flexGrow: 0,
|
|
234
|
+
flexShrink: 0,
|
|
235
|
+
},
|
|
236
|
+
'Right',
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
const middleLeft = this._createPositionContainer(
|
|
240
|
+
this.middleRow,
|
|
241
|
+
{
|
|
242
|
+
justifyContent: 'flex-start',
|
|
243
|
+
alignItems: 'center',
|
|
244
|
+
flexDirection: 'row',
|
|
245
|
+
flexGrow: 0,
|
|
246
|
+
flexShrink: 0,
|
|
247
|
+
},
|
|
248
|
+
'Left',
|
|
249
|
+
);
|
|
250
|
+
const center = this._createPositionContainer(
|
|
251
|
+
this.middleRow,
|
|
252
|
+
{
|
|
253
|
+
justifyContent: 'center',
|
|
254
|
+
alignItems: 'center',
|
|
255
|
+
flexDirection: 'row',
|
|
256
|
+
flexGrow: 1,
|
|
257
|
+
flexShrink: 0,
|
|
258
|
+
},
|
|
259
|
+
'Center',
|
|
260
|
+
);
|
|
261
|
+
const middleRight = this._createPositionContainer(
|
|
262
|
+
this.middleRow,
|
|
263
|
+
{
|
|
264
|
+
justifyContent: 'flex-end',
|
|
265
|
+
alignItems: 'center',
|
|
266
|
+
flexDirection: 'row',
|
|
267
|
+
flexGrow: 0,
|
|
268
|
+
flexShrink: 0,
|
|
269
|
+
},
|
|
270
|
+
'Right',
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
const bottomLeft = this._createPositionContainer(
|
|
274
|
+
this.bottomRow,
|
|
275
|
+
{
|
|
276
|
+
justifyContent: 'flex-start',
|
|
277
|
+
alignItems: 'flex-end',
|
|
278
|
+
flexDirection: 'row',
|
|
279
|
+
flexGrow: 0,
|
|
280
|
+
flexShrink: 0,
|
|
281
|
+
},
|
|
282
|
+
'Left',
|
|
283
|
+
);
|
|
284
|
+
const bottomCenter = this._createPositionContainer(
|
|
285
|
+
this.bottomRow,
|
|
286
|
+
{
|
|
287
|
+
justifyContent: 'center',
|
|
288
|
+
alignItems: 'flex-end',
|
|
289
|
+
flexGrow: 1,
|
|
290
|
+
flexShrink: 0,
|
|
291
|
+
flexDirection: 'row',
|
|
292
|
+
},
|
|
293
|
+
'Center',
|
|
294
|
+
);
|
|
295
|
+
const bottomRight = this._createPositionContainer(
|
|
296
|
+
this.bottomRow,
|
|
297
|
+
{
|
|
298
|
+
justifyContent: 'flex-end',
|
|
299
|
+
alignItems: 'flex-end',
|
|
300
|
+
flexDirection: 'row',
|
|
301
|
+
flexGrow: 0,
|
|
302
|
+
flexShrink: 0,
|
|
303
|
+
},
|
|
304
|
+
'Right',
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
// Map all edge variants to the appropriate containers
|
|
308
|
+
this._positionContainers.set('top left', topLeft);
|
|
309
|
+
this._positionContainers.set('left top', topLeft);
|
|
310
|
+
|
|
311
|
+
this._positionContainers.set('top center', topCenter);
|
|
312
|
+
this._positionContainers.set('top', topCenter);
|
|
313
|
+
|
|
314
|
+
this._positionContainers.set('top right', topRight);
|
|
315
|
+
this._positionContainers.set('right top', topRight);
|
|
316
|
+
|
|
317
|
+
this._positionContainers.set('left center', middleLeft);
|
|
318
|
+
this._positionContainers.set('left', middleLeft);
|
|
319
|
+
this._positionContainers.set('left bottom', bottomLeft);
|
|
320
|
+
|
|
321
|
+
this._positionContainers.set('center', center);
|
|
322
|
+
|
|
323
|
+
this._positionContainers.set('right center', middleRight);
|
|
324
|
+
this._positionContainers.set('right', middleRight);
|
|
325
|
+
this._positionContainers.set('right bottom', bottomRight);
|
|
326
|
+
|
|
327
|
+
this._positionContainers.set('bottom left', bottomLeft);
|
|
328
|
+
|
|
329
|
+
this._positionContainers.set('bottom center', bottomCenter);
|
|
330
|
+
this._positionContainers.set('bottom', bottomCenter);
|
|
331
|
+
|
|
332
|
+
this._positionContainers.set('bottom right', bottomRight);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
private _createPositionContainer(parent: FlexContainer, layout: Partial<LayoutOptions>, label: string): Container {
|
|
336
|
+
const container = parent.add.container({
|
|
337
|
+
layout: {
|
|
338
|
+
width: 'auto',
|
|
339
|
+
height: 'auto',
|
|
340
|
+
...layout,
|
|
341
|
+
},
|
|
342
|
+
});
|
|
343
|
+
container.label = label;
|
|
344
|
+
container.on('childAdded', this._updateLayout);
|
|
345
|
+
container.on('childRemoved', this._updateLayout);
|
|
346
|
+
container.on('layout', this._updateLayout);
|
|
347
|
+
return container;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
protected _canvasChildren: PIXIContainer[] = [];
|
|
351
|
+
|
|
352
|
+
public get canvasChildren(): PIXIContainer[] {
|
|
353
|
+
return this._canvasChildren;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Get the application instance.
|
|
358
|
+
*/
|
|
359
|
+
public get app(): AppTypeOverrides['App'] {
|
|
360
|
+
return Application.getInstance();
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
destroy() {
|
|
364
|
+
// Must be set before any child.destroy() call — PixiJS's destroy cascade
|
|
365
|
+
// calls child.removeFromParent() → parent.removeChild() internally.
|
|
366
|
+
this._disableAddChildError = true;
|
|
367
|
+
|
|
368
|
+
// Clean up debug
|
|
369
|
+
if (this.config.debug) {
|
|
370
|
+
unregisterDebug(`UICanvas:${this.uid}`);
|
|
371
|
+
}
|
|
372
|
+
if (this._debugGraphics) {
|
|
373
|
+
this._debugGraphics.destroy();
|
|
374
|
+
this._debugGraphics = null;
|
|
375
|
+
}
|
|
376
|
+
if (this._debugLabel) {
|
|
377
|
+
this._debugLabel.destroy();
|
|
378
|
+
this._debugLabel = null;
|
|
379
|
+
}
|
|
380
|
+
for (const rl of this._regionLabels) {
|
|
381
|
+
rl.destroy();
|
|
382
|
+
}
|
|
383
|
+
this._regionLabels = [];
|
|
384
|
+
|
|
385
|
+
this.canvasChildren?.forEach((child) => {
|
|
386
|
+
child.off('layout', this._updateLayout);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
this.children.forEach((child) => {
|
|
390
|
+
child.off('layout', this._updateLayout);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
this.off('childAdded', this._updateLayout);
|
|
394
|
+
this.off('childRemoved', this._updateLayout);
|
|
395
|
+
|
|
396
|
+
this._positionContainers.forEach((container) => {
|
|
397
|
+
container.off('childAdded', this._updateLayout);
|
|
398
|
+
container.off('childRemoved', this._updateLayout);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
this._bindings = [];
|
|
402
|
+
|
|
403
|
+
super.destroy();
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
set size(value: SizeLike) {
|
|
407
|
+
this.config.size = value === undefined ? { width: 0, height: 0 } : resolveSizeLike(value);
|
|
408
|
+
|
|
409
|
+
this.layout = { width: this.config.size.width, height: this.config.size.height };
|
|
410
|
+
|
|
411
|
+
this.updateLayout();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
set padding(value: Partial<Padding> | PointLike) {
|
|
415
|
+
this.config.padding = ensurePadding(value);
|
|
416
|
+
// Update position to account for padding
|
|
417
|
+
this.layout = {
|
|
418
|
+
paddingLeft: this.config.padding.left,
|
|
419
|
+
paddingTop: this.config.padding.top,
|
|
420
|
+
paddingRight: this.config.padding.right,
|
|
421
|
+
paddingBottom: this.config.padding.bottom,
|
|
422
|
+
};
|
|
423
|
+
this._updateLayout();
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
private static isFlexContainer(child: PIXIContainer): boolean {
|
|
427
|
+
return child instanceof FlexContainer;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Removes all the children from the container
|
|
432
|
+
*/
|
|
433
|
+
public removeChildren = (beginIndex?: number, endIndex?: number): PIXIContainer[] => {
|
|
434
|
+
return super.removeChildren(beginIndex, endIndex) as PIXIContainer[];
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Removes a child from the container at the specified index
|
|
439
|
+
*/
|
|
440
|
+
public removeChildAt = <U extends PIXIContainer | RenderLayer>(index: number): U => {
|
|
441
|
+
return super.removeChildAt(index) as U;
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Adds a child to the container at the specified index
|
|
446
|
+
*/
|
|
447
|
+
public addChildAt = <U extends PIXIContainer | RenderLayer>(_child: U, _index: number): U => {
|
|
448
|
+
throw new Error(
|
|
449
|
+
`UICanvas: Do not call addChildAt() directly. Use addElement(child, { align }) instead.\n` +
|
|
450
|
+
`Example: uiCanvas.addElement(myChild, { align: 'top right' })`,
|
|
451
|
+
);
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Sets the index of the child in the container
|
|
456
|
+
*/
|
|
457
|
+
public setChildIndex = <U extends PIXIContainer>(child: U, index: number): void => {
|
|
458
|
+
super.setChildIndex(child, index);
|
|
459
|
+
this._updateLayout();
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Gets the index of a child in the container
|
|
464
|
+
*/
|
|
465
|
+
public getChildIndex = <U extends PIXIContainer>(child: U): number => {
|
|
466
|
+
return super.getChildIndex(child);
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Gets the child at the specified index
|
|
471
|
+
*/
|
|
472
|
+
public getChildAt = <U extends PIXIContainer | RenderLayer>(index: number): U => {
|
|
473
|
+
return super.getChildAt(index) as U;
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
public addChild<U extends (ContainerChild | RenderLayer)[]>(...children: U): U[0] {
|
|
477
|
+
if (this._disableAddChildError) {
|
|
478
|
+
return super.addChild(...children);
|
|
479
|
+
}
|
|
480
|
+
throw new Error(
|
|
481
|
+
`UICanvas: Do not call addChild() directly. Use addElement(child, { align }) instead.\n` +
|
|
482
|
+
`Example: uiCanvas.addElement(myChild, { align: 'top right' })`,
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Removes one or more children from the container
|
|
488
|
+
*/
|
|
489
|
+
public removeChild(..._children: (PIXIContainer | RenderLayer)[]): PIXIContainer {
|
|
490
|
+
if (this._disableAddChildError) {
|
|
491
|
+
return super.removeChild(...(_children as PIXIContainer[]));
|
|
492
|
+
}
|
|
493
|
+
throw new Error(`UICanvas: Do not call removeChild() directly. Use removeElement(child) instead.`);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
public resize() {
|
|
497
|
+
if (this.config.useAppSize) {
|
|
498
|
+
this.size = { width: this.app.size.width, height: this.app.size.height };
|
|
499
|
+
this.position.set(-this.app.size.width * 0.5, -this.app.size.height * 0.5);
|
|
500
|
+
} else {
|
|
501
|
+
this._updateLayout();
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
public updateLayout() {
|
|
506
|
+
if (this.destroyed || !this.layout || !this.app?.renderer.layout) return;
|
|
507
|
+
this.app.renderer.layout.update(this);
|
|
508
|
+
|
|
509
|
+
this._positionContainers.forEach((container) => {
|
|
510
|
+
this.app.renderer.layout.update(container);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
if (this.config.useAppSize) {
|
|
514
|
+
this.position.set(-this.config.size.width * 0.5, -this.config.size.height * 0.5);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
this._updateBindings();
|
|
518
|
+
|
|
519
|
+
if (this.config.debug) {
|
|
520
|
+
this.app.ticker.addOnce(this.drawDebug);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Bind a free-floating element to a UICanvas-managed anchor without adding it
|
|
526
|
+
* to the flex flow. The element is parented to the canvas as a `layout: false`
|
|
527
|
+
* child (so it never re-measures a region — it can't "shift everything left"),
|
|
528
|
+
* and `place` re-runs on every layout pass with the anchor's current box in
|
|
529
|
+
* canvas-local space. Use it for popovers, tooltips, and dropdowns anchored to
|
|
530
|
+
* laid-out chrome. Idempotent per child — binding the same child again replaces
|
|
531
|
+
* the previous binding.
|
|
532
|
+
*
|
|
533
|
+
* The bound element must NOT be a `@pixi/layout` node: re-enabling `.layout` on
|
|
534
|
+
* it (a layout-enabled direct child of the canvas joins the column flow and
|
|
535
|
+
* bottom-docks + reflows the canvas). Position its own subtree manually.
|
|
536
|
+
*/
|
|
537
|
+
public bindElement(child: PIXIContainer, anchor: PIXIContainer, place: UICanvasBindFn): void {
|
|
538
|
+
if (child.parent !== this) {
|
|
539
|
+
this._disableAddChildError = true;
|
|
540
|
+
super.addChild(child);
|
|
541
|
+
this._disableAddChildError = false;
|
|
542
|
+
}
|
|
543
|
+
child.layout = false;
|
|
544
|
+
this._bindings = this._bindings.filter((b) => b.child !== child);
|
|
545
|
+
this._bindings.push({ child, anchor, place });
|
|
546
|
+
this._updateLayout();
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** Remove a binding created by `bindElement` and detach the element. */
|
|
550
|
+
public unbindElement(child: PIXIContainer): void {
|
|
551
|
+
const had = this._bindings.some((b) => b.child === child);
|
|
552
|
+
this._bindings = this._bindings.filter((b) => b.child !== child);
|
|
553
|
+
if (had && child.parent === this) {
|
|
554
|
+
this._disableAddChildError = true;
|
|
555
|
+
super.removeChild(child);
|
|
556
|
+
this._disableAddChildError = false;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
private _updateBindings(): void {
|
|
561
|
+
for (const { child, anchor, place } of this._bindings) {
|
|
562
|
+
const rect = this._anchorRect(anchor);
|
|
563
|
+
if (rect) place(rect, child);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/** The anchor's box in canvas-local space, summed from the computed-layout
|
|
568
|
+
* offsets up to this canvas — deterministic and free of render-transform lag
|
|
569
|
+
* (the same source the debug overlay uses to draw regions). */
|
|
570
|
+
private _anchorRect(anchor: PIXIContainer): UICanvasBindRect | null {
|
|
571
|
+
const own = anchor.layout?.computedLayout;
|
|
572
|
+
if (!own) return null;
|
|
573
|
+
let left = 0;
|
|
574
|
+
let top = 0;
|
|
575
|
+
for (let node: PIXIContainer | null = anchor; node && node !== this; node = node.parent) {
|
|
576
|
+
const cl = node.layout?.computedLayout;
|
|
577
|
+
if (cl) {
|
|
578
|
+
left += cl.left;
|
|
579
|
+
top += cl.top;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return { left, top, width: own.width, height: own.height };
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
public addElement<U extends PIXIContainer = PIXIContainer>(
|
|
586
|
+
child: PIXIContainer,
|
|
587
|
+
settings?: Partial<UICanvasChildProps>,
|
|
588
|
+
): U {
|
|
589
|
+
const position = settings?.align ?? 'top left';
|
|
590
|
+
const container = this._positionContainers.get(position);
|
|
591
|
+
|
|
592
|
+
if (!container) {
|
|
593
|
+
Logger.error(`UICanvas:: Invalid position "${position}" for element`);
|
|
594
|
+
return child as U;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (UICanvas.isFlexContainer(child as PIXIContainer)) {
|
|
598
|
+
this.addSignalConnection((child as unknown as FlexContainer).onLayoutComplete.connect(this._updateLayout));
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
this.settingsMap.set(child, {
|
|
602
|
+
align: position,
|
|
603
|
+
padding: settings?.padding ? ensurePadding(settings.padding) : { top: 0, left: 0, bottom: 0, right: 0 },
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
this._childMap.set(child, container);
|
|
607
|
+
this._canvasChildren = Array.from(this._childMap.keys());
|
|
608
|
+
|
|
609
|
+
container.add.existing(child);
|
|
610
|
+
this._childAdded(child);
|
|
611
|
+
|
|
612
|
+
return child as U;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
public removeElement(child: PIXIContainer): PIXIContainer {
|
|
616
|
+
const container = this._childMap.get(child);
|
|
617
|
+
if (!container) {
|
|
618
|
+
throw new Error(
|
|
619
|
+
`UICanvas: Cannot remove element — it was not added via addElement().\n` +
|
|
620
|
+
`Child label: "${child.label ?? '(unlabeled)'}"`,
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
container.removeChild(child);
|
|
625
|
+
child.off('layout', this._updateLayout);
|
|
626
|
+
this.settingsMap.delete(child);
|
|
627
|
+
this._childMap.delete(child);
|
|
628
|
+
this._canvasChildren = Array.from(this._childMap.keys());
|
|
629
|
+
this._updateLayout();
|
|
630
|
+
return child;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
private _childAdded(child: PIXIContainer) {
|
|
634
|
+
if (this.config.autoLayoutChildren) {
|
|
635
|
+
if (!child.layout) {
|
|
636
|
+
child.layout = true;
|
|
637
|
+
}
|
|
638
|
+
if (!child.layout?.style?.width) {
|
|
639
|
+
child.layout = { width: 'auto' };
|
|
640
|
+
}
|
|
641
|
+
if (!child.layout?.style?.height) {
|
|
642
|
+
child.layout = { height: 'auto' };
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
child.on('layout', this._updateLayout);
|
|
646
|
+
Container.childAdded(child);
|
|
647
|
+
this._updateLayout();
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
private _childRemoved(child: any) {
|
|
651
|
+
this.settingsMap.delete(child);
|
|
652
|
+
this._childMap.delete(child as PIXIContainer);
|
|
653
|
+
this._canvasChildren = Array.from(this._childMap.keys());
|
|
654
|
+
Container.childRemoved(child);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
private _added() {
|
|
658
|
+
this._updateLayout();
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// --- Debug visualization ---
|
|
662
|
+
get debug(): boolean {
|
|
663
|
+
return this.config.debug;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
set debug(value: boolean) {
|
|
667
|
+
this.config.debug = value;
|
|
668
|
+
if (value) {
|
|
669
|
+
const uid = `UICanvas:${this.uid}`;
|
|
670
|
+
registerDebug(uid, this.label || 'UICanvas', DebugColors.outerBounds);
|
|
671
|
+
this.drawDebug();
|
|
672
|
+
} else {
|
|
673
|
+
unregisterDebug(`UICanvas:${this.uid}`);
|
|
674
|
+
if (this._debugGraphics) {
|
|
675
|
+
this._debugGraphics.clear();
|
|
676
|
+
}
|
|
677
|
+
if (this._debugLabel) {
|
|
678
|
+
this._debugLabel.visible = false;
|
|
679
|
+
}
|
|
680
|
+
for (const rl of this._regionLabels) {
|
|
681
|
+
rl.visible = false;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
private drawDebug() {
|
|
687
|
+
// Lazily create debug graphics as a child of this canvas
|
|
688
|
+
if (!this._debugGraphics) {
|
|
689
|
+
this._disableAddChildError = true;
|
|
690
|
+
this._debugGraphics = createDebugGraphics(`${this.label ?? 'UICanvas'}:debug`);
|
|
691
|
+
super.addChild(this._debugGraphics);
|
|
692
|
+
this._debugGraphics.layout = false;
|
|
693
|
+
this._disableAddChildError = false;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if (!this._debugLabel) {
|
|
697
|
+
this._disableAddChildError = true;
|
|
698
|
+
this._debugLabel = createDebugLabel(this.label || 'UICanvas', DebugColors.outerBounds);
|
|
699
|
+
super.addChild(this._debugLabel);
|
|
700
|
+
this._debugLabel.layout = false;
|
|
701
|
+
this._disableAddChildError = false;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
this._debugLabel.text = this.label || 'UICanvas';
|
|
705
|
+
this._debugLabel.visible = true;
|
|
706
|
+
this._debugLabel.position.set(2, 2);
|
|
707
|
+
|
|
708
|
+
this._debugGraphics.clear();
|
|
709
|
+
|
|
710
|
+
const w = this.config.size.width;
|
|
711
|
+
const h = this.config.size.height;
|
|
712
|
+
const pad = this.config.padding;
|
|
713
|
+
|
|
714
|
+
// 1. Outer bounds (red)
|
|
715
|
+
this._debugGraphics
|
|
716
|
+
.rect(0, 0, w, h)
|
|
717
|
+
.stroke({ width: 1, color: DebugColors.outerBounds, alpha: DebugAlpha.stroke, pixelLine: true });
|
|
718
|
+
|
|
719
|
+
// 2. Padding areas (red subtle fill)
|
|
720
|
+
if (pad.top > 0) {
|
|
721
|
+
this._debugGraphics.rect(0, 0, w, pad.top).fill({ color: DebugColors.outerBounds, alpha: DebugAlpha.fill });
|
|
722
|
+
}
|
|
723
|
+
if (pad.bottom > 0) {
|
|
724
|
+
this._debugGraphics
|
|
725
|
+
.rect(0, h - pad.bottom, w, pad.bottom)
|
|
726
|
+
.fill({ color: DebugColors.outerBounds, alpha: DebugAlpha.fill });
|
|
727
|
+
}
|
|
728
|
+
if (pad.left > 0) {
|
|
729
|
+
this._debugGraphics
|
|
730
|
+
.rect(0, pad.top, pad.left, h - pad.top - pad.bottom)
|
|
731
|
+
.fill({ color: DebugColors.outerBounds, alpha: DebugAlpha.fill });
|
|
732
|
+
}
|
|
733
|
+
if (pad.right > 0) {
|
|
734
|
+
this._debugGraphics
|
|
735
|
+
.rect(w - pad.right, pad.top, pad.right, h - pad.top - pad.bottom)
|
|
736
|
+
.fill({ color: DebugColors.outerBounds, alpha: DebugAlpha.fill });
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// 3. Inner bounds (green)
|
|
740
|
+
const innerX = pad.left;
|
|
741
|
+
const innerY = pad.top;
|
|
742
|
+
const innerW = w - pad.left - pad.right;
|
|
743
|
+
const innerH = h - pad.top - pad.bottom;
|
|
744
|
+
this._debugGraphics
|
|
745
|
+
.rect(innerX, innerY, innerW, innerH)
|
|
746
|
+
.stroke({ width: 1, color: DebugColors.innerBounds, alpha: DebugAlpha.stroke, pixelLine: true });
|
|
747
|
+
|
|
748
|
+
// 4. 9-grid region visualization
|
|
749
|
+
// Build a name map from edge → container for labeling
|
|
750
|
+
const edgeNames = new Map<Container, string>();
|
|
751
|
+
this._positionContainers.forEach((container, edge) => {
|
|
752
|
+
// Use the shortest edge name for each unique container
|
|
753
|
+
if (!edgeNames.has(container) || edge.length < edgeNames.get(container)!.length) {
|
|
754
|
+
edgeNames.set(container, edge);
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
const uniqueContainers = [...new Set(this._positionContainers.values())];
|
|
759
|
+
|
|
760
|
+
// Ensure we have enough region labels
|
|
761
|
+
while (this._regionLabels.length < uniqueContainers.length) {
|
|
762
|
+
this._disableAddChildError = true;
|
|
763
|
+
const rl = createDebugLabel('', DebugColors.region);
|
|
764
|
+
super.addChild(rl);
|
|
765
|
+
rl.layout = false;
|
|
766
|
+
this._regionLabels.push(rl);
|
|
767
|
+
this._disableAddChildError = false;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
uniqueContainers.forEach((container, i) => {
|
|
771
|
+
if (!container.layout?.computedLayout) return;
|
|
772
|
+
const cl = container.layout.computedLayout;
|
|
773
|
+
const parent = container.parent;
|
|
774
|
+
if (!parent?.layout?.computedLayout) return;
|
|
775
|
+
const parentCL = parent.layout.computedLayout;
|
|
776
|
+
|
|
777
|
+
const rx = parentCL.left + cl.left;
|
|
778
|
+
const ry = parentCL.top + cl.top;
|
|
779
|
+
const rw = cl.width;
|
|
780
|
+
const rh = cl.height;
|
|
781
|
+
const hasChildren = container.children.length > 0;
|
|
782
|
+
|
|
783
|
+
// Region fill (different alpha for occupied vs empty)
|
|
784
|
+
this._debugGraphics!
|
|
785
|
+
.rect(rx, ry, rw, rh)
|
|
786
|
+
.fill({ color: DebugColors.region, alpha: hasChildren ? DebugAlpha.fillActive : DebugAlpha.fill })
|
|
787
|
+
.stroke({ width: 1, color: DebugColors.region, alpha: 0.3, pixelLine: true });
|
|
788
|
+
|
|
789
|
+
// Region label
|
|
790
|
+
const rl = this._regionLabels[i];
|
|
791
|
+
rl.text = edgeNames.get(container) ?? '';
|
|
792
|
+
rl.visible = true;
|
|
793
|
+
rl.position.set(rx + 2, ry + 2);
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
// Hide unused region labels
|
|
797
|
+
for (let i = uniqueContainers.length; i < this._regionLabels.length; i++) {
|
|
798
|
+
this._regionLabels[i].visible = false;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// 5. Center crosshairs
|
|
802
|
+
const centerX = w / 2;
|
|
803
|
+
const centerY = h / 2;
|
|
804
|
+
this._debugGraphics
|
|
805
|
+
.moveTo(centerX, centerY - 10)
|
|
806
|
+
.lineTo(centerX, centerY + 10)
|
|
807
|
+
.stroke({ width: 1, color: DebugColors.outerBounds, alpha: DebugAlpha.crosshair, pixelLine: true })
|
|
808
|
+
.moveTo(centerX - 10, centerY)
|
|
809
|
+
.lineTo(centerX + 10, centerY)
|
|
810
|
+
.stroke({ width: 1, color: DebugColors.outerBounds, alpha: DebugAlpha.crosshair, pixelLine: true });
|
|
811
|
+
}
|
|
812
|
+
}
|