@alicloud/alfa-react 1.4.6 → 1.4.9-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.
@@ -0,0 +1,4 @@
1
+ import { addRequestInterceptor } from '@alicloud/alfa-core';
2
+ export default function addGlobalRequestInterceptor(interceptor) {
3
+ addRequestInterceptor(interceptor);
4
+ }
@@ -86,8 +86,12 @@ export default function createApplication(loader) {
86
86
  };
87
87
  }, []);
88
88
  useEffect(function () {
89
+ var App;
90
+
89
91
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
90
- var _yield$loader$registe, App, logger;
92
+ var _app$context$updateBo, _app$context;
93
+
94
+ var _yield$loader$registe, app, logger;
91
95
 
92
96
  return _regeneratorRuntime.wrap(function _callee$(_context) {
93
97
  while (1) {
@@ -100,11 +104,12 @@ export default function createApplication(loader) {
100
104
 
101
105
  case 2:
102
106
  _yield$loader$registe = _context.sent;
103
- App = _yield$loader$registe.app;
107
+ app = _yield$loader$registe.app;
104
108
  logger = _yield$loader$registe.logger;
109
+ App = app;
105
110
 
106
- if (App) {
107
- _context.next = 7;
111
+ if (app) {
112
+ _context.next = 8;
108
113
  break;
109
114
  }
110
115
 
@@ -113,9 +118,9 @@ export default function createApplication(loader) {
113
118
  E_MSG: 'load app failed.'
114
119
  }));
115
120
 
116
- case 7:
121
+ case 8:
117
122
  if (appRef.current) {
118
- _context.next = 9;
123
+ _context.next = 10;
119
124
  break;
120
125
  }
121
126
 
@@ -124,16 +129,18 @@ export default function createApplication(loader) {
124
129
  E_MSG: 'cannot find container.'
125
130
  }));
126
131
 
127
- case 9:
128
- _context.next = 11;
129
- return App.mount(appRef.current, {
132
+ case 10:
133
+ // update body in sandbox context
134
+ (_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);
135
+ _context.next = 13;
136
+ return app.mount(appRef.current, {
130
137
  customProps: customProps
131
138
  });
132
139
 
133
- case 11:
134
- setApp(App);
140
+ case 13:
141
+ setApp(app);
135
142
 
136
- case 12:
143
+ case 14:
137
144
  case "end":
138
145
  return _context.stop();
139
146
  }
@@ -146,7 +153,7 @@ export default function createApplication(loader) {
146
153
  });
147
154
 
148
155
  return function () {
149
- app && app.unmount();
156
+ App && App.unmount();
150
157
  };
151
158
  }, [memoOptions]);
152
159
 
package/es/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as createAlfaApp } from './createAlfaApp';
2
2
  export { default as createAlfaWidget } from './createAlfaWidget';
3
- export { eventEmitter as widgetEventEmitter } from './widget/index'; // todo
3
+ export { eventEmitter as widgetEventEmitter } from './widget/index';
4
+ export { default as addGlobalRequestInterceptor } from './addGlobalRequestInterceptor'; // todo
4
5
 
5
6
  export { createEventBus, prefetch } from '@alicloud/alfa-core';
package/es/version.js CHANGED
@@ -1 +1 @@
1
- export var version = '1.4.6';
1
+ export var version = '1.4.9-alpha.2';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = addGlobalRequestInterceptor;
7
+
8
+ var _alfaCore = require("@alicloud/alfa-core");
9
+
10
+ function addGlobalRequestInterceptor(interceptor) {
11
+ (0, _alfaCore.addRequestInterceptor)(interceptor);
12
+ }
@@ -108,8 +108,11 @@ function createApplication(loader) {
108
108
  };
109
109
  }, []);
