@alicloud/alfa-react 1.4.28 → 1.4.30-alpha.0
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/LICENSE +21 -0
- package/dist/index.js +2 -2
- package/es/createApplication.js +10 -4
- package/es/hooks/beforeLoadHook.js +14 -2
- package/es/utils/index.js +16 -0
- package/es/version.js +1 -1
- package/lib/createApplication.js +9 -3
- package/lib/hooks/beforeLoadHook.js +14 -2
- package/lib/utils/index.js +21 -2
- package/lib/version.js +1 -1
- package/package.json +4 -4
- package/types/types/index.d.ts +7 -0
- package/types/utils/index.d.ts +4 -0
- package/types/version.d.ts +1 -1
package/es/createApplication.js
CHANGED
|
@@ -10,7 +10,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
10
10
|
|
|
11
11
|
import React, { useRef, useEffect, useState, useMemo } from 'react';
|
|
12
12
|
import Loading from './components/Loading';
|
|
13
|
-
import { normalizeName } from './utils';
|
|
13
|
+
import { normalizeName, isOsContext } from './utils';
|
|
14
14
|
import { version as loaderVersion } from './version';
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -40,7 +40,8 @@ export default function createApplication(loader) {
|
|
|
40
40
|
beforeUpdate = props.beforeUpdate,
|
|
41
41
|
customSandbox = props.sandbox,
|
|
42
42
|
locale = props.locale,
|
|
43
|
-
dynamicConfig = props.dynamicConfig
|
|
43
|
+
dynamicConfig = props.dynamicConfig,
|
|
44
|
+
noCache = props.noCache;
|
|
44
45
|
|
|
45
46
|
var _useState = useState(null),
|
|
46
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -98,8 +99,9 @@ export default function createApplication(loader) {
|
|
|
98
99
|
afterUnmount: afterUnmount,
|
|
99
100
|
beforeUpdate: beforeUpdate,
|
|
100
101
|
locale: locale,
|
|
102
|
+
noCache: noCache,
|
|
101
103
|
// 用户自定义 manifest 且未传入 dynamicConfig 时,默认值为 false,否则为 true
|
|
102
|
-
dynamicConfig: dynamicConfig
|
|
104
|
+
dynamicConfig: typeof dynamicConfig === 'boolean' ? dynamicConfig : !manifest
|
|
103
105
|
};
|
|
104
106
|
}, []);
|
|
105
107
|
useEffect(function () {
|
|
@@ -179,8 +181,12 @@ export default function createApplication(loader) {
|
|
|
179
181
|
});
|
|
180
182
|
|
|
181
183
|
return function () {
|
|
184
|
+
var _App;
|
|
185
|
+
|
|
182
186
|
isUnmounted = true;
|
|
183
|
-
App && App.unmount();
|
|
187
|
+
App && App.unmount(); // 在沙箱中嵌套时,必须销毁实例,避免第二次加载时异常
|
|
188
|
+
|
|
189
|
+
if (isOsContext()) (_App = App) === null || _App === void 0 ? void 0 : _App.destroy();
|
|
184
190
|
};
|
|
185
191
|
}, [memoOptions]);
|
|
186
192
|
|
|
@@ -18,7 +18,7 @@ function afterLoadHook(_x) {
|
|
|
18
18
|
|
|
19
19
|
function _afterLoadHook() {
|
|
20
20
|
_afterLoadHook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
|
|
21
|
-
var app, logger, sandbox, dynamicConfig, defaultConsoleConfig, defaultConsoleGlobal, CONFIG_START_TIME, CONFIG_END_TIME, configData, _yield$Promise$all, _yield$Promise$all2, consoleConfig, consoleGlobal, messages, i18nMessages, END_TIME;
|
|
21
|
+
var app, logger, sandbox, dynamicConfig, defaultConsoleConfig, defaultConsoleGlobal, CONFIG_START_TIME, CONFIG_END_TIME, configData, _yield$Promise$all, _yield$Promise$all2, consoleConfig, consoleGlobal, messages, i18nMessages, overrides, END_TIME;
|
|
22
22
|
|
|
23
23
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
24
24
|
while (1) {
|
|
@@ -71,6 +71,18 @@ function _afterLoadHook() {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
case 22:
|
|
74
|
+
overrides = sandbox === null || sandbox === void 0 ? void 0 : sandbox.overrideGlobalVars;
|
|
75
|
+
|
|
76
|
+
if (overrides && app) {
|
|
77
|
+
Object.entries(overrides).forEach(function (_ref) {
|
|
78
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
79
|
+
key = _ref2[0],
|
|
80
|
+
value = _ref2[1];
|
|
81
|
+
|
|
82
|
+
app.context.window[key] = value;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
END_TIME = Date.now();
|
|
75
87
|
(logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
|
|
76
88
|
CONFIG_START_TIME: CONFIG_START_TIME,
|
|
@@ -81,7 +93,7 @@ function _afterLoadHook() {
|
|
|
81
93
|
(logger === null || logger === void 0 ? void 0 : logger.send) && logger.send();
|
|
82
94
|
return _context.abrupt("return", appConfig);
|
|
83
95
|
|
|
84
|
-
case
|
|
96
|
+
case 28:
|
|
85
97
|
case "end":
|
|
86
98
|
return _context.stop();
|
|
87
99
|
}
|
package/es/utils/index.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kernel 会为沙箱 context 注入 __IS_CONSOLE_OS_CONTEXT__
|
|
3
|
+
*/
|
|
1
4
|
export var normalizeName = function normalizeName(name) {
|
|
2
5
|
return name.replace(/@/g, '').replace(/\//g, '-');
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 判断是否在沙箱环境中运行
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export var isOsContext = function isOsContext() {
|
|
12
|
+
try {
|
|
13
|
+
return context.__IS_CONSOLE_OS_CONTEXT__;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
// 历史逻辑问题,window.__IS_CONSOLE_OS_CONTEXT__ 会被污染导致判断异常
|
|
16
|
+
// 降级
|
|
17
|
+
return !!window.__IS_CONSOLE_OS_CONTEXT__;
|
|
18
|
+
}
|
|
3
19
|
};
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '1.4.
|
|
1
|
+
export var version = '1.4.30-alpha.0';
|
package/lib/createApplication.js
CHANGED
|
@@ -62,7 +62,8 @@ function createApplication(loader) {
|
|
|
62
62
|
beforeUpdate = props.beforeUpdate,
|
|
63
63
|
customSandbox = props.sandbox,
|
|
64
64
|
locale = props.locale,
|
|
65
|
-
dynamicConfig = props.dynamicConfig
|
|
65
|
+
dynamicConfig = props.dynamicConfig,
|
|
66
|
+
noCache = props.noCache;
|
|
66
67
|
|
|
67
68
|
var _useState = (0, _react.useState)(null),
|
|
68
69
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -120,8 +121,9 @@ function createApplication(loader) {
|
|
|
120
121
|
afterUnmount: afterUnmount,
|
|
121
122
|
beforeUpdate: beforeUpdate,
|
|
122
123
|
locale: locale,
|
|
124
|
+
noCache: noCache,
|
|
123
125
|
// 用户自定义 manifest 且未传入 dynamicConfig 时,默认值为 false,否则为 true
|
|
124
|
-
dynamicConfig: dynamicConfig
|
|
126
|
+
dynamicConfig: typeof dynamicConfig === 'boolean' ? dynamicConfig : !manifest
|
|
125
127
|
};
|
|
126
128
|
}, []);
|
|
127
129
|
(0, _react.useEffect)(function () {
|
|
@@ -199,8 +201,12 @@ function createApplication(loader) {
|
|
|
199
201
|
});
|
|
200
202
|
});
|
|
201
203
|
return function () {
|
|
204
|
+
var _App;
|
|
205
|
+
|
|
202
206
|
isUnmounted = true;
|
|
203
|
-
App && App.unmount();
|
|
207
|
+
App && App.unmount(); // 在沙箱中嵌套时,必须销毁实例,避免第二次加载时异常
|
|
208
|
+
|
|
209
|
+
if ((0, _utils.isOsContext)()) (_App = App) === null || _App === void 0 ? void 0 : _App.destroy();
|
|
204
210
|
};
|
|
205
211
|
}, [memoOptions]);
|
|
206
212
|
|
|
@@ -32,7 +32,7 @@ function afterLoadHook(_x) {
|
|
|
32
32
|
|
|
33
33
|
function _afterLoadHook() {
|
|
34
34
|
_afterLoadHook = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(appConfig) {
|
|
35
|
-
var app, logger, sandbox, dynamicConfig, defaultConsoleConfig, defaultConsoleGlobal, CONFIG_START_TIME, CONFIG_END_TIME, configData, _yield$Promise$all, _yield$Promise$all2, consoleConfig, consoleGlobal, messages, i18nMessages, END_TIME;
|
|
35
|
+
var app, logger, sandbox, dynamicConfig, defaultConsoleConfig, defaultConsoleGlobal, CONFIG_START_TIME, CONFIG_END_TIME, configData, _yield$Promise$all, _yield$Promise$all2, consoleConfig, consoleGlobal, messages, i18nMessages, overrides, END_TIME;
|
|
36
36
|
|
|
37
37
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
38
38
|
while (1) {
|
|
@@ -85,6 +85,18 @@ function _afterLoadHook() {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
case 22:
|
|
88
|
+
overrides = sandbox === null || sandbox === void 0 ? void 0 : sandbox.overrideGlobalVars;
|
|
89
|
+
|
|
90
|
+
if (overrides && app) {
|
|
91
|
+
Object.entries(overrides).forEach(function (_ref) {
|
|
92
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
93
|
+
key = _ref2[0],
|
|
94
|
+
value = _ref2[1];
|
|
95
|
+
|
|
96
|
+
app.context.window[key] = value;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
88
100
|
END_TIME = Date.now();
|
|
89
101
|
(logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
|
|
90
102
|
CONFIG_START_TIME: CONFIG_START_TIME,
|
|
@@ -95,7 +107,7 @@ function _afterLoadHook() {
|
|
|
95
107
|
(logger === null || logger === void 0 ? void 0 : logger.send) && logger.send();
|
|
96
108
|
return _context.abrupt("return", appConfig);
|
|
97
109
|
|
|
98
|
-
case
|
|
110
|
+
case 28:
|
|
99
111
|
case "end":
|
|
100
112
|
return _context.stop();
|
|
101
113
|
}
|
package/lib/utils/index.js
CHANGED
|
@@ -3,10 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.normalizeName = void 0;
|
|
6
|
+
exports.normalizeName = exports.isOsContext = void 0;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* kernel 会为沙箱 context 注入 __IS_CONSOLE_OS_CONTEXT__
|
|
10
|
+
*/
|
|
8
11
|
var normalizeName = function normalizeName(name) {
|
|
9
12
|
return name.replace(/@/g, '').replace(/\//g, '-');
|
|
10
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* 判断是否在沙箱环境中运行
|
|
16
|
+
*/
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
|
|
19
|
+
exports.normalizeName = normalizeName;
|
|
20
|
+
|
|
21
|
+
var isOsContext = function isOsContext() {
|
|
22
|
+
try {
|
|
23
|
+
return context.__IS_CONSOLE_OS_CONTEXT__;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
// 历史逻辑问题,window.__IS_CONSOLE_OS_CONTEXT__ 会被污染导致判断异常
|
|
26
|
+
// 降级
|
|
27
|
+
return !!window.__IS_CONSOLE_OS_CONTEXT__;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.isOsContext = isOsContext;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-react",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.30-alpha.0",
|
|
4
4
|
"description": "Alfa Framework (React Version)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"typescript": "^3.0.3"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@alicloud/alfa-core": "
|
|
46
|
-
"@alicloud/console-os-loader": "
|
|
45
|
+
"@alicloud/alfa-core": "1.4.30-alpha.0",
|
|
46
|
+
"@alicloud/console-os-loader": "1.4.30-alpha.0",
|
|
47
47
|
"@alicloud/widget-utils-console": "^0.1.6",
|
|
48
48
|
"classnames": "^2.2.6",
|
|
49
49
|
"crypto-js": "^4.1.1"
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": ">=16.0.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "971f337e52ca2ea36090f1e6f0fc6c57bb715a06"
|
|
55
55
|
}
|
package/types/types/index.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ export interface AlfaFactoryOption extends IAppConfig {
|
|
|
19
19
|
css?: Record<string, string>;
|
|
20
20
|
js?: Record<string, string>;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* 关闭缓存模式
|
|
24
|
+
*/
|
|
25
|
+
noCache?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 开启业务配置加载
|
|
28
|
+
*/
|
|
22
29
|
dynamicConfig?: boolean;
|
|
23
30
|
runtimeVersion?: string;
|
|
24
31
|
fallbackRender?: (error: Error) => Element;
|
package/types/utils/index.d.ts
CHANGED
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.4.
|
|
1
|
+
export declare const version = "1.4.30-alpha.0";
|