@microsoft/teams-js 2.0.0-beta.3-dev.68 → 2.0.0-beta.3-dev.69

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.
@@ -3446,12 +3446,21 @@ export namespace media {
3446
3446
  * @param mediaEvent indicates what the event that needs to be signaled to the host client
3447
3447
  * Optional; @param callback is used to send app if host client has successfully handled the notification event or not
3448
3448
  */
3449
- protected notifyEventToHost(mediaEvent: MediaControllerEvent, callback?: (err?: SdkError) => void): void;
3449
+ protected notifyEventToHost(mediaEvent: MediaControllerEvent, callback?: (err?: SdkError) => void): Promise<void>;
3450
3450
  /**
3451
+ * Function to programatically stop the ongoing media event
3452
+ *
3453
+ * @returns A resolved promise
3454
+ * */
3455
+ stop(): Promise<void>;
3456
+ /**
3457
+ * @deprecated
3458
+ * As of 2.0.0-beta.3, please use {@link MediaController.stop MediaController.stop(): Promise\<void\>} instead.
3459
+
3451
3460
  * Function to programatically stop the ongoing media event
3452
3461
  * Optional; @param callback is used to send app if host client has successfully stopped the event or not
3453
3462
  */
3454
- stop(callback?: (err?: SdkError) => void): void;
3463
+ stop(callback: (err?: SdkError) => void): void;
3455
3464
  }
3456
3465
  /**
3457
3466
  * Callback which will register your app to listen to lifecycle events during the video capture flow
@@ -3555,6 +3564,12 @@ export namespace media {
3555
3564
  sequence: number;
3556
3565
  file: Blob;
3557
3566
  }
3567
+ /**
3568
+ * Select an attachment using camera/gallery
3569
+ *
3570
+ * @param mediaInputs - The input params to customize the media to be selected
3571
+ * @returns A promise resolved with an array of media data or rejected with an @see SdkError
3572
+ */
3558
3573
  export function selectMedia(mediaInputs: MediaInputs): Promise<Media[]>;
3559
3574
  /**
3560
3575
  * Select an attachment using camera/gallery
@@ -1120,7 +1120,7 @@ __webpack_require__.d(__webpack_exports__, {
1120
1120
  });
1121
1121
 
1122
1122
  ;// CONCATENATED MODULE: ./src/internal/constants.ts
1123
- var version = "2.0.0-beta.3-dev.68";
1123
+ var version = "2.0.0-beta.3-dev.69";
1124
1124
  /**
1125
1125
  * @hidden
1126
1126
  * The client version when all SDK APIs started to check platform compatibility for the APIs was 1.6.0.
@@ -1748,7 +1748,7 @@ function ensureInitialized() {
1748
1748
  *
1749
1749
  * @internal
1750
1750
  */
