@hkdigital/lib-sveltekit 0.1.22 → 0.1.23
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/image/ImageScene.svelte.d.ts +54 -26
- package/dist/classes/svelte/image/ImageScene.svelte.js +208 -75
- package/dist/classes/svelte/image/ImageVariantsLoader.svelte.d.ts +5 -6
- package/dist/classes/svelte/image/ImageVariantsLoader.svelte.js +39 -55
- package/dist/components/area/HkArea.svelte.d.ts +0 -14
- package/dist/components/area/HkGridArea.svelte.d.ts +0 -22
- package/dist/components/buttons/button/Button.svelte.d.ts +0 -21
- package/dist/components/buttons/button-icon-steeze/SteezeIconButton.svelte.d.ts +0 -9
- package/dist/components/buttons/button-text/TextButton.svelte.d.ts +0 -7
- package/dist/components/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte.d.ts +0 -4
- package/dist/components/hkdev/blocks/TextBlock.svelte.d.ts +0 -13
- package/dist/components/hkdev/buttons/CheckButton.svelte.d.ts +0 -18
- package/dist/components/icons/HkIcon.svelte.d.ts +0 -12
- package/dist/components/icons/HkTabIcon.svelte.d.ts +0 -21
- package/dist/components/icons/SteezeIcon.svelte.d.ts +0 -12
- package/dist/components/inputs/text-input/TextInput.svelte.d.ts +0 -28
- package/dist/components/layout/grid-layers/GridLayers.svelte.d.ts +0 -23
- package/dist/components/panels/panel/Panel.svelte.d.ts +0 -13
- package/dist/components/rows/panel-grid-row/PanelGridRow.svelte.d.ts +0 -14
- package/dist/components/rows/panel-row-2/PanelRow2.svelte.d.ts +0 -14
- package/dist/components/tab-bar/HkTabBar.svelte.d.ts +0 -18
- package/dist/components/tab-bar/HkTabBarSelector.svelte.d.ts +0 -19
- package/dist/design/tailwind-theme-extend.d.ts +4 -4
- package/dist/server/logger.d.ts +0 -1
- package/dist/widgets/button-group/ButtonGroup.svelte.d.ts +0 -20
- package/dist/widgets/compare-left-right/CompareLeftRight.svelte.d.ts +0 -10
- package/dist/widgets/game-box/GameBox.svelte.d.ts +0 -41
- package/dist/widgets/hk-app-layout/HkAppLayout.svelte.d.ts +0 -11
- package/dist/widgets/image-box/ImageBox.svelte +4 -8
- package/dist/widgets/image-box/ImageBox.svelte.d.ts +1 -22
- package/dist/widgets/presenter/ImageSlide.svelte.d.ts +1 -5
- package/dist/widgets/presenter/Presenter.svelte.d.ts +0 -11
- package/dist/widgets/virtual-viewport/VirtualViewport.svelte.d.ts +0 -22
- package/package.json +1 -1
- package/dist/classes/svelte/image/ImageScene.svelte.js__ +0 -253
- package/dist/classes/svelte/image/ImageVariantsLoader.svelte.js--responsive-loading-fails-fix-tried__ +0 -184
@@ -1,50 +1,78 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef {object} SourceConfig
|
3
|
+
* // property ...
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @typedef {object} ImageSource
|
7
|
+
* @property {string} label
|
8
|
+
* @property {ImageLoader} imageLoader
|
9
|
+
* @property {ImageMeta} [imageMeta]
|
10
|
+
*/
|
1
11
|
export default class ImageScene {
|
12
|
+
state: string;
|
13
|
+
loaded: boolean;
|
14
|
+
destroy(): void;
|
2
15
|
/**
|
3
|
-
*
|
16
|
+
* Add image source
|
17
|
+
* - Uses an ImageLoader instance to load image data from network
|
4
18
|
*
|
5
|
-
* @param {object}
|
6
|
-
* @param {string}
|
7
|
-
* @param {ImageMeta|ImageMeta[]}
|
19
|
+
* @param {object} _
|
20
|
+
* @param {string} _.label
|
21
|
+
* @param {ImageMeta|ImageMeta[]} _.imageMeta
|
8
22
|
*/
|
9
23
|
defineImage({ label, imageMeta }: {
|
10
24
|
label: string;
|
11
25
|
imageMeta: ImageMeta | ImageMeta[];
|
12
26
|
}): void;
|
13
27
|
/**
|
14
|
-
* Start loading all
|
28
|
+
* Start loading all image sources
|
15
29
|
*/
|
16
30
|
load(): void;
|
17
31
|
/**
|
18
|
-
*
|
32
|
+
* Get image scene loading progress
|
19
33
|
*/
|
20
|
-
|
34
|
+
get progress(): {
|
35
|
+
totalBytesLoaded: number;
|
36
|
+
totalSize: number;
|
37
|
+
sourcesLoaded: number;
|
38
|
+
numberOfSources: number;
|
39
|
+
};
|
21
40
|
/**
|
22
|
-
* Get
|
41
|
+
* Get an image loader
|
23
42
|
*
|
24
|
-
* @param {string} label
|
25
|
-
*
|
26
|
-
|
27
|
-
getImageLoader(label: string): ImageLoader | null;
|
28
|
-
/**
|
29
|
-
* Check if the scene is currently loading
|
43
|
+
* @param {string} label
|
44
|
+
*
|
45
|
+
* @returns {ImageLoader}
|
30
46
|
*/
|
31
|
-
|
47
|
+
getImageLoader(label: string): ImageLoader;
|
32
48
|
/**
|
33
|
-
*
|
49
|
+
* Get object URL that can be used as src parameter of an HTML image
|
50
|
+
*
|
51
|
+
* @param {string} label
|
52
|
+
*
|
53
|
+
* @returns {ImageMeta}
|
34
54
|
*/
|
35
|
-
|
55
|
+
getImageMeta(label: string): ImageMeta;
|
36
56
|
/**
|
37
|
-
* Get
|
57
|
+
* Get object URL that can be used as src parameter of an HTML image
|
58
|
+
*
|
59
|
+
* @param {string} label
|
60
|
+
*
|
61
|
+
* @note the objectURL should be revoked when no longer used
|
62
|
+
*
|
63
|
+
* @returns {string}
|
38
64
|
*/
|
39
|
-
|
40
|
-
bytesLoaded: number;
|
41
|
-
size: number;
|
42
|
-
loaded: boolean;
|
43
|
-
};
|
65
|
+
getObjectURL(label: string): string;
|
44
66
|
#private;
|
45
67
|
}
|
68
|
+
export type ImageMeta = import("./typedef.js").ImageMeta;
|
46
69
|
/**
|
47
|
-
*
|
70
|
+
* // property ...
|
48
71
|
*/
|
49
|
-
export type
|
50
|
-
|
72
|
+
export type SourceConfig = object;
|
73
|
+
export type ImageSource = {
|
74
|
+
label: string;
|
75
|
+
imageLoader: ImageLoader;
|
76
|
+
imageMeta?: ImageMeta;
|
77
|
+
};
|
78
|
+
import ImageLoader from './ImageLoader.svelte.js';
|
@@ -1,120 +1,253 @@
|
|
1
|
+
/** @typedef {import('./typedef.js').ImageMeta} ImageMeta */
|
2
|
+
|
3
|
+
import * as expect from '../../../util/expect/index.js';
|
4
|
+
|
5
|
+
import {
|
6
|
+
LoadingStateMachine,
|
7
|
+
STATE_INITIAL,
|
8
|
+
STATE_LOADING,
|
9
|
+
STATE_UNLOADING,
|
10
|
+
STATE_LOADED,
|
11
|
+
STATE_CANCELLED,
|
12
|
+
STATE_ERROR,
|
13
|
+
LOAD,
|
14
|
+
// CANCEL,
|
15
|
+
ERROR,
|
16
|
+
LOADED,
|
17
|
+
UNLOAD,
|
18
|
+
INITIAL
|
19
|
+
} from '../loading-state-machine/index.js';
|
20
|
+
|
21
|
+
import ImageLoader from './ImageLoader.svelte.js';
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @typedef {object} SourceConfig
|
25
|
+
* // property ...
|
26
|
+
*/
|
27
|
+
|
1
28
|
/**
|
2
|
-
*
|
3
|
-
*
|
4
|
-
* @
|
29
|
+
* @typedef {object} ImageSource
|
30
|
+
* @property {string} label
|
31
|
+
* @property {ImageLoader} imageLoader
|
32
|
+
* @property {ImageMeta} [imageMeta]
|
5
33
|
*/
|
6
|
-
import { ImageLoader } from './index.js';
|
7
34
|
|
8
35
|
export default class ImageScene {
|
9
|
-
|
10
|
-
#loaders = $state.raw(new Map());
|
36
|
+
#state = new LoadingStateMachine();
|
11
37
|
|
12
|
-
|
13
|
-
|
38
|
+
// @note this exported state is set by $effect's
|
39
|
+
state = $state(STATE_INITIAL);
|
14
40
|
|
15
|
-
|
16
|
-
|
41
|
+
// @note this exported state is set by $effect's
|
42
|
+
loaded = $derived.by(() => {
|
43
|
+
return this.state === STATE_LOADED;
|
44
|
+
});
|
17
45
|
|
18
|
-
/** @type {
|
19
|
-
#
|
46
|
+
/** @type {ImageSource[]} */
|
47
|
+
#imageSources = $state([]);
|
20
48
|
|
21
|
-
|
22
|
-
|
23
|
-
*
|
24
|
-
* @param {object} params
|
25
|
-
* @param {string} params.label - Unique identifier for the image
|
26
|
-
* @param {ImageMeta|ImageMeta[]} params.imageMeta - Image metadata (single or variants)
|
27
|
-
*/
|
28
|
-
defineImage({ label, imageMeta }) {
|
29
|
-
// Create loader for this image
|
30
|
-
const loader = new ImageLoader({ imageMeta });
|
31
|
-
this.#loaders.set(label, loader);
|
32
|
-
}
|
49
|
+
#progress = $derived.by(() => {
|
50
|
+
// console.log('update progress');
|
33
51
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
load() {
|
38
|
-
if (this.#loading || this.#loaded) return;
|
52
|
+
let totalSize = 0;
|
53
|
+
let totalBytesLoaded = 0;
|
54
|
+
let sourcesLoaded = 0;
|
39
55
|
|
40
|
-
|
56
|
+
const sources = this.#imageSources;
|
57
|
+
const numberOfSources = sources.length;
|
41
58
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
}
|
59
|
+
for (let j = 0; j < numberOfSources; j++) {
|
60
|
+
const source = sources[j];
|
61
|
+
const { imageLoader } = source;
|
46
62
|
|
47
|
-
|
48
|
-
$effect(() => {
|
49
|
-
if (this.#loaders.size === 0) return;
|
63
|
+
const { bytesLoaded, size, loaded } = imageLoader.progress;
|
50
64
|
|
51
|
-
|
52
|
-
|
53
|
-
let allLoaded = true;
|
65
|
+
totalSize += size;
|
66
|
+
totalBytesLoaded += bytesLoaded;
|
54
67
|
|
55
|
-
|
56
|
-
|
68
|
+
if (loaded) {
|
69
|
+
sourcesLoaded++;
|
70
|
+
}
|
71
|
+
} // end for
|
57
72
|
|
58
|
-
|
59
|
-
|
73
|
+
return {
|
74
|
+
totalBytesLoaded,
|
75
|
+
totalSize,
|
76
|
+
sourcesLoaded,
|
77
|
+
numberOfSources
|
78
|
+
};
|
79
|
+
});
|
60
80
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
81
|
+
/**
|
82
|
+
* Construct ImageScene
|
83
|
+
*/
|
84
|
+
constructor() {
|
85
|
+
const state = this.#state;
|
86
|
+
|
87
|
+
$effect(() => {
|
88
|
+
if (state.current === STATE_LOADING) {
|
89
|
+
// console.log(
|
90
|
+
// 'progress',
|
91
|
+
// JSON.stringify($state.snapshot(this.#progress))
|
92
|
+
// );
|
65
93
|
|
66
|
-
|
67
|
-
bytesLoaded: totalBytesLoaded,
|
68
|
-
size: totalSize,
|
69
|
-
loaded: allLoaded
|
70
|
-
};
|
94
|
+
const { sourcesLoaded, numberOfSources } = this.#progress;
|
71
95
|
|
72
|
-
|
73
|
-
|
96
|
+
if (sourcesLoaded === numberOfSources) {
|
97
|
+
// console.log(`All [${numberOfSources}] sources loaded`);
|
98
|
+
this.#state.send(LOADED);
|
99
|
+
}
|
74
100
|
}
|
75
101
|
});
|
102
|
+
|
103
|
+
$effect(() => {
|
104
|
+
switch (state.current) {
|
105
|
+
case STATE_LOADING:
|
106
|
+
{
|
107
|
+
// console.log('ImageScene:loading');
|
108
|
+
this.#startLoading();
|
109
|
+
}
|
110
|
+
break;
|
111
|
+
|
112
|
+
case STATE_UNLOADING:
|
113
|
+
{
|
114
|
+
// console.log('ImageScene:unloading');
|
115
|
+
// this.#startUnLoading();
|
116
|
+
}
|
117
|
+
break;
|
118
|
+
|
119
|
+
case STATE_LOADED:
|
120
|
+
{
|
121
|
+
// console.log('ImageScene:loaded');
|
122
|
+
// TODO
|
123
|
+
// this.#abortLoading = null;
|
124
|
+
}
|
125
|
+
break;
|
126
|
+
|
127
|
+
case STATE_CANCELLED:
|
128
|
+
{
|
129
|
+
// console.log('ImageScene:cancelled');
|
130
|
+
// TODO
|
131
|
+
}
|
132
|
+
break;
|
133
|
+
|
134
|
+
case STATE_ERROR:
|
135
|
+
{
|
136
|
+
console.log('ImageScene:error', state.error);
|
137
|
+
}
|
138
|
+
break;
|
139
|
+
} // end switch
|
140
|
+
|
141
|
+
this.state = state.current;
|
142
|
+
});
|
143
|
+
}
|
144
|
+
|
145
|
+
destroy() {
|
146
|
+
// TODO: disconnect all image sources?
|
147
|
+
// TODO: Unload ImageLoaders?
|
148
|
+
}
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Add image source
|
152
|
+
* - Uses an ImageLoader instance to load image data from network
|
153
|
+
*
|
154
|
+
* @param {object} _
|
155
|
+
* @param {string} _.label
|
156
|
+
* @param {ImageMeta|ImageMeta[]} _.imageMeta
|
157
|
+
*/
|
158
|
+
defineImage({ label, imageMeta }) {
|
159
|
+
expect.notEmptyString(label);
|
160
|
+
|
161
|
+
// expect.notEmptyString(url);
|
162
|
+
|
163
|
+
const imageLoader = new ImageLoader({ imageMeta });
|
164
|
+
|
165
|
+
this.#imageSources.push({ label, imageLoader, imageMeta });
|
76
166
|
}
|
77
167
|
|
78
168
|
/**
|
79
|
-
*
|
169
|
+
* Start loading all image sources
|
80
170
|
*/
|
81
|
-
|
82
|
-
|
83
|
-
|
171
|
+
load() {
|
172
|
+
this.#state.send(LOAD);
|
173
|
+
|
174
|
+
// FIXME: in unit test when moved to startloading it hangs!
|
175
|
+
|
176
|
+
for (const { imageLoader } of this.#imageSources) {
|
177
|
+
imageLoader.load();
|
84
178
|
}
|
179
|
+
}
|
85
180
|
|
86
|
-
|
87
|
-
|
181
|
+
async #startLoading() {
|
182
|
+
// console.log('#startLoading');
|
183
|
+
// FIXME: in unit test when moved to startloading it hangs!
|
184
|
+
// for (const { audioLoader } of this.#memorySources) {
|
185
|
+
// audioLoader.load();
|
186
|
+
// }
|
88
187
|
}
|
89
188
|
|
90
189
|
/**
|
91
|
-
* Get
|
190
|
+
* Get Image source
|
92
191
|
*
|
93
|
-
* @param {string} label
|
94
|
-
*
|
192
|
+
* @param {string} label
|
193
|
+
*
|
194
|
+
* @returns {ImageSource}
|
95
195
|
*/
|
96
|
-
|
97
|
-
|
196
|
+
#getImageSource(label) {
|
197
|
+
for (const source of this.#imageSources) {
|
198
|
+
if (label === source.label) {
|
199
|
+
return source;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
throw new Error(`Source [${label}] has not been defined`);
|
204
|
+
}
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Get image scene loading progress
|
208
|
+
*/
|
209
|
+
get progress() {
|
210
|
+
return this.#progress;
|
98
211
|
}
|
99
212
|
|
100
213
|
/**
|
101
|
-
*
|
214
|
+
* Get an image loader
|
215
|
+
*
|
216
|
+
* @param {string} label
|
217
|
+
*
|
218
|
+
* @returns {ImageLoader}
|
102
219
|
*/
|
103
|
-
|
104
|
-
|
220
|
+
getImageLoader(label) {
|
221
|
+
const source = this.#getImageSource(label);
|
222
|
+
|
223
|
+
return source.imageLoader;
|
105
224
|
}
|
106
225
|
|
107
226
|
/**
|
108
|
-
*
|
227
|
+
* Get object URL that can be used as src parameter of an HTML image
|
228
|
+
*
|
229
|
+
* @param {string} label
|
230
|
+
*
|
231
|
+
* @returns {ImageMeta}
|
109
232
|
*/
|
110
|
-
|
111
|
-
|
233
|
+
getImageMeta(label) {
|
234
|
+
const source = this.#getImageSource(label);
|
235
|
+
|
236
|
+
return source.imageMeta;
|
112
237
|
}
|
113
238
|
|
114
239
|
/**
|
115
|
-
* Get
|
240
|
+
* Get object URL that can be used as src parameter of an HTML image
|
241
|
+
*
|
242
|
+
* @param {string} label
|
243
|
+
*
|
244
|
+
* @note the objectURL should be revoked when no longer used
|
245
|
+
*
|
246
|
+
* @returns {string}
|
116
247
|
*/
|
117
|
-
|
118
|
-
|
248
|
+
getObjectURL(label) {
|
249
|
+
const source = this.#getImageSource(label);
|
250
|
+
|
251
|
+
return source.imageLoader.getObjectURL();
|
119
252
|
}
|
120
253
|
}
|
@@ -1,5 +1,8 @@
|
|
1
1
|
export default class ImageVariantsLoader {
|
2
|
-
|
2
|
+
/**
|
3
|
+
* @param {ImageMeta[]} imagesMeta
|
4
|
+
*/
|
5
|
+
constructor(imagesMeta: ImageMeta[], { devicePixelRatio }?: {
|
3
6
|
devicePixelRatio?: number;
|
4
7
|
});
|
5
8
|
/**
|
@@ -25,11 +28,7 @@ export default class ImageVariantsLoader {
|
|
25
28
|
* @returns {string|null}
|
26
29
|
*/
|
27
30
|
getObjectURL(): string | null;
|
28
|
-
get progress():
|
29
|
-
bytesLoaded: any;
|
30
|
-
size: any;
|
31
|
-
loaded: boolean;
|
32
|
-
};
|
31
|
+
get progress(): import("../network-loader/typedef.js").LoadingProgress;
|
33
32
|
/**
|
34
33
|
* Get optimal image variant
|
35
34
|
*
|
@@ -1,7 +1,11 @@
|
|
1
1
|
/** @typedef {import('./typedef.js').ImageMeta} ImageMeta */
|
2
2
|
|
3
|
+
// import * as expect from '../../../util/expect/index.js';
|
4
|
+
|
3
5
|
import { calculateEffectiveWidth } from '../../../util/image/index.js';
|
6
|
+
|
4
7
|
import { untrack } from 'svelte';
|
8
|
+
|
5
9
|
import ImageLoader from './ImageLoader.svelte.js';
|
6
10
|
|
7
11
|
export default class ImageVariantsLoader {
|
@@ -17,32 +21,22 @@ export default class ImageVariantsLoader {
|
|
17
21
|
/** @type {ImageLoader|null} */
|
18
22
|
#imageLoader = $state(null);
|
19
23
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
#progress = $derived.by(() => {
|
25
|
+
if (this.#imageLoader) {
|
26
|
+
return this.#imageLoader.progress;
|
27
|
+
} else {
|
28
|
+
return { bytesLoaded: 0, size: 0, loaded: false };
|
29
|
+
}
|
30
|
+
});
|
25
31
|
|
26
|
-
|
27
|
-
#baseProgress = $state({ bytesLoaded: 0, size: 0, loaded: false });
|
32
|
+
#loaded = $derived.by(() => this.#progress?.loaded || false);
|
28
33
|
|
34
|
+
/**
|
35
|
+
* @param {ImageMeta[]} imagesMeta
|
36
|
+
*/
|
29
37
|
constructor(imagesMeta, { devicePixelRatio = 1 } = {}) {
|
30
38
|
this.#devicePixelRatio = devicePixelRatio ?? 1;
|
31
39
|
this.#imagesMeta = [...imagesMeta].sort((a, b) => a.width - b.width);
|
32
|
-
|
33
|
-
// Track the imageLoader's progress
|
34
|
-
$effect(() => {
|
35
|
-
if (this.#imageLoader) {
|
36
|
-
// Store the base progress from the loader
|
37
|
-
this.#baseProgress = this.#imageLoader.progress;
|
38
|
-
|
39
|
-
// When the base image is loaded, we can say variant is loaded
|
40
|
-
// if an object URL has been created
|
41
|
-
if (this.#baseProgress.loaded && this.#isObjectUrlCreated) {
|
42
|
-
this.#variantLoaded = true;
|
43
|
-
}
|
44
|
-
}
|
45
|
-
});
|
46
40
|
}
|
47
41
|
|
48
42
|
/**
|
@@ -73,11 +67,7 @@ export default class ImageVariantsLoader {
|
|
73
67
|
) {
|
74
68
|
this.#imageVariant = newVariant;
|
75
69
|
|
76
|
-
//
|
77
|
-
this.#isObjectUrlCreated = false;
|
78
|
-
this.#variantLoaded = false;
|
79
|
-
|
80
|
-
// Clean up and create a new loader
|
70
|
+
// Create and start loader here directly when variant changes
|
81
71
|
if (this.#imageLoader?.initial) {
|
82
72
|
this.#imageLoader.unload();
|
83
73
|
}
|
@@ -91,7 +81,7 @@ export default class ImageVariantsLoader {
|
|
91
81
|
}
|
92
82
|
|
93
83
|
get loaded() {
|
94
|
-
return this.#
|
84
|
+
return this.#loaded;
|
95
85
|
}
|
96
86
|
|
97
87
|
get variant() {
|
@@ -106,38 +96,31 @@ export default class ImageVariantsLoader {
|
|
106
96
|
* @returns {string|null}
|
107
97
|
*/
|
108
98
|
getObjectURL() {
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
//
|
120
|
-
|
121
|
-
|
122
|
-
//
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
this.#variantLoaded = true;
|
129
|
-
}
|
99
|
+
// Example usage:
|
100
|
+
//
|
101
|
+
// $effect(() => {
|
102
|
+
// if (variantsLoader.loaded) {
|
103
|
+
// // @ts-ignore
|
104
|
+
// imageUrl = variantsLoader.getObjectURL();
|
105
|
+
// }
|
106
|
+
|
107
|
+
// return () => {
|
108
|
+
// if (imageUrl) {
|
109
|
+
// URL.revokeObjectURL(imageUrl);
|
110
|
+
// imageUrl = null;
|
111
|
+
// }
|
112
|
+
// };
|
113
|
+
// });
|
114
|
+
|
115
|
+
const blob = this.#imageLoader?.getBlob();
|
116
|
+
|
117
|
+
const url = blob ? URL.createObjectURL(blob) : null;
|
130
118
|
|
131
119
|
return url;
|
132
120
|
}
|
133
121
|
|
134
122
|
get progress() {
|
135
|
-
|
136
|
-
return {
|
137
|
-
bytesLoaded: this.#baseProgress.bytesLoaded,
|
138
|
-
size: this.#baseProgress.size,
|
139
|
-
loaded: this.#variantLoaded
|
140
|
-
};
|
123
|
+
return this.#progress;
|
141
124
|
}
|
142
125
|
|
143
126
|
/**
|
@@ -158,6 +141,7 @@ export default class ImageVariantsLoader {
|
|
158
141
|
const imagesMeta = this.#imagesMeta;
|
159
142
|
|
160
143
|
// Find the smallest image that's larger than our required width
|
144
|
+
|
161
145
|
const optimal = imagesMeta.find(
|
162
146
|
(current) => current.width >= requiredWidth
|
163
147
|
);
|
@@ -165,4 +149,4 @@ export default class ImageVariantsLoader {
|
|
165
149
|
// Fall back to the largest image if nothing is big enough
|
166
150
|
return optimal || imagesMeta[imagesMeta.length - 1];
|
167
151
|
}
|
168
|
-
}
|
152
|
+
} // end class
|
@@ -1,18 +1,4 @@
|
|
1
1
|
export default HkArea;
|
2
|
-
type HkArea = {
|
3
|
-
$on?(type: string, callback: (e: any) => void): () => void;
|
4
|
-
$set?(props: Partial<{
|
5
|
-
base?: string;
|
6
|
-
bg?: string;
|
7
|
-
padding?: string;
|
8
|
-
margin?: string;
|
9
|
-
classes?: string;
|
10
|
-
style?: string;
|
11
|
-
children: Snippet<[]>;
|
12
|
-
} & {
|
13
|
-
[attr: string]: any;
|
14
|
-
}>): void;
|
15
|
-
};
|
16
2
|
declare const HkArea: import("svelte").Component<{
|
17
3
|
base?: string;
|
18
4
|
bg?: string;
|
@@ -1,26 +1,4 @@
|
|
1
1
|
export default HkGridArea;
|
2
|
-
type HkGridArea = {
|
3
|
-
$on?(type: string, callback: (e: any) => void): () => void;
|
4
|
-
$set?(props: Partial<{
|
5
|
-
base?: string;
|
6
|
-
bg?: string;
|
7
|
-
padding?: string;
|
8
|
-
margin?: string;
|
9
|
-
classes?: string;
|
10
|
-
style?: string;
|
11
|
-
boxBase?: string;
|
12
|
-
boxBg?: string;
|
13
|
-
boxPadding?: string;
|
14
|
-
boxMargin?: string;
|
15
|
-
boxClasses?: string;
|
16
|
-
boxAttrs?: {
|
17
|
-
[attr: string]: any;
|
18
|
-
};
|
19
|
-
children: Snippet<[]>;
|
20
|
-
} & {
|
21
|
-
[attr: string]: any;
|
22
|
-
}>): void;
|
23
|
-
};
|
24
2
|
declare const HkGridArea: import("svelte").Component<{
|
25
3
|
base?: string;
|
26
4
|
bg?: string;
|
@@ -1,25 +1,4 @@
|
|
1
1
|
export default Button;
|
2
|
-
type Button = {
|
3
|
-
$on?(type: string, callback: (e: any) => void): () => void;
|
4
|
-
$set?(props: Partial<{
|
5
|
-
[key: string]: any;
|
6
|
-
base?: string;
|
7
|
-
bg?: string;
|
8
|
-
classes?: string;
|
9
|
-
type?: string;
|
10
|
-
role?: "custom" | "primary" | "secondary" | "tertiary";
|
11
|
-
size?: "sm" | "md" | "lg";
|
12
|
-
variant?: string;
|
13
|
-
active?: boolean;
|
14
|
-
selected?: boolean;
|
15
|
-
loading?: boolean;
|
16
|
-
error?: boolean;
|
17
|
-
disabled?: boolean;
|
18
|
-
snippetLoading?: Snippet<[]>;
|
19
|
-
snippetError?: Snippet<[]>;
|
20
|
-
children: Snippet<[]>;
|
21
|
-
}>): void;
|
22
|
-
};
|
23
2
|
declare const Button: import("svelte").Component<{
|
24
3
|
[key: string]: any;
|
25
4
|
base?: string;
|