beestate 0.1.4 → 0.1.6

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.
Files changed (83) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/InternalStore.d.ts +15 -54
  3. package/dist/@types/StoreProvider.d.ts +2 -2
  4. package/dist/@types/createStore.d.ts +5 -6
  5. package/dist/@types/createStoreController.d.ts +6 -0
  6. package/dist/@types/createStoreRegistry.d.ts +8 -5
  7. package/dist/@types/createUseDispatcher.d.ts +7 -7
  8. package/dist/@types/createUseLatest.d.ts +11 -0
  9. package/dist/@types/createUseProp.d.ts +3 -6
  10. package/dist/@types/createUsePropAll.d.ts +3 -6
  11. package/dist/@types/createUseStore.d.ts +11 -11
  12. package/dist/@types/index.d.ts +12 -4
  13. package/dist/@types/pipe/Error.d.ts +6 -0
  14. package/dist/@types/pipe/check.d.ts +37 -0
  15. package/dist/@types/pipe/createPipeKit.d.ts +24 -0
  16. package/dist/@types/pipe/debug/createDebugger.d.ts +2 -0
  17. package/dist/@types/pipe/debug/debugInstruction.d.ts +1 -0
  18. package/dist/@types/pipe/debug/extendedDebugInstruction.d.ts +5 -0
  19. package/dist/@types/pipe/debug/index.d.ts +4 -0
  20. package/dist/@types/pipe/debug/log.d.ts +2 -0
  21. package/dist/@types/pipe/deepCopy.env-detect.dev.d.ts +1 -0
  22. package/dist/@types/pipe/deepCopy.env-detect.main.d.ts +4 -0
  23. package/dist/@types/pipe/entities/Adjunct.d.ts +3 -0
  24. package/dist/@types/pipe/entities/Connect.d.ts +9 -0
  25. package/dist/@types/pipe/entities/DataBarrel.d.ts +24 -0
  26. package/dist/@types/pipe/entities/Fill.d.ts +25 -0
  27. package/dist/@types/pipe/entities/Instruction.d.ts +81 -0
  28. package/dist/@types/pipe/entities/ParentPipe.d.ts +9 -0
  29. package/dist/@types/pipe/entities/Pipe.d.ts +57 -0
  30. package/dist/@types/pipe/entities/Stream.d.ts +13 -0
  31. package/dist/@types/pipe/entities/StreamGroup.d.ts +25 -0
  32. package/dist/@types/pipe/entities/index.d.ts +9 -0
  33. package/dist/@types/pipe/index.core.d.ts +26 -0
  34. package/dist/@types/pipe/index.d.ts +4 -0
  35. package/dist/@types/pipe/index.debug.d.ts +14 -0
  36. package/dist/@types/pipe/instruction.d.ts +9 -0
  37. package/dist/@types/requestState.d.ts +19 -0
  38. package/dist/@types/requestStateDefault.d.ts +7 -0
  39. package/dist/@types/requestStatus.d.ts +12 -0
  40. package/dist/@types/types/Dispatcher.d.ts +5 -7
  41. package/dist/@types/types/InitInstance.d.ts +2 -2
  42. package/dist/@types/types/InitPayload.d.ts +3 -4
  43. package/dist/@types/types/InstanceKey.d.ts +1 -1
  44. package/dist/@types/types/InternalStore/Dispatch.d.ts +7 -0
  45. package/dist/@types/types/InternalStore/GetState.d.ts +5 -0
  46. package/dist/@types/types/InternalStore/GetStateAll.d.ts +5 -0
  47. package/dist/@types/types/InternalStore/InitInstance.d.ts +8 -0
  48. package/dist/@types/types/InternalStore/Listener.d.ts +7 -0
  49. package/dist/@types/types/InternalStore/ListenerAll.d.ts +7 -0
  50. package/dist/@types/types/InternalStore/ResetInstance.d.ts +6 -0
  51. package/dist/@types/types/InternalStore/Subscribe.d.ts +7 -0
  52. package/dist/@types/types/InternalStore/SubscribeAll.d.ts +6 -0
  53. package/dist/@types/types/InternalStore/Unsubscribe.d.ts +3 -0
  54. package/dist/@types/types/InternalStore/UnsubscribeAll.d.ts +3 -0
  55. package/dist/@types/types/InternalStoreProps.d.ts +6 -6
  56. package/dist/@types/types/Reducer.d.ts +2 -2
  57. package/dist/@types/types/ReducerLink.d.ts +8 -6
  58. package/dist/@types/types/ReducerMap.d.ts +2 -2
  59. package/dist/@types/types/ReducerPayload.d.ts +3 -4
  60. package/dist/@types/types/RegisterDefaultInstance.d.ts +2 -2
  61. package/dist/@types/types/RegisterInstance.d.ts +3 -3
  62. package/dist/@types/types/RequestState/RequestAbortedState.d.ts +12 -0
  63. package/dist/@types/types/RequestState/RequestFulfilledState.d.ts +12 -0
  64. package/dist/@types/types/RequestState/RequestIdleState.d.ts +12 -0
  65. package/dist/@types/types/RequestState/RequestPendingState.d.ts +12 -0
  66. package/dist/@types/types/RequestState/RequestRejectedState.d.ts +12 -0
  67. package/dist/@types/types/RequestState.d.ts +7 -0
  68. package/dist/@types/types/RequestStateMeta.d.ts +1 -0
  69. package/dist/@types/types/RequestStateStoreKey.d.ts +5 -0
  70. package/dist/@types/types/ResetInstance.d.ts +1 -1
  71. package/dist/@types/types/ResetPayload.d.ts +3 -4
  72. package/dist/@types/types/StateLink.d.ts +5 -5
  73. package/dist/@types/types/Store.d.ts +8 -8
  74. package/dist/@types/types/StoreController.d.ts +7 -6
  75. package/dist/@types/types/StoreInstanceController.d.ts +7 -0
  76. package/dist/@types/types/StoreRegistry.d.ts +1 -1
  77. package/dist/@types/types/UseProp.d.ts +7 -0
  78. package/dist/@types/types/UsePropAll.d.ts +7 -0
  79. package/dist/cjs/index.cjs.js +229 -112
  80. package/dist/esm/index.esm.js +229 -114
  81. package/package.json +2 -1
  82. package/dist/@types/types/StoreControllerInstance.d.ts +0 -7
  83. package/dist/@types/types/index.d.ts +0 -20
