@alicloud/alfa-react 1.5.1-alpha.1 → 1.5.1-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.
- package/LICENSE +21 -0
- package/es/components/ErrorBoundary/ErrorPanel.js +1 -1
- package/es/createApplication.js +20 -16
- package/es/version.js +1 -1
- package/lib/components/ErrorBoundary/ErrorPanel.js +1 -1
- package/lib/createApplication.js +20 -16
- package/lib/version.js +1 -1
- package/package.json +18 -18
- package/types/version.d.ts +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Alibaba Cloud
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -2,11 +2,11 @@ import React from 'react';
|
|
|
2
2
|
var padding = 24;
|
|
3
3
|
var containerBackground = '#fcebea';
|
|
4
4
|
var containerStyle = {
|
|
5
|
+
display: 'none',
|
|
5
6
|
background: containerBackground,
|
|
6
7
|
padding: padding
|
|
7
8
|
};
|
|
8
9
|
var commonErrorStyle = {
|
|
9
|
-
display: 'none',
|
|
10
10
|
lineHeight: '22px',
|
|
11
11
|
color: '#d93026',
|
|
12
12
|
fontSize: 14
|
package/es/createApplication.js
CHANGED
|
@@ -171,7 +171,7 @@ export default function createApplication(loader) {
|
|
|
171
171
|
var dispatchFramePopstate = function dispatchFramePopstate() {
|
|
172
172
|
var _App, _App$context$baseFram, _App$context$baseFram2;
|
|
173
173
|
var popstateEvent = new Event('popstate');
|
|
174
|
-
popstateEvent.state =
|
|
174
|
+
popstateEvent.state = history.state;
|
|
175
175
|
(_App = App) === null || _App === void 0 ? void 0 : (_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);
|
|
176
176
|
};
|
|
177
177
|
var updateAppHistory = function updateAppHistory() {
|
|
@@ -192,19 +192,21 @@ export default function createApplication(loader) {
|
|
|
192
192
|
};
|
|
193
193
|
|
|
194
194
|
// 受控模式下,返回不会触发子应用内的路由更新,需要主动通知
|
|
195
|
+
// 这段逻辑不一定生效,因为我们已经劫持了沙箱内的 history.go 方法
|
|
195
196
|
if ($syncHistory.current) window.addEventListener('popstate', updateAppHistory);
|
|
196
197
|
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
197
198
|
var _app$context$updateBo, _app$context, _app$context$baseFram;
|
|
198
|
-
var _yield$loader$registe, app, logger, realVersion, _ref2, path, frameWindow;
|
|
199
|
+
var fakeBody, _yield$loader$registe, app, logger, realVersion, _ref2, path, frameWindow;
|
|
199
200
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
200
201
|
while (1) switch (_context.prev = _context.next) {
|
|
201
202
|
case 0:
|
|
202
203
|
countRegister(memoOptions.name);
|
|
203
|
-
|
|
204
|
+
fakeBody = memoOptions.container || appRef.current || document.body;
|
|
205
|
+
_context.next = 4;
|
|
204
206
|
return loader.register(_objectSpread(_objectSpread({}, memoOptions), {}, {
|
|
205
|
-
container:
|
|
207
|
+
container: fakeBody
|
|
206
208
|
}));
|
|
207
|
-
case
|
|
209
|
+
case 4:
|
|
208
210
|
_yield$loader$registe = _context.sent;
|
|
209
211
|
app = _yield$loader$registe.app;
|
|
210
212
|
logger = _yield$loader$registe.logger;
|
|
@@ -214,31 +216,31 @@ export default function createApplication(loader) {
|
|
|
214
216
|
|
|
215
217
|
// container has been unmounted
|
|
216
218
|
if (!isUnmounted) {
|
|
217
|
-
_context.next =
|
|
219
|
+
_context.next = 12;
|
|
218
220
|
break;
|
|
219
221
|
}
|
|
220
222
|
return _context.abrupt("return");
|
|
221
|
-
case
|
|
223
|
+
case 12:
|
|
222
224
|
if (app) {
|
|
223
|
-
_context.next =
|
|
225
|
+
_context.next = 14;
|
|
224
226
|
break;
|
|
225
227
|
}
|
|
226
228
|
return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
227
229
|
E_CODE: 'RuntimeError',
|
|
228
230
|
E_MSG: 'load app failed.'
|
|
229
231
|
}));
|
|
230
|
-
case
|
|
232
|
+
case 14:
|
|
231
233
|
if (appRef.current) {
|
|
232
|
-
_context.next =
|
|
234
|
+
_context.next = 16;
|
|
233
235
|
break;
|
|
234
236
|
}
|
|
235
237
|
return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
236
238
|
E_CODE: 'RuntimeError',
|
|
237
239
|
E_MSG: 'cannot find container.'
|
|
238
240
|
}));
|
|
239
|
-
case
|
|
241
|
+
case 16:
|
|
240
242
|
// update body in sandbox context
|
|
241
|
-
(_app$context$updateBo = (_app$context = app.context).updateBody) === null || _app$context$updateBo === void 0 ? void 0 : _app$context$updateBo.call(_app$context, memoOptions.sandbox.disableFakeBody ? document.body :
|
|
243
|
+
(_app$context$updateBo = (_app$context = app.context).updateBody) === null || _app$context$updateBo === void 0 ? void 0 : _app$context$updateBo.call(_app$context, memoOptions.sandbox.disableFakeBody ? document.body : fakeBody);
|
|
242
244
|
_ref2 = memoOptions.props, path = _ref2.path;
|
|
243
245
|
frameWindow = (_app$context$baseFram = app.context.baseFrame) === null || _app$context$baseFram === void 0 ? void 0 : _app$context$baseFram.contentWindow;
|
|
244
246
|
if (frameWindow) {
|
|
@@ -270,14 +272,16 @@ export default function createApplication(loader) {
|
|
|
270
272
|
// 劫持微应用的返回
|
|
271
273
|
frameWindow.history.go = function (n) {
|
|
272
274
|
window.history.go(n);
|
|
275
|
+
// 同步更新子应用的 state
|
|
276
|
+
originalReplaceState(history.state, '', peelPath(frameWindow.location));
|
|
273
277
|
};
|
|
274
278
|
}
|
|
275
279
|
}
|
|
276
|
-
_context.next =
|
|
277
|
-
return app.mount(
|
|
280
|
+
_context.next = 22;
|
|
281
|
+
return app.mount(fakeBody, {
|
|
278
282
|
customProps: customProps
|
|
279
283
|
});
|
|
280
|
-
case
|
|
284
|
+
case 22:
|
|
281
285
|
if (frameWindow) {
|
|
282
286
|
// 每次挂载后主动触发子应用内的 popstate 事件,借此触发 react-router history 的检查逻辑
|
|
283
287
|
dispatchFramePopstate();
|
|
@@ -285,7 +289,7 @@ export default function createApplication(loader) {
|
|
|
285
289
|
|
|
286
290
|
// just run once
|
|
287
291
|
setAppInstance(app);
|
|
288
|
-
case
|
|
292
|
+
case 24:
|
|
289
293
|
case "end":
|
|
290
294
|
return _context.stop();
|
|
291
295
|
}
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '1.5.
|
|
1
|
+
export var version = '1.5.1-alpha.3';
|
|
@@ -9,11 +9,11 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var padding = 24;
|
|
10
10
|
var containerBackground = '#fcebea';
|
|
11
11
|
var containerStyle = {
|
|
12
|
+
display: 'none',
|
|
12
13
|
background: containerBackground,
|
|
13
14
|
padding: padding
|
|
14
15
|
};
|
|
15
16
|
var commonErrorStyle = {
|
|
16
|
-
display: 'none',
|
|
17
17
|
lineHeight: '22px',
|
|
18
18
|
color: '#d93026',
|
|
19
19
|
fontSize: 14
|
package/lib/createApplication.js
CHANGED
|
@@ -181,7 +181,7 @@ function createApplication(loader) {
|
|
|
181
181
|
var dispatchFramePopstate = function dispatchFramePopstate() {
|
|
182
182
|
var _App, _App$context$baseFram, _App$context$baseFram2;
|
|
183
183
|
var popstateEvent = new Event('popstate');
|
|
184
|
-
popstateEvent.state =
|
|
184
|
+
popstateEvent.state = history.state;
|
|
185
185
|
(_App = App) === null || _App === void 0 ? void 0 : (_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);
|
|
186
186
|
};
|
|
187
187
|
var updateAppHistory = function updateAppHistory() {
|
|
@@ -202,19 +202,21 @@ function createApplication(loader) {
|
|
|
202
202
|
};
|
|
203
203
|
|
|
204
204
|
// 受控模式下,返回不会触发子应用内的路由更新,需要主动通知
|
|
205
|
+
// 这段逻辑不一定生效,因为我们已经劫持了沙箱内的 history.go 方法
|
|
205
206
|
if ($syncHistory.current) window.addEventListener('popstate', updateAppHistory);
|
|
206
207
|
(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
207
208
|
var _app$context$updateBo, _app$context, _app$context$baseFram;
|
|
208
|
-
var _yield$loader$registe, app, logger, realVersion, _ref2, path, frameWindow;
|
|
209
|
+
var fakeBody, _yield$loader$registe, app, logger, realVersion, _ref2, path, frameWindow;
|
|
209
210
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
210
211
|
while (1) switch (_context.prev = _context.next) {
|
|
211
212
|
case 0:
|
|
212
213
|
(0, _counter.countRegister)(memoOptions.name);
|
|
213
|
-
|
|
214
|
+
fakeBody = memoOptions.container || appRef.current || document.body;
|
|
215
|
+
_context.next = 4;
|
|
214
216
|
return loader.register(_objectSpread(_objectSpread({}, memoOptions), {}, {
|
|
215
|
-
container:
|
|
217
|
+
container: fakeBody
|
|
216
218
|
}));
|
|
217
|
-
case
|
|
219
|
+
case 4:
|
|
218
220
|
_yield$loader$registe = _context.sent;
|
|
219
221
|
app = _yield$loader$registe.app;
|
|
220
222
|
logger = _yield$loader$registe.logger;
|
|
@@ -224,31 +226,31 @@ function createApplication(loader) {
|
|
|
224
226
|
|
|
225
227
|
// container has been unmounted
|
|
226
228
|
if (!isUnmounted) {
|
|
227
|
-
_context.next =
|
|
229
|
+
_context.next = 12;
|
|
228
230
|
break;
|
|
229
231
|
}
|
|
230
232
|
return _context.abrupt("return");
|
|
231
|
-
case
|
|
233
|
+
case 12:
|
|
232
234
|
if (app) {
|
|
233
|
-
_context.next =
|
|
235
|
+
_context.next = 14;
|
|
234
236
|
break;
|
|
235
237
|
}
|
|
236
238
|
return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
237
239
|
E_CODE: 'RuntimeError',
|
|
238
240
|
E_MSG: 'load app failed.'
|
|
239
241
|
}));
|
|
240
|
-
case
|
|
242
|
+
case 14:
|
|
241
243
|
if (appRef.current) {
|
|
242
|
-
_context.next =
|
|
244
|
+
_context.next = 16;
|
|
243
245
|
break;
|
|
244
246
|
}
|
|
245
247
|
return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
|
|
246
248
|
E_CODE: 'RuntimeError',
|
|
247
249
|
E_MSG: 'cannot find container.'
|
|
248
250
|
}));
|
|
249
|
-
case
|
|
251
|
+
case 16:
|
|
250
252
|
// update body in sandbox context
|
|
251
|
-
(_app$context$updateBo = (_app$context = app.context).updateBody) === null || _app$context$updateBo === void 0 ? void 0 : _app$context$updateBo.call(_app$context, memoOptions.sandbox.disableFakeBody ? document.body :
|
|
253
|
+
(_app$context$updateBo = (_app$context = app.context).updateBody) === null || _app$context$updateBo === void 0 ? void 0 : _app$context$updateBo.call(_app$context, memoOptions.sandbox.disableFakeBody ? document.body : fakeBody);
|
|
252
254
|
_ref2 = memoOptions.props, path = _ref2.path;
|
|
253
255
|
frameWindow = (_app$context$baseFram = app.context.baseFrame) === null || _app$context$baseFram === void 0 ? void 0 : _app$context$baseFram.contentWindow;
|
|
254
256
|
if (frameWindow) {
|
|
@@ -280,14 +282,16 @@ function createApplication(loader) {
|
|
|
280
282
|
// 劫持微应用的返回
|
|
281
283
|
frameWindow.history.go = function (n) {
|
|
282
284
|
window.history.go(n);
|
|
285
|
+
// 同步更新子应用的 state
|
|
286
|
+
originalReplaceState(history.state, '', peelPath(frameWindow.location));
|
|
283
287
|
};
|
|
284
288
|
}
|
|
285
289
|
}
|
|
286
|
-
_context.next =
|
|
287
|
-
return app.mount(
|
|
290
|
+
_context.next = 22;
|
|
291
|
+
return app.mount(fakeBody, {
|
|
288
292
|
customProps: customProps
|
|
289
293
|
});
|
|
290
|
-
case
|
|
294
|
+
case 22:
|
|
291
295
|
if (frameWindow) {
|
|
292
296
|
// 每次挂载后主动触发子应用内的 popstate 事件,借此触发 react-router history 的检查逻辑
|
|
293
297
|
dispatchFramePopstate();
|
|
@@ -295,7 +299,7 @@ function createApplication(loader) {
|
|
|
295
299
|
|
|
296
300
|
// just run once
|
|
297
301
|
setAppInstance(app);
|
|
298
|
-
case
|
|
302
|
+
case 24:
|
|
299
303
|
case "end":
|
|
300
304
|
return _context.stop();
|
|
301
305
|
}
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-react",
|
|
3
|
-
"version": "1.5.1-alpha.
|
|
3
|
+
"version": "1.5.1-alpha.3",
|
|
4
4
|
"description": "Alfa Framework (React Version)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
8
8
|
"author": "pushiming",
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"prepublish": "npm run version && npm run build && npm run babel && npm run babel:esm && npm run types",
|
|
12
|
-
"build": "breezr build --engine webpack",
|
|
13
|
-
"babel": "breezr build --engine babel",
|
|
14
|
-
"babel:esm": "breezr build --engine babel --es-module",
|
|
15
|
-
"types": "tsc --emitDeclarationOnly -d --declarationDir ./types",
|
|
16
|
-
"storybook": "breezr start-storybook",
|
|
17
|
-
"clean": "rm -rf lib es dist types yarn.lock",
|
|
18
|
-
"start": "breezr start-storybook",
|
|
19
|
-
"precommit": "npm run version",
|
|
20
|
-
"version": "node -p \"'export const version = \\'' + require('./package.json').version + '\\';'\" > src/version.ts && git add src/version.ts"
|
|
21
|
-
},
|
|
22
10
|
"publishConfig": {
|
|
23
11
|
"access": "public"
|
|
24
12
|
},
|
|
@@ -43,16 +31,28 @@
|
|
|
43
31
|
"typescript": "^4.0.0"
|
|
44
32
|
},
|
|
45
33
|
"dependencies": {
|
|
46
|
-
"@alicloud/alfa-core": "workspace:*",
|
|
47
|
-
"@alicloud/console-os-loader": "workspace:*",
|
|
48
34
|
"@alicloud/widget-utils-console": "^0.1.6",
|
|
49
35
|
"axios": "^1.4.0",
|
|
50
36
|
"classnames": "^2.2.6",
|
|
51
37
|
"crypto-js": "^4.1.1",
|
|
52
|
-
"prop-types": "^15.8.1"
|
|
38
|
+
"prop-types": "^15.8.1",
|
|
39
|
+
"@alicloud/alfa-core": "1.4.32",
|
|
40
|
+
"@alicloud/console-os-loader": "1.4.30-alpha.0"
|
|
53
41
|
},
|
|
54
42
|
"peerDependencies": {
|
|
55
43
|
"react": ">=16.0.0"
|
|
56
44
|
},
|
|
57
|
-
"gitHead": "ff9294b1d5e08b14691c8aa2bef098da2857f3df"
|
|
58
|
-
|
|
45
|
+
"gitHead": "ff9294b1d5e08b14691c8aa2bef098da2857f3df",
|
|
46
|
+
"scripts": {
|
|
47
|
+
"prepublish": "npm run version && npm run build && npm run babel && npm run babel:esm && npm run types",
|
|
48
|
+
"build": "breezr build --engine webpack",
|
|
49
|
+
"babel": "breezr build --engine babel",
|
|
50
|
+
"babel:esm": "breezr build --engine babel --es-module",
|
|
51
|
+
"types": "tsc --emitDeclarationOnly -d --declarationDir ./types",
|
|
52
|
+
"storybook": "breezr start-storybook",
|
|
53
|
+
"clean": "rm -rf lib es dist types yarn.lock",
|
|
54
|
+
"start": "breezr start-storybook",
|
|
55
|
+
"precommit": "npm run version",
|
|
56
|
+
"version": "node -p \"'export const version = \\'' + require('./package.json').version + '\\';'\" > src/version.ts && git add src/version.ts"
|
|
57
|
+
}
|
|
58
|
+
}
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.5.
|
|
1
|
+
export declare const version = "1.5.1-alpha.3";
|