@vnejs/plugins.text.locs 0.1.8 → 0.1.10

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
@@ -1 +1 @@
1
- export {};
1
+ import "@vnejs/plugins.text.locs.contract";
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "@vnejs/plugins.text.locs.contract";
1
2
  import { regPlugin } from "@vnejs/shared";
2
3
  import { PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.text.locs.contract";
3
4
  import { TextLocs } from "./modules/locs.js";
@@ -1,6 +1,7 @@
1
1
  import { Module } from "@vnejs/module";
2
+ import type { SettingsChangedResult } from "@vnejs/plugins.core.settings.contract";
2
3
  import type { LocsPluginConstants, LocsPluginEvents, LocsPluginParams, LocsPluginSettings } from "../types.js";
3
- import type { ComponentsInjectResult, LocsComponent, LocsGetPayload, LocsLoadPayload, SettingsChangedPayload, TextReplaceHandlerPayload } from "../utils/locs.js";
4
+ import type { ComponentsInjectResult, LocsComponent, LocsGetPayload, LocsLoadPayload, TextReplaceHandlerPayload } from "../utils/locs.js";
4
5
  export declare class TextLocs extends Module<LocsPluginEvents, LocsPluginConstants, LocsPluginSettings, LocsPluginParams> {
5
6
  name: string;
6
7
  loading: Record<string, Promise<void> | undefined>;
@@ -11,7 +12,7 @@ export declare class TextLocs extends Module<LocsPluginEvents, LocsPluginConstan
11
12
  onLocsLoad: ({ label, lang }?: LocsLoadPayload) => Promise<void>;
12
13
  onLocsChanged: () => Promise<void>;
13
14
  onLocsGet: ({ label, lang }?: LocsGetPayload) => Promise<unknown>;
14
- onSettingChange: ({ name, value }?: SettingsChangedPayload) => false | Promise<unknown[]> | undefined;
15
+ onSettingChange: ({ name, value }: SettingsChangedResult) => false | Promise<unknown[]> | undefined;
15
16
  getLoadedLocs: (label?: string, lang?: string | null) => Promise<unknown> | undefined;
16
17
  loadLoc: (label?: string) => Promise<void>;
17
18
  setLang: (lang: string) => Promise<unknown[]> | undefined;
@@ -53,7 +53,7 @@ export class TextLocs extends Module {
53
53
  await this.emit(this.EVENTS.LOCS.LOAD, { label, lang });
54
54
  return this.getLoadedLocs(label, lang);
55
55
  };
56
- onSettingChange = ({ name, value } = {}) => name === this.SETTINGS.LOCS.LANG && this.setLang(value);
56
+ onSettingChange = ({ name, value }) => name === this.SETTINGS.LOCS.LANG && this.setLang(value);
57
57
  getLoadedLocs = (label, lang) => this.emitOne(this.EVENTS.MEMORY.GET, { module: this.name, key: `${lang || this.shared.lang}:${label}` });
58
58
  loadLoc = (label) => {
59
59
  const [loadingId, url] = [`${this.shared.lang}:${label}`, this.media.locs?.[`${this.shared.lang}/${label}`]];
@@ -14,10 +14,6 @@ export type ComponentsInjectResult = {
14
14
  field: string;
15
15
  value: LocsRecord;
16
16
  };
17
- export type SettingsChangedPayload = {
18
- name?: string;
19
- value?: unknown;
20
- };
21
17
  export type TextReplaceHandlerPayload = {
22
18
  text?: string;
23
19
  label?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.text.locs",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import "@vnejs/plugins.text.locs.contract";
2
+
1
3
  import { regPlugin } from "@vnejs/shared";
2
4
  import { PARAMS, PLUGIN_NAME, SETTINGS_KEYS, SUBSCRIBE_EVENTS } from "@vnejs/plugins.text.locs.contract";
3
5
 
@@ -1,5 +1,6 @@
1
1
  import { Module } from "@vnejs/module";
2
2
  import { toJson } from "@vnejs/helpers";
3
+ import type { SettingsChangedResult } from "@vnejs/plugins.core.settings.contract";
3
4
 
4
5
  import type { LocsPluginConstants, LocsPluginEvents, LocsPluginParams, LocsPluginSettings } from "../types.js";
5
6
  import type {
@@ -8,7 +9,6 @@ import type {
8
9
  LocsGetPayload,
9
10
  LocsLoadPayload,
10
11
  LocsRecord,
11
- SettingsChangedPayload,
12
12
  TextReplaceHandlerPayload,
13
13
  } from "../utils/locs.js";
14
14
 
@@ -84,7 +84,7 @@ export class TextLocs extends Module<LocsPluginEvents, LocsPluginConstants, Locs
84
84
  return this.getLoadedLocs(label, lang);
85
85
  };
86
86
 
87
- onSettingChange = ({ name, value }: SettingsChangedPayload = {}) => name === this.SETTINGS.LOCS.LANG && this.setLang(value as string);
87
+ onSettingChange = ({ name, value }: SettingsChangedResult) => name === this.SETTINGS.LOCS.LANG && this.setLang(value as string);
88
88
 
89
89
  getLoadedLocs = (label?: string, lang?: string | null) =>
90
90
  this.emitOne(this.EVENTS.MEMORY.GET, { module: this.name, key: `${lang || this.shared.lang}:${label}` });
package/src/utils/locs.ts CHANGED
@@ -19,11 +19,6 @@ export type ComponentsInjectResult = {
19
19
  value: LocsRecord;
20
20
  };
21
21
 
22
- export type SettingsChangedPayload = {
23
- name?: string;
24
- value?: unknown;
25
- };
26
-
27
22
  export type TextReplaceHandlerPayload = {
28
23
  text?: string;
29
24
  label?: string;