wevu 6.13.0 → 6.13.2
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-BPZxNlC8.d.mts +246 -0
- package/dist/{index-B7QVA9YG.d.mts → index-BvyrZ_XI.d.mts} +524 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/router-DW4Yf9Yj.d.mts +46 -0
- package/dist/router.d.mts +1 -1
- package/dist/{src-DLHIGzBf.mjs → src-xqSS8INA.mjs} +6 -2
- package/dist/store.d.mts +1 -1
- package/dist/vue-demi.d.mts +3 -4
- package/dist/vue-demi.mjs +1 -2
- package/package.json +3 -3
- package/dist/index-CJdlA5zG.d.mts +0 -112
- package/dist/vue-types-D8BVm-8u.d.mts +0 -698
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/runtime/types/props/router.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Router 路由类型映射(供声明合并扩展)。
|
|
4
|
+
*
|
|
5
|
+
* 典型用法:在业务项目的类型声明中补充 `entries` 联合类型,
|
|
6
|
+
* 让 `useNativeRouter()/useNativePageRouter()` 的 `url` 参数获得字面量约束。
|
|
7
|
+
*/
|
|
8
|
+
interface WevuTypedRouterRouteMap {}
|
|
9
|
+
type ResolveTypedRouterEntries = WevuTypedRouterRouteMap extends {
|
|
10
|
+
entries: infer Entries;
|
|
11
|
+
} ? Extract<Entries, string> : string;
|
|
12
|
+
type ResolveTypedRouterTabBarEntries = WevuTypedRouterRouteMap extends {
|
|
13
|
+
tabBarEntries: infer Entries;
|
|
14
|
+
} ? Extract<Entries, string> : ResolveTypedRouterEntries;
|
|
15
|
+
type RelativeRouterUrl = `./${string}` | `../${string}`;
|
|
16
|
+
type AbsoluteRouterPath<Path extends string> = Path | `/${Path}`;
|
|
17
|
+
type AbsoluteRouterUrl<Path extends string> = AbsoluteRouterPath<Path> | `${Path}?${string}` | `/${Path}?${string}`;
|
|
18
|
+
type RouterUrl<Path extends string> = string extends Path ? string : AbsoluteRouterUrl<Path> | RelativeRouterUrl;
|
|
19
|
+
type RouterPathUrl<Path extends string> = string extends Path ? string : AbsoluteRouterPath<Path>;
|
|
20
|
+
type TypedRouterUrl = RouterUrl<ResolveTypedRouterEntries>;
|
|
21
|
+
type TypedRouterTabBarUrl = RouterPathUrl<ResolveTypedRouterTabBarEntries>;
|
|
22
|
+
type RouterSwitchTabOption = Omit<WechatMiniprogram.SwitchTabOption, 'url'> & {
|
|
23
|
+
url: TypedRouterTabBarUrl;
|
|
24
|
+
};
|
|
25
|
+
type RouterReLaunchOption = Omit<WechatMiniprogram.ReLaunchOption, 'url'> & {
|
|
26
|
+
url: TypedRouterUrl;
|
|
27
|
+
};
|
|
28
|
+
type RouterRedirectToOption = Omit<WechatMiniprogram.RedirectToOption, 'url'> & {
|
|
29
|
+
url: TypedRouterUrl;
|
|
30
|
+
};
|
|
31
|
+
type RouterNavigateToOption = Omit<WechatMiniprogram.NavigateToOption, 'url'> & {
|
|
32
|
+
url: TypedRouterUrl;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* setup 场景下推荐使用的 Router 类型。
|
|
36
|
+
* 默认行为与原生 Router 一致;声明合并后可获得更精确的 `url` 类型提示。
|
|
37
|
+
*/
|
|
38
|
+
interface SetupContextRouter {
|
|
39
|
+
switchTab: (option: RouterSwitchTabOption) => ReturnType<WechatMiniprogram.Component.Router['switchTab']>;
|
|
40
|
+
reLaunch: (option: RouterReLaunchOption) => ReturnType<WechatMiniprogram.Component.Router['reLaunch']>;
|
|
41
|
+
redirectTo: (option: RouterRedirectToOption) => ReturnType<WechatMiniprogram.Component.Router['redirectTo']>;
|
|
42
|
+
navigateTo: (option: RouterNavigateToOption) => ReturnType<WechatMiniprogram.Component.Router['navigateTo']>;
|
|
43
|
+
navigateBack: WechatMiniprogram.Component.Router['navigateBack'];
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { SetupContextRouter as a, WevuTypedRouterRouteMap as c, RouterSwitchTabOption as i, RouterReLaunchOption as n, TypedRouterTabBarUrl as o, RouterRedirectToOption as r, TypedRouterUrl as s, RouterNavigateToOption as t };
|
package/dist/router.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SetupContextRouter, c as WevuTypedRouterRouteMap, i as RouterSwitchTabOption, n as RouterReLaunchOption, o as TypedRouterTabBarUrl, r as RouterRedirectToOption, s as TypedRouterUrl, t as RouterNavigateToOption } from "./router-DW4Yf9Yj.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/routerInternal/types.d.ts
|
|
4
4
|
interface RouteResolveCodec {
|
|
@@ -430,6 +430,9 @@ function watchSyncEffect(effectFn, options = {}) {
|
|
|
430
430
|
});
|
|
431
431
|
}
|
|
432
432
|
//#endregion
|
|
433
|
+
//#region src/version.ts
|
|
434
|
+
const version = "6.13.2";
|
|
435
|
+
//#endregion
|
|
433
436
|
//#region src/utils.ts
|
|
434
437
|
function capitalize(str) {
|
|
435
438
|
if (!str) return "";
|
|
@@ -4607,7 +4610,8 @@ function createApp(options) {
|
|
|
4607
4610
|
for (const cleanup of appUnmountCleanups) cleanup();
|
|
4608
4611
|
appUnmountCleanups.clear();
|
|
4609
4612
|
},
|
|
4610
|
-
config: appConfig
|
|
4613
|
+
config: appConfig,
|
|
4614
|
+
version
|
|
4611
4615
|
};
|
|
4612
4616
|
const hasGlobalApp = typeof App === "function";
|
|
4613
4617
|
try {
|
|
@@ -5518,4 +5522,4 @@ function useTemplateRef(name) {
|
|
|
5518
5522
|
return target;
|
|
5519
5523
|
}
|
|
5520
5524
|
//#endregion
|
|
5521
|
-
export {
|
|
5525
|
+
export { onBeforeMount as $, registerApp as A, resetWevuDefaults as B, resolveLayoutBridge as C, useLayoutBridge as D, unregisterRuntimeLayoutHosts as E, resolveRuntimePageLayoutName as F, watch as G, isNoSetData as H, setPageLayout as I, watchSyncEffect as J, watchEffect as K, syncRuntimePageLayoutState as L, setRuntimeSetDataVisibility as M, teardownRuntimeInstance as N, useLayoutHosts as O, runSetupFunction as P, onActivated as Q, syncRuntimePageLayoutStateFromRuntime as R, registerRuntimeLayoutHosts as S, unregisterPageLayoutBridge as T, markNoSetData as U, setWevuDefaults as V, version as W, setDeepWatchStrategy as X, getDeepWatchStrategy as Y, callUpdateHooks as Z, createWevuScopedSlotComponent as _, useAttrs as a, onServerPrefetch as at, registerComponent as b, defineAppSetup as c, traverse as ct, normalizeClass as d, isShallowRef as dt, onBeforeUnmount as et, normalizeStyle as f, shallowRef as ft, createWevuComponent as g, useDisposables as h, useModel as i, onMounted as it, mountRuntimeInstance as j, waitForLayoutHost as k, use as l, toRef as lt, useIntersectionObserver as m, mergeModels as n, onDeactivated as nt, useNativeInstance as o, onUnmounted as ot, usePageScrollThrottle as p, triggerRef as pt, watchPostEffect as q, useBindModel as r, onErrorCaptured as rt, useSlots as s, onUpdated as st, useTemplateRef as t, onBeforeUpdate as tt, useUpdatePerformanceListener as u, toRefs as ut, defineComponent as v, resolveLayoutHost as w, registerPageLayoutBridge as x, createApp as y, usePageLayout as z };
|
package/dist/store.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ActionContext, c as MutationType, d as SubscriptionCallback, i as defineStore, l as StoreManager, n as storeToRefs, o as ActionSubscriber, r as createStore, s as DefineStoreOptions, t as StoreToRefsResult, u as StoreSubscribeOptions } from "./index-
|
|
1
|
+
import { a as ActionContext, c as MutationType, d as SubscriptionCallback, i as defineStore, l as StoreManager, n as storeToRefs, o as ActionSubscriber, r as createStore, s as DefineStoreOptions, t as StoreToRefsResult, u as StoreSubscribeOptions } from "./index-BPZxNlC8.mjs";
|
|
2
2
|
export { ActionContext, ActionSubscriber, DefineStoreOptions, MutationType, StoreManager, StoreSubscribeOptions, StoreToRefsResult, SubscriptionCallback, createStore, defineStore, storeToRefs };
|
package/dist/vue-demi.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import {
|
|
3
|
-
import { a as
|
|
4
|
-
import { version } from "vue";
|
|
1
|
+
import { $ as PropOptions, A as CustomRefSource, B as ComponentPropsOptions, C as ComputedRef, D as computed, E as WritableComputedRef, F as customRef, G as InferNativeProps, H as ExtractPropTypes, I as isRef, J as NativePropType, K as InferPropType, L as ref, M as MaybeRefOrGetter, N as Ref, O as CustomRefFactory, P as ShallowRef, Q as PropConstructor, R as toValue, S as ComputedGetter, T as WritableComputedOptions, U as ExtractPublicPropTypes, V as ExtractDefaultPropTypes, W as InferNativePropType, X as NativeTypeHint, Y as NativePropsOptions, Z as NativeTypedProperty, _ as ObjectDirective, a as ActionContext, b as VNode, c as MutationType, d as SubscriptionCallback, et as PropType, f as AllowedComponentProps, g as NativeComponent, h as DefineComponent, i as defineStore, j as MaybeRef, k as CustomRefOptions, l as StoreManager, m as ComponentOptionsMixin, n as storeToRefs, o as ActionSubscriber, p as ComponentCustomProps, q as InferProps, r as createStore, s as DefineStoreOptions, t as StoreToRefsResult, u as StoreSubscribeOptions, v as PublicProps, w as ComputedSetter, x as VNodeProps, y as ShallowUnwrapRef, z as unref } from "./index-BPZxNlC8.mjs";
|
|
2
|
+
import { a as SetupContextRouter, c as WevuTypedRouterRouteMap } from "./router-DW4Yf9Yj.mjs";
|
|
3
|
+
import { $ as WevuPageLayoutMap, $n as MiniProgramInstance, $r as MutationOp, $t as onUnhandledRejection, A as use, An as WevuGlobalDirectives, Ar as traverse, At as onUpdated, B as teardownRuntimeInstance, Bn as SetupFunction, Br as shallowReadonly, Bt as onPageNotFound, C as UseModelOptions, Cn as setWevuDefaults, Cr as WatchScheduler, Ct as onBeforeUnmount, D as useAttrs, Dn as TemplateRefValue, Dr as WatchStopHandle, Dt as onMounted, E as useModel, En as GlobalDirectives, Er as WatchSources, Et as onErrorCaptured, F as normalizeClass, Fn as PageFeatures, Fr as shallowRef, Ft as onHide, G as injectGlobal, Gn as RuntimeInstance, Gr as reactive, Gt as onResize, H as registerApp, Hn as InternalRuntimeState, Hr as isRaw, Ht as onPullDownRefresh, I as normalizeStyle, In as SetDataDebugInfo, Ir as triggerRef, It as onLaunch, J as setGlobalProvidedValue, Jn as MiniProgramAppOptions, Jr as shallowReactive, Jt as onShareAppMessage, K as provide, Kn as WevuPlugin, Kr as toRaw, Kt as onRouteDone, L as runSetupFunction, Ln as SetDataSnapshotOptions, Lr as isProxy, Lt as onLoad, M as UpdatePerformanceListenerResult, Mn as DataOption, Mr as toRef, Mt as onAttached, N as UseUpdatePerformanceListenerStopHandle, Nn as DefineAppOptions, Nr as toRefs, Nt as onDetached, O as useNativeInstance, On as TemplateRefs, Or as getDeepWatchStrategy, Ot as onServerPrefetch, P as useUpdatePerformanceListener, Pn as DefineComponentOptions, Pr as isShallowRef, Pt as onError, Q as PageLayoutState, Qn as MiniProgramComponentRawOptions, Qr as MutationKind, Qt as onThemeChange, R as mountRuntimeInstance, Rn as SetupContext, Rr as isReadonly, Rt as onMemoryWarning, S as ModelModifiers, Sn as resetWevuDefaults, Sr as WatchOptions, St as onBeforeMount, T as useBindModel, Tn as GlobalComponents, Tr as WatchSourceValue, Tt as onDeactivated, U as hasInjectionContext, Un as InternalRuntimeStateFields, Ur as isReactive, Ut as onReachBottom, V as registerComponent, Vn as AppConfig, Vr as getReactiveVersion, Vt as onPageScroll, W as inject, Wn as RuntimeApp, Wr as markRaw, Wt as onReady, X as UsePageScrollThrottleStopHandle, Xn as MiniProgramComponentBehaviorOptions, Xr as prelinkReactiveTree, Xt as onShow, Y as UsePageScrollThrottleOptions, Yn as MiniProgramBehaviorIdentifier, Yr as PrelinkReactiveTreeOptions, Yt as onShareTimeline, Z as usePageScrollThrottle, Zn as MiniProgramComponentOptions, Zr as touchReactive, Zt as onTabItemTap, _ as EmitsOptions, _n as WevuComponentConstructor, _r as OnCleanup, _t as UseIntersectionObserverOptions, a as PageLayoutMeta, ai as effect, an as setCurrentInstance, ar as ExtractMethods, at as isNoSetData, b as useNativePageRouter, bn as defineComponent, br as WatchEffectOptions, bt as callUpdateHooks, c as defineExpose, ci as getCurrentScope, cn as DisposableLike, cr as ModelBindingOptions, ct as registerPageLayoutBridge, d as definePageMeta, di as stop, dn as useDisposables, dr as watchEffect, dt as resolveLayoutHost, ei as MutationRecord, en as onUnload, er as MiniProgramPageLifetimes, et as resolveRuntimePageLayoutName, f as defineProps, fi as nextTick, fn as ComponentDefinition, fr as watchPostEffect, ft as unregisterPageLayoutBridge, g as EmitFn, gn as SetupFunctionWithTypeProps, gr as MultiWatchSources, gt as waitForLayoutHost, h as ComponentTypeEmits, hn as SetupContextWithTypeProps, hr as MaybeUndefined, ht as useLayoutHosts, i as ModelRef, ii as batch, in as getCurrentSetupContext, ir as ExtractComputed, it as usePageLayout, j as UpdatePerformanceListener, jn as CreateAppOptions, jr as ToRefs, jt as onAddToFavorites, k as useSlots, kn as WevuGlobalComponents, kr as setDeepWatchStrategy, kt as onUnmounted, l as defineModel, li as onScopeDispose, ln as DisposableMethodName, lr as ModelBindingPayload, lt as registerRuntimeLayoutHosts, m as withDefaults, mn as DefineComponentWithTypeProps, mr as MapSources, mt as useLayoutBridge, n as DefineModelModifiers, ni as removeMutationRecorder, nn as callHookReturn, nr as ComponentPublicInstance, nt as syncRuntimePageLayoutState, o as PageMeta, oi as effectScope, on as setCurrentSetupContext, or as MethodDefinitions, ot as markNoSetData, p as defineSlots, pn as DefineComponentTypePropsOptions, pr as watchSyncEffect, pt as unregisterRuntimeLayoutHosts, q as provideGlobal, qn as MiniProgramAdapter, qr as isShallowReactive, qt as onSaveExitState, r as DefineModelTransformOptions, ri as EffectScope, rn as getCurrentInstance, rr as ComputedDefinitions, rt as syncRuntimePageLayoutStateFromRuntime, s as defineEmits, si as endBatch, sn as DisposableBag, sr as ModelBinding, st as LayoutHostBinding, t as version, ti as addMutationRecorder, tn as callHookList, tr as TriggerEventOptions, tt as setPageLayout, u as defineOptions, ui as startBatch, un as DisposableObject, ur as watch, ut as resolveLayoutBridge, v as TemplateRef, vn as createWevuComponent, vr as WatchCallback, vt as UseIntersectionObserverResult, w as mergeModels, wn as createApp, wr as WatchSource, wt as onBeforeUpdate, x as useNativeRouter, xn as WevuDefaults, xr as WatchMultiSources, xt as onActivated, y as useTemplateRef, yn as createWevuScopedSlotComponent, yr as WatchEffect, yt as useIntersectionObserver, z as setRuntimeSetDataVisibility, zn as SetupContextNativeInstance, zr as readonly, zt as onMoved } from "./index-BvyrZ_XI.mjs";
|
|
5
4
|
|
|
6
5
|
//#region src/vue-demi.d.ts
|
|
7
6
|
/**
|
package/dist/vue-demi.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { C as effect, D as onScopeDispose, E as getCurrentScope, N as nextTick, O as startBatch, S as batch, T as endBatch, a as toValue, b as addMutationRecorder, c as isRaw, d as reactive, f as isShallowReactive, g as touchReactive, h as prelinkReactiveTree, i as ref, k as stop, l as isReactive, n as isRef, o as unref, p as shallowReactive, s as getReactiveVersion, t as customRef, u as markRaw, w as effectScope, x as removeMutationRecorder, y as toRaw } from "./ref-DvvlGmiL.mjs";
|
|
2
2
|
import { i as computed, n as defineStore, r as createStore, t as storeToRefs } from "./store-C-Eil5IU.mjs";
|
|
3
3
|
import { A as onThemeChange, B as setCurrentSetupContext, C as onResize, D as onShareTimeline, E as onShareAppMessage, F as callHookReturn, G as readonly, I as getCurrentInstance, K as shallowReadonly, L as getCurrentSetupContext, M as onUnload, O as onShow, P as callHookList, S as onReady, T as onSaveExitState, U as isProxy, W as isReadonly, _ as onMoved, a as injectGlobal, b as onPullDownRefresh, c as setGlobalProvidedValue, d as onDetached, f as onError, g as onMemoryWarning, h as onLoad, i as inject, j as onUnhandledRejection, k as onTabItemTap, l as onAddToFavorites, m as onLaunch, n as useNativeRouter, o as provide, p as onHide, r as hasInjectionContext, s as provideGlobal, t as useNativePageRouter, u as onAttached, v as onPageNotFound, w as onRouteDone, x as onReachBottom, y as onPageScroll, z as setCurrentInstance } from "./router-DJKYJlu_.mjs";
|
|
4
|
-
import { $ as
|
|
5
|
-
import { version } from "vue";
|
|
4
|
+
import { $ as onBeforeMount, A as registerApp, B as resetWevuDefaults, C as resolveLayoutBridge, D as useLayoutBridge, E as unregisterRuntimeLayoutHosts, F as resolveRuntimePageLayoutName, G as watch, H as isNoSetData, I as setPageLayout, J as watchSyncEffect, K as watchEffect, L as syncRuntimePageLayoutState, M as setRuntimeSetDataVisibility, N as teardownRuntimeInstance, O as useLayoutHosts, P as runSetupFunction, Q as onActivated, R as syncRuntimePageLayoutStateFromRuntime, S as registerRuntimeLayoutHosts, T as unregisterPageLayoutBridge, U as markNoSetData, V as setWevuDefaults, W as version, X as setDeepWatchStrategy, Y as getDeepWatchStrategy, Z as callUpdateHooks, _ as createWevuScopedSlotComponent, a as useAttrs, at as onServerPrefetch, b as registerComponent, c as defineAppSetup, ct as traverse, d as normalizeClass, dt as isShallowRef, et as onBeforeUnmount, f as normalizeStyle, ft as shallowRef, g as createWevuComponent, h as useDisposables, i as useModel, it as onMounted, j as mountRuntimeInstance, k as waitForLayoutHost, l as use, lt as toRef, m as useIntersectionObserver, n as mergeModels, nt as onDeactivated, o as useNativeInstance, ot as onUnmounted, p as usePageScrollThrottle, pt as triggerRef, q as watchPostEffect, r as useBindModel, rt as onErrorCaptured, s as useSlots, st as onUpdated, t as useTemplateRef, tt as onBeforeUpdate, u as useUpdatePerformanceListener, ut as toRefs, v as defineComponent, w as resolveLayoutHost, x as registerPageLayoutBridge, y as createApp, z as usePageLayout } from "./src-xqSS8INA.mjs";
|
|
6
5
|
//#region src/vue-demi.ts
|
|
7
6
|
/**
|
|
8
7
|
* 标记当前兼容层运行在 Vue 3 风格分支。
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wevu",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.13.
|
|
4
|
+
"version": "6.13.2",
|
|
5
5
|
"description": "Vue 3 风格的小程序运行时,包含响应式、diff+setData 与轻量状态管理",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -101,9 +101,9 @@
|
|
|
101
101
|
"miniprogram-api-typings": "^5.0.0"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"vue": "^3.5.
|
|
104
|
+
"vue": "^3.5.32",
|
|
105
105
|
"@wevu/api": "0.2.2",
|
|
106
|
-
"@wevu/compiler": "6.13.
|
|
106
|
+
"@wevu/compiler": "6.13.2"
|
|
107
107
|
},
|
|
108
108
|
"scripts": {
|
|
109
109
|
"dev": "tsdown -w",
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Zt as Ref } from "./vue-types-D8BVm-8u.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/store/types.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* @description Store 变更类型
|
|
6
|
-
*/
|
|
7
|
-
type MutationType = 'patch object' | 'patch function' | 'direct';
|
|
8
|
-
/**
|
|
9
|
-
* @description Store 订阅回调签名
|
|
10
|
-
*/
|
|
11
|
-
interface SubscriptionCallback<S = any> {
|
|
12
|
-
(mutation: {
|
|
13
|
-
type: MutationType;
|
|
14
|
-
storeId: string;
|
|
15
|
-
}, state: S): void;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @description Store 订阅选项
|
|
19
|
-
*/
|
|
20
|
-
interface StoreSubscribeOptions {
|
|
21
|
-
/**
|
|
22
|
-
* @description 是否在卸载后仍保留订阅(适用于跨页面生命周期的订阅)
|
|
23
|
-
*/
|
|
24
|
-
detached?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* @description Action 订阅回调上下文
|
|
28
|
-
*/
|
|
29
|
-
interface ActionContext<TStore = any> {
|
|
30
|
-
name: string;
|
|
31
|
-
store: TStore;
|
|
32
|
-
args: any[];
|
|
33
|
-
after: (cb: (result: any) => void) => void;
|
|
34
|
-
onError: (cb: (error: any) => void) => void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @description Action 订阅回调类型
|
|
38
|
-
*/
|
|
39
|
-
interface ActionSubscriber<TStore = any> {
|
|
40
|
-
(context: ActionContext<TStore>): void;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* @description Store 管理器(插件与共享实例)
|
|
44
|
-
*/
|
|
45
|
-
interface StoreManager {
|
|
46
|
-
install: (app: any) => void;
|
|
47
|
-
_stores: Map<string, any>;
|
|
48
|
-
use: (plugin: (context: {
|
|
49
|
-
store: any;
|
|
50
|
-
}) => void) => StoreManager;
|
|
51
|
-
_plugins: Array<(context: {
|
|
52
|
-
store: any;
|
|
53
|
-
}) => void>;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @description Getter 定义集合
|
|
57
|
-
*/
|
|
58
|
-
type GetterTree<S extends Record<string, any>> = Record<string, (state: S) => any>;
|
|
59
|
-
/**
|
|
60
|
-
* @description 从 Getter 定义中推导返回类型
|
|
61
|
-
*/
|
|
62
|
-
type StoreGetters<G extends GetterTree<any>> = { [K in keyof G]: G[K] extends ((...args: any[]) => infer R) ? R : never };
|
|
63
|
-
/**
|
|
64
|
-
* @description defineStore(options) 的配置类型
|
|
65
|
-
*/
|
|
66
|
-
interface DefineStoreOptions<S extends Record<string, any>, G extends GetterTree<S>, A extends Record<string, any>> {
|
|
67
|
-
state: () => S;
|
|
68
|
-
getters?: G & Record<string, (state: S) => any> & ThisType<S & StoreGetters<G> & A>;
|
|
69
|
-
actions?: A & ThisType<S & StoreGetters<G> & A>;
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/store/define.d.ts
|
|
73
|
-
type SetupDefinition<T> = () => T;
|
|
74
|
-
/**
|
|
75
|
-
* @description 定义一个 setup 风格的 store
|
|
76
|
-
*/
|
|
77
|
-
declare function defineStore<T extends Record<string, any>>(id: string, setup: SetupDefinition<T>): () => T & {
|
|
78
|
-
$id: string;
|
|
79
|
-
$patch: (patch: Record<string, any> | ((state: any) => void)) => void;
|
|
80
|
-
$reset: () => void;
|
|
81
|
-
$subscribe: (cb: SubscriptionCallback<any>, opts?: StoreSubscribeOptions) => () => void;
|
|
82
|
-
$onAction: (cb: ActionSubscriber<any>) => () => void;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* @description 定义一个 options 风格的 store
|
|
86
|
-
*/
|
|
87
|
-
declare function defineStore<S extends Record<string, any>, G extends Record<string, any>, A extends Record<string, any>>(id: string, options: DefineStoreOptions<S, G, A>): () => S & StoreGetters<G> & A & {
|
|
88
|
-
$id: string;
|
|
89
|
-
$state: S;
|
|
90
|
-
$patch: (patch: Partial<S> | ((state: S) => void)) => void;
|
|
91
|
-
$reset: () => void;
|
|
92
|
-
$subscribe: (cb: SubscriptionCallback<S>, opts?: StoreSubscribeOptions) => () => void;
|
|
93
|
-
$onAction: (cb: ActionSubscriber<S & StoreGetters<G> & A>) => () => void;
|
|
94
|
-
};
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/store/manager.d.ts
|
|
97
|
-
/**
|
|
98
|
-
* @description 创建 store 管理器(插件与共享实例入口)
|
|
99
|
-
*/
|
|
100
|
-
declare function createStore(): StoreManager;
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/store/storeToRefs.d.ts
|
|
103
|
-
/**
|
|
104
|
-
* @description storeToRefs 返回类型推导
|
|
105
|
-
*/
|
|
106
|
-
type StoreToRefsResult<T extends Record<string, any>> = { [K in keyof T]: T[K] extends ((...args: any[]) => any) ? T[K] : T[K] extends Ref<infer V> ? Ref<V> : Ref<T[K]> };
|
|
107
|
-
/**
|
|
108
|
-
* @description 将 store 状态转换为 Ref
|
|
109
|
-
*/
|
|
110
|
-
declare function storeToRefs<T extends Record<string, any>>(store: T): StoreToRefsResult<T>;
|
|
111
|
-
//#endregion
|
|
112
|
-
export { ActionContext as a, MutationType as c, SubscriptionCallback as d, defineStore as i, StoreManager as l, storeToRefs as n, ActionSubscriber as o, createStore as r, DefineStoreOptions as s, StoreToRefsResult as t, StoreSubscribeOptions as u };
|