@ray-js/router-mp 1.6.30-alpha.0 → 1.6.30

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/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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RouteOptions, Router as TRouter } from '@ray-js/types';
1
+ import { Router as TRouter, RouteOptions } from '@ray-js/types';
2
2
  import { RouterScheduler } from './RouterScheduler';
3
3
  export declare class Router implements TRouter {
4
4
  private urlPrefix;
@@ -19,25 +19,7 @@ export declare class Router implements TRouter {
19
19
  * 标准化路由路径,将 web 标准的地址栏转化到 小程序地址
20
20
  */
21
21
  private normalizeRoute;
22
- /**
23
- * 跳转到指定路由
24
- * @param to - routes.config.ts 中配置的路由地址
25
- * @param options
26
- * @param options.subpackage - 分包名
27
- *
28
- * @example
29
- * router.push('/cat', { subpackage: 'packageA' });
30
- */
31
22
  push(to: string, options?: RouteOptions): void;
32
- /**
33
- * 替换当前页到指定路由
34
- * @param to - routes.config.ts 中配置的路由地址
35
- * @param options
36
- * @param options.subpackage - 分包名
37
- *
38
- * @example
39
- * router.replace('/cat', { subpackage: 'packageA' });
40
- */
41
23
  replace(to: string, options?: RouteOptions): void;
42
24
  reload(): void;
43
25
  go(delta: number): void;
package/lib/Router.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import { navigateBack, navigateTo, reLaunch, redirectTo, switchTab } from '@ray-js/api';
3
2
  import { url } from '@ray-js/library';
3
+ import { navigateBack, navigateTo, reLaunch, switchTab, redirectTo } from '@ray-js/api';
4
4
  import { RouterScheduler, currentPage } from './RouterScheduler';
5
5
  function pathRelative(fromPath, toPath) {
6
6
  const from = fromPath.split('/');
@@ -119,16 +119,6 @@ export class Router {
119
119
  }
120
120
  return Promise.resolve(matchedPage);
121
121
  }
122
-
123
- /**
124
- * 跳转到指定路由
125
- * @param to - routes.config.ts 中配置的路由地址
126
- * @param options
127
- * @param options.subpackage - 分包名
128
- *
129
- * @example
130
- * router.push('/cat', { subpackage: 'packageA' });
131
- */
132
122
  push(to, options) {
133
123
  const subpackage = options === null || options === void 0 ? void 0 : options.subpackage;
134
124
  this.normalizeRoute({
@@ -147,16 +137,6 @@ export class Router {
147
137
  }
148
138
  });
149
139
  }
150
-
151
- /**
152
- * 替换当前页到指定路由
153
- * @param to - routes.config.ts 中配置的路由地址
154
- * @param options
155
- * @param options.subpackage - 分包名
156
- *
157
- * @example
158
- * router.replace('/cat', { subpackage: 'packageA' });
159
- */
160
140
  replace(to, options) {
161
141
  const subpackage = options === null || options === void 0 ? void 0 : options.subpackage;
162
142
  this.normalizeRoute({
@@ -188,7 +168,6 @@ export class Router {
188
168
  delta: 1
189
169
  });
190
170
  }
191
-
192
171
  // 获取宿主环境上的 href ,小程序端需要通过 path 进行转换
193
172
  get href() {
194
173
  const page = currentPage();
@@ -1,4 +1,4 @@
1
- import { RouterScheduler as IRouterScheduler, type Routes, type SubPackages, type TabBar } from '@ray-js/types';
1
+ import { RouterScheduler as IRouterScheduler, Routes, SubPackages, TabBar } from '@ray-js/types';
2
2
  export type Route = Routes[number] & {
3
3
  isTabBar: boolean;
4
4
  };
@@ -30,7 +30,7 @@ export declare class RouterScheduler extends IRouterScheduler<Route> {
30
30
  tabBar: TabBar;
31
31
  subpackages?: SubPackages;
32
32
  }): void;
33
- getMatchedPage(pathname: string): import("@ray-js/types").RootRouteItem & {
33
+ getMatchedPage(pathname: string): import("@ray-js/types").Route & {
34
34
  isTabBar: boolean;
35
35
  } & {
36
36
  params: object;
@@ -3,11 +3,11 @@ import "core-js/modules/esnext.iterator.constructor.js";
3
3
  import "core-js/modules/esnext.iterator.find.js";
4
4
  import "core-js/modules/esnext.iterator.for-each.js";
5
5
  import "core-js/modules/esnext.iterator.some.js";
6
- import { getLaunchOptionsSync } from '@ray-js/api';
7
- import { url } from '@ray-js/library';
8
- import { RouterScheduler as IRouterScheduler } from '@ray-js/types';
9
6
  import { compile, match, pathToRegexp } from 'path-to-regexp';
7
+ import { url } from '@ray-js/library';
10
8
  import slash from 'slash';
9
+ import { RouterScheduler as IRouterScheduler } from '@ray-js/types';
10
+ import { getLaunchOptionsSync } from '@ray-js/api';
11
11
  export function currentPage() {
12
12
  const pages = getCurrentPages();
13
13
  if (pages.length > 0) {
@@ -43,7 +43,8 @@ export class RouterScheduler extends IRouterScheduler {
43
43
  if (!normalizedRoute.startsWith('/')) {
44
44
  normalizedRoute = '/' + normalizedRoute;
45
45
  }
46
- return this.getRouteByPath(normalizedRoute);
46
+ const matchedRoute = this.getRouteByPath(normalizedRoute);
47
+ return matchedRoute;
47
48
  }
48
49
 
49
50
  /**
@@ -91,8 +92,7 @@ export class RouterScheduler extends IRouterScheduler {
91
92
  const tabBarList = (tabBar === null || tabBar === void 0 ? void 0 : tabBar.list) || [];
92
93
  subpackages.forEach(subPackage => {
93
94
  const root = subPackage.root;
94
- const subPackagesPages = subPackage.routes || subPackage.pages || [];
95
- subPackagesPages.forEach(page => {
95
+ subPackage.pages.forEach(page => {
96
96
  this.addSubPackagePage({
97
97
  root,
98
98
  route: page.route || page.path,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/router-mp",
3
- "version": "1.6.30-alpha.0",
3
+ "version": "1.6.30",
4
4
  "description": "Ray Core",
5
5
  "keywords": [
6
6
  "ray"
@@ -23,23 +23,22 @@
23
23
  "watch": "tsc -p ./tsconfig.build.json --module esnext --outDir lib --watch"
24
24
  },
25
25
  "peerDependencies": {
26
- "@ray-js/api": "1.6.30-alpha.0"
26
+ "@ray-js/api": "1.5.17"
27
27
  },
28
28
  "dependencies": {
29
- "@ray-js/env": "1.6.29",
30
- "@ray-js/library": "1.6.29",
31
- "@ray-js/types": "1.6.30-alpha.0",
29
+ "@ray-js/env": "1.6.30",
30
+ "@ray-js/library": "1.6.30",
31
+ "@ray-js/types": "1.6.30",
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.30-alpha.0",
38
- "typescript": "^5.8.2"
37
+ "@ray-js/cli": "1.6.30"
39
38
  },
40
39
  "publishConfig": {
41
40
  "access": "public",
42
41
  "registry": "https://registry.npmjs.com"
43
42
  },
44
- "gitHead": "511cd3f8d57c2888411700526781e65959037c5b"
43
+ "gitHead": "6db627db6ff0dffe0a249fbfc07b0281454e82c9"
45
44
  }