@alicloud/alfa-react 1.5.1-alpha.0 → 1.5.1-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/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.
@@ -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 = 'mock';
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() {
@@ -195,16 +195,17 @@ export default function createApplication(loader) {
195
195
  if ($syncHistory.current) window.addEventListener('popstate', updateAppHistory);
196
196
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
197
197
  var _app$context$updateBo, _app$context, _app$context$baseFram;
198
- var _yield$loader$registe, app, logger, realVersion, _ref2, path, frameWindow;
198
+ var fakeBody, _yield$loader$registe, app, logger, realVersion, _ref2, path, frameWindow;
199
199
  return _regeneratorRuntime.wrap(function _callee$(_context) {
200
200
  while (1) switch (_context.prev = _context.next) {
201
201
  case 0:
202
202
  countRegister(memoOptions.name);
203
- _context.next = 3;
203
+ fakeBody = memoOptions.container || appRef.current || document.body;
204
+ _context.next = 4;
204
205
  return loader.register(_objectSpread(_objectSpread({}, memoOptions), {}, {
205
- container: memoOptions.container || appRef.current
206
+ container: fakeBody
206
207
  }));
207
- case 3:
208
+ case 4:
208
209
  _yield$loader$registe = _context.sent;
209
210
  app = _yield$loader$registe.app;
210
211
  logger = _yield$loader$registe.logger;
@@ -214,31 +215,31 @@ export default function createApplication(loader) {
214
215
 
215
216
  // container has been unmounted
216
217
  if (!isUnmounted) {
217
- _context.next = 11;
218
+ _context.next = 12;
218
219
  break;
219
220
  }
220
221
  return _context.abrupt("return");
221
- case 11:
222
+ case 12:
222
223
  if (app) {
223
- _context.next = 13;
224
+ _context.next = 14;
224
225
  break;
225
226
  }
226
227
  return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
227
228
  E_CODE: 'RuntimeError',
228
229
  E_MSG: 'load app failed.'
229
230
  }));
230
- case 13:
231
+ case 14:
231
232
  if (appRef.current) {
232
- _context.next = 15;
233
+ _context.next = 16;
233
234
  break;
234
235
  }
235
236
  return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
236
237
  E_CODE: 'RuntimeError',
237
238
  E_MSG: 'cannot find container.'
238
239
  }));
239
- case 15:
240
+ case 16:
240
241
  // 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 : appRef.current);
242
+ (_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
243
  _ref2 = memoOptions.props, path = _ref2.path;
243
244
  frameWindow = (_app$context$baseFram = app.context.baseFrame) === null || _app$context$baseFram === void 0 ? void 0 : _app$context$baseFram.contentWindow;
244
245
  if (frameWindow) {
@@ -273,11 +274,11 @@ export default function createApplication(loader) {
273
274
  };
274
275
  }
275
276
  }
