swico 2.0.0-beta.15 → 2.0.0-beta.17
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 +27 -23
- package/src/bin.js +17 -7
- package/src/command/build.js +1 -1
- package/src/command/start.js +2 -2
- package/src/config/rsbpack.dev.js +21 -11
- package/src/config/rspack.base.react.d.ts +1 -1
- package/src/config/rspack.base.react.js +7 -7
- package/src/config/rspack.base.vue.js +6 -6
- package/src/config/rspack.prod.js +19 -9
- package/src/index.react.d.ts +1 -1
- package/src/index.react.js +4 -4
- package/src/index.vue.d.ts +6 -4
- package/src/project-path/.swico-react/$env/index.js +21 -11
- package/src/project-path/.swico-react/react-hooks.js +4 -4
- package/src/project-path/.swico-vue/Container.d.ts +1 -1
- package/src/project-path/src/layout/Layout.d.ts +1 -1
- package/src/project-path/src/layout/index.js +2 -2
- package/src/utils/config.js +17 -7
- package/src/utils/tools.d.ts +1 -1
- package/src/utils/tools.js +17 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.17",
|
|
4
4
|
"description": "Simple, efficient, and practical front-end framework",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -30,48 +30,52 @@
|
|
|
30
30
|
"author": "scw",
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@rspack/core": "1.3.
|
|
34
|
-
"@rspack/dev-server": "
|
|
35
|
-
"@vue/compiler-sfc": "3.
|
|
33
|
+
"@rspack/core": "1.3.5",
|
|
34
|
+
"@rspack/dev-server": "1.1.1",
|
|
35
|
+
"@vue/compiler-sfc": "3.5.13",
|
|
36
36
|
"autoprefixer": "10.3.7",
|
|
37
37
|
"chalk": "4.1.2",
|
|
38
38
|
"chokidar": "3.6.0",
|
|
39
39
|
"commander": "12.0.0",
|
|
40
40
|
"cross-spawn": "7.0.5",
|
|
41
|
-
"css-loader": "
|
|
42
|
-
"eslint-
|
|
41
|
+
"css-loader": "7.1.2",
|
|
42
|
+
"eslint-rspack-plugin": "4.2.1",
|
|
43
43
|
"fs-extra": "11.3.0",
|
|
44
|
-
"html-loader": "5.
|
|
45
|
-
"less": "4.
|
|
44
|
+
"html-loader": "5.1.0",
|
|
45
|
+
"less": "4.3.0",
|
|
46
46
|
"less-loader": "12.2.0",
|
|
47
47
|
"ora": "5.4.1",
|
|
48
48
|
"portfinder": "1.0.32",
|
|
49
49
|
"postcss-loader": "8.1.0",
|
|
50
50
|
"postcss-preset-env": "9.3.0",
|
|
51
51
|
"qs": "6.13.0",
|
|
52
|
-
"react-router
|
|
53
|
-
"sass-embedded": "
|
|
52
|
+
"react-router": "7.5.0",
|
|
53
|
+
"sass-embedded": "1.86.3",
|
|
54
54
|
"sass-loader": "16.0.5",
|
|
55
55
|
"style-loader": "3.3.0",
|
|
56
|
-
"ts-checker-rspack-plugin": "
|
|
56
|
+
"ts-checker-rspack-plugin": "1.1.1",
|
|
57
57
|
"ts-node": "10.9.1",
|
|
58
58
|
"vue-loader": "17.4.2",
|
|
59
|
-
"vue-router": "
|
|
59
|
+
"vue-router": "4.5.0",
|
|
60
60
|
"vue-style-loader": "4.1.3",
|
|
61
61
|
"webpack-bundle-analyzer": "4.9.1",
|
|
62
|
-
"webpack-merge": "
|
|
63
|
-
"webpackbar": "
|
|
62
|
+
"webpack-merge": "6.0.1",
|
|
63
|
+
"webpackbar": "7.0.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "22.13.10",
|
|
67
|
-
"@types/react": "
|
|
68
|
-
"@types/react-dom": "
|
|
69
|
-
"
|
|
70
|
-
"@
|
|
71
|
-
"eslint": "8.
|
|
72
|
-
"
|
|
73
|
-
"react
|
|
74
|
-
"
|
|
75
|
-
"
|
|
67
|
+
"@types/react": "19.1.0",
|
|
68
|
+
"@types/react-dom": "19.1.0",
|
|
69
|
+
"eslint": "9.24.0",
|
|
70
|
+
"@eslint/js": "9.24.0",
|
|
71
|
+
"typescript-eslint": "8.30.1",
|
|
72
|
+
"globals": "16.0.0",
|
|
73
|
+
"react": "~19.1.0",
|
|
74
|
+
"react-dom": "~19.1.0",
|
|
75
|
+
"typescript": "5.8.3",
|
|
76
|
+
"vue": "~3.5.13"
|
|
77
|
+
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=20.0.0"
|
|
76
80
|
}
|
|
77
81
|
}
|
package/src/bin.js
CHANGED
|
@@ -16,13 +16,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
16
16
|
}) : function(o, v) {
|
|
17
17
|
o["default"] = v;
|
|
18
18
|
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
26
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
38
|
};
|
package/src/command/build.js
CHANGED
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
15
16
|
const rspack_prod_1 = __importDefault(require("../config/rspack.prod"));
|
|
16
17
|
const config_1 = require("../utils/config");
|
|
17
18
|
const tools_1 = require("../utils/tools");
|
|
@@ -50,4 +51,3 @@ function default_1() {
|
|
|
50
51
|
});
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
|
-
exports.default = default_1;
|
package/src/command/start.js
CHANGED
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = start;
|
|
15
16
|
const rsbpack_dev_1 = __importDefault(require("../config/rsbpack.dev"));
|
|
16
17
|
const tools_1 = require("../utils/tools");
|
|
17
18
|
const config_1 = require("../utils/config");
|
|
@@ -129,8 +130,8 @@ const createCompileListener = (compiler) => {
|
|
|
129
130
|
});
|
|
130
131
|
};
|
|
131
132
|
function start() {
|
|
132
|
-
var _a, _b, _c, _d, _e, _f;
|
|
133
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
var _a, _b, _c, _d, _e, _f;
|
|
134
135
|
process.env.SWICO_ENV = 'dev';
|
|
135
136
|
if (SWICO_RESTART !== 'true') {
|
|
136
137
|
console.log('\n');
|
|
@@ -168,4 +169,3 @@ function start() {
|
|
|
168
169
|
}
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
|
-
exports.default = start;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,15 +45,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.default = default_1;
|
|
38
49
|
const config_1 = require("../utils/config");
|
|
39
50
|
const path_1 = __importDefault(require("path"));
|
|
40
51
|
const webpack_merge_1 = require("webpack-merge");
|
|
41
|
-
const
|
|
52
|
+
const eslint_rspack_plugin_1 = __importDefault(require("eslint-rspack-plugin"));
|
|
42
53
|
const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
|
|
43
54
|
const tools_1 = require("../utils/tools");
|
|
44
55
|
function default_1(options) {
|
|
45
|
-
var _a, _b, _c, _d, _e;
|
|
46
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a, _b, _c, _d, _e;
|
|
47
58
|
const { projectPath, customConfig, templateType, entryPath, env } = options;
|
|
48
59
|
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
49
60
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'dev' }));
|
|
@@ -88,7 +99,7 @@ function default_1(options) {
|
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
}),
|
|
91
|
-
new
|
|
102
|
+
new eslint_rspack_plugin_1.default({
|
|
92
103
|
context: path_1.default.join(projectPath, '/src'),
|
|
93
104
|
failOnError: false,
|
|
94
105
|
failOnWarning: true,
|
|
@@ -101,4 +112,3 @@ function default_1(options) {
|
|
|
101
112
|
});
|
|
102
113
|
});
|
|
103
114
|
}
|
|
104
|
-
exports.default = default_1;
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
15
16
|
const path_1 = __importDefault(require("path"));
|
|
16
17
|
const config_1 = require("../utils/config");
|
|
17
18
|
const core_1 = require("@rspack/core");
|
|
@@ -19,9 +20,9 @@ const cssLoader = require.resolve('css-loader');
|
|
|
19
20
|
const lessLoader = require.resolve('less-loader');
|
|
20
21
|
const sassLoader = require.resolve('sass-loader');
|
|
21
22
|
const postcssLoader = require.resolve('postcss-loader');
|
|
22
|
-
function default_1(
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
function default_1(_a) {
|
|
24
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
25
|
+
var _b, _c, _d;
|
|
25
26
|
const customBaseConfig = customConfig.base;
|
|
26
27
|
const getCustomAliasConfig = () => {
|
|
27
28
|
const { alias } = customBaseConfig || {};
|
|
@@ -34,9 +35,9 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
34
35
|
return custAliasConfig;
|
|
35
36
|
};
|
|
36
37
|
const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
37
|
-
const routerBase = ((
|
|
38
|
+
const routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
|
|
38
39
|
const basicPlugins = [];
|
|
39
|
-
const defineConfigData = (
|
|
40
|
+
const defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
|
|
40
41
|
const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
|
|
41
42
|
if (Object.keys(formatObj).length !== 0) {
|
|
42
43
|
basicPlugins.push(new core_1.rspack.DefinePlugin(formatObj));
|
|
@@ -172,7 +173,7 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
172
173
|
},
|
|
173
174
|
resolve: {
|
|
174
175
|
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
175
|
-
alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router
|
|
176
|
+
alias: Object.assign({ '@': path_1.default.join(projectPath, '/src'), 'react-router': path_1.default.dirname(require.resolve('react-router')), qs: path_1.default.dirname(require.resolve('qs')) }, getCustomAliasConfig())
|
|
176
177
|
},
|
|
177
178
|
externals: customConfig.base.externals,
|
|
178
179
|
plugins: [
|
|
@@ -192,4 +193,3 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
192
193
|
};
|
|
193
194
|
});
|
|
194
195
|
}
|
|
195
|
-
exports.default = default_1;
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = default_1;
|
|
15
16
|
const path_1 = __importDefault(require("path"));
|
|
16
17
|
const config_1 = require("../utils/config");
|
|
17
18
|
const vue_loader_1 = require("vue-loader");
|
|
@@ -21,9 +22,9 @@ const cssLoader = require.resolve('css-loader');
|
|
|
21
22
|
const lessLoader = require.resolve('less-loader');
|
|
22
23
|
const sassLoader = require.resolve('sass-loader');
|
|
23
24
|
const postcssLoader = require.resolve('postcss-loader');
|
|
24
|
-
function default_1(
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
function default_1(_a) {
|
|
26
|
+
return __awaiter(this, arguments, void 0, function* ({ projectPath, entryPath, env, customConfig }) {
|
|
27
|
+
var _b, _c, _d;
|
|
27
28
|
const customBaseConfig = customConfig.base;
|
|
28
29
|
const getCustomAliasConfig = () => {
|
|
29
30
|
const { alias } = customBaseConfig || {};
|
|
@@ -36,9 +37,9 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
36
37
|
return custAliasConfig;
|
|
37
38
|
};
|
|
38
39
|
const publicPath = (customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.publicPath) || config_1.initConfig.publicPath;
|
|
39
|
-
const routerBase = ((
|
|
40
|
+
const routerBase = ((_b = customBaseConfig === null || customBaseConfig === void 0 ? void 0 : customBaseConfig.router) === null || _b === void 0 ? void 0 : _b.base) || config_1.initConfig.router.base;
|
|
40
41
|
const basicPlugins = [];
|
|
41
|
-
const defineConfigData = (
|
|
42
|
+
const defineConfigData = (_d = (_c = customConfig === null || customConfig === void 0 ? void 0 : customConfig.base) === null || _c === void 0 ? void 0 : _c.define) !== null && _d !== void 0 ? _d : {};
|
|
42
43
|
const formatObj = yield (0, config_1.getFormatDefineVars)(defineConfigData);
|
|
43
44
|
if (Object.keys(formatObj).length !== 0) {
|
|
44
45
|
basicPlugins.push(new core_1.rspack.DefinePlugin(formatObj));
|
|
@@ -164,4 +165,3 @@ function default_1({ projectPath, entryPath, env, customConfig }) {
|
|
|
164
165
|
};
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
|
-
exports.default = default_1;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,6 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.default = default_1;
|
|
38
49
|
const webpack_bundle_analyzer_1 = __importDefault(require("webpack-bundle-analyzer"));
|
|
39
50
|
const path_1 = __importDefault(require("path"));
|
|
40
51
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -46,8 +57,8 @@ const core_1 = require("@rspack/core");
|
|
|
46
57
|
const BundleAnalyzerPlugin = webpack_bundle_analyzer_1.default.BundleAnalyzerPlugin;
|
|
47
58
|
const isAnalyze = process.env.ANALYZE === 'true';
|
|
48
59
|
function default_1(options) {
|
|
49
|
-
var _a, _b, _c, _d, _e;
|
|
50
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
var _a, _b, _c, _d, _e;
|
|
51
62
|
const { projectPath, customConfig, templateType } = options;
|
|
52
63
|
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
53
64
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'prod' }));
|
|
@@ -123,4 +134,3 @@ function default_1(options) {
|
|
|
123
134
|
});
|
|
124
135
|
});
|
|
125
136
|
}
|
|
126
|
-
exports.default = default_1;
|
package/src/index.react.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const Link: FC<{
|
|
|
9
9
|
className?: string;
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
}>;
|
|
12
|
-
export { Outlet } from 'react-router
|
|
12
|
+
export { Outlet } from 'react-router';
|
|
13
13
|
export { useLocation, useNav } from './project-path/.swico-react/react-hooks';
|
|
14
14
|
export { history } from './mock-history';
|
|
15
15
|
export interface DefineSwicoConfigType {
|
package/src/index.react.js
CHANGED
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.defineGlobal = exports.defineConfig = exports.history = exports.useNav = exports.useLocation = exports.Outlet = exports.Link = void 0;
|
|
7
|
-
const
|
|
7
|
+
const react_router_1 = require("react-router");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const Link = ({ replace, to, style, className, children }) => react_1.default.createElement(
|
|
9
|
+
const Link = ({ replace, to, style, className, children }) => react_1.default.createElement(react_router_1.Link, { replace, to, style, className }, children);
|
|
10
10
|
exports.Link = Link;
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return
|
|
11
|
+
var react_router_2 = require("react-router");
|
|
12
|
+
Object.defineProperty(exports, "Outlet", { enumerable: true, get: function () { return react_router_2.Outlet; } });
|
|
13
13
|
var react_hooks_1 = require("./project-path/.swico-react/react-hooks");
|
|
14
14
|
Object.defineProperty(exports, "useLocation", { enumerable: true, get: function () { return react_hooks_1.useLocation; } });
|
|
15
15
|
Object.defineProperty(exports, "useNav", { enumerable: true, get: function () { return react_hooks_1.useNav; } });
|
package/src/index.vue.d.ts
CHANGED
|
@@ -6,23 +6,25 @@ export { RouterView as Outlet } from 'vue-router';
|
|
|
6
6
|
export { useLocation, useNav } from './project-path/.swico-vue/vue-hooks';
|
|
7
7
|
export { history } from './mock-history';
|
|
8
8
|
export type { GlobalSwicoConfigType };
|
|
9
|
-
export declare const Link: import("vue").DefineComponent<{
|
|
9
|
+
export declare const Link: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
10
|
to: {
|
|
11
11
|
type: StringConstructor;
|
|
12
12
|
};
|
|
13
13
|
replace: {
|
|
14
14
|
type: BooleanConstructor;
|
|
15
15
|
};
|
|
16
|
-
}
|
|
16
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
17
|
to: {
|
|
18
18
|
type: StringConstructor;
|
|
19
19
|
};
|
|
20
20
|
replace: {
|
|
21
21
|
type: BooleanConstructor;
|
|
22
22
|
};
|
|
23
|
-
}
|
|
23
|
+
}>> & Readonly<{}>, {
|
|
24
24
|
replace: boolean;
|
|
25
|
-
}, {}
|
|
25
|
+
}, {}, {
|
|
26
|
+
RouterLink: import("vue-router")._RouterLinkI;
|
|
27
|
+
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
28
|
export interface DefineSwicoConfigType {
|
|
27
29
|
(env: 'base', config: CustomConfigType['base']): any;
|
|
28
30
|
(env: 'dev', config: CustomConfigType['dev']): any;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -29,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
39
|
exports.getChildrenRouteList = void 0;
|
|
30
40
|
const client_1 = require("react-dom/client");
|
|
31
41
|
const react_1 = __importStar(require("react"));
|
|
32
|
-
const
|
|
42
|
+
const react_router_1 = require("react-router");
|
|
33
43
|
const loading_1 = __importDefault(require("../loading"));
|
|
34
44
|
const history_1 = require("./history");
|
|
35
45
|
require("../../src/global");
|
|
@@ -57,7 +67,7 @@ const getChildrenRouteList = (childrenRoutes, ancPathKey) => {
|
|
|
57
67
|
const { component, path, children, redirect } = item;
|
|
58
68
|
const newAncPathKey = `${ancPathKey}-${path}`;
|
|
59
69
|
return {
|
|
60
|
-
element: redirect ? (react_1.default.createElement(
|
|
70
|
+
element: redirect ? (react_1.default.createElement(react_router_1.Navigate, { to: redirect, replace: true })) : component ? (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement(loading_1.default, null) }, (0, react_1.createElement)((0, react_1.lazy)(component)))) : (react_1.default.createElement(react_router_1.Outlet, null)),
|
|
61
71
|
key: newAncPathKey,
|
|
62
72
|
path: path.startsWith('/') ? path.slice(1) : path,
|
|
63
73
|
children: (0, exports.getChildrenRouteList)(children, newAncPathKey)
|
|
@@ -74,7 +84,7 @@ const App = () => {
|
|
|
74
84
|
children: (0, exports.getChildrenRouteList)(routes_1.default, '')
|
|
75
85
|
}
|
|
76
86
|
];
|
|
77
|
-
const router = (config_1.routerType === 'hash' ?
|
|
87
|
+
const router = (config_1.routerType === 'hash' ? react_router_1.createHashRouter : react_router_1.createBrowserRouter)(routeList, {
|
|
78
88
|
basename: config_1.routerBase
|
|
79
89
|
});
|
|
80
90
|
if (config_1.routerBase && config_1.routerBase !== '/') {
|
|
@@ -85,7 +95,7 @@ const App = () => {
|
|
|
85
95
|
(0, react_1.useLayoutEffect)(() => {
|
|
86
96
|
history_1.history = (0, history_1.getHistory)(router);
|
|
87
97
|
});
|
|
88
|
-
return react_1.default.createElement(
|
|
98
|
+
return react_1.default.createElement(react_router_1.RouterProvider, { router: router });
|
|
89
99
|
};
|
|
90
100
|
const root = (0, client_1.createRoot)(document.getElementById('root'));
|
|
91
101
|
root.render(react_1.default.createElement(App, null));
|
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useNav = exports.useLocation = void 0;
|
|
7
|
-
const
|
|
7
|
+
const react_router_1 = require("react-router");
|
|
8
8
|
const history_1 = require("./$env/history");
|
|
9
9
|
const qs_1 = __importDefault(require("qs"));
|
|
10
10
|
const useLocation = () => {
|
|
11
11
|
var _a;
|
|
12
|
-
const location = (0,
|
|
13
|
-
const params = (0,
|
|
12
|
+
const location = (0, react_router_1.useLocation)();
|
|
13
|
+
const params = (0, react_router_1.useParams)();
|
|
14
14
|
const { search, hash, pathname, state } = location;
|
|
15
15
|
const matchItem = history_1.pathNameList.find((item) => (Object.keys(params).length > 0 && (0, history_1.compareURLPatterns)(pathname, item.path)) ||
|
|
16
16
|
item.path === pathname);
|
|
@@ -39,7 +39,7 @@ const getFormatNavPath = (to) => {
|
|
|
39
39
|
return newPath;
|
|
40
40
|
};
|
|
41
41
|
const useNav = () => {
|
|
42
|
-
const navigate = (0,
|
|
42
|
+
const navigate = (0, react_router_1.useNavigate)();
|
|
43
43
|
const newNavigate = (to, options) => {
|
|
44
44
|
switch (typeof to) {
|
|
45
45
|
case 'string':
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
2
|
export default _default;
|
|
@@ -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
|
-
const
|
|
6
|
+
const react_router_1 = require("react-router");
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
exports.default = () => react_1.default.createElement(
|
|
8
|
+
exports.default = () => react_1.default.createElement(react_router_1.Outlet, null);
|
package/src/utils/config.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
package/src/utils/tools.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigRouterType } from './config';
|
|
2
2
|
export declare const copyDirFiles: (src: any, dest: any, filter?: (fileName: any) => boolean) => Promise<void>;
|
|
3
|
-
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType[
|
|
3
|
+
export declare const getFormatRouter: (projectPath: string, routes: ConfigRouterType["routes"], templateType: any) => any[];
|
|
4
4
|
export declare const getPort: () => Promise<number>;
|
|
5
5
|
export declare const colorConfig: {
|
|
6
6
|
theme: string;
|
package/src/utils/tools.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|