@tarojs/router 4.0.0-beta.9 → 4.0.0-beta.90
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/api.js +8 -3
- package/dist/history.js +2 -1
- package/dist/index.cjs.d.ts +2 -1
- package/dist/index.cjs.js +286 -165
- package/dist/index.esm.d.ts +2 -1
- package/dist/index.esm.js +287 -167
- package/dist/index.js +3 -3
- package/dist/navigationBar.d.ts +2 -1
- package/dist/navigationBar.js +24 -7
- package/dist/router/mpa.js +10 -5
- package/dist/router/navigation-bar.d.ts +5 -1
- package/dist/router/navigation-bar.js +57 -14
- package/dist/router/spa.js +15 -4
- package/dist/style.js +47 -10
- package/dist/utils/navigate.d.ts +2 -1
- package/dist/utils/navigate.js +5 -2
- package/package.json +7 -5
- package/types/api.d.ts +5 -0
package/dist/api.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { addLeadingSlash } from '@tarojs/runtime';
|
|
3
|
+
import { EventChannel } from '@tarojs/shared';
|
|
3
4
|
import { parsePath } from 'history';
|
|
4
5
|
import { history, prependBasename } from './history.js';
|
|
5
6
|
import { RouterConfig } from './router/index.js';
|
|
6
7
|
import stacks from './router/stack.js';
|
|
7
8
|
import { routesAlias } from './utils/index.js';
|
|
8
9
|
|
|
10
|
+
const routeEvtChannel = EventChannel.routeChannel;
|
|
9
11
|
function processNavigateUrl(option) {
|
|
10
12
|
var _a;
|
|
11
13
|
const pathPieces = parsePath(option.url);
|
|
@@ -37,6 +39,10 @@ function navigate(option, method) {
|
|
|
37
39
|
const { success, complete, fail } = option;
|
|
38
40
|
const unListen = history.listen(() => {
|
|
39
41
|
const res = { errMsg: `${method}:ok` };
|
|
42
|
+
if (method === 'navigateTo') {
|
|
43
|
+
res.eventChannel = routeEvtChannel;
|
|
44
|
+
routeEvtChannel.addEvents(option.events);
|
|
45
|
+
}
|
|
40
46
|
success === null || success === void 0 ? void 0 : success(res);
|
|
41
47
|
complete === null || complete === void 0 ? void 0 : complete(res);
|
|
42
48
|
resolve(res);
|
|
@@ -48,9 +54,8 @@ function navigate(option, method) {
|
|
|
48
54
|
const state = { timestamp: Date.now() };
|
|
49
55
|
if (pathPieces.pathname) {
|
|
50
56
|
const originPath = routesAlias.getOrigin(pathPieces.pathname);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const res = { errMsg: `${method}:fail page ${pagePath} is not found` };
|
|
57
|
+
if (!RouterConfig.isPage(addLeadingSlash(originPath)) && !RouterConfig.isPage(addLeadingSlash(pathPieces.pathname))) {
|
|
58
|
+
const res = { errMsg: `${method}:fail page ${originPath} is not found` };
|
|
54
59
|
fail === null || fail === void 0 ? void 0 : fail(res);
|
|
55
60
|
complete === null || complete === void 0 ? void 0 : complete(res);
|
|
56
61
|
if (fail || complete) {
|
package/dist/history.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { addLeadingSlash } from '@tarojs/runtime';
|
|
1
2
|
import { createBrowserHistory, createHashHistory, Action } from 'history';
|
|
2
3
|
export { createBrowserHistory, createHashHistory } from 'history';
|
|
3
4
|
import { RouterConfig } from './router/index.js';
|
|
@@ -25,7 +26,7 @@ class MpaHistory {
|
|
|
25
26
|
}
|
|
26
27
|
parseUrl(to) {
|
|
27
28
|
let url = to.pathname || '';
|
|
28
|
-
if (RouterConfig.isPage(url)) {
|
|
29
|
+
if (RouterConfig.isPage(addLeadingSlash(url))) {
|
|
29
30
|
url += '.html';
|
|
30
31
|
}
|
|
31
32
|
if (to.search) {
|
package/dist/index.cjs.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ declare function setNavigationBarStyle(option: {
|
|
|
60
60
|
backgroundColor: string;
|
|
61
61
|
frontColor: string;
|
|
62
62
|
}): void;
|
|
63
|
+
declare function setNavigationBarLoading(loading: boolean): void;
|
|
63
64
|
declare function handleAppMount(config: SpaRouterConfig | MpaRouterConfig, _: History, appId?: string): void;
|
|
64
65
|
declare function handleAppMountWithTabbar(config: SpaRouterConfig | MpaRouterConfig, history: History, appId?: string): void;
|
|
65
|
-
export { navigateTo, redirectTo, navigateBack, switchTab, reLaunch, getCurrentPages, history, setHistory, createMpaHistory, createBrowserHistory, createHashHistory, setHistoryMode, prependBasename, createMultiRouter, createRouter, routesAlias, isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, handleAppMount, handleAppMountWithTabbar };
|
|
66
|
+
export { navigateTo, redirectTo, navigateBack, switchTab, reLaunch, getCurrentPages, history, setHistory, createMpaHistory, createBrowserHistory, createHashHistory, setHistoryMode, prependBasename, createMultiRouter, createRouter, routesAlias, isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, setNavigationBarLoading, handleAppMount, handleAppMountWithTabbar };
|