@vnejs/compatibility.text-with-audio.voice 0.2.1 → 0.2.3
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 +3 -3
- package/dist/index.js +4 -6
- package/package.json +1 -1
- package/src/index.ts +4 -7
- package/src/tests/audio.voice.test.ts +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -7,11 +7,11 @@ import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from
|
|
|
7
7
|
type CompatState = {
|
|
8
8
|
currentName: string;
|
|
9
9
|
};
|
|
10
|
-
export declare class
|
|
10
|
+
export declare class CompatibilityTextWithAudioVoice extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams, CompatState> {
|
|
11
11
|
name: string;
|
|
12
12
|
subscribe: () => void;
|
|
13
|
-
init: () => Promise<
|
|
14
|
-
onLineLoad: ({ args, priority }?: LineLoadHandlerArg) => Promise<
|
|
13
|
+
init: () => Promise<import("@vnejs/shared").EmitResults<"vne:scenario:line_load_reg">> | undefined;
|
|
14
|
+
onLineLoad: ({ args, priority }?: LineLoadHandlerArg) => Promise<import("@vnejs/shared").EmitResults<"vne:audio:media_load">> | undefined;
|
|
15
15
|
onTextEmitBefore: () => Promise<void>;
|
|
16
16
|
onTextEmit: (payload?: TextEmitPayload) => Promise<void>;
|
|
17
17
|
onInteractStarted: () => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -5,18 +5,16 @@ import { ModuleCore } from "@vnejs/module.core";
|
|
|
5
5
|
import { SETTINGS_KEYS as VOICE_SETTINGS_KEYS } from "@vnejs/contracts.audio.voice";
|
|
6
6
|
import { regModule } from "@vnejs/shared";
|
|
7
7
|
import { resolveVoicePath } from "./utils/voice.js";
|
|
8
|
-
export class
|
|
8
|
+
export class CompatibilityTextWithAudioVoice extends ModuleCore {
|
|
9
9
|
name = "compatibility.text-with-audio.voice";
|
|
10
10
|
subscribe = () => {
|
|
11
11
|
this.on(this.EVENTS.TEXT.EMIT, this.onTextEmit);
|
|
12
12
|
this.on(this.EVENTS.INTERACT.STARTED, this.onInteractStarted);
|
|
13
13
|
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingsChanged);
|
|
14
14
|
this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
|
|
15
|
+
this.on(this.EVENTS.TEXT.EMIT_BEFORE, this.onTextEmitBefore);
|
|
15
16
|
};
|
|
16
|
-
init = () =>
|
|
17
|
-
this.emit(this.EVENTS.SCENARIO.LINE_LOAD_REG, { module: this.CONST.SCENARIO.OTHER_MODULE, handler: this.onLineLoad }),
|
|
18
|
-
this.emit(this.EVENTS.TEXT.EMIT_BEFORE_REG, { handler: this.onTextEmitBefore }),
|
|
19
|
-
]);
|
|
17
|
+
init = () => this.emit(this.EVENTS.SCENARIO.LINE_LOAD_REG, { module: this.CONST.SCENARIO.OTHER_MODULE, handler: this.onLineLoad });
|
|
20
18
|
onLineLoad = ({ args = {}, priority = this.CONST.MEDIA.PRIORITIES.BACKGROUND } = {}) => {
|
|
21
19
|
const voice = this.getVoiceArg(args);
|
|
22
20
|
if (!voice || this.shared.voiceDisableSources.isNotEmpty())
|
|
@@ -62,4 +60,4 @@ export class CompatibilityTextVoice extends ModuleCore {
|
|
|
62
60
|
};
|
|
63
61
|
getVoiceVolume = () => this.shared.settings[VOICE_SETTINGS_KEYS.VOLUME] ?? 100;
|
|
64
62
|
}
|
|
65
|
-
regModule(
|
|
63
|
+
regModule(CompatibilityTextWithAudioVoice);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ type CompatState = {
|
|
|
14
14
|
currentName: string;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export class
|
|
17
|
+
export class CompatibilityTextWithAudioVoice extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams, CompatState> {
|
|
18
18
|
name = "compatibility.text-with-audio.voice";
|
|
19
19
|
|
|
20
20
|
subscribe = () => {
|
|
@@ -22,13 +22,10 @@ export class CompatibilityTextVoice extends ModuleCore<PluginEvents, PluginConst
|
|
|
22
22
|
this.on(this.EVENTS.INTERACT.STARTED, this.onInteractStarted);
|
|
23
23
|
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingsChanged);
|
|
24
24
|
this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
|
|
25
|
+
this.on(this.EVENTS.TEXT.EMIT_BEFORE, this.onTextEmitBefore);
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
init = () =>
|
|
28
|
-
Promise.all([
|
|
29
|
-
this.emit(this.EVENTS.SCENARIO.LINE_LOAD_REG, { module: this.CONST.SCENARIO.OTHER_MODULE, handler: this.onLineLoad }),
|
|
30
|
-
this.emit(this.EVENTS.TEXT.EMIT_BEFORE_REG, { handler: this.onTextEmitBefore }),
|
|
31
|
-
]);
|
|
28
|
+
init = () => this.emit(this.EVENTS.SCENARIO.LINE_LOAD_REG, { module: this.CONST.SCENARIO.OTHER_MODULE, handler: this.onLineLoad });
|
|
32
29
|
|
|
33
30
|
onLineLoad = ({ args = {}, priority = this.CONST.MEDIA.PRIORITIES.BACKGROUND }: LineLoadHandlerArg = {}) => {
|
|
34
31
|
const voice = this.getVoiceArg(args);
|
|
@@ -96,4 +93,4 @@ export class CompatibilityTextVoice extends ModuleCore<PluginEvents, PluginConst
|
|
|
96
93
|
getVoiceVolume = () => (this.shared.settings[VOICE_SETTINGS_KEYS.VOLUME] as number | undefined) ?? 100;
|
|
97
94
|
}
|
|
98
95
|
|
|
99
|
-
regModule(
|
|
96
|
+
regModule(CompatibilityTextWithAudioVoice);
|
|
@@ -4,14 +4,14 @@ import { spyEvent } from "@vnejs/test-utils";
|
|
|
4
4
|
|
|
5
5
|
import { SourcesSet } from "@vnejs/sources-set";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { CompatibilityTextWithAudioVoice } from "../index.js";
|
|
8
8
|
import { AUDIO_EVENTS, createCompatibilityTestModule, registerCompatibilityVne, TEXT_EVENTS, VOICE_CONST } from "./setup.js";
|
|
9
9
|
|
|
10
|
-
describe("
|
|
10
|
+
describe("CompatibilityTextWithAudioVoice", () => {
|
|
11
11
|
beforeEach(() => registerCompatibilityVne());
|
|
12
12
|
|
|
13
13
|
it("TEXT.EMIT with voice plays on voice layer", async () => {
|
|
14
|
-
const { observer } = createCompatibilityTestModule(
|
|
14
|
+
const { observer } = createCompatibilityTestModule(CompatibilityTextWithAudioVoice);
|
|
15
15
|
const play = spyEvent(observer, AUDIO_EVENTS.PLAY);
|
|
16
16
|
|
|
17
17
|
await observer.emit(TEXT_EVENTS.EMIT, { args: { voice: "line1" } });
|
|
@@ -24,7 +24,7 @@ describe("CompatibilityTextVoice", () => {
|
|
|
24
24
|
const disableSources = new SourcesSet();
|
|
25
25
|
disableSources.set("blocker", true);
|
|
26
26
|
|
|
27
|
-
const { observer } = createCompatibilityTestModule(
|
|
27
|
+
const { observer } = createCompatibilityTestModule(CompatibilityTextWithAudioVoice, {
|
|
28
28
|
shared: { voiceDisableSources: disableSources },
|
|
29
29
|
});
|
|
30
30
|
const play = spyEvent(observer, AUDIO_EVENTS.PLAY);
|