@signalwire/realtime-api
Advanced tools
Comparing version 3.0.0-beta.7 to 3.0.0-beta.8
import type { Task } from '@redux-saga/types'; | ||
import { Action } from './redux'; | ||
import { ExecuteParams, BaseComponentOptions, ExecuteExtendedOptions, EventsPrefix, EventTransform, SDKWorker, SDKWorkerDefinition, SessionAuthStatus } from './utils/interfaces'; | ||
import { ExecuteParams, BaseComponentOptions, ExecuteExtendedOptions, EventsPrefix, EventTransform, SDKWorker, SDKWorkerDefinition, SessionAuthStatus, SDKWorkerParams } from './utils/interfaces'; | ||
import { EventEmitter } from './utils/EventEmitter'; | ||
@@ -25,2 +25,3 @@ import { SDKState } from './redux/interfaces'; | ||
private _destroyer?; | ||
private _handleCompoundEvents; | ||
/** | ||
@@ -167,2 +168,4 @@ * A Namespace let us scope specific instances inside of a | ||
protected _attachListeners(namespace?: string): void; | ||
/** @internal */ | ||
protected getCompoundEvents(): Map<EventEmitter.EventNames<EventTypes>, EventEmitter.EventNames<EventTypes>[]>; | ||
/** | ||
@@ -192,5 +195,5 @@ * Returns a structure with the emitter transforms that we want to `apply` | ||
/** @internal */ | ||
protected attachWorkers(): void; | ||
protected attachWorkers(params?: Partial<SDKWorkerParams<any>>): void; | ||
private detachWorkers; | ||
} | ||
//# sourceMappingURL=BaseComponent.d.ts.map |
@@ -13,5 +13,7 @@ import { BaseComponent, EventEmitter, BaseComponentOptions, JSONRPCSubscribeMethod } from '.'; | ||
protected subscribeParams?: Record<string, any>; | ||
private _latestExecuteParams; | ||
constructor(options: BaseComponentOptions<EventTypes>); | ||
private shouldExecuteSubscribe; | ||
subscribe(): Promise<unknown>; | ||
} | ||
//# sourceMappingURL=BaseConsumer.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { uuid, setLogger, getLogger, isGlobalEvent, toExternalJSON, toLocalEvent, toSyntheticEvent, extendComponent, validateEventsToSubscribe, toInternalEventName, serializeableProxy } from './utils'; | ||
import { uuid, setLogger, getLogger, isGlobalEvent, toExternalJSON, toLocalEvent, toSyntheticEvent, extendComponent, validateEventsToSubscribe, toInternalEventName, serializeableProxy, timeoutPromise } from './utils'; | ||
import { BaseSession } from './BaseSession'; | ||
@@ -9,11 +9,11 @@ import { BaseJWTSession } from './BaseJWTSession'; | ||
import { EventEmitter, getEventEmitter } from './utils/EventEmitter'; | ||
import { findNamespaceInPayload } from './redux/features/shared/namespace'; | ||
import { GLOBAL_VIDEO_EVENTS } from './utils/constants'; | ||
import { MEMBER_UPDATED_EVENTS, INTERNAL_MEMBER_UPDATED_EVENTS } from './types/videoMember'; | ||
export { uuid, setLogger, getLogger, BaseSession, BaseJWTSession, BaseComponent, BaseConsumer, BaseClient, connect, configureStore, EventEmitter, extendComponent, validateEventsToSubscribe, getEventEmitter, isGlobalEvent, toExternalJSON, toLocalEvent, toInternalEventName, serializeableProxy, toSyntheticEvent, GLOBAL_VIDEO_EVENTS, MEMBER_UPDATED_EVENTS, INTERNAL_MEMBER_UPDATED_EVENTS, }; | ||
export { uuid, setLogger, getLogger, BaseSession, BaseJWTSession, BaseComponent, BaseConsumer, BaseClient, connect, configureStore, EventEmitter, extendComponent, validateEventsToSubscribe, getEventEmitter, isGlobalEvent, toExternalJSON, toLocalEvent, toInternalEventName, serializeableProxy, toSyntheticEvent, GLOBAL_VIDEO_EVENTS, MEMBER_UPDATED_EVENTS, INTERNAL_MEMBER_UPDATED_EVENTS, findNamespaceInPayload, timeoutPromise, }; | ||
export * from './RPCMessages'; | ||
export * from './internal'; | ||
export * from './utils/interfaces'; | ||
export * from './types'; | ||
export * from './CustomErrors'; | ||
export type { SessionState, CustomSagaParams, CustomSaga, PubSubChannel, MapToPubSubShape } from './redux/interfaces'; | ||
export type { SessionState, CustomSagaParams, CustomSaga, PubSubChannel, MapToPubSubShape, } from './redux/interfaces'; | ||
export * as actions from './redux/actions'; | ||
@@ -25,2 +25,3 @@ export * as sagaHelpers from './redux/utils/sagaHelpers'; | ||
export * as Chat from './chat'; | ||
export * as MemberPosition from './memberPosition'; | ||
export type { RoomSessionRecording, RoomSessionPlayback } from './rooms'; | ||
@@ -33,2 +34,3 @@ export declare const selectors: { | ||
}; | ||
export { ChatMember, ChatMessage } from './chat'; | ||
//# sourceMappingURL=index.d.ts.map |
import { createAction, Action } from './toolkit'; | ||
import { JSONRPCRequest, SessionAuthError } from '../utils/interfaces'; | ||
import { ExecuteActionParams } from './interfaces'; | ||
import { EventEmitter } from '..'; | ||
export declare const initAction: import("./toolkit").ActionCreatorWithoutPayload<"swSdk/init">; | ||
@@ -34,3 +35,8 @@ export declare const destroyAction: import("./toolkit").ActionCreatorWithoutPayload<"swSdk/destroy">; | ||
export declare const getCustomSagaActionType: (id: string, action: Action) => string; | ||
export declare const compoundEventAttachAction: import("./toolkit").ActionCreatorWithPayload<{ | ||
compoundEvents: EventEmitter.EventNames<EventEmitter.ValidEventTypes>[]; | ||
event: EventEmitter.EventNames<EventEmitter.ValidEventTypes>; | ||
namespace?: string | undefined; | ||
}, "compound_event:attach">; | ||
export { createAction }; | ||
//# sourceMappingURL=actions.d.ts.map |
import { SagaIterator, EventChannel } from '@redux-saga/core'; | ||
import { BaseSession } from '../../../BaseSession'; | ||
import { PubSubChannel } from '../../interfaces'; | ||
import type { PubSubChannel, SwEventChannel } from '../../interfaces'; | ||
declare type SessionSagaParams = { | ||
@@ -8,2 +8,3 @@ session: BaseSession; | ||
pubSubChannel: PubSubChannel; | ||
swEventChannel: SwEventChannel; | ||
}; | ||
@@ -17,5 +18,5 @@ /** | ||
export declare function executeActionWatcher(session: BaseSession): SagaIterator; | ||
export declare function sessionChannelWatcher({ session, sessionChannel, pubSubChannel, }: SessionSagaParams): SagaIterator; | ||
export declare function sessionChannelWatcher({ session, sessionChannel, pubSubChannel, swEventChannel, }: SessionSagaParams): SagaIterator; | ||
export declare function createSessionChannel(session: BaseSession): EventChannel<unknown>; | ||
export {}; | ||
//# sourceMappingURL=sessionSaga.d.ts.map |
import type { SagaIterator } from '@redux-saga/types'; | ||
import type { PayloadAction } from './toolkit'; | ||
import { JSONRPCResponse, SessionAuthError, SessionAuthStatus, SessionEvents, JSONRPCMethod, BaseConnectionState } from '../utils/interfaces'; | ||
import type { VideoAPIEventParams, InternalVideoAPIEvent, ChatAction } from '../types'; | ||
import type { VideoAPIEventParams, InternalVideoAPIEvent, ChatAction, SwEventParams } from '../types'; | ||
import { SDKRunSaga } from '.'; | ||
@@ -78,3 +78,4 @@ import { MulticastChannel } from '@redux-saga/core'; | ||
export declare type PubSubChannel = MulticastChannel<PubSubAction>; | ||
export declare type SwEventChannel = MulticastChannel<MapToPubSubShape<SwEventParams>>; | ||
export {}; | ||
//# sourceMappingURL=interfaces.d.ts.map |
@@ -27,2 +27,3 @@ import { BaseRoomInterface } from '.'; | ||
name: string; | ||
positions?: Record<string, VideoPosition>; | ||
} | ||
@@ -49,4 +50,8 @@ export declare const setLayout: RoomMethodDescriptor<void, RoomMethodParams>; | ||
volume?: number; | ||
positions?: Record<string, VideoPosition>; | ||
}; | ||
export declare const play: RoomMethodDescriptor<any, PlayParams>; | ||
export interface SetMetaParams extends Record<string, unknown> { | ||
} | ||
export declare const setMeta: RoomMethodDescriptor<void, SetMetaParams>; | ||
export declare type GetLayouts = ReturnType<typeof getLayouts.value>; | ||
@@ -61,2 +66,3 @@ export declare type GetMembers = ReturnType<typeof getMembers.value>; | ||
export declare type Play = ReturnType<typeof play.value>; | ||
export declare type SetMeta = ReturnType<typeof setMeta.value>; | ||
/** | ||
@@ -80,2 +86,6 @@ * Room Member Methods | ||
export declare const removeMember: RoomMethodDescriptor<void, Required<RoomMemberMethodParams>>; | ||
export interface SetMemberMetaParams extends MemberCommandParams { | ||
meta: Record<string, unknown>; | ||
} | ||
export declare const setMemberMeta: RoomMethodDescriptor<void, RoomMemberMethodParams>; | ||
export declare type AudioMuteMember = ReturnType<typeof audioMuteMember.value>; | ||
@@ -95,3 +105,4 @@ export declare type AudioUnmuteMember = ReturnType<typeof audioUnmuteMember.value>; | ||
export declare type RemoveMember = ReturnType<typeof removeMember.value>; | ||
export declare type SetMemberMeta = ReturnType<typeof setMemberMeta.value>; | ||
export {}; | ||
//# sourceMappingURL=methods.d.ts.map |
import { ConfigureStoreOptions } from './redux'; | ||
import { PubSubChannel } from './redux/interfaces'; | ||
import { PubSubChannel, SwEventChannel } from './redux/interfaces'; | ||
import { RPCConnectResult, InternalSDKLogger } from './utils/interfaces'; | ||
@@ -25,2 +25,3 @@ export declare const createMockedLogger: () => InternalSDKLogger; | ||
export declare const createPubSubChannel: () => PubSubChannel; | ||
export declare const createSwEventChannel: () => SwEventChannel; | ||
//# sourceMappingURL=testUtils.d.ts.map |
@@ -12,3 +12,36 @@ import { VideoRoomSessionEventNames, VideoRoomEvent, InternalVideoRoomSessionEventNames, InternalVideoRoomEvent } from './videoRoomSession'; | ||
export declare type RTCTrackEventName = 'track'; | ||
export declare type VideoPosition = 'self' | 'standard' | `standard-${number}` | 'off-canvas'; | ||
/** | ||
* Each video layout has a number of positions which members can be assigned to. | ||
* This type enumerates all the available position names. Note that not all | ||
* these position names may be available within a given layout. | ||
* | ||
* - `auto`: the position of the member in the layout is determined automatically. | ||
* - `reserved-n`: the _n_-th reserved position in the layout (e.g. `reserved-3`). | ||
* - `standard-n`: the _n_-th standard position in the layout (e.g. `standard-3`). | ||
* - `off-canvas`: the member is hidden outside the layout. | ||
*/ | ||
export declare type VideoPosition = 'auto' | `reserved-${number}` | `standard-${number}` | 'off-canvas'; | ||
/** | ||
* An object whose keys represent member IDs, and values are chosen from | ||
* {@link VideoPosition}. Instead of a member ID, in some contexts you can use | ||
* the special keyword `self` if you don't know yet the ID of the member which | ||
* is going to be created. | ||
* | ||
* For example: | ||
* | ||
* ```js | ||
* { | ||
* "1bf4d4fb-a3e4-4d46-80a8-3ebfdceb2a60": "reserved-1", | ||
* "e0c5be44-d6c7-438f-8cda-f859a1a0b1e7": "auto" | ||
* } | ||
* ``` | ||
* | ||
* Or: | ||
* | ||
* ```js | ||
* { | ||
* "self": "reserved-1" | ||
* } | ||
* ``` | ||
*/ | ||
export declare type VideoPositions = Record<string, VideoPosition>; | ||
@@ -15,0 +48,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import type { SwEvent } from '.'; | ||
import type { SwEvent, VideoPosition } from '.'; | ||
import type { CamelToSnakeCase, SnakeToCamelCase, EntityUpdated, ToInternalVideoEvent, OnlyStateProperties, OnlyFunctionProperties, AssertSameType } from './utils'; | ||
@@ -18,5 +18,6 @@ import * as Rooms from '../rooms'; | ||
input_sensitivity: number; | ||
meta: {}; | ||
}; | ||
export declare type InternalVideoMemberUpdatableProps = typeof INTERNAL_MEMBER_UPDATABLE_PROPS; | ||
export declare const INTERNAL_MEMBER_UPDATED_EVENTS: ("video.member.updated.audio_muted" | "video.member.updated.video_muted" | "video.member.updated.deaf" | "video.member.updated.on_hold" | "video.member.updated.visible" | "video.member.updated.input_volume" | "video.member.updated.output_volume" | "video.member.updated.input_sensitivity")[]; | ||
export declare const INTERNAL_MEMBER_UPDATED_EVENTS: ("video.member.updated.meta" | "video.member.updated.audio_muted" | "video.member.updated.video_muted" | "video.member.updated.deaf" | "video.member.updated.on_hold" | "video.member.updated.visible" | "video.member.updated.input_volume" | "video.member.updated.output_volume" | "video.member.updated.input_sensitivity")[]; | ||
declare type VideoMemberUpdatablePropsMain = { | ||
@@ -44,5 +45,7 @@ [K in keyof InternalVideoMemberUpdatableProps as SnakeToCamelCase<K>]: InternalVideoMemberUpdatableProps[K]; | ||
inputSensitivity: number; | ||
/** Metadata associated to this member. */ | ||
meta: Record<string, unknown>; | ||
}>; | ||
export declare const MEMBER_UPDATABLE_PROPS: VideoMemberUpdatableProps; | ||
export declare const MEMBER_UPDATED_EVENTS: ("member.updated.deaf" | "member.updated.visible" | "member.updated.audioMuted" | "member.updated.videoMuted" | "member.updated.onHold" | "member.updated.inputVolume" | "member.updated.outputVolume" | "member.updated.inputSensitivity")[]; | ||
export declare const MEMBER_UPDATED_EVENTS: ("member.updated.meta" | "member.updated.deaf" | "member.updated.visible" | "member.updated.audioMuted" | "member.updated.videoMuted" | "member.updated.onHold" | "member.updated.inputVolume" | "member.updated.outputVolume" | "member.updated.inputSensitivity")[]; | ||
/** | ||
@@ -109,2 +112,9 @@ * Public event types | ||
/** | ||
* Position requested for this member in the layout. This may differ from | ||
* `currentPosition` if the requested position is not currently available. | ||
*/ | ||
requestedPosition: VideoPosition; | ||
/** Current position of this member in the layout. */ | ||
currentPosition?: VideoPosition; | ||
/** | ||
* Mutes the outbound audio for this member (e.g., the one coming from a | ||
@@ -111,0 +121,0 @@ * microphone). The other participants will not hear audio from the muted |
@@ -42,2 +42,4 @@ import type { SwEvent } from '.'; | ||
previewUrl?: string; | ||
/** Metadata associated to this room session. */ | ||
meta: Record<string, unknown>; | ||
audioMute(params?: MemberCommandParams): Rooms.AudioMuteMember; | ||
@@ -61,2 +63,4 @@ audioUnmute(params?: MemberCommandParams): Rooms.AudioUnmuteMember; | ||
setLayout(params: Rooms.SetLayoutParams): Rooms.SetLayout; | ||
setPositions(params: Rooms.SetPositionsParams): Rooms.SetPositions; | ||
setMemberPosition(params: Rooms.SetMemberPositionParams): Rooms.SetMemberPosition; | ||
getRecordings(): Rooms.GetRecordings; | ||
@@ -66,2 +70,4 @@ startRecording(): Promise<Rooms.RoomSessionRecording>; | ||
play(params: Rooms.PlayParams): Promise<Rooms.RoomSessionPlayback>; | ||
setMeta(params: Rooms.SetMetaParams): Rooms.SetMeta; | ||
setMemberMeta(params: Rooms.SetMemberMetaParams): Rooms.SetMemberMeta; | ||
} | ||
@@ -68,0 +74,0 @@ /** |
@@ -7,2 +7,3 @@ import { JSONRPCRequest, JSONRPCResponse } from '..'; | ||
export * from './toInternalEventName'; | ||
export * from './toInternalAction'; | ||
export * from './extendComponent'; | ||
@@ -14,3 +15,3 @@ export * from './eventTransformUtils'; | ||
export declare const checkWebSocketHost: (host: string) => string; | ||
export declare const timeoutPromise: (promise: Promise<unknown>, time: number, exception: any) => Promise<unknown>; | ||
export declare const timeoutPromise: <T = unknown>(promise: Promise<T>, time: number, exception: any) => Promise<Awaited<T>>; | ||
/** @internal */ | ||
@@ -17,0 +18,0 @@ export declare const isGlobalEvent: (event: string) => boolean; |
@@ -7,5 +7,4 @@ /// <reference types="node" /> | ||
import { GLOBAL_VIDEO_EVENTS, INTERNAL_GLOBAL_VIDEO_EVENTS, PRODUCT_PREFIXES } from './constants'; | ||
import type { CustomSaga, PubSubChannel } from '../redux/interfaces'; | ||
import type { CustomSaga, PubSubChannel, SwEventChannel } from '../redux/interfaces'; | ||
import type { URL as NodeURL } from 'node:url'; | ||
import { InternalRPCMethods } from '../internal'; | ||
import { ChatJSONRPCMethod, ChatTransformType } from '..'; | ||
@@ -16,3 +15,3 @@ declare type JSONRPCParams = Record<string, any>; | ||
export declare type VertoMethod = 'verto.invite' | 'verto.attach' | 'verto.answer' | 'verto.info' | 'verto.display' | 'verto.media' | 'verto.event' | 'verto.bye' | 'verto.punt' | 'verto.broadcast' | 'verto.subscribe' | 'verto.unsubscribe' | 'verto.clientReady' | 'verto.modify' | 'verto.mediaParams' | 'verto.prompt' | 'jsapi' | 'verto.stats' | 'verto.ping' | 'verto.announce'; | ||
export declare type JSONRPCMethod = 'signalwire.connect' | 'signalwire.ping' | 'signalwire.disconnect' | 'signalwire.event' | 'signalwire.reauthenticate' | 'signalwire.subscribe' | 'video.message' | RoomMethod | VertoMethod | InternalRPCMethods | ChatJSONRPCMethod; | ||
export declare type JSONRPCMethod = 'signalwire.connect' | 'signalwire.ping' | 'signalwire.disconnect' | 'signalwire.event' | 'signalwire.reauthenticate' | 'signalwire.subscribe' | 'video.message' | RoomMethod | VertoMethod | ChatJSONRPCMethod; | ||
export declare type JSONRPCSubscribeMethod = Extract<JSONRPCMethod, 'signalwire.subscribe' | 'chat.subscribe'>; | ||
@@ -113,2 +112,3 @@ export interface JSONRPCRequest { | ||
export declare type SessionEvents = `session.${SessionStatus}`; | ||
export declare type CompoundEvents = 'compound_event:attach'; | ||
/** | ||
@@ -127,3 +127,3 @@ * List of all the events the client can listen to. | ||
*/ | ||
export declare type RoomMethod = 'video.list_available_layouts' | 'video.hide_video_muted' | 'video.show_video_muted' | 'video.members.get' | 'video.member.audio_mute' | 'video.member.audio_unmute' | 'video.member.video_mute' | 'video.member.video_unmute' | 'video.member.deaf' | 'video.member.undeaf' | 'video.member.set_input_volume' | 'video.member.set_output_volume' | 'video.member.set_input_sensitivity' | 'video.member.set_position' | 'video.member.remove' | 'video.set_layout' | 'video.set_position' | 'video.recording.list' | 'video.recording.start' | 'video.recording.stop' | 'video.recording.pause' | 'video.recording.resume' | 'video.playback.list' | 'video.playback.start' | 'video.playback.pause' | 'video.playback.resume' | 'video.playback.stop' | 'video.playback.set_volume'; | ||
export declare type RoomMethod = 'video.list_available_layouts' | 'video.hide_video_muted' | 'video.show_video_muted' | 'video.members.get' | 'video.member.audio_mute' | 'video.member.audio_unmute' | 'video.member.video_mute' | 'video.member.video_unmute' | 'video.member.deaf' | 'video.member.undeaf' | 'video.member.set_input_volume' | 'video.member.set_output_volume' | 'video.member.set_input_sensitivity' | 'video.member.set_position' | 'video.member.remove' | 'video.member.set_meta' | 'video.set_meta' | 'video.set_layout' | 'video.set_position' | 'video.recording.list' | 'video.recording.start' | 'video.recording.stop' | 'video.recording.pause' | 'video.recording.resume' | 'video.playback.list' | 'video.playback.start' | 'video.playback.pause' | 'video.playback.resume' | 'video.playback.stop' | 'video.playback.set_volume'; | ||
export interface WebSocketClient { | ||
@@ -257,2 +257,3 @@ addEventListener: WebSocket['addEventListener']; | ||
pubSubChannel: PubSubChannel; | ||
swEventChannel: SwEventChannel; | ||
}; | ||
@@ -263,2 +264,3 @@ export declare type SDKWorkerParams<T> = { | ||
runSaga: any; | ||
payload?: any; | ||
}; | ||
@@ -265,0 +267,0 @@ export declare type SDKWorker<T> = (params: SDKWorkerParams<T>) => SagaIterator<any>; |
import { EventTransform } from '..'; | ||
export declare const serializeableProxy: ({ instance, proxiedObj, payload, }: { | ||
export declare const serializeableProxy: ({ instance, proxiedObj, payload, transformedPayload, transform, }: { | ||
instance: any; | ||
proxiedObj: any; | ||
payload: any; | ||
transformedPayload: any; | ||
transform: any; | ||
}) => any; | ||
@@ -7,0 +9,0 @@ interface ProxyFactoryOptions { |
@@ -25,2 +25,14 @@ var __create = Object.create; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __objRest = (source, exclude) => { | ||
var target = {}; | ||
for (var prop in source) | ||
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) | ||
target[prop] = source[prop]; | ||
if (source != null && __getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(source)) { | ||
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) | ||
target[prop] = source[prop]; | ||
} | ||
return target; | ||
}; | ||
var __export = (target, all) => { | ||
@@ -74,4 +86,7 @@ for (var name in all) | ||
__export(src_exports, { | ||
Chat: () => Chat_exports, | ||
Video: () => Video_exports, | ||
createClient: () => createClient2 | ||
config: () => config, | ||
createClient: () => createClient2, | ||
getConfig: () => getConfig | ||
}); | ||
@@ -85,6 +100,6 @@ | ||
}); | ||
var import_core9 = require("@signalwire/core"); | ||
var import_core10 = require("@signalwire/core"); | ||
// src/video/RoomSession.ts | ||
var import_core2 = require("@signalwire/core"); | ||
var import_core3 = require("@signalwire/core"); | ||
@@ -176,4 +191,18 @@ // src/utils/debounce.ts | ||
// src/video/memberPosition/workers.ts | ||
var import_core2 = require("@signalwire/core"); | ||
var memberPositionWorker = function* memberPositionWorker2(options) { | ||
const { instance, channels } = options; | ||
const { swEventChannel } = channels; | ||
const action = yield import_core2.sagaEffects.take(swEventChannel, (action2) => { | ||
const istargetEvent = action2.type === "video.room.subscribed"; | ||
return istargetEvent && (0, import_core2.findNamespaceInPayload)(action2) === instance._eventsNamespace; | ||
}); | ||
yield import_core2.sagaEffects.fork(import_core2.MemberPosition.memberPositionWorker, __spreadProps(__spreadValues({}, options), { | ||
payload: action.payload | ||
})); | ||
}; | ||
// src/video/RoomSession.ts | ||
var RoomSessionConsumer = class extends import_core2.BaseConsumer { | ||
var RoomSessionConsumer = class extends import_core3.BaseConsumer { | ||
constructor(options) { | ||
@@ -187,3 +216,10 @@ super(options); | ||
this.debouncedSubscribe = debounce(this.subscribe, 100); | ||
this.setWorker("memberPositionWorker", { | ||
worker: memberPositionWorker | ||
}); | ||
this.attachWorkers(); | ||
} | ||
_internal_on(event, fn) { | ||
return super.on(event, fn); | ||
} | ||
on(event, fn) { | ||
@@ -216,2 +252,7 @@ const instance = super.on(event, fn); | ||
} | ||
getCompoundEvents() { | ||
return new Map([ | ||
...import_core3.MemberPosition.MEMBER_POSITION_COMPOUND_EVENTS | ||
]); | ||
} | ||
getEmitterTransforms() { | ||
@@ -227,3 +268,3 @@ return /* @__PURE__ */ new Map([ | ||
payloadTransform: (payload) => { | ||
return (0, import_core2.toExternalJSON)(payload.room_session); | ||
return (0, import_core3.toExternalJSON)(payload.room_session); | ||
}, | ||
@@ -246,3 +287,3 @@ getInstanceEventNamespace: (payload) => { | ||
payloadTransform: (payload) => { | ||
return (0, import_core2.toExternalJSON)(__spreadProps(__spreadValues({}, payload.room_session), { | ||
return (0, import_core3.toExternalJSON)(__spreadProps(__spreadValues({}, payload.room_session), { | ||
room_session_id: payload.room_session.id | ||
@@ -267,3 +308,3 @@ })); | ||
payloadTransform: (payload) => { | ||
return (0, import_core2.toExternalJSON)(payload.layout); | ||
return (0, import_core3.toExternalJSON)(payload.layout); | ||
} | ||
@@ -282,3 +323,3 @@ } | ||
"video.member.updated", | ||
...import_core2.INTERNAL_MEMBER_UPDATED_EVENTS | ||
...import_core3.INTERNAL_MEMBER_UPDATED_EVENTS | ||
], | ||
@@ -294,3 +335,3 @@ { | ||
payloadTransform: (payload) => { | ||
return (0, import_core2.toExternalJSON)(__spreadProps(__spreadValues({}, payload.member), { | ||
return (0, import_core3.toExternalJSON)(__spreadProps(__spreadValues({}, payload.member), { | ||
member_id: payload.member.id | ||
@@ -303,3 +344,3 @@ })); | ||
[ | ||
(0, import_core2.toLocalEvent)("video.recording.start"), | ||
(0, import_core3.toLocalEvent)("video.recording.start"), | ||
"video.recording.started", | ||
@@ -312,3 +353,3 @@ "video.recording.updated", | ||
instanceFactory: (_payload) => { | ||
return import_core2.Rooms.createRoomSessionRecordingObject({ | ||
return import_core3.Rooms.createRoomSessionRecordingObject({ | ||
store: this.store, | ||
@@ -319,3 +360,3 @@ emitter: this.emitter | ||
payloadTransform: (payload) => { | ||
return (0, import_core2.toExternalJSON)(__spreadProps(__spreadValues({}, payload.recording), { | ||
return (0, import_core3.toExternalJSON)(__spreadProps(__spreadValues({}, payload.recording), { | ||
room_session_id: payload.room_session_id | ||
@@ -328,3 +369,3 @@ })); | ||
[ | ||
(0, import_core2.toLocalEvent)("video.playback.start"), | ||
(0, import_core3.toLocalEvent)("video.playback.start"), | ||
"video.playback.started", | ||
@@ -337,3 +378,3 @@ "video.playback.updated", | ||
instanceFactory: (_payload) => { | ||
return import_core2.Rooms.createRoomSessionPlaybackObject({ | ||
return import_core3.Rooms.createRoomSessionPlaybackObject({ | ||
store: this.store, | ||
@@ -344,3 +385,3 @@ emitter: this.emitter | ||
payloadTransform: (payload) => { | ||
return (0, import_core2.toExternalJSON)(__spreadProps(__spreadValues({}, payload.playback), { | ||
return (0, import_core3.toExternalJSON)(__spreadProps(__spreadValues({}, payload.playback), { | ||
room_session_id: payload.room_session_id | ||
@@ -354,26 +395,30 @@ })); | ||
}; | ||
var RoomSessionAPI = (0, import_core2.extendComponent)(RoomSessionConsumer, { | ||
videoMute: import_core2.Rooms.videoMuteMember, | ||
videoUnmute: import_core2.Rooms.videoUnmuteMember, | ||
getMembers: import_core2.Rooms.getMembers, | ||
audioMute: import_core2.Rooms.audioMuteMember, | ||
audioUnmute: import_core2.Rooms.audioUnmuteMember, | ||
deaf: import_core2.Rooms.deafMember, | ||
undeaf: import_core2.Rooms.undeafMember, | ||
setInputVolume: import_core2.Rooms.setInputVolumeMember, | ||
setOutputVolume: import_core2.Rooms.setOutputVolumeMember, | ||
setMicrophoneVolume: import_core2.Rooms.setInputVolumeMember, | ||
setSpeakerVolume: import_core2.Rooms.setOutputVolumeMember, | ||
setInputSensitivity: import_core2.Rooms.setInputSensitivityMember, | ||
removeMember: import_core2.Rooms.removeMember, | ||
setHideVideoMuted: import_core2.Rooms.setHideVideoMuted, | ||
getLayouts: import_core2.Rooms.getLayouts, | ||
setLayout: import_core2.Rooms.setLayout, | ||
getRecordings: import_core2.Rooms.getRecordings, | ||
startRecording: import_core2.Rooms.startRecording, | ||
getPlaybacks: import_core2.Rooms.getPlaybacks, | ||
play: import_core2.Rooms.play | ||
var RoomSessionAPI = (0, import_core3.extendComponent)(RoomSessionConsumer, { | ||
videoMute: import_core3.Rooms.videoMuteMember, | ||
videoUnmute: import_core3.Rooms.videoUnmuteMember, | ||
getMembers: import_core3.Rooms.getMembers, | ||
audioMute: import_core3.Rooms.audioMuteMember, | ||
audioUnmute: import_core3.Rooms.audioUnmuteMember, | ||
deaf: import_core3.Rooms.deafMember, | ||
undeaf: import_core3.Rooms.undeafMember, | ||
setInputVolume: import_core3.Rooms.setInputVolumeMember, | ||
setOutputVolume: import_core3.Rooms.setOutputVolumeMember, | ||
setMicrophoneVolume: import_core3.Rooms.setInputVolumeMember, | ||
setSpeakerVolume: import_core3.Rooms.setOutputVolumeMember, | ||
setInputSensitivity: import_core3.Rooms.setInputSensitivityMember, | ||
removeMember: import_core3.Rooms.removeMember, | ||
setHideVideoMuted: import_core3.Rooms.setHideVideoMuted, | ||
getLayouts: import_core3.Rooms.getLayouts, | ||
setLayout: import_core3.Rooms.setLayout, | ||
setPositions: import_core3.Rooms.setPositions, | ||
setMemberPosition: import_core3.Rooms.setMemberPosition, | ||
getRecordings: import_core3.Rooms.getRecordings, | ||
startRecording: import_core3.Rooms.startRecording, | ||
getPlaybacks: import_core3.Rooms.getPlaybacks, | ||
play: import_core3.Rooms.play, | ||
setMeta: import_core3.Rooms.setMeta, | ||
setMemberMeta: import_core3.Rooms.setMemberMeta | ||
}); | ||
var createRoomSessionObject = (params) => { | ||
const roomSession = (0, import_core2.connect)({ | ||
const roomSession = (0, import_core3.connect)({ | ||
store: params.store, | ||
@@ -390,42 +435,8 @@ Component: RoomSessionAPI, | ||
// src/video/VideoClient.ts | ||
var import_core8 = require("@signalwire/core"); | ||
var import_core9 = require("@signalwire/core"); | ||
// src/client/Client.ts | ||
var import_core3 = require("@signalwire/core"); | ||
var Client = class extends import_core3.BaseClient { | ||
}; | ||
// src/client/getClient.ts | ||
var import_core4 = require("@signalwire/core"); | ||
var CLIENTS_MAP = /* @__PURE__ */ new Map(); | ||
var getClientKey = ({ | ||
project, | ||
token | ||
}) => { | ||
return `${project}:${token}`; | ||
var Client = class extends import_core4.BaseClient { | ||
}; | ||
var createClient = (userOptions) => { | ||
const client = (0, import_core4.connect)({ | ||
store: userOptions.store, | ||
Component: Client, | ||
componentListeners: { | ||
errors: "onError", | ||
responses: "onSuccess" | ||
} | ||
})(userOptions); | ||
return client; | ||
}; | ||
var getClient = (userOptions) => { | ||
const clientKey = getClientKey({ | ||
project: userOptions.project, | ||
token: userOptions.token | ||
}); | ||
if (CLIENTS_MAP.has(clientKey)) { | ||
return CLIENTS_MAP.get(clientKey); | ||
} else { | ||
const client = createClient(userOptions); | ||
CLIENTS_MAP.set(clientKey, client); | ||
return client; | ||
} | ||
}; | ||
@@ -438,45 +449,35 @@ // src/client/clientConnect.ts | ||
// src/client/clientProxyFactory.ts | ||
var clientProxyFactory = (client) => { | ||
const clientOn = (...args) => { | ||
clientConnect(client); | ||
return client.on(...args); | ||
}; | ||
const clientOnce = (...args) => { | ||
clientConnect(client); | ||
return client.once(...args); | ||
}; | ||
return new Proxy(client, { | ||
get(target, prop, receiver) { | ||
if (prop === "on") { | ||
return clientOn; | ||
} else if (prop === "once") { | ||
return clientOnce; | ||
} | ||
return Reflect.get(target, prop, receiver); | ||
} | ||
}); | ||
// src/client/setupClient.ts | ||
var import_core8 = require("@signalwire/core"); | ||
// src/utils/internals.ts | ||
var import_core6 = require("@signalwire/core"); | ||
// src/configure/index.ts | ||
var GLOBAL_CONFIG = {}; | ||
var getConfig = () => { | ||
return GLOBAL_CONFIG; | ||
}; | ||
// src/client/getProxiedClient.ts | ||
var import_core5 = require("@signalwire/core"); | ||
var getProxiedClient = (userOptions) => { | ||
const client = getClient(userOptions); | ||
client.on("session.auth_error", () => { | ||
(0, import_core5.getLogger)().error("Wrong credentials: couldn't connect the client."); | ||
var config = (_a) => { | ||
var _b = _a, { | ||
cache = GLOBAL_CONFIG | ||
} = _b, options = __objRest(_b, [ | ||
"cache" | ||
]); | ||
if (cache) { | ||
GLOBAL_CONFIG = cache; | ||
} | ||
Object.entries(options).forEach(([key, value]) => { | ||
GLOBAL_CONFIG[key] = value; | ||
}); | ||
return clientProxyFactory(client); | ||
}; | ||
// src/utils/internals.ts | ||
var import_core7 = require("@signalwire/core"); | ||
// src/Session.ts | ||
var import_core6 = require("@signalwire/core"); | ||
var import_core5 = require("@signalwire/core"); | ||
var import_ws = __toESM(require("ws")); | ||
var Session = class extends import_core6.BaseSession { | ||
var Session = class extends import_core5.BaseSession { | ||
constructor() { | ||
super(...arguments); | ||
__publicField(this, "WebSocketConstructor", import_ws.default); | ||
__publicField(this, "agent", "@signalwire/realtime-api/3.0.0-beta.7"); | ||
__publicField(this, "agent", "@signalwire/realtime-api/3.0.0-beta.8"); | ||
} | ||
@@ -487,7 +488,7 @@ }; | ||
var setupInternals = (userOptions) => { | ||
const emitter = (0, import_core7.getEventEmitter)(); | ||
const emitter = (0, import_core6.getEventEmitter)(); | ||
const baseOptions = __spreadProps(__spreadValues({}, userOptions), { | ||
emitter | ||
}); | ||
const store = (0, import_core7.configureStore)({ | ||
const store = (0, import_core6.configureStore)({ | ||
userOptions: baseOptions, | ||
@@ -499,5 +500,6 @@ SessionConstructor: Session | ||
var getToken = (userToken) => { | ||
const token = userToken || process.env.SW_TOKEN; | ||
const globalConfig = getConfig(); | ||
const token = userToken || globalConfig.token || process.env.SW_TOKEN; | ||
if (!token) { | ||
throw new Error("Missing token"); | ||
throw new Error("Missing `token`"); | ||
} | ||
@@ -507,5 +509,6 @@ return token; | ||
var getProject = (userProject) => { | ||
const project = userProject || process.env.SW_PROJECT; | ||
const globalConfig = getConfig(); | ||
const project = userProject || globalConfig.project || process.env.SW_PROJECT; | ||
if (!project) { | ||
throw new Error("Missing Project"); | ||
throw new Error("Missing `project`"); | ||
} | ||
@@ -515,18 +518,102 @@ return project; | ||
var getCredentials = (options) => { | ||
const project = getProject(options.project); | ||
const token = getToken(options.token); | ||
const project = getProject(options == null ? void 0 : options.project); | ||
const token = getToken(options == null ? void 0 : options.token); | ||
return { project, token }; | ||
}; | ||
// src/client/clientProxyFactory.ts | ||
var defaultInterceptors = { | ||
connect: clientConnect | ||
}; | ||
var clientProxyFactory = (client, interceptors = defaultInterceptors) => { | ||
const clientConnect2 = interceptors.connect || clientConnect; | ||
const clientOn = (...args) => { | ||
clientConnect2(client); | ||
return client.on(...args); | ||
}; | ||
const clientOnce = (...args) => { | ||
clientConnect2(client); | ||
return client.once(...args); | ||
}; | ||
return new Proxy(client, { | ||
get(target, prop, receiver) { | ||
if (prop === "on") { | ||
return clientOn; | ||
} else if (prop === "once") { | ||
return clientOnce; | ||
} | ||
return Reflect.get(target, prop, receiver); | ||
} | ||
}); | ||
}; | ||
// src/client/getClient.ts | ||
var import_core7 = require("@signalwire/core"); | ||
var CLIENTS_MAP = /* @__PURE__ */ new Map(); | ||
var getClientKey = ({ | ||
project, | ||
token | ||
}) => { | ||
return `${project}:${token}`; | ||
}; | ||
var createClient = (userOptions) => { | ||
const client = (0, import_core7.connect)({ | ||
store: userOptions.store, | ||
Component: Client, | ||
componentListeners: { | ||
errors: "onError", | ||
responses: "onSuccess" | ||
} | ||
})(userOptions); | ||
return client; | ||
}; | ||
var getClient = (_a) => { | ||
var _b = _a, { | ||
cache = CLIENTS_MAP | ||
} = _b, userOptions = __objRest(_b, [ | ||
"cache" | ||
]); | ||
const clientKey = getClientKey({ | ||
project: userOptions.project, | ||
token: userOptions.token | ||
}); | ||
if (cache.has(clientKey)) { | ||
return cache.get(clientKey); | ||
} else { | ||
const { emitter, store } = setupInternals(userOptions); | ||
const client = createClient(__spreadProps(__spreadValues({}, userOptions), { | ||
store, | ||
emitter | ||
})); | ||
const config2 = { | ||
client, | ||
store, | ||
emitter | ||
}; | ||
cache.set(clientKey, config2); | ||
return config2; | ||
} | ||
}; | ||
// src/client/setupClient.ts | ||
var setupClient = (userOptions) => { | ||
const credentials = getCredentials({ | ||
token: userOptions == null ? void 0 : userOptions.token, | ||
project: userOptions == null ? void 0 : userOptions.project | ||
}); | ||
const { client, store, emitter } = getClient(__spreadValues(__spreadValues({}, userOptions), credentials)); | ||
client.on("session.auth_error", () => { | ||
(0, import_core8.getLogger)().error("Wrong credentials: couldn't connect the client."); | ||
}); | ||
const proxiedClient = clientProxyFactory(client); | ||
return { | ||
client: proxiedClient, | ||
store, | ||
emitter | ||
}; | ||
}; | ||
// src/video/VideoClient.ts | ||
var VideoClient = function(options) { | ||
const credentials = getCredentials({ | ||
token: options.token, | ||
project: options.project | ||
}); | ||
const { emitter, store } = setupInternals(__spreadValues(__spreadValues({}, options), credentials)); | ||
const client = getProxiedClient(__spreadProps(__spreadValues(__spreadValues({}, options), credentials), { | ||
emitter, | ||
store | ||
})); | ||
const { client, store, emitter } = setupClient(options); | ||
const video = createVideoObject({ | ||
@@ -552,3 +639,3 @@ store, | ||
} catch (e) { | ||
(0, import_core8.getLogger)().error("Client subscription failed."); | ||
(0, import_core9.getLogger)().error("Client subscription failed."); | ||
client.disconnect(); | ||
@@ -574,3 +661,3 @@ } | ||
// src/video/Video.ts | ||
var VideoAPI = class extends import_core9.BaseConsumer { | ||
var VideoAPI = class extends import_core10.BaseConsumer { | ||
constructor() { | ||
@@ -596,3 +683,3 @@ super(...arguments); | ||
payloadTransform: (payload) => { | ||
return (0, import_core9.toExternalJSON)(__spreadProps(__spreadValues({}, payload.room_session), { | ||
return (0, import_core10.toExternalJSON)(__spreadProps(__spreadValues({}, payload.room_session), { | ||
room_session_id: payload.room_session.id | ||
@@ -613,3 +700,3 @@ })); | ||
var createVideoObject = (params) => { | ||
const video = (0, import_core9.connect)({ | ||
const video = (0, import_core10.connect)({ | ||
store: params.store, | ||
@@ -636,7 +723,7 @@ Component: VideoAPI, | ||
// src/createClient.ts | ||
var import_core11 = require("@signalwire/core"); | ||
var import_core12 = require("@signalwire/core"); | ||
// src/Client.ts | ||
var import_core10 = require("@signalwire/core"); | ||
var Client2 = class extends import_core10.BaseClient { | ||
var import_core11 = require("@signalwire/core"); | ||
var Client2 = class extends import_core11.BaseClient { | ||
constructor() { | ||
@@ -677,9 +764,9 @@ super(...arguments); | ||
const baseUserOptions = __spreadProps(__spreadValues({}, userOptions), { | ||
emitter: (0, import_core11.getEventEmitter)() | ||
emitter: (0, import_core12.getEventEmitter)() | ||
}); | ||
const store = (0, import_core11.configureStore)({ | ||
const store = (0, import_core12.configureStore)({ | ||
userOptions: baseUserOptions, | ||
SessionConstructor: Session | ||
}); | ||
const client = (0, import_core11.connect)({ | ||
const client = (0, import_core12.connect)({ | ||
store, | ||
@@ -697,8 +784,72 @@ Component: Client2, | ||
}); | ||
// src/chat/Chat.ts | ||
var Chat_exports = {}; | ||
__export(Chat_exports, { | ||
ChatMember: () => import_core15.ChatMember, | ||
ChatMessage: () => import_core15.ChatMessage, | ||
Client: () => ChatClient | ||
}); | ||
var import_core15 = require("@signalwire/core"); | ||
// src/chat/ChatClient.ts | ||
var import_core13 = require("@signalwire/core"); | ||
var import_core14 = require("@signalwire/core"); | ||
var INTERCEPTED_METHODS = [ | ||
"subscribe", | ||
"publish", | ||
"getMessages", | ||
"getMembers", | ||
"getMemberState", | ||
"setMemberState" | ||
]; | ||
var ChatClient = function(options) { | ||
if (process.env.NODE_ENV === "production") { | ||
(0, import_core14.getLogger)().warn("`Chat` is still under development and may change in the future without prior notice."); | ||
} | ||
const { client, store, emitter } = setupClient(options); | ||
const chat = import_core13.Chat.createBaseChatObject({ | ||
store, | ||
emitter | ||
}); | ||
const chatOn = (...args) => { | ||
clientConnect(client); | ||
return chat.on(...args); | ||
}; | ||
const chatOnce = (...args) => { | ||
clientConnect(client); | ||
return chat.once(...args); | ||
}; | ||
const createInterceptor = (prop) => { | ||
return (...params) => __async(this, null, function* () { | ||
yield clientConnect(client); | ||
return chat[prop](...params); | ||
}); | ||
}; | ||
const interceptors = { | ||
on: chatOn, | ||
once: chatOnce, | ||
_session: client | ||
}; | ||
return new Proxy(chat, { | ||
get(target, prop, receiver) { | ||
if (prop in interceptors) { | ||
return interceptors[prop]; | ||
} | ||
if (prop !== "_session" && INTERCEPTED_METHODS.includes(prop)) { | ||
return createInterceptor(prop); | ||
} | ||
return Reflect.get(target, prop, receiver); | ||
} | ||
}); | ||
}; | ||
module.exports = __toCommonJS(src_exports); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
Chat, | ||
Video, | ||
createClient | ||
config, | ||
createClient, | ||
getConfig | ||
}); | ||
//# sourceMappingURL=index.node.js.map |
import { RealtimeClient } from './Client'; | ||
export declare const clientProxyFactory: (client: RealtimeClient) => RealtimeClient; | ||
interface ClientInterceptors { | ||
connect?: (client: RealtimeClient) => Promise<void | RealtimeClient>; | ||
} | ||
export declare const clientProxyFactory: (client: RealtimeClient, interceptors?: ClientInterceptors) => RealtimeClient; | ||
export {}; | ||
//# sourceMappingURL=clientProxyFactory.d.ts.map |
import { configureStore, EventEmitter, UserOptions } from '@signalwire/core'; | ||
import { RealtimeClient } from './Client'; | ||
export declare const getClient: (userOptions: { | ||
export interface ClientConfig { | ||
client: RealtimeClient; | ||
store: ReturnType<typeof configureStore>; | ||
emitter: EventEmitter<any>; | ||
} | ||
export declare type ClientCache = Map<string, ClientConfig>; | ||
export declare const getClient: ({ cache, ...userOptions }: { | ||
project: string; | ||
token: string; | ||
logLevel?: UserOptions['logLevel']; | ||
store: ReturnType<typeof configureStore>; | ||
emitter: EventEmitter; | ||
}) => RealtimeClient; | ||
cache?: ClientCache | undefined; | ||
}) => ClientConfig; | ||
//# sourceMappingURL=getClient.d.ts.map |
export * from './Client'; | ||
export * from './getClient'; | ||
export * from './clientConnect'; | ||
export * from './clientProxyFactory'; | ||
export * from './getProxiedClient'; | ||
export * from './setupClient'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -52,2 +52,25 @@ /** | ||
export * from './createClient'; | ||
/** | ||
* Access the Chat API Consumer. You can instantiate a {@link Chat.Client} to | ||
* subscribe to Chat events. Please check {@link Chat.ChatClientApiEvents} | ||
* for the full list of events that a {@link Chat.Client} can subscribe to. | ||
* | ||
* ### Example | ||
* | ||
* The following example logs the messages sent to the "welcome" channel. | ||
* | ||
* ```javascript | ||
* const chatClient = new Chat.Client({ | ||
* project: '<project-id>', | ||
* token: '<api-token>' | ||
* }) | ||
* | ||
* chatClient.on('message', m => console.log(m)) | ||
* | ||
* await chatClient.subscribe("welcome") | ||
* ``` | ||
*/ | ||
export * as Chat from './chat/Chat'; | ||
/** @ignore */ | ||
export * from './configure'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -20,9 +20,11 @@ import { UserOptions } from '@signalwire/core'; | ||
}; | ||
export declare const getCredentials: (options: { | ||
interface GetCredentialsOptions { | ||
token?: string; | ||
project?: string; | ||
}) => { | ||
} | ||
export declare const getCredentials: (options?: GetCredentialsOptions | undefined) => { | ||
project: string; | ||
token: string; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=internals.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { BaseComponentOptions, EventTransform, InternalVideoMemberEventNames, Rooms, InternalVideoRoomSessionEventNames, InternalVideoLayoutEventNames, InternalVideoRecordingEventNames, InternalVideoPlaybackEventNames, VideoRoomSessionContract, ConsumerContract, EntityUpdated, VideoMemberEntity, AssertSameType, BaseConsumer, EventEmitter } from '@signalwire/core'; | ||
import { BaseComponentOptions, EventTransform, InternalVideoMemberEventNames, Rooms, InternalVideoRoomSessionEventNames, InternalVideoLayoutEventNames, InternalVideoRecordingEventNames, InternalVideoPlaybackEventNames, VideoRoomSessionContract, ConsumerContract, EntityUpdated, VideoMemberEntity, AssertSameType, BaseConsumer, EventEmitter, VideoPosition, VideoPositions } from '@signalwire/core'; | ||
import { RealTimeRoomApiEvents } from '../types'; | ||
@@ -274,4 +274,2 @@ import { RoomSessionMember } from './RoomSessionMember'; | ||
* with {@link getLayouts}. | ||
* @param params | ||
* @param params.name name of the layout | ||
* | ||
@@ -284,5 +282,42 @@ * @example Set the 6x6 layout: | ||
setLayout(params: { | ||
/** Name of the layout */ | ||
name: string; | ||
/** Positions to assign as soon as the new layout is set. */ | ||
positions?: VideoPositions; | ||
}): Rooms.SetLayout; | ||
/** | ||
* Assigns a position in the layout for multiple members. | ||
* | ||
* @example | ||
* ```js | ||
* await roomSession.setPositions({ | ||
* positions: { | ||
* "1bf4d4fb-a3e4-4d46-80a8-3ebfdceb2a60": "reserved-1", | ||
* "e0c5be44-d6c7-438f-8cda-f859a1a0b1e7": "auto" | ||
* } | ||
* }) | ||
* ``` | ||
*/ | ||
setPositions(params: { | ||
/** Mapping of member IDs and positions to assign */ | ||
positions: VideoPositions; | ||
}): Promise<void>; | ||
/** | ||
* Assigns a position in the layout to the specified member. | ||
* | ||
* @example | ||
* ```js | ||
* await roomSession.setMemberPosition({ | ||
* memberId: "1bf4d4fb-a3e4-4d46-80a8-3ebfdceb2a60", | ||
* position: "off-canvas" | ||
* }) | ||
* ``` | ||
*/ | ||
setMemberPosition(params: { | ||
/** Id of the member to affect. */ | ||
memberId: string; | ||
/** Position to assign in the layout. */ | ||
position: VideoPosition; | ||
}): Promise<void>; | ||
/** | ||
* Obtains a list of recordings for the current room session. | ||
@@ -332,7 +367,2 @@ * | ||
* | ||
* @param params.url The url (http, https, rtmp, rtmps) of the stream to | ||
* reproduce. | ||
* @param params.volume The audio volume at which to play the stream. Values | ||
* range from -50 to 50, with a default of 0. | ||
* | ||
* @example | ||
@@ -345,6 +375,57 @@ * ```typescript | ||
play(params: { | ||
/** The url (http, https, rtmp, rtmps) of the stream to reproduce. */ | ||
url: string; | ||
/** | ||
* The audio volume at which to play the stream. Values range from -50 to | ||
* 50, with a default of 0. | ||
*/ | ||
volume?: number; | ||
/** | ||
* Positions to assign as soon as the playback starts. You can use the | ||
* special keywork `self` to refer to the id of the playback. | ||
*/ | ||
positions?: VideoPositions; | ||
}): Promise<Rooms.RoomSessionPlayback>; | ||
/** | ||
* Assigns custom metadata to the RoomSession. You can use this to store | ||
* metadata whose meaning is entirely defined by your application. | ||
* | ||
* Note that calling this method overwrites any metadata that had been | ||
* previously set on this RoomSession. | ||
* | ||
* @param meta The metadata object to assign to the RoomSession. | ||
* | ||
* @example | ||
* ```js | ||
* await roomSession.setMeta({ foo: 'bar' }) | ||
* ``` | ||
*/ | ||
setMeta(meta: Record<string, unknown>): Rooms.SetMeta; | ||
/** | ||
* Assigns custom metadata to the specified RoomSession member. You can use | ||
* this to store metadata whose meaning is entirely defined by your | ||
* application. | ||
* | ||
* Note that calling this method overwrites any metadata that had been | ||
* previously set on the specified member. | ||
* | ||
* @param params.memberId Id of the member to affect. | ||
* @param params.meta The medatada object to assign to the member. | ||
* | ||
* @example | ||
* Setting metadata for a member: | ||
* ```js | ||
* await roomSession.setMemberMeta({ | ||
* memberId: 'de550c0c-3fac-4efd-b06f-b5b8614b8966' // you can get this from getMembers() | ||
* meta: { | ||
* email: 'joe@example.com' | ||
* } | ||
* }) | ||
* ``` | ||
*/ | ||
setMemberMeta(params: { | ||
memberId: string; | ||
meta: Record<string, unknown>; | ||
}): Rooms.SetMemberMeta; | ||
/** | ||
* Listens for the events for which you have provided event handlers and | ||
@@ -480,2 +561,4 @@ * returns the {@link RoomSessionFullState} that contains the full state of | ||
constructor(options: BaseComponentOptions<RealTimeRoomApiEvents>); | ||
/** @internal */ | ||
protected _internal_on(event: keyof RealTimeRoomApiEvents, fn: EventEmitter.EventListener<RealTimeRoomApiEvents, any>): EventEmitter<RealTimeRoomApiEvents, any>; | ||
on(event: keyof RealTimeRoomApiEvents, fn: EventEmitter.EventListener<RealTimeRoomApiEvents, any>): EventEmitter<RealTimeRoomApiEvents, any>; | ||
@@ -493,2 +576,4 @@ once(event: keyof RealTimeRoomApiEvents, fn: EventEmitter.EventListener<RealTimeRoomApiEvents, any>): EventEmitter<RealTimeRoomApiEvents, any>; | ||
/** @internal */ | ||
protected getCompoundEvents(): Map<any, any>; | ||
/** @internal */ | ||
protected getEmitterTransforms(): Map<EmitterTransformsEvents | EmitterTransformsEvents[], EventTransform>; | ||
@@ -495,0 +580,0 @@ } |
@@ -45,4 +45,4 @@ import type { AssertSameType, UserOptions } from '@signalwire/core'; | ||
/** @ignore */ | ||
declare const VideoClient: new (options: VideoClientOptions) => VideoClient; | ||
declare const VideoClient: new (options?: VideoClientOptions | undefined) => VideoClient; | ||
export { VideoClient as Client }; | ||
//# sourceMappingURL=VideoClient.d.ts.map |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "3.0.0-beta.7", | ||
"version": "3.0.0-beta.8", | ||
"main": "dist/index.node.js", | ||
@@ -38,3 +38,3 @@ "beta": true, | ||
"build": "tsc --project tsconfig.build.json && sw-build --node", | ||
"test": "NODE_ENV=test jest", | ||
"test": "NODE_ENV=test jest --detectOpenHandles --forceExit", | ||
"prepublishOnly": "npm run build", | ||
@@ -47,9 +47,9 @@ "docs": "npm run docs:md && npm run docs:html", | ||
"dependencies": { | ||
"@signalwire/core": "3.6.0", | ||
"ws": "^8.4.0" | ||
"@signalwire/core": "3.7.0", | ||
"ws": "^8.5.0" | ||
}, | ||
"devDependencies": { | ||
"@types/ws": "^8.2.2" | ||
"@types/ws": "^8.5.3" | ||
}, | ||
"types": "dist/realtime-api/src/index.d.ts" | ||
} |
import { RealtimeClient } from './Client' | ||
import { clientConnect } from './clientConnect' | ||
import { clientConnect as baseClientConnect } from './clientConnect' | ||
export const clientProxyFactory = (client: RealtimeClient) => { | ||
interface ClientInterceptors { | ||
connect?: (client: RealtimeClient) => Promise<void | RealtimeClient> | ||
} | ||
const defaultInterceptors: ClientInterceptors = { | ||
connect: baseClientConnect, | ||
} | ||
export const clientProxyFactory = ( | ||
client: RealtimeClient, | ||
interceptors: ClientInterceptors = defaultInterceptors | ||
) => { | ||
const clientConnect = interceptors.connect || baseClientConnect | ||
// Client interceptors | ||
@@ -6,0 +19,0 @@ const clientOn: RealtimeClient['on'] = (...args) => { |
@@ -8,6 +8,15 @@ import { | ||
} from '@signalwire/core' | ||
import { setupInternals } from '../utils/internals' | ||
import { Client, RealtimeClient } from './Client' | ||
const CLIENTS_MAP: Map<string, RealtimeClient> = new Map() | ||
export interface ClientConfig { | ||
client: RealtimeClient | ||
store: ReturnType<typeof configureStore> | ||
emitter: EventEmitter<any> | ||
} | ||
export type ClientCache = Map<string, ClientConfig> | ||
const CLIENTS_MAP: ClientCache = new Map() | ||
const getClientKey = ({ | ||
@@ -36,3 +45,3 @@ project, | ||
responses: 'onSuccess', | ||
} | ||
}, | ||
})(userOptions) | ||
@@ -43,9 +52,11 @@ | ||
export const getClient = (userOptions: { | ||
export const getClient = ({ | ||
cache = CLIENTS_MAP, | ||
...userOptions | ||
}: { | ||
project: string | ||
token: string | ||
logLevel?: UserOptions['logLevel'] | ||
store: ReturnType<typeof configureStore> | ||
emitter: EventEmitter | ||
}): RealtimeClient => { | ||
cache?: ClientCache | ||
}): ClientConfig => { | ||
const clientKey = getClientKey({ | ||
@@ -56,12 +67,20 @@ project: userOptions.project, | ||
if (CLIENTS_MAP.has(clientKey)) { | ||
if (cache.has(clientKey)) { | ||
// @ts-expect-error | ||
return CLIENTS_MAP.get(clientKey) | ||
return cache.get(clientKey) | ||
} else { | ||
const client = createClient(userOptions) | ||
CLIENTS_MAP.set(clientKey, client) | ||
return client | ||
const { emitter, store } = setupInternals(userOptions) | ||
const client = createClient({ | ||
...userOptions, | ||
store, | ||
emitter, | ||
}) | ||
const config: ClientConfig = { | ||
client, | ||
store, | ||
emitter, | ||
} | ||
cache.set(clientKey, config) | ||
return config | ||
} | ||
} |
export * from './Client' | ||
export * from './getClient' | ||
export * from './clientConnect' | ||
export * from './clientProxyFactory' | ||
export * from './getProxiedClient' | ||
export * from './setupClient' |
@@ -54,1 +54,26 @@ /** | ||
export * from './createClient' | ||
/** | ||
* Access the Chat API Consumer. You can instantiate a {@link Chat.Client} to | ||
* subscribe to Chat events. Please check {@link Chat.ChatClientApiEvents} | ||
* for the full list of events that a {@link Chat.Client} can subscribe to. | ||
* | ||
* ### Example | ||
* | ||
* The following example logs the messages sent to the "welcome" channel. | ||
* | ||
* ```javascript | ||
* const chatClient = new Chat.Client({ | ||
* project: '<project-id>', | ||
* token: '<api-token>' | ||
* }) | ||
* | ||
* chatClient.on('message', m => console.log(m)) | ||
* | ||
* await chatClient.subscribe("welcome") | ||
* ``` | ||
*/ | ||
export * as Chat from './chat/Chat' | ||
/** @ignore */ | ||
export * from './configure' |
import { configureStore, getEventEmitter, UserOptions } from '@signalwire/core' | ||
import { getConfig } from '../configure' | ||
import { Session } from '../Session' | ||
@@ -30,8 +31,8 @@ | ||
const getToken = (userToken?: string) => { | ||
// TODO: read from global store | ||
const token = userToken || process.env.SW_TOKEN | ||
const globalConfig = getConfig() | ||
const token = userToken || globalConfig.token || process.env.SW_TOKEN | ||
if (!token) { | ||
// TODO: Add error message | ||
throw new Error('Missing token') | ||
throw new Error('Missing `token`') | ||
} | ||
@@ -43,8 +44,8 @@ | ||
const getProject = (userProject?: string) => { | ||
// TODO: read from global store | ||
const project = userProject || process.env.SW_PROJECT | ||
const globalConfig = getConfig() | ||
const project = userProject || globalConfig.project || process.env.SW_PROJECT | ||
if (!project) { | ||
// TODO: Add error message | ||
throw new Error('Missing Project') | ||
throw new Error('Missing `project`') | ||
} | ||
@@ -55,10 +56,12 @@ | ||
export const getCredentials = (options: { | ||
interface GetCredentialsOptions { | ||
token?: string | ||
project?: string | ||
}) => { | ||
const project = getProject(options.project) | ||
const token = getToken(options.token) | ||
} | ||
export const getCredentials = (options?: GetCredentialsOptions) => { | ||
const project = getProject(options?.project) | ||
const token = getToken(options?.token) | ||
return { project, token } | ||
} |
@@ -10,3 +10,3 @@ import { actions } from '@signalwire/core' | ||
const { store, session, emitter } = configureFullStack() | ||
const { store, session, emitter, destroy } = configureFullStack() | ||
@@ -46,2 +46,6 @@ beforeEach(() => { | ||
afterAll(() => { | ||
destroy() | ||
}) | ||
it('should have all the custom methods defined', () => { | ||
@@ -180,3 +184,3 @@ expect(roomSession.videoMute).toBeDefined() | ||
it('should automatically call subscribe when attaching events', async () => { | ||
const { store, emitter } = configureFullStack() | ||
const { store, emitter, destroy } = configureFullStack() | ||
const room = createRoomSessionObject({ | ||
@@ -196,4 +200,6 @@ store, | ||
expect(room.debouncedSubscribe).toHaveBeenCalledTimes(2) | ||
destroy() | ||
}) | ||
}) | ||
}) |
@@ -28,2 +28,5 @@ import { | ||
EventEmitter, | ||
VideoPosition, | ||
VideoPositions, | ||
MemberPosition, | ||
} from '@signalwire/core' | ||
@@ -36,2 +39,3 @@ import { RealTimeRoomApiEvents } from '../types' | ||
} from './RoomSessionMember' | ||
import { memberPositionWorker } from './memberPosition/workers' | ||
@@ -306,4 +310,2 @@ type EmitterTransformsEvents = | ||
* with {@link getLayouts}. | ||
* @param params | ||
* @param params.name name of the layout | ||
* | ||
@@ -316,21 +318,44 @@ * @example Set the 6x6 layout: | ||
setLayout(params: { | ||
/** Name of the layout */ | ||
name: string | ||
// positions?: Record< | ||
// string, | ||
// 'self' | 'standard' | `standard-${number}` | 'off-canvas' | ||
// > | ||
/** Positions to assign as soon as the new layout is set. */ | ||
positions?: VideoPositions | ||
}): Rooms.SetLayout | ||
/** | ||
* Assigns a position in the layout for multiple members. | ||
* | ||
* @example | ||
* ```js | ||
* await roomSession.setPositions({ | ||
* positions: { | ||
* "1bf4d4fb-a3e4-4d46-80a8-3ebfdceb2a60": "reserved-1", | ||
* "e0c5be44-d6c7-438f-8cda-f859a1a0b1e7": "auto" | ||
* } | ||
* }) | ||
* ``` | ||
*/ | ||
setPositions(params: { | ||
/** Mapping of member IDs and positions to assign */ | ||
positions: VideoPositions | ||
}): Promise<void> | ||
// setPositions(params: { | ||
// positions: Record< | ||
// string, | ||
// 'self' | 'standard' | `standard-${number}` | 'off-canvas' | ||
// > | ||
// }): Promise<void> | ||
/** | ||
* Assigns a position in the layout to the specified member. | ||
* | ||
* @example | ||
* ```js | ||
* await roomSession.setMemberPosition({ | ||
* memberId: "1bf4d4fb-a3e4-4d46-80a8-3ebfdceb2a60", | ||
* position: "off-canvas" | ||
* }) | ||
* ``` | ||
*/ | ||
setMemberPosition(params: { | ||
/** Id of the member to affect. */ | ||
memberId: string | ||
/** Position to assign in the layout. */ | ||
position: VideoPosition | ||
}): Promise<void> | ||
// setMemberPosition(params: { | ||
// memberId?: string | ||
// position: 'self' | 'standard' | `standard-${number}` | 'off-canvas' | ||
// }): Promise<void> | ||
/** | ||
@@ -345,3 +370,3 @@ * Obtains a list of recordings for the current room session. | ||
* ``` | ||
* | ||
* | ||
* @returns The returned objects contain all the properties of a | ||
@@ -367,3 +392,3 @@ * {@link RoomSessionRecording}, but no methods. | ||
* Obtains a list of playbacks for the current room session. | ||
* | ||
* | ||
* @example | ||
@@ -386,7 +411,2 @@ * ```js | ||
* | ||
* @param params.url The url (http, https, rtmp, rtmps) of the stream to | ||
* reproduce. | ||
* @param params.volume The audio volume at which to play the stream. Values | ||
* range from -50 to 50, with a default of 0. | ||
* | ||
* @example | ||
@@ -399,11 +419,60 @@ * ```typescript | ||
play(params: { | ||
/** The url (http, https, rtmp, rtmps) of the stream to reproduce. */ | ||
url: string | ||
/** | ||
* The audio volume at which to play the stream. Values range from -50 to | ||
* 50, with a default of 0. | ||
*/ | ||
volume?: number | ||
// positions?: Record< | ||
// string, | ||
// 'self' | 'standard' | `standard-${number}` | 'off-canvas' | ||
// > | ||
/** | ||
* Positions to assign as soon as the playback starts. You can use the | ||
* special keywork `self` to refer to the id of the playback. | ||
*/ | ||
positions?: VideoPositions | ||
}): Promise<Rooms.RoomSessionPlayback> | ||
/** | ||
* Assigns custom metadata to the RoomSession. You can use this to store | ||
* metadata whose meaning is entirely defined by your application. | ||
* | ||
* Note that calling this method overwrites any metadata that had been | ||
* previously set on this RoomSession. | ||
* | ||
* @param meta The metadata object to assign to the RoomSession. | ||
* | ||
* @example | ||
* ```js | ||
* await roomSession.setMeta({ foo: 'bar' }) | ||
* ``` | ||
*/ | ||
setMeta(meta: Record<string, unknown>): Rooms.SetMeta | ||
/** | ||
* Assigns custom metadata to the specified RoomSession member. You can use | ||
* this to store metadata whose meaning is entirely defined by your | ||
* application. | ||
* | ||
* Note that calling this method overwrites any metadata that had been | ||
* previously set on the specified member. | ||
* | ||
* @param params.memberId Id of the member to affect. | ||
* @param params.meta The medatada object to assign to the member. | ||
* | ||
* @example | ||
* Setting metadata for a member: | ||
* ```js | ||
* await roomSession.setMemberMeta({ | ||
* memberId: 'de550c0c-3fac-4efd-b06f-b5b8614b8966' // you can get this from getMembers() | ||
* meta: { | ||
* email: 'joe@example.com' | ||
* } | ||
* }) | ||
* ``` | ||
*/ | ||
setMemberMeta(params: { | ||
memberId: string | ||
meta: Record<string, unknown> | ||
}): Rooms.SetMemberMeta | ||
/** | ||
* Listens for the events for which you have provided event handlers and | ||
@@ -548,4 +617,16 @@ * returns the {@link RoomSessionFullState} that contains the full state of | ||
this.debouncedSubscribe = debounce(this.subscribe, 100) | ||
this.setWorker('memberPositionWorker', { | ||
worker: memberPositionWorker, | ||
}) | ||
this.attachWorkers() | ||
} | ||
/** @internal */ | ||
protected _internal_on( | ||
event: keyof RealTimeRoomApiEvents, | ||
fn: EventEmitter.EventListener<RealTimeRoomApiEvents, any> | ||
) { | ||
return super.on(event, fn) | ||
} | ||
on( | ||
@@ -598,2 +679,9 @@ event: keyof RealTimeRoomApiEvents, | ||
/** @internal */ | ||
protected override getCompoundEvents() { | ||
return new Map<any, any>([ | ||
...MemberPosition.MEMBER_POSITION_COMPOUND_EVENTS, | ||
]) | ||
} | ||
/** @internal */ | ||
protected getEmitterTransforms() { | ||
@@ -773,4 +861,4 @@ return new Map< | ||
setLayout: Rooms.setLayout, | ||
// setPositions: Rooms.setPositions, | ||
// setMemberPosition: Rooms.setMemberPosition, | ||
setPositions: Rooms.setPositions, | ||
setMemberPosition: Rooms.setMemberPosition, | ||
getRecordings: Rooms.getRecordings, | ||
@@ -780,2 +868,4 @@ startRecording: Rooms.startRecording, | ||
play: Rooms.play, | ||
setMeta: Rooms.setMeta, | ||
setMemberMeta: Rooms.setMemberMeta, | ||
}) | ||
@@ -782,0 +872,0 @@ |
@@ -10,3 +10,3 @@ import { actions } from '@signalwire/core' | ||
const memberId = '483c60ba-b776-4051-834a-5575c4b7cffe' | ||
const { store, session, emitter } = configureFullStack() | ||
const { store, session, emitter, destroy } = configureFullStack() | ||
@@ -52,2 +52,6 @@ beforeEach(() => { | ||
afterAll(() => { | ||
destroy() | ||
}) | ||
const expectExecute = (payload: any) => { | ||
@@ -54,0 +58,0 @@ // @ts-expect-error |
@@ -8,3 +8,3 @@ import { actions } from '@signalwire/core' | ||
const { store, session, emitter } = configureFullStack() | ||
const { store, session, emitter, destroy } = configureFullStack() | ||
beforeEach(() => { | ||
@@ -23,2 +23,6 @@ // remove all listeners before each run | ||
afterAll(() => { | ||
destroy() | ||
}) | ||
it('should not invoke execute without event listeners', async () => { | ||
@@ -49,3 +53,3 @@ await video.subscribe() | ||
) | ||
const eventChannelTwo = 'room.<uuid-one>' | ||
const eventChannelTwo = 'room.<uuid-two>' | ||
const secondRoom = JSON.parse( | ||
@@ -126,3 +130,3 @@ `{"jsonrpc":"2.0","id":"uuid1","method":"signalwire.event","params":{"params":{"room":{"recording":false,"room_session_id":"session-two","name":"Second Room","hide_video_muted":false,"music_on_hold":false,"room_id":"room_id","event_channel":"${eventChannelTwo}"},"room_session_id":"session-two","room_id":"room_id","room_session":{"recording":false,"name":"Second Room","hide_video_muted":false,"id":"session-two","music_on_hold":false,"room_id":"room_id","event_channel":"${eventChannelTwo}"}},"timestamp":1631692502.1308,"event_type":"video.room.started","event_channel":"video.rooms.4b7ae78a-d02e-4889-a63b-08b156d5916e"}}` | ||
room.on('member.updated.audioMuted', jest.fn) | ||
room.on('member.joined', jest.fn) | ||
// @ts-expect-error | ||
@@ -152,3 +156,3 @@ room.execute = mockExecute | ||
event_channel: eventChannelOne, | ||
events: ['video.member.updated', 'video.room.subscribed'], | ||
events: ['video.member.joined', 'video.room.subscribed'], | ||
}, | ||
@@ -161,3 +165,3 @@ }) | ||
event_channel: eventChannelTwo, | ||
events: ['video.member.updated', 'video.room.subscribed'], | ||
events: ['video.member.joined', 'video.room.subscribed'], | ||
}, | ||
@@ -164,0 +168,0 @@ }) |
import WS from 'jest-websocket-mock' | ||
import * as getProxiedClient from '../client/getProxiedClient' | ||
import { Client } from './VideoClient' | ||
@@ -52,25 +51,3 @@ import * as Video from './Video' | ||
describe('Automatic connect', () => { | ||
let getClientMock: jest.SpyInstance | ||
const mockedBaseClient: any = { | ||
connect: jest.fn(() => Promise.resolve()), | ||
on: jest.fn(), | ||
} | ||
beforeEach(async () => { | ||
getClientMock = jest | ||
.spyOn(getProxiedClient, 'getProxiedClient') | ||
.mockImplementationOnce(() => { | ||
return mockedBaseClient | ||
}) | ||
}) | ||
afterEach(() => { | ||
getClientMock.mockRestore() | ||
Object.values(mockedBaseClient).forEach((mock: any) => { | ||
if (typeof mock.mockRestore === 'function') { | ||
mock.mockRestore() | ||
} | ||
}) | ||
}) | ||
it('should automatically connect the underlying client', async () => { | ||
it('should automatically connect the underlying client', (done) => { | ||
const video = new Client({ | ||
@@ -83,7 +60,8 @@ // @ts-expect-error | ||
expect(mockedBaseClient.connect).toHaveBeenCalledTimes(0) | ||
video.once('room.started', () => {}) | ||
expect(mockedBaseClient.connect).toHaveBeenCalledTimes(1) | ||
video._session.on('session.connected', () => { | ||
expect(true).toEqual(true) | ||
done() | ||
}) | ||
}) | ||
@@ -128,2 +106,4 @@ }) | ||
expect(mockedVideo.subscribe).toHaveBeenCalledTimes(1) | ||
video._session.disconnect() | ||
}) | ||
@@ -179,2 +159,4 @@ }) | ||
} | ||
video._session.disconnect() | ||
}) | ||
@@ -205,4 +187,6 @@ }) | ||
}) | ||
video._session.disconnect() | ||
}) | ||
}) | ||
}) |
import type { AssertSameType, UserOptions } from '@signalwire/core' | ||
import type { RealTimeVideoApiEvents } from '../types' | ||
import { getLogger } from '@signalwire/core' | ||
import { getProxiedClient, clientConnect } from '../client/index' | ||
import { getCredentials, setupInternals } from '../utils/internals' | ||
import { setupClient, clientConnect } from '../client/index' | ||
import { createVideoObject, Video } from './Video' | ||
@@ -52,17 +51,4 @@ import { VideoClientDocs } from './VideoClient.docs' | ||
/** @ignore */ | ||
const VideoClient = function (options: VideoClientOptions) { | ||
const credentials = getCredentials({ | ||
token: options.token, | ||
project: options.project, | ||
}) | ||
const { emitter, store } = setupInternals({ | ||
...options, | ||
...credentials, | ||
}) | ||
const client = getProxiedClient({ | ||
...options, | ||
...credentials, | ||
emitter, | ||
store, | ||
}) | ||
const VideoClient = function (options?: VideoClientOptions) { | ||
const { client, store, emitter } = setupClient(options) | ||
@@ -113,3 +99,3 @@ const video = createVideoObject({ | ||
target: VideoClient, | ||
prop: keyof VideoClient | 'session', | ||
prop: keyof VideoClient, | ||
receiver: any | ||
@@ -126,4 +112,4 @@ ) { | ||
// For consistency with other constructors we'll make TS force the use of `new` | ||
} as unknown as { new (options: VideoClientOptions): VideoClient } | ||
} as unknown as { new (options?: VideoClientOptions): VideoClient } | ||
export { VideoClient as Client } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
921381
329
14295
6
+ Added@signalwire/core@3.7.0(transitive)
- Removed@signalwire/core@3.6.0(transitive)
Updated@signalwire/core@3.7.0
Updatedws@^8.5.0