@hkdigital/lib-core 0.3.15 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/README.md +6 -6
  2. package/dist/auth/errors.d.ts +1 -0
  3. package/dist/auth/errors.js +1 -0
  4. package/dist/{states → browser/navigation}/navigation.svelte.js +1 -1
  5. package/dist/browser/navigation.d.ts +1 -0
  6. package/dist/browser/navigation.js +1 -0
  7. package/dist/config/README.md +1 -1
  8. package/dist/config/generators/imagetools.d.ts +2 -0
  9. package/dist/config/generators/imagetools.js +23 -10
  10. package/dist/config/generators/vite.js +1 -1
  11. package/dist/config/imagetools.d.ts +5 -5
  12. package/dist/config/typedef.d.ts +11 -0
  13. package/dist/config/typedef.js +17 -0
  14. package/dist/design/README.md +75 -0
  15. package/dist/design/generators/index.js +35 -0
  16. package/dist/design/themes/hkdev/components/buttons/button-text.css +20 -1
  17. package/dist/design/themes/hkdev/theme-ext.js +1 -1
  18. package/dist/{classes/data → generic/data/classes}/IterableTree.js +2 -2
  19. package/dist/{classes/data → generic/data/classes}/Selector.js +1 -1
  20. package/dist/generic/data/classes/typedef.d.ts +24 -0
  21. package/dist/generic/data/classes/typedef.js +14 -0
  22. package/dist/generic/data.d.ts +2 -0
  23. package/dist/generic/data.js +2 -0
  24. package/dist/generic/errors.d.ts +2 -0
  25. package/dist/generic/errors.js +2 -0
  26. package/dist/generic/events.d.ts +1 -0
  27. package/dist/generic/events.js +1 -0
  28. package/dist/{classes/promise → generic/promises/classes}/HkPromise.d.ts +17 -7
  29. package/dist/{classes/promise → generic/promises/classes}/HkPromise.js +20 -10
  30. package/dist/generic/promises.d.ts +1 -0
  31. package/dist/generic/promises.js +1 -0
  32. package/dist/{classes/streams → generic/streaming/classes}/ServerEventsStore.d.ts +1 -1
  33. package/dist/{classes/streams → generic/streaming/classes}/ServerEventsStore.js +2 -2
  34. package/dist/generic/streaming.d.ts +3 -0
  35. package/dist/generic/streaming.js +3 -0
  36. package/dist/generic/typedef.d.ts +1 -0
  37. package/dist/generic/typedef.js +1 -0
  38. package/dist/index.js +1 -0
  39. package/dist/logging/errors.d.ts +7 -0
  40. package/dist/logging/errors.js +11 -0
  41. package/dist/logging/internal/adapters/console.d.ts +1 -16
  42. package/dist/logging/internal/adapters/console.js +320 -8
  43. package/dist/logging/internal/adapters/formatting.d.ts +69 -0
  44. package/dist/logging/internal/adapters/formatting.js +395 -0
  45. package/dist/logging/internal/adapters/pino.js +112 -21
  46. package/dist/logging/internal/adapters/typedef.d.ts +30 -0
  47. package/dist/logging/internal/adapters/typedef.js +11 -0
  48. package/dist/logging/internal/factories/server.js +11 -1
  49. package/dist/logging/internal/logger/Logger.d.ts +7 -5
  50. package/dist/logging/internal/logger/Logger.js +41 -6
  51. package/dist/logging/internal/test-errors.d.ts +35 -0
  52. package/dist/logging/internal/test-errors.js +137 -0
  53. package/dist/network/cache/IndexedDbCache.d.ts +1 -1
  54. package/dist/network/cache/MemoryResponseCache.d.ts +5 -0
  55. package/dist/network/cache/MemoryResponseCache.js +5 -2
  56. package/dist/network/errors.d.ts +2 -0
  57. package/dist/network/errors.js +2 -0
  58. package/dist/network/http/caching.js +1 -1
  59. package/dist/network/http/errors.d.ts +2 -2
  60. package/dist/network/http/errors.js +5 -13
  61. package/dist/network/http/http-request.js +1 -1
  62. package/dist/network/http/json-request.js +1 -1
  63. package/dist/network/http/response.js +1 -1
  64. package/dist/network/http/url.js +1 -1
  65. package/dist/network/loaders/README.md +14 -7
  66. package/dist/network/loaders/audio/AudioScene.svelte.js +3 -2
  67. package/dist/network/loaders/image/ImageLoader.svelte.d.ts +2 -2
  68. package/dist/network/loaders/image/ImageLoader.svelte.js +1 -1
  69. package/dist/network/loaders/image/ImageScene.svelte.d.ts +2 -2
  70. package/dist/network/loaders/image/ImageScene.svelte.js +9 -8
  71. package/dist/network/loaders/image/ImageVariantsLoader.svelte.d.ts +5 -5
  72. package/dist/network/loaders/image/ImageVariantsLoader.svelte.js +14 -13
  73. package/dist/network/loaders/image/utils/index.d.ts +2 -2
  74. package/dist/network/loaders/image/utils/index.js +9 -12
  75. package/dist/network/loaders/typedef.d.ts +0 -9
  76. package/dist/network/loaders/typedef.js +0 -12
  77. package/dist/network/states/NetworkLoader.svelte.d.ts +1 -1
  78. package/dist/network/states/NetworkLoader.svelte.js +3 -2
  79. package/dist/services/service-base/ServiceBase.d.ts +2 -2
  80. package/dist/services/service-base/ServiceBase.js +15 -11
  81. package/dist/services/service-base/typedef.d.ts +2 -31
  82. package/dist/services/service-base/typedef.js +3 -2
  83. package/dist/services/service-manager/ServiceManager.d.ts +3 -3
  84. package/dist/services/service-manager/ServiceManager.js +2 -2
  85. package/dist/services/service-manager/typedef.d.ts +3 -3
  86. package/dist/services/service-manager/typedef.js +3 -3
  87. package/dist/{classes/svelte → state/classes}/loading-state-machine/LoadingStateMachine.svelte.d.ts +1 -1
  88. package/dist/{classes/svelte → state/classes}/loading-state-machine/LoadingStateMachine.svelte.js +1 -1
  89. package/dist/state/classes/subscribers-count/index.d.ts +1 -0
  90. package/dist/state/classes/subscribers-count/index.js +1 -0
  91. package/dist/state/classes.d.ts +3 -0
  92. package/dist/state/classes.js +3 -0
  93. package/dist/{util/svelte/state-context/index.d.ts → state/context/state-context.d.ts} +1 -1
  94. package/dist/{util/svelte/state-context/index.js → state/context/state-context.js} +4 -4
  95. package/dist/state/context.d.ts +1 -0
  96. package/dist/state/context.js +1 -0
  97. package/dist/state/stores.d.ts +1 -0
  98. package/dist/state/stores.js +1 -0
  99. package/dist/ui/README.md +49 -0
  100. package/dist/ui/components/button-group/index.d.ts +1 -0
  101. package/dist/ui/components/button-group/index.js +1 -0
  102. package/dist/ui/{primitives → components}/drag-drop/DragDropContext.svelte +1 -1
  103. package/dist/ui/{primitives → components}/drag-drop/DragDropContext.svelte.d.ts +1 -1
  104. package/dist/ui/{primitives → components}/drag-drop/Draggable.svelte +2 -2
  105. package/dist/ui/{primitives → components}/drag-drop/Draggable.svelte.d.ts +1 -1
  106. package/dist/ui/{primitives → components}/drag-drop/DropZone.svelte +4 -4
  107. package/dist/ui/{primitives → components}/drag-drop/DropZone.svelte.d.ts +3 -3
  108. package/dist/ui/{primitives → components}/drag-drop/DropZoneArea.svelte +3 -3
  109. package/dist/ui/{primitives → components}/drag-drop/DropZoneArea.svelte.d.ts +4 -4
  110. package/dist/ui/{primitives → components}/drag-drop/DropZoneList.svelte +3 -3
  111. package/dist/ui/{primitives → components}/drag-drop/DropZoneList.svelte.d.ts +3 -3
  112. package/dist/ui/{primitives → components}/drag-drop/drag-state.svelte.d.ts +11 -11
  113. package/dist/ui/{primitives → components}/drag-drop/drag-state.svelte.js +5 -5
  114. package/dist/ui/components/drag-drop/typedef.d.ts +2 -0
  115. package/dist/ui/components/drag-drop/typedef.js +2 -0
  116. package/dist/ui/components/game-box/index.d.ts +1 -0
  117. package/dist/ui/components/game-box/index.js +1 -0
  118. package/dist/ui/components/grid-layers/index.d.ts +1 -0
  119. package/dist/ui/components/grid-layers/index.js +1 -0
  120. package/dist/ui/{primitives/layout → components}/grid-layers/util.js +1 -1
  121. package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.d.ts +3 -3
  122. package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.js +3 -4
  123. package/dist/ui/components/hk-app-layout/index.d.ts +1 -0
  124. package/dist/ui/components/hk-app-layout/index.js +1 -0
  125. package/dist/ui/components/image-box/ImageBox.svelte +2 -2
  126. package/dist/ui/components/image-box/ImageBox.svelte.d.ts +3 -3
  127. package/dist/ui/components/image-box/index.d.ts +1 -1
  128. package/dist/ui/components/presenter/ImageSlide.svelte +1 -1
  129. package/dist/ui/components/presenter/ImageSlide.svelte.d.ts +2 -2
  130. package/dist/ui/components/presenter/Presenter.state.svelte.d.ts +3 -3
  131. package/dist/ui/components/presenter/Presenter.state.svelte.js +1 -1
  132. package/dist/ui/components/presenter/Presenter.svelte +1 -1
  133. package/dist/ui/components/presenter/Presenter.svelte.d.ts +1 -1
  134. package/dist/ui/{primitives → components}/rows/panel-grid-row/PanelGridRow.svelte.d.ts +1 -1
  135. package/dist/ui/{primitives → components}/rows/panel-row-2/PanelRow2.svelte.d.ts +1 -1
  136. package/dist/ui/{primitives → components}/tab-bar/HkTabBar.state.svelte.d.ts +3 -3
  137. package/dist/ui/{primitives → components}/tab-bar/HkTabBar.state.svelte.js +4 -2
  138. package/dist/ui/{primitives → components}/tab-bar/HkTabBar.svelte +2 -2
  139. package/dist/ui/{primitives → components}/tab-bar/HkTabBar.svelte.d.ts +2 -2
  140. package/dist/ui/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +19 -0
  141. package/dist/ui/{primitives → components}/tab-bar/HkTabBarSelector.state.svelte.js +2 -2
  142. package/dist/ui/{primitives → components}/tab-bar/HkTabBarSelector.svelte +1 -1
  143. package/dist/ui/{primitives → components}/tab-bar/HkTabBarSelector.svelte.d.ts +2 -2
  144. package/dist/ui/{primitives → components}/tab-bar/typedef.d.ts +1 -1
  145. package/dist/ui/{primitives → components}/tab-bar/typedef.js +1 -1
  146. package/dist/ui/components/typedef.d.ts +5 -0
  147. package/dist/ui/components/typedef.js +5 -0
  148. package/dist/ui/components/virtual-viewport/index.d.ts +1 -0
  149. package/dist/ui/components/virtual-viewport/index.js +1 -0
  150. package/dist/ui/components.d.ts +11 -0
  151. package/dist/ui/components.js +11 -0
  152. package/dist/ui/{primitives/hkdev → dev}/blocks/TextBlock.svelte +1 -1
  153. package/dist/ui/{primitives/debug → dev}/debug-panel-design-scaling/DebugPanelDesignScaling.svelte +1 -1
  154. package/dist/ui/dev.d.ts +3 -0
  155. package/dist/ui/dev.js +3 -0
  156. package/dist/ui/primitives/buttons/button/Button.svelte.d.ts +1 -1
  157. package/dist/ui/primitives/typedef.d.ts +1 -0
  158. package/dist/ui/primitives/typedef.js +1 -0
  159. package/dist/ui/primitives.d.ts +5 -0
  160. package/dist/ui/primitives.js +5 -0
  161. package/dist/ui/typedef.d.ts +2 -0
  162. package/dist/ui/typedef.js +2 -0
  163. package/dist/util/array/index.js +1 -1
  164. package/dist/util/bases/base58.d.ts +3 -3
  165. package/dist/util/bases/base58.js +3 -3
  166. package/dist/util/compare/index.d.ts +4 -5
  167. package/dist/util/compare/index.js +3 -4
  168. package/dist/util/exceptions/index.js +1 -1
  169. package/dist/util/expect/arrays.d.ts +11 -11
  170. package/dist/util/expect/arrays.js +14 -6
  171. package/dist/util/expect/index.js +2 -2
  172. package/dist/util/expect/primitives.d.ts +6 -5
  173. package/dist/util/expect/primitives.js +15 -5
  174. package/dist/util/expect/url.d.ts +6 -5
  175. package/dist/util/expect/url.js +15 -5
  176. package/dist/util/function/index.d.ts +1 -14
  177. package/dist/util/index.d.ts +5 -0
  178. package/dist/util/index.js +13 -0
  179. package/dist/util/is/index.d.ts +3 -2
  180. package/dist/util/is/index.js +2 -1
  181. package/dist/util/iterate/index.d.ts +6 -8
  182. package/dist/util/iterate/index.js +5 -5
  183. package/dist/util/object/index.d.ts +1 -2
  184. package/dist/util/object/index.js +2 -3
  185. package/dist/util/ssr/index.d.ts +16 -0
  186. package/dist/util/ssr/index.js +44 -0
  187. package/dist/util/svelte/index.d.ts +1 -1
  188. package/dist/util/svelte/index.js +1 -1
  189. package/dist/util/time/index.d.ts +2 -2
  190. package/dist/util/time/index.js +1 -1
  191. package/dist/valibot/index.d.ts +1 -1
  192. package/dist/valibot/index.js +27 -1
  193. package/package.json +3 -3
  194. package/dist/assets/autospuiten/car-paint-picker/army-green.jpg +0 -0
  195. package/dist/assets/autospuiten/car-paint-picker/electric-blue.jpg +0 -0
  196. package/dist/assets/autospuiten/car-paint-picker/lemon-yellow.jpg +0 -0
  197. package/dist/assets/autospuiten/car-paint-picker/opaque-purple.jpg +0 -0
  198. package/dist/assets/autospuiten/car-paint-picker/rusty.jpg +0 -0
  199. package/dist/assets/autospuiten/car-paint-picker/sunset-orange.jpg +0 -0
  200. package/dist/assets/autospuiten/car-paint-picker/tomato-red.jpg +0 -0
  201. package/dist/assets/autospuiten/car-paint-picker.d.ts +0 -17
  202. package/dist/assets/autospuiten/car-paint-picker.js +0 -41
  203. package/dist/assets/autospuiten/labels.d.ts +0 -7
  204. package/dist/assets/autospuiten/labels.js +0 -7
  205. package/dist/classes/data/index.d.ts +0 -2
  206. package/dist/classes/data/index.js +0 -2
  207. package/dist/classes/event-emitter/index.d.ts +0 -1
  208. package/dist/classes/event-emitter/index.js +0 -2
  209. package/dist/classes/index.d.ts +0 -4
  210. package/dist/classes/index.js +0 -4
  211. package/dist/classes/promise/index.d.ts +0 -1
  212. package/dist/classes/promise/index.js +0 -1
  213. package/dist/classes/stores/index.d.ts +0 -1
  214. package/dist/classes/stores/index.js +0 -1
  215. package/dist/classes/streams/index.d.ts +0 -3
  216. package/dist/classes/streams/index.js +0 -3
  217. package/dist/classes/svelte/index.d.ts +0 -1
  218. package/dist/classes/svelte/index.js +0 -1
  219. package/dist/errors/index.d.ts +0 -5
  220. package/dist/errors/index.js +0 -5
  221. package/dist/services/service-base/index.d.ts +0 -3
  222. package/dist/services/service-base/index.js +0 -3
  223. package/dist/states/index.d.ts +0 -1
  224. package/dist/states/index.js +0 -1
  225. package/dist/stores/index.d.ts +0 -1
  226. package/dist/stores/index.js +0 -1
  227. package/dist/typedef/index.d.ts +0 -3
  228. package/dist/typedef/index.js +0 -3
  229. package/dist/ui/primitives/debug/index.d.ts +0 -1
  230. package/dist/ui/primitives/debug/index.js +0 -1
  231. package/dist/ui/primitives/index.d.ts +0 -1
  232. package/dist/ui/primitives/index.js +0 -1
  233. package/dist/ui/primitives/layout/grid-layers/GridLayers.svelte__heightFrom__ +0 -372
  234. package/dist/ui/primitives/layout/index.d.ts +0 -1
  235. package/dist/ui/primitives/layout/index.js +0 -1
  236. package/dist/ui/primitives/tab-bar/HkTabBarSelector.state.svelte.d.ts +0 -19
  237. /package/dist/{errors → auth/errors}/jwt.d.ts +0 -0
  238. /package/dist/{errors → auth/errors}/jwt.js +0 -0
  239. /package/dist/{states → browser/navigation}/navigation.svelte.d.ts +0 -0
  240. /package/dist/{classes/data → generic/data/classes}/IterableTree.d.ts +0 -0
  241. /package/dist/{classes/data → generic/data/classes}/Selector.d.ts +0 -0
  242. /package/dist/{classes → generic}/data/typedef.d.ts +0 -0
  243. /package/dist/{classes → generic}/data/typedef.js +0 -0
  244. /package/dist/{errors → generic/errors}/generic.d.ts +0 -0
  245. /package/dist/{errors → generic/errors}/generic.js +0 -0
  246. /package/dist/{errors → generic/errors}/promise.d.ts +0 -0
  247. /package/dist/{errors → generic/errors}/promise.js +0 -0
  248. /package/dist/{classes/event-emitter → generic/events/classes}/EventEmitter.d.ts +0 -0
  249. /package/dist/{classes/event-emitter → generic/events/classes}/EventEmitter.js +0 -0
  250. /package/dist/{classes/streams → generic/streaming/classes}/LogTransformStream.d.ts +0 -0
  251. /package/dist/{classes/streams → generic/streaming/classes}/LogTransformStream.js +0 -0
  252. /package/dist/{classes/streams → generic/streaming/classes}/TimeStampSource.d.ts +0 -0
  253. /package/dist/{classes/streams → generic/streaming/classes}/TimeStampSource.js +0 -0
  254. /package/dist/{errors → network/errors}/api.d.ts +0 -0
  255. /package/dist/{errors → network/errors}/api.js +0 -0
  256. /package/dist/{errors → network/errors}/http.d.ts +0 -0
  257. /package/dist/{errors → network/errors}/http.js +0 -0
  258. /package/dist/{classes/svelte → state/classes}/finite-state-machine/FiniteStateMachine.svelte.d.ts +0 -0
  259. /package/dist/{classes/svelte → state/classes}/finite-state-machine/FiniteStateMachine.svelte.js +0 -0
  260. /package/dist/{classes/svelte → state/classes}/finite-state-machine/index.d.ts +0 -0
  261. /package/dist/{classes/svelte → state/classes}/finite-state-machine/index.js +0 -0
  262. /package/dist/{classes/svelte → state/classes}/loading-state-machine/constants.d.ts +0 -0
  263. /package/dist/{classes/svelte → state/classes}/loading-state-machine/constants.js +0 -0
  264. /package/dist/{classes/svelte → state/classes}/loading-state-machine/index.d.ts +0 -0
  265. /package/dist/{classes/svelte → state/classes}/loading-state-machine/index.js +0 -0
  266. /package/dist/{classes/stores → state/classes/subscribers-count}/SubscribersCount.d.ts +0 -0
  267. /package/dist/{classes/stores → state/classes/subscribers-count}/SubscribersCount.js +0 -0
  268. /package/dist/{typedef/context.d.ts → state/context/typedef.d.ts} +0 -0
  269. /package/dist/{typedef/context.js → state/context/typedef.js} +0 -0
  270. /package/dist/{stores → state/stores}/theme.d.ts +0 -0
  271. /package/dist/{stores → state/stores}/theme.js +0 -0
  272. /package/dist/ui/{primitives → components}/drag-drop/DragController.d.ts +0 -0
  273. /package/dist/ui/{primitives → components}/drag-drop/DragController.js +0 -0
  274. /package/dist/ui/{primitives → components}/drag-drop/actions.d.ts +0 -0
  275. /package/dist/ui/{primitives → components}/drag-drop/actions.js +0 -0
  276. /package/dist/ui/{primitives → components}/drag-drop/index.d.ts +0 -0
  277. /package/dist/ui/{primitives → components}/drag-drop/index.js +0 -0
  278. /package/dist/{typedef → ui/components/drag-drop/typedef}/drag.d.ts +0 -0
  279. /package/dist/{typedef → ui/components/drag-drop/typedef}/drag.js +0 -0
  280. /package/dist/{typedef → ui/components/drag-drop/typedef}/drop.d.ts +0 -0
  281. /package/dist/{typedef → ui/components/drag-drop/typedef}/drop.js +0 -0
  282. /package/dist/ui/{primitives → components}/drag-drop/util.d.ts +0 -0
  283. /package/dist/ui/{primitives → components}/drag-drop/util.js +0 -0
  284. /package/dist/ui/{primitives/layout → components}/grid-layers/GridLayers.svelte +0 -0
  285. /package/dist/ui/{primitives/layout → components}/grid-layers/GridLayers.svelte.d.ts +0 -0
  286. /package/dist/ui/{primitives/layout → components}/grid-layers/util.d.ts +0 -0
  287. /package/dist/ui/{primitives → components}/rows/index.d.ts +0 -0
  288. /package/dist/ui/{primitives → components}/rows/index.js +0 -0
  289. /package/dist/ui/{primitives → components}/rows/panel-grid-row/PanelGridRow.svelte +0 -0
  290. /package/dist/ui/{primitives → components}/rows/panel-row-2/PanelRow2.svelte +0 -0
  291. /package/dist/ui/{primitives → components}/tab-bar/index.d.ts +0 -0
  292. /package/dist/ui/{primitives → components}/tab-bar/index.js +0 -0
  293. /package/dist/ui/{primitives/hkdev → dev}/blocks/TextBlock.svelte.d.ts +0 -0
  294. /package/dist/ui/{primitives/hkdev → dev}/buttons/CheckButton.svelte +0 -0
  295. /package/dist/ui/{primitives/hkdev → dev}/buttons/CheckButton.svelte.d.ts +0 -0
  296. /package/dist/ui/{primitives/debug → dev}/debug-panel-design-scaling/DebugPanelDesignScaling.svelte.d.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  import { Logger } from '../logger/index.js';
