codenotch-react 1.0.33 → 1.0.35
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/dist/index.d.ts +1 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -28
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,18 +17,12 @@ export interface ICodenotchApi {
|
|
|
17
17
|
dispose: () => void;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
export type CodenotchAppFC<T> = React.FC<(ICodenotchEnv & T)>;
|
|
21
20
|
declare const CODENOTCH_ENV: ICodenotchEnv;
|
|
21
|
+
export declare function setupCodenotchEnv(env: any): void;
|
|
22
22
|
/**
|
|
23
23
|
* Return Codenotch API
|
|
24
24
|
* @returns {ICodenotchApi} Codenotch API
|
|
25
25
|
*/
|
|
26
26
|
export declare function useCodenotch(): ICodenotchApi;
|
|
27
|
-
/**
|
|
28
|
-
* Setup Codenotch environment and return Codenotch API
|
|
29
|
-
* @param props Codenotch app properties
|
|
30
|
-
* @returns {ICodenotchApi} Codenotch API
|
|
31
|
-
*/
|
|
32
|
-
export declare function useCodenotchApp(props?: ICodenotchEnv): ICodenotchApi;
|
|
33
27
|
export { CODENOTCH_ENV };
|
|
34
28
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC1B,GAAG,EAAE,aAAa,CAAC;IACnB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACjE,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACrE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK;QAAE,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;CACjF;AAED,QAAA,MAAM,aAAa,EAAE,aAAkB,CAAC;AAExC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAUhD;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,aAAa,CA8D5C;AAGD,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CODENOTCH_ENV = void 0;
|
|
4
|
+
exports.setupCodenotchEnv = setupCodenotchEnv;
|
|
4
5
|
exports.useCodenotch = useCodenotch;
|
|
5
|
-
exports.useCodenotchApp = useCodenotchApp;
|
|
6
6
|
const CODENOTCH_ENV = {};
|
|
7
7
|
exports.CODENOTCH_ENV = CODENOTCH_ENV;
|
|
8
|
+
function setupCodenotchEnv(env) {
|
|
9
|
+
if (env === undefined || env === null) {
|
|
10
|
+
console.warn("Codenotch environment is not defined. Please set it in the Codenotch configuration.");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
Object.keys(env).forEach((key) => {
|
|
14
|
+
CODENOTCH_ENV[key] = env[key];
|
|
15
|
+
console.log(`Codenotch environment variable ${key} set to ${env[key]}`);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
8
18
|
/**
|
|
9
19
|
* Return Codenotch API
|
|
10
20
|
* @returns {ICodenotchApi} Codenotch API
|
|
@@ -61,30 +71,3 @@ function useCodenotch() {
|
|
|
61
71
|
}
|
|
62
72
|
};
|
|
63
73
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Setup Codenotch environment and return Codenotch API
|
|
66
|
-
* @param props Codenotch app properties
|
|
67
|
-
* @returns {ICodenotchApi} Codenotch API
|
|
68
|
-
*/
|
|
69
|
-
function useCodenotchApp(props) {
|
|
70
|
-
if (props) {
|
|
71
|
-
if (props.clusterUrl)
|
|
72
|
-
CODENOTCH_ENV.clusterUrl = props.clusterUrl;
|
|
73
|
-
if (props.serviceName)
|
|
74
|
-
CODENOTCH_ENV.serviceName = props.serviceName;
|
|
75
|
-
if (props.tenantName)
|
|
76
|
-
CODENOTCH_ENV.tenantName = props.tenantName;
|
|
77
|
-
if (props.accessToken)
|
|
78
|
-
CODENOTCH_ENV.accessToken = props.accessToken;
|
|
79
|
-
// Inject URL parameters as props if they are not already defined
|
|
80
|
-
if (typeof window !== 'undefined') {
|
|
81
|
-
const params = new URL(window.location.href).searchParams;
|
|
82
|
-
params.forEach((value, key) => {
|
|
83
|
-
if (props[key] === undefined) {
|
|
84
|
-
props[key] = value;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return useCodenotch();
|
|
90
|
-
}
|