swico 0.5.0 → 0.5.2

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.2",
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;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  var vue_1 = require("vue");
8
- var routes_1 = require("./routes");
8
+ var routes_1 = __importDefault(require("./routes"));
9
9
  var vue_router_1 = require("vue-router");
10
10
  var Container_1 = __importDefault(require("./Container"));
11
11
  var config_1 = require("./config");
@@ -14,7 +14,7 @@ var global_1 = __importDefault(require("../global"));
14
14
  var qs_1 = __importDefault(require("qs"));
15
15
  var router = (0, vue_router_1.createRouter)({
16
16
  history: (config_1.routerType === 'hash' ? vue_router_1.createWebHashHistory : vue_router_1.createWebHistory)(config_1.routerBase),
17
- routes: routes_1.routes
17
+ routes: routes_1.default
18
18
  });
19
19
  var app = (0, vue_1.createApp)(Container_1.default);
20
20
  var Swico = { history: null };
@@ -2,5 +2,5 @@ import { RouteRecordRaw } from 'vue-router';
2
2
  type RouteItem = RouteRecordRaw & {
3
3
  decorator?: string;
4
4
  };
5
- export declare const routes: RouteItem[];
6
- export {};
5
+ declare const _default: RouteItem[];
6
+ export default _default;
@@ -1,4 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.routes = void 0;
4
- exports.routes = [];
3
+ exports.default = [];
@@ -226,20 +226,21 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
226
226
  case 0:
227
227
  targetPath = path_1.default.resolve(__dirname, '../index.js');
228
228
  targetTypesPath = path_1.default.resolve(__dirname, '../index.d.ts');
229
- replaceFileText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".js")), 'utf8');
229
+ return [4, fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".js")), 'utf8')];
230
+ case 1:
231
+ replaceFileText = _a.sent();
230
232
  fileTypesText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".d.ts")), 'utf8');
231
233
  if (templateType === 'react') {
232
234
  formatHooksPath = path_1.default
233
235
  .resolve(projectPath, './src/.swico/hooks')
234
236
  .replaceAll('\\', '/');
235
- console.log('formatHooksPath', formatHooksPath);
236
237
  replaceFileText = replaceFileText.replaceAll('require("./template/react/hooks");', "require(\"".concat(formatHooksPath, "\");"));
237
238
  }
238
239
  return [4, (0, tools_1.writeFile)(targetPath, replaceFileText)];
239
- case 1:
240
+ case 2:
240
241
  _a.sent();
241
242
  return [4, (0, tools_1.writeFile)(targetTypesPath, fileTypesText)];
242
- case 2:
243
+ case 3:
243
244
  _a.sent();
244
245
  return [2];
245
246
  }