@vnejs/plugins.text.locs 0.1.7 → 0.1.8
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 +1 -0
- package/dist/index.js +4 -0
- package/dist/modules/locs.d.ts +19 -0
- package/dist/modules/locs.js +73 -0
- package/dist/types.d.ts +12 -0
- package/dist/types.js +1 -0
- package/dist/utils/locs.d.ts +25 -0
- package/dist/utils/locs.js +1 -0
- package/package.json +38 -6
- package/src/index.ts +6 -0
- package/{modules/locs.js → src/modules/locs.ts} +36 -16
- package/src/types.ts +23 -0
- package/src/utils/locs.ts +32 -0
- package/tsconfig.json +9 -0
- package/const/events.js +0 -5
- package/const/params.js +0 -1
- package/const/settings.js +0 -1
- package/index.js +0 -9
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.text.locs.contract";
|
|
3
|
+
import { TextLocs } from "./modules/locs.js";
|
|
4
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params: PARAMS }, [TextLocs]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
import type { LocsPluginConstants, LocsPluginEvents, LocsPluginParams, LocsPluginSettings } from "../types.js";
|
|
3
|
+
import type { ComponentsInjectResult, LocsComponent, LocsGetPayload, LocsLoadPayload, SettingsChangedPayload, TextReplaceHandlerPayload } from "../utils/locs.js";
|
|
4
|
+
export declare class TextLocs extends Module<LocsPluginEvents, LocsPluginConstants, LocsPluginSettings, LocsPluginParams> {
|
|
5
|
+
name: string;
|
|
6
|
+
loading: Record<string, Promise<void> | undefined>;
|
|
7
|
+
subscribe: () => void;
|
|
8
|
+
init: () => Promise<unknown[] | undefined>;
|
|
9
|
+
componentsInjectHandler: (component: LocsComponent) => Promise<ComponentsInjectResult>;
|
|
10
|
+
textReplaceHandler: ({ text, label }?: TextReplaceHandlerPayload) => Promise<string>;
|
|
11
|
+
onLocsLoad: ({ label, lang }?: LocsLoadPayload) => Promise<void>;
|
|
12
|
+
onLocsChanged: () => Promise<void>;
|
|
13
|
+
onLocsGet: ({ label, lang }?: LocsGetPayload) => Promise<unknown>;
|
|
14
|
+
onSettingChange: ({ name, value }?: SettingsChangedPayload) => false | Promise<unknown[]> | undefined;
|
|
15
|
+
getLoadedLocs: (label?: string, lang?: string | null) => Promise<unknown> | undefined;
|
|
16
|
+
loadLoc: (label?: string) => Promise<void>;
|
|
17
|
+
setLang: (lang: string) => Promise<unknown[]> | undefined;
|
|
18
|
+
checkLang: () => boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
import { toJson } from "@vnejs/helpers";
|
|
3
|
+
export class TextLocs extends Module {
|
|
4
|
+
name = "text.locs";
|
|
5
|
+
loading = {};
|
|
6
|
+
subscribe = () => {
|
|
7
|
+
this.on(this.EVENTS.LOCS.LOAD, this.onLocsLoad);
|
|
8
|
+
this.on(this.EVENTS.LOCS.GET, this.onLocsGet);
|
|
9
|
+
this.on(this.EVENTS.LOCS.CHANGED, this.onLocsChanged);
|
|
10
|
+
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
|
|
11
|
+
};
|
|
12
|
+
init = async () => {
|
|
13
|
+
await Promise.all([
|
|
14
|
+
this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.LOCS.LANG, value: this.PARAMS.LOCS.DEFAULT_LANG }),
|
|
15
|
+
this.emit(this.EVENTS.MEMORY.REG, { module: this.name }),
|
|
16
|
+
this.emit(this.EVENTS.COMPONENTS.INJECT_REG, { handler: this.componentsInjectHandler }),
|
|
17
|
+
this.emit(this.EVENTS.TEXT.REPLACE_REG, { priority: -999999, handler: this.textReplaceHandler }),
|
|
18
|
+
]);
|
|
19
|
+
return this.setLang(this.shared.settings[this.SETTINGS.LOCS.LANG]);
|
|
20
|
+
};
|
|
21
|
+
componentsInjectHandler = async (component) => {
|
|
22
|
+
const result = { field: "locs", value: {} };
|
|
23
|
+
if (component.locLabel)
|
|
24
|
+
result.value = (await this.emitOne(this.EVENTS.LOCS.GET, { label: component.locLabel }));
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
textReplaceHandler = async ({ text = "", label = "" } = {}) => {
|
|
28
|
+
const locs = (await this.emitOne(this.EVENTS.LOCS.GET, { label }));
|
|
29
|
+
return locs?.[text] || text;
|
|
30
|
+
};
|
|
31
|
+
onLocsLoad = async ({ label, lang } = {}) => {
|
|
32
|
+
await this.waitRerenderCheck(this.checkLang);
|
|
33
|
+
const mediaId = `${lang || this.shared.lang}:${label}`;
|
|
34
|
+
const memoryLocs = await this.emitOne(this.EVENTS.MEMORY.GET, { module: this.name, key: mediaId });
|
|
35
|
+
if (memoryLocs)
|
|
36
|
+
return;
|
|
37
|
+
if (this.loading[mediaId])
|
|
38
|
+
return this.loading[mediaId];
|
|
39
|
+
return this.loadLoc(label);
|
|
40
|
+
};
|
|
41
|
+
onLocsChanged = async () => {
|
|
42
|
+
const { label } = this.globalState.scenario;
|
|
43
|
+
const loadedLocs = await this.getLoadedLocs(label);
|
|
44
|
+
if (!loadedLocs)
|
|
45
|
+
await this.emit(this.EVENTS.LOCS.LOAD, { label });
|
|
46
|
+
await this.emit(this.EVENTS.TEXT.RECALC);
|
|
47
|
+
};
|
|
48
|
+
onLocsGet = async ({ label = this.PARAMS.SCENARIO.INIT_LABEL_NAME, lang = null } = {}) => {
|
|
49
|
+
await this.waitRerenderCheck(this.checkLang);
|
|
50
|
+
const loadedLocs = await this.getLoadedLocs(label, lang);
|
|
51
|
+
if (loadedLocs)
|
|
52
|
+
return loadedLocs;
|
|
53
|
+
await this.emit(this.EVENTS.LOCS.LOAD, { label, lang });
|
|
54
|
+
return this.getLoadedLocs(label, lang);
|
|
55
|
+
};
|
|
56
|
+
onSettingChange = ({ name, value } = {}) => name === this.SETTINGS.LOCS.LANG && this.setLang(value);
|
|
57
|
+
getLoadedLocs = (label, lang) => this.emitOne(this.EVENTS.MEMORY.GET, { module: this.name, key: `${lang || this.shared.lang}:${label}` });
|
|
58
|
+
loadLoc = (label) => {
|
|
59
|
+
const [loadingId, url] = [`${this.shared.lang}:${label}`, this.media.locs?.[`${this.shared.lang}/${label}`]];
|
|
60
|
+
const promiseFunc = async () => {
|
|
61
|
+
const value = url ? (await fetch(`${this.CONST.SYSTEM.HOST}/${url}`).then(toJson)) : {};
|
|
62
|
+
await this.emit(this.EVENTS.MEMORY.SET, { module: this.name, key: loadingId, value });
|
|
63
|
+
delete this.loading[loadingId];
|
|
64
|
+
};
|
|
65
|
+
this.loading[loadingId] = promiseFunc();
|
|
66
|
+
return this.loading[loadingId];
|
|
67
|
+
};
|
|
68
|
+
setLang = (lang) => {
|
|
69
|
+
this.shared.lang = lang;
|
|
70
|
+
return this.emit(this.EVENTS.LOCS.CHANGED);
|
|
71
|
+
};
|
|
72
|
+
checkLang = () => Boolean(this.shared.lang);
|
|
73
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VnePluginConstantsMapRegistry, VnePluginEventsMapRegistry, VnePluginParamsMapRegistry, VnePluginSettingsMapRegistry } from "@vnejs/shared";
|
|
2
|
+
import type { PluginName as ComponentsPluginName, SubscribeEvents as ComponentsSubscribeEvents } from "@vnejs/plugins.core.components.contract";
|
|
3
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
|
|
4
|
+
import type { Params as ScenarioParams, PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/plugins.core.scenario.contract";
|
|
5
|
+
import type { PluginName as SettingsPluginName, SubscribeEvents as SettingsSubscribeEvents } from "@vnejs/plugins.core.settings.contract";
|
|
6
|
+
import type { Constants as SystemConstants, PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
|
|
7
|
+
import type { PluginName as TextPluginName, SubscribeEvents as TextSubscribeEvents } from "@vnejs/plugins.text.contract";
|
|
8
|
+
import type { Params, PluginName, SettingsKeys, SubscribeEvents } from "@vnejs/plugins.text.locs.contract";
|
|
9
|
+
export type LocsPluginEvents = VnePluginEventsMapRegistry & Record<PluginName, SubscribeEvents> & Record<ComponentsPluginName, ComponentsSubscribeEvents> & Record<MemoryPluginName, MemorySubscribeEvents> & Record<ScenarioPluginName, ScenarioSubscribeEvents> & Record<SettingsPluginName, SettingsSubscribeEvents> & Record<SystemPluginName, SystemSubscribeEvents> & Record<TextPluginName, TextSubscribeEvents>;
|
|
10
|
+
export type LocsPluginConstants = VnePluginConstantsMapRegistry & Record<SystemPluginName, SystemConstants>;
|
|
11
|
+
export type LocsPluginSettings = VnePluginSettingsMapRegistry & Record<PluginName, SettingsKeys>;
|
|
12
|
+
export type LocsPluginParams = VnePluginParamsMapRegistry & Record<PluginName, Params> & Record<ScenarioPluginName, ScenarioParams>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type LocsRecord = Record<string, string>;
|
|
2
|
+
export type LocsLoadPayload = {
|
|
3
|
+
label?: string;
|
|
4
|
+
lang?: string | null;
|
|
5
|
+
};
|
|
6
|
+
export type LocsGetPayload = {
|
|
7
|
+
label?: string;
|
|
8
|
+
lang?: string | null;
|
|
9
|
+
};
|
|
10
|
+
export type LocsComponent = {
|
|
11
|
+
locLabel?: string;
|
|
12
|
+
};
|
|
13
|
+
export type ComponentsInjectResult = {
|
|
14
|
+
field: string;
|
|
15
|
+
value: LocsRecord;
|
|
16
|
+
};
|
|
17
|
+
export type SettingsChangedPayload = {
|
|
18
|
+
name?: string;
|
|
19
|
+
value?: unknown;
|
|
20
|
+
};
|
|
21
|
+
export type TextReplaceHandlerPayload = {
|
|
22
|
+
text?: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
};
|
|
25
|
+
export type ComponentsInjectHandler = (component: LocsComponent) => ComponentsInjectResult | Promise<ComponentsInjectResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.text.locs",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.8",
|
|
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
|
+
],
|
|
5
20
|
"scripts": {
|
|
6
21
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
7
23
|
"publish:major:plugin": "npm run publish:major",
|
|
8
24
|
"publish:minor:plugin": "npm run publish:minor",
|
|
9
25
|
"publish:patch:plugin": "npm run publish:patch",
|
|
10
|
-
"publish:major": "
|
|
11
|
-
"publish:minor": "
|
|
12
|
-
"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"
|
|
13
29
|
},
|
|
14
30
|
"author": "",
|
|
15
31
|
"license": "ISC",
|
|
16
|
-
"
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@vnejs/plugins.text.locs.contract": "~0.0.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@vnejs/helpers": "~0.1.0",
|
|
37
|
+
"@vnejs/module": "~0.0.1",
|
|
38
|
+
"@vnejs/plugins.core.components.contract": "~0.0.1",
|
|
39
|
+
"@vnejs/plugins.core.memory.contract": "~0.0.1",
|
|
40
|
+
"@vnejs/plugins.core.scenario.contract": "~0.0.1",
|
|
41
|
+
"@vnejs/plugins.core.settings.contract": "~0.0.1",
|
|
42
|
+
"@vnejs/plugins.core.system.contract": "~0.0.1",
|
|
43
|
+
"@vnejs/plugins.text.contract": "~0.0.1",
|
|
44
|
+
"@vnejs/shared": "~0.0.9"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@vnejs/configs.ts-common": "~0.0.1"
|
|
48
|
+
}
|
|
17
49
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { regPlugin } from "@vnejs/shared";
|
|
2
|
+
import { PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.text.locs.contract";
|
|
3
|
+
|
|
4
|
+
import { TextLocs } from "./modules/locs.js";
|
|
5
|
+
|
|
6
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params: PARAMS }, [TextLocs]);
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { Module } from "@vnejs/module";
|
|
2
2
|
import { toJson } from "@vnejs/helpers";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import type { LocsPluginConstants, LocsPluginEvents, LocsPluginParams, LocsPluginSettings } from "../types.js";
|
|
5
|
+
import type {
|
|
6
|
+
ComponentsInjectResult,
|
|
7
|
+
LocsComponent,
|
|
8
|
+
LocsGetPayload,
|
|
9
|
+
LocsLoadPayload,
|
|
10
|
+
LocsRecord,
|
|
11
|
+
SettingsChangedPayload,
|
|
12
|
+
TextReplaceHandlerPayload,
|
|
13
|
+
} from "../utils/locs.js";
|
|
14
|
+
|
|
15
|
+
export class TextLocs extends Module<LocsPluginEvents, LocsPluginConstants, LocsPluginSettings, LocsPluginParams> {
|
|
5
16
|
name = "text.locs";
|
|
6
17
|
|
|
7
|
-
loading = {};
|
|
18
|
+
loading: Record<string, Promise<void> | undefined> = {};
|
|
8
19
|
|
|
9
20
|
subscribe = () => {
|
|
10
21
|
this.on(this.EVENTS.LOCS.LOAD, this.onLocsLoad);
|
|
@@ -24,20 +35,22 @@ export class TextLocs extends Module {
|
|
|
24
35
|
|
|
25
36
|
return this.setLang(this.shared.settings[this.SETTINGS.LOCS.LANG]);
|
|
26
37
|
};
|
|
27
|
-
componentsInjectHandler = async (component) => {
|
|
28
|
-
const result = { field: "locs", value: {} };
|
|
29
38
|
|
|
30
|
-
|
|
39
|
+
componentsInjectHandler = async (component: LocsComponent): Promise<ComponentsInjectResult> => {
|
|
40
|
+
const result: ComponentsInjectResult = { field: "locs", value: {} };
|
|
41
|
+
|
|
42
|
+
if (component.locLabel) result.value = (await this.emitOne(this.EVENTS.LOCS.GET, { label: component.locLabel })) as LocsRecord;
|
|
31
43
|
|
|
32
44
|
return result;
|
|
33
45
|
};
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
|
|
47
|
+
textReplaceHandler = async ({ text = "", label = "" }: TextReplaceHandlerPayload = {}) => {
|
|
48
|
+
const locs = (await this.emitOne(this.EVENTS.LOCS.GET, { label })) as LocsRecord | undefined;
|
|
36
49
|
|
|
37
50
|
return locs?.[text] || text;
|
|
38
51
|
};
|
|
39
52
|
|
|
40
|
-
onLocsLoad = async ({ label, lang } = {}) => {
|
|
53
|
+
onLocsLoad = async ({ label, lang }: LocsLoadPayload = {}) => {
|
|
41
54
|
await this.waitRerenderCheck(this.checkLang);
|
|
42
55
|
|
|
43
56
|
const mediaId = `${lang || this.shared.lang}:${label}`;
|
|
@@ -48,6 +61,7 @@ export class TextLocs extends Module {
|
|
|
48
61
|
|
|
49
62
|
return this.loadLoc(label);
|
|
50
63
|
};
|
|
64
|
+
|
|
51
65
|
onLocsChanged = async () => {
|
|
52
66
|
const { label } = this.globalState.scenario;
|
|
53
67
|
|
|
@@ -57,7 +71,8 @@ export class TextLocs extends Module {
|
|
|
57
71
|
|
|
58
72
|
await this.emit(this.EVENTS.TEXT.RECALC);
|
|
59
73
|
};
|
|
60
|
-
|
|
74
|
+
|
|
75
|
+
onLocsGet = async ({ label = this.PARAMS.SCENARIO.INIT_LABEL_NAME, lang = null }: LocsGetPayload = {}) => {
|
|
61
76
|
await this.waitRerenderCheck(this.checkLang);
|
|
62
77
|
|
|
63
78
|
const loadedLocs = await this.getLoadedLocs(label, lang);
|
|
@@ -68,14 +83,17 @@ export class TextLocs extends Module {
|
|
|
68
83
|
|
|
69
84
|
return this.getLoadedLocs(label, lang);
|
|
70
85
|
};
|
|
71
|
-
onSettingChange = ({ name, value } = {}) => name === this.SETTINGS.LOCS.LANG && this.setLang(value);
|
|
72
86
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
onSettingChange = ({ name, value }: SettingsChangedPayload = {}) => name === this.SETTINGS.LOCS.LANG && this.setLang(value as string);
|
|
88
|
+
|
|
89
|
+
getLoadedLocs = (label?: string, lang?: string | null) =>
|
|
90
|
+
this.emitOne(this.EVENTS.MEMORY.GET, { module: this.name, key: `${lang || this.shared.lang}:${label}` });
|
|
91
|
+
|
|
92
|
+
loadLoc = (label?: string) => {
|
|
93
|
+
const [loadingId, url] = [`${this.shared.lang}:${label}`, this.media.locs?.[`${this.shared.lang}/${label}`]];
|
|
76
94
|
|
|
77
95
|
const promiseFunc = async () => {
|
|
78
|
-
const value = url ? await fetch(`${this.CONST.SYSTEM.HOST}/${url}`).then(toJson) : {};
|
|
96
|
+
const value = url ? ((await fetch(`${this.CONST.SYSTEM.HOST}/${url}`).then(toJson)) as LocsRecord) : {};
|
|
79
97
|
|
|
80
98
|
await this.emit(this.EVENTS.MEMORY.SET, { module: this.name, key: loadingId, value });
|
|
81
99
|
|
|
@@ -86,10 +104,12 @@ export class TextLocs extends Module {
|
|
|
86
104
|
|
|
87
105
|
return this.loading[loadingId];
|
|
88
106
|
};
|
|
89
|
-
|
|
107
|
+
|
|
108
|
+
setLang = (lang: string) => {
|
|
90
109
|
this.shared.lang = lang;
|
|
91
110
|
|
|
92
111
|
return this.emit(this.EVENTS.LOCS.CHANGED);
|
|
93
112
|
};
|
|
94
|
-
|
|
113
|
+
|
|
114
|
+
checkLang = (): boolean => Boolean(this.shared.lang);
|
|
95
115
|
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { VnePluginConstantsMapRegistry, VnePluginEventsMapRegistry, VnePluginParamsMapRegistry, VnePluginSettingsMapRegistry } from "@vnejs/shared";
|
|
2
|
+
import type { PluginName as ComponentsPluginName, SubscribeEvents as ComponentsSubscribeEvents } from "@vnejs/plugins.core.components.contract";
|
|
3
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/plugins.core.memory.contract";
|
|
4
|
+
import type { Params as ScenarioParams, PluginName as ScenarioPluginName, SubscribeEvents as ScenarioSubscribeEvents } from "@vnejs/plugins.core.scenario.contract";
|
|
5
|
+
import type { PluginName as SettingsPluginName, SubscribeEvents as SettingsSubscribeEvents } from "@vnejs/plugins.core.settings.contract";
|
|
6
|
+
import type { Constants as SystemConstants, PluginName as SystemPluginName, SubscribeEvents as SystemSubscribeEvents } from "@vnejs/plugins.core.system.contract";
|
|
7
|
+
import type { PluginName as TextPluginName, SubscribeEvents as TextSubscribeEvents } from "@vnejs/plugins.text.contract";
|
|
8
|
+
import type { Params, PluginName, SettingsKeys, SubscribeEvents } from "@vnejs/plugins.text.locs.contract";
|
|
9
|
+
|
|
10
|
+
export type LocsPluginEvents = VnePluginEventsMapRegistry &
|
|
11
|
+
Record<PluginName, SubscribeEvents> &
|
|
12
|
+
Record<ComponentsPluginName, ComponentsSubscribeEvents> &
|
|
13
|
+
Record<MemoryPluginName, MemorySubscribeEvents> &
|
|
14
|
+
Record<ScenarioPluginName, ScenarioSubscribeEvents> &
|
|
15
|
+
Record<SettingsPluginName, SettingsSubscribeEvents> &
|
|
16
|
+
Record<SystemPluginName, SystemSubscribeEvents> &
|
|
17
|
+
Record<TextPluginName, TextSubscribeEvents>;
|
|
18
|
+
|
|
19
|
+
export type LocsPluginConstants = VnePluginConstantsMapRegistry & Record<SystemPluginName, SystemConstants>;
|
|
20
|
+
|
|
21
|
+
export type LocsPluginSettings = VnePluginSettingsMapRegistry & Record<PluginName, SettingsKeys>;
|
|
22
|
+
|
|
23
|
+
export type LocsPluginParams = VnePluginParamsMapRegistry & Record<PluginName, Params> & Record<ScenarioPluginName, ScenarioParams>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type LocsRecord = Record<string, string>;
|
|
2
|
+
|
|
3
|
+
export type LocsLoadPayload = {
|
|
4
|
+
label?: string;
|
|
5
|
+
lang?: string | null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type LocsGetPayload = {
|
|
9
|
+
label?: string;
|
|
10
|
+
lang?: string | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type LocsComponent = {
|
|
14
|
+
locLabel?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ComponentsInjectResult = {
|
|
18
|
+
field: string;
|
|
19
|
+
value: LocsRecord;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type SettingsChangedPayload = {
|
|
23
|
+
name?: string;
|
|
24
|
+
value?: unknown;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type TextReplaceHandlerPayload = {
|
|
28
|
+
text?: string;
|
|
29
|
+
label?: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type ComponentsInjectHandler = (component: LocsComponent) => ComponentsInjectResult | Promise<ComponentsInjectResult>;
|
package/tsconfig.json
ADDED
package/const/events.js
DELETED
package/const/params.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_LANG = "ru";
|
package/const/settings.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const SETTINGS_KEYS = { LANG: "vne:locs:lang" };
|
package/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { regPlugin } from "@vnejs/shared";
|
|
2
|
-
|
|
3
|
-
import { SUBSCRIBE_EVENTS } from "./const/events";
|
|
4
|
-
import * as params from "./const/params";
|
|
5
|
-
import { SETTINGS_KEYS } from "./const/settings";
|
|
6
|
-
|
|
7
|
-
import { TextLocs } from "./modules/locs";
|
|
8
|
-
|
|
9
|
-
regPlugin("LOCS", { events: SUBSCRIBE_EVENTS, settings: SETTINGS_KEYS, params }, [TextLocs]);
|