@vnejs/plugins.views.achievement 0.2.3 → 0.2.5

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.
@@ -1,10 +1,10 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
2
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
3
- import type { AchievementLockPayload, AchievementUnlockPayload } from "../utils/achievement.js";
3
+ import type { AchievementLockPayload, AchievementUnlockPayload } from "@vnejs/contracts.views.achievement";
4
4
  export declare class Achievement extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
5
5
  name: string;
6
6
  subscribe: () => void;
7
- onAchievementClear: () => Promise<unknown> | undefined;
7
+ onAchievementClear: () => Promise<void | undefined> | undefined;
8
8
  onAchievementLock: ({ id }?: AchievementLockPayload) => Promise<void>;
9
- onAchievementUnlock: ({ id, isSkipIfPossible }?: AchievementUnlockPayload) => Promise<unknown[] | undefined>;
9
+ onAchievementUnlock: ({ id, isSkipIfPossible }?: AchievementUnlockPayload) => Promise<import("@vnejs/shared").EmitResults<"vne:achievement:append"> | undefined>;
10
10
  }
@@ -1,6 +1,7 @@
1
1
  import { ModuleController } from "@vnejs/module.components";
2
2
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
3
- import type { AchievementAppendPayload, AchievementPluginState, AchievementLoadPayload } from "../utils/achievement.js";
3
+ import type { AchievementPluginState } from "../types.js";
4
+ import type { AchievementAppendPayload, AchievementLoadPayload } from "@vnejs/contracts.views.achievement";
4
5
  export declare class AchievementController extends ModuleController<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams, AchievementPluginState> {
5
6
  name: string;
6
7
  EVENT_UPDATE_VIEW: "vne:achievement:update";
@@ -3,12 +3,12 @@ import type { LineExecHandlerArg, LineLoadHandlerArg } from "@vnejs/module.core"
3
3
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
4
4
  export declare class AchievementExec extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
5
5
  name: string;
6
- init: () => Promise<[unknown[] | undefined, unknown[] | undefined]>;
6
+ init: () => Promise<[import("@vnejs/shared").EmitResults<"vne:scenario:line_exec_reg"> | undefined, import("@vnejs/shared").EmitResults<"vne:scenario:line_load_reg"> | undefined]>;
7
7
  onLineExec: ({ keywords, line }?: LineExecHandlerArg) => Promise<void>;
8
- onLineLoad: ({ line, priority }?: LineLoadHandlerArg) => Promise<unknown> | undefined;
9
- emitActionExec: (action?: string, tokens?: string[], keywords?: string[]) => Promise<unknown> | undefined;
10
- emitLockExec: (id?: string, isSkipIfPossible?: boolean) => Promise<unknown> | undefined;
11
- emitUnlockExec: (id?: string, isSkipIfPossible?: boolean) => Promise<unknown> | undefined;
12
- emitActionLoad: (action?: string, tokens?: string[], priority?: number) => Promise<unknown> | undefined;
13
- emitUnlockLoad: (id?: string, priority?: number) => Promise<unknown> | undefined;
8
+ onLineLoad: ({ line, priority }?: LineLoadHandlerArg) => Promise<void | undefined> | undefined;
9
+ emitActionExec: (action?: string, tokens?: string[], keywords?: string[]) => Promise<void | undefined> | undefined;
10
+ emitLockExec: (id?: string, isSkipIfPossible?: boolean) => Promise<void | undefined> | undefined;
11
+ emitUnlockExec: (id?: string, isSkipIfPossible?: boolean) => Promise<void | undefined> | undefined;
12
+ emitActionLoad: (action?: string, tokens?: string[], priority?: number) => Promise<void | undefined> | undefined;
13
+ emitUnlockLoad: (id?: string, priority?: number) => Promise<void | undefined> | undefined;
14
14
  }
