@vnejs/plugins.views.achievement 0.1.20 → 0.2.1
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/modules/achievement.d.ts +2 -1
- package/dist/modules/achievement.js +5 -0
- package/dist/modules/exec.d.ts +1 -0
- package/dist/modules/exec.js +3 -0
- package/dist/modules/logs.d.ts +2 -1
- package/dist/modules/logs.js +2 -0
- package/dist/utils/achievement.d.ts +7 -0
- package/package.json +19 -19
- package/src/modules/achievement.ts +7 -1
- package/src/modules/exec.ts +3 -0
- package/src/modules/logs.ts +5 -1
- package/src/utils/achievement.ts +9 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
|
|
3
|
-
import type { AchievementUnlockPayload } from "../utils/achievement.js";
|
|
3
|
+
import type { AchievementLockPayload, AchievementUnlockPayload } from "../utils/achievement.js";
|
|
4
4
|
export declare class Achievement extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
|
|
5
5
|
name: string;
|
|
6
6
|
subscribe: () => void;
|
|
7
7
|
onAchievementClear: () => Promise<unknown> | undefined;
|
|
8
|
+
onAchievementLock: ({ id }?: AchievementLockPayload) => Promise<void>;
|
|
8
9
|
onAchievementUnlock: ({ id, isSkipIfPossible }?: AchievementUnlockPayload) => Promise<unknown[] | undefined>;
|
|
9
10
|
}
|
|
@@ -4,9 +4,14 @@ export class Achievement extends ModuleCore {
|
|
|
4
4
|
name = "achievement";
|
|
5
5
|
subscribe = () => {
|
|
6
6
|
this.on(this.EVENTS.ACHIEVEMENT.CLEAR, this.onAchievementClear);
|
|
7
|
+
this.on(this.EVENTS.ACHIEVEMENT.LOCK, this.onAchievementLock);
|
|
7
8
|
this.on(this.EVENTS.ACHIEVEMENT.UNLOCK, this.onAchievementUnlock);
|
|
8
9
|
};
|
|
9
10
|
onAchievementClear = () => this.emitOne(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
|
|
11
|
+
onAchievementLock = async ({ id = "" } = {}) => {
|
|
12
|
+
this.emit(this.EVENTS.STORAGE.RM, { module: this.name, key: id });
|
|
13
|
+
this.emit(this.EVENTS.ACHIEVEMENT.LOCKED, { id });
|
|
14
|
+
};
|
|
10
15
|
onAchievementUnlock = async ({ id = "", isSkipIfPossible = false } = {}) => {
|
|
11
16
|
const storageValue = await this.emitOne(this.EVENTS.STORAGE.GET, { module: this.name, key: id });
|
|
12
17
|
this.emit(this.EVENTS.STORAGE.SET, { module: this.name, key: id, value: STORAGE_VALUE });
|
package/dist/modules/exec.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class AchievementExec extends ModuleCore<AchievementPluginEvents,
|
|
|
7
7
|
onLineExec: ({ keywords, line }?: LineExecHandlerArg) => Promise<void>;
|
|
8
8
|
onLineLoad: ({ line, priority }?: LineLoadHandlerArg) => Promise<unknown> | undefined;
|
|
9
9
|
emitActionExec: (action?: string, tokens?: string[], keywords?: string[]) => Promise<unknown> | undefined;
|
|
10
|
+
emitLockExec: (id?: string, isSkipIfPossible?: boolean) => Promise<unknown> | undefined;
|
|
10
11
|
emitUnlockExec: (id?: string, isSkipIfPossible?: boolean) => Promise<unknown> | undefined;
|
|
11
12
|
emitActionLoad: (action?: string, tokens?: string[], priority?: number) => Promise<unknown> | undefined;
|
|
12
13
|
emitUnlockLoad: (id?: string, priority?: number) => Promise<unknown> | undefined;
|
package/dist/modules/exec.js
CHANGED
|
@@ -17,9 +17,12 @@ export class AchievementExec extends ModuleCore {
|
|
|
17
17
|
};
|
|
18
18
|
emitActionExec = (action = "", tokens = [], keywords = []) => {
|
|
19
19
|
const isSkipIfPossible = keywords.includes(this.CONST.SCENARIO.LINE_KEYWORDS.SKIP_IF_POSSIBLE);
|
|
20
|
+
if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.LOCK)
|
|
21
|
+
return this.emitLockExec(tokens[0], isSkipIfPossible);
|
|
20
22
|
if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.UNLOCK)
|
|
21
23
|
return this.emitUnlockExec(tokens[0], isSkipIfPossible);
|
|
22
24
|
};
|
|
25
|
+
emitLockExec = (id = "", isSkipIfPossible = false) => this.emitOne(this.EVENTS.ACHIEVEMENT.LOCK, { id, isSkipIfPossible });
|
|
23
26
|
emitUnlockExec = (id = "", isSkipIfPossible = false) => this.emitOne(this.EVENTS.ACHIEVEMENT.UNLOCK, { id, isSkipIfPossible });
|
|
24
27
|
emitActionLoad = (action = "", tokens = [], priority) => {
|
|
25
28
|
if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.UNLOCK)
|
package/dist/modules/logs.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
|
|
3
|
-
import type { AchievementUnlockedPayload } from "../utils/achievement.js";
|
|
3
|
+
import type { AchievementLockedPayload, AchievementUnlockedPayload } from "../utils/achievement.js";
|
|
4
4
|
export declare class AchievementLogs extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
|
|
5
5
|
name: string;
|
|
6
6
|
subscribe: () => void;
|
|
7
|
+
onAchievementLocked: ({ id }?: AchievementLockedPayload) => undefined;
|
|
7
8
|
onAchievementUnlocked: ({ id }?: AchievementUnlockedPayload) => undefined;
|
|
8
9
|
}
|
package/dist/modules/logs.js
CHANGED
|
@@ -2,7 +2,9 @@ import { ModuleCore } from "@vnejs/module.core";
|
|
|
2
2
|
export class AchievementLogs extends ModuleCore {
|
|
3
3
|
name = "achievement.logs";
|
|
4
4
|
subscribe = () => {
|
|
5
|
+
this.on(this.EVENTS.ACHIEVEMENT.LOCKED, this.onAchievementLocked, this.CONST.LOGS.FILTER_FROM_RESULT_OPTIONS);
|
|
5
6
|
this.on(this.EVENTS.ACHIEVEMENT.UNLOCKED, this.onAchievementUnlocked, this.CONST.LOGS.FILTER_FROM_RESULT_OPTIONS);
|
|
6
7
|
};
|
|
8
|
+
onAchievementLocked = ({ id = "" } = {}) => void this.emitLog({ action: this.CONST.ACHIEVEMENT.LOGS_ACTIONS.LOCKED, id });
|
|
7
9
|
onAchievementUnlocked = ({ id = "" } = {}) => void this.emitLog({ action: this.CONST.ACHIEVEMENT.LOGS_ACTIONS.UNLOCKED, id });
|
|
8
10
|
}
|
|
@@ -10,6 +10,10 @@ export type AchievementPluginState = {
|
|
|
10
10
|
array?: AchievementItem[];
|
|
11
11
|
locs?: Record<string, string>;
|
|
12
12
|
};
|
|
13
|
+
export type AchievementLockPayload = {
|
|
14
|
+
id?: string;
|
|
15
|
+
isSkipIfPossible?: boolean;
|
|
16
|
+
};
|
|
13
17
|
export type AchievementUnlockPayload = {
|
|
14
18
|
id?: string;
|
|
15
19
|
isSkipIfPossible?: boolean;
|
|
@@ -21,6 +25,9 @@ export type AchievementLoadPayload = {
|
|
|
21
25
|
id?: string;
|
|
22
26
|
priority?: number;
|
|
23
27
|
};
|
|
28
|
+
export type AchievementLockedPayload = {
|
|
29
|
+
id?: string;
|
|
30
|
+
};
|
|
24
31
|
export type AchievementUnlockedPayload = {
|
|
25
32
|
id?: string;
|
|
26
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.views.achievement",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,27 +30,27 @@
|
|
|
30
30
|
"author": "",
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@vnejs/contracts.views.achievement": "~0.
|
|
33
|
+
"@vnejs/contracts.views.achievement": "~0.2.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@vnejs/helpers": "~0.
|
|
37
|
-
"@vnejs/module.core": "~0.
|
|
38
|
-
"@vnejs/module.components": "~0.
|
|
39
|
-
"@vnejs/shared": "~0.
|
|
40
|
-
"@vnejs/uis.react": "~0.
|
|
41
|
-
"@vnejs/uis.utils": "~0.
|
|
36
|
+
"@vnejs/helpers": "~0.2.0",
|
|
37
|
+
"@vnejs/module.core": "~0.2.0",
|
|
38
|
+
"@vnejs/module.components": "~0.2.0",
|
|
39
|
+
"@vnejs/shared": "~0.2.0",
|
|
40
|
+
"@vnejs/uis.react": "~0.2.0",
|
|
41
|
+
"@vnejs/uis.utils": "~0.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@vnejs/configs.ts-common": "~0.
|
|
45
|
-
"@vnejs/configs.vitest": "~0.
|
|
46
|
-
"@vnejs/test-utils": "~0.
|
|
47
|
-
"@vnejs/contracts.canvas.layer": "~0.
|
|
48
|
-
"@vnejs/contracts.views.achievement": "~0.
|
|
49
|
-
"@vnejs/helpers": "~0.
|
|
50
|
-
"@vnejs/module.core": "~0.
|
|
51
|
-
"@vnejs/module.components": "~0.
|
|
52
|
-
"@vnejs/shared": "~0.
|
|
53
|
-
"@vnejs/uis.react": "~0.
|
|
54
|
-
"@vnejs/uis.utils": "~0.
|
|
44
|
+
"@vnejs/configs.ts-common": "~0.2.0",
|
|
45
|
+
"@vnejs/configs.vitest": "~0.2.0",
|
|
46
|
+
"@vnejs/test-utils": "~0.2.0",
|
|
47
|
+
"@vnejs/contracts.canvas.layer": "~0.2.0",
|
|
48
|
+
"@vnejs/contracts.views.achievement": "~0.2.0",
|
|
49
|
+
"@vnejs/helpers": "~0.2.0",
|
|
50
|
+
"@vnejs/module.core": "~0.2.0",
|
|
51
|
+
"@vnejs/module.components": "~0.2.0",
|
|
52
|
+
"@vnejs/shared": "~0.2.0",
|
|
53
|
+
"@vnejs/uis.react": "~0.2.0",
|
|
54
|
+
"@vnejs/uis.utils": "~0.2.0"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -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 { AchievementUnlockPayload } from "../utils/achievement.js";
|
|
4
|
+
import type { AchievementLockPayload, AchievementUnlockPayload } from "../utils/achievement.js";
|
|
5
5
|
|
|
6
6
|
const STORAGE_VALUE = 1;
|
|
7
7
|
|
|
@@ -10,11 +10,17 @@ export class Achievement extends ModuleCore<AchievementPluginEvents, Achievement
|
|
|
10
10
|
|
|
11
11
|
subscribe = () => {
|
|
12
12
|
this.on(this.EVENTS.ACHIEVEMENT.CLEAR, this.onAchievementClear);
|
|
13
|
+
this.on(this.EVENTS.ACHIEVEMENT.LOCK, this.onAchievementLock);
|
|
13
14
|
this.on(this.EVENTS.ACHIEVEMENT.UNLOCK, this.onAchievementUnlock);
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
onAchievementClear = () => this.emitOne(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
|
|
17
18
|
|
|
19
|
+
onAchievementLock = async ({ id = "" }: AchievementLockPayload = {}) => {
|
|
20
|
+
this.emit(this.EVENTS.STORAGE.RM, { module: this.name, key: id });
|
|
21
|
+
this.emit(this.EVENTS.ACHIEVEMENT.LOCKED, { id });
|
|
22
|
+
};
|
|
23
|
+
|
|
18
24
|
onAchievementUnlock = async ({ id = "", isSkipIfPossible = false }: AchievementUnlockPayload = {}) => {
|
|
19
25
|
const storageValue = await this.emitOne(this.EVENTS.STORAGE.GET, { module: this.name, key: id });
|
|
20
26
|
|
package/src/modules/exec.ts
CHANGED
|
@@ -31,9 +31,12 @@ export class AchievementExec extends ModuleCore<AchievementPluginEvents, Achieve
|
|
|
31
31
|
emitActionExec = (action = "", tokens: string[] = [], keywords: string[] = []) => {
|
|
32
32
|
const isSkipIfPossible = keywords.includes(this.CONST.SCENARIO.LINE_KEYWORDS.SKIP_IF_POSSIBLE);
|
|
33
33
|
|
|
34
|
+
if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.LOCK) return this.emitLockExec(tokens[0], isSkipIfPossible);
|
|
34
35
|
if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.UNLOCK) return this.emitUnlockExec(tokens[0], isSkipIfPossible);
|
|
35
36
|
};
|
|
36
37
|
|
|
38
|
+
emitLockExec = (id = "", isSkipIfPossible = false) => this.emitOne(this.EVENTS.ACHIEVEMENT.LOCK, { id, isSkipIfPossible });
|
|
39
|
+
|
|
37
40
|
emitUnlockExec = (id = "", isSkipIfPossible = false) => this.emitOne(this.EVENTS.ACHIEVEMENT.UNLOCK, { id, isSkipIfPossible });
|
|
38
41
|
|
|
39
42
|
emitActionLoad = (action = "", tokens: string[] = [], priority?: number) => {
|
package/src/modules/logs.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { ModuleCore } from "@vnejs/module.core";
|
|
2
2
|
|
|
3
3
|
import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
|
|
4
|
-
import type { AchievementUnlockedPayload } from "../utils/achievement.js";
|
|
4
|
+
import type { AchievementLockedPayload, AchievementUnlockedPayload } from "../utils/achievement.js";
|
|
5
5
|
|
|
6
6
|
export class AchievementLogs extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
|
|
7
7
|
name = "achievement.logs";
|
|
8
8
|
|
|
9
9
|
subscribe = () => {
|
|
10
|
+
this.on(this.EVENTS.ACHIEVEMENT.LOCKED, this.onAchievementLocked, this.CONST.LOGS.FILTER_FROM_RESULT_OPTIONS);
|
|
10
11
|
this.on(this.EVENTS.ACHIEVEMENT.UNLOCKED, this.onAchievementUnlocked, this.CONST.LOGS.FILTER_FROM_RESULT_OPTIONS);
|
|
11
12
|
};
|
|
12
13
|
|
|
14
|
+
onAchievementLocked = ({ id = "" }: AchievementLockedPayload = {}) =>
|
|
15
|
+
void this.emitLog({ action: this.CONST.ACHIEVEMENT.LOGS_ACTIONS.LOCKED, id });
|
|
16
|
+
|
|
13
17
|
onAchievementUnlocked = ({ id = "" }: AchievementUnlockedPayload = {}) =>
|
|
14
18
|
void this.emitLog({ action: this.CONST.ACHIEVEMENT.LOGS_ACTIONS.UNLOCKED, id });
|
|
15
19
|
}
|
package/src/utils/achievement.ts
CHANGED
|
@@ -12,6 +12,11 @@ export type AchievementPluginState = {
|
|
|
12
12
|
locs?: Record<string, string>;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
export type AchievementLockPayload = {
|
|
16
|
+
id?: string;
|
|
17
|
+
isSkipIfPossible?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
15
20
|
export type AchievementUnlockPayload = {
|
|
16
21
|
id?: string;
|
|
17
22
|
isSkipIfPossible?: boolean;
|
|
@@ -26,6 +31,10 @@ export type AchievementLoadPayload = {
|
|
|
26
31
|
priority?: number;
|
|
27
32
|
};
|
|
28
33
|
|
|
34
|
+
export type AchievementLockedPayload = {
|
|
35
|
+
id?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
29
38
|
export type AchievementUnlockedPayload = {
|
|
30
39
|
id?: string;
|
|
31
40
|
};
|