@vnejs/plugins.views.scenario.interface 0.1.28 → 0.1.30

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,17 +1,19 @@
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> {
6
7
  name: string;
7
8
  subscribe: () => void;
8
- init: () => Promise<unknown[]> | undefined;
9
+ init: () => Promise<[unknown[] | undefined, unknown[] | undefined]>;
9
10
  onLineExec: ({ line }?: LineExecHandlerArg) => Promise<void>;
10
11
  onInteract: () => Promise<unknown[]> | undefined;
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, tokensVisible }?: InterfaceTextChangedPayload) => Promise<unknown[]> | undefined;
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,19 @@ 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
- this.on(this.EVENTS.TEXT.EMIT_BEFORE, this.onTextEmitBefore);
15
15
  this.on(this.EVENTS.STATE.SET, this.onStateSet);
16
16
  this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
17
17
  };
18
- init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
18
+ init = () => {
19
+ this.shared.interfaceTextShowAllTokensOnChange = true;
20
+ return Promise.all([
21
+ this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec }),
22
+ this.emit(this.EVENTS.TEXT.EMIT_BEFORE_REG, { handler: this.onTextEmitBefore }),
23
+ ]);
24
+ };
19
25
  onLineExec = async ({ line = "" } = {}) => {
20
26
  const isForce = this.shared.viewForceAnimationSources.isNotEmpty();
21
27
  const [action = "", execArg = ""] = tokenizeExecLine(line);
@@ -31,7 +37,11 @@ export class Interface extends ModuleCore {
31
37
  onShow = ({ isForce = false } = {}) => !this.state.isShow && this.setShow(true, isForce);
32
38
  onHide = ({ isForce = false } = {}) => this.state.isShow && this.setShow(false, isForce);
33
39
  onVisible = ({ isForce = false } = {}) => this.setVisible(!this.state.isVisible, isForce);
34
- onTextChanged = ({ tokens, uid, tokensVisible } = {}) => this.emitTextChanged(tokens, uid, tokensVisible);
40
+ onTextChanged = ({ tokens = [], uid = "" } = {}) => {
41
+ const tokensVisible = this.shared.interfaceTextShowAllTokensOnChange ? tokens.length : 0;
42
+ return this.emitTextChanged(tokens, uid, tokensVisible);
43
+ };
44
+ onVisibleTokensChanged = ({ tokensVisible = 0, uid = "" } = {}) => this.emitTextChanged(this.globalState.text.tokens, uid, tokensVisible);
35
45
  onTextSpeakerChanged = ({ speaker, meet } = {}) => this.emitSpeakerChanged(speaker, meet);
36
46
  onTextEmitBefore = () => this.emit(this.EVENTS.INTERFACE.SHOW);
37
47
  onTextHide = () => this.emitTextChanged([], "", 0);
@@ -61,9 +71,5 @@ export class Interface extends ModuleCore {
61
71
  Object.assign(this.state, { isShow, view, isVisible });
62
72
  return this.emit(this.EVENTS.INTERFACE.STATE_CHANGED);
63
73
  };
64
- getDefaultState = () => ({
65
- view: this.PARAMS.INTERFACE.DEFAULT_VIEW,
66
- isShow: false,
67
- isVisible: false,
68
- });
74
+ getDefaultState = () => ({ view: this.PARAMS.INTERFACE.DEFAULT_VIEW, isShow: false, isVisible: false });
69
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.views.scenario.interface",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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,16 +30,23 @@ 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);
34
- this.on(this.EVENTS.TEXT.EMIT_BEFORE, this.onTextEmitBefore);
35
37
 
36
38
  this.on(this.EVENTS.STATE.SET, this.onStateSet);
37
39
  this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
38
40
  };
39
41
 
40
- init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
42
+ init = () => {
43
+ this.shared.interfaceTextShowAllTokensOnChange = true;
44
+
45
+ return Promise.all([
46
+ this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec }),
47
+ this.emit(this.EVENTS.TEXT.EMIT_BEFORE_REG, { handler: this.onTextEmitBefore }),
48
+ ]);
49
+ };
41
50
 
42
51
  onLineExec = async ({ line = "" }: LineExecHandlerArg = {}) => {
43
52
  const isForce = this.shared.viewForceAnimationSources.isNotEmpty();
@@ -55,7 +64,13 @@ export class Interface extends ModuleCore<
55
64
  onShow = ({ isForce = false }: InterfaceForcePayload = {}) => !this.state.isShow && this.setShow(true, isForce);
56
65
  onHide = ({ isForce = false }: InterfaceForcePayload = {}) => this.state.isShow && this.setShow(false, isForce);
57
66
  onVisible = ({ isForce = false }: InterfaceForcePayload = {}) => this.setVisible(!this.state.isVisible, isForce);
58
- onTextChanged = ({ tokens, uid, tokensVisible }: InterfaceTextChangedPayload = {}) => this.emitTextChanged(tokens, uid, tokensVisible);
67
+ onTextChanged = ({ tokens = [], uid = "" }: InterfaceTextChangedPayload = {}) => {
68
+ const tokensVisible = this.shared.interfaceTextShowAllTokensOnChange ? tokens.length : 0;
69
+
70
+ return this.emitTextChanged(tokens, uid, tokensVisible);
71
+ };
72
+ onVisibleTokensChanged = ({ tokensVisible = 0, uid = "" }: InterfaceVisibleTokensChangedPayload = {}) =>
73
+ this.emitTextChanged(this.globalState.text.tokens, uid, tokensVisible);
59
74
  onTextSpeakerChanged = ({ speaker, meet }: InterfaceSpeakerChangedPayload = {}) => this.emitSpeakerChanged(speaker, meet);
60
75
  onTextEmitBefore = () => this.emit(this.EVENTS.INTERFACE.SHOW);
61
76
  onTextHide = () => this.emitTextChanged([], "", 0);
@@ -93,9 +108,5 @@ export class Interface extends ModuleCore<
93
108
  return this.emit(this.EVENTS.INTERFACE.STATE_CHANGED);
94
109
  };
95
110
 
96
- getDefaultState = (): InterfaceModuleState => ({
97
- view: this.PARAMS.INTERFACE.DEFAULT_VIEW,
98
- isShow: false,
99
- isVisible: false,
100
- });
111
+ getDefaultState = (): InterfaceModuleState => ({ view: this.PARAMS.INTERFACE.DEFAULT_VIEW, isShow: false, isVisible: false });
101
112
  }