@kosdev-code/kos-ui-sdk 0.1.0-next.944 → 0.1.0-next.948

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.
Files changed (281) hide show
  1. package/common/events/async-event-bus.d.ts +2 -11
  2. package/common/events/async-event-bus.d.ts.map +1 -1
  3. package/common/events/eventBus.d.ts +1 -18
  4. package/common/events/eventBus.d.ts.map +1 -1
  5. package/core/core/decorators/kos-child.d.ts +2 -3
  6. package/core/core/decorators/kos-child.d.ts.map +1 -1
  7. package/core/core/decorators/kos-companion.d.ts +25 -87
  8. package/core/core/decorators/kos-companion.d.ts.map +1 -1
  9. package/core/core/decorators/kos-container-aware.d.ts +67 -358
  10. package/core/core/decorators/kos-container-aware.d.ts.map +1 -1
  11. package/core/core/decorators/kos-execute-service-request.d.ts +7 -11
  12. package/core/core/decorators/kos-execute-service-request.d.ts.map +1 -1
  13. package/core/core/decorators/kos-execution-context.d.ts +14 -31
  14. package/core/core/decorators/kos-execution-context.d.ts.map +1 -1
  15. package/core/core/decorators/kos-future-aware.d.ts +21 -74
  16. package/core/core/decorators/kos-future-aware.d.ts.map +1 -1
  17. package/core/core/decorators/kos-http-decorators.d.ts +18 -62
  18. package/core/core/decorators/kos-http-decorators.d.ts.map +1 -1
  19. package/core/core/decorators/kos-logger-aware.d.ts +10 -60
  20. package/core/core/decorators/kos-logger-aware.d.ts.map +1 -1
  21. package/core/core/decorators/kos-model-effect.d.ts +10 -9
  22. package/core/core/decorators/kos-model-effect.d.ts.map +1 -1
  23. package/core/core/decorators/kos-multiple-future-aware.d.ts +21 -94
  24. package/core/core/decorators/kos-multiple-future-aware.d.ts.map +1 -1
  25. package/core/core/decorators/kos-reload-aware.d.ts +12 -16
  26. package/core/core/decorators/kos-reload-aware.d.ts.map +1 -1
  27. package/core/core/decorators/kos-service-request.d.ts +80 -238
  28. package/core/core/decorators/kos-service-request.d.ts.map +1 -1
  29. package/core/core/decorators/kos-state-machine.d.ts +35 -275
  30. package/core/core/decorators/kos-state-machine.d.ts.map +1 -1
  31. package/core/core/decorators/kos-trouble-aware.d.ts +9 -43
  32. package/core/core/decorators/kos-trouble-aware.d.ts.map +1 -1
  33. package/core/core/decorators/kos-view-model.d.ts +20 -100
  34. package/core/core/decorators/kos-view-model.d.ts.map +1 -1
  35. package/core/core/decorators/kosTopicHandler.d.ts +28 -89
  36. package/core/core/decorators/kosTopicHandler.d.ts.map +1 -1
  37. package/core/core/indexing/index.d.ts +2 -4
  38. package/core/core/indexing/index.d.ts.map +1 -1
  39. package/core/core/indexing/kos-container-index-aware.d.ts +17 -48
  40. package/core/core/indexing/kos-container-index-aware.d.ts.map +1 -1
  41. package/core/core/indexing/kos-index-aware.d.ts +11 -37
  42. package/core/core/indexing/kos-index-aware.d.ts.map +1 -1
  43. package/core/core/kos-container-model.d.ts +11 -32
  44. package/core/core/kos-container-model.d.ts.map +1 -1
  45. package/core/core/kos-data-container.d.ts +6 -6
  46. package/core/core/kos-data-container.d.ts.map +1 -1
  47. package/core/core/kosCore.d.ts +3 -3
  48. package/core/core/kosModelManager.d.ts +2 -3
  49. package/core/core/kosModelManager.d.ts.map +1 -1
  50. package/core/core/model/kos-offline-queue.d.ts +1 -1
  51. package/core/core/model/service-response-store.d.ts +2 -15
  52. package/core/core/model/service-response-store.d.ts.map +1 -1
  53. package/core/core/services/app-startup-service.d.ts +5 -13
  54. package/core/core/services/app-startup-service.d.ts.map +1 -1
  55. package/core/core/services/intent-service.d.ts +3 -12
  56. package/core/core/services/intent-service.d.ts.map +1 -1
  57. package/core/core/transport/mock/mock-frames.d.ts +3 -3
  58. package/core/types/model.d.ts +4 -8
  59. package/core/types/model.d.ts.map +1 -1
  60. package/core/types/service-response-store.d.ts +3 -11
  61. package/core/types/service-response-store.d.ts.map +1 -1
  62. package/core/types/utils/kos-fetch.d.ts +25 -37
  63. package/core/types/utils/kos-fetch.d.ts.map +1 -1
  64. package/core/util/abortable-when.d.ts +5 -6
  65. package/core/util/abortable-when.d.ts.map +1 -1
  66. package/core/util/ancestor-path-visitor.d.ts +14 -20
  67. package/core/util/ancestor-path-visitor.d.ts.map +1 -1
  68. package/core/util/container-utils.d.ts +26 -159
  69. package/core/util/container-utils.d.ts.map +1 -1
  70. package/core/util/date-utils.d.ts +9 -58
  71. package/core/util/date-utils.d.ts.map +1 -1
  72. package/core/util/debounce.d.ts +1 -8
  73. package/core/util/debounce.d.ts.map +1 -1
  74. package/core/util/kos-fetch.d.ts +1 -1
  75. package/core/util/kos-fetch.d.ts.map +1 -1
  76. package/core/util/kos-model-utils.d.ts +10 -11
  77. package/core/util/kos-model-utils.d.ts.map +1 -1
  78. package/core/util/model-attribute-utils.d.ts +5 -22
  79. package/core/util/model-attribute-utils.d.ts.map +1 -1
  80. package/core/util/promise-utils.d.ts +1 -26
  81. package/core/util/promise-utils.d.ts.map +1 -1
  82. package/core/util/service-factory.d.ts +5 -23
  83. package/core/util/service-factory.d.ts.map +1 -1
  84. package/core/util/service-request-error.d.ts +3 -5
  85. package/core/util/service-request-error.d.ts.map +1 -1
  86. package/core/util/service-response.d.ts +12 -67
  87. package/core/util/service-response.d.ts.map +1 -1
  88. package/core/util/transport-not-ready-error.d.ts +11 -13
  89. package/core/util/transport-not-ready-error.d.ts.map +1 -1
  90. package/core/util/when-ready.d.ts +1 -8
  91. package/core/util/when-ready.d.ts.map +1 -1
  92. package/index.cjs +12 -21
  93. package/index.cjs.map +1 -1
  94. package/index.js +13 -22
  95. package/index.js.map +1 -1
  96. package/models/decorators/future-service.d.ts +7 -7
  97. package/models/models/browser-router/browser-router-model.d.ts +10 -39
  98. package/models/models/browser-router/browser-router-model.d.ts.map +1 -1
  99. package/models/models/browser-router/browser-router-registration.d.ts +5 -77
  100. package/models/models/browser-router/browser-router-registration.d.ts.map +1 -1
  101. package/models/models/browser-router/types/index.d.ts +2 -16
  102. package/models/models/canvas-dispatcher/canvas-dispatcher-registration.d.ts +5 -77
  103. package/models/models/canvas-dispatcher/canvas-dispatcher-registration.d.ts.map +1 -1
  104. package/models/models/canvas-renderer/canvas-renderer-registration.d.ts +5 -75
  105. package/models/models/canvas-renderer/canvas-renderer-registration.d.ts.map +1 -1
  106. package/models/models/config-bean/config-bean-model-builder.d.ts +4 -11
  107. package/models/models/config-bean/config-bean-model-builder.d.ts.map +1 -1
  108. package/models/models/config-bean/config-bean-model.d.ts +14 -66
  109. package/models/models/config-bean/config-bean-model.d.ts.map +1 -1
  110. package/models/models/config-bean-prop/config-bean-prop-model.d.ts +15 -62
  111. package/models/models/config-bean-prop/config-bean-prop-model.d.ts.map +1 -1
  112. package/models/models/config-bean-prop/types/index.d.ts +34 -215
  113. package/models/models/device/device-model.d.ts +20 -199
  114. package/models/models/device/device-model.d.ts.map +1 -1
  115. package/models/models/device/device-registration.d.ts +7 -87
  116. package/models/models/device/device-registration.d.ts.map +1 -1
  117. package/models/models/device/types/index.d.ts +5 -34
  118. package/models/models/future/future-aware.d.ts +7 -71
  119. package/models/models/future/future-aware.d.ts.map +1 -1
  120. package/models/models/future/future-model-builder.d.ts +2 -2
  121. package/models/models/future/future-model.d.ts +3 -23
  122. package/models/models/future/future-model.d.ts.map +1 -1
  123. package/models/models/future/future-types.d.ts +28 -145
  124. package/models/models/future/future-types.d.ts.map +1 -1
  125. package/models/models/key-value/key-value-model.d.ts +12 -72
  126. package/models/models/key-value/key-value-model.d.ts.map +1 -1
  127. package/models/models/key-value/key-value-registration.d.ts +5 -77
  128. package/models/models/key-value/key-value-registration.d.ts.map +1 -1
  129. package/models/models/key-value/services/key-value-services.d.ts +13 -72
  130. package/models/models/key-value/services/key-value-services.d.ts.map +1 -1
  131. package/models/models/key-value/types/index.d.ts +3 -46
  132. package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts +32 -99
  133. package/models/models/kos-expression-evaluator/kos-expression-evaluator-model.d.ts.map +1 -1
  134. package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts +2 -12
  135. package/models/models/kos-expression-evaluator/services/kos-expression-evaluator-services.d.ts.map +1 -1
  136. package/models/models/kos-log-manager/kos-log-manager-model.d.ts +7 -46
  137. package/models/models/kos-log-manager/kos-log-manager-model.d.ts.map +1 -1
  138. package/models/models/kos-log-manager/kos-log-manager-registration.d.ts +5 -80
  139. package/models/models/kos-log-manager/kos-log-manager-registration.d.ts.map +1 -1
  140. package/models/models/kos-log-manager/types/index.d.ts +13 -156
  141. package/models/models/kos-time/kos-time-model.d.ts +8 -39
  142. package/models/models/kos-time/kos-time-model.d.ts.map +1 -1
  143. package/models/models/kos-time/kos-time-registration.d.ts +6 -73
  144. package/models/models/kos-time/kos-time-registration.d.ts.map +1 -1
  145. package/models/models/kos-time/types/index.d.ts +3 -58
  146. package/models/models/log-block/log-block-container-model.d.ts +2 -118
  147. package/models/models/log-block/log-block-container-model.d.ts.map +1 -1
  148. package/models/models/log-block/log-block-container-registration.d.ts +5 -75
  149. package/models/models/log-block/log-block-container-registration.d.ts.map +1 -1
  150. package/models/models/log-block/log-block-model.d.ts +5 -168
  151. package/models/models/log-block/log-block-model.d.ts.map +1 -1
  152. package/models/models/log-block/log-block-registration.d.ts +5 -75
  153. package/models/models/log-block/log-block-registration.d.ts.map +1 -1
  154. package/models/models/log-block/types/index.d.ts +14 -81
  155. package/models/models/log-stream/log-stream-container-model.d.ts +8 -35
  156. package/models/models/log-stream/log-stream-container-model.d.ts.map +1 -1
  157. package/models/models/log-stream/log-stream-container-registration.d.ts +5 -75
  158. package/models/models/log-stream/log-stream-container-registration.d.ts.map +1 -1
  159. package/models/models/log-stream/log-stream-model.d.ts +8 -29
  160. package/models/models/log-stream/log-stream-model.d.ts.map +1 -1
  161. package/models/models/log-stream/log-stream-registration.d.ts +5 -75
  162. package/models/models/log-stream/log-stream-registration.d.ts.map +1 -1
  163. package/models/models/log-stream/types/index.d.ts +5 -60
  164. package/models/models/network-interface/network-interface-container-model.d.ts +6 -35
  165. package/models/models/network-interface/network-interface-container-model.d.ts.map +1 -1
  166. package/models/models/network-interface/network-interface-container-registration.d.ts +5 -73
  167. package/models/models/network-interface/network-interface-container-registration.d.ts.map +1 -1
  168. package/models/models/network-interface/network-interface-model.d.ts +5 -43
  169. package/models/models/network-interface/network-interface-model.d.ts.map +1 -1
  170. package/models/models/network-interface/network-interface-registration.d.ts +5 -73
  171. package/models/models/network-interface/network-interface-registration.d.ts.map +1 -1
  172. package/models/models/network-interface/types/index.d.ts +2 -16
  173. package/models/models/ota/ota-model.d.ts +11 -39
  174. package/models/models/ota/ota-model.d.ts.map +1 -1
  175. package/models/models/ota/ota-registration.d.ts +5 -77
  176. package/models/models/ota/ota-registration.d.ts.map +1 -1
  177. package/models/models/ota/types/index.d.ts +2 -141
  178. package/models/models/region-info/types/index.d.ts +19 -99
  179. package/models/models/region-info/types/index.d.ts.map +1 -1
  180. package/models/models/software-info/services/software-info-services.d.ts +2 -14
  181. package/models/models/software-info/services/software-info-services.d.ts.map +1 -1
  182. package/models/models/software-info/software-info-model.d.ts +3 -39
  183. package/models/models/software-info/software-info-model.d.ts.map +1 -1
  184. package/models/models/software-info/software-info-registration.d.ts +6 -73
  185. package/models/models/software-info/software-info-registration.d.ts.map +1 -1
  186. package/models/models/software-info/types/index.d.ts +6 -20
  187. package/models/models/state-bean/state-bean-model.d.ts +10 -41
  188. package/models/models/state-bean/state-bean-model.d.ts.map +1 -1
  189. package/models/models/state-bean/state-bean-registration.d.ts +6 -73
  190. package/models/models/state-bean/state-bean-registration.d.ts.map +1 -1
  191. package/models/models/state-bean/types/index.d.ts +4 -84
  192. package/models/models/state-prop/state-prop-model.d.ts +6 -40
  193. package/models/models/state-prop/state-prop-model.d.ts.map +1 -1
  194. package/models/models/state-prop/state-prop-registration.d.ts +6 -73
  195. package/models/models/state-prop/state-prop-registration.d.ts.map +1 -1
  196. package/models/models/state-prop/types/index.d.ts +5 -37
  197. package/models/models/storage-device/storage-device-container-model.d.ts +7 -273
  198. package/models/models/storage-device/storage-device-container-model.d.ts.map +1 -1
  199. package/models/models/storage-device/storage-device-container-registration.d.ts +5 -75
  200. package/models/models/storage-device/storage-device-container-registration.d.ts.map +1 -1
  201. package/models/models/storage-device/storage-device-model.d.ts +3 -49
  202. package/models/models/storage-device/storage-device-model.d.ts.map +1 -1
  203. package/models/models/storage-device/storage-device-registration.d.ts +5 -75
  204. package/models/models/storage-device/storage-device-registration.d.ts.map +1 -1
  205. package/models/models/storage-device/types/index.d.ts +13 -82
  206. package/models/models/studio-properties/studio-properties-model.d.ts +13 -36
  207. package/models/models/studio-properties/studio-properties-model.d.ts.map +1 -1
  208. package/models/models/studio-properties/studio-properties-registration.d.ts +5 -75
  209. package/models/models/studio-properties/studio-properties-registration.d.ts.map +1 -1
  210. package/models/models/studio-properties/types/index.d.ts +2 -24
  211. package/models/models/translation/descriptor-merge.d.ts +13 -17
  212. package/models/models/translation/descriptor-merge.d.ts.map +1 -1
  213. package/models/models/translation/services/translation-services.d.ts +19 -77
  214. package/models/models/translation/services/translation-services.d.ts.map +1 -1
  215. package/models/models/translation/test-harness.d.ts +6 -8
  216. package/models/models/translation/test-harness.d.ts.map +1 -1
  217. package/models/models/translation/translation-container-model.d.ts +7 -59
  218. package/models/models/translation/translation-container-model.d.ts.map +1 -1
  219. package/models/models/translation/translation-container-registration.d.ts +6 -73
  220. package/models/models/translation/translation-container-registration.d.ts.map +1 -1
  221. package/models/models/translation/translation-model.d.ts +17 -50
  222. package/models/models/translation/translation-model.d.ts.map +1 -1
  223. package/models/models/translation/translation-registration.d.ts +6 -73
  224. package/models/models/translation/translation-registration.d.ts.map +1 -1
  225. package/models/models/translation/types/index.d.ts +51 -276
  226. package/models/models/trouble/trouble-registration.d.ts +6 -73
  227. package/models/models/trouble/trouble-registration.d.ts.map +1 -1
  228. package/models/models/trouble/types/index.d.ts +17 -188
  229. package/models/models/trouble/utils/is-trouble-aware.d.ts +4 -85
  230. package/models/models/trouble/utils/is-trouble-aware.d.ts.map +1 -1
  231. package/models/models/usb-update/usb-update-container-registration.d.ts +5 -75
  232. package/models/models/usb-update/usb-update-container-registration.d.ts.map +1 -1
  233. package/models/models/usb-update/usb-update-registration.d.ts +5 -75
  234. package/models/models/usb-update/usb-update-registration.d.ts.map +1 -1
  235. package/models/types/cancellable-promise.d.ts +6 -9
  236. package/models/types/cancellable-promise.d.ts.map +1 -1
  237. package/models/utils/await-future-call.d.ts +9 -21
  238. package/models/utils/await-future-call.d.ts.map +1 -1
  239. package/models/utils/cancellable-future-call.d.ts +8 -19
  240. package/models/utils/cancellable-future-call.d.ts.map +1 -1
  241. package/models/utils/cancellable-service.d.ts +14 -23
  242. package/models/utils/cancellable-service.d.ts.map +1 -1
  243. package/models/utils/conversion-utils.d.ts +8 -48
  244. package/models/utils/conversion-utils.d.ts.map +1 -1
  245. package/models/utils/persistence-store.d.ts +1 -1
  246. package/models/utils/service.d.ts +14 -48
  247. package/models/utils/service.d.ts.map +1 -1
  248. package/models/utils/services/kos/daily/service.d.ts +4 -4
  249. package/models/utils/services/vfs/daily/service.d.ts +4 -4
  250. package/models/utils/timer-manager.d.ts.map +1 -1
  251. package/package.json +3 -3
  252. package/{software-info-registration-GUbTY4KD.cjs → software-info-registration-CY_E6Rw7.cjs} +85 -368
  253. package/software-info-registration-CY_E6Rw7.cjs.map +1 -0
  254. package/{software-info-registration-CKlTQPet.js → software-info-registration-CuuEsH8v.js} +85 -368
  255. package/software-info-registration-CuuEsH8v.js.map +1 -0
  256. package/testing/index.d.ts +28 -33
  257. package/testing/index.d.ts.map +1 -1
  258. package/testing.cjs +1 -1
  259. package/testing.cjs.map +1 -1
  260. package/testing.js +1 -1
  261. package/testing.js.map +1 -1
  262. package/ui/features/canvas/hooks/use-image-renderer.d.ts +5 -4
  263. package/ui/features/canvas/hooks/use-image-renderer.d.ts.map +1 -1
  264. package/ui/hooks/use-function-warmup.d.ts +4 -14
  265. package/ui/hooks/use-function-warmup.d.ts.map +1 -1
  266. package/ui/hooks/use-kos-date-formats.d.ts +15 -29
  267. package/ui/hooks/use-kos-date-formats.d.ts.map +1 -1
  268. package/ui/hooks/use-kos-region-timezones.d.ts +4 -55
  269. package/ui/hooks/use-kos-region-timezones.d.ts.map +1 -1
  270. package/ui/hooks/use-kos-regions.d.ts +11 -23
  271. package/ui/hooks/use-kos-regions.d.ts.map +1 -1
  272. package/ui/hooks/use-kos-time-formats.d.ts +16 -31
  273. package/ui/hooks/use-kos-time-formats.d.ts.map +1 -1
  274. package/ui/hooks/use-kos-unit-systems.d.ts +13 -27
  275. package/ui/hooks/use-kos-unit-systems.d.ts.map +1 -1
  276. package/ui/hooks/view-model/use-view-model.d.ts +6 -31
  277. package/ui/hooks/view-model/use-view-model.d.ts.map +1 -1
  278. package/ui/policies/reload-on-disconnect-policy.d.ts +5 -6
  279. package/ui/policies/reload-on-disconnect-policy.d.ts.map +1 -1
  280. package/software-info-registration-CKlTQPet.js.map +0 -1
  281. package/software-info-registration-GUbTY4KD.cjs.map +0 -1
