@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
|
@@ -1,23 +1,70 @@
|
|
|
1
1
|
import {css, html, LitElement, nothing} from "lit";
|
|
2
2
|
import {customElement, property} from "lit/decorators.js";
|
|
3
|
-
|
|
3
|
+
import {Subscriber} from "@supersoniks/concorde/mixins";
|
|
4
|
+
|
|
5
|
+
const tagName = "sonic-if";
|
|
6
|
+
|
|
7
|
+
function pathGet(obj: unknown, path: string): unknown {
|
|
8
|
+
if (!path) return obj;
|
|
9
|
+
let cur: any = obj;
|
|
10
|
+
for (const p of path.split(".").filter(Boolean)) {
|
|
11
|
+
if (cur == null) return undefined;
|
|
12
|
+
cur = cur[p];
|
|
13
|
+
}
|
|
14
|
+
return cur;
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
/**
|
|
5
|
-
*
|
|
18
|
+
* Affiche le slot si `.condition` est true **ou** via attributs SDUI
|
|
19
|
+
* `dataProvider` + `key` (+ `equals` / `not` / `truthy` / `gt` / `lt`).
|
|
6
20
|
*/
|
|
7
21
|
@customElement(tagName)
|
|
8
|
-
export class SonicIF extends LitElement {
|
|
22
|
+
export class SonicIF extends Subscriber(LitElement) {
|
|
9
23
|
static styles = css`
|
|
10
24
|
:host {
|
|
11
25
|
display: contents;
|
|
12
26
|
}
|
|
13
27
|
`;
|
|
14
28
|
|
|
15
|
-
/**
|
|
16
|
-
* Le contenu s'affiche si la condition est évaluée à true.
|
|
17
|
-
*/
|
|
29
|
+
/** Mode Lit classique. */
|
|
18
30
|
@property({type: Boolean}) condition = false;
|
|
31
|
+
|
|
32
|
+
@property({type: String}) key = "";
|
|
33
|
+
|
|
34
|
+
@property({type: String}) equals = "";
|
|
35
|
+
|
|
36
|
+
@property({type: String}) not = "";
|
|
37
|
+
|
|
38
|
+
@property({type: Boolean}) truthy = false;
|
|
39
|
+
|
|
40
|
+
@property({type: String}) gt = "";
|
|
41
|
+
|
|
42
|
+
@property({type: String}) lt = "";
|
|
43
|
+
|
|
44
|
+
private attrMode(): boolean {
|
|
45
|
+
return Boolean(
|
|
46
|
+
this.dataProvider &&
|
|
47
|
+
(this.key ||
|
|
48
|
+
this.truthy ||
|
|
49
|
+
this.equals !== "" ||
|
|
50
|
+
this.not !== "" ||
|
|
51
|
+
this.gt !== "" ||
|
|
52
|
+
this.lt !== ""),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private show(): boolean {
|
|
57
|
+
if (!this.attrMode()) return this.condition;
|
|
58
|
+
const value = pathGet(this.props, this.key);
|
|
59
|
+
if (this.equals !== "") return String(value) === this.equals;
|
|
60
|
+
if (this.not !== "") return String(value) !== this.not;
|
|
61
|
+
if (this.gt !== "") return Number(value) > Number(this.gt);
|
|
62
|
+
if (this.lt !== "") return Number(value) < Number(this.lt);
|
|
63
|
+
return Boolean(value);
|
|
64
|
+
}
|
|
65
|
+
|
|
19
66
|
render() {
|
|
20
|
-
if (!this.
|
|
67
|
+
if (!this.show()) return nothing;
|
|
21
68
|
return html` <slot></slot> `;
|
|
22
69
|
}
|
|
23
70
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import { dispatch, type SonicActionMessage } from "./registry";
|
|
4
|
+
|
|
5
|
+
const tagName = "sonic-action";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wrapper clic → dispatch vers un store.
|
|
9
|
+
* `hold-repeat="170,50"` pour d-pad tactile.
|
|
10
|
+
*/
|
|
11
|
+
@customElement(tagName)
|
|
12
|
+
export class SonicAction extends LitElement {
|
|
13
|
+
static styles = css`
|
|
14
|
+
:host {
|
|
15
|
+
display: contents;
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
@property({ type: String })
|
|
20
|
+
target = "";
|
|
21
|
+
|
|
22
|
+
@property({ type: String })
|
|
23
|
+
type = "";
|
|
24
|
+
|
|
25
|
+
@property({ type: Object })
|
|
26
|
+
payload: unknown = null;
|
|
27
|
+
|
|
28
|
+
@property({ type: String, attribute: "hold-repeat" })
|
|
29
|
+
holdRepeat = "";
|
|
30
|
+
|
|
31
|
+
@property({ type: Boolean, attribute: "dispatch-event" })
|
|
32
|
+
dispatchEventFlag = false;
|
|
33
|
+
|
|
34
|
+
private holdTimer: number | null = null;
|
|
35
|
+
private holdInterval: number | null = null;
|
|
36
|
+
|
|
37
|
+
private onPointerDown = (e: PointerEvent) => {
|
|
38
|
+
if (e.button != null && e.button !== 0) return;
|
|
39
|
+
this.emit();
|
|
40
|
+
const parts = this.holdRepeat.split(",").map((s) => Number(s.trim()));
|
|
41
|
+
if (parts.length === 2 && parts.every((n) => Number.isFinite(n))) {
|
|
42
|
+
const [delay, interval] = parts;
|
|
43
|
+
this.holdTimer = window.setTimeout(() => {
|
|
44
|
+
this.emit();
|
|
45
|
+
this.holdInterval = window.setInterval(() => this.emit(), Math.max(16, interval));
|
|
46
|
+
}, Math.max(0, delay));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
private onPointerUp = () => this.clearHold();
|
|
51
|
+
|
|
52
|
+
private clearHold(): void {
|
|
53
|
+
if (this.holdTimer != null) clearTimeout(this.holdTimer);
|
|
54
|
+
if (this.holdInterval != null) clearInterval(this.holdInterval);
|
|
55
|
+
this.holdTimer = null;
|
|
56
|
+
this.holdInterval = null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private emit(): void {
|
|
60
|
+
if (!this.type) return;
|
|
61
|
+
const action: SonicActionMessage = { type: this.type, payload: this.payload };
|
|
62
|
+
if (this.target) dispatch(this.target, action);
|
|
63
|
+
if (this.dispatchEventFlag) {
|
|
64
|
+
this.dispatchEvent(
|
|
65
|
+
new CustomEvent("sonic-action", {
|
|
66
|
+
detail: action,
|
|
67
|
+
bubbles: true,
|
|
68
|
+
composed: true,
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
return html`<slot
|
|
76
|
+
@pointerdown=${this.onPointerDown}
|
|
77
|
+
@pointerup=${this.onPointerUp}
|
|
78
|
+
@pointercancel=${this.onPointerUp}
|
|
79
|
+
@pointerleave=${this.onPointerUp}
|
|
80
|
+
></slot>`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default SonicAction;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
3
|
+
import { dispatch, type SonicActionMessage } from "./registry";
|
|
4
|
+
import { set } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
5
|
+
|
|
6
|
+
const tagName = "sonic-gamepad";
|
|
7
|
+
|
|
8
|
+
type RepeatCfg = Record<string, [number, number]>;
|
|
9
|
+
|
|
10
|
+
const STANDARD: Record<string, number | { axis: number; dir: 1 | -1 }> = {
|
|
11
|
+
"dpad-up": 12,
|
|
12
|
+
"dpad-down": 13,
|
|
13
|
+
"dpad-left": 14,
|
|
14
|
+
"dpad-right": 15,
|
|
15
|
+
a: 0,
|
|
16
|
+
b: 1,
|
|
17
|
+
x: 2,
|
|
18
|
+
y: 3,
|
|
19
|
+
start: 9,
|
|
20
|
+
select: 8,
|
|
21
|
+
"ls-x-": { axis: 0, dir: -1 },
|
|
22
|
+
"ls-x+": { axis: 0, dir: 1 },
|
|
23
|
+
"ls-y-": { axis: 1, dir: -1 },
|
|
24
|
+
"ls-y+": { axis: 1, dir: 1 },
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Manette → actions store. Raf uniquement si une pad est connectée.
|
|
29
|
+
*/
|
|
30
|
+
@customElement(tagName)
|
|
31
|
+
export class SonicGamepad extends LitElement {
|
|
32
|
+
static styles = css`
|
|
33
|
+
:host {
|
|
34
|
+
display: contents;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
@property({ type: String })
|
|
39
|
+
target = "";
|
|
40
|
+
|
|
41
|
+
@property({ type: Object })
|
|
42
|
+
keymap: Record<string, string | { type: string; payload?: unknown }> = {
|
|
43
|
+
"dpad-left": "left",
|
|
44
|
+
"dpad-right": "right",
|
|
45
|
+
"dpad-up": "rotate",
|
|
46
|
+
"dpad-down": "soft-drop",
|
|
47
|
+
a: "rotate",
|
|
48
|
+
b: "drop",
|
|
49
|
+
start: "pause",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
@property({ type: Number })
|
|
53
|
+
deadzone = 0.25;
|
|
54
|
+
|
|
55
|
+
@property({ type: Object })
|
|
56
|
+
repeat: RepeatCfg = {};
|
|
57
|
+
|
|
58
|
+
@property({ type: String })
|
|
59
|
+
dataProvider = "";
|
|
60
|
+
|
|
61
|
+
@property({ type: Boolean, attribute: "dispatch-event" })
|
|
62
|
+
dispatchEventFlag = false;
|
|
63
|
+
|
|
64
|
+
@state() private connected = false;
|
|
65
|
+
|
|
66
|
+
private raf = 0;
|
|
67
|
+
private prev = new Map<string, boolean>();
|
|
68
|
+
private heldTimers = new Map<string, { timer?: number; interval?: number }>();
|
|
69
|
+
|
|
70
|
+
connectedCallback(): void {
|
|
71
|
+
super.connectedCallback();
|
|
72
|
+
window.addEventListener("gamepadconnected", this.onConnect);
|
|
73
|
+
window.addEventListener("gamepaddisconnected", this.onDisconnect);
|
|
74
|
+
this.scan();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
disconnectedCallback(): void {
|
|
78
|
+
window.removeEventListener("gamepadconnected", this.onConnect);
|
|
79
|
+
window.removeEventListener("gamepaddisconnected", this.onDisconnect);
|
|
80
|
+
this.stopLoop();
|
|
81
|
+
this.clearHolds();
|
|
82
|
+
super.disconnectedCallback();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private onConnect = () => this.scan();
|
|
86
|
+
private onDisconnect = () => this.scan();
|
|
87
|
+
|
|
88
|
+
private scan(): void {
|
|
89
|
+
const pads = navigator.getGamepads?.() ?? [];
|
|
90
|
+
const any = [...pads].some(Boolean);
|
|
91
|
+
this.connected = any;
|
|
92
|
+
this.publishStatus();
|
|
93
|
+
if (any) this.startLoop();
|
|
94
|
+
else this.stopLoop();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private publishStatus(): void {
|
|
98
|
+
if (!this.dataProvider) return;
|
|
99
|
+
const pads = navigator.getGamepads?.() ?? [];
|
|
100
|
+
const first = [...pads].find(Boolean);
|
|
101
|
+
set(this.dataProvider, {
|
|
102
|
+
connected: this.connected,
|
|
103
|
+
id: first?.id ?? null,
|
|
104
|
+
} as never);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private startLoop(): void {
|
|
108
|
+
if (this.raf) return;
|
|
109
|
+
const loop = () => {
|
|
110
|
+
this.raf = requestAnimationFrame(loop);
|
|
111
|
+
this.poll();
|
|
112
|
+
};
|
|
113
|
+
this.raf = requestAnimationFrame(loop);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private stopLoop(): void {
|
|
117
|
+
if (this.raf) cancelAnimationFrame(this.raf);
|
|
118
|
+
this.raf = 0;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private poll(): void {
|
|
122
|
+
const pads = navigator.getGamepads?.() ?? [];
|
|
123
|
+
const pad = [...pads].find(Boolean);
|
|
124
|
+
if (!pad) {
|
|
125
|
+
this.scan();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
for (const [name, mapped] of Object.entries(this.keymap || {})) {
|
|
129
|
+
const spec = STANDARD[name];
|
|
130
|
+
if (spec == null) continue;
|
|
131
|
+
let pressed = false;
|
|
132
|
+
if (typeof spec === "number") {
|
|
133
|
+
pressed = Boolean(pad.buttons[spec]?.pressed);
|
|
134
|
+
} else {
|
|
135
|
+
const axis = pad.axes[spec.axis] ?? 0;
|
|
136
|
+
pressed = spec.dir < 0 ? axis < -this.deadzone : axis > this.deadzone;
|
|
137
|
+
}
|
|
138
|
+
const was = this.prev.get(name) ?? false;
|
|
139
|
+
if (pressed && !was) {
|
|
140
|
+
this.fire(mapped);
|
|
141
|
+
this.startRepeat(name, mapped);
|
|
142
|
+
} else if (!pressed && was) {
|
|
143
|
+
this.stopRepeat(name);
|
|
144
|
+
}
|
|
145
|
+
this.prev.set(name, pressed);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private startRepeat(
|
|
150
|
+
name: string,
|
|
151
|
+
mapped: string | { type: string; payload?: unknown },
|
|
152
|
+
): void {
|
|
153
|
+
const action = typeof mapped === "string" ? { type: mapped } : mapped;
|
|
154
|
+
const rep = this.repeat?.[action.type];
|
|
155
|
+
if (!rep) return;
|
|
156
|
+
const [delay, interval] = rep;
|
|
157
|
+
const entry: { timer?: number; interval?: number } = {};
|
|
158
|
+
entry.timer = window.setTimeout(() => {
|
|
159
|
+
this.fire(mapped);
|
|
160
|
+
entry.interval = window.setInterval(() => this.fire(mapped), Math.max(16, interval));
|
|
161
|
+
}, Math.max(0, delay));
|
|
162
|
+
this.heldTimers.set(name, entry);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private stopRepeat(name: string): void {
|
|
166
|
+
const h = this.heldTimers.get(name);
|
|
167
|
+
if (!h) return;
|
|
168
|
+
if (h.timer) clearTimeout(h.timer);
|
|
169
|
+
if (h.interval) clearInterval(h.interval);
|
|
170
|
+
this.heldTimers.delete(name);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private clearHolds(): void {
|
|
174
|
+
for (const name of [...this.heldTimers.keys()]) this.stopRepeat(name);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private fire(mapped: string | { type: string; payload?: unknown }): void {
|
|
178
|
+
const action: SonicActionMessage =
|
|
179
|
+
typeof mapped === "string" ? { type: mapped } : { type: mapped.type, payload: mapped.payload };
|
|
180
|
+
if (this.target) dispatch(this.target, action);
|
|
181
|
+
if (this.dispatchEventFlag) {
|
|
182
|
+
this.dispatchEvent(
|
|
183
|
+
new CustomEvent("sonic-action", {
|
|
184
|
+
detail: action,
|
|
185
|
+
bubbles: true,
|
|
186
|
+
composed: true,
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
render() {
|
|
193
|
+
return html``;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default SonicGamepad;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { LitElement, css, html } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
import { dispatch, type SonicActionMessage } from "./registry";
|
|
4
|
+
|
|
5
|
+
const tagName = "sonic-gesture";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Zone tactile : tap, double-tap, swipe, long-press (+ drag optionnel).
|
|
9
|
+
*/
|
|
10
|
+
@customElement(tagName)
|
|
11
|
+
export class SonicGesture extends LitElement {
|
|
12
|
+
static styles = css`
|
|
13
|
+
:host {
|
|
14
|
+
display: block;
|
|
15
|
+
touch-action: none;
|
|
16
|
+
user-select: none;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
@property({ type: String })
|
|
21
|
+
target = "";
|
|
22
|
+
|
|
23
|
+
@property({ type: Number, attribute: "swipe-threshold" })
|
|
24
|
+
swipeThreshold = 40;
|
|
25
|
+
|
|
26
|
+
@property({ type: Number, attribute: "long-press-ms" })
|
|
27
|
+
longPressMs = 450;
|
|
28
|
+
|
|
29
|
+
@property({ type: Number, attribute: "double-tap-ms" })
|
|
30
|
+
doubleTapMs = 280;
|
|
31
|
+
|
|
32
|
+
@property({ type: Boolean })
|
|
33
|
+
drag = false;
|
|
34
|
+
|
|
35
|
+
@property({ type: Boolean, attribute: "dispatch-event" })
|
|
36
|
+
dispatchEventFlag = false;
|
|
37
|
+
|
|
38
|
+
private startX = 0;
|
|
39
|
+
private startY = 0;
|
|
40
|
+
private startT = 0;
|
|
41
|
+
private longTimer: number | null = null;
|
|
42
|
+
private lastTap = 0;
|
|
43
|
+
private pointerId: number | null = null;
|
|
44
|
+
|
|
45
|
+
private onDown = (e: PointerEvent) => {
|
|
46
|
+
if (this.pointerId != null) return;
|
|
47
|
+
this.pointerId = e.pointerId;
|
|
48
|
+
this.setPointerCapture(e.pointerId);
|
|
49
|
+
this.startX = e.clientX;
|
|
50
|
+
this.startY = e.clientY;
|
|
51
|
+
this.startT = performance.now();
|
|
52
|
+
this.longTimer = window.setTimeout(() => {
|
|
53
|
+
this.emit({ type: "long-press" });
|
|
54
|
+
this.longTimer = null;
|
|
55
|
+
}, this.longPressMs);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
private onMove = (e: PointerEvent) => {
|
|
59
|
+
if (this.pointerId !== e.pointerId) return;
|
|
60
|
+
const dx = e.clientX - this.startX;
|
|
61
|
+
const dy = e.clientY - this.startY;
|
|
62
|
+
if (Math.hypot(dx, dy) > 10 && this.longTimer != null) {
|
|
63
|
+
clearTimeout(this.longTimer);
|
|
64
|
+
this.longTimer = null;
|
|
65
|
+
}
|
|
66
|
+
if (this.drag) {
|
|
67
|
+
const rect = this.getBoundingClientRect();
|
|
68
|
+
this.emit({
|
|
69
|
+
type: "drag",
|
|
70
|
+
payload: {
|
|
71
|
+
dx: rect.width ? dx / rect.width : 0,
|
|
72
|
+
dy: rect.height ? dy / rect.height : 0,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
private onUp = (e: PointerEvent) => {
|
|
79
|
+
if (this.pointerId !== e.pointerId) return;
|
|
80
|
+
if (this.longTimer != null) {
|
|
81
|
+
clearTimeout(this.longTimer);
|
|
82
|
+
this.longTimer = null;
|
|
83
|
+
}
|
|
84
|
+
const dx = e.clientX - this.startX;
|
|
85
|
+
const dy = e.clientY - this.startY;
|
|
86
|
+
const dist = Math.hypot(dx, dy);
|
|
87
|
+
const dt = performance.now() - this.startT;
|
|
88
|
+
this.pointerId = null;
|
|
89
|
+
if (dist >= this.swipeThreshold) {
|
|
90
|
+
const type =
|
|
91
|
+
Math.abs(dx) > Math.abs(dy)
|
|
92
|
+
? dx > 0
|
|
93
|
+
? "swipe-right"
|
|
94
|
+
: "swipe-left"
|
|
95
|
+
: dy > 0
|
|
96
|
+
? "swipe-down"
|
|
97
|
+
: "swipe-up";
|
|
98
|
+
this.emit({ type });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (dt < this.longPressMs) {
|
|
102
|
+
const now = performance.now();
|
|
103
|
+
if (now - this.lastTap < this.doubleTapMs) {
|
|
104
|
+
this.emit({ type: "double-tap" });
|
|
105
|
+
this.lastTap = 0;
|
|
106
|
+
} else {
|
|
107
|
+
this.emit({ type: "tap" });
|
|
108
|
+
this.lastTap = now;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
private emit(action: SonicActionMessage): void {
|
|
114
|
+
if (this.target) dispatch(this.target, action);
|
|
115
|
+
if (this.dispatchEventFlag) {
|
|
116
|
+
this.dispatchEvent(
|
|
117
|
+
new CustomEvent("sonic-action", {
|
|
118
|
+
detail: action,
|
|
119
|
+
bubbles: true,
|
|
120
|
+
composed: true,
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
render() {
|
|
127
|
+
return html`<slot
|
|
128
|
+
@pointerdown=${this.onDown}
|
|
129
|
+
@pointermove=${this.onMove}
|
|
130
|
+
@pointerup=${this.onUp}
|
|
131
|
+
@pointercancel=${this.onUp}
|
|
132
|
+
></slot>`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export default SonicGesture;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
clamp,
|
|
4
|
+
matrix,
|
|
5
|
+
rand,
|
|
6
|
+
randInt,
|
|
7
|
+
range,
|
|
8
|
+
rotate,
|
|
9
|
+
immutableSet,
|
|
10
|
+
} from "./helpers";
|
|
11
|
+
|
|
12
|
+
describe("interactive helpers", () => {
|
|
13
|
+
it("rand is deterministic for a seed sequence", () => {
|
|
14
|
+
const a = rand(1);
|
|
15
|
+
const b = rand(a.seed);
|
|
16
|
+
const a2 = rand(1);
|
|
17
|
+
expect(a.value).toBeGreaterThanOrEqual(0);
|
|
18
|
+
expect(a.value).toBeLessThan(1);
|
|
19
|
+
expect(a2.value).toBe(a.value);
|
|
20
|
+
expect(b.seed).not.toBe(a.seed);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("randInt stays in range", () => {
|
|
24
|
+
let seed = 42;
|
|
25
|
+
for (let i = 0; i < 20; i++) {
|
|
26
|
+
const r = randInt(seed, 7);
|
|
27
|
+
expect(r.value).toBeGreaterThanOrEqual(0);
|
|
28
|
+
expect(r.value).toBeLessThan(7);
|
|
29
|
+
seed = r.seed;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("matrix / rotate / set / clamp / range", () => {
|
|
34
|
+
expect(matrix(2, 3, 1)).toEqual([
|
|
35
|
+
[1, 1],
|
|
36
|
+
[1, 1],
|
|
37
|
+
[1, 1],
|
|
38
|
+
]);
|
|
39
|
+
expect(rotate([
|
|
40
|
+
[1, 2],
|
|
41
|
+
[3, 4],
|
|
42
|
+
])).toEqual([
|
|
43
|
+
[3, 1],
|
|
44
|
+
[4, 2],
|
|
45
|
+
]);
|
|
46
|
+
expect(immutableSet({ a: { b: 1 } }, "a.b", 2)).toEqual({ a: { b: 2 } });
|
|
47
|
+
expect(clamp(5, 0, 3)).toBe(3);
|
|
48
|
+
expect(range(3)).toEqual([0, 1, 2]);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers JSONata purs pour sonic-store (PRNG, matrix, set immuable…).
|
|
3
|
+
* `$random` / `$now` volontairement absents — rejouabilité.
|
|
4
|
+
*/
|
|
5
|
+
import type { Expression } from "jsonata";
|
|
6
|
+
|
|
7
|
+
/** mulberry32 → { value: 0..1, seed } */
|
|
8
|
+
export function rand(seed: unknown): { value: number; seed: number } {
|
|
9
|
+
let t = (Number(seed) >>> 0) + 0x6d2b79f5;
|
|
10
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
11
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
12
|
+
const next = t >>> 0;
|
|
13
|
+
return { value: ((next ^ (next >>> 14)) >>> 0) / 4294967296, seed: next };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function randInt(seed: unknown, n: unknown): { value: number; seed: number } {
|
|
17
|
+
const r = rand(seed);
|
|
18
|
+
const max = Math.max(1, Math.floor(Number(n) || 1));
|
|
19
|
+
return { value: Math.floor(r.value * max), seed: r.seed };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function clamp(value: unknown, min: unknown, max: unknown): number {
|
|
23
|
+
const v = Number(value);
|
|
24
|
+
const a = Number(min);
|
|
25
|
+
const b = Number(max);
|
|
26
|
+
return Math.min(b, Math.max(a, v));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function range(n: unknown): number[] {
|
|
30
|
+
const len = Math.max(0, Math.min(10_000, Math.floor(Number(n) || 0)));
|
|
31
|
+
return Array.from({ length: len }, (_, i) => i);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Set immuable par chemin dot (`a.b.0.c`). */
|
|
35
|
+
export function immutableSet(
|
|
36
|
+
obj: unknown,
|
|
37
|
+
path: unknown,
|
|
38
|
+
value: unknown,
|
|
39
|
+
): unknown {
|
|
40
|
+
const parts = String(path ?? "")
|
|
41
|
+
.split(".")
|
|
42
|
+
.filter(Boolean);
|
|
43
|
+
if (!parts.length) return value;
|
|
44
|
+
const clone = (v: unknown): unknown => {
|
|
45
|
+
if (Array.isArray(v)) return v.slice();
|
|
46
|
+
if (v && typeof v === "object") return { ...(v as Record<string, unknown>) };
|
|
47
|
+
return v;
|
|
48
|
+
};
|
|
49
|
+
const root = clone(obj ?? {});
|
|
50
|
+
let cur: any = root;
|
|
51
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
52
|
+
const key = parts[i];
|
|
53
|
+
const next = cur[key];
|
|
54
|
+
cur[key] = clone(next ?? (/^\d+$/.test(parts[i + 1]) ? [] : {}));
|
|
55
|
+
cur = cur[key];
|
|
56
|
+
}
|
|
57
|
+
cur[parts[parts.length - 1]] = value;
|
|
58
|
+
return root;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function matrix(w: unknown, h: unknown, fill: unknown = 0): number[][] {
|
|
62
|
+
const width = Math.max(0, Math.min(256, Math.floor(Number(w) || 0)));
|
|
63
|
+
const height = Math.max(0, Math.min(256, Math.floor(Number(h) || 0)));
|
|
64
|
+
const f = Number(fill) || 0;
|
|
65
|
+
return Array.from({ length: height }, () =>
|
|
66
|
+
Array.from({ length: width }, () => f),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Rotation 90° horaire d’une matrice 2D. */
|
|
71
|
+
export function rotate(mat: unknown): number[][] {
|
|
72
|
+
if (!Array.isArray(mat) || !mat.length) return [];
|
|
73
|
+
const rows = mat as unknown[][];
|
|
74
|
+
const h = rows.length;
|
|
75
|
+
const w = Array.isArray(rows[0]) ? rows[0].length : 0;
|
|
76
|
+
const out: number[][] = Array.from({ length: w }, () =>
|
|
77
|
+
Array.from({ length: h }, () => 0),
|
|
78
|
+
);
|
|
79
|
+
for (let y = 0; y < h; y++) {
|
|
80
|
+
const row = rows[y];
|
|
81
|
+
if (!Array.isArray(row)) continue;
|
|
82
|
+
for (let x = 0; x < w; x++) {
|
|
83
|
+
out[x][h - 1 - y] = Number(row[x]) || 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function registerInteractiveHelpers(expression: Expression): void {
|
|
90
|
+
expression.registerFunction("rand", rand);
|
|
91
|
+
expression.registerFunction("randInt", randInt);
|
|
92
|
+
expression.registerFunction("clamp", clamp);
|
|
93
|
+
expression.registerFunction("range", range);
|
|
94
|
+
expression.registerFunction("set", immutableSet);
|
|
95
|
+
expression.registerFunction("matrix", matrix);
|
|
96
|
+
expression.registerFunction("rotate", rotate);
|
|
97
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Addon interactivity déclarative (stores, inputs, matrix).
|
|
3
|
+
* Opt-in : `@supersoniks/concorde/interactive`
|
|
4
|
+
*/
|
|
5
|
+
export {
|
|
6
|
+
dispatch,
|
|
7
|
+
getStore,
|
|
8
|
+
listStoreIds,
|
|
9
|
+
type SonicActionMessage,
|
|
10
|
+
} from "./registry";
|
|
11
|
+
export { SonicStore } from "./store";
|
|
12
|
+
export { SonicKeyboard } from "./keyboard";
|
|
13
|
+
export { SonicGamepad } from "./gamepad";
|
|
14
|
+
export { SonicGesture } from "./gesture";
|
|
15
|
+
export { SonicAction } from "./action";
|
|
16
|
+
export { SonicTicker } from "./ticker";
|
|
17
|
+
export { SonicMatrix } from "./matrix";
|
|
18
|
+
|
|
19
|
+
import "./store";
|
|
20
|
+
import "./keyboard";
|
|
21
|
+
import "./gamepad";
|
|
22
|
+
import "./gesture";
|
|
23
|
+
import "./action";
|
|
24
|
+
import "./ticker";
|
|
25
|
+
import "./matrix";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Interactive (SDUI)
|
|
2
|
+
|
|
3
|
+
Addon opt-in `@supersoniks/concorde/interactive` for **declarative** playable UIs under a strict CSP (no `eval`, no inline script, no `on*` handlers).
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
| Tag | Role |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `sonic-store` | State + JSONata reducer (`$state`, `$action`, `$env`) |
|
|
10
|
+
| `sonic-keyboard` | Keymap → actions |
|
|
11
|
+
| `sonic-gamepad` | Standard gamepad → actions |
|
|
12
|
+
| `sonic-gesture` | Tap / swipe / long-press |
|
|
13
|
+
| `sonic-action` | Click / hold-repeat → action |
|
|
14
|
+
| `sonic-ticker` | Clock `tick` with `dt` |
|
|
15
|
+
| `sonic-matrix` | 2D grid canvas from DataProvider |
|
|
16
|
+
|
|
17
|
+
Also: `sonic-if` accepts `dataProvider` + `key` + `equals`/`not`/`truthy`/`gt`/`lt` for SDUI. `sonic-value` accepts `format="00000"` or `format="intl:fr-FR"`.
|
|
18
|
+
|
|
19
|
+
## Reducer purity
|
|
20
|
+
|
|
21
|
+
Injected: `$rand`, `$randInt`, `$clamp`, `$range`, `$set`, `$matrix`, `$rotate`.
|
|
22
|
+
`$random` and `$now` throw — use `$rand(seed)` and `$action.t`.
|
|
23
|
+
|
|
24
|
+
## CDN
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<script src="concorde-core.bundle.js"></script>
|
|
28
|
+
<script src="concorde-interactive.bundle.js"></script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Out of scope (this pass)
|
|
32
|
+
|
|
33
|
+
Declarative sound, multiplayer, persistence.
|