wevu 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +175 -41
- package/dist/index.d.cts +187 -47
- package/dist/index.d.mts +187 -47
- package/dist/index.mjs +170 -42
- package/dist/{store-D0GD8ulz.cjs → store-DTqmKv0w.cjs} +1 -2
- package/dist/{store-2q4qcdBi.mjs → store-YHZDsE3y.mjs} +1 -2
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +1 -1
- package/dist/store.d.mts +1 -1
- package/dist/store.mjs +1 -1
- package/package.json +15 -1
- /package/dist/{index-0dF4y5p6.d.mts → index-B63NgJPS.d.cts} +0 -0
- /package/dist/{index-DVEFI-Uo.d.cts → index-Bq83Mwxo.d.mts} +0 -0
package/README.md
CHANGED
|
@@ -32,10 +32,6 @@ import {
|
|
|
32
32
|
} from 'wevu'
|
|
33
33
|
|
|
34
34
|
defineComponent({
|
|
35
|
-
features: {
|
|
36
|
-
listenPageScroll: true,
|
|
37
|
-
enableShareAppMessage: true,
|
|
38
|
-
},
|
|
39
35
|
data: () => ({ count: 0 }),
|
|
40
36
|
computed: {
|
|
41
37
|
doubled() {
|
|
@@ -69,7 +65,9 @@ defineComponent({
|
|
|
69
65
|
})
|
|
70
66
|
```
|
|
71
67
|
|
|
68
|
+
- 小程序部分页面事件是“按需派发”(分享/滚动等):使用 weapp-vite 时,若你调用了 `onPageScroll/onShareAppMessage/...`,编译阶段会自动补齐 `features.enableOnXxx = true`;非 weapp-vite 场景可在 `defineComponent({ features: ... })` 中手动开启。
|
|
72
69
|
- 当全局存在 `Component` 构造器时自动注册;否则可拿到 `component.__wevu_runtime` 手动挂载适配器。
|
|
70
|
+
- 分享/朋友圈/收藏是否触发由微信官方机制决定(例如右上角菜单/`open-type="share"`;朋友圈通常需配合 `wx.showShareMenu()` 开启菜单项)。
|
|
73
71
|
- 组件场景使用 `defineComponent`,SFC 构建产物可调用 `createWevuComponent`。
|
|
74
72
|
|
|
75
73
|
## 状态管理
|
|
@@ -98,6 +96,18 @@ counter.$subscribe(({ type }) => console.log('mutation', type))
|
|
|
98
96
|
counter.inc()
|
|
99
97
|
```
|
|
100
98
|
|
|
99
|
+
## 事件派发(emit)
|
|
100
|
+
|
|
101
|
+
在 `setup(props, ctx)` 中可使用 `ctx.emit(eventName, detail?, options?)`,底层直接调用小程序 `triggerEvent`。
|
|
102
|
+
|
|
103
|
+
`options` 支持:
|
|
104
|
+
|
|
105
|
+
- `bubbles`:事件是否冒泡(默认 `false`)
|
|
106
|
+
- `composed`:事件是否可以穿越组件边界(默认 `false`)
|
|
107
|
+
- `capturePhase`:事件是否拥有捕获阶段(默认 `false`)
|
|
108
|
+
|
|
109
|
+
与 Vue 3 不同:小程序事件只有一个 `detail` 载荷,不支持 `emit(event, ...args)` 的多参数透传。
|
|
110
|
+
|
|
101
111
|
## 调度与适配
|
|
102
112
|
|
|
103
113
|
- 更新被批量加入微任务队列,`nextTick` 与 Vue 3 行为一致。
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/compiler/index.ts
|
|
3
|
+
const WE_VU_PAGE_HOOK_TO_FEATURE = {
|
|
4
|
+
onPageScroll: "enableOnPageScroll",
|
|
5
|
+
onPullDownRefresh: "enableOnPullDownRefresh",
|
|
6
|
+
onReachBottom: "enableOnReachBottom",
|
|
7
|
+
onRouteDone: "enableOnRouteDone",
|
|
8
|
+
onTabItemTap: "enableOnTabItemTap",
|
|
9
|
+
onResize: "enableOnResize",
|
|
10
|
+
onShareAppMessage: "enableOnShareAppMessage",
|
|
11
|
+
onShareTimeline: "enableOnShareTimeline",
|
|
12
|
+
onAddToFavorites: "enableOnAddToFavorites",
|
|
13
|
+
onSaveExitState: "enableOnSaveExitState"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.WE_VU_PAGE_HOOK_TO_FEATURE = WE_VU_PAGE_HOOK_TO_FEATURE;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/compiler/index.d.ts
|
|
2
|
+
declare const WE_VU_PAGE_HOOK_TO_FEATURE: {
|
|
3
|
+
readonly onPageScroll: "enableOnPageScroll";
|
|
4
|
+
readonly onPullDownRefresh: "enableOnPullDownRefresh";
|
|
5
|
+
readonly onReachBottom: "enableOnReachBottom";
|
|
6
|
+
readonly onRouteDone: "enableOnRouteDone";
|
|
7
|
+
readonly onTabItemTap: "enableOnTabItemTap";
|
|
8
|
+
readonly onResize: "enableOnResize";
|
|
9
|
+
readonly onShareAppMessage: "enableOnShareAppMessage";
|
|
10
|
+
readonly onShareTimeline: "enableOnShareTimeline";
|
|
11
|
+
readonly onAddToFavorites: "enableOnAddToFavorites";
|
|
12
|
+
readonly onSaveExitState: "enableOnSaveExitState";
|
|
13
|
+
};
|
|
14
|
+
type WevuPageHookName = keyof typeof WE_VU_PAGE_HOOK_TO_FEATURE;
|
|
15
|
+
type WevuPageFeatureFlag = (typeof WE_VU_PAGE_HOOK_TO_FEATURE)[WevuPageHookName];
|
|
16
|
+
//#endregion
|
|
17
|
+
export { WE_VU_PAGE_HOOK_TO_FEATURE, WevuPageFeatureFlag, WevuPageHookName };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/compiler/index.d.ts
|
|
2
|
+
declare const WE_VU_PAGE_HOOK_TO_FEATURE: {
|
|
3
|
+
readonly onPageScroll: "enableOnPageScroll";
|
|
4
|
+
readonly onPullDownRefresh: "enableOnPullDownRefresh";
|
|
5
|
+
readonly onReachBottom: "enableOnReachBottom";
|
|
6
|
+
readonly onRouteDone: "enableOnRouteDone";
|
|
7
|
+
readonly onTabItemTap: "enableOnTabItemTap";
|
|
8
|
+
readonly onResize: "enableOnResize";
|
|
9
|
+
readonly onShareAppMessage: "enableOnShareAppMessage";
|
|
10
|
+
readonly onShareTimeline: "enableOnShareTimeline";
|
|
11
|
+
readonly onAddToFavorites: "enableOnAddToFavorites";
|
|
12
|
+
readonly onSaveExitState: "enableOnSaveExitState";
|
|
13
|
+
};
|
|
14
|
+
type WevuPageHookName = keyof typeof WE_VU_PAGE_HOOK_TO_FEATURE;
|
|
15
|
+
type WevuPageFeatureFlag = (typeof WE_VU_PAGE_HOOK_TO_FEATURE)[WevuPageHookName];
|
|
16
|
+
//#endregion
|
|
17
|
+
export { WE_VU_PAGE_HOOK_TO_FEATURE, WevuPageFeatureFlag, WevuPageHookName };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/compiler/index.ts
|
|
2
|
+
const WE_VU_PAGE_HOOK_TO_FEATURE = {
|
|
3
|
+
onPageScroll: "enableOnPageScroll",
|
|
4
|
+
onPullDownRefresh: "enableOnPullDownRefresh",
|
|
5
|
+
onReachBottom: "enableOnReachBottom",
|
|
6
|
+
onRouteDone: "enableOnRouteDone",
|
|
7
|
+
onTabItemTap: "enableOnTabItemTap",
|
|
8
|
+
onResize: "enableOnResize",
|
|
9
|
+
onShareAppMessage: "enableOnShareAppMessage",
|
|
10
|
+
onShareTimeline: "enableOnShareTimeline",
|
|
11
|
+
onAddToFavorites: "enableOnAddToFavorites",
|
|
12
|
+
onSaveExitState: "enableOnSaveExitState"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { WE_VU_PAGE_HOOK_TO_FEATURE };
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_store = require('./store-
|
|
1
|
+
const require_store = require('./store-DTqmKv0w.cjs');
|
|
2
2
|
|
|
3
3
|
//#region src/reactivity/readonly.ts
|
|
4
4
|
function readonly(target) {
|
|
@@ -437,6 +437,10 @@ function onShow(handler) {
|
|
|
437
437
|
if (!__currentInstance) throw new Error("onShow() must be called synchronously inside setup()");
|
|
438
438
|
pushHook(__currentInstance, "onShow", handler);
|
|
439
439
|
}
|
|
440
|
+
function onLoad(handler) {
|
|
441
|
+
if (!__currentInstance) throw new Error("onLoad() must be called synchronously inside setup()");
|
|
442
|
+
pushHook(__currentInstance, "onLoad", handler);
|
|
443
|
+
}
|
|
440
444
|
function onHide(handler) {
|
|
441
445
|
if (!__currentInstance) throw new Error("onHide() must be called synchronously inside setup()");
|
|
442
446
|
pushHook(__currentInstance, "onHide", handler);
|
|
@@ -449,6 +453,14 @@ function onReady(handler) {
|
|
|
449
453
|
if (!__currentInstance) throw new Error("onReady() must be called synchronously inside setup()");
|
|
450
454
|
pushHook(__currentInstance, "onReady", handler);
|
|
451
455
|
}
|
|
456
|
+
function onPullDownRefresh(handler) {
|
|
457
|
+
if (!__currentInstance) throw new Error("onPullDownRefresh() must be called synchronously inside setup()");
|
|
458
|
+
pushHook(__currentInstance, "onPullDownRefresh", handler);
|
|
459
|
+
}
|
|
460
|
+
function onReachBottom(handler) {
|
|
461
|
+
if (!__currentInstance) throw new Error("onReachBottom() must be called synchronously inside setup()");
|
|
462
|
+
pushHook(__currentInstance, "onReachBottom", handler);
|
|
463
|
+
}
|
|
452
464
|
function onPageScroll(handler) {
|
|
453
465
|
if (!__currentInstance) throw new Error("onPageScroll() must be called synchronously inside setup()");
|
|
454
466
|
pushHook(__currentInstance, "onPageScroll", handler);
|
|
@@ -461,6 +473,18 @@ function onTabItemTap(handler) {
|
|
|
461
473
|
if (!__currentInstance) throw new Error("onTabItemTap() must be called synchronously inside setup()");
|
|
462
474
|
pushHook(__currentInstance, "onTabItemTap", handler);
|
|
463
475
|
}
|
|
476
|
+
function onResize(handler) {
|
|
477
|
+
if (!__currentInstance) throw new Error("onResize() must be called synchronously inside setup()");
|
|
478
|
+
pushHook(__currentInstance, "onResize", handler);
|
|
479
|
+
}
|
|
480
|
+
function onMoved(handler) {
|
|
481
|
+
if (!__currentInstance) throw new Error("onMoved() must be called synchronously inside setup()");
|
|
482
|
+
pushHook(__currentInstance, "onMoved", handler);
|
|
483
|
+
}
|
|
484
|
+
function onError(handler) {
|
|
485
|
+
if (!__currentInstance) throw new Error("onError() must be called synchronously inside setup()");
|
|
486
|
+
pushHook(__currentInstance, "onError", handler);
|
|
487
|
+
}
|
|
464
488
|
function onSaveExitState(handler) {
|
|
465
489
|
if (!__currentInstance) throw new Error("onSaveExitState() must be called synchronously inside setup()");
|
|
466
490
|
pushHook(__currentInstance, "onSaveExitState", handler, { single: true });
|
|
@@ -633,11 +657,35 @@ function registerWatches(runtime, watchMap, instance) {
|
|
|
633
657
|
}
|
|
634
658
|
return stops;
|
|
635
659
|
}
|
|
636
|
-
function mountRuntimeInstance(target, runtimeApp, watchMap, setup) {
|
|
660
|
+
function mountRuntimeInstance(target, runtimeApp, watchMap, setup, options) {
|
|
637
661
|
if (target.__wevu) return target.__wevu;
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
|
|
662
|
+
const createDeferredAdapter = (instance) => {
|
|
663
|
+
let pending;
|
|
664
|
+
let enabled = false;
|
|
665
|
+
const adapter$1 = { setData(payload) {
|
|
666
|
+
if (!enabled) {
|
|
667
|
+
pending = {
|
|
668
|
+
...pending ?? {},
|
|
669
|
+
...payload
|
|
670
|
+
};
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
if (typeof instance.setData === "function") return instance.setData(payload);
|
|
674
|
+
} };
|
|
675
|
+
adapter$1.__wevu_enableSetData = () => {
|
|
676
|
+
enabled = true;
|
|
677
|
+
if (pending && Object.keys(pending).length && typeof instance.setData === "function") {
|
|
678
|
+
const payload = pending;
|
|
679
|
+
pending = void 0;
|
|
680
|
+
instance.setData(payload);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
return adapter$1;
|
|
684
|
+
};
|
|
685
|
+
const adapter = options?.deferSetData ? createDeferredAdapter(target) : { setData(payload) {
|
|
686
|
+
if (typeof target.setData === "function") return target.setData(payload);
|
|
687
|
+
} };
|
|
688
|
+
const runtime = runtimeApp.mount({ ...adapter });
|
|
641
689
|
const runtimeProxy = runtime?.proxy ?? {};
|
|
642
690
|
const runtimeState = runtime?.state ?? {};
|
|
643
691
|
if (!runtime?.methods) try {
|
|
@@ -675,8 +723,8 @@ function mountRuntimeInstance(target, runtimeApp, watchMap, setup) {
|
|
|
675
723
|
bindModel: runtimeBindModel.bind(runtimeWithDefaults),
|
|
676
724
|
watch: runtimeWatch.bind(runtimeWithDefaults),
|
|
677
725
|
instance: target,
|
|
678
|
-
emit: (event,
|
|
679
|
-
if (typeof target.triggerEvent === "function") target.triggerEvent(event,
|
|
726
|
+
emit: (event, detail, options$1) => {
|
|
727
|
+
if (typeof target.triggerEvent === "function") target.triggerEvent(event, detail, options$1);
|
|
680
728
|
},
|
|
681
729
|
expose: (exposed) => {
|
|
682
730
|
target.__wevuExposed = exposed;
|
|
@@ -704,6 +752,10 @@ function mountRuntimeInstance(target, runtimeApp, watchMap, setup) {
|
|
|
704
752
|
} catch {}
|
|
705
753
|
return runtime;
|
|
706
754
|
}
|
|
755
|
+
function enableDeferredSetData(target) {
|
|
756
|
+
const adapter = target.__wevu?.adapter;
|
|
757
|
+
if (adapter && typeof adapter.__wevu_enableSetData === "function") adapter.__wevu_enableSetData();
|
|
758
|
+
}
|
|
707
759
|
function teardownRuntimeInstance(target) {
|
|
708
760
|
const runtime = target.__wevu;
|
|
709
761
|
if (runtime && target.__wevuHooks) callHookList(target, "onUnload", []);
|
|
@@ -743,7 +795,7 @@ function registerApp(runtimeApp, methods, watch$1, setup, mpOptions) {
|
|
|
743
795
|
if (typeof userOnHide === "function") userOnHide.apply(this, args);
|
|
744
796
|
};
|
|
745
797
|
const userOnError = appOptions.onError;
|
|
746
|
-
appOptions.onError = function onError(...args) {
|
|
798
|
+
appOptions.onError = function onError$1(...args) {
|
|
747
799
|
callHookList(this, "onAppError", args);
|
|
748
800
|
if (typeof userOnError === "function") userOnError.apply(this, args);
|
|
749
801
|
};
|
|
@@ -760,7 +812,7 @@ function registerApp(runtimeApp, methods, watch$1, setup, mpOptions) {
|
|
|
760
812
|
}
|
|
761
813
|
App(appOptions);
|
|
762
814
|
}
|
|
763
|
-
function registerComponent(runtimeApp, methods, watch$1, setup, mpOptions
|
|
815
|
+
function registerComponent(runtimeApp, methods, watch$1, setup, mpOptions) {
|
|
764
816
|
const { methods: userMethods = {}, lifetimes: userLifetimes = {}, pageLifetimes: userPageLifetimes = {}, options: userOptions = {}, ...rest } = mpOptions;
|
|
765
817
|
const userOnLoad = rest.onLoad;
|
|
766
818
|
const userOnUnload = rest.onUnload;
|
|
@@ -768,21 +820,68 @@ function registerComponent(runtimeApp, methods, watch$1, setup, mpOptions, featu
|
|
|
768
820
|
const userOnHide = rest.onHide;
|
|
769
821
|
const userOnReady = rest.onReady;
|
|
770
822
|
const userOnSaveExitState = rest.onSaveExitState;
|
|
823
|
+
const userOnPullDownRefresh = rest.onPullDownRefresh;
|
|
824
|
+
const userOnReachBottom = rest.onReachBottom;
|
|
771
825
|
const userOnPageScroll = rest.onPageScroll;
|
|
826
|
+
const userOnRouteDone = rest.onRouteDone;
|
|
827
|
+
const userOnTabItemTap = rest.onTabItemTap;
|
|
828
|
+
const userOnResize = rest.onResize;
|
|
772
829
|
const userOnShareAppMessage = rest.onShareAppMessage;
|
|
773
830
|
const userOnShareTimeline = rest.onShareTimeline;
|
|
774
831
|
const userOnAddToFavorites = rest.onAddToFavorites;
|
|
832
|
+
const features = rest.features ?? {};
|
|
775
833
|
const restOptions = { ...rest };
|
|
834
|
+
const legacyCreated = restOptions.created;
|
|
835
|
+
delete restOptions.features;
|
|
836
|
+
delete restOptions.created;
|
|
776
837
|
delete restOptions.onLoad;
|
|
777
838
|
delete restOptions.onUnload;
|
|
778
839
|
delete restOptions.onShow;
|
|
779
840
|
delete restOptions.onHide;
|
|
780
841
|
delete restOptions.onReady;
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
842
|
+
const enableOnPullDownRefresh = typeof userOnPullDownRefresh === "function" || Boolean(features.enableOnPullDownRefresh);
|
|
843
|
+
const enableOnReachBottom = typeof userOnReachBottom === "function" || Boolean(features.enableOnReachBottom);
|
|
844
|
+
const enableOnPageScroll = typeof userOnPageScroll === "function" || Boolean(features.enableOnPageScroll);
|
|
845
|
+
const enableOnRouteDone = typeof userOnRouteDone === "function" || Boolean(features.enableOnRouteDone);
|
|
846
|
+
const enableOnTabItemTap = typeof userOnTabItemTap === "function" || Boolean(features.enableOnTabItemTap);
|
|
847
|
+
const enableOnResize = typeof userOnResize === "function" || Boolean(features.enableOnResize);
|
|
848
|
+
const enableOnShareAppMessage = typeof userOnShareAppMessage === "function" || Boolean(features.enableOnShareAppMessage);
|
|
849
|
+
const enableOnShareTimeline = typeof userOnShareTimeline === "function" || Boolean(features.enableOnShareTimeline);
|
|
850
|
+
const enableOnAddToFavorites = typeof userOnAddToFavorites === "function" || Boolean(features.enableOnAddToFavorites);
|
|
851
|
+
const enableOnSaveExitState = typeof userOnSaveExitState === "function" || Boolean(features.enableOnSaveExitState);
|
|
852
|
+
const fallbackNoop = () => {};
|
|
853
|
+
const fallbackShareContent = () => ({});
|
|
854
|
+
const fallbackTimelineContent = () => ({});
|
|
855
|
+
const effectiveOnSaveExitState = typeof userOnSaveExitState === "function" ? userOnSaveExitState : (() => ({ data: void 0 }));
|
|
856
|
+
const effectiveOnPullDownRefresh = typeof userOnPullDownRefresh === "function" ? userOnPullDownRefresh : fallbackNoop;
|
|
857
|
+
const effectiveOnReachBottom = typeof userOnReachBottom === "function" ? userOnReachBottom : fallbackNoop;
|
|
858
|
+
const effectiveOnPageScroll = typeof userOnPageScroll === "function" ? userOnPageScroll : fallbackNoop;
|
|
859
|
+
const effectiveOnRouteDone = typeof userOnRouteDone === "function" ? userOnRouteDone : fallbackNoop;
|
|
860
|
+
const effectiveOnTabItemTap = typeof userOnTabItemTap === "function" ? userOnTabItemTap : fallbackNoop;
|
|
861
|
+
const effectiveOnResize = typeof userOnResize === "function" ? userOnResize : fallbackNoop;
|
|
862
|
+
const effectiveOnShareAppMessage = typeof userOnShareAppMessage === "function" ? userOnShareAppMessage : fallbackShareContent;
|
|
863
|
+
const effectiveOnShareTimeline = typeof userOnShareTimeline === "function" ? userOnShareTimeline : fallbackTimelineContent;
|
|
864
|
+
const effectiveOnAddToFavorites = typeof userOnAddToFavorites === "function" ? userOnAddToFavorites : (() => ({}));
|
|
865
|
+
const hasHook = (target, name) => {
|
|
866
|
+
const hooks = target.__wevuHooks;
|
|
867
|
+
if (!hooks) return false;
|
|
868
|
+
const entry = hooks[name];
|
|
869
|
+
if (!entry) return false;
|
|
870
|
+
if (Array.isArray(entry)) return entry.length > 0;
|
|
871
|
+
return typeof entry === "function";
|
|
872
|
+
};
|
|
873
|
+
{
|
|
874
|
+
const userExport = restOptions.export;
|
|
875
|
+
restOptions.export = function __wevu_export() {
|
|
876
|
+
const exposed = this.__wevuExposed ?? {};
|
|
877
|
+
const base = typeof userExport === "function" ? userExport.call(this) : {};
|
|
878
|
+
if (base && typeof base === "object" && !Array.isArray(base)) return {
|
|
879
|
+
...exposed,
|
|
880
|
+
...base
|
|
881
|
+
};
|
|
882
|
+
return base ?? exposed;
|
|
883
|
+
};
|
|
884
|
+
}
|
|
786
885
|
const finalOptions = {
|
|
787
886
|
multipleSlots: userOptions.multipleSlots ?? true,
|
|
788
887
|
...userOptions
|
|
@@ -804,18 +903,11 @@ function registerComponent(runtimeApp, methods, watch$1, setup, mpOptions, featu
|
|
|
804
903
|
return result;
|
|
805
904
|
};
|
|
806
905
|
}
|
|
807
|
-
const wrapSpecial = (name) => {
|
|
808
|
-
const user = userLifetimes[name] ?? userPageLifetimes[name];
|
|
809
|
-
finalMethods[name] = function wrapped(...args) {
|
|
810
|
-
callHookList(this, name, args);
|
|
811
|
-
if (typeof user === "function") return user.apply(this, args);
|
|
812
|
-
};
|
|
813
|
-
};
|
|
814
|
-
wrapSpecial("onTabItemTap");
|
|
815
|
-
wrapSpecial("onRouteDone");
|
|
816
906
|
const pageLifecycleHooks = {
|
|
817
907
|
onLoad(...args) {
|
|
818
908
|
mountRuntimeInstance(this, runtimeApp, watch$1, setup);
|
|
909
|
+
enableDeferredSetData(this);
|
|
910
|
+
callHookList(this, "onLoad", args);
|
|
819
911
|
if (typeof userOnLoad === "function") return userOnLoad.apply(this, args);
|
|
820
912
|
},
|
|
821
913
|
onUnload(...args) {
|
|
@@ -836,39 +928,69 @@ function registerComponent(runtimeApp, methods, watch$1, setup, mpOptions, featu
|
|
|
836
928
|
callHookList(this, "onReady", args);
|
|
837
929
|
}
|
|
838
930
|
if (typeof userOnReady === "function") return userOnReady.apply(this, args);
|
|
839
|
-
},
|
|
840
|
-
onSaveExitState(...args) {
|
|
841
|
-
const ret = callHookReturn(this, "onSaveExitState", args);
|
|
842
|
-
if (ret !== void 0) return ret;
|
|
843
|
-
if (typeof userOnSaveExitState === "function") return userOnSaveExitState.apply(this, args);
|
|
844
931
|
}
|
|
845
932
|
};
|
|
846
|
-
if (
|
|
933
|
+
if (enableOnSaveExitState) pageLifecycleHooks.onSaveExitState = function onSaveExitState$1(...args) {
|
|
934
|
+
const ret = callHookReturn(this, "onSaveExitState", args);
|
|
935
|
+
if (ret !== void 0) return ret;
|
|
936
|
+
return effectiveOnSaveExitState.apply(this, args);
|
|
937
|
+
};
|
|
938
|
+
if (enableOnPullDownRefresh) pageLifecycleHooks.onPullDownRefresh = function onPullDownRefresh$1(...args) {
|
|
939
|
+
callHookList(this, "onPullDownRefresh", args);
|
|
940
|
+
if (!hasHook(this, "onPullDownRefresh")) return effectiveOnPullDownRefresh.apply(this, args);
|
|
941
|
+
};
|
|
942
|
+
if (enableOnReachBottom) pageLifecycleHooks.onReachBottom = function onReachBottom$1(...args) {
|
|
943
|
+
callHookList(this, "onReachBottom", args);
|
|
944
|
+
if (!hasHook(this, "onReachBottom")) return effectiveOnReachBottom.apply(this, args);
|
|
945
|
+
};
|
|
946
|
+
if (enableOnPageScroll) pageLifecycleHooks.onPageScroll = function onPageScroll$1(...args) {
|
|
847
947
|
callHookList(this, "onPageScroll", args);
|
|
848
|
-
if (
|
|
948
|
+
if (!hasHook(this, "onPageScroll")) return effectiveOnPageScroll.apply(this, args);
|
|
849
949
|
};
|
|
850
|
-
if (
|
|
950
|
+
if (enableOnRouteDone) pageLifecycleHooks.onRouteDone = function onRouteDone$1(...args) {
|
|
951
|
+
callHookList(this, "onRouteDone", args);
|
|
952
|
+
if (!hasHook(this, "onRouteDone")) return effectiveOnRouteDone.apply(this, args);
|
|
953
|
+
};
|
|
954
|
+
if (enableOnTabItemTap) pageLifecycleHooks.onTabItemTap = function onTabItemTap$1(...args) {
|
|
955
|
+
callHookList(this, "onTabItemTap", args);
|
|
956
|
+
if (!hasHook(this, "onTabItemTap")) return effectiveOnTabItemTap.apply(this, args);
|
|
957
|
+
};
|
|
958
|
+
if (enableOnResize) pageLifecycleHooks.onResize = function onResize$1(...args) {
|
|
959
|
+
callHookList(this, "onResize", args);
|
|
960
|
+
if (!hasHook(this, "onResize")) return effectiveOnResize.apply(this, args);
|
|
961
|
+
};
|
|
962
|
+
if (enableOnShareAppMessage) pageLifecycleHooks.onShareAppMessage = function onShareAppMessage$1(...args) {
|
|
851
963
|
const ret = callHookReturn(this, "onShareAppMessage", args);
|
|
852
964
|
if (ret !== void 0) return ret;
|
|
853
|
-
|
|
965
|
+
return effectiveOnShareAppMessage.apply(this, args);
|
|
854
966
|
};
|
|
855
|
-
if (
|
|
967
|
+
if (enableOnShareTimeline) pageLifecycleHooks.onShareTimeline = function onShareTimeline$1(...args) {
|
|
856
968
|
const ret = callHookReturn(this, "onShareTimeline", args);
|
|
857
969
|
if (ret !== void 0) return ret;
|
|
858
|
-
|
|
970
|
+
return effectiveOnShareTimeline.apply(this, args);
|
|
859
971
|
};
|
|
860
|
-
if (
|
|
972
|
+
if (enableOnAddToFavorites) pageLifecycleHooks.onAddToFavorites = function onAddToFavorites$1(...args) {
|
|
861
973
|
const ret = callHookReturn(this, "onAddToFavorites", args);
|
|
862
974
|
if (ret !== void 0) return ret;
|
|
863
|
-
|
|
975
|
+
return effectiveOnAddToFavorites.apply(this, args);
|
|
864
976
|
};
|
|
865
977
|
Component({
|
|
866
978
|
...restOptions,
|
|
867
979
|
...pageLifecycleHooks,
|
|
868
980
|
lifetimes: {
|
|
869
981
|
...userLifetimes,
|
|
982
|
+
created: function created(...args) {
|
|
983
|
+
mountRuntimeInstance(this, runtimeApp, watch$1, setup, { deferSetData: true });
|
|
984
|
+
if (typeof legacyCreated === "function") legacyCreated.apply(this, args);
|
|
985
|
+
if (typeof userLifetimes.created === "function") userLifetimes.created.apply(this, args);
|
|
986
|
+
},
|
|
987
|
+
moved: function moved(...args) {
|
|
988
|
+
callHookList(this, "onMoved", args);
|
|
989
|
+
if (typeof userLifetimes.moved === "function") userLifetimes.moved.apply(this, args);
|
|
990
|
+
},
|
|
870
991
|
attached: function attached(...args) {
|
|
871
992
|
mountRuntimeInstance(this, runtimeApp, watch$1, setup);
|
|
993
|
+
enableDeferredSetData(this);
|
|
872
994
|
if (typeof userLifetimes.attached === "function") userLifetimes.attached.apply(this, args);
|
|
873
995
|
},
|
|
874
996
|
ready: function ready(...args) {
|
|
@@ -881,6 +1003,10 @@ function registerComponent(runtimeApp, methods, watch$1, setup, mpOptions, featu
|
|
|
881
1003
|
detached: function detached(...args) {
|
|
882
1004
|
teardownRuntimeInstance(this);
|
|
883
1005
|
if (typeof userLifetimes.detached === "function") userLifetimes.detached.apply(this, args);
|
|
1006
|
+
},
|
|
1007
|
+
error: function error(...args) {
|
|
1008
|
+
callHookList(this, "onError", args);
|
|
1009
|
+
if (typeof userLifetimes.error === "function") userLifetimes.error.apply(this, args);
|
|
884
1010
|
}
|
|
885
1011
|
},
|
|
886
1012
|
pageLifetimes: {
|
|
@@ -892,6 +1018,10 @@ function registerComponent(runtimeApp, methods, watch$1, setup, mpOptions, featu
|
|
|
892
1018
|
hide: function hide(...args) {
|
|
893
1019
|
callHookList(this, "onHide", args);
|
|
894
1020
|
if (typeof userPageLifetimes.hide === "function") userPageLifetimes.hide.apply(this, args);
|
|
1021
|
+
},
|
|
1022
|
+
resize: function resize(...args) {
|
|
1023
|
+
callHookList(this, "onResize", args);
|
|
1024
|
+
if (typeof userPageLifetimes.resize === "function") userPageLifetimes.resize.apply(this, args);
|
|
895
1025
|
}
|
|
896
1026
|
},
|
|
897
1027
|
methods: finalMethods,
|
|
@@ -1126,7 +1256,6 @@ function setComputedValue(setters, key, value) {
|
|
|
1126
1256
|
* @example
|
|
1127
1257
|
* ```ts
|
|
1128
1258
|
* defineComponent({
|
|
1129
|
-
* features: { listenPageScroll: true },
|
|
1130
1259
|
* setup() {
|
|
1131
1260
|
* onPageScroll(() => {})
|
|
1132
1261
|
* }
|
|
@@ -1134,7 +1263,7 @@ function setComputedValue(setters, key, value) {
|
|
|
1134
1263
|
* ```
|
|
1135
1264
|
*/
|
|
1136
1265
|
function defineComponent(options) {
|
|
1137
|
-
const {
|
|
1266
|
+
const { data, computed: computed$1, methods, watch: watch$1, setup, props, ...mpOptions } = options;
|
|
1138
1267
|
const runtimeApp = createApp({
|
|
1139
1268
|
data,
|
|
1140
1269
|
computed: computed$1,
|
|
@@ -1151,10 +1280,9 @@ function defineComponent(options) {
|
|
|
1151
1280
|
methods,
|
|
1152
1281
|
watch: watch$1,
|
|
1153
1282
|
setup: setupWrapper,
|
|
1154
|
-
mpOptions: mpOptionsWithProps
|
|
1155
|
-
features
|
|
1283
|
+
mpOptions: mpOptionsWithProps
|
|
1156
1284
|
};
|
|
1157
|
-
registerComponent(runtimeApp, methods ?? {}, watch$1, setupWrapper, mpOptionsWithProps
|
|
1285
|
+
registerComponent(runtimeApp, methods ?? {}, watch$1, setupWrapper, mpOptionsWithProps);
|
|
1158
1286
|
return {
|
|
1159
1287
|
__wevu_runtime: runtimeApp,
|
|
1160
1288
|
__wevu_options: componentOptions
|
|
@@ -1349,11 +1477,17 @@ exports.onBeforeMount = onBeforeMount;
|
|
|
1349
1477
|
exports.onBeforeUnmount = onBeforeUnmount;
|
|
1350
1478
|
exports.onBeforeUpdate = onBeforeUpdate;
|
|
1351
1479
|
exports.onDeactivated = onDeactivated;
|
|
1480
|
+
exports.onError = onError;
|
|
1352
1481
|
exports.onErrorCaptured = onErrorCaptured;
|
|
1353
1482
|
exports.onHide = onHide;
|
|
1483
|
+
exports.onLoad = onLoad;
|
|
1354
1484
|
exports.onMounted = onMounted;
|
|
1485
|
+
exports.onMoved = onMoved;
|
|
1355
1486
|
exports.onPageScroll = onPageScroll;
|
|
1487
|
+
exports.onPullDownRefresh = onPullDownRefresh;
|
|
1488
|
+
exports.onReachBottom = onReachBottom;
|
|
1356
1489
|
exports.onReady = onReady;
|
|
1490
|
+
exports.onResize = onResize;
|
|
1357
1491
|
exports.onRouteDone = onRouteDone;
|
|
1358
1492
|
exports.onSaveExitState = onSaveExitState;
|
|
1359
1493
|
exports.onScopeDispose = require_store.onScopeDispose;
|