@vnejs/plugins.controllers.screens.intro 0.0.0-stage → 0.2.17

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.
Files changed (40) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +15 -0
  3. package/dist/modules/controller.bg.d.ts +13 -0
  4. package/dist/modules/controller.bg.js +11 -0
  5. package/dist/modules/controller.d.ts +12 -0
  6. package/dist/modules/controller.interact.d.ts +11 -0
  7. package/dist/modules/controller.interact.js +9 -0
  8. package/dist/modules/controller.js +10 -0
  9. package/dist/modules/intro.d.ts +13 -0
  10. package/dist/modules/intro.js +31 -0
  11. package/dist/modules/view.d.ts +10 -0
  12. package/dist/modules/view.js +9 -0
  13. package/dist/types.d.ts +17 -0
  14. package/dist/types.js +1 -0
  15. package/dist/view/components/IntroHint.d.ts +8 -0
  16. package/dist/view/components/IntroHint.js +5 -0
  17. package/dist/view/components/IntroTexts.d.ts +8 -0
  18. package/dist/view/components/IntroTexts.js +8 -0
  19. package/dist/view/components/index.d.ts +2 -0
  20. package/dist/view/components/index.js +2 -0
  21. package/dist/view/index.d.ts +3 -0
  22. package/dist/view/index.js +8 -0
  23. package/package.json +58 -4
  24. package/src/index.ts +19 -0
  25. package/src/modules/controller.bg.ts +18 -0
  26. package/src/modules/controller.interact.ts +22 -0
  27. package/src/modules/controller.ts +15 -0
  28. package/src/modules/intro.ts +44 -0
  29. package/src/modules/view.ts +17 -0
  30. package/src/tests/controller.bg.test.ts +38 -0
  31. package/src/tests/controller.interact.test.ts +87 -0
  32. package/src/tests/intro.test.ts +50 -0
  33. package/src/tests/setup.ts +41 -0
  34. package/src/types.ts +35 -0
  35. package/src/view/components/IntroHint.tsx +20 -0
  36. package/src/view/components/IntroTexts.tsx +27 -0
  37. package/src/view/components/index.ts +2 -0
  38. package/src/view/index.tsx +51 -0
  39. package/tsconfig.json +10 -0
  40. package/README.md +0 -3
