@hkdigital/lib-sveltekit 0.1.28 → 0.1.29

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.
@@ -0,0 +1,17 @@
1
+ export const carPaintImages: {
2
+ rusty: import("../../config/typedef.js").ImageMeta[];
3
+ "army-green": import("../../config/typedef.js").ImageMeta[];
4
+ "electric-blue": import("../../config/typedef.js").ImageMeta[];
5
+ "lemon-yellow": import("../../config/typedef.js").ImageMeta[];
6
+ "opaque-purple": import("../../config/typedef.js").ImageMeta[];
7
+ "sunset-orange": import("../../config/typedef.js").ImageMeta[];
8
+ "tomato-red": import("../../config/typedef.js").ImageMeta[];
9
+ };
10
+ import Rusty from './car-paint-picker/rusty.jpg?preset=render&responsive';
11
+ import ArmyGreen from './car-paint-picker/army-green.jpg?preset=render&responsive';
12
+ import ElectricBlue from './car-paint-picker/electric-blue.jpg?preset=render&responsive';
13
+ import LemonYellow from './car-paint-picker/lemon-yellow.jpg?preset=render&responsive';
14
+ import OpaquePurple from './car-paint-picker/opaque-purple.jpg?preset=render&responsive';
15
+ import SunsetOrange from './car-paint-picker/sunset-orange.jpg?preset=render&responsive';
16
+ import TomatoRed from './car-paint-picker/tomato-red.jpg?preset=render&responsive';
17
+ export { Rusty, ArmyGreen, ElectricBlue, LemonYellow, OpaquePurple, SunsetOrange, TomatoRed };
@@ -0,0 +1,41 @@
1
+ import {
2
+ LABEL_RUSTY,
3
+ LABEL_ARMY_GREEN,
4
+ LABEL_ELECTRIC_BLUE,
5
+ LABEL_LEMON_YELLOW,
6
+ LABEL_OPAQUE_PURPLE,
7
+ LABEL_SUNSET_ORANGE,
8
+ LABEL_TOMATO_RED
9
+ } from './labels.js';
10
+
11
+ import Rusty from './car-paint-picker/rusty.jpg?preset=render&responsive';
12
+
13
+ import ArmyGreen from './car-paint-picker/army-green.jpg?preset=render&responsive';
14
+ import ElectricBlue from './car-paint-picker/electric-blue.jpg?preset=render&responsive';
15
+ import LemonYellow from './car-paint-picker/lemon-yellow.jpg?preset=render&responsive';
16
+ import OpaquePurple from './car-paint-picker/opaque-purple.jpg?preset=render&responsive';
17
+ import SunsetOrange from './car-paint-picker/sunset-orange.jpg?preset=render&responsive';
18
+ import TomatoRed from './car-paint-picker/tomato-red.jpg?preset=render&responsive';
19
+
20
+ // console.log('ArmyGreen', ArmyGreen);
21
+
22
+ export const carPaintImages = {
23
+ [LABEL_RUSTY]: Rusty,
24
+ [LABEL_ARMY_GREEN]: ArmyGreen,
25
+ [LABEL_ELECTRIC_BLUE]: ElectricBlue,
26
+ [LABEL_LEMON_YELLOW]: LemonYellow,
27
+ [LABEL_OPAQUE_PURPLE]: OpaquePurple,
28
+ [LABEL_SUNSET_ORANGE]: SunsetOrange,
29
+ [LABEL_TOMATO_RED]: TomatoRed
30
+ };
31
+
32
+ /* Also export as individual images */
33
+ export {
34
+ Rusty,
35
+ ArmyGreen,
36
+ ElectricBlue,
37
+ LemonYellow,
38
+ OpaquePurple,
39
+ SunsetOrange,
40
+ TomatoRed
41
+ };
@@ -0,0 +1,7 @@
1
+ export const LABEL_RUSTY: "rusty";
2
+ export const LABEL_ARMY_GREEN: "army-green";
3
+ export const LABEL_ELECTRIC_BLUE: "electric-blue";
4
+ export const LABEL_LEMON_YELLOW: "lemon-yellow";
5
+ export const LABEL_OPAQUE_PURPLE: "opaque-purple";
6
+ export const LABEL_SUNSET_ORANGE: "sunset-orange";
7
+ export const LABEL_TOMATO_RED: "tomato-red";
@@ -0,0 +1,7 @@
1
+ export const LABEL_RUSTY = 'rusty';
2
+ export const LABEL_ARMY_GREEN = 'army-green';
3
+ export const LABEL_ELECTRIC_BLUE = 'electric-blue';
4
+ export const LABEL_LEMON_YELLOW = 'lemon-yellow';
5
+ export const LABEL_OPAQUE_PURPLE = 'opaque-purple';
6
+ export const LABEL_SUNSET_ORANGE = 'sunset-orange';
7
+ export const LABEL_TOMATO_RED = 'tomato-red';
@@ -166,28 +166,6 @@ export class PresenterState {
166
166
  return updatedLayer;
167
167
  }
