wevu 2.1.4 → 2.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.
- package/dist/index.d.mts +61 -22
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1242,22 +1242,47 @@ declare function defineSlots<T extends Record<string, any> = Record<string, any>
|
|
|
1242
1242
|
declare function defineModel<T = any>(name?: string, options?: Record<string, any>): Ref<T | undefined>;
|
|
1243
1243
|
//#endregion
|
|
1244
1244
|
//#region src/store/types.d.ts
|
|
1245
|
+
/**
|
|
1246
|
+
* @description Store 变更类型
|
|
1247
|
+
*/
|
|
1245
1248
|
type MutationType = 'patch object' | 'patch function' | 'direct';
|
|
1249
|
+
/**
|
|
1250
|
+
* @description Store 订阅回调签名
|
|
1251
|
+
*/
|
|
1246
1252
|
interface SubscriptionCallback<S = any> {
|
|
1247
1253
|
(mutation: {
|
|
1248
1254
|
type: MutationType;
|
|
1249
1255
|
storeId: string;
|
|
1250
1256
|
}, state: S): void;
|
|
1251
1257
|
}
|
|
1258
|
+
/**
|
|
1259
|
+
* @description Store 订阅选项
|
|
1260
|
+
*/
|
|
1261
|
+
interface StoreSubscribeOptions {
|
|
1262
|
+
/**
|
|
1263
|
+
* @description 是否在卸载后仍保留订阅(适用于跨页面生命周期的订阅)
|
|
1264
|
+
*/
|
|
1265
|
+
detached?: boolean;
|
|
1266
|
+
}
|
|
1267
|
+
/**
|
|
1268
|
+
* @description Action 订阅回调上下文
|
|
1269
|
+
*/
|
|
1270
|
+
interface ActionContext<TStore = any> {
|
|
1271
|
+
name: string;
|
|
1272
|
+
store: TStore;
|
|
1273
|
+
args: any[];
|
|
1274
|
+
after: (cb: (result: any) => void) => void;
|
|
1275
|
+
onError: (cb: (error: any) => void) => void;
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* @description Action 订阅回调类型
|
|
1279
|
+
*/
|
|
1252
1280
|
interface ActionSubscriber<TStore = any> {
|
|
1253
|
-
(context:
|
|
1254
|
-
name: string;
|
|
1255
|
-
store: TStore;
|
|
1256
|
-
args: any[];
|
|
1257
|
-
after: (cb: (result: any) => void) => void;
|
|
1258
|
-
onError: (cb: (error: any) => void) => void;
|
|
1259
|
-
}): void;
|
|
1281
|
+
(context: ActionContext<TStore>): void;
|
|
1260
1282
|
}
|
|
1283
|
+
/**
|
|
1284
|
+
* @description Store 管理器(插件与共享实例)
|
|
1285
|
+
*/
|
|
1261
1286
|
interface StoreManager {
|
|
1262
1287
|
install: (app: any) => void;
|
|
1263
1288
|
_stores: Map<string, any>;
|
|
@@ -1268,8 +1293,17 @@ interface StoreManager {
|
|
|
1268
1293
|
store: any;
|
|
1269
1294
|
}) => void>;
|
|
1270
1295
|
}
|
|
1296
|
+
/**
|
|
1297
|
+
* @description Getter 定义集合
|
|
1298
|
+
*/
|
|
1271
1299
|
type GetterTree<S extends Record<string, any>> = Record<string, (state: S) => any>;
|
|
1300
|
+
/**
|
|
1301
|
+
* @description 从 Getter 定义中推导返回类型
|
|
1302
|
+
*/
|
|
1272
1303
|
type StoreGetters<G extends GetterTree<any>> = { [K in keyof G]: G[K] extends ((...args: any[]) => infer R) ? R : never };
|
|
1304
|
+
/**
|
|
1305
|
+
* @description defineStore(options) 的配置类型
|
|
1306
|
+
*/
|
|
1273
1307
|
interface DefineStoreOptions<S extends Record<string, any>, G extends GetterTree<S>, A extends Record<string, any>> {
|
|
1274
1308
|
state: () => S;
|
|
1275
1309
|
getters?: G & Record<string, (state: S) => any> & ThisType<S & StoreGetters<G> & A>;
|
|
@@ -1278,37 +1312,42 @@ interface DefineStoreOptions<S extends Record<string, any>, G extends GetterTree
|
|
|
1278
1312
|
//#endregion
|
|
1279
1313
|
//#region src/store/define.d.ts
|
|
1280
1314
|
type SetupDefinition<T> = () => T;
|
|
1315
|
+
/**
|
|
1316
|
+
* @description 定义一个 setup 风格的 store
|
|
1317
|
+
*/
|
|
1281
1318
|
declare function defineStore<T extends Record<string, any>>(id: string, setup: SetupDefinition<T>): () => T & {
|
|
1282
1319
|
$id: string;
|
|
1283
1320
|
$patch: (patch: Record<string, any> | ((state: any) => void)) => void;
|
|
1284
1321
|
$reset: () => void;
|
|
1285
|
-
$subscribe: (cb: (
|
|
1286
|
-
|
|
1287
|
-
storeId: string;
|
|
1288
|
-
}, state: any) => void, opts?: {
|
|
1289
|
-
detached?: boolean;
|
|
1290
|
-
}) => () => void;
|
|
1291
|
-
$onAction: (cb: (context: any) => void) => () => void;
|
|
1322
|
+
$subscribe: (cb: SubscriptionCallback<any>, opts?: StoreSubscribeOptions) => () => void;
|
|
1323
|
+
$onAction: (cb: ActionSubscriber<any>) => () => void;
|
|
1292
1324
|
};
|
|
1325
|
+
/**
|
|
1326
|
+
* @description 定义一个 options 风格的 store
|
|
1327
|
+
*/
|
|
1293
1328
|
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 & {
|
|
1294
1329
|
$id: string;
|
|
1295
1330
|
$state: S;
|
|
1296
1331
|
$patch: (patch: Partial<S> | ((state: S) => void)) => void;
|
|
1297
1332
|
$reset: () => void;
|
|
1298
|
-
$subscribe: (cb: (
|
|
1299
|
-
|
|
1300
|
-
storeId: string;
|
|
1301
|
-
}, state: S) => void, opts?: {
|
|
1302
|
-
detached?: boolean;
|
|
1303
|
-
}) => () => void;
|
|
1304
|
-
$onAction: (cb: (context: any) => () => void) => () => void;
|
|
1333
|
+
$subscribe: (cb: SubscriptionCallback<S>, opts?: StoreSubscribeOptions) => () => void;
|
|
1334
|
+
$onAction: (cb: ActionSubscriber<S & StoreGetters<G> & A>) => () => void;
|
|
1305
1335
|
};
|
|
1306
1336
|
//#endregion
|
|
1307
1337
|
//#region src/store/manager.d.ts
|
|
1338
|
+
/**
|
|
1339
|
+
* @description 创建 store 管理器(插件与共享实例入口)
|
|
1340
|
+
*/
|
|
1308
1341
|
declare function createStore(): StoreManager;
|
|
1309
1342
|
//#endregion
|
|
1310
1343
|
//#region src/store/storeToRefs.d.ts
|
|
1344
|
+
/**
|
|
1345
|
+
* @description storeToRefs 返回类型推导
|
|
1346
|
+
*/
|
|
1311
1347
|
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]> };
|
|
1348
|
+
/**
|
|
1349
|
+
* @description 将 store 状态转换为 Ref
|
|
1350
|
+
*/
|
|
1312
1351
|
declare function storeToRefs<T extends Record<string, any>>(store: T): StoreToRefsResult<T>;
|
|
1313
1352
|
//#endregion
|
|
1314
|
-
export { ActionSubscriber, type AllowedComponentProps, type AppConfig, type ComponentCustomProps, ComponentDefinition, type ComponentOptionsMixin, type ComponentPropsOptions, type ComponentPublicInstance, type ComputedDefinitions, ComputedGetter, ComputedRef, ComputedSetter, type CreateAppOptions, type DefineAppOptions, type DefineComponent, type DefineComponentOptions, DefineStoreOptions, EffectScope, EmitsOptions, type ExtractComputed, type ExtractDefaultPropTypes, type ExtractMethods, type ExtractPropTypes, type ExtractPublicPropTypes, GlobalComponents, GlobalDirectives, type InferPropType, type InferProps, type InternalRuntimeState, type InternalRuntimeStateFields, MapSources, MaybeRef, MaybeRefOrGetter, MaybeUndefined, type MethodDefinitions, type MiniProgramAdapter, type MiniProgramAppOptions, type MiniProgramBehaviorIdentifier, type MiniProgramComponentBehaviorOptions, type MiniProgramComponentOptions, type MiniProgramComponentRawOptions, type MiniProgramInstance, type MiniProgramPageLifetimes, type ModelBinding, type ModelBindingOptions, type ModelBindingPayload, MultiWatchSources, type MutationKind, type MutationOp, type MutationRecord, MutationType, type ObjectDirective, OnCleanup, type PageFeatures, type PrelinkReactiveTreeOptions, type PropConstructor, type PropOptions, type PropType, type PublicProps, Ref, type RuntimeApp, type RuntimeInstance, type SetDataDebugInfo, type SetDataSnapshotOptions, type SetupContext, type SetupFunction, ShallowRef, type ShallowUnwrapRef, StoreManager, SubscriptionCallback, TemplateRef, TemplateRefValue, TemplateRefs, ToRefs, type TriggerEventOptions, type VNode, type VNodeProps, WatchCallback, WatchEffect, WatchEffectOptions, WatchMultiSources, WatchOptions, WatchScheduler, WatchSource, WatchSourceValue, WatchSources, WatchStopHandle, WevuDefaults, WevuGlobalComponents, WevuGlobalDirectives, type WevuPlugin, WritableComputedOptions, WritableComputedRef, addMutationRecorder, batch, callHookList, callHookReturn, callUpdateHooks, computed, createApp, createStore, createWevuComponent, createWevuScopedSlotComponent, defineComponent, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSlots, defineStore, effect, effectScope, endBatch, getCurrentInstance, getCurrentScope, getCurrentSetupContext, getDeepWatchStrategy, getReactiveVersion, inject, injectGlobal, isNoSetData, isRaw, isReactive, isRef, isShallowReactive, isShallowRef, markNoSetData, markRaw, mergeModels, mountRuntimeInstance, nextTick, normalizeClass, normalizeStyle, onActivated, onAddToFavorites, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMounted, onMoved, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onScopeDispose, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, prelinkReactiveTree, provide, provideGlobal, reactive, readonly, ref, registerApp, registerComponent, removeMutationRecorder, resetWevuDefaults, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setDeepWatchStrategy, setWevuDefaults, shallowReactive, shallowRef, startBatch, stop, storeToRefs, teardownRuntimeInstance, toRaw, toRef, toRefs, toValue, touchReactive, traverse, triggerRef, unref, useAttrs, useBindModel, useModel, useSlots, useTemplateRef, watch, watchEffect, withDefaults };
|
|
1353
|
+
export { ActionContext, ActionSubscriber, type AllowedComponentProps, type AppConfig, type ComponentCustomProps, ComponentDefinition, type ComponentOptionsMixin, type ComponentPropsOptions, type ComponentPublicInstance, type ComputedDefinitions, ComputedGetter, ComputedRef, ComputedSetter, type CreateAppOptions, type DefineAppOptions, type DefineComponent, type DefineComponentOptions, DefineStoreOptions, EffectScope, EmitsOptions, type ExtractComputed, type ExtractDefaultPropTypes, type ExtractMethods, type ExtractPropTypes, type ExtractPublicPropTypes, GlobalComponents, GlobalDirectives, type InferPropType, type InferProps, type InternalRuntimeState, type InternalRuntimeStateFields, MapSources, MaybeRef, MaybeRefOrGetter, MaybeUndefined, type MethodDefinitions, type MiniProgramAdapter, type MiniProgramAppOptions, type MiniProgramBehaviorIdentifier, type MiniProgramComponentBehaviorOptions, type MiniProgramComponentOptions, type MiniProgramComponentRawOptions, type MiniProgramInstance, type MiniProgramPageLifetimes, type ModelBinding, type ModelBindingOptions, type ModelBindingPayload, MultiWatchSources, type MutationKind, type MutationOp, type MutationRecord, MutationType, type ObjectDirective, OnCleanup, type PageFeatures, type PrelinkReactiveTreeOptions, type PropConstructor, type PropOptions, type PropType, type PublicProps, Ref, type RuntimeApp, type RuntimeInstance, type SetDataDebugInfo, type SetDataSnapshotOptions, type SetupContext, type SetupFunction, ShallowRef, type ShallowUnwrapRef, StoreManager, StoreSubscribeOptions, StoreToRefsResult, SubscriptionCallback, TemplateRef, TemplateRefValue, TemplateRefs, ToRefs, type TriggerEventOptions, type VNode, type VNodeProps, WatchCallback, WatchEffect, WatchEffectOptions, WatchMultiSources, WatchOptions, WatchScheduler, WatchSource, WatchSourceValue, WatchSources, WatchStopHandle, WevuComponentConstructor, WevuDefaults, WevuGlobalComponents, WevuGlobalDirectives, type WevuPlugin, WritableComputedOptions, WritableComputedRef, addMutationRecorder, batch, callHookList, callHookReturn, callUpdateHooks, computed, createApp, createStore, createWevuComponent, createWevuScopedSlotComponent, defineComponent, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSlots, defineStore, effect, effectScope, endBatch, getCurrentInstance, getCurrentScope, getCurrentSetupContext, getDeepWatchStrategy, getReactiveVersion, inject, injectGlobal, isNoSetData, isRaw, isReactive, isRef, isShallowReactive, isShallowRef, markNoSetData, markRaw, mergeModels, mountRuntimeInstance, nextTick, normalizeClass, normalizeStyle, onActivated, onAddToFavorites, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMounted, onMoved, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onScopeDispose, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, prelinkReactiveTree, provide, provideGlobal, reactive, readonly, ref, registerApp, registerComponent, removeMutationRecorder, resetWevuDefaults, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setDeepWatchStrategy, setWevuDefaults, shallowReactive, shallowRef, startBatch, stop, storeToRefs, teardownRuntimeInstance, toRaw, toRef, toRefs, toValue, touchReactive, traverse, triggerRef, unref, useAttrs, useBindModel, useModel, useSlots, useTemplateRef, watch, watchEffect, withDefaults };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wevu",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.6",
|
|
5
5
|
"description": "Vue 3 风格的小程序运行时,包含响应式、diff+setData 与轻量状态管理",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"vue": "^3.5.27",
|
|
70
|
-
"@wevu/compiler": "0.0.
|
|
70
|
+
"@wevu/compiler": "0.0.5"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {},
|
|
73
73
|
"scripts": {
|