swico 2.1.0 → 2.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swico",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-beta.2",
|
|
4
4
|
"description": "Simple, efficient, and practical front-end framework",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@eslint/js": "9.24.0",
|
|
63
|
-
"@rspack/core": "1.
|
|
63
|
+
"@rspack/core": "1.4.5",
|
|
64
64
|
"@types/node": "22.13.10",
|
|
65
65
|
"@types/react": "19.1.0",
|
|
66
66
|
"@types/react-dom": "19.1.0",
|
|
@@ -54,7 +54,7 @@ const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
|
|
|
54
54
|
const tools_1 = require("../utils/tools");
|
|
55
55
|
function default_1(options) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
var _a, _b, _c, _d, _e;
|
|
57
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
58
58
|
const { projectPath, customConfig, templateType, entryPath, env } = options;
|
|
59
59
|
const getBaseConfig = (yield Promise.resolve(`${templateType === 'vue' ? './rspack.base.vue' : './rspack.base.react'}`).then(s => __importStar(require(s)))).default;
|
|
60
60
|
const baseConfig = yield getBaseConfig(Object.assign(Object.assign({}, options), { env: 'dev' }));
|
|
@@ -74,7 +74,8 @@ function default_1(options) {
|
|
|
74
74
|
progress: false,
|
|
75
75
|
overlay: false
|
|
76
76
|
},
|
|
77
|
-
|
|
77
|
+
headers: (_c = (_b = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _b === void 0 ? void 0 : _b.headers) !== null && _c !== void 0 ? _c : config_1.initConfig.headers,
|
|
78
|
+
proxy: (_e = (_d = customConfig === null || customConfig === void 0 ? void 0 : customConfig.dev) === null || _d === void 0 ? void 0 : _d.proxy) !== null && _e !== void 0 ? _e : config_1.initConfig.proxy,
|
|
78
79
|
compress: true,
|
|
79
80
|
hot: true,
|
|
80
81
|
open: false,
|
|
@@ -109,7 +110,7 @@ function default_1(options) {
|
|
|
109
110
|
emitWarning: false,
|
|
110
111
|
cache: true
|
|
111
112
|
}),
|
|
112
|
-
...((
|
|
113
|
+
...((_g = (_f = customConfig.dev) === null || _f === void 0 ? void 0 : _f.plugins) !== null && _g !== void 0 ? _g : [])
|
|
113
114
|
]
|
|
114
115
|
});
|
|
115
116
|
});
|
|
@@ -120,6 +120,9 @@ const getFormatHistoryOption = (to, pathList, type) => {
|
|
|
120
120
|
throw `An error occurred while executing 'history.${type}' operation: The path for the name "${name}" could not be found`;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
+
if (!path && !name) {
|
|
124
|
+
obj.pathname = '';
|
|
125
|
+
}
|
|
123
126
|
return obj;
|
|
124
127
|
};
|
|
125
128
|
const getHistory = (router) => {
|
|
@@ -8,12 +8,16 @@ 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
|
-
var _a;
|
|
11
|
+
var _a, _b;
|
|
12
12
|
const location = (0, react_router_1.useLocation)();
|
|
13
13
|
const params = (0, react_router_1.useParams)();
|
|
14
14
|
const { search, hash, pathname, state } = location;
|
|
15
|
-
|
|
15
|
+
let matchItem = history_1.pathNameList.find((item) => (Object.keys(params).length > 0 && (0, history_1.compareURLPatterns)(pathname, item.path)) ||
|
|
16
16
|
item.path === pathname);
|
|
17
|
+
const generalItem = history_1.pathNameList.find((item) => item.path === '*');
|
|
18
|
+
if (!matchItem && generalItem) {
|
|
19
|
+
matchItem = generalItem;
|
|
20
|
+
}
|
|
17
21
|
const query = search ? qs_1.default.parse(search.startsWith('?') ? search.slice(1) : search) : {};
|
|
18
22
|
return {
|
|
19
23
|
name: matchItem === null || matchItem === void 0 ? void 0 : matchItem.name,
|
|
@@ -21,7 +25,7 @@ const useLocation = () => {
|
|
|
21
25
|
state: state !== null && state !== void 0 ? state : {},
|
|
22
26
|
path: pathname,
|
|
23
27
|
pathname: (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.pathname,
|
|
24
|
-
search:
|
|
28
|
+
search: (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.search,
|
|
25
29
|
query,
|
|
26
30
|
hash,
|
|
27
31
|
params
|
|
@@ -34,7 +38,7 @@ const getFormatNavPath = (to) => {
|
|
|
34
38
|
const search = query ? `?${qs_1.default.stringify(query)}` : '';
|
|
35
39
|
const formatHash = hash ? (hash.startsWith('#') ? hash : `#${hash}`) : '';
|
|
36
40
|
const formatPath = name ? (_a = history_1.pathNameList.find((item) => item.name === name)) === null || _a === void 0 ? void 0 : _a.path : path;
|
|
37
|
-
let newPath = formatPath ? (0, history_1.interpolatePath)(formatPath, params || {}) :
|
|
41
|
+
let newPath = formatPath ? (0, history_1.interpolatePath)(formatPath, params || {}) : '';
|
|
38
42
|
newPath = newPath + search + formatHash;
|
|
39
43
|
return newPath;
|
|
40
44
|
};
|
package/src/utils/config.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface GlobalSwicoConfigType {
|
|
|
22
22
|
alias?: Record<string, any>;
|
|
23
23
|
proxy?: Array<Record<string, any>>;
|
|
24
24
|
https?: boolean;
|
|
25
|
+
headers?: Record<string, any>;
|
|
25
26
|
copy?: Array<string | {
|
|
26
27
|
from: string;
|
|
27
28
|
to: string;
|
|
@@ -38,7 +39,7 @@ export interface GlobalData {
|
|
|
38
39
|
env?: 'dev' | 'prod';
|
|
39
40
|
customConfig: {
|
|
40
41
|
base: Pick<GlobalSwicoConfigType, 'plugins' | 'publicPath' | 'alias' | 'define' | 'devtool' | 'externals' | 'router' | 'template'>;
|
|
41
|
-
dev: Pick<GlobalSwicoConfigType, 'plugins' | 'proxy' | 'https' | 'devtool' | 'router'>;
|
|
42
|
+
dev: Pick<GlobalSwicoConfigType, 'plugins' | 'proxy' | 'https' | 'devtool' | 'router' | 'headers'>;
|
|
42
43
|
prod: Pick<GlobalSwicoConfigType, 'plugins' | 'console' | 'copy' | 'devtool' | 'router'>;
|
|
43
44
|
};
|
|
44
45
|
}
|
package/src/utils/config.js
CHANGED
|
@@ -82,7 +82,14 @@ const getProjectConfig = (env) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
82
82
|
configFileName = 'swico.ts';
|
|
83
83
|
break;
|
|
84
84
|
case 'dev':
|
|
85
|
-
supportedFieldList = [
|
|
85
|
+
supportedFieldList = [
|
|
86
|
+
'plugins',
|
|
87
|
+
'proxy',
|
|
88
|
+
'https',
|
|
89
|
+
'devtool',
|
|
90
|
+
'router',
|
|
91
|
+
'headers'
|
|
92
|
+
];
|
|
86
93
|
configFileName = 'swico.dev.ts';
|
|
87
94
|
break;
|
|
88
95
|
case 'prod':
|
|
@@ -269,6 +276,7 @@ exports.initConfig = {
|
|
|
269
276
|
plugins: [],
|
|
270
277
|
publicPath: '/',
|
|
271
278
|
proxy: undefined,
|
|
279
|
+
headers: undefined,
|
|
272
280
|
copy: [],
|
|
273
281
|
router: {
|
|
274
282
|
base: '/',
|