@phonghq/go-chat 1.0.1 → 1.0.3

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.
Files changed (186) hide show
  1. package/dist/chat/App.vue.d.ts +2 -2
  2. package/dist/chat/main.d.ts +6 -3
  3. package/dist/chat/page/customer-detail/CustomerDetail.vue.d.ts +1 -1
  4. package/dist/chat/page/home/ChatList.vue.d.ts +1 -1
  5. package/dist/chat/page/home/ChatMessage.vue.d.ts +2 -2
  6. package/dist/chat/page/home/Home.vue.d.ts +2 -2
  7. package/dist/chat/page/home/HomeHeader.vue.d.ts +1 -1
  8. package/dist/chat/page/home/InputChat.vue.d.ts +1 -1
  9. package/dist/chat/page/home/NewCustomer.vue.d.ts +1 -1
  10. package/dist/components/chat/call/Calling.vue.d.ts +1 -1
  11. package/dist/components/chat/common/input/InputSearch.vue.d.ts +1 -1
  12. package/dist/composable/useCallHelper.d.ts +1 -1
  13. package/dist/composable/useInitData.d.ts +1 -1
  14. package/dist/composable/useModalConfirm.d.ts +1 -1
  15. package/dist/go-chat.es.js +26369 -28399
  16. package/dist/go-chat.umd.js +15 -23
  17. package/dist/plugins/mqtt.d.ts +2 -1
  18. package/dist/plugins/websocket.d.ts +4 -1
  19. package/dist/style.css +1 -1
  20. package/dist/{chat → test/chat}/App.vue.js +60 -63
  21. package/dist/test/chat/main.js +6 -0
  22. package/dist/{chat/page/customer-appointment/CustomerApointment.vue.js → test/chat/page/customer-appointment/CustomerAppointment.vue.js} +5 -5
  23. package/dist/{chat → test/chat}/page/customer-check-in/CollapseCheckIn.vue.js +2 -2
  24. package/dist/{chat → test/chat}/page/customer-check-in/CustomerCheckIn.vue.js +4 -4
  25. package/dist/{chat → test/chat}/page/customer-detail/CustomerDetail.vue.js +16 -15
  26. package/dist/{chat → test/chat}/page/customer-detail/SubInformation.vue.js +1 -1
  27. package/dist/{chat → test/chat}/page/error/Error.vue.js +1 -1
  28. package/dist/{chat → test/chat}/page/home/ChatList.vue.js +11 -13
  29. package/dist/{chat → test/chat}/page/home/ChatMessage.vue.js +4 -4
  30. package/dist/{chat → test/chat}/page/home/Home.vue.js +10 -10
  31. package/dist/{chat → test/chat}/page/home/HomeHeader.vue.js +6 -6
  32. package/dist/{chat → test/chat}/page/home/InputChat.vue.js +13 -11
  33. package/dist/{chat → test/chat}/page/home/NewCustomer.vue.js +2 -2
  34. package/dist/test/components/ListenEvent.vue.js +45 -0
  35. package/dist/{components → test/components}/chat/ScrollEvent/ScrollEvent.vue.js +1 -1
  36. package/dist/{components → test/components}/chat/call/Calling.vue.js +68 -38
  37. package/dist/{components → test/components}/chat/common/collapse/CollapseBase.vue.js +1 -1
  38. package/dist/{components → test/components}/chat/common/input/InputSearch.vue.js +2 -2
  39. package/dist/{components → test/components}/chat/common/popover/PopoverBase.vue.js +1 -1
  40. package/dist/{components → test/components}/chat/layout/mobile/Footer.vue.js +10 -10
  41. package/dist/{components → test/components}/common/button/ButtonBase.vue.js +2 -2
  42. package/dist/{components → test/components}/common/button/ButtonToggle.vue.js +1 -1
  43. package/dist/{components → test/components}/common/checkbox/CCheckboxNumber.vue.js +1 -1
  44. package/dist/{components → test/components}/common/drawer/DrawerBase.vue.js +1 -1
  45. package/dist/{components → test/components}/common/dropdown/DropdownBase.vue.js +1 -1
  46. package/dist/{components → test/components}/common/input/CInputSearch.vue.js +1 -1
  47. package/dist/{components → test/components}/common/modal/ModalBase.vue.js +2 -2
  48. package/dist/{components → test/components}/common/slider/BaseSlider.vue.js +1 -1
  49. package/dist/{components → test/components}/modal/Confirm.vue.js +3 -3
  50. package/dist/{components → test/components}/ui/button/CButton.vue.js +1 -1
  51. package/dist/{components → test/components}/ui/checkbox/Checkbox.vue.js +1 -1
  52. package/dist/{components → test/components}/ui/dialog/DialogContent.vue.js +1 -1
  53. package/dist/{components → test/components}/ui/dialog/DialogDescription.vue.js +1 -1
  54. package/dist/{components → test/components}/ui/dialog/DialogFooter.vue.js +1 -1
  55. package/dist/{components → test/components}/ui/dialog/DialogHeader.vue.js +1 -1
  56. package/dist/{components → test/components}/ui/dialog/DialogScrollContent.vue.js +1 -1
  57. package/dist/{components → test/components}/ui/dialog/DialogTitle.vue.js +1 -1
  58. package/dist/{components → test/components}/ui/drawer/DrawerContent.vue.js +1 -1
  59. package/dist/{components → test/components}/ui/drawer/DrawerDescription.vue.js +1 -1
  60. package/dist/{components → test/components}/ui/drawer/DrawerFooter.vue.js +1 -1
  61. package/dist/{components → test/components}/ui/drawer/DrawerHeader.vue.js +1 -1
  62. package/dist/{components → test/components}/ui/drawer/DrawerOverlay.vue.js +1 -1
  63. package/dist/{components → test/components}/ui/drawer/DrawerTitle.vue.js +1 -1
  64. package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.js +1 -1
  65. package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuContent.vue.js +1 -1
  66. package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuItem.vue.js +1 -1
  67. package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuLabel.vue.js +1 -1
  68. package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuRadioItem.vue.js +1 -1
  69. package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuSeparator.vue.js +1 -1
  70. package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuShortcut.vue.js +1 -1
  71. package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuSubContent.vue.js +1 -1
  72. package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuSubTrigger.vue.js +1 -1
  73. package/dist/{components → test/components}/ui/popover/PopoverContent.vue.js +1 -1
  74. package/dist/{components → test/components}/ui/radio-group/RadioGroup.vue.js +1 -1
  75. package/dist/{components → test/components}/ui/radio-group/RadioGroupItem.vue.js +1 -1
  76. package/dist/{components → test/components}/ui/slider/Slider.vue.js +1 -1
  77. package/dist/{components → test/components}/ui/switch/Switch.vue.js +1 -1
  78. package/dist/{composable → test/composable}/useCallHelper.js +4 -16
  79. package/dist/{composable → test/composable}/useInitData.js +8 -6
  80. package/dist/{plugins → test/plugins}/mqtt.js +1 -2
  81. package/dist/{plugins → test/plugins}/sdk.js +3 -3
  82. package/dist/test/plugins/websocket.js +65 -0
  83. package/dist/test/types/chat/global.js +1 -0
  84. package/dist/test/types/chat/promise.js +1 -0
  85. package/dist/test/types/chat/user.js +1 -0
  86. package/dist/test/types/conversation.js +1 -0
  87. package/dist/test/types/global.js +15 -0
  88. package/dist/test/types/message.js +1 -0
  89. package/dist/{utils → test/utils}/chat/auth.js +2 -2
  90. package/dist/test/utils/chat/call.js +61 -0
  91. package/dist/{utils → test/utils}/chat/chat-router.js +1 -1
  92. package/dist/{utils → test/utils}/chat/conversation.js +1 -1
  93. package/dist/{utils → test/utils}/chat/message.js +1 -1
  94. package/dist/{utils → test/utils}/chat/user.js +1 -1
  95. package/dist/test/utils/json.js +18 -0
  96. package/dist/types/call.d.ts +4 -0
  97. package/dist/types/chat/auth.d.ts +37 -0
  98. package/dist/types/chat/global.d.ts +7 -0
  99. package/dist/types/chat/promise.d.ts +17 -0
  100. package/dist/types/global.d.ts +11 -0
  101. package/dist/types/message.d.ts +43 -0
  102. package/dist/utils/chat/auth.d.ts +1 -1
  103. package/dist/utils/chat/call.d.ts +4 -0
  104. package/dist/utils/chat/chat-router.d.ts +1 -1
  105. package/dist/utils/chat/conversation.d.ts +2 -2
  106. package/dist/utils/chat/message.d.ts +2 -2
  107. package/dist/utils/chat/user.d.ts +2 -2
  108. package/dist/utils/json.d.ts +2 -0
  109. package/package.json +1 -1
  110. package/dist/chat/main.js +0 -2
  111. package/dist/components/ListenEvent.vue.js +0 -47
  112. package/dist/plugins/websocket.js +0 -26
  113. package/dist/stores/general.d.ts +0 -48
  114. package/dist/stores/general.js +0 -39
  115. package/dist/utils/chat/call.js +0 -10
  116. /package/dist/chat/page/customer-appointment/{CustomerApointment.vue.d.ts → CustomerAppointment.vue.d.ts} +0 -0
  117. /package/dist/{assets → test/assets}/icons/IconArrowLeft.vue.js +0 -0
  118. /package/dist/{assets → test/assets}/icons/IconPhone.vue.js +0 -0
  119. /package/dist/{assets → test/assets}/icons/IconPlan.vue.js +0 -0
  120. /package/dist/{assets → test/assets}/icons/IconPlus.vue.js +0 -0
  121. /package/dist/{assets → test/assets}/icons/IconSearch.vue.js +0 -0
  122. /package/dist/{assets → test/assets}/icons/call/IconMic.vue.js +0 -0
  123. /package/dist/{assets → test/assets}/icons/call/IconPhone.vue.js +0 -0
  124. /package/dist/{assets → test/assets}/icons/call/IconPhoneCancel.vue.js +0 -0
  125. /package/dist/{assets → test/assets}/icons/call/IconSpeaker.vue.js +0 -0
  126. /package/dist/{assets → test/assets}/icons/customer-appointment/IconFilter.vue.js +0 -0
  127. /package/dist/{assets → test/assets}/icons/customer-detail/IconArrow.vue.js +0 -0
  128. /package/dist/{assets → test/assets}/icons/customer-detail/IconCheck.vue.js +0 -0
  129. /package/dist/{assets → test/assets}/icons/customer-detail/IconDate.vue.js +0 -0
  130. /package/dist/{assets → test/assets}/icons/customer-detail/IconGroup.vue.js +0 -0
  131. /package/dist/{assets → test/assets}/icons/customer-detail/IconMessage.vue.js +0 -0
  132. /package/dist/{assets → test/assets}/icons/customer-detail/IconNote.vue.js +0 -0
  133. /package/dist/{assets → test/assets}/icons/customer-detail/IconPhone.vue.js +0 -0
  134. /package/dist/{assets → test/assets}/icons/customer-detail/IconPin.vue.js +0 -0
  135. /package/dist/{assets → test/assets}/icons/customer-detail/IconSearch.vue.js +0 -0
  136. /package/dist/{components → test/components}/chat/card/CardCustomerDetail.vue.js +0 -0
  137. /package/dist/{components → test/components}/chat/common/spin/BaseSpin.vue.js +0 -0
  138. /package/dist/{components → test/components}/chat/customer/Avatar.vue.js +0 -0
  139. /package/dist/{components → test/components}/common/CustomLoading.vue.js +0 -0
  140. /package/dist/{components → test/components}/common/Notification/NotificationDescription.vue.js +0 -0
  141. /package/dist/{components → test/components}/common/collapse/BaseCollapse.vue.js +0 -0
  142. /package/dist/{components → test/components}/common/collapse/BaseCollapseItem.vue.js +0 -0
  143. /package/dist/{components → test/components}/common/popover/PopoverBase.vue.js +0 -0
  144. /package/dist/{components → test/components}/common/spin/CSpin.vue.js +0 -0
  145. /package/dist/{components → test/components}/common/tooltip/TooltipBase.vue.js +0 -0
  146. /package/dist/{components → test/components}/layout/Blank.vue.js +0 -0
  147. /package/dist/{components → test/components}/layout/Default.vue.js +0 -0
  148. /package/dist/{components → test/components}/ui/button/c-button.js +0 -0
  149. /package/dist/{components → test/components}/ui/checkbox/index.js +0 -0
  150. /package/dist/{components → test/components}/ui/collapsible/Collapsible.vue.js +0 -0
  151. /package/dist/{components → test/components}/ui/collapsible/CollapsibleContent.vue.js +0 -0
  152. /package/dist/{components → test/components}/ui/collapsible/CollapsibleTrigger.vue.js +0 -0
  153. /package/dist/{components → test/components}/ui/collapsible/index.js +0 -0
  154. /package/dist/{components → test/components}/ui/dialog/Dialog.vue.js +0 -0
  155. /package/dist/{components → test/components}/ui/dialog/DialogClose.vue.js +0 -0
  156. /package/dist/{components → test/components}/ui/dialog/DialogTrigger.vue.js +0 -0
  157. /package/dist/{components → test/components}/ui/dialog/index.js +0 -0
  158. /package/dist/{components → test/components}/ui/drawer/Drawer.vue.js +0 -0
  159. /package/dist/{components → test/components}/ui/drawer/index.js +0 -0
  160. /package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenu.vue.js +0 -0
  161. /package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuGroup.vue.js +0 -0
  162. /package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuRadioGroup.vue.js +0 -0
  163. /package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuSub.vue.js +0 -0
  164. /package/dist/{components → test/components}/ui/dropdown-menu/DropdownMenuTrigger.vue.js +0 -0
  165. /package/dist/{components → test/components}/ui/dropdown-menu/index.js +0 -0
  166. /package/dist/{components → test/components}/ui/popover/Popover.vue.js +0 -0
  167. /package/dist/{components → test/components}/ui/popover/PopoverTrigger.vue.js +0 -0
  168. /package/dist/{components → test/components}/ui/popover/index.js +0 -0
  169. /package/dist/{components → test/components}/ui/radio-group/index.js +0 -0
  170. /package/dist/{components → test/components}/ui/slider/index.js +0 -0
  171. /package/dist/{components → test/components}/ui/switch/index.js +0 -0
  172. /package/dist/{composable → test/composable}/useModalConfirm.js +0 -0
  173. /package/dist/{constant → test/constant}/color.js +0 -0
  174. /package/dist/{constant → test/constant}/datetime.js +0 -0
  175. /package/dist/{constant → test/constant}/general.js +0 -0
  176. /package/dist/{constant → test/constant}/message.js +0 -0
  177. /package/dist/{constant → test/constant}/mqtt.js +0 -0
  178. /package/dist/{constant → test/constant}/user.js +0 -0
  179. /package/dist/{lib → test/lib}/utils.js +0 -0
  180. /package/dist/{plugins → test/plugins}/axios-gci.js +0 -0
  181. /package/dist/{plugins → test/plugins}/axios.js +0 -0
  182. /package/dist/{types/chat/user.js → test/types/call.js} +0 -0
  183. /package/dist/{types/conversation.js → test/types/chat/auth.js} +0 -0
  184. /package/dist/{utils → test/utils}/debounce.js +0 -0
  185. /package/dist/{utils → test/utils}/logger.js +0 -0
  186. /package/dist/{utils → test/utils}/string-helper.js +0 -0
