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

@nlux/nlbridge-react

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nlux/nlbridge-react - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

cjs/nlbridge-react.js

@@ -1,1 +0,1 @@

"use strict";var e=require("@nlux/nlbridge"),t=require("react");const r=t=>{const{url:r,dataTransferMode:n,contextId:a,taskRunner:o}=t||{};if(n&&"stream"!==n&&"fetch"!==n)throw new Error("Data transfer mode not supported");if(!r)throw new Error("Runnable URL is required");let u=e.createChatAdapter().withUrl(r);return n&&(u=u.withDataTransferMode(n)),a&&(u=u.withContextId(a)),o&&(u=u.withTaskRunner(o)),u},n=e=>{if(e)return(t,r)=>{const n=e.registeredTaskCallbacks[t];if(n)return n(...r)}};Object.defineProperty(exports,"createChatAdapter",{enumerable:!0,get:function(){return e.createChatAdapter}}),Object.defineProperty(exports,"createContextAdapter",{enumerable:!0,get:function(){return e.createContextAdapter}}),exports.useChatAdapter=e=>{const{context:a,url:o,dataTransferMode:u}=e||{},s=a?t.useContext(a.ref):void 0,[d,c]=t.useState(!1),[i,f]=t.useState(r({...e,taskRunner:n(s)}));return t.useEffect((()=>{if(!d)return void c(!0);let e=r({url:o,dataTransferMode:u,contextId:s?.contextId,taskRunner:n(s)});f(e)}),[d,s,u,o]),i};
"use strict";var e=require("@nlux/nlbridge"),t=require("react");const r=t=>{const{url:r,mode:o,context:n}=t||{};if(o&&"copilot"!==o&&"chat"!==o)throw new Error("Data transfer mode not supported");if(!r)throw new Error("Runnable URL is required");let a=e.createChatAdapter().withUrl(r);return o&&(a=a.withMode(o)),n&&(a=a.withContext(n)),a.create()};Object.defineProperty(exports,"createChatAdapter",{enumerable:!0,get:function(){return e.createChatAdapter}}),Object.defineProperty(exports,"createContextAdapter",{enumerable:!0,get:function(){return e.createContextAdapter}}),exports.useChatAdapter=e=>{const{context:o,url:n,mode:a}=e,u=o?.ref?t.useContext(o.ref):void 0,[c,d]=t.useState(r({url:n,mode:a,context:u}));return t.useEffect((()=>{let e=r({url:n,mode:a,context:u});d(e)}),[n,u]),c};

@@ -1,1 +0,1 @@

import{createChatAdapter as r}from"@nlux/nlbridge";export{createChatAdapter,createContextAdapter}from"@nlux/nlbridge";import{useContext as t,useState as e,useEffect as n}from"react";const a=t=>{const{url:e,dataTransferMode:n,contextId:a,taskRunner:o}=t||{};if(n&&"stream"!==n&&"fetch"!==n)throw new Error("Data transfer mode not supported");if(!e)throw new Error("Runnable URL is required");let d=r().withUrl(e);return n&&(d=d.withDataTransferMode(n)),a&&(d=d.withContextId(a)),o&&(d=d.withTaskRunner(o)),d},o=r=>{if(r)return(t,e)=>{const n=r.registeredTaskCallbacks[t];if(n)return n(...e)}},d=r=>{const{context:d,url:s,dataTransferMode:i}=r||{},u=d?t(d.ref):void 0,[f,c]=e(!1),[l,x]=e(a({...r,taskRunner:o(u)}));return n((()=>{if(!f)return void c(!0);let r=a({url:s,dataTransferMode:i,contextId:u?.contextId,taskRunner:o(u)});x(r)}),[f,u,i,s]),l};export{d as useChatAdapter};
import{createChatAdapter as t}from"@nlux/nlbridge";export{createChatAdapter,createContextAdapter}from"@nlux/nlbridge";import{useContext as r,useState as e,useEffect as o}from"react";const n=r=>{const{url:e,mode:o,context:n}=r||{};if(o&&"copilot"!==o&&"chat"!==o)throw new Error("Data transfer mode not supported");if(!e)throw new Error("Runnable URL is required");let c=t().withUrl(e);return o&&(c=c.withMode(o)),n&&(c=c.withContext(n)),c.create()},c=t=>{const{context:c,url:d,mode:i}=t,l=c?.ref?r(c.ref):void 0,[a,u]=e(n({url:d,mode:i,context:l}));return o((()=>{let t=n({url:d,mode:i,context:l});u(t)}),[d,l]),a};export{c as useChatAdapter};

