@vnejs/plugins.views.screens.intro 0.1.7 → 0.1.9
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.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/modules/controller.d.ts +15 -0
- package/dist/modules/controller.js +15 -0
- package/dist/modules/intro.d.ts +14 -0
- package/dist/modules/intro.js +32 -0
- package/dist/modules/view.d.ts +11 -0
- package/dist/modules/view.js +10 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +1 -0
- package/dist/utils/intro.d.ts +9 -0
- package/dist/utils/intro.js +1 -0
- package/dist/view/components/IntroHint.d.ts +8 -0
- package/dist/view/components/IntroHint.js +6 -0
- package/dist/view/components/IntroTexts.d.ts +8 -0
- package/dist/view/components/IntroTexts.js +9 -0
- package/dist/view/components/index.d.ts +2 -0
- package/dist/view/components/index.js +2 -0
- package/dist/view/index.d.ts +3 -0
- package/dist/view/index.js +12 -0
- package/package.json +38 -6
- package/src/index.ts +8 -0
- package/{modules/controller.js → src/modules/controller.ts} +11 -2
- package/{modules/intro.js → src/modules/intro.ts} +8 -3
- package/src/modules/view.ts +22 -0
- package/src/types.ts +22 -0
- package/src/utils/intro.ts +10 -0
- package/src/view/components/IntroHint.tsx +25 -0
- package/src/view/components/IntroTexts.tsx +38 -0
- package/src/view/components/index.ts +2 -0
- package/src/view/index.tsx +43 -0
- package/tsconfig.json +10 -0
- package/const/events.js +0 -9
- package/const/params.js +0 -11
- package/index.js +0 -10
- package/modules/view.js +0 -14
- package/view/components/IntroHint.jsx +0 -13
- package/view/components/IntroTexts.jsx +0 -23
- package/view/components/index.js +0 -2
- package/view/index.jsx +0 -28
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.screens.intro.contract";
|
|
3
|
+
import { IntroController } from "./modules/controller.js";
|
|
4
|
+
import { Intro } from "./modules/intro.js";
|
|
5
|
+
import { IntroView } from "./modules/view.js";
|
|
6
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [IntroController, Intro, IntroView]);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
|
|
3
|
+
import type { IntroPluginState } from "../utils/intro.js";
|
|
4
|
+
export declare class IntroController extends ModuleController<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
emitInteract: () => undefined;
|
|
7
|
+
bgName: string;
|
|
8
|
+
updateEvent: "vne:intro:update";
|
|
9
|
+
controls: {
|
|
10
|
+
abstract_any: () => undefined;
|
|
11
|
+
};
|
|
12
|
+
controlsIndex: number;
|
|
13
|
+
subscribe: () => void;
|
|
14
|
+
beforeShow: () => Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
export class IntroController extends ModuleController {
|
|
3
|
+
name = "intro.controller";
|
|
4
|
+
emitInteract = () => void this.emit(this.EVENTS.INTRO.INTERACT);
|
|
5
|
+
bgName = this.PARAMS.INTRO.BACKGROUND;
|
|
6
|
+
updateEvent = this.EVENTS.INTRO.UPDATE;
|
|
7
|
+
controls = { [this.CONST.CONTROLS.BUTTONS.ANY]: this.emitInteract };
|
|
8
|
+
controlsIndex = this.PARAMS.INTRO.ZINDEX;
|
|
9
|
+
subscribe = () => {
|
|
10
|
+
this.on(this.EVENTS.INTRO.SHOW, this.onShow);
|
|
11
|
+
this.on(this.EVENTS.INTRO.HIDE, this.onHide);
|
|
12
|
+
this.on(this.EVENTS.SYSTEM.STARTED, this.loadBgMedia);
|
|
13
|
+
};
|
|
14
|
+
beforeShow = async () => this.updateState({ bgSrc: (await this.loadBgMedia()).src });
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
|
|
3
|
+
import type { IntroLineExecPayload } from "../utils/intro.js";
|
|
4
|
+
export declare class Intro extends Module<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams> {
|
|
5
|
+
name: string;
|
|
6
|
+
isShowed: boolean;
|
|
7
|
+
subscribe: () => void;
|
|
8
|
+
init: () => Promise<unknown[]> | undefined;
|
|
9
|
+
onLineExec: ({ keywords }?: IntroLineExecPayload) => Promise<unknown[]> | undefined;
|
|
10
|
+
onIntroClick: () => Promise<void>;
|
|
11
|
+
onIntroInteract: () => Promise<void>;
|
|
12
|
+
onIntroSkip: () => void;
|
|
13
|
+
emitSkip: () => undefined;
|
|
14
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
export class Intro extends Module {
|
|
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.emitSkip();
|
|
14
|
+
this.isShowed = true;
|
|
15
|
+
return this.emit(this.EVENTS.INTRO.SHOW);
|
|
16
|
+
};
|
|
17
|
+
onIntroClick = async () => {
|
|
18
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "click" } });
|
|
19
|
+
await this.emit(this.EVENTS.INTRO.HIDE);
|
|
20
|
+
this.emit(this.EVENTS.SCENARIO.NEXT, { module: this.name });
|
|
21
|
+
};
|
|
22
|
+
onIntroInteract = async () => {
|
|
23
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "interact" } });
|
|
24
|
+
await this.emit(this.EVENTS.INTRO.HIDE);
|
|
25
|
+
this.emit(this.EVENTS.SCENARIO.NEXT, { module: this.name });
|
|
26
|
+
};
|
|
27
|
+
onIntroSkip = () => {
|
|
28
|
+
this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "skip" } });
|
|
29
|
+
this.emit(this.EVENTS.SCENARIO.NEXT, { module: this.name });
|
|
30
|
+
};
|
|
31
|
+
emitSkip = () => void this.emit(this.EVENTS.INTRO.SKIP);
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
|
|
3
|
+
import type { IntroPluginState } from "../utils/intro.js";
|
|
4
|
+
export declare class IntroView extends ModuleView<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams, IntroPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
locLabel: string;
|
|
7
|
+
animationTime: number;
|
|
8
|
+
updateEvent: "vne:intro:update";
|
|
9
|
+
renderFunc: import("@vnejs/module.components").ViewRenderFunc<IntroPluginState>;
|
|
10
|
+
updateHandler: (state?: IntroPluginState | undefined) => Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
locLabel = this.PARAMS.INTRO.LOC_LABEL;
|
|
6
|
+
animationTime = this.PARAMS.INTRO.TRANSITION;
|
|
7
|
+
updateEvent = this.EVENTS.INTRO.UPDATE;
|
|
8
|
+
renderFunc = render;
|
|
9
|
+
updateHandler = this.onUpdateStoreComponent;
|
|
10
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
import type { Constants as ControlsConstants, PluginName as ControlsPluginName } from "@vnejs/plugins.controls.contract";
|
|
3
|
+
import type { Constants as ScenarioConstants, PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/plugins.core.scenario.contract";
|
|
4
|
+
import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/plugins.core.logs.contract";
|
|
5
|
+
import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
|
|
6
|
+
import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/plugins.text.locs.contract";
|
|
7
|
+
import type { Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.screens.intro.contract";
|
|
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<ControlsPluginName, ControlsConstants> & Record<ScenarioPluginName, ScenarioConstants>;
|
|
10
|
+
export type IntroPluginSettings = ModuleComponentsSettings;
|
|
11
|
+
export type IntroPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 "../../utils/intro.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-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PositionBox, Text, useMemo } from "@vnejs/uis.react";
|
|
3
|
+
export const IntroHint = ({ text = "", PARAMS }) => {
|
|
4
|
+
const propsText = useMemo(() => ({ ...PARAMS.INTRO.VIEW_PROPS.hint.text, text }), [text, PARAMS.INTRO.VIEW_PROPS.hint.text]);
|
|
5
|
+
return (_jsx(PositionBox, { ...PARAMS.INTRO.VIEW_PROPS.hint.position, children: _jsx(Text, { ...propsText }) }));
|
|
6
|
+
};
|
|
@@ -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 "../../utils/intro.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-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { Flex, PositionBox, Text, useMemo } 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
|
+
const textsObj = useMemo(() => text.split("\n").map((line) => ({ text: line, props: PARAMS.INTRO.VIEW_PROPS.texts.text })), [text, PARAMS.INTRO.VIEW_PROPS.texts.text]);
|
|
8
|
+
return (_jsx(PositionBox, { ...propsByView.position, children: _jsx(Flex, { ...propsByView.flex, children: textsObj.map(renderText) }) }));
|
|
9
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Screen, createRenderFunc, useCallback, useMemo, 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
|
+
const onClick = useCallback(() => void emit(EVENTS.INTRO.CLICK), [emit, EVENTS.INTRO.CLICK]);
|
|
7
|
+
const propsTexts = useMemo(() => ({ store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, text: locs.intro }), [store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, locs.intro]);
|
|
8
|
+
const propsHint = useMemo(() => ({ store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, text: locs.hint }), [store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, locs.hint]);
|
|
9
|
+
const propsScreen = useMemo(() => ({ ...PARAMS.INTRO.VIEW_PROPS.screen, bgSrc, isShow, isForce, onClick }), [bgSrc, isShow, isForce, onClick, PARAMS.INTRO.VIEW_PROPS.screen]);
|
|
10
|
+
return (_jsxs(Screen, { ...propsScreen, children: [_jsx(IntroTexts, { ...propsTexts }), _jsx(IntroHint, { ...propsHint })] }));
|
|
11
|
+
};
|
|
12
|
+
export const render = createRenderFunc(Intro);
|
package/package.json
CHANGED
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.views.screens.intro",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.9",
|
|
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
|
+
],
|
|
5
20
|
"scripts": {
|
|
6
21
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
7
23
|
"publish:major:plugin": "npm run publish:major",
|
|
8
24
|
"publish:minor:plugin": "npm run publish:minor",
|
|
9
25
|
"publish:patch:plugin": "npm run publish:patch",
|
|
10
|
-
"publish:major": "
|
|
11
|
-
"publish:minor": "
|
|
12
|
-
"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"
|
|
13
29
|
},
|
|
14
30
|
"author": "",
|
|
15
31
|
"license": "ISC",
|
|
16
|
-
"
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@vnejs/plugins.views.screens.intro.contract": "~0.0.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@vnejs/module": "~0.0.1",
|
|
37
|
+
"@vnejs/module.components": "~0.0.1",
|
|
38
|
+
"@vnejs/plugins.controls.contract": "~0.0.1",
|
|
39
|
+
"@vnejs/plugins.core.logs.contract": "~0.0.1",
|
|
40
|
+
"@vnejs/plugins.core.scenario.contract": "~0.0.1",
|
|
41
|
+
"@vnejs/plugins.core.system.contract": "~0.0.1",
|
|
42
|
+
"@vnejs/plugins.text.locs.contract": "~0.0.1",
|
|
43
|
+
"@vnejs/shared": "~0.0.9",
|
|
44
|
+
"@vnejs/uis.react": "~0.1.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@vnejs/configs.ts-common": "~0.0.1"
|
|
48
|
+
}
|
|
17
49
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/plugins.views.screens.intro.contract";
|
|
3
|
+
|
|
4
|
+
import { IntroController } from "./modules/controller.js";
|
|
5
|
+
import { Intro } from "./modules/intro.js";
|
|
6
|
+
import { IntroView } from "./modules/view.js";
|
|
7
|
+
|
|
8
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [IntroController, Intro, IntroView]);
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { ModuleController } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
|
|
4
|
+
import type { IntroPluginState } from "../utils/intro.js";
|
|
5
|
+
|
|
6
|
+
export class IntroController extends ModuleController<
|
|
7
|
+
IntroPluginEvents,
|
|
8
|
+
IntroPluginConstants,
|
|
9
|
+
IntroPluginSettings,
|
|
10
|
+
IntroPluginParams,
|
|
11
|
+
IntroPluginState
|
|
12
|
+
> {
|
|
4
13
|
name = "intro.controller";
|
|
5
14
|
|
|
6
|
-
emitInteract = () => this.emit(this.EVENTS.INTRO.INTERACT);
|
|
15
|
+
emitInteract = () => void this.emit(this.EVENTS.INTRO.INTERACT);
|
|
7
16
|
|
|
8
17
|
bgName = this.PARAMS.INTRO.BACKGROUND;
|
|
9
18
|
updateEvent = this.EVENTS.INTRO.UPDATE;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Module } from "@vnejs/module";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
|
|
4
|
+
import type { IntroLineExecPayload } from "../utils/intro.js";
|
|
5
|
+
|
|
6
|
+
export class Intro extends Module<IntroPluginEvents, IntroPluginConstants, IntroPluginSettings, IntroPluginParams> {
|
|
4
7
|
name = "intro";
|
|
5
8
|
|
|
9
|
+
isShowed = false;
|
|
10
|
+
|
|
6
11
|
subscribe = () => {
|
|
7
12
|
this.on(this.EVENTS.INTRO.SKIP, this.onIntroSkip);
|
|
8
13
|
this.on(this.EVENTS.INTRO.CLICK, this.onIntroClick);
|
|
@@ -10,7 +15,7 @@ export class Intro extends Module {
|
|
|
10
15
|
};
|
|
11
16
|
init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
|
|
12
17
|
|
|
13
|
-
onLineExec = ({ keywords = [] } = {}) => {
|
|
18
|
+
onLineExec = ({ keywords = [] }: IntroLineExecPayload = {}) => {
|
|
14
19
|
if (keywords.includes(this.CONST.SCENARIO.LINE_KEYWORDS.SKIP_IF_POSSIBLE) && this.isShowed) return void this.emitSkip();
|
|
15
20
|
|
|
16
21
|
this.isShowed = true;
|
|
@@ -33,5 +38,5 @@ export class Intro extends Module {
|
|
|
33
38
|
this.emit(this.EVENTS.SCENARIO.NEXT, { module: this.name });
|
|
34
39
|
};
|
|
35
40
|
|
|
36
|
-
emitSkip = () => this.emit(this.EVENTS.INTRO.SKIP);
|
|
41
|
+
emitSkip = () => void this.emit(this.EVENTS.INTRO.SKIP);
|
|
37
42
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import { render } from "../view/index.js";
|
|
4
|
+
import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
|
|
5
|
+
import type { IntroPluginState } from "../utils/intro.js";
|
|
6
|
+
|
|
7
|
+
export class IntroView extends ModuleView<
|
|
8
|
+
IntroPluginEvents,
|
|
9
|
+
IntroPluginConstants,
|
|
10
|
+
IntroPluginSettings,
|
|
11
|
+
IntroPluginParams,
|
|
12
|
+
IntroPluginState
|
|
13
|
+
> {
|
|
14
|
+
name = "intro.view";
|
|
15
|
+
|
|
16
|
+
locLabel = this.PARAMS.INTRO.LOC_LABEL;
|
|
17
|
+
animationTime = this.PARAMS.INTRO.TRANSITION;
|
|
18
|
+
updateEvent = this.EVENTS.INTRO.UPDATE;
|
|
19
|
+
|
|
20
|
+
renderFunc = render;
|
|
21
|
+
updateHandler = this.onUpdateStoreComponent;
|
|
22
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
import type { Constants as ControlsConstants, PluginName as ControlsPluginName } from "@vnejs/plugins.controls.contract";
|
|
3
|
+
import type { Constants as ScenarioConstants, PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/plugins.core.scenario.contract";
|
|
4
|
+
import type { PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/plugins.core.logs.contract";
|
|
5
|
+
import type { PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
|
|
6
|
+
import type { PluginName as LocsPluginName, SubscribeEvents as LocsSubscribeEvents } from "@vnejs/plugins.text.locs.contract";
|
|
7
|
+
import type { Params, PluginName, SubscribeEvents } from "@vnejs/plugins.views.screens.intro.contract";
|
|
8
|
+
|
|
9
|
+
export type IntroPluginEvents = ModuleComponentsEvents &
|
|
10
|
+
Record<PluginName, SubscribeEvents> &
|
|
11
|
+
Record<ScenarioPluginName, ScenarioSubscribeEvents> &
|
|
12
|
+
Record<SystemPluginName, SystemSubscribeEvents> &
|
|
13
|
+
Record<LogsPluginName, LogsSubscribeEvents> &
|
|
14
|
+
Record<LocsPluginName, LocsSubscribeEvents>;
|
|
15
|
+
|
|
16
|
+
export type IntroPluginConstants = ModuleComponentsConstants &
|
|
17
|
+
Record<ControlsPluginName, ControlsConstants> &
|
|
18
|
+
Record<ScenarioPluginName, ScenarioConstants>;
|
|
19
|
+
|
|
20
|
+
export type IntroPluginSettings = ModuleComponentsSettings;
|
|
21
|
+
|
|
22
|
+
export type IntroPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactComponentProps } from "@vnejs/uis.react";
|
|
2
|
+
import { PositionBox, Text, useMemo } from "@vnejs/uis.react";
|
|
3
|
+
|
|
4
|
+
import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../../types.js";
|
|
5
|
+
import type { IntroPluginState } from "../../utils/intro.js";
|
|
6
|
+
|
|
7
|
+
type IntroHintProps = ReactComponentProps<
|
|
8
|
+
IntroPluginEvents,
|
|
9
|
+
IntroPluginConstants,
|
|
10
|
+
IntroPluginSettings,
|
|
11
|
+
IntroPluginParams,
|
|
12
|
+
IntroPluginState
|
|
13
|
+
> & {
|
|
14
|
+
text?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const IntroHint = ({ text = "", PARAMS }: IntroHintProps) => {
|
|
18
|
+
const propsText = useMemo(() => ({ ...PARAMS.INTRO.VIEW_PROPS.hint.text, text }), [text, PARAMS.INTRO.VIEW_PROPS.hint.text]);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<PositionBox {...PARAMS.INTRO.VIEW_PROPS.hint.position}>
|
|
22
|
+
<Text {...propsText} />
|
|
23
|
+
</PositionBox>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactComponentProps } from "@vnejs/uis.react";
|
|
2
|
+
import { Flex, PositionBox, Text, useMemo } from "@vnejs/uis.react";
|
|
3
|
+
|
|
4
|
+
import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../../types.js";
|
|
5
|
+
import type { IntroPluginState } from "../../utils/intro.js";
|
|
6
|
+
|
|
7
|
+
type IntroTextsProps = ReactComponentProps<
|
|
8
|
+
IntroPluginEvents,
|
|
9
|
+
IntroPluginConstants,
|
|
10
|
+
IntroPluginSettings,
|
|
11
|
+
IntroPluginParams,
|
|
12
|
+
IntroPluginState
|
|
13
|
+
> & {
|
|
14
|
+
text?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const renderText = ({ text, props }: { text: string; props: Record<string, unknown> }, i: number) => (
|
|
18
|
+
<Text
|
|
19
|
+
{...props}
|
|
20
|
+
text={text}
|
|
21
|
+
key={i}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const IntroTexts = ({ text = "", PARAMS }: IntroTextsProps) => {
|
|
26
|
+
const propsByView = PARAMS.INTRO.VIEW_PROPS.texts;
|
|
27
|
+
|
|
28
|
+
const textsObj = useMemo(
|
|
29
|
+
() => text.split("\n").map((line) => ({ text: line, props: PARAMS.INTRO.VIEW_PROPS.texts.text })),
|
|
30
|
+
[text, PARAMS.INTRO.VIEW_PROPS.texts.text],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<PositionBox {...propsByView.position}>
|
|
35
|
+
<Flex {...propsByView.flex}>{textsObj.map(renderText)}</Flex>
|
|
36
|
+
</PositionBox>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ViewRenderFunc } from "@vnejs/module.components";
|
|
2
|
+
import type { ReactComponentProps } from "@vnejs/uis.react";
|
|
3
|
+
import { Screen, createRenderFunc, useCallback, useMemo, useStoreState } from "@vnejs/uis.react";
|
|
4
|
+
|
|
5
|
+
import type { IntroPluginConstants, IntroPluginEvents, IntroPluginParams, IntroPluginSettings } from "../types.js";
|
|
6
|
+
import type { IntroPluginState } from "../utils/intro.js";
|
|
7
|
+
import { IntroHint, IntroTexts } from "./components/index.js";
|
|
8
|
+
|
|
9
|
+
type IntroComponentProps = ReactComponentProps<
|
|
10
|
+
IntroPluginEvents,
|
|
11
|
+
IntroPluginConstants,
|
|
12
|
+
IntroPluginSettings,
|
|
13
|
+
IntroPluginParams,
|
|
14
|
+
IntroPluginState
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
const Intro = ({ store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS }: IntroComponentProps) => {
|
|
18
|
+
const { isShow = false, isForce = false, bgSrc = "", locs = {} } = useStoreState<IntroPluginState>(store, onMount);
|
|
19
|
+
|
|
20
|
+
const onClick = useCallback(() => void emit(EVENTS.INTRO.CLICK), [emit, EVENTS.INTRO.CLICK]);
|
|
21
|
+
|
|
22
|
+
const propsTexts = useMemo(
|
|
23
|
+
() => ({ store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, text: locs.intro }),
|
|
24
|
+
[store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, locs.intro],
|
|
25
|
+
);
|
|
26
|
+
const propsHint = useMemo(
|
|
27
|
+
() => ({ store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, text: locs.hint }),
|
|
28
|
+
[store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, locs.hint],
|
|
29
|
+
);
|
|
30
|
+
const propsScreen = useMemo(
|
|
31
|
+
() => ({ ...PARAMS.INTRO.VIEW_PROPS.screen, bgSrc, isShow, isForce, onClick }),
|
|
32
|
+
[bgSrc, isShow, isForce, onClick, PARAMS.INTRO.VIEW_PROPS.screen],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Screen {...propsScreen}>
|
|
37
|
+
<IntroTexts {...propsTexts} />
|
|
38
|
+
<IntroHint {...propsHint} />
|
|
39
|
+
</Screen>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const render: ViewRenderFunc<IntroPluginState> = createRenderFunc(Intro);
|
package/tsconfig.json
ADDED
package/const/events.js
DELETED
package/const/params.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const BACKGROUND = "loading";
|
|
2
|
-
|
|
3
|
-
export const TRANSITION = 500;
|
|
4
|
-
export const ZINDEX = 2000;
|
|
5
|
-
export const LOC_LABEL = "intro";
|
|
6
|
-
|
|
7
|
-
export const VIEW_PROPS = {
|
|
8
|
-
texts: { position: { top: 240, left: 120, right: 720 }, flex: { direction: "column", gap: 60 }, text: { size: 96 } },
|
|
9
|
-
hint: { position: { bottom: 120, left: 120, right: 120 }, text: { size: 60, align: "center" } },
|
|
10
|
-
screen: { transition: TRANSITION, zIndex: ZINDEX },
|
|
11
|
-
};
|
package/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { regPlugin } from "@vnejs/shared";
|
|
2
|
-
|
|
3
|
-
import { SUBSCRIBE_EVENTS } from "./const/events";
|
|
4
|
-
import * as params from "./const/params";
|
|
5
|
-
|
|
6
|
-
import { IntroController } from "./modules/controller";
|
|
7
|
-
import { Intro } from "./modules/intro";
|
|
8
|
-
import { IntroView } from "./modules/view";
|
|
9
|
-
|
|
10
|
-
regPlugin("INTRO", { events: SUBSCRIBE_EVENTS, params }, [IntroController, Intro, IntroView]);
|
package/modules/view.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
-
|
|
3
|
-
import { render } from "../view";
|
|
4
|
-
|
|
5
|
-
export class IntroView extends ModuleView {
|
|
6
|
-
name = "intro.view";
|
|
7
|
-
|
|
8
|
-
locLabel = this.PARAMS.INTRO.LOC_LABEL;
|
|
9
|
-
animationTime = this.PARAMS.INTRO.TRANSITION;
|
|
10
|
-
updateEvent = this.EVENTS.INTRO.UPDATE;
|
|
11
|
-
|
|
12
|
-
renderFunc = render;
|
|
13
|
-
updateHandler = this.onUpdateStoreComponent;
|
|
14
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
|
|
3
|
-
import { PositionBox, Text } from "@vnejs/uis.react";
|
|
4
|
-
|
|
5
|
-
export const IntroHint = ({ text = "", ...props } = {}) => {
|
|
6
|
-
const propsText = useMemo(() => ({ ...props.PARAMS.INTRO.VIEW_PROPS.hint.text, text }), [text]);
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<PositionBox {...props.PARAMS.INTRO.VIEW_PROPS.hint.position}>
|
|
10
|
-
<Text {...propsText} />
|
|
11
|
-
</PositionBox>
|
|
12
|
-
);
|
|
13
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
|
|
3
|
-
import { PositionBox, Text, Flex } from "@vnejs/uis.react";
|
|
4
|
-
|
|
5
|
-
const renderText = ({ text, props }, i) => (
|
|
6
|
-
<Text
|
|
7
|
-
{...props}
|
|
8
|
-
text={text}
|
|
9
|
-
key={i}
|
|
10
|
-
/>
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
export const IntroTexts = ({ text = "", ...props } = {}) => {
|
|
14
|
-
const propsByView = props.PARAMS.INTRO.VIEW_PROPS.texts;
|
|
15
|
-
|
|
16
|
-
const textsObj = useMemo(() => text.split("\n").map((line) => ({ text: line, props: props.PARAMS.INTRO.VIEW_PROPS.texts.text })), [text]);
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<PositionBox {...propsByView.position}>
|
|
20
|
-
<Flex {...propsByView.flex}>{textsObj.map(renderText)}</Flex>
|
|
21
|
-
</PositionBox>
|
|
22
|
-
);
|
|
23
|
-
};
|
package/view/components/index.js
DELETED
package/view/index.jsx
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
|
|
4
|
-
import { Screen } from "@vnejs/uis.react";
|
|
5
|
-
|
|
6
|
-
import { IntroHint, IntroTexts } from "./components";
|
|
7
|
-
|
|
8
|
-
const Intro = ({ store, onMount, ...props } = {}) => {
|
|
9
|
-
const [{ isShow = false, isForce = false, bgSrc = "", locs = {} }, setState] = useState({});
|
|
10
|
-
|
|
11
|
-
useEffect(() => store.subscribe(setState), []);
|
|
12
|
-
useEffect(() => void onMount(), []);
|
|
13
|
-
|
|
14
|
-
const onClick = useCallback(() => props.emit(props.EVENTS.INTRO.CLICK), []);
|
|
15
|
-
|
|
16
|
-
const propsTexts = useMemo(() => ({ ...props, text: locs.intro }), [locs]);
|
|
17
|
-
const propsHint = useMemo(() => ({ ...props, text: locs.hint }), [locs]);
|
|
18
|
-
const propsScreen = useMemo(() => ({ ...props.PARAMS.INTRO.VIEW_PROPS.screen, bgSrc, isShow, isForce, onClick }), [bgSrc, isShow, isForce]);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Screen {...propsScreen}>
|
|
22
|
-
<IntroTexts {...propsTexts} />
|
|
23
|
-
<IntroHint {...propsHint} />
|
|
24
|
-
</Screen>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const render = (props, root) => createRoot(root).render(<Intro {...props} />);
|