@namiruai/react 1.0.0 → 1.2.0
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/dist/index.d.ts +1 -10
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/package.json +15 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import type { LeadCaptureData
|
|
1
|
+
import type { LeadCaptureData } from "@namiruai/chat";
|
|
2
2
|
export interface NamiruChatProps {
|
|
3
3
|
agentId: string;
|
|
4
|
-
serverUrl?: string;
|
|
5
|
-
mode?: "button" | "inline";
|
|
6
|
-
position?: "bottom-left" | "bottom-right";
|
|
7
|
-
preChatEnabled?: boolean;
|
|
8
|
-
preChatTemplate?: "ecommerce" | "saas" | "services" | "custom" | null;
|
|
9
|
-
preChatCustom?: PreChatCustomConfig;
|
|
10
|
-
greetingDelay?: number;
|
|
11
|
-
width?: string;
|
|
12
|
-
height?: string;
|
|
13
4
|
onLeadCapture?: (lead: LeadCaptureData) => void;
|
|
14
5
|
onFeedback?: (rating: "up" | "down") => void;
|
|
15
6
|
onSessionStart?: (sessionId: string) => void;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useRef as
|
|
1
|
+
import{useRef as t,useEffect as r}from"react";import{jsx as c}from"react/jsx-runtime";function f(n){let a=t(null),e=t(null),i=t(n.agentId);return r(()=>{let o=!1;async function d(){let{init:u}=await import("@namiruai/chat");if(o||!a.current)return;let s={agentId:n.agentId,onLeadCapture:n.onLeadCapture,onFeedback:n.onFeedback,onSessionStart:n.onSessionStart,onSessionEnd:n.onSessionEnd};e.current=u(s)}return d(),()=>{o=!0,e.current?.destroy(),e.current=null}},[n.agentId]),r(()=>{if(i.current!==n.agentId){i.current=n.agentId;return}e.current?.updateConfig({onLeadCapture:n.onLeadCapture,onFeedback:n.onFeedback,onSessionStart:n.onSessionStart,onSessionEnd:n.onSessionEnd})},[n.onLeadCapture,n.onFeedback,n.onSessionStart,n.onSessionEnd]),c("div",{ref:a})}export{f as NamiruChat};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport type {\n NamiruChatConfig,\n NamiruChatInstance,\n LeadCaptureData,\n
|
|
5
|
-
"mappings": "AAAA,OAAS,UAAAA,EAAQ,aAAAC,MAAiB,
|
|
4
|
+
"sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport type {\n NamiruChatConfig,\n NamiruChatInstance,\n LeadCaptureData,\n} from \"@namiruai/chat\";\n\nexport interface NamiruChatProps {\n agentId: string;\n onLeadCapture?: (lead: LeadCaptureData) => void;\n onFeedback?: (rating: \"up\" | \"down\") => void;\n onSessionStart?: (sessionId: string) => void;\n onSessionEnd?: (sessionId: string) => void;\n}\n\nexport function NamiruChat(props: NamiruChatProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const instanceRef = useRef<NamiruChatInstance | null>(null);\n const prevAgentIdRef = useRef<string>(props.agentId);\n\n useEffect(() => {\n let destroyed = false;\n\n async function initialize() {\n const { init } = await import(\"@namiruai/chat\");\n\n if (destroyed || !containerRef.current) return;\n\n const config: NamiruChatConfig = {\n agentId: props.agentId,\n onLeadCapture: props.onLeadCapture,\n onFeedback: props.onFeedback,\n onSessionStart: props.onSessionStart,\n onSessionEnd: props.onSessionEnd,\n };\n\n instanceRef.current = init(config);\n }\n\n initialize();\n\n return () => {\n destroyed = true;\n instanceRef.current?.destroy();\n instanceRef.current = null;\n };\n }, [props.agentId]);\n\n // Update callbacks on prop changes (except agentId which triggers re-init)\n useEffect(() => {\n if (prevAgentIdRef.current !== props.agentId) {\n prevAgentIdRef.current = props.agentId;\n return;\n }\n\n instanceRef.current?.updateConfig({\n onLeadCapture: props.onLeadCapture,\n onFeedback: props.onFeedback,\n onSessionStart: props.onSessionStart,\n onSessionEnd: props.onSessionEnd,\n });\n }, [\n props.onLeadCapture,\n props.onFeedback,\n props.onSessionStart,\n props.onSessionEnd,\n ]);\n\n return <div ref={containerRef} />;\n}\n\nexport type { NamiruChatConfig, NamiruChatInstance, LeadCaptureData } from \"@namiruai/chat\";\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,UAAAA,EAAQ,aAAAC,MAAiB,QAoEzB,cAAAC,MAAA,oBArDF,SAASC,EAAWC,EAAwB,CACjD,IAAMC,EAAeL,EAAuB,IAAI,EAC1CM,EAAcN,EAAkC,IAAI,EACpDO,EAAiBP,EAAeI,EAAM,OAAO,EAEnD,OAAAH,EAAU,IAAM,CACd,IAAIO,EAAY,GAEhB,eAAeC,GAAa,CAC1B,GAAM,CAAE,KAAAC,CAAK,EAAI,KAAM,QAAO,gBAAgB,EAE9C,GAAIF,GAAa,CAACH,EAAa,QAAS,OAExC,IAAMM,EAA2B,CAC/B,QAASP,EAAM,QACf,cAAeA,EAAM,cACrB,WAAYA,EAAM,WAClB,eAAgBA,EAAM,eACtB,aAAcA,EAAM,YACtB,EAEAE,EAAY,QAAUI,EAAKC,CAAM,CACnC,CAEA,OAAAF,EAAW,EAEJ,IAAM,CACXD,EAAY,GACZF,EAAY,SAAS,QAAQ,EAC7BA,EAAY,QAAU,IACxB,CACF,EAAG,CAACF,EAAM,OAAO,CAAC,EAGlBH,EAAU,IAAM,CACd,GAAIM,EAAe,UAAYH,EAAM,QAAS,CAC5CG,EAAe,QAAUH,EAAM,QAC/B,MACF,CAEAE,EAAY,SAAS,aAAa,CAChC,cAAeF,EAAM,cACrB,WAAYA,EAAM,WAClB,eAAgBA,EAAM,eACtB,aAAcA,EAAM,YACtB,CAAC,CACH,EAAG,CACDA,EAAM,cACNA,EAAM,WACNA,EAAM,eACNA,EAAM,YACR,CAAC,EAEMF,EAAC,OAAI,IAAKG,EAAc,CACjC",
|
|
6
6
|
"names": ["useRef", "useEffect", "jsx", "NamiruChat", "props", "containerRef", "instanceRef", "prevAgentIdRef", "destroyed", "initialize", "init", "config"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.create;var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var I=(n,e)=>{for(var t in e)r(n,t,{get:e[t],enumerable:!0})},d=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of S(e))!l.call(n,a)&&a!==t&&r(n,a,{get:()=>e[a],enumerable:!(o=g(e,a))||o.enumerable});return n};var h=(n,e,t)=>(t=n!=null?f(m(n)):{},d(e||!n||!n.__esModule?r(t,"default",{value:n,enumerable:!0}):t,n)),L=n=>d(r({},"__esModule",{value:!0}),n);var E={};I(E,{NamiruChat:()=>N});module.exports=L(E);var i=require("react"),u=require("react/jsx-runtime");function N(n){let e=(0,i.useRef)(null),t=(0,i.useRef)(null),o=(0,i.useRef)(n.agentId);return(0,i.useEffect)(()=>{let a=!1;async function s(){let{init:c}=await import("@namiruai/chat");if(a||!e.current)return;let C={agentId:n.agentId,onLeadCapture:n.onLeadCapture,onFeedback:n.onFeedback,onSessionStart:n.onSessionStart,onSessionEnd:n.onSessionEnd};t.current=c(C)}return s(),()=>{a=!0,t.current?.destroy(),t.current=null}},[n.agentId]),(0,i.useEffect)(()=>{if(o.current!==n.agentId){o.current=n.agentId;return}t.current?.updateConfig({onLeadCapture:n.onLeadCapture,onFeedback:n.onFeedback,onSessionStart:n.onSessionStart,onSessionEnd:n.onSessionEnd})},[n.onLeadCapture,n.onFeedback,n.onSessionStart,n.onSessionEnd]),(0,u.jsx)("div",{ref:e})}
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport type {\n NamiruChatConfig,\n NamiruChatInstance,\n LeadCaptureData,\n
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkC,
|
|
4
|
+
"sourcesContent": ["import { useRef, useEffect } from \"react\";\nimport type {\n NamiruChatConfig,\n NamiruChatInstance,\n LeadCaptureData,\n} from \"@namiruai/chat\";\n\nexport interface NamiruChatProps {\n agentId: string;\n onLeadCapture?: (lead: LeadCaptureData) => void;\n onFeedback?: (rating: \"up\" | \"down\") => void;\n onSessionStart?: (sessionId: string) => void;\n onSessionEnd?: (sessionId: string) => void;\n}\n\nexport function NamiruChat(props: NamiruChatProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const instanceRef = useRef<NamiruChatInstance | null>(null);\n const prevAgentIdRef = useRef<string>(props.agentId);\n\n useEffect(() => {\n let destroyed = false;\n\n async function initialize() {\n const { init } = await import(\"@namiruai/chat\");\n\n if (destroyed || !containerRef.current) return;\n\n const config: NamiruChatConfig = {\n agentId: props.agentId,\n onLeadCapture: props.onLeadCapture,\n onFeedback: props.onFeedback,\n onSessionStart: props.onSessionStart,\n onSessionEnd: props.onSessionEnd,\n };\n\n instanceRef.current = init(config);\n }\n\n initialize();\n\n return () => {\n destroyed = true;\n instanceRef.current?.destroy();\n instanceRef.current = null;\n };\n }, [props.agentId]);\n\n // Update callbacks on prop changes (except agentId which triggers re-init)\n useEffect(() => {\n if (prevAgentIdRef.current !== props.agentId) {\n prevAgentIdRef.current = props.agentId;\n return;\n }\n\n instanceRef.current?.updateConfig({\n onLeadCapture: props.onLeadCapture,\n onFeedback: props.onFeedback,\n onSessionStart: props.onSessionStart,\n onSessionEnd: props.onSessionEnd,\n });\n }, [\n props.onLeadCapture,\n props.onFeedback,\n props.onSessionStart,\n props.onSessionEnd,\n ]);\n\n return <div ref={containerRef} />;\n}\n\nexport type { NamiruChatConfig, NamiruChatInstance, LeadCaptureData } from \"@namiruai/chat\";\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkC,iBAoEzBC,EAAA,6BArDF,SAASH,EAAWI,EAAwB,CACjD,IAAMC,KAAe,UAAuB,IAAI,EAC1CC,KAAc,UAAkC,IAAI,EACpDC,KAAiB,UAAeH,EAAM,OAAO,EAEnD,sBAAU,IAAM,CACd,IAAII,EAAY,GAEhB,eAAeC,GAAa,CAC1B,GAAM,CAAE,KAAAC,CAAK,EAAI,KAAM,QAAO,gBAAgB,EAE9C,GAAIF,GAAa,CAACH,EAAa,QAAS,OAExC,IAAMM,EAA2B,CAC/B,QAASP,EAAM,QACf,cAAeA,EAAM,cACrB,WAAYA,EAAM,WAClB,eAAgBA,EAAM,eACtB,aAAcA,EAAM,YACtB,EAEAE,EAAY,QAAUI,EAAKC,CAAM,CACnC,CAEA,OAAAF,EAAW,EAEJ,IAAM,CACXD,EAAY,GACZF,EAAY,SAAS,QAAQ,EAC7BA,EAAY,QAAU,IACxB,CACF,EAAG,CAACF,EAAM,OAAO,CAAC,KAGlB,aAAU,IAAM,CACd,GAAIG,EAAe,UAAYH,EAAM,QAAS,CAC5CG,EAAe,QAAUH,EAAM,QAC/B,MACF,CAEAE,EAAY,SAAS,aAAa,CAChC,cAAeF,EAAM,cACrB,WAAYA,EAAM,WAClB,eAAgBA,EAAM,eACtB,aAAcA,EAAM,YACtB,CAAC,CACH,EAAG,CACDA,EAAM,cACNA,EAAM,WACNA,EAAM,eACNA,EAAM,YACR,CAAC,KAEM,OAAC,OAAI,IAAKC,EAAc,CACjC",
|
|
6
6
|
"names": ["src_exports", "__export", "NamiruChat", "__toCommonJS", "import_react", "import_jsx_runtime", "props", "containerRef", "instanceRef", "prevAgentIdRef", "destroyed", "initialize", "init", "config"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@namiruai/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "React wrapper for Namiru AI chat widget",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"files": [
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
16
20
|
"sideEffects": false,
|
|
17
21
|
"license": "MIT",
|
|
18
22
|
"author": "Namiru <hello@namiru.ai>",
|
|
@@ -21,7 +25,15 @@
|
|
|
21
25
|
"type": "git",
|
|
22
26
|
"url": "https://github.com/namiru-ai/namiru"
|
|
23
27
|
},
|
|
24
|
-
"keywords": [
|
|
28
|
+
"keywords": [
|
|
29
|
+
"react",
|
|
30
|
+
"chat",
|
|
31
|
+
"widget",
|
|
32
|
+
"ai",
|
|
33
|
+
"customer-support",
|
|
34
|
+
"chatbot",
|
|
35
|
+
"namiru"
|
|
36
|
+
],
|
|
25
37
|
"scripts": {
|
|
26
38
|
"build": "node build.js",
|
|
27
39
|
"dev": "node build.js --watch"
|