@vnejs/plugins.views.scenario.interface 0.2.3 → 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/index.js CHANGED
@@ -1,8 +1,18 @@
1
1
  import "@vnejs/contracts.views.scenario.interface";
2
2
  import "@vnejs/contracts.text.meet";
3
3
  import { regPlugin } from "@vnejs/shared";
4
- import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.scenario.interface";
4
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.scenario.interface";
5
5
  import { InterfaceController } from "./modules/controller.js";
6
+ import { InterfaceControllerAccept } from "./modules/controller.accept.js";
7
+ import { InterfaceActions } from "./modules/actions.js";
6
8
  import { Interface } from "./modules/interface.js";
9
+ import { InterfaceScenario } from "./modules/scenario.js";
7
10
  import { InterfaceView } from "./modules/view.js";
8
- regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [InterfaceController, Interface, InterfaceView]);
11
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [
12
+ InterfaceController,
13
+ InterfaceControllerAccept,
14
+ Interface,
15
+ InterfaceActions,
16
+ InterfaceScenario,
17
+ InterfaceView,
18
+ ]);
@@ -0,0 +1,15 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
3
+ import type { InterfaceForcePayload, InterfaceViewPayload } from "../utils/interface.js";
4
+ export declare class InterfaceActions extends ModuleCore<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams> {
5
+ name: string;
6
+ subscribe: () => void;
7
+ onShow: ({ isForce }?: InterfaceForcePayload) => false | Promise<unknown[] | undefined>;
8
+ onHide: ({ isForce }?: InterfaceForcePayload) => false | Promise<unknown[] | undefined>;
9
+ onVisible: ({ isForce }?: InterfaceForcePayload) => Promise<unknown[]> | undefined;
10
+ onTextHide: () => Promise<unknown[]> | undefined;
11
+ onView: ({ view, isForce }?: InterfaceViewPayload) => Promise<void>;
12
+ setShow: (isShow: boolean, isForce?: boolean) => Promise<unknown[] | undefined>;
13
+ setVisible: (isVisible: boolean, isForce?: boolean) => Promise<unknown[]> | undefined;
14
+ setView: (view?: string, isForce?: boolean) => Promise<void>;
15
+ }
@@ -0,0 +1,31 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ export class InterfaceActions extends ModuleCore {
3
+ name = "interface.actions";
4
+ subscribe = () => {
5
+ this.on(this.EVENTS.INTERFACE.SHOW, this.onShow);
6
+ this.on(this.EVENTS.INTERFACE.HIDE, this.onHide);
7
+ this.on(this.EVENTS.INTERFACE.VISIBLE, this.onVisible);
8
+ this.on(this.EVENTS.INTERFACE.TEXT_HIDE, this.onTextHide);
9
+ this.on(this.EVENTS.INTERFACE.VIEW, this.onView);
10
+ };
11
+ onShow = ({ isForce = false } = {}) => !this.globalState.interface.isShow && this.setShow(true, isForce);
12
+ onHide = ({ isForce = false } = {}) => this.globalState.interface.isShow && this.setShow(false, isForce);
13
+ onVisible = ({ isForce = false } = {}) => this.setVisible(!this.globalState.interface.isVisible, isForce);
14
+ onTextHide = () => this.emit(this.EVENTS.INTERFACE.TEXT_CHANGED, { tokens: [], uid: "", tokensVisible: 0 });
15
+ onView = ({ view, isForce = false } = {}) => this.setView(view, isForce);
16
+ setShow = async (isShow, isForce = false) => {
17
+ this.globalState.interface.isShow = isShow;
18
+ if (isShow && !this.globalState.interface.isVisible)
19
+ await this.setVisible(true, isForce);
20
+ return this.emit(this.EVENTS.INTERFACE.SHOW_CHANGED, { isForce });
21
+ };
22
+ setVisible = (isVisible, isForce = false) => {
23
+ this.globalState.interface.isVisible = isVisible;
24
+ return this.emit(this.EVENTS.INTERFACE.VISIBLE_CHANGED, { isForce });
25
+ };
26
+ setView = async (view, isForce = false) => {
27
+ this.globalState.interface.view = view ?? "";
28
+ await this.emit(this.EVENTS.INTERFACE.VIEW_CHANGED, { isForce });
29
+ await this.waitRerender();
30
+ };
31
+ }
@@ -0,0 +1,10 @@
1
+ import { ModuleControllerAccept } from "@vnejs/module.controller.accept";
2
+ import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
3
+ export declare class InterfaceControllerAccept extends ModuleControllerAccept<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams> {
4
+ name: string;
5
+ EVENT_SHOW: "vne:interface:view_show";
6
+ EVENT_HIDE: "vne:interface:view_hide";
7
+ EVENT_ACCEPT: "vne:interface:interact";
8
+ CONTROLS_ZINDEX: number;
9
+ onAccept: () => undefined;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { ModuleControllerAccept } from "@vnejs/module.controller.accept";
2
+ export class InterfaceControllerAccept extends ModuleControllerAccept {
3
+ name = "interface.controller.accept";
4
+ EVENT_SHOW = this.EVENTS.INTERFACE.VIEW_SHOW;
5
+ EVENT_HIDE = this.EVENTS.INTERFACE.VIEW_HIDE;
6
+ EVENT_ACCEPT = this.EVENTS.INTERFACE.INTERACT;
7
+ CONTROLS_ZINDEX = this.PARAMS.INTERFACE.ZINDEX;
8
+ onAccept = () => void this.emit(this.globalState.interface.isVisible ? this.EVENTS.INTERACT.EMIT : this.EVENTS.INTERFACE.VISIBLE);
9
+ }
@@ -4,10 +4,7 @@ import type { InterfaceForcePayload, InterfacePluginState, InterfaceSpeakerChang
4
4
  export declare class InterfaceController extends ModuleController<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams, InterfacePluginState> {
5
5
  name: string;
6
6
  EVENT_UPDATE_VIEW: "vne:interface:view_update";
7
- CONTROLS: {
8
- abstract_interact: () => undefined;
9
- abstract_accept: () => undefined;
10
- };
7
+ CONTROLS: {};
11
8
  CONTROLS_UNVISIBLE: {};
12
9
  CONTROLS_INDEX: number;
13
10
  isStateChangeInProcess: boolean;
@@ -1,13 +1,9 @@
1
1
  import { ModuleController } from "@vnejs/module.components";
2
- import { CONSTANTS as ControlsConstants } from "@vnejs/contracts.controls";
3
2
  import { getTextSpeakerInfo } from "@vnejs/contracts.text";
4
3
  export class InterfaceController extends ModuleController {
5
4
  name = "interface.controller";
6
5
  EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE.VIEW_UPDATE;
7
- CONTROLS = {
8
- [ControlsConstants.BUTTONS.INTERACT]: () => void this.emit(this.EVENTS.INTERFACE.INTERACT),
9
- [ControlsConstants.BUTTONS.ACCEPT]: () => void this.emit(this.EVENTS.INTERFACE.INTERACT),
10
- };
6
+ CONTROLS = {};
11
7
  CONTROLS_UNVISIBLE = {};
12
8
  CONTROLS_INDEX = this.PARAMS.INTERFACE.ZINDEX;
13
9
  isStateChangeInProcess = false;
@@ -1,30 +1,11 @@
1
1
  import { ModuleCore, type ModuleGlobalStateRegistry } from "@vnejs/module.core";
2
- import type { LineExecHandlerArg } from "@vnejs/module.core";
3
- import type { InterfaceVisibleTokensChangedPayload } from "@vnejs/contracts.views.scenario.interface";
4
2
  import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
5
- import type { InterfaceForcePayload, InterfaceModuleState, InterfaceSpeakerChangedPayload, InterfaceTextChangedPayload, InterfaceViewPayload } from "../utils/interface.js";
3
+ import type { InterfaceModuleState } from "../utils/interface.js";
6
4
  export declare class Interface extends ModuleCore<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams, InterfaceModuleState> {
7
5
  name: string;
8
6
  subscribe: () => void;
9
- init: () => Promise<[unknown[] | undefined, unknown[] | undefined]>;
10
- onLineExec: ({ line }?: LineExecHandlerArg) => Promise<void>;
11
- onInteract: () => Promise<unknown[]> | undefined;
12
- onShow: ({ isForce }?: InterfaceForcePayload) => false | Promise<unknown[] | undefined>;
13
- onHide: ({ isForce }?: InterfaceForcePayload) => false | Promise<unknown[] | undefined>;
14
- onVisible: ({ isForce }?: InterfaceForcePayload) => Promise<unknown[]> | undefined;
15
- onTextChanged: ({ tokens, uid }?: InterfaceTextChangedPayload) => Promise<unknown[]> | undefined;
16
- onVisibleTokensChanged: ({ tokensVisible, uid }?: InterfaceVisibleTokensChangedPayload) => Promise<unknown[]> | undefined;
17
- onTextSpeakerChanged: ({ speaker }?: InterfaceSpeakerChangedPayload) => Promise<unknown[]> | undefined;
18
- onTextEmitBefore: () => Promise<unknown[]> | undefined;
19
- onTextHide: () => Promise<unknown[]> | undefined;
20
- onView: ({ view, isForce }?: InterfaceViewPayload) => Promise<void>;
21
7
  onStateSet: (payload: ModuleGlobalStateRegistry) => Promise<unknown[]> | undefined;
22
8
  onStateClear: () => Promise<unknown[]> | undefined;
23
- setView: (view?: string, isForce?: boolean) => Promise<void>;
24
- setShow: (isShow: boolean, isForce?: boolean) => Promise<unknown[] | undefined>;
25
- setVisible: (isVisible: boolean, isForce?: boolean) => Promise<unknown[]> | undefined;
26
- emitTextChanged: (tokens?: InterfaceTextChangedPayload["tokens"], uid?: string, tokensVisible?: number) => Promise<unknown[]> | undefined;
27
- emitSpeakerChanged: (speaker?: string) => Promise<unknown[]> | undefined;
28
9
  setNewState: (view?: string, isVisible?: boolean, isShow?: boolean) => Promise<unknown[]> | undefined;
29
10
  getDefaultState: () => InterfaceModuleState;
30
11
  }
@@ -1,73 +1,15 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
- import { tokenizeExecLine } from "@vnejs/helpers";
3
2
  export class Interface extends ModuleCore {
4
3
  name = "interface";
5
4
  subscribe = () => {
6
- this.on(this.EVENTS.INTERFACE.INTERACT, this.onInteract);
7
- this.on(this.EVENTS.INTERFACE.SHOW, this.onShow);
8
- this.on(this.EVENTS.INTERFACE.HIDE, this.onHide);
9
- this.on(this.EVENTS.INTERFACE.VISIBLE, this.onVisible);
10
- this.on(this.EVENTS.INTERFACE.TEXT_HIDE, this.onTextHide);
11
- this.on(this.EVENTS.INTERFACE.VIEW, this.onView);
12
- this.on(this.EVENTS.INTERFACE.VISIBLE_TOKENS_CHANGED, this.onVisibleTokensChanged);
13
- this.on(this.EVENTS.TEXT.CHANGED, this.onTextChanged);
14
- this.on(this.EVENTS.TEXT.SPEAKER_CHANGED, this.onTextSpeakerChanged);
15
5
  this.on(this.EVENTS.STATE.SET, this.onStateSet);
16
6
  this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
17
7
  };
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
- };
25
- onLineExec = async ({ line = "" } = {}) => {
26
- const isForce = this.shared.viewForceAnimationSources.isNotEmpty();
27
- const [action = "", execArg = ""] = tokenizeExecLine(line);
28
- if (action === "show")
29
- await this.emit(this.EVENTS.INTERFACE.SHOW, { isForce });
30
- if (action === "hide")
31
- await this.emit(this.EVENTS.INTERFACE.HIDE, { isForce });
32
- if (action === "view")
33
- await this.emit(this.EVENTS.INTERFACE.VIEW, { view: execArg, isForce });
34
- this.emitNext();
35
- };
36
- onInteract = () => this.emit(this.state.isVisible ? this.EVENTS.INTERACT.EMIT : this.EVENTS.INTERFACE.VISIBLE);
37
- onShow = ({ isForce = false } = {}) => !this.state.isShow && this.setShow(true, isForce);
38
- onHide = ({ isForce = false } = {}) => this.state.isShow && this.setShow(false, isForce);
39
- onVisible = ({ isForce = false } = {}) => this.setVisible(!this.state.isVisible, isForce);
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);
45
- onTextSpeakerChanged = ({ speaker } = {}) => this.emitSpeakerChanged(speaker);
46
- onTextEmitBefore = () => this.emit(this.EVENTS.INTERFACE.SHOW);
47
- onTextHide = () => this.emitTextChanged([], "", 0);
48
- onView = ({ view, isForce = false } = {}) => this.setView(view, isForce);
49
8
  onStateSet = (payload) => {
50
9
  const moduleState = this.getStateSlice(payload);
51
10
  return this.setNewState(moduleState?.view, moduleState?.isVisible, moduleState?.isShow);
52
11
  };
53
12
  onStateClear = () => this.setNewState(this.PARAMS.INTERFACE.DEFAULT_VIEW, false, false);
54
- setView = async (view, isForce = false) => {
55
- this.state.view = view ?? "";
56
- await this.emit(this.EVENTS.INTERFACE.VIEW_CHANGED, { isForce });
57
- await this.waitRerender();
58
- };
59
- setShow = async (isShow, isForce = false) => {
60
- this.state.isShow = isShow;
61
- if (isShow && !this.state.isVisible)
62
- await this.setVisible(true, isForce);
63
- return this.emit(this.EVENTS.INTERFACE.SHOW_CHANGED, { isForce });
64
- };
65
- setVisible = (isVisible, isForce = false) => {
66
- this.state.isVisible = isVisible;
67
- return this.emit(this.EVENTS.INTERFACE.VISIBLE_CHANGED, { isForce });
68
- };
69
- emitTextChanged = (tokens = [], uid = "", tokensVisible) => this.emit(this.EVENTS.INTERFACE.TEXT_CHANGED, { tokens, uid, tokensVisible });
70
- emitSpeakerChanged = (speaker = "") => this.emit(this.EVENTS.INTERFACE.SPEAKER_CHANGED, { speaker });
71
13
  setNewState = (view, isVisible, isShow) => {
72
14
  Object.assign(this.state, { isShow, view, isVisible });
73
15
  return this.emit(this.EVENTS.INTERFACE.STATE_CHANGED);
@@ -0,0 +1,9 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { LineExecHandlerArg } from "@vnejs/module.core";
3
+ import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
4
+ export declare class InterfaceScenario extends ModuleCore<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams> {
5
+ name: string;
6
+ execName: string;
7
+ init: () => Promise<unknown[]> | undefined;
8
+ onLineExec: ({ line }?: LineExecHandlerArg) => Promise<void>;
9
+ }
@@ -0,0 +1,18 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import { tokenizeExecLine } from "@vnejs/helpers";
3
+ export class InterfaceScenario extends ModuleCore {
4
+ name = "interface.scenario";
5
+ execName = "interface";
6
+ init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.execName, handler: this.onLineExec });
7
+ onLineExec = async ({ line = "" } = {}) => {
8
+ const isForce = this.shared.viewForceAnimationSources.isNotEmpty();
9
+ const [action = "", execArg = ""] = tokenizeExecLine(line);
10
+ if (action === this.CONST.INTERFACE.EXEC_ACTIONS.SHOW)
11
+ await this.emit(this.EVENTS.INTERFACE.SHOW, { isForce });
12
+ if (action === this.CONST.INTERFACE.EXEC_ACTIONS.HIDE)
13
+ await this.emit(this.EVENTS.INTERFACE.HIDE, { isForce });
14
+ if (action === this.CONST.INTERFACE.EXEC_ACTIONS.VIEW)
15
+ await this.emit(this.EVENTS.INTERFACE.VIEW, { view: execArg, isForce });
16
+ this.emitNext();
17
+ };
18
+ }
package/dist/types.d.ts CHANGED
@@ -4,11 +4,11 @@ import type { Constants as ControlsConstants, PluginName as ControlsPluginName }
4
4
  import type { PluginName as InteractPluginName, SubscribeEvents as InteractSubscribeEvents } from "@vnejs/contracts.core.interact";
5
5
  import type { PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/contracts.core.scenario";
6
6
  import type { PluginName as StatePluginName, SubscribeEvents as StateSubscribeEvents } from "@vnejs/contracts.core.state";
7
- import type { PluginName as TextPluginName, Params as TextParams, SubscribeEvents as TextSubscribeEvents } from "@vnejs/contracts.text";
8
- import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.views.scenario.interface";
7
+ import type { PluginName as TextPluginName, Params as TextParams } from "@vnejs/contracts.text";
8
+ import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.views.scenario.interface";
9
9
  import type { InterfacePluginState } from "./utils/interface.js";
10
- export type InterfacePluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<ScenarioPluginName, ScenarioSubscribeEvents> & Record<StatePluginName, StateSubscribeEvents> & Record<TextPluginName, TextSubscribeEvents> & Record<InteractPluginName, InteractSubscribeEvents>;
11
- export type InterfacePluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
10
+ export type InterfacePluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<ScenarioPluginName, ScenarioSubscribeEvents> & Record<StatePluginName, StateSubscribeEvents> & Record<InteractPluginName, InteractSubscribeEvents>;
11
+ export type InterfacePluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants> & Record<PluginName, Constants>;
12
12
  export type InterfacePluginSettings = ModuleComponentsSettings;
13
13
  export type InterfacePluginParams = ModuleComponentsParams & Record<PluginName, Params> & Record<TextPluginName, TextParams>;
14
14
  export type InterfacePluginViewState = InterfacePluginState & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.views.scenario.interface",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,6 +36,7 @@
36
36
  "@vnejs/helpers": "~0.2.0",
37
37
  "@vnejs/module.core": "~0.2.0",
38
38
  "@vnejs/module.components": "~0.2.0",
39
+ "@vnejs/module.controller.accept": "~0.2.0",
39
40
  "@vnejs/contracts.text": "~0.2.0",
40
41
  "@vnejs/contracts.text.meet": "~0.2.0",
41
42
  "@vnejs/contracts.text.wall": "~0.2.0",
@@ -52,6 +53,7 @@
52
53
  "@vnejs/helpers": "~0.2.0",
53
54
  "@vnejs/module.core": "~0.2.0",
54
55
  "@vnejs/module.components": "~0.2.0",
56
+ "@vnejs/module.controller.accept": "~0.2.0",
55
57
  "@vnejs/contracts.text.meet": "~0.2.0",
56
58
  "@vnejs/contracts.text.wall": "~0.2.0",
57
59
  "@vnejs/shared": "~0.2.0",
package/src/index.ts CHANGED
@@ -2,10 +2,20 @@ import "@vnejs/contracts.views.scenario.interface";
2
2
  import "@vnejs/contracts.text.meet";
3
3
 
4
4
  import { regPlugin } from "@vnejs/shared";
5
- import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.scenario.interface";
5
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.scenario.interface";
6
6
 
7
7
  import { InterfaceController } from "./modules/controller.js";
8
+ import { InterfaceControllerAccept } from "./modules/controller.accept.js";
9
+ import { InterfaceActions } from "./modules/actions.js";
8
10
  import { Interface } from "./modules/interface.js";
11
+ import { InterfaceScenario } from "./modules/scenario.js";
9
12
  import { InterfaceView } from "./modules/view.js";
10
13
 
11
- regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [InterfaceController, Interface, InterfaceView]);
14
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [
15
+ InterfaceController,
16
+ InterfaceControllerAccept,
17
+ Interface,
18
+ InterfaceActions,
19
+ InterfaceScenario,
20
+ InterfaceView,
21
+ ]);
@@ -0,0 +1,41 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+
3
+ import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
4
+ import type { InterfaceForcePayload, InterfaceViewPayload } from "../utils/interface.js";
5
+
6
+ export class InterfaceActions extends ModuleCore<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams> {
7
+ name = "interface.actions";
8
+
9
+ subscribe = () => {
10
+ this.on(this.EVENTS.INTERFACE.SHOW, this.onShow);
11
+ this.on(this.EVENTS.INTERFACE.HIDE, this.onHide);
12
+ this.on(this.EVENTS.INTERFACE.VISIBLE, this.onVisible);
13
+ this.on(this.EVENTS.INTERFACE.TEXT_HIDE, this.onTextHide);
14
+ this.on(this.EVENTS.INTERFACE.VIEW, this.onView);
15
+ };
16
+
17
+ onShow = ({ isForce = false }: InterfaceForcePayload = {}) => !this.globalState.interface.isShow && this.setShow(true, isForce);
18
+ onHide = ({ isForce = false }: InterfaceForcePayload = {}) => this.globalState.interface.isShow && this.setShow(false, isForce);
19
+ onVisible = ({ isForce = false }: InterfaceForcePayload = {}) => this.setVisible(!this.globalState.interface.isVisible, isForce);
20
+ onTextHide = () => this.emit(this.EVENTS.INTERFACE.TEXT_CHANGED, { tokens: [], uid: "", tokensVisible: 0 });
21
+ onView = ({ view, isForce = false }: InterfaceViewPayload = {}) => this.setView(view, isForce);
22
+
23
+ setShow = async (isShow: boolean, isForce = false) => {
24
+ this.globalState.interface.isShow = isShow;
25
+
26
+ if (isShow && !this.globalState.interface.isVisible) await this.setVisible(true, isForce);
27
+
28
+ return this.emit(this.EVENTS.INTERFACE.SHOW_CHANGED, { isForce });
29
+ };
30
+ setVisible = (isVisible: boolean, isForce = false) => {
31
+ this.globalState.interface.isVisible = isVisible;
32
+
33
+ return this.emit(this.EVENTS.INTERFACE.VISIBLE_CHANGED, { isForce });
34
+ };
35
+ setView = async (view?: string, isForce = false) => {
36
+ this.globalState.interface.view = view ?? "";
37
+
38
+ await this.emit(this.EVENTS.INTERFACE.VIEW_CHANGED, { isForce });
39
+ await this.waitRerender();
40
+ };
41
+ }
@@ -0,0 +1,20 @@
1
+ import { ModuleControllerAccept } from "@vnejs/module.controller.accept";
2
+
3
+ import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
4
+
5
+ export class InterfaceControllerAccept extends ModuleControllerAccept<
6
+ InterfacePluginEvents,
7
+ InterfacePluginConstants,
8
+ InterfacePluginSettings,
9
+ InterfacePluginParams
10
+ > {
11
+ name = "interface.controller.accept";
12
+
13
+ EVENT_SHOW = this.EVENTS.INTERFACE.VIEW_SHOW;
14
+ EVENT_HIDE = this.EVENTS.INTERFACE.VIEW_HIDE;
15
+ EVENT_ACCEPT = this.EVENTS.INTERFACE.INTERACT;
16
+
17
+ CONTROLS_ZINDEX = this.PARAMS.INTERFACE.ZINDEX;
18
+
19
+ onAccept = () => void this.emit(this.globalState.interface.isVisible ? this.EVENTS.INTERACT.EMIT : this.EVENTS.INTERFACE.VISIBLE);
20
+ }
@@ -1,6 +1,5 @@
1
1
  import { ModuleController } from "@vnejs/module.components";
2
2
  import type { ControlsPopPayload, ControlsPushPayload } from "@vnejs/module.components";
3
- import { CONSTANTS as ControlsConstants } from "@vnejs/contracts.controls";
4
3
  import { getTextSpeakerInfo } from "@vnejs/contracts.text";
5
4
 
6
5
  import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
@@ -23,10 +22,7 @@ export class InterfaceController extends ModuleController<
23
22
 
24
23
  EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE.VIEW_UPDATE;
25
24
 
26
- CONTROLS = {
27
- [ControlsConstants.BUTTONS.INTERACT]: () => void this.emit(this.EVENTS.INTERFACE.INTERACT),
28
- [ControlsConstants.BUTTONS.ACCEPT]: () => void this.emit(this.EVENTS.INTERFACE.INTERACT),
29
- };
25
+ CONTROLS = {};
30
26
  CONTROLS_UNVISIBLE = {};
31
27
  CONTROLS_INDEX = this.PARAMS.INTERFACE.ZINDEX;
32
28
 
@@ -1,18 +1,7 @@
1
1
  import { ModuleCore, type ModuleGlobalStateRegistry } from "@vnejs/module.core";
2
- import { tokenizeExecLine } from "@vnejs/helpers";
3
-
4
- import type { LineExecHandlerArg } from "@vnejs/module.core";
5
-
6
- import type { InterfaceVisibleTokensChangedPayload } from "@vnejs/contracts.views.scenario.interface";
7
2
 
8
3
  import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
9
- import type {
10
- InterfaceForcePayload,
11
- InterfaceModuleState,
12
- InterfaceSpeakerChangedPayload,
13
- InterfaceTextChangedPayload,
14
- InterfaceViewPayload,
15
- } from "../utils/interface.js";
4
+ import type { InterfaceModuleState } from "../utils/interface.js";
16
5
 
17
6
  export class Interface extends ModuleCore<
18
7
  InterfacePluginEvents,
@@ -24,57 +13,10 @@ export class Interface extends ModuleCore<
24
13
  name = "interface";
25
14
 
26
15
  subscribe = () => {
27
- this.on(this.EVENTS.INTERFACE.INTERACT, this.onInteract);
28
- this.on(this.EVENTS.INTERFACE.SHOW, this.onShow);
29
- this.on(this.EVENTS.INTERFACE.HIDE, this.onHide);
30
- this.on(this.EVENTS.INTERFACE.VISIBLE, this.onVisible);
31
- this.on(this.EVENTS.INTERFACE.TEXT_HIDE, this.onTextHide);
32
- this.on(this.EVENTS.INTERFACE.VIEW, this.onView);
33
- this.on(this.EVENTS.INTERFACE.VISIBLE_TOKENS_CHANGED, this.onVisibleTokensChanged);
34
-
35
- this.on(this.EVENTS.TEXT.CHANGED, this.onTextChanged);
36
- this.on(this.EVENTS.TEXT.SPEAKER_CHANGED, this.onTextSpeakerChanged);
37
-
38
16
  this.on(this.EVENTS.STATE.SET, this.onStateSet);
39
17
  this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
40
18
  };
41
19
 
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
- };
50
-
51
- onLineExec = async ({ line = "" }: LineExecHandlerArg = {}) => {
52
- const isForce = this.shared.viewForceAnimationSources.isNotEmpty();
53
-
54
- const [action = "", execArg = ""] = tokenizeExecLine(line);
55
-
56
- if (action === "show") await this.emit(this.EVENTS.INTERFACE.SHOW, { isForce });
57
- if (action === "hide") await this.emit(this.EVENTS.INTERFACE.HIDE, { isForce });
58
- if (action === "view") await this.emit(this.EVENTS.INTERFACE.VIEW, { view: execArg, isForce });
59
-
60
- this.emitNext();
61
- };
62
-
63
- onInteract = () => this.emit(this.state.isVisible ? this.EVENTS.INTERACT.EMIT : this.EVENTS.INTERFACE.VISIBLE);
64
- onShow = ({ isForce = false }: InterfaceForcePayload = {}) => !this.state.isShow && this.setShow(true, isForce);
65
- onHide = ({ isForce = false }: InterfaceForcePayload = {}) => this.state.isShow && this.setShow(false, isForce);
66
- onVisible = ({ isForce = false }: InterfaceForcePayload = {}) => this.setVisible(!this.state.isVisible, isForce);
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);
74
- onTextSpeakerChanged = ({ speaker }: InterfaceSpeakerChangedPayload = {}) => this.emitSpeakerChanged(speaker);
75
- onTextEmitBefore = () => this.emit(this.EVENTS.INTERFACE.SHOW);
76
- onTextHide = () => this.emitTextChanged([], "", 0);
77
- onView = ({ view, isForce = false }: InterfaceViewPayload = {}) => this.setView(view, isForce);
78
20
  onStateSet = (payload: ModuleGlobalStateRegistry) => {
79
21
  const moduleState = this.getStateSlice(payload);
80
22
 
@@ -82,27 +24,6 @@ export class Interface extends ModuleCore<
82
24
  };
