swico 0.6.0-beta22 → 0.6.0-beta24

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.6.0-beta22",
3
+ "version": "0.6.0-beta24",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -55,7 +55,7 @@ function default_1() {
55
55
  case 0:
56
56
  process.env.SWICO_ENV = 'prod';
57
57
  tools_1.toast.info("Swico v".concat(package_json_1.default.version));
58
- spinner.succeed('Initializing Swico production config...\n');
58
+ tools_1.toast.info('Initializing Swico production config...');
59
59
  return [4, (0, tools_1.initIndexFile)()];
60
60
  case 1:
61
61
  _a.sent();
@@ -132,7 +132,7 @@ function start() {
132
132
  case 0:
133
133
  process.env.SWICO_ENV = 'dev';
134
134
  tools_1.toast.info("Swico v".concat(package_json_1.default.version));
135
- spinner.succeed('Initializing Swico development config...\n');
135
+ tools_1.toast.info('Initializing Swico development config...\n');
136
136
  return [4, (0, tools_1.initIndexFile)()];
137
137
  case 1:
138
138
  _b.sent();
@@ -221,7 +221,7 @@ var getFormatRouter = function (routes, templateType) {
221
221
  });
222
222
  };
223
223
  var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0, void 0, function () {
224
- var targetPath, targetTypesPath, replaceFileText, fileTypesText;
224
+ var targetPath, targetTypesPath, replaceFileText, fileTypesText, formatHooksPath;
225
225
  return __generator(this, function (_a) {
226
226
  switch (_a.label) {
227
227
  case 0:
@@ -229,6 +229,12 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
229
229
  targetTypesPath = path_1.default.resolve(__dirname, '../index.d.ts');
230
230
  replaceFileText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".js")), 'utf8');
231
231
  fileTypesText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".d.ts")), 'utf8');
232
+ if (templateType === 'react') {
233
+ formatHooksPath = path_1.default
234
+ .resolve(projectPath, './src/.swico/hooks')
235
+ .replaceAll('\\', '/');
236
+ replaceFileText = replaceFileText.replaceAll('require("./template/react/hooks");', "require(\"".concat(formatHooksPath, "\");"));
237
+ }
232
238
  return [4, (0, tools_1.writeFile)(targetPath, replaceFileText)];
233
239
  case 1:
234
240
  _a.sent();
@@ -292,6 +298,7 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
292
298
  case 2:
293
299
  _a.sent();
294
300
  replaceIndexText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), 'utf8');
301
+ replaceIndexText = replaceIndexText.replaceAll('require("../global");', '');
295
302
  envAncPath = env === 'dev' ? '..' : '../..';
296
303
  _a.label = 3;
297
304
  case 3:
@@ -321,6 +328,9 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
321
328
  case 9:
322
329
  if (!(templateType === 'vue')) return [3, 11];
323
330
  replaceIndexText = replaceIndexText.replace('"./Container"', '"./Container.vue"');
331
+ if (env === 'prod') {
332
+ replaceIndexText = replaceIndexText.replaceAll('require("../layout/Layout")', 'require("../../layout/Layout")');
333
+ }
324
334
  return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
325
335
  case 10:
326
336
  _a.sent();
@@ -339,7 +349,11 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
339
349
  e_3 = _a.sent();
340
350
  replaceIndexText = replaceIndexText.replace('"../loading"', '"./loading"');
341
351
  return [3, 17];
342
- case 15: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
352
+ case 15:
353
+ if (env === 'prod') {
354
+ replaceIndexText = replaceIndexText.replaceAll('require("../layout")', 'require("../../layout")');
355
+ }
356
+ return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
343
357
  case 16:
344
358
  _a.sent();
345
359
  return [7];
@@ -176,6 +176,7 @@ var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, funct
176
176
  formatHooksPath = path_1.default
177
177
  .resolve(process.cwd(), './src/.swico/hooks')
178
178
  .replaceAll('\\', '/');
179
+ console.log('replace', "require(\"".concat(formatHooksPath, "\");"));
179
180
  fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./template/react/hooks");');
180
181
  return [4, (0, exports.writeFile)(targetPath, fileText)];
181
182
  case 1:
