orchestore 0.1.1 → 0.1.2
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 +29 -1
- package/dist/index.cjs +18 -9
- package/dist/index.d.cts +56 -17
- package/dist/index.d.ts +56 -17
- package/dist/index.js +18 -9
- package/package.json +72 -73
package/README.md
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
### 🚧 Coming Soon
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
OrcheStore is currently under active development and is not yet ready for production use.
|
|
6
|
+
|
|
7
|
+
> 📅 **Planned First Stable Release:** **2026-06-30**
|
|
8
|
+
|
|
9
|
+
> ⚠️ APIs, behavior, and internal implementation details may change without notice until the first stable release.
|
|
6
10
|
|
|
7
11
|
---
|
|
8
12
|
|
|
@@ -28,3 +32,27 @@ The goal is simple:
|
|
|
28
32
|
- Preserve predictable state transitions
|
|
29
33
|
- Maintain strong TypeScript inference
|
|
30
34
|
- Scale naturally through composition
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Release Status
|
|
39
|
+
|
|
40
|
+
### Pre-release Notice
|
|
41
|
+
|
|
42
|
+
OrcheStore is currently in a pre-release phase.
|
|
43
|
+
|
|
44
|
+
- Not recommended for production use
|
|
45
|
+
- APIs may change before the first stable release
|
|
46
|
+
- Internal architecture and runtime behavior are still evolving
|
|
47
|
+
- Documentation and feature coverage are actively being expanded
|
|
48
|
+
|
|
49
|
+
### Roadmap
|
|
50
|
+
|
|
51
|
+
| Milestone | Status |
|
|
52
|
+
| -------------------- | -------------- |
|
|
53
|
+
| Core Architecture | 🚧 In Progress |
|
|
54
|
+
| Documentation | 🚧 In Progress |
|
|
55
|
+
| Public Preview | 🚧 Planned |
|
|
56
|
+
| First Stable Release | 📅 2026-06-30 |
|
|
57
|
+
|
|
58
|
+
Stay tuned for updates.
|
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";var ee=Object.create;var R=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var ie=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},z=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of re(t))!ne.call(e,o)&&o!==r&&R(e,o,{get:()=>t[o],enumerable:!(n=te(t,o))||n.enumerable});return e};var se=(e,t,r)=>(r=e!=null?ee(oe(e)):{},z(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),ae=e=>z(R({},"__esModule",{value:!0}),e);var ve={};ie(ve,{StoreProvider:()=>G,configureDiagnostics:()=>U,createSlice:()=>L,createStore:()=>k,default:()=>xe,getGlobalUtils:()=>y,provideGlobalUtils:()=>q});module.exports=ae(ve);var Q=require("@reduxjs/toolkit");var E=require("@reduxjs/toolkit"),_=require("react-redux");var g={target:({slice:e})=>e?` Affected slice '${e}':
|
|
2
|
+
`:" ",RequiredName:e=>`[OrcheStore::${e.module}]${g.target(e)}${e.type} keys must be non-empty strings.`,InvalidName:(e,t)=>`[OrcheStore::${e.module}]${g.target(e)}${e.type} names cannot contain '.' or '/'. Received: ${t}.`,ReservedKey:(e,t)=>`[OrcheStore::${e.module}]${g.target(e)}'${t}' is a reserved name and cannot be used as a ${e.type} key.`,DuplicateKey:(e,t)=>`[OrcheStore::${e.module}]${g.target(e)}${e.type} name '${t}' conflicts with another member.`},F=(e,t)=>{if(e)if(t==="warn")console.warn(e);else if(t==="error")console.error(e);else throw new Error(e);else return!1},D=(e,t="",r="",n)=>typeof e!="string"||!e?!!F(t,n?.[0]):e.includes(".")||e.includes("/")?!!F(r,n?.[1]):!0,ce=(e,t,r)=>{let[n,o]=[g.RequiredName(e),g.InvalidName(e,t)];if(D(t,n,o,["error","error"])){if(r[0].includes(t))return console.error(g.ReservedKey(e,t));if(r[1].includes(t))return console.error(g.DuplicateKey(e,t))}else return;return!0},C=(e,t,r,n)=>(Object.entries(t).forEach(([o,c])=>{let s=ce(e,o,r)?n(o,c):void 0;if(s===void 0)return delete t[o];t[o]=s,r[1].push(o)}),t);var x="all",$={diagnostics:!1,prerelease:!1},J=globalThis.console?.log?.bind?.(globalThis.console)||globalThis.console?.log,le=globalThis.console?.warn?.bind?.(globalThis.console)||globalThis.console?.warn,de=globalThis.console?.error?.bind?.(globalThis.console)||globalThis.console?.error,ue=globalThis.console?.clear?.bind?.(globalThis.console)||globalThis.console?.clear;globalThis.console?.clear&&(globalThis.console.clear=(...e)=>{$.diagnostics=!1,ue?.(...e)});var pe=`[OrcheStore] \u{1F6A7} Pre-release Notice
|
|
3
|
+
Thank you for your interest in OrcheStore.
|
|
4
|
+
OrcheStore is currently under active development and is not yet ready for production use.
|
|
5
|
+
APIs, behavior, and internal implementation details may change without notice.
|
|
6
|
+
The first stable release is currently planned for 2026-06-30.
|
|
7
|
+
Stay tuned for updates!
|
|
8
|
+
`,fe=`[OrcheStore] Diagnostics are enabled.
|
|
9
|
+
OrcheStore may emit warnings and errors to help identify incorrect usage, invalid configurations, and potential runtime issues.
|
|
10
|
+
Runtime exceptions that stop code execution may still occur regardless of diagnostics settings.
|
|
4
11
|
Please resolve all OrcheStore warnings and errors before deploying to production.
|
|
5
|
-
|
|
12
|
+
Diagnostics can be configured with configureDiagnostics("off" | "errors" | "all").
|
|
13
|
+
`,i={inform(e){$[e]||($[e]=!0,x==="all"&&J?.(e==="prerelease"?pe:fe))},log(...e){x==="all"&&(i.inform("diagnostics"),J?.(...e))},warn(...e){x==="all"&&(i.inform("diagnostics"),le?.(...e))},error(...e){x!=="off"&&(i.inform("diagnostics"),de?.(...e))}};function U(e){x=e}var v=se(require("react"),1),P=require("react-redux");var I=[];function V(e){let t=I.find(r=>r.store===e);if(t)return t.dispatch;throw new Error("[OrcheStore] Using OrcheStore requires wrapping your application with <StoreProvider>.")}function me({store:e,children:t}){let r=(0,P.useDispatch)(),n=I.find(o=>o.store===e);return n||I.push(n={store:e,dispatch:r}),n.dispatch=r,v.default.createElement(v.default.Fragment,null,t)}function G(e){let{store:t,stabilityCheck:r,identityFunctionCheck:n}={...e||{}},o=M(t);if(!o)throw new Error("[OrcheStore::context] <StoreProvider> requires a store instance created with createStore(...).");return v.default.createElement(P.Provider,{stabilityCheck:r,identityFunctionCheck:n,store:o},v.default.createElement(me,{...e}))}var he=Object.assign,A=Object.getOwnPropertyDescriptor(Object,"defineProperty")?.value||Object.defineProperty,ge=(e,t,r)=>{A(e,t,{get:r,enumerable:!0,configurable:!1})},Se=(e,t,r)=>{A(e,t,{value:r,writable:!1,enumerable:!0,configurable:!1})},m={assign:he,defineProp:A,defineReadonly:ge,defineMethod:Se},W={isArray:Array.isArray},T={get:Reflect.get,set:Reflect.set,delete:Reflect.deleteProperty};var w={GetMissingProp:e=>["[OrcheStore::global-utils] Attempted to access a global utility before it became available. Missing property",e,`
|
|
14
|
+
If this utility is optional, register it as undefined using provideGlobalUtils(...) to suppress future warnings.
|
|
15
|
+
`],DeleteProp:e=>["[OrcheStore::global-utils] Avoid deleting properties. Trying to delete property",e,`
|
|
16
|
+
Use provideGlobalUtils(...) to set them to undefined instead for type safety.
|
|
17
|
+
`],InvalidArgs:"[OrcheStore::global-utils] Expected provideGlobalUtils(...) to receive a non-null object. Received:"},K=new Proxy({},{get(e,t,r){return t in e||i.error(...w.GetMissingProp(t)),T.get(e,t,r)},set(e,t,r,n){return T.set(e,t,r,n)},deleteProperty(e,t){return i.warn(...w.DeleteProp(t)),T.delete(e,t)}});function y(){return K}function q(e){return e==null?i.error(w.InvalidArgs,e):W.isArray(e)?i.error(w.InvalidArgs,"(type: array)",e):typeof e!="object"?i.error(w.InvalidArgs,`(type: ${typeof e})`,e):m.assign(K,e),K}function b(e,t){let r={};return Object.keys(e).filter(o=>o.startsWith(t)).map(o=>o.split(".")).sort((o,c)=>o.length-c.length).forEach(o=>{let c=r;o.slice(0,o.length-1).forEach(s=>c=c[s]||={}),c[o[o.length-1]]={...e[o.join(".")]}}),r}function X(e,t){return t.split(".").forEach(r=>e=e[r]),e}var B=[];function N(e){return B.find(t=>t.slice===e)}function L(e){i.inform("prerelease");let t={},r=ye(e),n=["name","path","state","computed","root","global","useSelect"],o=[],c=a=>({module:"createSlice",type:a,slice:r.name}),s=a=>({root:u(),rootState:a,global:y()}),u=()=>{let a=H();if(!a)throw new Error(d.RequiredStore(r.name));return a};C(c("mutation"),r.mutations,[n,o],(a,l)=>l?._reducerDefinitionType===E.ReducerType.asyncThunk||"reducer"in{...l||{}}?i.error(d.ReduxReducerConflict()):typeof l!="function"?i.error(d.InvalidMutation(a)):((j,Z)=>l(j,...Z.payload)));let p=(0,E.createSlice)({name:r.name,reducerPath:r.name,initialState:r.state,reducers:r.mutations}),h={path:r.name,slice:t,redux:p,children:{}};return m.defineReadonly(t,"name",()=>r.name),m.defineReadonly(t,"path",()=>h.path),m.defineReadonly(t,"global",()=>y()),m.defineMethod(t,"getState",()=>b(M(u()).getState(),h.path)),m.defineMethod(t,"useSelect",a=>(0,_.useSelector)(l=>{let f=s(b(l,""));return a.call(f,X(f.rootState,t.path),f)})),Object.entries(p.actions).map(([a,l])=>{t[a]=(...f)=>V(u())(l(f))}),C(c("method"),r.methods,[n,o],(a,l)=>typeof l!="function"?i.error(d.InvalidMethod(a)):t[a]=(...f)=>l.apply(t,f)),C(c("children"),r.children,[n,o],(a,l)=>N(l)?h.children[a]=l:i.error(d.InvalidChild(a))),Object.keys(r.computed).length>0&&i.warn("[OrcheStore::createSlice] Computed properties are not yet supported and will be ignored."),B.push(h),t}var ye=e=>{let t={...e||{}};if(D(t.name,d.RequiredName(),d.InvalidName(t.name)),typeof t.state=="function"){let u=t.state;t.state=()=>{let p=u();if(typeof p!="object")throw new Error(d.InvalidState(t.name));if(!p)throw new Error(d.RequiredState(t.name));return p}}else{if(typeof t.state!="object")throw new Error(d.InvalidState(t.name));if(!t.state)throw new Error(d.RequiredState(t.name))}t.mutations=typeof t.mutations=="object"&&t.mutations?{...t.mutations}:{},t.computed=typeof t.computed=="object"&&t.computed?{...t.computed}:{},t.methods=typeof t.methods=="object"&&t.methods?{...t.methods}:{},t.children=typeof t.children=="object"&&t.children?{...t.children}:{};let{reducers:r,extraReducers:n,reducerPath:o,initialState:c,selectors:s}={...t||{}};return c!==void 0&&i.warn(d.ReduxConflict("initialState")),r!==void 0&&i.warn(d.ReduxConflict("reducers")),n!==void 0&&i.warn(d.ReduxConflict("extraReducers")),o!==void 0&&i.warn(d.ReduxConflict("reducerPath")),s!==void 0&&i.warn(d.ReduxConflict("selectors")),t},d={RequiredName:()=>"[OrcheStore::createSlice] Missing required slice name. Expected a non-empty string.",InvalidName:e=>`[OrcheStore::createSlice] Slice names cannot contain '.' or '/'. Received: {${e}}`,RequiredState:e=>`[OrcheStore::createSlice] Missing required slice state for slice: {${e}}`,InvalidState:e=>`[OrcheStore::createSlice] Slice state must be a non-null object or a function that returns a non-null object. Slice: {${e}}`,ReservedKey:(e,t)=>`[OrcheStore::createSlice] '${t}' is reserved by OrcheStore and should not be provided as a ${e}.`,InvalidMutation:e=>`[OrcheStore::createSlice] Mutation '${e}' must be a function.`,InvalidMethod:e=>`[OrcheStore::createSlice] Method '${e}' must be a function.`,InvalidChild:e=>`[OrcheStore::createSlice] Child slice '${e}' must be a slice object created using createSlice(...).`,RequiredStore:e=>`[OrcheStore::slice-runtime] No root store found for slice: {${e}}. Slices must be created within the context of a store.
|
|
18
|
+
Create a store using createStore(...) and ensure that slices are accessed after the store is initialized.`,ReduxConflict:e=>`[OrcheStore::createSlice] '${e}' is a Redux Toolkit createSlice(...) option and is not applicable to OrcheStore slices. This property will be ignored.`,ReduxReducerConflict:()=>"[OrcheStore::createSlice] Redux Toolkit asyncThunk reducers are not supported in mutations. Use methods instead."};var Y=require("react-redux");var O=[];function M(e){return O.find(t=>t.store===e)?.redux}function H(){return O[0]?.store}function k({slices:e}){if(i.inform("prerelease"),O.length===1)return i.warn(`[OrcheStore::createStore] createStore(...) was called more than once.
|
|
6
19
|
OrcheStore currently supports only a single global store instance and will return the existing store.
|
|
7
20
|
If you are creating a store inside a React component, create it only once, for example:
|
|
8
21
|
const [store] = useState(() => createStore(...));
|
|
9
|
-
Avoid useState(createStore(...)) because createStore(...) will be executed on every render.`),
|
|
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});
|
|
22
|
+
Avoid useState(createStore(...)) because createStore(...) will be executed on every render.`),O[0].store;let t={},r=s=>({root:t,rootState:s,global:y()});m.defineMethod(t,"getState",()=>b(c.getState(),"")),m.defineMethod(t,"useSelect",s=>(0,Y.useSelector)(u=>{let p=r(b(u,""));return s.call(p,p.rootState,p)}));let n={},o=(s,u,p)=>{let h=N(u)||{};if(!h)return;let{redux:a,children:l}=h;h.path=s,n[s]=a.reducer,p[s]=u,Object.entries(l).forEach(([f,j])=>{o(s+"."+f,j,u)})};for(let s in e){let u=e[s];s in t||o(s,u,t)}let c=(0,Q.configureStore)({reducer:n});return O.push({store:t,redux:c}),t}var be={createStore:k,createSlice:L,StoreProvider:G,provideGlobalUtils:q,getGlobalUtils:y,configureDiagnostics:U},xe=be;0&&(module.exports={StoreProvider,configureDiagnostics,createSlice,createStore,getGlobalUtils,provideGlobalUtils});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ProviderProps } from 'react-redux';
|
|
3
3
|
|
|
4
|
-
type Dict<Value = any> = Record<string
|
|
4
|
+
type Dict<Value = any> = Record<string, Value>;
|
|
5
5
|
type Tail<T extends any[]> = T extends [any, ...infer R] ? R : T extends (infer U)[] ? U[] : never;
|
|
6
6
|
type DeepReadonly<T> = T extends (...args: any[]) => any ? T : T extends readonly (infer U)[] ? ReadonlyArray<DeepReadonly<U>> : T extends object ? {
|
|
7
7
|
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
@@ -26,9 +26,9 @@ type GlobalUtils = Definition<"global", GlobalUtilsRule, any>;
|
|
|
26
26
|
type RootStore = Definition<"root", RootStoreRule, any>;
|
|
27
27
|
|
|
28
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;
|
|
29
|
+
type ReservedKeys$1<R = {}, M = {}> = "name" | "path" | "computed" | "root" | "global" | "getState" | "useSelect" | keyof R | keyof M;
|
|
30
30
|
/** Defines the mutations available on a slice. */
|
|
31
|
-
type Mutations<S extends Dict> = Dict<(state: Omit<S, "
|
|
31
|
+
type Mutations<S extends Dict> = Dict<(state: Omit<S, "computed">, ...args: any[]) => void>;
|
|
32
32
|
/** Defines the computed functions available on a slice. */
|
|
33
33
|
type Computed<S extends Dict, C extends Dict> = Dict<(state: ExposedState<S, C>, ...args: any[]) => any>;
|
|
34
34
|
/** Defines the methods available on a slice with contextual `this` typing. */
|
|
@@ -36,7 +36,7 @@ type Methods<Context = any> = Dict<(...args: any[]) => any> & ThisType<Context>;
|
|
|
36
36
|
/** Defines the child slices nested within a slice. */
|
|
37
37
|
type Children = Dict<slice<any, Mutations<any>, Methods, Dict, Computed<any, any>, any>>;
|
|
38
38
|
/** Exposes immutable slice state with optional runtime helpers. */
|
|
39
|
-
type ExposedState<S extends Dict, C extends Children = Children
|
|
39
|
+
type ExposedState<S extends Dict, C extends Children = Children> = DeepReadonly<Omit<S, "computed">>;
|
|
40
40
|
/** Runtime slice API exposed by createSlice(...). */
|
|
41
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
42
|
/** Unique slice identifier. */
|
|
@@ -51,17 +51,26 @@ type slice<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M exten
|
|
|
51
51
|
};
|
|
52
52
|
/** Returns the latest immutable state snapshot. */
|
|
53
53
|
readonly getState: () => ExposedState<S, C>;
|
|
54
|
-
/** Subscribes to state changes within React components. */
|
|
55
|
-
readonly useSelect: <T>(selector: (state: ExposedState<S, C
|
|
54
|
+
/** Subscribes to state changes within React components. Runs with a context-bound `this` containing `root` store, `rootState` and `global` utilities. */
|
|
55
|
+
readonly useSelect: <T>(selector: (this: UseSelectContext<RootStore>, state: ExposedState<S, C>, context: UseSelectContext<any>) => T) => T;
|
|
56
56
|
} & {
|
|
57
57
|
/** Exposed mutation functions. */
|
|
58
|
-
readonly [K in Exclude<keyof R, ReservedKeys>]: (...args: Tail<Parameters<R[K]>>) => ReturnType<R[K]>;
|
|
58
|
+
readonly [K in Exclude<keyof R, ReservedKeys$1>]: (...args: Tail<Parameters<R[K]>>) => ReturnType<R[K]>;
|
|
59
59
|
} & {
|
|
60
60
|
/** Exposed method functions. */
|
|
61
|
-
readonly [K in Exclude<keyof M, ReservedKeys<R>>]: M[K];
|
|
61
|
+
readonly [K in Exclude<keyof M, ReservedKeys$1<R>>]: M[K];
|
|
62
62
|
} & {
|
|
63
63
|
/** Exposed child slices. */
|
|
64
|
-
readonly [K in Exclude<keyof C, ReservedKeys<R, M>>]: C[K];
|
|
64
|
+
readonly [K in Exclude<keyof C, ReservedKeys$1<R, M>>]: C[K];
|
|
65
|
+
};
|
|
66
|
+
/** Context available inside `useSelect`, providing access to the root store, root state snapshot, and global utilities. */
|
|
67
|
+
type UseSelectContext<RootStore extends store> = {
|
|
68
|
+
/** Root store instance. */
|
|
69
|
+
root: RootStore;
|
|
70
|
+
/** Latest root state snapshot. */
|
|
71
|
+
rootState: ReturnType<RootStore["getState"]>;
|
|
72
|
+
/** Global utilities shared across slices. */
|
|
73
|
+
global: GlobalUtils;
|
|
65
74
|
};
|
|
66
75
|
/** Configuration object used to create a slice. */
|
|
67
76
|
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> = {
|
|
@@ -81,13 +90,23 @@ type sliceOptions<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>,
|
|
|
81
90
|
children?: C;
|
|
82
91
|
};
|
|
83
92
|
|
|
84
|
-
|
|
93
|
+
/** Reserved store member names that cannot be overridden by user-defined APIs. */
|
|
94
|
+
type ReservedKeys<R = {}, M = {}> = "name" | "path" | "computed" | "root" | "global" | "getState" | "useSelect";
|
|
95
|
+
type store<C extends Children = Children> = {
|
|
96
|
+
/** Returns the latest immutable state snapshot. */
|
|
97
|
+
readonly getState: () => ExposedState<{}, C>;
|
|
98
|
+
/** Subscribes to state changes within React components. Runs with a context-bound `this` containing `global` utilities. */
|
|
99
|
+
readonly useSelect: <T>(selector: (this: UseSelectContext<RootStore>, state: ExposedState<{}, C>, context: UseSelectContext<any>) => T) => T;
|
|
100
|
+
} & {
|
|
101
|
+
/** Exposed slices. */
|
|
102
|
+
readonly [K in Exclude<keyof C, ReservedKeys>]: C[K];
|
|
103
|
+
};
|
|
85
104
|
|
|
86
105
|
type orchestore = {};
|
|
87
106
|
declare global {
|
|
88
107
|
type OrcheStore = orchestore;
|
|
89
108
|
namespace OrcheStore {
|
|
90
|
-
type Store = store
|
|
109
|
+
type Store<C extends Children = Children> = store<C>;
|
|
91
110
|
/** Runtime slice API exposed by createSlice(...). */
|
|
92
111
|
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
112
|
/** Configuration object used to create a slice. */
|
|
@@ -96,15 +115,15 @@ declare global {
|
|
|
96
115
|
}
|
|
97
116
|
|
|
98
117
|
/** Creates and initializes an OrcheStore instance. */
|
|
99
|
-
declare function createStore({ slices }: {
|
|
100
|
-
slices:
|
|
101
|
-
}): store
|
|
118
|
+
declare function createStore<C extends Children = Children>({ slices }: {
|
|
119
|
+
slices: C;
|
|
120
|
+
}): store<C>;
|
|
102
121
|
|
|
103
122
|
/** 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>(
|
|
123
|
+
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>(props: sliceOptions<S, R, M, C, G, N>): slice<S, R, M, C, G, N>;
|
|
105
124
|
|
|
106
125
|
type StoreProviderProps = Omit<ProviderProps, "store" | "serverState" | "context"> & {
|
|
107
|
-
/** The root OrcheStore instance created with createStore(...)
|
|
126
|
+
/** The root OrcheStore instance created with `createStore(...)`. */
|
|
108
127
|
store: store;
|
|
109
128
|
};
|
|
110
129
|
/** Provides an OrcheStore instance to the React component tree. */
|
|
@@ -115,6 +134,17 @@ declare function getGlobalUtils(): GlobalUtils;
|
|
|
115
134
|
/** Registers or updates application-wide global utilities. */
|
|
116
135
|
declare function provideGlobalUtils(value: Partial<GlobalUtils>): GlobalUtils;
|
|
117
136
|
|
|
137
|
+
type DiagnosticsLevel = "off" | "errors" | "all";
|
|
138
|
+
/**
|
|
139
|
+
* Configures OrcheStore diagnostics output.
|
|
140
|
+
*
|
|
141
|
+
* Levels:
|
|
142
|
+
* - "off" - disables all output
|
|
143
|
+
* - "errors" - shows errors only
|
|
144
|
+
* - "all" - shows logs, warnings, and errors
|
|
145
|
+
*/
|
|
146
|
+
declare function configureDiagnostics(level: DiagnosticsLevel): void;
|
|
147
|
+
|
|
118
148
|
declare const OrcheStore$1: {
|
|
119
149
|
/** Creates and initializes an OrcheStore instance. */
|
|
120
150
|
createStore: typeof createStore;
|
|
@@ -126,6 +156,15 @@ declare const OrcheStore$1: {
|
|
|
126
156
|
provideGlobalUtils: typeof provideGlobalUtils;
|
|
127
157
|
/** Returns the current global utilities object. */
|
|
128
158
|
getGlobalUtils: typeof getGlobalUtils;
|
|
159
|
+
/**
|
|
160
|
+
* Configures OrcheStore diagnostics output.
|
|
161
|
+
*
|
|
162
|
+
* Levels:
|
|
163
|
+
* - "off" - disables all output
|
|
164
|
+
* - "errors" - shows errors only
|
|
165
|
+
* - "all" - shows logs, warnings, and errors
|
|
166
|
+
*/
|
|
167
|
+
configureDiagnostics: typeof configureDiagnostics;
|
|
129
168
|
};
|
|
130
169
|
|
|
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 };
|
|
170
|
+
export { type GlobalUtils, type orchestore as OrcheStore, type RootStore, type slice as Slice, type sliceOptions as SliceOptions, type store as Store, StoreProvider, configureDiagnostics, createSlice, createStore, OrcheStore$1 as default, getGlobalUtils, provideGlobalUtils };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ProviderProps } from 'react-redux';
|
|
3
3
|
|
|
4
|
-
type Dict<Value = any> = Record<string
|
|
4
|
+
type Dict<Value = any> = Record<string, Value>;
|
|
5
5
|
type Tail<T extends any[]> = T extends [any, ...infer R] ? R : T extends (infer U)[] ? U[] : never;
|
|
6
6
|
type DeepReadonly<T> = T extends (...args: any[]) => any ? T : T extends readonly (infer U)[] ? ReadonlyArray<DeepReadonly<U>> : T extends object ? {
|
|
7
7
|
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
@@ -26,9 +26,9 @@ type GlobalUtils = Definition<"global", GlobalUtilsRule, any>;
|
|
|
26
26
|
type RootStore = Definition<"root", RootStoreRule, any>;
|
|
27
27
|
|
|
28
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;
|
|
29
|
+
type ReservedKeys$1<R = {}, M = {}> = "name" | "path" | "computed" | "root" | "global" | "getState" | "useSelect" | keyof R | keyof M;
|
|
30
30
|
/** Defines the mutations available on a slice. */
|
|
31
|
-
type Mutations<S extends Dict> = Dict<(state: Omit<S, "
|
|
31
|
+
type Mutations<S extends Dict> = Dict<(state: Omit<S, "computed">, ...args: any[]) => void>;
|
|
32
32
|
/** Defines the computed functions available on a slice. */
|
|
33
33
|
type Computed<S extends Dict, C extends Dict> = Dict<(state: ExposedState<S, C>, ...args: any[]) => any>;
|
|
34
34
|
/** Defines the methods available on a slice with contextual `this` typing. */
|
|
@@ -36,7 +36,7 @@ type Methods<Context = any> = Dict<(...args: any[]) => any> & ThisType<Context>;
|
|
|
36
36
|
/** Defines the child slices nested within a slice. */
|
|
37
37
|
type Children = Dict<slice<any, Mutations<any>, Methods, Dict, Computed<any, any>, any>>;
|
|
38
38
|
/** Exposes immutable slice state with optional runtime helpers. */
|
|
39
|
-
type ExposedState<S extends Dict, C extends Children = Children
|
|
39
|
+
type ExposedState<S extends Dict, C extends Children = Children> = DeepReadonly<Omit<S, "computed">>;
|
|
40
40
|
/** Runtime slice API exposed by createSlice(...). */
|
|
41
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
42
|
/** Unique slice identifier. */
|
|
@@ -51,17 +51,26 @@ type slice<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>, M exten
|
|
|
51
51
|
};
|
|
52
52
|
/** Returns the latest immutable state snapshot. */
|
|
53
53
|
readonly getState: () => ExposedState<S, C>;
|
|
54
|
-
/** Subscribes to state changes within React components. */
|
|
55
|
-
readonly useSelect: <T>(selector: (state: ExposedState<S, C
|
|
54
|
+
/** Subscribes to state changes within React components. Runs with a context-bound `this` containing `root` store, `rootState` and `global` utilities. */
|
|
55
|
+
readonly useSelect: <T>(selector: (this: UseSelectContext<RootStore>, state: ExposedState<S, C>, context: UseSelectContext<any>) => T) => T;
|
|
56
56
|
} & {
|
|
57
57
|
/** Exposed mutation functions. */
|
|
58
|
-
readonly [K in Exclude<keyof R, ReservedKeys>]: (...args: Tail<Parameters<R[K]>>) => ReturnType<R[K]>;
|
|
58
|
+
readonly [K in Exclude<keyof R, ReservedKeys$1>]: (...args: Tail<Parameters<R[K]>>) => ReturnType<R[K]>;
|
|
59
59
|
} & {
|
|
60
60
|
/** Exposed method functions. */
|
|
61
|
-
readonly [K in Exclude<keyof M, ReservedKeys<R>>]: M[K];
|
|
61
|
+
readonly [K in Exclude<keyof M, ReservedKeys$1<R>>]: M[K];
|
|
62
62
|
} & {
|
|
63
63
|
/** Exposed child slices. */
|
|
64
|
-
readonly [K in Exclude<keyof C, ReservedKeys<R, M>>]: C[K];
|
|
64
|
+
readonly [K in Exclude<keyof C, ReservedKeys$1<R, M>>]: C[K];
|
|
65
|
+
};
|
|
66
|
+
/** Context available inside `useSelect`, providing access to the root store, root state snapshot, and global utilities. */
|
|
67
|
+
type UseSelectContext<RootStore extends store> = {
|
|
68
|
+
/** Root store instance. */
|
|
69
|
+
root: RootStore;
|
|
70
|
+
/** Latest root state snapshot. */
|
|
71
|
+
rootState: ReturnType<RootStore["getState"]>;
|
|
72
|
+
/** Global utilities shared across slices. */
|
|
73
|
+
global: GlobalUtils;
|
|
65
74
|
};
|
|
66
75
|
/** Configuration object used to create a slice. */
|
|
67
76
|
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> = {
|
|
@@ -81,13 +90,23 @@ type sliceOptions<S extends Dict = Dict, R extends Mutations<S> = Mutations<S>,
|
|
|
81
90
|
children?: C;
|
|
82
91
|
};
|
|
83
92
|
|
|
84
|
-
|
|
93
|
+
/** Reserved store member names that cannot be overridden by user-defined APIs. */
|
|
94
|
+
type ReservedKeys<R = {}, M = {}> = "name" | "path" | "computed" | "root" | "global" | "getState" | "useSelect";
|
|
95
|
+
type store<C extends Children = Children> = {
|
|
96
|
+
/** Returns the latest immutable state snapshot. */
|
|
97
|
+
readonly getState: () => ExposedState<{}, C>;
|
|
98
|
+
/** Subscribes to state changes within React components. Runs with a context-bound `this` containing `global` utilities. */
|
|
99
|
+
readonly useSelect: <T>(selector: (this: UseSelectContext<RootStore>, state: ExposedState<{}, C>, context: UseSelectContext<any>) => T) => T;
|
|
100
|
+
} & {
|
|
101
|
+
/** Exposed slices. */
|
|
102
|
+
readonly [K in Exclude<keyof C, ReservedKeys>]: C[K];
|
|
103
|
+
};
|
|
85
104
|
|
|
86
105
|
type orchestore = {};
|
|
87
106
|
declare global {
|
|
88
107
|
type OrcheStore = orchestore;
|
|
89
108
|
namespace OrcheStore {
|
|
90
|
-
type Store = store
|
|
109
|
+
type Store<C extends Children = Children> = store<C>;
|
|
91
110
|
/** Runtime slice API exposed by createSlice(...). */
|
|
92
111
|
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
112
|
/** Configuration object used to create a slice. */
|
|
@@ -96,15 +115,15 @@ declare global {
|
|
|
96
115
|
}
|
|
97
116
|
|
|
98
117
|
/** Creates and initializes an OrcheStore instance. */
|
|
99
|
-
declare function createStore({ slices }: {
|
|
100
|
-
slices:
|
|
101
|
-
}): store
|
|
118
|
+
declare function createStore<C extends Children = Children>({ slices }: {
|
|
119
|
+
slices: C;
|
|
120
|
+
}): store<C>;
|
|
102
121
|
|
|
103
122
|
/** 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>(
|
|
123
|
+
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>(props: sliceOptions<S, R, M, C, G, N>): slice<S, R, M, C, G, N>;
|
|
105
124
|
|
|
106
125
|
type StoreProviderProps = Omit<ProviderProps, "store" | "serverState" | "context"> & {
|
|
107
|
-
/** The root OrcheStore instance created with createStore(...)
|
|
126
|
+
/** The root OrcheStore instance created with `createStore(...)`. */
|
|
108
127
|
store: store;
|
|
109
128
|
};
|
|
110
129
|
/** Provides an OrcheStore instance to the React component tree. */
|
|
@@ -115,6 +134,17 @@ declare function getGlobalUtils(): GlobalUtils;
|
|
|
115
134
|
/** Registers or updates application-wide global utilities. */
|
|
116
135
|
declare function provideGlobalUtils(value: Partial<GlobalUtils>): GlobalUtils;
|
|
117
136
|
|
|
137
|
+
type DiagnosticsLevel = "off" | "errors" | "all";
|
|
138
|
+
/**
|
|
139
|
+
* Configures OrcheStore diagnostics output.
|
|
140
|
+
*
|
|
141
|
+
* Levels:
|
|
142
|
+
* - "off" - disables all output
|
|
143
|
+
* - "errors" - shows errors only
|
|
144
|
+
* - "all" - shows logs, warnings, and errors
|
|
145
|
+
*/
|
|
146
|
+
declare function configureDiagnostics(level: DiagnosticsLevel): void;
|
|
147
|
+
|
|
118
148
|
declare const OrcheStore$1: {
|
|
119
149
|
/** Creates and initializes an OrcheStore instance. */
|
|
120
150
|
createStore: typeof createStore;
|
|
@@ -126,6 +156,15 @@ declare const OrcheStore$1: {
|
|
|
126
156
|
provideGlobalUtils: typeof provideGlobalUtils;
|
|
127
157
|
/** Returns the current global utilities object. */
|
|
128
158
|
getGlobalUtils: typeof getGlobalUtils;
|
|
159
|
+
/**
|
|
160
|
+
* Configures OrcheStore diagnostics output.
|
|
161
|
+
*
|
|
162
|
+
* Levels:
|
|
163
|
+
* - "off" - disables all output
|
|
164
|
+
* - "errors" - shows errors only
|
|
165
|
+
* - "all" - shows logs, warnings, and errors
|
|
166
|
+
*/
|
|
167
|
+
configureDiagnostics: typeof configureDiagnostics;
|
|
129
168
|
};
|
|
130
169
|
|
|
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 };
|
|
170
|
+
export { type GlobalUtils, type orchestore as OrcheStore, type RootStore, type slice as Slice, type sliceOptions as SliceOptions, type store as Store, StoreProvider, configureDiagnostics, createSlice, createStore, OrcheStore$1 as default, getGlobalUtils, provideGlobalUtils };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import{configureStore as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import{configureStore as de}from"@reduxjs/toolkit";import{createSlice as se,ReducerType as ae}from"@reduxjs/toolkit";import{useSelector as ce}from"react-redux";var g={target:({slice:e})=>e?` Affected slice '${e}':
|
|
2
|
+
`:" ",RequiredName:e=>`[OrcheStore::${e.module}]${g.target(e)}${e.type} keys must be non-empty strings.`,InvalidName:(e,t)=>`[OrcheStore::${e.module}]${g.target(e)}${e.type} names cannot contain '.' or '/'. Received: ${t}.`,ReservedKey:(e,t)=>`[OrcheStore::${e.module}]${g.target(e)}'${t}' is a reserved name and cannot be used as a ${e.type} key.`,DuplicateKey:(e,t)=>`[OrcheStore::${e.module}]${g.target(e)}${e.type} name '${t}' conflicts with another member.`},G=(e,t)=>{if(e)if(t==="warn")console.warn(e);else if(t==="error")console.error(e);else throw new Error(e);else return!1},E=(e,t="",r="",n)=>typeof e!="string"||!e?!!G(t,n?.[0]):e.includes(".")||e.includes("/")?!!G(r,n?.[1]):!0,_=(e,t,r)=>{let[n,o]=[g.RequiredName(e),g.InvalidName(e,t)];if(E(t,n,o,["error","error"])){if(r[0].includes(t))return console.error(g.ReservedKey(e,t));if(r[1].includes(t))return console.error(g.DuplicateKey(e,t))}else return;return!0},R=(e,t,r,n)=>(Object.entries(t).forEach(([o,c])=>{let s=_(e,o,r)?n(o,c):void 0;if(s===void 0)return delete t[o];t[o]=s,r[1].push(o)}),t);var v="all",j={diagnostics:!1,prerelease:!1},A=globalThis.console?.log?.bind?.(globalThis.console)||globalThis.console?.log,B=globalThis.console?.warn?.bind?.(globalThis.console)||globalThis.console?.warn,H=globalThis.console?.error?.bind?.(globalThis.console)||globalThis.console?.error,Q=globalThis.console?.clear?.bind?.(globalThis.console)||globalThis.console?.clear;globalThis.console?.clear&&(globalThis.console.clear=(...e)=>{j.diagnostics=!1,Q?.(...e)});var Y=`[OrcheStore] \u{1F6A7} Pre-release Notice
|
|
3
|
+
Thank you for your interest in OrcheStore.
|
|
4
|
+
OrcheStore is currently under active development and is not yet ready for production use.
|
|
5
|
+
APIs, behavior, and internal implementation details may change without notice.
|
|
6
|
+
The first stable release is currently planned for 2026-06-30.
|
|
7
|
+
Stay tuned for updates!
|
|
8
|
+
`,Z=`[OrcheStore] Diagnostics are enabled.
|
|
9
|
+
OrcheStore may emit warnings and errors to help identify incorrect usage, invalid configurations, and potential runtime issues.
|
|
10
|
+
Runtime exceptions that stop code execution may still occur regardless of diagnostics settings.
|
|
4
11
|
Please resolve all OrcheStore warnings and errors before deploying to production.
|
|
5
|
-
|
|
12
|
+
Diagnostics can be configured with configureDiagnostics("off" | "errors" | "all").
|
|
13
|
+
`,i={inform(e){j[e]||(j[e]=!0,v==="all"&&A?.(e==="prerelease"?Y:Z))},log(...e){v==="all"&&(i.inform("diagnostics"),A?.(...e))},warn(...e){v==="all"&&(i.inform("diagnostics"),B?.(...e))},error(...e){v!=="off"&&(i.inform("diagnostics"),H?.(...e))}};function K(e){v=e}import C from"react";import{Provider as ee,useDispatch as te}from"react-redux";var D=[];function q(e){let t=D.find(r=>r.store===e);if(t)return t.dispatch;throw new Error("[OrcheStore] Using OrcheStore requires wrapping your application with <StoreProvider>.")}function re({store:e,children:t}){let r=te(),n=D.find(o=>o.store===e);return n||D.push(n={store:e,dispatch:r}),n.dispatch=r,C.createElement(C.Fragment,null,t)}function N(e){let{store:t,stabilityCheck:r,identityFunctionCheck:n}={...e||{}},o=P(t);if(!o)throw new Error("[OrcheStore::context] <StoreProvider> requires a store instance created with createStore(...).");return C.createElement(ee,{stabilityCheck:r,identityFunctionCheck:n,store:o},C.createElement(re,{...e}))}var oe=Object.assign,$=Object.getOwnPropertyDescriptor(Object,"defineProperty")?.value||Object.defineProperty,ne=(e,t,r)=>{$(e,t,{get:r,enumerable:!0,configurable:!1})},ie=(e,t,r)=>{$(e,t,{value:r,writable:!1,enumerable:!0,configurable:!1})},m={assign:oe,defineProp:$,defineReadonly:ne,defineMethod:ie},L={isArray:Array.isArray},M={get:Reflect.get,set:Reflect.set,delete:Reflect.deleteProperty};var w={GetMissingProp:e=>["[OrcheStore::global-utils] Attempted to access a global utility before it became available. Missing property",e,`
|
|
14
|
+
If this utility is optional, register it as undefined using provideGlobalUtils(...) to suppress future warnings.
|
|
15
|
+
`],DeleteProp:e=>["[OrcheStore::global-utils] Avoid deleting properties. Trying to delete property",e,`
|
|
16
|
+
Use provideGlobalUtils(...) to set them to undefined instead for type safety.
|
|
17
|
+
`],InvalidArgs:"[OrcheStore::global-utils] Expected provideGlobalUtils(...) to receive a non-null object. Received:"},U=new Proxy({},{get(e,t,r){return t in e||i.error(...w.GetMissingProp(t)),M.get(e,t,r)},set(e,t,r,n){return M.set(e,t,r,n)},deleteProperty(e,t){return i.warn(...w.DeleteProp(t)),M.delete(e,t)}});function b(){return U}function k(e){return e==null?i.error(w.InvalidArgs,e):L.isArray(e)?i.error(w.InvalidArgs,"(type: array)",e):typeof e!="object"?i.error(w.InvalidArgs,`(type: ${typeof e})`,e):m.assign(U,e),U}function x(e,t){let r={};return Object.keys(e).filter(o=>o.startsWith(t)).map(o=>o.split(".")).sort((o,c)=>o.length-c.length).forEach(o=>{let c=r;o.slice(0,o.length-1).forEach(s=>c=c[s]||={}),c[o[o.length-1]]={...e[o.join(".")]}}),r}function z(e,t){return t.split(".").forEach(r=>e=e[r]),e}var F=[];function I(e){return F.find(t=>t.slice===e)}function J(e){i.inform("prerelease");let t={},r=le(e),n=["name","path","state","computed","root","global","useSelect"],o=[],c=a=>({module:"createSlice",type:a,slice:r.name}),s=a=>({root:u(),rootState:a,global:b()}),u=()=>{let a=V();if(!a)throw new Error(d.RequiredStore(r.name));return a};R(c("mutation"),r.mutations,[n,o],(a,l)=>l?._reducerDefinitionType===ae.asyncThunk||"reducer"in{...l||{}}?i.error(d.ReduxReducerConflict()):typeof l!="function"?i.error(d.InvalidMutation(a)):((T,X)=>l(T,...X.payload)));let p=se({name:r.name,reducerPath:r.name,initialState:r.state,reducers:r.mutations}),h={path:r.name,slice:t,redux:p,children:{}};return m.defineReadonly(t,"name",()=>r.name),m.defineReadonly(t,"path",()=>h.path),m.defineReadonly(t,"global",()=>b()),m.defineMethod(t,"getState",()=>x(P(u()).getState(),h.path)),m.defineMethod(t,"useSelect",a=>ce(l=>{let f=s(x(l,""));return a.call(f,z(f.rootState,t.path),f)})),Object.entries(p.actions).map(([a,l])=>{t[a]=(...f)=>q(u())(l(f))}),R(c("method"),r.methods,[n,o],(a,l)=>typeof l!="function"?i.error(d.InvalidMethod(a)):t[a]=(...f)=>l.apply(t,f)),R(c("children"),r.children,[n,o],(a,l)=>I(l)?h.children[a]=l:i.error(d.InvalidChild(a))),Object.keys(r.computed).length>0&&i.warn("[OrcheStore::createSlice] Computed properties are not yet supported and will be ignored."),F.push(h),t}var le=e=>{let t={...e||{}};if(E(t.name,d.RequiredName(),d.InvalidName(t.name)),typeof t.state=="function"){let u=t.state;t.state=()=>{let p=u();if(typeof p!="object")throw new Error(d.InvalidState(t.name));if(!p)throw new Error(d.RequiredState(t.name));return p}}else{if(typeof t.state!="object")throw new Error(d.InvalidState(t.name));if(!t.state)throw new Error(d.RequiredState(t.name))}t.mutations=typeof t.mutations=="object"&&t.mutations?{...t.mutations}:{},t.computed=typeof t.computed=="object"&&t.computed?{...t.computed}:{},t.methods=typeof t.methods=="object"&&t.methods?{...t.methods}:{},t.children=typeof t.children=="object"&&t.children?{...t.children}:{};let{reducers:r,extraReducers:n,reducerPath:o,initialState:c,selectors:s}={...t||{}};return c!==void 0&&i.warn(d.ReduxConflict("initialState")),r!==void 0&&i.warn(d.ReduxConflict("reducers")),n!==void 0&&i.warn(d.ReduxConflict("extraReducers")),o!==void 0&&i.warn(d.ReduxConflict("reducerPath")),s!==void 0&&i.warn(d.ReduxConflict("selectors")),t},d={RequiredName:()=>"[OrcheStore::createSlice] Missing required slice name. Expected a non-empty string.",InvalidName:e=>`[OrcheStore::createSlice] Slice names cannot contain '.' or '/'. Received: {${e}}`,RequiredState:e=>`[OrcheStore::createSlice] Missing required slice state for slice: {${e}}`,InvalidState:e=>`[OrcheStore::createSlice] Slice state must be a non-null object or a function that returns a non-null object. Slice: {${e}}`,ReservedKey:(e,t)=>`[OrcheStore::createSlice] '${t}' is reserved by OrcheStore and should not be provided as a ${e}.`,InvalidMutation:e=>`[OrcheStore::createSlice] Mutation '${e}' must be a function.`,InvalidMethod:e=>`[OrcheStore::createSlice] Method '${e}' must be a function.`,InvalidChild:e=>`[OrcheStore::createSlice] Child slice '${e}' must be a slice object created using createSlice(...).`,RequiredStore:e=>`[OrcheStore::slice-runtime] No root store found for slice: {${e}}. Slices must be created within the context of a store.
|
|
18
|
+
Create a store using createStore(...) and ensure that slices are accessed after the store is initialized.`,ReduxConflict:e=>`[OrcheStore::createSlice] '${e}' is a Redux Toolkit createSlice(...) option and is not applicable to OrcheStore slices. This property will be ignored.`,ReduxReducerConflict:()=>"[OrcheStore::createSlice] Redux Toolkit asyncThunk reducers are not supported in mutations. Use methods instead."};import{useSelector as ue}from"react-redux";var O=[];function P(e){return O.find(t=>t.store===e)?.redux}function V(){return O[0]?.store}function W({slices:e}){if(i.inform("prerelease"),O.length===1)return i.warn(`[OrcheStore::createStore] createStore(...) was called more than once.
|
|
6
19
|
OrcheStore currently supports only a single global store instance and will return the existing store.
|
|
7
20
|
If you are creating a store inside a React component, create it only once, for example:
|
|
8
21
|
const [store] = useState(() => createStore(...));
|
|
9
|
-
Avoid useState(createStore(...)) because createStore(...) will be executed on every render.`),
|
|
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};
|
|
22
|
+
Avoid useState(createStore(...)) because createStore(...) will be executed on every render.`),O[0].store;let t={},r=s=>({root:t,rootState:s,global:b()});m.defineMethod(t,"getState",()=>x(c.getState(),"")),m.defineMethod(t,"useSelect",s=>ue(u=>{let p=r(x(u,""));return s.call(p,p.rootState,p)}));let n={},o=(s,u,p)=>{let h=I(u)||{};if(!h)return;let{redux:a,children:l}=h;h.path=s,n[s]=a.reducer,p[s]=u,Object.entries(l).forEach(([f,T])=>{o(s+"."+f,T,u)})};for(let s in e){let u=e[s];s in t||o(s,u,t)}let c=de({reducer:n});return O.push({store:t,redux:c}),t}var pe={createStore:W,createSlice:J,StoreProvider:N,provideGlobalUtils:k,getGlobalUtils:b,configureDiagnostics:K},tt=pe;export{N as StoreProvider,K as configureDiagnostics,J as createSlice,W as createStore,tt as default,b as getGlobalUtils,k as provideGlobalUtils};
|
package/package.json
CHANGED
|
@@ -1,73 +1,72 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "orchestore",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "A function-oriented architecture built on top of Redux Toolkit for simplifying and automating application development.",
|
|
5
|
-
"author": "Oussama Saadaoui",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "./src/index.cjs",
|
|
9
|
-
"module": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"start": "tsup",
|
|
13
|
-
"build": "tsup",
|
|
14
|
-
"check": "tsc --noEmit",
|
|
15
|
-
"lint": "eslint ."
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"@types/react": "^19.0.0",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"react": "^16.9.0 || ^17 || ^18 || ^19"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"global-
|
|
57
|
-
"
|
|
58
|
-
"typed-
|
|
59
|
-
"
|
|
60
|
-
"react",
|
|
61
|
-
"react-
|
|
62
|
-
"react-
|
|
63
|
-
"
|
|
64
|
-
"redux",
|
|
65
|
-
"redux-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"state-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "orchestore",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "A function-oriented architecture built on top of Redux Toolkit for simplifying and automating application development.",
|
|
5
|
+
"author": "Oussama Saadaoui",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./src/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "tsup && node scripts/pack.mjs",
|
|
13
|
+
"build": "tsup && node scripts/pack.mjs",
|
|
14
|
+
"check": "tsc --noEmit",
|
|
15
|
+
"lint": "eslint ."
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"require": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"homepage": "https://github.com/saadaoui-oussama-dev/OrcheStore#readme",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/saadaoui-oussama-dev/OrcheStore/issues"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/saadaoui-oussama-dev/OrcheStore.git"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@reduxjs/toolkit": "^2.12.0",
|
|
37
|
+
"react-redux": "^9.3.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/react": "^19.0.0",
|
|
41
|
+
"@types/react-dom": "^19.0.0",
|
|
42
|
+
"eslint": "^9.0.0",
|
|
43
|
+
"tsup": "^8.5.1",
|
|
44
|
+
"typescript": "^6.0.3"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": "^16.9.0 || ^17 || ^18 || ^19",
|
|
48
|
+
"react-dom": "^16.9.0 || ^17 || ^18 || ^19"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"orchestore",
|
|
52
|
+
"store",
|
|
53
|
+
"slice",
|
|
54
|
+
"state",
|
|
55
|
+
"global-store",
|
|
56
|
+
"global-state",
|
|
57
|
+
"typed-store",
|
|
58
|
+
"typed-state",
|
|
59
|
+
"react",
|
|
60
|
+
"react-store",
|
|
61
|
+
"react-state",
|
|
62
|
+
"react-redux",
|
|
63
|
+
"redux",
|
|
64
|
+
"redux-toolkit",
|
|
65
|
+
"redux-automation",
|
|
66
|
+
"frontend",
|
|
67
|
+
"typescript",
|
|
68
|
+
"orchestration",
|
|
69
|
+
"state-management",
|
|
70
|
+
"state-orchestration"
|
|
71
|
+
]
|
|
72
|
+
}
|