swico 0.6.0-beta32 → 0.6.0-beta34

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-beta32",
3
+ "version": "0.6.0-beta34",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -10,7 +10,7 @@ export declare const Link: FC<{
10
10
  children: ReactNode;
11
11
  }>;
12
12
  export { Outlet } from 'react-router-dom';
13
- export { useLocation } from './template/react/hooks';
13
+ export { useLocation } from './template/react/react-hooks';
14
14
  export interface DefineSwicoConfigType {
15
15
  (env: 'base', config: CustomConfigType['base']): any;
16
16
  (env: 'dev', config: CustomConfigType['dev']): any;
@@ -13,8 +13,8 @@ var Link = function (_a) {
13
13
  exports.Link = Link;
14
14
  var react_router_dom_2 = require("react-router-dom");
15
15
  Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return react_router_dom_2.Outlet; } });
16
- var hooks_1 = require("./template/react/hooks");
17
- Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return hooks_1.useLocation; } });
16
+ var react_hooks_1 = require("./template/react/react-hooks");
17
+ Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return react_hooks_1.useLocation; } });
18
18
  var defineConfig = function (env, config) { return config; };
19
19
  exports.defineConfig = defineConfig;
20
20
  var defineGlobal = function (config) {
@@ -3,7 +3,7 @@ import { App } from 'vue';
3
3
  import { Router } from 'vue-router';
4
4
  export type CustomConfigType = GlobalData['customConfig'];
5
5
  export { RouterView as Outlet } from 'vue-router';
6
- export { useLocation } from './template/vue/hooks';
6
+ export { useLocation } from './template/vue/vue-hooks';
7
7
  export type { GlobalSwicoConfigType };
8
8
  export declare const Link: import("vue").DefineComponent<{
9
9
  to: {
package/src/index.vue.js CHANGED
@@ -5,8 +5,8 @@ var vue_1 = require("vue");
5
5
  var vue_router_1 = require("vue-router");
6
6
  var vue_router_2 = require("vue-router");
7
7
  Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return vue_router_2.RouterView; } });
