orchestore 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,183 @@
1
- import React from 'react';
1
+ import { ConfigureStoreOptions } from '@reduxjs/toolkit';
2
2
  import { ProviderProps } from 'react-redux';
3
3
 
4
+ type NodePrototype<N, A extends any[] = []> = {
5
+ /**
6
+ * Creates a new detached instance within the same lineage.
7
+ *
8
+ * The cloned instance is fully independent at runtime, but still
9
+ * linked to the original definition family.
10
+ */
11
+ readonly clone: (...args: A) => N;
12
+ /**
13
+ * Returns all instances that belong to the same lineage family,
14
+ * including the current instance.
15
+ */
16
+ readonly getLineage: () => N[];
17
+ /**
18
+ * Returns all other instances in the same lineage,
19
+ * excluding the current instance.
20
+ */
21
+ readonly getClones: () => N[];
22
+ /**
23
+ * Checks whether another instance belongs to the same lineage.
24
+ *
25
+ * Useful for verifying whether two slices originate from the same definition,
26
+ * even if they are different runtime instances.
27
+ */
28
+ readonly isTypeOf: (other?: any) => other is N;
29
+ };
30
+
31
+ declare global {
32
+ namespace OrcheStore {
33
+ /** User-defined framework type slots. */
34
+ interface Slots {
35
+ }
36
+ }
37
+ }
38
+ /** Resolves a type slot with validation and fallback support. */
39
+ 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;
40
+ /** Resolved type for application-wide utilities. */
41
+ type Utils = {
42
+ /**
43
+ * Application-wide utilities shared across all slices and the store.
44
+ *
45
+ * Utilities provide a global place to register and access runtime services such as:
46
+ * navigation, notifications, API clients, analytics, and other shared helpers.
47
+ *
48
+ * Once registered, utilities are available everywhere in the application:
49
+ * - inside slices via `this.utils`
50
+ * - from the root store via `store.utils`
51
+ * - directly via `getUtils()`
52
+ *
53
+ * Utilities can be updated at runtime using `setUtils`, and all updates are
54
+ * immediately reflected across the entire store tree.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * // Register utilities
59
+ * setUtils({
60
+ * notify(type, message) {
61
+ * console.log(type, message);
62
+ * },
63
+ * });
64
+ *
65
+ * // Inside a slice
66
+ * const userSlice = createSlice({
67
+ * name: "user",
68
+ * state: { loading: false },
69
+ *
70
+ * methods: {
71
+ * login() {
72
+ * this.utils.notify("success", "Login successful");
73
+ * },
74
+ * },
75
+ * });
76
+ *
77
+ * // From the store
78
+ * store.utils.notify("info", "App started");
79
+ *
80
+ * // Direct access
81
+ * const utils = getUtils();
82
+ * utils.notify("success", "Hello");
83
+ * ```
84
+ */
85
+ utils: Definition<"utils", Dict, any>;
86
+ };
87
+
88
+ /**
89
+ * Runtime API returned by `createStore()`.
90
+ *
91
+ * The store represents the root of the OrcheStore runtime tree and provides
92
+ * access to all mounted slices, global state, and shared utilities.
93
+ */
94
+ type store<C> = OmitNever<Utils & {
95
+ /** Unique name of the store. */
96
+ readonly name: string;
97
+ /**
98
+ * Returns the current immutable state snapshot of the entire store tree.
99
+ *
100
+ * Includes all mounted slices and nested state.
101
+ */
102
+ readonly getState: () => StoreState<C>;
103
+ /**
104
+ * Subscribes to store state changes inside React components.
105
+ *
106
+ * The selector receives the full store state along with a context
107
+ * containing shared utilities.
108
+ *
109
+ * This hook is bound to the store instance and requires `StoreProvider`
110
+ * to be mounted in the React tree.
111
+ */
112
+ readonly useSelect: <T>(selector: (this: Utils, state: StoreState<C>, context: Utils) => T) => T;
113
+ } & {
114
+ /** Root mounted slice instances. */
115
+ readonly [K in Exclude<keyof C, ReservedStoreKeys>]: C[K] extends slice<infer S, infer R, infer M, infer C> ? slice<S, R, M, C> : never;
116
+ }>;
117
+ /**
118
+ * Configuration used to create a store instance.
119
+ *
120
+ * A store is composed of multiple slices that are mounted into a single
121
+ * runtime tree. Each slice becomes accessible directly through the store API.
122
+ */
123
+ type storeOptions<C> = Omit<ConfigureStoreOptions, "reducer" | "middleware" | "duplicateMiddlewareCheck" | "preloadedState" | "enhancers"> & {
124
+ /** Unique name of the store. */
125
+ readonly name?: string;
126
+ /**
127
+ * Collection of slices registered in this store.
128
+ *
129
+ * Each slice is mounted and becomes available as:
130
+ * `store.<sliceKey>`
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * const store = createStore({
135
+ * slices: {
136
+ * counter,
137
+ * user,
138
+ * },
139
+ * });
140
+ *
141
+ * // Exposed slices access
142
+ * store.user.getState();
143
+ * store.counter.increment();
144
+ * store.counter.useSelect((state) => state.value);
145
+ *
146
+ * // State tree access
147
+ * store.getState().counter.value;
148
+ * store.useSelect((state) => state.counter.value);
149
+ * ```
150
+ */
151
+ slices: C;
152
+ };
153
+ /**
154
+ * Derived immutable state shape of the store.
155
+ *
156
+ * Represents the full read-only state tree including all mounted slices.
157
+ */
158
+ type StoreState<C> = ReadOnly<OmitNever<{
159
+ readonly [K in Exclude<keyof C, ReservedStoreKeys>]: C[K] extends slice<infer S, infer _, infer __, infer C> ? SliceState.State<S, C> : never;
160
+ }>>;
161
+ /**
162
+ * Props for the OrcheStore React provider.
163
+ *
164
+ * Wraps the application and injects the store into React-Redux context.
165
+ */
166
+ type StoreProviderProps<T = any> = Omit<ProviderProps, "store" | "serverState" | "context"> & {
167
+ /**
168
+ * Root store instance created with `createStore()`.
169
+ *
170
+ * This store will be injected into the React component tree.
171
+ */
172
+ store: store<T>;
173
+ };
174
+ /**
175
+ * Property names reserved by the framework.
176
+ *
177
+ * These names cannot be used for child slices.
178
+ */
179
+ type ReservedStoreKeys<R = {}, M = {}> = ("name" | "computed" | "utils" | "getState" | "useSelect") | (keyof R | keyof M);
180
+
4
181
  /** `Record` with string keys, requiring only the value type. */
