@vnejs/plugins.controllers.common.achievement 0.0.0-stage → 0.2.14

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.
@@ -0,0 +1 @@
1
+ import "@vnejs/contracts.controllers.common.achievement";
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import "@vnejs/contracts.controllers.common.achievement";
2
+ import { regPlugin } from "@vnejs/registry";
3
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.common.achievement";
4
+ import { Achievement } from "./modules/achievement.js";
5
+ import { AchievementController } from "./modules/controller.js";
6
+ import { AchievementExec } from "./modules/exec.js";
7
+ import { AchievementLogs } from "./modules/logs.js";
8
+ import { AchievementView } from "./modules/view.js";
9
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [
10
+ Achievement,
11
+ AchievementController,
12
+ AchievementExec,
13
+ AchievementLogs,
14
+ AchievementView,
15
+ ]);
@@ -0,0 +1,10 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { AchievementLockPayload, AchievementUnlockPayload } from "@vnejs/contracts.controllers.common.achievement";
3
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
4
+ export declare class Achievement extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
5
+ name: string;
6
+ subscribe: () => void;
7
+ onAchievementClear: () => Promise<void | undefined> | undefined;
8
+ onAchievementLock: ({ id }?: AchievementLockPayload) => Promise<void>;
9
+ onAchievementUnlock: ({ id, isSkipIfPossible }?: AchievementUnlockPayload) => Promise<import("@vnejs/registry").EmitResults<"vne:achievement:append"> | undefined>;
10
+ }
@@ -0,0 +1,22 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ const STORAGE_VALUE = 1;
3
+ export class Achievement extends ModuleCore {
4
+ name = "achievement";
5
+ subscribe = () => {
6
+ this.on(this.EVENTS.ACHIEVEMENT.CLEAR, this.onAchievementClear);
7
+ this.on(this.EVENTS.ACHIEVEMENT.LOCK, this.onAchievementLock);
8
+ this.on(this.EVENTS.ACHIEVEMENT.UNLOCK, this.onAchievementUnlock);
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
+ };
15
+ onAchievementUnlock = async ({ id = "", isSkipIfPossible = false } = {}) => {
16
+ const storageValue = await this.emitOne(this.EVENTS.STORAGE.GET, { module: this.name, key: id });
17
+ this.emit(this.EVENTS.STORAGE.SET, { module: this.name, key: id, value: STORAGE_VALUE });
18
+ this.emit(this.EVENTS.ACHIEVEMENT.UNLOCKED, { id });
19
+ if (!isSkipIfPossible || storageValue !== STORAGE_VALUE)
20
+ return this.emit(this.EVENTS.ACHIEVEMENT.APPEND, { id });
21
+ };
22
+ }
@@ -0,0 +1,18 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+ import type { AchievementAppendPayload, AchievementLoadPayload } from "@vnejs/contracts.controllers.common.achievement";
3
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
4
+ import type { AchievementPluginState } from "../types.js";
5
+ export declare class AchievementController extends ModuleController<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams, AchievementPluginState> {
6
+ name: string;
7
+ EVENT_UPDATE_VIEW: "vne:achievement:update";
8
+ EVENT_UPDATE_STATE: "vne:achievement:update_state";
9
+ EVENT_UPDATE_FAST: "vne:achievement:update_fast";
10
+ EVENT_UPDATE_FORCE: "vne:achievement:update_force";
11
+ EVENT_SHOW: "vne:achievement:show";
12
+ EVENT_HIDE: "vne:achievement:hide";
13
+ subscribe: () => void;
14
+ onLoad: ({ id }?: AchievementLoadPayload) => Promise<string> | undefined;
15
+ onAppend: ({ id }?: AchievementAppendPayload) => undefined;
16
+ append: (id?: string) => Promise<void>;
17
+ getIconSrc: (icon?: string) => Promise<string>;
18
+ }
@@ -0,0 +1,34 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+ export class AchievementController extends ModuleController {
3
+ name = "achievement.controller";
4
+ EVENT_UPDATE_VIEW = this.EVENTS.ACHIEVEMENT.UPDATE;
5
+ EVENT_UPDATE_STATE = this.EVENTS.ACHIEVEMENT.UPDATE_STATE;
6
+ EVENT_UPDATE_FAST = this.EVENTS.ACHIEVEMENT.UPDATE_FAST;
7
+ EVENT_UPDATE_FORCE = this.EVENTS.ACHIEVEMENT.UPDATE_FORCE;
8
+ EVENT_SHOW = this.EVENTS.ACHIEVEMENT.SHOW;
9
+ EVENT_HIDE = this.EVENTS.ACHIEVEMENT.HIDE;
10
+ subscribe = () => {
11
+ super.subscribe();
12
+ this.on(this.EVENTS.ACHIEVEMENT.LOAD, this.onLoad);
13
+ this.on(this.EVENTS.ACHIEVEMENT.APPEND, this.onAppend);
14
+ };
15
+ onLoad = ({ id = "" } = {}) => {
16
+ if (this.PARAMS.ACHIEVEMENT.INFO[id]?.icon)
17
+ return this.getIconSrc(this.PARAMS.ACHIEVEMENT.INFO[id].icon);
18
+ };
19
+ onAppend = ({ id = "" } = {}) => void this.append(id);
20
+ append = async (id = "") => {
21
+ const initialInfo = { id, isShow: false, isNotShowed: true };
22
+ const info = this.PARAMS.ACHIEVEMENT.INFO[id];
23
+ if (info?.icon)
24
+ initialInfo.icon = await this.getIconSrc(info.icon);
25
+ this.updateStateAndViewFast({ array: [...(this.state.array || []), initialInfo] });
26
+ await this.waitTimeout(this.PARAMS.ACHIEVEMENT.TRANSITION);
27
+ this.updateStateAndViewFast({ array: this.state.array?.map((i) => (i.id === id ? { ...i, isShow: true, isNotShowed: false } : i)) });
28
+ await this.waitTimeout(this.PARAMS.ACHIEVEMENT.SHOW_DURATION);
29
+ this.updateStateAndViewFast({ array: this.state.array?.map((i) => (i.id === id ? { ...i, isShow: false } : i)) });
30
+ await this.waitTimeout(this.PARAMS.ACHIEVEMENT.TRANSITION);
31
+ this.updateStateAndViewFast({ array: this.state.array?.filter((i) => i.id !== id) });
32
+ };
33
+ getIconSrc = async (icon = "") => (await this.loadImageMedia(`achievement/${icon}`, "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY])).src;
34
+ }
@@ -0,0 +1,14 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { LineExecHandlerArg, LineLoadHandlerArg } from "@vnejs/module.core";
3
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
4
+ export declare class AchievementExec extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
5
+ name: string;
6
+ init: () => Promise<[import("@vnejs/registry").EmitResults<"vne:scenario:line_exec_reg"> | undefined, import("@vnejs/registry").EmitResults<"vne:scenario:line_load_reg"> | undefined]>;
7
+ onLineExec: ({ keywords, line }?: LineExecHandlerArg) => Promise<void>;
8
+ onLineLoad: ({ line, priority }?: LineLoadHandlerArg) => Promise<void | undefined> | undefined;
9
+ emitLockExec: (id?: string, isSkipIfPossible?: boolean) => Promise<void | undefined> | undefined;
10
+ emitUnlockExec: (id?: string, isSkipIfPossible?: boolean) => Promise<void | undefined> | undefined;
11
+ emitUnlockLoad: (id?: string, priority?: number) => Promise<void | undefined> | undefined;
12
+ emitActionExec: (action?: string, tokens?: string[], keywords?: string[]) => Promise<void | undefined> | undefined;
13
+ emitActionLoad: (action?: string, tokens?: string[], priority?: number) => Promise<void | undefined> | undefined;
14
+ }
@@ -0,0 +1,32 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import { tokenizeExecLine } from "@vnejs/helpers";
3
+ export class AchievementExec extends ModuleCore {
4
+ name = "achievement.exec";
5
+ init = () => Promise.all([
6
+ this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: "achievement", handler: this.onLineExec }),
7
+ this.emit(this.EVENTS.SCENARIO.LINE_LOAD_REG, { module: "achievement", handler: this.onLineLoad }),
8
+ ]);
9
+ onLineExec = async ({ keywords = [], line = "" } = {}) => {
10
+ const [action = "", ...tokens] = tokenizeExecLine(line).map(String);
11
+ await this.emitActionExec(action, tokens, keywords);
12
+ this.emit(this.EVENTS.SCENARIO.NEXT);
13
+ };
14
+ onLineLoad = ({ line = "", priority = this.CONST.MEDIA.PRIORITIES.BACKGROUND } = {}) => {
15
+ const [action = "", ...tokens] = tokenizeExecLine(line).map(String);
16
+ return this.emitActionLoad(action, tokens, priority);
17
+ };
18
+ emitLockExec = (id = "", isSkipIfPossible = false) => this.emitOne(this.EVENTS.ACHIEVEMENT.LOCK, { id, isSkipIfPossible });
19
+ emitUnlockExec = (id = "", isSkipIfPossible = false) => this.emitOne(this.EVENTS.ACHIEVEMENT.UNLOCK, { id, isSkipIfPossible });
20
+ emitUnlockLoad = (id = "", priority) => this.emitOne(this.EVENTS.ACHIEVEMENT.LOAD, { id, priority });
21
+ emitActionExec = (action = "", tokens = [], keywords = []) => {
22
+ const isSkipIfPossible = keywords.includes(this.CONST.SCENARIO.LINE_KEYWORDS.SKIP_IF_POSSIBLE);
23
+ if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.LOCK)
24
+ return this.emitLockExec(tokens[0], isSkipIfPossible);
25
+ if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.UNLOCK)
26
+ return this.emitUnlockExec(tokens[0], isSkipIfPossible);
27
+ };
28
+ emitActionLoad = (action = "", tokens = [], priority) => {
29
+ if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.UNLOCK)
30
+ return this.emitUnlockLoad(tokens[0], priority);
31
+ };
32
+ }
@@ -0,0 +1,9 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ import type { AchievementLockedPayload, AchievementUnlockedPayload } from "@vnejs/contracts.controllers.common.achievement";
3
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
4
+ export declare class AchievementLogs extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
5
+ name: string;
6
+ subscribe: () => void;
7
+ onAchievementLocked: ({ id }?: AchievementLockedPayload) => undefined;
8
+ onAchievementUnlocked: ({ id }?: AchievementUnlockedPayload) => undefined;
9
+ }
@@ -0,0 +1,10 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+ export class AchievementLogs extends ModuleCore {
3
+ name = "achievement.logs";
4
+ subscribe = () => {
5
+ this.on(this.EVENTS.ACHIEVEMENT.LOCKED, this.onAchievementLocked, this.CONST.LOGS.FILTER_FROM_RESULT_OPTIONS);
6
+ this.on(this.EVENTS.ACHIEVEMENT.UNLOCKED, this.onAchievementUnlocked, this.CONST.LOGS.FILTER_FROM_RESULT_OPTIONS);
7
+ };
8
+ onAchievementLocked = ({ id = "" } = {}) => void this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.ACHIEVEMENT.LOGS_ACTIONS.LOCKED, id });
9
+ onAchievementUnlocked = ({ id = "" } = {}) => void this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.ACHIEVEMENT.LOGS_ACTIONS.UNLOCKED, id });
10
+ }
@@ -0,0 +1,10 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
3
+ import type { AchievementPluginState } from "../types.js";
4
+ export declare class AchievementView extends ModuleView<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams, AchievementPluginState> {
5
+ name: string;
6
+ EVENT_UPDATE_VIEW: "vne:achievement:update";
7
+ LOC_LABEL: string;
8
+ TRANSITION: number;
9
+ renderFunc: import("@vnejs/module.components").ViewRenderFunc<AchievementPluginState>;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+ import { render } from "../view/index.js";
3
+ export class AchievementView extends ModuleView {
4
+ name = "achievement.view";
5
+ EVENT_UPDATE_VIEW = this.EVENTS.ACHIEVEMENT.UPDATE;
6
+ LOC_LABEL = this.PARAMS.ACHIEVEMENT.LOC_LABEL;
7
+ TRANSITION = this.PARAMS.ACHIEVEMENT.TRANSITION;
8
+ renderFunc = render;
9
+ }
@@ -0,0 +1,16 @@
1
+ import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
+ import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.common.achievement";
3
+ import type { Constants as LogsConstants, PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/contracts.core.logs";
4
+ import type { Constants as ScenarioConstants, PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/contracts.core.scenario";
5
+ import type { PluginName as StoragePluginName, SubscribeEvents as StorageSubscribeEvents } from "@vnejs/contracts.core.storage";
6
+ import type { AchievementItem } from "./utils/achievement.js";
7
+ export type AchievementPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<StoragePluginName, StorageSubscribeEvents> & Record<ScenarioPluginName, ScenarioSubscribeEvents> & Record<LogsPluginName, LogsSubscribeEvents>;
8
+ export type AchievementPluginConstants = ModuleComponentsConstants & Record<PluginName, Constants> & Record<ScenarioPluginName, ScenarioConstants> & Record<LogsPluginName, LogsConstants>;
9
+ export type AchievementPluginSettings = ModuleComponentsSettings;
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
+ };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export type AchievementItem = {
2
+ id: string;
3
+ isShow: boolean;
4
+ isNotShowed: boolean;
5
+ icon?: string;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { ViewRenderFunc } from "@vnejs/module.components";
2
+ import type { AchievementPluginState } from "../types.js";
3
+ export declare const render: ViewRenderFunc<AchievementPluginState>;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Flex, Icon, Text, View, Wrap, createRenderFunc, useStoreState } from "@vnejs/uis.react";
3
+ import { getVneLength } from "@vnejs/uis.utils";
4
+ const renderOneView = ({ icon, id, isShow, isNotShowed, locs, PARAMS, isForce }, i) => {
5
+ const info = PARAMS.ACHIEVEMENT.INFO[id];
6
+ return (_jsx(View, { top: PARAMS.ACHIEVEMENT.TOP, left: PARAMS.ACHIEVEMENT.LEFT, translateY: getVneLength(PARAMS.ACHIEVEMENT.TOP_SHIFT * i), translateX: getVneLength(isNotShowed || !isShow ? 0 : PARAMS.ACHIEVEMENT.LEFT_SHIFT), isShow: isShow || isNotShowed, isForce: isForce, transition: PARAMS.ACHIEVEMENT.TRANSITION, zIndex: PARAMS.ACHIEVEMENT.ZINDEX, isHidden: isNotShowed, children: _jsx(Wrap, { ...PARAMS.ACHIEVEMENT.VIEW_PROPS.wrap, children: _jsxs(Flex, { ...PARAMS.ACHIEVEMENT.VIEW_PROPS.flex, children: [_jsx(Icon, { ...PARAMS.ACHIEVEMENT.VIEW_PROPS.icon, src: icon, isNotRender: !icon }), _jsxs(Flex, { ...PARAMS.ACHIEVEMENT.VIEW_PROPS.flexText, children: [_jsx(Text, { ...PARAMS.ACHIEVEMENT.VIEW_PROPS.title, text: locs[info?.title || ""] || info?.title }), _jsx(Text, { ...PARAMS.ACHIEVEMENT.VIEW_PROPS.description, text: locs[info?.description || ""] || info?.description })] })] }) }) }, id));
7
+ };
8
+ const Achievement = ({ store, onMount, PARAMS }) => {
9
+ const { locs = {}, array = [], isForce = false } = useStoreState(store, onMount);
10
+ return array.map((item, i) => renderOneView({ ...item, locs, isForce, PARAMS }, i));
11
+ };
12
+ export const render = createRenderFunc(Achievement);
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.controllers.common.achievement",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.14",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "tsconfig.json"
19
+ ],
20
+ "scripts": {
21
+ "test": "npx @vnejs/monorepo test",
22
+ "build": "npx @vnejs/monorepo package",
23
+ "publish:major:plugin": "npm run publish:major",
24
+ "publish:minor:plugin": "npm run publish:minor",
25
+ "publish:patch:plugin": "npm run publish:patch",
26
+ "publish:major": "npx @vnejs/monorepo publish major --access public",
27
+ "publish:minor": "npx @vnejs/monorepo publish minor --access public",
28
+ "publish:patch": "npx @vnejs/monorepo publish patch --access public"
29
+ },
30
+ "author": "",
31
+ "license": "ISC",
32
+ "dependencies": {
33
+ "@vnejs/contracts.controllers.common.achievement": "~0.2.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@vnejs/helpers": "~0.2.0",
37
+ "@vnejs/module.core": "~0.2.0",
38
+ "@vnejs/module.components": "~0.2.0",
39
+ "@vnejs/registry": "~0.2.0",
40
+ "@vnejs/uis.react": "~0.2.0",
41
+ "@vnejs/uis.utils": "~0.2.0"
42
+ },
43
+ "devDependencies": {
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.controllers.common.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/registry": "~0.2.0",
53
+ "@vnejs/uis.react": "~0.2.0",
54
+ "@vnejs/uis.utils": "~0.2.0"
55
+ }
56
+ }
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ import "@vnejs/contracts.controllers.common.achievement";
2
+
3
+ import { regPlugin } from "@vnejs/registry";
4
+
5
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.common.achievement";
6
+
7
+ import { Achievement } from "./modules/achievement.js";
8
+ import { AchievementController } from "./modules/controller.js";
9
+ import { AchievementExec } from "./modules/exec.js";
10
+ import { AchievementLogs } from "./modules/logs.js";
11
+ import { AchievementView } from "./modules/view.js";
12
+
13
+ regPlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS }, [
14
+ Achievement,
15
+ AchievementController,
16
+ AchievementExec,
17
+ AchievementLogs,
18
+ AchievementView,
19
+ ]);
@@ -0,0 +1,33 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+
3
+ import type { AchievementLockPayload, AchievementUnlockPayload } from "@vnejs/contracts.controllers.common.achievement";
4
+
5
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
6
+
7
+ const STORAGE_VALUE = 1;
8
+
9
+ export class Achievement extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
10
+ name = "achievement";
11
+
12
+ subscribe = () => {
13
+ this.on(this.EVENTS.ACHIEVEMENT.CLEAR, this.onAchievementClear);
14
+ this.on(this.EVENTS.ACHIEVEMENT.LOCK, this.onAchievementLock);
15
+ this.on(this.EVENTS.ACHIEVEMENT.UNLOCK, this.onAchievementUnlock);
16
+ };
17
+
18
+ onAchievementClear = () => this.emitOne(this.EVENTS.STORAGE.RM_ALL, { module: this.name });
19
+
20
+ onAchievementLock = async ({ id = "" }: AchievementLockPayload = {}) => {
21
+ this.emit(this.EVENTS.STORAGE.RM, { module: this.name, key: id });
22
+ this.emit(this.EVENTS.ACHIEVEMENT.LOCKED, { id });
23
+ };
24
+
25
+ onAchievementUnlock = async ({ id = "", isSkipIfPossible = false }: AchievementUnlockPayload = {}) => {
26
+ const storageValue = await this.emitOne(this.EVENTS.STORAGE.GET, { module: this.name, key: id });
27
+
28
+ this.emit(this.EVENTS.STORAGE.SET, { module: this.name, key: id, value: STORAGE_VALUE });
29
+ this.emit(this.EVENTS.ACHIEVEMENT.UNLOCKED, { id });
30
+
31
+ if (!isSkipIfPossible || storageValue !== STORAGE_VALUE) return this.emit(this.EVENTS.ACHIEVEMENT.APPEND, { id });
32
+ };
33
+ }
@@ -0,0 +1,54 @@
1
+ import { ModuleController } from "@vnejs/module.components";
2
+
3
+ import type { AchievementAppendPayload, AchievementLoadPayload } from "@vnejs/contracts.controllers.common.achievement";
4
+
5
+ import type { AchievementItem } from "../utils/achievement.js";
6
+
7
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
8
+ import type { AchievementPluginState } from "../types.js";
9
+
10
+ export class AchievementController extends ModuleController<
11
+ AchievementPluginEvents,
12
+ AchievementPluginConstants,
13
+ AchievementPluginSettings,
14
+ AchievementPluginParams,
15
+ AchievementPluginState
16
+ > {
17
+ name = "achievement.controller";
18
+
19
+ EVENT_UPDATE_VIEW = this.EVENTS.ACHIEVEMENT.UPDATE;
20
+ EVENT_UPDATE_STATE = this.EVENTS.ACHIEVEMENT.UPDATE_STATE;
21
+ EVENT_UPDATE_FAST = this.EVENTS.ACHIEVEMENT.UPDATE_FAST;
22
+ EVENT_UPDATE_FORCE = this.EVENTS.ACHIEVEMENT.UPDATE_FORCE;
23
+ EVENT_SHOW = this.EVENTS.ACHIEVEMENT.SHOW;
24
+ EVENT_HIDE = this.EVENTS.ACHIEVEMENT.HIDE;
25
+
26
+ subscribe = () => {
27
+ super.subscribe();
28
+ this.on(this.EVENTS.ACHIEVEMENT.LOAD, this.onLoad);
29
+ this.on(this.EVENTS.ACHIEVEMENT.APPEND, this.onAppend);
30
+ };
31
+
32
+ onLoad = ({ id = "" }: AchievementLoadPayload = {}) => {
33
+ if (this.PARAMS.ACHIEVEMENT.INFO[id as keyof typeof this.PARAMS.ACHIEVEMENT.INFO]?.icon)
34
+ return this.getIconSrc(this.PARAMS.ACHIEVEMENT.INFO[id as keyof typeof this.PARAMS.ACHIEVEMENT.INFO].icon!);
35
+ };
36
+
37
+ onAppend = ({ id = "" }: AchievementAppendPayload = {}) => void this.append(id);
38
+
39
+ append = async (id = "") => {
40
+ const initialInfo: AchievementItem = { id, isShow: false, isNotShowed: true };
41
+ const info = this.PARAMS.ACHIEVEMENT.INFO[id as keyof typeof this.PARAMS.ACHIEVEMENT.INFO];
42
+
43
+ if (info?.icon) initialInfo.icon = await this.getIconSrc(info.icon);
44
+
45
+ this.updateStateAndViewFast({ array: [...(this.state.array || []), initialInfo] });
46
+ await this.waitTimeout(this.PARAMS.ACHIEVEMENT.TRANSITION);
47
+ this.updateStateAndViewFast({ array: this.state.array?.map((i) => (i.id === id ? { ...i, isShow: true, isNotShowed: false } : i)) });
48
+ await this.waitTimeout(this.PARAMS.ACHIEVEMENT.SHOW_DURATION);
49
+ this.updateStateAndViewFast({ array: this.state.array?.map((i) => (i.id === id ? { ...i, isShow: false } : i)) });
50
+ await this.waitTimeout(this.PARAMS.ACHIEVEMENT.TRANSITION);
51
+ this.updateStateAndViewFast({ array: this.state.array?.filter((i) => i.id !== id) });
52
+ };
53
+ getIconSrc = async (icon = "") => (await this.loadImageMedia(`achievement/${icon}`, "icons", this.shared.settings[this.SETTINGS.LAYER.QUALITY])).src;
54
+ }
@@ -0,0 +1,45 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+
3
+ import type { LineExecHandlerArg, LineLoadHandlerArg } from "@vnejs/module.core";
4
+
5
+ import { tokenizeExecLine } from "@vnejs/helpers";
6
+
7
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
8
+
9
+ export class AchievementExec extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
10
+ name = "achievement.exec";
11
+
12
+ init = () =>
13
+ Promise.all([
14
+ this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: "achievement", handler: this.onLineExec }),
15
+ this.emit(this.EVENTS.SCENARIO.LINE_LOAD_REG, { module: "achievement", handler: this.onLineLoad }),
16
+ ]);
17
+
18
+ onLineExec = async ({ keywords = [], line = "" }: LineExecHandlerArg = {}) => {
19
+ const [action = "", ...tokens] = tokenizeExecLine(line).map(String);
20
+
21
+ await this.emitActionExec(action, tokens, keywords);
22
+
23
+ this.emit(this.EVENTS.SCENARIO.NEXT);
24
+ };
25
+
26
+ onLineLoad = ({ line = "", priority = this.CONST.MEDIA.PRIORITIES.BACKGROUND }: LineLoadHandlerArg = {}) => {
27
+ const [action = "", ...tokens] = tokenizeExecLine(line).map(String);
28
+
29
+ return this.emitActionLoad(action, tokens, priority);
30
+ };
31
+
32
+ emitLockExec = (id = "", isSkipIfPossible = false) => this.emitOne(this.EVENTS.ACHIEVEMENT.LOCK, { id, isSkipIfPossible });
33
+ emitUnlockExec = (id = "", isSkipIfPossible = false) => this.emitOne(this.EVENTS.ACHIEVEMENT.UNLOCK, { id, isSkipIfPossible });
34
+ emitUnlockLoad = (id = "", priority?: number) => this.emitOne(this.EVENTS.ACHIEVEMENT.LOAD, { id, priority });
35
+
36
+ emitActionExec = (action = "", tokens: string[] = [], keywords: string[] = []) => {
37
+ const isSkipIfPossible = keywords.includes(this.CONST.SCENARIO.LINE_KEYWORDS.SKIP_IF_POSSIBLE);
38
+
39
+ if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.LOCK) return this.emitLockExec(tokens[0], isSkipIfPossible);
40
+ if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.UNLOCK) return this.emitUnlockExec(tokens[0], isSkipIfPossible);
41
+ };
42
+ emitActionLoad = (action = "", tokens: string[] = [], priority?: number) => {
43
+ if (action === this.CONST.ACHIEVEMENT.EXEC_ACTIONS.UNLOCK) return this.emitUnlockLoad(tokens[0], priority);
44
+ };
45
+ }
@@ -0,0 +1,20 @@
1
+ import { ModuleCore } from "@vnejs/module.core";
2
+
3
+ import type { AchievementLockedPayload, AchievementUnlockedPayload } from "@vnejs/contracts.controllers.common.achievement";
4
+
5
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
6
+
7
+ export class AchievementLogs extends ModuleCore<AchievementPluginEvents, AchievementPluginConstants, AchievementPluginSettings, AchievementPluginParams> {
8
+ name = "achievement.logs";
9
+
10
+ subscribe = () => {
11
+ this.on(this.EVENTS.ACHIEVEMENT.LOCKED, this.onAchievementLocked, this.CONST.LOGS.FILTER_FROM_RESULT_OPTIONS);
12
+ this.on(this.EVENTS.ACHIEVEMENT.UNLOCKED, this.onAchievementUnlocked, this.CONST.LOGS.FILTER_FROM_RESULT_OPTIONS);
13
+ };
14
+
15
+ onAchievementLocked = ({ id = "" }: AchievementLockedPayload = {}) =>
16
+ void this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.ACHIEVEMENT.LOGS_ACTIONS.LOCKED, id });
17
+
18
+ onAchievementUnlocked = ({ id = "" }: AchievementUnlockedPayload = {}) =>
19
+ void this.emit(this.EVENTS.LOGS.EMIT, { action: this.CONST.ACHIEVEMENT.LOGS_ACTIONS.UNLOCKED, id });
20
+ }
@@ -0,0 +1,23 @@
1
+ import { ModuleView } from "@vnejs/module.components";
2
+
3
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
4
+ import type { AchievementPluginState } from "../types.js";
5
+
6
+ import { render } from "../view/index.js";
7
+ export class AchievementView extends ModuleView<
8
+ AchievementPluginEvents,
9
+ AchievementPluginConstants,
10
+ AchievementPluginSettings,
11
+ AchievementPluginParams,
12
+ AchievementPluginState
13
+ > {
14
+ name = "achievement.view";
15
+
16
+ EVENT_UPDATE_VIEW = this.EVENTS.ACHIEVEMENT.UPDATE;
17
+
18
+ LOC_LABEL = this.PARAMS.ACHIEVEMENT.LOC_LABEL;
19
+
20
+ TRANSITION = this.PARAMS.ACHIEVEMENT.TRANSITION;
21
+
22
+ renderFunc = render;
23
+ }
@@ -0,0 +1,46 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { Achievement } from "../modules/achievement.js";
6
+
7
+ import { createAchievementTestModule, registerAchievementPluginVne, STORAGE_EVENTS, SUBSCRIBE_EVENTS } from "./setup.js";
8
+
9
+ describe("Achievement", () => {
10
+ beforeEach(() => {
11
+ registerAchievementPluginVne();
12
+ });
13
+
14
+ it("UNLOCK stores value and emits UNLOCKED and APPEND for new achievement", async () => {
15
+ const { observer } = createAchievementTestModule(Achievement);
16
+ const unlocked = spyEvent(observer, SUBSCRIBE_EVENTS.UNLOCKED);
17
+ const append = spyEvent(observer, SUBSCRIBE_EVENTS.APPEND);
18
+ const storageSet = spyEvent(observer, STORAGE_EVENTS.SET);
19
+
20
+ await observer.emit(SUBSCRIBE_EVENTS.UNLOCK, { id: "kekw" });
21
+
22
+ expect(unlocked).toHaveBeenCalledExactlyOnceWith({ id: "kekw" });
23
+ expect(storageSet).toHaveBeenCalledOnce();
24
+ expect(append).toHaveBeenCalledExactlyOnceWith({ id: "kekw" });
25
+ });
26
+
27
+ it("UNLOCK skips APPEND when already unlocked and isSkipIfPossible", async () => {
28
+ const { observer, storage } = createAchievementTestModule(Achievement);
29
+ const append = spyEvent(observer, SUBSCRIBE_EVENTS.APPEND);
30
+
31
+ storage.set("kekw", 1);
32
+
33
+ await observer.emit(SUBSCRIBE_EVENTS.UNLOCK, { id: "kekw", isSkipIfPossible: true });
34
+
35
+ expect(append).not.toHaveBeenCalled();
36
+ });
37
+
38
+ it("CLEAR removes all storage for module", async () => {
39
+ const { observer } = createAchievementTestModule(Achievement);
40
+ const rmAll = spyEvent(observer, STORAGE_EVENTS.RM_ALL);
41
+
42
+ await observer.emit(SUBSCRIBE_EVENTS.CLEAR);
43
+
44
+ expect(rmAll).toHaveBeenCalledExactlyOnceWith({ module: "achievement" });
45
+ });
46
+ });
@@ -0,0 +1,57 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { CONSTANTS as SCENARIO_CONST } from "@vnejs/contracts.core.scenario";
6
+
7
+ import { AchievementExec } from "../modules/exec.js";
8
+
9
+ import { createAchievementTestModule, registerAchievementPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
10
+
11
+ describe("AchievementExec", () => {
12
+ beforeEach(() => {
13
+ registerAchievementPluginVne();
14
+ });
15
+
16
+ it("line exec unlock emits UNLOCK", async () => {
17
+ const { module, observer } = createAchievementTestModule(AchievementExec, { subscribe: false });
18
+ const unlock = spyEvent(observer, SUBSCRIBE_EVENTS.UNLOCK);
19
+
20
+ await (module as AchievementExec).init();
21
+ await (module as AchievementExec).onLineExec({ line: "unlock kekw", keywords: [] });
22
+
23
+ expect(unlock).toHaveBeenCalledExactlyOnceWith({ id: "kekw", isSkipIfPossible: false });
24
+ });
25
+
26
+ it("line exec with skip_if_possible keyword passes isSkipIfPossible", async () => {
27
+ const { module, observer } = createAchievementTestModule(AchievementExec, { subscribe: false });
28
+ const unlock = spyEvent(observer, SUBSCRIBE_EVENTS.UNLOCK);
29
+
30
+ await (module as AchievementExec).onLineExec({
31
+ line: "unlock kekw",
32
+ keywords: [SCENARIO_CONST.LINE_KEYWORDS.SKIP_IF_POSSIBLE],
33
+ });
34
+
35
+ expect(unlock).toHaveBeenCalledExactlyOnceWith({ id: "kekw", isSkipIfPossible: true });
36
+ });
37
+
38
+ it("line load unlock emits LOAD", async () => {
39
+ const { module, observer } = createAchievementTestModule(AchievementExec, { subscribe: false });
40
+ const load = spyEvent(observer, SUBSCRIBE_EVENTS.LOAD);
41
+
42
+ await (module as AchievementExec).onLineLoad({ line: "unlock kekw" });
43
+
44
+ expect(load).toHaveBeenCalledOnce();
45
+ });
46
+
47
+ it("line exec emits SCENARIO.NEXT", async () => {
48
+ const { module, observer } = createAchievementTestModule(AchievementExec, { subscribe: false });
49
+ const next = vi.fn();
50
+
51
+ observer.subscribe("vne:scenario:next", next);
52
+
53
+ await (module as AchievementExec).onLineExec({ line: "unlock kekw" });
54
+
55
+ expect(next).toHaveBeenCalledOnce();
56
+ });
57
+ });
@@ -0,0 +1,25 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { SUBSCRIBE_EVENTS as LOGS_EVENTS } from "@vnejs/contracts.core.logs";
6
+
7
+ import { AchievementLogs } from "../modules/logs.js";
8
+
9
+ import { createAchievementTestModule, registerAchievementPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
10
+
11
+ describe("AchievementLogs", () => {
12
+ beforeEach(() => {
13
+ registerAchievementPluginVne();
14
+ });
15
+
16
+ it("UNLOCKED emits log with unlocked action", async () => {
17
+ const { observer } = createAchievementTestModule(AchievementLogs);
18
+ const log = spyEvent(observer, LOGS_EVENTS.EMIT);
19
+
20
+ await observer.emit(SUBSCRIBE_EVENTS.UNLOCKED, { id: "kekw" });
21
+
22
+ expect(log).toHaveBeenCalledOnce();
23
+ expect(log.mock.calls[0][0]).toMatchObject({ action: "unlocked", id: "kekw" });
24
+ });
25
+ });
@@ -0,0 +1,47 @@
1
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin, stubEvent, stubSilentEvent } from "@vnejs/test-utils";
2
+
3
+ import { CONSTANTS as LAYER_CONST, PLUGIN_NAME as LAYER, SETTINGS_KEYS as LAYER_SETTINGS } from "@vnejs/contracts.canvas.layer";
4
+ import { CONSTANTS, PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.common.achievement";
5
+ import { SUBSCRIBE_EVENTS as MEDIA_EVENTS } from "@vnejs/contracts.core.media";
6
+ import { SUBSCRIBE_EVENTS as STORAGE_EVENTS } from "@vnejs/contracts.core.storage";
7
+
8
+ export const registerAchievementPluginVne = () => {
9
+ registerCoreVne();
10
+ registerVnePlugin(LAYER, { constants: LAYER_CONST, settings: LAYER_SETTINGS });
11
+ registerVnePlugin(PLUGIN_NAME, { constants: CONSTANTS, events: SUBSCRIBE_EVENTS, params: PARAMS });
12
+ };
13
+
14
+ export const createAchievementTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
15
+ ModuleClass: T,
16
+ options: Parameters<typeof baseCreateTestModule>[1] = {},
17
+ ) => {
18
+ const storage = new Map<string, unknown>();
19
+
20
+ const result = baseCreateTestModule(ModuleClass, {
21
+ state: {
22
+ "achievement.controller": { array: [], isShow: false },
23
+ ...(options.state ?? {}),
24
+ },
25
+ shared: {
26
+ settings: { [LAYER_SETTINGS.QUALITY]: LAYER_CONST.QUALITIES.FHD },
27
+ ...(options.shared ?? {}),
28
+ },
29
+ ...options,
30
+ });
31
+
32
+ stubEvent(result.observer, STORAGE_EVENTS.GET, ({ key }: { key?: string } = {}) => storage.get(key ?? ""));
33
+ stubSilentEvent(result.observer, STORAGE_EVENTS.SET, ({ key, value }: { key?: string; value?: unknown } = {}) => {
34
+ storage.set(key ?? "", value);
35
+ });
36
+ stubSilentEvent(result.observer, STORAGE_EVENTS.RM_ALL, () => storage.clear());
37
+ stubEvent(result.observer, MEDIA_EVENTS.LOAD, () => ({ src: "icon.png" }));
38
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UNLOCK);
39
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UNLOCKED);
40
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.APPEND);
41
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UPDATE);
42
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.LOAD);
43
+
44
+ return { ...result, storage };
45
+ };
46
+
47
+ export { SUBSCRIBE_EVENTS, PARAMS, PLUGIN_NAME, STORAGE_EVENTS };
package/src/types.ts ADDED
@@ -0,0 +1,34 @@
1
+ import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
2
+
3
+ import type { Constants, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.common.achievement";
4
+ import type { Constants as LogsConstants, PluginName as LogsPluginName, SubscribeEvents as LogsSubscribeEvents } from "@vnejs/contracts.core.logs";
5
+ import type {
6
+ Constants as ScenarioConstants,
7
+ PluginName as ScenarioPluginName,
8
+ SubscribeEvents as ScenarioSubscribeEvents,
9
+ } from "@vnejs/contracts.core.scenario";
10
+ import type { PluginName as StoragePluginName, SubscribeEvents as StorageSubscribeEvents } from "@vnejs/contracts.core.storage";
11
+
12
+ import type { AchievementItem } from "./utils/achievement.js";
13
+
14
+ export type AchievementPluginEvents = ModuleComponentsEvents &
15
+ Record<PluginName, SubscribeEvents> &
16
+ Record<StoragePluginName, StorageSubscribeEvents> &
17
+ Record<ScenarioPluginName, ScenarioSubscribeEvents> &
18
+ Record<LogsPluginName, LogsSubscribeEvents>;
19
+
20
+ export type AchievementPluginConstants = ModuleComponentsConstants &
21
+ Record<PluginName, Constants> &
22
+ Record<ScenarioPluginName, ScenarioConstants> &
23
+ Record<LogsPluginName, LogsConstants>;
24
+
25
+ export type AchievementPluginSettings = ModuleComponentsSettings;
26
+
27
+ export type AchievementPluginParams = ModuleComponentsParams & Record<PluginName, Params>;
28
+
29
+ export type AchievementPluginState = {
30
+ isShow: boolean;
31
+ isForce: boolean;
32
+ array?: AchievementItem[];
33
+ locs?: Record<string, string>;
34
+ };
@@ -0,0 +1,6 @@
1
+ export type AchievementItem = {
2
+ id: string;
3
+ isShow: boolean;
4
+ isNotShowed: boolean;
5
+ icon?: string;
6
+ };
@@ -0,0 +1,74 @@
1
+ import type { ViewRenderFunc } from "@vnejs/module.components";
2
+
3
+ import { Flex, Icon, Text, View, Wrap, createRenderFunc, useStoreState } from "@vnejs/uis.react";
4
+ import { getVneLength } from "@vnejs/uis.utils";
5
+
6
+ import type { ReactComponentProps } from "@vnejs/uis.react";
7
+
8
+ import type { AchievementItem } from "../utils/achievement.js";
9
+
10
+ import type { AchievementPluginConstants, AchievementPluginEvents, AchievementPluginParams, AchievementPluginSettings } from "../types.js";
11
+ import type { AchievementPluginState } from "../types.js";
12
+ type AchievementComponentProps = ReactComponentProps<
13
+ AchievementPluginEvents,
14
+ AchievementPluginConstants,
15
+ AchievementPluginSettings,
16
+ AchievementPluginParams,
17
+ AchievementPluginState
18
+ >;
19
+
20
+ type AchievementViewItem = AchievementItem & {
21
+ locs: Record<string, string>;
22
+ };
23
+
24
+ type AchievementViewItemProps = AchievementViewItem &
25
+ Pick<AchievementComponentProps, "PARAMS"> & {
26
+ isForce: boolean;
27
+ };
28
+
29
+ const renderOneView = ({ icon, id, isShow, isNotShowed, locs, PARAMS, isForce }: AchievementViewItemProps, i: number) => {
30
+ const info = PARAMS.ACHIEVEMENT.INFO[id as keyof typeof PARAMS.ACHIEVEMENT.INFO];
31
+
32
+ return (
33
+ <View
34
+ top={PARAMS.ACHIEVEMENT.TOP}
35
+ left={PARAMS.ACHIEVEMENT.LEFT}
36
+ translateY={getVneLength(PARAMS.ACHIEVEMENT.TOP_SHIFT * i)}
37
+ translateX={getVneLength(isNotShowed || !isShow ? 0 : PARAMS.ACHIEVEMENT.LEFT_SHIFT)}
38
+ isShow={isShow || isNotShowed}
39
+ isForce={isForce}
40
+ transition={PARAMS.ACHIEVEMENT.TRANSITION}
41
+ zIndex={PARAMS.ACHIEVEMENT.ZINDEX}
42
+ key={id}
43
+ isHidden={isNotShowed}
44
+ >
45
+ <Wrap {...PARAMS.ACHIEVEMENT.VIEW_PROPS.wrap}>
46
+ <Flex {...PARAMS.ACHIEVEMENT.VIEW_PROPS.flex}>
47
+ <Icon
48
+ {...PARAMS.ACHIEVEMENT.VIEW_PROPS.icon}
49
+ src={icon}
50
+ isNotRender={!icon}
51
+ />
52
+ <Flex {...PARAMS.ACHIEVEMENT.VIEW_PROPS.flexText}>
53
+ <Text
54
+ {...PARAMS.ACHIEVEMENT.VIEW_PROPS.title}
55
+ text={locs[info?.title || ""] || info?.title}
56
+ />
57
+ <Text
58
+ {...PARAMS.ACHIEVEMENT.VIEW_PROPS.description}
59
+ text={locs[info?.description || ""] || info?.description}
60
+ />
61
+ </Flex>
62
+ </Flex>
63
+ </Wrap>
64
+ </View>
65
+ );
66
+ };
67
+
68
+ const Achievement = ({ store, onMount, PARAMS }: AchievementComponentProps) => {
69
+ const { locs = {}, array = [], isForce = false } = useStoreState<AchievementPluginState>(store, onMount);
70
+
71
+ return array.map((item, i) => renderOneView({ ...item, locs, isForce, PARAMS }, i));
72
+ };
73
+
74
+ export const render: ViewRenderFunc<AchievementPluginState> = createRenderFunc(Achievement);
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@vnejs/configs.ts-common/tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "jsx": "react-jsx"
7
+ },
8
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
9
+ "exclude": ["dist", "node_modules", "src/tests"]
10
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.