swico 2.9.0-beta.2 → 2.9.0-beta.4
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.d.ts +3 -2
- package/src/index.react.d.ts +3 -3
- package/src/index.vue.d.ts +3 -3
- package/src/main-config/index.d.ts +2 -2
- package/src/rspack-config/rsbpack.dev.d.ts +2 -2
- package/src/rspack-config/rspack.base.react.d.ts +2 -2
- package/src/rspack-config/rspack.base.vue.d.ts +2 -2
- package/src/rspack-config/rspack.prod.d.ts +2 -2
- package/src/template-root/.swico-vue/$env/history.d.ts +0 -6
- package/src/template-root/.swico-vue/$env/history.js +1 -21
- package/src/template-root/.swico-vue/$env/index.js +1 -2
- package/src/template-root/.swico-vue/hooks.js +0 -6
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GlobalDataType, GlobalSwicoConfigType } from './main-config';
|
|
2
2
|
import { UseLocationType, UseNavType } from './typings/global-type';
|
|
3
3
|
import { App } from 'vue';
|
|
4
4
|
import { Router } from 'vue-router';
|
|
5
|
-
export type CustomConfigType =
|
|
5
|
+
export type CustomConfigType = GlobalDataType['customConfig'];
|
|
6
|
+
export type * from './main-config';
|
|
6
7
|
export type * from './typings/global-type';
|
|
7
8
|
export type { GlobalSwicoConfigType };
|
|
8
9
|
export { history } from './mock-history';
|
package/src/index.react.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GlobalDataType } from './main-config';
|
|
2
2
|
import { CSSProperties, FC, ReactNode } from 'react';
|
|
3
3
|
import { SwicoHistoryOptionType } from './typings/global-type';
|
|
4
4
|
import { useLocation, useNav } from './template-root/.swico-react/hooks';
|
|
5
|
-
export type CustomConfigType =
|
|
5
|
+
export type CustomConfigType = GlobalDataType['customConfig'];
|
|
6
6
|
export type * from './typings/global-type';
|
|
7
|
-
export type
|
|
7
|
+
export type * from './main-config';
|
|
8
8
|
interface LinkPropsType {
|
|
9
9
|
replace?: boolean;
|
|
10
10
|
to: string | number | SwicoHistoryOptionType;
|
package/src/index.vue.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GlobalDataType } from './main-config';
|
|
2
2
|
import { App } from 'vue';
|
|
3
3
|
import { Router } from 'vue-router';
|
|
4
4
|
import { useLocation, useNav } from './template-root/.swico-vue/hooks';
|
|
5
5
|
import { SwicoHistoryOptionType } from './typings/global-type';
|
|
6
|
-
export type CustomConfigType =
|
|
6
|
+
export type CustomConfigType = GlobalDataType['customConfig'];
|
|
7
7
|
export { RouterView } from 'vue-router';
|
|
8
8
|
export { useLocation, useNav };
|
|
9
9
|
export { history } from './mock-history';
|
|
10
|
-
export type { GlobalSwicoConfigType };
|
|
11
10
|
export type * from './typings/global-type';
|
|
11
|
+
export type * from './main-config';
|
|
12
12
|
export declare const Outlet: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
13
13
|
interface LinkPropsType {
|
|
14
14
|
replace?: boolean;
|
|
@@ -31,7 +31,7 @@ export interface GlobalSwicoConfigType {
|
|
|
31
31
|
externals?: any;
|
|
32
32
|
router?: ConfigRouterType;
|
|
33
33
|
}
|
|
34
|
-
export interface
|
|
34
|
+
export interface GlobalDataType {
|
|
35
35
|
templateType?: GlobalSwicoConfigType['template'];
|
|
36
36
|
projectPath: string;
|
|
37
37
|
entryPath: string;
|
|
@@ -43,7 +43,7 @@ export interface GlobalData {
|
|
|
43
43
|
prod: Pick<GlobalSwicoConfigType, 'plugins' | 'console' | 'copy' | 'devtool' | 'router'>;
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
export declare const getProjectConfig: (env:
|
|
46
|
+
export declare const getProjectConfig: (env: GlobalDataType['env']) => Promise<GlobalDataType>;
|
|
47
47
|
export declare const handleLoadingFile: (projectPath: any, replaceIndexText: any) => Promise<any>;
|
|
48
48
|
export declare const handleGlobalStyleFile: (replaceIndexText: any) => any;
|
|
49
49
|
export declare const updateIndexFileText: (envPath: any, newFileText: any) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function (options:
|
|
1
|
+
import { GlobalDataType } from '../main-config';
|
|
2
|
+
export default function (options: GlobalDataType): Promise<any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function ({ projectPath, entryPath, env, customConfig }:
|
|
1
|
+
import { GlobalDataType } from '../main-config';
|
|
2
|
+
export default function ({ projectPath, entryPath, env, customConfig }: GlobalDataType): Promise<{
|
|
3
3
|
entry: string;
|
|
4
4
|
output: {
|
|
5
5
|
path: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function ({ projectPath, entryPath, env, customConfig }:
|
|
1
|
+
import { GlobalDataType } from '../main-config';
|
|
2
|
+
export default function ({ projectPath, entryPath, env, customConfig }: GlobalDataType): Promise<{
|
|
3
3
|
entry: string;
|
|
4
4
|
output: {
|
|
5
5
|
path: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default function (options:
|
|
1
|
+
import { GlobalDataType } from '../main-config';
|
|
2
|
+
export default function (options: GlobalDataType): Promise<any>;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
import { SwicoHistoryType } from '../../../typings/global-type';
|
|
2
2
|
export declare let history: SwicoHistoryType;
|
|
3
|
-
export declare const formatAncPath: (ancPath: string) => string;
|
|
4
|
-
export declare const pathNameList: {
|
|
5
|
-
path: string;
|
|
6
|
-
name: string;
|
|
7
|
-
custom?: any;
|
|
8
|
-
}[];
|
|
9
3
|
export declare const getRouter: () => import("vue-router").Router;
|
|
@@ -3,7 +3,7 @@ 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
|
-
exports.getRouter = exports.
|
|
6
|
+
exports.getRouter = exports.history = void 0;
|
|
7
7
|
const vue_router_1 = require("vue-router");
|
|
8
8
|
const router_1 = require("./router");
|
|
9
9
|
const qs_1 = __importDefault(require("qs"));
|
|
@@ -14,26 +14,6 @@ const transformRouteItemCustomToMeta = (routeItem) => {
|
|
|
14
14
|
return Object.assign(Object.assign({}, newRouteItem), { children: children === null || children === void 0 ? void 0 : children.map((item) => transformRouteItemCustomToMeta(item)) });
|
|
15
15
|
};
|
|
16
16
|
const formatRoutes = router_1.routes.map((routeItem) => transformRouteItemCustomToMeta(routeItem));
|
|
17
|
-
const formatAncPath = (ancPath) => {
|
|
18
|
-
let newAncPath = ancPath.startsWith('/') ? ancPath : '/' + ancPath;
|
|
19
|
-
newAncPath = newAncPath.endsWith('/') ? newAncPath.slice(0, -1) : newAncPath;
|
|
20
|
-
return newAncPath;
|
|
21
|
-
};
|
|
22
|
-
exports.formatAncPath = formatAncPath;
|
|
23
|
-
const getPathNameList = (routes) => {
|
|
24
|
-
const list = [];
|
|
25
|
-
const checkRouteItem = (item, ancPath) => {
|
|
26
|
-
const { path, name, children, custom } = item;
|
|
27
|
-
const newAncPath = `${(0, exports.formatAncPath)(ancPath)}${path.startsWith('/') ? path : '/' + path}`;
|
|
28
|
-
list.push({ path: newAncPath, name, custom });
|
|
29
|
-
if (children) {
|
|
30
|
-
children.some((item) => checkRouteItem(item, newAncPath));
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
routes.forEach((item) => checkRouteItem(item, ''));
|
|
34
|
-
return list;
|
|
35
|
-
};
|
|
36
|
-
exports.pathNameList = getPathNameList(router_1.routes);
|
|
37
17
|
const getRouter = () => {
|
|
38
18
|
const router = (0, vue_router_1.createRouter)({
|
|
39
19
|
history: (router_1.routerType === 'hash' ? vue_router_1.createWebHashHistory : vue_router_1.createWebHistory)(router_1.routerBase),
|
|
@@ -14,11 +14,10 @@ const Container = (0, vue_1.defineComponent)({
|
|
|
14
14
|
const error = (0, vue_1.ref)(null);
|
|
15
15
|
(0, vue_1.onErrorCaptured)((err) => {
|
|
16
16
|
error.value = err.toString();
|
|
17
|
-
return false;
|
|
18
17
|
});
|
|
19
18
|
return { error };
|
|
20
19
|
},
|
|
21
|
-
template: '<SwicoLayout
|
|
20
|
+
template: '<SwicoLayout ></SwicoLayout>'
|
|
22
21
|
});
|
|
23
22
|
const router = (0, history_1.getRouter)();
|
|
24
23
|
const app = (0, vue_1.createApp)(Container);
|
|
@@ -8,7 +8,6 @@ const vue_router_1 = require("vue-router");
|
|
|
8
8
|
const qs_1 = __importDefault(require("qs"));
|
|
9
9
|
const vue_1 = require("vue");
|
|
10
10
|
const router_1 = require("./$env/router");
|
|
11
|
-
const history_1 = require("./$env/history");
|
|
12
11
|
const getFormatRouterBase = (routerBase) => {
|
|
13
12
|
const lastIndexBase = routerBase[routerBase.length - 1];
|
|
14
13
|
return lastIndexBase === '/' ? routerBase.slice(0, routerBase.length - 1) : routerBase;
|
|
@@ -46,7 +45,6 @@ exports.useLocation = useLocation;
|
|
|
46
45
|
const useNav = () => {
|
|
47
46
|
const router = (0, vue_router_1.useRouter)();
|
|
48
47
|
const newNavigate = (to, options) => {
|
|
49
|
-
var _a;
|
|
50
48
|
switch (typeof to) {
|
|
51
49
|
case 'string':
|
|
52
50
|
if (options === null || options === void 0 ? void 0 : options.replace) {
|
|
@@ -60,10 +58,6 @@ const useNav = () => {
|
|
|
60
58
|
router.go(to);
|
|
61
59
|
break;
|
|
62
60
|
case 'object': {
|
|
63
|
-
const name = to.name;
|
|
64
|
-
if (name && !((_a = history_1.pathNameList.find((item) => item.name === name)) === null || _a === void 0 ? void 0 : _a.path)) {
|
|
65
|
-
throw `An error occurred while executing 'useNav()' operation: The path for the name "${to.name}" could not be found`;
|
|
66
|
-
}
|
|
67
61
|
if (options === null || options === void 0 ? void 0 : options.replace) {
|
|
68
62
|
router.replace(to);
|
|
69
63
|
}
|