@hkdigital/lib-sveltekit 0.0.88 → 0.0.90

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.
@@ -10,7 +10,14 @@ import {
10
10
  * - The loading process can be monitored
11
11
  */
12
12
  export default class ImageLoader extends NetworkLoader {
13
- // > Inherited methods
13
+ //
14
+ // /**
15
+ // * Construct ImageLoader
16
+ // *
17
+ // * @param {object} _
18
+ // * @param {string} _.url
19
+ // */
20
+ // constructor( { url } ) {}
14
21
  //
15
22
  // /**
16
23
  // * Get object URL that can be used as src parameter of an HTML image
@@ -1,4 +1,4 @@
1
- export default class ImageMetasLoader {
1
+ export default class ImageVariantsLoader {
2
2
  /**
3
3
  * @param {ImageMeta[]} imagesMeta
4
4
  */
@@ -6,7 +6,7 @@ import { untrack } from 'svelte';
6
6
 
7
7
  import ImageLoader from './ImageLoader.svelte.js';
8
8
 
9
- export default class ImageMetasLoader {
9
+ export default class ImageVariantsLoader {
10
10
  /** @type {number} */
11
11
  #devicePixelRatio;
12
12
 
@@ -69,11 +69,7 @@ export default class ImageMetasLoader {
69
69
  updateOptimalImageMeta(containerWidth) {
70
70
  const newVariant = this.getOptimalImageMeta(containerWidth);
71
71
 
72
- if (
73
- !newVariant ||
74
- !this.#imageVariant ||
75
- newVariant.width > this.#imageVariant.width
76
- ) {
72
+ if (!newVariant || !this.#imageVariant || newVariant.width > this.#imageVariant.width) {
77
73
  // Only update imageVariant is width is larger
78
74
  this.#imageVariant = newVariant;
79
75
  }
@@ -141,9 +137,7 @@ export default class ImageMetasLoader {
141
137
 
142
138
  // Find the smallest image that's larger than our required width
143
139
 
144
- const optimal = imagesMeta.find(
145
- (current) => current.width >= requiredWidth
146
- );
140
+ const optimal = imagesMeta.find((current) => current.width >= requiredWidth);
147
141
 
148
142
  // Fall back to the largest image if nothing is big enough
149
143
  return optimal || imagesMeta[imagesMeta.length - 1];
@@ -1,2 +1,2 @@
1
1
  export { default as ImageLoader } from "./ImageLoader.svelte";
2
- export { default as ImageMetasLoader } from "./ImageMetasLoader.svelte";
2
+ export { default as ImageVariantsLoader } from "./ImageVariantsLoader.svelte";
@@ -1,4 +1,4 @@
1
1
  export { default as ImageLoader } from './ImageLoader.svelte';
2
- export { default as ImageMetasLoader } from './ImageMetasLoader.svelte';
2
+ export { default as ImageVariantsLoader } from './ImageVariantsLoader.svelte';
3
3
 
4
4
  // export * from './constants.js';
@@ -15,6 +15,7 @@ export default class NetworkLoader {
15
15
  });
16
16
  _state: LoadingStateMachine;
17
17
  state: string;
18
+ initial: boolean;
18
19
  loaded: boolean;
19
20
  /** @type {string|null} */
20
21
  _url: string | null;
@@ -33,6 +33,10 @@ export default class NetworkLoader {
33
33
  // @note this exported state is set by $effect's
34
34
  state = $state(STATE_INITIAL);
35
35
 
36
+ initial = $derived.by(() => {
37
+ return this.state === STATE_INITIAL;
38
+ });
39
+
36
40
  loaded = $derived.by(() => {
37
41
  return this.state === STATE_LOADED;
38
42
  });
@@ -1,7 +1,7 @@
1
1
  <script>
2
2
  /** @typedef {import('../../types/imagetools.js').ImageMeta} ImageMeta */
3
3
 
4
- import { ImageMetasLoader } from '../../classes/svelte/image/index.js';
4
+ import { ImageVariantsLoader } from '../../classes/svelte/image/index.js';
5
5
 
6
6
  /**
7
7
  * @type {{
@@ -29,7 +29,7 @@
29
29
  ...attrs
30
30
  } = $props();
31
31
 
32
- let variantsLoader = new ImageMetasLoader(images);
32
+ let variantsLoader = new ImageVariantsLoader(images);
33
33
 
34
34
  let containerWidth = $state(0);
35
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.0.88",
3
+ "version": "0.0.90",
4
4
  "author": "Jens Kleinhout, HKdigital (https://hkdigital.nl)",
5
5
  "license": "ISC",
6
6
  "repository": {