1751
- function isAPISupportedByPlatform(requiredVersion) {
1751
+ function isCurrentSDKVersionAtLeast(requiredVersion) {
1752
1752
  if (requiredVersion === void 0) { requiredVersion = defaultSDKVersionForCompatCheck; }
1753
1753
  var value = compareSDKVersions(GlobalVars.clientSupportedSDKVersion, requiredVersion);
1754
1754
  if (isNaN(value)) {
@@ -1768,22 +1768,21 @@ function isHostClientMobile() {
1768
1768
  /**
1769
1769
  * @hidden
1770
1770
  * Helper function which indicates if current API is supported on mobile or not.
1771
- * @returns SdkError if host client is not android/ios or if the requiredVersion is not
1771
+ * @throws SdkError if host client is not android/ios or if the requiredVersion is not
1772
1772
  * supported by platform or not. Null is returned in case of success.
1773
1773
  *
1774
1774
  * @internal
1775
1775
  */
1776
- function isApiSupportedOnMobile(requiredVersion) {
1776
+ function throwExceptionIfMobileApiIsNotSupported(requiredVersion) {
1777
1777
  if (requiredVersion === void 0) { requiredVersion = defaultSDKVersionForCompatCheck; }
1778
1778
  if (!isHostClientMobile()) {
1779
1779
  var notSupportedError = { errorCode: ErrorCode.NOT_SUPPORTED_ON_PLATFORM };
1780
- return notSupportedError;
1780
+ throw notSupportedError;
1781
1781
  }
1782
- else if (!isAPISupportedByPlatform(requiredVersion)) {
1782
+ else if (!isCurrentSDKVersionAtLeast(requiredVersion)) {
1783
1783
  var oldPlatformError = { errorCode: ErrorCode.OLD_PLATFORM };
1784
- return oldPlatformError;
1784
+ throw oldPlatformError;
1785
1785
  }
1786
- return null;
1787
1786
  }
1788
1787
  /**
1789
1788
  * @hidden
@@ -4460,21 +4459,20 @@ function decodeAttachment(attachment, mimeType) {
4460
4459
  }
4461
4460
  /**
4462
4461
  * @hidden
4463
- * Function returns null if the media call is supported on current mobile version, else SdkError.
4464
- *
4462
+ * Function throws an SdkError if the media call is not supported on current mobile version, else undefined.
4463
+ * @throws an SdkError if the media call is not supported
4465
4464
  * @internal
4466
4465
  */
4467
- function isMediaCallSupportedOnMobile(mediaInputs) {
4466
+ function throwExceptionIfMediaCallIsNotSupportedOnMobile(mediaInputs) {
4468
4467
  if (isMediaCallForVideoAndImageInputs(mediaInputs)) {
4469
- return isApiSupportedOnMobile(videoAndImageMediaAPISupportVersion);
4468
+ return throwExceptionIfMobileApiIsNotSupported(videoAndImageMediaAPISupportVersion);
4470
4469
  }
4471
4470
  else if (isMediaCallForNonFullScreenVideoMode(mediaInputs)) {
4472
- return isApiSupportedOnMobile(nonFullScreenVideoModeAPISupportVersion);
4471
+ return throwExceptionIfMobileApiIsNotSupported(nonFullScreenVideoModeAPISupportVersion);
4473
4472
  }
4474
4473
  else if (isMediaCallForImageOutputFormats(mediaInputs)) {
4475
- return isApiSupportedOnMobile(imageOutputFormatsAPISupportVersion);
4474
+ return throwExceptionIfMobileApiIsNotSupported(imageOutputFormatsAPISupportVersion);
4476
4475
  }
4477
- return null;
4478
4476
  }
4479
4477
  /**
4480
4478
  * @hidden
@@ -4612,7 +4610,6 @@ function validatePeoplePickerInput(peoplePickerInputs) {
4612
4610
  }
4613
4611
 
4614
4612
  ;// CONCATENATED MODULE: ./src/public/media.ts
4615
- /* eslint-disable @typescript-eslint/explicit-member-accessibility */
4616
4613
  var __extends = (undefined && undefined.__extends) || (function () {
4617
4614
  var extendStatics = function (d, b) {
4618
4615
  extendStatics = Object.setPrototypeOf ||
@@ -4667,7 +4664,7 @@ var media;
4667
4664
  if (!GlobalVars.isFramelessWindow) {
4668
4665
  throw { errorCode: ErrorCode.NOT_SUPPORTED_ON_PLATFORM };
4669
4666
  }
4670
- if (!isAPISupportedByPlatform(captureImageMobileSupportVersion)) {
4667
+ if (!isCurrentSDKVersionAtLeast(captureImageMobileSupportVersion)) {
4671
4668
  throw { errorCode: ErrorCode.OLD_PLATFORM };
4672
4669
  }
4673
4670
  resolve(sendAndHandleSdkError('captureImage'));
@@ -4699,14 +4696,14 @@ var media;
4699
4696
  ensureInitialized(FrameContexts.content, FrameContexts.task);
4700
4697
  var wrappedFunction = function () {
4701
4698
  return new Promise(function (resolve) {
4702
- if (!isAPISupportedByPlatform(mediaAPISupportVersion)) {
4699
+ if (!isCurrentSDKVersionAtLeast(mediaAPISupportVersion)) {
4703
4700
  throw { errorCode: ErrorCode.OLD_PLATFORM };
4704
4701
  }
4705
4702
  if (!validateGetMediaInputs(_this.mimeType, _this.format, _this.content)) {
4706
4703
  throw { errorCode: ErrorCode.INVALID_ARGUMENTS };
4707
4704
  }
4708
4705
  // Call the new get media implementation via callbacks if the client version is greater than or equal to '2.0.0'
4709
- if (isAPISupportedByPlatform(getMediaCallbackSupportVersion)) {
4706
+ if (isCurrentSDKVersionAtLeast(getMediaCallbackSupportVersion)) {
4710
4707
  resolve(_this.getMediaViaCallback());
4711
4708
  }
4712
4709
  else {
@@ -4807,26 +4804,33 @@ var media;
4807
4804
  */
4808
4805
  MediaController.prototype.notifyEventToHost = function (mediaEvent, callback) {
4809
4806
  ensureInitialized(FrameContexts.content, FrameContexts.task);
4810
- var err = isApiSupportedOnMobile(nonFullScreenVideoModeAPISupportVersion);
4811
- if (err) {
4812
- if (callback) {
4813
- callback(err);
4814
- }
4815
- return;
4816
- }
4807
+ var mediaError;
4808
+ var promise = Promise.resolve().then(function () {
4809
+ return throwExceptionIfMobileApiIsNotSupported(nonFullScreenVideoModeAPISupportVersion);
4810
+ });
4817
4811
  var params = { mediaType: this.getMediaType(), mediaControllerEvent: mediaEvent };
4818
4812
  sendMessageToParent('media.controller', [params], function (err) {
4819
4813
  if (callback) {
4820
- callback(err);
4814
+ return callback(err);
4815
+ }
4816
+ else if (err) {
4817
+ mediaError = err;
4818
+ }
4819
+ });
4820
+ return promise
4821
+ .then(function () {
4822
+ if (mediaError) {
4823
+ throw mediaError;
4821
4824
  }
4825
+ })
4826
+ .catch(function (err) {
4827
+ throw err;
4822
4828
  });
4823
4829
  };
4824
- /**
4825
- * Function to programatically stop the ongoing media event
4826
- * Optional; @param callback is used to send app if host client has successfully stopped the event or not
4827
- */
4828
4830
  MediaController.prototype.stop = function (callback) {
4829
- this.notifyEventToHost(MediaControllerEvent.StopRecording, callback);
4831
+ var _this = this;
4832
+ var wrappedFunction = function () { return _this.notifyEventToHost(MediaControllerEvent.StopRecording, callback); };
4833
+ return callCallbackWithErrorOrResultFromPromiseAndReturnPromise(wrappedFunction, callback);
4830
4834
  };
4831
4835
  return MediaController;
4832
4836
  }());
@@ -4916,13 +4920,10 @@ var media;
4916
4920
  ensureInitialized(FrameContexts.content, FrameContexts.task);
4917
4921
  var wrappedFunction = function () {
4918
4922
  return new Promise(function (resolve) {
4919
- if (!isAPISupportedByPlatform(mediaAPISupportVersion)) {
4923
+ if (!isCurrentSDKVersionAtLeast(mediaAPISupportVersion)) {
4920
4924
  throw { errorCode: ErrorCode.OLD_PLATFORM };
4921
4925
  }
4922
- var err = isMediaCallSupportedOnMobile(mediaInputs);
4923
- if (err) {
4924
- throw err;
4925
- }
4926
+ throwExceptionIfMediaCallIsNotSupportedOnMobile(mediaInputs);
4926
4927
  if (!validateSelectMediaInputs(mediaInputs)) {
4927
4928
  throw { errorCode: ErrorCode.INVALID_ARGUMENTS };
4928
4929
  }
@@ -4957,7 +4958,7 @@ var media;
4957
4958
  ensureInitialized(FrameContexts.content, FrameContexts.task);
4958
4959
  var wrappedFunction = function () {
4959
4960
  return new Promise(function (resolve) {
4960
- if (!isAPISupportedByPlatform(mediaAPISupportVersion)) {
4961
+ if (!isCurrentSDKVersionAtLeast(mediaAPISupportVersion)) {
4961
4962
  throw { errorCode: ErrorCode.OLD_PLATFORM };
4962
4963
  }
4963
4964
  if (!validateViewImagesInput(uriList)) {
@@ -5002,7 +5003,7 @@ var media;
5002
5003
  GlobalVars.hostClientType === HostClientType.teamsDisplays) {
5003
5004
  throw { errorCode: ErrorCode.NOT_SUPPORTED_ON_PLATFORM };
5004
5005
  }
5005
- if (!isAPISupportedByPlatform(scanBarCodeAPIMobileSupportVersion)) {
5006
+ if (!isCurrentSDKVersionAtLeast(scanBarCodeAPIMobileSupportVersion)) {
5006
5007
  throw { errorCode: ErrorCode.OLD_PLATFORM };
5007
5008
  }
5008
5009
  if (!validateScanBarCodeInput(config)) {
@@ -5040,7 +5041,7 @@ var location_location;
5040
5041
  location_1.getLocation = getLocation;
5041
5042
  function getLocationHelper(props) {
5042
5043
  return new Promise(function (resolve) {
5043
- if (!isAPISupportedByPlatform(locationAPIsRequiredVersion)) {
5044
+ if (!isCurrentSDKVersionAtLeast(locationAPIsRequiredVersion)) {
5044
5045
  throw { errorCode: ErrorCode.OLD_PLATFORM };
5045
5046
  }
5046
5047
  if (!props) {
@@ -5056,7 +5057,7 @@ var location_location;
5056
5057
  location_1.showLocation = showLocation;
5057
5058
  function showLocationHelper(location) {
5058
5059
  return new Promise(function (resolve) {
5059
- if (!isAPISupportedByPlatform(locationAPIsRequiredVersion)) {
5060
+ if (!isCurrentSDKVersionAtLeast(locationAPIsRequiredVersion)) {
5060
5061
  throw { errorCode: ErrorCode.OLD_PLATFORM };
5061
5062
  }
5062
5063
  if (!location) {
@@ -5448,7 +5449,7 @@ var people;
5448
5449
  people_1.selectPeople = selectPeople;
5449
5450
  function selectPeopleHelper(peoplePickerInputs) {
5450
5451
  return new Promise(function (resolve) {
5451
- if (!isAPISupportedByPlatform(peoplePickerRequiredVersion)) {
5452
+ if (!isCurrentSDKVersionAtLeast(peoplePickerRequiredVersion)) {
5452
5453
  throw { errorCode: ErrorCode.OLD_PLATFORM };
5453
5454
  }
5454
5455
  if (!validatePeoplePickerInput(peoplePickerInputs)) {
@@ -6687,7 +6688,7 @@ var legacy;
6687
6688
  GlobalVars.hostClientType === HostClientType.teamsRoomsAndroid ||
6688
6689
  GlobalVars.hostClientType === HostClientType.teamsPhones ||
6689
6690
  GlobalVars.hostClientType === HostClientType.teamsDisplays) &&
6690
- !isAPISupportedByPlatform(getUserJoinedTeamsSupportedAndroidClientVersion)) {
6691
+ !isCurrentSDKVersionAtLeast(getUserJoinedTeamsSupportedAndroidClientVersion)) {
6691
6692
  var oldPlatformError = { errorCode: ErrorCode.OLD_PLATFORM };
6692
6693
  throw new Error(JSON.stringify(oldPlatformError));
6693
6694
  }