swico 0.6.2-beta4 → 0.6.2-beta5

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.2-beta4",
3
+ "version": "0.6.2-beta5",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { GlobalData, GlobalSwicoConfigType } from './utils/config';
2
2
  export type CustomConfigType = GlobalData['customConfig'];
3
3
  export type { GlobalSwicoConfigType };
4
+ export { history } from './mock-history';
4
5
  declare let Outlet: any, Link: any, useLocation: any;
5
6
  export { Outlet, Link, useLocation };
6
7
  export interface DefineSwicoConfigType {
package/src/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineGlobal = exports.defineConfig = exports.useLocation = exports.Link = exports.Outlet = void 0;
3
+ exports.defineGlobal = exports.defineConfig = exports.useLocation = exports.Link = exports.Outlet = exports.history = void 0;
4
+ var mock_history_1 = require("./mock-history");
5
+ Object.defineProperty(exports, "history", { enumerable: true, get: function () { return mock_history_1.history; } });
4
6
  var Outlet, Link, useLocation;
5
7
  var defineConfig = function (env, config) { return config; };
6
8
  exports.defineConfig = defineConfig;
@@ -11,7 +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
+ export { history } from './mock-history';
15
15
  export interface DefineSwicoConfigType {
16
16
  (env: 'base', config: CustomConfigType['base']): any;
17
17
  (env: 'dev', config: CustomConfigType['dev']): any;
@@ -15,8 +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
+ var mock_history_1 = require("./mock-history");
19
+ Object.defineProperty(exports, "history", { enumerable: true, get: function () { return mock_history_1.history; } });
20
20
  var defineConfig = function (env, config) { return config; };
21
21
  exports.defineConfig = defineConfig;
22
22
  var defineGlobal = function (config) {
@@ -4,7 +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
+ export { history } from './mock-history';
8
8
  export type { GlobalSwicoConfigType };
9
9
  export declare const Link: import("vue").DefineComponent<{
10
10
  to: {
package/src/index.vue.js CHANGED
@@ -7,8 +7,8 @@ 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
+ var mock_history_1 = require("./mock-history");
11
+ Object.defineProperty(exports, "history", { enumerable: true, get: function () { return mock_history_1.history; } });
12
12
  exports.Link = (0, vue_1.defineComponent)({
13
13
  components: {
14
14
  RouterLink: vue_router_1.RouterLink
@@ -0,0 +1 @@
1
+ export declare const history: SwicoHistoryType;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.history = void 0;
4
+ exports.history = {};
@@ -1,6 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import '../../global';
3
- export declare let history: any;
3
+ export declare const history: SwicoHistoryType;
4
4
  export type RoutesItemType = {
5
5
  component?: () => Promise<{
6
6
  default: FC;
@@ -36,6 +36,8 @@ var history_1 = require("./history");
36
36
  var config_1 = require("./config");
37
37
  require("../../global");
38
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;
39
41
  var renderChildrenRouteList = function (childrenRoutes, ancPathKey) {
40
42
  return childrenRoutes === null || childrenRoutes === void 0 ? void 0 : childrenRoutes.map(function (item) {
41
43
  var component = item.component, path = item.path, children = item.children, redirect = item.redirect;
@@ -44,8 +46,6 @@ var renderChildrenRouteList = function (childrenRoutes, ancPathKey) {
44
46
  });
45
47
  };
46
48
  var App = function () {
47
- var _a = (0, history_1.getHistory)(config_1.routerBase, config_1.routerType), swicoHistory = _a.history, originalHistory = _a.originalHistory;
48
- exports.history = swicoHistory;
49
49
  if (config_1.routerBase && config_1.routerBase !== '/') {
50
50
  if (config_1.routerType === 'browser' && window.location.pathname === '/') {
51
51
  window.location.replace("".concat(config_1.routerBase));
@@ -223,7 +223,7 @@ var getFormatRouter = function (routes, templateType) {
223
223
  });
224
224
  };
225
225
  var initCliIndexFile = function (templateType, env) { return __awaiter(void 0, void 0, void 0, function () {
226
- var targetPath, targetTypesPath, replaceFileText, fileTypesText, formatHooksPath, formatHistoryPath, formatHistoryPath;
226
+ var targetPath, targetTypesPath, replaceFileText, fileTypesText, formatHooksPath, formatHistoryPath;
227
227
  return __generator(this, function (_a) {
228
228
  switch (_a.label) {
229
229
  case 0:
@@ -235,22 +235,14 @@ var initCliIndexFile = function (templateType, env) { return __awaiter(void 0, v
235
235
  return [4, fs_extra_1.default.readFile(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".d.ts")), 'utf8')];
236
236
  case 2:
237
237
  fileTypesText = _a.sent();
238
- if (templateType === 'react') {
239
- formatHooksPath = path_1.default
240
- .resolve(projectPath, './src/.swico/react-hooks')
241
- .replaceAll('\\', '/');
242
- replaceFileText = replaceFileText.replaceAll('require("./template/react/react-hooks");', "require(\"".concat(formatHooksPath, "\");"));
243
- formatHistoryPath = path_1.default
244
- .resolve(projectPath, "./src/.swico/.".concat(env, "/index"))
245
- .replaceAll('\\', '/');
246
- replaceFileText = replaceFileText.replaceAll('require("./template/react/$env/index");', "require(\"".concat(formatHistoryPath, "\");"));
247
- }
248
- else {
249
- formatHistoryPath = path_1.default
250
- .resolve(projectPath, "./src/.swico/.".concat(env, "/index"))
251
- .replaceAll('\\', '/');
252
- replaceFileText = replaceFileText.replaceAll('require("./template/vue/$env/index");', "require(\"".concat(formatHistoryPath, "\");"));
253
- }
238
+ formatHooksPath = path_1.default
239
+ .resolve(projectPath, './src/.swico/react-hooks')
240
+ .replaceAll('\\', '/');
241
+ replaceFileText = replaceFileText.replaceAll('require("./template/react/react-hooks");', "require(\"".concat(formatHooksPath, "\");"));
242
+ formatHistoryPath = path_1.default
243
+ .resolve(projectPath, "./src/.swico/.".concat(env, "/index"))
244
+ .replaceAll('\\', '/');
245
+ replaceFileText = replaceFileText.replaceAll('require("./mock-history");', "require(\"".concat(formatHistoryPath, "\");"));
254
246
  return [4, fs_extra_1.default.writeFile(targetPath, replaceFileText)];
255
247
  case 3:
256
248
  _a.sent();
@@ -213,7 +213,7 @@ var initIndexFile = function (env) { return __awaiter(void 0, void 0, void 0, fu
213
213
  .resolve(process.cwd(), "./src/.swico/.".concat(env, "/index"))
214
214
  .replaceAll('\\', '/');
215
215
  if (!fileText.includes("require(\"".concat(formatHistoryPath, "\");"))) return [3, 5];
216
- fileText = fileText.replaceAll("require(\"".concat(formatHistoryPath, "\");"), 'require("./template/react/$env/index");');
216
+ fileText = fileText.replaceAll("require(\"".concat(formatHistoryPath, "\");"), 'require("./mock-history");');
217
217
  return [4, fs_extra_1.default.writeFile(targetPath, fileText)];
218
218
  case 4:
219
219
  _a.sent();