wevu 1.0.0-alpha.2 → 1.0.0-alpha.4
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 +14 -4
- package/dist/compiler.cjs +17 -0
- package/dist/compiler.d.cts +17 -0
- package/dist/compiler.d.mts +17 -0
- package/dist/compiler.mjs +16 -0
- package/dist/index.cjs +1017 -102
- package/dist/index.d.cts +277 -48
- package/dist/index.d.mts +277 -48
- package/dist/index.mjs +953 -51
- package/package.json +15 -1
- package/dist/index-0dF4y5p6.d.mts +0 -80
- package/dist/index-DVEFI-Uo.d.cts +0 -80
- package/dist/store-2q4qcdBi.mjs +0 -726
- package/dist/store-D0GD8ulz.cjs +0 -888
- package/dist/store.cjs +0 -5
- package/dist/store.d.cts +0 -2
- package/dist/store.d.mts +0 -2
- package/dist/store.mjs +0 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/reactivity/ref.d.ts
|
|
2
|
+
interface Ref<T$1 = any, S = T$1> {
|
|
3
|
+
get value(): T$1;
|
|
4
|
+
set value(_: S);
|
|
5
|
+
[key: symbol]: any;
|
|
6
|
+
}
|
|
7
|
+
declare function isRef(value: unknown): value is Ref<any>;
|
|
8
|
+
declare function ref<T$1>(value: T$1): Ref<T$1>;
|
|
9
|
+
declare function unref<T$1>(value: T$1 | Ref<T$1>): T$1;
|
|
10
|
+
//#endregion
|
|
3
11
|
//#region src/reactivity/computed.d.ts
|
|
4
12
|
type ComputedGetter<T$1> = () => T$1;
|
|
5
13
|
type ComputedSetter<T$1> = (value: T$1) => void;
|
|
@@ -60,7 +68,6 @@ declare function reactive<T$1 extends object>(target: T$1): T$1;
|
|
|
60
68
|
declare function isReactive(value: unknown): boolean;
|
|
61
69
|
declare function toRaw<T$1>(observed: T$1): T$1;
|
|
62
70
|
/**
|
|
63
|
-
* Establish a dependency on the whole reactive object "version".
|
|
64
71
|
* 让 effect 订阅整个对象的“版本号”,无需深度遍历即可对任何字段变化做出响应。
|
|
65
72
|
*/
|
|
66
73
|
declare function touchReactive(target: object): void;
|
|
@@ -80,7 +87,7 @@ declare function touchReactive(target: object): void;
|
|
|
80
87
|
*/
|
|
81
88
|
declare function shallowReactive<T$1 extends object>(target: T$1): T$1;
|
|
82
89
|
/**
|
|
83
|
-
*
|
|
90
|
+
* 判断一个值是否为 shallowReactive 创建的浅层响应式对象
|
|
84
91
|
*/
|
|
85
92
|
declare function isShallowReactive(value: unknown): boolean;
|
|
86
93
|
/**
|
|
@@ -220,6 +227,72 @@ type ComponentPublicInstance<D extends object, C extends ComputedDefinitions, M
|
|
|
220
227
|
interface MiniProgramAdapter {
|
|
221
228
|
setData?: (payload: Record<string, any>) => void | Promise<void>;
|
|
222
229
|
}
|
|
230
|
+
type MiniProgramComponentBehaviorOptions = WechatMiniprogram.Component.ComponentOptions;
|
|
231
|
+
type MpComponentOptions = WechatMiniprogram.Component.TrivialOption;
|
|
232
|
+
type MiniProgramBehaviorIdentifier = WechatMiniprogram.Behavior.BehaviorIdentifier | string;
|
|
233
|
+
interface MiniProgramComponentOptions {
|
|
234
|
+
/**
|
|
235
|
+
* 类似于 mixins/traits 的组件间代码复用机制(behaviors)。
|
|
236
|
+
*/
|
|
237
|
+
behaviors?: MiniProgramBehaviorIdentifier[];
|
|
238
|
+
/**
|
|
239
|
+
* 组件接受的外部样式类。
|
|
240
|
+
*/
|
|
241
|
+
externalClasses?: MpComponentOptions['externalClasses'];
|
|
242
|
+
/**
|
|
243
|
+
* 组件间关系定义。
|
|
244
|
+
*/
|
|
245
|
+
relations?: MpComponentOptions['relations'];
|
|
246
|
+
/**
|
|
247
|
+
* 组件数据字段监听器,用于监听 properties 和 data 的变化。
|
|
248
|
+
*/
|
|
249
|
+
observers?: MpComponentOptions['observers'];
|
|
250
|
+
/**
|
|
251
|
+
* 组件生命周期声明对象:
|
|
252
|
+
* `created`/`attached`/`ready`/`moved`/`detached`/`error`。
|
|
253
|
+
*
|
|
254
|
+
* 注意:wevu 会在 `attached/ready/detached/moved/error` 阶段做桥接与包装,
|
|
255
|
+
* 但 `created` 发生在 setup() 之前。
|
|
256
|
+
*/
|
|
257
|
+
lifetimes?: MpComponentOptions['lifetimes'];
|
|
258
|
+
/**
|
|
259
|
+
* 组件所在页面的生命周期声明对象:`show`/`hide`/`resize`/`routeDone`。
|
|
260
|
+
*/
|
|
261
|
+
pageLifetimes?: MpComponentOptions['pageLifetimes'];
|
|
262
|
+
/**
|
|
263
|
+
* 组件选项(multipleSlots/styleIsolation/pureDataPattern/virtualHost 等)。
|
|
264
|
+
*/
|
|
265
|
+
options?: MpComponentOptions['options'];
|
|
266
|
+
/**
|
|
267
|
+
* 定义段过滤器,用于自定义组件扩展。
|
|
268
|
+
*/
|
|
269
|
+
definitionFilter?: MpComponentOptions['definitionFilter'];
|
|
270
|
+
/**
|
|
271
|
+
* 组件自定义导出:当使用 `behavior: wx://component-export` 时,
|
|
272
|
+
* 可用于指定组件被 selectComponent 调用时的返回值。
|
|
273
|
+
*
|
|
274
|
+
* wevu 默认会将 setup() 中通过 `expose()` 写入的内容作为 export() 返回值,
|
|
275
|
+
* 因此大多数情况下无需手动编写 export();若同时提供 export(),则会与 expose() 结果浅合并。
|
|
276
|
+
*/
|
|
277
|
+
export?: MpComponentOptions['export'];
|
|
278
|
+
/**
|
|
279
|
+
* 原生 properties(与 wevu 的 props 不同)。
|
|
280
|
+
*
|
|
281
|
+
* - 推荐:使用 wevu 的 `props` 选项,让运行时规范化为小程序 `properties`。
|
|
282
|
+
* - 兼容:也可以直接传入小程序 `properties`。
|
|
283
|
+
*/
|
|
284
|
+
properties?: MpComponentOptions['properties'];
|
|
285
|
+
/**
|
|
286
|
+
* 旧式生命周期(基础库 `2.2.3` 起推荐使用 `lifetimes` 字段)。
|
|
287
|
+
* 保留以增强类型提示与兼容性。
|
|
288
|
+
*/
|
|
289
|
+
created?: MpComponentOptions['created'];
|
|
290
|
+
attached?: MpComponentOptions['attached'];
|
|
291
|
+
ready?: MpComponentOptions['ready'];
|
|
292
|
+
moved?: MpComponentOptions['moved'];
|
|
293
|
+
detached?: MpComponentOptions['detached'];
|
|
294
|
+
error?: MpComponentOptions['error'];
|
|
295
|
+
}
|
|
223
296
|
interface ModelBindingOptions<T$1 = any> {
|
|
224
297
|
event?: string;
|
|
225
298
|
valueProp?: string;
|
|
@@ -237,6 +310,7 @@ interface AppConfig {
|
|
|
237
310
|
type WevuPlugin = ((app: RuntimeApp<any, any, any>, ...options: any[]) => any) | {
|
|
238
311
|
install: (app: RuntimeApp<any, any, any>, ...options: any[]) => any;
|
|
239
312
|
};
|
|
313
|
+
type MiniProgramAppOptions<T$1 extends Record<string, any> = Record<string, any>> = WechatMiniprogram.App.Options<T$1>;
|
|
240
314
|
interface RuntimeApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> {
|
|
241
315
|
mount: (adapter?: MiniProgramAdapter) => RuntimeInstance<D, C, M>;
|
|
242
316
|
use: (plugin: WevuPlugin, ...options: any[]) => RuntimeApp<D, C, M>;
|
|
@@ -268,11 +342,11 @@ type ComponentPropsOptions = Record<string, PropOptions<any> | PropType<any> | n
|
|
|
268
342
|
interface PropOptions<T$1 = any> {
|
|
269
343
|
type?: PropType<T$1> | true | null;
|
|
270
344
|
/**
|
|
271
|
-
*
|
|
345
|
+
* 默认值(对齐 Vue 的 `default`;会被赋给小程序 property 的 `value`)
|
|
272
346
|
*/
|
|
273
347
|
default?: T$1 | (() => T$1);
|
|
274
348
|
/**
|
|
275
|
-
*
|
|
349
|
+
* 小程序 `value` 的别名
|
|
276
350
|
*/
|
|
277
351
|
value?: T$1 | (() => T$1);
|
|
278
352
|
required?: boolean;
|
|
@@ -297,73 +371,109 @@ type InferProps<P$1 extends ComponentPropsOptions = ComponentPropsOptions> = { [
|
|
|
297
371
|
type SetupFunction<P$1 extends ComponentPropsOptions, D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> = (props: InferProps<P$1>, ctx: SetupContext<D, C, M, P$1>) => Record<string, any> | void;
|
|
298
372
|
interface SetupContext<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions, P$1 extends ComponentPropsOptions = ComponentPropsOptions> {
|
|
299
373
|
/**
|
|
300
|
-
*
|
|
374
|
+
* 组件 props(来自小程序 properties)
|
|
301
375
|
*/
|
|
302
376
|
props: InferProps<P$1>;
|
|
303
377
|
/**
|
|
304
|
-
*
|
|
378
|
+
* 运行时实例
|
|
305
379
|
*/
|
|
306
380
|
runtime: RuntimeInstance<D, C, M>;
|
|
307
381
|
/**
|
|
308
|
-
*
|
|
382
|
+
* 响应式状态
|
|
309
383
|
*/
|
|
310
384
|
state: D;
|
|
311
385
|
/**
|
|
312
|
-
*
|
|
386
|
+
* 公开实例代理
|
|
313
387
|
*/
|
|
314
388
|
proxy: ComponentPublicInstance<D, C, M>;
|
|
315
389
|
/**
|
|
316
|
-
*
|
|
390
|
+
* 双向绑定辅助方法
|
|
317
391
|
*/
|
|
318
392
|
bindModel: RuntimeInstance<D, C, M>['bindModel'];
|
|
319
393
|
/**
|
|
320
|
-
*
|
|
394
|
+
* watch 辅助方法
|
|
321
395
|
*/
|
|
322
396
|
watch: RuntimeInstance<D, C, M>['watch'];
|
|
323
397
|
/**
|
|
324
|
-
*
|
|
398
|
+
* 小程序内部实例
|
|
325
399
|
*/
|
|
326
400
|
instance: InternalRuntimeState;
|
|
327
401
|
/**
|
|
328
|
-
*
|
|
402
|
+
* 通过小程序 `triggerEvent(eventName, detail?, options?)` 派发事件。
|
|
403
|
+
*
|
|
404
|
+
* 注意:不同于 Vue 3 的 `emit(event, ...args)`,小程序事件只携带一个 `detail` 载荷;
|
|
405
|
+
* `options` 用于控制事件传播行为(`bubbles`/`composed`/`capturePhase`)。
|
|
329
406
|
*/
|
|
330
|
-
emit: (event: string,
|
|
407
|
+
emit: (event: string, detail?: any, options?: TriggerEventOptions) => void;
|
|
331
408
|
/**
|
|
332
|
-
* Vue 3
|
|
409
|
+
* Vue 3 对齐:expose 公共属性
|
|
333
410
|
*/
|
|
334
|
-
expose
|
|
411
|
+
expose: (exposed: Record<string, any>) => void;
|
|
335
412
|
/**
|
|
336
|
-
* Vue 3
|
|
413
|
+
* Vue 3 对齐:attrs(小程序场景兜底为空对象)
|
|
337
414
|
*/
|
|
338
|
-
attrs
|
|
415
|
+
attrs: Record<string, any>;
|
|
416
|
+
/**
|
|
417
|
+
* Vue 3 对齐:slots(小程序场景兜底为空对象)
|
|
418
|
+
*/
|
|
419
|
+
slots: Record<string, any>;
|
|
339
420
|
}
|
|
340
|
-
|
|
421
|
+
type TriggerEventOptions = WechatMiniprogram.Component.TriggerEventOption;
|
|
422
|
+
interface InternalRuntimeStateFields {
|
|
341
423
|
__wevu?: RuntimeInstance<any, any, any>;
|
|
342
424
|
__wevuWatchStops?: WatchStopHandle[];
|
|
343
425
|
$wevu?: RuntimeInstance<any, any, any>;
|
|
344
426
|
__wevuHooks?: Record<string, any>;
|
|
345
427
|
__wevuExposed?: Record<string, any>;
|
|
346
428
|
}
|
|
347
|
-
|
|
429
|
+
type MiniProgramInstance = WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.App.TrivialInstance;
|
|
430
|
+
type InternalRuntimeState = InternalRuntimeStateFields & Partial<MiniProgramInstance>;
|
|
431
|
+
type MiniProgramPageLifetimes = Partial<WechatMiniprogram.Page.ILifetime>;
|
|
432
|
+
type MiniProgramComponentRawOptions = Omit<WechatMiniprogram.Component.TrivialOption, 'behaviors'> & {
|
|
433
|
+
behaviors?: MiniProgramBehaviorIdentifier[];
|
|
434
|
+
} & MiniProgramPageLifetimes & Record<string, any>;
|
|
435
|
+
interface DefineComponentOptions<P$1 extends ComponentPropsOptions = ComponentPropsOptions, D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> extends MiniProgramComponentOptions, MiniProgramPageLifetimes {
|
|
348
436
|
/**
|
|
349
|
-
* Page
|
|
350
|
-
*
|
|
437
|
+
* 页面特性开关(用于按需注入 Page 事件处理函数)。
|
|
438
|
+
*
|
|
439
|
+
* 说明:小程序的部分页面事件/菜单项具有“按需派发/按需展示”特性,
|
|
440
|
+
* 只有定义了对应的 `onXXX` 方法才会触发/展示(如 `onPageScroll`、`onShareTimeline`)。
|
|
441
|
+
* 因此 wevu 需要在注册阶段(Component())就决定是否注入这些 onXXX。
|
|
442
|
+
*
|
|
443
|
+
* - 若你在 options 中显式定义了原生 `onXXX`,wevu 会自动桥接对应 hook(无需 features)。
|
|
444
|
+
* - 若你只想在 `setup()` 里使用 wevu hook(不额外写原生 `onXXX`),则通过 `features` 显式开启注入。
|
|
351
445
|
*/
|
|
352
446
|
features?: PageFeatures;
|
|
353
447
|
/**
|
|
354
|
-
* Vue
|
|
448
|
+
* 类 Vue 的 props 定义(会被规范化为小程序 `properties`)
|
|
355
449
|
*/
|
|
356
450
|
props?: P$1;
|
|
357
451
|
watch?: Record<string, any>;
|
|
358
452
|
setup?: SetupFunction<P$1, D, C, M>;
|
|
453
|
+
/**
|
|
454
|
+
* 组件 data(建议使用函数返回初始值)。
|
|
455
|
+
*/
|
|
456
|
+
data?: () => D;
|
|
457
|
+
/**
|
|
458
|
+
* 组件 computed(会参与快照 diff)。
|
|
459
|
+
*/
|
|
460
|
+
computed?: C;
|
|
461
|
+
/**
|
|
462
|
+
* 组件 methods(会绑定到 public instance 上)。
|
|
463
|
+
*/
|
|
464
|
+
methods?: M;
|
|
465
|
+
/**
|
|
466
|
+
* 透传/扩展字段:允许携带其他小程序原生 Component 选项或自定义字段。
|
|
467
|
+
* 说明:为保持兼容性保留 index signature,但仍会对已知字段提供智能提示。
|
|
468
|
+
*/
|
|
359
469
|
[key: string]: any;
|
|
360
470
|
}
|
|
361
|
-
interface DefineAppOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> {
|
|
471
|
+
interface DefineAppOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> extends MiniProgramAppOptions {
|
|
362
472
|
watch?: Record<string, any>;
|
|
363
473
|
setup?: (ctx: SetupContext<D, C, M>) => Record<string, any> | void;
|
|
364
474
|
[key: string]: any;
|
|
365
475
|
}
|
|
366
|
-
interface CreateAppOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> {
|
|
476
|
+
interface CreateAppOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> extends MiniProgramAppOptions {
|
|
367
477
|
data?: () => D;
|
|
368
478
|
computed?: C;
|
|
369
479
|
methods?: M;
|
|
@@ -372,10 +482,46 @@ interface CreateAppOptions<D extends object = Record<string, any>, C extends Com
|
|
|
372
482
|
[key: string]: any;
|
|
373
483
|
}
|
|
374
484
|
interface PageFeatures {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
485
|
+
/**
|
|
486
|
+
* 启用页面滚动事件(注入 `onPageScroll`)。
|
|
487
|
+
*/
|
|
488
|
+
enableOnPageScroll?: boolean;
|
|
489
|
+
/**
|
|
490
|
+
* 启用下拉刷新事件(注入 `onPullDownRefresh`;仍需在页面配置开启 enablePullDownRefresh)。
|
|
491
|
+
*/
|
|
492
|
+
enableOnPullDownRefresh?: boolean;
|
|
493
|
+
/**
|
|
494
|
+
* 启用触底事件(注入 `onReachBottom`)。
|
|
495
|
+
*/
|
|
496
|
+
enableOnReachBottom?: boolean;
|
|
497
|
+
/**
|
|
498
|
+
* 启用路由动画完成事件(注入 `onRouteDone`)。
|
|
499
|
+
*/
|
|
500
|
+
enableOnRouteDone?: boolean;
|
|
501
|
+
/**
|
|
502
|
+
* 启用 Tab 点击事件(注入 `onTabItemTap`)。
|
|
503
|
+
*/
|
|
504
|
+
enableOnTabItemTap?: boolean;
|
|
505
|
+
/**
|
|
506
|
+
* 启用窗口尺寸变化事件(注入 `onResize`)。
|
|
507
|
+
*/
|
|
508
|
+
enableOnResize?: boolean;
|
|
509
|
+
/**
|
|
510
|
+
* 启用“转发/分享给朋友”(注入 `onShareAppMessage`,使右上角菜单显示“转发”)。
|
|
511
|
+
*/
|
|
512
|
+
enableOnShareAppMessage?: boolean;
|
|
513
|
+
/**
|
|
514
|
+
* 启用“分享到朋友圈”(注入 `onShareTimeline`,使右上角菜单显示“分享到朋友圈”)。
|
|
515
|
+
*/
|
|
516
|
+
enableOnShareTimeline?: boolean;
|
|
517
|
+
/**
|
|
518
|
+
* 启用“收藏”(注入 `onAddToFavorites`)。
|
|
519
|
+
*/
|
|
520
|
+
enableOnAddToFavorites?: boolean;
|
|
521
|
+
/**
|
|
522
|
+
* 启用“退出状态保存”(注入 `onSaveExitState`)。
|
|
523
|
+
*/
|
|
524
|
+
enableOnSaveExitState?: boolean;
|
|
379
525
|
}
|
|
380
526
|
//#endregion
|
|
381
527
|
//#region src/runtime/app.d.ts
|
|
@@ -401,8 +547,7 @@ interface ComponentDefinition<D extends object, C extends ComputedDefinitions, M
|
|
|
401
547
|
methods: M;
|
|
402
548
|
watch: Record<string, any> | undefined;
|
|
403
549
|
setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'];
|
|
404
|
-
mpOptions:
|
|
405
|
-
features?: DefineComponentOptions<ComponentPropsOptions, D, C, M>['features'];
|
|
550
|
+
mpOptions: MiniProgramComponentRawOptions;
|
|
406
551
|
};
|
|
407
552
|
}
|
|
408
553
|
/**
|
|
@@ -426,7 +571,6 @@ interface ComponentDefinition<D extends object, C extends ComputedDefinitions, M
|
|
|
426
571
|
* @example
|
|
427
572
|
* ```ts
|
|
428
573
|
* defineComponent({
|
|
429
|
-
* features: { listenPageScroll: true },
|
|
430
574
|
* setup() {
|
|
431
575
|
* onPageScroll(() => {})
|
|
432
576
|
* }
|
|
@@ -440,28 +584,36 @@ declare function defineComponent<P$1 extends ComponentPropsOptions = ComponentPr
|
|
|
440
584
|
* @param options 组件选项,可能包含小程序特有的 properties
|
|
441
585
|
*/
|
|
442
586
|
declare function createWevuComponent<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: DefineComponentOptions<ComponentPropsOptions, D, C, M> & {
|
|
443
|
-
properties?:
|
|
587
|
+
properties?: WechatMiniprogram.Component.PropertyOption;
|
|
444
588
|
}): void;
|
|
445
589
|
//#endregion
|
|
446
590
|
//#region src/runtime/hooks.d.ts
|
|
447
|
-
declare function getCurrentInstance():
|
|
591
|
+
declare function getCurrentInstance<T$1 extends InternalRuntimeState = InternalRuntimeState>(): T$1 | undefined;
|
|
448
592
|
declare function setCurrentInstance(inst: InternalRuntimeState | undefined): void;
|
|
593
|
+
declare function getCurrentSetupContext<T$1 = any>(): T$1 | undefined;
|
|
594
|
+
declare function setCurrentSetupContext(ctx: any | undefined): void;
|
|
449
595
|
declare function callHookList(target: InternalRuntimeState, name: string, args?: any[]): void;
|
|
450
596
|
declare function callHookReturn(target: InternalRuntimeState, name: string, args?: any[]): any;
|
|
451
|
-
declare function onAppShow(handler: () => void): void;
|
|
597
|
+
declare function onAppShow(handler: (options: WechatMiniprogram.App.LaunchShowOption) => void): void;
|
|
452
598
|
declare function onAppHide(handler: () => void): void;
|
|
453
|
-
declare function onAppError(handler: (
|
|
599
|
+
declare function onAppError(handler: (error: string) => void): void;
|
|
454
600
|
declare function onShow(handler: () => void): void;
|
|
601
|
+
declare function onLoad(handler: WechatMiniprogram.Page.ILifetime['onLoad']): void;
|
|
455
602
|
declare function onHide(handler: () => void): void;
|
|
456
603
|
declare function onUnload(handler: () => void): void;
|
|
457
604
|
declare function onReady(handler: () => void): void;
|
|
458
|
-
declare function
|
|
459
|
-
declare function
|
|
460
|
-
declare function
|
|
461
|
-
declare function
|
|
462
|
-
declare function
|
|
463
|
-
declare function
|
|
464
|
-
declare function
|
|
605
|
+
declare function onPullDownRefresh(handler: WechatMiniprogram.Page.ILifetime['onPullDownRefresh']): void;
|
|
606
|
+
declare function onReachBottom(handler: WechatMiniprogram.Page.ILifetime['onReachBottom']): void;
|
|
607
|
+
declare function onPageScroll(handler: (opt: WechatMiniprogram.Page.IPageScrollOption) => void): void;
|
|
608
|
+
declare function onRouteDone(handler: WechatMiniprogram.Page.ILifetime['onRouteDone'] | ((opt?: unknown) => void)): void;
|
|
609
|
+
declare function onTabItemTap(handler: (opt: WechatMiniprogram.Page.ITabItemTapOption) => void): void;
|
|
610
|
+
declare function onResize(handler: (opt: WechatMiniprogram.Page.IResizeOption) => void): void;
|
|
611
|
+
declare function onMoved(handler: () => void): void;
|
|
612
|
+
declare function onError(handler: (err: any) => void): void;
|
|
613
|
+
declare function onSaveExitState(handler: () => WechatMiniprogram.Page.ISaveExitState): void;
|
|
614
|
+
declare function onShareAppMessage(handler: WechatMiniprogram.Page.ILifetime['onShareAppMessage']): void;
|
|
615
|
+
declare function onShareTimeline(handler: WechatMiniprogram.Page.ILifetime['onShareTimeline']): void;
|
|
616
|
+
declare function onAddToFavorites(handler: WechatMiniprogram.Page.ILifetime['onAddToFavorites']): void;
|
|
465
617
|
/**
|
|
466
618
|
* Vue 3 对齐:组件/页面已挂载,映射小程序 onReady
|
|
467
619
|
*/
|
|
@@ -560,9 +712,86 @@ type WatchDescriptor = WatchHandler | string | {
|
|
|
560
712
|
};
|
|
561
713
|
type WatchMap = Record<string, WatchDescriptor>;
|
|
562
714
|
declare function runSetupFunction(setup: ((...args: any[]) => any) | undefined, props: Record<string, any>, context: any): any;
|
|
563
|
-
declare function mountRuntimeInstance<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(target: InternalRuntimeState, runtimeApp: RuntimeApp<D, C, M>, watchMap: WatchMap | undefined, setup?: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup']
|
|
715
|
+
declare function mountRuntimeInstance<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(target: InternalRuntimeState, runtimeApp: RuntimeApp<D, C, M>, watchMap: WatchMap | undefined, setup?: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'], options?: {
|
|
716
|
+
deferSetData?: boolean;
|
|
717
|
+
}): RuntimeInstance<D, C, M>;
|
|
564
718
|
declare function teardownRuntimeInstance(target: InternalRuntimeState): void;
|
|
565
|
-
declare function registerApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(runtimeApp: RuntimeApp<D, C, M>, methods: MethodDefinitions, watch: WatchMap | undefined, setup: DefineAppOptions<D, C, M>['setup'], mpOptions:
|
|
566
|
-
declare function registerComponent<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(runtimeApp: RuntimeApp<D, C, M>, methods: MethodDefinitions, watch: WatchMap | undefined, setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'], mpOptions:
|
|
719
|
+
declare function registerApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(runtimeApp: RuntimeApp<D, C, M>, methods: MethodDefinitions, watch: WatchMap | undefined, setup: DefineAppOptions<D, C, M>['setup'], mpOptions: MiniProgramAppOptions): void;
|
|
720
|
+
declare function registerComponent<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(runtimeApp: RuntimeApp<D, C, M>, methods: MethodDefinitions, watch: WatchMap | undefined, setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'], mpOptions: MiniProgramComponentRawOptions): void;
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region src/runtime/vueCompat.d.ts
|
|
723
|
+
declare function useAttrs(): Record<string, any>;
|
|
724
|
+
declare function useSlots(): Record<string, any>;
|
|
725
|
+
declare function useModel<T$1 = any>(props: Record<string, any>, name: string): Ref<T$1>;
|
|
726
|
+
declare function mergeModels<T$1>(a: T$1, b: T$1): T$1;
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/store/types.d.ts
|
|
729
|
+
type MutationType = 'patch object' | 'patch function';
|
|
730
|
+
interface SubscriptionCallback<S = any> {
|
|
731
|
+
(mutation: {
|
|
732
|
+
type: MutationType;
|
|
733
|
+
storeId: string;
|
|
734
|
+
}, state: S): void;
|
|
735
|
+
}
|
|
736
|
+
interface ActionSubscriber<TStore = any> {
|
|
737
|
+
(context: {
|
|
738
|
+
name: string;
|
|
739
|
+
store: TStore;
|
|
740
|
+
args: any[];
|
|
741
|
+
after: (cb: (result: any) => void) => void;
|
|
742
|
+
onError: (cb: (error: any) => void) => void;
|
|
743
|
+
}): void;
|
|
744
|
+
}
|
|
745
|
+
interface StoreManager {
|
|
746
|
+
install: (app: any) => void;
|
|
747
|
+
_stores: Map<string, any>;
|
|
748
|
+
use: (plugin: (context: {
|
|
749
|
+
store: any;
|
|
750
|
+
}) => void) => StoreManager;
|
|
751
|
+
_plugins: Array<(context: {
|
|
752
|
+
store: any;
|
|
753
|
+
}) => void>;
|
|
754
|
+
}
|
|
755
|
+
type GetterTree<S extends Record<string, any>> = Record<string, (state: S) => any>;
|
|
756
|
+
type StoreGetters<G extends GetterTree<any>> = { [K in keyof G]: G[K] extends ((...args: any[]) => infer R) ? R : never };
|
|
757
|
+
interface DefineStoreOptions<S extends Record<string, any>, G extends GetterTree<S>, A extends Record<string, any>> {
|
|
758
|
+
state: () => S;
|
|
759
|
+
getters?: G & Record<string, (state: S) => any> & ThisType<S & StoreGetters<G> & A>;
|
|
760
|
+
actions?: A & ThisType<S & StoreGetters<G> & A>;
|
|
761
|
+
}
|
|
762
|
+
//#endregion
|
|
763
|
+
//#region src/store/define.d.ts
|
|
764
|
+
type SetupDefinition<T$1> = () => T$1;
|
|
765
|
+
declare function defineStore<T$1 extends Record<string, any>>(id: string, setup: SetupDefinition<T$1>): () => T$1 & {
|
|
766
|
+
$id: string;
|
|
767
|
+
$patch: (patch: Record<string, any> | ((state: any) => void)) => void;
|
|
768
|
+
$subscribe: (cb: (mutation: {
|
|
769
|
+
type: MutationType;
|
|
770
|
+
storeId: string;
|
|
771
|
+
}, state: any) => void, opts?: {
|
|
772
|
+
detached?: boolean;
|
|
773
|
+
}) => () => void;
|
|
774
|
+
$onAction: (cb: (context: any) => void) => () => void;
|
|
775
|
+
};
|
|
776
|
+
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 & {
|
|
777
|
+
$id: string;
|
|
778
|
+
$state: S;
|
|
779
|
+
$patch: (patch: Partial<S> | ((state: S) => void)) => void;
|
|
780
|
+
$reset: () => void;
|
|
781
|
+
$subscribe: (cb: (mutation: {
|
|
782
|
+
type: MutationType;
|
|
783
|
+
storeId: string;
|
|
784
|
+
}, state: S) => void, opts?: {
|
|
785
|
+
detached?: boolean;
|
|
786
|
+
}) => () => void;
|
|
787
|
+
$onAction: (cb: (context: any) => () => void) => () => void;
|
|
788
|
+
};
|
|
789
|
+
//#endregion
|
|
790
|
+
//#region src/store/manager.d.ts
|
|
791
|
+
declare function createStore(): StoreManager;
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region src/store/storeToRefs.d.ts
|
|
794
|
+
type StoreToRefsResult<T$1 extends Record<string, any>> = { [K in keyof T$1]: T$1[K] extends ((...args: any[]) => any) ? T$1[K] : T$1[K] extends Ref<infer V> ? Ref<V> : Ref<T$1[K]> };
|
|
795
|
+
declare function storeToRefs<T$1 extends Record<string, any>>(store: T$1): StoreToRefsResult<T$1>;
|
|
567
796
|
//#endregion
|
|
568
|
-
export { ActionSubscriber, AppConfig, ComponentDefinition, ComponentPropsOptions, ComponentPublicInstance, ComputedDefinitions, ComputedGetter, ComputedRef, ComputedSetter, CreateAppOptions, DefineAppOptions, DefineComponentOptions, DefineStoreOptions, EffectScope, ExtractComputed, ExtractMethods, InferPropType, InferProps, InternalRuntimeState, MethodDefinitions, MiniProgramAdapter, ModelBinding, ModelBindingOptions, MutationType, PageFeatures, PropConstructor, PropOptions, PropType, Ref, RuntimeApp, RuntimeInstance, SetupContext, SetupFunction, StoreManager, SubscriptionCallback, ToRefs, WatchOptions, WatchStopHandle, WevuPlugin, WritableComputedOptions, WritableComputedRef, batch, callHookList, callHookReturn, callUpdateHooks, computed, createApp, createStore, createWevuComponent, defineComponent, defineStore, effect, effectScope, endBatch, getCurrentInstance, getCurrentScope, getDeepWatchStrategy, inject, injectGlobal, isRaw, isReactive, isRef, isShallowReactive, isShallowRef, markRaw, mountRuntimeInstance, nextTick, onActivated, onAddToFavorites, onAppError, onAppHide, onAppShow, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onHide, onMounted, onPageScroll, onReady, onRouteDone, onSaveExitState, onScopeDispose, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onUnload, onUnmounted, onUpdated, provide, provideGlobal, reactive, readonly, ref, registerApp, registerComponent, runSetupFunction, setCurrentInstance, setDeepWatchStrategy, shallowReactive, shallowRef, startBatch, stop, storeToRefs, teardownRuntimeInstance, toRaw, toRef, toRefs, touchReactive, traverse, triggerRef, unref, watch, watchEffect };
|
|
797
|
+
export { ActionSubscriber, AppConfig, ComponentDefinition, ComponentPropsOptions, ComponentPublicInstance, ComputedDefinitions, ComputedGetter, ComputedRef, ComputedSetter, CreateAppOptions, DefineAppOptions, DefineComponentOptions, DefineStoreOptions, EffectScope, ExtractComputed, ExtractMethods, InferPropType, InferProps, InternalRuntimeState, InternalRuntimeStateFields, MethodDefinitions, MiniProgramAdapter, MiniProgramAppOptions, MiniProgramBehaviorIdentifier, MiniProgramComponentBehaviorOptions, MiniProgramComponentOptions, MiniProgramComponentRawOptions, MiniProgramInstance, MiniProgramPageLifetimes, ModelBinding, ModelBindingOptions, MutationType, PageFeatures, PropConstructor, PropOptions, PropType, Ref, RuntimeApp, RuntimeInstance, SetupContext, SetupFunction, StoreManager, SubscriptionCallback, ToRefs, TriggerEventOptions, WatchOptions, WatchStopHandle, WevuPlugin, WritableComputedOptions, WritableComputedRef, batch, callHookList, callHookReturn, callUpdateHooks, computed, createApp, createStore, createWevuComponent, defineComponent, defineStore, effect, effectScope, endBatch, getCurrentInstance, getCurrentScope, getCurrentSetupContext, getDeepWatchStrategy, inject, injectGlobal, isRaw, isReactive, isRef, isShallowReactive, isShallowRef, markRaw, mergeModels, mountRuntimeInstance, nextTick, onActivated, onAddToFavorites, onAppError, onAppHide, onAppShow, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onError, onErrorCaptured, onHide, onLoad, onMounted, onMoved, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onScopeDispose, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onUnload, onUnmounted, onUpdated, provide, provideGlobal, reactive, readonly, ref, registerApp, registerComponent, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setDeepWatchStrategy, shallowReactive, shallowRef, startBatch, stop, storeToRefs, teardownRuntimeInstance, toRaw, toRef, toRefs, touchReactive, traverse, triggerRef, unref, useAttrs, useModel, useSlots, watch, watchEffect };
|