@alicloud/alfa-react 1.7.1-alpha.2 → 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.
- package/.storybook/main.ts +49 -0
- package/.storybook/preview.ts +14 -0
- package/es/components/ErrorBoundary/index.js +7 -9
- package/es/components/Loading/Paragraph.js +6 -8
- package/es/components/Loading/Skeleton.js +8 -10
- package/es/components/Loading/Title.js +2 -2
- package/es/createAlfaApp.js +4 -4
- package/es/createAlfaWidget.js +8 -8
- package/es/createApplication.js +43 -33
- package/es/loaders/beforeLoadHook.js +13 -13
- package/es/loaders/beforeResolveHook.js +5 -5
- package/es/schedule.js +1 -2
- package/es/types/base.js +5 -6
- package/es/utils/getConsoleConfig.js +4 -4
- package/es/utils/getConsoleGlobal.js +4 -4
- package/es/version.js +1 -1
- package/es/widget/emitter.js +6 -8
- package/es/widget/getWidgetConfigById.js +8 -8
- package/es/widget/getWidgetDeps.js +28 -29
- package/es/widget/getWidgetVersionById.js +19 -19
- package/es/widget.js +13 -13
- package/lib/components/ErrorBoundary/ErrorPanel.js +1 -2
- package/lib/components/ErrorBoundary/index.js +9 -12
- package/lib/components/Loading/Paragraph.js +8 -12
- package/lib/components/Loading/Skeleton.js +10 -14
- package/lib/components/Loading/Title.js +4 -6
- package/lib/components/Loading/style.js +1 -2
- package/lib/createAlfaApp.js +6 -8
- package/lib/createAlfaWidget.js +10 -12
- package/lib/createApplication.js +44 -35
- package/lib/index.js +1 -2
- package/lib/loaders/beforeLoadHook.js +14 -15
- package/lib/loaders/beforeResolveHook.js +6 -7
- package/lib/schedule.js +3 -5
- package/lib/types/base.js +7 -9
- package/lib/utils/counter.js +2 -3
- package/lib/utils/getConsoleConfig.js +6 -7
- package/lib/utils/getConsoleGlobal.js +6 -7
- package/lib/utils/index.js +11 -21
- package/lib/version.js +1 -2
- package/lib/widget/emitter.js +7 -10
- package/lib/widget/env.js +4 -7
- package/lib/widget/getWidgetConfigById.js +11 -12
- package/lib/widget/getWidgetDeps.js +32 -35
- package/lib/widget/getWidgetVersionById.js +24 -26
- package/lib/widget.js +14 -15
- package/package.json +27 -13
- package/scripts/postinstall.js +95 -0
- package/types/components/ErrorBoundary/index.d.ts +4 -3
- package/types/components/Loading/Paragraph.d.ts +1 -1
- package/types/components/Loading/Skeleton.d.ts +2 -2
- package/types/components/Loading/Title.d.ts +2 -1
- package/types/components/Loading/index.d.ts +1 -1
- package/types/createAlfaApp.d.ts +3 -5
- package/types/createApplication.d.ts +2 -1
- package/types/types/index.d.ts +6 -3
- package/types/utils/getConsoleConfig.d.ts +1 -0
- package/types/version.d.ts +1 -1
- package/types/widget.d.ts +3 -2
- package/es/hooks/beforeLoadHook.js +0 -82
- package/es/hooks/beforeResolveHook.js +0 -41
- package/lib/hooks/beforeLoadHook.js +0 -90
- package/lib/hooks/beforeResolveHook.js +0 -48
- package/types/hooks/beforeLoadHook.d.ts +0 -7
- package/types/hooks/beforeResolveHook.d.ts +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/alfa-react",
|
|
3
|
-
"version": "1.7.1-
|
|
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",
|
|
@@ -11,52 +11,66 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@alicloud/console-toolkit-cli": "^1.0.
|
|
14
|
+
"@alicloud/console-toolkit-cli": "^1.0.1",
|
|
15
15
|
"@alicloud/console-toolkit-preset-wind-component": "^1.0.0",
|
|
16
|
+
"@chromatic-com/storybook": "^3.2.6",
|
|
17
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
18
|
+
"@storybook/addon-interactions": "^8.6.12",
|
|
19
|
+
"@storybook/addon-onboarding": "^8.6.12",
|
|
20
|
+
"@storybook/react": "^8.6.12",
|
|
21
|
+
"@storybook/react-vite": "^8.6.12",
|
|
16
22
|
"@types/axios": "^0.14.0",
|
|
17
23
|
"@types/chai": "^4.1.7",
|
|
18
24
|
"@types/classnames": "^2.2.9",
|
|
19
25
|
"@types/crypto-js": "^4.0.2",
|
|
20
26
|
"@types/jest": "^23.3.13",
|
|
21
27
|
"@types/lodash": "^4.14.176",
|
|
28
|
+
"@types/lodash-es": "^4.17.12",
|
|
22
29
|
"@types/prop-types": "^15.7.5",
|
|
23
|
-
"@types/react": "^
|
|
24
|
-
"@types/react-dom": "^
|
|
30
|
+
"@types/react": "^18.3.20",
|
|
31
|
+
"@types/react-dom": "^18.3.6",
|
|
25
32
|
"@types/react-lazyload": "^3.2.3",
|
|
26
33
|
"@types/single-spa-react": "^2.8.3",
|
|
27
34
|
"jest": "^23.6.0",
|
|
28
|
-
"react": "^
|
|
29
|
-
"react-dom": "^
|
|
35
|
+
"react": "^18.3.1",
|
|
36
|
+
"react-dom": "^18.3.1",
|
|
37
|
+
"sass": "^1.86.3",
|
|
38
|
+
"storybook": "^8.6.12",
|
|
30
39
|
"ts-jest": "^23.10.5",
|
|
31
40
|
"tslib": "^2.4.0",
|
|
32
|
-
"typescript": "^4.0.0"
|
|
41
|
+
"typescript": "^4.0.0",
|
|
42
|
+
"vite": "^6.3.2",
|
|
43
|
+
"vite-plugin-node-polyfills": "^0.23.0"
|
|
33
44
|
},
|
|
34
45
|
"dependencies": {
|
|
35
|
-
"@alicloud/alfa-core": "^1.5.0-alpha.1",
|
|
36
46
|
"@alicloud/console-base-messenger": "^1.18.1",
|
|
37
|
-
"@alicloud/console-os-loader": "^1.4.45-alpha.0",
|
|
38
47
|
"@alicloud/widget-utils-console": "^0.1.6",
|
|
39
48
|
"@alicloud/xconsole-context": "^2.4.32",
|
|
40
49
|
"axios": "^0.21.4",
|
|
41
50
|
"classnames": "^2.2.6",
|
|
42
51
|
"crypto-js": "^4.1.1",
|
|
52
|
+
"lodash-es": "^4.17.21",
|
|
43
53
|
"prop-types": "^15.8.1",
|
|
44
|
-
"react-lazyload": "^3.2.1"
|
|
54
|
+
"react-lazyload": "^3.2.1",
|
|
55
|
+
"@alicloud/console-os-loader": "^1.4.45",
|
|
56
|
+
"@alicloud/alfa-core": "^1.5.7"
|
|
45
57
|
},
|
|
46
58
|
"peerDependencies": {
|
|
47
59
|
"react": ">=16.0.0",
|
|
48
60
|
"react-dom": ">=16.0.0"
|
|
49
61
|
},
|
|
50
62
|
"scripts": {
|
|
63
|
+
"build": "npm run version && npm run babel && npm run babel:esm && npm run types",
|
|
51
64
|
"pub": "pnpm publish",
|
|
52
|
-
"build": "breezr build --engine webpack",
|
|
65
|
+
"build:webpack": "breezr build --engine webpack",
|
|
53
66
|
"babel": "breezr build --engine babel",
|
|
54
67
|
"babel:esm": "breezr build --engine babel --es-module",
|
|
55
68
|
"types": "tsc --emitDeclarationOnly -d --declarationDir ./types",
|
|
56
69
|
"storybook": "breezr start-storybook",
|
|
57
70
|
"clean": "rm -rf lib es dist types yarn.lock",
|
|
58
|
-
"start": "
|
|
71
|
+
"start": "storybook dev -p 6006",
|
|
59
72
|
"precommit": "npm run version",
|
|
60
|
-
"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"
|
|
61
75
|
}
|
|
62
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,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { AlfaLogger } from '@alicloud/alfa-core';
|
|
3
|
+
import type { PropsWithChildren, ErrorInfo } from 'react';
|
|
3
4
|
interface IProps {
|
|
4
5
|
fallbackRender?: (error?: Error) => React.ReactNode;
|
|
5
6
|
appDidCatch?: (error?: Error, info?: ErrorInfo) => void;
|
|
@@ -9,9 +10,9 @@ interface State {
|
|
|
9
10
|
hasError: boolean;
|
|
10
11
|
error?: Error;
|
|
11
12
|
}
|
|
12
|
-
declare class ErrorBoundary extends React.Component<IProps
|
|
13
|
+
declare class ErrorBoundary extends React.Component<PropsWithChildren<IProps>, State> {
|
|
13
14
|
constructor(props: IProps);
|
|
14
15
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
15
|
-
render(): React.ReactNode;
|
|
16
|
+
render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
16
17
|
}
|
|
17
18
|
export default ErrorBoundary;
|
|
@@ -13,7 +13,7 @@ export interface SkeletonProps {
|
|
|
13
13
|
declare class Skeleton extends React.Component<SkeletonProps, any> {
|
|
14
14
|
static defaultProps: Partial<SkeletonProps>;
|
|
15
15
|
componentDidMount(): void;
|
|
16
|
-
renderSkeleton: () => React.ReactNode;
|
|
17
|
-
render(): React.ReactNode;
|
|
16
|
+
renderSkeleton: () => string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
17
|
+
render(): string | number | boolean | React.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
18
18
|
}
|
|
19
19
|
export default Skeleton;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
export interface SkeletonTitleProps {
|
|
2
3
|
prefixCls?: string;
|
|
3
4
|
className?: string;
|
|
4
5
|
style?: object;
|
|
5
6
|
width?: number | string;
|
|
6
7
|
}
|
|
7
|
-
declare const Title: ({ prefixCls, className, width, style }: SkeletonTitleProps) => JSX.Element;
|
|
8
|
+
declare const Title: ({ prefixCls, className, width, style }: SkeletonTitleProps) => React.JSX.Element;
|
|
8
9
|
export default Title;
|
package/types/createAlfaApp.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { AlfaFactoryOption } from './types';
|
|
2
|
-
|
|
3
|
-
interface IProps extends IApplicationProps, IApplicationCustomProps {
|
|
4
|
-
}
|
|
5
|
-
declare function createAlfaApp<P = any>(option: AlfaFactoryOption): (() => null) | ((props: P & IProps) => JSX.Element);
|
|
3
|
+
declare function createAlfaApp<P = any>(option: AlfaFactoryOption): React.FC<any>;
|
|
6
4
|
/**
|
|
7
5
|
* create memorized app in react function component,
|
|
8
6
|
* it will update when name or version changed as default
|
|
@@ -10,5 +8,5 @@ declare function createAlfaApp<P = any>(option: AlfaFactoryOption): (() => null)
|
|
|
10
8
|
* @param dep custom useMemo deps
|
|
11
9
|
* @returns
|
|
12
10
|
*/
|
|
13
|
-
export declare function useAlfaApp<P = any>(option: AlfaFactoryOption, deps?: any[]):
|
|
11
|
+
export declare function useAlfaApp<P = any>(option: AlfaFactoryOption, deps?: any[]): React.FC<any>;
|
|
14
12
|
export default createAlfaApp;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { BaseLoader } from '@alicloud/alfa-core';
|
|
2
3
|
import type { AlfaFactoryOption } from './types';
|
|
3
4
|
export interface IApplicationCustomProps {
|
|
@@ -61,4 +62,4 @@ export interface IApplicationProps<C = any> extends AlfaFactoryOption {
|
|
|
61
62
|
* @param loader alfa-core loader
|
|
62
63
|
* @returns
|
|
63
64
|
*/
|
|
64
|
-
export default function createApplication(loader: BaseLoader): <C = any>(props: IApplicationProps<C>) => JSX.Element;
|
|
65
|
+
export default function createApplication(loader: BaseLoader): <C = any>(props: IApplicationProps<C>) => React.JSX.Element;
|
package/types/types/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
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;
|
|
@@ -43,7 +42,7 @@ export interface AlfaFactoryOption extends IAppConfig {
|
|
|
43
42
|
/**
|
|
44
43
|
* @deprecated
|
|
45
44
|
*/
|
|
46
|
-
fallbackRender?: (error?: Error) =>
|
|
45
|
+
fallbackRender?: (error?: Error) => React.ReactNode;
|
|
47
46
|
/**
|
|
48
47
|
* 延迟加载
|
|
49
48
|
*/
|
|
@@ -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>>;
|
package/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.7.1-
|
|
1
|
+
export declare const version = "1.7.1-beta.1";
|
package/types/widget.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { WidgetFactoryOption } from './types';
|
|
3
|
+
export declare function createCWSWidget<T>(option: WidgetFactoryOption): (props: T) => React.JSX.Element;
|
|
@@ -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;
|