83
25
  onStateClear = () => this.setNewState(this.PARAMS.INTERFACE.DEFAULT_VIEW, false, false);
84
26
 
85
- setView = async (view?: string, isForce = false) => {
86
- this.state.view = view ?? "";
87
-
88
- await this.emit(this.EVENTS.INTERFACE.VIEW_CHANGED, { isForce });
89
- await this.waitRerender();
90
- };
91
- setShow = async (isShow: boolean, isForce = false) => {
92
- this.state.isShow = isShow;
93
-
94
- if (isShow && !this.state.isVisible) await this.setVisible(true, isForce);
95
-
96
- return this.emit(this.EVENTS.INTERFACE.SHOW_CHANGED, { isForce });
97
- };
98
- setVisible = (isVisible: boolean, isForce = false) => {
99
- this.state.isVisible = isVisible;
100
-
101
- return this.emit(this.EVENTS.INTERFACE.VISIBLE_CHANGED, { isForce });
102
- };
103
- emitTextChanged = (tokens: InterfaceTextChangedPayload["tokens"] = [], uid = "", tokensVisible?: number) =>
104
- this.emit(this.EVENTS.INTERFACE.TEXT_CHANGED, { tokens, uid, tokensVisible });
105
- emitSpeakerChanged = (speaker = "") => this.emit(this.EVENTS.INTERFACE.SPEAKER_CHANGED, { speaker });
106
27
  setNewState = (view?: string, isVisible?: boolean, isShow?: boolean) => {
107
28
  Object.assign(this.state, { isShow, view, isVisible });
108
29
 
@@ -0,0 +1,26 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import { tokenizeExecLine } from "@vnejs/helpers";
3
+
4
+ import type { LineExecHandlerArg } from "@vnejs/module.core";
5
+
6
+ import type { InterfacePluginConstants, InterfacePluginEvents, InterfacePluginParams, InterfacePluginSettings } from "../types.js";
7
+
8
+ export class InterfaceScenario extends ModuleCore<InterfacePluginEvents, InterfacePluginConstants, InterfacePluginSettings, InterfacePluginParams> {
9
+ name = "interface.scenario";
10
+
11
+ execName = "interface";
12
+
13
+ init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.execName, handler: this.onLineExec });
14
+
15
+ onLineExec = async ({ line = "" }: LineExecHandlerArg = {}) => {
16
+ const isForce = this.shared.viewForceAnimationSources.isNotEmpty();
17
+
18
+ const [action = "", execArg = ""] = tokenizeExecLine(line);
19
+
20
+ if (action === this.CONST.INTERFACE.EXEC_ACTIONS.SHOW) await this.emit(this.EVENTS.INTERFACE.SHOW, { isForce });
21
+ if (action === this.CONST.INTERFACE.EXEC_ACTIONS.HIDE) await this.emit(this.EVENTS.INTERFACE.HIDE, { isForce });
22
+ if (action === this.CONST.INTERFACE.EXEC_ACTIONS.VIEW) await this.emit(this.EVENTS.INTERFACE.VIEW, { view: execArg, isForce });
23
+
24
+ this.emitNext();
25
+ };
26
+ }
@@ -0,0 +1,76 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { InterfaceControllerAccept } from "../modules/controller.accept.js";
6
+ import { CONTROLS_EVENTS, createInterfaceTestModule, INTERACT_EVENTS, PARAMS, registerInterfacePluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
7
+
8
+ describe("InterfaceControllerAccept", () => {
9
+ beforeEach(() => {
10
+ registerInterfacePluginVne();
11
+ });
12
+
13
+ it("VIEW_SHOW pushes ACCEPT and INTERACT controls", async () => {
14
+ const { module, observer } = createInterfaceTestModule(InterfaceControllerAccept);
15
+ const accept = module as InterfaceControllerAccept;
16
+ const push = spyEvent(observer, CONTROLS_EVENTS.PUSH);
17
+
18
+ await observer.emit(SUBSCRIBE_EVENTS.VIEW_SHOW);
19
+
20
+ expect(push).toHaveBeenCalledExactlyOnceWith(
21
+ expect.objectContaining({
22
+ key: "interface.controller.accept",
23
+ checkNext: true,
24
+ index: accept.PARAMS.INTERFACE.ZINDEX + 1,
25
+ }),
26
+ );
27
+ expect(push.mock.calls[0][0].controls).toHaveProperty(accept.CONST.CONTROLS.BUTTONS.ACCEPT);
28
+ expect(push.mock.calls[0][0].controls).toHaveProperty(accept.CONST.CONTROLS.BUTTONS.INTERACT);
29
+ });
30
+
31
+ it("VIEW_HIDE pops ACCEPT controls", async () => {
32
+ const { observer } = createInterfaceTestModule(InterfaceControllerAccept);
33
+ const pop = spyEvent(observer, CONTROLS_EVENTS.POP);
34
+
35
+ await observer.emit(SUBSCRIBE_EVENTS.VIEW_HIDE);
36
+
37
+ expect(pop).toHaveBeenCalledExactlyOnceWith({ key: "interface.controller.accept" });
38
+ });
39
+
40
+ it("ACCEPT and INTERACT emit INTERFACE.INTERACT", async () => {
41
+ const { module, observer } = createInterfaceTestModule(InterfaceControllerAccept);
42
+ const accept = module as InterfaceControllerAccept;
43
+ const interact = spyEvent(observer, SUBSCRIBE_EVENTS.INTERACT);
44
+
45
+ accept.CONTROLS[accept.CONST.CONTROLS.BUTTONS.ACCEPT]();
46
+ accept.CONTROLS[accept.CONST.CONTROLS.BUTTONS.INTERACT]();
47
+ await Promise.resolve();
48
+ await Promise.resolve();
49
+
50
+ expect(interact).toHaveBeenCalledTimes(2);
51
+ });
52
+
53
+ it("INTERACT emits VISIBLE when interface is hidden", async () => {
54
+ const { observer } = createInterfaceTestModule(InterfaceControllerAccept);
55
+ const visible = spyEvent(observer, SUBSCRIBE_EVENTS.VISIBLE);
56
+ const emit = spyEvent(observer, INTERACT_EVENTS.EMIT);
57
+
58
+ await observer.emit(SUBSCRIBE_EVENTS.INTERACT);
59
+
60
+ expect(visible).toHaveBeenCalledOnce();
61
+ expect(emit).not.toHaveBeenCalled();
62
+ });
63
+
64
+ it("INTERACT emits INTERACT.EMIT when interface is visible", async () => {
65
+ const { observer } = createInterfaceTestModule(InterfaceControllerAccept, {
66
+ state: { interface: { view: PARAMS.DEFAULT_VIEW, isShow: true, isVisible: true } },
67
+ });
68
+ const visible = spyEvent(observer, SUBSCRIBE_EVENTS.VISIBLE);
69
+ const emit = spyEvent(observer, INTERACT_EVENTS.EMIT);
70
+
71
+ await observer.emit(SUBSCRIBE_EVENTS.INTERACT);
72
+
73
+ expect(emit).toHaveBeenCalledOnce();
74
+ expect(visible).not.toHaveBeenCalled();
75
+ });
76
+ });
@@ -0,0 +1,85 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { InterfaceActions } from "../modules/actions.js";
6
+ import { createInterfaceTestModule, registerInterfacePluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
7
+
8
+ describe("InterfaceActions", () => {
9
+ beforeEach(() => {
10
+ registerInterfacePluginVne();
11
+ });
12
+
13
+ it("SHOW sets isShow and emits SHOW_CHANGED", async () => {
14
+ const { module, observer } = createInterfaceTestModule(InterfaceActions);
15
+ const showChanged = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW_CHANGED);
16
+
17
+ await (module as InterfaceActions).onShow();
18
+
19
+ expect(module.globalState.interface.isShow).toBe(true);
20
+ expect(showChanged).toHaveBeenCalledOnce();
21
+ expect(showChanged).toHaveBeenCalledWith({ isForce: false });
22
+ });
23
+
24
+ it("SHOW makes interface visible when it was hidden", async () => {
25
+ const { module, observer } = createInterfaceTestModule(InterfaceActions);
26
+ const visibleChanged = spyEvent(observer, SUBSCRIBE_EVENTS.VISIBLE_CHANGED);
27
+
28
+ await (module as InterfaceActions).onShow();
29
+
30
+ expect(module.globalState.interface.isVisible).toBe(true);
31
+ expect(visibleChanged).toHaveBeenCalledOnce();
32
+ });
33
+
34
+ it("SHOW is a no-op when already shown", async () => {
35
+ const { module, observer } = createInterfaceTestModule(InterfaceActions);
36
+ module.globalState.interface.isShow = true;
37
+ const showChanged = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW_CHANGED);
38
+
39
+ await (module as InterfaceActions).onShow();
40
+
41
+ expect(showChanged).not.toHaveBeenCalled();
42
+ });
43
+
44
+ it("HIDE clears isShow and emits SHOW_CHANGED", async () => {
45
+ const { module, observer } = createInterfaceTestModule(InterfaceActions);
46
+ module.globalState.interface.isShow = true;
47
+ const showChanged = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW_CHANGED);
48
+
49
+ await (module as InterfaceActions).onHide();
50
+
51
+ expect(module.globalState.interface.isShow).toBe(false);
52
+ expect(showChanged).toHaveBeenCalledOnce();
53
+ });
54
+
55
+ it("VISIBLE toggles isVisible", async () => {
56
+ const { module, observer } = createInterfaceTestModule(InterfaceActions);
57
+ const visibleChanged = spyEvent(observer, SUBSCRIBE_EVENTS.VISIBLE_CHANGED);
58
+
59
+ await (module as InterfaceActions).onVisible();
60
+
61
+ expect(module.globalState.interface.isVisible).toBe(true);
62
+ expect(visibleChanged).toHaveBeenCalledWith({ isForce: false });
63
+ });
64
+
65
+ it("TEXT_HIDE emits empty TEXT_CHANGED", async () => {
66
+ const { module, observer } = createInterfaceTestModule(InterfaceActions);
67
+ const textChanged = spyEvent(observer, SUBSCRIBE_EVENTS.TEXT_CHANGED);
68
+
69
+ await (module as InterfaceActions).onTextHide();
70
+
71
+ expect(textChanged).toHaveBeenCalledOnce();
72
+ expect(textChanged).toHaveBeenCalledWith({ tokens: [], uid: "", tokensVisible: 0 });
73
+ });
74
+
75
+ it("VIEW writes view and emits VIEW_CHANGED", async () => {
76
+ const { module, observer } = createInterfaceTestModule(InterfaceActions);
77
+ const viewChanged = spyEvent(observer, SUBSCRIBE_EVENTS.VIEW_CHANGED);
78
+
79
+ await (module as InterfaceActions).onView({ view: "wall" });
80
+
81
+ expect(module.globalState.interface.view).toBe("wall");
82
+ expect(viewChanged).toHaveBeenCalledOnce();
83
+ expect(viewChanged).toHaveBeenCalledWith({ isForce: false });
84
+ });
85
+ });
@@ -1,62 +1,13 @@
1
1
  import { beforeEach, describe, expect, it } from "vitest";