2
-
3
2
  import { PinoAdapter } from '../adapters/pino.js';
4
3
  import { INFO } from '../../constants.js';
4
+ // import { expectNoSSRContext } from '../../../util/ssr/index.js';
5
5
 
6
6
  /**
7
7
  * Create a server-side logger with pino adapter
@@ -12,10 +12,20 @@ import { INFO } from '../../constants.js';
12
12
  * @returns {Logger} Configured logger instance
13
13
  */
14
14
  export function createServerLogger(name, level = INFO, pinoOptions = {}) {
15
+ // Guard against SSR serialization issues
16
+ // expectNoSSRContext();
17
+
15
18
  const logger = new Logger(name, level);
16
19
  const adapter = new PinoAdapter(pinoOptions);
17
20
 
18
21
  // Connect adapter to logger events
22
+ //
23
+ // @note pino might fail if:
24
+ // pino tries to create a worker thread for pino-pretty before the
25
+ // development environment is fully ready, causing the transport target
26
+ // determination to fail
27
+ // -> Stop and start the dev server
28
+ //
19
29
  logger.on('log', (logEvent) => adapter.handleLog(logEvent));
20
30
 
21
31
  return logger;
@@ -33,6 +33,7 @@ export default class Logger extends EventEmitter {
33
33
  *
34
34
  * @param {string} message - Log message
35
35
  * @param {*} [details] - Additional details
36
+ *
36
37
  * @returns {boolean} True if the log was emitted
37
38
  */
38
39
  info(message: string, details?: any): boolean;
@@ -41,23 +42,24 @@ export default class Logger extends EventEmitter {
41
42
  *
42
43
  * @param {string} message - Log message
43
44
  * @param {*} [details] - Additional details
45
+ *
44
46
  * @returns {boolean} True if the log was emitted
45
47
  */
46
48
  warn(message: string, details?: any): boolean;
47
49
  /**
48
50
  * Log an error message
49
51
  *
50
- * @param {string} message - Log message
51
- * @param {*} [details] - Additional details
52
+ * @param {Error|string} originalErrorOrMessage
53
+ * @param {Error} [originalError]
54
+ *
52
55
  * @returns {boolean} True if the log was emitted
53
56
  */
54
- error(message: string, details?: any): boolean;
57
+ error(originalErrorOrMessage: Error | string, originalError?: Error, ...args: any[]): boolean;
55
58
  /**
56
59
  * Create a child logger with additional context
57
60
  *
58
61
  * @param {string} namespace
59
62
  * Namespace of the context (needed for chaining contexts)
60
- *
61
63
  * @param {Object} additionalContext - Additional context data
62
64
  *
63
65
  * @returns {Logger} New logger instance with merged context
@@ -75,4 +77,4 @@ export default class Logger extends EventEmitter {
75
77
  logFromEvent(eventName: string, eventData: import("../../typedef.js").LogEventData): boolean;
76
78
  #private;
77
79
  }
78
- import { EventEmitter } from '../../../classes/event-emitter';
80
+ import { EventEmitter } from '../../../generic/events.js';
@@ -32,7 +32,7 @@
32
32
  * logger.setLevel(DEBUG); // Now debug messages will also be logged
33
33
  */
34
34
 
35
- import { EventEmitter } from '../../../classes/event-emitter';
35
+ import { EventEmitter } from '../../../generic/events.js';
36
36
 
37
37
  import {
38
38
  DEBUG,
@@ -43,6 +43,11 @@ import {
43
43
  LOG
44
44
  } from '../../constants.js';
45
45
 
46
+ import { DetailedError } from '../../../generic/errors.js';
47
+ import { LoggerError } from '../../errors.js';
48
+
49
+ import { toArray } from '../../../util/array/index.js';
50
+
46
51
  /**
47
52
  * Logger class for consistent logging
48
53
  * @extends EventEmitter
@@ -99,6 +104,7 @@ export default class Logger extends EventEmitter {
99
104
  *
100
105
  * @param {string} message - Log message
101
106
  * @param {*} [details] - Additional details
107
+ *
102
108
  * @returns {boolean} True if the log was emitted
103
109
  */
104
110
  info(message, details) {
@@ -110,6 +116,7 @@ export default class Logger extends EventEmitter {
110
116
  *
111
117
  * @param {string} message - Log message
112
118
  * @param {*} [details] - Additional details
119
+ *
113
120
  * @returns {boolean} True if the log was emitted
114
121
  */
115
122
  warn(message, details) {
@@ -119,12 +126,41 @@ export default class Logger extends EventEmitter {
119
126
  /**
120
127
  * Log an error message
121
128
  *
122
- * @param {string} message - Log message
123
- * @param {*} [details] - Additional details
129
+ * @param {Error|string} originalErrorOrMessage
130
+ * @param {Error} [originalError]
131
+ *
124
132
  * @returns {boolean} True if the log was emitted
125
133
  */
126
- error(message, details) {
127
- return this.#log(ERROR, message, details);
134
+ error(originalErrorOrMessage, originalError) {
135
+
136
+ if( originalErrorOrMessage instanceof Error )
137
+ {
138
+ // params: {error} originalErrorOrMessage
139
+ const loggerError = new LoggerError(originalErrorOrMessage);
140
+
141
+ const message = originalErrorOrMessage.message;
142
+
143
+ return this.#log(ERROR, message, loggerError);
144
+ }
145
+ else if( typeof originalErrorOrMessage === 'string' && originalError instanceof Error ) {
146
+ // params: {string} message, {error} originalError
147
+ const detailedError = new DetailedError(
148
+ originalErrorOrMessage,
149
+ null,
150
+ originalError
151
+ );
152
+
153
+ return this.#log(ERROR, detailedError.message, detailedError);
154
+ }
155
+ else {
156
+ // wrong params
157
+ const detailedError = new DetailedError(
158
+ 'Invalid parameters supplied to Logger.error',
159
+ toArray(arguments)
160
+ );
161
+
162
+ return this.#log(ERROR, detailedError.message, detailedError);
163
+ }
128
164
  }
129
165
 
130
166
  /**
@@ -132,7 +168,6 @@ export default class Logger extends EventEmitter {
132
168
  *
133
169
  * @param {string} namespace
134
170
  * Namespace of the context (needed for chaining contexts)
135
- *
136
171
  * @param {Object} additionalContext - Additional context data
137
172
  *
138
173
  * @returns {Logger} New logger instance with merged context
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Test functions for generating various types of errors for logging demonstration
3
+ */
4
+ /**
5
+ * Simple error: division by zero (which creates NaN in JS, so we'll throw manually)
6
+ */
7
+ export function throwSimpleError(): number;
8
+ /**
9
+ * Simple error occurring in a sub function
10
+ */
11
+ export function throwErrorInSubFunction(): void;
12
+ /**
13
+ * Promise rejection in async function
14
+ */
15
+ export function throwPromiseRejection(): Promise<any>;
16
+ /**
17
+ * HkPromise timeout
18
+ */
19
+ export function throwHkPromiseTimeout(): Promise<any>;
20
+ /**
21
+ * HTTP request that fails
22
+ */
23
+ export function throwHttpException(): Promise<Response>;
24
+ /**
25
+ * Expect validation error
26
+ */
27
+ export function throwExpectError(): void;
28
+ /**
29
+ * Rethrow chain error
30
+ */
31
+ export function throwRethrowChainError(): void;
32
+ /**
33
+ * Raw valibot validation error (without expect wrapper)
34
+ */
35
+ export function throwRawValibotError(): any;
@@ -0,0 +1,137 @@
1
+ import { expect, rethrow } from '../../util/index.js';
2
+ import { HkPromise } from '../../generic/promises.js';
3
+ import { httpGet } from '../../network/http/index.js';
4
+ import { v } from '../../valibot/index.js';
5
+
6
+ /**
7
+ * Test functions for generating various types of errors for logging demonstration
8
+ */
9
+
10
+ /**
11
+ * Simple error: division by zero (which creates NaN in JS, so we'll throw manually)
12
+ */
13
+ export function throwSimpleError() {
14
+ const a = 10;
15
+ const b = 0;
16
+
17
+ if (b === 0) {
18
+ throw new Error('Division by zero is not allowed');
19
+ }
20
+
21
+ return a / b; // This won't be reached
22
+ }
23
+
24
+ /**
25
+ * Simple error occurring in a sub function
26
+ */
27
+ export function throwErrorInSubFunction() {
28
+ function deepFunction() {
29
+ function evenDeeperFunction() {
30
+ throw new Error('Error occurred in deeply nested function');
31
+ }
32
+
33
+ evenDeeperFunction();
34
+ }
35
+
36
+ function callDeepFunction() {
37
+ deepFunction();
38
+ }
39
+
40
+ callDeepFunction();
41
+ }
42
+
43
+ /**
44
+ * Promise rejection in async function
45
+ */
46
+ export async function throwPromiseRejection() {
47
+ // Create a promise that rejects after a short delay
48
+ const rejectedPromise = new Promise((resolve, reject) => {
49
+ setTimeout(() => {
50
+ reject(new Error('Promise was rejected after timeout'));
51
+ }, 100);
52
+ });
53
+
54
+ // Await the promise (will throw)
55
+ return await rejectedPromise;
56
+ }
57
+
58
+ /**
59
+ * HkPromise timeout
60
+ */
61
+ export async function throwHkPromiseTimeout() {
62
+ // Create an HkPromise that times out
63
+ const timeoutPromise = new HkPromise((resolve) => {
64
+ // Never resolve this promise to cause timeout
65
+ setTimeout(() => {
66
+ // This resolve will never be reached because timeout occurs first
67
+ resolve('This should not complete');
68
+ }, 2000);
69
+ });
70
+
71
+ // Set timeout of 500ms (will timeout before the 2000ms resolve)
72
+ timeoutPromise.setTimeout(500, 'HkPromise timeout after 500ms');
73
+
74
+ return await timeoutPromise;
75
+ }
76
+
77
+ /**
78
+ * HTTP request that fails
79
+ */
80
+ export async function throwHttpException() {
81
+ // Try to fetch with an invalid URL format
82
+ const response = await httpGet({
83
+ url: 'not-a-valid-url-format'
84
+ });
85
+ return response;
86
+ }
87
+
88
+ /**
89
+ * Expect validation error
90
+ */
91
+ export function throwExpectError() {
92
+ try {
93
+ // This will always fail and trigger an expect error
94
+ expect.string(123);
95
+ } catch (e) {
96
+ rethrow('throwExpectError failed', e);
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Rethrow chain error
102
+ */
103
+ export function throwRethrowChainError() {
104
+ function level1Function() {
105
+ try {
106
+ level2Function();
107
+ } catch (e) {
108
+ rethrow('Error in level1Function', e);
109
+ }
110
+ }
111
+
112
+ function level2Function() {
113
+ try {
114
+ level3Function();
115
+ } catch (e) {
116
+ rethrow('Error in level2Function', e);
117
+ }
118
+ }
119
+
120
+ function level3Function() {
121
+ throw new Error('Original error at deepest level');
122
+ }
123
+
124
+ level1Function();
125
+ }
126
+
127
+ /**
128
+ * Raw valibot validation error (without expect wrapper)
129
+ */
130
+ export function throwRawValibotError() {
131
+ // This calls valibot.parse directly, not through expect_*
132
+ const schema = v.string();
133
+ const invalidValue = 456;
134
+
135
+ // This will throw a ValiError directly from our valibotParser wrapper
136
+ return v.parse(schema, invalidValue);
137
+ }
@@ -50,7 +50,7 @@ export default class IndexedDbCache {
50
50
  * @private
51
51
  */
52
52
  private cleanupState;
53
- postponeCleanupTimer: number;
53
+ postponeCleanupTimer: NodeJS.Timeout;
54
54
  /**
55
55
  * Initialize the database connection
56
56
  *
@@ -28,6 +28,7 @@
28
28
  * @property {number|null} expires - Expiration timestamp (null if no expiration)
29
29
  * @property {string|null} etag - ETag header if present
30
30
  * @property {string|null} lastModified - Last-Modified header if present
31
+ * @property {string|null} cacheVersion - Cache version identifier
31
32
  */
32
33
  /**
33
34
  * In-memory response cache implementation
@@ -103,4 +104,8 @@ export type CacheEntry = {
103
104
  * - Last-Modified header if present
104
105
  */
105
106
  lastModified: string | null;
107
+ /**
108
+ * - Cache version identifier
109
+ */
110
+ cacheVersion: string | null;
106
111
  };
@@ -29,6 +29,7 @@
29
29
  * @property {number|null} expires - Expiration timestamp (null if no expiration)
30
30
  * @property {string|null} etag - ETag header if present
31
31
  * @property {string|null} lastModified - Last-Modified header if present
32
+ * @property {string|null} cacheVersion - Cache version identifier
32
33
  */
33
34
 
34
35
  /**
@@ -75,7 +76,8 @@ export default class MemoryResponseCache {
75
76
  timestamp: entry.timestamp,
76
77
  expires: entry.expires,
77
78
  etag: entry.etag,
78
- lastModified: entry.lastModified
79
+ lastModified: entry.lastModified,
80
+ cacheVersion: entry.cacheVersion
79
81
  };
80
82
  }
81
83
 
@@ -104,7 +106,8 @@ export default class MemoryResponseCache {
104
106
  lastAccessed: now,
105
107
  expires,
106
108
  etag: response.headers.get('ETag'),
107
- lastModified: response.headers.get('Last-Modified')
109
+ lastModified: response.headers.get('Last-Modified'),
110
+ cacheVersion: metadata.cacheVersion || null
108
111
  });
109
112
  }
110
113
 
@@ -0,0 +1,2 @@
1
+ export * from "./errors/api.js";
2
+ export * from "./errors/http.js";
@@ -0,0 +1,2 @@
1
+ export * from './errors/api.js';
2
+ export * from './errors/http.js';
@@ -135,7 +135,7 @@ export async function getCachedResponse(cacheKeyParams) {
135
135
  * @param {string} type Type of storage ('indexed-db', 'memory')
136
136
  * @param {Object} options Options for the storage adapter
137
137
  *
138
- * @returns {import('../../classes/cache').CacheStorage}
138
+ * @returns {import('../cache.js').CacheStorage}
139
139
  */
140
140
  function createCacheStorage(type = 'indexed-db', options = {}) {
141
141
  switch (type) {
@@ -13,6 +13,6 @@
13
13
  *
14
14
  * @param {object} response
15
15
  *
16
- * @returns {Error} error
16
+ * @returns {Promise<Error>} error
17
17
  */
18
- export function getErrorFromResponse(response: object): Error;
18
+ export function getErrorFromResponse(response: object): Promise<Error>;
@@ -1,4 +1,5 @@
1
1
  import * as expect from '../../util/expect/index.js';
2
+ import { DetailedError } from '../../generic/errors.js';
2
3
 
3
4
  import { CONTENT_TYPE } from '../../constants/http/index.js';
4
5
 
@@ -19,7 +20,7 @@ import { APPLICATION_JSON } from '../../constants/mime/index.js';
19
20
  *
20
21
  * @param {object} response
21
22
  *
22
- * @returns {Error} error
23
+ * @returns {Promise<Error>} error
23
24
  */
24
25
  export async function getErrorFromResponse(response) {
25
26
  expect.object(response);
@@ -77,21 +78,12 @@ export async function getErrorFromResponse(response) {
77
78
  }
78
79
  }
79
80
  } else {
80
- const tmp = await response.text();
81
-
82
- if (tmp.length) {
83
- message = tmp;
84
- } else {
85
- message = response.statusText;
86
- }
81
+ // For non-JSON responses, always use status text (avoid HTML pages)
82
+ message = response.statusText || `HTTP ${response.status}`;
87
83
  }
88
84
  // console.log( "message", message );
89
85
 
90
- const error = new Error(message);
91
-
92
- if (details) {
93
- error.details = details;
94
- }
86
+ const error = new DetailedError(message, details);
95
87
 
96
88
  return error;
97
89
  }
@@ -11,7 +11,7 @@ import {
11
11
  import { APPLICATION_JSON } from '../../constants/mime/application.js';
12
12
  import { CONTENT_TYPE } from '../../constants/http/headers.js';
13
13
 
14
- import { AbortError, TimeoutError } from '../../errors/api.js';
14
+ import { AbortError, TimeoutError } from '../errors/api.js';
15
15
 
16
16
  import * as expect from '../../util/expect/index.js';
17
17
 
@@ -2,7 +2,7 @@ import { METHOD_GET, METHOD_POST } from '../../constants/http/methods.js';
2
2
 
3
3
  import { APPLICATION_JSON } from '../../constants/mime/application.js';
4
4
  import { CONTENT_TYPE } from '../../constants/http/headers.js';
5
- import { ResponseError } from '../../errors/index.js';
5
+ import { ResponseError } from '../errors.js';
6
6
 
7
7
  import * as expect from '../../util/expect/index.js';
8
8
 
@@ -1,4 +1,4 @@
1
- import { ResponseError, HttpError } from '../../errors/index.js';
1
+ import { ResponseError, HttpError } from '../errors.js';
2
2
  import * as expect from '../../util/expect/index.js';
3
3
  import { toURL } from './url.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { TypeOrValueError } from '../../errors/index.js';
1
+ import { TypeOrValueError } from '../../generic/errors.js';
2
2
 
3
3
  /**
4
4
  * Returns an URL instance
@@ -44,22 +44,29 @@ Loads responsive image variants, automatically selecting the best size for conta
44
44
  ```javascript
45
45
  import { ImageVariantsLoader } from '$lib/network/loaders.js';
46
46
 
47
- const loader = new ImageVariantsLoader();
48
-
49
- // Load responsive variants
47
+ // Responsive image variants (array of ImageMeta)
50
48
  const imageSource = [
51
49
  { src: '/image-400.jpg', width: 400, height: 300 },
52
50
  { src: '/image-800.jpg', width: 800, height: 600 },
53
51
  { src: '/image-1200.jpg', width: 1200, height: 900 }
54
52
  ];
55
53
 
56
- await loader.load({
57
- imageSource,
54
+ const loader = new ImageVariantsLoader(imageSource, {
55
+ devicePixelRatio: window.devicePixelRatio
56
+ });
57
+
58
+ // Set optimal image variant for container
59
+ loader.setOptimalImageVariant({
58
60
  containerWidth: 600,
59
61
  containerHeight: 400,
60
- fit: 'cover', // or 'contain', 'fill'
61
- devicePixelRatio: window.devicePixelRatio
62
+ fit: 'cover' // or 'contain', 'fill'
62
63
  });
64
+
65
+ // Access the selected variant and loader
66
+ if (loader.loaded) {
67
+ const objectURL = loader.getObjectURL();
68
+ // Use objectURL in img src
69
+ }
63
70
  ```
64
71
 
65
72
  ### ImageScene
@@ -1,7 +1,8 @@
1
1
  import * as expect from '../../../util/expect/index.js';
2
2
 
3
+ import { LoadingStateMachine } from '../../../state/classes.js';
4
+
3
5
  import {
4
- LoadingStateMachine,
5
6
  STATE_INITIAL,
6
7
  STATE_LOADING,
7
8
  STATE_UNLOADING,
@@ -10,7 +11,7 @@ import {
10
11
  STATE_ERROR,
11
12
  LOAD,
12
13
  LOADED
13
- } from '../../../classes/svelte/loading-state-machine/index.js';
14
+ } from '../../../state/classes/loading-state-machine/constants.js';
14
15
 
15
16
  import AudioLoader from './AudioLoader.svelte.js';
16
17
 
@@ -5,9 +5,9 @@
5
5
  */
6
6
  export default class ImageLoader extends NetworkLoader {
7
7
  /**
8
- * @param {import('../typedef.js').ImageSource} imageSource
8
+ * @param {import('../../../config/typedef.js').ImageSource} imageSource
9
9
  */
10
- constructor(imageSource: import("../typedef.js").ImageSource);
10
+ constructor(imageSource: import("../../../config/typedef.js").ImageSource);
11
11
  get imageMeta(): import("./typedef.js").ImageMeta;
12
12
  get url(): string;
13
13
  #private;
@@ -16,7 +16,7 @@ export default class ImageLoader extends NetworkLoader {
16
16
  #imageMeta;
17
17
 
18
18
  /**
19
- * @param {import('../typedef.js').ImageSource} imageSource
19
+ * @param {import('../../../config/typedef.js').ImageSource} imageSource
20
20
  */
21
21
  constructor(imageSource) {
22
22
  const imageMeta = toSingleImageMeta(imageSource);
@@ -17,11 +17,11 @@ export default class ImageScene {
17
17
  *
18
18
  * @param {object} _
19
19
  * @param {string} _.label
20
- * @param {import('../typedef.js').ImageSource} _.imageSource
20
+ * @param {import('../../../config/typedef.js').ImageSource} _.imageSource
21
21
  */
22
22
  defineImage({ label, imageSource }: {
23
23
  label: string;
24
- imageSource: import("../typedef.js").ImageSource;
24
+ imageSource: import("../../../config/typedef.js").ImageSource;
25
25
  }): void;
26
26
  /**
27
27
  * Start loading all image sources
@@ -2,8 +2,9 @@
2
2
 
3
3
  import * as expect from '../../../util/expect/index.js';
4
4
 
5
+ import { LoadingStateMachine } from '../../../state/classes.js';
6
+
5
7
  import {
6
- LoadingStateMachine,
7
8
  STATE_INITIAL,
8
9
  STATE_LOADING,
9
10
  STATE_UNLOADING,
@@ -12,7 +13,7 @@ import {
12
13
  STATE_ERROR,
13
14
  LOAD,
14
15
  LOADED
15
- } from '../../../classes/svelte/loading-state-machine/index.js';
16
+ } from '../../../state/classes/loading-state-machine/constants.js';
16
17
 
17
18
  import ImageLoader from './ImageLoader.svelte.js';
18
19
 
@@ -148,7 +149,7 @@ export default class ImageScene {
148
149
  *
149
150
  * @param {object} _
150
151
  * @param {string} _.label
151
- * @param {import('../typedef.js').ImageSource} _.imageSource
152
+ * @param {import('../../../config/typedef.js').ImageSource} _.imageSource
152
153
  */
153
154
  defineImage({ label, imageSource }) {
154
155
  expect.notEmptyString(label);
@@ -188,7 +189,7 @@ export default class ImageScene {
188
189
  *
189
190
  * @returns {ImageSceneSource}
190
191
  */
191
- #getImageSource(label) {
192
+ #getImageSceneSource(label) {
192
193
  for (const source of this.#imageSources) {
193
194
  if (label === source.label) {
194
195
  return source;
@@ -213,7 +214,7 @@ export default class ImageScene {
213
214
  * @returns {ImageLoader}
214
215
  */
215
216
  getImageLoader(label) {
216
- const source = this.#getImageSource(label);
217
+ const source = this.#getImageSceneSource(label);
217
218
 
218
219
  return source.imageLoader;
219
220
  }
@@ -226,9 +227,9 @@ export default class ImageScene {
226
227
  * @returns {ImageMeta}
227
228
  */
228
229
  getImageMeta(label) {
229
- const source = this.#getImageSource(label);
230
+ const source = this.#getImageSceneSource(label);
230
231
 
231
- return source.imageMeta;
232
+ return source.imageLoader.imageMeta;
232
233
  }
233
234
 
234
235
  /**
@@ -241,7 +242,7 @@ export default class ImageScene {
241
242
  * @returns {string}
242
243
  */
243
244
  getObjectURL(label) {
244
- const source = this.#getImageSource(label);
245
+ const source = this.#getImageSceneSource(label);
245
246
 
246
247
  return source.imageLoader.getObjectURL();
247
248
  }