@vnejs/shared 0.0.14 → 0.0.16
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.js +5 -4
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
- package/src/index.ts +7 -5
- package/src/types.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -5,12 +5,13 @@ export const regModule = (Module) => {
|
|
|
5
5
|
VNE_MODULES.push(Module);
|
|
6
6
|
return Module;
|
|
7
7
|
};
|
|
8
|
+
const cloneRegistryEntry = (value) => ({ ...value });
|
|
8
9
|
export const regPlugin = (namespace = "", { constants = {}, events = {}, settings = {}, params = {} } = {}, modules = []) => {
|
|
9
10
|
if (!namespace)
|
|
10
11
|
return;
|
|
11
|
-
VNE.EVENTS[namespace] = events;
|
|
12
|
-
VNE.PARAMS[namespace] = params;
|
|
13
|
-
VNE.CONST[namespace] = constants;
|
|
14
|
-
VNE.SETTINGS[namespace] = settings;
|
|
12
|
+
VNE.EVENTS[namespace] = cloneRegistryEntry(events);
|
|
13
|
+
VNE.PARAMS[namespace] = cloneRegistryEntry(params);
|
|
14
|
+
VNE.CONST[namespace] = cloneRegistryEntry(constants);
|
|
15
|
+
VNE.SETTINGS[namespace] = cloneRegistryEntry(settings);
|
|
15
16
|
modules.forEach(regModule);
|
|
16
17
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -42,10 +42,10 @@ export interface VnePluginSettings {
|
|
|
42
42
|
}
|
|
43
43
|
export interface VnePluginParams {
|
|
44
44
|
}
|
|
45
|
-
export type VnePluginConstantsRegistry = VnePluginConstants & Partial<Record<string,
|
|
45
|
+
export type VnePluginConstantsRegistry = VnePluginConstants & Partial<Record<string, unknown>>;
|
|
46
46
|
export type VnePluginEventsRegistry = VnePluginEvents & Partial<Record<string, string>>;
|
|
47
47
|
export type VnePluginSettingsRegistry = VnePluginSettings & Partial<Record<string, string>>;
|
|
48
|
-
export type VnePluginParamsRegistry = VnePluginParams & Partial<Record<string,
|
|
48
|
+
export type VnePluginParamsRegistry = VnePluginParams & Partial<Record<string, unknown>>;
|
|
49
49
|
export type VneNamespace = keyof VnePluginConstantsMap | keyof VnePluginEventsMap | keyof VnePluginSettingsMap | keyof VnePluginParamsMap | (string & {});
|
|
50
50
|
export type VneRegistry = {
|
|
51
51
|
CONST: VnePluginConstantsMapRegistry;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -28,11 +28,13 @@ export const VNE_MODULES: VneModuleClass[] = [];
|
|
|
28
28
|
|
|
29
29
|
export const VNE: VneRegistry = { CONST: {}, EVENTS: {}, SETTINGS: {}, PARAMS: {} } as VneRegistry;
|
|
30
30
|
|
|
31
|
-
export const regModule = (Module: VneModuleClass) => {
|
|
31
|
+
export const regModule = (Module: VneModuleClass): VneModuleClass => {
|
|
32
32
|
if (Module) VNE_MODULES.push(Module);
|
|
33
33
|
return Module;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
const cloneRegistryEntry = <T extends object>(value: T): T => ({ ...value } as T);
|
|
37
|
+
|
|
36
38
|
export const regPlugin = (
|
|
37
39
|
namespace: VneNamespace = "",
|
|
38
40
|
{ constants = {}, events = {}, settings = {}, params = {} }: VnePluginShape = {},
|
|
@@ -40,10 +42,10 @@ export const regPlugin = (
|
|
|
40
42
|
) => {
|
|
41
43
|
if (!namespace) return;
|
|
42
44
|
|
|
43
|
-
VNE.EVENTS[namespace] = events;
|
|
44
|
-
VNE.PARAMS[namespace] = params;
|
|
45
|
-
VNE.CONST[namespace] = constants;
|
|
46
|
-
VNE.SETTINGS[namespace] = settings;
|
|
45
|
+
VNE.EVENTS[namespace] = cloneRegistryEntry(events);
|
|
46
|
+
VNE.PARAMS[namespace] = cloneRegistryEntry(params);
|
|
47
|
+
VNE.CONST[namespace] = cloneRegistryEntry(constants);
|
|
48
|
+
VNE.SETTINGS[namespace] = cloneRegistryEntry(settings);
|
|
47
49
|
|
|
48
50
|
modules.forEach(regModule);
|
|
49
51
|
};
|
package/src/types.ts
CHANGED
|
@@ -42,10 +42,10 @@ export interface VnePluginEvents {}
|
|
|
42
42
|
export interface VnePluginSettings {}
|
|
43
43
|
export interface VnePluginParams {}
|
|
44
44
|
|
|
45
|
-
export type VnePluginConstantsRegistry = VnePluginConstants & Partial<Record<string,
|
|
45
|
+
export type VnePluginConstantsRegistry = VnePluginConstants & Partial<Record<string, unknown>>;
|
|
46
46
|
export type VnePluginEventsRegistry = VnePluginEvents & Partial<Record<string, string>>;
|
|
47
47
|
export type VnePluginSettingsRegistry = VnePluginSettings & Partial<Record<string, string>>;
|
|
48
|
-
export type VnePluginParamsRegistry = VnePluginParams & Partial<Record<string,
|
|
48
|
+
export type VnePluginParamsRegistry = VnePluginParams & Partial<Record<string, unknown>>;
|
|
49
49
|
|
|
50
50
|
export type VneNamespace =
|
|
51
51
|
| keyof VnePluginConstantsMap
|