@alicloud/alfa-react 1.4.40-alpha.0 → 1.5.0-alpha.0

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.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/es/components/ErrorBoundary/ErrorPanel.js +0 -2
  3. package/es/components/ErrorBoundary/index.js +7 -19
  4. package/es/components/Loading/Paragraph.js +9 -25
  5. package/es/components/Loading/Skeleton.js +14 -46
  6. package/es/components/Loading/Title.js +3 -8
  7. package/es/components/Loading/index.js +0 -2
  8. package/es/createAlfaApp.js +6 -10
  9. package/es/createAlfaWidget.js +16 -28
  10. package/es/createApplication.js +154 -188
  11. package/es/hooks/beforeLoadHook.js +60 -81
  12. package/es/hooks/beforeResolveHook.js +24 -29
  13. package/es/index.js +2 -2
  14. package/es/types/base.js +0 -9
  15. package/es/utils/counter.js +1 -3
  16. package/es/utils/getConsoleConfig.js +13 -32
  17. package/es/utils/getConsoleGlobal.js +6 -13
  18. package/es/utils/index.js +2 -1
  19. package/es/version.js +1 -1
  20. package/es/widget/emitter.js +2 -11
  21. package/es/widget/env.js +2 -4
  22. package/es/widget/getWidgetConfigById.js +19 -27
  23. package/es/widget/getWidgetDeps.js +104 -130
  24. package/es/widget/getWidgetVersionById.js +79 -106
  25. package/es/widget.js +45 -58
  26. package/lib/addGlobalRequestInterceptor.js +0 -2
  27. package/lib/components/ErrorBoundary/ErrorPanel.js +0 -5
  28. package/lib/components/ErrorBoundary/index.js +7 -25
  29. package/lib/components/Loading/Paragraph.js +9 -32
  30. package/lib/components/Loading/Skeleton.js +14 -60
  31. package/lib/components/Loading/Title.js +3 -14
  32. package/lib/components/Loading/index.js +0 -6
  33. package/lib/createAlfaApp.js +6 -24
  34. package/lib/createAlfaWidget.js +16 -45
  35. package/lib/createApplication.js +154 -199
  36. package/lib/hooks/beforeLoadHook.js +60 -88
  37. package/lib/hooks/beforeResolveHook.js +21 -33
  38. package/lib/index.js +0 -9
  39. package/lib/types/base.js +0 -14
  40. package/lib/utils/counter.js +1 -4
  41. package/lib/utils/getConsoleConfig.js +12 -37
  42. package/lib/utils/getConsoleGlobal.js +6 -18
  43. package/lib/utils/index.js +2 -5
  44. package/lib/version.js +1 -1
  45. package/lib/widget/emitter.js +2 -16
  46. package/lib/widget/env.js +2 -6
  47. package/lib/widget/getWidgetConfigById.js +19 -36
  48. package/lib/widget/getWidgetDeps.js +103 -146
  49. package/lib/widget/getWidgetVersionById.js +79 -113
  50. package/lib/widget/index.js +0 -8
  51. package/lib/widget.js +45 -72
  52. package/package.json +22 -19
  53. package/types/components/ErrorBoundary/index.d.ts +1 -1
  54. package/types/components/Loading/Paragraph.d.ts +1 -1
  55. package/types/components/Loading/Skeleton.d.ts +2 -2
  56. package/types/createAlfaApp.d.ts +7 -1
  57. package/types/createAlfaWidget.d.ts +2 -2
  58. package/types/createApplication.d.ts +1 -0
  59. package/types/types/index.d.ts +5 -5
  60. package/types/utils/getConsoleConfig.d.ts +4 -2
  61. package/types/utils/getConsoleGlobal.d.ts +3 -1
  62. package/types/version.d.ts +1 -1
  63. package/types/widget/getWidgetDeps.d.ts +1 -1
  64. package/dist/index.js +0 -21
  65. package/es/app.js +0 -194
  66. package/es/hooks/afterLoadHook.js +0 -69
  67. package/lib/app.d.ts +0 -3
  68. package/lib/app.js +0 -223
  69. package/lib/components/ErrorBoundary/ErrorPanel.d.ts +0 -6
  70. package/lib/components/ErrorBoundary/index.d.ts +0 -17
  71. package/lib/components/Loading/Paragraph.d.ts +0 -14
  72. package/lib/components/Loading/Skeleton.d.ts +0 -19
  73. package/lib/components/Loading/Title.d.ts +0 -8
  74. package/lib/components/Loading/index.d.ts +0 -4
  75. package/lib/components/Loading/style.d.ts +0 -2
  76. package/lib/createAlfaApp.d.ts +0 -7
  77. package/lib/createAlfaWidget.d.ts +0 -4
  78. package/lib/createApplication.d.ts +0 -12
  79. package/lib/hooks/afterLoadHook.d.ts +0 -3
  80. package/lib/hooks/afterLoadHook.js +0 -84
  81. package/lib/hooks/beforeLoadHook.d.ts +0 -3
  82. package/lib/hooks/beforeResolveHook.d.ts +0 -3
  83. package/lib/index.d.ts +0 -4
  84. package/lib/types/base.d.ts +0 -11
  85. package/lib/types/index.d.ts +0 -91
  86. package/lib/utils/getConsoleConfig.d.ts +0 -1
  87. package/lib/utils/getConsoleGlobal.d.ts +0 -1
  88. package/lib/utils/index.d.ts +0 -1
  89. package/lib/version.d.ts +0 -1
  90. package/lib/widget/emitter.d.ts +0 -8
  91. package/lib/widget/env.d.ts +0 -4
  92. package/lib/widget/getWidgetConfigById.d.ts +0 -2
  93. package/lib/widget/getWidgetDeps.d.ts +0 -2
  94. package/lib/widget/getWidgetVersionById.d.ts +0 -6
  95. package/lib/widget/index.d.ts +0 -4
  96. package/lib/widget.d.ts +0 -2
