@ray-js/router-mp 1.3.21 → 1.3.23
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.md +9 -0
- package/lib/Router.js +117 -165
- package/lib/RouterScheduler.d.ts +2 -2
- package/lib/RouterScheduler.js +104 -168
- package/lib/index.js +8 -11
- package/package.json +7 -7
package/LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Copyright © 2014-2022 Tuya.inc
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/lib/Router.js
CHANGED
@@ -1,186 +1,138 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
4
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
5
|
-
import "core-js/modules/es.object.to-string.js";
|
6
|
-
import "core-js/modules/es.promise.js";
|
7
|
-
import "core-js/modules/es.array.slice.js";
|
8
|
-
import "core-js/modules/es.regexp.exec.js";
|
9
|
-
import "core-js/modules/es.string.replace.js";
|
10
|
-
import "core-js/modules/es.regexp.constructor.js";
|
11
|
-
import "core-js/modules/es.regexp.dot-all.js";
|
12
|
-
import "core-js/modules/es.regexp.sticky.js";
|
13
|
-
import "core-js/modules/es.regexp.to-string.js";
|
14
2
|
import { url } from '@ray-js/library';
|
15
3
|
import { navigateBack, navigateTo, reLaunch, switchTab, redirectTo, getLaunchOptionsSync } from '@ray-js/api';
|
16
4
|
import { RouterScheduler } from './RouterScheduler';
|
17
|
-
|
18
5
|
function currentPage() {
|
19
|
-
|
20
|
-
|
6
|
+
const pages = getCurrentPages();
|
21
7
|
if (pages.length > 0) {
|
22
8
|
return pages[pages.length - 1];
|
23
9
|
} else {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
const {
|
11
|
+
path,
|
12
|
+
query
|
13
|
+
} = getLaunchOptionsSync();
|
28
14
|
return {
|
29
15
|
route: path,
|
30
16
|
options: query
|
31
17
|
};
|
32
18
|
}
|
33
19
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
20
|
+
export class Router {
|
21
|
+
// 只有作为其他小程序的子包时,才设置urlPrefix
|
22
|
+
urlPrefix = '';
|
23
|
+
|
24
|
+
/**
|
25
|
+
* setUrlPrefix
|
26
|
+
*/
|
27
|
+
setUrlPrefix(prefix) {
|
28
|
+
this.urlPrefix = prefix;
|
42
29
|
}
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
30
|
+
scheduler = new RouterScheduler();
|
31
|
+
|
32
|
+
/**
|
33
|
+
* 标准化路由路径,将 web 标准的地址栏转化到 小程序地址
|
34
|
+
*/
|
35
|
+
normalizeRoute(params) {
|
36
|
+
const {
|
37
|
+
pathname,
|
38
|
+
query,
|
39
|
+
hash
|
40
|
+
} = url.parse(params.to);
|
41
|
+
const subPackage = params.subpackage;
|
42
|
+
const matchedPage = subPackage ? this.scheduler.getMatchedSubPackagePage(pathname, subPackage) : this.scheduler.getMatchedPage(pathname);
|
43
|
+
if (!matchedPage) {
|
44
|
+
return Promise.reject(undefined);
|
45
|
+
}
|
46
|
+
// 作为其他小程序时不能作为tabBar
|
47
|
+
if (this.urlPrefix) {
|
48
|
+
matchedPage.isTabBar = false;
|
49
|
+
}
|
50
|
+
let finalPath = matchedPage.path;
|
51
|
+
// FIXME: tabBar.list里的页面不能有query,也不能有hash
|
52
|
+
if (!matchedPage.isTabBar) {
|
53
|
+
finalPath = url.format({
|
54
|
+
pathname: matchedPage.path,
|
55
|
+
query: _objectSpread(_objectSpread(_objectSpread({}, query), matchedPage.params), {}, {
|
56
|
+
// 模式匹配得到的参数,如/xxx/:id 可以匹配路径 /xxx/123 得参数id: 123
|
57
|
+
____h_a_s_h____: hash.slice(1) // 小程序中不能传递hash参数,用query辅助传递
|
58
|
+
})
|
59
|
+
});
|
52
60
|
}
|
53
|
-
}, {
|
54
|
-
key: "normalizeRoute",
|
55
|
-
value:
|
56
61
|
/**
|
57
|
-
*
|
62
|
+
* 坑点之一
|
63
|
+
* 微信小程序: app.json 里的页面配置不能以`/`开头,wx.navigatorTo 却需要
|
58
64
|
*/
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
if (!matchedPage.isTabBar) {
|
80
|
-
finalPath = url.format({
|
81
|
-
pathname: matchedPage.path,
|
82
|
-
query: _objectSpread(_objectSpread(_objectSpread({}, query), matchedPage.params), {}, {
|
83
|
-
// 模式匹配得到的参数,如/xxx/:id 可以匹配路径 /xxx/123 得参数id: 123
|
84
|
-
____h_a_s_h____: hash.slice(1) // 小程序中不能传递hash参数,用query辅助传递
|
85
|
-
|
86
|
-
})
|
65
|
+
if (this.urlPrefix) {
|
66
|
+
finalPath = ('/' + this.urlPrefix + '/' + finalPath).replace(/\/+/g, '/');
|
67
|
+
}
|
68
|
+
matchedPage.path = finalPath;
|
69
|
+
return Promise.resolve(matchedPage);
|
70
|
+
}
|
71
|
+
push(to, options) {
|
72
|
+
const subpackage = options === null || options === void 0 ? void 0 : options.subpackage;
|
73
|
+
this.normalizeRoute({
|
74
|
+
to,
|
75
|
+
subpackage
|
76
|
+
}).then(route => {
|
77
|
+
const path = route.path;
|
78
|
+
if (route.isTabBar) {
|
79
|
+
switchTab({
|
80
|
+
url: path
|
81
|
+
});
|
82
|
+
} else {
|
83
|
+
navigateTo({
|
84
|
+
url: path
|
87
85
|
});
|
88
86
|
}
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
87
|
+
});
|
88
|
+
}
|
89
|
+
replace(to, options) {
|
90
|
+
const subpackage = options === null || options === void 0 ? void 0 : options.subpackage;
|
91
|
+
this.normalizeRoute({
|
92
|
+
to,
|
93
|
+
subpackage
|
94
|
+
}).then(route => {
|
95
|
+
if (route.isTabBar) {
|
96
|
+
switchTab({
|
97
|
+
url: route.path
|
98
|
+
});
|
99
|
+
} else {
|
100
|
+
redirectTo({
|
101
|
+
url: route.path
|
102
|
+
});
|
97
103
|
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
url: route.path
|
134
|
-
});
|
135
|
-
} else {
|
136
|
-
redirectTo({
|
137
|
-
url: route.path
|
138
|
-
});
|
139
|
-
}
|
140
|
-
});
|
141
|
-
}
|
142
|
-
}, {
|
143
|
-
key: "reload",
|
144
|
-
value: function reload() {
|
145
|
-
var page = currentPage();
|
146
|
-
reLaunch({
|
147
|
-
url: url.params(page.route, page.options)
|
148
|
-
});
|
149
|
-
}
|
150
|
-
}, {
|
151
|
-
key: "go",
|
152
|
-
value: function go() {
|
153
|
-
throw new Error('Method not implemented.');
|
154
|
-
}
|
155
|
-
}, {
|
156
|
-
key: "back",
|
157
|
-
value: function back() {
|
158
|
-
navigateBack({
|
159
|
-
delta: 1
|
160
|
-
});
|
161
|
-
} // 获取宿主环境上的 href ,小程序端需要通过 path 进行转换
|
162
|
-
|
163
|
-
}, {
|
164
|
-
key: "href",
|
165
|
-
get: function get() {
|
166
|
-
var page = currentPage();
|
167
|
-
var reg = RegExp('^' + this.urlPrefix + '/');
|
168
|
-
var r = page.route.replace(reg, '');
|
169
|
-
var path = url.params("/".concat(r), page.options);
|
170
|
-
|
171
|
-
var _url$parse2 = url.parse(path),
|
172
|
-
pathname = _url$parse2.pathname,
|
173
|
-
query = _url$parse2.query,
|
174
|
-
hash = _url$parse2.hash;
|
175
|
-
|
176
|
-
return this.scheduler.getHrefByPath({
|
177
|
-
path: pathname,
|
178
|
-
query: query,
|
179
|
-
hash: hash
|
180
|
-
});
|
181
|
-
}
|
182
|
-
}]);
|
183
|
-
|
184
|
-
return Router;
|
185
|
-
}();
|
186
|
-
export var router = new Router();
|
104
|
+
});
|
105
|
+
}
|
106
|
+
reload() {
|
107
|
+
const page = currentPage();
|
108
|
+
reLaunch({
|
109
|
+
url: url.params(page.route, page.options)
|
110
|
+
});
|
111
|
+
}
|
112
|
+
go() {
|
113
|
+
throw new Error('Method not implemented.');
|
114
|
+
}
|
115
|
+
back() {
|
116
|
+
navigateBack({
|
117
|
+
delta: 1
|
118
|
+
});
|
119
|
+
}
|
120
|
+
// 获取宿主环境上的 href ,小程序端需要通过 path 进行转换
|
121
|
+
get href() {
|
122
|
+
const page = currentPage();
|
123
|
+
const reg = RegExp('^' + this.urlPrefix + '/');
|
124
|
+
const r = page.route.replace(reg, '');
|
125
|
+
const path = url.params(`/${r}`, page.options);
|
126
|
+
const {
|
127
|
+
pathname,
|
128
|
+
query,
|
129
|
+
hash
|
130
|
+
} = url.parse(path);
|
131
|
+
return this.scheduler.getHrefByPath({
|
132
|
+
path: pathname,
|
133
|
+
query,
|
134
|
+
hash
|
135
|
+
});
|
136
|
+
}
|
137
|
+
}
|
138
|
+
export const router = new Router();
|
package/lib/RouterScheduler.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { RouterScheduler as IRouterScheduler, Routes, TabBar, SubPackages } from '@ray-js/types';
|
2
|
-
export
|
2
|
+
export type Route = Routes[number] & {
|
3
3
|
isTabBar: boolean;
|
4
4
|
};
|
5
|
-
export
|
5
|
+
export type SubPackageRoute = {
|
6
6
|
root: string;
|
7
7
|
route: string;
|
8
8
|
path: string;
|
package/lib/RouterScheduler.js
CHANGED
@@ -1,184 +1,120 @@
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
5
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
6
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
8
|
-
import "core-js/modules/es.array.concat.js";
|
9
|
-
import "core-js/modules/es.object.to-string.js";
|
10
|
-
import "core-js/modules/es.array.find.js";
|
11
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
12
2
|
import { match, compile, pathToRegexp } from 'path-to-regexp';
|
13
3
|
import { url } from '@ray-js/library';
|
14
4
|
import slash from 'slash';
|
15
5
|
import { RouterScheduler as IRouterScheduler } from '@ray-js/types';
|
16
|
-
|
17
6
|
/**
|
18
7
|
* 小程序路由别名机制,将标准化的 web pathname 转化为小程序的 path
|
19
8
|
*/
|
20
|
-
export
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
hash = _opts$hash === void 0 ? '' : _opts$hash;
|
57
|
-
var route = this.matchPageByPath(path);
|
58
|
-
|
59
|
-
if (route) {
|
60
|
-
var keys = [];
|
61
|
-
pathToRegexp(route.route, keys);
|
62
|
-
|
63
|
-
if (keys.length > 0) {
|
64
|
-
var restQuery = _objectSpread({}, query);
|
65
|
-
|
66
|
-
keys.forEach(function (_ref) {
|
67
|
-
var name = _ref.name;
|
68
|
-
delete restQuery[name];
|
69
|
-
}); // 兼容小程序tab页,因tab页不能携带参数
|
70
|
-
|
71
|
-
keys.forEach(function (k) {
|
72
|
-
var _query$k$name;
|
73
|
-
|
74
|
-
return query[k.name] = (_query$k$name = query[k.name]) !== null && _query$k$name !== void 0 ? _query$k$name : '';
|
75
|
-
});
|
76
|
-
var href = compile(route.route, {
|
77
|
-
validate: false
|
78
|
-
})(query) + hash;
|
79
|
-
return url.params(href, restQuery);
|
80
|
-
}
|
81
|
-
|
82
|
-
return url.params(route.route + hash, query);
|
9
|
+
export class RouterScheduler extends IRouterScheduler {
|
10
|
+
$entityMap = [];
|
11
|
+
$pathMap = []; // 以小程序路径作为键存储关系
|
12
|
+
$subPackageRoute = {};
|
13
|
+
|
14
|
+
/**
|
15
|
+
* 将小程序地址栏转化为 web 地址
|
16
|
+
* @param path - 小程序页面地址
|
17
|
+
*/
|
18
|
+
getHrefByPath(opts) {
|
19
|
+
const {
|
20
|
+
query,
|
21
|
+
path,
|
22
|
+
hash = ''
|
23
|
+
} = opts;
|
24
|
+
const route = this.matchPageByPath(path);
|
25
|
+
if (route) {
|
26
|
+
let keys = [];
|
27
|
+
pathToRegexp(route.route, keys);
|
28
|
+
if (keys.length > 0) {
|
29
|
+
const restQuery = _objectSpread({}, query);
|
30
|
+
keys.forEach(_ref => {
|
31
|
+
let {
|
32
|
+
name
|
33
|
+
} = _ref;
|
34
|
+
delete restQuery[name];
|
35
|
+
});
|
36
|
+
// 兼容小程序tab页,因tab页不能携带参数
|
37
|
+
keys.forEach(k => {
|
38
|
+
var _query$k$name;
|
39
|
+
return query[k.name] = (_query$k$name = query[k.name]) !== null && _query$k$name !== void 0 ? _query$k$name : '';
|
40
|
+
});
|
41
|
+
const href = compile(route.route, {
|
42
|
+
validate: false
|
43
|
+
})(query) + hash;
|
44
|
+
return url.params(href, restQuery);
|
83
45
|
}
|
84
|
-
|
85
|
-
return '';
|
46
|
+
return url.params(route.route + hash, query);
|
86
47
|
}
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
if (!route) {
|
101
|
-
console.warn('Not match route by:', path);
|
102
|
-
return undefined;
|
103
|
-
}
|
104
|
-
|
105
|
-
return route;
|
48
|
+
return '';
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* 以小程序地址进行匹配页面
|
52
|
+
* @param path - 小程序页面地址 /pages/home/index
|
53
|
+
* @returns
|
54
|
+
*/
|
55
|
+
matchPageByPath(path) {
|
56
|
+
const route = this.$pathMap.find(route => route.path === path);
|
57
|
+
if (!route) {
|
58
|
+
console.warn('Not match route by:', path);
|
59
|
+
return undefined;
|
106
60
|
}
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
path: page.path
|
124
|
-
});
|
125
|
-
});
|
126
|
-
});
|
127
|
-
routes.forEach(function (r) {
|
128
|
-
var isTabBar = tabBarList.some(function (item) {
|
129
|
-
return r.path === item.pagePath;
|
61
|
+
return route;
|
62
|
+
}
|
63
|
+
registryPages(params) {
|
64
|
+
const {
|
65
|
+
routes,
|
66
|
+
tabBar,
|
67
|
+
subpackages = []
|
68
|
+
} = params;
|
69
|
+
const tabBarList = (tabBar === null || tabBar === void 0 ? void 0 : tabBar.list) || [];
|
70
|
+
subpackages.forEach(subPackage => {
|
71
|
+
const root = subPackage.root;
|
72
|
+
subPackage.pages.forEach(page => {
|
73
|
+
this.addSubPackagePage({
|
74
|
+
root,
|
75
|
+
route: page.route || page.path,
|
76
|
+
path: page.path
|
130
77
|
});
|
131
|
-
var route = r.route || r.path;
|
132
|
-
|
133
|
-
_this2.addPage(_objectSpread(_objectSpread({}, r), {}, {
|
134
|
-
isTabBar: isTabBar,
|
135
|
-
route: route
|
136
|
-
}));
|
137
78
|
});
|
79
|
+
});
|
80
|
+
routes.forEach(r => {
|
81
|
+
const isTabBar = tabBarList.some(item => r.path === item.pagePath);
|
82
|
+
const route = r.route || r.path;
|
83
|
+
this.addPage(_objectSpread(_objectSpread({}, r), {}, {
|
84
|
+
isTabBar,
|
85
|
+
route
|
86
|
+
}));
|
87
|
+
});
|
88
|
+
}
|
89
|
+
getMatchedPage(pathname) {
|
90
|
+
return this.matchPageByPathname(pathname);
|
91
|
+
}
|
92
|
+
addPage(route) {
|
93
|
+
this.$entityMap.push(route);
|
94
|
+
this.$pathMap.push(route);
|
95
|
+
}
|
96
|
+
addSubPackagePage(subPackageRoute) {
|
97
|
+
if (!this.$subPackageRoute[subPackageRoute.root]) {
|
98
|
+
this.$subPackageRoute[subPackageRoute.root] = [];
|
138
99
|
}
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
this.$subPackageRoute[subPackageRoute.root].push(subPackageRoute);
|
158
|
-
}
|
159
|
-
}, {
|
160
|
-
key: "getMatchedSubPackagePage",
|
161
|
-
value: function getMatchedSubPackagePage(pathname, subPackage) {
|
162
|
-
var subs = this.$subPackageRoute[subPackage] || [];
|
163
|
-
|
164
|
-
for (var index = 0; index < subs.length; index++) {
|
165
|
-
var item = subs[index];
|
166
|
-
var urlMatch = match(item.route, {
|
167
|
-
decode: decodeURIComponent
|
168
|
-
});
|
169
|
-
|
170
|
-
if (urlMatch(pathname)) {
|
171
|
-
return {
|
172
|
-
pathname: pathname,
|
173
|
-
route: item.route,
|
174
|
-
params: urlMatch(pathname)['params'],
|
175
|
-
subPackage: subPackage,
|
176
|
-
path: slash('/' + subPackage + item.path)
|
177
|
-
};
|
178
|
-
}
|
100
|
+
this.$subPackageRoute[subPackageRoute.root].push(subPackageRoute);
|
101
|
+
}
|
102
|
+
getMatchedSubPackagePage(pathname, subPackage) {
|
103
|
+
const subs = this.$subPackageRoute[subPackage] || [];
|
104
|
+
for (let index = 0; index < subs.length; index++) {
|
105
|
+
const item = subs[index];
|
106
|
+
const urlMatch = match(item.route, {
|
107
|
+
decode: decodeURIComponent
|
108
|
+
});
|
109
|
+
if (urlMatch(pathname)) {
|
110
|
+
return {
|
111
|
+
pathname,
|
112
|
+
route: item.route,
|
113
|
+
params: urlMatch(pathname)['params'],
|
114
|
+
subPackage,
|
115
|
+
path: slash('/' + subPackage + item.path)
|
116
|
+
};
|
179
117
|
}
|
180
118
|
}
|
181
|
-
}
|
182
|
-
|
183
|
-
return RouterScheduler;
|
184
|
-
}(IRouterScheduler);
|
119
|
+
}
|
120
|
+
}
|
package/lib/index.js
CHANGED
@@ -1,22 +1,19 @@
|
|
1
|
-
import "core-js/modules/es.array.map.js";
|
2
1
|
import { router } from './Router';
|
3
2
|
import { normalizeTabBar } from '@ray-js/framework-shared';
|
4
3
|
export function createRouter(params) {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
const {
|
5
|
+
tabBar = {},
|
6
|
+
subpackages
|
7
|
+
} = params;
|
8
|
+
const routes = params.routes.map(item => {
|
9
9
|
var _item$route;
|
10
|
-
|
11
10
|
item.route = (_item$route = item.route) !== null && _item$route !== void 0 ? _item$route : item.path;
|
12
11
|
return item;
|
13
12
|
});
|
14
|
-
|
15
|
-
var _tabBar = normalizeTabBar(tabBar, routes);
|
16
|
-
|
13
|
+
const _tabBar = normalizeTabBar(tabBar, routes);
|
17
14
|
router.scheduler.registryPages({
|
18
|
-
routes
|
19
|
-
subpackages
|
15
|
+
routes,
|
16
|
+
subpackages,
|
20
17
|
tabBar: _tabBar
|
21
18
|
});
|
22
19
|
return router;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/router-mp",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.23",
|
4
4
|
"description": "Ray Core",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -20,16 +20,16 @@
|
|
20
20
|
"watch": "tsc -p ./tsconfig.build.json --module esnext --outDir lib --watch"
|
21
21
|
},
|
22
22
|
"dependencies": {
|
23
|
-
"@ray-js/api": "1.3.
|
24
|
-
"@ray-js/env": "1.3.
|
25
|
-
"@ray-js/library": "1.3.
|
26
|
-
"@ray-js/types": "1.3.
|
23
|
+
"@ray-js/api": "1.3.23",
|
24
|
+
"@ray-js/env": "1.3.23",
|
25
|
+
"@ray-js/library": "1.3.23",
|
26
|
+
"@ray-js/types": "1.3.23",
|
27
27
|
"@react-navigation/core": "^6.1.0",
|
28
28
|
"path-to-regexp": "^6.2.0",
|
29
29
|
"slash": "^5.0.0"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"@ray-js/cli": "1.3.
|
32
|
+
"@ray-js/cli": "1.3.23"
|
33
33
|
},
|
34
34
|
"maintainers": [
|
35
35
|
{
|
@@ -37,6 +37,6 @@
|
|
37
37
|
"email": "tuyafe@tuya.com"
|
38
38
|
}
|
39
39
|
],
|
40
|
-
"gitHead": "
|
40
|
+
"gitHead": "04708bb394d817a7a522fcde178f19f170d5d364",
|
41
41
|
"repository": {}
|
42
42
|
}
|