swico 1.7.3 → 2.0.0-beta.10
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 +10 -21
- package/src/bin.js +6 -6
- package/src/command/build.js +33 -73
- package/src/command/start.js +100 -192
- package/src/config/rsbpack.dev.js +104 -0
- package/src/config/{webpack.base.react.d.ts → rspack.base.react.d.ts} +43 -6
- package/src/config/rspack.base.react.js +195 -0
- package/src/config/{webpack.base.vue.d.ts → rspack.base.vue.d.ts} +32 -32
- package/src/config/rspack.base.vue.js +167 -0
- package/src/config/rspack.prod.js +122 -0
- package/src/index.js +3 -5
- package/src/index.react.js +5 -10
- package/src/index.vue.js +4 -6
- package/src/project-path/.swico-react/$env/history.js +65 -66
- package/src/project-path/.swico-react/$env/index.js +29 -47
- package/src/project-path/.swico-react/loading.js +1 -1
- package/src/project-path/.swico-react/react-hooks.js +24 -37
- package/src/project-path/.swico-vue/$env/history.js +25 -36
- package/src/project-path/.swico-vue/$env/index.js +7 -7
- package/src/project-path/.swico-vue/Container.js +1 -1
- package/src/project-path/.swico-vue/vue-hooks.js +17 -28
- package/src/project-path/src/layout/Layout.js +1 -1
- package/src/project-path/src/layout/index.js +3 -3
- package/src/task.js +13 -58
- package/src/utils/config.js +185 -349
- package/src/utils/tools.js +103 -199
- package/src/config/webpack.base.react.js +0 -315
- package/src/config/webpack.base.vue.js +0 -338
- package/src/config/webpack.dev.js +0 -159
- package/src/config/webpack.prod.js +0 -193
- /package/src/config/{webpack.dev.d.ts → rsbpack.dev.d.ts} +0 -0
- /package/src/config/{webpack.prod.d.ts → rspack.prod.d.ts} +0 -0
|
@@ -1,53 +1,42 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
6
|
exports.getRouter = exports.history = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
const vue_router_1 = require("vue-router");
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
const routes_1 = __importDefault(require("./routes"));
|
|
10
|
+
const qs_1 = __importDefault(require("qs"));
|
|
11
|
+
const transformRouteItemCustomToMeta = (routeItem) => {
|
|
12
|
+
const newRouteItem = Object.assign({}, routeItem);
|
|
13
|
+
const { custom, children } = routeItem;
|
|
25
14
|
newRouteItem.meta = custom;
|
|
26
|
-
return
|
|
15
|
+
return Object.assign(Object.assign({}, newRouteItem), { children: children === null || children === void 0 ? void 0 : children.map((item) => transformRouteItemCustomToMeta(item)) });
|
|
27
16
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
const formatRoutes = routes_1.default.map((routeItem) => transformRouteItemCustomToMeta(routeItem));
|
|
18
|
+
const getRouter = () => {
|
|
19
|
+
const router = (0, vue_router_1.createRouter)({
|
|
31
20
|
history: (config_1.routerType === 'hash' ? vue_router_1.createWebHashHistory : vue_router_1.createWebHistory)(config_1.routerBase),
|
|
32
21
|
routes: formatRoutes
|
|
33
22
|
});
|
|
34
23
|
exports.history = {
|
|
35
|
-
push:
|
|
24
|
+
push: (options) => {
|
|
36
25
|
if (typeof options === 'string') {
|
|
37
26
|
router.push(options);
|
|
38
27
|
}
|
|
39
28
|
else {
|
|
40
|
-
|
|
41
|
-
router.push({ name
|
|
29
|
+
const { query, name, hash, params, path, state } = options;
|
|
30
|
+
router.push({ name, path, query, hash, params, state: { swicoState: state } });
|
|
42
31
|
}
|
|
43
32
|
},
|
|
44
|
-
replace:
|
|
33
|
+
replace: (options) => {
|
|
45
34
|
if (typeof options === 'string') {
|
|
46
35
|
router.replace(options);
|
|
47
36
|
}
|
|
48
37
|
else {
|
|
49
|
-
|
|
50
|
-
router.replace({ name
|
|
38
|
+
const { query, name, hash, params, path, state } = options;
|
|
39
|
+
router.replace({ name, path, query, hash, params, state: { swicoState: state } });
|
|
51
40
|
}
|
|
52
41
|
},
|
|
53
42
|
go: router.go,
|
|
@@ -55,17 +44,17 @@ var getRouter = function () {
|
|
|
55
44
|
forward: router.forward,
|
|
56
45
|
get location() {
|
|
57
46
|
var _a, _b;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
const lastIndexBase = config_1.routerBase[config_1.routerBase.length - 1];
|
|
48
|
+
const formatRouterBase = lastIndexBase === '/' ? config_1.routerBase.slice(0, config_1.routerBase.length - 1) : config_1.routerBase;
|
|
49
|
+
const { path, params, query, name, hash, fullPath, meta } = router.currentRoute.value;
|
|
61
50
|
return {
|
|
62
|
-
path
|
|
51
|
+
path,
|
|
63
52
|
custom: meta,
|
|
64
53
|
pathname: formatRouterBase + path,
|
|
65
|
-
params
|
|
66
|
-
query
|
|
67
|
-
name
|
|
68
|
-
hash
|
|
54
|
+
params,
|
|
55
|
+
query,
|
|
56
|
+
name,
|
|
57
|
+
hash,
|
|
69
58
|
state: (_b = (_a = window.history.state) === null || _a === void 0 ? void 0 : _a.swicoState) !== null && _b !== void 0 ? _b : {},
|
|
70
59
|
search: query ? qs_1.default.stringify(query) : ''
|
|
71
60
|
};
|
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const vue_1 = require("vue");
|
|
8
|
+
const Container_1 = __importDefault(require("../Container"));
|
|
9
|
+
const Layout_1 = __importDefault(require("../../src/layout/Layout"));
|
|
10
|
+
const global_1 = __importDefault(require("../../src/global"));
|
|
11
|
+
const history_1 = require("./history");
|
|
12
|
+
const router = (0, history_1.getRouter)();
|
|
13
|
+
const app = (0, vue_1.createApp)(Container_1.default);
|
|
14
14
|
app.component('Layout', Layout_1.default);
|
|
15
15
|
app.use(router);
|
|
16
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);
|
|
@@ -1,32 +1,21 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
6
|
exports.useNav = exports.useLocation = exports.getFormatRouterBase = void 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
const vue_router_1 = require("vue-router");
|
|
8
|
+
const qs_1 = __importDefault(require("qs"));
|
|
9
|
+
const vue_1 = require("vue");
|
|
10
|
+
const config_1 = require("./$env/config");
|
|
11
|
+
const getFormatRouterBase = (routerBase) => {
|
|
12
|
+
const lastIndexBase = routerBase[routerBase.length - 1];
|
|
24
13
|
return lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
|
|
25
14
|
};
|
|
26
15
|
exports.getFormatRouterBase = getFormatRouterBase;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
const useLocation = () => {
|
|
17
|
+
const route = (0, vue_router_1.useRoute)();
|
|
18
|
+
const location = (0, vue_1.reactive)({
|
|
30
19
|
name: '',
|
|
31
20
|
path: '',
|
|
32
21
|
search: '',
|
|
@@ -36,10 +25,10 @@ var useLocation = function () {
|
|
|
36
25
|
params: {},
|
|
37
26
|
query: {}
|
|
38
27
|
});
|
|
39
|
-
(0, vue_1.watchEffect)(
|
|
28
|
+
(0, vue_1.watchEffect)(() => {
|
|
40
29
|
var _a;
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
const { hash, path, params, fullPath, query, name, meta } = route;
|
|
31
|
+
const search = query ? qs_1.default.stringify(query) : '';
|
|
43
32
|
location.name = name;
|
|
44
33
|
location.path = path;
|
|
45
34
|
location.pathname = (0, exports.getFormatRouterBase)(config_1.routerBase) + path;
|
|
@@ -53,9 +42,9 @@ var useLocation = function () {
|
|
|
53
42
|
return location;
|
|
54
43
|
};
|
|
55
44
|
exports.useLocation = useLocation;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
const useNav = () => {
|
|
46
|
+
const router = (0, vue_router_1.useRouter)();
|
|
47
|
+
const newNavigate = (to, options) => {
|
|
59
48
|
switch (typeof to) {
|
|
60
49
|
case 'string':
|
|
61
50
|
if (options === null || options === void 0 ? void 0 : options.replace) {
|
|
@@ -73,11 +62,11 @@ var useNav = function () {
|
|
|
73
62
|
router.replace(to);
|
|
74
63
|
}
|
|
75
64
|
else {
|
|
76
|
-
router.push(
|
|
65
|
+
router.push(Object.assign(Object.assign({}, to), { state: { swicoState: to.state } }));
|
|
77
66
|
}
|
|
78
67
|
break;
|
|
79
68
|
default:
|
|
80
|
-
throw
|
|
69
|
+
throw `An error occurred while executing useNav() operation: unexpected type of 'to':${typeof to}`;
|
|
81
70
|
}
|
|
82
71
|
};
|
|
83
72
|
return newNavigate;
|
|
@@ -3,6 +3,6 @@ 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
|
-
|
|
7
|
-
|
|
8
|
-
exports.default = (
|
|
6
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
exports.default = () => react_1.default.createElement(react_router_dom_1.Outlet, null);
|
package/src/task.js
CHANGED
|
@@ -8,68 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}); };
|
|
58
|
-
var copyReadMeFiles = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
-
var filePath, targetPath;
|
|
60
|
-
return __generator(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0:
|
|
63
|
-
filePath = path_1.default.resolve(__dirname, '../README.md');
|
|
64
|
-
targetPath = path_1.default.resolve(__dirname, '../dist/README.md');
|
|
65
|
-
return [4, fs_extra_1.default.copyFile(filePath, targetPath)];
|
|
66
|
-
case 1:
|
|
67
|
-
_a.sent();
|
|
68
|
-
return [2];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}); };
|
|
72
|
-
var main = function () {
|
|
15
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const copyVueFiles = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const filePath = path_1.default.resolve(__dirname, './project-path/.swico-vue/Container.vue');
|
|
19
|
+
const targetPath = path_1.default.resolve(__dirname, '../dist/src/project-path/.swico-vue/Container.vue');
|
|
20
|
+
yield fs_extra_1.default.copyFile(filePath, targetPath);
|
|
21
|
+
});
|
|
22
|
+
const copyReadMeFiles = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const filePath = path_1.default.resolve(__dirname, '../README.md');
|
|
24
|
+
const targetPath = path_1.default.resolve(__dirname, '../dist/README.md');
|
|
25
|
+
yield fs_extra_1.default.copyFile(filePath, targetPath);
|
|
26
|
+
});
|
|
27
|
+
const main = () => {
|
|
73
28
|
copyVueFiles();
|
|
74
29
|
copyReadMeFiles();
|
|
75
30
|
};
|