@@ -1,2 +0,2 @@

import { ChatAdapterBuilder } from '@nlux/nlbridge';
import { ChatAdapter } from '@nlux/nlbridge';
export { ChatAdapter, ChatAdapterBuilder, ChatAdapterOptions, ContextAdapter, ContextAdapterBuilder, DataTransferMode, StandardChatAdapter, StreamingAdapterObserver, createChatAdapter, createContextAdapter } from '@nlux/nlbridge';

@@ -7,7 +7,7 @@ import { AiContext } from '@nlux/react';

url: string;
dataTransferMode?: 'stream' | 'fetch';
mode?: 'chat' | 'copilot';
context?: AiContext;
};
declare const useChatAdapter: (options: ReactChatAdapterOptions) => ChatAdapterBuilder;
declare const useChatAdapter: (options: ReactChatAdapterOptions) => ChatAdapter;
export { type ReactChatAdapterOptions, useChatAdapter };
{
"name": "@nlux/nlbridge-react",
"version": "1.0.1",
"version": "1.0.2",
"description": "The nlbridge adapters for nlux React, the React JS library for building conversational AI interfaces.",

@@ -62,6 +62,6 @@ "keywords": [

"dependencies": {
"@nlux/nlbridge": "1.0.1"
"@nlux/nlbridge": "1.0.2"
},
"peerDependencies": {
"@nlux/react": "1.0.1",
"@nlux/react": "1.0.2",
"react": "^18.2.0"

@@ -68,0 +68,0 @@ },

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/nlbridge"),require("react")):"function"==typeof define&&define.amd?define(["exports","@nlux/nlbridge","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/nlbridge-react"]={},e.nlbridge,e.react)}(this,(function(e,t,r){"use strict";const n=e=>{const{url:r,dataTransferMode:n,contextId:a,taskRunner:o}=e||{};if(n&&"stream"!==n&&"fetch"!==n)throw new Error("Data transfer mode not supported");if(!r)throw new Error("Runnable URL is required");let d=t.createChatAdapter().withUrl(r);return n&&(d=d.withDataTransferMode(n)),a&&(d=d.withContextId(a)),o&&(d=d.withTaskRunner(o)),d},a=e=>{if(e)return(t,r)=>{const n=e.registeredTaskCallbacks[t];if(n)return n(...r)}};Object.defineProperty(e,"createChatAdapter",{enumerable:!0,get:function(){return t.createChatAdapter}}),Object.defineProperty(e,"createContextAdapter",{enumerable:!0,get:function(){return t.createContextAdapter}}),e.useChatAdapter=e=>{const{context:t,url:o,dataTransferMode:d}=e||{},u=t?r.useContext(t.ref):void 0,[i,s]=r.useState(!1),[f,c]=r.useState(n({...e,taskRunner:a(u)}));return r.useEffect((()=>{if(!i)return void s(!0);let e=n({url:o,dataTransferMode:d,contextId:u?.contextId,taskRunner:a(u)});c(e)}),[i,u,d,o]),f}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@nlux/nlbridge"),require("react")):"function"==typeof define&&define.amd?define(["exports","@nlux/nlbridge","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@nlux/nlbridge-react"]={},e.nlbridge,e.react)}(this,(function(e,t,r){"use strict";const n=e=>{const{url:r,mode:n,context:o}=e||{};if(n&&"copilot"!==n&&"chat"!==n)throw new Error("Data transfer mode not supported");if(!r)throw new Error("Runnable URL is required");let a=t.createChatAdapter().withUrl(r);return n&&(a=a.withMode(n)),o&&(a=a.withContext(o)),a.create()};Object.defineProperty(e,"createChatAdapter",{enumerable:!0,get:function(){return t.createChatAdapter}}),Object.defineProperty(e,"createContextAdapter",{enumerable:!0,get:function(){return t.createContextAdapter}}),e.useChatAdapter=e=>{const{context:t,url:o,mode:a}=e,i=t?.ref?r.useContext(t.ref):void 0,[u,d]=r.useState(n({url:o,mode:a,context:i}));return r.useEffect((()=>{let e=n({url:o,mode:a,context:i});d(e)}),[o,i]),u}}));
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