2
2
 
3
- import { spyEvent } from "@vnejs/test-utils";
4
-
5
3
  import { Interface } from "../modules/interface.js";
6
- import { createInterfaceTestModule, PARAMS, registerInterfacePluginVne, SCENARIO_EVENTS, SUBSCRIBE_EVENTS, TEXT_EVENTS } from "./setup.js";
4
+ import { createInterfaceTestModule, PARAMS, registerInterfacePluginVne } from "./setup.js";
7
5
 
8
6
  describe("Interface", () => {
9
7
  beforeEach(() => {
10
8
  registerInterfacePluginVne();
11
9
  });
12
10
 
13
- it("init registers scenario line exec and text emit before handlers", async () => {
14
- const { module, observer } = createInterfaceTestModule(Interface, { subscribe: false });
15
- const lineExecReg = spyEvent(observer, SCENARIO_EVENTS.LINE_EXEC_REG);
16
- const textEmitBeforeReg = spyEvent(observer, TEXT_EVENTS.EMIT_BEFORE_REG);
17
-
18
- await (module as Interface).init();
19
-
20
- expect(lineExecReg).toHaveBeenCalledOnce();
21
- expect(textEmitBeforeReg).toHaveBeenCalledOnce();
22
- });
23
-
24
- it("onLineExec show sets isShow", async () => {
25
- const { module } = createInterfaceTestModule(Interface);
26
-
27
- await (module as Interface).onLineExec({ line: "show" });
28
-
29
- expect((module as Interface).state.isShow).toBe(true);
30
- });
31
-
32
- it("onLineExec hide clears isShow", async () => {
33
- const { module } = createInterfaceTestModule(Interface);
34
-
35
- (module as Interface).state.isShow = true;
36
- await (module as Interface).onLineExec({ line: "hide" });
37
-
38
- expect((module as Interface).state.isShow).toBe(false);
39
- });
40
-
41
- it("onLineExec view changes view", async () => {
42
- const { module } = createInterfaceTestModule(Interface);
43
- const viewChanged = spyEvent(module.observer!, SUBSCRIBE_EVENTS.VIEW_CHANGED);
44
-
45
- await (module as Interface).onLineExec({ line: "view wall" });
46
-
47
- expect((module as Interface).state.view).toBe("wall");
48
- expect(viewChanged).toHaveBeenCalledOnce();
49
- });
50
-
51
- it("onInteract emits VISIBLE when interface is hidden", async () => {
52
- const { module, observer } = createInterfaceTestModule(Interface);
53
- const visible = spyEvent(observer, SUBSCRIBE_EVENTS.VISIBLE);
54
-
55
- await observer.emit(SUBSCRIBE_EVENTS.INTERACT);
56
-
57
- expect(visible).toHaveBeenCalledOnce();
58
- });
59
-
60
11
  it("onStateClear resets to default view", async () => {
61
12
  const { module } = createInterfaceTestModule(Interface);
62
13
 
@@ -0,0 +1,52 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { InterfaceScenario } from "../modules/scenario.js";
6
+ import { createInterfaceTestModule, registerInterfacePluginVne, SCENARIO_EVENTS, SUBSCRIBE_EVENTS } from "./setup.js";
7
+
8
+ describe("InterfaceScenario", () => {
9
+ beforeEach(() => {
10
+ registerInterfacePluginVne();
11
+ });
12
+
13
+ it("init registers scenario line exec handler", async () => {
14
+ const { module, observer } = createInterfaceTestModule(InterfaceScenario, { subscribe: false });
15
+ const lineExecReg = spyEvent(observer, SCENARIO_EVENTS.LINE_EXEC_REG);
16
+
17
+ await (module as InterfaceScenario).init();
18
+
19
+ expect(lineExecReg).toHaveBeenCalledOnce();
20
+ expect(lineExecReg).toHaveBeenCalledWith({ module: "interface", handler: (module as InterfaceScenario).onLineExec });
21
+ });
22
+
23
+ it("onLineExec show emits SHOW", async () => {
24
+ const { module, observer } = createInterfaceTestModule(InterfaceScenario);
25
+ const show = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW);
26
+
27
+ await (module as InterfaceScenario).onLineExec({ line: "show" });
28
+
29
+ expect(show).toHaveBeenCalledOnce();
30
+ expect(show).toHaveBeenCalledWith({ isForce: false });
31
+ });
32
+
33
+ it("onLineExec hide emits HIDE", async () => {
34
+ const { module, observer } = createInterfaceTestModule(InterfaceScenario);
35
+ const hide = spyEvent(observer, SUBSCRIBE_EVENTS.HIDE);
36
+
37
+ await (module as InterfaceScenario).onLineExec({ line: "hide" });
38
+
39
+ expect(hide).toHaveBeenCalledOnce();
40
+ expect(hide).toHaveBeenCalledWith({ isForce: false });
41
+ });
42
+
43
+ it("onLineExec view emits VIEW", async () => {
44
+ const { module, observer } = createInterfaceTestModule(InterfaceScenario);
45
+ const view = spyEvent(observer, SUBSCRIBE_EVENTS.VIEW);
46
+
47
+ await (module as InterfaceScenario).onLineExec({ line: "view wall" });
48
+
49
+ expect(view).toHaveBeenCalledOnce();
50
+ expect(view).toHaveBeenCalledWith({ view: "wall", isForce: false });
51
+ });
52
+ });
@@ -1,7 +1,8 @@
1
1
  import { CONSTANTS as CONTROLS_CONST, PLUGIN_NAME as CONTROLS, SUBSCRIBE_EVENTS as CONTROLS_EVENTS } from "@vnejs/contracts.controls";
2
+ import { SUBSCRIBE_EVENTS as INTERACT_EVENTS } from "@vnejs/contracts.core.interact";
2
3
  import { SUBSCRIBE_EVENTS as SCENARIO_EVENTS } from "@vnejs/contracts.core.scenario";
3
4
  import { SUBSCRIBE_EVENTS as TEXT_EVENTS, PLUGIN_NAME as TEXT } from "@vnejs/contracts.text";
4
- import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.scenario.interface";
5
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.scenario.interface";
5
6
  import { SourcesSet } from "@vnejs/sources-set";
6
7
  import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin, stubEvent, stubSilentEvent } from "@vnejs/test-utils";
7
8
 
@@ -9,7 +10,7 @@ export const registerInterfacePluginVne = () => {
9
10
  registerCoreVne();
10
11
  registerVnePlugin(CONTROLS, { constants: CONTROLS_CONST, events: CONTROLS_EVENTS });
11
12
  registerVnePlugin(TEXT, { events: TEXT_EVENTS });
12
- registerVnePlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS });
13
+ registerVnePlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS });
13
14
  };
