@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,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Type definitions for the service management system.
|
|
3
|
+
*
|
|
4
|
+
* This file contains all TypeScript/JSDoc type definitions used throughout
|
|
5
|
+
* the service management system. Import these types in your service
|
|
6
|
+
* implementations and when using the ServiceManager.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // In your service implementation
|
|
10
|
+
* import { ServiceBase } from './ServiceBase.js';
|
|
11
|
+
*
|
|
12
|
+
* // @ typedef {import('./typedef.js').ServiceConfig} ServiceConfig
|
|
13
|
+
* // @ typedef {import('./typedef.js').HealthStatus} HealthStatus
|
|
14
|
+
*
|
|
15
|
+
* class MyService extends ServiceBase {
|
|
16
|
+
* async _init(config) {
|
|
17
|
+
* // config is typed as ServiceConfig
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* async _healthCheck() {
|
|
21
|
+
* // Return type is HealthStatus
|
|
22
|
+
* return { latency: 10 };
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // When using ServiceManager
|
|
28
|
+
* import { ServiceManager } from './ServiceManager.js';
|
|
29
|
+
*
|
|
30
|
+
* // @ typedef {import('./typedef.js').ServiceManagerConfig} ServiceManagerConfig
|
|
31
|
+
* // @ typedef {import('./typedef.js').ServiceRegistrationOptions} ServiceRegistrationOptions
|
|
32
|
+
*
|
|
33
|
+
* const config = {
|
|
34
|
+
* environment: 'development',
|
|
35
|
+
* stopTimeout: 5000
|
|
36
|
+
* };
|
|
37
|
+
*
|
|
38
|
+
* const manager = new ServiceManager(config);
|
|
39
|
+
*
|
|
40
|
+
* const options = {
|
|
41
|
+
* dependencies: ['database'],
|
|
42
|
+
* tags: ['critical']
|
|
43
|
+
* };
|
|
44
|
+
*
|
|
45
|
+
* manager.register('auth', AuthService, {}, options);
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Service configuration object passed to service initialization
|
|
50
|
+
*
|
|
51
|
+
* @typedef {Object} ServiceConfig
|
|
52
|
+
* @property {*} [key] - Service-specific configuration properties
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Options for creating a service instance
|
|
57
|
+
*
|
|
58
|
+
* @typedef {Object} ServiceOptions
|
|
59
|
+
* @property {string} [logLevel] - Initial log level for the service
|
|
60
|
+
* @property {number} [shutdownTimeout=5000] - Timeout for graceful shutdown
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Options for stopping a service
|
|
65
|
+
*
|
|
66
|
+
* @typedef {Object} StopOptions
|
|
67
|
+
* @property {number} [timeout] - Override shutdown timeout
|
|
68
|
+
* @property {boolean} [force=false] - Force stop even if timeout exceeded
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Health status returned by service health checks
|
|
73
|
+
*
|
|
74
|
+
* @typedef {Object} HealthStatus
|
|
75
|
+
* @property {string} name - Service name
|
|
76
|
+
* @property {string} state - Current service state
|
|
77
|
+
* @property {boolean} healthy - Whether the service is healthy
|
|
78
|
+
* @property {string} [error] - Error message if unhealthy
|
|
79
|
+
* @property {string} [checkError] - Error from health check itself
|
|
80
|
+
* @property {*} [key] - Additional health check properties
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @typedef {Object} StateChangeEvent
|
|
85
|
+
* @property {string} service - Service name (added by ServiceManager)
|
|
86
|
+
* @property {string} oldState - Previous state
|
|
87
|
+
* @property {string} newState - New state
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @typedef {Object} HealthChangeEvent
|
|
92
|
+
* @property {string} service - Service name (added by ServiceManager)
|
|
93
|
+
* @property {boolean} healthy - Current health status
|
|
94
|
+
* @property {boolean} [wasHealthy] - Previous health status
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Event emitted when service encounters an error
|
|
99
|
+
*
|
|
100
|
+
* @typedef {Object} ServiceErrorEvent
|
|
101
|
+
* @property {string} service - Service name
|
|
102
|
+
* @property {string} operation - Operation that failed
|
|
103
|
+
* @property {Error} error - Error that occurred
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Service class constructor type
|
|
108
|
+
*
|
|
109
|
+
* @typedef {new (name: string, options?: ServiceOptions) => ServiceInstance} ServiceConstructor
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Options for registering a service
|
|
114
|
+
*
|
|
115
|
+
* @typedef {Object} ServiceRegistrationOptions
|
|
116
|
+
* @property {string[]} [dependencies=[]] - Services this service depends on
|
|
117
|
+
* @property {string[]} [tags=[]] - Tags for grouping services
|
|
118
|
+
* @property {number} [priority=0] - Startup priority (higher starts first)
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Configuration for ServiceManager
|
|
123
|
+
*
|
|
124
|
+
* @typedef {Object} ServiceManagerConfig
|
|
125
|
+
* @property {boolean} [debug=false] - Debug mode switch
|
|
126
|
+
* @property {boolean} [autoStart=false] - Auto-start services on registration
|
|
127
|
+
* @property {number} [stopTimeout=10000] - Default timeout for stopping services
|
|
128
|
+
* @property {string} [logLevel] - Initial log level for ServiceManager
|
|
129
|
+
* @property {LogConfig} [logConfig={}] - Logging configuration
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Logging configuration
|
|
134
|
+
*
|
|
135
|
+
* @typedef {Object} LogConfig
|
|
136
|
+
* @property {string} [defaultLevel] - Default log level for services
|
|
137
|
+
* @property {string} [globalLevel] - Override level for all services
|
|
138
|
+
* @property {Object<string, string>} [serviceLevels] - Per-service log levels
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Internal service registry entry
|
|
143
|
+
*
|
|
144
|
+
* @typedef {Object} ServiceEntry
|
|
145
|
+
* @property {ServiceConstructor} ServiceClass - Service class constructor
|
|
146
|
+
* @property {ServiceInstance|null} instance - Service instance (lazy-created)
|
|
147
|
+
* @property {ServiceConfig} config - Service configuration
|
|
148
|
+
* @property {string[]} dependencies - Service dependencies
|
|
149
|
+
* @property {Set<string>} dependents - Services that depend on this one
|
|
150
|
+
* @property {string[]} tags - Service tags
|
|
151
|
+
* @property {number} priority - Startup priority
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Result of health check for all services
|
|
156
|
+
* @typedef {Object<string, HealthStatus>} HealthCheckResult
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Base class interface that services must implement
|
|
161
|
+
*
|
|
162
|
+
* @typedef {Object} ServiceInstance
|
|
163
|
+
* @property {string} name - Service name
|
|
164
|
+
* @property {string} state - Current state
|
|
165
|
+
* @property {boolean} healthy - Health status
|
|
166
|
+
* @property {Error|null} error - Last error
|
|
167
|
+
* @property {import('../logging').Logger} logger - Service logger
|
|
168
|
+
* @property {(config?: ServiceConfig) => Promise<boolean>} initialize
|
|
169
|
+
* @property {() => Promise<boolean>} start
|
|
170
|
+
* @property {(options?: StopOptions) => Promise<boolean>} stop
|
|
171
|
+
* @property {() => Promise<boolean>} recover
|
|
172
|
+
* @property {() => Promise<boolean>} destroy
|
|
173
|
+
* @property {() => Promise<HealthStatus>} getHealth
|
|
174
|
+
* @property {(level: string) => boolean} setLogLevel
|
|
175
|
+
* @property {(event: string, handler: Function) => Function} on
|
|
176
|
+
* @property {(event: string, data: any) => boolean} emit
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class that can be used to add a `SubscribersCount` store to classes
|
|
3
|
+
* or other objects
|
|
4
|
+
*/
|
|
5
|
+
export default class SubscribersCount {
|
|
6
|
+
/**
|
|
7
|
+
* Create a writable store with added 'subscribeCount' functionality
|
|
8
|
+
*/
|
|
9
|
+
static writable(...args: any[]): any;
|
|
10
|
+
/**
|
|
11
|
+
* Add subscriber count functionality to an existing store by wrapping
|
|
12
|
+
* the store with a Proxy
|
|
13
|
+
*
|
|
14
|
+
* @template T;
|
|
15
|
+
*
|
|
16
|
+
* @param {import('svelte/store').Writable<T>} store
|
|
17
|
+
*/
|
|
18
|
+
static wrap<T>(store: import("svelte/store").Writable<T>): any;
|
|
19
|
+
increment(): void;
|
|
20
|
+
decrement(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Subscribe to `SubscribersCount` store
|
|
23
|
+
*
|
|
24
|
+
* @param {(value:number)=>void} fn
|
|
25
|
+
*
|
|
26
|
+
* @returns {()=>void} unsubscribe
|
|
27
|
+
*/
|
|
28
|
+
subscribe(fn: (value: number) => void): () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Subscribe to `SubscribersCount` store and receive an update once if the
|
|
31
|
+
* count is zero.
|
|
32
|
+
*
|
|
33
|
+
* @param {(value:number)=>void} fn
|
|
34
|
+
*
|
|
35
|
+
* @returns {()=>void} unsubscribe
|
|
36
|
+
*/
|
|
37
|
+
onceEmpty(fn: (value: number) => void): () => void;
|
|
38
|
+
#private;
|
|
39
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { writable, get } from 'svelte/store';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Class that can be used to add a `SubscribersCount` store to classes
|
|
5
|
+
* or other objects
|
|
6
|
+
*/
|
|
7
|
+
export default class SubscribersCount {
|
|
8
|
+
#count;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
this.#count = writable(0);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
increment() {
|
|
15
|
+
this.#count.update((value) => value + 1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
decrement() {
|
|
19
|
+
this.#count.update((value) => value - 1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Subscribe to `SubscribersCount` store
|
|
24
|
+
*
|
|
25
|
+
* @param {(value:number)=>void} fn
|
|
26
|
+
*
|
|
27
|
+
* @returns {()=>void} unsubscribe
|
|
28
|
+
*/
|
|
29
|
+
subscribe(fn) {
|
|
30
|
+
return this.#count.subscribe(fn);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Subscribe to `SubscribersCount` store and receive an update once if the
|
|
35
|
+
* count is zero.
|
|
36
|
+
*
|
|
37
|
+
* @param {(value:number)=>void} fn
|
|
38
|
+
*
|
|
39
|
+
* @returns {()=>void} unsubscribe
|
|
40
|
+
*/
|
|
41
|
+
onceEmpty(fn) {
|
|
42
|
+
let unsubscribe = this.#count.subscribe((value) => {
|
|
43
|
+
if (value === 0) {
|
|
44
|
+
unsubscribe();
|
|
45
|
+
fn(value);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return unsubscribe;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create a writable store with added 'subscribeCount' functionality
|
|
54
|
+
*/
|
|
55
|
+
static writable() {
|
|
56
|
+
const store = writable(...arguments);
|
|
57
|
+
|
|
58
|
+
return SubscribersCount.wrap(store);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Add subscriber count functionality to an existing store by wrapping
|
|
63
|
+
* the store with a Proxy
|
|
64
|
+
*
|
|
65
|
+
* @template T;
|
|
66
|
+
*
|
|
67
|
+
* @param {import('svelte/store').Writable<T>} store
|
|
68
|
+
*/
|
|
69
|
+
static wrap(store) {
|
|
70
|
+
// expect.store( store );
|
|
71
|
+
|
|
72
|
+
const counter = new SubscribersCount();
|
|
73
|
+
|
|
74
|
+
const handler = {
|
|
75
|
+
/**
|
|
76
|
+
* @param {any} target
|
|
77
|
+
* @param {string} prop
|
|
78
|
+
*/
|
|
79
|
+
get(target, prop) {
|
|
80
|
+
switch (prop) {
|
|
81
|
+
case 'subscribe': {
|
|
82
|
+
return /* subscribe */ function () {
|
|
83
|
+
counter.increment();
|
|
84
|
+
const unsubscribe = target[prop](...arguments);
|
|
85
|
+
|
|
86
|
+
return /* unsubscribe */ () => {
|
|
87
|
+
counter.decrement();
|
|
88
|
+
unsubscribe();
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
case 'value':
|
|
94
|
+
return get(store);
|
|
95
|
+
|
|
96
|
+
case 'subscribersCount':
|
|
97
|
+
return counter;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return Reflect.get(target, prop);
|
|
101
|
+
// return target[prop];
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return new Proxy(store, handler);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SubscribersCount } from "./SubscribersCount.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SubscribersCount } from './SubscribersCount.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default class LogTransformStream extends TransformStream {
|
|
2
|
+
constructor() {
|
|
3
|
+
const transformer = {
|
|
4
|
+
/**
|
|
5
|
+
* Log the chunk and enqueue the unchanged chunk
|
|
6
|
+
*
|
|
7
|
+
* @param {any} chunk
|
|
8
|
+
* @param {any} controller
|
|
9
|
+
*/
|
|
10
|
+
transform: (chunk, controller) => {
|
|
11
|
+
console.log('log', chunk);
|
|
12
|
+
controller.enqueue(chunk);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
super(transformer);
|
|
17
|
+
}
|
|
18
|
+
start() {}
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default class ServerEventsStore {
|
|
2
|
+
/**
|
|
3
|
+
* @param {object} _
|
|
4
|
+
* @param {Zods.AbsOrRelUrl} _.url
|
|
5
|
+
*/
|
|
6
|
+
constructor({ url }: {
|
|
7
|
+
url: Zods.AbsOrRelUrl;
|
|
8
|
+
});
|
|
9
|
+
/** @type {SubscribersCount} */
|
|
10
|
+
subscribersCount: SubscribersCount;
|
|
11
|
+
/**
|
|
12
|
+
* Subscribe to Server Send Events
|
|
13
|
+
*
|
|
14
|
+
* @param {import("svelte/store").Subscriber<object|null>} fn
|
|
15
|
+
*
|
|
16
|
+
* @returns {()=>void} unsubscribe
|
|
17
|
+
*/
|
|
18
|
+
subscribe(fn: import("svelte/store").Subscriber<object | null>): () => void;
|
|
19
|
+
#private;
|
|
20
|
+
}
|
|
21
|
+
import SubscribersCount from '../stores/SubscribersCount.js';
|
|
22
|
+
import * as Zods from '../../zod/all.js';
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
|
4
|
+
import * as Zods from '../../zod/all.js';
|
|
5
|
+
|
|
6
|
+
import SubscribersCount from '../stores/SubscribersCount.js';
|
|
7
|
+
|
|
8
|
+
// > Class
|
|
9
|
+
|
|
10
|
+
export default class ServerEventsStore {
|
|
11
|
+
/** @type {Zods.AbsOrRelUrl} */
|
|
12
|
+
#url;
|
|
13
|
+
|
|
14
|
+
/** @type {import("svelte/store").Writable<object|null>} */
|
|
15
|
+
#store;
|
|
16
|
+
|
|
17
|
+
/** @type {boolean} */
|
|
18
|
+
#starting = false;
|
|
19
|
+
|
|
20
|
+
/** @type {ReadableStream<Uint8Array>|null} */
|
|
21
|
+
#stream = null;
|
|
22
|
+
|
|
23
|
+
/** @type {SubscribersCount} */
|
|
24
|
+
subscribersCount;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {object} _
|
|
28
|
+
* @param {Zods.AbsOrRelUrl} _.url
|
|
29
|
+
*/
|
|
30
|
+
constructor({ url }) {
|
|
31
|
+
this.#url = Zods.AbsOrRelUrl.parse(url);
|
|
32
|
+
|
|
33
|
+
this.#store = writable(null);
|
|
34
|
+
|
|
35
|
+
this.subscribersCount = new SubscribersCount();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Subscribe to Server Send Events
|
|
40
|
+
*
|
|
41
|
+
* @param {import("svelte/store").Subscriber<object|null>} fn
|
|
42
|
+
*
|
|
43
|
+
* @returns {()=>void} unsubscribe
|
|
44
|
+
*/
|
|
45
|
+
subscribe(fn) {
|
|
46
|
+
this.subscribersCount.increment();
|
|
47
|
+
|
|
48
|
+
const unsubscribe = this.#store?.subscribe(fn);
|
|
49
|
+
|
|
50
|
+
this.#tryStartStream();
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
this.subscribersCount.decrement();
|
|
54
|
+
unsubscribe?.();
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async #tryStartStream() {
|
|
59
|
+
if (this.#stream || this.#starting) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
this.#starting = true;
|
|
65
|
+
|
|
66
|
+
const aborter = new AbortController();
|
|
67
|
+
const signal = aborter.signal;
|
|
68
|
+
|
|
69
|
+
const response = await fetch(this.#url, { signal });
|
|
70
|
+
|
|
71
|
+
const stream = (this.#stream = response.body);
|
|
72
|
+
|
|
73
|
+
this.#starting = false;
|
|
74
|
+
|
|
75
|
+
const reader =
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
stream.pipeThrough(new TextDecoderStream()).getReader();
|
|
78
|
+
|
|
79
|
+
// const textDecoder = new TextDecoder('utf-8');
|
|
80
|
+
|
|
81
|
+
while (!signal.aborted) {
|
|
82
|
+
const { value, done } = await reader.read();
|
|
83
|
+
|
|
84
|
+
if (undefined === value) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const obj = JSON.parse(value);
|
|
89
|
+
// const obj = JSON.parse(textDecoder.decode(value));
|
|
90
|
+
|
|
91
|
+
if (!done) {
|
|
92
|
+
this.#store.set(obj);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// console.log({ ...obj, done });
|
|
96
|
+
|
|
97
|
+
if (done) {
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
} // end for
|
|
101
|
+
} catch (e) {
|
|
102
|
+
this.#starting = false;
|
|
103
|
+
this.#stream = null;
|
|
104
|
+
|
|
105
|
+
if (e instanceof Error && e.name !== 'AbortError') {
|
|
106
|
+
throw e;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default class TimestampSource {
|
|
2
|
+
/**
|
|
3
|
+
* Stream start function
|
|
4
|
+
*
|
|
5
|
+
* @param {ReadableStreamDefaultController} ctr
|
|
6
|
+
*/
|
|
7
|
+
start(ctr: ReadableStreamDefaultController): void;
|
|
8
|
+
/**
|
|
9
|
+
* Stop generation of new stream output
|
|
10
|
+
*/
|
|
11
|
+
cancel(): void;
|
|
12
|
+
#private;
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default class TimestampSource {
|
|
2
|
+
/** @type {number|NodeJS.Timeout|undefined} */
|
|
3
|
+
#interval;
|
|
4
|
+
|
|
5
|
+
constructor() {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Stream start function
|
|
9
|
+
*
|
|
10
|
+
* @param {ReadableStreamDefaultController} ctr
|
|
11
|
+
*/
|
|
12
|
+
start(ctr) {
|
|
13
|
+
ctr.enqueue(JSON.stringify({ now: Date.now() }));
|
|
14
|
+
|
|
15
|
+
this.#interval = setInterval(() => {
|
|
16
|
+
return ctr.enqueue(JSON.stringify({ now: Date.now() }));
|
|
17
|
+
}, 1000);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Stop generation of new stream output
|
|
22
|
+
*/
|
|
23
|
+
cancel() {
|
|
24
|
+
clearInterval(this.#interval);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AudioLoader instance
|
|
3
|
+
* - Loads audio data from network into an ArrayBuffer
|
|
4
|
+
* - Loaded data can be transferred to an AudioBufferSourceNode
|
|
5
|
+
*/
|
|
6
|
+
export default class AudioLoader extends NetworkLoader {
|
|
7
|
+
/**
|
|
8
|
+
* Get an AudioBufferSourceNode instance
|
|
9
|
+
*
|
|
10
|
+
* @note AudioBufferSourceNodes can play only once, a new source node
|
|
11
|
+
* must be created otherwise
|
|
12
|
+
*
|
|
13
|
+
* @param {AudioContext} audioContext
|
|
14
|
+
*
|
|
15
|
+
* @returns {Promise<AudioBufferSourceNode>}
|
|
16
|
+
*/
|
|
17
|
+
getAudioBufferSourceNode(audioContext: AudioContext): Promise<AudioBufferSourceNode>;
|
|
18
|
+
/**
|
|
19
|
+
* Gets data as AudioBuffer
|
|
20
|
+
* - Stores created AudioBuffer instance internally
|
|
21
|
+
* - Transfers data from internal ArrayBuffer, which will be detached
|
|
22
|
+
*
|
|
23
|
+
* @param {AudioContext} audioContext
|
|
24
|
+
*
|
|
25
|
+
* @returns {Promise<AudioBuffer>}
|
|
26
|
+
*/
|
|
27
|
+
getAudioBuffer(audioContext: AudioContext): Promise<AudioBuffer>;
|
|
28
|
+
#private;
|
|
29
|
+
}
|
|
30
|
+
import { NetworkLoader } from '../network-loader/index.js';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NetworkLoader,
|
|
3
|
+
ERROR_NOT_LOADED,
|
|
4
|
+
ERROR_TRANSFERRED
|
|
5
|
+
} from '../network-loader/index.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* AudioLoader instance
|
|
9
|
+
* - Loads audio data from network into an ArrayBuffer
|
|
10
|
+
* - Loaded data can be transferred to an AudioBufferSourceNode
|
|
11
|
+
*/
|
|
12
|
+
export default class AudioLoader extends NetworkLoader {
|
|
13
|
+
/** @type {AudioBuffer|null} */
|
|
14
|
+
#audioBuffer = null;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get an AudioBufferSourceNode instance
|
|
18
|
+
*
|
|
19
|
+
* @note AudioBufferSourceNodes can play only once, a new source node
|
|
20
|
+
* must be created otherwise
|
|
21
|
+
*
|
|
22
|
+
* @param {AudioContext} audioContext
|
|
23
|
+
*
|
|
24
|
+
* @returns {Promise<AudioBufferSourceNode>}
|
|
25
|
+
*/
|
|
26
|
+
async getAudioBufferSourceNode(audioContext) {
|
|
27
|
+
if (!this.#audioBuffer) {
|
|
28
|
+
this.#audioBuffer = await this.getAudioBuffer(audioContext);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return new AudioBufferSourceNode(audioContext, {
|
|
32
|
+
buffer: this.#audioBuffer
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Gets data as AudioBuffer
|
|
38
|
+
* - Stores created AudioBuffer instance internally
|
|
39
|
+
* - Transfers data from internal ArrayBuffer, which will be detached
|
|
40
|
+
*
|
|
41
|
+
* @param {AudioContext} audioContext
|
|
42
|
+
*
|
|
43
|
+
* @returns {Promise<AudioBuffer>}
|
|
44
|
+
*/
|
|
45
|
+
async getAudioBuffer(audioContext) {
|
|
46
|
+
if (!this._buffer) {
|
|
47
|
+
throw new Error(ERROR_NOT_LOADED);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (this._buffer.detached) {
|
|
51
|
+
throw new Error(ERROR_TRANSFERRED);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.#audioBuffer = await audioContext.decodeAudioData(this._buffer);
|
|
55
|
+
|
|
56
|
+
return this.#audioBuffer;
|
|
57
|
+
}
|
|
58
|
+
} // end class
|