@alicloud/alfa-react 1.7.1-alpha.3 → 1.7.1-beta.1

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 (39) hide show
  1. package/es/createAlfaApp.js +1 -1
  2. package/es/createAlfaWidget.js +3 -3
  3. package/es/createApplication.js +40 -30
  4. package/es/loaders/beforeLoadHook.js +10 -10
  5. package/es/loaders/beforeResolveHook.js +4 -4
  6. package/es/utils/getConsoleConfig.js +1 -1
  7. package/es/utils/getConsoleGlobal.js +1 -1
  8. package/es/version.js +1 -1
  9. package/es/widget/getWidgetConfigById.js +6 -6
  10. package/es/widget/getWidgetDeps.js +23 -23
  11. package/es/widget/getWidgetVersionById.js +17 -17
  12. package/es/widget.js +10 -10
  13. package/lib/components/Loading/Paragraph.js +1 -2
  14. package/lib/components/Loading/Skeleton.js +1 -2
  15. package/lib/components/Loading/Title.js +1 -2
  16. package/lib/createAlfaApp.js +2 -3
  17. package/lib/createAlfaWidget.js +4 -5
  18. package/lib/createApplication.js +41 -32
  19. package/lib/index.js +1 -2
  20. package/lib/loaders/beforeLoadHook.js +10 -10
  21. package/lib/loaders/beforeResolveHook.js +4 -4
  22. package/lib/utils/getConsoleConfig.js +1 -1
  23. package/lib/utils/getConsoleGlobal.js +1 -1
  24. package/lib/version.js +1 -1
  25. package/lib/widget/getWidgetConfigById.js +6 -6
  26. package/lib/widget/getWidgetDeps.js +24 -25
  27. package/lib/widget/getWidgetVersionById.js +17 -17
  28. package/lib/widget.js +11 -12
  29. package/package.json +7 -5
  30. package/scripts/postinstall.js +95 -0
  31. package/types/types/index.d.ts +5 -2
  32. package/types/utils/getConsoleConfig.d.ts +1 -0
  33. package/types/version.d.ts +1 -1
  34. package/es/hooks/beforeLoadHook.js +0 -82
  35. package/es/hooks/beforeResolveHook.js +0 -41
  36. package/lib/hooks/beforeLoadHook.js +0 -90
  37. package/lib/hooks/beforeResolveHook.js +0 -48
  38. package/types/hooks/beforeLoadHook.d.ts +0 -7
  39. package/types/hooks/beforeResolveHook.d.ts +0 -3
package/lib/widget.js CHANGED
@@ -16,14 +16,13 @@ var _index = require("./widget/index");
16
16
  var _ErrorBoundary = _interopRequireDefault(require("./components/ErrorBoundary"));
17
17
  var _Loading = _interopRequireDefault(require("./components/Loading"));
18
18
  var _utils = require("./utils");
