swico 1.6.0-beta.4 → 1.6.0-beta.6
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 +1 -1
- package/src/index.react.d.ts +1 -1
- package/src/index.react.js +1 -1
- package/src/index.vue.d.ts +1 -1
- package/src/index.vue.js +1 -1
- package/src/{template/react → project-path/.swico-react}/$env/index.d.ts +1 -1
- package/src/{template/react → project-path/.swico-react}/$env/index.js +2 -2
- package/src/{template → project-path/src}/global.d.ts +1 -1
- package/src/task.js +2 -2
- package/src/utils/config.js +9 -15
- package/src/utils/tools.js +1 -1
- package/src/template/vue/$env/history.d.ts +0 -3
- package/src/template/vue/$env/history.js +0 -76
- package/src/template/vue/$env/index.d.ts +0 -1
- package/src/template/vue/$env/index.js +0 -17
- package/src/template/vue/$env/routes.d.ts +0 -6
- package/src/template/vue/$env/routes.js +0 -3
- package/src/template/vue/Container.d.ts +0 -2
- package/src/template/vue/Container.js +0 -4
- /package/src/{template/react → project-path/.swico-react}/$env/config.d.ts +0 -0
- /package/src/{template/react → project-path/.swico-react}/$env/config.js +0 -0
- /package/src/{template/react → project-path/.swico-react}/$env/history.d.ts +0 -0
- /package/src/{template/react → project-path/.swico-react}/$env/history.js +0 -0
- /package/src/{template/react → project-path/.swico-react}/$env/routes.d.ts +0 -0
- /package/src/{template/react → project-path/.swico-react}/$env/routes.js +0 -0
- /package/src/{template/react → project-path/.swico-react}/loading.d.ts +0 -0
- /package/src/{template/react → project-path/.swico-react}/loading.js +0 -0
- /package/src/{template/react → project-path/.swico-react}/react-hooks.d.ts +0 -0
- /package/src/{template/react → project-path/.swico-react}/react-hooks.js +0 -0
- /package/src/{template/vue → project-path/.swico-vue}/$env/config.d.ts +0 -0
- /package/src/{template/vue → project-path/.swico-vue}/$env/config.js +0 -0
- /package/src/{template/vue → project-path/.swico-vue}/Container.vue +0 -0
- /package/src/{template/vue → project-path/.swico-vue}/vue-hooks.d.ts +0 -0
- /package/src/{template/vue → project-path/.swico-vue}/vue-hooks.js +0 -0
- /package/src/{template → project-path/src}/global.js +0 -0
- /package/src/{template → project-path/src}/layout/Layout.d.ts +0 -0
- /package/src/{template → project-path/src}/layout/Layout.js +0 -0
- /package/src/{template → project-path/src}/layout/index.d.ts +0 -0
- /package/src/{template → project-path/src}/layout/index.js +0 -0
package/package.json
CHANGED
package/src/index.react.d.ts
CHANGED
|
@@ -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, useNav } from './
|
|
13
|
+
export { useLocation, useNav } from './project-path/.swico-react/react-hooks';
|
|
14
14
|
export { history } from './mock-history';
|
|
15
15
|
export interface DefineSwicoConfigType {
|
|
16
16
|
(env: 'base', config: CustomConfigType['base']): any;
|
package/src/index.react.js
CHANGED
|
@@ -13,7 +13,7 @@ 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 react_hooks_1 = require("./
|
|
16
|
+
var react_hooks_1 = require("./project-path/.swico-react/react-hooks");
|
|
17
17
|
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return react_hooks_1.useLocation; } });
|
|
18
18
|
Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return react_hooks_1.useNav; } });
|
|
19
19
|
var mock_history_1 = require("./mock-history");
|
package/src/index.vue.d.ts
CHANGED
|
@@ -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, useNav } from './
|
|
6
|
+
export { useLocation, useNav } from './project-path/.swico-vue/vue-hooks';
|
|
7
7
|
export { history } from './mock-history';
|
|
8
8
|
export type { GlobalSwicoConfigType };
|
|
9
9
|
export declare const Link: import("vue").DefineComponent<{
|
package/src/index.vue.js
CHANGED
|
@@ -5,7 +5,7 @@ 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 vue_hooks_1 = require("./
|
|
8
|
+
var vue_hooks_1 = require("./project-path/.swico-vue/vue-hooks");
|
|
9
9
|
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return vue_hooks_1.useLocation; } });
|
|
10
10
|
Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return vue_hooks_1.useNav; } });
|
|
11
11
|
var mock_history_1 = require("./mock-history");
|
|
@@ -47,8 +47,8 @@ var react_1 = __importStar(require("react"));
|
|
|
47
47
|
var react_router_dom_1 = require("react-router-dom");
|
|
48
48
|
var loading_1 = __importDefault(require("../loading"));
|
|
49
49
|
var history_1 = require("./history");
|
|
50
|
-
require("../../global");
|
|
51
|
-
var layout_1 = __importDefault(require("../../layout"));
|
|
50
|
+
require("../../src/global");
|
|
51
|
+
var layout_1 = __importDefault(require("../../src/layout"));
|
|
52
52
|
var routes_1 = __importDefault(require("./routes"));
|
|
53
53
|
var config_1 = require("./config");
|
|
54
54
|
var Container = (function (_super) {
|
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, './
|
|
50
|
-
targetPath = path_1.default.resolve(__dirname, '../dist/src/
|
|
49
|
+
filePath = path_1.default.resolve(__dirname, './project-path/.swico-vue/Container.vue');
|
|
50
|
+
targetPath = path_1.default.resolve(__dirname, '../dist/src/project-path/.swico-vue/Container.vue');
|
|
51
51
|
return [4, fs_extra_1.default.copyFile(filePath, targetPath)];
|
|
52
52
|
case 1:
|
|
53
53
|
_a.sent();
|
package/src/utils/config.js
CHANGED
|
@@ -204,10 +204,12 @@ var initCliIndexFile = function (templateType, env) { return __awaiter(void 0, v
|
|
|
204
204
|
return [4, fs_extra_1.default.readFile(path_1.default.resolve(__dirname, "../index.".concat(templateType, ".d.ts")), 'utf8')];
|
|
205
205
|
case 2:
|
|
206
206
|
fileTypesText = _a.sent();
|
|
207
|
-
|
|
208
|
-
.
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
if (templateType === 'react') {
|
|
208
|
+
formatHooksPath = path_1.default
|
|
209
|
+
.resolve(projectPath, './.swico/react-hooks')
|
|
210
|
+
.replaceAll('\\', '/');
|
|
211
|
+
replaceFileText = replaceFileText.replaceAll('require("./project-path/.swico-react/react-hooks");', "require(\"".concat(formatHooksPath, "\");"));
|
|
212
|
+
}
|
|
211
213
|
formatHistoryPath = path_1.default
|
|
212
214
|
.resolve(projectPath, "./.swico/.".concat(env, "/history"))
|
|
213
215
|
.replaceAll('\\', '/');
|
|
@@ -297,7 +299,6 @@ var handleLoadingFile = function (replaceIndexText, envPath) { return __awaiter(
|
|
|
297
299
|
return [4, fs_extra_1.default.access(path_1.default.resolve(projectPath, './src/loading/index.tsx'), fs_extra_1.default.constants.F_OK)];
|
|
298
300
|
case 2:
|
|
299
301
|
_a.sent();
|
|
300
|
-
newReplaceIndexText = newReplaceIndexText.replace('"../loading"', '"../../src/loading"');
|
|
301
302
|
return [3, 4];
|
|
302
303
|
case 3:
|
|
303
304
|
e_1 = _a.sent();
|
|
@@ -312,7 +313,7 @@ var handleGlobalStyleFile = function (replaceIndexText) {
|
|
|
312
313
|
var _a = getGlobalStyleFilePath(), styleFilePath = _a.filePath, styleFileType = _a.fileType;
|
|
313
314
|
var newReplaceIndexText = replaceIndexText;
|
|
314
315
|
if (styleFilePath) {
|
|
315
|
-
newReplaceIndexText = newReplaceIndexText.replaceAll("require(\"../../global.".concat(styleFileType, "\");"), '');
|
|
316
|
+
newReplaceIndexText = newReplaceIndexText.replaceAll("require(\"../../src/global.".concat(styleFileType, "\");"), '');
|
|
316
317
|
newReplaceIndexText = "require(\"../../src/global.".concat(styleFileType, "\");\n").concat(replaceIndexText);
|
|
317
318
|
}
|
|
318
319
|
else {
|
|
@@ -344,7 +345,7 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
344
345
|
switch (_a.label) {
|
|
345
346
|
case 0:
|
|
346
347
|
copyTargetPath = path_1.default.resolve(projectPath, "./.swico".concat(envPath));
|
|
347
|
-
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../
|
|
348
|
+
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../project-path/.swico-".concat(templateType, "/$env")), copyTargetPath, function (fileName) {
|
|
348
349
|
return !fileName.endsWith('.d.ts') &&
|
|
349
350
|
(templateType === 'vue'
|
|
350
351
|
? !['Container.js', 'vue-hooks.js'].includes(fileName)
|
|
@@ -352,7 +353,7 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
352
353
|
})];
|
|
353
354
|
case 1:
|
|
354
355
|
_a.sent();
|
|
355
|
-
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../
|
|
356
|
+
return [4, (0, tools_1.copyDirFiles)(path_1.default.resolve(__dirname, "../project-path/.swico-".concat(templateType)), path_1.default.resolve(projectPath, './.swico'), function (fileName) {
|
|
356
357
|
return ['react-hooks.js', 'vue-hooks.js', 'loading.js', 'Container.vue'].includes(fileName);
|
|
357
358
|
})];
|
|
358
359
|
case 2:
|
|
@@ -371,13 +372,6 @@ var initTemplateConfig = function (routerConfig, templateType, env) {
|
|
|
371
372
|
return [4, fs_extra_1.default.writeFile(hooksFilePath, replaceHooksText)];
|
|
372
373
|
case 6:
|
|
373
374
|
_a.sent();
|
|
374
|
-
replaceIndexText = replaceIndexText.replace('require("../../global")', 'require("../../src/global");');
|
|
375
|
-
if (templateType === 'vue') {
|
|
376
|
-
replaceIndexText = replaceIndexText.replace('require("../../layout/Layout")', 'require("../../src/layout/Layout")');
|
|
377
|
-
}
|
|
378
|
-
else if (templateType === 'react') {
|
|
379
|
-
replaceIndexText = replaceIndexText.replace('require("../../layout")', 'require("../../src/layout")');
|
|
380
|
-
}
|
|
381
375
|
replaceIndexText = (0, exports.handleGlobalStyleFile)(replaceIndexText);
|
|
382
376
|
if (!(templateType === 'vue')) return [3, 8];
|
|
383
377
|
replaceIndexText = replaceIndexText.replace('"../Container"', '"../Container.vue"');
|
package/src/utils/tools.js
CHANGED
|
@@ -262,7 +262,7 @@ var initIndexFile = function () { return __awaiter(void 0, void 0, void 0, funct
|
|
|
262
262
|
.resolve(projectPath, './.swico/react-hooks')
|
|
263
263
|
.replaceAll('\\', '/');
|
|
264
264
|
if (!fileText.includes("require(\"".concat(formatHooksPath, "\");"))) return [3, 3];
|
|
265
|
-
fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./
|
|
265
|
+
fileText = fileText.replaceAll("require(\"".concat(formatHooksPath, "\");"), 'require("./project-path/.swico-react/react-hooks");');
|
|
266
266
|
return [4, fs_extra_1.default.writeFile(targetPath, fileText)];
|
|
267
267
|
case 2:
|
|
268
268
|
_a.sent();
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getRouter = exports.history = void 0;
|
|
18
|
-
var vue_router_1 = require("vue-router");
|
|
19
|
-
var config_1 = require("./config");
|
|
20
|
-
var routes_1 = __importDefault(require("./routes"));
|
|
21
|
-
var qs_1 = __importDefault(require("qs"));
|
|
22
|
-
var transformRouteItemCustomToMeta = function (routeItem) {
|
|
23
|
-
var newRouteItem = __assign({}, routeItem);
|
|
24
|
-
var custom = routeItem.custom, children = routeItem.children;
|
|
25
|
-
newRouteItem.meta = custom;
|
|
26
|
-
return __assign(__assign({}, newRouteItem), { children: children === null || children === void 0 ? void 0 : children.map(function (item) { return transformRouteItemCustomToMeta(item); }) });
|
|
27
|
-
};
|
|
28
|
-
var formatRoutes = routes_1.default.map(function (routeItem) { return transformRouteItemCustomToMeta(routeItem); });
|
|
29
|
-
var getRouter = function () {
|
|
30
|
-
var router = (0, vue_router_1.createRouter)({
|
|
31
|
-
history: (config_1.routerType === 'hash' ? vue_router_1.createWebHashHistory : vue_router_1.createWebHistory)(config_1.routerBase),
|
|
32
|
-
routes: formatRoutes
|
|
33
|
-
});
|
|
34
|
-
exports.history = {
|
|
35
|
-
push: function (options) {
|
|
36
|
-
if (typeof options === 'string') {
|
|
37
|
-
router.push(options);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
var query = options.query, name_1 = options.name, hash = options.hash, params = options.params, path = options.path, state = options.state;
|
|
41
|
-
router.push({ name: name_1, path: path, query: query, hash: hash, params: params, state: { swicoState: state } });
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
replace: function (options) {
|
|
45
|
-
if (typeof options === 'string') {
|
|
46
|
-
router.replace(options);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
var query = options.query, name_2 = options.name, hash = options.hash, params = options.params, path = options.path, state = options.state;
|
|
50
|
-
router.replace({ name: name_2, path: path, query: query, hash: hash, params: params, state: { swicoState: state } });
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
go: router.go,
|
|
54
|
-
back: router.back,
|
|
55
|
-
forward: router.forward,
|
|
56
|
-
get location() {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
var lastIndexBase = config_1.routerBase[config_1.routerBase.length - 1];
|
|
59
|
-
var formatRouterBase = lastIndexBase === '/' ? config_1.routerBase.slice(0, config_1.routerBase.length - 1) : config_1.routerBase;
|
|
60
|
-
var _c = router.currentRoute.value, path = _c.path, params = _c.params, query = _c.query, name = _c.name, hash = _c.hash, fullPath = _c.fullPath, meta = _c.meta;
|
|
61
|
-
return {
|
|
62
|
-
path: path,
|
|
63
|
-
custom: meta,
|
|
64
|
-
pathname: formatRouterBase + path,
|
|
65
|
-
params: params,
|
|
66
|
-
query: query,
|
|
67
|
-
name: name,
|
|
68
|
-
hash: hash,
|
|
69
|
-
state: (_b = (_a = window.history.state) === null || _a === void 0 ? void 0 : _a.swicoState) !== null && _b !== void 0 ? _b : {},
|
|
70
|
-
search: query ? qs_1.default.stringify(query) : ''
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
return router;
|
|
75
|
-
};
|
|
76
|
-
exports.getRouter = getRouter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
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 Container_1 = __importDefault(require("../Container"));
|
|
9
|
-
var Layout_1 = __importDefault(require("../../layout/Layout"));
|
|
10
|
-
var global_1 = __importDefault(require("../../global"));
|
|
11
|
-
var history_1 = require("./history");
|
|
12
|
-
var router = (0, history_1.getRouter)();
|
|
13
|
-
var app = (0, vue_1.createApp)(Container_1.default);
|
|
14
|
-
app.component('Layout', Layout_1.default);
|
|
15
|
-
app.use(router);
|
|
16
|
-
(_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);
|
|
17
|
-
app.mount('#root');
|
|
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
|
|
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
|