@getlimelight/sdk 0.2.0 → 0.3.0

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.mts CHANGED
@@ -312,13 +312,13 @@ interface LimelightConfig {
312
312
  /**
313
313
  * The unique project key for authenticating with the Limelight server.
314
314
  */
315
- projectKey: string;
315
+ projectKey?: string;
316
316
  /**
317
317
  * The platform of the application (e.g., "ios", "android").
318
318
  */
319
319
  platform?: string;
320
320
  /**
321
- * The URL of the Limelight server to connect to.
321
+ * The URL of the Limelight server to connect to. If not provided, it falls back to the local wss server url if there is no project key, or the web wss url if there is a project key.
322
322
  */
323
323
  serverUrl?: string;
324
324
  /**
@@ -427,7 +427,7 @@ declare class LimelightClient {
427
427
  * @param {LimelightConfig} [config] - Optional configuration object.
428
428
  * @returns {void}
429
429
  */
430
- connect(config: LimelightConfig): void;
430
+ connect(config?: LimelightConfig): void;
431
431
  /**
432
432
  * Attempts to reconnect to the Limelight server using exponential backoff.
433
433
  * Will retry up to maxReconnectAttempts times with increasing delays.
package/dist/index.d.ts CHANGED
@@ -312,13 +312,13 @@ interface LimelightConfig {
312
312
  /**
313
313
  * The unique project key for authenticating with the Limelight server.
314
314
  */
315
- projectKey: string;
315
+ projectKey?: string;
316
316
  /**
317
317
  * The platform of the application (e.g., "ios", "android").
318
318
  */
319
319
  platform?: string;
320
320
  /**
321
- * The URL of the Limelight server to connect to.
321
+ * The URL of the Limelight server to connect to. If not provided, it falls back to the local wss server url if there is no project key, or the web wss url if there is a project key.
322
322
  */
323
323
  serverUrl?: string;
324
324
  /**
@@ -427,7 +427,7 @@ declare class LimelightClient {
427
427
  * @param {LimelightConfig} [config] - Optional configuration object.
428
428
  * @returns {void}
429
429
  */
430
- connect(config: LimelightConfig): void;
430
+ connect(config?: LimelightConfig): void;
431
431
  /**
432
432
  * Attempts to reconnect to the Limelight server using exponential backoff.
433
433
  * Will retry up to maxReconnectAttempts times with increasing delays.
package/dist/index.js CHANGED
@@ -255,9 +255,10 @@ var SENSITIVE_HEADERS = [
255
255
  "x-secret",
256
256
  "bearer"
257
257
  ];
258
- var DEFAULT_PORT = 9090;
258
+ var LIMELIGHT_WEB_WSS_URL = "wss://api.getlimelight.io";
259
+ var LIMELIGHT_DESKTOP_WSS_URL = "ws://localhost:8484";
259
260
  var WS_PATH = "/limelight";
260
- var SDK_VERSION = true ? "0.2.0" : "test-version";
261
+ var SDK_VERSION = true ? "0.3.0" : "test-version";
261
262
  var RENDER_THRESHOLDS = {
262
263
  HOT_VELOCITY: 5,
263
264
  HIGH_RENDER_COUNT: 50,
@@ -1635,18 +1636,19 @@ var LimelightClient = class {
1635
1636
  * @returns {void}
1636
1637
  */
1637
1638
  configure(config) {
1638
- const isEnabled = config.enabled ?? isDevelopment();
1639
+ const isEnabled = config?.enabled ?? isDevelopment();
1640
+ const configServerUrl = config?.serverUrl ? config.serverUrl : config?.projectKey ? `${LIMELIGHT_WEB_WSS_URL}${WS_PATH}` : `${LIMELIGHT_DESKTOP_WSS_URL}${WS_PATH}`;
1639
1641
  this.config = {
1640
- appName: "Limelight App",
1641
- serverUrl: `ws://localhost:${DEFAULT_PORT}${WS_PATH}`,
1642
+ ...config,
1643
+ appName: config?.appName ?? "Limelight App",
1644
+ serverUrl: configServerUrl,
1642
1645
  enabled: isEnabled,
1643
- enableNetworkInspector: true,
1644
- enableConsole: true,
1645
- enableGraphQL: true,
1646
- enableRenderInspector: true,
1647
- ...config
1646
+ enableNetworkInspector: config?.enableNetworkInspector ?? true,
1647
+ enableConsole: config?.enableConsole ?? true,
1648
+ enableGraphQL: config?.enableGraphQL ?? true,
1649
+ enableRenderInspector: config?.enableRenderInspector ?? true
1648
1650
  };
1649
- if (!this.config.enabled) {
1651
+ if (!this.config?.enabled) {
1650
1652
  return;
1651
1653
  }
1652
1654
  this.sessionId = createSessionId();
@@ -1677,13 +1679,7 @@ var LimelightClient = class {
1677
1679
  * @returns {void}
1678
1680
  */
1679
1681
  connect(config) {
1680
- if (config) {
1681
- this.configure(config);
1682
- } else if (!this.config) {
1683
- throw new Error(
1684
- "[Limelight] Limelight not configured. Please provide a configuration object when calling connect(). Project id is the only required field."
1685
- );
1686
- }
1682
+ this.configure(config);
1687
1683
  if (!this.config?.enabled) {
1688
1684
  return;
1689
1685
  }
@@ -1715,7 +1711,7 @@ var LimelightClient = class {
1715
1711
  data: {
1716
1712
  appName,
1717
1713
  platform: platform || (typeof window !== "undefined" ? "web" : "react-native"),
1718
- projectKey: this.config.projectKey,
1714
+ projectKey: this.config.projectKey || "",
1719
1715
  sdkVersion: SDK_VERSION
1720
1716
  }
1721
1717
  };
@@ -1757,13 +1753,7 @@ var LimelightClient = class {
1757
1753
  );
1758
1754
  this.reconnectTimer = setTimeout(() => {
1759
1755
  this.reconnectTimer = null;
1760
- if (this.config) {
1761
- this.configure(this.config);
1762
- } else if (!this.config) {
1763
- throw new Error(
1764
- "[Limelight] Limelight not configured. Please provide a configuration object when calling connect(). Project id is the only required field."
1765
- );
1766
- }
1756
+ this.connect(this.config || void 0);
1767
1757
  }, delay);
1768
1758
  }
1769
1759
  /**