@namiruai/vue 1.0.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/LICENSE +21 -0
- package/README.md +75 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Namiru.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @namiru/vue
|
|
2
|
+
|
|
3
|
+
Vue 3 wrapper for the [Namiru.ai](https://namiru.ai) chat widget -- add AI customer support to your Vue app.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @namiru/vue
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Floating Button (default)
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<script setup>
|
|
17
|
+
import { NamiruChat } from '@namiru/vue';
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<NamiruChat
|
|
22
|
+
agent-id="your-agent-id"
|
|
23
|
+
position="bottom-right"
|
|
24
|
+
/>
|
|
25
|
+
</template>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Inline Mode
|
|
29
|
+
|
|
30
|
+
```vue
|
|
31
|
+
<script setup>
|
|
32
|
+
import { NamiruChat } from '@namiru/vue';
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<div style="width: 400px; height: 600px">
|
|
37
|
+
<NamiruChat
|
|
38
|
+
agent-id="your-agent-id"
|
|
39
|
+
mode="inline"
|
|
40
|
+
width="100%"
|
|
41
|
+
height="100%"
|
|
42
|
+
@lead-capture="onLeadCapture"
|
|
43
|
+
@session-start="onSessionStart"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Props
|
|
50
|
+
|
|
51
|
+
| Prop | Type | Description |
|
|
52
|
+
|------|------|-------------|
|
|
53
|
+
| `agent-id` | `string` | **Required.** Your Namiru agent ID. |
|
|
54
|
+
| `server-url` | `string` | Custom server URL (defaults to Namiru cloud). |
|
|
55
|
+
| `mode` | `'button' \| 'inline'` | Display mode. Default: `'button'`. |
|
|
56
|
+
| `position` | `'bottom-left' \| 'bottom-right'` | Button position. Default: `'bottom-right'`. |
|
|
57
|
+
| `width` | `string` | Width for inline mode. |
|
|
58
|
+
| `height` | `string` | Height for inline mode. |
|
|
59
|
+
|
|
60
|
+
### Events
|
|
61
|
+
|
|
62
|
+
| Event | Payload | Description |
|
|
63
|
+
|-------|---------|-------------|
|
|
64
|
+
| `lead-capture` | `LeadCaptureData` | Emitted when a lead is captured. |
|
|
65
|
+
| `feedback` | `'up' \| 'down'` | Emitted when user gives feedback. |
|
|
66
|
+
| `session-start` | `string` | Emitted with session ID when chat starts. |
|
|
67
|
+
| `session-end` | `string` | Emitted with session ID when chat ends. |
|
|
68
|
+
|
|
69
|
+
## Documentation
|
|
70
|
+
|
|
71
|
+
For full documentation, visit [namiru.ai](https://namiru.ai).
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
2
|
+
import type { PreChatCustomConfig } from "@namiruai/chat";
|
|
3
|
+
export declare const NamiruChat: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
agentId: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
serverUrl: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
};
|
|
11
|
+
mode: {
|
|
12
|
+
type: PropType<"button" | "inline">;
|
|
13
|
+
};
|
|
14
|
+
position: {
|
|
15
|
+
type: PropType<"bottom-left" | "bottom-right">;
|
|
16
|
+
};
|
|
17
|
+
preChatEnabled: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
};
|
|
20
|
+
preChatTemplate: {
|
|
21
|
+
type: PropType<"ecommerce" | "saas" | "services" | "custom" | null>;
|
|
22
|
+
};
|
|
23
|
+
preChatCustom: {
|
|
24
|
+
type: PropType<PreChatCustomConfig>;
|
|
25
|
+
};
|
|
26
|
+
greetingDelay: {
|
|
27
|
+
type: NumberConstructor;
|
|
28
|
+
};
|
|
29
|
+
width: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
};
|
|
32
|
+
height: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
};
|
|
35
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("leadCapture" | "feedback" | "sessionStart" | "sessionEnd")[], "leadCapture" | "feedback" | "sessionStart" | "sessionEnd", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
38
|
+
agentId: {
|
|
39
|
+
type: StringConstructor;
|
|
40
|
+
required: true;
|
|
41
|
+
};
|
|
42
|
+
serverUrl: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
};
|
|
45
|
+
mode: {
|
|
46
|
+
type: PropType<"button" | "inline">;
|
|
47
|
+
};
|
|
48
|
+
position: {
|
|
49
|
+
type: PropType<"bottom-left" | "bottom-right">;
|
|
50
|
+
};
|
|
51
|
+
preChatEnabled: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
};
|
|
54
|
+
preChatTemplate: {
|
|
55
|
+
type: PropType<"ecommerce" | "saas" | "services" | "custom" | null>;
|
|
56
|
+
};
|
|
57
|
+
preChatCustom: {
|
|
58
|
+
type: PropType<PreChatCustomConfig>;
|
|
59
|
+
};
|
|
60
|
+
greetingDelay: {
|
|
61
|
+
type: NumberConstructor;
|
|
62
|
+
};
|
|
63
|
+
width: {
|
|
64
|
+
type: StringConstructor;
|
|
65
|
+
};
|
|
66
|
+
height: {
|
|
67
|
+
type: StringConstructor;
|
|
68
|
+
};
|
|
69
|
+
}>> & Readonly<{
|
|
70
|
+
onLeadCapture?: ((...args: any[]) => any) | undefined;
|
|
71
|
+
onFeedback?: ((...args: any[]) => any) | undefined;
|
|
72
|
+
onSessionStart?: ((...args: any[]) => any) | undefined;
|
|
73
|
+
onSessionEnd?: ((...args: any[]) => any) | undefined;
|
|
74
|
+
}>, {
|
|
75
|
+
preChatEnabled: boolean;
|
|
76
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
77
|
+
export type { NamiruChatConfig, NamiruChatInstance, LeadCaptureData } from "@namiruai/chat";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{defineComponent as d,ref as l,onMounted as C,onBeforeUnmount as m,watch as h,h as g}from"vue";var y=d({name:"NamiruChat",props:{agentId:{type:String,required:!0},serverUrl:{type:String},mode:{type:String},position:{type:String},preChatEnabled:{type:Boolean},preChatTemplate:{type:String},preChatCustom:{type:Object},greetingDelay:{type:Number},width:{type:String},height:{type:String}},emits:["leadCapture","feedback","sessionStart","sessionEnd"],setup(e,{emit:n}){let r=l(null),a=l(null);async function o(){let{init:i}=await import("@namiruai/chat"),u={agentId:e.agentId,serverUrl:e.serverUrl,mode:e.mode,position:e.position,container:e.mode==="inline"?r.value??void 0:void 0,preChatEnabled:e.preChatEnabled,preChatTemplate:e.preChatTemplate,preChatCustom:e.preChatCustom,greetingDelay:e.greetingDelay,width:e.width,height:e.height,onLeadCapture:t=>n("leadCapture",t),onFeedback:t=>n("feedback",t),onSessionStart:t=>n("sessionStart",t),onSessionEnd:t=>n("sessionEnd",t)};a.value=i(u)}return C(()=>{o()}),m(()=>{a.value?.destroy(),a.value=null}),h(()=>e.agentId,()=>{a.value?.destroy(),a.value=null,o()}),h(()=>[e.serverUrl,e.mode,e.position,e.preChatEnabled,e.preChatTemplate,e.preChatCustom,e.greetingDelay,e.width,e.height],()=>{a.value?.updateConfig({serverUrl:e.serverUrl,mode:e.mode,position:e.position,preChatEnabled:e.preChatEnabled,preChatTemplate:e.preChatTemplate,preChatCustom:e.preChatCustom,greetingDelay:e.greetingDelay,width:e.width,height:e.height})}),()=>{let i=e.mode==="inline"?{width:"100%",height:"100%"}:void 0;return g("div",{ref:r,style:i})}}});export{y as NamiruChat};
|
|
2
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 PreChatCustomConfig,\n} from \"@namiruai/chat\";\n\nexport const NamiruChat = defineComponent({\n name: \"NamiruChat\",\n props: {\n agentId: { type: String, required: true },\n serverUrl: { type: String },\n mode: { type: String as PropType<\"button\" | \"inline\"> },\n position: { type: String as PropType<\"bottom-left\" | \"bottom-right\"> },\n preChatEnabled: { type: Boolean },\n preChatTemplate: {\n type: String as PropType<\n \"ecommerce\" | \"saas\" | \"services\" | \"custom\" | null\n >,\n },\n preChatCustom: { type: Object as PropType<PreChatCustomConfig> },\n greetingDelay: { type: Number },\n width: { type: String },\n height: { type: String },\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 serverUrl: props.serverUrl,\n mode: props.mode,\n position: props.position,\n container:\n props.mode === \"inline\" ? containerRef.value ?? undefined : undefined,\n preChatEnabled: props.preChatEnabled,\n preChatTemplate: props.preChatTemplate,\n preChatCustom: props.preChatCustom,\n greetingDelay: props.greetingDelay,\n width: props.width,\n 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 // Other prop changes trigger updateConfig\n watch(\n () => [\n props.serverUrl,\n props.mode,\n props.position,\n props.preChatEnabled,\n props.preChatTemplate,\n props.preChatCustom,\n props.greetingDelay,\n props.width,\n props.height,\n ],\n () => {\n instance.value?.updateConfig({\n serverUrl: props.serverUrl,\n mode: props.mode,\n position: props.position,\n preChatEnabled: props.preChatEnabled,\n preChatTemplate: props.preChatTemplate,\n preChatCustom: props.preChatCustom,\n greetingDelay: props.greetingDelay,\n width: props.width,\n height: props.height,\n });\n }\n );\n\n return () => {\n const style =\n props.mode === \"inline\"\n ? { width: \"100%\", height: \"100%\" }\n : undefined;\n return h(\"div\", { ref: containerRef, style });\n };\n },\n});\n\nexport type { NamiruChatConfig, NamiruChatInstance, LeadCaptureData } from \"@namiruai/chat\";\n"],
|
|
5
|
+
"mappings": "AAAA,OACE,mBAAAA,EACA,OAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,SAAAC,EACA,KAAAC,MAEK,MAQA,IAAMC,EAAaN,EAAgB,CACxC,KAAM,aACN,MAAO,CACL,QAAS,CAAE,KAAM,OAAQ,SAAU,EAAK,EACxC,UAAW,CAAE,KAAM,MAAO,EAC1B,KAAM,CAAE,KAAM,MAAwC,EACtD,SAAU,CAAE,KAAM,MAAmD,EACrE,eAAgB,CAAE,KAAM,OAAQ,EAChC,gBAAiB,CACf,KAAM,MAGR,EACA,cAAe,CAAE,KAAM,MAAwC,EAC/D,cAAe,CAAE,KAAM,MAAO,EAC9B,MAAO,CAAE,KAAM,MAAO,EACtB,OAAQ,CAAE,KAAM,MAAO,CACzB,EACA,MAAO,CAAC,cAAe,WAAY,eAAgB,YAAY,EAC/D,MAAMO,EAAO,CAAE,KAAAC,CAAK,EAAG,CACrB,IAAMC,EAAeR,EAAwB,IAAI,EAC3CS,EAAWT,EAA+B,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,MAAO,EAChC,OACN,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"]
|
|
7
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var C=Object.create;var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var s=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var c=(e,t)=>{for(var n in t)l(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of g(t))!y.call(e,r)&&r!==n&&l(e,r,{get:()=>t[r],enumerable:!(i=m(t,r))||i.enumerable});return e};var f=(e,t,n)=>(n=e!=null?C(s(e)):{},u(t||!e||!e.__esModule?l(n,"default",{value:e,enumerable:!0}):n,e)),v=e=>u(l({},"__esModule",{value:!0}),e);var S={};c(S,{NamiruChat:()=>b});module.exports=v(S);var a=require("vue"),b=(0,a.defineComponent)({name:"NamiruChat",props:{agentId:{type:String,required:!0},serverUrl:{type:String},mode:{type:String},position:{type:String},preChatEnabled:{type:Boolean},preChatTemplate:{type:String},preChatCustom:{type:Object},greetingDelay:{type:Number},width:{type:String},height:{type:String}},emits:["leadCapture","feedback","sessionStart","sessionEnd"],setup(e,{emit:t}){let n=(0,a.ref)(null),i=(0,a.ref)(null);async function r(){let{init:h}=await import("@namiruai/chat"),d={agentId:e.agentId,serverUrl:e.serverUrl,mode:e.mode,position:e.position,container:e.mode==="inline"?n.value??void 0:void 0,preChatEnabled:e.preChatEnabled,preChatTemplate:e.preChatTemplate,preChatCustom:e.preChatCustom,greetingDelay:e.greetingDelay,width:e.width,height:e.height,onLeadCapture:o=>t("leadCapture",o),onFeedback:o=>t("feedback",o),onSessionStart:o=>t("sessionStart",o),onSessionEnd:o=>t("sessionEnd",o)};i.value=h(d)}return(0,a.onMounted)(()=>{r()}),(0,a.onBeforeUnmount)(()=>{i.value?.destroy(),i.value=null}),(0,a.watch)(()=>e.agentId,()=>{i.value?.destroy(),i.value=null,r()}),(0,a.watch)(()=>[e.serverUrl,e.mode,e.position,e.preChatEnabled,e.preChatTemplate,e.preChatCustom,e.greetingDelay,e.width,e.height],()=>{i.value?.updateConfig({serverUrl:e.serverUrl,mode:e.mode,position:e.position,preChatEnabled:e.preChatEnabled,preChatTemplate:e.preChatTemplate,preChatCustom:e.preChatCustom,greetingDelay:e.greetingDelay,width:e.width,height:e.height})}),()=>{let h=e.mode==="inline"?{width:"100%",height:"100%"}:void 0;return(0,a.h)("div",{ref:n,style:h})}}});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 PreChatCustomConfig,\n} from \"@namiruai/chat\";\n\nexport const NamiruChat = defineComponent({\n name: \"NamiruChat\",\n props: {\n agentId: { type: String, required: true },\n serverUrl: { type: String },\n mode: { type: String as PropType<\"button\" | \"inline\"> },\n position: { type: String as PropType<\"bottom-left\" | \"bottom-right\"> },\n preChatEnabled: { type: Boolean },\n preChatTemplate: {\n type: String as PropType<\n \"ecommerce\" | \"saas\" | \"services\" | \"custom\" | null\n >,\n },\n preChatCustom: { type: Object as PropType<PreChatCustomConfig> },\n greetingDelay: { type: Number },\n width: { type: String },\n height: { type: String },\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 serverUrl: props.serverUrl,\n mode: props.mode,\n position: props.position,\n container:\n props.mode === \"inline\" ? containerRef.value ?? undefined : undefined,\n preChatEnabled: props.preChatEnabled,\n preChatTemplate: props.preChatTemplate,\n preChatCustom: props.preChatCustom,\n greetingDelay: props.greetingDelay,\n width: props.width,\n 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 // Other prop changes trigger updateConfig\n watch(\n () => [\n props.serverUrl,\n props.mode,\n props.position,\n props.preChatEnabled,\n props.preChatTemplate,\n props.preChatCustom,\n props.greetingDelay,\n props.width,\n props.height,\n ],\n () => {\n instance.value?.updateConfig({\n serverUrl: props.serverUrl,\n mode: props.mode,\n position: props.position,\n preChatEnabled: props.preChatEnabled,\n preChatTemplate: props.preChatTemplate,\n preChatCustom: props.preChatCustom,\n greetingDelay: props.greetingDelay,\n width: props.width,\n height: props.height,\n });\n }\n );\n\n return () => {\n const style =\n props.mode === \"inline\"\n ? { width: \"100%\", height: \"100%\" }\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,IA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ACZ,IAAM,CACJG,EAAS,OAAO,QAAQ,EACxBA,EAAS,MAAQ,KACjBC,EAAW,CACb,CACF,KAGA,SACE,IAAM,CACJJ,EAAM,UACNA,EAAM,KACNA,EAAM,SACNA,EAAM,eACNA,EAAM,gBACNA,EAAM,cACNA,EAAM,cACNA,EAAM,MACNA,EAAM,MACR,EACA,IAAM,CACJG,EAAS,OAAO,aAAa,CAC3B,UAAWH,EAAM,UACjB,KAAMA,EAAM,KACZ,SAAUA,EAAM,SAChB,eAAgBA,EAAM,eACtB,gBAAiBA,EAAM,gBACvB,cAAeA,EAAM,cACrB,cAAeA,EAAM,cACrB,MAAOA,EAAM,MACb,OAAQA,EAAM,MAChB,CAAC,CACH,CACF,EAEO,IAAM,CACX,IAAMU,EACJV,EAAM,OAAS,SACX,CAAE,MAAO,OAAQ,OAAQ,MAAO,EAChC,OACN,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"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@namiruai/vue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Vue wrapper for Namiru AI chat widget",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.esm.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": ["dist", "LICENSE", "README.md"],
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Namiru <hello@namiru.ai>",
|
|
19
|
+
"homepage": "https://namiru.ai",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/namiru-ai/namiru"
|
|
23
|
+
},
|
|
24
|
+
"keywords": ["vue", "chat", "widget", "ai", "customer-support", "chatbot", "namiru"],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "node build.js",
|
|
27
|
+
"dev": "node build.js --watch"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"vue": ">=3.0.0",
|
|
31
|
+
"@namiruai/chat": "^1.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"esbuild": "^0.20.0",
|
|
35
|
+
"typescript": "^5.3.0",
|
|
36
|
+
"vue": "^3.4.0"
|
|
37
|
+
}
|
|
38
|
+
}
|