@@ -2,105 +2,84 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
-
6
5
  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; }
7
-
8
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; }
9
-
10
7
  import { getConfig, getI18nMessages } from '@alicloud/alfa-core';
11
8
  import { getConsoleConfig } from '../utils/getConsoleConfig';
12
9
  import { getConsoleGlobal } from '../utils/getConsoleGlobal';
13
-
14
10
  // inject consoleConfig & locales after load
15
11
  function afterLoadHook(_x) {
16
12
  return _afterLoadHook.apply(this, arguments);
17
13
  }
18
-
19
14
  function _afterLoadHook() {
20
15
  _afterLoadHook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
21
16
  var app, logger, sandbox, dynamicConfig, defaultConsoleConfig, defaultConsoleGlobal, CONFIG_START_TIME, CONFIG_END_TIME, configData, _yield$Promise$all, _yield$Promise$all2, consoleConfig, consoleGlobal, messages, i18nMessages, overrides, END_TIME;
22
-
23
17
  return _regeneratorRuntime.wrap(function _callee$(_context) {
24
- while (1) {
25
- switch (_context.prev = _context.next) {
26
- case 0:
27
- app = appConfig.app, logger = appConfig.logger, sandbox = appConfig.sandbox, dynamicConfig = appConfig.dynamicConfig;
28
- defaultConsoleConfig = window.ALIYUN_CONSOLE_CONFIG || {};
29
- defaultConsoleGlobal = window.ALIYUN_CONSOLE_GLOBAL || {};
30
- CONFIG_START_TIME = Date.now();
31
- CONFIG_END_TIME = Date.now();
32
-
33
- if (!dynamicConfig) {
34
- _context.next = 21;
35
- break;
36
- }
37
-
38
- _context.next = 8;
39
- return getConfig(appConfig);
40
-
41
- case 8:
42
- configData = _context.sent;
43
- _context.next = 11;
44
- return Promise.all([getConsoleConfig(configData, defaultConsoleConfig), getConsoleGlobal(configData, defaultConsoleGlobal), getI18nMessages(appConfig)]);
45
-
46
- case 11:
47
- _yield$Promise$all = _context.sent;
48
- _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
49
- consoleConfig = _yield$Promise$all2[0];
50
- consoleGlobal = _yield$Promise$all2[1];
51
- messages = _yield$Promise$all2[2];
52
- CONFIG_END_TIME = Date.now();
53
- i18nMessages = _objectSpread(_objectSpread({}, window.ALIYUN_CONSOLE_I18N_MESSAGE), messages); // inject global variables when sandbox is valid
54
-
55
- if (app !== null && app !== void 0 && app.context && !(sandbox !== null && sandbox !== void 0 && sandbox.disable)) {
56
- app.context.window.ALIYUN_CONSOLE_CONFIG = consoleConfig;
57
- app.context.window.ALIYUN_CONSOLE_GLOBAL = consoleGlobal;
58
- app.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = i18nMessages;
59
- app.context.window.ALIYUN_WIND_MESSAGE = window.ALIYUN_WIND_MESSAGE;
60
- }
61
-
62
- _context.next = 22;
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ app = appConfig.app, logger = appConfig.logger, sandbox = appConfig.sandbox, dynamicConfig = appConfig.dynamicConfig;
21
+ defaultConsoleConfig = window.ALIYUN_CONSOLE_CONFIG || {};
22
+ defaultConsoleGlobal = window.ALIYUN_CONSOLE_GLOBAL || {};
23
+ CONFIG_START_TIME = Date.now();
24
+ CONFIG_END_TIME = Date.now();
25
+ if (!dynamicConfig) {
26
+ _context.next = 21;
63
27
  break;
64
-
65
- case 21:
66
- if (app !== null && app !== void 0 && app.context && !(sandbox !== null && sandbox !== void 0 && sandbox.disable)) {
67
- app.context.window.ALIYUN_CONSOLE_CONFIG = defaultConsoleConfig;
68
- app.context.window.ALIYUN_CONSOLE_GLOBAL = defaultConsoleGlobal;
69
- app.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = window.ALIYUN_CONSOLE_I18N_MESSAGE;
70
- app.context.window.ALIYUN_WIND_MESSAGE = window.ALIYUN_WIND_MESSAGE;
71
- }
72
-
73
- case 22:
74
- overrides = sandbox === null || sandbox === void 0 ? void 0 : sandbox.overrideGlobalVars;
75
-
76
- if (overrides && app) {
77
- Object.entries(overrides).forEach(function (_ref) {
78
- var _ref2 = _slicedToArray(_ref, 2),
79
- key = _ref2[0],
80
- value = _ref2[1];
81
-
82
- app.context.window[key] = value;
83
- });
84
- }
85
-
86
- END_TIME = Date.now();
87
- (logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
88
- CONFIG_START_TIME: CONFIG_START_TIME,
89
- CONFIG_END_TIME: CONFIG_END_TIME,
90
- END_TIME: END_TIME,
91
- COST: CONFIG_END_TIME - CONFIG_START_TIME
28
+ }
29
+ _context.next = 8;
30
+ return getConfig(appConfig);
31
+ case 8:
32
+ configData = _context.sent;
33
+ _context.next = 11;
34
+ return Promise.all([getConsoleConfig(configData, defaultConsoleConfig), getConsoleGlobal(configData, defaultConsoleGlobal), getI18nMessages(appConfig)]);
35
+ case 11:
36
+ _yield$Promise$all = _context.sent;
37
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
38
+ consoleConfig = _yield$Promise$all2[0];
39
+ consoleGlobal = _yield$Promise$all2[1];
40
+ messages = _yield$Promise$all2[2];
41
+ CONFIG_END_TIME = Date.now();
42
+ i18nMessages = _objectSpread(_objectSpread({}, window.ALIYUN_CONSOLE_I18N_MESSAGE), messages); // inject global variables when sandbox is valid
43
+ if (app !== null && app !== void 0 && app.context && !(sandbox !== null && sandbox !== void 0 && sandbox.disable)) {
44
+ app.context.window.ALIYUN_CONSOLE_CONFIG = consoleConfig;
45
+ app.context.window.ALIYUN_CONSOLE_GLOBAL = consoleGlobal;
46
+ app.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = i18nMessages;
47
+ app.context.window.ALIYUN_WIND_MESSAGE = window.ALIYUN_WIND_MESSAGE;
48
+ }
49
+ _context.next = 22;
50
+ break;
51
+ case 21:
52
+ if (app !== null && app !== void 0 && app.context && !(sandbox !== null && sandbox !== void 0 && sandbox.disable)) {
53
+ app.context.window.ALIYUN_CONSOLE_CONFIG = defaultConsoleConfig;
54
+ app.context.window.ALIYUN_CONSOLE_GLOBAL = defaultConsoleGlobal;
55
+ app.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = window.ALIYUN_CONSOLE_I18N_MESSAGE;
56
+ app.context.window.ALIYUN_WIND_MESSAGE = window.ALIYUN_WIND_MESSAGE;
57
+ }
58
+ case 22:
59
+ overrides = sandbox === null || sandbox === void 0 ? void 0 : sandbox.overrideGlobalVars;
60
+ if (overrides && app) {
61
+ Object.entries(overrides).forEach(function (_ref) {
62
+ var _ref2 = _slicedToArray(_ref, 2),
63
+ key = _ref2[0],
64
+ value = _ref2[1];
65
+ app.context.window[key] = value;
92
66
  });
93
- (logger === null || logger === void 0 ? void 0 : logger.send) && logger.send();
94
- return _context.abrupt("return", appConfig);
95
-
96
- case 28:
97
- case "end":
98
- return _context.stop();
99
- }
67
+ }
68
+ END_TIME = Date.now();
69
+ (logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
70
+ CONFIG_START_TIME: CONFIG_START_TIME,
71
+ CONFIG_END_TIME: CONFIG_END_TIME,
72
+ END_TIME: END_TIME,
73
+ COST: CONFIG_END_TIME - CONFIG_START_TIME
74
+ });
75
+ (logger === null || logger === void 0 ? void 0 : logger.send) && logger.send();
76
+ return _context.abrupt("return", appConfig);
77
+ case 28:
78
+ case "end":
79
+ return _context.stop();
100
80
  }
101
81
  }, _callee);
102
82
  }));
