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

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
@@ -6,7 +6,6 @@ import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from
6
6
  declare module "@vnejs/contracts.scenario.choose" {
7
7
  interface ChooseOption {
8
8
  qte?: string;
9
- qte_fallback?: boolean;
10
9
  }
11
10
  }
12
11
  export declare class CompatibilityChooseQte extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ export class CompatibilityChooseQte extends ModuleCore {
36
36
  return this.resolveFailIndex(index, options);
37
37
  };
38
38
  resolveFailIndex = (index, options) => {
39
- const fallbackIndex = options.findIndex((option) => option.qte_fallback === true);
39
+ const fallbackIndex = options.findIndex((option) => option.keywords?.includes(this.CONST.QTE.LINE_KEYWORDS.QTE_FALLBACK));
40
40
  if (fallbackIndex < 0) {
41
41
  this.emitLog({ action: "missing_fallback", index });
42
42
  return index;
package/dist/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
2
  import type { PluginName as ChoosePluginName, SubscribeEvents as ChooseSubscribeEvents } from "@vnejs/contracts.scenario.choose";
3
- import type { Params as QteParams, PluginName as QtePluginName, SubscribeEvents as QteSubscribeEvents } from "@vnejs/contracts.scenario.qte";
3
+ import type { Constants as QteConstants, Params as QteParams, PluginName as QtePluginName, SubscribeEvents as QteSubscribeEvents } from "@vnejs/contracts.scenario.qte";
4
4
  export type PluginEvents = ModuleCoreEvents & Record<ChoosePluginName, ChooseSubscribeEvents> & Record<QtePluginName, QteSubscribeEvents>;
5
- export type PluginConstants = ModuleCoreConstants;
5
+ export type PluginConstants = ModuleCoreConstants & Record<QtePluginName, QteConstants>;
6
6
  export type PluginSettings = ModuleCoreSettings;
7
7
  export type PluginParams = ModuleCoreParams & Record<QtePluginName, QteParams>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/compatibility.scenario.choose-with-scenario.qte",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,18 +30,18 @@
30
30
  "author": "",
31
31
  "license": "ISC",
32
32
  "peerDependencies": {
33
- "@vnejs/module.core": "~0.1.0",
34
- "@vnejs/contracts.scenario.choose": "~0.1.0",
35
- "@vnejs/contracts.scenario.qte": "~0.1.0",
36
- "@vnejs/shared": "~0.1.0"
33
+ "@vnejs/module.core": "~0.2.0",
34
+ "@vnejs/contracts.scenario.choose": "~0.2.0",
35
+ "@vnejs/contracts.scenario.qte": "~0.2.0",
36
+ "@vnejs/shared": "~0.2.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@vnejs/configs.ts-common": "~0.1.0",
40
- "@vnejs/configs.vitest": "~0.1.0",
41
- "@vnejs/test-utils": "~0.1.0",
42
- "@vnejs/contracts.scenario.choose": "~0.1.0",
43
- "@vnejs/contracts.scenario.qte": "~0.1.0",
44
- "@vnejs/module.core": "~0.1.0",
45
- "@vnejs/shared": "~0.1.0"
39
+ "@vnejs/configs.ts-common": "~0.2.0",
40
+ "@vnejs/configs.vitest": "~0.2.0",
41
+ "@vnejs/test-utils": "~0.2.0",
42
+ "@vnejs/contracts.scenario.choose": "~0.2.0",
43
+ "@vnejs/contracts.scenario.qte": "~0.2.0",
44
+ "@vnejs/module.core": "~0.2.0",
45
+ "@vnejs/shared": "~0.2.0"
46
46
  }
47
47
  }
package/src/index.ts CHANGED
@@ -15,7 +15,6 @@ import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from
15
15
  declare module "@vnejs/contracts.scenario.choose" {
16
16
  interface ChooseOption {
17
17
  qte?: string;
18
- qte_fallback?: boolean;
19
18
  }
20
19
  }
21
20
 
@@ -65,7 +64,9 @@ export class CompatibilityChooseQte extends ModuleCore<PluginEvents, PluginConst
65
64
  };
66
65
 