@@ -1,7 +1,7 @@
1
1
  /// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
2
  import { reactiveOmit } from "@vueuse/core";
3
3
  import { DropdownMenuItem, useForwardProps } from "reka-ui";
4
- import { cn } from "@/lib/utils";
4
+ import { cn } from "../../../lib/utils";
5
5
  const props = defineProps();
6
6
  const delegatedProps = reactiveOmit(props, "class");
7
7
  const forwardedProps = useForwardProps(delegatedProps);
@@ -1,7 +1,7 @@
1
1
  /// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
2
  import { reactiveOmit } from "@vueuse/core";
3
3
  import { DropdownMenuLabel, useForwardProps } from "reka-ui";
4
- import { cn } from "@/lib/utils";
4
+ import { cn } from "../../../lib/utils";
5
5
  const props = defineProps();
6
6
  const delegatedProps = reactiveOmit(props, "class");
7
7
  const forwardedProps = useForwardProps(delegatedProps);
@@ -2,7 +2,7 @@
2
2
  import { reactiveOmit } from "@vueuse/core";
3
3
  import { Circle } from "lucide-vue-next";
4
4
  import { DropdownMenuItemIndicator, DropdownMenuRadioItem, useForwardPropsEmits, } from "reka-ui";
5
- import { cn } from "@/lib/utils";
5
+ import { cn } from "../../../lib/utils";
6
6
  const props = defineProps();
