@vnejs/shared 0.0.15 → 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 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/shared",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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
  };