swico 0.5.0-beta5 → 0.5.0-beta6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swico",
3
- "version": "0.5.0-beta5",
3
+ "version": "0.5.0-beta6",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -30,7 +30,8 @@ var useLocation = function () {
30
30
  var location = (0, react_router_dom_1.useLocation)();
31
31
  var params = (0, react_router_dom_1.useParams)();
32
32
  var search = location.search, hash = location.hash, pathname = location.pathname;
33
- var name = (_a = history_1.pathNameList.find(function (item) { return (params && compareURLPatterns(pathname, item.path)) || item.path === pathname; })) === null || _a === void 0 ? void 0 : _a.name;
33
+ var pathNameList = (0, history_1.getPathNameList)();
34
+ var name = (_a = pathNameList.find(function (item) { return (params && compareURLPatterns(pathname, item.path)) || item.path === pathname; })) === null || _a === void 0 ? void 0 : _a.name;
34
35
  var query = search ? qs_1.default.parse(search.startsWith('?') ? search.slice(1) : search) : {};
35
36
  return {
36
37
  name: name,
@@ -1,10 +1,10 @@
1
1
  import { ConfigRouterType } from '../../utils/config';
2
2
  export { unstable_HistoryRouter as HistoryRouter } from 'react-router-dom';
3
3
  export declare const formatAncPath: (ancPath: string) => string;
4
- export declare const pathNameList: {
4
+ export declare const getPathNameList: () => Array<{
5
5
  path: string;
6
6
  name: string;
7
- }[];
7
+ }>;
8
8
  export declare const getHistory: (routerBase: ConfigRouterType['base'], routerType: ConfigRouterType['type']) => {
9
9
  history: SwicoHistoryType;
10
10
  originalHistory: import("history").HashHistory;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getHistory = exports.pathNameList = exports.formatAncPath = exports.HistoryRouter = void 0;
6
+ exports.getHistory = exports.getPathNameList = exports.formatAncPath = exports.HistoryRouter = void 0;
7
7
  var routes_1 = __importDefault(require("./routes"));
8
8
  var qs_1 = __importDefault(require("qs"));
9
9
  var history_1 = require("history");
@@ -45,7 +45,7 @@ var getPathNameList = function () {
45
45
  routes_1.default.forEach(function (item) { return checkRouteItem(item, ''); });
46
46
  return list;
47
47
  };
48
- exports.pathNameList = getPathNameList();
48
+ exports.getPathNameList = getPathNameList;
49
49
  var getLocation = function (originalHistory) {
50
50
  var _a = originalHistory.location, pathname = _a.pathname, hash = _a.hash, search = _a.search;
51
51
  return {
@@ -84,6 +84,7 @@ var getHistory = function (routerBase, routerType) {
84
84
  var _a;
85
85
  var history;
86
86
  var originalHistory = (_a = (routerType === 'hash' ? history_1.createHashHistory : history_1.createBrowserHistory)) === null || _a === void 0 ? void 0 : _a();
87
+ var pathNameList = (0, exports.getPathNameList)();
87
88
  var lastIndexBase = routerBase[routerBase.length - 1];
88
89
  var formatRouterBase = lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
89
90
  history = {
@@ -96,7 +97,7 @@ var getHistory = function (routerBase, routerType) {
96
97
  originalHistory.push("".concat(formatRouterBase).concat(to));
97
98
  break;
98
99
  case 'object':
99
- var formatOption = getFormatHistoryOption(to, formatRouterBase, exports.pathNameList, 'push');
100
+ var formatOption = getFormatHistoryOption(to, formatRouterBase, pathNameList, 'push');
100
101
  originalHistory.push(formatOption);
101
102
  break;
102
103
  default:
@@ -109,7 +110,7 @@ var getHistory = function (routerBase, routerType) {
109
110
  originalHistory.replace("".concat(formatRouterBase).concat(to));
110
111
  break;
111
112
  case 'object':
112
- var formatOption = getFormatHistoryOption(to, formatRouterBase, exports.pathNameList, 'replace');
113
+ var formatOption = getFormatHistoryOption(to, formatRouterBase, pathNameList, 'replace');
113
114
  originalHistory.replace(formatOption);
114
115
  break;
115
116
  default: