@tarojs/taro-h5 3.4.0-beta.2 → 3.4.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.
Files changed (168) hide show
  1. package/dist/api/ad/index.js +4 -0
  2. package/dist/api/ai/facial.js +5 -0
  3. package/dist/api/ai/index.js +2 -0
  4. package/dist/api/ai/visual.js +5 -0
  5. package/dist/api/alipay/index.js +3 -0
  6. package/dist/api/base/crypto.js +3 -0
  7. package/dist/api/base/debug.js +4 -0
  8. package/dist/api/base/index.js +17 -0
  9. package/dist/api/base/performance.js +4 -0
  10. package/dist/api/base/system.js +187 -0
  11. package/dist/api/base/update.js +4 -0
  12. package/dist/api/base/weapp/app-event.js +18 -0
  13. package/dist/api/base/weapp/life-cycle.js +4 -0
  14. package/dist/api/canvas/CanvasContext.js +191 -0
  15. package/dist/api/canvas/canvasGetImageData.js +25 -0
  16. package/dist/api/canvas/canvasPutImageData.js +22 -0
  17. package/dist/api/canvas/canvasToTempFilePath.js +22 -0
  18. package/dist/api/canvas/createCanvasContext.js +16 -0
  19. package/dist/api/canvas/index.js +12 -0
  20. package/dist/api/cloud/index.js +21 -0
  21. package/dist/api/data-analysis/index.js +5 -0
  22. package/dist/api/device/accelerometer.js +83 -0
  23. package/dist/api/device/accessibility.js +3 -0
  24. package/dist/api/device/battery.js +21 -0
  25. package/dist/api/device/bluetooth-ble.js +18 -0
  26. package/dist/api/device/bluetooth-peripheral.js +5 -0
  27. package/dist/api/device/bluetooth.js +15 -0
  28. package/dist/api/device/calendar.js +4 -0
  29. package/dist/api/device/clipboard.js +65 -0
  30. package/dist/api/device/compass.js +64 -0
  31. package/dist/api/device/contact.js +4 -0
  32. package/dist/api/device/crypto.js +3 -0
  33. package/dist/api/device/gyroscope.js +6 -0
  34. package/dist/api/device/iBeacon.js +9 -0
  35. package/dist/api/device/index.js +23 -0
  36. package/dist/api/device/keyboard.js +6 -0
  37. package/dist/api/device/memory.js +4 -0
  38. package/dist/api/device/motion.js +81 -0
  39. package/dist/api/device/network.js +78 -0
  40. package/dist/api/device/nfc.js +9 -0
  41. package/dist/api/device/phone.js +24 -0
  42. package/dist/api/device/scan.js +6 -0
  43. package/dist/api/device/screen.js +8 -0
  44. package/dist/api/device/vibrate.js +35 -0
  45. package/dist/api/device/wifi.js +13 -0
  46. package/dist/api/ext/index.js +4 -0
  47. package/dist/api/files/index.js +10 -0
  48. package/dist/api/framework/index.js +7 -0
  49. package/dist/api/index.js +24 -0
  50. package/dist/api/location/chooseLocation.js +93 -0
  51. package/dist/api/location/index.js +13 -0
  52. package/dist/api/location/style.css +79 -0
  53. package/dist/api/media/EditorContext.js +19 -0
  54. package/dist/api/media/audio/InnerAudioContext.js +84 -0
  55. package/dist/api/media/audio/index.js +15 -0
  56. package/dist/api/media/background-audio/BackgroundAudioManager.js +86 -0
  57. package/dist/api/media/background-audio/index.js +15 -0
  58. package/dist/api/media/camera.js +3 -0
  59. package/dist/api/media/image/chooseImage.js +74 -0
  60. package/dist/api/media/image/getImageInfo.js +31 -0
  61. package/dist/api/media/image/index.js +9 -0
  62. package/dist/api/media/image/previewImage.js +67 -0
  63. package/dist/api/media/index.js +12 -0
  64. package/dist/api/media/live.js +4 -0
  65. package/dist/api/media/map.js +3 -0
  66. package/dist/api/media/media-recorder.js +3 -0
  67. package/dist/api/media/recorder.js +5 -0
  68. package/dist/api/media/video/index.js +74 -0
  69. package/dist/api/media/video-decoder.js +3 -0
  70. package/dist/api/media/video-processing.js +3 -0
  71. package/dist/api/media/voip.js +16 -0
  72. package/dist/api/navigate/index.js +6 -0
  73. package/dist/api/network/download.js +124 -0
  74. package/dist/api/network/index.js +7 -0
  75. package/dist/api/network/mdns.js +12 -0
  76. package/dist/api/network/request/index.js +125 -0
  77. package/dist/api/network/tcp.js +3 -0
  78. package/dist/api/network/udp.js +3 -0
  79. package/dist/api/network/upload.js +146 -0
  80. package/dist/api/network/utils.js +65 -0
  81. package/dist/api/network/websocket/index.js +70 -0
  82. package/dist/api/network/websocket/socketTask.js +63 -0
  83. package/dist/api/open-api/account.js +3 -0
  84. package/dist/api/open-api/address.js +3 -0
  85. package/dist/api/open-api/authorize.js +4 -0
  86. package/dist/api/open-api/card.js +4 -0
  87. package/dist/api/open-api/channels-live.js +8 -0
  88. package/dist/api/open-api/customer-service.js +3 -0
  89. package/dist/api/open-api/facial.js +6 -0
  90. package/dist/api/open-api/favorites.js +4 -0
  91. package/dist/api/open-api/group.js +3 -0
  92. package/dist/api/open-api/index.js +18 -0
  93. package/dist/api/open-api/invoice.js +4 -0
  94. package/dist/api/open-api/license-plate.js +3 -0
  95. package/dist/api/open-api/login.js +5 -0
  96. package/dist/api/open-api/red-package.js +3 -0
  97. package/dist/api/open-api/settings.js +4 -0
  98. package/dist/api/open-api/soter.js +5 -0
  99. package/dist/api/open-api/subscribe-message.js +3 -0
  100. package/dist/api/open-api/user-info.js +4 -0
  101. package/dist/api/open-api/werun.js +4 -0
  102. package/dist/api/payment/index.js +4 -0
  103. package/dist/api/route/index.js +3 -0
  104. package/dist/api/share/index.js +12 -0
  105. package/dist/api/storage/background-fetch.js +6 -0
  106. package/dist/api/storage/index.js +157 -0
  107. package/dist/api/swan/index.js +26 -0
  108. package/dist/api/taro.js +47 -0
  109. package/dist/api/ui/animation/index.js +288 -0
  110. package/dist/api/ui/background.js +4 -0
  111. package/dist/api/ui/custom-component.js +3 -0
  112. package/dist/api/ui/fonts.js +51 -0
  113. package/dist/api/ui/index.js +12 -0
  114. package/dist/api/ui/interaction/actionSheet.js +188 -0
  115. package/dist/api/ui/interaction/index.js +268 -0
  116. package/dist/api/ui/interaction/modal.js +207 -0
  117. package/dist/api/ui/interaction/toast.js +195 -0
  118. package/dist/api/ui/menu.js +3 -0
  119. package/dist/api/ui/navigation-bar/index.js +42 -0
  120. package/dist/api/ui/pull-down-refresh.js +26 -0
  121. package/dist/api/ui/scroll/index.js +83 -0
  122. package/dist/api/ui/sticky.js +3 -0
  123. package/dist/api/ui/tab-bar.js +282 -0
  124. package/dist/api/ui/window.js +31 -0
  125. package/dist/api/utils/handler.js +80 -0
  126. package/dist/api/utils/index.js +172 -0
  127. package/dist/api/worker/index.js +3 -0
  128. package/dist/api/wxml/index.js +6 -0
  129. package/dist/api/wxml/nodesRef.js +42 -0
  130. package/dist/api/wxml/selectorQuery.js +201 -0
  131. package/dist/index.cjs.js +5028 -6988
  132. package/dist/index.js +4 -10767
  133. package/dist/taroApis.js +1 -1
  134. package/dist/types/type.js +2 -0
  135. package/package.json +11 -13
  136. package/src/api/ai/visual.ts +3 -0
  137. package/src/api/base/system.ts +207 -0
  138. package/src/api/canvas/CanvasContext.ts +42 -39
  139. package/src/api/canvas/createCanvasContext.ts +2 -2
  140. package/src/api/canvas/index.ts +10 -2
  141. package/src/api/cloud/index.ts +4 -0
  142. package/src/api/device/battery.ts +18 -1
  143. package/src/api/device/index.ts +1 -0
  144. package/src/api/{base/system → device}/network.ts +35 -15
  145. package/src/api/device/wifi.ts +1 -0
  146. package/src/api/location/chooseLocation.ts +2 -2
  147. package/src/api/media/{editor.ts → EditorContext.ts} +2 -0
  148. package/src/api/media/audio/InnerAudioContext.ts +98 -0
  149. package/src/api/media/audio/index.ts +1 -86
  150. package/src/api/media/background-audio/BackgroundAudioManager.ts +103 -0
  151. package/src/api/media/{background-audio.ts → background-audio/index.ts} +7 -2
  152. package/src/api/media/image/previewImage.ts +4 -25
  153. package/src/api/media/index.ts +0 -1
  154. package/src/api/network/download.ts +5 -5
  155. package/src/api/network/upload.ts +7 -13
  156. package/src/api/network/websocket/index.ts +1 -1
  157. package/src/api/ui/animation/index.ts +11 -12
  158. package/src/api/ui/fonts.ts +61 -2
  159. package/src/api/ui/interaction/index.ts +12 -10
  160. package/src/api/ui/navigation-bar/index.ts +2 -2
  161. package/src/api/ui/scroll/index.ts +3 -3
  162. package/src/api/utils/handler.ts +4 -4
  163. package/src/api/utils/index.ts +34 -13
  164. package/src/api/wxml/nodesRef.ts +10 -3
  165. package/src/api/wxml/selectorQuery.ts +68 -23
  166. package/src/index.ts +2 -2
  167. package/src/api/base/system/index.ts +0 -2
  168. package/src/api/base/system/info.ts +0 -64
