@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 +9 -6
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +2 -3
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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
|
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\";\
|
|
5
|
-
"mappings": "AAAA,OAAS,UAAAA,EAAQ,aAAAC,MAAiB,
|
|
6
|
-
"names": ["useRef", "useEffect", "jsx", "
|
|
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
|
|
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\";\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["src_exports", "__export", "NamiruChat", "__toCommonJS", "import_react", "import_jsx_runtime", "
|
|
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.
|
|
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",
|