@@ -9,7 +9,7 @@ export class AchievementExec extends ModuleCore {
9
9
  onLineExec = async ({ keywords = [], line = "" } = {}) => {
10
10
  const [action = "", ...tokens] = tokenizeExecLine(line).map(String);
11
11
  await this.emitActionExec(action, tokens, keywords);
12
- this.emitNext();
12
+ this.emit(this.EVENTS.SCENARIO.NEXT);
13
13
  };
14
14
  onLineLoad = ({ line = "", priority = this.CONST.MEDIA.PRIORITIES.BACKGROUND } = {}) => {
15
15
  const [action = "", ...tokens] = tokenizeExecLine(line).map(String);
@@ -1,6 +1,6 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
2
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
3
- import type { AchievementLockedPayload, AchievementUnlockedPayload } from "../utils/achievement.js";
3
+ import type { AchievementLockedPayload, AchievementUnlockedPayload } from "@vnejs/contracts.views.achievement";
4
4
  export declare class AchievementLogs extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
5
5
  name: string;
6
6
  subscribe: () => void;
@@ -1,6 +1,6 @@
1
1
  import { ModuleView } from "@vnejs/module.components";
2
2
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
3
- import type { AchievementPluginState } from "../utils/achievement.js";
3
+ import type { AchievementPluginState } from "../types.js";
4
4
  export declare class AchievementView extends ModuleView<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams, AchievementPluginState> {
5
5
  name: string;
6
6
  EVENT_UPDATE_VIEW: "vne:achievement:update";
package/dist/types.d.ts CHANGED
@@ -3,7 +3,14 @@ import type { Constants as LogsConstants, PluginName as LogsPluginName, Subscrib
3
3
  import type { Constants as ScenarioConstants, PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/contracts.core.scenario";
4
4
  import type { PluginName as StoragePluginName, SubscribeEvents as StorageSubscribeEvents } from "@vnejs/contracts.core.storage";
5
5
  import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.views.achievement";
6
+ import type { AchievementItem } from "./utils/achievement.js";
6
7
  export type AchievementPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<StoragePluginName, StorageSubscribeEvents> & Record<ScenarioPluginName, ScenarioSubscribeEvents> & Record<LogsPluginName, LogsSubscribeEvents>;
7
8
  export type AchievementPluginConstants = ModuleComponentsConstants & Record<PluginName, Constants> & Record<ScenarioPluginName, ScenarioConstants> & Record<LogsPluginName, LogsConstants>;
8
9
  export type AchievementPluginSettings = ModuleComponentsSettings;
9
10
  export type AchievementPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
11
+ export type AchievementPluginState = {
12
+ isShow: boolean;
13
+ isForce: boolean;
14
+ array?: AchievementItem[];
15
+ locs?: Record<string, string>;
16
+ };
@@ -4,30 +4,3 @@ export type AchievementItem = {
4
4
  isNotShowed: boolean;
5
5
  icon?: string;
6
6
  };
7
- export type AchievementPluginState = {
8
- isShow: boolean;
9
- isForce: boolean;
10
- array?: AchievementItem[];
11
- locs?: Record<string, string>;
12
- };
13
- export type AchievementLockPayload = {
14
- id?: string;
15
- isSkipIfPossible?: boolean;
16
- };
17
- export type AchievementUnlockPayload = {
18
- id?: string;
19
- isSkipIfPossible?: boolean;
20
- };
21
- export type AchievementAppendPayload = {
22
- id?: string;
23
- };
24
- export type AchievementLoadPayload = {
25
- id?: string;
26
- priority?: number;
27
- };
28
- export type AchievementLockedPayload = {
29
- id?: string;
30
- };
31
- export type AchievementUnlockedPayload = {
32
- id?: string;
33
- };
@@ -1,3 +1,3 @@
1
1
  import type { ViewRenderFunc } from "@vnejs/module.components";
2
- import type { AchievementPluginState } from "../utils/achievement.js";
2
+ import type { AchievementPluginState } from "../types.js";
3
3
  export declare const render: ViewRenderFunc<AchievementPluginState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.views.achievement",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
2
 
3
3
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
4
- import type { AchievementLockPayload, AchievementUnlockPayload } from "../utils/achievement.js";
4
+ import type { AchievementLockPayload, AchievementUnlockPayload } from "@vnejs/contracts.views.achievement";
5
5
 
6
6
  const STORAGE_VALUE = 1;
7
7
 
@@ -1,7 +1,9 @@
1
1
  import { ModuleController } from "@vnejs/module.components";
2
2
 
3
3
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
4
- import type { AchievementAppendPayload, AchievementPluginState, AchievementItem, AchievementLoadPayload } from "../utils/achievement.js";
4
+ import type { AchievementPluginState } from "../types.js";
5
+ import type { AchievementItem } from "../utils/achievement.js";
6
+ import type { AchievementAppendPayload, AchievementLoadPayload } from "@vnejs/contracts.views.achievement";
5
7
 
6
8
  export class AchievementController extends ModuleController<
7
9
  AchievementPluginEvents,
@@ -19,7 +19,7 @@ export class AchievementExec extends ModuleCore<AchievementPluginEvents, Achieve
19
19
 
20
20
  await this.emitActionExec(action, tokens, keywords);
21
21
 
22
- this.emitNext();
22
+ this.emit(this.EVENTS.SCENARIO.NEXT);
23
23
  };
24
24
 
25
25
  onLineLoad = ({ line = "", priority = this.CONST.MEDIA.PRIORITIES.BACKGROUND }: LineLoadHandlerArg = {}) => {
@@ -1,7 +1,7 @@
1
1
  import { ModuleCore } from "@vnejs/module.core";
2
2
 
3
3
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
4
- import type { AchievementLockedPayload, AchievementUnlockedPayload } from "../utils/achievement.js";
4
+ import type { AchievementLockedPayload, AchievementUnlockedPayload } from "@vnejs/contracts.views.achievement";
5
5
 
6
6
  export class AchievementLogs extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
7
7
  name = "achievement.logs";
@@ -2,8 +2,7 @@ import { ModuleView } from "@vnejs/module.components";
2
2
 
3
3
  import { render } from "../view/index.js";
4
4
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
5
- import type { AchievementPluginState } from "../utils/achievement.js";
6
-
5
+ import type { AchievementPluginState } from "../types.js";
7
6
  export class AchievementView extends ModuleView<
8
7
  AchievementPluginEvents,
9
8
  AchievementPluginConstants,
@@ -42,7 +42,7 @@ describe("AchievementExec", () => {
42
42
  expect(load).toHaveBeenCalledOnce();
43
43
  });
44
44
 
45
- it("line exec calls emitNext", async () => {
45
+ it("line exec emits SCENARIO.NEXT", async () => {
46
46
  const { module, observer } = createAchievementTestModule(AchievementExec, { subscribe: false });
47
47
  const next = vi.fn();
48
48
 
package/src/types.ts CHANGED
@@ -8,6 +8,8 @@ import type {
8
8
  import type { PluginName as StoragePluginName, SubscribeEvents as StorageSubscribeEvents } from "@vnejs/contracts.core.storage";
9
9
  import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.views.achievement";
10
10
 
11
+ import type { AchievementItem } from "./utils/achievement.js";
12
+
11
13
  export type AchievementPluginEvents = ModuleComponentsEvents &
12
14
  Record<PluginName, SubscribeEvents> &
13
15
  Record<StoragePluginName, StorageSubscribeEvents> &
@@ -22,3 +24,10 @@ export type AchievementPluginConstants = ModuleComponentsConstants &
22
24
  export type AchievementPluginSettings = ModuleComponentsSettings;
23
25
 
24
26
  export type AchievementPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
27
+
28
+ export type AchievementPluginState = {
29
+ isShow: boolean;
30
+ isForce: boolean;
31
+ array?: AchievementItem[];
32
+ locs?: Record<string, string>;
33
+ };
@@ -4,37 +4,3 @@ export type AchievementItem = {
4
4
  isNotShowed: boolean;
5
5
  icon?: string;
6
6
  };
7
-
8
- export type AchievementPluginState = {
9
- isShow: boolean;
10
- isForce: boolean;
11
- array?: AchievementItem[];
12
- locs?: Record<string, string>;
13
- };
14
-
15
- export type AchievementLockPayload = {
16
- id?: string;
17
- isSkipIfPossible?: boolean;
18
- };
19
-
20
- export type AchievementUnlockPayload = {
21
- id?: string;
22
- isSkipIfPossible?: boolean;
23
- };
24
-
25
- export type AchievementAppendPayload = {
26
- id?: string;
27
- };
28
-
29
- export type AchievementLoadPayload = {
30
- id?: string;
31
- priority?: number;
32
- };
33
-
34
- export type AchievementLockedPayload = {
35
- id?: string;
36
- };
37
-
38
- export type AchievementUnlockedPayload = {
39
- id?: string;
40
- };
@@ -4,8 +4,8 @@ import { Flex, Icon, Text, View, Wrap, createRenderFunc, useMemo, useStoreState
4
4
  import { getVneLength } from "@vnejs/uis.utils";
5
5
 
6
6
  import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
7
- import type { AchievementPluginState, AchievementItem } from "../utils/achievement.js";
8
-
7
+ import type { AchievementPluginState } from "../types.js";
8
+ import type { AchievementItem } from "../utils/achievement.js";
9
9
  type AchievementComponentProps = ReactComponentProps<
10
10
  AchievementPluginEvents,
11
11
  AchievementPluginConstants,