103
83
  return _afterLoadHook.apply(this, arguments);
104
84
  }
105
-
106
85
  export default afterLoadHook;
@@ -1,46 +1,41 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { getManifest } from '@alicloud/alfa-core';
4
- import { version as LOADER_VERSION } from '../version'; // get manifest before resolve
5
- // normalize name
4
+ import { version as LOADER_VERSION } from '../version';
6
5
 
6
+ // get manifest before resolve
7
+ // normalize name
7
8
  function beforeResolveHook(_x) {
8
9
  return _beforeResolveHook.apply(this, arguments);
9
10
  }
10
-
11
11
  function _beforeResolveHook() {
12
12
  _beforeResolveHook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
13
13
  var logger, START_TIME, MANIFEST_START_TIME, resolvedManifest, MANIFEST_END_TIME;
14
14
  return _regeneratorRuntime.wrap(function _callee$(_context) {
15
- while (1) {
16
- switch (_context.prev = _context.next) {
17
- case 0:
18
- logger = appConfig.logger;
19
- START_TIME = Date.now();
20
- MANIFEST_START_TIME = Date.now();
21
- _context.next = 5;
22
- return getManifest(appConfig);
23
-
24
- case 5:
25
- resolvedManifest = _context.sent;
26
- MANIFEST_END_TIME = Date.now();
27
- (logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
28
- LOADER_VERSION: LOADER_VERSION,
29
- START_TIME: START_TIME,
30
- MANIFEST_START_TIME: MANIFEST_START_TIME,
31
- MANIFEST_END_TIME: MANIFEST_END_TIME
32
- });
33
- appConfig.manifest = resolvedManifest;
34
- return _context.abrupt("return", appConfig);
35
-
36
- case 10:
37
- case "end":
38
- return _context.stop();
39
- }
15
+ while (1) switch (_context.prev = _context.next) {
16
+ case 0:
17
+ logger = appConfig.logger;
18
+ START_TIME = Date.now();
19
+ MANIFEST_START_TIME = Date.now();
20
+ _context.next = 5;
21
+ return getManifest(appConfig);
22
+ case 5:
23
+ resolvedManifest = _context.sent;
24
+ MANIFEST_END_TIME = Date.now();
25
+ (logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
26
+ LOADER_VERSION: LOADER_VERSION,
27
+ START_TIME: START_TIME,
28
+ MANIFEST_START_TIME: MANIFEST_START_TIME,
29
+ MANIFEST_END_TIME: MANIFEST_END_TIME
30
+ });
31
+ appConfig.manifest = resolvedManifest;
32
+ return _context.abrupt("return", appConfig);
33
+ case 10:
34
+ case "end":
35
+ return _context.stop();
40
36
  }
41
37
  }, _callee);
