@vnejs/plugins.views.scenario.qte 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,6 +2,6 @@ import "@vnejs/contracts.scenario.qte";
2
2
  import "@vnejs/contracts.views.scenario.qte";
3
3
  import { regPlugin } from "@vnejs/shared";
4
4
  import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.scenario.qte";
5
- import { QteController } from "./modules/controller.js";
6
- import { QteView } from "./modules/view.js";
7
- regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [QteController, QteView]);
5
+ import { QteViewController } from "./modules/controller.js";
6
+ import { QteViewView } from "./modules/view.js";
7
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [QteViewController, QteViewView]);
@@ -2,14 +2,14 @@ import { ModuleController } from "@vnejs/module.components";
2
2
  import type { ViewActionPayload } from "@vnejs/module.components";
3
3
  import type { QtePluginConstants, QtePluginEvents, QtePluginParams, QtePluginSettings } from "../types.js";
4
4
  import type { QtePluginControllerState, QteVisibilityPayload } from "../utils/qte.js";
5
- export declare class QteController extends ModuleController<QtePluginEvents, QtePluginConstants, QtePluginSettings, QtePluginParams, QtePluginControllerState> {
5
+ export declare class QteViewController extends ModuleController<QtePluginEvents, QtePluginConstants, QtePluginSettings, QtePluginParams, QtePluginControllerState> {
6
6
  name: string;
7
- updateEvent: "vne:qte_view:update";
8
- controls: {
7
+ EVENT_UPDATE_VIEW: "vne:qte_view:update";
8
+ CONTROLS: {
9
9
  abstract_accept: () => undefined;
10
10
  abstract_interact: () => undefined;
11
11
  };
12
- controlsIndex: number;
12
+ CONTROLS_INDEX: number;
13
13
  activeStartedAt: number | null;
14
14
  isResolved: boolean;
15
15
  resultTimeout: ReturnType<typeof setTimeout> | null;
@@ -1,13 +1,13 @@
1
1
  import { ModuleController } from "@vnejs/module.components";
2
2
  import { getFailAtProgress, getProgressFromElapsed, isProgressInsideZone } from "../utils/qte.js";
3
- export class QteController extends ModuleController {
3
+ export class QteViewController extends ModuleController {
4
4
  name = "qte_view.controller";
5
- updateEvent = this.EVENTS.QTE_VIEW.UPDATE;
6
- controls = {
5
+ EVENT_UPDATE_VIEW = this.EVENTS.QTE_VIEW.UPDATE;
6
+ CONTROLS = {
7
7
  [this.CONST.CONTROLS.BUTTONS.ACCEPT]: () => void this.onAction(),
8
8
  [this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.onAction(),
9
9
  };
10
- controlsIndex = this.PARAMS.QTE_VIEW.ZINDEX;
10
+ CONTROLS_INDEX = this.PARAMS.QTE_VIEW.ZINDEX;
11
11
  activeStartedAt = null;
12
12
  isResolved = false;
13
13
  resultTimeout = null;
@@ -1,11 +1,10 @@
1
1
  import { ModuleView } from "@vnejs/module.components";
2
2
  import type { QtePluginConstants, QtePluginEvents, QtePluginParams, QtePluginSettings } from "../types.js";
3
3
  import type { QtePluginControllerState } from "../utils/qte.js";
4
- export declare class QteView extends ModuleView<QtePluginEvents, QtePluginConstants, QtePluginSettings, QtePluginParams, QtePluginControllerState> {
4
+ export declare class QteViewView extends ModuleView<QtePluginEvents, QtePluginConstants, QtePluginSettings, QtePluginParams, QtePluginControllerState> {
5
5
  name: string;
6
- locLabel: string;
7
- animationTime: number;
8
- updateEvent: "vne:qte_view:update";
6
+ EVENT_UPDATE_VIEW: "vne:qte_view:update";
7
+ LOC_LABEL: string;
8
+ TRANSITION: number;
9
9
  renderFunc: import("@vnejs/module.components").ViewRenderFunc<QtePluginControllerState>;
10
- updateHandler: (state?: QtePluginControllerState | undefined) => Promise<void>;
11
10
  }
@@ -1,10 +1,9 @@
1
1
  import { ModuleView } from "@vnejs/module.components";
2
2
  import { render } from "../view/index.js";
3
- export class QteView extends ModuleView {
3
+ export class QteViewView extends ModuleView {
4
4
  name = "qte_view.view";
5
- locLabel = this.PARAMS.QTE_VIEW.LOC_LABEL;
6
- animationTime = this.PARAMS.QTE_VIEW.TRANSITION;
7
- updateEvent = this.EVENTS.QTE_VIEW.UPDATE;
5
+ EVENT_UPDATE_VIEW = this.EVENTS.QTE_VIEW.UPDATE;
6
+ LOC_LABEL = this.PARAMS.QTE_VIEW.LOC_LABEL;
7
+ TRANSITION = this.PARAMS.QTE_VIEW.TRANSITION;
8
8
  renderFunc = render;
9
- updateHandler = this.onUpdateStoreComponent;
10
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.views.scenario.qte",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ import "@vnejs/contracts.views.scenario.qte";
4
4
  import { regPlugin } from "@vnejs/shared";
5
5
  import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.scenario.qte";
6
6
 
7
- import { QteController } from "./modules/controller.js";
8
- import { QteView } from "./modules/view.js";
7
+ import { QteViewController } from "./modules/controller.js";
8
+ import { QteViewView } from "./modules/view.js";
9
9
 
10
- regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [QteController, QteView]);
10
+ regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [QteViewController, QteViewView]);
@@ -6,16 +6,16 @@ import type { QtePluginConstants, QtePluginEvents, QtePluginParams, QtePluginSet
6
6
  import type { QtePluginControllerState, QteVisibilityPayload } from "../utils/qte.js";
7
7
  import { getFailAtProgress, getProgressFromElapsed, isProgressInsideZone } from "../utils/qte.js";
8
8
 
9
- export class QteController extends ModuleController<QtePluginEvents, QtePluginConstants, QtePluginSettings, QtePluginParams, QtePluginControllerState> {
9
+ export class QteViewController extends ModuleController<QtePluginEvents, QtePluginConstants, QtePluginSettings, QtePluginParams, QtePluginControllerState> {
10
10
  name = "qte_view.controller";
11
11
 
12
- updateEvent = this.EVENTS.QTE_VIEW.UPDATE;
12
+ EVENT_UPDATE_VIEW = this.EVENTS.QTE_VIEW.UPDATE;
13
13
 
14
- controls = {
14
+ CONTROLS = {
15
15
  [this.CONST.CONTROLS.BUTTONS.ACCEPT]: () => void this.onAction(),
16
16
  [this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.onAction(),
17
17
  };
18
- controlsIndex = this.PARAMS.QTE_VIEW.ZINDEX;
18
+ CONTROLS_INDEX = this.PARAMS.QTE_VIEW.ZINDEX;
19
19
 
20
20
  activeStartedAt: number | null = null;
21
21
  isResolved = false;
@@ -4,13 +4,14 @@ import { render } from "../view/index.js";
4
4
  import type { QtePluginConstants, QtePluginEvents, QtePluginParams, QtePluginSettings } from "../types.js";
5
5
  import type { QtePluginControllerState } from "../utils/qte.js";
6
6
 
7
- export class QteView extends ModuleView<QtePluginEvents, QtePluginConstants, QtePluginSettings, QtePluginParams, QtePluginControllerState> {
7
+ export class QteViewView extends ModuleView<QtePluginEvents, QtePluginConstants, QtePluginSettings, QtePluginParams, QtePluginControllerState> {
8
8
  name = "qte_view.view";
9
9
 
10
- locLabel = this.PARAMS.QTE_VIEW.LOC_LABEL;
11
- animationTime = this.PARAMS.QTE_VIEW.TRANSITION;
12
- updateEvent = this.EVENTS.QTE_VIEW.UPDATE;
10
+ EVENT_UPDATE_VIEW = this.EVENTS.QTE_VIEW.UPDATE;
11
+
12
+ LOC_LABEL = this.PARAMS.QTE_VIEW.LOC_LABEL;
13
+
14
+ TRANSITION = this.PARAMS.QTE_VIEW.TRANSITION;
13
15
 
14
16
  renderFunc = render;
15
- updateHandler = this.onUpdateStoreComponent;
16
17
  }
@@ -2,17 +2,17 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
2
2
 
3
3
  import { spyEvent } from "@vnejs/test-utils";
4
4
 
5
- import { QteController } from "../modules/controller.js";
5
+ import { QteViewController } from "../modules/controller.js";
6
6
  import { createQteViewTestModule, registerQteViewPluginVne, QTE_EVENTS, SUBSCRIBE_EVENTS } from "./setup.js";
7
7
 
8
- describe("QteController", () => {
8
+ describe("QteViewController", () => {
9
9
  beforeEach(() => {
10
10
  registerQteViewPluginVne();
11
11
  vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "performance"] });
12
12
  });
13
13
 
14
14
  it("OPENED bridge emits SHOW with payload", async () => {
15
- const { observer } = createQteViewTestModule(QteController);
15
+ const { observer } = createQteViewTestModule(QteViewController);
16
16
  const show = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW);
17
17
  const payload = { id: "door_lock", item: { start: 70, size: 20, duration: 1500 } };
18
18
 
@@ -22,66 +22,66 @@ describe("QteController", () => {
22
22
  });
23
23
 
24
24
  it("SHOW starts in initial, then intro, then active", async () => {
25
- const { module, observer } = createQteViewTestModule(QteController);
25
+ const { module, observer } = createQteViewTestModule(QteViewController);
26
26
  const item = { start: 70, size: 20, duration: 1500 };
27
- const { INITIAL, TRANSITION } = (module as QteController).PARAMS.QTE_VIEW;
27
+ const { INITIAL, TRANSITION } = (module as QteViewController).PARAMS.QTE_VIEW;
28
28
 
29
29
  await observer.emit(SUBSCRIBE_EVENTS.SHOW, { id: "door_lock", item });
30
30
 
31
- expect((module as QteController).state.id).toBe("door_lock");
32
- expect((module as QteController).state.item).toEqual(item);
33
- expect((module as QteController).state.phase).toBe("initial");
31
+ expect((module as QteViewController).state.id).toBe("door_lock");
32
+ expect((module as QteViewController).state.item).toEqual(item);
33
+ expect((module as QteViewController).state.phase).toBe("initial");
34
34
 
35
35
  await vi.advanceTimersByTimeAsync(INITIAL);
36
- expect((module as QteController).state.phase).toBe("intro");
36
+ expect((module as QteViewController).state.phase).toBe("intro");
37
37
 
38
38
  await vi.advanceTimersByTimeAsync(TRANSITION - INITIAL);
39
- expect((module as QteController).state.phase).toBe("active");
40
- expect((module as QteController).activeStartedAt).not.toBeNull();
39
+ expect((module as QteViewController).state.phase).toBe("active");
40
+ expect((module as QteViewController).activeStartedAt).not.toBeNull();
41
41
  });
42
42
 
43
43
  it("ACTION resolves success inside zone by elapsed time", async () => {
44
- const { module, observer } = createQteViewTestModule(QteController);
44
+ const { module, observer } = createQteViewTestModule(QteViewController);
45
45
  const result = spyEvent(observer, QTE_EVENTS.RESULT);
46
46
  const item = { start: 40, size: 20, duration: 1000 };
47
47
 
48
48
  await observer.emit(SUBSCRIBE_EVENTS.SHOW, { id: "door_lock", item });
49
- await vi.advanceTimersByTimeAsync((module as QteController).PARAMS.QTE_VIEW.TRANSITION);
49
+ await vi.advanceTimersByTimeAsync((module as QteViewController).PARAMS.QTE_VIEW.TRANSITION);
50
50
  await vi.advanceTimersByTimeAsync(500);
51
51
 
52
52
  await observer.emit(SUBSCRIBE_EVENTS.ACTION);
53
53
 
54
- expect((module as QteController).state.result).toBe("success");
54
+ expect((module as QteViewController).state.result).toBe("success");
55
55
 
56
- await vi.advanceTimersByTimeAsync((module as QteController).PARAMS.QTE_VIEW.RESULT_DELAY);
56
+ await vi.advanceTimersByTimeAsync((module as QteViewController).PARAMS.QTE_VIEW.RESULT_DELAY);
57
57
 
58
58
  expect(result).toHaveBeenCalledExactlyOnceWith({ success: true });
59
59
  });
60
60
 
61
61
  it("ACTION resolves fail outside zone", async () => {
62
- const { module, observer } = createQteViewTestModule(QteController);
62
+ const { module, observer } = createQteViewTestModule(QteViewController);
63
63
  const item = { start: 70, size: 20, duration: 1000 };
64
64
 
65
65
  await observer.emit(SUBSCRIBE_EVENTS.SHOW, { id: "door_lock", item });
66
- await vi.advanceTimersByTimeAsync((module as QteController).PARAMS.QTE_VIEW.TRANSITION);
66
+ await vi.advanceTimersByTimeAsync((module as QteViewController).PARAMS.QTE_VIEW.TRANSITION);
67
67
  await vi.advanceTimersByTimeAsync(100);
68
68
 
69
- (module as QteController).controls[(module as QteController).CONST.CONTROLS.BUTTONS.ACCEPT]();
69
+ (module as QteViewController).CONTROLS[(module as QteViewController).CONST.CONTROLS.BUTTONS.ACCEPT]();
70
70
 
71
- expect((module as QteController).state.result).toBe("fail");
71
+ expect((module as QteViewController).state.result).toBe("fail");
72
72
  });
73
73
 
74
74
  it("auto-fails when pointer leaves the zone", async () => {
75
- const { module, observer } = createQteViewTestModule(QteController);
75
+ const { module, observer } = createQteViewTestModule(QteViewController);
76
76
  const result = spyEvent(observer, QTE_EVENTS.RESULT);
77
77
  const item = { start: 50, size: 10, duration: 1000 };
78
78
 
79
79
  await observer.emit(SUBSCRIBE_EVENTS.SHOW, { id: "door_lock", item });
80
- await vi.advanceTimersByTimeAsync((module as QteController).PARAMS.QTE_VIEW.TRANSITION);
80
+ await vi.advanceTimersByTimeAsync((module as QteViewController).PARAMS.QTE_VIEW.TRANSITION);
81
81
  await vi.advanceTimersByTimeAsync(600);
82
- await vi.advanceTimersByTimeAsync((module as QteController).PARAMS.QTE_VIEW.RESULT_DELAY);
82
+ await vi.advanceTimersByTimeAsync((module as QteViewController).PARAMS.QTE_VIEW.RESULT_DELAY);
83
83
 
84
- expect((module as QteController).state.result).toBe("fail");
84
+ expect((module as QteViewController).state.result).toBe("fail");
85
85
  expect(result).toHaveBeenCalledExactlyOnceWith({ success: false });
86
86
  });
87
87
  });