@hkdigital/lib-core 0.4.44 → 0.4.45

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,8 @@ import {
10
10
  LOAD,
11
11
  LOADED,
12
12
  ABORT,
13
- ABORTED
13
+ ABORTED,
14
+ ERROR
14
15
  } from '../../../state/machines.js';
15
16
 
16
17
  import { waitForState } from '../../../util/svelte.js';
@@ -108,6 +109,20 @@ export default class SceneBase {
108
109
  }
109
110
  });
110
111
 
112
+ $effect(() => {
113
+ if (this.#state.current === STATE_LOADING) {
114
+ // Check if any source failed during loading
115
+ const sources = this.sources;
116
+ for (const source of sources) {
117
+ const loader = this.getLoaderFromSource(source);
118
+ if (loader.state === STATE_ERROR) {
119
+ this.#state.send(ERROR, loader.error || new Error('Source loading failed'));
120
+ break;
121
+ }
122
+ }
123
+ }
124
+ });
125
+
111
126
  state.onenter = (currentState) => {
112
127
  if (currentState === STATE_LOADING) {
113
128
  this.#startLoading();
@@ -253,7 +268,7 @@ export default class SceneBase {
253
268
  if (isAborted || this.state === STATE_ABORTED) {
254
269
  reject(new Error('Preload was aborted'));
255
270
  } else if (this.state === STATE_ERROR) {
256
- reject(new Error('Preload failed due to error'));
271
+ reject(this.#state.error);
257
272
  } else if (this.loaded) {
258
273
  resolve(this);
259
274
  } else {
@@ -65,6 +65,7 @@ export default class LoadingStateMachine extends FiniteStateMachine {
65
65
  },
66
66
  [STATE_ABORTED]: {
67
67
  [LOAD]: STATE_LOADING,
68
+ [LOADED]: STATE_LOADED,
68
69
  [UNLOAD]: STATE_UNLOADING
69
70
  },
70
71
  [STATE_TIMEOUT]: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.4.44",
3
+ "version": "0.4.45",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"