Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/**/*.d.ts
81 changes: 81 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
declare module "tawk-messenger-react" {
import type React from "react";
type CallbackFunc = (...args: any[]) => any;

export type TawkAPI = {
onLoad: CallbackFunc;
onStatusChange: CallbackFunc;
onBeforeLoad: CallbackFunc;
onChatMaximized: CallbackFunc;
onChatMinimized: CallbackFunc;
onChatHidden: CallbackFunc;
onChatStarted: CallbackFunc;
onChatEnded: CallbackFunc;
onPrechatSubmit: CallbackFunc;
onOfflineSubmit: CallbackFunc;
onChatMessageVisitor: CallbackFunc;
onChatMessageAgent: CallbackFunc;
onChatMessageSystem: CallbackFunc;
onAgentJoinChat: CallbackFunc;
onAgentLeaveChat: CallbackFunc;
onChatSatisfaction: CallbackFunc;
onVisitorNameChanged: CallbackFunc;
onFileUpload: CallbackFunc;
onTagsUpdated: CallbackFunc;
onUnreadCountChanged: CallbackFunc;
visitor: { name: string; email: string };
maximize: CallbackFunc;
minimize: CallbackFunc;
toggle: CallbackFunc;
popup: CallbackFunc;
getWindowType: () => "inline" | "embed";
showWidget: CallbackFunc;
hideWidget: CallbackFunc;
toggleVisibility: CallbackFunc;
getStatus: () => "online" | "away" | "offline";
isChatMaximized: () => boolean;
isChatMinimized: () => boolean;
isChatHidden: () => boolean;
isChatOngoing: () => boolean;
isVisitorEngaged: () => boolean;
endChat: () => boolean;
setAttributes: (
attributes: Record<string, string | number>,
errCallback: (err?: any) => any
) => any;
addEvent: (eventName: string, eventData: any) => any;
addTags: (tags: string[]) => any;
removeTags: (tags: string[]) => any;
customStyle: Record<string, any>;
};
interface TawkMessengerProps {
propertyId: string;
widgetId: string;
embedId?: string;
customStyle?: any;
onLoad?: CallbackFunc;
onStatusChange?: CallbackFunc;
onBeforeLoad?: CallbackFunc;
onChatMaximized?: CallbackFunc;
onChatMinimized?: CallbackFunc;
onChatHidden?: CallbackFunc;
onChatStarted?: CallbackFunc;
onChatEnded?: CallbackFunc;
onPrechatSubmit?: CallbackFunc;
onOfflineSubmit?: CallbackFunc;
onChatMessageVisitor?: CallbackFunc;
onChatMessageAgent?: CallbackFunc;
onChatMessageSystem?: CallbackFunc;
onAgentJoinChat?: CallbackFunc;
onAgentLeaveChat?: CallbackFunc;
onChatSatisfaction?: CallbackFunc;
onVisitorNameChanged?: CallbackFunc;
onFileUpload?: CallbackFunc;
onTagsUpdated?: CallbackFunc;
onUnreadCountChanged?: CallbackFunc;
ref?: React.Ref<TawkAPI>;
}

const TawkMessenger: React.SFC<TawkMessengerProps>;
export default TawkMessenger;
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@
"react-scripts": "4.0.3"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
"eslint-plugin-jest": "^24.7.0",
"eslint-plugin-react": "^7.28.0",
"@testing-library/jest-dom": "^5.15.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3"
"@testing-library/user-event": "^12.8.3",
"@types/react": "^17.0.43",
"babel-eslint": "^10.1.0",
"eslint-plugin-jest": "^24.7.0",
"eslint-plugin-react": "^7.28.0"
},
"eslintConfig": {
"extends": [
Expand Down
27 changes: 27 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"esModuleInterop": true,
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"strictNullChecks": true,
"include": [
"src"
]
}
104 changes: 76 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1752,18 +1752,37 @@
"resolved" "https://registry.npmjs.org/@types/prettier/-/prettier-2.4.2.tgz"
"version" "2.4.2"

"@types/prop-types@*":
"integrity" "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ=="
"resolved" "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.4.tgz"
"version" "15.7.4"

"@types/q@^1.5.1":
"integrity" "sha512-L28j2FcJfSZOnL1WBjDYp2vUHCeIFlyYI/53EwD/rKUBQ7MtUUfbQWiyKJGpcnv4/WgrhWsFKrcPstcAt/J0tQ=="
"resolved" "https://registry.npmjs.org/@types/q/-/q-1.5.5.tgz"
"version" "1.5.5"

"@types/react@^17.0.43":
"integrity" "sha512-8Q+LNpdxf057brvPu1lMtC5Vn7J119xrP1aq4qiaefNioQUYANF/CYeK4NsKorSZyUGJ66g0IM+4bbjwx45o2A=="
"resolved" "https://registry.npmjs.org/@types/react/-/react-17.0.43.tgz"
"version" "17.0.43"
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
"csstype" "^3.0.2"

"@types/[email protected]":
"integrity" "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ=="
"resolved" "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz"
"version" "0.0.8"
dependencies:
"@types/node" "*"

"@types/scheduler@*":
"integrity" "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="
"resolved" "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz"
"version" "0.16.2"

"@types/source-list-map@*":
"integrity" "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA=="
"resolved" "https://registry.npmjs.org/@types/source-list-map/-/source-list-map-0.1.2.tgz"
Expand Down Expand Up @@ -2727,6 +2746,13 @@
"resolved" "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz"
"version" "2.2.0"

"bindings@^1.5.0":
"integrity" "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ=="
"resolved" "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz"
"version" "1.5.0"
dependencies:
"file-uri-to-path" "1.0.0"

"bluebird@^3.5.5":
"integrity" "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
"resolved" "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz"
Expand Down Expand Up @@ -3859,6 +3885,11 @@
dependencies:
"cssom" "~0.3.6"

"csstype@^3.0.2":
"integrity" "sha512-sa6P2wJ+CAbgyy4KFssIb/JNMLxFvKF1pCYCSXS8ZMuqZnMsrxqI2E5sPyoTpxoPU/gVZMzr2zjOfg8GIZOMsw=="
"resolved" "https://registry.npmjs.org/csstype/-/csstype-3.0.11.tgz"
"version" "3.0.11"

"cyclist@^1.0.1":
"integrity" "sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk="
"resolved" "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz"
Expand Down Expand Up @@ -4595,14 +4626,7 @@
"esrecurse" "^4.3.0"
"estraverse" "^4.1.1"

"eslint-utils@^2.0.0":
"integrity" "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg=="
"resolved" "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz"
"version" "2.1.0"
dependencies:
"eslint-visitor-keys" "^1.1.0"

"eslint-utils@^2.1.0":
"eslint-utils@^2.0.0", "eslint-utils@^2.1.0":
"integrity" "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg=="
"resolved" "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz"
"version" "2.1.0"
Expand All @@ -4616,17 +4640,7 @@
dependencies:
"eslint-visitor-keys" "^2.0.0"

"eslint-visitor-keys@^1.0.0":
"integrity" "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ=="
"resolved" "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz"
"version" "1.3.0"

"eslint-visitor-keys@^1.1.0":
"integrity" "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ=="
"resolved" "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz"
"version" "1.3.0"

"eslint-visitor-keys@^1.3.0":
"eslint-visitor-keys@^1.0.0", "eslint-visitor-keys@^1.1.0", "eslint-visitor-keys@^1.3.0":
"integrity" "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ=="
"resolved" "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz"
"version" "1.3.0"
Expand Down Expand Up @@ -5192,6 +5206,19 @@
"resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
"version" "1.0.0"

"fsevents@^1.2.7":
"integrity" "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw=="
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz"
"version" "1.2.13"
dependencies:
"bindings" "^1.5.0"
"nan" "^2.12.1"

"fsevents@^2.1.2", "fsevents@^2.1.3", "fsevents@~2.3.2":
"integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
"version" "2.3.2"

"function-bind@^1.1.1":
"integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
"resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
Expand Down Expand Up @@ -5682,7 +5709,12 @@
"resolved" "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz"
"version" "4.0.6"

"ignore@^5.1.4", "ignore@^5.1.8":
"ignore@^5.1.4":
"integrity" "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ=="
"resolved" "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz"
"version" "5.2.0"

"ignore@^5.1.8":
"integrity" "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ=="
"resolved" "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz"
"version" "5.2.0"
Expand Down Expand Up @@ -7438,6 +7470,11 @@
"dns-packet" "^1.3.1"
"thunky" "^1.0.2"

"nan@^2.12.1":
"integrity" "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
"resolved" "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz"
"version" "2.15.0"

"nanoid@^3.1.30":
"integrity" "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ=="
"resolved" "https://registry.npmjs.org/nanoid/-/nanoid-3.1.30.tgz"
Expand Down Expand Up @@ -9218,8 +9255,9 @@
optionalDependencies:
"fsevents" "^2.1.3"

"react@*", "react@>= 16", "[email protected]", "react@file:../test-apps/my-react-app/node_modules/react":
"resolved" "file:../test-apps/my-react-app/node_modules/react"
"react@*", "react@^17.0.2", "react@>= 16", "[email protected]":
"integrity" "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA=="
"resolved" "https://registry.npmjs.org/react/-/react-17.0.2.tgz"
"version" "17.0.2"
dependencies:
"loose-envify" "^1.1.0"
Expand Down Expand Up @@ -10108,17 +10146,17 @@
"resolved" "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz"
"version" "0.4.1"

"source-map@^0.5.0":
"source-map@^0.5.0", "source-map@^0.5.6":
"integrity" "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
"resolved" "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz"
"version" "0.5.7"

"source-map@^0.5.6":
"integrity" "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
"resolved" "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz"
"version" "0.5.7"
"source-map@^0.6.0":
"integrity" "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
"resolved" "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
"version" "0.6.1"

"source-map@^0.6.0", "source-map@^0.6.1", "source-map@~0.6.0", "source-map@~0.6.1", "[email protected]":
"source-map@^0.6.1", "[email protected]":
"integrity" "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
"resolved" "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
"version" "0.6.1"
Expand All @@ -10128,6 +10166,16 @@
"resolved" "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz"
"version" "0.7.3"

"source-map@~0.6.0":
"integrity" "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
"resolved" "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
"version" "0.6.1"

"source-map@~0.6.1":
"integrity" "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
"resolved" "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
"version" "0.6.1"

"source-map@~0.7.2":
"integrity" "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ=="
"resolved" "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz"
Expand Down