8
- var hooks_1 = require("./template/vue/hooks");
9
- Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return hooks_1.useLocation; } });
8
+ var vue_hooks_1 = require("./template/vue/vue-hooks");
9
+ Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return vue_hooks_1.useLocation; } });
10
10
  exports.Link = (0, vue_1.defineComponent)({
11
11
  components: {
12
12
  RouterLink: vue_router_1.RouterLink
package/src/task.js CHANGED
@@ -46,8 +46,8 @@ var copyVueFiles = function () { return __awaiter(void 0, void 0, void 0, functi
46
46
  return __generator(this, function (_a) {
47
47
  switch (_a.label) {
48
48
  case 0:
49
- filePath = path_1.default.resolve(__dirname, './template/vue/.env/Container.vue');
50
- targetPath = path_1.default.resolve(__dirname, '../dist/src/template/vue/.env/Container.vue');
49
+ filePath = path_1.default.resolve(__dirname, './template/vue/Container.vue');
50
+ targetPath = path_1.default.resolve(__dirname, '../dist/src/template/vue/Container.vue');
51
51
  return [4, fs_extra_1.default.copyFile(filePath, targetPath)];
52
52
  case 1:
53
53
  _a.sent();
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.useLocation = void 0;
7
7
  var react_router_dom_1 = require("react-router-dom");
8
- var history_1 = require("./.env/history");
8
+ var history_1 = require("./$env/history");
9
9
  var qs_1 = __importDefault(require("qs"));
10
10
  var compareURLPatterns = function (urlPatternWithValues, urlPatternWithParams) {
11
11
  var patternWithValuesParts = urlPatternWithValues.split('/');
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ var _a;
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ var vue_1 = require("vue");
8
+ var routes_1 = __importDefault(require("./routes"));
9
+ var vue_router_1 = require("vue-router");
10
+ var Container_1 = __importDefault(require("../Container"));
11
+ var config_1 = require("./config");
12
+ var Layout_1 = __importDefault(require("../../layout/Layout"));
13
+ var global_1 = __importDefault(require("../../global"));
14
+ var qs_1 = __importDefault(require("qs"));
15
+ var router = (0, vue_router_1.createRouter)({
16
+ history: (config_1.routerType === 'hash' ? vue_router_1.createWebHashHistory : vue_router_1.createWebHistory)(config_1.routerBase),
17
+ routes: routes_1.default
18
+ });
19
+ var app = (0, vue_1.createApp)(Container_1.default);
20
+ var Swico = { history: null };
21
+ Swico.history = {
22
+ push: function (options) {
23
+ if (typeof options === 'string') {
24
+ router.push(options);
25
+ }
26
+ else {
27
+ var query = options.query, name_1 = options.name, hash = options.hash, params = options.params, path = options.path;
28
+ router.push({ name: name_1, path: path, query: query, hash: hash, params: params });
29
+ }
30
+ },
31
+ replace: function (options) {
32
+ if (typeof options === 'string') {
33
+ router.replace(options);
34
+ }
35
+ else {
36
+ var query = options.query, name_2 = options.name, hash = options.hash, params = options.params, path = options.path;
37
+ router.replace({ name: name_2, path: path, query: query, hash: hash, params: params });
38
+ }
39
+ },
40
+ go: router.go,
41
+ back: router.back,
42
+ forward: router.forward,
43
+ get location() {
44
+ var lastIndexBase = config_1.routerBase[config_1.routerBase.length - 1];
45
+ var formatRouterBase = lastIndexBase === '/' ? config_1.routerBase.slice(0, config_1.routerBase.length - 1) : config_1.routerBase;
46
+ var _a = router.currentRoute.value, path = _a.path, params = _a.params, query = _a.query, name = _a.name, hash = _a.hash, fullPath = _a.fullPath;
47
+ return {
48
+ path: path,
49
+ pathname: formatRouterBase + path,
50
+ params: params,
51
+ query: query,
52
+ name: name,
53
+ hash: hash,
54
+ search: query ? qs_1.default.stringify(query) : ''
55
+ };
56
+ }
57
+ };
58
+ app.component('Layout', Layout_1.default);
59
+ app.use(router);
60
+ window.Swico = Swico;
61
+ (_a = global_1.default === null || global_1.default === void 0 ? void 0 : global_1.default.onInit) === null || _a === void 0 ? void 0 : _a.call(global_1.default, app, router);
62
+ app.mount('#root');
@@ -0,0 +1,6 @@
1
+ import { RouteRecordRaw } from 'vue-router';
2
+ type RouteItem = RouteRecordRaw & {
3
+ decorator?: string;
4
+ };
5
+ declare const _default: RouteItem[];
6
+ export default _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = [];
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var vue_1 = require("vue");
4
+ exports.default = (0, vue_1.defineComponent)({});
@@ -7,7 +7,7 @@ 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
- var config_1 = require("./.env/config");
10
+ var config_1 = require("./$env/config");
11
11
  var getFormatRouterBase = function (routerBase) {
12
12
  var lastIndexBase = routerBase[routerBase.length - 1];
13
13
  return lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
@@ -231,9 +231,9 @@ var initCliIndexFile = function (templateType) { return __awaiter(void 0, void 0
231
231
  fileTypesText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".d.ts")), 'utf8');
232
232
  if (templateType === 'react') {
233
233
  formatHooksPath = path_1.default
234
- .resolve(projectPath, './src/.swico/hooks')
234
+ .resolve(projectPath, './src/.swico/react-hooks')
235
235
  .replaceAll('\\', '/');
236
- replaceFileText = replaceFileText.replaceAll('require("./template/react/hooks");', "require(\"".concat(formatHooksPath, "\");"));
236
+ replaceFileText = replaceFileText.replaceAll('require("./template/react/react-hooks");', "require(\"".concat(formatHooksPath, "\");"));
237
237
  }
238
238
  return [4, (0, tools_1.writeFile)(targetPath, replaceFileText)];
239
239
  case 1:
@@ -283,69 +283,71 @@ var formatRouterConfig = function (_a, templateType, env) {
283
283
  var initTemplateConfig = function (routerConfig, templateType, env) {
284
284
  var envPath = env === 'dev' ? '/.dev/' : '/.prod/';
285
285
  return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
286
- var copyTargetPath, replaceIndexText, replaceHooksText, e_1, e_2;
286
+ var copyTargetPath, replaceIndexText, hooksFilePath, replaceHooksText, e_1, e_2;
287
287
  return __generator(this, function (_a) {
288
288
  switch (_a.label) {
289
289
  case 0:
290
290
  copyTargetPath = path_1.default.resolve(projectPath, "./src/.swico".concat(envPath));
291
- return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType, "/.env")), copyTargetPath, function (fileName) {
291
+ return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType, "/$env")), copyTargetPath, function (fileName) {
292
292
  return !fileName.endsWith('.d.ts') &&
293
293
  (templateType === 'vue'
294
- ? !['Container.js', 'hooks.js'].includes(fileName)
295
- : !['hooks.js'].includes(fileName));
294
+ ? !['Container.js', 'vue-hooks.js'].includes(fileName)
295
+ : !['react-hooks.js'].includes(fileName));
296
296
  })];
297
297
  case 1:
298
298
  _a.sent();
299
- return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), path_1.default.resolve(projectPath, './src/.swico'), function (fileName) { return ['hooks.js', 'loading.js'].includes(fileName); })];
299
+ return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../template/".concat(templateType)), path_1.default.resolve(projectPath, './src/.swico'), function (fileName) { return ['react-hooks.js', 'vue-hooks.js', 'loading.js'].includes(fileName); })];
300
300
  case 2:
301
301
  _a.sent();
302
302
  return [4, formatRouterConfig(routerConfig, templateType, env)];
303
303
  case 3:
304
304
  _a.sent();
305
305
  replaceIndexText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), 'utf8');
306
- replaceHooksText = fs_extra_1.default.readFileSync(path_1.default.resolve(projectPath, './src/.swico/hooks.js'), 'utf8');
307
- replaceHooksText = replaceHooksText.replaceAll('.env', ".".concat(env));
308
- _a.label = 4;
306
+ hooksFilePath = path_1.default.resolve(projectPath, "./src/.swico/".concat(templateType, "-hooks.js"));
307
+ replaceHooksText = fs_extra_1.default.readFileSync(hooksFilePath, 'utf8');
308
+ replaceHooksText = replaceHooksText.replaceAll('$env', ".".concat(env));
309
+ return [4, (0, tools_1.writeFile)(hooksFilePath, replaceHooksText)];
309
310
  case 4:
310
- _a.trys.push([4, 6, , 7]);
311
- return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/global.less'), fs_extra_1.default.constants.F_OK)];
311
+ _a.sent();
312
+ _a.label = 5;
312
313
  case 5:
314
+ _a.trys.push([5, 7, , 8]);
315
+ return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/global.less'), fs_extra_1.default.constants.F_OK)];
316
+ case 6:
313
317
  _a.sent();
314
318
  replaceIndexText = replaceIndexText.replaceAll('require("../../global.less");', '');
315
319
  replaceIndexText = 'require("../../global.less");\n' + replaceIndexText;
316
- return [3, 7];
317
- case 6:
320
+ return [3, 8];
321
+ case 7:
318
322
  e_1 = _a.sent();
319
323
  replaceIndexText = replaceIndexText.replaceAll('require("../../global.less");', '');
320
- return [3, 7];
321
- case 7:
322
- if (!(templateType === 'vue')) return [3, 9];
323
- replaceIndexText = replaceIndexText.replace('"./Container"', '"./Container.vue"');
324
- return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
324
+ return [3, 8];
325
325
  case 8:
326
- _a.sent();
327
- return [3, 15];
326
+ if (!(templateType === 'vue')) return [3, 10];
327
+ replaceIndexText = replaceIndexText.replace('"../Container"', '"../Container.vue"');
328
+ return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
328
329
  case 9:
329
- if (!(templateType === 'react')) return [3, 15];
330
- _a.label = 10;
330
+ _a.sent();
331
+ return [3, 16];
331
332
  case 10:
332
- _a.trys.push([10, 12, 13, 15]);
333
- return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
333
+ if (!(templateType === 'react')) return [3, 16];
334
+ _a.label = 11;
334
335
  case 11:
336
+ _a.trys.push([11, 13, 14, 16]);
337
+ return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
338
+ case 12:
335
339
  _a.sent();
336
340
  replaceIndexText = replaceIndexText.replace('"../loading"', '"../../loading"');
337
- return [3, 15];
338
- case 12:
341
+ return [3, 16];
342
+ case 13:
339
343
  e_2 = _a.sent();
340
344
  replaceIndexText = replaceIndexText.replace('"../../loading"', '"../loading"');
341
- return [3, 15];
342
- case 13: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
343
- case 14:
345
+ return [3, 16];
346
+ case 14: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, "./src/.swico".concat(envPath, "index.js")), replaceIndexText)];
347
+ case 15:
344
348
  _a.sent();