168
168
 
169
- // /**
170
- // * Set up reactivity for tracking transition promises
171
- // * This handles the completion of animations and layer swapping
172
- // */
173
- // #setupTransitionTracking() {
174
- // $effect(() => {
175
- // const promises = this.transitionPromises;
176
-
177
- // if (promises.length > 0) {
178
- // const nextSlide = this.#getSlide(this.nextLayerLabel);
179
-
180
- // if (!nextSlide) {
181
- // return;
182
- // }
183
-
184
- // untrack(() => {
185
- // this.#executeTransition(promises);
186
- // });
187
- // }
188
- // });
189
- // }
190
-
191
169
  /**
192
170
  * Execute the transition by waiting for all promises and then
193
171
  * completing the transition
@@ -334,16 +312,16 @@ export class PresenterState {
334
312
  }
335
313
  };
336
314
 
337
- // console.debug('Checkpoint 1');
315
+ console.debug('Checkpoint 1');
338
316
 
339
317
  // Add next slide to next layer
340
318
  this.#updateSlide(this.nextLayerLabel, slideWithProps);
341
319
 
342
- // console.debug('Checkpoint 2');
320
+ console.debug('Checkpoint 2');
343
321
 
344
322
  await tick();
345
323
 
346
- // console.debug('Checkpoint 3');
324
+ console.debug('Checkpoint 3');
347
325
 
348
326
  if (this.slideLoadingPromise) {
349
327
  // console.debug('Waiting for slide to load');
@@ -356,7 +334,7 @@ export class PresenterState {
356
334
  const currentSlide = this.#getSlide(this.currentLayerLabel);
357
335
  const nextSlide = this.#getSlide(this.nextLayerLabel);
358
336
 
359
- // console.debug('Checkpoint 4');
337
+ console.debug('Checkpoint 4');
360
338
 
361
339
  // Make next layer visible, move to front, and prepare for
362
340
  // transition in
@@ -376,11 +354,13 @@ export class PresenterState {
376
354
  transitions: currentSlide?.outro ?? []
377
355
  });
378
356
 
379
- // console.debug('Checkpoint 5');
357
+ console.debug('Checkpoint 5');
380
358
 
381
359
  // Start transitions
382
360
  this.#applyTransitions();
383
361
 
362
+ // FIXME: wait?
363
+
384
364
  await this.#executeTransition(this.transitionPromises);
385
365
 
386
366
  // Check if there's a pending slide transition
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { PresenterState } from './Presenter.state.svelte.js';
7
7
  import { getPresenterState } from './index.js';
8
- import { cssBefore, cssDuring } from './util.js';
8
+ import { cssBefore, cssDuring, waitForRender } from './util.js';
9
9
 
10
10
  /* ------------------------------------------------------------------ Props */
11
11
 
@@ -41,7 +41,7 @@
41
41
  // State
42
42
  instanceKey,
43
43
 
44
- presenter = $bindable(new PresenterState()),
44
+ // presenter = $bindable(),
45
45
 
46
46
  // Snippets
47
47
  layoutSnippet,
@@ -52,7 +52,7 @@
52
52
 
53
53
  // FIXME: Using getPresenterState to force creation of presenter outside
54
54
  // the component. Otherwise transitions doe not work somehow..
55
- presenter = getPresenterState(instanceKey);
55
+ const presenter = getPresenterState(instanceKey);
56
56
 
57
57
  // > State
58
58
 
