@vnejs/plugins.controllers.screens.credits 0.0.0-stage → 0.2.16

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.
@@ -0,0 +1 @@
1
+ import "@vnejs/contracts.controllers.screens.credits";
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import "@vnejs/contracts.controllers.screens.credits";
2
+ import { regPlugin } from "@vnejs/registry";
3
+ import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.screens.credits";
4
+ import { CreditsControllerInteract } from "./modules/controller.interact.js";
5
+ import { CreditsController } from "./modules/controller.js";
6
+ import { Credits } from "./modules/credits.js";
7
+ import { CreditsHideControls } from "./modules/hide.controls.js";
8
+ import { CreditsHideState } from "./modules/hide.state.js";
9
+ import { CreditsView } from "./modules/view.js";
10
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [
11
+ CreditsController,
12
+ CreditsControllerInteract,
13
+ CreditsHideControls,
14
+ CreditsHideState,
15
+ Credits,
16
+ CreditsView,
17
+ ]);
@@ -0,0 +1,15 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
3
+ import type { CreditsPluginState } from "../types.js";
4
+ export declare class CreditsController extends ModuleController<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams, CreditsPluginState> {
5
+ name: string;
6
+ EVENT_UPDATE_VIEW: "vne:credits:update";
7
+ EVENT_UPDATE_STATE: "vne:credits:update_state";
8
+ EVENT_UPDATE_FAST: "vne:credits:update_fast";
9
+ EVENT_UPDATE_FORCE: "vne:credits:update_force";
10
+ EVENT_SHOW: "vne:credits:show";
11
+ EVENT_HIDE: "vne:credits:hide";
12
+ CONTROLS: {};
13
+ CONTROLS_INDEX: number;
14
+ onHideAfter: () => void;
15
+ }
@@ -0,0 +1,10 @@
1
+ import { ModuleControllerInteract } from "@vnejs/module.controller.interact";
2
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
3
+ import type { CreditsPluginState } from "../types.js";
4
+ export declare class CreditsControllerInteract extends ModuleControllerInteract<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams, CreditsPluginState> {
5
+ name: string;
6
+ EVENT_SHOW: "vne:credits:show";
7
+ EVENT_HIDE: "vne:credits:hide";
8
+ CONTROLS_ZINDEX: number;
9
+ onInteract: () => Promise<import("@vnejs/registry").EmitResults<"vne:credits:hide">> | undefined;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { ModuleControllerInteract } from "@vnejs/module.controller.interact";
2
+ export class CreditsControllerInteract extends ModuleControllerInteract {
3
+ name = "credits.controller.interact";
4
+ EVENT_SHOW = this.EVENTS.CREDITS.SHOW;
5
+ EVENT_HIDE = this.EVENTS.CREDITS.HIDE;
6
+ CONTROLS_ZINDEX = this.PARAMS.CREDITS.ZINDEX;
7
+ onInteract = () => this.emit(this.EVENTS.CREDITS.HIDE);
8
+ }
@@ -0,0 +1,15 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+ export class CreditsController extends ModuleController {
3
+ name = "credits.controller";
4
+ EVENT_UPDATE_VIEW = this.EVENTS.CREDITS.UPDATE;
5
+ EVENT_UPDATE_STATE = this.EVENTS.CREDITS.UPDATE_STATE;
6
+ EVENT_UPDATE_FAST = this.EVENTS.CREDITS.UPDATE_FAST;
7
+ EVENT_UPDATE_FORCE = this.EVENTS.CREDITS.UPDATE_FORCE;
8
+ EVENT_SHOW = this.EVENTS.CREDITS.SHOW;
9
+ EVENT_HIDE = this.EVENTS.CREDITS.HIDE;
10
+ CONTROLS = {};
11
+ CONTROLS_INDEX = this.PARAMS.CREDITS.ZINDEX;
12
+ onHideAfter = () => {
13
+ void this.emit(this.EVENTS.SCENARIO.NEXT);
14
+ };
15
+ }
@@ -0,0 +1,8 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { LineExecHandlerArg } from "@vnejs/module.core";
3
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
4
+ export declare class Credits extends ModuleCore<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams> {
5
+ name: string;
6
+ init: () => Promise<import("@vnejs/registry").EmitResults<"vne:scenario:line_exec_reg">> | undefined;
7
+ onLineExec: ({ line }?: LineExecHandlerArg) => Promise<import("@vnejs/registry").EmitResults<"vne:credits:hide">> | undefined;
8
+ }
@@ -0,0 +1,13 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import { tokenizeExecLine } from "@vnejs/helpers";
3
+ export class Credits extends ModuleCore {
4
+ name = "credits";
5
+ init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
6
+ onLineExec = ({ line = "" } = {}) => {
7
+ const [action = ""] = tokenizeExecLine(line);
8
+ if (action === "show")
9
+ return this.emit(this.EVENTS.CREDITS.SHOW);
10
+ if (action === "hide")
11
+ return this.emit(this.EVENTS.CREDITS.HIDE);
12
+ };
13
+ }
@@ -0,0 +1,8 @@
1
+ import { ModuleControllerHideOnControls } from "@vnejs/module.controller.hide.on.controls";
2
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
3
+ export declare class CreditsHideControls extends ModuleControllerHideOnControls<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams> {
4
+ name: string;
5
+ EVENT_SHOW: "vne:credits:show";
6
+ EVENT_HIDE: "vne:credits:hide";
7
+ CONTROLS_ZINDEX: number;
8
+ }
@@ -0,0 +1,7 @@
1
+ import { ModuleControllerHideOnControls } from "@vnejs/module.controller.hide.on.controls";
2
+ export class CreditsHideControls extends ModuleControllerHideOnControls {
3
+ name = "credits.hide.controls";
4
+ EVENT_SHOW = this.EVENTS.CREDITS.SHOW;
5
+ EVENT_HIDE = this.EVENTS.CREDITS.HIDE;
6
+ CONTROLS_ZINDEX = this.PARAMS.CREDITS.ZINDEX;
7
+ }
@@ -0,0 +1,6 @@
1
+ import { ModuleControllerHideOnState } from "@vnejs/module.controller.hide.on.state";
2
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
3
+ export declare class CreditsHideState extends ModuleControllerHideOnState<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams> {
4
+ name: string;
5
+ EVENT_HIDE: "vne:credits:hide";
6
+ }
@@ -0,0 +1,5 @@
1
+ import { ModuleControllerHideOnState } from "@vnejs/module.controller.hide.on.state";
2
+ export class CreditsHideState extends ModuleControllerHideOnState {
3
+ name = "credits.hide.state";
4
+ EVENT_HIDE = this.EVENTS.CREDITS.HIDE;
5
+ }
@@ -0,0 +1,9 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
3
+ import type { CreditsPluginState } from "../types.js";
4
+ export declare class CreditsView extends ModuleView<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams, CreditsPluginState> {
5
+ name: string;
6
+ EVENT_UPDATE_VIEW: "vne:credits:update";
7
+ TRANSITION: number;
8
+ renderFunc: import("@vnejs/module.components").ViewRenderFunc<CreditsPluginState>;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+ import { render } from "../view/index.js";
3
+ export class CreditsView extends ModuleView {
4
+ name = "credits.view";
5
+ EVENT_UPDATE_VIEW = this.EVENTS.CREDITS.UPDATE;
6
+ TRANSITION = this.PARAMS.CREDITS.TRANSITION;
7
+ renderFunc = render;
8
+ }
@@ -0,0 +1,13 @@
1
+ import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
+ import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.screens.credits";
3
+ import type { Constants as ControlsConstants, PluginName as ControlsPluginName } from "@vnejs/contracts.controls";
4
+ import type { PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/contracts.core.scenario";
5
+ import type { PluginName as StatePluginName, SubscribeEvents as StateSubscribeEvents } from "@vnejs/contracts.core.state";
6
+ export type CreditsPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<ScenarioPluginName, ScenarioSubscribeEvents> & Record<StatePluginName, StateSubscribeEvents>;
7
+ export type CreditsPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
8
+ export type CreditsPluginSettings = ModuleComponentsSettings;
9
+ export type CreditsPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
10
+ export type CreditsPluginState = {
11
+ isShow: boolean;
12
+ isForce: boolean;
13
+ };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { ViewRenderFunc } from "@vnejs/module.components";
2
+ import type { CreditsPluginState } from "../types.js";
3
+ export declare const render: ViewRenderFunc<CreditsPluginState>;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ import { Flex, Screen, ScrollContent, Text, createRenderFunc, useStoreState } from "@vnejs/uis.react";
4
+ const renderLine = ({ text, props }, i) => (_createElement(Text, { ...props, text: text, key: i }));
5
+ const Credits = ({ store, onMount, PARAMS, emit, EVENTS }) => {
6
+ const { isShow = false, isForce = false } = useStoreState(store, onMount);
7
+ const propsByView = PARAMS.CREDITS.VIEW_PROPS;
8
+ const onClose = () => void emit(EVENTS.CREDITS.HIDE);
9
+ return (_jsx(Screen, { ...propsByView.screen, isShow: isShow, isForce: isForce, onClick: onClose, children: _jsx(ScrollContent, { ...propsByView.scroll, shouldScroll: isShow, onFinish: onClose, children: _jsx(Flex, { ...propsByView.flex, children: PARAMS.CREDITS.LINES.split("\n").map((line, i) => renderLine({ text: line, props: propsByView.text }, i)) }) }) }));
10
+ };
11
+ export const render = createRenderFunc(Credits);
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.controllers.screens.credits",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.16",
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.credits": "~0.2.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@vnejs/helpers": "~0.2.0",
37
+ "@vnejs/module.core": "~0.2.0",
38
+ "@vnejs/module.components": "~0.2.0",
39
+ "@vnejs/module.controller.interact": "~0.2.0",
40
+ "@vnejs/module.controller.hide.on.controls": "~0.2.0",
41
+ "@vnejs/module.controller.hide.on.state": "~0.2.0",
42
+ "@vnejs/contracts.controls": "~0.2.0",
43
+ "@vnejs/registry": "~0.2.0",
44
+ "@vnejs/uis.react": "~0.2.0"
45
+ },
46
+ "devDependencies": {
47
+ "@vnejs/configs.ts-common": "~0.2.0",
48
+ "@vnejs/configs.vitest": "~0.2.0",
49
+ "@vnejs/test-utils": "~0.2.0",
50
+ "@vnejs/contracts.controls": "~0.2.0",
51
+ "@vnejs/contracts.controllers.screens.credits": "~0.2.0",
52
+ "@vnejs/helpers": "~0.2.0",
53
+ "@vnejs/module.core": "~0.2.0",
54
+ "@vnejs/module.components": "~0.2.0",
55
+ "@vnejs/module.controller.interact": "~0.2.0",
56
+ "@vnejs/module.controller.hide.on.controls": "~0.2.0",
57
+ "@vnejs/module.controller.hide.on.state": "~0.2.0",
58
+ "@vnejs/registry": "~0.2.0",
59
+ "@vnejs/uis.react": "~0.2.0"
60
+ }
61
+ }
package/src/index.ts ADDED
@@ -0,0 +1,21 @@
1
+ import "@vnejs/contracts.controllers.screens.credits";
2
+
3
+ import { regPlugin } from "@vnejs/registry";
4
+
5
+ import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.screens.credits";
6
+
7
+ import { CreditsControllerInteract } from "./modules/controller.interact.js";
8
+ import { CreditsController } from "./modules/controller.js";
9
+ import { Credits } from "./modules/credits.js";
10
+ import { CreditsHideControls } from "./modules/hide.controls.js";
11
+ import { CreditsHideState } from "./modules/hide.state.js";
12
+ import { CreditsView } from "./modules/view.js";
13
+
14
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [
15
+ CreditsController,
16
+ CreditsControllerInteract,
17
+ CreditsHideControls,
18
+ CreditsHideState,
19
+ Credits,
20
+ CreditsView,
21
+ ]);
@@ -0,0 +1,21 @@
1
+ import { ModuleControllerInteract } from "@vnejs/module.controller.interact";
2
+
3
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
4
+ import type { CreditsPluginState } from "../types.js";
5
+
6
+ export class CreditsControllerInteract extends ModuleControllerInteract<
7
+ CreditsPluginEvents,
8
+ CreditsPluginConstants,
9
+ CreditsPluginSettings,
10
+ CreditsPluginParams,
11
+ CreditsPluginState
12
+ > {
13
+ name = "credits.controller.interact";
14
+
15
+ EVENT_SHOW = this.EVENTS.CREDITS.SHOW;
16
+ EVENT_HIDE = this.EVENTS.CREDITS.HIDE;
17
+
18
+ CONTROLS_ZINDEX = this.PARAMS.CREDITS.ZINDEX;
19
+
20
+ onInteract = () => this.emit(this.EVENTS.CREDITS.HIDE);
21
+ }
@@ -0,0 +1,27 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+
3
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
4
+ import type { CreditsPluginState } from "../types.js";
5
+ export class CreditsController extends ModuleController<
6
+ CreditsPluginEvents,
7
+ CreditsPluginConstants,
8
+ CreditsPluginSettings,
9
+ CreditsPluginParams,
10
+ CreditsPluginState
11
+ > {
12
+ name = "credits.controller";
13
+
14
+ EVENT_UPDATE_VIEW = this.EVENTS.CREDITS.UPDATE;
15
+ EVENT_UPDATE_STATE = this.EVENTS.CREDITS.UPDATE_STATE;
16
+ EVENT_UPDATE_FAST = this.EVENTS.CREDITS.UPDATE_FAST;
17
+ EVENT_UPDATE_FORCE = this.EVENTS.CREDITS.UPDATE_FORCE;
18
+ EVENT_SHOW = this.EVENTS.CREDITS.SHOW;
19
+ EVENT_HIDE = this.EVENTS.CREDITS.HIDE;
20
+
21
+ CONTROLS = {};
22
+ CONTROLS_INDEX = this.PARAMS.CREDITS.ZINDEX;
23
+
24
+ onHideAfter = () => {
25
+ void this.emit(this.EVENTS.SCENARIO.NEXT);
26
+ };
27
+ }
@@ -0,0 +1,20 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+
3
+ import type { LineExecHandlerArg } from "@vnejs/module.core";
4
+
5
+ import { tokenizeExecLine } from "@vnejs/helpers";
6
+
7
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
8
+
9
+ export class Credits extends ModuleCore<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams> {
10
+ name = "credits";
11
+
12
+ init = () => this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec });
13
+
14
+ onLineExec = ({ line = "" }: LineExecHandlerArg = {}) => {
15
+ const [action = ""] = tokenizeExecLine(line);
16
+
17
+ if (action === "show") return this.emit(this.EVENTS.CREDITS.SHOW);
18
+ if (action === "hide") return this.emit(this.EVENTS.CREDITS.HIDE);
19
+ };
20
+ }
@@ -0,0 +1,17 @@
1
+ import { ModuleControllerHideOnControls } from "@vnejs/module.controller.hide.on.controls";
2
+
3
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
4
+
5
+ export class CreditsHideControls extends ModuleControllerHideOnControls<
6
+ CreditsPluginEvents,
7
+ CreditsPluginConstants,
8
+ CreditsPluginSettings,
9
+ CreditsPluginParams
10
+ > {
11
+ name = "credits.hide.controls";
12
+
13
+ EVENT_SHOW = this.EVENTS.CREDITS.SHOW;
14
+ EVENT_HIDE = this.EVENTS.CREDITS.HIDE;
15
+
16
+ CONTROLS_ZINDEX = this.PARAMS.CREDITS.ZINDEX;
17
+ }
@@ -0,0 +1,9 @@
1
+ import { ModuleControllerHideOnState } from "@vnejs/module.controller.hide.on.state";
2
+
3
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
4
+
5
+ export class CreditsHideState extends ModuleControllerHideOnState<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams> {
6
+ name = "credits.hide.state";
7
+
8
+ EVENT_HIDE = this.EVENTS.CREDITS.HIDE;
9
+ }
@@ -0,0 +1,15 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+
3
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
4
+ import type { CreditsPluginState } from "../types.js";
5
+
6
+ import { render } from "../view/index.js";
7
+ export class CreditsView extends ModuleView<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams, CreditsPluginState> {
8
+ name = "credits.view";
9
+
10
+ EVENT_UPDATE_VIEW = this.EVENTS.CREDITS.UPDATE;
11
+
12
+ TRANSITION = this.PARAMS.CREDITS.TRANSITION;
13
+
14
+ renderFunc = render;
15
+ }
@@ -0,0 +1,30 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { SUBSCRIBE_EVENTS as SCENARIO_EVENTS } from "@vnejs/contracts.core.scenario";
6
+
7
+ import { CreditsController } from "../modules/controller.js";
8
+
9
+ import { createCreditsTestModule, registerCreditsPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
10
+
11
+ describe("CreditsController", () => {
12
+ beforeEach(() => {
13
+ registerCreditsPluginVne();
14
+ });
15
+
16
+ it("HIDE emits SCENARIO.NEXT after the screen closes", async () => {
17
+ const { module, observer } = createCreditsTestModule(CreditsController, {
18
+ shared: { viewForceAnimationSources: { isNotEmpty: () => false } },
19
+ });
20
+
21
+ (module as CreditsController).state = { isShow: true, isForce: false };
22
+
23
+ const next = spyEvent(observer, SCENARIO_EVENTS.NEXT);
24
+
25
+ await observer.emit(SUBSCRIBE_EVENTS.HIDE);
26
+
27
+ expect(next).toHaveBeenCalledOnce();
28
+ expect((module as CreditsController).state.isShow).toBe(false);
29
+ });
30
+ });
@@ -0,0 +1,32 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { Credits } from "../modules/credits.js";
6
+
7
+ import { createCreditsTestModule, registerCreditsPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
8
+
9
+ describe("Credits", () => {
10
+ beforeEach(() => {
11
+ registerCreditsPluginVne();
12
+ });
13
+
14
+ it("line exec show emits SHOW", async () => {
15
+ const { module, observer } = createCreditsTestModule(Credits, { subscribe: false });
16
+ const show = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW);
17
+
18
+ await (module as Credits).init();
19
+ await (module as Credits).onLineExec({ line: "show" });
20
+
21
+ expect(show).toHaveBeenCalledOnce();
22
+ });
23
+
24
+ it("line exec hide emits HIDE", async () => {
25
+ const { module, observer } = createCreditsTestModule(Credits, { subscribe: false });
26
+ const hide = spyEvent(observer, SUBSCRIBE_EVENTS.HIDE);
27
+
28
+ await (module as Credits).onLineExec({ line: "hide" });
29
+
30
+ expect(hide).toHaveBeenCalledOnce();
31
+ });
32
+ });
@@ -0,0 +1,57 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { CreditsHideControls } from "../modules/hide.controls.js";
6
+
7
+ import { CONTROLS_EVENTS, createCreditsTestModule, registerCreditsPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
8
+
9
+ describe("CreditsHideControls", () => {
10
+ beforeEach(() => {
11
+ registerCreditsPluginVne();
12
+ });
13
+
14
+ it("SHOW pushes BACK, MENU and GAMEMENU controls", async () => {
15
+ const { module, observer } = createCreditsTestModule(CreditsHideControls);
16
+ const hide = module as CreditsHideControls;
17
+ const push = spyEvent(observer, CONTROLS_EVENTS.PUSH);
18
+
19
+ await observer.emit(SUBSCRIBE_EVENTS.SHOW);
20
+
21
+ expect(push).toHaveBeenCalledExactlyOnceWith(
22
+ expect.objectContaining({
23
+ key: "credits.hide.controls",
24
+ checkNext: true,
25
+ index: hide.PARAMS.CREDITS.ZINDEX + 1,
26
+ }),
27
+ );
28
+ expect(push.mock.calls[0][0].controls).toHaveProperty(hide.CONST.CONTROLS.BUTTONS.BACK);
29
+ expect(push.mock.calls[0][0].controls).toHaveProperty(hide.CONST.CONTROLS.BUTTONS.MENU);
30
+ expect(push.mock.calls[0][0].controls).toHaveProperty(hide.CONST.CONTROLS.BUTTONS.GAMEMENU);
31
+ });
32
+
33
+ it("HIDE pops hide.controls", async () => {
34
+ const { observer } = createCreditsTestModule(CreditsHideControls);
35
+ const pop = spyEvent(observer, CONTROLS_EVENTS.POP);
36
+
37
+ await observer.emit(SUBSCRIBE_EVENTS.SHOW);
38
+ await observer.emit(SUBSCRIBE_EVENTS.HIDE);
39
+
40
+ expect(pop).toHaveBeenCalledExactlyOnceWith({ key: "credits.hide.controls" });
41
+ });
42
+
43
+ it("BACK, MENU and GAMEMENU emit CREDITS.HIDE", async () => {
44
+ const { module, observer } = createCreditsTestModule(CreditsHideControls);
45
+ const hide = module as CreditsHideControls;
46
+ const hideEvent = spyEvent(observer, SUBSCRIBE_EVENTS.HIDE);
47
+
48
+ hide.CONTROLS[hide.CONST.CONTROLS.BUTTONS.BACK]();
49
+ hide.CONTROLS[hide.CONST.CONTROLS.BUTTONS.MENU]();
50
+ hide.CONTROLS[hide.CONST.CONTROLS.BUTTONS.GAMEMENU]();
51
+ await Promise.resolve();
52
+ await Promise.resolve();
53
+ await Promise.resolve();
54
+
55
+ expect(hideEvent).toHaveBeenCalledTimes(3);
56
+ });
57
+ });
@@ -0,0 +1,27 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { SUBSCRIBE_EVENTS as STATE_EVENTS } from "@vnejs/contracts.core.state";
6
+
7
+ import { CreditsHideState } from "../modules/hide.state.js";
8
+
9
+ import { createCreditsTestModule, registerCreditsPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
10
+
11
+ describe("CreditsHideState", () => {
12
+ beforeEach(() => {
13
+ registerCreditsPluginVne();
14
+ });
15
+
16
+ it("STATE.SET and STATE.CLEAR emit HIDE with isForce", async () => {
17
+ const { observer } = createCreditsTestModule(CreditsHideState);
18
+ const hide = spyEvent(observer, SUBSCRIBE_EVENTS.HIDE);
19
+
20
+ await observer.emit(STATE_EVENTS.SET);
21
+ await observer.emit(STATE_EVENTS.CLEAR);
22
+
23
+ expect(hide).toHaveBeenCalledTimes(2);
24
+ expect(hide).toHaveBeenNthCalledWith(1, { isForce: true });
25
+ expect(hide).toHaveBeenNthCalledWith(2, { isForce: true });
26
+ });
27
+ });
@@ -0,0 +1,90 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent, stubSilentEvent } from "@vnejs/test-utils";
4
+
5
+ import { SUBSCRIBE_EVENTS as INTERACT_EVENTS } from "@vnejs/contracts.core.interact";
6
+
7
+ import { CreditsControllerInteract } from "../modules/controller.interact.js";
8
+
9
+ import { CONTROLS_EVENTS, createCreditsTestModule, registerCreditsPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
10
+
11
+ describe("CreditsControllerInteract", () => {
12
+ beforeEach(() => {
13
+ registerCreditsPluginVne();
14
+ });
15
+
16
+ it("SHOW pushes ANY and interact handler", async () => {
17
+ const { module, observer } = createCreditsTestModule(CreditsControllerInteract);
18
+ const interact = module as CreditsControllerInteract;
19
+ const controlsPush = spyEvent(observer, CONTROLS_EVENTS.PUSH);
20
+ const interactPush = spyEvent(observer, INTERACT_EVENTS.PUSH);
21
+
22
+ await observer.emit(SUBSCRIBE_EVENTS.SHOW);
23
+
24
+ expect(controlsPush).toHaveBeenCalledExactlyOnceWith(
25
+ expect.objectContaining({
26
+ key: "credits.controller.interact",
27
+ checkNext: true,
28
+ index: interact.PARAMS.CREDITS.ZINDEX + 1,
29
+ }),
30
+ );
31
+ expect(controlsPush.mock.calls[0][0].controls).toHaveProperty(interact.CONST.CONTROLS.BUTTONS.ANY);
32
+ expect(interactPush).toHaveBeenCalledExactlyOnceWith(
33
+ expect.objectContaining({
34
+ key: "credits.controller.interact",
35
+ }),
36
+ );
37
+ });
38
+
39
+ it("ANY emits INTERACT.EMIT", async () => {
40
+ const { module, observer } = createCreditsTestModule(CreditsControllerInteract);
41
+ const interact = module as CreditsControllerInteract;
42
+ const emit = spyEvent(observer, INTERACT_EVENTS.EMIT);
43
+
44
+ interact.CONTROLS[interact.CONST.CONTROLS.BUTTONS.ANY]();
45
+ await Promise.resolve();
46
+
47
+ expect(emit).toHaveBeenCalledOnce();
48
+ });
49
+
50
+ it("interact handler emits CREDITS.HIDE", async () => {
51
+ const { observer } = createCreditsTestModule(CreditsControllerInteract);
52
+
53
+ stubSilentEvent(observer, CONTROLS_EVENTS.PUSH);
54
+ stubSilentEvent(observer, CONTROLS_EVENTS.POP);
55
+
56
+ const interactPush = spyEvent(observer, INTERACT_EVENTS.PUSH);
57
+ const hide = spyEvent(observer, SUBSCRIBE_EVENTS.HIDE);
58
+
59
+ await observer.emit(SUBSCRIBE_EVENTS.SHOW);
60
+
61
+ const { handler } = interactPush.mock.calls[0][0] as { handler: () => void | Promise<unknown> };
62
+
63
+ await handler();
64
+
65
+ expect(hide).toHaveBeenCalledOnce();
66
+ });
67
+
68
+ it("HIDE pops interact and controls", async () => {
69
+ const { observer } = createCreditsTestModule(CreditsControllerInteract);
70
+ const interactPop = spyEvent(observer, INTERACT_EVENTS.POP);
71
+ const controlsPop = spyEvent(observer, CONTROLS_EVENTS.POP);
72
+
73
+ await observer.emit(SUBSCRIBE_EVENTS.SHOW);
74
+ await observer.emit(SUBSCRIBE_EVENTS.HIDE);
75
+
76
+ expect(interactPop).toHaveBeenCalledExactlyOnceWith({ key: "credits.controller.interact" });
77
+ expect(controlsPop).toHaveBeenCalledExactlyOnceWith({ key: "credits.controller.interact" });
78
+ });
79
+
80
+ it("HIDE without SHOW pops interact and controls", async () => {
81
+ const { observer } = createCreditsTestModule(CreditsControllerInteract);
82
+ const interactPop = spyEvent(observer, INTERACT_EVENTS.POP);
83
+ const controlsPop = spyEvent(observer, CONTROLS_EVENTS.POP);
84
+
85
+ await observer.emit(SUBSCRIBE_EVENTS.HIDE);
86
+
87
+ expect(interactPop).toHaveBeenCalledExactlyOnceWith({ key: "credits.controller.interact" });
88
+ expect(controlsPop).toHaveBeenCalledExactlyOnceWith({ key: "credits.controller.interact" });
89
+ });
90
+ });
@@ -0,0 +1,31 @@
1
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin, stubSilentEvent } from "@vnejs/test-utils";
2
+
3
+ import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.screens.credits";
4
+ import { CONSTANTS as CONTROLS_CONST, PLUGIN_NAME as CONTROLS, SUBSCRIBE_EVENTS as CONTROLS_EVENTS } from "@vnejs/contracts.controls";
5
+
6
+ export const registerCreditsPluginVne = () => {
7
+ registerCoreVne();
8
+ registerVnePlugin(CONTROLS, { constants: CONTROLS_CONST, events: CONTROLS_EVENTS });
9
+ registerVnePlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS });
10
+ };
11
+
12
+ export const createCreditsTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
13
+ ModuleClass: T,
14
+ options: Parameters<typeof baseCreateTestModule>[1] = {},
15
+ ) => {
16
+ const result = baseCreateTestModule(ModuleClass, {
17
+ state: {
18
+ credits: { isShow: false },
19
+ ...(options.state ?? {}),
20
+ },
21
+ ...options,
22
+ });
23
+
24
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.SHOW);
25
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.HIDE);
26
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UPDATE);
27
+
28
+ return result;
29
+ };
30
+
31
+ export { SUBSCRIBE_EVENTS, PARAMS, PLUGIN_NAME, CONTROLS_EVENTS };
package/src/types.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
+
3
+ import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.screens.credits";
4
+ import type { Constants as ControlsConstants, PluginName as ControlsPluginName } from "@vnejs/contracts.controls";
5
+ import type { PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/contracts.core.scenario";
6
+ import type { PluginName as StatePluginName, SubscribeEvents as StateSubscribeEvents } from "@vnejs/contracts.core.state";
7
+
8
+ export type CreditsPluginEvents = ModuleComponentsEvents &
9
+ Record<PluginName, SubscribeEvents> &
10
+ Record<ScenarioPluginName, ScenarioSubscribeEvents> &
11
+ Record<StatePluginName, StateSubscribeEvents>;
12
+
13
+ export type CreditsPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
14
+
15
+ export type CreditsPluginSettings = ModuleComponentsSettings;
16
+
17
+ export type CreditsPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
18
+
19
+ export type CreditsPluginState = {
20
+ isShow: boolean;
21
+ isForce: boolean;
22
+ };
@@ -0,0 +1,43 @@
1
+ import type { ViewRenderFunc } from "@vnejs/module.components";
2
+
3
+ import { Flex, Screen, ScrollContent, Text, createRenderFunc, useStoreState } from "@vnejs/uis.react";
4
+
5
+ import type { ReactComponentProps } from "@vnejs/uis.react";
6
+
7
+ import type { CreditsPluginConstants, CreditsPluginEvents, CreditsPluginParams, CreditsPluginSettings } from "../types.js";
8
+ import type { CreditsPluginState } from "../types.js";
9
+ type CreditsComponentProps = ReactComponentProps<CreditsPluginEvents, CreditsPluginConstants, CreditsPluginSettings, CreditsPluginParams, CreditsPluginState>;
10
+
11
+ const renderLine = ({ text, props }: { text: string; props: Record<string, unknown> }, i: number) => (
12
+ <Text
13
+ {...props}
14
+ text={text}
15
+ key={i}
16
+ />
17
+ );
18
+
19
+ const Credits = ({ store, onMount, PARAMS, emit, EVENTS }: CreditsComponentProps) => {
20
+ const { isShow = false, isForce = false } = useStoreState<CreditsPluginState>(store, onMount);
21
+
22
+ const propsByView = PARAMS.CREDITS.VIEW_PROPS;
23
+ const onClose = () => void emit(EVENTS.CREDITS.HIDE);
24
+
25
+ return (
26
+ <Screen
27
+ {...propsByView.screen}
28
+ isShow={isShow}
29
+ isForce={isForce}
30
+ onClick={onClose}
31
+ >
32
+ <ScrollContent
33
+ {...propsByView.scroll}
34
+ shouldScroll={isShow}
35
+ onFinish={onClose}
36
+ >
37
+ <Flex {...propsByView.flex}>{PARAMS.CREDITS.LINES.split("\n").map((line, i) => renderLine({ text: line, props: propsByView.text }, i))}</Flex>
38
+ </ScrollContent>
39
+ </Screen>
40
+ );
41
+ };
42
+
43
+ export const render: ViewRenderFunc<CreditsPluginState> = createRenderFunc(Credits);
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.