@tarojs/taro-h5 3.3.9 → 3.3.13
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.
- package/dist/index.cjs.js +192 -91
- package/package.json +5 -5
- package/src/api/image/previewImage.js +12 -3
- package/src/taro/index.js +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -919,7 +919,11 @@ function createBrowserHistory(b) {
|
|
|
919
919
|
|
|
920
920
|
function x(c, a) {
|
|
921
921
|
void 0 === a && (a = null);
|
|
922
|
-
return C(_extends({
|
|
922
|
+
return C(_extends({
|
|
923
|
+
pathname: q.pathname,
|
|
924
|
+
hash: "",
|
|
925
|
+
search: ""
|
|
926
|
+
}, "string" === typeof c ? J(c) : c, {
|
|
923
927
|
state: a,
|
|
924
928
|
key: H()
|
|
925
929
|
}));
|
|
@@ -1102,7 +1106,11 @@ function createHashHistory(b) {
|
|
|
1102
1106
|
|
|
1103
1107
|
function z(a, e) {
|
|
1104
1108
|
void 0 === e && (e = null);
|
|
1105
|
-
return C(_extends({
|
|
1109
|
+
return C(_extends({
|
|
1110
|
+
pathname: d.pathname,
|
|
1111
|
+
hash: "",
|
|
1112
|
+
search: ""
|
|
1113
|
+
}, "string" === typeof a ? J(a) : a, {
|
|
1106
1114
|
state: e,
|
|
1107
1115
|
key: H()
|
|
1108
1116
|
}));
|
|
@@ -1244,7 +1252,7 @@ function setHistoryMode(mode) {
|
|
|
1244
1252
|
}
|
|
1245
1253
|
}
|
|
1246
1254
|
|
|
1247
|
-
function
|
|
1255
|
+
function prependBasename() {
|
|
1248
1256
|
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
1249
1257
|
return basename.replace(/\/$/, '') + '/' + url.replace(/^\//, '');
|
|
1250
1258
|
}
|
|
@@ -1286,65 +1294,98 @@ var throttle = function throttle(fn, threshold) {
|
|
|
1286
1294
|
};
|
|
1287
1295
|
};
|
|
1288
1296
|
|
|
1289
|
-
function
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
var parameters = '';
|
|
1297
|
+
var stripBasename = function stripBasename(path, basename) {
|
|
1298
|
+
return path.startsWith(basename) ? path.replace(basename, '') : path;
|
|
1299
|
+
};
|
|
1293
1300
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1301
|
+
var isTabBar = function isTabBar(config) {
|
|
1302
|
+
var _a, _b;
|
|
1303
|
+
|
|
1304
|
+
var _config$router = config.router,
|
|
1305
|
+
_config$router$custom = _config$router.customRoutes,
|
|
1306
|
+
customRoutes = _config$router$custom === void 0 ? {} : _config$router$custom,
|
|
1307
|
+
_config$router$basena = _config$router.basename,
|
|
1308
|
+
basename = _config$router$basena === void 0 ? '' : _config$router$basena,
|
|
1309
|
+
pathname = _config$router.pathname;
|
|
1310
|
+
var routePath = stripBasename(pathname, basename);
|
|
1311
|
+
var pagePath = ((_a = Object.entries(customRoutes).find(function (_ref) {
|
|
1312
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
1313
|
+
target = _ref2[1];
|
|
1314
|
+
|
|
1315
|
+
return target === routePath;
|
|
1316
|
+
})) === null || _a === void 0 ? void 0 : _a[0]) || routePath;
|
|
1317
|
+
return !!pagePath && (((_b = config.tabBar) === null || _b === void 0 ? void 0 : _b.list) || []).some(function (t) {
|
|
1318
|
+
return t.pagePath === pagePath;
|
|
1319
|
+
});
|
|
1320
|
+
};
|
|
1321
|
+
|
|
1322
|
+
function processNavigateUrl(option) {
|
|
1323
|
+
var pathPieces = J(option.url); // 处理自定义路由
|
|
1298
1324
|
|
|
1299
1325
|
Object.keys(routesAlias).forEach(function (key) {
|
|
1300
|
-
if (addLeadingSlash(key) === addLeadingSlash(
|
|
1301
|
-
|
|
1326
|
+
if (addLeadingSlash(key) === addLeadingSlash(pathPieces.pathname)) {
|
|
1327
|
+
pathPieces.pathname = routesAlias[key];
|
|
1302
1328
|
}
|
|
1303
|
-
});
|
|
1304
|
-
}
|
|
1329
|
+
}); // 处理 basename
|
|
1305
1330
|
|
|
1306
|
-
|
|
1307
|
-
var success = option.success,
|
|
1308
|
-
complete = option.complete,
|
|
1309
|
-
fail = option.fail;
|
|
1310
|
-
var failReason;
|
|
1331
|
+
pathPieces.pathname = prependBasename(pathPieces.pathname); // hack fix history v5 bug: https://github.com/remix-run/history/issues/814
|
|
1311
1332
|
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
1314
|
-
|
|
1333
|
+
if (!pathPieces.search) pathPieces.search = '';
|
|
1334
|
+
return pathPieces;
|
|
1335
|
+
}
|
|
1315
1336
|
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
timestamp: Date.now()
|
|
1320
|
-
});
|
|
1321
|
-
} else if (method === 'redirectTo') {
|
|
1322
|
-
exports.history.replace(parsePath(option.url), {
|
|
1323
|
-
timestamp: Date.now()
|
|
1324
|
-
});
|
|
1325
|
-
} else if (method === 'navigateBack') {
|
|
1326
|
-
setHistoryBackDelta(option.delta);
|
|
1327
|
-
exports.history.go(-option.delta);
|
|
1328
|
-
}
|
|
1329
|
-
} catch (error) {
|
|
1330
|
-
failReason = error;
|
|
1331
|
-
}
|
|
1337
|
+
function navigate(_x, _x2) {
|
|
1338
|
+
return _navigate.apply(this, arguments);
|
|
1339
|
+
}
|
|
1332
1340
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1341
|
+
function _navigate() {
|
|
1342
|
+
_navigate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(option, method) {
|
|
1343
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
1344
|
+
while (1) {
|
|
1345
|
+
switch (_context2.prev = _context2.next) {
|
|
1346
|
+
case 0:
|
|
1347
|
+
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
|
1348
|
+
var success = option.success,
|
|
1349
|
+
complete = option.complete,
|
|
1350
|
+
fail = option.fail;
|
|
1351
|
+
var unListen = exports.history.listen(function () {
|
|
1352
|
+
success === null || success === void 0 ? void 0 : success();
|
|
1353
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
|
1354
|
+
resolve();
|
|
1355
|
+
unListen();
|
|
1356
|
+
});
|
|
1340
1357
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1358
|
+
try {
|
|
1359
|
+
if ('url' in option) {
|
|
1360
|
+
var pathPieces = processNavigateUrl(option);
|
|
1361
|
+
var state = {
|
|
1362
|
+
timestamp: Date.now()
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
if (method === 'navigateTo') {
|
|
1366
|
+
exports.history.push(pathPieces, state);
|
|
1367
|
+
} else if (method === 'redirectTo') {
|
|
1368
|
+
exports.history.replace(pathPieces, state);
|
|
1369
|
+
}
|
|
1370
|
+
} else if (method === 'navigateBack') {
|
|
1371
|
+
setHistoryBackDelta(option.delta);
|
|
1372
|
+
exports.history.go(-option.delta);
|
|
1373
|
+
}
|
|
1374
|
+
} catch (error) {
|
|
1375
|
+
fail === null || fail === void 0 ? void 0 : fail(error);
|
|
1376
|
+
complete === null || complete === void 0 ? void 0 : complete();
|
|
1377
|
+
reject(error);
|
|
1378
|
+
}
|
|
1379
|
+
}));
|
|
1380
|
+
|
|
1381
|
+
case 1:
|
|
1382
|
+
case "end":
|
|
1383
|
+
return _context2.stop();
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}, _callee2);
|
|
1387
|
+
}));
|
|
1388
|
+
return _navigate.apply(this, arguments);
|
|
1348
1389
|
}
|
|
1349
1390
|
|
|
1350
1391
|
function navigateTo(option) {
|
|
@@ -1368,10 +1409,12 @@ function navigateBack() {
|
|
|
1368
1409
|
}
|
|
1369
1410
|
|
|
1370
1411
|
function switchTab(option) {
|
|
1371
|
-
|
|
1412
|
+
// TODO: 清除掉所有的栈去目标页面
|
|
1413
|
+
return redirectTo(option);
|
|
1372
1414
|
}
|
|
1373
1415
|
|
|
1374
1416
|
function reLaunch(option) {
|
|
1417
|
+
// TODO: 清除掉所有的栈去目标页面
|
|
1375
1418
|
return redirectTo(option);
|
|
1376
1419
|
}
|
|
1377
1420
|
|
|
@@ -2043,6 +2086,10 @@ function initTabbar(config) {
|
|
|
2043
2086
|
tabbar.conf.customRoutes = {};
|
|
2044
2087
|
}
|
|
2045
2088
|
|
|
2089
|
+
if (typeof routerConfig.basename !== 'undefined') {
|
|
2090
|
+
tabbar.conf.basename = routerConfig.basename;
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2046
2093
|
var container = document.getElementById('container'); // eslint-disable-next-line no-unused-expressions
|
|
2047
2094
|
|
|
2048
2095
|
container === null || container === void 0 ? void 0 : container.appendChild(tabbar);
|
|
@@ -2812,14 +2859,14 @@ function createRouter(app, config, framework) {
|
|
|
2812
2859
|
});
|
|
2813
2860
|
app.onLaunch();
|
|
2814
2861
|
var render = throttle( /*#__PURE__*/function () {
|
|
2815
|
-
var
|
|
2816
|
-
var location, action, _a, _b, _c, _d, element, pageConfig, enablePullDownRefresh, shouldLoad, delta, prevIndex, prev, el,
|
|
2862
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref3) {
|
|
2863
|
+
var location, action, _a, _b, _c, _d, element, pageConfig, enablePullDownRefresh, shouldLoad, delta, prevIndex, prev, pathname, _prevIndex, _prev, el, loadConfig, _pathname, routerIndex, page;
|
|
2817
2864
|
|
|
2818
2865
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
2819
2866
|
while (1) {
|
|
2820
2867
|
switch (_context.prev = _context.next) {
|
|
2821
2868
|
case 0:
|
|
2822
|
-
location =
|
|
2869
|
+
location = _ref3.location, action = _ref3.action;
|
|
2823
2870
|
routerConfig.router.pathname = location.pathname;
|
|
2824
2871
|
_context.prev = 2;
|
|
2825
2872
|
_context.next = 5;
|
|
@@ -2875,45 +2922,96 @@ function createRouter(app, config, framework) {
|
|
|
2875
2922
|
|
|
2876
2923
|
shouldLoad = false;
|
|
2877
2924
|
|
|
2878
|
-
if (action === 'POP') {
|
|
2879
|
-
|
|
2880
|
-
|
|
2925
|
+
if (!(action === 'POP')) {
|
|
2926
|
+
_context.next = 32;
|
|
2927
|
+
break;
|
|
2928
|
+
}
|
|
2881
2929
|
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
} // 最终必须重置为 1
|
|
2930
|
+
unloadPage(runtime.Current.page);
|
|
2931
|
+
delta = historyBackDelta;
|
|
2885
2932
|
|
|
2933
|
+
while (delta-- > 1) {
|
|
2934
|
+
unloadPage(stacks.slice(-1)[0]);
|
|
2935
|
+
} // 最终必须重置为 1
|
|
2886
2936
|
|
|
2887
|
-
setHistoryBackDelta(1);
|
|
2888
|
-
prevIndex = stacks.reduceRight(function (p, s, i) {
|
|
2889
|
-
if (p !== 0) return p;else if (s.path === location.pathname + runtime.stringify(qs(i))) return i;else return 0;
|
|
2890
|
-
}, 0);
|
|
2891
|
-
prev = stacks[prevIndex];
|
|
2892
2937
|
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
} else
|
|
2902
|
-
unloadPage(runtime.Current.page);
|
|
2938
|
+
setHistoryBackDelta(1);
|
|
2939
|
+
prevIndex = stacks.reduceRight(function (p, s, i) {
|
|
2940
|
+
if (p !== 0) return p;else if (s.path === location.pathname + runtime.stringify(qs(i))) return i;else return 0;
|
|
2941
|
+
}, 0);
|
|
2942
|
+
prev = stacks[prevIndex];
|
|
2943
|
+
|
|
2944
|
+
if (prev) {
|
|
2945
|
+
showPage(prev, pageConfig, prevIndex);
|
|
2946
|
+
} else {
|
|
2903
2947
|
shouldLoad = true;
|
|
2904
2948
|
}
|
|
2905
2949
|
|
|
2950
|
+
_context.next = 49;
|
|
2951
|
+
break;
|
|
2952
|
+
|
|
2953
|
+
case 32:
|
|
2954
|
+
if (!(action === 'PUSH')) {
|
|
2955
|
+
_context.next = 37;
|
|
2956
|
+
break;
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
hidePage(runtime.Current.page);
|
|
2960
|
+
shouldLoad = true;
|
|
2961
|
+
_context.next = 49;
|
|
2962
|
+
break;
|
|
2963
|
+
|
|
2964
|
+
case 37:
|
|
2965
|
+
if (!(action === 'REPLACE')) {
|
|
2966
|
+
_context.next = 49;
|
|
2967
|
+
break;
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2970
|
+
if (!isTabBar(config)) {
|
|
2971
|
+
_context.next = 47;
|
|
2972
|
+
break;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
hidePage(runtime.Current.page);
|
|
2976
|
+
pathname = stripBasename(config.router.pathname, basename);
|
|
2977
|
+
_prevIndex = stacks.findIndex(function (r) {
|
|
2978
|
+
var _a;
|
|
2979
|
+
|
|
2980
|
+
return ((_a = r.path) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) === pathname;
|
|
2981
|
+
});
|
|
2982
|
+
|
|
2983
|
+
if (!(_prevIndex > -1)) {
|
|
2984
|
+
_context.next = 45;
|
|
2985
|
+
break;
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
// tabbar 页且之前出现过,直接复用
|
|
2989
|
+
_prev = stacks[_prevIndex];
|
|
2990
|
+
return _context.abrupt("return", showPage(_prev, pageConfig, _prevIndex));
|
|
2991
|
+
|
|
2992
|
+
case 45:
|
|
2993
|
+
_context.next = 48;
|
|
2994
|
+
break;
|
|
2995
|
+
|
|
2996
|
+
case 47:
|
|
2997
|
+
unloadPage(runtime.Current.page);
|
|
2998
|
+
|
|
2999
|
+
case 48:
|
|
3000
|
+
shouldLoad = true;
|
|
3001
|
+
|
|
3002
|
+
case 49:
|
|
2906
3003
|
if (shouldLoad) {
|
|
2907
3004
|
el = (_c = element["default"]) !== null && _c !== void 0 ? _c : element;
|
|
2908
|
-
|
|
2909
|
-
delete
|
|
2910
|
-
delete
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
3005
|
+
loadConfig = Object.assign({}, pageConfig);
|
|
3006
|
+
delete loadConfig['path'];
|
|
3007
|
+
delete loadConfig['load'];
|
|
3008
|
+
_pathname = stripBasename(config.router.pathname, basename);
|
|
3009
|
+
routerIndex = stacks.length;
|
|
3010
|
+
page = runtime.createPageConfig(enablePullDownRefresh ? (_d = runtimeHooks.createPullDownComponent) === null || _d === void 0 ? void 0 : _d.call(runtimeHooks, el, location.pathname, framework, routerConfig.PullDownRefresh) : el, _pathname + runtime.stringify(qs(routerIndex)), {}, loadConfig);
|
|
3011
|
+
loadPage(page, pageConfig, routerIndex);
|
|
2914
3012
|
}
|
|
2915
3013
|
|
|
2916
|
-
case
|
|
3014
|
+
case 50:
|
|
2917
3015
|
case "end":
|
|
2918
3016
|
return _context.stop();
|
|
2919
3017
|
}
|
|
@@ -2921,13 +3019,13 @@ function createRouter(app, config, framework) {
|
|
|
2921
3019
|
}, _callee, null, [[2, 8]]);
|
|
2922
3020
|
}));
|
|
2923
3021
|
|
|
2924
|
-
return function (
|
|
2925
|
-
return
|
|
3022
|
+
return function (_x3) {
|
|
3023
|
+
return _ref4.apply(this, arguments);
|
|
2926
3024
|
};
|
|
2927
3025
|
}(), 500);
|
|
2928
3026
|
|
|
2929
3027
|
if (exports.history.location.pathname === '/') {
|
|
2930
|
-
exports.history.replace(
|
|
3028
|
+
exports.history.replace(prependBasename(routes[0].path + exports.history.location.search));
|
|
2931
3029
|
}
|
|
2932
3030
|
|
|
2933
3031
|
render({
|
|
@@ -3276,7 +3374,7 @@ var initPxTransform = getInitPxTransform$1(taro);
|
|
|
3276
3374
|
var requirePlugin = permanentlyNotSupport('requirePlugin');
|
|
3277
3375
|
|
|
3278
3376
|
var getApp = function getApp() {
|
|
3279
|
-
return
|
|
3377
|
+
return getCurrentInstance().app;
|
|
3280
3378
|
};
|
|
3281
3379
|
|
|
3282
3380
|
var pxTransform = function pxTransform(size) {
|
|
@@ -6291,11 +6389,14 @@ function _previewImage() {
|
|
|
6291
6389
|
function loadImage(url, fail) {
|
|
6292
6390
|
return new Promise(function (resolve) {
|
|
6293
6391
|
var item = document.createElement('taro-swiper-item-core');
|
|
6294
|
-
item.style.cssText = "\n display: flex;\n align-items:
|
|
6392
|
+
item.style.cssText = "\n display: flex;\n align-items: start;\n justify-content: center;\n overflow-y: scroll;\n ";
|
|
6295
6393
|
var image = new Image();
|
|
6296
6394
|
image.style.maxWidth = '100%';
|
|
6297
6395
|
image.src = url;
|
|
6298
|
-
|
|
6396
|
+
var div = document.createElement('div');
|
|
6397
|
+
div.style.cssText = "\n display: flex;\n align-items: center;\n justify-content: center;\n max-width: 100%;\n min-height: 100%;\n ";
|
|
6398
|
+
div.appendChild(image);
|
|
6399
|
+
item.appendChild(div); // Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
6299
6400
|
|
|
6300
6401
|
resolve(item);
|
|
6301
6402
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro-h5",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.13",
|
|
4
4
|
"description": "Taro h5 framework",
|
|
5
5
|
"main:h5": "src/index.js",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"author": "O2Team",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tarojs/api": "3.3.
|
|
37
|
-
"@tarojs/router": "3.3.
|
|
38
|
-
"@tarojs/runtime": "3.3.
|
|
36
|
+
"@tarojs/api": "3.3.13",
|
|
37
|
+
"@tarojs/router": "3.3.13",
|
|
38
|
+
"@tarojs/runtime": "3.3.13",
|
|
39
39
|
"base64-js": "^1.3.0",
|
|
40
40
|
"jsonp-retry": "^1.0.3",
|
|
41
41
|
"mobile-detect": "^1.4.2",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"jest-fetch-mock": "^3.0.3"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "d84177a97cc27c01ca63c9dd07e5ab5bbaa91d8a"
|
|
49
49
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
/**
|
|
3
2
|
* 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
|
|
4
3
|
* @param {Object} options
|
|
@@ -67,13 +66,23 @@ function loadImage (url, fail) {
|
|
|
67
66
|
const item = document.createElement('taro-swiper-item-core')
|
|
68
67
|
item.style.cssText = `
|
|
69
68
|
display: flex;
|
|
70
|
-
align-items:
|
|
69
|
+
align-items: start;
|
|
71
70
|
justify-content: center;
|
|
71
|
+
overflow-y: scroll;
|
|
72
72
|
`
|
|
73
73
|
const image = new Image()
|
|
74
74
|
image.style.maxWidth = '100%'
|
|
75
75
|
image.src = url
|
|
76
|
-
|
|
76
|
+
const div = document.createElement('div')
|
|
77
|
+
div.style.cssText = `
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
max-width: 100%;
|
|
82
|
+
min-height: 100%;
|
|
83
|
+
`
|
|
84
|
+
div.appendChild(image)
|
|
85
|
+
item.appendChild(div)
|
|
77
86
|
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
78
87
|
resolve(item)
|
|
79
88
|
if (typeof fail === 'function') {
|
package/src/taro/index.js
CHANGED