@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.
- package/README.md +149 -0
- package/dist/assets/autospuiten/car-paint-picker/army-green.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/electric-blue.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/lemon-yellow.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/opaque-purple.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/rusty.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/sunset-orange.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker/tomato-red.jpg +0 -0
- package/dist/assets/autospuiten/car-paint-picker.d.ts +17 -0
- package/dist/assets/autospuiten/car-paint-picker.js +41 -0
- package/dist/assets/autospuiten/labels.d.ts +7 -0
- package/dist/assets/autospuiten/labels.js +7 -0
- package/dist/classes/cache/IndexedDbCache.d.ts +216 -0
- package/dist/classes/cache/IndexedDbCache.js +1407 -0
- package/dist/classes/cache/MemoryResponseCache.d.ts +106 -0
- package/dist/classes/cache/MemoryResponseCache.js +138 -0
- package/dist/classes/cache/index.d.ts +3 -0
- package/dist/classes/cache/index.js +5 -0
- package/dist/classes/cache/typedef.d.ts +67 -0
- package/dist/classes/cache/typedef.js +41 -0
- package/dist/classes/data/IterableTree.d.ts +51 -0
- package/dist/classes/data/IterableTree.js +243 -0
- package/dist/classes/data/Selector.d.ts +30 -0
- package/dist/classes/data/Selector.js +190 -0
- package/dist/classes/data/index.d.ts +2 -0
- package/dist/classes/data/index.js +2 -0
- package/dist/classes/events/EventEmitter.d.ts +142 -0
- package/dist/classes/events/EventEmitter.js +275 -0
- package/dist/classes/events/index.d.ts +1 -0
- package/dist/classes/events/index.js +2 -0
- package/dist/classes/index.d.ts +4 -0
- package/dist/classes/index.js +4 -0
- package/dist/classes/logging/Logger.d.ts +78 -0
- package/dist/classes/logging/Logger.js +210 -0
- package/dist/classes/logging/constants.d.ts +12 -0
- package/dist/classes/logging/constants.js +16 -0
- package/dist/classes/logging/index.d.ts +2 -0
- package/dist/classes/logging/index.js +4 -0
- package/dist/classes/logging/typedef.d.ts +34 -0
- package/dist/classes/logging/typedef.js +17 -0
- package/dist/classes/promise/HkPromise.d.ts +121 -0
- package/dist/classes/promise/HkPromise.js +377 -0
- package/dist/classes/promise/index.d.ts +1 -0
- package/dist/classes/promise/index.js +1 -0
- package/dist/classes/services/ServiceBase.d.ts +163 -0
- package/dist/classes/services/ServiceBase.js +463 -0
- package/dist/classes/services/ServiceManager.d.ts +179 -0
- package/dist/classes/services/ServiceManager.js +614 -0
- package/dist/classes/services/index.d.ts +4 -0
- package/dist/classes/services/index.js +5 -0
- package/dist/classes/services/service-states.d.ts +159 -0
- package/dist/classes/services/service-states.js +205 -0
- package/dist/classes/services/typedef.d.ts +247 -0
- package/dist/classes/services/typedef.js +179 -0
- package/dist/classes/stores/SubscribersCount.d.ts +39 -0
- package/dist/classes/stores/SubscribersCount.js +107 -0
- package/dist/classes/stores/index.d.ts +1 -0
- package/dist/classes/stores/index.js +1 -0
- package/dist/classes/streams/LogTransformStream.d.ts +4 -0
- package/dist/classes/streams/LogTransformStream.js +19 -0
- package/dist/classes/streams/ServerEventsStore.d.ts +22 -0
- package/dist/classes/streams/ServerEventsStore.js +110 -0
- package/dist/classes/streams/TimeStampSource.d.ts +13 -0
- package/dist/classes/streams/TimeStampSource.js +26 -0
- package/dist/classes/streams/index.d.ts +3 -0
- package/dist/classes/streams/index.js +3 -0
- package/dist/classes/svelte/audio/AudioLoader.svelte.d.ts +30 -0
- package/dist/classes/svelte/audio/AudioLoader.svelte.js +58 -0
- package/dist/classes/svelte/audio/AudioScene.svelte.d.ts +74 -0
- package/dist/classes/svelte/audio/AudioScene.svelte.js +324 -0
- package/dist/classes/svelte/audio/mocks.d.ts +7 -0
- package/dist/classes/svelte/audio/mocks.js +35 -0
- package/dist/classes/svelte/finite-state-machine/FiniteStateMachine.svelte.d.ts +50 -0
- package/dist/classes/svelte/finite-state-machine/FiniteStateMachine.svelte.js +133 -0
- package/dist/classes/svelte/finite-state-machine/index.d.ts +1 -0
- package/dist/classes/svelte/finite-state-machine/index.js +1 -0
- package/dist/classes/svelte/image/ImageLoader.svelte.d.ts +19 -0
- package/dist/classes/svelte/image/ImageLoader.svelte.js +45 -0
- package/dist/classes/svelte/image/ImageScene.svelte.d.ts +78 -0
- package/dist/classes/svelte/image/ImageScene.svelte.js +249 -0
- package/dist/classes/svelte/image/ImageVariantsLoader.svelte.d.ts +43 -0
- package/dist/classes/svelte/image/ImageVariantsLoader.svelte.js +152 -0
- package/dist/classes/svelte/image/index.d.ts +2 -0
- package/dist/classes/svelte/image/index.js +4 -0
- package/dist/classes/svelte/image/mocks.d.ts +7 -0
- package/dist/classes/svelte/image/mocks.js +35 -0
- package/dist/classes/svelte/image/typedef.d.ts +16 -0
- package/dist/classes/svelte/image/typedef.js +8 -0
- package/dist/classes/svelte/index.d.ts +9 -0
- package/dist/classes/svelte/index.js +14 -0
- package/dist/classes/svelte/loading-state-machine/LoadingStateMachine.svelte.d.ts +12 -0
- package/dist/classes/svelte/loading-state-machine/LoadingStateMachine.svelte.js +109 -0
- package/dist/classes/svelte/loading-state-machine/constants.d.ts +12 -0
- package/dist/classes/svelte/loading-state-machine/constants.js +16 -0
- package/dist/classes/svelte/loading-state-machine/index.d.ts +2 -0
- package/dist/classes/svelte/loading-state-machine/index.js +3 -0
- package/dist/classes/svelte/network-loader/NetworkLoader.svelte.d.ts +91 -0
- package/dist/classes/svelte/network-loader/NetworkLoader.svelte.js +338 -0
- package/dist/classes/svelte/network-loader/constants.d.ts +2 -0
- package/dist/classes/svelte/network-loader/constants.js +3 -0
- package/dist/classes/svelte/network-loader/index.d.ts +2 -0
- package/dist/classes/svelte/network-loader/index.js +3 -0
- package/dist/classes/svelte/network-loader/mocks.d.ts +7 -0
- package/dist/classes/svelte/network-loader/mocks.js +30 -0
- package/dist/classes/svelte/network-loader/typedef.d.ts +7 -0
- package/dist/classes/svelte/network-loader/typedef.js +8 -0
- package/dist/components/area/HkArea.svelte +49 -0
- package/dist/components/area/HkArea.svelte.d.ts +26 -0
- package/dist/components/area/HkGridArea.svelte +77 -0
- package/dist/components/area/HkGridArea.svelte.d.ts +42 -0
- package/dist/components/area/index.d.ts +2 -0
- package/dist/components/area/index.js +2 -0
- package/dist/components/buttons/button/Button.svelte +82 -0
- package/dist/components/buttons/button/Button.svelte.d.ts +44 -0
- package/dist/components/buttons/button-icon-steeze/SteezeIconButton.svelte +30 -0
- package/dist/components/buttons/button-icon-steeze/SteezeIconButton.svelte.d.ts +16 -0
- package/dist/components/buttons/button-text/TextButton.svelte +21 -0
- package/dist/components/buttons/button-text/TextButton.svelte.d.ts +12 -0
- package/dist/components/buttons/index.d.ts +3 -0
- package/dist/components/buttons/index.js +3 -0
- package/dist/components/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte +146 -0
- package/dist/components/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte.d.ts +6 -0
- package/dist/components/debug/index.d.ts +1 -0
- package/dist/components/debug/index.js +1 -0
- package/dist/components/drag-drop/DragController.d.ts +20 -0
- package/dist/components/drag-drop/DragController.js +44 -0
- package/dist/components/drag-drop/DragDropContext.svelte +111 -0
- package/dist/components/drag-drop/DragDropContext.svelte.d.ts +18 -0
- package/dist/components/drag-drop/Draggable.svelte +519 -0
- package/dist/components/drag-drop/Draggable.svelte.d.ts +95 -0
- package/dist/components/drag-drop/DropZone.svelte +258 -0
- package/dist/components/drag-drop/DropZone.svelte.d.ts +96 -0
- package/dist/components/drag-drop/DropZoneArea.svelte +119 -0
- package/dist/components/drag-drop/DropZoneArea.svelte.d.ts +90 -0
- package/dist/components/drag-drop/DropZoneList.svelte +125 -0
- package/dist/components/drag-drop/DropZoneList.svelte.d.ts +92 -0
- package/dist/components/drag-drop/actions.d.ts +9 -0
- package/dist/components/drag-drop/actions.js +26 -0
- package/dist/components/drag-drop/drag-state.svelte.d.ts +97 -0
- package/dist/components/drag-drop/drag-state.svelte.js +322 -0
- package/dist/components/drag-drop/index.d.ts +6 -0
- package/dist/components/drag-drop/index.js +7 -0
- package/dist/components/drag-drop/util.d.ts +0 -0
- package/dist/components/drag-drop/util.js +85 -0
- package/dist/components/hkdev/blocks/TextBlock.svelte +47 -0
- package/dist/components/hkdev/blocks/TextBlock.svelte.d.ts +24 -0
- package/dist/components/hkdev/buttons/CheckButton.svelte +63 -0
- package/dist/components/hkdev/buttons/CheckButton.svelte.d.ts +34 -0
- package/dist/components/icons/HkIcon.svelte +86 -0
- package/dist/components/icons/HkIcon.svelte.d.ts +22 -0
- package/dist/components/icons/HkTabIcon.svelte +116 -0
- package/dist/components/icons/HkTabIcon.svelte.d.ts +40 -0
- package/dist/components/icons/SteezeIcon.svelte +97 -0
- package/dist/components/icons/SteezeIcon.svelte.d.ts +22 -0
- package/dist/components/icons/index.d.ts +4 -0
- package/dist/components/icons/index.js +6 -0
- package/dist/components/icons/typedef.d.ts +13 -0
- package/dist/components/icons/typedef.js +16 -0
- package/dist/components/index.d.ts +0 -0
- package/dist/components/index.js +2 -0
- package/dist/components/inputs/index.d.ts +1 -0
- package/dist/components/inputs/index.js +1 -0
- package/dist/components/inputs/text-input/TestTextInput.svelte__ +102 -0
- package/dist/components/inputs/text-input/TextInput.svelte +223 -0
- package/dist/components/inputs/text-input/TextInput.svelte.d.ts +56 -0
- package/dist/components/inputs/text-input/TextInput.svelte___ +83 -0
- package/dist/components/inputs/text-input/assets/IconInvalid.svelte +14 -0
- package/dist/components/inputs/text-input/assets/IconInvalid.svelte.d.ts +26 -0
- package/dist/components/inputs/text-input/assets/IconValid.svelte +12 -0
- package/dist/components/inputs/text-input/assets/IconValid.svelte.d.ts +26 -0
- package/dist/components/layout/grid-layers/GridLayers.svelte +63 -0
- package/dist/components/layout/grid-layers/GridLayers.svelte.d.ts +26 -0
- package/dist/components/layout/grid-layers/GridLayers.svelte__heightFrom__ +372 -0
- package/dist/components/layout/grid-layers/util.d.ts +19 -0
- package/dist/components/layout/grid-layers/util.js +74 -0
- package/dist/components/layout/index.d.ts +1 -0
- package/dist/components/layout/index.js +1 -0
- package/dist/components/panels/index.d.ts +1 -0
- package/dist/components/panels/index.js +1 -0
- package/dist/components/panels/panel/Panel.svelte +43 -0
- package/dist/components/panels/panel/Panel.svelte.d.ts +24 -0
- package/dist/components/rows/index.d.ts +2 -0
- package/dist/components/rows/index.js +3 -0
- package/dist/components/rows/panel-grid-row/PanelGridRow.svelte +104 -0
- package/dist/components/rows/panel-grid-row/PanelGridRow.svelte.d.ts +26 -0
- package/dist/components/rows/panel-row-2/PanelRow2.svelte +40 -0
- package/dist/components/rows/panel-row-2/PanelRow2.svelte.d.ts +26 -0
- package/dist/components/tab-bar/HkTabBar.state.svelte.d.ts +54 -0
- package/dist/components/tab-bar/HkTabBar.state.svelte.js +149 -0
- package/dist/components/tab-bar/HkTabBar.svelte +74 -0
- package/dist/components/tab-bar/HkTabBar.svelte.d.ts +34 -0
- package/dist/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +19 -0
- package/dist/components/tab-bar/HkTabBarSelector.state.svelte.js +93 -0
- package/dist/components/tab-bar/HkTabBarSelector.svelte +49 -0
- package/dist/components/tab-bar/HkTabBarSelector.svelte.d.ts +36 -0
- package/dist/components/tab-bar/index.d.ts +5 -0
- package/dist/components/tab-bar/index.js +17 -0
- package/dist/components/tab-bar/typedef.d.ts +8 -0
- package/dist/components/tab-bar/typedef.js +11 -0
- package/dist/config/imagetools-config.d.ts +26 -0
- package/dist/config/imagetools-config.js +189 -0
- package/dist/config/imagetools.d.ts +72 -0
- package/dist/constants/bases.d.ts +10 -0
- package/dist/constants/bases.js +13 -0
- package/dist/constants/errors/api.d.ts +10 -0
- package/dist/constants/errors/api.js +9 -0
- package/dist/constants/errors/generic.d.ts +20 -0
- package/dist/constants/errors/generic.js +20 -0
- package/dist/constants/errors/http.d.ts +16 -0
- package/dist/constants/errors/http.js +16 -0
- package/dist/constants/errors/index.d.ts +4 -0
- package/dist/constants/errors/index.js +4 -0
- package/dist/constants/errors/jwt.d.ts +8 -0
- package/dist/constants/errors/jwt.js +5 -0
- package/dist/constants/http/headers.d.ts +5 -0
- package/dist/constants/http/headers.js +6 -0
- package/dist/constants/http/index.d.ts +2 -0
- package/dist/constants/http/index.js +2 -0
- package/dist/constants/http/methods.d.ts +7 -0
- package/dist/constants/http/methods.js +14 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +3 -0
- package/dist/constants/mime/application.d.ts +3 -0
- package/dist/constants/mime/application.js +5 -0
- package/dist/constants/mime/audio.d.ts +10 -0
- package/dist/constants/mime/audio.js +13 -0
- package/dist/constants/mime/image.d.ts +3 -0
- package/dist/constants/mime/image.js +3 -0
- package/dist/constants/mime/index.d.ts +4 -0
- package/dist/constants/mime/index.js +4 -0
- package/dist/constants/mime/text.d.ts +2 -0
- package/dist/constants/mime/text.js +2 -0
- package/dist/constants/regexp/index.d.ts +3 -0
- package/dist/constants/regexp/index.js +31 -0
- package/dist/constants/regexp/inspiratie.js__ +95 -0
- package/dist/constants/regexp/text.d.ts +47 -0
- package/dist/constants/regexp/text.js +49 -0
- package/dist/constants/regexp/user.d.ts +6 -0
- package/dist/constants/regexp/user.js +33 -0
- package/dist/constants/regexp/web.d.ts +1 -0
- package/dist/constants/regexp/web.js +3 -0
- package/dist/constants/state-labels/drag-states.d.ts +5 -0
- package/dist/constants/state-labels/drag-states.js +6 -0
- package/dist/constants/state-labels/drop-states.d.ts +4 -0
- package/dist/constants/state-labels/drop-states.js +6 -0
- package/dist/constants/state-labels/input-states.d.ts +8 -0
- package/dist/constants/state-labels/input-states.js +11 -0
- package/dist/constants/state-labels/submit-states.d.ts +4 -0
- package/dist/constants/state-labels/submit-states.js +4 -0
- package/dist/constants/time.d.ts +18 -0
- package/dist/constants/time.js +28 -0
- package/dist/css/utilities.css +43 -0
- package/dist/design/design-config.d.ts +157 -0
- package/dist/design/design-config.js +73 -0
- package/dist/design/tailwind-theme-extend.d.ts +23 -0
- package/dist/design/tailwind-theme-extend.js +158 -0
- package/dist/features/button-group/ButtonGroup.svelte +82 -0
- package/dist/features/button-group/ButtonGroup.svelte.d.ts +34 -0
- package/dist/features/button-group/typedef.d.ts +7 -0
- package/dist/features/button-group/typedef.js +10 -0
- package/dist/features/compare-left-right/CompareLeftRight.svelte +179 -0
- package/dist/features/compare-left-right/CompareLeftRight.svelte.d.ts +18 -0
- package/dist/features/compare-left-right/index.d.ts +1 -0
- package/dist/features/compare-left-right/index.js +1 -0
- package/dist/features/game-box/GameBox.svelte +577 -0
- package/dist/features/game-box/GameBox.svelte.d.ts +140 -0
- package/dist/features/game-box/gamebox.util.d.ts +32 -0
- package/dist/features/game-box/gamebox.util.js +83 -0
- package/dist/features/hk-app-layout/HkAppLayout.state.svelte.d.ts +6 -0
- package/dist/features/hk-app-layout/HkAppLayout.state.svelte.js +25 -0
- package/dist/features/hk-app-layout/HkAppLayout.svelte +251 -0
- package/dist/features/hk-app-layout/HkAppLayout.svelte.d.ts +19 -0
- package/dist/features/image-box/ImageBox.svelte +210 -0
- package/dist/features/image-box/ImageBox.svelte.d.ts +38 -0
- package/dist/features/image-box/index.d.ts +4 -0
- package/dist/features/image-box/index.js +5 -0
- package/dist/features/image-box/typedef.d.ts +4 -0
- package/dist/features/image-box/typedef.js +32 -0
- package/dist/features/index.d.ts +11 -0
- package/dist/features/index.js +23 -0
- package/dist/features/presenter/ImageSlide.svelte +64 -0
- package/dist/features/presenter/ImageSlide.svelte.d.ts +36 -0
- package/dist/features/presenter/Presenter.state.svelte.d.ts +74 -0
- package/dist/features/presenter/Presenter.state.svelte.js +638 -0
- package/dist/features/presenter/Presenter.svelte +142 -0
- package/dist/features/presenter/Presenter.svelte.d.ts +18 -0
- package/dist/features/presenter/constants.d.ts +5 -0
- package/dist/features/presenter/constants.js +7 -0
- package/dist/features/presenter/index.d.ts +6 -0
- package/dist/features/presenter/index.js +10 -0
- package/dist/features/presenter/typedef.d.ts +92 -0
- package/dist/features/presenter/typedef.js +106 -0
- package/dist/features/presenter/util.d.ts +63 -0
- package/dist/features/presenter/util.js +210 -0
- package/dist/features/virtual-viewport/VirtualViewport.svelte +196 -0
- package/dist/features/virtual-viewport/VirtualViewport.svelte.d.ts +42 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/logging/adapters/console.d.ts +48 -0
- package/dist/logging/adapters/console.js +114 -0
- package/dist/logging/adapters/pino.d.ts +25 -0
- package/dist/logging/adapters/pino.js +60 -0
- package/dist/logging/constants.d.ts +1 -0
- package/dist/logging/constants.js +1 -0
- package/dist/logging/factories/client.d.ts +10 -0
- package/dist/logging/factories/client.js +21 -0
- package/dist/logging/factories/server.d.ts +10 -0
- package/dist/logging/factories/server.js +22 -0
- package/dist/logging/factories/universal.d.ts +9 -0
- package/dist/logging/factories/universal.js +23 -0
- package/dist/logging/index.d.ts +5 -0
- package/dist/logging/index.js +8 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/validate-url.d.ts +30 -0
- package/dist/schemas/validate-url.js +180 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/logger.d.ts +25 -0
- package/dist/server/logger.js +94 -0
- package/dist/states/index.d.ts +1 -0
- package/dist/states/index.js +1 -0
- package/dist/states/navigation.svelte.d.ts +23 -0
- package/dist/states/navigation.svelte.js +55 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.js +1 -0
- package/dist/stores/theme.d.ts +28 -0
- package/dist/stores/theme.js +80 -0
- package/dist/themes/hkdev/components/blocks/text-block.css +34 -0
- package/dist/themes/hkdev/components/boxes/game-box.css +11 -0
- package/dist/themes/hkdev/components/buttons/button-icon-steeze.css +22 -0
- package/dist/themes/hkdev/components/buttons/button-text.css +32 -0
- package/dist/themes/hkdev/components/buttons/button.css +146 -0
- package/dist/themes/hkdev/components/buttons/skip-button.css +5 -0
- package/dist/themes/hkdev/components/drag-drop/draggable.css +73 -0
- package/dist/themes/hkdev/components/drag-drop/drop-zone.css +58 -0
- package/dist/themes/hkdev/components/icons/icon-steeze.css +16 -0
- package/dist/themes/hkdev/components/inputs/text-input.css +102 -0
- package/dist/themes/hkdev/components/panels/panel.css +25 -0
- package/dist/themes/hkdev/components/rows/panel-grid-row.css +4 -0
- package/dist/themes/hkdev/components/rows/panel-row-2.css +5 -0
- package/dist/themes/hkdev/components.css +29 -0
- package/dist/themes/hkdev/debug.css +2 -0
- package/dist/themes/hkdev/global/layout.css +32 -0
- package/dist/themes/hkdev/global/on-colors.css +32 -0
- package/dist/themes/hkdev/globals.css +4 -0
- package/dist/themes/hkdev/responsive.css +12 -0
- package/dist/themes/hkdev/theme-ext.d.ts +4 -0
- package/dist/themes/hkdev/theme-ext.js +12 -0
- package/dist/themes/hkdev/theme.css +219 -0
- package/dist/themes/index.d.ts +1 -0
- package/dist/themes/index.js +1 -0
- package/dist/typedef/context.d.ts +3 -0
- package/dist/typedef/context.js +6 -0
- package/dist/typedef/drag.d.ts +29 -0
- package/dist/typedef/drag.js +25 -0
- package/dist/typedef/drop.d.ts +15 -0
- package/dist/typedef/drop.js +12 -0
- package/dist/typedef/image.d.ts +12 -0
- package/dist/typedef/image.js +38 -0
- package/dist/typedef/index.d.ts +4 -0
- package/dist/typedef/index.js +4 -0
- package/dist/util/array/index.d.ts +183 -0
- package/dist/util/array/index.js +436 -0
- package/dist/util/bases/base58.d.ts +58 -0
- package/dist/util/bases/base58.js +262 -0
- package/dist/util/bases/index.d.ts +1 -0
- package/dist/util/bases/index.js +1 -0
- package/dist/util/compare/index.d.ts +68 -0
- package/dist/util/compare/index.js +247 -0
- package/dist/util/css/css-vars.d.ts +24 -0
- package/dist/util/css/css-vars.js +83 -0
- package/dist/util/css/index.d.ts +1 -0
- package/dist/util/css/index.js +1 -0
- package/dist/util/design-system/components/states.d.ts +15 -0
- package/dist/util/design-system/components/states.js +22 -0
- package/dist/util/design-system/css/clamp.d.ts +17 -0
- package/dist/util/design-system/css/clamp.js +66 -0
- package/dist/util/design-system/css/root-design-vars.d.ts +77 -0
- package/dist/util/design-system/css/root-design-vars.js +102 -0
- package/dist/util/design-system/index.d.ts +5 -0
- package/dist/util/design-system/index.js +5 -0
- package/dist/util/design-system/layout/scaling.d.ts +98 -0
- package/dist/util/design-system/layout/scaling.js +228 -0
- package/dist/util/design-system/skeleton.d.ts +41 -0
- package/dist/util/design-system/skeleton.js +208 -0
- package/dist/util/design-system/tailwind.d.ts +183 -0
- package/dist/util/design-system/tailwind.js +288 -0
- package/dist/util/env/index.d.ts +1 -0
- package/dist/util/env/index.js +9 -0
- package/dist/util/exceptions/index.d.ts +15 -0
- package/dist/util/exceptions/index.js +23 -0
- package/dist/util/expect/arrays.d.ts +30 -0
- package/dist/util/expect/arrays.js +47 -0
- package/dist/util/expect/index.d.ts +103 -0
- package/dist/util/expect/index.js +259 -0
- package/dist/util/expect/primitives.d.ts +30 -0
- package/dist/util/expect/primitives.js +55 -0
- package/dist/util/expect/url.d.ts +32 -0
- package/dist/util/expect/url.js +60 -0
- package/dist/util/function/index.d.ts +34 -0
- package/dist/util/function/index.js +218 -0
- package/dist/util/geo/index.d.ts +10 -0
- package/dist/util/geo/index.js +26 -0
- package/dist/util/http/caching.d.ts +28 -0
- package/dist/util/http/caching.js +263 -0
- package/dist/util/http/errors.d.ts +18 -0
- package/dist/util/http/errors.js +97 -0
- package/dist/util/http/headers.d.ts +40 -0
- package/dist/util/http/headers.js +75 -0
- package/dist/util/http/http-request.d.ts +267 -0
- package/dist/util/http/http-request.js +578 -0
- package/dist/util/http/index.d.ts +6 -0
- package/dist/util/http/index.js +22 -0
- package/dist/util/http/json-request.d.ts +84 -0
- package/dist/util/http/json-request.js +224 -0
- package/dist/util/http/mocks.d.ts +20 -0
- package/dist/util/http/mocks.js +65 -0
- package/dist/util/http/response.d.ts +125 -0
- package/dist/util/http/response.js +294 -0
- package/dist/util/http/test-data__/content-length-test-hkdigital-small.V4HfZyBQ.avif +0 -0
- package/dist/util/http/typedef.d.ts +184 -0
- package/dist/util/http/typedef.js +93 -0
- package/dist/util/http/url.d.ts +25 -0
- package/dist/util/http/url.js +52 -0
- package/dist/util/image/index.d.ts +25 -0
- package/dist/util/image/index.js +86 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/index.js +3 -0
- package/dist/util/is/index.d.ts +68 -0
- package/dist/util/is/index.js +140 -0
- package/dist/util/iterate/index.d.ts +131 -0
- package/dist/util/iterate/index.js +234 -0
- package/dist/util/object/index.d.ts +326 -0
- package/dist/util/object/index.js +1361 -0
- package/dist/util/singleton/index.d.ts +34 -0
- package/dist/util/singleton/index.js +97 -0
- package/dist/util/string/array-path.d.ts +15 -0
- package/dist/util/string/array-path.js +75 -0
- package/dist/util/string/convert.d.ts +22 -0
- package/dist/util/string/convert.js +54 -0
- package/dist/util/string/fs.d.ts +55 -0
- package/dist/util/string/fs.js +226 -0
- package/dist/util/string/index.d.ts +5 -0
- package/dist/util/string/index.js +5 -0
- package/dist/util/string/interpolate.d.ts +22 -0
- package/dist/util/string/interpolate.js +61 -0
- package/dist/util/string/pad.d.ts +8 -0
- package/dist/util/string/pad.js +10 -0
- package/dist/util/svelte/index.d.ts +3 -0
- package/dist/util/svelte/index.js +4 -0
- package/dist/util/svelte/loading/loading-tracker.svelte.d.ts +31 -0
- package/dist/util/svelte/loading/loading-tracker.svelte.js +108 -0
- package/dist/util/svelte/observe/index.d.ts +10 -0
- package/dist/util/svelte/observe/index.js +49 -0
- package/dist/util/svelte/state-context/index.d.ts +18 -0
- package/dist/util/svelte/state-context/index.js +117 -0
- package/dist/util/svelte/wait/index.d.ts +15 -0
- package/dist/util/svelte/wait/index.js +38 -0
- package/dist/util/sveltekit/index.d.ts +1 -0
- package/dist/util/sveltekit/index.js +1 -0
- package/dist/util/sveltekit/route-folders/index.d.ts +28 -0
- package/dist/util/sveltekit/route-folders/index.js +101 -0
- package/dist/util/time/index.d.ts +108 -0
- package/dist/util/time/index.js +323 -0
- package/dist/util/unique/index.d.ts +81 -0
- package/dist/util/unique/index.js +249 -0
- package/dist/valibot/date.js__ +10 -0
- package/dist/valibot/index.d.ts +4 -0
- package/dist/valibot/index.js +9 -0
- package/dist/valibot/url.d.ts +26 -0
- package/dist/valibot/url.js +95 -0
- package/dist/valibot/user.d.ts +6 -0
- package/dist/valibot/user.js +23 -0
- package/dist/zod/all.d.ts +6 -0
- package/dist/zod/all.js +33 -0
- package/dist/zod/generic.d.ts +6 -0
- package/dist/zod/generic.js +11 -0
- package/dist/zod/javascript.d.ts +8 -0
- package/dist/zod/javascript.js +32 -0
- package/dist/zod/user.d.ts +9 -0
- package/dist/zod/user.js +16 -0
- package/dist/zod/web.d.ts +21 -0
- package/dist/zod/web.js +52 -0
- 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
|
|
Binary file
|
|
@@ -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;
|