@hamak/ui-store-api 0.1.0
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/.turbo/turbo-build.log +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +6 -0
- package/dist/api/middleware-registry.d.ts +33 -0
- package/dist/api/middleware-registry.d.ts.map +1 -0
- package/dist/api/middleware-registry.js +5 -0
- package/dist/api/reducer-registry.d.ts +41 -0
- package/dist/api/reducer-registry.d.ts.map +1 -0
- package/dist/api/reducer-registry.js +5 -0
- package/dist/api/store-manager.d.ts +55 -0
- package/dist/api/store-manager.d.ts.map +1 -0
- package/dist/api/store-manager.js +5 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/tokens/index.d.ts +5 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +4 -0
- package/dist/tokens/service-tokens.d.ts +8 -0
- package/dist/tokens/service-tokens.d.ts.map +1 -0
- package/dist/tokens/service-tokens.js +7 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/middleware-types.d.ts +31 -0
- package/dist/types/middleware-types.d.ts.map +1 -0
- package/dist/types/middleware-types.js +4 -0
- package/dist/types/reducer-types.d.ts +22 -0
- package/dist/types/reducer-types.d.ts.map +1 -0
- package/dist/types/reducer-types.js +4 -0
- package/dist/types/store-types.d.ts +49 -0
- package/dist/types/store-types.d.ts.map +1 -0
- package/dist/types/store-types.js +4 -0
- package/package.json +37 -0
- package/src/api/index.ts +7 -0
- package/src/api/middleware-registry.ts +39 -0
- package/src/api/reducer-registry.ts +48 -0
- package/src/api/store-manager.ts +65 -0
- package/src/index.ts +8 -0
- package/src/tokens/index.ts +5 -0
- package/src/tokens/service-tokens.ts +8 -0
- package/src/types/index.ts +7 -0
- package/src/types/middleware-types.ts +39 -0
- package/src/types/reducer-types.ts +27 -0
- package/src/types/store-types.ts +56 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
$ tsc -p tsconfig.json
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware Registry Interface
|
|
3
|
+
* Extension point for plugins to contribute middleware
|
|
4
|
+
*/
|
|
5
|
+
import type { Middleware } from 'redux';
|
|
6
|
+
import type { MiddlewareRegistration } from '../types';
|
|
7
|
+
export interface IMiddlewareRegistry {
|
|
8
|
+
/**
|
|
9
|
+
* Register a middleware
|
|
10
|
+
*/
|
|
11
|
+
register(registration: MiddlewareRegistration): void;
|
|
12
|
+
/**
|
|
13
|
+
* Unregister a middleware by ID
|
|
14
|
+
*/
|
|
15
|
+
unregister(id: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get all middleware in priority order
|
|
18
|
+
*/
|
|
19
|
+
getAll(): Middleware[];
|
|
20
|
+
/**
|
|
21
|
+
* Check if middleware is registered
|
|
22
|
+
*/
|
|
23
|
+
has(id: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Get middleware registration info
|
|
26
|
+
*/
|
|
27
|
+
getInfo(id: string): MiddlewareRegistration | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Get all registrations with metadata
|
|
30
|
+
*/
|
|
31
|
+
getAllRegistrations(): MiddlewareRegistration[];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=middleware-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-registry.d.ts","sourceRoot":"","sources":["../../src/api/middleware-registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAErD;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B;;OAEG;IACH,MAAM,IAAI,UAAU,EAAE,CAAC;IAEvB;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAAC;IAExD;;OAEG;IACH,mBAAmB,IAAI,sBAAsB,EAAE,CAAC;CACjD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reducer Registry Interface
|
|
3
|
+
* Allows dynamic reducer registration and hot replacement
|
|
4
|
+
*/
|
|
5
|
+
import type { Reducer } from 'redux';
|
|
6
|
+
import type { ReducerMap, ReducerRegistration } from '../types';
|
|
7
|
+
export interface IReducerRegistry {
|
|
8
|
+
/**
|
|
9
|
+
* Register a reducer for a state slice key
|
|
10
|
+
* @param key - State slice key
|
|
11
|
+
* @param reducer - Reducer function
|
|
12
|
+
* @param replace - Whether to replace existing reducer (default: false)
|
|
13
|
+
*/
|
|
14
|
+
register(key: string, reducer: Reducer, replace?: boolean): void;
|
|
15
|
+
/**
|
|
16
|
+
* Unregister a reducer
|
|
17
|
+
* @param key - State slice key
|
|
18
|
+
*/
|
|
19
|
+
unregister(key: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get all registered reducers
|
|
22
|
+
*/
|
|
23
|
+
getAll(): ReducerMap;
|
|
24
|
+
/**
|
|
25
|
+
* Get combined root reducer
|
|
26
|
+
*/
|
|
27
|
+
getCombinedReducer(): Reducer;
|
|
28
|
+
/**
|
|
29
|
+
* Check if reducer is registered
|
|
30
|
+
*/
|
|
31
|
+
has(key: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Get reducer registration info
|
|
34
|
+
*/
|
|
35
|
+
getInfo(key: string): ReducerRegistration | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Get all registrations with metadata
|
|
38
|
+
*/
|
|
39
|
+
getAllRegistrations(): ReducerRegistration[];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=reducer-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer-registry.d.ts","sourceRoot":"","sources":["../../src/api/reducer-registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEhE,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEjE;;;OAGG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;OAEG;IACH,MAAM,IAAI,UAAU,CAAC;IAErB;;OAEG;IACH,kBAAkB,IAAI,OAAO,CAAC;IAE9B;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAAC;IAEtD;;OAEG;IACH,mBAAmB,IAAI,mBAAmB,EAAE,CAAC;CAC9C"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store Manager Interface
|
|
3
|
+
* Main orchestrator for Redux store management
|
|
4
|
+
*/
|
|
5
|
+
import type { Store, Reducer, Action } from 'redux';
|
|
6
|
+
import type { StoreConfig, RootState, AppAction } from '../types';
|
|
7
|
+
import type { IMiddlewareRegistry } from './middleware-registry';
|
|
8
|
+
import type { IReducerRegistry } from './reducer-registry';
|
|
9
|
+
export interface IStoreManager {
|
|
10
|
+
/**
|
|
11
|
+
* Get the Redux store instance
|
|
12
|
+
* @throws Error if store is not initialized
|
|
13
|
+
*/
|
|
14
|
+
getStore(): Store<RootState, AppAction>;
|
|
15
|
+
/**
|
|
16
|
+
* Check if store is initialized
|
|
17
|
+
*/
|
|
18
|
+
isInitialized(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the store
|
|
21
|
+
* Should be called after all plugins have registered middleware/reducers
|
|
22
|
+
* @internal - Called by plugin framework during activation
|
|
23
|
+
*/
|
|
24
|
+
initialize(config?: StoreConfig): Store<RootState, AppAction>;
|
|
25
|
+
/**
|
|
26
|
+
* Get middleware registry (for plugin contributions)
|
|
27
|
+
*/
|
|
28
|
+
getMiddlewareRegistry(): IMiddlewareRegistry;
|
|
29
|
+
/**
|
|
30
|
+
* Get reducer registry (for dynamic reducers)
|
|
31
|
+
*/
|
|
32
|
+
getReducerRegistry(): IReducerRegistry;
|
|
33
|
+
/**
|
|
34
|
+
* Dispatch an action
|
|
35
|
+
*/
|
|
36
|
+
dispatch<A extends Action>(action: A): A;
|
|
37
|
+
/**
|
|
38
|
+
* Get current state
|
|
39
|
+
*/
|
|
40
|
+
getState<S = RootState>(): S;
|
|
41
|
+
/**
|
|
42
|
+
* Subscribe to state changes
|
|
43
|
+
* @returns Unsubscribe function
|
|
44
|
+
*/
|
|
45
|
+
subscribe(listener: () => void): () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Replace the root reducer (for hot module replacement)
|
|
48
|
+
*/
|
|
49
|
+
replaceReducer(nextReducer: Reducer<RootState, AppAction>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Destroy the store and clean up resources
|
|
52
|
+
*/
|
|
53
|
+
destroy(): void;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=store-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-manager.d.ts","sourceRoot":"","sources":["../../src/api/store-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAExC;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC;IAEzB;;;;OAIG;IACH,UAAU,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAE9D;;OAEG;IACH,qBAAqB,IAAI,mBAAmB,CAAC;IAE7C;;OAEG;IACH,kBAAkB,IAAI,gBAAgB,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,CAAC,GAAG,SAAS,KAAK,CAAC,CAAC;IAE7B;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAE5C;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;IAEjE;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Injection Tokens
|
|
3
|
+
* Used for service resolution in the microkernel
|
|
4
|
+
*/
|
|
5
|
+
export declare const STORE_MANAGER_TOKEN: unique symbol;
|
|
6
|
+
export declare const MIDDLEWARE_REGISTRY_TOKEN: unique symbol;
|
|
7
|
+
export declare const REDUCER_REGISTRY_TOKEN: unique symbol;
|
|
8
|
+
//# sourceMappingURL=service-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-tokens.d.ts","sourceRoot":"","sources":["../../src/tokens/service-tokens.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,mBAAmB,eAAyB,CAAC;AAC1D,eAAO,MAAM,yBAAyB,eAA+B,CAAC;AACtE,eAAO,MAAM,sBAAsB,eAA4B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Injection Tokens
|
|
3
|
+
* Used for service resolution in the microkernel
|
|
4
|
+
*/
|
|
5
|
+
export const STORE_MANAGER_TOKEN = Symbol('StoreManager');
|
|
6
|
+
export const MIDDLEWARE_REGISTRY_TOKEN = Symbol('MiddlewareRegistry');
|
|
7
|
+
export const REDUCER_REGISTRY_TOKEN = Symbol('ReducerRegistry');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
import type { Middleware } from 'redux';
|
|
5
|
+
/**
|
|
6
|
+
* Middleware registration with metadata
|
|
7
|
+
*/
|
|
8
|
+
export interface MiddlewareRegistration {
|
|
9
|
+
/** Unique identifier for this middleware */
|
|
10
|
+
id: string;
|
|
11
|
+
/** The Redux middleware function */
|
|
12
|
+
middleware: Middleware;
|
|
13
|
+
/** Execution priority (higher = runs earlier). Default: 0 */
|
|
14
|
+
priority?: number;
|
|
15
|
+
/** Plugin that registered this middleware */
|
|
16
|
+
plugin?: string;
|
|
17
|
+
/** Optional description for debugging */
|
|
18
|
+
description?: string;
|
|
19
|
+
/** Whether this middleware can be disabled */
|
|
20
|
+
optional?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Middleware configuration
|
|
24
|
+
*/
|
|
25
|
+
export interface MiddlewareConfig {
|
|
26
|
+
/** Middleware IDs to disable */
|
|
27
|
+
disabled?: string[];
|
|
28
|
+
/** Override priorities for specific middleware */
|
|
29
|
+
priorities?: Record<string, number>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=middleware-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware-types.d.ts","sourceRoot":"","sources":["../../src/types/middleware-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IAEX,oCAAoC;IACpC,UAAU,EAAE,UAAU,CAAC;IAEvB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reducer Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
import type { Reducer } from 'redux';
|
|
5
|
+
/**
|
|
6
|
+
* Reducer registration metadata
|
|
7
|
+
*/
|
|
8
|
+
export interface ReducerRegistration {
|
|
9
|
+
/** State slice key */
|
|
10
|
+
key: string;
|
|
11
|
+
/** The reducer function */
|
|
12
|
+
reducer: Reducer;
|
|
13
|
+
/** Plugin that registered this reducer */
|
|
14
|
+
plugin?: string;
|
|
15
|
+
/** Timestamp of registration */
|
|
16
|
+
registeredAt: Date;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reducer map type
|
|
20
|
+
*/
|
|
21
|
+
export type ReducerMap = Record<string, Reducer>;
|
|
22
|
+
//# sourceMappingURL=reducer-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer-types.d.ts","sourceRoot":"","sources":["../../src/types/reducer-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,sBAAsB;IACtB,GAAG,EAAE,MAAM,CAAC;IAEZ,2BAA2B;IAC3B,OAAO,EAAE,OAAO,CAAC;IAEjB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gCAAgC;IAChC,YAAY,EAAE,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
import type { Store, Action, StoreEnhancer } from 'redux';
|
|
5
|
+
/**
|
|
6
|
+
* Store configuration
|
|
7
|
+
*/
|
|
8
|
+
export interface StoreConfig {
|
|
9
|
+
/** Enable Redux DevTools integration */
|
|
10
|
+
devTools?: boolean;
|
|
11
|
+
/** Initial/preloaded state */
|
|
12
|
+
preloadedState?: any;
|
|
13
|
+
/** Additional store enhancers */
|
|
14
|
+
enhancers?: StoreEnhancer[];
|
|
15
|
+
/** Persistence configuration */
|
|
16
|
+
persistence?: {
|
|
17
|
+
/** Enable state persistence */
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
/** Storage key prefix */
|
|
20
|
+
key?: string;
|
|
21
|
+
/** Storage type */
|
|
22
|
+
storage?: 'localStorage' | 'sessionStorage' | 'indexedDB';
|
|
23
|
+
/** Keys to persist (whitelist) */
|
|
24
|
+
whitelist?: string[];
|
|
25
|
+
/** Keys to ignore (blacklist) */
|
|
26
|
+
blacklist?: string[];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Root state shape (can be extended by applications)
|
|
31
|
+
*/
|
|
32
|
+
export interface RootState {
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Standard action shape following FSA (Flux Standard Action)
|
|
37
|
+
*/
|
|
38
|
+
export interface AppAction<T = any> extends Action<string> {
|
|
39
|
+
type: string;
|
|
40
|
+
payload?: T;
|
|
41
|
+
error?: boolean;
|
|
42
|
+
meta?: any;
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Store instance type
|
|
47
|
+
*/
|
|
48
|
+
export type AppStore = Store<RootState, AppAction>;
|
|
49
|
+
//# sourceMappingURL=store-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-types.d.ts","sourceRoot":"","sources":["../../src/types/store-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAW,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,8BAA8B;IAC9B,cAAc,CAAC,EAAE,GAAG,CAAC;IAErB,iCAAiC;IACjC,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAE5B,gCAAgC;IAChC,WAAW,CAAC,EAAE;QACZ,+BAA+B;QAC/B,OAAO,EAAE,OAAO,CAAC;QACjB,yBAAyB;QACzB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,mBAAmB;QACnB,OAAO,CAAC,EAAE,cAAc,GAAG,gBAAgB,GAAG,WAAW,CAAC;QAC1D,kCAAkC;QAClC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,iCAAiC;QACjC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,MAAM,CAAC,MAAM,CAAC;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hamak/ui-store-api",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "UI Store API - Redux store interfaces and contracts",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/amah/app-framework.git",
|
|
13
|
+
"directory": "packages/ui-store/ui-store-api"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"clean": "rm -rf dist",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:watch": "vitest"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"redux": "^5.0.1"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"typescript": "~5.4.0",
|
|
35
|
+
"vitest": "^2.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware Registry Interface
|
|
3
|
+
* Extension point for plugins to contribute middleware
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Middleware } from 'redux';
|
|
7
|
+
import type { MiddlewareRegistration } from '../types';
|
|
8
|
+
|
|
9
|
+
export interface IMiddlewareRegistry {
|
|
10
|
+
/**
|
|
11
|
+
* Register a middleware
|
|
12
|
+
*/
|
|
13
|
+
register(registration: MiddlewareRegistration): void;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Unregister a middleware by ID
|
|
17
|
+
*/
|
|
18
|
+
unregister(id: string): void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get all middleware in priority order
|
|
22
|
+
*/
|
|
23
|
+
getAll(): Middleware[];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Check if middleware is registered
|
|
27
|
+
*/
|
|
28
|
+
has(id: string): boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get middleware registration info
|
|
32
|
+
*/
|
|
33
|
+
getInfo(id: string): MiddlewareRegistration | undefined;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get all registrations with metadata
|
|
37
|
+
*/
|
|
38
|
+
getAllRegistrations(): MiddlewareRegistration[];
|
|
39
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reducer Registry Interface
|
|
3
|
+
* Allows dynamic reducer registration and hot replacement
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Reducer } from 'redux';
|
|
7
|
+
import type { ReducerMap, ReducerRegistration } from '../types';
|
|
8
|
+
|
|
9
|
+
export interface IReducerRegistry {
|
|
10
|
+
/**
|
|
11
|
+
* Register a reducer for a state slice key
|
|
12
|
+
* @param key - State slice key
|
|
13
|
+
* @param reducer - Reducer function
|
|
14
|
+
* @param replace - Whether to replace existing reducer (default: false)
|
|
15
|
+
*/
|
|
16
|
+
register(key: string, reducer: Reducer, replace?: boolean): void;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Unregister a reducer
|
|
20
|
+
* @param key - State slice key
|
|
21
|
+
*/
|
|
22
|
+
unregister(key: string): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get all registered reducers
|
|
26
|
+
*/
|
|
27
|
+
getAll(): ReducerMap;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get combined root reducer
|
|
31
|
+
*/
|
|
32
|
+
getCombinedReducer(): Reducer;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Check if reducer is registered
|
|
36
|
+
*/
|
|
37
|
+
has(key: string): boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get reducer registration info
|
|
41
|
+
*/
|
|
42
|
+
getInfo(key: string): ReducerRegistration | undefined;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get all registrations with metadata
|
|
46
|
+
*/
|
|
47
|
+
getAllRegistrations(): ReducerRegistration[];
|
|
48
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store Manager Interface
|
|
3
|
+
* Main orchestrator for Redux store management
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Store, Reducer, Action } from 'redux';
|
|
7
|
+
import type { StoreConfig, RootState, AppAction } from '../types';
|
|
8
|
+
import type { IMiddlewareRegistry } from './middleware-registry';
|
|
9
|
+
import type { IReducerRegistry } from './reducer-registry';
|
|
10
|
+
|
|
11
|
+
export interface IStoreManager {
|
|
12
|
+
/**
|
|
13
|
+
* Get the Redux store instance
|
|
14
|
+
* @throws Error if store is not initialized
|
|
15
|
+
*/
|
|
16
|
+
getStore(): Store<RootState, AppAction>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Check if store is initialized
|
|
20
|
+
*/
|
|
21
|
+
isInitialized(): boolean;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the store
|
|
25
|
+
* Should be called after all plugins have registered middleware/reducers
|
|
26
|
+
* @internal - Called by plugin framework during activation
|
|
27
|
+
*/
|
|
28
|
+
initialize(config?: StoreConfig): Store<RootState, AppAction>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get middleware registry (for plugin contributions)
|
|
32
|
+
*/
|
|
33
|
+
getMiddlewareRegistry(): IMiddlewareRegistry;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get reducer registry (for dynamic reducers)
|
|
37
|
+
*/
|
|
38
|
+
getReducerRegistry(): IReducerRegistry;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Dispatch an action
|
|
42
|
+
*/
|
|
43
|
+
dispatch<A extends Action>(action: A): A;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get current state
|
|
47
|
+
*/
|
|
48
|
+
getState<S = RootState>(): S;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Subscribe to state changes
|
|
52
|
+
* @returns Unsubscribe function
|
|
53
|
+
*/
|
|
54
|
+
subscribe(listener: () => void): () => void;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Replace the root reducer (for hot module replacement)
|
|
58
|
+
*/
|
|
59
|
+
replaceReducer(nextReducer: Reducer<RootState, AppAction>): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Destroy the store and clean up resources
|
|
63
|
+
*/
|
|
64
|
+
destroy(): void;
|
|
65
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Injection Tokens
|
|
3
|
+
* Used for service resolution in the microkernel
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const STORE_MANAGER_TOKEN = Symbol('StoreManager');
|
|
7
|
+
export const MIDDLEWARE_REGISTRY_TOKEN = Symbol('MiddlewareRegistry');
|
|
8
|
+
export const REDUCER_REGISTRY_TOKEN = Symbol('ReducerRegistry');
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Middleware } from 'redux';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Middleware registration with metadata
|
|
9
|
+
*/
|
|
10
|
+
export interface MiddlewareRegistration {
|
|
11
|
+
/** Unique identifier for this middleware */
|
|
12
|
+
id: string;
|
|
13
|
+
|
|
14
|
+
/** The Redux middleware function */
|
|
15
|
+
middleware: Middleware;
|
|
16
|
+
|
|
17
|
+
/** Execution priority (higher = runs earlier). Default: 0 */
|
|
18
|
+
priority?: number;
|
|
19
|
+
|
|
20
|
+
/** Plugin that registered this middleware */
|
|
21
|
+
plugin?: string;
|
|
22
|
+
|
|
23
|
+
/** Optional description for debugging */
|
|
24
|
+
description?: string;
|
|
25
|
+
|
|
26
|
+
/** Whether this middleware can be disabled */
|
|
27
|
+
optional?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Middleware configuration
|
|
32
|
+
*/
|
|
33
|
+
export interface MiddlewareConfig {
|
|
34
|
+
/** Middleware IDs to disable */
|
|
35
|
+
disabled?: string[];
|
|
36
|
+
|
|
37
|
+
/** Override priorities for specific middleware */
|
|
38
|
+
priorities?: Record<string, number>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reducer Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Reducer } from 'redux';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Reducer registration metadata
|
|
9
|
+
*/
|
|
10
|
+
export interface ReducerRegistration {
|
|
11
|
+
/** State slice key */
|
|
12
|
+
key: string;
|
|
13
|
+
|
|
14
|
+
/** The reducer function */
|
|
15
|
+
reducer: Reducer;
|
|
16
|
+
|
|
17
|
+
/** Plugin that registered this reducer */
|
|
18
|
+
plugin?: string;
|
|
19
|
+
|
|
20
|
+
/** Timestamp of registration */
|
|
21
|
+
registeredAt: Date;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Reducer map type
|
|
26
|
+
*/
|
|
27
|
+
export type ReducerMap = Record<string, Reducer>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Store, Reducer, Action, StoreEnhancer } from 'redux';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Store configuration
|
|
9
|
+
*/
|
|
10
|
+
export interface StoreConfig {
|
|
11
|
+
/** Enable Redux DevTools integration */
|
|
12
|
+
devTools?: boolean;
|
|
13
|
+
|
|
14
|
+
/** Initial/preloaded state */
|
|
15
|
+
preloadedState?: any;
|
|
16
|
+
|
|
17
|
+
/** Additional store enhancers */
|
|
18
|
+
enhancers?: StoreEnhancer[];
|
|
19
|
+
|
|
20
|
+
/** Persistence configuration */
|
|
21
|
+
persistence?: {
|
|
22
|
+
/** Enable state persistence */
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
/** Storage key prefix */
|
|
25
|
+
key?: string;
|
|
26
|
+
/** Storage type */
|
|
27
|
+
storage?: 'localStorage' | 'sessionStorage' | 'indexedDB';
|
|
28
|
+
/** Keys to persist (whitelist) */
|
|
29
|
+
whitelist?: string[];
|
|
30
|
+
/** Keys to ignore (blacklist) */
|
|
31
|
+
blacklist?: string[];
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Root state shape (can be extended by applications)
|
|
37
|
+
*/
|
|
38
|
+
export interface RootState {
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Standard action shape following FSA (Flux Standard Action)
|
|
44
|
+
*/
|
|
45
|
+
export interface AppAction<T = any> extends Action<string> {
|
|
46
|
+
type: string;
|
|
47
|
+
payload?: T;
|
|
48
|
+
error?: boolean;
|
|
49
|
+
meta?: any;
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Store instance type
|
|
55
|
+
*/
|
|
56
|
+
export type AppStore = Store<RootState, AppAction>;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"isolatedModules": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"allowImportingTsExtensions": false
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
|
19
|
+
}
|