14
15
 
15
16
  export const createInterfaceTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
@@ -35,6 +36,7 @@ export const createInterfaceTestModule = <T extends Parameters<typeof baseCreate
35
36
  stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.VIEW_UPDATE);
36
37
  stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.VIEW_SHOW);
37
38
  stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.VIEW_HIDE);
39
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.INTERACT);
38
40
  stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.SHOW_CHANGED);
39
41
  stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.VISIBLE_CHANGED);
40
42
  stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.VISIBLE);
@@ -45,4 +47,4 @@ export const createInterfaceTestModule = <T extends Parameters<typeof baseCreate
45
47
  return result;
46
48
  };
47
49
 
48
- export { SUBSCRIBE_EVENTS, PARAMS, PLUGIN_NAME, SCENARIO_EVENTS, TEXT_EVENTS, CONTROLS_EVENTS };
50
+ export { SUBSCRIBE_EVENTS, PARAMS, PLUGIN_NAME, SCENARIO_EVENTS, TEXT_EVENTS, CONTROLS_EVENTS, INTERACT_EVENTS };
package/src/types.ts CHANGED
@@ -4,8 +4,8 @@ import type { Constants as ControlsConstants, PluginName as ControlsPluginName }
4
4
  import type { PluginName as InteractPluginName, SubscribeEvents as InteractSubscribeEvents } from "@vnejs/contracts.core.interact";