42
38
  }));
43
39
  return _beforeResolveHook.apply(this, arguments);
44
40
  }
45
-
46
41
  export default beforeResolveHook;
package/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { default as createAlfaApp, useAlfaApp } from './createAlfaApp';
2
2
  export { default as createAlfaWidget, useAlfaWidget } from './createAlfaWidget';
3
3
  export { eventEmitter as widgetEventEmitter } from './widget/index';
4
- export { default as addGlobalRequestInterceptor } from './addGlobalRequestInterceptor'; // todo
5
-
4
+ export { default as addGlobalRequestInterceptor } from './addGlobalRequestInterceptor';
5
+ // todo
6
6
  export { createEventBus, prefetch } from '@alicloud/alfa-core';
package/es/types/base.js CHANGED
@@ -3,25 +3,16 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
-
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
8
  import React from 'react';
12
-
13
9
  var MicroAppBase = /*#__PURE__*/function (_React$Component) {
14
10
  _inherits(MicroAppBase, _React$Component);
15
-
16
11
  var _super = _createSuper(MicroAppBase);
17
-
18
12
  function MicroAppBase() {
19
13
  _classCallCheck(this, MicroAppBase);
20
-
21
14
  return _super.apply(this, arguments);
22
15
  }
23
-
24
16
  return _createClass(MicroAppBase);
25
17
  }(React.Component);
