@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.
@@ -62,6 +62,8 @@ export const getDeviceInfo = () => {
62
62
  const info = {
63
63
  /** 应用二进制接口类型(仅 Android 支持) */
64
64
  abi: '',
65
+ /** 设备二进制接口类型(仅 Android 支持) */
66
+ deviceAbi: '',
65
67
  /** 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50) */
66
68
  benchmarkLevel: -1,
67
69
  /** 设备品牌 */
@@ -71,7 +73,9 @@ export const getDeviceInfo = () => {
71
73
  /** 操作系统及版本 */
72
74
  system: md.os(),
73
75
  /** 客户端平台 */
74
- platform: navigator.platform
76
+ platform: navigator.platform,
77
+ /** 设备二进制接口类型(仅 Android 支持) */
78
+ CPUType: '',
75
79
  };
76
80
  return info;
77
81
  };
@@ -0,0 +1,20 @@
1
+ import Taro from '@tarojs/taro';
2
+ declare type TElement = Document | HTMLElement | Element;
3
+ export declare class TaroH5IntersectionObserver implements Taro.IntersectionObserver {
4
+ private _component;
5
+ private _options;
6
+ private _observerInst;
7
+ private _listeners;
8
+ private _root;
9
+ private _rootMargin;
10
+ private _isInited;
11
+ protected get container(): TElement;
12
+ constructor(component: TaroGeneral.IAnyObject, options?: Taro.createIntersectionObserver.Option);
13
+ private createInst;
14
+ disconnect(): void;
15
+ observe(targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void;
16
+ relativeTo(selector: string, margins?: Taro.IntersectionObserver.RelativeToMargins | undefined): Taro.IntersectionObserver;
17
+ relativeToViewport(margins?: Taro.IntersectionObserver.RelativeToViewportMargins | undefined): Taro.IntersectionObserver;
18
+ private _getCallbackByElement;
19
+ }
20
+ export {};
@@ -0,0 +1,104 @@
1
+ import { findDOM } from '../../utils';
2
+ // pollify
3
+ import('intersection-observer');
4
+ export class TaroH5IntersectionObserver {
5
+ constructor(component, options = {}) {
6
+ // 选项
7
+ this._options = {
8
+ thresholds: [0],
9
+ initialRatio: 0,
10
+ observeAll: false
11
+ };
12
+ // 监控中的选择器
13
+ this._listeners = [];
14
+ // 用来扩展(或收缩)参照节点布局区域的边界
15
+ this._rootMargin = {};
16
+ // 是否已初始化
17
+ this._isInited = false;
18
+ this._component = component;
19
+ Object.assign(this._options, options);
20
+ }
21
+ // selector 的容器节点
22
+ get container() {
23
+ const container = (this._component !== null
24
+ ? (findDOM(this._component) || document)
25
+ : document);
26
+ return container;
27
+ }
28
+ createInst() {
29
+ // 去除原本的实例
30
+ this.disconnect();
31
+ const { left = 0, top = 0, bottom = 0, right = 0 } = this._rootMargin;
32
+ return new IntersectionObserver(entries => {
33
+ entries.forEach(entry => {
34
+ const _callback = this._getCallbackByElement(entry.target);
35
+ const result = {
36
+ boundingClientRect: entry.boundingClientRect,
37
+ intersectionRatio: entry.intersectionRatio,
38
+ intersectionRect: entry.intersectionRect,
39
+ relativeRect: entry.rootBounds || { left: 0, right: 0, top: 0, bottom: 0 },
40
+ time: entry.time
41
+ };
42
+ // web端会默认首次触发
43
+ if (!this._isInited && this._options.initialRatio <= Math.min.apply(Math, this._options.thresholds)) {
44
+ // 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。
45
+ return;
46
+ }
47
+ _callback && _callback.call(this, result);
48
+ });
49
+ this._isInited = true;
50
+ }, {
51
+ root: this._root,
52
+ rootMargin: [`${top}px`, `${right}px`, `${bottom}px`, `${left}px`].join(' '),
53
+ threshold: this._options.thresholds
54
+ });
55
+ }
56
+ disconnect() {
57
+ if (this._observerInst) {
58
+ let listener;
59
+ while ((listener = this._listeners.pop())) {
60
+ this._observerInst.unobserve(listener.element);
61
+ }
62
+ this._observerInst.disconnect();
63
+ }
64
+ }
65
+ observe(targetSelector, callback) {
66
+ // 同wx小程序效果一致,每个实例监听一个Selector
67
+ if (this._listeners.length)
68
+ return;
69
+ // 监听前没有设置关联的节点
70
+ if (!this._observerInst) {
71
+ console.warn('Intersection observer will be ignored because no relative nodes are found.');
72
+ return;
73
+ }
74
+ const nodeList = this._options.observeAll
75
+ ? this.container.querySelectorAll(targetSelector)
76
+ : [this.container.querySelector(targetSelector)];
77
+ nodeList.forEach(element => {
78
+ if (!element)
79
+ return;
80
+ this._observerInst.observe(element);
81
+ this._listeners.push({ element, callback });
82
+ });
83
+ }
84
+ relativeTo(selector, margins) {
85
+ // 已设置observe监听后,重新关联节点
86
+ if (this._listeners.length) {
87
+ console.error('Relative nodes cannot be added after "observe" call in IntersectionObserver');
88
+ return this;
89
+ }
90
+ this._root = this.container.querySelector(selector) || null;
91
+ if (margins) {
92
+ this._rootMargin = margins;
93
+ }
94
+ this._observerInst = this.createInst();
95
+ return this;
96
+ }
97
+ relativeToViewport(margins) {
98
+ return this.relativeTo('.taro_page', margins);
99
+ }
100
+ _getCallbackByElement(element) {
101
+ const listener = this._listeners.find(listener => listener.element === element);
102
+ return listener ? listener.callback : null;
103
+ }
104
+ }
@@ -0,0 +1,7 @@
1
+ import Taro from '@tarojs/taro';
2
+ export declare class MediaQueryObserver implements Taro.MediaQueryObserver {
3
+ private _mediaQueryObserver;
4
+ private _listener;
5
+ observe(descriptor: Taro.MediaQueryObserver.descriptor, callback: Taro.MediaQueryObserver.observeCallback): void;
6
+ disconnect(): void;
7
+ }
@@ -0,0 +1,50 @@
1
+ import { isFunction } from '@tarojs/shared';
2
+ import { toKebabCase } from '../../utils';
3
+ function generateMediaQueryStr(descriptor) {
4
+ const mediaQueryArr = [];
5
+ const descriptorMenu = ['width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'orientation'];
6
+ for (const item of descriptorMenu) {
7
+ if (item !== 'orientation' &&
8
+ descriptor[item] &&
9
+ Number(descriptor[item]) >= 0) {
10
+ mediaQueryArr.push(`(${(toKebabCase(item))}: ${Number(descriptor[item])}px)`);
11
+ }
12
+ if (item === 'orientation' && descriptor[item]) {
13
+ mediaQueryArr.push(`(${toKebabCase(item)}: ${descriptor[item]})`);
14
+ }
15
+ }
16
+ return mediaQueryArr.join(' and ');
17
+ }
18
+ export class MediaQueryObserver {
19
+ // 监听页面媒体查询变化情况
20
+ observe(descriptor, callback) {
21
+ if (isFunction(callback)) {
22
+ // 创建媒体查询对象
23
+ this._mediaQueryObserver = window.matchMedia(generateMediaQueryStr(descriptor));
24
+ // 监听器
25
+ this._listener = (ev) => {
26
+ callback({ matches: ev.matches });
27
+ };
28
+ callback({ matches: this._mediaQueryObserver.matches });
29
+ // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'
30
+ if ('addEventListener' in this._mediaQueryObserver) {
31
+ this._mediaQueryObserver.addEventListener('change', this._listener);
32
+ }
33
+ else {
34
+ this._mediaQueryObserver.addListener(this._listener);
35
+ }
36
+ }
37
+ }
38
+ // 停止监听,销毁媒体查询对象
39
+ disconnect() {
40
+ if (this._mediaQueryObserver && this._listener) {
41
+ // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'
42
+ if ('removeEventListener' in this._mediaQueryObserver) {
43
+ this._mediaQueryObserver.removeEventListener('change', this._listener);
44
+ }
45
+ else {
46
+ this._mediaQueryObserver.removeListener(this._listener);
47
+ }
48
+ }
49
+ }
50
+ }
@@ -1,3 +1,4 @@
1
1
  import Taro from '@tarojs/api';
2
2
  export declare const createSelectorQuery: typeof Taro.createSelectorQuery;
3
- export declare const createIntersectionObserver: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
3
+ export declare const createIntersectionObserver: typeof Taro.createIntersectionObserver;
4
+ export declare const createMediaQueryObserver: typeof Taro.createMediaQueryObserver;
@@ -1,6 +1,12 @@
1
- import { temporarilyNotSupport } from '../../utils';
1
+ import { TaroH5IntersectionObserver } from './IntersectionObserver';
2
+ import { MediaQueryObserver } from './MediaQueryObserver';
2
3
  import { SelectorQuery } from './selectorQuery';
3
4
  export const createSelectorQuery = () => {
4
5
  return new SelectorQuery();
5
6
  };
6
- export const createIntersectionObserver = temporarilyNotSupport('createIntersectionObserver');
7
+ export const createIntersectionObserver = (component, options) => {
8
+ return new TaroH5IntersectionObserver(component, options);
9
+ };
10
+ export const createMediaQueryObserver = () => {
11
+ return new MediaQueryObserver();
12
+ };
@@ -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.cjs.js CHANGED
@@ -15,6 +15,24 @@ var jsonpRetry = require('jsonp-retry');
15
15
 
16
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
17
 
18
+ function _interopNamespace(e) {
19
+ if (e && e.__esModule) return e;
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ n["default"] = e;
33
+ return Object.freeze(n);
34
+ }
35
+
18
36
  var Taro__default = /*#__PURE__*/_interopDefaultLegacy(Taro);
19
37
  var jsonpRetry__default = /*#__PURE__*/_interopDefaultLegacy(jsonpRetry);
20
38
 
@@ -43,7 +61,7 @@ class MethodHandler {
43
61
  else {
44
62
  res.errMsg = `${this.methodName}:fail ${res.errMsg}`;
45
63
  }
46
- if (!isProd) {
64
+ if (process.env.NODE_ENV !== 'production') {
47
65
  console.error(res.errMsg);
48
66
  }
49
67
  shared.isFunction(this.__fail) && this.__fail(res);
@@ -158,7 +176,6 @@ const isValidColor = (color) => {
158
176
  };
159
177
 
160
178
  /* eslint-disable prefer-promise-reject-errors */
161
- const isProd = process.env.NODE_ENV === 'production';
162
179
  function shouldBeObject(target) {
163
180
  if (target && typeof target === 'object')
164
181
  return { flag: true };
@@ -202,6 +219,9 @@ function upperCaseFirstLetter(string) {
202
219
  string = string.replace(/^./, match => match.toUpperCase());
203
220
  return string;
204
221
  }
222
+ const toKebabCase = function (string) {
223
+ return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
224
+ };
205
225
  function inlineStyle(style) {
206
226
  let res = '';
207
227
  for (const attr in style)
@@ -237,7 +257,7 @@ function temporarilyNotSupport(name = '') {
237
257
  type: 'method',
238
258
  category: 'temporarily',
239
259
  });
240
- if (isProd) {
260
+ if (process.env.NODE_ENV === 'production') {
241
261
  console.warn(errMsg);
242
262
  return handle.success({ errMsg });
243
263
  }
@@ -257,7 +277,7 @@ function weixinCorpSupport(name) {
257
277
  type: 'method',
258
278
  category: 'weixin_corp',
259
279
  });
260
- if (isProd) {
280
+ if (process.env.NODE_ENV === 'production') {
261
281
  console.warn(errMsg);
262
282
  return handle.success({ errMsg });
263
283
  }
@@ -277,7 +297,7 @@ function permanentlyNotSupport(name = '') {
277
297
  type: 'method',
278
298
  category: 'permanently',
279
299
  });
280
- if (isProd) {
300
+ if (process.env.NODE_ENV === 'production') {
281
301
  console.warn(errMsg);
282
302
  return handle.success({ errMsg });
283
303
  }
@@ -642,6 +662,8 @@ const getDeviceInfo = () => {
642
662
  const info = {
643
663
  /** 应用二进制接口类型(仅 Android 支持) */
644
664
  abi: '',
665
+ /** 设备二进制接口类型(仅 Android 支持) */
666
+ deviceAbi: '',
645
667
  /** 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50) */
646
668
  benchmarkLevel: -1,
647
669
  /** 设备品牌 */
@@ -651,7 +673,9 @@ const getDeviceInfo = () => {
651
673
  /** 操作系统及版本 */
652
674
  system: md.os(),
653
675
  /** 客户端平台 */
654
- platform: navigator.platform
676
+ platform: navigator.platform,
677
+ /** 设备二进制接口类型(仅 Android 支持) */
678
+ CPUType: '',
655
679
  };
656
680
  return info;
657
681
  };
@@ -4996,6 +5020,159 @@ const offWindowResize = callback => {
4996
5020
  // Worker
4997
5021
  const createWorker = temporarilyNotSupport('createWorker');
4998
5022
 
5023
+ // pollify
5024
+ Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('intersection-observer')); });
5025
+ class TaroH5IntersectionObserver {
5026
+ constructor(component, options = {}) {
5027
+ // 选项
5028
+ this._options = {
5029
+ thresholds: [0],
5030
+ initialRatio: 0,
5031
+ observeAll: false
5032
+ };
5033
+ // 监控中的选择器
5034
+ this._listeners = [];
5035
+ // 用来扩展(或收缩)参照节点布局区域的边界
5036
+ this._rootMargin = {};
5037
+ // 是否已初始化
5038
+ this._isInited = false;
5039
+ this._component = component;
5040
+ Object.assign(this._options, options);
5041
+ }
5042
+ // selector 的容器节点
5043
+ get container() {
5044
+ const container = (this._component !== null
5045
+ ? (findDOM(this._component) || document)
5046
+ : document);
5047
+ return container;
5048
+ }
5049
+ createInst() {
5050
+ // 去除原本的实例
5051
+ this.disconnect();
5052
+ const { left = 0, top = 0, bottom = 0, right = 0 } = this._rootMargin;
5053
+ return new IntersectionObserver(entries => {
5054
+ entries.forEach(entry => {
5055
+ const _callback = this._getCallbackByElement(entry.target);
5056
+ const result = {
5057
+ boundingClientRect: entry.boundingClientRect,
5058
+ intersectionRatio: entry.intersectionRatio,
5059
+ intersectionRect: entry.intersectionRect,
5060
+ relativeRect: entry.rootBounds || { left: 0, right: 0, top: 0, bottom: 0 },
5061
+ time: entry.time
5062
+ };
5063
+ // web端会默认首次触发
5064
+ if (!this._isInited && this._options.initialRatio <= Math.min.apply(Math, this._options.thresholds)) {
5065
+ // 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。
5066
+ return;
5067
+ }
5068
+ _callback && _callback.call(this, result);
5069
+ });
5070
+ this._isInited = true;
5071
+ }, {
5072
+ root: this._root,
5073
+ rootMargin: [`${top}px`, `${right}px`, `${bottom}px`, `${left}px`].join(' '),
5074
+ threshold: this._options.thresholds
5075
+ });
5076
+ }
5077
+ disconnect() {
5078
+ if (this._observerInst) {
5079
+ let listener;
5080
+ while ((listener = this._listeners.pop())) {
5081
+ this._observerInst.unobserve(listener.element);
5082
+ }
5083
+ this._observerInst.disconnect();
5084
+ }
5085
+ }
5086
+ observe(targetSelector, callback) {
5087
+ // 同wx小程序效果一致,每个实例监听一个Selector
5088
+ if (this._listeners.length)
5089
+ return;
5090
+ // 监听前没有设置关联的节点
5091
+ if (!this._observerInst) {
5092
+ console.warn('Intersection observer will be ignored because no relative nodes are found.');
5093
+ return;
5094
+ }
5095
+ const nodeList = this._options.observeAll
5096
+ ? this.container.querySelectorAll(targetSelector)
5097
+ : [this.container.querySelector(targetSelector)];
5098
+ nodeList.forEach(element => {
5099
+ if (!element)
5100
+ return;
5101
+ this._observerInst.observe(element);
5102
+ this._listeners.push({ element, callback });
5103
+ });
5104
+ }
5105
+ relativeTo(selector, margins) {
5106
+ // 已设置observe监听后,重新关联节点
5107
+ if (this._listeners.length) {
5108
+ console.error('Relative nodes cannot be added after "observe" call in IntersectionObserver');
5109
+ return this;
5110
+ }
5111
+ this._root = this.container.querySelector(selector) || null;
5112
+ if (margins) {
5113
+ this._rootMargin = margins;
5114
+ }
5115
+ this._observerInst = this.createInst();
5116
+ return this;
5117
+ }
5118
+ relativeToViewport(margins) {
5119
+ return this.relativeTo('.taro_page', margins);
5120
+ }
5121
+ _getCallbackByElement(element) {
5122
+ const listener = this._listeners.find(listener => listener.element === element);
5123
+ return listener ? listener.callback : null;
5124
+ }
5125
+ }
5126
+
5127
+ function generateMediaQueryStr(descriptor) {
5128
+ const mediaQueryArr = [];
5129
+ const descriptorMenu = ['width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'orientation'];
5130
+ for (const item of descriptorMenu) {
5131
+ if (item !== 'orientation' &&
5132
+ descriptor[item] &&
5133
+ Number(descriptor[item]) >= 0) {
5134
+ mediaQueryArr.push(`(${(toKebabCase(item))}: ${Number(descriptor[item])}px)`);
5135
+ }
5136
+ if (item === 'orientation' && descriptor[item]) {
5137
+ mediaQueryArr.push(`(${toKebabCase(item)}: ${descriptor[item]})`);
5138
+ }
5139
+ }
5140
+ return mediaQueryArr.join(' and ');
5141
+ }
5142
+ class MediaQueryObserver {
5143
+ // 监听页面媒体查询变化情况
5144
+ observe(descriptor, callback) {
5145
+ if (shared.isFunction(callback)) {
5146
+ // 创建媒体查询对象
5147
+ this._mediaQueryObserver = window.matchMedia(generateMediaQueryStr(descriptor));
5148
+ // 监听器
5149
+ this._listener = (ev) => {
5150
+ callback({ matches: ev.matches });
5151
+ };
5152
+ callback({ matches: this._mediaQueryObserver.matches });
5153
+ // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'
5154
+ if ('addEventListener' in this._mediaQueryObserver) {
5155
+ this._mediaQueryObserver.addEventListener('change', this._listener);
5156
+ }
5157
+ else {
5158
+ this._mediaQueryObserver.addListener(this._listener);
5159
+ }
5160
+ }
5161
+ }
5162
+ // 停止监听,销毁媒体查询对象
5163
+ disconnect() {
5164
+ if (this._mediaQueryObserver && this._listener) {
5165
+ // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'
5166
+ if ('removeEventListener' in this._mediaQueryObserver) {
5167
+ this._mediaQueryObserver.removeEventListener('change', this._listener);
5168
+ }
5169
+ else {
5170
+ this._mediaQueryObserver.removeListener(this._listener);
5171
+ }
5172
+ }
5173
+ }
5174
+ }
5175
+
4999
5176
  class NodesRef {
5000
5177
  constructor(selector, querySelectorQuery, single) {
5001
5178
  this._component = querySelectorQuery._component;
@@ -5241,7 +5418,12 @@ class SelectorQuery {
5241
5418
  const createSelectorQuery = () => {
5242
5419
  return new SelectorQuery();
5243
5420
  };
5244
- const createIntersectionObserver = temporarilyNotSupport('createIntersectionObserver');
5421
+ const createIntersectionObserver = (component, options) => {
5422
+ return new TaroH5IntersectionObserver(component, options);
5423
+ };
5424
+ const createMediaQueryObserver = () => {
5425
+ return new MediaQueryObserver();
5426
+ };
5245
5427
 
5246
5428
  const { Behavior, getEnv, ENV_TYPE, Link, interceptors, getInitPxTransform, Current, options, eventCenter, Events, preload } = Taro__default["default"];
5247
5429
  const taro = {
@@ -5382,6 +5564,7 @@ exports.createLivePusherContext = createLivePusherContext;
5382
5564
  exports.createMapContext = createMapContext;
5383
5565
  exports.createMediaAudioPlayer = createMediaAudioPlayer;
5384
5566
  exports.createMediaContainer = createMediaContainer;
5567
+ exports.createMediaQueryObserver = createMediaQueryObserver;
5385
5568
  exports.createMediaRecorder = createMediaRecorder;
5386
5569
  exports.createOffscreenCanvas = createOffscreenCanvas;
5387
5570
  exports.createRewardedVideoAd = createRewardedVideoAd;