@cqsjjb/jjb-cloud-component 0.0.2 → 0.0.3

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.
@@ -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 }>;
@@ -43,4 +44,4 @@ interface CloudComponentFc extends React.FC<CloudComponentProps> {
43
44
  }
44
45
 
45
46
  declare const CloudComponent: CloudComponentFc;
46
- export default CloudComponent;
47
+ declare const ImportCloudComponent: typeof I_ImportCloudComponent;
@@ -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
- return tools.isUndefined(window[ lib ][ name ]);
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
- import CloudComponent from './cloud-component';
2
- import ImportCloudComponent from './import-cloud-component';
3
-
4
- export {
5
- CloudComponent,
6
- ImportCloudComponent
7
- };
1
+ export CloudComponent from './cloud-component';
2
+ export ImportCloudComponent from './import-cloud-component';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqsjjb/jjb-cloud-component",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "前端-云组件",
5
5
  "main": "index.js",
6
6
  "scripts": {