callix-dialer-widget 2.8.1 → 2.8.2

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/WIDGET-README.md CHANGED
@@ -145,7 +145,14 @@ Pausas no modo motor (2.8.1): a lista de pausas é a do serviço no Callix, traz
145
145
  do motor; a pausa escolhida vai no comando `pause` e o discador mostra o nome dela. Com um
146
146
  motor anterior ao 2.8.1 a lista cai numa pausa única ("Pausa") e o motor usa a configurada
147
147
  nele. O widget também informa a própria versão ao host, que a registra no log: é o jeito de
148
- achar navegadores com um build antigo em cache.
148
+ achar navegadores com um build antigo em cache. No console da página, `CallixDialer.version`
149
+ diz qual build está carregado.
150
+
151
+ Comandos durante uma queda da conexão (2.8.2): um clique dado enquanto a conexão com o host
152
+ está caída ou reconectando (rede instável) não se perde mais em silêncio. O comando fica
153
+ guardado, a tela avisa que a conexão está voltando, e ele é enviado no reconectar, se ainda
154
+ tiver menos de 15 s; mais velho que isso é descartado, para não atingir outra chamada. Antes,
155
+ um "encerrar" dado nesse momento deixava a chamada ativa no motor.
149
156
 
150
157
  Sem `engineUrl` nada muda: o SDK continua rodando no navegador como sempre.
151
158
 
@@ -43754,6 +43754,8 @@ const INITIAL_TRANSCRIPT = { segments: [], status: null, insight: null, interims
43754
43754
  const MAX_SEGMENTS = 300;
43755
43755
  const RECONNECT_MIN_MS = 500;
43756
43756
  const RECONNECT_MAX_MS = 5e3;
43757
+ const PENDING_COMMANDS_MAX = 10;
43758
+ const PENDING_COMMANDS_TTL_MS = 15e3;
43757
43759
  function engineWsUrl(baseUrl) {
43758
43760
  const url = new URL(baseUrl, typeof window !== "undefined" ? window.location.href : "http://localhost");
43759
43761
  url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
@@ -43771,6 +43773,7 @@ class EngineClient {
43771
43773
  this.viewWaiters = [];
43772
43774
  this.ws = null;
43773
43775
  this.reconnectDelay = RECONNECT_MIN_MS;
43776
+ this.pendingCommands = [];
43774
43777
  this.reconnectTimer = null;
43775
43778
  this.closed = false;
43776
43779
  this.iceServers = [{ urls: "stun:stun.l.google.com:19302" }];
@@ -43921,6 +43924,7 @@ class EngineClient {
43921
43924
  case "welcome": {
43922
43925
  if (Array.isArray(message.iceServers) && message.iceServers.length > 0) this.iceServers = message.iceServers;
43923
43926
  this.setState({ tabId: message.tabId, rejected: null });
43927
+ this.flushPendingCommands();
43924
43928
  this.applyView(message.view);
43925
43929
  this.log(`sou a aba ${message.tabId}`);
43926
43930
  if (this.options.autoEngage !== false && message.view.engagedTabId !== message.tabId) this.engage();
@@ -44039,8 +44043,29 @@ class EngineClient {
44039
44043
  this.send({ type: "release" });
44040
44044
  }
44041
44045
  command(command) {
44042
- this.send({ type: "command", command });
44043
- this.log(`comando: ${command.name}${command.phone ? ` ${command.phone}` : ""}`);
44046
+ if (this.ws && this.ws.readyState === WebSocket.OPEN && this.state.tabId) {
44047
+ this.send({ type: "command", command });
44048
+ this.log(`comando: ${command.name}${command.phone ? ` ${command.phone}` : ""}`);
44049
+ return;
44050
+ }
44051
+ this.pendingCommands.push({ command, at: Date.now() });
44052
+ if (this.pendingCommands.length > PENDING_COMMANDS_MAX) this.pendingCommands.shift();
44053
+ this.log(`comando: ${command.name} guardado até a conexão com o motor voltar`);
44054
+ this.setState({ lastError: "Sem conexão com o motor neste momento; o comando será enviado assim que ela voltar." });
44055
+ this.connect();
44056
+ }
44057
+ /** manda os comandos guardados que ainda fazem sentido (os velhos poderiam atingir outra chamada) */
44058
+ flushPendingCommands() {
44059
+ const now = Date.now();
44060
+ const pending = this.pendingCommands.splice(0);
44061
+ for (const entry of pending) {
44062
+ if (now - entry.at > PENDING_COMMANDS_TTL_MS) {
44063
+ this.log(`comando ${entry.command.name} descartado: a conexão demorou demais para voltar`);
44064
+ continue;
44065
+ }
44066
+ this.send({ type: "command", command: entry.command });
44067
+ this.log(`comando: ${entry.command.name} (enviado depois da reconexão)`);
44068
+ }
44044
44069
  }
44045
44070
  // ------------------------------------------------------------------ áudio
44046
44071
  setInputMuted(muted) {
@@ -60755,7 +60780,7 @@ function ClickToCallAgent({ enabled = true, pollIntervalMs, sessionToken, onTask
60755
60780
  }, [enabled, pollIntervalMs, sessionToken]);
60756
60781
  return null;
60757
60782
  }
60758
- const WIDGET_VERSION = "2.8.1";
60783
+ const WIDGET_VERSION = "2.8.2";
60759
60784
  let currentSipWebSocket = null;
60760
60785
  function sendSipUnregisterIfPossible(ws) {
60761
60786
  if (ws.readyState !== WebSocket.OPEN) return;