@namiruai/vue 1.11.0 → 1.12.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,4 +1,35 @@
1
1
  import { type PropType } from "vue";
2
+ export interface LeadCaptureData {
3
+ email?: string;
4
+ name?: string;
5
+ phone?: string;
6
+ company?: string;
7
+ }
8
+ export interface NamiruChatConfig {
9
+ agentId: string;
10
+ mode?: "button" | "inline";
11
+ position?: "bottom-right" | "bottom-left";
12
+ width?: string;
13
+ height?: string;
14
+ container?: HTMLElement;
15
+ serverUrl?: string;
16
+ wsUrl?: string;
17
+ onLeadCapture?: (lead: LeadCaptureData) => void;
18
+ onFeedback?: (rating: "up" | "down") => void;
19
+ onSessionStart?: (sessionId: string) => void;
20
+ onSessionEnd?: (sessionId: string) => void;
21
+ }
22
+ export interface NamiruChatInstance {
23
+ destroy: () => void;
24
+ updateConfig: (config: Partial<NamiruChatConfig>) => void;
25
+ }
26
+ declare global {
27
+ interface Window {
28
+ NamiruChat?: {
29
+ init: (config: NamiruChatConfig) => NamiruChatInstance;
30
+ };
31
+ }
32
+ }
2
33
  export declare const NamiruChat: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
