@tarojs/runtime 4.1.7-alpha.0 → 4.1.7-alpha.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.
@@ -760,6 +760,9 @@ interface PageLifeCycle extends Show {
760
760
  onAddToFavorites?(): void;
761
761
  onLoad?(options: Record<string, unknown>, cb?: TFunc): void;
762
762
  onOptionMenuClick?(): void;
763
+ onKeyboardHeight?(obj: {
764
+ height: number;
765
+ }): void;
763
766
  onPageScroll?(obj: {
764
767
  scrollTop: number;
765
768
  }): void;
@@ -793,6 +796,8 @@ interface PageInstance extends PageLifeCycle {
793
796
  options?: Record<string, unknown>;
794
797
  /** 页面渲染引擎类型 */
795
798
  renderer?: 'webview' | 'skyline';
799
+ /** 页面事件对象,支付宝小程序特有,详见[events](https://opendocs.alipay.com/mini/framework/page-detail#events) */
800
+ events?: Record<string, (...args: any[]) => any>;
796
801
  /** 获得一个 EventChannel 对象,用于页面间通讯 */
797
802
  getOpenerEventChannel?(): Record<string, any>;
798
803
  /** 执行关键帧动画,详见[动画](https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html) */
@@ -4145,19 +4145,34 @@ function createPageConfig(component, pageName, data, pageConfig) {
4145
4145
  }
4146
4146
  LIFECYCLES.forEach((lifecycle) => {
4147
4147
  let isDefer = false;
4148
+ let isEvent = false;
4148
4149
  lifecycle = lifecycle.replace(/^defer:/, () => {
4149
4150
  isDefer = true;
4150
4151
  return '';
4151
4152
  });
4152
- config[lifecycle] = function () {
4153
- const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
4154
- if (isDefer) {
4155
- hasLoaded.then(exec);
4156
- }
4157
- else {
4158
- return exec();
4159
- }
4160
- };
4153
+ lifecycle = lifecycle.replace(/^events:/, () => {
4154
+ isEvent = true;
4155
+ return '';
4156
+ });
4157
+ if (isEvent && process.env.TARO_ENV === 'alipay') {
4158
+ // 初始化 config.events 对象
4159
+ if (!config.events)
4160
+ config.events = {};
4161
+ config.events[lifecycle] = function () {
4162
+ return safeExecute(this.$taroPath, lifecycle, ...arguments);
4163
+ };
4164
+ }
4165
+ else {
4166
+ config[lifecycle] = function () {
4167
+ const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
4168
+ if (isDefer) {
4169
+ hasLoaded.then(exec);
4170
+ }
4171
+ else {
4172
+ return exec();
4173
+ }
4174
+ };
4175
+ }
4161
4176
  });
4162
4177
  // onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
4163
4178
  SIDE_EFFECT_LIFECYCLES.forEach(lifecycle => {