whyuzeim 1.1.32 → 1.1.34

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.
@@ -12,18 +12,17 @@ var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/esm/asyncToGener
12
12
  var _defineProperty = require('@babel/runtime-corejs3/helpers/esm/defineProperty');
13
13
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/esm/slicedToArray');
14
14
  var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
15
+ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
15
16
  var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
16
17
  var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
17
18
  var _setInterval = require('@babel/runtime-corejs3/core-js-stable/set-interval');
18
19
  var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
19
20
  var React = require('react');
20
21
  var agoraChatUikit = require('agora-chat-uikit');
21
- var jsrsasign = require('jsrsasign');
22
22
  var context = require('../IM/context.js');
23
23
  var type = require('../type.js');
24
24
  var tools = require('../tools.js');
25
25
  var avatar_default = require('../Icon/avatar_default.svg.js');
26
- var encryption = require('../IM/encryption.js');
27
26
  require('./style/index.scss');
28
27
 
29
28
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -39,6 +38,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
39
38
  var _useSDK = agoraChatUikit.useSDK(),
40
39
  MessageSDK = _useSDK.ChatSDK;
41
40
  var manulLoginRef = React.useRef(false);
41
+ var _useChatContext = agoraChatUikit.useChatContext(),
42
+ repliedMessage = _useChatContext.repliedMessage;
43
+ console.log(_JSON$stringify(repliedMessage), 'dfsfs');
42
44
  var _useContext = React.useContext(context.Context),
43
45
  http = _useContext.http,
44
46
  userInfo = _useContext.userInfo;
@@ -61,9 +63,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
61
63
  currentConversation = _useState6[0],
62
64
  setCurrentConversation = _useState6[1];
63
65
  var _useState7 = React.useState(true),
64
- _useState8 = _slicedToArray(_useState7, 2),
65
- isAgent = _useState8[0],
66
- setIsAgent = _useState8[1];
66
+ _useState8 = _slicedToArray(_useState7, 2);
67
+ _useState8[0];
68
+ var setIsAgent = _useState8[1];
67
69
  var renderTxtMsg = function renderTxtMsg(msg) {
68
70
  var _userInfo$uid;
69
71
  var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid = userInfo.uid) === null || _userInfo$uid === void 0 ? void 0 : _userInfo$uid.toLowerCase());
@@ -317,31 +319,31 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
317
319
  setLoading(!currentLoginState);
318
320
  if (!agoraChatUikit.rootStore.loginState && !manulLoginRef.current && !window.AGAIN_ENTER_IM_INIT) {
319
321
  manulLoginRef.current = true;
320
- http.get("/capi/account/imuser/getkeypair", {
321
- params: {
322
- type: 2
323
- }
324
- }).then(function (result1) {
325
- var publickey = result1.data.data.publickey;
326
- // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
327
- var publicPemKey = "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
328
- var pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
329
- var enc = jsrsasign.KJUR.crypto.Cipher.encrypt(encryption.aesKey, pub, "RSAOAEP");
330
- http.get("/capi/account/imuser/getutoken", {
331
- params: {
332
- type: 2,
333
- token: jsrsasign.hextob64(enc)
334
- }
335
- }).then(function (result2) {
336
- var token = encryption.aesDecrypt(result2.data.data.utoken, encryption.aesKey);
337
- client.open({
338
- user: userInfo.uid,
339
- accessToken: token
340
- });
341
- })["catch"](function (error) {
342
- console.log(error, 'rewrew');
343
- });
344
- });
322
+ // http.get("/capi/account/imuser/getkeypair", {
323
+ // params: { type: 2 },
324
+ // }).then((result1)=>{
325
+ // const publickey = result1.data.data.publickey;
326
+ // // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
327
+ // const publicPemKey =
328
+ // "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
329
+ // const pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
330
+ // const enc = jsrsasign.KJUR.crypto.Cipher.encrypt(
331
+ // aesKey,
332
+ // pub as jsrsasign.RSAKey,
333
+ // "RSAOAEP"
334
+ // );
335
+ // http.get("/capi/account/imuser/getutoken", {
336
+ // params: { type: 2, token: jsrsasign.hextob64(enc) },
337
+ // }).then((result2)=>{
338
+ // const token = aesDecrypt(result2.data.data.utoken, aesKey);
339
+ // client.open({
340
+ // user: userInfo.uid,
341
+ // accessToken:token,
342
+ // })
343
+ // }).catch(error=>{
344
+ // console.log(error,'rewrew')
345
+ // })
346
+ // })
345
347
  }
346
348
  if (currentLoginState && props.conversationId) {
347
349
  initConversation();
@@ -378,7 +380,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
378
380
  }, [getHeaderInfo, initConversation, props.conversationId]);