@@ -0,0 +1,25 @@
1
+ import type { Adjunct } from './Adjunct';
2
+ import type { DataBarrelRegistry } from './DataBarrel';
3
+ import type { BasePipe } from './Pipe';
4
+ import type { Stream } from './Stream';
5
+ export declare const streamGroupStatus: {
6
+ readonly open: "open";
7
+ readonly closed: "closed";
8
+ readonly retired: "retired";
9
+ readonly deleted: "deleted";
10
+ };
11
+ export type StreamGroupStatus = (typeof streamGroupStatus)[keyof typeof streamGroupStatus];
12
+ export type StreamGroup<TAdjuncts extends Adjunct[] = Adjunct[]> = {
13
+ /**
14
+ * Available if import.meta.env.DEV
15
+ */
16
+ uniqKey: symbol;
17
+ papa: symbol;
18
+ status: StreamGroupStatus;
19
+ members: StreamGroupMembers<TAdjuncts>;
20
+ dataBarrelRegistry: DataBarrelRegistry;
21
+ retire: null | (() => void);
22
+ };
23
+ export type StreamGroupMembers<TAdjuncts extends any = any> = TAdjuncts extends [infer TAdjunct, ...(infer TRestAdjuncts)] ? TAdjunct extends BasePipe<infer TValue> ? [null | Stream<TValue>, ...StreamGroupMembers<TRestAdjuncts>] : StreamGroupMembers<TRestAdjuncts> : TAdjuncts extends (infer TAdjunct)[] ? Extract<TAdjunct, BasePipe> extends BasePipe<infer TValue> ? (null | Stream<TValue>)[] : [] : [];
24
+ export type StreamGroupValues<TAdjuncts extends any[] = any[]> = TAdjuncts extends [infer TAdjunct, ...(infer TRestAdjuncts)] ? TAdjunct extends BasePipe<infer TValue> ? [TValue, ...StreamGroupValues<TRestAdjuncts>] : StreamGroupValues<TRestAdjuncts> : TAdjuncts extends (infer TAdjunct)[] ? Extract<TAdjunct, BasePipe> extends BasePipe<infer TValue> ? TValue[] : [] : [];
25
+ export type StreamGroupRegistry<TAdjuncts extends Adjunct[] = Adjunct[]> = Record<symbol, StreamGroup<TAdjuncts>>;
@@ -0,0 +1,9 @@
1
+ export * from './Adjunct';
2
+ export * from './Connect';
3
+ export * from './Instruction';
4
+ export * from './DataBarrel';
5
+ export * from './Fill';
6
+ export * from './ParentPipe';
7
+ export * from './Pipe';
8
+ export * from './Stream';
9
+ export * from './StreamGroup';
@@ -0,0 +1,26 @@
1
+ export { createPipeKit } from './createPipeKit';
2
+ export type { Adjunct } from './entities';
3
+ export type { BasePipe } from './entities';
4
+ export type { ControlInstruction } from './entities';
5
+ export type { CreateFill } from './entities';
6
+ export type { DataBarrel } from './entities';
7
+ export type { DataPipe } from './entities';
8
+ export type { DataType } from './entities';
9
+ export type { DisplayNameInstruction } from './entities';
10
+ export type { Emit } from './entities';
11
+ export type { ForkInstruction } from './entities';
12
+ export type { Instruction } from './entities';
13
+ export type { LatestInstruction } from './entities';
14
+ export type { LeadingInstruction } from './entities';
15
+ export type { OnceInstruction } from './entities';
16
+ export type { PipeState } from './entities';
17
+ export type { StreamGroup } from './entities';
18
+ export type { StreamGroupValues } from './entities';
19
+ export type { TerminateAll } from './entities';
20
+ export type { UniversalDataPipe } from './entities';
21
+ export { FINAL } from './entities';
22
+ export { dataType } from './entities';
23
+ export { dataBarrelStatus } from './entities';
24
+ export { streamGroupStatus } from './entities';
25
+ export { createControlInstruction } from './instruction';
26
+ export { createInstruction } from './instruction';
@@ -0,0 +1,4 @@
1
+ export { fork } from './createPipeKit';
2
+ export { latest } from './createPipeKit';
3
+ export { leading } from './createPipeKit';
4
+ export { once } from './createPipeKit';
@@ -0,0 +1,14 @@
1
+ export type { ExtendedDebugInstruction } from './debug';
2
+ export { createDebugger } from './debug';
3
+ export { debugInstruction } from './debug';
4
+ export { extendedDebugInstruction } from './debug';
5
+ export { extendedDebugInstruction as debug } from './debug';
6
+ export { log } from './debug';
7
+ export type { Debugger } from './entities';
8
+ export type { DebugInstruction } from './entities';
9
+ export type { DisplayNameInstruction } from './entities';
10
+ export { DEBUG_INSTRUCTION_TYPE } from './entities';
11
+ export { DISPLAY_NAME_INSTRUCTION_TYPE } from './entities';
12
+ export { createDebugInstruction } from './instruction';
13
+ export { createDisplayNameInstruction } from './instruction';
14
+ export { createDisplayNameInstruction as dn } from './instruction';
@@ -0,0 +1,9 @@
1
+ import type { Instruction } from './entities';
2
+ import type { ControlInstruction } from './entities';
3
+ import type { CreateDebugger } from './entities';
4
+ import type { DebugInstruction } from './entities';
5
+ import type { DisplayNameInstruction } from './entities';
6
+ export declare function createInstruction<TInstructionType extends symbol = symbol>(instructionType: TInstructionType): Instruction<TInstructionType>;
7
+ export declare function createDebugInstruction(createDebugger: CreateDebugger, displayName?: string): DebugInstruction;
8
+ export declare function createDisplayNameInstruction(displayName: string): DisplayNameInstruction;
9
+ export declare function createControlInstruction<TControlInstructionType extends symbol = symbol>(controlInstructionType: TControlInstructionType, props: Pick<ControlInstruction, `createStreamEmitHandler` | `createStreamTerminateHandler`>): ControlInstruction<TControlInstructionType>;
@@ -0,0 +1,19 @@
1
+ import type { RequestAbortedState } from './types/RequestState/RequestAbortedState.tsx';
2
+ import type { RequestFulfilledState } from './types/RequestState/RequestFulfilledState.tsx';
3
+ import type { RequestIdleState } from './types/RequestState/RequestIdleState.tsx';
4
+ import type { RequestPendingState } from './types/RequestState/RequestPendingState.tsx';
5
+ export type { RequestState } from './types/RequestState.tsx';
6
+ import type { RequestRejectedState } from './types/RequestState/RequestRejectedState.tsx';
7
+ import type { RequestStateMeta } from './types/RequestStateMeta.tsx';
8
+ export declare const requestState: {
9
+ idle: <TMeta extends RequestStateMeta = RequestStateMeta>(meta?: null | TMeta) => RequestIdleState<TMeta>;
10
+ pending: <TMeta extends RequestStateMeta = RequestStateMeta>(meta?: null | TMeta) => RequestPendingState<TMeta>;
11
+ fulfilled: <TMeta extends RequestStateMeta = RequestStateMeta>(meta?: null | TMeta) => RequestFulfilledState<TMeta>;
12
+ rejected: <TMeta extends RequestStateMeta = RequestStateMeta, TError extends unknown = unknown>(error?: null | TError, meta?: null | TMeta) => RequestRejectedState<TMeta, TError>;
13
+ aborted: <TMeta extends RequestStateMeta = RequestStateMeta>(meta?: null | TMeta) => RequestAbortedState<TMeta>;
14
+ forceIdle: <TMeta extends RequestStateMeta = RequestStateMeta>(meta?: null | TMeta) => RequestIdleState<TMeta>;
15
+ forcePending: <TMeta extends RequestStateMeta = RequestStateMeta>(meta?: null | TMeta) => RequestPendingState<TMeta>;
16
+ forceFulfilled: <TMeta extends RequestStateMeta = RequestStateMeta>(meta?: null | TMeta) => RequestFulfilledState<TMeta>;
17
+ forceRejected: <TMeta extends RequestStateMeta = RequestStateMeta, TError extends unknown = unknown>(error?: null | TError, meta?: null | TMeta) => RequestRejectedState<TMeta, TError>;
18
+ forceAborted: <TMeta extends RequestStateMeta = RequestStateMeta>(meta?: null | TMeta) => RequestAbortedState<TMeta>;
19
+ };
@@ -0,0 +1,7 @@
1
+ export declare const requestStateDefault: {
2
+ readonly isAborted: false;
3
+ readonly isFulfilled: false;
4
+ readonly isIdle: false;
5
+ readonly isPending: false;
6
+ readonly isRejected: false;
7
+ };
@@ -0,0 +1,12 @@
1
+ export declare const requestStatus: {
2
+ readonly IDLE: "IDLE";
3
+ readonly PENDING: "PENDING";
4
+ readonly FULFILLED: "FULFILLED";
5
+ readonly REJECTED: "REJECTED";
6
+ readonly ABORTED: "ABORTED";
7
+ readonly FORCE_IDLE: "IDLE";
8
+ readonly FORCE_PENDING: "PENDING";
9
+ readonly FORCE_FULFILLED: "FULFILLED";
10
+ readonly FORCE_REJECTED: "REJECTED";
11
+ readonly FORCE_ABORTED: "ABORTED";
12
+ };
@@ -1,8 +1,6 @@
1
- import { type InstanceKey } from './';
2
- import { type Reducer } from './';
3
- import { type ReducerPayload } from './';
4
- import { type StoreState } from './';
5
- export type Dispatcher<TStoreState extends StoreState = StoreState, TReducer extends Reducer<TStoreState, any> = Reducer<TStoreState, any>> = {
6
- (payload: ReducerPayload<TStoreState, TReducer>): void;
7
- (instanceKey: InstanceKey, payload: ReducerPayload<TStoreState, TReducer>): void;
1
+ import type { InstanceKey } from './InstanceKey.tsx';
2
+ import type { Payload } from './Payload.tsx';
3
+ export type Dispatcher<TPayload extends void | Payload = void | Payload> = {
4
+ (payload: TPayload): void;
5
+ (instanceKey: InstanceKey, payload: TPayload): void;
8
6
  };
@@ -1,5 +1,5 @@
1
- import { type Payload } from './';
2
- import { type ResetInstance } from './';
1
+ import type { Payload } from './Payload.tsx';
2
+ import type { ResetInstance } from './ResetInstance.tsx';
3
3
  export type InitInstance<TInitPayload extends void | Payload = void | Payload, TResetPayload extends void | Payload = void | Payload> = {
4
4
  (payload: TInitPayload): ResetInstance<TResetPayload>;
5
5
  };
@@ -1,4 +1,3 @@
1
- import { type ReducerMap } from './';
2
- import { type ReducerPayload } from './';
3
- import { type StoreState } from './';
4
- export type InitPayload<TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>> = ReducerPayload<TStoreState, TReducerMap[`$$init`]>;
1
+ import type { ReducerMap } from './ReducerMap.tsx';
2
+ import type { ReducerPayload } from './ReducerPayload.tsx';
3
+ export type InitPayload<TReducerMap extends ReducerMap<any> = ReducerMap<any>> = ReducerPayload<TReducerMap[`$$init`]>;
@@ -1 +1 @@
1
- export type InstanceKey = number | string | symbol;
1
+ export type InstanceKey = string | symbol;
@@ -0,0 +1,7 @@
1
+ import type { InstanceKey } from '../InstanceKey.tsx';
2
+ import type { Payload } from '../Payload.tsx';
3
+ import type { Reducer } from '../Reducer.tsx';
4
+ import type { StoreState } from '../StoreState.tsx';
5
+ export type Dispatch<TStoreState extends StoreState = StoreState> = {
6
+ <TPayload extends void | Payload = void | Payload>(instanceKey: InstanceKey, payload: TPayload, reducer: Reducer<TStoreState, TPayload>): void;
7
+ };
@@ -0,0 +1,5 @@
1
+ import type { InstanceKey } from '../InstanceKey.tsx';
2
+ import type { StoreState } from '../StoreState.tsx';
3
+ export type GetState<TStoreState extends StoreState = StoreState> = {
4
+ (instanceKey: InstanceKey): TStoreState;
5
+ };
@@ -0,0 +1,5 @@
1
+ import type { InstanceKey } from '../InstanceKey.tsx';
2
+ import type { StoreState } from '../StoreState.tsx';
3
+ export type GetStateAll<TStoreState extends StoreState = StoreState> = {
4
+ (): Record<InstanceKey, TStoreState>;
5
+ };
@@ -0,0 +1,8 @@
1
+ import type { InstanceKey } from '../InstanceKey.tsx';
2
+ import type { Payload } from '../Payload.tsx';
3
+ import type { Reducer } from '../Reducer.tsx';
4
+ import type { ResetInstance } from './ResetInstance.tsx';
5
+ import type { StoreState } from '../StoreState.tsx';
6
+ export type InitInstance<TStoreState extends StoreState = StoreState, TInitPayload extends void | Payload = void | Payload, TResetPayload extends void | Payload = void | Payload> = {
7
+ (instanceKey: InstanceKey, initialState: TStoreState, initPayload: TInitPayload, initReducer: Reducer<TStoreState, TInitPayload>): ResetInstance<TStoreState, TResetPayload>;
8
+ };
@@ -0,0 +1,7 @@
1
+ import type { InstanceKey } from '../InstanceKey.tsx';
2
+ import type { Payload } from '../Payload.tsx';
3
+ import type { Reducer } from '../Reducer.tsx';
4
+ import type { StoreState } from '../StoreState.tsx';
5
+ export type Listener<TStoreState extends StoreState = StoreState> = {
6
+ <TPayload extends void | Payload = void | Payload, TReducer extends Reducer<TStoreState, TPayload> = Reducer<TStoreState, TPayload>>(instanceKey: InstanceKey, payload: TPayload, reducer: TReducer): void;
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { InstanceKey } from '../InstanceKey.tsx';
2
+ import type { Payload } from '../Payload.tsx';
3
+ import type { Reducer } from '../Reducer.tsx';
4
+ import type { StoreState } from '../StoreState.tsx';
5
+ export type ListenerAll<TStoreState extends StoreState = StoreState> = {
6
+ <TPayload extends void | Payload = void | Payload, TReducer extends Reducer<TStoreState, TPayload> = Reducer<TStoreState, TPayload>>(instanceKey: InstanceKey, payload: TPayload, reducer: TReducer): void;
7
+ };
@@ -0,0 +1,6 @@
1
+ import type { Payload } from '../Payload.tsx';
2
+ import type { Reducer } from '../Reducer.tsx';
3
+ import type { StoreState } from '../StoreState.tsx';
4
+ export type ResetInstance<TStoreState extends StoreState = StoreState, TResetPayload extends void | Payload = void | Payload> = {
5
+ (resetPayload: TResetPayload, resetReducer: Reducer<TStoreState, TResetPayload>): void;
6
+ };
@@ -0,0 +1,7 @@
1
+ import type { InstanceKey } from '../InstanceKey.tsx';
2
+ import type { Listener } from './Listener.tsx';
3
+ import type { StoreState } from '../StoreState.tsx';
4
+ import type { Unsubscribe } from './Unsubscribe.tsx';
5
+ export type Subscribe<TStoreState extends StoreState = StoreState> = {
6
+ (instanceKey: InstanceKey, listener: Listener<TStoreState>): Unsubscribe;
7
+ };
@@ -0,0 +1,6 @@
1
+ import type { ListenerAll } from './ListenerAll.tsx';
2
+ import type { StoreState } from '../StoreState.tsx';
3
+ import type { UnsubscribeAll } from './UnsubscribeAll.tsx';
4
+ export type SubscribeAll<TStoreState extends StoreState = StoreState> = {
5
+ (listener: ListenerAll<TStoreState>): UnsubscribeAll;
6
+ };
@@ -0,0 +1,3 @@
1
+ export type Unsubscribe = {
2
+ (): void;
3
+ };
@@ -0,0 +1,3 @@
1
+ export type UnsubscribeAll = {
2
+ (): void;
3
+ };
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import { type InstanceKey } from './';
3
- import { type Reducer } from './';
4
- import { type StoreState } from './';
5
- export type InternalStoreProps<TStoreName extends string = string, TStoreState extends StoreState = StoreState, TInitReducer extends Reducer<TStoreState, any> = Reducer<TStoreState, any>, TResetReducer extends Reducer<TStoreState, any> = Reducer<TStoreState, any>> = {
6
- [`$$init`]: TInitReducer;
7
- [`$$reset`]: TResetReducer;
2
+ import type { InstanceKey } from './InstanceKey.tsx';
3
+ import type { ReducerMap } from './ReducerMap.tsx';
4
+ import type { StoreState } from './StoreState.tsx';
5
+ export type InternalStoreProps<TStoreName extends string = string, TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>> = {
6
+ [`$$init`]: TReducerMap[`$$init`];
7
+ [`$$reset`]: TReducerMap[`$$reset`];
8
8
  context: React.Context<null | InstanceKey>;
9
9
  initialState: TStoreState;
10
10
  name: TStoreName;
@@ -1,5 +1,5 @@
1
- import { type Payload } from './';
2
- import { type StoreState } from './';
1
+ import type { Payload } from './Payload.tsx';
2
+ import type { StoreState } from './StoreState.tsx';
3
3
  export type Reducer<TStoreState extends StoreState = StoreState, TPayload extends void | Payload = void | Payload> = {
4
4
  (state: TStoreState, payload: TPayload): TStoreState;
5
5
  };
@@ -1,11 +1,13 @@
1
1
  import { INTERNAL_STORE_PROPS_ACCESSOR } from '../constants.tsx';
2
2
  import { REDUCER_LINK } from '../constants.tsx';
3
- import { type InternalStoreProps } from './';
4
- import { type Reducer } from './';
5
- import { type StoreState } from './';
6
- export type ReducerLink<TStoreName extends string = string, TStoreState extends StoreState = StoreState, TInitReducer extends Reducer<TStoreState, any> = Reducer<TStoreState, any>, TResetReducer extends Reducer<TStoreState, any> = Reducer<TStoreState, any>, TReducerName extends string = string, TReducer extends Reducer<TStoreState, any> = Reducer<TStoreState, any>> = {
7
- [INTERNAL_STORE_PROPS_ACCESSOR]: InternalStoreProps<TStoreName, TStoreState, TInitReducer, TResetReducer>;
8
- reducer: TReducer;
3
+ import type { InternalStoreProps } from './InternalStoreProps.tsx';
4
+ import type { Reducer } from './Reducer.tsx';
5
+ import type { ReducerMap } from './ReducerMap.tsx';
6
+ import type { ReducerPayload } from './ReducerPayload.tsx';
7
+ import type { StoreState } from './StoreState.tsx';
8
+ export type ReducerLink<TStoreName extends string = string, TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>, TReducerName extends string = string> = {
9
+ [INTERNAL_STORE_PROPS_ACCESSOR]: InternalStoreProps<TStoreName, TStoreState, TReducerMap>;
10
+ reducer: Reducer<TStoreState, ReducerPayload<TReducerMap[TReducerName]>>;
9
11
  reducerName: TReducerName;
10
12
  type: typeof REDUCER_LINK;
11
13
  };
@@ -1,5 +1,5 @@
1
- import { type Reducer } from './';
2
- import { type StoreState } from './';
1
+ import type { Reducer } from './Reducer.tsx';
2
+ import type { StoreState } from './StoreState.tsx';
3
3
  export type ReducerMap<TStoreState extends StoreState = StoreState> = Record<string, Reducer<TStoreState, void | any>> & {
4
4
  [`$$init`]: Reducer<TStoreState, void | any>;
5
5
  [`$$reset`]: Reducer<TStoreState, void | any>;
@@ -1,4 +1,3 @@
1
- import { type Payload } from './';
2
- import { type Reducer } from './';
3
- import { type StoreState } from './';
4
- export type ReducerPayload<TStoreState extends StoreState = StoreState, TReducer extends Reducer<TStoreState, any> = Reducer<TStoreState, any>> = Parameters<TReducer>[1] extends Payload ? Parameters<TReducer>[1] : void;
1
+ import type { Payload } from './Payload.tsx';
2
+ import type { Reducer } from './Reducer.tsx';
3
+ export type ReducerPayload<TReducer extends Reducer<any, any> = Reducer<any, any>> = Parameters<TReducer>[1] extends Payload ? Parameters<TReducer>[1] : void;
@@ -1,6 +1,6 @@
1
1
  import { STORE_INSTANCE_UNREGISTERED } from '../constants.tsx';
2
- import { type InitInstance } from './';
3
- import { type Payload } from './';
2
+ import type { InitInstance } from './InitInstance.tsx';
3
+ import type { Payload } from './Payload.tsx';
4
4
  export type RegisterDefaultInstance<TInitPayload extends void | Payload = void | Payload, TResetPayload extends void | Payload = void | Payload> = {
5
5
  (initInstance: InitInstance<TInitPayload, TResetPayload>, instanceKey: void): () => typeof STORE_INSTANCE_UNREGISTERED;
6
6
  };
@@ -1,7 +1,7 @@
1
1
  import { STORE_INSTANCE_UNREGISTERED } from '../constants.tsx';
2
- import { type InitInstance } from './';
3
- import { type InstanceKey } from './';
4
- import { type Payload } from './';
2
+ import type { InitInstance } from './InitInstance.tsx';
3
+ import type { InstanceKey } from './InstanceKey.tsx';
4
+ import type { Payload } from './Payload.tsx';
5
5
  export type RegisterInstance<TInitPayload extends void | Payload = void | Payload, TResetPayload extends void | Payload = void | Payload> = {
6
6
  (initInstance: InitInstance<TInitPayload, TResetPayload>, instanceKey: InstanceKey): () => typeof STORE_INSTANCE_UNREGISTERED;
7
7
  };
@@ -0,0 +1,12 @@
1
+ import type { requestStatus } from '../../requestStatus.tsx';
2
+ import type { RequestStateMeta } from '../RequestStateMeta.tsx';
3
+ export type RequestAbortedState<TMeta extends RequestStateMeta = RequestStateMeta> = {
4
+ isIdle: false;
5
+ isPending: false;
6
+ isFulfilled: false;
7
+ isRejected: false;
8
+ isAborted: true;
9
+ status: typeof requestStatus.ABORTED | typeof requestStatus.FORCE_ABORTED;
10
+ error: null;
11
+ meta: null | TMeta;
12
+ };
@@ -0,0 +1,12 @@
1
+ import type { requestStatus } from '../../requestStatus.tsx';
2
+ import type { RequestStateMeta } from '../RequestStateMeta.tsx';
3
+ export type RequestFulfilledState<TMeta extends RequestStateMeta = RequestStateMeta> = {
4
+ isIdle: false;
5
+ isPending: false;
6
+ isFulfilled: true;
7
+ isRejected: false;
8
+ isAborted: false;
9
+ status: typeof requestStatus.FULFILLED | typeof requestStatus.FORCE_FULFILLED;
10
+ error: null;
11
+ meta: null | TMeta;
12
+ };
@@ -0,0 +1,12 @@
1
+ import type { requestStatus } from '../../requestStatus.tsx';
2
+ import type { RequestStateMeta } from '../RequestStateMeta.tsx';
3
+ export type RequestIdleState<TMeta extends RequestStateMeta = RequestStateMeta> = {
4
+ isIdle: true;
5
+ isPending: false;
6
+ isFulfilled: false;
7
+ isRejected: false;
8
+ isAborted: false;
9
+ status: typeof requestStatus.IDLE | typeof requestStatus.FORCE_IDLE;
10
+ error: null;
11
+ meta: null | TMeta;
12
+ };
@@ -0,0 +1,12 @@
1
+ import type { requestStatus } from '../../requestStatus.tsx';
2
+ import type { RequestStateMeta } from '../RequestStateMeta.tsx';
3
+ export type RequestPendingState<TMeta extends RequestStateMeta = RequestStateMeta> = {
4
+ isIdle: false;
5
+ isPending: true;
6
+ isFulfilled: false;
7
+ isRejected: false;
8
+ isAborted: false;
9
+ status: typeof requestStatus.PENDING | typeof requestStatus.FORCE_PENDING;
10
+ error: null;
11
+ meta: null | TMeta;
12
+ };
@@ -0,0 +1,12 @@
1
+ import type { requestStatus } from '../../requestStatus.tsx';
2
+ import type { RequestStateMeta } from '../RequestStateMeta.tsx';
3
+ export type RequestRejectedState<TMeta extends RequestStateMeta = RequestStateMeta, TResponseError extends unknown = unknown> = {
4
+ isIdle: false;
5
+ isPending: false;
6
+ isFulfilled: false;
7
+ isRejected: true;
8
+ isAborted: false;
9
+ status: typeof requestStatus.REJECTED | typeof requestStatus.FORCE_REJECTED;
10
+ error: null | TResponseError;
11
+ meta: null | TMeta;
12
+ };
@@ -0,0 +1,7 @@
1
+ import type { RequestAbortedState } from './RequestState/RequestAbortedState.tsx';
2
+ import type { RequestFulfilledState } from './RequestState/RequestFulfilledState.tsx';
3
+ import type { RequestIdleState } from './RequestState/RequestIdleState.tsx';
4
+ import type { RequestPendingState } from './RequestState/RequestPendingState.tsx';
5
+ import type { RequestRejectedState } from './RequestState/RequestRejectedState.tsx';
6
+ import type { RequestStateMeta } from './RequestStateMeta.tsx';
7
+ export type RequestState<TMeta extends RequestStateMeta = RequestStateMeta, TError extends unknown = unknown> = RequestIdleState<TMeta> | RequestPendingState<TMeta> | RequestFulfilledState<TMeta> | RequestRejectedState<TMeta, TError> | RequestAbortedState<TMeta>;
@@ -0,0 +1 @@
1
+ export type RequestStateMeta = Record<string, any>;
@@ -0,0 +1,5 @@
1
+ import type { RequestState } from './RequestState.tsx';
2
+ import type { StoreState } from './StoreState.tsx';
3
+ export type RequestStateStoreKey<TStoreState extends StoreState = StoreState> = {
4
+ [TKey in keyof TStoreState]: TStoreState[TKey] extends RequestState ? TKey : never;
5
+ }[keyof TStoreState];
@@ -1,5 +1,5 @@
1
1
  import { STORE_INSTANCE_UNREGISTERED } from '../constants.tsx';
2
- import { type Payload } from './';
2
+ import type { Payload } from './Payload.tsx';
3
3
  export type ResetInstance<TPayload extends void | Payload = void | Payload> = {
4
4
  (payload: TPayload): typeof STORE_INSTANCE_UNREGISTERED;
5
5
  };
@@ -1,4 +1,3 @@
1
- import { type ReducerMap } from './';
2
- import { type ReducerPayload } from './';
3
- import { type StoreState } from './';
4
- export type ResetPayload<TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>> = ReducerPayload<TStoreState, TReducerMap[`$$reset`]>;
1
+ import type { ReducerMap } from './ReducerMap.tsx';
2
+ import type { ReducerPayload } from './ReducerPayload.tsx';
3
+ export type ResetPayload<TReducerMap extends ReducerMap<any> = ReducerMap<any>> = ReducerPayload<TReducerMap[`$$reset`]>;
@@ -1,10 +1,10 @@
1
1
  import { INTERNAL_STORE_PROPS_ACCESSOR } from '../constants.tsx';
2
2
  import { STATE_LINK } from '../constants.tsx';
3
- import { type InternalStoreProps } from './';
4
- import { type Reducer } from './';
5
- import { type StoreState } from './';
6
- export type StateLink<TStoreName extends string = string, TStoreState extends StoreState = StoreState, TInitReducer extends Reducer<TStoreState, any> = Reducer<TStoreState, any>, TResetReducer extends Reducer<TStoreState, any> = Reducer<TStoreState, any>, TStateName extends keyof TStoreState = keyof TStoreState> = {
7
- [INTERNAL_STORE_PROPS_ACCESSOR]: InternalStoreProps<TStoreName, TStoreState, TInitReducer, TResetReducer>;
3
+ import type { InternalStoreProps } from './InternalStoreProps.tsx';
4
+ import type { ReducerMap } from './ReducerMap.tsx';
5
+ import type { StoreState } from './StoreState.tsx';
6
+ export type StateLink<TStoreName extends string = string, TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>, TStateName extends keyof TStoreState = keyof TStoreState> = {
7
+ [INTERNAL_STORE_PROPS_ACCESSOR]: InternalStoreProps<TStoreName, TStoreState, TReducerMap>;
8
8
  stateName: TStateName;
9
9
  type: typeof STATE_LINK;
10
10
  };
@@ -1,16 +1,16 @@
1
1
  import { INTERNAL_STORE_PROPS_ACCESSOR } from '../constants.tsx';
2
- import { type InternalStoreProps } from './';
3
- import { type ReducerMap } from './';
4
- import { type ReducerLink } from './';
5
- import { type StateLink } from './';
6
- import { type StoreState } from './';
2
+ import type { InternalStoreProps } from './InternalStoreProps.tsx';
3
+ import type { ReducerMap } from './ReducerMap.tsx';
4
+ import type { ReducerLink } from './ReducerLink.tsx';
5
+ import type { StateLink } from './StateLink.tsx';
6
+ import type { StoreState } from './StoreState.tsx';
7
7
  export type Store<TStoreName extends string = string, TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>> = {
8
- [INTERNAL_STORE_PROPS_ACCESSOR]: InternalStoreProps<TStoreName, TStoreState, TReducerMap[`$$init`], TReducerMap[`$$reset`]>;
8
+ [INTERNAL_STORE_PROPS_ACCESSOR]: InternalStoreProps<TStoreName, TStoreState, TReducerMap>;
9
9
  } & {
10
10
  [`$$init`]: void;
11
11
  [`$$reset`]: void;
12
12
  } & {
13
- [TKey in keyof TStoreState]: TKey extends string ? StateLink<TStoreName, TStoreState, TReducerMap[`$$init`], TReducerMap[`$$reset`], TKey> : never;
13
+ [TKey in keyof TStoreState]: TKey extends string ? StateLink<TStoreName, TStoreState, TReducerMap, TKey> : never;
14
14
  } & {
15
- [TKey in keyof TReducerMap]: TKey extends string ? TKey extends keyof TStoreState ? never : ReducerLink<TStoreName, TStoreState, TReducerMap[`$$init`], TReducerMap[`$$reset`], TKey, TReducerMap[TKey]> : never;
15
+ [TKey in keyof TReducerMap]: TKey extends string ? TKey extends keyof TStoreState ? never : ReducerLink<TStoreName, TStoreState, TReducerMap, TKey> : never;
16
16
  };
@@ -1,9 +1,10 @@
1
1
  import { InternalStore } from '../InternalStore.tsx';
2
- import { type InstanceKey } from './';
3
- import { type ReducerMap } from './';
4
- import { type StoreControllerInstance } from './StoreControllerInstance.tsx';
5
- import { type StoreState } from './';
2
+ import type { InstanceKey } from './InstanceKey.tsx';
3
+ import type { ReducerMap } from './ReducerMap.tsx';
4
+ import type { StoreInstanceController } from './StoreInstanceController.tsx';
5
+ import type { StoreState } from './StoreState.tsx';
6
6
  export type StoreController<TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>> = {
7
- internalStore: InternalStore<TStoreState, Parameters<TReducerMap[`$$init`]>[1], Parameters<TReducerMap[`$$reset`]>[1]>;
8
- instances: Record<InstanceKey, StoreControllerInstance<TStoreState, Parameters<TReducerMap[`$$reset`]>[1]>>;
7
+ internalStore: InternalStore<TStoreState, TReducerMap>;
8
+ instances: Record<InstanceKey, StoreInstanceController<TStoreState, Parameters<TReducerMap[`$$reset`]>[1]>>;
9
+ earlySubscribers: Record<InstanceKey, (() => void)[]>;
9
10
  };
@@ -0,0 +1,7 @@
1
+ import type { StoreState } from './StoreState.tsx';
2
+ import type { Payload } from './Payload.tsx';
3
+ import type { Reducer } from './Reducer.tsx';
4
+ export type StoreInstanceController<TStoreState extends StoreState = StoreState, TResetPayload extends void | Payload = void | Payload> = {
5
+ owners: symbol[];
6
+ resetState: (resetPayload: TResetPayload, resetReducer: Reducer<TStoreState, TResetPayload>) => void;
7
+ };
@@ -1,2 +1,2 @@
1
- import type { StoreController } from './';
1
+ import type { StoreController } from './StoreController.tsx';
2
2
  export type StoreRegistry = Record<symbol, StoreController>;
@@ -0,0 +1,7 @@
1
+ import type { InstanceKey } from './InstanceKey.tsx';
2
+ import type { ReducerMap } from './ReducerMap.tsx';
3
+ import type { StateLink } from './StateLink.tsx';
4
+ import type { StoreState } from './StoreState.tsx';
5
+ export type UseProp = {
6
+ <TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>, TStateName extends keyof TStoreState = keyof TStoreState>(stateLink: StateLink<string, TStoreState, TReducerMap, TStateName>, instanceKey?: InstanceKey): TStoreState[TStateName];
7
+ };
@@ -0,0 +1,7 @@
1
+ import type { InstanceKey } from './InstanceKey.tsx';
2
+ import type { ReducerMap } from './ReducerMap.tsx';
3
+ import type { StateLink } from './StateLink.tsx';
4
+ import type { StoreState } from './StoreState.tsx';
5
+ export type UsePropAll = {
6
+ <TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>, TStateName extends keyof TStoreState = keyof TStoreState>(stateLink: StateLink<string, TStoreState, TReducerMap, TStateName>, instanceKeys?: InstanceKey[] | ((state: TStoreState) => boolean)): [instanceKey: InstanceKey, state: TStoreState[TStateName]][];
7
+ };