26
-
27
18
  export { MicroAppBase as default };
@@ -1,18 +1,16 @@
1
1
  var lastApp;
2
2
  var lastTime = 0;
3
3
  var min = 1000;
4
+
4
5
  /**
5
6
  * 计算初始化次数,并提示重复加载的应用
6
7
  * @param appId string
7
8
  */
8
-
9
9
  export var countRegister = function countRegister(appId) {
10
10
  var nowTime = Date.now();
11
-
12
11
  if (lastApp === appId && lastTime && nowTime - lastTime < min) {
13
12
  console.warn("[@alicloud/alfa-react] ".concat(appId, " \u91CD\u590D\u52A0\u8F7D\uFF0C\u8BF7\u68C0\u67E5\u4F60\u7684\u4EE3\u7801\u3002\u8BF7\u5728\u51FD\u6570\u7EC4\u4EF6\u4E2D\u4F7F\u7528 useAlfaApp \u6216 useAlfaWidget \u65B9\u6CD5\u3002"));
14
13
  }
15
-
16
14
  lastApp = appId;
17
15
  lastTime = nowTime;
18
16
  };
@@ -1,40 +1,34 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
-
5
4
  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; }
6
-
7
5
  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; }
8
-
9
6
  import md5 from 'crypto-js/md5';
