@vnejs/module.controller.audio 0.2.1
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/index.d.ts +24 -0
- package/dist/index.js +27 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +1 -0
- package/package.json +40 -0
- package/src/index.ts +61 -0
- package/src/types.ts +10 -0
- package/tsconfig.json +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
import type { ModuleControllerAudioConstants, ModuleControllerAudioEvents, ModuleControllerAudioParams, ModuleControllerAudioSettings } from "./types.js";
|
|
3
|
+
export type { ModuleControllerAudioConstants, ModuleControllerAudioEvents, ModuleControllerAudioParams, ModuleControllerAudioSettings, } from "./types.js";
|
|
4
|
+
export declare abstract class ModuleControllerAudio<TEvents extends ModuleControllerAudioEvents = ModuleControllerAudioEvents, TConstants extends ModuleControllerAudioConstants = ModuleControllerAudioConstants, TSettings extends ModuleControllerAudioSettings = ModuleControllerAudioSettings, TParams extends ModuleControllerAudioParams = ModuleControllerAudioParams, TState = unknown> extends ModuleCore<TEvents, TConstants, TSettings, TParams, TState> {
|
|
5
|
+
abstract name: string;
|
|
6
|
+
abstract AUDIO_NAME: string;
|
|
7
|
+
abstract AUDIO_START_DURATION: number;
|
|
8
|
+
abstract SHOW_EVENT: string;
|
|
9
|
+
abstract HIDE_EVENT: string;
|
|
10
|
+
abstract LOAD_EVENT: string;
|
|
11
|
+
PARAMS_ALL: {
|
|
12
|
+
layer: string;
|
|
13
|
+
name: string;
|
|
14
|
+
duration: number;
|
|
15
|
+
};
|
|
16
|
+
PARAMS_DURATION: {
|
|
17
|
+
duration: number;
|
|
18
|
+
};
|
|
19
|
+
subscribe: () => void;
|
|
20
|
+
init: () => void;
|
|
21
|
+
onShow: () => void;
|
|
22
|
+
onHide: () => void;
|
|
23
|
+
onLoad: () => undefined;
|
|
24
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
export class ModuleControllerAudio extends ModuleCore {
|
|
3
|
+
PARAMS_ALL;
|
|
4
|
+
PARAMS_DURATION;
|
|
5
|
+
subscribe = () => {
|
|
6
|
+
if (!this.AUDIO_NAME)
|
|
7
|
+
return;
|
|
8
|
+
this.on(this.SHOW_EVENT, this.onShow);
|
|
9
|
+
this.on(this.HIDE_EVENT, this.onHide);
|
|
10
|
+
this.on(this.LOAD_EVENT, this.onLoad);
|
|
11
|
+
this.on(this.EVENTS.STATE.SET, this.onHide);
|
|
12
|
+
this.on(this.EVENTS.STATE.CLEAR, this.onHide);
|
|
13
|
+
};
|
|
14
|
+
init = () => {
|
|
15
|
+
this.PARAMS_ALL = { layer: "view", name: this.AUDIO_NAME, duration: this.AUDIO_START_DURATION };
|
|
16
|
+
this.PARAMS_DURATION = { duration: this.AUDIO_START_DURATION };
|
|
17
|
+
};
|
|
18
|
+
onShow = () => {
|
|
19
|
+
this.emit(this.EVENTS.AUDIO.GLOBAL_PAUSE, this.PARAMS_DURATION);
|
|
20
|
+
this.emit(this.EVENTS.AUDIO.PLAY, this.PARAMS_ALL);
|
|
21
|
+
};
|
|
22
|
+
onHide = () => {
|
|
23
|
+
this.emit(this.EVENTS.AUDIO.STOP, this.PARAMS_ALL);
|
|
24
|
+
this.emit(this.EVENTS.AUDIO.GLOBAL_RESUME, this.PARAMS_DURATION);
|
|
25
|
+
};
|
|
26
|
+
onLoad = () => void this.emit(this.EVENTS.AUDIO.MEDIA_LOAD, this.PARAMS_ALL);
|
|
27
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { PluginName as AudioPluginName, SubscribeEvents as AudioSubscribeEvents } from "@vnejs/contracts.audio";
|
|
3
|
+
export type ModuleControllerAudioEvents = ModuleCoreEvents & Record<AudioPluginName, AudioSubscribeEvents>;
|
|
4
|
+
export type ModuleControllerAudioConstants = ModuleCoreConstants;
|
|
5
|
+
export type ModuleControllerAudioSettings = ModuleCoreSettings;
|
|
6
|
+
export type ModuleControllerAudioParams = ModuleCoreParams;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/module.controller.audio",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"tsconfig.json"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
23
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
24
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
25
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
26
|
+
},
|
|
27
|
+
"author": "",
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@vnejs/module.core": "~0.2.0",
|
|
31
|
+
"@vnejs/contracts.audio": "~0.2.0",
|
|
32
|
+
"@vnejs/shared": "~0.2.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@vnejs/configs.ts-common": "~0.2.0",
|
|
36
|
+
"@vnejs/module.core": "~0.2.0",
|
|
37
|
+
"@vnejs/contracts.audio": "~0.2.0",
|
|
38
|
+
"@vnejs/shared": "~0.2.0"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ModuleControllerAudioConstants,
|
|
5
|
+
ModuleControllerAudioEvents,
|
|
6
|
+
ModuleControllerAudioParams,
|
|
7
|
+
ModuleControllerAudioSettings,
|
|
8
|
+
} from "./types.js";
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
ModuleControllerAudioConstants,
|
|
12
|
+
ModuleControllerAudioEvents,
|
|
13
|
+
ModuleControllerAudioParams,
|
|
14
|
+
ModuleControllerAudioSettings,
|
|
15
|
+
} from "./types.js";
|
|
16
|
+
|
|
17
|
+
export abstract class ModuleControllerAudio<
|
|
18
|
+
TEvents extends ModuleControllerAudioEvents = ModuleControllerAudioEvents,
|
|
19
|
+
TConstants extends ModuleControllerAudioConstants = ModuleControllerAudioConstants,
|
|
20
|
+
TSettings extends ModuleControllerAudioSettings = ModuleControllerAudioSettings,
|
|
21
|
+
TParams extends ModuleControllerAudioParams = ModuleControllerAudioParams,
|
|
22
|
+
TState = unknown,
|
|
23
|
+
> extends ModuleCore<TEvents, TConstants, TSettings, TParams, TState> {
|
|
24
|
+
abstract override name: string;
|
|
25
|
+
|
|
26
|
+
abstract AUDIO_NAME: string;
|
|
27
|
+
abstract AUDIO_START_DURATION: number;
|
|
28
|
+
|
|
29
|
+
abstract SHOW_EVENT: string;
|
|
30
|
+
abstract HIDE_EVENT: string;
|
|
31
|
+
abstract LOAD_EVENT: string;
|
|
32
|
+
|
|
33
|
+
PARAMS_ALL!: { layer: string; name: string; duration: number };
|
|
34
|
+
PARAMS_DURATION!: { duration: number };
|
|
35
|
+
|
|
36
|
+
subscribe = () => {
|
|
37
|
+
if (!this.AUDIO_NAME) return;
|
|
38
|
+
|
|
39
|
+
this.on(this.SHOW_EVENT, this.onShow);
|
|
40
|
+
this.on(this.HIDE_EVENT, this.onHide);
|
|
41
|
+
this.on(this.LOAD_EVENT, this.onLoad);
|
|
42
|
+
|
|
43
|
+
this.on(this.EVENTS.STATE.SET, this.onHide);
|
|
44
|
+
this.on(this.EVENTS.STATE.CLEAR, this.onHide);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
init = () => {
|
|
48
|
+
this.PARAMS_ALL = { layer: "view", name: this.AUDIO_NAME, duration: this.AUDIO_START_DURATION };
|
|
49
|
+
this.PARAMS_DURATION = { duration: this.AUDIO_START_DURATION };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
onShow = () => {
|
|
53
|
+
this.emit(this.EVENTS.AUDIO.GLOBAL_PAUSE, this.PARAMS_DURATION);
|
|
54
|
+
this.emit(this.EVENTS.AUDIO.PLAY, this.PARAMS_ALL);
|
|
55
|
+
};
|
|
56
|
+
onHide = () => {
|
|
57
|
+
this.emit(this.EVENTS.AUDIO.STOP, this.PARAMS_ALL);
|
|
58
|
+
this.emit(this.EVENTS.AUDIO.GLOBAL_RESUME, this.PARAMS_DURATION);
|
|
59
|
+
};
|
|
60
|
+
onLoad = () => void this.emit(this.EVENTS.AUDIO.MEDIA_LOAD, this.PARAMS_ALL);
|
|
61
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { PluginName as AudioPluginName, SubscribeEvents as AudioSubscribeEvents } from "@vnejs/contracts.audio";
|
|
3
|
+
|
|
4
|
+
export type ModuleControllerAudioEvents = ModuleCoreEvents & Record<AudioPluginName, AudioSubscribeEvents>;
|
|
5
|
+
|
|
6
|
+
export type ModuleControllerAudioConstants = ModuleCoreConstants;
|
|
7
|
+
|
|
8
|
+
export type ModuleControllerAudioSettings = ModuleCoreSettings;
|
|
9
|
+
|
|
10
|
+
export type ModuleControllerAudioParams = ModuleCoreParams;
|