@@ -0,0 +1 @@
1
+ import "@vnejs/contracts.controllers.screens.intro";
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import "@vnejs/contracts.controllers.screens.intro";
2
+ import { regPlugin } from "@vnejs/registry";
3
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.screens.intro";
4
+ import { IntroControllerBg } from "./modules/controller.bg.js";
5
+ import { IntroControllerInteract } from "./modules/controller.interact.js";
6
+ import { IntroController } from "./modules/controller.js";
7
+ import { Intro } from "./modules/intro.js";
8
+ import { IntroView } from "./modules/view.js";
9
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [
10
+ IntroController,
11
+ IntroControllerBg,
12
+ IntroControllerInteract,
13
+ Intro,
14
+ IntroView,
15
+ ]);
@@ -0,0 +1,13 @@
1
+ import { ModuleControllerBg } from "@vnejs/module.controller.bg";
2
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
3
+ import type { IntroPluginState } from "../types.js";
4
+ export declare class IntroControllerBg extends ModuleControllerBg<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> {
5
+ name: string;
6
+ EVENT_SHOW: "vne:intro:show";
7
+ EVENT_HIDE: "vne:intro:hide";
8
+ EVENT_UPDATE_STATE: "vne:intro:update_state";
9
+ EVENT_UPDATE_FAST: "vne:intro:update_fast";
10
+ BGNAME: string;
11
+ QUALITY_SETTING: "vne:canvas:quality";
12
+ IS_START_PRELOAD_ENABLED: boolean;
13
+ }
@@ -0,0 +1,11 @@
1
+ import { ModuleControllerBg } from "@vnejs/module.controller.bg";
2
+ export class IntroControllerBg extends ModuleControllerBg {
3
+ name = "intro.controller.bg";
4
+ EVENT_SHOW = this.EVENTS.INTRO.SHOW;
5
+ EVENT_HIDE = this.EVENTS.INTRO.HIDE;
6
+ EVENT_UPDATE_STATE = this.EVENTS.INTRO.UPDATE_STATE;
7
+ EVENT_UPDATE_FAST = this.EVENTS.INTRO.UPDATE_FAST;
8
+ BGNAME = this.PARAMS.INTRO.BACKGROUND;
9
+ QUALITY_SETTING = this.SETTINGS.LAYER.QUALITY;
10
+ IS_START_PRELOAD_ENABLED = true;
11
+ }
@@ -0,0 +1,12 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
3
+ import type { IntroPluginState } from "../types.js";
4
+ export declare class IntroController extends ModuleController<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> {
5
+ name: string;
6
+ EVENT_UPDATE_VIEW: "vne:intro:update";
7
+ EVENT_UPDATE_STATE: "vne:intro:update_state";
8
+ EVENT_UPDATE_FAST: "vne:intro:update_fast";
9
+ EVENT_UPDATE_FORCE: "vne:intro:update_force";
10
+ EVENT_SHOW: "vne:intro:show";
11
+ EVENT_HIDE: "vne:intro:hide";
12
+ }
@@ -0,0 +1,11 @@
1
+ import { ModuleControllerInteract } from "@vnejs/module.controller.interact";
2
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
3
+ import type { IntroPluginState } from "../types.js";
4
+ export declare class IntroControllerInteract extends ModuleControllerInteract<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> {
5
+ name: string;
6
+ EVENT_SHOW: "vne:intro:show";
7
+ EVENT_HIDE: "vne:intro:hide";
8
+ CONTROLS_ZINDEX: number;
9
+ CONTROLS_CHECK_NEXT: boolean;
10
+ onInteract: () => Promise<import("@vnejs/registry").EmitResults<"vne:intro:interact">> | undefined;
11
+ }
@@ -0,0 +1,9 @@
1
+ import { ModuleControllerInteract } from "@vnejs/module.controller.interact";
2
+ export class IntroControllerInteract extends ModuleControllerInteract {
3
+ name = "intro.controller.interact";
4
+ EVENT_SHOW = this.EVENTS.INTRO.SHOW;
5
+ EVENT_HIDE = this.EVENTS.INTRO.HIDE;
6
+ CONTROLS_ZINDEX = this.PARAMS.INTRO.ZINDEX;
7
+ CONTROLS_CHECK_NEXT = false;
8
+ onInteract = () => this.emit(this.EVENTS.INTRO.INTERACT);
9
+ }
@@ -0,0 +1,10 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+ export class IntroController extends ModuleController {
3
+ name = "intro.controller";
4
+ EVENT_UPDATE_VIEW = this.EVENTS.INTRO.UPDATE;
5
+ EVENT_UPDATE_STATE = this.EVENTS.INTRO.UPDATE_STATE;
6
+ EVENT_UPDATE_FAST = this.EVENTS.INTRO.UPDATE_FAST;
7
+ EVENT_UPDATE_FORCE = this.EVENTS.INTRO.UPDATE_FORCE;
8
+ EVENT_SHOW = this.EVENTS.INTRO.SHOW;
9
+ EVENT_HIDE = this.EVENTS.INTRO.HIDE;
10
+ }
@@ -0,0 +1,13 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { LineExecHandlerArg } from "@vnejs/module.core";
3
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
4
+ export declare class Intro extends ModuleCore<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams> {
5
+ name: string;
6
+ isShowed: boolean;
7
+ subscribe: () => void;
8
+ init: () => Promise<import("@vnejs/registry").EmitResults<"vne:scenario:line_exec_reg">> | undefined;
9
+ onLineExec: ({ keywords }?: LineExecHandlerArg) => Promise<import("@vnejs/registry").EmitResults<"vne:intro:show">> | undefined;
10
+ onIntroSkip: () => void;
11
+ onIntroClick: () => Promise<void>;
12
+ onIntroInteract: () => Promise<void>;
13
+ }
@@ -0,0 +1,31 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ export class Intro extends ModuleCore {
3
+ name = "intro";
4
+ isShowed = false;
5
+ subscribe = () => {
6
+ this.on(this.EVENTS.INTRO.SKIP, this.onIntroSkip);
7
+ this.on(this.EVENTS.INTRO.CLICK, this.onIntroClick);
8
+ this.on(this.EVENTS.INTRO.INTERACT, this.onIntroInteract);
9
+ };
10
+ init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
11
+ onLineExec = ({ keywords = [] } = {}) => {
12
+ if (keywords.includes(this.CONST.SCENARIO.LINE_KEYWORDS.SKIP_IF_POSSIBLE) && this.isShowed)
13
+ return void this.emit(this.EVENTS.INTRO.SKIP);
14
+ this.isShowed = true;
15
+ return this.emit(this.EVENTS.INTRO.SHOW);
16
+ };
17
+ onIntroSkip = () => {
18
+ this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.INTRO.LOGS_ACTIONS.SKIP });
19
+ this.emit(this.EVENTS.SCENARIO.NEXT);
20
+ };
21
+ onIntroClick = async () => {
22
+ this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.INTRO.LOGS_ACTIONS.CLICK });
23
+ await this.emit(this.EVENTS.INTRO.HIDE);
24
+ this.emit(this.EVENTS.SCENARIO.NEXT);
25
+ };
26
+ onIntroInteract = async () => {
27
+ this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.INTRO.LOGS_ACTIONS.INTERACT });
28
+ await this.emit(this.EVENTS.INTRO.HIDE);
29
+ this.emit(this.EVENTS.SCENARIO.NEXT);
30
+ };
31
+ }
@@ -0,0 +1,10 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
3
+ import type { IntroPluginState } from "../types.js";
4
+ export declare class IntroView extends ModuleView<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> {
5
+ name: string;
6
+ EVENT_UPDATE_VIEW: "vne:intro:update";
7
+ LOC_LABEL: string;
8
+ TRANSITION: number;
9
+ renderFunc: import("@vnejs/module.components").ViewRenderFunc<IntroPluginState>;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+ import { render } from "../view/index.js";
3
+ export class IntroView extends ModuleView {
4
+ name = "intro.view";
5
+ EVENT_UPDATE_VIEW = this.EVENTS.INTRO.UPDATE;
6
+ LOC_LABEL = this.PARAMS.INTRO.LOC_LABEL;
7
+ TRANSITION = this.PARAMS.INTRO.TRANSITION;
8
+ renderFunc = render;
9
+ }
@@ -0,0 +1,17 @@
1
+ import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
+ import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.screens.intro";
3
+ import type { Constants as ControlsConstants, PluginName as ControlsPluginName } from "@vnejs/contracts.controls";
4
+ import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/contracts.core.logs";
5
+ import type { Constants as ScenarioConstants, PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/contracts.core.scenario";
6
+ import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/contracts.core.system";
7
+ import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/contracts.text.locs";
8
+ export type IntroPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<ScenarioPluginName, ScenarioSubscribeEvents> & Record<SystemPluginName, SystemSubscribeEvents> & Record<LogsPluginName, LogsSubscribeEvents> & Record<LocsPluginName, LocsSubscribeEvents>;
9
+ export type IntroPluginConstants = ModuleComponentsConstants & Record<PluginName, Constants> & Record<ControlsPluginName, ControlsConstants> & Record<ScenarioPluginName, ScenarioConstants>;
10
+ export type IntroPluginSettings = ModuleComponentsSettings;
11
+ export type IntroPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
12
+ export type IntroPluginState = {
13
+ isShow: boolean;
14
+ isForce: boolean;
15
+ bgSrc?: string;
16
+ locs?: Record<string, string>;
17
+ };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ReactComponentProps } from "@vnejs/uis.react";
2
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../../types.js";
3
+ import type { IntroPluginState } from "../../types.js";
4
+ type IntroHintProps = ReactComponentProps<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> & {
5
+ text?: string;
6
+ };
7
+ export declare const IntroHint: ({ text, PARAMS }: IntroHintProps) => import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { PositionBox, Text } from "@vnejs/uis.react";
3
+ export const IntroHint = ({ text = "", PARAMS }) => {
4
+ return (_jsx(PositionBox, { ...PARAMS.INTRO.VIEW_PROPS.hint.position, children: _jsx(Text, { ...PARAMS.INTRO.VIEW_PROPS.hint.text, text: text }) }));
5
+ };
@@ -0,0 +1,8 @@
1
+ import type { ReactComponentProps } from "@vnejs/uis.react";
2
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../../types.js";
3
+ import type { IntroPluginState } from "../../types.js";
4
+ type IntroTextsProps = ReactComponentProps<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> & {
5
+ text?: string;
6
+ };
7
+ export declare const IntroTexts: ({ text, PARAMS }: IntroTextsProps) => import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ import { Flex, PositionBox, Text } from "@vnejs/uis.react";
4
+ const renderText = ({ text, props }, i) => (_createElement(Text, { ...props, text: text, key: i }));
5
+ export const IntroTexts = ({ text = "", PARAMS }) => {
6
+ const propsByView = PARAMS.INTRO.VIEW_PROPS.texts;
7
+ return (_jsx(PositionBox, { ...propsByView.position, children: _jsx(Flex, { ...propsByView.flex, children: text.split("\n").map((line, i) => renderText({ text: line, props: propsByView.text }, i)) }) }));
8
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./IntroHint.js";
2
+ export * from "./IntroTexts.js";
@@ -0,0 +1,2 @@
1
+ export * from "./IntroHint.js";
2
+ export * from "./IntroTexts.js";
@@ -0,0 +1,3 @@
1
+ import type { ViewRenderFunc } from "@vnejs/module.components";
2
+ import type { IntroPluginState } from "../types.js";
3
+ export declare const render: ViewRenderFunc<IntroPluginState>;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Screen, createRenderFunc, useStoreState } from "@vnejs/uis.react";
3
+ import { IntroHint, IntroTexts } from "./components/index.js";
4
+ const Intro = ({ store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS }) => {
5
+ const { isShow = false, isForce = false, bgSrc = "", locs = {} } = useStoreState(store, onMount);
6
+ return (_jsxs(Screen, { ...PARAMS.INTRO.VIEW_PROPS.screen, bgSrc: bgSrc, isShow: isShow, isForce: isForce, onClick: () => void emit(EVENTS.INTRO.CLICK), children: [_jsx(IntroTexts, { store: store, onMount: onMount, PARAMS: PARAMS, emit: emit, EVENTS: EVENTS, shared: shared, CONST: CONST, SETTINGS: SETTINGS, text: locs.intro }), _jsx(IntroHint, { store: store, onMount: onMount, PARAMS: PARAMS, emit: emit, EVENTS: EVENTS, shared: shared, CONST: CONST, SETTINGS: SETTINGS, text: locs.hint })] }));
7
+ };
8
+ export const render = createRenderFunc(Intro);
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.controllers.screens.intro",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.17",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "tsconfig.json"
19
+ ],
20
+ "scripts": {
21
+ "test": "npx @vnejs/monorepo test",
22
+ "build": "npx @vnejs/monorepo package",
23
+ "publish:major:plugin": "npm run publish:major",
24
+ "publish:minor:plugin": "npm run publish:minor",
25
+ "publish:patch:plugin": "npm run publish:patch",
26
+ "publish:major": "npx @vnejs/monorepo publish major --access public",
27
+ "publish:minor": "npx @vnejs/monorepo publish minor --access public",
28
+ "publish:patch": "npx @vnejs/monorepo publish patch --access public"
29
+ },
30
+ "author": "",
31
+ "license": "ISC",
32
+ "dependencies": {
33
+ "@vnejs/contracts.controllers.screens.intro": "~0.2.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@vnejs/module.core": "~0.2.0",
37
+ "@vnejs/module.components": "~0.2.0",
38
+ "@vnejs/module.controller.bg": "~0.2.0",
39
+ "@vnejs/module.controller.interact": "~0.2.0",
40
+ "@vnejs/contracts.controls": "~0.2.0",
41
+ "@vnejs/contracts.text.locs": "~0.2.0",
42
+ "@vnejs/registry": "~0.2.0",
43
+ "@vnejs/uis.react": "~0.2.0"
44
+ },
45
+ "devDependencies": {
46
+ "@vnejs/configs.ts-common": "~0.2.0",
47
+ "@vnejs/configs.vitest": "~0.2.0",
48
+ "@vnejs/test-utils": "~0.2.0",
49
+ "@vnejs/contracts.canvas.layer": "~0.2.0",
50
+ "@vnejs/contracts.controls": "~0.2.0",
51
+ "@vnejs/contracts.text.locs": "~0.2.0",
52
+ "@vnejs/contracts.controllers.screens.intro": "~0.2.0",
53
+ "@vnejs/module.core": "~0.2.0",
54
+ "@vnejs/module.components": "~0.2.0",
55
+ "@vnejs/module.controller.bg": "~0.2.0",
56
+ "@vnejs/module.controller.interact": "~0.2.0",
57
+ "@vnejs/registry": "~0.2.0",
58
+ "@vnejs/uis.react": "~0.2.0"
59
+ }
60
+ }
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ import "@vnejs/contracts.controllers.screens.intro";
2
+
3
+ import { regPlugin } from "@vnejs/registry";
4
+
5
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.screens.intro";
6
+
7
+ import { IntroControllerBg } from "./modules/controller.bg.js";
8
+ import { IntroControllerInteract } from "./modules/controller.interact.js";
9
+ import { IntroController } from "./modules/controller.js";
10
+ import { Intro } from "./modules/intro.js";
11
+ import { IntroView } from "./modules/view.js";
12
+
13
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [
14
+ IntroController,
15
+ IntroControllerBg,
16
+ IntroControllerInteract,
17
+ Intro,
18
+ IntroView,
19
+ ]);
@@ -0,0 +1,18 @@
1
+ import { ModuleControllerBg } from "@vnejs/module.controller.bg";
2
+
3
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
4
+ import type { IntroPluginState } from "../types.js";
5
+ export class IntroControllerBg extends ModuleControllerBg<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> {
6
+ name = "intro.controller.bg";
7
+
8
+ EVENT_SHOW = this.EVENTS.INTRO.SHOW;
9
+ EVENT_HIDE = this.EVENTS.INTRO.HIDE;
10
+ EVENT_UPDATE_STATE = this.EVENTS.INTRO.UPDATE_STATE;
11
+ EVENT_UPDATE_FAST = this.EVENTS.INTRO.UPDATE_FAST;
12
+
13
+ BGNAME = this.PARAMS.INTRO.BACKGROUND;
14
+
15
+ QUALITY_SETTING = this.SETTINGS.LAYER.QUALITY;
16
+
17
+ IS_START_PRELOAD_ENABLED = true;
18
+ }
@@ -0,0 +1,22 @@
1
+ import { ModuleControllerInteract } from "@vnejs/module.controller.interact";
2
+
3
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
4
+ import type { IntroPluginState } from "../types.js";
5
+
6
+ export class IntroControllerInteract extends ModuleControllerInteract<
7
+ IntroPluginEvents,
8
+ IntroPluginConstants,
9
+ IntroPluginSettings,
10
+ IntroPluginParams,
11
+ IntroPluginState
12
+ > {
13
+ name = "intro.controller.interact";
14
+
15
+ EVENT_SHOW = this.EVENTS.INTRO.SHOW;
16
+ EVENT_HIDE = this.EVENTS.INTRO.HIDE;
17
+
18
+ CONTROLS_ZINDEX = this.PARAMS.INTRO.ZINDEX;
19
+ CONTROLS_CHECK_NEXT = false;
20
+
21
+ onInteract = () => this.emit(this.EVENTS.INTRO.INTERACT);
22
+ }
@@ -0,0 +1,15 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+
3
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
4
+ import type { IntroPluginState } from "../types.js";
5
+
6
+ export class IntroController extends ModuleController<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> {
7
+ name = "intro.controller";
8
+
9
+ EVENT_UPDATE_VIEW = this.EVENTS.INTRO.UPDATE;
10
+ EVENT_UPDATE_STATE = this.EVENTS.INTRO.UPDATE_STATE;
11
+ EVENT_UPDATE_FAST = this.EVENTS.INTRO.UPDATE_FAST;
12
+ EVENT_UPDATE_FORCE = this.EVENTS.INTRO.UPDATE_FORCE;
13
+ EVENT_SHOW = this.EVENTS.INTRO.SHOW;
14
+ EVENT_HIDE = this.EVENTS.INTRO.HIDE;
15
+ }
@@ -0,0 +1,44 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+
3
+ import type { LineExecHandlerArg } from "@vnejs/module.core";
4
+
5
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
6
+
7
+ export class Intro extends ModuleCore<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams> {
8
+ name = "intro";
9
+
10
+ isShowed = false;
11
+
12
+ subscribe = () => {
13
+ this.on(this.EVENTS.INTRO.SKIP, this.onIntroSkip);
14
+ this.on(this.EVENTS.INTRO.CLICK, this.onIntroClick);
15
+ this.on(this.EVENTS.INTRO.INTERACT, this.onIntroInteract);
16
+ };
17
+
18
+ init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
19
+
20
+ onLineExec = ({ keywords = [] }: LineExecHandlerArg = {}) => {
21
+ if (keywords.includes(this.CONST.SCENARIO.LINE_KEYWORDS.SKIP_IF_POSSIBLE) && this.isShowed) return void this.emit(this.EVENTS.INTRO.SKIP);
22
+
23
+ this.isShowed = true;
24
+
25
+ return this.emit(this.EVENTS.INTRO.SHOW);
26
+ };
27
+
28
+ onIntroSkip = () => {
29
+ this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.INTRO.LOGS_ACTIONS.SKIP });
30
+ this.emit(this.EVENTS.SCENARIO.NEXT);
31
+ };
32
+
33
+ onIntroClick = async () => {
34
+ this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.INTRO.LOGS_ACTIONS.CLICK });
35
+ await this.emit(this.EVENTS.INTRO.HIDE);
36
+ this.emit(this.EVENTS.SCENARIO.NEXT);
37
+ };
38
+
39
+ onIntroInteract = async () => {
40
+ this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.INTRO.LOGS_ACTIONS.INTERACT });
41
+ await this.emit(this.EVENTS.INTRO.HIDE);
42
+ this.emit(this.EVENTS.SCENARIO.NEXT);
43
+ };
44
+ }
@@ -0,0 +1,17 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+
3
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
4
+ import type { IntroPluginState } from "../types.js";
5
+
6
+ import { render } from "../view/index.js";
7
+ export class IntroView extends ModuleView<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> {
8
+ name = "intro.view";
9
+
10
+ EVENT_UPDATE_VIEW = this.EVENTS.INTRO.UPDATE;
11
+
12
+ LOC_LABEL = this.PARAMS.INTRO.LOC_LABEL;
13
+
14
+ TRANSITION = this.PARAMS.INTRO.TRANSITION;
15
+
16
+ renderFunc = render;
17
+ }
@@ -0,0 +1,38 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent, stubEvent } from "@vnejs/test-utils";
4
+
5
+ import { SUBSCRIBE_EVENTS as MEDIA_EVENTS } from "@vnejs/contracts.core.media";
6
+
7
+ import { IntroControllerBg } from "../modules/controller.bg.js";
8
+
9
+ import { createIntroTestModule, PARAMS, registerIntroPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
10
+
11
+ describe("IntroControllerBg", () => {
12
+ beforeEach(() => {
13
+ registerIntroPluginVne();
14
+ });
15
+
16
+ it("SHOW loads bg and emits UPDATE_STATE with bgSrc", async () => {
17
+ const { observer } = createIntroTestModule(IntroControllerBg);
18
+ stubEvent(observer, MEDIA_EVENTS.LOAD, () => ({ src: "bg.png" }));
19
+ const mediaLoad = spyEvent(observer, MEDIA_EVENTS.LOAD);
20
+ const stateUpdate = spyEvent(observer, SUBSCRIBE_EVENTS.UPDATE_STATE);
21
+
22
+ await observer.emit(SUBSCRIBE_EVENTS.SHOW);
23
+
24
+ expect(mediaLoad).toHaveBeenCalledOnce();
25
+ expect(mediaLoad.mock.calls[0][0]).toMatchObject({ name: `bg/${PARAMS.BACKGROUND}`, mediaType: "view" });
26
+ expect(stateUpdate).toHaveBeenCalledWith({ bgSrc: "bg.png" });
27
+ });
28
+
29
+ it("start preloads bg media", async () => {
30
+ const { module, observer } = createIntroTestModule(IntroControllerBg);
31
+ stubEvent(observer, MEDIA_EVENTS.LOAD, () => ({ src: "bg.png" }));
32
+ const mediaLoad = spyEvent(observer, MEDIA_EVENTS.LOAD);
33
+
34
+ await (module as IntroControllerBg).start();
35
+
36
+ expect(mediaLoad).toHaveBeenCalledOnce();
37
+ });
38
+ });
@@ -0,0 +1,87 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { SUBSCRIBE_EVENTS as CONTROLS_EVENTS } from "@vnejs/contracts.controls";
6
+ import { SUBSCRIBE_EVENTS as INTERACT_EVENTS } from "@vnejs/contracts.core.interact";
7
+
8
+ import { IntroControllerInteract } from "../modules/controller.interact.js";
9
+
10
+ import { createIntroTestModule, registerIntroPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
11
+
12
+ describe("IntroControllerInteract", () => {
13
+ beforeEach(() => {
14
+ registerIntroPluginVne();
15
+ });
16
+
17
+ it("SHOW pushes ANY and interact handler", async () => {
18
+ const { module, observer } = createIntroTestModule(IntroControllerInteract);
19
+ const interact = module as IntroControllerInteract;
20
+ const controlsPush = spyEvent(observer, CONTROLS_EVENTS.PUSH);
21
+ const interactPush = spyEvent(observer, INTERACT_EVENTS.PUSH);
22
+
23
+ await observer.emit(SUBSCRIBE_EVENTS.SHOW);
24
+
25
+ expect(controlsPush).toHaveBeenCalledExactlyOnceWith(
26
+ expect.objectContaining({
27
+ key: "intro.controller.interact",
28
+ checkNext: false,
29
+ index: interact.PARAMS.INTRO.ZINDEX + 1,
30
+ }),
31
+ );
32
+ expect(controlsPush.mock.calls[0][0].controls).toHaveProperty(interact.CONST.CONTROLS.BUTTONS.ANY);
33
+ expect(interactPush).toHaveBeenCalledExactlyOnceWith(
34
+ expect.objectContaining({
35
+ key: "intro.controller.interact",
36
+ }),
37
+ );
38
+ });
39
+
40
+ it("ANY emits INTERACT.EMIT", async () => {
41
+ const { module, observer } = createIntroTestModule(IntroControllerInteract);
42
+ const interact = module as IntroControllerInteract;
43
+ const emit = spyEvent(observer, INTERACT_EVENTS.EMIT);
44
+
45
+ interact.CONTROLS[interact.CONST.CONTROLS.BUTTONS.ANY]();
46
+ await Promise.resolve();
47
+
48
+ expect(emit).toHaveBeenCalledOnce();
49
+ });
50
+
51
+ it("interact handler emits INTRO.INTERACT", async () => {
52
+ const { observer } = createIntroTestModule(IntroControllerInteract);
53
+ const interactPush = spyEvent(observer, INTERACT_EVENTS.PUSH);
54
+ const introInteract = spyEvent(observer, SUBSCRIBE_EVENTS.INTERACT);
55
+
56
+ await observer.emit(SUBSCRIBE_EVENTS.SHOW);
57
+
58
+ const { handler } = interactPush.mock.calls[0][0] as { handler: () => void | Promise<unknown> };
59
+
60
+ await handler();
61
+
62
+ expect(introInteract).toHaveBeenCalledOnce();
63
+ });
64
+
65
+ it("HIDE pops interact and controls", async () => {
66
+ const { observer } = createIntroTestModule(IntroControllerInteract);
67
+ const interactPop = spyEvent(observer, INTERACT_EVENTS.POP);
68
+ const controlsPop = spyEvent(observer, CONTROLS_EVENTS.POP);
69
+
70
+ await observer.emit(SUBSCRIBE_EVENTS.SHOW);
71
+ await observer.emit(SUBSCRIBE_EVENTS.HIDE);
72
+
73
+ expect(interactPop).toHaveBeenCalledExactlyOnceWith({ key: "intro.controller.interact" });
74
+ expect(controlsPop).toHaveBeenCalledExactlyOnceWith({ key: "intro.controller.interact" });
75
+ });
76
+
77
+ it("HIDE without SHOW pops interact and controls", async () => {
78
+ const { observer } = createIntroTestModule(IntroControllerInteract);
79
+ const interactPop = spyEvent(observer, INTERACT_EVENTS.POP);
80
+ const controlsPop = spyEvent(observer, CONTROLS_EVENTS.POP);
81
+
82
+ await observer.emit(SUBSCRIBE_EVENTS.HIDE);
83
+
84
+ expect(interactPop).toHaveBeenCalledExactlyOnceWith({ key: "intro.controller.interact" });
85
+ expect(controlsPop).toHaveBeenCalledExactlyOnceWith({ key: "intro.controller.interact" });
86
+ });
87
+ });
@@ -0,0 +1,50 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { CONSTANTS as SCENARIO_CONST } from "@vnejs/contracts.core.scenario";
6
+
7
+ import { Intro } from "../modules/intro.js";
8
+
9
+ import { createIntroTestModule, registerIntroPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
10
+
11
+ describe("Intro", () => {
12
+ beforeEach(() => {
13
+ registerIntroPluginVne();
14
+ });
15
+
16
+ it("line exec first time emits SHOW", async () => {
17
+ const { module, observer } = createIntroTestModule(Intro, { subscribe: false });
18
+ const show = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW);
19
+
20
+ await (module as Intro).init();
21
+ await (module as Intro).onLineExec({ keywords: [] });
22
+
23
+ expect(show).toHaveBeenCalledOnce();
24
+ expect((module as Intro).isShowed).toBe(true);
25
+ });
26
+
27
+ it("line exec with skip_if_possible skips when already shown", async () => {
28
+ const { module, observer } = createIntroTestModule(Intro, { subscribe: false });
29
+ const skip = spyEvent(observer, SUBSCRIBE_EVENTS.SKIP);
30
+
31
+ (module as Intro).isShowed = true;
32
+
33
+ await (module as Intro).onLineExec({ keywords: [SCENARIO_CONST.LINE_KEYWORDS.SKIP_IF_POSSIBLE] });
34
+
35
+ expect(skip).toHaveBeenCalledOnce();
36
+ });
37
+
38
+ it("CLICK hides and emits next", async () => {
39
+ const { observer } = createIntroTestModule(Intro);
40
+ const hide = spyEvent(observer, SUBSCRIBE_EVENTS.HIDE);
41
+ const next = vi.fn();
42
+
43
+ observer.subscribe("vne:scenario:next", next);
44
+
45
+ await observer.emit(SUBSCRIBE_EVENTS.CLICK);
46
+
47
+ expect(hide).toHaveBeenCalledOnce();
48
+ expect(next).toHaveBeenCalledOnce();
49
+ });
50
+ });
@@ -0,0 +1,41 @@
1
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin, stubEvent, stubSilentEvent } from "@vnejs/test-utils";
2
+
3
+ import { CONSTANTS as LAYER_CONST, PLUGIN_NAME as LAYER, SETTINGS_KEYS as LAYER_SETTINGS } from "@vnejs/contracts.canvas.layer";
4
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.screens.intro";
5
+ import { CONSTANTS as CONTROLS_CONST, PLUGIN_NAME as CONTROLS, SUBSCRIBE_EVENTS as CONTROLS_EVENTS } from "@vnejs/contracts.controls";
6
+ import { SUBSCRIBE_EVENTS as MEDIA_EVENTS } from "@vnejs/contracts.core.media";
7
+
8
+ export const registerIntroPluginVne = () => {
9
+ registerCoreVne();
10
+ registerVnePlugin(CONTROLS, { constants: CONTROLS_CONST, events: CONTROLS_EVENTS });
11
+ registerVnePlugin(LAYER, { constants: LAYER_CONST, settings: LAYER_SETTINGS });
12
+ registerVnePlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS });
13
+ };
14
+
15
+ export const createIntroTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
16
+ ModuleClass: T,
17
+ options: Parameters<typeof baseCreateTestModule>[1] = {},
18
+ ) => {
19
+ const result = baseCreateTestModule(ModuleClass, {
20
+ state: {
21
+ intro: { bgSrc: "", isShow: false },
22
+ ...(options.state ?? {}),
23
+ },
24
+ shared: {
25
+ settings: { [LAYER_SETTINGS.QUALITY]: LAYER_CONST.QUALITIES.FHD },
26
+ ...(options.shared ?? {}),
27
+ },
28
+ ...options,
29
+ });
30
+
31
+ stubEvent(result.observer, MEDIA_EVENTS.LOAD, () => ({ src: "bg.png" }));
32
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.SHOW);
33
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.HIDE);
34
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UPDATE);
35
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UPDATE_FAST);
36
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UPDATE_STATE);
37
+
38
+ return result;
39
+ };
40
+
41
+ export { SUBSCRIBE_EVENTS, PARAMS, PLUGIN_NAME };
package/src/types.ts ADDED
@@ -0,0 +1,35 @@
1
+ import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
+
3
+ import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.screens.intro";
4
+ import type { Constants as ControlsConstants, PluginName as ControlsPluginName } from "@vnejs/contracts.controls";
5
+ import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/contracts.core.logs";
6
+ import type {
7
+ Constants as ScenarioConstants,
8
+ PluginName as ScenarioPluginName,
9
+ SubscribeEvents as ScenarioSubscribeEvents,
10
+ } from "@vnejs/contracts.core.scenario";
11
+ import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/contracts.core.system";
12
+ import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/contracts.text.locs";
13
+
14
+ export type IntroPluginEvents = ModuleComponentsEvents &
15
+ Record<PluginName, SubscribeEvents> &
16
+ Record<ScenarioPluginName, ScenarioSubscribeEvents> &
17
+ Record<SystemPluginName, SystemSubscribeEvents> &
18
+ Record<LogsPluginName, LogsSubscribeEvents> &
19
+ Record<LocsPluginName, LocsSubscribeEvents>;
20
+
21
+ export type IntroPluginConstants = ModuleComponentsConstants &
22
+ Record<PluginName, Constants> &
23
+ Record<ControlsPluginName, ControlsConstants> &
24
+ Record<ScenarioPluginName, ScenarioConstants>;
25
+
26
+ export type IntroPluginSettings = ModuleComponentsSettings;
27
+
28
+ export type IntroPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
29
+
30
+ export type IntroPluginState = {
31
+ isShow: boolean;
32
+ isForce: boolean;
33
+ bgSrc?: string;
34
+ locs?: Record<string, string>;
35
+ };
@@ -0,0 +1,20 @@
1
+ import { PositionBox, Text } from "@vnejs/uis.react";
2
+
3
+ import type { ReactComponentProps } from "@vnejs/uis.react";
4
+
5
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../../types.js";
6
+ import type { IntroPluginState } from "../../types.js";
7
+ type IntroHintProps = ReactComponentProps<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> & {
8
+ text?: string;
9
+ };
10
+
11
+ export const IntroHint = ({ text = "", PARAMS }: IntroHintProps) => {
12
+ return (
13
+ <PositionBox {...PARAMS.INTRO.VIEW_PROPS.hint.position}>
14
+ <Text
15
+ {...PARAMS.INTRO.VIEW_PROPS.hint.text}
16
+ text={text}
17
+ />
18
+ </PositionBox>
19
+ );
20
+ };
@@ -0,0 +1,27 @@
1
+ import { Flex, PositionBox, Text } from "@vnejs/uis.react";
2
+
3
+ import type { ReactComponentProps } from "@vnejs/uis.react";
4
+
5
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../../types.js";
6
+ import type { IntroPluginState } from "../../types.js";
7
+ type IntroTextsProps = ReactComponentProps<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> & {
8
+ text?: string;
9
+ };
10
+
11
+ const renderText = ({ text, props }: { text: string; props: Record<string, unknown> }, i: number) => (
12
+ <Text
13
+ {...props}
14
+ text={text}
15
+ key={i}
16
+ />
17
+ );
18
+
19
+ export const IntroTexts = ({ text = "", PARAMS }: IntroTextsProps) => {
20
+ const propsByView = PARAMS.INTRO.VIEW_PROPS.texts;
21
+
22
+ return (
23
+ <PositionBox {...propsByView.position}>
24
+ <Flex {...propsByView.flex}>{text.split("\n").map((line, i) => renderText({ text: line, props: propsByView.text }, i))}</Flex>
25
+ </PositionBox>
26
+ );
27
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./IntroHint.js";
2
+ export * from "./IntroTexts.js";
@@ -0,0 +1,51 @@
1
+ import type { ViewRenderFunc } from "@vnejs/module.components";
2
+
3
+ import { Screen, createRenderFunc, useStoreState } from "@vnejs/uis.react";
4
+
5
+ import type { ReactComponentProps } from "@vnejs/uis.react";
6
+
7
+ import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
8
+ import type { IntroPluginState } from "../types.js";
9
+
10
+ import { IntroHint, IntroTexts } from "./components/index.js";
11
+
12
+ type IntroComponentProps = ReactComponentProps<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState>;
13
+
14
+ const Intro = ({ store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS }: IntroComponentProps) => {
15
+ const { isShow = false, isForce = false, bgSrc = "", locs = {} } = useStoreState<IntroPluginState>(store, onMount);
16
+
17
+ return (
18
+ <Screen
19
+ {...PARAMS.INTRO.VIEW_PROPS.screen}
20
+ bgSrc={bgSrc}
21
+ isShow={isShow}
22
+ isForce={isForce}
23
+ onClick={() => void emit(EVENTS.INTRO.CLICK)}
24
+ >
25
+ <IntroTexts
26
+ store={store}
27
+ onMount={onMount}
28
+ PARAMS={PARAMS}
29
+ emit={emit}
30
+ EVENTS={EVENTS}
31
+ shared={shared}
32
+ CONST={CONST}
33
+ SETTINGS={SETTINGS}
34
+ text={locs.intro}
35
+ />
36
+ <IntroHint
37
+ store={store}
38
+ onMount={onMount}
39
+ PARAMS={PARAMS}
40
+ emit={emit}
41
+ EVENTS={EVENTS}
42
+ shared={shared}
43
+ CONST={CONST}
44
+ SETTINGS={SETTINGS}
45
+ text={locs.hint}
46
+ />
47
+ </Screen>
48
+ );
49
+ };
50
+
51
+ export const render: ViewRenderFunc<IntroPluginState> = createRenderFunc(Intro);
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@vnejs/configs.ts-common/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "jsx": "react-jsx"
7
+ },
8
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
9
+ "exclude": ["dist", "node_modules", "src/tests"]
10
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.