@menuia/react 1.5.1 → 1.5.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/dist/index.js CHANGED
@@ -43,9 +43,15 @@ var import_react2 = __toESM(require("react"));
43
43
  var import_react = require("react");
44
44
  var import_core = require("@menuia/core");
45
45
  var normalizar = (s) => (s || "").trim().replace(/\s+/g, " ").toLowerCase();
46
+ var ehIdLocal = (id) => /^(user|assistant)_\d/.test(id || "");
46
47
  function mesmaMensagem(lista, msg) {
47
48
  const alvo = normalizar(msg.content);
48
- return lista.some((m) => m.id === msg.id || !!alvo && m.role === msg.role && normalizar(m.content) === alvo);
49
+ return lista.some((m) => {
50
+ if (m.id === msg.id) return true;
51
+ if (!alvo || m.role !== msg.role) return false;
52
+ if (normalizar(m.content) !== alvo) return false;
53
+ return ehIdLocal(m.id) || ehIdLocal(msg.id);
54
+ });
49
55
  }
50
56
  var vazia = (m) => !normalizar(m.content || "") && !m.mediaUrl;
51
57
  function useMenuIA(config) {
package/dist/index.mjs CHANGED
@@ -5,9 +5,15 @@ import React, { useState as useState2, useRef as useRef2, useEffect as useEffect
5
5
  import { useState, useEffect, useRef, useCallback } from "react";
6
6
  import { MenuIAClient } from "@menuia/core";
7
7
  var normalizar = (s) => (s || "").trim().replace(/\s+/g, " ").toLowerCase();
8
+ var ehIdLocal = (id) => /^(user|assistant)_\d/.test(id || "");
8
9
  function mesmaMensagem(lista, msg) {
9
10
  const alvo = normalizar(msg.content);
10
- return lista.some((m) => m.id === msg.id || !!alvo && m.role === msg.role && normalizar(m.content) === alvo);
11
+ return lista.some((m) => {
12
+ if (m.id === msg.id) return true;
13
+ if (!alvo || m.role !== msg.role) return false;
14
+ if (normalizar(m.content) !== alvo) return false;
15
+ return ehIdLocal(m.id) || ehIdLocal(msg.id);
16
+ });
11
17
  }
12
18
  var vazia = (m) => !normalizar(m.content || "") && !m.mediaUrl;
13
19
  function useMenuIA(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@menuia/react",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "MenuIA Chat SDK - React Component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",