@umijs/plugins 4.0.21 → 4.0.23
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/dist/access.js +45 -34
- package/dist/dva.js +66 -1
- package/dist/layout.js +10 -9
- package/dist/qiankun/slave.js +6 -10
- package/dist/valtio.d.ts +3 -0
- package/dist/valtio.js +64 -0
- package/libs/locale/runtime.tpl +3 -5
- package/libs/qiankun/slave/lifecycles.ts +1 -1
- package/package.json +4 -3
package/dist/access.js
CHANGED
|
@@ -50,7 +50,7 @@ import { AccessContext } from './context';
|
|
|
50
50
|
|
|
51
51
|
function Provider(props) {${hasAccessFile ? `
|
|
52
52
|
const { initialState } = useModel('@@initialState');
|
|
53
|
-
const access =
|
|
53
|
+
const access = accessFactory(initialState);
|
|
54
54
|
` : `
|
|
55
55
|
const access = {};
|
|
56
56
|
`}
|
|
@@ -91,48 +91,59 @@ export const Access: React.FC<PropsWithChildren<AccessProps>> = (props) => {
|
|
|
91
91
|
|
|
92
92
|
export const useAccessMarkedRoutes = (routes: IRoute[]) => {
|
|
93
93
|
const access = useAccess();
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// check access code
|
|
102
|
-
if (typeof accessCode === 'string') {
|
|
103
|
-
const detector = access[accessCode];
|
|
104
|
-
|
|
105
|
-
if (typeof detector === 'function') {
|
|
106
|
-
route.unaccessible = !detector(route);
|
|
107
|
-
} else if (typeof detector === 'boolean') {
|
|
108
|
-
route.unaccessible = !detector;
|
|
109
|
-
} else if (typeof detector === 'undefined') {
|
|
110
|
-
route.unaccessible = true;
|
|
111
|
-
}
|
|
94
|
+
const process = (route, parentAccessCode, parentRoute) => {
|
|
95
|
+
let accessCode = route.access;
|
|
96
|
+
// \u7528\u7236\u7EA7\u7684\u8DEF\u7531\u68C0\u6D4B\u7236\u7EA7\u7684 accessCode
|
|
97
|
+
let detectorRoute = route;
|
|
98
|
+
if (!accessCode && parentAccessCode) {
|
|
99
|
+
accessCode = parentAccessCode;
|
|
100
|
+
detectorRoute = parentRoute;
|
|
112
101
|
}
|
|
113
102
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const isNoAccessibleChild = !route.children.reduce((hasAccessibleChild, child) => {
|
|
117
|
-
process(child, accessCode);
|
|
103
|
+
// set default status
|
|
104
|
+
route.unaccessible = ${api.config.access.strictMode ? "true" : "false"};
|
|
118
105
|
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
// check access code
|
|
107
|
+
if (typeof accessCode === "string") {
|
|
108
|
+
const detector = access[accessCode];
|
|
121
109
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
110
|
+
if (typeof detector === "function") {
|
|
111
|
+
route.unaccessible = !detector(detectorRoute);
|
|
112
|
+
} else if (typeof detector === "boolean") {
|
|
113
|
+
route.unaccessible = !detector;
|
|
114
|
+
} else if (typeof detector === "undefined") {
|
|
115
|
+
route.unaccessible = true;
|
|
126
116
|
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// check children access code
|
|
120
|
+
if (route.children?.length) {
|
|
121
|
+
const isNoAccessibleChild = !route.children.reduce(
|
|
122
|
+
(hasAccessibleChild, child) => {
|
|
123
|
+
process(child, accessCode, route);
|
|
124
|
+
|
|
125
|
+
return hasAccessibleChild || !child.unaccessible;
|
|
126
|
+
},
|
|
127
|
+
false
|
|
128
|
+
);
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
// make sure parent route is unaccessible if all children are unaccessible
|
|
131
|
+
if (isNoAccessibleChild) {
|
|
132
|
+
route.unaccessible = true;
|
|
133
|
+
}
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
// \u4E3A\u4E86\u517C\u5BB9\u65E7\u7248\u672C\u7684layout\uFF0C<= 7.1.0
|
|
137
|
+
// \u5982\u679C\u662F 7.1.0 \u4EE5\u4E0B\u7684layout\u53EF\u80FD\u4F1A\u51FA\u73B0\u6570\u636E\u5F02\u5E38\u3002
|
|
138
|
+
delete route.routes;
|
|
139
|
+
route.routes = route.children;
|
|
140
|
+
|
|
141
|
+
return route;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return routes.map((route) => process(route));
|
|
145
|
+
};
|
|
133
146
|
|
|
134
|
-
return markdedRoutes;
|
|
135
|
-
}
|
|
136
147
|
`
|
|
137
148
|
});
|
|
138
149
|
api.writeTmpFile({
|
package/dist/dva.js
CHANGED
|
@@ -41,7 +41,8 @@ var dva_default = (api) => {
|
|
|
41
41
|
schema(Joi) {
|
|
42
42
|
return Joi.alternatives().try(Joi.object({
|
|
43
43
|
extraModels: Joi.array().items(Joi.string()),
|
|
44
|
-
immer: Joi.object()
|
|
44
|
+
immer: Joi.object(),
|
|
45
|
+
skipModelValidate: Joi.boolean()
|
|
45
46
|
}), Joi.boolean().invalid(true));
|
|
46
47
|
}
|
|
47
48
|
},
|
|
@@ -171,6 +172,68 @@ export { connect, useDispatch, useStore, useSelector } from 'dva';
|
|
|
171
172
|
export { getDvaApp } from './dva';
|
|
172
173
|
`
|
|
173
174
|
});
|
|
175
|
+
api.writeTmpFile({
|
|
176
|
+
path: "types.d.ts",
|
|
177
|
+
tpl: `
|
|
178
|
+
import type { History } from 'umi';
|
|
179
|
+
|
|
180
|
+
export interface ConnectProps {
|
|
181
|
+
dispatch?: Dispatch;
|
|
182
|
+
}
|
|
183
|
+
type RequiredConnectProps = Required<ConnectProps>
|
|
184
|
+
export type ConnectRC<
|
|
185
|
+
T = {},
|
|
186
|
+
> = React.ForwardRefRenderFunction<any, T & RequiredConnectProps>;
|
|
187
|
+
interface Action<T = any> {
|
|
188
|
+
type: T
|
|
189
|
+
}
|
|
190
|
+
interface AnyAction extends Action {
|
|
191
|
+
// Allows any extra properties to be defined in an action.
|
|
192
|
+
[extraProps: string]: any
|
|
193
|
+
}
|
|
194
|
+
interface Dispatch<A extends Action = AnyAction> {
|
|
195
|
+
<T extends A>(action: T): T
|
|
196
|
+
}
|
|
197
|
+
interface EffectsCommandMap {
|
|
198
|
+
put: <A extends AnyAction>(action: A) => any,
|
|
199
|
+
call: Function,
|
|
200
|
+
select: Function,
|
|
201
|
+
take: Function,
|
|
202
|
+
cancel: Function,
|
|
203
|
+
[key: string]: any,
|
|
204
|
+
}
|
|
205
|
+
interface Action<T = any> {
|
|
206
|
+
type: T
|
|
207
|
+
}
|
|
208
|
+
export type Reducer<S = any, A extends Action = AnyAction> = (prevState: S, action: A) => S;
|
|
209
|
+
export type Effect = (action: AnyAction, effects: EffectsCommandMap) => void;
|
|
210
|
+
type EffectType = 'takeEvery' | 'takeLatest' | 'watcher' | 'throttle';
|
|
211
|
+
type EffectWithType = [Effect, { type: EffectType }];
|
|
212
|
+
export type Subscription = (api: SubscriptionAPI, done: Function) => void;
|
|
213
|
+
|
|
214
|
+
export interface ReducersMapObject<T> {
|
|
215
|
+
[key: string]: Reducer<T>,
|
|
216
|
+
}
|
|
217
|
+
export interface EffectsMapObject {
|
|
218
|
+
[key: string]: Effect | EffectWithType,
|
|
219
|
+
}
|
|
220
|
+
export interface SubscriptionAPI {
|
|
221
|
+
dispatch: Dispatch<any>,
|
|
222
|
+
history: History,
|
|
223
|
+
}
|
|
224
|
+
export interface SubscriptionsMapObject {
|
|
225
|
+
[key: string]: Subscription,
|
|
226
|
+
}
|
|
227
|
+
export interface DvaModel<T, E = EffectsMapObject, R = ReducersMapObject<T>> {
|
|
228
|
+
namespace: string,
|
|
229
|
+
state?: T,
|
|
230
|
+
reducers?: R,
|
|
231
|
+
effects?: E,
|
|
232
|
+
subscriptions?: SubscriptionsMapObject,
|
|
233
|
+
}
|
|
234
|
+
`,
|
|
235
|
+
context: {}
|
|
236
|
+
});
|
|
174
237
|
});
|
|
175
238
|
api.addTmpGenerateWatcherPaths(() => {
|
|
176
239
|
return [(0, import_path.join)(api.paths.absSrcPath, "models")];
|
|
@@ -192,6 +255,8 @@ export { getDvaApp } from './dva';
|
|
|
192
255
|
function getModelUtil(api) {
|
|
193
256
|
return new import_modelUtils.ModelUtils(api, {
|
|
194
257
|
contentTest(content) {
|
|
258
|
+
if (api == null ? void 0 : api.config.dva.skipModelValidate)
|
|
259
|
+
return true;
|
|
195
260
|
return content.startsWith("// @dva-model");
|
|
196
261
|
},
|
|
197
262
|
astTest({ node, content }) {
|
package/dist/layout.js
CHANGED
|
@@ -124,13 +124,13 @@ const filterRoutes = (routes: IRoute[], filterFn: (route: IRoute) => boolean) =>
|
|
|
124
124
|
let newRoutes = []
|
|
125
125
|
for (const route of routes) {
|
|
126
126
|
if (filterFn(route)) {
|
|
127
|
-
if (Array.isArray(route.
|
|
128
|
-
newRoutes.push(...filterRoutes(route.
|
|
127
|
+
if (Array.isArray(route.children)) {
|
|
128
|
+
newRoutes.push(...filterRoutes(route.children, filterFn))
|
|
129
129
|
}
|
|
130
130
|
} else {
|
|
131
131
|
newRoutes.push(route);
|
|
132
|
-
if (Array.isArray(route.
|
|
133
|
-
route.
|
|
132
|
+
if (Array.isArray(route.children)) {
|
|
133
|
+
route.children = filterRoutes(route.children, filterFn);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -150,11 +150,11 @@ const mapRoutes = (routes: IRoute[]) => {
|
|
|
150
150
|
newRoute.path = route.originPath
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
if (Array.isArray(route.
|
|
154
|
-
newRoute.
|
|
153
|
+
if (Array.isArray(route.children)) {
|
|
154
|
+
newRoute.children = mapRoutes(route.children);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
return newRoute
|
|
157
|
+
return newRoute;
|
|
158
158
|
})
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -180,12 +180,13 @@ const { formatMessage } = useIntl();
|
|
|
180
180
|
},
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
const
|
|
183
|
+
const matchedRouteNoAccess = useMemo(() => matchRoutes(clientRoutes, location.pathname)?.pop()?.route||[], [location.pathname]);
|
|
184
|
+
// \u73B0\u5728\u7684 layout \u53CA wrapper \u5B9E\u73B0\u662F\u901A\u8FC7\u7236\u8DEF\u7531\u7684\u5F62\u5F0F\u5B9E\u73B0\u7684, \u4F1A\u5BFC\u81F4\u8DEF\u7531\u6570\u636E\u591A\u4E86\u5197\u4F59\u5C42\u7EA7, proLayout \u6D88\u8D39\u65F6, \u65E0\u6CD5\u6B63\u786E\u5C55\u793A\u83DC\u5355, \u8FD9\u91CC\u5BF9\u5197\u4F59\u6570\u636E\u8FDB\u884C\u8FC7\u6EE4\u64CD\u4F5C
|
|
184
185
|
const newRoutes = filterRoutes(clientRoutes.filter(route => route.id === 'ant-design-pro-layout'), (route) => {
|
|
185
186
|
return (!!route.isLayout && route.id !== 'ant-design-pro-layout') || !!route.isWrapper;
|
|
186
187
|
})
|
|
187
188
|
const [route] = useAccessMarkedRoutes(mapRoutes(newRoutes));
|
|
188
|
-
|
|
189
|
+
const [matchedRoute] = useAccessMarkedRoutes([matchedRouteNoAccess]);
|
|
189
190
|
return (
|
|
190
191
|
<ProLayout
|
|
191
192
|
route={route}
|
package/dist/qiankun/slave.js
CHANGED
|
@@ -122,7 +122,7 @@ export interface IRuntimeConfig {
|
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
124
|
api.modifyDefaultConfig((memo) => {
|
|
125
|
-
var _a, _b, _c;
|
|
125
|
+
var _a, _b, _c, _d, _e;
|
|
126
126
|
const initialSlaveOptions = {
|
|
127
127
|
devSourceMap: true,
|
|
128
128
|
...JSON.parse(process.env.INITIAL_QIANKUN_SLAVE_OPTIONS || "{}"),
|
|
@@ -141,17 +141,13 @@ export interface IRuntimeConfig {
|
|
|
141
141
|
if (!shouldNotModifyDefaultBase && historyType !== "hash") {
|
|
142
142
|
modifiedDefaultConfig.base = `/${api.pkg.name}`;
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (config.mfsu !== false) {
|
|
149
|
-
config.mfsu = {
|
|
150
|
-
...config.mfsu,
|
|
151
|
-
mfName: ((_a = config.mfsu) == null ? void 0 : _a.mfName) || `mf_${(_b = api.pkg.name) == null ? void 0 : _b.replace(/^@/, "").replace(/\W/g, "_")}`
|
|
144
|
+
if (modifiedDefaultConfig.mfsu !== false) {
|
|
145
|
+
modifiedDefaultConfig.mfsu = {
|
|
146
|
+
...modifiedDefaultConfig.mfsu,
|
|
147
|
+
mfName: ((_d = modifiedDefaultConfig.mfsu) == null ? void 0 : _d.mfName) || `mf_${(_e = api.pkg.name) == null ? void 0 : _e.replace(/^@/, "").replace(/\W/g, "_")}`
|
|
152
148
|
};
|
|
153
149
|
}
|
|
154
|
-
return
|
|
150
|
+
return modifiedDefaultConfig;
|
|
155
151
|
});
|
|
156
152
|
api.addHTMLHeadScripts(() => {
|
|
157
153
|
var _a, _b;
|
package/dist/valtio.d.ts
ADDED
package/dist/valtio.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/valtio.ts
|
|
23
|
+
var valtio_exports = {};
|
|
24
|
+
__export(valtio_exports, {
|
|
25
|
+
default: () => valtio_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(valtio_exports);
|
|
28
|
+
var import_path = require("path");
|
|
29
|
+
var import_utils = require("@umijs/utils");
|
|
30
|
+
var valtio_default = (api) => {
|
|
31
|
+
api.describe({
|
|
32
|
+
key: "valtio",
|
|
33
|
+
config: {
|
|
34
|
+
schema(joi) {
|
|
35
|
+
return joi.object();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const libPath = (0, import_utils.winPath)((0, import_path.dirname)(require.resolve("@umijs/valtio/package.json")));
|
|
40
|
+
api.onGenerateFiles(() => {
|
|
41
|
+
api.writeTmpFile({
|
|
42
|
+
path: "index.ts",
|
|
43
|
+
content: `
|
|
44
|
+
export {
|
|
45
|
+
proxy, useSnapshot, snapshot, subscribe,
|
|
46
|
+
proxyWithComputed,
|
|
47
|
+
proxyWithHistory,
|
|
48
|
+
proxyWithDevtools,
|
|
49
|
+
proxyMap,
|
|
50
|
+
proxySet,
|
|
51
|
+
} from '${libPath}';
|
|
52
|
+
`
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
api.modifyConfig((memo) => {
|
|
56
|
+
memo.alias = {
|
|
57
|
+
...memo.alias,
|
|
58
|
+
"@umijs/valtio": libPath
|
|
59
|
+
};
|
|
60
|
+
return memo;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {});
|
package/libs/locale/runtime.tpl
CHANGED
|
@@ -16,15 +16,13 @@ export function patchRoutes({ routes }) {
|
|
|
16
16
|
Object.keys(routes).forEach((key) => {
|
|
17
17
|
const route = routes[key];
|
|
18
18
|
if (route.title) {
|
|
19
|
+
route.locale = route.title;
|
|
19
20
|
const newTitle = intl.messages[route.title] ? intl.formatMessage({ id: route.title }, {}) : route.title;
|
|
20
21
|
route.name = intl.messages[route.title] ? intl.formatMessage({ id: route.title }, {}) : route.name;
|
|
21
22
|
route.title = newTitle;
|
|
22
23
|
}
|
|
23
|
-
if (route.
|
|
24
|
-
traverseRoute(route.
|
|
25
|
-
}
|
|
26
|
-
if (route.routes) {
|
|
27
|
-
traverseRoute(route.routes);
|
|
24
|
+
if (route.children) {
|
|
25
|
+
traverseRoute(route.children);
|
|
28
26
|
}
|
|
29
27
|
})
|
|
30
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugins",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.23",
|
|
4
4
|
"description": "@umijs/plugins",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"@ant-design/antd-theme-variable": "^1.0.0",
|
|
28
28
|
"@ant-design/icons": "^4.7.0",
|
|
29
29
|
"@ant-design/pro-components": "^2.0.1",
|
|
30
|
-
"@umijs/bundler-utils": "4.0.
|
|
30
|
+
"@umijs/bundler-utils": "4.0.23",
|
|
31
|
+
"@umijs/valtio": "^1.0.0",
|
|
31
32
|
"antd-dayjs-webpack-plugin": "^1.0.6",
|
|
32
33
|
"axios": "^0.27.2",
|
|
33
34
|
"babel-plugin-import": "^1.13.5",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"warning": "^4.0.3"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"umi": "4.0.
|
|
50
|
+
"umi": "4.0.23"
|
|
50
51
|
},
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"access": "public"
|