@alicloud/alfa-core 1.3.0-canary.7 → 1.3.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/breezr.config.js +3 -3
- package/dist/index.js +4 -4
- package/es/base.js +82 -27
- package/es/createMicroApp.js +3 -2
- package/es/index.js +8 -5
- package/es/types/index.js +5 -0
- package/es/utils/getAlfaConfig.js +1 -1
- package/es/utils/getAlfaManifest.js +21 -15
- package/es/utils/hookManager.js +2 -1
- package/es/utils/logger.js +91 -0
- package/lib/base.d.ts +7 -1
- package/lib/base.js +82 -26
- package/lib/createMicroApp.d.ts +1 -1
- package/lib/createMicroApp.js +2 -1
- package/lib/index.d.ts +8 -5
- package/lib/index.js +78 -23
- package/lib/types/index.d.ts +10 -7
- package/lib/types/index.js +17 -1
- package/lib/utils/getAlfaConfig.js +1 -1
- package/lib/utils/getAlfaManifest.js +21 -15
- package/lib/utils/hookManager.d.ts +1 -1
- package/lib/utils/hookManager.js +2 -1
- package/lib/utils/index.d.ts +2 -2
- package/lib/utils/index.js +1 -1
- package/lib/utils/logger.d.ts +20 -0
- package/lib/utils/logger.js +100 -0
- package/package.json +4 -4
- package/es/createIsomorphicMicroApp.js +0 -61
- package/es/env.js +0 -36
- package/es/resolveAlfaConfig.js +0 -74
- package/es/resolveAlfaManifest.js +0 -46
- package/es/resolveAlfaRelease.js +0 -29
- package/es/types.js +0 -0
- package/es/utils.js +0 -43
- package/lib/createIsomorphicMicroApp.d.ts +0 -4
- package/lib/createIsomorphicMicroApp.js +0 -78
- package/lib/env.d.ts +0 -3
- package/lib/env.js +0 -46
- package/lib/resolveAlfaConfig.d.ts +0 -7
- package/lib/resolveAlfaConfig.js +0 -89
- package/lib/resolveAlfaManifest.d.ts +0 -3
- package/lib/resolveAlfaManifest.js +0 -64
- package/lib/types.d.ts +0 -61
- package/lib/types.js +0 -1
- package/lib/utils.d.ts +0 -14
- package/lib/utils.js +0 -67
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import axios from 'axios';
|
|
4
|
-
import { resolveReleaseUrl } from './utils';
|
|
5
|
-
export var getManifest = /*#__PURE__*/function () {
|
|
6
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(option) {
|
|
7
|
-
var resp, releaseConfig;
|
|
8
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9
|
-
while (1) {
|
|
10
|
-
switch (_context.prev = _context.next) {
|
|
11
|
-
case 0:
|
|
12
|
-
_context.next = 2;
|
|
13
|
-
return axios.get(resolveReleaseUrl(option));
|
|
14
|
-
|
|
15
|
-
case 2:
|
|
16
|
-
resp = _context.sent;
|
|
17
|
-
releaseConfig = resp.data;
|
|
18
|
-
return _context.abrupt("return", parseManifestFromRelease(releaseConfig, option));
|
|
19
|
-
|
|
20
|
-
case 5:
|
|
21
|
-
case "end":
|
|
22
|
-
return _context.stop();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}, _callee);
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
return function getManifest(_x) {
|
|
29
|
-
return _ref.apply(this, arguments);
|
|
30
|
-
};
|
|
31
|
-
}();
|
|
32
|
-
export var parseManifestFromRelease = function parseManifestFromRelease(releaseConfig, option) {
|
|
33
|
-
if (!option.version) {
|
|
34
|
-
var _releaseConfig$distT;
|
|
35
|
-
|
|
36
|
-
option.version = (_releaseConfig$distT = releaseConfig["dist-tags"]) === null || _releaseConfig$distT === void 0 ? void 0 : _releaseConfig$distT.latest;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var configByVersion = releaseConfig.versions[option.version];
|
|
40
|
-
|
|
41
|
-
if (!configByVersion) {
|
|
42
|
-
throw new Error("".concat(option.name, "@").concat(option.version, " is not found, please check you release."));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return releaseConfig.versions[option.version].entry;
|
|
46
|
-
};
|
package/es/resolveAlfaRelease.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import axios from 'axios';
|
|
4
|
-
import { resolveReleaseUrl } from './utils';
|
|
5
|
-
export var getRelease = /*#__PURE__*/function () {
|
|
6
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(option) {
|
|
7
|
-
var resp;
|
|
8
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9
|
-
while (1) {
|
|
10
|
-
switch (_context.prev = _context.next) {
|
|
11
|
-
case 0:
|
|
12
|
-
_context.next = 2;
|
|
13
|
-
return axios.get(resolveReleaseUrl(option));
|
|
14
|
-
|
|
15
|
-
case 2:
|
|
16
|
-
resp = _context.sent;
|
|
17
|
-
|
|
18
|
-
case 3:
|
|
19
|
-
case "end":
|
|
20
|
-
return _context.stop();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}, _callee);
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
return function getRelease(_x) {
|
|
27
|
-
return _ref.apply(this, arguments);
|
|
28
|
-
};
|
|
29
|
-
}();
|
package/es/types.js
DELETED
|
File without changes
|
package/es/utils.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import template from 'lodash/template';
|
|
2
|
-
import { ENV, getConsoleEnv } from './env';
|
|
3
|
-
export var resolveReleaseUrl = function resolveReleaseUrl(option) {
|
|
4
|
-
// 如果没找环境到 fallback 到 prod
|
|
5
|
-
var env = ENV[option.env || getConsoleEnv()] || ENV.prod;
|
|
6
|
-
return template(env.releaseUrl)({
|
|
7
|
-
appId: option.name
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export var resolveConfigUrl = function resolveConfigUrl(option) {
|
|
11
|
-
// 如果没找环境到 fallback 到 prod
|
|
12
|
-
var env = ENV[option.env || getConsoleEnv()] || ENV.prod;
|
|
13
|
-
return template(env.configUrl)({
|
|
14
|
-
appId: option.name
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
export var getURL = function getURL(appConfig) {
|
|
18
|
-
var entry = appConfig.entry;
|
|
19
|
-
var url = '';
|
|
20
|
-
|
|
21
|
-
if (typeof entry === 'string') {
|
|
22
|
-
url = entry;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return url;
|
|
26
|
-
};
|
|
27
|
-
export var getManifest = function getManifest(appConfig) {
|
|
28
|
-
// 定义了 entry 时,优先从 entry 生成 manifest
|
|
29
|
-
if (appConfig.entry && typeof appConfig.entry !== 'string') {
|
|
30
|
-
return {
|
|
31
|
-
name: appConfig.name,
|
|
32
|
-
resources: {},
|
|
33
|
-
entrypoints: {
|
|
34
|
-
index: {
|
|
35
|
-
js: appConfig.entry.scripts,
|
|
36
|
-
css: appConfig.entry.styles
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return appConfig.manifest;
|
|
43
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { IIsomorphicEnvironment } from '@alicloud/console-os-kernal';
|
|
2
|
-
import { IAppConfig, IOptions } from './types';
|
|
3
|
-
export declare const createIsomorphicMicroApp: <T>(appConfig: IAppConfig<T>, options?: IOptions<T>) => import("@alicloud/console-os-kernal/lib/server/Application").Application;
|
|
4
|
-
export declare const renderToString: <T>(props: IAppConfig<T>, env: IIsomorphicEnvironment) => any;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.renderToString = exports.createIsomorphicMicroApp = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _consoleOsKernal = require("@alicloud/console-os-kernal");
|
|
13
|
-
|
|
14
|
-
var _utils = require("./utils");
|
|
15
|
-
|
|
16
|
-
var _resolveAlfaManifest = require("./resolveAlfaManifest");
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
22
|
-
var createIsomorphicMicroApp = function createIsomorphicMicroApp(appConfig) {
|
|
23
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
24
|
-
var manifest = (0, _utils.getManifest)(appConfig);
|
|
25
|
-
var url = (0, _utils.getURL)(appConfig);
|
|
26
|
-
|
|
27
|
-
if (!manifest && !url) {
|
|
28
|
-
throw new Error("No entry or manifest in ".concat(appConfig.name));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return (0, _consoleOsKernal.createIsomorphicMicroApp)({
|
|
32
|
-
name: appConfig.name,
|
|
33
|
-
dom: appConfig.container,
|
|
34
|
-
manifest: manifest,
|
|
35
|
-
customProps: appConfig.props,
|
|
36
|
-
deps: appConfig.deps,
|
|
37
|
-
url: url,
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
appWillMount: options.beforeMount,
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
appDidMount: options.afterMount,
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
appWillUnmount: options.beforeUnmount,
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
appDidUnmount: options.afterUnmount,
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
appWillUpdate: options.beforeUpdate
|
|
48
|
-
}, {
|
|
49
|
-
sandbox: options.sandbox
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
exports.createIsomorphicMicroApp = createIsomorphicMicroApp;
|
|
54
|
-
|
|
55
|
-
var renderToString = function renderToString(props, env) {
|
|
56
|
-
var manifest = props.manifest;
|
|
57
|
-
|
|
58
|
-
if (!manifest) {
|
|
59
|
-
var releaseUrl = (0, _utils.resolveReleaseUrl)(props);
|
|
60
|
-
var releaseJson = env.getJson(releaseUrl);
|
|
61
|
-
env.fetchJsonResource(releaseUrl);
|
|
62
|
-
|
|
63
|
-
if (!releaseJson) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
manifest = (0, _resolveAlfaManifest.parseManifestFromRelease)(releaseJson, props);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var renderString = createIsomorphicMicroApp(_objectSpread(_objectSpread({}, props), {}, {
|
|
71
|
-
manifest: manifest
|
|
72
|
-
})).load(env).mount({
|
|
73
|
-
customProps: props
|
|
74
|
-
});
|
|
75
|
-
return renderString;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
exports.renderToString = renderToString;
|
package/lib/env.d.ts
DELETED
package/lib/env.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getConsoleEnv = exports.ENV = void 0;
|
|
7
|
-
var cdnUrl = 'https://cws.alicdn.com/Release/alfa/${appId}/release.json';
|
|
8
|
-
var cdnPreUrl = 'https://cws2.alicdn.com/Prepub/alfa/${appId}/release.json';
|
|
9
|
-
var configUrl = 'https://cws.alicdn.com/Release/alfa-products/${appId}/config.json';
|
|
10
|
-
var configPreUrl = 'https://cws2.alicdn.com/Prepub/alfa-products/${appId}/config.json';
|
|
11
|
-
var ENV = {
|
|
12
|
-
local: {
|
|
13
|
-
releaseUrl: process.env.ALFA_RELEASE_URL || cdnPreUrl,
|
|
14
|
-
cdnBackupUrl: cdnUrl,
|
|
15
|
-
configUrl: configPreUrl
|
|
16
|
-
},
|
|
17
|
-
daily: {
|
|
18
|
-
releaseUrl: cdnPreUrl,
|
|
19
|
-
cdnBackupUrl: cdnPreUrl,
|
|
20
|
-
configUrl: configPreUrl
|
|
21
|
-
},
|
|
22
|
-
pre: {
|
|
23
|
-
releaseUrl: cdnPreUrl,
|
|
24
|
-
cdnBackupUrl: cdnPreUrl,
|
|
25
|
-
configUrl: configPreUrl
|
|
26
|
-
},
|
|
27
|
-
prod: {
|
|
28
|
-
releaseUrl: cdnUrl,
|
|
29
|
-
cdnBackupUrl: cdnUrl,
|
|
30
|
-
configUrl: configUrl
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
exports.ENV = ENV;
|
|
34
|
-
|
|
35
|
-
var getConsoleEnv = function getConsoleEnv() {
|
|
36
|
-
var _window, _window$ALIYUN_CONSOL;
|
|
37
|
-
|
|
38
|
-
if (process.env.NODE_ENV === 'development') {
|
|
39
|
-
return 'local';
|
|
40
|
-
} // @ts-ignore
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
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';
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
exports.getConsoleEnv = getConsoleEnv;
|
package/lib/resolveAlfaConfig.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.getConfig = void 0;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
-
|
|
16
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
17
|
-
|
|
18
|
-
var _utils = require("./utils");
|
|
19
|
-
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
|
|
24
|
-
var cachedConfig = {};
|
|
25
|
-
var productReg = /@ali\/alfa-cloud-([a-zA-z]*)-app-.*/;
|
|
26
|
-
/**
|
|
27
|
-
* 获取 Alfa 平台配置的 Config
|
|
28
|
-
* @param option
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
var getConfig = /*#__PURE__*/function () {
|
|
33
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(option) {
|
|
34
|
-
var matches, configId, resp, configData;
|
|
35
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
36
|
-
while (1) {
|
|
37
|
-
switch (_context.prev = _context.next) {
|
|
38
|
-
case 0:
|
|
39
|
-
matches = option.name.match(productReg);
|
|
40
|
-
|
|
41
|
-
if (matches) {
|
|
42
|
-
_context.next = 3;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return _context.abrupt("return", {});
|
|
47
|
-
|
|
48
|
-
case 3:
|
|
49
|
-
configId = matches[1] || option.name;
|
|
50
|
-
|
|
51
|
-
if (cachedConfig[configId]) {
|
|
52
|
-
_context.next = 15;
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
_context.prev = 5;
|
|
57
|
-
_context.next = 8;
|
|
58
|
-
return _axios.default.get((0, _utils.resolveConfigUrl)(_objectSpread(_objectSpread({}, option), {}, {
|
|
59
|
-
name: configId
|
|
60
|
-
})));
|
|
61
|
-
|
|
62
|
-
case 8:
|
|
63
|
-
resp = _context.sent;
|
|
64
|
-
configData = resp.data;
|
|
65
|
-
cachedConfig[configId] = configData;
|
|
66
|
-
_context.next = 15;
|
|
67
|
-
break;
|
|
68
|
-
|
|
69
|
-
case 13:
|
|
70
|
-
_context.prev = 13;
|
|
71
|
-
_context.t0 = _context["catch"](5);
|
|
72
|
-
|
|
73
|
-
case 15:
|
|
74
|
-
return _context.abrupt("return", cachedConfig[configId] || {});
|
|
75
|
-
|
|
76
|
-
case 16:
|
|
77
|
-
case "end":
|
|
78
|
-
return _context.stop();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}, _callee, null, [[5, 13]]);
|
|
82
|
-
}));
|
|
83
|
-
|
|
84
|
-
return function getConfig(_x) {
|
|
85
|
-
return _ref.apply(this, arguments);
|
|
86
|
-
};
|
|
87
|
-
}();
|
|
88
|
-
|
|
89
|
-
exports.getConfig = getConfig;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.parseManifestFromRelease = exports.getManifest = void 0;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
|
-
var _axios = _interopRequireDefault(require("axios"));
|
|
15
|
-
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
|
|
18
|
-
var getManifest = /*#__PURE__*/function () {
|
|
19
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(option) {
|
|
20
|
-
var resp, releaseConfig;
|
|
21
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
22
|
-
while (1) {
|
|
23
|
-
switch (_context.prev = _context.next) {
|
|
24
|
-
case 0:
|
|
25
|
-
_context.next = 2;
|
|
26
|
-
return _axios.default.get((0, _utils.resolveReleaseUrl)(option));
|
|
27
|
-
|
|
28
|
-
case 2:
|
|
29
|
-
resp = _context.sent;
|
|
30
|
-
releaseConfig = resp.data;
|
|
31
|
-
return _context.abrupt("return", parseManifestFromRelease(releaseConfig, option));
|
|
32
|
-
|
|
33
|
-
case 5:
|
|
34
|
-
case "end":
|
|
35
|
-
return _context.stop();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}, _callee);
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
return function getManifest(_x) {
|
|
42
|
-
return _ref.apply(this, arguments);
|
|
43
|
-
};
|
|
44
|
-
}();
|
|
45
|
-
|
|
46
|
-
exports.getManifest = getManifest;
|
|
47
|
-
|
|
48
|
-
var parseManifestFromRelease = function parseManifestFromRelease(releaseConfig, option) {
|
|
49
|
-
if (!option.version) {
|
|
50
|
-
var _releaseConfig$distT;
|
|
51
|
-
|
|
52
|
-
option.version = (_releaseConfig$distT = releaseConfig["dist-tags"]) === null || _releaseConfig$distT === void 0 ? void 0 : _releaseConfig$distT.latest;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var configByVersion = releaseConfig.versions[option.version];
|
|
56
|
-
|
|
57
|
-
if (!configByVersion) {
|
|
58
|
-
throw new Error("".concat(option.name, "@").concat(option.version, " is not found, please check you release."));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return releaseConfig.versions[option.version].entry;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
exports.parseManifestFromRelease = parseManifestFromRelease;
|
package/lib/types.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { OSApplication, SandBoxOption } from '@alicloud/console-os-kernal';
|
|
2
|
-
export interface IAppManifest {
|
|
3
|
-
scripts: string[];
|
|
4
|
-
styles?: string[];
|
|
5
|
-
}
|
|
6
|
-
export interface IAppConfig<T = any> {
|
|
7
|
-
entry?: IAppManifest | string;
|
|
8
|
-
name: string;
|
|
9
|
-
container?: HTMLElement | null;
|
|
10
|
-
props?: Record<string, T>;
|
|
11
|
-
manifest?: string;
|
|
12
|
-
logger?: {
|
|
13
|
-
debug: () => {};
|
|
14
|
-
error: () => {};
|
|
15
|
-
warn: () => {};
|
|
16
|
-
info: () => {};
|
|
17
|
-
};
|
|
18
|
-
deps?: {
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export interface IOptions<T = any> {
|
|
23
|
-
sandbox?: boolean | SandBoxOption;
|
|
24
|
-
beforeMount?(app: OSApplication): void;
|
|
25
|
-
afterMount?(app: OSApplication): void;
|
|
26
|
-
beforeUnmount?(app: OSApplication): void;
|
|
27
|
-
afterUnmount?(app: OSApplication): void;
|
|
28
|
-
beforeUpdate?(app: OSApplication): void;
|
|
29
|
-
afterUpdate?(app: OSApplication): void;
|
|
30
|
-
}
|
|
31
|
-
export interface AlfaVersion {
|
|
32
|
-
entry: string;
|
|
33
|
-
}
|
|
34
|
-
declare type Version = string;
|
|
35
|
-
export interface AlfaReleaseConfig {
|
|
36
|
-
versions: Record<Version, AlfaVersion>;
|
|
37
|
-
'dist-tags': Record<string, string>;
|
|
38
|
-
}
|
|
39
|
-
declare type AlfaChannelLinks = Record<string, Record<string, string>>;
|
|
40
|
-
declare type AlfaChannelFeatures = Record<string, Record<string, any>>;
|
|
41
|
-
export interface AlfaDynamicConfig {
|
|
42
|
-
ALL_CHANNEL_LINKS: AlfaChannelLinks;
|
|
43
|
-
ALL_CHANNEL_FEATURE_STATUS: AlfaChannelFeatures;
|
|
44
|
-
}
|
|
45
|
-
export interface AlfaFactoryOption {
|
|
46
|
-
name: string;
|
|
47
|
-
version?: string;
|
|
48
|
-
env?: 'prod' | 'local' | 'pre' | 'daily';
|
|
49
|
-
}
|
|
50
|
-
export interface AlfaEnvConfigDescriptor {
|
|
51
|
-
releaseUrl: string;
|
|
52
|
-
cdnBackupUrl: string;
|
|
53
|
-
configUrl: string;
|
|
54
|
-
}
|
|
55
|
-
export interface AlfaEnvConfig {
|
|
56
|
-
daily?: AlfaEnvConfigDescriptor;
|
|
57
|
-
local?: AlfaEnvConfigDescriptor;
|
|
58
|
-
pre?: AlfaEnvConfigDescriptor;
|
|
59
|
-
prod?: AlfaEnvConfigDescriptor;
|
|
60
|
-
}
|
|
61
|
-
export {};
|
package/lib/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/lib/utils.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AlfaFactoryOption, IAppConfig } from './types';
|
|
2
|
-
export declare const resolveReleaseUrl: (option: AlfaFactoryOption) => string;
|
|
3
|
-
export declare const resolveConfigUrl: (option: AlfaFactoryOption) => string;
|
|
4
|
-
export declare const getURL: (appConfig: IAppConfig) => string;
|
|
5
|
-
export declare const getManifest: (appConfig: IAppConfig) => string | {
|
|
6
|
-
name: string;
|
|
7
|
-
resources: {};
|
|
8
|
-
entrypoints: {
|
|
9
|
-
index: {
|
|
10
|
-
js: string[];
|
|
11
|
-
css: string[];
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
package/lib/utils.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.getManifest = exports.getURL = exports.resolveConfigUrl = exports.resolveReleaseUrl = void 0;
|
|
9
|
-
|
|
10
|
-
var _template = _interopRequireDefault(require("lodash/template"));
|
|
11
|
-
|
|
12
|
-
var _env = require("./env");
|
|
13
|
-
|
|
14
|
-
var resolveReleaseUrl = function resolveReleaseUrl(option) {
|
|
15
|
-
// 如果没找环境到 fallback 到 prod
|
|
16
|
-
var env = _env.ENV[option.env || (0, _env.getConsoleEnv)()] || _env.ENV.prod;
|
|
17
|
-
|
|
18
|
-
return (0, _template.default)(env.releaseUrl)({
|
|
19
|
-
appId: option.name
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.resolveReleaseUrl = resolveReleaseUrl;
|
|
24
|
-
|
|
25
|
-
var resolveConfigUrl = function resolveConfigUrl(option) {
|
|
26
|
-
// 如果没找环境到 fallback 到 prod
|
|
27
|
-
var env = _env.ENV[option.env || (0, _env.getConsoleEnv)()] || _env.ENV.prod;
|
|
28
|
-
|
|
29
|
-
return (0, _template.default)(env.configUrl)({
|
|
30
|
-
appId: option.name
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
exports.resolveConfigUrl = resolveConfigUrl;
|
|
35
|
-
|
|
36
|
-
var getURL = function getURL(appConfig) {
|
|
37
|
-
var entry = appConfig.entry;
|
|
38
|
-
var url = '';
|
|
39
|
-
|
|
40
|
-
if (typeof entry === 'string') {
|
|
41
|
-
url = entry;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return url;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
exports.getURL = getURL;
|
|
48
|
-
|
|
49
|
-
var getManifest = function getManifest(appConfig) {
|
|
50
|
-
// 定义了 entry 时,优先从 entry 生成 manifest
|
|
51
|
-
if (appConfig.entry && typeof appConfig.entry !== 'string') {
|
|
52
|
-
return {
|
|
53
|
-
name: appConfig.name,
|
|
54
|
-
resources: {},
|
|
55
|
-
entrypoints: {
|
|
56
|
-
index: {
|
|
57
|
-
js: appConfig.entry.scripts,
|
|
58
|
-
css: appConfig.entry.styles
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return appConfig.manifest;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
exports.getManifest = getManifest;
|