@chatbotkit/react 1.24.0 → 1.25.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.
@@ -26,12 +26,14 @@ function useWidgetInstance(selector, deps) {
26
26
  };
27
27
  }
28
28
  }
29
- if (window.chatbotkitWidget) {
30
- window.chatbotkitWidget.instancePromise.then((instance) => setInstance(instance));
29
+ const chatbotkitWidget = (window).chatbotkitWidget;
30
+ if (chatbotkitWidget) {
31
+ chatbotkitWidget.instancePromise.then((instance) => setInstance(instance));
31
32
  return;
32
33
  }
33
34
  function onInit() {
34
- window.chatbotkitWidget.instancePromise.then((instance) => setInstance(instance));
35
+ const chatbotkitWidget = (window).chatbotkitWidget;
36
+ chatbotkitWidget.instancePromise.then((instance) => setInstance(instance));
35
37
  }
36
38
  window.addEventListener('chatbotkitWidgetInit', onInit);
37
39
  return () => {
@@ -1,41 +1,4 @@
1
- export function useWidgetInstance(selector?: string, deps?: any[]): ChatBotKitWidgetInstance | null;
1
+ export function useWidgetInstance(selector?: string, deps?: any[]): ChatBotKitWidgetElementV2 | null;
2
2
  export default useWidgetInstance;
3
- export type WidgetMessage = {
4
- id: string;
5
- type: string;
6
- text: string;
7
- };
8
- export type WidgetNotification = {
9
- text: string;
10
- };
11
- export type WidgetFunctionBase = {
12
- description: string;
13
- parameters: Record<string, any>;
14
- };
15
- export type WidgetFunctionWithResult = WidgetFunctionBase & {
16
- result: {
17
- data: any;
18
- };
19
- };
20
- export type WidgetFunctionWithHandler = WidgetFunctionBase & {
21
- handler: (args: any) => any;
22
- };
23
- export type WidgetFunction = WidgetFunctionWithResult | WidgetFunctionWithHandler;
24
- export type WidgetRestartConversationFn = () => void;
25
- export type WidgetSendMessageFn = (options: string | (({
26
- message: string;
27
- } | {
28
- text: string;
29
- }) & {
30
- hidden?: boolean;
31
- respond?: boolean;
32
- })) => void;
33
- export type ChatBotKitWidgetInstance = HTMLElement & {
34
- ready: boolean;
35
- readyPromise: Promise<boolean>;
36
- messages?: WidgetMessage[] | null;
37
- notifications?: Record<string, WidgetNotification> | null;
38
- functions?: Record<string, WidgetFunction> | null;
39
- restartConversation: WidgetRestartConversationFn;
40
- sendMessage: WidgetSendMessageFn;
41
- };
3
+ export type ChatBotKitWidgetElementV2 = any;
4
+ export type ChatBotKitGlobalObject = any;
@@ -1,6 +1,7 @@
1
1
  export function useWidgetInstanceFunctions(params?: {
2
2
  selector?: string;
3
- functions?: Record<string, WidgetFunction> | null;
4
- }, deps?: any[]): import("./useWidgetInstance.js").ChatBotKitWidgetInstance | null;
3
+ functions?: Record<string, FunctionDefinition | null> | null;
4
+ }, deps?: any[]): ChatBotKitWidgetElementV2 | null;
5
5
  export default useWidgetInstanceFunctions;
6
- export type WidgetFunction = import("./useWidgetInstance.js").WidgetFunction;
6
+ export type FunctionDefinition = any;
7
+ export type ChatBotKitWidgetElementV2 = any;
@@ -1,6 +1,7 @@
1
1
  export function useWidgetInstanceNotifications(params?: {
2
2
  selector?: string;
3
- notifications?: Record<string, WidgetNotification> | null;
4
- }, deps?: any[]): import("./useWidgetInstance.js").ChatBotKitWidgetInstance | null;
3
+ notifications?: Record<string, NotificationDefinition | null> | null;
4
+ }, deps?: any[]): ChatBotKitWidgetElementV2 | null;
5
5
  export default useWidgetInstanceNotifications;
6
- export type WidgetNotification = import("./useWidgetInstance.js").WidgetNotification;
6
+ export type NotificationDefinition = any;
7
+ export type ChatBotKitWidgetElementV2 = any;
@@ -1,41 +1,4 @@
1
- export function useWidgetInstance(selector?: string, deps?: any[]): ChatBotKitWidgetInstance | null;
1
+ export function useWidgetInstance(selector?: string, deps?: any[]): ChatBotKitWidgetElementV2 | null;
2
2
  export default useWidgetInstance;
3
- export type WidgetMessage = {
4
- id: string;
5
- type: string;
6
- text: string;
7
- };
8
- export type WidgetNotification = {
9
- text: string;
10
- };
11
- export type WidgetFunctionBase = {
12
- description: string;
13
- parameters: Record<string, any>;
14
- };
15
- export type WidgetFunctionWithResult = WidgetFunctionBase & {
16
- result: {
17
- data: any;
18
- };
19
- };
20
- export type WidgetFunctionWithHandler = WidgetFunctionBase & {
21
- handler: (args: any) => any;
22
- };
23
- export type WidgetFunction = WidgetFunctionWithResult | WidgetFunctionWithHandler;
24
- export type WidgetRestartConversationFn = () => void;
25
- export type WidgetSendMessageFn = (options: string | (({
26
- message: string;
27
- } | {
28
- text: string;
29
- }) & {
30
- hidden?: boolean;
31
- respond?: boolean;
32
- })) => void;
33
- export type ChatBotKitWidgetInstance = HTMLElement & {
34
- ready: boolean;
35
- readyPromise: Promise<boolean>;
36
- messages?: WidgetMessage[] | null;
37
- notifications?: Record<string, WidgetNotification> | null;
38
- functions?: Record<string, WidgetFunction> | null;
39
- restartConversation: WidgetRestartConversationFn;
40
- sendMessage: WidgetSendMessageFn;
41
- };
3
+ export type ChatBotKitWidgetElementV2 = import("@chatbotkit/widget/v2").ChatBotKitWidgetElementV2;
4
+ export type ChatBotKitGlobalObject = import("@chatbotkit/widget/v2").ChatBotKitGlobalObject;
@@ -22,12 +22,14 @@ export function useWidgetInstance(selector, deps) {
22
22
  };
