_StoreWithState,
StoreProperties,
StoreOnActionListener,
+ _StoreOnActionListenerContext,
StoreOnActionListenerContext,
SubscriptionCallback,
SubscriptionCallbackMutation,
DefineStoreOptions,
DefineSetupStoreOptions,
DefineStoreOptionsInPlugin,
+ _ExtractActionsFromSetupStore,
+ _ExtractGettersFromSetupStore,
+ _ExtractStateFromSetupStore,
+ _DeepPartial,
+ _ExtractActionsFromSetupStore_Keys,
+ _ExtractGettersFromSetupStore_Keys,
+ _ExtractStateFromSetupStore_Keys,
+ _UnwrapAll,
} from './types'
export { MutationType } from './types'
import {
StateTree,
SubscriptionCallback,
- DeepPartial,
+ _DeepPartial,
isPlainObject,
Store,
_Method,
function mergeReactiveObjects<T extends StateTree>(
target: T,
- patchToApply: DeepPartial<T>
+ patchToApply: _DeepPartial<T>
): T {
// no need to go through symbols because they cannot be serialized anyway
for (const key in patchToApply) {
const hotState = ref({} as S)
function $patch(stateMutation: (state: UnwrapRef<S>) => void): void
- function $patch(partialState: DeepPartial<UnwrapRef<S>>): void
+ function $patch(partialState: _DeepPartial<UnwrapRef<S>>): void
function $patch(
partialStateOrMutator:
- | DeepPartial<UnwrapRef<S>>
+ | _DeepPartial<UnwrapRef<S>>
| ((state: UnwrapRef<S>) => void)
): void {
let subscriptionMutation: SubscriptionCallbackMutation<S>
*
* @internal
*/
-export type DeepPartial<T> = { [K in keyof T]?: DeepPartial<T[K]> }
+export type _DeepPartial<T> = { [K in keyof T]?: _DeepPartial<T[K]> }
// type DeepReadonly<T> = { readonly [P in keyof T]: DeepReadonly<T[P]> }
// TODO: can we change these to numbers?
/**
* Object passed to `store.$patch()`.
*/
- payload: DeepPartial<S>
+ payload: _DeepPartial<S>
}
/**
| SubscriptionCallbackMutationPatchObject<S>
| SubscriptionCallbackMutationPatchFunction
-export type UnwrapPromise<T> = T extends Promise<infer V> ? V : T
-
/**
* Callback of a subscription
*/
/**
* Actual type for {@link StoreOnActionListenerContext}. Exists for refactoring
* purposes. For internal use only.
+ * @internal
*/
-interface _StoreOnActionListenerContext<Store, ActionName extends string, A> {
+export interface _StoreOnActionListenerContext<
+ Store,
+ ActionName extends string,
+ A
+> {
/**
* Name of the action
*/
after: (
callback: A extends Record<ActionName, _Method>
? (
- resolvedReturn: UnwrapPromise<ReturnType<A[ActionName]>>
+ resolvedReturn: Awaited<ReturnType<A[ActionName]>>
// allow the after callback to override the return value
) =>
| void
| ReturnType<A[ActionName]>
- | UnwrapPromise<ReturnType<A[ActionName]>>
+ | Awaited<ReturnType<A[ActionName]>>
: () => void
) => void
*
* @param partialState - patch to apply to the state
*/
- $patch(partialState: DeepPartial<UnwrapRef<S>>): void
+ $patch(partialState: _DeepPartial<UnwrapRef<S>>): void
/**
* Group multiple changes into one function. Useful when mutating objects like
export type _ActionsTree = Record<string, _Method>
/**
+ * Type that enables refactoring through IDE.
* @internal
*/
-type _ExtractStateFromSetupStore_Keys<SS> = keyof {
+export type _ExtractStateFromSetupStore_Keys<SS> = keyof {
[K in keyof SS as SS[K] extends _Method | ComputedRef ? never : K]: any
}
/**
+ * Type that enables refactoring through IDE.
* @internal
*/
-type _ExtractActionsFromSetupStore_Keys<SS> = keyof {
+export type _ExtractActionsFromSetupStore_Keys<SS> = keyof {
[K in keyof SS as SS[K] extends _Method ? K : never]: any
}
/**
+ * Type that enables refactoring through IDE.
* @internal
*/
-type _ExtractGettersFromSetupStore_Keys<SS> = keyof {
+export type _ExtractGettersFromSetupStore_Keys<SS> = keyof {
[K in keyof SS as SS[K] extends ComputedRef ? K : never]: any
}
/**
+ * Type that enables refactoring through IDE.
* @internal
*/
-type _UnwrapAll<SS> = { [K in keyof SS]: UnwrapRef<SS[K]> }
+export type _UnwrapAll<SS> = { [K in keyof SS]: UnwrapRef<SS[K]> }
/**
* @internal