@hkdigital/lib-sveltekit 0.0.89 → 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.
- package/dist/classes/svelte/audio/AudioScene.svelte.js +1 -1
- package/dist/classes/svelte/audio/mocks.js +2 -2
- package/dist/classes/svelte/image/ImageLoader.svelte.d.ts +1 -0
- package/dist/classes/svelte/image/ImageLoader.svelte.js +25 -2
- package/dist/classes/svelte/image/ImageVariantsLoader.svelte.d.ts +2 -6
- package/dist/classes/svelte/image/ImageVariantsLoader.svelte.js +3 -3
- package/dist/classes/svelte/image/mocks.js +2 -5
- package/dist/classes/svelte/image/typedef.js +0 -2
- package/dist/classes/svelte/loading-state-machine/LoadingStateMachine.svelte.js +2 -0
- package/dist/classes/svelte/network-loader/NetworkLoader.svelte.d.ts +5 -7
- package/dist/classes/svelte/network-loader/NetworkLoader.svelte.js +25 -14
- package/dist/classes/svelte/network-loader/mocks.js +2 -2
- package/dist/classes/svelte/network-loader/typedef.d.ts +7 -0
- package/dist/classes/svelte/network-loader/typedef.js +8 -0
- package/dist/components/image/ImageBox.svelte +229 -0
- package/dist/components/image/ImageBox.svelte.d.ts +55 -0
- package/dist/components/image/ResponsiveImage.svelte +1 -1
- package/dist/components/image/typedef.d.ts +4 -0
- package/dist/components/image/typedef.js +32 -0
- package/dist/config/imagetools-config.js +6 -1
- package/dist/{types → config}/imagetools.d.ts +31 -21
- package/dist/config/typedef.d.ts +7 -0
- package/dist/config/typedef.js +8 -0
- package/dist/util/http/mocks.js +1 -1
- package/package.json +12 -10
@@ -1,6 +1,6 @@
|
|
1
|
-
import { CONTENT_TYPE, CONTENT_LENGTH } from '
|
1
|
+
import { CONTENT_TYPE, CONTENT_LENGTH } from '../../../constants/http/index.js';
|
2
2
|
|
3
|
-
import { AUDIO_WAV } from '
|
3
|
+
import { AUDIO_WAV } from '../../../constants/mime/audio.js';
|
4
4
|
|
5
5
|
// import MockWav from './tiny-silence.wav?raw';
|
6
6
|
|
@@ -10,13 +10,36 @@ import {
|
|
10
10
|
* - The loading process can be monitored
|
11
11
|
*/
|
12
12
|
export default class ImageLoader extends NetworkLoader {
|
13
|
-
//
|
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
|
+
|
29
|
+
//
|
30
|
+
// /**
|
31
|
+
// * Construct ImageLoader
|
32
|
+
// *
|
33
|
+
// * @param {object} _
|
34
|
+
// * @param {string} _.url
|
35
|
+
// */
|
36
|
+
// constructor( { url } ) {}
|
14
37
|
//
|
15
38
|
// /**
|
16
39
|
// * Get object URL that can be used as src parameter of an HTML image
|
17
40
|
// *
|
18
41
|
// * @note the objectURL should be revoked when no longer used
|
19
42
|
// */
|
20
|
-
//
|
43
|
+
// getObjectURL() {}
|
21
44
|
//
|
22
45
|
} // end class
|
@@ -20,12 +20,8 @@ export default class ImageVariantsLoader {
|
|
20
20
|
*
|
21
21
|
* @returns {string|null}
|
22
22
|
*/
|
23
|
-
|
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 '
|
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
|
-
|
93
|
+
getObjectURL() {
|
94
94
|
// Example usage:
|
95
95
|
//
|
96
96
|
// $effect(() => {
|
97
97
|
// if (variantsLoader.loaded) {
|
98
98
|
// // @ts-ignore
|
99
|
-
// imageUrl = variantsLoader.
|
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 '
|
3
|
+
import { IMAGE_PNG } from '../../../constants/mime/image.js';
|
7
4
|
|
8
5
|
/**
|
9
6
|
* A minimal 1x1 black PNG encoded as base64
|
@@ -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,8 @@ export default class NetworkLoader {
|
|
14
14
|
url: string;
|
15
15
|
});
|
16
16
|
_state: LoadingStateMachine;
|
17
|
-
state:
|
17
|
+
state: any;
|
18
|
+
initial: boolean;
|
18
19
|
loaded: boolean;
|
19
20
|
/** @type {string|null} */
|
20
21
|
_url: string | null;
|
@@ -29,11 +30,8 @@ export default class NetworkLoader {
|
|
29
30
|
_headers: Headers | null;
|
30
31
|
/** @type {ArrayBuffer|null} */
|
31
32
|
_buffer: ArrayBuffer | null;
|
32
|
-
|
33
|
-
|
34
|
-
size: number;
|
35
|
-
loaded: boolean;
|
36
|
-
};
|
33
|
+
/** @type {import('./typedef.js').LoadingProgress} */
|
34
|
+
progress: import("./typedef.js").LoadingProgress;
|
37
35
|
/** @type {null|(()=>void)} */
|
38
36
|
_abortLoading: null | (() => void);
|
39
37
|
/**
|
@@ -87,7 +85,7 @@ export default class NetworkLoader {
|
|
87
85
|
*
|
88
86
|
* @returns {string|null}
|
89
87
|
*/
|
90
|
-
|
88
|
+
getObjectURL(): string | null;
|
91
89
|
#private;
|
92
90
|
}
|
93
91
|
import { LoadingStateMachine } from '../loading-state-machine/index.js';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CONTENT_TYPE } from '
|
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 '
|
19
|
+
import * as expect from '../../../util/expect/index.js';
|
20
20
|
|
21
|
-
import { httpGet, loadResponseBuffer } from '
|
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,13 +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
|
-
|
34
|
-
|
34
|
+
state = $derived.by(() => {
|
35
|
+
return this._state.current;
|
36
|
+
});
|
37
|
+
|
38
|
+
initial = $derived.by(() => {
|
39
|
+
return this._state.current === STATE_INITIAL;
|
40
|
+
});
|
35
41
|
|
36
42
|
loaded = $derived.by(() => {
|
37
|
-
return this.
|
43
|
+
return this._state.current === STATE_LOADED;
|
38
44
|
});
|
39
45
|
|
40
46
|
/** @type {string|null} */
|
@@ -56,6 +62,8 @@ export default class NetworkLoader {
|
|
56
62
|
_buffer = null;
|
57
63
|
|
58
64
|
// Export state property as readonly
|
65
|
+
|
66
|
+
/** @type {import('./typedef.js').LoadingProgress} */
|
59
67
|
progress = $derived.by(() => {
|
60
68
|
return {
|
61
69
|
bytesLoaded: this._bytesLoaded,
|
@@ -80,11 +88,15 @@ export default class NetworkLoader {
|
|
80
88
|
|
81
89
|
const state = this._state;
|
82
90
|
|
83
|
-
|
91
|
+
//
|
92
|
+
// ISSUE: $effect is not triggered by this._state changes,
|
93
|
+
// using onenter instead
|
94
|
+
//
|
95
|
+
this._state.onenter = () => {
|
84
96
|
switch (state.current) {
|
85
97
|
case STATE_LOADING:
|
86
98
|
{
|
87
|
-
// console.log('NetworkLoader:loading');
|
99
|
+
// console.log('**** NetworkLoader:loading');
|
88
100
|
this.#load();
|
89
101
|
}
|
90
102
|
break;
|
@@ -121,15 +133,14 @@ export default class NetworkLoader {
|
|
121
133
|
}
|
122
134
|
break;
|
123
135
|
} // end switch
|
124
|
-
|
125
|
-
this.state = state.current;
|
126
|
-
});
|
136
|
+
};
|
127
137
|
}
|
128
138
|
|
129
139
|
/**
|
130
140
|
* Start loading all network data
|
131
141
|
*/
|
132
142
|
load() {
|
143
|
+
// console.log('NetworkLoader: load() called');
|
133
144
|
this._state.send(LOAD);
|
134
145
|
}
|
135
146
|
|
@@ -218,14 +229,14 @@ export default class NetworkLoader {
|
|
218
229
|
*
|
219
230
|
* @returns {string|null}
|
220
231
|
*/
|
221
|
-
|
232
|
+
getObjectURL() {
|
222
233
|
//
|
223
234
|
// Example usage:
|
224
235
|
//
|
225
236
|
// $effect(() => {
|
226
237
|
// if (loader.loaded) {
|
227
238
|
// // @ts-ignore
|
228
|
-
// objectUrl = loader.
|
239
|
+
// objectUrl = loader.getObjectURL();
|
229
240
|
// }
|
230
241
|
//
|
231
242
|
// return () => {
|
@@ -247,7 +258,7 @@ export default class NetworkLoader {
|
|
247
258
|
*/
|
248
259
|
async #load() {
|
249
260
|
try {
|
250
|
-
// console.log('
|
261
|
+
// console.log('>>>> NetworkLoader:#load', this._url);
|
251
262
|
|
252
263
|
if (this._abortLoading) {
|
253
264
|
// console.log('Abort loading');
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { CONTENT_TYPE, CONTENT_LENGTH } from '
|
1
|
+
import { CONTENT_TYPE, CONTENT_LENGTH } from '../../../constants/http/index.js';
|
2
2
|
|
3
|
-
import { OCTET_STREAM } from '
|
3
|
+
import { OCTET_STREAM } from '../../../constants/mime/application.js';
|
4
4
|
|
5
5
|
const BASE64_DATA =
|
6
6
|
'UklGRnwAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YVgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
|
@@ -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
|
+
}, {}, "">;
|
@@ -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
|
-
|
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=
|
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=
|
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=
|
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=
|
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
|
+
}
|
package/dist/util/http/mocks.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hkdigital/lib-sveltekit",
|
3
|
-
"version": "0.0.
|
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": {
|