19
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
21
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
22
  function createCWSWidget(option) {
24
23
  var AlfaWidget = /*#__PURE__*/(0, _react.lazy)(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
25
24
  var url, config, _yield$getWidgetVersi, version, entryUrl, deps;
26
- return _regenerator.default.wrap(function _callee$(_context) {
25
+ return _regenerator.default.wrap(function (_context) {
27
26
  while (1) switch (_context.prev = _context.next) {
28
27
  case 0:
29
28
  url = option.url;
@@ -34,26 +33,26 @@ function createCWSWidget(option) {
34
33
  conf: {}
35
34
  };
36
35
  if (url) {
37
- _context.next = 12;
36
+ _context.next = 3;
38
37
  break;
39
38
  }
40
- _context.next = 5;
39
+ _context.next = 1;
41
40
  return (0, _index.getWidgetVersionById)(option);
42
- case 5:
41
+ case 1:
43
42
  _yield$getWidgetVersi = _context.sent;
44
43
  version = _yield$getWidgetVersi.version;
45
44
  entryUrl = _yield$getWidgetVersi.entryUrl;
46
45
  url = entryUrl;
47
- _context.next = 11;
46
+ _context.next = 2;
48
47
  return (0, _index.getWidgetConfigById)(_objectSpread(_objectSpread({}, option), {}, {
49
48
  version: version
50
49
  }));
51
- case 11:
50
+ case 2:
52
51
  config = _context.sent;
53
- case 12:
54
- _context.next = 14;
52
+ case 3:
53
+ _context.next = 4;
55
54
  return (0, _index.getWidgetDeps)(config, option);
56
- case 14:
55
+ case 4:
57
56
  deps = _context.sent;
58
57
  return _context.abrupt("return", (0, _consoleOsLoader.loadBundle)({
59
58
  id: (0, _utils.normalizeName)(option.name),
@@ -67,7 +66,7 @@ function createCWSWidget(option) {
67
66
  document: document
68
67
  }
69
68
  }));
70
- case 16:
69
+ case 5:
71
70
  case "end":
72
71
  return _context.stop();
73
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/alfa-react",
3
- "version": "1.7.1-alpha.3",
3
+ "version": "1.7.1-beta.1",
4
4
  "description": "Alfa Framework (React Version)",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -52,16 +52,17 @@
52
52
  "lodash-es": "^4.17.21",
53
53
  "prop-types": "^15.8.1",
54
54
  "react-lazyload": "^3.2.1",
55
- "@alicloud/console-os-loader": "^1.4.45-alpha.1",
56
- "@alicloud/alfa-core": "^1.5.0-alpha.2"
55
+ "@alicloud/console-os-loader": "^1.4.45",
56
+ "@alicloud/alfa-core": "^1.5.7"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "react": ">=16.0.0",
60
60
  "react-dom": ">=16.0.0"
61
61
  },
62
62
  "scripts": {
63
+ "build": "npm run version && npm run babel && npm run babel:esm && npm run types",
63
64
  "pub": "pnpm publish",
64
- "build": "breezr build --engine webpack",
65
+ "build:webpack": "breezr build --engine webpack",
65
66
  "babel": "breezr build --engine babel",
66
67
  "babel:esm": "breezr build --engine babel --es-module",
67
68
  "types": "tsc --emitDeclarationOnly -d --declarationDir ./types",
@@ -69,6 +70,7 @@
69
70
  "clean": "rm -rf lib es dist types yarn.lock",
70
71
  "start": "storybook dev -p 6006",
71
72
  "precommit": "npm run version",
72
- "version": "node -p \"'export const version = \\'' + require('./package.json').version + '\\';'\" > src/version.ts && git add src/version.ts"
73
+ "version": "node -p \"'export const version = \\'' + require('./package.json').version + '\\';'\" > src/version.ts && git add src/version.ts",
74
+ "postinstall": "node ./scripts/postinstall.js"
73
75
  }
74
76
  }
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require("path");
4
+ const https = require("https");
5
+
6
+ (async () => {
7
+ try {
8
+ if (typeof process === "undefined" || typeof process.env === "undefined") {
9
+ return;
10
+ }
11
+
12
+ const { BUILD_ENV, INIT_CWD, npm_config_user_agent } = process.env;
13
+ if (BUILD_ENV !== "cloud" || INIT_CWD === process.cwd()) {
14
+ return;
15
+ }
16
+
17
+ const envKeys = [
18
+ "BUILD_GIT_GROUP",
19
+ "BUILD_GIT_PROJECT",
20
+ "BUILD_GIT_BRANCH",
21
+ "BUILD_GIT_COMMITID",
22
+ "BUILD_BUILDER_DIR",
23
+ "BUILD_USER",
24
+ "BUILD_TASK_ID",
25
+ "npm_package_name",
26
+ "npm_package_version",
27
+ "NODE_VERSION",
28
+ "CLOUDBUILD_ENV",
29
+ "CLOUDBUILD_RUNNER_VERSION",
30
+ "BUILD_ENV",
31
+ ];
32
+
33
+ const logEntry = {};
34
+ envKeys.forEach((key) => {
35
+ if (process.env[key]) {
36
+ logEntry[key] = process.env[key];
37
+ }
38
+ });
39
+
40
+ let rootPackage = null;
41
+ try {
42
+ const rootPackagePath = path.resolve(
43
+ INIT_CWD || process.cwd(),
44
+ "package.json"
45
+ );
46
+ rootPackage = require(rootPackagePath);
47
+ } catch (err) {
48
+ // Skip if error occurs
49
+ }
50
+
51
+ let currentPackage = null;
52
+ try {
53
+ const currentPackagePath = path.resolve(__dirname, "../package.json");
54
+ currentPackage = require(currentPackagePath);
55
+ } catch (err) {
56
+ // Skip if error occurs
57
+ }
58
+
59
+ if (rootPackage) {
60
+ logEntry.root_package = JSON.stringify(rootPackage);
61
+ }
62
+ if (currentPackage) {
63
+ logEntry.name = currentPackage.name;
64
+ logEntry.version = currentPackage.version;
65
+ }
66
+
67
+ const payload = {
68
+ __topic__: "package_postinstall",
69
+ __logs__: [logEntry],
70
+ };
71
+
72
+ const body = JSON.stringify(payload);
73
+ const options = {
74
+ hostname: "alfa.log-global.aliyuncs.com",
75
+ path: "/logstores/package-usage-telemetry/track",
76
+ method: "POST",
77
+ headers: {
78
+ "Content-Type": "application/json",
79
+ "x-log-apiversion": "0.6.0",
80
+ "user-agent": npm_config_user_agent || "",
81
+ },
82
+ timeout: 5000,
83
+ };
84
+
85
+ const req = https.request(options, (res) => {
86
+ res.on("data", () => {});
87
+ });
88
+
89
+ req.on("error", () => {});
90
+ req.write(body);
91
+ req.end();
92
+ } catch (err) {
93
+ // Catch all errors and ignore
94
+ }
95
+ })();
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
- import React from 'React';
1
+ import React from 'react';
3
2
  import { createMicroApp, IAppConfig } from '@alicloud/alfa-core';
4
3
  export interface AlfaVersion {
5
4
  entry: string;
@@ -74,6 +73,10 @@ export interface AlfaFactoryOption extends IAppConfig {
74
73
  */
75
74
  scrollContainer?: string | Element | undefined;
76
75
  };
76
+ /**
77
+ * 强制上报日志
78
+ */
79
+ forceLog?: boolean;
77
80
  }
78
81
  type ThenArg<T> = T extends PromiseLike<infer U> ? U : T;
79
82
  export type MicroApplication = ThenArg<ReturnType<typeof createMicroApp>>;
@@ -32,4 +32,5 @@ export declare const getConsoleConfig: (configData: AlfaConfig, consoleConfig: a
32
32
  portalType?: string | undefined;
33
33
  MAIN_ACCOUNT_PK?: string | undefined;
34
34
  CURRENT_PK?: string | undefined;
35
+ APP_ID?: string | undefined;
35
36
  }>;
@@ -1 +1 @@
1
- export declare const version = "1.7.1-alpha.3";
1
+ export declare const version = "1.7.1-beta.1";
@@ -1,82 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
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; }
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; }
7
- import { getConfig, getI18nMessages } from '@alicloud/alfa-core';
8
- import { getConsoleConfig } from '../utils/getConsoleConfig';
9
- import { getConsoleGlobal } from '../utils/getConsoleGlobal';
10
- // inject consoleConfig & locales after load
11
- function afterLoadHook(_x) {
12
- return _afterLoadHook.apply(this, arguments);
13
- }
14
- function _afterLoadHook() {
15
- _afterLoadHook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
16
- var app, logger, sandbox, dynamicConfig, channel, defaultConsoleConfig, defaultConsoleGlobal, CONFIG_START_TIME, CONFIG_END_TIME, configData, _yield$Promise$all, _yield$Promise$all2, consoleConfig, consoleGlobal, messages, i18nMessages, overrides;
17
- return _regeneratorRuntime.wrap(function _callee$(_context) {
18
- while (1) switch (_context.prev = _context.next) {
19
- case 0:
20
- app = appConfig.app, logger = appConfig.logger, sandbox = appConfig.sandbox, dynamicConfig = appConfig.dynamicConfig, channel = appConfig.channel;
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;
27
- break;
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, channel), 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;
66
- });
67
- }
68
- (logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
69
- CONFIG_START_TIME: CONFIG_START_TIME,
70
- CONFIG_END_TIME: CONFIG_END_TIME,
71
- COST: CONFIG_END_TIME - CONFIG_START_TIME
72
- });
73
- return _context.abrupt("return", appConfig);
74
- case 26:
75
- case "end":
76
- return _context.stop();
77
- }
78
- }, _callee);
79
- }));
80
- return _afterLoadHook.apply(this, arguments);
81
- }
82
- export default afterLoadHook;
@@ -1,41 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { getManifest } from '@alicloud/alfa-core';
4
- import { version as LOADER_VERSION } from '../version';
5
-
6
- // get manifest before resolve
7
- // normalize name
8
- function beforeResolveHook(_x) {
9
- return _beforeResolveHook.apply(this, arguments);
10
- }
11
- function _beforeResolveHook() {
12
- _beforeResolveHook = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(appConfig) {
13
- var logger, START_TIME, MANIFEST_START_TIME, resolvedManifest, MANIFEST_END_TIME;
14
- return _regeneratorRuntime.wrap(function _callee$(_context) {
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();
36
- }
37
- }, _callee);
38
- }));
39
- return _beforeResolveHook.apply(this, arguments);
40
- }
41
- export default beforeResolveHook;
@@ -1,90 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
- var _alfaCore = require("@alicloud/alfa-core");
13
- var _getConsoleConfig = require("../utils/getConsoleConfig");
14
- var _getConsoleGlobal = require("../utils/getConsoleGlobal");
15
- 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; }
16
- 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) { (0, _defineProperty2.default)(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; }
17
- // inject consoleConfig & locales after load
18
- function afterLoadHook(_x) {
19
- return _afterLoadHook.apply(this, arguments);
20
- }
21
- function _afterLoadHook() {
22
- _afterLoadHook = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(appConfig) {
23
- var app, logger, sandbox, dynamicConfig, channel, defaultConsoleConfig, defaultConsoleGlobal, CONFIG_START_TIME, CONFIG_END_TIME, configData, _yield$Promise$all, _yield$Promise$all2, consoleConfig, consoleGlobal, messages, i18nMessages, overrides;
24
- return _regenerator.default.wrap(function _callee$(_context) {
25
- while (1) switch (_context.prev = _context.next) {
26
- case 0:
27
- app = appConfig.app, logger = appConfig.logger, sandbox = appConfig.sandbox, dynamicConfig = appConfig.dynamicConfig, channel = appConfig.channel;
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
- if (!dynamicConfig) {
33
- _context.next = 21;
34
- break;
35
- }
36
- _context.next = 8;
37
- return (0, _alfaCore.getConfig)(appConfig);
38
- case 8:
39
- configData = _context.sent;
40
- _context.next = 11;
41
- return Promise.all([(0, _getConsoleConfig.getConsoleConfig)(configData, defaultConsoleConfig, channel), (0, _getConsoleGlobal.getConsoleGlobal)(configData, defaultConsoleGlobal), (0, _alfaCore.getI18nMessages)(appConfig)]);
42
- case 11:
43
- _yield$Promise$all = _context.sent;
44
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 3);
45
- consoleConfig = _yield$Promise$all2[0];
46
- consoleGlobal = _yield$Promise$all2[1];
47
- messages = _yield$Promise$all2[2];
48
- CONFIG_END_TIME = Date.now();
49
- i18nMessages = _objectSpread(_objectSpread({}, window.ALIYUN_CONSOLE_I18N_MESSAGE), messages); // inject global variables when sandbox is valid
50
- if (app !== null && app !== void 0 && app.context && !(sandbox !== null && sandbox !== void 0 && sandbox.disable)) {
51
- app.context.window.ALIYUN_CONSOLE_CONFIG = consoleConfig;
52
- app.context.window.ALIYUN_CONSOLE_GLOBAL = consoleGlobal;
53
- app.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = i18nMessages;
54
- app.context.window.ALIYUN_WIND_MESSAGE = window.ALIYUN_WIND_MESSAGE;
55
- }
56
- _context.next = 22;
57
- break;
58
- case 21:
59
- if (app !== null && app !== void 0 && app.context && !(sandbox !== null && sandbox !== void 0 && sandbox.disable)) {
60
- app.context.window.ALIYUN_CONSOLE_CONFIG = defaultConsoleConfig;
61
- app.context.window.ALIYUN_CONSOLE_GLOBAL = defaultConsoleGlobal;
62
- app.context.window.ALIYUN_CONSOLE_I18N_MESSAGE = window.ALIYUN_CONSOLE_I18N_MESSAGE;
63
- app.context.window.ALIYUN_WIND_MESSAGE = window.ALIYUN_WIND_MESSAGE;
64
- }
65
- case 22:
66
- overrides = sandbox === null || sandbox === void 0 ? void 0 : sandbox.overrideGlobalVars;
67
- if (overrides && app) {
68
- Object.entries(overrides).forEach(function (_ref) {
69
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
70
- key = _ref2[0],
71
- value = _ref2[1];
72
- app.context.window[key] = value;
73
- });
74
- }
75
- (logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
76
- CONFIG_START_TIME: CONFIG_START_TIME,
77
- CONFIG_END_TIME: CONFIG_END_TIME,
78
- COST: CONFIG_END_TIME - CONFIG_START_TIME
79
- });
80
- return _context.abrupt("return", appConfig);
81
- case 26:
82
- case "end":
83
- return _context.stop();
84
- }
85
- }, _callee);
86
- }));
87
- return _afterLoadHook.apply(this, arguments);
88
- }
89
- var _default = afterLoadHook;
90
- exports.default = _default;
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _alfaCore = require("@alicloud/alfa-core");
11
- var _version = require("../version");
12
- // get manifest before resolve
13
- // normalize name
14
- function beforeResolveHook(_x) {
15
- return _beforeResolveHook.apply(this, arguments);
16
- }
17
- function _beforeResolveHook() {
18
- _beforeResolveHook = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(appConfig) {
19
- var logger, START_TIME, MANIFEST_START_TIME, resolvedManifest, MANIFEST_END_TIME;
20
- return _regenerator.default.wrap(function _callee$(_context) {
21
- while (1) switch (_context.prev = _context.next) {
22
- case 0:
23
- logger = appConfig.logger;
24
- START_TIME = Date.now();
25
- MANIFEST_START_TIME = Date.now();
26
- _context.next = 5;
27
- return (0, _alfaCore.getManifest)(appConfig);
28
- case 5:
29
- resolvedManifest = _context.sent;
30
- MANIFEST_END_TIME = Date.now();
31
- (logger === null || logger === void 0 ? void 0 : logger.record) && logger.record({
32
- LOADER_VERSION: _version.version,
33
- START_TIME: START_TIME,
34
- MANIFEST_START_TIME: MANIFEST_START_TIME,
35
- MANIFEST_END_TIME: MANIFEST_END_TIME
36
- });
37
- appConfig.manifest = resolvedManifest;
38
- return _context.abrupt("return", appConfig);
39
- case 10:
40
- case "end":
41
- return _context.stop();
42
- }
43
- }, _callee);
44
- }));
45
- return _beforeResolveHook.apply(this, arguments);
46
- }
47
- var _default = beforeResolveHook;
48
- exports.default = _default;
@@ -1,7 +0,0 @@
1
- import { IAppConfig } from '@alicloud/alfa-core';
2
- declare function afterLoadHook(appConfig: IAppConfig & {
3
- channel?: string;
4
- }): Promise<IAppConfig<any> & {
5
- channel?: string | undefined;
6
- }>;
7
- export default afterLoadHook;
@@ -1,3 +0,0 @@
1
- import { IAppConfig } from '@alicloud/alfa-core';
2
- declare function beforeResolveHook(appConfig: IAppConfig): Promise<IAppConfig<any>>;
3
- export default beforeResolveHook;