@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,323 @@
1
+ /**
2
+ * time.js
3
+ *
4
+ * @description
5
+ * This file contains time related functionality
6
+ *
7
+ * @example
8
+ *
9
+ * import { delay, now } from './time.js';
10
+ *
11
+ * async function test()
12
+ * {
13
+ * console.log( `Current timestamp [${now()}]` );
14
+ *
15
+ * await delay( 1000 );
16
+ *
17
+ * console.log( `Current timestamp [${now()}]` );
18
+ * }
19
+ */
20
+
21
+ /**
22
+ * FIXME: use Intl.DateTimeFormat instead of custom conversions
23
+ *
24
+ * e.g.
25
+ * return new Intl.DateTimeFormat('nl-NL', {
26
+ * month: "long",
27
+ * timeZone: 'Europe/Amsterdam'
28
+ * }).format(d);
29
+ */
30
+
31
+ import {
32
+ SECOND_MS,
33
+ MINUTE_MS,
34
+ HOUR_MS,
35
+ DAY_MS,
36
+ TIME_2025_01_01 } from '../../constants/time.js';
37
+
38
+ import * as expect from '../expect';
39
+ import { HkPromise } from '../../classes/promise/index.js';
40
+
41
+ /**
42
+ * Returns a promise that resolves after a specified timeout
43
+ * - If the returned promise is rejected, the timeout is cancelled
44
+ *
45
+ * @param {number} delayOrMinDelayMs
46
+ * Number of milliseconds to wait before promise resolves
47
+ *
48
+ * @param {number} [maxDelayMs=delayOrMinDelayMs]
49
+ * Maximum number of milliseconds to wait before the returned promise
50
+ * resolves. If this parameter is set, the delay will be chosen randomly
51
+ * between the values [delayOrMinDelayMs, maxDelayMs]
52
+ *
53
+ * @returns {HkPromise} promise that resolves after a specified timeout
54
+ */
55
+ export function delay(delayOrMinDelayMs, maxDelayMs) {
56
+ expect.number(delayOrMinDelayMs);
57
+
58
+ if (maxDelayMs) {
59
+ //
60
+ // maxDelayMs was set -> generate random delay
61
+ //
62
+ if (maxDelayMs > delayOrMinDelayMs) {
63
+ delayOrMinDelayMs = Math.floor(
64
+ delayOrMinDelayMs + Math.random() * (maxDelayMs - delayOrMinDelayMs)
65
+ );
66
+ }
67
+ }
68
+
69
+ const promise = new HkPromise();
70
+
71
+ let timer = setTimeout(() => {
72
+ timer = null;
73
+ promise.resolve();
74
+ }, delayOrMinDelayMs);
75
+
76
+ // Register catch method to cancel timer when promise is rejected
77
+ promise.catch(() => {
78
+ if (timer) {
79
+ clearTimeout(timer);
80
+ timer = null;
81
+ }
82
+ });
83
+
84
+ return promise;
85
+ }
86
+
87
+ /**
88
+ * Get the number of milliseconds since the specified time stamp of the default
89
+ * reference time stamp TIME_2025_01_01
90
+ *
91
+ * @param {number} [sinceMs=TIME_2025_01_01]
92
+ *
93
+ * @returns {number} number of milliseconds since the specified time
94
+ */
95
+ export function sinceMs(sinceMs = TIME_2025_01_01) {
96
+ return Date.now() - sinceMs;
97
+ }
98
+
99
+ /**
100
+ * Get a string that represents the time in a readable
101
+ * string format: [DD:][HH:]MM:SS.mmm
102
+ *
103
+ * @param {number} timeMs [description]
104
+ *
105
+ * @returns {string} time in human readable format
106
+ */
107
+ export function timeToString(timeMs) {
108
+ const days = Math.floor(timeMs / DAY_MS);
109
+
110
+ let restMs = timeMs - days * DAY_MS;
111
+
112
+ const hours = Math.floor(restMs / HOUR_MS);
113
+
114
+ restMs = restMs - hours * HOUR_MS;
115
+
116
+ const minutes = Math.floor(restMs / MINUTE_MS);
117
+
118
+ restMs = restMs - minutes * MINUTE_MS;
119
+
120
+ const seconds = Math.floor(restMs / SECOND_MS);
121
+
122
+ restMs = restMs - seconds * SECOND_MS;
123
+
124
+ let str = '';
125
+
126
+ if (days) {
127
+ str += `${days.toString().padStart(2, '0')}:`;
128
+ str += `${hours.toString().padStart(2, '0')}:`;
129
+ } else if (hours) {
130
+ str += `${hours.toString().padStart(2, '0')}:`;
131
+ }
132
+
133
+ str += `${minutes.toString().padStart(2, '0')}:`;
134
+ str += `${seconds.toString().padStart(2, '0')}.`;
135
+ str += `${restMs.toString().padStart(3, '0')}`;
136
+
137
+ return str;
138
+ }
139
+
140
+ /**
141
+ * Returns a Date object
142
+ * - The input can be a Date object or a numeric timestamp
143
+ *
144
+ * @param {Date|number} dateOrTimestamp
145
+ *
146
+ * @returns {Date} date object
147
+ */
148
+ export function toDate(dateOrTimestamp) {
149
+ if (dateOrTimestamp instanceof Date) {
150
+ return dateOrTimestamp;
151
+ }
152
+
153
+ if (typeof dateOrTimestamp === 'number') {
154
+ return new Date(dateOrTimestamp);
155
+ }
156
+
157
+ throw new Error('Missing or invalid parameter [dateOrTimestamp]');
158
+ }
159
+
160
+ /**
161
+ * Get the ISO 8601 week number of the specified date
162
+ *
163
+ * @see https://stackoverflow.com
164
+ * /questions/6117814/get-week-of-year-in-javascript-like-in-php
165
+ *
166
+ * @param {Date|number} dateOrTimestamp
167
+ *
168
+ * @returns {number} week number
169
+ */
170
+ export function getWeekNumber(dateOrTimestamp) {
171
+ const date = toDate(dateOrTimestamp);
172
+
173
+ //
174
+ // Create a copy of this date object
175
+ //
176
+ const target = new Date(date.valueOf());
177
+
178
+ //
179
+ // ISO week date weeks start on Monday, so correct the day number
180
+ //
181
+ const dayNumber = (date.getDay() + 6) % 7;
182
+
183
+ //
184
+ // ISO 8601 states that week 1 is the week with the first Thursday
185
+ // of that year.
186
+ //
187
+ // Set the target date to the Thursday in the target week
188
+ //
189
+ target.setDate(target.getDate() - dayNumber + 3);
190
+
191
+ //
192
+ // Store the millisecond value of the target date
193
+ //
194
+ const firstThursday = target.valueOf();
195
+
196
+ // Set the target to the first Thursday of the year
197
+ // First, set the target to January 1st
198
+ target.setMonth(0, 1);
199
+
200
+ //
201
+ // Not a Thursday? Correct the date to the next Thursday
202
+ //
203
+ if (target.getDay() !== 4) {
204
+ target.setMonth(0, 1 + ((4 - target.getDay() + 7) % 7));
205
+ }
206
+
207
+ //
208
+ // The week number is the number of weeks between the first Thursday
209
+ // of the year and the Thursday in the target week
210
+ // (604800000 = 7 * 24 * 3600 * 1000)
211
+ //
212
+ return 1 + Math.ceil((firstThursday - target.getTime()) / 604800000);
213
+ }
214
+
215
+ /**
216
+ * Get the name of the month
217
+ * - Returns the month name using Intl.DateTimeFormat
218
+ * - By default uses English locale, but locale can be specified
219
+ *
220
+ * @param {Date|number} dateOrTimestamp - Date object or timestamp
221
+ * @param {string} [locale='nl-NL'] - The locale to use for the month name
222
+ *
223
+ * @param {Object} [options]
224
+ * @param {'numeric'|'2-digit'|'narrow'|'short'|'long'} [options.month='long']
225
+ * @param {string} [options.timeZone] - Optional timezone
226
+ *
227
+ * @returns {string} name of the month in the specified locale
228
+ */
229
+ export function getMonthName(dateOrTimestamp, locale = 'nl-NL',
230
+ options = { month: 'long' }) {
231
+
232
+ const date = toDate(dateOrTimestamp);
233
+
234
+ // Create formatter with provided locale and options
235
+ // @ts-ignore - TypeScript kan hier strikter zijn dan nodig met de options
236
+ const formatter = new Intl.DateTimeFormat(locale, {
237
+ month: options?.month || 'long',
238
+ ...(options?.timeZone ? { timeZone: options.timeZone } : {})
239
+ });
240
+
241
+ return formatter.format(date);
242
+ }
243
+
244
+ /**
245
+ * Get the name of the day of the week
246
+ * - Returns the day name using Intl.DateTimeFormat
247
+ * - By default uses English locale, but locale can be specified
248
+ *
249
+ * @param {Date|number} dateOrTimestamp - Date object or timestamp
250
+ * @param {string} [locale='nl-NL'] - The locale to use for the day name
251
+ *
252
+ * @param {Object} [options]
253
+ * @param {'narrow'|'short'|'long'} [options.weekday='long']
254
+ * @param {string} [options.timeZone] - Optional timezone
255
+ *
256
+ * @returns {string} name of the day in the specified locale
257
+ */
258
+ export function getDayName(dateOrTimestamp, locale = 'nl-NL',
259
+ options = { weekday: 'long' }) {
260
+
261
+ const date = toDate(dateOrTimestamp);
262
+
263
+ // Create formatter with provided locale and options
264
+ // @ts-ignore - TypeScript kan hier strikter zijn dan nodig met de options
265
+ const formatter = new Intl.DateTimeFormat(locale, {
266
+ weekday: options?.weekday || 'long',
267
+ ...(options?.timeZone ? { timeZone: options.timeZone } : {})
268
+ });
269
+
270
+ return formatter.format(date);
271
+ }
272
+
273
+ /**
274
+ * Return the timestamp of the start of the day
275
+ * - Midnight
276
+ *
277
+ * @param {Date|number} [dateOrTimestamp]
278
+ *
279
+ * @returns {number} timestamp of start of the day (00:00:00:0000)
280
+ */
281
+ export function getTimeAtStartOfDay(dateOrTimestamp) {
282
+ let d;
283
+
284
+ if (dateOrTimestamp) {
285
+ d = toDate(dateOrTimestamp);
286
+ } else {
287
+ // today, now
288
+ d = new Date();
289
+ }
290
+
291
+ d.setHours(0);
292
+ d.setMinutes(0);
293
+ d.setSeconds(0);
294
+ d.setMilliseconds(0);
295
+
296
+ return d.getTime();
297
+ }
298
+
299
+ /**
300
+ * Return the timestamp of the end of the day
301
+ * - Midnight - 1 millisecond
302
+ *
303
+ * @param {Date|number} [dateOrTimestamp]
304
+ *
305
+ * @returns {number} timestamp of start of the day
306
+ */
307
+ export function getTimeAtEndOfDay(dateOrTimestamp) {
308
+ let d;
309
+
310
+ if (dateOrTimestamp) {
311
+ d = toDate(dateOrTimestamp);
312
+ } else {
313
+ // today, now
314
+ d = new Date();
315
+ }
316
+
317
+ d.setHours(23);
318
+ d.setMinutes(59);
319
+ d.setSeconds(59);
320
+ d.setMilliseconds(999);
321
+
322
+ return d.getTime();
323
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Returns a three character prefix that is calculated at boot
3
+ *
4
+ * @returns {string} boot time prefix
5
+ */
6
+ export function bootTimePrefix(): string;
7
+ /**
8
+ * Create a string that contains random characters from the base58 alphabet
9
+ *
10
+ * @param {number} [length=48]
11
+ *
12
+ * @returns {string} a base 58 encoded random string
13
+ */
14
+ export function randomStringBase58(length?: number): string;
15
+ /**
16
+ * Create a string that contains random characters from a for human's not
17
+ * ambiguous alphabet
18
+ *
19
+ * @param {number} [length=48]
20
+ *
21
+ * @returns {string} a human friendly encoded random string
22
+ */
23
+ export function randomStringBaseHuman(length?: number): string;
24
+ /**
25
+ * Create a string that contains random characters from the specified alphabet
26
+ *
27
+ * @param {number} [length=48]
28
+ * @param {string} [ALPHABET=ALPHABET_BASE_58]
29
+ *
30
+ * @returns {string} a base 58 encoded random string
31
+ */
32
+ export function randomString(length?: number, ALPHABET?: string): string;
33
+ /**
34
+ * Create an access code: a string that contains 48 random characters from the
35
+ * base58 alphabet
36
+ *
37
+ * @returns {string} a base 58 encoded random string of length 48
38
+ */
39
+ export function randomAccessCode(): string;
40
+ /**
41
+ * Generate client session id
42
+ *
43
+ * @returns {string} a base 58 encoded random string of length 48
44
+ */
45
+ export function generateClientSessionId(): string;
46
+ /**
47
+ * Generates and returns a new unique local id
48
+ * - The generated id is garanteed to be unique on the currently running
49
+ * local system
50
+ *
51
+ * @param {number} [timeMs]
52
+ * Custom time value to be used instead of Date.now()
53
+ *
54
+ * @returns {string} local id
55
+ */
56
+ export function generateLocalId(timeMs?: number): string;
57
+ /**
58
+ * Returns a time based number that changes every 30 seconds
59
+ *
60
+ * @param {number} [timeMs=sinceMs()]
61
+ * Custom time value to be used instead of sinceMs()
62
+ *
63
+ * @returns {number} time based numerical that changes every 30 seconds
64
+ */
65
+ export function getTimeBasedNumber30s(timeMs?: number): number;
66
+ /**
67
+ * Returns two character base58 encoded string that changes every 10
68
+ * milliseconds
69
+ *
70
+ * - The function output changes every 9 milliseconds
71
+ * - Returns a two character string
72
+ * - The string is base58 encoded
73
+ * - After 58 * 58 * 10ms = 33,6 seconds, the function output repeats
74
+ *
75
+ * @param {number} [timeMs]
76
+ * Custom time value to be used instead of Date.now()
77
+ *
78
+ * @returns {string} time based value
79
+ */
80
+ export function getTwoChar10ms(timeMs?: number): string;
81
+ export const BOOT_STAMP: string;
@@ -0,0 +1,249 @@
1
+ /**
2
+ * unique.js
3
+ *
4
+ * @description
5
+ * This file contains functionality to generate unique data
6
+ *
7
+ * @example
8
+ *
9
+ * import { generateLocalId } from './unqiue.js';
10
+ *
11
+ * async function test()
12
+ * {
13
+ * console.log( `Id 1 [${generateLocalId()}]` );
14
+ * console.log( `Id 2 [${generateLocalId()}]` );
15
+ * }
16
+ */
17
+
18
+ /* ------------------------------------------------------------------ Imports */
19
+
20
+ import { ALPHABET_BASE_HUMAN, ALPHABET_BASE_58 } from '../../constants/bases.js';
21
+
22
+ import { base58fromNumber } from '../bases';
23
+
24
+ import { TIME_2025_01_01 } from '../../constants/time';
25
+
26
+ import { sinceMs } from '../time';
27
+
28
+ /**
29
+ * @type {{
30
+ * bootTimePrefix?:string,
31
+ * lastTimeBasedNumber?: number,
32
+ * lastTimeBasedValue58?: string,
33
+ * lastCountBasedNumber?: number
34
+ * }}
35
+ */
36
+ var vars = {}; /* @note use 'var declaration' for hoisting */
37
+
38
+ export const BOOT_STAMP = ( Date.now() - TIME_2025_01_01 ).toString(36);
39
+
40
+ /* ------------------------------------------------------------------ Exports */
41
+
42
+ /**
43
+ * Returns a three character prefix that is calculated at boot
44
+ *
45
+ * @returns {string} boot time prefix
46
+ */
47
+ export function bootTimePrefix()
48
+ {
49
+ if( !vars.bootTimePrefix )
50
+ {
51
+ vars.bootTimePrefix = '3' + getTwoChar10ms();
52
+ }
53
+
54
+ return vars.bootTimePrefix;
55
+ }
56
+
57
+ /**
58
+ * Create a string that contains random characters from the base58 alphabet
59
+ *
60
+ * @param {number} [length=48]
61
+ *
62
+ * @returns {string} a base 58 encoded random string
63
+ */
64
+ export function randomStringBase58( length=48 )
65
+ {
66
+ return randomString( length, ALPHABET_BASE_58 );
67
+ }
68
+
69
+ /**
70
+ * Create a string that contains random characters from a for human's not
71
+ * ambiguous alphabet
72
+ *
73
+ * @param {number} [length=48]
74
+ *
75
+ * @returns {string} a human friendly encoded random string
76
+ */
77
+ export function randomStringBaseHuman( length=48 )
78
+ {
79
+ return randomString( length, ALPHABET_BASE_HUMAN );
80
+ }
81
+
82
+ /**
83
+ * Create a string that contains random characters from the specified alphabet
84
+ *
85
+ * @param {number} [length=48]
86
+ * @param {string} [ALPHABET=ALPHABET_BASE_58]
87
+ *
88
+ * @returns {string} a base 58 encoded random string
89
+ */
90
+ export function randomString( length=48, ALPHABET=ALPHABET_BASE_58 )
91
+ {
92
+ if( typeof length !== 'number' || length < 1 )
93
+ {
94
+ throw new Error('Invalid parameter [length]');
95
+ }
96
+
97
+ if( typeof ALPHABET !== 'string' || !ALPHABET.length )
98
+ {
99
+ throw new Error('Invalid parameter [ALPHABET]');
100
+ }
101
+
102
+ let str = '';
103
+
104
+ const n = ALPHABET.length;
105
+
106
+ for( let j = length; j > 0; j = j - 1 )
107
+ {
108
+ const num = n * Math.random() & -1; // number [0...n-1]
109
+ str += ALPHABET[ num ];
110
+ }
111
+
112
+ return str;
113
+ }
114
+
115
+ /**
116
+ * Create an access code: a string that contains 48 random characters from the
117
+ * base58 alphabet
118
+ *
119
+ * @returns {string} a base 58 encoded random string of length 48
120
+ */
121
+ export function randomAccessCode()
122
+ {
123
+ return randomStringBase58( 48 );
124
+ }
125
+
126
+ /**
127
+ * Generate client session id
128
+ *
129
+ * @returns {string} a base 58 encoded random string of length 48
130
+ */
131
+ export function generateClientSessionId()
132
+ {
133
+ return randomStringBase58( 48 );
134
+ }
135
+
136
+ /**
137
+ * Generates and returns a new unique local id
138
+ * - The generated id is garanteed to be unique on the currently running
139
+ * local system
140
+ *
141
+ * @param {number} [timeMs]
142
+ * Custom time value to be used instead of Date.now()
143
+ *
144
+ * @returns {string} local id
145
+ */
146
+ export function generateLocalId( timeMs )
147
+ {
148
+ const timeBasedNumber = getTimeBasedNumber30s( timeMs );
149
+
150
+ let timeBasedValue58;
151
+
152
+ let countBasedNumber;
153
+
154
+ if( vars.lastTimeBasedNumber !== timeBasedNumber )
155
+ {
156
+ // -- Time stamp based number changed -> reset counter to zero
157
+
158
+ countBasedNumber =
159
+ vars.lastCountBasedNumber = 0;
160
+
161
+ // -- Calculate timeBasedValue58 and update cache
162
+
163
+ vars.lastTimeBasedNumber = timeBasedNumber;
164
+
165
+ // cache string representation
166
+ timeBasedValue58 =
167
+ vars.lastTimeBasedValue58 = base58fromNumber( timeBasedNumber );
168
+ }
169
+ else {
170
+ // -- Same time stamp based number -> increment counter
171
+
172
+ countBasedNumber =
173
+ vars.lastCountBasedNumber = vars.lastCountBasedNumber + 1;
174
+
175
+ // -- Use cached lastTimeBasedNumber
176
+
177
+ timeBasedValue58 = vars.lastTimeBasedValue58;
178
+ }
179
+
180
+ const countBasedValue58 = base58fromNumber( countBasedNumber );
181
+
182
+ // Combine parts into single identifier string
183
+ //
184
+ // @note ALPHABET_BASE_58 is used because it is faster than
185
+ // base58fromNumber for single character encoding
186
+ //
187
+ const id =
188
+ // idFormatPrefix
189
+ bootTimePrefix() +
190
+ ALPHABET_BASE_58[ timeBasedValue58.length ] +
191
+ timeBasedValue58 +
192
+ countBasedValue58;
193
+
194
+ // std.debug( id );
195
+
196
+ return id;
197
+ }
198
+
199
+
200
+ /**
201
+ * Returns a time based number that changes every 30 seconds
202
+ *
203
+ * @param {number} [timeMs=sinceMs()]
204
+ * Custom time value to be used instead of sinceMs()
205
+ *
206
+ * @returns {number} time based numerical that changes every 30 seconds
207
+ */
208
+ export function getTimeBasedNumber30s( timeMs )
209
+ {
210
+ if( !timeMs )
211
+ {
212
+ timeMs = sinceMs();
213
+ }
214
+
215
+ // @note do not use bitwise shift since it only works on 32 bit numbers!
216
+ return Math.floor( timeMs / 30000 );
217
+ }
218
+
219
+
220
+ /**
221
+ * Returns two character base58 encoded string that changes every 10
222
+ * milliseconds
223
+ *
224
+ * - The function output changes every 9 milliseconds
225
+ * - Returns a two character string
226
+ * - The string is base58 encoded
227
+ * - After 58 * 58 * 10ms = 33,6 seconds, the function output repeats
228
+ *
229
+ * @param {number} [timeMs]
230
+ * Custom time value to be used instead of Date.now()
231
+ *
232
+ * @returns {string} time based value
233
+ */
234
+ export function getTwoChar10ms( timeMs )
235
+ {
236
+ const now = timeMs || Date.now();
237
+
238
+ // @note
239
+ // do not use bitwise shift since it only works on 32 bit numbers
240
+ const num = Math.floor( now / 10 ) % 3364;
241
+
242
+ if( num >= 58 )
243
+ {
244
+ return base58fromNumber( num );
245
+ }
246
+ else {
247
+ return '1' + base58fromNumber( num );
248
+ }
249
+ }
@@ -0,0 +1,10 @@
1
+ // > Imports
2
+
3
+ import * as v from 'valibot';
4
+
5
+ // > Exports
6
+
7
+ /**
8
+ * Schema to validate a Date or ISO timestamp.
9
+ */
10
+ export const DateOrIsoTimeStamp = v.union([v.date(), v.pipe(v.string(), v.isoTimestamp())]);
@@ -0,0 +1,4 @@
1
+ export * from "./user.js";
2
+ export * from "./url.js";
3
+ export default v;
4
+ import * as v from 'valibot';
@@ -0,0 +1,9 @@
1
+ import * as v from 'valibot';
2
+
3
+ // export * from './date.js';
4
+
5
+ export * from './user.js';
6
+
7
+ export * from './url.js';
8
+
9
+ export default v;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Schema to validate an URL or empty string.
3
+ */
4
+ export const UrlOrEmptyString: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, v.UnionSchema<[v.LiteralSchema<"", undefined>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>]>], undefined>]>;
5
+ /**
6
+ * Schema to validate an url that may miss the protocol part
7
+ *
8
+ * @note an empty string is not allowed!
9
+ */
10
+ export const HumanUrl: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.TransformAction<string, string>, v.UrlAction<string, undefined>]>;
11
+ /**
12
+ * Schema to validate url path, without a search and hash part
13
+ */
14
+ export const UrlPath: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, URL>, v.CustomSchema<URL, "Invalid URL pathname">, v.TransformAction<URL, string>]>;
15
+ /**
16
+ * Schema to validate a url path, which consists of
17
+ * a path and optionally search and hash parts
18
+ */
19
+ export const RelativeUrl: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, URL>, v.CustomSchema<URL, "Invalid URL pathname or search part">, v.TransformAction<URL, string>]>;
20
+ /**
21
+ * Schema to validate an absolute or relative url
22
+ *
23
+ * @note an empty string is not allowed!
24
+ */
25
+ export const AbsOrRelUrl: v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.UrlAction<string, undefined>]>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, URL>, v.CustomSchema<URL, "Invalid URL pathname or search part">, v.TransformAction<URL, string>]>]>], undefined>;
26
+ import * as v from 'valibot';