@tarojs/taro-h5 3.3.11 → 3.3.12
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 +135 -71
- package/package.json +5 -5
package/dist/index.cjs.js
CHANGED
|
@@ -1244,7 +1244,7 @@ function setHistoryMode(mode) {
|
|
|
1244
1244
|
}
|
|
1245
1245
|
}
|
|
1246
1246
|
|
|
1247
|
-
function
|
|
1247
|
+
function prependBasename() {
|
|
1248
1248
|
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
1249
1249
|
return basename.replace(/\/$/, '') + '/' + url.replace(/^\//, '');
|
|
1250
1250
|
}
|
|
@@ -1286,21 +1286,44 @@ var throttle = function throttle(fn, threshold) {
|
|
|
1286
1286
|
};
|
|
1287
1287
|
};
|
|
1288
1288
|
|
|
1289
|
-
function
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
var parameters = '';
|
|
1289
|
+
var stripBasename = function stripBasename(path, basename) {
|
|
1290
|
+
return path.startsWith(basename) ? path.replace(basename, '') : path;
|
|
1291
|
+
};
|
|
1293
1292
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1293
|
+
var isTabBar = function isTabBar(config) {
|
|
1294
|
+
var _a, _b;
|
|
1295
|
+
|
|
1296
|
+
var _config$router = config.router,
|
|
1297
|
+
_config$router$custom = _config$router.customRoutes,
|
|
1298
|
+
customRoutes = _config$router$custom === void 0 ? {} : _config$router$custom,
|
|
1299
|
+
_config$router$basena = _config$router.basename,
|
|
1300
|
+
basename = _config$router$basena === void 0 ? '' : _config$router$basena,
|
|
1301
|
+
pathname = _config$router.pathname;
|
|
1302
|
+
var routePath = stripBasename(pathname, basename);
|
|
1303
|
+
var pagePath = ((_a = Object.entries(customRoutes).find(function (_ref) {
|
|
1304
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
1305
|
+
target = _ref2[1];
|
|
1306
|
+
|
|
1307
|
+
return target === routePath;
|
|
1308
|
+
})) === null || _a === void 0 ? void 0 : _a[0]) || routePath;
|
|
1309
|
+
return !!pagePath && (((_b = config.tabBar) === null || _b === void 0 ? void 0 : _b.list) || []).some(function (t) {
|
|
1310
|
+
return t.pagePath === pagePath;
|
|
1311
|
+
});
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1314
|
+
function processNavigateUrl(option) {
|
|
1315
|
+
var pathPieces = J(option.url); // 处理自定义路由
|
|
1298
1316
|
|
|
1299
1317
|
Object.keys(routesAlias).forEach(function (key) {
|
|
1300
|
-
if (addLeadingSlash(key) === addLeadingSlash(
|
|
1301
|
-
|
|
1318
|
+
if (addLeadingSlash(key) === addLeadingSlash(pathPieces.pathname)) {
|
|
1319
|
+
pathPieces.pathname = routesAlias[key];
|
|
1302
1320
|
}
|
|
1303
|
-
});
|
|
1321
|
+
}); // 处理 basename
|
|
1322
|
+
|
|
1323
|
+
pathPieces.pathname = prependBasename(pathPieces.pathname); // hack fix history v5 bug: https://github.com/remix-run/history/issues/814
|
|
1324
|
+
|
|
1325
|
+
if (!pathPieces.search) pathPieces.search = '';
|
|
1326
|
+
return pathPieces;
|
|
1304
1327
|
}
|
|
1305
1328
|
|
|
1306
1329
|
function navigate(option, method) {
|
|
@@ -1309,19 +1332,18 @@ function navigate(option, method) {
|
|
|
1309
1332
|
fail = option.fail;
|
|
1310
1333
|
var failReason;
|
|
1311
1334
|
|
|
1312
|
-
if (option.url) {
|
|
1313
|
-
processNavigateUrl(option);
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
1335
|
try {
|
|
1317
|
-
if (
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
});
|
|
1321
|
-
} else if (method === 'redirectTo') {
|
|
1322
|
-
exports.history.replace(parsePath(option.url), {
|
|
1336
|
+
if ('url' in option) {
|
|
1337
|
+
var pathPieces = processNavigateUrl(option);
|
|
1338
|
+
var state = {
|
|
1323
1339
|
timestamp: Date.now()
|
|
1324
|
-
}
|
|
1340
|
+
};
|
|
1341
|
+
|
|
1342
|
+
if (method === 'navigateTo') {
|
|
1343
|
+
exports.history.push(pathPieces, state);
|
|
1344
|
+
} else if (method === 'redirectTo') {
|
|
1345
|
+
exports.history.replace(pathPieces, state);
|
|
1346
|
+
}
|
|
1325
1347
|
} else if (method === 'navigateBack') {
|
|
1326
1348
|
setHistoryBackDelta(option.delta);
|
|
1327
1349
|
exports.history.go(-option.delta);
|
|
@@ -1368,10 +1390,12 @@ function navigateBack() {
|
|
|
1368
1390
|
}
|
|
1369
1391
|
|
|
1370
1392
|
function switchTab(option) {
|
|
1371
|
-
|
|
1393
|
+
// TODO: 清除掉所有的栈去目标页面
|
|
1394
|
+
return redirectTo(option);
|
|
1372
1395
|
}
|
|
1373
1396
|
|
|
1374
1397
|
function reLaunch(option) {
|
|
1398
|
+
// TODO: 清除掉所有的栈去目标页面
|
|
1375
1399
|
return redirectTo(option);
|
|
1376
1400
|
}
|
|
1377
1401
|
|
|
@@ -2043,6 +2067,10 @@ function initTabbar(config) {
|
|
|
2043
2067
|
tabbar.conf.customRoutes = {};
|
|
2044
2068
|
}
|
|
2045
2069
|
|
|
2070
|
+
if (typeof routerConfig.basename !== 'undefined') {
|
|
2071
|
+
tabbar.conf.basename = routerConfig.basename;
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2046
2074
|
var container = document.getElementById('container'); // eslint-disable-next-line no-unused-expressions
|
|
2047
2075
|
|
|
2048
2076
|
container === null || container === void 0 ? void 0 : container.appendChild(tabbar);
|
|
@@ -2812,14 +2840,14 @@ function createRouter(app, config, framework) {
|
|
|
2812
2840
|
});
|
|
2813
2841
|
app.onLaunch();
|
|
2814
2842
|
var render = throttle( /*#__PURE__*/function () {
|
|
2815
|
-
var
|
|
2816
|
-
var location, action, _a, _b, _c, _d,
|
|
2843
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref3) {
|
|
2844
|
+
var location, action, _a, _b, _c, _d, element, pageConfig, enablePullDownRefresh, shouldLoad, delta, prevIndex, prev, pathname, _prevIndex, _prev, el, loadConfig, _pathname, routerIndex, page;
|
|
2817
2845
|
|
|
2818
2846
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
2819
2847
|
while (1) {
|
|
2820
2848
|
switch (_context.prev = _context.next) {
|
|
2821
2849
|
case 0:
|
|
2822
|
-
location =
|
|
2850
|
+
location = _ref3.location, action = _ref3.action;
|
|
2823
2851
|
routerConfig.router.pathname = location.pathname;
|
|
2824
2852
|
_context.prev = 2;
|
|
2825
2853
|
_context.next = 5;
|
|
@@ -2875,60 +2903,96 @@ function createRouter(app, config, framework) {
|
|
|
2875
2903
|
|
|
2876
2904
|
shouldLoad = false;
|
|
2877
2905
|
|
|
2878
|
-
if (action === 'POP') {
|
|
2879
|
-
|
|
2880
|
-
|
|
2906
|
+
if (!(action === 'POP')) {
|
|
2907
|
+
_context.next = 32;
|
|
2908
|
+
break;
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
unloadPage(runtime.Current.page);
|
|
2912
|
+
delta = historyBackDelta;
|
|
2881
2913
|
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2914
|
+
while (delta-- > 1) {
|
|
2915
|
+
unloadPage(stacks.slice(-1)[0]);
|
|
2916
|
+
} // 最终必须重置为 1
|
|
2885
2917
|
|
|
2886
2918
|
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2919
|
+
setHistoryBackDelta(1);
|
|
2920
|
+
prevIndex = stacks.reduceRight(function (p, s, i) {
|
|
2921
|
+
if (p !== 0) return p;else if (s.path === location.pathname + runtime.stringify(qs(i))) return i;else return 0;
|
|
2922
|
+
}, 0);
|
|
2923
|
+
prev = stacks[prevIndex];
|
|
2892
2924
|
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
shouldLoad = true;
|
|
2897
|
-
}
|
|
2898
|
-
} else if (action === 'PUSH') {
|
|
2899
|
-
hidePage(runtime.Current.page);
|
|
2900
|
-
shouldLoad = true;
|
|
2901
|
-
} else if (action === 'REPLACE') {
|
|
2902
|
-
unloadPage(runtime.Current.page);
|
|
2925
|
+
if (prev) {
|
|
2926
|
+
showPage(prev, pageConfig, prevIndex);
|
|
2927
|
+
} else {
|
|
2903
2928
|
shouldLoad = true;
|
|
2904
2929
|
}
|
|
2905
2930
|
|
|
2931
|
+
_context.next = 49;
|
|
2932
|
+
break;
|
|
2933
|
+
|
|
2934
|
+
case 32:
|
|
2935
|
+
if (!(action === 'PUSH')) {
|
|
2936
|
+
_context.next = 37;
|
|
2937
|
+
break;
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2940
|
+
hidePage(runtime.Current.page);
|
|
2941
|
+
shouldLoad = true;
|
|
2942
|
+
_context.next = 49;
|
|
2943
|
+
break;
|
|
2944
|
+
|
|
2945
|
+
case 37:
|
|
2946
|
+
if (!(action === 'REPLACE')) {
|
|
2947
|
+
_context.next = 49;
|
|
2948
|
+
break;
|
|
2949
|
+
}
|
|
2950
|
+
|
|
2951
|
+
if (!isTabBar(config)) {
|
|
2952
|
+
_context.next = 47;
|
|
2953
|
+
break;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
hidePage(runtime.Current.page);
|
|
2957
|
+
pathname = stripBasename(config.router.pathname, basename);
|
|
2958
|
+
_prevIndex = stacks.findIndex(function (r) {
|
|
2959
|
+
var _a;
|
|
2960
|
+
|
|
2961
|
+
return ((_a = r.path) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) === pathname;
|
|
2962
|
+
});
|
|
2963
|
+
|
|
2964
|
+
if (!(_prevIndex > -1)) {
|
|
2965
|
+
_context.next = 45;
|
|
2966
|
+
break;
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
// tabbar 页且之前出现过,直接复用
|
|
2970
|
+
_prev = stacks[_prevIndex];
|
|
2971
|
+
return _context.abrupt("return", showPage(_prev, pageConfig, _prevIndex));
|
|
2972
|
+
|
|
2973
|
+
case 45:
|
|
2974
|
+
_context.next = 48;
|
|
2975
|
+
break;
|
|
2976
|
+
|
|
2977
|
+
case 47:
|
|
2978
|
+
unloadPage(runtime.Current.page);
|
|
2979
|
+
|
|
2980
|
+
case 48:
|
|
2981
|
+
shouldLoad = true;
|
|
2982
|
+
|
|
2983
|
+
case 49:
|
|
2906
2984
|
if (shouldLoad) {
|
|
2907
2985
|
el = (_c = element["default"]) !== null && _c !== void 0 ? _c : element;
|
|
2908
|
-
|
|
2909
|
-
delete
|
|
2910
|
-
delete
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
return ((_a = TabBarItem.pagePath) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) === pathname;
|
|
2916
|
-
});
|
|
2917
|
-
|
|
2918
|
-
if ((stacks === null || stacks === void 0 ? void 0 : stacks.length) > 0 && isTabBar) {
|
|
2919
|
-
routerIndex = stacks.findIndex(function (r) {
|
|
2920
|
-
var _a;
|
|
2921
|
-
|
|
2922
|
-
return ((_a = r.path) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) === pathname;
|
|
2923
|
-
});
|
|
2924
|
-
}
|
|
2925
|
-
|
|
2926
|
-
routerIndex = (routerIndex || routerIndex === 0) && routerIndex !== -1 ? routerIndex : stacks.length;
|
|
2927
|
-
page = runtime.createPageConfig(enablePullDownRefresh ? (_e = runtimeHooks.createPullDownComponent) === null || _e === void 0 ? void 0 : _e.call(runtimeHooks, el, location.pathname, framework, routerConfig.PullDownRefresh) : el, pathname + runtime.stringify(qs(routerIndex)), {}, _config);
|
|
2986
|
+
loadConfig = Object.assign({}, pageConfig);
|
|
2987
|
+
delete loadConfig['path'];
|
|
2988
|
+
delete loadConfig['load'];
|
|
2989
|
+
_pathname = stripBasename(config.router.pathname, basename);
|
|
2990
|
+
routerIndex = stacks.length;
|
|
2991
|
+
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);
|
|
2928
2992
|
loadPage(page, pageConfig, routerIndex);
|
|
2929
2993
|
}
|
|
2930
2994
|
|
|
2931
|
-
case
|
|
2995
|
+
case 50:
|
|
2932
2996
|
case "end":
|
|
2933
2997
|
return _context.stop();
|
|
2934
2998
|
}
|
|
@@ -2937,12 +3001,12 @@ function createRouter(app, config, framework) {
|
|
|
2937
3001
|
}));
|
|
2938
3002
|
|
|
2939
3003
|
return function (_x) {
|
|
2940
|
-
return
|
|
3004
|
+
return _ref4.apply(this, arguments);
|
|
2941
3005
|
};
|
|
2942
3006
|
}(), 500);
|
|
2943
3007
|
|
|
2944
3008
|
if (exports.history.location.pathname === '/') {
|
|
2945
|
-
exports.history.replace(
|
|
3009
|
+
exports.history.replace(prependBasename(routes[0].path + exports.history.location.search));
|
|
2946
3010
|
}
|
|
2947
3011
|
|
|
2948
3012
|
render({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro-h5",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.12",
|
|
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.12",
|
|
37
|
+
"@tarojs/router": "3.3.12",
|
|
38
|
+
"@tarojs/runtime": "3.3.12",
|
|
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": "0d7650ee4263efafacd87b9c8b69bb29b2a852c0"
|
|
49
49
|
}
|