@vnejs/shared 0.0.11 → 0.0.13
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 +5 -5
- package/dist/index.js +5 -1
- package/dist/types.d.ts +33 -9
- package/package.json +9 -10
- package/src/index.ts +49 -0
- package/src/types.ts +76 -0
- package/tsconfig.json +17 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type { VneNamespace, VnePluginConstants, VnePluginConstantsMap, VnePluginEvents, VnePluginEventsMap, VnePluginParams, VnePluginParamsMap, VnePluginSettings, VnePluginSettingsMap, VnePluginShape, } from "./types.js";
|
|
2
|
-
import type { VneNamespace, VnePluginShape, VneRegistry } from "./types.js";
|
|
3
|
-
export declare const VNE_MODULES:
|
|
1
|
+
export type { VneModule, VneModuleClass, VneNamespace, VnePluginConstants, VnePluginConstantsMap, VnePluginConstantsMapRegistry, VnePluginConstantsRegistry, VnePluginEvents, VnePluginEventsMap, VnePluginEventsMapRegistry, VnePluginEventsRegistry, VnePluginParams, VnePluginParamsMap, VnePluginParamsMapRegistry, VnePluginParamsRegistry, VnePluginSettings, VnePluginSettingsMap, VnePluginSettingsMapRegistry, VnePluginSettingsRegistry, VnePluginShape, VneRegistry, } from "./types.js";
|
|
2
|
+
import type { VneModuleClass, VneNamespace, VnePluginShape, VneRegistry } from "./types.js";
|
|
3
|
+
export declare const VNE_MODULES: VneModuleClass[];
|
|
4
4
|
export declare const VNE: VneRegistry;
|
|
5
|
-
export declare const regModule: (Module:
|
|
6
|
-
export declare const regPlugin: (namespace?: VneNamespace, { constants, events, settings, params }?: VnePluginShape, modules?:
|
|
5
|
+
export declare const regModule: (Module: VneModuleClass) => VneModuleClass;
|
|
6
|
+
export declare const regPlugin: (namespace?: VneNamespace, { constants, events, settings, params }?: VnePluginShape, modules?: VneModuleClass[]) => void;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export const VNE_MODULES = [];
|
|
2
2
|
export const VNE = { CONST: {}, EVENTS: {}, SETTINGS: {}, PARAMS: {} };
|
|
3
|
-
export const regModule = (Module) =>
|
|
3
|
+
export const regModule = (Module) => {
|
|
4
|
+
if (Module)
|
|
5
|
+
VNE_MODULES.push(Module);
|
|
6
|
+
return Module;
|
|
7
|
+
};
|
|
4
8
|
export const regPlugin = (namespace = "", { constants = {}, events = {}, settings = {}, params = {} } = {}, modules = []) => {
|
|
5
9
|
if (!namespace)
|
|
6
10
|
return;
|
package/dist/types.d.ts
CHANGED
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
* interface VnePluginConstantsMap {
|
|
10
10
|
* SCENARIO: typeof constants;
|
|
11
11
|
* }
|
|
12
|
+
* interface VnePluginEvents {
|
|
13
|
+
* CUSTOM: string;
|
|
14
|
+
* }
|
|
12
15
|
* }
|
|
16
|
+
*
|
|
17
|
+
* // Namespace and event keys may be unset until regPlugin runs:
|
|
18
|
+
* VNE.EVENTS.STORAGE?.CLEAR
|
|
13
19
|
*/
|
|
14
20
|
export interface VnePluginConstantsMap {
|
|
15
21
|
}
|
|
@@ -19,7 +25,15 @@ export interface VnePluginSettingsMap {
|
|
|
19
25
|
}
|
|
20
26
|
export interface VnePluginParamsMap {
|
|
21
27
|
}
|
|
22
|
-
/**
|
|
28
|
+
/** Namespace and its fields may be missing until plugins register (use `?.` when needed). */
|
|
29
|
+
type OptionalPluginMapValues<T> = {
|
|
30
|
+
[K in keyof T]?: T[K] extends object ? Partial<T[K]> & T[K] : T[K];
|
|
31
|
+
};
|
|
32
|
+
export type VnePluginConstantsMapRegistry = OptionalPluginMapValues<VnePluginConstantsMap> & Partial<Record<string, VnePluginConstantsRegistry | undefined>>;
|
|
33
|
+
export type VnePluginEventsMapRegistry = OptionalPluginMapValues<VnePluginEventsMap> & Partial<Record<string, VnePluginEventsRegistry | undefined>>;
|
|
34
|
+
export type VnePluginSettingsMapRegistry = OptionalPluginMapValues<VnePluginSettingsMap> & Partial<Record<string, VnePluginSettingsRegistry | undefined>>;
|
|
35
|
+
export type VnePluginParamsMapRegistry = OptionalPluginMapValues<VnePluginParamsMap> & Partial<Record<string, VnePluginParamsRegistry | undefined>>;
|
|
36
|
+
/** Fallback shape for one plugin namespace not listed in *Map interfaces. */
|
|
23
37
|
export interface VnePluginConstants {
|
|
24
38
|
}
|
|
25
39
|
export interface VnePluginEvents {
|
|
@@ -28,16 +42,26 @@ export interface VnePluginSettings {
|
|
|
28
42
|
}
|
|
29
43
|
export interface VnePluginParams {
|
|
30
44
|
}
|
|
45
|
+
export type VnePluginConstantsRegistry = VnePluginConstants & Partial<Record<string, never>>;
|
|
46
|
+
export type VnePluginEventsRegistry = VnePluginEvents & Partial<Record<string, string>>;
|
|
47
|
+
export type VnePluginSettingsRegistry = VnePluginSettings & Partial<Record<string, string>>;
|
|
48
|
+
export type VnePluginParamsRegistry = VnePluginParams & Partial<Record<string, never>>;
|
|
31
49
|
export type VneNamespace = keyof VnePluginConstantsMap | keyof VnePluginEventsMap | keyof VnePluginSettingsMap | keyof VnePluginParamsMap | (string & {});
|
|
32
50
|
export type VneRegistry = {
|
|
33
|
-
CONST:
|
|
34
|
-
EVENTS:
|
|
35
|
-
SETTINGS:
|
|
36
|
-
PARAMS:
|
|
51
|
+
CONST: VnePluginConstantsMapRegistry;
|
|
52
|
+
EVENTS: VnePluginEventsMapRegistry;
|
|
53
|
+
SETTINGS: VnePluginSettingsMapRegistry;
|
|
54
|
+
PARAMS: VnePluginParamsMapRegistry;
|
|
37
55
|
};
|
|
38
56
|
export interface VnePluginShape {
|
|
39
|
-
constants?:
|
|
40
|
-
events?:
|
|
41
|
-
settings?:
|
|
42
|
-
params?:
|
|
57
|
+
constants?: VnePluginConstantsRegistry;
|
|
58
|
+
events?: VnePluginEventsRegistry;
|
|
59
|
+
settings?: VnePluginSettingsRegistry;
|
|
60
|
+
params?: VnePluginParamsRegistry;
|
|
61
|
+
}
|
|
62
|
+
export interface VneModule {
|
|
63
|
+
name: string;
|
|
64
|
+
isReady: boolean;
|
|
43
65
|
}
|
|
66
|
+
export type VneModuleClass = new () => VneModule;
|
|
67
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/shared",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"src",
|
|
10
|
+
"tsconfig.json"
|
|
9
11
|
],
|
|
10
12
|
"scripts": {
|
|
11
13
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
-
"build": "
|
|
13
|
-
"publish:major": "
|
|
14
|
-
"publish:minor": "
|
|
15
|
-
"publish:patch": "
|
|
14
|
+
"build": "npx @vnejs/monorepo package",
|
|
15
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
16
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
17
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
16
18
|
},
|
|
17
19
|
"author": "",
|
|
18
|
-
"license": "ISC"
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"typescript": "^6.0.3"
|
|
21
|
-
}
|
|
20
|
+
"license": "ISC"
|
|
22
21
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
VneModule,
|
|
3
|
+
VneModuleClass,
|
|
4
|
+
VneNamespace,
|
|
5
|
+
VnePluginConstants,
|
|
6
|
+
VnePluginConstantsMap,
|
|
7
|
+
VnePluginConstantsMapRegistry,
|
|
8
|
+
VnePluginConstantsRegistry,
|
|
9
|
+
VnePluginEvents,
|
|
10
|
+
VnePluginEventsMap,
|
|
11
|
+
VnePluginEventsMapRegistry,
|
|
12
|
+
VnePluginEventsRegistry,
|
|
13
|
+
VnePluginParams,
|
|
14
|
+
VnePluginParamsMap,
|
|
15
|
+
VnePluginParamsMapRegistry,
|
|
16
|
+
VnePluginParamsRegistry,
|
|
17
|
+
VnePluginSettings,
|
|
18
|
+
VnePluginSettingsMap,
|
|
19
|
+
VnePluginSettingsMapRegistry,
|
|
20
|
+
VnePluginSettingsRegistry,
|
|
21
|
+
VnePluginShape,
|
|
22
|
+
VneRegistry,
|
|
23
|
+
} from "./types.js";
|
|
24
|
+
|
|
25
|
+
import type { VneModuleClass, VneNamespace, VnePluginShape, VneRegistry } from "./types.js";
|
|
26
|
+
|
|
27
|
+
export const VNE_MODULES: VneModuleClass[] = [];
|
|
28
|
+
|
|
29
|
+
export const VNE: VneRegistry = { CONST: {}, EVENTS: {}, SETTINGS: {}, PARAMS: {} } as VneRegistry;
|
|
30
|
+
|
|
31
|
+
export const regModule = (Module: VneModuleClass) => {
|
|
32
|
+
if (Module) VNE_MODULES.push(Module);
|
|
33
|
+
return Module;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const regPlugin = (
|
|
37
|
+
namespace: VneNamespace = "",
|
|
38
|
+
{ constants = {}, events = {}, settings = {}, params = {} }: VnePluginShape = {},
|
|
39
|
+
modules: VneModuleClass[] = [],
|
|
40
|
+
) => {
|
|
41
|
+
if (!namespace) return;
|
|
42
|
+
|
|
43
|
+
VNE.EVENTS[namespace] = events;
|
|
44
|
+
VNE.PARAMS[namespace] = params;
|
|
45
|
+
VNE.CONST[namespace] = constants;
|
|
46
|
+
VNE.SETTINGS[namespace] = settings;
|
|
47
|
+
|
|
48
|
+
modules.forEach(regModule);
|
|
49
|
+
};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extend in consumer packages via module augmentation:
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* declare module "@vnejs/shared" {
|
|
6
|
+
* interface VnePluginEventsMap {
|
|
7
|
+
* SCENARIO: typeof SUBSCRIBE_EVENTS;
|
|
8
|
+
* }
|
|
9
|
+
* interface VnePluginConstantsMap {
|
|
10
|
+
* SCENARIO: typeof constants;
|
|
11
|
+
* }
|
|
12
|
+
* interface VnePluginEvents {
|
|
13
|
+
* CUSTOM: string;
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* // Namespace and event keys may be unset until regPlugin runs:
|
|
18
|
+
* VNE.EVENTS.STORAGE?.CLEAR
|
|
19
|
+
*/
|
|
20
|
+
export interface VnePluginConstantsMap {}
|
|
21
|
+
export interface VnePluginEventsMap {}
|
|
22
|
+
export interface VnePluginSettingsMap {}
|
|
23
|
+
export interface VnePluginParamsMap {}
|
|
24
|
+
|
|
25
|
+
/** Namespace and its fields may be missing until plugins register (use `?.` when needed). */
|
|
26
|
+
type OptionalPluginMapValues<T> = {
|
|
27
|
+
[K in keyof T]?: T[K] extends object ? Partial<T[K]> & T[K] : T[K];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type VnePluginConstantsMapRegistry = OptionalPluginMapValues<VnePluginConstantsMap> &
|
|
31
|
+
Partial<Record<string, VnePluginConstantsRegistry | undefined>>;
|
|
32
|
+
export type VnePluginEventsMapRegistry = OptionalPluginMapValues<VnePluginEventsMap> &
|
|
33
|
+
Partial<Record<string, VnePluginEventsRegistry | undefined>>;
|
|
34
|
+
export type VnePluginSettingsMapRegistry = OptionalPluginMapValues<VnePluginSettingsMap> &
|
|
35
|
+
Partial<Record<string, VnePluginSettingsRegistry | undefined>>;
|
|
36
|
+
export type VnePluginParamsMapRegistry = OptionalPluginMapValues<VnePluginParamsMap> &
|
|
37
|
+
Partial<Record<string, VnePluginParamsRegistry | undefined>>;
|
|
38
|
+
|
|
39
|
+
/** Fallback shape for one plugin namespace not listed in *Map interfaces. */
|
|
40
|
+
export interface VnePluginConstants {}
|
|
41
|
+
export interface VnePluginEvents {}
|
|
42
|
+
export interface VnePluginSettings {}
|
|
43
|
+
export interface VnePluginParams {}
|
|
44
|
+
|
|
45
|
+
export type VnePluginConstantsRegistry = VnePluginConstants & Partial<Record<string, never>>;
|
|
46
|
+
export type VnePluginEventsRegistry = VnePluginEvents & Partial<Record<string, string>>;
|
|
47
|
+
export type VnePluginSettingsRegistry = VnePluginSettings & Partial<Record<string, string>>;
|
|
48
|
+
export type VnePluginParamsRegistry = VnePluginParams & Partial<Record<string, never>>;
|
|
49
|
+
|
|
50
|
+
export type VneNamespace =
|
|
51
|
+
| keyof VnePluginConstantsMap
|
|
52
|
+
| keyof VnePluginEventsMap
|
|
53
|
+
| keyof VnePluginSettingsMap
|
|
54
|
+
| keyof VnePluginParamsMap
|
|
55
|
+
| (string & {});
|
|
56
|
+
|
|
57
|
+
export type VneRegistry = {
|
|
58
|
+
CONST: VnePluginConstantsMapRegistry;
|
|
59
|
+
EVENTS: VnePluginEventsMapRegistry;
|
|
60
|
+
SETTINGS: VnePluginSettingsMapRegistry;
|
|
61
|
+
PARAMS: VnePluginParamsMapRegistry;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export interface VnePluginShape {
|
|
65
|
+
constants?: VnePluginConstantsRegistry;
|
|
66
|
+
events?: VnePluginEventsRegistry;
|
|
67
|
+
settings?: VnePluginSettingsRegistry;
|
|
68
|
+
params?: VnePluginParamsRegistry;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface VneModule {
|
|
72
|
+
name: string;
|
|
73
|
+
isReady: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type VneModuleClass = new () => VneModule;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"noEmitOnError": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"rootDir": "src",
|
|
13
|
+
"outDir": "dist"
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*.ts"],
|
|
16
|
+
"exclude": ["dist", "node_modules"]
|
|
17
|
+
}
|