5
5
  import type { PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/contracts.core.scenario";
6
6
  import type { PluginName as StatePluginName, SubscribeEvents as StateSubscribeEvents } from "@vnejs/contracts.core.state";
7
- import type { PluginName as TextPluginName, Params as TextParams, SubscribeEvents as TextSubscribeEvents } from "@vnejs/contracts.text";
8
- import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.views.scenario.interface";
7
+ import type { PluginName as TextPluginName, Params as TextParams } from "@vnejs/contracts.text";
8
+ import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.views.scenario.interface";
9
9
 
10
10
  import type { InterfacePluginState } from "./utils/interface.js";
11
11
 
@@ -13,10 +13,9 @@ export type InterfacePluginEvents = ModuleComponentsEvents &
13
13
  Record<PluginName, SubscribeEvents> &
14
14
  Record<ScenarioPluginName, ScenarioSubscribeEvents> &
15
15
  Record<StatePluginName, StateSubscribeEvents> &
16
- Record<TextPluginName, TextSubscribeEvents> &
17
16
  Record<InteractPluginName, InteractSubscribeEvents>;
18
17
 
19
- export type InterfacePluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
18
+ export type InterfacePluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants> & Record<PluginName, Constants>;
20
19
 
21
20
  export type InterfacePluginSettings = ModuleComponentsSettings;
22
21