orchestore 0.1.0 → 0.1.1
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/README.md +6 -1083
- package/dist/index.cjs +13 -32
- package/dist/index.d.cts +130 -3
- package/dist/index.d.ts +130 -3
- package/dist/index.js +13 -7
- package/package.json +27 -9
package/dist/index.cjs
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
test: () => test
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
function test() {
|
|
27
|
-
console.log("Working");
|
|
28
|
-
}
|
|
29
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
-
0 && (module.exports = {
|
|
31
|
-
test
|
|
32
|
-
});
|
|
1
|
+
"use strict";var E=Object.create;var a=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var F=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},O=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of K(t))!q.call(e,o)&&o!==r&&a(e,o,{get:()=>t[o],enumerable:!(n=I(t,o))||n.enumerable});return e};var V=(e,t,r)=>(r=e!=null?E(N(e)):{},O(t||!e||!e.__esModule?a(r,"default",{value:e,enumerable:!0}):r,e)),_=e=>O(a({},"__esModule",{value:!0}),e);var Z={};F(Z,{StoreProvider:()=>m,createSlice:()=>f,createStore:()=>S,default:()=>Y,getGlobalUtils:()=>v,provideGlobalUtils:()=>P});module.exports=_(Z);var R=require("@reduxjs/toolkit");var U=require("@reduxjs/toolkit"),G=[];function C(e){return G.find(t=>t.slice===e)?.redux}function f(e){let t=e,r=(0,U.createSlice)({name:e.name,initialState:e.state,reducers:e.mutations});return G.push({slice:t,redux:r}),t}var g=typeof globalThis<"u"&&typeof globalThis.process<"u"&&globalThis.process?.env?.NODE_ENV!=="production",h=!1,D=globalThis.console?.log?.bind?.(globalThis.console)||globalThis.console?.log,J=globalThis.console?.warn?.bind?.(globalThis.console)||globalThis.console?.warn,W=globalThis.console?.error?.bind?.(globalThis.console)||globalThis.console?.error,X=globalThis.console?.clear?.bind?.(globalThis.console)||globalThis.console?.clear;globalThis.console?.clear&&(globalThis.console.clear=(...e)=>{h=!1,X?.(...e)});var $=`[OrcheStore] Development diagnostics are enabled.
|
|
2
|
+
Warnings and errors from OrcheStore are not shown in production builds.
|
|
3
|
+
Runtime exceptions that stop code execution may still occur.
|
|
4
|
+
Please resolve all OrcheStore warnings and errors before deploying to production.
|
|
5
|
+
`,y=()=>{h||(h=!0,D?.($))},i={log(...e){g&&(y(),D?.(...e))},warn(...e){g&&(y(),J?.(...e))},error(...e){g&&(y(),W?.(...e))}};var d=[];function A(e){return d.find(t=>t.store===e)?.redux}function S({slices:e}){if(d.length===1)return i.warn(`[OrcheStore] createStore(...) was called more than once.
|
|
6
|
+
OrcheStore currently supports only a single global store instance and will return the existing store.
|
|
7
|
+
If you are creating a store inside a React component, create it only once, for example:
|
|
8
|
+
const [store] = useState(() => createStore(...));
|
|
9
|
+
Avoid useState(createStore(...)) because createStore(...) will be executed on every render.`),d[0].store;let t={},r={};for(let o in e){let T=e[o],w=C(T);w&&(t[o]=T,r[o]=w.reducer)}let n=(0,R.configureStore)({reducer:r});return d.push({store:t,redux:n}),t}var l=V(require("react"),1),p=require("react-redux");var M=[];function z({store:e,children:t}){let r=(0,p.useDispatch)(),n=M.find(o=>o.store===e);return n||M.push(n={store:e,dispatch:r}),n.dispatch=r,l.default.createElement(l.default.Fragment,null,t)}function m(e){let{store:t,stabilityCheck:r,identityFunctionCheck:n}=e,o=A(t);if(!o)throw new Error("[OrcheStore] <StoreProvider> requires a store instance created with createStore(...).");return l.default.createElement(p.Provider,{stabilityCheck:r,identityFunctionCheck:n,store:o},l.default.createElement(z,{...e}))}var B=Object.assign,b=Object.getOwnPropertyDescriptor(Object,"defineProperty")?.value||Object.defineProperty,H=(e,t,r)=>{b(e,t,{get:r,enumerable:!0,configurable:!1})},L=(e,t,r)=>{b(e,t,{value:r,writable:!1,enumerable:!0,configurable:!1})},k={assign:B,defineProp:b,defineReadonly:H,defineMethod:L},j={isArray:Array.isArray},u={get:Reflect.get,set:Reflect.set,delete:Reflect.deleteProperty};var c={GetMissingProp:e=>["OrcheStore[global-utils] Attempted to access a global utility before it became available. Missing property",e,`
|
|
10
|
+
If this utility is optional, register it as undefined using provideGlobalUtils(...) to suppress future warnings.
|
|
11
|
+
`],DeleteProp:e=>["OrcheStore[global-utils] Avoid deleting properties. Trying to delete property",e,`
|
|
12
|
+
Use provideGlobalUtils(...) to set them to undefined instead for type safety.
|
|
13
|
+
`],InvalidArgs:"OrcheStore[global-utils] Expected provideGlobalUtils(...) to receive a non-null object. Received:"},x=new Proxy({},{get(e,t,r){return t in e||i.error(...c.GetMissingProp(t)),u.get(e,t,r)},set(e,t,r,n){return u.set(e,t,r,n)},deleteProperty(e,t){return i.warn(...c.DeleteProp(t)),u.delete(e,t)}});function v(){return x}function P(e){return e==null?i.error(c.InvalidArgs,e):j.isArray(e)?i.error(c.InvalidArgs,"(type: array)",e):typeof e!="object"?i.error(c.InvalidArgs,`(type: ${typeof e})`,e):k.assign(x,e),x}var Q={createStore:S,createSlice:f,StoreProvider:m,provideGlobalUtils:P,getGlobalUtils:v},Y=Q;0&&(module.exports={StoreProvider,createSlice,createStore,getGlobalUtils,provideGlobalUtils});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ProviderProps } from 'react-redux';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type Dict<Value = any> = Record<string | number | symbol, Value>;
|
|
5
|
+
type Tail<T extends any[]> = T extends [any, ...infer R] ? R : T extends (infer U)[] ? U[] : never;
|
|
6
|
+
type DeepReadonly<T> = T extends (...args: any[]) => any ? T : T extends readonly (infer U)[] ? ReadonlyArray<DeepReadonly<U>> : T extends object ? {
|
|
7
|
+
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
8
|
+
} : T;
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
namespace OrcheStore {
|
|
12
|
+
/** User-defined framework type slots. */
|
|
13
|
+
interface Slots {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Resolves a type slot with validation and fallback support. */
|
|
18
|
+
type Definition<T, Rule, Default> = T extends keyof OrcheStore.Slots ? Exclude<OrcheStore.Slots[T], undefined | null> extends Rule ? Exclude<OrcheStore.Slots[T], undefined | null> : Default : Default;
|
|
19
|
+
/** Validation rule for the `global` type slot. */
|
|
20
|
+
type GlobalUtilsRule = Record<PropertyKey, any>;
|
|
21
|
+
/** Validation rule for the `root` type slot. */
|
|
22
|
+
type RootStoreRule = Record<PropertyKey, any>;
|
|
23
|
+
/** Resolved type for application-wide global utilities. */
|
|
24
|
+
type GlobalUtils = Definition<"global", GlobalUtilsRule, any>;
|
|
25
|
+
/** Resolved type for the application root store. */
|
|
26
|
+
type RootStore = Definition<"root", RootStoreRule, any>;
|
|
27
|
+
|
|
28
|
+
/** Reserved slice member names that cannot be overridden by user-defined APIs. */
|
|
29
|
+
type ReservedKeys<R = {}, M = {}> = "name" | "path" | "computed" | "root" | "global" | "getState" | "useSelect" | keyof R | keyof M;
|
|
30
|
+
/** Defines the mutations available on a slice. */
|
|
31
|
+
type Mutations<S extends Dict> = Dict<(state: Omit<S, "root" | "computed">, ...args: any[]) => void>;
|
|
32
|
+
/** Defines the computed functions available on a slice. */
|
|
33
|
+
type Computed<S extends Dict, C extends Dict> = Dict<(state: ExposedState<S, C>, ...args: any[]) => any>;
|
|
34
|
+
/** Defines the methods available on a slice with contextual `this` typing. */
|
|
35
|
+
type Methods<Context = any> = Dict<(...args: any[]) => any> & ThisType<Context>;
|
|
36
|
+
/** Defines the child slices nested within a slice. */
|
|
37
|
+
type Children = Dict<slice<any, Mutations<any>, Methods, Dict, Computed<any, any>, any>>;
|
|
38
|
+
/** Exposes immutable slice state with optional runtime helpers. */
|
|
39
|
+
type ExposedState<S extends Dict, C extends Children = Children, Root = {}> = DeepReadonly<Omit<S, "root"> & Root>;
|
|
40
|
+
/** Runtime slice API exposed by createSlice(...). */
|
|
41
|
+
type slice<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string> = {
|
|
42
|
+
/** Unique slice identifier. */
|
|
43
|
+
readonly name: N;
|
|
44
|
+
/** Fully qualified runtime path of the slice. */
|
|
45
|
+
readonly path: string;
|
|
46
|
+
/** Application-wide global utilities. */
|
|
47
|
+
readonly global: GlobalUtils;
|
|
48
|
+
/** Collection of derived state functions. */
|
|
49
|
+
readonly computed: {
|
|
50
|
+
readonly [K in keyof G]: (...args: Tail<Parameters<G[K]>>) => ReturnType<G[K]>;
|
|
51
|
+
};
|
|
52
|
+
/** Returns the latest immutable state snapshot. */
|
|
53
|
+
readonly getState: () => ExposedState<S, C>;
|
|
54
|
+
/** Subscribes to state changes within React components. */
|
|
55
|
+
readonly useSelect: <T>(selector: (state: ExposedState<S, C, true>) => T) => T;
|
|
56
|
+
} & {
|
|
57
|
+
/** Exposed mutation functions. */
|
|
58
|
+
readonly [K in Exclude<keyof R, ReservedKeys>]: (...args: Tail<Parameters<R[K]>>) => ReturnType<R[K]>;
|
|
59
|
+
} & {
|
|
60
|
+
/** Exposed method functions. */
|
|
61
|
+
readonly [K in Exclude<keyof M, ReservedKeys<R>>]: M[K];
|
|
62
|
+
} & {
|
|
63
|
+
/** Exposed child slices. */
|
|
64
|
+
readonly [K in Exclude<keyof C, ReservedKeys<R, M>>]: C[K];
|
|
65
|
+
};
|
|
66
|
+
/** Configuration object used to create a slice. */
|
|
67
|
+
type sliceOptions<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string> = {
|
|
68
|
+
/** Unique slice identifier. */
|
|
69
|
+
name: N;
|
|
70
|
+
/** Initial state object or lazy state initializer. */
|
|
71
|
+
state: S | (() => S);
|
|
72
|
+
/** Collection of synchronous state transition functions. */
|
|
73
|
+
mutations: R;
|
|
74
|
+
/** Collection of derived state functions. */
|
|
75
|
+
computed?: G & ThisType<G>;
|
|
76
|
+
/** Collection of slice methods and orchestration logic. */
|
|
77
|
+
methods?: M & ThisType<slice<S, R, M, C, G, N> & {
|
|
78
|
+
root: RootStore;
|
|
79
|
+
}>;
|
|
80
|
+
/** Collection of nested child slices. */
|
|
81
|
+
children?: C;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
type store = Record<string, slice>;
|
|
85
|
+
|
|
86
|
+
type orchestore = {};
|
|
87
|
+
declare global {
|
|
88
|
+
type OrcheStore = orchestore;
|
|
89
|
+
namespace OrcheStore {
|
|
90
|
+
type Store = store;
|
|
91
|
+
/** Runtime slice API exposed by createSlice(...). */
|
|
92
|
+
type Slice<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string> = slice<S, R, M, C, G, N>;
|
|
93
|
+
/** Configuration object used to create a slice. */
|
|
94
|
+
type SliceOptions<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string> = sliceOptions<S, R, M, C, G, N>;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Creates and initializes an OrcheStore instance. */
|
|
99
|
+
declare function createStore({ slices }: {
|
|
100
|
+
slices: Record<string, slice>;
|
|
101
|
+
}): store;
|
|
102
|
+
|
|
103
|
+
/** Creates and initializes an OrcheStore slice. */
|
|
104
|
+
declare function createSlice<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string>(options: sliceOptions<S, R, M, C, G, N>): slice<S, R, M, C, G, N>;
|
|
105
|
+
|
|
106
|
+
type StoreProviderProps = Omit<ProviderProps, "store" | "serverState" | "context"> & {
|
|
107
|
+
/** The root OrcheStore instance created with createStore(...). */
|
|
108
|
+
store: store;
|
|
109
|
+
};
|
|
110
|
+
/** Provides an OrcheStore instance to the React component tree. */
|
|
111
|
+
declare function StoreProvider(props: StoreProviderProps): React.JSX.Element;
|
|
112
|
+
|
|
113
|
+
/** Returns the current global utilities object. */
|
|
114
|
+
declare function getGlobalUtils(): GlobalUtils;
|
|
115
|
+
/** Registers or updates application-wide global utilities. */
|
|
116
|
+
declare function provideGlobalUtils(value: Partial<GlobalUtils>): GlobalUtils;
|
|
117
|
+
|
|
118
|
+
declare const OrcheStore$1: {
|
|
119
|
+
/** Creates and initializes an OrcheStore instance. */
|
|
120
|
+
createStore: typeof createStore;
|
|
121
|
+
/** Creates and initializes an OrcheStore slice. */
|
|
122
|
+
createSlice: typeof createSlice;
|
|
123
|
+
/** Provides an OrcheStore instance to the React component tree. */
|
|
124
|
+
StoreProvider: typeof StoreProvider;
|
|
125
|
+
/** Registers or updates application-wide global utilities. */
|
|
126
|
+
provideGlobalUtils: typeof provideGlobalUtils;
|
|
127
|
+
/** Returns the current global utilities object. */
|
|
128
|
+
getGlobalUtils: typeof getGlobalUtils;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export { type GlobalUtils, type orchestore as OrcheStore, type RootStore, type slice as Slice, type sliceOptions as SliceOptions, type store as Store, StoreProvider, createSlice, createStore, OrcheStore$1 as default, getGlobalUtils, provideGlobalUtils };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ProviderProps } from 'react-redux';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type Dict<Value = any> = Record<string | number | symbol, Value>;
|
|
5
|
+
type Tail<T extends any[]> = T extends [any, ...infer R] ? R : T extends (infer U)[] ? U[] : never;
|
|
6
|
+
type DeepReadonly<T> = T extends (...args: any[]) => any ? T : T extends readonly (infer U)[] ? ReadonlyArray<DeepReadonly<U>> : T extends object ? {
|
|
7
|
+
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
8
|
+
} : T;
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
namespace OrcheStore {
|
|
12
|
+
/** User-defined framework type slots. */
|
|
13
|
+
interface Slots {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Resolves a type slot with validation and fallback support. */
|
|
18
|
+
type Definition<T, Rule, Default> = T extends keyof OrcheStore.Slots ? Exclude<OrcheStore.Slots[T], undefined | null> extends Rule ? Exclude<OrcheStore.Slots[T], undefined | null> : Default : Default;
|
|
19
|
+
/** Validation rule for the `global` type slot. */
|
|
20
|
+
type GlobalUtilsRule = Record<PropertyKey, any>;
|
|
21
|
+
/** Validation rule for the `root` type slot. */
|
|
22
|
+
type RootStoreRule = Record<PropertyKey, any>;
|
|
23
|
+
/** Resolved type for application-wide global utilities. */
|
|
24
|
+
type GlobalUtils = Definition<"global", GlobalUtilsRule, any>;
|
|
25
|
+
/** Resolved type for the application root store. */
|
|
26
|
+
type RootStore = Definition<"root", RootStoreRule, any>;
|
|
27
|
+
|
|
28
|
+
/** Reserved slice member names that cannot be overridden by user-defined APIs. */
|
|
29
|
+
type ReservedKeys<R = {}, M = {}> = "name" | "path" | "computed" | "root" | "global" | "getState" | "useSelect" | keyof R | keyof M;
|
|
30
|
+
/** Defines the mutations available on a slice. */
|
|
31
|
+
type Mutations<S extends Dict> = Dict<(state: Omit<S, "root" | "computed">, ...args: any[]) => void>;
|
|
32
|
+
/** Defines the computed functions available on a slice. */
|
|
33
|
+
type Computed<S extends Dict, C extends Dict> = Dict<(state: ExposedState<S, C>, ...args: any[]) => any>;
|
|
34
|
+
/** Defines the methods available on a slice with contextual `this` typing. */
|
|
35
|
+
type Methods<Context = any> = Dict<(...args: any[]) => any> & ThisType<Context>;
|
|
36
|
+
/** Defines the child slices nested within a slice. */
|
|
37
|
+
type Children = Dict<slice<any, Mutations<any>, Methods, Dict, Computed<any, any>, any>>;
|
|
38
|
+
/** Exposes immutable slice state with optional runtime helpers. */
|
|
39
|
+
type ExposedState<S extends Dict, C extends Children = Children, Root = {}> = DeepReadonly<Omit<S, "root"> & Root>;
|
|
40
|
+
/** Runtime slice API exposed by createSlice(...). */
|
|
41
|
+
type slice<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string> = {
|
|
42
|
+
/** Unique slice identifier. */
|
|
43
|
+
readonly name: N;
|
|
44
|
+
/** Fully qualified runtime path of the slice. */
|
|
45
|
+
readonly path: string;
|
|
46
|
+
/** Application-wide global utilities. */
|
|
47
|
+
readonly global: GlobalUtils;
|
|
48
|
+
/** Collection of derived state functions. */
|
|
49
|
+
readonly computed: {
|
|
50
|
+
readonly [K in keyof G]: (...args: Tail<Parameters<G[K]>>) => ReturnType<G[K]>;
|
|
51
|
+
};
|
|
52
|
+
/** Returns the latest immutable state snapshot. */
|
|
53
|
+
readonly getState: () => ExposedState<S, C>;
|
|
54
|
+
/** Subscribes to state changes within React components. */
|
|
55
|
+
readonly useSelect: <T>(selector: (state: ExposedState<S, C, true>) => T) => T;
|
|
56
|
+
} & {
|
|
57
|
+
/** Exposed mutation functions. */
|
|
58
|
+
readonly [K in Exclude<keyof R, ReservedKeys>]: (...args: Tail<Parameters<R[K]>>) => ReturnType<R[K]>;
|
|
59
|
+
} & {
|
|
60
|
+
/** Exposed method functions. */
|
|
61
|
+
readonly [K in Exclude<keyof M, ReservedKeys<R>>]: M[K];
|
|
62
|
+
} & {
|
|
63
|
+
/** Exposed child slices. */
|
|
64
|
+
readonly [K in Exclude<keyof C, ReservedKeys<R, M>>]: C[K];
|
|
65
|
+
};
|
|
66
|
+
/** Configuration object used to create a slice. */
|
|
67
|
+
type sliceOptions<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string> = {
|
|
68
|
+
/** Unique slice identifier. */
|
|
69
|
+
name: N;
|
|
70
|
+
/** Initial state object or lazy state initializer. */
|
|
71
|
+
state: S | (() => S);
|
|
72
|
+
/** Collection of synchronous state transition functions. */
|
|
73
|
+
mutations: R;
|
|
74
|
+
/** Collection of derived state functions. */
|
|
75
|
+
computed?: G & ThisType<G>;
|
|
76
|
+
/** Collection of slice methods and orchestration logic. */
|
|
77
|
+
methods?: M & ThisType<slice<S, R, M, C, G, N> & {
|
|
78
|
+
root: RootStore;
|
|
79
|
+
}>;
|
|
80
|
+
/** Collection of nested child slices. */
|
|
81
|
+
children?: C;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
type store = Record<string, slice>;
|
|
85
|
+
|
|
86
|
+
type orchestore = {};
|
|
87
|
+
declare global {
|
|
88
|
+
type OrcheStore = orchestore;
|
|
89
|
+
namespace OrcheStore {
|
|
90
|
+
type Store = store;
|
|
91
|
+
/** Runtime slice API exposed by createSlice(...). */
|
|
92
|
+
type Slice<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string> = slice<S, R, M, C, G, N>;
|
|
93
|
+
/** Configuration object used to create a slice. */
|
|
94
|
+
type SliceOptions<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string> = sliceOptions<S, R, M, C, G, N>;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Creates and initializes an OrcheStore instance. */
|
|
99
|
+
declare function createStore({ slices }: {
|
|
100
|
+
slices: Record<string, slice>;
|
|
101
|
+
}): store;
|
|
102
|
+
|
|
103
|
+
/** Creates and initializes an OrcheStore slice. */
|
|
104
|
+
declare function createSlice<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M extends Methods = Methods, C extends Children = Children, G extends Computed<S, C> = Computed<S, C>, N extends string = string>(options: sliceOptions<S, R, M, C, G, N>): slice<S, R, M, C, G, N>;
|
|
105
|
+
|
|
106
|
+
type StoreProviderProps = Omit<ProviderProps, "store" | "serverState" | "context"> & {
|
|
107
|
+
/** The root OrcheStore instance created with createStore(...). */
|
|
108
|
+
store: store;
|
|
109
|
+
};
|
|
110
|
+
/** Provides an OrcheStore instance to the React component tree. */
|
|
111
|
+
declare function StoreProvider(props: StoreProviderProps): React.JSX.Element;
|
|
112
|
+
|
|
113
|
+
/** Returns the current global utilities object. */
|
|
114
|
+
declare function getGlobalUtils(): GlobalUtils;
|
|
115
|
+
/** Registers or updates application-wide global utilities. */
|
|
116
|
+
declare function provideGlobalUtils(value: Partial<GlobalUtils>): GlobalUtils;
|
|
117
|
+
|
|
118
|
+
declare const OrcheStore$1: {
|
|
119
|
+
/** Creates and initializes an OrcheStore instance. */
|
|
120
|
+
createStore: typeof createStore;
|
|
121
|
+
/** Creates and initializes an OrcheStore slice. */
|
|
122
|
+
createSlice: typeof createSlice;
|
|
123
|
+
/** Provides an OrcheStore instance to the React component tree. */
|
|
124
|
+
StoreProvider: typeof StoreProvider;
|
|
125
|
+
/** Registers or updates application-wide global utilities. */
|
|
126
|
+
provideGlobalUtils: typeof provideGlobalUtils;
|
|
127
|
+
/** Returns the current global utilities object. */
|
|
128
|
+
getGlobalUtils: typeof getGlobalUtils;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export { type GlobalUtils, type orchestore as OrcheStore, type RootStore, type slice as Slice, type sliceOptions as SliceOptions, type store as Store, StoreProvider, createSlice, createStore, OrcheStore$1 as default, getGlobalUtils, provideGlobalUtils };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import{configureStore as I}from"@reduxjs/toolkit";import{createSlice as A}from"@reduxjs/toolkit";var b=[];function x(e){return b.find(t=>t.slice===e)?.redux}function v(e){let t=e,r=A({name:e.name,initialState:e.state,reducers:e.mutations});return b.push({slice:t,redux:r}),t}var u=typeof globalThis<"u"&&typeof globalThis.process<"u"&&globalThis.process?.env?.NODE_ENV!=="production",g=!1,P=globalThis.console?.log?.bind?.(globalThis.console)||globalThis.console?.log,M=globalThis.console?.warn?.bind?.(globalThis.console)||globalThis.console?.warn,k=globalThis.console?.error?.bind?.(globalThis.console)||globalThis.console?.error,j=globalThis.console?.clear?.bind?.(globalThis.console)||globalThis.console?.clear;globalThis.console?.clear&&(globalThis.console.clear=(...e)=>{g=!1,j?.(...e)});var E=`[OrcheStore] Development diagnostics are enabled.
|
|
2
|
+
Warnings and errors from OrcheStore are not shown in production builds.
|
|
3
|
+
Runtime exceptions that stop code execution may still occur.
|
|
4
|
+
Please resolve all OrcheStore warnings and errors before deploying to production.
|
|
5
|
+
`,f=()=>{g||(g=!0,P?.(E))},i={log(...e){u&&(f(),P?.(...e))},warn(...e){u&&(f(),M?.(...e))},error(...e){u&&(f(),k?.(...e))}};var a=[];function T(e){return a.find(t=>t.store===e)?.redux}function w({slices:e}){if(a.length===1)return i.warn(`[OrcheStore] createStore(...) was called more than once.
|
|
6
|
+
OrcheStore currently supports only a single global store instance and will return the existing store.
|
|
7
|
+
If you are creating a store inside a React component, create it only once, for example:
|
|
8
|
+
const [store] = useState(() => createStore(...));
|
|
9
|
+
Avoid useState(createStore(...)) because createStore(...) will be executed on every render.`),a[0].store;let t={},r={};for(let n in e){let S=e[n],m=x(S);m&&(t[n]=S,r[n]=m.reducer)}let o=I({reducer:r});return a.push({store:t,redux:o}),t}import d from"react";import{Provider as K,useDispatch as N}from"react-redux";var O=[];function q({store:e,children:t}){let r=N(),o=O.find(n=>n.store===e);return o||O.push(o={store:e,dispatch:r}),o.dispatch=r,d.createElement(d.Fragment,null,t)}function U(e){let{store:t,stabilityCheck:r,identityFunctionCheck:o}=e,n=T(t);if(!n)throw new Error("[OrcheStore] <StoreProvider> requires a store instance created with createStore(...).");return d.createElement(K,{stabilityCheck:r,identityFunctionCheck:o,store:n},d.createElement(q,{...e}))}var F=Object.assign,y=Object.getOwnPropertyDescriptor(Object,"defineProperty")?.value||Object.defineProperty,V=(e,t,r)=>{y(e,t,{get:r,enumerable:!0,configurable:!1})},_=(e,t,r)=>{y(e,t,{value:r,writable:!1,enumerable:!0,configurable:!1})},G={assign:F,defineProp:y,defineReadonly:V,defineMethod:_},C={isArray:Array.isArray},p={get:Reflect.get,set:Reflect.set,delete:Reflect.deleteProperty};var c={GetMissingProp:e=>["OrcheStore[global-utils] Attempted to access a global utility before it became available. Missing property",e,`
|
|
10
|
+
If this utility is optional, register it as undefined using provideGlobalUtils(...) to suppress future warnings.
|
|
11
|
+
`],DeleteProp:e=>["OrcheStore[global-utils] Avoid deleting properties. Trying to delete property",e,`
|
|
12
|
+
Use provideGlobalUtils(...) to set them to undefined instead for type safety.
|
|
13
|
+
`],InvalidArgs:"OrcheStore[global-utils] Expected provideGlobalUtils(...) to receive a non-null object. Received:"},h=new Proxy({},{get(e,t,r){return t in e||i.error(...c.GetMissingProp(t)),p.get(e,t,r)},set(e,t,r,o){return p.set(e,t,r,o)},deleteProperty(e,t){return i.warn(...c.DeleteProp(t)),p.delete(e,t)}});function D(){return h}function R(e){return e==null?i.error(c.InvalidArgs,e):C.isArray(e)?i.error(c.InvalidArgs,"(type: array)",e):typeof e!="object"?i.error(c.InvalidArgs,`(type: ${typeof e})`,e):G.assign(h,e),h}var J={createStore:w,createSlice:v,StoreProvider:U,provideGlobalUtils:R,getGlobalUtils:D},ye=J;export{U as StoreProvider,v as createSlice,w as createStore,ye as default,D as getGlobalUtils,R as provideGlobalUtils};
|
package/package.json
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orchestore",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A function-oriented architecture built on top of Redux Toolkit for simplifying and automating application development.",
|
|
5
5
|
"author": "Oussama Saadaoui",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"main": "./
|
|
8
|
+
"main": "./src/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
9
10
|
"types": "./dist/index.d.ts",
|
|
10
11
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
+
"start": "tsup",
|
|
13
|
+
"build": "tsup",
|
|
14
|
+
"check": "tsc --noEmit",
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
12
17
|
},
|
|
13
18
|
"exports": {
|
|
14
19
|
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
15
21
|
"import": "./dist/index.js",
|
|
16
|
-
"
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
17
23
|
}
|
|
18
24
|
},
|
|
19
25
|
"files": [
|
|
@@ -27,6 +33,21 @@
|
|
|
27
33
|
"type": "git",
|
|
28
34
|
"url": "https://github.com/saadaoui-oussama-dev/OrcheStore.git"
|
|
29
35
|
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@reduxjs/toolkit": "^2.12.0",
|
|
38
|
+
"react-redux": "^9.3.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/react": "^19.0.0",
|
|
42
|
+
"@types/react-dom": "^19.0.0",
|
|
43
|
+
"eslint": "^9.0.0",
|
|
44
|
+
"tsup": "^8.5.1",
|
|
45
|
+
"typescript": "^6.0.3"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": "^16.9.0 || ^17 || ^18 || ^19",
|
|
49
|
+
"react-dom": "^16.9.0 || ^17 || ^18 || ^19"
|
|
50
|
+
},
|
|
30
51
|
"keywords": [
|
|
31
52
|
"orchestore",
|
|
32
53
|
"store",
|
|
@@ -42,14 +63,11 @@
|
|
|
42
63
|
"react-redux",
|
|
43
64
|
"redux",
|
|
44
65
|
"redux-toolkit",
|
|
66
|
+
"redux-automation",
|
|
45
67
|
"frontend",
|
|
46
68
|
"typescript",
|
|
47
69
|
"orchestration",
|
|
48
70
|
"state-management",
|
|
49
71
|
"state-orchestration"
|
|
50
|
-
]
|
|
51
|
-
"devDependencies": {
|
|
52
|
-
"tsup": "^8.5.1",
|
|
53
|
-
"typescript": "^6.0.3"
|
|
54
|
-
}
|
|
72
|
+
]
|
|
55
73
|
}
|