@vnejs/shared 0.0.9 → 0.0.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/index.d.ts CHANGED
@@ -1,12 +1,28 @@
1
- declare interface CONST {}
2
- declare interface EVENTS {}
3
- declare interface PARAMS {}
4
- declare interface SETTINGS {}
5
- declare interface MODULE_EXTENSIONS {}
6
-
7
- export const VNE: {
8
- CONST: CONST;
9
- EVENTS: EVENTS;
10
- PARAMS: PARAMS;
11
- SETTINGS: SETTINGS;
1
+ export declare const VNE_MODULES: unknown[];
2
+ export type VneNamespace = string;
3
+ export interface VnePluginConstants {
4
+ [key: string]: unknown;
5
+ }
6
+ export interface VnePluginEvents {
7
+ [key: string]: unknown;
8
+ }
9
+ export interface VnePluginSettings {
10
+ [key: string]: unknown;
11
+ }
12
+ export interface VnePluginParams {
13
+ [key: string]: unknown;
14
+ }
15
+ export interface VnePluginShape {
16
+ constants?: VnePluginConstants;
17
+ events?: VnePluginEvents;
18
+ settings?: VnePluginSettings;
19
+ params?: VnePluginParams;
20
+ }
21
+ export declare const VNE: {
22
+ CONST: Record<VneNamespace, VnePluginConstants>;
23
+ EVENTS: Record<VneNamespace, VnePluginEvents>;
24
+ SETTINGS: Record<VneNamespace, VnePluginSettings>;
25
+ PARAMS: Record<VneNamespace, VnePluginParams>;
12
26
  };
27
+ export declare const regModule: (Module: unknown) => unknown;
28
+ export declare const regPlugin: (namespace?: VneNamespace, { constants, events, settings, params }?: VnePluginShape, modules?: unknown[]) => void;
package/index.js CHANGED
@@ -1,16 +1,12 @@
1
1
  export const VNE_MODULES = [];
2
-
3
2
  export const VNE = { CONST: {}, EVENTS: {}, SETTINGS: {}, PARAMS: {} };
4
-
5
3
  export const regModule = (Module) => Module && VNE_MODULES.push(Module);
6
-
7
4
  export const regPlugin = (namespace = "", { constants = {}, events = {}, settings = {}, params = {} } = {}, modules = []) => {
8
- if (!namespace) return;
9
-
10
- VNE.EVENTS[namespace] = events;
11
- VNE.PARAMS[namespace] = params;
12
- VNE.CONST[namespace] = constants;
13
- VNE.SETTINGS[namespace] = settings;
14
-
15
- modules.forEach(regModule);
5
+ if (!namespace)
6
+ return;
7
+ VNE.EVENTS[namespace] = events;
8
+ VNE.PARAMS[namespace] = params;
9
+ VNE.CONST[namespace] = constants;
10
+ VNE.SETTINGS[namespace] = settings;
11
+ modules.forEach(regModule);
16
12
  };
package/index.ts ADDED
@@ -0,0 +1,56 @@
1
+ export const VNE_MODULES: unknown[] = [];
2
+
3
+ export type VneNamespace = string;
4
+
5
+ // These interfaces are intentionally empty and meant to be extended
6
+ // by consumers via module augmentation:
7
+ // declare module "@vnejs/shared-ts" { interface VnePluginEvents { ... } }
8
+ export interface VnePluginConstants {
9
+ [key: string]: unknown;
10
+ }
11
+ export interface VnePluginEvents {
12
+ [key: string]: unknown;
13
+ }
14
+ export interface VnePluginSettings {
15
+ [key: string]: unknown;
16
+ }
17
+ export interface VnePluginParams {
18
+ [key: string]: unknown;
19
+ }
20
+
21
+ export interface VnePluginShape {
22
+ constants?: VnePluginConstants;
23
+ events?: VnePluginEvents;
24
+ settings?: VnePluginSettings;
25
+ params?: VnePluginParams;
26
+ }
27
+
28
+ export const VNE: {
29
+ CONST: Record<VneNamespace, VnePluginConstants>;
30
+ EVENTS: Record<VneNamespace, VnePluginEvents>;
31
+ SETTINGS: Record<VneNamespace, VnePluginSettings>;
32
+ PARAMS: Record<VneNamespace, VnePluginParams>;
33
+ } = { CONST: {}, EVENTS: {}, SETTINGS: {}, PARAMS: {} } as unknown as {
34
+ CONST: Record<VneNamespace, VnePluginConstants>;
35
+ EVENTS: Record<VneNamespace, VnePluginEvents>;
36
+ SETTINGS: Record<VneNamespace, VnePluginSettings>;
37
+ PARAMS: Record<VneNamespace, VnePluginParams>;
38
+ };
39
+
40
+ export const regModule = (Module: unknown) => Module && VNE_MODULES.push(Module);
41
+
42
+ export const regPlugin = (
43
+ namespace: VneNamespace = "",
44
+ { constants = {}, events = {}, settings = {}, params = {} }: VnePluginShape = {},
45
+ modules: unknown[] = []
46
+ ) => {
47
+ if (!namespace) return;
48
+
49
+ VNE.EVENTS[namespace] = events;
50
+ VNE.PARAMS[namespace] = params;
51
+ VNE.CONST[namespace] = constants;
52
+ VNE.SETTINGS[namespace] = settings;
53
+
54
+ modules.forEach(regModule);
55
+ };
56
+
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@vnejs/shared",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "main": "index.js",
5
+ "types": "index.d.ts",
5
6
  "scripts": {
6
7
  "test": "echo \"Error: no test specified\" && exit 1",
7
- "build": "tsc ./index.ts",
8
+ "build": "tsc -p tsconfig.json",
8
9
  "publish:major": "npm version major && npm publish --access public --legacy-peer-deps",
9
10
  "publish:minor": "npm version minor && npm publish --access public --legacy-peer-deps",
10
11
  "publish:patch": "npm version patch && npm publish --access public --legacy-peer-deps"
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ES2020",
5
+ "moduleResolution": "Bundler",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "declaration": true,
9
+ "noEmitOnError": true,
10
+ "esModuleInterop": true,
11
+ "forceConsistentCasingInFileNames": true
12
+ },
13
+ "include": ["index.ts"]
14
+ }
15
+