@docshound/chat-react 0.9.0 → 0.9.1

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.
package/README.md CHANGED
@@ -50,7 +50,7 @@ The DocsHoundChat component accepts the following props:
50
50
  - `userAvatarUrl`: The URL for the avatar image of the user. Optional.
51
51
  - `firstMessage`: The initial agent message that appears when the chat opens. Optional.
52
52
  - `theme`: Defines the theme of the chat interface, either 'light' or 'dark'. Optional.
53
- - `position`: The position of the chat widget on the screen ('center' or 'right'). Optional. Defaults to 'right'.
53
+ - `position`: The position of the chat trigger on the screen ('right', 'right-top', or 'right-bottom'). Optional. Defaults to 'right'.
54
54
  - `accentColor`: The accent color of the chat interface. Optional.
55
55
  - `triggerLabel`: The label for the trigger button that starts the chat. Optional.
56
56
  - `token`: Authentication token for jwt / password / basic protected guides. Optional.
package/dist/index.d.ts CHANGED
@@ -67,11 +67,11 @@ type DocsHoundChatProps = {
67
67
  */
68
68
  theme?: "light" | "dark";
69
69
  /**
70
- * Defines the position of the chat widget on the screen. Can be either 'center' or 'right'.
70
+ * Defines the position of the chat trigger on the screen. Can be either 'right', 'right-bottom' or 'right-top'.
71
71
  *
72
72
  * Optional field. Defaults to 'right'
73
73
  */
74
- position?: "center" | "right";
74
+ position?: "right" | "right-top" | "right-bottom";
75
75
  /**
76
76
  * Sets the accent color of the chat interface (e.g., for buttons or highlights).
77
77
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/components/DocsHoundChat.tsx","../src/utils/devLog.ts","../src/hooks/useDocsHoundChat.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\n\nexport type DocsHoundChatProps = {\n\t/**\n\t * Domain where the guide is published. Eg: https://docs.docshound.com\n\t *\n\t * This field is not reactive, so if you change it, you need to reload the page.\n\t *\n\t * Required field;\n\t */\n\tsrc: string;\n\n\t/**\n\t * The name of the agent responding in the chat.\n\t *\n\t * Optional field. Defaults to value set in the DocsHound.\n\t */\n\tagentName?: string;\n\n\t/**\n\t * The URL for the avatar image of the agent.\n\t *\n\t * Optional field. Defaults to value set in the DocsHound.\n\t */\n\tagentAvatarUrl?: string;\n\n\t/**\n\t * A unique identifier for the user interacting with the chat.\n\t * This should be unique identifier coming from your system.\n\t * Used to identify the user and their support tickets.\n\t *\n\t * Optional field. Defaults to undefined.\n\t */\n\tuserId?: string;\n\n\t/**\n\t * The email address of the user interacting with the chat.\n\t * Will be pre-filled for the user when they decide to submit a support ticket.\n\t *\n\t * Optional field. Defaults to undefined.\n\t */\n\tuserEmail?: string;\n\n\t/**\n\t * The display name of the user interacting with the chat.\n\t *\n\t * Optional field. Defaults to 'You'.\n\t */\n\tuserName?: string;\n\n\t/**\n\t * The platform where the chat is being used. Could be either 'site' (marketing site), 'app' (application), or 'docs' (documentation site / platform).\n\t *\n\t * Optional field, defaults to 'app'.\n\t */\n\tplatform?: \"site\" | \"app\" | \"docs\";\n\n\t/**\n\t * The URL for the avatar image of the user interacting with the chat.\n\t *\n\t * Optional field. Defaults to generic user avatar.\n\t */\n\tuserAvatarUrl?: string;\n\n\t/**\n\t * The initial agent message that will be prepopulated when user opens the chatbot widget.\n\t *\n\t * Optional field. Default to value set in DocsHound.\n\t */\n\tfirstMessage?: string;\n\n\t/**\n\t * Defines the theme of the chat interface, either 'light' or 'dark'.\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\ttheme?: \"light\" | \"dark\";\n\n\t/**\n\t * Defines the position of the chat widget on the screen. Can be either 'center' or 'right'.\n\t *\n\t * Optional field. Defaults to 'right'\n\t */\n\tposition?: \"center\" | \"right\";\n\n\t/**\n\t * Sets the accent color of the chat interface (e.g., for buttons or highlights).\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\taccentColor?: string;\n\n\t/**\n\t * The label for the trigger button that starts the chat.\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\ttriggerLabel?: string;\n\n\t/**\n\t * Authentication token for jwt / password / basic protected guides\n\t *\n\t * Optional field.\n\t */\n\ttoken?: string;\n};\n\nexport const DocsHoundChat = ({\n\tsrc,\n\tagentName,\n\tagentAvatarUrl,\n\taccentColor,\n\tplatform,\n\tposition,\n\ttheme,\n\ttriggerLabel,\n\tuserAvatarUrl,\n\tuserId,\n\tuserEmail,\n\tuserName,\n\tfirstMessage,\n\ttoken,\n}: DocsHoundChatProps) => {\n\tconst id = `__DH_CHAT_SCRIPT__`;\n\n\tuseEffect(() => {\n\t\tif (!customElements.get(\"docshound-chat\")) {\n\t\t\tlet existingScript = document.getElementById(\n\t\t\t\tid\n\t\t\t) as HTMLScriptElement | null;\n\n\t\t\tif (!existingScript) {\n\t\t\t\tlet finalSrc = \"\";\n\n\t\t\t\tif (src.endsWith(\"/-/chat.js\")) {\n\t\t\t\t\tfinalSrc = src;\n\t\t\t\t} else if (src.endsWith(\"/\")) {\n\t\t\t\t\tfinalSrc = `${src}-/chat.js`;\n\t\t\t\t} else {\n\t\t\t\t\tfinalSrc = `${src}/-/chat.js`;\n\t\t\t\t}\n\n\t\t\t\tconst script = document.createElement(\"script\");\n\t\t\t\tscript.src = finalSrc;\n\t\t\t\tscript.id = id;\n\t\t\t\tscript.type = \"text/javascript\";\n\t\t\t\tscript.async = true;\n\t\t\t\tscript.defer = true;\n\t\t\t\tdocument.head.appendChild(script);\n\t\t\t}\n\t\t}\n\t}, []);\n\n\treturn (\n\t\t<docshound-chat\n\t\t\tagent-name={agentName}\n\t\t\tagent-avatar-url={agentAvatarUrl}\n\t\t\taccent-color={accentColor}\n\t\t\tplatform={platform}\n\t\t\tposition={position}\n\t\t\ttheme={theme}\n\t\t\ttrigger-label={triggerLabel}\n\t\t\tuser-id={userId}\n\t\t\tuser-email={userEmail}\n\t\t\tuser-name={userName}\n\t\t\tuser-avatar-url={userAvatarUrl}\n\t\t\tfirst-message={firstMessage}\n\t\t\ttoken={token}\n\t\t/>\n\t);\n};\n","export function devWarn(...args: Parameters<typeof console.warn>) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(...args);\n }\n}","import { useCallback } from \"react\";\nimport { devWarn } from \"../utils/devLog\";\n\ntype UseDocsHoundChat = {\n\t/**\n\t * Method to clear thread and send a query on behalf of the user\n\t *\n\t * @param question - user query\n\t */\n\tsendQuestion: (question: string) => void;\n\n\t/**\n\t * Method to show or hide the chat component\n\t *\n\t * @param show - Whether to show or hide the chat component\n\t */\n\tshow: (show: boolean) => void;\n\n\t/**\n\t * Method to clear history of the chat component\n\t */\n\tclear: () => void;\n};\n\nexport function useDocsHoundChat(): UseDocsHoundChat {\n\tconst show = useCallback((show: boolean) => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.show) {\n\t\t\telement.show(show);\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\tconst clear = useCallback(() => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.clear) {\n\t\t\telement.clear();\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\tconst sendQuestion = useCallback((question: string) => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.sendQuestion) {\n\t\t\telement.sendQuestion(question);\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\t// Return the show and clear methods\n\treturn { show, clear, sendQuestion };\n}\n\nexport default useDocsHoundChat;\n"],"names":["DocsHoundChat","src","agentName","agentAvatarUrl","accentColor","platform","position","theme","triggerLabel","userAvatarUrl","userId","userEmail","userName","firstMessage","token","id","useEffect","customElements","get","document","getElementById","finalSrc","endsWith","script","createElement","type","async","defer","head","appendChild","_jsx","devWarn","args","process","env","NODE_ENV","console","warn","useDocsHoundChat","show","useCallback","element","querySelector","clear","sendQuestion","question"],"mappings":"2FA2GO,MAAMA,EAAgB,EAC5BC,MACAC,YACAC,iBACAC,cACAC,WACAC,WACAC,QACAC,eACAC,gBACAC,SACAC,YACAC,WACAC,eACAC,YAEA,MAAMC,EAAK,qBA8BX,OA5BAC,GAAU,KACT,IAAKC,eAAeC,IAAI,kBAAmB,CAK1C,IAJqBC,SAASC,eAC7BL,GAGoB,CACpB,IAAIM,EAAW,GAGdA,EADGpB,EAAIqB,SAAS,cACLrB,EACDA,EAAIqB,SAAS,KACZ,GAAGrB,aAEH,GAAGA,cAGf,MAAMsB,EAASJ,SAASK,cAAc,UACtCD,EAAOtB,IAAMoB,EACbE,EAAOR,GAAKA,EACZQ,EAAOE,KAAO,kBACdF,EAAOG,OAAQ,EACfH,EAAOI,OAAQ,EACfR,SAASS,KAAKC,YAAYN,OAG1B,IAGFO,EACa,iBAAA,CAAA,aAAA5B,EACM,mBAAAC,iBACJC,EACdC,SAAUA,EACVC,SAAUA,EACVC,MAAOA,EAAK,gBACGC,EACN,UAAAE,EACG,aAAAC,cACDC,EAAQ,kBACFH,EAAa,gBACfI,EACfC,MAAOA,GACN,ECxKY,SAAAiB,KAAWC,GACI,gBAAzBC,QAAQC,IAAIC,UACdC,QAAQC,QAAQL,EAEpB,UCoBgBM,IAmCf,MAAO,CAAEC,KAlCIC,GAAaD,IACzB,MAAME,EAAUtB,SAASuB,cACxB,kBAEGD,GAAWA,EAAQF,KACtBE,EAAQF,KAAKA,GAEbR,EAAQ,6DAEP,IAyBYY,MAvBDH,GAAY,KACzB,MAAMC,EAAUtB,SAASuB,cACxB,kBAEGD,GAAWA,EAAQE,MACtBF,EAAQE,QAERZ,EAAQ,6DAEP,IAcmBa,aAZDJ,GAAaK,IACjC,MAAMJ,EAAUtB,SAASuB,cACxB,kBAEGD,GAAWA,EAAQG,aACtBH,EAAQG,aAAaC,GAErBd,EAAQ,6DAEP,IAIJ"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/components/DocsHoundChat.tsx","../src/utils/devLog.ts","../src/hooks/useDocsHoundChat.tsx"],"sourcesContent":["import { useEffect } from \"react\";\n\nexport type DocsHoundChatProps = {\n\t/**\n\t * Domain where the guide is published. Eg: https://docs.docshound.com\n\t *\n\t * This field is not reactive, so if you change it, you need to reload the page.\n\t *\n\t * Required field;\n\t */\n\tsrc: string;\n\n\t/**\n\t * The name of the agent responding in the chat.\n\t *\n\t * Optional field. Defaults to value set in the DocsHound.\n\t */\n\tagentName?: string;\n\n\t/**\n\t * The URL for the avatar image of the agent.\n\t *\n\t * Optional field. Defaults to value set in the DocsHound.\n\t */\n\tagentAvatarUrl?: string;\n\n\t/**\n\t * A unique identifier for the user interacting with the chat.\n\t * This should be unique identifier coming from your system.\n\t * Used to identify the user and their support tickets.\n\t *\n\t * Optional field. Defaults to undefined.\n\t */\n\tuserId?: string;\n\n\t/**\n\t * The email address of the user interacting with the chat.\n\t * Will be pre-filled for the user when they decide to submit a support ticket.\n\t *\n\t * Optional field. Defaults to undefined.\n\t */\n\tuserEmail?: string;\n\n\t/**\n\t * The display name of the user interacting with the chat.\n\t *\n\t * Optional field. Defaults to 'You'.\n\t */\n\tuserName?: string;\n\n\t/**\n\t * The platform where the chat is being used. Could be either 'site' (marketing site), 'app' (application), or 'docs' (documentation site / platform).\n\t *\n\t * Optional field, defaults to 'app'.\n\t */\n\tplatform?: \"site\" | \"app\" | \"docs\";\n\n\t/**\n\t * The URL for the avatar image of the user interacting with the chat.\n\t *\n\t * Optional field. Defaults to generic user avatar.\n\t */\n\tuserAvatarUrl?: string;\n\n\t/**\n\t * The initial agent message that will be prepopulated when user opens the chatbot widget.\n\t *\n\t * Optional field. Default to value set in DocsHound.\n\t */\n\tfirstMessage?: string;\n\n\t/**\n\t * Defines the theme of the chat interface, either 'light' or 'dark'.\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\ttheme?: \"light\" | \"dark\";\n\n\t/**\n\t * Defines the position of the chat trigger on the screen. Can be either 'right', 'right-bottom' or 'right-top'.\n\t *\n\t * Optional field. Defaults to 'right'\n\t */\n\tposition?: \"right\" | \"right-top\" | \"right-bottom\";\n\n\t/**\n\t * Sets the accent color of the chat interface (e.g., for buttons or highlights).\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\taccentColor?: string;\n\n\t/**\n\t * The label for the trigger button that starts the chat.\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\ttriggerLabel?: string;\n\n\t/**\n\t * Authentication token for jwt / password / basic protected guides\n\t *\n\t * Optional field.\n\t */\n\ttoken?: string;\n};\n\nexport const DocsHoundChat = ({\n\tsrc,\n\tagentName,\n\tagentAvatarUrl,\n\taccentColor,\n\tplatform,\n\tposition,\n\ttheme,\n\ttriggerLabel,\n\tuserAvatarUrl,\n\tuserId,\n\tuserEmail,\n\tuserName,\n\tfirstMessage,\n\ttoken,\n}: DocsHoundChatProps) => {\n\tconst id = `__DH_CHAT_SCRIPT__`;\n\n\tuseEffect(() => {\n\t\tif (!customElements.get(\"docshound-chat\")) {\n\t\t\tlet existingScript = document.getElementById(\n\t\t\t\tid\n\t\t\t) as HTMLScriptElement | null;\n\n\t\t\tif (!existingScript) {\n\t\t\t\tlet finalSrc = \"\";\n\n\t\t\t\tif (src.endsWith(\"/-/chat.js\")) {\n\t\t\t\t\tfinalSrc = src;\n\t\t\t\t} else if (src.endsWith(\"/\")) {\n\t\t\t\t\tfinalSrc = `${src}-/chat.js`;\n\t\t\t\t} else {\n\t\t\t\t\tfinalSrc = `${src}/-/chat.js`;\n\t\t\t\t}\n\n\t\t\t\tconst script = document.createElement(\"script\");\n\t\t\t\tscript.src = finalSrc;\n\t\t\t\tscript.id = id;\n\t\t\t\tscript.type = \"text/javascript\";\n\t\t\t\tscript.async = true;\n\t\t\t\tscript.defer = true;\n\t\t\t\tdocument.head.appendChild(script);\n\t\t\t}\n\t\t}\n\t}, []);\n\n\treturn (\n\t\t<docshound-chat\n\t\t\tagent-name={agentName}\n\t\t\tagent-avatar-url={agentAvatarUrl}\n\t\t\taccent-color={accentColor}\n\t\t\tplatform={platform}\n\t\t\tposition={position}\n\t\t\ttheme={theme}\n\t\t\ttrigger-label={triggerLabel}\n\t\t\tuser-id={userId}\n\t\t\tuser-email={userEmail}\n\t\t\tuser-name={userName}\n\t\t\tuser-avatar-url={userAvatarUrl}\n\t\t\tfirst-message={firstMessage}\n\t\t\ttoken={token}\n\t\t/>\n\t);\n};\n","export function devWarn(...args: Parameters<typeof console.warn>) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(...args);\n }\n}","import { useCallback } from \"react\";\nimport { devWarn } from \"../utils/devLog\";\n\ntype UseDocsHoundChat = {\n\t/**\n\t * Method to clear thread and send a query on behalf of the user\n\t *\n\t * @param question - user query\n\t */\n\tsendQuestion: (question: string) => void;\n\n\t/**\n\t * Method to show or hide the chat component\n\t *\n\t * @param show - Whether to show or hide the chat component\n\t */\n\tshow: (show: boolean) => void;\n\n\t/**\n\t * Method to clear history of the chat component\n\t */\n\tclear: () => void;\n};\n\nexport function useDocsHoundChat(): UseDocsHoundChat {\n\tconst show = useCallback((show: boolean) => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.show) {\n\t\t\telement.show(show);\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\tconst clear = useCallback(() => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.clear) {\n\t\t\telement.clear();\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\tconst sendQuestion = useCallback((question: string) => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.sendQuestion) {\n\t\t\telement.sendQuestion(question);\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\t// Return the show and clear methods\n\treturn { show, clear, sendQuestion };\n}\n\nexport default useDocsHoundChat;\n"],"names":["DocsHoundChat","src","agentName","agentAvatarUrl","accentColor","platform","position","theme","triggerLabel","userAvatarUrl","userId","userEmail","userName","firstMessage","token","id","useEffect","customElements","get","document","getElementById","finalSrc","endsWith","script","createElement","type","async","defer","head","appendChild","_jsx","devWarn","args","process","env","NODE_ENV","console","warn","useDocsHoundChat","show","useCallback","element","querySelector","clear","sendQuestion","question"],"mappings":"2FA2GO,MAAMA,EAAgB,EAC5BC,MACAC,YACAC,iBACAC,cACAC,WACAC,WACAC,QACAC,eACAC,gBACAC,SACAC,YACAC,WACAC,eACAC,YAEA,MAAMC,EAAK,qBA8BX,OA5BAC,GAAU,KACT,IAAKC,eAAeC,IAAI,kBAAmB,CAK1C,IAJqBC,SAASC,eAC7BL,GAGoB,CACpB,IAAIM,EAAW,GAGdA,EADGpB,EAAIqB,SAAS,cACLrB,EACDA,EAAIqB,SAAS,KACZ,GAAGrB,aAEH,GAAGA,cAGf,MAAMsB,EAASJ,SAASK,cAAc,UACtCD,EAAOtB,IAAMoB,EACbE,EAAOR,GAAKA,EACZQ,EAAOE,KAAO,kBACdF,EAAOG,OAAQ,EACfH,EAAOI,OAAQ,EACfR,SAASS,KAAKC,YAAYN,OAG1B,IAGFO,EACa,iBAAA,CAAA,aAAA5B,EACM,mBAAAC,iBACJC,EACdC,SAAUA,EACVC,SAAUA,EACVC,MAAOA,EAAK,gBACGC,EACN,UAAAE,EACG,aAAAC,cACDC,EAAQ,kBACFH,EAAa,gBACfI,EACfC,MAAOA,GACN,ECxKY,SAAAiB,KAAWC,GACI,gBAAzBC,QAAQC,IAAIC,UACdC,QAAQC,QAAQL,EAEpB,UCoBgBM,IAmCf,MAAO,CAAEC,KAlCIC,GAAaD,IACzB,MAAME,EAAUtB,SAASuB,cACxB,kBAEGD,GAAWA,EAAQF,KACtBE,EAAQF,KAAKA,GAEbR,EAAQ,6DAEP,IAyBYY,MAvBDH,GAAY,KACzB,MAAMC,EAAUtB,SAASuB,cACxB,kBAEGD,GAAWA,EAAQE,MACtBF,EAAQE,QAERZ,EAAQ,6DAEP,IAcmBa,aAZDJ,GAAaK,IACjC,MAAMJ,EAAUtB,SAASuB,cACxB,kBAEGD,GAAWA,EAAQG,aACtBH,EAAQG,aAAaC,GAErBd,EAAQ,6DAEP,IAIJ"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/utils/devLog.ts","../src/components/DocsHoundChat.tsx","../src/hooks/useDocsHoundChat.tsx"],"sourcesContent":["export function devWarn(...args: Parameters<typeof console.warn>) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(...args);\n }\n}","import React, { useEffect } from \"react\";\n\nexport type DocsHoundChatProps = {\n\t/**\n\t * Domain where the guide is published. Eg: https://docs.docshound.com\n\t *\n\t * This field is not reactive, so if you change it, you need to reload the page.\n\t *\n\t * Required field;\n\t */\n\tsrc: string;\n\n\t/**\n\t * The name of the agent responding in the chat.\n\t *\n\t * Optional field. Defaults to value set in the DocsHound.\n\t */\n\tagentName?: string;\n\n\t/**\n\t * The URL for the avatar image of the agent.\n\t *\n\t * Optional field. Defaults to value set in the DocsHound.\n\t */\n\tagentAvatarUrl?: string;\n\n\t/**\n\t * A unique identifier for the user interacting with the chat.\n\t * This should be unique identifier coming from your system.\n\t * Used to identify the user and their support tickets.\n\t *\n\t * Optional field. Defaults to undefined.\n\t */\n\tuserId?: string;\n\n\t/**\n\t * The email address of the user interacting with the chat.\n\t * Will be pre-filled for the user when they decide to submit a support ticket.\n\t *\n\t * Optional field. Defaults to undefined.\n\t */\n\tuserEmail?: string;\n\n\t/**\n\t * The display name of the user interacting with the chat.\n\t *\n\t * Optional field. Defaults to 'You'.\n\t */\n\tuserName?: string;\n\n\t/**\n\t * The platform where the chat is being used. Could be either 'site' (marketing site), 'app' (application), or 'docs' (documentation site / platform).\n\t *\n\t * Optional field, defaults to 'app'.\n\t */\n\tplatform?: \"site\" | \"app\" | \"docs\";\n\n\t/**\n\t * The URL for the avatar image of the user interacting with the chat.\n\t *\n\t * Optional field. Defaults to generic user avatar.\n\t */\n\tuserAvatarUrl?: string;\n\n\t/**\n\t * The initial agent message that will be prepopulated when user opens the chatbot widget.\n\t *\n\t * Optional field. Default to value set in DocsHound.\n\t */\n\tfirstMessage?: string;\n\n\t/**\n\t * Defines the theme of the chat interface, either 'light' or 'dark'.\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\ttheme?: \"light\" | \"dark\";\n\n\t/**\n\t * Defines the position of the chat widget on the screen. Can be either 'center' or 'right'.\n\t *\n\t * Optional field. Defaults to 'right'\n\t */\n\tposition?: \"center\" | \"right\";\n\n\t/**\n\t * Sets the accent color of the chat interface (e.g., for buttons or highlights).\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\taccentColor?: string;\n\n\t/**\n\t * The label for the trigger button that starts the chat.\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\ttriggerLabel?: string;\n\n\t/**\n\t * Authentication token for jwt / password / basic protected guides\n\t *\n\t * Optional field.\n\t */\n\ttoken?: string;\n};\n\nexport const DocsHoundChat = ({\n\tsrc,\n\tagentName,\n\tagentAvatarUrl,\n\taccentColor,\n\tplatform,\n\tposition,\n\ttheme,\n\ttriggerLabel,\n\tuserAvatarUrl,\n\tuserId,\n\tuserEmail,\n\tuserName,\n\tfirstMessage,\n\ttoken,\n}: DocsHoundChatProps) => {\n\tconst id = `__DH_CHAT_SCRIPT__`;\n\n\tuseEffect(() => {\n\t\tif (!customElements.get(\"docshound-chat\")) {\n\t\t\tlet existingScript = document.getElementById(\n\t\t\t\tid\n\t\t\t) as HTMLScriptElement | null;\n\n\t\t\tif (!existingScript) {\n\t\t\t\tlet finalSrc = \"\";\n\n\t\t\t\tif (src.endsWith(\"/-/chat.js\")) {\n\t\t\t\t\tfinalSrc = src;\n\t\t\t\t} else if (src.endsWith(\"/\")) {\n\t\t\t\t\tfinalSrc = `${src}-/chat.js`;\n\t\t\t\t} else {\n\t\t\t\t\tfinalSrc = `${src}/-/chat.js`;\n\t\t\t\t}\n\n\t\t\t\tconst script = document.createElement(\"script\");\n\t\t\t\tscript.src = finalSrc;\n\t\t\t\tscript.id = id;\n\t\t\t\tscript.type = \"text/javascript\";\n\t\t\t\tscript.async = true;\n\t\t\t\tscript.defer = true;\n\t\t\t\tdocument.head.appendChild(script);\n\t\t\t}\n\t\t}\n\t}, []);\n\n\treturn (\n\t\t<docshound-chat\n\t\t\tagent-name={agentName}\n\t\t\tagent-avatar-url={agentAvatarUrl}\n\t\t\taccent-color={accentColor}\n\t\t\tplatform={platform}\n\t\t\tposition={position}\n\t\t\ttheme={theme}\n\t\t\ttrigger-label={triggerLabel}\n\t\t\tuser-id={userId}\n\t\t\tuser-email={userEmail}\n\t\t\tuser-name={userName}\n\t\t\tuser-avatar-url={userAvatarUrl}\n\t\t\tfirst-message={firstMessage}\n\t\t\ttoken={token}\n\t\t/>\n\t);\n};\n","import { useCallback } from \"react\";\nimport { devWarn } from \"../utils/devLog\";\n\ntype UseDocsHoundChat = {\n\t/**\n\t * Method to clear thread and send a query on behalf of the user\n\t *\n\t * @param question - user query\n\t */\n\tsendQuestion: (question: string) => void;\n\n\t/**\n\t * Method to show or hide the chat component\n\t *\n\t * @param show - Whether to show or hide the chat component\n\t */\n\tshow: (show: boolean) => void;\n\n\t/**\n\t * Method to clear history of the chat component\n\t */\n\tclear: () => void;\n};\n\nexport function useDocsHoundChat(): UseDocsHoundChat {\n\tconst show = useCallback((show: boolean) => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.show) {\n\t\t\telement.show(show);\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\tconst clear = useCallback(() => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.clear) {\n\t\t\telement.clear();\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\tconst sendQuestion = useCallback((question: string) => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.sendQuestion) {\n\t\t\telement.sendQuestion(question);\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\t// Return the show and clear methods\n\treturn { show, clear, sendQuestion };\n}\n\nexport default useDocsHoundChat;\n"],"names":["devWarn","args","process","env","NODE_ENV","console","warn","src","agentName","agentAvatarUrl","accentColor","platform","position","theme","triggerLabel","userAvatarUrl","userId","userEmail","userName","firstMessage","token","id","useEffect","customElements","get","document","getElementById","finalSrc","endsWith","script","createElement","type","async","defer","head","appendChild","_jsx","jsx","show","useCallback","element","querySelector","clear","sendQuestion","question"],"mappings":"mEAAgB,SAAAA,KAAWC,GACI,gBAAzBC,QAAQC,IAAIC,UACdC,QAAQC,QAAQL,EAEpB,uBCuG6B,EAC5BM,MACAC,YACAC,iBACAC,cACAC,WACAC,WACAC,QACAC,eACAC,gBACAC,SACAC,YACAC,WACAC,eACAC,YAEA,MAAMC,EAAK,qBA8BX,OA5BAC,EAAAA,WAAU,KACT,IAAKC,eAAeC,IAAI,kBAAmB,CAK1C,IAJqBC,SAASC,eAC7BL,GAGoB,CACpB,IAAIM,EAAW,GAGdA,EADGpB,EAAIqB,SAAS,cACLrB,EACDA,EAAIqB,SAAS,KACZ,GAAGrB,aAEH,GAAGA,cAGf,MAAMsB,EAASJ,SAASK,cAAc,UACtCD,EAAOtB,IAAMoB,EACbE,EAAOR,GAAKA,EACZQ,EAAOE,KAAO,kBACdF,EAAOG,OAAQ,EACfH,EAAOI,OAAQ,EACfR,SAASS,KAAKC,YAAYN,OAG1B,IAGFO,EACaC,IAAA,iBAAA,CAAA,aAAA7B,EACM,mBAAAC,iBACJC,EACdC,SAAUA,EACVC,SAAUA,EACVC,MAAOA,EAAK,gBACGC,EACN,UAAAE,EACG,aAAAC,cACDC,EAAQ,kBACFH,EAAa,gBACfI,EACfC,MAAOA,GACN,sCC7GH,MAAO,CAAEkB,KAlCIC,eAAaD,IACzB,MAAME,EAAUf,SAASgB,cACxB,kBAEGD,GAAWA,EAAQF,KACtBE,EAAQF,KAAKA,GAEbtC,EAAQ,6DAEP,IAyBY0C,MAvBDH,EAAAA,aAAY,KACzB,MAAMC,EAAUf,SAASgB,cACxB,kBAEGD,GAAWA,EAAQE,MACtBF,EAAQE,QAER1C,EAAQ,6DAEP,IAcmB2C,aAZDJ,eAAaK,IACjC,MAAMJ,EAAUf,SAASgB,cACxB,kBAEGD,GAAWA,EAAQG,aACtBH,EAAQG,aAAaC,GAErB5C,EAAQ,6DAEP,IAIJ"}
1
+ {"version":3,"file":"index.js","sources":["../src/utils/devLog.ts","../src/components/DocsHoundChat.tsx","../src/hooks/useDocsHoundChat.tsx"],"sourcesContent":["export function devWarn(...args: Parameters<typeof console.warn>) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(...args);\n }\n}","import { useEffect } from \"react\";\n\nexport type DocsHoundChatProps = {\n\t/**\n\t * Domain where the guide is published. Eg: https://docs.docshound.com\n\t *\n\t * This field is not reactive, so if you change it, you need to reload the page.\n\t *\n\t * Required field;\n\t */\n\tsrc: string;\n\n\t/**\n\t * The name of the agent responding in the chat.\n\t *\n\t * Optional field. Defaults to value set in the DocsHound.\n\t */\n\tagentName?: string;\n\n\t/**\n\t * The URL for the avatar image of the agent.\n\t *\n\t * Optional field. Defaults to value set in the DocsHound.\n\t */\n\tagentAvatarUrl?: string;\n\n\t/**\n\t * A unique identifier for the user interacting with the chat.\n\t * This should be unique identifier coming from your system.\n\t * Used to identify the user and their support tickets.\n\t *\n\t * Optional field. Defaults to undefined.\n\t */\n\tuserId?: string;\n\n\t/**\n\t * The email address of the user interacting with the chat.\n\t * Will be pre-filled for the user when they decide to submit a support ticket.\n\t *\n\t * Optional field. Defaults to undefined.\n\t */\n\tuserEmail?: string;\n\n\t/**\n\t * The display name of the user interacting with the chat.\n\t *\n\t * Optional field. Defaults to 'You'.\n\t */\n\tuserName?: string;\n\n\t/**\n\t * The platform where the chat is being used. Could be either 'site' (marketing site), 'app' (application), or 'docs' (documentation site / platform).\n\t *\n\t * Optional field, defaults to 'app'.\n\t */\n\tplatform?: \"site\" | \"app\" | \"docs\";\n\n\t/**\n\t * The URL for the avatar image of the user interacting with the chat.\n\t *\n\t * Optional field. Defaults to generic user avatar.\n\t */\n\tuserAvatarUrl?: string;\n\n\t/**\n\t * The initial agent message that will be prepopulated when user opens the chatbot widget.\n\t *\n\t * Optional field. Default to value set in DocsHound.\n\t */\n\tfirstMessage?: string;\n\n\t/**\n\t * Defines the theme of the chat interface, either 'light' or 'dark'.\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\ttheme?: \"light\" | \"dark\";\n\n\t/**\n\t * Defines the position of the chat trigger on the screen. Can be either 'right', 'right-bottom' or 'right-top'.\n\t *\n\t * Optional field. Defaults to 'right'\n\t */\n\tposition?: \"right\" | \"right-top\" | \"right-bottom\";\n\n\t/**\n\t * Sets the accent color of the chat interface (e.g., for buttons or highlights).\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\taccentColor?: string;\n\n\t/**\n\t * The label for the trigger button that starts the chat.\n\t *\n\t * Optional field. Defaults to value set in DocsHound.\n\t */\n\ttriggerLabel?: string;\n\n\t/**\n\t * Authentication token for jwt / password / basic protected guides\n\t *\n\t * Optional field.\n\t */\n\ttoken?: string;\n};\n\nexport const DocsHoundChat = ({\n\tsrc,\n\tagentName,\n\tagentAvatarUrl,\n\taccentColor,\n\tplatform,\n\tposition,\n\ttheme,\n\ttriggerLabel,\n\tuserAvatarUrl,\n\tuserId,\n\tuserEmail,\n\tuserName,\n\tfirstMessage,\n\ttoken,\n}: DocsHoundChatProps) => {\n\tconst id = `__DH_CHAT_SCRIPT__`;\n\n\tuseEffect(() => {\n\t\tif (!customElements.get(\"docshound-chat\")) {\n\t\t\tlet existingScript = document.getElementById(\n\t\t\t\tid\n\t\t\t) as HTMLScriptElement | null;\n\n\t\t\tif (!existingScript) {\n\t\t\t\tlet finalSrc = \"\";\n\n\t\t\t\tif (src.endsWith(\"/-/chat.js\")) {\n\t\t\t\t\tfinalSrc = src;\n\t\t\t\t} else if (src.endsWith(\"/\")) {\n\t\t\t\t\tfinalSrc = `${src}-/chat.js`;\n\t\t\t\t} else {\n\t\t\t\t\tfinalSrc = `${src}/-/chat.js`;\n\t\t\t\t}\n\n\t\t\t\tconst script = document.createElement(\"script\");\n\t\t\t\tscript.src = finalSrc;\n\t\t\t\tscript.id = id;\n\t\t\t\tscript.type = \"text/javascript\";\n\t\t\t\tscript.async = true;\n\t\t\t\tscript.defer = true;\n\t\t\t\tdocument.head.appendChild(script);\n\t\t\t}\n\t\t}\n\t}, []);\n\n\treturn (\n\t\t<docshound-chat\n\t\t\tagent-name={agentName}\n\t\t\tagent-avatar-url={agentAvatarUrl}\n\t\t\taccent-color={accentColor}\n\t\t\tplatform={platform}\n\t\t\tposition={position}\n\t\t\ttheme={theme}\n\t\t\ttrigger-label={triggerLabel}\n\t\t\tuser-id={userId}\n\t\t\tuser-email={userEmail}\n\t\t\tuser-name={userName}\n\t\t\tuser-avatar-url={userAvatarUrl}\n\t\t\tfirst-message={firstMessage}\n\t\t\ttoken={token}\n\t\t/>\n\t);\n};\n","import { useCallback } from \"react\";\nimport { devWarn } from \"../utils/devLog\";\n\ntype UseDocsHoundChat = {\n\t/**\n\t * Method to clear thread and send a query on behalf of the user\n\t *\n\t * @param question - user query\n\t */\n\tsendQuestion: (question: string) => void;\n\n\t/**\n\t * Method to show or hide the chat component\n\t *\n\t * @param show - Whether to show or hide the chat component\n\t */\n\tshow: (show: boolean) => void;\n\n\t/**\n\t * Method to clear history of the chat component\n\t */\n\tclear: () => void;\n};\n\nexport function useDocsHoundChat(): UseDocsHoundChat {\n\tconst show = useCallback((show: boolean) => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.show) {\n\t\t\telement.show(show);\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\tconst clear = useCallback(() => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.clear) {\n\t\t\telement.clear();\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\tconst sendQuestion = useCallback((question: string) => {\n\t\tconst element = document.querySelector(\n\t\t\t\"docshound-chat\"\n\t\t) as DocsHoundChatElement | null;\n\t\tif (element && element.sendQuestion) {\n\t\t\telement.sendQuestion(question);\n\t\t} else {\n\t\t\tdevWarn(\"DocsHound Chat component not mounted or not initialized\");\n\t\t}\n\t}, []);\n\n\t// Return the show and clear methods\n\treturn { show, clear, sendQuestion };\n}\n\nexport default useDocsHoundChat;\n"],"names":["devWarn","args","process","env","NODE_ENV","console","warn","src","agentName","agentAvatarUrl","accentColor","platform","position","theme","triggerLabel","userAvatarUrl","userId","userEmail","userName","firstMessage","token","id","useEffect","customElements","get","document","getElementById","finalSrc","endsWith","script","createElement","type","async","defer","head","appendChild","_jsx","jsx","show","useCallback","element","querySelector","clear","sendQuestion","question"],"mappings":"mEAAgB,SAAAA,KAAWC,GACI,gBAAzBC,QAAQC,IAAIC,UACdC,QAAQC,QAAQL,EAEpB,uBCuG6B,EAC5BM,MACAC,YACAC,iBACAC,cACAC,WACAC,WACAC,QACAC,eACAC,gBACAC,SACAC,YACAC,WACAC,eACAC,YAEA,MAAMC,EAAK,qBA8BX,OA5BAC,EAAAA,WAAU,KACT,IAAKC,eAAeC,IAAI,kBAAmB,CAK1C,IAJqBC,SAASC,eAC7BL,GAGoB,CACpB,IAAIM,EAAW,GAGdA,EADGpB,EAAIqB,SAAS,cACLrB,EACDA,EAAIqB,SAAS,KACZ,GAAGrB,aAEH,GAAGA,cAGf,MAAMsB,EAASJ,SAASK,cAAc,UACtCD,EAAOtB,IAAMoB,EACbE,EAAOR,GAAKA,EACZQ,EAAOE,KAAO,kBACdF,EAAOG,OAAQ,EACfH,EAAOI,OAAQ,EACfR,SAASS,KAAKC,YAAYN,OAG1B,IAGFO,EACaC,IAAA,iBAAA,CAAA,aAAA7B,EACM,mBAAAC,iBACJC,EACdC,SAAUA,EACVC,SAAUA,EACVC,MAAOA,EAAK,gBACGC,EACN,UAAAE,EACG,aAAAC,cACDC,EAAQ,kBACFH,EAAa,gBACfI,EACfC,MAAOA,GACN,sCC7GH,MAAO,CAAEkB,KAlCIC,eAAaD,IACzB,MAAME,EAAUf,SAASgB,cACxB,kBAEGD,GAAWA,EAAQF,KACtBE,EAAQF,KAAKA,GAEbtC,EAAQ,6DAEP,IAyBY0C,MAvBDH,EAAAA,aAAY,KACzB,MAAMC,EAAUf,SAASgB,cACxB,kBAEGD,GAAWA,EAAQE,MACtBF,EAAQE,QAER1C,EAAQ,6DAEP,IAcmB2C,aAZDJ,eAAaK,IACjC,MAAMJ,EAAUf,SAASgB,cACxB,kBAEGD,GAAWA,EAAQG,aACtBH,EAAQG,aAAaC,GAErB5C,EAAQ,6DAEP,IAIJ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docshound/chat-react",
3
3
  "private": false,
4
- "version": "0.9.0",
4
+ "version": "0.9.1",
5
5
  "description": "React component library for integrating the DocsHound chat widget into React and Next.js applications.",
6
6
  "keywords": [
7
7
  "React",