@@ -1,12 +0,0 @@
1
- export interface UseLocationType {
2
- (): {
3
- name: string;
4
- path: string;
5
- pathname: string;
6
- search: string;
7
- query?: Record<string, any>;
8
- hash: string;
9
- params?: Record<string, any>;
10
- };
11
- }
12
- export declare const useLocation: UseLocationType;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useLocation = void 0;
7
- var react_router_dom_1 = require("react-router-dom");
8
- var qs_1 = __importDefault(require("qs"));
9
- var history_1 = require("../react/history");
10
- var routes_1 = require("../react/routes");
11
- var compareURLPatterns = function (urlPatternWithValues, urlPatternWithParams) {
12
- var patternWithValuesParts = urlPatternWithValues.split('/');
13
- var patternWithParamsParts = urlPatternWithParams.split('/');
14
- if (patternWithValuesParts.length !== patternWithParamsParts.length) {
15
- return false;
16
- }
17
- for (var i = 0; i < patternWithValuesParts.length; i++) {
18
- var valuePart = patternWithValuesParts[i];
19
- var paramPart = patternWithParamsParts[i];
20
- if (paramPart.startsWith(':') && paramPart !== '') {
21
- continue;
22
- }
23
- if (valuePart !== paramPart) {
24
- return false;
25
- }
26
- }
27
- return true;
28
- };
29
- var useLocation = function () {
30
- var _a, _b;
31
- var location = (0, react_router_dom_1.useLocation)();
32
- var params = (0, react_router_dom_1.useParams)();
33
- var search = location.search, hash = location.hash, pathname = location.pathname;
34
- var pathNameList = (0, history_1.getPathNameList)(routes_1.routes);
35
- var name = (_a = pathNameList.find(function (item) { return (params && compareURLPatterns(pathname, item.path)) || item.path === pathname; })) === null || _a === void 0 ? void 0 : _a.name;
36
- var query = search ? qs_1.default.parse(search.startsWith('?') ? search.slice(1) : search) : {};
37
- return {
38
- name: name,
39
- path: pathname,
40
- pathname: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.pathname,
41
- search: search,
42
- query: query,
43
- hash: hash,
44
- params: params
45
- };
46
- };
47
- exports.useLocation = useLocation;
@@ -1,3 +0,0 @@
1
- import { UseLocationType } from './react';
2
- export declare const getFormatRouterBase: (routerBase: any) => any;
3
- export declare const useLocation: UseLocationType;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useLocation = exports.getFormatRouterBase = void 0;
7
- var vue_router_1 = require("vue-router");
8
- var qs_1 = __importDefault(require("qs"));
9
- var vue_1 = require("vue");
10
- var config_1 = require("../vue/config");
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;
16
- var useLocation = function () {
17
- var route = (0, vue_router_1.useRoute)();
18
- var location = (0, vue_1.reactive)({
19
- name: '',
20
- path: '',
21
- search: '',
22
- hash: '',
23
- pathname: '',
24
- params: {},
25
- query: {}
26
- });
27
- (0, vue_1.watchEffect)(function () {
28
- var hash = route.hash, path = route.path, params = route.params, fullPath = route.fullPath, query = route.query, name = route.name;
29
- var search = query ? qs_1.default.stringify(query) : '';
30
- location.name = name;
31
- location.path = path;
32
- location.pathname = (0, exports.getFormatRouterBase)(config_1.routerBase) + path;
33
- location.search = search;
34
- location.query = query;
35
- location.hash = hash;
36
- location.params = params;
37
- });
38
- return location;
39
- };
40
- exports.useLocation = useLocation;
@@ -1,3 +0,0 @@
1
- import { ConfigRouterType } from '../../utils/config';
2
- export declare const routerType: ConfigRouterType['type'];
3
- export declare const routerBase: ConfigRouterType['base'];
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.routerBase = exports.routerType = void 0;
4
- exports.routerType = 'browser';
5
- exports.routerBase = '/';
@@ -1,3 +0,0 @@
1
- import { RoutesItemType } from './index';
2
- declare const _default: RoutesItemType[];
3
- export default _default;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = [];
@@ -1,3 +0,0 @@
1
- import { ConfigRouterType } from '../../utils/config';
2
- export declare const routerType: ConfigRouterType['type'];
3
- export declare const routerBase: ConfigRouterType['base'];
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.routerBase = exports.routerType = void 0;
4
- exports.routerType = 'browser';
5
- exports.routerBase = '/';
@@ -1,6 +0,0 @@
1
- import { RouteRecordRaw } from 'vue-router';
2
- type RouteItem = RouteRecordRaw & {
3
- decorator?: string;
4
- };
5
- declare const _default: RouteItem[];
6
- export default _default;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = [];