@hkdigital/lib-sveltekit 0.0.90 → 0.0.91

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.
@@ -1,4 +1,4 @@
1
- import * as expect from '@hkdigital/lib-sveltekit/util/expect/index.js';
1
+ import * as expect from '../../../util/expect/index.js';
2
2
 
3
3
  import {
4
4
  LoadingStateMachine,
@@ -1,6 +1,6 @@
1
- import { CONTENT_TYPE, CONTENT_LENGTH } from '@hkdigital/lib-sveltekit/constants/http/index.js';
1
+ import { CONTENT_TYPE, CONTENT_LENGTH } from '../../../constants/http/index.js';
2
2
 
3
- import { AUDIO_WAV } from '@hkdigital/lib-sveltekit/constants/mime/audio.js';
3
+ import { AUDIO_WAV } from '../../../constants/mime/audio.js';
4
4
 
5
5
  // import MockWav from './tiny-silence.wav?raw';
6
6
 
@@ -4,5 +4,6 @@
4
4
  * - The loading process can be monitored
5
5
  */
6
6
  export default class ImageLoader extends NetworkLoader {
7
+ get url(): string;
7
8
  }
8
9
  import { NetworkLoader } from '../network-loader/index.js';
@@ -10,6 +10,22 @@ import {
10
10
  * - The loading process can be monitored
11
11
  */
12
12
  export default class ImageLoader extends NetworkLoader {
13
+ // onenter(label) {
14
+ // console.log('ImageLoader:onenter', label);
15
+ // }
16
+
17
+ // constructor({ url }) {
18
+ // super({ url });
19
+
20
+ // $effect(() => {
21
+ // console.log('ImageLoader: state', this.state);
22
+ // });
23
+ // }
24
+
25
+ get url() {
26
+ return this._url;
27
+ }
28
+
13
29
  //
14
30
  // /**
15
31
  // * Construct ImageLoader
@@ -24,6 +40,6 @@ export default class ImageLoader extends NetworkLoader {
24
40
  // *
25
41
  // * @note the objectURL should be revoked when no longer used
26
42
  // */
27
- // getObjectUrl() {}
43
+ // getObjectURL() {}
28
44
  //
29
45
  } // end class
@@ -20,12 +20,8 @@ export default class ImageVariantsLoader {
20
20
  *
21
21
  * @returns {string|null}
22
22
  */
23
- getObjectUrl(): string | null;
24
- get progress(): {
25
- bytesLoaded: number;
26
- size: number;
27
- loaded: boolean;
28
- };
23
+ getObjectURL(): string | null;
24
+ get progress(): import("../network-loader/typedef.js").LoadingProgress;
29
25
  /**
30
26
  * Get optimal image variant
31
27
  *
@@ -1,6 +1,6 @@
1
1
  /** @typedef {import('./typedef.js').ImageMeta} ImageMeta */
2
2
 
3
- // import * as expect from '@hkdigital/lib-sveltekit/util/expect/index.js';
3
+ // import * as expect from '../../../util/expect/index.js';
4
4
 
5
5
  import { untrack } from 'svelte';
6
6
 
@@ -90,13 +90,13 @@ export default class ImageVariantsLoader {
90
90
  *
91
91
  * @returns {string|null}
92
92
  */
93
- getObjectUrl() {
93
+ getObjectURL() {
94
94
  // Example usage:
95
95
  //
96
96
  // $effect(() => {
97
97
  // if (variantsLoader.loaded) {
98
98
  // // @ts-ignore
99
- // imageUrl = variantsLoader.getObjectUrl();
99
+ // imageUrl = variantsLoader.getObjectURL();
100
100
  // }
101
101
 
102
102
  // return () => {
@@ -1,9 +1,6 @@
1
- import {
2
- CONTENT_TYPE,
3
- CONTENT_LENGTH
4
- } from '@hkdigital/lib-sveltekit/constants/http/index.js';
1
+ import { CONTENT_TYPE, CONTENT_LENGTH } from '../../../constants/http/index.js';
5
2
 
6
- import { IMAGE_PNG } from '@hkdigital/lib-sveltekit/constants/mime/image.js';
3
+ import { IMAGE_PNG } from '../../../constants/mime/image.js';
7
4
 
8
5
  /**
9
6
  * A minimal 1x1 black PNG encoded as base64
@@ -1,5 +1,3 @@
1
- // /** @typedef {import('@hkdigital/lib-sveltekit/types/imagetools.js').ImageMeta} ImageMeta */
2
-
3
1
  /**
4
2
  * @typedef {Object} ImageMeta
5
3
  * @property {string} src - URL of the image
@@ -47,6 +47,7 @@ export default class LoadingStateMachine extends FiniteStateMachine {
47
47
  },
48
48
  [STATE_LOADING]: {
49
49
  _enter: () => {
50
+ // console.log('LoadingStateMachine: enter LOADING');
50
51
  this.onenter?.(STATE_LOADING);
51
52
  },
52
53
  [CANCEL]: STATE_CANCELLED,
@@ -55,6 +56,7 @@ export default class LoadingStateMachine extends FiniteStateMachine {
55
56
  },
56
57
  [STATE_LOADED]: {
57
58
  _enter: () => {
59
+ // console.log('LoadingStateMachine: enter LOADED');
58
60
  this.onenter?.(STATE_LOADED);
59
61
  },
60
62
  [LOAD]: STATE_LOADING,
@@ -14,7 +14,7 @@ export default class NetworkLoader {
14
14
  url: string;
15
15
  });
16
16
  _state: LoadingStateMachine;
17
- state: string;
17
+ state: any;
18
18
  initial: boolean;
19
19
  loaded: boolean;
20
20
  /** @type {string|null} */
@@ -30,11 +30,8 @@ export default class NetworkLoader {
30
30
  _headers: Headers | null;
31
31
  /** @type {ArrayBuffer|null} */
32
32
  _buffer: ArrayBuffer | null;
33
- progress: {
34
- bytesLoaded: number;
35
- size: number;
36
- loaded: boolean;
37
- };
33
+ /** @type {import('./typedef.js').LoadingProgress} */
34
+ progress: import("./typedef.js").LoadingProgress;
38
35
  /** @type {null|(()=>void)} */
39
36
  _abortLoading: null | (() => void);
40
37
  /**
@@ -88,7 +85,7 @@ export default class NetworkLoader {
88
85
  *
89
86
  * @returns {string|null}
90
87
  */
91
- getObjectUrl(): string | null;
88
+ getObjectURL(): string | null;
92
89
  #private;
93
90
  }
94
91
  import { LoadingStateMachine } from '../loading-state-machine/index.js';
@@ -1,4 +1,4 @@
1
- import { CONTENT_TYPE } from '@hkdigital/lib-sveltekit/constants/http/index.js';
1
+ import { CONTENT_TYPE } from '../../../constants/http/index.js';
2
2
 
3
3
  import {
4
4
  LoadingStateMachine,
@@ -16,9 +16,9 @@ import {
16
16
  INITIAL
17
17
  } from '../loading-state-machine/index.js';
18
18
 
19
- import * as expect from '@hkdigital/lib-sveltekit/util/expect/index.js';
19
+ import * as expect from '../../../util/expect/index.js';
20
20
 
21
- import { httpGet, loadResponseBuffer } from '@hkdigital/lib-sveltekit/util/http/index.js';
21
+ import { httpGet, loadResponseBuffer } from '../../../util/http/index.js';
22
22
 
23
23
  import { ERROR_NOT_LOADED, ERROR_TRANSFERRED } from './constants.js';
24
24
 
@@ -28,17 +28,19 @@ import { ERROR_NOT_LOADED, ERROR_TRANSFERRED } from './constants.js';
28
28
  * - Loaded data can be transferred to an AudioBufferSourceNode
29
29
  */
30
30
  export default class NetworkLoader {
31
+ // _state = $state(new LoadingStateMachine());
31
32
  _state = new LoadingStateMachine();
32
33
 
33
- // @note this exported state is set by $effect's
34
- state = $state(STATE_INITIAL);
34
+ state = $derived.by(() => {
35
+ return this._state.current;
36
+ });
35
37
 
36
38
  initial = $derived.by(() => {
37
- return this.state === STATE_INITIAL;
39
+ return this._state.current === STATE_INITIAL;
38
40
  });
39
41
 
40
42
  loaded = $derived.by(() => {
41
- return this.state === STATE_LOADED;
43
+ return this._state.current === STATE_LOADED;
42
44
  });
43
45
 
44
46
  /** @type {string|null} */
@@ -60,6 +62,8 @@ export default class NetworkLoader {
60
62
  _buffer = null;
61
63
 
62
64
  // Export state property as readonly
65
+
66
+ /** @type {import('./typedef.js').LoadingProgress} */
63
67
  progress = $derived.by(() => {
64
68
  return {
65
69
  bytesLoaded: this._bytesLoaded,
@@ -84,11 +88,15 @@ export default class NetworkLoader {
84
88
 
85
89
  const state = this._state;
86
90
 
87
- $effect(() => {
91
+ //
92
+ // ISSUE: $effect is not triggered by this._state changes,
93
+ // using onenter instead
94
+ //
95
+ this._state.onenter = () => {
88
96
  switch (state.current) {
89
97
  case STATE_LOADING:
90
98
  {
91
- // console.log('NetworkLoader:loading');
99
+ // console.log('**** NetworkLoader:loading');
92
100
  this.#load();
93
101
  }
94
102
  break;
@@ -125,15 +133,14 @@ export default class NetworkLoader {
125
133
  }
126
134
  break;
127
135
  } // end switch
128
-
129
- this.state = state.current;
130
- });
136
+ };
131
137
  }
132
138
 
133
139
  /**
134
140
  * Start loading all network data
135
141
  */
136
142
  load() {
143
+ // console.log('NetworkLoader: load() called');
137
144
  this._state.send(LOAD);
138
145
  }
139
146
 
@@ -222,14 +229,14 @@ export default class NetworkLoader {
222
229
  *
223
230
  * @returns {string|null}
224
231
  */
225
- getObjectUrl() {
232
+ getObjectURL() {
226
233
  //
227
234
  // Example usage:
228
235
  //
229
236
  // $effect(() => {
230
237
  // if (loader.loaded) {
231
238
  // // @ts-ignore
232
- // objectUrl = loader.getObjectUrl();
239
+ // objectUrl = loader.getObjectURL();
233
240
  // }
234
241
  //
235
242
  // return () => {
@@ -251,7 +258,7 @@ export default class NetworkLoader {
251
258
  */
252
259
  async #load() {
253
260
  try {
254
- // console.log('#load', this._url);
261
+ // console.log('>>>> NetworkLoader:#load', this._url);
255
262
 
256
263
  if (this._abortLoading) {
257
264
  // console.log('Abort loading');
@@ -1,6 +1,6 @@
1
- import { CONTENT_TYPE, CONTENT_LENGTH } from '@hkdigital/lib-sveltekit/constants/http/index.js';
1
+ import { CONTENT_TYPE, CONTENT_LENGTH } from '../../../constants/http/index.js';
2
2
 
3
- import { OCTET_STREAM } from '@hkdigital/lib-sveltekit/constants/mime/application.js';
3
+ import { OCTET_STREAM } from '../../../constants/mime/application.js';
4
4
 
5
5
  const BASE64_DATA =
6
6
  'UklGRnwAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YVgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
@@ -0,0 +1,7 @@
1
+ declare const _default: {};
2
+ export default _default;
3
+ export type LoadingProgress = {
4
+ bytesLoaded: number;
5
+ size: number;
6
+ loaded: boolean;
7
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @typedef {Object} LoadingProgress
3
+ * @property {number} bytesLoaded
4
+ * @property {number} size
5
+ * @property {boolean} loaded
6
+ */
7
+
8
+ export default {};
@@ -0,0 +1,229 @@
1
+ <script>
2
+ import { onMount } from 'svelte';
3
+
4
+ import { ImageLoader } from '../../classes/svelte/image/index.js';
5
+
6
+ /**
7
+ * @example
8
+ * import { ImageBox } from '/path/to/ImageBox/index.js';
9
+ *
10
+ * // @note 'as=metadata' is set by the preset
11
+ * import NeonLightsOff from '../../img/NeonLightsOff.jpg?preset=gradient';
12
+ *
13
+ * <!-- Example that fits in an outer-box -->
14
+ *
15
+ * <div class="outer-box">
16
+ * <ImageBox image={ArmyGreen} fit="contain" position="center center" />
17
+ * </div>
18
+ *
19
+ * <!-- Examples that has have width, height or aspect set -->
20
+ *
21
+ * <ImageBox
22
+ * image={ArmyGreen}
23
+ * fit="contain"
24
+ * position="center center"
25
+ * width="w-[200px]"
26
+ * height="h-[200px]"
27
+ * classes="border-8 border-green-500"
28
+ * />
29
+ *
30
+ * <ImageBox
31
+ * image={ArmyGreen}
32
+ * fit="contain"
33
+ * position="center center"
34
+ * width="w-[200px]"
35
+ * aspect="aspect-square"
36
+ * classes="border-8 border-green-500"
37
+ * />
38
+ *
39
+ * <ImageBox
40
+ * image={ArmyGreen}
41
+ * fit="contain"
42
+ * position="center center"
43
+ * height="h-[200px]"
44
+ * aspect="aspect-square"
45
+ * classes="border-8 border-green-500"
46
+ * />
47
+ *
48
+ * <!-- Or hack it using !important -->
49
+ *
50
+ * <ImageBox
51
+ * image={ArmyGreen}
52
+ * fit="contain"
53
+ * position="center center"
54
+ * classes="!w-[200px] !h-[200px] border-8 border-green-500"
55
+ * />
56
+ */
57
+
58
+ /**
59
+ * @typedef {import('./typedef.js').ObjectFit} ObjectFit
60
+ * @typedef {import('./typedef.js').ObjectPosition} ObjectPosition
61
+ *
62
+ * @typedef {import('../../classes/svelte/network-loader/typedef.js').LoadingProgress} LoadingProgress
63
+ *
64
+ * @typedef {import('../../config/typedef.js').ImageMeta} ImageMeta
65
+ *
66
+ * @typedef {Object} Props
67
+ * @property {string} [base] - Base styling class
68
+ * @property {string} [bg] - Background styling class
69
+ * @property {string} [classes] - Additional CSS classes
70
+ * @property {string} [width] - Width of the image container
71
+ * @property {string} [height] - Height of the image container
72
+ * @property {string} [aspect] - Aspect ratio of the image container
73
+ * @property {string} [overflow] - Overflow behavior
74
+ * @property {ObjectFit} [fit] - Object-fit property
75
+ * @property {ObjectPosition} [position] - Object-position property
76
+ * @property {ImageMeta|ImageMeta[]} image - Image metadata or array of image metadata
77
+ * @property {string} [alt] - Alternative text for the image
78
+ * @property {() => LoadingProgress} [onProgress] - Progress callback function
79
+ * @property {*} [attr] - Additional arbitrary attributes
80
+ */
81
+
82
+ /** @type {Props} */
83
+ let {
84
+ // Style
85
+ base,
86
+ bg,
87
+ classes,
88
+ width,
89
+ height,
90
+ aspect,
91
+ overflow = 'overflow-clip',
92
+
93
+ // Fitting and positioning of image in its container
94
+ fit = 'contain',
95
+ position = 'left top',
96
+
97
+ // Image meta
98
+ image,
99
+
100
+ alt = '',
101
+
102
+ // Attributes
103
+ ...attrs
104
+ } = $props();
105
+
106
+ // let show = $state(false);
107
+
108
+ /** @type {HTMLDivElement|undefined} */
109
+ let imgBoxElem = $state();
110
+
111
+ /** @type {HTMLImageElement|undefined} */
112
+ let imgElem = $state();
113
+
114
+ let aspectStyle = $state('');
115
+
116
+ // > Loading
117
+
118
+ let metaWidth = $state(0);
119
+ let metaHeight = $state(0);
120
+
121
+ let singleImage = $state();
122
+
123
+ $effect(() => {
124
+ if (image instanceof Array && image[0]) {
125
+ throw new Error('Responsive image is not supported (yet)');
126
+ } else if (typeof image === 'object') {
127
+ // expect image.src
128
+ // expect image.width
129
+ // expect image.height
130
+ singleImage = image;
131
+ }
132
+ });
133
+
134
+ $effect(() => {
135
+ //
136
+ // Set meta width and height
137
+ //
138
+ if (singleImage) {
139
+ if (singleImage.width) {
140
+ metaWidth = singleImage.width;
141
+ }
142
+
143
+ if (singleImage.height) {
144
+ metaHeight = singleImage.height;
145
+ }
146
+ }
147
+ });
148
+
149
+ /** @type {ImageLoader|undefined} */
150
+ let imageLoader = $state();
151
+
152
+ /** @type {string|null} */
153
+ let objectUrl = $state(null);
154
+
155
+ $effect(() => {
156
+ //
157
+ // Create image loader
158
+ //
159
+ if (singleImage.src && !imageLoader) {
160
+ const url = singleImage.src;
161
+ imageLoader = new ImageLoader({ url });
162
+ }
163
+ });
164
+
165
+ $effect(() => {
166
+ //
167
+ // Start loading if imageLoader is in state 'initial'
168
+ //
169
+ // TODO: implement lazy flag
170
+ //
171
+ if (imageLoader?.initial) {
172
+ imageLoader.load();
173
+ }
174
+ });
175
+
176
+ $effect(() => {
177
+ //
178
+ // Get objectUrl when the image has finished loading
179
+ //
180
+ if (imageLoader.loaded) {
181
+ // @ts-ignore
182
+ objectUrl = imageLoader.getObjectURL();
183
+ }
184
+
185
+ return () => {
186
+ if (objectUrl) {
187
+ URL.revokeObjectURL(objectUrl);
188
+ objectUrl = null;
189
+ }
190
+ };
191
+ });
192
+
193
+ $effect(() => {
194
+ console.log('classes', classes);
195
+ });
196
+ </script>
197
+
198
+ <div
199
+ data-image-box
200
+ bind:this={imgBoxElem}
201
+ class="{base} {bg} {aspect} {overflow} {width} {height} {classes}"
202
+ style:--fit={fit}
203
+ style:--pos={position}
204
+ style:aspect-ratio={aspectStyle}
205
+ style:width={width || (height && aspect) ? undefined : '100%'}
206
+ style:height={height || (width && aspect) ? undefined : '100%'}
207
+ {...attrs}
208
+ >
209
+ {#if metaWidth && metaHeight}
210
+ <img src={objectUrl} {alt} width={metaWidth} height={metaHeight} />
211
+ {/if}
212
+ </div>
213
+
214
+ <style>
215
+ [data-image-box] {
216
+ max-width: 100%;
217
+ max-height: 100%;
218
+ }
219
+
220
+ img {
221
+ display: block;
222
+ width: 100%;
223
+ height: 100%;
224
+ max-width: 100%;
225
+ max-height: 100%;
226
+ object-fit: var(--fit);
227
+ object-position: var(--pos);
228
+ }
229
+ </style>
@@ -0,0 +1,55 @@
1
+ export default ImageBox;
2
+ declare const ImageBox: import("svelte").Component<{
3
+ /**
4
+ * - Base styling class
5
+ */
6
+ base?: string;
7
+ /**
8
+ * - Background styling class
9
+ */
10
+ bg?: string;
11
+ /**
12
+ * - Additional CSS classes
13
+ */
14
+ classes?: string;
15
+ /**
16
+ * - Width of the image container
17
+ */
18
+ width?: string;
19
+ /**
20
+ * - Height of the image container
21
+ */
22
+ height?: string;
23
+ /**
24
+ * - Aspect ratio of the image container
25
+ */
26
+ aspect?: string;
27
+ /**
28
+ * - Overflow behavior
29
+ */
30
+ overflow?: string;
31
+ /**
32
+ * - Object-fit property
33
+ */
34
+ fit?: import("./typedef.js").ObjectFit;
35
+ /**
36
+ * - Object-position property
37
+ */
38
+ position?: import("./typedef.js").ObjectPosition;
39
+ /**
40
+ * - Image metadata or array of image metadata
41
+ */
42
+ image: import("../../config/typedef.js").ImageMeta | import("../../config/typedef.js").ImageMeta[];
43
+ /**
44
+ * - Alternative text for the image
45
+ */
46
+ alt?: string;
47
+ /**
48
+ * - Progress callback function
49
+ */
50
+ onProgress?: () => import("../../classes/svelte/network-loader/typedef.js").LoadingProgress;
51
+ /**
52
+ * - Additional arbitrary attributes
53
+ */
54
+ attr?: any;
55
+ }, {}, "">;
@@ -52,7 +52,7 @@
52
52
 
53
53
  if (variantsLoader.loaded) {
54
54
  // @ts-ignore
55
- imageUrl = variantsLoader.getObjectUrl();
55
+ imageUrl = variantsLoader.getObjectURL();
56
56
 
57
57
  // image = new Image();
58
58
  // image.src = url;
@@ -0,0 +1,4 @@
1
+ declare const _default: {};
2
+ export default _default;
3
+ export type ObjectFit = ("contain" | "cover" | "fill" | "none" | "scale-down");
4
+ export type ObjectPosition = ("left" | "center" | "right" | "top" | "bottom" | "left top" | "left center" | "left bottom" | "center top" | "center center" | "center bottom" | "right top" | "right center" | "right bottom" | `${number}% ${number}%` | `${number}px ${number}px`);
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @typedef {(
3
+ * 'contain' |
4
+ * 'cover' |
5
+ * 'fill' |
6
+ * 'none' |
7
+ * 'scale-down'
8
+ * )} ObjectFit
9
+ */
10
+
11
+ /**
12
+ * @typedef {(
13
+ * 'left' |
14
+ * 'center' |
15
+ * 'right' |
16
+ * 'top' |
17
+ * 'bottom' |
18
+ * 'left top' |
19
+ * 'left center' |
20
+ * 'left bottom' |
21
+ * 'center top' |
22
+ * 'center center' |
23
+ * 'center bottom' |
24
+ * 'right top' |
25
+ * 'right center' |
26
+ * 'right bottom' |
27
+ * `${number}% ${number}%` |
28
+ * `${number}px ${number}px`
29
+ * )} ObjectPosition
30
+ */
31
+
32
+ export default {};
@@ -5,7 +5,7 @@ const DEFAULT_PRESETS = {
5
5
  format: 'avif',
6
6
  quality: '90'
7
7
  },
8
- gradient: {
8
+ render: {
9
9
  format: 'jpg',
10
10
  quality: '95',
11
11
  as: 'metadata'
@@ -15,6 +15,11 @@ const DEFAULT_PRESETS = {
15
15
  quality: '95',
16
16
  as: 'metadata'
17
17
  },
18
+ gradient: {
19
+ format: 'jpg',
20
+ quality: '95',
21
+ as: 'metadata'
22
+ },
18
23
  drawing: {
19
24
  format: 'avif',
20
25
  quality: '90',
@@ -1,10 +1,10 @@
1
+ // export interface ImageMeta {
2
+ // src: string;
3
+ // width: number;
4
+ // height: number;
5
+ // }
1
6
 
2
-
3
- interface ImageMeta {
4
- src: string;
5
- width?: number;
6
- height?: number;
7
- }
7
+ type ImageMeta = import('./typedef.js').ImageMeta;
8
8
 
9
9
  declare module '*?responsive' {
10
10
  const out: ImageMeta[];
@@ -16,52 +16,62 @@ declare module '*&responsive' {
16
16
  export default out;
17
17
  }
18
18
 
19
- declare module '*?preset=gradient' {
20
- const out: ImageMeta|ImageMeta[];
19
+ declare module '*?preset=photo' {
20
+ const out: ImageMeta | ImageMeta[];
21
21
  export default out;
22
22
  }
23
23
 
24
- declare module '*&preset=gradient' {
25
- const out: ImageMeta|ImageMeta[];
24
+ declare module '*&preset=photo' {
25
+ const out: ImageMeta | ImageMeta[];
26
26
  export default out;
27
27
  }
28
28
 
29
- declare module '*?preset=photo' {
30
- const out: ImageMeta|ImageMeta[];
29
+ declare module '*?preset=render' {
30
+ const out: ImageMeta | ImageMeta[];
31
31
  export default out;
32
32
  }
33
33
 
34
- declare module '*&preset=photo' {
35
- const out: ImageMeta|ImageMeta[];
34
+ declare module '*&preset=render' {
35
+ const out: ImageMeta | ImageMeta[];
36
+ export default out;
37
+ }
38
+
39
+ declare module '*?preset=gradient' {
40
+ const out: ImageMeta | ImageMeta[];
41
+ export default out;
42
+ }
43
+
44
+ declare module '*&preset=gradient' {
45
+ const out: ImageMeta | ImageMeta[];
36
46
  export default out;
37
47
  }
38
48
 
39
49
  declare module '*?preset=drawing' {
40
- const out: ImageMeta|ImageMeta[];
50
+ const out: ImageMeta | ImageMeta[];
41
51
  export default out;
42
52
  }
43
53
 
44
54
  declare module '*&preset=drawing' {
45
- const out: ImageMeta|ImageMeta[];
55
+ const out: ImageMeta | ImageMeta[];
46
56
  export default out;
47
57
  }
48
58
 
49
59
  declare module '*?preset=savedata' {
50
- const out: ImageMeta|ImageMeta[];
60
+ const out: ImageMeta | ImageMeta[];
51
61
  export default out;
52
62
  }
53
63
 
54
64
  declare module '*&preset=savedata' {
55
- const out: ImageMeta|ImageMeta[];
65
+ const out: ImageMeta | ImageMeta[];
56
66
  export default out;
57
67
  }
58
68
 
59
69
  declare module '*?preset=blur' {
60
- const out: ImageMeta|ImageMeta[];
70
+ const out: ImageMeta | ImageMeta[];
61
71
  export default out;
62
72
  }
63
73
 
64
74
  declare module '*&preset=blur' {
65
- const out: ImageMeta|ImageMeta[];
75
+ const out: ImageMeta | ImageMeta[];
66
76
  export default out;
67
- }
77
+ }
@@ -0,0 +1,7 @@
1
+ declare const _default: {};
2
+ export default _default;
3
+ export type ImageMeta = {
4
+ src: string;
5
+ width: number;
6
+ height: number;
7
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @typedef {object} ImageMeta
3
+ * @property {string} src
4
+ * @property {number} width
5
+ * @property {number} height
6
+ */
7
+
8
+ export default {};
@@ -1,4 +1,4 @@
1
- import { CONTENT_TYPE, CONTENT_LENGTH } from '@hkdigital/lib-sveltekit/constants/http/index.js';
1
+ import { CONTENT_TYPE, CONTENT_LENGTH } from '../../constants/http/index.js';
2
2
 
3
3
  import { OCTET_STREAM } from '../../constants/mime/index.js';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.0.90",
3
+ "version": "0.0.91",
4
4
  "author": "Jens Kleinhout, HKdigital (https://hkdigital.nl)",
5
5
  "license": "ISC",
6
6
  "repository": {
@@ -17,19 +17,19 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "dev": "vite dev",
20
- "build": "vite build && npm run package",
20
+ "build": "cross-env vite build && npm run package",
21
21
  "preview": "vite preview",
22
- "package": "svelte-kit sync && svelte-package && publint",
23
- "prepublishOnly": "npm run package",
24
- "publish:npm": "npm version patch && npm publish --access public && git push",
25
- "check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
26
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
22
+ "package": "cross-env svelte-kit sync && svelte-package && publint",
23
+ "prepublishOnly": "cross-env npm run package",
24
+ "publish:npm": "cross-env npm version patch && npm publish --access public && git push",
25
+ "check": "cross-env svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
26
+ "check:watch": "cross-env svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
27
27
  "format": "prettier --write .",
28
- "lint": "prettier --check . && eslint .",
28
+ "lint": "cross-env prettier --check . && eslint .",
29
29
  "test:unit": "vitest",
30
- "test": "npm run test:unit -- --run && npm run test:e2e",
30
+ "test": "cross-env npm run test:unit -- --run && npm run test:e2e",
31
31
  "test:e2e": "playwright test",
32
- "upgrade:all": "ncu -u && pnpm install"
32
+ "upgrade:all": "cross-env ncu -u && pnpm install"
33
33
  },
34
34
  "files": [
35
35
  "dist",
@@ -57,6 +57,7 @@
57
57
  "@sveltejs/vite-plugin-svelte": "^5.0.3",
58
58
  "@types/eslint": "^9.6.1",
59
59
  "autoprefixer": "^10.4.20",
60
+ "cross-env": "^7.0.3",
60
61
  "eslint": "^9.17.0",
61
62
  "eslint-config-prettier": "^9.1.0",
62
63
  "eslint-plugin-svelte": "^2.46.1",
@@ -72,6 +73,7 @@
72
73
  "tailwindcss": "^3.4.17",
73
74
  "typescript": "^5.7.3",
74
75
  "vite": "^6.0.7",
76
+ "vite-imagetools": "^7.0.5",
75
77
  "vitest": "^2.1.8"
76
78
  },
77
79
  "dependencies": {