swico 0.6.1 → 0.6.2-beta2

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",
3
+ "version": "0.6.2-beta2",
4
4
  "description": "Simple, efficient, and practical front-end framework",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -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
@@ -111,13 +111,14 @@ var getFormatHistoryOption = function (to, formatRouterBase, pathList, type) {
111
111
  obj.pathname = "".concat(formatRouterBase).concat(path);
112
112
  }
113
113
  if (name) {
114
+ console.log('pathList', pathList);
114
115
  var fullPath = (_a = pathList.find(function (item) { return item.name === name; })) === null || _a === void 0 ? void 0 : _a.path;
115
116
  var targetPath = fullPath ? interpolatePath(fullPath, params) : null;
116
117
  if (targetPath) {
117
118
  obj.pathname = "".concat(formatRouterBase).concat(targetPath);
118
119
  }
119
120
  else {
120
- throw "An error occurred while executing 'Navigation.".concat(type, "' operation: The path for the name \"").concat(name, "\" could not be found");
121
+ throw "An error occurred while executing 'history.".concat(type, "' operation: The path for the name \"").concat(name, "\" could not be found");
121
122
  }
122
123
  }
123
124
  return obj;
@@ -140,7 +141,7 @@ var getHistory = function (routerBase, routerType) {
140
141
  originalHistory.push(formatOption);
141
142
  break;
142
143
  default:
143
- throw "An error occurred while executing Navigation.push operation: unexpected type of 'to':".concat(typeof to);
144
+ throw "An error occurred while executing history.push operation: unexpected type of 'to':".concat(typeof to);
144
145
  }
145
146
  },
146
147
  replace: function (to) {
@@ -153,7 +154,7 @@ var getHistory = function (routerBase, routerType) {
153
154
  originalHistory.replace(formatOption);
154
155
  break;
155
156
  default:
156
- throw "An error occurred while executing Navigation.replace operation: unexpected type of 'to':".concat(typeof to);
157
+ throw "An error occurred while executing history.replace operation: unexpected type of 'to':".concat(typeof to);
157
158
  }
158
159
  },
159
160
  get location() {
@@ -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,8 +19,9 @@ 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) {
24
+ console.log('routes', routes_1.default);
23
25
  if (typeof options === 'string') {
24
26
  router.push(options);
25
27
  }
@@ -55,6 +57,7 @@ Swico.history = {
55
57
  };
56
58
  }
57
59
  };
60
+ Swico.history = exports.history;
58
61
  app.component('Layout', Layout_1.default);
59
62
  app.use(router);
60
63
  window.Swico = Swico;