@developer.notchatbot/webchat 1.7.1 → 2.0.0

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 (34) hide show
  1. package/README.md +2 -0
  2. package/dist/components/ChatBot.d.ts +3 -4
  3. package/dist/components/ContactCapture.d.ts +7 -0
  4. package/dist/components/MessageActions.d.ts +8 -0
  5. package/dist/components/MessageAlertSettings.d.ts +5 -0
  6. package/dist/components/MessageSelectionActions.d.ts +4 -0
  7. package/dist/components/ReplyQuote.d.ts +8 -0
  8. package/dist/components/UnreadMessagePreview.d.ts +15 -0
  9. package/dist/components/embedchat/EmbedChat.d.ts +6 -2
  10. package/dist/config/endpoints.d.ts +0 -5
  11. package/dist/hooks/useMessageAlerts.d.ts +11 -0
  12. package/dist/hooks/useMessageGesture.d.ts +14 -0
  13. package/dist/hooks/useTeamAvailability.d.ts +2 -0
  14. package/dist/hooks/useVisitorChat.d.ts +48 -0
  15. package/dist/types.d.ts +86 -14
  16. package/dist/utils/cart-model.d.ts +23 -0
  17. package/dist/utils/contact-link.d.ts +2 -0
  18. package/dist/utils/convex.d.ts +2 -3
  19. package/dist/utils/markdown.d.ts +2 -0
  20. package/dist/utils/message-alerts.d.ts +15 -0
  21. package/dist/utils/message-colors.d.ts +3 -0
  22. package/dist/utils/message-id.d.ts +2 -0
  23. package/dist/utils/phone.d.ts +16 -0
  24. package/dist/utils/storefront-cart.d.ts +6 -0
  25. package/dist/utils/storefront-identity.d.ts +23 -0
  26. package/dist/utils/transcript.d.ts +23 -0
  27. package/dist/utils/visitor-presence.d.ts +30 -0
  28. package/dist/utils/visitor-session.d.ts +31 -0
  29. package/dist/webchat-bundle.min.js +9460 -6124
  30. package/dist/webchat-bundle.min.umd.cjs +81 -55
  31. package/package.json +8 -4
  32. package/dist/components/ConversationRating.d.ts +0 -7
  33. package/dist/utils/notchatbot-cookie.d.ts +0 -32
  34. package/dist/utils/survey.d.ts +0 -30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developer.notchatbot/webchat",
3
- "version": "1.7.1",
3
+ "version": "2.0.0",
4
4
  "description": "A beautiful React chatbot widget with single-file bundle",
5
5
  "main": "dist/webchat-bundle.min.umd.cjs",
6
6
  "module": "dist/webchat-bundle.min.js",
@@ -11,16 +11,17 @@
11
11
  ],
12
12
  "exports": {
13
13
  ".": {
14
+ "types": "./dist/index.d.ts",
14
15
  "import": "./dist/webchat-bundle.min.js",
15
- "require": "./dist/webchat-bundle.min.umd.cjs",
16
- "types": "./dist/index.d.ts"
16
+ "require": "./dist/webchat-bundle.min.umd.cjs"
17
17
  }
18
18
  },
19
19
  "scripts": {
20
20
  "dev": "vite",
21
21
  "build": "tsc && vite build",
22
22
  "preview": "vite preview",
23
- "test": "node --test tests/*.test.mjs"
23
+ "test": "node --test tests/*.test.mjs",
24
+ "sandbox": "node sandbox/start.mjs"
24
25
  },
25
26
  "keywords": [
26
27
  "chatbot",
@@ -39,6 +40,7 @@
39
40
  "@types/react-dom": "^18.2.18",
40
41
  "@vitejs/plugin-react": "^4.2.1",
41
42
  "autoprefixer": "^10.4.16",
43
+ "jsdom": "^29.1.1",
42
44
  "postcss": "^8.4.32",
43
45
  "tailwindcss": "^3.4.0",
44
46
  "typescript": "^5.3.3",
@@ -47,6 +49,8 @@
47
49
  },
