@supersoniks/concorde 2.0.7 → 3.0.1
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/build-infos.json +1 -0
- package/concorde-core.bundle.js +387 -344
- package/concorde-core.es.js +8040 -11093
- package/index.html +44 -0
- package/notes de migration.md +21 -0
- package/package.json +23 -290
- package/scripts/postbuild.mjs +22 -0
- package/scripts/prebuild.mjs +22 -0
- package/{components.js → src/components.ts} +5 -2
- package/src/concorde-loaded.ts +3 -0
- package/src/core/_types/types.ts +55 -0
- package/src/core/components/functional/date/date.md +290 -0
- package/src/core/components/functional/date/date.ts +206 -0
- package/src/core/components/functional/example/example.ts +11 -0
- package/src/core/components/functional/fetch/fetch.md +117 -0
- package/{core/components/functional/fetch/fetch.js → src/core/components/functional/fetch/fetch.ts} +33 -37
- package/src/core/components/functional/if/if.md +16 -0
- package/src/core/components/functional/if/if.test.ts +40 -0
- package/src/core/components/functional/if/if.ts +23 -0
- package/src/core/components/functional/list/list.md +194 -0
- package/src/core/components/functional/list/list.ts +236 -0
- package/src/core/components/functional/mix/mix.md +41 -0
- package/src/core/components/functional/mix/mix.ts +95 -0
- package/src/core/components/functional/queue/queue.md +87 -0
- package/src/core/components/functional/queue/queue.ts +279 -0
- package/src/core/components/functional/router/redirect.ts +44 -0
- package/src/core/components/functional/router/router.md +112 -0
- package/src/core/components/functional/router/router.ts +108 -0
- package/src/core/components/functional/sdui/SDUIDescriptorTransformer.ts +229 -0
- package/{core → src/core}/components/functional/sdui/default-library.json +13 -13
- package/src/core/components/functional/sdui/example.json +99 -0
- package/src/core/components/functional/sdui/sdui-utils.ts +62 -0
- package/src/core/components/functional/sdui/sdui.md +356 -0
- package/src/core/components/functional/sdui/sdui.ts +230 -0
- package/src/core/components/functional/sdui/types.ts +34 -0
- package/src/core/components/functional/sonic-scope/sonic-scope.ts +13 -0
- package/src/core/components/functional/states/states.md +87 -0
- package/src/core/components/functional/states/states.ts +121 -0
- package/src/core/components/functional/submit/submit.md +48 -0
- package/src/core/components/functional/submit/submit.ts +265 -0
- package/src/core/components/functional/subscriber/subscriber.md +91 -0
- package/src/core/components/functional/subscriber/subscriber.ts +28 -0
- package/src/core/components/functional/value/value.md +35 -0
- package/src/core/components/functional/value/value.ts +18 -0
- package/{core/components/ui/_css/scroll.js → src/core/components/ui/_css/scroll.ts} +3 -2
- package/{core/components/ui/_css/size.js → src/core/components/ui/_css/size.ts} +5 -2
- package/{core/components/ui/_css/type.js → src/core/components/ui/_css/type.ts} +5 -3
- package/src/core/components/ui/alert/alert.md +121 -0
- package/src/core/components/ui/alert/alert.ts +177 -0
- package/src/core/components/ui/badge/badge.md +102 -0
- package/{core/components/ui/badge/badge.js → src/core/components/ui/badge/badge.ts} +36 -51
- package/src/core/components/ui/button/button.md +184 -0
- package/{core/components/ui/button/button.js → src/core/components/ui/button/button.ts} +258 -302
- package/src/core/components/ui/captcha/captcha.md +12 -0
- package/src/core/components/ui/captcha/captcha.ts +88 -0
- package/src/core/components/ui/card/card-footer.ts +19 -0
- package/src/core/components/ui/card/card-header-descripton.ts +24 -0
- package/{core/components/ui/card/card-header.js → src/core/components/ui/card/card-header.ts} +28 -38
- package/src/core/components/ui/card/card-main.ts +24 -0
- package/src/core/components/ui/card/card.md +96 -0
- package/{core/components/ui/card/card.js → src/core/components/ui/card/card.ts} +23 -34
- package/src/core/components/ui/divider/divider.md +35 -0
- package/{core/components/ui/divider/divider.js → src/core/components/ui/divider/divider.ts} +35 -65
- package/src/core/components/ui/form/checkbox/checkbox.md +96 -0
- package/{core/components/ui/form/checkbox/checkbox.js → src/core/components/ui/form/checkbox/checkbox.ts} +79 -98
- package/{core/components/ui/form/css/form-control.js → src/core/components/ui/form/css/form-control.ts} +9 -5
- package/src/core/components/ui/form/fieldset/fieldset.md +129 -0
- package/src/core/components/ui/form/fieldset/fieldset.ts +96 -0
- package/src/core/components/ui/form/fieldset/legend-description.ts +23 -0
- package/src/core/components/ui/form/fieldset/legend.ts +90 -0
- package/src/core/components/ui/form/form-actions/form-actions.md +77 -0
- package/src/core/components/ui/form/form-actions/form-actions.ts +32 -0
- package/src/core/components/ui/form/form-layout/form-layout.md +43 -0
- package/src/core/components/ui/form/form-layout/form-layout.ts +71 -0
- package/src/core/components/ui/form/input/input.md +168 -0
- package/src/core/components/ui/form/input/input.ts +227 -0
- package/src/core/components/ui/form/input/password-helper.ts +68 -0
- package/src/core/components/ui/form/input/same-value-helper.ts +48 -0
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +130 -0
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.ts +285 -0
- package/src/core/components/ui/form/radio/radio.md +86 -0
- package/src/core/components/ui/form/radio/radio.ts +44 -0
- package/src/core/components/ui/form/select/select.md +99 -0
- package/src/core/components/ui/form/select/select.ts +310 -0
- package/src/core/components/ui/form/textarea/textarea.md +66 -0
- package/src/core/components/ui/form/textarea/textarea.ts +119 -0
- package/src/core/components/ui/group/group.md +75 -0
- package/src/core/components/ui/group/group.ts +101 -0
- package/src/core/components/ui/icon/icon.md +125 -0
- package/src/core/components/ui/icon/icon.stories.ts +100 -0
- package/src/core/components/ui/icon/icon.ts +106 -0
- package/src/core/components/ui/icon/icons.json +1 -0
- package/src/core/components/ui/icon/icons.ts +130 -0
- package/src/core/components/ui/icon/svgs/cancel.svg +3 -0
- package/src/core/components/ui/icon/svgs/check-circled-outline.svg +4 -0
- package/src/core/components/ui/icon/svgs/check.svg +3 -0
- package/src/core/components/ui/icon/svgs/emoji-puzzled.svg +1 -0
- package/src/core/components/ui/icon/svgs/info-empty.svg +5 -0
- package/src/core/components/ui/icon/svgs/loader.svg +1 -0
- package/src/core/components/ui/icon/svgs/minus-small.svg +3 -0
- package/src/core/components/ui/icon/svgs/more-horiz.svg +5 -0
- package/src/core/components/ui/icon/svgs/more-vert.svg +5 -0
- package/src/core/components/ui/icon/svgs/nav-arrow-down.svg +3 -0
- package/src/core/components/ui/icon/svgs/warning-circled-outline.svg +5 -0
- package/src/core/components/ui/image/image.md +107 -0
- package/src/core/components/ui/image/image.ts +117 -0
- package/src/core/components/ui/link/link.md +43 -0
- package/src/core/components/ui/link/link.ts +108 -0
- package/src/core/components/ui/loader/loader.md +37 -0
- package/src/core/components/ui/loader/loader.stories.ts +25 -0
- package/src/core/components/ui/loader/loader.ts +81 -0
- package/{core/components/ui/loader/styles/fixed.js → src/core/components/ui/loader/styles/fixed.ts} +2 -1
- package/{core/components/ui/loader/styles/inline.js → src/core/components/ui/loader/styles/inline.ts} +3 -2
- package/src/core/components/ui/menu/menu-item.ts +30 -0
- package/src/core/components/ui/menu/menu.md +288 -0
- package/src/core/components/ui/menu/menu.ts +292 -0
- package/src/core/components/ui/modal/modal-actions.ts +35 -0
- package/src/core/components/ui/modal/modal-close.ts +36 -0
- package/src/core/components/ui/modal/modal-content.ts +19 -0
- package/src/core/components/ui/modal/modal-subtitle.ts +23 -0
- package/src/core/components/ui/modal/modal-title.ts +22 -0
- package/src/core/components/ui/modal/modal.md +123 -0
- package/src/core/components/ui/modal/modal.stories.ts +140 -0
- package/src/core/components/ui/modal/modal.ts +386 -0
- package/src/core/components/ui/pop/pop.md +79 -0
- package/src/core/components/ui/pop/pop.ts +291 -0
- package/src/core/components/ui/progress/progress.md +65 -0
- package/{core/components/ui/progress/progress.js → src/core/components/ui/progress/progress.ts} +31 -50
- package/src/core/components/ui/table/table-caption.ts +21 -0
- package/src/core/components/ui/table/table-tbody.ts +32 -0
- package/src/core/components/ui/table/table-td.ts +47 -0
- package/src/core/components/ui/table/table-tfoot.ts +20 -0
- package/src/core/components/ui/table/table-th.ts +56 -0
- package/src/core/components/ui/table/table-thead.ts +18 -0
- package/src/core/components/ui/table/table-tr.ts +48 -0
- package/src/core/components/ui/table/table.md +467 -0
- package/{core/components/ui/table/table.js → src/core/components/ui/table/table.ts} +32 -53
- package/{core/components/ui/theme/theme-collection/core-variables.js → src/core/components/ui/theme/theme-collection/core-variables.ts} +3 -2
- package/{core/components/ui/theme/theme-collection/dark.js → src/core/components/ui/theme/theme-collection/dark.ts} +5 -3
- package/{core/components/ui/theme/theme-collection/light.js → src/core/components/ui/theme/theme-collection/light.ts} +3 -2
- package/src/core/components/ui/theme/theme.ts +118 -0
- package/src/core/components/ui/toast/message-subscriber.stories.ts +43 -0
- package/src/core/components/ui/toast/message-subscriber.ts +37 -0
- package/{core/components/ui/toast/toast-item.js → src/core/components/ui/toast/toast-item.ts} +86 -113
- package/src/core/components/ui/toast/toast.ts +237 -0
- package/src/core/components/ui/toast/types.ts +14 -0
- package/src/core/components/ui/tooltip/tooltip.md +37 -0
- package/{core/components/ui/tooltip/tooltip.js → src/core/components/ui/tooltip/tooltip.ts} +26 -47
- package/{core/components/ui/ui.js → src/core/components/ui/ui.ts} +2 -0
- package/src/core/core.ts +22 -0
- package/src/core/decorators/Subscriber.ts +187 -0
- package/src/core/directives/DataProvider.ts +113 -0
- package/src/core/directives/Wording.ts +220 -0
- package/src/core/mixins/Fetcher.ts +258 -0
- package/src/core/mixins/FormCheckable.ts +287 -0
- package/src/core/mixins/FormElement.ts +275 -0
- package/src/core/mixins/FormInput.ts +135 -0
- package/src/core/mixins/Subscriber.ts +352 -0
- package/src/core/mixins/TemplatesContainer.ts +70 -0
- package/{core/mixins/mixins.d.ts → src/core/mixins/mixins.ts} +1 -1
- package/src/core/utils/Arrays.ts +161 -0
- package/src/core/utils/DataBindObserver.ts +286 -0
- package/src/core/utils/Electron.ts +15 -0
- package/src/core/utils/Format.ts +58 -0
- package/src/core/utils/HTML.ts +126 -0
- package/src/core/utils/LocationHandler.ts +139 -0
- package/src/core/utils/Objects.ts +103 -0
- package/src/core/utils/PublisherProxy.ts +786 -0
- package/src/core/utils/Utils.ts +12 -0
- package/src/core/utils/api.ts +456 -0
- package/{core/utils/url-pattern.d.ts → src/core/utils/url-pattern.ts} +1 -0
- package/{decorators.js → src/decorators.ts} +6 -2
- package/{directives.js → src/directives.ts} +11 -6
- package/src/docs/_core-concept/overview.md +57 -0
- package/src/docs/_core-concept/subscriber.md +76 -0
- package/src/docs/_getting-started/concorde-outside.md +141 -0
- package/src/docs/_getting-started/create-a-component.md +137 -0
- package/src/docs/_getting-started/pubsub.md +150 -0
- package/src/docs/_getting-started/start.md +37 -0
- package/src/docs/_getting-started/theming.md +91 -0
- package/src/docs/code.ts +281 -0
- package/src/docs/docs.ts +6 -0
- package/src/docs/example/users.ts +64 -0
- package/src/docs/navigation/navigation.ts +101 -0
- package/src/docs/prism/index.ts +6 -0
- package/src/docs/prism/prism.css +158 -0
- package/src/docs/prism/prism.js +1022 -0
- package/src/docs/search/docs-search.json +3767 -0
- package/src/docs/search/markdown-renderer.ts +40 -0
- package/src/docs/search/page.ts +40 -0
- package/src/docs/search/search.ts +184 -0
- package/src/docs.ts +2 -0
- package/src/index.ts +7 -0
- package/{mixins.js → src/mixins.ts} +10 -6
- package/src/tag-list.json +1 -0
- package/src/test-utils/TestUtils.ts +13 -0
- package/src/tsconfig.json +113 -0
- package/{utils.js → src/utils.ts} +15 -11
- package/test-utils/TestUtils.ts +13 -0
- package/vite/config.js +136 -0
- package/vite.config.mts +87 -0
- package/README.md +0 -27
- package/cli.js +0 -75
- package/components.d.ts +0 -4
- package/core/_types/types.d.ts +0 -28
- package/core/_types/types.js +0 -2
- package/core/components/functional/date/date.d.ts +0 -45
- package/core/components/functional/date/date.js +0 -243
- package/core/components/functional/example/example.d.ts +0 -7
- package/core/components/functional/example/example.js +0 -26
- package/core/components/functional/fetch/fetch.d.ts +0 -93
- package/core/components/functional/functional.js +0 -15
- package/core/components/functional/if/if.d.ts +0 -12
- package/core/components/functional/if/if.js +0 -38
- package/core/components/functional/if/if.test.d.ts +0 -1
- package/core/components/functional/if/if.test.js +0 -35
- package/core/components/functional/list/list.d.ts +0 -117
- package/core/components/functional/list/list.js +0 -214
- package/core/components/functional/mix/mix.d.ts +0 -22
- package/core/components/functional/mix/mix.js +0 -102
- package/core/components/functional/queue/queue.d.ts +0 -67
- package/core/components/functional/queue/queue.js +0 -310
- package/core/components/functional/router/redirect.d.ts +0 -18
- package/core/components/functional/router/redirect.js +0 -53
- package/core/components/functional/router/router.d.ts +0 -27
- package/core/components/functional/router/router.js +0 -119
- package/core/components/functional/sdui/SDUIDescriptorTransformer.d.ts +0 -58
- package/core/components/functional/sdui/SDUIDescriptorTransformer.js +0 -215
- package/core/components/functional/sdui/sdui-utils.d.ts +0 -5
- package/core/components/functional/sdui/sdui-utils.js +0 -63
- package/core/components/functional/sdui/sdui.d.ts +0 -136
- package/core/components/functional/sdui/sdui.js +0 -254
- package/core/components/functional/sdui/types.d.ts +0 -37
- package/core/components/functional/sdui/types.js +0 -1
- package/core/components/functional/sonic-scope/sonic-scope.d.ts +0 -5
- package/core/components/functional/sonic-scope/sonic-scope.js +0 -21
- package/core/components/functional/states/states.d.ts +0 -29
- package/core/components/functional/states/states.js +0 -134
- package/core/components/functional/submit/submit.d.ts +0 -30
- package/core/components/functional/submit/submit.js +0 -236
- package/core/components/functional/subscriber/subscriber.d.ts +0 -12
- package/core/components/functional/subscriber/subscriber.js +0 -38
- package/core/components/functional/value/value.d.ts +0 -7
- package/core/components/functional/value/value.js +0 -27
- package/core/components/ui/_css/scroll.d.ts +0 -1
- package/core/components/ui/_css/size.d.ts +0 -2
- package/core/components/ui/_css/type.d.ts +0 -2
- package/core/components/ui/alert/alert.d.ts +0 -34
- package/core/components/ui/alert/alert.js +0 -202
- package/core/components/ui/badge/badge.d.ts +0 -26
- package/core/components/ui/button/button.d.ts +0 -171
- package/core/components/ui/captcha/captcha.d.ts +0 -30
- package/core/components/ui/captcha/captcha.js +0 -93
- package/core/components/ui/card/card-footer.d.ts +0 -4
- package/core/components/ui/card/card-footer.js +0 -24
- package/core/components/ui/card/card-header-descripton.d.ts +0 -5
- package/core/components/ui/card/card-header-descripton.js +0 -32
- package/core/components/ui/card/card-header.d.ts +0 -8
- package/core/components/ui/card/card-main.d.ts +0 -4
- package/core/components/ui/card/card-main.js +0 -28
- package/core/components/ui/card/card.d.ts +0 -12
- package/core/components/ui/divider/divider.d.ts +0 -15
- package/core/components/ui/form/checkbox/checkbox.d.ts +0 -181
- package/core/components/ui/form/css/form-control.d.ts +0 -4
- package/core/components/ui/form/fieldset/fieldset.d.ts +0 -23
- package/core/components/ui/form/fieldset/fieldset.js +0 -118
- package/core/components/ui/form/fieldset/legend-description.d.ts +0 -5
- package/core/components/ui/form/fieldset/legend-description.js +0 -30
- package/core/components/ui/form/fieldset/legend.d.ts +0 -16
- package/core/components/ui/form/fieldset/legend.js +0 -112
- package/core/components/ui/form/form-actions/form-actions.d.ts +0 -7
- package/core/components/ui/form/form-actions/form-actions.js +0 -46
- package/core/components/ui/form/form-layout/form-layout.d.ts +0 -12
- package/core/components/ui/form/form-layout/form-layout.js +0 -83
- package/core/components/ui/form/input/input.d.ts +0 -106
- package/core/components/ui/form/input/input.js +0 -268
- package/core/components/ui/form/input/password-helper.d.ts +0 -25
- package/core/components/ui/form/input/password-helper.js +0 -119
- package/core/components/ui/form/input/same-value-helper.d.ts +0 -16
- package/core/components/ui/form/input/same-value-helper.js +0 -77
- package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +0 -136
- package/core/components/ui/form/input-autocomplete/input-autocomplete.js +0 -296
- package/core/components/ui/form/radio/radio.d.ts +0 -12
- package/core/components/ui/form/radio/radio.js +0 -50
- package/core/components/ui/form/select/select.d.ts +0 -58
- package/core/components/ui/form/select/select.js +0 -298
- package/core/components/ui/form/textarea/textarea.d.ts +0 -84
- package/core/components/ui/form/textarea/textarea.js +0 -150
- package/core/components/ui/group/group.d.ts +0 -16
- package/core/components/ui/group/group.js +0 -118
- package/core/components/ui/icon/icon.d.ts +0 -26
- package/core/components/ui/icon/icon.js +0 -113
- package/core/components/ui/icon/icons.d.ts +0 -10
- package/core/components/ui/icon/icons.js +0 -126
- package/core/components/ui/icon/icons.json +0 -1
- package/core/components/ui/image/image.d.ts +0 -15
- package/core/components/ui/image/image.js +0 -153
- package/core/components/ui/link/link.d.ts +0 -29
- package/core/components/ui/link/link.js +0 -124
- package/core/components/ui/loader/loader.d.ts +0 -23
- package/core/components/ui/loader/loader.js +0 -97
- package/core/components/ui/loader/styles/fixed.d.ts +0 -1
- package/core/components/ui/loader/styles/inline.d.ts +0 -1
- package/core/components/ui/menu/menu-item.d.ts +0 -5
- package/core/components/ui/menu/menu-item.js +0 -34
- package/core/components/ui/menu/menu.d.ts +0 -41
- package/core/components/ui/menu/menu.js +0 -313
- package/core/components/ui/modal/modal-actions.d.ts +0 -7
- package/core/components/ui/modal/modal-actions.js +0 -42
- package/core/components/ui/modal/modal-close.d.ts +0 -7
- package/core/components/ui/modal/modal-close.js +0 -43
- package/core/components/ui/modal/modal-content.d.ts +0 -5
- package/core/components/ui/modal/modal-content.js +0 -26
- package/core/components/ui/modal/modal-subtitle.d.ts +0 -5
- package/core/components/ui/modal/modal-subtitle.js +0 -30
- package/core/components/ui/modal/modal-title.d.ts +0 -5
- package/core/components/ui/modal/modal-title.js +0 -29
- package/core/components/ui/modal/modal.d.ts +0 -58
- package/core/components/ui/modal/modal.js +0 -401
- package/core/components/ui/pop/pop.d.ts +0 -37
- package/core/components/ui/pop/pop.js +0 -299
- package/core/components/ui/progress/progress.d.ts +0 -10
- package/core/components/ui/table/table-caption.d.ts +0 -5
- package/core/components/ui/table/table-caption.js +0 -28
- package/core/components/ui/table/table-tbody.d.ts +0 -5
- package/core/components/ui/table/table-tbody.js +0 -39
- package/core/components/ui/table/table-td.d.ts +0 -12
- package/core/components/ui/table/table-td.js +0 -68
- package/core/components/ui/table/table-tfoot.d.ts +0 -5
- package/core/components/ui/table/table-tfoot.js +0 -27
- package/core/components/ui/table/table-th.d.ts +0 -11
- package/core/components/ui/table/table-th.js +0 -73
- package/core/components/ui/table/table-thead.d.ts +0 -5
- package/core/components/ui/table/table-thead.js +0 -25
- package/core/components/ui/table/table-tr.d.ts +0 -13
- package/core/components/ui/table/table-tr.js +0 -66
- package/core/components/ui/table/table.d.ts +0 -17
- package/core/components/ui/theme/theme-collection/core-variables.d.ts +0 -1
- package/core/components/ui/theme/theme-collection/dark.d.ts +0 -1
- package/core/components/ui/theme/theme-collection/light.d.ts +0 -1
- package/core/components/ui/theme/theme.d.ts +0 -19
- package/core/components/ui/theme/theme.js +0 -124
- package/core/components/ui/toast/message-subscriber.d.ts +0 -18
- package/core/components/ui/toast/message-subscriber.js +0 -40
- package/core/components/ui/toast/toast-item.d.ts +0 -19
- package/core/components/ui/toast/toast.d.ts +0 -25
- package/core/components/ui/toast/toast.js +0 -226
- package/core/components/ui/toast/types.d.ts +0 -11
- package/core/components/ui/toast/types.js +0 -1
- package/core/components/ui/tooltip/tooltip.d.ts +0 -10
- package/core/components/ui/ui.d.ts +0 -32
- package/core/core.d.ts +0 -4
- package/core/core.js +0 -19
- package/core/decorators/Subscriber.d.ts +0 -4
- package/core/decorators/Subscriber.js +0 -166
- package/core/directives/DataProvider.d.ts +0 -23
- package/core/directives/DataProvider.js +0 -102
- package/core/directives/Wording.d.ts +0 -42
- package/core/directives/Wording.js +0 -202
- package/core/mixins/Fetcher.d.ts +0 -90
- package/core/mixins/Fetcher.js +0 -242
- package/core/mixins/FormCheckable.d.ts +0 -88
- package/core/mixins/FormCheckable.js +0 -306
- package/core/mixins/FormElement.d.ts +0 -32
- package/core/mixins/FormElement.js +0 -272
- package/core/mixins/FormInput.d.ts +0 -70
- package/core/mixins/FormInput.js +0 -81
- package/core/mixins/Subscriber.d.ts +0 -36
- package/core/mixins/Subscriber.js +0 -333
- package/core/mixins/TemplatesContainer.d.ts +0 -13
- package/core/mixins/TemplatesContainer.js +0 -69
- package/core/mixins/mixins.js +0 -6
- package/core/utils/Arrays.d.ts +0 -97
- package/core/utils/Arrays.js +0 -140
- package/core/utils/DataBindObserver.d.ts +0 -83
- package/core/utils/DataBindObserver.js +0 -264
- package/core/utils/Electron.d.ts +0 -7
- package/core/utils/Electron.js +0 -11
- package/core/utils/Format.d.ts +0 -12
- package/core/utils/Format.js +0 -38
- package/core/utils/HTML.d.ts +0 -42
- package/core/utils/HTML.js +0 -119
- package/core/utils/LocationHandler.d.ts +0 -46
- package/core/utils/LocationHandler.js +0 -133
- package/core/utils/Objects.d.ts +0 -28
- package/core/utils/Objects.js +0 -102
- package/core/utils/PublisherProxy.d.ts +0 -176
- package/core/utils/PublisherProxy.js +0 -709
- package/core/utils/Utils.d.ts +0 -4
- package/core/utils/Utils.js +0 -12
- package/core/utils/api.d.ts +0 -139
- package/core/utils/api.js +0 -391
- package/core/utils/url-pattern.js +0 -2
- package/decorators.d.ts +0 -3
- package/directives.d.ts +0 -40
- package/img/concorde-logo.svg +0 -1
- package/img/concorde.png +0 -0
- package/img/concorde_def.png +0 -0
- package/mixins.d.ts +0 -181
- package/svg/regular/plane.svg +0 -1
- package/svg/solid/plane.svg +0 -1
- package/test-utils/TestUtils.d.ts +0 -4
- package/test-utils/TestUtils.js +0 -12
- package/utils.d.ts +0 -20
- /package/{core/components/functional/functional.d.ts → src/core/components/functional/functional.ts} +0 -0
- /package/{core → src/core}/components/ui/theme/css/tailwind.css +0 -0
- /package/{core → src/core}/components/ui/theme/css/tailwind.d.ts +0 -0
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any*/
|
|
2
|
+
/**
|
|
3
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
4
|
+
* Merci de laisser ce fichier sans la moindre dépendance en dehors de types du ceur.
|
|
5
|
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
6
|
+
* **/
|
|
7
|
+
import {
|
|
8
|
+
PublisherInterface,
|
|
9
|
+
CoreJSType,
|
|
10
|
+
PublisherContentType,
|
|
11
|
+
} from "../_types/types";
|
|
12
|
+
import HTML from "./HTML";
|
|
13
|
+
type DynamicFillingListener = any;
|
|
14
|
+
type TemplateFillingListener = {
|
|
15
|
+
propertyMap: Record<string, string>;
|
|
16
|
+
} & DynamicFillingListener;
|
|
17
|
+
function isComplex(value: any) {
|
|
18
|
+
return typeof value === "object" && value != null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const queueTaskPromise = async () => {
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
window.queueMicrotask(() => resolve(null));
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Custom Proxy contient les méthodes des publishers retournés par PublisherManager.get(publisherId) qui seront utilisées couramment
|
|
29
|
+
*/
|
|
30
|
+
export class PublisherProxy<T = any> {
|
|
31
|
+
static instances = new Map<number, PublisherProxy>();
|
|
32
|
+
static instancesCounter = 0;
|
|
33
|
+
_proxies_: Map<string, PublisherProxy> = new Map();
|
|
34
|
+
_value_: T;
|
|
35
|
+
_is_savable_ = false;
|
|
36
|
+
_invalidateListeners_ = new Set<VoidFunction>();
|
|
37
|
+
_assignListeners_ = new Set<(value: T) => void>();
|
|
38
|
+
_mutationListeners_ = new Set<VoidFunction>();
|
|
39
|
+
_fillListeners_ = new Set<Record<string, CoreJSType>>();
|
|
40
|
+
_templateFillListeners_ = new Set<TemplateFillingListener>();
|
|
41
|
+
_lockInternalMutationPublishing_ = false;
|
|
42
|
+
_instanceCounter_ = 0;
|
|
43
|
+
parent: PublisherProxy | null;
|
|
44
|
+
root: PublisherProxy;
|
|
45
|
+
|
|
46
|
+
constructor(target: T, parentProxPub: PublisherProxy | null) {
|
|
47
|
+
this._value_ = target;
|
|
48
|
+
this.parent = parentProxPub || null;
|
|
49
|
+
this.root = this;
|
|
50
|
+
this._instanceCounter_ = 0;
|
|
51
|
+
while (this.root.parent) {
|
|
52
|
+
this.root = this.root.parent;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Supprime le proxy et ses sous proxy
|
|
57
|
+
* Supprime les écouteurs associés
|
|
58
|
+
*/
|
|
59
|
+
delete() {
|
|
60
|
+
for (const proxy of this._proxies_.values()) {
|
|
61
|
+
proxy.delete();
|
|
62
|
+
}
|
|
63
|
+
this._invalidateListeners_.clear();
|
|
64
|
+
this._assignListeners_.clear();
|
|
65
|
+
this._mutationListeners_.clear();
|
|
66
|
+
this._fillListeners_.clear();
|
|
67
|
+
this._templateFillListeners_.clear();
|
|
68
|
+
this._proxies_.clear();
|
|
69
|
+
PublisherProxy.instances.delete(this._instanceCounter_);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Utile pour savoir si quelque chose est en écoute d'une modification sur le proxy via une des methodes associées
|
|
73
|
+
*/
|
|
74
|
+
hasListener() {
|
|
75
|
+
return (
|
|
76
|
+
this._templateFillListeners_.size > 0 ||
|
|
77
|
+
this._assignListeners_.size > 0 ||
|
|
78
|
+
this._invalidateListeners_.size > 0 ||
|
|
79
|
+
this._mutationListeners_.size > 0 ||
|
|
80
|
+
this._fillListeners_.size > 0
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
_assignmentId_ = 0;
|
|
84
|
+
_publishInternalMutation_(lockInternalMutationsTransmission = false) {
|
|
85
|
+
this._mutationListeners_.forEach((handler: VoidFunction): void =>
|
|
86
|
+
handler()
|
|
87
|
+
);
|
|
88
|
+
if (this._is_savable_ && !PublisherManager.changed) {
|
|
89
|
+
PublisherManager.changed = true;
|
|
90
|
+
PublisherManager.saveId++;
|
|
91
|
+
const saveId = PublisherManager.saveId;
|
|
92
|
+
setTimeout(
|
|
93
|
+
() => PublisherManager.getInstance().saveToLocalStorage(saveId),
|
|
94
|
+
1000
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
if (lockInternalMutationsTransmission) return;
|
|
98
|
+
if (this.parent) {
|
|
99
|
+
this.parent._publishInternalMutation_();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async _publishAssignement_(lockInternalMutationsTransmission = false) {
|
|
103
|
+
this._assignmentId_++;
|
|
104
|
+
const currentId = this._assignmentId_;
|
|
105
|
+
await queueTaskPromise();
|
|
106
|
+
if (currentId !== this._assignmentId_) return;
|
|
107
|
+
const newValue = this.get();
|
|
108
|
+
this._assignListeners_.forEach((handler: (value: T) => void) =>
|
|
109
|
+
handler(newValue)
|
|
110
|
+
);
|
|
111
|
+
this._publishInternalMutation_(lockInternalMutationsTransmission);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_publishInvalidation_() {
|
|
115
|
+
this._invalidateListeners_.forEach((handler: VoidFunction) => handler());
|
|
116
|
+
}
|
|
117
|
+
_publishDynamicFilling_(key: string, value: CoreJSType) {
|
|
118
|
+
this._fillListeners_.forEach((handler) => {
|
|
119
|
+
if (handler[key] !== value) handler[key] = value;
|
|
120
|
+
});
|
|
121
|
+
this._publishTemplateFilling_(key, value);
|
|
122
|
+
}
|
|
123
|
+
_publishTemplateFilling_(key: string, value: CoreJSType) {
|
|
124
|
+
this._templateFillListeners_.forEach((handler) => {
|
|
125
|
+
const desc = Object.getOwnPropertyDescriptor(handler, key);
|
|
126
|
+
|
|
127
|
+
if (desc && !desc.set && !desc.writable) return;
|
|
128
|
+
|
|
129
|
+
if (handler.propertyMap && handler.propertyMap[key]) {
|
|
130
|
+
key = handler.propertyMap[key];
|
|
131
|
+
}
|
|
132
|
+
if (typeof handler[key] != "undefined" && handler[key] !== value) {
|
|
133
|
+
handler[key] = value;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Appel la fonction "handler" (passée en paramettre) lorsque la valeur gérée par le proxy change par assignation
|
|
140
|
+
* hanlder reçois alors la nouvelle valeur interne du proxy en paramètre
|
|
141
|
+
*/
|
|
142
|
+
onAssign(handler: (value: T) => void, directHandlerCall = true) {
|
|
143
|
+
if (typeof handler != "function") return;
|
|
144
|
+
if (this._assignListeners_.has(handler)) return;
|
|
145
|
+
this._assignListeners_.add(handler);
|
|
146
|
+
if (directHandlerCall) handler(this.get());
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Stop les appels de la fonction "handler" (passée en paramettre) lorsque la valeur gérée par le proxy change par assignation
|
|
150
|
+
*/
|
|
151
|
+
offAssign(handler: (value: T) => void) {
|
|
152
|
+
this._assignListeners_.delete(handler);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Appel la fonction "handler" (passée en paramettre) lorsque la donnée est flaggée comme invalide
|
|
157
|
+
*/
|
|
158
|
+
onInvalidate(handler: VoidFunction | undefined) {
|
|
159
|
+
if (typeof handler != "function") return;
|
|
160
|
+
this._invalidateListeners_.add(handler);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Stop les appels de la fonction "handler" (passée en paramettre) lorsque la donnée est flaggée comme invalide
|
|
164
|
+
*/
|
|
165
|
+
offInvalidate(handler: VoidFunction | undefined) {
|
|
166
|
+
if (typeof handler != "function") return;
|
|
167
|
+
this._invalidateListeners_.delete(handler);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Flag les données comme étant invalides
|
|
171
|
+
*/
|
|
172
|
+
invalidate() {
|
|
173
|
+
this._publishInvalidation_();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Appel la fonction "handler" (passée en paramettre) lorsque quelque chose change la valeur gérée par le proxy quelque soit la profondeur de la donnée
|
|
178
|
+
*
|
|
179
|
+
*/
|
|
180
|
+
onInternalMutation(handler: VoidFunction | undefined) {
|
|
181
|
+
if (typeof handler != "function") return;
|
|
182
|
+
this._mutationListeners_.add(handler);
|
|
183
|
+
handler();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Stop les Appels de la fonction "handler" (passée en paramettre) lorsque quelque chose change la valeur gérée par le proxy quelque soit la profondeur de la donnée
|
|
187
|
+
*/
|
|
188
|
+
offInternalMutation(handler: VoidFunction | undefined) {
|
|
189
|
+
if (typeof handler != "function") return;
|
|
190
|
+
this._mutationListeners_.delete(handler);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Maintient le remplissage de l'objet / tableau "handler" passé en paramètre avec les valeurs du proxy
|
|
194
|
+
* Remplit uniquement les valeurs déjà présentes dans l'objet / tableau passé en paramètre
|
|
195
|
+
*/
|
|
196
|
+
startTemplateFilling(handler: TemplateFillingListener) {
|
|
197
|
+
this._templateFillListeners_.add(handler);
|
|
198
|
+
if (typeof this._value_ != "object") return;
|
|
199
|
+
for (const z in this._value_) {
|
|
200
|
+
let valueKey = z as string;
|
|
201
|
+
const value = this._value_[z];
|
|
202
|
+
if (handler.propertyMap && handler.propertyMap[z]) {
|
|
203
|
+
valueKey = handler.propertyMap[z];
|
|
204
|
+
}
|
|
205
|
+
if (typeof handler[z] != "undefined" && handler[z] !== value) {
|
|
206
|
+
handler[valueKey] = value;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Arrête de maintenir le remplissage de l'objet / tableau "handler" passé en paramètre avec les valeurs du proxy
|
|
213
|
+
*/
|
|
214
|
+
stopTemplateFilling(handler: TemplateFillingListener) {
|
|
215
|
+
this._templateFillListeners_.delete(handler);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Maintient le remplissage de l'objet / tableau "handler" passé en paramètre avec les valeurs du proxy
|
|
220
|
+
* Remplit toute valeur qu'elle soit présente ou pas initialement dans l'objet
|
|
221
|
+
*/
|
|
222
|
+
startDynamicFilling(handler: DynamicFillingListener) {
|
|
223
|
+
this._fillListeners_.add(handler);
|
|
224
|
+
for (const z in this._value_) {
|
|
225
|
+
const value = this._value_[z];
|
|
226
|
+
if (handler[z] !== value) handler[z] = value;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/*
|
|
230
|
+
* Arrête de maintenir le remplissage de l'objet / tableau "handler" passé en paramètre avec les valeurs du proxy
|
|
231
|
+
*/
|
|
232
|
+
stopDynamicFilling(handler: DynamicFillingListener) {
|
|
233
|
+
this._fillListeners_.delete(handler);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Assigne une nouvelle valeur au proxy ce qui déclenche la transmission de la donnée en fonction des "écouteurs" associés
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
async set(newValue: T, lockInternalMutationsTransmission = false) {
|
|
240
|
+
/**
|
|
241
|
+
* On retounre tout de suite si la valeur n'a pas changé
|
|
242
|
+
*/
|
|
243
|
+
if (this._value_ === newValue) return true;
|
|
244
|
+
|
|
245
|
+
if (
|
|
246
|
+
this._value_ &&
|
|
247
|
+
newValue &&
|
|
248
|
+
Object.prototype.hasOwnProperty.call(this._value_, "__value") &&
|
|
249
|
+
Object.prototype.hasOwnProperty.call(newValue, "__value") &&
|
|
250
|
+
(this._value_ as any).__value === (newValue as any).__value
|
|
251
|
+
) {
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* On assigne la nouvelle valeur
|
|
256
|
+
*/
|
|
257
|
+
const prevValue = this._value_ as any;
|
|
258
|
+
this._value_ = isComplex(newValue)
|
|
259
|
+
? newValue
|
|
260
|
+
: ({ __value: newValue } as any);
|
|
261
|
+
this._cachedGet_ = undefined;
|
|
262
|
+
/**
|
|
263
|
+
* Si il s'agit d'une valeur primitive (un entier, une chaine ) la valeure en renseignée par un objet contenant la vaeur {__value}
|
|
264
|
+
* On publie juste et on sen va.
|
|
265
|
+
*/
|
|
266
|
+
const isPrimitiveValue = Object.prototype.hasOwnProperty.call(
|
|
267
|
+
this._value_,
|
|
268
|
+
"__value"
|
|
269
|
+
);
|
|
270
|
+
if (isPrimitiveValue) {
|
|
271
|
+
await this._publishAssignement_(lockInternalMutationsTransmission);
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* On fait la diff sur l'existant.
|
|
276
|
+
* On maintient les proxys à supprimer et ceux à ajouter.
|
|
277
|
+
* On met à jour leur valeur interne
|
|
278
|
+
* On publie les maj au fur et a mesure de modifications
|
|
279
|
+
*/
|
|
280
|
+
for (const key in this._value_) {
|
|
281
|
+
if (this._value_[key] === undefined) delete this._value_[key];
|
|
282
|
+
}
|
|
283
|
+
this._proxies_.forEach((_subProxy, key) => {
|
|
284
|
+
/**
|
|
285
|
+
* On supprime les proxys qui ne sont plus dans la nouvelle valeur si ils n'on pas d'écouteurs
|
|
286
|
+
**/
|
|
287
|
+
if ((this._value_ as any)[key] === undefined) {
|
|
288
|
+
// if (!_subProxy?.hasListener()) {
|
|
289
|
+
// // this._proxies_.delete(key);
|
|
290
|
+
// } else {
|
|
291
|
+
if (key != "_parent_") {
|
|
292
|
+
if (prevValue[key]) (this._value_ as any)[key] = null;
|
|
293
|
+
}
|
|
294
|
+
// }
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
/**
|
|
298
|
+
* On prévient les écouteurs que la valeur a changé
|
|
299
|
+
*/
|
|
300
|
+
await this._publishAssignement_();
|
|
301
|
+
/**
|
|
302
|
+
* Si la donnée est complexe (objet, tableau)
|
|
303
|
+
* on crée les proxys pour les sous-éléments qui n'en on pas
|
|
304
|
+
* On renseigne les nouvelles valeurs internes des proxies
|
|
305
|
+
*/
|
|
306
|
+
|
|
307
|
+
if (isComplex(this._value_)) {
|
|
308
|
+
for (const key in this._value_) {
|
|
309
|
+
const v = newValue[key] as any;
|
|
310
|
+
const isVComplex = isComplex(v);
|
|
311
|
+
const valueV = isVComplex ? v : { __value: v };
|
|
312
|
+
if (!this._proxies_.has(key)) {
|
|
313
|
+
// A surveiller ancienne version
|
|
314
|
+
// const newPublisher = new Publisher({}, this);
|
|
315
|
+
// this._proxies_.set(key, newPublisher);
|
|
316
|
+
// newPublisher._proxies_.set("_parent_", this);
|
|
317
|
+
|
|
318
|
+
this._publishDynamicFilling_(key, v);
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
await this._proxies_.get(key)?.set(valueV, true);
|
|
322
|
+
this._publishDynamicFilling_(key, v);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Extraire la valeur actuelle du proxy
|
|
329
|
+
*/
|
|
330
|
+
_cachedGet_?: T;
|
|
331
|
+
get(): T {
|
|
332
|
+
if (this._cachedGet_ !== undefined) return this._cachedGet_;
|
|
333
|
+
if (PublisherManager.modifiedCollectore.length > 0)
|
|
334
|
+
PublisherManager.modifiedCollectore[0].add(this);
|
|
335
|
+
if (Object.prototype.hasOwnProperty.call(this._value_, "__value")) {
|
|
336
|
+
const v = (this._value_ as any).__value;
|
|
337
|
+
return (this._cachedGet_ = (v != undefined ? v : null) as T);
|
|
338
|
+
}
|
|
339
|
+
return (this._cachedGet_ = this._value_);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* retourner le webcomponent auquel le proxy est associé
|
|
343
|
+
*/
|
|
344
|
+
get $tag(): string {
|
|
345
|
+
if (!this._instanceCounter_) {
|
|
346
|
+
PublisherProxy.instancesCounter++;
|
|
347
|
+
this._instanceCounter_ = PublisherProxy.instancesCounter;
|
|
348
|
+
}
|
|
349
|
+
PublisherProxy.instances.set(this._instanceCounter_, this);
|
|
350
|
+
const str =
|
|
351
|
+
'<reactive-publisher-proxy publisher="' +
|
|
352
|
+
this._instanceCounter_ +
|
|
353
|
+
'"></reactive-publisher-proxy>';
|
|
354
|
+
return str;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Utilitaires de gestion des Publisher
|
|
360
|
+
* Obtenir, replacer ou supprimer un Publisher
|
|
361
|
+
*
|
|
362
|
+
*/
|
|
363
|
+
|
|
364
|
+
declare const __BUILD_DATE__: string;
|
|
365
|
+
if (typeof __BUILD_DATE__ === "undefined") {
|
|
366
|
+
(window as any).__BUILD_DATE__ = "No build date";
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export class PublisherManager {
|
|
370
|
+
static buildDate = __BUILD_DATE__;
|
|
371
|
+
static changed = false;
|
|
372
|
+
static saving = false;
|
|
373
|
+
static saveId = 0;
|
|
374
|
+
static instance: PublisherManager | null = null;
|
|
375
|
+
enabledLocaStorageProxies: string[] = [];
|
|
376
|
+
publishers = new Map<string, Publisher>();
|
|
377
|
+
localStorageData: Record<
|
|
378
|
+
string,
|
|
379
|
+
{ lastModifiationMS: number; data: PublisherContentType }
|
|
380
|
+
> = {};
|
|
381
|
+
isLocalStrorageReady: Promise<boolean> | null = null;
|
|
382
|
+
constructor() {
|
|
383
|
+
if (PublisherManager.instance != null) throw "Singleton / use getInstance";
|
|
384
|
+
PublisherManager.instance = this;
|
|
385
|
+
this.isLocalStrorageReady = this.cleanStorageData() as Promise<boolean>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
async cleanStorageData() {
|
|
389
|
+
return new Promise((resolve) => {
|
|
390
|
+
const doiIt = async () => {
|
|
391
|
+
try {
|
|
392
|
+
let compressedData = localStorage.getItem("publisher-proxies-data");
|
|
393
|
+
|
|
394
|
+
let localStorageJSON = null;
|
|
395
|
+
if (compressedData)
|
|
396
|
+
localStorageJSON = await this.decompress(compressedData, "gzip");
|
|
397
|
+
|
|
398
|
+
if (localStorageJSON) {
|
|
399
|
+
try {
|
|
400
|
+
this.localStorageData = JSON.parse(localStorageJSON);
|
|
401
|
+
} catch (e) {
|
|
402
|
+
this.localStorageData = {};
|
|
403
|
+
}
|
|
404
|
+
} else {
|
|
405
|
+
compressedData = await this.compress("{}", "gzip");
|
|
406
|
+
localStorage.setItem("publisher-proxies-data", compressedData);
|
|
407
|
+
this.localStorageData = {};
|
|
408
|
+
}
|
|
409
|
+
const expires = new Date().getTime() - 1000 * 60 * 60 * 12;
|
|
410
|
+
for (const key in this.localStorageData) {
|
|
411
|
+
const item = this.localStorageData[key];
|
|
412
|
+
if (item.lastModifiationMS < expires) {
|
|
413
|
+
delete this.localStorageData[key];
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
resolve(true);
|
|
417
|
+
// compressedData = await this.compress(JSON.stringify(this.localStorageData), "gzip");
|
|
418
|
+
// localStorage.setItem("publisher-proxies-data", compressedData);
|
|
419
|
+
} catch (e) {
|
|
420
|
+
window.requestAnimationFrame(() => {
|
|
421
|
+
resolve(false);
|
|
422
|
+
});
|
|
423
|
+
console.log("no publisher cache in this browser");
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
doiIt();
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* PublisherManager est un singleton
|
|
432
|
+
*/
|
|
433
|
+
static getInstance() {
|
|
434
|
+
if (PublisherManager.instance == null) return new PublisherManager();
|
|
435
|
+
return PublisherManager.instance;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* shortcut static pour obtenir un publisher vias sont id/adresse sans taper getInstance.
|
|
439
|
+
* Si le publisher n'existe pas, il est créé.
|
|
440
|
+
*/
|
|
441
|
+
public static get(id: string, options?: { localStorageMode?: string }) {
|
|
442
|
+
return PublisherManager.getInstance().get(id, options);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
public static modifiedCollectore: Set<PublisherProxy>[] = [];
|
|
446
|
+
public static collectModifiedPublisher() {
|
|
447
|
+
PublisherManager.modifiedCollectore.unshift(new Set());
|
|
448
|
+
}
|
|
449
|
+
public static getModifiedPublishers() {
|
|
450
|
+
return PublisherManager.modifiedCollectore.shift();
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* shortcut static pour supprimer un publisher de la liste et appel également delete sur le publisher ce qui le supprime, de même que ses sous publishers
|
|
455
|
+
*/
|
|
456
|
+
static delete(id: string | null) {
|
|
457
|
+
if (!id) return false;
|
|
458
|
+
return PublisherManager.getInstance().delete(id);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Obtenir un publisher vias sont id/adresse
|
|
463
|
+
* Si le publisher n'existe pas, il est créé.
|
|
464
|
+
*/
|
|
465
|
+
async setLocalData(publisher: PublisherInterface, id: string) {
|
|
466
|
+
await this.isLocalStrorageReady;
|
|
467
|
+
publisher.set(
|
|
468
|
+
this.localStorageData[id + "¤lang_" + HTML.getLanguage()]?.data ||
|
|
469
|
+
publisher.get()
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
initialisedData: string[] = [];
|
|
474
|
+
get(id: string, options?: { localStorageMode?: string }) {
|
|
475
|
+
const hasLocalStorage = options?.localStorageMode === "enabled";
|
|
476
|
+
if (!this.publishers.has(id)) {
|
|
477
|
+
const data = {};
|
|
478
|
+
const publisher = new Publisher(data) as PublisherInterface;
|
|
479
|
+
this.set(id, publisher);
|
|
480
|
+
}
|
|
481
|
+
const publisher = this.publishers.get(id) as PublisherInterface;
|
|
482
|
+
if (hasLocalStorage && this.initialisedData.indexOf(id) === -1) {
|
|
483
|
+
publisher._is_savable_ = true;
|
|
484
|
+
this.initialisedData.push(id);
|
|
485
|
+
this.setLocalData(publisher, id);
|
|
486
|
+
}
|
|
487
|
+
return this.publishers.get(id) as PublisherInterface;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Remplace un publisher pour l'id fourni par un autre.
|
|
491
|
+
* L'autre publisher n'est pas supprimé.
|
|
492
|
+
*/
|
|
493
|
+
set(id: string, publisher: Publisher) {
|
|
494
|
+
this.publishers.set(id, publisher);
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* @warning
|
|
498
|
+
* !!!!! ATTENTION !!!!!
|
|
499
|
+
* Il est fort à aprier que vous ne voulez pas utiliser cette methode
|
|
500
|
+
* Il s'agit d'une supression complete
|
|
501
|
+
* * du publisher de la liste
|
|
502
|
+
* * des bindings
|
|
503
|
+
* * de même que ses sous publishers
|
|
504
|
+
*
|
|
505
|
+
* UTILISEZ PLUTÔT la méthode publisher.set({}) pour réinitialiser un publisher sans perdre les ecouteurs
|
|
506
|
+
*/
|
|
507
|
+
delete(id: string) {
|
|
508
|
+
if (!this.publishers.has(id)) return false;
|
|
509
|
+
this.publishers.delete(id);
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
async saveToLocalStorage(saveId = 0) {
|
|
514
|
+
/**
|
|
515
|
+
* si l'id a changé et que ce n'est pas un multiple de 10, on ne sauve pas
|
|
516
|
+
* on sauvegarde quand même tous les 10 au cas ou on aurrait des changements en continue, par exemple à chaque frame
|
|
517
|
+
*/
|
|
518
|
+
if (saveId !== PublisherManager.saveId && saveId % 10 != 0) return;
|
|
519
|
+
try {
|
|
520
|
+
if (!PublisherManager.changed || PublisherManager.saving) return;
|
|
521
|
+
PublisherManager.saving = true;
|
|
522
|
+
PublisherManager.changed = false;
|
|
523
|
+
const keys = Array.from(this.publishers.keys());
|
|
524
|
+
let hasChanged = false;
|
|
525
|
+
for (const key of keys) {
|
|
526
|
+
const publisher = this.publishers.get(key);
|
|
527
|
+
if (!publisher?._is_savable_) continue;
|
|
528
|
+
const data = publisher?.get();
|
|
529
|
+
if (!data) continue;
|
|
530
|
+
this.localStorageData[key + "¤lang_" + HTML.getLanguage()] = {
|
|
531
|
+
lastModifiationMS: new Date().getTime(),
|
|
532
|
+
data: data,
|
|
533
|
+
};
|
|
534
|
+
hasChanged = true;
|
|
535
|
+
}
|
|
536
|
+
// on enregistre les données
|
|
537
|
+
if (hasChanged) {
|
|
538
|
+
const compressedData = await this.compress(
|
|
539
|
+
JSON.stringify(this.localStorageData),
|
|
540
|
+
"gzip"
|
|
541
|
+
);
|
|
542
|
+
localStorage.setItem("publisher-proxies-data", compressedData);
|
|
543
|
+
}
|
|
544
|
+
PublisherManager.saving = false;
|
|
545
|
+
if (PublisherManager.changed) {
|
|
546
|
+
PublisherManager.saveId++;
|
|
547
|
+
const saveId = PublisherManager.saveId;
|
|
548
|
+
setTimeout(() => this.saveToLocalStorage(saveId), 1000);
|
|
549
|
+
}
|
|
550
|
+
} catch (e) {
|
|
551
|
+
PublisherManager.saving = false;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
async compress(string: string, encoding: string) {
|
|
555
|
+
const byteArray = new TextEncoder().encode(string);
|
|
556
|
+
const win = window as any;
|
|
557
|
+
const cs = new win.CompressionStream(encoding);
|
|
558
|
+
const writer = cs.writable.getWriter();
|
|
559
|
+
writer.write(byteArray);
|
|
560
|
+
writer.close();
|
|
561
|
+
const result = await new Response(cs.readable).arrayBuffer();
|
|
562
|
+
const arrayBufferView = new Uint8Array(result);
|
|
563
|
+
let str = "";
|
|
564
|
+
for (let i = 0; i < arrayBufferView.length; i++) {
|
|
565
|
+
str += String.fromCharCode(arrayBufferView[i]);
|
|
566
|
+
}
|
|
567
|
+
return btoa(str);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
async decompress(str: string, encoding: string) {
|
|
571
|
+
const decodedString = atob(str);
|
|
572
|
+
const arrayBufferViewFromLocalStorage = Uint8Array.from(
|
|
573
|
+
decodedString,
|
|
574
|
+
(c) => c.charCodeAt(0)
|
|
575
|
+
);
|
|
576
|
+
const byteArray = arrayBufferViewFromLocalStorage.buffer;
|
|
577
|
+
const win = window as any;
|
|
578
|
+
const cs = new win.DecompressionStream(encoding);
|
|
579
|
+
const writer = cs.writable.getWriter();
|
|
580
|
+
writer.write(byteArray);
|
|
581
|
+
writer.close();
|
|
582
|
+
const result = await new Response(cs.readable).arrayBuffer();
|
|
583
|
+
return new TextDecoder().decode(result);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const internalProps: Set<string> = new Set([
|
|
588
|
+
"invalidate",
|
|
589
|
+
"onInvalidate",
|
|
590
|
+
"offInvalidate",
|
|
591
|
+
"onAssign",
|
|
592
|
+
"offAssign",
|
|
593
|
+
"startDynamicFilling",
|
|
594
|
+
"stopDynamicFilling",
|
|
595
|
+
"startTemplateFilling",
|
|
596
|
+
"stopTemplateFilling",
|
|
597
|
+
"onInternalMutation",
|
|
598
|
+
"offInternalMutation",
|
|
599
|
+
"set",
|
|
600
|
+
"get",
|
|
601
|
+
"$tag",
|
|
602
|
+
"_cachedGet_",
|
|
603
|
+
"_templateFillListeners_",
|
|
604
|
+
"_fillListeners_",
|
|
605
|
+
"_assignListeners_",
|
|
606
|
+
"_invalidateListeners_",
|
|
607
|
+
"_publishInternalMutation_",
|
|
608
|
+
"hasListener",
|
|
609
|
+
"delete",
|
|
610
|
+
"_mutationListeners_",
|
|
611
|
+
"_publishDynamicFilling_",
|
|
612
|
+
"_publishInvalidation_",
|
|
613
|
+
"_publishTemplateFilling_",
|
|
614
|
+
"_publishAssignement_",
|
|
615
|
+
"_proxies_",
|
|
616
|
+
"parent",
|
|
617
|
+
"_value_",
|
|
618
|
+
"_is_savable_",
|
|
619
|
+
"_lockInternalMutationPublishing_",
|
|
620
|
+
"_instanceCounter_",
|
|
621
|
+
"_assignmentId_",
|
|
622
|
+
]);
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Le Proxy Javascript
|
|
626
|
+
*/
|
|
627
|
+
export default class Publisher<
|
|
628
|
+
T = PublisherContentType
|
|
629
|
+
> extends PublisherProxy<T> {
|
|
630
|
+
constructor(target: T, parentProxPub: PublisherProxy | null = null) {
|
|
631
|
+
super(target, parentProxPub);
|
|
632
|
+
const thisProxy = new Proxy(this, {
|
|
633
|
+
/**
|
|
634
|
+
* Lorsque l'on écrit monConteneur = publisher.maClef ou monConteneur = publisher["maClef"] monConteneur contient :
|
|
635
|
+
* Les methodes de PublisherProxy (onAssign... : voir liste dans kle tableaus si dessous), si la clef est une méthode de PublisherProxy,,
|
|
636
|
+
* Sinon un autre proxy qui a comme valeur interne la valeur corespondante à la clef dans l'objet.
|
|
637
|
+
*/
|
|
638
|
+
get: function (publisherInstance: PublisherProxy<T>, sKey: any) {
|
|
639
|
+
if (sKey == Symbol.toPrimitive) {
|
|
640
|
+
return () => thisProxy.get();
|
|
641
|
+
}
|
|
642
|
+
if (internalProps.has(sKey)) return (publisherInstance as any)[sKey];
|
|
643
|
+
if (!publisherInstance._proxies_.has(sKey)) {
|
|
644
|
+
const vValue = (publisherInstance._value_ as any)[sKey];
|
|
645
|
+
const newPublisher = new Publisher(
|
|
646
|
+
isComplex(vValue) ? vValue : { __value: vValue },
|
|
647
|
+
publisherInstance
|
|
648
|
+
);
|
|
649
|
+
newPublisher._proxies_.set("_parent_", thisProxy);
|
|
650
|
+
publisherInstance._proxies_.set(sKey, newPublisher);
|
|
651
|
+
}
|
|
652
|
+
return publisherInstance._proxies_.get(sKey);
|
|
653
|
+
},
|
|
654
|
+
/**
|
|
655
|
+
* Lorsque l'on écrit publisher.maClef = value ou publisher["maClef"] = value, on assigne la valeur à la clef dans l'objet interne.
|
|
656
|
+
* Les gestionnairs associés sopnt déclenchés en conséquence de manière profonde et remontante si nécessaire.
|
|
657
|
+
*/
|
|
658
|
+
set: function (publisherInstance, sKey: string, vValue) {
|
|
659
|
+
//Fonctionnement pour la donnée interne pas de dispatch;
|
|
660
|
+
if (sKey == "_value_") {
|
|
661
|
+
publisherInstance._value_ = vValue;
|
|
662
|
+
return true;
|
|
663
|
+
}
|
|
664
|
+
if (sKey == "_cachedGet_") {
|
|
665
|
+
publisherInstance._cachedGet_ = vValue;
|
|
666
|
+
return true;
|
|
667
|
+
}
|
|
668
|
+
if (sKey == "_assignmentId_") {
|
|
669
|
+
publisherInstance._assignmentId_ = vValue;
|
|
670
|
+
return true;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
if (sKey == "_is_savable_") {
|
|
674
|
+
publisherInstance._is_savable_ = vValue;
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
if (sKey == "_instanceCounter_") {
|
|
678
|
+
publisherInstance._instanceCounter_ = vValue;
|
|
679
|
+
return true;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
//Création du publisher si il n'existe pas
|
|
683
|
+
if (!publisherInstance._proxies_.has(sKey)) {
|
|
684
|
+
const newPublisher = new Publisher({}, publisherInstance);
|
|
685
|
+
newPublisher._proxies_.set("_parent_", thisProxy);
|
|
686
|
+
publisherInstance._proxies_.set(sKey, newPublisher);
|
|
687
|
+
}
|
|
688
|
+
//mis à jour et publication de la donnée si elle a changé
|
|
689
|
+
const prevValue = (publisherInstance._value_ as any)[sKey];
|
|
690
|
+
if (prevValue !== vValue) {
|
|
691
|
+
(publisherInstance._value_ as any)[sKey] = vValue;
|
|
692
|
+
publisherInstance._publishDynamicFilling_(sKey, vValue);
|
|
693
|
+
publisherInstance._proxies_
|
|
694
|
+
.get(sKey)
|
|
695
|
+
?.set(isComplex(vValue) ? vValue : { __value: vValue });
|
|
696
|
+
}
|
|
697
|
+
//on retourne le proxy pour pouvoir chainer les assignements
|
|
698
|
+
// return publisherInstance._proxies_.get(sKey);
|
|
699
|
+
return true;
|
|
700
|
+
},
|
|
701
|
+
/**
|
|
702
|
+
* Autres propriétés classiques d'un objet implémentées par le proxy
|
|
703
|
+
*/
|
|
704
|
+
deleteProperty: function (publisherInstance, sKey: string) {
|
|
705
|
+
publisherInstance;
|
|
706
|
+
publisherInstance._publishDynamicFilling_(sKey, null);
|
|
707
|
+
// if (!publisherInstance._proxies_.get(sKey)?.hasListener()) {
|
|
708
|
+
// publisherInstance._proxies_.delete(sKey);
|
|
709
|
+
// } else {
|
|
710
|
+
publisherInstance._proxies_.get(sKey)?.set(null);
|
|
711
|
+
// }
|
|
712
|
+
return delete (publisherInstance._value_ as any)[sKey];
|
|
713
|
+
},
|
|
714
|
+
// enumerate: function (publisherInstance, sKey): CoreJSType {
|
|
715
|
+
// return publisherInstance._value_.keys();
|
|
716
|
+
// },
|
|
717
|
+
has: function (publisherInstance, sKey) {
|
|
718
|
+
publisherInstance;
|
|
719
|
+
return (
|
|
720
|
+
sKey in (publisherInstance._value_ as any) &&
|
|
721
|
+
sKey != "_lockInternalMutationPublishing_"
|
|
722
|
+
);
|
|
723
|
+
},
|
|
724
|
+
defineProperty: function (publisherInstance, sKey, oDesc) {
|
|
725
|
+
publisherInstance;
|
|
726
|
+
if (oDesc && "value" in oDesc) {
|
|
727
|
+
(publisherInstance._value_ as any)[sKey] = oDesc.value;
|
|
728
|
+
}
|
|
729
|
+
return true;
|
|
730
|
+
// return publisherInstance._value_;
|
|
731
|
+
},
|
|
732
|
+
getOwnPropertyDescriptor: function (publisherInstance, sKey) {
|
|
733
|
+
publisherInstance;
|
|
734
|
+
sKey;
|
|
735
|
+
return {
|
|
736
|
+
enumerable: true,
|
|
737
|
+
configurable: true,
|
|
738
|
+
};
|
|
739
|
+
},
|
|
740
|
+
ownKeys: function (publisherInstance) {
|
|
741
|
+
if ((publisherInstance._value_ as any).__value)
|
|
742
|
+
return Object.keys((publisherInstance._value_ as any).__value);
|
|
743
|
+
return Object.keys((publisherInstance as any)._value_);
|
|
744
|
+
},
|
|
745
|
+
});
|
|
746
|
+
return thisProxy as any;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
toString() {
|
|
750
|
+
return "hey";
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
valueOf() {
|
|
754
|
+
return 2;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
getProperty<U, K extends keyof U>(o: U, propertyName: K): U[K] {
|
|
758
|
+
return o[propertyName]; // o[propertyName] is of type T[K]
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// if (typeof module != "undefined") module.exports = {Publisher: Publisher, PublisherManager: PublisherManager};
|
|
763
|
+
|
|
764
|
+
// /**
|
|
765
|
+
// * A custom webcomponent wich will be linked to a publisher via its attribute "publisher"
|
|
766
|
+
// * the publisher will be found via PublisherManager.get(publisherId) and will be used to fill the component using the onAssign method
|
|
767
|
+
// */
|
|
768
|
+
class PublisherWebComponent extends HTMLElement {
|
|
769
|
+
publisherId = "";
|
|
770
|
+
publisher: any;
|
|
771
|
+
constructor() {
|
|
772
|
+
super();
|
|
773
|
+
}
|
|
774
|
+
connectedCallback() {
|
|
775
|
+
this.publisherId = this.getAttribute("publisher") || "";
|
|
776
|
+
this.publisher = PublisherProxy.instances.get(parseInt(this.publisherId));
|
|
777
|
+
this.publisher?.onAssign(this.onAssign);
|
|
778
|
+
}
|
|
779
|
+
disconnectedCallback() {
|
|
780
|
+
this.publisher?.offAssign(this.onAssign);
|
|
781
|
+
}
|
|
782
|
+
onAssign = (value: any) => {
|
|
783
|
+
this.innerHTML = value.toString();
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
customElements.define("reactive-publisher-proxy", PublisherWebComponent);
|