@vnejs/shared 0.0.10 → 0.0.12

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.
@@ -0,0 +1,6 @@
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
+ export declare const VNE: VneRegistry;
5
+ export declare const regModule: (Module: VneModuleClass) => VneModuleClass;
6
+ export declare const regPlugin: (namespace?: VneNamespace, { constants, events, settings, params }?: VnePluginShape, modules?: VneModuleClass[]) => void;
@@ -1,6 +1,10 @@
1
1
  export const VNE_MODULES = [];
2
2
  export const VNE = { CONST: {}, EVENTS: {}, SETTINGS: {}, PARAMS: {} };
3
- export const regModule = (Module) => Module && VNE_MODULES.push(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;
@@ -0,0 +1,67 @@
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
+ }
22
+ export interface VnePluginEventsMap {
23
+ }
24
+ export interface VnePluginSettingsMap {
25
+ }
26
+ export interface VnePluginParamsMap {
27
+ }
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. */
37
+ export interface VnePluginConstants {
38
+ }
39
+ export interface VnePluginEvents {
40
+ }
41
+ export interface VnePluginSettings {
42
+ }
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
+ export type VneNamespace = keyof VnePluginConstantsMap | keyof VnePluginEventsMap | keyof VnePluginSettingsMap | keyof VnePluginParamsMap | (string & {});
50
+ export type VneRegistry = {
51
+ CONST: VnePluginConstantsMapRegistry;
52
+ EVENTS: VnePluginEventsMapRegistry;
53
+ SETTINGS: VnePluginSettingsMapRegistry;
54
+ PARAMS: VnePluginParamsMapRegistry;
55
+ };
56
+ export interface VnePluginShape {
57
+ constants?: VnePluginConstantsRegistry;
58
+ events?: VnePluginEventsRegistry;
59
+ settings?: VnePluginSettingsRegistry;
60
+ params?: VnePluginParamsRegistry;
61
+ }
62
+ export interface VneModule {
63
+ name: string;
64
+ isReady: boolean;
65
+ }
66
+ export type VneModuleClass = new () => VneModule;
67
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,16 +1,22 @@
1
1
  {
2
2
  "name": "@vnejs/shared",
3
- "version": "0.0.10",
4
- "main": "index.js",
5
- "types": "index.d.ts",
3
+ "version": "0.0.12",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
6
10
  "scripts": {
7
11
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "build": "tsc -p tsconfig.json",
9
- "publish:major": "npm version major && npm publish --access public --legacy-peer-deps",
10
- "publish:minor": "npm version minor && npm publish --access public --legacy-peer-deps",
11
- "publish:patch": "npm version patch && npm publish --access public --legacy-peer-deps"
12
+ "build": "rm -rf dist && tsc -p tsconfig.json",
13
+ "publish:major": "npm run build && npm version major && npm publish --access public",
14
+ "publish:minor": "npm run build && npm version minor && npm publish --access public",
15
+ "publish:patch": "npm run build && npm version patch && npm publish --access public"
12
16
  },
13
17
  "author": "",
14
18
  "license": "ISC",
15
- "description": ""
19
+ "devDependencies": {
20
+ "typescript": "^6.0.3"
21
+ }
16
22
  }
package/index.d.ts DELETED
@@ -1,28 +0,0 @@
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>;
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.ts DELETED
@@ -1,56 +0,0 @@
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/tsconfig.json DELETED
@@ -1,15 +0,0 @@
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
-