276
- _context.next = 21;
277
- return app.mount(appRef.current, {
277
+ _context.next = 22;
278
+ return app.mount(fakeBody, {
278
279
  customProps: customProps
279
280
  });
280
- case 21:
281
+ case 22:
281
282
  if (frameWindow) {
282
283
  // 每次挂载后主动触发子应用内的 popstate 事件,借此触发 react-router history 的检查逻辑
283
284
  dispatchFramePopstate();
@@ -285,7 +286,7 @@ export default function createApplication(loader) {
285
286
 
286
287
  // just run once
287
288
  setAppInstance(app);
288
- case 23:
289
+ case 24:
289
290
  case "end":
290
291
  return _context.stop();
291
292
  }
package/es/version.js CHANGED
@@ -1 +1 @@
1
- export var version = '1.5.0';
1
+ export var version = '1.5.1-alpha.2';
@@ -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 = 'mock';
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() {
@@ -205,16 +205,17 @@ function createApplication(loader) {
205
205
  if ($syncHistory.current) window.addEventListener('popstate', updateAppHistory);
206
206
  (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
207
207
  var _app$context$updateBo, _app$context, _app$context$baseFram;
208
- var _yield$loader$registe, app, logger, realVersion, _ref2, path, frameWindow;
208
+ var fakeBody, _yield$loader$registe, app, logger, realVersion, _ref2, path, frameWindow;
209
209
  return _regenerator.default.wrap(function _callee$(_context) {
210
210
  while (1) switch (_context.prev = _context.next) {
211
211
  case 0:
212
212
  (0, _counter.countRegister)(memoOptions.name);
213
- _context.next = 3;
213
+ fakeBody = memoOptions.container || appRef.current || document.body;
214
+ _context.next = 4;
214
215
  return loader.register(_objectSpread(_objectSpread({}, memoOptions), {}, {
215
- container: memoOptions.container || appRef.current
216
+ container: fakeBody
216
217
  }));
217
- case 3:
218
+ case 4:
218
219
  _yield$loader$registe = _context.sent;
219
220
  app = _yield$loader$registe.app;
220
221
  logger = _yield$loader$registe.logger;
@@ -224,31 +225,31 @@ function createApplication(loader) {
224
225
 
225
226
  // container has been unmounted
226
227
  if (!isUnmounted) {
227
- _context.next = 11;
228
+ _context.next = 12;
228
229
  break;
229
230
  }
230
231
  return _context.abrupt("return");
231
- case 11:
232
+ case 12:
232
233
  if (app) {
233
- _context.next = 13;
234
+ _context.next = 14;
234
235
  break;
235
236
  }
236
237
  return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
237
238
  E_CODE: 'RuntimeError',
238
239
  E_MSG: 'load app failed.'
239
240
  }));
240
- case 13:
241
+ case 14:
241
242
  if (appRef.current) {
242
- _context.next = 15;
243
+ _context.next = 16;
243
244
  break;
244
245
  }
245
246
  return _context.abrupt("return", (logger === null || logger === void 0 ? void 0 : logger.error) && logger.error({
246
247
  E_CODE: 'RuntimeError',
247
248
  E_MSG: 'cannot find container.'
248
249
  }));
249
- case 15:
250
+ case 16:
250
251
  // 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 : appRef.current);
252
+ (_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
253
  _ref2 = memoOptions.props, path = _ref2.path;
253
254
  frameWindow = (_app$context$baseFram = app.context.baseFrame) === null || _app$context$baseFram === void 0 ? void 0 : _app$context$baseFram.contentWindow;
254
255
  if (frameWindow) {
@@ -283,11 +284,11 @@ function createApplication(loader) {
283
284
  };
284
285
  }
285
286
  }
286
- _context.next = 21;
287
- return app.mount(appRef.current, {
287
+ _context.next = 22;
288
+ return app.mount(fakeBody, {
288
289
  customProps: customProps
289
290
  });
290
- case 21:
291
+ case 22:
291
292
  if (frameWindow) {
292
293
  // 每次挂载后主动触发子应用内的 popstate 事件,借此触发 react-router history 的检查逻辑
293
294
  dispatchFramePopstate();
@@ -295,7 +296,7 @@ function createApplication(loader) {
295
296
 
296
297
  // just run once
297
298
  setAppInstance(app);
298
- case 23:
299
+ case 24:
299
300
  case "end":
300
301
  return _context.stop();
301
302
  }
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.0';
7
+ var version = '1.5.1-alpha.2';
8
8
  exports.version = version;
package/package.json CHANGED
@@ -1,24 +1,12 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-react",
3
- "version": "1.5.1-alpha.0",
3
+ "version": "1.5.1-alpha.2",
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/console-os-loader": "1.4.30-alpha.0",
40
+ "@alicloud/alfa-core": "1.4.32"
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
+ }
@@ -1 +1 @@
1
- export declare const version = "1.5.0";
1
+ export declare const version = "1.5.1-alpha.2";