@@ -0,0 +1,172 @@
1
+ /* eslint-disable prefer-promise-reject-errors */
2
+ import { Current, container, SERVICE_IDENTIFIER } from '@tarojs/runtime';
3
+ export function shouldBeObject(target) {
4
+ if (target && typeof target === 'object')
5
+ return { flag: true };
6
+ return {
7
+ flag: false,
8
+ msg: getParameterError({
9
+ correct: 'Object',
10
+ wrong: target
11
+ })
12
+ };
13
+ }
14
+ export function findDOM(inst) {
15
+ const runtimeHooks = container.get(SERVICE_IDENTIFIER.Hooks);
16
+ if (inst) {
17
+ const find = runtimeHooks.getDOMNode;
18
+ if (typeof find === 'function') {
19
+ return find(inst);
20
+ }
21
+ }
22
+ const page = Current.page;
23
+ const path = page === null || page === void 0 ? void 0 : page.path;
24
+ const msg = '没有找到已经加载了的页面,请在页面加载完成后时候此 API。';
25
+ if (path == null) {
26
+ throw new Error(msg);
27
+ }
28
+ const el = document.getElementById(path);
29
+ if (el == null) {
30
+ throw new Error('在已加载页面中没有找到对应的容器元素。');
31
+ }
32
+ return el;
33
+ }
34
+ export function getParameterError({ name = '', para, correct, wrong }) {
35
+ const parameter = para ? `parameter.${para}` : 'parameter';
36
+ const errorType = upperCaseFirstLetter(wrong === null ? 'Null' : typeof wrong);
37
+ if (name) {
38
+ return `${name}:fail parameter error: ${parameter} should be ${correct} instead of ${errorType}`;
39
+ }
40
+ else {
41
+ return `parameter error: ${parameter} should be ${correct} instead of ${errorType}`;
42
+ }
43
+ }
44
+ function upperCaseFirstLetter(string) {
45
+ if (typeof string !== 'string')
46
+ return string;
47
+ string = string.replace(/^./, match => match.toUpperCase());
48
+ return string;
49
+ }
50
+ export function inlineStyle(style) {
51
+ let res = '';
52
+ for (const attr in style)
53
+ res += `${attr}: ${style[attr]};`;
54
+ if (res.indexOf('display: flex;') >= 0)
55
+ res += 'display: -webkit-box;display: -webkit-flex;';
56
+ res = res.replace(/transform:(.+?);/g, (s, $1) => `${s}-webkit-transform:${$1};`);
57
+ res = res.replace(/flex-direction:(.+?);/g, (s, $1) => `${s}-webkit-flex-direction:${$1};`);
58
+ return res;
59
+ }
60
+ export function setTransform(el, val) {
61
+ el.style.webkitTransform = val;
62
+ el.style.transform = val;
63
+ }
64
+ export function serializeParams(params) {
65
+ if (!params) {
66
+ return '';
67
+ }
68
+ return Object.keys(params)
69
+ .map(key => (`${encodeURIComponent(key)}=${typeof (params[key]) === 'object'
70
+ ? encodeURIComponent(JSON.stringify(params[key]))
71
+ : encodeURIComponent(params[key])}`))
72
+ .join('&');
73
+ }
74
+ export function temporarilyNotSupport(apiName) {
75
+ return () => {
76
+ const errMsg = `暂时不支持 API ${apiName}`;
77
+ if (process.env.NODE_ENV !== 'production') {
78
+ console.error(errMsg);
79
+ return Promise.reject({
80
+ errMsg
81
+ });
82
+ }
83
+ else {
84
+ console.warn(errMsg);
85
+ return Promise.resolve({
86
+ errMsg
87
+ });
88
+ }
89
+ };
90
+ }
91
+ export function weixinCorpSupport(apiName) {
92
+ return () => {
93
+ const errMsg = `h5端仅在微信公众号中支持 API ${apiName}`;
94
+ if (process.env.NODE_ENV !== 'production') {
95
+ console.error(errMsg);
96
+ return Promise.reject({
97
+ errMsg
98
+ });
99
+ }
100
+ else {
101
+ console.warn(errMsg);
102
+ return Promise.resolve({
103
+ errMsg
104
+ });
105
+ }
106
+ };
107
+ }
108
+ export function permanentlyNotSupport(apiName) {
109
+ return () => {
110
+ const errMsg = `不支持 API ${apiName}`;
111
+ if (process.env.NODE_ENV !== 'production') {
112
+ console.error(errMsg);
113
+ return Promise.reject({
114
+ errMsg
115
+ });
116
+ }
117
+ else {
118
+ console.warn(errMsg);
119
+ return Promise.resolve({
120
+ errMsg
121
+ });
122
+ }
123
+ };
124
+ }
125
+ export function isFunction(obj) {
126
+ return typeof obj === 'function';
127
+ }
128
+ const VALID_COLOR_REG = /^#[0-9a-fA-F]{6}$/;
129
+ export const isValidColor = (color) => {
130
+ return VALID_COLOR_REG.test(color);
131
+ };
132
+ export function processOpenApi(apiName, defaultOptions, formatResult = res => res, formatParams = options => options) {
133
+ // @ts-ignore
134
+ if (!window.wx) {
135
+ return weixinCorpSupport(apiName);
136
+ }
137
+ return options => {
138
+ options = options || {};
139
+ const obj = Object.assign({}, defaultOptions, options);
140
+ const p = new Promise((resolve, reject) => {
141
+ ['fail', 'success', 'complete'].forEach(k => {
142
+ obj[k] = oriRes => {
143
+ const res = formatResult(oriRes);
144
+ options[k] && options[k](res);
145
+ if (k === 'success') {
146
+ resolve(res);
147
+ }
148
+ else if (k === 'fail') {
149
+ reject(res);
150
+ }
151
+ };
152
+ });
153
+ // @ts-ignore
154
+ wx[apiName](formatParams(obj));
155
+ });
156
+ return p;
157
+ };
158
+ }
159
+ /**
160
+ * ease-in-out的函数
161
+ * @param t 0-1的数字
162
+ */
163
+ export const easeInOut = (t) => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
164
+ export const getTimingFunc = (easeFunc, frameCnt) => {
165
+ return x => {
166
+ if (frameCnt <= 1) {
167
+ return easeFunc(1);
168
+ }
169
+ const t = x / (frameCnt - 1);
170
+ return easeFunc(t);
171
+ };
172
+ };
@@ -0,0 +1,3 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // Worker
3
+ export const createWorker = temporarilyNotSupport('createWorker');
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ import { SelectorQuery } from './selectorQuery';
3
+ export const createSelectorQuery = () => {
4
+ return new SelectorQuery();
5
+ };
6
+ export const createIntersectionObserver = temporarilyNotSupport('createIntersectionObserver');
@@ -0,0 +1,42 @@
1
+ export class NodesRef {
2
+ constructor(selector, querySelectorQuery, single) {
3
+ this._component = querySelectorQuery._component;
4
+ this._selector = selector;
5
+ this._selectorQuery = querySelectorQuery;
6
+ this._single = single;
7
+ }
8
+ context(cb) {
9
+ const { _selector, _component, _single, _selectorQuery } = this;
10
+ _selectorQuery._push(_selector, _component, _single, { context: !0 }, cb);
11
+ return _selectorQuery;
12
+ }
13
+ node(cb) {
14
+ const { _selector, _component, _single, _selectorQuery } = this;
15
+ _selectorQuery._push(_selector, _component, _single, { nodeCanvasType: !0, node: !0 }, cb);
16
+ return _selectorQuery;
17
+ }
18
+ boundingClientRect(cb) {
19
+ const { _selector, _component, _single, _selectorQuery } = this;
20
+ _selectorQuery._push(_selector, _component, _single, { id: !0, dataset: !0, rect: !0, size: !0 }, cb);
21
+ return _selectorQuery;
22
+ }
23
+ scrollOffset(cb) {
24
+ const { _selector, _component, _single, _selectorQuery } = this;
25
+ _selectorQuery._push(_selector, _component, _single, { id: !0, dataset: !0, scrollOffset: !0 }, cb);
26
+ return _selectorQuery;
27
+ }
28
+ fields(fields, cb) {
29
+ const { _selector, _component, _single, _selectorQuery } = this;
30
+ const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [] } = fields;
31
+ _selectorQuery._push(_selector, _component, _single, {
32
+ id,
33
+ dataset,
34
+ rect,
35
+ size,
36
+ scrollOffset,
37
+ properties,
38
+ computedStyle
39
+ }, cb);
40
+ return _selectorQuery;
41
+ }
42
+ }
@@ -0,0 +1,201 @@
1
+ import { CanvasContext } from '../canvas/CanvasContext';
2
+ import { findDOM } from '../utils';
3
+ import { NodesRef } from './nodesRef';
4
+ function filter(fields, dom, selector) {
5
+ if (!dom)
6
+ return null;
7
+ const isViewport = selector === '.taro_page';
8
+ const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [], nodeCanvasType, node, context } = fields;
9
+ const res = {};
10
+ if (nodeCanvasType && node) {
11
+ const tagName = dom.tagName;
12
+ res.node = {
13
+ id: dom.id,
14
+ $taroElement: dom
15
+ };
16
+ if (/^taro-canvas-core/i.test(tagName)) {
17
+ const type = dom.type || '';
18
+ res.nodeCanvasType = type;
19
+ const canvas = dom.getElementsByTagName('canvas')[0];
20
+ if (/^(2d|webgl)/i.test(type) && canvas) {
21
+ res.node = canvas;
22
+ }
23
+ else {
24
+ res.node = null;
25
+ }
26
+ }
27
+ else {
28
+ // TODO https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html
29
+ // if (/^taro-scroll-view-core/i.test(tagName))
30
+ res.nodeCanvasType = '';
31
+ res.node = dom;
32
+ }
33
+ return res;
34
+ }
35
+ if (context) {
36
+ const tagName = dom.tagName;
37
+ if (/^taro-video-core/i.test(tagName)) {
38
+ // TODO HTMLVideoElement to VideoContext
39
+ return { context: dom };
40
+ }
41
+ else if (/^taro-canvas-core/i.test(tagName)) {
42
+ const type = dom.type || '2d';
43
+ const canvas = dom === null || dom === void 0 ? void 0 : dom.querySelector('canvas');
44
+ const ctx = canvas === null || canvas === void 0 ? void 0 : canvas.getContext(type);
45
+ return { context: new CanvasContext(canvas, ctx) };
46
+ }
47
+ else if (/^taro-live-player-core/i.test(tagName)) {
48
+ console.error('暂时不支持通过 NodesRef.context 获取 LivePlayerContext');
49
+ }
50
+ else if (/^taro-editor-core/i.test(tagName)) {
51
+ console.error('暂时不支持通过 NodesRef.context 获取 EditorContext');
52
+ }
53
+ else if (/^taro-map-core/i.test(tagName)) {
54
+ console.error('暂时不支持通过 NodesRef.context 获取 MapContext');
55
+ }
56
+ return;
57
+ }
58
+ if (id)
59
+ res.id = dom.id;
60
+ if (dataset)
61
+ res.dataset = Object.assign({}, dom.dataset);
62
+ if (rect || size) {
63
+ const { left, right, top, bottom, width, height } = dom.getBoundingClientRect();
64
+ if (rect) {
65
+ if (!isViewport) {
66
+ res.left = left;
67
+ res.right = right;
68
+ res.top = top;
69
+ res.bottom = bottom;
70
+ }
71
+ else {
72
+ res.left = 0;
73
+ res.right = 0;
74
+ res.top = 0;
75
+ res.bottom = 0;
76
+ }
77
+ }
78
+ if (size) {
79
+ if (!isViewport) {
80
+ res.width = width;
81
+ res.height = height;
82
+ }
83
+ else {
84
+ res.width = dom.clientWidth;
85
+ res.height = dom.clientHeight;
86
+ }
87
+ }
88
+ }
89
+ if (scrollOffset) {
90
+ res.scrollLeft = dom.scrollLeft;
91
+ res.scrollTop = dom.scrollTop;
92
+ }
93
+ if (properties.length) {
94
+ properties.forEach(prop => {
95
+ const attr = dom.getAttribute(prop);
96
+ if (attr)
97
+ res[prop] = attr;
98
+ });
99
+ }
100
+ if (computedStyle.length) {
101
+ const styles = window.getComputedStyle(dom);
102
+ computedStyle.forEach(key => {
103
+ const value = styles.getPropertyValue(key) || styles[key];
104
+ if (value)
105
+ res[key] = value;
106
+ });
107
+ }
108
+ return res;
109
+ }
110
+ /**
111
+ * WXML节点信息API
112
+ * @return {Object} SelectorQuery 对象实例
113
+ */
114
+ function queryBat(queue, cb) {
115
+ const result = [];
116
+ queue.forEach(item => {
117
+ var _a;
118
+ const { selector, single, fields, component } = item;
119
+ // selector 的容器节点
120
+ /* eslint-disable */
121
+ const container = (component !== null ?
122
+ (findDOM(component) || document) :
123
+ document);
124
+ /* eslint-enable */
125
+ // 特殊处理 ---- 选自己
126
+ let selectSelf = false;
127
+ if (container !== document) {
128
+ const $nodeList = (_a = container.parentNode) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selector);
129
+ if ($nodeList) {
130
+ for (let i = 0, len = $nodeList.length; i < len; ++i) {
131
+ if (container === $nodeList[i]) {
132
+ selectSelf = true;
133
+ break;
134
+ }
135
+ }
136
+ }
137
+ }
138
+ if (single) {
139
+ const el = selectSelf === true ? container : container.querySelector(selector);
140
+ result.push(filter(fields, el, selector));
141
+ }
142
+ else {
143
+ const $children = container.querySelectorAll(selector);
144
+ const children = [];
145
+ selectSelf === true && children.push(container);
146
+ for (let i = 0, len = $children.length; i < len; ++i) {
147
+ children.push($children[i]);
148
+ }
149
+ result.push(children.map(dom => filter(fields, dom)));
150
+ }
151
+ });
152
+ cb(result);
153
+ }
154
+ export class SelectorQuery {
155
+ constructor() {
156
+ this._defaultWebviewId = null;
157
+ this._webviewId = null;
158
+ this._queue = [];
159
+ this._queueCb = [];
160
+ this._component;
161
+ }
162
+ in(component) {
163
+ this._component = component;
164
+ return this;
165
+ }
166
+ select(selector) {
167
+ // 小程序里跨自定义组件的后代选择器 '>>>' 在 h5 替换为普通后代选择器 '>'
168
+ if (typeof selector === 'string')
169
+ selector = selector.replace('>>>', '>');
170
+ return new NodesRef(selector, this, true);
171
+ }
172
+ selectAll(selector) {
173
+ // 小程序里跨自定义组件的后代选择器 '>>>' 在 h5 替换为普通后代选择器 '>'
174
+ if (typeof selector === 'string')
175
+ selector = selector.replace('>>>', '>');
176
+ return new NodesRef(selector, this, false);
177
+ }
178
+ selectViewport() {
179
+ return new NodesRef('.taro_page', this, true);
180
+ }
181
+ exec(cb) {
182
+ queryBat(this._queue, res => {
183
+ const _queueCb = this._queueCb;
184
+ res.forEach((item, index) => {
185
+ const cb = _queueCb[index];
186
+ typeof cb === 'function' && cb.call(this, item);
187
+ });
188
+ typeof cb === 'function' && cb.call(this, res);
189
+ });
190
+ return this;
191
+ }
192
+ _push(selector, component, single, fields, callback = null) {
193
+ this._queue.push({
194
+ component,
195
+ selector,
196
+ single,
197
+ fields
198
+ });
199
+ this._queueCb.push(callback);
200
+ }
201
+ }