Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nlux/react

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nlux/react - npm Package Compare versions

Comparing version 0.8.9 to 0.8.10

2

cjs/nlux-react.js

@@ -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,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})};
"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})};

@@ -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)}))})),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{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};

@@ -5,4 +5,4 @@ import { Adapter, AdapterBuilder, HighlighterExtension, ConversationOptions, LayoutOptions, PromptBoxOptions } from '@nlux/core';

type PersonasOptions = {
bot: {
type PersonaOptions = {
bot?: {
name: string;

@@ -12,3 +12,3 @@ picture: string | JSX.Element;

};
user: {
user?: {
name: string;

@@ -51,5 +51,5 @@ picture: string | JSX.Element;

/**
* The options to use for the personas.
* The options to use for the personaOptions.
*/
personas?: PersonasOptions;
personaOptions?: PersonaOptions;
};

@@ -59,2 +59,2 @@

export { AiChat, type AiChatProps, type PersonasOptions };
export { AiChat, type AiChatProps, type PersonaOptions };
{
"name": "@nlux/react",
"version": "0.8.9",
"version": "0.8.10",
"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.9"
"@nlux/core": "0.8.10"
},

@@ -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,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})}}));
!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})}}));
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc