@alicloud/alfa-react 1.5.13-alpha.1 → 1.5.13-alpha.3

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.
@@ -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,
@@ -8,6 +8,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
8
8
  import React, { useRef, useEffect, useState, useMemo, useContext } from 'react';
9
9
  import { createEventBus } from '@alicloud/alfa-core';
10
10
  import { ConsoleRegion, ConsoleResourceGroup, ConsoleContext } from '@alicloud/xconsole-context';
11
+ import { forApp } from '@alicloud/console-base-messenger';
11
12
  import Loading from './components/Loading';
12
13
  import { normalizeName } from './utils';
13
14
  import { countRegister } from './utils/counter';
@@ -135,20 +136,37 @@ export default function createApplication(loader) {
135
136
  // 禁止注入 history
136
137
  customProps.__injectHistory = null;
137
138
  }
138
- customProps.consoleBase = _objectSpread(_objectSpread(_objectSpread({}, ConsoleRegion), ConsoleResourceGroup), customProps.consoleBase);
139
139
 
140
140
  /**
141
141
  * 同步主应用的 Region
142
- */
143
- if (syncRegion) {
144
- customProps.consoleBase = _objectSpread(_objectSpread({}, customProps.consoleBase), regionContext);
145
- }
146
-
147
- /**
148
142
  * 同步更新主应用的 ResourceGroup
149
143
  */
150
- if (syncResourceGroup) {
151
- customProps.consoleBase = _objectSpread(_objectSpread({}, customProps.consoleBase), resourceGroupContext);
144
+ if (syncRegion || syncResourceGroup) {
145
+ var region;
146
+ var resourceGroup;
147
+ if (syncRegion) {
148
+ // regionContext 为默认值时,不覆盖
149
+ if (regionContext === ConsoleRegion) {
150
+ region = undefined;
151
+ } else {
152
+ region = regionContext;
153
+ }
154
+ } else {
155
+ region = ConsoleRegion;
156
+ }
157
+ if (syncResourceGroup) {
158
+ // resourceGroupContext 为默认值时,不覆盖
159
+ if (resourceGroupContext === ConsoleResourceGroup) {
160
+ resourceGroup = undefined;
161
+ } else {
162
+ resourceGroup = resourceGroupContext;
163
+ }
164
+ } else {
165
+ resourceGroup = ConsoleResourceGroup;
166
+ }
167
+ customProps.consoleBase = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customProps.consoleBase), forApp), region), resourceGroup);
168
+ } else {
169
+ customProps.consoleBase = _objectSpread(_objectSpread(_objectSpread({}, ConsoleRegion), ConsoleResourceGroup), customProps.consoleBase);
152
170
  }
