@hkdigital/lib-core 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (485) hide show
  1. package/README.md +149 -0
  2. package/dist/assets/autospuiten/car-paint-picker/army-green.jpg +0 -0
  3. package/dist/assets/autospuiten/car-paint-picker/electric-blue.jpg +0 -0
  4. package/dist/assets/autospuiten/car-paint-picker/lemon-yellow.jpg +0 -0
  5. package/dist/assets/autospuiten/car-paint-picker/opaque-purple.jpg +0 -0
  6. package/dist/assets/autospuiten/car-paint-picker/rusty.jpg +0 -0
  7. package/dist/assets/autospuiten/car-paint-picker/sunset-orange.jpg +0 -0
  8. package/dist/assets/autospuiten/car-paint-picker/tomato-red.jpg +0 -0
  9. package/dist/assets/autospuiten/car-paint-picker.d.ts +17 -0
  10. package/dist/assets/autospuiten/car-paint-picker.js +41 -0
  11. package/dist/assets/autospuiten/labels.d.ts +7 -0
  12. package/dist/assets/autospuiten/labels.js +7 -0
  13. package/dist/classes/cache/IndexedDbCache.d.ts +216 -0
  14. package/dist/classes/cache/IndexedDbCache.js +1407 -0
  15. package/dist/classes/cache/MemoryResponseCache.d.ts +106 -0
  16. package/dist/classes/cache/MemoryResponseCache.js +138 -0
  17. package/dist/classes/cache/index.d.ts +3 -0
  18. package/dist/classes/cache/index.js +5 -0
  19. package/dist/classes/cache/typedef.d.ts +67 -0
  20. package/dist/classes/cache/typedef.js +41 -0
  21. package/dist/classes/data/IterableTree.d.ts +51 -0
  22. package/dist/classes/data/IterableTree.js +243 -0
  23. package/dist/classes/data/Selector.d.ts +30 -0
  24. package/dist/classes/data/Selector.js +190 -0
  25. package/dist/classes/data/index.d.ts +2 -0
  26. package/dist/classes/data/index.js +2 -0
  27. package/dist/classes/events/EventEmitter.d.ts +142 -0
  28. package/dist/classes/events/EventEmitter.js +275 -0
  29. package/dist/classes/events/index.d.ts +1 -0
  30. package/dist/classes/events/index.js +2 -0
  31. package/dist/classes/index.d.ts +4 -0
  32. package/dist/classes/index.js +4 -0
  33. package/dist/classes/logging/Logger.d.ts +78 -0
  34. package/dist/classes/logging/Logger.js +210 -0
  35. package/dist/classes/logging/constants.d.ts +12 -0
  36. package/dist/classes/logging/constants.js +16 -0
  37. package/dist/classes/logging/index.d.ts +2 -0
  38. package/dist/classes/logging/index.js +4 -0
  39. package/dist/classes/logging/typedef.d.ts +34 -0
  40. package/dist/classes/logging/typedef.js +17 -0
  41. package/dist/classes/promise/HkPromise.d.ts +121 -0
  42. package/dist/classes/promise/HkPromise.js +377 -0
  43. package/dist/classes/promise/index.d.ts +1 -0
  44. package/dist/classes/promise/index.js +1 -0
  45. package/dist/classes/services/ServiceBase.d.ts +163 -0
  46. package/dist/classes/services/ServiceBase.js +463 -0
  47. package/dist/classes/services/ServiceManager.d.ts +179 -0
  48. package/dist/classes/services/ServiceManager.js +614 -0
  49. package/dist/classes/services/index.d.ts +4 -0
  50. package/dist/classes/services/index.js +5 -0
  51. package/dist/classes/services/service-states.d.ts +159 -0
  52. package/dist/classes/services/service-states.js +205 -0
  53. package/dist/classes/services/typedef.d.ts +247 -0
  54. package/dist/classes/services/typedef.js +179 -0
  55. package/dist/classes/stores/SubscribersCount.d.ts +39 -0
  56. package/dist/classes/stores/SubscribersCount.js +107 -0
  57. package/dist/classes/stores/index.d.ts +1 -0
  58. package/dist/classes/stores/index.js +1 -0
  59. package/dist/classes/streams/LogTransformStream.d.ts +4 -0
  60. package/dist/classes/streams/LogTransformStream.js +19 -0
  61. package/dist/classes/streams/ServerEventsStore.d.ts +22 -0
  62. package/dist/classes/streams/ServerEventsStore.js +110 -0
  63. package/dist/classes/streams/TimeStampSource.d.ts +13 -0
  64. package/dist/classes/streams/TimeStampSource.js +26 -0
  65. package/dist/classes/streams/index.d.ts +3 -0
  66. package/dist/classes/streams/index.js +3 -0
  67. package/dist/classes/svelte/audio/AudioLoader.svelte.d.ts +30 -0
  68. package/dist/classes/svelte/audio/AudioLoader.svelte.js +58 -0
  69. package/dist/classes/svelte/audio/AudioScene.svelte.d.ts +74 -0
  70. package/dist/classes/svelte/audio/AudioScene.svelte.js +324 -0
  71. package/dist/classes/svelte/audio/mocks.d.ts +7 -0
  72. package/dist/classes/svelte/audio/mocks.js +35 -0
  73. package/dist/classes/svelte/finite-state-machine/FiniteStateMachine.svelte.d.ts +50 -0
  74. package/dist/classes/svelte/finite-state-machine/FiniteStateMachine.svelte.js +133 -0
  75. package/dist/classes/svelte/finite-state-machine/index.d.ts +1 -0
  76. package/dist/classes/svelte/finite-state-machine/index.js +1 -0
  77. package/dist/classes/svelte/image/ImageLoader.svelte.d.ts +19 -0
  78. package/dist/classes/svelte/image/ImageLoader.svelte.js +45 -0
  79. package/dist/classes/svelte/image/ImageScene.svelte.d.ts +78 -0
  80. package/dist/classes/svelte/image/ImageScene.svelte.js +249 -0
  81. package/dist/classes/svelte/image/ImageVariantsLoader.svelte.d.ts +43 -0
  82. package/dist/classes/svelte/image/ImageVariantsLoader.svelte.js +152 -0
  83. package/dist/classes/svelte/image/index.d.ts +2 -0
  84. package/dist/classes/svelte/image/index.js +4 -0
  85. package/dist/classes/svelte/image/mocks.d.ts +7 -0
  86. package/dist/classes/svelte/image/mocks.js +35 -0
  87. package/dist/classes/svelte/image/typedef.d.ts +16 -0
  88. package/dist/classes/svelte/image/typedef.js +8 -0
  89. package/dist/classes/svelte/index.d.ts +9 -0
  90. package/dist/classes/svelte/index.js +14 -0
  91. package/dist/classes/svelte/loading-state-machine/LoadingStateMachine.svelte.d.ts +12 -0
  92. package/dist/classes/svelte/loading-state-machine/LoadingStateMachine.svelte.js +109 -0
  93. package/dist/classes/svelte/loading-state-machine/constants.d.ts +12 -0
  94. package/dist/classes/svelte/loading-state-machine/constants.js +16 -0
  95. package/dist/classes/svelte/loading-state-machine/index.d.ts +2 -0
  96. package/dist/classes/svelte/loading-state-machine/index.js +3 -0
  97. package/dist/classes/svelte/network-loader/NetworkLoader.svelte.d.ts +91 -0
  98. package/dist/classes/svelte/network-loader/NetworkLoader.svelte.js +338 -0
  99. package/dist/classes/svelte/network-loader/constants.d.ts +2 -0
  100. package/dist/classes/svelte/network-loader/constants.js +3 -0
  101. package/dist/classes/svelte/network-loader/index.d.ts +2 -0
  102. package/dist/classes/svelte/network-loader/index.js +3 -0
  103. package/dist/classes/svelte/network-loader/mocks.d.ts +7 -0
  104. package/dist/classes/svelte/network-loader/mocks.js +30 -0
  105. package/dist/classes/svelte/network-loader/typedef.d.ts +7 -0
  106. package/dist/classes/svelte/network-loader/typedef.js +8 -0
  107. package/dist/components/area/HkArea.svelte +49 -0
  108. package/dist/components/area/HkArea.svelte.d.ts +26 -0
  109. package/dist/components/area/HkGridArea.svelte +77 -0
  110. package/dist/components/area/HkGridArea.svelte.d.ts +42 -0
  111. package/dist/components/area/index.d.ts +2 -0
  112. package/dist/components/area/index.js +2 -0
  113. package/dist/components/buttons/button/Button.svelte +82 -0
  114. package/dist/components/buttons/button/Button.svelte.d.ts +44 -0
  115. package/dist/components/buttons/button-icon-steeze/SteezeIconButton.svelte +30 -0
  116. package/dist/components/buttons/button-icon-steeze/SteezeIconButton.svelte.d.ts +16 -0
  117. package/dist/components/buttons/button-text/TextButton.svelte +21 -0
  118. package/dist/components/buttons/button-text/TextButton.svelte.d.ts +12 -0
  119. package/dist/components/buttons/index.d.ts +3 -0
  120. package/dist/components/buttons/index.js +3 -0
  121. package/dist/components/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte +146 -0
  122. package/dist/components/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte.d.ts +6 -0
  123. package/dist/components/debug/index.d.ts +1 -0
  124. package/dist/components/debug/index.js +1 -0
  125. package/dist/components/drag-drop/DragController.d.ts +20 -0
  126. package/dist/components/drag-drop/DragController.js +44 -0
  127. package/dist/components/drag-drop/DragDropContext.svelte +111 -0
  128. package/dist/components/drag-drop/DragDropContext.svelte.d.ts +18 -0
  129. package/dist/components/drag-drop/Draggable.svelte +519 -0
  130. package/dist/components/drag-drop/Draggable.svelte.d.ts +95 -0
  131. package/dist/components/drag-drop/DropZone.svelte +258 -0
  132. package/dist/components/drag-drop/DropZone.svelte.d.ts +96 -0
  133. package/dist/components/drag-drop/DropZoneArea.svelte +119 -0
  134. package/dist/components/drag-drop/DropZoneArea.svelte.d.ts +90 -0
  135. package/dist/components/drag-drop/DropZoneList.svelte +125 -0
  136. package/dist/components/drag-drop/DropZoneList.svelte.d.ts +92 -0
  137. package/dist/components/drag-drop/actions.d.ts +9 -0
  138. package/dist/components/drag-drop/actions.js +26 -0
  139. package/dist/components/drag-drop/drag-state.svelte.d.ts +97 -0
  140. package/dist/components/drag-drop/drag-state.svelte.js +322 -0
  141. package/dist/components/drag-drop/index.d.ts +6 -0
  142. package/dist/components/drag-drop/index.js +7 -0
  143. package/dist/components/drag-drop/util.d.ts +0 -0
  144. package/dist/components/drag-drop/util.js +85 -0
  145. package/dist/components/hkdev/blocks/TextBlock.svelte +47 -0
  146. package/dist/components/hkdev/blocks/TextBlock.svelte.d.ts +24 -0
  147. package/dist/components/hkdev/buttons/CheckButton.svelte +63 -0
  148. package/dist/components/hkdev/buttons/CheckButton.svelte.d.ts +34 -0
  149. package/dist/components/icons/HkIcon.svelte +86 -0
  150. package/dist/components/icons/HkIcon.svelte.d.ts +22 -0
  151. package/dist/components/icons/HkTabIcon.svelte +116 -0
  152. package/dist/components/icons/HkTabIcon.svelte.d.ts +40 -0
  153. package/dist/components/icons/SteezeIcon.svelte +97 -0
  154. package/dist/components/icons/SteezeIcon.svelte.d.ts +22 -0
  155. package/dist/components/icons/index.d.ts +4 -0
  156. package/dist/components/icons/index.js +6 -0
  157. package/dist/components/icons/typedef.d.ts +13 -0
  158. package/dist/components/icons/typedef.js +16 -0
  159. package/dist/components/index.d.ts +0 -0
  160. package/dist/components/index.js +2 -0
  161. package/dist/components/inputs/index.d.ts +1 -0
  162. package/dist/components/inputs/index.js +1 -0
  163. package/dist/components/inputs/text-input/TestTextInput.svelte__ +102 -0
  164. package/dist/components/inputs/text-input/TextInput.svelte +223 -0
  165. package/dist/components/inputs/text-input/TextInput.svelte.d.ts +56 -0
  166. package/dist/components/inputs/text-input/TextInput.svelte___ +83 -0
  167. package/dist/components/inputs/text-input/assets/IconInvalid.svelte +14 -0
  168. package/dist/components/inputs/text-input/assets/IconInvalid.svelte.d.ts +26 -0
  169. package/dist/components/inputs/text-input/assets/IconValid.svelte +12 -0
  170. package/dist/components/inputs/text-input/assets/IconValid.svelte.d.ts +26 -0
  171. package/dist/components/layout/grid-layers/GridLayers.svelte +63 -0
  172. package/dist/components/layout/grid-layers/GridLayers.svelte.d.ts +26 -0
  173. package/dist/components/layout/grid-layers/GridLayers.svelte__heightFrom__ +372 -0
  174. package/dist/components/layout/grid-layers/util.d.ts +19 -0
  175. package/dist/components/layout/grid-layers/util.js +74 -0
  176. package/dist/components/layout/index.d.ts +1 -0
  177. package/dist/components/layout/index.js +1 -0
  178. package/dist/components/panels/index.d.ts +1 -0
  179. package/dist/components/panels/index.js +1 -0
  180. package/dist/components/panels/panel/Panel.svelte +43 -0
  181. package/dist/components/panels/panel/Panel.svelte.d.ts +24 -0
  182. package/dist/components/rows/index.d.ts +2 -0
  183. package/dist/components/rows/index.js +3 -0
  184. package/dist/components/rows/panel-grid-row/PanelGridRow.svelte +104 -0
  185. package/dist/components/rows/panel-grid-row/PanelGridRow.svelte.d.ts +26 -0
  186. package/dist/components/rows/panel-row-2/PanelRow2.svelte +40 -0
  187. package/dist/components/rows/panel-row-2/PanelRow2.svelte.d.ts +26 -0
  188. package/dist/components/tab-bar/HkTabBar.state.svelte.d.ts +54 -0
  189. package/dist/components/tab-bar/HkTabBar.state.svelte.js +149 -0
  190. package/dist/components/tab-bar/HkTabBar.svelte +74 -0
  191. package/dist/components/tab-bar/HkTabBar.svelte.d.ts +34 -0
  192. package/dist/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +19 -0
  193. package/dist/components/tab-bar/HkTabBarSelector.state.svelte.js +93 -0
  194. package/dist/components/tab-bar/HkTabBarSelector.svelte +49 -0
  195. package/dist/components/tab-bar/HkTabBarSelector.svelte.d.ts +36 -0
  196. package/dist/components/tab-bar/index.d.ts +5 -0
  197. package/dist/components/tab-bar/index.js +17 -0
  198. package/dist/components/tab-bar/typedef.d.ts +8 -0
  199. package/dist/components/tab-bar/typedef.js +11 -0
  200. package/dist/config/imagetools-config.d.ts +26 -0
  201. package/dist/config/imagetools-config.js +189 -0
  202. package/dist/config/imagetools.d.ts +72 -0
  203. package/dist/constants/bases.d.ts +10 -0
  204. package/dist/constants/bases.js +13 -0
  205. package/dist/constants/errors/api.d.ts +10 -0
  206. package/dist/constants/errors/api.js +9 -0
  207. package/dist/constants/errors/generic.d.ts +20 -0
  208. package/dist/constants/errors/generic.js +20 -0
  209. package/dist/constants/errors/http.d.ts +16 -0
  210. package/dist/constants/errors/http.js +16 -0
  211. package/dist/constants/errors/index.d.ts +4 -0
  212. package/dist/constants/errors/index.js +4 -0
  213. package/dist/constants/errors/jwt.d.ts +8 -0
  214. package/dist/constants/errors/jwt.js +5 -0
  215. package/dist/constants/http/headers.d.ts +5 -0
  216. package/dist/constants/http/headers.js +6 -0
  217. package/dist/constants/http/index.d.ts +2 -0
  218. package/dist/constants/http/index.js +2 -0
  219. package/dist/constants/http/methods.d.ts +7 -0
  220. package/dist/constants/http/methods.js +14 -0
  221. package/dist/constants/index.d.ts +2 -0
  222. package/dist/constants/index.js +3 -0
  223. package/dist/constants/mime/application.d.ts +3 -0
  224. package/dist/constants/mime/application.js +5 -0
  225. package/dist/constants/mime/audio.d.ts +10 -0
  226. package/dist/constants/mime/audio.js +13 -0
  227. package/dist/constants/mime/image.d.ts +3 -0
  228. package/dist/constants/mime/image.js +3 -0
  229. package/dist/constants/mime/index.d.ts +4 -0
  230. package/dist/constants/mime/index.js +4 -0
  231. package/dist/constants/mime/text.d.ts +2 -0
  232. package/dist/constants/mime/text.js +2 -0
  233. package/dist/constants/regexp/index.d.ts +3 -0
  234. package/dist/constants/regexp/index.js +31 -0
  235. package/dist/constants/regexp/inspiratie.js__ +95 -0
  236. package/dist/constants/regexp/text.d.ts +47 -0
  237. package/dist/constants/regexp/text.js +49 -0
  238. package/dist/constants/regexp/user.d.ts +6 -0
  239. package/dist/constants/regexp/user.js +33 -0
  240. package/dist/constants/regexp/web.d.ts +1 -0
  241. package/dist/constants/regexp/web.js +3 -0
  242. package/dist/constants/state-labels/drag-states.d.ts +5 -0
  243. package/dist/constants/state-labels/drag-states.js +6 -0
  244. package/dist/constants/state-labels/drop-states.d.ts +4 -0
  245. package/dist/constants/state-labels/drop-states.js +6 -0
  246. package/dist/constants/state-labels/input-states.d.ts +8 -0
  247. package/dist/constants/state-labels/input-states.js +11 -0
  248. package/dist/constants/state-labels/submit-states.d.ts +4 -0
  249. package/dist/constants/state-labels/submit-states.js +4 -0
  250. package/dist/constants/time.d.ts +18 -0
  251. package/dist/constants/time.js +28 -0
  252. package/dist/css/utilities.css +43 -0
  253. package/dist/design/design-config.d.ts +157 -0
  254. package/dist/design/design-config.js +73 -0
  255. package/dist/design/tailwind-theme-extend.d.ts +23 -0
  256. package/dist/design/tailwind-theme-extend.js +158 -0
  257. package/dist/features/button-group/ButtonGroup.svelte +82 -0
  258. package/dist/features/button-group/ButtonGroup.svelte.d.ts +34 -0
  259. package/dist/features/button-group/typedef.d.ts +7 -0
  260. package/dist/features/button-group/typedef.js +10 -0
  261. package/dist/features/compare-left-right/CompareLeftRight.svelte +179 -0
  262. package/dist/features/compare-left-right/CompareLeftRight.svelte.d.ts +18 -0
  263. package/dist/features/compare-left-right/index.d.ts +1 -0
  264. package/dist/features/compare-left-right/index.js +1 -0
  265. package/dist/features/game-box/GameBox.svelte +577 -0
  266. package/dist/features/game-box/GameBox.svelte.d.ts +140 -0
  267. package/dist/features/game-box/gamebox.util.d.ts +32 -0
  268. package/dist/features/game-box/gamebox.util.js +83 -0
  269. package/dist/features/hk-app-layout/HkAppLayout.state.svelte.d.ts +6 -0
  270. package/dist/features/hk-app-layout/HkAppLayout.state.svelte.js +25 -0
  271. package/dist/features/hk-app-layout/HkAppLayout.svelte +251 -0
  272. package/dist/features/hk-app-layout/HkAppLayout.svelte.d.ts +19 -0
  273. package/dist/features/image-box/ImageBox.svelte +210 -0
  274. package/dist/features/image-box/ImageBox.svelte.d.ts +38 -0
  275. package/dist/features/image-box/index.d.ts +4 -0
  276. package/dist/features/image-box/index.js +5 -0
  277. package/dist/features/image-box/typedef.d.ts +4 -0
  278. package/dist/features/image-box/typedef.js +32 -0
  279. package/dist/features/index.d.ts +11 -0
  280. package/dist/features/index.js +23 -0
  281. package/dist/features/presenter/ImageSlide.svelte +64 -0
  282. package/dist/features/presenter/ImageSlide.svelte.d.ts +36 -0
  283. package/dist/features/presenter/Presenter.state.svelte.d.ts +74 -0
  284. package/dist/features/presenter/Presenter.state.svelte.js +638 -0
  285. package/dist/features/presenter/Presenter.svelte +142 -0
  286. package/dist/features/presenter/Presenter.svelte.d.ts +18 -0
  287. package/dist/features/presenter/constants.d.ts +5 -0
  288. package/dist/features/presenter/constants.js +7 -0
  289. package/dist/features/presenter/index.d.ts +6 -0
  290. package/dist/features/presenter/index.js +10 -0
  291. package/dist/features/presenter/typedef.d.ts +92 -0
  292. package/dist/features/presenter/typedef.js +106 -0
  293. package/dist/features/presenter/util.d.ts +63 -0
  294. package/dist/features/presenter/util.js +210 -0
  295. package/dist/features/virtual-viewport/VirtualViewport.svelte +196 -0
  296. package/dist/features/virtual-viewport/VirtualViewport.svelte.d.ts +42 -0
  297. package/dist/index.d.ts +0 -0
  298. package/dist/index.js +0 -0
  299. package/dist/logging/adapters/console.d.ts +48 -0
  300. package/dist/logging/adapters/console.js +114 -0
  301. package/dist/logging/adapters/pino.d.ts +25 -0
  302. package/dist/logging/adapters/pino.js +60 -0
  303. package/dist/logging/constants.d.ts +1 -0
  304. package/dist/logging/constants.js +1 -0
  305. package/dist/logging/factories/client.d.ts +10 -0
  306. package/dist/logging/factories/client.js +21 -0
  307. package/dist/logging/factories/server.d.ts +10 -0
  308. package/dist/logging/factories/server.js +22 -0
  309. package/dist/logging/factories/universal.d.ts +9 -0
  310. package/dist/logging/factories/universal.js +23 -0
  311. package/dist/logging/index.d.ts +5 -0
  312. package/dist/logging/index.js +8 -0
  313. package/dist/schemas/index.d.ts +1 -0
  314. package/dist/schemas/index.js +1 -0
  315. package/dist/schemas/validate-url.d.ts +30 -0
  316. package/dist/schemas/validate-url.js +180 -0
  317. package/dist/server/index.d.ts +1 -0
  318. package/dist/server/index.js +1 -0
  319. package/dist/server/logger.d.ts +25 -0
  320. package/dist/server/logger.js +94 -0
  321. package/dist/states/index.d.ts +1 -0
  322. package/dist/states/index.js +1 -0
  323. package/dist/states/navigation.svelte.d.ts +23 -0
  324. package/dist/states/navigation.svelte.js +55 -0
  325. package/dist/stores/index.d.ts +1 -0
  326. package/dist/stores/index.js +1 -0
  327. package/dist/stores/theme.d.ts +28 -0
  328. package/dist/stores/theme.js +80 -0
  329. package/dist/themes/hkdev/components/blocks/text-block.css +34 -0
  330. package/dist/themes/hkdev/components/boxes/game-box.css +11 -0
  331. package/dist/themes/hkdev/components/buttons/button-icon-steeze.css +22 -0
  332. package/dist/themes/hkdev/components/buttons/button-text.css +32 -0
  333. package/dist/themes/hkdev/components/buttons/button.css +146 -0
  334. package/dist/themes/hkdev/components/buttons/skip-button.css +5 -0
  335. package/dist/themes/hkdev/components/drag-drop/draggable.css +73 -0
  336. package/dist/themes/hkdev/components/drag-drop/drop-zone.css +58 -0
  337. package/dist/themes/hkdev/components/icons/icon-steeze.css +16 -0
  338. package/dist/themes/hkdev/components/inputs/text-input.css +102 -0
  339. package/dist/themes/hkdev/components/panels/panel.css +25 -0
  340. package/dist/themes/hkdev/components/rows/panel-grid-row.css +4 -0
  341. package/dist/themes/hkdev/components/rows/panel-row-2.css +5 -0
  342. package/dist/themes/hkdev/components.css +29 -0
  343. package/dist/themes/hkdev/debug.css +2 -0
  344. package/dist/themes/hkdev/global/layout.css +32 -0
  345. package/dist/themes/hkdev/global/on-colors.css +32 -0
  346. package/dist/themes/hkdev/globals.css +4 -0
  347. package/dist/themes/hkdev/responsive.css +12 -0
  348. package/dist/themes/hkdev/theme-ext.d.ts +4 -0
  349. package/dist/themes/hkdev/theme-ext.js +12 -0
  350. package/dist/themes/hkdev/theme.css +219 -0
  351. package/dist/themes/index.d.ts +1 -0
  352. package/dist/themes/index.js +1 -0
  353. package/dist/typedef/context.d.ts +3 -0
  354. package/dist/typedef/context.js +6 -0
  355. package/dist/typedef/drag.d.ts +29 -0
  356. package/dist/typedef/drag.js +25 -0
  357. package/dist/typedef/drop.d.ts +15 -0
  358. package/dist/typedef/drop.js +12 -0
  359. package/dist/typedef/image.d.ts +12 -0
  360. package/dist/typedef/image.js +38 -0
  361. package/dist/typedef/index.d.ts +4 -0
  362. package/dist/typedef/index.js +4 -0
  363. package/dist/util/array/index.d.ts +183 -0
  364. package/dist/util/array/index.js +436 -0
  365. package/dist/util/bases/base58.d.ts +58 -0
  366. package/dist/util/bases/base58.js +262 -0
  367. package/dist/util/bases/index.d.ts +1 -0
  368. package/dist/util/bases/index.js +1 -0
  369. package/dist/util/compare/index.d.ts +68 -0
  370. package/dist/util/compare/index.js +247 -0
  371. package/dist/util/css/css-vars.d.ts +24 -0
  372. package/dist/util/css/css-vars.js +83 -0
  373. package/dist/util/css/index.d.ts +1 -0
  374. package/dist/util/css/index.js +1 -0
  375. package/dist/util/design-system/components/states.d.ts +15 -0
  376. package/dist/util/design-system/components/states.js +22 -0
  377. package/dist/util/design-system/css/clamp.d.ts +17 -0
  378. package/dist/util/design-system/css/clamp.js +66 -0
  379. package/dist/util/design-system/css/root-design-vars.d.ts +77 -0
  380. package/dist/util/design-system/css/root-design-vars.js +102 -0
  381. package/dist/util/design-system/index.d.ts +5 -0
  382. package/dist/util/design-system/index.js +5 -0
  383. package/dist/util/design-system/layout/scaling.d.ts +98 -0
  384. package/dist/util/design-system/layout/scaling.js +228 -0
  385. package/dist/util/design-system/skeleton.d.ts +41 -0
  386. package/dist/util/design-system/skeleton.js +208 -0
  387. package/dist/util/design-system/tailwind.d.ts +183 -0
  388. package/dist/util/design-system/tailwind.js +288 -0
  389. package/dist/util/env/index.d.ts +1 -0
  390. package/dist/util/env/index.js +9 -0
  391. package/dist/util/exceptions/index.d.ts +15 -0
  392. package/dist/util/exceptions/index.js +23 -0
  393. package/dist/util/expect/arrays.d.ts +30 -0
  394. package/dist/util/expect/arrays.js +47 -0
  395. package/dist/util/expect/index.d.ts +103 -0
  396. package/dist/util/expect/index.js +259 -0
  397. package/dist/util/expect/primitives.d.ts +30 -0
  398. package/dist/util/expect/primitives.js +55 -0
  399. package/dist/util/expect/url.d.ts +32 -0
  400. package/dist/util/expect/url.js +60 -0
  401. package/dist/util/function/index.d.ts +34 -0
  402. package/dist/util/function/index.js +218 -0
  403. package/dist/util/geo/index.d.ts +10 -0
  404. package/dist/util/geo/index.js +26 -0
  405. package/dist/util/http/caching.d.ts +28 -0
  406. package/dist/util/http/caching.js +263 -0
  407. package/dist/util/http/errors.d.ts +18 -0
  408. package/dist/util/http/errors.js +97 -0
  409. package/dist/util/http/headers.d.ts +40 -0
  410. package/dist/util/http/headers.js +75 -0
  411. package/dist/util/http/http-request.d.ts +267 -0
  412. package/dist/util/http/http-request.js +578 -0
  413. package/dist/util/http/index.d.ts +6 -0
  414. package/dist/util/http/index.js +22 -0
  415. package/dist/util/http/json-request.d.ts +84 -0
  416. package/dist/util/http/json-request.js +224 -0
  417. package/dist/util/http/mocks.d.ts +20 -0
  418. package/dist/util/http/mocks.js +65 -0
  419. package/dist/util/http/response.d.ts +125 -0
  420. package/dist/util/http/response.js +294 -0
  421. package/dist/util/http/test-data__/content-length-test-hkdigital-small.V4HfZyBQ.avif +0 -0
  422. package/dist/util/http/typedef.d.ts +184 -0
  423. package/dist/util/http/typedef.js +93 -0
  424. package/dist/util/http/url.d.ts +25 -0
  425. package/dist/util/http/url.js +52 -0
  426. package/dist/util/image/index.d.ts +25 -0
  427. package/dist/util/image/index.js +86 -0
  428. package/dist/util/index.d.ts +3 -0
  429. package/dist/util/index.js +3 -0
  430. package/dist/util/is/index.d.ts +68 -0
  431. package/dist/util/is/index.js +140 -0
  432. package/dist/util/iterate/index.d.ts +131 -0
  433. package/dist/util/iterate/index.js +234 -0
  434. package/dist/util/object/index.d.ts +326 -0
  435. package/dist/util/object/index.js +1361 -0
  436. package/dist/util/singleton/index.d.ts +34 -0
  437. package/dist/util/singleton/index.js +97 -0
  438. package/dist/util/string/array-path.d.ts +15 -0
  439. package/dist/util/string/array-path.js +75 -0
  440. package/dist/util/string/convert.d.ts +22 -0
  441. package/dist/util/string/convert.js +54 -0
  442. package/dist/util/string/fs.d.ts +55 -0
  443. package/dist/util/string/fs.js +226 -0
  444. package/dist/util/string/index.d.ts +5 -0
  445. package/dist/util/string/index.js +5 -0
  446. package/dist/util/string/interpolate.d.ts +22 -0
  447. package/dist/util/string/interpolate.js +61 -0
  448. package/dist/util/string/pad.d.ts +8 -0
  449. package/dist/util/string/pad.js +10 -0
  450. package/dist/util/svelte/index.d.ts +3 -0
  451. package/dist/util/svelte/index.js +4 -0
  452. package/dist/util/svelte/loading/loading-tracker.svelte.d.ts +31 -0
  453. package/dist/util/svelte/loading/loading-tracker.svelte.js +108 -0
  454. package/dist/util/svelte/observe/index.d.ts +10 -0
  455. package/dist/util/svelte/observe/index.js +49 -0
  456. package/dist/util/svelte/state-context/index.d.ts +18 -0
  457. package/dist/util/svelte/state-context/index.js +117 -0
  458. package/dist/util/svelte/wait/index.d.ts +15 -0
  459. package/dist/util/svelte/wait/index.js +38 -0
  460. package/dist/util/sveltekit/index.d.ts +1 -0
  461. package/dist/util/sveltekit/index.js +1 -0
  462. package/dist/util/sveltekit/route-folders/index.d.ts +28 -0
  463. package/dist/util/sveltekit/route-folders/index.js +101 -0
  464. package/dist/util/time/index.d.ts +108 -0
  465. package/dist/util/time/index.js +323 -0
  466. package/dist/util/unique/index.d.ts +81 -0
  467. package/dist/util/unique/index.js +249 -0
  468. package/dist/valibot/date.js__ +10 -0
  469. package/dist/valibot/index.d.ts +4 -0
  470. package/dist/valibot/index.js +9 -0
  471. package/dist/valibot/url.d.ts +26 -0
  472. package/dist/valibot/url.js +95 -0
  473. package/dist/valibot/user.d.ts +6 -0
  474. package/dist/valibot/user.js +23 -0
  475. package/dist/zod/all.d.ts +6 -0
  476. package/dist/zod/all.js +33 -0
  477. package/dist/zod/generic.d.ts +6 -0
  478. package/dist/zod/generic.js +11 -0
  479. package/dist/zod/javascript.d.ts +8 -0
  480. package/dist/zod/javascript.js +32 -0
  481. package/dist/zod/user.d.ts +9 -0
  482. package/dist/zod/user.js +16 -0
  483. package/dist/zod/web.d.ts +21 -0
  484. package/dist/zod/web.js +52 -0
  485. package/package.json +133 -0
