@alicloud/alfa-react 1.4.30-alpha.3 → 1.4.30-alpha.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.
@@ -5,7 +5,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
5
5
 
6
6
  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; }
7
7
 
8
- import React from 'react';
8
+ import React, { useMemo } from 'react';
9
9
  import { BaseLoader } from '@alicloud/alfa-core';
10
10
  import ErrorBoundary from './components/ErrorBoundary';
11
11
  import createApplication from './createApplication';
@@ -26,19 +26,23 @@ function createAlfaApp(option) {
26
26
  return null;
27
27
  };
28
28
  var passedInOption = option;
29
- return /*#__PURE__*/React.memo(function (props) {
30
- var customProps = _objectSpread(_objectSpread({}, props), {}, {
31
- __injectHistory: props.history
32
- });
33
-
34
- return /*#__PURE__*/React.createElement(ErrorBoundary, props, /*#__PURE__*/React.createElement(Application, _extends({}, passedInOption, {
29
+ return function (props) {
30
+ var customProps = useMemo(function () {
31
+ return _objectSpread(_objectSpread({}, props), {}, {
32
+ __injectHistory: props.history
33
+ });
34
+ }, [props]);
35
+ return /*#__PURE__*/React.createElement(ErrorBoundary, props, /*#__PURE__*/React.createElement(Application // 兼容历史逻辑,优先使用 option 中的 sandbox 参数
36
+ , _extends({}, passedInOption, {
35
37
  puppeteer: props.puppeteer,
36
38
  basename: props.basename,
37
39
  sandbox: option.sandbox || props.sandbox,
38
40
  deps: dependencies || {},
39
- customProps: customProps
41
+ customProps: customProps // 受控模式下,用于触发子应用随主应用路由变更更新
42
+ ,
43
+ path: props.puppeteer ? window.location.toString() : props.path
40
44
  })));
41
- });
45
+ };
42
46
  }
43
47
 
44
48
  export default createAlfaApp;
@@ -56,7 +56,7 @@ function createAlfaWidget(option) {
56
56
  return null;
57
57
  };
58
58
  var passedInOption = option;
59
- return /*#__PURE__*/React.memo(function (props) {
59
+ return function (props) {
60
60
  return (
61
61
  /*#__PURE__*/
62
62
  // Compatible with old logic
@@ -67,7 +67,7 @@ function createAlfaWidget(option) {
67
67
  customProps: props
68
68
  })))
69
69
  );
70
- });
70
+ };
71
71
  }
72
72
 
73
73
  export default createAlfaWidget;
@@ -13,13 +13,46 @@ import Loading from './components/Loading';
13
13
  import { normalizeName, isOsContext } from './utils';
14
14
  import { version as loaderVersion } from './version';
15
15
 
16
+ var resolvePath = function resolvePath() {
17
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
18
+ args[_key] = arguments[_key];
19
+ }
20
+
21
+ return "/".concat(args.join('/')).replace(/\/+/g, '/');
22
+ };
23
+ /**
24
+ * 去掉 location.origin 的路径
25
+ */
26
+
27
+
28
+ var peelPath = function peelPath(location) {
29
+ return location.pathname + location.search + location.hash;
30
+ };
31
+
32
+ var addBasename = function addBasename(path, basename) {
33
+ if (!basename) return path;
34
+ return resolvePath(basename, path);
35
+ };
36
+
37
+ var stripBasename = function stripBasename(path, basename) {
38
+ if (!basename) return path;
39
+
40
+ var _path = resolvePath(path);
41
+
42
+ var _basename = resolvePath(basename);
43
+
44
+ if (_path === _basename) return '/';
45
+ return _path.replace(new RegExp("^".concat(_basename), 'ig'), '');
46
+ };
16
47
  /**
17
48
  * container for microApp mount
18
49
  * @param loader alfa-core loader
19
50
  * @returns
20
51
  */