153
171
  var sandbox = useMemo(function () {
154
172
  var _UA_Opt, _RISK_INFO, _um;
package/es/version.js CHANGED
@@ -1 +1 @@
1
- export var version = '1.5.13-alpha.1';
1
+ export var version = '1.5.13-alpha.3';
@@ -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,
@@ -14,6 +14,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
14
14
  var _react = _interopRequireWildcard(require("react"));
15
15
  var _alfaCore = require("@alicloud/alfa-core");
16
16
  var _xconsoleContext = require("@alicloud/xconsole-context");
17
+ var _consoleBaseMessenger = require("@alicloud/console-base-messenger");
17
18
  var _Loading = _interopRequireDefault(require("./components/Loading"));
18
19
  var _utils = require("./utils");
19
20
  var _counter = require("./utils/counter");
@@ -145,20 +146,37 @@ function createApplication(loader) {
145
146
  // 禁止注入 history
146
147
  customProps.__injectHistory = null;
147
148
  }
148
- customProps.consoleBase = _objectSpread(_objectSpread(_objectSpread({}, _xconsoleContext.ConsoleRegion), _xconsoleContext.ConsoleResourceGroup), customProps.consoleBase);
149
149
 
150
150
  /**
151
151
  * 同步主应用的 Region
152
- */
153
- if (syncRegion) {
154
- customProps.consoleBase = _objectSpread(_objectSpread({}, customProps.consoleBase), regionContext);
155
- }
156
-
157
- /**
158
152
  * 同步更新主应用的 ResourceGroup
159
153
  */
160
- if (syncResourceGroup) {
161
- customProps.consoleBase = _objectSpread(_objectSpread({}, customProps.consoleBase), resourceGroupContext);
154
+ if (syncRegion || syncResourceGroup) {
155
+ var region;
156
+ var resourceGroup;
157
+ if (syncRegion) {
158
+ // regionContext 为默认值时,不覆盖
159
+ if (regionContext === _xconsoleContext.ConsoleRegion) {
160
+ region = undefined;
161
+ } else {
162
+ region = regionContext;
163
+ }
164
+ } else {
165
+ region = _xconsoleContext.ConsoleRegion;
166
+ }
167
+ if (syncResourceGroup) {
168
+ // resourceGroupContext 为默认值时,不覆盖
169
+ if (resourceGroupContext === _xconsoleContext.ConsoleResourceGroup) {
170
+ resourceGroup = undefined;
171
+ } else {
172
+ resourceGroup = resourceGroupContext;
173
+ }
174
+ } else {
175
+ resourceGroup = _xconsoleContext.ConsoleResourceGroup;
176
+ }
177
+ customProps.consoleBase = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customProps.consoleBase), _consoleBaseMessenger.forApp), region), resourceGroup);
178
+ } else {
179
+ customProps.consoleBase = _objectSpread(_objectSpread(_objectSpread({}, _xconsoleContext.ConsoleRegion), _xconsoleContext.ConsoleResourceGroup), customProps.consoleBase);
162
180
  }
163
181
  var sandbox = (0, _react.useMemo)(function () {
164
182
  var _UA_Opt, _RISK_INFO, _um;
package/lib/version.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '1.5.13-alpha.1';
7
+ var version = '1.5.13-alpha.3';
8
8
  exports.version = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-react",
3
- "version": "1.5.13-alpha.1",
3
+ "version": "1.5.13-alpha.3",
4
4
  "description": "Alfa Framework (React Version)",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,23 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { AlfaFactoryOption, CommonProps } from './types';
3
- interface IProps extends CommonProps {
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, CommonProps } from './types';
3
- interface IProps extends CommonProps {
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,26 +1,63 @@
1
1
  /// <reference types="react" />
2
2
  import { BaseLoader } from '@alicloud/alfa-core';
3
3
  import { AlfaFactoryOption } from './types';
4
- interface IProps<C = any> extends AlfaFactoryOption {
5
- customProps: C & {
6
- consoleBase?: any;
7
- path?: string;
8
- appConfig?: any;
9
- __injectHistory?: any;
10
- __innerStamp?: string;
11
- __historyState?: string;
12
- handleExternalLink?: (href: string) => void;
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
+ */
35
+ syncHistory?: boolean;
36
+ /**
37
+ * 是否开启 region 自动同步
38
+ */
14
39
  syncRegion?: boolean;
40
+ /**
41
+ * 是否开启资源组自动同步
42
+ */
15
43
  syncResourceGroup?: boolean;
16
- syncHistory?: boolean;
17
- onSyncHistory?: (type: 'replace' | 'push', path: string, data: any) => void;
44
+ /**
45
+ * 同步子应用路由的回调函数
46
+ */
47
+ onSyncHistory?: (type: 'replace' | 'push', pathname: string, state: any) => void;
48
+ /**
49
+ * 分配给子应用的路由前缀
50
+ */
18
51
  basename?: string;
52
+ /**
53
+ * @deprecated
54
+ * 注入给子应用的 history 实例,不推荐使用
55
+ */
56
+ history?: any;
19
57
  }
20
58
  /**
21
59
  * container for microApp mount
22
60
  * @param loader alfa-core loader
23
61
  * @returns
24
62
  */
25
- export default function createApplication(loader: BaseLoader): <C = any>(props: IProps<C>) => JSX.Element;
26
- export {};
63
+ export default function createApplication(loader: BaseLoader): <C = any>(props: IApplicationProps<C>) => JSX.Element;
@@ -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 {
@@ -1 +1 @@
1
- export declare const version = "1.5.13-alpha.1";
1
+ export declare const version = "1.5.13-alpha.3";