345
349
  return [7];
346
- case 15: return [4, (0, tools_1.writeFile)(path_1.default.resolve(projectPath, './src/.swico/hooks.js'), replaceHooksText)];
347
350
  case 16:
348
- _a.sent();
349
351
  resolve(null);
350
352
  return [2];
351
353
  }
@@ -174,15 +174,15 @@ var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, funct
174
174
  fileText = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, '../index.js'), 'utf8');
175
175
  targetPath = path_1.default.resolve(__dirname, '../index.js');
176
176
  formatHooksPath = path_1.default
177
- .resolve(process.cwd(), './src/.swico/hooks')
177
+ .resolve(process.cwd(), './src/.swico/react-hooks')
178
178
  .replaceAll('\\', '/');
179
- console.log('formatHooksPath', formatHooksPath);
180
- fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./template/react/hooks");');
181
- console.log('fileText', fileText);
179
+ if (!fileText.includes("require(\"".concat(formatHooksPath, "\");"))) return [3, 2];
180
+ fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./template/react/react-hooks");');
182
181
  return [4, (0, exports.writeFile)(targetPath, fileText)];
183
182
  case 1:
184
183
  _a.sent();
185
- return [2];
184
+ _a.label = 2;
185
+ case 2: return [2];
186
186
  }
187
187
  });
188
188
  }); };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes