swico 0.5.0 → 0.5.1

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",
3
+ "version": "0.5.1",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -1,11 +1,10 @@
1
1
  import { ConfigRouterType } from '../../utils/config';
2
- import { RoutesItemType } from './index';
3
2
  export { unstable_HistoryRouter as HistoryRouter } from 'react-router-dom';
4
3
  export declare const formatAncPath: (ancPath: string) => string;
5
- export declare const getPathNameList: (routes: RoutesItemType[]) => Array<{
4
+ export declare const pathNameList: {
6
5
  path: string;
7
6
  name: string;
8
- }>;
7
+ }[];
9
8
  export declare const getHistory: (routerBase: ConfigRouterType['base'], routerType: ConfigRouterType['type']) => {
10
9
  history: SwicoHistoryType;
11
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.getPathNameList = exports.formatAncPath = exports.HistoryRouter = void 0;
6
+ exports.getHistory = exports.pathNameList = exports.formatAncPath = exports.HistoryRouter = void 0;
7
7
  var qs_1 = __importDefault(require("qs"));
8
8
  var history_1 = require("history");
9
9
  var routes_1 = __importDefault(require("./routes"));
@@ -45,7 +45,7 @@ var getPathNameList = function (routes) {
45
45
  routes.forEach(function (item) { return checkRouteItem(item, ''); });
46
46
  return list;
47
47
  };
48
- exports.getPathNameList = getPathNameList;
48
+ exports.pathNameList = getPathNameList(routes_1.default);
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,7 +84,6 @@ 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)(routes_1.default);
88
87
  var lastIndexBase = routerBase[routerBase.length - 1];
89
88
  var formatRouterBase = lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
90
89
  history = {
@@ -97,7 +96,7 @@ var getHistory = function (routerBase, routerType) {
97
96
  originalHistory.push("".concat(formatRouterBase).concat(to));
98
97
  break;
99
98
  case 'object':
100
- var formatOption = getFormatHistoryOption(to, formatRouterBase, pathNameList, 'push');
99
+ var formatOption = getFormatHistoryOption(to, formatRouterBase, exports.pathNameList, 'push');
101
100
  originalHistory.push(formatOption);
102
101
  break;
103
102
  default:
@@ -110,7 +109,7 @@ var getHistory = function (routerBase, routerType) {
110
109
  originalHistory.replace("".concat(formatRouterBase).concat(to));
111
110
  break;
112
111
  case 'object':
113
- var formatOption = getFormatHistoryOption(to, formatRouterBase, pathNameList, 'replace');
112
+ var formatOption = getFormatHistoryOption(to, formatRouterBase, exports.pathNameList, 'replace');
114
113
  originalHistory.replace(formatOption);
115
114
  break;
116
115
  default:
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useLocation = void 0;
7
- var routes_1 = __importDefault(require("./routes"));
8
7
  var react_router_dom_1 = require("react-router-dom");
9
8
  var history_1 = require("./history");
10
9
  var qs_1 = __importDefault(require("qs"));
@@ -28,12 +27,10 @@ var compareURLPatterns = function (urlPatternWithValues, urlPatternWithParams) {
28
27
  };
29
28
  var useLocation = function () {
30
29
  var _a, _b;
31
- console.log('useLocationRoutes', routes_1.default);
32
30
  var location = (0, react_router_dom_1.useLocation)();
33
31
  var params = (0, react_router_dom_1.useParams)();
34
32
  var search = location.search, hash = location.hash, pathname = location.pathname;
35
- var pathNameList = (0, history_1.getPathNameList)(routes_1.default);
36
- var name = (_a = pathNameList.find(function (item) {
33
+ var name = (_a = history_1.pathNameList.find(function (item) {
37
34
  return (Object.keys(params).length > 0 && compareURLPatterns(pathname, item.path)) ||
38
35
  item.path === pathname;
39
36
  })) === null || _a === void 0 ? void 0 : _a.name;
@@ -232,7 +232,6 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
232
232
  formatHooksPath = path_1.default
233
233
  .resolve(projectPath, './src/.swico/hooks')
234
234
  .replaceAll('\\', '/');
235
- console.log('formatHooksPath', formatHooksPath);
236
235
  replaceFileText = replaceFileText.replaceAll('require("./template/react/hooks");', "require(\"".concat(formatHooksPath, "\");"));
237
236
  }
238
237
  return [4, (0, tools_1.writeFile)(targetPath, replaceFileText)];