@tarojs/taro-h5 3.6.0-beta.0 → 3.6.0-beta.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.
@@ -755,6 +755,7 @@ declare const offWindowResize: typeof Taro.offWindowResize;
755
755
  // Worker
756
756
  declare const createWorker: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
757
757
  declare const createSelectorQuery: typeof Taro.createSelectorQuery;
758
- declare const createIntersectionObserver: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
759
- export { taro as default, taro, createRewardedVideoAd, createInterstitialAd, stopFaceDetect, initFaceDetect, faceDetect, isVKSupport, createVKSession, getOpenUserInfo, canIUse, arrayBufferToBase64, base64ToArrayBuffer, getUserCryptoManager, setEnableDebug, getRealtimeLogManager, getLogManager, reportPerformance, getPerformance, openSystemBluetoothSetting, openAppAuthorizeSetting, getWindowInfo, getSystemSetting, getDeviceInfo, getAppBaseInfo, getAppAuthorizeSetting, getSystemInfoSync, getSystemInfoAsync, getSystemInfo, updateWeChatApp, getUpdateManager, onUnhandledRejection, onThemeChange, onPageNotFound, onError, onAudioInterruptionEnd, onAudioInterruptionBegin, onAppShow, onAppHide, offUnhandledRejection, offThemeChange, offPageNotFound, offError, offAudioInterruptionEnd, offAudioInterruptionBegin, offAppShow, offAppHide, getLaunchOptionsSync, getEnterOptionsSync, createOffscreenCanvas, createCanvasContext, canvasToTempFilePath, canvasPutImageData, canvasGetImageData, cloud, reportMonitor, reportAnalytics, reportEvent, getExptInfoSync, stopAccelerometer, startAccelerometer, onAccelerometerChange, offAccelerometerChange, checkIsOpenAccessibility, getBatteryInfoSync, getBatteryInfo, stopBluetoothDevicesDiscovery, startBluetoothDevicesDiscovery, openBluetoothAdapter, onBluetoothDeviceFound, onBluetoothAdapterStateChange, offBluetoothDeviceFound, offBluetoothAdapterStateChange, makeBluetoothPair, isBluetoothDevicePaired, getConnectedBluetoothDevices, getBluetoothDevices, getBluetoothAdapterState, closeBluetoothAdapter, writeBLECharacteristicValue, setBLEMTU, readBLECharacteristicValue, onBLEMTUChange, onBLEConnectionStateChange, onBLECharacteristicValueChange, offBLEMTUChange, offBLEConnectionStateChange, offBLECharacteristicValueChange, notifyBLECharacteristicValueChange, getBLEMTU, getBLEDeviceServices, getBLEDeviceRSSI, getBLEDeviceCharacteristics, createBLEConnection, closeBLEConnection, onBLEPeripheralConnectionStateChanged, offBLEPeripheralConnectionStateChanged, createBLEPeripheralServer, addPhoneRepeatCalendar, addPhoneCalendar, setClipboardData, getClipboardData, stopCompass, startCompass, onCompassChange, offCompassChange, chooseContact, addPhoneContact, getRandomValues, stopGyroscope, startGyroscope, onGyroscopeChange, offGyroscopeChange, stopBeaconDiscovery, startBeaconDiscovery, onBeaconUpdate, onBeaconServiceChange, offBeaconUpdate, offBeaconServiceChange, getBeacons, onKeyboardHeightChange, offKeyboardHeightChange, hideKeyboard, getSelectedTextRange, onMemoryWarning, offMemoryWarning, stopDeviceMotionListening, startDeviceMotionListening, onDeviceMotionChange, offDeviceMotionChange, getNetworkType, onNetworkWeakChange, onNetworkStatusChange, offNetworkWeakChange, offNetworkStatusChange, getLocalIPAddress, stopHCE, startHCE, sendHCEMessage, onHCEMessage, offHCEMessage, getNFCAdapter, getHCEState, makePhoneCall, scanCode, setVisualEffectOnCapture, setScreenBrightness, setKeepScreenOn, onUserCaptureScreen, offUserCaptureScreen, getScreenBrightness, vibrateShort, vibrateLong, stopWifi, startWifi, setWifiList, onWifiConnectedWithPartialInfo, onWifiConnected, onGetWifiList, offWifiConnected, offGetWifiList, getWifiList, getConnectedWifi, connectWifi, getExtConfigSync, getExtConfig, saveFileToDisk, saveFile, removeSavedFile, openDocument, getSavedFileList, getSavedFileInfo, getFileSystemManager, getFileInfo, getApp, getCurrentInstance, stopLocationUpdate, startLocationUpdateBackground, startLocationUpdate, openLocation, onLocationChangeError, onLocationChange, offLocationChangeError, offLocationChange, getLocation, choosePoi, getFuzzyLocation, chooseLocation, stopVoice, setInnerAudioOption, playVoice, pauseVoice, getAvailableAudioSources, createWebAudioContext, createMediaAudioPlayer, createInnerAudioContext, createAudioContext, stopBackgroundAudio, seekBackgroundAudio, playBackgroundAudio, pauseBackgroundAudio, onBackgroundAudioStop, onBackgroundAudioPlay, onBackgroundAudioPause, getBackgroundAudioPlayerState, getBackgroundAudioManager, createCameraContext, saveImageToPhotosAlbum, previewMedia, getImageInfo, previewImage, compressImage, chooseMessageFile, chooseImage, createLivePusherContext, createLivePlayerContext, createMapContext, createMediaRecorder, stopRecord, startRecord, getRecorderManager, saveVideoToPhotosAlbum, openVideoEditor, getVideoInfo, createVideoContext, compressVideo, chooseVideo, chooseMedia, createVideoDecoder, createMediaContainer, updateVoIPChatMuteConfig, subscribeVoIPVideoMembers, setEnable1v1Chat, onVoIPVideoMembersChanged, onVoIPChatStateChanged, onVoIPChatSpeakersChanged, onVoIPChatMembersChanged, onVoIPChatInterrupted, offVoIPVideoMembersChanged, offVoIPChatStateChanged, offVoIPChatMembersChanged, offVoIPChatInterrupted, joinVoIPChat, exitVoIPChat, openEmbeddedMiniProgram, navigateToMiniProgram, navigateBackMiniProgram, exitMiniProgram, openBusinessView, downloadFile, stopLocalServiceDiscovery, startLocalServiceDiscovery, onLocalServiceResolveFail, onLocalServiceLost, onLocalServiceFound, onLocalServiceDiscoveryStop, offLocalServiceResolveFail, offLocalServiceLost, offLocalServiceFound, offLocalServiceDiscoveryStop, request, addInterceptor, createTCPSocket, createUDPSocket, uploadFile, sendSocketMessage, onSocketOpen, onSocketMessage, onSocketError, onSocketClose, connectSocket, closeSocket, getAccountInfoSync, chooseAddress, authorizeForMiniProgram, authorize, openCard, addCard, reserveChannelsLive, openChannelsLive, openChannelsEvent, openChannelsActivity, getChannelsLiveNoticeInfo, getChannelsLiveInfo, openCustomerServiceChat, checkIsSupportFacialRecognition, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, faceVerifyForPay, addVideoToFavorites, addFileToFavorites, getGroupEnterInfo, chooseInvoiceTitle, chooseInvoice, chooseLicensePlate, pluginLogin, login, checkSession, showRedPackage, openSetting, getSetting, startSoterAuthentication, checkIsSupportSoterAuthentication, checkIsSoterEnrolledInDevice, requestSubscribeMessage, getUserProfile, getUserInfo, shareToWeRun, getWeRunData, requestPayment, requestOrderPayment, updateShareMenu, showShareMenu, showShareImageMenu, shareVideoMessage, shareFileMessage, onCopyUrl, offCopyUrl, hideShareMenu, getShareInfo, authPrivateMessage, setStorageSync, setStorage, revokeBufferURL, removeStorageSync, removeStorage, getStorageSync, getStorageInfoSync, getStorageInfo, getStorage, createBufferURL, clearStorageSync, clearStorage, setBackgroundFetchToken, onBackgroundFetchData, getBackgroundFetchToken, getBackgroundFetchData, setPageInfo, ocrIdCard, ocrBankCard, ocrDrivingLicense, ocrVehicleLicense, textReview, textToAudio, imageAudit, advancedGeneralIdentify, objectDetectIdentify, carClassify, dishClassify, logoClassify, animalClassify, plantClassify, getSwanId, requestPolymerPayment, navigateToSmartGameProgram, navigateToSmartProgram, navigateBackSmartProgram, preloadSubPackage, createAnimation, setBackgroundTextStyle, setBackgroundColor, nextTick, loadFontFace, disableAlertBeforeUnload, enableAlertBeforeUnload, hideLoading, hideToast, showActionSheet, showLoading, showModal, showToast, getMenuButtonBoundingClientRect, showNavigationBarLoading, setNavigationBarTitle, setNavigationBarColor, hideNavigationBarLoading, hideHomeButton, startPullDownRefresh, stopPullDownRefresh, pageScrollTo, setTopBarText, initTabBarApis, showTabBarRedDot, showTabBar, setTabBarStyle, setTabBarItem, setTabBarBadge, removeTabBarBadge, hideTabBarRedDot, hideTabBar, setWindowSize, onWindowResize, offWindowResize, createWorker, createSelectorQuery, createIntersectionObserver, Behavior, canIUseWebp, Current, ENV_TYPE, eventCenter, Events, getEnv, history, initPxTransform, interceptors, Link, options, preload, pxTransform, requirePlugin };
758
+ declare const createIntersectionObserver: typeof Taro.createIntersectionObserver;
759
+ declare const createMediaQueryObserver: typeof Taro.createMediaQueryObserver;
760
+ export { taro as default, taro, createRewardedVideoAd, createInterstitialAd, stopFaceDetect, initFaceDetect, faceDetect, isVKSupport, createVKSession, getOpenUserInfo, canIUse, arrayBufferToBase64, base64ToArrayBuffer, getUserCryptoManager, setEnableDebug, getRealtimeLogManager, getLogManager, reportPerformance, getPerformance, openSystemBluetoothSetting, openAppAuthorizeSetting, getWindowInfo, getSystemSetting, getDeviceInfo, getAppBaseInfo, getAppAuthorizeSetting, getSystemInfoSync, getSystemInfoAsync, getSystemInfo, updateWeChatApp, getUpdateManager, onUnhandledRejection, onThemeChange, onPageNotFound, onError, onAudioInterruptionEnd, onAudioInterruptionBegin, onAppShow, onAppHide, offUnhandledRejection, offThemeChange, offPageNotFound, offError, offAudioInterruptionEnd, offAudioInterruptionBegin, offAppShow, offAppHide, getLaunchOptionsSync, getEnterOptionsSync, createOffscreenCanvas, createCanvasContext, canvasToTempFilePath, canvasPutImageData, canvasGetImageData, cloud, reportMonitor, reportAnalytics, reportEvent, getExptInfoSync, stopAccelerometer, startAccelerometer, onAccelerometerChange, offAccelerometerChange, checkIsOpenAccessibility, getBatteryInfoSync, getBatteryInfo, stopBluetoothDevicesDiscovery, startBluetoothDevicesDiscovery, openBluetoothAdapter, onBluetoothDeviceFound, onBluetoothAdapterStateChange, offBluetoothDeviceFound, offBluetoothAdapterStateChange, makeBluetoothPair, isBluetoothDevicePaired, getConnectedBluetoothDevices, getBluetoothDevices, getBluetoothAdapterState, closeBluetoothAdapter, writeBLECharacteristicValue, setBLEMTU, readBLECharacteristicValue, onBLEMTUChange, onBLEConnectionStateChange, onBLECharacteristicValueChange, offBLEMTUChange, offBLEConnectionStateChange, offBLECharacteristicValueChange, notifyBLECharacteristicValueChange, getBLEMTU, getBLEDeviceServices, getBLEDeviceRSSI, getBLEDeviceCharacteristics, createBLEConnection, closeBLEConnection, onBLEPeripheralConnectionStateChanged, offBLEPeripheralConnectionStateChanged, createBLEPeripheralServer, addPhoneRepeatCalendar, addPhoneCalendar, setClipboardData, getClipboardData, stopCompass, startCompass, onCompassChange, offCompassChange, chooseContact, addPhoneContact, getRandomValues, stopGyroscope, startGyroscope, onGyroscopeChange, offGyroscopeChange, stopBeaconDiscovery, startBeaconDiscovery, onBeaconUpdate, onBeaconServiceChange, offBeaconUpdate, offBeaconServiceChange, getBeacons, onKeyboardHeightChange, offKeyboardHeightChange, hideKeyboard, getSelectedTextRange, onMemoryWarning, offMemoryWarning, stopDeviceMotionListening, startDeviceMotionListening, onDeviceMotionChange, offDeviceMotionChange, getNetworkType, onNetworkWeakChange, onNetworkStatusChange, offNetworkWeakChange, offNetworkStatusChange, getLocalIPAddress, stopHCE, startHCE, sendHCEMessage, onHCEMessage, offHCEMessage, getNFCAdapter, getHCEState, makePhoneCall, scanCode, setVisualEffectOnCapture, setScreenBrightness, setKeepScreenOn, onUserCaptureScreen, offUserCaptureScreen, getScreenBrightness, vibrateShort, vibrateLong, stopWifi, startWifi, setWifiList, onWifiConnectedWithPartialInfo, onWifiConnected, onGetWifiList, offWifiConnected, offGetWifiList, getWifiList, getConnectedWifi, connectWifi, getExtConfigSync, getExtConfig, saveFileToDisk, saveFile, removeSavedFile, openDocument, getSavedFileList, getSavedFileInfo, getFileSystemManager, getFileInfo, getApp, getCurrentInstance, stopLocationUpdate, startLocationUpdateBackground, startLocationUpdate, openLocation, onLocationChangeError, onLocationChange, offLocationChangeError, offLocationChange, getLocation, choosePoi, getFuzzyLocation, chooseLocation, stopVoice, setInnerAudioOption, playVoice, pauseVoice, getAvailableAudioSources, createWebAudioContext, createMediaAudioPlayer, createInnerAudioContext, createAudioContext, stopBackgroundAudio, seekBackgroundAudio, playBackgroundAudio, pauseBackgroundAudio, onBackgroundAudioStop, onBackgroundAudioPlay, onBackgroundAudioPause, getBackgroundAudioPlayerState, getBackgroundAudioManager, createCameraContext, saveImageToPhotosAlbum, previewMedia, getImageInfo, previewImage, compressImage, chooseMessageFile, chooseImage, createLivePusherContext, createLivePlayerContext, createMapContext, createMediaRecorder, stopRecord, startRecord, getRecorderManager, saveVideoToPhotosAlbum, openVideoEditor, getVideoInfo, createVideoContext, compressVideo, chooseVideo, chooseMedia, createVideoDecoder, createMediaContainer, updateVoIPChatMuteConfig, subscribeVoIPVideoMembers, setEnable1v1Chat, onVoIPVideoMembersChanged, onVoIPChatStateChanged, onVoIPChatSpeakersChanged, onVoIPChatMembersChanged, onVoIPChatInterrupted, offVoIPVideoMembersChanged, offVoIPChatStateChanged, offVoIPChatMembersChanged, offVoIPChatInterrupted, joinVoIPChat, exitVoIPChat, openEmbeddedMiniProgram, navigateToMiniProgram, navigateBackMiniProgram, exitMiniProgram, openBusinessView, downloadFile, stopLocalServiceDiscovery, startLocalServiceDiscovery, onLocalServiceResolveFail, onLocalServiceLost, onLocalServiceFound, onLocalServiceDiscoveryStop, offLocalServiceResolveFail, offLocalServiceLost, offLocalServiceFound, offLocalServiceDiscoveryStop, request, addInterceptor, createTCPSocket, createUDPSocket, uploadFile, sendSocketMessage, onSocketOpen, onSocketMessage, onSocketError, onSocketClose, connectSocket, closeSocket, getAccountInfoSync, chooseAddress, authorizeForMiniProgram, authorize, openCard, addCard, reserveChannelsLive, openChannelsLive, openChannelsEvent, openChannelsActivity, getChannelsLiveNoticeInfo, getChannelsLiveInfo, openCustomerServiceChat, checkIsSupportFacialRecognition, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, faceVerifyForPay, addVideoToFavorites, addFileToFavorites, getGroupEnterInfo, chooseInvoiceTitle, chooseInvoice, chooseLicensePlate, pluginLogin, login, checkSession, showRedPackage, openSetting, getSetting, startSoterAuthentication, checkIsSupportSoterAuthentication, checkIsSoterEnrolledInDevice, requestSubscribeMessage, getUserProfile, getUserInfo, shareToWeRun, getWeRunData, requestPayment, requestOrderPayment, updateShareMenu, showShareMenu, showShareImageMenu, shareVideoMessage, shareFileMessage, onCopyUrl, offCopyUrl, hideShareMenu, getShareInfo, authPrivateMessage, setStorageSync, setStorage, revokeBufferURL, removeStorageSync, removeStorage, getStorageSync, getStorageInfoSync, getStorageInfo, getStorage, createBufferURL, clearStorageSync, clearStorage, setBackgroundFetchToken, onBackgroundFetchData, getBackgroundFetchToken, getBackgroundFetchData, setPageInfo, ocrIdCard, ocrBankCard, ocrDrivingLicense, ocrVehicleLicense, textReview, textToAudio, imageAudit, advancedGeneralIdentify, objectDetectIdentify, carClassify, dishClassify, logoClassify, animalClassify, plantClassify, getSwanId, requestPolymerPayment, navigateToSmartGameProgram, navigateToSmartProgram, navigateBackSmartProgram, preloadSubPackage, createAnimation, setBackgroundTextStyle, setBackgroundColor, nextTick, loadFontFace, disableAlertBeforeUnload, enableAlertBeforeUnload, hideLoading, hideToast, showActionSheet, showLoading, showModal, showToast, getMenuButtonBoundingClientRect, showNavigationBarLoading, setNavigationBarTitle, setNavigationBarColor, hideNavigationBarLoading, hideHomeButton, startPullDownRefresh, stopPullDownRefresh, pageScrollTo, setTopBarText, initTabBarApis, showTabBarRedDot, showTabBar, setTabBarStyle, setTabBarItem, setTabBarBadge, removeTabBarBadge, hideTabBarRedDot, hideTabBar, setWindowSize, onWindowResize, offWindowResize, createWorker, createSelectorQuery, createIntersectionObserver, createMediaQueryObserver, Behavior, canIUseWebp, Current, ENV_TYPE, eventCenter, Events, getEnv, history, initPxTransform, interceptors, Link, options, preload, pxTransform, requirePlugin };
760
761
  export { getCurrentPages, navigateBack, navigateTo, redirectTo, reLaunch, switchTab } from "@tarojs/router";
package/dist/index.esm.js CHANGED
@@ -35,7 +35,7 @@ class MethodHandler {
35
35
  else {
36
36
  res.errMsg = `${this.methodName}:fail ${res.errMsg}`;
37
37
  }
38
- if (!isProd) {
38
+ if (process.env.NODE_ENV !== 'production') {
39
39
  console.error(res.errMsg);
40
40
  }
41
41
  isFunction(this.__fail) && this.__fail(res);
@@ -150,7 +150,6 @@ const isValidColor = (color) => {
150
150
  };
151
151
 
152
152
  /* eslint-disable prefer-promise-reject-errors */
153
- const isProd = process.env.NODE_ENV === 'production';
154
153
  function shouldBeObject(target) {
155
154
  if (target && typeof target === 'object')
156
155
  return { flag: true };
@@ -194,6 +193,9 @@ function upperCaseFirstLetter(string) {
194
193
  string = string.replace(/^./, match => match.toUpperCase());
195
194
  return string;
196
195
  }
196
+ const toKebabCase = function (string) {
197
+ return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
198
+ };
197
199
  function inlineStyle(style) {
198
200
  let res = '';
199
201
  for (const attr in style)
@@ -229,7 +231,7 @@ function temporarilyNotSupport(name = '') {
229
231
  type: 'method',
230
232
  category: 'temporarily',
231
233
  });
232
- if (isProd) {
234
+ if (process.env.NODE_ENV === 'production') {
233
235
  console.warn(errMsg);
234
236
  return handle.success({ errMsg });
235
237
  }
@@ -249,7 +251,7 @@ function weixinCorpSupport(name) {
249
251
  type: 'method',
250
252
  category: 'weixin_corp',
251
253
  });
252
- if (isProd) {
254
+ if (process.env.NODE_ENV === 'production') {
253
255
  console.warn(errMsg);
254
256
  return handle.success({ errMsg });
255
257
  }
@@ -269,7 +271,7 @@ function permanentlyNotSupport(name = '') {
269
271
  type: 'method',
270
272
  category: 'permanently',
271
273
  });
272
- if (isProd) {
274
+ if (process.env.NODE_ENV === 'production') {
273
275
  console.warn(errMsg);
274
276
  return handle.success({ errMsg });
275
277
  }
@@ -634,6 +636,8 @@ const getDeviceInfo = () => {
634
636
  const info = {
635
637
  /** 应用二进制接口类型(仅 Android 支持) */
636
638
  abi: '',
639
+ /** 设备二进制接口类型(仅 Android 支持) */
640
+ deviceAbi: '',
637
641
  /** 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50) */
638
642
  benchmarkLevel: -1,
639
643
  /** 设备品牌 */
@@ -643,7 +647,9 @@ const getDeviceInfo = () => {
643
647
  /** 操作系统及版本 */
644
648
  system: md.os(),
645
649
  /** 客户端平台 */
646
- platform: navigator.platform
650
+ platform: navigator.platform,
651
+ /** 设备二进制接口类型(仅 Android 支持) */
652
+ CPUType: '',
647
653
  };
648
654
  return info;
649
655
  };
@@ -4988,6 +4994,159 @@ const offWindowResize = callback => {
4988
4994
  // Worker
4989
4995
  const createWorker = temporarilyNotSupport('createWorker');
4990
4996
 
4997
+ // pollify
4998
+ import('intersection-observer');
4999
+ class TaroH5IntersectionObserver {
5000
+ constructor(component, options = {}) {
5001
+ // 选项
5002
+ this._options = {
5003
+ thresholds: [0],
5004
+ initialRatio: 0,
5005
+ observeAll: false
5006
+ };
5007
+ // 监控中的选择器
5008
+ this._listeners = [];
5009
+ // 用来扩展(或收缩)参照节点布局区域的边界
5010
+ this._rootMargin = {};
5011
+ // 是否已初始化
5012
+ this._isInited = false;
5013
+ this._component = component;
5014
+ Object.assign(this._options, options);
5015
+ }
5016
+ // selector 的容器节点
5017
+ get container() {
5018
+ const container = (this._component !== null
5019
+ ? (findDOM(this._component) || document)
5020
+ : document);
5021
+ return container;
5022
+ }
5023
+ createInst() {
5024
+ // 去除原本的实例
5025
+ this.disconnect();
5026
+ const { left = 0, top = 0, bottom = 0, right = 0 } = this._rootMargin;
5027
+ return new IntersectionObserver(entries => {
5028
+ entries.forEach(entry => {
5029
+ const _callback = this._getCallbackByElement(entry.target);
5030
+ const result = {
5031
+ boundingClientRect: entry.boundingClientRect,
5032
+ intersectionRatio: entry.intersectionRatio,
5033
+ intersectionRect: entry.intersectionRect,
5034
+ relativeRect: entry.rootBounds || { left: 0, right: 0, top: 0, bottom: 0 },
5035
+ time: entry.time
5036
+ };
5037
+ // web端会默认首次触发
5038
+ if (!this._isInited && this._options.initialRatio <= Math.min.apply(Math, this._options.thresholds)) {
5039
+ // 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。
5040
+ return;
5041
+ }
5042
+ _callback && _callback.call(this, result);
5043
+ });
5044
+ this._isInited = true;
5045
+ }, {
5046
+ root: this._root,
5047
+ rootMargin: [`${top}px`, `${right}px`, `${bottom}px`, `${left}px`].join(' '),
5048
+ threshold: this._options.thresholds
5049
+ });
5050
+ }
5051
+ disconnect() {
5052
+ if (this._observerInst) {
5053
+ let listener;
5054
+ while ((listener = this._listeners.pop())) {
5055
+ this._observerInst.unobserve(listener.element);
5056
+ }
5057
+ this._observerInst.disconnect();
5058
+ }
5059
+ }
5060
+ observe(targetSelector, callback) {
5061
+ // 同wx小程序效果一致,每个实例监听一个Selector
5062
+ if (this._listeners.length)
5063
+ return;
5064
+ // 监听前没有设置关联的节点
5065
+ if (!this._observerInst) {
5066
+ console.warn('Intersection observer will be ignored because no relative nodes are found.');
5067
+ return;
5068
+ }
5069
+ const nodeList = this._options.observeAll
5070
+ ? this.container.querySelectorAll(targetSelector)
5071
+ : [this.container.querySelector(targetSelector)];
5072
+ nodeList.forEach(element => {
5073
+ if (!element)
5074
+ return;
5075
+ this._observerInst.observe(element);
5076
+ this._listeners.push({ element, callback });
5077
+ });
5078
+ }
5079
+ relativeTo(selector, margins) {
5080
+ // 已设置observe监听后,重新关联节点
5081
+ if (this._listeners.length) {
5082
+ console.error('Relative nodes cannot be added after "observe" call in IntersectionObserver');
5083
+ return this;
5084
+ }
5085
+ this._root = this.container.querySelector(selector) || null;
5086
+ if (margins) {
5087
+ this._rootMargin = margins;
5088
+ }
5089
+ this._observerInst = this.createInst();
5090
+ return this;
5091
+ }
5092
+ relativeToViewport(margins) {
5093
+ return this.relativeTo('.taro_page', margins);
5094
+ }
5095
+ _getCallbackByElement(element) {
5096
+ const listener = this._listeners.find(listener => listener.element === element);
5097
+ return listener ? listener.callback : null;
5098
+ }
5099
+ }
5100
+
5101
+ function generateMediaQueryStr(descriptor) {
5102
+ const mediaQueryArr = [];
5103
+ const descriptorMenu = ['width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'orientation'];
5104
+ for (const item of descriptorMenu) {
5105
+ if (item !== 'orientation' &&
5106
+ descriptor[item] &&
5107
+ Number(descriptor[item]) >= 0) {
5108
+ mediaQueryArr.push(`(${(toKebabCase(item))}: ${Number(descriptor[item])}px)`);
5109
+ }
5110
+ if (item === 'orientation' && descriptor[item]) {
5111
+ mediaQueryArr.push(`(${toKebabCase(item)}: ${descriptor[item]})`);
5112
+ }
5113
+ }
5114
+ return mediaQueryArr.join(' and ');
5115
+ }
5116
+ class MediaQueryObserver {
5117
+ // 监听页面媒体查询变化情况
5118
+ observe(descriptor, callback) {
5119
+ if (isFunction(callback)) {
5120
+ // 创建媒体查询对象
5121
+ this._mediaQueryObserver = window.matchMedia(generateMediaQueryStr(descriptor));
5122
+ // 监听器
5123
+ this._listener = (ev) => {
5124
+ callback({ matches: ev.matches });
5125
+ };
5126
+ callback({ matches: this._mediaQueryObserver.matches });
5127
+ // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'
5128
+ if ('addEventListener' in this._mediaQueryObserver) {
5129
+ this._mediaQueryObserver.addEventListener('change', this._listener);
5130
+ }
5131
+ else {
5132
+ this._mediaQueryObserver.addListener(this._listener);
5133
+ }
5134
+ }
5135
+ }
5136
+ // 停止监听,销毁媒体查询对象
5137
+ disconnect() {
5138
+ if (this._mediaQueryObserver && this._listener) {
5139
+ // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'
5140
+ if ('removeEventListener' in this._mediaQueryObserver) {
5141
+ this._mediaQueryObserver.removeEventListener('change', this._listener);
5142
+ }
5143
+ else {
5144
+ this._mediaQueryObserver.removeListener(this._listener);
5145
+ }
5146
+ }
5147
+ }
5148
+ }
5149
+
4991
5150
  class NodesRef {
4992
5151
  constructor(selector, querySelectorQuery, single) {
4993
5152
  this._component = querySelectorQuery._component;
@@ -5233,7 +5392,12 @@ class SelectorQuery {
5233
5392
  const createSelectorQuery = () => {
5234
5393
  return new SelectorQuery();
5235
5394
  };
5236
- const createIntersectionObserver = temporarilyNotSupport('createIntersectionObserver');
5395
+ const createIntersectionObserver = (component, options) => {
5396
+ return new TaroH5IntersectionObserver(component, options);
5397
+ };
5398
+ const createMediaQueryObserver = () => {
5399
+ return new MediaQueryObserver();
5400
+ };
5237
5401
 
5238
5402
  const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload } = Taro;
5239
5403
  const taro = {
@@ -5280,5 +5444,5 @@ taro.initPxTransform = initPxTransform;
5280
5444
  // @ts-ignore
5281
5445
  taro.canIUseWebp = canIUseWebp;
5282
5446
 
5283
- export { Behavior, Current, ENV_TYPE, Events, Link, addCard, addFileToFavorites, addInterceptor, addPhoneCalendar, addPhoneContact, addPhoneRepeatCalendar, addVideoToFavorites, advancedGeneralIdentify, animalClassify, arrayBufferToBase64, authPrivateMessage, authorize, authorizeForMiniProgram, base64ToArrayBuffer, canIUse, canIUseWebp, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, carClassify, checkIsOpenAccessibility, checkIsSoterEnrolledInDevice, checkIsSupportFacialRecognition, checkIsSupportSoterAuthentication, checkSession, chooseAddress, chooseContact, chooseImage, chooseInvoice, chooseInvoiceTitle, chooseLicensePlate, chooseLocation, chooseMedia, chooseMessageFile, choosePoi, chooseVideo, clearStorage, clearStorageSync, closeBLEConnection, closeBluetoothAdapter, closeSocket, cloud, compressImage, compressVideo, connectSocket, connectWifi, createAnimation, createAudioContext, createBLEConnection, createBLEPeripheralServer, createBufferURL, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createInterstitialAd, createLivePlayerContext, createLivePusherContext, createMapContext, createMediaAudioPlayer, createMediaContainer, createMediaRecorder, createOffscreenCanvas, createRewardedVideoAd, createSelectorQuery, createTCPSocket, createUDPSocket, createVKSession, createVideoContext, createVideoDecoder, createWebAudioContext, createWorker, taro as default, disableAlertBeforeUnload, dishClassify, downloadFile, enableAlertBeforeUnload, eventCenter, exitMiniProgram, exitVoIPChat, faceDetect, faceVerifyForPay, getAccountInfoSync, getApp, getAppAuthorizeSetting, getAppBaseInfo, getAvailableAudioSources, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, getBackgroundAudioManager, getBackgroundAudioPlayerState, getBackgroundFetchData, getBackgroundFetchToken, getBatteryInfo, getBatteryInfoSync, getBeacons, getBluetoothAdapterState, getBluetoothDevices, getChannelsLiveInfo, getChannelsLiveNoticeInfo, getClipboardData, getConnectedBluetoothDevices, getConnectedWifi, getCurrentInstance, getDeviceInfo, getEnterOptionsSync, getEnv, getExptInfoSync, getExtConfig, getExtConfigSync, getFileInfo, getFileSystemManager, getFuzzyLocation, getGroupEnterInfo, getHCEState, getImageInfo, getLaunchOptionsSync, getLocalIPAddress, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNFCAdapter, getNetworkType, getOpenUserInfo, getPerformance, getRandomValues, getRealtimeLogManager, getRecorderManager, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange, getSetting, getShareInfo, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSwanId, getSystemInfo, getSystemInfoAsync, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserCryptoManager, getUserInfo, getUserProfile, getVideoInfo, getWeRunData, getWifiList, getWindowInfo, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, imageAudit, initFaceDetect, initPxTransform, initTabBarApis, interceptors, isBluetoothDevicePaired, isVKSupport, joinVoIPChat, loadFontFace, login, logoClassify, makeBluetoothPair, makePhoneCall, navigateBackMiniProgram, navigateBackSmartProgram, navigateToMiniProgram, navigateToSmartGameProgram, navigateToSmartProgram, nextTick, notifyBLECharacteristicValueChange, objectDetectIdentify, ocrBankCard, ocrDrivingLicense, ocrIdCard, ocrVehicleLicense, offAccelerometerChange, offAppHide, offAppShow, offAudioInterruptionBegin, offAudioInterruptionEnd, offBLECharacteristicValueChange, offBLEConnectionStateChange, offBLEMTUChange, offBLEPeripheralConnectionStateChanged, offBeaconServiceChange, offBeaconUpdate, offBluetoothAdapterStateChange, offBluetoothDeviceFound, offCompassChange, offCopyUrl, offDeviceMotionChange, offError, offGetWifiList, offGyroscopeChange, offHCEMessage, offKeyboardHeightChange, offLocalServiceDiscoveryStop, offLocalServiceFound, offLocalServiceLost, offLocalServiceResolveFail, offLocationChange, offLocationChangeError, offMemoryWarning, offNetworkStatusChange, offNetworkWeakChange, offPageNotFound, offThemeChange, offUnhandledRejection, offUserCaptureScreen, offVoIPChatInterrupted, offVoIPChatMembersChanged, offVoIPChatStateChanged, offVoIPVideoMembersChanged, offWifiConnected, offWindowResize, onAccelerometerChange, onAppHide, onAppShow, onAudioInterruptionBegin, onAudioInterruptionEnd, onBLECharacteristicValueChange, onBLEConnectionStateChange, onBLEMTUChange, onBLEPeripheralConnectionStateChanged, onBackgroundAudioPause, onBackgroundAudioPlay, onBackgroundAudioStop, onBackgroundFetchData, onBeaconServiceChange, onBeaconUpdate, onBluetoothAdapterStateChange, onBluetoothDeviceFound, onCompassChange, onCopyUrl, onDeviceMotionChange, onError, onGetWifiList, onGyroscopeChange, onHCEMessage, onKeyboardHeightChange, onLocalServiceDiscoveryStop, onLocalServiceFound, onLocalServiceLost, onLocalServiceResolveFail, onLocationChange, onLocationChangeError, onMemoryWarning, onNetworkStatusChange, onNetworkWeakChange, onPageNotFound, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onThemeChange, onUnhandledRejection, onUserCaptureScreen, onVoIPChatInterrupted, onVoIPChatMembersChanged, onVoIPChatSpeakersChanged, onVoIPChatStateChanged, onVoIPVideoMembersChanged, onWifiConnected, onWifiConnectedWithPartialInfo, onWindowResize, openAppAuthorizeSetting, openBluetoothAdapter, openBusinessView, openCard, openChannelsActivity, openChannelsEvent, openChannelsLive, openCustomerServiceChat, openDocument, openEmbeddedMiniProgram, openLocation, openSetting, openSystemBluetoothSetting, openVideoEditor, options, pageScrollTo, pauseBackgroundAudio, pauseVoice, plantClassify, playBackgroundAudio, playVoice, pluginLogin, preload, preloadSubPackage, previewImage, previewMedia, pxTransform, readBLECharacteristicValue, removeSavedFile, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, reportEvent, reportMonitor, reportPerformance, request, requestOrderPayment, requestPayment, requestPolymerPayment, requestSubscribeMessage, requirePlugin, reserveChannelsLive, revokeBufferURL, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, seekBackgroundAudio, sendHCEMessage, sendSocketMessage, setBLEMTU, setBackgroundColor, setBackgroundFetchToken, setBackgroundTextStyle, setClipboardData, setEnable1v1Chat, setEnableDebug, setInnerAudioOption, setKeepScreenOn, setNavigationBarColor, setNavigationBarTitle, setPageInfo, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopBarText, setVisualEffectOnCapture, setWifiList, setWindowSize, shareFileMessage, shareToWeRun, shareVideoMessage, showActionSheet, showLoading, showModal, showNavigationBarLoading, showRedPackage, showShareImageMenu, showShareMenu, showTabBar, showTabBarRedDot, showToast, startAccelerometer, startBeaconDiscovery, startBluetoothDevicesDiscovery, startCompass, startDeviceMotionListening, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, startGyroscope, startHCE, startLocalServiceDiscovery, startLocationUpdate, startLocationUpdateBackground, startPullDownRefresh, startRecord, startSoterAuthentication, startWifi, stopAccelerometer, stopBackgroundAudio, stopBeaconDiscovery, stopBluetoothDevicesDiscovery, stopCompass, stopDeviceMotionListening, stopFaceDetect, stopGyroscope, stopHCE, stopLocalServiceDiscovery, stopLocationUpdate, stopPullDownRefresh, stopRecord, stopVoice, stopWifi, subscribeVoIPVideoMembers, textReview, textToAudio, updateShareMenu, updateVoIPChatMuteConfig, updateWeChatApp, uploadFile, vibrateLong, vibrateShort, writeBLECharacteristicValue };
5447
+ export { Behavior, Current, ENV_TYPE, Events, Link, addCard, addFileToFavorites, addInterceptor, addPhoneCalendar, addPhoneContact, addPhoneRepeatCalendar, addVideoToFavorites, advancedGeneralIdentify, animalClassify, arrayBufferToBase64, authPrivateMessage, authorize, authorizeForMiniProgram, base64ToArrayBuffer, canIUse, canIUseWebp, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, carClassify, checkIsOpenAccessibility, checkIsSoterEnrolledInDevice, checkIsSupportFacialRecognition, checkIsSupportSoterAuthentication, checkSession, chooseAddress, chooseContact, chooseImage, chooseInvoice, chooseInvoiceTitle, chooseLicensePlate, chooseLocation, chooseMedia, chooseMessageFile, choosePoi, chooseVideo, clearStorage, clearStorageSync, closeBLEConnection, closeBluetoothAdapter, closeSocket, cloud, compressImage, compressVideo, connectSocket, connectWifi, createAnimation, createAudioContext, createBLEConnection, createBLEPeripheralServer, createBufferURL, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createInterstitialAd, createLivePlayerContext, createLivePusherContext, createMapContext, createMediaAudioPlayer, createMediaContainer, createMediaQueryObserver, createMediaRecorder, createOffscreenCanvas, createRewardedVideoAd, createSelectorQuery, createTCPSocket, createUDPSocket, createVKSession, createVideoContext, createVideoDecoder, createWebAudioContext, createWorker, taro as default, disableAlertBeforeUnload, dishClassify, downloadFile, enableAlertBeforeUnload, eventCenter, exitMiniProgram, exitVoIPChat, faceDetect, faceVerifyForPay, getAccountInfoSync, getApp, getAppAuthorizeSetting, getAppBaseInfo, getAvailableAudioSources, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, getBackgroundAudioManager, getBackgroundAudioPlayerState, getBackgroundFetchData, getBackgroundFetchToken, getBatteryInfo, getBatteryInfoSync, getBeacons, getBluetoothAdapterState, getBluetoothDevices, getChannelsLiveInfo, getChannelsLiveNoticeInfo, getClipboardData, getConnectedBluetoothDevices, getConnectedWifi, getCurrentInstance, getDeviceInfo, getEnterOptionsSync, getEnv, getExptInfoSync, getExtConfig, getExtConfigSync, getFileInfo, getFileSystemManager, getFuzzyLocation, getGroupEnterInfo, getHCEState, getImageInfo, getLaunchOptionsSync, getLocalIPAddress, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNFCAdapter, getNetworkType, getOpenUserInfo, getPerformance, getRandomValues, getRealtimeLogManager, getRecorderManager, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange, getSetting, getShareInfo, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSwanId, getSystemInfo, getSystemInfoAsync, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserCryptoManager, getUserInfo, getUserProfile, getVideoInfo, getWeRunData, getWifiList, getWindowInfo, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, imageAudit, initFaceDetect, initPxTransform, initTabBarApis, interceptors, isBluetoothDevicePaired, isVKSupport, joinVoIPChat, loadFontFace, login, logoClassify, makeBluetoothPair, makePhoneCall, navigateBackMiniProgram, navigateBackSmartProgram, navigateToMiniProgram, navigateToSmartGameProgram, navigateToSmartProgram, nextTick, notifyBLECharacteristicValueChange, objectDetectIdentify, ocrBankCard, ocrDrivingLicense, ocrIdCard, ocrVehicleLicense, offAccelerometerChange, offAppHide, offAppShow, offAudioInterruptionBegin, offAudioInterruptionEnd, offBLECharacteristicValueChange, offBLEConnectionStateChange, offBLEMTUChange, offBLEPeripheralConnectionStateChanged, offBeaconServiceChange, offBeaconUpdate, offBluetoothAdapterStateChange, offBluetoothDeviceFound, offCompassChange, offCopyUrl, offDeviceMotionChange, offError, offGetWifiList, offGyroscopeChange, offHCEMessage, offKeyboardHeightChange, offLocalServiceDiscoveryStop, offLocalServiceFound, offLocalServiceLost, offLocalServiceResolveFail, offLocationChange, offLocationChangeError, offMemoryWarning, offNetworkStatusChange, offNetworkWeakChange, offPageNotFound, offThemeChange, offUnhandledRejection, offUserCaptureScreen, offVoIPChatInterrupted, offVoIPChatMembersChanged, offVoIPChatStateChanged, offVoIPVideoMembersChanged, offWifiConnected, offWindowResize, onAccelerometerChange, onAppHide, onAppShow, onAudioInterruptionBegin, onAudioInterruptionEnd, onBLECharacteristicValueChange, onBLEConnectionStateChange, onBLEMTUChange, onBLEPeripheralConnectionStateChanged, onBackgroundAudioPause, onBackgroundAudioPlay, onBackgroundAudioStop, onBackgroundFetchData, onBeaconServiceChange, onBeaconUpdate, onBluetoothAdapterStateChange, onBluetoothDeviceFound, onCompassChange, onCopyUrl, onDeviceMotionChange, onError, onGetWifiList, onGyroscopeChange, onHCEMessage, onKeyboardHeightChange, onLocalServiceDiscoveryStop, onLocalServiceFound, onLocalServiceLost, onLocalServiceResolveFail, onLocationChange, onLocationChangeError, onMemoryWarning, onNetworkStatusChange, onNetworkWeakChange, onPageNotFound, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onThemeChange, onUnhandledRejection, onUserCaptureScreen, onVoIPChatInterrupted, onVoIPChatMembersChanged, onVoIPChatSpeakersChanged, onVoIPChatStateChanged, onVoIPVideoMembersChanged, onWifiConnected, onWifiConnectedWithPartialInfo, onWindowResize, openAppAuthorizeSetting, openBluetoothAdapter, openBusinessView, openCard, openChannelsActivity, openChannelsEvent, openChannelsLive, openCustomerServiceChat, openDocument, openEmbeddedMiniProgram, openLocation, openSetting, openSystemBluetoothSetting, openVideoEditor, options, pageScrollTo, pauseBackgroundAudio, pauseVoice, plantClassify, playBackgroundAudio, playVoice, pluginLogin, preload, preloadSubPackage, previewImage, previewMedia, pxTransform, readBLECharacteristicValue, removeSavedFile, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, reportEvent, reportMonitor, reportPerformance, request, requestOrderPayment, requestPayment, requestPolymerPayment, requestSubscribeMessage, requirePlugin, reserveChannelsLive, revokeBufferURL, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, seekBackgroundAudio, sendHCEMessage, sendSocketMessage, setBLEMTU, setBackgroundColor, setBackgroundFetchToken, setBackgroundTextStyle, setClipboardData, setEnable1v1Chat, setEnableDebug, setInnerAudioOption, setKeepScreenOn, setNavigationBarColor, setNavigationBarTitle, setPageInfo, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopBarText, setVisualEffectOnCapture, setWifiList, setWindowSize, shareFileMessage, shareToWeRun, shareVideoMessage, showActionSheet, showLoading, showModal, showNavigationBarLoading, showRedPackage, showShareImageMenu, showShareMenu, showTabBar, showTabBarRedDot, showToast, startAccelerometer, startBeaconDiscovery, startBluetoothDevicesDiscovery, startCompass, startDeviceMotionListening, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, startGyroscope, startHCE, startLocalServiceDiscovery, startLocationUpdate, startLocationUpdateBackground, startPullDownRefresh, startRecord, startSoterAuthentication, startWifi, stopAccelerometer, stopBackgroundAudio, stopBeaconDiscovery, stopBluetoothDevicesDiscovery, stopCompass, stopDeviceMotionListening, stopFaceDetect, stopGyroscope, stopHCE, stopLocalServiceDiscovery, stopLocationUpdate, stopPullDownRefresh, stopRecord, stopVoice, stopWifi, subscribeVoIPVideoMembers, textReview, textToAudio, updateShareMenu, updateVoIPChatMuteConfig, updateWeChatApp, uploadFile, vibrateLong, vibrateShort, writeBLECharacteristicValue };
5284
5448
  //# sourceMappingURL=index.esm.js.map