swico 0.5.0-beta4 → 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-beta4",
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,2 +1,3 @@
1
1
  import { UseLocationType } from './react';
2
+ export declare const getFormatRouterBase: (routerBase: any) => any;
2
3
  export declare const useLocation: UseLocationType;
@@ -3,12 +3,16 @@ 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.useLocation = void 0;
6
+ exports.useLocation = exports.getFormatRouterBase = void 0;
7
7
  var vue_router_1 = require("vue-router");
8
8
  var qs_1 = __importDefault(require("qs"));
9
9
  var vue_1 = require("vue");
10
10
  var config_1 = require("../vue/config");
11
- var tools_1 = require("../../utils/tools");
11
+ var getFormatRouterBase = function (routerBase) {
12
+ var lastIndexBase = routerBase[routerBase.length - 1];
13
+ return lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
14
+ };
15
+ exports.getFormatRouterBase = getFormatRouterBase;
12
16
  var useLocation = function () {
13
17
  var route = (0, vue_router_1.useRoute)();
14
18
  var location = (0, vue_1.reactive)({
@@ -25,7 +29,7 @@ var useLocation = function () {
25
29
  var search = query ? qs_1.default.stringify(query) : '';
26
30
  location.name = name;
27
31
  location.path = path;
28
- location.pathname = (0, tools_1.getFormatRouterBase)(config_1.routerBase) + path;
32
+ location.pathname = (0, exports.getFormatRouterBase)(config_1.routerBase) + path;
29
33
  location.search = search;
30
34
  location.query = query;
31
35
  location.hash = hash;
@@ -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:
@@ -51,7 +51,7 @@ Swico.history = {
51
51
  query: query,
52
52
  name: name,
53
53
  hash: hash,
54
- search: qs_1.default.stringify(query)
54
+ search: query ? qs_1.default.stringify(query) : ''
55
55
  };
56
56
  }
57
57
  };
@@ -5,4 +5,3 @@ export declare const toast: {
5
5
  warning: (message: string | string[]) => void;
6
6
  };
7
7
  export declare const writeFile: (sourcePath: any, text: any) => Promise<unknown>;
8
- export declare const getFormatRouterBase: (routerBase: any) => any;
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.getFormatRouterBase = exports.writeFile = exports.toast = exports.getPort = exports.copyDirFiles = void 0;
42
+ exports.writeFile = exports.toast = exports.getPort = exports.copyDirFiles = void 0;
43
43
  var portfinder_1 = __importDefault(require("portfinder"));
44
44
  var fs_extra_1 = __importDefault(require("fs-extra"));
45
45
  var path_1 = __importDefault(require("path"));
@@ -139,8 +139,3 @@ var writeFile = function (sourcePath, text) {
139
139
  });
140
140
  };
141
141
  exports.writeFile = writeFile;
142
- var getFormatRouterBase = function (routerBase) {
143
- var lastIndexBase = routerBase[routerBase.length - 1];
144
- return lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
145
- };
146
- exports.getFormatRouterBase = getFormatRouterBase;