@superleapai/flow-ui 2.2.4 → 2.2.6
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/core/superleapClient.js +21 -16
- package/dist/output.css +1 -1
- package/dist/superleap-flow.min.js +1 -1
- package/index.js +14 -0
- package/package.json +1 -1
package/core/superleapClient.js
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
* Matches SuperLeapSDK constructor defaults (sdk.js).
|
|
19
19
|
*/
|
|
20
20
|
var DEFAULT_CONFIG = {
|
|
21
|
-
apiKey: "",
|
|
22
|
-
baseUrl: "",
|
|
21
|
+
apiKey: "NWM2MGEZMDMTYME2YI0ZYZDHLTLKNWQTNDM3NDNIZDU3YTQ1",
|
|
22
|
+
baseUrl: "https://razorpay-sandbox.superleap.dev/api/v1",
|
|
23
23
|
clientId: "",
|
|
24
24
|
clientSecret: "",
|
|
25
25
|
cache: {
|
|
@@ -90,38 +90,43 @@
|
|
|
90
90
|
function init(config) {
|
|
91
91
|
if (config == null) {
|
|
92
92
|
_config = null;
|
|
93
|
+
_sdkInstance = null;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
_config = mergeConfig(DEFAULT_CONFIG, config);
|
|
98
|
+
|
|
99
|
+
// Create SDK instance immediately during init
|
|
100
|
+
// Check for both global function and class constructor
|
|
101
|
+
if (typeof global.createSuperLeapSDK === "function") {
|
|
102
|
+
_sdkInstance = global.createSuperLeapSDK(_config);
|
|
103
|
+
} else if (typeof global.SuperLeapSDK === "function") {
|
|
104
|
+
_sdkInstance = new global.SuperLeapSDK(_config);
|
|
93
105
|
} else {
|
|
94
|
-
|
|
106
|
+
console.warn(
|
|
107
|
+
"[superleapClient] SuperLeap SDK not found. Install with: npm install superleap-sdk"
|
|
108
|
+
);
|
|
109
|
+
_sdkInstance = null;
|
|
95
110
|
}
|
|
96
|
-
_sdkInstance = null;
|
|
97
111
|
}
|
|
98
112
|
|
|
99
113
|
/**
|
|
100
|
-
* Get the SDK instance.
|
|
114
|
+
* Get the SDK instance. Returns the instance created during init().
|
|
101
115
|
* Returns null if init() was not called or the SDK script is not loaded (components can show empty state).
|
|
102
116
|
*
|
|
103
117
|
* @returns {SuperLeapSDK|null} SDK instance or null
|
|
104
118
|
*/
|
|
105
119
|
function getSdk() {
|
|
106
|
-
if (typeof global.createSuperLeapSDK !== "function") {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
if (!_config) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
if (!_sdkInstance) {
|
|
113
|
-
_sdkInstance = global.createSuperLeapSDK(_config);
|
|
114
|
-
}
|
|
115
120
|
return _sdkInstance;
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
/**
|
|
119
|
-
* Check if the client is initialized and the SDK
|
|
124
|
+
* Check if the client is initialized and the SDK instance is available.
|
|
120
125
|
*
|
|
121
126
|
* @returns {boolean}
|
|
122
127
|
*/
|
|
123
128
|
function isAvailable() {
|
|
124
|
-
return
|
|
129
|
+
return _config != null && _sdkInstance != null;
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
/**
|