@hkdigital/lib-core 0.3.14 → 0.4.3
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 +18 -9
- package/dist/auth/errors.d.ts +1 -0
- package/dist/auth/errors.js +1 -0
- package/dist/{states → browser/navigation}/navigation.svelte.js +1 -1
- package/dist/browser/navigation.d.ts +1 -0
- package/dist/browser/navigation.js +1 -0
- package/dist/config/README.md +5 -5
- package/dist/config/generators/imagetools.d.ts +2 -0
- package/dist/config/generators/imagetools.js +23 -10
- package/dist/config/generators/vite.js +1 -1
- package/dist/config/imagetools.d.ts +5 -5
- package/dist/config/typedef.d.ts +11 -0
- package/dist/config/typedef.js +17 -0
- package/dist/design/README.md +211 -66
- package/dist/design/config/{design-config.d.ts → design-tokens.d.ts} +23 -10
- package/dist/design/config/design-tokens.js +107 -0
- package/dist/design/generators/index.d.ts +51 -0
- package/dist/design/generators/index.js +124 -0
- package/dist/design/index.d.ts +3 -4
- package/dist/design/index.js +24 -41
- package/dist/design/plugins/skeleton.d.ts +4 -2
- package/dist/design/plugins/skeleton.js +3 -2
- package/dist/design/themes/hkdev/components/buttons/button-text.css +38 -25
- package/dist/design/themes/hkdev/theme-ext.js +1 -1
- package/dist/design/utils/clamp.js +1 -1
- package/dist/design/utils/root-vars.d.ts +50 -39
- package/dist/design/utils/root-vars.js +127 -29
- package/dist/{classes/data → generic/data/classes}/IterableTree.js +2 -2
- package/dist/{classes/data → generic/data/classes}/Selector.js +1 -1
- package/dist/generic/data/classes/typedef.d.ts +24 -0
- package/dist/generic/data/classes/typedef.js +14 -0
- package/dist/generic/data.d.ts +2 -0
- package/dist/generic/data.js +2 -0
- package/dist/generic/errors.d.ts +2 -0
- package/dist/generic/errors.js +2 -0
- package/dist/generic/events.d.ts +1 -0
- package/dist/generic/events.js +1 -0
- package/dist/{classes/promise → generic/promises/classes}/HkPromise.d.ts +17 -7
- package/dist/{classes/promise → generic/promises/classes}/HkPromise.js +20 -10
- package/dist/generic/promises.d.ts +1 -0
- package/dist/generic/promises.js +1 -0
- package/dist/{classes/streams → generic/streaming/classes}/ServerEventsStore.d.ts +1 -1
- package/dist/{classes/streams → generic/streaming/classes}/ServerEventsStore.js +2 -2
- package/dist/generic/streaming.d.ts +3 -0
- package/dist/generic/streaming.js +3 -0
- package/dist/generic/typedef.d.ts +1 -0
- package/dist/generic/typedef.js +1 -0
- package/dist/index.js +1 -0
- package/dist/logging/errors.d.ts +7 -0
- package/dist/logging/errors.js +11 -0
- package/dist/logging/index.d.ts +2 -3
- package/dist/logging/index.js +3 -4
- package/dist/logging/internal/adapters/console.d.ts +1 -16
- package/dist/logging/internal/adapters/console.js +322 -14
- package/dist/logging/internal/adapters/formatting.d.ts +69 -0
- package/dist/logging/internal/adapters/formatting.js +395 -0
- package/dist/logging/internal/adapters/pino.js +128 -27
- package/dist/logging/internal/adapters/typedef.d.ts +30 -0
- package/dist/logging/internal/adapters/typedef.js +11 -0
- package/dist/logging/internal/factories/client.js +1 -1
- package/dist/logging/internal/factories/server.js +12 -2
- package/dist/logging/internal/logger/Logger.d.ts +9 -7
- package/dist/logging/internal/logger/Logger.js +44 -9
- package/dist/logging/internal/test-errors.d.ts +35 -0
- package/dist/logging/internal/test-errors.js +137 -0
- package/dist/network/cache/IndexedDbCache.d.ts +1 -1
- package/dist/network/cache/MemoryResponseCache.d.ts +5 -0
- package/dist/network/cache/MemoryResponseCache.js +5 -2
- package/dist/network/errors.d.ts +2 -0
- package/dist/network/errors.js +2 -0
- package/dist/network/http/caching.js +1 -1
- package/dist/network/http/errors.d.ts +2 -2
- package/dist/network/http/errors.js +5 -13
- package/dist/network/http/http-request.js +1 -1
- package/dist/network/http/json-request.js +1 -1
- package/dist/network/http/response.js +1 -1
- package/dist/network/http/url.js +1 -1
- package/dist/network/loaders/README.md +14 -7
- package/dist/network/loaders/audio/AudioScene.svelte.js +3 -2
- package/dist/network/loaders/image/ImageLoader.svelte.d.ts +2 -2
- package/dist/network/loaders/image/ImageLoader.svelte.js +1 -1
- package/dist/network/loaders/image/ImageScene.svelte.d.ts +2 -2
- package/dist/network/loaders/image/ImageScene.svelte.js +9 -8
- package/dist/network/loaders/image/ImageVariantsLoader.svelte.d.ts +5 -5
- package/dist/network/loaders/image/ImageVariantsLoader.svelte.js +14 -13
- package/dist/network/loaders/image/utils/index.d.ts +2 -2
- package/dist/network/loaders/image/utils/index.js +9 -12
- package/dist/network/loaders/typedef.d.ts +0 -9
- package/dist/network/loaders/typedef.js +0 -12
- package/dist/network/states/NetworkLoader.svelte.d.ts +1 -1
- package/dist/network/states/NetworkLoader.svelte.js +3 -2
- package/dist/services/index.d.ts +0 -2
- package/dist/services/index.js +0 -3
- package/dist/services/service-base/ServiceBase.d.ts +2 -2
- package/dist/services/service-base/ServiceBase.js +15 -11
- package/dist/services/service-base/typedef.d.ts +2 -31
- package/dist/services/service-base/typedef.js +3 -2
- package/dist/services/service-manager/ServiceManager.d.ts +3 -3
- package/dist/services/service-manager/ServiceManager.js +2 -2
- package/dist/services/service-manager/typedef.d.ts +3 -3
- package/dist/services/service-manager/typedef.js +3 -3
- package/dist/services/typedef.d.ts +2 -0
- package/dist/services/typedef.js +2 -0
- package/dist/{classes/svelte → state/classes}/loading-state-machine/LoadingStateMachine.svelte.d.ts +1 -1
- package/dist/{classes/svelte → state/classes}/loading-state-machine/LoadingStateMachine.svelte.js +1 -1
- package/dist/state/classes/subscribers-count/index.d.ts +1 -0
- package/dist/state/classes/subscribers-count/index.js +1 -0
- package/dist/state/classes.d.ts +3 -0
- package/dist/state/classes.js +3 -0
- package/dist/{util/svelte/state-context/index.d.ts → state/context/state-context.d.ts} +1 -1
- package/dist/{util/svelte/state-context/index.js → state/context/state-context.js} +4 -4
- package/dist/state/context.d.ts +1 -0
- package/dist/state/context.js +1 -0
- package/dist/state/stores.d.ts +1 -0
- package/dist/state/stores.js +1 -0
- package/dist/ui/README.md +49 -0
- package/dist/ui/components/button-group/index.d.ts +1 -0
- package/dist/ui/components/button-group/index.js +1 -0
- package/dist/ui/{primitives → components}/drag-drop/DragDropContext.svelte +1 -1
- package/dist/ui/{primitives → components}/drag-drop/DragDropContext.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/drag-drop/Draggable.svelte +2 -2
- package/dist/ui/{primitives → components}/drag-drop/Draggable.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/drag-drop/DropZone.svelte +4 -4
- package/dist/ui/{primitives → components}/drag-drop/DropZone.svelte.d.ts +3 -3
- package/dist/ui/{primitives → components}/drag-drop/DropZoneArea.svelte +3 -3
- package/dist/ui/{primitives → components}/drag-drop/DropZoneArea.svelte.d.ts +4 -4
- package/dist/ui/{primitives → components}/drag-drop/DropZoneList.svelte +3 -3
- package/dist/ui/{primitives → components}/drag-drop/DropZoneList.svelte.d.ts +3 -3
- package/dist/ui/{primitives → components}/drag-drop/drag-state.svelte.d.ts +11 -11
- package/dist/ui/{primitives → components}/drag-drop/drag-state.svelte.js +5 -5
- package/dist/ui/components/drag-drop/typedef.d.ts +2 -0
- package/dist/ui/components/drag-drop/typedef.js +2 -0
- package/dist/ui/components/game-box/GameBox.svelte +1 -1
- package/dist/ui/components/game-box/index.d.ts +1 -0
- package/dist/ui/components/game-box/index.js +1 -0
- package/dist/ui/components/grid-layers/index.d.ts +1 -0
- package/dist/ui/components/grid-layers/index.js +1 -0
- package/dist/ui/{primitives/layout → components}/grid-layers/util.js +1 -1
- package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.d.ts +3 -3
- package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.js +3 -4
- package/dist/ui/components/hk-app-layout/index.d.ts +1 -0
- package/dist/ui/components/hk-app-layout/index.js +1 -0
- package/dist/ui/components/image-box/ImageBox.svelte +2 -2
- package/dist/ui/components/image-box/ImageBox.svelte.d.ts +3 -3
- package/dist/ui/components/image-box/index.d.ts +1 -1
- package/dist/ui/components/presenter/ImageSlide.svelte +1 -1
- package/dist/ui/components/presenter/ImageSlide.svelte.d.ts +2 -2
- package/dist/ui/components/presenter/Presenter.state.svelte.d.ts +3 -3
- package/dist/ui/components/presenter/Presenter.state.svelte.js +1 -1
- package/dist/ui/components/presenter/Presenter.svelte +1 -1
- package/dist/ui/components/presenter/Presenter.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/rows/panel-grid-row/PanelGridRow.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/rows/panel-row-2/PanelRow2.svelte.d.ts +1 -1
- package/dist/ui/{primitives → components}/tab-bar/HkTabBar.state.svelte.d.ts +3 -3
- package/dist/ui/{primitives → components}/tab-bar/HkTabBar.state.svelte.js +4 -2
- package/dist/ui/{primitives → components}/tab-bar/HkTabBar.svelte +2 -2
- package/dist/ui/{primitives → components}/tab-bar/HkTabBar.svelte.d.ts +2 -2
- package/dist/ui/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +19 -0
- package/dist/ui/{primitives → components}/tab-bar/HkTabBarSelector.state.svelte.js +2 -2
- package/dist/ui/{primitives → components}/tab-bar/HkTabBarSelector.svelte +1 -1
- package/dist/ui/{primitives → components}/tab-bar/HkTabBarSelector.svelte.d.ts +2 -2
- package/dist/ui/{primitives → components}/tab-bar/typedef.d.ts +1 -1
- package/dist/ui/{primitives → components}/tab-bar/typedef.js +1 -1
- package/dist/ui/components/typedef.d.ts +5 -0
- package/dist/ui/components/typedef.js +5 -0
- package/dist/ui/components/virtual-viewport/index.d.ts +1 -0
- package/dist/ui/components/virtual-viewport/index.js +1 -0
- package/dist/ui/components.d.ts +11 -0
- package/dist/ui/components.js +11 -0
- package/dist/ui/{primitives/hkdev → dev}/blocks/TextBlock.svelte +1 -1
- package/dist/ui/{primitives/debug → dev}/debug-panel-design-scaling/DebugPanelDesignScaling.svelte +8 -8
- package/dist/ui/dev.d.ts +3 -0
- package/dist/ui/dev.js +3 -0
- package/dist/ui/primitives/buttons/button/Button.svelte.d.ts +1 -1
- package/dist/ui/primitives/buttons/button-text/TextButton.svelte +1 -1
- package/dist/ui/primitives/typedef.d.ts +1 -0
- package/dist/ui/primitives/typedef.js +1 -0
- package/dist/ui/primitives.d.ts +5 -0
- package/dist/ui/primitives.js +5 -0
- package/dist/ui/typedef.d.ts +2 -0
- package/dist/ui/typedef.js +2 -0
- package/dist/util/array/index.js +1 -1
- package/dist/util/bases/base58.d.ts +3 -3
- package/dist/util/bases/base58.js +3 -3
- package/dist/util/compare/index.d.ts +4 -5
- package/dist/util/compare/index.js +3 -4
- package/dist/util/exceptions/index.js +1 -1
- package/dist/util/expect/arrays.d.ts +11 -11
- package/dist/util/expect/arrays.js +14 -6
- package/dist/util/expect/index.js +2 -2
- package/dist/util/expect/primitives.d.ts +6 -5
- package/dist/util/expect/primitives.js +15 -5
- package/dist/util/expect/url.d.ts +6 -5
- package/dist/util/expect/url.js +15 -5
- package/dist/util/function/index.d.ts +1 -14
- package/dist/util/index.d.ts +5 -0
- package/dist/util/index.js +13 -0
- package/dist/util/is/index.d.ts +3 -2
- package/dist/util/is/index.js +2 -1
- package/dist/util/iterate/index.d.ts +6 -8
- package/dist/util/iterate/index.js +5 -5
- package/dist/util/object/index.d.ts +1 -2
- package/dist/util/object/index.js +2 -3
- package/dist/util/ssr/index.d.ts +16 -0
- package/dist/util/ssr/index.js +44 -0
- package/dist/util/svelte/index.d.ts +1 -1
- package/dist/util/svelte/index.js +1 -1
- package/dist/util/time/index.d.ts +2 -2
- package/dist/util/time/index.js +1 -1
- package/dist/valibot/index.d.ts +1 -1
- package/dist/valibot/index.js +27 -1
- package/package.json +4 -4
- 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 +0 -17
- package/dist/assets/autospuiten/car-paint-picker.js +0 -41
- package/dist/assets/autospuiten/labels.d.ts +0 -7
- package/dist/assets/autospuiten/labels.js +0 -7
- package/dist/classes/data/index.d.ts +0 -2
- package/dist/classes/data/index.js +0 -2
- package/dist/classes/event-emitter/index.d.ts +0 -1
- package/dist/classes/event-emitter/index.js +0 -2
- package/dist/classes/index.d.ts +0 -4
- package/dist/classes/index.js +0 -4
- package/dist/classes/promise/index.d.ts +0 -1
- package/dist/classes/promise/index.js +0 -1
- package/dist/classes/stores/index.d.ts +0 -1
- package/dist/classes/stores/index.js +0 -1
- package/dist/classes/streams/index.d.ts +0 -3
- package/dist/classes/streams/index.js +0 -3
- package/dist/classes/svelte/index.d.ts +0 -1
- package/dist/classes/svelte/index.js +0 -1
- package/dist/design/config/design-config.js +0 -73
- package/dist/design/tailwind-theme-extend.d.ts +0 -23
- package/dist/design/tailwind-theme-extend.js +0 -158
- package/dist/errors/index.d.ts +0 -5
- package/dist/errors/index.js +0 -5
- package/dist/logging/internal/factories/universal.d.ts +0 -9
- package/dist/logging/internal/factories/universal.js +0 -22
- package/dist/services/service-base/index.d.ts +0 -3
- package/dist/services/service-base/index.js +0 -3
- package/dist/states/index.d.ts +0 -1
- package/dist/states/index.js +0 -1
- package/dist/stores/index.d.ts +0 -1
- package/dist/stores/index.js +0 -1
- package/dist/typedef/index.d.ts +0 -4
- package/dist/typedef/index.js +0 -4
- package/dist/ui/primitives/debug/index.d.ts +0 -1
- package/dist/ui/primitives/debug/index.js +0 -1
- package/dist/ui/primitives/index.d.ts +0 -0
- package/dist/ui/primitives/index.js +0 -2
- package/dist/ui/primitives/layout/grid-layers/GridLayers.svelte__heightFrom__ +0 -372
- package/dist/ui/primitives/layout/index.d.ts +0 -1
- package/dist/ui/primitives/layout/index.js +0 -1
- package/dist/ui/primitives/tab-bar/HkTabBarSelector.state.svelte.d.ts +0 -19
- /package/dist/{errors → auth/errors}/jwt.d.ts +0 -0
- /package/dist/{errors → auth/errors}/jwt.js +0 -0
- /package/dist/{states → browser/navigation}/navigation.svelte.d.ts +0 -0
- /package/dist/{classes/data → generic/data/classes}/IterableTree.d.ts +0 -0
- /package/dist/{classes/data → generic/data/classes}/Selector.d.ts +0 -0
- /package/dist/{classes → generic}/data/typedef.d.ts +0 -0
- /package/dist/{classes → generic}/data/typedef.js +0 -0
- /package/dist/{errors → generic/errors}/generic.d.ts +0 -0
- /package/dist/{errors → generic/errors}/generic.js +0 -0
- /package/dist/{errors → generic/errors}/promise.d.ts +0 -0
- /package/dist/{errors → generic/errors}/promise.js +0 -0
- /package/dist/{classes/event-emitter → generic/events/classes}/EventEmitter.d.ts +0 -0
- /package/dist/{classes/event-emitter → generic/events/classes}/EventEmitter.js +0 -0
- /package/dist/{classes/streams → generic/streaming/classes}/LogTransformStream.d.ts +0 -0
- /package/dist/{classes/streams → generic/streaming/classes}/LogTransformStream.js +0 -0
- /package/dist/{classes/streams → generic/streaming/classes}/TimeStampSource.d.ts +0 -0
- /package/dist/{classes/streams → generic/streaming/classes}/TimeStampSource.js +0 -0
- /package/dist/logging/{internal/constants.d.ts → constants.d.ts} +0 -0
- /package/dist/logging/{internal/constants.js → constants.js} +0 -0
- /package/dist/logging/{internal/typedef.d.ts → typedef.d.ts} +0 -0
- /package/dist/logging/{internal/typedef.js → typedef.js} +0 -0
- /package/dist/{errors → network/errors}/api.d.ts +0 -0
- /package/dist/{errors → network/errors}/api.js +0 -0
- /package/dist/{errors → network/errors}/http.d.ts +0 -0
- /package/dist/{errors → network/errors}/http.js +0 -0
- /package/dist/{classes/svelte → state/classes}/finite-state-machine/FiniteStateMachine.svelte.d.ts +0 -0
- /package/dist/{classes/svelte → state/classes}/finite-state-machine/FiniteStateMachine.svelte.js +0 -0
- /package/dist/{classes/svelte → state/classes}/finite-state-machine/index.d.ts +0 -0
- /package/dist/{classes/svelte → state/classes}/finite-state-machine/index.js +0 -0
- /package/dist/{classes/svelte → state/classes}/loading-state-machine/constants.d.ts +0 -0
- /package/dist/{classes/svelte → state/classes}/loading-state-machine/constants.js +0 -0
- /package/dist/{classes/svelte → state/classes}/loading-state-machine/index.d.ts +0 -0
- /package/dist/{classes/svelte → state/classes}/loading-state-machine/index.js +0 -0
- /package/dist/{classes/stores → state/classes/subscribers-count}/SubscribersCount.d.ts +0 -0
- /package/dist/{classes/stores → state/classes/subscribers-count}/SubscribersCount.js +0 -0
- /package/dist/{typedef/context.d.ts → state/context/typedef.d.ts} +0 -0
- /package/dist/{typedef/context.js → state/context/typedef.js} +0 -0
- /package/dist/{stores → state/stores}/theme.d.ts +0 -0
- /package/dist/{stores → state/stores}/theme.js +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/DragController.d.ts +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/DragController.js +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/actions.d.ts +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/actions.js +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/index.d.ts +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/index.js +0 -0
- /package/dist/{typedef → ui/components/drag-drop/typedef}/drag.d.ts +0 -0
- /package/dist/{typedef → ui/components/drag-drop/typedef}/drag.js +0 -0
- /package/dist/{typedef → ui/components/drag-drop/typedef}/drop.d.ts +0 -0
- /package/dist/{typedef → ui/components/drag-drop/typedef}/drop.js +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/util.d.ts +0 -0
- /package/dist/ui/{primitives → components}/drag-drop/util.js +0 -0
- /package/dist/ui/{primitives/layout → components}/grid-layers/GridLayers.svelte +0 -0
- /package/dist/ui/{primitives/layout → components}/grid-layers/GridLayers.svelte.d.ts +0 -0
- /package/dist/ui/{primitives/layout → components}/grid-layers/util.d.ts +0 -0
- /package/dist/ui/{primitives → components}/rows/index.d.ts +0 -0
- /package/dist/ui/{primitives → components}/rows/index.js +0 -0
- /package/dist/ui/{primitives → components}/rows/panel-grid-row/PanelGridRow.svelte +0 -0
- /package/dist/ui/{primitives → components}/rows/panel-row-2/PanelRow2.svelte +0 -0
- /package/dist/ui/{primitives → components}/tab-bar/index.d.ts +0 -0
- /package/dist/ui/{primitives → components}/tab-bar/index.js +0 -0
- /package/dist/ui/{primitives/hkdev → dev}/blocks/TextBlock.svelte.d.ts +0 -0
- /package/dist/ui/{primitives/hkdev → dev}/buttons/CheckButton.svelte +0 -0
- /package/dist/ui/{primitives/hkdev → dev}/buttons/CheckButton.svelte.d.ts +0 -0
- /package/dist/ui/{primitives/debug → dev}/debug-panel-design-scaling/DebugPanelDesignScaling.svelte.d.ts +0 -0
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} ErrorSummaryMeta
|
|
3
|
+
* @property {string} category - Error category (rethrow, validation, http, promise, error)
|
|
4
|
+
* @property {string} method - Specific method (rethrow, expect, httpGet, hkpromise.timeout, etc)
|
|
5
|
+
* @property {string} [origin] - User function name where error originated
|
|
6
|
+
* @property {number} [relevantFrameIndex] - Index of most relevant stack frame to highlight
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
10
|
* @typedef {Object} ErrorSummary
|
|
3
11
|
* @property {string} name - The name of the exception/error
|
|
4
12
|
* @property {string} message - The error message
|
|
13
|
+
* @property {ErrorSummaryMeta} [meta] - Error meta
|
|
5
14
|
* @property {string} [stack] Stack trace (in debug mode for first exception)
|
|
6
15
|
* @property {number} [status] - HTTP status code (for HttpError instances)
|
|
7
16
|
* @property {*} [details] - Additional error details (for HttpError instances)
|
|
17
|
+
* @property {string} [errorType] - Formatted error type for display
|
|
18
|
+
* @property {string[]} [stackFrames] - Cleaned stack frames for terminal display
|
|
8
19
|
*/
|
|
9
20
|
|
|
10
21
|
export default {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger } from '../logger/index.js';
|
|
2
|
-
|
|
3
2
|
import { PinoAdapter } from '../adapters/pino.js';
|
|
4
|
-
import { INFO } from '
|
|
3
|
+
import { INFO } from '../../constants.js';
|
|
4
|
+
// import { expectNoSSRContext } from '../../../util/ssr/index.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a server-side logger with pino adapter
|
|
@@ -12,10 +12,20 @@ import { INFO } from '../constants.js';
|
|
|
12
12
|
* @returns {Logger} Configured logger instance
|
|
13
13
|
*/
|
|
14
14
|
export function createServerLogger(name, level = INFO, pinoOptions = {}) {
|
|
15
|
+
// Guard against SSR serialization issues
|
|
16
|
+
// expectNoSSRContext();
|
|
17
|
+
|
|
15
18
|
const logger = new Logger(name, level);
|
|
16
19
|
const adapter = new PinoAdapter(pinoOptions);
|
|
17
20
|
|
|
18
21
|
// Connect adapter to logger events
|
|
22
|
+
//
|
|
23
|
+
// @note pino might fail if:
|
|
24
|
+
// pino tries to create a worker thread for pino-pretty before the
|
|
25
|
+
// development environment is fully ready, causing the transport target
|
|
26
|
+
// determination to fail
|
|
27
|
+
// -> Stop and start the dev server
|
|
28
|
+
//
|
|
19
29
|
logger.on('log', (logEvent) => adapter.handleLog(logEvent));
|
|
20
30
|
|
|
21
31
|
return logger;
|
|
@@ -33,6 +33,7 @@ export default class Logger extends EventEmitter {
|
|
|
33
33
|
*
|
|
34
34
|
* @param {string} message - Log message
|
|
35
35
|
* @param {*} [details] - Additional details
|
|
36
|
+
*
|
|
36
37
|
* @returns {boolean} True if the log was emitted
|
|
37
38
|
*/
|
|
38
39
|
info(message: string, details?: any): boolean;
|
|
@@ -41,23 +42,24 @@ export default class Logger extends EventEmitter {
|
|
|
41
42
|
*
|
|
42
43
|
* @param {string} message - Log message
|
|
43
44
|
* @param {*} [details] - Additional details
|
|
45
|
+
*
|
|
44
46
|
* @returns {boolean} True if the log was emitted
|
|
45
47
|
*/
|
|
46
48
|
warn(message: string, details?: any): boolean;
|
|
47
49
|
/**
|
|
48
50
|
* Log an error message
|
|
49
51
|
*
|
|
50
|
-
* @param {string}
|
|
51
|
-
* @param {
|
|
52
|
+
* @param {Error|string} originalErrorOrMessage
|
|
53
|
+
* @param {Error} [originalError]
|
|
54
|
+
*
|
|
52
55
|
* @returns {boolean} True if the log was emitted
|
|
53
56
|
*/
|
|
54
|
-
error(
|
|
57
|
+
error(originalErrorOrMessage: Error | string, originalError?: Error, ...args: any[]): boolean;
|
|
55
58
|
/**
|
|
56
59
|
* Create a child logger with additional context
|
|
57
60
|
*
|
|
58
61
|
* @param {string} namespace
|
|
59
62
|
* Namespace of the context (needed for chaining contexts)
|
|
60
|
-
*
|
|
61
63
|
* @param {Object} additionalContext - Additional context data
|
|
62
64
|
*
|
|
63
65
|
* @returns {Logger} New logger instance with merged context
|
|
@@ -70,9 +72,9 @@ export default class Logger extends EventEmitter {
|
|
|
70
72
|
* forwarded to this logger.
|
|
71
73
|
*
|
|
72
74
|
* @param {string} eventName
|
|
73
|
-
* @param {import('
|
|
75
|
+
* @param {import('../../typedef.js').LogEventData} eventData
|
|
74
76
|
*/
|
|
75
|
-
logFromEvent(eventName: string, eventData: import("
|
|
77
|
+
logFromEvent(eventName: string, eventData: import("../../typedef.js").LogEventData): boolean;
|
|
76
78
|
#private;
|
|
77
79
|
}
|
|
78
|
-
import { EventEmitter } from '../../../
|
|
80
|
+
import { EventEmitter } from '../../../generic/events.js';
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* logger.setLevel(DEBUG); // Now debug messages will also be logged
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
|
-
import { EventEmitter } from '../../../
|
|
35
|
+
import { EventEmitter } from '../../../generic/events.js';
|
|
36
36
|
|
|
37
37
|
import {
|
|
38
38
|
DEBUG,
|
|
@@ -41,7 +41,12 @@ import {
|
|
|
41
41
|
ERROR,
|
|
42
42
|
LEVELS,
|
|
43
43
|
LOG
|
|
44
|
-
} from '
|
|
44
|
+
} from '../../constants.js';
|
|
45
|
+
|
|
46
|
+
import { DetailedError } from '../../../generic/errors.js';
|
|
47
|
+
import { LoggerError } from '../../errors.js';
|
|
48
|
+
|
|
49
|
+
import { toArray } from '../../../util/array/index.js';
|
|
45
50
|
|
|
46
51
|
/**
|
|
47
52
|
* Logger class for consistent logging
|
|
@@ -99,6 +104,7 @@ export default class Logger extends EventEmitter {
|
|
|
99
104
|
*
|
|
100
105
|
* @param {string} message - Log message
|
|
101
106
|
* @param {*} [details] - Additional details
|
|
107
|
+
*
|
|
102
108
|
* @returns {boolean} True if the log was emitted
|
|
103
109
|
*/
|
|
104
110
|
info(message, details) {
|
|
@@ -110,6 +116,7 @@ export default class Logger extends EventEmitter {
|
|
|
110
116
|
*
|
|
111
117
|
* @param {string} message - Log message
|
|
112
118
|
* @param {*} [details] - Additional details
|
|
119
|
+
*
|
|
113
120
|
* @returns {boolean} True if the log was emitted
|
|
114
121
|
*/
|
|
115
122
|
warn(message, details) {
|
|
@@ -119,12 +126,41 @@ export default class Logger extends EventEmitter {
|
|
|
119
126
|
/**
|
|
120
127
|
* Log an error message
|
|
121
128
|
*
|
|
122
|
-
* @param {string}
|
|
123
|
-
* @param {
|
|
129
|
+
* @param {Error|string} originalErrorOrMessage
|
|
130
|
+
* @param {Error} [originalError]
|
|
131
|
+
*
|
|
124
132
|
* @returns {boolean} True if the log was emitted
|
|
125
133
|
*/
|
|
126
|
-
error(
|
|
127
|
-
|
|
134
|
+
error(originalErrorOrMessage, originalError) {
|
|
135
|
+
|
|
136
|
+
if( originalErrorOrMessage instanceof Error )
|
|
137
|
+
{
|
|
138
|
+
// params: {error} originalErrorOrMessage
|
|
139
|
+
const loggerError = new LoggerError(originalErrorOrMessage);
|
|
140
|
+
|
|
141
|
+
const message = originalErrorOrMessage.message;
|
|
142
|
+
|
|
143
|
+
return this.#log(ERROR, message, loggerError);
|
|
144
|
+
}
|
|
145
|
+
else if( typeof originalErrorOrMessage === 'string' && originalError instanceof Error ) {
|
|
146
|
+
// params: {string} message, {error} originalError
|
|
147
|
+
const detailedError = new DetailedError(
|
|
148
|
+
originalErrorOrMessage,
|
|
149
|
+
null,
|
|
150
|
+
originalError
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
return this.#log(ERROR, detailedError.message, detailedError);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// wrong params
|
|
157
|
+
const detailedError = new DetailedError(
|
|
158
|
+
'Invalid parameters supplied to Logger.error',
|
|
159
|
+
toArray(arguments)
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
return this.#log(ERROR, detailedError.message, detailedError);
|
|
163
|
+
}
|
|
128
164
|
}
|
|
129
165
|
|
|
130
166
|
/**
|
|
@@ -132,7 +168,6 @@ export default class Logger extends EventEmitter {
|
|
|
132
168
|
*
|
|
133
169
|
* @param {string} namespace
|
|
134
170
|
* Namespace of the context (needed for chaining contexts)
|
|
135
|
-
*
|
|
136
171
|
* @param {Object} additionalContext - Additional context data
|
|
137
172
|
*
|
|
138
173
|
* @returns {Logger} New logger instance with merged context
|
|
@@ -157,7 +192,7 @@ export default class Logger extends EventEmitter {
|
|
|
157
192
|
* forwarded to this logger.
|
|
158
193
|
*
|
|
159
194
|
* @param {string} eventName
|
|
160
|
-
* @param {import('
|
|
195
|
+
* @param {import('../../typedef.js').LogEventData} eventData
|
|
161
196
|
*/
|
|
162
197
|
logFromEvent(eventName, eventData) {
|
|
163
198
|
const level = eventData.level;
|
|
@@ -205,7 +240,7 @@ export default class Logger extends EventEmitter {
|
|
|
205
240
|
/**
|
|
206
241
|
* Internal event loggin method
|
|
207
242
|
*
|
|
208
|
-
* @param {import('
|
|
243
|
+
* @param {import('../../typedef.js').LogEvent} logEvent
|
|
209
244
|
*/
|
|
210
245
|
#logEvent(logEvent) {
|
|
211
246
|
// Emit as both specific level event and generic 'log' event
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test functions for generating various types of errors for logging demonstration
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Simple error: division by zero (which creates NaN in JS, so we'll throw manually)
|
|
6
|
+
*/
|
|
7
|
+
export function throwSimpleError(): number;
|
|
8
|
+
/**
|
|
9
|
+
* Simple error occurring in a sub function
|
|
10
|
+
*/
|
|
11
|
+
export function throwErrorInSubFunction(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Promise rejection in async function
|
|
14
|
+
*/
|
|
15
|
+
export function throwPromiseRejection(): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* HkPromise timeout
|
|
18
|
+
*/
|
|
19
|
+
export function throwHkPromiseTimeout(): Promise<any>;
|
|
20
|
+
/**
|
|
21
|
+
* HTTP request that fails
|
|
22
|
+
*/
|
|
23
|
+
export function throwHttpException(): Promise<Response>;
|
|
24
|
+
/**
|
|
25
|
+
* Expect validation error
|
|
26
|
+
*/
|
|
27
|
+
export function throwExpectError(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Rethrow chain error
|
|
30
|
+
*/
|
|
31
|
+
export function throwRethrowChainError(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Raw valibot validation error (without expect wrapper)
|
|
34
|
+
*/
|
|
35
|
+
export function throwRawValibotError(): any;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { expect, rethrow } from '../../util/index.js';
|
|
2
|
+
import { HkPromise } from '../../generic/promises.js';
|
|
3
|
+
import { httpGet } from '../../network/http/index.js';
|
|
4
|
+
import { v } from '../../valibot/index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Test functions for generating various types of errors for logging demonstration
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Simple error: division by zero (which creates NaN in JS, so we'll throw manually)
|
|
12
|
+
*/
|
|
13
|
+
export function throwSimpleError() {
|
|
14
|
+
const a = 10;
|
|
15
|
+
const b = 0;
|
|
16
|
+
|
|
17
|
+
if (b === 0) {
|
|
18
|
+
throw new Error('Division by zero is not allowed');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return a / b; // This won't be reached
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Simple error occurring in a sub function
|
|
26
|
+
*/
|
|
27
|
+
export function throwErrorInSubFunction() {
|
|
28
|
+
function deepFunction() {
|
|
29
|
+
function evenDeeperFunction() {
|
|
30
|
+
throw new Error('Error occurred in deeply nested function');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
evenDeeperFunction();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function callDeepFunction() {
|
|
37
|
+
deepFunction();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
callDeepFunction();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Promise rejection in async function
|
|
45
|
+
*/
|
|
46
|
+
export async function throwPromiseRejection() {
|
|
47
|
+
// Create a promise that rejects after a short delay
|
|
48
|
+
const rejectedPromise = new Promise((resolve, reject) => {
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
reject(new Error('Promise was rejected after timeout'));
|
|
51
|
+
}, 100);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Await the promise (will throw)
|
|
55
|
+
return await rejectedPromise;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* HkPromise timeout
|
|
60
|
+
*/
|
|
61
|
+
export async function throwHkPromiseTimeout() {
|
|
62
|
+
// Create an HkPromise that times out
|
|
63
|
+
const timeoutPromise = new HkPromise((resolve) => {
|
|
64
|
+
// Never resolve this promise to cause timeout
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
// This resolve will never be reached because timeout occurs first
|
|
67
|
+
resolve('This should not complete');
|
|
68
|
+
}, 2000);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Set timeout of 500ms (will timeout before the 2000ms resolve)
|
|
72
|
+
timeoutPromise.setTimeout(500, 'HkPromise timeout after 500ms');
|
|
73
|
+
|
|
74
|
+
return await timeoutPromise;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* HTTP request that fails
|
|
79
|
+
*/
|
|
80
|
+
export async function throwHttpException() {
|
|
81
|
+
// Try to fetch with an invalid URL format
|
|
82
|
+
const response = await httpGet({
|
|
83
|
+
url: 'not-a-valid-url-format'
|
|
84
|
+
});
|
|
85
|
+
return response;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Expect validation error
|
|
90
|
+
*/
|
|
91
|
+
export function throwExpectError() {
|
|
92
|
+
try {
|
|
93
|
+
// This will always fail and trigger an expect error
|
|
94
|
+
expect.string(123);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
rethrow('throwExpectError failed', e);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Rethrow chain error
|
|
102
|
+
*/
|
|
103
|
+
export function throwRethrowChainError() {
|
|
104
|
+
function level1Function() {
|
|
105
|
+
try {
|
|
106
|
+
level2Function();
|
|
107
|
+
} catch (e) {
|
|
108
|
+
rethrow('Error in level1Function', e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function level2Function() {
|
|
113
|
+
try {
|
|
114
|
+
level3Function();
|
|
115
|
+
} catch (e) {
|
|
116
|
+
rethrow('Error in level2Function', e);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function level3Function() {
|
|
121
|
+
throw new Error('Original error at deepest level');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
level1Function();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Raw valibot validation error (without expect wrapper)
|
|
129
|
+
*/
|
|
130
|
+
export function throwRawValibotError() {
|
|
131
|
+
// This calls valibot.parse directly, not through expect_*
|
|
132
|
+
const schema = v.string();
|
|
133
|
+
const invalidValue = 456;
|
|
134
|
+
|
|
135
|
+
// This will throw a ValiError directly from our valibotParser wrapper
|
|
136
|
+
return v.parse(schema, invalidValue);
|
|
137
|
+
}
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
* @property {number|null} expires - Expiration timestamp (null if no expiration)
|
|
29
29
|
* @property {string|null} etag - ETag header if present
|
|
30
30
|
* @property {string|null} lastModified - Last-Modified header if present
|
|
31
|
+
* @property {string|null} cacheVersion - Cache version identifier
|
|
31
32
|
*/
|
|
32
33
|
/**
|
|
33
34
|
* In-memory response cache implementation
|
|
@@ -103,4 +104,8 @@ export type CacheEntry = {
|
|
|
103
104
|
* - Last-Modified header if present
|
|
104
105
|
*/
|
|
105
106
|
lastModified: string | null;
|
|
107
|
+
/**
|
|
108
|
+
* - Cache version identifier
|
|
109
|
+
*/
|
|
110
|
+
cacheVersion: string | null;
|
|
106
111
|
};
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
* @property {number|null} expires - Expiration timestamp (null if no expiration)
|
|
30
30
|
* @property {string|null} etag - ETag header if present
|
|
31
31
|
* @property {string|null} lastModified - Last-Modified header if present
|
|
32
|
+
* @property {string|null} cacheVersion - Cache version identifier
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -75,7 +76,8 @@ export default class MemoryResponseCache {
|
|
|
75
76
|
timestamp: entry.timestamp,
|
|
76
77
|
expires: entry.expires,
|
|
77
78
|
etag: entry.etag,
|
|
78
|
-
lastModified: entry.lastModified
|
|
79
|
+
lastModified: entry.lastModified,
|
|
80
|
+
cacheVersion: entry.cacheVersion
|
|
79
81
|
};
|
|
80
82
|
}
|
|
81
83
|
|
|
@@ -104,7 +106,8 @@ export default class MemoryResponseCache {
|
|
|
104
106
|
lastAccessed: now,
|
|
105
107
|
expires,
|
|
106
108
|
etag: response.headers.get('ETag'),
|
|
107
|
-
lastModified: response.headers.get('Last-Modified')
|
|
109
|
+
lastModified: response.headers.get('Last-Modified'),
|
|
110
|
+
cacheVersion: metadata.cacheVersion || null
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
113
|
|
|
@@ -135,7 +135,7 @@ export async function getCachedResponse(cacheKeyParams) {
|
|
|
135
135
|
* @param {string} type Type of storage ('indexed-db', 'memory')
|
|
136
136
|
* @param {Object} options Options for the storage adapter
|
|
137
137
|
*
|
|
138
|
-
* @returns {import('
|
|
138
|
+
* @returns {import('../cache.js').CacheStorage}
|
|
139
139
|
*/
|
|
140
140
|
function createCacheStorage(type = 'indexed-db', options = {}) {
|
|
141
141
|
switch (type) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as expect from '../../util/expect/index.js';
|
|
2
|
+
import { DetailedError } from '../../generic/errors.js';
|
|
2
3
|
|
|
3
4
|
import { CONTENT_TYPE } from '../../constants/http/index.js';
|
|
4
5
|
|
|
@@ -19,7 +20,7 @@ import { APPLICATION_JSON } from '../../constants/mime/index.js';
|
|
|
19
20
|
*
|
|
20
21
|
* @param {object} response
|
|
21
22
|
*
|
|
22
|
-
* @returns {Error} error
|
|
23
|
+
* @returns {Promise<Error>} error
|
|
23
24
|
*/
|
|
24
25
|
export async function getErrorFromResponse(response) {
|
|
25
26
|
expect.object(response);
|
|
@@ -77,21 +78,12 @@ export async function getErrorFromResponse(response) {
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
} else {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (tmp.length) {
|
|
83
|
-
message = tmp;
|
|
84
|
-
} else {
|
|
85
|
-
message = response.statusText;
|
|
86
|
-
}
|
|
81
|
+
// For non-JSON responses, always use status text (avoid HTML pages)
|
|
82
|
+
message = response.statusText || `HTTP ${response.status}`;
|
|
87
83
|
}
|
|
88
84
|
// console.log( "message", message );
|
|
89
85
|
|
|
90
|
-
const error = new
|
|
91
|
-
|
|
92
|
-
if (details) {
|
|
93
|
-
error.details = details;
|
|
94
|
-
}
|
|
86
|
+
const error = new DetailedError(message, details);
|
|
95
87
|
|
|
96
88
|
return error;
|
|
97
89
|
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { APPLICATION_JSON } from '../../constants/mime/application.js';
|
|
12
12
|
import { CONTENT_TYPE } from '../../constants/http/headers.js';
|
|
13
13
|
|
|
14
|
-
import { AbortError, TimeoutError } from '
|
|
14
|
+
import { AbortError, TimeoutError } from '../errors/api.js';
|
|
15
15
|
|
|
16
16
|
import * as expect from '../../util/expect/index.js';
|
|
17
17
|
|
|
@@ -2,7 +2,7 @@ import { METHOD_GET, METHOD_POST } from '../../constants/http/methods.js';
|
|
|
2
2
|
|
|
3
3
|
import { APPLICATION_JSON } from '../../constants/mime/application.js';
|
|
4
4
|
import { CONTENT_TYPE } from '../../constants/http/headers.js';
|
|
5
|
-
import { ResponseError } from '
|
|
5
|
+
import { ResponseError } from '../errors.js';
|
|
6
6
|
|
|
7
7
|
import * as expect from '../../util/expect/index.js';
|
|
8
8
|
|
package/dist/network/http/url.js
CHANGED
|
@@ -44,22 +44,29 @@ Loads responsive image variants, automatically selecting the best size for conta
|
|
|
44
44
|
```javascript
|
|
45
45
|
import { ImageVariantsLoader } from '$lib/network/loaders.js';
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// Load responsive variants
|
|
47
|
+
// Responsive image variants (array of ImageMeta)
|
|
50
48
|
const imageSource = [
|
|
51
49
|
{ src: '/image-400.jpg', width: 400, height: 300 },
|
|
52
50
|
{ src: '/image-800.jpg', width: 800, height: 600 },
|
|
53
51
|
{ src: '/image-1200.jpg', width: 1200, height: 900 }
|
|
54
52
|
];
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const loader = new ImageVariantsLoader(imageSource, {
|
|
55
|
+
devicePixelRatio: window.devicePixelRatio
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Set optimal image variant for container
|
|
59
|
+
loader.setOptimalImageVariant({
|
|
58
60
|
containerWidth: 600,
|
|
59
61
|
containerHeight: 400,
|
|
60
|
-
fit: 'cover'
|
|
61
|
-
devicePixelRatio: window.devicePixelRatio
|
|
62
|
+
fit: 'cover' // or 'contain', 'fill'
|
|
62
63
|
});
|
|
64
|
+
|
|
65
|
+
// Access the selected variant and loader
|
|
66
|
+
if (loader.loaded) {
|
|
67
|
+
const objectURL = loader.getObjectURL();
|
|
68
|
+
// Use objectURL in img src
|
|
69
|
+
}
|
|
63
70
|
```
|
|
64
71
|
|
|
65
72
|
### ImageScene
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as expect from '../../../util/expect/index.js';
|
|
2
2
|
|
|
3
|
+
import { LoadingStateMachine } from '../../../state/classes.js';
|
|
4
|
+
|
|
3
5
|
import {
|
|
4
|
-
LoadingStateMachine,
|
|
5
6
|
STATE_INITIAL,
|
|
6
7
|
STATE_LOADING,
|
|
7
8
|
STATE_UNLOADING,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
STATE_ERROR,
|
|
11
12
|
LOAD,
|
|
12
13
|
LOADED
|
|
13
|
-
} from '../../../classes/
|
|
14
|
+
} from '../../../state/classes/loading-state-machine/constants.js';
|
|
14
15
|
|
|
15
16
|
import AudioLoader from './AudioLoader.svelte.js';
|
|
16
17
|
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export default class ImageLoader extends NetworkLoader {
|
|
7
7
|
/**
|
|
8
|
-
* @param {import('
|
|
8
|
+
* @param {import('../../../config/typedef.js').ImageSource} imageSource
|
|
9
9
|
*/
|
|
10
|
-
constructor(imageSource: import("
|
|
10
|
+
constructor(imageSource: import("../../../config/typedef.js").ImageSource);
|
|
11
11
|
get imageMeta(): import("./typedef.js").ImageMeta;
|
|
12
12
|
get url(): string;
|
|
13
13
|
#private;
|
|
@@ -16,7 +16,7 @@ export default class ImageLoader extends NetworkLoader {
|
|
|
16
16
|
#imageMeta;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* @param {import('
|
|
19
|
+
* @param {import('../../../config/typedef.js').ImageSource} imageSource
|
|
20
20
|
*/
|
|
21
21
|
constructor(imageSource) {
|
|
22
22
|
const imageMeta = toSingleImageMeta(imageSource);
|
|
@@ -17,11 +17,11 @@ export default class ImageScene {
|
|
|
17
17
|
*
|
|
18
18
|
* @param {object} _
|
|
19
19
|
* @param {string} _.label
|
|
20
|
-
* @param {import('
|
|
20
|
+
* @param {import('../../../config/typedef.js').ImageSource} _.imageSource
|
|
21
21
|
*/
|
|
22
22
|
defineImage({ label, imageSource }: {
|
|
23
23
|
label: string;
|
|
24
|
-
imageSource: import("
|
|
24
|
+
imageSource: import("../../../config/typedef.js").ImageSource;
|
|
25
25
|
}): void;
|
|
26
26
|
/**
|
|
27
27
|
* Start loading all image sources
|