@vnejs/plugins.views.scenario.interface 0.1.28 → 0.1.29
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,5 +1,6 @@
|
|
|
1
1
|
import { ModuleCore, type ModuleGlobalStateRegistry } from "@vnejs/module.core";
|
|
2
2
|
import type { LineExecHandlerArg } from "@vnejs/module.core";
|
|
3
|
+
import type { InterfaceVisibleTokensChangedPayload } from "@vnejs/contracts.views.scenario.interface";
|
|
3
4
|
import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
|
|
4
5
|
import type { InterfaceForcePayload, InterfaceModuleState, InterfaceSpeakerChangedPayload, InterfaceTextChangedPayload, InterfaceViewPayload } from "../utils/interface.js";
|
|
5
6
|
export declare class Interface extends ModuleCore<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams, InterfaceModuleState> {
|
|
@@ -11,7 +12,8 @@ export declare class Interface extends ModuleCore<InterfacePluginEvents, Interfa
|
|
|
11
12
|
onShow: ({ isForce }?: InterfaceForcePayload) => false | Promise<unknown[] | undefined>;
|
|
12
13
|
onHide: ({ isForce }?: InterfaceForcePayload) => false | Promise<unknown[] | undefined>;
|
|
13
14
|
onVisible: ({ isForce }?: InterfaceForcePayload) => Promise<unknown[]> | undefined;
|
|
14
|
-
onTextChanged: ({ tokens, uid
|
|
15
|
+
onTextChanged: ({ tokens, uid }?: InterfaceTextChangedPayload) => Promise<unknown[]> | undefined;
|
|
16
|
+
onVisibleTokensChanged: ({ tokensVisible, uid }?: InterfaceVisibleTokensChangedPayload) => Promise<unknown[]> | undefined;
|
|
15
17
|
onTextSpeakerChanged: ({ speaker, meet }?: InterfaceSpeakerChangedPayload) => Promise<unknown[]> | undefined;
|
|
16
18
|
onTextEmitBefore: () => Promise<unknown[]> | undefined;
|
|
17
19
|
onTextHide: () => Promise<unknown[]> | undefined;
|
|
@@ -9,13 +9,17 @@ export class Interface extends ModuleCore {
|
|
|
9
9
|
this.on(this.EVENTS.INTERFACE.VISIBLE, this.onVisible);
|
|
10
10
|
this.on(this.EVENTS.INTERFACE.TEXT_HIDE, this.onTextHide);
|
|
11
11
|
this.on(this.EVENTS.INTERFACE.VIEW, this.onView);
|
|
12
|
+
this.on(this.EVENTS.INTERFACE.VISIBLE_TOKENS_CHANGED, this.onVisibleTokensChanged);
|
|
12
13
|
this.on(this.EVENTS.TEXT.CHANGED, this.onTextChanged);
|
|
13
14
|
this.on(this.EVENTS.TEXT.SPEAKER_CHANGED, this.onTextSpeakerChanged);
|
|
14
15
|
this.on(this.EVENTS.TEXT.EMIT_BEFORE, this.onTextEmitBefore);
|
|
15
16
|
this.on(this.EVENTS.STATE.SET, this.onStateSet);
|
|
16
17
|
this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
|
|
17
18
|
};
|
|
18
|
-
init = () =>
|
|
19
|
+
init = () => {
|
|
20
|
+
this.shared.interfaceTextShowAllTokensOnChange = true;
|
|
21
|
+
return this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
|
|
22
|
+
};
|
|
19
23
|
onLineExec = async ({ line = "" } = {}) => {
|
|
20
24
|
const isForce = this.shared.viewForceAnimationSources.isNotEmpty();
|
|
21
25
|
const [action = "", execArg = ""] = tokenizeExecLine(line);
|
|
@@ -31,7 +35,11 @@ export class Interface extends ModuleCore {
|
|
|
31
35
|
onShow = ({ isForce = false } = {}) => !this.state.isShow && this.setShow(true, isForce);
|
|
32
36
|
onHide = ({ isForce = false } = {}) => this.state.isShow && this.setShow(false, isForce);
|
|
33
37
|
onVisible = ({ isForce = false } = {}) => this.setVisible(!this.state.isVisible, isForce);
|
|
34
|
-
onTextChanged = ({ tokens, uid
|
|
38
|
+
onTextChanged = ({ tokens = [], uid = "" } = {}) => {
|
|
39
|
+
const tokensVisible = this.shared.interfaceTextShowAllTokensOnChange ? tokens.length : 0;
|
|
40
|
+
return this.emitTextChanged(tokens, uid, tokensVisible);
|
|
41
|
+
};
|
|
42
|
+
onVisibleTokensChanged = ({ tokensVisible = 0, uid = "" } = {}) => this.emitTextChanged(this.globalState.text.tokens, uid, tokensVisible);
|
|
35
43
|
onTextSpeakerChanged = ({ speaker, meet } = {}) => this.emitSpeakerChanged(speaker, meet);
|
|
36
44
|
onTextEmitBefore = () => this.emit(this.EVENTS.INTERFACE.SHOW);
|
|
37
45
|
onTextHide = () => this.emitTextChanged([], "", 0);
|
|
@@ -61,9 +69,5 @@ export class Interface extends ModuleCore {
|
|
|
61
69
|
Object.assign(this.state, { isShow, view, isVisible });
|
|
62
70
|
return this.emit(this.EVENTS.INTERFACE.STATE_CHANGED);
|
|
63
71
|
};
|
|
64
|
-
getDefaultState = () => ({
|
|
65
|
-
view: this.PARAMS.INTERFACE.DEFAULT_VIEW,
|
|
66
|
-
isShow: false,
|
|
67
|
-
isVisible: false,
|
|
68
|
-
});
|
|
72
|
+
getDefaultState = () => ({ view: this.PARAMS.INTERFACE.DEFAULT_VIEW, isShow: false, isVisible: false });
|
|
69
73
|
}
|
package/package.json
CHANGED
package/src/modules/interface.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { tokenizeExecLine } from "@vnejs/helpers";
|
|
|
3
3
|
|
|
4
4
|
import type { LineExecHandlerArg } from "@vnejs/module.core";
|
|
5
5
|
|
|
6
|
+
import type { InterfaceVisibleTokensChangedPayload } from "@vnejs/contracts.views.scenario.interface";
|
|
7
|
+
|
|
6
8
|
import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
|
|
7
9
|
import type {
|
|
8
10
|
InterfaceForcePayload,
|
|
@@ -28,6 +30,7 @@ export class Interface extends ModuleCore<
|
|
|
28
30
|
this.on(this.EVENTS.INTERFACE.VISIBLE, this.onVisible);
|
|
29
31
|
this.on(this.EVENTS.INTERFACE.TEXT_HIDE, this.onTextHide);
|
|
30
32
|
this.on(this.EVENTS.INTERFACE.VIEW, this.onView);
|
|
33
|
+
this.on(this.EVENTS.INTERFACE.VISIBLE_TOKENS_CHANGED, this.onVisibleTokensChanged);
|
|
31
34
|
|
|
32
35
|
this.on(this.EVENTS.TEXT.CHANGED, this.onTextChanged);
|
|
33
36
|
this.on(this.EVENTS.TEXT.SPEAKER_CHANGED, this.onTextSpeakerChanged);
|
|
@@ -37,7 +40,11 @@ export class Interface extends ModuleCore<
|
|
|
37
40
|
this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
|
|
38
41
|
};
|
|
39
42
|
|
|
40
|
-
init = () =>
|
|
43
|
+
init = () => {
|
|
44
|
+
this.shared.interfaceTextShowAllTokensOnChange = true;
|
|
45
|
+
|
|
46
|
+
return this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
|
|
47
|
+
};
|
|
41
48
|
|
|
42
49
|
onLineExec = async ({ line = "" }: LineExecHandlerArg = {}) => {
|
|
43
50
|
const isForce = this.shared.viewForceAnimationSources.isNotEmpty();
|
|
@@ -55,7 +62,13 @@ export class Interface extends ModuleCore<
|
|
|
55
62
|
onShow = ({ isForce = false }: InterfaceForcePayload = {}) => !this.state.isShow && this.setShow(true, isForce);
|
|
56
63
|
onHide = ({ isForce = false }: InterfaceForcePayload = {}) => this.state.isShow && this.setShow(false, isForce);
|
|
57
64
|
onVisible = ({ isForce = false }: InterfaceForcePayload = {}) => this.setVisible(!this.state.isVisible, isForce);
|
|
58
|
-
onTextChanged = ({ tokens, uid
|
|
65
|
+
onTextChanged = ({ tokens = [], uid = "" }: InterfaceTextChangedPayload = {}) => {
|
|
66
|
+
const tokensVisible = this.shared.interfaceTextShowAllTokensOnChange ? tokens.length : 0;
|
|
67
|
+
|
|
68
|
+
return this.emitTextChanged(tokens, uid, tokensVisible);
|
|
69
|
+
};
|
|
70
|
+
onVisibleTokensChanged = ({ tokensVisible = 0, uid = "" }: InterfaceVisibleTokensChangedPayload = {}) =>
|
|
71
|
+
this.emitTextChanged(this.globalState.text.tokens, uid, tokensVisible);
|
|
59
72
|
onTextSpeakerChanged = ({ speaker, meet }: InterfaceSpeakerChangedPayload = {}) => this.emitSpeakerChanged(speaker, meet);
|
|
60
73
|
onTextEmitBefore = () => this.emit(this.EVENTS.INTERFACE.SHOW);
|
|
61
74
|
onTextHide = () => this.emitTextChanged([], "", 0);
|
|
@@ -93,9 +106,5 @@ export class Interface extends ModuleCore<
|
|
|
93
106
|
return this.emit(this.EVENTS.INTERFACE.STATE_CHANGED);
|
|
94
107
|
};
|
|
95
108
|
|
|
96
|
-
getDefaultState = (): InterfaceModuleState => ({
|
|
97
|
-
view: this.PARAMS.INTERFACE.DEFAULT_VIEW,
|
|
98
|
-
isShow: false,
|
|
99
|
-
isVisible: false,
|
|
100
|
-
});
|
|
109
|
+
getDefaultState = (): InterfaceModuleState => ({ view: this.PARAMS.INTERFACE.DEFAULT_VIEW, isShow: false, isVisible: false });
|
|
101
110
|
}
|