67
66
  resolveFailIndex = (index: number, options: ChooseOption[]) => {
68
- const fallbackIndex = options.findIndex((option) => option.qte_fallback === true);
67
+ const fallbackIndex = options.findIndex((option) =>
68
+ option.keywords?.includes(this.CONST.QTE.LINE_KEYWORDS.QTE_FALLBACK),
69
+ );
69
70
 
70
71
  if (fallbackIndex < 0) {
71
72
  this.emitLog({ action: "missing_fallback", index });
@@ -4,11 +4,18 @@ import { spyEvent } from "@vnejs/test-utils";
4
4
  import type { ChooseOption, ChooseOptionReplaceHandler } from "@vnejs/contracts.scenario.choose";
5
5
 
6
6
  import { CompatibilityChooseQte } from "../index.js";
7
- import { CHOOSE_EVENTS, createCompatibilityTestModule, QTE_EVENTS, QTE_PARAMS, registerCompatibilityVne } from "./setup.js";
7
+ import {
8
+ CHOOSE_EVENTS,
9
+ createCompatibilityTestModule,
10
+ QTE_EVENTS,
11
+ QTE_LINE_KEYWORDS,
12
+ QTE_PARAMS,
13
+ registerCompatibilityVne,
14
+ } from "./setup.js";
8
15
 
9
16
  const OPTIONS: ChooseOption[] = [
10
17
  { index: 10, text: "With QTE", qte: "easy" },
11
- { index: 20, text: "Fallback", qte_fallback: true },
18
+ { index: 20, text: "Fallback", keywords: [QTE_LINE_KEYWORDS.QTE_FALLBACK] },
12
19
  ];
13
20
 
14
21
  const ITEM = { start: 50, size: 40, duration: 2500 };
@@ -61,7 +68,7 @@ describe("CompatibilityChooseQte", () => {
61
68
  expect(await pending).toBe(0);
62
69
  });
63
70
 
64
- it("fail remaps to qte_fallback option", async () => {
71
+ it("fail remaps to qte-fallback option", async () => {
65
72
  const { module, observer } = createCompatibilityTestModule(CompatibilityChooseQte);
66
73
  const replaceReg = spyEvent(observer, CHOOSE_EVENTS.OPTION_REPLACE_REG);
67
74
 
@@ -98,7 +105,7 @@ describe("CompatibilityChooseQte", () => {
98
105
  const emit = spyEvent(observer, QTE_EVENTS.EMIT);
99
106
  const options: ChooseOption[] = [
100
107
  { index: 10, text: "With QTE", qte: "missing" },
101
- { index: 20, text: "Fallback", qte_fallback: true },
108
+ { index: 20, text: "Fallback", keywords: [QTE_LINE_KEYWORDS.QTE_FALLBACK] },
102
109
  ];
103
110
 
104
111
  await (module as CompatibilityChooseQte).init();
@@ -1,11 +1,17 @@
1
1
  import { PARAMS as CHOOSE_PARAMS, PLUGIN_NAME as CHOOSE, SUBSCRIBE_EVENTS as CHOOSE_EVENTS } from "@vnejs/contracts.scenario.choose";
2
- import { PARAMS as QTE_PARAMS, PLUGIN_NAME as QTE, SUBSCRIBE_EVENTS as QTE_EVENTS } from "@vnejs/contracts.scenario.qte";
2
+ import {
3
+ CONSTANTS as QTE_CONSTANTS,
4
+ LINE_KEYWORDS as QTE_LINE_KEYWORDS,
5
+ PARAMS as QTE_PARAMS,
6
+ PLUGIN_NAME as QTE,
7
+ SUBSCRIBE_EVENTS as QTE_EVENTS,
8
+ } from "@vnejs/contracts.scenario.qte";
3
9
  import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
4
10
 
5
11
  export const registerCompatibilityVne = () => {
6
12
  registerCoreVne();
7
13
  registerVnePlugin(CHOOSE, { events: CHOOSE_EVENTS, params: CHOOSE_PARAMS });
8
- registerVnePlugin(QTE, { events: QTE_EVENTS, params: QTE_PARAMS });
14
+ registerVnePlugin(QTE, { events: QTE_EVENTS, params: QTE_PARAMS, constants: QTE_CONSTANTS });
9
15
  };
10
16
 
11
17
  export const createCompatibilityTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
@@ -13,4 +19,4 @@ export const createCompatibilityTestModule = <T extends Parameters<typeof baseCr
13
19
  options: Parameters<typeof baseCreateTestModule>[1] = {},
14
20
  ) => baseCreateTestModule(ModuleClass, options);
15
21
 
16
- export { CHOOSE_EVENTS, QTE_EVENTS, QTE_PARAMS };
22
+ export { CHOOSE_EVENTS, QTE_EVENTS, QTE_LINE_KEYWORDS, QTE_PARAMS };
package/src/types.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
2
2
  import type { PluginName as ChoosePluginName, SubscribeEvents as ChooseSubscribeEvents } from "@vnejs/contracts.scenario.choose";
3
3
  import type {
4
+ Constants as QteConstants,
4
5
  Params as QteParams,
5
6
  PluginName as QtePluginName,
6
7
  SubscribeEvents as QteSubscribeEvents,
@@ -10,7 +11,7 @@ export type PluginEvents = ModuleCoreEvents &
10
11
  Record<ChoosePluginName, ChooseSubscribeEvents> &
11
12
  Record<QtePluginName, QteSubscribeEvents>;
12
13
 
13
- export type PluginConstants = ModuleCoreConstants;
14
+ export type PluginConstants = ModuleCoreConstants & Record<QtePluginName, QteConstants>;
14
15
 
15
16
  export type PluginSettings = ModuleCoreSettings;
16
17