@nlux/react
Advanced tools
Comparing version 0.8.12 to 0.8.13
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("@nlux/core"),t=require("react"),r=require("react-dom");const n=e=>new Promise((t=>{const n=document.createElement("div");r.render(e,n,(()=>{if(1!==n.children.length||!n.firstElementChild)throw new Error("Expected exactly one child");t(n.firstElementChild)}))})),o=(e,t)=>{if(void 0===e&&void 0===t)return;if(void 0!==e&&void 0===t){const t={},r=Object.keys(e);for(const e of r)t[e]=void 0;return t}if(void 0===e&&void 0!==t)return t;if(!t||!e)return;let r=!1;const n={},o=Object.keys(t);for(const i of o)e[i]!==t[i]&&(n[i]=t[i],r=!0);return r?n:void 0};Object.defineProperty(exports,"NluxConfigError",{enumerable:!0,get:function(){return e.NluxConfigError}}),Object.defineProperty(exports,"NluxError",{enumerable:!0,get:function(){return e.NluxError}}),Object.defineProperty(exports,"NluxRenderingError",{enumerable:!0,get:function(){return e.NluxRenderingError}}),Object.defineProperty(exports,"NluxUsageError",{enumerable:!0,get:function(){return e.NluxUsageError}}),Object.defineProperty(exports,"NluxValidationError",{enumerable:!0,get:function(){return e.NluxValidationError}}),Object.defineProperty(exports,"debug",{enumerable:!0,get:function(){return e.debug}}),exports.AiChat=r=>{const i=t.useRef(null),[s,u]=t.useState(null),a=t.useRef(null);return t.useEffect((()=>{if(!i.current)throw new Error("Root element is not defined");let t=!0;const{adapter:o,className:s,syntaxHighlighter:u,layoutOptions:c,conversationOptions:p,promptBoxOptions:l,personaOptions:d}=r;let f=e.createAiChat().withAdapter(o);return c&&(f=f.withLayoutOptions(c)),l&&(f=f.withPromptBoxOptions(l)),p&&(f=f.withConversationOptions(p)),s&&(f=f.withClassName(s)),u&&(f=f.withSyntaxHighlighter(u)),d?(async e=>{const[t,r]=await Promise.all([(async()=>{if(!e.bot)return;const t="string"==typeof e.bot.picture?e.bot.picture:await n(e.bot.picture);return{name:e.bot.name,tagline:e.bot.tagline,picture:t}})(),(async()=>{if(!e.user)return;const t="string"==typeof e.user.picture?e.user.picture:await n(e.user.picture);return{name:e.user.name,picture:t}})()]);return{bot:t,user:r}})(d).then((r=>{f=f.withPersonaOptions(r),t&&(i.current?(f.mount(i.current),a.current=f):e.warn("Root element is not defined! AiChat cannot be mounted."))})):(f.mount(i.current),a.current=f),()=>{t=!1,f?.unmount()}}),[]),t.useEffect((()=>{if(s){if(s.adapter!==r.adapter)throw new Error("Adapter passed to <AiChat /> component cannot be changed. Make sure you use Reacts useMemo hook to memoize the adapter instance.");a.current&&((e,t,r)=>{let n=!1;const i=o(t.layoutOptions,r.layoutOptions),s=o(t.conversationOptions,r.conversationOptions),u=o(t.promptBoxOptions,r.promptBoxOptions);o(t.personaOptions,r.personaOptions),[i,s,u].some((e=>void 0!==e))&&(n=!0);const a={layoutOptions:i??{},conversationOptions:s??{},promptBoxOptions:u??{}};t.className!==r.className&&(a.className=r.className,n=!0),t.syntaxHighlighter!==r.syntaxHighlighter&&(a.syntaxHighlighter=r.syntaxHighlighter,n=!0),n&&e.updateProps(a)})(a.current,s,r)}else u(r)}),[r]),t.createElement("div",{ref:i})}; | ||
"use strict";var e=require("@nlux/core"),t=require("react"),r=require("react-dom");const n=e=>new Promise((t=>{const n=document.createElement("div");r.render(e,n,(()=>{if(1!==n.children.length||!n.firstElementChild)throw new Error("Expected exactly one child");t(n.firstElementChild)}))})),o=async e=>{const[t,r]=await Promise.all([(async()=>{if(!e.bot)return;const t="string"==typeof e.bot.picture?e.bot.picture:await n(e.bot.picture);return{name:e.bot.name,tagline:e.bot.tagline,picture:t}})(),(async()=>{if(!e.user)return;const t="string"==typeof e.user.picture?e.user.picture:await n(e.user.picture);return{name:e.user.name,picture:t}})()]);return{bot:t,user:r}},i=(e,t)=>{if(void 0===e&&void 0===t)return;if(void 0!==e&&void 0===t){const t={},r=Object.keys(e);for(const e of r)t[e]=void 0;return t}if(void 0===e&&void 0!==t)return t;if(!t||!e)return;let r=!1;const n={},o=Object.keys(t);for(const i of o)e[i]!==t[i]&&(n[i]=t[i],r=!0);return r?n:void 0},a=async(t,r)=>{const n=i(t.layoutOptions,r.layoutOptions),a=i(t.conversationOptions,r.conversationOptions),s=i(t.promptBoxOptions,r.promptBoxOptions),u=await(async(e,t)=>{const r={};if((void 0!==e||void 0!==t)&&(e?.bot!==t?.bot&&(r.bot=void 0===t?.bot?void 0:(await o({bot:t.bot})).bot),e?.user!==t?.user&&(r.user=void 0===t?.user?void 0:(await o({user:t.user})).user),0!==Object.keys(r).length))return r})(t.personaOptions,r.personaOptions),c={};void 0!==n&&(c.layoutOptions=n??{}),void 0!==a&&(c.conversationOptions=a??{}),void 0!==s&&(c.promptBoxOptions=s??{}),void 0!==u&&(c.personaOptions=u??{});const p=t.adapter!==r.adapter?r.adapter:void 0;if(void 0!==p){const t=(t=>{let r="unknown";const n=t;if("function"==typeof n?.create)r="builder";else if("function"==typeof n?.fetchText||"function"==typeof n?.streamText)return r="instance",t;if("unknown"!==r){if("builder"===r){const t=n.create();return"function"==typeof t?.fetchText||"function"==typeof t?.streamText?t:void e.warn("The adapter builder did not return a valid adapter.")}return t}e.warn("Unable to determine the type of the adapter.")})(p);t?c.adapter=t:e.warn({message:"Invalid new adapter property provided! The adapter must be an instance of Adapter or AdapterBuilder.",type:"invalid-adapter"})}t.className!==r.className&&(c.className=r.className),t.syntaxHighlighter!==r.syntaxHighlighter&&(c.syntaxHighlighter=r.syntaxHighlighter);if(Object.keys(c).length>0)return c};Object.defineProperty(exports,"NluxConfigError",{enumerable:!0,get:function(){return e.NluxConfigError}}),Object.defineProperty(exports,"NluxError",{enumerable:!0,get:function(){return e.NluxError}}),Object.defineProperty(exports,"NluxRenderingError",{enumerable:!0,get:function(){return e.NluxRenderingError}}),Object.defineProperty(exports,"NluxUsageError",{enumerable:!0,get:function(){return e.NluxUsageError}}),Object.defineProperty(exports,"NluxValidationError",{enumerable:!0,get:function(){return e.NluxValidationError}}),Object.defineProperty(exports,"debug",{enumerable:!0,get:function(){return e.debug}}),exports.AiChat=r=>{const n=t.useRef(null),[i,s]=t.useState(null),u=t.useRef(null);return t.useEffect((()=>{if(!n.current)throw new Error("Root element is not defined");let t=!0;const{adapter:i,className:a,syntaxHighlighter:s,layoutOptions:c,conversationOptions:p,promptBoxOptions:d,personaOptions:l}=r;let f=e.createAiChat().withAdapter(i);return c&&(f=f.withLayoutOptions(c)),d&&(f=f.withPromptBoxOptions(d)),p&&(f=f.withConversationOptions(p)),a&&(f=f.withClassName(a)),s&&(f=f.withSyntaxHighlighter(s)),l?o(l).then((r=>{f=f.withPersonaOptions(r),t&&(n.current?(f.mount(n.current),u.current=f):e.warn("Root element is not defined! AiChat cannot be mounted."))})):(f.mount(n.current),u.current=f),()=>{t=!1,f?.unmount()}}),[]),t.useEffect((()=>{let t=!1;if(i)return u.current&&a(i,r).then((n=>{!t&&n&&(u.current?(s(r),u.current.updateProps(n)):e.warn("AiChat is not defined! Cannot update."))})),()=>{t=!0};s(r)}),[r,i]),t.createElement("div",{ref:n})}; |
@@ -1,1 +0,1 @@ | ||
import{createAiChat as t,warn as e}from"@nlux/core";export{NluxConfigError,NluxError,NluxRenderingError,NluxUsageError,NluxValidationError,debug}from"@nlux/core";import o,{useRef as r,useState as n,useEffect as i}from"react";import{render as s}from"react-dom";const a=t=>new Promise((e=>{const o=document.createElement("div");s(t,o,(()=>{if(1!==o.children.length||!o.firstElementChild)throw new Error("Expected exactly one child");e(o.firstElementChild)}))})),u=(t,e)=>{if(void 0===t&&void 0===e)return;if(void 0!==t&&void 0===e){const e={},o=Object.keys(t);for(const t of o)e[t]=void 0;return e}if(void 0===t&&void 0!==e)return e;if(!e||!t)return;let o=!1;const r={},n=Object.keys(e);for(const i of n)t[i]!==e[i]&&(r[i]=e[i],o=!0);return o?r:void 0},c=s=>{const c=r(null),[p,l]=n(null),m=r(null);return i((()=>{if(!c.current)throw new Error("Root element is not defined");let o=!0;const{adapter:r,className:n,syntaxHighlighter:i,layoutOptions:u,conversationOptions:p,promptBoxOptions:l,personaOptions:d}=s;let h=t().withAdapter(r);return u&&(h=h.withLayoutOptions(u)),l&&(h=h.withPromptBoxOptions(l)),p&&(h=h.withConversationOptions(p)),n&&(h=h.withClassName(n)),i&&(h=h.withSyntaxHighlighter(i)),d?(async t=>{const[e,o]=await Promise.all([(async()=>{if(!t.bot)return;const e="string"==typeof t.bot.picture?t.bot.picture:await a(t.bot.picture);return{name:t.bot.name,tagline:t.bot.tagline,picture:e}})(),(async()=>{if(!t.user)return;const e="string"==typeof t.user.picture?t.user.picture:await a(t.user.picture);return{name:t.user.name,picture:e}})()]);return{bot:e,user:o}})(d).then((t=>{h=h.withPersonaOptions(t),o&&(c.current?(h.mount(c.current),m.current=h):e("Root element is not defined! AiChat cannot be mounted."))})):(h.mount(c.current),m.current=h),()=>{o=!1,h?.unmount()}}),[]),i((()=>{if(p){if(p.adapter!==s.adapter)throw new Error("Adapter passed to <AiChat /> component cannot be changed. Make sure you use Reacts useMemo hook to memoize the adapter instance.");m.current&&((t,e,o)=>{let r=!1;const n=u(e.layoutOptions,o.layoutOptions),i=u(e.conversationOptions,o.conversationOptions),s=u(e.promptBoxOptions,o.promptBoxOptions);u(e.personaOptions,o.personaOptions),[n,i,s].some((t=>void 0!==t))&&(r=!0);const a={layoutOptions:n??{},conversationOptions:i??{},promptBoxOptions:s??{}};e.className!==o.className&&(a.className=o.className,r=!0),e.syntaxHighlighter!==o.syntaxHighlighter&&(a.syntaxHighlighter=o.syntaxHighlighter,r=!0),r&&t.updateProps(a)})(m.current,p,s)}else l(s)}),[s]),o.createElement("div",{ref:c})};export{c as AiChat}; | ||
import{warn as t,createAiChat as e}from"@nlux/core";export{NluxConfigError,NluxError,NluxRenderingError,NluxUsageError,NluxValidationError,debug}from"@nlux/core";import r,{useRef as o,useState as n,useEffect as i}from"react";import{render as a}from"react-dom";const s=t=>new Promise((e=>{const r=document.createElement("div");a(t,r,(()=>{if(1!==r.children.length||!r.firstElementChild)throw new Error("Expected exactly one child");e(r.firstElementChild)}))})),u=async t=>{const[e,r]=await Promise.all([(async()=>{if(!t.bot)return;const e="string"==typeof t.bot.picture?t.bot.picture:await s(t.bot.picture);return{name:t.bot.name,tagline:t.bot.tagline,picture:e}})(),(async()=>{if(!t.user)return;const e="string"==typeof t.user.picture?t.user.picture:await s(t.user.picture);return{name:t.user.name,picture:e}})()]);return{bot:e,user:r}},p=(t,e)=>{if(void 0===t&&void 0===e)return;if(void 0!==t&&void 0===e){const e={},r=Object.keys(t);for(const t of r)e[t]=void 0;return e}if(void 0===t&&void 0!==e)return e;if(!e||!t)return;let r=!1;const o={},n=Object.keys(e);for(const i of n)t[i]!==e[i]&&(o[i]=e[i],r=!0);return r?o:void 0},c=async(e,r)=>{const o=p(e.layoutOptions,r.layoutOptions),n=p(e.conversationOptions,r.conversationOptions),i=p(e.promptBoxOptions,r.promptBoxOptions),a=await(async(t,e)=>{const r={};if((void 0!==t||void 0!==e)&&(t?.bot!==e?.bot&&(r.bot=void 0===e?.bot?void 0:(await u({bot:e.bot})).bot),t?.user!==e?.user&&(r.user=void 0===e?.user?void 0:(await u({user:e.user})).user),0!==Object.keys(r).length))return r})(e.personaOptions,r.personaOptions),s={};void 0!==o&&(s.layoutOptions=o??{}),void 0!==n&&(s.conversationOptions=n??{}),void 0!==i&&(s.promptBoxOptions=i??{}),void 0!==a&&(s.personaOptions=a??{});const c=e.adapter!==r.adapter?r.adapter:void 0;if(void 0!==c){const e=(e=>{let r="unknown";const o=e;if("function"==typeof o?.create)r="builder";else if("function"==typeof o?.fetchText||"function"==typeof o?.streamText)return r="instance",e;if("unknown"!==r){if("builder"===r){const e=o.create();return"function"==typeof e?.fetchText||"function"==typeof e?.streamText?e:void t("The adapter builder did not return a valid adapter.")}return e}t("Unable to determine the type of the adapter.")})(c);e?s.adapter=e:t({message:"Invalid new adapter property provided! The adapter must be an instance of Adapter or AdapterBuilder.",type:"invalid-adapter"})}e.className!==r.className&&(s.className=r.className),e.syntaxHighlighter!==r.syntaxHighlighter&&(s.syntaxHighlighter=r.syntaxHighlighter);if(Object.keys(s).length>0)return s},d=a=>{const s=o(null),[p,d]=n(null),l=o(null);return i((()=>{if(!s.current)throw new Error("Root element is not defined");let r=!0;const{adapter:o,className:n,syntaxHighlighter:i,layoutOptions:p,conversationOptions:c,promptBoxOptions:d,personaOptions:f}=a;let m=e().withAdapter(o);return p&&(m=m.withLayoutOptions(p)),d&&(m=m.withPromptBoxOptions(d)),c&&(m=m.withConversationOptions(c)),n&&(m=m.withClassName(n)),i&&(m=m.withSyntaxHighlighter(i)),f?u(f).then((e=>{m=m.withPersonaOptions(e),r&&(s.current?(m.mount(s.current),l.current=m):t("Root element is not defined! AiChat cannot be mounted."))})):(m.mount(s.current),l.current=m),()=>{r=!1,m?.unmount()}}),[]),i((()=>{let e=!1;if(p)return l.current&&c(p,a).then((r=>{!e&&r&&(l.current?(d(a),l.current.updateProps(r)):t("AiChat is not defined! Cannot update."))})),()=>{e=!0};d(a)}),[a,p]),r.createElement("div",{ref:s})};export{d as AiChat}; |
@@ -14,6 +14,6 @@ import { Adapter, AdapterBuilder, HighlighterExtension, ConversationOptions, LayoutOptions, PromptBoxOptions } from '@nlux/core'; | ||
} | ||
type PersonaOptions = { | ||
interface PersonaOptions { | ||
bot?: BotPersona; | ||
user?: UserPersona; | ||
}; | ||
} | ||
@@ -20,0 +20,0 @@ /** |
{ | ||
"name": "@nlux/react", | ||
"version": "0.8.12", | ||
"version": "0.8.13", | ||
"description": "NLUX React is a library for building conversational AI interfaces, with support for OpenAI, HuggingFace, and more.", | ||
@@ -57,3 +57,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@nlux/core": "0.8.12" | ||
"@nlux/core": "0.8.13" | ||
}, | ||
@@ -60,0 +60,0 @@ "peerDependencies": { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/core"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@nlux/core","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/react"]={},e.core,e.React,e.reactDom)}(this,(function(e,t,r,n){"use strict";const o=e=>new Promise((t=>{const r=document.createElement("div");n.render(e,r,(()=>{if(1!==r.children.length||!r.firstElementChild)throw new Error("Expected exactly one child");t(r.firstElementChild)}))})),i=(e,t)=>{if(void 0===e&&void 0===t)return;if(void 0!==e&&void 0===t){const t={},r=Object.keys(e);for(const e of r)t[e]=void 0;return t}if(void 0===e&&void 0!==t)return t;if(!t||!e)return;let r=!1;const n={},o=Object.keys(t);for(const i of o)e[i]!==t[i]&&(n[i]=t[i],r=!0);return r?n:void 0};Object.defineProperty(e,"NluxConfigError",{enumerable:!0,get:function(){return t.NluxConfigError}}),Object.defineProperty(e,"NluxError",{enumerable:!0,get:function(){return t.NluxError}}),Object.defineProperty(e,"NluxRenderingError",{enumerable:!0,get:function(){return t.NluxRenderingError}}),Object.defineProperty(e,"NluxUsageError",{enumerable:!0,get:function(){return t.NluxUsageError}}),Object.defineProperty(e,"NluxValidationError",{enumerable:!0,get:function(){return t.NluxValidationError}}),Object.defineProperty(e,"debug",{enumerable:!0,get:function(){return t.debug}}),e.AiChat=e=>{const n=r.useRef(null),[s,u]=r.useState(null),a=r.useRef(null);return r.useEffect((()=>{if(!n.current)throw new Error("Root element is not defined");let r=!0;const{adapter:i,className:s,syntaxHighlighter:u,layoutOptions:c,conversationOptions:l,promptBoxOptions:p,personaOptions:d}=e;let f=t.createAiChat().withAdapter(i);return c&&(f=f.withLayoutOptions(c)),p&&(f=f.withPromptBoxOptions(p)),l&&(f=f.withConversationOptions(l)),s&&(f=f.withClassName(s)),u&&(f=f.withSyntaxHighlighter(u)),d?(async e=>{const[t,r]=await Promise.all([(async()=>{if(!e.bot)return;const t="string"==typeof e.bot.picture?e.bot.picture:await o(e.bot.picture);return{name:e.bot.name,tagline:e.bot.tagline,picture:t}})(),(async()=>{if(!e.user)return;const t="string"==typeof e.user.picture?e.user.picture:await o(e.user.picture);return{name:e.user.name,picture:t}})()]);return{bot:t,user:r}})(d).then((e=>{f=f.withPersonaOptions(e),r&&(n.current?(f.mount(n.current),a.current=f):t.warn("Root element is not defined! AiChat cannot be mounted."))})):(f.mount(n.current),a.current=f),()=>{r=!1,f?.unmount()}}),[]),r.useEffect((()=>{if(s){if(s.adapter!==e.adapter)throw new Error("Adapter passed to <AiChat /> component cannot be changed. Make sure you use Reacts useMemo hook to memoize the adapter instance.");a.current&&((e,t,r)=>{let n=!1;const o=i(t.layoutOptions,r.layoutOptions),s=i(t.conversationOptions,r.conversationOptions),u=i(t.promptBoxOptions,r.promptBoxOptions);i(t.personaOptions,r.personaOptions),[o,s,u].some((e=>void 0!==e))&&(n=!0);const a={layoutOptions:o??{},conversationOptions:s??{},promptBoxOptions:u??{}};t.className!==r.className&&(a.className=r.className,n=!0),t.syntaxHighlighter!==r.syntaxHighlighter&&(a.syntaxHighlighter=r.syntaxHighlighter,n=!0),n&&e.updateProps(a)})(a.current,s,e)}else u(e)}),[e]),r.createElement("div",{ref:n})}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/core"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@nlux/core","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/react"]={},e.core,e.React,e.reactDom)}(this,(function(e,t,r,n){"use strict";const o=e=>new Promise((t=>{const r=document.createElement("div");n.render(e,r,(()=>{if(1!==r.children.length||!r.firstElementChild)throw new Error("Expected exactly one child");t(r.firstElementChild)}))})),i=async e=>{const[t,r]=await Promise.all([(async()=>{if(!e.bot)return;const t="string"==typeof e.bot.picture?e.bot.picture:await o(e.bot.picture);return{name:e.bot.name,tagline:e.bot.tagline,picture:t}})(),(async()=>{if(!e.user)return;const t="string"==typeof e.user.picture?e.user.picture:await o(e.user.picture);return{name:e.user.name,picture:t}})()]);return{bot:t,user:r}},a=(e,t)=>{if(void 0===e&&void 0===t)return;if(void 0!==e&&void 0===t){const t={},r=Object.keys(e);for(const e of r)t[e]=void 0;return t}if(void 0===e&&void 0!==t)return t;if(!t||!e)return;let r=!1;const n={},o=Object.keys(t);for(const i of o)e[i]!==t[i]&&(n[i]=t[i],r=!0);return r?n:void 0},u=async(e,r)=>{const n=a(e.layoutOptions,r.layoutOptions),o=a(e.conversationOptions,r.conversationOptions),u=a(e.promptBoxOptions,r.promptBoxOptions),s=await(async(e,t)=>{const r={};if((void 0!==e||void 0!==t)&&(e?.bot!==t?.bot&&(r.bot=void 0===t?.bot?void 0:(await i({bot:t.bot})).bot),e?.user!==t?.user&&(r.user=void 0===t?.user?void 0:(await i({user:t.user})).user),0!==Object.keys(r).length))return r})(e.personaOptions,r.personaOptions),c={};void 0!==n&&(c.layoutOptions=n??{}),void 0!==o&&(c.conversationOptions=o??{}),void 0!==u&&(c.promptBoxOptions=u??{}),void 0!==s&&(c.personaOptions=s??{});const d=e.adapter!==r.adapter?r.adapter:void 0;if(void 0!==d){const e=(e=>{let r="unknown";const n=e;if("function"==typeof n?.create)r="builder";else if("function"==typeof n?.fetchText||"function"==typeof n?.streamText)return r="instance",e;if("unknown"!==r){if("builder"===r){const e=n.create();return"function"==typeof e?.fetchText||"function"==typeof e?.streamText?e:void t.warn("The adapter builder did not return a valid adapter.")}return e}t.warn("Unable to determine the type of the adapter.")})(d);e?c.adapter=e:t.warn({message:"Invalid new adapter property provided! The adapter must be an instance of Adapter or AdapterBuilder.",type:"invalid-adapter"})}e.className!==r.className&&(c.className=r.className),e.syntaxHighlighter!==r.syntaxHighlighter&&(c.syntaxHighlighter=r.syntaxHighlighter);if(Object.keys(c).length>0)return c};Object.defineProperty(e,"NluxConfigError",{enumerable:!0,get:function(){return t.NluxConfigError}}),Object.defineProperty(e,"NluxError",{enumerable:!0,get:function(){return t.NluxError}}),Object.defineProperty(e,"NluxRenderingError",{enumerable:!0,get:function(){return t.NluxRenderingError}}),Object.defineProperty(e,"NluxUsageError",{enumerable:!0,get:function(){return t.NluxUsageError}}),Object.defineProperty(e,"NluxValidationError",{enumerable:!0,get:function(){return t.NluxValidationError}}),Object.defineProperty(e,"debug",{enumerable:!0,get:function(){return t.debug}}),e.AiChat=e=>{const n=r.useRef(null),[o,a]=r.useState(null),s=r.useRef(null);return r.useEffect((()=>{if(!n.current)throw new Error("Root element is not defined");let r=!0;const{adapter:o,className:a,syntaxHighlighter:u,layoutOptions:c,conversationOptions:d,promptBoxOptions:p,personaOptions:l}=e;let f=t.createAiChat().withAdapter(o);return c&&(f=f.withLayoutOptions(c)),p&&(f=f.withPromptBoxOptions(p)),d&&(f=f.withConversationOptions(d)),a&&(f=f.withClassName(a)),u&&(f=f.withSyntaxHighlighter(u)),l?i(l).then((e=>{f=f.withPersonaOptions(e),r&&(n.current?(f.mount(n.current),s.current=f):t.warn("Root element is not defined! AiChat cannot be mounted."))})):(f.mount(n.current),s.current=f),()=>{r=!1,f?.unmount()}}),[]),r.useEffect((()=>{let r=!1;if(o)return s.current&&u(o,e).then((n=>{!r&&n&&(s.current?(a(e),s.current.updateProps(n)):t.warn("AiChat is not defined! Cannot update."))})),()=>{r=!0};a(e)}),[e,o]),r.createElement("div",{ref:n})}})); |
18005
101
+ Added@nlux/core@0.8.13(transitive)
- Removed@nlux/core@0.8.12(transitive)
Updated@nlux/core@0.8.13