@hkdigital/lib-core 0.4.39 → 0.4.40
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/network/loaders/audio/AudioScene.svelte.d.ts +4 -11
- package/dist/network/loaders/audio/AudioScene.svelte.js +21 -15
- package/dist/network/loaders/audio/typedef.d.ts +20 -0
- package/dist/network/loaders/audio/typedef.js +13 -0
- package/dist/network/loaders/image/ImageLoader.svelte.d.ts +1 -1
- package/dist/network/loaders/image/typedef.d.ts +1 -14
- package/dist/network/loaders/image/typedef.js +1 -6
- package/dist/services/service-manager/ServiceManager.js +1 -1
- package/package.json +1 -1
|
@@ -29,16 +29,9 @@ export default class AudioScene extends SceneBase {
|
|
|
29
29
|
* Add in-memory audio source
|
|
30
30
|
* - Uses an AudioLoader instance to load audio data from network
|
|
31
31
|
*
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {string} _.label
|
|
34
|
-
* @param {string} _.url
|
|
35
|
-
* @param {SourceConfig} [_.config]
|
|
32
|
+
* @param {import('./typedef.js').MemorySourceParams} params
|
|
36
33
|
*/
|
|
37
|
-
defineMemorySource({ label, url, config }:
|
|
38
|
-
label: string;
|
|
39
|
-
url: string;
|
|
40
|
-
config?: object | undefined;
|
|
41
|
-
}): void;
|
|
34
|
+
defineMemorySource({ label, url, config }: import("./typedef.js").MemorySourceParams): void;
|
|
42
35
|
/**
|
|
43
36
|
* Get a source that can be used to play the audio once
|
|
44
37
|
*
|
|
@@ -63,9 +56,9 @@ export default class AudioScene extends SceneBase {
|
|
|
63
56
|
*/
|
|
64
57
|
setTargetGain(value: number): void;
|
|
65
58
|
/**
|
|
66
|
-
* Get the current target gain
|
|
59
|
+
* Get the current target gain
|
|
67
60
|
*
|
|
68
|
-
* @returns {number}
|
|
61
|
+
* @returns {number}
|
|
69
62
|
*/
|
|
70
63
|
getTargetGain(): number;
|
|
71
64
|
/**
|
|
@@ -25,19 +25,16 @@ export default class AudioScene extends SceneBase {
|
|
|
25
25
|
|
|
26
26
|
targetGain = $derived( this.#targetGain );
|
|
27
27
|
|
|
28
|
-
/** @type {AudioContext|
|
|
29
|
-
#audioContext
|
|
28
|
+
/** @type {AudioContext|undefined} */
|
|
29
|
+
#audioContext;
|
|
30
30
|
|
|
31
|
-
/** {GainNode} */
|
|
32
|
-
#targetGainNode
|
|
31
|
+
/** @type {GainNode|undefined} */
|
|
32
|
+
#targetGainNode;
|
|
33
33
|
|
|
34
34
|
/** @type {MemorySource[]} */
|
|
35
35
|
#memorySources = $state([]);
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
/**
|
|
39
|
-
* Construct AudioScene
|
|
40
|
-
*/
|
|
41
38
|
constructor() {
|
|
42
39
|
super();
|
|
43
40
|
}
|
|
@@ -71,10 +68,7 @@ export default class AudioScene extends SceneBase {
|
|
|
71
68
|
* Add in-memory audio source
|
|
72
69
|
* - Uses an AudioLoader instance to load audio data from network
|
|
73
70
|
*
|
|
74
|
-
* @param {
|
|
75
|
-
* @param {string} _.label
|
|
76
|
-
* @param {string} _.url
|
|
77
|
-
* @param {SourceConfig} [_.config]
|
|
71
|
+
* @param {import('./typedef.js').MemorySourceParams} params
|
|
78
72
|
*/
|
|
79
73
|
defineMemorySource({ label, url, config }) {
|
|
80
74
|
expect.notEmptyString(label);
|
|
@@ -95,8 +89,10 @@ export default class AudioScene extends SceneBase {
|
|
|
95
89
|
* @returns {Promise<AudioBufferSourceNode>}
|
|
96
90
|
*/
|
|
97
91
|
async getSourceNode(label) {
|
|
92
|
+
|
|
98
93
|
// @note Gain setup
|
|
99
|
-
// https://stackoverflow.com/
|
|
94
|
+
// https://stackoverflow.com/
|
|
95
|
+
// questions/46203191/should-i-disconnect-nodes-that-cant-be-used-anymore
|
|
100
96
|
|
|
101
97
|
const { audioLoader /*, config */ } = this.#getMemorySource(label);
|
|
102
98
|
|
|
@@ -149,9 +145,9 @@ export default class AudioScene extends SceneBase {
|
|
|
149
145
|
}
|
|
150
146
|
|
|
151
147
|
/**
|
|
152
|
-
* Get the current target gain
|
|
148
|
+
* Get the current target gain
|
|
153
149
|
*
|
|
154
|
-
* @returns {number}
|
|
150
|
+
* @returns {number}
|
|
155
151
|
*/
|
|
156
152
|
getTargetGain()
|
|
157
153
|
{
|
|
@@ -191,6 +187,11 @@ export default class AudioScene extends SceneBase {
|
|
|
191
187
|
|
|
192
188
|
/* ==== Internals */
|
|
193
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Get or create the master gain node
|
|
192
|
+
*
|
|
193
|
+
* @returns {GainNode}
|
|
194
|
+
*/
|
|
194
195
|
#getGainNode()
|
|
195
196
|
{
|
|
196
197
|
if( !this.#targetGainNode )
|
|
@@ -205,6 +206,11 @@ export default class AudioScene extends SceneBase {
|
|
|
205
206
|
return this.#targetGainNode;
|
|
206
207
|
}
|
|
207
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Get or create the audio context
|
|
211
|
+
*
|
|
212
|
+
* @returns {AudioContext}
|
|
213
|
+
*/
|
|
208
214
|
#getAudioContext()
|
|
209
215
|
{
|
|
210
216
|
if( !this.#audioContext )
|
|
@@ -216,7 +222,7 @@ export default class AudioScene extends SceneBase {
|
|
|
216
222
|
}
|
|
217
223
|
|
|
218
224
|
/**
|
|
219
|
-
*
|
|
225
|
+
* Find memory source by label
|
|
220
226
|
*
|
|
221
227
|
* @param {string} label
|
|
222
228
|
*
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const _default: {};
|
|
2
|
+
export default _default;
|
|
3
|
+
export type MemorySourceParams = {
|
|
4
|
+
/**
|
|
5
|
+
* - Source identifier
|
|
6
|
+
*/
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* - Audio file URL
|
|
10
|
+
*/
|
|
11
|
+
url: string;
|
|
12
|
+
/**
|
|
13
|
+
* - Optional source configuration
|
|
14
|
+
*/
|
|
15
|
+
config?: object | undefined;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* // property ...
|
|
19
|
+
*/
|
|
20
|
+
export type SourceConfig = object;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} MemorySourceParams
|
|
3
|
+
* @property {string} label - Source identifier
|
|
4
|
+
* @property {string} url - Audio file URL
|
|
5
|
+
* @property {SourceConfig} [config] - Optional source configuration
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {object} SourceConfig
|
|
10
|
+
* // property ...
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default {};
|
|
@@ -8,7 +8,7 @@ export default class ImageLoader extends NetworkLoader {
|
|
|
8
8
|
* @param {import('../../../config/typedef.js').ImageSource} imageSource
|
|
9
9
|
*/
|
|
10
10
|
constructor(imageSource: import("../../../config/typedef.js").ImageSource);
|
|
11
|
-
get imageMeta(): import("
|
|
11
|
+
get imageMeta(): import("../../../config/typedef.js").ImageMeta;
|
|
12
12
|
get url(): string | null;
|
|
13
13
|
#private;
|
|
14
14
|
}
|
|
@@ -1,16 +1,3 @@
|
|
|
1
1
|
declare const _default: {};
|
|
2
2
|
export default _default;
|
|
3
|
-
export type ImageMeta =
|
|
4
|
-
/**
|
|
5
|
-
* - URL of the image
|
|
6
|
-
*/
|
|
7
|
-
src: string;
|
|
8
|
-
/**
|
|
9
|
-
* - Width of the image
|
|
10
|
-
*/
|
|
11
|
-
width: number;
|
|
12
|
-
/**
|
|
13
|
-
* - Height of the image
|
|
14
|
-
*/
|
|
15
|
-
height: number;
|
|
16
|
-
};
|
|
3
|
+
export type ImageMeta = import("../../../config/typedef.js").ImageMeta;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} ImageMeta
|
|
3
|
-
* @property {string} src - URL of the image
|
|
4
|
-
* @property {number} width - Width of the image
|
|
5
|
-
* @property {number} height - Height of the image
|
|
6
|
-
*/
|
|
1
|
+
/** @typedef {import('../../../config/typedef.js').ImageMeta} ImageMeta */
|
|
7
2
|
|
|
8
3
|
export default {};
|
|
@@ -422,7 +422,7 @@ export class ServiceManager extends EventEmitter {
|
|
|
422
422
|
if (!result.ok) {
|
|
423
423
|
// Create detailed error with the actual service failure
|
|
424
424
|
const detailedError = new DetailedError(
|
|
425
|
-
`Failed to start service [${name}]
|
|
425
|
+
`Failed to start service [${name}]`,
|
|
426
426
|
null,
|
|
427
427
|
result.error
|
|
428
428
|
);
|