@cqsjjb/jjb-cloud-component 0.0.2 → 0.0.4
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/cloud-component.d.ts +4 -1
- package/cloud-component.js +3 -0
- package/import-cloud-component.js +4 -2
- package/index.js +2 -7
- package/package.json +1 -1
package/cloud-component.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import type I_ImportCloudComponent from './import-cloud-component';
|
|
3
4
|
|
|
4
5
|
interface ComponentProps {
|
|
5
6
|
ref?: React.Ref<{ [ p: string ]: any }>;
|
|
@@ -7,6 +8,8 @@ interface ComponentProps {
|
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
interface CloudComponentProps extends ComponentProps {
|
|
11
|
+
// 云组件依赖库变量
|
|
12
|
+
lib: string;
|
|
10
13
|
// 组件资源地址
|
|
11
14
|
from: string;
|
|
12
15
|
// 缓存
|
|
@@ -43,4 +46,4 @@ interface CloudComponentFc extends React.FC<CloudComponentProps> {
|
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
declare const CloudComponent: CloudComponentFc;
|
|
46
|
-
|
|
49
|
+
declare const ImportCloudComponent: typeof I_ImportCloudComponent;
|
package/cloud-component.js
CHANGED
|
@@ -16,6 +16,7 @@ export default function CloudComponent(props) {
|
|
|
16
16
|
let styleId;
|
|
17
17
|
const [ Component, setComponent ] = React.useState(null);
|
|
18
18
|
const {
|
|
19
|
+
lib,
|
|
19
20
|
from,
|
|
20
21
|
cache,
|
|
21
22
|
headers,
|
|
@@ -36,6 +37,7 @@ export default function CloudComponent(props) {
|
|
|
36
37
|
module,
|
|
37
38
|
styleId: _styleId
|
|
38
39
|
} = await ImportCloudComponent({
|
|
40
|
+
lib,
|
|
39
41
|
from,
|
|
40
42
|
cache,
|
|
41
43
|
headers
|
|
@@ -69,3 +71,4 @@ export default function CloudComponent(props) {
|
|
|
69
71
|
/>
|
|
70
72
|
);
|
|
71
73
|
}
|
|
74
|
+
|
|
@@ -61,7 +61,8 @@ function print(msg) {
|
|
|
61
61
|
* @return {boolean}
|
|
62
62
|
*/
|
|
63
63
|
function checkDependence(lib, name) {
|
|
64
|
-
|
|
64
|
+
const dependencies = new Function(`return window${ansLibField(lib)}`)();
|
|
65
|
+
return tools.isUndefined(dependencies[ name ]);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -92,7 +93,7 @@ function checkDependencies(lib, dependencies, isProxy) {
|
|
|
92
93
|
* @return {Promise<{ module: { info: {}, default:() => React.Component }, styleId: string }>}
|
|
93
94
|
*/
|
|
94
95
|
export default function ImportCloudComponent(options) {
|
|
95
|
-
const lib = options.lib || '__coreLib'
|
|
96
|
+
const lib = typeof window.proxy === 'undefined' ? `${options.lib || '__coreLib'}` : `.proxy.${options.lib || '__coreLib'}`;
|
|
96
97
|
const from = options.from;
|
|
97
98
|
|
|
98
99
|
const cache = options.cache || 'force-cache';
|
|
@@ -147,3 +148,4 @@ export default function ImportCloudComponent(options) {
|
|
|
147
148
|
};
|
|
148
149
|
});
|
|
149
150
|
}
|
|
151
|
+
|
package/index.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
CloudComponent,
|
|
6
|
-
ImportCloudComponent
|
|
7
|
-
};
|
|
1
|
+
export { default as CloudComponent } from './cloud-component';
|
|
2
|
+
export { default as ImportCloudComponent } from './import-cloud-component';
|