5
182
  type Dict<Value = any> = Record<string, Value>;
6
183
  /** `Record` with default property keys, requiring only the value type. */
@@ -16,63 +193,181 @@ type ReadOnly<T> = T extends (...args: any[]) => any ? T : T extends readonly (i
16
193
  readonly [K in keyof T]: ReadOnly<T[K]>;
17
194
  } : T;
18
195
 
19
- /** Runtime slice API exposed by createSlice(...). */
20
- type slice<S extends Obj, R extends Mutations<S, C>, M, C> = GlobalUtils & {
21
- /** Unique slice identifier. */
196
+ /** Runtime API returned by `createSlice()`. */
197
+ type slice<S extends Obj, R extends Mutations<S, C>, M, C> = Utils & {
198
+ /** Unique name of the slice. */
22
199
  readonly name: string;
23
- /** Fully qualified runtime path of the slice. */
200
+ /** Dot-separated path of this slice within the mounted store tree. */
24
201
  readonly path: string;
25
- /** Returns the latest immutable state snapshot. */
26
- readonly getState: () => SliceState.State<S, C>;
27
- /** Subscribes to state changes within React components. Runs with a context-bound `this` containing `root` store, `rootState` and `global` utilities. */
28
- readonly useSelect: <T>(selector: (this: GlobalUtils, state: SliceState.State<S, C>, context: GlobalUtils) => T) => T;
29
- /** Root store that owns this slice instance. */
202
+ /** Root store instance that owns this slice. */
30
203
  root: store<any>;
31
- /** Parent slice in the hierarchy, if mounted under another slice. */
204
+ /** Parent slice in the runtime tree, or `undefined` if this is a root slice. */
32
205
  parent: slice<any, Mutations<any, any>, any, any> | undefined;
33
- /** Runtime lineage and cloning utilities for this slice instance. */
34
- readonly prototype: {
35
- /** Creates a new detached clone within the same lineage. */
36
- readonly clone: () => slice<S, R, M, C>;
37
- /** Returns all slice instances in the same lineage, including this one. */
38
- readonly getLineage: () => slice<S, R, M, C>[];
39
- /** Returns all sibling instances in the same lineage, excluding this one. */
40
- readonly getClones: () => slice<S, R, M, C>[];
41
- /** Returns true if both slices belong to the same lineage. */
42
- readonly isTypeOf: (other: any) => boolean;
206
+ /**
207
+ * Subscribes to this slice's state changes inside React components.
208
+ *
209
+ * The selector receives:
210
+ * - full store state
211
+ * - runtime utilities context
212
+ *
213
+ * The hook is context-bound to the store instance.
214
+ *
215
+ * The hook rely on utilizing StoreProvider being present in the component tree.
216
+ */
217
+ readonly useSelect: <T>(selector: (this: Utils, state: SliceState.State<S, C>, context: Utils) => T) => T;
218
+ /**
219
+ * Returns the current immutable state snapshot of the slice.
220
+ *
221
+ * Includes all mounted child slices and nested state.
222
+ */
223
+ readonly getState: () => SliceState.State<S, C>;
224
+ /**
225
+ * Returns the slice's original initial state.
226
+ *
227
+ * Does not include runtime updates or mutations.
228
+ */
229
+ readonly getInitialState: {
230
+ /**
231
+ * Returns the slice's original initial state.
232
+ *
233
+ * Does not include runtime updates or mutations.
234
+ */
235
+ (): SliceState.State<S, {}>;
236
+ /**
237
+ * Returns the complete initial state.
238
+ *
239
+ * Includes all mounted child slices and nested state.
240
+ */
241
+ readonly deep: () => SliceState.State<S, C>;
43
242
  };
243
+ /**
244
+ * Runtime utilities for cloning, lineage inspection,
245
+ * and instance identity.
246
+ */
247
+ readonly prototype: NodePrototype<slice<S, R, M, C>, [CloneArgs<S, C>["transform"]]>;
44
248
  /** Collection of derived state functions. */
45
249
  readonly computed: undefined;
46
250
  } & OmitNever<{
47
- /** Exposed mutation functions. */
251
+ /** Directly callable state mutation functions. */
48
252
  readonly [K in Exclude<keyof R, ReservedSliceKeys>]: R[K] extends (...args: any[]) => void ? (...args: Tail<Parameters<R[K]>>) => void : never;
49
253
  }> & OmitNever<{
50
- /** Exposed method functions. */
254
+ /** User-defined instance methods. */
51
255
  readonly [K in Exclude<keyof M, ReservedSliceKeys<R>>]: M[K] extends (...args: any[]) => void ? M[K] : never;
52
256
  }> & OmitNever<{
53
- /** Exposed children. */
257
+ /** Nested child slice instances. */
54
258
  readonly [K in Exclude<keyof C, ReservedSliceKeys<R, M>>]: C[K] extends slice<infer S, infer R, infer M, infer C> ? slice<S, R, M, C> : never;
55
259
  }>;
56
- /** Configuration object used to create a slice. */
260
+ /** Configuration used to create a slice definition. */
57
261
  type sliceOptions<S extends Obj, R extends Mutations<S, C>, M, C> = {
58
- /** Unique slice identifier. */
262
+ /** Unique name of the slice. */
59
263
  name: string;
60
- /** Initial state object or lazy state initializer. */
61
- state: S | (() => S);
62
- /** Collection of synchronous state transition functions. */
63
- mutations?: R & ThisType<GlobalUtils>;
64
- /** Collection of slice methods and orchestration logic. */
65
- methods?: M & ThisType<slice<S, R, M, C> & {
66
- root: RootStore;
67
- }>;
68
- /** Collection of derived state functions. */ /** Collection of nested child slices. */
264
+ /**
265
+ * Initial state of the slice.
266
+ *
267
+ * May be an object or a lazy initializer returning the initial state.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * const counter = createSlice({
272
+ * name: "counter",
273
+ *
274
+ * state: {
275
+ * value: 0,
276
+ * loading: false,
277
+ * },
278
+ * });
279
+ * ```
280
+ *
281
+ * @example
282
+ * ```ts
283
+ * const counter = createSlice({
284
+ * name: "counter",
285
+ *
286
+ * state: () => ({
287
+ * value: computeInitialValue(),
288
+ * loading: false,
289
+ * }),
290
+ * });
291
+ * ```
292
+ *
293
+ * @example
294
+ * Runtime usage
295
+ * ```ts
296
+ * counter.getState(); // current reactive snapshot
297
+ * counter.useSelect((state) => state.value); // React subscription
298
+ * counter.getInitialState(); // initial state only
299
+ * counter.getInitialState.deep(); // full tree initial state (including children)
300
+ * ```
301
+ */
302
+ state?: S | (() => S);
303
+ /**
304
+ * Collection of state mutation functions.
305
+ *
306
+ * Each mutation receives an Immer draft of the slice state and is exposed
307
+ * as a directly callable method on the created slice instance.
308
+ *
309
+ * @example
310
+ * ```ts
311
+ * mutations: {
312
+ * increment(state, amount: number) {
313
+ * state.value += amount;
314
+ * }
315
+ * }
316
+ *
317
+ * // usage: without dispatch
318
+ * slice.increment(1);
319
+ * ```
320
+ */
321
+ mutations?: R & ThisType<Utils>;
322
+ /**
323
+ * Collection of user-defined instance methods.
324
+ *
325
+ * Methods are bound to the slice instance and can access:
326
+ * state, mutations, children, parent, root, and utils via `this`.
327
+ *
328
+ * @example
329
+ * ```ts
330
+ * methods: {
331
+ * log() {
332
+ * console.log(this.getState());
333
+ * }
334
+ * }
335
+ *
336
+ * // usage:
337
+ * slice.log();
338
+ * ```
339
+ */
340
+ methods?: M & ThisType<slice<S, R, M, C>>;
341
+ /** Collection of derived state functions. */
342
+ /**
343
+ * Collection of child slices.
344
+ *
345
+ * Each child becomes a mounted runtime node under this slice.
346
+ *
347
+ * @example
348
+ * ```ts
349
+ * children: {
350
+ * products: productsSlice,
351
+ * categories: categoriesSlice,
352
+ * }
353
+ *
354
+ * // usage:
355
+ * shop.products.getState(); // access slice instance
356
+ * shop.getState().products; // access state subtree
357
+ * ```
358
+ */
69
359
  children?: C;
70
360
  };
71
- /** Defines the mutations available on a slice. */
72
- type Mutations<S extends Obj, C> = Dict<(state: SliceState.Draft<S, C>, ...args: any[]) => void | S>;
73
- /** Derived state shape exposed by a slice, excluding internal framework fields. */
361
+ /**
362
+ * Collection of functions that update slice state.
363
+ *
364
+ * Mutations receive an Immer draft and may either mutate it
365
+ * directly or return a replacement state.
366
+ */
367
+ type Mutations<S extends Obj, C> = Dict<(state: SliceState.Draft<S, C>, ...args: any[]) => void | SliceState.Draft<S, C>>;
368
+ /** Utilities for deriving the public and mutable state types associated with a slice. */
74
369
  declare namespace SliceState {
75
- type InferState<C> = C extends Obj ? (C["getState"] extends () => infer S ? S extends Obj ? S : never : never) : never;
370
+ type InferState<C> = C extends Obj ? C["getState"] extends () => infer S ? S extends Obj ? S : never : never : never;
76
371
  export type State<S extends Obj, C> = ReadOnly<Omit<S, "computed" | keyof OmitNever<{
77
372
  [K in keyof C]: InferState<C[K]>;
78
373
  }>> & OmitNever<{
@@ -85,58 +380,22 @@ declare namespace SliceState {
85
380
  }>;
86
381
  export { };
87
382
  }
88
- /** Reserved slice member names that cannot be overridden by user-defined APIs. */
89
- type ReservedSliceKeys<R = {}, M = {}> = ("name" | "path" | "computed" | "root" | "parent" | "prototype" | "global" | "getState" | "useSelect") | (keyof R | keyof M);
383
+ /**
384
+ * Property names reserved by the framework.
385
+ *
386
+ * These names cannot be used for mutations,
387
+ * methods, or child slices.
388
+ */
389
+ type ReservedSliceKeys<R = {}, M = {}> = ("name" | "path" | "computed" | "root" | "parent" | "prototype" | "utils" | "getState" | "getInitialState" | "useSelect") | (keyof R | keyof M);
90
390
  type AnySlice = slice<any, Mutations<any, any>, any, any>;
91
-
92
- /** Runtime store API exposed by createStore(...). */
93
- type store<C> = OmitNever<GlobalUtils & {
94
- /** Unique store identifier. Currently this is set to "default" and is nt configurable */
95
- readonly name: "default";
96
- /** Returns the latest immutable state snapshot. */
97
- readonly getState: () => StoreState<C>;
98
- /** Subscribes to state changes within React components. Runs with a context-bound `this` containing `global` utilities. */
99
- readonly useSelect: <T>(selector: (this: GlobalUtils, state: StoreState<C>, context: GlobalUtils) => T) => T;
100
- } & {
101
- /** Exposed slices. */
102
- readonly [K in Exclude<keyof C, ReservedStoreKeys>]: C[K] extends slice<infer S, infer R, infer M, infer C> ? slice<S, R, M, C> : never;
103
- }>;
104
- /** Configuration object used to create a store. */
105
- type storeOptions<C> = {
106
- /** Collection of slices. */
107
- slices: C;
391
+ type CloneArgs<S extends Obj = any, C = any> = {
392
+ /** Optional name used when reporting clone validation errors. */
393
+ name?: string;
394
+ /** Explicit state to assign to the cloned slice. */
395
+ object?: Obj;
396
+ /** Receives the cloned state before initialization, allowing it to be customized. */
397
+ transform?: (state: SliceState.Draft<S, C>) => void | SliceState.Draft<S, C>;
108
398
  };
109
- /** Derived immutable state shape of the store. */
110
- type StoreState<C> = ReadOnly<OmitNever<{
111
- readonly [K in Exclude<keyof C, ReservedStoreKeys>]: C[K] extends slice<infer S, infer _, infer __, infer C> ? SliceState.State<S, C> : never;
112
- }>>;
113
- /** Props accepted by the store provider component. */
114
- type StoreProviderProps<T = any> = Omit<ProviderProps, "store" | "serverState" | "context"> & {
115
- /** The root store instance created with `createStore(...)`. */
116
- store: store<T>;
117
- };
118
- /** Reserved store member names that cannot be overridden by user-defined APIs. */
119
- type ReservedStoreKeys<R = {}, M = {}> = ("name" | "computed" | "global" | "getState" | "useSelect") | (keyof R | keyof M);
120
-
121
- declare global {
122
- namespace OrcheStore {
123
- /** User-defined framework type slots. */
124
- interface Slots {
125
- }
126
- }
127
- }
128
- /** Resolves a type slot with validation and fallback support. */
129
- 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;
130
- /** Resolved type for application-wide global utilities. */
131
- type GlobalUtils = {
132
- /** Application-wide global utilities. */
133
- global: Definition<"global", Dict, any>;
134
- };
135
- /** Resolved type for the application root store. */
136
- type RootStore = Definition<"root", store<unknown>, any>;
137
-
138
- /** Provides an OrcheStore instance to the React component tree. */
139
- declare function StoreProvider<T>(props: StoreProviderProps<T>): React.JSX.Element;
140
399
 
141
400
  declare global {
142
401
  namespace OrcheStore {
@@ -151,31 +410,404 @@ declare global {
151
410
  }
152
411
  }
153
412
 
154
- /** Returns the current global utilities object. */
155
- declare function getGlobalUtils(): GlobalUtils["global"];
156
- /** Registers or updates application-wide global utilities. */
157
- declare function provideGlobalUtils(value: Partial<GlobalUtils["global"]>): GlobalUtils["global"];
413
+ /**
414
+ * Provides an OrcheStore instance to the React component tree.
415
+ *
416
+ * The slice hook (`useSelect`) rely on this provider being
417
+ * present in the component tree.
418
+ *
419
+ * @example
420
+ * ```tsx
421
+ * import { StoreProvider, createStore } from "orchestore";
422
+ *
423
+ * const store = createStore(...);
424
+ *
425
+ * export function AppWrapper() {
426
+ * return (
427
+ * <StoreProvider store={store}>
428
+ * <App />
429
+ * </StoreProvider>
430
+ * );
431
+ * }
432
+ * ```
433
+ *
434
+ * @internal
435
+ * Uses React-Redux Provider internally to bind the underlying Redux store
436
+ * into React context.
437
+ */
438
+ declare function StoreProvider<T>(props: StoreProviderProps<T>): React.JSX.Element;
439
+
440
+ /**
441
+ * Returns the global utilities registry.
442
+ *
443
+ * The returned object acts as a shared runtime container for application-wide utilities
444
+ * such as navigation, notifications, API clients, and other injected services.
445
+ *
446
+ * Accessing an unregistered utility will trigger a development warning.
447
+ */
448
+ declare function getUtils(): Utils["utils"];
449
+ /**
450
+ * Registers or updates application-wide utilities.
451
+ *
452
+ * Utilities are merged into the existing runtime registry and become immediately
453
+ * available across all slices and store instances.
454
+ *
455
+ * This is the core mechanism behind OrcheStore’s global runtime utility system shared across all slices.
456
+ */
457
+ declare function setUtils(value: Partial<Utils["utils"]>): Utils["utils"];
158
458
 
159
- /** Configures diagnostics output level ("off" | "errors" | "all"). */
160
- declare function configureDiagnostics(level: "off" | "errors" | "all"): void;
459
+ /**
460
+ * Configures runtime diagnostic reporting behavior.
461
+ *
462
+ * Supports enabling/disabling logs, warnings, and errors globally or individually.
463
+ */
464
+ declare function setReporting(enabled: boolean): void;
465
+ declare function setReporting(config: {
466
+ all?: boolean;
467
+ logs?: boolean;
468
+ warnings?: boolean;
469
+ errors?: boolean;
470
+ }): void;
471
+ declare function setReporting(level: "logs" | "warnings" | "errors" | "all", enabled: boolean): void;
161
472
 
162
- /** Creates and initializes an OrcheStore slice. */
473
+ /**
474
+ * Creates and initializes a slice runtime instance.
475
+ *
476
+ * This function constructs a fully functional OrcheStore slice,
477
+ * including state, mutations, methods, and nested children.
478
+ *
479
+ * @example
480
+ * ```tsx
481
+ * import { createStore, createSlice } from "orchestore";
482
+ *
483
+ * const counterSlice = createSlice({
484
+ * name: "counter",
485
+ *
486
+ * state: { value: 0 },
487
+ *
488
+ * mutations: {
489
+ * increment(state, amount: number = 1) {
490
+ * state.value += amount;
491
+ * },
492
+ * },
493
+ *
494
+ * methods: {
495
+ * async incrementAfter(amount: number, delay: number) {
496
+ * await new Promise((resolve) => setTimeout(resolve, delay));
497
+ * this.increment(amount);
498
+ * },
499
+ * },
500
+ * });
501
+ *
502
+ * // Create store tree
503
+ * const store = createStore({
504
+ * slices: {
505
+ * counter: counterSlice,
506
+ * },
507
+ * });
508
+ *
509
+ * // Direct usage
510
+ * counterSlice.increment(12);
511
+ * store.counter.increment(1);
512
+ * store.counter.getState(); // { value: 13 }
513
+ *
514
+ * // React usage
515
+ * function App() {
516
+ * const count = store.counter.useSelect((state) => state.value);
517
+ *
518
+ * return (
519
+ * <>
520
+ * <div>Counter {count}</div>
521
+ *
522
+ * <button onClick={() => store.counter.increment(1)}>
523
+ * Increment
524
+ * </button>
525
+ *
526
+ * <button onClick={() => store.counter.incrementAfter(1, 1000)}>
527
+ * Increment after 1 second
528
+ * </button>
529
+ * </>
530
+ * );
531
+ * }
532
+ * ```
533
+ *
534
+ * @internal
535
+ * Integrates Redux Toolkit, builds reducers, and wires runtime context.
536
+ *
537
+ * @prerelease
538
+ * Calling this function will print a pre-release message in the console.
539
+ * This behavior will be removed in the first stable release.
540
+ */
163
541
  declare const createSliceWrapper: <S extends Obj, R extends Mutations<S, C>, M, C>(props: sliceOptions<S, R, M, C>) => slice<S, R, M, C>;
164
- /** Creates and initializes an OrcheStore instance. */
542
+ /**
543
+ * Creates and initializes an OrcheStore root instance.
544
+ *
545
+ * This function sets up the application-wide store tree,
546
+ * mounts all slices, and connects the runtime to Redux Toolkit.
547
+ *
548
+ * The resulting store becomes the central access point for:
549
+ * - slice instances and their mutations
550
+ * - global state inspection
551
+ * - React subscriptions via `useSelect`
552
+ * - runtime utilities via `utils`
553
+ *
554
+ * @example
555
+ * ```tsx
556
+ * import { createStore, createSlice } from "orchestore";
557
+ *
558
+ * const counterSlice = createSlice({
559
+ * name: "counter",
560
+ *
561
+ * state: { value: 0 },
562
+ *
563
+ * mutations: {
564
+ * increment(state, amount: number = 1) {
565
+ * state.value += amount;
566
+ * },
567
+ * },
568
+ *
569
+ * methods: {
570
+ * async incrementAfter(amount: number, delay: number) {
571
+ * await new Promise((r) => setTimeout(r, delay));
572
+ * this.increment(amount);
573
+ * },
574
+ * },
575
+ * });
576
+ *
577
+ * const store = createStore({
578
+ * slices: {
579
+ * counter: counterSlice,
580
+ * },
581
+ * });
582
+ *
583
+ * // Direct access
584
+ * counterSlice.increment(12);
585
+ * store.counter.increment(1);
586
+ * store.counter.getState(); // { value: 13 }
587
+ *
588
+ * // React usage
589
+ * function App() {
590
+ * const value = store.counter.useSelect((state) => state.value);
591
+ *
592
+ * return (
593
+ * <>
594
+ * <div>{value}</div>
595
+ *
596
+ * <button onClick={() => store.counter.increment(1)}>
597
+ * Increment
598
+ * </button>
599
+ *
600
+ * <button onClick={() => store.counter.incrementAfter(1, 1000)}>
601
+ * Increment later
602
+ * </button>
603
+ * </>
604
+ * );
605
+ * }
606
+ * ```
607
+ *
608
+ * @internal
609
+ * Bootstraps Redux Toolkit, mounts slice tree, and initializes runtime store graph.
610
+ *
611
+ * @prerelease
612
+ * Calling this function will print a pre-release message in the console.
613
+ * This behavior will be removed in the first stable release.
614
+ */
165
615
  declare const createStoreWrapper: <T>(props: storeOptions<T>) => store<T>;
616
+
166
617
  declare const defaultExport: {
167
- /** Creates and initializes an OrcheStore instance. */
618
+ /**
619
+ * Creates and initializes an OrcheStore root instance.
620
+ *
621
+ * This function sets up the application-wide store tree,
622
+ * mounts all slices, and connects the runtime to Redux Toolkit.
623
+ *
624
+ * The resulting store becomes the central access point for:
625
+ * - slice instances and their mutations
626
+ * - global state inspection
627
+ * - React subscriptions via `useSelect`
628
+ * - runtime utilities via `utils`
629
+ *
630
+ * @example
631
+ * ```tsx
632
+ * import { createStore, createSlice } from "orchestore";
633
+ *
634
+ * const counterSlice = createSlice({
635
+ * name: "counter",
636
+ *
637
+ * state: { value: 0 },
638
+ *
639
+ * mutations: {
640
+ * increment(state, amount: number = 1) {
641
+ * state.value += amount;
642
+ * },
643
+ * },
644
+ *
645
+ * methods: {
646
+ * async incrementAfter(amount: number, delay: number) {
647
+ * await new Promise((r) => setTimeout(r, delay));
648
+ * this.increment(amount);
649
+ * },
650
+ * },
651
+ * });
652
+ *
653
+ * const store = createStore({
654
+ * slices: {
655
+ * counter: counterSlice,
656
+ * },
657
+ * });
658
+ *
659
+ * // Direct access
660
+ * counterSlice.increment(12);
661
+ * store.counter.increment(1);
662
+ * store.counter.getState(); // { value: 13 }
663
+ *
664
+ * // React usage
665
+ * function App() {
666
+ * const value = store.counter.useSelect((state) => state.value);
667
+ *
668
+ * return (
669
+ * <>
670
+ * <div>{value}</div>
671
+ *
672
+ * <button onClick={() => store.counter.increment(1)}>
673
+ * Increment
674
+ * </button>
675
+ *
676
+ * <button onClick={() => store.counter.incrementAfter(1, 1000)}>
677
+ * Increment later
678
+ * </button>
679
+ * </>
680
+ * );
681
+ * }
682
+ * ```
683
+ *
684
+ * @internal
685
+ * Bootstraps Redux Toolkit, mounts slice tree, and initializes runtime store graph.
686
+ *
687
+ * @prerelease
688
+ * Calling this function will print a pre-release message in the console.
689
+ * This behavior will be removed in the first stable release.
690
+ */
168
691
  createStore: <T>(props: storeOptions<T>) => store<T>;
169
- /** Creates and initializes an OrcheStore slice. */
692
+ /**
693
+ * Creates and initializes a slice runtime instance.
694
+ *
695
+ * This function constructs a fully functional OrcheStore slice,
696
+ * including state, mutations, methods, and nested children.
697
+ *
698
+ * @example
699
+ * ```tsx
700
+ * import { createStore, createSlice } from "orchestore";
701
+ *
702
+ * const counterSlice = createSlice({
703
+ * name: "counter",
704
+ *
705
+ * state: { value: 0 },
706
+ *
707
+ * mutations: {
708
+ * increment(state, amount: number = 1) {
709
+ * state.value += amount;
710
+ * },
711
+ * },
712
+ *
713
+ * methods: {
714
+ * async incrementAfter(amount: number, delay: number) {
715
+ * await new Promise((resolve) => setTimeout(resolve, delay));
716
+ * this.increment(amount);
717
+ * },
718
+ * },
719
+ * });
720
+ *
721
+ * // Create store tree
722
+ * const store = createStore({
723
+ * slices: {
724
+ * counter: counterSlice,
725
+ * },
726
+ * });
727
+ *
728
+ * // Direct usage
729
+ * counterSlice.increment(12);
730
+ * store.counter.increment(1);
731
+ * store.counter.getState(); // { value: 13 }
732
+ *
733
+ * // React usage
734
+ * function App() {
735
+ * const count = store.counter.useSelect((state) => state.value);
736
+ *
737
+ * return (
738
+ * <>
739
+ * <div>Counter {count}</div>
740
+ *
741
+ * <button onClick={() => store.counter.increment(1)}>
742
+ * Increment
743
+ * </button>
744
+ *
745
+ * <button onClick={() => store.counter.incrementAfter(1, 1000)}>
746
+ * Increment after 1 second
747
+ * </button>
748
+ * </>
749
+ * );
750
+ * }
751
+ * ```
752
+ *
753
+ * @internal
754
+ * Integrates Redux Toolkit, builds reducers, and wires runtime context.
755
+ *
756
+ * @prerelease
757
+ * Calling this function will print a pre-release message in the console.
758
+ * This behavior will be removed in the first stable release.
759
+ */
170
760
  createSlice: <S extends Obj, R extends Mutations<S, C>, M, C>(props: sliceOptions<S, R, M, C>) => slice<S, R, M, C>;
171
- /** Provides an OrcheStore instance to the React component tree. */
761
+ /**
762
+ * Provides an OrcheStore instance to the React component tree.
763
+ *
764
+ * The slice hook (`useSelect`) rely on this provider being
765
+ * present in the component tree.
766
+ *
767
+ * @example
768
+ * ```tsx
769
+ * import { StoreProvider, createStore } from "orchestore";
770
+ *
771
+ * const store = createStore(...);
772
+ *
773
+ * export function AppWrapper() {
774
+ * return (
775
+ * <StoreProvider store={store}>
776
+ * <App />
777
+ * </StoreProvider>
778
+ * );
779
+ * }
780
+ * ```
781
+ *
782
+ * @internal
783
+ * Uses React-Redux Provider internally to bind the underlying Redux store
784
+ * into React context.
785
+ */
172
786
  StoreProvider: typeof StoreProvider;
173
- /** Registers or updates application-wide global utilities. */
174
- provideGlobalUtils: typeof provideGlobalUtils;
175
- /** Returns the current global utilities object. */
176
- getGlobalUtils: typeof getGlobalUtils;
177
- /** Configures diagnostics output level ("off" | "errors" | "all"). */
178
- configureDiagnostics: typeof configureDiagnostics;
787
+ /**
788
+ * Returns the global utilities registry.
789
+ *
790
+ * The returned object acts as a shared runtime container for application-wide utilities
791
+ * such as navigation, notifications, API clients, and other injected services.
792
+ *
793
+ * Accessing an unregistered utility will trigger a development warning.
794
+ */
795
+ getUtils: typeof getUtils;
796
+ /**
797
+ * Registers or updates application-wide utilities.
798
+ *
799
+ * Utilities are merged into the existing runtime registry and become immediately
800
+ * available across all slices and store instances.
801
+ *
802
+ * This is the core mechanism behind OrcheStore’s global runtime utility system shared across all slices.
803
+ */
804
+ setUtils: typeof setUtils;
805
+ /**
806
+ * Configures runtime diagnostic reporting behavior.
807
+ *
808
+ * Supports enabling/disabling logs, warnings, and errors globally or individually.
809
+ */
810
+ setReporting: typeof setReporting;
179
811
  };
180
812
 
181
- export { type GlobalUtils, type RootStore, type slice as Slice, type sliceOptions as SliceOptions, type store as Store, type storeOptions as StoreOptions, StoreProvider, configureDiagnostics, createSliceWrapper as createSlice, createStoreWrapper as createStore, defaultExport as default, getGlobalUtils, provideGlobalUtils };
813
+ export { type slice as Slice, type sliceOptions as SliceOptions, type store as Store, type storeOptions as StoreOptions, StoreProvider, type Utils, createSliceWrapper as createSlice, createStoreWrapper as createStore, defaultExport as default, getUtils, setReporting, setUtils };