@stream-io/video-client 0.0.35 → 0.0.37

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/dist/index.cjs.js CHANGED
@@ -37,39 +37,14 @@ var SDP__namespace = /*#__PURE__*/_interopNamespaceDefault(SDP);
37
37
  /**
38
38
  * @export
39
39
  */
40
- const APIErrorCodeEnum = {
41
- INTERNAL_ERROR: 'internal-error',
42
- ACCESS_KEY_ERROR: 'access-key-error',
43
- INPUT_ERROR: 'input-error',
44
- AUTH_FAILED: 'auth-failed',
45
- DUPLICATE_USERNAME: 'duplicate-username',
46
- RATE_LIMITED: 'rate-limited',
47
- NOT_FOUND: 'not-found',
48
- NOT_ALLOWED: 'not-allowed',
49
- EVENT_NOT_SUPPORTED: 'event-not-supported',
50
- CHANNEL_FEATURE_NOT_SUPPORTED: 'channel-feature-not-supported',
51
- MESSAGE_TOO_LONG: 'message-too-long',
52
- MULTIPLE_NESTING_LEVEL: 'multiple-nesting-level',
53
- PAYLOAD_TOO_BIG: 'payload-too-big',
54
- EXPIRED_TOKEN: 'expired-token',
55
- TOKEN_NOT_VALID_YET: 'token-not-valid-yet',
56
- TOKEN_USED_BEFORE_IAT: 'token-used-before-iat',
57
- INVALID_TOKEN_SIGNATURE: 'invalid-token-signature',
58
- CUSTOM_COMMAND_ENDPOINT_MISSING: 'custom-command-endpoint-missing',
59
- CUSTOM_COMMAND_ENDPOINTCALL_ERROR: 'custom-command-endpoint=call-error',
60
- CONNECTION_ID_NOT_FOUND: 'connection-id-not-found',
61
- COOL_DOWN: 'cool-down',
62
- QUERY_CHANNEL_PERMISSIONS_MISMATCH: 'query-channel-permissions-mismatch',
63
- TOO_MANY_CONNECTIONS: 'too-many-connections',
64
- NOT_SUPPORTED_IN_PUSH_V1: 'not-supported-in-push-v1',
65
- MODERATION_FAILED: 'moderation-failed',
66
- VIDEO_PROVIDER_NOT_CONFIGURED: 'video-provider-not-configured',
67
- VIDEO_INVALID_CALL_ID: 'video-invalid-call-id',
68
- VIDEO_CREATE_CALL_FAILED: 'video-create-call-failed',
69
- APP_SUSPENDED: 'app-suspended',
70
- VIDEO_NO_DATACENTERS_AVAILABLE: 'video-no-datacenters-available',
71
- VIDEO_JOIN_CALL_FAILURE: 'video-join-call-failure',
72
- QUERY_CALLS_PERMISSIONS_MISMATCH: 'query-calls-permissions-mismatch',
40
+ const AudioSettingsDefaultDeviceEnum = {
41
+ SPEAKER: 'speaker',
42
+ };
43
+ /**
44
+ * @export
45
+ */
46
+ const AudioSettingsRequestDefaultDeviceEnum = {
47
+ SPEAKER: 'speaker',
73
48
  };
74
49
  /**
75
50
  * @export
@@ -8511,7 +8486,6 @@ const registerRingingCallEventHandlers = (call) => {
8511
8486
  * @param data the data for the call.
8512
8487
  */
8513
8488
  const join = (httpClient, type, id, data) => __awaiter(void 0, void 0, void 0, function* () {
8514
- yield httpClient.connectionIdPromise;
8515
8489
  const joinCallResponse = yield doJoin(httpClient, type, id, data);
8516
8490
  const { call, credentials, members, own_capabilities } = joinCallResponse;
8517
8491
  return {
@@ -11508,7 +11482,10 @@ class StreamClient {
11508
11482
  if (this.waitForConnectPromise) {
11509
11483
  yield this.waitForConnectPromise;
11510
11484
  }
11511
- yield this.tokenManager.tokenReady();
11485
+ yield Promise.all([
11486
+ this.tokenManager.tokenReady(),
11487
+ this.connectionIdPromise,
11488
+ ]);
11512
11489
  }
11513
11490
  const requestConfig = this._enrichAxiosOptions(options);
11514
11491
  try {
@@ -11857,7 +11834,7 @@ class StreamClient {
11857
11834
  }
11858
11835
  getUserAgent() {
11859
11836
  return (this.userAgent ||
11860
- `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.34"}`);
11837
+ `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.36"}`);
11861
11838
  }
11862
11839
  setUserAgent(userAgent) {
11863
11840
  this.userAgent = userAgent;
@@ -11976,15 +11953,13 @@ class StreamVideoClient {
11976
11953
  *
11977
11954
  * @param type the type of the call.
11978
11955
  * @param id the id of the call, if not provided a unique random value is used
11979
- * @param {boolean} [ringing] whether the call should be created in the ringing state.
11980
11956
  */
11981
- this.call = (type, id, ringing) => {
11957
+ this.call = (type, id) => {
11982
11958
  return new Call({
11983
11959
  streamClient: this.streamClient,
11984
11960
  id: id,
11985
11961
  type: type,
11986
11962
  clientStore: this.writeableStateStore,
11987
- ringing,
11988
11963
  });
11989
11964
  };
11990
11965
  /**
@@ -12001,8 +11976,6 @@ class StreamVideoClient {
12001
11976
  * @param data the query data.
12002
11977
  */
12003
11978
  this.queryCalls = (data) => __awaiter(this, void 0, void 0, function* () {
12004
- if (data.watch)
12005
- yield this.streamClient.connectionIdPromise;
12006
11979
  const response = yield this.streamClient.post('/calls', data);
12007
11980
  const calls = response.calls.map((c) => {
12008
11981
  const call = new Call({
@@ -12075,6 +12048,29 @@ class StreamVideoClient {
12075
12048
  this.removeDevice = (id, userID) => __awaiter(this, void 0, void 0, function* () {
12076
12049
  return yield this.streamClient.delete('/devices', Object.assign({ id }, (userID ? { user_id: userID } : {})));
12077
12050
  });
12051
+ /**
12052
+ * A callback that can be used to create ringing calls from push notifications. If the call already exists, it will do nothing.
12053
+ * @param call_cid
12054
+ * @returns
12055
+ */
12056
+ this.onRingingCall = (call_cid) => __awaiter(this, void 0, void 0, function* () {
12057
+ // if we find the call and is already ringing, we don't need to create a new call
12058
+ // as client would have received the call.ring state because the app had WS alive when receiving push notifications
12059
+ let call = this.readOnlyStateStore.calls.find((c) => c.cid === call_cid && c.ringing);
12060
+ if (!call) {
12061
+ // if not it means that WS is not alive when receiving the push notifications and we need to fetch the call
12062
+ const [callType, callId] = call_cid.split(':');
12063
+ call = new Call({
12064
+ streamClient: this.streamClient,
12065
+ type: callType,
12066
+ id: callId,
12067
+ clientStore: this.writeableStateStore,
12068
+ ringing: true,
12069
+ });
12070
+ yield call.get();
12071
+ }
12072
+ return call;
12073
+ });
12078
12074
  /**
12079
12075
  * Connects the given anonymous user to the client.
12080
12076
  *
@@ -12588,7 +12584,8 @@ Object.defineProperty(exports, 'AxiosError', {
12588
12584
  enumerable: true,
12589
12585
  get: function () { return axios.AxiosError; }
12590
12586
  });
12591
- exports.APIErrorCodeEnum = APIErrorCodeEnum;
12587
+ exports.AudioSettingsDefaultDeviceEnum = AudioSettingsDefaultDeviceEnum;
12588
+ exports.AudioSettingsRequestDefaultDeviceEnum = AudioSettingsRequestDefaultDeviceEnum;
12592
12589
  exports.Browsers = browsers;
12593
12590
  exports.Call = Call;
12594
12591
  exports.CallState = CallState;