@@ -79,7 +79,7 @@
79
79
  if (stageBeforeIn || stageBeforeOut) {
80
80
  ({ style: stylesA, classes: classesA } = cssBefore(transitions));
81
81
  } else if (stageIn || stageOut) {
82
- setTimeout(() => {
82
+ waitForRender(() => {
83
83
  ({ style: stylesA, classes: classesA } = cssDuring(transitions));
84
84
  });
85
85
  }
@@ -99,7 +99,7 @@
99
99
  if (stageBeforeIn || stageBeforeOut) {
100
100
  ({ style: stylesB, classes: classesB } = cssBefore(transitions));
101
101
  } else if (stageIn || stageOut) {
102
- setTimeout(() => {
102
+ waitForRender(() => {
103
103
  ({ style: stylesB, classes: classesB } = cssDuring(transitions));
104
104
  });
105
105
  }
@@ -8,4 +8,4 @@ declare const Presenter: import("svelte").Component<{
8
8
  presenter?: import("./Presenter.state.svelte.js").PresenterState;
9
9
  layoutSnippet: import("svelte").Snippet<[import("./typedef.js").Slide | null, import("./typedef.js").Layer]>;
10
10
  loadingSnippet?: import("svelte").Snippet;
11
- }, {}, "presenter">;
11
+ }, {}, "">;
@@ -1,8 +1,15 @@
1
1
  /**
2
2
  * @typedef {import("./typedef").Transition} Transition
3
3
  */
4
- /** ----------------------------------------------------------------- Exports */
5
- /** ----------------------------------- Generate CSS for lists of transitions */
4
+ /**
5
+ * Ensures DOM is updated by Svelte and then painted by the browser
6
+ * before executing the callback function.
7
+ *
8
+ * @param {Function} callback - Function to execute after DOM update and paint
9
+ * @returns {Promise<void>} - Promise that resolves after the callback is executed
10
+ */
11
+ export function waitForRender(callback: Function): Promise<void>;
12
+ /** === Generate CSS for lists of transitions */
6
13
  /**
7
14
  * Generates style and class names to be used before the transitions
8
15
  * become active
@@ -26,7 +33,7 @@ export function cssDuring(transitions: Transition[]): {
26
33
  style: string;
27
34
  classes: string;
28
35
  };
29
- /** ------------------------------------- Generate CSS for single transitions */
36
+ /** === Generate CSS for single transitions */
30
37
  /**
31
38
  * Generates style and class names for specified transition for
32
39
  * the stage 'stageBeforeIn'
@@ -1,3 +1,5 @@
1
+ import { tick } from 'svelte';
2
+
1
3
  import * as expect from '../../util/expect/index.js';
2
4
 
3
5
  import { pushNotEmpty } from '../../util/array/index.js';
@@ -8,9 +10,27 @@ import { TRANSITION_CSS, FADE_IN, FADE_OUT } from './constants.js';
8
10
  * @typedef {import("./typedef").Transition} Transition
9
11
  */
10
12
 
11
- /** ----------------------------------------------------------------- Exports */
13
+ /**
14
+ * Ensures DOM is updated by Svelte and then painted by the browser
15
+ * before executing the callback function.
16
+ *
17
+ * @param {Function} callback - Function to execute after DOM update and paint
18
+ * @returns {Promise<void>} - Promise that resolves after the callback is executed
19
+ */
20
+ export function waitForRender(callback) {
21
+ return tick().then(() => {
22
+ return new Promise((resolve) => {
23
+ requestAnimationFrame(() => {
24
+ requestAnimationFrame(() => {
25
+ callback();
26
+ resolve();
27
+ });
28
+ });
29
+ });
30
+ });
31
+ }
12
32
 
13
- /** ----------------------------------- Generate CSS for lists of transitions */
33
+ /** === Generate CSS for lists of transitions */
14
34
 
15
35
  /**
16
36
  * Generates style and class names to be used before the transitions
@@ -79,7 +99,7 @@ export function cssDuring(transitions) {
79
99
  return { style, classes: classesArr.join() };
80
100
  }
81
101
 
82
- /** ------------------------------------- Generate CSS for single transitions */
102
+ /** === Generate CSS for single transitions */
83
103
 
84
104
  /**
85
105
  * Generates style and class names for specified transition for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"