@alicloud/alfa-react 1.3.0-alpha.1 → 1.3.0-canary.11
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 +6 -6
- package/es/app/createIsomorphicMicroApp.js +45 -0
- package/es/app/getConsoleConfig.js +49 -0
- package/es/app.js +48 -45
- package/es/components/ErrorBoundary/index.js +1 -0
- package/es/components/Loading/index.js +17 -1
- package/es/context.js +7 -0
- package/es/index.js +2 -2
- package/es/utils/getConsoleConfig.js +3 -1
- package/es/utils.js +3 -0
- package/es/widget/emitter.js +4 -4
- package/es/widget/getWidgetConfigById.js +6 -5
- package/es/widget/getWidgetDeps.js +3 -3
- package/es/widget.js +1 -1
- package/lib/app/createIsomorphicMicroApp.d.ts +2 -0
- package/lib/app/createIsomorphicMicroApp.js +65 -0
- package/lib/app/getConsoleConfig.d.ts +2 -0
- package/lib/{utils → app}/getConsoleConfig.js +7 -45
- package/lib/app.d.ts +1 -2
- package/lib/app.js +48 -43
- package/lib/base.d.ts +1 -4
- package/lib/components/ErrorBoundary/index.js +1 -0
- package/lib/components/Loading/Title.d.ts +0 -1
- package/lib/components/Loading/index.d.ts +5 -2
- package/lib/components/Loading/index.js +18 -1
- package/lib/context.d.ts +7 -0
- package/lib/context.js +15 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -6
- package/lib/types.d.ts +7 -5
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +8 -2
- package/lib/widget/emitter.d.ts +1 -0
- package/lib/widget/emitter.js +4 -4
- package/lib/widget/getWidgetConfigById.js +6 -5
- package/lib/widget/getWidgetDeps.js +2 -2
- package/lib/widget.d.ts +1 -2
- package/lib/widget.js +2 -2
- package/package.json +6 -10
- package/es/utils/checkOptions.js +0 -13
- package/lib/createAlfaApp.d.ts +0 -4
- package/lib/createAlfaApp.js +0 -135
- package/lib/createAlfaWidget.d.ts +0 -4
- package/lib/createAlfaWidget.js +0 -145
- package/lib/createApplication.d.ts +0 -13
- package/lib/createApplication.js +0 -133
- package/lib/types/base.d.ts +0 -11
- package/lib/types/base.js +0 -37
- package/lib/types/index.d.ts +0 -86
- package/lib/types/index.js +0 -5
- package/lib/utils/checkOptions.d.ts +0 -0
- package/lib/utils/checkOptions.js +0 -14
- package/lib/utils/getConsoleConfig.d.ts +0 -21
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -12
package/lib/app.js
CHANGED
|
@@ -31,14 +31,16 @@ var _alfaCore = require("@alicloud/alfa-core");
|
|
|
31
31
|
|
|
32
32
|
var _Loading = _interopRequireDefault(require("./components/Loading"));
|
|
33
33
|
|
|
34
|
-
var _types = require("./types");
|
|
35
|
-
|
|
36
34
|
var _ErrorBoundary = _interopRequireDefault(require("./components/ErrorBoundary"));
|
|
37
35
|
|
|
38
|
-
var _getConsoleConfig = require("./
|
|
36
|
+
var _getConsoleConfig = require("./app/getConsoleConfig");
|
|
37
|
+
|
|
38
|
+
var _createIsomorphicMicroApp = require("./app/createIsomorphicMicroApp");
|
|
39
39
|
|
|
40
40
|
var _utils = require("./utils");
|
|
41
41
|
|
|
42
|
+
var _types = require("./types");
|
|
43
|
+
|
|
42
44
|
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); }
|
|
43
45
|
|
|
44
46
|
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; }
|
|
@@ -55,8 +57,10 @@ var getProps = function getProps(props) {
|
|
|
55
57
|
delete parcelProps.loading;
|
|
56
58
|
delete parcelProps.entry;
|
|
57
59
|
delete parcelProps.container;
|
|
58
|
-
delete parcelProps.logger;
|
|
59
|
-
|
|
60
|
+
delete parcelProps.logger; // @ts-ignore
|
|
61
|
+
|
|
62
|
+
delete parcelProps.env; // @ts-ignore
|
|
63
|
+
|
|
60
64
|
delete parcelProps.dependencies;
|
|
61
65
|
return parcelProps;
|
|
62
66
|
};
|
|
@@ -67,8 +71,7 @@ var Application = function Application(props) {
|
|
|
67
71
|
loading = props.loading,
|
|
68
72
|
style = props.style,
|
|
69
73
|
className = props.className,
|
|
70
|
-
consoleConfig = props.consoleConfig
|
|
71
|
-
i18nMessages = props.i18nMessages;
|
|
74
|
+
consoleConfig = props.consoleConfig;
|
|
72
75
|
|
|
73
76
|
var _useState = (0, _react.useState)(false),
|
|
74
77
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -83,7 +86,7 @@ var Application = function Application(props) {
|
|
|
83
86
|
var appRef = (0, _react.useRef)(null);
|
|
84
87
|
(0, _react.useEffect)(function () {
|
|
85
88
|
(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
86
|
-
var
|
|
89
|
+
var app;
|
|
87
90
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
88
91
|
while (1) {
|
|
89
92
|
switch (_context.prev = _context.next) {
|
|
@@ -97,35 +100,27 @@ var Application = function Application(props) {
|
|
|
97
100
|
});
|
|
98
101
|
|
|
99
102
|
case 2:
|
|
100
|
-
|
|
103
|
+
app = _context.sent;
|
|
101
104
|
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
if (app.context && app.context.baseFrame) {
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
app.context.baseFrame.contentWindow.ALIYUN_CONSOLE_CONFIG = consoleConfig;
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
_context.next = 6;
|
|
108
|
-
return
|
|
111
|
+
return app.load();
|
|
109
112
|
|
|
110
113
|
case 6:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return _context.abrupt("return");
|
|
117
|
-
|
|
118
|
-
case 8:
|
|
119
|
-
_context.next = 10;
|
|
120
|
-
return App.mount(appRef.current, {
|
|
114
|
+
_context.next = 8;
|
|
115
|
+
return app.mount(appRef.current, {
|
|
121
116
|
customProps: getProps(props)
|
|
122
117
|
});
|
|
123
118
|
|
|
124
|
-
case
|
|
119
|
+
case 8:
|
|
125
120
|
setMounted(true);
|
|
126
|
-
setApp(
|
|
121
|
+
setApp(app);
|
|
127
122
|
|
|
128
|
-
case
|
|
123
|
+
case 10:
|
|
129
124
|
case "end":
|
|
130
125
|
return _context.stop();
|
|
131
126
|
}
|
|
@@ -142,23 +137,31 @@ var Application = function Application(props) {
|
|
|
142
137
|
}
|
|
143
138
|
|
|
144
139
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !mounted && /*#__PURE__*/_react.default.createElement(_Loading.default, {
|
|
140
|
+
microAppContainer: name,
|
|
145
141
|
loading: loading
|
|
146
142
|
}), sandbox && sandbox !== true && sandbox.disableFakeBody ? /*#__PURE__*/_react.default.createElement(name, {
|
|
147
143
|
style: style,
|
|
148
144
|
className: className,
|
|
149
145
|
ref: appRef,
|
|
150
146
|
dataId: name
|
|
151
|
-
}) : /*#__PURE__*/_react.default.createElement(name, {
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
}) : /*#__PURE__*/_react.default.createElement(name, {
|
|
148
|
+
children: /*#__PURE__*/_react.default.createElement('div', {
|
|
149
|
+
ref: appRef
|
|
150
|
+
})
|
|
151
|
+
}));
|
|
154
152
|
};
|
|
155
153
|
|
|
156
154
|
function createAlfaApp(option) {
|
|
157
155
|
var name = option.name,
|
|
158
156
|
loading = option.loading,
|
|
159
157
|
manifest = option.manifest;
|
|
158
|
+
|
|
159
|
+
if ((0, _utils.isSSR)()) {
|
|
160
|
+
return (0, _createIsomorphicMicroApp.createIsomorphicAlfaApp)(option);
|
|
161
|
+
}
|
|
162
|
+
|
|
160
163
|
var AlfaApp = /*#__PURE__*/(0, _react.lazy)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
161
|
-
var resolvedManifest, consoleConfig,
|
|
164
|
+
var resolvedManifest, consoleConfig, AlfaApp;
|
|
162
165
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
163
166
|
while (1) {
|
|
164
167
|
switch (_context2.prev = _context2.next) {
|
|
@@ -177,34 +180,35 @@ function createAlfaApp(option) {
|
|
|
177
180
|
resolvedManifest = _context2.sent;
|
|
178
181
|
|
|
179
182
|
case 5:
|
|
183
|
+
// @ts-ignore
|
|
180
184
|
consoleConfig = window.ALIYUN_CONSOLE_CONFIG || {};
|
|
181
|
-
|
|
185
|
+
|
|
186
|
+
if (!option.dynamicConfig) {
|
|
187
|
+
_context2.next = 10;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
_context2.next = 9;
|
|
182
192
|
return (0, _getConsoleConfig.getConsoleConfig)(option, consoleConfig);
|
|
183
193
|
|
|
184
|
-
case
|
|
194
|
+
case 9:
|
|
185
195
|
consoleConfig = _context2.sent;
|
|
186
|
-
_context2.next = 11;
|
|
187
|
-
return (0, _alfaCore.getLocale)(option);
|
|
188
|
-
|
|
189
|
-
case 11:
|
|
190
|
-
messages = _context2.sent;
|
|
191
|
-
i18nMessages = _objectSpread(_objectSpread({}, window.ALIYUN_CONSOLE_I18N_MESSAGE), messages);
|
|
192
196
|
|
|
193
|
-
|
|
197
|
+
case 10:
|
|
198
|
+
AlfaApp = function AlfaApp(props) {
|
|
194
199
|
return /*#__PURE__*/_react.default.createElement(Application, (0, _extends2.default)({
|
|
195
200
|
manifest: resolvedManifest
|
|
196
201
|
}, props, {
|
|
197
202
|
name: (0, _utils.normalizeName)(name),
|
|
198
|
-
consoleConfig: consoleConfig
|
|
199
|
-
i18nMessages: i18nMessages
|
|
203
|
+
consoleConfig: consoleConfig
|
|
200
204
|
}));
|
|
201
205
|
};
|
|
202
206
|
|
|
203
207
|
return _context2.abrupt("return", {
|
|
204
|
-
default:
|
|
208
|
+
default: AlfaApp
|
|
205
209
|
});
|
|
206
210
|
|
|
207
|
-
case
|
|
211
|
+
case 12:
|
|
208
212
|
case "end":
|
|
209
213
|
return _context2.stop();
|
|
210
214
|
}
|
|
@@ -214,6 +218,7 @@ function createAlfaApp(option) {
|
|
|
214
218
|
return function (props) {
|
|
215
219
|
return /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, props, /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
216
220
|
fallback: /*#__PURE__*/_react.default.createElement(_Loading.default, {
|
|
221
|
+
microAppContainer: (0, _utils.normalizeName)(name),
|
|
217
222
|
loading: loading
|
|
218
223
|
})
|
|
219
224
|
}, /*#__PURE__*/_react.default.createElement(AlfaApp, (0, _extends2.default)({}, option, {
|
package/lib/base.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from 'react';
|
|
2
|
-
import { IAppConfig, IOptions
|
|
2
|
+
import { IAppConfig, IOptions } from '@alicloud/alfa-core';
|
|
3
3
|
export interface IProps<T = any> extends HTMLAttributes<Element>, IAppConfig, IOptions {
|
|
4
4
|
loading?: boolean | React.ReactChild;
|
|
5
5
|
consoleConfig?: any;
|
|
6
|
-
i18nMessages?: any;
|
|
7
|
-
env?: AlfaEnvEnum;
|
|
8
|
-
dependencies?: any;
|
|
9
6
|
}
|
|
10
7
|
export default class MicroAppBase<T> extends React.Component<Partial<IProps<T>>> {
|
|
11
8
|
}
|
|
@@ -63,6 +63,7 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
63
63
|
(0, _isFunction.default)((_window = window) === null || _window === void 0 ? void 0 : (_window$__bl = _window.__bl) === null || _window$__bl === void 0 ? void 0 : _window$__bl.error) && window.__bl.error(error, errorInfo);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
console.error(error);
|
|
66
67
|
this.props.appDidCatch && this.props.appDidCatch(error);
|
|
67
68
|
}
|
|
68
69
|
}, {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
interface IProps {
|
|
3
3
|
loading?: boolean | React.ReactChild;
|
|
4
|
-
|
|
4
|
+
microAppContainer?: string;
|
|
5
|
+
}
|
|
6
|
+
export default function getLoading({ loading, microAppContainer }: IProps): JSX.Element | null;
|
|
7
|
+
export {};
|
|
@@ -11,8 +11,25 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _Skeleton = _interopRequireDefault(require("./Skeleton"));
|
|
13
13
|
|
|
14
|
+
var initialPath = window.location.pathname;
|
|
15
|
+
|
|
14
16
|
function getLoading(_ref) {
|
|
15
|
-
var loading = _ref.loading
|
|
17
|
+
var loading = _ref.loading,
|
|
18
|
+
microAppContainer = _ref.microAppContainer;
|
|
19
|
+
|
|
20
|
+
// 第一次如果是 ssr 出来的内容直接拿 ssr 的内容作为骨架做展示
|
|
21
|
+
// 防止出现首屏抖动
|
|
22
|
+
if (microAppContainer) {
|
|
23
|
+
var node = document.querySelector(microAppContainer); //@ts-ignore
|
|
24
|
+
|
|
25
|
+
if (initialPath === window.location.pathname && window.__isSSR) {
|
|
26
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
27
|
+
dangerouslySetInnerHTML: {
|
|
28
|
+
__html: node ? node.innerHTML : ''
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
16
33
|
|
|
17
34
|
if (loading === false) {
|
|
18
35
|
return null;
|
package/lib/context.d.ts
ADDED
package/lib/context.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 用来提供 ssr 状态下的获取 服务端 manifest & bundle 的实现
|
|
12
|
+
*/
|
|
13
|
+
var EnvContext = /*#__PURE__*/(0, _react.createContext)({});
|
|
14
|
+
var _default = EnvContext;
|
|
15
|
+
exports.default = _default;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { createAlfaWidget } from './widget';
|
|
2
|
+
export { createAlfaApp } from './app';
|
|
3
3
|
export { eventEmitter as widgetEventEmitter } from './widget/index';
|
|
4
4
|
export { createEventBus, prefetch } from '@alicloud/alfa-core';
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
Object.defineProperty(exports, "createAlfaApp", {
|
|
9
7
|
enumerable: true,
|
|
10
8
|
get: function get() {
|
|
11
|
-
return
|
|
9
|
+
return _app.createAlfaApp;
|
|
12
10
|
}
|
|
13
11
|
});
|
|
14
12
|
Object.defineProperty(exports, "createAlfaWidget", {
|
|
15
13
|
enumerable: true,
|
|
16
14
|
get: function get() {
|
|
17
|
-
return
|
|
15
|
+
return _widget.createAlfaWidget;
|
|
18
16
|
}
|
|
19
17
|
});
|
|
20
18
|
Object.defineProperty(exports, "createEventBus", {
|
|
@@ -36,9 +34,9 @@ Object.defineProperty(exports, "widgetEventEmitter", {
|
|
|
36
34
|
}
|
|
37
35
|
});
|
|
38
36
|
|
|
39
|
-
var
|
|
37
|
+
var _widget = require("./widget");
|
|
40
38
|
|
|
41
|
-
var
|
|
39
|
+
var _app = require("./app");
|
|
42
40
|
|
|
43
41
|
var _index = require("./widget/index");
|
|
44
42
|
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import React from 'React';
|
|
3
|
-
import { createMicroApp,
|
|
3
|
+
import { createMicroApp, IOptions } from '@alicloud/alfa-core';
|
|
4
4
|
export interface AlfaVersion {
|
|
5
5
|
entry: string;
|
|
6
6
|
}
|
|
@@ -10,18 +10,20 @@ export interface AlfaReleaseConfig {
|
|
|
10
10
|
'dist-tag': Record<string, string>;
|
|
11
11
|
}
|
|
12
12
|
export declare type EnvEnum = 'prod' | 'local' | 'pre' | 'daily';
|
|
13
|
-
export interface AlfaFactoryOption extends
|
|
13
|
+
export interface AlfaFactoryOption extends IOptions {
|
|
14
|
+
name: string;
|
|
15
|
+
version?: string;
|
|
14
16
|
loading?: boolean | React.ReactChild;
|
|
17
|
+
env?: EnvEnum;
|
|
18
|
+
url?: string;
|
|
19
|
+
manifest?: string;
|
|
15
20
|
dependencies?: Record<string, any>;
|
|
16
21
|
dynamicConfig?: boolean;
|
|
17
|
-
className?: string;
|
|
18
|
-
style?: Record<string, any>;
|
|
19
22
|
}
|
|
20
23
|
declare type OmitKeys = 'manifest';
|
|
21
24
|
export interface WidgetFactoryOption extends Omit<AlfaFactoryOption, OmitKeys> {
|
|
22
25
|
runtimeVersion?: string;
|
|
23
26
|
alfaLoader?: boolean;
|
|
24
|
-
theme?: string;
|
|
25
27
|
}
|
|
26
28
|
export interface AlfaEnvConfigDescriptor {
|
|
27
29
|
releaseUrl: string;
|
package/lib/utils.d.ts
CHANGED
package/lib/utils.js
CHANGED
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.normalizeName = void 0;
|
|
6
|
+
exports.normalizeName = exports.isSSR = void 0;
|
|
7
7
|
|
|
8
8
|
var normalizeName = function normalizeName(name) {
|
|
9
9
|
return name.replace(/@/g, '').replace(/\//g, '-');
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
exports.normalizeName = normalizeName;
|
|
12
|
+
exports.normalizeName = normalizeName;
|
|
13
|
+
|
|
14
|
+
var isSSR = function isSSR() {
|
|
15
|
+
return typeof document === 'undefined';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.isSSR = isSSR;
|
package/lib/widget/emitter.d.ts
CHANGED
package/lib/widget/emitter.js
CHANGED
|
@@ -30,13 +30,13 @@ var WidgetEventEmitter = /*#__PURE__*/function (_EventEmitter) {
|
|
|
30
30
|
|
|
31
31
|
function WidgetEventEmitter() {
|
|
32
32
|
(0, _classCallCheck2.default)(this, WidgetEventEmitter);
|
|
33
|
-
return _super.
|
|
34
|
-
}
|
|
33
|
+
return _super.call(this);
|
|
34
|
+
} // Compatible with the old api, this may get removed at sometime later.
|
|
35
|
+
|
|
35
36
|
|
|
36
37
|
(0, _createClass2.default)(WidgetEventEmitter, [{
|
|
37
38
|
key: "refersh",
|
|
38
|
-
value:
|
|
39
|
-
function refersh(widgetId) {
|
|
39
|
+
value: function refersh(widgetId) {
|
|
40
40
|
return this.emit("".concat(widgetId, ":REFRESH"));
|
|
41
41
|
}
|
|
42
42
|
}, {
|
|
@@ -27,25 +27,26 @@ var getWidgetConfigById = /*#__PURE__*/function () {
|
|
|
27
27
|
switch (_context.prev = _context.next) {
|
|
28
28
|
case 0:
|
|
29
29
|
env = _env.ENV[option.env || (0, _env.getConsoleEnv)()];
|
|
30
|
+
console.log(env.configUrl);
|
|
30
31
|
|
|
31
32
|
if (cachedConfig[option.name]) {
|
|
32
|
-
_context.next =
|
|
33
|
+
_context.next = 7;
|
|
33
34
|
break;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
_context.next =
|
|
37
|
+
_context.next = 5;
|
|
37
38
|
return _axios.default.get((0, _template.default)(env.configUrl)({
|
|
38
39
|
id: option.name
|
|
39
40
|
}));
|
|
40
41
|
|
|
41
|
-
case
|
|
42
|
+
case 5:
|
|
42
43
|
resp = _context.sent;
|
|
43
44
|
cachedConfig[option.name] = resp.data;
|
|
44
45
|
|
|
45
|
-
case
|
|
46
|
+
case 7:
|
|
46
47
|
return _context.abrupt("return", cachedConfig[option.name]);
|
|
47
48
|
|
|
48
|
-
case
|
|
49
|
+
case 8:
|
|
49
50
|
case "end":
|
|
50
51
|
return _context.stop();
|
|
51
52
|
}
|
|
@@ -57,7 +57,7 @@ var createWidget = function createWidget(option) {
|
|
|
57
57
|
|
|
58
58
|
var id = _ref.id,
|
|
59
59
|
version = _ref.version;
|
|
60
|
-
return (0, _widget.
|
|
60
|
+
return (0, _widget.createAlfaWidget)({
|
|
61
61
|
name: id,
|
|
62
62
|
version: version,
|
|
63
63
|
dependencies: option === null || option === void 0 ? void 0 : option.dependencies,
|
|
@@ -185,7 +185,7 @@ var getWidgetDeps = /*#__PURE__*/function () {
|
|
|
185
185
|
react: _react.default,
|
|
186
186
|
'react-dom': _reactDom.default,
|
|
187
187
|
'prop-types': propTypes,
|
|
188
|
-
axios: _axios.default
|
|
188
|
+
'axios': _axios.default
|
|
189
189
|
}, cachedRuntime[version].default), {}, (_objectSpread2 = {}, (0, _defineProperty2.default)(_objectSpread2, WIDGET_UTILS_PKG_NAME, injectedWidgetUtils), (0, _defineProperty2.default)(_objectSpread2, '@ali/widget-utils-config', injectedWidgetUtils), (0, _defineProperty2.default)(_objectSpread2, '@ali/widget-loader', createWidget), _objectSpread2)));
|
|
190
190
|
|
|
191
191
|
case 31:
|
package/lib/widget.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { WidgetFactoryOption } from './types';
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function createAlfaWidget<T>(option: WidgetFactoryOption): (props: T) => JSX.Element;
|
package/lib/widget.js
CHANGED
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.
|
|
10
|
+
exports.createAlfaWidget = createAlfaWidget;
|
|
11
11
|
|
|
12
12
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
13
|
|
|
@@ -37,7 +37,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
37
37
|
|
|
38
38
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
39
39
|
|
|
40
|
-
function
|
|
40
|
+
function createAlfaWidget(option) {
|
|
41
41
|
var AlfaWidget = /*#__PURE__*/(0, _react.lazy)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
42
42
|
var url, config, _yield$getWidgetVersi, version, entryUrl, deps;
|
|
43
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-react",
|
|
3
|
-
"version": "1.3.0-
|
|
3
|
+
"version": "1.3.0-canary.11",
|
|
4
4
|
"description": "Alfa Framework (React Version)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "breezr start-storybook",
|
|
12
|
-
"prepublish": "npm run build && npm run babel && npm run babel:esm",
|
|
12
|
+
"prepublish": "npm run clean && npm run build && npm run babel && npm run babel:esm",
|
|
13
13
|
"babel": "breezr build --engine babel && tsc --emitDeclarationOnly -d --declarationDir ./lib",
|
|
14
14
|
"babel:esm": "breezr build --engine babel --es-module",
|
|
15
15
|
"build": "breezr build --engine webpack",
|
|
@@ -19,14 +19,11 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@ali/home-widget-runtime": "^1.1.6",
|
|
23
22
|
"@alicloud/console-toolkit-cli": "^1.0.0",
|
|
24
23
|
"@alicloud/console-toolkit-preset-wind-component": "^1.0.0",
|
|
25
24
|
"@types/chai": "^4.1.7",
|
|
26
25
|
"@types/classnames": "^2.2.9",
|
|
27
|
-
"@types/crypto-js": "^4.0.2",
|
|
28
26
|
"@types/jest": "^23.3.13",
|
|
29
|
-
"@types/lodash": "^4.14.176",
|
|
30
27
|
"@types/react": "^16.9.2",
|
|
31
28
|
"@types/react-dom": "^16.9.0",
|
|
32
29
|
"@types/single-spa-react": "^2.8.3",
|
|
@@ -38,14 +35,13 @@
|
|
|
38
35
|
"typescript": "^3.0.3"
|
|
39
36
|
},
|
|
40
37
|
"dependencies": {
|
|
41
|
-
"@alicloud/alfa-core": "
|
|
42
|
-
"@alicloud/console-os-loader": "
|
|
38
|
+
"@alicloud/alfa-core": "1.3.0-canary.7",
|
|
39
|
+
"@alicloud/console-os-loader": "1.3.0-canary.5",
|
|
43
40
|
"@alicloud/widget-utils-console": "^0.1.6",
|
|
44
|
-
"classnames": "^2.2.6"
|
|
45
|
-
"crypto-js": "^4.1.1"
|
|
41
|
+
"classnames": "^2.2.6"
|
|
46
42
|
},
|
|
47
43
|
"peerDependencies": {
|
|
48
44
|
"react": "^16 | ^17"
|
|
49
45
|
},
|
|
50
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "92b51c833b6fd5aa584c0bbbab6470a79c96f8c4"
|
|
51
47
|
}
|
package/es/utils/checkOptions.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// import { AlfaFactoryOption } from '@alicloud/alfa-core';
|
|
2
|
-
// enum Type {
|
|
3
|
-
// app = 'app',
|
|
4
|
-
// widget = 'widget'
|
|
5
|
-
// }
|
|
6
|
-
// const getType = (name: string): Type => {
|
|
7
|
-
// return Type.app;
|
|
8
|
-
// };
|
|
9
|
-
// const checkOptions = <T extends AlfaFactoryOption>(option: T, type: Type): T => {
|
|
10
|
-
// const { name } = option;
|
|
11
|
-
// const type = get
|
|
12
|
-
// };
|
|
13
|
-
// export default checkOptions;
|
package/lib/createAlfaApp.d.ts
DELETED