@nlux/react
Advanced tools
Comparing version 0.8.8 to 0.8.9
@@ -1,1 +0,1 @@ | ||
"use strict";var e=require("@nlux/core"),t=require("react");const r=(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 o={},n=Object.keys(t);for(const i of n)e[i]!==t[i]&&(o[i]=t[i],r=!0);return r?o: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=o=>{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");const{adapter:t,className:r,syntaxHighlighter:i,layoutOptions:s,conversationOptions:a,promptBoxOptions:c}=o;let l=e.createAiChat().withAdapter(t);return s&&(l=l.withLayoutOptions(s)),c&&(l=l.withPromptBoxOptions(c)),a&&(l=l.withConversationOptions(a)),r&&(l=l.withClassName(r)),i&&(l=l.withSyntaxHighlighter(i)),l.mount(n.current),u.current=l,()=>{l?.unmount()}}),[]),t.useEffect((()=>{if(i){if(i.adapter!==o.adapter)throw new Error("Adapter passed to <AiChat /> component cannot be changed. Make sure you use Reacts useMemo hook to memoize the adapter instance.");u.current&&((e,t,o)=>{let n=!1;const i=r(t.layoutOptions,o.layoutOptions),s=r(t.conversationOptions,o.conversationOptions),u=r(t.promptBoxOptions,o.promptBoxOptions);[i,s,u].some((e=>void 0!==e))&&(n=!0);const a={layoutOptions:i??{},conversationOptions:s??{},promptBoxOptions:u??{}};t.className!==o.className&&(a.className=o.className,n=!0),t.syntaxHighlighter!==o.syntaxHighlighter&&(a.syntaxHighlighter=o.syntaxHighlighter,n=!0),n&&e.updateProps(a)})(u.current,i,o)}else s(o)}),[o]),t.createElement("div",{ref:n})}; | ||
"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,personas: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="string"==typeof e.bot.picture?e.bot.picture:await n(e.bot.picture),r="string"==typeof e.user.picture?e.user.picture:await n(e.user.picture);return{bot:{name:e.bot.name,tagline:e.bot.tagline,picture:t},user:{name:e.user.name,picture:r}}})(d).then((r=>{f=f.withPersonas(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.personas,r.personas),[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})}; |
@@ -1,1 +0,1 @@ | ||
import{createAiChat as t}from"@nlux/core";export{NluxConfigError,NluxError,NluxRenderingError,NluxUsageError,NluxValidationError,debug}from"@nlux/core";import o,{useRef as r,useState as e,useEffect as n}from"react";const i=(t,o)=>{if(void 0===t&&void 0===o)return;if(void 0!==t&&void 0===o){const o={},r=Object.keys(t);for(const t of r)o[t]=void 0;return o}if(void 0===t&&void 0!==o)return o;if(!o||!t)return;let r=!1;const e={},n=Object.keys(o);for(const i of n)t[i]!==o[i]&&(e[i]=o[i],r=!0);return r?e:void 0},s=s=>{const a=r(null),[p,l]=e(null),u=r(null);return n((()=>{if(!a.current)throw new Error("Root element is not defined");const{adapter:o,className:r,syntaxHighlighter:e,layoutOptions:n,conversationOptions:i,promptBoxOptions:p}=s;let l=t().withAdapter(o);return n&&(l=l.withLayoutOptions(n)),p&&(l=l.withPromptBoxOptions(p)),i&&(l=l.withConversationOptions(i)),r&&(l=l.withClassName(r)),e&&(l=l.withSyntaxHighlighter(e)),l.mount(a.current),u.current=l,()=>{l?.unmount()}}),[]),n((()=>{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.");u.current&&((t,o,r)=>{let e=!1;const n=i(o.layoutOptions,r.layoutOptions),s=i(o.conversationOptions,r.conversationOptions),a=i(o.promptBoxOptions,r.promptBoxOptions);[n,s,a].some((t=>void 0!==t))&&(e=!0);const p={layoutOptions:n??{},conversationOptions:s??{},promptBoxOptions:a??{}};o.className!==r.className&&(p.className=r.className,e=!0),o.syntaxHighlighter!==r.syntaxHighlighter&&(p.syntaxHighlighter=r.syntaxHighlighter,e=!0),e&&t.updateProps(p)})(u.current,p,s)}else l(s)}),[s]),o.createElement("div",{ref:a})};export{s as AiChat}; | ||
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)}))})),c=(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},u=s=>{const u=r(null),[p,l]=n(null),m=r(null);return i((()=>{if(!u.current)throw new Error("Root element is not defined");let o=!0;const{adapter:r,className:n,syntaxHighlighter:i,layoutOptions:c,conversationOptions:p,promptBoxOptions:l,personas:d}=s;let h=t().withAdapter(r);return c&&(h=h.withLayoutOptions(c)),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="string"==typeof t.bot.picture?t.bot.picture:await a(t.bot.picture),o="string"==typeof t.user.picture?t.user.picture:await a(t.user.picture);return{bot:{name:t.bot.name,tagline:t.bot.tagline,picture:e},user:{name:t.user.name,picture:o}}})(d).then((t=>{h=h.withPersonas(t),o&&(u.current?(h.mount(u.current),m.current=h):e("Root element is not defined! AiChat cannot be mounted."))})):(h.mount(u.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=c(e.layoutOptions,o.layoutOptions),i=c(e.conversationOptions,o.conversationOptions),s=c(e.promptBoxOptions,o.promptBoxOptions);c(e.personas,o.personas),[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:u})};export{u as AiChat}; |
import { Adapter, AdapterBuilder, HighlighterExtension, ConversationOptions, LayoutOptions, PromptBoxOptions } from '@nlux/core'; | ||
export { Adapter, DataTransferMode, NluxConfigError, NluxError, NluxRenderingError, NluxUsageError, NluxValidationError, StandardAdapter, StreamingAdapterObserver, debug } from '@nlux/core'; | ||
import React from 'react'; | ||
export { Adapter, AdapterBuilder, ConversationOptions, DataTransferMode, HighlighterExtension, LayoutOptions, NluxConfigError, NluxError, NluxRenderingError, NluxUsageError, NluxValidationError, PromptBoxOptions, StandardAdapter, StreamingAdapterObserver, debug } from '@nlux/core'; | ||
import React, { JSX } from 'react'; | ||
type PersonasOptions = { | ||
bot: { | ||
name: string; | ||
picture: string | JSX.Element; | ||
tagline?: string; | ||
}; | ||
user: { | ||
name: string; | ||
picture: string | JSX.Element; | ||
}; | ||
}; | ||
/** | ||
@@ -36,2 +48,6 @@ * Properties for the AiChat React component. | ||
promptBoxOptions?: PromptBoxOptions; | ||
/** | ||
* The options to use for the personas. | ||
*/ | ||
personas?: PersonasOptions; | ||
}; | ||
@@ -41,2 +57,2 @@ | ||
export { AiChat, type AiChatProps }; | ||
export { AiChat, type AiChatProps, type PersonasOptions }; |
{ | ||
"name": "@nlux/react", | ||
"version": "0.8.8", | ||
"version": "0.8.9", | ||
"description": "NLUX React is a library for building conversational AI interfaces, with support for OpenAI, HuggingFace, and more.", | ||
@@ -57,6 +57,7 @@ "keywords": [ | ||
"dependencies": { | ||
"@nlux/core": "0.8.8" | ||
"@nlux/core": "0.8.9" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.2.0" | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
@@ -63,0 +64,0 @@ "main": "index.js", |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/core"),require("react")):"function"==typeof define&&define.amd?define(["exports","@nlux/core","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/react"]={},e.core,e.React)}(this,(function(e,t,r){"use strict";const 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 o={},n=Object.keys(t);for(const i of n)e[i]!==t[i]&&(o[i]=t[i],r=!0);return r?o: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),[i,s]=r.useState(null),u=r.useRef(null);return r.useEffect((()=>{if(!n.current)throw new Error("Root element is not defined");const{adapter:r,className:o,syntaxHighlighter:i,layoutOptions:s,conversationOptions:a,promptBoxOptions:c}=e;let l=t.createAiChat().withAdapter(r);return s&&(l=l.withLayoutOptions(s)),c&&(l=l.withPromptBoxOptions(c)),a&&(l=l.withConversationOptions(a)),o&&(l=l.withClassName(o)),i&&(l=l.withSyntaxHighlighter(i)),l.mount(n.current),u.current=l,()=>{l?.unmount()}}),[]),r.useEffect((()=>{if(i){if(i.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.");u.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);[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)})(u.current,i,e)}else s(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=(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,personas: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="string"==typeof e.bot.picture?e.bot.picture:await o(e.bot.picture),r="string"==typeof e.user.picture?e.user.picture:await o(e.user.picture);return{bot:{name:e.bot.name,tagline:e.bot.tagline,picture:t},user:{name:e.user.name,picture:r}}})(d).then((e=>{f=f.withPersonas(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.personas,r.personas),[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})}})); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14757
89
3
+ Added@nlux/core@0.8.9(transitive)
+ Addedreact-dom@18.3.1(transitive)
+ Addedscheduler@0.23.2(transitive)
- Removed@nlux/core@0.8.8(transitive)
Updated@nlux/core@0.8.9