@kosdev-code/kos-ui-sdk 3.0.26 → 3.0.28
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/.kos.json +2 -1
- package/common/events/async-event-bus.d.ts +8 -11
- package/common/events/async-event-bus.d.ts.map +1 -1
- package/common/events/eventBus.d.ts +1 -18
- package/common/events/eventBus.d.ts.map +1 -1
- package/core/core/companion-instantiator.d.ts +5 -0
- package/core/core/companion-instantiator.d.ts.map +1 -1
- package/core/core/decorators/index.d.ts +1 -0
- package/core/core/decorators/index.d.ts.map +1 -1
- package/core/core/decorators/kos-child.d.ts +2 -3
- package/core/core/decorators/kos-child.d.ts.map +1 -1
- package/core/core/decorators/kos-companion.d.ts +26 -88
- package/core/core/decorators/kos-companion.d.ts.map +1 -1
- package/core/core/decorators/kos-container-aware-reconcile.test-d.d.ts +2 -0
- package/core/core/decorators/kos-container-aware-reconcile.test-d.d.ts.map +1 -0
- package/core/core/decorators/kos-container-aware.d.ts +191 -420
- package/core/core/decorators/kos-container-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-execute-service-request.d.ts +7 -11
- package/core/core/decorators/kos-execute-service-request.d.ts.map +1 -1
- package/core/core/decorators/kos-execution-context.d.ts +14 -31
- package/core/core/decorators/kos-execution-context.d.ts.map +1 -1
- package/core/core/decorators/kos-future-aware.d.ts +21 -74
- package/core/core/decorators/kos-future-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-http-decorators.d.ts +18 -62
- package/core/core/decorators/kos-http-decorators.d.ts.map +1 -1
- package/core/core/decorators/kos-logger-aware.d.ts +10 -60
- package/core/core/decorators/kos-logger-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-mixin.d.ts +69 -0
- package/core/core/decorators/kos-mixin.d.ts.map +1 -0
- package/core/core/decorators/kos-model-effect.d.ts +10 -9
- package/core/core/decorators/kos-model-effect.d.ts.map +1 -1
- package/core/core/decorators/kos-multiple-future-aware.d.ts +21 -94
- package/core/core/decorators/kos-multiple-future-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-reload-aware.d.ts +14 -16
- package/core/core/decorators/kos-reload-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-service-request.d.ts +80 -238
- package/core/core/decorators/kos-service-request.d.ts.map +1 -1
- package/core/core/decorators/kos-state-machine.d.ts +35 -275
- package/core/core/decorators/kos-state-machine.d.ts.map +1 -1
- package/core/core/decorators/kos-topic-handler-flow-control.d.ts +11 -3
- package/core/core/decorators/kos-topic-handler-flow-control.d.ts.map +1 -1
- package/core/core/decorators/kos-trouble-aware.d.ts +9 -43
- package/core/core/decorators/kos-trouble-aware.d.ts.map +1 -1
- package/core/core/decorators/kos-view-model.d.ts +20 -100
- package/core/core/decorators/kos-view-model.d.ts.map +1 -1
- package/core/core/decorators/kosModel.d.ts.map +1 -1
- package/core/core/decorators/kosTopicHandler.d.ts +28 -89
- package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
- package/core/core/decorators/propKeys.d.ts +1 -0
- package/core/core/decorators/propKeys.d.ts.map +1 -1
- package/core/core/indexing/index.d.ts +2 -4
- package/core/core/indexing/index.d.ts.map +1 -1
- package/core/core/indexing/kos-container-index-aware.d.ts +17 -48
- package/core/core/indexing/kos-container-index-aware.d.ts.map +1 -1
- package/core/core/indexing/kos-index-aware.d.ts +11 -37
- package/core/core/indexing/kos-index-aware.d.ts.map +1 -1
- package/core/core/kos-container-index.d.ts +11 -0
- package/core/core/kos-container-index.d.ts.map +1 -1
- package/core/core/kos-container-model.d.ts +11 -32
- package/core/core/kos-container-model.d.ts.map +1 -1
- package/core/core/kos-data-container.d.ts +6 -6
- package/core/core/kos-data-container.d.ts.map +1 -1
- package/core/core/kosCore.d.ts +7 -4
- package/core/core/kosCore.d.ts.map +1 -1
- package/core/core/kosModel.d.ts +16 -8
- package/core/core/kosModel.d.ts.map +1 -1
- package/core/core/kosModelManager.d.ts +2 -3
- package/core/core/kosModelManager.d.ts.map +1 -1
- package/core/core/lifecycle/constants.d.ts +6 -2
- package/core/core/lifecycle/constants.d.ts.map +1 -1
- package/core/core/lifecycle/kosCoreLifecycle.d.ts +11 -1
- package/core/core/lifecycle/kosCoreLifecycle.d.ts.map +1 -1
- package/core/core/lifecycle/kosModelLifecycle.d.ts +6 -0
- package/core/core/lifecycle/kosModelLifecycle.d.ts.map +1 -1
- package/core/core/lifecycle/model-machine.d.ts +6 -0
- package/core/core/lifecycle/model-machine.d.ts.map +1 -1
- package/core/core/model/kos-fsm-manager.d.ts +6 -0
- package/core/core/model/kos-fsm-manager.d.ts.map +1 -1
- package/core/core/model/kos-offline-queue.d.ts +1 -1
- package/core/core/model/kos-subscription-manager.d.ts.map +1 -1
- package/core/core/model/service-response-store.d.ts +2 -15
- package/core/core/model/service-response-store.d.ts.map +1 -1
- package/core/core/reconnect/reconnect-fixture.d.ts +17 -0
- package/core/core/reconnect/reconnect-fixture.d.ts.map +1 -0
- package/core/core/registration/model-registration.d.ts.map +1 -1
- package/core/core/services/app-startup-service.d.ts +5 -13
- package/core/core/services/app-startup-service.d.ts.map +1 -1
- package/core/core/services/intent-service.d.ts +3 -12
- package/core/core/services/intent-service.d.ts.map +1 -1
- package/core/core/transport/mock/mock-frames.d.ts +3 -3
- package/core/core/transport/transport.d.ts +1 -1
- package/core/core/transport/transport.d.ts.map +1 -1
- package/core/core/transport/webSocketTransport.d.ts +10 -0
- package/core/core/transport/webSocketTransport.d.ts.map +1 -1
- package/core/types/model.d.ts +4 -8
- package/core/types/model.d.ts.map +1 -1
- package/core/types/service-response-store.d.ts +3 -11
- package/core/types/service-response-store.d.ts.map +1 -1
- package/core/types/utils/kos-fetch.d.ts +25 -37
- package/core/types/utils/kos-fetch.d.ts.map +1 -1
- package/core/util/abortable-when.d.ts +5 -6
- package/core/util/abortable-when.d.ts.map +1 -1
- package/core/util/ancestor-path-visitor.d.ts +14 -20
- package/core/util/ancestor-path-visitor.d.ts.map +1 -1
- package/core/util/container-utils.d.ts +26 -159
- package/core/util/container-utils.d.ts.map +1 -1
- package/core/util/date-utils.d.ts +9 -58
- package/core/util/date-utils.d.ts.map +1 -1
- package/core/util/debounce.d.ts +1 -8
- package/core/util/debounce.d.ts.map +1 -1
- package/core/util/kos-fetch.d.ts +1 -1
- package/core/util/kos-fetch.d.ts.map +1 -1
- package/core/util/kos-model-utils.d.ts +10 -11
- package/core/util/kos-model-utils.d.ts.map +1 -1
- package/core/util/model-attribute-utils.d.ts +5 -22
- package/core/util/model-attribute-utils.d.ts.map +1 -1
- package/core/util/model-type-guards.d.ts.map +1 -1
- package/core/util/promise-utils.d.ts +1 -26
- package/core/util/promise-utils.d.ts.map +1 -1
- package/core/util/service-factory.d.ts +5 -23
- package/core/util/service-factory.d.ts.map +1 -1
- package/core/util/service-request-error.d.ts +3 -5
- package/core/util/service-request-error.d.ts.map +1 -1
- package/core/util/service-response.d.ts +12 -67
- package/core/util/service-response.d.ts.map +1 -1
- package/core/util/transport-not-ready-error.d.ts +11 -13
- package/core/util/transport-not-ready-error.d.ts.map +1 -1
- package/core/util/when-ready.d.ts +1 -8
- package/core/util/when-ready.d.ts.map +1 -1
- package/index.cjs +692 -11760
- package/index.cjs.map +1 -1
- package/index.js +774 -11846
- package/index.js.map +1 -1
- package/models/decorators/future-service.d.ts +7 -7
- package/models/models/browser-router/browser-router-model.d.ts +10 -39
- package/models/models/browser-router/browser-router-model.d.ts.map +1 -1
- package/models/models/browser-router/browser-router-registration.d.ts +5 -77
- package/models/models/browser-router/browser-router-registration.d.ts.map +1 -1
- package/models/models/browser-router/types/index.d.ts +2 -16
- package/models/models/canvas-dispatcher/canvas-dispatcher-registration.d.ts +5 -77
- package/models/models/canvas-dispatcher/canvas-dispatcher-registration.d.ts.map +1 -1
- package/models/models/canvas-renderer/canvas-renderer-registration.d.ts +5 -75
- package/models/models/canvas-renderer/canvas-renderer-registration.d.ts.map +1 -1
- package/models/models/config-bean/config-bean-model-builder.d.ts +4 -11
- package/models/models/config-bean/config-bean-model-builder.d.ts.map +1 -1
- package/models/models/config-bean/config-bean-model.d.ts +23 -66
- package/models/models/config-bean/config-bean-model.d.ts.map +1 -1
- package/models/models/config-bean-prop/config-bean-prop-model.d.ts +15 -62
- package/models/models/config-bean-prop/config-bean-prop-model.d.ts.map +1 -1
- package/models/models/config-bean-prop/types/index.d.ts +34 -215
- package/models/models/device/device-model.d.ts +20 -199
- package/models/models/device/device-model.d.ts.map +1 -1
- package/models/models/device/device-registration.d.ts +7 -87
- package/models/models/device/device-registration.d.ts.map +1 -1
- package/models/models/device/types/index.d.ts +5 -34
- package/models/models/future/future-aware.d.ts +7 -71
- package/models/models/future/future-aware.d.ts.map +1 -1
- package/models/models/future/future-model-builder.d.ts +2 -2
- package/models/models/future/future-model.d.ts +3 -23
- package/models/models/future/future-model.d.ts.map +1 -1
- package/models/models/future/future-types.d.ts +28 -145
- package/models/models/future/future-types.d.ts.map +1 -1
- package/models/models/gpio-chip/gpio-chip-builders.d.ts +14 -0
- package/models/models/gpio-chip/gpio-chip-builders.d.ts.map +1 -0
- package/models/models/gpio-chip/gpio-chip-container-model.d.ts +2 -1
- package/models/models/gpio-chip/gpio-chip-container-model.d.ts.map +1 -1
- package/models/models/key-value/key-value-model.d.ts +12 -72
- package/models/models/key-value/key-value-model.d.ts.map +1 -1
- package/models/models/key-value/key-value-registration.d.ts +5 -77
- package/models/models/key-value/key-value-registration.d.ts.map +1 -1
- package/models/models/key-value/services/key-value-services.d.ts +13 -72
- package/models/models/key-value/services/key-value-services.d.ts.map +1 -1
- package/models/models/key-value/types/index.d.ts +3 -46
- package/models/models/kos-expression-evaluator/expression-parse-cache.d.ts +29 -0
- package/models/models/kos-expression-evaluator/expression-parse-cache.d.ts.map +1 -0
- package/models/models/kos-expression-evaluator/index.d.ts +1 -0
- package/models/models/kos-expression-evaluator/index.d.ts.map +1 -1
- package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts +73 -105
- package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts.map +1 -1
- package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts +2 -12
- package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts.map +1 -1
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts +7 -46
- package/models/models/kos-log-manager/kos-log-manager-model.d.ts.map +1 -1
- package/models/models/kos-log-manager/kos-log-manager-registration.d.ts +5 -80
- package/models/models/kos-log-manager/kos-log-manager-registration.d.ts.map +1 -1
- package/models/models/kos-log-manager/types/index.d.ts +13 -156
- package/models/models/kos-time/kos-time-model.d.ts +8 -39
- package/models/models/kos-time/kos-time-model.d.ts.map +1 -1
- package/models/models/kos-time/kos-time-registration.d.ts +6 -73
- package/models/models/kos-time/kos-time-registration.d.ts.map +1 -1
- package/models/models/kos-time/types/index.d.ts +3 -58
- package/models/models/log-block/log-block-container-model.d.ts +2 -118
- package/models/models/log-block/log-block-container-model.d.ts.map +1 -1
- package/models/models/log-block/log-block-container-registration.d.ts +5 -75
- package/models/models/log-block/log-block-container-registration.d.ts.map +1 -1
- package/models/models/log-block/log-block-model.d.ts +5 -168
- package/models/models/log-block/log-block-model.d.ts.map +1 -1
- package/models/models/log-block/log-block-registration.d.ts +5 -75
- package/models/models/log-block/log-block-registration.d.ts.map +1 -1
- package/models/models/log-block/types/index.d.ts +14 -81
- package/models/models/log-stream/log-stream-container-model.d.ts +8 -35
- package/models/models/log-stream/log-stream-container-model.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-container-registration.d.ts +5 -75
- package/models/models/log-stream/log-stream-container-registration.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-model.d.ts +8 -29
- package/models/models/log-stream/log-stream-model.d.ts.map +1 -1
- package/models/models/log-stream/log-stream-registration.d.ts +5 -75
- package/models/models/log-stream/log-stream-registration.d.ts.map +1 -1
- package/models/models/log-stream/types/index.d.ts +5 -60
- package/models/models/network-interface/network-interface-container-model.d.ts +6 -35
- package/models/models/network-interface/network-interface-container-model.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-container-registration.d.ts +5 -73
- package/models/models/network-interface/network-interface-container-registration.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-model.d.ts +5 -43
- package/models/models/network-interface/network-interface-model.d.ts.map +1 -1
- package/models/models/network-interface/network-interface-registration.d.ts +5 -73
- package/models/models/network-interface/network-interface-registration.d.ts.map +1 -1
- package/models/models/network-interface/types/index.d.ts +2 -16
- package/models/models/ota/ota-model.d.ts +11 -39
- package/models/models/ota/ota-model.d.ts.map +1 -1
- package/models/models/ota/ota-registration.d.ts +5 -77
- package/models/models/ota/ota-registration.d.ts.map +1 -1
- package/models/models/ota/types/index.d.ts +2 -141
- package/models/models/region-info/types/index.d.ts +19 -99
- package/models/models/region-info/types/index.d.ts.map +1 -1
- package/models/models/software-info/services/software-info-services.d.ts +2 -14
- package/models/models/software-info/services/software-info-services.d.ts.map +1 -1
- package/models/models/software-info/software-info-model.d.ts +3 -39
- package/models/models/software-info/software-info-model.d.ts.map +1 -1
- package/models/models/software-info/software-info-registration.d.ts +6 -73
- package/models/models/software-info/software-info-registration.d.ts.map +1 -1
- package/models/models/software-info/types/index.d.ts +6 -20
- package/models/models/state-bean/state-bean-model.d.ts +10 -41
- package/models/models/state-bean/state-bean-model.d.ts.map +1 -1
- package/models/models/state-bean/state-bean-registration.d.ts +6 -73
- package/models/models/state-bean/state-bean-registration.d.ts.map +1 -1
- package/models/models/state-bean/types/index.d.ts +4 -84
- package/models/models/state-prop/state-prop-model.d.ts +6 -40
- package/models/models/state-prop/state-prop-model.d.ts.map +1 -1
- package/models/models/state-prop/state-prop-registration.d.ts +6 -73
- package/models/models/state-prop/state-prop-registration.d.ts.map +1 -1
- package/models/models/state-prop/types/index.d.ts +5 -37
- package/models/models/storage-device/storage-device-container-model.d.ts +7 -273
- package/models/models/storage-device/storage-device-container-model.d.ts.map +1 -1
- package/models/models/storage-device/storage-device-container-registration.d.ts +5 -75
- package/models/models/storage-device/storage-device-container-registration.d.ts.map +1 -1
- package/models/models/storage-device/storage-device-model.d.ts +3 -49
- package/models/models/storage-device/storage-device-model.d.ts.map +1 -1
- package/models/models/storage-device/storage-device-registration.d.ts +5 -75
- package/models/models/storage-device/storage-device-registration.d.ts.map +1 -1
- package/models/models/storage-device/types/index.d.ts +13 -82
- package/models/models/studio-properties/studio-properties-model.d.ts +13 -36
- package/models/models/studio-properties/studio-properties-model.d.ts.map +1 -1
- package/models/models/studio-properties/studio-properties-registration.d.ts +5 -75
- package/models/models/studio-properties/studio-properties-registration.d.ts.map +1 -1
- package/models/models/studio-properties/types/index.d.ts +2 -24
- package/models/models/translation/descriptor-merge.d.ts +13 -17
- package/models/models/translation/descriptor-merge.d.ts.map +1 -1
- package/models/models/translation/services/translation-services.d.ts +19 -77
- package/models/models/translation/services/translation-services.d.ts.map +1 -1
- package/models/models/translation/test-harness.d.ts +6 -8
- package/models/models/translation/test-harness.d.ts.map +1 -1
- package/models/models/translation/translation-container-model.d.ts +7 -59
- package/models/models/translation/translation-container-model.d.ts.map +1 -1
- package/models/models/translation/translation-container-registration.d.ts +6 -73
- package/models/models/translation/translation-container-registration.d.ts.map +1 -1
- package/models/models/translation/translation-model.d.ts +17 -50
- package/models/models/translation/translation-model.d.ts.map +1 -1
- package/models/models/translation/translation-registration.d.ts +6 -73
- package/models/models/translation/translation-registration.d.ts.map +1 -1
- package/models/models/translation/types/index.d.ts +51 -276
- package/models/models/trouble/trouble-registration.d.ts +6 -73
- package/models/models/trouble/trouble-registration.d.ts.map +1 -1
- package/models/models/trouble/types/index.d.ts +17 -188
- package/models/models/trouble/utils/is-trouble-aware.d.ts +4 -85
- package/models/models/trouble/utils/is-trouble-aware.d.ts.map +1 -1
- package/models/models/trouble-container/trouble-builders.d.ts +11 -0
- package/models/models/trouble-container/trouble-builders.d.ts.map +1 -0
- package/models/models/trouble-container/trouble-container-model.d.ts +2 -1
- package/models/models/trouble-container/trouble-container-model.d.ts.map +1 -1
- package/models/models/usb-update/usb-update-container-registration.d.ts +5 -75
- package/models/models/usb-update/usb-update-container-registration.d.ts.map +1 -1
- package/models/models/usb-update/usb-update-registration.d.ts +5 -75
- package/models/models/usb-update/usb-update-registration.d.ts.map +1 -1
- package/models/types/cancellable-promise.d.ts +6 -9
- package/models/types/cancellable-promise.d.ts.map +1 -1
- package/models/utils/await-future-call.d.ts +9 -21
- package/models/utils/await-future-call.d.ts.map +1 -1
- package/models/utils/cancellable-future-call.d.ts +8 -19
- package/models/utils/cancellable-future-call.d.ts.map +1 -1
- package/models/utils/cancellable-service.d.ts +14 -23
- package/models/utils/cancellable-service.d.ts.map +1 -1
- package/models/utils/conversion-utils.d.ts +8 -48
- package/models/utils/conversion-utils.d.ts.map +1 -1
- package/models/utils/persistence-store.d.ts +1 -1
- package/models/utils/service.d.ts +14 -48
- package/models/utils/service.d.ts.map +1 -1
- package/models/utils/services/kos/daily/service.d.ts +4 -4
- package/models/utils/services/vfs/daily/service.d.ts +4 -4
- package/models/utils/timer-manager.d.ts.map +1 -1
- package/package.json +2 -2
- package/{index-D52vEGXT.cjs → software-info-registration-Le3V0a6v.cjs} +11906 -416
- package/software-info-registration-Le3V0a6v.cjs.map +1 -0
- package/{index-Csq0zQtb.js → software-info-registration-kSGacOka.js} +12116 -625
- package/software-info-registration-kSGacOka.js.map +1 -0
- package/testing/index.d.ts +32 -34
- package/testing/index.d.ts.map +1 -1
- package/testing.cjs +2 -1
- package/testing.cjs.map +1 -1
- package/testing.js +2 -1
- package/testing.js.map +1 -1
- package/ui/components/connection-dev-button/connection-dev-button-styles.d.ts +9 -0
- package/ui/components/connection-dev-button/connection-dev-button-styles.d.ts.map +1 -0
- package/ui/components/connection-dev-button/index.d.ts +36 -0
- package/ui/components/connection-dev-button/index.d.ts.map +1 -0
- package/ui/components/connection-dev-button/use-connection-dev-state.d.ts +29 -0
- package/ui/components/connection-dev-button/use-connection-dev-state.d.ts.map +1 -0
- package/ui/components/index.d.ts +1 -0
- package/ui/components/index.d.ts.map +1 -1
- package/ui/features/canvas/hooks/use-image-renderer.d.ts +5 -4
- package/ui/features/canvas/hooks/use-image-renderer.d.ts.map +1 -1
- package/ui/hooks/use-function-warmup.d.ts +4 -14
- package/ui/hooks/use-function-warmup.d.ts.map +1 -1
- package/ui/hooks/use-kos-date-formats.d.ts +15 -29
- package/ui/hooks/use-kos-date-formats.d.ts.map +1 -1
- package/ui/hooks/use-kos-region-timezones.d.ts +4 -55
- package/ui/hooks/use-kos-region-timezones.d.ts.map +1 -1
- package/ui/hooks/use-kos-regions.d.ts +11 -23
- package/ui/hooks/use-kos-regions.d.ts.map +1 -1
- package/ui/hooks/use-kos-time-formats.d.ts +16 -31
- package/ui/hooks/use-kos-time-formats.d.ts.map +1 -1
- package/ui/hooks/use-kos-unit-systems.d.ts +13 -27
- package/ui/hooks/use-kos-unit-systems.d.ts.map +1 -1
- package/ui/hooks/view-model/use-view-model.d.ts +6 -31
- package/ui/hooks/view-model/use-view-model.d.ts.map +1 -1
- package/ui/policies/reload-on-disconnect-policy.d.ts +5 -6
- package/ui/policies/reload-on-disconnect-policy.d.ts.map +1 -1
- package/index-Csq0zQtb.js.map +0 -1
- package/index-D52vEGXT.cjs.map +0 -1
package/testing/index.d.ts
CHANGED
|
@@ -4,18 +4,20 @@ export interface BootKosCoreOptions {
|
|
|
4
4
|
alias?: string;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* A model's registration bean
|
|
8
|
-
* model,
|
|
7
|
+
* A model's registration bean: the value `@kosModel` generates beside the
|
|
8
|
+
* model, which an application passes to `KosModelRegistry...model()`.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* registers nothing, and the model
|
|
10
|
+
* Pass the bean itself rather than its `registration` property; the property
|
|
11
|
+
* registers nothing, and the model then fails on its first build.
|
|
12
12
|
*/
|
|
13
13
|
export type KosTestRegistration = BaseKosModelRegistrationBean<any, any> | KosModelRegistrationType<any, any>;
|
|
14
14
|
/**
|
|
15
15
|
* The registration chain an application uses, terminated by `boot()`.
|
|
16
16
|
*
|
|
17
17
|
* Every call is deferred until `boot()`, so ordering within the chain does not
|
|
18
|
-
* matter and `alias()` may come after the models it applies to.
|
|
18
|
+
* matter and `alias()` may come after the models it applies to. `boot()`
|
|
19
|
+
* registers the SDK's core models before the chain's own registrations, the
|
|
20
|
+
* same set `KosModelRegistry.core.models()` registers in an app.
|
|
19
21
|
*/
|
|
20
22
|
export interface KosCoreBootBuilder {
|
|
21
23
|
/** Register a model under test, optionally preloading it. */
|
|
@@ -29,42 +31,38 @@ export interface KosCoreBootBuilder {
|
|
|
29
31
|
/** Connection alias, when the model under test cares about one. */
|
|
30
32
|
alias: (alias: string) => KosCoreBootBuilder;
|
|
31
33
|
/**
|
|
32
|
-
* Install a KosMock setup module before boot
|
|
34
|
+
* Install a KosMock setup module before boot: the default export the
|
|
33
35
|
* fixture server serves from `fixtures/setups/*.mjs`, imported directly. It
|
|
34
|
-
* runs before the transport exists, so it
|
|
35
|
-
* config injections and observers;
|
|
36
|
+
* runs before the transport exists, so it can register routes, transformers,
|
|
37
|
+
* config injections and observers; pushes belong after boot.
|
|
36
38
|
*/
|
|
37
39
|
setup: (module: KosMockSetupModule) => KosCoreBootBuilder;
|
|
38
40
|
/**
|
|
39
|
-
* Load a recorded fixture before boot
|
|
40
|
-
* imported directly. Test defaults
|
|
41
|
-
* `pushes: "manual"` (the capture's topic and future timeline stays inert
|
|
42
|
-
* test pushes what it asserts on). Pass options to override either.
|
|
41
|
+
* Load a recorded fixture before boot: the JSON the fixture server serves,
|
|
42
|
+
* imported directly. Test defaults are `ignoreLatency: true` (full speed) and
|
|
43
|
+
* `pushes: "manual"` (the capture's topic and future timeline stays inert, and
|
|
44
|
+
* the test pushes what it asserts on). Pass options to override either.
|
|
43
45
|
*/
|
|
44
46
|
fixture: (fixture: KosMockFixture, options?: KosMockPlaybackOptions) => KosCoreBootBuilder;
|
|
45
|
-
/** Boot KosCore with everything
|
|
47
|
+
/** Boot KosCore with the core models and everything on this chain. */
|
|
46
48
|
boot: () => Promise<IKosCoreManager>;
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Open a registration chain, then `boot()` it.
|
|
50
52
|
*
|
|
51
|
-
* Idempotent per module instance: the first `boot()` boots
|
|
52
|
-
* the same core. KosCore and the model manager are process-global, so
|
|
53
|
-
* file gets one core and one set of singletons
|
|
54
|
-
* boundary, and the reason a differently-configured singleton needs its own
|
|
55
|
-
* file.
|
|
53
|
+
* Idempotent per module instance: the first `boot()` boots and later calls
|
|
54
|
+
* return the same core. KosCore and the model manager are process-global, so
|
|
55
|
+
* a test file gets one core and one set of singletons.
|
|
56
56
|
*
|
|
57
|
-
* Register
|
|
58
|
-
* the boot requests
|
|
59
|
-
* `.fixture()` on it.
|
|
57
|
+
* Register the routes the models need before calling `boot()` so nothing races
|
|
58
|
+
* the boot requests, either with `KosMock.get(...)` above the chain or with
|
|
59
|
+
* `.setup()` / `.fixture()` on it.
|
|
60
60
|
*
|
|
61
61
|
* @example
|
|
62
62
|
* ```ts
|
|
63
|
-
* await bootKosCore().model(AssetManager).model(AssetEntry).boot();
|
|
64
|
-
*
|
|
65
63
|
* await bootKosCore()
|
|
66
|
-
* .setup(boardBaseline)
|
|
67
|
-
* .fixture(pourOk)
|
|
64
|
+
* .setup(boardBaseline) // fixtures/setups/board-baseline.mjs
|
|
65
|
+
* .fixture(pourOk) // fixtures/pour-ok.json
|
|
68
66
|
* .model(Board)
|
|
69
67
|
* .boot();
|
|
70
68
|
* ```
|
|
@@ -73,22 +71,22 @@ export declare function bootKosCore(): KosCoreBootBuilder;
|
|
|
73
71
|
/**
|
|
74
72
|
* Boot KosCore from an assembled registry.
|
|
75
73
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* registration beans directly
|
|
74
|
+
* For callers that already hold an `IKosRegistry`; it boots exactly the
|
|
75
|
+
* registry it is given. A test registering its own models should use the
|
|
76
|
+
* no-argument chain, which takes registration beans directly and registers the
|
|
77
|
+
* SDK's core models.
|
|
79
78
|
*
|
|
80
79
|
* @param registration Models under test, e.g. `{ models: {...}, preloadModels: [] }`.
|
|
81
80
|
*/
|
|
82
81
|
export declare function bootKosCore(registration: IKosRegistry, options?: BootKosCoreOptions): Promise<IKosCoreManager>;
|
|
83
82
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
83
|
+
* Resolves once `predicate` holds, or rejects with a message naming `label`
|
|
84
|
+
* after the timeout.
|
|
86
85
|
*
|
|
87
86
|
* Model reactions are asynchronous, so a test that changes an input and asserts
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* fires at all.
|
|
87
|
+
* at once reads the old value. Polling for the outcome is faster than sleeping
|
|
88
|
+
* for a fixed interval and fails with a clear message when the reaction never
|
|
89
|
+
* fires.
|
|
92
90
|
*
|
|
93
91
|
* @param label What is being waited for, quoted back in the timeout message.
|
|
94
92
|
*/
|
package/testing/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/kos-ui-sdk/src/testing/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/kos-ui-sdk/src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,OAAO,KAAK,EACV,4BAA4B,EAC5B,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,SAAS,EACV,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAC3B,4BAA4B,CAAC,GAAG,EAAE,GAAG,CAAC,GACtC,wBAAwB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEvC;;;;;;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perty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("mobx");
|
|
4
|
-
const service = require("./
|
|
4
|
+
const service = require("./software-info-registration-Le3V0a6v.cjs");
|
|
5
5
|
require("loglevel");
|
|
6
6
|
let booted;
|
|
7
7
|
let prepared = false;
|
|
@@ -77,6 +77,7 @@ function buildBootBuilder() {
|
|
|
77
77
|
await install();
|
|
78
78
|
}
|
|
79
79
|
prepareTransport(alias);
|
|
80
|
+
service.KosModelRegistry.core.models();
|
|
80
81
|
registrations.splice(0).forEach((register) => register());
|
|
81
82
|
return bootCore({ models: {}, preloadModels }, { alias });
|
|
82
83
|
}
|
package/testing.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.cjs","sources":["../../../packages/kos-ui-sdk/src/testing/index.ts"],"sourcesContent":["/**\n * Test support for KOS models — boot the framework in a unit test, with no\n * device, no WebSocket server and no browser.\n *\n * KOS models cannot be built in isolation: they need a live KosCore, and\n * KosCore opens a WebSocket the moment it is created. `bootKosCore` boots it on\n * KosMock's standalone loopback transport instead, which authorizes itself so\n * `whenReady()` resolves with no device and no `KOS_ALLOW_ANONYMOUS` build flag.\n *\n * Models register the way an application registers them. `bootKosCore()` with\n * no arguments returns a builder carrying the same chain an app's\n * `KosModelRegistry` gives — `.model()`, `.preload()`, `.companion()`,\n * `.legacy()` — so a test hands over the registration bean itself rather than\n * assembling a registry by hand.\n *\n * Backend traffic is mocked the same way an app would mock it — `KosMock.get`,\n * `KosMock.post`, fixtures, config injection — so a test exercises the real\n * request path rather than a stubbed service function. The chain's `.setup()`\n * and `.fixture()` install the project's committed setup modules and recorded\n * fixtures before boot, so the declarations the browser dev loop runs are the\n * ones the test runs.\n *\n * ```ts\n * import { bootKosCore, until } from \"@kosdev-code/kos-ui-sdk/testing\";\n * import { KosMock } from \"@kosdev-code/kos-ui-sdk\";\n * import { Board } from \"./models/board\";\n *\n * beforeAll(async () => {\n * KosMock.get(\"/api/board/:id\", { data: { id: \"b1\", state: \"READY\" } });\n * await bootKosCore().model(Board).boot();\n * });\n *\n * it(\"loads the board\", async () => {\n * const board = Board.instance(\"b1\").options({}).build();\n * await whenReady(board);\n * expect(board.state).toBe(\"READY\");\n * });\n * ```\n *\n * ## Two things that bite\n *\n * **Singleton models take one configuration per test file.** A second\n * `options(...)` call returns the FIRST instance and discards the new options in\n * silence, so assertions written against them pass for the wrong reason. A case\n * needing different options belongs in its own file, which the test runner\n * gives its own module state.\n *\n * **The standalone socket authorizes by publishing Studio's\n * `/studioServer/auth/LOGGED_IN` on every open.** A device never sends that, so\n * a test shaped around disconnect/reconnect here is exercising Studio's\n * sequence, not a device's. It makes no difference to tests that never\n * reconnect.\n */\nimport type {\n BaseKosModelRegistrationBean,\n IKosCoreManager,\n IKosModelRegistration,\n IKosRegistry,\n KosCompanionModelType,\n KosMockFixture,\n KosMockPlaybackOptions,\n KosMockSetupModule,\n KosModelRegistrationType,\n Preloaded,\n} from \"../core\";\nimport { KosCore, KosMock, RegistrationManager } from \"../core\";\n\nlet booted: Promise<IKosCoreManager> | undefined;\nlet prepared = false;\n\nexport interface BootKosCoreOptions {\n /** Connection alias, when the model under test cares about one. */\n alias?: string;\n}\n\n/**\n * A model's registration bean — the value `@kosModel` generates beside the\n * model, and the one an application passes to `KosModelRegistry...model()`.\n *\n * The bean itself, not its `registration` property: handing over the property\n * registers nothing, and the model only fails later, on the first build.\n */\nexport type KosTestRegistration =\n | BaseKosModelRegistrationBean<any, any>\n | KosModelRegistrationType<any, any>;\n\n/**\n * The registration chain an application uses, terminated by `boot()`.\n *\n * Every call is deferred until `boot()`, so ordering within the chain does not\n * matter and `alias()` may come after the models it applies to.\n */\nexport interface KosCoreBootBuilder {\n /** Register a model under test, optionally preloading it. */\n model: (\n registration: KosTestRegistration,\n preload?: boolean\n ) => KosCoreBootBuilder;\n /** Preload a model type, or a specific instance of one, at boot. */\n preload: (model: Preloaded) => KosCoreBootBuilder;\n /** Attach a companion model type to a parent type. */\n companion: (\n parentType: string,\n companion: KosCompanionModelType<any>\n ) => KosCoreBootBuilder;\n /** Register a hand-written registration record against a type. */\n legacy: (\n type: string,\n registration: IKosModelRegistration\n ) => KosCoreBootBuilder;\n /** Connection alias, when the model under test cares about one. */\n alias: (alias: string) => KosCoreBootBuilder;\n /**\n * Install a KosMock setup module before boot — the same default export the\n * fixture server serves from `fixtures/setups/*.mjs`, imported directly. It\n * runs before the transport exists, so it registers routes, transformers,\n * config injections and observers; anything it pushes belongs after boot.\n */\n setup: (module: KosMockSetupModule) => KosCoreBootBuilder;\n /**\n * Load a recorded fixture before boot — the JSON the fixture server serves,\n * imported directly. Test defaults: `ignoreLatency: true` (full speed) and\n * `pushes: \"manual\"` (the capture's topic and future timeline stays inert; a\n * test pushes what it asserts on). Pass options to override either.\n */\n fixture: (\n fixture: KosMockFixture,\n options?: KosMockPlaybackOptions\n ) => KosCoreBootBuilder;\n /** Boot KosCore with everything registered on this chain. */\n boot: () => Promise<IKosCoreManager>;\n}\n\n/**\n * Put the mock transport and the connection alias in place before anything\n * constructs KosCore.\n *\n * KosCore picks its transport and reads its alias in the constructor, and\n * registering a model reaches `KosCore.getInstance()` — so registration cannot\n * come first.\n */\nfunction prepareTransport(alias?: string): void {\n if (prepared) {\n return;\n }\n prepared = true;\n KosMock.configure({ standalone: true });\n KosCore.getInstance({ connectionAlias: alias });\n}\n\nfunction bootCore(\n registration: IKosRegistry,\n options: BootKosCoreOptions\n): Promise<IKosCoreManager> {\n if (!booted) {\n prepareTransport(options.alias);\n const core = KosCore.create(registration, false, options.alias);\n booted = core.whenReady().then(() => core);\n }\n return booted;\n}\n\nconst FIXTURE_TEST_DEFAULTS: KosMockPlaybackOptions = {\n ignoreLatency: true,\n pushes: \"manual\",\n};\n\nfunction buildBootBuilder(): KosCoreBootBuilder {\n const registrations: (() => void)[] = [];\n const mockInstalls: (() => Promise<void> | void)[] = [];\n const preloadModels: Preloaded[] = [];\n let alias: string | undefined;\n\n const builder: KosCoreBootBuilder = {\n model: (registration, preload) => {\n registrations.push(() =>\n RegistrationManager.model.register(builder)(registration, preload)\n );\n return builder;\n },\n preload: (model) => {\n preloadModels.push(model);\n return builder;\n },\n companion: (parentType, companion) => {\n registrations.push(() =>\n RegistrationManager.companion.register(builder)(parentType, companion)\n );\n return builder;\n },\n legacy: (type, registration) => {\n registrations.push(() =>\n RegistrationManager.model.registerLegacyModel(builder)(\n type,\n registration\n )\n );\n return builder;\n },\n alias: (value) => {\n alias = value;\n return builder;\n },\n setup: (module) => {\n mockInstalls.push(async () => {\n await module(KosMock);\n });\n return builder;\n },\n fixture: (fixture, options) => {\n mockInstalls.push(() => {\n KosMock.loadFixture(fixture, { ...FIXTURE_TEST_DEFAULTS, ...options });\n });\n return builder;\n },\n boot: async () => {\n // Mocks first, in call order, before the transport exists — the same\n // \"routes before boot\" rule a test follows when it calls KosMock.get.\n for (const install of mockInstalls.splice(0)) {\n await install();\n }\n prepareTransport(alias);\n registrations.splice(0).forEach((register) => register());\n return bootCore({ models: {}, preloadModels }, { alias });\n },\n };\n\n return builder;\n}\n\n/**\n * Open a registration chain, then `boot()` it.\n *\n * Idempotent per module instance: the first `boot()` boots, later ones return\n * the same core. KosCore and the model manager are process-global, so a test\n * file gets one core and one set of singletons — which is the isolation\n * boundary, and the reason a differently-configured singleton needs its own\n * file.\n *\n * Register any routes the models need BEFORE calling `boot()`, so nothing races\n * the boot requests — `KosMock.get(...)` above the chain, or `.setup()` /\n * `.fixture()` on it.\n *\n * @example\n * ```ts\n * await bootKosCore().model(AssetManager).model(AssetEntry).boot();\n *\n * await bootKosCore()\n * .setup(boardBaseline) // fixtures/setups/board-baseline.mjs\n * .fixture(pourOk) // fixtures/pour-ok.json\n * .model(Board)\n * .boot();\n * ```\n */\nexport function bootKosCore(): KosCoreBootBuilder;\n/**\n * Boot KosCore from an assembled registry.\n *\n * Kept for callers that already hold an `IKosRegistry`. A test registering its\n * own models should use the no-argument chain instead, which takes the\n * registration beans directly.\n *\n * @param registration Models under test, e.g. `{ models: {...}, preloadModels: [] }`.\n */\nexport function bootKosCore(\n registration: IKosRegistry,\n options?: BootKosCoreOptions\n): Promise<IKosCoreManager>;\nexport function bootKosCore(\n registration?: IKosRegistry,\n options: BootKosCoreOptions = {}\n): KosCoreBootBuilder | Promise<IKosCoreManager> {\n return registration ? bootCore(registration, options) : buildBootBuilder();\n}\n\n/**\n * Wait until `predicate` holds, then resolve — or reject naming what never\n * happened.\n *\n * Model reactions are asynchronous, so a test that changes an input and asserts\n * immediately reads the old value. Polling for the OUTCOME beats sleeping for an\n * arbitrary interval: it is faster when the reaction is quick, and it fails with\n * a usable message instead of a bare assertion diff when the reaction never\n * fires at all.\n *\n * @param label What is being waited for, quoted back in the timeout message.\n */\nexport async function until(\n predicate: () => boolean,\n label: string,\n timeoutMs = 2000\n): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n while (!predicate()) {\n if (Date.now() > deadline) {\n throw new Error(`timed out waiting for ${label}`);\n }\n await new Promise((resolve) => setTimeout(resolve, 5));\n }\n}\n"],"names":["KosMock","KosCore","RegistrationManager","module"],"mappings":";;;;;AAmEA,IAAI;AACJ,IAAI,WAAW;AAyEf,SAAS,iBAAiB,OAAsB;AAC9C,MAAI,UAAU;AACZ;AAAA,EACF;AACA,aAAW;AACXA,UAAAA,QAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtCC,UAAAA,QAAQ,YAAY,EAAE,iBAAiB,MAAA,CAAO;AAChD;AAEA,SAAS,SACP,cACA,SAC0B;AAC1B,MAAI,CAAC,QAAQ;AACX,qBAAiB,QAAQ,KAAK;AAC9B,UAAM,OAAOA,QAAAA,QAAQ,OAAO,cAAc,OAAO,QAAQ,KAAK;AAC9D,aAAS,KAAK,UAAA,EAAY,KAAK,MAAM,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAEA,MAAM,wBAAgD;AAAA,EACpD,eAAe;AAAA,EACf,QAAQ;AACV;AAEA,SAAS,mBAAuC;AAC9C,QAAM,gBAAgC,CA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AiB,EAAE,OAAO;AAAA,IAC1D;AAAA,EAAA;AAGF,SAAO;AACT;AAwCO,SAAS,YACd,cACA,UAA8B,IACiB;AAC/C,SAAO,eAAe,SAAS,cAAc,OAAO,IAAI,iBAAA;AAC1D;AAcA,eAAsB,MACpB,WACA,OACA,YAAY,KACG;AACf,QAAM,WAAW,KAAK,IAAA,IAAQ;AAC9B,SAAO,CAAC,aAAa;AACnB,QAAI,KAAK,IAAA,IAAQ,UAAU;AACzB,YAAM,IAAI,MAAM,yBAAyB,KAAK,EAAE;AAAA,IAClD;AACA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,CAAC,CAAC;AAAA,EACvD;AACF;;;"}
|
|
1
|
+
{"version":3,"file":"testing.cjs","sources":["../../../packages/kos-ui-sdk/src/testing/index.ts"],"sourcesContent":["/**\n * Test support for KOS models: boots the framework in a unit test without a\n * device, WebSocket server or browser.\n *\n * KOS models need a live KosCore, and KosCore opens a WebSocket as soon as it\n * is created. `bootKosCore` boots it on KosMock's standalone loopback\n * transport instead, which authorizes itself so `whenReady()` resolves without\n * a device or the `KOS_ALLOW_ANONYMOUS` build flag.\n *\n * `bootKosCore()` returns the same registration chain an app's\n * `KosModelRegistry` gives (`.model()`, `.preload()`, `.companion()`,\n * `.legacy()`), so a test passes the model's registration bean directly.\n * `boot()` also registers the SDK's core models, so a model with a\n * `@kosConfigProperty` or a dependency on a core model builds with only the\n * model under test on the chain.\n *\n * Backend traffic is mocked as an app would mock it (`KosMock.get`,\n * `KosMock.post`, fixtures, config injection), so a test exercises the real\n * request path. `.setup()` and `.fixture()` install the project's setup modules\n * and recorded fixtures before boot.\n *\n * ```ts\n * import { bootKosCore } from \"@kosdev-code/kos-ui-sdk/testing\";\n * import { KosMock, whenReady } from \"@kosdev-code/kos-ui-sdk\";\n * import { Board } from \"./models/board\";\n *\n * beforeAll(async () => {\n * KosMock.get(\"/api/board/:id\", { data: { id: \"b1\", state: \"READY\" } });\n * await bootKosCore().model(Board).boot();\n * });\n *\n * it(\"loads the board\", async () => {\n * const board = Board.instance(\"b1\").options({}).build();\n * await whenReady(board);\n * expect(board.state).toBe(\"READY\");\n * });\n * ```\n *\n * Singleton models take one configuration per test file: a second\n * `options(...)` call returns the first instance and silently discards the new\n * options. Put a case that needs different options in its own file.\n *\n * The standalone socket authorizes by publishing Studio's\n * `/studioServer/auth/LOGGED_IN` on every open, which a device never sends, so\n * disconnect and reconnect tests here follow Studio's sequence rather than a\n * device's.\n */\nimport type {\n BaseKosModelRegistrationBean,\n IKosCoreManager,\n IKosModelRegistration,\n IKosRegistry,\n KosCompanionModelType,\n KosMockFixture,\n KosMockPlaybackOptions,\n KosMockSetupModule,\n KosModelRegistrationType,\n Preloaded,\n} from \"../core\";\nimport { KosCore, KosMock, RegistrationManager } from \"../core\";\nimport { KosModelRegistry } from \"../models/utils/core-registration-manager\";\n\nlet booted: Promise<IKosCoreManager> | undefined;\nlet prepared = false;\n\nexport interface BootKosCoreOptions {\n /** Connection alias, when the model under test cares about one. */\n alias?: string;\n}\n\n/**\n * A model's registration bean: the value `@kosModel` generates beside the\n * model, which an application passes to `KosModelRegistry...model()`.\n *\n * Pass the bean itself rather than its `registration` property; the property\n * registers nothing, and the model then fails on its first build.\n */\nexport type KosTestRegistration =\n | BaseKosModelRegistrationBean<any, any>\n | KosModelRegistrationType<any, any>;\n\n/**\n * The registration chain an application uses, terminated by `boot()`.\n *\n * Every call is deferred until `boot()`, so ordering within the chain does not\n * matter and `alias()` may come after the models it applies to. `boot()`\n * registers the SDK's core models before the chain's own registrations, the\n * same set `KosModelRegistry.core.models()` registers in an app.\n */\nexport interface KosCoreBootBuilder {\n /** Register a model under test, optionally preloading it. */\n model: (\n registration: KosTestRegistration,\n preload?: boolean\n ) => KosCoreBootBuilder;\n /** Preload a model type, or a specific instance of one, at boot. */\n preload: (model: Preloaded) => KosCoreBootBuilder;\n /** Attach a companion model type to a parent type. */\n companion: (\n parentType: string,\n companion: KosCompanionModelType<any>\n ) => KosCoreBootBuilder;\n /** Register a hand-written registration record against a type. */\n legacy: (\n type: string,\n registration: IKosModelRegistration\n ) => KosCoreBootBuilder;\n /** Connection alias, when the model under test cares about one. */\n alias: (alias: string) => KosCoreBootBuilder;\n /**\n * Install a KosMock setup module before boot: the default export the\n * fixture server serves from `fixtures/setups/*.mjs`, imported directly. It\n * runs before the transport exists, so it can register routes, transformers,\n * config injections and observers; pushes belong after boot.\n */\n setup: (module: KosMockSetupModule) => KosCoreBootBuilder;\n /**\n * Load a recorded fixture before boot: the JSON the fixture server serves,\n * imported directly. Test defaults are `ignoreLatency: true` (full speed) and\n * `pushes: \"manual\"` (the capture's topic and future timeline stays inert, and\n * the test pushes what it asserts on). Pass options to override either.\n */\n fixture: (\n fixture: KosMockFixture,\n options?: KosMockPlaybackOptions\n ) => KosCoreBootBuilder;\n /** Boot KosCore with the core models and everything on this chain. */\n boot: () => Promise<IKosCoreManager>;\n}\n\n/**\n * Put the mock transport and the connection alias in place before anything\n * constructs KosCore.\n *\n * KosCore picks its transport and reads its alias in the constructor, and\n * registering a model calls `KosCore.getInstance()`, so registration cannot\n * come first.\n */\nfunction prepareTransport(alias?: string): void {\n if (prepared) {\n return;\n }\n prepared = true;\n KosMock.configure({ standalone: true });\n KosCore.getInstance({ connectionAlias: alias });\n}\n\nfunction bootCore(\n registration: IKosRegistry,\n options: BootKosCoreOptions\n): Promise<IKosCoreManager> {\n if (!booted) {\n prepareTransport(options.alias);\n const core = KosCore.create(registration, false, options.alias);\n booted = core.whenReady().then(() => core);\n }\n return booted;\n}\n\nconst FIXTURE_TEST_DEFAULTS: KosMockPlaybackOptions = {\n ignoreLatency: true,\n pushes: \"manual\",\n};\n\nfunction buildBootBuilder(): KosCoreBootBuilder {\n const registrations: (() => void)[] = [];\n const mockInstalls: (() => Promise<void> | void)[] = [];\n const preloadModels: Preloaded[] = [];\n let alias: string | undefined;\n\n const builder: KosCoreBootBuilder = {\n model: (registration, preload) => {\n registrations.push(() =>\n RegistrationManager.model.register(builder)(registration, preload)\n );\n return builder;\n },\n preload: (model) => {\n preloadModels.push(model);\n return builder;\n },\n companion: (parentType, companion) => {\n registrations.push(() =>\n RegistrationManager.companion.register(builder)(parentType, companion)\n );\n return builder;\n },\n legacy: (type, registration) => {\n registrations.push(() =>\n RegistrationManager.model.registerLegacyModel(builder)(\n type,\n registration\n )\n );\n return builder;\n },\n alias: (value) => {\n alias = value;\n return builder;\n },\n setup: (module) => {\n mockInstalls.push(async () => {\n await module(KosMock);\n });\n return builder;\n },\n fixture: (fixture, options) => {\n mockInstalls.push(() => {\n KosMock.loadFixture(fixture, { ...FIXTURE_TEST_DEFAULTS, ...options });\n });\n return builder;\n },\n boot: async () => {\n // Mocks first, in call order, before the transport exists.\n for (const install of mockInstalls.splice(0)) {\n await install();\n }\n prepareTransport(alias);\n KosModelRegistry.core.models();\n registrations.splice(0).forEach((register) => register());\n return bootCore({ models: {}, preloadModels }, { alias });\n },\n };\n\n return builder;\n}\n\n/**\n * Open a registration chain, then `boot()` it.\n *\n * Idempotent per module instance: the first `boot()` boots and later calls\n * return the same core. KosCore and the model manager are process-global, so\n * a test file gets one core and one set of singletons.\n *\n * Register the routes the models need before calling `boot()` so nothing races\n * the boot requests, either with `KosMock.get(...)` above the chain or with\n * `.setup()` / `.fixture()` on it.\n *\n * @example\n * ```ts\n * await bootKosCore()\n * .setup(boardBaseline) // fixtures/setups/board-baseline.mjs\n * .fixture(pourOk) // fixtures/pour-ok.json\n * .model(Board)\n * .boot();\n * ```\n */\nexport function bootKosCore(): KosCoreBootBuilder;\n/**\n * Boot KosCore from an assembled registry.\n *\n * For callers that already hold an `IKosRegistry`; it boots exactly the\n * registry it is given. A test registering its own models should use the\n * no-argument chain, which takes registration beans directly and registers the\n * SDK's core models.\n *\n * @param registration Models under test, e.g. `{ models: {...}, preloadModels: [] }`.\n */\nexport function bootKosCore(\n registration: IKosRegistry,\n options?: BootKosCoreOptions\n): Promise<IKosCoreManager>;\nexport function bootKosCore(\n registration?: IKosRegistry,\n options: BootKosCoreOptions = {}\n): KosCoreBootBuilder | Promise<IKosCoreManager> {\n return registration ? bootCore(registration, options) : buildBootBuilder();\n}\n\n/**\n * Resolves once `predicate` holds, or rejects with a message naming `label`\n * after the timeout.\n *\n * Model reactions are asynchronous, so a test that changes an input and asserts\n * at once reads the old value. Polling for the outcome is faster than sleeping\n * for a fixed interval and fails with a clear message when the reaction never\n * fires.\n *\n * @param label What is being waited for, quoted back in the timeout message.\n */\nexport async function until(\n predicate: () => boolean,\n label: string,\n timeoutMs = 2000\n): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n while (!predicate()) {\n if (Date.now() > deadline) {\n throw new Error(`timed out waiting for ${label}`);\n }\n await new Promise((resolve) => setTimeout(resolve, 5));\n }\n}\n"],"names":["KosMock","KosCore","RegistrationManager","module","KosModelRegistry"],"mappings":";;;;;AA8DA,IAAI;AACJ,IAAI,WAAW;AA2Ef,SAAS,iBAAiB,OAAsB;AAC9C,MAAI,UAAU;AACZ;AAAA,EACF;AACA,aAAW;AACXA,UAAAA,QAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtCC,UAAAA,QAAQ,YAAY,EAAE,iBAAiB,MAAA,CAAO;AAChD;AAEA,SAAS,SACP,cACA,SAC0B;AAC1B,MAAI,CAAC,QAAQ;AACX,qBAAiB,QAAQ,KAAK;AAC9B,UAAM,OAAOA,QAAAA,QAAQ,OAAO,cAAc,OAAO,QAAQ,KAAK;AAC9D,aAAS,KAAK,UAAA,EAAY,KAAK,MAAM,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAEA,MAAM,wBAAgD;AAAA,EACpD,eAAe;AAAA,EACf,QAAQ;AACV;AAEA,SAAS,mBAAuC;AAC9C,QAAM,gBAAgC,CAAA;AACtC,QAAM,eAA+C,CAAA;AACrD,QAAM,gBAA6B,CAAA;AACnC,MAAI;AAEJ,QAAM,UAA8B;AAAA,IAClC,OAAO,CAAC,cAAc,YAAY;AAChC,oBAAc;AAAA,QAAK,MACjB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,cAAc,OAAO,IAAI,iBAAA;AAC1D;AAaA,eAAsB,MACpB,WACA,OACA,YAAY,KACG;AACf,QAAM,WAAW,KAAK,IAAA,IAAQ;AAC9B,SAAO,CAAC,aAAa;AACnB,QAAI,KAAK,IAAA,IAAQ,UAAU;AACzB,YAAM,IAAI,MAAM,yBAAyB,KAAK,EAAE;AAAA,IAClD;AACA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,CAAC,CAAC;AAAA,EACvD;AACF;;;"}
|
package/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "mobx";
|
|
2
|
-
import {
|
|
2
|
+
import { h as KosCore, bU as KosMock, bZ as KosModelRegistry, cn as RegistrationManager } from "./software-info-registration-kSGacOka.js";
|
|
3
3
|
import "loglevel";
|
|
4
4
|
let booted;
|
|
5
5
|
let prepared = false;
|
|
@@ -75,6 +75,7 @@ function buildBootBuilder() {
|
|
|
75
75
|
await install();
|
|
76
76
|
}
|
|
77
77
|
prepareTransport(alias);
|
|
78
|
+
KosModelRegistry.core.models();
|
|
78
79
|
registrations.splice(0).forEach((register) => register());
|
|
79
80
|
return bootCore({ models: {}, preloadModels }, { alias });
|
|
80
81
|
}
|
package/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sources":["../../../packages/kos-ui-sdk/src/testing/index.ts"],"sourcesContent":["/**\n * Test support for KOS models — boot the framework in a unit test, with no\n * device, no WebSocket server and no browser.\n *\n * KOS models cannot be built in isolation: they need a live KosCore, and\n * KosCore opens a WebSocket the moment it is created. `bootKosCore` boots it on\n * KosMock's standalone loopback transport instead, which authorizes itself so\n * `whenReady()` resolves with no device and no `KOS_ALLOW_ANONYMOUS` build flag.\n *\n * Models register the way an application registers them. `bootKosCore()` with\n * no arguments returns a builder carrying the same chain an app's\n * `KosModelRegistry` gives — `.model()`, `.preload()`, `.companion()`,\n * `.legacy()` — so a test hands over the registration bean itself rather than\n * assembling a registry by hand.\n *\n * Backend traffic is mocked the same way an app would mock it — `KosMock.get`,\n * `KosMock.post`, fixtures, config injection — so a test exercises the real\n * request path rather than a stubbed service function. The chain's `.setup()`\n * and `.fixture()` install the project's committed setup modules and recorded\n * fixtures before boot, so the declarations the browser dev loop runs are the\n * ones the test runs.\n *\n * ```ts\n * import { bootKosCore, until } from \"@kosdev-code/kos-ui-sdk/testing\";\n * import { KosMock } from \"@kosdev-code/kos-ui-sdk\";\n * import { Board } from \"./models/board\";\n *\n * beforeAll(async () => {\n * KosMock.get(\"/api/board/:id\", { data: { id: \"b1\", state: \"READY\" } });\n * await bootKosCore().model(Board).boot();\n * });\n *\n * it(\"loads the board\", async () => {\n * const board = Board.instance(\"b1\").options({}).build();\n * await whenReady(board);\n * expect(board.state).toBe(\"READY\");\n * });\n * ```\n *\n * ## Two things that bite\n *\n * **Singleton models take one configuration per test file.** A second\n * `options(...)` call returns the FIRST instance and discards the new options in\n * silence, so assertions written against them pass for the wrong reason. A case\n * needing different options belongs in its own file, which the test runner\n * gives its own module state.\n *\n * **The standalone socket authorizes by publishing Studio's\n * `/studioServer/auth/LOGGED_IN` on every open.** A device never sends that, so\n * a test shaped around disconnect/reconnect here is exercising Studio's\n * sequence, not a device's. It makes no difference to tests that never\n * reconnect.\n */\nimport type {\n BaseKosModelRegistrationBean,\n IKosCoreManager,\n IKosModelRegistration,\n IKosRegistry,\n KosCompanionModelType,\n KosMockFixture,\n KosMockPlaybackOptions,\n KosMockSetupModule,\n KosModelRegistrationType,\n Preloaded,\n} from \"../core\";\nimport { KosCore, KosMock, RegistrationManager } from \"../core\";\n\nlet booted: Promise<IKosCoreManager> | undefined;\nlet prepared = false;\n\nexport interface BootKosCoreOptions {\n /** Connection alias, when the model under test cares about one. */\n alias?: string;\n}\n\n/**\n * A model's registration bean — the value `@kosModel` generates beside the\n * model, and the one an application passes to `KosModelRegistry...model()`.\n *\n * The bean itself, not its `registration` property: handing over the property\n * registers nothing, and the model only fails later, on the first build.\n */\nexport type KosTestRegistration =\n | BaseKosModelRegistrationBean<any, any>\n | KosModelRegistrationType<any, any>;\n\n/**\n * The registration chain an application uses, terminated by `boot()`.\n *\n * Every call is deferred until `boot()`, so ordering within the chain does not\n * matter and `alias()` may come after the models it applies to.\n */\nexport interface KosCoreBootBuilder {\n /** Register a model under test, optionally preloading it. */\n model: (\n registration: KosTestRegistration,\n preload?: boolean\n ) => KosCoreBootBuilder;\n /** Preload a model type, or a specific instance of one, at boot. */\n preload: (model: Preloaded) => KosCoreBootBuilder;\n /** Attach a companion model type to a parent type. */\n companion: (\n parentType: string,\n companion: KosCompanionModelType<any>\n ) => KosCoreBootBuilder;\n /** Register a hand-written registration record against a type. */\n legacy: (\n type: string,\n registration: IKosModelRegistration\n ) => KosCoreBootBuilder;\n /** Connection alias, when the model under test cares about one. */\n alias: (alias: string) => KosCoreBootBuilder;\n /**\n * Install a KosMock setup module before boot — the same default export the\n * fixture server serves from `fixtures/setups/*.mjs`, imported directly. It\n * runs before the transport exists, so it registers routes, transformers,\n * config injections and observers; anything it pushes belongs after boot.\n */\n setup: (module: KosMockSetupModule) => KosCoreBootBuilder;\n /**\n * Load a recorded fixture before boot — the JSON the fixture server serves,\n * imported directly. Test defaults: `ignoreLatency: true` (full speed) and\n * `pushes: \"manual\"` (the capture's topic and future timeline stays inert; a\n * test pushes what it asserts on). Pass options to override either.\n */\n fixture: (\n fixture: KosMockFixture,\n options?: KosMockPlaybackOptions\n ) => KosCoreBootBuilder;\n /** Boot KosCore with everything registered on this chain. */\n boot: () => Promise<IKosCoreManager>;\n}\n\n/**\n * Put the mock transport and the connection alias in place before anything\n * constructs KosCore.\n *\n * KosCore picks its transport and reads its alias in the constructor, and\n * registering a model reaches `KosCore.getInstance()` — so registration cannot\n * come first.\n */\nfunction prepareTransport(alias?: string): void {\n if (prepared) {\n return;\n }\n prepared = true;\n KosMock.configure({ standalone: true });\n KosCore.getInstance({ connectionAlias: alias });\n}\n\nfunction bootCore(\n registration: IKosRegistry,\n options: BootKosCoreOptions\n): Promise<IKosCoreManager> {\n if (!booted) {\n prepareTransport(options.alias);\n const core = KosCore.create(registration, false, options.alias);\n booted = core.whenReady().then(() => core);\n }\n return booted;\n}\n\nconst FIXTURE_TEST_DEFAULTS: KosMockPlaybackOptions = {\n ignoreLatency: true,\n pushes: \"manual\",\n};\n\nfunction buildBootBuilder(): KosCoreBootBuilder {\n const registrations: (() => void)[] = [];\n const mockInstalls: (() => Promise<void> | void)[] = [];\n const preloadModels: Preloaded[] = [];\n let alias: string | undefined;\n\n const builder: KosCoreBootBuilder = {\n model: (registration, preload) => {\n registrations.push(() =>\n RegistrationManager.model.register(builder)(registration, preload)\n );\n return builder;\n },\n preload: (model) => {\n preloadModels.push(model);\n return builder;\n },\n companion: (parentType, companion) => {\n registrations.push(() =>\n RegistrationManager.companion.register(builder)(parentType, companion)\n );\n return builder;\n },\n legacy: (type, registration) => {\n registrations.push(() =>\n RegistrationManager.model.registerLegacyModel(builder)(\n type,\n registration\n )\n );\n return builder;\n },\n alias: (value) => {\n alias = value;\n return builder;\n },\n setup: (module) => {\n mockInstalls.push(async () => {\n await module(KosMock);\n });\n return builder;\n },\n fixture: (fixture, options) => {\n mockInstalls.push(() => {\n KosMock.loadFixture(fixture, { ...FIXTURE_TEST_DEFAULTS, ...options });\n });\n return builder;\n },\n boot: async () => {\n // Mocks first, in call order, before the transport exists — the same\n // \"routes before boot\" rule a test follows when it calls KosMock.get.\n for (const install of mockInstalls.splice(0)) {\n await install();\n }\n prepareTransport(alias);\n registrations.splice(0).forEach((register) => register());\n return bootCore({ models: {}, preloadModels }, { alias });\n },\n };\n\n return builder;\n}\n\n/**\n * Open a registration chain, then `boot()` it.\n *\n * Idempotent per module instance: the first `boot()` boots, later ones return\n * the same core. KosCore and the model manager are process-global, so a test\n * file gets one core and one set of singletons — which is the isolation\n * boundary, and the reason a differently-configured singleton needs its own\n * file.\n *\n * Register any routes the models need BEFORE calling `boot()`, so nothing races\n * the boot requests — `KosMock.get(...)` above the chain, or `.setup()` /\n * `.fixture()` on it.\n *\n * @example\n * ```ts\n * await bootKosCore().model(AssetManager).model(AssetEntry).boot();\n *\n * await bootKosCore()\n * .setup(boardBaseline) // fixtures/setups/board-baseline.mjs\n * .fixture(pourOk) // fixtures/pour-ok.json\n * .model(Board)\n * .boot();\n * ```\n */\nexport function bootKosCore(): KosCoreBootBuilder;\n/**\n * Boot KosCore from an assembled registry.\n *\n * Kept for callers that already hold an `IKosRegistry`. A test registering its\n * own models should use the no-argument chain instead, which takes the\n * registration beans directly.\n *\n * @param registration Models under test, e.g. `{ models: {...}, preloadModels: [] }`.\n */\nexport function bootKosCore(\n registration: IKosRegistry,\n options?: BootKosCoreOptions\n): Promise<IKosCoreManager>;\nexport function bootKosCore(\n registration?: IKosRegistry,\n options: BootKosCoreOptions = {}\n): KosCoreBootBuilder | Promise<IKosCoreManager> {\n return registration ? bootCore(registration, options) : buildBootBuilder();\n}\n\n/**\n * Wait until `predicate` holds, then resolve — or reject naming what never\n * happened.\n *\n * Model reactions are asynchronous, so a test that changes an input and asserts\n * immediately reads the old value. Polling for the OUTCOME beats sleeping for an\n * arbitrary interval: it is faster when the reaction is quick, and it fails with\n * a usable message instead of a bare assertion diff when the reaction never\n * fires at all.\n *\n * @param label What is being waited for, quoted back in the timeout message.\n */\nexport async function until(\n predicate: () => boolean,\n label: string,\n timeoutMs = 2000\n): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n while (!predicate()) {\n if (Date.now() > deadline) {\n throw new Error(`timed out waiting for ${label}`);\n }\n await new Promise((resolve) => setTimeout(resolve, 5));\n }\n}\n"],"names":[],"mappings":";;;AAmEA,IAAI;AACJ,IAAI,WAAW;AAyEf,SAAS,iBAAiB,OAAsB;AAC9C,MAAI,UAAU;AACZ;AAAA,EACF;AACA,aAAW;AACX,UAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtC,UAAQ,YAAY,EAAE,iBAAiB,MAAA,CAAO;AAChD;AAEA,SAAS,SACP,cACA,SA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AAA,MACvE,CAAC;AACD,aAAO;AAAA,IACT;AAAA,IACA,MAAM,YAAY;AAGhB,iBAAW,WAAW,aAAa,OAAO,CAAC,GAAG;AAC5C,cAAM,QAAA;AAAA,MACR;AACA,uBAAiB,KAAK;AACtB,oBAAc,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,UAAU;AACxD,aAAO,SAAS,EAAE,QAAQ,CAAA,GAAI,cAAA,GAAiB,EAAE,OAAO;AAAA,IAC1D;AAAA,EAAA;AAGF,SAAO;AACT;AAwCO,SAAS,YACd,cACA,UAA8B,IACiB;AAC/C,SAAO,eAAe,SAAS,cAAc,OAAO,IAAI,iBAAA;AAC1D;AAcA,eAAsB,MACpB,WACA,OACA,YAAY,KACG;AACf,QAAM,WAAW,KAAK,IAAA,IAAQ;AAC9B,SAAO,CAAC,aAAa;AACnB,QAAI,KAAK,IAAA,IAAQ,UAAU;AACzB,YAAM,IAAI,MAAM,yBAAyB,KAAK,EAAE;AAAA,IAClD;AACA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,CAAC,CAAC;AAAA,EACvD;AACF;"}
|
|
1
|
+
{"version":3,"file":"testing.js","sources":["../../../packages/kos-ui-sdk/src/testing/index.ts"],"sourcesContent":["/**\n * Test support for KOS models: boots the framework in a unit test without a\n * device, WebSocket server or browser.\n *\n * KOS models need a live KosCore, and KosCore opens a WebSocket as soon as it\n * is created. `bootKosCore` boots it on KosMock's standalone loopback\n * transport instead, which authorizes itself so `whenReady()` resolves without\n * a device or the `KOS_ALLOW_ANONYMOUS` build flag.\n *\n * `bootKosCore()` returns the same registration chain an app's\n * `KosModelRegistry` gives (`.model()`, `.preload()`, `.companion()`,\n * `.legacy()`), so a test passes the model's registration bean directly.\n * `boot()` also registers the SDK's core models, so a model with a\n * `@kosConfigProperty` or a dependency on a core model builds with only the\n * model under test on the chain.\n *\n * Backend traffic is mocked as an app would mock it (`KosMock.get`,\n * `KosMock.post`, fixtures, config injection), so a test exercises the real\n * request path. `.setup()` and `.fixture()` install the project's setup modules\n * and recorded fixtures before boot.\n *\n * ```ts\n * import { bootKosCore } from \"@kosdev-code/kos-ui-sdk/testing\";\n * import { KosMock, whenReady } from \"@kosdev-code/kos-ui-sdk\";\n * import { Board } from \"./models/board\";\n *\n * beforeAll(async () => {\n * KosMock.get(\"/api/board/:id\", { data: { id: \"b1\", state: \"READY\" } });\n * await bootKosCore().model(Board).boot();\n * });\n *\n * it(\"loads the board\", async () => {\n * const board = Board.instance(\"b1\").options({}).build();\n * await whenReady(board);\n * expect(board.state).toBe(\"READY\");\n * });\n * ```\n *\n * Singleton models take one configuration per test file: a second\n * `options(...)` call returns the first instance and silently discards the new\n * options. Put a case that needs different options in its own file.\n *\n * The standalone socket authorizes by publishing Studio's\n * `/studioServer/auth/LOGGED_IN` on every open, which a device never sends, so\n * disconnect and reconnect tests here follow Studio's sequence rather than a\n * device's.\n */\nimport type {\n BaseKosModelRegistrationBean,\n IKosCoreManager,\n IKosModelRegistration,\n IKosRegistry,\n KosCompanionModelType,\n KosMockFixture,\n KosMockPlaybackOptions,\n KosMockSetupModule,\n KosModelRegistrationType,\n Preloaded,\n} from \"../core\";\nimport { KosCore, KosMock, RegistrationManager } from \"../core\";\nimport { KosModelRegistry } from \"../models/utils/core-registration-manager\";\n\nlet booted: Promise<IKosCoreManager> | undefined;\nlet prepared = false;\n\nexport interface BootKosCoreOptions {\n /** Connection alias, when the model under test cares about one. */\n alias?: string;\n}\n\n/**\n * A model's registration bean: the value `@kosModel` generates beside the\n * model, which an application passes to `KosModelRegistry...model()`.\n *\n * Pass the bean itself rather than its `registration` property; the property\n * registers nothing, and the model then fails on its first build.\n */\nexport type KosTestRegistration =\n | BaseKosModelRegistrationBean<any, any>\n | KosModelRegistrationType<any, any>;\n\n/**\n * The registration chain an application uses, terminated by `boot()`.\n *\n * Every call is deferred until `boot()`, so ordering within the chain does not\n * matter and `alias()` may come after the models it applies to. `boot()`\n * registers the SDK's core models before the chain's own registrations, the\n * same set `KosModelRegistry.core.models()` registers in an app.\n */\nexport interface KosCoreBootBuilder {\n /** Register a model under test, optionally preloading it. */\n model: (\n registration: KosTestRegistration,\n preload?: boolean\n ) => KosCoreBootBuilder;\n /** Preload a model type, or a specific instance of one, at boot. */\n preload: (model: Preloaded) => KosCoreBootBuilder;\n /** Attach a companion model type to a parent type. */\n companion: (\n parentType: string,\n companion: KosCompanionModelType<any>\n ) => KosCoreBootBuilder;\n /** Register a hand-written registration record against a type. */\n legacy: (\n type: string,\n registration: IKosModelRegistration\n ) => KosCoreBootBuilder;\n /** Connection alias, when the model under test cares about one. */\n alias: (alias: string) => KosCoreBootBuilder;\n /**\n * Install a KosMock setup module before boot: the default export the\n * fixture server serves from `fixtures/setups/*.mjs`, imported directly. It\n * runs before the transport exists, so it can register routes, transformers,\n * config injections and observers; pushes belong after boot.\n */\n setup: (module: KosMockSetupModule) => KosCoreBootBuilder;\n /**\n * Load a recorded fixture before boot: the JSON the fixture server serves,\n * imported directly. Test defaults are `ignoreLatency: true` (full speed) and\n * `pushes: \"manual\"` (the capture's topic and future timeline stays inert, and\n * the test pushes what it asserts on). Pass options to override either.\n */\n fixture: (\n fixture: KosMockFixture,\n options?: KosMockPlaybackOptions\n ) => KosCoreBootBuilder;\n /** Boot KosCore with the core models and everything on this chain. */\n boot: () => Promise<IKosCoreManager>;\n}\n\n/**\n * Put the mock transport and the connection alias in place before anything\n * constructs KosCore.\n *\n * KosCore picks its transport and reads its alias in the constructor, and\n * registering a model calls `KosCore.getInstance()`, so registration cannot\n * come first.\n */\nfunction prepareTransport(alias?: string): void {\n if (prepared) {\n return;\n }\n prepared = true;\n KosMock.configure({ standalone: true });\n KosCore.getInstance({ connectionAlias: alias });\n}\n\nfunction bootCore(\n registration: IKosRegistry,\n options: BootKosCoreOptions\n): Promise<IKosCoreManager> {\n if (!booted) {\n prepareTransport(options.alias);\n const core = KosCore.create(registration, false, options.alias);\n booted = core.whenReady().then(() => core);\n }\n return booted;\n}\n\nconst FIXTURE_TEST_DEFAULTS: KosMockPlaybackOptions = {\n ignoreLatency: true,\n pushes: \"manual\",\n};\n\nfunction buildBootBuilder(): KosCoreBootBuilder {\n const registrations: (() => void)[] = [];\n const mockInstalls: (() => Promise<void> | void)[] = [];\n const preloadModels: Preloaded[] = [];\n let alias: string | undefined;\n\n const builder: KosCoreBootBuilder = {\n model: (registration, preload) => {\n registrations.push(() =>\n RegistrationManager.model.register(builder)(registration, preload)\n );\n return builder;\n },\n preload: (model) => {\n preloadModels.push(model);\n return builder;\n },\n companion: (parentType, companion) => {\n registrations.push(() =>\n RegistrationManager.companion.register(builder)(parentType, companion)\n );\n return builder;\n },\n legacy: (type, registration) => {\n registrations.push(() =>\n RegistrationManager.model.registerLegacyModel(builder)(\n type,\n registration\n )\n );\n return builder;\n },\n alias: (value) => {\n alias = value;\n return builder;\n },\n setup: (module) => {\n mockInstalls.push(async () => {\n await module(KosMock);\n });\n return builder;\n },\n fixture: (fixture, options) => {\n mockInstalls.push(() => {\n KosMock.loadFixture(fixture, { ...FIXTURE_TEST_DEFAULTS, ...options });\n });\n return builder;\n },\n boot: async () => {\n // Mocks first, in call order, before the transport exists.\n for (const install of mockInstalls.splice(0)) {\n await install();\n }\n prepareTransport(alias);\n KosModelRegistry.core.models();\n registrations.splice(0).forEach((register) => register());\n return bootCore({ models: {}, preloadModels }, { alias });\n },\n };\n\n return builder;\n}\n\n/**\n * Open a registration chain, then `boot()` it.\n *\n * Idempotent per module instance: the first `boot()` boots and later calls\n * return the same core. KosCore and the model manager are process-global, so\n * a test file gets one core and one set of singletons.\n *\n * Register the routes the models need before calling `boot()` so nothing races\n * the boot requests, either with `KosMock.get(...)` above the chain or with\n * `.setup()` / `.fixture()` on it.\n *\n * @example\n * ```ts\n * await bootKosCore()\n * .setup(boardBaseline) // fixtures/setups/board-baseline.mjs\n * .fixture(pourOk) // fixtures/pour-ok.json\n * .model(Board)\n * .boot();\n * ```\n */\nexport function bootKosCore(): KosCoreBootBuilder;\n/**\n * Boot KosCore from an assembled registry.\n *\n * For callers that already hold an `IKosRegistry`; it boots exactly the\n * registry it is given. A test registering its own models should use the\n * no-argument chain, which takes registration beans directly and registers the\n * SDK's core models.\n *\n * @param registration Models under test, e.g. `{ models: {...}, preloadModels: [] }`.\n */\nexport function bootKosCore(\n registration: IKosRegistry,\n options?: BootKosCoreOptions\n): Promise<IKosCoreManager>;\nexport function bootKosCore(\n registration?: IKosRegistry,\n options: BootKosCoreOptions = {}\n): KosCoreBootBuilder | Promise<IKosCoreManager> {\n return registration ? bootCore(registration, options) : buildBootBuilder();\n}\n\n/**\n * Resolves once `predicate` holds, or rejects with a message naming `label`\n * after the timeout.\n *\n * Model reactions are asynchronous, so a test that changes an input and asserts\n * at once reads the old value. Polling for the outcome is faster than sleeping\n * for a fixed interval and fails with a clear message when the reaction never\n * fires.\n *\n * @param label What is being waited for, quoted back in the timeout message.\n */\nexport async function until(\n predicate: () => boolean,\n label: string,\n timeoutMs = 2000\n): Promise<void> {\n const deadline = Date.now() + timeoutMs;\n while (!predicate()) {\n if (Date.now() > deadline) {\n throw new Error(`timed out waiting for ${label}`);\n }\n await new Promise((resolve) => setTimeout(resolve, 5));\n }\n}\n"],"names":[],"mappings":";;;AA8DA,IAAI;AACJ,IAAI,WAAW;AA2Ef,SAAS,iBAAiB,OAAsB;AAC9C,MAAI,UAAU;AACZ;AAAA,EACF;AACA,aAAW;AACX,UAAQ,UAAU,EAAE,YAAY,KAAA,CAAM;AACtC,UAAQ,YAAY,EAAE,iBAAiB,MAAA,CAAO;AAChD;AAEA,SAAS,SACP,cACA,SAC0B;AAC1B,MAAI,CAAC,QAAQ;AACX,qBAAiB,QAAQ,KAAK;AAC9B,UAAM,OAAO,QAAQ,OAAO,cAAc,OAAO,QAAQ,KAAK;AAC9D,aAAS,KAAK,UAAA,EAAY,KAAK,MAAM,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAEA,MAAM,wBAAgD;AAAA,EACpD,eAAe;AAAA,EACf,QAAQ;AACV;AA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AAE,QAAQ,CAAA,GAAI,cAAA,GAAiB,EAAE,OAAO;AAAA,IAC1D;AAAA,EAAA;AAGF,SAAO;AACT;AAqCO,SAAS,YACd,cACA,UAA8B,IACiB;AAC/C,SAAO,eAAe,SAAS,cAAc,OAAO,IAAI,iBAAA;AAC1D;AAaA,eAAsB,MACpB,WACA,OACA,YAAY,KACG;AACf,QAAM,WAAW,KAAK,IAAA,IAAQ;AAC9B,SAAO,CAAC,aAAa;AACnB,QAAI,KAAK,IAAA,IAAQ,UAAU;AACzB,YAAM,IAAI,MAAM,yBAAyB,KAAK,EAAE;AAAA,IAClD;AACA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,CAAC,CAAC;AAAA,EACvD;AACF;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const buttonRoot: import('@emotion/react').SerializedStyles;
|
|
2
|
+
export declare const positions: {
|
|
3
|
+
readonly "bottom-left": import('@emotion/react').SerializedStyles;
|
|
4
|
+
readonly "bottom-right": import('@emotion/react').SerializedStyles;
|
|
5
|
+
readonly "top-left": import('@emotion/react').SerializedStyles;
|
|
6
|
+
readonly "top-right": import('@emotion/react').SerializedStyles;
|
|
7
|
+
};
|
|
8
|
+
export declare const statusText: import('@emotion/react').SerializedStyles;
|
|
9
|
+
//# sourceMappingURL=connection-dev-button-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-dev-button-styles.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/ui/components/connection-dev-button/connection-dev-button-styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,2CAoBtB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;CAiBZ,CAAC;AAEX,eAAO,MAAM,UAAU,2CAItB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ConnectionDevState } from './use-connection-dev-state';
|
|
3
|
+
export { useConnectionDevState, type ConnectionDevState, type ConnectionDevStatus, } from './use-connection-dev-state';
|
|
4
|
+
/**
|
|
5
|
+
* Props for ConnectionDevButton.
|
|
6
|
+
*
|
|
7
|
+
* @kosService core.connection-dev-button
|
|
8
|
+
* @kosApiLevel 25
|
|
9
|
+
*/
|
|
10
|
+
export interface ConnectionDevButtonProps {
|
|
11
|
+
/** Screen corner the button is fixed to. Default: "bottom-right". */
|
|
12
|
+
position?: "bottom-left" | "bottom-right" | "top-left" | "top-right";
|
|
13
|
+
/** Button label. Default: "Drop connection". */
|
|
14
|
+
label?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Fully replace the button's content with a custom renderer. Receives the
|
|
18
|
+
* connection state. If provided, the default label and status are not
|
|
19
|
+
* rendered.
|
|
20
|
+
*/
|
|
21
|
+
renderContent?: (state: ConnectionDevState) => React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Minimal, unbranded development button that drops the KOS websocket so the
|
|
25
|
+
* reconnect path can be exercised from any KOS application. Shows the live
|
|
26
|
+
* connection status and, on click, calls the transport's `dropConnection()`;
|
|
27
|
+
* the transport reconnects on its own and KOS Core runs its reconnect
|
|
28
|
+
* sequence. Disabled while the core is not online.
|
|
29
|
+
*
|
|
30
|
+
* Pair with ReconnectingOverlay to see the reconnect as users do.
|
|
31
|
+
*
|
|
32
|
+
* @kosService core.connection-dev-button
|
|
33
|
+
* @kosApiLevel 25
|
|
34
|
+
*/
|
|
35
|
+
export declare const ConnectionDevButton: React.FC<ConnectionDevButtonProps>;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/ui/components/connection-dev-button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;AAOpC,OAAO,EACL,qBAAqB,EACrB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,4BAA4B,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC;IACrE,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,KAAK,CAAC,SAAS,CAAC;CAChE;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA0BlE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection status shown by ConnectionDevButton.
|
|
3
|
+
*
|
|
4
|
+
* @kosService core.use-connection-dev-state
|
|
5
|
+
* @kosApiLevel 25
|
|
6
|
+
*/
|
|
7
|
+
export type ConnectionDevStatus = "online" | "offline" | "reconnecting";
|
|
8
|
+
/**
|
|
9
|
+
* Snapshot of the connection, returned by useConnectionDevState.
|
|
10
|
+
*
|
|
11
|
+
* @kosService core.use-connection-dev-state
|
|
12
|
+
* @kosApiLevel 25
|
|
13
|
+
*/
|
|
14
|
+
export interface ConnectionDevState {
|
|
15
|
+
/**
|
|
16
|
+
* `reconnecting` while KOS Core reloads or runs its reconnect sequence,
|
|
17
|
+
* otherwise `online` or `offline` from the core's connection.
|
|
18
|
+
*/
|
|
19
|
+
status: ConnectionDevStatus;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Headless state hook for ConnectionDevButton. Tracks KOS Core's `isOnline`
|
|
23
|
+
* and `reloading` reactively and reports them as one status.
|
|
24
|
+
*
|
|
25
|
+
* @kosService core.use-connection-dev-state
|
|
26
|
+
* @kosApiLevel 25
|
|
27
|
+
*/
|
|
28
|
+
export declare const useConnectionDevState: () => ConnectionDevState;
|
|
29
|
+
//# sourceMappingURL=use-connection-dev-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-connection-dev-state.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/ui/components/connection-dev-button/use-connection-dev-state.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,SAAS,GAAG,cAAc,CAAC;AAExE;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAOD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAO,kBAgBxC,CAAC"}
|
package/ui/components/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/ui/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,cAAc,kBAAkB,CAAC;AAEjC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,oBAAoB,CAAC;AAEnC,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/ui/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,cAAc,kBAAkB,CAAC;AAEjC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,oBAAoB,CAAC;AAEnC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,yBAAyB,CAAC"}
|
|
@@ -5,17 +5,18 @@ interface UseImageRendererProps {
|
|
|
5
5
|
src: string;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* A custom hook that initializes and manages
|
|
8
|
+
* A custom hook that initializes and manages an image renderer, streaming the
|
|
9
|
+
* image as frames at 5 fps.
|
|
9
10
|
*
|
|
10
|
-
* @param {UseImageRendererProps} props - The properties required to configure the
|
|
11
|
+
* @param {UseImageRendererProps} props - The properties required to configure the image renderer.
|
|
11
12
|
* @param {number} props.width - The width of the image frame.
|
|
12
13
|
* @param {number} props.height - The height of the image frame.
|
|
13
14
|
* @param {Function} props.onFrame - A callback function invoked for each rendered frame.
|
|
14
15
|
* @param {string} props.src - The source URL or path of the image to be rendered.
|
|
15
16
|
*
|
|
16
17
|
* @returns {readonly [boolean, () => void]} A tuple containing:
|
|
17
|
-
* - `isStreaming` (boolean): Indicates whether the
|
|
18
|
-
* - `startStreaming` (Function): A function to start
|
|
18
|
+
* - `isStreaming` (boolean): Indicates whether the image is currently streaming.
|
|
19
|
+
* - `startStreaming` (Function): A function to start streaming.
|
|
19
20
|
*/
|
|
20
21
|
export declare const useImageRenderer: ({ width, height, onFrame, src, }: UseImageRendererProps) => readonly [boolean, () => void];
|
|
21
22
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-image-renderer.d.ts","sourceRoot":"","sources":["../../../../../../../packages/kos-ui-sdk/src/ui/features/canvas/hooks/use-image-renderer.ts"],"names":[],"mappings":"AAIA,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5C,GAAG,EAAE,MAAM,CAAC;CACb;AACD
|
|
1
|
+
{"version":3,"file":"use-image-renderer.d.ts","sourceRoot":"","sources":["../../../../../../../packages/kos-ui-sdk/src/ui/features/canvas/hooks/use-image-renderer.ts"],"names":[],"mappings":"AAIA,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5C,GAAG,EAAE,MAAM,CAAC;CACb;AACD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAAI,kCAM9B,qBAAqB,mCAWvB,CAAC"}
|
|
@@ -39,21 +39,11 @@ interface UseFunctionWarmupOptions {
|
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
41
|
* ```tsx
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* if (arg?.__warmup) {
|
|
46
|
-
* console.log('Warming up...');
|
|
47
|
-
* } else {
|
|
48
|
-
* console.log('Executing function...');
|
|
49
|
-
* }
|
|
42
|
+
* const lookup = (arg?: string | WarmupMarker) => {
|
|
43
|
+
* if (typeof arg === "object" && arg.__warmup) return;
|
|
44
|
+
* // ...
|
|
50
45
|
* };
|
|
51
|
-
*
|
|
52
|
-
* function MyComponent() {
|
|
53
|
-
* useFunctionWarmup(myFunction, { intervalMs: 60000, immediate: true });
|
|
54
|
-
*
|
|
55
|
-
* return <div>My Component</div>;
|
|
56
|
-
* }
|
|
46
|
+
* useFunctionWarmup(lookup, { intervalMs: 60000 });
|
|
57
47
|
* ```
|
|
58
48
|
*/
|
|
59
49
|
export declare function useFunctionWarmup<T extends (arg?: any) => any>(fn: Warmupable<T>, options?: UseFunctionWarmupOptions): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-function-warmup.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/ui/hooks/use-function-warmup.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,CAAC;AAG9C,KAAK,UAAU,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,IAAI,CAC9C,GAAG,CAAC,EAAE,GAAG,GAAG,YAAY,KACrB,UAAU,CAAC,CAAC,CAAC,CAAC;AAEnB,UAAU,wBAAwB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED
|
|
1
|
+
{"version":3,"file":"use-function-warmup.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/ui/hooks/use-function-warmup.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,CAAC;AAG9C,KAAK,UAAU,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,IAAI,CAC9C,GAAG,CAAC,EAAE,GAAG,GAAG,YAAY,KACrB,UAAU,CAAC,CAAC,CAAC,CAAC;AAEnB,UAAU,wBAAwB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,GAAG,EAC5D,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,EACjB,OAAO,GAAE,wBAA6B,QA0BvC"}
|
|
@@ -3,19 +3,18 @@ import { ChangeEvent } from 'react';
|
|
|
3
3
|
type SelectCallback = string | ChangeEvent<HTMLSelectElement>;
|
|
4
4
|
type DateFormatMap<T extends {} = any> = (format: DateFormatOptions) => T;
|
|
5
5
|
/**
|
|
6
|
-
* The data returned from the
|
|
7
|
-
* @typeParam
|
|
8
|
-
* @typeParam T - the type of the options returned from the regionMap function.
|
|
6
|
+
* The data returned from the useKosDateFormats hook.
|
|
7
|
+
* @typeParam T - the type of the options returned from the dateFormatMap function.
|
|
9
8
|
*/
|
|
10
9
|
export interface KosDateFormatHookData<T extends {} = any> {
|
|
11
|
-
/**the
|
|
10
|
+
/** the ids of the available date formats. */
|
|
12
11
|
raw: string[];
|
|
13
|
-
/**the region model
|
|
12
|
+
/** the region info model. */
|
|
14
13
|
regionModel?: RegionInfoModel;
|
|
15
|
-
/**the currently selected
|
|
14
|
+
/** the currently selected date format. */
|
|
16
15
|
selectedDateFormat: string;
|
|
17
16
|
dateFormatId: string;
|
|
18
|
-
/**
|
|
17
|
+
/** updates the selected date format. */
|
|
19
18
|
updateDateFormat: (e: SelectCallback) => void;
|
|
20
19
|
/**the props that can be spread into a select box component. */
|
|
21
20
|
props: {
|
|
@@ -25,30 +24,17 @@ export interface KosDateFormatHookData<T extends {} = any> {
|
|
|
25
24
|
};
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
27
|
+
* Manages the region's date format: the available formats, the selected
|
|
28
|
+
* format, and props for a date format select box.
|
|
29
|
+
*
|
|
30
|
+
* @param dateFormatMap - maps a date format to a select-box option. The
|
|
31
|
+
* default returns an `<option>` with the format as value and label.
|
|
32
32
|
* @returns KosDateFormatHookData - the data returned from the hook.
|
|
33
33
|
* @example
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* ```typescript
|
|
40
|
-
* interface RegionData extends RegionServices.BaseRegionResponse {
|
|
41
|
-
* rfidRegion: string;
|
|
42
|
-
* }
|
|
43
|
-
* const { regionSelectProps, regionModel, regionData, selectedRegion, updateRegion } = useKosRegions<RegionData>();
|
|
44
|
-
* const { options, ...selectAttributes } = regionSelectProps;
|
|
45
|
-
* ...
|
|
46
|
-
* <div>
|
|
47
|
-
* <label>Select region: </label>
|
|
48
|
-
* <select {...selectAttributes}>{options}</select>
|
|
49
|
-
* </div>
|
|
50
|
-
* <div>Selected Region: {selectedRegion}</div>
|
|
51
|
-
* <div>Region Data: {regionData?.rfidRegion}</div>
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const { props } = useKosDateFormats();
|
|
36
|
+
* const { options, ...selectAttributes } = props;
|
|
37
|
+
* return <select {...selectAttributes}>{options}</select>;
|
|
52
38
|
* ```
|
|
53
39
|
*/
|
|
54
40
|
export declare const useKosDateFormats: <T extends {} = any>(dateFormatMap?: DateFormatMap<T>) => KosDateFormatHookData<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-kos-date-formats.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/ui/hooks/use-kos-date-formats.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EAEhB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAoC,MAAM,OAAO,CAAC;AAGtE,KAAK,cAAc,GAAG,MAAM,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAC9D,KAAK,aAAa,CAAC,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,iBAAiB,KAAK,CAAC,CAAC;AAO1E
|
|
1
|
+
{"version":3,"file":"use-kos-date-formats.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/ui/hooks/use-kos-date-formats.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EAEhB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAoC,MAAM,OAAO,CAAC;AAGtE,KAAK,cAAc,GAAG,MAAM,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAC9D,KAAK,aAAa,CAAC,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,iBAAiB,KAAK,CAAC,CAAC;AAO1E;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,EAAE,GAAG,GAAG;IACvD,6CAA6C;IAC7C,GAAG,EAAE,MAAM,EAAE,CAAC;IAEd,6BAA6B;IAC7B,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B,0CAA0C;IAC1C,kBAAkB,EAAE,MAAM,CAAC;IAE3B,YAAY,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,gBAAgB,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE9C,+DAA+D;IAC/D,KAAK,EAAE;QACL,QAAQ,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;QACtC,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,EAAE,CAAC;KACd,CAAC;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,EAAE,GAAG,GAAG,EAClD,gBAAe,aAAa,CAAC,CAAC,CAAsB,KACnD,qBAAqB,CAAC,CAAC,CAkEzB,CAAC"}
|
|
@@ -12,63 +12,12 @@ type OptionMap<T extends {} = any> = (option: string) => T;
|
|
|
12
12
|
* @returns An object containing timezone options, raw timezone data, the selected timezone, and functions to handle updates.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* import { useKosTimeZones } from '@kosdev-code/kos-ui-sdk';
|
|
18
|
-
*
|
|
19
|
-
* const MyComponent: React.FC = () => {
|
|
20
|
-
* // Using the hook with the default option mapper
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const TimeZonePicker = kosComponent(() => {
|
|
21
17
|
* const { selectProps } = useKosTimeZones();
|
|
22
|
-
*
|
|
23
|
-
* return
|
|
24
|
-
* <div>
|
|
25
|
-
* <label>Select Timezone:</label>
|
|
26
|
-
* <select {...selectProps}>
|
|
27
|
-
* {selectProps.options}
|
|
28
|
-
* </select>
|
|
29
|
-
* </div>
|
|
30
|
-
* );
|
|
31
|
-
* };
|
|
32
|
-
*
|
|
33
|
-
* export default MyComponent;
|
|
34
|
-
* ```
|
|
35
|
-
* @example
|
|
36
|
-
* Using the hook with a custom component and regionMap function:
|
|
37
|
-
*
|
|
38
|
-
* ```typescript
|
|
39
|
-
* import React from 'react';
|
|
40
|
-
* import { useKosTimeZones } from '@kosdev-code/kos-ui-sdk';
|
|
41
|
-
*
|
|
42
|
-
* // Custom component that expects an options prop
|
|
43
|
-
* const CustomSelectComponent: React.FC<{ options: { label: string; value: string }[] }> = ({ options }) => {
|
|
44
|
-
* return (
|
|
45
|
-
* <select>
|
|
46
|
-
* {options.map(option => (
|
|
47
|
-
* <option key={option.value} value={option.value}>{option.label}</option>
|
|
48
|
-
* ))}
|
|
49
|
-
* </select>
|
|
50
|
-
* );
|
|
51
|
-
* };
|
|
52
|
-
*
|
|
53
|
-
* // Custom regionMap function to map timezones to the required format for CustomSelectComponent
|
|
54
|
-
* const customRegionMap = (timezone: string) => ({
|
|
55
|
-
* label: `Timezone: ${timezone}`,
|
|
56
|
-
* value: timezone
|
|
18
|
+
* const { options, ...props } = selectProps;
|
|
19
|
+
* return <select {...props}>{options}</select>;
|
|
57
20
|
* });
|
|
58
|
-
*
|
|
59
|
-
* const MyComponent: React.FC = () => {
|
|
60
|
-
* // Using the hook with the custom regionMap function
|
|
61
|
-
* const { options } = useKosTimeZones(customRegionMap);
|
|
62
|
-
*
|
|
63
|
-
* return (
|
|
64
|
-
* <div>
|
|
65
|
-
* <label>Select Timezone:</label>
|
|
66
|
-
* <CustomSelectComponent options={options} />
|
|
67
|
-
* </div>
|
|
68
|
-
* );
|
|
69
|
-
* };
|
|
70
|
-
*
|
|
71
|
-
* export default MyComponent;
|
|
72
21
|
* ```
|
|
73
22
|
*/
|
|
74
23
|
export declare const useKosTimeZones: <T extends {} = any>(optionsMap?: OptionMap<T>) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-kos-region-timezones.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/ui/hooks/use-kos-region-timezones.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoC,MAAM,OAAO,CAAC;AAEtE,OAAO,EAIL,eAAe,EAGhB,MAAM,cAAc,CAAC;AAGtB,KAAK,cAAc,GAAG,MAAM,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAC9D,KAAK,SAAS,CAAC,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,CAAC;AAY3D
|
|
1
|
+
{"version":3,"file":"use-kos-region-timezones.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/ui/hooks/use-kos-region-timezones.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoC,MAAM,OAAO,CAAC;AAEtE,OAAO,EAIL,eAAe,EAGhB,MAAM,cAAc,CAAC;AAGtB,KAAK,cAAc,GAAG,MAAM,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAC9D,KAAK,SAAS,CAAC,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,CAAC;AAY3D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,EAAE,GAAG,GAAG,EAChD,aAAY,SAAS,CAAC,CAAC,CAAsB;;;;;;wBA+CR,cAAc;;sBAAd,cAAc;;;;CA0BpD,CAAC"}
|