7
+
10
8
  /**
11
9
  * transform
12
10
  * @param features
13
11
  */
14
-
15
12
  var processFeatures = function processFeatures(features) {
16
13
  if (!features) return {};
17
14
  return Object.keys(features).reduce(function (newFeatures, key) {
18
15
  var _ALIYUN_CONSOLE_CONFI;
19
-
20
16
  var feature = features === null || features === void 0 ? void 0 : features[key];
21
17
  if (!feature) return newFeatures;
22
18
  var uid = ((_ALIYUN_CONSOLE_CONFI = window.ALIYUN_CONSOLE_CONFIG) === null || _ALIYUN_CONSOLE_CONFI === void 0 ? void 0 : _ALIYUN_CONSOLE_CONFI.MAIN_ACCOUNT_PK) || '';
23
19
  var md5Uid = md5(uid).toString();
24
20
  var enableBlockList = feature.enableBlockList,
25
- enableSampling = feature.enableSampling,
26
- enableWhiteList = feature.enableWhiteList,
27
- sampling = feature.sampling,
28
- blockList = feature.blockList,
29
- whiteList = feature.whiteList;
30
-
21
+ enableSampling = feature.enableSampling,
22
+ enableWhiteList = feature.enableWhiteList,
23
+ sampling = feature.sampling,
24
+ blockList = feature.blockList,
25
+ whiteList = feature.whiteList;
31
26
  if (enableBlockList && blockList !== null && blockList !== void 0 && blockList.includes(md5Uid)) {
32
27
  newFeatures[key] = false;
33
28
  } else if (enableWhiteList && whiteList !== null && whiteList !== void 0 && whiteList.includes(md5Uid)) {
34
29
  newFeatures[key] = true;
35
30
  } else if (enableSampling) {
36
31
  var gray = uid.substring(uid.length - 2);
37
-
38
32
  if (Number(gray) >= (sampling !== null && sampling !== void 0 ? sampling : 0) * 100 || sampling === 0) {
39
33
  newFeatures[key] = false;
40
34
  } else {
@@ -43,29 +37,24 @@ var processFeatures = function processFeatures(features) {
43
37
  } else {
44
38
  newFeatures[key] = false;
45
39
  }
46
-
47
40
  return newFeatures;
48
41
  }, {});
49
42
  };
50
-
51
43
  var getRegions = function getRegions(regions) {
52
44
  if (!Array.isArray(regions) && regions.region) {
53
45
  return regions.region || [];
54
46
  }
55
-
56
47
  return [];
57
48
  };
58
-
59
49
  var processChannelFeatures = function processChannelFeatures(allChannelFeatures, channel) {
60
50
  var channelFeatures = allChannelFeatures === null || allChannelFeatures === void 0 ? void 0 : allChannelFeatures[channel];
61
51
  if (!channelFeatures) return {};
62
52
  return Object.keys(channelFeatures).reduce(function (newChannelFeatures, key) {
63
53
  var channelFeature = channelFeatures[key];
64
54
  if (!channelFeature) return newChannelFeatures;
65
-
66
55
  if (newChannelFeatures) {
67
56
  var status = channelFeature.status,
68
- attribute = channelFeature.attribute;
57
+ attribute = channelFeature.attribute;
69
58
  newChannelFeatures[key] = {
70
59
  status: status,
71
60
  attribute: _objectSpread(_objectSpread({}, attribute), {}, {
@@ -73,14 +62,11 @@ var processChannelFeatures = function processChannelFeatures(allChannelFeatures,
73
62
  })
74
63
  };
75
64
  }
76
-
77
65
  return newChannelFeatures;
78
66
  }, {});
79
67
  };
80
-
81
68
  var mergeConfigDataWithConsoleConfig = function mergeConfigDataWithConsoleConfig(configData, consoleConfig) {
82
69
  var _window, _window$ALIYUN_CONSOL, _configData$ALL_CHANN;
83
-
84
70
  var channel = ((_window = window) === null || _window === void 0 ? void 0 : (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.CHANNEL) || 'OFFICIAL';
85
71
  var channelLinks = (_configData$ALL_CHANN = configData.ALL_CHANNEL_LINKS) === null || _configData$ALL_CHANN === void 0 ? void 0 : _configData$ALL_CHANN[channel];
86
72
  var channelFeatures = configData.ALL_CHANNEL_FEATURE_STATUS;
@@ -91,23 +77,18 @@ var mergeConfigDataWithConsoleConfig = function mergeConfigDataWithConsoleConfig
91
77
  FEATURE_STATUS: _objectSpread(_objectSpread({}, consoleConfig === null || consoleConfig === void 0 ? void 0 : consoleConfig.FEATURE_STATUS), processFeatures(features))
92
78
  });
93
79
  };
94
-
95
80
  export var getConsoleConfig = /*#__PURE__*/function () {
96
81
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(configData, consoleConfig) {
97
82
  return _regeneratorRuntime.wrap(function _callee$(_context) {
98
- while (1) {
99
- switch (_context.prev = _context.next) {
100
- case 0:
101
- return _context.abrupt("return", mergeConfigDataWithConsoleConfig(configData, consoleConfig));
102
-
103
- case 1:
104
- case "end":
105
- return _context.stop();
106
- }
83
+ while (1) switch (_context.prev = _context.next) {
84
+ case 0:
85
+ return _context.abrupt("return", mergeConfigDataWithConsoleConfig(configData, consoleConfig));
86
+ case 1:
87
+ case "end":
88
+ return _context.stop();
107
89
  }
108
90
  }, _callee);
109
91
  }));
110
-
111
92
  return function getConsoleConfig(_x, _x2) {
112
93
  return _ref.apply(this, arguments);
113
94
  };
@@ -1,27 +1,20 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
-
5
4
  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; }
6
-
7
5
  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; }