52
+
53
+
21
54
  export default function createApplication(loader) {
22
- return function Application(props) {
55
+ function Application(props) {
23
56
  var name = props.name,
24
57
  version = props.version,
25
58
  manifest = props.manifest,
@@ -59,8 +92,15 @@ export default function createApplication(loader) {
59
92
  var $basename = useRef(basename);
60
93
  var tagName = normalizeName(props.name);
61
94
  $puppeteer.current = puppeteer;
62
- $basename.current = basename;
63
- if ($puppeteer.current) customProps.consoleBase = null;
95
+ $basename.current = basename; // 受控模式锁定一些参数
96
+
97
+ if ($puppeteer.current) {
98
+ // 禁止子应用和 consoleBase 通信
99
+ customProps.consoleBase = null; // 覆写 path 参数,用于通知子应用更新路由
100
+
101
+ customProps.path = stripBasename(peelPath(window.location), $basename.current);
102
+ }
103
+
64
104
  var sandbox = useMemo(function () {
65
105
  var _UA_Opt, _RISK_INFO, _um;
66
106
 
@@ -116,7 +156,25 @@ export default function createApplication(loader) {
116
156
  var App;
117
157
  var originalPushState;
118
158
  var originalReplaceState;
119
- var originalGo;
159
+ var originalGo; // 受控模式下,返回不会触发子应用内的路由更新
160
+
161
+ var updateAppHistory = function updateAppHistory() {
162
+ if (App) {
163
+ // 如果子应用路径不同,则主动通知
164
+ var nextPath = peelPath(App.context.location);
165
+
166
+ if (nextPath !== stripBasename(peelPath(window.location), $basename.current)) {
167
+ var _App$context$baseFram, _App$context$baseFram2;
168
+
169
+ var popstateEvent = new Event('popstate');
170
+ popstateEvent.state = 'mock';
171
+ if (originalReplaceState) originalReplaceState(null, '', stripBasename(peelPath(window.location), $basename.current));
172
+ (_App$context$baseFram = App.context.baseFrame) === null || _App$context$baseFram === void 0 ? void 0 : (_App$context$baseFram2 = _App$context$baseFram.contentWindow) === null || _App$context$baseFram2 === void 0 ? void 0 : _App$context$baseFram2.dispatchEvent(popstateEvent);
173
+ }
174
+ }
175
+ };
176
+
177
+ window.addEventListener('popstate', updateAppHistory);
120
178
 
121
179
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
122
180
  var _app$context$updateBo, _app$context, _app$context$baseFram;
@@ -178,18 +236,33 @@ export default function createApplication(loader) {
178
236
  originalReplaceState = frameWindow === null || frameWindow === void 0 ? void 0 : frameWindow.history.replaceState;
179
237
  originalGo = frameWindow === null || frameWindow === void 0 ? void 0 : frameWindow.history.go; // update context history according to path
180
238
 
181
- if (path) originalReplaceState(null, '', path);
239
+ if (path) originalReplaceState(null, '', path.replace(/\/+/g, '/'));
182
240
 
183
- if ($puppeteer.current && frameWindow) {
241
+ if (frameWindow) {
184
242
  frameWindow.history.pushState = function (data, unused, _url) {
185
- window.history.pushState(data, unused, "".concat($basename.current || '', "/").concat(_url).replace(/\/\//g, '/'));
186
- originalReplaceState(data, unused, _url);
243
+ if ($puppeteer.current) {
244
+ var nextPath = addBasename((_url === null || _url === void 0 ? void 0 : _url.toString()) || '', $basename.current);
245
+
246
+ if ("".concat(nextPath) !== peelPath(window.location)) {
247
+ window.history.pushState(data, unused, nextPath);
248
+ }
249
+
250
+ originalReplaceState(data, unused, _url);
251
+ } else {
252
+ originalPushState(data, unused, _url);
253
+ }
187
254
  };
188
255
 
189
256
  frameWindow.history.replaceState = function (data, unused, _url) {
190
- window.history.replaceState(data, unused, "".concat($basename.current || '', "/").concat(_url).replace(/\/\//g, '/'));
257
+ var nextPath = addBasename((_url === null || _url === void 0 ? void 0 : _url.toString()) || '', $basename.current);
258
+
259
+ if ($puppeteer.current) {
260
+ window.history.replaceState(data, unused, nextPath);
261
+ }
262
+
191
263
  originalReplaceState(data, unused, _url);
192
- };
264
+ }; // 劫持微应用的返回
265
+
193
266
 
194
267
  frameWindow.history.go = function (n) {
195
268
  window.history.go(n);
@@ -219,19 +292,20 @@ export default function createApplication(loader) {
219
292
  });
220
293
 
221
294
  return function () {
222
- var _App$context$baseFram, _App$context$baseFram2;
295
+ var _App$context$baseFram3, _App$context$baseFram4;
223
296
 
224
297
  isUnmounted = true;
298
+ window.removeEventListener('popstate', updateAppHistory);
225
299
  if (!App) return;
226
- App.unmount();
227
- var frameHistory = (_App$context$baseFram = App.context.baseFrame) === null || _App$context$baseFram === void 0 ? void 0 : (_App$context$baseFram2 = _App$context$baseFram.contentWindow) === null || _App$context$baseFram2 === void 0 ? void 0 : _App$context$baseFram2.history;
300
+ var frameHistory = (_App$context$baseFram3 = App.context.baseFrame) === null || _App$context$baseFram3 === void 0 ? void 0 : (_App$context$baseFram4 = _App$context$baseFram3.contentWindow) === null || _App$context$baseFram4 === void 0 ? void 0 : _App$context$baseFram4.history;
228
301
 
229
302
  if (frameHistory) {
230
303
  if (originalPushState !== frameHistory.pushState) frameHistory.pushState = originalPushState;
231
304
  if (originalReplaceState !== frameHistory.replaceState) frameHistory.pushState = originalReplaceState;
232
305
  if (originalGo !== frameHistory.go) frameHistory.go = originalGo;
233
- } // 在沙箱中嵌套时,必须销毁实例,避免第二次加载时异常
306
+ }
234
307
 
308
+ App.unmount(); // 在沙箱中嵌套时,必须销毁实例,避免第二次加载时异常
235
309
 
236
310
  if (isOsContext()) App.destroy();
237
311
  };
@@ -257,5 +331,7 @@ export default function createApplication(loader) {
257
331
  style: style,
258
332
  className: className
259
333
  })));
260
- };
334
+ }
335
+
336
+ return /*#__PURE__*/React.memo(Application);
261
337
  }
package/es/version.js CHANGED
@@ -1 +1 @@
1
- export var version = '1.4.30-alpha.3';
1
+ export var version = '1.4.30-alpha.4';
@@ -2,6 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
@@ -11,7 +13,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
13
 
12
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
15
 
14
- var _react = _interopRequireDefault(require("react"));
16
+ var _react = _interopRequireWildcard(require("react"));
15
17
 
16
18
  var _alfaCore = require("@alicloud/alfa-core");
17
19
 
@@ -23,6 +25,10 @@ var _beforeResolveHook = _interopRequireDefault(require("./hooks/beforeResolveHo
23
25
 
24
26
  var _beforeLoadHook = _interopRequireDefault(require("./hooks/beforeLoadHook"));
25
27
 
28
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
+
30
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
+
26
32
  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; }
27
33
 
28
34
  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) { (0, _defineProperty2.default)(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; }
@@ -43,19 +49,23 @@ function createAlfaApp(option) {
43
49
  return null;
44
50
  };
45
51
  var passedInOption = option;
46
- return /*#__PURE__*/_react.default.memo(function (props) {
47
- var customProps = _objectSpread(_objectSpread({}, props), {}, {
48
- __injectHistory: props.history
49
- });
50
-
51
- return /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, props, /*#__PURE__*/_react.default.createElement(Application, (0, _extends2.default)({}, passedInOption, {
52
+ return function (props) {
53
+ var customProps = (0, _react.useMemo)(function () {
54
+ return _objectSpread(_objectSpread({}, props), {}, {
55
+ __injectHistory: props.history
56
+ });
57
+ }, [props]);
58
+ return /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, props, /*#__PURE__*/_react.default.createElement(Application // 兼容历史逻辑,优先使用 option 中的 sandbox 参数
59
+ , (0, _extends2.default)({}, passedInOption, {
52
60
  puppeteer: props.puppeteer,
53
61
  basename: props.basename,
54
62
  sandbox: option.sandbox || props.sandbox,
55
63
  deps: dependencies || {},
56
- customProps: customProps
64
+ customProps: customProps // 受控模式下,用于触发子应用随主应用路由变更更新
65
+ ,
66
+ path: props.puppeteer ? window.location.toString() : props.path
57
67
  })));
58
- });
68
+ };
59
69
  }
60
70
 
61
71
  var _default = createAlfaApp;
@@ -76,7 +76,7 @@ function createAlfaWidget(option) {
76
76
  return null;
77
77
  };
78
78
  var passedInOption = option;
79
- return /*#__PURE__*/_react.default.memo(function (props) {
79
+ return function (props) {
80
80
  return (
81
81
  /*#__PURE__*/
82
82
  // Compatible with old logic
@@ -87,7 +87,7 @@ function createAlfaWidget(option) {
87
87
  customProps: props
88
88
  })))
89
89
  );
90
- });
90
+ };
91
91
  }
92
92
 
93
93
  var _default = createAlfaWidget;
@@ -35,13 +35,46 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
35
35
 
36
36
  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) { (0, _defineProperty2.default)(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; }
37
37
 
38
+ var resolvePath = function resolvePath() {
39
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
+ args[_key] = arguments[_key];
41
+ }
42
+
43
+ return "/".concat(args.join('/')).replace(/\/+/g, '/');
44
+ };
45
+ /**
46
+ * 去掉 location.origin 的路径
47
+ */
48
+
49
+
50
+ var peelPath = function peelPath(location) {
51
+ return location.pathname + location.search + location.hash;
52
+ };
53
+
54
+ var addBasename = function addBasename(path, basename) {
55
+ if (!basename) return path;
56
+ return resolvePath(basename, path);
57
+ };
58
+
59
+ var stripBasename = function stripBasename(path, basename) {
60
+ if (!basename) return path;
61
+
62
+ var _path = resolvePath(path);
63
+
64
+ var _basename = resolvePath(basename);
65
+
66
+ if (_path === _basename) return '/';
67
+ return _path.replace(new RegExp("^".concat(_basename), 'ig'), '');
68
+ };
38
69
  /**
39
70
  * container for microApp mount
40
71
  * @param loader alfa-core loader
41
72
  * @returns
42
73
  */
74
+
75
+
43
76
  function createApplication(loader) {
44
- return function Application(props) {
77
+ function Application(props) {
45
78
  var name = props.name,
46
79
  version = props.version,
47
80
  manifest = props.manifest,
@@ -81,8 +114,15 @@ function createApplication(loader) {
81
114
  var $basename = (0, _react.useRef)(basename);
82
115
  var tagName = (0, _utils.normalizeName)(props.name);
83
116
  $puppeteer.current = puppeteer;
84
- $basename.current = basename;
85
- if ($puppeteer.current) customProps.consoleBase = null;
117
+ $basename.current = basename; // 受控模式锁定一些参数
118
+
119
+ if ($puppeteer.current) {
120
+ // 禁止子应用和 consoleBase 通信
121
+ customProps.consoleBase = null; // 覆写 path 参数,用于通知子应用更新路由
122
+
123
+ customProps.path = stripBasename(peelPath(window.location), $basename.current);
124
+ }
125
+
86
126
  var sandbox = (0, _react.useMemo)(function () {
87
127
  var _UA_Opt, _RISK_INFO, _um;
88
128
 
@@ -138,7 +178,25 @@ function createApplication(loader) {
138
178
  var App;
139
179
  var originalPushState;
140
180
  var originalReplaceState;
141
- var originalGo;
181
+ var originalGo; // 受控模式下,返回不会触发子应用内的路由更新
182
+
183
+ var updateAppHistory = function updateAppHistory() {
184
+ if (App) {
185
+ // 如果子应用路径不同,则主动通知
186
+ var nextPath = peelPath(App.context.location);
187
+
188
+ if (nextPath !== stripBasename(peelPath(window.location), $basename.current)) {
189
+ var _App$context$baseFram, _App$context$baseFram2;
190
+
191
+ var popstateEvent = new Event('popstate');
192
+ popstateEvent.state = 'mock';
193
+ if (originalReplaceState) originalReplaceState(null, '', stripBasename(peelPath(window.location), $basename.current));
194
+ (_App$context$baseFram = App.context.baseFrame) === null || _App$context$baseFram === void 0 ? void 0 : (_App$context$baseFram2 = _App$context$baseFram.contentWindow) === null || _App$context$baseFram2 === void 0 ? void 0 : _App$context$baseFram2.dispatchEvent(popstateEvent);
195
+ }
196
+ }
197
+ };
198
+
199
+ window.addEventListener('popstate', updateAppHistory);
142
200
  (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
143
201
  var _app$context$updateBo, _app$context, _app$context$baseFram;
144
202
 
@@ -199,18 +257,33 @@ function createApplication(loader) {
199
257
  originalReplaceState = frameWindow === null || frameWindow === void 0 ? void 0 : frameWindow.history.replaceState;
200
258
  originalGo = frameWindow === null || frameWindow === void 0 ? void 0 : frameWindow.history.go; // update context history according to path
201
259
 
202
- if (path) originalReplaceState(null, '', path);
260
+ if (path) originalReplaceState(null, '', path.replace(/\/+/g, '/'));
203
261
 
204
- if ($puppeteer.current && frameWindow) {
262
+ if (frameWindow) {
205
263
  frameWindow.history.pushState = function (data, unused, _url) {
206
- window.history.pushState(data, unused, "".concat($basename.current || '', "/").concat(_url).replace(/\/\//g, '/'));
207
- originalReplaceState(data, unused, _url);
264
+ if ($puppeteer.current) {
265
+ var nextPath = addBasename((_url === null || _url === void 0 ? void 0 : _url.toString()) || '', $basename.current);
266
+
267
+ if ("".concat(nextPath) !== peelPath(window.location)) {
268
+ window.history.pushState(data, unused, nextPath);
269
+ }
270
+
271
+ originalReplaceState(data, unused, _url);
272
+ } else {
273
+ originalPushState(data, unused, _url);
274
+ }
208
275
  };
209
276
 
210
277
  frameWindow.history.replaceState = function (data, unused, _url) {
211
- window.history.replaceState(data, unused, "".concat($basename.current || '', "/").concat(_url).replace(/\/\//g, '/'));
278
+ var nextPath = addBasename((_url === null || _url === void 0 ? void 0 : _url.toString()) || '', $basename.current);
279
+
280
+ if ($puppeteer.current) {
281
+ window.history.replaceState(data, unused, nextPath);
282
+ }
283
+
212
284
  originalReplaceState(data, unused, _url);
213
- };
285
+ }; // 劫持微应用的返回
286
+
214
287
 
215
288
  frameWindow.history.go = function (n) {
216
289
  window.history.go(n);
@@ -239,19 +312,20 @@ function createApplication(loader) {
239
312
  });
240
313
  });
241
314
  return function () {
242
- var _App$context$baseFram, _App$context$baseFram2;
315
+ var _App$context$baseFram3, _App$context$baseFram4;
243
316
 
244
317
  isUnmounted = true;
318
+ window.removeEventListener('popstate', updateAppHistory);
245
319
  if (!App) return;
246
- App.unmount();
247
- var frameHistory = (_App$context$baseFram = App.context.baseFrame) === null || _App$context$baseFram === void 0 ? void 0 : (_App$context$baseFram2 = _App$context$baseFram.contentWindow) === null || _App$context$baseFram2 === void 0 ? void 0 : _App$context$baseFram2.history;
320
+ var frameHistory = (_App$context$baseFram3 = App.context.baseFrame) === null || _App$context$baseFram3 === void 0 ? void 0 : (_App$context$baseFram4 = _App$context$baseFram3.contentWindow) === null || _App$context$baseFram4 === void 0 ? void 0 : _App$context$baseFram4.history;
248
321
 
249
322
  if (frameHistory) {
250
323
  if (originalPushState !== frameHistory.pushState) frameHistory.pushState = originalPushState;
251
324
  if (originalReplaceState !== frameHistory.replaceState) frameHistory.pushState = originalReplaceState;
252
325
  if (originalGo !== frameHistory.go) frameHistory.go = originalGo;
253
- } // 在沙箱中嵌套时,必须销毁实例,避免第二次加载时异常
326
+ }
254
327
 
328
+ App.unmount(); // 在沙箱中嵌套时,必须销毁实例,避免第二次加载时异常
255
329
 
256
330
  if ((0, _utils.isOsContext)()) App.destroy();
257
331
  };
@@ -277,5 +351,7 @@ function createApplication(loader) {
277
351
  style: style,
278
352
  className: className
279
353
  })));
280
- };
354
+ }
355
+
356
+ return /*#__PURE__*/_react.default.memo(Application);
281
357
  }
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.4.30-alpha.3';
7
+ var version = '1.4.30-alpha.4';
8
8
  exports.version = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-react",
3
- "version": "1.4.30-alpha.3",
3
+ "version": "1.4.30-alpha.4",
4
4
  "description": "Alfa Framework (React Version)",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,9 +1,14 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { AlfaFactoryOption } from './types';
3
- declare function createAlfaApp<P = any>(option: AlfaFactoryOption): (() => null) | React.MemoExoticComponent<(props: P & {
4
- history: any;
5
- sandbox: {};
3
+ interface IProps {
4
+ /**
5
+ * @deprecated
6
+ */
7
+ sandbox: Record<string, any>;
6
8
  puppeteer?: boolean;
7
9
  basename?: string;
8
- }) => JSX.Element>;
10
+ history?: any;
11
+ path?: string;
12
+ }
13
+ declare function createAlfaApp<P = any>(option: AlfaFactoryOption): (() => null) | ((props: P & IProps) => JSX.Element);
9
14
  export default createAlfaApp;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { AlfaFactoryOption } from './types';
3
- declare function createAlfaWidget<P = any>(option: AlfaFactoryOption): ((props: P) => JSX.Element) | (() => null) | React.MemoExoticComponent<(props: P) => JSX.Element>;
3
+ declare function createAlfaWidget<P = any>(option: AlfaFactoryOption): ((props: P) => JSX.Element) | (() => null);
4
4
  export default createAlfaWidget;
@@ -1,15 +1,16 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { BaseLoader } from '@alicloud/alfa-core';
3
3
  import { AlfaFactoryOption } from './types';
4
4
  interface IProps<C = any> extends AlfaFactoryOption {
5
5
  customProps: C;
6
6
  puppeteer?: boolean;
7
7
  basename?: string;
8
+ path?: string;
8
9
  }
9
10
  /**
10
11
  * container for microApp mount
11
12
  * @param loader alfa-core loader
12
13
  * @returns
13
14
  */
14
- export default function createApplication(loader: BaseLoader): <C = any>(props: IProps<C>) => JSX.Element;
15
+ export default function createApplication(loader: BaseLoader): React.MemoExoticComponent<(<C = any>(props: IProps<C>) => JSX.Element)>;
15
16
  export {};
@@ -1 +1 @@
1
- export declare const version = "1.4.30-alpha.3";
1
+ export declare const version = "1.4.30-alpha.4";