@callembed/vue 0.0.0-stage → 0.1.2
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 +79 -2
- package/dist/index.cjs +467 -0
- package/dist/index.d.cts +241 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.js +444 -0
- package/dist/styles.css +89 -0
- package/package.json +80 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sealby
|
|
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
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@callembed/vue`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Vue 3 components and composables for [CallEmbed](https://callembed.sealby.me) — a **thin wrapper** over [`@callembed/sdk`](../sdk).
|
|
4
|
+
|
|
5
|
+
**Product model:** customer-service queue only. An end user on a web page clicks “talk to a human” → rings a project queue → an agent answers. This package does **not** implement person-to-person calling.
|
|
6
|
+
|
|
7
|
+
Call / auth / LiveKit connection logic stays in `@callembed/sdk`. Remote audio is already handled by the headless SDK (`hidePanel: true`).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @callembed/vue @callembed/sdk livekit-client vue
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Peer dependencies: `vue` (^3.4), `@callembed/sdk`, and `livekit-client` (optional peer; required transitively by the SDK).
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import { CallEmbedProvider, CallEmbedButton } from "@callembed/vue";
|
|
22
|
+
import "@callembed/vue/styles.css";
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<CallEmbedProvider
|
|
27
|
+
publishable-key="pk_…"
|
|
28
|
+
api-base-url=""
|
|
29
|
+
locale="en"
|
|
30
|
+
queue="onboarding"
|
|
31
|
+
>
|
|
32
|
+
<CallEmbedButton />
|
|
33
|
+
</CallEmbedProvider>
|
|
34
|
+
</template>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Plugin
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { createApp } from "vue";
|
|
41
|
+
import { CallEmbedPlugin } from "@callembed/vue";
|
|
42
|
+
|
|
43
|
+
createApp(App).use(CallEmbedPlugin).mount("#app");
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Composable
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { useCallEmbed } from "@callembed/vue";
|
|
50
|
+
|
|
51
|
+
const { uiState, muted, start, end, setMuted } = useCallEmbed();
|
|
52
|
+
// uiState: idle | ringing | connected | ended | error
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
| Export | Role |
|
|
58
|
+
|--------|------|
|
|
59
|
+
| `CallEmbedProvider` | Calls `CallEmbed.init` on the client; provides context |
|
|
60
|
+
| `CallEmbedButton` | Start / end button + optional mute + status line (en / zh-TW) |
|
|
61
|
+
| `useCallEmbed()` | `{ status, uiState, callId, muted, error, start, end, setMuted, … }` |
|
|
62
|
+
| `CallEmbedPlugin` | Registers Provider + Button globally |
|
|
63
|
+
|
|
64
|
+
`uiState` maps SDK `answered` → `connected`, and folds `connecting` into `ringing`. Locale strings match `@callembed/sdk/ui` (`en` + `zh-TW`). Theme: `--ce-*` CSS variables.
|
|
65
|
+
|
|
66
|
+
Unmount or `publishableKey` / `apiBaseUrl` change hangs up any active/ringing call. Init/start failures set `error` uiState.
|
|
67
|
+
|
|
68
|
+
## SSR / Nuxt
|
|
69
|
+
|
|
70
|
+
- No `window` / `document` access at import time.
|
|
71
|
+
- `CallEmbed.init` runs only when `typeof window !== "undefined"` (client).
|
|
72
|
+
- Use inside a client-only boundary (`<ClientOnly>` in Nuxt) if the button must not SSR-render interactive call UI.
|
|
73
|
+
|
|
74
|
+
## Builds
|
|
75
|
+
|
|
76
|
+
Emits ESM (`dist/index.js`), CJS (`dist/index.cjs`), and TypeScript declarations (`dist/index.d.ts`), plus `dist/styles.css`.
|
|
77
|
+
|
|
78
|
+
## Publishing
|
|
79
|
+
|
|
80
|
+
Published via the multi-package tag workflow (see [`docs/RELEASING.md`](../../docs/RELEASING.md)). Local allowlist check: `npm run pack:verify -w @callembed/vue`.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sdk = require('@callembed/sdk');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var ui = require('@callembed/sdk/ui');
|
|
6
|
+
|
|
7
|
+
// src/provider.ts
|
|
8
|
+
|
|
9
|
+
// src/types.ts
|
|
10
|
+
function toUiState(status) {
|
|
11
|
+
switch (status) {
|
|
12
|
+
case "connecting":
|
|
13
|
+
case "ringing":
|
|
14
|
+
return "ringing";
|
|
15
|
+
case "answered":
|
|
16
|
+
return "connected";
|
|
17
|
+
case "ended":
|
|
18
|
+
return "ended";
|
|
19
|
+
case "error":
|
|
20
|
+
return "error";
|
|
21
|
+
case "idle":
|
|
22
|
+
default:
|
|
23
|
+
return "idle";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
var CALL_EMBED_KEY = /* @__PURE__ */ Symbol("callembed");
|
|
27
|
+
|
|
28
|
+
// src/provider.ts
|
|
29
|
+
function toErrorState(err) {
|
|
30
|
+
if (err instanceof sdk.CallEmbedError) {
|
|
31
|
+
return { code: err.code, message: err.message };
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
code: "call_failed",
|
|
35
|
+
message: err instanceof Error ? err.message : String(err)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function isActiveStatus(status) {
|
|
39
|
+
return status === "connecting" || status === "ringing" || status === "answered";
|
|
40
|
+
}
|
|
41
|
+
function bindCall(call, handlers) {
|
|
42
|
+
const offs = [
|
|
43
|
+
call.on("statusChange", ({ status }) => {
|
|
44
|
+
handlers.setStatus(status);
|
|
45
|
+
if (call.callId && call.callId !== "pending") {
|
|
46
|
+
handlers.setCallId(call.callId);
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
call.on("muteChange", ({ muted }) => {
|
|
50
|
+
handlers.setMuted(muted);
|
|
51
|
+
}),
|
|
52
|
+
call.on("error", ({ code, message, callId }) => {
|
|
53
|
+
handlers.setError({ code, message });
|
|
54
|
+
handlers.setStatus("error");
|
|
55
|
+
if (callId && callId !== "pending") handlers.setCallId(callId);
|
|
56
|
+
}),
|
|
57
|
+
call.on("ended", ({ callId }) => {
|
|
58
|
+
handlers.setStatus("ended");
|
|
59
|
+
if (callId && callId !== "pending") handlers.setCallId(callId);
|
|
60
|
+
})
|
|
61
|
+
];
|
|
62
|
+
return () => {
|
|
63
|
+
offs.forEach((off) => off());
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
var CallEmbedProvider = vue.defineComponent({
|
|
67
|
+
name: "CallEmbedProvider",
|
|
68
|
+
props: {
|
|
69
|
+
publishableKey: { type: String, required: true },
|
|
70
|
+
apiBaseUrl: { type: String, required: true },
|
|
71
|
+
locale: { type: String, default: void 0 },
|
|
72
|
+
copy: {
|
|
73
|
+
type: Object,
|
|
74
|
+
default: void 0
|
|
75
|
+
},
|
|
76
|
+
branding: { type: Boolean, default: void 0 },
|
|
77
|
+
debug: { type: Boolean, default: void 0 },
|
|
78
|
+
queue: { type: String, default: void 0 }
|
|
79
|
+
},
|
|
80
|
+
slots: Object,
|
|
81
|
+
setup(props, { slots }) {
|
|
82
|
+
const status = vue.ref("idle");
|
|
83
|
+
const callId = vue.ref(null);
|
|
84
|
+
const muted = vue.ref(false);
|
|
85
|
+
const error = vue.ref(null);
|
|
86
|
+
const resolvedLocale = vue.ref(props.locale ?? "en");
|
|
87
|
+
const callRef = vue.ref(null);
|
|
88
|
+
let unbind = null;
|
|
89
|
+
const copyKey = vue.computed(() => JSON.stringify(props.copy ?? {}));
|
|
90
|
+
const brandingValue = vue.computed(() => props.branding !== false);
|
|
91
|
+
function hangUpActive() {
|
|
92
|
+
unbind?.();
|
|
93
|
+
unbind = null;
|
|
94
|
+
const call = callRef.value ?? sdk.CallEmbed.getActiveCall();
|
|
95
|
+
callRef.value = null;
|
|
96
|
+
if (call && isActiveStatus(call.status)) {
|
|
97
|
+
void call.hangUp();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function runInit() {
|
|
101
|
+
if (typeof window === "undefined") return;
|
|
102
|
+
try {
|
|
103
|
+
sdk.CallEmbed.init({
|
|
104
|
+
publishableKey: props.publishableKey,
|
|
105
|
+
apiBaseUrl: props.apiBaseUrl,
|
|
106
|
+
locale: props.locale,
|
|
107
|
+
copy: props.copy,
|
|
108
|
+
branding: props.branding,
|
|
109
|
+
debug: props.debug
|
|
110
|
+
});
|
|
111
|
+
const runtime = sdk.CallEmbed._getRuntime();
|
|
112
|
+
if (runtime) resolvedLocale.value = runtime.locale;
|
|
113
|
+
} catch (err) {
|
|
114
|
+
const state = toErrorState(err);
|
|
115
|
+
error.value = state;
|
|
116
|
+
status.value = "error";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
vue.watch(
|
|
120
|
+
() => [
|
|
121
|
+
props.publishableKey,
|
|
122
|
+
props.apiBaseUrl,
|
|
123
|
+
props.locale,
|
|
124
|
+
copyKey.value,
|
|
125
|
+
brandingValue.value,
|
|
126
|
+
props.debug
|
|
127
|
+
],
|
|
128
|
+
() => {
|
|
129
|
+
runInit();
|
|
130
|
+
},
|
|
131
|
+
{ immediate: true }
|
|
132
|
+
);
|
|
133
|
+
vue.watch(
|
|
134
|
+
() => [props.publishableKey, props.apiBaseUrl],
|
|
135
|
+
(_next, _prev, onCleanup) => {
|
|
136
|
+
onCleanup(() => {
|
|
137
|
+
hangUpActive();
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
{ immediate: true }
|
|
141
|
+
);
|
|
142
|
+
async function start(options = {}) {
|
|
143
|
+
try {
|
|
144
|
+
const q = options.queue ?? props.queue;
|
|
145
|
+
if (!q?.trim()) {
|
|
146
|
+
throw new sdk.CallEmbedError(
|
|
147
|
+
"invalid_queue",
|
|
148
|
+
"queue is required (pass queue on the provider, button, or start())."
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
error.value = null;
|
|
152
|
+
muted.value = false;
|
|
153
|
+
const userOn = options.on;
|
|
154
|
+
const call = await sdk.CallEmbed.startCall({
|
|
155
|
+
...options,
|
|
156
|
+
queue: q,
|
|
157
|
+
hidePanel: true,
|
|
158
|
+
on: {
|
|
159
|
+
...userOn,
|
|
160
|
+
statusChange: (payload) => {
|
|
161
|
+
status.value = payload.status;
|
|
162
|
+
userOn?.statusChange?.(payload);
|
|
163
|
+
},
|
|
164
|
+
muteChange: (payload) => {
|
|
165
|
+
muted.value = payload.muted;
|
|
166
|
+
userOn?.muteChange?.(payload);
|
|
167
|
+
},
|
|
168
|
+
error: (payload) => {
|
|
169
|
+
error.value = { code: payload.code, message: payload.message };
|
|
170
|
+
status.value = "error";
|
|
171
|
+
if (payload.callId && payload.callId !== "pending") {
|
|
172
|
+
callId.value = payload.callId;
|
|
173
|
+
}
|
|
174
|
+
userOn?.error?.(payload);
|
|
175
|
+
},
|
|
176
|
+
ended: (payload) => {
|
|
177
|
+
status.value = "ended";
|
|
178
|
+
if (payload.callId && payload.callId !== "pending") {
|
|
179
|
+
callId.value = payload.callId;
|
|
180
|
+
}
|
|
181
|
+
userOn?.ended?.(payload);
|
|
182
|
+
},
|
|
183
|
+
ringing: (payload) => {
|
|
184
|
+
callId.value = payload.callId;
|
|
185
|
+
userOn?.ringing?.(payload);
|
|
186
|
+
},
|
|
187
|
+
answered: (payload) => {
|
|
188
|
+
callId.value = payload.callId;
|
|
189
|
+
userOn?.answered?.(payload);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
unbind?.();
|
|
194
|
+
callRef.value = call;
|
|
195
|
+
status.value = call.status;
|
|
196
|
+
if (call.callId !== "pending") callId.value = call.callId;
|
|
197
|
+
unbind = bindCall(call, {
|
|
198
|
+
setStatus: (s) => {
|
|
199
|
+
status.value = s;
|
|
200
|
+
},
|
|
201
|
+
setCallId: (id) => {
|
|
202
|
+
callId.value = id;
|
|
203
|
+
},
|
|
204
|
+
setMuted: (m) => {
|
|
205
|
+
muted.value = m;
|
|
206
|
+
},
|
|
207
|
+
setError: (e) => {
|
|
208
|
+
error.value = e;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return call;
|
|
212
|
+
} catch (err) {
|
|
213
|
+
const state = toErrorState(err);
|
|
214
|
+
error.value = state;
|
|
215
|
+
status.value = "error";
|
|
216
|
+
if (err instanceof sdk.CallEmbedError) throw err;
|
|
217
|
+
throw new sdk.CallEmbedError("call_failed", state.message);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
async function end() {
|
|
221
|
+
const call = callRef.value ?? sdk.CallEmbed.getActiveCall();
|
|
222
|
+
if (!call) {
|
|
223
|
+
status.value = "idle";
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
await call.hangUp();
|
|
227
|
+
}
|
|
228
|
+
async function setMuted(next) {
|
|
229
|
+
const call = callRef.value ?? sdk.CallEmbed.getActiveCall();
|
|
230
|
+
if (!call) {
|
|
231
|
+
muted.value = next;
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
await call.setMuted(next);
|
|
235
|
+
}
|
|
236
|
+
const api = vue.reactive({
|
|
237
|
+
get status() {
|
|
238
|
+
return status.value;
|
|
239
|
+
},
|
|
240
|
+
get uiState() {
|
|
241
|
+
return toUiState(status.value);
|
|
242
|
+
},
|
|
243
|
+
get callId() {
|
|
244
|
+
return callId.value;
|
|
245
|
+
},
|
|
246
|
+
get muted() {
|
|
247
|
+
return muted.value;
|
|
248
|
+
},
|
|
249
|
+
get error() {
|
|
250
|
+
return error.value;
|
|
251
|
+
},
|
|
252
|
+
get locale() {
|
|
253
|
+
return resolvedLocale.value;
|
|
254
|
+
},
|
|
255
|
+
start,
|
|
256
|
+
end,
|
|
257
|
+
setMuted,
|
|
258
|
+
get defaultQueue() {
|
|
259
|
+
return props.queue;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
vue.provide(CALL_EMBED_KEY, api);
|
|
263
|
+
return () => slots.default?.();
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
function useCallEmbed() {
|
|
267
|
+
const ctx = vue.inject(CALL_EMBED_KEY, null);
|
|
268
|
+
if (!ctx) {
|
|
269
|
+
throw new Error("useCallEmbed() must be used within <CallEmbedProvider>.");
|
|
270
|
+
}
|
|
271
|
+
return ctx;
|
|
272
|
+
}
|
|
273
|
+
function statusLabel(copy, uiState, sdkStatus) {
|
|
274
|
+
switch (uiState) {
|
|
275
|
+
case "idle":
|
|
276
|
+
return copy.ready;
|
|
277
|
+
case "ringing":
|
|
278
|
+
return sdkStatus === "connecting" ? copy.connecting : copy.ringing;
|
|
279
|
+
case "connected":
|
|
280
|
+
return copy.answered;
|
|
281
|
+
case "ended":
|
|
282
|
+
return copy.ended;
|
|
283
|
+
case "error":
|
|
284
|
+
return copy.error;
|
|
285
|
+
default:
|
|
286
|
+
return copy.ready;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function runtimeForCopy(locale, copyOverrides = {}) {
|
|
290
|
+
return {
|
|
291
|
+
publishableKey: "",
|
|
292
|
+
apiBaseUrl: "",
|
|
293
|
+
locale,
|
|
294
|
+
copyOverrides,
|
|
295
|
+
branding: true,
|
|
296
|
+
debug: false
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// src/CallEmbedButton.ts
|
|
301
|
+
var CallEmbedButton = vue.defineComponent({
|
|
302
|
+
name: "CallEmbedButton",
|
|
303
|
+
props: {
|
|
304
|
+
/** Queue to ring. Falls back to `CallEmbedProvider` `queue`. */
|
|
305
|
+
queue: { type: String, default: void 0 },
|
|
306
|
+
/** Idle-state label; defaults to locale `launchDefault`. */
|
|
307
|
+
label: { type: String, default: void 0 },
|
|
308
|
+
/** Optional metadata forwarded to `startCall`. */
|
|
309
|
+
metadata: {
|
|
310
|
+
type: Object,
|
|
311
|
+
default: void 0
|
|
312
|
+
},
|
|
313
|
+
/** Optional caller display name. */
|
|
314
|
+
displayName: { type: String, default: void 0 },
|
|
315
|
+
/** Show a status line under the button. Default: `true`. */
|
|
316
|
+
showStatus: { type: Boolean, default: true },
|
|
317
|
+
/** Show mute control while ringing/connected. Default: `true`. */
|
|
318
|
+
showMute: { type: Boolean, default: true },
|
|
319
|
+
disabled: { type: Boolean, default: false }
|
|
320
|
+
},
|
|
321
|
+
emits: {
|
|
322
|
+
error: (_error) => true
|
|
323
|
+
},
|
|
324
|
+
setup(props, { emit, attrs }) {
|
|
325
|
+
const embed = useCallEmbed();
|
|
326
|
+
const busy = vue.ref(false);
|
|
327
|
+
const copy = vue.computed(() => ui.resolveCopy(runtimeForCopy(embed.locale)));
|
|
328
|
+
const inCall = vue.computed(
|
|
329
|
+
() => embed.uiState === "ringing" || embed.uiState === "connected"
|
|
330
|
+
);
|
|
331
|
+
const buttonLabel = vue.computed(
|
|
332
|
+
() => inCall.value ? copy.value.hangup : props.label ?? copy.value.launchDefault
|
|
333
|
+
);
|
|
334
|
+
const statusText = vue.computed(() => {
|
|
335
|
+
if (embed.uiState === "error" && embed.error) {
|
|
336
|
+
return ui.friendlyErrorMessage(
|
|
337
|
+
copy.value,
|
|
338
|
+
embed.error.code,
|
|
339
|
+
embed.error.message
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
return statusLabel(copy.value, embed.uiState, embed.status);
|
|
343
|
+
});
|
|
344
|
+
const tone = vue.computed(
|
|
345
|
+
() => embed.uiState === "error" ? "error" : embed.uiState === "connected" ? "ok" : void 0
|
|
346
|
+
);
|
|
347
|
+
async function onClick() {
|
|
348
|
+
if (busy.value) return;
|
|
349
|
+
busy.value = true;
|
|
350
|
+
try {
|
|
351
|
+
if (inCall.value) {
|
|
352
|
+
await embed.end();
|
|
353
|
+
} else {
|
|
354
|
+
await embed.start({
|
|
355
|
+
queue: props.queue ?? embed.defaultQueue,
|
|
356
|
+
metadata: props.metadata,
|
|
357
|
+
displayName: props.displayName
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
} catch (err) {
|
|
361
|
+
const ce = err instanceof sdk.CallEmbedError ? err : new sdk.CallEmbedError(
|
|
362
|
+
"call_failed",
|
|
363
|
+
err instanceof Error ? err.message : String(err)
|
|
364
|
+
);
|
|
365
|
+
emit("error", ce);
|
|
366
|
+
} finally {
|
|
367
|
+
busy.value = false;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
async function onMuteClick() {
|
|
371
|
+
if (busy.value) return;
|
|
372
|
+
busy.value = true;
|
|
373
|
+
try {
|
|
374
|
+
await embed.setMuted(!embed.muted);
|
|
375
|
+
} catch (err) {
|
|
376
|
+
const ce = err instanceof sdk.CallEmbedError ? err : new sdk.CallEmbedError(
|
|
377
|
+
"call_failed",
|
|
378
|
+
err instanceof Error ? err.message : String(err)
|
|
379
|
+
);
|
|
380
|
+
emit("error", ce);
|
|
381
|
+
} finally {
|
|
382
|
+
busy.value = false;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return () => {
|
|
386
|
+
const rootClass = ["ce-vue-root", attrs.class].filter(Boolean).join(" ");
|
|
387
|
+
const children = [
|
|
388
|
+
vue.h(
|
|
389
|
+
"button",
|
|
390
|
+
{
|
|
391
|
+
type: "button",
|
|
392
|
+
class: "ce-vue-button",
|
|
393
|
+
"data-state": embed.uiState,
|
|
394
|
+
disabled: props.disabled || busy.value,
|
|
395
|
+
"aria-busy": busy.value || void 0,
|
|
396
|
+
onClick: () => {
|
|
397
|
+
void onClick();
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
buttonLabel.value
|
|
401
|
+
)
|
|
402
|
+
];
|
|
403
|
+
if (props.showMute && inCall.value) {
|
|
404
|
+
children.push(
|
|
405
|
+
vue.h(
|
|
406
|
+
"button",
|
|
407
|
+
{
|
|
408
|
+
type: "button",
|
|
409
|
+
class: "ce-vue-mute",
|
|
410
|
+
disabled: busy.value,
|
|
411
|
+
onClick: () => {
|
|
412
|
+
void onMuteClick();
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
embed.muted ? copy.value.unmute : copy.value.mute
|
|
416
|
+
)
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
if (props.showStatus) {
|
|
420
|
+
children.push(
|
|
421
|
+
vue.h(
|
|
422
|
+
"p",
|
|
423
|
+
{
|
|
424
|
+
class: "ce-vue-status",
|
|
425
|
+
"data-tone": tone.value,
|
|
426
|
+
"data-state": embed.uiState
|
|
427
|
+
},
|
|
428
|
+
statusText.value
|
|
429
|
+
)
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
return vue.h("div", { class: rootClass, "data-ce-vue": "" }, children);
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
// src/plugin.ts
|
|
438
|
+
var CallEmbedPlugin = {
|
|
439
|
+
install(app, options = {}) {
|
|
440
|
+
app.component(options.providerName ?? "CallEmbedProvider", CallEmbedProvider);
|
|
441
|
+
app.component(options.buttonName ?? "CallEmbedButton", CallEmbedButton);
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
Object.defineProperty(exports, "enCopy", {
|
|
446
|
+
enumerable: true,
|
|
447
|
+
get: function () { return ui.enCopy; }
|
|
448
|
+
});
|
|
449
|
+
Object.defineProperty(exports, "friendlyErrorMessage", {
|
|
450
|
+
enumerable: true,
|
|
451
|
+
get: function () { return ui.friendlyErrorMessage; }
|
|
452
|
+
});
|
|
453
|
+
Object.defineProperty(exports, "resolveCopy", {
|
|
454
|
+
enumerable: true,
|
|
455
|
+
get: function () { return ui.resolveCopy; }
|
|
456
|
+
});
|
|
457
|
+
Object.defineProperty(exports, "zhTwCopy", {
|
|
458
|
+
enumerable: true,
|
|
459
|
+
get: function () { return ui.zhTwCopy; }
|
|
460
|
+
});
|
|
461
|
+
exports.CALL_EMBED_KEY = CALL_EMBED_KEY;
|
|
462
|
+
exports.CallEmbedButton = CallEmbedButton;
|
|
463
|
+
exports.CallEmbedPlugin = CallEmbedPlugin;
|
|
464
|
+
exports.CallEmbedProvider = CallEmbedProvider;
|
|
465
|
+
exports.statusLabel = statusLabel;
|
|
466
|
+
exports.toUiState = toUiState;
|
|
467
|
+
exports.useCallEmbed = useCallEmbed;
|