@callembed/vue 0.0.0-stage → 0.1.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.
@@ -0,0 +1,241 @@
1
+ import * as vue from 'vue';
2
+ import { PropType, SlotsType, Plugin } from 'vue';
3
+ import { CallStatus, Locale, StartCallOptions, ActiveCall, InitOptions, CallEmbedError } from '@callembed/sdk';
4
+ export { ActiveCall, CallStatus, InitOptions, Locale, StartCallOptions } from '@callembed/sdk';
5
+ import { PanelCopy } from '@callembed/sdk/ui';
6
+ export { PanelCopy, enCopy, friendlyErrorMessage, resolveCopy, zhTwCopy } from '@callembed/sdk/ui';
7
+
8
+ /**
9
+ * Simplified UI lifecycle for `<CallEmbedButton />`.
10
+ * Maps onto SDK {@link CallStatus}:
11
+ * - `connecting` | `ringing` → `ringing`
12
+ * - `answered` → `connected`
13
+ */
14
+ type CallEmbedUiState = "idle" | "ringing" | "connected" | "ended" | "error";
15
+ declare function toUiState(status: CallStatus | "idle"): CallEmbedUiState;
16
+ interface CallEmbedErrorState {
17
+ code: string;
18
+ message: string;
19
+ }
20
+ interface CallEmbedContextValue {
21
+ /** SDK call status (includes `connecting` / `answered`). */
22
+ status: CallStatus | "idle";
23
+ /** Button-oriented status (`answered` → `connected`). */
24
+ uiState: CallEmbedUiState;
25
+ callId: string | null;
26
+ muted: boolean;
27
+ error: CallEmbedErrorState | null;
28
+ locale: Locale;
29
+ /** Start a queue call (customer-service ring → agent answers). */
30
+ start: (options?: Partial<StartCallOptions> & {
31
+ queue?: string;
32
+ }) => Promise<ActiveCall>;
33
+ /** Hang up the active call (idempotent). */
34
+ end: () => Promise<void>;
35
+ setMuted: (muted: boolean) => Promise<void>;
36
+ /** Default queue from the provider when button/composable omit `queue`. */
37
+ defaultQueue: string | undefined;
38
+ }
39
+ type CallEmbedProviderProps = InitOptions & {
40
+ /**
41
+ * Default queue name for `<CallEmbedButton />` / `useCallEmbed().start()`
42
+ * when callers omit `queue`.
43
+ */
44
+ queue?: string;
45
+ };
46
+ declare const CALL_EMBED_KEY: unique symbol;
47
+
48
+ /**
49
+ * Initializes `@callembed/sdk` once for the subtree and exposes call state.
50
+ * Safe for Nuxt / Vue SSR: no `window` access at module evaluate time;
51
+ * `CallEmbed.init` runs in a client-only watcher (skipped when `window` is undefined).
52
+ *
53
+ * Unmount or `publishableKey` / `apiBaseUrl` change hangs up any active call
54
+ * so an SPA route change cannot leave a billed call running.
55
+ */
56
+ declare const CallEmbedProvider: vue.DefineComponent<vue.ExtractPropTypes<{
57
+ publishableKey: {
58
+ type: StringConstructor;
59
+ required: true;
60
+ };
61
+ apiBaseUrl: {
62
+ type: StringConstructor;
63
+ required: true;
64
+ };
65
+ locale: {
66
+ type: PropType<Locale>;
67
+ default: undefined;
68
+ };
69
+ copy: {
70
+ type: PropType<Partial<Record<string, string>>>;
71
+ default: undefined;
72
+ };
73
+ branding: {
74
+ type: BooleanConstructor;
75
+ default: undefined;
76
+ };
77
+ debug: {
78
+ type: BooleanConstructor;
79
+ default: undefined;
80
+ };
81
+ queue: {
82
+ type: StringConstructor;
83
+ default: undefined;
84
+ };
85
+ }>, () => unknown, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
86
+ publishableKey: {
87
+ type: StringConstructor;
88
+ required: true;
89
+ };
90
+ apiBaseUrl: {
91
+ type: StringConstructor;
92
+ required: true;
93
+ };
94
+ locale: {
95
+ type: PropType<Locale>;
96
+ default: undefined;
97
+ };
98
+ copy: {
99
+ type: PropType<Partial<Record<string, string>>>;
100
+ default: undefined;
101
+ };
102
+ branding: {
103
+ type: BooleanConstructor;
104
+ default: undefined;
105
+ };
106
+ debug: {
107
+ type: BooleanConstructor;
108
+ default: undefined;
109
+ };
110
+ queue: {
111
+ type: StringConstructor;
112
+ default: undefined;
113
+ };
114
+ }>> & Readonly<{}>, {
115
+ locale: Locale;
116
+ copy: Partial<Record<string, string>>;
117
+ branding: boolean;
118
+ debug: boolean;
119
+ queue: string;
120
+ }, SlotsType<{
121
+ default: () => unknown;
122
+ }>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
123
+ /**
124
+ * Access CallEmbed state and controls. Must be used under {@link CallEmbedProvider}.
125
+ */
126
+ declare function useCallEmbed(): CallEmbedContextValue;
127
+
128
+ /**
129
+ * Start / end call button for a customer-service queue.
130
+ * States: `idle` → `ringing` → `connected` → `ended` | `error`.
131
+ */
132
+ declare const CallEmbedButton: vue.DefineComponent<vue.ExtractPropTypes<{
133
+ /** Queue to ring. Falls back to `CallEmbedProvider` `queue`. */
134
+ queue: {
135
+ type: StringConstructor;
136
+ default: undefined;
137
+ };
138
+ /** Idle-state label; defaults to locale `launchDefault`. */
139
+ label: {
140
+ type: StringConstructor;
141
+ default: undefined;
142
+ };
143
+ /** Optional metadata forwarded to `startCall`. */
144
+ metadata: {
145
+ type: PropType<Record<string, unknown>>;
146
+ default: undefined;
147
+ };
148
+ /** Optional caller display name. */
149
+ displayName: {
150
+ type: StringConstructor;
151
+ default: undefined;
152
+ };
153
+ /** Show a status line under the button. Default: `true`. */
154
+ showStatus: {
155
+ type: BooleanConstructor;
156
+ default: boolean;
157
+ };
158
+ /** Show mute control while ringing/connected. Default: `true`. */
159
+ showMute: {
160
+ type: BooleanConstructor;
161
+ default: boolean;
162
+ };
163
+ disabled: {
164
+ type: BooleanConstructor;
165
+ default: boolean;
166
+ };
167
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
168
+ [key: string]: any;
169
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
170
+ error: (_error: CallEmbedError) => true;
171
+ }, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
172
+ /** Queue to ring. Falls back to `CallEmbedProvider` `queue`. */
173
+ queue: {
174
+ type: StringConstructor;
175
+ default: undefined;
176
+ };
177
+ /** Idle-state label; defaults to locale `launchDefault`. */
178
+ label: {
179
+ type: StringConstructor;
180
+ default: undefined;
181
+ };
182
+ /** Optional metadata forwarded to `startCall`. */
183
+ metadata: {
184
+ type: PropType<Record<string, unknown>>;
185
+ default: undefined;
186
+ };
187
+ /** Optional caller display name. */
188
+ displayName: {
189
+ type: StringConstructor;
190
+ default: undefined;
191
+ };
192
+ /** Show a status line under the button. Default: `true`. */
193
+ showStatus: {
194
+ type: BooleanConstructor;
195
+ default: boolean;
196
+ };
197
+ /** Show mute control while ringing/connected. Default: `true`. */
198
+ showMute: {
199
+ type: BooleanConstructor;
200
+ default: boolean;
201
+ };
202
+ disabled: {
203
+ type: BooleanConstructor;
204
+ default: boolean;
205
+ };
206
+ }>> & Readonly<{
207
+ onError?: ((_error: CallEmbedError) => any) | undefined;
208
+ }>, {
209
+ queue: string;
210
+ metadata: Record<string, unknown>;
211
+ displayName: string;
212
+ label: string;
213
+ showStatus: boolean;
214
+ showMute: boolean;
215
+ disabled: boolean;
216
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
217
+ type CallEmbedButtonProps = {
218
+ queue?: string;
219
+ label?: string;
220
+ metadata?: Record<string, unknown>;
221
+ displayName?: string;
222
+ showStatus?: boolean;
223
+ showMute?: boolean;
224
+ disabled?: boolean;
225
+ };
226
+
227
+ interface CallEmbedPluginOptions {
228
+ /** Register components under these names (defaults shown). */
229
+ providerName?: string;
230
+ buttonName?: string;
231
+ }
232
+ /**
233
+ * Vue plugin: registers `<CallEmbedProvider>` and `<CallEmbedButton>` globally.
234
+ * Prefer local imports in tree-shaken apps; use the plugin for Nuxt plugins / quick demos.
235
+ */
236
+ declare const CallEmbedPlugin: Plugin<CallEmbedPluginOptions>;
237
+
238
+ /** Status line for the Vue button / composable consumers. */
239
+ declare function statusLabel(copy: PanelCopy, uiState: CallEmbedUiState, sdkStatus: string): string;
240
+
241
+ export { CALL_EMBED_KEY, CallEmbedButton, type CallEmbedButtonProps, type CallEmbedContextValue, type CallEmbedErrorState, CallEmbedPlugin, type CallEmbedPluginOptions, CallEmbedProvider, type CallEmbedProviderProps, type CallEmbedUiState, statusLabel, toUiState, useCallEmbed };
@@ -0,0 +1,241 @@
1
+ import * as vue from 'vue';
2
+ import { PropType, SlotsType, Plugin } from 'vue';
3
+ import { CallStatus, Locale, StartCallOptions, ActiveCall, InitOptions, CallEmbedError } from '@callembed/sdk';
4
+ export { ActiveCall, CallStatus, InitOptions, Locale, StartCallOptions } from '@callembed/sdk';
5
+ import { PanelCopy } from '@callembed/sdk/ui';
6
+ export { PanelCopy, enCopy, friendlyErrorMessage, resolveCopy, zhTwCopy } from '@callembed/sdk/ui';
7
+
8
+ /**
9
+ * Simplified UI lifecycle for `<CallEmbedButton />`.
10
+ * Maps onto SDK {@link CallStatus}:
11
+ * - `connecting` | `ringing` → `ringing`
12
+ * - `answered` → `connected`
13
+ */
14
+ type CallEmbedUiState = "idle" | "ringing" | "connected" | "ended" | "error";
15
+ declare function toUiState(status: CallStatus | "idle"): CallEmbedUiState;
16
+ interface CallEmbedErrorState {
17
+ code: string;
18
+ message: string;
19
+ }
20
+ interface CallEmbedContextValue {
21
+ /** SDK call status (includes `connecting` / `answered`). */
22
+ status: CallStatus | "idle";
23
+ /** Button-oriented status (`answered` → `connected`). */
24
+ uiState: CallEmbedUiState;
25
+ callId: string | null;
26
+ muted: boolean;
27
+ error: CallEmbedErrorState | null;
28
+ locale: Locale;
29
+ /** Start a queue call (customer-service ring → agent answers). */
30
+ start: (options?: Partial<StartCallOptions> & {
31
+ queue?: string;
32
+ }) => Promise<ActiveCall>;
33
+ /** Hang up the active call (idempotent). */
34
+ end: () => Promise<void>;
35
+ setMuted: (muted: boolean) => Promise<void>;
36
+ /** Default queue from the provider when button/composable omit `queue`. */
37
+ defaultQueue: string | undefined;
38
+ }
39
+ type CallEmbedProviderProps = InitOptions & {
40
+ /**
41
+ * Default queue name for `<CallEmbedButton />` / `useCallEmbed().start()`
42
+ * when callers omit `queue`.
43
+ */
44
+ queue?: string;
45
+ };
46
+ declare const CALL_EMBED_KEY: unique symbol;
47
+
48
+ /**
49
+ * Initializes `@callembed/sdk` once for the subtree and exposes call state.
50
+ * Safe for Nuxt / Vue SSR: no `window` access at module evaluate time;
51
+ * `CallEmbed.init` runs in a client-only watcher (skipped when `window` is undefined).
52
+ *
53
+ * Unmount or `publishableKey` / `apiBaseUrl` change hangs up any active call
54
+ * so an SPA route change cannot leave a billed call running.
55
+ */
56
+ declare const CallEmbedProvider: vue.DefineComponent<vue.ExtractPropTypes<{
57
+ publishableKey: {
58
+ type: StringConstructor;
59
+ required: true;
60
+ };
61
+ apiBaseUrl: {
62
+ type: StringConstructor;
63
+ required: true;
64
+ };
65
+ locale: {
66
+ type: PropType<Locale>;
67
+ default: undefined;
68
+ };
69
+ copy: {
70
+ type: PropType<Partial<Record<string, string>>>;
71
+ default: undefined;
72
+ };
73
+ branding: {
74
+ type: BooleanConstructor;
75
+ default: undefined;
76
+ };
77
+ debug: {
78
+ type: BooleanConstructor;
79
+ default: undefined;
80
+ };
81
+ queue: {
82
+ type: StringConstructor;
83
+ default: undefined;
84
+ };
85
+ }>, () => unknown, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
86
+ publishableKey: {
87
+ type: StringConstructor;
88
+ required: true;
89
+ };
90
+ apiBaseUrl: {
91
+ type: StringConstructor;
92
+ required: true;
93
+ };
94
+ locale: {
95
+ type: PropType<Locale>;
96
+ default: undefined;
97
+ };
98
+ copy: {
99
+ type: PropType<Partial<Record<string, string>>>;
100
+ default: undefined;
101
+ };
102
+ branding: {
103
+ type: BooleanConstructor;
104
+ default: undefined;
105
+ };
106
+ debug: {
107
+ type: BooleanConstructor;
108
+ default: undefined;
109
+ };
110
+ queue: {
111
+ type: StringConstructor;
112
+ default: undefined;
113
+ };
114
+ }>> & Readonly<{}>, {
115
+ locale: Locale;
116
+ copy: Partial<Record<string, string>>;
117
+ branding: boolean;
118
+ debug: boolean;
119
+ queue: string;
120
+ }, SlotsType<{
121
+ default: () => unknown;
122
+ }>, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
123
+ /**
124
+ * Access CallEmbed state and controls. Must be used under {@link CallEmbedProvider}.
125
+ */
126
+ declare function useCallEmbed(): CallEmbedContextValue;
127
+
128
+ /**
129
+ * Start / end call button for a customer-service queue.
130
+ * States: `idle` → `ringing` → `connected` → `ended` | `error`.
131
+ */
132
+ declare const CallEmbedButton: vue.DefineComponent<vue.ExtractPropTypes<{
133
+ /** Queue to ring. Falls back to `CallEmbedProvider` `queue`. */
134
+ queue: {
135
+ type: StringConstructor;
136
+ default: undefined;
137
+ };
138
+ /** Idle-state label; defaults to locale `launchDefault`. */
139
+ label: {
140
+ type: StringConstructor;
141
+ default: undefined;
142
+ };
143
+ /** Optional metadata forwarded to `startCall`. */
144
+ metadata: {
145
+ type: PropType<Record<string, unknown>>;
146
+ default: undefined;
147
+ };
148
+ /** Optional caller display name. */
149
+ displayName: {
150
+ type: StringConstructor;
151
+ default: undefined;
152
+ };
153
+ /** Show a status line under the button. Default: `true`. */
154
+ showStatus: {
155
+ type: BooleanConstructor;
156
+ default: boolean;
157
+ };
158
+ /** Show mute control while ringing/connected. Default: `true`. */
159
+ showMute: {
160
+ type: BooleanConstructor;
161
+ default: boolean;
162
+ };
163
+ disabled: {
164
+ type: BooleanConstructor;
165
+ default: boolean;
166
+ };
167
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
168
+ [key: string]: any;
169
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
170
+ error: (_error: CallEmbedError) => true;
171
+ }, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
172
+ /** Queue to ring. Falls back to `CallEmbedProvider` `queue`. */
173
+ queue: {
174
+ type: StringConstructor;
175
+ default: undefined;
176
+ };
177
+ /** Idle-state label; defaults to locale `launchDefault`. */
178
+ label: {
179
+ type: StringConstructor;
180
+ default: undefined;
181
+ };
182
+ /** Optional metadata forwarded to `startCall`. */
183
+ metadata: {
184
+ type: PropType<Record<string, unknown>>;
185
+ default: undefined;
186
+ };
187
+ /** Optional caller display name. */
188
+ displayName: {
189
+ type: StringConstructor;
190
+ default: undefined;
191
+ };
192
+ /** Show a status line under the button. Default: `true`. */
193
+ showStatus: {
194
+ type: BooleanConstructor;
195
+ default: boolean;
196
+ };
197
+ /** Show mute control while ringing/connected. Default: `true`. */
198
+ showMute: {
199
+ type: BooleanConstructor;
200
+ default: boolean;
201
+ };
202
+ disabled: {
203
+ type: BooleanConstructor;
204
+ default: boolean;
205
+ };
206
+ }>> & Readonly<{
207
+ onError?: ((_error: CallEmbedError) => any) | undefined;
208
+ }>, {
209
+ queue: string;
210
+ metadata: Record<string, unknown>;
211
+ displayName: string;
212
+ label: string;
213
+ showStatus: boolean;
214
+ showMute: boolean;
215
+ disabled: boolean;
216
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
217
+ type CallEmbedButtonProps = {
218
+ queue?: string;
219
+ label?: string;
220
+ metadata?: Record<string, unknown>;
221
+ displayName?: string;
222
+ showStatus?: boolean;
223
+ showMute?: boolean;
224
+ disabled?: boolean;
225
+ };
226
+
227
+ interface CallEmbedPluginOptions {
228
+ /** Register components under these names (defaults shown). */
229
+ providerName?: string;
230
+ buttonName?: string;
231
+ }
232
+ /**
233
+ * Vue plugin: registers `<CallEmbedProvider>` and `<CallEmbedButton>` globally.
234
+ * Prefer local imports in tree-shaken apps; use the plugin for Nuxt plugins / quick demos.
235
+ */
236
+ declare const CallEmbedPlugin: Plugin<CallEmbedPluginOptions>;
237
+
238
+ /** Status line for the Vue button / composable consumers. */
239
+ declare function statusLabel(copy: PanelCopy, uiState: CallEmbedUiState, sdkStatus: string): string;
240
+
241
+ export { CALL_EMBED_KEY, CallEmbedButton, type CallEmbedButtonProps, type CallEmbedContextValue, type CallEmbedErrorState, CallEmbedPlugin, type CallEmbedPluginOptions, CallEmbedProvider, type CallEmbedProviderProps, type CallEmbedUiState, statusLabel, toUiState, useCallEmbed };