@wexio/messenger-widget-angular 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 +21 -0
- package/README.md +175 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +1 -0
- package/dist/wexio-widget.component.js +119 -0
- package/dist/widget.js +100809 -0
- package/package.json +44 -0
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,175 @@
|
|
|
1
|
+
# Welcome to @wexio/messenger-widget-angular 👋
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@wexio/messenger-widget-angular)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://learn.wexio.io/docs/web-widget)
|
|
6
|
+
|
|
7
|
+
Native Angular standalone component for the [Wexio](https://wexio.io) web messenger. Thin 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 Angular 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
|
+
- [Identifying users](#identifying-users)
|
|
17
|
+
- [Inputs](#inputs)
|
|
18
|
+
- [Outputs](#outputs)
|
|
19
|
+
- [Types](#types)
|
|
20
|
+
- [SSR (Angular Universal)](#ssr-angular-universal)
|
|
21
|
+
- [Browser support](#browser-support)
|
|
22
|
+
- [Author](#author)
|
|
23
|
+
- [License](#-license)
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @wexio/messenger-widget-angular
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
or
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install @wexio/messenger-widget-angular
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Peer dependencies: `@angular/core >= 16`, `@angular/common >= 16`. The widget uses the host's Angular runtime.
|
|
38
|
+
|
|
39
|
+
## Quick start
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// app.component.ts
|
|
43
|
+
import { Component } from "@angular/core";
|
|
44
|
+
import { WexioWidgetComponent } from "@wexio/messenger-widget-angular";
|
|
45
|
+
|
|
46
|
+
@Component({
|
|
47
|
+
standalone: true,
|
|
48
|
+
imports: [WexioWidgetComponent],
|
|
49
|
+
selector: "app-root",
|
|
50
|
+
template: `
|
|
51
|
+
<main>
|
|
52
|
+
<!-- your app -->
|
|
53
|
+
<wexio-widget-ng publicKey="pk_live_..." />
|
|
54
|
+
</main>
|
|
55
|
+
`,
|
|
56
|
+
})
|
|
57
|
+
export class AppComponent {}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
That's it — the widget mounts a floating launcher, handles its own theme/locale/state, and the operator dashboard sees the visitor immediately.
|
|
61
|
+
|
|
62
|
+
> **Selector** — the component selector is `wexio-widget-ng` (suffixed to avoid clashing with the underlying `<wexio-widget>` custom element it renders).
|
|
63
|
+
|
|
64
|
+
## Identifying users
|
|
65
|
+
|
|
66
|
+
Pass a verified `user` input 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:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { Component } from "@angular/core";
|
|
70
|
+
import {
|
|
71
|
+
VisitorIdentity,
|
|
72
|
+
WexioWidgetComponent,
|
|
73
|
+
} from "@wexio/messenger-widget-angular";
|
|
74
|
+
|
|
75
|
+
@Component({
|
|
76
|
+
standalone: true,
|
|
77
|
+
imports: [WexioWidgetComponent],
|
|
78
|
+
selector: "app-root",
|
|
79
|
+
template: `<wexio-widget-ng publicKey="pk_live_..." [user]="user" />`,
|
|
80
|
+
})
|
|
81
|
+
export class AppComponent {
|
|
82
|
+
user: VisitorIdentity = {
|
|
83
|
+
jwt: serverSignedJwt, // host-signed identity token (recommended)
|
|
84
|
+
name: "Ada Lovelace",
|
|
85
|
+
email: "ada@example.com",
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
> **Reactive identity** — assign a new object (or `null`) to `user` to re-fire the handshake / log out. The component's `ngOnChanges` watches it.
|
|
91
|
+
|
|
92
|
+
## Inputs
|
|
93
|
+
|
|
94
|
+
| Input | Type | Description |
|
|
95
|
+
| -------------- | ----------------------------- | --------------------------------------------------------------------------------- |
|
|
96
|
+
| `publicKey` | `string` | Wexio integration public key (`pk_live_...`). Omit for demo mode. |
|
|
97
|
+
| `locale` | `string` | UI locale (BCP-47). Overrides the operator's `localeStrategy`. |
|
|
98
|
+
| `prefillName` | `string` | Unverified prechat prefill. |
|
|
99
|
+
| `prefillEmail` | `string` | Unverified prechat prefill. |
|
|
100
|
+
| `prefillPhone` | `string` | Unverified prechat prefill. |
|
|
101
|
+
| `user` | `VisitorIdentity \| null` | Known-user identity proof. Pass `null` to log out. |
|
|
102
|
+
|
|
103
|
+
## Outputs
|
|
104
|
+
|
|
105
|
+
| Output | Payload | When |
|
|
106
|
+
| --------- | -------------------------------------- | --------------------------------------------------- |
|
|
107
|
+
| `resize` | `{ width: number; height: number }` | Panel dimensions changed (open ↔ closed). |
|
|
108
|
+
| `close` | `void` | Visitor closed the panel. |
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
template: `
|
|
112
|
+
<wexio-widget-ng
|
|
113
|
+
publicKey="pk_live_..."
|
|
114
|
+
(resize)="onResize($event)"
|
|
115
|
+
(close)="onClose()"
|
|
116
|
+
/>
|
|
117
|
+
`;
|
|
118
|
+
|
|
119
|
+
// ...
|
|
120
|
+
onResize(size: { width: number; height: number }) {
|
|
121
|
+
console.log(size.width, size.height);
|
|
122
|
+
}
|
|
123
|
+
onClose() {
|
|
124
|
+
console.log("visitor closed the panel");
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Types
|
|
129
|
+
|
|
130
|
+
### VisitorIdentity
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
interface VisitorIdentity {
|
|
134
|
+
googleIdToken?: string; // Google FedCM id_token (preferred)
|
|
135
|
+
jwt?: string; // Host-signed JWT
|
|
136
|
+
userId?: string; // Legacy HMAC pair…
|
|
137
|
+
userHash?: string; // …(HMAC-SHA256(userId, integrationSecret))
|
|
138
|
+
name?: string;
|
|
139
|
+
email?: string;
|
|
140
|
+
phone?: string;
|
|
141
|
+
attributes?: Record<string, unknown>;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## SSR (Angular Universal)
|
|
146
|
+
|
|
147
|
+
The wrapper renders an empty `<wexio-widget>` element on the server. The actual widget initialises on first client-side mount (`ngAfterViewInit`). No special handling is needed for Angular Universal — the custom element runs only in the browser.
|
|
148
|
+
|
|
149
|
+
## Browser support
|
|
150
|
+
|
|
151
|
+
Modern evergreen browsers — anything that supports Shadow DOM and ES2020. Internet Explorer is not supported.
|
|
152
|
+
|
|
153
|
+
## Use with other frameworks
|
|
154
|
+
|
|
155
|
+
The underlying widget runtime is a Web Component, so it works in any modern framework:
|
|
156
|
+
|
|
157
|
+
- [`@wexio/messenger-widget-react`](https://www.npmjs.com/package/@wexio/messenger-widget-react) — React
|
|
158
|
+
- [`@wexio/messenger-widget-vue`](https://www.npmjs.com/package/@wexio/messenger-widget-vue) — Vue 3
|
|
159
|
+
- [`@wexio/messenger-widget-ember`](https://www.npmjs.com/package/@wexio/messenger-widget-ember) — Ember
|
|
160
|
+
|
|
161
|
+
## Author
|
|
162
|
+
|
|
163
|
+
👤 **Wexio** ([https://wexio.io](https://wexio.io))
|
|
164
|
+
|
|
165
|
+
## Show your support
|
|
166
|
+
|
|
167
|
+
Give a ⭐️ if this package helped you!
|
|
168
|
+
|
|
169
|
+
## 📝 License
|
|
170
|
+
|
|
171
|
+
This project is [MIT](./LICENSE) licensed.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
_Created with ❤️ by [Wexio](https://wexio.io)_
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AfterViewInit,
|
|
3
|
+
ElementRef,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
OnChanges,
|
|
6
|
+
OnDestroy,
|
|
7
|
+
SimpleChanges,
|
|
8
|
+
} from "@angular/core";
|
|
9
|
+
|
|
10
|
+
/** Known-user identity proof. Provide ONE of `googleIdToken`, `jwt`,
|
|
11
|
+
* or the legacy `userId` + `userHash` pair. */
|
|
12
|
+
export interface VisitorIdentity {
|
|
13
|
+
googleIdToken?: string;
|
|
14
|
+
jwt?: string;
|
|
15
|
+
userId?: string;
|
|
16
|
+
userHash?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
phone?: string;
|
|
20
|
+
attributes?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Standalone Angular component wrapping the `<wexio-widget>` web
|
|
25
|
+
* component. Drop into any component's `imports`:
|
|
26
|
+
*
|
|
27
|
+
* @Component({
|
|
28
|
+
* standalone: true,
|
|
29
|
+
* imports: [WexioWidgetComponent],
|
|
30
|
+
* template: `<wexio-widget-ng [publicKey]="pk" (close)="onClose()" />`,
|
|
31
|
+
* })
|
|
32
|
+
* export class AppComponent { ... }
|
|
33
|
+
*/
|
|
34
|
+
export declare class WexioWidgetComponent
|
|
35
|
+
implements AfterViewInit, OnChanges, OnDestroy
|
|
36
|
+
{
|
|
37
|
+
/** Wexio integration public key (`pk_live_...`). Omit for demo mode. */
|
|
38
|
+
publicKey?: string;
|
|
39
|
+
/** UI locale (BCP-47). Overrides the operator's `localeStrategy`. */
|
|
40
|
+
locale?: string;
|
|
41
|
+
/** Force widget mode. Public consumers should not set this. */
|
|
42
|
+
mode?: "production" | "preview" | "demo";
|
|
43
|
+
/** Unverified prechat prefill. */
|
|
44
|
+
prefillName?: string;
|
|
45
|
+
/** Unverified prechat prefill. */
|
|
46
|
+
prefillEmail?: string;
|
|
47
|
+
/** Unverified prechat prefill. */
|
|
48
|
+
prefillPhone?: string;
|
|
49
|
+
/** Known-user identity proof. Pass `null` to log out. */
|
|
50
|
+
user?: VisitorIdentity | null;
|
|
51
|
+
|
|
52
|
+
/** Fires every time panel dimensions change (open ↔ closed). */
|
|
53
|
+
resize: EventEmitter<{ width: number; height: number }>;
|
|
54
|
+
/** Fires when the visitor closes the panel. */
|
|
55
|
+
close: EventEmitter<void>;
|
|
56
|
+
|
|
57
|
+
elRef: ElementRef<HTMLElement>;
|
|
58
|
+
|
|
59
|
+
ngAfterViewInit(): void;
|
|
60
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
61
|
+
ngOnDestroy(): void;
|
|
62
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WexioWidgetComponent } from "./wexio-widget.component";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@wexio/messenger-widget-angular` — Angular standalone component
|
|
3
|
+
* wrapping the `<wexio-widget>` custom element.
|
|
4
|
+
*
|
|
5
|
+
* Forwards `@Input()` properties to kebab-case attributes on the
|
|
6
|
+
* underlying custom element and re-emits its `wexio:resize` /
|
|
7
|
+
* `wexio:close` CustomEvents as Angular `@Output()` `EventEmitter`s.
|
|
8
|
+
*
|
|
9
|
+
* Importing this module side-effect registers `<wexio-widget>` as a
|
|
10
|
+
* custom element — no separate script tag needed.
|
|
11
|
+
*
|
|
12
|
+
* Standalone — drop into any Angular component's `imports`:
|
|
13
|
+
*
|
|
14
|
+
* import { WexioWidgetComponent } from "@wexio/messenger-widget-angular";
|
|
15
|
+
*
|
|
16
|
+
* @Component({
|
|
17
|
+
* standalone: true,
|
|
18
|
+
* imports: [WexioWidgetComponent],
|
|
19
|
+
* template: `<wexio-widget-ng [publicKey]="pk" (close)="onClose()" />`,
|
|
20
|
+
* })
|
|
21
|
+
* export class AppComponent { ... }
|
|
22
|
+
*/
|
|
23
|
+
var _a;
|
|
24
|
+
import { __decorate, __metadata } from "tslib";
|
|
25
|
+
import { Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, EventEmitter, Input, Output, ViewChild, } from "@angular/core";
|
|
26
|
+
import "./widget.js";
|
|
27
|
+
let WexioWidgetComponent = class WexioWidgetComponent {
|
|
28
|
+
constructor() {
|
|
29
|
+
/** Fires every time panel dimensions change (open ↔ closed). */
|
|
30
|
+
this.resize = new EventEmitter();
|
|
31
|
+
/** Fires when the visitor closes the panel. */
|
|
32
|
+
this.close = new EventEmitter();
|
|
33
|
+
this.onResize = (event) => {
|
|
34
|
+
const detail = event
|
|
35
|
+
.detail;
|
|
36
|
+
if (detail)
|
|
37
|
+
this.resize.emit(detail);
|
|
38
|
+
};
|
|
39
|
+
this.onClose = () => this.close.emit();
|
|
40
|
+
}
|
|
41
|
+
ngAfterViewInit() {
|
|
42
|
+
const el = this.elRef?.nativeElement;
|
|
43
|
+
if (!el)
|
|
44
|
+
return;
|
|
45
|
+
el.addEventListener("wexio:resize", this.onResize);
|
|
46
|
+
el.addEventListener("wexio:close", this.onClose);
|
|
47
|
+
if (this.user)
|
|
48
|
+
el.identify?.(this.user);
|
|
49
|
+
}
|
|
50
|
+
ngOnChanges(changes) {
|
|
51
|
+
if (changes["user"] && this.elRef?.nativeElement) {
|
|
52
|
+
this.elRef.nativeElement.identify?.(this.user ?? null);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
ngOnDestroy() {
|
|
56
|
+
const el = this.elRef?.nativeElement;
|
|
57
|
+
if (!el)
|
|
58
|
+
return;
|
|
59
|
+
el.removeEventListener("wexio:resize", this.onResize);
|
|
60
|
+
el.removeEventListener("wexio:close", this.onClose);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
__decorate([
|
|
64
|
+
Input(),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], WexioWidgetComponent.prototype, "publicKey", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
Input(),
|
|
69
|
+
__metadata("design:type", String)
|
|
70
|
+
], WexioWidgetComponent.prototype, "locale", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
Input(),
|
|
73
|
+
__metadata("design:type", String)
|
|
74
|
+
], WexioWidgetComponent.prototype, "mode", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
Input(),
|
|
77
|
+
__metadata("design:type", String)
|
|
78
|
+
], WexioWidgetComponent.prototype, "prefillName", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
Input(),
|
|
81
|
+
__metadata("design:type", String)
|
|
82
|
+
], WexioWidgetComponent.prototype, "prefillEmail", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
Input(),
|
|
85
|
+
__metadata("design:type", String)
|
|
86
|
+
], WexioWidgetComponent.prototype, "prefillPhone", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
Input(),
|
|
89
|
+
__metadata("design:type", Object)
|
|
90
|
+
], WexioWidgetComponent.prototype, "user", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
Output(),
|
|
93
|
+
__metadata("design:type", Object)
|
|
94
|
+
], WexioWidgetComponent.prototype, "resize", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
Output(),
|
|
97
|
+
__metadata("design:type", Object)
|
|
98
|
+
], WexioWidgetComponent.prototype, "close", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
ViewChild("el", { static: true }),
|
|
101
|
+
__metadata("design:type", typeof (_a = typeof ElementRef !== "undefined" && ElementRef) === "function" ? _a : Object)
|
|
102
|
+
], WexioWidgetComponent.prototype, "elRef", void 0);
|
|
103
|
+
WexioWidgetComponent = __decorate([
|
|
104
|
+
Component({
|
|
105
|
+
standalone: true,
|
|
106
|
+
selector: "wexio-widget-ng",
|
|
107
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
108
|
+
template: `<wexio-widget
|
|
109
|
+
#el
|
|
110
|
+
[attr.public-key]="publicKey ?? null"
|
|
111
|
+
[attr.locale]="locale ?? null"
|
|
112
|
+
[attr.mode]="mode ?? null"
|
|
113
|
+
[attr.prefill-name]="prefillName ?? null"
|
|
114
|
+
[attr.prefill-email]="prefillEmail ?? null"
|
|
115
|
+
[attr.prefill-phone]="prefillPhone ?? null"
|
|
116
|
+
></wexio-widget>`,
|
|
117
|
+
})
|
|
118
|
+
], WexioWidgetComponent);
|
|
119
|
+
export { WexioWidgetComponent };
|