@@ -4,11 +4,11 @@ export interface BootKosCoreOptions {
4
4
  alias?: string;
5
5
  }
6
6
  /**
7
- * A model's registration bean — the value `@kosModel` generates beside the
8
- * model, and the one an application passes to `KosModelRegistry...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
- * The bean itself, not its `registration` property: handing over the property
11
- * registers nothing, and the model only fails later, on the first build.
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
  /**
@@ -31,17 +31,17 @@ export interface KosCoreBootBuilder {
31
31
  /** Connection alias, when the model under test cares about one. */
32
32
  alias: (alias: string) => KosCoreBootBuilder;
33
33
  /**
34
- * Install a KosMock setup module before boot — the same default export the
34
+ * Install a KosMock setup module before boot: the default export the
35
35
  * fixture server serves from `fixtures/setups/*.mjs`, imported directly. It
36
- * runs before the transport exists, so it registers routes, transformers,
37
- * config injections and observers; anything it pushes belongs after boot.
36
+ * runs before the transport exists, so it can register routes, transformers,
37
+ * config injections and observers; pushes belong after boot.
38
38
  */
39
39
  setup: (module: KosMockSetupModule) => KosCoreBootBuilder;
40
40
  /**
41
- * Load a recorded fixture before boot — the JSON the fixture server serves,
42
- * imported directly. Test defaults: `ignoreLatency: true` (full speed) and
43
- * `pushes: "manual"` (the capture's topic and future timeline stays inert; a
44
- * 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.
45
45
  */
