@namiruai/react 1.11.0 → 1.13.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 CHANGED
@@ -1,14 +1,17 @@
1
- import type { LeadCaptureData } from "@namiruai/chat";
2
1
  export interface NamiruChatProps {
3
2
  agentId: string;
4
3
  mode?: "button" | "inline";
5
4
  position?: "bottom-right" | "bottom-left";
6
5
  width?: string;
7
6
  height?: string;
8
- onLeadCapture?: (lead: LeadCaptureData) => void;
9
- onFeedback?: (rating: "up" | "down") => void;
10
- onSessionStart?: (sessionId: string) => void;
11
- onSessionEnd?: (sessionId: string) => void;
7
+ }
8
+ declare global {
9
+ interface Window {
10
+ NamiruChat?: {
11
+ init: (config: Record<string, unknown>) => {
12
+ destroy: () => void;
13
+ };
14
+ };
15
+ }
12
16
  }
13
17
  export declare function NamiruChat(props: NamiruChatProps): import("react/jsx-runtime").JSX.Element;
14
- export type { NamiruChatConfig, NamiruChatInstance, LeadCaptureData } from "@namiruai/chat";
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{useRef as i,useEffect as d}from"react";import{jsx as s}from"react/jsx-runtime";function g(n){let t=i(null),e=i(null),a=i(n.agentId);return d(()=>{let o=!1;async function r(){let{init:u}=await import("@namiruai/chat");if(o||!t.current)return;let c={agentId:n.agentId,mode:n.mode,position:n.position,width:n.width,height:n.height,container:n.mode==="inline"?t.current:void 0,onLeadCapture:n.onLeadCapture,onFeedback:n.onFeedback,onSessionStart:n.onSessionStart,onSessionEnd:n.onSessionEnd};e.current=u(c)}return r(),()=>{o=!0,e.current?.destroy(),e.current=null}},[n.agentId]),d(()=>{if(a.current!==n.agentId){a.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]),s("div",{ref:t,style:n.mode==="inline"?{width:n.width,height:n.height}:void 0})}export{g as NamiruChat};
1
+ import{useRef as r,useEffect as a}from"react";import{jsx as c}from"react/jsx-runtime";var o="https://namiru.ai/widget.js";function u(){return new Promise((t,n)=>{if(window.NamiruChat){t();return}let i=document.querySelector(`script[src="${o}"]`);if(i){i.addEventListener("load",()=>t()),i.addEventListener("error",()=>n(new Error("Failed to load Namiru widget script")));return}let e=document.createElement("script");e.src=o,e.async=!0,e.onload=()=>t(),e.onerror=()=>n(new Error("Failed to load Namiru widget script")),document.head.appendChild(e)})}function s(t){let n=r(null),i=r(null);return a(()=>{let e=!1;async function d(){await u(),!(e||!n.current||!window.NamiruChat)&&(i.current=window.NamiruChat.init({agentId:t.agentId,mode:t.mode,position:t.position,width:t.width,height:t.height,container:t.mode==="inline"?n.current:void 0}))}return d(),()=>{e=!0,i.current?.destroy(),i.current=null}},[t.agentId]),c("div",{ref:n,style:t.mode==="inline"?{width:t.width,height:t.height}:void 0})}export{s as NamiruChat};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -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} from \"@namiruai/chat\";\n\nexport interface NamiruChatProps {\n agentId: string;\n mode?: \"button\" | \"inline\";\n position?: \"bottom-right\" | \"bottom-left\";\n width?: string;\n height?: 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 mode: props.mode,\n position: props.position,\n width: props.width,\n height: props.height,\n container: props.mode === \"inline\" ? containerRef.current : undefined,\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} style={props.mode === 'inline' ? { width: props.width, height: props.height } : undefined} />;\n}\n\nexport type { NamiruChatConfig, NamiruChatInstance, LeadCaptureData } from \"@namiruai/chat\";\n"],
5
- "mappings": "AAAA,OAAS,UAAAA,EAAQ,aAAAC,MAAiB,QA6EzB,cAAAC,MAAA,oBA1DF,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,KAAMA,EAAM,KACZ,SAAUA,EAAM,SAChB,MAAOA,EAAM,MACb,OAAQA,EAAM,OACd,UAAWA,EAAM,OAAS,SAAWC,EAAa,QAAU,OAC5D,cAAeD,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,MAAOD,EAAM,OAAS,SAAW,CAAE,MAAOA,EAAM,MAAO,OAAQA,EAAM,MAAO,EAAI,OAAW,CAC5H",
6
- "names": ["useRef", "useEffect", "jsx", "NamiruChat", "props", "containerRef", "instanceRef", "prevAgentIdRef", "destroyed", "initialize", "init", "config"]
4
+ "sourcesContent": ["import { useRef, useEffect } from \"react\";\n\nexport interface NamiruChatProps {\n agentId: string;\n mode?: \"button\" | \"inline\";\n position?: \"bottom-right\" | \"bottom-left\";\n width?: string;\n height?: string;\n}\n\ndeclare global {\n interface Window {\n NamiruChat?: {\n init: (config: Record<string, unknown>) => { destroy: () => void };\n };\n }\n}\n\nconst WIDGET_SCRIPT_URL = \"https://namiru.ai/widget.js\";\n\nfunction loadWidgetScript(): Promise<void> {\n return new Promise((resolve, reject) => {\n if (window.NamiruChat) { resolve(); return; }\n const existing = document.querySelector(`script[src=\"${WIDGET_SCRIPT_URL}\"]`);\n if (existing) {\n existing.addEventListener(\"load\", () => resolve());\n existing.addEventListener(\"error\", () => reject(new Error(\"Failed to load Namiru widget script\")));\n return;\n }\n const script = document.createElement(\"script\");\n script.src = WIDGET_SCRIPT_URL;\n script.async = true;\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(\"Failed to load Namiru widget script\"));\n document.head.appendChild(script);\n });\n}\n\nexport function NamiruChat(props: NamiruChatProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const instanceRef = useRef<{ destroy: () => void } | null>(null);\n\n useEffect(() => {\n let destroyed = false;\n\n async function initialize() {\n await loadWidgetScript();\n if (destroyed || !containerRef.current || !window.NamiruChat) return;\n\n instanceRef.current = window.NamiruChat.init({\n agentId: props.agentId,\n mode: props.mode,\n position: props.position,\n width: props.width,\n height: props.height,\n container: props.mode === \"inline\" ? containerRef.current : undefined,\n });\n }\n\n initialize();\n\n return () => {\n destroyed = true;\n instanceRef.current?.destroy();\n instanceRef.current = null;\n };\n }, [props.agentId]);\n\n return <div ref={containerRef} style={props.mode === 'inline' ? { width: props.width, height: props.height } : undefined} />;\n}\n"],
5
+ "mappings": "AAAA,OAAS,UAAAA,EAAQ,aAAAC,MAAiB,QAoEzB,cAAAC,MAAA,oBAlDT,IAAMC,EAAoB,8BAE1B,SAASC,GAAkC,CACzC,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW,CACtC,GAAI,OAAO,WAAY,CAAED,EAAQ,EAAG,MAAQ,CAC5C,IAAME,EAAW,SAAS,cAAc,eAAeJ,CAAiB,IAAI,EAC5E,GAAII,EAAU,CACZA,EAAS,iBAAiB,OAAQ,IAAMF,EAAQ,CAAC,EACjDE,EAAS,iBAAiB,QAAS,IAAMD,EAAO,IAAI,MAAM,qCAAqC,CAAC,CAAC,EACjG,MACF,CACA,IAAME,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAML,EACbK,EAAO,MAAQ,GACfA,EAAO,OAAS,IAAMH,EAAQ,EAC9BG,EAAO,QAAU,IAAMF,EAAO,IAAI,MAAM,qCAAqC,CAAC,EAC9E,SAAS,KAAK,YAAYE,CAAM,CAClC,CAAC,CACH,CAEO,SAASC,EAAWC,EAAwB,CACjD,IAAMC,EAAeX,EAAuB,IAAI,EAC1CY,EAAcZ,EAAuC,IAAI,EAE/D,OAAAC,EAAU,IAAM,CACd,IAAIY,EAAY,GAEhB,eAAeC,GAAa,CAC1B,MAAMV,EAAiB,EACnB,EAAAS,GAAa,CAACF,EAAa,SAAW,CAAC,OAAO,cAElDC,EAAY,QAAU,OAAO,WAAW,KAAK,CAC3C,QAASF,EAAM,QACf,KAAMA,EAAM,KACZ,SAAUA,EAAM,SAChB,MAAOA,EAAM,MACb,OAAQA,EAAM,OACd,UAAWA,EAAM,OAAS,SAAWC,EAAa,QAAU,MAC9D,CAAC,EACH,CAEA,OAAAG,EAAW,EAEJ,IAAM,CACXD,EAAY,GACZD,EAAY,SAAS,QAAQ,EAC7BA,EAAY,QAAU,IACxB,CACF,EAAG,CAACF,EAAM,OAAO,CAAC,EAEXR,EAAC,OAAI,IAAKS,EAAc,MAAOD,EAAM,OAAS,SAAW,CAAE,MAAOA,EAAM,MAAO,OAAQA,EAAM,MAAO,EAAI,OAAW,CAC5H",
6
+ "names": ["useRef", "useEffect", "jsx", "WIDGET_SCRIPT_URL", "loadWidgetScript", "resolve", "reject", "existing", "script", "NamiruChat", "props", "containerRef", "instanceRef", "destroyed", "initialize"]
7
7
  }
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var g=Object.create;var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var S=(n,e)=>{for(var t in e)d(n,t,{get:e[t],enumerable:!0})},r=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of m(e))!l.call(n,i)&&i!==t&&d(n,i,{get:()=>e[i],enumerable:!(o=f(e,i))||o.enumerable});return n};var I=(n,e,t)=>(t=n!=null?g(C(n)):{},r(e||!n||!n.__esModule?d(t,"default",{value:n,enumerable:!0}):t,n)),L=n=>r(d({},"__esModule",{value:!0}),n);var N={};S(N,{NamiruChat:()=>b});module.exports=L(N);var a=require("react"),u=require("react/jsx-runtime");function b(n){let e=(0,a.useRef)(null),t=(0,a.useRef)(null),o=(0,a.useRef)(n.agentId);return(0,a.useEffect)(()=>{let i=!1;async function c(){let{init:s}=await import("@namiruai/chat");if(i||!e.current)return;let h={agentId:n.agentId,mode:n.mode,position:n.position,width:n.width,height:n.height,container:n.mode==="inline"?e.current:void 0,onLeadCapture:n.onLeadCapture,onFeedback:n.onFeedback,onSessionStart:n.onSessionStart,onSessionEnd:n.onSessionEnd};t.current=s(h)}return c(),()=>{i=!0,t.current?.destroy(),t.current=null}},[n.agentId]),(0,a.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,style:n.mode==="inline"?{width:n.width,height:n.height}:void 0})}
1
+ "use strict";var d=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var i in e)d(t,i,{get:e[i],enumerable:!0})},m=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of l(e))!s.call(t,r)&&r!==i&&d(t,r,{get:()=>e[r],enumerable:!(n=c(e,r))||n.enumerable});return t};var g=t=>m(d({},"__esModule",{value:!0}),t);var C={};h(C,{NamiruChat:()=>w});module.exports=g(C);var o=require("react"),u=require("react/jsx-runtime"),a="https://namiru.ai/widget.js";function f(){return new Promise((t,e)=>{if(window.NamiruChat){t();return}let i=document.querySelector(`script[src="${a}"]`);if(i){i.addEventListener("load",()=>t()),i.addEventListener("error",()=>e(new Error("Failed to load Namiru widget script")));return}let n=document.createElement("script");n.src=a,n.async=!0,n.onload=()=>t(),n.onerror=()=>e(new Error("Failed to load Namiru widget script")),document.head.appendChild(n)})}function w(t){let e=(0,o.useRef)(null),i=(0,o.useRef)(null);return(0,o.useEffect)(()=>{let n=!1;async function r(){await f(),!(n||!e.current||!window.NamiruChat)&&(i.current=window.NamiruChat.init({agentId:t.agentId,mode:t.mode,position:t.position,width:t.width,height:t.height,container:t.mode==="inline"?e.current:void 0}))}return r(),()=>{n=!0,i.current?.destroy(),i.current=null}},[t.agentId]),(0,u.jsx)("div",{ref:e,style:t.mode==="inline"?{width:t.width,height:t.height}:void 0})}
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} from \"@namiruai/chat\";\n\nexport interface NamiruChatProps {\n agentId: string;\n mode?: \"button\" | \"inline\";\n position?: \"bottom-right\" | \"bottom-left\";\n width?: string;\n height?: 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 mode: props.mode,\n position: props.position,\n width: props.width,\n height: props.height,\n container: props.mode === \"inline\" ? containerRef.current : undefined,\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} style={props.mode === 'inline' ? { width: props.width, height: props.height } : undefined} />;\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,iBA6EzBC,EAAA,6BA1DF,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,KAAMA,EAAM,KACZ,SAAUA,EAAM,SAChB,MAAOA,EAAM,MACb,OAAQA,EAAM,OACd,UAAWA,EAAM,OAAS,SAAWC,EAAa,QAAU,OAC5D,cAAeD,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,MAAOD,EAAM,OAAS,SAAW,CAAE,MAAOA,EAAM,MAAO,OAAQA,EAAM,MAAO,EAAI,OAAW,CAC5H",
6
- "names": ["src_exports", "__export", "NamiruChat", "__toCommonJS", "import_react", "import_jsx_runtime", "props", "containerRef", "instanceRef", "prevAgentIdRef", "destroyed", "initialize", "init", "config"]
4
+ "sourcesContent": ["import { useRef, useEffect } from \"react\";\n\nexport interface NamiruChatProps {\n agentId: string;\n mode?: \"button\" | \"inline\";\n position?: \"bottom-right\" | \"bottom-left\";\n width?: string;\n height?: string;\n}\n\ndeclare global {\n interface Window {\n NamiruChat?: {\n init: (config: Record<string, unknown>) => { destroy: () => void };\n };\n }\n}\n\nconst WIDGET_SCRIPT_URL = \"https://namiru.ai/widget.js\";\n\nfunction loadWidgetScript(): Promise<void> {\n return new Promise((resolve, reject) => {\n if (window.NamiruChat) { resolve(); return; }\n const existing = document.querySelector(`script[src=\"${WIDGET_SCRIPT_URL}\"]`);\n if (existing) {\n existing.addEventListener(\"load\", () => resolve());\n existing.addEventListener(\"error\", () => reject(new Error(\"Failed to load Namiru widget script\")));\n return;\n }\n const script = document.createElement(\"script\");\n script.src = WIDGET_SCRIPT_URL;\n script.async = true;\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(\"Failed to load Namiru widget script\"));\n document.head.appendChild(script);\n });\n}\n\nexport function NamiruChat(props: NamiruChatProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const instanceRef = useRef<{ destroy: () => void } | null>(null);\n\n useEffect(() => {\n let destroyed = false;\n\n async function initialize() {\n await loadWidgetScript();\n if (destroyed || !containerRef.current || !window.NamiruChat) return;\n\n instanceRef.current = window.NamiruChat.init({\n agentId: props.agentId,\n mode: props.mode,\n position: props.position,\n width: props.width,\n height: props.height,\n container: props.mode === \"inline\" ? containerRef.current : undefined,\n });\n }\n\n initialize();\n\n return () => {\n destroyed = true;\n instanceRef.current?.destroy();\n instanceRef.current = null;\n };\n }, [props.agentId]);\n\n return <div ref={containerRef} style={props.mode === 'inline' ? { width: props.width, height: props.height } : undefined} />;\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkC,iBAoEzBC,EAAA,6BAlDHC,EAAoB,8BAE1B,SAASC,GAAkC,CACzC,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW,CACtC,GAAI,OAAO,WAAY,CAAED,EAAQ,EAAG,MAAQ,CAC5C,IAAME,EAAW,SAAS,cAAc,eAAeJ,CAAiB,IAAI,EAC5E,GAAII,EAAU,CACZA,EAAS,iBAAiB,OAAQ,IAAMF,EAAQ,CAAC,EACjDE,EAAS,iBAAiB,QAAS,IAAMD,EAAO,IAAI,MAAM,qCAAqC,CAAC,CAAC,EACjG,MACF,CACA,IAAME,EAAS,SAAS,cAAc,QAAQ,EAC9CA,EAAO,IAAML,EACbK,EAAO,MAAQ,GACfA,EAAO,OAAS,IAAMH,EAAQ,EAC9BG,EAAO,QAAU,IAAMF,EAAO,IAAI,MAAM,qCAAqC,CAAC,EAC9E,SAAS,KAAK,YAAYE,CAAM,CAClC,CAAC,CACH,CAEO,SAAST,EAAWU,EAAwB,CACjD,IAAMC,KAAe,UAAuB,IAAI,EAC1CC,KAAc,UAAuC,IAAI,EAE/D,sBAAU,IAAM,CACd,IAAIC,EAAY,GAEhB,eAAeC,GAAa,CAC1B,MAAMT,EAAiB,EACnB,EAAAQ,GAAa,CAACF,EAAa,SAAW,CAAC,OAAO,cAElDC,EAAY,QAAU,OAAO,WAAW,KAAK,CAC3C,QAASF,EAAM,QACf,KAAMA,EAAM,KACZ,SAAUA,EAAM,SAChB,MAAOA,EAAM,MACb,OAAQA,EAAM,OACd,UAAWA,EAAM,OAAS,SAAWC,EAAa,QAAU,MAC9D,CAAC,EACH,CAEA,OAAAG,EAAW,EAEJ,IAAM,CACXD,EAAY,GACZD,EAAY,SAAS,QAAQ,EAC7BA,EAAY,QAAU,IACxB,CACF,EAAG,CAACF,EAAM,OAAO,CAAC,KAEX,OAAC,OAAI,IAAKC,EAAc,MAAOD,EAAM,OAAS,SAAW,CAAE,MAAOA,EAAM,MAAO,OAAQA,EAAM,MAAO,EAAI,OAAW,CAC5H",
6
+ "names": ["src_exports", "__export", "NamiruChat", "__toCommonJS", "import_react", "import_jsx_runtime", "WIDGET_SCRIPT_URL", "loadWidgetScript", "resolve", "reject", "existing", "script", "props", "containerRef", "instanceRef", "destroyed", "initialize"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namiruai/react",
3
- "version": "1.11.0",
3
+ "version": "1.13.0",
4
4
  "description": "React wrapper for Namiru AI chat widget",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -36,8 +36,7 @@
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": ">=17.0.0",
39
- "react-dom": ">=17.0.0",
40
- "@namiruai/chat": "^1.0.0"
39
+ "react-dom": ">=17.0.0"
41
40
  },
42
41
  "devDependencies": {
43
42
  "@types/react": "^18.2.0",