@native-router/core 1.0.3 → 1.1.0

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/README.md CHANGED
File without changes
package/dist/index.cjs CHANGED
@@ -373,6 +373,22 @@ function listen(router, onViewChange) {
373
373
  };
374
374
  }
375
375
 
376
+ /**
377
+ * Get current route params from router.
378
+ * @group Methods
379
+ * @category Router
380
+ * @param router router instance
381
+ * @returns the params object
382
+ */
383
+ function getParams(router) {
384
+ const {
385
+ index
386
+ } = getHistoryState(router);
387
+ const matched = router.viewStack[index];
388
+ if (!matched || !matched.length) return {};
389
+ return matched[matched.length - 1]?.params ?? {};
390
+ }
391
+
376
392
  exports.NativeRouterError = NativeRouterError;
377
393
  exports.NotFoundError = NotFoundError;
378
394
  exports.back = back;
@@ -384,6 +400,7 @@ exports.createHref = createHref;
384
400
  exports.forward = forward;
385
401
  exports.getCurrentView = getCurrentView;
386
402
  exports.getLocation = getLocation;
403
+ exports.getParams = getParams;
387
404
  exports.go = go;
388
405
  exports.initHistoryStack = initHistoryStack;
389
406
  exports.listen = listen;
package/dist/index.mjs CHANGED
@@ -371,4 +371,20 @@ function listen(router, onViewChange) {
371
371
  };
372
372
  }
373
373
 
374
- export { NativeRouterError, NotFoundError, back, cancel, commit, commitReplace, create, createHref, forward, getCurrentView, getLocation, go, initHistoryStack, listen, match, navigate, refresh, resolve, resolveTo, setOptions, toLocation };
374
+ /**
375
+ * Get current route params from router.
376
+ * @group Methods
377
+ * @category Router
378
+ * @param router router instance
379
+ * @returns the params object
380
+ */
381
+ function getParams(router) {
382
+ const {
383
+ index
384
+ } = getHistoryState(router);
385
+ const matched = router.viewStack[index];
386
+ if (!matched || !matched.length) return {};
387
+ return matched[matched.length - 1]?.params ?? {};
388
+ }
389
+
390
+ export { NativeRouterError, NotFoundError, back, cancel, commit, commitReplace, create, createHref, forward, getCurrentView, getLocation, getParams, go, initHistoryStack, listen, match, navigate, refresh, resolve, resolveTo, setOptions, toLocation };
File without changes
File without changes
@@ -18,18 +18,18 @@ export declare function setOptions<R extends BaseRoute = BaseRoute, V = any>(rou
18
18
  location: import("./types").WrappedLocation;
19
19
  };
20
20
  viewStack: V[];
21
- locationStack: Location<any>[];
21
+ locationStack: Location[];
22
22
  resolveView: ResolveView<R, V>;
23
23
  currentGuard<T>(promise: Promise<T>): Promise<T>;
24
24
  cancelAll(): void;
25
- resolving?: Location<any> | undefined;
25
+ resolving?: Location;
26
26
  } & Required<Pick<Options<V>, "baseUrl">> & Omit<Options<V>, "baseUrl"> & Omit<Options<V>, "currentView">;
27
27
  export declare function getLocation({ history }: Pick<RouterInstance<any>, 'history'>): {
28
28
  state: any;
29
- key: string;
30
- pathname: string;
31
- search: string;
32
- hash: string;
29
+ key: import("history").Key;
30
+ pathname: import("history").Pathname;
31
+ search: import("history").Search;
32
+ hash: import("history").Hash;
33
33
  };
34
34
  export declare function getCurrentView<R extends BaseRoute = BaseRoute>(router: RouterInstance<R>): any;
35
35
  /**
@@ -152,3 +152,11 @@ export declare function initHistoryStack<R extends BaseRoute = BaseRoute, V = an
152
152
  * @returns unlisten - A function that may be used to stop listening
153
153
  */
154
154
  export declare function listen<R extends BaseRoute = BaseRoute, V = any>(router: RouterInstance<R, V>, onViewChange: (v: V) => void): () => void;
155
+ /**
156
+ * Get current route params from router.
157
+ * @group Methods
158
+ * @category Router
159
+ * @param router router instance
160
+ * @returns the params object
161
+ */
162
+ export declare function getParams<R extends BaseRoute = BaseRoute>(router: RouterInstance<R>): Record<string, string>;
File without changes
@@ -3,7 +3,7 @@ export declare function noop(): void;
3
3
  export declare const resolve: {
4
4
  (): Promise<void>;
5
5
  <T>(value: T): Promise<Awaited<T>>;
6
- <T_1>(value: T_1 | PromiseLike<T_1>): Promise<Awaited<T_1>>;
6
+ <T>(value: T | PromiseLike<T>): Promise<Awaited<T>>;
7
7
  };
8
8
  export declare const reject: <T = never>(reason?: any) => Promise<T>;
9
9
  export declare function cancelPromise(): Promise<unknown>;
package/dist/util.cjs CHANGED
File without changes
package/dist/util.mjs CHANGED
File without changes
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@native-router/core",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "exports": {
5
5
  ".": {
6
+ "types": "./dist/types/index.d.ts",
6
7
  "import": "./dist/index.mjs",
7
- "require": "./dist/index.cjs",
8
- "types": "./dist/types/index.d.ts"
8
+ "require": "./dist/index.cjs"
9
9
  },
10
10
  "./util": {
11
+ "types": "./dist/types/util.d.ts",
11
12
  "import": "./dist/util.mjs",
12
- "require": "./dist/util.cjs",
13
- "types": "./dist/types/util.d.ts"
13
+ "require": "./dist/util.cjs"
14
14
  }
15
15
  },
16
16
  "types": "./dist/types/index.d.ts",
@@ -31,25 +31,22 @@
31
31
  "build": "rm -rf dist && rollup -c && tsc -p tsconfig.production.json && tsc-alias -p tsconfig.production.json",
32
32
  "commit": "lint-staged && git-cz -n",
33
33
  "coverage": "nyc report --reporter=text-lcov > ./.nyc_output/coverage.txt",
34
- "lint": "eslint --fix src test demos *.js --ext .js,.jsx,.ts,.tsx",
34
+ "lint": "eslint --fix src test *.js --ext .js,.jsx,.ts,.tsx",
35
35
  "doc:gen": "typedoc",
36
36
  "deploy": "npm run doc:gen && gh-pages -d dist",
37
- "test": "cross-env NODE_ENV=test nyc mocha",
38
- "preversion": "npm run build",
39
- "postversion": "npm publish",
40
- "postpublish": "git push --follow-tags && npm run deploy"
37
+ "test": "cross-env NODE_ENV=test nyc mocha"
41
38
  },
42
39
  "repository": {
43
40
  "type": "git",
44
- "url": "https://github.com/wmzy/@native-router/core"
41
+ "url": "git+https://github.com/native-router/core.git"
45
42
  },
46
43
  "sideEffects": false,
47
44
  "author": "wmzy",
48
45
  "license": "MIT",
49
46
  "bugs": {
50
- "url": "https://github.com/wmzy/@native-router/core/issues"
47
+ "url": "https://github.com/native-router/core/issues"
51
48
  },
52
- "homepage": "https://github.com/wmzy/@native-router/core",
49
+ "homepage": "https://github.com/native-router/core",
53
50
  "engines": {
54
51
  "node": ">=14"
55
52
  },
@@ -78,7 +75,7 @@
78
75
  "core-js": "^3.31.1",
79
76
  "coveralls": "^3.1.1",
80
77
  "cross-env": "^7.0.3",
81
- "eslint": "^8.45.0",
78
+ "eslint": "^8.50.0",
82
79
  "eslint-config-airbnb": "^19.0.4",
83
80
  "eslint-config-airbnb-typescript": "^17.1.0",
84
81
  "eslint-config-prettier": "^8.8.0",
@@ -107,6 +104,7 @@
107
104
  "typedoc": "^0.24.8",
108
105
  "typedoc-plugin-mark-react-functional-components": "^0.2.2",
109
106
  "typedoc-plugin-missing-exports": "^2.0.0",
110
- "typescript": "^5.1.6"
107
+ "typescript": "^5.9.3",
108
+ "semantic-release": "^25.0.3"
111
109
  }
112
110
  }