robodialog 0.1.0 → 0.1.2

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
@@ -1,4 +1,4 @@
1
- # My Chatbot Widget
1
+ # RoboDialog Embed
2
2
 
3
3
  Embed your AI chatbot anywhere!
4
4
 
@@ -8,7 +8,7 @@ Embed your AI chatbot anywhere!
8
8
 
9
9
  ```html
10
10
  <script
11
- src="https://cdn.yoursite.com/widget.js"
11
+ src="https://cdn.jsdelivr.net/npm/robodialog/dist/widget.js"
12
12
  data-bot-id="YOUR_BOT_ID_HERE"
13
13
  ></script>
14
14
  ```
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["export interface ChatbotLoaderOptions {\r\n /** The unique identifier for your chatbot. You can find this in your RoboDialog dashboard. */\r\n chatbotId: string;\r\n /** Optional: The ID of the currently logged-in user to sync conversation history. */\r\n userId?: string;\r\n /** Optional: The email of the user for lead capture or identification. */\r\n email?: string;\r\n /** Optional: A bearer token if your API requires needs authentication. */\r\n bearer?: string;\r\n /** Optional: Set to true to open the chatbot in full screen mode. */\r\n fullScreen?: boolean;\r\n /** \r\n * Optional: Override the default widget script URL.\r\n * Use this to pin a specific version or load from a custom domain.\r\n */\r\n widgetUrl?: string;\r\n}\r\n\r\n/**\r\n * Initializes and injects the RoboDialog chat widget into the page.\r\n * \r\n * This function creates a script tag that loads the widget code and appends it to the document body.\r\n * It returns a cleanup function that removes the widget and the script tag.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { Chat } from 'robodialog';\r\n * \r\n * // 1. Basic usage\r\n * Chat({\r\n * chatbotId: 'your-chatbot-id'\r\n * });\r\n * \r\n * // 2. With authenticated user data\r\n * Chat({\r\n * chatbotId: 'your-chatbot-id',\r\n * userId: 'user-123',\r\n * email: 'user@example.com'\r\n * });\r\n * \r\n * // 3. Usage in a React useEffect hook\r\n * useEffect(() => {\r\n * const cleanup = Chat({\r\n * chatbotId: 'your-chatbot-id'\r\n * });\r\n * \r\n * // Cleanup on unmount\r\n * return cleanup;\r\n * }, []);\r\n * ```\r\n * \r\n * @param options - Configuration options for the chatbot widget.\r\n * @returns A function that destroys the widget and removes the script tag when called.\r\n */\r\nexport function Chat(options: ChatbotLoaderOptions): () => void {\r\n // Validate required options\r\n if (!options.chatbotId) {\r\n throw new Error('[RoboDialog] chatbotId is required');\r\n }\r\n\r\n // Check if widget is already loaded\r\n const existingContainer = document.getElementById('my-chatbot-root');\r\n if (existingContainer) {\r\n console.warn('[RoboDialog] Widget is already loaded. Skipping.');\r\n return () => {};\r\n }\r\n\r\n // Create script element\r\n const script = document.createElement('script');\r\n \r\n // Set script source with default CDN\r\n script.src = options.widgetUrl || 'https://cdn.jsdelivr.net/npm/robodialog/dist/widget.js';\r\n \r\n // Set required data attribute\r\n script.dataset.chatbotId = options.chatbotId;\r\n \r\n // Set optional data attributes\r\n if (options.userId) {\r\n script.dataset.userId = options.userId;\r\n }\r\n \r\n if (options.email) {\r\n script.dataset.email = options.email;\r\n }\r\n \r\n if (options.bearer) {\r\n script.dataset.bearer = options.bearer;\r\n }\r\n\r\n if (options.fullScreen) {\r\n script.dataset.fullScreen = 'true';\r\n }\r\n\r\n // Add error handling\r\n let isLoaded = false;\r\n script.onload = () => {\r\n isLoaded = true;\r\n };\r\n \r\n script.onerror = () => {\r\n console.error('[RoboDialog] Failed to load widget from', script.src);\r\n script.remove();\r\n };\r\n\r\n // Append to document body\r\n document.body.appendChild(script);\r\n\r\n // Return cleanup function\r\n return () => {\r\n // Remove event listeners if not loaded yet\r\n if (!isLoaded) {\r\n script.onload = null;\r\n script.onerror = null;\r\n }\r\n \r\n // Remove script tag\r\n script.remove();\r\n \r\n // Remove container div created by the widget\r\n const container = document.getElementById('my-chatbot-root');\r\n if (container) {\r\n container.remove();\r\n }\r\n \r\n console.log('[RoboDialog] Widget removed');\r\n };\r\n}\r\n\r\n// Default export for convenience\r\nexport default Chat;"],"names":["Chat","options","script","isLoaded","container"],"mappings":"AAsDO,SAASA,EAAKC,GAA2C;AAE9D,MAAI,CAACA,EAAQ;AACX,UAAM,IAAI,MAAM,oCAAoC;AAKtD,MAD0B,SAAS,eAAe,iBAAiB;AAEjE,mBAAQ,KAAK,kDAAkD,GACxD,MAAM;AAAA,IAAC;AAIhB,QAAMC,IAAS,SAAS,cAAc,QAAQ;AAG9C,EAAAA,EAAO,MAAMD,EAAQ,aAAa,0DAGlCC,EAAO,QAAQ,YAAYD,EAAQ,WAG/BA,EAAQ,WACVC,EAAO,QAAQ,SAASD,EAAQ,SAG9BA,EAAQ,UACVC,EAAO,QAAQ,QAAQD,EAAQ,QAG7BA,EAAQ,WACVC,EAAO,QAAQ,SAASD,EAAQ,SAG9BA,EAAQ,eACVC,EAAO,QAAQ,aAAa;AAI9B,MAAIC,IAAW;AACf,SAAAD,EAAO,SAAS,MAAM;AACpB,IAAAC,IAAW;AAAA,EACb,GAEAD,EAAO,UAAU,MAAM;AACrB,YAAQ,MAAM,2CAA2CA,EAAO,GAAG,GACnEA,EAAO,OAAA;AAAA,EACT,GAGA,SAAS,KAAK,YAAYA,CAAM,GAGzB,MAAM;AAEX,IAAKC,MACHD,EAAO,SAAS,MAChBA,EAAO,UAAU,OAInBA,EAAO,OAAA;AAGP,UAAME,IAAY,SAAS,eAAe,iBAAiB;AAC3D,IAAIA,KACFA,EAAU,OAAA,GAGZ,QAAQ,IAAI,6BAA6B;AAAA,EAC3C;AACF;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["export interface ChatbotLoaderOptions {\r\n /** The unique identifier for your chatbot. You can find this in your RoboDialog dashboard. */\r\n chatbotId: string;\r\n /** Optional: The ID of the currently logged-in user to sync conversation history. */\r\n userId?: string;\r\n /** Optional: The email of the user for lead capture or identification. */\r\n email?: string;\r\n /** Optional: A bearer token if your API requires needs authentication. */\r\n bearer?: string;\r\n /** Optional: Set to true to open the chatbot in full screen mode. */\r\n fullScreen?: boolean;\r\n /** \r\n * Optional: Override the default widget script URL.\r\n * Use this to pin a specific version or load from a custom domain.\r\n */\r\n widgetUrl?: string;\r\n}\r\n\r\n/**\r\n * Initializes and injects the RoboDialog chat widget into the page.\r\n * \r\n * This function creates a script tag that loads the widget code and appends it to the document body.\r\n * It returns a cleanup function that removes the widget and the script tag.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { Chat } from 'robodialog';\r\n * \r\n * // 1. Basic usage\r\n * Chat({\r\n * chatbotId: 'your-chatbot-id'\r\n * });\r\n * \r\n * // 2. With authenticated user data\r\n * Chat({\r\n * chatbotId: 'your-chatbot-id',\r\n * userId: 'user-123',\r\n * email: 'user@example.com'\r\n * });\r\n * \r\n * // 3. Usage in a React useEffect hook\r\n * useEffect(() => {\r\n * const cleanup = Chat({\r\n * chatbotId: 'your-chatbot-id'\r\n * });\r\n * \r\n * // Cleanup on unmount\r\n * return cleanup;\r\n * }, []);\r\n * ```\r\n * \r\n * @param options - Configuration options for the chatbot widget.\r\n * @returns A function that destroys the widget and removes the script tag when called.\r\n */\r\nexport function Chat(options: ChatbotLoaderOptions): () => void {\r\n // Validate required options\r\n if (!options.chatbotId) {\r\n throw new Error('[RoboDialog] chatbotId is required');\r\n }\r\n\r\n // Check if widget is already loaded\r\n const existingContainer = document.getElementById('my-chatbot-root');\r\n if (existingContainer) {\r\n console.warn('[RoboDialog] Widget is already loaded. Skipping.');\r\n return () => {};\r\n }\r\n\r\n // Create script element\r\n const script = document.createElement('script');\r\n \r\n // Set script source with default CDN\r\n script.src = options.widgetUrl || 'https://cdn.jsdelivr.net/npm/robodialog/dist/widget.js';\r\n\r\n // Set required data attribute\r\n script.dataset.chatbotId = options.chatbotId;\r\n \r\n // Set optional data attributes\r\n if (options.userId) {\r\n script.dataset.userId = options.userId;\r\n }\r\n \r\n if (options.email) {\r\n script.dataset.email = options.email;\r\n }\r\n \r\n if (options.bearer) {\r\n script.dataset.bearer = options.bearer;\r\n }\r\n\r\n if (options.fullScreen) {\r\n script.dataset.fullScreen = 'true';\r\n }\r\n\r\n // Add error handling\r\n let isLoaded = false;\r\n script.onload = () => {\r\n isLoaded = true;\r\n };\r\n \r\n script.onerror = () => {\r\n console.error('[RoboDialog] Failed to load widget from', script.src);\r\n script.remove();\r\n };\r\n\r\n // Append to document body\r\n document.body.appendChild(script);\r\n\r\n // Return cleanup function\r\n return () => {\r\n // Remove event listeners if not loaded yet\r\n if (!isLoaded) {\r\n script.onload = null;\r\n script.onerror = null;\r\n }\r\n \r\n // Remove script tag\r\n script.remove();\r\n \r\n // Remove container div created by the widget\r\n const container = document.getElementById('my-chatbot-root');\r\n if (container) {\r\n container.remove();\r\n }\r\n \r\n console.log('[RoboDialog] Widget removed');\r\n };\r\n}\r\n\r\n// Default export for convenience\r\nexport default Chat;"],"names":["Chat","options","script","isLoaded","container"],"mappings":"AAsDO,SAASA,EAAKC,GAA2C;AAE9D,MAAI,CAACA,EAAQ;AACX,UAAM,IAAI,MAAM,oCAAoC;AAKtD,MAD0B,SAAS,eAAe,iBAAiB;AAEjE,mBAAQ,KAAK,kDAAkD,GACxD,MAAM;AAAA,IAAC;AAIhB,QAAMC,IAAS,SAAS,cAAc,QAAQ;AAG9C,EAAAA,EAAO,MAAMD,EAAQ,aAAa,0DAGlCC,EAAO,QAAQ,YAAYD,EAAQ,WAG/BA,EAAQ,WACVC,EAAO,QAAQ,SAASD,EAAQ,SAG9BA,EAAQ,UACVC,EAAO,QAAQ,QAAQD,EAAQ,QAG7BA,EAAQ,WACVC,EAAO,QAAQ,SAASD,EAAQ,SAG9BA,EAAQ,eACVC,EAAO,QAAQ,aAAa;AAI9B,MAAIC,IAAW;AACf,SAAAD,EAAO,SAAS,MAAM;AACpB,IAAAC,IAAW;AAAA,EACb,GAEAD,EAAO,UAAU,MAAM;AACrB,YAAQ,MAAM,2CAA2CA,EAAO,GAAG,GACnEA,EAAO,OAAA;AAAA,EACT,GAGA,SAAS,KAAK,YAAYA,CAAM,GAGzB,MAAM;AAEX,IAAKC,MACHD,EAAO,SAAS,MAChBA,EAAO,UAAU,OAInBA,EAAO,OAAA;AAGP,UAAME,IAAY,SAAS,eAAe,iBAAiB;AAC3D,IAAIA,KACFA,EAAU,OAAA,GAGZ,QAAQ,IAAI,6BAA6B;AAAA,EAC3C;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.cjs","sources":["../src/index.tsx"],"sourcesContent":["export interface ChatbotLoaderOptions {\r\n /** The unique identifier for your chatbot. You can find this in your RoboDialog dashboard. */\r\n chatbotId: string;\r\n /** Optional: The ID of the currently logged-in user to sync conversation history. */\r\n userId?: string;\r\n /** Optional: The email of the user for lead capture or identification. */\r\n email?: string;\r\n /** Optional: A bearer token if your API requires needs authentication. */\r\n bearer?: string;\r\n /** Optional: Set to true to open the chatbot in full screen mode. */\r\n fullScreen?: boolean;\r\n /** \r\n * Optional: Override the default widget script URL.\r\n * Use this to pin a specific version or load from a custom domain.\r\n */\r\n widgetUrl?: string;\r\n}\r\n\r\n/**\r\n * Initializes and injects the RoboDialog chat widget into the page.\r\n * \r\n * This function creates a script tag that loads the widget code and appends it to the document body.\r\n * It returns a cleanup function that removes the widget and the script tag.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { Chat } from 'robodialog';\r\n * \r\n * // 1. Basic usage\r\n * Chat({\r\n * chatbotId: 'your-chatbot-id'\r\n * });\r\n * \r\n * // 2. With authenticated user data\r\n * Chat({\r\n * chatbotId: 'your-chatbot-id',\r\n * userId: 'user-123',\r\n * email: 'user@example.com'\r\n * });\r\n * \r\n * // 3. Usage in a React useEffect hook\r\n * useEffect(() => {\r\n * const cleanup = Chat({\r\n * chatbotId: 'your-chatbot-id'\r\n * });\r\n * \r\n * // Cleanup on unmount\r\n * return cleanup;\r\n * }, []);\r\n * ```\r\n * \r\n * @param options - Configuration options for the chatbot widget.\r\n * @returns A function that destroys the widget and removes the script tag when called.\r\n */\r\nexport function Chat(options: ChatbotLoaderOptions): () => void {\r\n // Validate required options\r\n if (!options.chatbotId) {\r\n throw new Error('[RoboDialog] chatbotId is required');\r\n }\r\n\r\n // Check if widget is already loaded\r\n const existingContainer = document.getElementById('my-chatbot-root');\r\n if (existingContainer) {\r\n console.warn('[RoboDialog] Widget is already loaded. Skipping.');\r\n return () => {};\r\n }\r\n\r\n // Create script element\r\n const script = document.createElement('script');\r\n \r\n // Set script source with default CDN\r\n script.src = options.widgetUrl || 'https://cdn.jsdelivr.net/npm/robodialog/dist/widget.js';\r\n \r\n // Set required data attribute\r\n script.dataset.chatbotId = options.chatbotId;\r\n \r\n // Set optional data attributes\r\n if (options.userId) {\r\n script.dataset.userId = options.userId;\r\n }\r\n \r\n if (options.email) {\r\n script.dataset.email = options.email;\r\n }\r\n \r\n if (options.bearer) {\r\n script.dataset.bearer = options.bearer;\r\n }\r\n\r\n if (options.fullScreen) {\r\n script.dataset.fullScreen = 'true';\r\n }\r\n\r\n // Add error handling\r\n let isLoaded = false;\r\n script.onload = () => {\r\n isLoaded = true;\r\n };\r\n \r\n script.onerror = () => {\r\n console.error('[RoboDialog] Failed to load widget from', script.src);\r\n script.remove();\r\n };\r\n\r\n // Append to document body\r\n document.body.appendChild(script);\r\n\r\n // Return cleanup function\r\n return () => {\r\n // Remove event listeners if not loaded yet\r\n if (!isLoaded) {\r\n script.onload = null;\r\n script.onerror = null;\r\n }\r\n \r\n // Remove script tag\r\n script.remove();\r\n \r\n // Remove container div created by the widget\r\n const container = document.getElementById('my-chatbot-root');\r\n if (container) {\r\n container.remove();\r\n }\r\n \r\n console.log('[RoboDialog] Widget removed');\r\n };\r\n}\r\n\r\n// Default export for convenience\r\nexport default Chat;"],"names":["Chat","options","script","isLoaded","container"],"mappings":"kOAsDO,SAASA,EAAKC,EAA2C,CAE9D,GAAI,CAACA,EAAQ,UACX,MAAM,IAAI,MAAM,oCAAoC,EAKtD,GAD0B,SAAS,eAAe,iBAAiB,EAEjE,eAAQ,KAAK,kDAAkD,EACxD,IAAM,CAAC,EAIhB,MAAMC,EAAS,SAAS,cAAc,QAAQ,EAG9CA,EAAO,IAAMD,EAAQ,WAAa,yDAGlCC,EAAO,QAAQ,UAAYD,EAAQ,UAG/BA,EAAQ,SACVC,EAAO,QAAQ,OAASD,EAAQ,QAG9BA,EAAQ,QACVC,EAAO,QAAQ,MAAQD,EAAQ,OAG7BA,EAAQ,SACVC,EAAO,QAAQ,OAASD,EAAQ,QAG9BA,EAAQ,aACVC,EAAO,QAAQ,WAAa,QAI9B,IAAIC,EAAW,GACf,OAAAD,EAAO,OAAS,IAAM,CACpBC,EAAW,EACb,EAEAD,EAAO,QAAU,IAAM,CACrB,QAAQ,MAAM,0CAA2CA,EAAO,GAAG,EACnEA,EAAO,OAAA,CACT,EAGA,SAAS,KAAK,YAAYA,CAAM,EAGzB,IAAM,CAENC,IACHD,EAAO,OAAS,KAChBA,EAAO,QAAU,MAInBA,EAAO,OAAA,EAGP,MAAME,EAAY,SAAS,eAAe,iBAAiB,EACvDA,GACFA,EAAU,OAAA,EAGZ,QAAQ,IAAI,6BAA6B,CAC3C,CACF"}
1
+ {"version":3,"file":"index.umd.cjs","sources":["../src/index.tsx"],"sourcesContent":["export interface ChatbotLoaderOptions {\r\n /** The unique identifier for your chatbot. You can find this in your RoboDialog dashboard. */\r\n chatbotId: string;\r\n /** Optional: The ID of the currently logged-in user to sync conversation history. */\r\n userId?: string;\r\n /** Optional: The email of the user for lead capture or identification. */\r\n email?: string;\r\n /** Optional: A bearer token if your API requires needs authentication. */\r\n bearer?: string;\r\n /** Optional: Set to true to open the chatbot in full screen mode. */\r\n fullScreen?: boolean;\r\n /** \r\n * Optional: Override the default widget script URL.\r\n * Use this to pin a specific version or load from a custom domain.\r\n */\r\n widgetUrl?: string;\r\n}\r\n\r\n/**\r\n * Initializes and injects the RoboDialog chat widget into the page.\r\n * \r\n * This function creates a script tag that loads the widget code and appends it to the document body.\r\n * It returns a cleanup function that removes the widget and the script tag.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { Chat } from 'robodialog';\r\n * \r\n * // 1. Basic usage\r\n * Chat({\r\n * chatbotId: 'your-chatbot-id'\r\n * });\r\n * \r\n * // 2. With authenticated user data\r\n * Chat({\r\n * chatbotId: 'your-chatbot-id',\r\n * userId: 'user-123',\r\n * email: 'user@example.com'\r\n * });\r\n * \r\n * // 3. Usage in a React useEffect hook\r\n * useEffect(() => {\r\n * const cleanup = Chat({\r\n * chatbotId: 'your-chatbot-id'\r\n * });\r\n * \r\n * // Cleanup on unmount\r\n * return cleanup;\r\n * }, []);\r\n * ```\r\n * \r\n * @param options - Configuration options for the chatbot widget.\r\n * @returns A function that destroys the widget and removes the script tag when called.\r\n */\r\nexport function Chat(options: ChatbotLoaderOptions): () => void {\r\n // Validate required options\r\n if (!options.chatbotId) {\r\n throw new Error('[RoboDialog] chatbotId is required');\r\n }\r\n\r\n // Check if widget is already loaded\r\n const existingContainer = document.getElementById('my-chatbot-root');\r\n if (existingContainer) {\r\n console.warn('[RoboDialog] Widget is already loaded. Skipping.');\r\n return () => {};\r\n }\r\n\r\n // Create script element\r\n const script = document.createElement('script');\r\n \r\n // Set script source with default CDN\r\n script.src = options.widgetUrl || 'https://cdn.jsdelivr.net/npm/robodialog/dist/widget.js';\r\n\r\n // Set required data attribute\r\n script.dataset.chatbotId = options.chatbotId;\r\n \r\n // Set optional data attributes\r\n if (options.userId) {\r\n script.dataset.userId = options.userId;\r\n }\r\n \r\n if (options.email) {\r\n script.dataset.email = options.email;\r\n }\r\n \r\n if (options.bearer) {\r\n script.dataset.bearer = options.bearer;\r\n }\r\n\r\n if (options.fullScreen) {\r\n script.dataset.fullScreen = 'true';\r\n }\r\n\r\n // Add error handling\r\n let isLoaded = false;\r\n script.onload = () => {\r\n isLoaded = true;\r\n };\r\n \r\n script.onerror = () => {\r\n console.error('[RoboDialog] Failed to load widget from', script.src);\r\n script.remove();\r\n };\r\n\r\n // Append to document body\r\n document.body.appendChild(script);\r\n\r\n // Return cleanup function\r\n return () => {\r\n // Remove event listeners if not loaded yet\r\n if (!isLoaded) {\r\n script.onload = null;\r\n script.onerror = null;\r\n }\r\n \r\n // Remove script tag\r\n script.remove();\r\n \r\n // Remove container div created by the widget\r\n const container = document.getElementById('my-chatbot-root');\r\n if (container) {\r\n container.remove();\r\n }\r\n \r\n console.log('[RoboDialog] Widget removed');\r\n };\r\n}\r\n\r\n// Default export for convenience\r\nexport default Chat;"],"names":["Chat","options","script","isLoaded","container"],"mappings":"kOAsDO,SAASA,EAAKC,EAA2C,CAE9D,GAAI,CAACA,EAAQ,UACX,MAAM,IAAI,MAAM,oCAAoC,EAKtD,GAD0B,SAAS,eAAe,iBAAiB,EAEjE,eAAQ,KAAK,kDAAkD,EACxD,IAAM,CAAC,EAIhB,MAAMC,EAAS,SAAS,cAAc,QAAQ,EAG9CA,EAAO,IAAMD,EAAQ,WAAa,yDAGlCC,EAAO,QAAQ,UAAYD,EAAQ,UAG/BA,EAAQ,SACVC,EAAO,QAAQ,OAASD,EAAQ,QAG9BA,EAAQ,QACVC,EAAO,QAAQ,MAAQD,EAAQ,OAG7BA,EAAQ,SACVC,EAAO,QAAQ,OAASD,EAAQ,QAG9BA,EAAQ,aACVC,EAAO,QAAQ,WAAa,QAI9B,IAAIC,EAAW,GACf,OAAAD,EAAO,OAAS,IAAM,CACpBC,EAAW,EACb,EAEAD,EAAO,QAAU,IAAM,CACrB,QAAQ,MAAM,0CAA2CA,EAAO,GAAG,EACnEA,EAAO,OAAA,CACT,EAGA,SAAS,KAAK,YAAYA,CAAM,EAGzB,IAAM,CAENC,IACHD,EAAO,OAAS,KAChBA,EAAO,QAAU,MAInBA,EAAO,OAAA,EAGP,MAAME,EAAY,SAAS,eAAe,iBAAiB,EACvDA,GACFA,EAAU,OAAA,EAGZ,QAAQ,IAAI,6BAA6B,CAC3C,CACF"}