swico 0.6.1-beta1 → 0.6.2-beta1

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.1-beta1",
3
+ "version": "0.6.2-beta1",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -21,8 +21,7 @@
21
21
  "scripts": {
22
22
  "compile": "tsc && ts-node ./src/task.ts",
23
23
  "publish:offical": "npm run compile && cd ./dist && npm publish",
24
- "publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta",
25
- "test": "ts-node ./test.ts"
24
+ "publish:beta": "npm run compile && cd ./dist && npm publish --tag=beta"
26
25
  },
27
26
  "repository": {
28
27
  "type": "git",
@@ -58,7 +58,7 @@ var config_1 = require("../utils/config");
58
58
  var chokidar_1 = __importDefault(require("chokidar"));
59
59
  var path_1 = __importDefault(require("path"));
60
60
  var cross_spawn_1 = __importDefault(require("cross-spawn"));
61
- var envPort = process.env.PORT;
61
+ var _a = process.env, envPort = _a.PORT, RESTART = _a.RESTART;
62
62
  var package_json_1 = __importDefault(require("../../package.json"));
63
63
  var handleWatch = function (projectPath, devServer) {
64
64
  var configFilesWatcher = chokidar_1.default
@@ -114,7 +114,7 @@ var handleWatch = function (projectPath, devServer) {
114
114
  };
115
115
  var availablePort;
116
116
  var restartServer = function () {
117
- var result = cross_spawn_1.default.sync('cross-env', ["PORT=".concat(availablePort), 'swico', 'start'], {
117
+ var result = cross_spawn_1.default.sync('cross-env', ["PORT=".concat(availablePort), 'RESTART=true', 'swico', 'start'], {
118
118
  stdio: 'inherit'
119
119
  });
120
120
  if (result.error) {
@@ -129,8 +129,10 @@ function start() {
129
129
  switch (_b.label) {
130
130
  case 0:
131
131
  process.env.SWICO_ENV = 'dev';
132
- tools_1.toast.info("Swico v".concat(package_json_1.default.version));
133
- tools_1.toast.info('Initializing Swico development config...');
132
+ if (RESTART !== 'true') {
133
+ tools_1.toast.info("Swico v".concat(package_json_1.default.version));
134
+ tools_1.toast.info('Initializing Swico development config...');
135
+ }
134
136
  return [4, (0, tools_1.initIndexFile)()];
135
137
  case 1:
136
138
  _b.sent();
@@ -11,6 +11,7 @@ export declare const Link: FC<{
11
11
  }>;
12
12
  export { Outlet } from 'react-router-dom';
13
13
  export { useLocation } from './template/react/react-hooks';
14
+ export { history } from './template/react/$env/index';
14
15
  export interface DefineSwicoConfigType {
15
16
  (env: 'base', config: CustomConfigType['base']): any;
16
17
  (env: 'dev', config: CustomConfigType['dev']): any;
@@ -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.defineGlobal = exports.defineConfig = exports.useLocation = exports.Outlet = exports.Link = void 0;
6
+ exports.defineGlobal = exports.defineConfig = exports.history = exports.useLocation = exports.Outlet = exports.Link = void 0;
7
7
  var react_router_dom_1 = require("react-router-dom");
8
8
  var react_1 = __importDefault(require("react"));
9
9
  var Link = function (_a) {
@@ -15,6 +15,8 @@ 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
16
  var react_hooks_1 = require("./template/react/react-hooks");
17
17
  Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return react_hooks_1.useLocation; } });
18
+ var index_1 = require("./template/react/$env/index");
19
+ Object.defineProperty(exports, "history", { enumerable: true, get: function () { return index_1.history; } });
18
20
  var defineConfig = function (env, config) { return config; };
19
21
  exports.defineConfig = defineConfig;
20
22
  var defineGlobal = function (config) {
@@ -4,6 +4,7 @@ import { Router } from 'vue-router';
4
4
  export type CustomConfigType = GlobalData['customConfig'];
5
5
  export { RouterView as Outlet } from 'vue-router';
6
6
  export { useLocation } from './template/vue/vue-hooks';
7
+ export { history } from './template/vue/$env/index';
7
8
  export type { GlobalSwicoConfigType };
8
9
  export declare const Link: import("vue").DefineComponent<{
9
10
  to: {
package/src/index.vue.js CHANGED
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineGlobal = exports.defineConfig = exports.Link = exports.useLocation = exports.Outlet = void 0;
3
+ exports.defineGlobal = exports.defineConfig = exports.Link = exports.history = exports.useLocation = exports.Outlet = void 0;
4
4
  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
8
  var vue_hooks_1 = require("./template/vue/vue-hooks");
9
9
  Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return vue_hooks_1.useLocation; } });
10
+ var index_1 = require("./template/vue/$env/index");
11
+ Object.defineProperty(exports, "history", { enumerable: true, get: function () { return index_1.history; } });
10
12
  exports.Link = (0, vue_1.defineComponent)({
11
13
  components: {
12
14
  RouterLink: vue_router_1.RouterLink
@@ -1,5 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import '../../global';
3
+ export declare let history: SwicoHistoryType;
3
4
  export type RoutesItemType = {
4
5
  component?: () => Promise<{
5
6
  default: FC;
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.history = void 0;
29
30
  var client_1 = require("react-dom/client");
30
31
  var react_1 = __importStar(require("react"));
31
32
  var react_router_dom_1 = require("react-router-dom");
@@ -35,6 +36,8 @@ var history_1 = require("./history");
35
36
  var config_1 = require("./config");
36
37
  require("../../global");
37
38
  var layout_1 = __importDefault(require("../../layout"));
39
+ var _a = (0, history_1.getHistory)(config_1.routerBase, config_1.routerType), swicoHistory = _a.history, originalHistory = _a.originalHistory;
40
+ exports.history = swicoHistory;
38
41
  var renderChildrenRouteList = function (childrenRoutes, ancPathKey) {
39
42
  return childrenRoutes === null || childrenRoutes === void 0 ? void 0 : childrenRoutes.map(function (item) {
40
43
  var component = item.component, path = item.path, children = item.children, redirect = item.redirect;
@@ -43,14 +46,13 @@ var renderChildrenRouteList = function (childrenRoutes, ancPathKey) {
43
46
  });
44
47
  };
45
48
  var App = function () {
46
- var _a = (0, history_1.getHistory)(config_1.routerBase, config_1.routerType), history = _a.history, originalHistory = _a.originalHistory;
47
49
  if (config_1.routerBase && config_1.routerBase !== '/') {
48
50
  if (config_1.routerType === 'browser' && window.location.pathname === '/') {
49
51
  window.location.replace("".concat(config_1.routerBase));
50
52
  }
51
53
  }
52
54
  window.Swico = {
53
- history: history
55
+ history: exports.history
54
56
  };
55
57
  return (react_1.default.createElement(history_1.HistoryRouter, { basename: config_1.routerBase, history: originalHistory },
56
58
  react_1.default.createElement(react_router_dom_1.Routes, null,
@@ -1 +1 @@
1
- export {};
1
+ export declare const history: SwicoHistoryType;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.history = void 0;
7
8
  var vue_1 = require("vue");
8
9
  var routes_1 = __importDefault(require("./routes"));
9
10
  var vue_router_1 = require("vue-router");
@@ -18,7 +19,7 @@ var router = (0, vue_router_1.createRouter)({
18
19
  });
19
20
  var app = (0, vue_1.createApp)(Container_1.default);
20
21
  var Swico = { history: null };
21
- Swico.history = {
22
+ exports.history = {
22
23
  push: function (options) {
23
24
  if (typeof options === 'string') {
24
25
  router.push(options);
@@ -55,6 +56,7 @@ Swico.history = {
55
56
  };
56
57
  }
57
58
  };
59
+ Swico.history = exports.history;
58
60
  app.component('Layout', Layout_1.default);
59
61
  app.use(router);
60
62
  window.Swico = Swico;