@superleapai/flow-ui 2.2.6 → 2.2.7

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.
@@ -6,7 +6,7 @@
6
6
  * Licensed under MIT
7
7
  *
8
8
  * Build: development
9
- * Date: 2026-02-12T08:47:06.944Z
9
+ * Date: 2026-02-12T10:47:05.105Z
10
10
  *
11
11
  * For documentation and examples, visit:
12
12
  * https://github.com/superleap/superleap-flow
@@ -2664,8 +2664,8 @@
2664
2664
  * Matches SuperLeapSDK constructor defaults (sdk.js).
2665
2665
  */
2666
2666
  var DEFAULT_CONFIG = {
2667
- apiKey: "",
2668
- baseUrl: "",
2667
+ apiKey: "NWM2MGEZMDMTYME2YI0ZYZDHLTLKNWQTNDM3NDNIZDU3YTQ1",
2668
+ baseUrl: "https://razorpay-sandbox.superleap.dev/api/v1",
2669
2669
  clientId: "",
2670
2670
  clientSecret: "",
2671
2671
  cache: {
@@ -2736,38 +2736,43 @@
2736
2736
  function init(config) {
2737
2737
  if (config == null) {
2738
2738
  _config = null;
2739
+ _sdkInstance = null;
2740
+ return;
2741
+ }
2742
+
2743
+ _config = mergeConfig(DEFAULT_CONFIG, config);
2744
+
2745
+ // Create SDK instance immediately during init
2746
+ // Check for both global function and class constructor
2747
+ if (typeof global.createSuperLeapSDK === "function") {
2748
+ _sdkInstance = global.createSuperLeapSDK(_config);
2749
+ } else if (typeof global.SuperLeapSDK === "function") {
2750
+ _sdkInstance = new global.SuperLeapSDK(_config);
2739
2751
  } else {
2740
- _config = mergeConfig(DEFAULT_CONFIG, config);
2752
+ console.warn(
2753
+ "[superleapClient] SuperLeap SDK not found. Install with: npm install superleap-sdk"
2754
+ );
2755
+ _sdkInstance = null;
2741
2756
  }
2742
- _sdkInstance = null;
2743
2757
  }
2744
2758
 
2745
2759
  /**
2746
- * Get the SDK instance. Creates it via createSuperLeapSDK(mergedConfig) on first call.
2760
+ * Get the SDK instance. Returns the instance created during init().
2747
2761
  * Returns null if init() was not called or the SDK script is not loaded (components can show empty state).
2748
2762
  *
2749
2763
  * @returns {SuperLeapSDK|null} SDK instance or null
2750
2764
  */
2751
2765
  function getSdk() {
2752
- if (typeof global.createSuperLeapSDK !== "function") {
2753
- return null;
2754
- }
2755
- if (!_config) {
2756
- return null;
2757
- }
2758
- if (!_sdkInstance) {
2759
- _sdkInstance = global.createSuperLeapSDK(_config);
2760
- }
2761
2766
  return _sdkInstance;
2762
2767
  }
2763
2768
 
2764
2769
  /**
2765
- * Check if the client is initialized and the SDK factory is available (does not create the instance).
2770
+ * Check if the client is initialized and the SDK instance is available.
2766
2771
  *
2767
2772
  * @returns {boolean}
2768
2773
  */
2769
2774
  function isAvailable() {
2770
- return typeof global.createSuperLeapSDK === "function" && _config != null;
2775
+ return _config != null && _sdkInstance != null;
2771
2776
  }
2772
2777
 
2773
2778
  /**
@@ -16792,6 +16797,20 @@
16792
16797
  // Execute immediately (synchronously)
16793
16798
  captureComponents();
16794
16799
 
16800
+ // Auto-initialize SDK with default config if not in iframe context
16801
+ // This allows standalone testing without calling SuperLeap.init() manually
16802
+ // In iframe context, SuperLeap.connect() will reinitialize with CRM config
16803
+ const client = _components["superleapClient"];
16804
+ if (client && typeof client.init === "function") {
16805
+ // Check if we're NOT in an iframe context (standalone usage)
16806
+ const isStandalone = window === window.parent;
16807
+ if (isStandalone && !client.isAvailable()) {
16808
+ // Auto-init with default config for standalone testing
16809
+ client.init(client.getDefaultConfig());
16810
+ console.log("[Superleap-Flow] SDK auto-initialized for standalone mode");
16811
+ }
16812
+ }
16813
+
16795
16814
  // Dispatch custom event when library is ready
16796
16815
  if (typeof CustomEvent !== "undefined" && typeof document !== "undefined") {
16797
16816
  // Function to dispatch the ready event