swico 0.1.0

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.
Files changed (56) hide show
  1. package/package.json +90 -0
  2. package/src/bin.d.ts +2 -0
  3. package/src/bin.js +46 -0
  4. package/src/command/build.d.ts +1 -0
  5. package/src/command/build.js +91 -0
  6. package/src/command/start.d.ts +1 -0
  7. package/src/command/start.js +166 -0
  8. package/src/config/webpack.base.react.d.ts +82 -0
  9. package/src/config/webpack.base.react.js +286 -0
  10. package/src/config/webpack.base.vue.d.ts +106 -0
  11. package/src/config/webpack.base.vue.js +303 -0
  12. package/src/config/webpack.dev.d.ts +2 -0
  13. package/src/config/webpack.dev.js +140 -0
  14. package/src/config/webpack.prod.d.ts +2 -0
  15. package/src/config/webpack.prod.js +183 -0
  16. package/src/index.d.ts +15 -0
  17. package/src/index.js +10 -0
  18. package/src/index.react.d.ts +19 -0
  19. package/src/index.react.js +19 -0
  20. package/src/index.vue.d.ts +34 -0
  21. package/src/index.vue.js +29 -0
  22. package/src/task.d.ts +1 -0
  23. package/src/task.js +61 -0
  24. package/src/template/global.d.ts +3 -0
  25. package/src/template/global.js +3 -0
  26. package/src/template/hooks/react.d.ts +12 -0
  27. package/src/template/hooks/react.js +45 -0
  28. package/src/template/hooks/vue.d.ts +2 -0
  29. package/src/template/hooks/vue.js +34 -0
  30. package/src/template/layout/Layout.d.ts +2 -0
  31. package/src/template/layout/Layout.js +6 -0
  32. package/src/template/layout/index.d.ts +4 -0
  33. package/src/template/layout/index.js +6 -0
  34. package/src/template/react/config.d.ts +3 -0
  35. package/src/template/react/config.js +5 -0
  36. package/src/template/react/history.d.ts +11 -0
  37. package/src/template/react/history.js +109 -0
  38. package/src/template/react/index.d.ts +11 -0
  39. package/src/template/react/index.js +63 -0
  40. package/src/template/react/loading.d.ts +2 -0
  41. package/src/template/react/loading.js +3 -0
  42. package/src/template/react/routes.d.ts +3 -0
  43. package/src/template/react/routes.js +3 -0
  44. package/src/template/vue/Container.d.ts +2 -0
  45. package/src/template/vue/Container.js +4 -0
  46. package/src/template/vue/Container.vue +7 -0
  47. package/src/template/vue/config.d.ts +3 -0
  48. package/src/template/vue/config.js +5 -0
  49. package/src/template/vue/index.d.ts +1 -0
  50. package/src/template/vue/index.js +46 -0
  51. package/src/template/vue/routes.d.ts +6 -0
  52. package/src/template/vue/routes.js +3 -0
  53. package/src/utils/config.d.ts +47 -0
  54. package/src/utils/config.js +394 -0
  55. package/src/utils/tools.d.ts +7 -0
  56. package/src/utils/tools.js +141 -0