379
381
  var handleSendMessage = /*#__PURE__*/function () {
380
382
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(text) {
381
- var txtMessage, cuiScrollList, cuiScrollListWrap, htmlString, template, node;
383
+ var txtMessage;
382
384
  return _regeneratorRuntime.wrap(function _callee$(_context2) {
383
385
  while (1) switch (_context2.prev = _context2.next) {
384
386
  case 0:
@@ -399,22 +401,6 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
399
401
  _context2.next = 6;
400
402
  return agoraChatUikit.rootStore.messageStore.sendMessage(txtMessage);
401
403
  case 6:
402
- if (isAgent) {
403
- cuiScrollList = document.querySelector(".cui-scrollList div");
404
- cuiScrollListWrap = document.querySelector(".cui-scrollList");
405
- if (cuiScrollList) {
406
- htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\">Mar</span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
407
- template = document.createElement('template');
408
- template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
409
- node = template.content.firstChild;
410
- if (node) {
411
- cuiScrollList.appendChild(node);
412
- cuiScrollListWrap === null || cuiScrollListWrap === void 0 || cuiScrollListWrap.scrollTo({
413
- top: 1000000000
414
- });
415
- }
416
- }
417
- }
418
404
  afterSendMsg(txtMessage);
419
405
  _context2.next = 13;
420
406
  break;
@@ -448,18 +434,6 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
448
434
  return _ref4.apply(this, arguments);
449
435
  };
450
436
  }();
451
- // useEffect(()=>{
452
- // if(client){
453
- // client.addEventHandler("UIKitMessage", {
454
- // onChannelMessage(message:any){
455
- // console.log(JSON.stringify(message),'dfsfsd1')
456
- // },
457
- // onTextMessage(message:any){
458
- // console.log(JSON.stringify(message),'dfsfsd2')
459
- // }
460
- // })
461
- // }
462
- // },[client])
463
437
  return /*#__PURE__*/React.createElement("div", {
464
438
  className: "bg-[var(--im-main-backgroundColor)] im-agent-mid ".concat((_props$className = props.className) !== null && _props$className !== void 0 ? _props$className : "", " w-full h-full overflow-hidden flex flex-col")
465
439
  }, loading ? /*#__PURE__*/React.createElement("div", {
@@ -10,18 +10,17 @@ import _asyncToGenerator from '@babel/runtime-corejs3/helpers/esm/asyncToGenerat
10
10
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
11
11
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
12
12
  import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
13
+ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
13
14
  import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
14
15
  import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
15
16
  import _setInterval from '@babel/runtime-corejs3/core-js-stable/set-interval';
16
17
  import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
17
18
  import React, { useRef, useContext, useState, useCallback, useEffect } from 'react';
18
- import { useClient, useSDK, rootStore, MessageList, MessageInput, ImageMessage, FileMessage, VideoMessage, BaseMessage } from 'agora-chat-uikit';
19
- import jsrsasign from 'jsrsasign';
19
+ import { useClient, useSDK, useChatContext, rootStore, MessageList, MessageInput, ImageMessage, FileMessage, VideoMessage, BaseMessage } from 'agora-chat-uikit';
20
20
  import { Context } from '../IM/context.js';
21
21
  import { commonMessageInputConfig, commonMessageProps } from '../type.js';
22
22
  import { reportAgentInUse } from '../tools.js';
23
23
  import img from '../Icon/avatar_default.svg.js';
24
- import { aesKey, aesDecrypt } from '../IM/encryption.js';
25
24
  import './style/index.scss';
26
25
 
27
26
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -37,6 +36,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
37
36
  var _useSDK = useSDK(),
38
37
  MessageSDK = _useSDK.ChatSDK;
39
38
  var manulLoginRef = useRef(false);
39
+ var _useChatContext = useChatContext(),
40
+ repliedMessage = _useChatContext.repliedMessage;
41
+ console.log(_JSON$stringify(repliedMessage), 'dfsfs');
40
42
  var _useContext = useContext(Context),
41
43
  http = _useContext.http,
42
44
  userInfo = _useContext.userInfo;
@@ -59,9 +61,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
59
61
  currentConversation = _useState6[0],
60
62
  setCurrentConversation = _useState6[1];
61
63
  var _useState7 = useState(true),
62
- _useState8 = _slicedToArray(_useState7, 2),
63
- isAgent = _useState8[0],
64
- setIsAgent = _useState8[1];
64
+ _useState8 = _slicedToArray(_useState7, 2);
65
+ _useState8[0];
66
+ var setIsAgent = _useState8[1];
65
67
  var renderTxtMsg = function renderTxtMsg(msg) {
66
68
  var _userInfo$uid;
67
69
  var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid = userInfo.uid) === null || _userInfo$uid === void 0 ? void 0 : _userInfo$uid.toLowerCase());
@@ -315,31 +317,31 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
315
317
  setLoading(!currentLoginState);
316
318
  if (!rootStore.loginState && !manulLoginRef.current && !window.AGAIN_ENTER_IM_INIT) {
317
319
  manulLoginRef.current = true;
318
- http.get("/capi/account/imuser/getkeypair", {
319
- params: {
320
- type: 2
321
- }
322
- }).then(function (result1) {
323
- var publickey = result1.data.data.publickey;
324
- // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
325
- var publicPemKey = "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
326
- var pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
327
- var enc = jsrsasign.KJUR.crypto.Cipher.encrypt(aesKey, pub, "RSAOAEP");
328
- http.get("/capi/account/imuser/getutoken", {
329
- params: {
330
- type: 2,
331
- token: jsrsasign.hextob64(enc)
332
- }
333
- }).then(function (result2) {
334
- var token = aesDecrypt(result2.data.data.utoken, aesKey);
335
- client.open({
336
- user: userInfo.uid,
337
- accessToken: token
338
- });
339
- })["catch"](function (error) {
340
- console.log(error, 'rewrew');
341
- });
342
- });
320
+ // http.get("/capi/account/imuser/getkeypair", {
321
+ // params: { type: 2 },
322
+ // }).then((result1)=>{
323
+ // const publickey = result1.data.data.publickey;
324
+ // // const rsaStr = encryption.rsaEncrypt(this.aesKey, publickey)
325
+ // const publicPemKey =
326
+ // "-----BEGIN PUBLIC KEY-----\n" + publickey + "\n-----END PUBLIC KEY-----";
327
+ // const pub = jsrsasign.KEYUTIL.getKey(publicPemKey);
328
+ // const enc = jsrsasign.KJUR.crypto.Cipher.encrypt(
329
+ // aesKey,
330
+ // pub as jsrsasign.RSAKey,
331
+ // "RSAOAEP"
332
+ // );
333
+ // http.get("/capi/account/imuser/getutoken", {
334
+ // params: { type: 2, token: jsrsasign.hextob64(enc) },
335
+ // }).then((result2)=>{
336
+ // const token = aesDecrypt(result2.data.data.utoken, aesKey);
337
+ // client.open({
338
+ // user: userInfo.uid,
339
+ // accessToken:token,
340
+ // })
341
+ // }).catch(error=>{
342
+ // console.log(error,'rewrew')
343
+ // })
344
+ // })
343
345
  }
344
346
  if (currentLoginState && props.conversationId) {
345
347
  initConversation();
@@ -376,7 +378,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
376
378
  }, [getHeaderInfo, initConversation, props.conversationId]);
377
379
  var handleSendMessage = /*#__PURE__*/function () {
378
380
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(text) {
379
- var txtMessage, cuiScrollList, cuiScrollListWrap, htmlString, template, node;
381
+ var txtMessage;
380
382
  return _regeneratorRuntime.wrap(function _callee$(_context2) {
381
383
  while (1) switch (_context2.prev = _context2.next) {
382
384
  case 0:
@@ -397,22 +399,6 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
397
399
  _context2.next = 6;
398
400
  return rootStore.messageStore.sendMessage(txtMessage);
399
401
  case 6:
400
- if (isAgent) {
401
- cuiScrollList = document.querySelector(".cui-scrollList div");
402
- cuiScrollListWrap = document.querySelector(".cui-scrollList");
403
- if (cuiScrollList) {
404
- htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\">Mar</span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
405
- template = document.createElement('template');
406
- template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
407
- node = template.content.firstChild;
408
- if (node) {
409
- cuiScrollList.appendChild(node);
410
- cuiScrollListWrap === null || cuiScrollListWrap === void 0 || cuiScrollListWrap.scrollTo({
411
- top: 1000000000
412
- });
413
- }
414
- }
415
- }
416
402
  afterSendMsg(txtMessage);
417
403
  _context2.next = 13;
418
404
  break;
@@ -446,18 +432,6 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
446
432
  return _ref4.apply(this, arguments);
447
433
  };
448
434
  }();
449
- // useEffect(()=>{
450
- // if(client){
451
- // client.addEventHandler("UIKitMessage", {
452
- // onChannelMessage(message:any){
453
- // console.log(JSON.stringify(message),'dfsfsd1')
454
- // },
455
- // onTextMessage(message:any){
456
- // console.log(JSON.stringify(message),'dfsfsd2')
457
- // }
458
- // })
459
- // }
460
- // },[client])
461
435
  return /*#__PURE__*/React.createElement("div", {
462
436
  className: "bg-[var(--im-main-backgroundColor)] im-agent-mid ".concat((_props$className = props.className) !== null && _props$className !== void 0 ? _props$className : "", " w-full h-full overflow-hidden flex flex-col")
463
437
  }, loading ? /*#__PURE__*/React.createElement("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whyuzeim",
3
- "version": "1.1.32",
3
+ "version": "1.1.34",
4
4
  "description": "im componenets",
5
5
  "main": "cjs/index.js",
6
6
  "module": "es/index.js",