23
23
  }
24
24
  }
25
- if (window.chatbotkitWidget) {
26
- window.chatbotkitWidget.instancePromise.then((instance) => setInstance(instance));
25
+ const chatbotkitWidget = (window).chatbotkitWidget;
26
+ if (chatbotkitWidget) {
27
+ chatbotkitWidget.instancePromise.then((instance) => setInstance(instance));
27
28
  return;
28
29
  }
29
30
  function onInit() {
30
- window.chatbotkitWidget.instancePromise.then((instance) => setInstance(instance));
31
+ const chatbotkitWidget = (window).chatbotkitWidget;
32
+ chatbotkitWidget.instancePromise.then((instance) => setInstance(instance));
31
33
  }
32
34
  window.addEventListener('chatbotkitWidgetInit', onInit);
33
35
  return () => {
@@ -1,6 +1,7 @@
1
1
  export function useWidgetInstanceFunctions(params?: {
2
2
  selector?: string;
3
- functions?: Record<string, WidgetFunction> | null;
4
- }, deps?: any[]): import("./useWidgetInstance.js").ChatBotKitWidgetInstance | null;
3
+ functions?: Record<string, FunctionDefinition | null> | null;
4
+ }, deps?: any[]): ChatBotKitWidgetElementV2 | null;
5
5
  export default useWidgetInstanceFunctions;
6
- export type WidgetFunction = import("./useWidgetInstance.js").WidgetFunction;
6
+ export type FunctionDefinition = import("@chatbotkit/widget/v2").FunctionDefinition;
7
+ export type ChatBotKitWidgetElementV2 = import("@chatbotkit/widget/v2").ChatBotKitWidgetElementV2;
@@ -1,6 +1,7 @@
1
1
  export function useWidgetInstanceNotifications(params?: {
2
2
  selector?: string;
3
- notifications?: Record<string, WidgetNotification> | null;
4
- }, deps?: any[]): import("./useWidgetInstance.js").ChatBotKitWidgetInstance | null;
3
+ notifications?: Record<string, NotificationDefinition | null> | null;
4
+ }, deps?: any[]): ChatBotKitWidgetElementV2 | null;
5
5
  export default useWidgetInstanceNotifications;
6
- export type WidgetNotification = import("./useWidgetInstance.js").WidgetNotification;
6
+ export type NotificationDefinition = import("@chatbotkit/widget/v2").NotificationDefinition;
7
+ export type ChatBotKitWidgetElementV2 = import("@chatbotkit/widget/v2").ChatBotKitWidgetElementV2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatbotkit/react",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "The fastest way to build advanced AI chat bots",
5
5
  "license": "ISC",
6
6
  "engines": {
@@ -461,7 +461,8 @@
461
461
  "types": "./dist/cjs/index.d.ts",
462
462
  "dependencies": {
463
463
  "tslib": "^2.6.2",
464
- "@chatbotkit/sdk": "1.24.0"
464
+ "@chatbotkit/sdk": "1.25.0",
465
+ "@chatbotkit/widget": "1.25.0"
465
466
  },
466
467
  "peerDependencies": {
467
468
  "react": ">=18.0.0",
@@ -481,14 +482,14 @@
481
482
  ],
482
483
  "scripts": {
483
484
  "build": "run-s build:*",
484
- "build:cjs": "tsc -p tsconfig.cjs.json",
485
- "build:cjs_rename": "node ../../scripts/rename-cjs.js",
486
- "build:cjs_rewrite_cjs": "node ../../scripts/rewrite-cjs.js",
487
- "build:cjs_rewrite_ts": "node ../../scripts/rewrite-ts.js",
488
- "build:docs": "typedoc",
489
- "build:esm": "tsc -p tsconfig.esm.json",
490
- "build:exports": "node ../../scripts/create-standard-exports.js",
491
- "build:types": "tsc -p tsconfig.types.json",
485
+ "build:01-cjs": "tsc -p tsconfig.cjs.json",
486
+ "build:01-cjs_rename": "node ../../scripts/rename-cjs.js",
487
+ "build:01-cjs_rewrite_cjs": "node ../../scripts/rewrite-cjs.js",
488
+ "build:01-cjs_rewrite_ts": "node ../../scripts/rewrite-ts.js",
489
+ "build:03-docs": "typedoc",
490
+ "build:02-esm": "tsc -p tsconfig.esm.json",
491
+ "build:00-exports": "node ../../scripts/create-standard-exports.js",
492
+ "build:00-types": "tsc -p tsconfig.types.json",
492
493
  "check": "tsc -p tsconfig.check.json",
493
494
  "clean": "run-p clean:*",
494
495
  "clean:buildinfo": "rimraf *.tsbuildinfo",