@namiruai/vue 1.12.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,32 +1,10 @@
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
2
  declare global {
27
3
  interface Window {
28
4
  NamiruChat?: {
29
- init: (config: NamiruChatConfig) => NamiruChatInstance;
5
+ init: (config: Record<string, unknown>) => {
6
+ destroy: () => void;
7
+ };
30
8
  };
31
9
  }
32
10
  }
@@ -53,7 +31,7 @@ export declare const NamiruChat: import("vue").DefineComponent<import("vue").Ext
53
31
  };
54
32
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
55
33
  [key: string]: any;
56
- }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("leadCapture" | "feedback" | "sessionStart" | "sessionEnd")[], "leadCapture" | "feedback" | "sessionStart" | "sessionEnd", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
34
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
57
35
  agentId: {
58
36
  type: StringConstructor;
59
37
  required: true;
@@ -74,12 +52,7 @@ export declare const NamiruChat: import("vue").DefineComponent<import("vue").Ext
74
52
  type: StringConstructor;
75
53
  default: undefined;
76
54
  };
77
- }>> & Readonly<{
78
- onLeadCapture?: ((...args: any[]) => any) | undefined;
79
- onFeedback?: ((...args: any[]) => any) | undefined;
80
- onSessionStart?: ((...args: any[]) => any) | undefined;
81
- onSessionEnd?: ((...args: any[]) => any) | undefined;
82
- }>, {
55
+ }>> & Readonly<{}>, {
83
56
  mode: "button" | "inline";
84
57
  position: "bottom-right" | "bottom-left";
85
58
  width: string;
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
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};
1
+ import{defineComponent as a,ref as d,onMounted as u,onBeforeUnmount as l,watch as c,h}from"vue";var o="https://namiru.ai/widget.js";function m(){return new Promise((t,i)=>{if(window.NamiruChat){t();return}let e=document.querySelector(`script[src="${o}"]`);if(e){e.addEventListener("load",()=>t()),e.addEventListener("error",()=>i(new Error("Failed to load Namiru widget script")));return}let n=document.createElement("script");n.src=o,n.async=!0,n.onload=()=>t(),n.onerror=()=>i(new Error("Failed to load Namiru widget script")),document.head.appendChild(n)})}var s=a({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}},setup(t){let i=d(null),e=d(null);async function n(){await m(),window.NamiruChat&&(e.value=window.NamiruChat.init({agentId:t.agentId,...t.mode&&{mode:t.mode},...t.position&&{position:t.position},...t.width&&{width:t.width},...t.height&&{height:t.height}}))}return u(()=>{n()}),l(()=>{e.value?.destroy(),e.value=null}),c(()=>t.agentId,()=>{e.value?.destroy(),e.value=null,n()}),()=>{let r=t.mode==="inline"?{width:t.width,height:t.height}:void 0;return h("div",{ref:i,style:r})}}});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.ts"],
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,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,IAAMC,EAAaX,EAAgB,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,MAAMY,EAAO,CAAE,KAAAC,CAAK,EAAG,CACrB,IAAMC,EAAeb,EAAwB,IAAI,EAC3Cc,EAAWd,EAA+B,IAAI,EAEpD,eAAee,GAAa,CAE1B,GADA,MAAMV,EAAiB,EACnB,CAAC,OAAO,WAAY,OAExB,IAAMW,EAA2B,CAC/B,QAASL,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,cAAgBM,GAA0BL,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"]
4
+ "sourcesContent": ["import { defineComponent, ref, onMounted, onBeforeUnmount, watch, h, type PropType } from \"vue\";\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 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 setup(props) {\n const containerRef = ref<HTMLElement | null>(null);\n const instance = ref<{ destroy: () => void } | null>(null);\n\n async function initialize() {\n await loadWidgetScript();\n if (!window.NamiruChat) return;\n\n instance.value = window.NamiruChat.init({\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 });\n }\n\n onMounted(() => { initialize(); });\n\n onBeforeUnmount(() => {\n instance.value?.destroy();\n instance.value = null;\n });\n\n watch(() => props.agentId, () => {\n instance.value?.destroy();\n instance.value = null;\n initialize();\n });\n\n return () => {\n const style = props.mode === \"inline\" ? { width: props.width, height: props.height } : undefined;\n return h(\"div\", { ref: containerRef, style });\n };\n },\n});\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,EAAiB,OAAAC,EAAK,aAAAC,EAAW,mBAA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AAU,CAAE,OAAQA,EAAM,MAAO,CAC7C,CAAC,EACH,CAEA,OAAAV,EAAU,IAAM,CAAEa,EAAW,CAAG,CAAC,EAEjCZ,EAAgB,IAAM,CACpBW,EAAS,OAAO,QAAQ,EACxBA,EAAS,MAAQ,IACnB,CAAC,EAEDV,EAAM,IAAMQ,EAAM,QAAS,IAAM,CAC/BE,EAAS,OAAO,QAAQ,EACxBA,EAAS,MAAQ,KACjBC,EAAW,CACb,CAAC,EAEM,IAAM,CACX,IAAMC,EAAQJ,EAAM,OAAS,SAAW,CAAE,MAAOA,EAAM,MAAO,OAAQA,EAAM,MAAO,EAAI,OACvF,OAAO,EAAE,MAAO,CAAE,IAAKC,EAAc,MAAAG,CAAM,CAAC,CAC9C,CACF,CACF,CAAC",
6
+ "names": ["defineComponent", "ref", "onMounted", "onBeforeUnmount", "watch", "WIDGET_SCRIPT_URL", "loadWidgetScript", "resolve", "reject", "existing", "script", "NamiruChat", "props", "containerRef", "instance", "initialize", "style"]
7
7
  }
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
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})}}});
1
+ "use strict";var r=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(t,e)=>{for(var n in e)r(t,n,{get:e[n],enumerable:!0})},m=(t,e,n,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of l(e))!c.call(t,o)&&o!==n&&r(t,o,{get:()=>e[o],enumerable:!(d=u(e,o))||d.enumerable});return t};var g=t=>m(r({},"__esModule",{value:!0}),t);var w={};h(w,{NamiruChat:()=>f});module.exports=g(w);var i=require("vue"),a="https://namiru.ai/widget.js";function s(){return new Promise((t,e)=>{if(window.NamiruChat){t();return}let n=document.querySelector(`script[src="${a}"]`);if(n){n.addEventListener("load",()=>t()),n.addEventListener("error",()=>e(new Error("Failed to load Namiru widget script")));return}let d=document.createElement("script");d.src=a,d.async=!0,d.onload=()=>t(),d.onerror=()=>e(new Error("Failed to load Namiru widget script")),document.head.appendChild(d)})}var f=(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}},setup(t){let e=(0,i.ref)(null),n=(0,i.ref)(null);async function d(){await s(),window.NamiruChat&&(n.value=window.NamiruChat.init({agentId:t.agentId,...t.mode&&{mode:t.mode},...t.position&&{position:t.position},...t.width&&{width:t.width},...t.height&&{height:t.height}}))}return(0,i.onMounted)(()=>{d()}),(0,i.onBeforeUnmount)(()=>{n.value?.destroy(),n.value=null}),(0,i.watch)(()=>t.agentId,()=>{n.value?.destroy(),n.value=null,d()}),()=>{let o=t.mode==="inline"?{width:t.width,height:t.height}:void 0;return(0,i.h)("div",{ref:e,style:o})}}});
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\";\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": "yaA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AAIA,EAAM,UAAY,CAAE,SAAUA,EAAM,QAAS,EACjD,GAAIA,EAAM,OAAS,CAAE,MAAOA,EAAM,KAAM,EACxC,GAAIA,EAAM,QAAU,CAAE,OAAQA,EAAM,MAAO,EAC3C,cAAgBM,GAA0BL,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,sBAAU,IAAM,CACdD,EAAW,CACb,CAAC,KAED,mBAAgB,IAAM,CACpBD,EAAS,OAAO,QAAQ,EACxBA,EAAS,MAAQ,IACnB,CAAC,KAED,SACE,IAAMH,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,SAAO,KAAE,MAAO,CAAE,IAAKE,EAAc,MAAAO,CAAM,CAAC,CAC9C,CACF,CACF,CAAC",
6
- "names": ["src_exports", "__export", "NamiruChat", "__toCommonJS", "import_vue", "WIDGET_SCRIPT_URL", "loadWidgetScript", "resolve", "reject", "existing", "script", "props", "emit", "containerRef", "instance", "initialize", "config", "lead", "rating", "id", "style"]
4
+ "sourcesContent": ["import { defineComponent, ref, onMounted, onBeforeUnmount, watch, h, type PropType } from \"vue\";\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 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 setup(props) {\n const containerRef = ref<HTMLElement | null>(null);\n const instance = ref<{ destroy: () => void } | null>(null);\n\n async function initialize() {\n await loadWidgetScript();\n if (!window.NamiruChat) return;\n\n instance.value = window.NamiruChat.init({\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 });\n }\n\n onMounted(() => { initialize(); });\n\n onBeforeUnmount(() => {\n instance.value?.destroy();\n instance.value = null;\n });\n\n watch(() => props.agentId, () => {\n instance.value?.destroy();\n instance.value = null;\n initialize();\n });\n\n return () => {\n const style = props.mode === \"inline\" ? { width: props.width, height: props.height } : 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,EAA0F,eAUpFC,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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EAAW,CACb,CAAC,EAEM,IAAM,CACX,IAAMC,EAAQJ,EAAM,OAAS,SAAW,CAAE,MAAOA,EAAM,MAAO,OAAQA,EAAM,MAAO,EAAI,OACvF,SAAO,KAAE,MAAO,CAAE,IAAKC,EAAc,MAAAG,CAAM,CAAC,CAC9C,CACF,CACF,CAAC",
6
+ "names": ["src_exports", "__export", "NamiruChat", "__toCommonJS", "import_vue", "WIDGET_SCRIPT_URL", "loadWidgetScript", "resolve", "reject", "existing", "script", "props", "containerRef", "instance", "initialize", "style"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namiruai/vue",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "Vue wrapper for Namiru AI chat widget",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",