@tarojs/taro-h5 3.3.17 → 3.3.18

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 (34) hide show
  1. package/dist/index.cjs.js +1081 -627
  2. package/dist/index.js +1077 -628
  3. package/dist/taroApis.js +1 -1
  4. package/package.json +6 -6
  5. package/src/api/base/system/index.ts +2 -2
  6. package/src/api/canvas/canvasGetImageData.ts +1 -3
  7. package/src/api/canvas/canvasPutImageData.ts +1 -3
  8. package/src/api/canvas/canvasToTempFilePath.ts +1 -3
  9. package/src/api/canvas/createCanvasContext.ts +1 -3
  10. package/src/api/canvas/index.ts +4 -4
  11. package/src/api/cloud/index.ts +1 -1
  12. package/src/api/device/accelerometer.ts +4 -6
  13. package/src/api/device/compass.ts +4 -11
  14. package/src/api/device/motion.ts +4 -11
  15. package/src/api/location/index.ts +1 -1
  16. package/src/api/media/audio/index.ts +12 -6
  17. package/src/api/media/image/chooseImage.ts +1 -3
  18. package/src/api/media/image/getImageInfo.ts +35 -0
  19. package/src/api/media/image/index.ts +3 -3
  20. package/src/api/media/image/previewImage.ts +101 -0
  21. package/src/api/network/download.ts +1 -3
  22. package/src/api/network/upload.ts +1 -3
  23. package/src/api/network/websocket/index.ts +12 -20
  24. package/src/api/network/websocket/socketTask.ts +1 -1
  25. package/src/api/storage/index.ts +58 -70
  26. package/src/api/ui/animation/index.ts +25 -21
  27. package/src/api/ui/interaction/index.ts +28 -24
  28. package/src/api/ui/pull-down-refresh.ts +2 -7
  29. package/src/api/ui/scroll/index.ts +8 -10
  30. package/src/api/utils/index.ts +17 -33
  31. package/src/api/wxml/nodesRef.ts +49 -0
  32. package/src/api/wxml/selectorQuery.ts +2 -48
  33. package/src/api/media/image/getImageInfo.js +0 -74
  34. package/src/api/media/image/previewImage.js +0 -98
