@signalwire/web-components 4.0.0-beta.2 → 4.0.0-beta.4
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/README.md +3 -1
- package/dist/components/audio-level.d.ts +106 -0
- package/dist/components/audio-level.d.ts.map +1 -0
- package/dist/components/audio-level.js +203 -0
- package/dist/components/audio-level.js.map +1 -0
- package/dist/components/call-controls.d.ts +163 -0
- package/dist/components/call-controls.d.ts.map +1 -0
- package/dist/components/call-controls.js +606 -0
- package/dist/components/call-controls.js.map +1 -0
- package/dist/components/call-media.d.ts +114 -0
- package/dist/components/call-media.d.ts.map +1 -0
- package/dist/components/call-media.js +215 -0
- package/dist/components/call-media.js.map +1 -0
- package/dist/components/call-status.d.ts +71 -0
- package/dist/components/call-status.d.ts.map +1 -0
- package/dist/components/call-status.js +251 -0
- package/dist/components/call-status.js.map +1 -0
- package/dist/components/click-to-call.d.ts +123 -0
- package/dist/components/click-to-call.d.ts.map +1 -0
- package/dist/components/click-to-call.js +428 -0
- package/dist/components/click-to-call.js.map +1 -0
- package/dist/components/device-selector.d.ts +250 -0
- package/dist/components/device-selector.d.ts.map +1 -0
- package/dist/components/device-selector.js +685 -0
- package/dist/components/device-selector.js.map +1 -0
- package/dist/components/dialpad.d.ts +60 -0
- package/dist/components/dialpad.d.ts.map +1 -0
- package/dist/components/dialpad.js +372 -0
- package/dist/components/dialpad.js.map +1 -0
- package/dist/components/directory.d.ts +103 -0
- package/dist/components/directory.d.ts.map +1 -0
- package/dist/components/directory.js +503 -0
- package/dist/components/directory.js.map +1 -0
- package/dist/components/example-button.d.ts +20 -0
- package/dist/components/example-button.d.ts.map +1 -0
- package/dist/components/example-button.js +74 -0
- package/dist/components/example-button.js.map +1 -0
- package/dist/components/participant-controls.d.ts +94 -0
- package/dist/components/participant-controls.d.ts.map +1 -0
- package/dist/components/participant-controls.js +468 -0
- package/dist/components/participant-controls.js.map +1 -0
- package/dist/components/participants.d.ts +116 -0
- package/dist/components/participants.d.ts.map +1 -0
- package/dist/components/participants.js +394 -0
- package/dist/components/participants.js.map +1 -0
- package/dist/components/self-media.d.ts +78 -0
- package/dist/components/self-media.d.ts.map +1 -0
- package/dist/components/self-media.js +128 -0
- package/dist/components/self-media.js.map +1 -0
- package/dist/context/call-context.d.ts +13 -0
- package/dist/context/call-context.d.ts.map +1 -0
- package/dist/context/call-context.js +6 -0
- package/dist/context/call-context.js.map +1 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -5645
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +101 -0
- package/dist/types/index.d.ts +67 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/debounce.d.ts +10 -0
- package/dist/utils/debounce.d.ts.map +1 -0
- package/dist/utils/debounce.js +13 -0
- package/dist/utils/debounce.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/video.d.ts +34 -0
- package/dist/utils/video.d.ts.map +1 -0
- package/dist/utils/video.js +26 -0
- package/dist/utils/video.js.map +1 -0
- package/package.json +70 -3
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React JSX type declarations for SignalWire web components.
|
|
3
|
+
*
|
|
4
|
+
* Provides proper element types so `useRef<CallMedia>()` gives access
|
|
5
|
+
* to component properties like `.call` without type casting.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* /// <reference types="@signalwire/web-components/react" />
|
|
9
|
+
*
|
|
10
|
+
* Or add to tsconfig.json:
|
|
11
|
+
* { "compilerOptions": { "types": ["@signalwire/web-components/react"] } }
|
|
12
|
+
*
|
|
13
|
+
* Then in your component:
|
|
14
|
+
* import type { CallMedia } from '@signalwire/web-components';
|
|
15
|
+
* const ref = useRef<CallMedia>(null);
|
|
16
|
+
* ref.current.call = call; // fully typed, no cast needed
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { CallMedia } from './components/call-media.js';
|
|
20
|
+
import type { SelfMedia } from './components/self-media.js';
|
|
21
|
+
import type { CallControls } from './components/call-controls.js';
|
|
22
|
+
import type { CallStatusComponent } from './components/call-status.js';
|
|
23
|
+
import type { DeviceSelector } from './components/device-selector.js';
|
|
24
|
+
import type { AudioLevel } from './components/audio-level.js';
|
|
25
|
+
import type { DialpadComponent } from './components/dialpad.js';
|
|
26
|
+
import type { ClickToCallComponent } from './components/click-to-call.js';
|
|
27
|
+
import type { DirectoryComponent } from './components/directory.js';
|
|
28
|
+
import type { ParticipantControlsComponent } from './components/participant-controls.js';
|
|
29
|
+
import type { Participants } from './components/participants.js';
|
|
30
|
+
|
|
31
|
+
export {};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Helper: maps a Lit element class to a React JSX props type.
|
|
35
|
+
* Uses the actual element class for ref typing.
|
|
36
|
+
*/
|
|
37
|
+
type SWProps<E extends HTMLElement, A = object> = React.DetailedHTMLProps<
|
|
38
|
+
React.HTMLAttributes<E> & A,
|
|
39
|
+
E
|
|
40
|
+
>;
|
|
41
|
+
|
|
42
|
+
declare module 'react' {
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
44
|
+
namespace JSX {
|
|
45
|
+
interface IntrinsicElements {
|
|
46
|
+
/** Remote video container and call context provider. */
|
|
47
|
+
'sw-call-media': SWProps<CallMedia>;
|
|
48
|
+
|
|
49
|
+
/** Local video overlay with optional mirror mode. */
|
|
50
|
+
'sw-self-media': SWProps<SelfMedia, {
|
|
51
|
+
mirror?: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
|
|
54
|
+
/** Mute, hangup, and screen-share controls. */
|
|
55
|
+
'sw-call-controls': SWProps<CallControls, {
|
|
56
|
+
orientation?: 'horizontal' | 'vertical';
|
|
57
|
+
'show-tooltips'?: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
|
|
60
|
+
/** Call status display with duration timer. */
|
|
61
|
+
'sw-call-status': SWProps<CallStatusComponent>;
|
|
62
|
+
|
|
63
|
+
/** Media device dropdowns with optional preview. */
|
|
64
|
+
'sw-device-selector': SWProps<DeviceSelector, {
|
|
65
|
+
'show-preview'?: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
|
|
68
|
+
/** Real-time audio level visualizer. */
|
|
69
|
+
'sw-audio-level': SWProps<AudioLevel, {
|
|
70
|
+
bars?: number;
|
|
71
|
+
orientation?: 'vertical' | 'horizontal';
|
|
72
|
+
'max-size'?: number;
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
/** DTMF dialpad. */
|
|
76
|
+
'sw-dialpad': SWProps<DialpadComponent, {
|
|
77
|
+
'show-call-button'?: boolean;
|
|
78
|
+
placeholder?: string;
|
|
79
|
+
}>;
|
|
80
|
+
|
|
81
|
+
/** Single-button call widget. */
|
|
82
|
+
'sw-click-to-call': SWProps<ClickToCallComponent, {
|
|
83
|
+
destination?: string;
|
|
84
|
+
label?: string;
|
|
85
|
+
'audio-only'?: boolean;
|
|
86
|
+
}>;
|
|
87
|
+
|
|
88
|
+
/** Searchable contact directory. */
|
|
89
|
+
'sw-directory': SWProps<DirectoryComponent>;
|
|
90
|
+
|
|
91
|
+
/** Per-participant mute, volume, and remove controls. */
|
|
92
|
+
'sw-participant-controls': SWProps<ParticipantControlsComponent, {
|
|
93
|
+
'show-volume'?: boolean;
|
|
94
|
+
'show-pin'?: boolean;
|
|
95
|
+
}>;
|
|
96
|
+
|
|
97
|
+
/** Remote participant overlay list. */
|
|
98
|
+
'sw-participants': SWProps<Participants>;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for call-media components.
|
|
3
|
+
*
|
|
4
|
+
* Call and LayoutLayer types are imported from the SDK.
|
|
5
|
+
* Other types are defined locally for web-component specific needs.
|
|
6
|
+
*/
|
|
7
|
+
import type { Observable } from 'rxjs';
|
|
8
|
+
import type { Call, LayoutLayer } from '@signalwire/js';
|
|
9
|
+
export type { Call, LayoutLayer };
|
|
10
|
+
/**
|
|
11
|
+
* Type helper for accessing call.self with proper typing
|
|
12
|
+
* The SDK's Call.self is typed as unknown for flexibility
|
|
13
|
+
*/
|
|
14
|
+
export interface CallSelf {
|
|
15
|
+
id: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Helper to safely get self ID from a Call
|
|
19
|
+
*/
|
|
20
|
+
export declare function getSelfId(call: Call | undefined): string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Helper to cast participants from unknown[] to Participant[]
|
|
23
|
+
* The SDK uses unknown[] for flexibility, but web-components knows the shape
|
|
24
|
+
*/
|
|
25
|
+
export declare function castParticipants(participants: unknown[]): Participant[];
|
|
26
|
+
/**
|
|
27
|
+
* Participant interface for call participants
|
|
28
|
+
* Web-component specific with optional methods
|
|
29
|
+
*/
|
|
30
|
+
export interface Participant {
|
|
31
|
+
id: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
name$?: Observable<string>;
|
|
34
|
+
audioMuted?: boolean;
|
|
35
|
+
audioMuted$?: Observable<boolean>;
|
|
36
|
+
videoMuted?: boolean;
|
|
37
|
+
videoMuted$?: Observable<boolean>;
|
|
38
|
+
mute?(): Promise<void>;
|
|
39
|
+
unmute?(): Promise<void>;
|
|
40
|
+
muteVideo?(): Promise<void>;
|
|
41
|
+
unmuteVideo?(): Promise<void>;
|
|
42
|
+
remove?(): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Device info interface matching MediaDeviceInfo structure
|
|
46
|
+
*/
|
|
47
|
+
export interface DeviceInfo {
|
|
48
|
+
deviceId: string;
|
|
49
|
+
label: string;
|
|
50
|
+
kind: 'audioinput' | 'audiooutput' | 'videoinput';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* DeviceController interface for observing device lists
|
|
54
|
+
*/
|
|
55
|
+
export interface DeviceController {
|
|
56
|
+
audioInputDevices$: Observable<DeviceInfo[]>;
|
|
57
|
+
videoInputDevices$: Observable<DeviceInfo[]>;
|
|
58
|
+
audioOutputDevices$: Observable<DeviceInfo[]>;
|
|
59
|
+
selectedAudioInputDevice$?: Observable<DeviceInfo | null>;
|
|
60
|
+
selectedVideoInputDevice$?: Observable<DeviceInfo | null>;
|
|
61
|
+
selectedAudioOutputDevice$?: Observable<DeviceInfo | null>;
|
|
62
|
+
selectAudioInputDevice?: (device: DeviceInfo) => void;
|
|
63
|
+
selectVideoInputDevice?: (device: DeviceInfo) => void;
|
|
64
|
+
selectAudioOutputDevice?: (device: DeviceInfo) => void;
|
|
65
|
+
getLocalStream?: () => Promise<MediaStream>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGxD,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;AAElC;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,CAEvE;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,SAAS,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,GAAG,aAAa,GAAG,YAAY,CAAC;CACnD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC;IAC7C,kBAAkB,EAAE,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC;IAC7C,mBAAmB,EAAE,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC;IAC9C,yBAAyB,CAAC,EAAE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC1D,yBAAyB,CAAC,EAAE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC1D,0BAA0B,CAAC,EAAE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC3D,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACtD,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACtD,uBAAuB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACvD,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/types/index.ts"],"sourcesContent":["/**\n * Type definitions for call-media components.\n *\n * Call and LayoutLayer types are imported from the SDK.\n * Other types are defined locally for web-component specific needs.\n */\n\nimport type { Observable } from 'rxjs';\nimport type { Call, LayoutLayer } from '@signalwire/js';\n\n// Re-export SDK types for internal use\nexport type { Call, LayoutLayer };\n\n/**\n * Type helper for accessing call.self with proper typing\n * The SDK's Call.self is typed as unknown for flexibility\n */\nexport interface CallSelf {\n id: string;\n}\n\n/**\n * Helper to safely get self ID from a Call\n */\nexport function getSelfId(call: Call | undefined): string | undefined {\n const self = call?.self as CallSelf | undefined;\n return self?.id;\n}\n\n/**\n * Helper to cast participants from unknown[] to Participant[]\n * The SDK uses unknown[] for flexibility, but web-components knows the shape\n */\nexport function castParticipants(participants: unknown[]): Participant[] {\n return participants as Participant[];\n}\n\n/**\n * Participant interface for call participants\n * Web-component specific with optional methods\n */\nexport interface Participant {\n id: string;\n name?: string;\n name$?: Observable<string>;\n audioMuted?: boolean;\n audioMuted$?: Observable<boolean>;\n videoMuted?: boolean;\n videoMuted$?: Observable<boolean>;\n mute?(): Promise<void>;\n unmute?(): Promise<void>;\n muteVideo?(): Promise<void>;\n unmuteVideo?(): Promise<void>;\n remove?(): Promise<void>;\n}\n\n/**\n * Device info interface matching MediaDeviceInfo structure\n */\nexport interface DeviceInfo {\n deviceId: string;\n label: string;\n kind: 'audioinput' | 'audiooutput' | 'videoinput';\n}\n\n/**\n * DeviceController interface for observing device lists\n */\nexport interface DeviceController {\n audioInputDevices$: Observable<DeviceInfo[]>;\n videoInputDevices$: Observable<DeviceInfo[]>;\n audioOutputDevices$: Observable<DeviceInfo[]>;\n selectedAudioInputDevice$?: Observable<DeviceInfo | null>;\n selectedVideoInputDevice$?: Observable<DeviceInfo | null>;\n selectedAudioOutputDevice$?: Observable<DeviceInfo | null>;\n selectAudioInputDevice?: (device: DeviceInfo) => void;\n selectVideoInputDevice?: (device: DeviceInfo) => void;\n selectAudioOutputDevice?: (device: DeviceInfo) => void;\n getLocalStream?: () => Promise<MediaStream>;\n}\n"],"names":["getSelfId","call","self","castParticipants","participants"],"mappings":"AAwBO,SAASA,EAAUC,GAA4C;AACpE,QAAMC,IAAOD,KAAA,gBAAAA,EAAM;AACnB,SAAOC,KAAA,gBAAAA,EAAM;AACf;AAMO,SAASC,EAAiBC,GAAwC;AACvE,SAAOA;AACT;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced function that delays invoking the provided function
|
|
3
|
+
* until after the specified wait time has elapsed since the last invocation.
|
|
4
|
+
*
|
|
5
|
+
* @param func - The function to debounce
|
|
6
|
+
* @param wait - The number of milliseconds to delay
|
|
7
|
+
* @returns A debounced version of the function
|
|
8
|
+
*/
|
|
9
|
+
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
10
|
+
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/utils/debounce.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAclC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","sources":["../../src/utils/debounce.ts"],"sourcesContent":["/**\n * Creates a debounced function that delays invoking the provided function\n * until after the specified wait time has elapsed since the last invocation.\n *\n * @param func - The function to debounce\n * @param wait - The number of milliseconds to delay\n * @returns A debounced version of the function\n */\nexport function debounce<T extends (...args: any[]) => any>(\n func: T,\n wait: number\n): (...args: Parameters<T>) => void {\n let timeout: ReturnType<typeof setTimeout> | null = null;\n\n return function executedFunction(...args: Parameters<T>) {\n const later = () => {\n timeout = null;\n func(...args);\n };\n\n if (timeout !== null) {\n clearTimeout(timeout);\n }\n timeout = setTimeout(later, wait);\n };\n}\n"],"names":["debounce","func","wait","timeout","args","later"],"mappings":"AAQO,SAASA,EACdC,GACAC,GACkC;AAClC,MAAIC,IAAgD;AAEpD,SAAO,YAA6BC,GAAqB;AACvD,UAAMC,IAAQ,MAAM;AAClB,MAAAF,IAAU,MACVF,EAAK,GAAGG,CAAI;AAAA,IACd;AAEA,IAAID,MAAY,QACd,aAAaA,CAAO,GAEtBA,IAAU,WAAWE,GAAOH,CAAI;AAAA,EAClC;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video element utilities for creating and managing video elements
|
|
3
|
+
* with proper configuration for WebRTC streams.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Creates a video element configured for WebRTC streams.
|
|
7
|
+
* The video is muted, autoplays, and plays inline (mobile Safari support).
|
|
8
|
+
* Prevents pause events which can occur on camera switches or PiP mode.
|
|
9
|
+
*
|
|
10
|
+
* @returns A configured HTMLVideoElement
|
|
11
|
+
*/
|
|
12
|
+
export declare function createVideoElement(): HTMLVideoElement;
|
|
13
|
+
/**
|
|
14
|
+
* Waits for a video element to be ready for playback.
|
|
15
|
+
* Resolves when the video has metadata or when it can play.
|
|
16
|
+
*
|
|
17
|
+
* @param element - The video element to wait for
|
|
18
|
+
* @returns A promise that resolves when the video is ready
|
|
19
|
+
*/
|
|
20
|
+
export declare function waitForVideoReady(element: HTMLVideoElement): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Attaches a MediaStream to a video element.
|
|
23
|
+
*
|
|
24
|
+
* @param element - The video element to attach the stream to
|
|
25
|
+
* @param stream - The MediaStream to attach, or null to detach
|
|
26
|
+
*/
|
|
27
|
+
export declare function attachMediaStream(element: HTMLVideoElement, stream: MediaStream | null): void;
|
|
28
|
+
/**
|
|
29
|
+
* Detaches any MediaStream from a video element.
|
|
30
|
+
*
|
|
31
|
+
* @param element - The video element to detach the stream from
|
|
32
|
+
*/
|
|
33
|
+
export declare function detachMediaStream(element: HTMLVideoElement): void;
|
|
34
|
+
//# sourceMappingURL=video.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../src/utils/video.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,gBAAgB,CAcrD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB1E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAE7F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAIjE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function a(e) {
|
|
2
|
+
return new Promise((t) => {
|
|
3
|
+
if (e.readyState >= HTMLMediaElement.HAVE_METADATA) {
|
|
4
|
+
t();
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const n = () => {
|
|
8
|
+
e.removeEventListener("canplay", n), e.removeEventListener("resize", r), t();
|
|
9
|
+
}, r = () => {
|
|
10
|
+
e.removeEventListener("canplay", n), e.removeEventListener("resize", r), t();
|
|
11
|
+
};
|
|
12
|
+
e.addEventListener("canplay", n), e.addEventListener("resize", r);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function i(e, t) {
|
|
16
|
+
e.srcObject = t;
|
|
17
|
+
}
|
|
18
|
+
function c(e) {
|
|
19
|
+
e.srcObject && (e.srcObject = null);
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
i as attachMediaStream,
|
|
23
|
+
c as detachMediaStream,
|
|
24
|
+
a as waitForVideoReady
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.js","sources":["../../src/utils/video.ts"],"sourcesContent":["/**\n * Video element utilities for creating and managing video elements\n * with proper configuration for WebRTC streams.\n */\n\n/**\n * Creates a video element configured for WebRTC streams.\n * The video is muted, autoplays, and plays inline (mobile Safari support).\n * Prevents pause events which can occur on camera switches or PiP mode.\n *\n * @returns A configured HTMLVideoElement\n */\nexport function createVideoElement(): HTMLVideoElement {\n const video = document.createElement('video');\n video.muted = true;\n video.autoplay = true;\n video.playsInline = true;\n\n // Prevent pause (Safari/Firefox pause on PiP, camera switch)\n video.addEventListener('pause', () => {\n video.play().catch((error) => {\n console.error('Video Element Paused', error);\n });\n });\n\n return video;\n}\n\n/**\n * Waits for a video element to be ready for playback.\n * Resolves when the video has metadata or when it can play.\n *\n * @param element - The video element to wait for\n * @returns A promise that resolves when the video is ready\n */\nexport function waitForVideoReady(element: HTMLVideoElement): Promise<void> {\n return new Promise<void>((resolve) => {\n if (element.readyState >= HTMLMediaElement.HAVE_METADATA) {\n resolve();\n return;\n }\n\n const onCanPlay = () => {\n element.removeEventListener('canplay', onCanPlay);\n element.removeEventListener('resize', onResize);\n resolve();\n };\n\n const onResize = () => {\n element.removeEventListener('canplay', onCanPlay);\n element.removeEventListener('resize', onResize);\n resolve();\n };\n\n element.addEventListener('canplay', onCanPlay);\n element.addEventListener('resize', onResize);\n });\n}\n\n/**\n * Attaches a MediaStream to a video element.\n *\n * @param element - The video element to attach the stream to\n * @param stream - The MediaStream to attach, or null to detach\n */\nexport function attachMediaStream(element: HTMLVideoElement, stream: MediaStream | null): void {\n element.srcObject = stream;\n}\n\n/**\n * Detaches any MediaStream from a video element.\n *\n * @param element - The video element to detach the stream from\n */\nexport function detachMediaStream(element: HTMLVideoElement): void {\n if (element.srcObject) {\n element.srcObject = null;\n }\n}\n"],"names":["waitForVideoReady","element","resolve","onCanPlay","onResize","attachMediaStream","stream","detachMediaStream"],"mappings":"AAmCO,SAASA,EAAkBC,GAA0C;AAC1E,SAAO,IAAI,QAAc,CAACC,MAAY;AACpC,QAAID,EAAQ,cAAc,iBAAiB,eAAe;AACxD,MAAAC,EAAA;AACA;AAAA,IACF;AAEA,UAAMC,IAAY,MAAM;AACtB,MAAAF,EAAQ,oBAAoB,WAAWE,CAAS,GAChDF,EAAQ,oBAAoB,UAAUG,CAAQ,GAC9CF,EAAA;AAAA,IACF,GAEME,IAAW,MAAM;AACrB,MAAAH,EAAQ,oBAAoB,WAAWE,CAAS,GAChDF,EAAQ,oBAAoB,UAAUG,CAAQ,GAC9CF,EAAA;AAAA,IACF;AAEA,IAAAD,EAAQ,iBAAiB,WAAWE,CAAS,GAC7CF,EAAQ,iBAAiB,UAAUG,CAAQ;AAAA,EAC7C,CAAC;AACH;AAQO,SAASC,EAAkBJ,GAA2BK,GAAkC;AAC7F,EAAAL,EAAQ,YAAYK;AACtB;AAOO,SAASC,EAAkBN,GAAiC;AACjE,EAAIA,EAAQ,cACVA,EAAQ,YAAY;AAExB;"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signalwire/web-components",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.4",
|
|
4
4
|
"description": "UI components library built with Lit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/index.js",
|
|
11
|
+
"./dist/components/*.js"
|
|
12
|
+
],
|
|
9
13
|
"exports": {
|
|
10
14
|
".": {
|
|
11
15
|
"types": "./dist/index.d.ts",
|
|
12
16
|
"import": "./dist/index.js",
|
|
13
17
|
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./call-media": {
|
|
20
|
+
"types": "./dist/components/call-media.d.ts",
|
|
21
|
+
"import": "./dist/components/call-media.js"
|
|
22
|
+
},
|
|
23
|
+
"./self-media": {
|
|
24
|
+
"types": "./dist/components/self-media.d.ts",
|
|
25
|
+
"import": "./dist/components/self-media.js"
|
|
26
|
+
},
|
|
27
|
+
"./participants": {
|
|
28
|
+
"types": "./dist/components/participants.d.ts",
|
|
29
|
+
"import": "./dist/components/participants.js"
|
|
30
|
+
},
|
|
31
|
+
"./call-controls": {
|
|
32
|
+
"types": "./dist/components/call-controls.d.ts",
|
|
33
|
+
"import": "./dist/components/call-controls.js"
|
|
34
|
+
},
|
|
35
|
+
"./call-status": {
|
|
36
|
+
"types": "./dist/components/call-status.d.ts",
|
|
37
|
+
"import": "./dist/components/call-status.js"
|
|
38
|
+
},
|
|
39
|
+
"./audio-level": {
|
|
40
|
+
"types": "./dist/components/audio-level.d.ts",
|
|
41
|
+
"import": "./dist/components/audio-level.js"
|
|
42
|
+
},
|
|
43
|
+
"./device-selector": {
|
|
44
|
+
"types": "./dist/components/device-selector.d.ts",
|
|
45
|
+
"import": "./dist/components/device-selector.js"
|
|
46
|
+
},
|
|
47
|
+
"./dialpad": {
|
|
48
|
+
"types": "./dist/components/dialpad.d.ts",
|
|
49
|
+
"import": "./dist/components/dialpad.js"
|
|
50
|
+
},
|
|
51
|
+
"./click-to-call": {
|
|
52
|
+
"types": "./dist/components/click-to-call.d.ts",
|
|
53
|
+
"import": "./dist/components/click-to-call.js"
|
|
54
|
+
},
|
|
55
|
+
"./directory": {
|
|
56
|
+
"types": "./dist/components/directory.d.ts",
|
|
57
|
+
"import": "./dist/components/directory.js"
|
|
58
|
+
},
|
|
59
|
+
"./participant-controls": {
|
|
60
|
+
"types": "./dist/components/participant-controls.d.ts",
|
|
61
|
+
"import": "./dist/components/participant-controls.js"
|
|
62
|
+
},
|
|
63
|
+
"./example-button": {
|
|
64
|
+
"types": "./dist/components/example-button.d.ts",
|
|
65
|
+
"import": "./dist/components/example-button.js"
|
|
66
|
+
},
|
|
67
|
+
"./context": {
|
|
68
|
+
"types": "./dist/context/index.d.ts",
|
|
69
|
+
"import": "./dist/context/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./types": {
|
|
72
|
+
"types": "./dist/types/index.d.ts",
|
|
73
|
+
"import": "./dist/types/index.js"
|
|
74
|
+
},
|
|
75
|
+
"./utils": {
|
|
76
|
+
"types": "./dist/utils/index.d.ts",
|
|
77
|
+
"import": "./dist/utils/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./react": {
|
|
80
|
+
"types": "./dist/react.d.ts"
|
|
14
81
|
}
|
|
15
82
|
},
|
|
16
83
|
"files": [
|
|
@@ -19,7 +86,7 @@
|
|
|
19
86
|
"scripts": {
|
|
20
87
|
"dev": "vite",
|
|
21
88
|
"dev:test": "vite --port 3000",
|
|
22
|
-
"build": "tsc --project tsconfig.build.json &&
|
|
89
|
+
"build": "vite build && tsc --project tsconfig.build.json && cp src/react.d.ts dist/",
|
|
23
90
|
"preview": "vite preview",
|
|
24
91
|
"type-check": "tsc --noEmit",
|
|
25
92
|
"lint": "eslint src --ext .ts",
|
|
@@ -48,7 +115,7 @@
|
|
|
48
115
|
"rxjs": "^7.8.2"
|
|
49
116
|
},
|
|
50
117
|
"peerDependencies": {
|
|
51
|
-
"@signalwire/js": "4.0.0-beta.
|
|
118
|
+
"@signalwire/js": "4.0.0-beta.4"
|
|
52
119
|
},
|
|
53
120
|
"devDependencies": {
|
|
54
121
|
"@playwright/test": "^1.56.1",
|