34
  agentId: {
4
35
  type: StringConstructor;
@@ -54,4 +85,3 @@ export declare const NamiruChat: import("vue").DefineComponent<import("vue").Ext
54
85
  width: string;
55
86
  height: string;
56
87
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
57
- export type { NamiruChatConfig, NamiruChatInstance, LeadCaptureData } from "@namiruai/chat";
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- import{defineComponent as h,ref as d,onMounted as l,onBeforeUnmount as s,watch as f,h as m}from"vue";var c=h({name:"NamiruChat",props:{agentId:{type:String,required:!0},mode:{type:String,default:void 0},position:{type:String,default:void 0},width:{type:String,default:void 0},height:{type:String,default:void 0}},emits:["leadCapture","feedback","sessionStart","sessionEnd"],setup(t,{emit:i}){let u=d(null),n=d(null);async function o(){let{init:a}=await import("@namiruai/chat"),r={agentId:t.agentId,...t.mode&&{mode:t.mode},...t.position&&{position:t.position},...t.width&&{width:t.width},...t.height&&{height:t.height},onLeadCapture:e=>i("leadCapture",e),onFeedback:e=>i("feedback",e),onSessionStart:e=>i("sessionStart",e),onSessionEnd:e=>i("sessionEnd",e)};n.value=a(r)}return l(()=>{o()}),s(()=>{n.value?.destroy(),n.value=null}),f(()=>t.agentId,()=>{n.value?.destroy(),n.value=null,o()}),()=>{let a=t.mode==="inline"?{width:t.width,height:t.height}:void 0;return m("div",{ref:u,style:a})}}});export{c as NamiruChat};
1
+ import{defineComponent as u,ref as d,onMounted as l,onBeforeUnmount as g,watch as c,h}from"vue";var s="https://namiru.ai/widget.js";function m(){return new Promise((t,n)=>{if(window.NamiruChat){t();return}let a=document.querySelector(`script[src="${s}"]`);if(a){a.addEventListener("load",()=>t()),a.addEventListener("error",()=>n(new Error("Failed to load Namiru widget script")));return}let e=document.createElement("script");e.src=s,e.async=!0,e.onload=()=>t(),e.onerror=()=>n(new Error("Failed to load Namiru widget script")),document.head.appendChild(e)})}var C=u({name:"NamiruChat",props:{agentId:{type:String,required:!0},mode:{type:String,default:void 0},position:{type:String,default:void 0},width:{type:String,default:void 0},height:{type:String,default:void 0}},emits:["leadCapture","feedback","sessionStart","sessionEnd"],setup(t,{emit:n}){let a=d(null),e=d(null);async function r(){if(await m(),!window.NamiruChat)return;let o={agentId:t.agentId,...t.mode&&{mode:t.mode},...t.position&&{position:t.position},...t.width&&{width:t.width},...t.height&&{height:t.height},onLeadCapture:i=>n("leadCapture",i),onFeedback:i=>n("feedback",i),onSessionStart:i=>n("sessionStart",i),onSessionEnd:i=>n("sessionEnd",i)};e.value=window.NamiruChat.init(o)}return l(()=>{r()}),g(()=>{e.value?.destroy(),e.value=null}),c(()=>t.agentId,()=>{e.value?.destroy(),e.value=null,r()}),()=>{let o=t.mode==="inline"?{width:t.width,height:t.height}:void 0;return h("div",{ref:a,style:o})}}});export{C as NamiruChat};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import {\n defineComponent,\n ref,\n onMounted,\n onBeforeUnmount,\n watch,\n h,\n type PropType,\n} from \"vue\";\nimport type {\n NamiruChatConfig,\n NamiruChatInstance,\n LeadCaptureData,\n} from \"@namiruai/chat\";\n\nexport const NamiruChat = defineComponent({\n name: \"NamiruChat\",\n props: {\n agentId: { type: String, required: true },\n mode: { type: String as PropType<\"button\" | \"inline\">, default: undefined },\n position: { type: String as PropType<\"bottom-right\" | \"bottom-left\">, default: undefined },\n width: { type: String, default: undefined },\n height: { type: String, default: undefined },\n },\n emits: [\"leadCapture\", \"feedback\", \"sessionStart\", \"sessionEnd\"],\n setup(props, { emit }) {\n const containerRef = ref<HTMLElement | null>(null);\n const instance = ref<NamiruChatInstance | null>(null);\n\n async function initialize() {\n const { init } = await import(\"@namiruai/chat\");\n\n const config: NamiruChatConfig = {\n agentId: props.agentId,\n ...(props.mode && { mode: props.mode }),\n ...(props.position && { position: props.position }),\n ...(props.width && { width: props.width }),\n ...(props.height && { height: props.height }),\n onLeadCapture: (lead: LeadCaptureData) => emit(\"leadCapture\", lead),\n onFeedback: (rating: \"up\" | \"down\") => emit(\"feedback\", rating),\n onSessionStart: (id: string) => emit(\"sessionStart\", id),\n onSessionEnd: (id: string) => emit(\"sessionEnd\", id),\n };\n\n instance.value = init(config);\n }\n\n onMounted(() => {\n initialize();\n });\n\n onBeforeUnmount(() => {\n instance.value?.destroy();\n instance.value = null;\n });\n\n // agentId change triggers full re-init\n watch(\n () => props.agentId,\n () => {\n instance.value?.destroy();\n instance.value = null;\n initialize();\n }\n );\n\n return () => {\n const style = props.mode === \"inline\"\n ? { width: props.width, height: props.height }\n : undefined;\n return h(\"div\", { ref: containerRef, style });\n };\n },\n});\n\nexport type { NamiruChatConfig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GDN,EACE,IAAMG,EAAM,QACZ,IAAM,CACJG,EAAS,OAAO,QAAQ,EACxBA,EAAS,MAAQ,KACjBC,EAAW,CACb,CACF,EAEO,IAAM,CACX,IAAMM,EAAQV,EAAM,OAAS,SACzB,CAAE,MAAOA,EAAM,MAAO,OAAQA,EAAM,MAAO,EAC3C,OACJ,OAAOF,EAAE,MAAO,CAAE,IAAKI,EAAc,MAAAQ,CAAM,CAAC,CAC9C,CACF,CACF,CAAC",
6
- "names": ["defineComponent", "ref", "onMounted", "onBeforeUnmount", "watch", "h", "NamiruChat", "props", "emit", "containerRef", "instance", "initialize", "init", "config", "lead", "rating", "id", "style"]
4
+ "sourcesContent": ["import {\n defineComponent,\n ref,\n onMounted,\n onBeforeUnmount,\n watch,\n h,\n type PropType,\n} from \"vue\";\n\nexport interface LeadCaptureData {\n email?: string;\n name?: string;\n phone?: string;\n company?: string;\n}\n\nexport interface NamiruChatConfig {\n agentId: string;\n mode?: \"button\" | \"inline\";\n position?: \"bottom-right\" | \"bottom-left\";\n width?: string;\n height?: string;\n container?: HTMLElement;\n serverUrl?: string;\n wsUrl?: 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 interface NamiruChatInstance {\n destroy: () => void;\n updateConfig: (config: Partial<NamiruChatConfig>) => void;\n}\n\ndeclare global {\n interface Window {\n NamiruChat?: {\n init: (config: NamiruChatConfig) => NamiruChatInstance;\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 const NamiruChat = defineComponent({\n name: \"NamiruChat\",\n props: {\n agentId: { type: String, required: true },\n mode: { type: String as PropType<\"button\" | \"inline\">, default: undefined },\n position: { type: String as PropType<\"bottom-right\" | \"bottom-left\">, default: undefined },\n width: { type: String, default: undefined },\n height: { type: String, default: undefined },\n },\n emits: [\"leadCapture\", \"feedback\", \"sessionStart\", \"sessionEnd\"],\n setup(props, { emit }) {\n const containerRef = ref<HTMLElement | null>(null);\n const instance = ref<NamiruChatInstance | null>(null);\n\n async function initialize() {\n await loadWidgetScript();\n if (!window.NamiruChat) return;\n\n const config: NamiruChatConfig = {\n agentId: props.agentId,\n ...(props.mode && { mode: props.mode }),\n ...(props.position && { position: props.position }),\n ...(props.width && { width: props.width }),\n ...(props.height && { height: props.height }),\n onLeadCapture: (lead: LeadCaptureData) => emit(\"leadCapture\", lead),\n onFeedback: (rating: \"up\" | \"down\") => emit(\"feedback\", rating),\n onSessionStart: (id: string) => emit(\"sessionStart\", id),\n onSessionEnd: (id: string) => emit(\"sessionEnd\", id),\n };\n\n instance.value = window.NamiruChat.init(config);\n }\n\n onMounted(() => {\n initialize();\n });\n\n onBeforeUnmount(() => {\n instance.value?.destroy();\n instance.value = null;\n });\n\n watch(\n () => props.agentId,\n () => {\n instance.value?.destroy();\n instance.value = null;\n initialize();\n }\n );\n\n return () => {\n const style = props.mode === \"inline\"\n ? { width: props.width, height: props.height }\n : undefined;\n return h(\"div\", { ref: containerRef, style });\n };\n },\n});\n"],
5
+ "mappings": "AAAA,OACE,mBAAAA,EACA,OAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,SAAAC,EACA,MAEK,MAqCP,IAAMC,EAAoB,8BAE1B,SAASC,GAAkC,CACzC,OAAO,IAAI,QAAQ,CAACC,EAASC,IAA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AA0BL,EAAK,cAAeK,CAAI,EAClE,WAAaC,GAA0BN,EAAK,WAAYM,CAAM,EAC9D,eAAiBC,GAAeP,EAAK,eAAgBO,CAAE,EACvD,aAAeA,GAAeP,EAAK,aAAcO,CAAE,CACrD,EAEAL,EAAS,MAAQ,OAAO,WAAW,KAAKE,CAAM,CAChD,CAEA,OAAAf,EAAU,IAAM,CACdc,EAAW,CACb,CAAC,EAEDb,EAAgB,IAAM,CACpBY,EAAS,OAAO,QAAQ,EACxBA,EAAS,MAAQ,IACnB,CAAC,EAEDX,EACE,IAAMQ,EAAM,QACZ,IAAM,CACJG,EAAS,OAAO,QAAQ,EACxBA,EAAS,MAAQ,KACjBC,EAAW,CACb,CACF,EAEO,IAAM,CACX,IAAMK,EAAQT,EAAM,OAAS,SACzB,CAAE,MAAOA,EAAM,MAAO,OAAQA,EAAM,MAAO,EAC3C,OACJ,OAAO,EAAE,MAAO,CAAE,IAAKE,EAAc,MAAAO,CAAM,CAAC,CAC9C,CACF,CACF,CAAC",
6
+ "names": ["defineComponent", "ref", "onMounted", "onBeforeUnmount", "watch", "WIDGET_SCRIPT_URL", "loadWidgetScript", "resolve", "reject", "existing", "script", "NamiruChat", "props", "emit", "containerRef", "instance", "initialize", "config", "lead", "rating", "id", "style"]
7
7
  }
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var s=Object.create;var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var i in e)u(t,i,{get:e[i],enumerable:!0})},h=(t,e,i,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!c.call(t,o)&&o!==i&&u(t,o,{get:()=>e[o],enumerable:!(a=f(e,o))||a.enumerable});return t};var y=(t,e,i)=>(i=t!=null?s(g(t)):{},h(e||!t||!t.__esModule?u(i,"default",{value:t,enumerable:!0}):i,t)),p=t=>h(u({},"__esModule",{value:!0}),t);var w={};C(w,{NamiruChat:()=>S});module.exports=p(w);var n=require("vue"),S=(0,n.defineComponent)({name:"NamiruChat",props:{agentId:{type:String,required:!0},mode:{type:String,default:void 0},position:{type:String,default:void 0},width:{type:String,default:void 0},height:{type:String,default:void 0}},emits:["leadCapture","feedback","sessionStart","sessionEnd"],setup(t,{emit:e}){let i=(0,n.ref)(null),a=(0,n.ref)(null);async function o(){let{init:r}=await import("@namiruai/chat"),l={agentId:t.agentId,...t.mode&&{mode:t.mode},...t.position&&{position:t.position},...t.width&&{width:t.width},...t.height&&{height:t.height},onLeadCapture:d=>e("leadCapture",d),onFeedback:d=>e("feedback",d),onSessionStart:d=>e("sessionStart",d),onSessionEnd:d=>e("sessionEnd",d)};a.value=r(l)}return(0,n.onMounted)(()=>{o()}),(0,n.onBeforeUnmount)(()=>{a.value?.destroy(),a.value=null}),(0,n.watch)(()=>t.agentId,()=>{a.value?.destroy(),a.value=null,o()}),()=>{let r=t.mode==="inline"?{width:t.width,height:t.height}:void 0;return(0,n.h)("div",{ref:i,style:r})}}});
1
+ "use strict";var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var a in e)s(t,a,{get:e[a],enumerable:!0})},m=(t,e,a,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of g(e))!c.call(t,o)&&o!==a&&s(t,o,{get:()=>e[o],enumerable:!(n=l(e,o))||n.enumerable});return t};var f=t=>m(s({},"__esModule",{value:!0}),t);var p={};h(p,{NamiruChat:()=>w});module.exports=f(p);var i=require("vue"),u="https://namiru.ai/widget.js";function C(){return new Promise((t,e)=>{if(window.NamiruChat){t();return}let a=document.querySelector(`script[src="${u}"]`);if(a){a.addEventListener("load",()=>t()),a.addEventListener("error",()=>e(new Error("Failed to load Namiru widget script")));return}let n=document.createElement("script");n.src=u,n.async=!0,n.onload=()=>t(),n.onerror=()=>e(new Error("Failed to load Namiru widget script")),document.head.appendChild(n)})}var w=(0,i.defineComponent)({name:"NamiruChat",props:{agentId:{type:String,required:!0},mode:{type:String,default:void 0},position:{type:String,default:void 0},width:{type:String,default:void 0},height:{type:String,default:void 0}},emits:["leadCapture","feedback","sessionStart","sessionEnd"],setup(t,{emit:e}){let a=(0,i.ref)(null),n=(0,i.ref)(null);async function o(){if(await C(),!window.NamiruChat)return;let d={agentId:t.agentId,...t.mode&&{mode:t.mode},...t.position&&{position:t.position},...t.width&&{width:t.width},...t.height&&{height:t.height},onLeadCapture:r=>e("leadCapture",r),onFeedback:r=>e("feedback",r),onSessionStart:r=>e("sessionStart",r),onSessionEnd:r=>e("sessionEnd",r)};n.value=window.NamiruChat.init(d)}return(0,i.onMounted)(()=>{o()}),(0,i.onBeforeUnmount)(()=>{n.value?.destroy(),n.value=null}),(0,i.watch)(()=>t.agentId,()=>{n.value?.destroy(),n.value=null,o()}),()=>{let d=t.mode==="inline"?{width:t.width,height:t.height}:void 0;return(0,i.h)("div",{ref:a,style:d})}}});
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.ts"],
4
- "sourcesContent": ["import {\n defineComponent,\n ref,\n onMounted,\n onBeforeUnmount,\n watch,\n h,\n type PropType,\n} from \"vue\";\nimport type {\n NamiruChatConfig,\n NamiruChatInstance,\n LeadCaptureData,\n} from \"@namiruai/chat\";\n\nexport const NamiruChat = defineComponent({\n name: \"NamiruChat\",\n props: {\n agentId: { type: String, required: true },\n mode: { type: String as PropType<\"button\" | \"inline\">, default: undefined },\n position: { type: String as PropType<\"bottom-right\" | \"bottom-left\">, default: undefined },\n width: { type: String, default: undefined },\n height: { type: String, default: undefined },\n },\n emits: [\"leadCapture\", \"feedback\", \"sessionStart\", \"sessionEnd\"],\n setup(props, { emit }) {\n const containerRef = ref<HTMLElement | null>(null);\n const instance = ref<NamiruChatInstance | null>(null);\n\n async function initialize() {\n const { init } = await import(\"@namiruai/chat\");\n\n const config: NamiruChatConfig = {\n agentId: props.agentId,\n ...(props.mode && { mode: props.mode }),\n ...(props.position && { position: props.position }),\n ...(props.width && { width: props.width }),\n ...(props.height && { height: props.height }),\n onLeadCapture: (lead: LeadCaptureData) => emit(\"leadCapture\", lead),\n onFeedback: (rating: \"up\" | \"down\") => emit(\"feedback\", rating),\n onSessionStart: (id: string) => emit(\"sessionStart\", id),\n onSessionEnd: (id: string) => emit(\"sessionEnd\", id),\n };\n\n instance.value = init(config);\n }\n\n onMounted(() => {\n initialize();\n });\n\n onBeforeUnmount(() => {\n instance.value?.destroy();\n instance.value = null;\n });\n\n // agentId change triggers full re-init\n watch(\n () => props.agentId,\n () => {\n instance.value?.destroy();\n instance.value = null;\n initialize();\n }\n );\n\n return () => {\n const style = props.mode === \"inline\"\n ? { width: props.width, height: props.height }\n : undefined;\n return h(\"div\", { ref: containerRef, style });\n };\n },\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,EAQO,eAOMF,KAAa,mBAAgB,CACxC,KAAM,aACN,MAAO,CACL,QAAS,CAAE,KAAM,OAAQ,SAAU,EAAK,EACxC,KAAM,CAAE,KAAM,OAAyC,QAAS,MAAU,EAC1E,SAAU,CAAE,KAAM,OAAoD,QAAS,MAAU,EACzF,MAAO,CAAE,KAAM,OAAQ,QAAS,MAAU,EAC1C,OAAQ,CAAE,KAAM,OAAQ,QAAS,MAAU,CAC7C,EACA,MAAO,CAAC,cAAe,WAAY,eAAgB,YAAY,EAC/D,MAAMG,EAAO,CAAE,KAAAC,CAAK,EAAG,CACrB,IAAMC,KAAe,OAAwB,IAAI,EAC3CC,KAAW,OAA+B,IAAI,EAEpD,eAAeC,GAAa,CAC1B,GAAM,CAAE,KAAAC,CAAK,EAAI,KAAM,QAAO,gBAAgB,EAExCC,EAA2B,CAC/B,QAASN,EAAM,QACf,GAAIA,EAAM,MAAQ,CAAE,KAAMA,EAAM,IAAK,EACrC,GAAIA,EAAM,UAAY,CAAE,SAAUA,EAAM,QAAS,EACjD,GAAIA,EAAM,OAAS,CAAE,MAAOA,EAAM,KAAM,EACxC,GAAIA,EAAM,QAAU,CAAE,OAAQA,EAAM,MAAO,EAC3C,cAAgBO,GAA0BN,EAAK,cAAeM,CAAI,EAClE,WAAaC,GAA0BP,EAAK,WAAYO,CAAM,EAC9D,eAAiBC,GAAeR,EAAK,eAAgBQ,CAAE,EACvD,aAAeA,GAAeR,EAAK,aAAcQ,CAAE,CACrD,EAEAN,EAAS,MAAQE,EAAKC,CAAM,CAC9B,CAEA,sBAAU,IAAM,CACdF,EAAW,CACb,CAAC,KAED,mBAAgB,IAAM,CACpBD,EAAS,OAAO,QAAQ,EACxBA,EAAS,MAAQ,IACnB,CAAC,KAGD,SACE,IAAMH,EAAM,QACZ,IAAM,CACJG,EAAS,OAAO,QAAQ,EACxBA,EAAS,MAAQ,KACjBC,EAAW,CACb,CACF,EAEO,IAAM,CACX,IAAMM,EAAQV,EAAM,OAAS,SACzB,CAAE,MAAOA,EAAM,MAAO,OAAQA,EAAM,MAAO,EAC3C,OACJ,SAAO,KAAE,MAAO,CAAE,IAAKE,EAAc,MAAAQ,CAAM,CAAC,CAC9C,CACF,CACF,CAAC",
6
- "names": ["src_exports", "__export", "NamiruChat", "__toCommonJS", "import_vue", "props", "emit", "containerRef", "instance", "initialize", "init", "config", "lead", "rating", "id", "style"]
4
+ "sourcesContent": ["import {\n defineComponent,\n ref,\n onMounted,\n onBeforeUnmount,\n watch,\n h,\n type PropType,\n} from \"vue\";\n\nexport interface LeadCaptureData {\n email?: string;\n name?: string;\n phone?: string;\n company?: string;\n}\n\nexport interface NamiruChatConfig {\n agentId: string;\n mode?: \"button\" | \"inline\";\n position?: \"bottom-right\" | \"bottom-left\";\n width?: string;\n height?: string;\n container?: HTMLElement;\n serverUrl?: string;\n wsUrl?: 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 interface NamiruChatInstance {\n destroy: () => void;\n updateConfig: (config: Partial<NamiruChatConfig>) => void;\n}\n\ndeclare global {\n interface Window {\n NamiruChat?: {\n init: (config: NamiruChatConfig) => NamiruChatInstance;\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 const NamiruChat = defineComponent({\n name: \"NamiruChat\",\n props: {\n agentId: { type: String, required: true },\n mode: { type: String as PropType<\"button\" | \"inline\">, default: undefined },\n position: { type: String as PropType<\"bottom-right\" | \"bottom-left\">, default: undefined },\n width: { type: String, default: undefined },\n height: { type: String, default: undefined },\n },\n emits: [\"leadCapture\", \"feedback\", \"sessionStart\", \"sessionEnd\"],\n setup(props, { emit }) {\n const containerRef = ref<HTMLElement | null>(null);\n const instance = ref<NamiruChatInstance | null>(null);\n\n async function initialize() {\n await loadWidgetScript();\n if (!window.NamiruChat) return;\n\n const config: NamiruChatConfig = {\n agentId: props.agentId,\n ...(props.mode && { mode: props.mode }),\n ...(props.position && { position: props.position }),\n ...(props.width && { width: props.width }),\n ...(props.height && { height: props.height }),\n onLeadCapture: (lead: LeadCaptureData) => emit(\"leadCapture\", lead),\n onFeedback: (rating: \"up\" | \"down\") => emit(\"feedback\", rating),\n onSessionStart: (id: string) => emit(\"sessionStart\", id),\n onSessionEnd: (id: string) => emit(\"sessionEnd\", id),\n };\n\n instance.value = window.NamiruChat.init(config);\n }\n\n onMounted(() => {\n initialize();\n });\n\n onBeforeUnmount(() => {\n instance.value?.destroy();\n instance.value = null;\n });\n\n watch(\n () => props.agentId,\n () => {\n instance.value?.destroy();\n instance.value = null;\n initialize();\n }\n );\n\n return () => {\n const style = props.mode === \"inline\"\n ? { width: props.width, height: props.height }\n : undefined;\n return h(\"div\", { ref: containerRef, style });\n };\n },\n});\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAQO,eAqCDC,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,IAAMR,KAAa,mBAAgB,CACxC,KAAM,aACN,MAAO,CACL,QAAS,CAAE,KAAM,OAAQ,SAAU,EAAK,EACxC,KAAM,CAAE,KAAM,OAAyC,QAAS,MAAU,EAC1E,SAAU,CAAE,KAAM,OAAoD,QAAS,MAA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ommonJS", "import_vue", "WIDGET_SCRIPT_URL", "loadWidgetScript", "resolve", "reject", "existing", "script", "props", "emit", "containerRef", "instance", "initialize", "config", "lead", "rating", "id", "style"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namiruai/vue",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Vue wrapper for Namiru AI chat widget",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -35,8 +35,7 @@
35
35
  "dev": "node build.js --watch"
36
36
  },
37
37
  "peerDependencies": {
38
- "vue": ">=3.0.0",
39
- "@namiruai/chat": "^1.0.0"
38
+ "vue": ">=3.0.0"
40
39
  },
41
40
  "devDependencies": {
42
41
  "esbuild": "^0.20.0",