@centive/aria-sdk 0.5.3 → 0.5.4

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.
@@ -6358,7 +6358,7 @@ class ge {
6358
6358
  this.setStatus("connecting");
6359
6359
  try {
6360
6360
  this.ws = new WebSocket(this.config.websocketUrl), this.ws.onopen = () => {
6361
- console.log("[AriaSessionManager] WebSocket connected"), this.setStatus("connected"), this.retryCount = 0, this.emit({ type: "connection_change", data: { connected: !0 } }), this.config.onConnectionStateChange?.(!0), this.config.preloadSession !== !1 && this.triggerSessionPreload();
6361
+ console.log("[AriaSessionManager] WebSocket connected"), this.setStatus("connected"), this.retryCount = 0, this.emit({ type: "connection_change", data: { connected: !0 } }), this.config.onConnectionStateChange?.(!0), this.config.preloadSession !== !1 && this.config.userId ? (console.log("[AriaSessionManager] Auto-preloading session for user:", this.config.userId), this.triggerSessionPreload()) : this.config.preloadSession !== !1 && !this.config.userId && console.log("[AriaSessionManager] Skipping auto-preload: no userId configured. Session will be created when user triggers.");
6362
6362
  }, this.ws.onmessage = (e) => this.handleWebSocketMessage(e), this.ws.onerror = (e) => {
6363
6363
  console.error("[AriaSessionManager] WebSocket error:", e), this.setStatus("error"), this.updateSessionState({ lastError: "WebSocket connection error" }), this.config.onError?.(new Error("WebSocket connection failed"));
6364
6364
  }, this.ws.onclose = () => {
@@ -6476,6 +6476,14 @@ class ge {
6476
6476
  // Session Preloading
6477
6477
  // ============================================================================
6478
6478
  triggerSessionPreload() {
6479
+ if (this.sessionState.isSessionReady || this.sessionState.token) {
6480
+ console.log("[AriaSessionManager] Session already exists, skipping preload");
6481
+ return;
6482
+ }
6483
+ if (this.status === "ready" || this.status === "preloading") {
6484
+ console.log("[AriaSessionManager] Session already in progress, skipping preload");
6485
+ return;
6486
+ }
6479
6487
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
6480
6488
  console.warn("[AriaSessionManager] Cannot preload session: WebSocket not connected");
6481
6489
  return;
@@ -6491,8 +6499,20 @@ class ge {
6491
6499
  }
6492
6500
  /**
6493
6501
  * Manually trigger a session (for user-initiated actions)
6502
+ *
6503
+ * NOTE: With global session management, this is typically not needed.
6504
+ * The session is automatically preloaded when the provider mounts.
6505
+ * This method will be a no-op if a session already exists.
6494
6506
  */
6495
6507
  triggerSession(e = !0) {
6508
+ if (this.sessionState.isSessionReady || this.sessionState.token) {
6509
+ console.log("[AriaSessionManager] Session already exists, skipping trigger");
6510
+ return;
6511
+ }
6512
+ if (this.status === "ready" || this.status === "preloading") {
6513
+ console.log("[AriaSessionManager] Session already in progress, skipping trigger");
6514
+ return;
6515
+ }
6496
6516
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
6497
6517
  console.error("[AriaSessionManager] Cannot trigger session: WebSocket not connected");
6498
6518
  return;
@@ -6516,7 +6536,7 @@ class ge {
6516
6536
  console.log("[AriaSessionManager] Initializing Anam client for preloading"), this.setStatus("preloading");
6517
6537
  try {
6518
6538
  this.createHiddenVideoElement();
6519
- const { createClient: i } = await import("./index-dSSsRgxB.js"), o = i(e);
6539
+ const { createClient: i } = await import("./index-Cg6WCsh_.js"), o = i(e);
6520
6540
  o.addListener(F.SESSION_READY, () => {
6521
6541
  const u = o.getActiveSessionId();
6522
6542
  u && (this.updateSessionState({ session_id: u }), console.log("[AriaSessionManager] Session ready with ID:", u)), this.setStatus("ready"), this.emit({ type: "session_ready", data: { sessionId: u } }), this.config.onSessionReady?.(), this.config.onSessionPreloaded?.();
@@ -7074,4 +7094,4 @@ export {
7074
7094
  nn as y,
7075
7095
  on as z
7076
7096
  };
7077
- //# sourceMappingURL=index-AqGMglQT.js.map
7097
+ //# sourceMappingURL=index-BpJZlLfH.js.map