46
46
  fixture: (fixture: KosMockFixture, options?: KosMockPlaybackOptions) => KosCoreBootBuilder;
47
47
  /** Boot KosCore with the core models and everything on this chain. */
@@ -50,23 +50,19 @@ export interface KosCoreBootBuilder {
50
50
  /**
51
51
  * Open a registration chain, then `boot()` it.
52
52
  *
53
- * Idempotent per module instance: the first `boot()` boots, later ones return
54
- * the same core. KosCore and the model manager are process-global, so a test
55
- * file gets one core and one set of singletons — which is the isolation
56
- * boundary, and the reason a differently-configured singleton needs its own
57
- * 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.
58
56
  *
59
- * Register any routes the models need BEFORE calling `boot()`, so nothing races
60
- * the boot requests — `KosMock.get(...)` above the chain, or `.setup()` /
61
- * `.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.
62
60
  *
63
61
  * @example
64
62
  * ```ts
65
- * await bootKosCore().model(AssetManager).model(AssetEntry).boot();
66
- *
67
63
  * await bootKosCore()
68
- * .setup(boardBaseline) // fixtures/setups/board-baseline.mjs
69
- * .fixture(pourOk) // fixtures/pour-ok.json
64
+ * .setup(boardBaseline) // fixtures/setups/board-baseline.mjs
65
+ * .fixture(pourOk) // fixtures/pour-ok.json
70
66
  * .model(Board)
71
67
  * .boot();
72
68
  * ```
@@ -75,23 +71,22 @@ export declare function bootKosCore(): KosCoreBootBuilder;
75
71
  /**
76
72
  * Boot KosCore from an assembled registry.
77
73
  *
78
- * Kept for callers that already hold an `IKosRegistry`. A test registering its
79
- * own models should use the no-argument chain instead, which takes the
80
- * registration beans directly and registers the SDK's core models. This form
81
- * boots exactly the registry it is given.
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.
82
78
  *
83
79
  * @param registration Models under test, e.g. `{ models: {...}, preloadModels: [] }`.
84
80
  */
85
81
  export declare function bootKosCore(registration: IKosRegistry, options?: BootKosCoreOptions): Promise<IKosCoreManager>;
86
82
  /**
87
- * Wait until `predicate` holds, then resolve — or reject naming what never
88
- * happened.
83
+ * Resolves once `predicate` holds, or rejects with a message naming `label`
84
+ * after the timeout.
89
85
  *
90
86
  * Model reactions are asynchronous, so a test that changes an input and asserts
91
- * immediately reads the old value. Polling for the OUTCOME beats sleeping for an
92
- * arbitrary interval: it is faster when the reaction is quick, and it fails with
93
- * a usable message instead of a bare assertion diff when the reaction never
94
- * 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.
95
90
  *
96
91
  * @param label What is being waited for, quoted back in the timeout message.
97
92
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/kos-ui-sdk/src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,OAAO,KAAK,EACV,4BAA4B,EAC5B,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,sBAAsB,E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1B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,eAAe,CAAC,CAAC;AAQ5B;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,CACzB,SAAS,EAAE,MAAM,OAAO,EACxB,KAAK,EAAE,MAAM,EACb,SAAS,SAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAQf"}
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;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,KAAK,EAAE,CACL,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE,OAAO,KACd,kBAAkB,CAAC;IACxB,oEAAoE;IACpE,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,kBAAkB,CAAC;IAClD,sDAAsD;IACtD,SAAS,EAAE,CACT,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,qBAAqB,CAAC,GAAG,CAAC,KAClC,kBAAkB,CAAC;IACxB,kEAAkE;IAClE,MAAM,EAAE,CACN,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,qBAAqB,KAChC,kBAAkB,CAAC;IACxB,mEAAmE;IACnE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,kBAAkB,CAAC;IAC7C;;;;;OAKG;IACH,KAAK,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,kBAAkB,CAAC;IAC1D;;;;;OAKG;IACH,OAAO,EAAE,CACP,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE,sBAAsB,KAC7B,kBAAkB,CAAC;IACxB,sEAAsE;IACtE,IAAI,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CACtC;AAmGD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,IAAI,kBAAkB,CAAC;AAClD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,YAAY,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,eAAe,CAAC,CAAC;AAQ5B;;;;;;;;;;GAUG;AACH,wBAAsB,KAAK,CACzB,SAAS,EAAE,MAAM,OAAO,EACxB,KAAK,EAAE,MAAM,EACb,SAAS,SAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAQf"}
package/testing.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("mobx");
4
- const service = require("./software-info-registration-GUbTY4KD.cjs");
4
+ const service = require("./software-info-registration-CY_E6Rw7.cjs");
5
5
  require("loglevel");
6
6
  let booted;
7
7
  let prepared = false;
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. `boot()` also registers the SDK's core models,\n * the set an app's `KosModelRegistry.core.models()` registers (config beans,\n * config properties and region info among them), 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 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\";\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, 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. `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 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 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 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 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, 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 and registers the SDK's core models. This form\n * boots exactly the registry it is given.\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","KosModelRegistry"],"mappings":";;;;;AAwEA,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,MACjBC,QAAAA,oBAAoB,MAAM,SAAS,OAAO,EAAE,cAAc,OAAO;AAAA,MAAA;AAEnE,aAAO;AAAA,IACT;AAAA,IACA,SAAS,CAAC,UAAU;AAClB,oBAAc,KAAK,KAAK;AACxB,aAAO;AAAA,IACT;AAAA,IACA,WAAW,CAAC,YAAY,cAAc;AACpC,oBAAc;AAAA,QAAK,MACjBA,QAAAA,oBAAoB,UAAU,SAAS,OAAO,EAAE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AS,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,MACjBC,QAAAA,oBAAoB,MAAM,SAAS,OAAO,EAAE,cAAc,OAAO;AAAA,MAAA;AAEnE,aAAO;AAAA,IACT;AAAA,IACA,SAAS,CAAC,UAAU;AAClB,oBAAc,KAAK,KAAK;AACxB,aAAO;AAAA,IACT;AAAA,IACA,WAAW,CAAC,YAAY,cAAc;AACpC,oBAAc;AAAA,QAAK,MACjBA,QAAAA,oBAAoB,UAAU,SAAS,OAAO,EAAE,YAAY,SAAS;AAAA,MAAA;AAEvE,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,CAAC,MAAM,iBAAiB;AAC9B,oBAAc;AAAA,QAAK,MACjBA,4BAA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m as RegistrationManager } from "./software-info-registration-CKlTQPet.js";
2
+ import { g as KosCore, bT as KosMock, bY as KosModelRegistry, cm as RegistrationManager } from "./software-info-registration-CuuEsH8v.js";
3
3
  import "loglevel";
4
4
  let booted;
5
5
  let prepared = false;
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. `boot()` also registers the SDK's core models,\n * the set an app's `KosModelRegistry.core.models()` registers (config beans,\n * config properties and region info among them), 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 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\";\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, 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. `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 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 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 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 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, 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 and registers the SDK's core models. This form\n * boots exactly the registry it is given.\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":";;;AAwEA,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;AAEA,SAAS,mBAAuC;AAC9C,QAAM,gBAAgC,CAAA;AACtC,QAAM,eAA+C,CAAA;A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A;AAGF,SAAO;AACT;AAyCO,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;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,oBAAoB,MAAM,SAAS,OAAO,EAAE,cAAc,OAAO;AAAA,MAAA;AAEnE,aAAO;AAAA,IACT;AAAA,IACA,SAAS,CAAC,UAAU;AACl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IAAQ,UAAU;AACzB,YAAM,IAAI,MAAM,yBAAyB,KAAK,EAAE;AAAA,IAClD;AACA,UAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,CAAC,CAAC;AAAA,EACvD;AACF;"}
@@ -5,17 +5,18 @@ interface UseImageRendererProps {
5
5
  src: string;
6
6
  }
7
7
  /**
8
- * A custom hook that initializes and manages a video renderer for streaming video frames.
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 video renderer.
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 video is currently streaming.
18
- * - `startStreaming` (Function): A function to start the video streaming process.
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;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,GAAI,kCAM9B,qBAAqB,mCAWvB,CAAC"}
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
- * import { useFunctionWarmup } from './use-function-warmup';
43
- *
44
- * const myFunction = (arg?: any) => {
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;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"}
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 useKosRegions hook.
7
- * @typeParam RegionData - the region data returned from the backend service. The type must extend BaseRegionResponse from the kos-core-model.
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 raw region data returned from the backend service. */
10
+ /** the ids of the available date formats. */
12
11
  raw: string[];
13
- /**the region model returned from the backend service. */
12
+ /** the region info model. */
14
13
  regionModel?: RegionInfoModel;
15
- /**the currently selected region. */
14
+ /** the currently selected date format. */
16
15
  selectedDateFormat: string;
17
16
  dateFormatId: string;
18
- /**a function that can be used to update the region. */
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
- * A hook that will help manage the use of region date formats on a dispenser.
29
- * @param dateFormatMap - a function that maps a region string a structure that can be
30
- * used as an option in a select box. The default is to return an option element
31
- * with the date format as the value and label.
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
- * In this example the default region map is used to populate a select box with the available regions. If using a third party select box component where the options
35
- * are passed in as a prop, the options property can be spread into the props for the component. In this case, a region map function could be passed in to map the region
36
- * to a structure that the component expects.
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;;;;GAIG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,EAAE,GAAG,GAAG;IACvD,4DAA4D;IAC5D,GAAG,EAAE,MAAM,EAAE,CAAC;IAEd,yDAAyD;IACzD,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B,oCAAoC;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAE3B,YAAY,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,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;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,EAAE,GAAG,GAAG,EAClD,gBAAe,aAAa,CAAC,CAAC,CAAsB,KACnD,qBAAqB,CAAC,CAAC,CAkEzB,CAAC"}
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
- * ```typescript
16
- * import React from 'react';
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,EAAE,GAAG,GAAG,EAChD,aAAY,SAAS,CAAC,CAAC,CAAsB;;;;;;wBA+CR,cAAc;;sBAAd,cAAc;;;;CA0BpD,CAAC"}
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"}
@@ -4,7 +4,7 @@ type SelectCallback = string | ChangeEvent<HTMLSelectElement>;
4
4
  type RegionMap<T extends object = any> = (region: string) => T;
5
5
  /**
6
6
  * The data returned from the useKosRegions hook.
7
- * @typeParam RegionData - the region data returned from the backend service. The type must extend BaseRegionResponse from the kos-core-model.
7
+ * @typeParam RegionData - the region data returned from the backend service. Must extend `RegionServices.BaseRegionResponse`.
8
8
  * @typeParam T - the type of the options returned from the regionMap function.
9
9
  */
10
10
  export interface KosRegionHookData<RegionData extends RegionServices.BaseRegionResponse = RegionServices.BaseRegionResponse, T extends object = any> {
@@ -26,31 +26,19 @@ export interface KosRegionHookData<RegionData extends RegionServices.BaseRegionR
26
26
  };
27
27
  }
28
28
  /**
29
- * A hook that will help manage the use of region information on a dispenser.
30
- * @typeParam RegionData - the region data returned from the backend service. The type must extend BaseRegionResponse from the kos-core-model.
31
- * @param regionMap - a function that maps a region string a structure that can be
32
- * used as an option in a select box. The default is to return an option element
33
- * with the region as the value and label.
29
+ * Manages the device region: the available regions, the selected region and
30
+ * its data, and props for a region select box.
31
+ *
32
+ * @typeParam RegionData - the region data returned from the backend service. Must extend `RegionServices.BaseRegionResponse`.
33
+ * @param regionMap - maps a region string to a select-box option. The default
34
+ * returns an `<option>` with the region as value and label. Pass a custom map
35
+ * when a third-party select component expects a different option shape.
34
36
  * @returns KosRegionHookData - the data returned from the hook.
35
37
  * @example
36
- * In this example the default region map is used to populate a select box with the available regions. If using a third party select box component where the options
37
- * are passed in as a prop, the options property can be spread into the props for the component. In this case, a region map function could be passed in to map the region
38
- * to a structure that the component expects.
39
- *
40
- *
41
- * ```typescript
42
- * interface RegionData extends RegionServices.BaseRegionResponse {
43
- * rfidRegion: string;
44
- * }
45
- * const { regionSelectProps, regionModel, regionData, selectedRegion, updateRegion } = useKosRegions<RegionData>();
38
+ * ```tsx
39
+ * const { regionSelectProps, selectedRegion } = useKosRegions();
46
40
  * const { options, ...selectAttributes } = regionSelectProps;
47
- * ...
48
- * <div>
49
- * <label>Select region: </label>
50
- * <select {...selectAttributes}>{options}</select>
51
- * </div>
52
- * <div>Selected Region: {selectedRegion}</div>
53
- * <div>Region Data: {regionData?.rfidRegion}</div>
41
+ * return <select {...selectAttributes}>{options}</select>;
54
42
  * ```
55
43
  */
56
44
  export declare const useKosRegions: <RegionData extends RegionServices.BaseRegionResponse = RegionServices.BaseRegionResponse, T extends {} = any>(regionMap?: RegionMap<T>) => KosRegionHookData<RegionData, T>;
@@ -1 +1 @@
1
- {"version":3,"file":"use-kos-regions.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/ui/hooks/use-kos-regions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoC,MAAM,OAAO,CAAC;AAMtE,OAAO,EAGL,cAAc,EACd,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AAQzC,KAAK,cAAc,GAAG,MAAM,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAC9D,KAAK,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,CAAC,CAAC;AAO/D;;;;GAIG;AACH,MAAM,WAAW,iBAAiB,CAChC,UAAU,SAAS,cAAc,CAAC,kBAAkB,GAAG,cAAc,CAAC,kBAAkB,EACxF,CAAC,SAAS,MAAM,GAAG,GAAG;IAEtB,4DAA4D;IAC5D,GAAG,EAAE,MAAM,EAAE,CAAC;IAEd,yDAAyD;IACzD,WAAW,CAAC,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IAE1C,yDAAyD;IACzD,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IAEvB,uDAAuD;IACvD,YAAY,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAE1C,+DAA+D;IAC/D,iBAAiB,EAAE;QACjB,QAAQ,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;QACtC,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,EAAE,CAA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,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,EAAE,CAAC;KACd,CAAC;CACH;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,SAAS,cAAc,CAAC,kBAAkB,GAAG,cAAc,CAAC,kBAAkB,EACxF,CAAC,SAAS,EAAE,GAAG,GAAG,EAElB,YAAW,SAAS,CAAC,CAAC,CAAsB,KAC3C,iBAAiB,CAAC,UAAU,EAAE,CAAC,CA+DjC,CAAC"}
@@ -3,19 +3,18 @@ import { ChangeEvent } from 'react';
3
3
  type SelectCallback = string | ChangeEvent<HTMLSelectElement>;
4
4
  type TimeFormatMap<T extends {} = any> = (format: TimeFormatOptions) => T;
5
5
  /**
6
- * The data returned from the useKosRegions hook.
7
- * @typeParam RegionData - the region data returned from the backend service. The type must extend BaseRegionResponse from the kos-core-model.
8
- * @typeParam T - the type of the options returned from the regionMap function.
6
+ * The data returned from the useKosTimeFormats hook.
7
+ * @typeParam T - the type of the options returned from the timeFormatMap function.
9
8
  */
10
9
  export interface KosTimeFormatHookData<T extends {} = any> {
11
- /**the raw region data returned from the backend service. */
10
+ /** the ids of the available time formats. */
12
11
  raw: string[];
13
- /**the region model returned from the backend service. */
12
+ /** the region info model. */
14
13
  regionModel?: RegionInfoModel;
15
- /**the currently selected region. */
14
+ /** the currently selected time format. */
16
15
  selectedTimeFormat: string;
17
16
  timeFormatId: string;
18
- /**a function that can be used to update the region. */
17
+ /** updates the selected time format. */
19
18
  updateTimeFormat: (e: SelectCallback) => void;
20
19
  /**the props that can be spread into a select box component. */
21
20
  props: {
@@ -25,31 +24,17 @@ export interface KosTimeFormatHookData<T extends {} = any> {
25
24
  };
26
25
  }
27
26
  /**
28
- * A hook that will help manage the use of region information on a dispenser.
29
- * @typeParam RegionData - the region data returned from the backend service. The type must extend BaseRegionResponse from the kos-core-model.
30
- * @param timeFormatMap - a function that maps a region string a structure that can be
31
- * used as an option in a select box. The default is to return an option element
32
- * with the region as the value and label.
33
- * @returns KosRegionHookData - the data returned from the hook.
34
- * @example
35
- * In this example the default region map is used to populate a select box with the available regions. If using a third party select box component where the options
36
- * are passed in as a prop, the options property can be spread into the props for the component. In this case, a region map function could be passed in to map the region
37
- * to a structure that the component expects.
38
- *
27
+ * Manages the region's time format: the available formats, the selected
28
+ * format, and props for a time format select box.
39
29
  *
40
- * ```typescript
41
- * interface RegionData extends RegionServices.BaseRegionResponse {
42
- * rfidRegion: string;
43
- * }
44
- * const { regionSelectProps, regionModel, regionData, selectedRegion, updateRegion } = useKosRegions<RegionData>();
45
- * const { options, ...selectAttributes } = regionSelectProps;
46
- * ...
47
- * <div>
48
- * <label>Select region: </label>
49
- * <select {...selectAttributes}>{options}</select>
50
- * </div>
51
- * <div>Selected Region: {selectedRegion}</div>
52
- * <div>Region Data: {regionData?.rfidRegion}</div>
30
+ * @param timeFormatMap - maps a time format to a select-box option. The
31
+ * default returns an `<option>` with the format as value and label.
32
+ * @returns KosTimeFormatHookData - the data returned from the hook.
33
+ * @example
34
+ * ```tsx
35
+ * const { props } = useKosTimeFormats();
36
+ * const { options, ...selectAttributes } = props;
37
+ * return <select {...selectAttributes}>{options}</select>;
53
38
  * ```
54
39
  */
55
40
  export declare const useKosTimeFormats: <T extends {} = any>(timeFormatMap?: TimeFormatMap<T>) => KosTimeFormatHookData<T>;