@vnejs/plugins.text.wall 0.2.2 → 0.2.4
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/modules/emit.before.d.ts +2 -2
- package/dist/modules/emit.before.js +3 -1
- package/dist/modules/exec.d.ts +2 -2
- package/dist/modules/recalc.js +1 -1
- package/dist/modules/wall.d.ts +3 -3
- package/dist/modules/wall.js +1 -1
- package/package.json +1 -1
- package/src/modules/emit.before.ts +3 -1
- package/src/modules/recalc.ts +2 -2
- package/src/modules/wall.ts +2 -2
- package/src/tests/emit.before.test.ts +5 -4
|
@@ -4,6 +4,6 @@ import type { ModuleGlobalStateTextWall } from "@vnejs/contracts.text.wall";
|
|
|
4
4
|
import type { TextWallPluginConstants, TextWallPluginEvents, TextWallPluginParams, TextWallPluginSettings } from "../types.js";
|
|
5
5
|
export declare class TextWallEmitBefore extends ModuleCore<TextWallPluginEvents, TextWallPluginConstants, TextWallPluginSettings, TextWallPluginParams, ModuleGlobalStateTextWall> {
|
|
6
6
|
name: string;
|
|
7
|
-
|
|
8
|
-
onTextEmitBefore: ({ isExtend }?: TextEmitBeforePayload) => Promise<
|
|
7
|
+
subscribe: () => void;
|
|
8
|
+
onTextEmitBefore: ({ isExtend }?: TextEmitBeforePayload) => Promise<import("@vnejs/shared").EmitResults<"vne:text_wall:state_update"> | undefined>;
|
|
9
9
|
}
|
|
@@ -2,7 +2,9 @@ import { ModuleCore } from "@vnejs/module.core";
|
|
|
2
2
|
import { getTextSpeakerInfo } from "@vnejs/contracts.text";
|
|
3
3
|
export class TextWallEmitBefore extends ModuleCore {
|
|
4
4
|
name = "text.wall.emit.before";
|
|
5
|
-
|
|
5
|
+
subscribe = () => {
|
|
6
|
+
this.on(this.EVENTS.TEXT.EMIT_BEFORE, this.onTextEmitBefore);
|
|
7
|
+
};
|
|
6
8
|
onTextEmitBefore = async ({ isExtend = false } = {}) => {
|
|
7
9
|
const state = this.globalState["text.wall"];
|
|
8
10
|
if (isExtend || !state.isStarted || this.shared.isTextWallSetStateInProcess)
|
package/dist/modules/exec.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { LineExecHandlerArg } from "@vnejs/module.core";
|
|
|
4
4
|
import type { TextWallPluginConstants, TextWallPluginEvents, TextWallPluginParams, TextWallPluginSettings } from "../types.js";
|
|
5
5
|
export declare class TextWallExec extends ModuleCore<TextWallPluginEvents, TextWallPluginConstants, TextWallPluginSettings, TextWallPluginParams, ModuleGlobalStateTextWall> {
|
|
6
6
|
name: string;
|
|
7
|
-
init: () => Promise<
|
|
7
|
+
init: () => Promise<import("@vnejs/shared").EmitResults<"vne:scenario:line_exec_reg">> | undefined;
|
|
8
8
|
onLineExec: ({ line }?: LineExecHandlerArg) => Promise<void>;
|
|
9
|
-
emitAction: (action: string) => Promise<
|
|
9
|
+
emitAction: (action: string) => Promise<import("@vnejs/shared").EmitResults<"vne:text_wall:state_update">> | undefined;
|
|
10
10
|
}
|
package/dist/modules/recalc.js
CHANGED
|
@@ -18,5 +18,5 @@ export class TextWallRecalc extends ModuleCore {
|
|
|
18
18
|
tokens.push(...tokenizeText(await this.getRealText(wallObj.texts[i].text, wallObj.texts[i].args)));
|
|
19
19
|
return { ...wallObj, tokens };
|
|
20
20
|
};
|
|
21
|
-
getRealText = (text, args) => this.emitOne(this.EVENTS.TEXT.REPLACE, { text, args, label: this.globalState.scenario.label, state: this.globalState });
|
|
21
|
+
getRealText = async (text, args) => (await this.emitOne(this.EVENTS.TEXT.REPLACE, { text, args, label: this.globalState.scenario.label, state: this.globalState })) ?? "";
|
|
22
22
|
}
|
package/dist/modules/wall.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
import type { ModuleGlobalStateRegistry } from "@vnejs/module.core";
|
|
3
|
-
import type { ModuleGlobalStateTextWall } from "@vnejs/contracts.text.wall";
|
|
3
|
+
import type { ModuleGlobalStateTextWall, TextWallStateUpdatePayload } from "@vnejs/contracts.text.wall";
|
|
4
4
|
import type { TextWallPluginConstants, TextWallPluginEvents, TextWallPluginParams, TextWallPluginSettings } from "../types.js";
|
|
5
5
|
export declare class TextWall extends ModuleCore<TextWallPluginEvents, TextWallPluginConstants, TextWallPluginSettings, TextWallPluginParams, ModuleGlobalStateTextWall> {
|
|
6
6
|
name: string;
|
|
7
7
|
subscribe: () => void;
|
|
8
8
|
postinject: () => void;
|
|
9
|
-
onStateUpdate: (payload
|
|
9
|
+
onStateUpdate: (payload?: TextWallStateUpdatePayload) => void;
|
|
10
10
|
onStateSet: (payload: ModuleGlobalStateRegistry) => Promise<void>;
|
|
11
|
-
onStateClear: () => Promise<
|
|
11
|
+
onStateClear: () => Promise<import("@vnejs/shared").EmitResults<"vne:text_wall:changed"> | undefined>;
|
|
12
12
|
getDefaultState: () => ModuleGlobalStateTextWall;
|
|
13
13
|
}
|
package/dist/modules/wall.js
CHANGED
|
@@ -9,7 +9,7 @@ export class TextWall extends ModuleCore {
|
|
|
9
9
|
postinject = () => {
|
|
10
10
|
this.shared.isTextWallSetStateInProcess = false;
|
|
11
11
|
};
|
|
12
|
-
onStateUpdate = (payload) => this.updateState(payload);
|
|
12
|
+
onStateUpdate = (payload = {}) => this.updateState(payload);
|
|
13
13
|
onStateSet = async (payload) => {
|
|
14
14
|
this.shared.isTextWallSetStateInProcess = true;
|
|
15
15
|
await this.onSetStateClone(payload);
|
package/package.json
CHANGED
|
@@ -15,7 +15,9 @@ export class TextWallEmitBefore extends ModuleCore<
|
|
|
15
15
|
> {
|
|
16
16
|
name = "text.wall.emit.before";
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
subscribe = () => {
|
|
19
|
+
this.on(this.EVENTS.TEXT.EMIT_BEFORE, this.onTextEmitBefore);
|
|
20
|
+
};
|
|
19
21
|
|
|
20
22
|
onTextEmitBefore = async ({ isExtend = false }: TextEmitBeforePayload = {}) => {
|
|
21
23
|
const state = this.globalState["text.wall"];
|
package/src/modules/recalc.ts
CHANGED
|
@@ -35,6 +35,6 @@ export class TextWallRecalc extends ModuleCore<
|
|
|
35
35
|
|
|
36
36
|
return { ...wallObj, tokens };
|
|
37
37
|
};
|
|
38
|
-
getRealText = (text: string, args: Record<string, unknown>) =>
|
|
39
|
-
this.emitOne(this.EVENTS.TEXT.REPLACE, { text, args, label: this.globalState.scenario.label, state: this.globalState })
|
|
38
|
+
getRealText = async (text: string, args: Record<string, unknown>) =>
|
|
39
|
+
(await this.emitOne(this.EVENTS.TEXT.REPLACE, { text, args, label: this.globalState.scenario.label, state: this.globalState })) ?? "";
|
|
40
40
|
}
|
package/src/modules/wall.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
import type { ModuleGlobalStateRegistry } from "@vnejs/module.core";
|
|
3
3
|
|
|
4
|
-
import type { ModuleGlobalStateTextWall } from "@vnejs/contracts.text.wall";
|
|
4
|
+
import type { ModuleGlobalStateTextWall, TextWallStateUpdatePayload } from "@vnejs/contracts.text.wall";
|
|
5
5
|
|
|
6
6
|
import type { TextWallPluginConstants, TextWallPluginEvents, TextWallPluginParams, TextWallPluginSettings } from "../types.js";
|
|
7
7
|
|
|
@@ -25,7 +25,7 @@ export class TextWall extends ModuleCore<
|
|
|
25
25
|
this.shared.isTextWallSetStateInProcess = false;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
onStateUpdate = (payload:
|
|
28
|
+
onStateUpdate = (payload: TextWallStateUpdatePayload = {}) => this.updateState(payload);
|
|
29
29
|
|
|
30
30
|
onStateSet = async (payload: ModuleGlobalStateRegistry) => {
|
|
31
31
|
this.shared.isTextWallSetStateInProcess = true;
|
|
@@ -10,13 +10,14 @@ describe("TextWallEmitBefore", () => {
|
|
|
10
10
|
registerTextWallPluginVne();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
it("
|
|
13
|
+
it("subscribe registers emit before handler", () => {
|
|
14
14
|
const { module, observer } = createTextWallTestModule(TextWallEmitBefore, { subscribe: false });
|
|
15
|
-
const emitBeforeReg = spyEvent(observer, TEXT_EVENTS.EMIT_BEFORE_REG);
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
(module as TextWallEmitBefore).subscribe();
|
|
18
17
|
|
|
19
|
-
expect(
|
|
18
|
+
expect(observer.subscribers[TEXT_EVENTS.EMIT_BEFORE]?.flatMap((group) => group.subscribers)).toEqual(
|
|
19
|
+
expect.arrayContaining([expect.objectContaining({ func: (module as TextWallEmitBefore).onTextEmitBefore })]),
|
|
20
|
+
);
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
it("skips when wall is not started", async () => {
|