7
7
  const emits = defineEmits();
8
8
  const delegatedProps = reactiveOmit(props, "class");
@@ -1,7 +1,7 @@
1
1
  /// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
2
  import { reactiveOmit } from "@vueuse/core";
3
3
  import { DropdownMenuSeparator, } from "reka-ui";
4
- import { cn } from "@/lib/utils";
4
+ import { cn } from "../../../lib/utils";
5
5
  const props = defineProps();
6
6
  const delegatedProps = reactiveOmit(props, "class");
7
7
  debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
@@ -1,5 +1,5 @@
1
1
  /// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
- import { cn } from "@/lib/utils";
2
+ import { cn } from "../../../lib/utils";
3
3
  const props = defineProps();
4
4
  debugger; /* PartiallyEnd: #3632/scriptSetup.vue */
5
5
  const __VLS_ctx = {
@@ -1,7 +1,7 @@
1
1
  /// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
2
  import { reactiveOmit } from "@vueuse/core";
3
3
  import { DropdownMenuSubContent, useForwardPropsEmits, } from "reka-ui";
4
- import { cn } from "@/lib/utils";
4
+ import { cn } from "../../../lib/utils";
5
5
  const props = defineProps();
6
6
  const emits = defineEmits();
7
7
  const delegatedProps = reactiveOmit(props, "class");
@@ -2,7 +2,7 @@
2
2
  import { reactiveOmit } from "@vueuse/core";
3
3
  import { ChevronRight } from "lucide-vue-next";
4
4
  import { DropdownMenuSubTrigger, useForwardProps, } from "reka-ui";
5
- import { cn } from "@/lib/utils";
5
+ import { cn } from "../../../lib/utils";
6
6
  const props = defineProps();
7
7
  const delegatedProps = reactiveOmit(props, "class");
8
8
  const forwardedProps = useForwardProps(delegatedProps);
@@ -1,7 +1,7 @@
1
1
  /// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
2
  import { reactiveOmit } from "@vueuse/core";
3
3
  import { PopoverContent, PopoverPortal, useForwardPropsEmits, } from "reka-ui";
4
- import { cn } from "@/lib/utils";
4
+ import { cn } from "../../../lib/utils";
5
5
  defineOptions({
6
6
  inheritAttrs: false,
7
7
  });
@@ -1,7 +1,7 @@
1
1
  /// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
2
  import { reactiveOmit } from "@vueuse/core";
3
3
  import { RadioGroupRoot, useForwardPropsEmits } from "reka-ui";
4
- import { cn } from "@/lib/utils";
4
+ import { cn } from "../../../lib/utils";
5
5
  const props = defineProps();
6
6
  const emits = defineEmits();
7
7
  const delegatedProps = reactiveOmit(props, "class");
@@ -2,7 +2,7 @@
2
2
  import { reactiveOmit } from "@vueuse/core";
3
3
  import { Circle } from "lucide-vue-next";
4
4
  import { RadioGroupIndicator, RadioGroupItem, useForwardProps, } from "reka-ui";
5
- import { cn } from "@/lib/utils";
5
+ import { cn } from "../../../lib/utils";
6
6
  const props = defineProps();
7
7
  const delegatedProps = reactiveOmit(props, "class");
8
8
  const forwardedProps = useForwardProps(delegatedProps);
@@ -1,7 +1,7 @@
1
1
  /// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
2
  import { reactiveOmit } from '@vueuse/core';
3
3
  import { SliderRange, SliderRoot, SliderThumb, SliderTrack, useForwardPropsEmits } from 'reka-ui';
4
- import { cn } from '@/lib/utils';
4
+ import { cn } from '../../../lib/utils';
5
5
  const props = defineProps();
6
6
  const emits = defineEmits();
7
7
  const delegatedProps = reactiveOmit(props, 'class');
@@ -1,7 +1,7 @@
1
1
  /// <reference types="C:/phonghq/go-chat/node_modules/.vue-global-types/vue_3.5_0.d.ts" />
2
2
  import { reactiveOmit } from '@vueuse/core';
3
3
  import { SwitchRoot, SwitchThumb, useForwardPropsEmits } from 'reka-ui';
4
- import { cn } from '@/lib/utils';
4
+ import { cn } from '../../../lib/utils';
5
5
  const props = defineProps();
6
6
  const emits = defineEmits();
7
7
  const delegatedProps = reactiveOmit(props, 'class');
@@ -1,20 +1,14 @@
1
- import { publishMessage } from '@/plugins/mqtt';
2
- import { TOPIC_DETAIL_CALL } from '@/constant/mqtt';
3
- import { getIceService } from '@/utils/chat/call';
4
- import { dataProfile } from '@/utils/chat/auth';
1
+ import { publishMessage } from '../plugins/mqtt';
2
+ import { TOPIC_DETAIL_CALL } from '../constant/mqtt';
3
+ import { getIceService } from '../utils/chat/call';
4
+ import { dataProfile } from '../utils/chat/auth';
5
5
  import { ref } from 'vue';
6
6
  export function useCallHelper() {
7
7
  let pc;
8
8
  let iceStunServiceLink = '';
9
- let iceTurnServiceLink = '';
10
9
  let iceServer = null;
11
10
  let answer;
12
11
  let offer = null;
13
- // const servers = {
14
- // iceServers: [
15
- // { urls: 'stun:stun.l.google.com:19302' }
16
- // ]
17
- // }
18
12
  const remoteAudio = () => {
19
13
  return document.getElementById('go-chat-remote-audio');
20
14
  };
@@ -22,11 +16,6 @@ export function useCallHelper() {
22
16
  return document.getElementById('go-chat-local-audio');
23
17
  };
24
18
  const userRemoter = ref(null);
25
- // const start = async () => {
26
- // localStream = await navigator?.mediaDevices?.getUserMedia({ audio: true })
27
- // const local = localAudio() as any
28
- // if (local) local.srcObject = localStream
29
- // }
30
19
  const call = async (user) => {
31
20
  userRemoter.value = user;
32
21
  await getIceServiceLink();
@@ -120,7 +109,6 @@ export function useCallHelper() {
120
109
  const res = await getIceService();
121
110
  console.log(res);
122
111
  iceStunServiceLink = res[0]?.urls[0] ?? '';
123
- iceTurnServiceLink = res[1]?.urls[0] ?? '';
124
112
  iceServer = res;
125
113
  };
126
114
  const handleOffer = async (data) => {
@@ -1,10 +1,11 @@
1
1
  import { ref } from 'vue';
2
- import { sdkInit } from '@/plugins/sdk';
3
- import { dataProfile, getProfile, loginLink } from '@/utils/chat/auth';
4
- import { routerPush } from '@/utils/chat/chat-router';
5
- import { PAGE } from '@/constant/general';
6
- import { subscribeToTopic, unsubscribeFromTopic } from '@/plugins/mqtt';
7
- import { TOPIC_DETAIL_CALL } from '@/constant/mqtt';
2
+ import { sdkInit } from '../plugins/sdk';
3
+ import { dataProfile, getProfile, loginLink } from '../utils/chat/auth';
4
+ import { routerPush } from '../utils/chat/chat-router';
5
+ import { PAGE } from '../constant/general';
6
+ import { subscribeToTopic, unsubscribeFromTopic } from '../plugins/mqtt';
7
+ import { TOPIC_DETAIL_CALL } from '../constant/mqtt';
8
+ import { getWebSocket } from '../plugins/websocket';
8
9
  //PINIA
9
10
  export const isRouterReady = ref(false);
10
11
  export function useInitData() {
@@ -38,6 +39,7 @@ export function useInitData() {
38
39
  };
39
40
  const initData = async () => {
40
41
  await getProfile();
42
+ getWebSocket();
41
43
  unsubscribeFromTopic(TOPIC_DETAIL_CALL + dataProfile.value?.id);
42
44
  subscribeToTopic(TOPIC_DETAIL_CALL + dataProfile.value?.id);
43
45
  };
@@ -1,5 +1,4 @@
1
- // import mqtt from 'mqtt/dist/mqtt.min'
2
- import mqtt from 'mqtt';
1
+ import mqtt from 'mqtt/dist/mqtt.min';
3
2
  const mqttOptions = { qos: 1, retain: false };
4
3
  // const mqttClient = ref<MqttClient | null>(null)
5
4
  let mqttClient = null;
@@ -1,8 +1,8 @@
1
1
  import Gap, { GapApiVersion } from 'gap-nodejs-sdk';
2
2
  import { GapMiniAppSdk } from 'gap-miniapp-sdk';
3
- import logger from '@/utils/logger';
4
- import { loginTenant, setDataLogin } from '@/utils/chat/auth';
5
- import { setAxiosGciInstance } from '@/plugins/axios-gci';
3
+ import logger from '../utils/logger';
4
+ import { loginTenant, setDataLogin } from '../utils/chat/auth';
5
+ import { setAxiosGciInstance } from '../plugins/axios-gci';
6
6
  const baseSdk = new Gap.BaseApi(GapApiVersion.V1);
7
7
  const gapMiniAppSdk = (function () {
8
8
  let instance;
@@ -0,0 +1,65 @@
1
+ import { tryParseJson } from '../utils/json';
2
+ let socket = null;
3
+ let dataCallBack = [];
4
+ export function initWebSocket(server) {
5
+ // Create WebSocket connection.
6
+ socket = new WebSocket('wss://web-socket.dev01.dtsmart.dev');
7
+ // socket.addEventListener('open', (event: any) => {
8
+ // console.log('fffffff')
9
+ // socket.send('Hello Server!')
10
+ // })
11
+ //
12
+ // socket.addEventListener('message', (event: any) => {
13
+ // console.log('Message from server ', event.data)
14
+ // })
15
+ socket.onopen = (event) => {
16
+ console.log('Connected!');
17
+ };
18
+ socket.onmessage = (event) => {
19
+ const data = tryParseJson(event.data);
20
+ dataCallBack.forEach((e) => {
21
+ e.callBack(data);
22
+ });
23
+ };
24
+ socket.onclose = (event) => {
25
+ console.log('Disconnected:', event.reason);
26
+ };
27
+ socket.onerror = (event) => {
28
+ console.error('Socket error:', event);
29
+ };
30
+ }
31
+ const socketSend = (data) => {
32
+ let request = typeof data == 'string' ? data : JSON.stringify(data);
33
+ socket.send(request);
34
+ };
35
+ export const getWebSocket = async () => {
36
+ const url = 'https://web-socket.dev01.dtsmart.dev/ws/connect';
37
+ try {
38
+ const response = await fetch(url, {
39
+ method: 'POST',
40
+ body: JSON.stringify({
41
+ clientId: 'test1'
42
+ }),
43
+ headers: {
44
+ Authorization: 'Bearer -Qixt-ZztiBA5Dxl-EIWG7f2TDhK-ZCj'
45
+ }
46
+ });
47
+ if (!response.ok) {
48
+ throw new Error(`Response status: ${response.status}`);
49
+ }
50
+ const result = await response.json();
51
+ }
52
+ catch (error) {
53
+ console.error(error.message);
54
+ }
55
+ };
56
+ export const addHandleWebSK = (key, callBack) => {
57
+ removeHandleWebSK(key);
58
+ dataCallBack.push({ key, callBack });
59
+ };
60
+ export const removeHandleWebSK = (key) => {
61
+ const index = dataCallBack.findIndex((e) => e.key === key);
62
+ if (index > -1) {
63
+ dataCallBack.splice(index, 1);
64
+ }
65
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ export {};
2
+ // declare global {
3
+ // /**
4
+ // * Now declare things that go in the global namespace,
5
+ // * or augment existing declarations in the global namespace.
6
+ // */
7
+ // type AddPromise<T = unknown> = T & {
8
+ // resolve: Resolve
9
+ // reject?: Reject
10
+ // }
11
+ //
12
+ // // PROMISE
13
+ // declare type Resolve = typeof ReturnType<Promise.resolve>
14
+ // declare type Reject = typeof ReturnType<Promise.reject>
15
+ // }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
- import axios from '@/plugins/axios';
2
- import { gapMiniAppSdk } from '@/plugins/sdk';
1
+ import axios from '../../plugins/axios';
2
+ import { gapMiniAppSdk } from '../../plugins/sdk';
3
3
  import { ref } from 'vue';
4
4
  export const dataProfile = ref(null);
5
5
  export const dataLoginLink = ref(null);
@@ -0,0 +1,61 @@
1
+ import axios from '../../plugins/axios';
2
+ import { dataProfile } from '../../utils/chat/auth';
3
+ const BARE_WEBSOCKET_URL = 'https://web-socket.dev01.dtsmart.dev';
4
+ // const BARE_WEBSOCKET_URL = 'http://192.168.1.173:3000'
5
+ export const getIceService = async () => {
6
+ const res = await axios.post('/api/v1/message/call/ice-servers', {
7
+ key_id: '3dc07e93f89e44ef5d5ff98c91edb520',
8
+ api_token: 'c0a60a3d2b0f490b2c99fd7ff095ed1218fd7eda55c80c8b70efc9e0b8dfcd85'
9
+ }, {
10
+ token: '3VbvrMLtH6b0b9vBe0mhJz9G9NKyATiL'
11
+ });
12
+ return res;
13
+ };
14
+ // export const callClient = async (body: IResCall): Promise<any> => {
15
+ // const res = await axios.post('/call/answer', body, {
16
+ // })
17
+ // return res
18
+ // }
19
+ export const callClient = async (body) => {
20
+ const url = BARE_WEBSOCKET_URL + '/call/answer';
21
+ try {
22
+ const response = await fetch(url, {
23
+ method: 'POST',
24
+ body: JSON.stringify(body),
25
+ headers: {
26
+ ['Content-Type']: 'application/json'
27
+ }
28
+ });
29
+ if (!response.ok) {
30
+ throw new Error(`Response status: ${response.status}`);
31
+ }
32
+ const result = await response.json();
33
+ console.log(result);
34
+ }
35
+ catch (error) {
36
+ console.error(error.message);
37
+ }
38
+ };
39
+ export const callOutBound = async (user) => {
40
+ const url = BARE_WEBSOCKET_URL + '/call/outbound';
41
+ try {
42
+ const response = await fetch(url, {
43
+ method: 'POST',
44
+ body: JSON.stringify({
45
+ from: dataProfile.value?.phone,
46
+ to: user?.phone ?? ''
47
+ }),
48
+ headers: {
49
+ ['Content-Type']: 'application/json'
50
+ }
51
+ });
52
+ if (!response.ok) {
53
+ throw new Error(`Response status: ${response.status}`);
54
+ }
55
+ const result = await response.json();
56
+ console.log(result);
57
+ }
58
+ catch (error) {
59
+ console.error(error.message);
60
+ }
61
+ };
@@ -1,5 +1,5 @@
1
1
  import { ref } from 'vue';
2
- import { PAGE } from '@/constant/general';
2
+ import { PAGE } from '../../constant/general';
3
3
  export const currentPage = ref(PAGE.HOME);
4
4
  let beforeEach = null;
5
5
  export const routerPush = (page) => {
@@ -1,4 +1,4 @@
1
- import axios from '@/plugins/axios';
1
+ import axios from '../../plugins/axios';
2
2
  export const getConversation = async (param) => {
3
3
  const res = await axios.get('/api/v1/message/conversation/get-conversation', {
4
4
  params: param
@@ -1,4 +1,4 @@
1
- import axios from '@/plugins/axios';
1
+ import axios from '../../plugins/axios';
2
2
  export const getMessage = async (params) => {
3
3
  const res = await axios.get('/api/v1/message/message/get-message', {
4
4
  params
@@ -1,5 +1,5 @@
1
1
  import { ref } from 'vue';
2
- import axios from '@/plugins/axios-gci';
2
+ import axios from '../../plugins/axios-gci';
3
3
  import dayjs from 'dayjs';
4
4
  export const user = ref(null);
5
5
  export const userHistory = ref(null);
@@ -0,0 +1,18 @@
1
+ export const isJsonString = (str) => {
2
+ try {
3
+ JSON.parse(str);
4
+ }
5
+ catch (e) {
6
+ return false;
7
+ }
8
+ return true;
9
+ };
10
+ export const tryParseJson = (data) => {
11
+ try {
12
+ const result = JSON.parse(data);
13
+ return result;
14
+ }
15
+ catch (e) {
16
+ return data;
17
+ }
18
+ };
@@ -0,0 +1,4 @@
1
+ export type IResCall = {
2
+ from: string;
3
+ to: string;
4
+ };
@@ -0,0 +1,37 @@
1
+ interface IBodyLoginTenant {
2
+ tenant_id: string;
3
+ }
4
+ interface IResLoginLink {
5
+ token: string;
6
+ refresh_token: string;
7
+ conversation_id: number;
8
+ receiver_id: number;
9
+ }
10
+ interface IBodyLoginCustomer {
11
+ phone: string;
12
+ }
13
+ interface IBodyVerifyOTP {
14
+ session_uuid: string;
15
+ phone: string;
16
+ otp: string;
17
+ }
18
+ interface IResProfile {
19
+ id: number;
20
+ username: string;
21
+ tenant_id: string | null;
22
+ phone: string;
23
+ avatar: string | null;
24
+ user_type: 'customer' | 'tenant';
25
+ color: string;
26
+ }
27
+ interface IPramsLoginLink {
28
+ tenant_id: string;
29
+ phone: string;
30
+ message: string;
31
+ customer_name: string;
32
+ business_name: string;
33
+ }
34
+ interface IRefreshToken {
35
+ refresh_token: string;
36
+ }
37
+ export type { IBodyLoginTenant, IBodyLoginCustomer, IBodyVerifyOTP, IResProfile, IPramsLoginLink, IRefreshToken, IResLoginLink };
@@ -0,0 +1,7 @@
1
+ export type GoChatProps = {
2
+ token?: string;
3
+ id?: string;
4
+ domain?: string;
5
+ response?: PAGE_RESPONSE;
6
+ };
7
+ export type PAGE_RESPONSE = 'mobile' | 'tablet';
@@ -0,0 +1,17 @@
1
+ export type ConfirmPayload = {
2
+ headerTitle?: string;
3
+ bodyTitle?: string;
4
+ bodyImage?: string;
5
+ bodyMessage?: string;
6
+ confirmButtonText?: string;
7
+ cancelButtonText?: string;
8
+ timeOut?: number;
9
+ type?: 'confirm' | 'information';
10
+ };
11
+ export type ConfirmPayloadPromise = AddPromise<ConfirmPayload>;
12
+ export type AddPromise<T = unknown> = T & {
13
+ resolve: Resolve;
14
+ reject?: Reject;
15
+ };
16
+ export type Resolve = any;
17
+ export type Reject = any;
@@ -0,0 +1,11 @@
1
+ export {};
2
+ export type DataWithMetaResponse<T> = {
3
+ items: T;
4
+ _meta: MetaResponse;
5
+ };
6
+ export type MetaResponse = {
7
+ totalCount: number;
8
+ pageCount: number;
9
+ currentPage: number;
10
+ perPage: number;
11
+ };
@@ -0,0 +1,43 @@
1
+ import { MessageState } from '../constant/message';
2
+ export type IResUser = {
3
+ id: string;
4
+ username: string;
5
+ phone: string;
6
+ avatar: string | null;
7
+ tenant_id: string | null;
8
+ conversation_id: number;
9
+ color: string;
10
+ status: number;
11
+ last_offline_at: string;
12
+ };
13
+ export type IResMessage = {
14
+ id: number | string;
15
+ conversation_id: number;
16
+ sender_id: number;
17
+ receiver_id: number;
18
+ message: string | null;
19
+ created_at: string;
20
+ attachments: IAttachment[];
21
+ state?: MessageStateType;
22
+ error?: string;
23
+ };
24
+ export interface IAttachment {
25
+ file_name: string;
26
+ file_path: string;
27
+ file_local?: Blob;
28
+ mime?: string;
29
+ size?: number;
30
+ }
31
+ export type IResUploadImage = {
32
+ files: IUploadFile[];
33
+ };
34
+ export type IUploadFile = {
35
+ name: string;
36
+ type: string;
37
+ size: number;
38
+ base_url: string;
39
+ path: string;
40
+ url: string;
41
+ delete_url: string;
42
+ };
43
+ export type MessageStateType = typeof MessageState[keyof typeof MessageState];
@@ -1,4 +1,4 @@
1
- import type { IResLoginLink, IResProfile } from '@/types/chat/auth';
1
+ import type { IResLoginLink, IResProfile } from '../../types/chat/auth';
2
2
  interface IBodyLoginTenant {
3
3
  tenant_id: string;
4
4
  }
@@ -1 +1,5 @@
1
+ import type { IResUser } from '../../types/message';
2
+ import type { IResCall } from '../../types/call';
1
3
  export declare const getIceService: () => Promise<import("axios").AxiosResponse<any, any>>;
4
+ export declare const callClient: (body: IResCall) => Promise<void>;
5
+ export declare const callOutBound: (user: IResUser) => Promise<void>;
@@ -1,3 +1,3 @@
1
- import { PAGE } from '@/constant/general';
1
+ import { PAGE } from '../../constant/general';
2
2
  export declare const currentPage: import("vue").Ref<PAGE, PAGE>;
3
3
  export declare const routerPush: (page: PAGE) => void;
@@ -1,3 +1,3 @@
1
- import type { IConversation, IParamGetConversation } from '@/types/conversation';
2
- import type { DataWithMetaResponse } from '@/types/global';
1
+ import type { IConversation, IParamGetConversation } from '../../types/conversation';
2
+ import type { DataWithMetaResponse } from '../../types/global';
3
3
  export declare const getConversation: (param: IParamGetConversation) => Promise<DataWithMetaResponse<IConversation[]>>;
@@ -1,5 +1,5 @@
1
- import type { DataWithMetaResponse } from '@/types/global';
2
- import type { IResMessage, IResUser, IUploadFile } from '@/types/message';
1
+ import type { DataWithMetaResponse } from '../../types/global';
2
+ import type { IResMessage, IResUser, IUploadFile } from '../../types/message';
3
3
  interface IParamsMessage {
4
4
  page: number;
5
5
  receiver_id: string;
@@ -1,5 +1,5 @@
1
- import type { IResUser } from '@/types/message';
2
- import type { GetCustomerHistoryResponse } from '@/types/chat/user';
1
+ import type { IResUser } from '../../types/message';
2
+ import type { GetCustomerHistoryResponse } from '../../types/chat/user';
3
3
  export declare const user: import("vue").Ref<{
4
4
  id: string;
5
5
  username: string;
@@ -0,0 +1,2 @@
1
+ export declare const isJsonString: (str: string) => boolean;
2
+ export declare const tryParseJson: (data: any) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phonghq/go-chat",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist"
package/dist/chat/main.js DELETED
@@ -1,2 +0,0 @@
1
- import AppComponent from "./App.vue";
2
- export { AppComponent };