@@ -0,0 +1,294 @@
1
+ import { ResponseError } from '../../constants/errors/index.js';
2
+ import * as expect from '../expect/index.js';
3
+ import { toURL } from './url.js';
4
+
5
+ import {
6
+ WWW_AUTHENTICATE,
7
+ CONTENT_LENGTH
8
+ } from '../../constants/http/headers.js';
9
+
10
+ import { href } from './url.js';
11
+
12
+ import { getErrorFromResponse } from './errors.js';
13
+
14
+ // > Types
15
+
16
+ /**
17
+ * Callback function that reports progress of data loading
18
+ *
19
+ * @callback progressCallback
20
+ *
21
+ * @param {object} _
22
+ * @param {number} _.bytesLoaded - Number of bytes loaded so far
23
+ * @param {number} _.size - Total size of the response in bytes (0 if unknown)
24
+ */
25
+
26
+ // > Exports
27
+
28
+ /**
29
+ * Check if the response status is ok (in 200-299 range)
30
+ * This function examines HTTP status codes and throws appropriate errors for
31
+ * non-successful responses, with special handling for 401 Unauthorized.
32
+ *
33
+ * @param {object} response - Fetch Response object to check
34
+ *
35
+ * @param {string} url - The URL used for the request (for error messages)
36
+ *
37
+ * @throws {Error} When response has 401 status with authorization details
38
+ * @throws {ResponseError} When response has other non-successful status codes
39
+ *
40
+ * @example
41
+ * // Check if response was successful
42
+ * try {
43
+ * await expectResponseOk(response, 'https://api.example.com/data');
44
+ * // Process successful response here
45
+ * } catch (error) {
46
+ * // Handle specific error types
47
+ * if (error.message.includes('401')) {
48
+ * // Handle unauthorized error
49
+ * }
50
+ * }
51
+ */
52
+ export async function expectResponseOk(response, url) {
53
+ expect.object(response);
54
+
55
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200
56
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201
57
+
58
+ if (200 === response.status || 201 === response.status) {
59
+ if (!response.ok) {
60
+ throw new ResponseError(
61
+ `Server returned - ${response.status} ${response.statusText} ` +
62
+ `[response.ok=false] [url=${href(url)}]`
63
+ );
64
+ }
65
+
66
+ // All ok
67
+ return;
68
+ }
69
+
70
+ // > Handle 401 Unauthorized
71
+
72
+ if (401 === response.status) {
73
+ let errorMessage = 'Server returned [401] Unauthorized';
74
+
75
+ const authValue = response.headers.get(WWW_AUTHENTICATE);
76
+
77
+ if (authValue) {
78
+ // Add WWW_AUTHENTICATE response to error message
79
+ errorMessage += ` (${authValue})`;
80
+ }
81
+
82
+ errorMessage += ` [url=${href(url)}]`;
83
+
84
+ throw new Error(errorMessage);
85
+ }
86
+
87
+ // > Handle all other error responses
88
+
89
+ const error = await getErrorFromResponse(response);
90
+
91
+ throw new ResponseError(
92
+ `Server returned - ${response.status} ${response.statusText} ` +
93
+ `[url=${href(url)}]`,
94
+ { cause: error }
95
+ );
96
+ }
97
+
98
+ /**
99
+ * Get the response size from the content-length response header
100
+ *
101
+ * @param {Response} response - Fetch Response object
102
+ *
103
+ * @returns {number} Response size in bytes, or 0 if content-length is not set
104
+ *
105
+ * @example
106
+ * const response = await fetch('https://example.com/large-file.zip');
107
+ * const size = getResponseSize(response);
108
+ * console.log(`Download size: ${size} bytes`);
109
+ */
110
+ export function getResponseSize(response) {
111
+ const sizeStr = response.headers.get(CONTENT_LENGTH);
112
+
113
+ if (!sizeStr) {
114
+ return 0;
115
+ }
116
+
117
+ return parseInt(sizeStr, 10);
118
+ }
119
+
120
+ /**
121
+ * Wait for a response and check if the response is ok
122
+ * This function awaits a response promise and performs error checking,
123
+ * wrapping network errors in a standardized ResponseError format.
124
+ *
125
+ * @param {Promise<Response>} responsePromise - Promise that resolves to a Response
126
+ *
127
+ * @param {string|URL} url - URL used for the request (for error messages)
128
+ *
129
+ * @throws {ResponseError} When a network error occurs or response is not ok
130
+ *
131
+ * @returns {Promise<Response>} The response if successful
132
+ *
133
+ * @example
134
+ * // Handle a fetch promise with proper error handling
135
+ * const responsePromise = fetch('https://api.example.com/data');
136
+ * try {
137
+ * const response = await waitForAndCheckResponse(
138
+ * responsePromise,
139
+ * 'https://api.example.com/data'
140
+ * );
141
+ * // Process response
142
+ * } catch (error) {
143
+ * // Handle standardized ResponseError
144
+ * console.error(error.message);
145
+ * }
146
+ */
147
+ export async function waitForAndCheckResponse(responsePromise, url) {
148
+ expect.promise(responsePromise);
149
+
150
+ url = toURL(url);
151
+
152
+ let response;
153
+
154
+ try {
155
+ response = await responsePromise;
156
+
157
+ if (response && false === response.ok) {
158
+ // if response.ok is false, it also indicates a network error
159
+ throw new Error(`Response failed [response.ok=false]`);
160
+ }
161
+ } catch (e) {
162
+ if (e instanceof TypeError || response?.ok === false) {
163
+ throw new ResponseError(
164
+ `A network error occurred for request [${href(url)}]`,
165
+ {
166
+ cause: e
167
+ }
168
+ );
169
+ } else {
170
+ throw e;
171
+ }
172
+ }
173
+
174
+ return response;
175
+ }
176
+
177
+ /**
178
+ * Load response body as ArrayBuffer with progress monitoring and abort capability
179
+ *
180
+ * This function reads a response body stream chunk by chunk, with optional
181
+ * progress reporting. It provides an abort mechanism to cancel an in-progress
182
+ * download.
183
+ *
184
+ * @param {Response} response - Fetch Response object to read
185
+ *
186
+ * @param {progressCallback} [onProgress] - Optional callback for progress updates
187
+ *
188
+ * @returns {{
189
+ * bufferPromise: Promise<ArrayBuffer>,
190
+ * abort: () => void
191
+ * }} Object containing the buffer promise and abort function
192
+ *
193
+ * @example
194
+ * // Download a file with progress monitoring and abort capability
195
+ * const response = await fetch('https://example.com/large-file.zip');
196
+ *
197
+ * const { bufferPromise, abort } = loadResponseBuffer(
198
+ * response,
199
+ * ({ bytesLoaded, size }) => {
200
+ * // Update progress UI
201
+ * const percent = size ? Math.round((bytesLoaded / size) * 100) : 0;
202
+ * console.log(`Downloaded ${bytesLoaded} bytes (${percent}%)`);
203
+ * }
204
+ * );
205
+ *
206
+ * // To abort the download:
207
+ * // abort();
208
+ *
209
+ * try {
210
+ * const buffer = await bufferPromise;
211
+ * // Process the complete buffer
212
+ * } catch (error) {
213
+ * console.error('Download failed or was aborted', error);
214
+ * }
215
+ */
216
+ export function loadResponseBuffer(response, onProgress) {
217
+ // @note size might be 0
218
+ // @note might not be send by server in dev mode
219
+ const size = getResponseSize(response);
220
+
221
+ let bytesLoaded = 0;
222
+
223
+ if (onProgress /*&& size*/) {
224
+ onProgress({ bytesLoaded, size });
225
+ }
226
+
227
+ if (!response.body) {
228
+ throw new Error('Missing [response.body]');
229
+ }
230
+
231
+ let reader;
232
+ let aborted = false;
233
+
234
+ /**
235
+ * Read chunks from response body using reader
236
+ *
237
+ * @returns {Promise<ArrayBuffer>}
238
+ */
239
+ async function read() {
240
+ reader = response.body.getReader();
241
+ let chunks = [];
242
+
243
+ for (;;) {
244
+ const { done, value } = await reader.read();
245
+
246
+ if (value) {
247
+ // @note value is an ArrayBuffer
248
+ bytesLoaded += value.byteLength;
249
+
250
+ chunks.push(value);
251
+
252
+ if (onProgress /*&& size*/) {
253
+ onProgress({ bytesLoaded, size });
254
+ }
255
+ }
256
+
257
+ if (done || aborted) {
258
+ // Loading complete or aborted by user
259
+ break;
260
+ }
261
+ } // end for
262
+
263
+ if (size && bytesLoaded !== size) {
264
+ console.error(`Received [${bytesLoaded}], but expected [${size}] bytes`);
265
+ }
266
+
267
+ // Concat the chunks into a single array
268
+ let buffer = new ArrayBuffer(bytesLoaded);
269
+ let body = new Uint8Array(buffer);
270
+
271
+ let offset = 0;
272
+
273
+ // Place the chunks in the buffer
274
+ for (let chunk of chunks) {
275
+ body.set(chunk, offset);
276
+ offset += chunk.byteLength;
277
+ } // end for
278
+
279
+ return buffer;
280
+ }
281
+
282
+ const bufferPromise = read();
283
+
284
+ return {
285
+ bufferPromise,
286
+ abort: () => {
287
+ aborted = true;
288
+
289
+ if (reader) {
290
+ reader.cancel('Aborted by user');
291
+ }
292
+ }
293
+ };
294
+ } // end fn
@@ -0,0 +1,184 @@
1
+ export type HttpRequestOptions = {
2
+ /**
3
+ * URL string or URL object for the request
4
+ */
5
+ url: string | URL;
6
+ /**
7
+ * HTTP method to use (GET, POST, etc.)
8
+ */
9
+ method?: string;
10
+ /**
11
+ * Parameters to add to the URL
12
+ */
13
+ urlSearchParams?: any | URLSearchParams;
14
+ /**
15
+ * Request body (for POST, PUT, etc.)
16
+ */
17
+ body?: any;
18
+ /**
19
+ * HTTP headers as name-value pairs
20
+ */
21
+ headers?: any;
22
+ /**
23
+ * Whether to include credentials
24
+ */
25
+ withCredentials?: boolean;
26
+ /**
27
+ * Request timeout in milliseconds
28
+ */
29
+ timeoutMs?: number;
30
+ /**
31
+ * Handler for abort/timeout control
32
+ */
33
+ requestHandler?: Function;
34
+ /**
35
+ * CORS mode ('cors', 'no-cors', 'same-origin')
36
+ */
37
+ mode?: string;
38
+ /**
39
+ * Cache mode ('default', 'no-cache', etc.)
40
+ */
41
+ cache?: string;
42
+ /**
43
+ * Redirect mode ('follow', 'error', 'manual')
44
+ */
45
+ redirect?: string;
46
+ /**
47
+ * Referrer policy
48
+ */
49
+ referrerPolicy?: string;
50
+ /**
51
+ * Enable or disabled automatic caching
52
+ */
53
+ cacheEnabled?: boolean;
54
+ };
55
+ export type RequestHandlerParams = {
56
+ /**
57
+ * The AbortController instance for this request
58
+ */
59
+ controller: AbortController;
60
+ /**
61
+ * Function to abort the request
62
+ */
63
+ abort: (reason?: Error) => void;
64
+ /**
65
+ * Function to set a timeout
66
+ */
67
+ timeout: (delayMs: number) => void;
68
+ };
69
+ export type RequestHandler = (params: RequestHandlerParams) => void;
70
+ export type JsonGetOptions = {
71
+ /**
72
+ * URL string or URL object for the request
73
+ */
74
+ url: string | URL;
75
+ /**
76
+ * Parameters to add to the URL
77
+ */
78
+ urlSearchParams?: any | URLSearchParams;
79
+ /**
80
+ * HTTP headers as name-value pairs
81
+ */
82
+ headers?: any;
83
+ /**
84
+ * Whether to include credentials
85
+ */
86
+ withCredentials?: boolean;
87
+ /**
88
+ * Request timeout in milliseconds
89
+ */
90
+ timeoutMs?: number;
91
+ /**
92
+ * Handler for abort/timeout control
93
+ */
94
+ requestHandler?: RequestHandler;
95
+ /**
96
+ * CORS mode ('cors', 'no-cors', 'same-origin')
97
+ */
98
+ mode?: string;
99
+ /**
100
+ * Cache mode ('default', 'no-cache', etc.)
101
+ */
102
+ cache?: string;
103
+ /**
104
+ * Redirect mode ('follow', 'error', 'manual')
105
+ */
106
+ redirect?: string;
107
+ /**
108
+ * Referrer policy
109
+ */
110
+ referrerPolicy?: string;
111
+ /**
112
+ * Enable or disabled automatic caching
113
+ */
114
+ cacheEnabled?: boolean;
115
+ };
116
+ export type JsonPostOptions = {
117
+ /**
118
+ * URL string or URL object for the request
119
+ */
120
+ url: string | URL;
121
+ /**
122
+ * Request body (will be sent as JSON)
123
+ */
124
+ body: any;
125
+ /**
126
+ * Parameters to add to the URL
127
+ */
128
+ urlSearchParams?: any | URLSearchParams;
129
+ /**
130
+ * HTTP headers as name-value pairs
131
+ */
132
+ headers?: any;
133
+ /**
134
+ * Whether to include credentials
135
+ */
136
+ withCredentials?: boolean;
137
+ /**
138
+ * Request timeout in milliseconds
139
+ */
140
+ timeoutMs?: number;
141
+ /**
142
+ * Handler for abort/timeout control
143
+ */
144
+ requestHandler?: RequestHandler;
145
+ /**
146
+ * CORS mode ('cors', 'no-cors', 'same-origin')
147
+ */
148
+ mode?: string;
149
+ /**
150
+ * Cache mode ('default', 'no-cache', etc.)
151
+ */
152
+ cache?: string;
153
+ /**
154
+ * Redirect mode ('follow', 'error', 'manual')
155
+ */
156
+ redirect?: string;
157
+ /**
158
+ * Referrer policy
159
+ */
160
+ referrerPolicy?: string;
161
+ /**
162
+ * Enable or disabled automatic caching
163
+ */
164
+ cacheEnabled?: boolean;
165
+ };
166
+ export type StaleInfo = {
167
+ /**
168
+ * Whether the response contains stale data
169
+ */
170
+ isStale: boolean;
171
+ /**
172
+ * Promise that resolves to fresh data (if available)
173
+ */
174
+ fresh: Promise<Response> | null;
175
+ /**
176
+ * When the response was originally cached
177
+ */
178
+ timestamp: number;
179
+ /**
180
+ * When the response expires
181
+ */
182
+ expires: number | null;
183
+ };
184
+ export type ResponseWithStale = Response;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @typedef {Object} HttpRequestOptions
3
+ * @property {string|URL} url URL string or URL object for the request
4
+ * @property {string} [method] HTTP method to use (GET, POST, etc.)
5
+ *
6
+ * @property {Object|URLSearchParams} [urlSearchParams]
7
+ * Parameters to add to the URL
8
+ *
9
+ * @property {*} [body] Request body (for POST, PUT, etc.)
10
+ * @property {Object} [headers] HTTP headers as name-value pairs
11
+ * @property {boolean} [withCredentials] Whether to include credentials
12
+ * @property {number} [timeoutMs] Request timeout in milliseconds
13
+ * @property {Function} [requestHandler] Handler for abort/timeout control
14
+ * @property {string} [mode] CORS mode ('cors', 'no-cors', 'same-origin')
15
+ * @property {string} [cache] Cache mode ('default', 'no-cache', etc.)
16
+ * @property {string} [redirect] Redirect mode ('follow', 'error', 'manual')
17
+ * @property {string} [referrerPolicy] Referrer policy
18
+ * @property {boolean} [cacheEnabled] Enable or disabled automatic caching
19
+ */
20
+
21
+ /**
22
+ * @typedef {Object} RequestHandlerParams
23
+ *
24
+ * @property {AbortController} controller
25
+ * The AbortController instance for this request
26
+ *
27
+ * @property {(reason?: Error) => void} abort Function to abort the request
28
+ * @property {(delayMs: number) => void} timeout Function to set a timeout
29
+ */
30
+
31
+ /**
32
+ * @callback RequestHandler
33
+ * @param {RequestHandlerParams} params Parameters for controlling the request
34
+ * @returns {void}
35
+ */
36
+
37
+ /**
38
+ * @typedef {Object} JsonGetOptions
39
+ * @property {string|URL} url URL string or URL object for the request
40
+ *
41
+ * @property {Object|URLSearchParams} [urlSearchParams]
42
+ * Parameters to add to the URL
43
+ *
44
+ * @property {Object} [headers] HTTP headers as name-value pairs
45
+ * @property {boolean} [withCredentials] Whether to include credentials
46
+ * @property {number} [timeoutMs] Request timeout in milliseconds
47
+ * @property {RequestHandler} [requestHandler] Handler for abort/timeout control
48
+ * @property {string} [mode] CORS mode ('cors', 'no-cors', 'same-origin')
49
+ * @property {string} [cache] Cache mode ('default', 'no-cache', etc.)
50
+ * @property {string} [redirect] Redirect mode ('follow', 'error', 'manual')
51
+ * @property {string} [referrerPolicy] Referrer policy
52
+ * @property {boolean} [cacheEnabled] Enable or disabled automatic caching
53
+ */
54
+
55
+ /**
56
+ * @typedef {Object} JsonPostOptions
57
+ * @property {string|URL} url URL string or URL object for the request
58
+ * @property {*} body Request body (will be sent as JSON)
59
+ *
60
+ * @property {Object|URLSearchParams} [urlSearchParams]
61
+ * Parameters to add to the URL
62
+ *
63
+ * @property {Object} [headers] HTTP headers as name-value pairs
64
+ * @property {boolean} [withCredentials] Whether to include credentials
65
+ * @property {number} [timeoutMs] Request timeout in milliseconds
66
+ * @property {RequestHandler} [requestHandler] Handler for abort/timeout control
67
+ * @property {string} [mode] CORS mode ('cors', 'no-cors', 'same-origin')
68
+ * @property {string} [cache] Cache mode ('default', 'no-cache', etc.)
69
+ * @property {string} [redirect] Redirect mode ('follow', 'error', 'manual')
70
+ * @property {string} [referrerPolicy] Referrer policy
71
+ * @property {boolean} [cacheEnabled] Enable or disabled automatic caching
72
+ */
73
+
74
+ /**
75
+ * @typedef {Object} StaleInfo
76
+ * @property {boolean} isStale Whether the response contains stale data
77
+ *
78
+ * @property {Promise<Response>|null} fresh
79
+ * Promise that resolves to fresh data (if available)
80
+ *
81
+ * @property {number} timestamp When the response was originally cached
82
+ * @property {number|null} expires When the response expires
83
+ */
84
+
85
+ /**
86
+ * @typedef {Response} ResponseWithStale
87
+ * @property {boolean} isStale Whether this response contains stale data
88
+ *
89
+ * @property {Promise<Response>|null} fresh
90
+ * Promise for fresh data if this is stale
91
+ */
92
+
93
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Returns an URL instance
3
+ * - Prefixes the URL with the current orign if the url is relative
4
+ *
5
+ * @param {string|URL} url
6
+ *
7
+ * @returns {URL} url instance
8
+ */
9
+ export function toURL(url: string | URL): URL;
10
+ /**
11
+ * Checks if the url starts with a protocol specification such
12
+ * as https://
13
+ *
14
+ * @param {string} url
15
+ *
16
+ * @return {boolean} true if the value looks like an array
17
+ */
18
+ export function hasProtocol(url: string): boolean;
19
+ /**
20
+ * Convert an url to an absolute url and apply decodeURI to
21
+ * convert URI encoded characters to normal characters
22
+ *
23
+ * @param {string|URL} url
24
+ */
25
+ export function href(url: string | URL): string;
@@ -0,0 +1,52 @@
1
+ import { TypeOrValueError } from '../../constants/errors/index.js';
2
+
3
+ /**
4
+ * Returns an URL instance
5
+ * - Prefixes the URL with the current orign if the url is relative
6
+ *
7
+ * @param {string|URL} url
8
+ *
9
+ * @returns {URL} url instance
10
+ */
11
+ export function toURL(url) {
12
+ if (typeof url === 'string') {
13
+ if (hasProtocol(url)) {
14
+ return new URL(url);
15
+ } else {
16
+ // Use location.origin aas baseUrl
17
+ return new URL(url, location.origin);
18
+ }
19
+ } else if (!(url instanceof URL)) {
20
+ throw new TypeOrValueError('Missing or invalid parameter [url]');
21
+ }
22
+
23
+ // already an URL instance
24
+ return url;
25
+ }
26
+
27
+ /**
28
+ * Checks if the url starts with a protocol specification such
29
+ * as https://
30
+ *
31
+ * @param {string} url
32
+ *
33
+ * @return {boolean} true if the value looks like an array
34
+ */
35
+ export function hasProtocol(url) {
36
+ if (/^([a-zA-Z]{2,})s?:\/\//.test(url)) {
37
+ return true;
38
+ }
39
+
40
+ return false;
41
+ }
42
+
43
+ /**
44
+ * Convert an url to an absolute url and apply decodeURI to
45
+ * convert URI encoded characters to normal characters
46
+ *
47
+ * @param {string|URL} url
48
+ */
49
+ export function href(url) {
50
+ const urlObj = toURL(url);
51
+ return decodeURI(urlObj.href);
52
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Returns the unchanged image meta object or the last item of
3
+ * an array of ImageMeta objects. This is assumed to be a list
4
+ * of sorted responsive image formats, so it should be the
5
+ * largest image.
6
+ *
7
+ * @param {ImageMeta|ImageMeta[]} imageMeta
8
+ */
9
+ export function toSingleImageMeta(imageMeta: ImageMeta | ImageMeta[]): import("../../typedef").ImageMeta;
10
+ /**
11
+ * Calculate effective width based on container dimensions and fit mode
12
+ *
13
+ * @param {object} params
14
+ * @param {number} [params.containerWidth] Container width in pixels
15
+ * @param {number} [params.containerHeight] Container height in pixels
16
+ * @param {number} params.imageAspectRatio Original image aspect ratio (width/height)
17
+ * @param {'cover'|'contain'|'fill'} [params.fit='contain'] Fit mode
18
+ * @returns {number} Effective width needed
19
+ */
20
+ export function calculateEffectiveWidth({ containerWidth, containerHeight, imageAspectRatio, fit }: {
21
+ containerWidth?: number;
22
+ containerHeight?: number;
23
+ imageAspectRatio: number;
24
+ fit?: "cover" | "contain" | "fill";
25
+ }): number;