package/src/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineGlobal = exports.defineConfig = exports.useLocation = exports.Link = exports.Outlet = void 0;
4
+ var Outlet, Link, useLocation;
5
+ var defineConfig = function (env, config) { return config; };
6
+ exports.defineConfig = defineConfig;
7
+ var defineGlobal = function (config) {
8
+ return config;
9
+ };
10
+ exports.defineGlobal = defineGlobal;
@@ -0,0 +1,19 @@
1
+ import { GlobalData, GlobalSecywoConfigType } from './utils/config';
2
+ import { CSSProperties, FC, ReactNode } from 'react';
3
+ export type CustomConfigType = GlobalData['customConfig'];
4
+ export type { GlobalSecywoConfigType };
5
+ export declare const Link: FC<{
6
+ replace?: boolean;
7
+ to: string;
8
+ style?: CSSProperties;
9
+ className?: string;
10
+ children: ReactNode;
11
+ }>;
12
+ export { Outlet } from 'react-router-dom';
13
+ export { useLocation } from './template/hooks/react';
14
+ export interface DefineSecywoConfigType {
15
+ (env: 'base', config: CustomConfigType['base']): any;
16
+ (env: 'dev', config: CustomConfigType['dev']): any;
17
+ (env: 'prod', config: CustomConfigType['prod']): any;
18
+ }
19
+ export declare const defineConfig: DefineSecywoConfigType;
@@ -0,0 +1,19 @@
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.defineConfig = exports.useLocation = exports.Outlet = exports.Link = void 0;
7
+ var react_router_dom_1 = require("react-router-dom");
8
+ var react_1 = __importDefault(require("react"));
9
+ var Link = function (_a) {
10
+ var replace = _a.replace, to = _a.to, style = _a.style, className = _a.className, children = _a.children;
11
+ return react_1.default.createElement(react_router_dom_1.Link, { replace: replace, to: to, style: style, className: className }, children);
12
+ };
13
+ exports.Link = Link;
14
+ var react_router_dom_2 = require("react-router-dom");
15
+ Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return react_router_dom_2.Outlet; } });
16
+ var react_2 = require("./template/hooks/react");
17
+ Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return react_2.useLocation; } });
18
+ var defineConfig = function (env, config) { return config; };
19
+ exports.defineConfig = defineConfig;
@@ -0,0 +1,34 @@
1
+ import { GlobalData, GlobalSecywoConfigType } from './utils/config';
2
+ import { App } from 'vue';
3
+ import { Router } from 'vue-router';
4
+ export type CustomConfigType = GlobalData['customConfig'];
5
+ export { RouterView as Outlet } from 'vue-router';
6
+ export { useLocation } from './template/hooks/vue';
7
+ export type { GlobalSecywoConfigType };
8
+ export declare const Link: import("vue").DefineComponent<{
9
+ to: {
10
+ type: StringConstructor;
11
+ };
12
+ replace: {
13
+ type: BooleanConstructor;
14
+ };
15
+ }, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ to: {
17
+ type: StringConstructor;
18
+ };
19
+ replace: {
20
+ type: BooleanConstructor;
21
+ };
22
+ }>>, {
23
+ replace: boolean;
24
+ }, {}>;
25
+ export interface DefineSecywoConfigType {
26
+ (env: 'base', config: CustomConfigType['base']): any;
27
+ (env: 'dev', config: CustomConfigType['dev']): any;
28
+ (env: 'prod', config: CustomConfigType['prod']): any;
29
+ }
30
+ export declare const defineConfig: DefineSecywoConfigType;
31
+ export interface DefineGlobalConfigType {
32
+ onInit?: (app: App, router: Router) => void;
33
+ }
34
+ export declare const defineGlobal: (config: DefineGlobalConfigType) => DefineGlobalConfigType;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineGlobal = exports.defineConfig = exports.Link = exports.useLocation = exports.Outlet = void 0;
4
+ var vue_1 = require("vue");
5
+ var vue_router_1 = require("vue-router");
6
+ var vue_router_2 = require("vue-router");
7
+ Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return vue_router_2.RouterView; } });
8
+ var vue_2 = require("./template/hooks/vue");
9
+ Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return vue_2.useLocation; } });
10
+ exports.Link = (0, vue_1.defineComponent)({
11
+ components: {
12
+ RouterLink: vue_router_1.RouterLink
13
+ },
14
+ props: {
15
+ to: {
16
+ type: String
17
+ },
18
+ replace: {
19
+ type: Boolean
20
+ }
21
+ },
22
+ template: '<RouterLink :to="to" :replace="replace" ><slot></slot></RouterLink>'
23
+ });
24
+ var defineConfig = function (env, config) { return config; };
25
+ exports.defineConfig = defineConfig;
26
+ var defineGlobal = function (config) {
27
+ return config;
28
+ };
29
+ exports.defineGlobal = defineGlobal;
package/src/task.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/src/task.js ADDED
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var fs_extra_1 = __importDefault(require("fs-extra"));
43
+ var path_1 = __importDefault(require("path"));
44
+ var copyVueFiles = function () { return __awaiter(void 0, void 0, void 0, function () {
45
+ var filePath, targetPath;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
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
+ return [4, fs_extra_1.default.copyFile(filePath, targetPath)];
52
+ case 1:
53
+ _a.sent();
54
+ return [2];
55
+ }
56
+ });
57
+ }); };
58
+ var main = function () {
59
+ copyVueFiles();
60
+ };
61
+ main();
@@ -0,0 +1,3 @@
1
+ import { DefineGlobalConfigType } from '../index.vue';
2
+ declare const _default: DefineGlobalConfigType;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {};
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,45 @@
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 compareURLPatterns = function (urlPatternWithValues, urlPatternWithParams) {
11
+ var patternWithValuesParts = urlPatternWithValues.split('/');
12
+ var patternWithParamsParts = urlPatternWithParams.split('/');
13
+ if (patternWithValuesParts.length !== patternWithParamsParts.length) {
14
+ return false;
15
+ }
16
+ for (var i = 0; i < patternWithValuesParts.length; i++) {
17
+ var valuePart = patternWithValuesParts[i];
18
+ var paramPart = patternWithParamsParts[i];
19
+ if (paramPart.startsWith(':') && paramPart !== '') {
20
+ continue;
21
+ }
22
+ if (valuePart !== paramPart) {
23
+ return false;
24
+ }
25
+ }
26
+ return true;
27
+ };
28
+ var useLocation = function () {
29
+ var _a, _b;
30
+ var location = (0, react_router_dom_1.useLocation)();
31
+ var params = (0, react_router_dom_1.useParams)();
32
+ var search = location.search, hash = location.hash, pathname = location.pathname;
33
+ var name = (_a = history_1.pathNameList.find(function (item) { return (params && compareURLPatterns(pathname, item.path)) || item.path === pathname; })) === null || _a === void 0 ? void 0 : _a.name;
34
+ var query = search ? qs_1.default.parse(search.startsWith('?') ? search.slice(1) : search) : {};
35
+ return {
36
+ name: name,
37
+ path: pathname,
38
+ pathname: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.pathname,
39
+ search: search,
40
+ query: query,
41
+ hash: hash,
42
+ params: params
43
+ };
44
+ };
45
+ exports.useLocation = useLocation;
@@ -0,0 +1,2 @@
1
+ import { UseLocationType } from './react';
2
+ export declare const useLocation: UseLocationType;
@@ -0,0 +1,34 @@
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 vue_router_1 = require("vue-router");
8
+ var qs_1 = __importDefault(require("qs"));
9
+ var vue_1 = require("vue");
10
+ var useLocation = function () {
11
+ var route = (0, vue_router_1.useRoute)();
12
+ var location = (0, vue_1.reactive)({
13
+ name: '',
14
+ path: '',
15
+ search: '',
16
+ hash: '',
17
+ pathname: '',
18
+ params: {},
19
+ query: {}
20
+ });
21
+ (0, vue_1.watchEffect)(function () {
22
+ var hash = route.hash, path = route.path, params = route.params, fullPath = route.fullPath, query = route.query, name = route.name;
23
+ var search = query ? qs_1.default.stringify(query) : '';
24
+ location.name = name;
25
+ location.path = path;
26
+ location.pathname = fullPath;
27
+ location.search = search;
28
+ location.query = query;
29
+ location.hash = hash;
30
+ location.params = params;
31
+ });
32
+ return location;
33
+ };
34
+ exports.useLocation = useLocation;
@@ -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,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var vue_1 = require("vue");
4
+ exports.default = (0, vue_1.defineComponent)({
5
+ template: '<template><slot></slot></template>'
6
+ });
@@ -0,0 +1,4 @@
1
+ declare const _default: ({ children }: {
2
+ children: any;
3
+ }) => any;
4
+ export default _default;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (function (_a) {
4
+ var children = _a.children;
5
+ return children;
6
+ });
@@ -0,0 +1,3 @@
1
+ import { ConfigRouterType } from '../../utils/config';
2
+ export declare const routerType: ConfigRouterType['type'];
3
+ export declare const routerBase: ConfigRouterType['base'];
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.routerBase = exports.routerType = void 0;
4
+ exports.routerType = 'browser';
5
+ exports.routerBase = '/';
@@ -0,0 +1,11 @@
1
+ import { ConfigRouterType } from '../../utils/config';
2
+ export { unstable_HistoryRouter as HistoryRouter } from 'react-router-dom';
3
+ export declare const formatAncPath: (ancPath: string) => string;
4
+ export declare const pathNameList: {
5
+ path: string;
6
+ name: string;
7
+ }[];
8
+ export declare const getHistory: (routerBase: ConfigRouterType['base'], routerType: ConfigRouterType['type']) => {
9
+ history: SecywoHistoryType;
10
+ originalHistory: import("history").HashHistory;
11
+ };
@@ -0,0 +1,109 @@
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.getHistory = exports.pathNameList = exports.formatAncPath = exports.HistoryRouter = void 0;
7
+ var routes_1 = __importDefault(require("./routes"));
8
+ var qs_1 = __importDefault(require("qs"));
9
+ var history_1 = require("history");
10
+ var react_router_dom_1 = require("react-router-dom");
11
+ Object.defineProperty(exports, "HistoryRouter", { enumerable: true, get: function () { return react_router_dom_1.unstable_HistoryRouter; } });
12
+ var interpolatePath = function (pathTemplate, params) {
13
+ var pathParts = pathTemplate.split('/');
14
+ var interpolatedParts = pathParts.map(function (part) {
15
+ var paramMatch = part.match(/^\:(.+)$/);
16
+ if (paramMatch) {
17
+ var paramName = paramMatch[1];
18
+ if (params[paramName]) {
19
+ return params[paramName];
20
+ }
21
+ else {
22
+ throw "Missing required params '".concat(paramName, "'");
23
+ }
24
+ }
25
+ return part;
26
+ });
27
+ return interpolatedParts.join('/');
28
+ };
29
+ var formatAncPath = function (ancPath) {
30
+ var newAncPath = ancPath.startsWith('/') ? ancPath : '/' + ancPath;
31
+ newAncPath = newAncPath.endsWith('/') ? newAncPath.slice(0, -1) : newAncPath;
32
+ return newAncPath;
33
+ };
34
+ exports.formatAncPath = formatAncPath;
35
+ var getPathNameList = function () {
36
+ var list = [];
37
+ var checkRouteItem = function (item, ancPath) {
38
+ var path = item.path, name = item.name, children = item.children;
39
+ var newAncPath = "".concat((0, exports.formatAncPath)(ancPath)).concat(path.startsWith('/') ? path : '/' + path);
40
+ list.push({ path: newAncPath, name: name });
41
+ if (children) {
42
+ children.some(function (item) { return checkRouteItem(item, newAncPath); });
43
+ }
44
+ };
45
+ routes_1.default.forEach(function (item) { return checkRouteItem(item, ''); });
46
+ return list;
47
+ };
48
+ exports.pathNameList = getPathNameList();
49
+ var getFormatHistoryOption = function (to, formatRouterBase, pathList, type) {
50
+ var _a;
51
+ var params = to.params, path = to.path, hash = to.hash, name = to.name, query = to.query;
52
+ var obj = {
53
+ hash: hash,
54
+ search: query ? qs_1.default.stringify(query) : undefined
55
+ };
56
+ if (path) {
57
+ obj.pathname = "".concat(formatRouterBase).concat(path);
58
+ }
59
+ if (name) {
60
+ var fullPath = (_a = pathList.find(function (item) { return item.name === name; })) === null || _a === void 0 ? void 0 : _a.path;
61
+ var targetPath = fullPath ? interpolatePath(fullPath, params) : null;
62
+ if (targetPath) {
63
+ obj.pathname = "".concat(formatRouterBase).concat(targetPath);
64
+ }
65
+ else {
66
+ throw "An error occurred while executing 'Navigation.".concat(type, "' operation: The path for the name \"").concat(name, "\" could not be found");
67
+ }
68
+ }
69
+ return obj;
70
+ };
71
+ var getHistory = function (routerBase, routerType) {
72
+ var _a;
73
+ var history;
74
+ var originalHistory = (_a = (routerType === 'hash' ? history_1.createHashHistory : history_1.createBrowserHistory)) === null || _a === void 0 ? void 0 : _a();
75
+ var lastIndexBase = routerBase[routerBase.length - 1];
76
+ var formatRouterBase = lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
77
+ history = {
78
+ go: originalHistory.go,
79
+ back: originalHistory.back,
80
+ push: function (to) {
81
+ switch (typeof to) {
82
+ case 'string':
83
+ originalHistory.push("".concat(formatRouterBase).concat(to));
84
+ break;
85
+ case 'object':
86
+ var formatOption = getFormatHistoryOption(to, formatRouterBase, exports.pathNameList, 'push');
87
+ originalHistory.push(formatOption);
88
+ break;
89
+ default:
90
+ throw "An error occurred while executing Navigation.push operation: unexpected type of 'to':".concat(typeof to);
91
+ }
92
+ },
93
+ replace: function (to) {
94
+ switch (typeof to) {
95
+ case 'string':
96
+ originalHistory.replace("".concat(formatRouterBase).concat(to));
97
+ break;
98
+ case 'object':
99
+ var formatOption = getFormatHistoryOption(to, formatRouterBase, exports.pathNameList, 'replace');
100
+ originalHistory.replace(formatOption);
101
+ break;
102
+ default:
103
+ throw "An error occurred while executing Navigation.replace operation: unexpected type of 'to':".concat(typeof to);
104
+ }
105
+ }
106
+ };
107
+ return { history: history, originalHistory: originalHistory };
108
+ };
109
+ exports.getHistory = getHistory;
@@ -0,0 +1,11 @@
1
+ import { FC } from 'react';
2
+ import '../global';
3
+ export type RoutesItemType = {
4
+ component?: () => Promise<{
5
+ default: FC;
6
+ }>;
7
+ children?: RoutesItemType[];
8
+ path: string;
9
+ redirect?: string;
10
+ name?: string;
11
+ };
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ var client_1 = require("react-dom/client");
30
+ var react_1 = __importStar(require("react"));
31
+ var react_router_dom_1 = require("react-router-dom");
32
+ var layout_1 = __importDefault(require("../layout"));
33
+ var routes_1 = __importDefault(require("./routes"));
34
+ var loading_1 = __importDefault(require("./loading"));
35
+ var history_1 = require("./history");
36
+ var config_1 = require("./config");
37
+ require("../global");
38
+ var renderChildrenRouteList = function (childrenRoutes, ancPathKey) {
39
+ return childrenRoutes === null || childrenRoutes === void 0 ? void 0 : childrenRoutes.map(function (item) {
40
+ var component = item.component, path = item.path, children = item.children, redirect = item.redirect;
41
+ var newAncPathKey = "".concat(ancPathKey, "-").concat(path);
42
+ return (react_1.default.createElement(react_router_dom_1.Route, { element: redirect ? (react_1.default.createElement(react_router_dom_1.Navigate, { to: redirect, replace: true })) : component ? (react_1.default.createElement(react_1.Suspense, { fallback: (0, react_1.createElement)(loading_1.default) }, (0, react_1.createElement)((0, react_1.lazy)(component)))) : (react_1.default.createElement(react_router_dom_1.Outlet, null)), key: newAncPathKey, path: path }, renderChildrenRouteList(children, newAncPathKey)));
43
+ });
44
+ };
45
+ var App = function () {
46
+ var _a = (0, history_1.getHistory)(config_1.routerBase, config_1.routerType), history = _a.history, originalHistory = _a.originalHistory;
47
+ if (config_1.routerBase && config_1.routerBase !== '/') {
48
+ if (config_1.routerType === 'hash' && ['', '/'].includes(window.location.hash)) {
49
+ window.location.replace("/#".concat(config_1.routerBase));
50
+ }
51
+ else if (config_1.routerType === 'browser' && window.location.pathname === '/') {
52
+ window.location.replace("".concat(config_1.routerBase));
53
+ }
54
+ }
55
+ window.Secywo = {
56
+ history: history
57
+ };
58
+ return (react_1.default.createElement(history_1.HistoryRouter, { basename: config_1.routerBase, history: originalHistory },
59
+ react_1.default.createElement(layout_1.default, null,
60
+ react_1.default.createElement(react_router_dom_1.Routes, null, renderChildrenRouteList(routes_1.default, '')))));
61
+ };
62
+ var root = (0, client_1.createRoot)(document.getElementById('root'));
63
+ root.render(react_1.default.createElement(App, null));
@@ -0,0 +1,2 @@
1
+ declare const _default: () => any;
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (function () { return null; });
@@ -0,0 +1,3 @@
1
+ import { RoutesItemType } from './index';
2
+ declare const _default: RoutesItemType[];
3
+ 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)({});
@@ -0,0 +1,7 @@
1
+ <script setup lang="ts"></script>
2
+
3
+ <template>
4
+ <Layout><RouterView /></Layout>
5
+ </template>
6
+
7
+ <style scoped></style>
@@ -0,0 +1,3 @@
1
+ import { ConfigRouterType } from '../../utils/config';
2
+ export declare const routerType: ConfigRouterType['type'];
3
+ export declare const routerBase: ConfigRouterType['base'];
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.routerBase = exports.routerType = void 0;
4
+ exports.routerType = 'browser';
5
+ exports.routerBase = '/';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
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 router = (0, vue_router_1.createRouter)({
15
+ history: (config_1.routerType === 'hash' ? vue_router_1.createWebHashHistory : vue_router_1.createWebHistory)(config_1.routerBase),
16
+ routes: routes_1.default
17
+ });
18
+ var app = (0, vue_1.createApp)(Container_1.default);
19
+ var Secywo = { history: null };
20
+ Secywo.history = {
21
+ push: function (options) {
22
+ if (typeof options === 'string') {
23
+ router.push(options);
24
+ }
25
+ else {
26
+ var query = options.query, name_1 = options.name, hash = options.hash, params = options.params, path = options.path;
27
+ router.push({ name: name_1, path: path, query: query, hash: hash, params: params });
28
+ }
29
+ },
30
+ replace: function (options) {
31
+ if (typeof options === 'string') {
32
+ router.replace(options);
33
+ }
34
+ else {
35
+ var query = options.query, name_2 = options.name, hash = options.hash, params = options.params, path = options.path;
36
+ router.replace({ name: name_2, path: path, query: query, hash: hash, params: params });
37
+ }
38
+ },
39
+ go: router.go,
40
+ back: router.back
41
+ };
42
+ app.component('Layout', Layout_1.default);
43
+ app.use(router);
44
+ window.Secywo = Secywo;
45
+ (_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);
46
+ 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 = [];