@ray-js/router-mp 1.6.19 → 1.6.20

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/lib/Router.js CHANGED
@@ -1,9 +1,4 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import "core-js/modules/es.regexp.constructor.js";
4
- import "core-js/modules/es.regexp.dot-all.js";
5
- import "core-js/modules/es.regexp.exec.js";
6
- import "core-js/modules/es.string.replace.js";
7
2
  import { url } from '@ray-js/library';
8
3
  import { navigateBack, navigateTo, reLaunch, switchTab, redirectTo } from '@ray-js/api';
9
4
  import { RouterScheduler, currentPage } from './RouterScheduler';
@@ -33,19 +28,15 @@ function pathRelative(fromPath, toPath) {
33
28
  return result;
34
29
  }
35
30
  export class Router {
36
- constructor() {
37
- // 只有作为其他小程序的子包时,才设置urlPrefix
38
- _defineProperty(this, "urlPrefix", '');
39
- /**
40
- * 功能页模式为 functional,使用相对路径模式
41
- * 如果是绝对路径,表示跳转到宿主小程序
42
- *
43
- * @private
44
- */
45
- _defineProperty(this, "mode", 'miniprogram');
46
- _defineProperty(this, "scheduler", new RouterScheduler());
47
- }
48
- // functional
31
+ // 只有作为其他小程序的子包时,才设置urlPrefix
32
+ urlPrefix = '';
33
+ /**
34
+ * 功能页模式为 functional,使用相对路径模式
35
+ * 如果是绝对路径,表示跳转到宿主小程序
36
+ *
37
+ * @private
38
+ */
39
+ mode = 'miniprogram'; // functional
49
40
 
50
41
  /**
51
42
  * setUrlPrefix
@@ -56,6 +47,8 @@ export class Router {
56
47
  setMode(mode) {
57
48
  this.mode = mode;
58
49
  }
50
+ scheduler = (() => new RouterScheduler())();
51
+
59
52
  /**
60
53
  * 标准化路由路径,将 web 标准的地址栏转化到 小程序地址
61
54
  */
@@ -180,7 +173,7 @@ export class Router {
180
173
  const page = currentPage();
181
174
  const reg = RegExp('^' + this.urlPrefix + '/');
182
175
  const r = page.route.replace(reg, '');
183
- const path = url.params("/".concat(r), page.options);
176
+ const path = url.params(`/${r}`, page.options);
184
177
  const {
185
178
  pathname,
186
179
  query,
@@ -1,10 +1,8 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
2
  import "core-js/modules/esnext.iterator.constructor.js";
4
3
  import "core-js/modules/esnext.iterator.find.js";
5
4
  import "core-js/modules/esnext.iterator.for-each.js";
6
5
  import "core-js/modules/esnext.iterator.some.js";
7
- import "core-js/modules/web.dom-collections.iterator.js";
8
6
  import { compile, match, pathToRegexp } from 'path-to-regexp';
9
7
  import { url } from '@ray-js/library';
10
8
  import slash from 'slash';
@@ -30,13 +28,9 @@ export function currentPage() {
30
28
  * 小程序路由别名机制,将标准化的 web pathname 转化为小程序的 path
31
29
  */
32
30
  export class RouterScheduler extends IRouterScheduler {
33
- constructor() {
34
- super(...arguments);
35
- _defineProperty(this, "$entityMap", []);
36
- _defineProperty(this, "$subPackageRoute", {});
37
- _defineProperty(this, "$pathMap", []);
38
- }
39
- // 以小程序路径作为键存储关系
31
+ $entityMap = [];
32
+ $subPackageRoute = {};
33
+ $pathMap = []; // 以小程序路径作为键存储关系
40
34
 
41
35
  getCurrentRoute() {
42
36
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/router-mp",
3
- "version": "1.6.19",
3
+ "version": "1.6.20",
4
4
  "description": "Ray Core",
5
5
  "keywords": [
6
6
  "ray"
@@ -26,19 +26,19 @@
26
26
  "@ray-js/api": "1.5.17"
27
27
  },
28
28
  "dependencies": {
29
- "@ray-js/env": "1.6.19",
30
- "@ray-js/library": "1.6.19",
31
- "@ray-js/types": "1.6.19",
29
+ "@ray-js/env": "1.6.20",
30
+ "@ray-js/library": "1.6.20",
31
+ "@ray-js/types": "1.6.20",
32
32
  "@react-navigation/core": "^6.4.17",
33
33
  "path-to-regexp": "^6.3.0",
34
34
  "slash": "^5.1.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@ray-js/cli": "1.6.19"
37
+ "@ray-js/cli": "1.6.20"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public",
41
41
  "registry": "https://registry.npmjs.com"
42
42
  },
43
- "gitHead": "4ea8520f14ca36fcd9a397609c329421ce5704db"
43
+ "gitHead": "09a3ae02055470a3c05e953f2a4aec0d34c12952"
44
44
  }