110
110
  (0, _react.useEffect)(function () {
111
+ var App;
111
112
  (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
112
- var _yield$loader$registe, App, logger;
113
+ var _app$context$updateBo, _app$context;
114
+
115
+ var _yield$loader$registe, app, logger;
113
116
 
114
117
  return _regenerator.default.wrap(function _callee$(_context) {
115
118
  while (1) {
@@ -122,11 +125,12 @@ function createApplication(loader) {
122
125
 
123
126
  case 2:
124
127
  _yield$loader$registe = _context.sent;
125
- App = _yield$loader$registe.app;
128
+ app = _yield$loader$registe.app;
126
129
  logger = _yield$loader$registe.logger;
130
+ App = app;
127
131
 
128
- if (App) {
129
- _context.next = 7;
132
+ if (app) {
133
+ _context.next = 8;
130
134
  break;
131
135
  }
132
136
 
@@ -135,9 +139,9 @@ function createApplication(loader) {
135
139
  E_MSG: 'load app failed.'
136
140
  }));
137
141
 
138
- case 7:
142
+ case 8:
139
143
  if (appRef.current) {
140
- _context.next = 9;
144
+ _context.next = 10;
141
145
  break;
142
146
  }
143
147
 
@@ -146,16 +150,18 @@ function createApplication(loader) {
146
150
  E_MSG: 'cannot find container.'
147
151
  }));
148
152
 
149
- case 9:
150
- _context.next = 11;
151
- return App.mount(appRef.current, {
153
+ case 10:
154
+ // update body in sandbox context
155
+ (_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);
156
+ _context.next = 13;
157
+ return app.mount(appRef.current, {
152
158
  customProps: customProps
153
159
  });
154
160
 
155
- case 11:
156
- setApp(App);
161
+ case 13:
162
+ setApp(app);
157
163
 
158
- case 12:
164
+ case 14:
159
165
  case "end":
160
166
  return _context.stop();
161
167
  }
@@ -167,7 +173,7 @@ function createApplication(loader) {
167
173
  });
168
174
  });
169
175
  return function () {
170
- app && app.unmount();
176
+ App && App.unmount();
171
177
  };
172
178
  }, [memoOptions]);
173
179
 
package/lib/index.js CHANGED
@@ -5,6 +5,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ Object.defineProperty(exports, "addGlobalRequestInterceptor", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _addGlobalRequestInterceptor.default;
12
+ }
13
+ });
8
14
  Object.defineProperty(exports, "createAlfaApp", {
9
15
  enumerable: true,
10
16
  get: function get() {
@@ -42,4 +48,6 @@ var _createAlfaWidget = _interopRequireDefault(require("./createAlfaWidget"));
42
48
 
43
49
  var _index = require("./widget/index");
44
50
 
51
+ var _addGlobalRequestInterceptor = _interopRequireDefault(require("./addGlobalRequestInterceptor"));
52
+
45
53
  var _alfaCore = require("@alicloud/alfa-core");
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.6';
7
+ var version = '1.4.9-alpha.2';
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.6",
3
+ "version": "1.4.9-alpha.2",
4
4
  "description": "Alfa Framework (React Version)",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -25,6 +25,7 @@
25
25
  "devDependencies": {
26
26
  "@alicloud/console-toolkit-cli": "^1.0.0",
27
27
  "@alicloud/console-toolkit-preset-wind-component": "^1.0.0",
28
+ "@types/axios": "^0.14.0",
28
29
  "@types/chai": "^4.1.7",
29
30
  "@types/classnames": "^2.2.9",
30
31
  "@types/crypto-js": "^4.0.2",
@@ -37,10 +38,11 @@
37
38
  "react": "^16.9.0",
38
39
  "react-dom": "^16.9.0",
39
40
  "ts-jest": "^23.10.5",
41
+ "tslib": "^2.4.0",
40
42
  "typescript": "^3.0.3"
41
43
  },
42
44
  "dependencies": {
43
- "@alicloud/alfa-core": "^1.4.5",
45
+ "@alicloud/alfa-core": "^1.4.9-alpha.2",
44
46
  "@alicloud/console-os-loader": "^1.2.3",
45
47
  "@alicloud/widget-utils-console": "^0.1.6",
46
48
  "classnames": "^2.2.6",
@@ -49,5 +51,5 @@
49
51
  "peerDependencies": {
50
52
  "react": "^16 | ^17"
51
53
  },
52
- "gitHead": "9c6fffdb53e1b42c98b80e3f4eb896a3e2ee0c86"
54
+ "gitHead": "79ca36eb444681042c6b76a3094327094a48e21b"
53
55
  }
@@ -0,0 +1,2 @@
1
+ import { RequestInterceptor } from '@alicloud/alfa-core/types/utils/interceptors';
2
+ export default function addGlobalRequestInterceptor(interceptor: RequestInterceptor): void;
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { default as createAlfaApp } from './createAlfaApp';
2
2
  export { default as createAlfaWidget } from './createAlfaWidget';
3
3
  export { eventEmitter as widgetEventEmitter } from './widget/index';
4
+ export { default as addGlobalRequestInterceptor } from './addGlobalRequestInterceptor';
4
5
  export { createEventBus, prefetch } from '@alicloud/alfa-core';
@@ -1 +1 @@
1
- export declare const version = "1.4.6";
1
+ export declare const version = "1.4.9-alpha.2";