@alicloud/alfa-react 1.5.13-alpha.0 → 1.5.13-alpha.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/es/createAlfaApp.js +2 -0
- package/es/createApplication.js +23 -2
- package/es/version.js +1 -1
- package/lib/createAlfaApp.js +2 -0
- package/lib/createApplication.js +22 -1
- package/lib/version.js +1 -1
- package/package.json +3 -1
- package/types/createAlfaApp.d.ts +3 -19
- package/types/createAlfaWidget.d.ts +3 -2
- package/types/createApplication.d.ts +52 -13
- package/types/types/index.d.ts +0 -20
- package/types/version.d.ts +1 -1
package/es/createAlfaApp.js
CHANGED
|
@@ -33,6 +33,8 @@ function createAlfaApp(option) {
|
|
|
33
33
|
, _extends({}, passedInOption, {
|
|
34
34
|
style: props.style || passedInOption.style,
|
|
35
35
|
syncHistory: props.syncHistory,
|
|
36
|
+
syncRegion: props.syncRegion,
|
|
37
|
+
syncResourceGroup: props.syncResourceGroup,
|
|
36
38
|
onSyncHistory: props.onSyncHistory,
|
|
37
39
|
basename: props.basename,
|
|
38
40
|
sandbox: option.sandbox || props.sandbox,
|
package/es/createApplication.js
CHANGED
|
@@ -5,8 +5,9 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
import React, { useRef, useEffect, useState, useMemo } from 'react';
|
|
8
|
+
import React, { useRef, useEffect, useState, useMemo, useContext } from 'react';
|
|
9
9
|
import { createEventBus } from '@alicloud/alfa-core';
|
|
10
|
+
import { ConsoleRegion, ConsoleResourceGroup, ConsoleContext } from '@alicloud/xconsole-context';
|
|
10
11
|
import Loading from './components/Loading';
|
|
11
12
|
import { normalizeName } from './utils';
|
|
12
13
|
import { countRegister } from './utils/counter';
|
|
@@ -93,6 +94,8 @@ export default function createApplication(loader) {
|
|
|
93
94
|
dynamicConfig = props.dynamicConfig,
|
|
94
95
|
noCache = props.noCache,
|
|
95
96
|
syncHistory = props.syncHistory,
|
|
97
|
+
syncRegion = props.syncRegion,
|
|
98
|
+
syncResourceGroup = props.syncResourceGroup,
|
|
96
99
|
basename = props.basename,
|
|
97
100
|
onSyncHistory = props.onSyncHistory;
|
|
98
101
|
var handleExternalLink = customProps.handleExternalLink;
|
|
@@ -106,6 +109,9 @@ export default function createApplication(loader) {
|
|
|
106
109
|
var appRef = useRef(undefined);
|
|
107
110
|
var $syncHistory = useRef(syncHistory);
|
|
108
111
|
var $basename = useRef(basename);
|
|
112
|
+
var _useContext = useContext(ConsoleContext),
|
|
113
|
+
regionContext = _useContext.region,
|
|
114
|
+
resourceGroupContext = _useContext.resourceGroup;
|
|
109
115
|
var tagName = normalizeName(props.name);
|
|
110
116
|
var _useState5 = useState(''),
|
|
111
117
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
@@ -123,12 +129,27 @@ export default function createApplication(loader) {
|
|
|
123
129
|
// 受控模式锁定一些参数
|
|
124
130
|
if ($syncHistory.current) {
|
|
125
131
|
// 禁止子应用和 consoleBase 通信
|
|
126
|
-
|
|
132
|
+
customProps.consoleBase = null;
|
|
127
133
|
// 覆写 path 参数,用于通知子应用更新路由
|
|
128
134
|
customProps.path = addLeftSlash(stripBasename(peelPath(window.location), $basename.current));
|
|
129
135
|
// 禁止注入 history
|
|
130
136
|
customProps.__injectHistory = null;
|
|
131
137
|
}
|
|
138
|
+
customProps.consoleBase = _objectSpread(_objectSpread(_objectSpread({}, ConsoleRegion), ConsoleResourceGroup), customProps.consoleBase);
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 同步主应用的 Region
|
|
142
|
+
*/
|
|
143
|
+
if (syncRegion) {
|
|
144
|
+
customProps.consoleBase = _objectSpread(_objectSpread({}, customProps.consoleBase), regionContext);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 同步更新主应用的 ResourceGroup
|
|
149
|
+
*/
|
|
150
|
+
if (syncResourceGroup) {
|
|
151
|
+
customProps.consoleBase = _objectSpread(_objectSpread({}, customProps.consoleBase), resourceGroupContext);
|
|
152
|
+
}
|
|
132
153
|
var sandbox = useMemo(function () {
|
|
133
154
|
var _UA_Opt, _RISK_INFO, _um;
|
|
134
155
|
var aliyunExternalsVars = [];
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '1.5.13-alpha.
|
|
1
|
+
export var version = '1.5.13-alpha.2';
|
package/lib/createAlfaApp.js
CHANGED
|
@@ -44,6 +44,8 @@ function createAlfaApp(option) {
|
|
|
44
44
|
, (0, _extends2.default)({}, passedInOption, {
|
|
45
45
|
style: props.style || passedInOption.style,
|
|
46
46
|
syncHistory: props.syncHistory,
|
|
47
|
+
syncRegion: props.syncRegion,
|
|
48
|
+
syncResourceGroup: props.syncResourceGroup,
|
|
47
49
|
onSyncHistory: props.onSyncHistory,
|
|
48
50
|
basename: props.basename,
|
|
49
51
|
sandbox: option.sandbox || props.sandbox,
|
package/lib/createApplication.js
CHANGED
|
@@ -13,6 +13,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
13
13
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
var _alfaCore = require("@alicloud/alfa-core");
|
|
16
|
+
var _xconsoleContext = require("@alicloud/xconsole-context");
|
|
16
17
|
var _Loading = _interopRequireDefault(require("./components/Loading"));
|
|
17
18
|
var _utils = require("./utils");
|
|
18
19
|
var _counter = require("./utils/counter");
|
|
@@ -103,6 +104,8 @@ function createApplication(loader) {
|
|
|
103
104
|
dynamicConfig = props.dynamicConfig,
|
|
104
105
|
noCache = props.noCache,
|
|
105
106
|
syncHistory = props.syncHistory,
|
|
107
|
+
syncRegion = props.syncRegion,
|
|
108
|
+
syncResourceGroup = props.syncResourceGroup,
|
|
106
109
|
basename = props.basename,
|
|
107
110
|
onSyncHistory = props.onSyncHistory;
|
|
108
111
|
var handleExternalLink = customProps.handleExternalLink;
|
|
@@ -116,6 +119,9 @@ function createApplication(loader) {
|
|
|
116
119
|
var appRef = (0, _react.useRef)(undefined);
|
|
117
120
|
var $syncHistory = (0, _react.useRef)(syncHistory);
|
|
118
121
|
var $basename = (0, _react.useRef)(basename);
|
|
122
|
+
var _useContext = (0, _react.useContext)(_xconsoleContext.ConsoleContext),
|
|
123
|
+
regionContext = _useContext.region,
|
|
124
|
+
resourceGroupContext = _useContext.resourceGroup;
|
|
119
125
|
var tagName = (0, _utils.normalizeName)(props.name);
|
|
120
126
|
var _useState5 = (0, _react.useState)(''),
|
|
121
127
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
@@ -133,12 +139,27 @@ function createApplication(loader) {
|
|
|
133
139
|
// 受控模式锁定一些参数
|
|
134
140
|
if ($syncHistory.current) {
|
|
135
141
|
// 禁止子应用和 consoleBase 通信
|
|
136
|
-
|
|
142
|
+
customProps.consoleBase = null;
|
|
137
143
|
// 覆写 path 参数,用于通知子应用更新路由
|
|
138
144
|
customProps.path = addLeftSlash(stripBasename(peelPath(window.location), $basename.current));
|
|
139
145
|
// 禁止注入 history
|
|
140
146
|
customProps.__injectHistory = null;
|
|
141
147
|
}
|
|
148
|
+
customProps.consoleBase = _objectSpread(_objectSpread(_objectSpread({}, _xconsoleContext.ConsoleRegion), _xconsoleContext.ConsoleResourceGroup), customProps.consoleBase);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 同步主应用的 Region
|
|
152
|
+
*/
|
|
153
|
+
if (syncRegion) {
|
|
154
|
+
customProps.consoleBase = _objectSpread(_objectSpread({}, customProps.consoleBase), regionContext);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 同步更新主应用的 ResourceGroup
|
|
159
|
+
*/
|
|
160
|
+
if (syncResourceGroup) {
|
|
161
|
+
customProps.consoleBase = _objectSpread(_objectSpread({}, customProps.consoleBase), resourceGroupContext);
|
|
162
|
+
}
|
|
142
163
|
var sandbox = (0, _react.useMemo)(function () {
|
|
143
164
|
var _UA_Opt, _RISK_INFO, _um;
|
|
144
165
|
var aliyunExternalsVars = [];
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-react",
|
|
3
|
-
"version": "1.5.13-alpha.
|
|
3
|
+
"version": "1.5.13-alpha.2",
|
|
4
4
|
"description": "Alfa Framework (React Version)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"typescript": "^4.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@alicloud/console-base-messenger": "^1.18.1",
|
|
34
35
|
"@alicloud/widget-utils-console": "^0.1.6",
|
|
36
|
+
"@alicloud/xconsole-context": "^2.4.32",
|
|
35
37
|
"axios": "^1.4.0",
|
|
36
38
|
"classnames": "^2.2.6",
|
|
37
39
|
"crypto-js": "^4.1.1",
|
package/types/createAlfaApp.d.ts
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { AlfaFactoryOption
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* 是否开启路由自动同步,需配合 basename 使用
|
|
6
|
-
*/
|
|
7
|
-
syncHistory?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* 同步子应用路由的回调函数
|
|
10
|
-
*/
|
|
11
|
-
onSyncHistory?: (type: 'replace' | 'push', pathname: string, state: any) => void;
|
|
12
|
-
/**
|
|
13
|
-
* 子应用路由前缀
|
|
14
|
-
*/
|
|
15
|
-
basename?: string;
|
|
16
|
-
history?: any;
|
|
17
|
-
/**
|
|
18
|
-
* 子应用路由
|
|
19
|
-
*/
|
|
20
|
-
path?: string;
|
|
2
|
+
import { AlfaFactoryOption } from './types';
|
|
3
|
+
import type { IApplicationProps, IApplicationCustomProps } from './createApplication';
|
|
4
|
+
interface IProps extends IApplicationProps, IApplicationCustomProps {
|
|
21
5
|
}
|
|
22
6
|
declare function createAlfaApp<P = any>(option: AlfaFactoryOption): (() => null) | ((props: P & IProps) => JSX.Element);
|
|
23
7
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { AlfaFactoryOption
|
|
3
|
-
|
|
2
|
+
import { AlfaFactoryOption } from './types';
|
|
3
|
+
import type { IApplicationCustomProps } from './createApplication';
|
|
4
|
+
interface IProps extends Omit<IApplicationCustomProps, 'consoleBase' | 'path' | 'appConfig'> {
|
|
4
5
|
}
|
|
5
6
|
declare function createAlfaWidget<P = any>(option: AlfaFactoryOption): (() => null) | ((props: P & IProps) => JSX.Element);
|
|
6
7
|
/**
|
|
@@ -1,24 +1,63 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseLoader } from '@alicloud/alfa-core';
|
|
3
3
|
import { AlfaFactoryOption } from './types';
|
|
4
|
-
interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
export interface IApplicationCustomProps {
|
|
5
|
+
/**
|
|
6
|
+
* 根结点样式
|
|
7
|
+
*/
|
|
8
|
+
style?: Record<string, any>;
|
|
9
|
+
/**
|
|
10
|
+
* 注入给子应用的 consoleBase 配置
|
|
11
|
+
*/
|
|
12
|
+
consoleBase?: any;
|
|
13
|
+
/**
|
|
14
|
+
* 指定子应用 path
|
|
15
|
+
*/
|
|
16
|
+
path?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 注入给子应用的运行时配置
|
|
19
|
+
*/
|
|
20
|
+
appConfig?: any;
|
|
21
|
+
__injectHistory?: any;
|
|
22
|
+
__innerStamp?: string;
|
|
23
|
+
__historyState?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 处理外部链接跳转
|
|
26
|
+
* @param href
|
|
27
|
+
*/
|
|
28
|
+
handleExternalLink?: (href: string) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface IApplicationProps<C = any> extends AlfaFactoryOption {
|
|
31
|
+
customProps: C & IApplicationCustomProps;
|
|
32
|
+
/**
|
|
33
|
+
* 是否开启路由自动同步,需配合 basename 使用
|
|
34
|
+
*/
|
|
14
35
|
syncHistory?: boolean;
|
|
15
|
-
|
|
36
|
+
/**
|
|
37
|
+
* 是否开启 region 自动同步
|
|
38
|
+
*/
|
|
39
|
+
syncRegion?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* 是否开启资源组自动同步
|
|
42
|
+
*/
|
|
43
|
+
syncResourceGroup?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* 同步子应用路由的回调函数
|
|
46
|
+
*/
|
|
47
|
+
onSyncHistory?: (type: 'replace' | 'push', pathname: string, state: any) => void;
|
|
48
|
+
/**
|
|
49
|
+
* 分配给子应用的路由前缀
|
|
50
|
+
*/
|
|
16
51
|
basename?: string;
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated
|
|
54
|
+
* 注入给子应用的 history 实例,不推荐使用
|
|
55
|
+
*/
|
|
56
|
+
history?: any;
|
|
17
57
|
}
|
|
18
58
|
/**
|
|
19
59
|
* container for microApp mount
|
|
20
60
|
* @param loader alfa-core loader
|
|
21
61
|
* @returns
|
|
22
62
|
*/
|
|
23
|
-
export default function createApplication(loader: BaseLoader): <C = any>(props:
|
|
24
|
-
export {};
|
|
63
|
+
export default function createApplication(loader: BaseLoader): <C = any>(props: IApplicationProps<C>) => JSX.Element;
|
package/types/types/index.d.ts
CHANGED
|
@@ -41,26 +41,6 @@ export interface AlfaFactoryOption extends IAppConfig {
|
|
|
41
41
|
*/
|
|
42
42
|
fallbackRender?: (error?: Error) => Element;
|
|
43
43
|
}
|
|
44
|
-
export interface CommonProps {
|
|
45
|
-
/**
|
|
46
|
-
* @deprecated
|
|
47
|
-
*/
|
|
48
|
-
sandbox?: Record<string, any>;
|
|
49
|
-
/**
|
|
50
|
-
* 处理外跳链接
|
|
51
|
-
* @param url
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
handleExternalLink?: (url?: string) => void;
|
|
55
|
-
/**
|
|
56
|
-
* 根节点样式
|
|
57
|
-
*/
|
|
58
|
-
style?: React.CSSProperties;
|
|
59
|
-
/**
|
|
60
|
-
* render when throw error
|
|
61
|
-
*/
|
|
62
|
-
fallbackRender?: (error?: Error) => Element;
|
|
63
|
-
}
|
|
64
44
|
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T;
|
|
65
45
|
export type MicroApplication = ThenArg<ReturnType<typeof createMicroApp>>;
|
|
66
46
|
export interface AlfaEnvConfigDescriptor {
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.5.13-alpha.
|
|
1
|
+
export declare const version = "1.5.13-alpha.2";
|