hanc-webrtc-widgets 2.8.2 → 2.8.3

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,15 @@
1
+ import { ApiError, Manifest, StatusResponse, SubmitResponse } from './types';
2
+ export declare class CallbackApiError extends Error {
3
+ readonly status: number;
4
+ readonly body: ApiError;
5
+ constructor(status: number, body: ApiError);
6
+ }
7
+ export declare function fetchManifest(agentId: string, apiBaseUrl?: string): Promise<Manifest>;
8
+ export declare function submitCallback(agentId: string, phone: string, country: string, apiBaseUrl?: string, pageUrl?: string): Promise<SubmitResponse>;
9
+ export declare function fetchStatus(requestId: string, apiBaseUrl?: string, signal?: AbortSignal): Promise<StatusResponse>;
10
+ export declare function cancelCallback(requestId: string, apiBaseUrl?: string): Promise<void>;
11
+ /**
12
+ * Best-effort cancel using navigator.sendBeacon — used on `beforeunload`.
13
+ * Returns true if the beacon was queued by the browser.
14
+ */
15
+ export declare function cancelCallbackBeacon(requestId: string, apiBaseUrl?: string): boolean;
@@ -0,0 +1,68 @@
1
+ import { LitElement, nothing } from 'lit';
2
+ import { Manifest } from './types';
3
+ export declare class HancAiCallback extends LitElement {
4
+ agentId: string;
5
+ apiBaseUrl: string;
6
+ /**
7
+ * Skip the manifest fetch and use `manifestOverride` instead. Used in the
8
+ * dashboard preview where we want to render the widget with a synthetic
9
+ * config without hitting the API.
10
+ */
11
+ skipFetch: boolean;
12
+ manifestOverride: Manifest | null;
13
+ /** Overrides theme name (matches the dashboard color picker). */
14
+ theme: string;
15
+ private view;
16
+ private manifest;
17
+ private selectedCountry;
18
+ private phoneRaw;
19
+ private phoneError;
20
+ private apiError;
21
+ private pickerOpen;
22
+ private pickerSearch;
23
+ private pollAbort;
24
+ private pollTimer;
25
+ private lastFocusedBeforeOpen;
26
+ connectedCallback(): Promise<void>;
27
+ disconnectedCallback(): void;
28
+ protected updated(changed: Map<string, unknown>): void;
29
+ private loadManifest;
30
+ private adoptManifest;
31
+ private detectCountryFromLocale;
32
+ private onDocumentKey;
33
+ private open;
34
+ private close;
35
+ private selectCountry;
36
+ private onPhoneInput;
37
+ private validatePhoneSoft;
38
+ private onSubmit;
39
+ private handleSubmitError;
40
+ private onCancel;
41
+ private startPolling;
42
+ private stopPolling;
43
+ private onPollUpdate;
44
+ render(): import('lit').TemplateResult<1> | typeof nothing;
45
+ private renderFab;
46
+ private handsetIcon;
47
+ private renderCard;
48
+ private renderBody;
49
+ private renderForm;
50
+ private renderCountryPicker;
51
+ private renderQueued;
52
+ private renderDialing;
53
+ private renderCompleted;
54
+ private renderFailed;
55
+ private renderRateLimited;
56
+ private closeIcon;
57
+ private chevronIcon;
58
+ private queueIcon;
59
+ private ringingIcon;
60
+ private checkIcon;
61
+ private alertIcon;
62
+ static styles: import('lit').CSSResult;
63
+ }
64
+ declare global {
65
+ interface HTMLElementTagNameMap {
66
+ 'hanc-ai-callback': HancAiCallback;
67
+ }
68
+ }
@@ -0,0 +1,2 @@
1
+ export * from './callback';
2
+ export type { Manifest, StatusResponse, SubmitResponse } from './types';
@@ -0,0 +1,6 @@
1
+ /** Returns true if another submit is allowed right now. */
2
+ export declare function canSubmit(): boolean;
3
+ /** Record a submit attempt (call after a successful server response). */
4
+ export declare function recordSubmit(): void;
5
+ /** Seconds until the oldest tracked submit falls out of the window. */
6
+ export declare function timeToReset(): number;
@@ -0,0 +1,7 @@
1
+ export declare const THEME_PRIMARY: Record<string, string>;
2
+ export declare function getThemeColor(name?: string): string;
3
+ /**
4
+ * Choose a readable foreground (text/icon) colour for a given primary.
5
+ * Plain luminance threshold — good enough for our 11-colour palette.
6
+ */
7
+ export declare function getContrastingForeground(primary: string): string;
@@ -0,0 +1,76 @@
1
+ export interface ManifestCountry {
2
+ code: string;
3
+ name: string;
4
+ dial_code: string;
5
+ flag: string;
6
+ enabled: boolean;
7
+ }
8
+ export interface ManifestTerms {
9
+ enabled: boolean;
10
+ content: string;
11
+ terms_url?: string;
12
+ privacy_url?: string;
13
+ }
14
+ export interface ManifestRetry {
15
+ max_attempts: number;
16
+ interval_seconds: number;
17
+ }
18
+ export interface Manifest {
19
+ agent_id: string;
20
+ agent_name: string;
21
+ agent_locale: string;
22
+ theme: string;
23
+ allow_all_domains: boolean;
24
+ allowed_domains: string[];
25
+ retry: ManifestRetry;
26
+ allowed_countries: ManifestCountry[];
27
+ terms?: ManifestTerms;
28
+ }
29
+ export type CallbackStatus = 'queued' | 'dialing' | 'completed' | 'failed' | 'cancelled' | 'expired';
30
+ export interface StatusResponse {
31
+ status: CallbackStatus;
32
+ position?: number;
33
+ estimated_wait_seconds?: number;
34
+ attempts?: number;
35
+ max_attempts?: number;
36
+ failure_reason?: string;
37
+ }
38
+ export interface SubmitResponse {
39
+ request_id: string;
40
+ position: number;
41
+ estimated_wait_seconds: number;
42
+ expires_at: string;
43
+ }
44
+ export type ViewState = {
45
+ kind: 'loading';
46
+ } | {
47
+ kind: 'closed';
48
+ } | {
49
+ kind: 'form';
50
+ } | {
51
+ kind: 'submitting';
52
+ } | {
53
+ kind: 'queued';
54
+ request_id: string;
55
+ position: number;
56
+ eta_seconds: number;
57
+ } | {
58
+ kind: 'dialing';
59
+ request_id: string;
60
+ } | {
61
+ kind: 'completed';
62
+ } | {
63
+ kind: 'failed';
64
+ reason: string;
65
+ can_retry: boolean;
66
+ } | {
67
+ kind: 'rate_limited';
68
+ } | {
69
+ kind: 'manifest_error';
70
+ };
71
+ export type ErrorCode = 'rate_limit_phone' | 'queue_full' | 'callback_disabled' | 'invalid_phone' | 'country_not_supported' | 'blocked_prefix' | 'insufficient_credits' | 'no_outbound_number' | 'plan_required' | 'domain_not_allowed' | 'agent_not_found' | 'config_disabled' | 'token_invalid' | 'unknown';
72
+ export interface ApiError {
73
+ error_code: ErrorCode;
74
+ message: string;
75
+ retry_after_seconds?: number;
76
+ }
@@ -2,6 +2,7 @@ export * from './inline-call';
2
2
  export * from './floating-call';
3
3
  export * from './pill-call';
4
4
  export * from './pill-floating-call';
5
+ export * from './callback';
5
6
  export { darkPresets, lightPresets, getColorPreset, getPresetNames } from '../core/orb/colorPresets';
6
7
  export type { OrbColors } from '../core/orb';
7
8
  export { themes, darkThemes, lightThemes, getTheme, getThemeNames, applyTheme } from '../core/orb/themes';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hanc-webrtc-widgets",
3
- "version": "2.8.2",
3
+ "version": "2.8.3",
4
4
  "type": "module",
5
5
  "main": "dist/hanc-webrtc-widgets.umd.js",
6
6
  "module": "dist/hanc-webrtc-widgets.es.js",
@@ -14,6 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@livekit/noise-filter": "^0.1.3",
17
+ "libphonenumber-js": "^1.13.1",
17
18
  "lit": "^3.2.1",
18
19
  "livekit-client": "^2.15.6",
19
20
  "three": "^0.182.0"