@supersoniks/concorde 4.9.98-visual-stack.1 → 4.9.98-visual-stack.3
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/.gitlab-ci.yml +0 -13
- package/build-infos.json +1 -1
- package/concorde-3d.bundle.js +1 -1
- package/concorde-3d.es.js +2 -2
- package/concorde-core.bundle.js +557 -622
- package/concorde-core.es.js +6025 -5575
- package/concorde-hugging-face-infer.bundle.js +1 -1
- package/concorde-hugging-face-infer.es.js +1 -1
- package/concorde-interactive.bundle.js +1162 -0
- package/concorde-interactive.es.js +10723 -0
- package/concorde-shader.bundle.js +1 -1
- package/concorde-shader.es.js +2 -2
- package/concorde-webgpu.bundle.js +1 -1
- package/concorde-webgpu.es.js +2 -2
- package/dist/concorde-3d.bundle.js +1 -1
- package/dist/concorde-3d.es.js +2 -2
- package/dist/concorde-core.bundle.js +557 -622
- package/dist/concorde-core.es.js +6025 -5575
- package/dist/concorde-hugging-face-infer.bundle.js +1 -1
- package/dist/concorde-hugging-face-infer.es.js +1 -1
- package/dist/concorde-interactive.bundle.js +1162 -0
- package/dist/concorde-interactive.es.js +10723 -0
- package/dist/concorde-shader.bundle.js +1 -1
- package/dist/concorde-shader.es.js +2 -2
- package/dist/concorde-webgpu.bundle.js +1 -1
- package/dist/concorde-webgpu.es.js +2 -2
- package/dist/docs-mock-api-sw.js +5 -1
- package/dist/docs-mock-api-sw.js.map +2 -2
- package/dist/js/addons/interactive.js +6 -0
- package/dist/js/addons/interactive.js.map +1 -0
- package/dist/js/core/components/functional/if/if.js +65 -7
- package/dist/js/core/components/functional/if/if.js.map +1 -1
- package/dist/js/core/components/functional/interactive/action.js +96 -0
- package/dist/js/core/components/functional/interactive/action.js.map +1 -0
- package/dist/js/core/components/functional/interactive/gamepad.js +206 -0
- package/dist/js/core/components/functional/interactive/gamepad.js.map +1 -0
- package/dist/js/core/components/functional/interactive/gesture.js +148 -0
- package/dist/js/core/components/functional/interactive/gesture.js.map +1 -0
- package/dist/js/core/components/functional/interactive/helpers.js +82 -0
- package/dist/js/core/components/functional/interactive/helpers.js.map +1 -0
- package/dist/js/core/components/functional/interactive/index.js +20 -0
- package/dist/js/core/components/functional/interactive/index.js.map +1 -0
- package/dist/js/core/components/functional/interactive/keyboard.js +183 -0
- package/dist/js/core/components/functional/interactive/keyboard.js.map +1 -0
- package/dist/js/core/components/functional/interactive/matrix.js +201 -0
- package/dist/js/core/components/functional/interactive/matrix.js.map +1 -0
- package/dist/js/core/components/functional/interactive/registry.js +28 -0
- package/dist/js/core/components/functional/interactive/registry.js.map +1 -0
- package/dist/js/core/components/functional/interactive/store.js +264 -0
- package/dist/js/core/components/functional/interactive/store.js.map +1 -0
- package/dist/js/core/components/functional/interactive/ticker.js +182 -0
- package/dist/js/core/components/functional/interactive/ticker.js.map +1 -0
- package/dist/js/core/components/functional/value/value.js +49 -4
- package/dist/js/core/components/functional/value/value.js.map +1 -1
- package/dist/js/core/components/ui/_css/rounded.js +34 -0
- package/dist/js/core/components/ui/_css/rounded.js.map +1 -0
- package/dist/js/core/components/ui/_css/type.js +44 -0
- package/dist/js/core/components/ui/_css/type.js.map +1 -1
- package/dist/js/core/components/ui/_i18n/ui-aria-labels.js +95 -0
- package/dist/js/core/components/ui/_i18n/ui-aria-labels.js.map +1 -0
- package/dist/js/core/components/ui/alert/alert.js +72 -87
- package/dist/js/core/components/ui/alert/alert.js.map +1 -1
- package/dist/js/core/components/ui/alert-messages/alert-messages.js +1 -0
- package/dist/js/core/components/ui/alert-messages/alert-messages.js.map +1 -1
- package/dist/js/core/components/ui/badge/badge.js +29 -80
- package/dist/js/core/components/ui/badge/badge.js.map +1 -1
- package/dist/js/core/components/ui/button/button.js +8 -7
- package/dist/js/core/components/ui/button/button.js.map +1 -1
- package/dist/js/core/components/ui/card/card-header.js +7 -2
- package/dist/js/core/components/ui/card/card-header.js.map +1 -1
- package/dist/js/core/components/ui/divider/divider.js +1 -1
- package/dist/js/core/components/ui/divider/divider.js.map +1 -1
- package/dist/js/core/components/ui/form/checkbox/checkbox.js +4 -20
- package/dist/js/core/components/ui/form/checkbox/checkbox.js.map +1 -1
- package/dist/js/core/components/ui/form/fieldset/legend-description.js +1 -1
- package/dist/js/core/components/ui/form/fieldset/legend.js +1 -1
- package/dist/js/core/components/ui/form/input/input.js +12 -15
- package/dist/js/core/components/ui/form/input/input.js.map +1 -1
- package/dist/js/core/components/ui/form/input-autocomplete/input-autocomplete.js +363 -158
- package/dist/js/core/components/ui/form/input-autocomplete/input-autocomplete.js.map +1 -1
- package/dist/js/core/components/ui/form/radio/radio.js +1 -1
- package/dist/js/core/components/ui/form/select/select.js +3 -6
- package/dist/js/core/components/ui/form/select/select.js.map +1 -1
- package/dist/js/core/components/ui/form/textarea/textarea.js +1 -2
- package/dist/js/core/components/ui/form/textarea/textarea.js.map +1 -1
- package/dist/js/core/components/ui/image/image.js +9 -37
- package/dist/js/core/components/ui/image/image.js.map +1 -1
- package/dist/js/core/components/ui/link/link.js +25 -26
- package/dist/js/core/components/ui/link/link.js.map +1 -1
- package/dist/js/core/components/ui/modal/modal-close.js +3 -12
- package/dist/js/core/components/ui/modal/modal-close.js.map +1 -1
- package/dist/js/core/components/ui/modal/modal.js +18 -18
- package/dist/js/core/components/ui/modal/modal.js.map +1 -1
- package/dist/js/core/components/ui/pop/pop.js +131 -112
- package/dist/js/core/components/ui/pop/pop.js.map +1 -1
- package/dist/js/core/components/ui/table/table.js.map +1 -1
- package/dist/js/core/components/ui/theme/theme.js +1 -1
- package/dist/js/core/components/ui/toast/dismissed.js +9 -0
- package/dist/js/core/components/ui/toast/dismissed.js.map +1 -0
- package/dist/js/core/components/ui/toast/render-content.js +14 -0
- package/dist/js/core/components/ui/toast/render-content.js.map +1 -0
- package/dist/js/core/components/ui/toast/toast-item.js +150 -96
- package/dist/js/core/components/ui/toast/toast-item.js.map +1 -1
- package/dist/js/core/components/ui/toast/toast.js +41 -13
- package/dist/js/core/components/ui/toast/toast.js.map +1 -1
- package/dist/js/core/components/ui/tooltip/tooltip.js +144 -143
- package/dist/js/core/components/ui/tooltip/tooltip.js.map +1 -1
- package/dist/js/core/decorators/subscriber/ancestorAttribute.js.map +1 -1
- package/dist/js/core/decorators/subscriber/derive.js +3 -1
- package/dist/js/core/decorators/subscriber/derive.js.map +1 -1
- package/dist/js/core/mixins/Fetcher.js.map +1 -1
- package/dist/js/core/mixins/FormCheckable.js +1 -8
- package/dist/js/core/mixins/FormCheckable.js.map +1 -1
- package/dist/js/core/mixins/FormElement.js +26 -53
- package/dist/js/core/mixins/FormElement.js.map +1 -1
- package/dist/js/core/utils/AncestorAttributeObserver.js +130 -55
- package/dist/js/core/utils/AncestorAttributeObserver.js.map +1 -1
- package/dist/js/core/utils/LocationHandler.js +1 -1
- package/dist/js/core/utils/LocationHandler.js.map +1 -1
- package/dist/js/core/utils/dismissed.js +23 -0
- package/dist/js/core/utils/dismissed.js.map +1 -0
- package/dist/js/core/utils/positioning.js +110 -0
- package/dist/js/core/utils/positioning.js.map +1 -0
- package/dist/js/directives.js +1 -2
- package/dist/js/directives.js.map +1 -1
- package/dist/types/addons/interactive.d.ts +6 -0
- package/dist/types/addons/interactive.d.ts.map +1 -0
- package/dist/types/core/components/functional/if/if.d.ts +14 -5
- package/dist/types/core/components/functional/if/if.d.ts.map +1 -1
- package/dist/types/core/components/functional/interactive/action.d.ts +22 -0
- package/dist/types/core/components/functional/interactive/action.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/gamepad.d.ts +37 -0
- package/dist/types/core/components/functional/interactive/gamepad.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/gesture.d.ts +26 -0
- package/dist/types/core/components/functional/interactive/gesture.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/helpers.d.ts +23 -0
- package/dist/types/core/components/functional/interactive/helpers.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/index.d.ts +20 -0
- package/dist/types/core/components/functional/interactive/index.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/keyboard.d.ts +37 -0
- package/dist/types/core/components/functional/interactive/keyboard.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/matrix.d.ts +31 -0
- package/dist/types/core/components/functional/interactive/matrix.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/registry.d.ts +23 -0
- package/dist/types/core/components/functional/interactive/registry.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/store.d.ts +46 -0
- package/dist/types/core/components/functional/interactive/store.d.ts.map +1 -0
- package/dist/types/core/components/functional/interactive/ticker.d.ts +33 -0
- package/dist/types/core/components/functional/interactive/ticker.d.ts.map +1 -0
- package/dist/types/core/components/functional/value/value.d.ts +6 -0
- package/dist/types/core/components/functional/value/value.d.ts.map +1 -1
- package/dist/types/core/components/ui/_css/rounded.d.ts +3 -0
- package/dist/types/core/components/ui/_css/rounded.d.ts.map +1 -0
- package/dist/types/core/components/ui/_css/type.d.ts +13 -0
- package/dist/types/core/components/ui/_css/type.d.ts.map +1 -1
- package/dist/types/core/components/ui/_i18n/ui-aria-labels.d.ts +83 -0
- package/dist/types/core/components/ui/_i18n/ui-aria-labels.d.ts.map +1 -0
- package/dist/types/core/components/ui/alert/alert.d.ts +14 -12
- package/dist/types/core/components/ui/alert/alert.d.ts.map +1 -1
- package/dist/types/core/components/ui/alert-messages/alert-messages.d.ts.map +1 -1
- package/dist/types/core/components/ui/badge/badge.d.ts +1 -1
- package/dist/types/core/components/ui/badge/badge.d.ts.map +1 -1
- package/dist/types/core/components/ui/button/button.d.ts +13 -29
- package/dist/types/core/components/ui/button/button.d.ts.map +1 -1
- package/dist/types/core/components/ui/card/card-header.d.ts.map +1 -1
- package/dist/types/core/components/ui/divider/divider.d.ts +2 -1
- package/dist/types/core/components/ui/divider/divider.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/checkbox/checkbox.d.ts +25 -73
- package/dist/types/core/components/ui/form/checkbox/checkbox.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/input/input.d.ts +14 -29
- package/dist/types/core/components/ui/form/input/input.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +63 -65
- package/dist/types/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/radio/radio.d.ts +1 -1
- package/dist/types/core/components/ui/form/select/select.d.ts +3 -5
- package/dist/types/core/components/ui/form/select/select.d.ts.map +1 -1
- package/dist/types/core/components/ui/form/textarea/textarea.d.ts +12 -28
- package/dist/types/core/components/ui/form/textarea/textarea.d.ts.map +1 -1
- package/dist/types/core/components/ui/image/image.d.ts +2 -1
- package/dist/types/core/components/ui/image/image.d.ts.map +1 -1
- package/dist/types/core/components/ui/link/link.d.ts +10 -9
- package/dist/types/core/components/ui/link/link.d.ts.map +1 -1
- package/dist/types/core/components/ui/modal/modal-close.d.ts +2 -2
- package/dist/types/core/components/ui/modal/modal-close.d.ts.map +1 -1
- package/dist/types/core/components/ui/pop/pop.d.ts +12 -4
- package/dist/types/core/components/ui/pop/pop.d.ts.map +1 -1
- package/dist/types/core/components/ui/table/table.d.ts +2 -1
- package/dist/types/core/components/ui/table/table.d.ts.map +1 -1
- package/dist/types/core/components/ui/toast/dismissed.d.ts +3 -0
- package/dist/types/core/components/ui/toast/dismissed.d.ts.map +1 -0
- package/dist/types/core/components/ui/toast/render-content.d.ts +7 -0
- package/dist/types/core/components/ui/toast/render-content.d.ts.map +1 -0
- package/dist/types/core/components/ui/toast/toast-item.d.ts +26 -9
- package/dist/types/core/components/ui/toast/toast-item.d.ts.map +1 -1
- package/dist/types/core/components/ui/toast/toast.d.ts +6 -3
- package/dist/types/core/components/ui/toast/toast.d.ts.map +1 -1
- package/dist/types/core/components/ui/toast/types.d.ts +12 -2
- package/dist/types/core/components/ui/toast/types.d.ts.map +1 -1
- package/dist/types/core/components/ui/tooltip/tooltip.d.ts +19 -11
- package/dist/types/core/components/ui/tooltip/tooltip.d.ts.map +1 -1
- package/dist/types/core/decorators/subscriber/ancestorAttribute.d.ts +3 -4
- package/dist/types/core/decorators/subscriber/ancestorAttribute.d.ts.map +1 -1
- package/dist/types/core/decorators/subscriber/derive.d.ts.map +1 -1
- package/dist/types/core/mixins/FormCheckable.d.ts +10 -27
- package/dist/types/core/mixins/FormCheckable.d.ts.map +1 -1
- package/dist/types/core/mixins/FormElement.d.ts +21 -10
- package/dist/types/core/mixins/FormElement.d.ts.map +1 -1
- package/dist/types/core/mixins/FormInput.d.ts +11 -27
- package/dist/types/core/mixins/FormInput.d.ts.map +1 -1
- package/dist/types/core/utils/AncestorAttributeObserver.d.ts +17 -9
- package/dist/types/core/utils/AncestorAttributeObserver.d.ts.map +1 -1
- package/dist/types/core/utils/LocationHandler.d.ts +3 -2
- package/dist/types/core/utils/LocationHandler.d.ts.map +1 -1
- package/dist/types/core/utils/dismissed.d.ts +3 -0
- package/dist/types/core/utils/dismissed.d.ts.map +1 -0
- package/dist/types/core/utils/positioning.d.ts +44 -0
- package/dist/types/core/utils/positioning.d.ts.map +1 -0
- package/dist/types/directives.d.ts +1 -3
- package/dist/types/directives.d.ts.map +1 -1
- package/dist/types/mixins.d.ts +22 -55
- package/dist/types/mixins.d.ts.map +1 -1
- package/docs/assets/{index-FmK4JaIM.js → index-D8MVWqY6.js} +946 -687
- package/docs/assets/index-DiD0qYvE.css +1 -0
- package/docs/crawl/core/components/ui/form/input-autocomplete/input-autocomplete.html +17 -85
- package/docs/crawl/docs/_misc/formelement-subscriber-removal.html +1 -1
- package/docs/crawl/hubs/form-components.html +13 -11
- package/docs/docs-mock-api-sw.js +5 -1
- package/docs/docs-mock-api-sw.js.map +2 -2
- package/docs/index.html +2 -2
- package/docs/llms-full.txt +12 -38
- package/docs/llms.txt +1 -1
- package/docs/src/core/components/functional/sdui/sdui.md +0 -0
- package/docs/src/core/components/ui/form/checkbox/checkbox.md +0 -0
- package/docs/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +14 -118
- package/docs/src/docs/_getting-started/create-a-component.md +0 -0
- package/docs/src/docs/_misc/formelement-subscriber-removal.md +1 -1
- package/docs/src/docs/search/docs-search.json +195 -200
- package/docs/src/tsconfig.json +324 -0
- package/gitlab/job_tests.sh +25 -12
- package/index.html +3 -3
- package/package.json +182 -10
- package/public/docs-mock-api-sw.js +5 -1
- package/public/docs-mock-api-sw.js.map +2 -2
- package/scripts/build-addons.mjs +2 -2
- package/scripts/post-build.mjs +9 -0
- package/src/addons/interactive.ts +5 -0
- package/src/core/components/functional/if/if.ts +54 -7
- package/src/core/components/functional/interactive/action.ts +84 -0
- package/src/core/components/functional/interactive/gamepad.ts +197 -0
- package/src/core/components/functional/interactive/gesture.ts +136 -0
- package/src/core/components/functional/interactive/helpers.spec.ts +50 -0
- package/src/core/components/functional/interactive/helpers.ts +97 -0
- package/src/core/components/functional/interactive/index.ts +25 -0
- package/src/core/components/functional/interactive/interactive.md +33 -0
- package/src/core/components/functional/interactive/keyboard.ts +171 -0
- package/src/core/components/functional/interactive/matrix.ts +185 -0
- package/src/core/components/functional/interactive/registry.ts +46 -0
- package/src/core/components/functional/interactive/store.ts +270 -0
- package/src/core/components/functional/interactive/ticker.ts +171 -0
- package/src/core/components/functional/list/list.ts +0 -0
- package/src/core/components/functional/subscriber/subscriber.ts +0 -0
- package/src/core/components/functional/value/value.ts +44 -4
- package/src/core/components/ui/_css/rounded.ts +36 -0
- package/src/core/components/ui/_css/type.ts +49 -0
- package/src/core/components/ui/_i18n/ui-aria-labels.ts +104 -0
- package/src/core/components/ui/alert/alert.md +128 -72
- package/src/core/components/ui/alert/alert.spec.ts +145 -0
- package/src/core/components/ui/alert/alert.ts +86 -91
- package/src/core/components/ui/alert-messages/alert-messages.ts +1 -1
- package/src/core/components/ui/badge/badge.md +126 -78
- package/src/core/components/ui/badge/badge.ts +29 -81
- package/src/core/components/ui/button/button.md +1 -0
- package/src/core/components/ui/button/button.ts +12 -10
- package/src/core/components/ui/card/card-header.ts +7 -2
- package/src/core/components/ui/card/card.md +120 -65
- package/src/core/components/ui/divider/divider.ts +4 -9
- package/src/core/components/ui/form/checkbox/checkbox.md +1 -1
- package/src/core/components/ui/form/checkbox/checkbox.ts +4 -20
- package/src/core/components/ui/form/fieldset/legend-description.ts +1 -1
- package/src/core/components/ui/form/fieldset/legend.ts +1 -1
- package/src/core/components/ui/form/input/input.md +1 -1
- package/src/core/components/ui/form/input/input.ts +25 -27
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +14 -118
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.ts +419 -187
- package/src/core/components/ui/form/radio/radio.ts +1 -1
- package/src/core/components/ui/form/select/select.ts +3 -6
- package/src/core/components/ui/form/textarea/textarea.md +1 -1
- package/src/core/components/ui/form/textarea/textarea.ts +1 -2
- package/src/core/components/ui/image/image.md +147 -53
- package/src/core/components/ui/image/image.ts +10 -44
- package/src/core/components/ui/link/link.md +2 -2
- package/src/core/components/ui/link/link.ts +42 -37
- package/src/core/components/ui/modal/modal-close.ts +8 -12
- package/src/core/components/ui/modal/modal.ts +18 -18
- package/src/core/components/ui/pop/pop.md +105 -1
- package/src/core/components/ui/pop/pop.ts +145 -141
- package/src/core/components/ui/table/table.ts +2 -8
- package/src/core/components/ui/theme/theme.ts +1 -1
- package/src/core/components/ui/toast/dismissed.ts +14 -0
- package/src/core/components/ui/toast/render-content.ts +13 -0
- package/src/core/components/ui/toast/toast-item.ts +179 -103
- package/src/core/components/ui/toast/toast.ts +58 -21
- package/src/core/components/ui/toast/types.ts +14 -2
- package/src/core/components/ui/tooltip/tooltip.ts +176 -154
- package/src/core/decorators/subscriber/ancestorAttribute.spec.ts +26 -0
- package/src/core/decorators/subscriber/ancestorAttribute.ts +3 -4
- package/src/core/decorators/subscriber/derive.ts +3 -3
- package/src/core/mixins/Fetcher.ts +1 -1
- package/src/core/mixins/FormCheckable.ts +1 -8
- package/src/core/mixins/FormElement.ts +74 -76
- package/src/core/mixins/Subscriber.ts +5 -1
- package/src/core/utils/AncestorAttributeObserver.ts +183 -70
- package/src/core/utils/DataBindObserver.ts +0 -0
- package/src/core/utils/LocationHandler.ts +12 -5
- package/src/core/utils/Objects.ts +0 -0
- package/src/core/utils/dismissed.ts +22 -0
- package/src/core/utils/positioning.spec.ts +208 -0
- package/src/core/utils/positioning.ts +183 -0
- package/src/directives.ts +1 -3
- package/src/docs/_core-concept/dataFlow.md +1 -1
- package/src/docs/_decorators/ancestor-attribute.md +3 -2
- package/src/docs/_getting-started/cdn-addons.md +1 -0
- package/src/docs/_getting-started/concorde-outside.md +3 -3
- package/src/docs/_misc/formelement-subscriber-removal.md +115 -0
- package/src/docs/_misc/html-integration.md +2 -0
- package/src/docs/code.ts +3 -1
- package/src/docs/components/docs-demo-sources.ts +60 -0
- package/src/docs/docs.ts +1 -0
- package/src/docs/example/docs-input-autocomplete-demos.ts +110 -0
- package/src/docs/mock-api/router.ts +17 -1
- package/src/docs/navigation/navigation.ts +8 -0
- package/src/docs/search/docs-search.json +956 -243
- package/src/docs/tailwind/css/tailwind.css +13 -6
- package/src/tsconfig.json +135 -6
- package/src/tsconfig.tsbuildinfo +1 -1
- package/tailwind.config.js +50 -3
- package/vite/config.js +23 -35
- package/vite.config.mts +5 -0
- package/vitest.setup.ts +49 -13
- package/docs/assets/index-BZiZXMU-.css +0 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, css, html } from "lit";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
|
+
import { dispatch } from "./registry";
|
|
10
|
+
import { set } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
11
|
+
const tagName = "sonic-gamepad";
|
|
12
|
+
const STANDARD = {
|
|
13
|
+
"dpad-up": 12,
|
|
14
|
+
"dpad-down": 13,
|
|
15
|
+
"dpad-left": 14,
|
|
16
|
+
"dpad-right": 15,
|
|
17
|
+
a: 0,
|
|
18
|
+
b: 1,
|
|
19
|
+
x: 2,
|
|
20
|
+
y: 3,
|
|
21
|
+
start: 9,
|
|
22
|
+
select: 8,
|
|
23
|
+
"ls-x-": { axis: 0, dir: -1 },
|
|
24
|
+
"ls-x+": { axis: 0, dir: 1 },
|
|
25
|
+
"ls-y-": { axis: 1, dir: -1 },
|
|
26
|
+
"ls-y+": { axis: 1, dir: 1 },
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Manette → actions store. Raf uniquement si une pad est connectée.
|
|
30
|
+
*/
|
|
31
|
+
let SonicGamepad = class SonicGamepad extends LitElement {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
this.target = "";
|
|
35
|
+
this.keymap = {
|
|
36
|
+
"dpad-left": "left",
|
|
37
|
+
"dpad-right": "right",
|
|
38
|
+
"dpad-up": "rotate",
|
|
39
|
+
"dpad-down": "soft-drop",
|
|
40
|
+
a: "rotate",
|
|
41
|
+
b: "drop",
|
|
42
|
+
start: "pause",
|
|
43
|
+
};
|
|
44
|
+
this.deadzone = 0.25;
|
|
45
|
+
this.repeat = {};
|
|
46
|
+
this.dataProvider = "";
|
|
47
|
+
this.dispatchEventFlag = false;
|
|
48
|
+
this.connected = false;
|
|
49
|
+
this.raf = 0;
|
|
50
|
+
this.prev = new Map();
|
|
51
|
+
this.heldTimers = new Map();
|
|
52
|
+
this.onConnect = () => this.scan();
|
|
53
|
+
this.onDisconnect = () => this.scan();
|
|
54
|
+
}
|
|
55
|
+
connectedCallback() {
|
|
56
|
+
super.connectedCallback();
|
|
57
|
+
window.addEventListener("gamepadconnected", this.onConnect);
|
|
58
|
+
window.addEventListener("gamepaddisconnected", this.onDisconnect);
|
|
59
|
+
this.scan();
|
|
60
|
+
}
|
|
61
|
+
disconnectedCallback() {
|
|
62
|
+
window.removeEventListener("gamepadconnected", this.onConnect);
|
|
63
|
+
window.removeEventListener("gamepaddisconnected", this.onDisconnect);
|
|
64
|
+
this.stopLoop();
|
|
65
|
+
this.clearHolds();
|
|
66
|
+
super.disconnectedCallback();
|
|
67
|
+
}
|
|
68
|
+
scan() {
|
|
69
|
+
const pads = navigator.getGamepads?.() ?? [];
|
|
70
|
+
const any = [...pads].some(Boolean);
|
|
71
|
+
this.connected = any;
|
|
72
|
+
this.publishStatus();
|
|
73
|
+
if (any)
|
|
74
|
+
this.startLoop();
|
|
75
|
+
else
|
|
76
|
+
this.stopLoop();
|
|
77
|
+
}
|
|
78
|
+
publishStatus() {
|
|
79
|
+
if (!this.dataProvider)
|
|
80
|
+
return;
|
|
81
|
+
const pads = navigator.getGamepads?.() ?? [];
|
|
82
|
+
const first = [...pads].find(Boolean);
|
|
83
|
+
set(this.dataProvider, {
|
|
84
|
+
connected: this.connected,
|
|
85
|
+
id: first?.id ?? null,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
startLoop() {
|
|
89
|
+
if (this.raf)
|
|
90
|
+
return;
|
|
91
|
+
const loop = () => {
|
|
92
|
+
this.raf = requestAnimationFrame(loop);
|
|
93
|
+
this.poll();
|
|
94
|
+
};
|
|
95
|
+
this.raf = requestAnimationFrame(loop);
|
|
96
|
+
}
|
|
97
|
+
stopLoop() {
|
|
98
|
+
if (this.raf)
|
|
99
|
+
cancelAnimationFrame(this.raf);
|
|
100
|
+
this.raf = 0;
|
|
101
|
+
}
|
|
102
|
+
poll() {
|
|
103
|
+
const pads = navigator.getGamepads?.() ?? [];
|
|
104
|
+
const pad = [...pads].find(Boolean);
|
|
105
|
+
if (!pad) {
|
|
106
|
+
this.scan();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
for (const [name, mapped] of Object.entries(this.keymap || {})) {
|
|
110
|
+
const spec = STANDARD[name];
|
|
111
|
+
if (spec == null)
|
|
112
|
+
continue;
|
|
113
|
+
let pressed = false;
|
|
114
|
+
if (typeof spec === "number") {
|
|
115
|
+
pressed = Boolean(pad.buttons[spec]?.pressed);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
const axis = pad.axes[spec.axis] ?? 0;
|
|
119
|
+
pressed = spec.dir < 0 ? axis < -this.deadzone : axis > this.deadzone;
|
|
120
|
+
}
|
|
121
|
+
const was = this.prev.get(name) ?? false;
|
|
122
|
+
if (pressed && !was) {
|
|
123
|
+
this.fire(mapped);
|
|
124
|
+
this.startRepeat(name, mapped);
|
|
125
|
+
}
|
|
126
|
+
else if (!pressed && was) {
|
|
127
|
+
this.stopRepeat(name);
|
|
128
|
+
}
|
|
129
|
+
this.prev.set(name, pressed);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
startRepeat(name, mapped) {
|
|
133
|
+
const action = typeof mapped === "string" ? { type: mapped } : mapped;
|
|
134
|
+
const rep = this.repeat?.[action.type];
|
|
135
|
+
if (!rep)
|
|
136
|
+
return;
|
|
137
|
+
const [delay, interval] = rep;
|
|
138
|
+
const entry = {};
|
|
139
|
+
entry.timer = window.setTimeout(() => {
|
|
140
|
+
this.fire(mapped);
|
|
141
|
+
entry.interval = window.setInterval(() => this.fire(mapped), Math.max(16, interval));
|
|
142
|
+
}, Math.max(0, delay));
|
|
143
|
+
this.heldTimers.set(name, entry);
|
|
144
|
+
}
|
|
145
|
+
stopRepeat(name) {
|
|
146
|
+
const h = this.heldTimers.get(name);
|
|
147
|
+
if (!h)
|
|
148
|
+
return;
|
|
149
|
+
if (h.timer)
|
|
150
|
+
clearTimeout(h.timer);
|
|
151
|
+
if (h.interval)
|
|
152
|
+
clearInterval(h.interval);
|
|
153
|
+
this.heldTimers.delete(name);
|
|
154
|
+
}
|
|
155
|
+
clearHolds() {
|
|
156
|
+
for (const name of [...this.heldTimers.keys()])
|
|
157
|
+
this.stopRepeat(name);
|
|
158
|
+
}
|
|
159
|
+
fire(mapped) {
|
|
160
|
+
const action = typeof mapped === "string" ? { type: mapped } : { type: mapped.type, payload: mapped.payload };
|
|
161
|
+
if (this.target)
|
|
162
|
+
dispatch(this.target, action);
|
|
163
|
+
if (this.dispatchEventFlag) {
|
|
164
|
+
this.dispatchEvent(new CustomEvent("sonic-action", {
|
|
165
|
+
detail: action,
|
|
166
|
+
bubbles: true,
|
|
167
|
+
composed: true,
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
render() {
|
|
172
|
+
return html ``;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
SonicGamepad.styles = css `
|
|
176
|
+
:host {
|
|
177
|
+
display: contents;
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
__decorate([
|
|
181
|
+
property({ type: String })
|
|
182
|
+
], SonicGamepad.prototype, "target", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
property({ type: Object })
|
|
185
|
+
], SonicGamepad.prototype, "keymap", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
property({ type: Number })
|
|
188
|
+
], SonicGamepad.prototype, "deadzone", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
property({ type: Object })
|
|
191
|
+
], SonicGamepad.prototype, "repeat", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
property({ type: String })
|
|
194
|
+
], SonicGamepad.prototype, "dataProvider", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
property({ type: Boolean, attribute: "dispatch-event" })
|
|
197
|
+
], SonicGamepad.prototype, "dispatchEventFlag", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
state()
|
|
200
|
+
], SonicGamepad.prototype, "connected", void 0);
|
|
201
|
+
SonicGamepad = __decorate([
|
|
202
|
+
customElement(tagName)
|
|
203
|
+
], SonicGamepad);
|
|
204
|
+
export { SonicGamepad };
|
|
205
|
+
export default SonicGamepad;
|
|
206
|
+
//# sourceMappingURL=gamepad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gamepad.js","sourceRoot":"","sources":["../../../../../../src/core/components/functional/interactive/gamepad.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAA2B,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,iDAAiD,CAAC;AAEtE,MAAM,OAAO,GAAG,eAAe,CAAC;AAIhC,MAAM,QAAQ,GAA2D;IACvE,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,EAAE;IAChB,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE;IAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE;IAC5B,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE;IAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE;CAC7B,CAAC;AAEF;;GAEG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAQL,WAAM,GAAG,EAAE,CAAC;QAGZ,WAAM,GAAiE;YACrE,WAAW,EAAE,MAAM;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B;AAET;IAAhB,KAAK,EAAE;+CAA2B;AAjCxB,YAAY;IADxB,aAAa,CAAC,OAAO,CAAC;GACV,YAAY,CAoKxB;;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, css, html } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { dispatch } from "./registry";
|
|
10
|
+
const tagName = "sonic-gesture";
|
|
11
|
+
/**
|
|
12
|
+
* Zone tactile : tap, double-tap, swipe, long-press (+ drag optionnel).
|
|
13
|
+
*/
|
|
14
|
+
let SonicGesture = class SonicGesture extends LitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.target = "";
|
|
18
|
+
this.swipeThreshold = 40;
|
|
19
|
+
this.longPressMs = 450;
|
|
20
|
+
this.doubleTapMs = 280;
|
|
21
|
+
this.drag = false;
|
|
22
|
+
this.dispatchEventFlag = false;
|
|
23
|
+
this.startX = 0;
|
|
24
|
+
this.startY = 0;
|
|
25
|
+
this.startT = 0;
|
|
26
|
+
this.longTimer = null;
|
|
27
|
+
this.lastTap = 0;
|
|
28
|
+
this.pointerId = null;
|
|
29
|
+
this.onDown = (e) => {
|
|
30
|
+
if (this.pointerId != null)
|
|
31
|
+
return;
|
|
32
|
+
this.pointerId = e.pointerId;
|
|
33
|
+
this.setPointerCapture(e.pointerId);
|
|
34
|
+
this.startX = e.clientX;
|
|
35
|
+
this.startY = e.clientY;
|
|
36
|
+
this.startT = performance.now();
|
|
37
|
+
this.longTimer = window.setTimeout(() => {
|
|
38
|
+
this.emit({ type: "long-press" });
|
|
39
|
+
this.longTimer = null;
|
|
40
|
+
}, this.longPressMs);
|
|
41
|
+
};
|
|
42
|
+
this.onMove = (e) => {
|
|
43
|
+
if (this.pointerId !== e.pointerId)
|
|
44
|
+
return;
|
|
45
|
+
const dx = e.clientX - this.startX;
|
|
46
|
+
const dy = e.clientY - this.startY;
|
|
47
|
+
if (Math.hypot(dx, dy) > 10 && this.longTimer != null) {
|
|
48
|
+
clearTimeout(this.longTimer);
|
|
49
|
+
this.longTimer = null;
|
|
50
|
+
}
|
|
51
|
+
if (this.drag) {
|
|
52
|
+
const rect = this.getBoundingClientRect();
|
|
53
|
+
this.emit({
|
|
54
|
+
type: "drag",
|
|
55
|
+
payload: {
|
|
56
|
+
dx: rect.width ? dx / rect.width : 0,
|
|
57
|
+
dy: rect.height ? dy / rect.height : 0,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
this.onUp = (e) => {
|
|
63
|
+
if (this.pointerId !== e.pointerId)
|
|
64
|
+
return;
|
|
65
|
+
if (this.longTimer != null) {
|
|
66
|
+
clearTimeout(this.longTimer);
|
|
67
|
+
this.longTimer = null;
|
|
68
|
+
}
|
|
69
|
+
const dx = e.clientX - this.startX;
|
|
70
|
+
const dy = e.clientY - this.startY;
|
|
71
|
+
const dist = Math.hypot(dx, dy);
|
|
72
|
+
const dt = performance.now() - this.startT;
|
|
73
|
+
this.pointerId = null;
|
|
74
|
+
if (dist >= this.swipeThreshold) {
|
|
75
|
+
const type = Math.abs(dx) > Math.abs(dy)
|
|
76
|
+
? dx > 0
|
|
77
|
+
? "swipe-right"
|
|
78
|
+
: "swipe-left"
|
|
79
|
+
: dy > 0
|
|
80
|
+
? "swipe-down"
|
|
81
|
+
: "swipe-up";
|
|
82
|
+
this.emit({ type });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (dt < this.longPressMs) {
|
|
86
|
+
const now = performance.now();
|
|
87
|
+
if (now - this.lastTap < this.doubleTapMs) {
|
|
88
|
+
this.emit({ type: "double-tap" });
|
|
89
|
+
this.lastTap = 0;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.emit({ type: "tap" });
|
|
93
|
+
this.lastTap = now;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
emit(action) {
|
|
99
|
+
if (this.target)
|
|
100
|
+
dispatch(this.target, action);
|
|
101
|
+
if (this.dispatchEventFlag) {
|
|
102
|
+
this.dispatchEvent(new CustomEvent("sonic-action", {
|
|
103
|
+
detail: action,
|
|
104
|
+
bubbles: true,
|
|
105
|
+
composed: true,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
render() {
|
|
110
|
+
return html `<slot
|
|
111
|
+
@pointerdown=${this.onDown}
|
|
112
|
+
@pointermove=${this.onMove}
|
|
113
|
+
@pointerup=${this.onUp}
|
|
114
|
+
@pointercancel=${this.onUp}
|
|
115
|
+
></slot>`;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
SonicGesture.styles = css `
|
|
119
|
+
:host {
|
|
120
|
+
display: block;
|
|
121
|
+
touch-action: none;
|
|
122
|
+
user-select: none;
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
__decorate([
|
|
126
|
+
property({ type: String })
|
|
127
|
+
], SonicGesture.prototype, "target", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
property({ type: Number, attribute: "swipe-threshold" })
|
|
130
|
+
], SonicGesture.prototype, "swipeThreshold", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
property({ type: Number, attribute: "long-press-ms" })
|
|
133
|
+
], SonicGesture.prototype, "longPressMs", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
property({ type: Number, attribute: "double-tap-ms" })
|
|
136
|
+
], SonicGesture.prototype, "doubleTapMs", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
property({ type: Boolean })
|
|
139
|
+
], SonicGesture.prototype, "drag", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
property({ type: Boolean, attribute: "dispatch-event" })
|
|
142
|
+
], SonicGesture.prototype, "dispatchEventFlag", void 0);
|
|
143
|
+
SonicGesture = __decorate([
|
|
144
|
+
customElement(tagName)
|
|
145
|
+
], SonicGesture);
|
|
146
|
+
export { SonicGesture };
|
|
147
|
+
export default SonicGesture;
|
|
148
|
+
//# sourceMappingURL=gesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gesture.js","sourceRoot":"","sources":["../../../../../../src/core/components/functional/interactive/gesture.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAA2B,MAAM,YAAY,CAAC;AAE/D,MAAM,OAAO,GAAG,eAAe,CAAC;AAEhC;;GAEG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAUL,WAAM,GAAG,EAAE,CAAC;QAGZ,mBAAc,GAAG,EAAE,CAAC;QAGpB,gBAAW,GAAG,GAAG,CAAC;QAGlB,gBAAW,GAAG,GAAG,CAAC;QAGlB,SAAI,GAAG,KAAK,CAAC;QAGb,sBAAiB,GAAG,KAAK,CAAC;QAElB,WAAM,GAAG,CAAC,CAAC;QACX,WAAM,GAAG,CAAC,CAAC;QACX,WAAM,GAAG,CAAC,CAAC;QACX,cAAS,GAAkB,IAAI,CAAC;QAChC,YAAO,GAAG,CAAC,CAAC;QACZ,cAAS,GAAkB,IAAI,CAAC;Q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,MAAM,EAAE,CAAC;4CACf;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;oDACrC;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;iDACrC;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;iDACrC;AAGlB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;uDAC/B;AAzBf,YAAY;IADxB,aAAa,CAAC,OAAO,CAAC;GACV,YAAY,CA2HxB;;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** mulberry32 → { value: 0..1, seed } */
|
|
2
|
+
export function rand(seed) {
|
|
3
|
+
let t = (Number(seed) >>> 0) + 0x6d2b79f5;
|
|
4
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
5
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
6
|
+
const next = t >>> 0;
|
|
7
|
+
return { value: ((next ^ (next >>> 14)) >>> 0) / 4294967296, seed: next };
|
|
8
|
+
}
|
|
9
|
+
export function randInt(seed, n) {
|
|
10
|
+
const r = rand(seed);
|
|
11
|
+
const max = Math.max(1, Math.floor(Number(n) || 1));
|
|
12
|
+
return { value: Math.floor(r.value * max), seed: r.seed };
|
|
13
|
+
}
|
|
14
|
+
export function clamp(value, min, max) {
|
|
15
|
+
const v = Number(value);
|
|
16
|
+
const a = Number(min);
|
|
17
|
+
const b = Number(max);
|
|
18
|
+
return Math.min(b, Math.max(a, v));
|
|
19
|
+
}
|
|
20
|
+
export function range(n) {
|
|
21
|
+
const len = Math.max(0, Math.min(10_000, Math.floor(Number(n) || 0)));
|
|
22
|
+
return Array.from({ length: len }, (_, i) => i);
|
|
23
|
+
}
|
|
24
|
+
/** Set immuable par chemin dot (`a.b.0.c`). */
|
|
25
|
+
export function immutableSet(obj, path, value) {
|
|
26
|
+
const parts = String(path ?? "")
|
|
27
|
+
.split(".")
|
|
28
|
+
.filter(Boolean);
|
|
29
|
+
if (!parts.length)
|
|
30
|
+
return value;
|
|
31
|
+
const clone = (v) => {
|
|
32
|
+
if (Array.isArray(v))
|
|
33
|
+
return v.slice();
|
|
34
|
+
if (v && typeof v === "object")
|
|
35
|
+
return { ...v };
|
|
36
|
+
return v;
|
|
37
|
+
};
|
|
38
|
+
const root = clone(obj ?? {});
|
|
39
|
+
let cur = root;
|
|
40
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
41
|
+
const key = parts[i];
|
|
42
|
+
const next = cur[key];
|
|
43
|
+
cur[key] = clone(next ?? (/^\d+$/.test(parts[i + 1]) ? [] : {}));
|
|
44
|
+
cur = cur[key];
|
|
45
|
+
}
|
|
46
|
+
cur[parts[parts.length - 1]] = value;
|
|
47
|
+
return root;
|
|
48
|
+
}
|
|
49
|
+
export function matrix(w, h, fill = 0) {
|
|
50
|
+
const width = Math.max(0, Math.min(256, Math.floor(Number(w) || 0)));
|
|
51
|
+
const height = Math.max(0, Math.min(256, Math.floor(Number(h) || 0)));
|
|
52
|
+
const f = Number(fill) || 0;
|
|
53
|
+
return Array.from({ length: height }, () => Array.from({ length: width }, () => f));
|
|
54
|
+
}
|
|
55
|
+
/** Rotation 90° horaire d’une matrice 2D. */
|
|
56
|
+
export function rotate(mat) {
|
|
57
|
+
if (!Array.isArray(mat) || !mat.length)
|
|
58
|
+
return [];
|
|
59
|
+
const rows = mat;
|
|
60
|
+
const h = rows.length;
|
|
61
|
+
const w = Array.isArray(rows[0]) ? rows[0].length : 0;
|
|
62
|
+
const out = Array.from({ length: w }, () => Array.from({ length: h }, () => 0));
|
|
63
|
+
for (let y = 0; y < h; y++) {
|
|
64
|
+
const row = rows[y];
|
|
65
|
+
if (!Array.isArray(row))
|
|
66
|
+
continue;
|
|
67
|
+
for (let x = 0; x < w; x++) {
|
|
68
|
+
out[x][h - 1 - y] = Number(row[x]) || 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
export function registerInteractiveHelpers(expression) {
|
|
74
|
+
expression.registerFunction("rand", rand);
|
|
75
|
+
expression.registerFunction("randInt", randInt);
|
|
76
|
+
expression.registerFunction("clamp", clamp);
|
|
77
|
+
expression.registerFunction("range", range);
|
|
78
|
+
expression.registerFunction("set", immutableSet);
|
|
79
|
+
expression.registerFunction("matrix", matrix);
|
|
80
|
+
expression.registerFunction("rotate", rotate);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../src/core/components/functional/interactive/helpers.ts"],"names":[],"mappings":"AAMA,yCAAyC;AACzC,MAAM,UAAU,IAAI,CAAC,IAAa;IAChC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CAAC;IAC1C,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,EAAE,IAAI,EAAE,IAAI,EA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,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,SAAS;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,UAAsB;IAC/D,UAAU,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1C,UAAU,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChD,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5C,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5C,UAAU,CAAC,gBAAgB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACjD,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9C,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Addon interactivity déclarative (stores, inputs, matrix).
|
|
3
|
+
* Opt-in : `@supersoniks/concorde/interactive`
|
|
4
|
+
*/
|
|
5
|
+
export { dispatch, getStore, listStoreIds, } from "./registry";
|
|
6
|
+
export { SonicStore } from "./store";
|
|
7
|
+
export { SonicKeyboard } from "./keyboard";
|
|
8
|
+
export { SonicGamepad } from "./gamepad";
|
|
9
|
+
export { SonicGesture } from "./gesture";
|
|
10
|
+
export { SonicAction } from "./action";
|
|
11
|
+
export { SonicTicker } from "./ticker";
|
|
12
|
+
export { SonicMatrix } from "./matrix";
|
|
13
|
+
import "./store";
|
|
14
|
+
import "./keyboard";
|
|
15
|
+
import "./gamepad";
|
|
16
|
+
import "./gesture";
|
|
17
|
+
import "./action";
|
|
18
|
+
import "./ticker";
|
|
19
|
+
import "./matrix";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/core/components/functional/interactive/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,GAEb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,SAAS,CAAC;AACjB,OAAO,YAAY,CAAC;AACpB,OAAO,WAAW,CAAC;AACnB,OAAO,WAAW,CAAC;AACnB,OAAO,UAAU,CAAC;AAClB,OAAO,UAAU,CAAC;AAClB,OAAO,UAAU,CAAC"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, css, html } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { dispatch } from "./registry";
|
|
10
|
+
const tagName = "sonic-keyboard";
|
|
11
|
+
/**
|
|
12
|
+
* Source d’actions clavier → store (`target`).
|
|
13
|
+
* Opt-in `@supersoniks/concorde/interactive`.
|
|
14
|
+
*/
|
|
15
|
+
let SonicKeyboard = class SonicKeyboard extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.target = "";
|
|
19
|
+
this.keymap = {};
|
|
20
|
+
/** `document` | `focus` */
|
|
21
|
+
this.scope = "document";
|
|
22
|
+
/** `{ "left": [delayMs, intervalMs] }` */
|
|
23
|
+
this.repeat = {};
|
|
24
|
+
this.keyup = false;
|
|
25
|
+
this.dispatchEventFlag = false;
|
|
26
|
+
this.held = new Map();
|
|
27
|
+
this.onVis = () => {
|
|
28
|
+
if (document.hidden)
|
|
29
|
+
this.releaseAll();
|
|
30
|
+
};
|
|
31
|
+
this.onKeyDown = (ev) => {
|
|
32
|
+
const e = ev;
|
|
33
|
+
if (e.repeat)
|
|
34
|
+
return; // handled via our DAS/ARR
|
|
35
|
+
if (this.isEditableTarget(e.target))
|
|
36
|
+
return;
|
|
37
|
+
const code = e.code || e.key;
|
|
38
|
+
const mapped = this.keymap?.[code] ?? this.keymap?.[e.key];
|
|
39
|
+
if (!mapped)
|
|
40
|
+
return;
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
const action = this.toAction(mapped);
|
|
43
|
+
this.emit(action);
|
|
44
|
+
const rep = this.repeat?.[action.type];
|
|
45
|
+
if (rep) {
|
|
46
|
+
const [delay, interval] = rep;
|
|
47
|
+
const entry = {
|
|
48
|
+
type: action.type,
|
|
49
|
+
payload: action.payload,
|
|
50
|
+
timer: window.setTimeout(() => {
|
|
51
|
+
this.emit({ type: action.type, payload: action.payload });
|
|
52
|
+
entry.interval = window.setInterval(() => {
|
|
53
|
+
this.emit({ type: action.type, payload: action.payload });
|
|
54
|
+
}, Math.max(16, interval));
|
|
55
|
+
}, Math.max(0, delay)),
|
|
56
|
+
};
|
|
57
|
+
this.held.set(code, entry);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.held.set(code, { type: action.type, payload: action.payload });
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
this.onKeyUp = (ev) => {
|
|
64
|
+
const e = ev;
|
|
65
|
+
const code = e.code || e.key;
|
|
66
|
+
const held = this.held.get(code);
|
|
67
|
+
if (held) {
|
|
68
|
+
if (held.timer)
|
|
69
|
+
clearTimeout(held.timer);
|
|
70
|
+
if (held.interval)
|
|
71
|
+
clearInterval(held.interval);
|
|
72
|
+
this.held.delete(code);
|
|
73
|
+
if (this.keyup) {
|
|
74
|
+
this.emit({ type: `${held.type}:up`, payload: held.payload });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
this.releaseAll = () => {
|
|
79
|
+
for (const [, held] of this.held) {
|
|
80
|
+
if (held.timer)
|
|
81
|
+
clearTimeout(held.timer);
|
|
82
|
+
if (held.interval)
|
|
83
|
+
clearInterval(held.interval);
|
|
84
|
+
}
|
|
85
|
+
this.held.clear();
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
connectedCallback() {
|
|
89
|
+
super.connectedCallback();
|
|
90
|
+
if (this.scope === "focus") {
|
|
91
|
+
if (!this.hasAttribute("tabindex"))
|
|
92
|
+
this.tabIndex = 0;
|
|
93
|
+
}
|
|
94
|
+
this.bindTarget().addEventListener("keydown", this.onKeyDown);
|
|
95
|
+
this.bindTarget().addEventListener("keyup", this.onKeyUp);
|
|
96
|
+
window.addEventListener("blur", this.releaseAll);
|
|
97
|
+
document.addEventListener("visibilitychange", this.onVis);
|
|
98
|
+
}
|
|
99
|
+
disconnectedCallback() {
|
|
100
|
+
this.bindTarget().removeEventListener("keydown", this.onKeyDown);
|
|
101
|
+
this.bindTarget().removeEventListener("keyup", this.onKeyUp);
|
|
102
|
+
window.removeEventListener("blur", this.releaseAll);
|
|
103
|
+
document.removeEventListener("visibilitychange", this.onVis);
|
|
104
|
+
this.releaseAll();
|
|
105
|
+
super.disconnectedCallback();
|
|
106
|
+
}
|
|
107
|
+
updated(changed) {
|
|
108
|
+
if (changed.has("scope")) {
|
|
109
|
+
// rebind would need disconnect/connect; keep simple: focus ring attrs
|
|
110
|
+
if (this.scope === "focus" && !this.hasAttribute("tabindex"))
|
|
111
|
+
this.tabIndex = 0;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
bindTarget() {
|
|
115
|
+
return this.scope === "focus" ? this : window;
|
|
116
|
+
}
|
|
117
|
+
isEditableTarget(t) {
|
|
118
|
+
if (!(t instanceof HTMLElement))
|
|
119
|
+
return false;
|
|
120
|
+
const tag = t.tagName;
|
|
121
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT")
|
|
122
|
+
return true;
|
|
123
|
+
if (t.isContentEditable)
|
|
124
|
+
return true;
|
|
125
|
+
return Boolean(t.closest("input,textarea,select,[contenteditable=true]"));
|
|
126
|
+
}
|
|
127
|
+
toAction(mapped) {
|
|
128
|
+
if (typeof mapped === "string")
|
|
129
|
+
return { type: mapped };
|
|
130
|
+
return { type: mapped.type, payload: mapped.payload };
|
|
131
|
+
}
|
|
132
|
+
emit(action) {
|
|
133
|
+
if (this.target)
|
|
134
|
+
dispatch(this.target, action);
|
|
135
|
+
if (this.dispatchEventFlag) {
|
|
136
|
+
this.dispatchEvent(new CustomEvent("sonic-action", {
|
|
137
|
+
detail: action,
|
|
138
|
+
bubbles: true,
|
|
139
|
+
composed: true,
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
render() {
|
|
144
|
+
return this.scope === "focus" ? html `<slot></slot>` : html ``;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
SonicKeyboard.styles = css `
|
|
148
|
+
:host {
|
|
149
|
+
display: contents;
|
|
150
|
+
}
|
|
151
|
+
:host([scope="focus"]) {
|
|
152
|
+
display: block;
|
|
153
|
+
outline: none;
|
|
154
|
+
}
|
|
155
|
+
:host([scope="focus"]:focus) {
|
|
156
|
+
outline: 2px solid var(--sc-primary, #3b82f6);
|
|
157
|
+
outline-offset: 2px;
|
|
158
|
+
}
|
|
159
|
+
`;
|
|
160
|
+
__decorate([
|
|
161
|
+
property({ type: String })
|
|
162
|
+
], SonicKeyboard.prototype, "target", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
property({ type: Object })
|
|
165
|
+
], SonicKeyboard.prototype, "keymap", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
property({ type: String })
|
|
168
|
+
], SonicKeyboard.prototype, "scope", void 0);
|
|
169
|
+
__decorate([
|
|
170
|
+
property({ type: Object })
|
|
171
|
+
], SonicKeyboard.prototype, "repeat", void 0);
|
|
172
|
+
__decorate([
|
|
173
|
+
property({ type: Boolean })
|
|
174
|
+
], SonicKeyboard.prototype, "keyup", void 0);
|
|
175
|
+
__decorate([
|
|
176
|
+
property({ type: Boolean, attribute: "dispatch-event" })
|
|
177
|
+
], SonicKeyboard.prototype, "dispatchEventFlag", void 0);
|
|
178
|
+
SonicKeyboard = __decorate([
|
|
179
|
+
customElement(tagName)
|
|
180
|
+
], SonicKeyboard);
|
|
181
|
+
export { SonicKeyboard };
|
|
182
|
+
export default SonicKeyboard;
|
|
183
|
+
//# sourceMappingURL=keyboard.js.map
|