@wexio/messenger-widget-vue 1.0.23

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wexio
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,219 @@
1
+ # Welcome to @wexio/messenger-widget-vue 👋
2
+
3
+ [![Version](https://img.shields.io/npm/v/@wexio/messenger-widget-vue.svg)](https://www.npmjs.com/package/@wexio/messenger-widget-vue)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
5
+ [![Documentation](https://img.shields.io/badge/docs-wexio.io-blue.svg)](https://learn.wexio.io/docs/web-widget)
6
+
7
+ Native Vue 3 component for the [Wexio](https://wexio.io) web messenger. Thin reactive wrapper around the underlying `<wexio-widget>` custom element — same `WidgetShell` runtime as the script-injected iframe and the React component. Same chat, same visitor identity, same backend; the only difference is **where the Vue tree mounts**.
8
+
9
+ 🏠 [Website](https://wexio.io)
10
+ 📚 [Developer Docs](https://learn.wexio.io/docs/web-widget)
11
+
12
+ ## 📂 Description
13
+
14
+ - [Installation](#installation)
15
+ - [Quick start](#quick-start)
16
+ - [Build configuration](#build-configuration)
17
+ - [Identifying users](#identifying-users)
18
+ - [Props](#props)
19
+ - [Events](#events)
20
+ - [Types](#types)
21
+ - [SSR](#ssr)
22
+ - [Browser support](#browser-support)
23
+ - [Author](#author)
24
+ - [License](#-license)
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ yarn add @wexio/messenger-widget-vue
30
+ ```
31
+
32
+ or
33
+
34
+ ```bash
35
+ npm install @wexio/messenger-widget-vue
36
+ ```
37
+
38
+ `vue >= 3.3` is a peer dependency — the widget uses the host's Vue runtime.
39
+
40
+ ## Quick start
41
+
42
+ ```vue
43
+ <script setup lang="ts">
44
+ import { WexioWidget } from "@wexio/messenger-widget-vue";
45
+ </script>
46
+
47
+ <template>
48
+ <main>
49
+ <!-- your app -->
50
+ <WexioWidget public-key="pk_live_..." />
51
+ </main>
52
+ </template>
53
+ ```
54
+
55
+ That's it — the widget mounts a floating launcher, handles its own theme/locale/state, and the operator dashboard sees the visitor immediately.
56
+
57
+ ## Build configuration
58
+
59
+ Vue's template compiler warns about unknown DOM elements by default. Mark `wexio-widget` as a custom element so the warning is suppressed and Vue doesn't try to component-resolve it:
60
+
61
+ ### Vite
62
+
63
+ ```js
64
+ // vite.config.js
65
+ import { defineConfig } from "vite";
66
+ import vue from "@vitejs/plugin-vue";
67
+
68
+ export default defineConfig({
69
+ plugins: [
70
+ vue({
71
+ template: {
72
+ compilerOptions: {
73
+ isCustomElement: (tag) => tag === "wexio-widget",
74
+ },
75
+ },
76
+ }),
77
+ ],
78
+ });
79
+ ```
80
+
81
+ ### Vue CLI
82
+
83
+ ```js
84
+ // vue.config.js
85
+ module.exports = {
86
+ chainWebpack: (config) => {
87
+ config.module
88
+ .rule("vue")
89
+ .use("vue-loader")
90
+ .tap((opts) => ({
91
+ ...opts,
92
+ compilerOptions: {
93
+ isCustomElement: (tag) => tag === "wexio-widget",
94
+ },
95
+ }));
96
+ },
97
+ };
98
+ ```
99
+
100
+ ### Nuxt 3
101
+
102
+ ```ts
103
+ // nuxt.config.ts
104
+ export default defineNuxtConfig({
105
+ vue: {
106
+ compilerOptions: {
107
+ isCustomElement: (tag) => tag === "wexio-widget",
108
+ },
109
+ },
110
+ });
111
+ ```
112
+
113
+ ## Identifying users
114
+
115
+ Pass a verified `user` prop to log a known visitor in. Provide ONE proof — a Google FedCM `id_token`, a host-signed `jwt`, or the legacy `userId` + `userHash` HMAC pair:
116
+
117
+ ```vue
118
+ <script setup lang="ts">
119
+ import { WexioWidget, type VisitorIdentity } from "@wexio/messenger-widget-vue";
120
+
121
+ const user: VisitorIdentity = {
122
+ jwt: serverSignedJwt, // host-signed identity token (recommended)
123
+ name: "Ada Lovelace",
124
+ email: "ada@example.com",
125
+ };
126
+ </script>
127
+
128
+ <template>
129
+ <WexioWidget public-key="pk_live_..." :user="user" />
130
+ </template>
131
+ ```
132
+
133
+ > **Use a reactive `ref` for `user` when identity changes** — the wrapper watches it and re-runs `identify()` on change. Pass `null` to log the visitor out.
134
+
135
+ ## Props
136
+
137
+ | Prop | Type | Description |
138
+ | --------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
139
+ | `public-key` | `string` | Wexio integration public key (`pk_live_...`). Omit to render in demo mode. |
140
+ | `locale` | `string` | UI locale (BCP-47, e.g. `"en"`, `"pt-BR"`, `"uk"`). Overrides the operator's `localeStrategy`. |
141
+ | `prefill-name` | `string` | Unverified prechat prefill. |
142
+ | `prefill-email` | `string` | Unverified prechat prefill. |
143
+ | `prefill-phone` | `string` | Unverified prechat prefill. |
144
+ | `user` | `VisitorIdentity \| null` | Known-user identity proof. Pass `null` to log out. |
145
+
146
+ ## Events
147
+
148
+ | Event | Payload | When |
149
+ | -------- | -------------------------------------- | --------------------------------------------------- |
150
+ | `resize` | `{ width: number; height: number }` | Panel dimensions changed (open ↔ closed). |
151
+ | `close` | — | Visitor closed the panel. |
152
+
153
+ ```vue
154
+ <template>
155
+ <WexioWidget
156
+ public-key="pk_live_..."
157
+ @resize="onResize"
158
+ @close="onClose"
159
+ />
160
+ </template>
161
+
162
+ <script setup lang="ts">
163
+ function onResize(size: { width: number; height: number }) {
164
+ console.log(size.width, size.height);
165
+ }
166
+ function onClose() {
167
+ console.log("visitor closed the panel");
168
+ }
169
+ </script>
170
+ ```
171
+
172
+ ## Types
173
+
174
+ ### VisitorIdentity
175
+
176
+ ```ts
177
+ interface VisitorIdentity {
178
+ googleIdToken?: string; // Google FedCM id_token (preferred)
179
+ jwt?: string; // Host-signed JWT
180
+ userId?: string; // Legacy HMAC pair…
181
+ userHash?: string; // …(HMAC-SHA256(userId, integrationSecret))
182
+ name?: string;
183
+ email?: string;
184
+ phone?: string;
185
+ attributes?: Record<string, unknown>;
186
+ }
187
+ ```
188
+
189
+ ## SSR
190
+
191
+ The wrapper renders an empty `<wexio-widget>` element on the server. The actual widget initialises on first client-side mount (`onMounted`). For Nuxt / SSR apps, no special handling is needed — the custom element runs only in the browser.
192
+
193
+ ## Browser support
194
+
195
+ Modern evergreen browsers — anything that supports Shadow DOM and ES2020. Internet Explorer is not supported.
196
+
197
+ ## Use with other frameworks
198
+
199
+ The underlying widget runtime is a Web Component, so it works in any modern framework:
200
+
201
+ - [`@wexio/messenger-widget-react`](https://www.npmjs.com/package/@wexio/messenger-widget-react) — React
202
+ - [`@wexio/messenger-widget-angular`](https://www.npmjs.com/package/@wexio/messenger-widget-angular) — Angular
203
+ - [`@wexio/messenger-widget-ember`](https://www.npmjs.com/package/@wexio/messenger-widget-ember) — Ember
204
+
205
+ ## Author
206
+
207
+ 👤 **Wexio** ([https://wexio.io](https://wexio.io))
208
+
209
+ ## Show your support
210
+
211
+ Give a ⭐️ if this package helped you!
212
+
213
+ ## 📝 License
214
+
215
+ This project is [MIT](./LICENSE) licensed.
216
+
217
+ ---
218
+
219
+ _Created with ❤️ by [Wexio](https://wexio.io)_
@@ -0,0 +1,62 @@
1
+ import type { DefineComponent } from "vue";
2
+
3
+ /** Known-user identity proof. Provide ONE of `googleIdToken`, `jwt`,
4
+ * or the legacy `userId` + `userHash` pair. `name` / `email` /
5
+ * `phone` populate the People profile; `attributes` is an open bag
6
+ * of context fields. */
7
+ export interface VisitorIdentity {
8
+ googleIdToken?: string;
9
+ jwt?: string;
10
+ userId?: string;
11
+ userHash?: string;
12
+ name?: string;
13
+ email?: string;
14
+ phone?: string;
15
+ attributes?: Record<string, unknown>;
16
+ }
17
+
18
+ export interface WexioWidgetProps {
19
+ /** Wexio integration public key (`pk_live_...`). Omit for demo mode. */
20
+ publicKey?: string;
21
+ /** UI locale (BCP-47, e.g. "en", "pt-BR", "uk"). Overrides the
22
+ * operator's `localeStrategy`. */
23
+ locale?: string;
24
+ /** Unverified prechat prefill. */
25
+ prefillName?: string;
26
+ /** Unverified prechat prefill. */
27
+ prefillEmail?: string;
28
+ /** Unverified prechat prefill. */
29
+ prefillPhone?: string;
30
+ /** Known-user identity proof. Pass `null` to log out. */
31
+ user?: VisitorIdentity | null;
32
+ }
33
+
34
+ export interface WexioWidgetEmits {
35
+ /** Fires every time panel dimensions change (open ↔ closed). */
36
+ resize: [size: { width: number; height: number }];
37
+ /** Fires when the visitor closes the panel. */
38
+ close: [];
39
+ }
40
+
41
+ /**
42
+ * Vue 3 wrapper around the `<wexio-widget>` web component.
43
+ *
44
+ * Forwards camelCase props to kebab-case attributes on the underlying
45
+ * custom element; re-emits the element's `wexio:resize` / `wexio:close`
46
+ * CustomEvents as Vue events.
47
+ *
48
+ * Importing this module SIDE-EFFECT registers `<wexio-widget>` — no
49
+ * separate script tag needed.
50
+ */
51
+ export declare const WexioWidget: DefineComponent<
52
+ WexioWidgetProps,
53
+ {},
54
+ {},
55
+ {},
56
+ {},
57
+ {},
58
+ {},
59
+ WexioWidgetEmits
60
+ >;
61
+
62
+ export default WexioWidget;
package/dist/index.js ADDED
@@ -0,0 +1,113 @@
1
+ /**
2
+ * `@wexio/messenger-widget-vue` — Vue 3 wrapper around the `<wexio-widget>`
3
+ * web component.
4
+ *
5
+ * Mounts a Shadow-DOM-isolated Wexio messenger inside a Vue tree. Forwards
6
+ * camelCase props to the underlying custom element's kebab-case
7
+ * attributes, and re-emits the element's `wexio:resize` / `wexio:close`
8
+ * CustomEvents as Vue events (with the `.detail` unwrapped).
9
+ *
10
+ * Importing this module side-effect registers `<wexio-widget>` as a
11
+ * custom element. The web-component bundle ships in this package's
12
+ * `dist/widget.js`; the consumer's bundler resolves it relative to
13
+ * the package main.
14
+ *
15
+ * Vue treats `<wexio-widget>` as an unknown DOM element by default —
16
+ * configure your build so the compiler skips it:
17
+ *
18
+ * // vite.config.js
19
+ * import vue from "@vitejs/plugin-vue";
20
+ * export default defineConfig({
21
+ * plugins: [vue({
22
+ * template: { compilerOptions: { isCustomElement: (tag) => tag === "wexio-widget" } },
23
+ * })],
24
+ * });
25
+ */
26
+
27
+ import {
28
+ defineComponent,
29
+ h,
30
+ onBeforeUnmount,
31
+ onMounted,
32
+ ref,
33
+ watch,
34
+ } from "vue";
35
+
36
+ import "./widget.js";
37
+
38
+ export const WexioWidget = defineComponent({
39
+ name: "WexioWidget",
40
+ props: {
41
+ /** Wexio integration public key (`pk_live_...`). Omit for demo mode. */
42
+ publicKey: { type: String, default: undefined },
43
+ /** UI locale (BCP-47). Overrides the operator's `localeStrategy`. */
44
+ locale: { type: String, default: undefined },
45
+ /** Force the widget mode. Public consumers should not set this —
46
+ * it auto-resolves to `production` when `publicKey` is set,
47
+ * `demo` otherwise. */
48
+ mode: { type: String, default: undefined },
49
+ /** Unverified prechat prefill. */
50
+ prefillName: { type: String, default: undefined },
51
+ /** Unverified prechat prefill. */
52
+ prefillEmail: { type: String, default: undefined },
53
+ /** Unverified prechat prefill. */
54
+ prefillPhone: { type: String, default: undefined },
55
+ /** Known-user identity proof. Pass `null` to log out. */
56
+ user: { type: [Object, null], default: undefined },
57
+ },
58
+ emits: {
59
+ resize: (payload) =>
60
+ payload &&
61
+ typeof payload.width === "number" &&
62
+ typeof payload.height === "number",
63
+ close: () => true,
64
+ },
65
+ setup(props, { emit }) {
66
+ const elRef = ref(null);
67
+
68
+ const onResize = (event) => {
69
+ if (event && event.detail) emit("resize", event.detail);
70
+ };
71
+ const onClose = () => emit("close");
72
+
73
+ onMounted(() => {
74
+ const el = elRef.value;
75
+ if (!el) return;
76
+ el.addEventListener("wexio:resize", onResize);
77
+ el.addEventListener("wexio:close", onClose);
78
+ if (props.user) el.identify?.(props.user);
79
+ });
80
+
81
+ onBeforeUnmount(() => {
82
+ const el = elRef.value;
83
+ if (!el) return;
84
+ el.removeEventListener("wexio:resize", onResize);
85
+ el.removeEventListener("wexio:close", onClose);
86
+ });
87
+
88
+ // Identity is set imperatively rather than as a reactive attribute —
89
+ // mirrors the React component's `user` prop semantics. `null` /
90
+ // `undefined` logs the visitor out.
91
+ watch(
92
+ () => props.user,
93
+ (next) => {
94
+ const el = elRef.value;
95
+ if (!el || !el.identify) return;
96
+ el.identify(next ?? null);
97
+ },
98
+ );
99
+
100
+ return () =>
101
+ h("wexio-widget", {
102
+ ref: elRef,
103
+ "public-key": props.publicKey,
104
+ locale: props.locale,
105
+ mode: props.mode,
106
+ "prefill-name": props.prefillName,
107
+ "prefill-email": props.prefillEmail,
108
+ "prefill-phone": props.prefillPhone,
109
+ });
110
+ },
111
+ });
112
+
113
+ export default WexioWidget;