@vnejs/compatibility.scenario.choose-with-scenario.qte 0.2.0 → 0.2.2

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 CHANGED
@@ -8,7 +8,7 @@ declare module "@vnejs/contracts.scenario.choose" {
8
8
  qte?: string;
9
9
  }
10
10
  }
11
- export declare class CompatibilityChooseQte extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
11
+ export declare class CompatibilityScenarioChooseWithScenarioQte extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
12
12
  name: string;
13
13
  pendingResolve: ((success: boolean) => void) | null;
14
14
  init: () => Promise<unknown[]> | undefined;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "@vnejs/contracts.scenario.choose";
2
2
  import { ModuleCore } from "@vnejs/module.core";
3
3
  import { regModule } from "@vnejs/shared";
4
- export class CompatibilityChooseQte extends ModuleCore {
4
+ export class CompatibilityScenarioChooseWithScenarioQte extends ModuleCore {
5
5
  name = "compatibility.scenario.choose-with-scenario.qte";
6
6
  pendingResolve = null;
7
7
  init = () => this.emit(this.EVENTS.CHOOSE.OPTION_REPLACE_REG, {
@@ -44,4 +44,4 @@ export class CompatibilityChooseQte extends ModuleCore {
44
44
  return fallbackIndex;
45
45
  };
46
46
  }
47
- regModule(CompatibilityChooseQte);
47
+ regModule(CompatibilityScenarioChooseWithScenarioQte);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/compatibility.scenario.choose-with-scenario.qte",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -2,12 +2,7 @@ import "@vnejs/contracts.scenario.choose";
2
2
 
3
3
  import { ModuleCore } from "@vnejs/module.core";
4
4
  import { regModule } from "@vnejs/shared";
5
- import type {
6
- ChooseOption,
7
- ChooseOptionReplaceHandler,
8
- ChooseOptionReplacePayload,
9
- ChooseOptionReplaceRegPayload,
10
- } from "@vnejs/contracts.scenario.choose";
5
+ import type { ChooseOption, ChooseOptionReplaceHandler, ChooseOptionReplacePayload, ChooseOptionReplaceRegPayload } from "@vnejs/contracts.scenario.choose";
11
6
  import type { QteEmitPayload, QteResultPayload } from "@vnejs/contracts.scenario.qte";
12
7
 
13
8
  import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "./types.js";
@@ -18,7 +13,7 @@ declare module "@vnejs/contracts.scenario.choose" {
18
13
  }
19
14
  }
20
15
 
21
- export class CompatibilityChooseQte extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
16
+ export class CompatibilityScenarioChooseWithScenarioQte extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
22
17
  name = "compatibility.scenario.choose-with-scenario.qte";
23
18
 
24
19
  pendingResolve: ((success: boolean) => void) | null = null;
@@ -64,9 +59,7 @@ export class CompatibilityChooseQte extends ModuleCore<PluginEvents, PluginConst
64
59
  };
65
60
 
66
61
  resolveFailIndex = (index: number, options: ChooseOption[]) => {
67
- const fallbackIndex = options.findIndex((option) =>
68
- option.keywords?.includes(this.CONST.QTE.LINE_KEYWORDS.QTE_FALLBACK),
69
- );
62
+ const fallbackIndex = options.findIndex((option) => option.keywords?.includes(this.CONST.QTE.LINE_KEYWORDS.QTE_FALLBACK));
70
63
 
71
64
  if (fallbackIndex < 0) {
72
65
  this.emitLog({ action: "missing_fallback", index });
@@ -77,4 +70,4 @@ export class CompatibilityChooseQte extends ModuleCore<PluginEvents, PluginConst
77
70
  };
78
71
  }
79
72
 
80
- regModule(CompatibilityChooseQte);
73
+ regModule(CompatibilityScenarioChooseWithScenarioQte);
@@ -3,15 +3,8 @@ import { beforeEach, describe, expect, it } from "vitest";
3
3
  import { spyEvent } from "@vnejs/test-utils";
4
4
  import type { ChooseOption, ChooseOptionReplaceHandler } from "@vnejs/contracts.scenario.choose";
5
5
 
6
- import { CompatibilityChooseQte } from "../index.js";
7
- import {
8
- CHOOSE_EVENTS,
9
- createCompatibilityTestModule,
10
- QTE_EVENTS,
11
- QTE_LINE_KEYWORDS,
12
- QTE_PARAMS,
13
- registerCompatibilityVne,
14
- } from "./setup.js";
6
+ import { CompatibilityScenarioChooseWithScenarioQte } from "../index.js";
7
+ import { CHOOSE_EVENTS, createCompatibilityTestModule, QTE_EVENTS, QTE_LINE_KEYWORDS, QTE_PARAMS, registerCompatibilityVne } from "./setup.js";
15
8
 
16
9
  const OPTIONS: ChooseOption[] = [
17
10
  { index: 10, text: "With QTE", qte: "easy" },
@@ -20,28 +13,28 @@ const OPTIONS: ChooseOption[] = [
20
13
 
21
14
  const ITEM = { start: 50, size: 40, duration: 2500 };
22
15
 
23
- describe("CompatibilityChooseQte", () => {
16
+ describe("CompatibilityScenarioChooseWithScenarioQte", () => {
24
17
  beforeEach(() => {
25
18
  registerCompatibilityVne();
26
19
  Object.assign(QTE_PARAMS.ITEMS, { easy: ITEM });
27
20
  });
28
21
 
29
22
  it("init registers OPTION_REPLACE handler", async () => {
30
- const { module, observer } = createCompatibilityTestModule(CompatibilityChooseQte, { subscribe: false });
23
+ const { module, observer } = createCompatibilityTestModule(CompatibilityScenarioChooseWithScenarioQte, { subscribe: false });
31
24
  const replaceReg = spyEvent(observer, CHOOSE_EVENTS.OPTION_REPLACE_REG);
32
25
 
33
- await (module as CompatibilityChooseQte).init();
26
+ await (module as CompatibilityScenarioChooseWithScenarioQte).init();
34
27
 
35
28
  expect(replaceReg).toHaveBeenCalledOnce();
36
29
  expect(replaceReg.mock.calls[0]?.[0]?.handler).toBeTypeOf("function");
37
30
  });
38
31
 
39
32
  it("returns same index when option has no qte", async () => {
40
- const { module, observer } = createCompatibilityTestModule(CompatibilityChooseQte, { subscribe: false });
33
+ const { module, observer } = createCompatibilityTestModule(CompatibilityScenarioChooseWithScenarioQte, { subscribe: false });
41
34
  const replaceReg = spyEvent(observer, CHOOSE_EVENTS.OPTION_REPLACE_REG);
42
35
  const emit = spyEvent(observer, QTE_EVENTS.EMIT);
43
36
 
44
- await (module as CompatibilityChooseQte).init();
37
+ await (module as CompatibilityScenarioChooseWithScenarioQte).init();
45
38
 
46
39
  const handler = replaceReg.mock.calls[0]?.[0]?.handler as ChooseOptionReplaceHandler;
47
40
  const result = await handler({ index: 1, options: OPTIONS });
@@ -51,11 +44,11 @@ describe("CompatibilityChooseQte", () => {
51
44
  });
52
45
 
53
46
  it("success keeps selected index", async () => {
54
- const { module, observer } = createCompatibilityTestModule(CompatibilityChooseQte);
47
+ const { module, observer } = createCompatibilityTestModule(CompatibilityScenarioChooseWithScenarioQte);
55
48
  const replaceReg = spyEvent(observer, CHOOSE_EVENTS.OPTION_REPLACE_REG);
56
49
  const emit = spyEvent(observer, QTE_EVENTS.EMIT);
57
50
 
58
- await (module as CompatibilityChooseQte).init();
51
+ await (module as CompatibilityScenarioChooseWithScenarioQte).init();
59
52
 
60
53
  const handler = replaceReg.mock.calls[0]?.[0]?.handler as ChooseOptionReplaceHandler;
61
54
  const pending = handler({ index: 0, options: OPTIONS });
@@ -69,10 +62,10 @@ describe("CompatibilityChooseQte", () => {
69
62
  });
70
63
 
71
64
  it("fail remaps to qte-fallback option", async () => {
72
- const { module, observer } = createCompatibilityTestModule(CompatibilityChooseQte);
65
+ const { module, observer } = createCompatibilityTestModule(CompatibilityScenarioChooseWithScenarioQte);
73
66
  const replaceReg = spyEvent(observer, CHOOSE_EVENTS.OPTION_REPLACE_REG);
74
67
 
75
- await (module as CompatibilityChooseQte).init();
68
+ await (module as CompatibilityScenarioChooseWithScenarioQte).init();
76
69
 
77
70
  const handler = replaceReg.mock.calls[0]?.[0]?.handler as ChooseOptionReplaceHandler;
78
71
  const pending = handler({ index: 0, options: OPTIONS });
@@ -84,11 +77,11 @@ describe("CompatibilityChooseQte", () => {
84
77
  });
85
78
 
86
79
  it("fail without fallback keeps selected index", async () => {
87
- const { module, observer } = createCompatibilityTestModule(CompatibilityChooseQte);
80
+ const { module, observer } = createCompatibilityTestModule(CompatibilityScenarioChooseWithScenarioQte);
88
81
  const replaceReg = spyEvent(observer, CHOOSE_EVENTS.OPTION_REPLACE_REG);
89
82
  const options: ChooseOption[] = [{ index: 10, text: "With QTE", qte: "easy" }];
90
83
 
91
- await (module as CompatibilityChooseQte).init();
84
+ await (module as CompatibilityScenarioChooseWithScenarioQte).init();
92
85
 
93
86
  const handler = replaceReg.mock.calls[0]?.[0]?.handler as ChooseOptionReplaceHandler;
94
87
  const pending = handler({ index: 0, options });
@@ -100,7 +93,7 @@ describe("CompatibilityChooseQte", () => {
100
93
  });
101
94
 
102
95
  it("missing item fails without opening QTE emit of item", async () => {
103
- const { module, observer } = createCompatibilityTestModule(CompatibilityChooseQte, { subscribe: false });
96
+ const { module, observer } = createCompatibilityTestModule(CompatibilityScenarioChooseWithScenarioQte, { subscribe: false });
104
97
  const replaceReg = spyEvent(observer, CHOOSE_EVENTS.OPTION_REPLACE_REG);
105
98
  const emit = spyEvent(observer, QTE_EVENTS.EMIT);
106
99
  const options: ChooseOption[] = [
@@ -108,7 +101,7 @@ describe("CompatibilityChooseQte", () => {
108
101
  { index: 20, text: "Fallback", keywords: [QTE_LINE_KEYWORDS.QTE_FALLBACK] },
109
102
  ];
110
103
 
111
- await (module as CompatibilityChooseQte).init();
104
+ await (module as CompatibilityScenarioChooseWithScenarioQte).init();
112
105
 
113
106
  const handler = replaceReg.mock.calls[0]?.[0]?.handler as ChooseOptionReplaceHandler;
114
107
  const result = await handler({ index: 0, options });
package/src/types.ts CHANGED
@@ -7,9 +7,7 @@ import type {
7
7
  SubscribeEvents as QteSubscribeEvents,
8
8
  } from "@vnejs/contracts.scenario.qte";
9
9
 
10
- export type PluginEvents = ModuleCoreEvents &
11
- Record<ChoosePluginName, ChooseSubscribeEvents> &
12
- Record<QtePluginName, QteSubscribeEvents>;
10
+ export type PluginEvents = ModuleCoreEvents & Record<ChoosePluginName, ChooseSubscribeEvents> & Record<QtePluginName, QteSubscribeEvents>;
13
11
 
14
12
  export type PluginConstants = ModuleCoreConstants & Record<QtePluginName, QteConstants>;
15
13
 
package/tsconfig.json CHANGED
@@ -4,12 +4,6 @@
4
4
  "rootDir": "src",
5
5
  "outDir": "dist"
6
6
  },
7
- "include": [
8
- "src/**/*.ts"
9
- ],
10
- "exclude": [
11
- "dist",
12
- "node_modules",
13
- "src/tests"
14
- ]
7
+ "include": ["src/**/*.ts"],
8
+ "exclude": ["dist", "node_modules", "src/tests"]
15
9
  }