8
-
9
6
  export var getConsoleGlobal = /*#__PURE__*/function () {
10
7
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(configData, global) {
11
8
  return _regeneratorRuntime.wrap(function _callee$(_context) {
12
- while (1) {
13
- switch (_context.prev = _context.next) {
14
- case 0:
15
- return _context.abrupt("return", _objectSpread(_objectSpread({}, global), configData === null || configData === void 0 ? void 0 : configData.GLOBAL_DATA));
16
-
17
- case 1:
18
- case "end":
19
- return _context.stop();
20
- }
9
+ while (1) switch (_context.prev = _context.next) {
10
+ case 0:
11
+ return _context.abrupt("return", _objectSpread(_objectSpread({}, global), configData === null || configData === void 0 ? void 0 : configData.GLOBAL_DATA));
12
+ case 1:
13
+ case "end":
14
+ return _context.stop();
21
15
  }
22
16
  }, _callee);
23
17
  }));
24
-
25
18
  return function getConsoleGlobal(_x, _x2) {
26
19
  return _ref.apply(this, arguments);
27
20
  };
package/es/utils/index.js CHANGED
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * kernel 会为沙箱 context 注入 __IS_CONSOLE_OS_CONTEXT__
3
3
  */
4
+
4
5
  export var normalizeName = function normalizeName(name) {
5
6
  return name.replace(/@/g, '').replace(/\//g, '-');
6
7
  };
8
+
7
9
  /**
8
10
  * 判断是否在沙箱环境中运行
9
11
  */
10
-
11
12
  export var isOsContext = function isOsContext() {
12
13
  try {
13
14
  return context.__IS_CONSOLE_OS_CONTEXT__;
package/es/version.js CHANGED
@@ -1 +1 @@
1
- export var version = '1.4.40-alpha.0';
1
+ export var version = '1.5.0-alpha.0';
@@ -3,27 +3,20 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
-
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
8
  import { EventEmitter } from 'events';
12
-
13
9
  var WidgetEventEmitter = /*#__PURE__*/function (_EventEmitter) {
14
10
  _inherits(WidgetEventEmitter, _EventEmitter);
15
-
16
11
  var _super = _createSuper(WidgetEventEmitter);
17
-
18
12
  function WidgetEventEmitter() {
19
13
  _classCallCheck(this, WidgetEventEmitter);
20
-
21
14
  return _super.apply(this, arguments);
22
15
  }
23
-
24
16
  _createClass(WidgetEventEmitter, [{
25
17
  key: "refersh",
26
- value: // Compatible with the old api, this may get removed at sometime later.
18
+ value:
19
+ // Compatible with the old api, this may get removed at sometime later.
27
20
  function refersh(widgetId) {
28
21
  return this.emit("".concat(widgetId, ":REFRESH"));
29
22
  }
@@ -33,8 +26,6 @@ var WidgetEventEmitter = /*#__PURE__*/function (_EventEmitter) {
33
26
  return this.emit("".concat(widgetId, ":REFRESH"));
34
27
  }
35
28
  }]);
36
-
37
29
  return WidgetEventEmitter;
38
30
  }(EventEmitter);
39
-
40
31
  export default new WidgetEventEmitter();
package/es/widget/env.js CHANGED
@@ -52,11 +52,9 @@ export var DIS_ENV = {
52
52
  };
53
53
  export var getConsoleEnv = function getConsoleEnv() {
54
54
  var _window, _window$ALIYUN_CONSOL;
55
-
56
55
  if (process.env.NODE_ENV === 'development') {
57
56
  return 'local';
58
- } // @ts-ignore
59
-
60
-
57
+ }
58
+ // @ts-ignore
61
59
  return ((_window = window) === null || _window === void 0 ? void 0 : (_window$ALIYUN_CONSOL = _window.ALIYUN_CONSOLE_CONFIG) === null || _window$ALIYUN_CONSOL === void 0 ? void 0 : _window$ALIYUN_CONSOL.fEnv) || 'prod';
62
60
  };
@@ -8,36 +8,28 @@ export var getWidgetConfigById = /*#__PURE__*/function () {
8
8
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(option) {
9
9
  var env, resp;
10
10
  return _regeneratorRuntime.wrap(function _callee$(_context) {
11
- while (1) {
12
- switch (_context.prev = _context.next) {
13
- case 0:
14
- env = ENV[option.env || getConsoleEnv()];
15
-
16
- if (cachedConfig[option.name]) {
17
- _context.next = 6;
18
- break;
19
- }
20
-
21
- _context.next = 4;
22
- return request.get(template(env.configUrl)({
23
- id: option.name
24
- }));
25
-
26
- case 4:
27
- resp = _context.sent;
28
- cachedConfig[option.name] = resp === null || resp === void 0 ? void 0 : resp.data;
29
-
30
- case 6:
31
- return _context.abrupt("return", cachedConfig[option.name]);
32
-
33
- case 7:
34
- case "end":
35
- return _context.stop();
36
- }
11
+ while (1) switch (_context.prev = _context.next) {
12
+ case 0:
13
+ env = ENV[option.env || getConsoleEnv()];
14
+ if (cachedConfig[option.name]) {
15
+ _context.next = 6;
16
+ break;
17
+ }
18
+ _context.next = 4;
19
+ return request.get(template(env.configUrl)({
20
+ id: option.name
21
+ }));
22
+ case 4:
23
+ resp = _context.sent;
24
+ cachedConfig[option.name] = resp === null || resp === void 0 ? void 0 : resp.data;
25
+ case 6:
26
+ return _context.abrupt("return", cachedConfig[option.name]);
27
+ case 7:
28
+ case "end":
29
+ return _context.stop();
37
30
  }
38
31
  }, _callee);
39
32
  }));
40
-
41
33
  return function getWidgetConfigById(_x) {
42
34
  return _ref.apply(this, arguments);
43
35
  };