package/dist/index.js CHANGED
@@ -1168,11 +1168,15 @@ function prependBasename() {
1168
1168
  return basename.replace(/\/$/, '') + '/' + url.replace(/^\//, '');
1169
1169
  }
1170
1170
 
1171
- var hasBasename = function hasBasename(path, prefix) {
1171
+ var hasBasename = function hasBasename() {
1172
+ var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1173
+ var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1172
1174
  return new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path);
1173
1175
  };
1174
1176
 
1175
- var stripBasename = function stripBasename(path, prefix) {
1177
+ var stripBasename = function stripBasename() {
1178
+ var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1179
+ var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1176
1180
  return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
1177
1181
  };
1178
1182
 
@@ -1216,12 +1220,14 @@ var Stacks = /*#__PURE__*/function () {
1216
1220
  }, {
1217
1221
  key: "getLastIndex",
1218
1222
  value: function getLastIndex(pathname) {
1223
+ var stateWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1224
+
1219
1225
  var list = _toConsumableArray(this.stacks).reverse();
1220
1226
 
1221
1227
  return list.findIndex(function (page, i) {
1222
1228
  var _a;
1223
1229
 
1224
- return i !== 0 && ((_a = page.path) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) === pathname;
1230
+ return i >= stateWith && ((_a = page.path) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) === pathname;
1225
1231
  });
1226
1232
  }
1227
1233
  }, {
@@ -1237,7 +1243,8 @@ var Stacks = /*#__PURE__*/function () {
1237
1243
  }, {
1238
1244
  key: "getPrevIndex",
1239
1245
  value: function getPrevIndex(pathname) {
1240
- var lastIndex = this.getLastIndex(pathname);
1246
+ var stateWith = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1247
+ var lastIndex = this.getLastIndex(pathname, stateWith);
1241
1248
 
1242
1249
  if (lastIndex < 0) {
1243
1250
  return -1;
@@ -1278,7 +1285,9 @@ var RoutesAlias = /*#__PURE__*/function () {
1278
1285
 
1279
1286
  this.conf = [];
1280
1287
 
1281
- this.getConfig = function (url) {
1288
+ this.getConfig = function () {
1289
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1290
+
1282
1291
  var customRoute = _this2.conf.filter(function (arr) {
1283
1292
  return arr.includes(url);
1284
1293
  });
@@ -1286,19 +1295,24 @@ var RoutesAlias = /*#__PURE__*/function () {
1286
1295
  return customRoute[0];
1287
1296
  };
1288
1297
 
1289
- this.getOrigin = function (url) {
1298
+ this.getOrigin = function () {
1299
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1300
+
1290
1301
  var _a;
1291
1302
 
1292
1303
  return ((_a = _this2.getConfig(url)) === null || _a === void 0 ? void 0 : _a[0]) || url;
1293
1304
  };
1294
1305
 
1295
- this.getAlias = function (url) {
1306
+ this.getAlias = function () {
1307
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1308
+
1296
1309
  var _a;
1297
1310
 
1298
1311
  return ((_a = _this2.getConfig(url)) === null || _a === void 0 ? void 0 : _a[1]) || url;
1299
1312
  };
1300
1313
 
1301
- this.getAll = function (url) {
1314
+ this.getAll = function () {
1315
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1302
1316
  return _this2.conf.filter(function (arr) {
1303
1317
  return arr.includes(url);
1304
1318
  }).reduce(function (p, a) {
@@ -1343,33 +1357,6 @@ var RoutesAlias = /*#__PURE__*/function () {
1343
1357
 
1344
1358
  var routesAlias = new RoutesAlias();
1345
1359
 
1346
- var isTabBar = function isTabBar(config) {
1347
- var _a, _b;
1348
-
1349
- var _config$router = config.router,
1350
- _config$router$custom = _config$router.customRoutes,
1351
- customRoutes = _config$router$custom === void 0 ? {} : _config$router$custom,
1352
- _config$router$basena = _config$router.basename,
1353
- basename = _config$router$basena === void 0 ? '' : _config$router$basena,
1354
- pathname = _config$router.pathname;
1355
- var routePath = stripBasename(pathname, basename);
1356
- var pagePath = ((_a = Object.entries(customRoutes).find(function (_ref) {
1357
- var _ref2 = _slicedToArray(_ref, 2),
1358
- target = _ref2[1];
1359
-
1360
- if (typeof target === 'string') {
1361
- return target === routePath;
1362
- } else if ((target === null || target === void 0 ? void 0 : target.length) > 0) {
1363
- return target.includes(routePath);
1364
- }
1365
-
1366
- return false;
1367
- })) === null || _a === void 0 ? void 0 : _a[0]) || routePath;
1368
- return !!pagePath && (((_b = config.tabBar) === null || _b === void 0 ? void 0 : _b.list) || []).some(function (t) {
1369
- return t.pagePath === pagePath;
1370
- });
1371
- };
1372
-
1373
1360
  function processNavigateUrl(option) {
1374
1361
  var _a;
1375
1362
 
@@ -2137,119 +2124,7 @@ var UniversalRouter = function () {
2137
2124
  return UniversalRouter;
2138
2125
  }();
2139
2126
 
2140
- UniversalRouter.pathToRegexp = pathToRegexp_1; // @ts-nocheck
2141
-
2142
- function initTabbar(config) {
2143
- if (config.tabBar == null) {
2144
- return;
2145
- } // TODO: 找到 tabbar 的类型
2146
-
2147
-
2148
- var tabbar = document.createElement('taro-tabbar');
2149
- var homePage = config.entryPagePath || (config.pages ? config.pages[0] : '');
2150
- tabbar.conf = config.tabBar;
2151
- tabbar.conf.homePage = history.location.pathname === '/' ? homePage : history.location.pathname;
2152
- var routerConfig = config.router;
2153
- tabbar.conf.mode = routerConfig && routerConfig.mode ? routerConfig.mode : 'hash';
2154
-
2155
- if (routerConfig.customRoutes) {
2156
- tabbar.conf.custom = true;
2157
- tabbar.conf.customRoutes = routerConfig.customRoutes;
2158
- } else {
2159
- tabbar.conf.custom = false;
2160
- tabbar.conf.customRoutes = {};
2161
- }
2162
-
2163
- if (typeof routerConfig.basename !== 'undefined') {
2164
- tabbar.conf.basename = routerConfig.basename;
2165
- }
2166
-
2167
- var container = document.getElementById('container'); // eslint-disable-next-line no-unused-expressions
2168
-
2169
- container === null || container === void 0 ? void 0 : container.appendChild(tabbar);
2170
- initTabBarApis$1(config);
2171
- }
2172
-
2173
- var routerConfig = Object.create(null);
2174
-
2175
- function init(config) {
2176
- var _a;
2177
-
2178
- config.router.mode = config.router.mode || 'hash';
2179
- setHistoryMode(config.router.mode, config.router.basename);
2180
- Object.assign(routerConfig, config);
2181
- (_a = document.getElementById('app')) === null || _a === void 0 ? void 0 : _a.remove();
2182
- var container = document.createElement('div');
2183
- container.classList.add('taro-tabbar__container');
2184
- container.id = 'container';
2185
- var panel = document.createElement('div');
2186
- panel.classList.add('taro-tabbar__panel');
2187
- var app = document.createElement('div');
2188
- app.id = 'app';
2189
- app.classList.add('taro_router');
2190
- panel.appendChild(app);
2191
- container.appendChild(panel);
2192
- document.body.appendChild(container);
2193
- initTabbar(config);
2194
- }
2195
-
2196
- var pageScrollFn;
2197
- var pageDOM = window;
2198
-
2199
- function bindPageScroll(page, config) {
2200
- pageDOM.removeEventListener('scroll', pageScrollFn);
2201
- pageDOM = getScrollContainer();
2202
- var distance = config.onReachBottomDistance || 50;
2203
- var isReachBottom = false;
2204
-
2205
- pageScrollFn = function pageScrollFn() {
2206
- page.onPageScroll && page.onPageScroll({
2207
- scrollTop: pageDOM instanceof Window ? window.scrollY : pageDOM.scrollTop
2208
- });
2209
-
2210
- if (isReachBottom && getOffset() > distance) {
2211
- isReachBottom = false;
2212
- }
2213
-
2214
- if (page.onReachBottom && !isReachBottom && getOffset() < distance) {
2215
- isReachBottom = true;
2216
- page.onReachBottom();
2217
- }
2218
- };
2219
-
2220
- pageDOM.addEventListener('scroll', pageScrollFn, false);
2221
- }
2222
-
2223
- window.addEventListener('DOMSubtreeModified', function (e) {
2224
- var _a; // @ts-ignore
2225
-
2226
-
2227
- var className = (_a = e.target) === null || _a === void 0 ? void 0 : _a.className;
2228
-
2229
- if (className && /taro-tabbar__/.test(className)) {
2230
- pageDOM.removeEventListener('scroll', pageScrollFn);
2231
- pageDOM = getScrollContainer();
2232
- pageDOM.addEventListener('scroll', pageScrollFn, false);
2233
- }
2234
- }, false);
2235
-
2236
- function getScrollContainer() {
2237
- if (document.querySelector('.taro-tabbar__tabbar') === null) {
2238
- // 没设置tabbar
2239
- return window;
2240
- } else {
2241
- // 有设置tabbar
2242
- return document.querySelector('.taro-tabbar__panel') || window;
2243
- }
2244
- }
2245
-
2246
- function getOffset() {
2247
- if (pageDOM instanceof Window) {
2248
- return document.documentElement.scrollHeight - window.scrollY - window.innerHeight;
2249
- } else {
2250
- return pageDOM.scrollHeight - pageDOM.scrollTop - pageDOM.clientHeight;
2251
- }
2252
- }
2127
+ UniversalRouter.pathToRegexp = pathToRegexp_1;
2253
2128
 
2254
2129
  function createCommonjsModule$1(fn, module) {
2255
2130
  return module = {
@@ -2819,137 +2694,468 @@ var queryString_4 = queryString.parseUrl;
2819
2694
  var queryString_5 = queryString.stringifyUrl;
2820
2695
  var queryString_6 = queryString.pick;
2821
2696
  var queryString_7 = queryString.exclude;
2697
+ var pageScrollFn;
2698
+ var pageDOM = window;
2822
2699
 
2823
- function getSearch() {
2824
- var search = '?';
2700
+ function bindPageScroll(page, config) {
2701
+ pageDOM.removeEventListener('scroll', pageScrollFn);
2702
+ pageDOM = getScrollContainer();
2703
+ var distance = config.onReachBottomDistance || 50;
2704
+ var isReachBottom = false;
2825
2705
 
2826
- if (routerConfig.router.mode === 'hash') {
2827
- var idx = location.hash.indexOf('?');
2706
+ pageScrollFn = function pageScrollFn() {
2707
+ page.onPageScroll && page.onPageScroll({
2708
+ scrollTop: pageDOM instanceof Window ? window.scrollY : pageDOM.scrollTop
2709
+ });
2828
2710
 
2829
- if (idx > -1) {
2830
- search = location.hash.slice(idx);
2711
+ if (isReachBottom && getOffset() > distance) {
2712
+ isReachBottom = false;
2831
2713
  }
2832
- } else {
2833
- search = location.search;
2834
- }
2835
2714
 
2836
- return search.substr(1);
2715
+ if (page.onReachBottom && !isReachBottom && getOffset() < distance) {
2716
+ isReachBottom = true;
2717
+ page.onReachBottom();
2718
+ }
2719
+ };
2720
+
2721
+ pageDOM.addEventListener('scroll', pageScrollFn, false);
2837
2722
  }
2838
2723
 
2839
- var qs = function qs() {
2840
- var stamp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2841
- var search = getSearch();
2842
- var query = search ? queryString.parse(search) : {};
2724
+ window.addEventListener('DOMSubtreeModified', function (e) {
2725
+ var target = e.target;
2726
+ var className = target === null || target === void 0 ? void 0 : target.className;
2843
2727
 
2844
- if (stamp) {
2845
- query.stamp = stamp.toString();
2728
+ if (className && /taro_page/.test(className)) {
2729
+ pageDOM.removeEventListener('scroll', pageScrollFn);
2730
+ pageDOM = getScrollContainer();
2731
+ pageDOM.addEventListener('scroll', pageScrollFn, false);
2846
2732
  }
2733
+ }, false);
2847
2734
 
2848
- return query;
2849
- };
2850
- /* eslint-disable dot-notation */
2735
+ function getScrollContainer() {
2736
+ var _a;
2851
2737
 
2738
+ var id = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path;
2739
+ var el = id ? document.getElementById(id) : document.querySelector('.taro_page') || document.querySelector('.taro_router');
2740
+ return el || window;
2741
+ }
2852
2742
 
2853
- function pageOnReady(page) {
2854
- var onLoad = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2743
+ function getOffset() {
2744
+ if (pageDOM instanceof Window) {
2745
+ return document.documentElement.scrollHeight - window.scrollY - window.innerHeight;
2746
+ } else {
2747
+ return pageDOM.scrollHeight - pageDOM.scrollTop - pageDOM.clientHeight;
2748
+ }
2749
+ }
2750
+ /**
2751
+ * 插入页面动画需要的样式
2752
+ */
2855
2753
 
2856
- var _a, _b;
2857
2754
 
2858
- var pageEl = document.getElementById(page.path);
2755
+ function loadAnimateStyle() {
2756
+ var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 300;
2757
+ var css = "\n.taro_router .taro_page {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n transform: translate3d(100%, 0, 0);\n transition: transform ".concat(ms, "ms;\n}\n\n.taro_router .taro_page.taro_tabbar_page {\n transform: none;\n}\n\n.taro_router .taro_page.taro_page_show {\n transform: translate3d(0, 0, 0);\n}");
2758
+ var style = document.createElement('style');
2759
+ style.innerHTML = css;
2760
+ document.getElementsByTagName('head')[0].appendChild(style);
2761
+ } // @ts-nocheck
2859
2762
 
2860
- if (pageEl && !(pageEl === null || pageEl === void 0 ? void 0 : pageEl['__isReady'])) {
2861
- var el = pageEl.firstElementChild;
2862
- (_b = (_a = el === null || el === void 0 ? void 0 : el['componentOnReady']) === null || _a === void 0 ? void 0 : _a.call(el)) === null || _b === void 0 ? void 0 : _b.then(function () {
2863
- requestAnimationFrame(function () {
2864
- page.onReady();
2865
- pageEl['__isReady'] = true;
2866
- });
2867
- });
2868
- onLoad && (pageEl['__page'] = page);
2869
- }
2870
- }
2871
2763
 
2872
- function loadPage(page) {
2873
- var pageConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2874
- var stacksIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2875
- if (!page) return;
2876
- var pageEl = document.getElementById(page.path);
2764
+ function initTabbar(config) {
2765
+ if (config.tabBar == null) {
2766
+ return;
2767
+ } // TODO: custom-tab-bar
2768
+
2769
+
2770
+ var tabbar = document.createElement('taro-tabbar');
2771
+ var homePage = config.entryPagePath || (config.pages ? config.pages[0] : '');
2772
+ tabbar.conf = config.tabBar;
2773
+ tabbar.conf.homePage = history.location.pathname === '/' ? homePage : history.location.pathname;
2774
+ var routerConfig = config.router;
2775
+ tabbar.conf.mode = routerConfig && routerConfig.mode ? routerConfig.mode : 'hash';
2877
2776
 
2878
- if (pageEl) {
2879
- pageEl.style.display = 'block';
2777
+ if (routerConfig.customRoutes) {
2778
+ tabbar.conf.custom = true;
2779
+ tabbar.conf.customRoutes = routerConfig.customRoutes;
2880
2780
  } else {
2881
- page.onLoad(qs(stacksIndex), function () {
2882
- return pageOnReady(page, true);
2883
- });
2781
+ tabbar.conf.custom = false;
2782
+ tabbar.conf.customRoutes = {};
2884
2783
  }
2885
2784
 
2886
- stacks.push(page);
2887
- page.onShow();
2888
- bindPageScroll(page, pageConfig);
2785
+ if (typeof routerConfig.basename !== 'undefined') {
2786
+ tabbar.conf.basename = routerConfig.basename;
2787
+ }
2788
+
2789
+ var container = document.getElementById('container');
2790
+ container === null || container === void 0 ? void 0 : container.appendChild(tabbar);
2791
+ initTabBarApis$1(config);
2889
2792
  }
2890
2793
 
2891
- function unloadPage(page) {
2892
- var delta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
2893
- if (!page) return;
2894
- stacks.delta = --delta;
2895
- stacks.pop();
2896
- page.onUnload();
2897
- if (delta >= 1) unloadPage(stacks.last, delta);
2794
+ function setDisplay(el) {
2795
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2796
+
2797
+ if (el) {
2798
+ el.style.display = type;
2799
+ }
2898
2800
  }
2899
2801
 
2900
- function showPage(page) {
2901
- var pageConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2902
- var stacksIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2903
- if (!page) return;
2904
- page.onShow();
2905
- var pageEl = document.getElementById(page.path);
2802
+ var PageHandler = /*#__PURE__*/function () {
2803
+ function PageHandler(config) {
2804
+ _classCallCheck$1(this, PageHandler);
2906
2805
 
2907
- if (pageEl) {
2908
- pageEl.style.display = 'block';
2909
- } else {
2910
- page.onLoad(qs(stacksIndex), function () {
2911
- return pageOnReady(page, false);
2912
- });
2806
+ this.defaultAnimation = {
2807
+ duration: 300,
2808
+ delay: 50
2809
+ };
2810
+ this.config = config;
2811
+ this.mount();
2913
2812
  }
2914
2813
 
2915
- bindPageScroll(page, pageConfig);
2916
- }
2814
+ _createClass$1(PageHandler, [{
2815
+ key: "appId",
2816
+ get: function get() {
2817
+ return 'app';
2818
+ }
2819
+ }, {
2820
+ key: "router",
2821
+ get: function get() {
2822
+ return this.config.router;
2823
+ }
2824
+ }, {
2825
+ key: "routerMode",
2826
+ get: function get() {
2827
+ return this.router.mode || 'hash';
2828
+ }
2829
+ }, {
2830
+ key: "customRoutes",
2831
+ get: function get() {
2832
+ return this.router.customRoutes || {};
2833
+ }
2834
+ }, {
2835
+ key: "routes",
2836
+ get: function get() {
2837
+ return this.config.routes;
2838
+ }
2839
+ }, {
2840
+ key: "tabBarList",
2841
+ get: function get() {
2842
+ var _a;
2917
2843
 
2918
- function hidePage(page) {
2919
- if (!page) return; // NOTE: 修复多页并发问题,此处可能因为路由跳转过快,执行时页面可能还没有创建成功
2844
+ return ((_a = this.config.tabBar) === null || _a === void 0 ? void 0 : _a.list) || [];
2845
+ }
2846
+ }, {
2847
+ key: "PullDownRefresh",
2848
+ get: function get() {
2849
+ return this.config.PullDownRefresh;
2850
+ }
2851
+ }, {
2852
+ key: "animation",
2853
+ get: function get() {
2854
+ var _a, _b;
2920
2855
 
2921
- var pageEl = document.getElementById(page.path);
2856
+ return (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.animation) !== null && _b !== void 0 ? _b : this.defaultAnimation;
2857
+ }
2858
+ }, {
2859
+ key: "animationDelay",
2860
+ get: function get() {
2861
+ var _a;
2922
2862
 
2923
- if (pageEl) {
2924
- pageEl.style.display = 'none';
2925
- page.onHide();
2926
- } else {
2927
- setTimeout(function () {
2928
- return hidePage(page);
2929
- }, 0);
2930
- }
2931
- }
2863
+ return _typeof$1(this.animation) === 'object' ? this.animation.delay : this.animation ? (_a = this.defaultAnimation) === null || _a === void 0 ? void 0 : _a.delay : 0;
2864
+ }
2865
+ }, {
2866
+ key: "animationDuration",
2867
+ get: function get() {
2868
+ var _a;
2869
+
2870
+ return _typeof$1(this.animation) === 'object' ? this.animation.duration : this.animation ? (_a = this.defaultAnimation) === null || _a === void 0 ? void 0 : _a.duration : 0;
2871
+ }
2872
+ }, {
2873
+ key: "pathname",
2874
+ get: function get() {
2875
+ return this.router.pathname;
2876
+ },
2877
+ set: function set(p) {
2878
+ this.router.pathname = p;
2879
+ }
2880
+ }, {
2881
+ key: "basename",
2882
+ get: function get() {
2883
+ return this.router.basename || '';
2884
+ }
2885
+ }, {
2886
+ key: "pageConfig",
2887
+ get: function get() {
2888
+ var _this4 = this;
2889
+
2890
+ return this.routes.find(function (r) {
2891
+ var _a;
2892
+
2893
+ var routePath = stripBasename(_this4.pathname, _this4.basename);
2894
+ var pagePath = addLeadingSlash(r.path);
2895
+ return pagePath === routePath || ((_a = routesAlias.getConfig(pagePath)) === null || _a === void 0 ? void 0 : _a.includes(routePath));
2896
+ });
2897
+ }
2898
+ }, {
2899
+ key: "isTabBar",
2900
+ get: function get() {
2901
+ var _a;
2902
+
2903
+ var routePath = stripBasename(this.pathname, this.basename);
2904
+ var pagePath = ((_a = Object.entries(this.customRoutes).find(function (_ref) {
2905
+ var _ref2 = _slicedToArray(_ref, 2),
2906
+ target = _ref2[1];
2907
+
2908
+ if (typeof target === 'string') {
2909
+ return target === routePath;
2910
+ } else if ((target === null || target === void 0 ? void 0 : target.length) > 0) {
2911
+ return target.includes(routePath);
2912
+ }
2913
+
2914
+ return false;
2915
+ })) === null || _a === void 0 ? void 0 : _a[0]) || routePath;
2916
+ return !!pagePath && this.tabBarList.some(function (t) {
2917
+ return t.pagePath === pagePath;
2918
+ });
2919
+ }
2920
+ }, {
2921
+ key: "isSamePage",
2922
+ value: function isSamePage(page) {
2923
+ var routePath = stripBasename(this.pathname, this.basename);
2924
+ var pagePath = stripBasename(page === null || page === void 0 ? void 0 : page.path, this.basename);
2925
+ return pagePath.startsWith(routePath + '?');
2926
+ }
2927
+ }, {
2928
+ key: "search",
2929
+ get: function get() {
2930
+ var search = '?';
2931
+
2932
+ if (this.routerMode) {
2933
+ var idx = location.hash.indexOf('?');
2934
+
2935
+ if (idx > -1) {
2936
+ search = location.hash.slice(idx);
2937
+ }
2938
+ } else {
2939
+ search = location.search;
2940
+ }
2941
+
2942
+ return search.substr(1);
2943
+ }
2944
+ }, {
2945
+ key: "getQuery",
2946
+ value: function getQuery() {
2947
+ var stamp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2948
+ var search = this.search;
2949
+ var query = search ? queryString.parse(search) : {};
2950
+
2951
+ if (stamp) {
2952
+ query.stamp = stamp.toString();
2953
+ }
2954
+
2955
+ return query;
2956
+ }
2957
+ }, {
2958
+ key: "mount",
2959
+ value: function mount() {
2960
+ var _a;
2961
+
2962
+ setHistoryMode(this.routerMode, this.router.basename);
2963
+ (_a = document.getElementById('app')) === null || _a === void 0 ? void 0 : _a.remove();
2964
+ this.animation && loadAnimateStyle(this.animationDuration);
2965
+ var app = document.createElement('div');
2966
+ app.id = this.appId;
2967
+ app.classList.add('taro_router');
2968
+
2969
+ if (this.tabBarList.length > 1) {
2970
+ var _container = document.createElement('div');
2971
+
2972
+ _container.classList.add('taro-tabbar__container');
2973
+
2974
+ _container.id = 'container';
2975
+ var panel = document.createElement('div');
2976
+ panel.classList.add('taro-tabbar__panel');
2977
+ panel.appendChild(app);
2978
+
2979
+ _container.appendChild(panel);
2980
+
2981
+ document.body.appendChild(_container);
2982
+ initTabbar(this.config);
2983
+ } else {
2984
+ document.body.appendChild(app);
2985
+ }
2986
+ }
2987
+ }, {
2988
+ key: "onReady",
2989
+ value: function onReady(page) {
2990
+ var onLoad = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2991
+
2992
+ var _a, _b;
2993
+
2994
+ var pageEl = document.getElementById(page.path);
2995
+
2996
+ if (pageEl && !(pageEl === null || pageEl === void 0 ? void 0 : pageEl['__isReady'])) {
2997
+ var el = pageEl.firstElementChild;
2998
+ (_b = (_a = el === null || el === void 0 ? void 0 : el['componentOnReady']) === null || _a === void 0 ? void 0 : _a.call(el)) === null || _b === void 0 ? void 0 : _b.then(function () {
2999
+ requestAnimationFrame(function () {
3000
+ page.onReady();
3001
+ pageEl['__isReady'] = true;
3002
+ });
3003
+ });
3004
+ onLoad && (pageEl['__page'] = page);
3005
+ }
3006
+ }
3007
+ }, {
3008
+ key: "load",
3009
+ value: function load(page) {
3010
+ var _this5 = this;
3011
+
3012
+ var pageConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3013
+ var stacksIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
3014
+ if (!page) return;
3015
+ var pageEl = document.getElementById(page.path);
3016
+
3017
+ if (pageEl) {
3018
+ setDisplay(pageEl);
3019
+ this.isTabBar && pageEl.classList.add('taro_tabbar_page');
3020
+ this.addAnimation(pageEl, stacksIndex === 0);
3021
+ } else {
3022
+ page.onLoad(this.getQuery(stacksIndex), function () {
3023
+ pageEl = document.getElementById(page.path);
3024
+ _this5.isTabBar && (pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.add('taro_tabbar_page'));
3025
+
3026
+ _this5.addAnimation(pageEl, stacksIndex === 0);
3027
+
3028
+ _this5.onReady(page, true);
3029
+ });
3030
+ }
3031
+
3032
+ stacks.push(page);
3033
+ page.onShow();
3034
+ bindPageScroll(page, pageConfig);
3035
+ }
3036
+ }, {
3037
+ key: "unload",
3038
+ value: function unload(page) {
3039
+ var _this6 = this;
3040
+
3041
+ var delta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
3042
+ var top = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3043
+
3044
+ var _a;
3045
+
3046
+ if (!page) return;
3047
+ stacks.delta = --delta;
3048
+ stacks.pop();
3049
+
3050
+ if (this.animation && top) {
3051
+ if (this.unloadTimer) {
3052
+ clearTimeout(this.unloadTimer);
3053
+ (_a = this.lastUnloadPage) === null || _a === void 0 ? void 0 : _a.onUnload();
3054
+ this.unloadTimer = null;
3055
+ }
3056
+
3057
+ this.lastUnloadPage = page;
3058
+ var pageEl = document.getElementById(page.path);
3059
+ pageEl === null || pageEl === void 0 ? void 0 : pageEl.classList.remove('taro_page_show');
3060
+ this.unloadTimer = setTimeout(function () {
3061
+ var _a;
3062
+
3063
+ _this6.unloadTimer = null;
3064
+ (_a = _this6.lastUnloadPage) === null || _a === void 0 ? void 0 : _a.onUnload();
3065
+ }, this.animationDuration);
3066
+ }
3067
+
3068
+ if (delta >= 1) this.unload(stacks.last, delta);
3069
+ }
3070
+ }, {
3071
+ key: "show",
3072
+ value: function show(page) {
3073
+ var _this7 = this;
3074
+
3075
+ var pageConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3076
+ var stacksIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
3077
+ if (!page) return;
3078
+ page.onShow();
3079
+ var pageEl = document.getElementById(page.path);
3080
+
3081
+ if (pageEl) {
3082
+ setDisplay(pageEl);
3083
+ this.addAnimation(pageEl, stacksIndex === 0);
3084
+ } else {
3085
+ page.onLoad(this.getQuery(stacksIndex), function () {
3086
+ pageEl = document.getElementById(page.path);
3087
+
3088
+ _this7.addAnimation(pageEl, stacksIndex === 0);
3089
+
3090
+ _this7.onReady(page, false);
3091
+ });
3092
+ }
3093
+
3094
+ bindPageScroll(page, pageConfig);
3095
+ }
3096
+ }, {
3097
+ key: "hide",
3098
+ value: function hide(page) {
3099
+ var _this8 = this;
3100
+
3101
+ if (!page) return; // NOTE: 修复多页并发问题,此处可能因为路由跳转过快,执行时页面可能还没有创建成功
3102
+
3103
+ var pageEl = document.getElementById(page.path);
3104
+
3105
+ if (pageEl) {
3106
+ if (this.hideTimer) {
3107
+ clearTimeout(this.hideTimer);
3108
+ this.hideTimer = null;
3109
+ setDisplay(this.lastHidePage, 'none');
3110
+ }
3111
+
3112
+ this.lastHidePage = pageEl;
3113
+ this.hideTimer = setTimeout(function () {
3114
+ _this8.hideTimer = null;
3115
+ setDisplay(_this8.lastHidePage, 'none');
3116
+ }, this.animationDelay);
3117
+ page.onHide();
3118
+ } else {
3119
+ setTimeout(function () {
3120
+ return _this8.hide(page);
3121
+ }, 0);
3122
+ }
3123
+ }
3124
+ }, {
3125
+ key: "addAnimation",
3126
+ value: function addAnimation(pageEl) {
3127
+ var first = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3128
+ if (!pageEl) return;
3129
+
3130
+ if (this.animation && !first) {
3131
+ setTimeout(function () {
3132
+ pageEl.classList.add('taro_page_show');
3133
+ }, this.animationDelay);
3134
+ } else {
3135
+ pageEl.classList.add('taro_page_show');
3136
+ }
3137
+ }
3138
+ }]);
3139
+
3140
+ return PageHandler;
3141
+ }();
2932
3142
  /* eslint-disable dot-notation */
2933
3143
 
2934
3144
 
2935
3145
  function createRouter(app, config, framework) {
2936
3146
  var _a;
2937
3147
 
2938
- init(config);
2939
- var routes = [];
3148
+ var handler = new PageHandler(config);
2940
3149
  var runtimeHooks = container.get(SERVICE_IDENTIFIER.Hooks);
2941
- routesAlias.set(config.router.customRoutes);
2942
-
2943
- for (var i = 0; i < config.routes.length; i++) {
2944
- var route = config.routes[i];
2945
- var path = addLeadingSlash(route.path);
2946
- routes.push({
2947
- path: routesAlias.getAll(path),
3150
+ routesAlias.set(handler.router.customRoutes);
3151
+ var basename = handler.router.basename;
3152
+ var routes = handler.routes.map(function (route) {
3153
+ return {
3154
+ path: routesAlias.getAll(addLeadingSlash(route.path)),
2948
3155
  action: route.load
2949
- });
2950
- }
2951
-
2952
- var basename = config.router.basename;
3156
+ };
3157
+ });
3158
+ var entryPagePath = config.entryPagePath || ((_a = routes[0].path) === null || _a === void 0 ? void 0 : _a[0]);
2953
3159
  var router = new UniversalRouter(routes, {
2954
3160
  baseUrl: basename || ''
2955
3161
  });
@@ -2964,10 +3170,10 @@ function createRouter(app, config, framework) {
2964
3170
  switch (_context.prev = _context.next) {
2965
3171
  case 0:
2966
3172
  location = _ref3.location, action = _ref3.action;
2967
- routerConfig.router.pathname = location.pathname;
3173
+ handler.pathname = location.pathname;
2968
3174
  _context.prev = 2;
2969
3175
  _context.next = 5;
2970
- return router.resolve(config.router.forcePath || location.pathname);
3176
+ return router.resolve(handler.router.forcePath || handler.pathname);
2971
3177
 
2972
3178
  case 5:
2973
3179
  element = _context.sent;
@@ -2984,7 +3190,7 @@ function createRouter(app, config, framework) {
2984
3190
  }
2985
3191
 
2986
3192
  (_a = app.onPageNotFound) === null || _a === void 0 ? void 0 : _a.call(app, {
2987
- path: location.pathname
3193
+ path: handler.pathname
2988
3194
  });
2989
3195
  _context.next = 15;
2990
3196
  break;
@@ -3001,17 +3207,11 @@ function createRouter(app, config, framework) {
3001
3207
  return _context.abrupt("return");
3002
3208
 
3003
3209
  case 17:
3004
- pageConfig = config.routes.find(function (r) {
3005
- var _a;
3006
-
3007
- var path = addLeadingSlash(r.path);
3008
- var urlPath = stripBasename(location.pathname, routerConfig.router.basename);
3009
- return path === urlPath || ((_a = routesAlias.getConfig(path)) === null || _a === void 0 ? void 0 : _a.includes(urlPath));
3010
- });
3210
+ pageConfig = handler.pageConfig;
3011
3211
  enablePullDownRefresh = false;
3012
3212
  eventCenter$1.trigger('__taroRouterChange', {
3013
3213
  toLocation: {
3014
- path: location.pathname
3214
+ path: handler.pathname
3015
3215
  }
3016
3216
  });
3017
3217
 
@@ -3021,7 +3221,7 @@ function createRouter(app, config, framework) {
3021
3221
  }
3022
3222
 
3023
3223
  currentPage = Current$1.page;
3024
- pathname = location.pathname;
3224
+ pathname = handler.pathname;
3025
3225
  shouldLoad = false;
3026
3226
 
3027
3227
  if (!(action === 'POP')) {
@@ -3032,64 +3232,60 @@ function createRouter(app, config, framework) {
3032
3232
  // NOTE: 浏览器事件退后多次时,该事件只会被触发一次
3033
3233
  prevIndex = stacks.getPrevIndex(pathname);
3034
3234
  delta = stacks.getDelta(pathname);
3035
- unloadPage(currentPage, delta);
3235
+ handler.unload(currentPage, delta, prevIndex > -1);
3036
3236
 
3037
3237
  if (prevIndex > -1) {
3038
- showPage(stacks.getItem(prevIndex), pageConfig, prevIndex);
3238
+ handler.show(stacks.getItem(prevIndex), pageConfig, prevIndex);
3039
3239
  } else {
3040
3240
  shouldLoad = true;
3041
3241
  }
3042
3242
 
3043
- _context.next = 47;
3243
+ _context.next = 42;
3044
3244
  break;
3045
3245
 
3046
3246
  case 31:
3047
- if (!(action === 'PUSH')) {
3048
- _context.next = 36;
3247
+ if (!handler.isTabBar) {
3248
+ _context.next = 40;
3049
3249
  break;
3050
3250
  }
3051
3251
 
3052
- hidePage(currentPage);
3053
- shouldLoad = true;
3054
- _context.next = 47;
3055
- break;
3056
-
3057
- case 36:
3058
- if (!(action === 'REPLACE')) {
3059
- _context.next = 47;
3252
+ if (!handler.isSamePage(currentPage)) {
3253
+ _context.next = 34;
3060
3254
  break;
3061
3255
  }
3062
3256
 
3063
- if (!isTabBar(config)) {
3064
- _context.next = 44;
3065
- break;
3066
- }
3257
+ return _context.abrupt("return");
3067
3258
 
3068
- hidePage(currentPage);
3069
- _prevIndex = stacks.getPrevIndex(pathname);
3259
+ case 34:
3260
+ _prevIndex = stacks.getPrevIndex(pathname, 0);
3261
+ handler.hide(currentPage);
3070
3262
 
3071
3263
  if (!(_prevIndex > -1)) {
3072
- _context.next = 42;
3264
+ _context.next = 38;
3073
3265
  break;
3074
3266
  }
3075
3267
 
3076
- return _context.abrupt("return", showPage(stacks.getItem(_prevIndex), pageConfig, _prevIndex));
3268
+ return _context.abrupt("return", handler.show(stacks.getItem(_prevIndex), pageConfig, _prevIndex));
3077
3269
 
3078
- case 42:
3079
- _context.next = 46;
3270
+ case 38:
3271
+ _context.next = 41;
3080
3272
  break;
3081
3273
 
3082
- case 44:
3083
- _delta = stacks.getDelta(pathname); // NOTE: 页面路由记录并不会清空,只是移除掉缓存的 stack 以及页面
3274
+ case 40:
3275
+ if (action === 'REPLACE') {
3276
+ _delta = stacks.getDelta(pathname); // NOTE: 页面路由记录并不会清空,只是移除掉缓存的 stack 以及页面
3084
3277
 
3085
- unloadPage(currentPage, _delta);
3278
+ handler.unload(currentPage, _delta);
3279
+ } else if (action === 'PUSH') {
3280
+ handler.hide(currentPage);
3281
+ }
3086
3282
 
3087
- case 46:
3283
+ case 41:
3088
3284
  shouldLoad = true;
3089
3285
 
3090
- case 47:
3286
+ case 42:
3091
3287
  if (!(shouldLoad || stacks.length < 1)) {
3092
- _context.next = 55;
3288
+ _context.next = 50;
3093
3289
  break;
3094
3290
  }
3095
3291
 
@@ -3098,10 +3294,10 @@ function createRouter(app, config, framework) {
3098
3294
  stacksIndex = stacks.length;
3099
3295
  delete loadConfig['path'];
3100
3296
  delete loadConfig['load'];
3101
- page = createPageConfig(enablePullDownRefresh ? (_d = runtimeHooks.createPullDownComponent) === null || _d === void 0 ? void 0 : _d.call(runtimeHooks, el, location.pathname, framework, routerConfig.PullDownRefresh) : el, pathname + stringify(qs(stacksIndex)), {}, loadConfig);
3102
- return _context.abrupt("return", loadPage(page, pageConfig, stacksIndex));
3297
+ page = createPageConfig(enablePullDownRefresh ? (_d = runtimeHooks.createPullDownComponent) === null || _d === void 0 ? void 0 : _d.call(runtimeHooks, el, location.pathname, framework, handler.PullDownRefresh) : el, pathname + stringify(handler.getQuery(stacksIndex)), {}, loadConfig);
3298
+ return _context.abrupt("return", handler.load(page, pageConfig, stacksIndex));
3103
3299
 
3104
- case 55:
3300
+ case 50:
3105
3301
  case "end":
3106
3302
  return _context.stop();
3107
3303
  }
@@ -3115,14 +3311,14 @@ function createRouter(app, config, framework) {
3115
3311
  }();
3116
3312
 
3117
3313
  if (history.location.pathname === '/') {
3118
- history.replace(prependBasename((config.entryPagePath || ((_a = routes[0].path) === null || _a === void 0 ? void 0 : _a[0])) + history.location.search));
3314
+ history.replace(prependBasename(entryPagePath + history.location.search));
3119
3315
  }
3120
3316
 
3121
3317
  render({
3122
3318
  location: history.location,
3123
3319
  action: r.Push
3124
3320
  });
3125
- app.onShow(qs(stacks.length));
3321
+ app.onShow(handler.getQuery(stacks.length));
3126
3322
  return history.listen(render);
3127
3323
  }
3128
3324
 
@@ -3253,7 +3449,7 @@ function processOpenApi(apiName, defaultOptions, formatResult = res => res, form
3253
3449
  return p;
3254
3450
  };
3255
3451
  }
3256
- const easeInOut = t => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
3452
+ const easeInOut = (t) => t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
3257
3453
  const getTimingFunc = (easeFunc, frameCnt) => {
3258
3454
  return x => {
3259
3455
  if (frameCnt <= 1) {
@@ -4501,7 +4697,9 @@ const onNetworkStatusChange = (cb) => {
4501
4697
  });
4502
4698
  });
4503
4699
  }
4504
- };
4700
+ };
4701
+ const offNetworkStatusChange = temporarilyNotSupport('offNetworkStatusChange');
4702
+ const getLocalIPAddress = temporarilyNotSupport('getLocalIPAddress');
4505
4703
 
4506
4704
  const updateWeChatApp = temporarilyNotSupport('updateWeChatApp');
4507
4705
  const getUpdateManager = temporarilyNotSupport('getUpdateManager');
@@ -4932,6 +5130,19 @@ const onBackgroundFetchData = temporarilyNotSupport('onBackgroundFetchData');
4932
5130
  const getBackgroundFetchToken = temporarilyNotSupport('getBackgroundFetchToken');
4933
5131
  const getBackgroundFetchData = temporarilyNotSupport('getBackgroundFetchData');
4934
5132
 
5133
+ function getItem(key) {
5134
+ let item;
5135
+ try {
5136
+ item = JSON.parse(localStorage.getItem(key) || '');
5137
+ }
5138
+ catch (e) { }
5139
+ if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
5140
+ return { result: true, data: item.data };
5141
+ }
5142
+ else {
5143
+ return { result: false };
5144
+ }
5145
+ }
4935
5146
  const setStorageSync = (key, data = '') => {
4936
5147
  if (typeof key !== 'string') {
4937
5148
  console.error(getParameterError({
@@ -4972,15 +5183,27 @@ const setStorage = (options) => {
4972
5183
  setStorageSync(key, data);
4973
5184
  return handle.success();
4974
5185
  };
4975
- const getStorage = (options) => {
5186
+ const revokeBufferURL = temporarilyNotSupport('revokeBufferURL');
5187
+ const removeStorageSync = (key) => {
5188
+ if (typeof key !== 'string') {
5189
+ console.error(getParameterError({
5190
+ name: 'removeStorage',
5191
+ correct: 'String',
5192
+ wrong: key
5193
+ }));
5194
+ return;
5195
+ }
5196
+ localStorage.removeItem(key);
5197
+ };
5198
+ const removeStorage = (options) => {
4976
5199
  const isObject = shouldBeObject(options);
4977
5200
  if (!isObject.flag) {
4978
- const res = { errMsg: `getStorage:fail ${isObject.msg}` };
5201
+ const res = { errMsg: `removeStorage:fail ${isObject.msg}` };
4979
5202
  console.error(res.errMsg);
4980
5203
  return Promise.reject(res);
4981
5204
  }
4982
5205
  const { key, success, fail, complete } = options;
4983
- const handle = new MethodHandler({ name: 'getStorage', success, fail, complete });
5206
+ const handle = new MethodHandler({ name: 'removeStorage', success, fail, complete });
4984
5207
  if (typeof key !== 'string') {
4985
5208
  return handle.fail({
4986
5209
  errMsg: getParameterError({
@@ -4990,15 +5213,8 @@ const getStorage = (options) => {
4990
5213
  })
4991
5214
  });
4992
5215
  }
4993
- const { result, data } = getItem(key);
4994
- if (result) {
4995
- return handle.success({ data });
4996
- }
4997
- else {
4998
- return handle.fail({
4999
- errMsg: 'data not found'
5000
- });
5001
- }
5216
+ removeStorageSync(key);
5217
+ return handle.success();
5002
5218
  };
5003
5219
  const getStorageSync = (key) => {
5004
5220
  if (typeof key !== 'string') {
@@ -5014,19 +5230,6 @@ const getStorageSync = (key) => {
5014
5230
  return res.data;
5015
5231
  return '';
5016
5232
  };
5017
- function getItem(key) {
5018
- let item;
5019
- try {
5020
- item = JSON.parse(localStorage.getItem(key) || '');
5021
- }
5022
- catch (e) { }
5023
- if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
5024
- return { result: true, data: item.data };
5025
- }
5026
- else {
5027
- return { result: false };
5028
- }
5029
- }
5030
5233
  const getStorageInfoSync = () => {
5031
5234
  const res = {
5032
5235
  keys: Object.keys(localStorage),
@@ -5039,26 +5242,15 @@ const getStorageInfo = ({ success, fail, complete } = {}) => {
5039
5242
  const handle = new MethodHandler({ name: 'getStorageInfo', success, fail, complete });
5040
5243
  return handle.success(getStorageInfoSync());
5041
5244
  };
5042
- const removeStorageSync = (key) => {
5043
- if (typeof key !== 'string') {
5044
- console.error(getParameterError({
5045
- name: 'removeStorage',
5046
- correct: 'String',
5047
- wrong: key
5048
- }));
5049
- return;
5050
- }
5051
- localStorage.removeItem(key);
5052
- };
5053
- const removeStorage = (options) => {
5245
+ const getStorage = (options) => {
5054
5246
  const isObject = shouldBeObject(options);
5055
5247
  if (!isObject.flag) {
5056
- const res = { errMsg: `removeStorage:fail ${isObject.msg}` };
5248
+ const res = { errMsg: `getStorage:fail ${isObject.msg}` };
5057
5249
  console.error(res.errMsg);
5058
5250
  return Promise.reject(res);
5059
5251
  }
5060
5252
  const { key, success, fail, complete } = options;
5061
- const handle = new MethodHandler({ name: 'removeStorage', success, fail, complete });
5253
+ const handle = new MethodHandler({ name: 'getStorage', success, fail, complete });
5062
5254
  if (typeof key !== 'string') {
5063
5255
  return handle.fail({
5064
5256
  errMsg: getParameterError({
@@ -5068,18 +5260,25 @@ const removeStorage = (options) => {
5068
5260
  })
5069
5261
  });
5070
5262
  }
5071
- removeStorageSync(key);
5072
- return handle.success();
5263
+ const { result, data } = getItem(key);
5264
+ if (result) {
5265
+ return handle.success({ data });
5266
+ }
5267
+ else {
5268
+ return handle.fail({
5269
+ errMsg: 'data not found'
5270
+ });
5271
+ }
5272
+ };
5273
+ const createBufferURL = temporarilyNotSupport('createBufferURL');
5274
+ const clearStorageSync = () => {
5275
+ localStorage.clear();
5073
5276
  };
5074
5277
  const clearStorage = ({ success, fail, complete } = {}) => {
5075
5278
  const handle = new MethodHandler({ name: 'clearStorage', success, fail, complete });
5076
- localStorage.clear();
5279
+ clearStorageSync();
5077
5280
  return handle.success();
5078
- };
5079
- const clearStorageSync = () => {
5080
- clearStorage();
5081
- };
5082
- const revokeBufferURL = temporarilyNotSupport('revokeBufferURL');
5281
+ };
5083
5282
 
5084
5283
  const CLIPBOARD_STORAGE_NAME = 'taro_clipboard';
5085
5284
  document.addEventListener('copy', () => {
@@ -5518,23 +5717,28 @@ class InnerAudioContext {
5518
5717
  this.stopStack = new CallbackManager();
5519
5718
  Taro.eventCenter.on('__taroRouterChange', () => { this.stop(); });
5520
5719
  }
5521
- set autoplay(e) { Object.defineProperty(this.Instance, 'autoplay', { value: e }); }
5720
+ set autoplay(e) { this.setProperty('autoplay', e); }
5522
5721
  get autoplay() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.autoplay) || false; }
5523
5722
  get buffered() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.buffered.length) || 0; }
5524
5723
  get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
5525
5724
  get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
5526
- set loop(e) { Object.defineProperty(this.Instance, 'loop', { value: e }); }
5725
+ set loop(e) { this.setProperty('loop', e); }
5527
5726
  get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
5528
5727
  get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || true; }
5529
- set src(e) { Object.defineProperty(this.Instance, 'src', { value: e }); }
5728
+ set src(e) { this.setProperty('src', e); }
5530
5729
  get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
5531
- set volume(e) { Object.defineProperty(this.Instance, 'volume', { value: e }); }
5730
+ set volume(e) { this.setProperty('volume', e); }
5532
5731
  get volume() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
5533
- set playbackRate(e) { Object.defineProperty(this.Instance, 'playbackRate', { value: e }); }
5732
+ set playbackRate(e) { this.setProperty('playbackRate', e); }
5534
5733
  get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
5535
5734
  get obeyMuteSwitch() { return true; }
5536
- set startTime(e) { Object.defineProperty(this.Instance, 'startTime', { value: e }); }
5735
+ set startTime(e) { this.setProperty('startTime', e); }
5537
5736
  get startTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
5737
+ setProperty(key, value) {
5738
+ if (this.Instance) {
5739
+ this.Instance[key] = value;
5740
+ }
5741
+ }
5538
5742
  }
5539
5743
  const stopVoice = temporarilyNotSupport('stopVoice');
5540
5744
  const setInnerAudioOption = temporarilyNotSupport('setInnerAudioOption');
@@ -5575,186 +5779,107 @@ class EditorContext {
5575
5779
  }
5576
5780
  }
5577
5781
 
5578
- /**
5579
- * previewImage api基于开源的React组件[react-wx-images-viewer](https://github.com/react-ld/react-wx-images-viewer)开发,感谢!
5580
- */
5581
-
5582
- /**
5583
- * 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
5584
- * @param {Object} options
5585
- * @param {Array.<string>} options.urls 需要预览的图片链接列表。2.2.3 起支持云文件ID。
5586
- * @param {string} [options.current=options.urls[0]] urls的第一张 当前显示图片的链接
5587
- * @param {function} [options.success] 接口调用成功的回调函数
5588
- * @param {function} [options.fail] 接口调用失败的回调函数
5589
- * @param {function} [options.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
5590
- */
5591
- function previewImage(_x) {
5592
- return _previewImage.apply(this, arguments);
5593
- }
5594
-
5595
- function _previewImage() {
5596
- _previewImage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(options) {
5597
- var container, swiper, _options$urls, urls, _options$current, current, children, i, child, currentIndex;
5598
-
5599
- return regeneratorRuntime.wrap(function _callee$(_context) {
5600
- while (1) {
5601
- switch (_context.prev = _context.next) {
5602
- case 0:
5603
- container = document.createElement('div');
5604
- container.classList.add('preview-image');
5605
- container.style.cssText = "\n position: fixed;\n top: 0;\n left: 0;\n z-index: 1050;\n width: 100%;\n height: 100%;\n overflow: hidden;\n outline: 0;\n background-color: #111;\n ";
5606
- container.addEventListener('click', function () {
5607
- container.remove();
5608
- });
5609
- swiper = document.createElement('taro-swiper-core');
5610
- swiper.full = true;
5611
- _options$urls = options.urls, urls = _options$urls === void 0 ? [] : _options$urls, _options$current = options.current, current = _options$current === void 0 ? '' : _options$current;
5612
- children = [];
5613
- _context.prev = 8;
5614
- _context.next = 11;
5615
- return Promise.all(urls.map(function (e) {
5616
- return loadImage(e, options.fail);
5617
- }));
5618
-
5619
- case 11:
5620
- children = _context.sent;
5621
- _context.next = 17;
5622
- break;
5623
-
5624
- case 14:
5625
- _context.prev = 14;
5626
- _context.t0 = _context["catch"](8);
5627
-
5628
- if (options.fail) {
5629
- options.fail(_context.t0);
5630
- }
5631
-
5632
- case 17:
5633
- for (i = 0; i < children.length; i++) {
5634
- child = children[i];
5635
- swiper.appendChild(child);
5636
- }
5637
-
5638
- currentIndex = urls.indexOf(current);
5639
- swiper.current = currentIndex;
5640
- container.appendChild(swiper);
5641
- document.body.appendChild(container);
5642
-
5643
- if (options.success) {
5644
- options.success();
5645
- }
5646
-
5647
- if (options.complete) {
5648
- options.complete();
5649
- }
5650
-
5651
- case 24:
5652
- case "end":
5653
- return _context.stop();
5654
- }
5655
- }
5656
- }, _callee, null, [[8, 14]]);
5657
- }));
5658
- return _previewImage.apply(this, arguments);
5659
- }
5660
-
5661
- function loadImage(url, fail) {
5662
- return new Promise(function (resolve) {
5663
- var item = document.createElement('taro-swiper-item-core');
5664
- item.style.cssText = "\n display: flex;\n align-items: start;\n justify-content: center;\n overflow-y: scroll;\n ";
5665
- var image = new Image();
5666
- image.style.maxWidth = '100%';
5667
- image.src = url;
5668
- var div = document.createElement('div');
5669
- div.style.cssText = "\n display: flex;\n align-items: center;\n justify-content: center;\n max-width: 100%;\n min-height: 100%;\n ";
5670
- div.appendChild(image);
5671
- item.appendChild(div); // Note: 等待图片加载完后返回,会导致轮播被卡住
5672
-
5673
- resolve(item);
5674
-
5675
- if (typeof fail === 'function') {
5676
- image.addEventListener('error', function (err) {
5677
- fail(err);
5678
- });
5679
- }
5680
- });
5681
- }
5682
-
5683
- // const ORIENTATION_MAP = {
5684
- // // up 默认方向(手机横持拍照),对应 Exif 中的 1。或无 orientation 信息。
5685
- // 1: 'up',
5686
- // // up-mirrored 同 up,但镜像翻转,对应 Exif 中的 2
5687
- // 2: 'up-mirrored',
5688
- // // down 旋转180度,对应 Exif 中的 3
5689
- // 3: 'down',
5690
- // // down-mirrored 同 down,但镜像翻转,对应 Exif 中的 4
5691
- // 4: 'down-mirrored',
5692
- // // left-mirrored 同 left,但镜像翻转,对应 Exif 中的 5
5693
- // 5: 'left-mirrored',
5694
- // // right 顺时针旋转90度,对应 Exif 中的 6
5695
- // 6: 'right',
5696
- // // right-mirrored 同 right,但镜像翻转,对应 Exif 中的 7
5697
- // 7: 'right-mirrored',
5698
- // // left 逆时针旋转90度,对应 Exif 中的 8
5699
- // 8: 'left'
5700
- // }
5701
-
5702
- /**
5703
- * @typedef {'up'|'up-mirrored'|'down'|'down-mirrored'|'left-mirrored'|'right'|'right-mirrored'|'left'} Orientation
5704
- * @typedef ImageInfo object.success 回调函数的参数
5705
- * @property {number} width 图片原始宽度,单位px。不考虑旋转。
5706
- * @property {number} height 图片原始高度,单位px。不考虑旋转。
5707
- * @property {string} path 图片的本地路径
5708
- * @property {Orientation} orientation 拍照时设备方向
5709
- * @property {string} type 图片格式
5710
- */
5711
-
5712
- /**
5713
- * 获取图片信息。网络图片需先配置download域名才能生效。
5714
- * @param {Object} object 参数
5715
- * @param {string} object.src 图片的路径,可以是相对路径、临时文件路径、存储文件路径、网络图片路径
5716
- * @param {(res: ImageInfo) => void} [object.success] 接口调用成功的回调函数
5717
- * @param {function} [object.fail] 接口调用失败的回调函数
5718
- * @param {function} [object.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
5719
- */
5720
- var getImageInfo = function getImageInfo() {
5721
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
5722
- src = _ref.src,
5723
- success = _ref.success,
5724
- fail = _ref.fail,
5725
- complete = _ref.complete;
5726
-
5727
- return new Promise(function (resolve, reject) {
5728
- var onSuccess = function onSuccess(res) {
5729
- success && success(res);
5730
- complete && complete();
5731
- resolve(res);
5732
- };
5733
-
5734
- var onError = function onError(res) {
5735
- fail && fail(res);
5736
- complete && complete();
5737
- reject(res);
5738
- };
5739
-
5740
- var image = new Image();
5741
-
5742
- image.onload = function () {
5743
- onSuccess({
5744
- errMsg: 'getImageInfo:ok',
5745
- width: image.naturalWidth,
5746
- height: image.naturalHeight
5747
- });
5748
- };
5749
-
5750
- image.onerror = function (e) {
5751
- onError({
5752
- errMsg: "getImageInfo:fail ".concat(e.message)
5753
- });
5754
- };
5782
+ const previewImage = async (options) => {
5783
+ function loadImage(url, loadFail) {
5784
+ return new Promise((resolve) => {
5785
+ const item = document.createElement('taro-swiper-item-core');
5786
+ item.style.cssText = `
5787
+ display: flex;
5788
+ align-items: start;
5789
+ justify-content: center;
5790
+ overflow-y: scroll;
5791
+ `;
5792
+ const image = new Image();
5793
+ image.style.maxWidth = '100%';
5794
+ image.src = url;
5795
+ const div = document.createElement('div');
5796
+ div.style.cssText = `
5797
+ display: flex;
5798
+ align-items: center;
5799
+ justify-content: center;
5800
+ max-width: 100%;
5801
+ min-height: 100%;
5802
+ `;
5803
+ div.appendChild(image);
5804
+ item.appendChild(div);
5805
+ resolve(item);
5806
+ if (typeof loadFail === 'function') {
5807
+ image.addEventListener('error', (err) => {
5808
+ loadFail({ errMsg: err.message });
5809
+ });
5810
+ }
5811
+ });
5812
+ }
5813
+ const isObject = shouldBeObject(options);
5814
+ if (!isObject.flag) {
5815
+ const res = { errMsg: `previewImage:fail ${isObject.msg}` };
5816
+ console.error(res.errMsg);
5817
+ return Promise.reject(res);
5818
+ }
5819
+ const { urls = [], current = '', success, fail, complete } = options;
5820
+ const handle = new MethodHandler({ name: 'previewImage', success, fail, complete });
5821
+ const container = document.createElement('div');
5822
+ container.classList.add('preview-image');
5823
+ container.style.cssText = `
5824
+ position: fixed;
5825
+ top: 0;
5826
+ left: 0;
5827
+ z-index: 1050;
5828
+ width: 100%;
5829
+ height: 100%;
5830
+ overflow: hidden;
5831
+ outline: 0;
5832
+ background-color: #111;
5833
+ `;
5834
+ container.addEventListener('click', () => {
5835
+ container.remove();
5836
+ });
5837
+ const swiper = document.createElement('taro-swiper-core');
5838
+ swiper.full = true;
5839
+ let children = [];
5840
+ try {
5841
+ children = await Promise.all(urls.map(e => loadImage(e, fail)));
5842
+ }
5843
+ catch (error) {
5844
+ return handle.fail({
5845
+ errMsg: error
5846
+ });
5847
+ }
5848
+ for (let i = 0; i < children.length; i++) {
5849
+ const child = children[i];
5850
+ swiper.appendChild(child);
5851
+ }
5852
+ const currentIndex = urls.indexOf(current);
5853
+ swiper.current = currentIndex;
5854
+ container.appendChild(swiper);
5855
+ document.body.appendChild(container);
5856
+ return handle.success();
5857
+ };
5755
5858
 
5756
- image.src = src;
5757
- });
5859
+ const getImageInfo = (options) => {
5860
+ const isObject = shouldBeObject(options);
5861
+ if (!isObject.flag) {
5862
+ const res = { errMsg: `getImageInfo:fail ${isObject.msg}` };
5863
+ console.error(res.errMsg);
5864
+ return Promise.reject(res);
5865
+ }
5866
+ const { src, success, fail, complete } = options;
5867
+ const handle = new MethodHandler({ name: 'getImageInfo', success, fail, complete });
5868
+ return new Promise((resolve, reject) => {
5869
+ const image = new Image();
5870
+ image.onload = () => {
5871
+ handle.success({
5872
+ width: image.naturalWidth,
5873
+ height: image.naturalHeight
5874
+ }, resolve);
5875
+ };
5876
+ image.onerror = (e) => {
5877
+ handle.fail({
5878
+ errMsg: e.message
5879
+ }, reject);
5880
+ };
5881
+ image.src = src;
5882
+ });
5758
5883
  };
5759
5884
 
5760
5885
  const chooseImage = function (options) {
@@ -5930,6 +6055,137 @@ const navigateToMiniProgram = temporarilyNotSupport('navigateToMiniProgram');
5930
6055
  const navigateBackMiniProgram = temporarilyNotSupport('navigateBackMiniProgram');
5931
6056
  const exitMiniProgram = temporarilyNotSupport('exitMiniProgram');
5932
6057
 
6058
+ const NETWORK_TIMEOUT = 60000;
6059
+ const XHR_STATS = {
6060
+ UNSENT: 0,
6061
+ OPENED: 1,
6062
+ HEADERS_RECEIVED: 2,
6063
+ LOADING: 3,
6064
+ DONE: 4
6065
+ };
6066
+ const setHeader = (xhr, header) => {
6067
+ let headerKey;
6068
+ for (headerKey in header) {
6069
+ xhr.setRequestHeader(headerKey, header[headerKey]);
6070
+ }
6071
+ };
6072
+ const convertObjectUrlToBlob = url => {
6073
+ return new Promise((resolve, reject) => {
6074
+ const xhr = new XMLHttpRequest();
6075
+ xhr.open('GET', url, true);
6076
+ xhr.responseType = 'blob';
6077
+ xhr.onload = function () {
6078
+ if (this.status === 200) {
6079
+ resolve(this.response);
6080
+ }
6081
+ else {
6082
+ reject({ status: this.status });
6083
+ }
6084
+ };
6085
+ xhr.send();
6086
+ });
6087
+ };
6088
+
6089
+ const createDownloadTask = ({ url, header, success, error }) => {
6090
+ let timeout;
6091
+ const apiName = 'downloadFile';
6092
+ const xhr = new XMLHttpRequest();
6093
+ const callbackManager = {
6094
+ headersReceived: new CallbackManager(),
6095
+ progressUpdate: new CallbackManager()
6096
+ };
6097
+ xhr.open('GET', url, true);
6098
+ xhr.responseType = 'blob';
6099
+ setHeader(xhr, header);
6100
+ xhr.onprogress = e => {
6101
+ const { loaded, total } = e;
6102
+ callbackManager.progressUpdate.trigger({
6103
+ progress: Math.round(loaded / total * 100),
6104
+ totalBytesWritten: loaded,
6105
+ totalBytesExpectedToWrite: total
6106
+ });
6107
+ };
6108
+ xhr.onreadystatechange = () => {
6109
+ if (xhr.readyState !== XHR_STATS.HEADERS_RECEIVED)
6110
+ return;
6111
+ callbackManager.headersReceived.trigger({
6112
+ header: xhr.getAllResponseHeaders()
6113
+ });
6114
+ };
6115
+ xhr.onload = () => {
6116
+ const response = xhr.response;
6117
+ const status = xhr.status;
6118
+ success({
6119
+ errMsg: `${apiName}:ok`,
6120
+ statusCode: status,
6121
+ tempFilePath: window.URL.createObjectURL(response)
6122
+ });
6123
+ };
6124
+ xhr.onabort = () => {
6125
+ clearTimeout(timeout);
6126
+ error({
6127
+ errMsg: `${apiName}:fail abort`
6128
+ });
6129
+ };
6130
+ xhr.onerror = (e) => {
6131
+ error({
6132
+ errMsg: `${apiName}:fail ${e.message}`
6133
+ });
6134
+ };
6135
+ const abort = () => {
6136
+ xhr.abort();
6137
+ };
6138
+ const send = () => {
6139
+ xhr.send();
6140
+ timeout = setTimeout(() => {
6141
+ xhr.onabort = null;
6142
+ xhr.onload = null;
6143
+ xhr.onprogress = null;
6144
+ xhr.onreadystatechange = null;
6145
+ xhr.onerror = null;
6146
+ abort();
6147
+ error({
6148
+ errMsg: `${apiName}:fail timeout`
6149
+ });
6150
+ }, NETWORK_TIMEOUT);
6151
+ };
6152
+ send();
6153
+ const onHeadersReceived = callbackManager.headersReceived.add;
6154
+ const offHeadersReceived = callbackManager.headersReceived.remove;
6155
+ const onProgressUpdate = callbackManager.progressUpdate.add;
6156
+ const offProgressUpdate = callbackManager.progressUpdate.remove;
6157
+ return {
6158
+ abort,
6159
+ onHeadersReceived,
6160
+ offHeadersReceived,
6161
+ onProgressUpdate,
6162
+ offProgressUpdate
6163
+ };
6164
+ };
6165
+ const downloadFile = ({ url, header, success, fail, complete }) => {
6166
+ let task;
6167
+ const result = new Promise((resolve, reject) => {
6168
+ task = createDownloadTask({
6169
+ url,
6170
+ header,
6171
+ success: res => {
6172
+ success && success(res);
6173
+ complete && complete(res);
6174
+ resolve(res);
6175
+ },
6176
+ error: res => {
6177
+ fail && fail(res);
6178
+ complete && complete(res);
6179
+ reject(res);
6180
+ }
6181
+ });
6182
+ result.headersReceive = task.onHeadersReceived;
6183
+ result.progress = task.onProgressUpdate;
6184
+ result.abort = task.abort;
6185
+ });
6186
+ return result;
6187
+ };
6188
+
5933
6189
  const stopLocalServiceDiscovery = temporarilyNotSupport('stopLocalServiceDiscovery');
5934
6190
  const startLocalServiceDiscovery = temporarilyNotSupport('startLocalServiceDiscovery');
5935
6191
  const onLocalServiceResolveFail = temporarilyNotSupport('onLocalServiceResolveFail');
@@ -7200,6 +7456,133 @@ const createTCPSocket = temporarilyNotSupport('createTCPSocket');
7200
7456
 
7201
7457
  const createUDPSocket = temporarilyNotSupport('createUDPSocket');
7202
7458
 
7459
+ const createUploadTask = ({ url, filePath, formData, name, header, timeout, fileName, success, error }) => {
7460
+ let timeoutInter;
7461
+ let formKey;
7462
+ const apiName = 'uploadFile';
7463
+ const xhr = new XMLHttpRequest();
7464
+ const form = new FormData();
7465
+ const callbackManager = {
7466
+ headersReceived: new CallbackManager(),
7467
+ progressUpdate: new CallbackManager()
7468
+ };
7469
+ xhr.open('POST', url);
7470
+ setHeader(xhr, header);
7471
+ for (formKey in formData) {
7472
+ form.append(formKey, formData[formKey]);
7473
+ }
7474
+ xhr.upload.onprogress = e => {
7475
+ const { loaded, total } = e;
7476
+ callbackManager.progressUpdate.trigger({
7477
+ progress: Math.round(loaded / total * 100),
7478
+ totalBytesSent: loaded,
7479
+ totalBytesExpectedToSent: total
7480
+ });
7481
+ };
7482
+ xhr.onreadystatechange = () => {
7483
+ if (xhr.readyState !== XHR_STATS.HEADERS_RECEIVED)
7484
+ return;
7485
+ callbackManager.headersReceived.trigger({
7486
+ header: xhr.getAllResponseHeaders()
7487
+ });
7488
+ };
7489
+ xhr.onload = () => {
7490
+ const status = xhr.status;
7491
+ clearTimeout(timeoutInter);
7492
+ success({
7493
+ errMsg: `${apiName}:ok`,
7494
+ statusCode: status,
7495
+ data: xhr.responseText || xhr.response
7496
+ });
7497
+ };
7498
+ xhr.onabort = () => {
7499
+ clearTimeout(timeoutInter);
7500
+ error({
7501
+ errMsg: `${apiName}:fail abort`
7502
+ });
7503
+ };
7504
+ xhr.onerror = (e) => {
7505
+ clearTimeout(timeoutInter);
7506
+ error({
7507
+ errMsg: `${apiName}:fail ${e.message}`
7508
+ });
7509
+ };
7510
+ const abort = () => {
7511
+ clearTimeout(timeoutInter);
7512
+ xhr.abort();
7513
+ };
7514
+ const send = () => {
7515
+ xhr.send(form);
7516
+ timeoutInter = setTimeout(() => {
7517
+ xhr.onabort = null;
7518
+ xhr.onload = null;
7519
+ xhr.upload.onprogress = null;
7520
+ xhr.onreadystatechange = null;
7521
+ xhr.onerror = null;
7522
+ abort();
7523
+ error({
7524
+ errMsg: `${apiName}:fail timeout`
7525
+ });
7526
+ }, timeout || NETWORK_TIMEOUT);
7527
+ };
7528
+ convertObjectUrlToBlob(filePath)
7529
+ .then((fileObj) => {
7530
+ if (!fileName) {
7531
+ fileName = typeof fileObj !== 'string' && fileObj.name;
7532
+ }
7533
+ form.append(name, fileObj, fileName || `file-${Date.now()}`);
7534
+ send();
7535
+ })
7536
+ .catch(e => {
7537
+ error({
7538
+ errMsg: `${apiName}:fail ${e.message}`
7539
+ });
7540
+ });
7541
+ const onHeadersReceived = callbackManager.headersReceived.add;
7542
+ const offHeadersReceived = callbackManager.headersReceived.remove;
7543
+ const onProgressUpdate = callbackManager.progressUpdate.add;
7544
+ const offProgressUpdate = callbackManager.progressUpdate.remove;
7545
+ const headersReceived = temporarilyNotSupport('UploadTask.headersReceived');
7546
+ const progress = temporarilyNotSupport('UploadTask.progress');
7547
+ return {
7548
+ abort,
7549
+ onHeadersReceived,
7550
+ offHeadersReceived,
7551
+ onProgressUpdate,
7552
+ offProgressUpdate,
7553
+ headersReceived,
7554
+ progress
7555
+ };
7556
+ };
7557
+ const uploadFile = ({ url, filePath, name, header, formData, timeout, fileName, success, fail, complete }) => {
7558
+ let task;
7559
+ const result = new Promise((resolve, reject) => {
7560
+ task = createUploadTask({
7561
+ url,
7562
+ header,
7563
+ name,
7564
+ filePath,
7565
+ formData,
7566
+ timeout,
7567
+ fileName,
7568
+ success: res => {
7569
+ success && success(res);
7570
+ complete && complete(res);
7571
+ resolve(res);
7572
+ },
7573
+ error: res => {
7574
+ fail && fail(res);
7575
+ complete && complete(res);
7576
+ reject(res);
7577
+ }
7578
+ });
7579
+ result.headersReceive = task.onHeadersReceived;
7580
+ result.progress = task.onProgressUpdate;
7581
+ result.abort = task.abort;
7582
+ });
7583
+ return result;
7584
+ };
7585
+
7203
7586
  class SocketTask {
7204
7587
  constructor(url, protocols) {
7205
7588
  if (protocols && protocols.length) {
@@ -7315,9 +7698,10 @@ function connectSocket(options) {
7315
7698
  socketTasks = socketTasks.filter(socketTask => socketTask !== this);
7316
7699
  };
7317
7700
  socketTasks.push(task);
7318
- return handle.success({
7701
+ handle.success({
7319
7702
  socketTaskId: socketsCounter++
7320
- }, resolve);
7703
+ });
7704
+ return resolve(task);
7321
7705
  });
7322
7706
  }
7323
7707
  function closeSocket() {
@@ -7430,15 +7814,15 @@ if ($detect.style['animation-name'] === 'standard') {
7430
7814
  TRANSFORM = 'transform';
7431
7815
  }
7432
7816
  else if ($detect.style['-webkit-animation-name'] === 'webkit') {
7433
- TRANSITION_END = 'webkitTransionEnd';
7817
+ TRANSITION_END = 'webkitTransitionEnd';
7434
7818
  TRANSFORM = '-webkit-transform';
7435
7819
  }
7436
7820
  else if ($detect.style['-moz-animation-name'] === 'moz') {
7437
- TRANSITION_END = 'mozTransionEnd';
7821
+ TRANSITION_END = 'mozTransitionEnd';
7438
7822
  TRANSFORM = '-moz-transform';
7439
7823
  }
7440
7824
  else if ($detect.style['-ms-animation-name'] === 'ms') {
7441
- TRANSITION_END = 'MSTransionEnd';
7825
+ TRANSITION_END = 'msTransitionEnd';
7442
7826
  TRANSFORM = '-ms-transform';
7443
7827
  }
7444
7828
  let animId = 0;
@@ -7486,8 +7870,8 @@ class Animation {
7486
7870
  setDefault(duration, delay, timingFunction, transformOrigin) {
7487
7871
  this.DEFAULT = { duration, delay, timingFunction, transformOrigin };
7488
7872
  }
7489
- matrix(a, b, c, d, e, f) {
7490
- this.transform.push(`matrix(${a}, ${b}, ${c}, ${d}, ${e}, ${f})`);
7873
+ matrix(a, b, c, d, tx, ty) {
7874
+ this.transform.push(`matrix(${a}, ${b}, ${c}, ${d}, ${tx}, ${ty})`);
7491
7875
  return this;
7492
7876
  }
7493
7877
  matrix3d(a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3, a4, b4, c4, d4) {
@@ -7499,7 +7883,12 @@ class Animation {
7499
7883
  return this;
7500
7884
  }
7501
7885
  rotate3d(x, y, z, angle) {
7502
- this.transform.push(`rotate3d(${x}, ${y}, ${z}, ${angle}deg)`);
7886
+ if (typeof y !== 'number') {
7887
+ this.transform.push(`rotate3d(${x})`);
7888
+ }
7889
+ else {
7890
+ this.transform.push(`rotate3d(${x}, ${y || 0}, ${z || 0}, ${angle || 0}deg)`);
7891
+ }
7503
7892
  return this;
7504
7893
  }
7505
7894
  rotateX(angle) {
@@ -7640,9 +8029,9 @@ class Animation {
7640
8029
  return this.createAnimationData();
7641
8030
  }
7642
8031
  }
7643
- function createAnimation(...arg) {
7644
- return new Animation(...arg);
7645
- }
8032
+ const createAnimation = (option) => {
8033
+ return new Animation(option);
8034
+ };
7646
8035
 
7647
8036
  const setBackgroundTextStyle = temporarilyNotSupport('setBackgroundTextStyle');
7648
8037
  const setBackgroundColor = temporarilyNotSupport('setBackgroundColor');
@@ -7708,27 +8097,26 @@ const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
7708
8097
  });
7709
8098
  };
7710
8099
 
7711
- let scrollFunc;
7712
8100
  let timer;
7713
8101
  const FRAME_DURATION = 17;
7714
8102
  const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success, fail, complete }) => {
8103
+ let scrollFunc;
7715
8104
  const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete });
7716
8105
  return new Promise((resolve, reject) => {
8106
+ var _a;
7717
8107
  try {
7718
8108
  if (scrollTop === undefined && !selector) {
7719
8109
  return handle.fail({
7720
8110
  errMsg: 'scrollTop" 或 "selector" 需要其之一'
7721
8111
  }, reject);
7722
8112
  }
7723
- let el;
7724
- if (document.querySelector('.taro-tabbar__tabbar') === null) {
7725
- el = window;
7726
- }
7727
- else {
7728
- el = document.querySelector('.taro-tabbar__panel') || window;
7729
- }
8113
+ const id = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path;
8114
+ const el = (id
8115
+ ? document.getElementById(id)
8116
+ : document.querySelector('.taro_page') ||
8117
+ document.querySelector('.taro_router'));
7730
8118
  if (!scrollFunc) {
7731
- if (el === window) {
8119
+ if (!el) {
7732
8120
  scrollFunc = pos => {
7733
8121
  if (pos === undefined) {
7734
8122
  return window.pageYOffset;
@@ -8126,7 +8514,11 @@ class Toast {
8126
8514
  }
8127
8515
  create(options = {}, _type = 'toast') {
8128
8516
  const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style;
8129
- const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
8517
+ const config = {
8518
+ ...this.options,
8519
+ ...options,
8520
+ _type
8521
+ };
8130
8522
  this.el = document.createElement('div');
8131
8523
  this.el.className = 'taro__toast';
8132
8524
  this.el.style.opacity = '0';
@@ -8136,17 +8528,26 @@ class Toast {
8136
8528
  this.mask.style.display = config.mask ? 'block' : 'none';
8137
8529
  this.icon = document.createElement('p');
8138
8530
  if (config.image) {
8139
- this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, imageStyle), { 'background-image': `url(${config.image})` })));
8531
+ this.icon.setAttribute('style', inlineStyle({
8532
+ ...imageStyle,
8533
+ 'background-image': `url(${config.image})`
8534
+ }));
8140
8535
  }
8141
8536
  else {
8142
8537
  const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle;
8143
- this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, iconStyle), (config.icon === 'none' ? { display: 'none' } : {}))));
8538
+ this.icon.setAttribute('style', inlineStyle({
8539
+ ...iconStyle,
8540
+ ...(config.icon === 'none' ? { display: 'none' } : {})
8541
+ }));
8144
8542
  }
8145
8543
  this.toast = document.createElement('div');
8146
- this.toast.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, toastStyle), (config.icon === 'none' ? {
8147
- 'min-height': '0',
8148
- padding: '10px 15px'
8149
- } : {}))));
8544
+ this.toast.setAttribute('style', inlineStyle({
8545
+ ...toastStyle,
8546
+ ...(config.icon === 'none' ? {
8547
+ 'min-height': '0',
8548
+ padding: '10px 15px'
8549
+ } : {})
8550
+ }));
8150
8551
  this.title = document.createElement('p');
8151
8552
  this.title.setAttribute('style', inlineStyle(textStyle));
8152
8553
  this.title.textContent = config.title;
@@ -8161,7 +8562,11 @@ class Toast {
8161
8562
  return '';
8162
8563
  }
8163
8564
  show(options = {}, _type = 'toast') {
8164
- const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
8565
+ const config = {
8566
+ ...this.options,
8567
+ ...options,
8568
+ _type
8569
+ };
8165
8570
  if (this.hideOpacityTimer)
8166
8571
  clearTimeout(this.hideOpacityTimer);
8167
8572
  if (this.hideDisplayTimer)
@@ -8170,18 +8575,27 @@ class Toast {
8170
8575
  this.mask.style.display = config.mask ? 'block' : 'none';
8171
8576
  const { toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle } = this.style;
8172
8577
  if (config.image) {
8173
- this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, imageStyle), { 'background-image': `url(${config.image})` })));
8578
+ this.icon.setAttribute('style', inlineStyle({
8579
+ ...imageStyle,
8580
+ 'background-image': `url(${config.image})`
8581
+ }));
8174
8582
  }
8175
8583
  else {
8176
8584
  if (!config.image && config.icon) {
8177
8585
  const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle;
8178
- this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, iconStyle), (config.icon === 'none' ? { display: 'none' } : {}))));
8586
+ this.icon.setAttribute('style', inlineStyle({
8587
+ ...iconStyle,
8588
+ ...(config.icon === 'none' ? { display: 'none' } : {})
8589
+ }));
8179
8590
  }
8180
8591
  }
8181
- this.toast.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, toastStyle), (config.icon === 'none' ? {
8182
- 'min-height': '0',
8183
- padding: '10px 15px'
8184
- } : {}))));
8592
+ this.toast.setAttribute('style', inlineStyle({
8593
+ ...toastStyle,
8594
+ ...(config.icon === 'none' ? {
8595
+ 'min-height': '0',
8596
+ padding: '10px 15px'
8597
+ } : {})
8598
+ }));
8185
8599
  this.el.style.display = 'block';
8186
8600
  setTimeout(() => { this.el.style.opacity = '1'; }, 0);
8187
8601
  this.type = config._type;
@@ -8265,7 +8679,10 @@ class Modal {
8265
8679
  create(options = {}) {
8266
8680
  return new Promise((resolve) => {
8267
8681
  const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style;
8268
- const config = Object.assign(Object.assign({}, this.options), options);
8682
+ const config = {
8683
+ ...this.options,
8684
+ ...options
8685
+ };
8269
8686
  this.el = document.createElement('div');
8270
8687
  this.el.className = 'taro__modal';
8271
8688
  this.el.style.opacity = '0';
@@ -8276,12 +8693,19 @@ class Modal {
8276
8693
  const modal = document.createElement('div');
8277
8694
  modal.className = 'taro-modal__content';
8278
8695
  modal.setAttribute('style', inlineStyle(modalStyle));
8279
- const titleCSS = config.title ? titleStyle : Object.assign(Object.assign({}, titleStyle), { display: 'none' });
8696
+ const titleCSS = config.title ? titleStyle : {
8697
+ ...titleStyle,
8698
+ display: 'none'
8699
+ };
8280
8700
  this.title = document.createElement('div');
8281
8701
  this.title.className = 'taro-modal__title';
8282
8702
  this.title.setAttribute('style', inlineStyle(titleCSS));
8283
8703
  this.title.textContent = config.title;
8284
- const textCSS = config.title ? textStyle : Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
8704
+ const textCSS = config.title ? textStyle : {
8705
+ ...textStyle,
8706
+ padding: '40px 20px 26px',
8707
+ color: '#353535'
8708
+ };
8285
8709
  this.text = document.createElement('div');
8286
8710
  this.text.className = 'taro-modal__text';
8287
8711
  this.text.setAttribute('style', inlineStyle(textCSS));
@@ -8289,7 +8713,11 @@ class Modal {
8289
8713
  const foot = document.createElement('div');
8290
8714
  foot.className = 'taro-modal__foot';
8291
8715
  foot.setAttribute('style', inlineStyle(footStyle));
8292
- const cancelCSS = Object.assign(Object.assign({}, btnStyle), { color: config.cancelColor, display: config.showCancel ? 'block' : 'none' });
8716
+ const cancelCSS = {
8717
+ ...btnStyle,
8718
+ color: config.cancelColor,
8719
+ display: config.showCancel ? 'block' : 'none'
8720
+ };
8293
8721
  this.cancel = document.createElement('div');
8294
8722
  this.cancel.className = 'taro-model__btn taro-model__cancel';
8295
8723
  this.cancel.setAttribute('style', inlineStyle(cancelCSS));
@@ -8320,7 +8748,10 @@ class Modal {
8320
8748
  }
8321
8749
  show(options = {}) {
8322
8750
  return new Promise((resolve) => {
8323
- const config = Object.assign(Object.assign({}, this.options), options);
8751
+ const config = {
8752
+ ...this.options,
8753
+ ...options
8754
+ };
8324
8755
  if (this.hideOpacityTimer)
8325
8756
  clearTimeout(this.hideOpacityTimer);
8326
8757
  if (this.hideDisplayTimer)
@@ -8333,7 +8764,11 @@ class Modal {
8333
8764
  }
8334
8765
  else {
8335
8766
  this.title.style.display = 'none';
8336
- const textCSS = Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
8767
+ const textCSS = {
8768
+ ...textStyle,
8769
+ padding: '40px 20px 26px',
8770
+ color: '#353535'
8771
+ };
8337
8772
  this.text.setAttribute('style', inlineStyle(textCSS));
8338
8773
  }
8339
8774
  this.text.textContent = config.content || '';
@@ -8422,7 +8857,10 @@ class ActionSheet {
8422
8857
  create(options = {}) {
8423
8858
  return new Promise((resolve) => {
8424
8859
  const { maskStyle, actionSheetStyle, menuStyle, cellStyle, cancelStyle } = this.style;
8425
- const config = Object.assign(Object.assign({}, this.options), options);
8860
+ const config = {
8861
+ ...this.options,
8862
+ ...options
8863
+ };
8426
8864
  this.lastConfig = config;
8427
8865
  this.el = document.createElement('div');
8428
8866
  this.el.className = 'taro__actionSheet';
@@ -8433,7 +8871,10 @@ class ActionSheet {
8433
8871
  this.actionSheet = document.createElement('div');
8434
8872
  this.actionSheet.setAttribute('style', inlineStyle(actionSheetStyle));
8435
8873
  this.menu = document.createElement('div');
8436
- this.menu.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, menuStyle), { color: config.itemColor })));
8874
+ this.menu.setAttribute('style', inlineStyle({
8875
+ ...menuStyle,
8876
+ color: config.itemColor
8877
+ }));
8437
8878
  this.cells = config.itemList.map((item, index) => {
8438
8879
  const cell = document.createElement('div');
8439
8880
  cell.className = 'taro-actionsheet__cell';
@@ -8471,7 +8912,10 @@ class ActionSheet {
8471
8912
  }
8472
8913
  show(options = {}) {
8473
8914
  return new Promise((resolve) => {
8474
- const config = Object.assign(Object.assign({}, this.options), options);
8915
+ const config = {
8916
+ ...this.options,
8917
+ ...options
8918
+ };
8475
8919
  this.lastConfig = config;
8476
8920
  if (this.hideOpacityTimer)
8477
8921
  clearTimeout(this.hideOpacityTimer);
@@ -8530,7 +8974,7 @@ class ActionSheet {
8530
8974
  }
8531
8975
 
8532
8976
  let status = 'default';
8533
- function init$1(doc) {
8977
+ function init(doc) {
8534
8978
  if (status === 'ready')
8535
8979
  return;
8536
8980
  const taroStyle = doc.createElement('style');
@@ -8541,14 +8985,15 @@ function init$1(doc) {
8541
8985
  const toast = new Toast();
8542
8986
  const modal = new Modal();
8543
8987
  const actionSheet = new ActionSheet();
8544
- const showToast = (options = {
8545
- title: '',
8546
- icon: 'success',
8547
- image: '',
8548
- duration: 1500,
8549
- mask: false
8550
- }) => {
8551
- init$1(document);
8988
+ const showToast = (options = { title: '' }) => {
8989
+ init(document);
8990
+ options = Object.assign({
8991
+ title: '',
8992
+ icon: 'success',
8993
+ image: '',
8994
+ duration: 1500,
8995
+ mask: false
8996
+ }, options);
8552
8997
  const { success, fail, complete } = options;
8553
8998
  const handle = new MethodHandler({ name: 'showToast', success, fail, complete });
8554
8999
  if (typeof options.title !== 'string') {
@@ -8588,11 +9033,12 @@ const hideToast = ({ success, fail, complete } = {}) => {
8588
9033
  toast.hide(0, 'toast');
8589
9034
  return handle.success();
8590
9035
  };
8591
- const showLoading = (options = {
8592
- title: '',
8593
- mask: false
8594
- }) => {
8595
- init$1(document);
9036
+ const showLoading = (options = { title: '' }) => {
9037
+ init(document);
9038
+ options = Object.assign({
9039
+ title: '',
9040
+ mask: false
9041
+ }, options);
8596
9042
  const { success, fail, complete } = options;
8597
9043
  const handle = new MethodHandler({ name: 'showLoading', success, fail, complete });
8598
9044
  const config = {
@@ -8627,16 +9073,17 @@ const hideLoading = ({ success, fail, complete } = {}) => {
8627
9073
  toast.hide(0, 'loading');
8628
9074
  return handle.success();
8629
9075
  };
8630
- const showModal = async (options = {
8631
- title: '',
8632
- content: '',
8633
- showCancel: true,
8634
- cancelText: '取消',
8635
- cancelColor: '#000000',
8636
- confirmText: '确定',
8637
- confirmColor: '#3CC51F'
8638
- }) => {
8639
- init$1(document);
9076
+ const showModal = async (options = {}) => {
9077
+ init(document);
9078
+ options = Object.assign({
9079
+ title: '',
9080
+ content: '',
9081
+ showCancel: true,
9082
+ cancelText: '取消',
9083
+ cancelColor: '#000000',
9084
+ confirmText: '确定',
9085
+ confirmColor: '#3CC51F'
9086
+ }, options);
8640
9087
  const { success, fail, complete } = options;
8641
9088
  const handle = new MethodHandler({ name: 'showModal', success, fail, complete });
8642
9089
  if (typeof options.title !== 'string') {
@@ -8718,11 +9165,12 @@ function hideModal() {
8718
9165
  return;
8719
9166
  modal.hide();
8720
9167
  }
8721
- const showActionSheet = async (options = {
8722
- itemColor: '#000000',
8723
- itemList: []
8724
- }) => {
8725
- init$1(document);
9168
+ const showActionSheet = async (options = { itemList: [] }) => {
9169
+ init(document);
9170
+ options = Object.assign({
9171
+ itemColor: '#000000',
9172
+ itemList: []
9173
+ }, options);
8726
9174
  const { success, fail, complete } = options;
8727
9175
  const handle = new MethodHandler({ name: 'showActionSheet', success, fail, complete });
8728
9176
  if (!Array.isArray(options.itemList)) {
@@ -8784,6 +9232,41 @@ const disableAlertBeforeUnload = temporarilyNotSupport('disableAlertBeforeUnload
8784
9232
 
8785
9233
  const createWorker = temporarilyNotSupport('createWorker');
8786
9234
 
9235
+ class NodesRef {
9236
+ constructor(selector, querySelectorQuery, single) {
9237
+ this.context = temporarilyNotSupport('NodesRef.context');
9238
+ this.node = temporarilyNotSupport('NodesRef.node');
9239
+ this._component = querySelectorQuery._component;
9240
+ this._selector = selector;
9241
+ this._selectorQuery = querySelectorQuery;
9242
+ this._single = single;
9243
+ }
9244
+ boundingClientRect(cb) {
9245
+ const { _selector, _component, _single, _selectorQuery } = this;
9246
+ _selectorQuery._push(_selector, _component, _single, { id: !0, dataset: !0, rect: !0, size: !0 }, cb);
9247
+ return _selectorQuery;
9248
+ }
9249
+ scrollOffset(cb) {
9250
+ const { _selector, _component, _single, _selectorQuery } = this;
9251
+ _selectorQuery._push(_selector, _component, _single, { id: !0, dataset: !0, scrollOffset: !0 }, cb);
9252
+ return _selectorQuery;
9253
+ }
9254
+ fields(fields, cb) {
9255
+ const { _selector, _component, _single, _selectorQuery } = this;
9256
+ const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [] } = fields;
9257
+ _selectorQuery._push(_selector, _component, _single, {
9258
+ id,
9259
+ dataset,
9260
+ rect,
9261
+ size,
9262
+ scrollOffset,
9263
+ properties,
9264
+ computedStyle
9265
+ }, cb);
9266
+ return _selectorQuery;
9267
+ }
9268
+ }
9269
+
8787
9270
  function filter(fields, dom, selector) {
8788
9271
  if (!dom)
8789
9272
  return null;
@@ -8921,40 +9404,6 @@ class SelectorQuery {
8921
9404
  });
8922
9405
  this._queueCb.push(callback);
8923
9406
  }
8924
- }
8925
- class NodesRef {
8926
- constructor(selector, querySelectorQuery, single) {
8927
- this.context = temporarilyNotSupport('NodesRef.context');
8928
- this.node = temporarilyNotSupport('NodesRef.node');
8929
- this._component = querySelectorQuery._component;
8930
- this._selector = selector;
8931
- this._selectorQuery = querySelectorQuery;
8932
- this._single = single;
8933
- }
8934
- boundingClientRect(cb) {
8935
- const { _selector, _component, _single, _selectorQuery } = this;
8936
- _selectorQuery._push(_selector, _component, _single, { id: !0, dataset: !0, rect: !0, size: !0 }, cb);
8937
- return _selectorQuery;
8938
- }
8939
- scrollOffset(cb) {
8940
- const { _selector, _component, _single, _selectorQuery } = this;
8941
- _selectorQuery._push(_selector, _component, _single, { id: !0, dataset: !0, scrollOffset: !0 }, cb);
8942
- return _selectorQuery;
8943
- }
8944
- fields(fields, cb) {
8945
- const { _selector, _component, _single, _selectorQuery } = this;
8946
- const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [] } = fields;
8947
- _selectorQuery._push(_selector, _component, _single, {
8948
- id,
8949
- dataset,
8950
- rect,
8951
- size,
8952
- scrollOffset,
8953
- properties,
8954
- computedStyle
8955
- }, cb);
8956
- return _selectorQuery;
8957
- }
8958
9407
  }
8959
9408
 
8960
9409
  const createSelectorQuery = () => {
@@ -9041,4 +9490,4 @@ taro.initPxTransform = initPxTransform;
9041
9490
  taro.canIUseWebp = canIUseWebp;
9042
9491
 
9043
9492
  export default taro;
9044
- export { Behavior$1 as Behavior, Current, ENV_TYPE$1 as ENV_TYPE, EditorContext, Events, Link$2 as 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, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createInterstitialAd, createLivePlayerContext, createLivePusherContext, createMapContext, createMediaAudioPlayer, createMediaContainer, createMediaRecorder, createOffscreenCanvas, createRewardedVideoAd, createRouter, createSelectorQuery, createTCPSocket, createUDPSocket, createVKSession, createVideoContext, createVideoDecoder, createWebAudioContext, createWorker, disableAlertBeforeUnload, dishClassify, drawCanvas, enableAlertBeforeUnload, eventCenter, exitMiniProgram, exitVoIPChat, faceDetect, faceVerifyForPay, getAccountInfoSync, getApp, getAvailableAudioSources, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, getBackgroundAudioManager, getBackgroundAudioPlayerState, getBackgroundFetchData, getBackgroundFetchToken, getBatteryInfo, getBatteryInfoSync, getBeacons, getBluetoothAdapterState, getBluetoothDevices, getChannelsLiveInfo, getChannelsLiveNoticeInfo, getClipboardData, getConnectedBluetoothDevices, getConnectedWifi, getCurrentInstance, getCurrentPages, getEnterOptionsSync, getEnv$1 as getEnv, getExptInfoSync, getExtConfig, getExtConfigSync, getFileInfo, getFileSystemManager, getGroupEnterInfo, getHCEState, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNFCAdapter, getNetworkType, getOpenUserInfo, getPerformance, getRandomValues, getRealtimeLogManager, getRecorderManager, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange, getSetting, getShareInfo, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSwanId, getSystemInfo, getSystemInfoSync, getUpdateManager, getUserCryptoManager, getUserInfo, getUserProfile, getVideoInfo, getWeRunData, getWifiList, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, history, imageAudit, initFaceDetect, initPxTransform, initTabBarApis, interceptors$1 as interceptors, isBluetoothDevicePaired, joinVoIPChat, loadFontFace, login, logoClassify, makeBluetoothPair, makePhoneCall, navigateBack, navigateBackMiniProgram, navigateBackSmartProgram, navigateTo, 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, 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, onPageNotFound, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onThemeChange, onUnhandledRejection, onUserCaptureScreen, onVoIPChatInterrupted, onVoIPChatMembersChanged, onVoIPChatSpeakersChanged, onVoIPChatStateChanged, onVoIPVideoMembersChanged, onWifiConnected, onWindowResize, openBluetoothAdapter, openCard, openChannelsActivity, openChannelsEvent, openChannelsLive, openCustomerServiceChat, openDocument, openEmbeddedMiniProgram, openLocation, openSetting, openVideoEditor, options, pageScrollTo, pauseBackgroundAudio, pauseVoice, plantClassify, playBackgroundAudio, playVoice, pluginLogin, preload, preloadSubPackage, previewImage, previewMedia, pxTransform, reLaunch, readBLECharacteristicValue, redirectTo, 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, switchTab, textReview, textToAudio, updateShareMenu, updateVoIPChatMuteConfig, updateWeChatApp, useAddToFavorites, useDidHide, useDidShow, useOptionMenuClick, usePageScroll, usePullDownRefresh, usePullIntercept, useReachBottom, useReady, useResize, useRouter, useShareAppMessage, useShareTimeline, useTabItemTap, useTitleClick, vibrateLong, vibrateShort, writeBLECharacteristicValue };
9493
+ export { Behavior$1 as Behavior, Current, ENV_TYPE$1 as ENV_TYPE, EditorContext, Events, Link$2 as 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, createRouter, createSelectorQuery, createTCPSocket, createUDPSocket, createVKSession, createVideoContext, createVideoDecoder, createWebAudioContext, createWorker, disableAlertBeforeUnload, dishClassify, downloadFile, drawCanvas, enableAlertBeforeUnload, eventCenter, exitMiniProgram, exitVoIPChat, faceDetect, faceVerifyForPay, getAccountInfoSync, getApp, getAvailableAudioSources, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, getBackgroundAudioManager, getBackgroundAudioPlayerState, getBackgroundFetchData, getBackgroundFetchToken, getBatteryInfo, getBatteryInfoSync, getBeacons, getBluetoothAdapterState, getBluetoothDevices, getChannelsLiveInfo, getChannelsLiveNoticeInfo, getClipboardData, getConnectedBluetoothDevices, getConnectedWifi, getCurrentInstance, getCurrentPages, getEnterOptionsSync, getEnv$1 as getEnv, getExptInfoSync, getExtConfig, getExtConfigSync, getFileInfo, getFileSystemManager, 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, getSystemInfoSync, getUpdateManager, getUserCryptoManager, getUserInfo, getUserProfile, getVideoInfo, getWeRunData, getWifiList, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, history, imageAudit, initFaceDetect, initPxTransform, initTabBarApis, interceptors$1 as interceptors, isBluetoothDevicePaired, joinVoIPChat, loadFontFace, login, logoClassify, makeBluetoothPair, makePhoneCall, navigateBack, navigateBackMiniProgram, navigateBackSmartProgram, navigateTo, 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, 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, onPageNotFound, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onThemeChange, onUnhandledRejection, onUserCaptureScreen, onVoIPChatInterrupted, onVoIPChatMembersChanged, onVoIPChatSpeakersChanged, onVoIPChatStateChanged, onVoIPVideoMembersChanged, onWifiConnected, onWindowResize, openBluetoothAdapter, openCard, openChannelsActivity, openChannelsEvent, openChannelsLive, openCustomerServiceChat, openDocument, openEmbeddedMiniProgram, openLocation, openSetting, openVideoEditor, options, pageScrollTo, pauseBackgroundAudio, pauseVoice, plantClassify, playBackgroundAudio, playVoice, pluginLogin, preload, preloadSubPackage, previewImage, previewMedia, pxTransform, reLaunch, readBLECharacteristicValue, redirectTo, 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, switchTab, textReview, textToAudio, updateShareMenu, updateVoIPChatMuteConfig, updateWeChatApp, uploadFile, useAddToFavorites, useDidHide, useDidShow, useOptionMenuClick, usePageScroll, usePullDownRefresh, usePullIntercept, useReachBottom, useReady, useResize, useRouter, useShareAppMessage, useShareTimeline, useTabItemTap, useTitleClick, vibrateLong, vibrateShort, writeBLECharacteristicValue };