48
50
  "dependencies": {
49
51
  "convex": "^1.27.3",
52
+ "dompurify": "^3.4.15",
53
+ "libphonenumber-js": "^1.13.12",
50
54
  "marked": "^15.0.12",
51
55
  "react": "^18.2.0",
52
56
  "react-dom": "^18.2.0"
@@ -1,7 +0,0 @@
1
- import { default as React } from 'react';
2
- interface ConversationRatingProps {
3
- onRate?: (rating: number) => void;
4
- conversationId?: string;
5
- }
6
- declare const ConversationRating: React.FC<ConversationRatingProps>;
7
- export default ConversationRating;
@@ -1,32 +0,0 @@
1
- export interface NotChatbotCookieData {
2
- conversationId: string;
3
- conversationStarted: boolean;
4
- }
5
- /**
6
- * Get the notchatbot cookie data, creating it if it doesn't exist
7
- */
8
- export declare function getNotChatbotCookie(): NotChatbotCookieData;
9
- /**
10
- * Set the notchatbot cookie with specified data
11
- */
12
- export declare function setNotChatbotCookie(data: NotChatbotCookieData): void;
13
- /**
14
- * Update the conversationStarted flag in the cookie
15
- */
16
- export declare function setConversationStarted(started: boolean): NotChatbotCookieData;
17
- /**
18
- * Get current conversation ID from the cookie
19
- */
20
- export declare function getConversationId(): string;
21
- /**
22
- * Check if conversation has been started
23
- */
24
- export declare function isConversationStarted(): boolean;
25
- /**
26
- * Reset the conversation by creating a new conversation ID and setting conversationStarted to false
27
- */
28
- export declare function resetConversation(): NotChatbotCookieData;
29
- /**
30
- * Delete the notchatbot cookie
31
- */
32
- export declare function deleteNotChatbotCookie(): void;
@@ -1,30 +0,0 @@
1
- import { Message } from '../types';
2
- /** Legacy hardcoded threshold, used when the backend does not send one. */
3
- export declare const DEFAULT_SURVEY_AFTER_USER_MESSAGES = 2;
4
- /**
5
- * Resolves the configured auto-survey threshold.
6
- * Falls back to the default when the backend does not expose the field yet
7
- * or sends something unusable (non-number, NaN, zero/negative).
8
- */
9
- export declare const resolveSurveyThreshold: (value: unknown) => number;
10
- /** Counts only messages sent by the end user (bot/employee ones don't count). */
11
- export declare const countUserMessages: (messages: Message[]) => number;
12
- /**
13
- * Whether the survey should auto-open because the user reached the
14
- * configured message threshold. Never true for already rated conversations.
15
- */
16
- export declare const shouldAutoShowSurvey: (messages: Message[], surveyAfterUserMessages: number | undefined, isRated: boolean) => boolean;
17
- /**
18
- * Whether a manual survey request (`webchatSurveyRequestedAt`, a timestamp
19
- * written by an agent from Livechat) is a new, still unhandled trigger.
20
- * Comparing against the last handled value — not just presence — keeps
21
- * re-renders and Convex reconnections from re-opening the survey for the
22
- * same request, while a fresh timestamp triggers it again.
23
- *
24
- * Deliberately NOT gated on `isRated`: a manual request fired after a rating
25
- * re-opens the survey so the agent can re-validate the experience (the new
26
- * rating overwrites the previous one server-side). Stale requests can't leak
27
- * across reloads because the backend clears `webchatSurveyRequestedAt` when a
28
- * rating is submitted — a present timestamp is always a pending ask.
29
- */
30
- export declare const isNewSurveyRequest: (requestedAt: number | undefined, lastHandledRequestedAt: number | undefined) => boolean;