import * as rtk from '@reduxjs/toolkit'; import { Action, AnyAction, EnhancedStore, PayloadAction } from '@reduxjs/toolkit'; import { AugmentedMiddlewareAPI, DuxActions, DuxConfig, DuxReaction, DuxSelectors, DuxState, Mutation } from './types.js'; import { EffectMiddleware } from './effects.js'; type CreateStoreOptions = Partial<{ preloadedState: DuxState; }>; interface ActionCreator> { type: T; match: (action: Action) => action is PayloadAction; (...args: A): PayloadAction; } /** * @description main Updux class */ export default class Updux { #private; private readonly duxConfig; constructor(duxConfig: D); /** * @description Initial state of the dux. */ get initialState(): DuxState; get subduxes(): {}; get actions(): DuxActions; createStore(options?: CreateStoreOptions): EnhancedStore> & AugmentedMiddlewareAPI; addAction(action: ActionCreator): void; addSelector(name: N, selector: (state: DuxState) => R): Updux) => R>; }>; addMutation>(actionType: A, mutation: Mutation[A] extends (...args: any[]) => infer R ? R : AnyAction, DuxState>, terminal?: boolean): Updux; addMutation>(actionCreator: AC, mutation: Mutation, DuxState>, terminal?: boolean): Updux; }>; addMutation>(actionCreator: ActionCreator, mutation: Mutation>, DuxState>, terminal?: boolean): Updux>; }>; addMutation(matcher: (action: AnyAction) => boolean, mutation: Mutation>, terminal?: boolean): Updux; setDefaultMutation(mutation: Mutation>, terminal?: boolean): Updux; get reducer(): any; get selectors(): DuxSelectors; addEffect>(actionType: A, effect: EffectMiddleware[A] extends (...args: any[]) => infer R ? R : AnyAction>): Updux; addEffect>(actionCreator: AC, effect: EffectMiddleware>): Updux; }>; addEffect(guardFunc: (action: AnyAction) => boolean, effect: EffectMiddleware): Updux; addEffect(effect: EffectMiddleware): Updux; get effects(): any[]; get upreducer(): (action: AnyAction) => (state?: DuxState) => DuxState; addReaction(reaction: DuxReaction): this; get reactions(): any; get defaultMutation(): { terminal: boolean; mutation: Mutation : unknown) extends infer T ? T extends (D extends { initialState: any; } ? D["initialState"] : {}) & (D extends { subduxes: any; } ? import("./types.js").SubduxesState : unknown) ? T extends { [key: string]: any; } ? { [key in keyof T]: T[key]; } : T : never : never>; }; /** * @description Returns an object holding the Updux reducer and all its * paraphernalia. */ get asDux(): { initialState: DuxState; actions: DuxActions; reducer: (state: DuxState, action: AnyAction) => DuxState; effects: EffectMiddleware[]; reactions: DuxReaction[]; }; } export {};