@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,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a singleton instance
|
|
3
|
+
* - A class can be supplied to create the singleton instance from
|
|
4
|
+
* - The singleton is identified by a needle string
|
|
5
|
+
*
|
|
6
|
+
* @param {object} _
|
|
7
|
+
* @param {any} _.class
|
|
8
|
+
* @param {*[]} [_.args] - Constructor arguments
|
|
9
|
+
* @param {string} [_.needle]
|
|
10
|
+
* If not supplied, a needle will be constructed from the serialized
|
|
11
|
+
* constructor arguments (args).
|
|
12
|
+
*/
|
|
13
|
+
export function getInstance({ needle, class: Class, args }: {
|
|
14
|
+
class: any;
|
|
15
|
+
args?: any[];
|
|
16
|
+
needle?: string;
|
|
17
|
+
}): any;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a proxy that instantiates the singleton class upon it's first usage
|
|
20
|
+
*
|
|
21
|
+
* @template T
|
|
22
|
+
*
|
|
23
|
+
* @param {object} _
|
|
24
|
+
* @param {new() => T} _.class
|
|
25
|
+
* @param {*[]} [_.args] - Constructor arguments
|
|
26
|
+
*
|
|
27
|
+
* @returns {T & {init:()=>null}} proxy
|
|
28
|
+
*/
|
|
29
|
+
export function lazySingleton<T>({ class: Class, args }: {
|
|
30
|
+
class: new () => T;
|
|
31
|
+
args?: any[];
|
|
32
|
+
}): T & {
|
|
33
|
+
init: () => null;
|
|
34
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { expect } from '../index.js';
|
|
2
|
+
|
|
3
|
+
const instancesByNeedle = new Map();
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get a singleton instance
|
|
7
|
+
* - A class can be supplied to create the singleton instance from
|
|
8
|
+
* - The singleton is identified by a needle string
|
|
9
|
+
*
|
|
10
|
+
* @param {object} _
|
|
11
|
+
* @param {any} _.class
|
|
12
|
+
* @param {*[]} [_.args] - Constructor arguments
|
|
13
|
+
* @param {string} [_.needle]
|
|
14
|
+
* If not supplied, a needle will be constructed from the serialized
|
|
15
|
+
* constructor arguments (args).
|
|
16
|
+
*/
|
|
17
|
+
export function getInstance({ needle, class: Class, args }) {
|
|
18
|
+
expect.class(Class);
|
|
19
|
+
|
|
20
|
+
if (!needle) {
|
|
21
|
+
// Stringify instance arguments and use it as needle
|
|
22
|
+
needle = JSON.stringify(args === undefined ? null : args);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
expect.notEmptyString(needle);
|
|
26
|
+
|
|
27
|
+
const className = Class.constructor.name;
|
|
28
|
+
|
|
29
|
+
// console.log('getInstance()', { needle, args, className });
|
|
30
|
+
|
|
31
|
+
needle = `${className}:${needle}`;
|
|
32
|
+
|
|
33
|
+
let instance = instancesByNeedle.get(needle);
|
|
34
|
+
|
|
35
|
+
if (!instance) {
|
|
36
|
+
// console.log('Create new instance');
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
instance = new Class(...(args ?? []));
|
|
39
|
+
|
|
40
|
+
instancesByNeedle.set(needle, instance);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return instance;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Creates a proxy that instantiates the singleton class upon it's first usage
|
|
48
|
+
*
|
|
49
|
+
* @template T
|
|
50
|
+
*
|
|
51
|
+
* @param {object} _
|
|
52
|
+
* @param {new() => T} _.class
|
|
53
|
+
* @param {*[]} [_.args] - Constructor arguments
|
|
54
|
+
*
|
|
55
|
+
* @returns {T & {init:()=>null}} proxy
|
|
56
|
+
*/
|
|
57
|
+
export function lazySingleton({ class: Class, args }) {
|
|
58
|
+
/** @type {T} */
|
|
59
|
+
let singleton;
|
|
60
|
+
|
|
61
|
+
/** @type {T & {init:()=>null}} */
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
const proxy = new Proxy(
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
{},
|
|
66
|
+
{
|
|
67
|
+
/**
|
|
68
|
+
* @param {T} target
|
|
69
|
+
* @param {string} prop
|
|
70
|
+
*/
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
get(target, prop) {
|
|
73
|
+
// console.log('lazySingleton: get property', prop);
|
|
74
|
+
|
|
75
|
+
if (!singleton) {
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
singleton = new Class(...(args ?? []));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (prop === 'init') {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
if (prop in singleton) {
|
|
83
|
+
// The class has an init method itself, return a reference
|
|
84
|
+
return singleton[prop];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return () => null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
return singleton[prop];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
return proxy;
|
|
97
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a path string to an array path
|
|
3
|
+
* - The path string will be spit at the `pathSeparator` token
|
|
4
|
+
* - If the supplied path is already an array, the original array will
|
|
5
|
+
* be returned
|
|
6
|
+
*
|
|
7
|
+
* @param {string|string[]} path
|
|
8
|
+
* String or array path (e.g. "some.path.to")
|
|
9
|
+
*
|
|
10
|
+
* @param {string} [pathSeparator=PATH_SEPARATOR]
|
|
11
|
+
* A custom path separator to use instead of the default "."
|
|
12
|
+
*
|
|
13
|
+
* @returns {string} string path (e.g. "some.path.to")
|
|
14
|
+
*/
|
|
15
|
+
export function toStringPath(path: string | string[], pathSeparator?: string): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { PATH_SEPARATOR } from '../object/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convert a path string to an array path
|
|
5
|
+
* - The path string will be spit at the `pathSeparator` token
|
|
6
|
+
* - If the supplied path is already an array, the original array will
|
|
7
|
+
* be returned
|
|
8
|
+
*
|
|
9
|
+
* @param {string|string[]} path
|
|
10
|
+
* String or array path (e.g. "some.path.to")
|
|
11
|
+
*
|
|
12
|
+
* @param {string} [pathSeparator=PATH_SEPARATOR]
|
|
13
|
+
* A custom path separator to use instead of the default "."
|
|
14
|
+
*
|
|
15
|
+
* @returns {string} string path (e.g. "some.path.to")
|
|
16
|
+
*/
|
|
17
|
+
export function toStringPath(path, pathSeparator = PATH_SEPARATOR) {
|
|
18
|
+
if (Array.isArray(path)) {
|
|
19
|
+
return path.join(pathSeparator);
|
|
20
|
+
} else if (typeof path === 'string') {
|
|
21
|
+
// path is already a string
|
|
22
|
+
return path;
|
|
23
|
+
} else {
|
|
24
|
+
throw new Error(
|
|
25
|
+
'Missing or invalid parameter [path] (expected string or array)'
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// -----------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Make sure that the outputted path is an array path
|
|
34
|
+
* - The input value may be a array path
|
|
35
|
+
* - The input value may be a string path (no conversion needed)
|
|
36
|
+
*
|
|
37
|
+
* @param {string|string[]} path
|
|
38
|
+
*
|
|
39
|
+
* @returns {string[]} array path (list of strings)
|
|
40
|
+
*/
|
|
41
|
+
// export function fromPath( path )
|
|
42
|
+
// {
|
|
43
|
+
// if( typeof path === "string" )
|
|
44
|
+
// {
|
|
45
|
+
// return path;
|
|
46
|
+
// }
|
|
47
|
+
// else {
|
|
48
|
+
// expect.array( path,
|
|
49
|
+
// "Missing or invalid parameter [path] (expected string or string[])" );
|
|
50
|
+
|
|
51
|
+
// let strPath = proc.arrayToStringPathWeakMap.get( path );
|
|
52
|
+
|
|
53
|
+
// if( strPath )
|
|
54
|
+
// {
|
|
55
|
+
// // std.debug( "Using cached value", path );
|
|
56
|
+
// return strPath;
|
|
57
|
+
// }
|
|
58
|
+
|
|
59
|
+
// // Check array path
|
|
60
|
+
// for( let j = 0, n = path.length; j < n; j = j + 1 )
|
|
61
|
+
// {
|
|
62
|
+
// if( typeof path[j] !== "string" )
|
|
63
|
+
// {
|
|
64
|
+
// throw new Error("Invalid array path. Expected array of strings");
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
// strPath = path.join("/");
|
|
69
|
+
|
|
70
|
+
// proc.safeArrayPathsWeakMap.set( path, true );
|
|
71
|
+
// proc.arrayToStringPathWeakMap.set( path, strPath );
|
|
72
|
+
|
|
73
|
+
// return strPath;
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove strange characters from a string and replace whitespace by
|
|
3
|
+
* dashes.
|
|
4
|
+
*
|
|
5
|
+
* @returns {string} string that can be used as uri
|
|
6
|
+
*/
|
|
7
|
+
export function toUriName(str: any): string;
|
|
8
|
+
/**
|
|
9
|
+
* Captizalize the first character of a string
|
|
10
|
+
*
|
|
11
|
+
* @param {string} str - Input string
|
|
12
|
+
*
|
|
13
|
+
* @returns {string} string with first letter capitalized
|
|
14
|
+
*/
|
|
15
|
+
export function capitalizeFirst(str: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a kebab-case string to Title Case.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} kebabString - The kebab-case string to convert
|
|
20
|
+
* @return {string} The converted Title Case string
|
|
21
|
+
*/
|
|
22
|
+
export function kebabToTitleCase(kebabString: string): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as expect from '../expect/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Remove strange characters from a string and replace whitespace by
|
|
5
|
+
* dashes.
|
|
6
|
+
*
|
|
7
|
+
* @returns {string} string that can be used as uri
|
|
8
|
+
*/
|
|
9
|
+
export function toUriName(str) {
|
|
10
|
+
expect.string(str);
|
|
11
|
+
|
|
12
|
+
str = str.toLowerCase().replace(/[^a-z0-9]+/gi, '-');
|
|
13
|
+
|
|
14
|
+
// TODO: remove duplicate dashes
|
|
15
|
+
|
|
16
|
+
return str;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Captizalize the first character of a string
|
|
21
|
+
*
|
|
22
|
+
* @param {string} str - Input string
|
|
23
|
+
*
|
|
24
|
+
* @returns {string} string with first letter capitalized
|
|
25
|
+
*/
|
|
26
|
+
export function capitalizeFirst(str) {
|
|
27
|
+
if (!str.length) {
|
|
28
|
+
return str;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Converts a kebab-case string to Title Case.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} kebabString - The kebab-case string to convert
|
|
38
|
+
* @return {string} The converted Title Case string
|
|
39
|
+
*/
|
|
40
|
+
export function kebabToTitleCase(kebabString) {
|
|
41
|
+
// Check if input is a string
|
|
42
|
+
if (typeof kebabString !== 'string') {
|
|
43
|
+
throw new Error('Input must be a string');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Split the string by hyphens
|
|
47
|
+
return kebabString
|
|
48
|
+
.split('-')
|
|
49
|
+
.map((word) => {
|
|
50
|
+
// Capitalize the first letter of each word
|
|
51
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
52
|
+
})
|
|
53
|
+
.join(' ');
|
|
54
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path utilities for working with file and directory paths.
|
|
3
|
+
* Provides functions similar to Node.js path module but for browser and SvelteKit use.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Extracts the filename from a path, with or without extension.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} path - The path to extract the filename from
|
|
9
|
+
* @param {boolean} [includeExtension=true] - Whether to include the extension
|
|
10
|
+
* @return {string} The extracted filename
|
|
11
|
+
*/
|
|
12
|
+
export function basename(path: string, includeExtension?: boolean): string;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the extension from a filename.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} path - The path to extract the extension from
|
|
17
|
+
* @param {boolean} [includeDot=false] - Whether to include the dot in the extension
|
|
18
|
+
* @return {string} The extracted extension
|
|
19
|
+
*/
|
|
20
|
+
export function extname(path: string, includeDot?: boolean): string;
|
|
21
|
+
/**
|
|
22
|
+
* Extracts the directory name from a path.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} path - The path to extract the directory name from
|
|
25
|
+
* @return {string} The extracted directory name
|
|
26
|
+
*/
|
|
27
|
+
export function dirname(path: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Joins path segments with the appropriate separator.
|
|
30
|
+
*
|
|
31
|
+
* @param {...string} paths - The path segments to join
|
|
32
|
+
* @return {string} The joined path
|
|
33
|
+
*/
|
|
34
|
+
export function join(...paths: string[]): string;
|
|
35
|
+
/**
|
|
36
|
+
* Normalizes a path by resolving '..' and '.' segments.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} path - The path to normalize
|
|
39
|
+
* @return {string} The normalized path
|
|
40
|
+
*/
|
|
41
|
+
export function normalize(path: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Checks if a path is absolute.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} path - The path to check
|
|
46
|
+
* @return {boolean} Whether the path is absolute
|
|
47
|
+
*/
|
|
48
|
+
export function isAbsolute(path: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the path segments as an array.
|
|
51
|
+
*
|
|
52
|
+
* @param {string} path - The path to split
|
|
53
|
+
* @return {string[]} The path segments
|
|
54
|
+
*/
|
|
55
|
+
export function segments(path: string): string[];
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path utilities for working with file and directory paths.
|
|
3
|
+
* Provides functions similar to Node.js path module but for browser and SvelteKit use.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extracts the filename from a path, with or without extension.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} path - The path to extract the filename from
|
|
10
|
+
* @param {boolean} [includeExtension=true] - Whether to include the extension
|
|
11
|
+
* @return {string} The extracted filename
|
|
12
|
+
*/
|
|
13
|
+
export function basename(path, includeExtension = true) {
|
|
14
|
+
if (typeof path !== 'string') {
|
|
15
|
+
throw new Error('Path must be a string');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Handle empty string
|
|
19
|
+
if (path === '') {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Remove trailing slashes
|
|
24
|
+
path = path.replace(/\/+$/, '');
|
|
25
|
+
|
|
26
|
+
// Find the last occurrence of '/'
|
|
27
|
+
const lastSlashIndex = path.lastIndexOf('/');
|
|
28
|
+
|
|
29
|
+
// Get the full filename
|
|
30
|
+
const filename =
|
|
31
|
+
lastSlashIndex === -1 ? path : path.substring(lastSlashIndex + 1);
|
|
32
|
+
|
|
33
|
+
// Return the full filename if extension should be included
|
|
34
|
+
if (includeExtension) {
|
|
35
|
+
return filename;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Otherwise, remove the extension
|
|
39
|
+
const lastDotIndex = filename.lastIndexOf('.');
|
|
40
|
+
|
|
41
|
+
// If no dot is found or dot is the first character (hidden file), return the filename
|
|
42
|
+
if (lastDotIndex <= 0) {
|
|
43
|
+
return filename;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Return everything before the last dot
|
|
47
|
+
return filename.substring(0, lastDotIndex);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Extracts the extension from a filename.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} path - The path to extract the extension from
|
|
54
|
+
* @param {boolean} [includeDot=false] - Whether to include the dot in the extension
|
|
55
|
+
* @return {string} The extracted extension
|
|
56
|
+
*/
|
|
57
|
+
export function extname(path, includeDot = false) {
|
|
58
|
+
if (typeof path !== 'string') {
|
|
59
|
+
throw new Error('Path must be a string');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const filename = basename(path);
|
|
63
|
+
const lastDotIndex = filename.lastIndexOf('.');
|
|
64
|
+
|
|
65
|
+
// If no dot is found or dot is the first character (hidden file), return empty string
|
|
66
|
+
if (lastDotIndex <= 0) {
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Return the extension with or without the dot
|
|
71
|
+
return includeDot
|
|
72
|
+
? filename.substring(lastDotIndex)
|
|
73
|
+
: filename.substring(lastDotIndex + 1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Extracts the directory name from a path.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} path - The path to extract the directory name from
|
|
80
|
+
* @return {string} The extracted directory name
|
|
81
|
+
*/
|
|
82
|
+
export function dirname(path) {
|
|
83
|
+
if (typeof path !== 'string') {
|
|
84
|
+
throw new Error('Path must be a string');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Handle empty string
|
|
88
|
+
if (path === '') {
|
|
89
|
+
return '.';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Remove trailing slashes
|
|
93
|
+
path = path.replace(/\/+$/, '');
|
|
94
|
+
|
|
95
|
+
// Find the last occurrence of '/'
|
|
96
|
+
const lastSlashIndex = path.lastIndexOf('/');
|
|
97
|
+
|
|
98
|
+
// If no slash is found, return '.'
|
|
99
|
+
if (lastSlashIndex === -1) {
|
|
100
|
+
return '.';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// If slash is at the beginning, return '/'
|
|
104
|
+
if (lastSlashIndex === 0) {
|
|
105
|
+
return '/';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Return everything before the last slash
|
|
109
|
+
return path.substring(0, lastSlashIndex);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Joins path segments with the appropriate separator.
|
|
114
|
+
*
|
|
115
|
+
* @param {...string} paths - The path segments to join
|
|
116
|
+
* @return {string} The joined path
|
|
117
|
+
*/
|
|
118
|
+
export function join(...paths) {
|
|
119
|
+
if (paths.length === 0) {
|
|
120
|
+
return '.';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return paths
|
|
124
|
+
.filter((segment) => typeof segment === 'string' && segment !== '')
|
|
125
|
+
.join('/')
|
|
126
|
+
.replace(/\/+/g, '/'); // Replace multiple consecutive slashes with a single one
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Normalizes a path by resolving '..' and '.' segments.
|
|
131
|
+
*
|
|
132
|
+
* @param {string} path - The path to normalize
|
|
133
|
+
* @return {string} The normalized path
|
|
134
|
+
*/
|
|
135
|
+
export function normalize(path) {
|
|
136
|
+
if (typeof path !== 'string') {
|
|
137
|
+
throw new Error('Path must be a string');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Replace backslashes with forward slashes
|
|
141
|
+
path = path.replace(/\\/g, '/');
|
|
142
|
+
|
|
143
|
+
// Handle empty string
|
|
144
|
+
if (path === '') {
|
|
145
|
+
return '.';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const isAbsolute = path.startsWith('/');
|
|
149
|
+
const trailingSlash = path.endsWith('/');
|
|
150
|
+
|
|
151
|
+
// Split path into segments
|
|
152
|
+
const segments = path.split('/').filter(Boolean);
|
|
153
|
+
const resultSegments = [];
|
|
154
|
+
|
|
155
|
+
for (const segment of segments) {
|
|
156
|
+
if (segment === '.') {
|
|
157
|
+
// Ignore current directory marker
|
|
158
|
+
continue;
|
|
159
|
+
} else if (segment === '..') {
|
|
160
|
+
// Go up one directory
|
|
161
|
+
if (
|
|
162
|
+
resultSegments.length > 0 &&
|
|
163
|
+
resultSegments[resultSegments.length - 1] !== '..'
|
|
164
|
+
) {
|
|
165
|
+
resultSegments.pop();
|
|
166
|
+
} else if (!isAbsolute) {
|
|
167
|
+
resultSegments.push('..');
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
// Add segment to result
|
|
171
|
+
resultSegments.push(segment);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Handle empty result
|
|
176
|
+
if (resultSegments.length === 0) {
|
|
177
|
+
return isAbsolute ? '/' : '.';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Join segments
|
|
181
|
+
let result = resultSegments.join('/');
|
|
182
|
+
|
|
183
|
+
// Add leading slash for absolute paths
|
|
184
|
+
if (isAbsolute) {
|
|
185
|
+
result = '/' + result;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Add trailing slash if original path had one
|
|
189
|
+
if (trailingSlash && !result.endsWith('/')) {
|
|
190
|
+
result += '/';
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Checks if a path is absolute.
|
|
198
|
+
*
|
|
199
|
+
* @param {string} path - The path to check
|
|
200
|
+
* @return {boolean} Whether the path is absolute
|
|
201
|
+
*/
|
|
202
|
+
export function isAbsolute(path) {
|
|
203
|
+
if (typeof path !== 'string') {
|
|
204
|
+
throw new Error('Path must be a string');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return path.startsWith('/');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Returns the path segments as an array.
|
|
212
|
+
*
|
|
213
|
+
* @param {string} path - The path to split
|
|
214
|
+
* @return {string[]} The path segments
|
|
215
|
+
*/
|
|
216
|
+
export function segments(path) {
|
|
217
|
+
if (typeof path !== 'string') {
|
|
218
|
+
throw new Error('Path must be a string');
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Normalize path first
|
|
222
|
+
const normalizedPath = normalize(path);
|
|
223
|
+
|
|
224
|
+
// Split path into segments
|
|
225
|
+
return normalizedPath.split('/').filter(Boolean);
|
|
226
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interpolate: substitute variables in a string
|
|
3
|
+
*
|
|
4
|
+
* - Uses mustache template style expression substitution:
|
|
5
|
+
* Variables and expressions are surrounded by {{...}}
|
|
6
|
+
*
|
|
7
|
+
* TODO: full mustache support, see https://github.com/janl/mustache.js
|
|
8
|
+
*
|
|
9
|
+
* --
|
|
10
|
+
*
|
|
11
|
+
* @eg const template = `Hello {{name}}`;
|
|
12
|
+
*
|
|
13
|
+
* --
|
|
14
|
+
*
|
|
15
|
+
* @param {string} template - Template string to interpolate
|
|
16
|
+
* @param {object} templateData - Template data to use for interpolation
|
|
17
|
+
*
|
|
18
|
+
* @returns {string} interpolated string
|
|
19
|
+
*/
|
|
20
|
+
export function interpolate(template: string, templateData: object, expressionRegexp?: RegExp): string;
|
|
21
|
+
export const RE_JS_EXPRESSION: RegExp;
|
|
22
|
+
export const RE_MUSTACHE: RegExp;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as expect from '../expect/index.js';
|
|
2
|
+
|
|
3
|
+
import { toArrayPath } from '../array/index.js';
|
|
4
|
+
|
|
5
|
+
import { objectGet, PATH_SEPARATOR } from '../object/index.js';
|
|
6
|
+
|
|
7
|
+
export const RE_JS_EXPRESSION = /\$\{([^${}]*)\}/g;
|
|
8
|
+
export const RE_MUSTACHE = /\{\{([^{}]*)\}\}/g;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Interpolate: substitute variables in a string
|
|
12
|
+
*
|
|
13
|
+
* - Uses mustache template style expression substitution:
|
|
14
|
+
* Variables and expressions are surrounded by {{...}}
|
|
15
|
+
*
|
|
16
|
+
* TODO: full mustache support, see https://github.com/janl/mustache.js
|
|
17
|
+
*
|
|
18
|
+
* --
|
|
19
|
+
*
|
|
20
|
+
* @eg const template = `Hello {{name}}`;
|
|
21
|
+
*
|
|
22
|
+
* --
|
|
23
|
+
*
|
|
24
|
+
* @param {string} template - Template string to interpolate
|
|
25
|
+
* @param {object} templateData - Template data to use for interpolation
|
|
26
|
+
*
|
|
27
|
+
* @returns {string} interpolated string
|
|
28
|
+
*/
|
|
29
|
+
export function interpolate(
|
|
30
|
+
template,
|
|
31
|
+
templateData,
|
|
32
|
+
expressionRegexp = RE_MUSTACHE
|
|
33
|
+
) {
|
|
34
|
+
expect.string(template);
|
|
35
|
+
|
|
36
|
+
expect.object(templateData);
|
|
37
|
+
|
|
38
|
+
return template.replace(
|
|
39
|
+
expressionRegexp,
|
|
40
|
+
|
|
41
|
+
(match, expression) => {
|
|
42
|
+
const path = toArrayPath(expression);
|
|
43
|
+
|
|
44
|
+
/** @type {string} */
|
|
45
|
+
const replacement = objectGet(templateData, path, undefined);
|
|
46
|
+
|
|
47
|
+
if (
|
|
48
|
+
typeof replacement !== 'string' &&
|
|
49
|
+
typeof replacement !== 'number' &&
|
|
50
|
+
typeof replacement !== 'boolean'
|
|
51
|
+
) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
'Failed to interpolate template: Missing or invalid value for ' +
|
|
54
|
+
`expression [${expression}] (expected string, number or boolean)`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return replacement;
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|