beestate 0.1.3 → 0.1.5
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 +1 -0
- package/dist/@types/InternalStore.d.ts +21 -30
- package/dist/@types/StoreProvider.d.ts +2 -2
- package/dist/@types/createStore.d.ts +5 -6
- package/dist/@types/createStoreRegistry.d.ts +8 -5
- package/dist/@types/createUseDispatcher.d.ts +6 -6
- package/dist/@types/createUseLatest.d.ts +11 -0
- package/dist/@types/createUseProp.d.ts +3 -6
- package/dist/@types/createUsePropAll.d.ts +3 -6
- package/dist/@types/createUseStore.d.ts +11 -11
- package/dist/@types/index.d.ts +11 -3
- package/dist/@types/pipe/Error.d.ts +6 -0
- package/dist/@types/pipe/check.d.ts +37 -0
- package/dist/@types/pipe/createPipeKit.d.ts +24 -0
- package/dist/@types/pipe/debug/createDebugger.d.ts +2 -0
- package/dist/@types/pipe/debug/debugInstruction.d.ts +1 -0
- package/dist/@types/pipe/debug/extendedDebugInstruction.d.ts +5 -0
- package/dist/@types/pipe/debug/index.d.ts +4 -0
- package/dist/@types/pipe/debug/log.d.ts +2 -0
- package/dist/@types/pipe/deepCopy.env-detect.dev.d.ts +1 -0
- package/dist/@types/pipe/deepCopy.env-detect.main.d.ts +4 -0
- package/dist/@types/pipe/entities/Adjunct.d.ts +3 -0
- package/dist/@types/pipe/entities/Connect.d.ts +9 -0
- package/dist/@types/pipe/entities/DataBarrel.d.ts +24 -0
- package/dist/@types/pipe/entities/Fill.d.ts +25 -0
- package/dist/@types/pipe/entities/Instruction.d.ts +81 -0
- package/dist/@types/pipe/entities/ParentPipe.d.ts +9 -0
- package/dist/@types/pipe/entities/Pipe.d.ts +57 -0
- package/dist/@types/pipe/entities/Stream.d.ts +13 -0
- package/dist/@types/pipe/entities/StreamGroup.d.ts +25 -0
- package/dist/@types/pipe/entities/index.d.ts +9 -0
- package/dist/@types/pipe/index.core.d.ts +26 -0
- package/dist/@types/pipe/index.d.ts +4 -0
- package/dist/@types/pipe/index.debug.d.ts +14 -0
- package/dist/@types/pipe/instruction.d.ts +9 -0
- package/dist/@types/requestState.d.ts +19 -0
- package/dist/@types/requestStateDefault.d.ts +7 -0
- package/dist/@types/requestStatus.d.ts +12 -0
- package/dist/@types/types/Dispatcher.d.ts +5 -7
- package/dist/@types/types/InitInstance.d.ts +2 -2
- package/dist/@types/types/InitPayload.d.ts +3 -4
- package/dist/@types/types/InternalStoreProps.d.ts +6 -6
- package/dist/@types/types/Reducer.d.ts +2 -2
- package/dist/@types/types/ReducerLink.d.ts +8 -6
- package/dist/@types/types/ReducerMap.d.ts +2 -2
- package/dist/@types/types/ReducerPayload.d.ts +3 -4
- package/dist/@types/types/RegisterDefaultInstance.d.ts +2 -2
- package/dist/@types/types/RegisterInstance.d.ts +3 -3
- package/dist/@types/types/RequestState/RequestAbortedState.d.ts +12 -0
- package/dist/@types/types/RequestState/RequestFulfilledState.d.ts +12 -0
- package/dist/@types/types/RequestState/RequestIdleState.d.ts +12 -0
- package/dist/@types/types/RequestState/RequestPendingState.d.ts +12 -0
- package/dist/@types/types/RequestState/RequestRejectedState.d.ts +12 -0
- package/dist/@types/types/RequestState.d.ts +7 -0
- package/dist/@types/types/RequestStateMeta.d.ts +1 -0
- package/dist/@types/types/RequestStateStoreKey.d.ts +5 -0
- package/dist/@types/types/ResetInstance.d.ts +1 -1
- package/dist/@types/types/ResetPayload.d.ts +3 -4
- package/dist/@types/types/StateLink.d.ts +5 -5
- package/dist/@types/types/Store.d.ts +8 -8
- package/dist/@types/types/StoreController.d.ts +5 -5
- package/dist/@types/types/StoreControllerInstance.d.ts +3 -3
- package/dist/@types/types/StoreRegistry.d.ts +1 -1
- package/dist/@types/types/UseProp.d.ts +7 -0
- package/dist/@types/types/UsePropAll.d.ts +7 -0
- package/dist/@types/types/index.d.ts +10 -0
- package/dist/cjs/index.cjs.js +140 -46
- package/dist/esm/index.esm.js +140 -48
- package/package.json +2 -1
|
@@ -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,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: <TError extends Error = Error, TMeta extends RequestStateMeta = RequestStateMeta>(error?: null | TError, meta?: null | TMeta) => RequestRejectedState<TError, TMeta>;
|
|
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: <TError extends Error = Error, TMeta extends RequestStateMeta = RequestStateMeta>(error?: null | TError, meta?: null | TMeta) => RequestRejectedState<TError, TMeta>;
|
|
18
|
+
forceAborted: <TMeta extends RequestStateMeta = RequestStateMeta>(meta?: null | TMeta) => RequestAbortedState<TMeta>;
|
|
19
|
+
};
|
|
@@ -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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(payload: ReducerPayload<TStoreState, TReducer>): void;
|
|
7
|
-
(instanceKey: InstanceKey, payload: ReducerPayload<TStoreState, TReducer>): void;
|
|
1
|
+
import type { InstanceKey } from './index.tsx';
|
|
2
|
+
import type { Payload } from './index.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 {
|
|
2
|
-
import {
|
|
1
|
+
import type { Payload } from './index.tsx';
|
|
2
|
+
import type { ResetInstance } from './index.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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export type InitPayload<TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>> = ReducerPayload<TStoreState, TReducerMap[`$$init`]>;
|
|
1
|
+
import type { ReducerMap } from './index.tsx';
|
|
2
|
+
import type { ReducerPayload } from './index.tsx';
|
|
3
|
+
export type InitPayload<TReducerMap extends ReducerMap<any> = ReducerMap<any>> = ReducerPayload<TReducerMap[`$$init`]>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export type InternalStoreProps<TStoreName extends string = string, TStoreState extends StoreState = StoreState,
|
|
6
|
-
[`$$init`]:
|
|
7
|
-
[`$$reset`]:
|
|
2
|
+
import type { InstanceKey } from './index.tsx';
|
|
3
|
+
import type { ReducerMap } from './index.tsx';
|
|
4
|
+
import type { StoreState } from './index.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 {
|
|
2
|
-
import {
|
|
1
|
+
import type { Payload } from './index.tsx';
|
|
2
|
+
import type { StoreState } from './index.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 {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import type { InternalStoreProps } from './index.tsx';
|
|
4
|
+
import type { Reducer } from './index.tsx';
|
|
5
|
+
import type { ReducerMap } from './index.tsx';
|
|
6
|
+
import type { ReducerPayload } from './index.tsx';
|
|
7
|
+
import type { StoreState } from './index.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 {
|
|
2
|
-
import {
|
|
1
|
+
import type { Reducer } from './index.tsx';
|
|
2
|
+
import type { StoreState } from './index.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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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 './index.tsx';
|
|
2
|
+
import type { Reducer } from './index.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 {
|
|
3
|
-
import {
|
|
2
|
+
import type { InitInstance } from './index.tsx';
|
|
3
|
+
import type { Payload } from './index.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 {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import type { InitInstance } from './index.tsx';
|
|
3
|
+
import type { InstanceKey } from './index.tsx';
|
|
4
|
+
import type { Payload } from './index.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<TResponseError extends Error = Error, TMeta extends RequestStateMeta = RequestStateMeta> = {
|
|
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<TError extends Error = Error, TMeta extends RequestStateMeta = RequestStateMeta> = RequestIdleState<TMeta> | RequestPendingState<TMeta> | RequestFulfilledState<TMeta> | RequestRejectedState<TError, TMeta> | 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 {
|
|
2
|
+
import type { Payload } from './index.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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export type ResetPayload<TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>> = ReducerPayload<TStoreState, TReducerMap[`$$reset`]>;
|
|
1
|
+
import type { ReducerMap } from './index.tsx';
|
|
2
|
+
import type { ReducerPayload } from './index.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 {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export type StateLink<TStoreName extends string = string, TStoreState extends StoreState = StoreState,
|
|
7
|
-
[INTERNAL_STORE_PROPS_ACCESSOR]: InternalStoreProps<TStoreName, TStoreState,
|
|
3
|
+
import type { InternalStoreProps } from './index.tsx';
|
|
4
|
+
import type { ReducerMap } from './index.tsx';
|
|
5
|
+
import type { StoreState } from './index.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 {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import type { InternalStoreProps } from './index.tsx';
|
|
3
|
+
import type { ReducerMap } from './index.tsx';
|
|
4
|
+
import type { ReducerLink } from './index.tsx';
|
|
5
|
+
import type { StateLink } from './index.tsx';
|
|
6
|
+
import type { StoreState } from './index.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
|
|
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
|
|
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
|
|
15
|
+
[TKey in keyof TReducerMap]: TKey extends string ? TKey extends keyof TStoreState ? never : ReducerLink<TStoreName, TStoreState, TReducerMap, TKey> : never;
|
|
16
16
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { InternalStore } from '../InternalStore.tsx';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import type { InstanceKey } from './index.tsx';
|
|
3
|
+
import type { ReducerMap } from './index.tsx';
|
|
4
|
+
import type { StoreControllerInstance } from './index.tsx';
|
|
5
|
+
import type { StoreState } from './index.tsx';
|
|
6
6
|
export type StoreController<TStoreState extends StoreState = StoreState, TReducerMap extends ReducerMap<TStoreState> = ReducerMap<TStoreState>> = {
|
|
7
|
-
internalStore: InternalStore<TStoreState,
|
|
7
|
+
internalStore: InternalStore<TStoreState, TReducerMap>;
|
|
8
8
|
instances: Record<InstanceKey, StoreControllerInstance<TStoreState, Parameters<TReducerMap[`$$reset`]>[1]>>;
|
|
9
9
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { StoreState } from './';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { StoreState } from './index.tsx';
|
|
2
|
+
import type { Payload } from './index.tsx';
|
|
3
|
+
import type { Reducer } from './index.tsx';
|
|
4
4
|
export type StoreControllerInstance<TStoreState extends StoreState = StoreState, TResetPayload extends void | Payload = void | Payload> = {
|
|
5
5
|
owners: symbol[];
|
|
6
6
|
resetState: (resetPayload: TResetPayload, resetReducer: Reducer<TStoreState, TResetPayload>) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { StoreController } from './';
|
|
1
|
+
import type { StoreController } from './index.tsx';
|
|
2
2
|
export type StoreRegistry = Record<symbol, StoreController>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InstanceKey } from './index.tsx';
|
|
2
|
+
import type { ReducerMap } from './index.tsx';
|
|
3
|
+
import type { StateLink } from './index.tsx';
|
|
4
|
+
import type { StoreState } from './index.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 './index.tsx';
|
|
2
|
+
import type { ReducerMap } from './index.tsx';
|
|
3
|
+
import type { StateLink } from './index.tsx';
|
|
4
|
+
import type { StoreState } from './index.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
|
+
};
|
|
@@ -10,6 +10,14 @@ export * from './ReducerMap.tsx';
|
|
|
10
10
|
export * from './ReducerPayload.tsx';
|
|
11
11
|
export * from './RegisterDefaultInstance.tsx';
|
|
12
12
|
export * from './RegisterInstance.tsx';
|
|
13
|
+
export * from './RequestState/RequestAbortedState.tsx';
|
|
14
|
+
export * from './RequestState/RequestFulfilledState.tsx';
|
|
15
|
+
export * from './RequestState/RequestIdleState.tsx';
|
|
16
|
+
export * from './RequestState/RequestPendingState.tsx';
|
|
17
|
+
export * from './RequestState/RequestRejectedState.tsx';
|
|
18
|
+
export * from './RequestState.tsx';
|
|
19
|
+
export * from './RequestStateMeta.tsx';
|
|
20
|
+
export * from './RequestStateStoreKey.tsx';
|
|
13
21
|
export * from './ResetInstance.tsx';
|
|
14
22
|
export * from './ResetPayload.tsx';
|
|
15
23
|
export * from './StateLink.tsx';
|
|
@@ -18,3 +26,5 @@ export * from './StoreController.tsx';
|
|
|
18
26
|
export * from './StoreControllerInstance.tsx';
|
|
19
27
|
export * from './StoreRegistry.tsx';
|
|
20
28
|
export * from './StoreState.tsx';
|
|
29
|
+
export * from './UseProp.tsx';
|
|
30
|
+
export * from './UsePropAll.tsx';
|