@hkdigital/lib-core 0.4.40 → 0.4.42

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.
@@ -1,13 +1,4 @@
1
- /**
2
- * @typedef {object} SourceConfig
3
- * // property ...
4
- */
5
- /**
6
- * @typedef {object} MemorySource
7
- * @property {string} label
8
- * @property {AudioLoader} audioLoader
9
- * @property {SourceConfig} [config]
10
- */
1
+ /** @typedef {import('./typedef.js').MemorySource} MemorySource */
11
2
  export default class AudioScene extends SceneBase {
12
3
  muted: boolean;
13
4
  targetGain: number;
@@ -77,14 +68,6 @@ export default class AudioScene extends SceneBase {
77
68
  unmute(): void;
78
69
  #private;
79
70
  }
80
- /**
81
- * // property ...
82
- */
83
- export type SourceConfig = object;
84
- export type MemorySource = {
85
- label: string;
86
- audioLoader: AudioLoader;
87
- config?: object | undefined;
88
- };
71
+ export type MemorySource = import("./typedef.js").MemorySource;
89
72
  import SceneBase from '../base/SceneBase.svelte.js';
90
73
  import AudioLoader from './AudioLoader.svelte.js';
@@ -3,17 +3,7 @@ import * as expect from '../../../util/expect.js';
3
3
  import SceneBase from '../base/SceneBase.svelte.js';
4
4
  import AudioLoader from './AudioLoader.svelte.js';
5
5
 
6
- /**
7
- * @typedef {object} SourceConfig
8
- * // property ...
9
- */
10
-
11
- /**
12
- * @typedef {object} MemorySource
13
- * @property {string} label
14
- * @property {AudioLoader} audioLoader
15
- * @property {SourceConfig} [config]
16
- */
6
+ /** @typedef {import('./typedef.js').MemorySource} MemorySource */
17
7
 
18
8
  export default class AudioScene extends SceneBase {
19
9
 
@@ -1,5 +1,9 @@
1
1
  declare const _default: {};
2
2
  export default _default;
3
+ /**
4
+ * // property ...
5
+ */
6
+ export type SourceConfig = object;
3
7
  export type MemorySourceParams = {
4
8
  /**
5
9
  * - Source identifier
@@ -14,7 +18,8 @@ export type MemorySourceParams = {
14
18
  */
15
19
  config?: object | undefined;
16
20
  };
17
- /**
18
- * // property ...
19
- */
20
- export type SourceConfig = object;
21
+ export type MemorySource = {
22
+ label: string;
23
+ audioLoader: import("./AudioLoader.svelte.js").default;
24
+ config?: object | undefined;
25
+ };
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @typedef {object} SourceConfig
3
+ * // property ...
4
+ */
5
+
1
6
  /**
2
7
  * @typedef {object} MemorySourceParams
3
8
  * @property {string} label - Source identifier
@@ -6,8 +11,10 @@
6
11
  */
7
12
 
8
13
  /**
9
- * @typedef {object} SourceConfig
10
- * // property ...
14
+ * @typedef {object} MemorySource
15
+ * @property {string} label
16
+ * @property {import('./AudioLoader.svelte.js').default} audioLoader
17
+ * @property {SourceConfig} [config]
11
18
  */
12
19
 
13
20
  export default {};
@@ -1,3 +1,4 @@
1
+ /** @typedef {import('./typedef.js').SceneLoadingProgress} SceneLoadingProgress */
1
2
  /**
2
3
  * Base class for scene loaders that manage collections of media sources
3
4
  */
@@ -13,20 +14,15 @@ export default class SceneBase {
13
14
  /**
14
15
  * Extract the loader from a source object
15
16
  *
16
- * @param {*} source
17
+ * @param {object} source - Source object
17
18
  *
18
- * @returns {*} Loader object with progress and state properties
19
+ * @returns {import('../../states/index.js').NetworkLoader} loader
19
20
  */
20
- getLoaderFromSource(source: any): any;
21
+ getLoaderFromSource(source: object): import("../../states/index.js").NetworkLoader;
21
22
  /**
22
23
  * Get scene loading progress
23
24
  */
24
- get progress(): {
25
- totalBytesLoaded: number;
26
- totalSize: number;
27
- sourcesLoaded: number;
28
- numberOfSources: number;
29
- };
25
+ get progress(): import("./typedef.js").SceneLoadingProgress;
30
26
  /**
31
27
  * Get scene abort progress
32
28
  */
@@ -44,22 +40,24 @@ export default class SceneBase {
44
40
  abort(): void;
45
41
  /**
46
42
  * Preload all sources with progress tracking and abort capability
47
- * - Starts loading and waits for completion
48
- * - Supports timeout and progress callbacks
49
- * - Returns object with promise and abort function
50
43
  *
51
44
  * @param {object} [options]
52
- * @param {number} [options.timeoutMs=10000] - Timeout in milliseconds
53
- * @param {Function} [options.onProgress] - Progress callback function
45
+ * @param {number} [options.timeoutMs=10000]
46
+ * Timeout in milliseconds
47
+ * @param {(progress: SceneLoadingProgress) => void} [options.onProgress]
48
+ * Progress callback function
54
49
  *
55
- * @returns {object} Object with promise and abort function
56
- * @returns {Promise<SceneBase>} returns.promise - Promise that resolves when loaded
57
- * @returns {Function} returns.abort - Function to abort preloading
50
+ * @returns {{promise: Promise<SceneBase>, abort: Function}}
51
+ * Object with promise that resolves when loaded and abort function
58
52
  */
59
53
  preload({ timeoutMs, onProgress }?: {
60
54
  timeoutMs?: number | undefined;
61
- onProgress?: Function | undefined;
62
- }): object;
55
+ onProgress?: ((progress: SceneLoadingProgress) => void) | undefined;
56
+ }): {
57
+ promise: Promise<SceneBase>;
58
+ abort: Function;
59
+ };
63
60
  destroy(): void;
64
61
  #private;
65
62
  }
63
+ export type SceneLoadingProgress = import("./typedef.js").SceneLoadingProgress;
@@ -15,6 +15,8 @@ import {
15
15
 
16
16
  import { waitForState } from '../../../util/svelte.js';
17
17
 
18
+ /** @typedef {import('./typedef.js').SceneLoadingProgress} SceneLoadingProgress */
19
+
18
20
  /**
19
21
  * Base class for scene loaders that manage collections of media sources
20
22
  */
@@ -28,6 +30,7 @@ export default class SceneBase {
28
30
  return this.state === STATE_LOADED;
29
31
  });
30
32
 
33
+ /** @type {SceneLoadingProgress} */
31
34
  #progress = $derived.by(() => {
32
35
  let totalSize = 0;
33
36
  let totalBytesLoaded = 0;
@@ -130,9 +133,9 @@ export default class SceneBase {
130
133
  /**
131
134
  * Extract the loader from a source object
132
135
  *
133
- * @param {*} source
136
+ * @param {object} source - Source object
134
137
  *
135
- * @returns {*} Loader object with progress and state properties
138
+ * @returns {import('../../states/index.js').NetworkLoader} loader
136
139
  */
137
140
  // eslint-disable-next-line no-unused-vars
138
141
  getLoaderFromSource(source) {
@@ -171,21 +174,24 @@ export default class SceneBase {
171
174
 
172
175
  /**
173
176
  * Preload all sources with progress tracking and abort capability
174
- * - Starts loading and waits for completion
175
- * - Supports timeout and progress callbacks
176
- * - Returns object with promise and abort function
177
177
  *
178
178
  * @param {object} [options]
179
- * @param {number} [options.timeoutMs=10000] - Timeout in milliseconds
180
- * @param {Function} [options.onProgress] - Progress callback function
179
+ * @param {number} [options.timeoutMs=10000]
180
+ * Timeout in milliseconds
181
+ * @param {(progress: SceneLoadingProgress) => void} [options.onProgress]
182
+ * Progress callback function
181
183
  *
182
- * @returns {object} Object with promise and abort function
183
- * @returns {Promise<SceneBase>} returns.promise - Promise that resolves when loaded
184
- * @returns {Function} returns.abort - Function to abort preloading
184
+ * @returns {{promise: Promise<SceneBase>, abort: Function}}
185
+ * Object with promise that resolves when loaded and abort function
185
186
  */
186
187
  preload({ timeoutMs = 10000, onProgress } = {}) {
188
+
189
+ /** @type {number|NodeJS.Timeout|null} */
187
190
  let timeoutId = null;
191
+
192
+ /** @type {number|NodeJS.Timeout|null} */
188
193
  let progressIntervalId = null;
194
+
189
195
  let isAborted = false;
190
196
 
191
197
  const abort = () => {
@@ -0,0 +1,20 @@
1
+ declare const _default: {};
2
+ export default _default;
3
+ export type SceneLoadingProgress = {
4
+ /**
5
+ * - Total bytes loaded across all sources
6
+ */
7
+ totalBytesLoaded: number;
8
+ /**
9
+ * - Total size across all sources
10
+ */
11
+ totalSize: number;
12
+ /**
13
+ * - Number of sources fully loaded
14
+ */
15
+ sourcesLoaded: number;
16
+ /**
17
+ * - Total number of sources
18
+ */
19
+ numberOfSources: number;
20
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @typedef {Object} SceneLoadingProgress
3
+ * @property {number} totalBytesLoaded - Total bytes loaded across all sources
4
+ * @property {number} totalSize - Total size across all sources
5
+ * @property {number} sourcesLoaded - Number of sources fully loaded
6
+ * @property {number} numberOfSources - Total number of sources
7
+ */
8
+
9
+ export default {};
@@ -1,7 +1,3 @@
1
- /**
2
- * @typedef {object} SourceConfig
3
- * // property ...
4
- */
5
1
  /**
6
2
  * @typedef {object} ImageSceneSource
7
3
  * @property {string} label
@@ -63,10 +59,6 @@ export default class ImageScene extends SceneBase {
63
59
  #private;
64
60
  }
65
61
  export type ImageMeta = import("./typedef.js").ImageMeta;
66
- /**
67
- * // property ...
68
- */
69
- export type SourceConfig = object;
70
62
  export type ImageSceneSource = {
71
63
  label: string;
72
64
  imageLoader: ImageLoader;
@@ -5,11 +5,6 @@ import * as expect from '../../../util/expect.js';
5
5
  import SceneBase from '../base/SceneBase.svelte.js';
6
6
  import ImageLoader from './ImageLoader.svelte.js';
7
7
 
8
- /**
9
- * @typedef {object} SourceConfig
10
- * // property ...
11
- */
12
-
13
8
  /**
14
9
  * @typedef {object} ImageSceneSource
15
10
  * @property {string} label
@@ -1,3 +1,6 @@
1
+ export * from "./audio/typedef.js";
2
+ export * from "./base/typedef.js";
3
+ export * from "./image/typedef.js";
1
4
  declare const _default: {};
2
5
  export default _default;
3
6
  export type ObjectPosition = "center" | "top" | "bottom" | "left" | "right" | "left top" | "left center" | "left bottom" | "center top" | "center center" | "center bottom" | "right top" | "right center" | "right bottom" | string;
@@ -23,4 +23,8 @@
23
23
  * "2em center" // Length + keyword
24
24
  */
25
25
 
26
+ export * from './audio/typedef.js';
27
+ export * from './base/typedef.js';
28
+ export * from './image/typedef.js';
29
+
26
30
  export default {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.4.40",
3
+ "version": "0.4.42",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"